@napi-rs/cli 3.0.0-alpha.53 → 3.0.0-alpha.54
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.
|
@@ -64,16 +64,13 @@ globalThis.onmessage = function (e) {
|
|
|
64
64
|
`;
|
|
65
65
|
export const createWasiBrowserWorkerBinding = (fs) => {
|
|
66
66
|
const fsImport = fs
|
|
67
|
-
? `import {
|
|
67
|
+
? `import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
|
|
68
|
+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
|
|
68
69
|
|
|
69
70
|
const fs = createFsProxy(__memfsExported)`
|
|
70
|
-
:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const handler = new MessageHandler({
|
|
75
|
-
onLoad({ wasmModule, wasmMemory }) {
|
|
76
|
-
const wasi = new WASI({
|
|
71
|
+
: `import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'`;
|
|
72
|
+
const wasiCreation = fs
|
|
73
|
+
? `const wasi = new WASI({
|
|
77
74
|
fs,
|
|
78
75
|
preopens: {
|
|
79
76
|
'/': '/',
|
|
@@ -86,7 +83,22 @@ const handler = new MessageHandler({
|
|
|
86
83
|
// eslint-disable-next-line no-console
|
|
87
84
|
console.error.apply(console, arguments)
|
|
88
85
|
},
|
|
89
|
-
})
|
|
86
|
+
})`
|
|
87
|
+
: `const wasi = new WASI({
|
|
88
|
+
print: function () {
|
|
89
|
+
// eslint-disable-next-line no-console
|
|
90
|
+
console.log.apply(console, arguments)
|
|
91
|
+
},
|
|
92
|
+
printErr: function() {
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.error.apply(console, arguments)
|
|
95
|
+
},
|
|
96
|
+
})`;
|
|
97
|
+
return `${fsImport}
|
|
98
|
+
|
|
99
|
+
const handler = new MessageHandler({
|
|
100
|
+
onLoad({ wasmModule, wasmMemory }) {
|
|
101
|
+
${wasiCreation}
|
|
90
102
|
return instantiateNapiModuleSync(wasmModule, {
|
|
91
103
|
childThread: true,
|
|
92
104
|
wasi,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasi-worker-template.js","sourceRoot":"","sources":["../../../src/api/templates/wasi-worker-template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DnC,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAAW,EAAE,EAAE;IAC5D,MAAM,QAAQ,GAAG,EAAE;QACjB,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"wasi-worker-template.js","sourceRoot":"","sources":["../../../src/api/templates/wasi-worker-template.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DnC,CAAA;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,EAAW,EAAE,EAAE;IAC5D,MAAM,QAAQ,GAAG,EAAE;QACjB,CAAC,CAAC;;;0CAGoC;QACtC,CAAC,CAAC,yFAAyF,CAAA;IAC7F,MAAM,YAAY,GAAG,EAAE;QACrB,CAAC,CAAC;;;;;;;;;;;;;OAaC;QACH,CAAC,CAAC;;;;;;;;;OASC,CAAA;IACL,OAAO,GAAG,QAAQ;;;;MAId,YAAY;;;;;;;;;;;;;;;;;;;CAmBjB,CAAA;AACD,CAAC,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -17347,15 +17347,11 @@ globalThis.onmessage = function (e) {
|
|
|
17347
17347
|
};
|
|
17348
17348
|
`;
|
|
17349
17349
|
var createWasiBrowserWorkerBinding = (fs2) => {
|
|
17350
|
-
const fsImport = fs2 ? `import {
|
|
17350
|
+
const fsImport = fs2 ? `import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
|
|
17351
|
+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
|
|
17351
17352
|
|
|
17352
|
-
const fs = createFsProxy(__memfsExported)` :
|
|
17353
|
-
|
|
17354
|
-
${fsImport}
|
|
17355
|
-
|
|
17356
|
-
const handler = new MessageHandler({
|
|
17357
|
-
onLoad({ wasmModule, wasmMemory }) {
|
|
17358
|
-
const wasi = new WASI({
|
|
17353
|
+
const fs = createFsProxy(__memfsExported)` : `import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'`;
|
|
17354
|
+
const wasiCreation = fs2 ? `const wasi = new WASI({
|
|
17359
17355
|
fs,
|
|
17360
17356
|
preopens: {
|
|
17361
17357
|
'/': '/',
|
|
@@ -17368,7 +17364,21 @@ const handler = new MessageHandler({
|
|
|
17368
17364
|
// eslint-disable-next-line no-console
|
|
17369
17365
|
console.error.apply(console, arguments)
|
|
17370
17366
|
},
|
|
17371
|
-
})
|
|
17367
|
+
})` : `const wasi = new WASI({
|
|
17368
|
+
print: function () {
|
|
17369
|
+
// eslint-disable-next-line no-console
|
|
17370
|
+
console.log.apply(console, arguments)
|
|
17371
|
+
},
|
|
17372
|
+
printErr: function() {
|
|
17373
|
+
// eslint-disable-next-line no-console
|
|
17374
|
+
console.error.apply(console, arguments)
|
|
17375
|
+
},
|
|
17376
|
+
})`;
|
|
17377
|
+
return `${fsImport}
|
|
17378
|
+
|
|
17379
|
+
const handler = new MessageHandler({
|
|
17380
|
+
onLoad({ wasmModule, wasmMemory }) {
|
|
17381
|
+
${wasiCreation}
|
|
17372
17382
|
return instantiateNapiModuleSync(wasmModule, {
|
|
17373
17383
|
childThread: true,
|
|
17374
17384
|
wasi,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/cli",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.54",
|
|
4
4
|
"description": "Cli tools for napi-rs",
|
|
5
5
|
"author": "LongYinan <lynweklm@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/napi-rs/napi-rs",
|
|
@@ -129,5 +129,5 @@
|
|
|
129
129
|
"**/__tests__/**/*.spec.ts"
|
|
130
130
|
]
|
|
131
131
|
},
|
|
132
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "a54b759bb1767d0b45968ea4acf795de78af268a"
|
|
133
133
|
}
|
|
@@ -65,16 +65,13 @@ globalThis.onmessage = function (e) {
|
|
|
65
65
|
|
|
66
66
|
export const createWasiBrowserWorkerBinding = (fs: boolean) => {
|
|
67
67
|
const fsImport = fs
|
|
68
|
-
? `import {
|
|
68
|
+
? `import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
|
|
69
|
+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
|
|
69
70
|
|
|
70
71
|
const fs = createFsProxy(__memfsExported)`
|
|
71
|
-
:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const handler = new MessageHandler({
|
|
76
|
-
onLoad({ wasmModule, wasmMemory }) {
|
|
77
|
-
const wasi = new WASI({
|
|
72
|
+
: `import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'`
|
|
73
|
+
const wasiCreation = fs
|
|
74
|
+
? `const wasi = new WASI({
|
|
78
75
|
fs,
|
|
79
76
|
preopens: {
|
|
80
77
|
'/': '/',
|
|
@@ -87,7 +84,22 @@ const handler = new MessageHandler({
|
|
|
87
84
|
// eslint-disable-next-line no-console
|
|
88
85
|
console.error.apply(console, arguments)
|
|
89
86
|
},
|
|
90
|
-
})
|
|
87
|
+
})`
|
|
88
|
+
: `const wasi = new WASI({
|
|
89
|
+
print: function () {
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
console.log.apply(console, arguments)
|
|
92
|
+
},
|
|
93
|
+
printErr: function() {
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.error.apply(console, arguments)
|
|
96
|
+
},
|
|
97
|
+
})`
|
|
98
|
+
return `${fsImport}
|
|
99
|
+
|
|
100
|
+
const handler = new MessageHandler({
|
|
101
|
+
onLoad({ wasmModule, wasmMemory }) {
|
|
102
|
+
${wasiCreation}
|
|
91
103
|
return instantiateNapiModuleSync(wasmModule, {
|
|
92
104
|
childThread: true,
|
|
93
105
|
wasi,
|