github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/storage/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package storage 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/storage/bindings" 11 ) 12 13 type AccessLevel uint32 14 15 const ( 16 _ AccessLevel = iota 17 18 AccessLevel_TRUSTED_CONTEXTS 19 AccessLevel_TRUSTED_AND_UNTRUSTED_CONTEXTS 20 ) 21 22 func (AccessLevel) FromRef(str js.Ref) AccessLevel { 23 return AccessLevel(bindings.ConstOfAccessLevel(str)) 24 } 25 26 func (x AccessLevel) String() (string, bool) { 27 switch x { 28 case AccessLevel_TRUSTED_CONTEXTS: 29 return "TRUSTED_CONTEXTS", true 30 case AccessLevel_TRUSTED_AND_UNTRUSTED_CONTEXTS: 31 return "TRUSTED_AND_UNTRUSTED_CONTEXTS", true 32 default: 33 return "", false 34 } 35 } 36 37 type SetAccessLevelArgAccessOptions struct { 38 // AccessLevel is "SetAccessLevelArgAccessOptions.accessLevel" 39 // 40 // Required 41 AccessLevel AccessLevel 42 43 FFI_USE bool 44 } 45 46 // FromRef calls UpdateFrom and returns a SetAccessLevelArgAccessOptions with all fields set. 47 func (p SetAccessLevelArgAccessOptions) FromRef(ref js.Ref) SetAccessLevelArgAccessOptions { 48 p.UpdateFrom(ref) 49 return p 50 } 51 52 // New creates a new SetAccessLevelArgAccessOptions in the application heap. 53 func (p SetAccessLevelArgAccessOptions) New() js.Ref { 54 return bindings.SetAccessLevelArgAccessOptionsJSLoad( 55 js.Pointer(&p), js.True, 0, 56 ) 57 } 58 59 // UpdateFrom copies value of all fields of the heap object to p. 60 func (p *SetAccessLevelArgAccessOptions) UpdateFrom(ref js.Ref) { 61 bindings.SetAccessLevelArgAccessOptionsJSStore( 62 js.Pointer(p), ref, 63 ) 64 } 65 66 // Update writes all fields of the p to the heap object referenced by ref. 67 func (p *SetAccessLevelArgAccessOptions) Update(ref js.Ref) { 68 bindings.SetAccessLevelArgAccessOptionsJSLoad( 69 js.Pointer(p), js.False, ref, 70 ) 71 } 72 73 // FreeMembers frees fields with heap reference, if recursive is true 74 // free all heap references reachable from p. 75 func (p *SetAccessLevelArgAccessOptions) FreeMembers(recursive bool) { 76 } 77 78 type OneOf_String_ArrayString_Any struct { 79 ref js.Ref 80 } 81 82 func (x OneOf_String_ArrayString_Any) Ref() js.Ref { 83 return x.ref 84 } 85 86 func (x OneOf_String_ArrayString_Any) Free() { 87 x.ref.Free() 88 } 89 90 func (x OneOf_String_ArrayString_Any) FromRef(ref js.Ref) OneOf_String_ArrayString_Any { 91 return OneOf_String_ArrayString_Any{ 92 ref: ref, 93 } 94 } 95 96 func (x OneOf_String_ArrayString_Any) String() js.String { 97 return js.String{}.FromRef(x.ref) 98 } 99 100 func (x OneOf_String_ArrayString_Any) ArrayString() js.Array[js.String] { 101 return js.Array[js.String]{}.FromRef(x.ref) 102 } 103 104 func (x OneOf_String_ArrayString_Any) Any() js.Any { 105 return js.Any{}.FromRef(x.ref) 106 } 107 108 type OneOf_String_ArrayString struct { 109 ref js.Ref 110 } 111 112 func (x OneOf_String_ArrayString) Ref() js.Ref { 113 return x.ref 114 } 115 116 func (x OneOf_String_ArrayString) Free() { 117 x.ref.Free() 118 } 119 120 func (x OneOf_String_ArrayString) FromRef(ref js.Ref) OneOf_String_ArrayString { 121 return OneOf_String_ArrayString{ 122 ref: ref, 123 } 124 } 125 126 func (x OneOf_String_ArrayString) String() js.String { 127 return js.String{}.FromRef(x.ref) 128 } 129 130 func (x OneOf_String_ArrayString) ArrayString() js.Array[js.String] { 131 return js.Array[js.String]{}.FromRef(x.ref) 132 } 133 134 type StorageArea struct { 135 ref js.Ref 136 } 137 138 func (this StorageArea) Once() StorageArea { 139 this.ref.Once() 140 return this 141 } 142 143 func (this StorageArea) Ref() js.Ref { 144 return this.ref 145 } 146 147 func (this StorageArea) FromRef(ref js.Ref) StorageArea { 148 this.ref = ref 149 return this 150 } 151 152 func (this StorageArea) Free() { 153 this.ref.Free() 154 } 155 156 // HasFuncGet returns true if the method "StorageArea.get" exists. 157 func (this StorageArea) HasFuncGet() bool { 158 return js.True == bindings.HasFuncStorageAreaGet( 159 this.ref, 160 ) 161 } 162 163 // FuncGet returns the method "StorageArea.get". 164 func (this StorageArea) FuncGet() (fn js.Func[func(keys OneOf_String_ArrayString_Any) js.Promise[js.Any]]) { 165 bindings.FuncStorageAreaGet( 166 this.ref, js.Pointer(&fn), 167 ) 168 return 169 } 170 171 // Get calls the method "StorageArea.get". 172 func (this StorageArea) Get(keys OneOf_String_ArrayString_Any) (ret js.Promise[js.Any]) { 173 bindings.CallStorageAreaGet( 174 this.ref, js.Pointer(&ret), 175 keys.Ref(), 176 ) 177 178 return 179 } 180 181 // TryGet calls the method "StorageArea.get" 182 // in a try/catch block and returns (_, err, ok = false) when it went through 183 // the catch clause. 184 func (this StorageArea) TryGet(keys OneOf_String_ArrayString_Any) (ret js.Promise[js.Any], exception js.Any, ok bool) { 185 ok = js.True == bindings.TryStorageAreaGet( 186 this.ref, js.Pointer(&ret), js.Pointer(&exception), 187 keys.Ref(), 188 ) 189 190 return 191 } 192 193 // HasFuncGet1 returns true if the method "StorageArea.get" exists. 194 func (this StorageArea) HasFuncGet1() bool { 195 return js.True == bindings.HasFuncStorageAreaGet1( 196 this.ref, 197 ) 198 } 199 200 // FuncGet1 returns the method "StorageArea.get". 201 func (this StorageArea) FuncGet1() (fn js.Func[func() js.Promise[js.Any]]) { 202 bindings.FuncStorageAreaGet1( 203 this.ref, js.Pointer(&fn), 204 ) 205 return 206 } 207 208 // Get1 calls the method "StorageArea.get". 209 func (this StorageArea) Get1() (ret js.Promise[js.Any]) { 210 bindings.CallStorageAreaGet1( 211 this.ref, js.Pointer(&ret), 212 ) 213 214 return 215 } 216 217 // TryGet1 calls the method "StorageArea.get" 218 // in a try/catch block and returns (_, err, ok = false) when it went through 219 // the catch clause. 220 func (this StorageArea) TryGet1() (ret js.Promise[js.Any], exception js.Any, ok bool) { 221 ok = js.True == bindings.TryStorageAreaGet1( 222 this.ref, js.Pointer(&ret), js.Pointer(&exception), 223 ) 224 225 return 226 } 227 228 // HasFuncGetBytesInUse returns true if the method "StorageArea.getBytesInUse" exists. 229 func (this StorageArea) HasFuncGetBytesInUse() bool { 230 return js.True == bindings.HasFuncStorageAreaGetBytesInUse( 231 this.ref, 232 ) 233 } 234 235 // FuncGetBytesInUse returns the method "StorageArea.getBytesInUse". 236 func (this StorageArea) FuncGetBytesInUse() (fn js.Func[func(keys OneOf_String_ArrayString) js.Promise[js.BigInt[int64]]]) { 237 bindings.FuncStorageAreaGetBytesInUse( 238 this.ref, js.Pointer(&fn), 239 ) 240 return 241 } 242 243 // GetBytesInUse calls the method "StorageArea.getBytesInUse". 244 func (this StorageArea) GetBytesInUse(keys OneOf_String_ArrayString) (ret js.Promise[js.BigInt[int64]]) { 245 bindings.CallStorageAreaGetBytesInUse( 246 this.ref, js.Pointer(&ret), 247 keys.Ref(), 248 ) 249 250 return 251 } 252 253 // TryGetBytesInUse calls the method "StorageArea.getBytesInUse" 254 // in a try/catch block and returns (_, err, ok = false) when it went through 255 // the catch clause. 256 func (this StorageArea) TryGetBytesInUse(keys OneOf_String_ArrayString) (ret js.Promise[js.BigInt[int64]], exception js.Any, ok bool) { 257 ok = js.True == bindings.TryStorageAreaGetBytesInUse( 258 this.ref, js.Pointer(&ret), js.Pointer(&exception), 259 keys.Ref(), 260 ) 261 262 return 263 } 264 265 // HasFuncGetBytesInUse1 returns true if the method "StorageArea.getBytesInUse" exists. 266 func (this StorageArea) HasFuncGetBytesInUse1() bool { 267 return js.True == bindings.HasFuncStorageAreaGetBytesInUse1( 268 this.ref, 269 ) 270 } 271 272 // FuncGetBytesInUse1 returns the method "StorageArea.getBytesInUse". 273 func (this StorageArea) FuncGetBytesInUse1() (fn js.Func[func() js.Promise[js.BigInt[int64]]]) { 274 bindings.FuncStorageAreaGetBytesInUse1( 275 this.ref, js.Pointer(&fn), 276 ) 277 return 278 } 279 280 // GetBytesInUse1 calls the method "StorageArea.getBytesInUse". 281 func (this StorageArea) GetBytesInUse1() (ret js.Promise[js.BigInt[int64]]) { 282 bindings.CallStorageAreaGetBytesInUse1( 283 this.ref, js.Pointer(&ret), 284 ) 285 286 return 287 } 288 289 // TryGetBytesInUse1 calls the method "StorageArea.getBytesInUse" 290 // in a try/catch block and returns (_, err, ok = false) when it went through 291 // the catch clause. 292 func (this StorageArea) TryGetBytesInUse1() (ret js.Promise[js.BigInt[int64]], exception js.Any, ok bool) { 293 ok = js.True == bindings.TryStorageAreaGetBytesInUse1( 294 this.ref, js.Pointer(&ret), js.Pointer(&exception), 295 ) 296 297 return 298 } 299 300 // HasFuncSet returns true if the method "StorageArea.set" exists. 301 func (this StorageArea) HasFuncSet() bool { 302 return js.True == bindings.HasFuncStorageAreaSet( 303 this.ref, 304 ) 305 } 306 307 // FuncSet returns the method "StorageArea.set". 308 func (this StorageArea) FuncSet() (fn js.Func[func(items js.Any) js.Promise[js.Void]]) { 309 bindings.FuncStorageAreaSet( 310 this.ref, js.Pointer(&fn), 311 ) 312 return 313 } 314 315 // Set calls the method "StorageArea.set". 316 func (this StorageArea) Set(items js.Any) (ret js.Promise[js.Void]) { 317 bindings.CallStorageAreaSet( 318 this.ref, js.Pointer(&ret), 319 items.Ref(), 320 ) 321 322 return 323 } 324 325 // TrySet calls the method "StorageArea.set" 326 // in a try/catch block and returns (_, err, ok = false) when it went through 327 // the catch clause. 328 func (this StorageArea) TrySet(items js.Any) (ret js.Promise[js.Void], exception js.Any, ok bool) { 329 ok = js.True == bindings.TryStorageAreaSet( 330 this.ref, js.Pointer(&ret), js.Pointer(&exception), 331 items.Ref(), 332 ) 333 334 return 335 } 336 337 // HasFuncRemove returns true if the method "StorageArea.remove" exists. 338 func (this StorageArea) HasFuncRemove() bool { 339 return js.True == bindings.HasFuncStorageAreaRemove( 340 this.ref, 341 ) 342 } 343 344 // FuncRemove returns the method "StorageArea.remove". 345 func (this StorageArea) FuncRemove() (fn js.Func[func(keys OneOf_String_ArrayString) js.Promise[js.Void]]) { 346 bindings.FuncStorageAreaRemove( 347 this.ref, js.Pointer(&fn), 348 ) 349 return 350 } 351 352 // Remove calls the method "StorageArea.remove". 353 func (this StorageArea) Remove(keys OneOf_String_ArrayString) (ret js.Promise[js.Void]) { 354 bindings.CallStorageAreaRemove( 355 this.ref, js.Pointer(&ret), 356 keys.Ref(), 357 ) 358 359 return 360 } 361 362 // TryRemove calls the method "StorageArea.remove" 363 // in a try/catch block and returns (_, err, ok = false) when it went through 364 // the catch clause. 365 func (this StorageArea) TryRemove(keys OneOf_String_ArrayString) (ret js.Promise[js.Void], exception js.Any, ok bool) { 366 ok = js.True == bindings.TryStorageAreaRemove( 367 this.ref, js.Pointer(&ret), js.Pointer(&exception), 368 keys.Ref(), 369 ) 370 371 return 372 } 373 374 // HasFuncClear returns true if the method "StorageArea.clear" exists. 375 func (this StorageArea) HasFuncClear() bool { 376 return js.True == bindings.HasFuncStorageAreaClear( 377 this.ref, 378 ) 379 } 380 381 // FuncClear returns the method "StorageArea.clear". 382 func (this StorageArea) FuncClear() (fn js.Func[func() js.Promise[js.Void]]) { 383 bindings.FuncStorageAreaClear( 384 this.ref, js.Pointer(&fn), 385 ) 386 return 387 } 388 389 // Clear calls the method "StorageArea.clear". 390 func (this StorageArea) Clear() (ret js.Promise[js.Void]) { 391 bindings.CallStorageAreaClear( 392 this.ref, js.Pointer(&ret), 393 ) 394 395 return 396 } 397 398 // TryClear calls the method "StorageArea.clear" 399 // in a try/catch block and returns (_, err, ok = false) when it went through 400 // the catch clause. 401 func (this StorageArea) TryClear() (ret js.Promise[js.Void], exception js.Any, ok bool) { 402 ok = js.True == bindings.TryStorageAreaClear( 403 this.ref, js.Pointer(&ret), js.Pointer(&exception), 404 ) 405 406 return 407 } 408 409 // HasFuncSetAccessLevel returns true if the method "StorageArea.setAccessLevel" exists. 410 func (this StorageArea) HasFuncSetAccessLevel() bool { 411 return js.True == bindings.HasFuncStorageAreaSetAccessLevel( 412 this.ref, 413 ) 414 } 415 416 // FuncSetAccessLevel returns the method "StorageArea.setAccessLevel". 417 func (this StorageArea) FuncSetAccessLevel() (fn js.Func[func(accessOptions SetAccessLevelArgAccessOptions) js.Promise[js.Void]]) { 418 bindings.FuncStorageAreaSetAccessLevel( 419 this.ref, js.Pointer(&fn), 420 ) 421 return 422 } 423 424 // SetAccessLevel calls the method "StorageArea.setAccessLevel". 425 func (this StorageArea) SetAccessLevel(accessOptions SetAccessLevelArgAccessOptions) (ret js.Promise[js.Void]) { 426 bindings.CallStorageAreaSetAccessLevel( 427 this.ref, js.Pointer(&ret), 428 js.Pointer(&accessOptions), 429 ) 430 431 return 432 } 433 434 // TrySetAccessLevel calls the method "StorageArea.setAccessLevel" 435 // in a try/catch block and returns (_, err, ok = false) when it went through 436 // the catch clause. 437 func (this StorageArea) TrySetAccessLevel(accessOptions SetAccessLevelArgAccessOptions) (ret js.Promise[js.Void], exception js.Any, ok bool) { 438 ok = js.True == bindings.TryStorageAreaSetAccessLevel( 439 this.ref, js.Pointer(&ret), js.Pointer(&exception), 440 js.Pointer(&accessOptions), 441 ) 442 443 return 444 } 445 446 type StorageChange struct { 447 // NewValue is "StorageChange.newValue" 448 // 449 // Optional 450 NewValue js.Any 451 // OldValue is "StorageChange.oldValue" 452 // 453 // Optional 454 OldValue js.Any 455 456 FFI_USE bool 457 } 458 459 // FromRef calls UpdateFrom and returns a StorageChange with all fields set. 460 func (p StorageChange) FromRef(ref js.Ref) StorageChange { 461 p.UpdateFrom(ref) 462 return p 463 } 464 465 // New creates a new StorageChange in the application heap. 466 func (p StorageChange) New() js.Ref { 467 return bindings.StorageChangeJSLoad( 468 js.Pointer(&p), js.True, 0, 469 ) 470 } 471 472 // UpdateFrom copies value of all fields of the heap object to p. 473 func (p *StorageChange) UpdateFrom(ref js.Ref) { 474 bindings.StorageChangeJSStore( 475 js.Pointer(p), ref, 476 ) 477 } 478 479 // Update writes all fields of the p to the heap object referenced by ref. 480 func (p *StorageChange) Update(ref js.Ref) { 481 bindings.StorageChangeJSLoad( 482 js.Pointer(p), js.False, ref, 483 ) 484 } 485 486 // FreeMembers frees fields with heap reference, if recursive is true 487 // free all heap references reachable from p. 488 func (p *StorageChange) FreeMembers(recursive bool) { 489 js.Free( 490 p.NewValue.Ref(), 491 p.OldValue.Ref(), 492 ) 493 p.NewValue = p.NewValue.FromRef(js.Undefined) 494 p.OldValue = p.OldValue.FromRef(js.Undefined) 495 } 496 497 // Local returns the value of property "WEBEXT.storage.local". 498 // 499 // The returned bool will be false if there is no such property. 500 func Local() (ret StorageArea, ok bool) { 501 ok = js.True == bindings.GetLocal( 502 js.Pointer(&ret), 503 ) 504 505 return 506 } 507 508 // SetLocal sets the value of property "WEBEXT.storage.local" to val. 509 // 510 // It returns false if the property cannot be set. 511 func SetLocal(val StorageArea) bool { 512 return js.True == bindings.SetLocal( 513 val.Ref()) 514 } 515 516 // Managed returns the value of property "WEBEXT.storage.managed". 517 // 518 // The returned bool will be false if there is no such property. 519 func Managed() (ret StorageArea, ok bool) { 520 ok = js.True == bindings.GetManaged( 521 js.Pointer(&ret), 522 ) 523 524 return 525 } 526 527 // SetManaged sets the value of property "WEBEXT.storage.managed" to val. 528 // 529 // It returns false if the property cannot be set. 530 func SetManaged(val StorageArea) bool { 531 return js.True == bindings.SetManaged( 532 val.Ref()) 533 } 534 535 type OnChangedEventCallbackFunc func(this js.Ref, changes *StorageChange, areaName js.String) js.Ref 536 537 func (fn OnChangedEventCallbackFunc) Register() js.Func[func(changes *StorageChange, areaName js.String)] { 538 return js.RegisterCallback[func(changes *StorageChange, areaName js.String)]( 539 fn, abi.FuncPCABIInternal(fn), 540 ) 541 } 542 543 func (fn OnChangedEventCallbackFunc) DispatchCallback( 544 targetPC uintptr, ctx *js.CallbackContext, 545 ) { 546 args := ctx.Args() 547 if len(args) != 2+1 /* js this */ || 548 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 549 js.ThrowInvalidCallbackInvocation() 550 } 551 var arg0 StorageChange 552 arg0.UpdateFrom(args[0+1]) 553 defer arg0.FreeMembers(true) 554 555 if ctx.Return(fn( 556 args[0], 557 558 mark.NoEscape(&arg0), 559 js.String{}.FromRef(args[1+1]), 560 )) { 561 return 562 } 563 564 js.ThrowCallbackValueNotReturned() 565 } 566 567 type OnChangedEventCallback[T any] struct { 568 Fn func(arg T, this js.Ref, changes *StorageChange, areaName js.String) js.Ref 569 Arg T 570 } 571 572 func (cb *OnChangedEventCallback[T]) Register() js.Func[func(changes *StorageChange, areaName js.String)] { 573 return js.RegisterCallback[func(changes *StorageChange, areaName js.String)]( 574 cb, abi.FuncPCABIInternal(cb.Fn), 575 ) 576 } 577 578 func (cb *OnChangedEventCallback[T]) DispatchCallback( 579 targetPC uintptr, ctx *js.CallbackContext, 580 ) { 581 args := ctx.Args() 582 if len(args) != 2+1 /* js this */ || 583 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 584 js.ThrowInvalidCallbackInvocation() 585 } 586 var arg0 StorageChange 587 arg0.UpdateFrom(args[0+1]) 588 defer arg0.FreeMembers(true) 589 590 if ctx.Return(cb.Fn( 591 cb.Arg, 592 args[0], 593 594 mark.NoEscape(&arg0), 595 js.String{}.FromRef(args[1+1]), 596 )) { 597 return 598 } 599 600 js.ThrowCallbackValueNotReturned() 601 } 602 603 // HasFuncOnChanged returns true if the function "WEBEXT.storage.onChanged.addListener" exists. 604 func HasFuncOnChanged() bool { 605 return js.True == bindings.HasFuncOnChanged() 606 } 607 608 // FuncOnChanged returns the function "WEBEXT.storage.onChanged.addListener". 609 func FuncOnChanged() (fn js.Func[func(callback js.Func[func(changes *StorageChange, areaName js.String)])]) { 610 bindings.FuncOnChanged( 611 js.Pointer(&fn), 612 ) 613 return 614 } 615 616 // OnChanged calls the function "WEBEXT.storage.onChanged.addListener" directly. 617 func OnChanged(callback js.Func[func(changes *StorageChange, areaName js.String)]) (ret js.Void) { 618 bindings.CallOnChanged( 619 js.Pointer(&ret), 620 callback.Ref(), 621 ) 622 623 return 624 } 625 626 // TryOnChanged calls the function "WEBEXT.storage.onChanged.addListener" 627 // in a try/catch block and returns (_, err, ok = false) when it went through 628 // the catch clause. 629 func TryOnChanged(callback js.Func[func(changes *StorageChange, areaName js.String)]) (ret js.Void, exception js.Any, ok bool) { 630 ok = js.True == bindings.TryOnChanged( 631 js.Pointer(&ret), js.Pointer(&exception), 632 callback.Ref(), 633 ) 634 635 return 636 } 637 638 // HasFuncOffChanged returns true if the function "WEBEXT.storage.onChanged.removeListener" exists. 639 func HasFuncOffChanged() bool { 640 return js.True == bindings.HasFuncOffChanged() 641 } 642 643 // FuncOffChanged returns the function "WEBEXT.storage.onChanged.removeListener". 644 func FuncOffChanged() (fn js.Func[func(callback js.Func[func(changes *StorageChange, areaName js.String)])]) { 645 bindings.FuncOffChanged( 646 js.Pointer(&fn), 647 ) 648 return 649 } 650 651 // OffChanged calls the function "WEBEXT.storage.onChanged.removeListener" directly. 652 func OffChanged(callback js.Func[func(changes *StorageChange, areaName js.String)]) (ret js.Void) { 653 bindings.CallOffChanged( 654 js.Pointer(&ret), 655 callback.Ref(), 656 ) 657 658 return 659 } 660 661 // TryOffChanged calls the function "WEBEXT.storage.onChanged.removeListener" 662 // in a try/catch block and returns (_, err, ok = false) when it went through 663 // the catch clause. 664 func TryOffChanged(callback js.Func[func(changes *StorageChange, areaName js.String)]) (ret js.Void, exception js.Any, ok bool) { 665 ok = js.True == bindings.TryOffChanged( 666 js.Pointer(&ret), js.Pointer(&exception), 667 callback.Ref(), 668 ) 669 670 return 671 } 672 673 // HasFuncHasOnChanged returns true if the function "WEBEXT.storage.onChanged.hasListener" exists. 674 func HasFuncHasOnChanged() bool { 675 return js.True == bindings.HasFuncHasOnChanged() 676 } 677 678 // FuncHasOnChanged returns the function "WEBEXT.storage.onChanged.hasListener". 679 func FuncHasOnChanged() (fn js.Func[func(callback js.Func[func(changes *StorageChange, areaName js.String)]) bool]) { 680 bindings.FuncHasOnChanged( 681 js.Pointer(&fn), 682 ) 683 return 684 } 685 686 // HasOnChanged calls the function "WEBEXT.storage.onChanged.hasListener" directly. 687 func HasOnChanged(callback js.Func[func(changes *StorageChange, areaName js.String)]) (ret bool) { 688 bindings.CallHasOnChanged( 689 js.Pointer(&ret), 690 callback.Ref(), 691 ) 692 693 return 694 } 695 696 // TryHasOnChanged calls the function "WEBEXT.storage.onChanged.hasListener" 697 // in a try/catch block and returns (_, err, ok = false) when it went through 698 // the catch clause. 699 func TryHasOnChanged(callback js.Func[func(changes *StorageChange, areaName js.String)]) (ret bool, exception js.Any, ok bool) { 700 ok = js.True == bindings.TryHasOnChanged( 701 js.Pointer(&ret), js.Pointer(&exception), 702 callback.Ref(), 703 ) 704 705 return 706 } 707 708 // Session returns the value of property "WEBEXT.storage.session". 709 // 710 // The returned bool will be false if there is no such property. 711 func Session() (ret StorageArea, ok bool) { 712 ok = js.True == bindings.GetSession( 713 js.Pointer(&ret), 714 ) 715 716 return 717 } 718 719 // SetSession sets the value of property "WEBEXT.storage.session" to val. 720 // 721 // It returns false if the property cannot be set. 722 func SetSession(val StorageArea) bool { 723 return js.True == bindings.SetSession( 724 val.Ref()) 725 } 726 727 // Sync returns the value of property "WEBEXT.storage.sync". 728 // 729 // The returned bool will be false if there is no such property. 730 func Sync() (ret StorageArea, ok bool) { 731 ok = js.True == bindings.GetSync( 732 js.Pointer(&ret), 733 ) 734 735 return 736 } 737 738 // SetSync sets the value of property "WEBEXT.storage.sync" to val. 739 // 740 // It returns false if the property cannot be set. 741 func SetSync(val StorageArea) bool { 742 return js.True == bindings.SetSync( 743 val.Ref()) 744 }