@tailwindcss/oxide-wasm32-wasi 0.0.0-insiders.bd30a71 → 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.
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.js +1142 -373
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +3 -3
- package/node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +1 -1
- package/node_modules/@emnapi/core/dist/emnapi-core.d.mts +3 -3
- package/node_modules/@emnapi/core/dist/emnapi-core.d.ts +3 -3
- package/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +1245 -378
- package/node_modules/@emnapi/core/dist/emnapi-core.js +1271 -416
- package/node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +3 -3
- 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 +1142 -373
- package/node_modules/@emnapi/core/package.json +2 -2
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.js +32 -5
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +8 -2
- package/node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -1
- package/node_modules/@emnapi/runtime/dist/emnapi.d.mts +8 -2
- package/node_modules/@emnapi/runtime/dist/emnapi.d.ts +8 -2
- package/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js +33 -5
- package/node_modules/@emnapi/runtime/dist/emnapi.iife.d.ts +8 -2
- package/node_modules/@emnapi/runtime/dist/emnapi.iife.js +33 -5
- package/node_modules/@emnapi/runtime/dist/emnapi.js +33 -5
- package/node_modules/@emnapi/runtime/dist/emnapi.min.d.mts +8 -2
- 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 +32 -5
- package/node_modules/@emnapi/runtime/package.json +1 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.js +21 -33
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.cjs.min.d.ts +2 -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 +2 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +2 -1
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.js +21 -33
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +21 -33
- package/node_modules/@emnapi/wasi-threads/dist/wasi-threads.min.d.mts +2 -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 +21 -33
- package/node_modules/@emnapi/wasi-threads/package.json +1 -1
- package/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +47 -12
- package/node_modules/@napi-rs/wasm-runtime/dist/fs.js +14310 -10201
- package/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +47 -12
- package/node_modules/@napi-rs/wasm-runtime/package.json +6 -4
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +164 -2
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +164 -2
- package/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -1
- package/node_modules/@tybys/wasm-util/dist/wasm-util.js +164 -2
- package/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -1
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +142 -0
- package/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +22 -2
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +142 -0
- package/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +22 -2
- package/node_modules/@tybys/wasm-util/package.json +1 -1
- package/package.json +6 -6
- package/tailwindcss-oxide.wasi-browser.js +1 -0
- package/tailwindcss-oxide.wasi.cjs +1 -1
- package/tailwindcss-oxide.wasm32-wasi.wasm +0 -0
- package/wasi-worker-browser.mjs +2 -0
|
@@ -123,7 +123,6 @@ class ThreadManager {
|
|
|
123
123
|
constructor(options) {
|
|
124
124
|
var _a;
|
|
125
125
|
this.unusedWorkers = [];
|
|
126
|
-
this.runningWorkers = [];
|
|
127
126
|
this.pthreads = Object.create(null);
|
|
128
127
|
this.wasmModule = null;
|
|
129
128
|
this.wasmMemory = null;
|
|
@@ -148,6 +147,7 @@ class ThreadManager {
|
|
|
148
147
|
this._beforeLoad = options.beforeLoad;
|
|
149
148
|
}
|
|
150
149
|
this.printErr = (_a = options.printErr) !== null && _a !== void 0 ? _a : console.error.bind(console);
|
|
150
|
+
this.threadSpawn = options.threadSpawn;
|
|
151
151
|
}
|
|
152
152
|
init() {
|
|
153
153
|
if (!this._childThread) {
|
|
@@ -220,7 +220,6 @@ class ThreadManager {
|
|
|
220
220
|
delete this.pthreads[tid];
|
|
221
221
|
}
|
|
222
222
|
this.unusedWorkers.push(worker);
|
|
223
|
-
this.runningWorkers.splice(this.runningWorkers.indexOf(worker), 1);
|
|
224
223
|
delete worker.__emnapi_tid;
|
|
225
224
|
if (ENVIRONMENT_IS_NODE) {
|
|
226
225
|
worker.unref();
|
|
@@ -269,6 +268,12 @@ class ThreadManager {
|
|
|
269
268
|
this.cleanThread(worker, payload.tid);
|
|
270
269
|
}
|
|
271
270
|
}
|
|
271
|
+
else if (type === 'spawn-thread') {
|
|
272
|
+
this.threadSpawn(payload.startArg, payload.errorOrTid);
|
|
273
|
+
}
|
|
274
|
+
else if (type === 'terminate-all-threads') {
|
|
275
|
+
this.terminateAllThreads();
|
|
276
|
+
}
|
|
272
277
|
}
|
|
273
278
|
};
|
|
274
279
|
worker.onmessage = (e) => {
|
|
@@ -341,10 +346,6 @@ class ThreadManager {
|
|
|
341
346
|
}
|
|
342
347
|
else {
|
|
343
348
|
delete this.pthreads[tid];
|
|
344
|
-
const index = this.runningWorkers.indexOf(worker);
|
|
345
|
-
if (index !== -1) {
|
|
346
|
-
this.runningWorkers.splice(index, 1);
|
|
347
|
-
}
|
|
348
349
|
this.terminateWorker(worker);
|
|
349
350
|
delete worker.__emnapi_tid;
|
|
350
351
|
}
|
|
@@ -363,14 +364,14 @@ class ThreadManager {
|
|
|
363
364
|
};
|
|
364
365
|
}
|
|
365
366
|
terminateAllThreads() {
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
const runningWorkers = Object.values(this.pthreads);
|
|
368
|
+
for (let i = 0; i < runningWorkers.length; ++i) {
|
|
369
|
+
this.terminateWorker(runningWorkers[i]);
|
|
368
370
|
}
|
|
369
371
|
for (let i = 0; i < this.unusedWorkers.length; ++i) {
|
|
370
372
|
this.terminateWorker(this.unusedWorkers[i]);
|
|
371
373
|
}
|
|
372
374
|
this.unusedWorkers = [];
|
|
373
|
-
this.runningWorkers = [];
|
|
374
375
|
this.pthreads = Object.create(null);
|
|
375
376
|
this.preparePool();
|
|
376
377
|
}
|
|
@@ -512,18 +513,6 @@ class WASIThreads {
|
|
|
512
513
|
}
|
|
513
514
|
this.postMessage = postMessage;
|
|
514
515
|
const wasm64 = Boolean(options.wasm64);
|
|
515
|
-
const onMessage = (e) => {
|
|
516
|
-
if (e.data.__emnapi__) {
|
|
517
|
-
const type = e.data.__emnapi__.type;
|
|
518
|
-
const payload = e.data.__emnapi__.payload;
|
|
519
|
-
if (type === 'spawn-thread') {
|
|
520
|
-
threadSpawn(payload.startArg, payload.errorOrTid);
|
|
521
|
-
}
|
|
522
|
-
else if (type === 'terminate-all-threads') {
|
|
523
|
-
this.terminateAllThreads();
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
516
|
const threadSpawn = (startArg, errorOrTid) => {
|
|
528
517
|
var _a;
|
|
529
518
|
const EAGAIN = 6;
|
|
@@ -546,7 +535,7 @@ class WASIThreads {
|
|
|
546
535
|
}
|
|
547
536
|
if (!isNewABI) {
|
|
548
537
|
const malloc = this.wasmInstance.exports.malloc;
|
|
549
|
-
errorOrTid = wasm64 ? Number(malloc(BigInt(8))) : malloc(8);
|
|
538
|
+
errorOrTid = wasm64 ? Number(malloc(BigInt(8))) : (malloc(8) >>> 0);
|
|
550
539
|
if (!errorOrTid) {
|
|
551
540
|
return -48;
|
|
552
541
|
}
|
|
@@ -584,10 +573,9 @@ class WASIThreads {
|
|
|
584
573
|
if (!worker) {
|
|
585
574
|
throw new Error('failed to get new worker');
|
|
586
575
|
}
|
|
587
|
-
PThread.addMessageEventListener(worker, onMessage);
|
|
588
576
|
tid = PThread.markId(worker);
|
|
589
577
|
if (ENVIRONMENT_IS_NODE) {
|
|
590
|
-
worker.
|
|
578
|
+
worker.unref();
|
|
591
579
|
}
|
|
592
580
|
worker.postMessage(createMessage('start', {
|
|
593
581
|
tid,
|
|
@@ -598,10 +586,6 @@ class WASIThreads {
|
|
|
598
586
|
if (typeof waitThreadStart === 'number') {
|
|
599
587
|
const waitResult = Atomics.wait(sab, 0, 0, waitThreadStart);
|
|
600
588
|
if (waitResult === 'timed-out') {
|
|
601
|
-
try {
|
|
602
|
-
PThread.cleanThread(worker, tid, true);
|
|
603
|
-
}
|
|
604
|
-
catch (_) { }
|
|
605
589
|
throw new Error('Spawning thread timed out. Please check if the worker is created successfully and if message is handled properly in the worker.');
|
|
606
590
|
}
|
|
607
591
|
}
|
|
@@ -610,15 +594,17 @@ class WASIThreads {
|
|
|
610
594
|
}
|
|
611
595
|
const r = Atomics.load(sab, 0);
|
|
612
596
|
if (r > 1) {
|
|
613
|
-
try {
|
|
614
|
-
PThread.cleanThread(worker, tid, true);
|
|
615
|
-
}
|
|
616
|
-
catch (_) { }
|
|
617
597
|
throw deserizeErrorFromBuffer(sab.buffer);
|
|
618
598
|
}
|
|
619
599
|
}
|
|
620
600
|
}
|
|
621
601
|
catch (e) {
|
|
602
|
+
if (worker !== undefined && tid !== undefined) {
|
|
603
|
+
try {
|
|
604
|
+
PThread.cleanThread(worker, tid, true);
|
|
605
|
+
}
|
|
606
|
+
catch (_) { }
|
|
607
|
+
}
|
|
622
608
|
Atomics.store(struct, 0, 1);
|
|
623
609
|
Atomics.store(struct, 1, EAGAIN);
|
|
624
610
|
Atomics.notify(struct, 1);
|
|
@@ -632,7 +618,6 @@ class WASIThreads {
|
|
|
632
618
|
Atomics.store(struct, 0, 0);
|
|
633
619
|
Atomics.store(struct, 1, tid);
|
|
634
620
|
Atomics.notify(struct, 1);
|
|
635
|
-
PThread.runningWorkers.push(worker);
|
|
636
621
|
if (!shouldWait) {
|
|
637
622
|
worker.whenLoaded.catch((err) => {
|
|
638
623
|
delete worker.whenLoaded;
|
|
@@ -647,6 +632,9 @@ class WASIThreads {
|
|
|
647
632
|
return tid;
|
|
648
633
|
};
|
|
649
634
|
this.threadSpawn = threadSpawn;
|
|
635
|
+
if (this.PThread) {
|
|
636
|
+
this.PThread.threadSpawn = threadSpawn;
|
|
637
|
+
}
|
|
650
638
|
}
|
|
651
639
|
getImportObject() {
|
|
652
640
|
return {
|
|
@@ -17,6 +17,21 @@ const getType = (value) => {
|
|
|
17
17
|
return -1
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
const RESPONSE_HEADER_SIZE = 16;
|
|
21
|
+
const RESPONSE_PAYLOAD_SIZE = 10240;
|
|
22
|
+
const RESPONSE_BUFFER_SIZE = RESPONSE_HEADER_SIZE + RESPONSE_PAYLOAD_SIZE;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {Int32Array} sab
|
|
26
|
+
* @param {Uint8Array} payload
|
|
27
|
+
*/
|
|
28
|
+
const writeResponsePayload = (sab, payload) => {
|
|
29
|
+
if (payload.length > RESPONSE_PAYLOAD_SIZE) {
|
|
30
|
+
throw new RangeError('payload overflow')
|
|
31
|
+
}
|
|
32
|
+
new Uint8Array(sab.buffer).set(payload, RESPONSE_HEADER_SIZE);
|
|
33
|
+
};
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* @param {import('memfs').IFs} memfs
|
|
22
37
|
* @param {any} value
|
|
@@ -91,9 +106,7 @@ const encodeValue = (memfs, value, type) => {
|
|
|
91
106
|
return view
|
|
92
107
|
}
|
|
93
108
|
case 9: {
|
|
94
|
-
|
|
95
|
-
view[0] = value;
|
|
96
|
-
return new Uint8Array(view.buffer)
|
|
109
|
+
return new TextEncoder().encode(String(value))
|
|
97
110
|
}
|
|
98
111
|
case -1:
|
|
99
112
|
default:
|
|
@@ -178,8 +191,9 @@ const decodeValue = (memfs, payload, type) => {
|
|
|
178
191
|
}
|
|
179
192
|
return obj
|
|
180
193
|
}
|
|
181
|
-
if (type === 9)
|
|
182
|
-
return new
|
|
194
|
+
if (type === 9) {
|
|
195
|
+
return BigInt(new TextDecoder().decode(payload.slice()))
|
|
196
|
+
}
|
|
183
197
|
throw new Error('unsupported data')
|
|
184
198
|
};
|
|
185
199
|
|
|
@@ -194,7 +208,7 @@ const createOnMessage = (fs) =>
|
|
|
194
208
|
/**
|
|
195
209
|
* 0..4 status(int32_t): 21(waiting) 0(success) 1(error)
|
|
196
210
|
* 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported)
|
|
197
|
-
* 9..16 payload_size(uint32_t) <=
|
|
211
|
+
* 9..16 payload_size(uint32_t) <= 10240
|
|
198
212
|
* 16..16 + payload_size payload_content
|
|
199
213
|
*/
|
|
200
214
|
const { sab, type, payload } = e.data.__fs__;
|
|
@@ -205,14 +219,35 @@ const createOnMessage = (fs) =>
|
|
|
205
219
|
Atomics.store(sab, 1, t);
|
|
206
220
|
const v = encodeValue(fs, ret, t);
|
|
207
221
|
Atomics.store(sab, 2, v.length);
|
|
208
|
-
|
|
222
|
+
writeResponsePayload(sab, v);
|
|
209
223
|
Atomics.store(sab, 0, 0); // success
|
|
210
224
|
} catch (/** @type {any} */ err) {
|
|
211
|
-
|
|
225
|
+
let t = getType(err);
|
|
226
|
+
let v;
|
|
227
|
+
try {
|
|
228
|
+
if (t === -1) {
|
|
229
|
+
throw new Error('unsupported data')
|
|
230
|
+
}
|
|
231
|
+
v = encodeValue(fs, err, t);
|
|
232
|
+
} catch {
|
|
233
|
+
const fallback = (() => {
|
|
234
|
+
try {
|
|
235
|
+
return String(err)
|
|
236
|
+
} catch {
|
|
237
|
+
return 'Unserializable thrown value'
|
|
238
|
+
}
|
|
239
|
+
})();
|
|
240
|
+
t = getType(fallback);
|
|
241
|
+
v = encodeValue(fs, fallback, t);
|
|
242
|
+
}
|
|
243
|
+
if (v.length > RESPONSE_PAYLOAD_SIZE) {
|
|
244
|
+
const overflowErr = new RangeError('payload overflow');
|
|
245
|
+
t = getType(overflowErr);
|
|
246
|
+
v = encodeValue(fs, overflowErr, t);
|
|
247
|
+
}
|
|
212
248
|
Atomics.store(sab, 1, t);
|
|
213
|
-
const v = encodeValue(fs, err, t);
|
|
214
249
|
Atomics.store(sab, 2, v.length);
|
|
215
|
-
|
|
250
|
+
writeResponsePayload(sab, v);
|
|
216
251
|
Atomics.store(sab, 0, 1); // error
|
|
217
252
|
} finally {
|
|
218
253
|
Atomics.notify(sab, 0);
|
|
@@ -232,7 +267,7 @@ const createFsProxy = (memfs) =>
|
|
|
232
267
|
* @param {any[]} args
|
|
233
268
|
*/
|
|
234
269
|
return function (...args) {
|
|
235
|
-
const sab = new SharedArrayBuffer(
|
|
270
|
+
const sab = new SharedArrayBuffer(RESPONSE_BUFFER_SIZE);
|
|
236
271
|
const i32arr = new Int32Array(sab);
|
|
237
272
|
Atomics.store(i32arr, 0, 21);
|
|
238
273
|
|
|
@@ -249,7 +284,7 @@ const createFsProxy = (memfs) =>
|
|
|
249
284
|
const status = Atomics.load(i32arr, 0);
|
|
250
285
|
const type = Atomics.load(i32arr, 1);
|
|
251
286
|
const size = Atomics.load(i32arr, 2);
|
|
252
|
-
const content = new Uint8Array(sab,
|
|
287
|
+
const content = new Uint8Array(sab, RESPONSE_HEADER_SIZE, size);
|
|
253
288
|
const value = decodeValue(memfs, content, type);
|
|
254
289
|
if (status === 1) {
|
|
255
290
|
throw value
|