@remix_labs/machine-starter 2.2048.0-dev → 2.2050.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common.js CHANGED
@@ -56,55 +56,88 @@ function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaM
56
56
  })
57
57
  }
58
58
 
59
- function StartWASM2(hub, config) {
59
+ // The parameter config.mixcore controls the mixcore integration. it can be one
60
+ // of the following:
61
+ //
62
+ // - {kind: "mixcore", mixcore: Mixcore}: use an already instantiated Mixcore
63
+ // - {kind: "webkit"}: use Webkit backend implemented in
64
+ // `mixcore/bindings/swift/Mixcore.swift` and used in flutter-runtime
65
+ // (AppClipWebview.swift and appclip.html)
66
+ // - {kind: "tauri", dbDir: STRING, dbName: STRING, dbUser: STRING}: use
67
+ // Tauri backend for turntable/remix-desktop, implemented in
68
+ // `mix-rs/mixcore/bindings/tauri/mixcore_tauri.rs`
69
+ // - {kind: "wasm", dbDir: STRING, dbName: STRING, dbUser: STRING, url: STRING}:
70
+ // use the Wasm backend, the `url` can something `fetch`able, or `file://` on
71
+ // node
72
+ // - {kind: "serviceworker", url: STRING, "dbName": STRING, "dbUser": STRING}
73
+ async function StartWASM2(hub, config) {
60
74
  console.log("GROOVEBOX_BUILD (machine-starter)", GROOVEBOX_BUILD);
61
- return hub.newChannel().then(channel => {
62
- // injected by either index.js or node.js
63
- let worker = globalThis.GetMachineWASMWorker();
64
- workers[config.vmID] = worker;
65
- let mixcoreConfig = config.mixcore;
66
- let localFFIs = config.localFFIs;
67
- let localFFIkind = {};
68
- let localFFIfuns = {};
69
- if (localFFIs) {
70
- for (const [k, v] of Object.entries(localFFIs)) {
71
- localFFIfuns[k] = {...v};
72
- if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
73
- console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
74
- } else {
75
- localFFIkind[k] = {...v};
76
- delete localFFIkind[k].run;
77
- }
78
- };
79
- let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
80
- localFFIkind["$vm_start"] = vm_kind;
81
- localFFIfuns["$vm_start"] = ffi_vm_start;
82
- localFFIkind["$vm_stop"] = vm_kind;
83
- localFFIfuns["$vm_stop"] = ffi_vm_stop;
84
- }
85
- let config_msg =
86
- { "_rmx_type": "msg_vm_configure",
87
- "baseURL": config.baseURL,
88
- "org": config.org,
89
- "workspace": config.workspace,
90
- "vmID": config.vmID,
91
- "user": config.user,
92
- "token": config.token,
93
- "hub": channel.port,
94
- "outputViaMQTT": !(config.noOutputViaMQTT),
95
- "machType": config.machType,
96
- "debugMask": initialMask,
97
- "localFFIs": localFFIkind,
98
- "allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
99
- "interceptFFI": config.interceptFFI,
100
- "interceptDynloadFFI": config.interceptDynloadFFI,
101
- "mixcore": mixcoreConfig,
102
- };
103
- worker.postMessage(config_msg, [ channel.port ]);
104
- if (localFFIs)
105
- setupLocalFFIs(hub, config, localFFIfuns); // don't await!
106
- return worker;
107
- })
75
+ let channel = await hub.newChannel();
76
+ // injected by either index.js or node.js
77
+ let worker = globalThis.GetMachineWASMWorker();
78
+ workers[config.vmID] = worker;
79
+ let mixcoreConfig = config.mixcore;
80
+ let localFFIs = config.localFFIs;
81
+ let localFFIkind = {};
82
+ let localFFIfuns = {};
83
+
84
+ console.log("MIXCORE CONFIG", mixcoreConfig);
85
+ if (mixcoreConfig && mixcoreConfig.kind == "mixcore") {
86
+ await mixcoreConfig.mixcore.setHandleFFIs(mixcoreConfig.includes, mixcoreConfig.excludes);
87
+ localFFIs = {...localFFIs, ...mixcore.localFFIs()};
88
+ mixcoreConfig = null;
89
+ }
90
+ if (mixcoreConfig && mixcoreConfig.kind == "wasm-instance") {
91
+ // this is the only mixcore configuration that cannot be to the
92
+ // machine-wasm. the FFIs are registered as localFFIs.
93
+ let mixcore = new MixcoreWasm(
94
+ mixcoreConfig.dbDir,
95
+ mixcoreConfig.dbName,
96
+ mixcoreConfig.username,
97
+ mixcoreConfig.instance);
98
+ await mixcore.setHandleFFIs(mixcoreConfig.includes, mixcoreConfig.excludes);
99
+ localFFIs = {...localFFIs, ...mixcore.localFFIs()};
100
+ mixcoreConfig = null;
101
+ }
102
+
103
+ if (localFFIs) {
104
+ for (const [k, v] of Object.entries(localFFIs)) {
105
+ localFFIfuns[k] = {...v};
106
+ if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
107
+ console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
108
+ } else {
109
+ localFFIkind[k] = {...v};
110
+ delete localFFIkind[k].run;
111
+ }
112
+ };
113
+ let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
114
+ localFFIkind["$vm_start"] = vm_kind;
115
+ localFFIfuns["$vm_start"] = ffi_vm_start;
116
+ localFFIkind["$vm_stop"] = vm_kind;
117
+ localFFIfuns["$vm_stop"] = ffi_vm_stop;
118
+ }
119
+ let config_msg =
120
+ { "_rmx_type": "msg_vm_configure",
121
+ "baseURL": config.baseURL,
122
+ "org": config.org,
123
+ "workspace": config.workspace,
124
+ "vmID": config.vmID,
125
+ "user": config.user,
126
+ "token": config.token,
127
+ "hub": channel.port,
128
+ "outputViaMQTT": !(config.noOutputViaMQTT),
129
+ "machType": config.machType,
130
+ "debugMask": initialMask,
131
+ "localFFIs": localFFIkind,
132
+ "allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
133
+ "interceptFFI": config.interceptFFI,
134
+ "interceptDynloadFFI": config.interceptDynloadFFI,
135
+ "mixcore": mixcoreConfig,
136
+ };
137
+ worker.postMessage(config_msg, [ channel.port ]);
138
+ if (localFFIs)
139
+ setupLocalFFIs(hub, config, localFFIfuns); // don't await!
140
+ return worker;
108
141
  }
109
142
 
110
143
  async function ffi_vm_start(conn, args) {
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "2192";
1
+ var GROOVEBOX_BUILD = "2194";
2
2
  export { GROOVEBOX_BUILD }