@remix_labs/machine-starter 2.11931.0-dev → 2.11935.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/node.js CHANGED
@@ -5,26 +5,6 @@ globalThis.console = new Console.Console({stdout: process.stderr, stderr: proces
5
5
  // redirect stdout to stderr to avoid that log messages appear in the wrong
6
6
  // order
7
7
 
8
- // NB: The only way I've made this work in node+webpack is if:
9
- //
10
- // * we use Worker from worker_threads directly
11
- // * we build each worker's module with webpack as an ESM .mjs bundle
12
- // * we put all the bundles in one directory
13
- // * we load the worker with a URL('./foo.mjs')
14
- //
15
- // Other ways to package/load might work, but definitely seems like
16
- // using worker_threads.Worker directly is needed (rather than through,
17
- // say, the web-worker packages that wraps either worker_threads.Worker
18
- // or the browser Worker to give the same interface). Webpack says ESM
19
- // is necessary but I'm not sure if this is true for either the main
20
- // script or the workers.
21
- import { Worker } from "worker_threads";
22
-
23
- function GetMachineWASMWorker() {
24
- return new Worker(new URL("./machine-wasm.node.mjs", import.meta.url));
25
- }
26
- globalThis.GetMachineWASMWorker = GetMachineWASMWorker;
27
-
28
8
  // Can't just `export *` because we need hub-client below in common.js
29
9
  import * as Hub from "@remix_labs/hub-client";
30
10
  export { Hub };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix_labs/machine-starter",
3
- "version": "2.11931.0-dev",
3
+ "version": "2.11935.0-dev",
4
4
  "description": "start the groove",
5
5
  "main": "node.js",
6
6
  "browser": "index.js",
@@ -11,7 +11,7 @@
11
11
  "author": "Remixlabs staff",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@remix_labs/hub-client": "2.11931.0-dev",
14
+ "@remix_labs/hub-client": "2.11935.0-dev",
15
15
  "nanoid": "^5.0.2",
16
16
  "web-worker": "^1.2.0"
17
17
  },
package/start.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import Process from "process";
2
+ import { Worker } from "worker_threads";
2
3
  import { StartWASM2, Hub } from "./node.js";
3
4
  import { mixcoreWasmBase64, mixcoreJsBase64 } from './mixcore-wasm-inmem.js';
5
+ import MachineWASMWorkerString from './machine-wasm.worker.mjs'
4
6
 
5
7
  if (Process.stdout._handle)
6
8
  Process.stdout._handle.setBlocking(true);
@@ -48,6 +50,25 @@ let mixcore = {
48
50
  dbName: "compiler-testing",
49
51
  createDbs: ["compiler-testing"],
50
52
  };
53
+
54
+ // comment from start.js (before https://github.com/remixlabs/mix-rs/pull/1129):
55
+ //
56
+ // NB: The only way I've made this work in node+webpack is if:
57
+ //
58
+ // * we use Worker from worker_threads directly
59
+ // * we build each worker's module with webpack as an ESM .mjs bundle
60
+ // * we put all the bundles in one directory
61
+ // * we load the worker with a URL('./foo.mjs')
62
+ //
63
+ // Other ways to package/load might work, but definitely seems like
64
+ // using worker_threads.Worker directly is needed (rather than through,
65
+ // say, the web-worker packages that wraps either worker_threads.Worker
66
+ // or the browser Worker to give the same interface). Webpack says ESM
67
+ // is necessary but I'm not sure if this is true for either the main
68
+ // script or the workers.
69
+ let workerUrl = "data:text/javascript," + encodeURIComponent(MachineWASMWorkerString);
70
+ let getMachineWorker = () => new Worker(workerUrl);
71
+
51
72
  w.configure({wsURL: mqttURL, user:mqttUser, token:mqttToken}).then(resp => {
52
73
  if (variant == "BYTE") variant = "QCODE";
53
74
  switch(variant) {
@@ -67,7 +88,7 @@ w.configure({wsURL: mqttURL, user:mqttUser, token:mqttToken}).then(resp => {
67
88
  machType: variant,
68
89
  localFFIs: {},
69
90
  mixcore,
70
- });
91
+ }, getMachineWorker);
71
92
  });
72
93
  if (globalThis.EnableAndStartMixCompiler) {
73
94
  EnableAndStartMixCompiler(w).then(startVM);