@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.bd9cf92 → 0.0.0-insiders.bdcd708

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.
Files changed (69) hide show
  1. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +1469 -511
  2. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +61 -5
  3. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -1
  4. package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +61 -5
  5. package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +61 -5
  6. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +1628 -523
  7. package/node_modules/@emnapi/core/dist/emnapi-core.js +1705 -585
  8. package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +61 -5
  9. package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -1
  10. package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -1
  11. package/node_modules/@emnapi/core/dist/emnapi-core.mjs +1469 -511
  12. package/node_modules/@emnapi/core/package.json +2 -2
  13. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +44 -14
  14. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +15 -7
  15. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -1
  16. package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +15 -7
  17. package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +15 -7
  18. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +45 -14
  19. package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +12 -6
  20. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +45 -14
  21. package/node_modules/@emnapi/runtime/dist/emnapi.js +45 -14
  22. package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +15 -7
  23. package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -1
  24. package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -1
  25. package/node_modules/@emnapi/runtime/dist/emnapi.mjs +44 -14
  26. package/node_modules/@emnapi/runtime/package.json +1 -1
  27. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +67 -63
  28. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +59 -2
  29. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -1
  30. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +59 -2
  31. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +59 -2
  32. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +67 -63
  33. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +67 -63
  34. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +59 -2
  35. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -1
  36. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -1
  37. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +67 -63
  38. package/node_modules/@emnapi/wasi-threads/package.json +1 -1
  39. package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +299 -0
  40. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +22125 -20726
  41. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +294 -0
  42. package/node_modules/@napi-rs/wasm-runtime/package.json +25 -16
  43. package/node_modules/@napi-rs/wasm-runtime/runtime.cjs +1 -1
  44. package/node_modules/@napi-rs/wasm-runtime/runtime.js +8 -0
  45. package/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +6 -0
  46. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +215 -33
  47. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +215 -33
  48. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -1
  49. package/node_modules/@tybys/wasm-util/dist/wasm-util.js +215 -33
  50. package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -1
  51. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +12 -14
  52. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +142 -0
  53. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +61 -19
  54. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +12 -14
  55. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +142 -0
  56. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +61 -19
  57. package/node_modules/@tybys/wasm-util/package.json +1 -1
  58. package/node_modules/tslib/package.json +1 -1
  59. package/node_modules/tslib/tslib.es6.js +10 -1
  60. package/node_modules/tslib/tslib.es6.mjs +10 -1
  61. package/node_modules/tslib/tslib.js +42 -33
  62. package/package.json +7 -7
  63. package/tailwindcss-oxide.wasi-browser.js +7 -3
  64. package/tailwindcss-oxide.wasi.cjs +27 -4
  65. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
  66. package/wasi-worker-browser.mjs +2 -0
  67. package/node_modules/@napi-rs/wasm-runtime/LICENSE +0 -43
  68. package/node_modules/@napi-rs/wasm-runtime/dist/runtime.js +0 -12285
  69. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.cjs +0 -209
@@ -0,0 +1,294 @@
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
+ const RESPONSE_HEADER_SIZE = 16
19
+ const RESPONSE_PAYLOAD_SIZE = 10240
20
+ const RESPONSE_BUFFER_SIZE = RESPONSE_HEADER_SIZE + RESPONSE_PAYLOAD_SIZE
21
+
22
+ /**
23
+ * @param {Int32Array} sab
24
+ * @param {Uint8Array} payload
25
+ */
26
+ const writeResponsePayload = (sab, payload) => {
27
+ if (payload.length > RESPONSE_PAYLOAD_SIZE) {
28
+ throw new RangeError('payload overflow')
29
+ }
30
+ new Uint8Array(sab.buffer).set(payload, RESPONSE_HEADER_SIZE)
31
+ }
32
+
33
+ /**
34
+ * @param {import('memfs').IFs} memfs
35
+ * @param {any} value
36
+ * @param {ReturnType<typeof getType>} type
37
+ * @returns {Uint8Array}
38
+ */
39
+ const encodeValue = (memfs, value, type) => {
40
+ switch (type) {
41
+ case 0:
42
+ case 1:
43
+ return new Uint8Array(0)
44
+ case 2: {
45
+ const view = new Int32Array(1)
46
+ view[0] = value ? 1 : 0
47
+ return new Uint8Array(view.buffer)
48
+ }
49
+ case 3: {
50
+ const view = new Float64Array(1)
51
+ view[0] = value
52
+ return new Uint8Array(view.buffer)
53
+ }
54
+ case 4: {
55
+ const view = new TextEncoder().encode(value)
56
+ return view
57
+ }
58
+ case 6: {
59
+ function storeConstructor(obj, memfs, processed = new WeakSet()) {
60
+ if (!obj || typeof obj !== 'object') {
61
+ return
62
+ }
63
+
64
+ if (processed.has(obj)) {
65
+ return
66
+ }
67
+
68
+ processed.add(obj)
69
+
70
+ const [entry] =
71
+ Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
72
+ []
73
+ if (entry) {
74
+ Object.defineProperty(obj, '__constructor__', {
75
+ configurable: true,
76
+ writable: true,
77
+ enumerable: true,
78
+ value: entry,
79
+ })
80
+ }
81
+
82
+ for (const value of Object.values(obj)) {
83
+ storeConstructor(value, memfs, processed)
84
+ }
85
+ }
86
+
87
+ storeConstructor(value, memfs)
88
+
89
+ const json = JSON.stringify(value, (_, value) => {
90
+ if (typeof value === 'bigint') {
91
+ return `BigInt(${String(value)})`
92
+ }
93
+ if (value instanceof Error) {
94
+ return {
95
+ ...value,
96
+ message: value.message,
97
+ stack: value.stack,
98
+ __error__: value.constructor.name,
99
+ }
100
+ }
101
+ return value
102
+ })
103
+ const view = new TextEncoder().encode(json)
104
+ return view
105
+ }
106
+ case 9: {
107
+ return new TextEncoder().encode(String(value))
108
+ }
109
+ case -1:
110
+ default:
111
+ throw new Error('unsupported data')
112
+ }
113
+ }
114
+
115
+ /**
116
+ * @param {typeof import('memfs')} memfs
117
+ * @param {Uint8Array} payload
118
+ * @param {number} type
119
+ * @returns {any}
120
+ */
121
+ const decodeValue = (memfs, payload, type) => {
122
+ if (type === 0) return undefined
123
+ if (type === 1) return null
124
+ if (type === 2)
125
+ return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
126
+ if (type === 3)
127
+ return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
128
+ if (type === 4) return new TextDecoder().decode(payload.slice())
129
+ if (type === 6) {
130
+ const obj = JSON.parse(
131
+ new TextDecoder().decode(payload.slice()),
132
+ (_key, value) => {
133
+ if (typeof value === 'string') {
134
+ const matched = value.match(/^BigInt\((-?\d+)\)$/)
135
+ if (matched && matched[1]) {
136
+ return BigInt(matched[1])
137
+ }
138
+ }
139
+ return value
140
+ },
141
+ )
142
+
143
+ function loadConstructor(obj, memfs, processed = new WeakSet()) {
144
+ if (!obj || typeof obj !== 'object') {
145
+ return
146
+ }
147
+
148
+ if (processed.has(obj)) {
149
+ return
150
+ }
151
+
152
+ processed.add(obj)
153
+
154
+ if (obj.__constructor__) {
155
+ const ctor = obj.__constructor__
156
+ delete obj.__constructor__
157
+ Object.setPrototypeOf(obj, memfs[ctor].prototype)
158
+ }
159
+
160
+ for (const value of Object.values(obj)) {
161
+ loadConstructor(value, memfs, processed)
162
+ }
163
+ }
164
+
165
+ loadConstructor(obj, memfs)
166
+
167
+ if (obj.__error__) {
168
+ const name = obj.__error__
169
+ const ErrorConstructor = globalThis[name] || Error
170
+ delete obj.__error__
171
+ const err = new ErrorConstructor(obj.message)
172
+ Object.defineProperty(err, 'stack', {
173
+ configurable: true,
174
+ enumerable: false,
175
+ writable: true,
176
+ value: err.stack,
177
+ })
178
+ Object.defineProperty(err, Symbol.toStringTag, {
179
+ configurable: true,
180
+ enumerable: false,
181
+ writable: true,
182
+ value: name,
183
+ })
184
+ for (const [k, v] of Object.entries(obj)) {
185
+ if (k === 'message' || k === 'stack') continue
186
+ err[k] = v
187
+ }
188
+ return err
189
+ }
190
+ return obj
191
+ }
192
+ if (type === 9) {
193
+ return BigInt(new TextDecoder().decode(payload.slice()))
194
+ }
195
+ throw new Error('unsupported data')
196
+ }
197
+
198
+ /**
199
+ * @param {import('memfs').IFs} fs
200
+ * @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
201
+ */
202
+ // oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
203
+ export const createOnMessage = (fs) =>
204
+ function onMessage(e) {
205
+ if (e.data.__fs__) {
206
+ /**
207
+ * 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
208
+ * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
209
+ * 9..16 payload_size(uint32_t) <= 10240
210
+ * 16..16 + payload_size payload_content
211
+ */
212
+ const { sab, type, payload } = e.data.__fs__
213
+ const fn = fs[type]
214
+ try {
215
+ const ret = fn.apply(fs, payload)
216
+ const t = getType(ret)
217
+ Atomics.store(sab, 1, t)
218
+ const v = encodeValue(fs, ret, t)
219
+ Atomics.store(sab, 2, v.length)
220
+ writeResponsePayload(sab, v)
221
+ Atomics.store(sab, 0, 0) // success
222
+ } catch (/** @type {any} */ err) {
223
+ let t = getType(err)
224
+ let v
225
+ try {
226
+ if (t === -1) {
227
+ throw new Error('unsupported data')
228
+ }
229
+ v = encodeValue(fs, err, t)
230
+ } catch {
231
+ const fallback = (() => {
232
+ try {
233
+ return String(err)
234
+ } catch {
235
+ return 'Unserializable thrown value'
236
+ }
237
+ })()
238
+ t = getType(fallback)
239
+ v = encodeValue(fs, fallback, t)
240
+ }
241
+ if (v.length > RESPONSE_PAYLOAD_SIZE) {
242
+ const overflowErr = new RangeError('payload overflow')
243
+ t = getType(overflowErr)
244
+ v = encodeValue(fs, overflowErr, t)
245
+ }
246
+ Atomics.store(sab, 1, t)
247
+ Atomics.store(sab, 2, v.length)
248
+ writeResponsePayload(sab, v)
249
+ Atomics.store(sab, 0, 1) // error
250
+ } finally {
251
+ Atomics.notify(sab, 0)
252
+ }
253
+ }
254
+ }
255
+
256
+ /**
257
+ * @param {typeof import('memfs')} memfs
258
+ */
259
+ export const createFsProxy = (memfs) =>
260
+ new Proxy(
261
+ {},
262
+ {
263
+ get(_target, p, _receiver) {
264
+ /**
265
+ * @param {any[]} args
266
+ */
267
+ return function (...args) {
268
+ const sab = new SharedArrayBuffer(RESPONSE_BUFFER_SIZE)
269
+ const i32arr = new Int32Array(sab)
270
+ Atomics.store(i32arr, 0, 21)
271
+
272
+ postMessage({
273
+ __fs__: {
274
+ sab: i32arr,
275
+ type: p,
276
+ payload: args,
277
+ },
278
+ })
279
+
280
+ Atomics.wait(i32arr, 0, 21)
281
+
282
+ const status = Atomics.load(i32arr, 0)
283
+ const type = Atomics.load(i32arr, 1)
284
+ const size = Atomics.load(i32arr, 2)
285
+ const content = new Uint8Array(sab, RESPONSE_HEADER_SIZE, size)
286
+ const value = decodeValue(memfs, content, type)
287
+ if (status === 1) {
288
+ throw value
289
+ }
290
+ return value
291
+ }
292
+ },
293
+ },
294
+ )
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@napi-rs/wasm-runtime",
3
- "version": "0.2.11",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "Runtime and polyfill for wasm targets",
6
+ "homepage": "https://napi.rs/",
6
7
  "author": {
7
8
  "name": "LongYinan",
8
9
  "url": "https://github.com/Brooooooklyn"
@@ -10,7 +11,7 @@
10
11
  "repository": {
11
12
  "type": "git",
12
13
  "url": "git+https://github.com/napi-rs/napi-rs.git",
13
- "directory": "wasi-runtime"
14
+ "directory": "wasm-runtime"
14
15
  },
15
16
  "license": "MIT",
16
17
  "publishConfig": {
@@ -19,43 +20,51 @@
19
20
  },
20
21
  "files": [
21
22
  "runtime.cjs",
22
- "fs-proxy.cjs",
23
+ "runtime.js",
24
+ "fs-proxy.js",
25
+ "dist/*.cjs",
23
26
  "dist/*.js"
24
27
  ],
25
28
  "devDependencies": {
26
- "@rollup/plugin-alias": "^5.1.1",
27
- "@rollup/plugin-commonjs": "^28.0.3",
29
+ "@rollup/plugin-alias": "^6.0.0",
30
+ "@rollup/plugin-commonjs": "^29.0.0",
28
31
  "@rollup/plugin-inject": "^5.0.5",
29
32
  "@rollup/plugin-json": "^6.1.0",
30
- "@rollup/plugin-node-resolve": "^16.0.1",
31
- "@rollup/plugin-replace": "^6.0.2",
33
+ "@rollup/plugin-node-resolve": "^16.0.3",
34
+ "@rollup/plugin-replace": "^6.0.3",
32
35
  "buffer": "^6.0.3",
33
- "memfs": "^4.17.0",
34
- "node-inspect-extracted": "^3.0.2",
36
+ "events": "^3.3.0",
37
+ "memfs": "^4.50.0",
38
+ "node-inspect-extracted": "^3.2.2",
35
39
  "path-browserify": "^1.0.1",
36
40
  "process": "^0.11.10",
37
41
  "readable-stream": "^4.7.0",
38
- "rollup": "^4.38.0",
42
+ "rollup": "^4.53.1",
39
43
  "rollup-plugin-polyfill-node": "^0.13.0",
40
44
  "tslib": "^2.8.1"
41
45
  },
42
46
  "dependencies": {
43
- "@emnapi/core": "^1.4.3",
44
- "@emnapi/runtime": "^1.4.3",
45
- "@tybys/wasm-util": "^0.9.0"
47
+ "@tybys/wasm-util": "^0.10.1"
48
+ },
49
+ "peerDependencies": {
50
+ "@emnapi/core": "^1.7.1",
51
+ "@emnapi/runtime": "^1.7.1"
46
52
  },
47
53
  "scripts": {
48
54
  "build": "rollup -c rollup.config.js",
49
55
  "test": "node --test"
50
56
  },
57
+ "funding": {
58
+ "type": "github",
59
+ "url": "https://github.com/sponsors/Brooooooklyn"
60
+ },
51
61
  "exports": {
52
62
  ".": {
53
- "import": "./dist/runtime.js",
63
+ "import": "./runtime.js",
54
64
  "require": "./runtime.cjs"
55
65
  },
56
66
  "./fs": {
57
67
  "import": "./dist/fs.js"
58
68
  }
59
- },
60
- "gitHead": "984d166275f29e24e4bcf9d6189fe9bbe2e96bfe"
69
+ }
61
70
  }
@@ -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,
@@ -0,0 +1,8 @@
1
+ export {
2
+ instantiateNapiModuleSync,
3
+ instantiateNapiModule,
4
+ MessageHandler,
5
+ } from '@emnapi/core'
6
+ export { getDefaultContext } from '@emnapi/runtime'
7
+ export * from '@tybys/wasm-util'
8
+ export { createOnMessage, createFsProxy } from './fs-proxy.js'
@@ -111,6 +111,11 @@ export declare interface FileHandle {
111
111
  close(): Promise<void>;
112
112
  }
113
113
 
114
+ /** @public */
115
+ export declare interface FinalizeBindingsOptions {
116
+ memory?: WebAssembly.Memory;
117
+ }
118
+
114
119
  /** @public */
115
120
  export declare interface IDirent {
116
121
  isFile(): boolean;
@@ -375,6 +380,7 @@ export declare class WASI {
375
380
  private [kBindingName];
376
381
  readonly wasiImport: Record<string, any>;
377
382
  constructor(options?: SyncWASIOptions);
383
+ finalizeBindings(instance: WebAssembly.Instance, { memory }?: FinalizeBindingsOptions): void;
378
384
  start(instance: WebAssembly.Instance): number | undefined | Promise<number> | Promise<undefined>;
379
385
  initialize(instance: WebAssembly.Instance): void | Promise<void>;
380
386
  getImportObject(): Record<string, Record<string, any>>;