@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.e73637d → 0.0.0-insiders.e9c9c4f
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/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +233 -138
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +58 -2
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -1
- package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +58 -2
- package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +58 -2
- package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +276 -140
- package/node_modules/@emnapi/core/dist/emnapi-core.js +320 -162
- package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +58 -2
- package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -1
- package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -1
- package/node_modules/@emnapi/core/dist/emnapi-core.mjs +233 -138
- package/node_modules/@emnapi/core/package.json +2 -2
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +13 -10
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +4 -4
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -1
- package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +4 -4
- package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +4 -4
- package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +13 -10
- package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +4 -4
- package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +13 -10
- package/node_modules/@emnapi/runtime/dist/emnapi.js +13 -10
- package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +4 -4
- package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -1
- package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -1
- package/node_modules/@emnapi/runtime/dist/emnapi.mjs +13 -10
- package/node_modules/@emnapi/runtime/package.json +1 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +23 -7
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +57 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +57 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +57 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +23 -7
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +23 -7
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +57 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +23 -7
- package/node_modules/@emnapi/wasi-threads/package.json +1 -1
- package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +264 -0
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +15502 -18356
- package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +259 -0
- package/node_modules/@napi-rs/wasm-runtime/package.json +14 -12
- package/node_modules/@napi-rs/wasm-runtime/runtime.cjs +1 -1
- package/node_modules/@napi-rs/wasm-runtime/runtime.js +8 -0
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +32 -15
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +32 -15
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -1
- package/node_modules/@tybys/wasm-util/dist/wasm-util.js +32 -15
- package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -1
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +32 -15
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +32 -15
- package/node_modules/@tybys/wasm-util/package.json +1 -1
- package/node_modules/tslib/package.json +1 -1
- package/node_modules/tslib/tslib.es6.js +10 -1
- package/node_modules/tslib/tslib.es6.mjs +10 -1
- package/node_modules/tslib/tslib.js +42 -33
- package/package.json +7 -7
- package/tailwindcss-oxide.wasi-browser.js +6 -3
- package/tailwindcss-oxide.wasi.cjs +26 -3
- package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
- package/node_modules/@napi-rs/wasm-runtime/LICENSE +0 -43
- package/node_modules/@napi-rs/wasm-runtime/dist/runtime.js +0 -12288
- package/node_modules/@napi-rs/wasm-runtime/fs-proxy.cjs +0 -209
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param {unknown} value
|
|
5
|
+
*/
|
|
6
|
+
const getType = (value) => {
|
|
7
|
+
if (value === undefined) return 0
|
|
8
|
+
if (value === null) return 1
|
|
9
|
+
const t = typeof value
|
|
10
|
+
if (t === 'boolean') return 2
|
|
11
|
+
if (t === 'number') return 3
|
|
12
|
+
if (t === 'string') return 4
|
|
13
|
+
if (t === 'object') return 6
|
|
14
|
+
if (t === 'bigint') return 9
|
|
15
|
+
return -1
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('memfs').IFs} memfs
|
|
20
|
+
* @param {any} value
|
|
21
|
+
* @param {ReturnType<typeof getType>} type
|
|
22
|
+
* @returns {Uint8Array}
|
|
23
|
+
*/
|
|
24
|
+
const encodeValue = (memfs, value, type) => {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case 0:
|
|
27
|
+
case 1:
|
|
28
|
+
return new Uint8Array(0)
|
|
29
|
+
case 2: {
|
|
30
|
+
const view = new Int32Array(1)
|
|
31
|
+
view[0] = value ? 1 : 0
|
|
32
|
+
return new Uint8Array(view.buffer)
|
|
33
|
+
}
|
|
34
|
+
case 3: {
|
|
35
|
+
const view = new Float64Array(1)
|
|
36
|
+
view[0] = value
|
|
37
|
+
return new Uint8Array(view.buffer)
|
|
38
|
+
}
|
|
39
|
+
case 4: {
|
|
40
|
+
const view = new TextEncoder().encode(value)
|
|
41
|
+
return view
|
|
42
|
+
}
|
|
43
|
+
case 6: {
|
|
44
|
+
function storeConstructor(obj, memfs, processed = new WeakSet()) {
|
|
45
|
+
if (!obj || typeof obj !== 'object') {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (processed.has(obj)) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
processed.add(obj)
|
|
54
|
+
|
|
55
|
+
const [entry] =
|
|
56
|
+
Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
|
|
57
|
+
[]
|
|
58
|
+
if (entry) {
|
|
59
|
+
Object.defineProperty(obj, '__constructor__', {
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
value: entry,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
for (const value of Object.values(obj)) {
|
|
68
|
+
storeConstructor(value, memfs, processed)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
storeConstructor(value, memfs)
|
|
73
|
+
|
|
74
|
+
const json = JSON.stringify(value, (_, value) => {
|
|
75
|
+
if (typeof value === 'bigint') {
|
|
76
|
+
return `BigInt(${String(value)})`
|
|
77
|
+
}
|
|
78
|
+
if (value instanceof Error) {
|
|
79
|
+
return {
|
|
80
|
+
...value,
|
|
81
|
+
message: value.message,
|
|
82
|
+
stack: value.stack,
|
|
83
|
+
__error__: value.constructor.name,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return value
|
|
87
|
+
})
|
|
88
|
+
const view = new TextEncoder().encode(json)
|
|
89
|
+
return view
|
|
90
|
+
}
|
|
91
|
+
case 9: {
|
|
92
|
+
const view = new BigInt64Array(1)
|
|
93
|
+
view[0] = value
|
|
94
|
+
return new Uint8Array(view.buffer)
|
|
95
|
+
}
|
|
96
|
+
case -1:
|
|
97
|
+
default:
|
|
98
|
+
throw new Error('unsupported data')
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param {typeof import('memfs')} memfs
|
|
104
|
+
* @param {Uint8Array} payload
|
|
105
|
+
* @param {number} type
|
|
106
|
+
* @returns {any}
|
|
107
|
+
*/
|
|
108
|
+
const decodeValue = (memfs, payload, type) => {
|
|
109
|
+
if (type === 0) return undefined
|
|
110
|
+
if (type === 1) return null
|
|
111
|
+
if (type === 2)
|
|
112
|
+
return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
|
|
113
|
+
if (type === 3)
|
|
114
|
+
return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
|
|
115
|
+
if (type === 4) return new TextDecoder().decode(payload.slice())
|
|
116
|
+
if (type === 6) {
|
|
117
|
+
const obj = JSON.parse(
|
|
118
|
+
new TextDecoder().decode(payload.slice()),
|
|
119
|
+
(_key, value) => {
|
|
120
|
+
if (typeof value === 'string') {
|
|
121
|
+
const matched = value.match(/^BigInt\((-?\d+)\)$/)
|
|
122
|
+
if (matched && matched[1]) {
|
|
123
|
+
return BigInt(matched[1])
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return value
|
|
127
|
+
},
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
function loadConstructor(obj, memfs, processed = new WeakSet()) {
|
|
131
|
+
if (!obj || typeof obj !== 'object') {
|
|
132
|
+
return
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (processed.has(obj)) {
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
processed.add(obj)
|
|
140
|
+
|
|
141
|
+
if (obj.__constructor__) {
|
|
142
|
+
const ctor = obj.__constructor__
|
|
143
|
+
delete obj.__constructor__
|
|
144
|
+
Object.setPrototypeOf(obj, memfs[ctor].prototype)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (const value of Object.values(obj)) {
|
|
148
|
+
loadConstructor(value, memfs, processed)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
loadConstructor(obj, memfs)
|
|
153
|
+
|
|
154
|
+
if (obj.__error__) {
|
|
155
|
+
const name = obj.__error__
|
|
156
|
+
const ErrorConstructor = globalThis[name] || Error
|
|
157
|
+
delete obj.__error__
|
|
158
|
+
const err = new ErrorConstructor(obj.message)
|
|
159
|
+
Object.defineProperty(err, 'stack', {
|
|
160
|
+
configurable: true,
|
|
161
|
+
enumerable: false,
|
|
162
|
+
writable: true,
|
|
163
|
+
value: err.stack,
|
|
164
|
+
})
|
|
165
|
+
Object.defineProperty(err, Symbol.toStringTag, {
|
|
166
|
+
configurable: true,
|
|
167
|
+
enumerable: false,
|
|
168
|
+
writable: true,
|
|
169
|
+
value: name,
|
|
170
|
+
})
|
|
171
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
172
|
+
if (k === 'message' || k === 'stack') continue
|
|
173
|
+
err[k] = v
|
|
174
|
+
}
|
|
175
|
+
return err
|
|
176
|
+
}
|
|
177
|
+
return obj
|
|
178
|
+
}
|
|
179
|
+
if (type === 9)
|
|
180
|
+
return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
|
|
181
|
+
throw new Error('unsupported data')
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* @param {import('memfs').IFs} fs
|
|
186
|
+
* @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
|
|
187
|
+
*/
|
|
188
|
+
// oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
|
|
189
|
+
export const createOnMessage = (fs) =>
|
|
190
|
+
function onMessage(e) {
|
|
191
|
+
if (e.data.__fs__) {
|
|
192
|
+
/**
|
|
193
|
+
* 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
|
|
194
|
+
* 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
|
|
195
|
+
* 9..16 payload_size(uint32_t) <= 1024
|
|
196
|
+
* 16..16 + payload_size payload_content
|
|
197
|
+
*/
|
|
198
|
+
const { sab, type, payload } = e.data.__fs__
|
|
199
|
+
const fn = fs[type]
|
|
200
|
+
try {
|
|
201
|
+
const ret = fn.apply(fs, payload)
|
|
202
|
+
const t = getType(ret)
|
|
203
|
+
Atomics.store(sab, 1, t)
|
|
204
|
+
const v = encodeValue(fs, ret, t)
|
|
205
|
+
Atomics.store(sab, 2, v.length)
|
|
206
|
+
new Uint8Array(sab.buffer).set(v, 16)
|
|
207
|
+
Atomics.store(sab, 0, 0) // success
|
|
208
|
+
} catch (/** @type {any} */ err) {
|
|
209
|
+
const t = getType(err)
|
|
210
|
+
Atomics.store(sab, 1, t)
|
|
211
|
+
const v = encodeValue(fs, err, t)
|
|
212
|
+
Atomics.store(sab, 2, v.length)
|
|
213
|
+
new Uint8Array(sab.buffer).set(v, 16)
|
|
214
|
+
Atomics.store(sab, 0, 1) // error
|
|
215
|
+
} finally {
|
|
216
|
+
Atomics.notify(sab, 0)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* @param {typeof import('memfs')} memfs
|
|
223
|
+
*/
|
|
224
|
+
export const createFsProxy = (memfs) =>
|
|
225
|
+
new Proxy(
|
|
226
|
+
{},
|
|
227
|
+
{
|
|
228
|
+
get(_target, p, _receiver) {
|
|
229
|
+
/**
|
|
230
|
+
* @param {any[]} args
|
|
231
|
+
*/
|
|
232
|
+
return function (...args) {
|
|
233
|
+
const sab = new SharedArrayBuffer(16 + 10240)
|
|
234
|
+
const i32arr = new Int32Array(sab)
|
|
235
|
+
Atomics.store(i32arr, 0, 21)
|
|
236
|
+
|
|
237
|
+
postMessage({
|
|
238
|
+
__fs__: {
|
|
239
|
+
sab: i32arr,
|
|
240
|
+
type: p,
|
|
241
|
+
payload: args,
|
|
242
|
+
},
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
Atomics.wait(i32arr, 0, 21)
|
|
246
|
+
|
|
247
|
+
const status = Atomics.load(i32arr, 0)
|
|
248
|
+
const type = Atomics.load(i32arr, 1)
|
|
249
|
+
const size = Atomics.load(i32arr, 2)
|
|
250
|
+
const content = new Uint8Array(sab, 16, size)
|
|
251
|
+
const value = decodeValue(memfs, content, type)
|
|
252
|
+
if (status === 1) {
|
|
253
|
+
throw value
|
|
254
|
+
}
|
|
255
|
+
return value
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@napi-rs/wasm-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Runtime and polyfill for wasm targets",
|
|
6
6
|
"author": {
|
|
@@ -19,30 +19,33 @@
|
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"runtime.cjs",
|
|
22
|
-
"
|
|
22
|
+
"runtime.js",
|
|
23
|
+
"fs-proxy.js",
|
|
24
|
+
"dist/*.cjs",
|
|
23
25
|
"dist/*.js"
|
|
24
26
|
],
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@rollup/plugin-alias": "^5.1.1",
|
|
27
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
29
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
28
30
|
"@rollup/plugin-inject": "^5.0.5",
|
|
29
31
|
"@rollup/plugin-json": "^6.1.0",
|
|
30
32
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
31
33
|
"@rollup/plugin-replace": "^6.0.2",
|
|
32
34
|
"buffer": "^6.0.3",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
+
"events": "^3.3.0",
|
|
36
|
+
"memfs": "^4.39.0",
|
|
37
|
+
"node-inspect-extracted": "^3.2.1",
|
|
35
38
|
"path-browserify": "^1.0.1",
|
|
36
39
|
"process": "^0.11.10",
|
|
37
40
|
"readable-stream": "^4.7.0",
|
|
38
|
-
"rollup": "^4.
|
|
41
|
+
"rollup": "^4.50.1",
|
|
39
42
|
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
40
43
|
"tslib": "^2.8.1"
|
|
41
44
|
},
|
|
42
45
|
"dependencies": {
|
|
43
|
-
"@emnapi/core": "^1.
|
|
44
|
-
"@emnapi/runtime": "^1.
|
|
45
|
-
"@tybys/wasm-util": "^0.10.
|
|
46
|
+
"@emnapi/core": "^1.5.0",
|
|
47
|
+
"@emnapi/runtime": "^1.5.0",
|
|
48
|
+
"@tybys/wasm-util": "^0.10.1"
|
|
46
49
|
},
|
|
47
50
|
"scripts": {
|
|
48
51
|
"build": "rollup -c rollup.config.js",
|
|
@@ -50,12 +53,11 @@
|
|
|
50
53
|
},
|
|
51
54
|
"exports": {
|
|
52
55
|
".": {
|
|
53
|
-
"import": "./
|
|
56
|
+
"import": "./runtime.js",
|
|
54
57
|
"require": "./runtime.cjs"
|
|
55
58
|
},
|
|
56
59
|
"./fs": {
|
|
57
60
|
"import": "./dist/fs.js"
|
|
58
61
|
}
|
|
59
|
-
}
|
|
60
|
-
"gitHead": "47ced636f9335fec4fc4d304dcb66bd1e5a5af45"
|
|
62
|
+
}
|
|
61
63
|
}
|
|
@@ -2,7 +2,7 @@ const { MessageHandler, instantiateNapiModuleSync, instantiateNapiModule } = req
|
|
|
2
2
|
const { getDefaultContext } = require('@emnapi/runtime')
|
|
3
3
|
const { WASI } = require('@tybys/wasm-util')
|
|
4
4
|
|
|
5
|
-
const { createFsProxy, createOnMessage } = require('./fs-proxy.cjs')
|
|
5
|
+
const { createFsProxy, createOnMessage } = require('./dist/fs-proxy.cjs')
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
MessageHandler,
|
|
@@ -1075,26 +1075,43 @@ function defineName(name, f) {
|
|
|
1075
1075
|
Object.defineProperty(f, 'name', { value: name });
|
|
1076
1076
|
return f;
|
|
1077
1077
|
}
|
|
1078
|
+
function tryCall(f, wasi, args) {
|
|
1079
|
+
let r;
|
|
1080
|
+
try {
|
|
1081
|
+
r = f.apply(wasi, args);
|
|
1082
|
+
}
|
|
1083
|
+
catch (err) {
|
|
1084
|
+
return handleError(err);
|
|
1085
|
+
}
|
|
1086
|
+
if (isPromiseLike(r)) {
|
|
1087
|
+
return r.then(_ => _, handleError);
|
|
1088
|
+
}
|
|
1089
|
+
return r;
|
|
1090
|
+
}
|
|
1078
1091
|
function syscallWrap(self, name, f) {
|
|
1079
|
-
|
|
1080
|
-
|
|
1092
|
+
let debug = false;
|
|
1093
|
+
const NODE_DEBUG_NATIVE = (() => {
|
|
1094
|
+
try {
|
|
1095
|
+
return process.env.NODE_DEBUG_NATIVE;
|
|
1096
|
+
}
|
|
1097
|
+
catch (_) {
|
|
1098
|
+
return undefined;
|
|
1099
|
+
}
|
|
1100
|
+
})();
|
|
1101
|
+
if (typeof NODE_DEBUG_NATIVE === 'string' && NODE_DEBUG_NATIVE.split(',').includes('wasi')) {
|
|
1102
|
+
debug = true;
|
|
1103
|
+
}
|
|
1104
|
+
return debug
|
|
1105
|
+
? defineName(name, function () {
|
|
1081
1106
|
const args = Array.prototype.slice.call(arguments);
|
|
1082
1107
|
let debugArgs = [`${name}(${Array.from({ length: arguments.length }).map(() => '%d').join(', ')})`];
|
|
1083
1108
|
debugArgs = debugArgs.concat(args);
|
|
1084
1109
|
console.debug.apply(console, debugArgs);
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
catch (err) {
|
|
1091
|
-
return handleError(err);
|
|
1092
|
-
}
|
|
1093
|
-
if (isPromiseLike(r)) {
|
|
1094
|
-
return r.then(_ => _, handleError);
|
|
1095
|
-
}
|
|
1096
|
-
return r;
|
|
1097
|
-
});
|
|
1110
|
+
return tryCall(f, self, args);
|
|
1111
|
+
})
|
|
1112
|
+
: defineName(name, function () {
|
|
1113
|
+
return tryCall(f, self, arguments);
|
|
1114
|
+
});
|
|
1098
1115
|
}
|
|
1099
1116
|
function resolvePathSync(fs, fileDescriptor, path, flags) {
|
|
1100
1117
|
let resolvedPath = resolve(fileDescriptor.realPath, path);
|
|
@@ -1075,26 +1075,43 @@ function defineName(name, f) {
|
|
|
1075
1075
|
Object.defineProperty(f, 'name', { value: name });
|
|
1076
1076
|
return f;
|
|
1077
1077
|
}
|
|
1078
|
+
function tryCall(f, wasi, args) {
|
|
1079
|
+
let r;
|
|
1080
|
+
try {
|
|
1081
|
+
r = f.apply(wasi, args);
|
|
1082
|
+
}
|
|
1083
|
+
catch (err) {
|
|
1084
|
+
return handleError(err);
|
|
1085
|
+
}
|
|
1086
|
+
if (isPromiseLike(r)) {
|
|
1087
|
+
return r.then(_ => _, handleError);
|
|
1088
|
+
}
|
|
1089
|
+
return r;
|
|
1090
|
+
}
|
|
1078
1091
|
function syscallWrap(self, name, f) {
|
|
1079
|
-
|
|
1080
|
-
|
|
1092
|
+
let debug = false;
|
|
1093
|
+
const NODE_DEBUG_NATIVE = (() => {
|
|
1094
|
+
try {
|
|
1095
|
+
return "wasi";
|
|
1096
|
+
}
|
|
1097
|
+
catch (_) {
|
|
1098
|
+
return undefined;
|
|
1099
|
+
}
|
|
1100
|
+
})();
|
|
1101
|
+
if (typeof NODE_DEBUG_NATIVE === 'string' && NODE_DEBUG_NATIVE.split(',').includes('wasi')) {
|
|
1102
|
+
debug = true;
|
|
1103
|
+
}
|
|
1104
|
+
return debug
|
|
1105
|
+
? defineName(name, function () {
|
|
1081
1106
|
const args = Array.prototype.slice.call(arguments);
|
|
1082
1107
|
let debugArgs = [`${name}(${Array.from({ length: arguments.length }).map(() => '%d').join(', ')})`];
|
|
1083
1108
|
debugArgs = debugArgs.concat(args);
|
|
1084
1109
|
console.debug.apply(console, debugArgs);
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
}
|
|
1090
|
-
catch (err) {
|
|
1091
|
-
return handleError(err);
|
|
1092
|
-
}
|
|
1093
|
-
if (isPromiseLike(r)) {
|
|
1094
|
-
return r.then(_ => _, handleError);
|
|
1095
|
-
}
|
|
1096
|
-
return r;
|
|
1097
|
-
});
|
|
1110
|
+
return tryCall(f, self, args);
|
|
1111
|
+
})
|
|
1112
|
+
: defineName(name, function () {
|
|
1113
|
+
return tryCall(f, self, arguments);
|
|
1114
|
+
});
|
|
1098
1115
|
}
|
|
1099
1116
|
function resolvePathSync(fs, fileDescriptor, path, flags) {
|
|
1100
1117
|
let resolvedPath = resolve(fileDescriptor.realPath, path);
|