@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.00ef99d

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 (115) hide show
  1. package/README.md +3 -0
  2. package/node_modules/@emnapi/core/LICENSE +21 -0
  3. package/node_modules/@emnapi/core/README.md +1 -0
  4. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +7746 -0
  5. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +428 -0
  6. package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -0
  7. package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +428 -0
  8. package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +430 -0
  9. package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +8741 -0
  10. package/node_modules/@emnapi/core/dist/emnapi-core.js +9777 -0
  11. package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +428 -0
  12. package/node_modules/@emnapi/core/dist/emnapi-core.min.js +1 -0
  13. package/node_modules/@emnapi/core/dist/emnapi-core.min.mjs +1 -0
  14. package/node_modules/@emnapi/core/dist/emnapi-core.mjs +7735 -0
  15. package/node_modules/@emnapi/core/index.js +5 -0
  16. package/node_modules/@emnapi/core/package.json +49 -0
  17. package/node_modules/@emnapi/runtime/LICENSE +21 -0
  18. package/node_modules/@emnapi/runtime/README.md +1 -0
  19. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +1398 -0
  20. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +671 -0
  21. package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -0
  22. package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +671 -0
  23. package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +673 -0
  24. package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +1457 -0
  25. package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +426 -0
  26. package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +1528 -0
  27. package/node_modules/@emnapi/runtime/dist/emnapi.js +1529 -0
  28. package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +671 -0
  29. package/node_modules/@emnapi/runtime/dist/emnapi.min.js +1 -0
  30. package/node_modules/@emnapi/runtime/dist/emnapi.min.mjs +1 -0
  31. package/node_modules/@emnapi/runtime/dist/emnapi.mjs +1367 -0
  32. package/node_modules/@emnapi/runtime/index.js +5 -0
  33. package/node_modules/@emnapi/runtime/package.json +48 -0
  34. package/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
  35. package/node_modules/@emnapi/wasi-threads/README.md +203 -0
  36. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +915 -0
  37. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +271 -0
  38. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.js +1 -0
  39. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.mts +271 -0
  40. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +273 -0
  41. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +975 -0
  42. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +987 -0
  43. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +271 -0
  44. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.js +1 -0
  45. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.mjs +1 -0
  46. package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.mjs +910 -0
  47. package/node_modules/@emnapi/wasi-threads/index.js +5 -0
  48. package/node_modules/@emnapi/wasi-threads/package.json +50 -0
  49. package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1826 -0
  50. package/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1823 -0
  51. package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +321 -0
  52. package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +25524 -0
  53. package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +316 -0
  54. package/node_modules/@napi-rs/wasm-runtime/package.json +74 -0
  55. package/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
  56. package/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
  57. package/node_modules/@tybys/wasm-util/README.md +193 -0
  58. package/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
  59. package/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
  60. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
  61. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
  62. package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
  63. package/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
  64. package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
  65. package/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
  66. package/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
  67. package/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
  68. package/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
  69. package/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
  70. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
  71. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
  72. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
  73. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
  74. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
  75. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
  76. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
  77. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
  78. package/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
  79. package/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
  80. package/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
  81. package/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
  82. package/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
  83. package/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
  84. package/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
  85. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
  86. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
  87. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
  88. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
  89. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
  90. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
  91. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
  92. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
  93. package/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
  94. package/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
  95. package/node_modules/@tybys/wasm-util/package.json +58 -0
  96. package/node_modules/tslib/CopyrightNotice.txt +15 -0
  97. package/node_modules/tslib/LICENSE.txt +12 -0
  98. package/node_modules/tslib/README.md +164 -0
  99. package/node_modules/tslib/SECURITY.md +41 -0
  100. package/node_modules/tslib/modules/index.d.ts +38 -0
  101. package/node_modules/tslib/modules/index.js +70 -0
  102. package/node_modules/tslib/modules/package.json +3 -0
  103. package/node_modules/tslib/package.json +47 -0
  104. package/node_modules/tslib/tslib.d.ts +460 -0
  105. package/node_modules/tslib/tslib.es6.html +1 -0
  106. package/node_modules/tslib/tslib.es6.js +402 -0
  107. package/node_modules/tslib/tslib.es6.mjs +401 -0
  108. package/node_modules/tslib/tslib.html +1 -0
  109. package/node_modules/tslib/tslib.js +484 -0
  110. package/package.json +42 -0
  111. package/tailwindcss-oxide.wasi-browser.js +67 -0
  112. package/tailwindcss-oxide.wasi.cjs +123 -0
  113. package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
  114. package/wasi-worker-browser.mjs +41 -0
  115. package/wasi-worker.mjs +72 -0
@@ -0,0 +1,321 @@
1
+ 'use strict';
2
+
3
+ // @ts-check
4
+
5
+ /**
6
+ * @param {unknown} value
7
+ */
8
+ const getType = (value) => {
9
+ if (value === undefined) return 0
10
+ if (value === null) return 1
11
+ if (isBuffer(value)) return 10
12
+ const t = typeof value;
13
+ if (t === 'boolean') return 2
14
+ if (t === 'number') return 3
15
+ if (t === 'string') return 4
16
+ if (t === 'object') return 6
17
+ if (t === 'bigint') return 9
18
+ return -1
19
+ };
20
+
21
+ /**
22
+ * @param {unknown} value
23
+ * @returns {value is Uint8Array}
24
+ */
25
+ const isBuffer = (value) => {
26
+ const BufferCtor = globalThis.Buffer;
27
+ if (typeof BufferCtor?.isBuffer === 'function') {
28
+ return BufferCtor.isBuffer(value)
29
+ }
30
+ return value instanceof Uint8Array && value.constructor?.name === 'Buffer'
31
+ };
32
+
33
+ const RESPONSE_HEADER_SIZE = 16;
34
+ const RESPONSE_PAYLOAD_SIZE = 10240;
35
+ const RESPONSE_BUFFER_SIZE = RESPONSE_HEADER_SIZE + RESPONSE_PAYLOAD_SIZE;
36
+
37
+ /**
38
+ * @param {Int32Array} sab
39
+ * @param {Uint8Array} payload
40
+ */
41
+ const writeResponsePayload = (sab, payload) => {
42
+ if (payload.length > RESPONSE_PAYLOAD_SIZE) {
43
+ throw new RangeError('payload overflow')
44
+ }
45
+ new Uint8Array(sab.buffer).set(payload, RESPONSE_HEADER_SIZE);
46
+ };
47
+
48
+ /**
49
+ * @param {import('memfs').IFs} memfs
50
+ * @param {any} value
51
+ * @param {ReturnType<typeof getType>} type
52
+ * @returns {Uint8Array}
53
+ */
54
+ const encodeValue = (memfs, value, type) => {
55
+ switch (type) {
56
+ case 0:
57
+ case 1:
58
+ return new Uint8Array(0)
59
+ case 2: {
60
+ const view = new Int32Array(1);
61
+ view[0] = value ? 1 : 0;
62
+ return new Uint8Array(view.buffer)
63
+ }
64
+ case 3: {
65
+ const view = new Float64Array(1);
66
+ view[0] = value;
67
+ return new Uint8Array(view.buffer)
68
+ }
69
+ case 4: {
70
+ const view = new TextEncoder().encode(value);
71
+ return view
72
+ }
73
+ case 10:
74
+ return new Uint8Array(value)
75
+ case 6: {
76
+ function storeConstructor(obj, memfs, processed = new WeakSet()) {
77
+ if (!obj || typeof obj !== 'object') {
78
+ return
79
+ }
80
+
81
+ if (processed.has(obj)) {
82
+ return
83
+ }
84
+
85
+ processed.add(obj);
86
+
87
+ const [entry] =
88
+ Object.entries(memfs).filter(([_, v]) => v === obj.constructor)[0] ??
89
+ [];
90
+ if (entry) {
91
+ Object.defineProperty(obj, '__constructor__', {
92
+ configurable: true,
93
+ writable: true,
94
+ enumerable: true,
95
+ value: entry,
96
+ });
97
+ }
98
+
99
+ for (const value of Object.values(obj)) {
100
+ storeConstructor(value, memfs, processed);
101
+ }
102
+ }
103
+
104
+ storeConstructor(value, memfs);
105
+
106
+ const json = JSON.stringify(value, (_, value) => {
107
+ if (typeof value === 'bigint') {
108
+ return `BigInt(${String(value)})`
109
+ }
110
+ if (value instanceof Error) {
111
+ return {
112
+ ...value,
113
+ message: value.message,
114
+ stack: value.stack,
115
+ __error__: value.constructor.name,
116
+ }
117
+ }
118
+ return value
119
+ });
120
+ const view = new TextEncoder().encode(json);
121
+ return view
122
+ }
123
+ case 9: {
124
+ return new TextEncoder().encode(String(value))
125
+ }
126
+ case -1:
127
+ default:
128
+ throw new Error('unsupported data')
129
+ }
130
+ };
131
+
132
+ /**
133
+ * @param {typeof import('memfs')} memfs
134
+ * @param {Uint8Array} payload
135
+ * @param {number} type
136
+ * @returns {any}
137
+ */
138
+ const decodeValue = (memfs, payload, type) => {
139
+ if (type === 0) return undefined
140
+ if (type === 1) return null
141
+ if (type === 2)
142
+ return Boolean(new Int32Array(payload.buffer, payload.byteOffset, 1)[0])
143
+ if (type === 3)
144
+ return new Float64Array(payload.buffer, payload.byteOffset, 1)[0]
145
+ if (type === 4) return new TextDecoder().decode(payload.slice())
146
+ if (type === 10) {
147
+ const BufferCtor = globalThis.Buffer;
148
+ if (typeof BufferCtor?.from === 'function') {
149
+ return BufferCtor.from(payload)
150
+ }
151
+ return payload.slice()
152
+ }
153
+ if (type === 6) {
154
+ const obj = JSON.parse(
155
+ new TextDecoder().decode(payload.slice()),
156
+ (_key, value) => {
157
+ if (typeof value === 'string') {
158
+ const matched = value.match(/^BigInt\((-?\d+)\)$/);
159
+ if (matched && matched[1]) {
160
+ return BigInt(matched[1])
161
+ }
162
+ }
163
+ return value
164
+ },
165
+ );
166
+
167
+ function loadConstructor(obj, memfs, processed = new WeakSet()) {
168
+ if (!obj || typeof obj !== 'object') {
169
+ return
170
+ }
171
+
172
+ if (processed.has(obj)) {
173
+ return
174
+ }
175
+
176
+ processed.add(obj);
177
+
178
+ if (obj.__constructor__) {
179
+ const ctor = obj.__constructor__;
180
+ delete obj.__constructor__;
181
+ Object.setPrototypeOf(obj, memfs[ctor].prototype);
182
+ }
183
+
184
+ for (const value of Object.values(obj)) {
185
+ loadConstructor(value, memfs, processed);
186
+ }
187
+ }
188
+
189
+ loadConstructor(obj, memfs);
190
+
191
+ if (obj.__error__) {
192
+ const name = obj.__error__;
193
+ const ErrorConstructor = globalThis[name] || Error;
194
+ delete obj.__error__;
195
+ const err = new ErrorConstructor(obj.message);
196
+ Object.defineProperty(err, 'stack', {
197
+ configurable: true,
198
+ enumerable: false,
199
+ writable: true,
200
+ value: err.stack,
201
+ });
202
+ Object.defineProperty(err, Symbol.toStringTag, {
203
+ configurable: true,
204
+ enumerable: false,
205
+ writable: true,
206
+ value: name,
207
+ });
208
+ for (const [k, v] of Object.entries(obj)) {
209
+ if (k === 'message' || k === 'stack') continue
210
+ err[k] = v;
211
+ }
212
+ return err
213
+ }
214
+ return obj
215
+ }
216
+ if (type === 9) {
217
+ return BigInt(new TextDecoder().decode(payload.slice()))
218
+ }
219
+ throw new Error('unsupported data')
220
+ };
221
+
222
+ /**
223
+ * @param {import('memfs').IFs} fs
224
+ * @returns {(e: { data: { __fs__: { sab: Int32Array, type: keyof import('memfs').IFs, payload: any[] } } }) => void}
225
+ */
226
+ // oxlint-disable-next-line no-unused-vars -- fixed in an upcoming release
227
+ const createOnMessage = (fs) =>
228
+ function onMessage(e) {
229
+ if (e.data.__fs__) {
230
+ /**
231
+ * 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
232
+ * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) 10(buffer) -1(unsupported)
233
+ * 9..16 payload_size(uint32_t) <= 10240
234
+ * 16..16 + payload_size payload_content
235
+ */
236
+ const { sab, type, payload } = e.data.__fs__;
237
+ const fn = fs[type];
238
+ try {
239
+ const ret = fn.apply(fs, payload);
240
+ const t = getType(ret);
241
+ Atomics.store(sab, 1, t);
242
+ const v = encodeValue(fs, ret, t);
243
+ Atomics.store(sab, 2, v.length);
244
+ writeResponsePayload(sab, v);
245
+ Atomics.store(sab, 0, 0); // success
246
+ } catch (/** @type {any} */ err) {
247
+ let t = getType(err);
248
+ let v;
249
+ try {
250
+ if (t === -1) {
251
+ throw new Error('unsupported data')
252
+ }
253
+ v = encodeValue(fs, err, t);
254
+ } catch {
255
+ const fallback = (() => {
256
+ try {
257
+ return String(err)
258
+ } catch {
259
+ return 'Unserializable thrown value'
260
+ }
261
+ })();
262
+ t = getType(fallback);
263
+ v = encodeValue(fs, fallback, t);
264
+ }
265
+ if (v.length > RESPONSE_PAYLOAD_SIZE) {
266
+ const overflowErr = new RangeError('payload overflow');
267
+ t = getType(overflowErr);
268
+ v = encodeValue(fs, overflowErr, t);
269
+ }
270
+ Atomics.store(sab, 1, t);
271
+ Atomics.store(sab, 2, v.length);
272
+ writeResponsePayload(sab, v);
273
+ Atomics.store(sab, 0, 1); // error
274
+ } finally {
275
+ Atomics.notify(sab, 0);
276
+ }
277
+ }
278
+ };
279
+
280
+ /**
281
+ * @param {typeof import('memfs')} memfs
282
+ */
283
+ const createFsProxy = (memfs) =>
284
+ new Proxy(
285
+ {},
286
+ {
287
+ get(_target, p, _receiver) {
288
+ /**
289
+ * @param {any[]} args
290
+ */
291
+ return function (...args) {
292
+ const sab = new SharedArrayBuffer(RESPONSE_BUFFER_SIZE);
293
+ const i32arr = new Int32Array(sab);
294
+ Atomics.store(i32arr, 0, 21);
295
+
296
+ postMessage({
297
+ __fs__: {
298
+ sab: i32arr,
299
+ type: p,
300
+ payload: args,
301
+ },
302
+ });
303
+
304
+ Atomics.wait(i32arr, 0, 21);
305
+
306
+ const status = Atomics.load(i32arr, 0);
307
+ const type = Atomics.load(i32arr, 1);
308
+ const size = Atomics.load(i32arr, 2);
309
+ const content = new Uint8Array(sab, RESPONSE_HEADER_SIZE, size);
310
+ const value = decodeValue(memfs, content, type);
311
+ if (status === 1) {
312
+ throw value
313
+ }
314
+ return value
315
+ }
316
+ },
317
+ },
318
+ );
319
+
320
+ exports.createFsProxy = createFsProxy;
321
+ exports.createOnMessage = createOnMessage;