@remix_labs/machine-starter 1.1874.0-dev → 1.1880.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.
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "1874";
1
+ var GROOVEBOX_BUILD = "1880";
2
2
  export { GROOVEBOX_BUILD }
package/index.js CHANGED
@@ -36,20 +36,27 @@ function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaM
36
36
  function StartWASM2(hub, config) {
37
37
  console.log("GROOVEBOX_BUILD (machine-starter)", GROOVEBOX_BUILD);
38
38
  return hub.newChannel().then(channel => {
39
- let bundle;
39
+ let worker;
40
40
  if (globalThis.ThisIsNode) {
41
- bundle = new URL("../../machine-wasm/dist/node-bundle.js", import.meta.url);
42
- } else if (globalThis.GROOVEBOX_URL_PREFIX) {
43
- // FIXME: Stopgap solution until we figure out a way to bundle groovebox correctly
44
- // already fire off the download of the wasm code:
45
- let code_url = new URL(`${globalThis.GROOVEBOX_URL_PREFIX}/machine-wasm-code.wasm`, window.location.href);
46
- fetch(code_url, {cache:"default"}).then(resp => { return resp.arrayBuffer() });
47
- bundle = new URL(`${globalThis.GROOVEBOX_URL_PREFIX}/machine-wasm-core.js`, window.location.href);
41
+ console.log("loading node bundle")
42
+ //bundle = new URL("file:///Users/verm/remix/harmony/components/groovebox/machine-wasm/dist/node-bundle.js");
43
+ worker = globalThis.getMachineWasmWorker();
48
44
  } else {
49
- // already fire off the download of the wasm code:
50
- let code_url = new URL("/g/machine-wasm-code.wasm", window.location.href);
51
- fetch(code_url, {cache:"default"}).then(resp => { return resp.arrayBuffer() });
52
- bundle = new URL("/g/machine-wasm-core.js", window.location.href);
45
+ console.log("non-node bundle");
46
+ let bundle;
47
+ if (globalThis.GROOVEBOX_URL_PREFIX) {
48
+ // FIXME: Stopgap solution until we figure out a way to bundle groovebox correctly
49
+ // already fire off the download of the wasm code:
50
+ let code_url = new URL(`${globalThis.GROOVEBOX_URL_PREFIX}/machine-wasm-code.wasm`, window.location.href);
51
+ fetch(code_url, {cache:"default"}).then(resp => { return resp.arrayBuffer() });
52
+ bundle = new URL(`${globalThis.GROOVEBOX_URL_PREFIX}/machine-wasm.js`, window.location.href);
53
+ } else {
54
+ // already fire off the download of the wasm code:
55
+ let code_url = new URL("/g/machine-wasm-code.wasm", window.location.href);
56
+ fetch(code_url, {cache:"default"}).then(resp => { return resp.arrayBuffer() });
57
+ bundle = new URL("/g/machine-wasm.js", window.location.href);
58
+ }
59
+ worker = new Worker(bundle);
53
60
  }
54
61
  let localFFIs = {};
55
62
  if (config.localFFIs) {
@@ -62,7 +69,6 @@ function StartWASM2(hub, config) {
62
69
  }
63
70
  }
64
71
  }
65
- let worker = new Worker(bundle);
66
72
  let config_msg =
67
73
  { "_rmx_type": "msg_vm_configure",
68
74
  "baseURL": config.baseURL,
package/node.js CHANGED
@@ -1,7 +1,49 @@
1
- import Worker from "web-worker";
2
- global.Worker = Worker;
3
- import WT from "worker_threads";
4
- global.MessageChannel = WT.MessageChannel;
1
+ //import Worker from "web-worker";
2
+ //global.Worker = Worker;
3
+ import { MessageChannel, Worker } from "worker_threads";
4
+ global.MessageChannel = MessageChannel;
5
5
  import Process from "process";
6
6
  global.Process = Process;
7
- export * from "./index.js";
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 as below 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. Webpack says ESM
17
+ // is necessary but I'm not sure if this is true for either the main
18
+ // script or the workers.
19
+ global.getHubWorker = () => {
20
+ console.log(`getting hub-worker worker`);
21
+ return new Worker(new URL("./hub-worker.mjs", import.meta.url))
22
+ }
23
+
24
+ global.getMachineWasmWorker = () => {
25
+ console.log("getting machine-wasm worker");
26
+ return new Worker(new URL("./machine-wasm.mjs", import.meta.url))
27
+ }
28
+
29
+ import * as Hub from "@remix_labs/hub-client";
30
+
31
+ import { fileURLToPath } from 'url';
32
+ global.__filename = fileURLToPath(import.meta.url);
33
+
34
+ import { CreateVMID, StartWASM, StartWASM2,
35
+ Token, Case, Opaque
36
+ } from "./index.js";
37
+
38
+ export { CreateVMID, StartWASM, StartWASM2,
39
+ Token, Case, Opaque, Hub
40
+ }
41
+
42
+ global.CreateVMID = CreateVMID;
43
+ global.StartWASM2 = StartWASM2;
44
+ global.StartWASM = StartWASM;
45
+ global.Token = Token;
46
+ global.Case = Case;
47
+ global.Opaque = Opaque;
48
+ global.Hub = Hub;
49
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix_labs/machine-starter",
3
- "version": "1.1874.0-dev",
3
+ "version": "1.1880.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": "1.1874.0-dev",
14
+ "@remix_labs/hub-client": "1.1880.0-dev",
15
15
  "nanoid": "^3.1.12",
16
16
  "web-worker": "^1.2.0"
17
17
  },
@@ -1,6 +1,14 @@
1
+ //import { fileURLToPath } from 'url';
2
+ //const __filename = fileURLToPath(import.meta.url);
3
+
1
4
  import Process from "process";
2
- import { StartWASM2 } from "./node.js";
3
- import * as Hub from "@remix_labs/hub-client";
5
+ import * as Starter from "./node.mjs";
6
+ //import { StartWASM2 } from "../dist/node.js";
7
+ //import * as Hub from "@remix_labs/hub-client";
8
+
9
+ StartWASM2 = Starter.StartWASM2;
10
+ Hub = Starter.Hub;
11
+
4
12
  if (Process.stdout._handle)
5
13
  Process.stdout._handle.setBlocking(true);
6
14
  if (Process.stderr._handle)
@@ -0,0 +1,39 @@
1
+ import path from 'path';
2
+
3
+ import {fileURLToPath} from 'url'
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+
7
+ export default [
8
+ {
9
+ target: 'node',
10
+ mode: "production",
11
+ entry: {
12
+ node: './node.js',
13
+ //'hub-worker': './hub-worker.js',
14
+ //'machine-wasm': './machine-wasm.js',
15
+ },
16
+ optimization: {
17
+ minimize: false,
18
+ },
19
+ module: {
20
+ rules: [
21
+ {
22
+ test: /\.js$/,
23
+ loader: '@open-wc/webpack-import-meta-loader'
24
+ }
25
+ ]
26
+ },
27
+ experiments: {
28
+ outputModule: true
29
+ },
30
+ output: {
31
+ chunkFormat: 'module',
32
+ filename: '[name].mjs',
33
+ library : {
34
+ type: 'module',
35
+ },
36
+ path: path.resolve(__dirname, '../dist'),
37
+ }
38
+ }
39
+ ]