github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/appviewguestinternal/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package appviewguestinternal 5 6 import ( 7 "github.com/primecitizens/pcz/std/ffi/js" 8 "github.com/primecitizens/pcz/std/plat/js/webext/appviewguestinternal/bindings" 9 ) 10 11 // HasFuncAttachFrame returns true if the function "WEBEXT.appViewGuestInternal.attachFrame" exists. 12 func HasFuncAttachFrame() bool { 13 return js.True == bindings.HasFuncAttachFrame() 14 } 15 16 // FuncAttachFrame returns the function "WEBEXT.appViewGuestInternal.attachFrame". 17 func FuncAttachFrame() (fn js.Func[func(url js.String, guestInstanceId int64) js.Promise[js.BigInt[int64]]]) { 18 bindings.FuncAttachFrame( 19 js.Pointer(&fn), 20 ) 21 return 22 } 23 24 // AttachFrame calls the function "WEBEXT.appViewGuestInternal.attachFrame" directly. 25 func AttachFrame(url js.String, guestInstanceId int64) (ret js.Promise[js.BigInt[int64]]) { 26 bindings.CallAttachFrame( 27 js.Pointer(&ret), 28 url.Ref(), 29 float64(guestInstanceId), 30 ) 31 32 return 33 } 34 35 // TryAttachFrame calls the function "WEBEXT.appViewGuestInternal.attachFrame" 36 // in a try/catch block and returns (_, err, ok = false) when it went through 37 // the catch clause. 38 func TryAttachFrame(url js.String, guestInstanceId int64) (ret js.Promise[js.BigInt[int64]], exception js.Any, ok bool) { 39 ok = js.True == bindings.TryAttachFrame( 40 js.Pointer(&ret), js.Pointer(&exception), 41 url.Ref(), 42 float64(guestInstanceId), 43 ) 44 45 return 46 } 47 48 // HasFuncDenyRequest returns true if the function "WEBEXT.appViewGuestInternal.denyRequest" exists. 49 func HasFuncDenyRequest() bool { 50 return js.True == bindings.HasFuncDenyRequest() 51 } 52 53 // FuncDenyRequest returns the function "WEBEXT.appViewGuestInternal.denyRequest". 54 func FuncDenyRequest() (fn js.Func[func(guestInstanceId int64)]) { 55 bindings.FuncDenyRequest( 56 js.Pointer(&fn), 57 ) 58 return 59 } 60 61 // DenyRequest calls the function "WEBEXT.appViewGuestInternal.denyRequest" directly. 62 func DenyRequest(guestInstanceId int64) (ret js.Void) { 63 bindings.CallDenyRequest( 64 js.Pointer(&ret), 65 float64(guestInstanceId), 66 ) 67 68 return 69 } 70 71 // TryDenyRequest calls the function "WEBEXT.appViewGuestInternal.denyRequest" 72 // in a try/catch block and returns (_, err, ok = false) when it went through 73 // the catch clause. 74 func TryDenyRequest(guestInstanceId int64) (ret js.Void, exception js.Any, ok bool) { 75 ok = js.True == bindings.TryDenyRequest( 76 js.Pointer(&ret), js.Pointer(&exception), 77 float64(guestInstanceId), 78 ) 79 80 return 81 }