@remix_labs/machine-starter 2.2224.0-dev → 2.2226.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 +46 -80
- package/groovebox_build.js +1 -1
- package/machine-wasm.worker.js +1 -1
- package/package.json +2 -2
- package/start.js +33 -50
package/common.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GROOVEBOX_BUILD } from "./groovebox_build.js";
|
|
2
|
-
import { filterFFINames } from "./mixcore-common.js";
|
|
3
2
|
import { nanoid } from "nanoid";
|
|
4
3
|
|
|
5
4
|
let workers = {};
|
|
@@ -57,73 +56,52 @@ function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaM
|
|
|
57
56
|
})
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
function
|
|
61
|
-
return Object.fromEntries(
|
|
62
|
-
names.map(name => [name, {
|
|
63
|
-
isRaw: true,
|
|
64
|
-
run: (conn, argsBuf) => mixcore.ffiDispatch(conn.call_id, name, argsBuf),
|
|
65
|
-
}]));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// See `mix-rs/mixcore/README.md` for a description of the values of
|
|
69
|
-
// config.mixcore.
|
|
70
|
-
async function StartWASM2(hub, config) {
|
|
59
|
+
function StartWASM2(hub, config) {
|
|
71
60
|
console.log("GROOVEBOX_BUILD (machine-starter)", GROOVEBOX_BUILD);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
localFFIfuns[k] = {...v};
|
|
94
|
-
if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
|
|
95
|
-
console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
|
|
96
|
-
} else {
|
|
97
|
-
localFFIkind[k] = {...v};
|
|
98
|
-
delete localFFIkind[k].run;
|
|
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 localFFIkind = {};
|
|
66
|
+
let localFFIfuns = {};
|
|
67
|
+
if (config.localFFIs) {
|
|
68
|
+
for (const [k, v] of Object.entries(config.localFFIs)) {
|
|
69
|
+
localFFIfuns[k] = {...v};
|
|
70
|
+
if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
|
|
71
|
+
console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
|
|
72
|
+
} else {
|
|
73
|
+
localFFIkind[k] = {...v};
|
|
74
|
+
delete localFFIkind[k].run;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
|
|
78
|
+
localFFIkind["$vm_start"] = vm_kind;
|
|
79
|
+
localFFIfuns["$vm_start"] = ffi_vm_start;
|
|
80
|
+
localFFIkind["$vm_stop"] = vm_kind;
|
|
81
|
+
localFFIfuns["$vm_stop"] = ffi_vm_stop;
|
|
99
82
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"mixcore": config.mixcore,
|
|
123
|
-
};
|
|
124
|
-
worker.postMessage(config_msg, [ channel.port ]);
|
|
125
|
-
setupLocalFFIs(hub, config, localFFIfuns); // don't await!
|
|
126
|
-
return worker;
|
|
83
|
+
let config_msg =
|
|
84
|
+
{ "_rmx_type": "msg_vm_configure",
|
|
85
|
+
"baseURL": config.baseURL,
|
|
86
|
+
"org": config.org,
|
|
87
|
+
"workspace": config.workspace,
|
|
88
|
+
"vmID": config.vmID,
|
|
89
|
+
"user": config.user,
|
|
90
|
+
"token": config.token,
|
|
91
|
+
"hub": channel.port,
|
|
92
|
+
"outputViaMQTT": !(config.noOutputViaMQTT),
|
|
93
|
+
"machType": config.machType,
|
|
94
|
+
"debugMask": initialMask,
|
|
95
|
+
"localFFIs": localFFIkind,
|
|
96
|
+
"allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
|
|
97
|
+
"interceptFFI": config.interceptFFI,
|
|
98
|
+
"interceptDynloadFFI": config.interceptDynloadFFI,
|
|
99
|
+
};
|
|
100
|
+
worker.postMessage(config_msg, [ channel.port ]);
|
|
101
|
+
if (config.localFFIs)
|
|
102
|
+
setupLocalFFIs(hub, config, localFFIfuns); // don't await!
|
|
103
|
+
return worker;
|
|
104
|
+
})
|
|
127
105
|
}
|
|
128
106
|
|
|
129
107
|
async function ffi_vm_start(conn, args) {
|
|
@@ -282,7 +260,8 @@ async function setupLocalFFIs(hub, config, localFFIs) {
|
|
|
282
260
|
let args = decode(msg.payload.args);
|
|
283
261
|
let fun = localFFIs[name];
|
|
284
262
|
try {
|
|
285
|
-
if (!fun)
|
|
263
|
+
if (!fun)
|
|
264
|
+
throw new Error("no such local FFI: " + name);
|
|
286
265
|
let connector =
|
|
287
266
|
{ call_id: call_id,
|
|
288
267
|
hub: hub,
|
|
@@ -305,19 +284,6 @@ async function setupLocalFFIs(hub, config, localFFIs) {
|
|
|
305
284
|
}
|
|
306
285
|
}
|
|
307
286
|
|
|
308
|
-
async function subscribeDebugObjects(mixcore, hub, config) {
|
|
309
|
-
let channel = await hub.newChannel();
|
|
310
|
-
let vmID = config.vmID;
|
|
311
|
-
await channel.setLocalSubTopic(`/debug-objects/${vmID}`);
|
|
312
|
-
let sub = await channel.subscribe(`/debug-objects/${vmID}`);
|
|
313
|
-
while (true) {
|
|
314
|
-
let msg = await sub.next();
|
|
315
|
-
let id = msg.payload.id;
|
|
316
|
-
let code = msg.payload.code;
|
|
317
|
-
mixcore.registerDebugObject(id, code);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
287
|
class FFIComm {
|
|
322
288
|
constructor(vmID, hub, channel) {
|
|
323
289
|
this.vmID = vmID;
|
package/groovebox_build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var GROOVEBOX_BUILD = "
|
|
1
|
+
var GROOVEBOX_BUILD = "2403";
|
|
2
2
|
export { GROOVEBOX_BUILD }
|