github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/webaccessibleresourcesmv2/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package webaccessibleresourcesmv2 5 6 import ( 7 "github.com/primecitizens/pcz/std/ffi/js" 8 "github.com/primecitizens/pcz/std/plat/js/webext/webaccessibleresourcesmv2/bindings" 9 ) 10 11 type ManifestKeys struct { 12 // WebAccessibleResources is "ManifestKeys.web_accessible_resources" 13 // 14 // Optional 15 WebAccessibleResources js.Array[js.String] 16 17 FFI_USE bool 18 } 19 20 // FromRef calls UpdateFrom and returns a ManifestKeys with all fields set. 21 func (p ManifestKeys) FromRef(ref js.Ref) ManifestKeys { 22 p.UpdateFrom(ref) 23 return p 24 } 25 26 // New creates a new ManifestKeys in the application heap. 27 func (p ManifestKeys) New() js.Ref { 28 return bindings.ManifestKeysJSLoad( 29 js.Pointer(&p), js.True, 0, 30 ) 31 } 32 33 // UpdateFrom copies value of all fields of the heap object to p. 34 func (p *ManifestKeys) UpdateFrom(ref js.Ref) { 35 bindings.ManifestKeysJSStore( 36 js.Pointer(p), ref, 37 ) 38 } 39 40 // Update writes all fields of the p to the heap object referenced by ref. 41 func (p *ManifestKeys) Update(ref js.Ref) { 42 bindings.ManifestKeysJSLoad( 43 js.Pointer(p), js.False, ref, 44 ) 45 } 46 47 // FreeMembers frees fields with heap reference, if recursive is true 48 // free all heap references reachable from p. 49 func (p *ManifestKeys) FreeMembers(recursive bool) { 50 js.Free( 51 p.WebAccessibleResources.Ref(), 52 ) 53 p.WebAccessibleResources = p.WebAccessibleResources.FromRef(js.Undefined) 54 }