@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.fc4afc2 → 0.0.0-insiders.ff9f183

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 (30) hide show
  1. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +3 -3
  2. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -1
  3. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +3 -3
  4. package/node_modules/@emnapi/core/dist/emnapi-core.js +4 -4
  5. package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -1
  6. package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -1
  7. package/node_modules/@emnapi/core/dist/emnapi-core.mjs +3 -3
  8. package/node_modules/@emnapi/core/package.json +2 -2
  9. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +7 -3
  10. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -1
  11. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +7 -3
  12. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +7 -3
  13. package/node_modules/@emnapi/runtime/dist/emnapi.js +7 -3
  14. package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -1
  15. package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -1
  16. package/node_modules/@emnapi/runtime/dist/emnapi.mjs +7 -3
  17. package/node_modules/@emnapi/runtime/package.json +1 -1
  18. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +3 -3
  19. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -1
  20. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +3 -3
  21. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +3 -3
  22. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -1
  23. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -1
  24. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +3 -3
  25. package/node_modules/@emnapi/wasi-threads/package.json +1 -1
  26. package/node_modules/@napi-rs/wasm-runtime/dist/runtime.js +78 -62
  27. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.cjs +77 -61
  28. package/node_modules/@napi-rs/wasm-runtime/package.json +4 -3
  29. package/package.json +5 -5
  30. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
@@ -55,6 +55,14 @@ const encodeValue = (memfs, value, type) => {
55
55
  if (typeof value === 'bigint') {
56
56
  return `BigInt(${String(value)})`
57
57
  }
58
+ if (value instanceof Error) {
59
+ return {
60
+ ...value,
61
+ message: value.message,
62
+ stack: value.stack,
63
+ __error__: value.constructor.name,
64
+ }
65
+ }
58
66
  return value
59
67
  })
60
68
  const view = new TextEncoder().encode(json)
@@ -71,6 +79,62 @@ const encodeValue = (memfs, value, type) => {
71
79
  }
72
80
  }
73
81
 
82
+ /**
83
+ * @param {typeof import('memfs')} memfs
84
+ * @param {Uint8Array} payload
85
+ * @param {number} type
86
+ * @returns {any}
87
+ */
88
+ const decodeValue = (memfs, payload, type) => {
89
+ if (type === 0) return undefined
90
+ if (type === 1) return null
91
+ if (type === 2) return Boolean(payload[0])
92
+ if (type === 3) return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
93
+ if (type === 4) return new TextDecoder().decode(payload.slice())
94
+ if (type === 6) {
95
+ const obj = JSON.parse(new TextDecoder().decode(payload.slice()), (_key, value) => {
96
+ if (typeof value === 'string') {
97
+ const matched = value.match(/^BigInt\((-?\d+)\)$/)
98
+ if (matched && matched[1]) {
99
+ return BigInt(matched[1])
100
+ }
101
+ }
102
+ return value
103
+ })
104
+ if (obj.__constructor__) {
105
+ const ctor = obj.__constructor__
106
+ delete obj.__constructor__
107
+ Object.setPrototypeOf(obj, memfs[ctor].prototype)
108
+ }
109
+ if (obj.__error__) {
110
+ const name = obj.__error__
111
+ const ErrorConstructor = globalThis[name] || Error
112
+ delete obj.__error__
113
+ const err = new ErrorConstructor(obj.message)
114
+ Object.defineProperty(err, 'stack', {
115
+ configurable: true,
116
+ enumerable: false,
117
+ writable: true,
118
+ value: err.stack
119
+ })
120
+ Object.defineProperty(err, Symbol.toStringTag, {
121
+ configurable: true,
122
+ enumerable: false,
123
+ writable: true,
124
+ value: name
125
+ })
126
+ for (const [k, v] of Object.entries(obj)) {
127
+ if (k === 'message' || k === 'stack') continue
128
+ err[k] = v
129
+ }
130
+ return err
131
+ }
132
+ return obj
133
+ }
134
+ if (type === 9) return new BigInt64Array(payload.buffer, payload.byteOffset, 1)[0]
135
+ throw new Error('unsupported data')
136
+ }
137
+
74
138
  /**
75
139
  * @param {import('memfs').IFs} fs
76
140
  * @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
@@ -86,33 +150,22 @@ module.exports.createOnMessage = (fs) => function onMessage(e) {
86
150
  */
87
151
  const { sab, type, payload } = e.data.__fs__
88
152
  const fn = fs[type]
89
- const args = payload ? payload.map((value) => {
90
- if (value instanceof Uint8Array) {
91
- // buffer polyfill bug
92
- // @ts-expect-error
93
- value._isBuffer = true
94
- }
95
- return value
96
- }) : payload
97
153
  try {
98
- const ret = fn.apply(fs, args)
99
- const t = getType(ret)
100
- const v = encodeValue(fs, ret, t)
154
+ const ret = fn.apply(fs, payload)
101
155
  Atomics.store(sab, 0, 0)
156
+ const t = getType(ret)
102
157
  Atomics.store(sab, 1, t)
158
+ const v = encodeValue(fs, ret, t)
103
159
  Atomics.store(sab, 2, v.length)
104
160
  new Uint8Array(sab.buffer).set(v, 16)
105
161
 
106
162
  } catch (/** @type {any} */ err) {
107
163
  Atomics.store(sab, 0, 1)
108
- Atomics.store(sab, 1, 6)
109
- const payloadContent = new TextEncoder().encode(JSON.stringify({
110
- ...err,
111
- message: err.message,
112
- stack: err.stack
113
- }))
114
- Atomics.store(sab, 2, payloadContent.length)
115
- new Uint8Array(sab.buffer).set(payloadContent, 16)
164
+ const t = getType(err)
165
+ Atomics.store(sab, 1, t)
166
+ const v = encodeValue(fs, err, t)
167
+ Atomics.store(sab, 2, v.length)
168
+ new Uint8Array(sab.buffer).set(v, 16)
116
169
  } finally {
117
170
  Atomics.notify(sab, 0)
118
171
  }
@@ -120,7 +173,7 @@ module.exports.createOnMessage = (fs) => function onMessage(e) {
120
173
  }
121
174
 
122
175
  /**
123
- * @param {import('memfs').IFs} memfs
176
+ * @param {typeof import('memfs')} memfs
124
177
  */
125
178
  module.exports.createFsProxy = (memfs) => new Proxy({}, {
126
179
  get (_target, p, _receiver) {
@@ -128,11 +181,10 @@ module.exports.createFsProxy = (memfs) => new Proxy({}, {
128
181
  * @param {any[]} args
129
182
  */
130
183
  return function (...args) {
131
- const sab = new SharedArrayBuffer(16 + 1024)
184
+ const sab = new SharedArrayBuffer(16 + 10240)
132
185
  const i32arr = new Int32Array(sab)
133
186
  Atomics.store(i32arr, 0, 21)
134
187
 
135
- // @ts-expect-error
136
188
  postMessage({
137
189
  __fs__: {
138
190
  sab: i32arr,
@@ -147,47 +199,11 @@ module.exports.createFsProxy = (memfs) => new Proxy({}, {
147
199
  const type = Atomics.load(i32arr, 1)
148
200
  const size = Atomics.load(i32arr, 2)
149
201
  const content = new Uint8Array(sab, 16, size)
202
+ const value = decodeValue(memfs, content, type)
150
203
  if (status === 1) {
151
- const errobj = JSON.parse(new TextDecoder().decode(content.slice()))
152
- const err = new Error(errobj.message)
153
- Object.defineProperty(err, 'stack', {
154
- configurable: true,
155
- enumerable: false,
156
- writable: true,
157
- value: errobj.stack
158
- })
159
- for (const [k, v] of Object.entries(errobj)) {
160
- if (k === 'message' || k === 'stack') continue
161
- // @ts-expect-error
162
- err[k] = v
163
- }
164
- throw err
165
- }
166
- if (type === 0) return undefined
167
- if (type === 1) return null
168
- if (type === 2) return Boolean(content[0])
169
- if (type === 3) return new Float64Array(sab, 16, 1)[0]
170
- if (type === 4) return new TextDecoder().decode(content.slice())
171
- if (type === 6) {
172
- const obj = JSON.parse(new TextDecoder().decode(content.slice()), (_key, value) => {
173
- if (typeof value === 'string') {
174
- const matched = value.match(/^BigInt\((-?\d+)\)$/)
175
- if (matched && matched[1]) {
176
- return BigInt(matched[1])
177
- }
178
- }
179
- return value
180
- })
181
- if (obj.__constructor__) {
182
- const ctor = obj.__constructor__
183
- delete obj.__constructor__
184
- // @ts-expect-error
185
- Object.setPrototypeOf(obj, memfs[ctor].prototype)
186
- }
187
- return obj
204
+ throw value
188
205
  }
189
- if (type === 9) return new BigInt64Array(sab, 16, 1)[0]
190
- throw new Error('unsupported data')
206
+ return value
191
207
  }
192
208
  }
193
209
  })
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@napi-rs/wasm-runtime",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "type": "module",
5
5
  "description": "Runtime and polyfill for wasm targets",
6
6
  "author": {
@@ -45,7 +45,8 @@
45
45
  "@tybys/wasm-util": "^0.9.0"
46
46
  },
47
47
  "scripts": {
48
- "build": "rollup -c rollup.config.js"
48
+ "build": "rollup -c rollup.config.js",
49
+ "test": "node --test"
49
50
  },
50
51
  "exports": {
51
52
  ".": {
@@ -56,5 +57,5 @@
56
57
  "import": "./dist/fs.js"
57
58
  }
58
59
  },
59
- "gitHead": "6ce13931967f9413ed3312a210a20418b8d6773f"
60
+ "gitHead": "84209fc82931e8c6ef93e61e4a0e1d1a0ffaf511"
60
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailwindcss/oxide-wasm32-wasi",
3
- "version": "0.0.0-insiders.fc4afc2",
3
+ "version": "0.0.0-insiders.ff9f183",
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": "^0.2.8",
31
- "@emnapi/core": "^1.4.0",
32
- "@emnapi/runtime": "^1.4.0",
30
+ "@napi-rs/wasm-runtime": "^0.2.9",
31
+ "@emnapi/core": "^1.4.3",
32
+ "@emnapi/runtime": "^1.4.3",
33
33
  "@tybys/wasm-util": "^0.9.0",
34
- "@emnapi/wasi-threads": "^1.0.1",
34
+ "@emnapi/wasi-threads": "^1.0.2",
35
35
  "tslib": "^2.8.0"
36
36
  },
37
37
  "bundledDependencies": [
Binary file