File tree Expand file tree Collapse file tree 2 files changed +11
-17
lines changed
packages/globe_runtime_ts Expand file tree Collapse file tree 2 files changed +11
-17
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,9 @@ declare global {
4242 const Dart : DartGlobal ;
4343
4444 const JsonPayload : {
45+ // Encoding payload using MessagePack
4546 encode ( value : unknown ) : Uint8Array | undefined ;
47+ // Decoding payload using MessagePack
4648 decode ( value : Uint8Array ) : any ;
4749 } ;
4850}
Original file line number Diff line number Diff line change @@ -8,23 +8,6 @@ import * as msgPackr from "ext:js_msg_packr/index.js";
88
99const { core } = Deno ;
1010
11- // Expose the `JsonPayload` interface to the global scope
12- Object . defineProperty ( globalThis , "JsonPayload" , {
13- value : {
14- encode : ( value : unknown ) : Uint8Array | undefined => {
15- if ( value === undefined ) return undefined ;
16- return msgPackr . pack ( value ) ;
17- } ,
18- decode : ( value : Uint8Array | undefined ) : any => {
19- if ( value === undefined ) return undefined ;
20- return msgPackr . unpack ( value ) ;
21- } ,
22- } ,
23- enumerable : false ,
24- writable : true ,
25- configurable : true ,
26- } ) ;
27-
2811function register_js_module ( moduleName : string , moduleFunctions ) {
2912 if ( globalThis [ moduleName ] ) {
3013 throw new Error ( `Module "${ moduleName } " is already registered.` ) ;
@@ -81,3 +64,12 @@ register_js_module("Dart", {
8164 return _dartJSService . SendValue ( { callbackId, message } ) ;
8265 } ,
8366} ) ;
67+
68+ register_js_module ( "JsonPayload" , {
69+ encode : ( value : unknown ) : Uint8Array => {
70+ return msgPackr . pack ( value ) ;
71+ } ,
72+ decode : ( value : Uint8Array ) : any => {
73+ return msgPackr . unpack ( value ) ;
74+ } ,
75+ } ) ;
You can’t perform that action at this time.
0 commit comments