github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/printing/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package printing 5 6 import ( 7 "github.com/primecitizens/pcz/std/core/abi" 8 "github.com/primecitizens/pcz/std/core/mark" 9 "github.com/primecitizens/pcz/std/ffi/js" 10 "github.com/primecitizens/pcz/std/plat/js/webext/printerprovider" 11 "github.com/primecitizens/pcz/std/plat/js/webext/printing/bindings" 12 ) 13 14 type CancelJobCallbackFunc func(this js.Ref) js.Ref 15 16 func (fn CancelJobCallbackFunc) Register() js.Func[func()] { 17 return js.RegisterCallback[func()]( 18 fn, abi.FuncPCABIInternal(fn), 19 ) 20 } 21 22 func (fn CancelJobCallbackFunc) DispatchCallback( 23 targetPC uintptr, ctx *js.CallbackContext, 24 ) { 25 args := ctx.Args() 26 if len(args) != 0+1 /* js this */ || 27 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 28 js.ThrowInvalidCallbackInvocation() 29 } 30 31 if ctx.Return(fn( 32 args[0], 33 )) { 34 return 35 } 36 37 js.ThrowCallbackValueNotReturned() 38 } 39 40 type CancelJobCallback[T any] struct { 41 Fn func(arg T, this js.Ref) js.Ref 42 Arg T 43 } 44 45 func (cb *CancelJobCallback[T]) Register() js.Func[func()] { 46 return js.RegisterCallback[func()]( 47 cb, abi.FuncPCABIInternal(cb.Fn), 48 ) 49 } 50 51 func (cb *CancelJobCallback[T]) DispatchCallback( 52 targetPC uintptr, ctx *js.CallbackContext, 53 ) { 54 args := ctx.Args() 55 if len(args) != 0+1 /* js this */ || 56 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 57 js.ThrowInvalidCallbackInvocation() 58 } 59 60 if ctx.Return(cb.Fn( 61 cb.Arg, 62 args[0], 63 )) { 64 return 65 } 66 67 js.ThrowCallbackValueNotReturned() 68 } 69 70 type PrinterStatus uint32 71 72 const ( 73 _ PrinterStatus = iota 74 75 PrinterStatus_DOOR_OPEN 76 PrinterStatus_TRAY_MISSING 77 PrinterStatus_OUT_OF_INK 78 PrinterStatus_OUT_OF_PAPER 79 PrinterStatus_OUTPUT_FULL 80 PrinterStatus_PAPER_JAM 81 PrinterStatus_GENERIC_ISSUE 82 PrinterStatus_STOPPED 83 PrinterStatus_UNREACHABLE 84 PrinterStatus_EXPIRED_CERTIFICATE 85 PrinterStatus_AVAILABLE 86 ) 87 88 func (PrinterStatus) FromRef(str js.Ref) PrinterStatus { 89 return PrinterStatus(bindings.ConstOfPrinterStatus(str)) 90 } 91 92 func (x PrinterStatus) String() (string, bool) { 93 switch x { 94 case PrinterStatus_DOOR_OPEN: 95 return "DOOR_OPEN", true 96 case PrinterStatus_TRAY_MISSING: 97 return "TRAY_MISSING", true 98 case PrinterStatus_OUT_OF_INK: 99 return "OUT_OF_INK", true 100 case PrinterStatus_OUT_OF_PAPER: 101 return "OUT_OF_PAPER", true 102 case PrinterStatus_OUTPUT_FULL: 103 return "OUTPUT_FULL", true 104 case PrinterStatus_PAPER_JAM: 105 return "PAPER_JAM", true 106 case PrinterStatus_GENERIC_ISSUE: 107 return "GENERIC_ISSUE", true 108 case PrinterStatus_STOPPED: 109 return "STOPPED", true 110 case PrinterStatus_UNREACHABLE: 111 return "UNREACHABLE", true 112 case PrinterStatus_EXPIRED_CERTIFICATE: 113 return "EXPIRED_CERTIFICATE", true 114 case PrinterStatus_AVAILABLE: 115 return "AVAILABLE", true 116 default: 117 return "", false 118 } 119 } 120 121 type GetPrinterInfoCallbackFunc func(this js.Ref, response *GetPrinterInfoResponse) js.Ref 122 123 func (fn GetPrinterInfoCallbackFunc) Register() js.Func[func(response *GetPrinterInfoResponse)] { 124 return js.RegisterCallback[func(response *GetPrinterInfoResponse)]( 125 fn, abi.FuncPCABIInternal(fn), 126 ) 127 } 128 129 func (fn GetPrinterInfoCallbackFunc) DispatchCallback( 130 targetPC uintptr, ctx *js.CallbackContext, 131 ) { 132 args := ctx.Args() 133 if len(args) != 1+1 /* js this */ || 134 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 135 js.ThrowInvalidCallbackInvocation() 136 } 137 var arg0 GetPrinterInfoResponse 138 arg0.UpdateFrom(args[0+1]) 139 defer arg0.FreeMembers(true) 140 141 if ctx.Return(fn( 142 args[0], 143 144 mark.NoEscape(&arg0), 145 )) { 146 return 147 } 148 149 js.ThrowCallbackValueNotReturned() 150 } 151 152 type GetPrinterInfoCallback[T any] struct { 153 Fn func(arg T, this js.Ref, response *GetPrinterInfoResponse) js.Ref 154 Arg T 155 } 156 157 func (cb *GetPrinterInfoCallback[T]) Register() js.Func[func(response *GetPrinterInfoResponse)] { 158 return js.RegisterCallback[func(response *GetPrinterInfoResponse)]( 159 cb, abi.FuncPCABIInternal(cb.Fn), 160 ) 161 } 162 163 func (cb *GetPrinterInfoCallback[T]) DispatchCallback( 164 targetPC uintptr, ctx *js.CallbackContext, 165 ) { 166 args := ctx.Args() 167 if len(args) != 1+1 /* js this */ || 168 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 169 js.ThrowInvalidCallbackInvocation() 170 } 171 var arg0 GetPrinterInfoResponse 172 arg0.UpdateFrom(args[0+1]) 173 defer arg0.FreeMembers(true) 174 175 if ctx.Return(cb.Fn( 176 cb.Arg, 177 args[0], 178 179 mark.NoEscape(&arg0), 180 )) { 181 return 182 } 183 184 js.ThrowCallbackValueNotReturned() 185 } 186 187 type GetPrinterInfoResponse struct { 188 // Capabilities is "GetPrinterInfoResponse.capabilities" 189 // 190 // Optional 191 Capabilities js.Object 192 // Status is "GetPrinterInfoResponse.status" 193 // 194 // Optional 195 Status PrinterStatus 196 197 FFI_USE bool 198 } 199 200 // FromRef calls UpdateFrom and returns a GetPrinterInfoResponse with all fields set. 201 func (p GetPrinterInfoResponse) FromRef(ref js.Ref) GetPrinterInfoResponse { 202 p.UpdateFrom(ref) 203 return p 204 } 205 206 // New creates a new GetPrinterInfoResponse in the application heap. 207 func (p GetPrinterInfoResponse) New() js.Ref { 208 return bindings.GetPrinterInfoResponseJSLoad( 209 js.Pointer(&p), js.True, 0, 210 ) 211 } 212 213 // UpdateFrom copies value of all fields of the heap object to p. 214 func (p *GetPrinterInfoResponse) UpdateFrom(ref js.Ref) { 215 bindings.GetPrinterInfoResponseJSStore( 216 js.Pointer(p), ref, 217 ) 218 } 219 220 // Update writes all fields of the p to the heap object referenced by ref. 221 func (p *GetPrinterInfoResponse) Update(ref js.Ref) { 222 bindings.GetPrinterInfoResponseJSLoad( 223 js.Pointer(p), js.False, ref, 224 ) 225 } 226 227 // FreeMembers frees fields with heap reference, if recursive is true 228 // free all heap references reachable from p. 229 func (p *GetPrinterInfoResponse) FreeMembers(recursive bool) { 230 js.Free( 231 p.Capabilities.Ref(), 232 ) 233 p.Capabilities = p.Capabilities.FromRef(js.Undefined) 234 } 235 236 type GetPrintersCallbackFunc func(this js.Ref, printers js.Array[Printer]) js.Ref 237 238 func (fn GetPrintersCallbackFunc) Register() js.Func[func(printers js.Array[Printer])] { 239 return js.RegisterCallback[func(printers js.Array[Printer])]( 240 fn, abi.FuncPCABIInternal(fn), 241 ) 242 } 243 244 func (fn GetPrintersCallbackFunc) DispatchCallback( 245 targetPC uintptr, ctx *js.CallbackContext, 246 ) { 247 args := ctx.Args() 248 if len(args) != 1+1 /* js this */ || 249 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 250 js.ThrowInvalidCallbackInvocation() 251 } 252 253 if ctx.Return(fn( 254 args[0], 255 256 js.Array[Printer]{}.FromRef(args[0+1]), 257 )) { 258 return 259 } 260 261 js.ThrowCallbackValueNotReturned() 262 } 263 264 type GetPrintersCallback[T any] struct { 265 Fn func(arg T, this js.Ref, printers js.Array[Printer]) js.Ref 266 Arg T 267 } 268 269 func (cb *GetPrintersCallback[T]) Register() js.Func[func(printers js.Array[Printer])] { 270 return js.RegisterCallback[func(printers js.Array[Printer])]( 271 cb, abi.FuncPCABIInternal(cb.Fn), 272 ) 273 } 274 275 func (cb *GetPrintersCallback[T]) DispatchCallback( 276 targetPC uintptr, ctx *js.CallbackContext, 277 ) { 278 args := ctx.Args() 279 if len(args) != 1+1 /* js this */ || 280 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 281 js.ThrowInvalidCallbackInvocation() 282 } 283 284 if ctx.Return(cb.Fn( 285 cb.Arg, 286 args[0], 287 288 js.Array[Printer]{}.FromRef(args[0+1]), 289 )) { 290 return 291 } 292 293 js.ThrowCallbackValueNotReturned() 294 } 295 296 type PrinterSource uint32 297 298 const ( 299 _ PrinterSource = iota 300 301 PrinterSource_USER 302 PrinterSource_POLICY 303 ) 304 305 func (PrinterSource) FromRef(str js.Ref) PrinterSource { 306 return PrinterSource(bindings.ConstOfPrinterSource(str)) 307 } 308 309 func (x PrinterSource) String() (string, bool) { 310 switch x { 311 case PrinterSource_USER: 312 return "USER", true 313 case PrinterSource_POLICY: 314 return "POLICY", true 315 default: 316 return "", false 317 } 318 } 319 320 type Printer struct { 321 // Id is "Printer.id" 322 // 323 // Optional 324 Id js.String 325 // Name is "Printer.name" 326 // 327 // Optional 328 Name js.String 329 // Description is "Printer.description" 330 // 331 // Optional 332 Description js.String 333 // Uri is "Printer.uri" 334 // 335 // Optional 336 Uri js.String 337 // Source is "Printer.source" 338 // 339 // Optional 340 Source PrinterSource 341 // IsDefault is "Printer.isDefault" 342 // 343 // Optional 344 // 345 // NOTE: FFI_USE_IsDefault MUST be set to true to make this field effective. 346 IsDefault bool 347 // RecentlyUsedRank is "Printer.recentlyUsedRank" 348 // 349 // Optional 350 // 351 // NOTE: FFI_USE_RecentlyUsedRank MUST be set to true to make this field effective. 352 RecentlyUsedRank int32 353 354 FFI_USE_IsDefault bool // for IsDefault. 355 FFI_USE_RecentlyUsedRank bool // for RecentlyUsedRank. 356 357 FFI_USE bool 358 } 359 360 // FromRef calls UpdateFrom and returns a Printer with all fields set. 361 func (p Printer) FromRef(ref js.Ref) Printer { 362 p.UpdateFrom(ref) 363 return p 364 } 365 366 // New creates a new Printer in the application heap. 367 func (p Printer) New() js.Ref { 368 return bindings.PrinterJSLoad( 369 js.Pointer(&p), js.True, 0, 370 ) 371 } 372 373 // UpdateFrom copies value of all fields of the heap object to p. 374 func (p *Printer) UpdateFrom(ref js.Ref) { 375 bindings.PrinterJSStore( 376 js.Pointer(p), ref, 377 ) 378 } 379 380 // Update writes all fields of the p to the heap object referenced by ref. 381 func (p *Printer) Update(ref js.Ref) { 382 bindings.PrinterJSLoad( 383 js.Pointer(p), js.False, ref, 384 ) 385 } 386 387 // FreeMembers frees fields with heap reference, if recursive is true 388 // free all heap references reachable from p. 389 func (p *Printer) FreeMembers(recursive bool) { 390 js.Free( 391 p.Id.Ref(), 392 p.Name.Ref(), 393 p.Description.Ref(), 394 p.Uri.Ref(), 395 ) 396 p.Id = p.Id.FromRef(js.Undefined) 397 p.Name = p.Name.FromRef(js.Undefined) 398 p.Description = p.Description.FromRef(js.Undefined) 399 p.Uri = p.Uri.FromRef(js.Undefined) 400 } 401 402 type JobStatus uint32 403 404 const ( 405 _ JobStatus = iota 406 407 JobStatus_PENDING 408 JobStatus_IN_PROGRESS 409 JobStatus_FAILED 410 JobStatus_CANCELED 411 JobStatus_PRINTED 412 ) 413 414 func (JobStatus) FromRef(str js.Ref) JobStatus { 415 return JobStatus(bindings.ConstOfJobStatus(str)) 416 } 417 418 func (x JobStatus) String() (string, bool) { 419 switch x { 420 case JobStatus_PENDING: 421 return "PENDING", true 422 case JobStatus_IN_PROGRESS: 423 return "IN_PROGRESS", true 424 case JobStatus_FAILED: 425 return "FAILED", true 426 case JobStatus_CANCELED: 427 return "CANCELED", true 428 case JobStatus_PRINTED: 429 return "PRINTED", true 430 default: 431 return "", false 432 } 433 } 434 435 type Properties struct { 436 ref js.Ref 437 } 438 439 func (this Properties) Once() Properties { 440 this.ref.Once() 441 return this 442 } 443 444 func (this Properties) Ref() js.Ref { 445 return this.ref 446 } 447 448 func (this Properties) FromRef(ref js.Ref) Properties { 449 this.ref = ref 450 return this 451 } 452 453 func (this Properties) Free() { 454 this.ref.Free() 455 } 456 457 // HasFuncMAX_SUBMIT_JOB_CALLS_PER_MINUTE returns true if the static method "Properties.MAX_SUBMIT_JOB_CALLS_PER_MINUTE" exists. 458 func (this Properties) HasFuncMAX_SUBMIT_JOB_CALLS_PER_MINUTE() bool { 459 return js.True == bindings.HasFuncPropertiesMAX_SUBMIT_JOB_CALLS_PER_MINUTE( 460 this.ref, 461 ) 462 } 463 464 // FuncMAX_SUBMIT_JOB_CALLS_PER_MINUTE returns the static method "Properties.MAX_SUBMIT_JOB_CALLS_PER_MINUTE". 465 func (this Properties) FuncMAX_SUBMIT_JOB_CALLS_PER_MINUTE() (fn js.Func[func() int32]) { 466 bindings.FuncPropertiesMAX_SUBMIT_JOB_CALLS_PER_MINUTE( 467 this.ref, js.Pointer(&fn), 468 ) 469 return 470 } 471 472 // MAX_SUBMIT_JOB_CALLS_PER_MINUTE calls the static method "Properties.MAX_SUBMIT_JOB_CALLS_PER_MINUTE". 473 func (this Properties) MAX_SUBMIT_JOB_CALLS_PER_MINUTE() (ret int32) { 474 bindings.CallPropertiesMAX_SUBMIT_JOB_CALLS_PER_MINUTE( 475 this.ref, js.Pointer(&ret), 476 ) 477 478 return 479 } 480 481 // TryMAX_SUBMIT_JOB_CALLS_PER_MINUTE calls the static method "Properties.MAX_SUBMIT_JOB_CALLS_PER_MINUTE" 482 // in a try/catch block and returns (_, err, ok = false) when it went through 483 // the catch clause. 484 func (this Properties) TryMAX_SUBMIT_JOB_CALLS_PER_MINUTE() (ret int32, exception js.Any, ok bool) { 485 ok = js.True == bindings.TryPropertiesMAX_SUBMIT_JOB_CALLS_PER_MINUTE( 486 this.ref, js.Pointer(&ret), js.Pointer(&exception), 487 ) 488 489 return 490 } 491 492 // HasFuncMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE returns true if the static method "Properties.MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE" exists. 493 func (this Properties) HasFuncMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE() bool { 494 return js.True == bindings.HasFuncPropertiesMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE( 495 this.ref, 496 ) 497 } 498 499 // FuncMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE returns the static method "Properties.MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE". 500 func (this Properties) FuncMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE() (fn js.Func[func() int32]) { 501 bindings.FuncPropertiesMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE( 502 this.ref, js.Pointer(&fn), 503 ) 504 return 505 } 506 507 // MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE calls the static method "Properties.MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE". 508 func (this Properties) MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE() (ret int32) { 509 bindings.CallPropertiesMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE( 510 this.ref, js.Pointer(&ret), 511 ) 512 513 return 514 } 515 516 // TryMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE calls the static method "Properties.MAX_GET_PRINTER_INFO_CALLS_PER_MINUTE" 517 // in a try/catch block and returns (_, err, ok = false) when it went through 518 // the catch clause. 519 func (this Properties) TryMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE() (ret int32, exception js.Any, ok bool) { 520 ok = js.True == bindings.TryPropertiesMAX_GET_PRINTER_INFO_CALLS_PER_MINUTE( 521 this.ref, js.Pointer(&ret), js.Pointer(&exception), 522 ) 523 524 return 525 } 526 527 type SubmitJobCallbackFunc func(this js.Ref, response *SubmitJobResponse) js.Ref 528 529 func (fn SubmitJobCallbackFunc) Register() js.Func[func(response *SubmitJobResponse)] { 530 return js.RegisterCallback[func(response *SubmitJobResponse)]( 531 fn, abi.FuncPCABIInternal(fn), 532 ) 533 } 534 535 func (fn SubmitJobCallbackFunc) DispatchCallback( 536 targetPC uintptr, ctx *js.CallbackContext, 537 ) { 538 args := ctx.Args() 539 if len(args) != 1+1 /* js this */ || 540 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 541 js.ThrowInvalidCallbackInvocation() 542 } 543 var arg0 SubmitJobResponse 544 arg0.UpdateFrom(args[0+1]) 545 defer arg0.FreeMembers(true) 546 547 if ctx.Return(fn( 548 args[0], 549 550 mark.NoEscape(&arg0), 551 )) { 552 return 553 } 554 555 js.ThrowCallbackValueNotReturned() 556 } 557 558 type SubmitJobCallback[T any] struct { 559 Fn func(arg T, this js.Ref, response *SubmitJobResponse) js.Ref 560 Arg T 561 } 562 563 func (cb *SubmitJobCallback[T]) Register() js.Func[func(response *SubmitJobResponse)] { 564 return js.RegisterCallback[func(response *SubmitJobResponse)]( 565 cb, abi.FuncPCABIInternal(cb.Fn), 566 ) 567 } 568 569 func (cb *SubmitJobCallback[T]) DispatchCallback( 570 targetPC uintptr, ctx *js.CallbackContext, 571 ) { 572 args := ctx.Args() 573 if len(args) != 1+1 /* js this */ || 574 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 575 js.ThrowInvalidCallbackInvocation() 576 } 577 var arg0 SubmitJobResponse 578 arg0.UpdateFrom(args[0+1]) 579 defer arg0.FreeMembers(true) 580 581 if ctx.Return(cb.Fn( 582 cb.Arg, 583 args[0], 584 585 mark.NoEscape(&arg0), 586 )) { 587 return 588 } 589 590 js.ThrowCallbackValueNotReturned() 591 } 592 593 type SubmitJobStatus uint32 594 595 const ( 596 _ SubmitJobStatus = iota 597 598 SubmitJobStatus_OK 599 SubmitJobStatus_USER_REJECTED 600 ) 601 602 func (SubmitJobStatus) FromRef(str js.Ref) SubmitJobStatus { 603 return SubmitJobStatus(bindings.ConstOfSubmitJobStatus(str)) 604 } 605 606 func (x SubmitJobStatus) String() (string, bool) { 607 switch x { 608 case SubmitJobStatus_OK: 609 return "OK", true 610 case SubmitJobStatus_USER_REJECTED: 611 return "USER_REJECTED", true 612 default: 613 return "", false 614 } 615 } 616 617 type SubmitJobResponse struct { 618 // Status is "SubmitJobResponse.status" 619 // 620 // Optional 621 Status SubmitJobStatus 622 // JobId is "SubmitJobResponse.jobId" 623 // 624 // Optional 625 JobId js.String 626 627 FFI_USE bool 628 } 629 630 // FromRef calls UpdateFrom and returns a SubmitJobResponse with all fields set. 631 func (p SubmitJobResponse) FromRef(ref js.Ref) SubmitJobResponse { 632 p.UpdateFrom(ref) 633 return p 634 } 635 636 // New creates a new SubmitJobResponse in the application heap. 637 func (p SubmitJobResponse) New() js.Ref { 638 return bindings.SubmitJobResponseJSLoad( 639 js.Pointer(&p), js.True, 0, 640 ) 641 } 642 643 // UpdateFrom copies value of all fields of the heap object to p. 644 func (p *SubmitJobResponse) UpdateFrom(ref js.Ref) { 645 bindings.SubmitJobResponseJSStore( 646 js.Pointer(p), ref, 647 ) 648 } 649 650 // Update writes all fields of the p to the heap object referenced by ref. 651 func (p *SubmitJobResponse) Update(ref js.Ref) { 652 bindings.SubmitJobResponseJSLoad( 653 js.Pointer(p), js.False, ref, 654 ) 655 } 656 657 // FreeMembers frees fields with heap reference, if recursive is true 658 // free all heap references reachable from p. 659 func (p *SubmitJobResponse) FreeMembers(recursive bool) { 660 js.Free( 661 p.JobId.Ref(), 662 ) 663 p.JobId = p.JobId.FromRef(js.Undefined) 664 } 665 666 type SubmitJobRequest struct { 667 // Job is "SubmitJobRequest.job" 668 // 669 // Optional 670 // 671 // NOTE: Job.FFI_USE MUST be set to true to get Job used. 672 Job printerprovider.PrintJob 673 // DocumentBlobUuid is "SubmitJobRequest.documentBlobUuid" 674 // 675 // Optional 676 DocumentBlobUuid js.String 677 678 FFI_USE bool 679 } 680 681 // FromRef calls UpdateFrom and returns a SubmitJobRequest with all fields set. 682 func (p SubmitJobRequest) FromRef(ref js.Ref) SubmitJobRequest { 683 p.UpdateFrom(ref) 684 return p 685 } 686 687 // New creates a new SubmitJobRequest in the application heap. 688 func (p SubmitJobRequest) New() js.Ref { 689 return bindings.SubmitJobRequestJSLoad( 690 js.Pointer(&p), js.True, 0, 691 ) 692 } 693 694 // UpdateFrom copies value of all fields of the heap object to p. 695 func (p *SubmitJobRequest) UpdateFrom(ref js.Ref) { 696 bindings.SubmitJobRequestJSStore( 697 js.Pointer(p), ref, 698 ) 699 } 700 701 // Update writes all fields of the p to the heap object referenced by ref. 702 func (p *SubmitJobRequest) Update(ref js.Ref) { 703 bindings.SubmitJobRequestJSLoad( 704 js.Pointer(p), js.False, ref, 705 ) 706 } 707 708 // FreeMembers frees fields with heap reference, if recursive is true 709 // free all heap references reachable from p. 710 func (p *SubmitJobRequest) FreeMembers(recursive bool) { 711 js.Free( 712 p.DocumentBlobUuid.Ref(), 713 ) 714 p.DocumentBlobUuid = p.DocumentBlobUuid.FromRef(js.Undefined) 715 if recursive { 716 p.Job.FreeMembers(true) 717 } 718 } 719 720 // HasFuncCancelJob returns true if the function "WEBEXT.printing.cancelJob" exists. 721 func HasFuncCancelJob() bool { 722 return js.True == bindings.HasFuncCancelJob() 723 } 724 725 // FuncCancelJob returns the function "WEBEXT.printing.cancelJob". 726 func FuncCancelJob() (fn js.Func[func(jobId js.String) js.Promise[js.Void]]) { 727 bindings.FuncCancelJob( 728 js.Pointer(&fn), 729 ) 730 return 731 } 732 733 // CancelJob calls the function "WEBEXT.printing.cancelJob" directly. 734 func CancelJob(jobId js.String) (ret js.Promise[js.Void]) { 735 bindings.CallCancelJob( 736 js.Pointer(&ret), 737 jobId.Ref(), 738 ) 739 740 return 741 } 742 743 // TryCancelJob calls the function "WEBEXT.printing.cancelJob" 744 // in a try/catch block and returns (_, err, ok = false) when it went through 745 // the catch clause. 746 func TryCancelJob(jobId js.String) (ret js.Promise[js.Void], exception js.Any, ok bool) { 747 ok = js.True == bindings.TryCancelJob( 748 js.Pointer(&ret), js.Pointer(&exception), 749 jobId.Ref(), 750 ) 751 752 return 753 } 754 755 // HasFuncGetPrinterInfo returns true if the function "WEBEXT.printing.getPrinterInfo" exists. 756 func HasFuncGetPrinterInfo() bool { 757 return js.True == bindings.HasFuncGetPrinterInfo() 758 } 759 760 // FuncGetPrinterInfo returns the function "WEBEXT.printing.getPrinterInfo". 761 func FuncGetPrinterInfo() (fn js.Func[func(printerId js.String) js.Promise[GetPrinterInfoResponse]]) { 762 bindings.FuncGetPrinterInfo( 763 js.Pointer(&fn), 764 ) 765 return 766 } 767 768 // GetPrinterInfo calls the function "WEBEXT.printing.getPrinterInfo" directly. 769 func GetPrinterInfo(printerId js.String) (ret js.Promise[GetPrinterInfoResponse]) { 770 bindings.CallGetPrinterInfo( 771 js.Pointer(&ret), 772 printerId.Ref(), 773 ) 774 775 return 776 } 777 778 // TryGetPrinterInfo calls the function "WEBEXT.printing.getPrinterInfo" 779 // in a try/catch block and returns (_, err, ok = false) when it went through 780 // the catch clause. 781 func TryGetPrinterInfo(printerId js.String) (ret js.Promise[GetPrinterInfoResponse], exception js.Any, ok bool) { 782 ok = js.True == bindings.TryGetPrinterInfo( 783 js.Pointer(&ret), js.Pointer(&exception), 784 printerId.Ref(), 785 ) 786 787 return 788 } 789 790 // HasFuncGetPrinters returns true if the function "WEBEXT.printing.getPrinters" exists. 791 func HasFuncGetPrinters() bool { 792 return js.True == bindings.HasFuncGetPrinters() 793 } 794 795 // FuncGetPrinters returns the function "WEBEXT.printing.getPrinters". 796 func FuncGetPrinters() (fn js.Func[func() js.Promise[js.Array[Printer]]]) { 797 bindings.FuncGetPrinters( 798 js.Pointer(&fn), 799 ) 800 return 801 } 802 803 // GetPrinters calls the function "WEBEXT.printing.getPrinters" directly. 804 func GetPrinters() (ret js.Promise[js.Array[Printer]]) { 805 bindings.CallGetPrinters( 806 js.Pointer(&ret), 807 ) 808 809 return 810 } 811 812 // TryGetPrinters calls the function "WEBEXT.printing.getPrinters" 813 // in a try/catch block and returns (_, err, ok = false) when it went through 814 // the catch clause. 815 func TryGetPrinters() (ret js.Promise[js.Array[Printer]], exception js.Any, ok bool) { 816 ok = js.True == bindings.TryGetPrinters( 817 js.Pointer(&ret), js.Pointer(&exception), 818 ) 819 820 return 821 } 822 823 type OnJobStatusChangedEventCallbackFunc func(this js.Ref, jobId js.String, status JobStatus) js.Ref 824 825 func (fn OnJobStatusChangedEventCallbackFunc) Register() js.Func[func(jobId js.String, status JobStatus)] { 826 return js.RegisterCallback[func(jobId js.String, status JobStatus)]( 827 fn, abi.FuncPCABIInternal(fn), 828 ) 829 } 830 831 func (fn OnJobStatusChangedEventCallbackFunc) DispatchCallback( 832 targetPC uintptr, ctx *js.CallbackContext, 833 ) { 834 args := ctx.Args() 835 if len(args) != 2+1 /* js this */ || 836 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 837 js.ThrowInvalidCallbackInvocation() 838 } 839 840 if ctx.Return(fn( 841 args[0], 842 843 js.String{}.FromRef(args[0+1]), 844 JobStatus(0).FromRef(args[1+1]), 845 )) { 846 return 847 } 848 849 js.ThrowCallbackValueNotReturned() 850 } 851 852 type OnJobStatusChangedEventCallback[T any] struct { 853 Fn func(arg T, this js.Ref, jobId js.String, status JobStatus) js.Ref 854 Arg T 855 } 856 857 func (cb *OnJobStatusChangedEventCallback[T]) Register() js.Func[func(jobId js.String, status JobStatus)] { 858 return js.RegisterCallback[func(jobId js.String, status JobStatus)]( 859 cb, abi.FuncPCABIInternal(cb.Fn), 860 ) 861 } 862 863 func (cb *OnJobStatusChangedEventCallback[T]) DispatchCallback( 864 targetPC uintptr, ctx *js.CallbackContext, 865 ) { 866 args := ctx.Args() 867 if len(args) != 2+1 /* js this */ || 868 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 869 js.ThrowInvalidCallbackInvocation() 870 } 871 872 if ctx.Return(cb.Fn( 873 cb.Arg, 874 args[0], 875 876 js.String{}.FromRef(args[0+1]), 877 JobStatus(0).FromRef(args[1+1]), 878 )) { 879 return 880 } 881 882 js.ThrowCallbackValueNotReturned() 883 } 884 885 // HasFuncOnJobStatusChanged returns true if the function "WEBEXT.printing.onJobStatusChanged.addListener" exists. 886 func HasFuncOnJobStatusChanged() bool { 887 return js.True == bindings.HasFuncOnJobStatusChanged() 888 } 889 890 // FuncOnJobStatusChanged returns the function "WEBEXT.printing.onJobStatusChanged.addListener". 891 func FuncOnJobStatusChanged() (fn js.Func[func(callback js.Func[func(jobId js.String, status JobStatus)])]) { 892 bindings.FuncOnJobStatusChanged( 893 js.Pointer(&fn), 894 ) 895 return 896 } 897 898 // OnJobStatusChanged calls the function "WEBEXT.printing.onJobStatusChanged.addListener" directly. 899 func OnJobStatusChanged(callback js.Func[func(jobId js.String, status JobStatus)]) (ret js.Void) { 900 bindings.CallOnJobStatusChanged( 901 js.Pointer(&ret), 902 callback.Ref(), 903 ) 904 905 return 906 } 907 908 // TryOnJobStatusChanged calls the function "WEBEXT.printing.onJobStatusChanged.addListener" 909 // in a try/catch block and returns (_, err, ok = false) when it went through 910 // the catch clause. 911 func TryOnJobStatusChanged(callback js.Func[func(jobId js.String, status JobStatus)]) (ret js.Void, exception js.Any, ok bool) { 912 ok = js.True == bindings.TryOnJobStatusChanged( 913 js.Pointer(&ret), js.Pointer(&exception), 914 callback.Ref(), 915 ) 916 917 return 918 } 919 920 // HasFuncOffJobStatusChanged returns true if the function "WEBEXT.printing.onJobStatusChanged.removeListener" exists. 921 func HasFuncOffJobStatusChanged() bool { 922 return js.True == bindings.HasFuncOffJobStatusChanged() 923 } 924 925 // FuncOffJobStatusChanged returns the function "WEBEXT.printing.onJobStatusChanged.removeListener". 926 func FuncOffJobStatusChanged() (fn js.Func[func(callback js.Func[func(jobId js.String, status JobStatus)])]) { 927 bindings.FuncOffJobStatusChanged( 928 js.Pointer(&fn), 929 ) 930 return 931 } 932 933 // OffJobStatusChanged calls the function "WEBEXT.printing.onJobStatusChanged.removeListener" directly. 934 func OffJobStatusChanged(callback js.Func[func(jobId js.String, status JobStatus)]) (ret js.Void) { 935 bindings.CallOffJobStatusChanged( 936 js.Pointer(&ret), 937 callback.Ref(), 938 ) 939 940 return 941 } 942 943 // TryOffJobStatusChanged calls the function "WEBEXT.printing.onJobStatusChanged.removeListener" 944 // in a try/catch block and returns (_, err, ok = false) when it went through 945 // the catch clause. 946 func TryOffJobStatusChanged(callback js.Func[func(jobId js.String, status JobStatus)]) (ret js.Void, exception js.Any, ok bool) { 947 ok = js.True == bindings.TryOffJobStatusChanged( 948 js.Pointer(&ret), js.Pointer(&exception), 949 callback.Ref(), 950 ) 951 952 return 953 } 954 955 // HasFuncHasOnJobStatusChanged returns true if the function "WEBEXT.printing.onJobStatusChanged.hasListener" exists. 956 func HasFuncHasOnJobStatusChanged() bool { 957 return js.True == bindings.HasFuncHasOnJobStatusChanged() 958 } 959 960 // FuncHasOnJobStatusChanged returns the function "WEBEXT.printing.onJobStatusChanged.hasListener". 961 func FuncHasOnJobStatusChanged() (fn js.Func[func(callback js.Func[func(jobId js.String, status JobStatus)]) bool]) { 962 bindings.FuncHasOnJobStatusChanged( 963 js.Pointer(&fn), 964 ) 965 return 966 } 967 968 // HasOnJobStatusChanged calls the function "WEBEXT.printing.onJobStatusChanged.hasListener" directly. 969 func HasOnJobStatusChanged(callback js.Func[func(jobId js.String, status JobStatus)]) (ret bool) { 970 bindings.CallHasOnJobStatusChanged( 971 js.Pointer(&ret), 972 callback.Ref(), 973 ) 974 975 return 976 } 977 978 // TryHasOnJobStatusChanged calls the function "WEBEXT.printing.onJobStatusChanged.hasListener" 979 // in a try/catch block and returns (_, err, ok = false) when it went through 980 // the catch clause. 981 func TryHasOnJobStatusChanged(callback js.Func[func(jobId js.String, status JobStatus)]) (ret bool, exception js.Any, ok bool) { 982 ok = js.True == bindings.TryHasOnJobStatusChanged( 983 js.Pointer(&ret), js.Pointer(&exception), 984 callback.Ref(), 985 ) 986 987 return 988 } 989 990 // HasFuncSubmitJob returns true if the function "WEBEXT.printing.submitJob" exists. 991 func HasFuncSubmitJob() bool { 992 return js.True == bindings.HasFuncSubmitJob() 993 } 994 995 // FuncSubmitJob returns the function "WEBEXT.printing.submitJob". 996 func FuncSubmitJob() (fn js.Func[func(request SubmitJobRequest) js.Promise[SubmitJobResponse]]) { 997 bindings.FuncSubmitJob( 998 js.Pointer(&fn), 999 ) 1000 return 1001 } 1002 1003 // SubmitJob calls the function "WEBEXT.printing.submitJob" directly. 1004 func SubmitJob(request SubmitJobRequest) (ret js.Promise[SubmitJobResponse]) { 1005 bindings.CallSubmitJob( 1006 js.Pointer(&ret), 1007 js.Pointer(&request), 1008 ) 1009 1010 return 1011 } 1012 1013 // TrySubmitJob calls the function "WEBEXT.printing.submitJob" 1014 // in a try/catch block and returns (_, err, ok = false) when it went through 1015 // the catch clause. 1016 func TrySubmitJob(request SubmitJobRequest) (ret js.Promise[SubmitJobResponse], exception js.Any, ok bool) { 1017 ok = js.True == bindings.TrySubmitJob( 1018 js.Pointer(&ret), js.Pointer(&exception), 1019 js.Pointer(&request), 1020 ) 1021 1022 return 1023 }