@napi-rs/cli 3.0.0-alpha.98 → 3.0.0
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/dist/api/templates/load-wasi-template.d.ts +1 -1
- package/dist/cli.js +11 -7
- package/dist/index.cjs +11 -7
- package/dist/index.js +11 -7
- package/dist/utils/config.d.ts +4 -0
- package/package.json +2 -2
- package/src/api/build.ts +1 -0
- package/src/api/templates/js-binding.ts +2 -2
- package/src/api/templates/load-wasi-template.ts +11 -0
- package/src/utils/config.ts +4 -0
package/dist/utils/config.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/cli",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
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",
|
|
@@ -132,5 +132,5 @@
|
|
|
132
132
|
"e2e/**/*.spec.ts"
|
|
133
133
|
]
|
|
134
134
|
},
|
|
135
|
-
"gitHead": "
|
|
135
|
+
"gitHead": "cdbf2bc43945175eabe56b19a6bb0f8584dbc34c"
|
|
136
136
|
}
|
package/src/api/build.ts
CHANGED
|
@@ -1056,6 +1056,7 @@ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array
|
|
|
1056
1056
|
this.config.wasm?.maximumMemory,
|
|
1057
1057
|
this.config.wasm?.browser?.fs,
|
|
1058
1058
|
this.config.wasm?.browser?.asyncInit,
|
|
1059
|
+
this.config.wasm?.browser?.buffer,
|
|
1059
1060
|
) +
|
|
1060
1061
|
`export default __napiModule.exports\n` +
|
|
1061
1062
|
idents
|
|
@@ -186,9 +186,9 @@ function requireNative() {
|
|
|
186
186
|
}
|
|
187
187
|
} else if (process.platform === 'openharmony') {
|
|
188
188
|
if (process.arch === 'arm64') {
|
|
189
|
-
${requireTuple('linux-x64-ohos')}
|
|
190
|
-
} else if (process.arch === 'x64') {
|
|
191
189
|
${requireTuple('linux-arm64-ohos')}
|
|
190
|
+
} else if (process.arch === 'x64') {
|
|
191
|
+
${requireTuple('linux-x64-ohos')}
|
|
192
192
|
} else if (process.arch === 'arm') {
|
|
193
193
|
${requireTuple('linux-arm-ohos')}
|
|
194
194
|
} else {
|
|
@@ -4,8 +4,14 @@ export const createWasiBrowserBinding = (
|
|
|
4
4
|
maximumMemory = 65536,
|
|
5
5
|
fs = false,
|
|
6
6
|
asyncInit = false,
|
|
7
|
+
buffer = false,
|
|
7
8
|
) => {
|
|
8
9
|
const fsImport = fs ? `import { memfs } from '@napi-rs/wasm-runtime/fs'` : ''
|
|
10
|
+
const bufferImport = buffer
|
|
11
|
+
? fs
|
|
12
|
+
? ``
|
|
13
|
+
: `import { Buffer } from 'buffer'`
|
|
14
|
+
: ''
|
|
9
15
|
const wasiCreation = fs
|
|
10
16
|
? `
|
|
11
17
|
export const { fs: __fs, vol: __volume } = memfs()
|
|
@@ -26,6 +32,9 @@ const __wasi = new __WASI({
|
|
|
26
32
|
? ` worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))\n`
|
|
27
33
|
: ''
|
|
28
34
|
|
|
35
|
+
const emnapiInjectBuffer = buffer
|
|
36
|
+
? '__emnapiContext.feature.Buffer = Buffer'
|
|
37
|
+
: ''
|
|
29
38
|
const emnapiInstantiateImport = asyncInit
|
|
30
39
|
? `instantiateNapiModule as __emnapiInstantiateNapiModule`
|
|
31
40
|
: `instantiateNapiModuleSync as __emnapiInstantiateNapiModuleSync`
|
|
@@ -40,10 +49,12 @@ const __wasi = new __WASI({
|
|
|
40
49
|
WASI as __WASI,
|
|
41
50
|
} from '@napi-rs/wasm-runtime'
|
|
42
51
|
${fsImport}
|
|
52
|
+
${bufferImport}
|
|
43
53
|
${wasiCreation}
|
|
44
54
|
|
|
45
55
|
const __wasmUrl = new URL('./${wasiFilename}.wasm', import.meta.url).href
|
|
46
56
|
const __emnapiContext = __emnapiGetDefaultContext()
|
|
57
|
+
${emnapiInjectBuffer}
|
|
47
58
|
|
|
48
59
|
const __sharedMemory = new WebAssembly.Memory({
|
|
49
60
|
initial: ${initialMemory},
|