github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/dashboardprivate/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package dashboardprivate 5 6 import ( 7 "github.com/primecitizens/pcz/std/ffi/js" 8 "github.com/primecitizens/pcz/std/plat/js/webext/dashboardprivate/bindings" 9 ) 10 11 type Result uint32 12 13 const ( 14 _ Result = iota 15 16 Result_ 17 Result_UNKNOWN_ERROR 18 Result_USER_CANCELLED 19 Result_INVALID_ID 20 Result_MANIFEST_ERROR 21 Result_ICON_ERROR 22 Result_INVALID_ICON_URL 23 ) 24 25 func (Result) FromRef(str js.Ref) Result { 26 return Result(bindings.ConstOfResult(str)) 27 } 28 29 func (x Result) String() (string, bool) { 30 switch x { 31 case Result_: 32 return "", true 33 case Result_UNKNOWN_ERROR: 34 return "unknown_error", true 35 case Result_USER_CANCELLED: 36 return "user_cancelled", true 37 case Result_INVALID_ID: 38 return "invalid_id", true 39 case Result_MANIFEST_ERROR: 40 return "manifest_error", true 41 case Result_ICON_ERROR: 42 return "icon_error", true 43 case Result_INVALID_ICON_URL: 44 return "invalid_icon_url", true 45 default: 46 return "", false 47 } 48 } 49 50 type ShowPermissionPromptForDelegatedInstallArgDetails struct { 51 // DelegatedUser is "ShowPermissionPromptForDelegatedInstallArgDetails.delegatedUser" 52 // 53 // Required 54 DelegatedUser js.String 55 // IconUrl is "ShowPermissionPromptForDelegatedInstallArgDetails.iconUrl" 56 // 57 // Optional 58 IconUrl js.String 59 // Id is "ShowPermissionPromptForDelegatedInstallArgDetails.id" 60 // 61 // Required 62 Id js.String 63 // LocalizedName is "ShowPermissionPromptForDelegatedInstallArgDetails.localizedName" 64 // 65 // Optional 66 LocalizedName js.String 67 // Manifest is "ShowPermissionPromptForDelegatedInstallArgDetails.manifest" 68 // 69 // Required 70 Manifest js.String 71 72 FFI_USE bool 73 } 74 75 // FromRef calls UpdateFrom and returns a ShowPermissionPromptForDelegatedInstallArgDetails with all fields set. 76 func (p ShowPermissionPromptForDelegatedInstallArgDetails) FromRef(ref js.Ref) ShowPermissionPromptForDelegatedInstallArgDetails { 77 p.UpdateFrom(ref) 78 return p 79 } 80 81 // New creates a new ShowPermissionPromptForDelegatedInstallArgDetails in the application heap. 82 func (p ShowPermissionPromptForDelegatedInstallArgDetails) New() js.Ref { 83 return bindings.ShowPermissionPromptForDelegatedInstallArgDetailsJSLoad( 84 js.Pointer(&p), js.True, 0, 85 ) 86 } 87 88 // UpdateFrom copies value of all fields of the heap object to p. 89 func (p *ShowPermissionPromptForDelegatedInstallArgDetails) UpdateFrom(ref js.Ref) { 90 bindings.ShowPermissionPromptForDelegatedInstallArgDetailsJSStore( 91 js.Pointer(p), ref, 92 ) 93 } 94 95 // Update writes all fields of the p to the heap object referenced by ref. 96 func (p *ShowPermissionPromptForDelegatedInstallArgDetails) Update(ref js.Ref) { 97 bindings.ShowPermissionPromptForDelegatedInstallArgDetailsJSLoad( 98 js.Pointer(p), js.False, ref, 99 ) 100 } 101 102 // FreeMembers frees fields with heap reference, if recursive is true 103 // free all heap references reachable from p. 104 func (p *ShowPermissionPromptForDelegatedInstallArgDetails) FreeMembers(recursive bool) { 105 js.Free( 106 p.DelegatedUser.Ref(), 107 p.IconUrl.Ref(), 108 p.Id.Ref(), 109 p.LocalizedName.Ref(), 110 p.Manifest.Ref(), 111 ) 112 p.DelegatedUser = p.DelegatedUser.FromRef(js.Undefined) 113 p.IconUrl = p.IconUrl.FromRef(js.Undefined) 114 p.Id = p.Id.FromRef(js.Undefined) 115 p.LocalizedName = p.LocalizedName.FromRef(js.Undefined) 116 p.Manifest = p.Manifest.FromRef(js.Undefined) 117 } 118 119 // HasFuncShowPermissionPromptForDelegatedInstall returns true if the function "WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall" exists. 120 func HasFuncShowPermissionPromptForDelegatedInstall() bool { 121 return js.True == bindings.HasFuncShowPermissionPromptForDelegatedInstall() 122 } 123 124 // FuncShowPermissionPromptForDelegatedInstall returns the function "WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall". 125 func FuncShowPermissionPromptForDelegatedInstall() (fn js.Func[func(details ShowPermissionPromptForDelegatedInstallArgDetails) js.Promise[Result]]) { 126 bindings.FuncShowPermissionPromptForDelegatedInstall( 127 js.Pointer(&fn), 128 ) 129 return 130 } 131 132 // ShowPermissionPromptForDelegatedInstall calls the function "WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall" directly. 133 func ShowPermissionPromptForDelegatedInstall(details ShowPermissionPromptForDelegatedInstallArgDetails) (ret js.Promise[Result]) { 134 bindings.CallShowPermissionPromptForDelegatedInstall( 135 js.Pointer(&ret), 136 js.Pointer(&details), 137 ) 138 139 return 140 } 141 142 // TryShowPermissionPromptForDelegatedInstall calls the function "WEBEXT.dashboardPrivate.showPermissionPromptForDelegatedInstall" 143 // in a try/catch block and returns (_, err, ok = false) when it went through 144 // the catch clause. 145 func TryShowPermissionPromptForDelegatedInstall(details ShowPermissionPromptForDelegatedInstallArgDetails) (ret js.Promise[Result], exception js.Any, ok bool) { 146 ok = js.True == bindings.TryShowPermissionPromptForDelegatedInstall( 147 js.Pointer(&ret), js.Pointer(&exception), 148 js.Pointer(&details), 149 ) 150 151 return 152 }