@remix_labs/machine-starter 1.1937.0-dev → 2.1841.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 +292 -0
- package/groovebox_build.js +1 -1
- package/index.js +8 -301
- package/machine-wasm.worker.js +2 -0
- package/node.js +29 -5
- package/package.json +2 -2
- package/start.js +2 -2
- package/webpack.config.js +50 -0
package/node.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
import Worker from "web-worker";
|
|
2
|
-
global.Worker = Worker;
|
|
3
|
-
import WT from "worker_threads";
|
|
4
|
-
global.MessageChannel = WT.MessageChannel;
|
|
5
1
|
import Process from "process";
|
|
6
2
|
global.Process = Process;
|
|
7
|
-
|
|
3
|
+
|
|
4
|
+
// NB: The only way I've made this work in node+webpack is if:
|
|
5
|
+
//
|
|
6
|
+
// * we use Worker from worker_threads directly
|
|
7
|
+
// * we build each worker's module with webpack as an ESM .mjs bundle
|
|
8
|
+
// * we put all the bundles in one directory
|
|
9
|
+
// * we load the worker with a URL('./foo.mjs')
|
|
10
|
+
//
|
|
11
|
+
// Other ways to package/load might work, but definitely seems like
|
|
12
|
+
// using worker_threads.Worker directly is needed (rather than through,
|
|
13
|
+
// say, the web-worker packages that wraps either worker_threads.Worker
|
|
14
|
+
// or the browser Worker to give the same interface). Webpack says ESM
|
|
15
|
+
// is necessary but I'm not sure if this is true for either the main
|
|
16
|
+
// script or the workers.
|
|
17
|
+
import { Worker } from "worker_threads";
|
|
18
|
+
|
|
19
|
+
function GetMachineWASMWorker() {
|
|
20
|
+
return new Worker(new URL("./machine-wasm.node.mjs", import.meta.url));
|
|
21
|
+
}
|
|
22
|
+
global.GetMachineWASMWorker = GetMachineWASMWorker;
|
|
23
|
+
|
|
24
|
+
// Can't just `export *` because we need hub-client below in common.js
|
|
25
|
+
import * as Hub from "@remix_labs/hub-client";
|
|
26
|
+
export { Hub };
|
|
27
|
+
|
|
28
|
+
import { fileURLToPath } from 'url';
|
|
29
|
+
global.__filename = fileURLToPath(import.meta.url);
|
|
30
|
+
|
|
31
|
+
export * from "./common.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix_labs/machine-starter",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.1841.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": "
|
|
14
|
+
"@remix_labs/hub-client": "2.1841.0-dev",
|
|
15
15
|
"nanoid": "^3.1.12",
|
|
16
16
|
"web-worker": "^1.2.0"
|
|
17
17
|
},
|
package/start.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Process from "process";
|
|
2
|
-
import { StartWASM2 } from "./node.js";
|
|
3
|
-
|
|
2
|
+
import { StartWASM2, Hub } from "./node.js";
|
|
3
|
+
|
|
4
4
|
if (Process.stdout._handle)
|
|
5
5
|
Process.stdout._handle.setBlocking(true);
|
|
6
6
|
if (Process.stderr._handle)
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
name: 'web',
|
|
10
|
+
entry: './index.js',
|
|
11
|
+
mode: "production",
|
|
12
|
+
output: {
|
|
13
|
+
filename: 'machine-starter.js',
|
|
14
|
+
path: path.resolve(__dirname, '../dist')
|
|
15
|
+
},
|
|
16
|
+
optimization: {
|
|
17
|
+
minimize: false
|
|
18
|
+
},
|
|
19
|
+
module: {
|
|
20
|
+
rules: [
|
|
21
|
+
{
|
|
22
|
+
test: /\.worker.js$/,
|
|
23
|
+
type: 'asset/source'
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'node',
|
|
30
|
+
target: 'node',
|
|
31
|
+
mode: "production",
|
|
32
|
+
entry: {
|
|
33
|
+
node: './start.js',
|
|
34
|
+
},
|
|
35
|
+
optimization: {
|
|
36
|
+
minimize: false,
|
|
37
|
+
},
|
|
38
|
+
experiments: {
|
|
39
|
+
outputModule: true
|
|
40
|
+
},
|
|
41
|
+
output: {
|
|
42
|
+
chunkFormat: 'module',
|
|
43
|
+
filename: 'machine-starter.mjs',
|
|
44
|
+
library : {
|
|
45
|
+
type: 'module',
|
|
46
|
+
},
|
|
47
|
+
path: path.resolve(__dirname, '../dist'),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
]
|