github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/bluetoothprivate/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package bluetoothprivate 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/bluetooth" 11 "github.com/primecitizens/pcz/std/plat/js/webext/bluetoothprivate/bindings" 12 ) 13 14 type ConnectCallbackFunc func(this js.Ref, result ConnectResultType) js.Ref 15 16 func (fn ConnectCallbackFunc) Register() js.Func[func(result ConnectResultType)] { 17 return js.RegisterCallback[func(result ConnectResultType)]( 18 fn, abi.FuncPCABIInternal(fn), 19 ) 20 } 21 22 func (fn ConnectCallbackFunc) DispatchCallback( 23 targetPC uintptr, ctx *js.CallbackContext, 24 ) { 25 args := ctx.Args() 26 if len(args) != 1+1 /* js this */ || 27 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 28 js.ThrowInvalidCallbackInvocation() 29 } 30 31 if ctx.Return(fn( 32 args[0], 33 34 ConnectResultType(0).FromRef(args[0+1]), 35 )) { 36 return 37 } 38 39 js.ThrowCallbackValueNotReturned() 40 } 41 42 type ConnectCallback[T any] struct { 43 Fn func(arg T, this js.Ref, result ConnectResultType) js.Ref 44 Arg T 45 } 46 47 func (cb *ConnectCallback[T]) Register() js.Func[func(result ConnectResultType)] { 48 return js.RegisterCallback[func(result ConnectResultType)]( 49 cb, abi.FuncPCABIInternal(cb.Fn), 50 ) 51 } 52 53 func (cb *ConnectCallback[T]) DispatchCallback( 54 targetPC uintptr, ctx *js.CallbackContext, 55 ) { 56 args := ctx.Args() 57 if len(args) != 1+1 /* js this */ || 58 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 59 js.ThrowInvalidCallbackInvocation() 60 } 61 62 if ctx.Return(cb.Fn( 63 cb.Arg, 64 args[0], 65 66 ConnectResultType(0).FromRef(args[0+1]), 67 )) { 68 return 69 } 70 71 js.ThrowCallbackValueNotReturned() 72 } 73 74 type ConnectResultType uint32 75 76 const ( 77 _ ConnectResultType = iota 78 79 ConnectResultType_ALREADY_CONNECTED 80 ConnectResultType_AUTH_CANCELED 81 ConnectResultType_AUTH_FAILED 82 ConnectResultType_AUTH_REJECTED 83 ConnectResultType_AUTH_TIMEOUT 84 ConnectResultType_FAILED 85 ConnectResultType_IN_PROGRESS 86 ConnectResultType_SUCCESS 87 ConnectResultType_UNKNOWN_ERROR 88 ConnectResultType_UNSUPPORTED_DEVICE 89 ConnectResultType_NOT_READY 90 ConnectResultType_ALREADY_EXISTS 91 ConnectResultType_NOT_CONNECTED 92 ConnectResultType_DOES_NOT_EXIST 93 ConnectResultType_INVALID_ARGS 94 ) 95 96 func (ConnectResultType) FromRef(str js.Ref) ConnectResultType { 97 return ConnectResultType(bindings.ConstOfConnectResultType(str)) 98 } 99 100 func (x ConnectResultType) String() (string, bool) { 101 switch x { 102 case ConnectResultType_ALREADY_CONNECTED: 103 return "alreadyConnected", true 104 case ConnectResultType_AUTH_CANCELED: 105 return "authCanceled", true 106 case ConnectResultType_AUTH_FAILED: 107 return "authFailed", true 108 case ConnectResultType_AUTH_REJECTED: 109 return "authRejected", true 110 case ConnectResultType_AUTH_TIMEOUT: 111 return "authTimeout", true 112 case ConnectResultType_FAILED: 113 return "failed", true 114 case ConnectResultType_IN_PROGRESS: 115 return "inProgress", true 116 case ConnectResultType_SUCCESS: 117 return "success", true 118 case ConnectResultType_UNKNOWN_ERROR: 119 return "unknownError", true 120 case ConnectResultType_UNSUPPORTED_DEVICE: 121 return "unsupportedDevice", true 122 case ConnectResultType_NOT_READY: 123 return "notReady", true 124 case ConnectResultType_ALREADY_EXISTS: 125 return "alreadyExists", true 126 case ConnectResultType_NOT_CONNECTED: 127 return "notConnected", true 128 case ConnectResultType_DOES_NOT_EXIST: 129 return "doesNotExist", true 130 case ConnectResultType_INVALID_ARGS: 131 return "invalidArgs", true 132 default: 133 return "", false 134 } 135 } 136 137 type TransportType uint32 138 139 const ( 140 _ TransportType = iota 141 142 TransportType_LE 143 TransportType_BREDR 144 TransportType_DUAL 145 ) 146 147 func (TransportType) FromRef(str js.Ref) TransportType { 148 return TransportType(bindings.ConstOfTransportType(str)) 149 } 150 151 func (x TransportType) String() (string, bool) { 152 switch x { 153 case TransportType_LE: 154 return "le", true 155 case TransportType_BREDR: 156 return "bredr", true 157 case TransportType_DUAL: 158 return "dual", true 159 default: 160 return "", false 161 } 162 } 163 164 type OneOf_String_ArrayString struct { 165 ref js.Ref 166 } 167 168 func (x OneOf_String_ArrayString) Ref() js.Ref { 169 return x.ref 170 } 171 172 func (x OneOf_String_ArrayString) Free() { 173 x.ref.Free() 174 } 175 176 func (x OneOf_String_ArrayString) FromRef(ref js.Ref) OneOf_String_ArrayString { 177 return OneOf_String_ArrayString{ 178 ref: ref, 179 } 180 } 181 182 func (x OneOf_String_ArrayString) String() js.String { 183 return js.String{}.FromRef(x.ref) 184 } 185 186 func (x OneOf_String_ArrayString) ArrayString() js.Array[js.String] { 187 return js.Array[js.String]{}.FromRef(x.ref) 188 } 189 190 type DiscoveryFilter struct { 191 // Transport is "DiscoveryFilter.transport" 192 // 193 // Optional 194 Transport TransportType 195 // Uuids is "DiscoveryFilter.uuids" 196 // 197 // Optional 198 Uuids OneOf_String_ArrayString 199 // Rssi is "DiscoveryFilter.rssi" 200 // 201 // Optional 202 // 203 // NOTE: FFI_USE_Rssi MUST be set to true to make this field effective. 204 Rssi int32 205 // Pathloss is "DiscoveryFilter.pathloss" 206 // 207 // Optional 208 // 209 // NOTE: FFI_USE_Pathloss MUST be set to true to make this field effective. 210 Pathloss int32 211 212 FFI_USE_Rssi bool // for Rssi. 213 FFI_USE_Pathloss bool // for Pathloss. 214 215 FFI_USE bool 216 } 217 218 // FromRef calls UpdateFrom and returns a DiscoveryFilter with all fields set. 219 func (p DiscoveryFilter) FromRef(ref js.Ref) DiscoveryFilter { 220 p.UpdateFrom(ref) 221 return p 222 } 223 224 // New creates a new DiscoveryFilter in the application heap. 225 func (p DiscoveryFilter) New() js.Ref { 226 return bindings.DiscoveryFilterJSLoad( 227 js.Pointer(&p), js.True, 0, 228 ) 229 } 230 231 // UpdateFrom copies value of all fields of the heap object to p. 232 func (p *DiscoveryFilter) UpdateFrom(ref js.Ref) { 233 bindings.DiscoveryFilterJSStore( 234 js.Pointer(p), ref, 235 ) 236 } 237 238 // Update writes all fields of the p to the heap object referenced by ref. 239 func (p *DiscoveryFilter) Update(ref js.Ref) { 240 bindings.DiscoveryFilterJSLoad( 241 js.Pointer(p), js.False, ref, 242 ) 243 } 244 245 // FreeMembers frees fields with heap reference, if recursive is true 246 // free all heap references reachable from p. 247 func (p *DiscoveryFilter) FreeMembers(recursive bool) { 248 js.Free( 249 p.Uuids.Ref(), 250 ) 251 p.Uuids = p.Uuids.FromRef(js.Undefined) 252 } 253 254 type NewAdapterState struct { 255 // Name is "NewAdapterState.name" 256 // 257 // Optional 258 Name js.String 259 // Powered is "NewAdapterState.powered" 260 // 261 // Optional 262 // 263 // NOTE: FFI_USE_Powered MUST be set to true to make this field effective. 264 Powered bool 265 // Discoverable is "NewAdapterState.discoverable" 266 // 267 // Optional 268 // 269 // NOTE: FFI_USE_Discoverable MUST be set to true to make this field effective. 270 Discoverable bool 271 272 FFI_USE_Powered bool // for Powered. 273 FFI_USE_Discoverable bool // for Discoverable. 274 275 FFI_USE bool 276 } 277 278 // FromRef calls UpdateFrom and returns a NewAdapterState with all fields set. 279 func (p NewAdapterState) FromRef(ref js.Ref) NewAdapterState { 280 p.UpdateFrom(ref) 281 return p 282 } 283 284 // New creates a new NewAdapterState in the application heap. 285 func (p NewAdapterState) New() js.Ref { 286 return bindings.NewAdapterStateJSLoad( 287 js.Pointer(&p), js.True, 0, 288 ) 289 } 290 291 // UpdateFrom copies value of all fields of the heap object to p. 292 func (p *NewAdapterState) UpdateFrom(ref js.Ref) { 293 bindings.NewAdapterStateJSStore( 294 js.Pointer(p), ref, 295 ) 296 } 297 298 // Update writes all fields of the p to the heap object referenced by ref. 299 func (p *NewAdapterState) Update(ref js.Ref) { 300 bindings.NewAdapterStateJSLoad( 301 js.Pointer(p), js.False, ref, 302 ) 303 } 304 305 // FreeMembers frees fields with heap reference, if recursive is true 306 // free all heap references reachable from p. 307 func (p *NewAdapterState) FreeMembers(recursive bool) { 308 js.Free( 309 p.Name.Ref(), 310 ) 311 p.Name = p.Name.FromRef(js.Undefined) 312 } 313 314 type PairingEventType uint32 315 316 const ( 317 _ PairingEventType = iota 318 319 PairingEventType_REQUEST_PINCODE 320 PairingEventType_DISPLAY_PINCODE 321 PairingEventType_REQUEST_PASSKEY 322 PairingEventType_DISPLAY_PASSKEY 323 PairingEventType_KEYS_ENTERED 324 PairingEventType_CONFIRM_PASSKEY 325 PairingEventType_REQUEST_AUTHORIZATION 326 PairingEventType_COMPLETE 327 ) 328 329 func (PairingEventType) FromRef(str js.Ref) PairingEventType { 330 return PairingEventType(bindings.ConstOfPairingEventType(str)) 331 } 332 333 func (x PairingEventType) String() (string, bool) { 334 switch x { 335 case PairingEventType_REQUEST_PINCODE: 336 return "requestPincode", true 337 case PairingEventType_DISPLAY_PINCODE: 338 return "displayPincode", true 339 case PairingEventType_REQUEST_PASSKEY: 340 return "requestPasskey", true 341 case PairingEventType_DISPLAY_PASSKEY: 342 return "displayPasskey", true 343 case PairingEventType_KEYS_ENTERED: 344 return "keysEntered", true 345 case PairingEventType_CONFIRM_PASSKEY: 346 return "confirmPasskey", true 347 case PairingEventType_REQUEST_AUTHORIZATION: 348 return "requestAuthorization", true 349 case PairingEventType_COMPLETE: 350 return "complete", true 351 default: 352 return "", false 353 } 354 } 355 356 type PairingEvent struct { 357 // Pairing is "PairingEvent.pairing" 358 // 359 // Optional 360 Pairing PairingEventType 361 // Device is "PairingEvent.device" 362 // 363 // Optional 364 // 365 // NOTE: Device.FFI_USE MUST be set to true to get Device used. 366 Device bluetooth.Device 367 // Pincode is "PairingEvent.pincode" 368 // 369 // Optional 370 Pincode js.String 371 // Passkey is "PairingEvent.passkey" 372 // 373 // Optional 374 // 375 // NOTE: FFI_USE_Passkey MUST be set to true to make this field effective. 376 Passkey int32 377 // EnteredKey is "PairingEvent.enteredKey" 378 // 379 // Optional 380 // 381 // NOTE: FFI_USE_EnteredKey MUST be set to true to make this field effective. 382 EnteredKey int32 383 384 FFI_USE_Passkey bool // for Passkey. 385 FFI_USE_EnteredKey bool // for EnteredKey. 386 387 FFI_USE bool 388 } 389 390 // FromRef calls UpdateFrom and returns a PairingEvent with all fields set. 391 func (p PairingEvent) FromRef(ref js.Ref) PairingEvent { 392 p.UpdateFrom(ref) 393 return p 394 } 395 396 // New creates a new PairingEvent in the application heap. 397 func (p PairingEvent) New() js.Ref { 398 return bindings.PairingEventJSLoad( 399 js.Pointer(&p), js.True, 0, 400 ) 401 } 402 403 // UpdateFrom copies value of all fields of the heap object to p. 404 func (p *PairingEvent) UpdateFrom(ref js.Ref) { 405 bindings.PairingEventJSStore( 406 js.Pointer(p), ref, 407 ) 408 } 409 410 // Update writes all fields of the p to the heap object referenced by ref. 411 func (p *PairingEvent) Update(ref js.Ref) { 412 bindings.PairingEventJSLoad( 413 js.Pointer(p), js.False, ref, 414 ) 415 } 416 417 // FreeMembers frees fields with heap reference, if recursive is true 418 // free all heap references reachable from p. 419 func (p *PairingEvent) FreeMembers(recursive bool) { 420 js.Free( 421 p.Pincode.Ref(), 422 ) 423 p.Pincode = p.Pincode.FromRef(js.Undefined) 424 if recursive { 425 p.Device.FreeMembers(true) 426 } 427 } 428 429 type PairingResponse uint32 430 431 const ( 432 _ PairingResponse = iota 433 434 PairingResponse_CONFIRM 435 PairingResponse_REJECT 436 PairingResponse_CANCEL 437 ) 438 439 func (PairingResponse) FromRef(str js.Ref) PairingResponse { 440 return PairingResponse(bindings.ConstOfPairingResponse(str)) 441 } 442 443 func (x PairingResponse) String() (string, bool) { 444 switch x { 445 case PairingResponse_CONFIRM: 446 return "confirm", true 447 case PairingResponse_REJECT: 448 return "reject", true 449 case PairingResponse_CANCEL: 450 return "cancel", true 451 default: 452 return "", false 453 } 454 } 455 456 type SetPairingResponseOptions struct { 457 // Device is "SetPairingResponseOptions.device" 458 // 459 // Optional 460 // 461 // NOTE: Device.FFI_USE MUST be set to true to get Device used. 462 Device bluetooth.Device 463 // Response is "SetPairingResponseOptions.response" 464 // 465 // Optional 466 Response PairingResponse 467 // Pincode is "SetPairingResponseOptions.pincode" 468 // 469 // Optional 470 Pincode js.String 471 // Passkey is "SetPairingResponseOptions.passkey" 472 // 473 // Optional 474 // 475 // NOTE: FFI_USE_Passkey MUST be set to true to make this field effective. 476 Passkey int32 477 478 FFI_USE_Passkey bool // for Passkey. 479 480 FFI_USE bool 481 } 482 483 // FromRef calls UpdateFrom and returns a SetPairingResponseOptions with all fields set. 484 func (p SetPairingResponseOptions) FromRef(ref js.Ref) SetPairingResponseOptions { 485 p.UpdateFrom(ref) 486 return p 487 } 488 489 // New creates a new SetPairingResponseOptions in the application heap. 490 func (p SetPairingResponseOptions) New() js.Ref { 491 return bindings.SetPairingResponseOptionsJSLoad( 492 js.Pointer(&p), js.True, 0, 493 ) 494 } 495 496 // UpdateFrom copies value of all fields of the heap object to p. 497 func (p *SetPairingResponseOptions) UpdateFrom(ref js.Ref) { 498 bindings.SetPairingResponseOptionsJSStore( 499 js.Pointer(p), ref, 500 ) 501 } 502 503 // Update writes all fields of the p to the heap object referenced by ref. 504 func (p *SetPairingResponseOptions) Update(ref js.Ref) { 505 bindings.SetPairingResponseOptionsJSLoad( 506 js.Pointer(p), js.False, ref, 507 ) 508 } 509 510 // FreeMembers frees fields with heap reference, if recursive is true 511 // free all heap references reachable from p. 512 func (p *SetPairingResponseOptions) FreeMembers(recursive bool) { 513 js.Free( 514 p.Pincode.Ref(), 515 ) 516 p.Pincode = p.Pincode.FromRef(js.Undefined) 517 if recursive { 518 p.Device.FreeMembers(true) 519 } 520 } 521 522 type VoidCallbackFunc func(this js.Ref) js.Ref 523 524 func (fn VoidCallbackFunc) Register() js.Func[func()] { 525 return js.RegisterCallback[func()]( 526 fn, abi.FuncPCABIInternal(fn), 527 ) 528 } 529 530 func (fn VoidCallbackFunc) DispatchCallback( 531 targetPC uintptr, ctx *js.CallbackContext, 532 ) { 533 args := ctx.Args() 534 if len(args) != 0+1 /* js this */ || 535 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 536 js.ThrowInvalidCallbackInvocation() 537 } 538 539 if ctx.Return(fn( 540 args[0], 541 )) { 542 return 543 } 544 545 js.ThrowCallbackValueNotReturned() 546 } 547 548 type VoidCallback[T any] struct { 549 Fn func(arg T, this js.Ref) js.Ref 550 Arg T 551 } 552 553 func (cb *VoidCallback[T]) Register() js.Func[func()] { 554 return js.RegisterCallback[func()]( 555 cb, abi.FuncPCABIInternal(cb.Fn), 556 ) 557 } 558 559 func (cb *VoidCallback[T]) DispatchCallback( 560 targetPC uintptr, ctx *js.CallbackContext, 561 ) { 562 args := ctx.Args() 563 if len(args) != 0+1 /* js this */ || 564 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 565 js.ThrowInvalidCallbackInvocation() 566 } 567 568 if ctx.Return(cb.Fn( 569 cb.Arg, 570 args[0], 571 )) { 572 return 573 } 574 575 js.ThrowCallbackValueNotReturned() 576 } 577 578 // HasFuncConnect returns true if the function "WEBEXT.bluetoothPrivate.connect" exists. 579 func HasFuncConnect() bool { 580 return js.True == bindings.HasFuncConnect() 581 } 582 583 // FuncConnect returns the function "WEBEXT.bluetoothPrivate.connect". 584 func FuncConnect() (fn js.Func[func(deviceAddress js.String) js.Promise[ConnectResultType]]) { 585 bindings.FuncConnect( 586 js.Pointer(&fn), 587 ) 588 return 589 } 590 591 // Connect calls the function "WEBEXT.bluetoothPrivate.connect" directly. 592 func Connect(deviceAddress js.String) (ret js.Promise[ConnectResultType]) { 593 bindings.CallConnect( 594 js.Pointer(&ret), 595 deviceAddress.Ref(), 596 ) 597 598 return 599 } 600 601 // TryConnect calls the function "WEBEXT.bluetoothPrivate.connect" 602 // in a try/catch block and returns (_, err, ok = false) when it went through 603 // the catch clause. 604 func TryConnect(deviceAddress js.String) (ret js.Promise[ConnectResultType], exception js.Any, ok bool) { 605 ok = js.True == bindings.TryConnect( 606 js.Pointer(&ret), js.Pointer(&exception), 607 deviceAddress.Ref(), 608 ) 609 610 return 611 } 612 613 // HasFuncDisconnectAll returns true if the function "WEBEXT.bluetoothPrivate.disconnectAll" exists. 614 func HasFuncDisconnectAll() bool { 615 return js.True == bindings.HasFuncDisconnectAll() 616 } 617 618 // FuncDisconnectAll returns the function "WEBEXT.bluetoothPrivate.disconnectAll". 619 func FuncDisconnectAll() (fn js.Func[func(deviceAddress js.String) js.Promise[js.Void]]) { 620 bindings.FuncDisconnectAll( 621 js.Pointer(&fn), 622 ) 623 return 624 } 625 626 // DisconnectAll calls the function "WEBEXT.bluetoothPrivate.disconnectAll" directly. 627 func DisconnectAll(deviceAddress js.String) (ret js.Promise[js.Void]) { 628 bindings.CallDisconnectAll( 629 js.Pointer(&ret), 630 deviceAddress.Ref(), 631 ) 632 633 return 634 } 635 636 // TryDisconnectAll calls the function "WEBEXT.bluetoothPrivate.disconnectAll" 637 // in a try/catch block and returns (_, err, ok = false) when it went through 638 // the catch clause. 639 func TryDisconnectAll(deviceAddress js.String) (ret js.Promise[js.Void], exception js.Any, ok bool) { 640 ok = js.True == bindings.TryDisconnectAll( 641 js.Pointer(&ret), js.Pointer(&exception), 642 deviceAddress.Ref(), 643 ) 644 645 return 646 } 647 648 // HasFuncForgetDevice returns true if the function "WEBEXT.bluetoothPrivate.forgetDevice" exists. 649 func HasFuncForgetDevice() bool { 650 return js.True == bindings.HasFuncForgetDevice() 651 } 652 653 // FuncForgetDevice returns the function "WEBEXT.bluetoothPrivate.forgetDevice". 654 func FuncForgetDevice() (fn js.Func[func(deviceAddress js.String) js.Promise[js.Void]]) { 655 bindings.FuncForgetDevice( 656 js.Pointer(&fn), 657 ) 658 return 659 } 660 661 // ForgetDevice calls the function "WEBEXT.bluetoothPrivate.forgetDevice" directly. 662 func ForgetDevice(deviceAddress js.String) (ret js.Promise[js.Void]) { 663 bindings.CallForgetDevice( 664 js.Pointer(&ret), 665 deviceAddress.Ref(), 666 ) 667 668 return 669 } 670 671 // TryForgetDevice calls the function "WEBEXT.bluetoothPrivate.forgetDevice" 672 // in a try/catch block and returns (_, err, ok = false) when it went through 673 // the catch clause. 674 func TryForgetDevice(deviceAddress js.String) (ret js.Promise[js.Void], exception js.Any, ok bool) { 675 ok = js.True == bindings.TryForgetDevice( 676 js.Pointer(&ret), js.Pointer(&exception), 677 deviceAddress.Ref(), 678 ) 679 680 return 681 } 682 683 type OnDeviceAddressChangedEventCallbackFunc func(this js.Ref, device *bluetooth.Device, oldAddress js.String) js.Ref 684 685 func (fn OnDeviceAddressChangedEventCallbackFunc) Register() js.Func[func(device *bluetooth.Device, oldAddress js.String)] { 686 return js.RegisterCallback[func(device *bluetooth.Device, oldAddress js.String)]( 687 fn, abi.FuncPCABIInternal(fn), 688 ) 689 } 690 691 func (fn OnDeviceAddressChangedEventCallbackFunc) DispatchCallback( 692 targetPC uintptr, ctx *js.CallbackContext, 693 ) { 694 args := ctx.Args() 695 if len(args) != 2+1 /* js this */ || 696 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 697 js.ThrowInvalidCallbackInvocation() 698 } 699 var arg0 bluetooth.Device 700 arg0.UpdateFrom(args[0+1]) 701 defer arg0.FreeMembers(true) 702 703 if ctx.Return(fn( 704 args[0], 705 706 mark.NoEscape(&arg0), 707 js.String{}.FromRef(args[1+1]), 708 )) { 709 return 710 } 711 712 js.ThrowCallbackValueNotReturned() 713 } 714 715 type OnDeviceAddressChangedEventCallback[T any] struct { 716 Fn func(arg T, this js.Ref, device *bluetooth.Device, oldAddress js.String) js.Ref 717 Arg T 718 } 719 720 func (cb *OnDeviceAddressChangedEventCallback[T]) Register() js.Func[func(device *bluetooth.Device, oldAddress js.String)] { 721 return js.RegisterCallback[func(device *bluetooth.Device, oldAddress js.String)]( 722 cb, abi.FuncPCABIInternal(cb.Fn), 723 ) 724 } 725 726 func (cb *OnDeviceAddressChangedEventCallback[T]) DispatchCallback( 727 targetPC uintptr, ctx *js.CallbackContext, 728 ) { 729 args := ctx.Args() 730 if len(args) != 2+1 /* js this */ || 731 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 732 js.ThrowInvalidCallbackInvocation() 733 } 734 var arg0 bluetooth.Device 735 arg0.UpdateFrom(args[0+1]) 736 defer arg0.FreeMembers(true) 737 738 if ctx.Return(cb.Fn( 739 cb.Arg, 740 args[0], 741 742 mark.NoEscape(&arg0), 743 js.String{}.FromRef(args[1+1]), 744 )) { 745 return 746 } 747 748 js.ThrowCallbackValueNotReturned() 749 } 750 751 // HasFuncOnDeviceAddressChanged returns true if the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener" exists. 752 func HasFuncOnDeviceAddressChanged() bool { 753 return js.True == bindings.HasFuncOnDeviceAddressChanged() 754 } 755 756 // FuncOnDeviceAddressChanged returns the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener". 757 func FuncOnDeviceAddressChanged() (fn js.Func[func(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)])]) { 758 bindings.FuncOnDeviceAddressChanged( 759 js.Pointer(&fn), 760 ) 761 return 762 } 763 764 // OnDeviceAddressChanged calls the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener" directly. 765 func OnDeviceAddressChanged(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) (ret js.Void) { 766 bindings.CallOnDeviceAddressChanged( 767 js.Pointer(&ret), 768 callback.Ref(), 769 ) 770 771 return 772 } 773 774 // TryOnDeviceAddressChanged calls the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.addListener" 775 // in a try/catch block and returns (_, err, ok = false) when it went through 776 // the catch clause. 777 func TryOnDeviceAddressChanged(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) (ret js.Void, exception js.Any, ok bool) { 778 ok = js.True == bindings.TryOnDeviceAddressChanged( 779 js.Pointer(&ret), js.Pointer(&exception), 780 callback.Ref(), 781 ) 782 783 return 784 } 785 786 // HasFuncOffDeviceAddressChanged returns true if the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener" exists. 787 func HasFuncOffDeviceAddressChanged() bool { 788 return js.True == bindings.HasFuncOffDeviceAddressChanged() 789 } 790 791 // FuncOffDeviceAddressChanged returns the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener". 792 func FuncOffDeviceAddressChanged() (fn js.Func[func(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)])]) { 793 bindings.FuncOffDeviceAddressChanged( 794 js.Pointer(&fn), 795 ) 796 return 797 } 798 799 // OffDeviceAddressChanged calls the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener" directly. 800 func OffDeviceAddressChanged(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) (ret js.Void) { 801 bindings.CallOffDeviceAddressChanged( 802 js.Pointer(&ret), 803 callback.Ref(), 804 ) 805 806 return 807 } 808 809 // TryOffDeviceAddressChanged calls the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.removeListener" 810 // in a try/catch block and returns (_, err, ok = false) when it went through 811 // the catch clause. 812 func TryOffDeviceAddressChanged(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) (ret js.Void, exception js.Any, ok bool) { 813 ok = js.True == bindings.TryOffDeviceAddressChanged( 814 js.Pointer(&ret), js.Pointer(&exception), 815 callback.Ref(), 816 ) 817 818 return 819 } 820 821 // HasFuncHasOnDeviceAddressChanged returns true if the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener" exists. 822 func HasFuncHasOnDeviceAddressChanged() bool { 823 return js.True == bindings.HasFuncHasOnDeviceAddressChanged() 824 } 825 826 // FuncHasOnDeviceAddressChanged returns the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener". 827 func FuncHasOnDeviceAddressChanged() (fn js.Func[func(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) bool]) { 828 bindings.FuncHasOnDeviceAddressChanged( 829 js.Pointer(&fn), 830 ) 831 return 832 } 833 834 // HasOnDeviceAddressChanged calls the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener" directly. 835 func HasOnDeviceAddressChanged(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) (ret bool) { 836 bindings.CallHasOnDeviceAddressChanged( 837 js.Pointer(&ret), 838 callback.Ref(), 839 ) 840 841 return 842 } 843 844 // TryHasOnDeviceAddressChanged calls the function "WEBEXT.bluetoothPrivate.onDeviceAddressChanged.hasListener" 845 // in a try/catch block and returns (_, err, ok = false) when it went through 846 // the catch clause. 847 func TryHasOnDeviceAddressChanged(callback js.Func[func(device *bluetooth.Device, oldAddress js.String)]) (ret bool, exception js.Any, ok bool) { 848 ok = js.True == bindings.TryHasOnDeviceAddressChanged( 849 js.Pointer(&ret), js.Pointer(&exception), 850 callback.Ref(), 851 ) 852 853 return 854 } 855 856 type OnPairingEventCallbackFunc func(this js.Ref, pairingEvent *PairingEvent) js.Ref 857 858 func (fn OnPairingEventCallbackFunc) Register() js.Func[func(pairingEvent *PairingEvent)] { 859 return js.RegisterCallback[func(pairingEvent *PairingEvent)]( 860 fn, abi.FuncPCABIInternal(fn), 861 ) 862 } 863 864 func (fn OnPairingEventCallbackFunc) DispatchCallback( 865 targetPC uintptr, ctx *js.CallbackContext, 866 ) { 867 args := ctx.Args() 868 if len(args) != 1+1 /* js this */ || 869 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 870 js.ThrowInvalidCallbackInvocation() 871 } 872 var arg0 PairingEvent 873 arg0.UpdateFrom(args[0+1]) 874 defer arg0.FreeMembers(true) 875 876 if ctx.Return(fn( 877 args[0], 878 879 mark.NoEscape(&arg0), 880 )) { 881 return 882 } 883 884 js.ThrowCallbackValueNotReturned() 885 } 886 887 type OnPairingEventCallback[T any] struct { 888 Fn func(arg T, this js.Ref, pairingEvent *PairingEvent) js.Ref 889 Arg T 890 } 891 892 func (cb *OnPairingEventCallback[T]) Register() js.Func[func(pairingEvent *PairingEvent)] { 893 return js.RegisterCallback[func(pairingEvent *PairingEvent)]( 894 cb, abi.FuncPCABIInternal(cb.Fn), 895 ) 896 } 897 898 func (cb *OnPairingEventCallback[T]) DispatchCallback( 899 targetPC uintptr, ctx *js.CallbackContext, 900 ) { 901 args := ctx.Args() 902 if len(args) != 1+1 /* js this */ || 903 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 904 js.ThrowInvalidCallbackInvocation() 905 } 906 var arg0 PairingEvent 907 arg0.UpdateFrom(args[0+1]) 908 defer arg0.FreeMembers(true) 909 910 if ctx.Return(cb.Fn( 911 cb.Arg, 912 args[0], 913 914 mark.NoEscape(&arg0), 915 )) { 916 return 917 } 918 919 js.ThrowCallbackValueNotReturned() 920 } 921 922 // HasFuncOnPairing returns true if the function "WEBEXT.bluetoothPrivate.onPairing.addListener" exists. 923 func HasFuncOnPairing() bool { 924 return js.True == bindings.HasFuncOnPairing() 925 } 926 927 // FuncOnPairing returns the function "WEBEXT.bluetoothPrivate.onPairing.addListener". 928 func FuncOnPairing() (fn js.Func[func(callback js.Func[func(pairingEvent *PairingEvent)])]) { 929 bindings.FuncOnPairing( 930 js.Pointer(&fn), 931 ) 932 return 933 } 934 935 // OnPairing calls the function "WEBEXT.bluetoothPrivate.onPairing.addListener" directly. 936 func OnPairing(callback js.Func[func(pairingEvent *PairingEvent)]) (ret js.Void) { 937 bindings.CallOnPairing( 938 js.Pointer(&ret), 939 callback.Ref(), 940 ) 941 942 return 943 } 944 945 // TryOnPairing calls the function "WEBEXT.bluetoothPrivate.onPairing.addListener" 946 // in a try/catch block and returns (_, err, ok = false) when it went through 947 // the catch clause. 948 func TryOnPairing(callback js.Func[func(pairingEvent *PairingEvent)]) (ret js.Void, exception js.Any, ok bool) { 949 ok = js.True == bindings.TryOnPairing( 950 js.Pointer(&ret), js.Pointer(&exception), 951 callback.Ref(), 952 ) 953 954 return 955 } 956 957 // HasFuncOffPairing returns true if the function "WEBEXT.bluetoothPrivate.onPairing.removeListener" exists. 958 func HasFuncOffPairing() bool { 959 return js.True == bindings.HasFuncOffPairing() 960 } 961 962 // FuncOffPairing returns the function "WEBEXT.bluetoothPrivate.onPairing.removeListener". 963 func FuncOffPairing() (fn js.Func[func(callback js.Func[func(pairingEvent *PairingEvent)])]) { 964 bindings.FuncOffPairing( 965 js.Pointer(&fn), 966 ) 967 return 968 } 969 970 // OffPairing calls the function "WEBEXT.bluetoothPrivate.onPairing.removeListener" directly. 971 func OffPairing(callback js.Func[func(pairingEvent *PairingEvent)]) (ret js.Void) { 972 bindings.CallOffPairing( 973 js.Pointer(&ret), 974 callback.Ref(), 975 ) 976 977 return 978 } 979 980 // TryOffPairing calls the function "WEBEXT.bluetoothPrivate.onPairing.removeListener" 981 // in a try/catch block and returns (_, err, ok = false) when it went through 982 // the catch clause. 983 func TryOffPairing(callback js.Func[func(pairingEvent *PairingEvent)]) (ret js.Void, exception js.Any, ok bool) { 984 ok = js.True == bindings.TryOffPairing( 985 js.Pointer(&ret), js.Pointer(&exception), 986 callback.Ref(), 987 ) 988 989 return 990 } 991 992 // HasFuncHasOnPairing returns true if the function "WEBEXT.bluetoothPrivate.onPairing.hasListener" exists. 993 func HasFuncHasOnPairing() bool { 994 return js.True == bindings.HasFuncHasOnPairing() 995 } 996 997 // FuncHasOnPairing returns the function "WEBEXT.bluetoothPrivate.onPairing.hasListener". 998 func FuncHasOnPairing() (fn js.Func[func(callback js.Func[func(pairingEvent *PairingEvent)]) bool]) { 999 bindings.FuncHasOnPairing( 1000 js.Pointer(&fn), 1001 ) 1002 return 1003 } 1004 1005 // HasOnPairing calls the function "WEBEXT.bluetoothPrivate.onPairing.hasListener" directly. 1006 func HasOnPairing(callback js.Func[func(pairingEvent *PairingEvent)]) (ret bool) { 1007 bindings.CallHasOnPairing( 1008 js.Pointer(&ret), 1009 callback.Ref(), 1010 ) 1011 1012 return 1013 } 1014 1015 // TryHasOnPairing calls the function "WEBEXT.bluetoothPrivate.onPairing.hasListener" 1016 // in a try/catch block and returns (_, err, ok = false) when it went through 1017 // the catch clause. 1018 func TryHasOnPairing(callback js.Func[func(pairingEvent *PairingEvent)]) (ret bool, exception js.Any, ok bool) { 1019 ok = js.True == bindings.TryHasOnPairing( 1020 js.Pointer(&ret), js.Pointer(&exception), 1021 callback.Ref(), 1022 ) 1023 1024 return 1025 } 1026 1027 // HasFuncPair returns true if the function "WEBEXT.bluetoothPrivate.pair" exists. 1028 func HasFuncPair() bool { 1029 return js.True == bindings.HasFuncPair() 1030 } 1031 1032 // FuncPair returns the function "WEBEXT.bluetoothPrivate.pair". 1033 func FuncPair() (fn js.Func[func(deviceAddress js.String) js.Promise[js.Void]]) { 1034 bindings.FuncPair( 1035 js.Pointer(&fn), 1036 ) 1037 return 1038 } 1039 1040 // Pair calls the function "WEBEXT.bluetoothPrivate.pair" directly. 1041 func Pair(deviceAddress js.String) (ret js.Promise[js.Void]) { 1042 bindings.CallPair( 1043 js.Pointer(&ret), 1044 deviceAddress.Ref(), 1045 ) 1046 1047 return 1048 } 1049 1050 // TryPair calls the function "WEBEXT.bluetoothPrivate.pair" 1051 // in a try/catch block and returns (_, err, ok = false) when it went through 1052 // the catch clause. 1053 func TryPair(deviceAddress js.String) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1054 ok = js.True == bindings.TryPair( 1055 js.Pointer(&ret), js.Pointer(&exception), 1056 deviceAddress.Ref(), 1057 ) 1058 1059 return 1060 } 1061 1062 // HasFuncRecordDeviceSelection returns true if the function "WEBEXT.bluetoothPrivate.recordDeviceSelection" exists. 1063 func HasFuncRecordDeviceSelection() bool { 1064 return js.True == bindings.HasFuncRecordDeviceSelection() 1065 } 1066 1067 // FuncRecordDeviceSelection returns the function "WEBEXT.bluetoothPrivate.recordDeviceSelection". 1068 func FuncRecordDeviceSelection() (fn js.Func[func(selectionDurationMs int32, wasPaired bool, transport bluetooth.Transport)]) { 1069 bindings.FuncRecordDeviceSelection( 1070 js.Pointer(&fn), 1071 ) 1072 return 1073 } 1074 1075 // RecordDeviceSelection calls the function "WEBEXT.bluetoothPrivate.recordDeviceSelection" directly. 1076 func RecordDeviceSelection(selectionDurationMs int32, wasPaired bool, transport bluetooth.Transport) (ret js.Void) { 1077 bindings.CallRecordDeviceSelection( 1078 js.Pointer(&ret), 1079 int32(selectionDurationMs), 1080 js.Bool(bool(wasPaired)), 1081 uint32(transport), 1082 ) 1083 1084 return 1085 } 1086 1087 // TryRecordDeviceSelection calls the function "WEBEXT.bluetoothPrivate.recordDeviceSelection" 1088 // in a try/catch block and returns (_, err, ok = false) when it went through 1089 // the catch clause. 1090 func TryRecordDeviceSelection(selectionDurationMs int32, wasPaired bool, transport bluetooth.Transport) (ret js.Void, exception js.Any, ok bool) { 1091 ok = js.True == bindings.TryRecordDeviceSelection( 1092 js.Pointer(&ret), js.Pointer(&exception), 1093 int32(selectionDurationMs), 1094 js.Bool(bool(wasPaired)), 1095 uint32(transport), 1096 ) 1097 1098 return 1099 } 1100 1101 // HasFuncRecordPairing returns true if the function "WEBEXT.bluetoothPrivate.recordPairing" exists. 1102 func HasFuncRecordPairing() bool { 1103 return js.True == bindings.HasFuncRecordPairing() 1104 } 1105 1106 // FuncRecordPairing returns the function "WEBEXT.bluetoothPrivate.recordPairing". 1107 func FuncRecordPairing() (fn js.Func[func(transport bluetooth.Transport, pairingDurationMs int32, result ConnectResultType)]) { 1108 bindings.FuncRecordPairing( 1109 js.Pointer(&fn), 1110 ) 1111 return 1112 } 1113 1114 // RecordPairing calls the function "WEBEXT.bluetoothPrivate.recordPairing" directly. 1115 func RecordPairing(transport bluetooth.Transport, pairingDurationMs int32, result ConnectResultType) (ret js.Void) { 1116 bindings.CallRecordPairing( 1117 js.Pointer(&ret), 1118 uint32(transport), 1119 int32(pairingDurationMs), 1120 uint32(result), 1121 ) 1122 1123 return 1124 } 1125 1126 // TryRecordPairing calls the function "WEBEXT.bluetoothPrivate.recordPairing" 1127 // in a try/catch block and returns (_, err, ok = false) when it went through 1128 // the catch clause. 1129 func TryRecordPairing(transport bluetooth.Transport, pairingDurationMs int32, result ConnectResultType) (ret js.Void, exception js.Any, ok bool) { 1130 ok = js.True == bindings.TryRecordPairing( 1131 js.Pointer(&ret), js.Pointer(&exception), 1132 uint32(transport), 1133 int32(pairingDurationMs), 1134 uint32(result), 1135 ) 1136 1137 return 1138 } 1139 1140 // HasFuncRecordReconnection returns true if the function "WEBEXT.bluetoothPrivate.recordReconnection" exists. 1141 func HasFuncRecordReconnection() bool { 1142 return js.True == bindings.HasFuncRecordReconnection() 1143 } 1144 1145 // FuncRecordReconnection returns the function "WEBEXT.bluetoothPrivate.recordReconnection". 1146 func FuncRecordReconnection() (fn js.Func[func(result ConnectResultType)]) { 1147 bindings.FuncRecordReconnection( 1148 js.Pointer(&fn), 1149 ) 1150 return 1151 } 1152 1153 // RecordReconnection calls the function "WEBEXT.bluetoothPrivate.recordReconnection" directly. 1154 func RecordReconnection(result ConnectResultType) (ret js.Void) { 1155 bindings.CallRecordReconnection( 1156 js.Pointer(&ret), 1157 uint32(result), 1158 ) 1159 1160 return 1161 } 1162 1163 // TryRecordReconnection calls the function "WEBEXT.bluetoothPrivate.recordReconnection" 1164 // in a try/catch block and returns (_, err, ok = false) when it went through 1165 // the catch clause. 1166 func TryRecordReconnection(result ConnectResultType) (ret js.Void, exception js.Any, ok bool) { 1167 ok = js.True == bindings.TryRecordReconnection( 1168 js.Pointer(&ret), js.Pointer(&exception), 1169 uint32(result), 1170 ) 1171 1172 return 1173 } 1174 1175 // HasFuncSetAdapterState returns true if the function "WEBEXT.bluetoothPrivate.setAdapterState" exists. 1176 func HasFuncSetAdapterState() bool { 1177 return js.True == bindings.HasFuncSetAdapterState() 1178 } 1179 1180 // FuncSetAdapterState returns the function "WEBEXT.bluetoothPrivate.setAdapterState". 1181 func FuncSetAdapterState() (fn js.Func[func(adapterState NewAdapterState) js.Promise[js.Void]]) { 1182 bindings.FuncSetAdapterState( 1183 js.Pointer(&fn), 1184 ) 1185 return 1186 } 1187 1188 // SetAdapterState calls the function "WEBEXT.bluetoothPrivate.setAdapterState" directly. 1189 func SetAdapterState(adapterState NewAdapterState) (ret js.Promise[js.Void]) { 1190 bindings.CallSetAdapterState( 1191 js.Pointer(&ret), 1192 js.Pointer(&adapterState), 1193 ) 1194 1195 return 1196 } 1197 1198 // TrySetAdapterState calls the function "WEBEXT.bluetoothPrivate.setAdapterState" 1199 // in a try/catch block and returns (_, err, ok = false) when it went through 1200 // the catch clause. 1201 func TrySetAdapterState(adapterState NewAdapterState) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1202 ok = js.True == bindings.TrySetAdapterState( 1203 js.Pointer(&ret), js.Pointer(&exception), 1204 js.Pointer(&adapterState), 1205 ) 1206 1207 return 1208 } 1209 1210 // HasFuncSetDiscoveryFilter returns true if the function "WEBEXT.bluetoothPrivate.setDiscoveryFilter" exists. 1211 func HasFuncSetDiscoveryFilter() bool { 1212 return js.True == bindings.HasFuncSetDiscoveryFilter() 1213 } 1214 1215 // FuncSetDiscoveryFilter returns the function "WEBEXT.bluetoothPrivate.setDiscoveryFilter". 1216 func FuncSetDiscoveryFilter() (fn js.Func[func(discoveryFilter DiscoveryFilter) js.Promise[js.Void]]) { 1217 bindings.FuncSetDiscoveryFilter( 1218 js.Pointer(&fn), 1219 ) 1220 return 1221 } 1222 1223 // SetDiscoveryFilter calls the function "WEBEXT.bluetoothPrivate.setDiscoveryFilter" directly. 1224 func SetDiscoveryFilter(discoveryFilter DiscoveryFilter) (ret js.Promise[js.Void]) { 1225 bindings.CallSetDiscoveryFilter( 1226 js.Pointer(&ret), 1227 js.Pointer(&discoveryFilter), 1228 ) 1229 1230 return 1231 } 1232 1233 // TrySetDiscoveryFilter calls the function "WEBEXT.bluetoothPrivate.setDiscoveryFilter" 1234 // in a try/catch block and returns (_, err, ok = false) when it went through 1235 // the catch clause. 1236 func TrySetDiscoveryFilter(discoveryFilter DiscoveryFilter) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1237 ok = js.True == bindings.TrySetDiscoveryFilter( 1238 js.Pointer(&ret), js.Pointer(&exception), 1239 js.Pointer(&discoveryFilter), 1240 ) 1241 1242 return 1243 } 1244 1245 // HasFuncSetPairingResponse returns true if the function "WEBEXT.bluetoothPrivate.setPairingResponse" exists. 1246 func HasFuncSetPairingResponse() bool { 1247 return js.True == bindings.HasFuncSetPairingResponse() 1248 } 1249 1250 // FuncSetPairingResponse returns the function "WEBEXT.bluetoothPrivate.setPairingResponse". 1251 func FuncSetPairingResponse() (fn js.Func[func(options SetPairingResponseOptions) js.Promise[js.Void]]) { 1252 bindings.FuncSetPairingResponse( 1253 js.Pointer(&fn), 1254 ) 1255 return 1256 } 1257 1258 // SetPairingResponse calls the function "WEBEXT.bluetoothPrivate.setPairingResponse" directly. 1259 func SetPairingResponse(options SetPairingResponseOptions) (ret js.Promise[js.Void]) { 1260 bindings.CallSetPairingResponse( 1261 js.Pointer(&ret), 1262 js.Pointer(&options), 1263 ) 1264 1265 return 1266 } 1267 1268 // TrySetPairingResponse calls the function "WEBEXT.bluetoothPrivate.setPairingResponse" 1269 // in a try/catch block and returns (_, err, ok = false) when it went through 1270 // the catch clause. 1271 func TrySetPairingResponse(options SetPairingResponseOptions) (ret js.Promise[js.Void], exception js.Any, ok bool) { 1272 ok = js.True == bindings.TrySetPairingResponse( 1273 js.Pointer(&ret), js.Pointer(&exception), 1274 js.Pointer(&options), 1275 ) 1276 1277 return 1278 }