github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/app/runtime/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package runtime 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/app/runtime/bindings" 11 ) 12 13 type ActionType uint32 14 15 const ( 16 _ ActionType = iota 17 18 ActionType_NEW_NOTE 19 ) 20 21 func (ActionType) FromRef(str js.Ref) ActionType { 22 return ActionType(bindings.ConstOfActionType(str)) 23 } 24 25 func (x ActionType) String() (string, bool) { 26 switch x { 27 case ActionType_NEW_NOTE: 28 return "new_note", true 29 default: 30 return "", false 31 } 32 } 33 34 type ActionData struct { 35 // ActionType is "ActionData.actionType" 36 // 37 // Optional 38 ActionType ActionType 39 // IsLockScreenAction is "ActionData.isLockScreenAction" 40 // 41 // Optional 42 // 43 // NOTE: FFI_USE_IsLockScreenAction MUST be set to true to make this field effective. 44 IsLockScreenAction bool 45 // RestoreLastActionState is "ActionData.restoreLastActionState" 46 // 47 // Optional 48 // 49 // NOTE: FFI_USE_RestoreLastActionState MUST be set to true to make this field effective. 50 RestoreLastActionState bool 51 52 FFI_USE_IsLockScreenAction bool // for IsLockScreenAction. 53 FFI_USE_RestoreLastActionState bool // for RestoreLastActionState. 54 55 FFI_USE bool 56 } 57 58 // FromRef calls UpdateFrom and returns a ActionData with all fields set. 59 func (p ActionData) FromRef(ref js.Ref) ActionData { 60 p.UpdateFrom(ref) 61 return p 62 } 63 64 // New creates a new ActionData in the application heap. 65 func (p ActionData) New() js.Ref { 66 return bindings.ActionDataJSLoad( 67 js.Pointer(&p), js.True, 0, 68 ) 69 } 70 71 // UpdateFrom copies value of all fields of the heap object to p. 72 func (p *ActionData) UpdateFrom(ref js.Ref) { 73 bindings.ActionDataJSStore( 74 js.Pointer(p), ref, 75 ) 76 } 77 78 // Update writes all fields of the p to the heap object referenced by ref. 79 func (p *ActionData) Update(ref js.Ref) { 80 bindings.ActionDataJSLoad( 81 js.Pointer(p), js.False, ref, 82 ) 83 } 84 85 // FreeMembers frees fields with heap reference, if recursive is true 86 // free all heap references reachable from p. 87 func (p *ActionData) FreeMembers(recursive bool) { 88 } 89 90 type EmbedRequest struct { 91 ref js.Ref 92 } 93 94 func (this EmbedRequest) Once() EmbedRequest { 95 this.ref.Once() 96 return this 97 } 98 99 func (this EmbedRequest) Ref() js.Ref { 100 return this.ref 101 } 102 103 func (this EmbedRequest) FromRef(ref js.Ref) EmbedRequest { 104 this.ref = ref 105 return this 106 } 107 108 func (this EmbedRequest) Free() { 109 this.ref.Free() 110 } 111 112 // EmbedderId returns the value of property "EmbedRequest.embedderId". 113 // 114 // It returns ok=false if there is no such property. 115 func (this EmbedRequest) EmbedderId() (ret js.String, ok bool) { 116 ok = js.True == bindings.GetEmbedRequestEmbedderId( 117 this.ref, js.Pointer(&ret), 118 ) 119 return 120 } 121 122 // SetEmbedderId sets the value of property "EmbedRequest.embedderId" to val. 123 // 124 // It returns false if the property cannot be set. 125 func (this EmbedRequest) SetEmbedderId(val js.String) bool { 126 return js.True == bindings.SetEmbedRequestEmbedderId( 127 this.ref, 128 val.Ref(), 129 ) 130 } 131 132 // Data returns the value of property "EmbedRequest.data". 133 // 134 // It returns ok=false if there is no such property. 135 func (this EmbedRequest) Data() (ret js.Any, ok bool) { 136 ok = js.True == bindings.GetEmbedRequestData( 137 this.ref, js.Pointer(&ret), 138 ) 139 return 140 } 141 142 // SetData sets the value of property "EmbedRequest.data" to val. 143 // 144 // It returns false if the property cannot be set. 145 func (this EmbedRequest) SetData(val js.Any) bool { 146 return js.True == bindings.SetEmbedRequestData( 147 this.ref, 148 val.Ref(), 149 ) 150 } 151 152 // HasFuncAllow returns true if the method "EmbedRequest.allow" exists. 153 func (this EmbedRequest) HasFuncAllow() bool { 154 return js.True == bindings.HasFuncEmbedRequestAllow( 155 this.ref, 156 ) 157 } 158 159 // FuncAllow returns the method "EmbedRequest.allow". 160 func (this EmbedRequest) FuncAllow() (fn js.Func[func(url js.String)]) { 161 bindings.FuncEmbedRequestAllow( 162 this.ref, js.Pointer(&fn), 163 ) 164 return 165 } 166 167 // Allow calls the method "EmbedRequest.allow". 168 func (this EmbedRequest) Allow(url js.String) (ret js.Void) { 169 bindings.CallEmbedRequestAllow( 170 this.ref, js.Pointer(&ret), 171 url.Ref(), 172 ) 173 174 return 175 } 176 177 // TryAllow calls the method "EmbedRequest.allow" 178 // in a try/catch block and returns (_, err, ok = false) when it went through 179 // the catch clause. 180 func (this EmbedRequest) TryAllow(url js.String) (ret js.Void, exception js.Any, ok bool) { 181 ok = js.True == bindings.TryEmbedRequestAllow( 182 this.ref, js.Pointer(&ret), js.Pointer(&exception), 183 url.Ref(), 184 ) 185 186 return 187 } 188 189 // HasFuncDeny returns true if the method "EmbedRequest.deny" exists. 190 func (this EmbedRequest) HasFuncDeny() bool { 191 return js.True == bindings.HasFuncEmbedRequestDeny( 192 this.ref, 193 ) 194 } 195 196 // FuncDeny returns the method "EmbedRequest.deny". 197 func (this EmbedRequest) FuncDeny() (fn js.Func[func()]) { 198 bindings.FuncEmbedRequestDeny( 199 this.ref, js.Pointer(&fn), 200 ) 201 return 202 } 203 204 // Deny calls the method "EmbedRequest.deny". 205 func (this EmbedRequest) Deny() (ret js.Void) { 206 bindings.CallEmbedRequestDeny( 207 this.ref, js.Pointer(&ret), 208 ) 209 210 return 211 } 212 213 // TryDeny calls the method "EmbedRequest.deny" 214 // in a try/catch block and returns (_, err, ok = false) when it went through 215 // the catch clause. 216 func (this EmbedRequest) TryDeny() (ret js.Void, exception js.Any, ok bool) { 217 ok = js.True == bindings.TryEmbedRequestDeny( 218 this.ref, js.Pointer(&ret), js.Pointer(&exception), 219 ) 220 221 return 222 } 223 224 type LaunchItem struct { 225 // Entry is "LaunchItem.entry" 226 // 227 // Optional 228 Entry js.Object 229 // Type is "LaunchItem.type" 230 // 231 // Optional 232 Type js.String 233 234 FFI_USE bool 235 } 236 237 // FromRef calls UpdateFrom and returns a LaunchItem with all fields set. 238 func (p LaunchItem) FromRef(ref js.Ref) LaunchItem { 239 p.UpdateFrom(ref) 240 return p 241 } 242 243 // New creates a new LaunchItem in the application heap. 244 func (p LaunchItem) New() js.Ref { 245 return bindings.LaunchItemJSLoad( 246 js.Pointer(&p), js.True, 0, 247 ) 248 } 249 250 // UpdateFrom copies value of all fields of the heap object to p. 251 func (p *LaunchItem) UpdateFrom(ref js.Ref) { 252 bindings.LaunchItemJSStore( 253 js.Pointer(p), ref, 254 ) 255 } 256 257 // Update writes all fields of the p to the heap object referenced by ref. 258 func (p *LaunchItem) Update(ref js.Ref) { 259 bindings.LaunchItemJSLoad( 260 js.Pointer(p), js.False, ref, 261 ) 262 } 263 264 // FreeMembers frees fields with heap reference, if recursive is true 265 // free all heap references reachable from p. 266 func (p *LaunchItem) FreeMembers(recursive bool) { 267 js.Free( 268 p.Entry.Ref(), 269 p.Type.Ref(), 270 ) 271 p.Entry = p.Entry.FromRef(js.Undefined) 272 p.Type = p.Type.FromRef(js.Undefined) 273 } 274 275 type LaunchSource uint32 276 277 const ( 278 _ LaunchSource = iota 279 280 LaunchSource_UNTRACKED 281 LaunchSource_APP_LAUNCHER 282 LaunchSource_NEW_TAB_PAGE 283 LaunchSource_RELOAD 284 LaunchSource_RESTART 285 LaunchSource_LOAD_AND_LAUNCH 286 LaunchSource_COMMAND_LINE 287 LaunchSource_FILE_HANDLER 288 LaunchSource_URL_HANDLER 289 LaunchSource_SYSTEM_TRAY 290 LaunchSource_ABOUT_PAGE 291 LaunchSource_KEYBOARD 292 LaunchSource_EXTENSIONS_PAGE 293 LaunchSource_MANAGEMENT_API 294 LaunchSource_EPHEMERAL_APP 295 LaunchSource_BACKGROUND 296 LaunchSource_KIOSK 297 LaunchSource_CHROME_INTERNAL 298 LaunchSource_TEST 299 LaunchSource_INSTALLED_NOTIFICATION 300 LaunchSource_CONTEXT_MENU 301 LaunchSource_ARC 302 LaunchSource_INTENT_URL 303 LaunchSource_APP_HOME_PAGE 304 ) 305 306 func (LaunchSource) FromRef(str js.Ref) LaunchSource { 307 return LaunchSource(bindings.ConstOfLaunchSource(str)) 308 } 309 310 func (x LaunchSource) String() (string, bool) { 311 switch x { 312 case LaunchSource_UNTRACKED: 313 return "untracked", true 314 case LaunchSource_APP_LAUNCHER: 315 return "app_launcher", true 316 case LaunchSource_NEW_TAB_PAGE: 317 return "new_tab_page", true 318 case LaunchSource_RELOAD: 319 return "reload", true 320 case LaunchSource_RESTART: 321 return "restart", true 322 case LaunchSource_LOAD_AND_LAUNCH: 323 return "load_and_launch", true 324 case LaunchSource_COMMAND_LINE: 325 return "command_line", true 326 case LaunchSource_FILE_HANDLER: 327 return "file_handler", true 328 case LaunchSource_URL_HANDLER: 329 return "url_handler", true 330 case LaunchSource_SYSTEM_TRAY: 331 return "system_tray", true 332 case LaunchSource_ABOUT_PAGE: 333 return "about_page", true 334 case LaunchSource_KEYBOARD: 335 return "keyboard", true 336 case LaunchSource_EXTENSIONS_PAGE: 337 return "extensions_page", true 338 case LaunchSource_MANAGEMENT_API: 339 return "management_api", true 340 case LaunchSource_EPHEMERAL_APP: 341 return "ephemeral_app", true 342 case LaunchSource_BACKGROUND: 343 return "background", true 344 case LaunchSource_KIOSK: 345 return "kiosk", true 346 case LaunchSource_CHROME_INTERNAL: 347 return "chrome_internal", true 348 case LaunchSource_TEST: 349 return "test", true 350 case LaunchSource_INSTALLED_NOTIFICATION: 351 return "installed_notification", true 352 case LaunchSource_CONTEXT_MENU: 353 return "context_menu", true 354 case LaunchSource_ARC: 355 return "arc", true 356 case LaunchSource_INTENT_URL: 357 return "intent_url", true 358 case LaunchSource_APP_HOME_PAGE: 359 return "app_home_page", true 360 default: 361 return "", false 362 } 363 } 364 365 type LaunchData struct { 366 // Id is "LaunchData.id" 367 // 368 // Optional 369 Id js.String 370 // Items is "LaunchData.items" 371 // 372 // Optional 373 Items js.Array[LaunchItem] 374 // Url is "LaunchData.url" 375 // 376 // Optional 377 Url js.String 378 // ReferrerUrl is "LaunchData.referrerUrl" 379 // 380 // Optional 381 ReferrerUrl js.String 382 // IsDemoSession is "LaunchData.isDemoSession" 383 // 384 // Optional 385 // 386 // NOTE: FFI_USE_IsDemoSession MUST be set to true to make this field effective. 387 IsDemoSession bool 388 // IsKioskSession is "LaunchData.isKioskSession" 389 // 390 // Optional 391 // 392 // NOTE: FFI_USE_IsKioskSession MUST be set to true to make this field effective. 393 IsKioskSession bool 394 // IsPublicSession is "LaunchData.isPublicSession" 395 // 396 // Optional 397 // 398 // NOTE: FFI_USE_IsPublicSession MUST be set to true to make this field effective. 399 IsPublicSession bool 400 // Source is "LaunchData.source" 401 // 402 // Optional 403 Source LaunchSource 404 // ActionData is "LaunchData.actionData" 405 // 406 // Optional 407 // 408 // NOTE: ActionData.FFI_USE MUST be set to true to get ActionData used. 409 ActionData ActionData 410 411 FFI_USE_IsDemoSession bool // for IsDemoSession. 412 FFI_USE_IsKioskSession bool // for IsKioskSession. 413 FFI_USE_IsPublicSession bool // for IsPublicSession. 414 415 FFI_USE bool 416 } 417 418 // FromRef calls UpdateFrom and returns a LaunchData with all fields set. 419 func (p LaunchData) FromRef(ref js.Ref) LaunchData { 420 p.UpdateFrom(ref) 421 return p 422 } 423 424 // New creates a new LaunchData in the application heap. 425 func (p LaunchData) New() js.Ref { 426 return bindings.LaunchDataJSLoad( 427 js.Pointer(&p), js.True, 0, 428 ) 429 } 430 431 // UpdateFrom copies value of all fields of the heap object to p. 432 func (p *LaunchData) UpdateFrom(ref js.Ref) { 433 bindings.LaunchDataJSStore( 434 js.Pointer(p), ref, 435 ) 436 } 437 438 // Update writes all fields of the p to the heap object referenced by ref. 439 func (p *LaunchData) Update(ref js.Ref) { 440 bindings.LaunchDataJSLoad( 441 js.Pointer(p), js.False, ref, 442 ) 443 } 444 445 // FreeMembers frees fields with heap reference, if recursive is true 446 // free all heap references reachable from p. 447 func (p *LaunchData) FreeMembers(recursive bool) { 448 js.Free( 449 p.Id.Ref(), 450 p.Items.Ref(), 451 p.Url.Ref(), 452 p.ReferrerUrl.Ref(), 453 ) 454 p.Id = p.Id.FromRef(js.Undefined) 455 p.Items = p.Items.FromRef(js.Undefined) 456 p.Url = p.Url.FromRef(js.Undefined) 457 p.ReferrerUrl = p.ReferrerUrl.FromRef(js.Undefined) 458 if recursive { 459 p.ActionData.FreeMembers(true) 460 } 461 } 462 463 type OnEmbedRequestedEventCallbackFunc func(this js.Ref, request EmbedRequest) js.Ref 464 465 func (fn OnEmbedRequestedEventCallbackFunc) Register() js.Func[func(request EmbedRequest)] { 466 return js.RegisterCallback[func(request EmbedRequest)]( 467 fn, abi.FuncPCABIInternal(fn), 468 ) 469 } 470 471 func (fn OnEmbedRequestedEventCallbackFunc) DispatchCallback( 472 targetPC uintptr, ctx *js.CallbackContext, 473 ) { 474 args := ctx.Args() 475 if len(args) != 1+1 /* js this */ || 476 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 477 js.ThrowInvalidCallbackInvocation() 478 } 479 480 if ctx.Return(fn( 481 args[0], 482 483 EmbedRequest{}.FromRef(args[0+1]), 484 )) { 485 return 486 } 487 488 js.ThrowCallbackValueNotReturned() 489 } 490 491 type OnEmbedRequestedEventCallback[T any] struct { 492 Fn func(arg T, this js.Ref, request EmbedRequest) js.Ref 493 Arg T 494 } 495 496 func (cb *OnEmbedRequestedEventCallback[T]) Register() js.Func[func(request EmbedRequest)] { 497 return js.RegisterCallback[func(request EmbedRequest)]( 498 cb, abi.FuncPCABIInternal(cb.Fn), 499 ) 500 } 501 502 func (cb *OnEmbedRequestedEventCallback[T]) DispatchCallback( 503 targetPC uintptr, ctx *js.CallbackContext, 504 ) { 505 args := ctx.Args() 506 if len(args) != 1+1 /* js this */ || 507 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 508 js.ThrowInvalidCallbackInvocation() 509 } 510 511 if ctx.Return(cb.Fn( 512 cb.Arg, 513 args[0], 514 515 EmbedRequest{}.FromRef(args[0+1]), 516 )) { 517 return 518 } 519 520 js.ThrowCallbackValueNotReturned() 521 } 522 523 // HasFuncOnEmbedRequested returns true if the function "WEBEXT.app.runtime.onEmbedRequested.addListener" exists. 524 func HasFuncOnEmbedRequested() bool { 525 return js.True == bindings.HasFuncOnEmbedRequested() 526 } 527 528 // FuncOnEmbedRequested returns the function "WEBEXT.app.runtime.onEmbedRequested.addListener". 529 func FuncOnEmbedRequested() (fn js.Func[func(callback js.Func[func(request EmbedRequest)])]) { 530 bindings.FuncOnEmbedRequested( 531 js.Pointer(&fn), 532 ) 533 return 534 } 535 536 // OnEmbedRequested calls the function "WEBEXT.app.runtime.onEmbedRequested.addListener" directly. 537 func OnEmbedRequested(callback js.Func[func(request EmbedRequest)]) (ret js.Void) { 538 bindings.CallOnEmbedRequested( 539 js.Pointer(&ret), 540 callback.Ref(), 541 ) 542 543 return 544 } 545 546 // TryOnEmbedRequested calls the function "WEBEXT.app.runtime.onEmbedRequested.addListener" 547 // in a try/catch block and returns (_, err, ok = false) when it went through 548 // the catch clause. 549 func TryOnEmbedRequested(callback js.Func[func(request EmbedRequest)]) (ret js.Void, exception js.Any, ok bool) { 550 ok = js.True == bindings.TryOnEmbedRequested( 551 js.Pointer(&ret), js.Pointer(&exception), 552 callback.Ref(), 553 ) 554 555 return 556 } 557 558 // HasFuncOffEmbedRequested returns true if the function "WEBEXT.app.runtime.onEmbedRequested.removeListener" exists. 559 func HasFuncOffEmbedRequested() bool { 560 return js.True == bindings.HasFuncOffEmbedRequested() 561 } 562 563 // FuncOffEmbedRequested returns the function "WEBEXT.app.runtime.onEmbedRequested.removeListener". 564 func FuncOffEmbedRequested() (fn js.Func[func(callback js.Func[func(request EmbedRequest)])]) { 565 bindings.FuncOffEmbedRequested( 566 js.Pointer(&fn), 567 ) 568 return 569 } 570 571 // OffEmbedRequested calls the function "WEBEXT.app.runtime.onEmbedRequested.removeListener" directly. 572 func OffEmbedRequested(callback js.Func[func(request EmbedRequest)]) (ret js.Void) { 573 bindings.CallOffEmbedRequested( 574 js.Pointer(&ret), 575 callback.Ref(), 576 ) 577 578 return 579 } 580 581 // TryOffEmbedRequested calls the function "WEBEXT.app.runtime.onEmbedRequested.removeListener" 582 // in a try/catch block and returns (_, err, ok = false) when it went through 583 // the catch clause. 584 func TryOffEmbedRequested(callback js.Func[func(request EmbedRequest)]) (ret js.Void, exception js.Any, ok bool) { 585 ok = js.True == bindings.TryOffEmbedRequested( 586 js.Pointer(&ret), js.Pointer(&exception), 587 callback.Ref(), 588 ) 589 590 return 591 } 592 593 // HasFuncHasOnEmbedRequested returns true if the function "WEBEXT.app.runtime.onEmbedRequested.hasListener" exists. 594 func HasFuncHasOnEmbedRequested() bool { 595 return js.True == bindings.HasFuncHasOnEmbedRequested() 596 } 597 598 // FuncHasOnEmbedRequested returns the function "WEBEXT.app.runtime.onEmbedRequested.hasListener". 599 func FuncHasOnEmbedRequested() (fn js.Func[func(callback js.Func[func(request EmbedRequest)]) bool]) { 600 bindings.FuncHasOnEmbedRequested( 601 js.Pointer(&fn), 602 ) 603 return 604 } 605 606 // HasOnEmbedRequested calls the function "WEBEXT.app.runtime.onEmbedRequested.hasListener" directly. 607 func HasOnEmbedRequested(callback js.Func[func(request EmbedRequest)]) (ret bool) { 608 bindings.CallHasOnEmbedRequested( 609 js.Pointer(&ret), 610 callback.Ref(), 611 ) 612 613 return 614 } 615 616 // TryHasOnEmbedRequested calls the function "WEBEXT.app.runtime.onEmbedRequested.hasListener" 617 // in a try/catch block and returns (_, err, ok = false) when it went through 618 // the catch clause. 619 func TryHasOnEmbedRequested(callback js.Func[func(request EmbedRequest)]) (ret bool, exception js.Any, ok bool) { 620 ok = js.True == bindings.TryHasOnEmbedRequested( 621 js.Pointer(&ret), js.Pointer(&exception), 622 callback.Ref(), 623 ) 624 625 return 626 } 627 628 type OnLaunchedEventCallbackFunc func(this js.Ref, launchData *LaunchData) js.Ref 629 630 func (fn OnLaunchedEventCallbackFunc) Register() js.Func[func(launchData *LaunchData)] { 631 return js.RegisterCallback[func(launchData *LaunchData)]( 632 fn, abi.FuncPCABIInternal(fn), 633 ) 634 } 635 636 func (fn OnLaunchedEventCallbackFunc) DispatchCallback( 637 targetPC uintptr, ctx *js.CallbackContext, 638 ) { 639 args := ctx.Args() 640 if len(args) != 1+1 /* js this */ || 641 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 642 js.ThrowInvalidCallbackInvocation() 643 } 644 var arg0 LaunchData 645 arg0.UpdateFrom(args[0+1]) 646 defer arg0.FreeMembers(true) 647 648 if ctx.Return(fn( 649 args[0], 650 651 mark.NoEscape(&arg0), 652 )) { 653 return 654 } 655 656 js.ThrowCallbackValueNotReturned() 657 } 658 659 type OnLaunchedEventCallback[T any] struct { 660 Fn func(arg T, this js.Ref, launchData *LaunchData) js.Ref 661 Arg T 662 } 663 664 func (cb *OnLaunchedEventCallback[T]) Register() js.Func[func(launchData *LaunchData)] { 665 return js.RegisterCallback[func(launchData *LaunchData)]( 666 cb, abi.FuncPCABIInternal(cb.Fn), 667 ) 668 } 669 670 func (cb *OnLaunchedEventCallback[T]) DispatchCallback( 671 targetPC uintptr, ctx *js.CallbackContext, 672 ) { 673 args := ctx.Args() 674 if len(args) != 1+1 /* js this */ || 675 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 676 js.ThrowInvalidCallbackInvocation() 677 } 678 var arg0 LaunchData 679 arg0.UpdateFrom(args[0+1]) 680 defer arg0.FreeMembers(true) 681 682 if ctx.Return(cb.Fn( 683 cb.Arg, 684 args[0], 685 686 mark.NoEscape(&arg0), 687 )) { 688 return 689 } 690 691 js.ThrowCallbackValueNotReturned() 692 } 693 694 // HasFuncOnLaunched returns true if the function "WEBEXT.app.runtime.onLaunched.addListener" exists. 695 func HasFuncOnLaunched() bool { 696 return js.True == bindings.HasFuncOnLaunched() 697 } 698 699 // FuncOnLaunched returns the function "WEBEXT.app.runtime.onLaunched.addListener". 700 func FuncOnLaunched() (fn js.Func[func(callback js.Func[func(launchData *LaunchData)])]) { 701 bindings.FuncOnLaunched( 702 js.Pointer(&fn), 703 ) 704 return 705 } 706 707 // OnLaunched calls the function "WEBEXT.app.runtime.onLaunched.addListener" directly. 708 func OnLaunched(callback js.Func[func(launchData *LaunchData)]) (ret js.Void) { 709 bindings.CallOnLaunched( 710 js.Pointer(&ret), 711 callback.Ref(), 712 ) 713 714 return 715 } 716 717 // TryOnLaunched calls the function "WEBEXT.app.runtime.onLaunched.addListener" 718 // in a try/catch block and returns (_, err, ok = false) when it went through 719 // the catch clause. 720 func TryOnLaunched(callback js.Func[func(launchData *LaunchData)]) (ret js.Void, exception js.Any, ok bool) { 721 ok = js.True == bindings.TryOnLaunched( 722 js.Pointer(&ret), js.Pointer(&exception), 723 callback.Ref(), 724 ) 725 726 return 727 } 728 729 // HasFuncOffLaunched returns true if the function "WEBEXT.app.runtime.onLaunched.removeListener" exists. 730 func HasFuncOffLaunched() bool { 731 return js.True == bindings.HasFuncOffLaunched() 732 } 733 734 // FuncOffLaunched returns the function "WEBEXT.app.runtime.onLaunched.removeListener". 735 func FuncOffLaunched() (fn js.Func[func(callback js.Func[func(launchData *LaunchData)])]) { 736 bindings.FuncOffLaunched( 737 js.Pointer(&fn), 738 ) 739 return 740 } 741 742 // OffLaunched calls the function "WEBEXT.app.runtime.onLaunched.removeListener" directly. 743 func OffLaunched(callback js.Func[func(launchData *LaunchData)]) (ret js.Void) { 744 bindings.CallOffLaunched( 745 js.Pointer(&ret), 746 callback.Ref(), 747 ) 748 749 return 750 } 751 752 // TryOffLaunched calls the function "WEBEXT.app.runtime.onLaunched.removeListener" 753 // in a try/catch block and returns (_, err, ok = false) when it went through 754 // the catch clause. 755 func TryOffLaunched(callback js.Func[func(launchData *LaunchData)]) (ret js.Void, exception js.Any, ok bool) { 756 ok = js.True == bindings.TryOffLaunched( 757 js.Pointer(&ret), js.Pointer(&exception), 758 callback.Ref(), 759 ) 760 761 return 762 } 763 764 // HasFuncHasOnLaunched returns true if the function "WEBEXT.app.runtime.onLaunched.hasListener" exists. 765 func HasFuncHasOnLaunched() bool { 766 return js.True == bindings.HasFuncHasOnLaunched() 767 } 768 769 // FuncHasOnLaunched returns the function "WEBEXT.app.runtime.onLaunched.hasListener". 770 func FuncHasOnLaunched() (fn js.Func[func(callback js.Func[func(launchData *LaunchData)]) bool]) { 771 bindings.FuncHasOnLaunched( 772 js.Pointer(&fn), 773 ) 774 return 775 } 776 777 // HasOnLaunched calls the function "WEBEXT.app.runtime.onLaunched.hasListener" directly. 778 func HasOnLaunched(callback js.Func[func(launchData *LaunchData)]) (ret bool) { 779 bindings.CallHasOnLaunched( 780 js.Pointer(&ret), 781 callback.Ref(), 782 ) 783 784 return 785 } 786 787 // TryHasOnLaunched calls the function "WEBEXT.app.runtime.onLaunched.hasListener" 788 // in a try/catch block and returns (_, err, ok = false) when it went through 789 // the catch clause. 790 func TryHasOnLaunched(callback js.Func[func(launchData *LaunchData)]) (ret bool, exception js.Any, ok bool) { 791 ok = js.True == bindings.TryHasOnLaunched( 792 js.Pointer(&ret), js.Pointer(&exception), 793 callback.Ref(), 794 ) 795 796 return 797 } 798 799 type OnRestartedEventCallbackFunc func(this js.Ref) js.Ref 800 801 func (fn OnRestartedEventCallbackFunc) Register() js.Func[func()] { 802 return js.RegisterCallback[func()]( 803 fn, abi.FuncPCABIInternal(fn), 804 ) 805 } 806 807 func (fn OnRestartedEventCallbackFunc) DispatchCallback( 808 targetPC uintptr, ctx *js.CallbackContext, 809 ) { 810 args := ctx.Args() 811 if len(args) != 0+1 /* js this */ || 812 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 813 js.ThrowInvalidCallbackInvocation() 814 } 815 816 if ctx.Return(fn( 817 args[0], 818 )) { 819 return 820 } 821 822 js.ThrowCallbackValueNotReturned() 823 } 824 825 type OnRestartedEventCallback[T any] struct { 826 Fn func(arg T, this js.Ref) js.Ref 827 Arg T 828 } 829 830 func (cb *OnRestartedEventCallback[T]) Register() js.Func[func()] { 831 return js.RegisterCallback[func()]( 832 cb, abi.FuncPCABIInternal(cb.Fn), 833 ) 834 } 835 836 func (cb *OnRestartedEventCallback[T]) DispatchCallback( 837 targetPC uintptr, ctx *js.CallbackContext, 838 ) { 839 args := ctx.Args() 840 if len(args) != 0+1 /* js this */ || 841 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 842 js.ThrowInvalidCallbackInvocation() 843 } 844 845 if ctx.Return(cb.Fn( 846 cb.Arg, 847 args[0], 848 )) { 849 return 850 } 851 852 js.ThrowCallbackValueNotReturned() 853 } 854 855 // HasFuncOnRestarted returns true if the function "WEBEXT.app.runtime.onRestarted.addListener" exists. 856 func HasFuncOnRestarted() bool { 857 return js.True == bindings.HasFuncOnRestarted() 858 } 859 860 // FuncOnRestarted returns the function "WEBEXT.app.runtime.onRestarted.addListener". 861 func FuncOnRestarted() (fn js.Func[func(callback js.Func[func()])]) { 862 bindings.FuncOnRestarted( 863 js.Pointer(&fn), 864 ) 865 return 866 } 867 868 // OnRestarted calls the function "WEBEXT.app.runtime.onRestarted.addListener" directly. 869 func OnRestarted(callback js.Func[func()]) (ret js.Void) { 870 bindings.CallOnRestarted( 871 js.Pointer(&ret), 872 callback.Ref(), 873 ) 874 875 return 876 } 877 878 // TryOnRestarted calls the function "WEBEXT.app.runtime.onRestarted.addListener" 879 // in a try/catch block and returns (_, err, ok = false) when it went through 880 // the catch clause. 881 func TryOnRestarted(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 882 ok = js.True == bindings.TryOnRestarted( 883 js.Pointer(&ret), js.Pointer(&exception), 884 callback.Ref(), 885 ) 886 887 return 888 } 889 890 // HasFuncOffRestarted returns true if the function "WEBEXT.app.runtime.onRestarted.removeListener" exists. 891 func HasFuncOffRestarted() bool { 892 return js.True == bindings.HasFuncOffRestarted() 893 } 894 895 // FuncOffRestarted returns the function "WEBEXT.app.runtime.onRestarted.removeListener". 896 func FuncOffRestarted() (fn js.Func[func(callback js.Func[func()])]) { 897 bindings.FuncOffRestarted( 898 js.Pointer(&fn), 899 ) 900 return 901 } 902 903 // OffRestarted calls the function "WEBEXT.app.runtime.onRestarted.removeListener" directly. 904 func OffRestarted(callback js.Func[func()]) (ret js.Void) { 905 bindings.CallOffRestarted( 906 js.Pointer(&ret), 907 callback.Ref(), 908 ) 909 910 return 911 } 912 913 // TryOffRestarted calls the function "WEBEXT.app.runtime.onRestarted.removeListener" 914 // in a try/catch block and returns (_, err, ok = false) when it went through 915 // the catch clause. 916 func TryOffRestarted(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 917 ok = js.True == bindings.TryOffRestarted( 918 js.Pointer(&ret), js.Pointer(&exception), 919 callback.Ref(), 920 ) 921 922 return 923 } 924 925 // HasFuncHasOnRestarted returns true if the function "WEBEXT.app.runtime.onRestarted.hasListener" exists. 926 func HasFuncHasOnRestarted() bool { 927 return js.True == bindings.HasFuncHasOnRestarted() 928 } 929 930 // FuncHasOnRestarted returns the function "WEBEXT.app.runtime.onRestarted.hasListener". 931 func FuncHasOnRestarted() (fn js.Func[func(callback js.Func[func()]) bool]) { 932 bindings.FuncHasOnRestarted( 933 js.Pointer(&fn), 934 ) 935 return 936 } 937 938 // HasOnRestarted calls the function "WEBEXT.app.runtime.onRestarted.hasListener" directly. 939 func HasOnRestarted(callback js.Func[func()]) (ret bool) { 940 bindings.CallHasOnRestarted( 941 js.Pointer(&ret), 942 callback.Ref(), 943 ) 944 945 return 946 } 947 948 // TryHasOnRestarted calls the function "WEBEXT.app.runtime.onRestarted.hasListener" 949 // in a try/catch block and returns (_, err, ok = false) when it went through 950 // the catch clause. 951 func TryHasOnRestarted(callback js.Func[func()]) (ret bool, exception js.Any, ok bool) { 952 ok = js.True == bindings.TryHasOnRestarted( 953 js.Pointer(&ret), js.Pointer(&exception), 954 callback.Ref(), 955 ) 956 957 return 958 }