@tailwindcss/oxide-wasm32-wasi 4.2.3 → 4.3.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.
Files changed (47) hide show
  1. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +854 -307
  2. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +3 -2
  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 +3 -2
  5. package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +3 -2
  6. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +892 -313
  7. package/node_modules/@emnapi/core/dist/emnapi-core.js +904 -328
  8. package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +3 -2
  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 +854 -307
  12. package/node_modules/@emnapi/core/package.json +2 -2
  13. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +32 -5
  14. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +8 -2
  15. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -1
  16. package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +8 -2
  17. package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +8 -2
  18. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +33 -5
  19. package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +8 -2
  20. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +33 -5
  21. package/node_modules/@emnapi/runtime/dist/emnapi.js +33 -5
  22. package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +8 -2
  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 +32 -5
  26. package/node_modules/@emnapi/runtime/package.json +1 -1
  27. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +17 -20
  28. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +2 -0
  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 +2 -0
  31. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +2 -0
  32. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +17 -20
  33. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +17 -20
  34. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +2 -0
  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 +17 -20
  38. package/node_modules/@emnapi/wasi-threads/package.json +1 -1
  39. package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +47 -12
  40. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +14310 -10201
  41. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +47 -12
  42. package/node_modules/@napi-rs/wasm-runtime/package.json +6 -4
  43. package/package.json +5 -5
  44. package/tailwindcss-oxide.wasi-browser.js +1 -0
  45. package/tailwindcss-oxide.wasi.cjs +1 -1
  46. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
  47. package/wasi-worker-browser.mjs +4 -0
@@ -15,6 +15,21 @@ const getType = (value) => {
15
15
  return -1
16
16
  }
17
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
+
18
33
  /**
19
34
  * @param {import('memfs').IFs} memfs
20
35
  * @param {any} value
@@ -89,9 +104,7 @@ const encodeValue = (memfs, value, type) => {
89
104
  return view
90
105
  }
91
106
  case 9: {
92
- const view = new BigInt64Array(1)
93
- view[0] = value
94
- return new Uint8Array(view.buffer)
107
+ return new TextEncoder().encode(String(value))
95
108
  }
96
109
  case -1:
97
110
  default:
@@ -176,8 +189,9 @@ const decodeValue = (memfs, payload, type) => {
176
189
  }
177
190
  return obj
178
191
  }
179
- if (type === 9)
180
- return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
192
+ if (type === 9) {
193
+ return BigInt(new TextDecoder().decode(payload.slice()))
194
+ }
181
195
  throw new Error('unsupported data')
182
196
  }
183
197
 
@@ -192,7 +206,7 @@ export const createOnMessage = (fs) =>
192
206
  /**
193
207
  * 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
194
208
  * 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
209
+ * 9..16 payload_size(uint32_t) <= 10240
196
210
  * 16..16 + payload_size payload_content
197
211
  */
198
212
  const { sab, type, payload } = e.data.__fs__
@@ -203,14 +217,35 @@ export const createOnMessage = (fs) =>
203
217
  Atomics.store(sab, 1, t)
204
218
  const v = encodeValue(fs, ret, t)
205
219
  Atomics.store(sab, 2, v.length)
206
- new Uint8Array(sab.buffer).set(v, 16)
220
+ writeResponsePayload(sab, v)
207
221
  Atomics.store(sab, 0, 0) // success
208
222
  } catch (/** @type {any} */ err) {
209
- const t = getType(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
+ }
210
246
  Atomics.store(sab, 1, t)
211
- const v = encodeValue(fs, err, t)
212
247
  Atomics.store(sab, 2, v.length)
213
- new Uint8Array(sab.buffer).set(v, 16)
248
+ writeResponsePayload(sab, v)
214
249
  Atomics.store(sab, 0, 1) // error
215
250
  } finally {
216
251
  Atomics.notify(sab, 0)
@@ -230,7 +265,7 @@ export const createFsProxy = (memfs) =>
230
265
  * @param {any[]} args
231
266
  */
232
267
  return function (...args) {
233
- const sab = new SharedArrayBuffer(16 + 10240)
268
+ const sab = new SharedArrayBuffer(RESPONSE_BUFFER_SIZE)
234
269
  const i32arr = new Int32Array(sab)
235
270
  Atomics.store(i32arr, 0, 21)
236
271
 
@@ -247,7 +282,7 @@ export const createFsProxy = (memfs) =>
247
282
  const status = Atomics.load(i32arr, 0)
248
283
  const type = Atomics.load(i32arr, 1)
249
284
  const size = Atomics.load(i32arr, 2)
250
- const content = new Uint8Array(sab, 16, size)
285
+ const content = new Uint8Array(sab, RESPONSE_HEADER_SIZE, size)
251
286
  const value = decodeValue(memfs, content, type)
252
287
  if (status === 1) {
253
288
  throw value
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/wasm-runtime",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "Runtime and polyfill for wasm targets",
6
6
  "homepage": "https://napi.rs/",
@@ -11,7 +11,7 @@
11
11
  "repository": {
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/napi-rs/napi-rs.git",
14
- "directory": "wasi-runtime"
14
+ "directory": "wasm-runtime"
15
15
  },
16
16
  "license": "MIT",
17
17
  "publishConfig": {
@@ -44,10 +44,12 @@
44
44
  "tslib": "^2.8.1"
45
45
  },
46
46
  "dependencies": {
47
- "@emnapi/core": "^1.7.1",
48
- "@emnapi/runtime": "^1.7.1",
49
47
  "@tybys/wasm-util": "^0.10.1"
50
48
  },
49
+ "peerDependencies": {
50
+ "@emnapi/core": "^1.7.1",
51
+ "@emnapi/runtime": "^1.7.1"
52
+ },
51
53
  "scripts": {
52
54
  "build": "rollup -c rollup.config.js",
53
55
  "test": "node --test"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailwindcss/oxide-wasm32-wasi",
3
- "version": "4.2.3",
3
+ "version": "4.3.0",
4
4
  "cpu": [
5
5
  "wasm32"
6
6
  ],
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "browser": "tailwindcss-oxide.wasi-browser.js",
29
29
  "dependencies": {
30
- "@napi-rs/wasm-runtime": "^1.1.1",
31
- "@emnapi/core": "^1.8.1",
32
- "@emnapi/runtime": "^1.8.1",
30
+ "@napi-rs/wasm-runtime": "^1.1.4",
31
+ "@emnapi/core": "^1.10.0",
32
+ "@emnapi/runtime": "^1.10.0",
33
33
  "@tybys/wasm-util": "^0.10.1",
34
- "@emnapi/wasi-threads": "^1.1.0",
34
+ "@emnapi/wasi-threads": "^1.2.1",
35
35
  "tslib": "^2.8.1"
36
36
  },
37
37
  "bundledDependencies": [
@@ -43,6 +43,7 @@ const {
43
43
  })
44
44
  worker.addEventListener('message', __wasmCreateOnMessageForFsProxy(__fs))
45
45
 
46
+
46
47
  return worker
47
48
  },
48
49
  overwriteImports(importObject) {
@@ -39,7 +39,7 @@ if (__nodeFs.existsSync(__wasmDebugFilePath)) {
39
39
  __wasmFilePath = __wasmDebugFilePath
40
40
  } else if (!__nodeFs.existsSync(__wasmFilePath)) {
41
41
  try {
42
- __wasmFilePath = __nodePath.resolve('@tailwindcss/oxide-wasm32-wasi')
42
+ __wasmFilePath = require.resolve('@tailwindcss/oxide-wasm32-wasi/tailwindcss-oxide.wasm32-wasi.wasm')
43
43
  } catch {
44
44
  throw new Error('Cannot find tailwindcss-oxide.wasm32-wasi.wasm file, and @tailwindcss/oxide-wasm32-wasi package is not installed.')
45
45
  }
Binary file
@@ -3,6 +3,8 @@ import { memfsExported as __memfsExported } from '@napi-rs/wasm-runtime/fs'
3
3
 
4
4
  const fs = createFsProxy(__memfsExported)
5
5
 
6
+ const errorOutputs = []
7
+
6
8
  const handler = new MessageHandler({
7
9
  onLoad({ wasmModule, wasmMemory }) {
8
10
  const wasi = new WASI({
@@ -17,6 +19,7 @@ const handler = new MessageHandler({
17
19
  printErr: function() {
18
20
  // eslint-disable-next-line no-console
19
21
  console.error.apply(console, arguments)
22
+
20
23
  },
21
24
  })
22
25
  return instantiateNapiModuleSync(wasmModule, {
@@ -32,6 +35,7 @@ const handler = new MessageHandler({
32
35
  },
33
36
  })
34
37
  },
38
+
35
39
  })
36
40
 
37
41
  globalThis.onmessage = function (e) {