nuxt-ai-ready 2.5.2 → 2.5.3
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/dist/module.json +1 -1
- package/dist/runtime/server/middleware/markdown.js +3 -3
- package/dist/runtime/server/utils/negotiation-response.d.ts +1 -1
- package/dist/runtime/server/utils/negotiation-response.js +17 -2
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +236 -0
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +1086 -0
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/package.json +35 -0
- package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/rollup.config.js +6 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +4 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +48 -16
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +1 -1
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +3339 -4021
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +1 -1
- package/package.json +1 -1
package/node_modules/mdream/node_modules/@emnapi/core/node_modules/@emnapi/wasi-threads/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@emnapi/wasi-threads",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "WASI threads proposal implementation in JavaScript",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/wasi-threads.js",
|
|
7
|
+
"module": "./dist/wasi-threads.js",
|
|
8
|
+
"types": "./dist/wasi-threads.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/wasi-threads.js",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"tslib": "^2.4.0"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "rollup -c",
|
|
19
|
+
"build:test": "node ./test/build.js",
|
|
20
|
+
"test": "node ./test/index.js"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/toyobayashi/emnapi.git"
|
|
25
|
+
},
|
|
26
|
+
"author": "toyobayashi",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/toyobayashi/emnapi/issues"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/toyobayashi/emnapi#readme",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -134,7 +134,10 @@ export declare class ThreadManager {
|
|
|
134
134
|
returnWorkerToPool(worker: WorkerLike): void;
|
|
135
135
|
loadWasmModuleToWorker(worker: WorkerLike, sab?: Int32Array): Promise<WorkerLike>;
|
|
136
136
|
allocateUnusedWorker(): WorkerLike;
|
|
137
|
+
private allocatePoolWorker;
|
|
138
|
+
private dropFailedLoad;
|
|
137
139
|
getNewWorker(sab?: Int32Array): WorkerLike | undefined;
|
|
140
|
+
private allocateAndLoadWorker;
|
|
138
141
|
cleanThread(worker: WorkerLike, tid: number, force?: boolean): void;
|
|
139
142
|
terminateWorker(worker: WorkerLike): void;
|
|
140
143
|
terminateAllThreads(): void;
|
|
@@ -173,6 +176,7 @@ export declare class ThreadMessageHandler {
|
|
|
173
176
|
private _load;
|
|
174
177
|
private _start;
|
|
175
178
|
protected _loaded(err: Error | null, source: WebAssembly.WebAssemblyInstantiatedSource | null, payload: LoadPayload): void;
|
|
179
|
+
private _failQueuedStarts;
|
|
176
180
|
protected handleAfterLoad<E extends WorkerMessageEvent>(e: E, f: (e: E) => void): void;
|
|
177
181
|
protected beforeReportError(_error: Error, _type: WorkerMessageType | 'async-worker-init', _tid?: number): void;
|
|
178
182
|
protected reportError(value: unknown, type: WorkerMessageType | 'async-worker-init', tid?: number): void;
|
|
@@ -231,11 +231,7 @@ class ThreadManager {
|
|
|
231
231
|
if (this._reuseWorker.size) {
|
|
232
232
|
let pthreadPoolSize = this._reuseWorker.size;
|
|
233
233
|
while (pthreadPoolSize--) {
|
|
234
|
-
|
|
235
|
-
if (ENVIRONMENT_IS_NODE) {
|
|
236
|
-
worker.once('message', () => { });
|
|
237
|
-
worker.unref();
|
|
238
|
-
}
|
|
234
|
+
this.allocatePoolWorker();
|
|
239
235
|
}
|
|
240
236
|
}
|
|
241
237
|
}
|
|
@@ -338,8 +334,7 @@ class ThreadManager {
|
|
|
338
334
|
}
|
|
339
335
|
if (!worker.loaded) {
|
|
340
336
|
reject(error);
|
|
341
|
-
_this.
|
|
342
|
-
_this.terminateWorker(worker);
|
|
337
|
+
_this.dropFailedLoad(worker);
|
|
343
338
|
return;
|
|
344
339
|
}
|
|
345
340
|
_this.fail(error, !ENVIRONMENT_IS_NODE);
|
|
@@ -374,8 +369,7 @@ class ThreadManager {
|
|
|
374
369
|
const error = deserializeError(threadError.error);
|
|
375
370
|
if (!worker.loaded && threadError.phase === 'load') {
|
|
376
371
|
reject(error);
|
|
377
|
-
this.
|
|
378
|
-
this.terminateWorker(worker);
|
|
372
|
+
this.dropFailedLoad(worker);
|
|
379
373
|
}
|
|
380
374
|
else {
|
|
381
375
|
this.fail(error, true);
|
|
@@ -430,8 +424,7 @@ class ThreadManager {
|
|
|
430
424
|
error = memoryError;
|
|
431
425
|
}
|
|
432
426
|
reject(error);
|
|
433
|
-
this.
|
|
434
|
-
this.terminateWorker(worker);
|
|
427
|
+
this.dropFailedLoad(worker);
|
|
435
428
|
}
|
|
436
429
|
});
|
|
437
430
|
return worker.whenLoaded;
|
|
@@ -447,6 +440,21 @@ class ThreadManager {
|
|
|
447
440
|
this.unusedWorkers.push(worker);
|
|
448
441
|
return worker;
|
|
449
442
|
}
|
|
443
|
+
allocatePoolWorker() {
|
|
444
|
+
const worker = this.allocateUnusedWorker();
|
|
445
|
+
if (ENVIRONMENT_IS_NODE) {
|
|
446
|
+
worker.once('message', () => { });
|
|
447
|
+
worker.unref();
|
|
448
|
+
}
|
|
449
|
+
return worker;
|
|
450
|
+
}
|
|
451
|
+
dropFailedLoad(worker) {
|
|
452
|
+
const idle = this.unusedWorkers.indexOf(worker) !== -1;
|
|
453
|
+
this.loadRejects.delete(worker);
|
|
454
|
+
this.terminateWorker(worker);
|
|
455
|
+
if (idle && !this._fatalError)
|
|
456
|
+
this.allocatePoolWorker();
|
|
457
|
+
}
|
|
450
458
|
getNewWorker(sab) {
|
|
451
459
|
this.assertRunning();
|
|
452
460
|
if (this._reuseWorker) {
|
|
@@ -459,14 +467,21 @@ class ThreadManager {
|
|
|
459
467
|
return;
|
|
460
468
|
}
|
|
461
469
|
}
|
|
462
|
-
|
|
470
|
+
return this.allocateAndLoadWorker(sab);
|
|
471
|
+
}
|
|
472
|
+
const worker = this.unusedWorkers.pop();
|
|
473
|
+
if (!worker.whenLoaded) {
|
|
463
474
|
this.loadWasmModuleToWorker(worker, sab);
|
|
464
475
|
}
|
|
465
|
-
return
|
|
476
|
+
return worker;
|
|
466
477
|
}
|
|
478
|
+
return this.allocateAndLoadWorker(sab);
|
|
479
|
+
}
|
|
480
|
+
allocateAndLoadWorker(sab) {
|
|
467
481
|
const worker = this.allocateUnusedWorker();
|
|
482
|
+
this.unusedWorkers.pop();
|
|
468
483
|
this.loadWasmModuleToWorker(worker, sab);
|
|
469
|
-
return this.
|
|
484
|
+
return this.expectedTerminations.has(worker) ? undefined : worker;
|
|
470
485
|
}
|
|
471
486
|
cleanThread(worker, tid, force) {
|
|
472
487
|
if (!force && this._reuseWorker) {
|
|
@@ -482,14 +497,20 @@ class ThreadManager {
|
|
|
482
497
|
const tid = worker.__emnapi_tid;
|
|
483
498
|
this.expectedTerminations.add(worker);
|
|
484
499
|
this.registeredWorkers.delete(worker);
|
|
500
|
+
const index = this.unusedWorkers.indexOf(worker);
|
|
501
|
+
if (index !== -1)
|
|
502
|
+
this.unusedWorkers.splice(index, 1);
|
|
485
503
|
this.loadRejects.delete(worker);
|
|
486
504
|
worker.terminate();
|
|
487
505
|
this.messageEvents.get(worker)?.clear();
|
|
488
506
|
this.messageEvents.delete(worker);
|
|
489
507
|
worker.onmessage = (e) => {
|
|
490
508
|
if (e.data.__emnapi__) {
|
|
509
|
+
const type = e.data.__emnapi__.type;
|
|
510
|
+
if (type === 'loaded')
|
|
511
|
+
return;
|
|
491
512
|
const err = this.printErr;
|
|
492
|
-
err('received "' +
|
|
513
|
+
err('received "' + type + '" command from terminated worker: ' + tid);
|
|
493
514
|
}
|
|
494
515
|
};
|
|
495
516
|
}
|
|
@@ -793,7 +814,7 @@ class WASIThreads {
|
|
|
793
814
|
worker.whenLoaded.catch((err) => {
|
|
794
815
|
delete worker.whenLoaded;
|
|
795
816
|
PThread.cleanThread(worker, tid, true);
|
|
796
|
-
|
|
817
|
+
PThread.printErr('failed to load the worker of thread ' + tid + ': ' + ((err && err.stack) || err));
|
|
797
818
|
});
|
|
798
819
|
}
|
|
799
820
|
if (isNewABI) {
|
|
@@ -1018,17 +1039,20 @@ class ThreadMessageHandler {
|
|
|
1018
1039
|
_loaded(err, source, payload) {
|
|
1019
1040
|
if (err) {
|
|
1020
1041
|
notifyPthreadCreateResult(payload.sab, 2, err);
|
|
1042
|
+
this._failQueuedStarts(err);
|
|
1021
1043
|
throw err;
|
|
1022
1044
|
}
|
|
1023
1045
|
if (source == null) {
|
|
1024
1046
|
const err = new TypeError('onLoad should return an object');
|
|
1025
1047
|
notifyPthreadCreateResult(payload.sab, 2, err);
|
|
1048
|
+
this._failQueuedStarts(err);
|
|
1026
1049
|
throw err;
|
|
1027
1050
|
}
|
|
1028
1051
|
const instance = source.instance;
|
|
1029
1052
|
if (!instance) {
|
|
1030
1053
|
const err = new TypeError('onLoad should return an object which includes "instance"');
|
|
1031
1054
|
notifyPthreadCreateResult(payload.sab, 2, err);
|
|
1055
|
+
this._failQueuedStarts(err);
|
|
1032
1056
|
throw err;
|
|
1033
1057
|
}
|
|
1034
1058
|
this.instance = instance;
|
|
@@ -1041,6 +1065,14 @@ class ThreadMessageHandler {
|
|
|
1041
1065
|
this.handle({ data });
|
|
1042
1066
|
}
|
|
1043
1067
|
}
|
|
1068
|
+
_failQueuedStarts(err) {
|
|
1069
|
+
this.messagesBeforeLoad = this.messagesBeforeLoad.filter((data) => {
|
|
1070
|
+
if (data?.__emnapi__?.type !== 'start')
|
|
1071
|
+
return true;
|
|
1072
|
+
notifyPthreadCreateResult(data.__emnapi__.payload.sab, 2, err);
|
|
1073
|
+
return false;
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1044
1076
|
handleAfterLoad(e, f) {
|
|
1045
1077
|
if (this.instance !== undefined) {
|
|
1046
1078
|
f.call(this, e);
|