Skip to content

Commit c08b7fc

Browse files
committed
fix(napi): commit wasi files
1 parent 85b8674 commit c08b7fc

6 files changed

+48
-6
lines changed

napi/minify/minify.wasi-browser.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import {
44
WASI as __WASI,
55
createOnMessage as __wasmCreateOnMessageForFsProxy,
66
} from '@napi-rs/wasm-runtime'
7-
7+
import { memfs } from '@napi-rs/wasm-runtime/fs'
88
import __wasmUrl from './minify.wasm32-wasi.wasm?url'
99

10+
export const { fs: __fs, vol: __volume } = memfs()
11+
1012
const __wasi = new __WASI({
1113
version: 'preview1',
14+
fs: __fs,
15+
preopens: {
16+
'/': '/',
17+
},
1218
})
1319

1420
const __emnapiContext = __emnapiGetDefaultContext()
@@ -33,6 +39,7 @@ const {
3339
const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
3440
type: 'module',
3541
})
42+
worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
3643

3744
return worker
3845
},

napi/minify/wasi-worker-browser.mjs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
1+
import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
2+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
3+
4+
const fs = createFsProxy(__memfsExported)
25

36
const handler = new MessageHandler({
47
onLoad({ wasmModule, wasmMemory }) {
58
const wasi = new WASI({
9+
fs,
10+
preopens: {
11+
'/': '/',
12+
},
613
print: function () {
714
// eslint-disable-next-line no-console
815
console.log.apply(console, arguments)

napi/parser/parser.wasi-browser.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import {
44
WASI as __WASI,
55
createOnMessage as __wasmCreateOnMessageForFsProxy,
66
} from '@napi-rs/wasm-runtime'
7-
7+
import { memfs } from '@napi-rs/wasm-runtime/fs'
88
import __wasmUrl from './parser.wasm32-wasi.wasm?url'
99

10+
export const { fs: __fs, vol: __volume } = memfs()
11+
1012
const __wasi = new __WASI({
1113
version: 'preview1',
14+
fs: __fs,
15+
preopens: {
16+
'/': '/',
17+
},
1218
})
1319

1420
const __emnapiContext = __emnapiGetDefaultContext()
@@ -33,6 +39,7 @@ const {
3339
const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
3440
type: 'module',
3541
})
42+
worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
3643

3744
return worker
3845
},

napi/parser/wasi-worker-browser.mjs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
1+
import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
2+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
3+
4+
const fs = createFsProxy(__memfsExported)
25

36
const handler = new MessageHandler({
47
onLoad({ wasmModule, wasmMemory }) {
58
const wasi = new WASI({
9+
fs,
10+
preopens: {
11+
'/': '/',
12+
},
613
print: function () {
714
// eslint-disable-next-line no-console
815
console.log.apply(console, arguments)

napi/transform/transform.wasi-browser.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@ import {
44
WASI as __WASI,
55
createOnMessage as __wasmCreateOnMessageForFsProxy,
66
} from '@napi-rs/wasm-runtime'
7-
7+
import { memfs } from '@napi-rs/wasm-runtime/fs'
88
import __wasmUrl from './transform.wasm32-wasi.wasm?url'
99

10+
export const { fs: __fs, vol: __volume } = memfs()
11+
1012
const __wasi = new __WASI({
1113
version: 'preview1',
14+
fs: __fs,
15+
preopens: {
16+
'/': '/',
17+
},
1218
})
1319

1420
const __emnapiContext = __emnapiGetDefaultContext()
@@ -33,6 +39,7 @@ const {
3339
const worker = new Worker(new URL('./wasi-worker-browser.mjs', import.meta.url), {
3440
type: 'module',
3541
})
42+
worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
3643

3744
return worker
3845
},

napi/transform/wasi-worker-browser.mjs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime'
1+
import { instantiateNapiModuleSync, MessageHandler, WASI, createFsProxy } from '@napi-rs/wasm-runtime'
2+
import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
3+
4+
const fs = createFsProxy(__memfsExported)
25

36
const handler = new MessageHandler({
47
onLoad({ wasmModule, wasmMemory }) {
58
const wasi = new WASI({
9+
fs,
10+
preopens: {
11+
'/': '/',
12+
},
613
print: function () {
714
// eslint-disable-next-line no-console
815
console.log.apply(console, arguments)

0 commit comments

Comments
 (0)