github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/chromewebviewinternal/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package chromewebviewinternal 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/chromewebviewinternal/bindings" 11 "github.com/primecitizens/pcz/std/plat/js/webext/contextmenus" 12 ) 13 14 type ContextMenuItem struct { 15 // CommandId is "ContextMenuItem.commandId" 16 // 17 // Required 18 CommandId int64 19 // Label is "ContextMenuItem.label" 20 // 21 // Optional 22 Label js.String 23 24 FFI_USE bool 25 } 26 27 // FromRef calls UpdateFrom and returns a ContextMenuItem with all fields set. 28 func (p ContextMenuItem) FromRef(ref js.Ref) ContextMenuItem { 29 p.UpdateFrom(ref) 30 return p 31 } 32 33 // New creates a new ContextMenuItem in the application heap. 34 func (p ContextMenuItem) New() js.Ref { 35 return bindings.ContextMenuItemJSLoad( 36 js.Pointer(&p), js.True, 0, 37 ) 38 } 39 40 // UpdateFrom copies value of all fields of the heap object to p. 41 func (p *ContextMenuItem) UpdateFrom(ref js.Ref) { 42 bindings.ContextMenuItemJSStore( 43 js.Pointer(p), ref, 44 ) 45 } 46 47 // Update writes all fields of the p to the heap object referenced by ref. 48 func (p *ContextMenuItem) Update(ref js.Ref) { 49 bindings.ContextMenuItemJSLoad( 50 js.Pointer(p), js.False, ref, 51 ) 52 } 53 54 // FreeMembers frees fields with heap reference, if recursive is true 55 // free all heap references reachable from p. 56 func (p *ContextMenuItem) FreeMembers(recursive bool) { 57 js.Free( 58 p.Label.Ref(), 59 ) 60 p.Label = p.Label.FromRef(js.Undefined) 61 } 62 63 type ContextMenusCreateArgCallbackFunc func(this js.Ref) js.Ref 64 65 func (fn ContextMenusCreateArgCallbackFunc) Register() js.Func[func()] { 66 return js.RegisterCallback[func()]( 67 fn, abi.FuncPCABIInternal(fn), 68 ) 69 } 70 71 func (fn ContextMenusCreateArgCallbackFunc) DispatchCallback( 72 targetPC uintptr, ctx *js.CallbackContext, 73 ) { 74 args := ctx.Args() 75 if len(args) != 0+1 /* js this */ || 76 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 77 js.ThrowInvalidCallbackInvocation() 78 } 79 80 if ctx.Return(fn( 81 args[0], 82 )) { 83 return 84 } 85 86 js.ThrowCallbackValueNotReturned() 87 } 88 89 type ContextMenusCreateArgCallback[T any] struct { 90 Fn func(arg T, this js.Ref) js.Ref 91 Arg T 92 } 93 94 func (cb *ContextMenusCreateArgCallback[T]) Register() js.Func[func()] { 95 return js.RegisterCallback[func()]( 96 cb, abi.FuncPCABIInternal(cb.Fn), 97 ) 98 } 99 100 func (cb *ContextMenusCreateArgCallback[T]) DispatchCallback( 101 targetPC uintptr, ctx *js.CallbackContext, 102 ) { 103 args := ctx.Args() 104 if len(args) != 0+1 /* js this */ || 105 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 106 js.ThrowInvalidCallbackInvocation() 107 } 108 109 if ctx.Return(cb.Fn( 110 cb.Arg, 111 args[0], 112 )) { 113 return 114 } 115 116 js.ThrowCallbackValueNotReturned() 117 } 118 119 type ContextMenusCreateArgCreatePropertiesFieldOnclickFunc func(this js.Ref, info *contextmenus.OnClickData) js.Ref 120 121 func (fn ContextMenusCreateArgCreatePropertiesFieldOnclickFunc) Register() js.Func[func(info *contextmenus.OnClickData)] { 122 return js.RegisterCallback[func(info *contextmenus.OnClickData)]( 123 fn, abi.FuncPCABIInternal(fn), 124 ) 125 } 126 127 func (fn ContextMenusCreateArgCreatePropertiesFieldOnclickFunc) DispatchCallback( 128 targetPC uintptr, ctx *js.CallbackContext, 129 ) { 130 args := ctx.Args() 131 if len(args) != 1+1 /* js this */ || 132 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 133 js.ThrowInvalidCallbackInvocation() 134 } 135 var arg0 contextmenus.OnClickData 136 arg0.UpdateFrom(args[0+1]) 137 defer arg0.FreeMembers(true) 138 139 if ctx.Return(fn( 140 args[0], 141 142 mark.NoEscape(&arg0), 143 )) { 144 return 145 } 146 147 js.ThrowCallbackValueNotReturned() 148 } 149 150 type ContextMenusCreateArgCreatePropertiesFieldOnclick[T any] struct { 151 Fn func(arg T, this js.Ref, info *contextmenus.OnClickData) js.Ref 152 Arg T 153 } 154 155 func (cb *ContextMenusCreateArgCreatePropertiesFieldOnclick[T]) Register() js.Func[func(info *contextmenus.OnClickData)] { 156 return js.RegisterCallback[func(info *contextmenus.OnClickData)]( 157 cb, abi.FuncPCABIInternal(cb.Fn), 158 ) 159 } 160 161 func (cb *ContextMenusCreateArgCreatePropertiesFieldOnclick[T]) DispatchCallback( 162 targetPC uintptr, ctx *js.CallbackContext, 163 ) { 164 args := ctx.Args() 165 if len(args) != 1+1 /* js this */ || 166 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 167 js.ThrowInvalidCallbackInvocation() 168 } 169 var arg0 contextmenus.OnClickData 170 arg0.UpdateFrom(args[0+1]) 171 defer arg0.FreeMembers(true) 172 173 if ctx.Return(cb.Fn( 174 cb.Arg, 175 args[0], 176 177 mark.NoEscape(&arg0), 178 )) { 179 return 180 } 181 182 js.ThrowCallbackValueNotReturned() 183 } 184 185 type OneOf_Int64_String struct { 186 ref js.Ref 187 } 188 189 func (x OneOf_Int64_String) Ref() js.Ref { 190 return x.ref 191 } 192 193 func (x OneOf_Int64_String) Free() { 194 x.ref.Free() 195 } 196 197 func (x OneOf_Int64_String) FromRef(ref js.Ref) OneOf_Int64_String { 198 return OneOf_Int64_String{ 199 ref: ref, 200 } 201 } 202 203 func (x OneOf_Int64_String) Int64() int64 { 204 return js.BigInt[int64]{}.FromRef(x.ref).Get() 205 } 206 207 func (x OneOf_Int64_String) String() js.String { 208 return js.String{}.FromRef(x.ref) 209 } 210 211 type ContextMenusCreateArgCreateProperties struct { 212 // Checked is "ContextMenusCreateArgCreateProperties.checked" 213 // 214 // Optional 215 // 216 // NOTE: FFI_USE_Checked MUST be set to true to make this field effective. 217 Checked bool 218 // Contexts is "ContextMenusCreateArgCreateProperties.contexts" 219 // 220 // Optional 221 Contexts js.Array[contextmenus.ContextType] 222 // DocumentUrlPatterns is "ContextMenusCreateArgCreateProperties.documentUrlPatterns" 223 // 224 // Optional 225 DocumentUrlPatterns js.Array[js.String] 226 // Enabled is "ContextMenusCreateArgCreateProperties.enabled" 227 // 228 // Optional 229 // 230 // NOTE: FFI_USE_Enabled MUST be set to true to make this field effective. 231 Enabled bool 232 // Id is "ContextMenusCreateArgCreateProperties.id" 233 // 234 // Optional 235 Id js.String 236 // Onclick is "ContextMenusCreateArgCreateProperties.onclick" 237 // 238 // Optional 239 Onclick js.Func[func(info *contextmenus.OnClickData)] 240 // ParentId is "ContextMenusCreateArgCreateProperties.parentId" 241 // 242 // Optional 243 ParentId OneOf_Int64_String 244 // TargetUrlPatterns is "ContextMenusCreateArgCreateProperties.targetUrlPatterns" 245 // 246 // Optional 247 TargetUrlPatterns js.Array[js.String] 248 // Title is "ContextMenusCreateArgCreateProperties.title" 249 // 250 // Optional 251 Title js.String 252 // Type is "ContextMenusCreateArgCreateProperties.type" 253 // 254 // Optional 255 Type contextmenus.ItemType 256 // Visible is "ContextMenusCreateArgCreateProperties.visible" 257 // 258 // Optional 259 // 260 // NOTE: FFI_USE_Visible MUST be set to true to make this field effective. 261 Visible bool 262 263 FFI_USE_Checked bool // for Checked. 264 FFI_USE_Enabled bool // for Enabled. 265 FFI_USE_Visible bool // for Visible. 266 267 FFI_USE bool 268 } 269 270 // FromRef calls UpdateFrom and returns a ContextMenusCreateArgCreateProperties with all fields set. 271 func (p ContextMenusCreateArgCreateProperties) FromRef(ref js.Ref) ContextMenusCreateArgCreateProperties { 272 p.UpdateFrom(ref) 273 return p 274 } 275 276 // New creates a new ContextMenusCreateArgCreateProperties in the application heap. 277 func (p ContextMenusCreateArgCreateProperties) New() js.Ref { 278 return bindings.ContextMenusCreateArgCreatePropertiesJSLoad( 279 js.Pointer(&p), js.True, 0, 280 ) 281 } 282 283 // UpdateFrom copies value of all fields of the heap object to p. 284 func (p *ContextMenusCreateArgCreateProperties) UpdateFrom(ref js.Ref) { 285 bindings.ContextMenusCreateArgCreatePropertiesJSStore( 286 js.Pointer(p), ref, 287 ) 288 } 289 290 // Update writes all fields of the p to the heap object referenced by ref. 291 func (p *ContextMenusCreateArgCreateProperties) Update(ref js.Ref) { 292 bindings.ContextMenusCreateArgCreatePropertiesJSLoad( 293 js.Pointer(p), js.False, ref, 294 ) 295 } 296 297 // FreeMembers frees fields with heap reference, if recursive is true 298 // free all heap references reachable from p. 299 func (p *ContextMenusCreateArgCreateProperties) FreeMembers(recursive bool) { 300 js.Free( 301 p.Contexts.Ref(), 302 p.DocumentUrlPatterns.Ref(), 303 p.Id.Ref(), 304 p.Onclick.Ref(), 305 p.ParentId.Ref(), 306 p.TargetUrlPatterns.Ref(), 307 p.Title.Ref(), 308 ) 309 p.Contexts = p.Contexts.FromRef(js.Undefined) 310 p.DocumentUrlPatterns = p.DocumentUrlPatterns.FromRef(js.Undefined) 311 p.Id = p.Id.FromRef(js.Undefined) 312 p.Onclick = p.Onclick.FromRef(js.Undefined) 313 p.ParentId = p.ParentId.FromRef(js.Undefined) 314 p.TargetUrlPatterns = p.TargetUrlPatterns.FromRef(js.Undefined) 315 p.Title = p.Title.FromRef(js.Undefined) 316 } 317 318 type ContextMenusRemoveAllArgCallbackFunc func(this js.Ref) js.Ref 319 320 func (fn ContextMenusRemoveAllArgCallbackFunc) Register() js.Func[func()] { 321 return js.RegisterCallback[func()]( 322 fn, abi.FuncPCABIInternal(fn), 323 ) 324 } 325 326 func (fn ContextMenusRemoveAllArgCallbackFunc) DispatchCallback( 327 targetPC uintptr, ctx *js.CallbackContext, 328 ) { 329 args := ctx.Args() 330 if len(args) != 0+1 /* js this */ || 331 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 332 js.ThrowInvalidCallbackInvocation() 333 } 334 335 if ctx.Return(fn( 336 args[0], 337 )) { 338 return 339 } 340 341 js.ThrowCallbackValueNotReturned() 342 } 343 344 type ContextMenusRemoveAllArgCallback[T any] struct { 345 Fn func(arg T, this js.Ref) js.Ref 346 Arg T 347 } 348 349 func (cb *ContextMenusRemoveAllArgCallback[T]) Register() js.Func[func()] { 350 return js.RegisterCallback[func()]( 351 cb, abi.FuncPCABIInternal(cb.Fn), 352 ) 353 } 354 355 func (cb *ContextMenusRemoveAllArgCallback[T]) DispatchCallback( 356 targetPC uintptr, ctx *js.CallbackContext, 357 ) { 358 args := ctx.Args() 359 if len(args) != 0+1 /* js this */ || 360 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 361 js.ThrowInvalidCallbackInvocation() 362 } 363 364 if ctx.Return(cb.Fn( 365 cb.Arg, 366 args[0], 367 )) { 368 return 369 } 370 371 js.ThrowCallbackValueNotReturned() 372 } 373 374 type ContextMenusRemoveArgCallbackFunc func(this js.Ref) js.Ref 375 376 func (fn ContextMenusRemoveArgCallbackFunc) Register() js.Func[func()] { 377 return js.RegisterCallback[func()]( 378 fn, abi.FuncPCABIInternal(fn), 379 ) 380 } 381 382 func (fn ContextMenusRemoveArgCallbackFunc) DispatchCallback( 383 targetPC uintptr, ctx *js.CallbackContext, 384 ) { 385 args := ctx.Args() 386 if len(args) != 0+1 /* js this */ || 387 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 388 js.ThrowInvalidCallbackInvocation() 389 } 390 391 if ctx.Return(fn( 392 args[0], 393 )) { 394 return 395 } 396 397 js.ThrowCallbackValueNotReturned() 398 } 399 400 type ContextMenusRemoveArgCallback[T any] struct { 401 Fn func(arg T, this js.Ref) js.Ref 402 Arg T 403 } 404 405 func (cb *ContextMenusRemoveArgCallback[T]) Register() js.Func[func()] { 406 return js.RegisterCallback[func()]( 407 cb, abi.FuncPCABIInternal(cb.Fn), 408 ) 409 } 410 411 func (cb *ContextMenusRemoveArgCallback[T]) DispatchCallback( 412 targetPC uintptr, ctx *js.CallbackContext, 413 ) { 414 args := ctx.Args() 415 if len(args) != 0+1 /* js this */ || 416 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 417 js.ThrowInvalidCallbackInvocation() 418 } 419 420 if ctx.Return(cb.Fn( 421 cb.Arg, 422 args[0], 423 )) { 424 return 425 } 426 427 js.ThrowCallbackValueNotReturned() 428 } 429 430 type ContextMenusUpdateArgCallbackFunc func(this js.Ref) js.Ref 431 432 func (fn ContextMenusUpdateArgCallbackFunc) Register() js.Func[func()] { 433 return js.RegisterCallback[func()]( 434 fn, abi.FuncPCABIInternal(fn), 435 ) 436 } 437 438 func (fn ContextMenusUpdateArgCallbackFunc) DispatchCallback( 439 targetPC uintptr, ctx *js.CallbackContext, 440 ) { 441 args := ctx.Args() 442 if len(args) != 0+1 /* js this */ || 443 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 444 js.ThrowInvalidCallbackInvocation() 445 } 446 447 if ctx.Return(fn( 448 args[0], 449 )) { 450 return 451 } 452 453 js.ThrowCallbackValueNotReturned() 454 } 455 456 type ContextMenusUpdateArgCallback[T any] struct { 457 Fn func(arg T, this js.Ref) js.Ref 458 Arg T 459 } 460 461 func (cb *ContextMenusUpdateArgCallback[T]) Register() js.Func[func()] { 462 return js.RegisterCallback[func()]( 463 cb, abi.FuncPCABIInternal(cb.Fn), 464 ) 465 } 466 467 func (cb *ContextMenusUpdateArgCallback[T]) DispatchCallback( 468 targetPC uintptr, ctx *js.CallbackContext, 469 ) { 470 args := ctx.Args() 471 if len(args) != 0+1 /* js this */ || 472 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 473 js.ThrowInvalidCallbackInvocation() 474 } 475 476 if ctx.Return(cb.Fn( 477 cb.Arg, 478 args[0], 479 )) { 480 return 481 } 482 483 js.ThrowCallbackValueNotReturned() 484 } 485 486 type ContextMenusUpdateArgUpdatePropertiesFieldOnclickFunc func(this js.Ref) js.Ref 487 488 func (fn ContextMenusUpdateArgUpdatePropertiesFieldOnclickFunc) Register() js.Func[func()] { 489 return js.RegisterCallback[func()]( 490 fn, abi.FuncPCABIInternal(fn), 491 ) 492 } 493 494 func (fn ContextMenusUpdateArgUpdatePropertiesFieldOnclickFunc) DispatchCallback( 495 targetPC uintptr, ctx *js.CallbackContext, 496 ) { 497 args := ctx.Args() 498 if len(args) != 0+1 /* js this */ || 499 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 500 js.ThrowInvalidCallbackInvocation() 501 } 502 503 if ctx.Return(fn( 504 args[0], 505 )) { 506 return 507 } 508 509 js.ThrowCallbackValueNotReturned() 510 } 511 512 type ContextMenusUpdateArgUpdatePropertiesFieldOnclick[T any] struct { 513 Fn func(arg T, this js.Ref) js.Ref 514 Arg T 515 } 516 517 func (cb *ContextMenusUpdateArgUpdatePropertiesFieldOnclick[T]) Register() js.Func[func()] { 518 return js.RegisterCallback[func()]( 519 cb, abi.FuncPCABIInternal(cb.Fn), 520 ) 521 } 522 523 func (cb *ContextMenusUpdateArgUpdatePropertiesFieldOnclick[T]) DispatchCallback( 524 targetPC uintptr, ctx *js.CallbackContext, 525 ) { 526 args := ctx.Args() 527 if len(args) != 0+1 /* js this */ || 528 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 529 js.ThrowInvalidCallbackInvocation() 530 } 531 532 if ctx.Return(cb.Fn( 533 cb.Arg, 534 args[0], 535 )) { 536 return 537 } 538 539 js.ThrowCallbackValueNotReturned() 540 } 541 542 type ContextMenusUpdateArgUpdateProperties struct { 543 // Checked is "ContextMenusUpdateArgUpdateProperties.checked" 544 // 545 // Optional 546 // 547 // NOTE: FFI_USE_Checked MUST be set to true to make this field effective. 548 Checked bool 549 // Contexts is "ContextMenusUpdateArgUpdateProperties.contexts" 550 // 551 // Optional 552 Contexts js.Array[contextmenus.ContextType] 553 // DocumentUrlPatterns is "ContextMenusUpdateArgUpdateProperties.documentUrlPatterns" 554 // 555 // Optional 556 DocumentUrlPatterns js.Array[js.String] 557 // Enabled is "ContextMenusUpdateArgUpdateProperties.enabled" 558 // 559 // Optional 560 // 561 // NOTE: FFI_USE_Enabled MUST be set to true to make this field effective. 562 Enabled bool 563 // Onclick is "ContextMenusUpdateArgUpdateProperties.onclick" 564 // 565 // Optional 566 Onclick js.Func[func()] 567 // ParentId is "ContextMenusUpdateArgUpdateProperties.parentId" 568 // 569 // Optional 570 ParentId OneOf_Int64_String 571 // TargetUrlPatterns is "ContextMenusUpdateArgUpdateProperties.targetUrlPatterns" 572 // 573 // Optional 574 TargetUrlPatterns js.Array[js.String] 575 // Title is "ContextMenusUpdateArgUpdateProperties.title" 576 // 577 // Optional 578 Title js.String 579 // Type is "ContextMenusUpdateArgUpdateProperties.type" 580 // 581 // Optional 582 Type contextmenus.ItemType 583 // Visible is "ContextMenusUpdateArgUpdateProperties.visible" 584 // 585 // Optional 586 // 587 // NOTE: FFI_USE_Visible MUST be set to true to make this field effective. 588 Visible bool 589 590 FFI_USE_Checked bool // for Checked. 591 FFI_USE_Enabled bool // for Enabled. 592 FFI_USE_Visible bool // for Visible. 593 594 FFI_USE bool 595 } 596 597 // FromRef calls UpdateFrom and returns a ContextMenusUpdateArgUpdateProperties with all fields set. 598 func (p ContextMenusUpdateArgUpdateProperties) FromRef(ref js.Ref) ContextMenusUpdateArgUpdateProperties { 599 p.UpdateFrom(ref) 600 return p 601 } 602 603 // New creates a new ContextMenusUpdateArgUpdateProperties in the application heap. 604 func (p ContextMenusUpdateArgUpdateProperties) New() js.Ref { 605 return bindings.ContextMenusUpdateArgUpdatePropertiesJSLoad( 606 js.Pointer(&p), js.True, 0, 607 ) 608 } 609 610 // UpdateFrom copies value of all fields of the heap object to p. 611 func (p *ContextMenusUpdateArgUpdateProperties) UpdateFrom(ref js.Ref) { 612 bindings.ContextMenusUpdateArgUpdatePropertiesJSStore( 613 js.Pointer(p), ref, 614 ) 615 } 616 617 // Update writes all fields of the p to the heap object referenced by ref. 618 func (p *ContextMenusUpdateArgUpdateProperties) Update(ref js.Ref) { 619 bindings.ContextMenusUpdateArgUpdatePropertiesJSLoad( 620 js.Pointer(p), js.False, ref, 621 ) 622 } 623 624 // FreeMembers frees fields with heap reference, if recursive is true 625 // free all heap references reachable from p. 626 func (p *ContextMenusUpdateArgUpdateProperties) FreeMembers(recursive bool) { 627 js.Free( 628 p.Contexts.Ref(), 629 p.DocumentUrlPatterns.Ref(), 630 p.Onclick.Ref(), 631 p.ParentId.Ref(), 632 p.TargetUrlPatterns.Ref(), 633 p.Title.Ref(), 634 ) 635 p.Contexts = p.Contexts.FromRef(js.Undefined) 636 p.DocumentUrlPatterns = p.DocumentUrlPatterns.FromRef(js.Undefined) 637 p.Onclick = p.Onclick.FromRef(js.Undefined) 638 p.ParentId = p.ParentId.FromRef(js.Undefined) 639 p.TargetUrlPatterns = p.TargetUrlPatterns.FromRef(js.Undefined) 640 p.Title = p.Title.FromRef(js.Undefined) 641 } 642 643 type OnShowArgEventFieldPreventDefaultFunc func(this js.Ref) js.Ref 644 645 func (fn OnShowArgEventFieldPreventDefaultFunc) Register() js.Func[func()] { 646 return js.RegisterCallback[func()]( 647 fn, abi.FuncPCABIInternal(fn), 648 ) 649 } 650 651 func (fn OnShowArgEventFieldPreventDefaultFunc) DispatchCallback( 652 targetPC uintptr, ctx *js.CallbackContext, 653 ) { 654 args := ctx.Args() 655 if len(args) != 0+1 /* js this */ || 656 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 657 js.ThrowInvalidCallbackInvocation() 658 } 659 660 if ctx.Return(fn( 661 args[0], 662 )) { 663 return 664 } 665 666 js.ThrowCallbackValueNotReturned() 667 } 668 669 type OnShowArgEventFieldPreventDefault[T any] struct { 670 Fn func(arg T, this js.Ref) js.Ref 671 Arg T 672 } 673 674 func (cb *OnShowArgEventFieldPreventDefault[T]) Register() js.Func[func()] { 675 return js.RegisterCallback[func()]( 676 cb, abi.FuncPCABIInternal(cb.Fn), 677 ) 678 } 679 680 func (cb *OnShowArgEventFieldPreventDefault[T]) DispatchCallback( 681 targetPC uintptr, ctx *js.CallbackContext, 682 ) { 683 args := ctx.Args() 684 if len(args) != 0+1 /* js this */ || 685 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 686 js.ThrowInvalidCallbackInvocation() 687 } 688 689 if ctx.Return(cb.Fn( 690 cb.Arg, 691 args[0], 692 )) { 693 return 694 } 695 696 js.ThrowCallbackValueNotReturned() 697 } 698 699 type OnShowArgEvent struct { 700 // PreventDefault is "OnShowArgEvent.preventDefault" 701 // 702 // Required 703 PreventDefault js.Func[func()] 704 705 FFI_USE bool 706 } 707 708 // FromRef calls UpdateFrom and returns a OnShowArgEvent with all fields set. 709 func (p OnShowArgEvent) FromRef(ref js.Ref) OnShowArgEvent { 710 p.UpdateFrom(ref) 711 return p 712 } 713 714 // New creates a new OnShowArgEvent in the application heap. 715 func (p OnShowArgEvent) New() js.Ref { 716 return bindings.OnShowArgEventJSLoad( 717 js.Pointer(&p), js.True, 0, 718 ) 719 } 720 721 // UpdateFrom copies value of all fields of the heap object to p. 722 func (p *OnShowArgEvent) UpdateFrom(ref js.Ref) { 723 bindings.OnShowArgEventJSStore( 724 js.Pointer(p), ref, 725 ) 726 } 727 728 // Update writes all fields of the p to the heap object referenced by ref. 729 func (p *OnShowArgEvent) Update(ref js.Ref) { 730 bindings.OnShowArgEventJSLoad( 731 js.Pointer(p), js.False, ref, 732 ) 733 } 734 735 // FreeMembers frees fields with heap reference, if recursive is true 736 // free all heap references reachable from p. 737 func (p *OnShowArgEvent) FreeMembers(recursive bool) { 738 js.Free( 739 p.PreventDefault.Ref(), 740 ) 741 p.PreventDefault = p.PreventDefault.FromRef(js.Undefined) 742 } 743 744 // HasFuncContextMenusCreate returns true if the function "WEBEXT.chromeWebViewInternal.contextMenusCreate" exists. 745 func HasFuncContextMenusCreate() bool { 746 return js.True == bindings.HasFuncContextMenusCreate() 747 } 748 749 // FuncContextMenusCreate returns the function "WEBEXT.chromeWebViewInternal.contextMenusCreate". 750 func FuncContextMenusCreate() (fn js.Func[func(instanceId int64, createProperties ContextMenusCreateArgCreateProperties, callback js.Func[func()]) OneOf_Int64_String]) { 751 bindings.FuncContextMenusCreate( 752 js.Pointer(&fn), 753 ) 754 return 755 } 756 757 // ContextMenusCreate calls the function "WEBEXT.chromeWebViewInternal.contextMenusCreate" directly. 758 func ContextMenusCreate(instanceId int64, createProperties ContextMenusCreateArgCreateProperties, callback js.Func[func()]) (ret OneOf_Int64_String) { 759 bindings.CallContextMenusCreate( 760 js.Pointer(&ret), 761 float64(instanceId), 762 js.Pointer(&createProperties), 763 callback.Ref(), 764 ) 765 766 return 767 } 768 769 // TryContextMenusCreate calls the function "WEBEXT.chromeWebViewInternal.contextMenusCreate" 770 // in a try/catch block and returns (_, err, ok = false) when it went through 771 // the catch clause. 772 func TryContextMenusCreate(instanceId int64, createProperties ContextMenusCreateArgCreateProperties, callback js.Func[func()]) (ret OneOf_Int64_String, exception js.Any, ok bool) { 773 ok = js.True == bindings.TryContextMenusCreate( 774 js.Pointer(&ret), js.Pointer(&exception), 775 float64(instanceId), 776 js.Pointer(&createProperties), 777 callback.Ref(), 778 ) 779 780 return 781 } 782 783 // HasFuncContextMenusRemove returns true if the function "WEBEXT.chromeWebViewInternal.contextMenusRemove" exists. 784 func HasFuncContextMenusRemove() bool { 785 return js.True == bindings.HasFuncContextMenusRemove() 786 } 787 788 // FuncContextMenusRemove returns the function "WEBEXT.chromeWebViewInternal.contextMenusRemove". 789 func FuncContextMenusRemove() (fn js.Func[func(instanceId int64, menuItemId OneOf_Int64_String, callback js.Func[func()])]) { 790 bindings.FuncContextMenusRemove( 791 js.Pointer(&fn), 792 ) 793 return 794 } 795 796 // ContextMenusRemove calls the function "WEBEXT.chromeWebViewInternal.contextMenusRemove" directly. 797 func ContextMenusRemove(instanceId int64, menuItemId OneOf_Int64_String, callback js.Func[func()]) (ret js.Void) { 798 bindings.CallContextMenusRemove( 799 js.Pointer(&ret), 800 float64(instanceId), 801 menuItemId.Ref(), 802 callback.Ref(), 803 ) 804 805 return 806 } 807 808 // TryContextMenusRemove calls the function "WEBEXT.chromeWebViewInternal.contextMenusRemove" 809 // in a try/catch block and returns (_, err, ok = false) when it went through 810 // the catch clause. 811 func TryContextMenusRemove(instanceId int64, menuItemId OneOf_Int64_String, callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 812 ok = js.True == bindings.TryContextMenusRemove( 813 js.Pointer(&ret), js.Pointer(&exception), 814 float64(instanceId), 815 menuItemId.Ref(), 816 callback.Ref(), 817 ) 818 819 return 820 } 821 822 // HasFuncContextMenusRemoveAll returns true if the function "WEBEXT.chromeWebViewInternal.contextMenusRemoveAll" exists. 823 func HasFuncContextMenusRemoveAll() bool { 824 return js.True == bindings.HasFuncContextMenusRemoveAll() 825 } 826 827 // FuncContextMenusRemoveAll returns the function "WEBEXT.chromeWebViewInternal.contextMenusRemoveAll". 828 func FuncContextMenusRemoveAll() (fn js.Func[func(instanceId int64, callback js.Func[func()])]) { 829 bindings.FuncContextMenusRemoveAll( 830 js.Pointer(&fn), 831 ) 832 return 833 } 834 835 // ContextMenusRemoveAll calls the function "WEBEXT.chromeWebViewInternal.contextMenusRemoveAll" directly. 836 func ContextMenusRemoveAll(instanceId int64, callback js.Func[func()]) (ret js.Void) { 837 bindings.CallContextMenusRemoveAll( 838 js.Pointer(&ret), 839 float64(instanceId), 840 callback.Ref(), 841 ) 842 843 return 844 } 845 846 // TryContextMenusRemoveAll calls the function "WEBEXT.chromeWebViewInternal.contextMenusRemoveAll" 847 // in a try/catch block and returns (_, err, ok = false) when it went through 848 // the catch clause. 849 func TryContextMenusRemoveAll(instanceId int64, callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 850 ok = js.True == bindings.TryContextMenusRemoveAll( 851 js.Pointer(&ret), js.Pointer(&exception), 852 float64(instanceId), 853 callback.Ref(), 854 ) 855 856 return 857 } 858 859 // HasFuncContextMenusUpdate returns true if the function "WEBEXT.chromeWebViewInternal.contextMenusUpdate" exists. 860 func HasFuncContextMenusUpdate() bool { 861 return js.True == bindings.HasFuncContextMenusUpdate() 862 } 863 864 // FuncContextMenusUpdate returns the function "WEBEXT.chromeWebViewInternal.contextMenusUpdate". 865 func FuncContextMenusUpdate() (fn js.Func[func(instanceId int64, id OneOf_Int64_String, updateProperties ContextMenusUpdateArgUpdateProperties, callback js.Func[func()])]) { 866 bindings.FuncContextMenusUpdate( 867 js.Pointer(&fn), 868 ) 869 return 870 } 871 872 // ContextMenusUpdate calls the function "WEBEXT.chromeWebViewInternal.contextMenusUpdate" directly. 873 func ContextMenusUpdate(instanceId int64, id OneOf_Int64_String, updateProperties ContextMenusUpdateArgUpdateProperties, callback js.Func[func()]) (ret js.Void) { 874 bindings.CallContextMenusUpdate( 875 js.Pointer(&ret), 876 float64(instanceId), 877 id.Ref(), 878 js.Pointer(&updateProperties), 879 callback.Ref(), 880 ) 881 882 return 883 } 884 885 // TryContextMenusUpdate calls the function "WEBEXT.chromeWebViewInternal.contextMenusUpdate" 886 // in a try/catch block and returns (_, err, ok = false) when it went through 887 // the catch clause. 888 func TryContextMenusUpdate(instanceId int64, id OneOf_Int64_String, updateProperties ContextMenusUpdateArgUpdateProperties, callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 889 ok = js.True == bindings.TryContextMenusUpdate( 890 js.Pointer(&ret), js.Pointer(&exception), 891 float64(instanceId), 892 id.Ref(), 893 js.Pointer(&updateProperties), 894 callback.Ref(), 895 ) 896 897 return 898 } 899 900 type OnClickedEventCallbackFunc func(this js.Ref) js.Ref 901 902 func (fn OnClickedEventCallbackFunc) Register() js.Func[func()] { 903 return js.RegisterCallback[func()]( 904 fn, abi.FuncPCABIInternal(fn), 905 ) 906 } 907 908 func (fn OnClickedEventCallbackFunc) DispatchCallback( 909 targetPC uintptr, ctx *js.CallbackContext, 910 ) { 911 args := ctx.Args() 912 if len(args) != 0+1 /* js this */ || 913 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 914 js.ThrowInvalidCallbackInvocation() 915 } 916 917 if ctx.Return(fn( 918 args[0], 919 )) { 920 return 921 } 922 923 js.ThrowCallbackValueNotReturned() 924 } 925 926 type OnClickedEventCallback[T any] struct { 927 Fn func(arg T, this js.Ref) js.Ref 928 Arg T 929 } 930 931 func (cb *OnClickedEventCallback[T]) Register() js.Func[func()] { 932 return js.RegisterCallback[func()]( 933 cb, abi.FuncPCABIInternal(cb.Fn), 934 ) 935 } 936 937 func (cb *OnClickedEventCallback[T]) DispatchCallback( 938 targetPC uintptr, ctx *js.CallbackContext, 939 ) { 940 args := ctx.Args() 941 if len(args) != 0+1 /* js this */ || 942 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 943 js.ThrowInvalidCallbackInvocation() 944 } 945 946 if ctx.Return(cb.Fn( 947 cb.Arg, 948 args[0], 949 )) { 950 return 951 } 952 953 js.ThrowCallbackValueNotReturned() 954 } 955 956 // HasFuncOnClicked returns true if the function "WEBEXT.chromeWebViewInternal.onClicked.addListener" exists. 957 func HasFuncOnClicked() bool { 958 return js.True == bindings.HasFuncOnClicked() 959 } 960 961 // FuncOnClicked returns the function "WEBEXT.chromeWebViewInternal.onClicked.addListener". 962 func FuncOnClicked() (fn js.Func[func(callback js.Func[func()])]) { 963 bindings.FuncOnClicked( 964 js.Pointer(&fn), 965 ) 966 return 967 } 968 969 // OnClicked calls the function "WEBEXT.chromeWebViewInternal.onClicked.addListener" directly. 970 func OnClicked(callback js.Func[func()]) (ret js.Void) { 971 bindings.CallOnClicked( 972 js.Pointer(&ret), 973 callback.Ref(), 974 ) 975 976 return 977 } 978 979 // TryOnClicked calls the function "WEBEXT.chromeWebViewInternal.onClicked.addListener" 980 // in a try/catch block and returns (_, err, ok = false) when it went through 981 // the catch clause. 982 func TryOnClicked(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 983 ok = js.True == bindings.TryOnClicked( 984 js.Pointer(&ret), js.Pointer(&exception), 985 callback.Ref(), 986 ) 987 988 return 989 } 990 991 // HasFuncOffClicked returns true if the function "WEBEXT.chromeWebViewInternal.onClicked.removeListener" exists. 992 func HasFuncOffClicked() bool { 993 return js.True == bindings.HasFuncOffClicked() 994 } 995 996 // FuncOffClicked returns the function "WEBEXT.chromeWebViewInternal.onClicked.removeListener". 997 func FuncOffClicked() (fn js.Func[func(callback js.Func[func()])]) { 998 bindings.FuncOffClicked( 999 js.Pointer(&fn), 1000 ) 1001 return 1002 } 1003 1004 // OffClicked calls the function "WEBEXT.chromeWebViewInternal.onClicked.removeListener" directly. 1005 func OffClicked(callback js.Func[func()]) (ret js.Void) { 1006 bindings.CallOffClicked( 1007 js.Pointer(&ret), 1008 callback.Ref(), 1009 ) 1010 1011 return 1012 } 1013 1014 // TryOffClicked calls the function "WEBEXT.chromeWebViewInternal.onClicked.removeListener" 1015 // in a try/catch block and returns (_, err, ok = false) when it went through 1016 // the catch clause. 1017 func TryOffClicked(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 1018 ok = js.True == bindings.TryOffClicked( 1019 js.Pointer(&ret), js.Pointer(&exception), 1020 callback.Ref(), 1021 ) 1022 1023 return 1024 } 1025 1026 // HasFuncHasOnClicked returns true if the function "WEBEXT.chromeWebViewInternal.onClicked.hasListener" exists. 1027 func HasFuncHasOnClicked() bool { 1028 return js.True == bindings.HasFuncHasOnClicked() 1029 } 1030 1031 // FuncHasOnClicked returns the function "WEBEXT.chromeWebViewInternal.onClicked.hasListener". 1032 func FuncHasOnClicked() (fn js.Func[func(callback js.Func[func()]) bool]) { 1033 bindings.FuncHasOnClicked( 1034 js.Pointer(&fn), 1035 ) 1036 return 1037 } 1038 1039 // HasOnClicked calls the function "WEBEXT.chromeWebViewInternal.onClicked.hasListener" directly. 1040 func HasOnClicked(callback js.Func[func()]) (ret bool) { 1041 bindings.CallHasOnClicked( 1042 js.Pointer(&ret), 1043 callback.Ref(), 1044 ) 1045 1046 return 1047 } 1048 1049 // TryHasOnClicked calls the function "WEBEXT.chromeWebViewInternal.onClicked.hasListener" 1050 // in a try/catch block and returns (_, err, ok = false) when it went through 1051 // the catch clause. 1052 func TryHasOnClicked(callback js.Func[func()]) (ret bool, exception js.Any, ok bool) { 1053 ok = js.True == bindings.TryHasOnClicked( 1054 js.Pointer(&ret), js.Pointer(&exception), 1055 callback.Ref(), 1056 ) 1057 1058 return 1059 } 1060 1061 type OnShowEventCallbackFunc func(this js.Ref, event *OnShowArgEvent) js.Ref 1062 1063 func (fn OnShowEventCallbackFunc) Register() js.Func[func(event *OnShowArgEvent)] { 1064 return js.RegisterCallback[func(event *OnShowArgEvent)]( 1065 fn, abi.FuncPCABIInternal(fn), 1066 ) 1067 } 1068 1069 func (fn OnShowEventCallbackFunc) DispatchCallback( 1070 targetPC uintptr, ctx *js.CallbackContext, 1071 ) { 1072 args := ctx.Args() 1073 if len(args) != 1+1 /* js this */ || 1074 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1075 js.ThrowInvalidCallbackInvocation() 1076 } 1077 var arg0 OnShowArgEvent 1078 arg0.UpdateFrom(args[0+1]) 1079 defer arg0.FreeMembers(true) 1080 1081 if ctx.Return(fn( 1082 args[0], 1083 1084 mark.NoEscape(&arg0), 1085 )) { 1086 return 1087 } 1088 1089 js.ThrowCallbackValueNotReturned() 1090 } 1091 1092 type OnShowEventCallback[T any] struct { 1093 Fn func(arg T, this js.Ref, event *OnShowArgEvent) js.Ref 1094 Arg T 1095 } 1096 1097 func (cb *OnShowEventCallback[T]) Register() js.Func[func(event *OnShowArgEvent)] { 1098 return js.RegisterCallback[func(event *OnShowArgEvent)]( 1099 cb, abi.FuncPCABIInternal(cb.Fn), 1100 ) 1101 } 1102 1103 func (cb *OnShowEventCallback[T]) DispatchCallback( 1104 targetPC uintptr, ctx *js.CallbackContext, 1105 ) { 1106 args := ctx.Args() 1107 if len(args) != 1+1 /* js this */ || 1108 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1109 js.ThrowInvalidCallbackInvocation() 1110 } 1111 var arg0 OnShowArgEvent 1112 arg0.UpdateFrom(args[0+1]) 1113 defer arg0.FreeMembers(true) 1114 1115 if ctx.Return(cb.Fn( 1116 cb.Arg, 1117 args[0], 1118 1119 mark.NoEscape(&arg0), 1120 )) { 1121 return 1122 } 1123 1124 js.ThrowCallbackValueNotReturned() 1125 } 1126 1127 // HasFuncOnShow returns true if the function "WEBEXT.chromeWebViewInternal.onShow.addListener" exists. 1128 func HasFuncOnShow() bool { 1129 return js.True == bindings.HasFuncOnShow() 1130 } 1131 1132 // FuncOnShow returns the function "WEBEXT.chromeWebViewInternal.onShow.addListener". 1133 func FuncOnShow() (fn js.Func[func(callback js.Func[func(event *OnShowArgEvent)])]) { 1134 bindings.FuncOnShow( 1135 js.Pointer(&fn), 1136 ) 1137 return 1138 } 1139 1140 // OnShow calls the function "WEBEXT.chromeWebViewInternal.onShow.addListener" directly. 1141 func OnShow(callback js.Func[func(event *OnShowArgEvent)]) (ret js.Void) { 1142 bindings.CallOnShow( 1143 js.Pointer(&ret), 1144 callback.Ref(), 1145 ) 1146 1147 return 1148 } 1149 1150 // TryOnShow calls the function "WEBEXT.chromeWebViewInternal.onShow.addListener" 1151 // in a try/catch block and returns (_, err, ok = false) when it went through 1152 // the catch clause. 1153 func TryOnShow(callback js.Func[func(event *OnShowArgEvent)]) (ret js.Void, exception js.Any, ok bool) { 1154 ok = js.True == bindings.TryOnShow( 1155 js.Pointer(&ret), js.Pointer(&exception), 1156 callback.Ref(), 1157 ) 1158 1159 return 1160 } 1161 1162 // HasFuncOffShow returns true if the function "WEBEXT.chromeWebViewInternal.onShow.removeListener" exists. 1163 func HasFuncOffShow() bool { 1164 return js.True == bindings.HasFuncOffShow() 1165 } 1166 1167 // FuncOffShow returns the function "WEBEXT.chromeWebViewInternal.onShow.removeListener". 1168 func FuncOffShow() (fn js.Func[func(callback js.Func[func(event *OnShowArgEvent)])]) { 1169 bindings.FuncOffShow( 1170 js.Pointer(&fn), 1171 ) 1172 return 1173 } 1174 1175 // OffShow calls the function "WEBEXT.chromeWebViewInternal.onShow.removeListener" directly. 1176 func OffShow(callback js.Func[func(event *OnShowArgEvent)]) (ret js.Void) { 1177 bindings.CallOffShow( 1178 js.Pointer(&ret), 1179 callback.Ref(), 1180 ) 1181 1182 return 1183 } 1184 1185 // TryOffShow calls the function "WEBEXT.chromeWebViewInternal.onShow.removeListener" 1186 // in a try/catch block and returns (_, err, ok = false) when it went through 1187 // the catch clause. 1188 func TryOffShow(callback js.Func[func(event *OnShowArgEvent)]) (ret js.Void, exception js.Any, ok bool) { 1189 ok = js.True == bindings.TryOffShow( 1190 js.Pointer(&ret), js.Pointer(&exception), 1191 callback.Ref(), 1192 ) 1193 1194 return 1195 } 1196 1197 // HasFuncHasOnShow returns true if the function "WEBEXT.chromeWebViewInternal.onShow.hasListener" exists. 1198 func HasFuncHasOnShow() bool { 1199 return js.True == bindings.HasFuncHasOnShow() 1200 } 1201 1202 // FuncHasOnShow returns the function "WEBEXT.chromeWebViewInternal.onShow.hasListener". 1203 func FuncHasOnShow() (fn js.Func[func(callback js.Func[func(event *OnShowArgEvent)]) bool]) { 1204 bindings.FuncHasOnShow( 1205 js.Pointer(&fn), 1206 ) 1207 return 1208 } 1209 1210 // HasOnShow calls the function "WEBEXT.chromeWebViewInternal.onShow.hasListener" directly. 1211 func HasOnShow(callback js.Func[func(event *OnShowArgEvent)]) (ret bool) { 1212 bindings.CallHasOnShow( 1213 js.Pointer(&ret), 1214 callback.Ref(), 1215 ) 1216 1217 return 1218 } 1219 1220 // TryHasOnShow calls the function "WEBEXT.chromeWebViewInternal.onShow.hasListener" 1221 // in a try/catch block and returns (_, err, ok = false) when it went through 1222 // the catch clause. 1223 func TryHasOnShow(callback js.Func[func(event *OnShowArgEvent)]) (ret bool, exception js.Any, ok bool) { 1224 ok = js.True == bindings.TryHasOnShow( 1225 js.Pointer(&ret), js.Pointer(&exception), 1226 callback.Ref(), 1227 ) 1228 1229 return 1230 } 1231 1232 // HasFuncShowContextMenu returns true if the function "WEBEXT.chromeWebViewInternal.showContextMenu" exists. 1233 func HasFuncShowContextMenu() bool { 1234 return js.True == bindings.HasFuncShowContextMenu() 1235 } 1236 1237 // FuncShowContextMenu returns the function "WEBEXT.chromeWebViewInternal.showContextMenu". 1238 func FuncShowContextMenu() (fn js.Func[func(instanceId int64, requestId int64, itemsToShow js.Array[ContextMenuItem])]) { 1239 bindings.FuncShowContextMenu( 1240 js.Pointer(&fn), 1241 ) 1242 return 1243 } 1244 1245 // ShowContextMenu calls the function "WEBEXT.chromeWebViewInternal.showContextMenu" directly. 1246 func ShowContextMenu(instanceId int64, requestId int64, itemsToShow js.Array[ContextMenuItem]) (ret js.Void) { 1247 bindings.CallShowContextMenu( 1248 js.Pointer(&ret), 1249 float64(instanceId), 1250 float64(requestId), 1251 itemsToShow.Ref(), 1252 ) 1253 1254 return 1255 } 1256 1257 // TryShowContextMenu calls the function "WEBEXT.chromeWebViewInternal.showContextMenu" 1258 // in a try/catch block and returns (_, err, ok = false) when it went through 1259 // the catch clause. 1260 func TryShowContextMenu(instanceId int64, requestId int64, itemsToShow js.Array[ContextMenuItem]) (ret js.Void, exception js.Any, ok bool) { 1261 ok = js.True == bindings.TryShowContextMenu( 1262 js.Pointer(&ret), js.Pointer(&exception), 1263 float64(instanceId), 1264 float64(requestId), 1265 itemsToShow.Ref(), 1266 ) 1267 1268 return 1269 }