github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/crossoriginisolation/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package crossoriginisolation 5 6 import ( 7 "github.com/primecitizens/pcz/std/ffi/js" 8 "github.com/primecitizens/pcz/std/plat/js/webext/crossoriginisolation/bindings" 9 ) 10 11 type ResponseHeader struct { 12 // Value is "ResponseHeader.value" 13 // 14 // Optional 15 Value js.String 16 17 FFI_USE bool 18 } 19 20 // FromRef calls UpdateFrom and returns a ResponseHeader with all fields set. 21 func (p ResponseHeader) FromRef(ref js.Ref) ResponseHeader { 22 p.UpdateFrom(ref) 23 return p 24 } 25 26 // New creates a new ResponseHeader in the application heap. 27 func (p ResponseHeader) New() js.Ref { 28 return bindings.ResponseHeaderJSLoad( 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 *ResponseHeader) UpdateFrom(ref js.Ref) { 35 bindings.ResponseHeaderJSStore( 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 *ResponseHeader) Update(ref js.Ref) { 42 bindings.ResponseHeaderJSLoad( 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 *ResponseHeader) FreeMembers(recursive bool) { 50 js.Free( 51 p.Value.Ref(), 52 ) 53 p.Value = p.Value.FromRef(js.Undefined) 54 } 55 56 type ManifestKeys struct { 57 // CrossOriginEmbedderPolicy is "ManifestKeys.cross_origin_embedder_policy" 58 // 59 // Optional 60 // 61 // NOTE: CrossOriginEmbedderPolicy.FFI_USE MUST be set to true to get CrossOriginEmbedderPolicy used. 62 CrossOriginEmbedderPolicy ResponseHeader 63 // CrossOriginOpenerPolicy is "ManifestKeys.cross_origin_opener_policy" 64 // 65 // Optional 66 // 67 // NOTE: CrossOriginOpenerPolicy.FFI_USE MUST be set to true to get CrossOriginOpenerPolicy used. 68 CrossOriginOpenerPolicy ResponseHeader 69 70 FFI_USE bool 71 } 72 73 // FromRef calls UpdateFrom and returns a ManifestKeys with all fields set. 74 func (p ManifestKeys) FromRef(ref js.Ref) ManifestKeys { 75 p.UpdateFrom(ref) 76 return p 77 } 78 79 // New creates a new ManifestKeys in the application heap. 80 func (p ManifestKeys) New() js.Ref { 81 return bindings.ManifestKeysJSLoad( 82 js.Pointer(&p), js.True, 0, 83 ) 84 } 85 86 // UpdateFrom copies value of all fields of the heap object to p. 87 func (p *ManifestKeys) UpdateFrom(ref js.Ref) { 88 bindings.ManifestKeysJSStore( 89 js.Pointer(p), ref, 90 ) 91 } 92 93 // Update writes all fields of the p to the heap object referenced by ref. 94 func (p *ManifestKeys) Update(ref js.Ref) { 95 bindings.ManifestKeysJSLoad( 96 js.Pointer(p), js.False, ref, 97 ) 98 } 99 100 // FreeMembers frees fields with heap reference, if recursive is true 101 // free all heap references reachable from p. 102 func (p *ManifestKeys) FreeMembers(recursive bool) { 103 if recursive { 104 p.CrossOriginEmbedderPolicy.FreeMembers(true) 105 p.CrossOriginOpenerPolicy.FreeMembers(true) 106 } 107 }