github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/notifications/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package notifications 5 6 import ( 7 "github.com/primecitizens/pcz/std/core/abi" 8 "github.com/primecitizens/pcz/std/ffi/js" 9 "github.com/primecitizens/pcz/std/plat/js/webext/notifications/bindings" 10 ) 11 12 type ClearCallbackFunc func(this js.Ref, wasCleared bool) js.Ref 13 14 func (fn ClearCallbackFunc) Register() js.Func[func(wasCleared bool)] { 15 return js.RegisterCallback[func(wasCleared bool)]( 16 fn, abi.FuncPCABIInternal(fn), 17 ) 18 } 19 20 func (fn ClearCallbackFunc) DispatchCallback( 21 targetPC uintptr, ctx *js.CallbackContext, 22 ) { 23 args := ctx.Args() 24 if len(args) != 1+1 /* js this */ || 25 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 26 js.ThrowInvalidCallbackInvocation() 27 } 28 29 if ctx.Return(fn( 30 args[0], 31 32 args[0+1] == js.True, 33 )) { 34 return 35 } 36 37 js.ThrowCallbackValueNotReturned() 38 } 39 40 type ClearCallback[T any] struct { 41 Fn func(arg T, this js.Ref, wasCleared bool) js.Ref 42 Arg T 43 } 44 45 func (cb *ClearCallback[T]) Register() js.Func[func(wasCleared bool)] { 46 return js.RegisterCallback[func(wasCleared bool)]( 47 cb, abi.FuncPCABIInternal(cb.Fn), 48 ) 49 } 50 51 func (cb *ClearCallback[T]) DispatchCallback( 52 targetPC uintptr, ctx *js.CallbackContext, 53 ) { 54 args := ctx.Args() 55 if len(args) != 1+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 args[0+1] == js.True, 65 )) { 66 return 67 } 68 69 js.ThrowCallbackValueNotReturned() 70 } 71 72 type CreateCallbackFunc func(this js.Ref, notificationId js.String) js.Ref 73 74 func (fn CreateCallbackFunc) Register() js.Func[func(notificationId js.String)] { 75 return js.RegisterCallback[func(notificationId js.String)]( 76 fn, abi.FuncPCABIInternal(fn), 77 ) 78 } 79 80 func (fn CreateCallbackFunc) DispatchCallback( 81 targetPC uintptr, ctx *js.CallbackContext, 82 ) { 83 args := ctx.Args() 84 if len(args) != 1+1 /* js this */ || 85 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 86 js.ThrowInvalidCallbackInvocation() 87 } 88 89 if ctx.Return(fn( 90 args[0], 91 92 js.String{}.FromRef(args[0+1]), 93 )) { 94 return 95 } 96 97 js.ThrowCallbackValueNotReturned() 98 } 99 100 type CreateCallback[T any] struct { 101 Fn func(arg T, this js.Ref, notificationId js.String) js.Ref 102 Arg T 103 } 104 105 func (cb *CreateCallback[T]) Register() js.Func[func(notificationId js.String)] { 106 return js.RegisterCallback[func(notificationId js.String)]( 107 cb, abi.FuncPCABIInternal(cb.Fn), 108 ) 109 } 110 111 func (cb *CreateCallback[T]) DispatchCallback( 112 targetPC uintptr, ctx *js.CallbackContext, 113 ) { 114 args := ctx.Args() 115 if len(args) != 1+1 /* js this */ || 116 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 117 js.ThrowInvalidCallbackInvocation() 118 } 119 120 if ctx.Return(cb.Fn( 121 cb.Arg, 122 args[0], 123 124 js.String{}.FromRef(args[0+1]), 125 )) { 126 return 127 } 128 129 js.ThrowCallbackValueNotReturned() 130 } 131 132 type GetAllCallbackFunc func(this js.Ref, notifications js.Object) js.Ref 133 134 func (fn GetAllCallbackFunc) Register() js.Func[func(notifications js.Object)] { 135 return js.RegisterCallback[func(notifications js.Object)]( 136 fn, abi.FuncPCABIInternal(fn), 137 ) 138 } 139 140 func (fn GetAllCallbackFunc) DispatchCallback( 141 targetPC uintptr, ctx *js.CallbackContext, 142 ) { 143 args := ctx.Args() 144 if len(args) != 1+1 /* js this */ || 145 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 146 js.ThrowInvalidCallbackInvocation() 147 } 148 149 if ctx.Return(fn( 150 args[0], 151 152 js.Object{}.FromRef(args[0+1]), 153 )) { 154 return 155 } 156 157 js.ThrowCallbackValueNotReturned() 158 } 159 160 type GetAllCallback[T any] struct { 161 Fn func(arg T, this js.Ref, notifications js.Object) js.Ref 162 Arg T 163 } 164 165 func (cb *GetAllCallback[T]) Register() js.Func[func(notifications js.Object)] { 166 return js.RegisterCallback[func(notifications js.Object)]( 167 cb, abi.FuncPCABIInternal(cb.Fn), 168 ) 169 } 170 171 func (cb *GetAllCallback[T]) DispatchCallback( 172 targetPC uintptr, ctx *js.CallbackContext, 173 ) { 174 args := ctx.Args() 175 if len(args) != 1+1 /* js this */ || 176 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 177 js.ThrowInvalidCallbackInvocation() 178 } 179 180 if ctx.Return(cb.Fn( 181 cb.Arg, 182 args[0], 183 184 js.Object{}.FromRef(args[0+1]), 185 )) { 186 return 187 } 188 189 js.ThrowCallbackValueNotReturned() 190 } 191 192 type NotificationBitmap struct { 193 // Width is "NotificationBitmap.width" 194 // 195 // Optional 196 // 197 // NOTE: FFI_USE_Width MUST be set to true to make this field effective. 198 Width int32 199 // Height is "NotificationBitmap.height" 200 // 201 // Optional 202 // 203 // NOTE: FFI_USE_Height MUST be set to true to make this field effective. 204 Height int32 205 // Data is "NotificationBitmap.data" 206 // 207 // Optional 208 Data js.ArrayBuffer 209 210 FFI_USE_Width bool // for Width. 211 FFI_USE_Height bool // for Height. 212 213 FFI_USE bool 214 } 215 216 // FromRef calls UpdateFrom and returns a NotificationBitmap with all fields set. 217 func (p NotificationBitmap) FromRef(ref js.Ref) NotificationBitmap { 218 p.UpdateFrom(ref) 219 return p 220 } 221 222 // New creates a new NotificationBitmap in the application heap. 223 func (p NotificationBitmap) New() js.Ref { 224 return bindings.NotificationBitmapJSLoad( 225 js.Pointer(&p), js.True, 0, 226 ) 227 } 228 229 // UpdateFrom copies value of all fields of the heap object to p. 230 func (p *NotificationBitmap) UpdateFrom(ref js.Ref) { 231 bindings.NotificationBitmapJSStore( 232 js.Pointer(p), ref, 233 ) 234 } 235 236 // Update writes all fields of the p to the heap object referenced by ref. 237 func (p *NotificationBitmap) Update(ref js.Ref) { 238 bindings.NotificationBitmapJSLoad( 239 js.Pointer(p), js.False, ref, 240 ) 241 } 242 243 // FreeMembers frees fields with heap reference, if recursive is true 244 // free all heap references reachable from p. 245 func (p *NotificationBitmap) FreeMembers(recursive bool) { 246 js.Free( 247 p.Data.Ref(), 248 ) 249 p.Data = p.Data.FromRef(js.Undefined) 250 } 251 252 type NotificationButton struct { 253 // Title is "NotificationButton.title" 254 // 255 // Optional 256 Title js.String 257 // IconUrl is "NotificationButton.iconUrl" 258 // 259 // Optional 260 IconUrl js.String 261 // IconBitmap is "NotificationButton.iconBitmap" 262 // 263 // Optional 264 // 265 // NOTE: IconBitmap.FFI_USE MUST be set to true to get IconBitmap used. 266 IconBitmap NotificationBitmap 267 268 FFI_USE bool 269 } 270 271 // FromRef calls UpdateFrom and returns a NotificationButton with all fields set. 272 func (p NotificationButton) FromRef(ref js.Ref) NotificationButton { 273 p.UpdateFrom(ref) 274 return p 275 } 276 277 // New creates a new NotificationButton in the application heap. 278 func (p NotificationButton) New() js.Ref { 279 return bindings.NotificationButtonJSLoad( 280 js.Pointer(&p), js.True, 0, 281 ) 282 } 283 284 // UpdateFrom copies value of all fields of the heap object to p. 285 func (p *NotificationButton) UpdateFrom(ref js.Ref) { 286 bindings.NotificationButtonJSStore( 287 js.Pointer(p), ref, 288 ) 289 } 290 291 // Update writes all fields of the p to the heap object referenced by ref. 292 func (p *NotificationButton) Update(ref js.Ref) { 293 bindings.NotificationButtonJSLoad( 294 js.Pointer(p), js.False, ref, 295 ) 296 } 297 298 // FreeMembers frees fields with heap reference, if recursive is true 299 // free all heap references reachable from p. 300 func (p *NotificationButton) FreeMembers(recursive bool) { 301 js.Free( 302 p.Title.Ref(), 303 p.IconUrl.Ref(), 304 ) 305 p.Title = p.Title.FromRef(js.Undefined) 306 p.IconUrl = p.IconUrl.FromRef(js.Undefined) 307 if recursive { 308 p.IconBitmap.FreeMembers(true) 309 } 310 } 311 312 type NotificationItem struct { 313 // Title is "NotificationItem.title" 314 // 315 // Optional 316 Title js.String 317 // Message is "NotificationItem.message" 318 // 319 // Optional 320 Message js.String 321 322 FFI_USE bool 323 } 324 325 // FromRef calls UpdateFrom and returns a NotificationItem with all fields set. 326 func (p NotificationItem) FromRef(ref js.Ref) NotificationItem { 327 p.UpdateFrom(ref) 328 return p 329 } 330 331 // New creates a new NotificationItem in the application heap. 332 func (p NotificationItem) New() js.Ref { 333 return bindings.NotificationItemJSLoad( 334 js.Pointer(&p), js.True, 0, 335 ) 336 } 337 338 // UpdateFrom copies value of all fields of the heap object to p. 339 func (p *NotificationItem) UpdateFrom(ref js.Ref) { 340 bindings.NotificationItemJSStore( 341 js.Pointer(p), ref, 342 ) 343 } 344 345 // Update writes all fields of the p to the heap object referenced by ref. 346 func (p *NotificationItem) Update(ref js.Ref) { 347 bindings.NotificationItemJSLoad( 348 js.Pointer(p), js.False, ref, 349 ) 350 } 351 352 // FreeMembers frees fields with heap reference, if recursive is true 353 // free all heap references reachable from p. 354 func (p *NotificationItem) FreeMembers(recursive bool) { 355 js.Free( 356 p.Title.Ref(), 357 p.Message.Ref(), 358 ) 359 p.Title = p.Title.FromRef(js.Undefined) 360 p.Message = p.Message.FromRef(js.Undefined) 361 } 362 363 type TemplateType uint32 364 365 const ( 366 _ TemplateType = iota 367 368 TemplateType_BASIC 369 TemplateType_IMAGE 370 TemplateType_LIST 371 TemplateType_PROGRESS 372 ) 373 374 func (TemplateType) FromRef(str js.Ref) TemplateType { 375 return TemplateType(bindings.ConstOfTemplateType(str)) 376 } 377 378 func (x TemplateType) String() (string, bool) { 379 switch x { 380 case TemplateType_BASIC: 381 return "basic", true 382 case TemplateType_IMAGE: 383 return "image", true 384 case TemplateType_LIST: 385 return "list", true 386 case TemplateType_PROGRESS: 387 return "progress", true 388 default: 389 return "", false 390 } 391 } 392 393 type NotificationOptions struct { 394 // Type is "NotificationOptions.type" 395 // 396 // Optional 397 Type TemplateType 398 // IconUrl is "NotificationOptions.iconUrl" 399 // 400 // Optional 401 IconUrl js.String 402 // IconBitmap is "NotificationOptions.iconBitmap" 403 // 404 // Optional 405 // 406 // NOTE: IconBitmap.FFI_USE MUST be set to true to get IconBitmap used. 407 IconBitmap NotificationBitmap 408 // AppIconMaskUrl is "NotificationOptions.appIconMaskUrl" 409 // 410 // Optional 411 AppIconMaskUrl js.String 412 // AppIconMaskBitmap is "NotificationOptions.appIconMaskBitmap" 413 // 414 // Optional 415 // 416 // NOTE: AppIconMaskBitmap.FFI_USE MUST be set to true to get AppIconMaskBitmap used. 417 AppIconMaskBitmap NotificationBitmap 418 // Title is "NotificationOptions.title" 419 // 420 // Optional 421 Title js.String 422 // Message is "NotificationOptions.message" 423 // 424 // Optional 425 Message js.String 426 // ContextMessage is "NotificationOptions.contextMessage" 427 // 428 // Optional 429 ContextMessage js.String 430 // Priority is "NotificationOptions.priority" 431 // 432 // Optional 433 // 434 // NOTE: FFI_USE_Priority MUST be set to true to make this field effective. 435 Priority int32 436 // EventTime is "NotificationOptions.eventTime" 437 // 438 // Optional 439 // 440 // NOTE: FFI_USE_EventTime MUST be set to true to make this field effective. 441 EventTime float64 442 // Buttons is "NotificationOptions.buttons" 443 // 444 // Optional 445 Buttons js.Array[NotificationButton] 446 // ExpandedMessage is "NotificationOptions.expandedMessage" 447 // 448 // Optional 449 ExpandedMessage js.String 450 // ImageUrl is "NotificationOptions.imageUrl" 451 // 452 // Optional 453 ImageUrl js.String 454 // ImageBitmap is "NotificationOptions.imageBitmap" 455 // 456 // Optional 457 // 458 // NOTE: ImageBitmap.FFI_USE MUST be set to true to get ImageBitmap used. 459 ImageBitmap NotificationBitmap 460 // Items is "NotificationOptions.items" 461 // 462 // Optional 463 Items js.Array[NotificationItem] 464 // Progress is "NotificationOptions.progress" 465 // 466 // Optional 467 // 468 // NOTE: FFI_USE_Progress MUST be set to true to make this field effective. 469 Progress int32 470 // IsClickable is "NotificationOptions.isClickable" 471 // 472 // Optional 473 // 474 // NOTE: FFI_USE_IsClickable MUST be set to true to make this field effective. 475 IsClickable bool 476 // RequireInteraction is "NotificationOptions.requireInteraction" 477 // 478 // Optional 479 // 480 // NOTE: FFI_USE_RequireInteraction MUST be set to true to make this field effective. 481 RequireInteraction bool 482 // Silent is "NotificationOptions.silent" 483 // 484 // Optional 485 // 486 // NOTE: FFI_USE_Silent MUST be set to true to make this field effective. 487 Silent bool 488 489 FFI_USE_Priority bool // for Priority. 490 FFI_USE_EventTime bool // for EventTime. 491 FFI_USE_Progress bool // for Progress. 492 FFI_USE_IsClickable bool // for IsClickable. 493 FFI_USE_RequireInteraction bool // for RequireInteraction. 494 FFI_USE_Silent bool // for Silent. 495 496 FFI_USE bool 497 } 498 499 // FromRef calls UpdateFrom and returns a NotificationOptions with all fields set. 500 func (p NotificationOptions) FromRef(ref js.Ref) NotificationOptions { 501 p.UpdateFrom(ref) 502 return p 503 } 504 505 // New creates a new NotificationOptions in the application heap. 506 func (p NotificationOptions) New() js.Ref { 507 return bindings.NotificationOptionsJSLoad( 508 js.Pointer(&p), js.True, 0, 509 ) 510 } 511 512 // UpdateFrom copies value of all fields of the heap object to p. 513 func (p *NotificationOptions) UpdateFrom(ref js.Ref) { 514 bindings.NotificationOptionsJSStore( 515 js.Pointer(p), ref, 516 ) 517 } 518 519 // Update writes all fields of the p to the heap object referenced by ref. 520 func (p *NotificationOptions) Update(ref js.Ref) { 521 bindings.NotificationOptionsJSLoad( 522 js.Pointer(p), js.False, ref, 523 ) 524 } 525 526 // FreeMembers frees fields with heap reference, if recursive is true 527 // free all heap references reachable from p. 528 func (p *NotificationOptions) FreeMembers(recursive bool) { 529 js.Free( 530 p.IconUrl.Ref(), 531 p.AppIconMaskUrl.Ref(), 532 p.Title.Ref(), 533 p.Message.Ref(), 534 p.ContextMessage.Ref(), 535 p.Buttons.Ref(), 536 p.ExpandedMessage.Ref(), 537 p.ImageUrl.Ref(), 538 p.Items.Ref(), 539 ) 540 p.IconUrl = p.IconUrl.FromRef(js.Undefined) 541 p.AppIconMaskUrl = p.AppIconMaskUrl.FromRef(js.Undefined) 542 p.Title = p.Title.FromRef(js.Undefined) 543 p.Message = p.Message.FromRef(js.Undefined) 544 p.ContextMessage = p.ContextMessage.FromRef(js.Undefined) 545 p.Buttons = p.Buttons.FromRef(js.Undefined) 546 p.ExpandedMessage = p.ExpandedMessage.FromRef(js.Undefined) 547 p.ImageUrl = p.ImageUrl.FromRef(js.Undefined) 548 p.Items = p.Items.FromRef(js.Undefined) 549 if recursive { 550 p.IconBitmap.FreeMembers(true) 551 p.AppIconMaskBitmap.FreeMembers(true) 552 p.ImageBitmap.FreeMembers(true) 553 } 554 } 555 556 type PermissionLevel uint32 557 558 const ( 559 _ PermissionLevel = iota 560 561 PermissionLevel_GRANTED 562 PermissionLevel_DENIED 563 ) 564 565 func (PermissionLevel) FromRef(str js.Ref) PermissionLevel { 566 return PermissionLevel(bindings.ConstOfPermissionLevel(str)) 567 } 568 569 func (x PermissionLevel) String() (string, bool) { 570 switch x { 571 case PermissionLevel_GRANTED: 572 return "granted", true 573 case PermissionLevel_DENIED: 574 return "denied", true 575 default: 576 return "", false 577 } 578 } 579 580 type PermissionLevelCallbackFunc func(this js.Ref, level PermissionLevel) js.Ref 581 582 func (fn PermissionLevelCallbackFunc) Register() js.Func[func(level PermissionLevel)] { 583 return js.RegisterCallback[func(level PermissionLevel)]( 584 fn, abi.FuncPCABIInternal(fn), 585 ) 586 } 587 588 func (fn PermissionLevelCallbackFunc) DispatchCallback( 589 targetPC uintptr, ctx *js.CallbackContext, 590 ) { 591 args := ctx.Args() 592 if len(args) != 1+1 /* js this */ || 593 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 594 js.ThrowInvalidCallbackInvocation() 595 } 596 597 if ctx.Return(fn( 598 args[0], 599 600 PermissionLevel(0).FromRef(args[0+1]), 601 )) { 602 return 603 } 604 605 js.ThrowCallbackValueNotReturned() 606 } 607 608 type PermissionLevelCallback[T any] struct { 609 Fn func(arg T, this js.Ref, level PermissionLevel) js.Ref 610 Arg T 611 } 612 613 func (cb *PermissionLevelCallback[T]) Register() js.Func[func(level PermissionLevel)] { 614 return js.RegisterCallback[func(level PermissionLevel)]( 615 cb, abi.FuncPCABIInternal(cb.Fn), 616 ) 617 } 618 619 func (cb *PermissionLevelCallback[T]) DispatchCallback( 620 targetPC uintptr, ctx *js.CallbackContext, 621 ) { 622 args := ctx.Args() 623 if len(args) != 1+1 /* js this */ || 624 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 625 js.ThrowInvalidCallbackInvocation() 626 } 627 628 if ctx.Return(cb.Fn( 629 cb.Arg, 630 args[0], 631 632 PermissionLevel(0).FromRef(args[0+1]), 633 )) { 634 return 635 } 636 637 js.ThrowCallbackValueNotReturned() 638 } 639 640 type UpdateCallbackFunc func(this js.Ref, wasUpdated bool) js.Ref 641 642 func (fn UpdateCallbackFunc) Register() js.Func[func(wasUpdated bool)] { 643 return js.RegisterCallback[func(wasUpdated bool)]( 644 fn, abi.FuncPCABIInternal(fn), 645 ) 646 } 647 648 func (fn UpdateCallbackFunc) DispatchCallback( 649 targetPC uintptr, ctx *js.CallbackContext, 650 ) { 651 args := ctx.Args() 652 if len(args) != 1+1 /* js this */ || 653 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 654 js.ThrowInvalidCallbackInvocation() 655 } 656 657 if ctx.Return(fn( 658 args[0], 659 660 args[0+1] == js.True, 661 )) { 662 return 663 } 664 665 js.ThrowCallbackValueNotReturned() 666 } 667 668 type UpdateCallback[T any] struct { 669 Fn func(arg T, this js.Ref, wasUpdated bool) js.Ref 670 Arg T 671 } 672 673 func (cb *UpdateCallback[T]) Register() js.Func[func(wasUpdated bool)] { 674 return js.RegisterCallback[func(wasUpdated bool)]( 675 cb, abi.FuncPCABIInternal(cb.Fn), 676 ) 677 } 678 679 func (cb *UpdateCallback[T]) DispatchCallback( 680 targetPC uintptr, ctx *js.CallbackContext, 681 ) { 682 args := ctx.Args() 683 if len(args) != 1+1 /* js this */ || 684 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 685 js.ThrowInvalidCallbackInvocation() 686 } 687 688 if ctx.Return(cb.Fn( 689 cb.Arg, 690 args[0], 691 692 args[0+1] == js.True, 693 )) { 694 return 695 } 696 697 js.ThrowCallbackValueNotReturned() 698 } 699 700 // HasFuncClear returns true if the function "WEBEXT.notifications.clear" exists. 701 func HasFuncClear() bool { 702 return js.True == bindings.HasFuncClear() 703 } 704 705 // FuncClear returns the function "WEBEXT.notifications.clear". 706 func FuncClear() (fn js.Func[func(notificationId js.String) js.Promise[js.Boolean]]) { 707 bindings.FuncClear( 708 js.Pointer(&fn), 709 ) 710 return 711 } 712 713 // Clear calls the function "WEBEXT.notifications.clear" directly. 714 func Clear(notificationId js.String) (ret js.Promise[js.Boolean]) { 715 bindings.CallClear( 716 js.Pointer(&ret), 717 notificationId.Ref(), 718 ) 719 720 return 721 } 722 723 // TryClear calls the function "WEBEXT.notifications.clear" 724 // in a try/catch block and returns (_, err, ok = false) when it went through 725 // the catch clause. 726 func TryClear(notificationId js.String) (ret js.Promise[js.Boolean], exception js.Any, ok bool) { 727 ok = js.True == bindings.TryClear( 728 js.Pointer(&ret), js.Pointer(&exception), 729 notificationId.Ref(), 730 ) 731 732 return 733 } 734 735 // HasFuncCreate returns true if the function "WEBEXT.notifications.create" exists. 736 func HasFuncCreate() bool { 737 return js.True == bindings.HasFuncCreate() 738 } 739 740 // FuncCreate returns the function "WEBEXT.notifications.create". 741 func FuncCreate() (fn js.Func[func(notificationId js.String, options NotificationOptions) js.Promise[js.String]]) { 742 bindings.FuncCreate( 743 js.Pointer(&fn), 744 ) 745 return 746 } 747 748 // Create calls the function "WEBEXT.notifications.create" directly. 749 func Create(notificationId js.String, options NotificationOptions) (ret js.Promise[js.String]) { 750 bindings.CallCreate( 751 js.Pointer(&ret), 752 notificationId.Ref(), 753 js.Pointer(&options), 754 ) 755 756 return 757 } 758 759 // TryCreate calls the function "WEBEXT.notifications.create" 760 // in a try/catch block and returns (_, err, ok = false) when it went through 761 // the catch clause. 762 func TryCreate(notificationId js.String, options NotificationOptions) (ret js.Promise[js.String], exception js.Any, ok bool) { 763 ok = js.True == bindings.TryCreate( 764 js.Pointer(&ret), js.Pointer(&exception), 765 notificationId.Ref(), 766 js.Pointer(&options), 767 ) 768 769 return 770 } 771 772 // HasFuncGetAll returns true if the function "WEBEXT.notifications.getAll" exists. 773 func HasFuncGetAll() bool { 774 return js.True == bindings.HasFuncGetAll() 775 } 776 777 // FuncGetAll returns the function "WEBEXT.notifications.getAll". 778 func FuncGetAll() (fn js.Func[func() js.Promise[js.Object]]) { 779 bindings.FuncGetAll( 780 js.Pointer(&fn), 781 ) 782 return 783 } 784 785 // GetAll calls the function "WEBEXT.notifications.getAll" directly. 786 func GetAll() (ret js.Promise[js.Object]) { 787 bindings.CallGetAll( 788 js.Pointer(&ret), 789 ) 790 791 return 792 } 793 794 // TryGetAll calls the function "WEBEXT.notifications.getAll" 795 // in a try/catch block and returns (_, err, ok = false) when it went through 796 // the catch clause. 797 func TryGetAll() (ret js.Promise[js.Object], exception js.Any, ok bool) { 798 ok = js.True == bindings.TryGetAll( 799 js.Pointer(&ret), js.Pointer(&exception), 800 ) 801 802 return 803 } 804 805 // HasFuncGetPermissionLevel returns true if the function "WEBEXT.notifications.getPermissionLevel" exists. 806 func HasFuncGetPermissionLevel() bool { 807 return js.True == bindings.HasFuncGetPermissionLevel() 808 } 809 810 // FuncGetPermissionLevel returns the function "WEBEXT.notifications.getPermissionLevel". 811 func FuncGetPermissionLevel() (fn js.Func[func() js.Promise[PermissionLevel]]) { 812 bindings.FuncGetPermissionLevel( 813 js.Pointer(&fn), 814 ) 815 return 816 } 817 818 // GetPermissionLevel calls the function "WEBEXT.notifications.getPermissionLevel" directly. 819 func GetPermissionLevel() (ret js.Promise[PermissionLevel]) { 820 bindings.CallGetPermissionLevel( 821 js.Pointer(&ret), 822 ) 823 824 return 825 } 826 827 // TryGetPermissionLevel calls the function "WEBEXT.notifications.getPermissionLevel" 828 // in a try/catch block and returns (_, err, ok = false) when it went through 829 // the catch clause. 830 func TryGetPermissionLevel() (ret js.Promise[PermissionLevel], exception js.Any, ok bool) { 831 ok = js.True == bindings.TryGetPermissionLevel( 832 js.Pointer(&ret), js.Pointer(&exception), 833 ) 834 835 return 836 } 837 838 type OnButtonClickedEventCallbackFunc func(this js.Ref, notificationId js.String, buttonIndex int32) js.Ref 839 840 func (fn OnButtonClickedEventCallbackFunc) Register() js.Func[func(notificationId js.String, buttonIndex int32)] { 841 return js.RegisterCallback[func(notificationId js.String, buttonIndex int32)]( 842 fn, abi.FuncPCABIInternal(fn), 843 ) 844 } 845 846 func (fn OnButtonClickedEventCallbackFunc) DispatchCallback( 847 targetPC uintptr, ctx *js.CallbackContext, 848 ) { 849 args := ctx.Args() 850 if len(args) != 2+1 /* js this */ || 851 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 852 js.ThrowInvalidCallbackInvocation() 853 } 854 855 if ctx.Return(fn( 856 args[0], 857 858 js.String{}.FromRef(args[0+1]), 859 js.Number[int32]{}.FromRef(args[1+1]).Get(), 860 )) { 861 return 862 } 863 864 js.ThrowCallbackValueNotReturned() 865 } 866 867 type OnButtonClickedEventCallback[T any] struct { 868 Fn func(arg T, this js.Ref, notificationId js.String, buttonIndex int32) js.Ref 869 Arg T 870 } 871 872 func (cb *OnButtonClickedEventCallback[T]) Register() js.Func[func(notificationId js.String, buttonIndex int32)] { 873 return js.RegisterCallback[func(notificationId js.String, buttonIndex int32)]( 874 cb, abi.FuncPCABIInternal(cb.Fn), 875 ) 876 } 877 878 func (cb *OnButtonClickedEventCallback[T]) DispatchCallback( 879 targetPC uintptr, ctx *js.CallbackContext, 880 ) { 881 args := ctx.Args() 882 if len(args) != 2+1 /* js this */ || 883 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 884 js.ThrowInvalidCallbackInvocation() 885 } 886 887 if ctx.Return(cb.Fn( 888 cb.Arg, 889 args[0], 890 891 js.String{}.FromRef(args[0+1]), 892 js.Number[int32]{}.FromRef(args[1+1]).Get(), 893 )) { 894 return 895 } 896 897 js.ThrowCallbackValueNotReturned() 898 } 899 900 // HasFuncOnButtonClicked returns true if the function "WEBEXT.notifications.onButtonClicked.addListener" exists. 901 func HasFuncOnButtonClicked() bool { 902 return js.True == bindings.HasFuncOnButtonClicked() 903 } 904 905 // FuncOnButtonClicked returns the function "WEBEXT.notifications.onButtonClicked.addListener". 906 func FuncOnButtonClicked() (fn js.Func[func(callback js.Func[func(notificationId js.String, buttonIndex int32)])]) { 907 bindings.FuncOnButtonClicked( 908 js.Pointer(&fn), 909 ) 910 return 911 } 912 913 // OnButtonClicked calls the function "WEBEXT.notifications.onButtonClicked.addListener" directly. 914 func OnButtonClicked(callback js.Func[func(notificationId js.String, buttonIndex int32)]) (ret js.Void) { 915 bindings.CallOnButtonClicked( 916 js.Pointer(&ret), 917 callback.Ref(), 918 ) 919 920 return 921 } 922 923 // TryOnButtonClicked calls the function "WEBEXT.notifications.onButtonClicked.addListener" 924 // in a try/catch block and returns (_, err, ok = false) when it went through 925 // the catch clause. 926 func TryOnButtonClicked(callback js.Func[func(notificationId js.String, buttonIndex int32)]) (ret js.Void, exception js.Any, ok bool) { 927 ok = js.True == bindings.TryOnButtonClicked( 928 js.Pointer(&ret), js.Pointer(&exception), 929 callback.Ref(), 930 ) 931 932 return 933 } 934 935 // HasFuncOffButtonClicked returns true if the function "WEBEXT.notifications.onButtonClicked.removeListener" exists. 936 func HasFuncOffButtonClicked() bool { 937 return js.True == bindings.HasFuncOffButtonClicked() 938 } 939 940 // FuncOffButtonClicked returns the function "WEBEXT.notifications.onButtonClicked.removeListener". 941 func FuncOffButtonClicked() (fn js.Func[func(callback js.Func[func(notificationId js.String, buttonIndex int32)])]) { 942 bindings.FuncOffButtonClicked( 943 js.Pointer(&fn), 944 ) 945 return 946 } 947 948 // OffButtonClicked calls the function "WEBEXT.notifications.onButtonClicked.removeListener" directly. 949 func OffButtonClicked(callback js.Func[func(notificationId js.String, buttonIndex int32)]) (ret js.Void) { 950 bindings.CallOffButtonClicked( 951 js.Pointer(&ret), 952 callback.Ref(), 953 ) 954 955 return 956 } 957 958 // TryOffButtonClicked calls the function "WEBEXT.notifications.onButtonClicked.removeListener" 959 // in a try/catch block and returns (_, err, ok = false) when it went through 960 // the catch clause. 961 func TryOffButtonClicked(callback js.Func[func(notificationId js.String, buttonIndex int32)]) (ret js.Void, exception js.Any, ok bool) { 962 ok = js.True == bindings.TryOffButtonClicked( 963 js.Pointer(&ret), js.Pointer(&exception), 964 callback.Ref(), 965 ) 966 967 return 968 } 969 970 // HasFuncHasOnButtonClicked returns true if the function "WEBEXT.notifications.onButtonClicked.hasListener" exists. 971 func HasFuncHasOnButtonClicked() bool { 972 return js.True == bindings.HasFuncHasOnButtonClicked() 973 } 974 975 // FuncHasOnButtonClicked returns the function "WEBEXT.notifications.onButtonClicked.hasListener". 976 func FuncHasOnButtonClicked() (fn js.Func[func(callback js.Func[func(notificationId js.String, buttonIndex int32)]) bool]) { 977 bindings.FuncHasOnButtonClicked( 978 js.Pointer(&fn), 979 ) 980 return 981 } 982 983 // HasOnButtonClicked calls the function "WEBEXT.notifications.onButtonClicked.hasListener" directly. 984 func HasOnButtonClicked(callback js.Func[func(notificationId js.String, buttonIndex int32)]) (ret bool) { 985 bindings.CallHasOnButtonClicked( 986 js.Pointer(&ret), 987 callback.Ref(), 988 ) 989 990 return 991 } 992 993 // TryHasOnButtonClicked calls the function "WEBEXT.notifications.onButtonClicked.hasListener" 994 // in a try/catch block and returns (_, err, ok = false) when it went through 995 // the catch clause. 996 func TryHasOnButtonClicked(callback js.Func[func(notificationId js.String, buttonIndex int32)]) (ret bool, exception js.Any, ok bool) { 997 ok = js.True == bindings.TryHasOnButtonClicked( 998 js.Pointer(&ret), js.Pointer(&exception), 999 callback.Ref(), 1000 ) 1001 1002 return 1003 } 1004 1005 type OnClickedEventCallbackFunc func(this js.Ref, notificationId js.String) js.Ref 1006 1007 func (fn OnClickedEventCallbackFunc) Register() js.Func[func(notificationId js.String)] { 1008 return js.RegisterCallback[func(notificationId js.String)]( 1009 fn, abi.FuncPCABIInternal(fn), 1010 ) 1011 } 1012 1013 func (fn OnClickedEventCallbackFunc) DispatchCallback( 1014 targetPC uintptr, ctx *js.CallbackContext, 1015 ) { 1016 args := ctx.Args() 1017 if len(args) != 1+1 /* js this */ || 1018 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1019 js.ThrowInvalidCallbackInvocation() 1020 } 1021 1022 if ctx.Return(fn( 1023 args[0], 1024 1025 js.String{}.FromRef(args[0+1]), 1026 )) { 1027 return 1028 } 1029 1030 js.ThrowCallbackValueNotReturned() 1031 } 1032 1033 type OnClickedEventCallback[T any] struct { 1034 Fn func(arg T, this js.Ref, notificationId js.String) js.Ref 1035 Arg T 1036 } 1037 1038 func (cb *OnClickedEventCallback[T]) Register() js.Func[func(notificationId js.String)] { 1039 return js.RegisterCallback[func(notificationId js.String)]( 1040 cb, abi.FuncPCABIInternal(cb.Fn), 1041 ) 1042 } 1043 1044 func (cb *OnClickedEventCallback[T]) DispatchCallback( 1045 targetPC uintptr, ctx *js.CallbackContext, 1046 ) { 1047 args := ctx.Args() 1048 if len(args) != 1+1 /* js this */ || 1049 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1050 js.ThrowInvalidCallbackInvocation() 1051 } 1052 1053 if ctx.Return(cb.Fn( 1054 cb.Arg, 1055 args[0], 1056 1057 js.String{}.FromRef(args[0+1]), 1058 )) { 1059 return 1060 } 1061 1062 js.ThrowCallbackValueNotReturned() 1063 } 1064 1065 // HasFuncOnClicked returns true if the function "WEBEXT.notifications.onClicked.addListener" exists. 1066 func HasFuncOnClicked() bool { 1067 return js.True == bindings.HasFuncOnClicked() 1068 } 1069 1070 // FuncOnClicked returns the function "WEBEXT.notifications.onClicked.addListener". 1071 func FuncOnClicked() (fn js.Func[func(callback js.Func[func(notificationId js.String)])]) { 1072 bindings.FuncOnClicked( 1073 js.Pointer(&fn), 1074 ) 1075 return 1076 } 1077 1078 // OnClicked calls the function "WEBEXT.notifications.onClicked.addListener" directly. 1079 func OnClicked(callback js.Func[func(notificationId js.String)]) (ret js.Void) { 1080 bindings.CallOnClicked( 1081 js.Pointer(&ret), 1082 callback.Ref(), 1083 ) 1084 1085 return 1086 } 1087 1088 // TryOnClicked calls the function "WEBEXT.notifications.onClicked.addListener" 1089 // in a try/catch block and returns (_, err, ok = false) when it went through 1090 // the catch clause. 1091 func TryOnClicked(callback js.Func[func(notificationId js.String)]) (ret js.Void, exception js.Any, ok bool) { 1092 ok = js.True == bindings.TryOnClicked( 1093 js.Pointer(&ret), js.Pointer(&exception), 1094 callback.Ref(), 1095 ) 1096 1097 return 1098 } 1099 1100 // HasFuncOffClicked returns true if the function "WEBEXT.notifications.onClicked.removeListener" exists. 1101 func HasFuncOffClicked() bool { 1102 return js.True == bindings.HasFuncOffClicked() 1103 } 1104 1105 // FuncOffClicked returns the function "WEBEXT.notifications.onClicked.removeListener". 1106 func FuncOffClicked() (fn js.Func[func(callback js.Func[func(notificationId js.String)])]) { 1107 bindings.FuncOffClicked( 1108 js.Pointer(&fn), 1109 ) 1110 return 1111 } 1112 1113 // OffClicked calls the function "WEBEXT.notifications.onClicked.removeListener" directly. 1114 func OffClicked(callback js.Func[func(notificationId js.String)]) (ret js.Void) { 1115 bindings.CallOffClicked( 1116 js.Pointer(&ret), 1117 callback.Ref(), 1118 ) 1119 1120 return 1121 } 1122 1123 // TryOffClicked calls the function "WEBEXT.notifications.onClicked.removeListener" 1124 // in a try/catch block and returns (_, err, ok = false) when it went through 1125 // the catch clause. 1126 func TryOffClicked(callback js.Func[func(notificationId js.String)]) (ret js.Void, exception js.Any, ok bool) { 1127 ok = js.True == bindings.TryOffClicked( 1128 js.Pointer(&ret), js.Pointer(&exception), 1129 callback.Ref(), 1130 ) 1131 1132 return 1133 } 1134 1135 // HasFuncHasOnClicked returns true if the function "WEBEXT.notifications.onClicked.hasListener" exists. 1136 func HasFuncHasOnClicked() bool { 1137 return js.True == bindings.HasFuncHasOnClicked() 1138 } 1139 1140 // FuncHasOnClicked returns the function "WEBEXT.notifications.onClicked.hasListener". 1141 func FuncHasOnClicked() (fn js.Func[func(callback js.Func[func(notificationId js.String)]) bool]) { 1142 bindings.FuncHasOnClicked( 1143 js.Pointer(&fn), 1144 ) 1145 return 1146 } 1147 1148 // HasOnClicked calls the function "WEBEXT.notifications.onClicked.hasListener" directly. 1149 func HasOnClicked(callback js.Func[func(notificationId js.String)]) (ret bool) { 1150 bindings.CallHasOnClicked( 1151 js.Pointer(&ret), 1152 callback.Ref(), 1153 ) 1154 1155 return 1156 } 1157 1158 // TryHasOnClicked calls the function "WEBEXT.notifications.onClicked.hasListener" 1159 // in a try/catch block and returns (_, err, ok = false) when it went through 1160 // the catch clause. 1161 func TryHasOnClicked(callback js.Func[func(notificationId js.String)]) (ret bool, exception js.Any, ok bool) { 1162 ok = js.True == bindings.TryHasOnClicked( 1163 js.Pointer(&ret), js.Pointer(&exception), 1164 callback.Ref(), 1165 ) 1166 1167 return 1168 } 1169 1170 type OnClosedEventCallbackFunc func(this js.Ref, notificationId js.String, byUser bool) js.Ref 1171 1172 func (fn OnClosedEventCallbackFunc) Register() js.Func[func(notificationId js.String, byUser bool)] { 1173 return js.RegisterCallback[func(notificationId js.String, byUser bool)]( 1174 fn, abi.FuncPCABIInternal(fn), 1175 ) 1176 } 1177 1178 func (fn OnClosedEventCallbackFunc) DispatchCallback( 1179 targetPC uintptr, ctx *js.CallbackContext, 1180 ) { 1181 args := ctx.Args() 1182 if len(args) != 2+1 /* js this */ || 1183 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1184 js.ThrowInvalidCallbackInvocation() 1185 } 1186 1187 if ctx.Return(fn( 1188 args[0], 1189 1190 js.String{}.FromRef(args[0+1]), 1191 args[1+1] == js.True, 1192 )) { 1193 return 1194 } 1195 1196 js.ThrowCallbackValueNotReturned() 1197 } 1198 1199 type OnClosedEventCallback[T any] struct { 1200 Fn func(arg T, this js.Ref, notificationId js.String, byUser bool) js.Ref 1201 Arg T 1202 } 1203 1204 func (cb *OnClosedEventCallback[T]) Register() js.Func[func(notificationId js.String, byUser bool)] { 1205 return js.RegisterCallback[func(notificationId js.String, byUser bool)]( 1206 cb, abi.FuncPCABIInternal(cb.Fn), 1207 ) 1208 } 1209 1210 func (cb *OnClosedEventCallback[T]) DispatchCallback( 1211 targetPC uintptr, ctx *js.CallbackContext, 1212 ) { 1213 args := ctx.Args() 1214 if len(args) != 2+1 /* js this */ || 1215 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1216 js.ThrowInvalidCallbackInvocation() 1217 } 1218 1219 if ctx.Return(cb.Fn( 1220 cb.Arg, 1221 args[0], 1222 1223 js.String{}.FromRef(args[0+1]), 1224 args[1+1] == js.True, 1225 )) { 1226 return 1227 } 1228 1229 js.ThrowCallbackValueNotReturned() 1230 } 1231 1232 // HasFuncOnClosed returns true if the function "WEBEXT.notifications.onClosed.addListener" exists. 1233 func HasFuncOnClosed() bool { 1234 return js.True == bindings.HasFuncOnClosed() 1235 } 1236 1237 // FuncOnClosed returns the function "WEBEXT.notifications.onClosed.addListener". 1238 func FuncOnClosed() (fn js.Func[func(callback js.Func[func(notificationId js.String, byUser bool)])]) { 1239 bindings.FuncOnClosed( 1240 js.Pointer(&fn), 1241 ) 1242 return 1243 } 1244 1245 // OnClosed calls the function "WEBEXT.notifications.onClosed.addListener" directly. 1246 func OnClosed(callback js.Func[func(notificationId js.String, byUser bool)]) (ret js.Void) { 1247 bindings.CallOnClosed( 1248 js.Pointer(&ret), 1249 callback.Ref(), 1250 ) 1251 1252 return 1253 } 1254 1255 // TryOnClosed calls the function "WEBEXT.notifications.onClosed.addListener" 1256 // in a try/catch block and returns (_, err, ok = false) when it went through 1257 // the catch clause. 1258 func TryOnClosed(callback js.Func[func(notificationId js.String, byUser bool)]) (ret js.Void, exception js.Any, ok bool) { 1259 ok = js.True == bindings.TryOnClosed( 1260 js.Pointer(&ret), js.Pointer(&exception), 1261 callback.Ref(), 1262 ) 1263 1264 return 1265 } 1266 1267 // HasFuncOffClosed returns true if the function "WEBEXT.notifications.onClosed.removeListener" exists. 1268 func HasFuncOffClosed() bool { 1269 return js.True == bindings.HasFuncOffClosed() 1270 } 1271 1272 // FuncOffClosed returns the function "WEBEXT.notifications.onClosed.removeListener". 1273 func FuncOffClosed() (fn js.Func[func(callback js.Func[func(notificationId js.String, byUser bool)])]) { 1274 bindings.FuncOffClosed( 1275 js.Pointer(&fn), 1276 ) 1277 return 1278 } 1279 1280 // OffClosed calls the function "WEBEXT.notifications.onClosed.removeListener" directly. 1281 func OffClosed(callback js.Func[func(notificationId js.String, byUser bool)]) (ret js.Void) { 1282 bindings.CallOffClosed( 1283 js.Pointer(&ret), 1284 callback.Ref(), 1285 ) 1286 1287 return 1288 } 1289 1290 // TryOffClosed calls the function "WEBEXT.notifications.onClosed.removeListener" 1291 // in a try/catch block and returns (_, err, ok = false) when it went through 1292 // the catch clause. 1293 func TryOffClosed(callback js.Func[func(notificationId js.String, byUser bool)]) (ret js.Void, exception js.Any, ok bool) { 1294 ok = js.True == bindings.TryOffClosed( 1295 js.Pointer(&ret), js.Pointer(&exception), 1296 callback.Ref(), 1297 ) 1298 1299 return 1300 } 1301 1302 // HasFuncHasOnClosed returns true if the function "WEBEXT.notifications.onClosed.hasListener" exists. 1303 func HasFuncHasOnClosed() bool { 1304 return js.True == bindings.HasFuncHasOnClosed() 1305 } 1306 1307 // FuncHasOnClosed returns the function "WEBEXT.notifications.onClosed.hasListener". 1308 func FuncHasOnClosed() (fn js.Func[func(callback js.Func[func(notificationId js.String, byUser bool)]) bool]) { 1309 bindings.FuncHasOnClosed( 1310 js.Pointer(&fn), 1311 ) 1312 return 1313 } 1314 1315 // HasOnClosed calls the function "WEBEXT.notifications.onClosed.hasListener" directly. 1316 func HasOnClosed(callback js.Func[func(notificationId js.String, byUser bool)]) (ret bool) { 1317 bindings.CallHasOnClosed( 1318 js.Pointer(&ret), 1319 callback.Ref(), 1320 ) 1321 1322 return 1323 } 1324 1325 // TryHasOnClosed calls the function "WEBEXT.notifications.onClosed.hasListener" 1326 // in a try/catch block and returns (_, err, ok = false) when it went through 1327 // the catch clause. 1328 func TryHasOnClosed(callback js.Func[func(notificationId js.String, byUser bool)]) (ret bool, exception js.Any, ok bool) { 1329 ok = js.True == bindings.TryHasOnClosed( 1330 js.Pointer(&ret), js.Pointer(&exception), 1331 callback.Ref(), 1332 ) 1333 1334 return 1335 } 1336 1337 type OnPermissionLevelChangedEventCallbackFunc func(this js.Ref, level PermissionLevel) js.Ref 1338 1339 func (fn OnPermissionLevelChangedEventCallbackFunc) Register() js.Func[func(level PermissionLevel)] { 1340 return js.RegisterCallback[func(level PermissionLevel)]( 1341 fn, abi.FuncPCABIInternal(fn), 1342 ) 1343 } 1344 1345 func (fn OnPermissionLevelChangedEventCallbackFunc) DispatchCallback( 1346 targetPC uintptr, ctx *js.CallbackContext, 1347 ) { 1348 args := ctx.Args() 1349 if len(args) != 1+1 /* js this */ || 1350 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1351 js.ThrowInvalidCallbackInvocation() 1352 } 1353 1354 if ctx.Return(fn( 1355 args[0], 1356 1357 PermissionLevel(0).FromRef(args[0+1]), 1358 )) { 1359 return 1360 } 1361 1362 js.ThrowCallbackValueNotReturned() 1363 } 1364 1365 type OnPermissionLevelChangedEventCallback[T any] struct { 1366 Fn func(arg T, this js.Ref, level PermissionLevel) js.Ref 1367 Arg T 1368 } 1369 1370 func (cb *OnPermissionLevelChangedEventCallback[T]) Register() js.Func[func(level PermissionLevel)] { 1371 return js.RegisterCallback[func(level PermissionLevel)]( 1372 cb, abi.FuncPCABIInternal(cb.Fn), 1373 ) 1374 } 1375 1376 func (cb *OnPermissionLevelChangedEventCallback[T]) DispatchCallback( 1377 targetPC uintptr, ctx *js.CallbackContext, 1378 ) { 1379 args := ctx.Args() 1380 if len(args) != 1+1 /* js this */ || 1381 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1382 js.ThrowInvalidCallbackInvocation() 1383 } 1384 1385 if ctx.Return(cb.Fn( 1386 cb.Arg, 1387 args[0], 1388 1389 PermissionLevel(0).FromRef(args[0+1]), 1390 )) { 1391 return 1392 } 1393 1394 js.ThrowCallbackValueNotReturned() 1395 } 1396 1397 // HasFuncOnPermissionLevelChanged returns true if the function "WEBEXT.notifications.onPermissionLevelChanged.addListener" exists. 1398 func HasFuncOnPermissionLevelChanged() bool { 1399 return js.True == bindings.HasFuncOnPermissionLevelChanged() 1400 } 1401 1402 // FuncOnPermissionLevelChanged returns the function "WEBEXT.notifications.onPermissionLevelChanged.addListener". 1403 func FuncOnPermissionLevelChanged() (fn js.Func[func(callback js.Func[func(level PermissionLevel)])]) { 1404 bindings.FuncOnPermissionLevelChanged( 1405 js.Pointer(&fn), 1406 ) 1407 return 1408 } 1409 1410 // OnPermissionLevelChanged calls the function "WEBEXT.notifications.onPermissionLevelChanged.addListener" directly. 1411 func OnPermissionLevelChanged(callback js.Func[func(level PermissionLevel)]) (ret js.Void) { 1412 bindings.CallOnPermissionLevelChanged( 1413 js.Pointer(&ret), 1414 callback.Ref(), 1415 ) 1416 1417 return 1418 } 1419 1420 // TryOnPermissionLevelChanged calls the function "WEBEXT.notifications.onPermissionLevelChanged.addListener" 1421 // in a try/catch block and returns (_, err, ok = false) when it went through 1422 // the catch clause. 1423 func TryOnPermissionLevelChanged(callback js.Func[func(level PermissionLevel)]) (ret js.Void, exception js.Any, ok bool) { 1424 ok = js.True == bindings.TryOnPermissionLevelChanged( 1425 js.Pointer(&ret), js.Pointer(&exception), 1426 callback.Ref(), 1427 ) 1428 1429 return 1430 } 1431 1432 // HasFuncOffPermissionLevelChanged returns true if the function "WEBEXT.notifications.onPermissionLevelChanged.removeListener" exists. 1433 func HasFuncOffPermissionLevelChanged() bool { 1434 return js.True == bindings.HasFuncOffPermissionLevelChanged() 1435 } 1436 1437 // FuncOffPermissionLevelChanged returns the function "WEBEXT.notifications.onPermissionLevelChanged.removeListener". 1438 func FuncOffPermissionLevelChanged() (fn js.Func[func(callback js.Func[func(level PermissionLevel)])]) { 1439 bindings.FuncOffPermissionLevelChanged( 1440 js.Pointer(&fn), 1441 ) 1442 return 1443 } 1444 1445 // OffPermissionLevelChanged calls the function "WEBEXT.notifications.onPermissionLevelChanged.removeListener" directly. 1446 func OffPermissionLevelChanged(callback js.Func[func(level PermissionLevel)]) (ret js.Void) { 1447 bindings.CallOffPermissionLevelChanged( 1448 js.Pointer(&ret), 1449 callback.Ref(), 1450 ) 1451 1452 return 1453 } 1454 1455 // TryOffPermissionLevelChanged calls the function "WEBEXT.notifications.onPermissionLevelChanged.removeListener" 1456 // in a try/catch block and returns (_, err, ok = false) when it went through 1457 // the catch clause. 1458 func TryOffPermissionLevelChanged(callback js.Func[func(level PermissionLevel)]) (ret js.Void, exception js.Any, ok bool) { 1459 ok = js.True == bindings.TryOffPermissionLevelChanged( 1460 js.Pointer(&ret), js.Pointer(&exception), 1461 callback.Ref(), 1462 ) 1463 1464 return 1465 } 1466 1467 // HasFuncHasOnPermissionLevelChanged returns true if the function "WEBEXT.notifications.onPermissionLevelChanged.hasListener" exists. 1468 func HasFuncHasOnPermissionLevelChanged() bool { 1469 return js.True == bindings.HasFuncHasOnPermissionLevelChanged() 1470 } 1471 1472 // FuncHasOnPermissionLevelChanged returns the function "WEBEXT.notifications.onPermissionLevelChanged.hasListener". 1473 func FuncHasOnPermissionLevelChanged() (fn js.Func[func(callback js.Func[func(level PermissionLevel)]) bool]) { 1474 bindings.FuncHasOnPermissionLevelChanged( 1475 js.Pointer(&fn), 1476 ) 1477 return 1478 } 1479 1480 // HasOnPermissionLevelChanged calls the function "WEBEXT.notifications.onPermissionLevelChanged.hasListener" directly. 1481 func HasOnPermissionLevelChanged(callback js.Func[func(level PermissionLevel)]) (ret bool) { 1482 bindings.CallHasOnPermissionLevelChanged( 1483 js.Pointer(&ret), 1484 callback.Ref(), 1485 ) 1486 1487 return 1488 } 1489 1490 // TryHasOnPermissionLevelChanged calls the function "WEBEXT.notifications.onPermissionLevelChanged.hasListener" 1491 // in a try/catch block and returns (_, err, ok = false) when it went through 1492 // the catch clause. 1493 func TryHasOnPermissionLevelChanged(callback js.Func[func(level PermissionLevel)]) (ret bool, exception js.Any, ok bool) { 1494 ok = js.True == bindings.TryHasOnPermissionLevelChanged( 1495 js.Pointer(&ret), js.Pointer(&exception), 1496 callback.Ref(), 1497 ) 1498 1499 return 1500 } 1501 1502 type OnShowSettingsEventCallbackFunc func(this js.Ref) js.Ref 1503 1504 func (fn OnShowSettingsEventCallbackFunc) Register() js.Func[func()] { 1505 return js.RegisterCallback[func()]( 1506 fn, abi.FuncPCABIInternal(fn), 1507 ) 1508 } 1509 1510 func (fn OnShowSettingsEventCallbackFunc) DispatchCallback( 1511 targetPC uintptr, ctx *js.CallbackContext, 1512 ) { 1513 args := ctx.Args() 1514 if len(args) != 0+1 /* js this */ || 1515 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 1516 js.ThrowInvalidCallbackInvocation() 1517 } 1518 1519 if ctx.Return(fn( 1520 args[0], 1521 )) { 1522 return 1523 } 1524 1525 js.ThrowCallbackValueNotReturned() 1526 } 1527 1528 type OnShowSettingsEventCallback[T any] struct { 1529 Fn func(arg T, this js.Ref) js.Ref 1530 Arg T 1531 } 1532 1533 func (cb *OnShowSettingsEventCallback[T]) Register() js.Func[func()] { 1534 return js.RegisterCallback[func()]( 1535 cb, abi.FuncPCABIInternal(cb.Fn), 1536 ) 1537 } 1538 1539 func (cb *OnShowSettingsEventCallback[T]) DispatchCallback( 1540 targetPC uintptr, ctx *js.CallbackContext, 1541 ) { 1542 args := ctx.Args() 1543 if len(args) != 0+1 /* js this */ || 1544 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 1545 js.ThrowInvalidCallbackInvocation() 1546 } 1547 1548 if ctx.Return(cb.Fn( 1549 cb.Arg, 1550 args[0], 1551 )) { 1552 return 1553 } 1554 1555 js.ThrowCallbackValueNotReturned() 1556 } 1557 1558 // HasFuncOnShowSettings returns true if the function "WEBEXT.notifications.onShowSettings.addListener" exists. 1559 func HasFuncOnShowSettings() bool { 1560 return js.True == bindings.HasFuncOnShowSettings() 1561 } 1562 1563 // FuncOnShowSettings returns the function "WEBEXT.notifications.onShowSettings.addListener". 1564 func FuncOnShowSettings() (fn js.Func[func(callback js.Func[func()])]) { 1565 bindings.FuncOnShowSettings( 1566 js.Pointer(&fn), 1567 ) 1568 return 1569 } 1570 1571 // OnShowSettings calls the function "WEBEXT.notifications.onShowSettings.addListener" directly. 1572 func OnShowSettings(callback js.Func[func()]) (ret js.Void) { 1573 bindings.CallOnShowSettings( 1574 js.Pointer(&ret), 1575 callback.Ref(), 1576 ) 1577 1578 return 1579 } 1580 1581 // TryOnShowSettings calls the function "WEBEXT.notifications.onShowSettings.addListener" 1582 // in a try/catch block and returns (_, err, ok = false) when it went through 1583 // the catch clause. 1584 func TryOnShowSettings(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 1585 ok = js.True == bindings.TryOnShowSettings( 1586 js.Pointer(&ret), js.Pointer(&exception), 1587 callback.Ref(), 1588 ) 1589 1590 return 1591 } 1592 1593 // HasFuncOffShowSettings returns true if the function "WEBEXT.notifications.onShowSettings.removeListener" exists. 1594 func HasFuncOffShowSettings() bool { 1595 return js.True == bindings.HasFuncOffShowSettings() 1596 } 1597 1598 // FuncOffShowSettings returns the function "WEBEXT.notifications.onShowSettings.removeListener". 1599 func FuncOffShowSettings() (fn js.Func[func(callback js.Func[func()])]) { 1600 bindings.FuncOffShowSettings( 1601 js.Pointer(&fn), 1602 ) 1603 return 1604 } 1605 1606 // OffShowSettings calls the function "WEBEXT.notifications.onShowSettings.removeListener" directly. 1607 func OffShowSettings(callback js.Func[func()]) (ret js.Void) { 1608 bindings.CallOffShowSettings( 1609 js.Pointer(&ret), 1610 callback.Ref(), 1611 ) 1612 1613 return 1614 } 1615 1616 // TryOffShowSettings calls the function "WEBEXT.notifications.onShowSettings.removeListener" 1617 // in a try/catch block and returns (_, err, ok = false) when it went through 1618 // the catch clause. 1619 func TryOffShowSettings(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) { 1620 ok = js.True == bindings.TryOffShowSettings( 1621 js.Pointer(&ret), js.Pointer(&exception), 1622 callback.Ref(), 1623 ) 1624 1625 return 1626 } 1627 1628 // HasFuncHasOnShowSettings returns true if the function "WEBEXT.notifications.onShowSettings.hasListener" exists. 1629 func HasFuncHasOnShowSettings() bool { 1630 return js.True == bindings.HasFuncHasOnShowSettings() 1631 } 1632 1633 // FuncHasOnShowSettings returns the function "WEBEXT.notifications.onShowSettings.hasListener". 1634 func FuncHasOnShowSettings() (fn js.Func[func(callback js.Func[func()]) bool]) { 1635 bindings.FuncHasOnShowSettings( 1636 js.Pointer(&fn), 1637 ) 1638 return 1639 } 1640 1641 // HasOnShowSettings calls the function "WEBEXT.notifications.onShowSettings.hasListener" directly. 1642 func HasOnShowSettings(callback js.Func[func()]) (ret bool) { 1643 bindings.CallHasOnShowSettings( 1644 js.Pointer(&ret), 1645 callback.Ref(), 1646 ) 1647 1648 return 1649 } 1650 1651 // TryHasOnShowSettings calls the function "WEBEXT.notifications.onShowSettings.hasListener" 1652 // in a try/catch block and returns (_, err, ok = false) when it went through 1653 // the catch clause. 1654 func TryHasOnShowSettings(callback js.Func[func()]) (ret bool, exception js.Any, ok bool) { 1655 ok = js.True == bindings.TryHasOnShowSettings( 1656 js.Pointer(&ret), js.Pointer(&exception), 1657 callback.Ref(), 1658 ) 1659 1660 return 1661 } 1662 1663 // HasFuncUpdate returns true if the function "WEBEXT.notifications.update" exists. 1664 func HasFuncUpdate() bool { 1665 return js.True == bindings.HasFuncUpdate() 1666 } 1667 1668 // FuncUpdate returns the function "WEBEXT.notifications.update". 1669 func FuncUpdate() (fn js.Func[func(notificationId js.String, options NotificationOptions) js.Promise[js.Boolean]]) { 1670 bindings.FuncUpdate( 1671 js.Pointer(&fn), 1672 ) 1673 return 1674 } 1675 1676 // Update calls the function "WEBEXT.notifications.update" directly. 1677 func Update(notificationId js.String, options NotificationOptions) (ret js.Promise[js.Boolean]) { 1678 bindings.CallUpdate( 1679 js.Pointer(&ret), 1680 notificationId.Ref(), 1681 js.Pointer(&options), 1682 ) 1683 1684 return 1685 } 1686 1687 // TryUpdate calls the function "WEBEXT.notifications.update" 1688 // in a try/catch block and returns (_, err, ok = false) when it went through 1689 // the catch clause. 1690 func TryUpdate(notificationId js.String, options NotificationOptions) (ret js.Promise[js.Boolean], exception js.Any, ok bool) { 1691 ok = js.True == bindings.TryUpdate( 1692 js.Pointer(&ret), js.Pointer(&exception), 1693 notificationId.Ref(), 1694 js.Pointer(&options), 1695 ) 1696 1697 return 1698 }