github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/debugger/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package debugger 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/debugger/bindings" 11 ) 12 13 type Debuggee struct { 14 // ExtensionId is "Debuggee.extensionId" 15 // 16 // Optional 17 ExtensionId js.String 18 // TabId is "Debuggee.tabId" 19 // 20 // Optional 21 // 22 // NOTE: FFI_USE_TabId MUST be set to true to make this field effective. 23 TabId int64 24 // TargetId is "Debuggee.targetId" 25 // 26 // Optional 27 TargetId js.String 28 29 FFI_USE_TabId bool // for TabId. 30 31 FFI_USE bool 32 } 33 34 // FromRef calls UpdateFrom and returns a Debuggee with all fields set. 35 func (p Debuggee) FromRef(ref js.Ref) Debuggee { 36 p.UpdateFrom(ref) 37 return p 38 } 39 40 // New creates a new Debuggee in the application heap. 41 func (p Debuggee) New() js.Ref { 42 return bindings.DebuggeeJSLoad( 43 js.Pointer(&p), js.True, 0, 44 ) 45 } 46 47 // UpdateFrom copies value of all fields of the heap object to p. 48 func (p *Debuggee) UpdateFrom(ref js.Ref) { 49 bindings.DebuggeeJSStore( 50 js.Pointer(p), ref, 51 ) 52 } 53 54 // Update writes all fields of the p to the heap object referenced by ref. 55 func (p *Debuggee) Update(ref js.Ref) { 56 bindings.DebuggeeJSLoad( 57 js.Pointer(p), js.False, ref, 58 ) 59 } 60 61 // FreeMembers frees fields with heap reference, if recursive is true 62 // free all heap references reachable from p. 63 func (p *Debuggee) FreeMembers(recursive bool) { 64 js.Free( 65 p.ExtensionId.Ref(), 66 p.TargetId.Ref(), 67 ) 68 p.ExtensionId = p.ExtensionId.FromRef(js.Undefined) 69 p.TargetId = p.TargetId.FromRef(js.Undefined) 70 } 71 72 type DetachReason uint32 73 74 const ( 75 _ DetachReason = iota 76 77 DetachReason_TARGET_CLOSED 78 DetachReason_CANCELED_BY_USER 79 ) 80 81 func (DetachReason) FromRef(str js.Ref) DetachReason { 82 return DetachReason(bindings.ConstOfDetachReason(str)) 83 } 84 85 func (x DetachReason) String() (string, bool) { 86 switch x { 87 case DetachReason_TARGET_CLOSED: 88 return "target_closed", true 89 case DetachReason_CANCELED_BY_USER: 90 return "canceled_by_user", true 91 default: 92 return "", false 93 } 94 } 95 96 type TargetInfoType uint32 97 98 const ( 99 _ TargetInfoType = iota 100 101 TargetInfoType_PAGE 102 TargetInfoType_BACKGROUND_PAGE 103 TargetInfoType_WORKER 104 TargetInfoType_OTHER 105 ) 106 107 func (TargetInfoType) FromRef(str js.Ref) TargetInfoType { 108 return TargetInfoType(bindings.ConstOfTargetInfoType(str)) 109 } 110 111 func (x TargetInfoType) String() (string, bool) { 112 switch x { 113 case TargetInfoType_PAGE: 114 return "page", true 115 case TargetInfoType_BACKGROUND_PAGE: 116 return "background_page", true 117 case TargetInfoType_WORKER: 118 return "worker", true 119 case TargetInfoType_OTHER: 120 return "other", true 121 default: 122 return "", false 123 } 124 } 125 126 type TargetInfo struct { 127 // Attached is "TargetInfo.attached" 128 // 129 // Required 130 Attached bool 131 // ExtensionId is "TargetInfo.extensionId" 132 // 133 // Optional 134 ExtensionId js.String 135 // FaviconUrl is "TargetInfo.faviconUrl" 136 // 137 // Optional 138 FaviconUrl js.String 139 // Id is "TargetInfo.id" 140 // 141 // Required 142 Id js.String 143 // TabId is "TargetInfo.tabId" 144 // 145 // Optional 146 // 147 // NOTE: FFI_USE_TabId MUST be set to true to make this field effective. 148 TabId int64 149 // Title is "TargetInfo.title" 150 // 151 // Required 152 Title js.String 153 // Type is "TargetInfo.type" 154 // 155 // Required 156 Type TargetInfoType 157 // Url is "TargetInfo.url" 158 // 159 // Required 160 Url js.String 161 162 FFI_USE_TabId bool // for TabId. 163 164 FFI_USE bool 165 } 166 167 // FromRef calls UpdateFrom and returns a TargetInfo with all fields set. 168 func (p TargetInfo) FromRef(ref js.Ref) TargetInfo { 169 p.UpdateFrom(ref) 170 return p 171 } 172 173 // New creates a new TargetInfo in the application heap. 174 func (p TargetInfo) New() js.Ref { 175 return bindings.TargetInfoJSLoad( 176 js.Pointer(&p), js.True, 0, 177 ) 178 } 179 180 // UpdateFrom copies value of all fields of the heap object to p. 181 func (p *TargetInfo) UpdateFrom(ref js.Ref) { 182 bindings.TargetInfoJSStore( 183 js.Pointer(p), ref, 184 ) 185 } 186 187 // Update writes all fields of the p to the heap object referenced by ref. 188 func (p *TargetInfo) Update(ref js.Ref) { 189 bindings.TargetInfoJSLoad( 190 js.Pointer(p), js.False, ref, 191 ) 192 } 193 194 // FreeMembers frees fields with heap reference, if recursive is true 195 // free all heap references reachable from p. 196 func (p *TargetInfo) FreeMembers(recursive bool) { 197 js.Free( 198 p.ExtensionId.Ref(), 199 p.FaviconUrl.Ref(), 200 p.Id.Ref(), 201 p.Title.Ref(), 202 p.Url.Ref(), 203 ) 204 p.ExtensionId = p.ExtensionId.FromRef(js.Undefined) 205 p.FaviconUrl = p.FaviconUrl.FromRef(js.Undefined) 206 p.Id = p.Id.FromRef(js.Undefined) 207 p.Title = p.Title.FromRef(js.Undefined) 208 p.Url = p.Url.FromRef(js.Undefined) 209 } 210 211 // HasFuncAttach returns true if the function "WEBEXT.debugger.attach" exists. 212 func HasFuncAttach() bool { 213 return js.True == bindings.HasFuncAttach() 214 } 215 216 // FuncAttach returns the function "WEBEXT.debugger.attach". 217 func FuncAttach() (fn js.Func[func(target Debuggee, requiredVersion js.String) js.Promise[js.Void]]) { 218 bindings.FuncAttach( 219 js.Pointer(&fn), 220 ) 221 return 222 } 223 224 // Attach calls the function "WEBEXT.debugger.attach" directly. 225 func Attach(target Debuggee, requiredVersion js.String) (ret js.Promise[js.Void]) { 226 bindings.CallAttach( 227 js.Pointer(&ret), 228 js.Pointer(&target), 229 requiredVersion.Ref(), 230 ) 231 232 return 233 } 234 235 // TryAttach calls the function "WEBEXT.debugger.attach" 236 // in a try/catch block and returns (_, err, ok = false) when it went through 237 // the catch clause. 238 func TryAttach(target Debuggee, requiredVersion js.String) (ret js.Promise[js.Void], exception js.Any, ok bool) { 239 ok = js.True == bindings.TryAttach( 240 js.Pointer(&ret), js.Pointer(&exception), 241 js.Pointer(&target), 242 requiredVersion.Ref(), 243 ) 244 245 return 246 } 247 248 // HasFuncDetach returns true if the function "WEBEXT.debugger.detach" exists. 249 func HasFuncDetach() bool { 250 return js.True == bindings.HasFuncDetach() 251 } 252 253 // FuncDetach returns the function "WEBEXT.debugger.detach". 254 func FuncDetach() (fn js.Func[func(target Debuggee) js.Promise[js.Void]]) { 255 bindings.FuncDetach( 256 js.Pointer(&fn), 257 ) 258 return 259 } 260 261 // Detach calls the function "WEBEXT.debugger.detach" directly. 262 func Detach(target Debuggee) (ret js.Promise[js.Void]) { 263 bindings.CallDetach( 264 js.Pointer(&ret), 265 js.Pointer(&target), 266 ) 267 268 return 269 } 270 271 // TryDetach calls the function "WEBEXT.debugger.detach" 272 // in a try/catch block and returns (_, err, ok = false) when it went through 273 // the catch clause. 274 func TryDetach(target Debuggee) (ret js.Promise[js.Void], exception js.Any, ok bool) { 275 ok = js.True == bindings.TryDetach( 276 js.Pointer(&ret), js.Pointer(&exception), 277 js.Pointer(&target), 278 ) 279 280 return 281 } 282 283 // HasFuncGetTargets returns true if the function "WEBEXT.debugger.getTargets" exists. 284 func HasFuncGetTargets() bool { 285 return js.True == bindings.HasFuncGetTargets() 286 } 287 288 // FuncGetTargets returns the function "WEBEXT.debugger.getTargets". 289 func FuncGetTargets() (fn js.Func[func() js.Promise[js.Array[TargetInfo]]]) { 290 bindings.FuncGetTargets( 291 js.Pointer(&fn), 292 ) 293 return 294 } 295 296 // GetTargets calls the function "WEBEXT.debugger.getTargets" directly. 297 func GetTargets() (ret js.Promise[js.Array[TargetInfo]]) { 298 bindings.CallGetTargets( 299 js.Pointer(&ret), 300 ) 301 302 return 303 } 304 305 // TryGetTargets calls the function "WEBEXT.debugger.getTargets" 306 // in a try/catch block and returns (_, err, ok = false) when it went through 307 // the catch clause. 308 func TryGetTargets() (ret js.Promise[js.Array[TargetInfo]], exception js.Any, ok bool) { 309 ok = js.True == bindings.TryGetTargets( 310 js.Pointer(&ret), js.Pointer(&exception), 311 ) 312 313 return 314 } 315 316 type OnDetachEventCallbackFunc func(this js.Ref, source *Debuggee, reason DetachReason) js.Ref 317 318 func (fn OnDetachEventCallbackFunc) Register() js.Func[func(source *Debuggee, reason DetachReason)] { 319 return js.RegisterCallback[func(source *Debuggee, reason DetachReason)]( 320 fn, abi.FuncPCABIInternal(fn), 321 ) 322 } 323 324 func (fn OnDetachEventCallbackFunc) DispatchCallback( 325 targetPC uintptr, ctx *js.CallbackContext, 326 ) { 327 args := ctx.Args() 328 if len(args) != 2+1 /* js this */ || 329 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 330 js.ThrowInvalidCallbackInvocation() 331 } 332 var arg0 Debuggee 333 arg0.UpdateFrom(args[0+1]) 334 defer arg0.FreeMembers(true) 335 336 if ctx.Return(fn( 337 args[0], 338 339 mark.NoEscape(&arg0), 340 DetachReason(0).FromRef(args[1+1]), 341 )) { 342 return 343 } 344 345 js.ThrowCallbackValueNotReturned() 346 } 347 348 type OnDetachEventCallback[T any] struct { 349 Fn func(arg T, this js.Ref, source *Debuggee, reason DetachReason) js.Ref 350 Arg T 351 } 352 353 func (cb *OnDetachEventCallback[T]) Register() js.Func[func(source *Debuggee, reason DetachReason)] { 354 return js.RegisterCallback[func(source *Debuggee, reason DetachReason)]( 355 cb, abi.FuncPCABIInternal(cb.Fn), 356 ) 357 } 358 359 func (cb *OnDetachEventCallback[T]) DispatchCallback( 360 targetPC uintptr, ctx *js.CallbackContext, 361 ) { 362 args := ctx.Args() 363 if len(args) != 2+1 /* js this */ || 364 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 365 js.ThrowInvalidCallbackInvocation() 366 } 367 var arg0 Debuggee 368 arg0.UpdateFrom(args[0+1]) 369 defer arg0.FreeMembers(true) 370 371 if ctx.Return(cb.Fn( 372 cb.Arg, 373 args[0], 374 375 mark.NoEscape(&arg0), 376 DetachReason(0).FromRef(args[1+1]), 377 )) { 378 return 379 } 380 381 js.ThrowCallbackValueNotReturned() 382 } 383 384 // HasFuncOnDetach returns true if the function "WEBEXT.debugger.onDetach.addListener" exists. 385 func HasFuncOnDetach() bool { 386 return js.True == bindings.HasFuncOnDetach() 387 } 388 389 // FuncOnDetach returns the function "WEBEXT.debugger.onDetach.addListener". 390 func FuncOnDetach() (fn js.Func[func(callback js.Func[func(source *Debuggee, reason DetachReason)])]) { 391 bindings.FuncOnDetach( 392 js.Pointer(&fn), 393 ) 394 return 395 } 396 397 // OnDetach calls the function "WEBEXT.debugger.onDetach.addListener" directly. 398 func OnDetach(callback js.Func[func(source *Debuggee, reason DetachReason)]) (ret js.Void) { 399 bindings.CallOnDetach( 400 js.Pointer(&ret), 401 callback.Ref(), 402 ) 403 404 return 405 } 406 407 // TryOnDetach calls the function "WEBEXT.debugger.onDetach.addListener" 408 // in a try/catch block and returns (_, err, ok = false) when it went through 409 // the catch clause. 410 func TryOnDetach(callback js.Func[func(source *Debuggee, reason DetachReason)]) (ret js.Void, exception js.Any, ok bool) { 411 ok = js.True == bindings.TryOnDetach( 412 js.Pointer(&ret), js.Pointer(&exception), 413 callback.Ref(), 414 ) 415 416 return 417 } 418 419 // HasFuncOffDetach returns true if the function "WEBEXT.debugger.onDetach.removeListener" exists. 420 func HasFuncOffDetach() bool { 421 return js.True == bindings.HasFuncOffDetach() 422 } 423 424 // FuncOffDetach returns the function "WEBEXT.debugger.onDetach.removeListener". 425 func FuncOffDetach() (fn js.Func[func(callback js.Func[func(source *Debuggee, reason DetachReason)])]) { 426 bindings.FuncOffDetach( 427 js.Pointer(&fn), 428 ) 429 return 430 } 431 432 // OffDetach calls the function "WEBEXT.debugger.onDetach.removeListener" directly. 433 func OffDetach(callback js.Func[func(source *Debuggee, reason DetachReason)]) (ret js.Void) { 434 bindings.CallOffDetach( 435 js.Pointer(&ret), 436 callback.Ref(), 437 ) 438 439 return 440 } 441 442 // TryOffDetach calls the function "WEBEXT.debugger.onDetach.removeListener" 443 // in a try/catch block and returns (_, err, ok = false) when it went through 444 // the catch clause. 445 func TryOffDetach(callback js.Func[func(source *Debuggee, reason DetachReason)]) (ret js.Void, exception js.Any, ok bool) { 446 ok = js.True == bindings.TryOffDetach( 447 js.Pointer(&ret), js.Pointer(&exception), 448 callback.Ref(), 449 ) 450 451 return 452 } 453 454 // HasFuncHasOnDetach returns true if the function "WEBEXT.debugger.onDetach.hasListener" exists. 455 func HasFuncHasOnDetach() bool { 456 return js.True == bindings.HasFuncHasOnDetach() 457 } 458 459 // FuncHasOnDetach returns the function "WEBEXT.debugger.onDetach.hasListener". 460 func FuncHasOnDetach() (fn js.Func[func(callback js.Func[func(source *Debuggee, reason DetachReason)]) bool]) { 461 bindings.FuncHasOnDetach( 462 js.Pointer(&fn), 463 ) 464 return 465 } 466 467 // HasOnDetach calls the function "WEBEXT.debugger.onDetach.hasListener" directly. 468 func HasOnDetach(callback js.Func[func(source *Debuggee, reason DetachReason)]) (ret bool) { 469 bindings.CallHasOnDetach( 470 js.Pointer(&ret), 471 callback.Ref(), 472 ) 473 474 return 475 } 476 477 // TryHasOnDetach calls the function "WEBEXT.debugger.onDetach.hasListener" 478 // in a try/catch block and returns (_, err, ok = false) when it went through 479 // the catch clause. 480 func TryHasOnDetach(callback js.Func[func(source *Debuggee, reason DetachReason)]) (ret bool, exception js.Any, ok bool) { 481 ok = js.True == bindings.TryHasOnDetach( 482 js.Pointer(&ret), js.Pointer(&exception), 483 callback.Ref(), 484 ) 485 486 return 487 } 488 489 type OnEventEventCallbackFunc func(this js.Ref, source *Debuggee, method js.String, params js.Any) js.Ref 490 491 func (fn OnEventEventCallbackFunc) Register() js.Func[func(source *Debuggee, method js.String, params js.Any)] { 492 return js.RegisterCallback[func(source *Debuggee, method js.String, params js.Any)]( 493 fn, abi.FuncPCABIInternal(fn), 494 ) 495 } 496 497 func (fn OnEventEventCallbackFunc) DispatchCallback( 498 targetPC uintptr, ctx *js.CallbackContext, 499 ) { 500 args := ctx.Args() 501 if len(args) != 3+1 /* js this */ || 502 targetPC != uintptr(abi.FuncPCABIInternal(fn)) { 503 js.ThrowInvalidCallbackInvocation() 504 } 505 var arg0 Debuggee 506 arg0.UpdateFrom(args[0+1]) 507 defer arg0.FreeMembers(true) 508 509 if ctx.Return(fn( 510 args[0], 511 512 mark.NoEscape(&arg0), 513 js.String{}.FromRef(args[1+1]), 514 js.Any{}.FromRef(args[2+1]), 515 )) { 516 return 517 } 518 519 js.ThrowCallbackValueNotReturned() 520 } 521 522 type OnEventEventCallback[T any] struct { 523 Fn func(arg T, this js.Ref, source *Debuggee, method js.String, params js.Any) js.Ref 524 Arg T 525 } 526 527 func (cb *OnEventEventCallback[T]) Register() js.Func[func(source *Debuggee, method js.String, params js.Any)] { 528 return js.RegisterCallback[func(source *Debuggee, method js.String, params js.Any)]( 529 cb, abi.FuncPCABIInternal(cb.Fn), 530 ) 531 } 532 533 func (cb *OnEventEventCallback[T]) DispatchCallback( 534 targetPC uintptr, ctx *js.CallbackContext, 535 ) { 536 args := ctx.Args() 537 if len(args) != 3+1 /* js this */ || 538 targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) { 539 js.ThrowInvalidCallbackInvocation() 540 } 541 var arg0 Debuggee 542 arg0.UpdateFrom(args[0+1]) 543 defer arg0.FreeMembers(true) 544 545 if ctx.Return(cb.Fn( 546 cb.Arg, 547 args[0], 548 549 mark.NoEscape(&arg0), 550 js.String{}.FromRef(args[1+1]), 551 js.Any{}.FromRef(args[2+1]), 552 )) { 553 return 554 } 555 556 js.ThrowCallbackValueNotReturned() 557 } 558 559 // HasFuncOnEvent returns true if the function "WEBEXT.debugger.onEvent.addListener" exists. 560 func HasFuncOnEvent() bool { 561 return js.True == bindings.HasFuncOnEvent() 562 } 563 564 // FuncOnEvent returns the function "WEBEXT.debugger.onEvent.addListener". 565 func FuncOnEvent() (fn js.Func[func(callback js.Func[func(source *Debuggee, method js.String, params js.Any)])]) { 566 bindings.FuncOnEvent( 567 js.Pointer(&fn), 568 ) 569 return 570 } 571 572 // OnEvent calls the function "WEBEXT.debugger.onEvent.addListener" directly. 573 func OnEvent(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) (ret js.Void) { 574 bindings.CallOnEvent( 575 js.Pointer(&ret), 576 callback.Ref(), 577 ) 578 579 return 580 } 581 582 // TryOnEvent calls the function "WEBEXT.debugger.onEvent.addListener" 583 // in a try/catch block and returns (_, err, ok = false) when it went through 584 // the catch clause. 585 func TryOnEvent(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) (ret js.Void, exception js.Any, ok bool) { 586 ok = js.True == bindings.TryOnEvent( 587 js.Pointer(&ret), js.Pointer(&exception), 588 callback.Ref(), 589 ) 590 591 return 592 } 593 594 // HasFuncOffEvent returns true if the function "WEBEXT.debugger.onEvent.removeListener" exists. 595 func HasFuncOffEvent() bool { 596 return js.True == bindings.HasFuncOffEvent() 597 } 598 599 // FuncOffEvent returns the function "WEBEXT.debugger.onEvent.removeListener". 600 func FuncOffEvent() (fn js.Func[func(callback js.Func[func(source *Debuggee, method js.String, params js.Any)])]) { 601 bindings.FuncOffEvent( 602 js.Pointer(&fn), 603 ) 604 return 605 } 606 607 // OffEvent calls the function "WEBEXT.debugger.onEvent.removeListener" directly. 608 func OffEvent(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) (ret js.Void) { 609 bindings.CallOffEvent( 610 js.Pointer(&ret), 611 callback.Ref(), 612 ) 613 614 return 615 } 616 617 // TryOffEvent calls the function "WEBEXT.debugger.onEvent.removeListener" 618 // in a try/catch block and returns (_, err, ok = false) when it went through 619 // the catch clause. 620 func TryOffEvent(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) (ret js.Void, exception js.Any, ok bool) { 621 ok = js.True == bindings.TryOffEvent( 622 js.Pointer(&ret), js.Pointer(&exception), 623 callback.Ref(), 624 ) 625 626 return 627 } 628 629 // HasFuncHasOnEvent returns true if the function "WEBEXT.debugger.onEvent.hasListener" exists. 630 func HasFuncHasOnEvent() bool { 631 return js.True == bindings.HasFuncHasOnEvent() 632 } 633 634 // FuncHasOnEvent returns the function "WEBEXT.debugger.onEvent.hasListener". 635 func FuncHasOnEvent() (fn js.Func[func(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) bool]) { 636 bindings.FuncHasOnEvent( 637 js.Pointer(&fn), 638 ) 639 return 640 } 641 642 // HasOnEvent calls the function "WEBEXT.debugger.onEvent.hasListener" directly. 643 func HasOnEvent(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) (ret bool) { 644 bindings.CallHasOnEvent( 645 js.Pointer(&ret), 646 callback.Ref(), 647 ) 648 649 return 650 } 651 652 // TryHasOnEvent calls the function "WEBEXT.debugger.onEvent.hasListener" 653 // in a try/catch block and returns (_, err, ok = false) when it went through 654 // the catch clause. 655 func TryHasOnEvent(callback js.Func[func(source *Debuggee, method js.String, params js.Any)]) (ret bool, exception js.Any, ok bool) { 656 ok = js.True == bindings.TryHasOnEvent( 657 js.Pointer(&ret), js.Pointer(&exception), 658 callback.Ref(), 659 ) 660 661 return 662 } 663 664 // HasFuncSendCommand returns true if the function "WEBEXT.debugger.sendCommand" exists. 665 func HasFuncSendCommand() bool { 666 return js.True == bindings.HasFuncSendCommand() 667 } 668 669 // FuncSendCommand returns the function "WEBEXT.debugger.sendCommand". 670 func FuncSendCommand() (fn js.Func[func(target Debuggee, method js.String, commandParams js.Any) js.Promise[js.Any]]) { 671 bindings.FuncSendCommand( 672 js.Pointer(&fn), 673 ) 674 return 675 } 676 677 // SendCommand calls the function "WEBEXT.debugger.sendCommand" directly. 678 func SendCommand(target Debuggee, method js.String, commandParams js.Any) (ret js.Promise[js.Any]) { 679 bindings.CallSendCommand( 680 js.Pointer(&ret), 681 js.Pointer(&target), 682 method.Ref(), 683 commandParams.Ref(), 684 ) 685 686 return 687 } 688 689 // TrySendCommand calls the function "WEBEXT.debugger.sendCommand" 690 // in a try/catch block and returns (_, err, ok = false) when it went through 691 // the catch clause. 692 func TrySendCommand(target Debuggee, method js.String, commandParams js.Any) (ret js.Promise[js.Any], exception js.Any, ok bool) { 693 ok = js.True == bindings.TrySendCommand( 694 js.Pointer(&ret), js.Pointer(&exception), 695 js.Pointer(&target), 696 method.Ref(), 697 commandParams.Ref(), 698 ) 699 700 return 701 }