@remix_labs/machine-starter 2.2241.0-dev → 2.2246.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
@@ -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 mixcoreLocalFFIs(mixcore, names) {
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
- let channel = await hub.newChannel();
73
- // injected by either index.js or node.js
74
- let worker = globalThis.GetMachineWASMWorker();
75
- workers[config.vmID] = worker;
76
- let mixcore = null;
77
- let localFFIs = config.localFFIs || {};
78
- if (config.mixcore && config.mixcore.kind == 'mixcore') {
79
- let enableFFIs, disableFFIs;
80
- ({mixcore, enableFFIs, disableFFIs} = config.mixcore);
81
- let ffiNames = filterFFINames(await mixcore.ffiNames(), enableFFIs, disableFFIs);
82
- console.log("Mixcore (starter)", mixcore, ffiNames, mixcore.registerDebugObject);
83
- localFFIs = {...localFFIs, ...mixcoreLocalFFIs(mixcore, ffiNames)};
84
- config.mixcore = {};
85
- if (mixcore.registerDebugObject) {
86
- config.mixcore.publishDebugObjects = true;
87
- subscribeDebugObjects(mixcore, hub, config);
88
- }
89
- }
90
- let localFFIkind = {};
91
- let localFFIfuns = {};
92
- for (const [k, v] of Object.entries(localFFIs)) {
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
- let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
102
- localFFIkind["$vm_start"] = vm_kind;
103
- localFFIfuns["$vm_start"] = ffi_vm_start;
104
- localFFIkind["$vm_stop"] = vm_kind;
105
- localFFIfuns["$vm_stop"] = ffi_vm_stop;
106
- let config_msg =
107
- { "_rmx_type": "msg_vm_configure",
108
- "baseURL": config.baseURL,
109
- "org": config.org,
110
- "workspace": config.workspace,
111
- "vmID": config.vmID,
112
- "user": config.user,
113
- "token": config.token,
114
- "hub": channel.port,
115
- "outputViaMQTT": !(config.noOutputViaMQTT),
116
- "machType": config.machType,
117
- "debugMask": initialMask,
118
- "localFFIs": localFFIkind,
119
- "allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
120
- "interceptFFI": config.interceptFFI,
121
- "interceptDynloadFFI": config.interceptDynloadFFI,
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) throw new Error("no such local FFI: " + name);
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;
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "2419";
1
+ var GROOVEBOX_BUILD = "2423";
2
2
  export { GROOVEBOX_BUILD }