@vue-jsx-vapor/compiler-rs-wasm32-wasi 2.6.13 → 2.7.1
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/compiler-rs.wasi-browser.js +12 -8
- package/compiler-rs.wasi.cjs +30 -16
- package/compiler-rs.wasm32-wasi.wasm +0 -0
- package/package.json +2 -2
- package/wasi-worker-browser.mjs +10 -5
- package/wasi-worker.mjs +30 -24
|
@@ -1,20 +1,21 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* prettier-ignore */
|
|
3
|
+
|
|
1
4
|
import {
|
|
2
|
-
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
|
3
5
|
getDefaultContext as __emnapiGetDefaultContext,
|
|
4
6
|
instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
|
|
5
7
|
WASI as __WASI,
|
|
8
|
+
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
|
6
9
|
} from '@napi-rs/wasm-runtime'
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
11
|
const __wasi = new __WASI({
|
|
11
12
|
version: 'preview1',
|
|
12
13
|
})
|
|
13
14
|
|
|
14
|
-
const __wasmUrl = new URL('./compiler-rs.wasm32-wasi.wasm', import.meta.url)
|
|
15
|
+
const __wasmUrl = new URL('./compiler-rs.wasm32-wasi.wasm', import.meta.url)
|
|
16
|
+
.href
|
|
15
17
|
const __emnapiContext = __emnapiGetDefaultContext()
|
|
16
18
|
|
|
17
|
-
|
|
18
19
|
const __sharedMemory = new WebAssembly.Memory({
|
|
19
20
|
initial: 4000,
|
|
20
21
|
maximum: 65536,
|
|
@@ -32,9 +33,12 @@ const {
|
|
|
32
33
|
asyncWorkPoolSize: 4,
|
|
33
34
|
wasi: __wasi,
|
|
34
35
|
onCreateWorker() {
|
|
35
|
-
const worker = new Worker(
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const worker = new Worker(
|
|
37
|
+
new URL('@vue-jsx-vapor/compiler-rs-wasm32-wasi/wasi-worker-browser.mjs', import.meta.url),
|
|
38
|
+
{
|
|
39
|
+
type: 'module',
|
|
40
|
+
},
|
|
41
|
+
)
|
|
38
42
|
|
|
39
43
|
return worker
|
|
40
44
|
},
|
package/compiler-rs.wasi.cjs
CHANGED
|
@@ -21,7 +21,7 @@ const __wasi = new __nodeWASI({
|
|
|
21
21
|
env: process.env,
|
|
22
22
|
preopens: {
|
|
23
23
|
[__rootDir]: __rootDir,
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
const __emnapiContext = __emnapiGetDefaultContext()
|
|
@@ -33,22 +33,36 @@ const __sharedMemory = new WebAssembly.Memory({
|
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
let __wasmFilePath = __nodePath.join(__dirname, 'compiler-rs.wasm32-wasi.wasm')
|
|
36
|
-
const __wasmDebugFilePath = __nodePath.join(
|
|
36
|
+
const __wasmDebugFilePath = __nodePath.join(
|
|
37
|
+
__dirname,
|
|
38
|
+
'compiler-rs.wasm32-wasi.debug.wasm',
|
|
39
|
+
)
|
|
37
40
|
|
|
38
41
|
if (__nodeFs.existsSync(__wasmDebugFilePath)) {
|
|
39
42
|
__wasmFilePath = __wasmDebugFilePath
|
|
40
43
|
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
|
|
41
44
|
try {
|
|
42
|
-
__wasmFilePath = __nodePath.resolve(
|
|
45
|
+
__wasmFilePath = __nodePath.resolve(
|
|
46
|
+
'@vue-jsx-vapor/compiler-rs-wasm32-wasi',
|
|
47
|
+
)
|
|
43
48
|
} catch {
|
|
44
|
-
throw new Error(
|
|
49
|
+
throw new Error(
|
|
50
|
+
'Cannot find compiler-rs.wasm32-wasi.wasm file, and @vue-jsx-vapor/compiler-rs-wasm32-wasi package is not installed.',
|
|
51
|
+
)
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
54
|
|
|
48
|
-
const {
|
|
55
|
+
const {
|
|
56
|
+
instance: __napiInstance,
|
|
57
|
+
module: __wasiModule,
|
|
58
|
+
napiModule: __napiModule,
|
|
59
|
+
} = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
|
|
49
60
|
context: __emnapiContext,
|
|
50
|
-
asyncWorkPoolSize: (function() {
|
|
51
|
-
const threadsSizeFromEnv = Number(
|
|
61
|
+
asyncWorkPoolSize: (function () {
|
|
62
|
+
const threadsSizeFromEnv = Number(
|
|
63
|
+
process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ??
|
|
64
|
+
process.env.UV_THREADPOOL_SIZE,
|
|
65
|
+
)
|
|
52
66
|
// NaN > 0 is false
|
|
53
67
|
if (threadsSizeFromEnv > 0) {
|
|
54
68
|
return threadsSizeFromEnv
|
|
@@ -72,21 +86,21 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule
|
|
|
72
86
|
// According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
|
|
73
87
|
// a worker is consist of two handles: kPublicPort and kHandle.
|
|
74
88
|
{
|
|
75
|
-
const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
|
|
76
|
-
s.toString().includes(
|
|
77
|
-
)
|
|
89
|
+
const kPublicPort = Object.getOwnPropertySymbols(worker).find((s) =>
|
|
90
|
+
s.toString().includes('kPublicPort'),
|
|
91
|
+
)
|
|
78
92
|
if (kPublicPort) {
|
|
79
|
-
worker[kPublicPort].ref = () => {}
|
|
93
|
+
worker[kPublicPort].ref = () => {}
|
|
80
94
|
}
|
|
81
95
|
|
|
82
|
-
const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
|
|
83
|
-
s.toString().includes(
|
|
84
|
-
)
|
|
96
|
+
const kHandle = Object.getOwnPropertySymbols(worker).find((s) =>
|
|
97
|
+
s.toString().includes('kHandle'),
|
|
98
|
+
)
|
|
85
99
|
if (kHandle) {
|
|
86
|
-
worker[kHandle].ref = () => {}
|
|
100
|
+
worker[kHandle].ref = () => {}
|
|
87
101
|
}
|
|
88
102
|
|
|
89
|
-
worker.unref()
|
|
103
|
+
worker.unref()
|
|
90
104
|
}
|
|
91
105
|
return worker
|
|
92
106
|
},
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-jsx-vapor/compiler-rs-wasm32-wasi",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"cpu": [
|
|
5
5
|
"wasm32"
|
|
6
6
|
],
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"node": ">=14.0.0"
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
|
-
"url": "git+
|
|
29
|
+
"url": "git+https://github.com/vuejs/vue-jsx-vapor.git",
|
|
30
30
|
"type": "git"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
package/wasi-worker-browser.mjs
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
instantiateNapiModuleSync,
|
|
3
|
+
MessageHandler,
|
|
4
|
+
WASI,
|
|
5
|
+
} from '@napi-rs/wasm-runtime'
|
|
2
6
|
|
|
3
7
|
const handler = new MessageHandler({
|
|
4
8
|
onLoad({ wasmModule, wasmMemory }) {
|
|
5
9
|
const wasi = new WASI({
|
|
6
|
-
print
|
|
7
|
-
// eslint-disable-next-line no-console
|
|
10
|
+
print() {
|
|
11
|
+
// eslint-disable-next-line prefer-spread, prefer-rest-params, no-console
|
|
8
12
|
console.log.apply(console, arguments)
|
|
9
13
|
},
|
|
10
|
-
printErr
|
|
11
|
-
// eslint-disable-next-line
|
|
14
|
+
printErr() {
|
|
15
|
+
// eslint-disable-next-line prefer-spread, prefer-rest-params
|
|
12
16
|
console.error.apply(console, arguments)
|
|
13
17
|
},
|
|
14
18
|
})
|
|
@@ -27,6 +31,7 @@ const handler = new MessageHandler({
|
|
|
27
31
|
},
|
|
28
32
|
})
|
|
29
33
|
|
|
34
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
|
30
35
|
globalThis.onmessage = function (e) {
|
|
31
36
|
handler.handle(e)
|
|
32
37
|
}
|
package/wasi-worker.mjs
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { createRequire } from
|
|
3
|
-
import { parse } from
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import { createRequire } from 'node:module'
|
|
3
|
+
import { parse } from 'node:path'
|
|
4
|
+
import process from 'node:process'
|
|
5
|
+
import { WASI } from 'node:wasi'
|
|
6
|
+
import { parentPort, Worker } from 'node:worker_threads'
|
|
6
7
|
|
|
7
|
-
const require = createRequire(import.meta.url)
|
|
8
|
+
const require = createRequire(import.meta.url)
|
|
8
9
|
|
|
9
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
instantiateNapiModuleSync,
|
|
12
|
+
MessageHandler,
|
|
13
|
+
getDefaultContext,
|
|
14
|
+
} = require('@napi-rs/wasm-runtime')
|
|
10
15
|
|
|
11
16
|
if (parentPort) {
|
|
12
|
-
parentPort.on(
|
|
13
|
-
globalThis.onmessage({ data })
|
|
14
|
-
})
|
|
17
|
+
parentPort.on('message', (data) => {
|
|
18
|
+
globalThis.onmessage({ data })
|
|
19
|
+
})
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
Object.assign(globalThis, {
|
|
18
23
|
self: globalThis,
|
|
19
24
|
require,
|
|
20
25
|
Worker,
|
|
21
|
-
importScripts
|
|
22
|
-
;(0, eval)(fs.readFileSync(f,
|
|
26
|
+
importScripts(f) {
|
|
27
|
+
;(0, eval)(`${fs.readFileSync(f, 'utf8')}//# sourceURL=${f}`)
|
|
23
28
|
},
|
|
24
|
-
postMessage
|
|
29
|
+
postMessage(msg) {
|
|
25
30
|
if (parentPort) {
|
|
26
|
-
parentPort.postMessage(msg)
|
|
31
|
+
parentPort.postMessage(msg)
|
|
27
32
|
}
|
|
28
33
|
},
|
|
29
|
-
})
|
|
34
|
+
})
|
|
30
35
|
|
|
31
|
-
const emnapiContext = getDefaultContext()
|
|
36
|
+
const emnapiContext = getDefaultContext()
|
|
32
37
|
|
|
33
|
-
const __rootDir = parse(process.cwd()).root
|
|
38
|
+
const __rootDir = parse(process.cwd()).root
|
|
34
39
|
|
|
35
40
|
const handler = new MessageHandler({
|
|
36
41
|
onLoad({ wasmModule, wasmMemory }) {
|
|
@@ -40,7 +45,7 @@ const handler = new MessageHandler({
|
|
|
40
45
|
preopens: {
|
|
41
46
|
[__rootDir]: __rootDir,
|
|
42
47
|
},
|
|
43
|
-
})
|
|
48
|
+
})
|
|
44
49
|
|
|
45
50
|
return instantiateNapiModuleSync(wasmModule, {
|
|
46
51
|
childThread: true,
|
|
@@ -51,13 +56,14 @@ const handler = new MessageHandler({
|
|
|
51
56
|
...importObject.env,
|
|
52
57
|
...importObject.napi,
|
|
53
58
|
...importObject.emnapi,
|
|
54
|
-
memory: wasmMemory
|
|
55
|
-
}
|
|
59
|
+
memory: wasmMemory,
|
|
60
|
+
}
|
|
56
61
|
},
|
|
57
|
-
})
|
|
62
|
+
})
|
|
58
63
|
},
|
|
59
|
-
})
|
|
64
|
+
})
|
|
60
65
|
|
|
66
|
+
// eslint-disable-next-line unicorn/prefer-add-event-listener
|
|
61
67
|
globalThis.onmessage = function (e) {
|
|
62
|
-
handler.handle(e)
|
|
63
|
-
}
|
|
68
|
+
handler.handle(e)
|
|
69
|
+
}
|