nuxt-ai-ready 2.5.0 → 2.5.2
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/chunks/agent-skills.mjs +1 -1
- package/dist/chunks/prerender.mjs +1 -1
- package/dist/cli.mjs +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/db/drizzle/queries.js +0 -1
- package/dist/runtime/server/db/queries.d.ts +2 -0
- package/dist/runtime/server/db/queries.js +11 -5
- package/dist/runtime/server/db/seed.d.ts +2 -2
- package/dist/runtime/server/routes/__ai-ready/reindex.post.js +2 -0
- package/dist/runtime/server/utils/batchIndex.js +4 -2
- package/dist/runtime/server/utils/checkStale.d.ts +1 -1
- package/dist/runtime/server/utils/checkStale.js +1 -1
- package/dist/runtime/server/utils/indexPage.d.ts +8 -1
- package/dist/runtime/server/utils/indexPage.js +13 -5
- package/dist/shared/{nuxt-ai-ready.DsokNmXc.mjs → nuxt-ai-ready.CLSWou20.mjs} +2 -0
- package/node_modules/@mdream/js/LICENSE.md +9 -0
- package/node_modules/@mdream/js/README.md +792 -0
- package/node_modules/@mdream/js/bin/mdream.mjs +2 -0
- package/node_modules/@mdream/js/dist/_chunks/const.mjs +134 -0
- package/node_modules/@mdream/js/dist/_chunks/index.d.mts +9 -0
- package/node_modules/@mdream/js/dist/_chunks/markdown-processor.mjs +1968 -0
- package/node_modules/@mdream/js/dist/_chunks/minimal.d.mts +6 -0
- package/node_modules/@mdream/js/dist/_chunks/parse.mjs +2756 -0
- package/node_modules/@mdream/js/dist/_chunks/plugins.mjs +725 -0
- package/node_modules/@mdream/js/dist/_chunks/resolve-plugins.mjs +44 -0
- package/node_modules/@mdream/js/dist/_chunks/stream.mjs +37 -0
- package/node_modules/@mdream/js/dist/_chunks/types.d.mts +473 -0
- package/node_modules/@mdream/js/dist/cli.d.mts +1 -0
- package/node_modules/@mdream/js/dist/cli.mjs +32 -0
- package/node_modules/@mdream/js/dist/core.d.mts +15 -0
- package/node_modules/@mdream/js/dist/core.mjs +28 -0
- package/node_modules/@mdream/js/dist/index.d.mts +4 -0
- package/node_modules/@mdream/js/dist/index.mjs +58 -0
- package/node_modules/@mdream/js/dist/llms-txt.d.mts +86 -0
- package/node_modules/@mdream/js/dist/llms-txt.mjs +308 -0
- package/node_modules/@mdream/js/dist/negotiate.d.mts +35 -0
- package/node_modules/@mdream/js/dist/negotiate.mjs +121 -0
- package/node_modules/@mdream/js/dist/parse.d.mts +90 -0
- package/node_modules/@mdream/js/dist/parse.mjs +2 -0
- package/node_modules/@mdream/js/dist/plugins.d.mts +85 -0
- package/node_modules/@mdream/js/dist/plugins.mjs +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.d.mts +2 -0
- package/node_modules/@mdream/js/dist/preset/minimal.mjs +33 -0
- package/node_modules/@mdream/js/dist/splitter.d.mts +18 -0
- package/node_modules/@mdream/js/dist/splitter.mjs +194 -0
- package/node_modules/@mdream/js/package.json +103 -0
- package/node_modules/cac/LICENSE +21 -0
- package/node_modules/cac/README.md +492 -0
- package/node_modules/cac/dist/index.d.ts +196 -0
- package/node_modules/cac/dist/index.js +638 -0
- package/node_modules/cac/package.json +72 -0
- package/node_modules/mdream/LICENSE.md +9 -0
- package/node_modules/mdream/README.md +1091 -0
- package/node_modules/mdream/bin/mdream.mjs +46 -0
- package/node_modules/mdream/dist/browser.d.mts +105 -0
- package/node_modules/mdream/dist/browser.mjs +262 -0
- package/node_modules/mdream/dist/edge.d.mts +100 -0
- package/node_modules/mdream/dist/edge.mjs +250 -0
- package/node_modules/mdream/dist/iife.js +605 -0
- package/node_modules/mdream/dist/index.d.mts +89 -0
- package/node_modules/mdream/dist/index.mjs +184 -0
- package/node_modules/mdream/dist/wasm.d.mts +100 -0
- package/node_modules/mdream/dist/wasm.mjs +140 -0
- package/node_modules/mdream/dist/worker.d.mts +101 -0
- package/node_modules/mdream/dist/worker.mjs +217 -0
- package/node_modules/mdream/napi/index.d.mts +127 -0
- package/node_modules/mdream/napi/index.d.ts +127 -0
- package/node_modules/mdream/napi/index.mjs +725 -0
- package/node_modules/mdream/napi/rust.android-arm-eabi.node +0 -0
- package/node_modules/mdream/napi/rust.android-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-arm64.node +0 -0
- package/node_modules/mdream/napi/rust.darwin-x64.node +0 -0
- package/node_modules/mdream/napi/rust.freebsd-x64.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm-gnueabihf.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-arm64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-gnu.node +0 -0
- package/node_modules/mdream/napi/rust.linux-x64-musl.node +0 -0
- package/node_modules/mdream/napi/rust.wasi.cjs +2144 -0
- package/node_modules/mdream/napi/rust.wasm32-wasi.wasm +0 -0
- package/node_modules/mdream/napi/rust.win32-arm64-msvc.node +0 -0
- package/node_modules/mdream/napi/rust.win32-x64-msvc.node +0 -0
- package/node_modules/mdream/node_modules/@emnapi/core/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/core/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.d.ts +392 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.full.js +8351 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/emnapi-core.js +7268 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/async-work.js +843 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.d.ts +4 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/index.js +3 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/threadsafe-function.js +1010 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.d.ts +5 -0
- package/node_modules/mdream/node_modules/@emnapi/core/dist/plugins/v8.js +1446 -0
- package/node_modules/mdream/node_modules/@emnapi/core/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/core/rollup.config.js +60 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/README.md +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.d.ts +833 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js +2306 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/dist/emnapi.js.map +1 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/index.cjs +63 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/package.json +39 -0
- package/node_modules/mdream/node_modules/@emnapi/runtime/rollup.config.js +25 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/README.md +203 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.d.ts +236 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/dist/wasi-threads.js +1086 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/package.json +35 -0
- package/node_modules/mdream/node_modules/@emnapi/wasi-threads/rollup.config.js +6 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.cjs +1472 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/emnapi-plugins.js +1470 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs-proxy.cjs +237 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/dist/fs.js +18260 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/fs-proxy.js +317 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/package.json +67 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.cjs +39 -0
- package/node_modules/mdream/node_modules/@napi-rs/wasm-runtime/runtime.js +36 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/LICENSE +21 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/README.md +193 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/tsdoc-metadata.json +11 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.d.ts +423 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.js +2932 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.esm.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.js +2954 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/dist/wasm-util.min.js +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/asyncify.js +158 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/index.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/jspi.js +46 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/load.js +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/memory.js +35 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/error.js +103 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fd.js +268 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/fs.js +3 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/index.js +192 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/path.js +316 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/preview1.js +1599 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/rights.js +141 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/types.js +220 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/wasi/util.js +128 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/cjs/webassembly.js +13 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/asyncify.mjs +153 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/index.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/jspi.mjs +39 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/load.mjs +89 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/memory.mjs +28 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/error.mjs +97 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fd.mjs +256 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/fs.mjs +1 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/index.mjs +186 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/path.mjs +310 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/preview1.mjs +1593 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/rights.mjs +135 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/types.mjs +216 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/wasi/util.mjs +113 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/lib/mjs/webassembly.mjs +9 -0
- package/node_modules/mdream/node_modules/@tybys/wasm-util/package.json +58 -0
- package/node_modules/mdream/node_modules/tslib/CopyrightNotice.txt +15 -0
- package/node_modules/mdream/node_modules/tslib/LICENSE.txt +12 -0
- package/node_modules/mdream/node_modules/tslib/README.md +164 -0
- package/node_modules/mdream/node_modules/tslib/SECURITY.md +41 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.d.ts +38 -0
- package/node_modules/mdream/node_modules/tslib/modules/index.js +70 -0
- package/node_modules/mdream/node_modules/tslib/modules/package.json +3 -0
- package/node_modules/mdream/node_modules/tslib/package.json +47 -0
- package/node_modules/mdream/node_modules/tslib/tslib.d.ts +460 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.js +402 -0
- package/node_modules/mdream/node_modules/tslib/tslib.es6.mjs +401 -0
- package/node_modules/mdream/node_modules/tslib/tslib.html +1 -0
- package/node_modules/mdream/node_modules/tslib/tslib.js +484 -0
- package/node_modules/mdream/package.json +110 -0
- package/node_modules/mdream/skills/mdream/SKILL.md +124 -0
- package/node_modules/mdream/skills/mdream/references/runtimes.md +49 -0
- package/node_modules/mdream/wasm/mdream_edge.d.ts +90 -0
- package/node_modules/mdream/wasm/mdream_edge.js +517 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm/package.json +17 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.d.ts +45 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge.js +13 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.js +413 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm +0 -0
- package/node_modules/mdream/wasm-bundler/mdream_edge_bg.wasm.d.ts +20 -0
- package/node_modules/mdream/wasm-bundler/package.json +19 -0
- package/node_modules/pathe/LICENSE +70 -0
- package/node_modules/pathe/README.md +73 -0
- package/node_modules/pathe/dist/index.cjs +39 -0
- package/node_modules/pathe/dist/index.d.cts +47 -0
- package/node_modules/pathe/dist/index.d.mts +47 -0
- package/node_modules/pathe/dist/index.d.ts +47 -0
- package/node_modules/pathe/dist/index.mjs +19 -0
- package/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs +266 -0
- package/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/node_modules/pathe/dist/utils.cjs +82 -0
- package/node_modules/pathe/dist/utils.d.cts +32 -0
- package/node_modules/pathe/dist/utils.d.mts +32 -0
- package/node_modules/pathe/dist/utils.d.ts +32 -0
- package/node_modules/pathe/dist/utils.mjs +77 -0
- package/node_modules/pathe/package.json +61 -0
- package/node_modules/pathe/utils.d.ts +1 -0
- package/package.json +8 -64
|
@@ -0,0 +1,843 @@
|
|
|
1
|
+
//#region src/emnapi/async-work.js
|
|
2
|
+
function asyncWork (emnapiPluginCtx) {
|
|
3
|
+
const { emnapiCtx, emnapiNodeBinding, emnapiAsyncWorkPoolSize } = emnapiPluginCtx;
|
|
4
|
+
var mod = (function (exports, emnapi_shared, emscripten_runtime) {
|
|
5
|
+
|
|
6
|
+
//#region src/async-work.ts
|
|
7
|
+
/**
|
|
8
|
+
* @__deps $emnapiCtx
|
|
9
|
+
* @__deps $emnapiEnv
|
|
10
|
+
* @__deps $emnapiNodeBinding
|
|
11
|
+
* @__deps $emnapiAsyncWorkPoolSize
|
|
12
|
+
* @__postset
|
|
13
|
+
* ```
|
|
14
|
+
* emnapiAWST.init();
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
var emnapiAWST = {
|
|
18
|
+
idGen: {},
|
|
19
|
+
values: [undefined],
|
|
20
|
+
queued: new Set(),
|
|
21
|
+
pending: [],
|
|
22
|
+
pendingHead: 0,
|
|
23
|
+
init: function () {
|
|
24
|
+
const idGen = {
|
|
25
|
+
nextId: 1,
|
|
26
|
+
list: [],
|
|
27
|
+
listHead: 0,
|
|
28
|
+
generate: function () {
|
|
29
|
+
let id;
|
|
30
|
+
if (idGen.listHead < idGen.list.length) {
|
|
31
|
+
id = idGen.list[idGen.listHead++];
|
|
32
|
+
if (idGen.listHead === idGen.list.length) {
|
|
33
|
+
idGen.list.length = 0;
|
|
34
|
+
idGen.listHead = 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
id = idGen.nextId;
|
|
39
|
+
idGen.nextId++;
|
|
40
|
+
}
|
|
41
|
+
return id;
|
|
42
|
+
},
|
|
43
|
+
reuse: function (id) {
|
|
44
|
+
idGen.list.push(id);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
emnapiAWST.idGen = idGen;
|
|
48
|
+
emnapiAWST.values = [undefined];
|
|
49
|
+
emnapiAWST.queued = new Set();
|
|
50
|
+
emnapiAWST.pending = [];
|
|
51
|
+
emnapiAWST.pendingHead = 0;
|
|
52
|
+
},
|
|
53
|
+
create: function (env, resource, resourceName, execute, complete, data) {
|
|
54
|
+
let asyncId = 0;
|
|
55
|
+
let triggerAsyncId = 0;
|
|
56
|
+
if (emnapiNodeBinding) {
|
|
57
|
+
const asyncContext = emnapiNodeBinding.node.emitAsyncInit(resource, resourceName, -1);
|
|
58
|
+
asyncId = asyncContext.asyncId;
|
|
59
|
+
triggerAsyncId = asyncContext.triggerAsyncId;
|
|
60
|
+
}
|
|
61
|
+
const id = emnapiAWST.idGen.generate();
|
|
62
|
+
emnapiAWST.values[id] = {
|
|
63
|
+
env,
|
|
64
|
+
id,
|
|
65
|
+
resource,
|
|
66
|
+
asyncId,
|
|
67
|
+
triggerAsyncId,
|
|
68
|
+
status: 0,
|
|
69
|
+
execute,
|
|
70
|
+
complete,
|
|
71
|
+
data
|
|
72
|
+
};
|
|
73
|
+
return id;
|
|
74
|
+
},
|
|
75
|
+
callComplete: function (work, status) {
|
|
76
|
+
const complete = work.complete;
|
|
77
|
+
const env = work.env;
|
|
78
|
+
const data = work.data;
|
|
79
|
+
const callback = () => {
|
|
80
|
+
if (!complete)
|
|
81
|
+
return;
|
|
82
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
83
|
+
const scope = emnapiCtx.openScope(envObject);
|
|
84
|
+
try {
|
|
85
|
+
envObject.callbackIntoModule(true, () => {
|
|
86
|
+
(emnapiPluginCtx.wasmTable.get(complete))(env, status, data);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
emnapiCtx.closeScope(envObject, scope);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
if (emnapiNodeBinding) {
|
|
94
|
+
emnapiNodeBinding.node.makeCallback(work.resource, callback, [], {
|
|
95
|
+
asyncId: work.asyncId,
|
|
96
|
+
triggerAsyncId: work.triggerAsyncId
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
callback();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
queue: function (id) {
|
|
104
|
+
const work = emnapiAWST.values[id];
|
|
105
|
+
if (!work)
|
|
106
|
+
return;
|
|
107
|
+
if (work.status === 0) {
|
|
108
|
+
work.status = 1;
|
|
109
|
+
if (emnapiAWST.queued.size >= (Math.abs(emnapiAsyncWorkPoolSize) || 4)) {
|
|
110
|
+
if (emnapiAWST.pendingHead >= 1024 && emnapiAWST.pendingHead * 2 >= emnapiAWST.pending.length) {
|
|
111
|
+
emnapiAWST.pending.splice(0, emnapiAWST.pendingHead);
|
|
112
|
+
emnapiAWST.pendingHead = 0;
|
|
113
|
+
}
|
|
114
|
+
emnapiAWST.pending.push(id);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
emnapiAWST.queued.add(id);
|
|
118
|
+
const env = work.env;
|
|
119
|
+
const data = work.data;
|
|
120
|
+
const execute = work.execute;
|
|
121
|
+
work.status = 2;
|
|
122
|
+
emnapiCtx.features.setImmediate(() => {
|
|
123
|
+
(emnapiPluginCtx.wasmTable.get(execute))(env, data);
|
|
124
|
+
emnapiAWST.queued.delete(id);
|
|
125
|
+
work.status = 3;
|
|
126
|
+
emnapiCtx.features.setImmediate(() => {
|
|
127
|
+
emnapiAWST.callComplete(work, 0 /* napi_status.napi_ok */);
|
|
128
|
+
});
|
|
129
|
+
if (emnapiAWST.pendingHead < emnapiAWST.pending.length) {
|
|
130
|
+
const nextWorkId = emnapiAWST.pending[emnapiAWST.pendingHead++];
|
|
131
|
+
if (emnapiAWST.pendingHead === emnapiAWST.pending.length) {
|
|
132
|
+
emnapiAWST.pending.length = 0;
|
|
133
|
+
emnapiAWST.pendingHead = 0;
|
|
134
|
+
}
|
|
135
|
+
emnapiAWST.values[nextWorkId].status = 0;
|
|
136
|
+
emnapiAWST.queue(nextWorkId);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
cancel: function (id) {
|
|
142
|
+
const index = emnapiAWST.pending.indexOf(id, emnapiAWST.pendingHead);
|
|
143
|
+
if (index !== -1) {
|
|
144
|
+
const work = emnapiAWST.values[id];
|
|
145
|
+
if (work && (work.status === 1)) {
|
|
146
|
+
work.status = 4;
|
|
147
|
+
emnapiAWST.pending.splice(index, 1);
|
|
148
|
+
if (emnapiAWST.pendingHead === emnapiAWST.pending.length) {
|
|
149
|
+
emnapiAWST.pending.length = 0;
|
|
150
|
+
emnapiAWST.pendingHead = 0;
|
|
151
|
+
}
|
|
152
|
+
emnapiCtx.features.setImmediate(() => {
|
|
153
|
+
emnapiAWST.callComplete(work, 11 /* napi_status.napi_cancelled */);
|
|
154
|
+
});
|
|
155
|
+
return 0 /* napi_status.napi_ok */;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
return 9 /* napi_status.napi_generic_failure */;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return 9 /* napi_status.napi_generic_failure */;
|
|
162
|
+
},
|
|
163
|
+
remove: function (id) {
|
|
164
|
+
const work = emnapiAWST.values[id];
|
|
165
|
+
if (!work)
|
|
166
|
+
return;
|
|
167
|
+
if (emnapiNodeBinding) {
|
|
168
|
+
emnapiNodeBinding.node.emitAsyncDestroy({
|
|
169
|
+
asyncId: work.asyncId,
|
|
170
|
+
triggerAsyncId: work.triggerAsyncId
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
emnapiAWST.values[id] = undefined;
|
|
174
|
+
emnapiAWST.idGen.reuse(id);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
//#endregion src/async-work.ts
|
|
179
|
+
|
|
180
|
+
//#region src/macro.ts
|
|
181
|
+
|
|
182
|
+
//#endregion src/macro.ts
|
|
183
|
+
|
|
184
|
+
//#region src/core/async-work.ts
|
|
185
|
+
const {
|
|
186
|
+
// onCreateWorker, napiModule, singleThreadAsyncWork, _emnapi_async_work_pool_size,
|
|
187
|
+
// PThread, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_PTHREAD, wasmInstance, _free, wasmMemory, _malloc,
|
|
188
|
+
_emnapi_node_emit_async_init, _emnapi_node_emit_async_destroy, _emnapi_runtime_keepalive_pop, _emnapi_runtime_keepalive_push } = emnapiPluginCtx;
|
|
189
|
+
var emnapiAWMT = {
|
|
190
|
+
pool: [],
|
|
191
|
+
workerReady: null,
|
|
192
|
+
globalAddress: 0,
|
|
193
|
+
globalOffset: {
|
|
194
|
+
idle_threads: 0,
|
|
195
|
+
q: 1 * 4,
|
|
196
|
+
next: 1 * 4,
|
|
197
|
+
prev: 2 * 4,
|
|
198
|
+
mutex: 3 * 4,
|
|
199
|
+
cond: 4 * 4,
|
|
200
|
+
exit_message: 5 * 4,
|
|
201
|
+
end: 7 * 4
|
|
202
|
+
},
|
|
203
|
+
offset: {
|
|
204
|
+
/* napi_ref */ resource: 0,
|
|
205
|
+
/* double */ async_id: 8,
|
|
206
|
+
/* double */ trigger_async_id: 16,
|
|
207
|
+
/* napi_env */ env: 24,
|
|
208
|
+
/* int32_t */ status: 1 * 4 + 24, // 0 for pending, 1 for cancelled, 2 for completed
|
|
209
|
+
queue: 2 * 4 + 24,
|
|
210
|
+
queue_next: 2 * 4 + 24,
|
|
211
|
+
queue_prev: 3 * 4 + 24,
|
|
212
|
+
/* void* */ data: 4 * 4 + 24,
|
|
213
|
+
/* napi_async_execute_callback */ execute: 5 * 4 + 24,
|
|
214
|
+
/* napi_async_complete_callback */ complete: 6 * 4 + 24,
|
|
215
|
+
end: 7 * 4 + 24
|
|
216
|
+
},
|
|
217
|
+
/**
|
|
218
|
+
* When another thread grows the shared WebAssembly.Memory, this agent's
|
|
219
|
+
* cached `wasmMemory.buffer` may still have the old shorter length
|
|
220
|
+
* (V8 refreshes it lazily). If a pointer derived from shared memory lies
|
|
221
|
+
* beyond the cached length, `wasmMemory.grow(0)` forces the agent to
|
|
222
|
+
* observe the current memory size and refreshes the buffer.
|
|
223
|
+
*/
|
|
224
|
+
ensureBufferFor(end) {
|
|
225
|
+
let buffer = emscripten_runtime.wasmMemory.buffer;
|
|
226
|
+
if (end > buffer.byteLength) {
|
|
227
|
+
emscripten_runtime.wasmMemory.grow(0);
|
|
228
|
+
buffer = emscripten_runtime.wasmMemory.buffer;
|
|
229
|
+
}
|
|
230
|
+
return buffer;
|
|
231
|
+
},
|
|
232
|
+
init() {
|
|
233
|
+
emnapiAWMT.pool = [];
|
|
234
|
+
emnapiAWMT.workerReady = null;
|
|
235
|
+
if (typeof emscripten_runtime.PThread !== 'undefined') {
|
|
236
|
+
emscripten_runtime.PThread.unusedWorkers.forEach(emnapiAWMT.addListener);
|
|
237
|
+
Object.values(emscripten_runtime.PThread.pthreads).forEach(emnapiAWMT.addListener);
|
|
238
|
+
const __original_getNewWorker = emscripten_runtime.PThread.getNewWorker;
|
|
239
|
+
emscripten_runtime.PThread.getNewWorker = function () {
|
|
240
|
+
const r = __original_getNewWorker.apply(this, arguments);
|
|
241
|
+
emnapiAWMT.addListener(r);
|
|
242
|
+
return r;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
addListener(worker) {
|
|
247
|
+
if (!worker)
|
|
248
|
+
return false;
|
|
249
|
+
if (worker._emnapiAWMTListener)
|
|
250
|
+
return true;
|
|
251
|
+
const handler = function (e) {
|
|
252
|
+
const data = emscripten_runtime.ENVIRONMENT_IS_NODE ? e : e.data;
|
|
253
|
+
const __emnapi__ = data.__emnapi__;
|
|
254
|
+
if (__emnapi__) {
|
|
255
|
+
const type = __emnapi__.type;
|
|
256
|
+
const payload = __emnapi__.payload;
|
|
257
|
+
if (type === 'async-work-complete') {
|
|
258
|
+
emnapiAWMT.callComplete(payload.work, 0 /* napi_status.napi_ok */);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const dispose = function () {
|
|
263
|
+
if (emscripten_runtime.ENVIRONMENT_IS_NODE) {
|
|
264
|
+
worker.off('message', handler);
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
worker.removeEventListener('message', handler, false);
|
|
268
|
+
}
|
|
269
|
+
delete worker._emnapiAWMTListener;
|
|
270
|
+
};
|
|
271
|
+
worker._emnapiAWMTListener = { handler, dispose };
|
|
272
|
+
if (emscripten_runtime.ENVIRONMENT_IS_NODE) {
|
|
273
|
+
worker.on('message', handler);
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
worker.addEventListener('message', handler, false);
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
279
|
+
},
|
|
280
|
+
initGlobal() {
|
|
281
|
+
if (!emnapiAWMT.globalAddress) {
|
|
282
|
+
emnapiAWMT.globalAddress = emscripten_runtime._malloc(emnapiAWMT.globalOffset.end);
|
|
283
|
+
emnapiAWMT.globalAddress >>>= 0;
|
|
284
|
+
const size = emnapiAWMT.globalOffset.end;
|
|
285
|
+
const addr = emnapiAWMT.globalAddress;
|
|
286
|
+
new Uint8Array(emnapiAWMT.ensureBufferFor(addr + size), addr, size).fill(0);
|
|
287
|
+
emnapiAWMT.queueInit(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.q);
|
|
288
|
+
emnapiAWMT.queueInit(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.exit_message);
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
terminateWorkers() {
|
|
292
|
+
emnapiAWMT.pool.forEach(w => {
|
|
293
|
+
w._emnapiAWMTListener?.dispose();
|
|
294
|
+
w._emnapiTSFNListener?.dispose();
|
|
295
|
+
w.terminate();
|
|
296
|
+
});
|
|
297
|
+
emnapiAWMT.pool.length = 0;
|
|
298
|
+
},
|
|
299
|
+
initWorkers(n) {
|
|
300
|
+
if (emscripten_runtime.ENVIRONMENT_IS_PTHREAD) {
|
|
301
|
+
return emnapiAWMT.workerReady || (emnapiAWMT.workerReady = Promise.resolve());
|
|
302
|
+
}
|
|
303
|
+
if (emnapiAWMT.workerReady)
|
|
304
|
+
return emnapiAWMT.workerReady;
|
|
305
|
+
if (!('emnapi_async_worker_create' in emscripten_runtime.wasmInstance.exports)) {
|
|
306
|
+
throw new TypeError('`emnapi_async_worker_create` is not exported, please try to add `--export=emnapi_async_worker_create` to linker flags');
|
|
307
|
+
}
|
|
308
|
+
const emnapi_async_worker_create = emscripten_runtime.wasmInstance.exports.emnapi_async_worker_create;
|
|
309
|
+
const args = [];
|
|
310
|
+
emnapiAWMT.initGlobal();
|
|
311
|
+
for (let i = 0; i < n; ++i) {
|
|
312
|
+
args.push(emnapi_async_worker_create(1, emnapiAWMT.globalAddress));
|
|
313
|
+
}
|
|
314
|
+
const promises = args.map(index => {
|
|
315
|
+
if (index === 0) {
|
|
316
|
+
return Promise.reject(new Error('Failed to create async worker'));
|
|
317
|
+
}
|
|
318
|
+
let worker;
|
|
319
|
+
if (index < 0) {
|
|
320
|
+
worker = emnapiAWMT.pool[-index - 1];
|
|
321
|
+
if (worker)
|
|
322
|
+
return worker.whenLoaded;
|
|
323
|
+
}
|
|
324
|
+
index >>>= 0;
|
|
325
|
+
const tidOffset = 20;
|
|
326
|
+
const view = new DataView(emnapiAWMT.ensureBufferFor(index + tidOffset + 4));
|
|
327
|
+
const tid = view.getInt32(index + tidOffset, true);
|
|
328
|
+
worker = emscripten_runtime.PThread.pthreads[tid];
|
|
329
|
+
return worker.whenLoaded;
|
|
330
|
+
});
|
|
331
|
+
emnapiAWMT.workerReady = Promise.all(promises);
|
|
332
|
+
return emnapiAWMT.workerReady;
|
|
333
|
+
},
|
|
334
|
+
getResource(work) {
|
|
335
|
+
emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.resource + 4);
|
|
336
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
337
|
+
return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.resource, true);
|
|
338
|
+
},
|
|
339
|
+
getExecute(work) {
|
|
340
|
+
emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.execute + 4);
|
|
341
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
342
|
+
return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.execute, true);
|
|
343
|
+
},
|
|
344
|
+
getComplete(work) {
|
|
345
|
+
emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.complete + 4);
|
|
346
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
347
|
+
return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.complete, true);
|
|
348
|
+
},
|
|
349
|
+
getEnv(work) {
|
|
350
|
+
emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.env + 4);
|
|
351
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
352
|
+
return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.env, true);
|
|
353
|
+
},
|
|
354
|
+
getData(work) {
|
|
355
|
+
emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.data + 4);
|
|
356
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
357
|
+
return GET_HEAP_DATA_VIEW().getUint32(work + emnapiAWMT.offset.data, true);
|
|
358
|
+
},
|
|
359
|
+
getMutex() {
|
|
360
|
+
const index = emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.mutex;
|
|
361
|
+
const mutex = {
|
|
362
|
+
lock() {
|
|
363
|
+
const isBrowserMain = typeof window !== 'undefined' && typeof document !== 'undefined' && !emscripten_runtime.ENVIRONMENT_IS_NODE;
|
|
364
|
+
const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
|
|
365
|
+
if (isBrowserMain) {
|
|
366
|
+
while (true) {
|
|
367
|
+
const oldValue = Atomics.compareExchange(i32a, 0, 0, 10);
|
|
368
|
+
if (oldValue === 0) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
while (true) {
|
|
375
|
+
const oldValue = Atomics.compareExchange(i32a, 0, 0, 10);
|
|
376
|
+
if (oldValue === 0) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
Atomics.wait(i32a, 0, 10);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
unlock() {
|
|
384
|
+
const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
|
|
385
|
+
const oldValue = Atomics.compareExchange(i32a, 0, 10, 0);
|
|
386
|
+
if (oldValue !== 10) {
|
|
387
|
+
throw new Error('Tried to unlock while not holding the mutex');
|
|
388
|
+
}
|
|
389
|
+
Atomics.notify(i32a, 0, 1);
|
|
390
|
+
},
|
|
391
|
+
execute(fn) {
|
|
392
|
+
mutex.lock();
|
|
393
|
+
try {
|
|
394
|
+
return fn();
|
|
395
|
+
}
|
|
396
|
+
finally {
|
|
397
|
+
mutex.unlock();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
return mutex;
|
|
402
|
+
},
|
|
403
|
+
getCond() {
|
|
404
|
+
const index = emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.cond;
|
|
405
|
+
const mutex = emnapiAWMT.getMutex();
|
|
406
|
+
const cond = {
|
|
407
|
+
wait() {
|
|
408
|
+
const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
|
|
409
|
+
const value = Atomics.load(i32a, 0);
|
|
410
|
+
mutex.unlock();
|
|
411
|
+
Atomics.wait(i32a, 0, value);
|
|
412
|
+
mutex.lock();
|
|
413
|
+
},
|
|
414
|
+
signal() {
|
|
415
|
+
const i32a = new Int32Array(emnapiAWMT.ensureBufferFor(index + 4), index, 1);
|
|
416
|
+
Atomics.add(i32a, 0, 1);
|
|
417
|
+
Atomics.notify(i32a, 0, 1);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
return cond;
|
|
421
|
+
},
|
|
422
|
+
queueInit(q) {
|
|
423
|
+
emnapiAWMT.ensureBufferFor(q + 4 + 4);
|
|
424
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
425
|
+
GET_HEAP_DATA_VIEW().setUint32(q, q, true);
|
|
426
|
+
GET_HEAP_DATA_VIEW().setUint32(q + 4, q, true);
|
|
427
|
+
},
|
|
428
|
+
queueInsertTail(h, q) {
|
|
429
|
+
emnapiAWMT.ensureBufferFor(h + 4 + 4);
|
|
430
|
+
emnapiAWMT.ensureBufferFor(q + 4 + 4);
|
|
431
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
432
|
+
GET_HEAP_DATA_VIEW().setUint32(q, h, true);
|
|
433
|
+
const tempValue = GET_HEAP_DATA_VIEW().getUint32(h + 4, true);
|
|
434
|
+
GET_HEAP_DATA_VIEW().setUint32(q + 4, tempValue, true);
|
|
435
|
+
const qprev = GET_HEAP_DATA_VIEW().getUint32(q + 4, true);
|
|
436
|
+
GET_HEAP_DATA_VIEW().setUint32(qprev, q, true);
|
|
437
|
+
GET_HEAP_DATA_VIEW().setUint32(h + 4, q, true);
|
|
438
|
+
},
|
|
439
|
+
queueRemove(q) {
|
|
440
|
+
emnapiAWMT.ensureBufferFor(q + 4 + 4);
|
|
441
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
442
|
+
const qprev = GET_HEAP_DATA_VIEW().getUint32(q + 4, true);
|
|
443
|
+
const qnext = GET_HEAP_DATA_VIEW().getUint32(q, true);
|
|
444
|
+
GET_HEAP_DATA_VIEW().setUint32(qprev, qnext, true);
|
|
445
|
+
GET_HEAP_DATA_VIEW().setUint32(qnext + 4, qprev, true);
|
|
446
|
+
},
|
|
447
|
+
queueEmpty(q) {
|
|
448
|
+
emnapiAWMT.ensureBufferFor(q + 4);
|
|
449
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
450
|
+
// eslint-disable-next-line eqeqeq
|
|
451
|
+
return q == GET_HEAP_DATA_VIEW().getUint32(q, true);
|
|
452
|
+
},
|
|
453
|
+
scheduleWork: function (work) {
|
|
454
|
+
if (!emnapiAWMT.workerReady?.ready) {
|
|
455
|
+
emnapiAWMT.initWorkers(emnapi_shared._emnapi_async_work_pool_size()).then(() => {
|
|
456
|
+
emnapiAWMT.workerReady.ready = true;
|
|
457
|
+
}).catch((err) => {
|
|
458
|
+
emnapiAWMT.workerReady = null;
|
|
459
|
+
throw err;
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
_emnapi_runtime_keepalive_push();
|
|
463
|
+
emnapiCtx.increaseWaitingRequestCounter();
|
|
464
|
+
const statusBuffer = new Int32Array(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4), work + emnapiAWMT.offset.status, 1);
|
|
465
|
+
Atomics.store(statusBuffer, 0, 0 /* AsyncWorkStatus.Pending */);
|
|
466
|
+
const mutex = emnapiAWMT.getMutex();
|
|
467
|
+
const cond = emnapiAWMT.getCond();
|
|
468
|
+
mutex.lock();
|
|
469
|
+
try {
|
|
470
|
+
emnapiAWMT.queueInsertTail(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.q, work + emnapiAWMT.offset.queue);
|
|
471
|
+
}
|
|
472
|
+
catch (err) {
|
|
473
|
+
_emnapi_runtime_keepalive_pop();
|
|
474
|
+
emnapiCtx.decreaseWaitingRequestCounter();
|
|
475
|
+
mutex.unlock();
|
|
476
|
+
throw err;
|
|
477
|
+
}
|
|
478
|
+
emnapiAWMT.ensureBufferFor(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.idle_threads + 4);
|
|
479
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
480
|
+
if (GET_HEAP_DATA_VIEW().getUint32(emnapiAWMT.globalAddress + emnapiAWMT.globalOffset.idle_threads, true) > 0) {
|
|
481
|
+
cond.signal();
|
|
482
|
+
}
|
|
483
|
+
mutex.unlock();
|
|
484
|
+
},
|
|
485
|
+
cancelWork(work) {
|
|
486
|
+
let cancelled = false;
|
|
487
|
+
emnapiAWMT.getMutex().execute(() => {
|
|
488
|
+
emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4);
|
|
489
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
490
|
+
cancelled = !emnapiAWMT.queueEmpty(work + emnapiAWMT.offset.queue) && GET_HEAP_DATA_VIEW().getInt32(work + emnapiAWMT.offset.status, true) !== 2 /* AsyncWorkStatus.Completed */;
|
|
491
|
+
if (cancelled) {
|
|
492
|
+
emnapiAWMT.queueRemove(work + emnapiAWMT.offset.queue);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
if (!cancelled) {
|
|
496
|
+
return 9 /* napi_status.napi_generic_failure */;
|
|
497
|
+
}
|
|
498
|
+
if (Atomics.compareExchange(new Int32Array(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4), work + emnapiAWMT.offset.status, 1), 0, 0 /* AsyncWorkStatus.Pending */, 1 /* AsyncWorkStatus.Cancelled */) !== 0 /* AsyncWorkStatus.Pending */) {
|
|
499
|
+
return 9 /* napi_status.napi_generic_failure */;
|
|
500
|
+
}
|
|
501
|
+
emnapiCtx.features.setImmediate(() => {
|
|
502
|
+
emnapiAWMT.callComplete(work, 11 /* napi_status.napi_cancelled */);
|
|
503
|
+
});
|
|
504
|
+
return 0 /* napi_status.napi_ok */;
|
|
505
|
+
},
|
|
506
|
+
callComplete: function (work, status) {
|
|
507
|
+
_emnapi_runtime_keepalive_pop();
|
|
508
|
+
emnapiCtx.decreaseWaitingRequestCounter();
|
|
509
|
+
const complete = emnapiAWMT.getComplete(work);
|
|
510
|
+
const env = emnapiAWMT.getEnv(work);
|
|
511
|
+
const data = emnapiAWMT.getData(work);
|
|
512
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
513
|
+
const scope = emnapiCtx.openScope(envObject);
|
|
514
|
+
const callback = () => {
|
|
515
|
+
if (!complete)
|
|
516
|
+
return;
|
|
517
|
+
envObject.callbackIntoModule(true, () => {
|
|
518
|
+
(emnapiPluginCtx.wasmTable.get(complete))(env, status, data);
|
|
519
|
+
});
|
|
520
|
+
};
|
|
521
|
+
try {
|
|
522
|
+
if (emnapiNodeBinding) {
|
|
523
|
+
const resource = emnapiAWMT.getResource(work);
|
|
524
|
+
const resource_value = emnapiCtx.getRef(resource).get();
|
|
525
|
+
const resourceObject = emnapiCtx.jsValueFromNapiValue(resource_value);
|
|
526
|
+
const view = new DataView(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.trigger_async_id + 8));
|
|
527
|
+
const asyncId = view.getFloat64(work + emnapiAWMT.offset.async_id, true);
|
|
528
|
+
const triggerAsyncId = view.getFloat64(work + emnapiAWMT.offset.trigger_async_id, true);
|
|
529
|
+
emnapiNodeBinding.node.makeCallback(resourceObject, callback, [], {
|
|
530
|
+
asyncId,
|
|
531
|
+
triggerAsyncId
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
callback();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
finally {
|
|
539
|
+
emnapiCtx.closeScope(envObject, scope);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
emnapiAWST.init();
|
|
544
|
+
emnapiAWMT.init();
|
|
545
|
+
/** @__sig ippppppp */
|
|
546
|
+
var napi_create_async_work = emnapi_shared.singleThreadAsyncWork
|
|
547
|
+
? function (env, resource, resource_name, execute, complete, data, result) {
|
|
548
|
+
if (!env)
|
|
549
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
550
|
+
// @ts-expect-error
|
|
551
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
552
|
+
envObject.checkGCAccess();
|
|
553
|
+
if (!execute)
|
|
554
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
555
|
+
if (!result)
|
|
556
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
557
|
+
let resourceObject;
|
|
558
|
+
if (resource) {
|
|
559
|
+
resourceObject = Object(emnapiCtx.jsValueFromNapiValue(resource));
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
resourceObject = {};
|
|
563
|
+
}
|
|
564
|
+
if (!resource_name)
|
|
565
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
566
|
+
const resourceName = String(emnapiCtx.jsValueFromNapiValue(resource_name));
|
|
567
|
+
const id = emnapiAWST.create(env, resourceObject, resourceName, execute, complete, data);
|
|
568
|
+
result >>>= 0;
|
|
569
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
570
|
+
GET_HEAP_DATA_VIEW().setUint32(result, id, true);
|
|
571
|
+
return envObject.clearLastError();
|
|
572
|
+
}
|
|
573
|
+
: function (env, resource, resource_name, execute, complete, data, result) {
|
|
574
|
+
if (!env)
|
|
575
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
576
|
+
// @ts-expect-error
|
|
577
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
578
|
+
envObject.checkGCAccess();
|
|
579
|
+
if (!execute)
|
|
580
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
581
|
+
if (!result)
|
|
582
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
583
|
+
let resourceObject;
|
|
584
|
+
if (resource) {
|
|
585
|
+
resourceObject = Object(emnapiCtx.jsValueFromNapiValue(resource));
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
resourceObject = {};
|
|
589
|
+
}
|
|
590
|
+
if (!resource_name)
|
|
591
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
592
|
+
const sizeofAW = emnapiAWMT.offset.end;
|
|
593
|
+
let aw = emscripten_runtime._malloc(sizeofAW);
|
|
594
|
+
if (!aw)
|
|
595
|
+
return envObject.setLastError(9 /* napi_status.napi_generic_failure */);
|
|
596
|
+
aw >>>= 0;
|
|
597
|
+
new Uint8Array(emnapiAWMT.ensureBufferFor(aw + sizeofAW)).subarray(aw, aw + sizeofAW).fill(0);
|
|
598
|
+
const s = emnapiCtx.napiValueFromJsValue(resourceObject);
|
|
599
|
+
const resourceRef = emnapiCtx.createReference(envObject, s, 1, 1 /* ReferenceOwnership.kUserland */);
|
|
600
|
+
const resource_ = resourceRef.id;
|
|
601
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
602
|
+
GET_HEAP_DATA_VIEW().setUint32(aw, resource_, true);
|
|
603
|
+
_emnapi_node_emit_async_init(s, resource_name, -1, aw + emnapiAWMT.offset.async_id);
|
|
604
|
+
GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.env, env, true);
|
|
605
|
+
GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.execute, execute, true);
|
|
606
|
+
GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.complete, complete, true);
|
|
607
|
+
GET_HEAP_DATA_VIEW().setUint32(aw + emnapiAWMT.offset.data, data, true);
|
|
608
|
+
emnapiAWMT.queueInit(aw + emnapiAWMT.offset.queue);
|
|
609
|
+
result >>>= 0;
|
|
610
|
+
GET_HEAP_DATA_VIEW().setUint32(result, aw, true);
|
|
611
|
+
return envObject.clearLastError();
|
|
612
|
+
};
|
|
613
|
+
/** @__sig ipp */
|
|
614
|
+
var napi_delete_async_work = emnapi_shared.singleThreadAsyncWork
|
|
615
|
+
? function (env, work) {
|
|
616
|
+
if (!env)
|
|
617
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
618
|
+
// @ts-expect-error
|
|
619
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
620
|
+
envObject.checkGCAccess();
|
|
621
|
+
if (!work)
|
|
622
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
623
|
+
work >>>= 0;
|
|
624
|
+
emnapiAWST.remove(work);
|
|
625
|
+
return envObject.clearLastError();
|
|
626
|
+
}
|
|
627
|
+
: function (env, work) {
|
|
628
|
+
if (!env)
|
|
629
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
630
|
+
// @ts-expect-error
|
|
631
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
632
|
+
envObject.checkGCAccess();
|
|
633
|
+
if (!work)
|
|
634
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
635
|
+
work >>>= 0;
|
|
636
|
+
const resource = emnapiAWMT.getResource(work);
|
|
637
|
+
emnapiCtx.getRef(resource).dispose();
|
|
638
|
+
if (emnapiNodeBinding) {
|
|
639
|
+
const view = new DataView(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.trigger_async_id + 8));
|
|
640
|
+
const asyncId = view.getFloat64(work + emnapiAWMT.offset.async_id, true);
|
|
641
|
+
const triggerAsyncId = view.getFloat64(work + emnapiAWMT.offset.trigger_async_id, true);
|
|
642
|
+
_emnapi_node_emit_async_destroy(asyncId, triggerAsyncId);
|
|
643
|
+
}
|
|
644
|
+
emscripten_runtime._free(work);
|
|
645
|
+
return envObject.clearLastError();
|
|
646
|
+
};
|
|
647
|
+
/** @__sig ipp */
|
|
648
|
+
var napi_queue_async_work = emnapi_shared.singleThreadAsyncWork
|
|
649
|
+
? function (env, work) {
|
|
650
|
+
if (!env)
|
|
651
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
652
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
653
|
+
if (!work)
|
|
654
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
655
|
+
work >>>= 0;
|
|
656
|
+
emnapiAWST.queue(work);
|
|
657
|
+
return envObject.clearLastError();
|
|
658
|
+
}
|
|
659
|
+
: function (env, work) {
|
|
660
|
+
if (!env)
|
|
661
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
662
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
663
|
+
if (!work)
|
|
664
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
665
|
+
work >>>= 0;
|
|
666
|
+
emnapiAWMT.scheduleWork(work);
|
|
667
|
+
return envObject.clearLastError();
|
|
668
|
+
};
|
|
669
|
+
/** @__sig ipp */
|
|
670
|
+
var napi_cancel_async_work = emnapi_shared.singleThreadAsyncWork
|
|
671
|
+
? function (env, work) {
|
|
672
|
+
if (!env)
|
|
673
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
674
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
675
|
+
if (!work)
|
|
676
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
677
|
+
work >>>= 0;
|
|
678
|
+
const status = emnapiAWST.cancel(work);
|
|
679
|
+
if (status === 0 /* napi_status.napi_ok */)
|
|
680
|
+
return envObject.clearLastError();
|
|
681
|
+
return envObject.setLastError(status);
|
|
682
|
+
}
|
|
683
|
+
: function (env, work) {
|
|
684
|
+
if (!env)
|
|
685
|
+
return 1 /* napi_status.napi_invalid_arg */;
|
|
686
|
+
const envObject = emnapi_shared.emnapiEnv;
|
|
687
|
+
if (!work)
|
|
688
|
+
return envObject.setLastError(1 /* napi_status.napi_invalid_arg */);
|
|
689
|
+
work >>>= 0;
|
|
690
|
+
const status = emnapiAWMT.cancelWork(work);
|
|
691
|
+
if (status === 0 /* napi_status.napi_ok */)
|
|
692
|
+
return envObject.clearLastError();
|
|
693
|
+
return envObject.setLastError(status);
|
|
694
|
+
};
|
|
695
|
+
/** @__sig pp */
|
|
696
|
+
function _emnapi_async_worker(globalAddress) {
|
|
697
|
+
globalAddress >>>= 0;
|
|
698
|
+
emnapiAWMT.globalAddress = globalAddress;
|
|
699
|
+
const mutex = emnapiAWMT.getMutex();
|
|
700
|
+
const cond = emnapiAWMT.getCond();
|
|
701
|
+
mutex.lock();
|
|
702
|
+
const exitMessageAddr = globalAddress + emnapiAWMT.globalOffset.exit_message;
|
|
703
|
+
const idleThreadsAddr = globalAddress + emnapiAWMT.globalOffset.idle_threads;
|
|
704
|
+
const workerQueueAddr = globalAddress + emnapiAWMT.globalOffset.q;
|
|
705
|
+
var HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer), GET_HEAP_DATA_VIEW = () => HEAP_DATA_VIEW.buffer === emnapiPluginCtx.wasmMemory.buffer ? HEAP_DATA_VIEW : (HEAP_DATA_VIEW = new DataView(emnapiPluginCtx.wasmMemory.buffer));
|
|
706
|
+
for (;;) {
|
|
707
|
+
emnapiAWMT.ensureBufferFor(workerQueueAddr + 4);
|
|
708
|
+
while (emnapiAWMT.queueEmpty(workerQueueAddr)) {
|
|
709
|
+
Atomics.add(new Int32Array(emnapiAWMT.ensureBufferFor(idleThreadsAddr + 4), idleThreadsAddr, 1), 0, 1);
|
|
710
|
+
cond.wait();
|
|
711
|
+
Atomics.sub(new Int32Array(emnapiAWMT.ensureBufferFor(idleThreadsAddr + 4), idleThreadsAddr, 1), 0, 1);
|
|
712
|
+
}
|
|
713
|
+
const q = GET_HEAP_DATA_VIEW().getUint32(workerQueueAddr, true);
|
|
714
|
+
if (q === exitMessageAddr) {
|
|
715
|
+
cond.signal();
|
|
716
|
+
mutex.unlock();
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
const work = q - emnapiAWMT.offset.queue;
|
|
720
|
+
emnapiAWMT.queueRemove(q);
|
|
721
|
+
emnapiAWMT.queueInit(q);
|
|
722
|
+
mutex.unlock();
|
|
723
|
+
const statusBuffer = new Int32Array(emnapiAWMT.ensureBufferFor(work + emnapiAWMT.offset.status + 4), work + emnapiAWMT.offset.status, 1);
|
|
724
|
+
if (Atomics.load(statusBuffer, 0) === 1 /* AsyncWorkStatus.Cancelled */) {
|
|
725
|
+
emscripten_runtime.abort('unreachable');
|
|
726
|
+
}
|
|
727
|
+
const execute = emnapiAWMT.getExecute(work);
|
|
728
|
+
const env = emnapiAWMT.getEnv(work);
|
|
729
|
+
const data = emnapiAWMT.getData(work);
|
|
730
|
+
(emnapiPluginCtx.wasmTable.get(execute))(env, data);
|
|
731
|
+
Atomics.store(statusBuffer, 0, 2 /* AsyncWorkStatus.Completed */);
|
|
732
|
+
const postMessage = emnapi_shared.napiModule.postMessage;
|
|
733
|
+
postMessage({
|
|
734
|
+
__emnapi__: {
|
|
735
|
+
type: 'async-work-complete',
|
|
736
|
+
payload: { work }
|
|
737
|
+
}
|
|
738
|
+
});
|
|
739
|
+
mutex.lock();
|
|
740
|
+
}
|
|
741
|
+
return 0;
|
|
742
|
+
}
|
|
743
|
+
/** @__sig ipp */
|
|
744
|
+
function _emnapi_spawn_worker(f, globalAddress) {
|
|
745
|
+
if (typeof emnapi_shared.onCreateWorker !== 'function') {
|
|
746
|
+
throw new TypeError('`options.onCreateWorker` is not a function');
|
|
747
|
+
}
|
|
748
|
+
const promises = [];
|
|
749
|
+
const args = [];
|
|
750
|
+
if (!('emnapi_async_worker_create' in emscripten_runtime.wasmInstance.exports)) {
|
|
751
|
+
throw new TypeError('`emnapi_async_worker_create` is not exported, please try to add `--export=emnapi_async_worker_create` to linker flags');
|
|
752
|
+
}
|
|
753
|
+
args.push(emscripten_runtime.wasmInstance.exports.emnapi_async_worker_create(0, 0));
|
|
754
|
+
let ret;
|
|
755
|
+
try {
|
|
756
|
+
const worker = emnapi_shared.onCreateWorker({ type: 'async-work', name: 'emnapi-async-worker' });
|
|
757
|
+
const handleError = () => {
|
|
758
|
+
// Loading failures reject loadWasmModuleToWorker and are local to this
|
|
759
|
+
// worker. Once loaded, every uncaught worker error is terminal; do not
|
|
760
|
+
// depend on engine-specific RuntimeError message text.
|
|
761
|
+
if (!worker.loaded)
|
|
762
|
+
return;
|
|
763
|
+
Promise.resolve().then(() => {
|
|
764
|
+
emnapiAWMT.terminateWorkers();
|
|
765
|
+
emscripten_runtime.PThread.terminateAllThreads();
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
if (emscripten_runtime.ENVIRONMENT_IS_NODE) {
|
|
769
|
+
worker.on('error', handleError);
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
worker.addEventListener('error', handleError, false);
|
|
773
|
+
}
|
|
774
|
+
const p = emscripten_runtime.PThread.loadWasmModuleToWorker(worker);
|
|
775
|
+
emnapiAWMT.addListener(worker);
|
|
776
|
+
if (typeof emnapiPluginCtx.emnapiTSFN !== 'undefined') {
|
|
777
|
+
emnapiPluginCtx.emnapiTSFN.addListener(worker);
|
|
778
|
+
}
|
|
779
|
+
promises.push(p.then(() => {
|
|
780
|
+
if (typeof worker.unref === 'function') {
|
|
781
|
+
worker.unref();
|
|
782
|
+
}
|
|
783
|
+
}));
|
|
784
|
+
ret = emnapiAWMT.pool.push(worker) - 1;
|
|
785
|
+
const arg = args[0];
|
|
786
|
+
worker.threadBlockBase = arg;
|
|
787
|
+
worker.postMessage({
|
|
788
|
+
__emnapi__: {
|
|
789
|
+
type: 'async-worker-init',
|
|
790
|
+
payload: { arg, func: [f, globalAddress] }
|
|
791
|
+
}
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
catch (err) {
|
|
795
|
+
const arg = args[0];
|
|
796
|
+
emscripten_runtime._free(arg);
|
|
797
|
+
throw err;
|
|
798
|
+
}
|
|
799
|
+
return ret;
|
|
800
|
+
}
|
|
801
|
+
function initWorker(startArg, func) {
|
|
802
|
+
if (emnapi_shared.napiModule.childThread) {
|
|
803
|
+
if (typeof emscripten_runtime.wasmInstance.exports.emnapi_async_worker_init !== 'function') {
|
|
804
|
+
throw new TypeError('`emnapi_async_worker_init` is not exported, please try to add `--export=emnapi_async_worker_init` to linker flags');
|
|
805
|
+
}
|
|
806
|
+
emscripten_runtime.wasmInstance.exports.emnapi_async_worker_init(startArg);
|
|
807
|
+
(emnapiPluginCtx.wasmTable.get(func[0]))(func[1]);
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
throw new Error('startThread is only available in child threads');
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
emnapi_shared.napiModule.initWorker = initWorker;
|
|
814
|
+
|
|
815
|
+
//#endregion src/core/async-work.ts
|
|
816
|
+
|
|
817
|
+
exports._emnapi_async_worker = _emnapi_async_worker;
|
|
818
|
+
exports._emnapi_spawn_worker = _emnapi_spawn_worker;
|
|
819
|
+
exports.napi_cancel_async_work = napi_cancel_async_work;
|
|
820
|
+
exports.napi_create_async_work = napi_create_async_work;
|
|
821
|
+
exports.napi_delete_async_work = napi_delete_async_work;
|
|
822
|
+
exports.napi_queue_async_work = napi_queue_async_work;
|
|
823
|
+
|
|
824
|
+
return exports;
|
|
825
|
+
|
|
826
|
+
})({}, emnapiPluginCtx, emnapiPluginCtx);
|
|
827
|
+
return {
|
|
828
|
+
importObject: (original) => {
|
|
829
|
+
|
|
830
|
+
Object.keys(mod).forEach(key => {
|
|
831
|
+
if (key.startsWith('napi_') || key.startsWith('node_api_')) {
|
|
832
|
+
original.napi[key] = mod[key];
|
|
833
|
+
} else {
|
|
834
|
+
original.env[key] = mod[key];
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
//#endregion src/emnapi/async-work.js
|
|
842
|
+
|
|
843
|
+
export { asyncWork as default };
|