@remix_labs/machine-starter 2.2187.0-dev → 2.2192.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 +66 -45
- package/groovebox_build.js +1 -1
- package/machine-wasm.worker.js +1 -1
- package/mixcore-common.js +38 -0
- package/package.json +2 -2
- package/start.js +15 -0
package/common.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GROOVEBOX_BUILD } from "./groovebox_build.js";
|
|
2
|
+
import { mixcoreFFIs } from "./mixcore-common.js";
|
|
2
3
|
import { nanoid } from "nanoid";
|
|
3
4
|
|
|
4
5
|
let workers = {};
|
|
@@ -56,52 +57,72 @@ function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaM
|
|
|
56
57
|
})
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function
|
|
60
|
+
function makeLocalFFIs(mixcore, names) {
|
|
61
|
+
console.log("Mixcore FFIs (local)", names);
|
|
62
|
+
return Object.fromEntries(
|
|
63
|
+
names.map(name => [name, {
|
|
64
|
+
isRaw: true,
|
|
65
|
+
run: (conn, argsBuf) => mixcore.ffiDispatch(conn.call_id, name, argsBuf),
|
|
66
|
+
}]));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// See `mix-rs/mixcore/bindings/javascript/mixcore.js` for a description of the
|
|
70
|
+
// values of config.mixcore.
|
|
71
|
+
async function StartWASM2(hub, config) {
|
|
60
72
|
console.log("GROOVEBOX_BUILD (machine-starter)", GROOVEBOX_BUILD);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
73
|
+
let channel = await hub.newChannel();
|
|
74
|
+
// injected by either index.js or node.js
|
|
75
|
+
let worker = globalThis.GetMachineWASMWorker();
|
|
76
|
+
workers[config.vmID] = worker;
|
|
77
|
+
let localFFIs = config.localFFIs || {};
|
|
78
|
+
if (config.mixcore && config.mixcore.kind == 'mixcore') {
|
|
79
|
+
let {mixcore, enableFFIs, disableFFIs} = config.mixcore;
|
|
80
|
+
let ffiNames = await mixcoreFFIs(mixcore, enableFFIs, disableFFIs);
|
|
81
|
+
let ffis = makeLocalFFIs(mixcore, ffiNames);
|
|
82
|
+
localFFIs = {...localFFIs, ...ffis};
|
|
83
|
+
config.mixcore = null;
|
|
84
|
+
}
|
|
85
|
+
let localFFIkind = {};
|
|
86
|
+
let localFFIfuns = {};
|
|
87
|
+
if (localFFIs) {
|
|
88
|
+
for (const [k, v] of Object.entries(localFFIs)) {
|
|
89
|
+
console.log("local FFI", k, v);
|
|
90
|
+
localFFIfuns[k] = {...v};
|
|
91
|
+
if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
|
|
92
|
+
console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
|
|
93
|
+
} else {
|
|
94
|
+
localFFIkind[k] = {...v};
|
|
95
|
+
delete localFFIkind[k].run;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
|
|
99
|
+
localFFIkind["$vm_start"] = vm_kind;
|
|
100
|
+
localFFIfuns["$vm_start"] = ffi_vm_start;
|
|
101
|
+
localFFIkind["$vm_stop"] = vm_kind;
|
|
102
|
+
localFFIfuns["$vm_stop"] = ffi_vm_stop;
|
|
103
|
+
}
|
|
104
|
+
let config_msg =
|
|
105
|
+
{ "_rmx_type": "msg_vm_configure",
|
|
106
|
+
"baseURL": config.baseURL,
|
|
107
|
+
"org": config.org,
|
|
108
|
+
"workspace": config.workspace,
|
|
109
|
+
"vmID": config.vmID,
|
|
110
|
+
"user": config.user,
|
|
111
|
+
"token": config.token,
|
|
112
|
+
"hub": channel.port,
|
|
113
|
+
"outputViaMQTT": !(config.noOutputViaMQTT),
|
|
114
|
+
"machType": config.machType,
|
|
115
|
+
"debugMask": initialMask,
|
|
116
|
+
"localFFIs": localFFIkind,
|
|
117
|
+
"allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
|
|
118
|
+
"interceptFFI": config.interceptFFI,
|
|
119
|
+
"interceptDynloadFFI": config.interceptDynloadFFI,
|
|
120
|
+
"mixcore": config.mixcore,
|
|
121
|
+
};
|
|
122
|
+
worker.postMessage(config_msg, [ channel.port ]);
|
|
123
|
+
if (localFFIs)
|
|
124
|
+
setupLocalFFIs(hub, config, localFFIfuns); // don't await!
|
|
125
|
+
return worker;
|
|
105
126
|
}
|
|
106
127
|
|
|
107
128
|
async function ffi_vm_start(conn, args) {
|
package/groovebox_build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var GROOVEBOX_BUILD = "
|
|
1
|
+
var GROOVEBOX_BUILD = "2364";
|
|
2
2
|
export { GROOVEBOX_BUILD }
|