@rolldown/binding-wasm32-wasi 0.10.2 → 0.10.3
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/README.md +1 -1
- package/package.json +2 -2
- package/rolldown-binding.wasi-browser.js +23 -17
- package/rolldown-binding.wasi.cjs +26 -13
- package/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/wasi-worker-browser.mjs +6 -7
- package/wasi-worker.mjs +5 -2
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolldown/binding-wasm32-wasi",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"cpu": [
|
|
5
5
|
"wasm32"
|
|
6
6
|
],
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
},
|
|
38
38
|
"browser": "rolldown-binding.wasi-browser.js",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@napi-rs/wasm-runtime": "^0.
|
|
40
|
+
"@napi-rs/wasm-runtime": "^0.2.0"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -2,20 +2,19 @@ import {
|
|
|
2
2
|
instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync,
|
|
3
3
|
getDefaultContext as __emnapiGetDefaultContext,
|
|
4
4
|
WASI as __WASI,
|
|
5
|
+
createOnMessage as __wasmCreateOnMessageForFsProxy,
|
|
5
6
|
} from '@napi-rs/wasm-runtime'
|
|
6
|
-
import {
|
|
7
|
-
|
|
7
|
+
import { memfs } from '@napi-rs/wasm-runtime/fs'
|
|
8
8
|
import __wasmUrl from './rolldown-binding.wasm32-wasi.wasm?url'
|
|
9
9
|
|
|
10
|
-
const __fs =
|
|
11
|
-
__Volume.fromJSON({
|
|
12
|
-
'/': null,
|
|
13
|
-
}),
|
|
14
|
-
)
|
|
10
|
+
export const { fs: __fs, vol: __volume } = memfs()
|
|
15
11
|
|
|
16
12
|
const __wasi = new __WASI({
|
|
17
13
|
version: 'preview1',
|
|
18
14
|
fs: __fs,
|
|
15
|
+
preopens: {
|
|
16
|
+
'/': '/',
|
|
17
|
+
}
|
|
19
18
|
})
|
|
20
19
|
|
|
21
20
|
const __emnapiContext = __emnapiGetDefaultContext()
|
|
@@ -37,9 +36,13 @@ const {
|
|
|
37
36
|
asyncWorkPoolSize: 4,
|
|
38
37
|
wasi: __wasi,
|
|
39
38
|
onCreateWorker() {
|
|
40
|
-
|
|
39
|
+
const worker = new Worker(new URL('@rolldown/binding-wasm32-wasi/wasi-worker-browser.mjs', import.meta.url), {
|
|
41
40
|
type: 'module',
|
|
42
41
|
})
|
|
42
|
+
|
|
43
|
+
worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
|
|
44
|
+
|
|
45
|
+
return worker
|
|
43
46
|
},
|
|
44
47
|
overwriteImports(importObject) {
|
|
45
48
|
importObject.env = {
|
|
@@ -74,16 +77,19 @@ function __napi_rs_initialize_modules(__napiInstance) {
|
|
|
74
77
|
__napiInstance.exports['__napi_register__ParallelJsPluginRegistry_struct_20']?.()
|
|
75
78
|
__napiInstance.exports['__napi_register__ParallelJsPluginRegistry_impl_22']?.()
|
|
76
79
|
__napiInstance.exports['__napi_register__register_plugins_23']?.()
|
|
77
|
-
__napiInstance.exports['
|
|
78
|
-
__napiInstance.exports['
|
|
79
|
-
__napiInstance.exports['
|
|
80
|
-
__napiInstance.exports['
|
|
81
|
-
__napiInstance.exports['
|
|
82
|
-
__napiInstance.exports['
|
|
83
|
-
__napiInstance.exports['
|
|
84
|
-
__napiInstance.exports['
|
|
85
|
-
__napiInstance.exports['
|
|
80
|
+
__napiInstance.exports['__napi_register__BindingModuleInfo_struct_24']?.()
|
|
81
|
+
__napiInstance.exports['__napi_register__BindingModuleInfo_impl_26']?.()
|
|
82
|
+
__napiInstance.exports['__napi_register__BindingOutputAsset_struct_27']?.()
|
|
83
|
+
__napiInstance.exports['__napi_register__BindingOutputAsset_impl_30']?.()
|
|
84
|
+
__napiInstance.exports['__napi_register__BindingOutputChunk_struct_31']?.()
|
|
85
|
+
__napiInstance.exports['__napi_register__BindingOutputChunk_impl_42']?.()
|
|
86
|
+
__napiInstance.exports['__napi_register__BindingOutputs_struct_43']?.()
|
|
87
|
+
__napiInstance.exports['__napi_register__BindingOutputs_impl_46']?.()
|
|
88
|
+
__napiInstance.exports['__napi_register__RenderedChunk_struct_47']?.()
|
|
89
|
+
__napiInstance.exports['__napi_register__BindingRenderedModule_struct_48']?.()
|
|
90
|
+
__napiInstance.exports['__napi_register__AliasItem_struct_49']?.()
|
|
86
91
|
}
|
|
92
|
+
export const BindingModuleInfo = __napiModule.exports.BindingModuleInfo
|
|
87
93
|
export const BindingOutputAsset = __napiModule.exports.BindingOutputAsset
|
|
88
94
|
export const BindingOutputChunk = __napiModule.exports.BindingOutputChunk
|
|
89
95
|
export const BindingOutputs = __napiModule.exports.BindingOutputs
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
const __nodeFs= require('node:fs')
|
|
6
|
+
const __nodeFs = require('node:fs')
|
|
7
7
|
const __nodePath = require('node:path')
|
|
8
8
|
const { WASI: __nodeWASI } = require('node:wasi')
|
|
9
9
|
const { Worker } = require('node:worker_threads')
|
|
@@ -11,13 +11,16 @@ const { Worker } = require('node:worker_threads')
|
|
|
11
11
|
const {
|
|
12
12
|
instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
|
|
13
13
|
getDefaultContext: __emnapiGetDefaultContext,
|
|
14
|
+
createOnMessage: __wasmCreateOnMessageForFsProxy,
|
|
14
15
|
} = require('@napi-rs/wasm-runtime')
|
|
15
16
|
|
|
17
|
+
const __rootDir = __nodePath.parse(process.cwd()).root
|
|
18
|
+
|
|
16
19
|
const __wasi = new __nodeWASI({
|
|
17
20
|
version: 'preview1',
|
|
18
21
|
env: process.env,
|
|
19
22
|
preopens: {
|
|
20
|
-
|
|
23
|
+
[__rootDir]: __rootDir,
|
|
21
24
|
}
|
|
22
25
|
})
|
|
23
26
|
|
|
@@ -30,8 +33,11 @@ const __sharedMemory = new WebAssembly.Memory({
|
|
|
30
33
|
})
|
|
31
34
|
|
|
32
35
|
let __wasmFilePath = __nodePath.join(__dirname, 'rolldown-binding.wasm32-wasi.wasm')
|
|
36
|
+
const __wasmDebugFilePath = __nodePath.join(__dirname, 'rolldown-binding.wasm32-wasi.debug.wasm')
|
|
33
37
|
|
|
34
|
-
if (
|
|
38
|
+
if (__nodeFs.existsSync(__wasmDebugFilePath)) {
|
|
39
|
+
__wasmFilePath = __wasmDebugFilePath
|
|
40
|
+
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
|
|
35
41
|
try {
|
|
36
42
|
__wasmFilePath = __nodePath.resolve('@rolldown/binding-wasm32-wasi')
|
|
37
43
|
} catch {
|
|
@@ -52,10 +58,14 @@ const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule
|
|
|
52
58
|
})(),
|
|
53
59
|
wasi: __wasi,
|
|
54
60
|
onCreateWorker() {
|
|
55
|
-
|
|
61
|
+
const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
|
|
56
62
|
env: process.env,
|
|
57
63
|
execArgv: ['--experimental-wasi-unstable-preview1'],
|
|
58
64
|
})
|
|
65
|
+
worker.onmessage = ({ data }) => {
|
|
66
|
+
__wasmCreateOnMessageForFsProxy(__nodeFs)(data)
|
|
67
|
+
}
|
|
68
|
+
return worker
|
|
59
69
|
},
|
|
60
70
|
overwriteImports(importObject) {
|
|
61
71
|
importObject.env = {
|
|
@@ -90,16 +100,19 @@ function __napi_rs_initialize_modules(__napiInstance) {
|
|
|
90
100
|
__napiInstance.exports['__napi_register__ParallelJsPluginRegistry_struct_20']?.()
|
|
91
101
|
__napiInstance.exports['__napi_register__ParallelJsPluginRegistry_impl_22']?.()
|
|
92
102
|
__napiInstance.exports['__napi_register__register_plugins_23']?.()
|
|
93
|
-
__napiInstance.exports['
|
|
94
|
-
__napiInstance.exports['
|
|
95
|
-
__napiInstance.exports['
|
|
96
|
-
__napiInstance.exports['
|
|
97
|
-
__napiInstance.exports['
|
|
98
|
-
__napiInstance.exports['
|
|
99
|
-
__napiInstance.exports['
|
|
100
|
-
__napiInstance.exports['
|
|
101
|
-
__napiInstance.exports['
|
|
103
|
+
__napiInstance.exports['__napi_register__BindingModuleInfo_struct_24']?.()
|
|
104
|
+
__napiInstance.exports['__napi_register__BindingModuleInfo_impl_26']?.()
|
|
105
|
+
__napiInstance.exports['__napi_register__BindingOutputAsset_struct_27']?.()
|
|
106
|
+
__napiInstance.exports['__napi_register__BindingOutputAsset_impl_30']?.()
|
|
107
|
+
__napiInstance.exports['__napi_register__BindingOutputChunk_struct_31']?.()
|
|
108
|
+
__napiInstance.exports['__napi_register__BindingOutputChunk_impl_42']?.()
|
|
109
|
+
__napiInstance.exports['__napi_register__BindingOutputs_struct_43']?.()
|
|
110
|
+
__napiInstance.exports['__napi_register__BindingOutputs_impl_46']?.()
|
|
111
|
+
__napiInstance.exports['__napi_register__RenderedChunk_struct_47']?.()
|
|
112
|
+
__napiInstance.exports['__napi_register__BindingRenderedModule_struct_48']?.()
|
|
113
|
+
__napiInstance.exports['__napi_register__AliasItem_struct_49']?.()
|
|
102
114
|
}
|
|
115
|
+
module.exports.BindingModuleInfo = __napiModule.exports.BindingModuleInfo
|
|
103
116
|
module.exports.BindingOutputAsset = __napiModule.exports.BindingOutputAsset
|
|
104
117
|
module.exports.BindingOutputChunk = __napiModule.exports.BindingOutputChunk
|
|
105
118
|
module.exports.BindingOutputs = __napiModule.exports.BindingOutputs
|
|
Binary file
|
package/wasi-worker-browser.mjs
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
|
|
2
|
-
import {
|
|
1
|
+
import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
|
|
2
|
+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
|
|
3
3
|
|
|
4
|
-
const fs =
|
|
5
|
-
Volume.fromJSON({
|
|
6
|
-
'/': null,
|
|
7
|
-
}),
|
|
8
|
-
)
|
|
4
|
+
const fs = createFsProxy(__memfsExported)
|
|
9
5
|
|
|
10
6
|
const handler = new MessageHandler({
|
|
11
7
|
onLoad({ wasmModule, wasmMemory }) {
|
|
12
8
|
const wasi = new WASI({
|
|
13
9
|
fs,
|
|
10
|
+
preopens: {
|
|
11
|
+
'/': '/',
|
|
12
|
+
},
|
|
14
13
|
print: function () {
|
|
15
14
|
// eslint-disable-next-line no-console
|
|
16
15
|
console.log.apply(console, arguments)
|
package/wasi-worker.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
+
import { parse } from "node:path";
|
|
3
4
|
import { WASI } from "node:wasi";
|
|
4
5
|
import { parentPort, Worker } from "node:worker_threads";
|
|
5
6
|
|
|
@@ -27,7 +28,9 @@ Object.assign(globalThis, {
|
|
|
27
28
|
},
|
|
28
29
|
});
|
|
29
30
|
|
|
30
|
-
const emnapiContext = getDefaultContext()
|
|
31
|
+
const emnapiContext = getDefaultContext();
|
|
32
|
+
|
|
33
|
+
const __rootDir = parse(process.cwd()).root;
|
|
31
34
|
|
|
32
35
|
const handler = new MessageHandler({
|
|
33
36
|
onLoad({ wasmModule, wasmMemory }) {
|
|
@@ -35,7 +38,7 @@ const handler = new MessageHandler({
|
|
|
35
38
|
version: 'preview1',
|
|
36
39
|
env: process.env,
|
|
37
40
|
preopens: {
|
|
38
|
-
|
|
41
|
+
[__rootDir]: __rootDir,
|
|
39
42
|
},
|
|
40
43
|
});
|
|
41
44
|
|