@qds.dev/code 0.9.1 → 0.10.0
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/README.md +7 -5
- package/lib/preview/bundler/repl-bundler-worker.qwik.mjs +6307 -5686
- package/lib/preview/bundler/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/lib/preview/bundler/wasi-worker-browser.mjs +3051 -3051
- package/lib-types/src/debug.d.ts +1 -0
- package/lib-types/src/index.d.ts +2 -0
- package/lib-types/src/preview/bundler/bundled-config.d.ts +33 -0
- package/lib-types/src/preview/bundler/bundled.d.ts +3 -0
- package/lib-types/src/preview/bundler/bundled.unit.d.ts +1 -0
- package/lib-types/src/preview/bundler/client-events-listener.d.ts +1 -0
- package/lib-types/src/preview/bundler/index.d.ts +34 -0
- package/lib-types/src/preview/bundler/repl-bundler-worker.d.ts +30 -0
- package/lib-types/src/preview/bundler/repl-ssr-worker.d.ts +27 -0
- package/lib-types/src/preview/bundler/rollup-plugins.d.ts +5 -0
- package/lib-types/src/preview/bundler/rollup-plugins.unit.d.ts +1 -0
- package/lib-types/src/preview/constants.d.ts +5 -0
- package/lib-types/src/preview/index.d.ts +19 -0
- package/lib-types/src/preview/mocks/browser.d.ts +2 -0
- package/lib-types/src/preview/preview-sw.d.ts +20 -0
- package/lib-types/src/preview/preview-sw.unit.d.ts +1 -0
- package/lib-types/src/preview/register-preview-sw.d.ts +2 -0
- package/lib-types/src/preview/register-preview-sw.unit.d.ts +1 -0
- package/lib-types/src/preview/repl-editor.d.ts +1 -0
- package/lib-types/src/preview/repl-helpers-node.d.ts +4 -0
- package/lib-types/src/preview/repl-helpers.unit.d.ts +1 -0
- package/lib-types/src/preview/test-extend.d.ts +9 -0
- package/lib-types/src/preview/types.d.ts +70 -0
- package/lib-types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -25
- package/LICENSE +0 -21
- package/lib/node_modules/.pnpm/@emnapi_core@1.7.1/node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.qwik.mjs +0 -5533
- package/lib/node_modules/.pnpm/@emnapi_runtime@1.8.1/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.qwik.mjs +0 -1225
- package/lib/node_modules/.pnpm/@emnapi_wasi-threads@1.1.0/node_modules/@emnapi/wasi-threads/dist/wasi-threads.esm-bundler.qwik.mjs +0 -619
- package/lib/node_modules/.pnpm/@napi-rs_wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/dist/fs.qwik.mjs +0 -14854
- package/lib/node_modules/.pnpm/@napi-rs_wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/fs-proxy.qwik.mjs +0 -109
- package/lib/node_modules/.pnpm/@napi-rs_wasm-runtime@1.1.1/node_modules/@napi-rs/wasm-runtime/runtime.qwik.mjs +0 -4
- package/lib/node_modules/.pnpm/@qwik.dev_core@2.0.0-beta.15_vite@7.1.5_@types_node@24.9.0_jiti@2.6.1_lightningcss@1.30.1_ter_sl453hnfnrysgqsj6ikt4cdmnq/node_modules/@qwik.dev/core/dist/qwikloader.qwik.mjs +0 -152
- package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/index.browser.qwik.mjs +0 -13
- package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/normalize-string-or-regex-BB1FWNyl.qwik.mjs +0 -789
- package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/rolldown-binding.wasi-browser.qwik.mjs +0 -107
- package/lib/node_modules/.pnpm/@rolldown_browser@1.0.0-beta.59/node_modules/@rolldown/browser/dist/rolldown-build-Bfw5c2c3.qwik.mjs +0 -4157
- package/lib/node_modules/.pnpm/@tybys_wasm-util@0.10.1/node_modules/@tybys/wasm-util/dist/wasm-util.esm-bundler.qwik.mjs +0 -1968
- package/lib/node_modules/.pnpm/magic-regexp@0.10.0/node_modules/magic-regexp/dist/index.qwik.mjs +0 -10
- package/lib/node_modules/.pnpm/magic-regexp@0.10.0/node_modules/magic-regexp/dist/shared/magic-regexp.DKp_q_HX.qwik.mjs +0 -95
- package/lib/node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.qwik.mjs +0 -34
- package/lib/vite/repl-plugin.qwik.mjs +0 -31
- package/lib-types/src/vite/repl-plugin.d.ts +0 -7
|
@@ -1,1225 +0,0 @@
|
|
|
1
|
-
import { __require } from "../../../../../../../_virtual/rolldown_runtime.qwik.mjs";
|
|
2
|
-
import { __extends } from "../../../../../tslib@2.8.1/node_modules/tslib/tslib.es6.qwik.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/@emnapi+runtime@1.8.1/node_modules/@emnapi/runtime/dist/emnapi.esm-bundler.js
|
|
5
|
-
var externalValue = /* @__PURE__ */ new WeakMap();
|
|
6
|
-
/** @public */
|
|
7
|
-
function isExternal(object) {
|
|
8
|
-
return externalValue.has(object);
|
|
9
|
-
}
|
|
10
|
-
/** @public */ var External = (function() {
|
|
11
|
-
function External$1(value) {
|
|
12
|
-
Object.setPrototypeOf(this, null);
|
|
13
|
-
externalValue.set(this, value);
|
|
14
|
-
}
|
|
15
|
-
External$1.prototype = null;
|
|
16
|
-
return External$1;
|
|
17
|
-
})();
|
|
18
|
-
/** @public */
|
|
19
|
-
function getExternalValue(external) {
|
|
20
|
-
if (!isExternal(external)) throw new TypeError("not external");
|
|
21
|
-
return externalValue.get(external);
|
|
22
|
-
}
|
|
23
|
-
var supportNewFunction = /* @__PURE__ */ (function() {
|
|
24
|
-
var f;
|
|
25
|
-
try {
|
|
26
|
-
f = new Function();
|
|
27
|
-
} catch (_) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return typeof f === "function";
|
|
31
|
-
})();
|
|
32
|
-
var _global = /* @__PURE__ */ (function() {
|
|
33
|
-
if (typeof globalThis !== "undefined") return globalThis;
|
|
34
|
-
var g = (function() {
|
|
35
|
-
return this;
|
|
36
|
-
})();
|
|
37
|
-
if (!g && supportNewFunction) try {
|
|
38
|
-
g = new Function("return this")();
|
|
39
|
-
} catch (_) {}
|
|
40
|
-
if (!g) {
|
|
41
|
-
if (typeof __webpack_public_path__ === "undefined") {
|
|
42
|
-
if (typeof global !== "undefined") return global;
|
|
43
|
-
}
|
|
44
|
-
if (typeof window !== "undefined") return window;
|
|
45
|
-
if (typeof self !== "undefined") return self;
|
|
46
|
-
}
|
|
47
|
-
return g;
|
|
48
|
-
})();
|
|
49
|
-
var TryCatch = /* @__PURE__ */ function() {
|
|
50
|
-
function TryCatch$1() {
|
|
51
|
-
this._exception = void 0;
|
|
52
|
-
this._caught = false;
|
|
53
|
-
}
|
|
54
|
-
TryCatch$1.prototype.isEmpty = function() {
|
|
55
|
-
return !this._caught;
|
|
56
|
-
};
|
|
57
|
-
TryCatch$1.prototype.hasCaught = function() {
|
|
58
|
-
return this._caught;
|
|
59
|
-
};
|
|
60
|
-
TryCatch$1.prototype.exception = function() {
|
|
61
|
-
return this._exception;
|
|
62
|
-
};
|
|
63
|
-
TryCatch$1.prototype.setError = function(err) {
|
|
64
|
-
this._caught = true;
|
|
65
|
-
this._exception = err;
|
|
66
|
-
};
|
|
67
|
-
TryCatch$1.prototype.reset = function() {
|
|
68
|
-
this._caught = false;
|
|
69
|
-
this._exception = void 0;
|
|
70
|
-
};
|
|
71
|
-
TryCatch$1.prototype.extractException = function() {
|
|
72
|
-
var e = this._exception;
|
|
73
|
-
this.reset();
|
|
74
|
-
return e;
|
|
75
|
-
};
|
|
76
|
-
return TryCatch$1;
|
|
77
|
-
}();
|
|
78
|
-
var canSetFunctionName = /* @__PURE__ */ (function() {
|
|
79
|
-
var _a;
|
|
80
|
-
try {
|
|
81
|
-
return Boolean((_a = Object.getOwnPropertyDescriptor(Function.prototype, "name")) === null || _a === void 0 ? void 0 : _a.configurable);
|
|
82
|
-
} catch (_) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
})();
|
|
86
|
-
var supportReflect = typeof Reflect === "object";
|
|
87
|
-
var supportFinalizer = typeof FinalizationRegistry !== "undefined" && typeof WeakRef !== "undefined";
|
|
88
|
-
var supportWeakSymbol = /* @__PURE__ */ (function() {
|
|
89
|
-
try {
|
|
90
|
-
var sym = Symbol();
|
|
91
|
-
new WeakRef(sym);
|
|
92
|
-
(/* @__PURE__ */ new WeakMap()).set(sym, void 0);
|
|
93
|
-
} catch (_) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return true;
|
|
97
|
-
})();
|
|
98
|
-
var supportBigInt = typeof BigInt !== "undefined";
|
|
99
|
-
var _require = /* @__PURE__ */ (function() {
|
|
100
|
-
var nativeRequire;
|
|
101
|
-
if (typeof __webpack_public_path__ !== "undefined") nativeRequire = (function() {
|
|
102
|
-
return typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : void 0;
|
|
103
|
-
})();
|
|
104
|
-
else nativeRequire = (function() {
|
|
105
|
-
return typeof __webpack_public_path__ !== "undefined" ? typeof __non_webpack_require__ !== "undefined" ? __non_webpack_require__ : void 0 : typeof __require !== "undefined" ? __require : void 0;
|
|
106
|
-
})();
|
|
107
|
-
return nativeRequire;
|
|
108
|
-
})();
|
|
109
|
-
var _MessageChannel = typeof MessageChannel === "function" ? MessageChannel : /* @__PURE__ */ (function() {
|
|
110
|
-
try {
|
|
111
|
-
return _require("worker_threads").MessageChannel;
|
|
112
|
-
} catch (_) {}
|
|
113
|
-
})();
|
|
114
|
-
var _setImmediate = typeof setImmediate === "function" ? setImmediate : function(callback) {
|
|
115
|
-
if (typeof callback !== "function") throw new TypeError("The \"callback\" argument must be of type function");
|
|
116
|
-
if (_MessageChannel) {
|
|
117
|
-
var channel_1 = new _MessageChannel();
|
|
118
|
-
channel_1.port1.onmessage = function() {
|
|
119
|
-
channel_1.port1.onmessage = null;
|
|
120
|
-
channel_1 = void 0;
|
|
121
|
-
callback();
|
|
122
|
-
};
|
|
123
|
-
channel_1.port2.postMessage(null);
|
|
124
|
-
} else setTimeout(callback, 0);
|
|
125
|
-
};
|
|
126
|
-
var _Buffer = typeof Buffer === "function" ? Buffer : /* @__PURE__ */ (function() {
|
|
127
|
-
try {
|
|
128
|
-
return _require("buffer").Buffer;
|
|
129
|
-
} catch (_) {}
|
|
130
|
-
})();
|
|
131
|
-
var version = "1.8.1";
|
|
132
|
-
var NODE_API_SUPPORTED_VERSION_MAX = 10;
|
|
133
|
-
var NAPI_VERSION_EXPERIMENTAL = 2147483647;
|
|
134
|
-
var NODE_API_DEFAULT_MODULE_API_VERSION = 8;
|
|
135
|
-
var Handle = /* @__PURE__ */ function() {
|
|
136
|
-
function Handle$1(id, value) {
|
|
137
|
-
this.id = id;
|
|
138
|
-
this.value = value;
|
|
139
|
-
}
|
|
140
|
-
Handle$1.prototype.data = function() {
|
|
141
|
-
return getExternalValue(this.value);
|
|
142
|
-
};
|
|
143
|
-
Handle$1.prototype.isNumber = function() {
|
|
144
|
-
return typeof this.value === "number";
|
|
145
|
-
};
|
|
146
|
-
Handle$1.prototype.isBigInt = function() {
|
|
147
|
-
return typeof this.value === "bigint";
|
|
148
|
-
};
|
|
149
|
-
Handle$1.prototype.isString = function() {
|
|
150
|
-
return typeof this.value === "string";
|
|
151
|
-
};
|
|
152
|
-
Handle$1.prototype.isFunction = function() {
|
|
153
|
-
return typeof this.value === "function";
|
|
154
|
-
};
|
|
155
|
-
Handle$1.prototype.isExternal = function() {
|
|
156
|
-
return isExternal(this.value);
|
|
157
|
-
};
|
|
158
|
-
Handle$1.prototype.isObject = function() {
|
|
159
|
-
return typeof this.value === "object" && this.value !== null;
|
|
160
|
-
};
|
|
161
|
-
Handle$1.prototype.isArray = function() {
|
|
162
|
-
return Array.isArray(this.value);
|
|
163
|
-
};
|
|
164
|
-
Handle$1.prototype.isArrayBuffer = function() {
|
|
165
|
-
return this.value instanceof ArrayBuffer;
|
|
166
|
-
};
|
|
167
|
-
Handle$1.prototype.isTypedArray = function() {
|
|
168
|
-
return ArrayBuffer.isView(this.value) && !(this.value instanceof DataView);
|
|
169
|
-
};
|
|
170
|
-
Handle$1.prototype.isBuffer = function(BufferConstructor) {
|
|
171
|
-
if (ArrayBuffer.isView(this.value)) return true;
|
|
172
|
-
BufferConstructor !== null && BufferConstructor !== void 0 || (BufferConstructor = _Buffer);
|
|
173
|
-
return typeof BufferConstructor === "function" && BufferConstructor.isBuffer(this.value);
|
|
174
|
-
};
|
|
175
|
-
Handle$1.prototype.isDataView = function() {
|
|
176
|
-
return this.value instanceof DataView;
|
|
177
|
-
};
|
|
178
|
-
Handle$1.prototype.isDate = function() {
|
|
179
|
-
return this.value instanceof Date;
|
|
180
|
-
};
|
|
181
|
-
Handle$1.prototype.isPromise = function() {
|
|
182
|
-
return this.value instanceof Promise;
|
|
183
|
-
};
|
|
184
|
-
Handle$1.prototype.isBoolean = function() {
|
|
185
|
-
return typeof this.value === "boolean";
|
|
186
|
-
};
|
|
187
|
-
Handle$1.prototype.isUndefined = function() {
|
|
188
|
-
return this.value === void 0;
|
|
189
|
-
};
|
|
190
|
-
Handle$1.prototype.isSymbol = function() {
|
|
191
|
-
return typeof this.value === "symbol";
|
|
192
|
-
};
|
|
193
|
-
Handle$1.prototype.isNull = function() {
|
|
194
|
-
return this.value === null;
|
|
195
|
-
};
|
|
196
|
-
Handle$1.prototype.dispose = function() {
|
|
197
|
-
this.value = void 0;
|
|
198
|
-
};
|
|
199
|
-
return Handle$1;
|
|
200
|
-
}();
|
|
201
|
-
var ConstHandle = /* @__PURE__ */ function(_super) {
|
|
202
|
-
__extends(ConstHandle$1, _super);
|
|
203
|
-
function ConstHandle$1(id, value) {
|
|
204
|
-
return _super.call(this, id, value) || this;
|
|
205
|
-
}
|
|
206
|
-
ConstHandle$1.prototype.dispose = function() {};
|
|
207
|
-
return ConstHandle$1;
|
|
208
|
-
}(Handle);
|
|
209
|
-
var HandleStore = /* @__PURE__ */ function() {
|
|
210
|
-
function HandleStore$1() {
|
|
211
|
-
this._values = [
|
|
212
|
-
void 0,
|
|
213
|
-
HandleStore$1.UNDEFINED,
|
|
214
|
-
HandleStore$1.NULL,
|
|
215
|
-
HandleStore$1.FALSE,
|
|
216
|
-
HandleStore$1.TRUE,
|
|
217
|
-
HandleStore$1.GLOBAL
|
|
218
|
-
];
|
|
219
|
-
this._next = HandleStore$1.MIN_ID;
|
|
220
|
-
}
|
|
221
|
-
HandleStore$1.prototype.push = function(value) {
|
|
222
|
-
var h;
|
|
223
|
-
var next = this._next;
|
|
224
|
-
var values = this._values;
|
|
225
|
-
if (next < values.length) {
|
|
226
|
-
h = values[next];
|
|
227
|
-
h.value = value;
|
|
228
|
-
} else {
|
|
229
|
-
h = new Handle(next, value);
|
|
230
|
-
values[next] = h;
|
|
231
|
-
}
|
|
232
|
-
this._next++;
|
|
233
|
-
return h;
|
|
234
|
-
};
|
|
235
|
-
HandleStore$1.prototype.erase = function(start, end) {
|
|
236
|
-
this._next = start;
|
|
237
|
-
var values = this._values;
|
|
238
|
-
for (var i = start; i < end; ++i) values[i].dispose();
|
|
239
|
-
};
|
|
240
|
-
HandleStore$1.prototype.get = function(id) {
|
|
241
|
-
return this._values[id];
|
|
242
|
-
};
|
|
243
|
-
HandleStore$1.prototype.swap = function(a, b) {
|
|
244
|
-
var values = this._values;
|
|
245
|
-
var h = values[a];
|
|
246
|
-
values[a] = values[b];
|
|
247
|
-
values[a].id = Number(a);
|
|
248
|
-
values[b] = h;
|
|
249
|
-
h.id = Number(b);
|
|
250
|
-
};
|
|
251
|
-
HandleStore$1.prototype.dispose = function() {
|
|
252
|
-
this._values.length = HandleStore$1.MIN_ID;
|
|
253
|
-
this._next = HandleStore$1.MIN_ID;
|
|
254
|
-
};
|
|
255
|
-
HandleStore$1.UNDEFINED = new ConstHandle(1, void 0);
|
|
256
|
-
HandleStore$1.NULL = new ConstHandle(2, null);
|
|
257
|
-
HandleStore$1.FALSE = new ConstHandle(3, false);
|
|
258
|
-
HandleStore$1.TRUE = new ConstHandle(4, true);
|
|
259
|
-
HandleStore$1.GLOBAL = new ConstHandle(5, _global);
|
|
260
|
-
HandleStore$1.MIN_ID = 6;
|
|
261
|
-
return HandleStore$1;
|
|
262
|
-
}();
|
|
263
|
-
var HandleScope = /* @__PURE__ */ function() {
|
|
264
|
-
function HandleScope$1(handleStore, id, parentScope, start, end) {
|
|
265
|
-
if (end === void 0) end = start;
|
|
266
|
-
this.handleStore = handleStore;
|
|
267
|
-
this.id = id;
|
|
268
|
-
this.parent = parentScope;
|
|
269
|
-
this.child = null;
|
|
270
|
-
if (parentScope !== null) parentScope.child = this;
|
|
271
|
-
this.start = start;
|
|
272
|
-
this.end = end;
|
|
273
|
-
this._escapeCalled = false;
|
|
274
|
-
this.callbackInfo = {
|
|
275
|
-
thiz: void 0,
|
|
276
|
-
data: 0,
|
|
277
|
-
args: void 0,
|
|
278
|
-
fn: void 0
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
HandleScope$1.prototype.add = function(value) {
|
|
282
|
-
var h = this.handleStore.push(value);
|
|
283
|
-
this.end++;
|
|
284
|
-
return h;
|
|
285
|
-
};
|
|
286
|
-
HandleScope$1.prototype.addExternal = function(data) {
|
|
287
|
-
return this.add(new External(data));
|
|
288
|
-
};
|
|
289
|
-
HandleScope$1.prototype.dispose = function() {
|
|
290
|
-
if (this._escapeCalled) this._escapeCalled = false;
|
|
291
|
-
if (this.start === this.end) return;
|
|
292
|
-
this.handleStore.erase(this.start, this.end);
|
|
293
|
-
};
|
|
294
|
-
HandleScope$1.prototype.escape = function(handle) {
|
|
295
|
-
if (this._escapeCalled) return null;
|
|
296
|
-
this._escapeCalled = true;
|
|
297
|
-
if (handle < this.start || handle >= this.end) return null;
|
|
298
|
-
this.handleStore.swap(handle, this.start);
|
|
299
|
-
var h = this.handleStore.get(this.start);
|
|
300
|
-
this.start++;
|
|
301
|
-
this.parent.end++;
|
|
302
|
-
return h;
|
|
303
|
-
};
|
|
304
|
-
HandleScope$1.prototype.escapeCalled = function() {
|
|
305
|
-
return this._escapeCalled;
|
|
306
|
-
};
|
|
307
|
-
return HandleScope$1;
|
|
308
|
-
}();
|
|
309
|
-
var ScopeStore = /* @__PURE__ */ function() {
|
|
310
|
-
function ScopeStore$1() {
|
|
311
|
-
this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
|
|
312
|
-
this.currentScope = this._rootScope;
|
|
313
|
-
this._values = [void 0];
|
|
314
|
-
}
|
|
315
|
-
ScopeStore$1.prototype.get = function(id) {
|
|
316
|
-
return this._values[id];
|
|
317
|
-
};
|
|
318
|
-
ScopeStore$1.prototype.openScope = function(handleStore) {
|
|
319
|
-
var currentScope = this.currentScope;
|
|
320
|
-
var scope = currentScope.child;
|
|
321
|
-
if (scope !== null) scope.start = scope.end = currentScope.end;
|
|
322
|
-
else {
|
|
323
|
-
var id = currentScope.id + 1;
|
|
324
|
-
scope = new HandleScope(handleStore, id, currentScope, currentScope.end);
|
|
325
|
-
this._values[id] = scope;
|
|
326
|
-
}
|
|
327
|
-
this.currentScope = scope;
|
|
328
|
-
return scope;
|
|
329
|
-
};
|
|
330
|
-
ScopeStore$1.prototype.closeScope = function() {
|
|
331
|
-
var scope = this.currentScope;
|
|
332
|
-
this.currentScope = scope.parent;
|
|
333
|
-
scope.dispose();
|
|
334
|
-
};
|
|
335
|
-
ScopeStore$1.prototype.dispose = function() {
|
|
336
|
-
this.currentScope = this._rootScope;
|
|
337
|
-
this._values.length = 1;
|
|
338
|
-
};
|
|
339
|
-
return ScopeStore$1;
|
|
340
|
-
}();
|
|
341
|
-
var RefTracker = /* @__PURE__ */ function() {
|
|
342
|
-
function RefTracker$1() {
|
|
343
|
-
this._next = null;
|
|
344
|
-
this._prev = null;
|
|
345
|
-
}
|
|
346
|
-
/** @virtual */
|
|
347
|
-
RefTracker$1.prototype.dispose = function() {};
|
|
348
|
-
/** @virtual */
|
|
349
|
-
RefTracker$1.prototype.finalize = function() {};
|
|
350
|
-
RefTracker$1.prototype.link = function(list) {
|
|
351
|
-
this._prev = list;
|
|
352
|
-
this._next = list._next;
|
|
353
|
-
if (this._next !== null) this._next._prev = this;
|
|
354
|
-
list._next = this;
|
|
355
|
-
};
|
|
356
|
-
RefTracker$1.prototype.unlink = function() {
|
|
357
|
-
if (this._prev !== null) this._prev._next = this._next;
|
|
358
|
-
if (this._next !== null) this._next._prev = this._prev;
|
|
359
|
-
this._prev = null;
|
|
360
|
-
this._next = null;
|
|
361
|
-
};
|
|
362
|
-
RefTracker$1.finalizeAll = function(list) {
|
|
363
|
-
while (list._next !== null) list._next.finalize();
|
|
364
|
-
};
|
|
365
|
-
return RefTracker$1;
|
|
366
|
-
}();
|
|
367
|
-
var Finalizer = /* @__PURE__ */ function() {
|
|
368
|
-
function Finalizer$1(envObject, _finalizeCallback, _finalizeData, _finalizeHint) {
|
|
369
|
-
if (_finalizeCallback === void 0) _finalizeCallback = 0;
|
|
370
|
-
if (_finalizeData === void 0) _finalizeData = 0;
|
|
371
|
-
if (_finalizeHint === void 0) _finalizeHint = 0;
|
|
372
|
-
this.envObject = envObject;
|
|
373
|
-
this._finalizeCallback = _finalizeCallback;
|
|
374
|
-
this._finalizeData = _finalizeData;
|
|
375
|
-
this._finalizeHint = _finalizeHint;
|
|
376
|
-
this._makeDynCall_vppp = envObject.makeDynCall_vppp;
|
|
377
|
-
}
|
|
378
|
-
Finalizer$1.prototype.callback = function() {
|
|
379
|
-
return this._finalizeCallback;
|
|
380
|
-
};
|
|
381
|
-
Finalizer$1.prototype.data = function() {
|
|
382
|
-
return this._finalizeData;
|
|
383
|
-
};
|
|
384
|
-
Finalizer$1.prototype.hint = function() {
|
|
385
|
-
return this._finalizeHint;
|
|
386
|
-
};
|
|
387
|
-
Finalizer$1.prototype.resetEnv = function() {
|
|
388
|
-
this.envObject = void 0;
|
|
389
|
-
};
|
|
390
|
-
Finalizer$1.prototype.resetFinalizer = function() {
|
|
391
|
-
this._finalizeCallback = 0;
|
|
392
|
-
this._finalizeData = 0;
|
|
393
|
-
this._finalizeHint = 0;
|
|
394
|
-
};
|
|
395
|
-
Finalizer$1.prototype.callFinalizer = function() {
|
|
396
|
-
var finalize_callback = this._finalizeCallback;
|
|
397
|
-
var finalize_data = this._finalizeData;
|
|
398
|
-
var finalize_hint = this._finalizeHint;
|
|
399
|
-
this.resetFinalizer();
|
|
400
|
-
if (!finalize_callback) return;
|
|
401
|
-
var fini = Number(finalize_callback);
|
|
402
|
-
if (!this.envObject) this._makeDynCall_vppp(fini)(0, finalize_data, finalize_hint);
|
|
403
|
-
else this.envObject.callFinalizer(fini, finalize_data, finalize_hint);
|
|
404
|
-
};
|
|
405
|
-
Finalizer$1.prototype.dispose = function() {
|
|
406
|
-
this.envObject = void 0;
|
|
407
|
-
this._makeDynCall_vppp = void 0;
|
|
408
|
-
};
|
|
409
|
-
return Finalizer$1;
|
|
410
|
-
}();
|
|
411
|
-
var TrackedFinalizer = /* @__PURE__ */ function(_super) {
|
|
412
|
-
__extends(TrackedFinalizer$1, _super);
|
|
413
|
-
function TrackedFinalizer$1(envObject, finalize_callback, finalize_data, finalize_hint) {
|
|
414
|
-
var _this = _super.call(this) || this;
|
|
415
|
-
_this._finalizer = new Finalizer(envObject, finalize_callback, finalize_data, finalize_hint);
|
|
416
|
-
return _this;
|
|
417
|
-
}
|
|
418
|
-
TrackedFinalizer$1.create = function(envObject, finalize_callback, finalize_data, finalize_hint) {
|
|
419
|
-
var finalizer = new TrackedFinalizer$1(envObject, finalize_callback, finalize_data, finalize_hint);
|
|
420
|
-
finalizer.link(envObject.finalizing_reflist);
|
|
421
|
-
return finalizer;
|
|
422
|
-
};
|
|
423
|
-
TrackedFinalizer$1.prototype.data = function() {
|
|
424
|
-
return this._finalizer.data();
|
|
425
|
-
};
|
|
426
|
-
TrackedFinalizer$1.prototype.dispose = function() {
|
|
427
|
-
if (!this._finalizer) return;
|
|
428
|
-
this.unlink();
|
|
429
|
-
this._finalizer.envObject.dequeueFinalizer(this);
|
|
430
|
-
this._finalizer.dispose();
|
|
431
|
-
this._finalizer = void 0;
|
|
432
|
-
_super.prototype.dispose.call(this);
|
|
433
|
-
};
|
|
434
|
-
TrackedFinalizer$1.prototype.finalize = function() {
|
|
435
|
-
this.unlink();
|
|
436
|
-
var error;
|
|
437
|
-
var caught = false;
|
|
438
|
-
try {
|
|
439
|
-
this._finalizer.callFinalizer();
|
|
440
|
-
} catch (err) {
|
|
441
|
-
caught = true;
|
|
442
|
-
error = err;
|
|
443
|
-
}
|
|
444
|
-
this.dispose();
|
|
445
|
-
if (caught) throw error;
|
|
446
|
-
};
|
|
447
|
-
return TrackedFinalizer$1;
|
|
448
|
-
}(RefTracker);
|
|
449
|
-
function throwNodeApiVersionError(moduleName, moduleApiVersion) {
|
|
450
|
-
var errorMessage = "".concat(moduleName, " requires Node-API version ").concat(moduleApiVersion, ", but this version of Node.js only supports version ").concat(NODE_API_SUPPORTED_VERSION_MAX, " add-ons.");
|
|
451
|
-
throw new Error(errorMessage);
|
|
452
|
-
}
|
|
453
|
-
function handleThrow(envObject, value) {
|
|
454
|
-
if (envObject.terminatedOrTerminating()) return;
|
|
455
|
-
throw value;
|
|
456
|
-
}
|
|
457
|
-
var Env = /* @__PURE__ */ function() {
|
|
458
|
-
function Env$1(ctx, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort) {
|
|
459
|
-
this.ctx = ctx;
|
|
460
|
-
this.moduleApiVersion = moduleApiVersion;
|
|
461
|
-
this.makeDynCall_vppp = makeDynCall_vppp;
|
|
462
|
-
this.makeDynCall_vp = makeDynCall_vp;
|
|
463
|
-
this.abort = abort;
|
|
464
|
-
this.openHandleScopes = 0;
|
|
465
|
-
this.instanceData = null;
|
|
466
|
-
this.tryCatch = new TryCatch();
|
|
467
|
-
this.refs = 1;
|
|
468
|
-
this.reflist = new RefTracker();
|
|
469
|
-
this.finalizing_reflist = new RefTracker();
|
|
470
|
-
this.pendingFinalizers = [];
|
|
471
|
-
this.lastError = {
|
|
472
|
-
errorCode: 0,
|
|
473
|
-
engineErrorCode: 0,
|
|
474
|
-
engineReserved: 0
|
|
475
|
-
};
|
|
476
|
-
this.inGcFinalizer = false;
|
|
477
|
-
this._bindingMap = /* @__PURE__ */ new WeakMap();
|
|
478
|
-
this.id = 0;
|
|
479
|
-
}
|
|
480
|
-
/** @virtual */
|
|
481
|
-
Env$1.prototype.canCallIntoJs = function() {
|
|
482
|
-
return true;
|
|
483
|
-
};
|
|
484
|
-
Env$1.prototype.terminatedOrTerminating = function() {
|
|
485
|
-
return !this.canCallIntoJs();
|
|
486
|
-
};
|
|
487
|
-
Env$1.prototype.ref = function() {
|
|
488
|
-
this.refs++;
|
|
489
|
-
};
|
|
490
|
-
Env$1.prototype.unref = function() {
|
|
491
|
-
this.refs--;
|
|
492
|
-
if (this.refs === 0) this.dispose();
|
|
493
|
-
};
|
|
494
|
-
Env$1.prototype.ensureHandle = function(value) {
|
|
495
|
-
return this.ctx.ensureHandle(value);
|
|
496
|
-
};
|
|
497
|
-
Env$1.prototype.ensureHandleId = function(value) {
|
|
498
|
-
return this.ensureHandle(value).id;
|
|
499
|
-
};
|
|
500
|
-
Env$1.prototype.clearLastError = function() {
|
|
501
|
-
var lastError = this.lastError;
|
|
502
|
-
if (lastError.errorCode !== 0) lastError.errorCode = 0;
|
|
503
|
-
if (lastError.engineErrorCode !== 0) lastError.engineErrorCode = 0;
|
|
504
|
-
if (lastError.engineReserved !== 0) lastError.engineReserved = 0;
|
|
505
|
-
return 0;
|
|
506
|
-
};
|
|
507
|
-
Env$1.prototype.setLastError = function(error_code, engine_error_code, engine_reserved) {
|
|
508
|
-
if (engine_error_code === void 0) engine_error_code = 0;
|
|
509
|
-
if (engine_reserved === void 0) engine_reserved = 0;
|
|
510
|
-
var lastError = this.lastError;
|
|
511
|
-
if (lastError.errorCode !== error_code) lastError.errorCode = error_code;
|
|
512
|
-
if (lastError.engineErrorCode !== engine_error_code) lastError.engineErrorCode = engine_error_code;
|
|
513
|
-
if (lastError.engineReserved !== engine_reserved) lastError.engineReserved = engine_reserved;
|
|
514
|
-
return error_code;
|
|
515
|
-
};
|
|
516
|
-
Env$1.prototype.getReturnStatus = function() {
|
|
517
|
-
return !this.tryCatch.hasCaught() ? 0 : this.setLastError(10);
|
|
518
|
-
};
|
|
519
|
-
Env$1.prototype.callIntoModule = function(fn, handleException) {
|
|
520
|
-
if (handleException === void 0) handleException = handleThrow;
|
|
521
|
-
var openHandleScopesBefore = this.openHandleScopes;
|
|
522
|
-
this.clearLastError();
|
|
523
|
-
var r = fn(this);
|
|
524
|
-
if (openHandleScopesBefore !== this.openHandleScopes) this.abort("open_handle_scopes != open_handle_scopes_before");
|
|
525
|
-
if (this.tryCatch.hasCaught()) {
|
|
526
|
-
var err = this.tryCatch.extractException();
|
|
527
|
-
handleException(this, err);
|
|
528
|
-
}
|
|
529
|
-
return r;
|
|
530
|
-
};
|
|
531
|
-
Env$1.prototype.invokeFinalizerFromGC = function(finalizer) {
|
|
532
|
-
if (this.moduleApiVersion !== NAPI_VERSION_EXPERIMENTAL) this.enqueueFinalizer(finalizer);
|
|
533
|
-
else {
|
|
534
|
-
var saved = this.inGcFinalizer;
|
|
535
|
-
this.inGcFinalizer = true;
|
|
536
|
-
try {
|
|
537
|
-
finalizer.finalize();
|
|
538
|
-
} finally {
|
|
539
|
-
this.inGcFinalizer = saved;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
};
|
|
543
|
-
Env$1.prototype.checkGCAccess = function() {
|
|
544
|
-
if (this.moduleApiVersion === NAPI_VERSION_EXPERIMENTAL && this.inGcFinalizer) this.abort("Finalizer is calling a function that may affect GC state.\nThe finalizers are run directly from GC and must not affect GC state.\nUse `node_api_post_finalizer` from inside of the finalizer to work around this issue.\nIt schedules the call as a new task in the event loop.");
|
|
545
|
-
};
|
|
546
|
-
/** @virtual */
|
|
547
|
-
Env$1.prototype.enqueueFinalizer = function(finalizer) {
|
|
548
|
-
if (this.pendingFinalizers.indexOf(finalizer) === -1) this.pendingFinalizers.push(finalizer);
|
|
549
|
-
};
|
|
550
|
-
/** @virtual */
|
|
551
|
-
Env$1.prototype.dequeueFinalizer = function(finalizer) {
|
|
552
|
-
var index = this.pendingFinalizers.indexOf(finalizer);
|
|
553
|
-
if (index !== -1) this.pendingFinalizers.splice(index, 1);
|
|
554
|
-
};
|
|
555
|
-
/** @virtual */
|
|
556
|
-
Env$1.prototype.deleteMe = function() {
|
|
557
|
-
RefTracker.finalizeAll(this.finalizing_reflist);
|
|
558
|
-
RefTracker.finalizeAll(this.reflist);
|
|
559
|
-
this.tryCatch.extractException();
|
|
560
|
-
this.ctx.envStore.remove(this.id);
|
|
561
|
-
};
|
|
562
|
-
Env$1.prototype.dispose = function() {
|
|
563
|
-
if (this.id === 0) return;
|
|
564
|
-
this.deleteMe();
|
|
565
|
-
this.finalizing_reflist.dispose();
|
|
566
|
-
this.reflist.dispose();
|
|
567
|
-
this.id = 0;
|
|
568
|
-
};
|
|
569
|
-
Env$1.prototype.initObjectBinding = function(value) {
|
|
570
|
-
var binding = {
|
|
571
|
-
wrapped: 0,
|
|
572
|
-
tag: null
|
|
573
|
-
};
|
|
574
|
-
this._bindingMap.set(value, binding);
|
|
575
|
-
return binding;
|
|
576
|
-
};
|
|
577
|
-
Env$1.prototype.getObjectBinding = function(value) {
|
|
578
|
-
if (this._bindingMap.has(value)) return this._bindingMap.get(value);
|
|
579
|
-
return this.initObjectBinding(value);
|
|
580
|
-
};
|
|
581
|
-
Env$1.prototype.setInstanceData = function(data, finalize_cb, finalize_hint) {
|
|
582
|
-
if (this.instanceData) this.instanceData.dispose();
|
|
583
|
-
this.instanceData = TrackedFinalizer.create(this, finalize_cb, data, finalize_hint);
|
|
584
|
-
};
|
|
585
|
-
Env$1.prototype.getInstanceData = function() {
|
|
586
|
-
return this.instanceData ? this.instanceData.data() : 0;
|
|
587
|
-
};
|
|
588
|
-
return Env$1;
|
|
589
|
-
}();
|
|
590
|
-
var NodeEnv = /* @__PURE__ */ function(_super) {
|
|
591
|
-
__extends(NodeEnv$1, _super);
|
|
592
|
-
function NodeEnv$1(ctx, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding) {
|
|
593
|
-
var _this = _super.call(this, ctx, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort) || this;
|
|
594
|
-
_this.filename = filename;
|
|
595
|
-
_this.nodeBinding = nodeBinding;
|
|
596
|
-
_this.destructing = false;
|
|
597
|
-
_this.finalizationScheduled = false;
|
|
598
|
-
return _this;
|
|
599
|
-
}
|
|
600
|
-
NodeEnv$1.prototype.deleteMe = function() {
|
|
601
|
-
this.destructing = true;
|
|
602
|
-
this.drainFinalizerQueue();
|
|
603
|
-
_super.prototype.deleteMe.call(this);
|
|
604
|
-
};
|
|
605
|
-
NodeEnv$1.prototype.canCallIntoJs = function() {
|
|
606
|
-
return _super.prototype.canCallIntoJs.call(this) && this.ctx.canCallIntoJs();
|
|
607
|
-
};
|
|
608
|
-
NodeEnv$1.prototype.triggerFatalException = function(err) {
|
|
609
|
-
if (this.nodeBinding) this.nodeBinding.napi.fatalException(err);
|
|
610
|
-
else if (typeof process === "object" && process !== null && typeof process._fatalException === "function") {
|
|
611
|
-
if (!process._fatalException(err)) {
|
|
612
|
-
console.error(err);
|
|
613
|
-
process.exit(1);
|
|
614
|
-
}
|
|
615
|
-
} else throw err;
|
|
616
|
-
};
|
|
617
|
-
NodeEnv$1.prototype.callbackIntoModule = function(enforceUncaughtExceptionPolicy, fn) {
|
|
618
|
-
return this.callIntoModule(fn, function(envObject, err) {
|
|
619
|
-
if (envObject.terminatedOrTerminating()) return;
|
|
620
|
-
var hasProcess = typeof process === "object" && process !== null;
|
|
621
|
-
var hasForceFlag = hasProcess ? Boolean(process.execArgv && process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy") !== -1) : false;
|
|
622
|
-
if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
|
|
623
|
-
(hasProcess && typeof process.emitWarning === "function" ? process.emitWarning : function(warning, type, code) {
|
|
624
|
-
if (warning instanceof Error) console.warn(warning.toString());
|
|
625
|
-
else {
|
|
626
|
-
var prefix = code ? "[".concat(code, "] ") : "";
|
|
627
|
-
console.warn("".concat(prefix).concat(type || "Warning", ": ").concat(warning));
|
|
628
|
-
}
|
|
629
|
-
})("Uncaught N-API callback exception detected, please run node with option --force-node-api-uncaught-exceptions-policy=true to handle those exceptions properly.", "DeprecationWarning", "DEP0168");
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
|
-
envObject.triggerFatalException(err);
|
|
633
|
-
});
|
|
634
|
-
};
|
|
635
|
-
NodeEnv$1.prototype.callFinalizer = function(cb, data, hint) {
|
|
636
|
-
this.callFinalizerInternal(1, cb, data, hint);
|
|
637
|
-
};
|
|
638
|
-
NodeEnv$1.prototype.callFinalizerInternal = function(forceUncaught, cb, data, hint) {
|
|
639
|
-
var f = this.makeDynCall_vppp(cb);
|
|
640
|
-
var env = this.id;
|
|
641
|
-
var scope = this.ctx.openScope(this);
|
|
642
|
-
try {
|
|
643
|
-
this.callbackIntoModule(Boolean(forceUncaught), function() {
|
|
644
|
-
f(env, data, hint);
|
|
645
|
-
});
|
|
646
|
-
} finally {
|
|
647
|
-
this.ctx.closeScope(this, scope);
|
|
648
|
-
}
|
|
649
|
-
};
|
|
650
|
-
NodeEnv$1.prototype.enqueueFinalizer = function(finalizer) {
|
|
651
|
-
var _this = this;
|
|
652
|
-
_super.prototype.enqueueFinalizer.call(this, finalizer);
|
|
653
|
-
if (!this.finalizationScheduled && !this.destructing) {
|
|
654
|
-
this.finalizationScheduled = true;
|
|
655
|
-
this.ref();
|
|
656
|
-
_setImmediate(function() {
|
|
657
|
-
_this.finalizationScheduled = false;
|
|
658
|
-
_this.unref();
|
|
659
|
-
_this.drainFinalizerQueue();
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
};
|
|
663
|
-
NodeEnv$1.prototype.drainFinalizerQueue = function() {
|
|
664
|
-
while (this.pendingFinalizers.length > 0) this.pendingFinalizers.shift().finalize();
|
|
665
|
-
};
|
|
666
|
-
return NodeEnv$1;
|
|
667
|
-
}(Env);
|
|
668
|
-
function newEnv(ctx, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding) {
|
|
669
|
-
moduleApiVersion = typeof moduleApiVersion !== "number" ? NODE_API_DEFAULT_MODULE_API_VERSION : moduleApiVersion;
|
|
670
|
-
if (moduleApiVersion < NODE_API_DEFAULT_MODULE_API_VERSION) moduleApiVersion = NODE_API_DEFAULT_MODULE_API_VERSION;
|
|
671
|
-
else if (moduleApiVersion > NODE_API_SUPPORTED_VERSION_MAX && moduleApiVersion !== NAPI_VERSION_EXPERIMENTAL) throwNodeApiVersionError(filename, moduleApiVersion);
|
|
672
|
-
var env = new NodeEnv(ctx, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding);
|
|
673
|
-
ctx.envStore.add(env);
|
|
674
|
-
ctx.addCleanupHook(env, function() {
|
|
675
|
-
env.unref();
|
|
676
|
-
}, 0);
|
|
677
|
-
return env;
|
|
678
|
-
}
|
|
679
|
-
var EmnapiError = /* @__PURE__ */ function(_super) {
|
|
680
|
-
__extends(EmnapiError$1, _super);
|
|
681
|
-
function EmnapiError$1(message) {
|
|
682
|
-
var _newTarget = this.constructor;
|
|
683
|
-
var _this = _super.call(this, message) || this;
|
|
684
|
-
var ErrorConstructor = _newTarget;
|
|
685
|
-
var proto = ErrorConstructor.prototype;
|
|
686
|
-
if (!(_this instanceof EmnapiError$1)) {
|
|
687
|
-
var setPrototypeOf = Object.setPrototypeOf;
|
|
688
|
-
if (typeof setPrototypeOf === "function") setPrototypeOf.call(Object, _this, proto);
|
|
689
|
-
else _this.__proto__ = proto;
|
|
690
|
-
if (typeof Error.captureStackTrace === "function") Error.captureStackTrace(_this, ErrorConstructor);
|
|
691
|
-
}
|
|
692
|
-
return _this;
|
|
693
|
-
}
|
|
694
|
-
return EmnapiError$1;
|
|
695
|
-
}(Error);
|
|
696
|
-
Object.defineProperty(EmnapiError.prototype, "name", {
|
|
697
|
-
configurable: true,
|
|
698
|
-
writable: true,
|
|
699
|
-
value: "EmnapiError"
|
|
700
|
-
});
|
|
701
|
-
var NotSupportWeakRefError = /* @__PURE__ */ function(_super) {
|
|
702
|
-
__extends(NotSupportWeakRefError$1, _super);
|
|
703
|
-
function NotSupportWeakRefError$1(api, message) {
|
|
704
|
-
return _super.call(this, "".concat(api, ": The current runtime does not support \"FinalizationRegistry\" and \"WeakRef\".").concat(message ? " ".concat(message) : "")) || this;
|
|
705
|
-
}
|
|
706
|
-
return NotSupportWeakRefError$1;
|
|
707
|
-
}(EmnapiError);
|
|
708
|
-
Object.defineProperty(NotSupportWeakRefError.prototype, "name", {
|
|
709
|
-
configurable: true,
|
|
710
|
-
writable: true,
|
|
711
|
-
value: "NotSupportWeakRefError"
|
|
712
|
-
});
|
|
713
|
-
var NotSupportBufferError = /* @__PURE__ */ function(_super) {
|
|
714
|
-
__extends(NotSupportBufferError$1, _super);
|
|
715
|
-
function NotSupportBufferError$1(api, message) {
|
|
716
|
-
return _super.call(this, "".concat(api, ": The current runtime does not support \"Buffer\". Consider using buffer polyfill to make sure `globalThis.Buffer` is defined.").concat(message ? " ".concat(message) : "")) || this;
|
|
717
|
-
}
|
|
718
|
-
return NotSupportBufferError$1;
|
|
719
|
-
}(EmnapiError);
|
|
720
|
-
Object.defineProperty(NotSupportBufferError.prototype, "name", {
|
|
721
|
-
configurable: true,
|
|
722
|
-
writable: true,
|
|
723
|
-
value: "NotSupportBufferError"
|
|
724
|
-
});
|
|
725
|
-
var StrongRef = /* @__PURE__ */ function() {
|
|
726
|
-
function StrongRef$1(value) {
|
|
727
|
-
this._value = value;
|
|
728
|
-
}
|
|
729
|
-
StrongRef$1.prototype.deref = function() {
|
|
730
|
-
return this._value;
|
|
731
|
-
};
|
|
732
|
-
StrongRef$1.prototype.dispose = function() {
|
|
733
|
-
this._value = void 0;
|
|
734
|
-
};
|
|
735
|
-
return StrongRef$1;
|
|
736
|
-
}();
|
|
737
|
-
var Persistent = /* @__PURE__ */ function() {
|
|
738
|
-
function Persistent$1(value) {
|
|
739
|
-
this._ref = new StrongRef(value);
|
|
740
|
-
}
|
|
741
|
-
Persistent$1.prototype.setWeak = function(param, callback) {
|
|
742
|
-
if (!supportFinalizer || this._ref === void 0 || this._ref instanceof WeakRef) return;
|
|
743
|
-
var value = this._ref.deref();
|
|
744
|
-
try {
|
|
745
|
-
Persistent$1._registry.register(value, this, this);
|
|
746
|
-
var weakRef = new WeakRef(value);
|
|
747
|
-
this._ref.dispose();
|
|
748
|
-
this._ref = weakRef;
|
|
749
|
-
this._param = param;
|
|
750
|
-
this._callback = callback;
|
|
751
|
-
} catch (err) {
|
|
752
|
-
if (typeof value === "symbol");
|
|
753
|
-
else throw err;
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
Persistent$1.prototype.clearWeak = function() {
|
|
757
|
-
if (!supportFinalizer || this._ref === void 0) return;
|
|
758
|
-
if (this._ref instanceof WeakRef) {
|
|
759
|
-
try {
|
|
760
|
-
Persistent$1._registry.unregister(this);
|
|
761
|
-
} catch (_) {}
|
|
762
|
-
this._param = void 0;
|
|
763
|
-
this._callback = void 0;
|
|
764
|
-
var value = this._ref.deref();
|
|
765
|
-
if (value === void 0) this._ref = value;
|
|
766
|
-
else this._ref = new StrongRef(value);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
Persistent$1.prototype.reset = function() {
|
|
770
|
-
if (supportFinalizer) try {
|
|
771
|
-
Persistent$1._registry.unregister(this);
|
|
772
|
-
} catch (_) {}
|
|
773
|
-
this._param = void 0;
|
|
774
|
-
this._callback = void 0;
|
|
775
|
-
if (this._ref instanceof StrongRef) this._ref.dispose();
|
|
776
|
-
this._ref = void 0;
|
|
777
|
-
};
|
|
778
|
-
Persistent$1.prototype.isEmpty = function() {
|
|
779
|
-
return this._ref === void 0;
|
|
780
|
-
};
|
|
781
|
-
Persistent$1.prototype.deref = function() {
|
|
782
|
-
if (this._ref === void 0) return void 0;
|
|
783
|
-
return this._ref.deref();
|
|
784
|
-
};
|
|
785
|
-
Persistent$1._registry = supportFinalizer ? new FinalizationRegistry(function(value) {
|
|
786
|
-
value._ref = void 0;
|
|
787
|
-
var callback = value._callback;
|
|
788
|
-
var param = value._param;
|
|
789
|
-
value._callback = void 0;
|
|
790
|
-
value._param = void 0;
|
|
791
|
-
if (typeof callback === "function") callback(param);
|
|
792
|
-
}) : void 0;
|
|
793
|
-
return Persistent$1;
|
|
794
|
-
}();
|
|
795
|
-
var ReferenceOwnership;
|
|
796
|
-
(function(ReferenceOwnership$1) {
|
|
797
|
-
ReferenceOwnership$1[ReferenceOwnership$1["kRuntime"] = 0] = "kRuntime";
|
|
798
|
-
ReferenceOwnership$1[ReferenceOwnership$1["kUserland"] = 1] = "kUserland";
|
|
799
|
-
})(ReferenceOwnership || (ReferenceOwnership = {}));
|
|
800
|
-
function canBeHeldWeakly(value) {
|
|
801
|
-
return value.isObject() || value.isFunction() || value.isSymbol();
|
|
802
|
-
}
|
|
803
|
-
var Reference = /* @__PURE__ */ function(_super) {
|
|
804
|
-
__extends(Reference$1, _super);
|
|
805
|
-
function Reference$1(envObject, handle_id, initialRefcount, ownership) {
|
|
806
|
-
var _this = _super.call(this) || this;
|
|
807
|
-
_this.envObject = envObject;
|
|
808
|
-
_this._refcount = initialRefcount;
|
|
809
|
-
_this._ownership = ownership;
|
|
810
|
-
var handle = envObject.ctx.handleStore.get(handle_id);
|
|
811
|
-
_this.canBeWeak = canBeHeldWeakly(handle);
|
|
812
|
-
_this.persistent = new Persistent(handle.value);
|
|
813
|
-
_this.id = 0;
|
|
814
|
-
if (initialRefcount === 0) _this._setWeak();
|
|
815
|
-
return _this;
|
|
816
|
-
}
|
|
817
|
-
Reference$1.weakCallback = function(ref) {
|
|
818
|
-
ref.persistent.reset();
|
|
819
|
-
ref.invokeFinalizerFromGC();
|
|
820
|
-
};
|
|
821
|
-
Reference$1.create = function(envObject, handle_id, initialRefcount, ownership, _unused1, _unused2, _unused3) {
|
|
822
|
-
var ref = new Reference$1(envObject, handle_id, initialRefcount, ownership);
|
|
823
|
-
envObject.ctx.refStore.add(ref);
|
|
824
|
-
ref.link(envObject.reflist);
|
|
825
|
-
return ref;
|
|
826
|
-
};
|
|
827
|
-
Reference$1.prototype.ref = function() {
|
|
828
|
-
if (this.persistent.isEmpty()) return 0;
|
|
829
|
-
if (++this._refcount === 1 && this.canBeWeak) this.persistent.clearWeak();
|
|
830
|
-
return this._refcount;
|
|
831
|
-
};
|
|
832
|
-
Reference$1.prototype.unref = function() {
|
|
833
|
-
if (this.persistent.isEmpty() || this._refcount === 0) return 0;
|
|
834
|
-
if (--this._refcount === 0) this._setWeak();
|
|
835
|
-
return this._refcount;
|
|
836
|
-
};
|
|
837
|
-
Reference$1.prototype.get = function(envObject) {
|
|
838
|
-
if (envObject === void 0) envObject = this.envObject;
|
|
839
|
-
if (this.persistent.isEmpty()) return 0;
|
|
840
|
-
var obj = this.persistent.deref();
|
|
841
|
-
return envObject.ensureHandle(obj).id;
|
|
842
|
-
};
|
|
843
|
-
/** @virtual */
|
|
844
|
-
Reference$1.prototype.resetFinalizer = function() {};
|
|
845
|
-
/** @virtual */
|
|
846
|
-
Reference$1.prototype.data = function() {
|
|
847
|
-
return 0;
|
|
848
|
-
};
|
|
849
|
-
Reference$1.prototype.refcount = function() {
|
|
850
|
-
return this._refcount;
|
|
851
|
-
};
|
|
852
|
-
Reference$1.prototype.ownership = function() {
|
|
853
|
-
return this._ownership;
|
|
854
|
-
};
|
|
855
|
-
/** @virtual */
|
|
856
|
-
Reference$1.prototype.callUserFinalizer = function() {};
|
|
857
|
-
/** @virtual */
|
|
858
|
-
Reference$1.prototype.invokeFinalizerFromGC = function() {
|
|
859
|
-
this.finalize();
|
|
860
|
-
};
|
|
861
|
-
Reference$1.prototype._setWeak = function() {
|
|
862
|
-
if (this.canBeWeak) this.persistent.setWeak(this, Reference$1.weakCallback);
|
|
863
|
-
else this.persistent.reset();
|
|
864
|
-
};
|
|
865
|
-
Reference$1.prototype.finalize = function() {
|
|
866
|
-
this.persistent.reset();
|
|
867
|
-
var deleteMe = this._ownership === ReferenceOwnership.kRuntime;
|
|
868
|
-
this.unlink();
|
|
869
|
-
this.callUserFinalizer();
|
|
870
|
-
if (deleteMe) this.dispose();
|
|
871
|
-
};
|
|
872
|
-
Reference$1.prototype.dispose = function() {
|
|
873
|
-
if (this.id === 0) return;
|
|
874
|
-
this.unlink();
|
|
875
|
-
this.persistent.reset();
|
|
876
|
-
this.envObject.ctx.refStore.remove(this.id);
|
|
877
|
-
_super.prototype.dispose.call(this);
|
|
878
|
-
this.envObject = void 0;
|
|
879
|
-
this.id = 0;
|
|
880
|
-
};
|
|
881
|
-
return Reference$1;
|
|
882
|
-
}(RefTracker);
|
|
883
|
-
var ReferenceWithData = /* @__PURE__ */ function(_super) {
|
|
884
|
-
__extends(ReferenceWithData$1, _super);
|
|
885
|
-
function ReferenceWithData$1(envObject, value, initialRefcount, ownership, _data) {
|
|
886
|
-
var _this = _super.call(this, envObject, value, initialRefcount, ownership) || this;
|
|
887
|
-
_this._data = _data;
|
|
888
|
-
return _this;
|
|
889
|
-
}
|
|
890
|
-
ReferenceWithData$1.create = function(envObject, value, initialRefcount, ownership, data) {
|
|
891
|
-
var reference = new ReferenceWithData$1(envObject, value, initialRefcount, ownership, data);
|
|
892
|
-
envObject.ctx.refStore.add(reference);
|
|
893
|
-
reference.link(envObject.reflist);
|
|
894
|
-
return reference;
|
|
895
|
-
};
|
|
896
|
-
ReferenceWithData$1.prototype.data = function() {
|
|
897
|
-
return this._data;
|
|
898
|
-
};
|
|
899
|
-
return ReferenceWithData$1;
|
|
900
|
-
}(Reference);
|
|
901
|
-
var ReferenceWithFinalizer = /* @__PURE__ */ function(_super) {
|
|
902
|
-
__extends(ReferenceWithFinalizer$1, _super);
|
|
903
|
-
function ReferenceWithFinalizer$1(envObject, value, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint) {
|
|
904
|
-
var _this = _super.call(this, envObject, value, initialRefcount, ownership) || this;
|
|
905
|
-
_this._finalizer = new Finalizer(envObject, finalize_callback, finalize_data, finalize_hint);
|
|
906
|
-
return _this;
|
|
907
|
-
}
|
|
908
|
-
ReferenceWithFinalizer$1.create = function(envObject, value, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint) {
|
|
909
|
-
var reference = new ReferenceWithFinalizer$1(envObject, value, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint);
|
|
910
|
-
envObject.ctx.refStore.add(reference);
|
|
911
|
-
reference.link(envObject.finalizing_reflist);
|
|
912
|
-
return reference;
|
|
913
|
-
};
|
|
914
|
-
ReferenceWithFinalizer$1.prototype.resetFinalizer = function() {
|
|
915
|
-
this._finalizer.resetFinalizer();
|
|
916
|
-
};
|
|
917
|
-
ReferenceWithFinalizer$1.prototype.data = function() {
|
|
918
|
-
return this._finalizer.data();
|
|
919
|
-
};
|
|
920
|
-
ReferenceWithFinalizer$1.prototype.callUserFinalizer = function() {
|
|
921
|
-
this._finalizer.callFinalizer();
|
|
922
|
-
};
|
|
923
|
-
ReferenceWithFinalizer$1.prototype.invokeFinalizerFromGC = function() {
|
|
924
|
-
this._finalizer.envObject.invokeFinalizerFromGC(this);
|
|
925
|
-
};
|
|
926
|
-
ReferenceWithFinalizer$1.prototype.dispose = function() {
|
|
927
|
-
if (!this._finalizer) return;
|
|
928
|
-
this._finalizer.envObject.dequeueFinalizer(this);
|
|
929
|
-
this._finalizer.dispose();
|
|
930
|
-
_super.prototype.dispose.call(this);
|
|
931
|
-
this._finalizer = void 0;
|
|
932
|
-
};
|
|
933
|
-
return ReferenceWithFinalizer$1;
|
|
934
|
-
}(Reference);
|
|
935
|
-
var Deferred = /* @__PURE__ */ function() {
|
|
936
|
-
function Deferred$1(ctx, value) {
|
|
937
|
-
this.id = 0;
|
|
938
|
-
this.ctx = ctx;
|
|
939
|
-
this.value = value;
|
|
940
|
-
}
|
|
941
|
-
Deferred$1.create = function(ctx, value) {
|
|
942
|
-
var deferred = new Deferred$1(ctx, value);
|
|
943
|
-
ctx.deferredStore.add(deferred);
|
|
944
|
-
return deferred;
|
|
945
|
-
};
|
|
946
|
-
Deferred$1.prototype.resolve = function(value) {
|
|
947
|
-
this.value.resolve(value);
|
|
948
|
-
this.dispose();
|
|
949
|
-
};
|
|
950
|
-
Deferred$1.prototype.reject = function(reason) {
|
|
951
|
-
this.value.reject(reason);
|
|
952
|
-
this.dispose();
|
|
953
|
-
};
|
|
954
|
-
Deferred$1.prototype.dispose = function() {
|
|
955
|
-
this.ctx.deferredStore.remove(this.id);
|
|
956
|
-
this.id = 0;
|
|
957
|
-
this.value = null;
|
|
958
|
-
this.ctx = null;
|
|
959
|
-
};
|
|
960
|
-
return Deferred$1;
|
|
961
|
-
}();
|
|
962
|
-
var Store = /* @__PURE__ */ function() {
|
|
963
|
-
function Store$1() {
|
|
964
|
-
this._values = [void 0];
|
|
965
|
-
this._values.length = 4;
|
|
966
|
-
this._size = 1;
|
|
967
|
-
this._freeList = [];
|
|
968
|
-
}
|
|
969
|
-
Store$1.prototype.add = function(value) {
|
|
970
|
-
var id;
|
|
971
|
-
if (this._freeList.length) id = this._freeList.shift();
|
|
972
|
-
else {
|
|
973
|
-
id = this._size;
|
|
974
|
-
this._size++;
|
|
975
|
-
var capacity = this._values.length;
|
|
976
|
-
if (id >= capacity) this._values.length = capacity + (capacity >> 1) + 16;
|
|
977
|
-
}
|
|
978
|
-
value.id = id;
|
|
979
|
-
this._values[id] = value;
|
|
980
|
-
};
|
|
981
|
-
Store$1.prototype.get = function(id) {
|
|
982
|
-
return this._values[id];
|
|
983
|
-
};
|
|
984
|
-
Store$1.prototype.has = function(id) {
|
|
985
|
-
return this._values[id] !== void 0;
|
|
986
|
-
};
|
|
987
|
-
Store$1.prototype.remove = function(id) {
|
|
988
|
-
var value = this._values[id];
|
|
989
|
-
if (value) {
|
|
990
|
-
value.id = 0;
|
|
991
|
-
this._values[id] = void 0;
|
|
992
|
-
this._freeList.push(Number(id));
|
|
993
|
-
}
|
|
994
|
-
};
|
|
995
|
-
Store$1.prototype.dispose = function() {
|
|
996
|
-
for (var i = 1; i < this._size; ++i) {
|
|
997
|
-
var value = this._values[i];
|
|
998
|
-
value === null || value === void 0 || value.dispose();
|
|
999
|
-
}
|
|
1000
|
-
this._values = [void 0];
|
|
1001
|
-
this._size = 1;
|
|
1002
|
-
this._freeList = [];
|
|
1003
|
-
};
|
|
1004
|
-
return Store$1;
|
|
1005
|
-
}();
|
|
1006
|
-
var CleanupHookCallback = /* @__PURE__ */ function() {
|
|
1007
|
-
function CleanupHookCallback$1(envObject, fn, arg, order) {
|
|
1008
|
-
this.envObject = envObject;
|
|
1009
|
-
this.fn = fn;
|
|
1010
|
-
this.arg = arg;
|
|
1011
|
-
this.order = order;
|
|
1012
|
-
}
|
|
1013
|
-
return CleanupHookCallback$1;
|
|
1014
|
-
}();
|
|
1015
|
-
var CleanupQueue = /* @__PURE__ */ function() {
|
|
1016
|
-
function CleanupQueue$1() {
|
|
1017
|
-
this._cleanupHooks = [];
|
|
1018
|
-
this._cleanupHookCounter = 0;
|
|
1019
|
-
}
|
|
1020
|
-
CleanupQueue$1.prototype.empty = function() {
|
|
1021
|
-
return this._cleanupHooks.length === 0;
|
|
1022
|
-
};
|
|
1023
|
-
CleanupQueue$1.prototype.add = function(envObject, fn, arg) {
|
|
1024
|
-
if (this._cleanupHooks.filter(function(hook) {
|
|
1025
|
-
return hook.envObject === envObject && hook.fn === fn && hook.arg === arg;
|
|
1026
|
-
}).length > 0) throw new Error("Can not add same fn and arg twice");
|
|
1027
|
-
this._cleanupHooks.push(new CleanupHookCallback(envObject, fn, arg, this._cleanupHookCounter++));
|
|
1028
|
-
};
|
|
1029
|
-
CleanupQueue$1.prototype.remove = function(envObject, fn, arg) {
|
|
1030
|
-
for (var i = 0; i < this._cleanupHooks.length; ++i) {
|
|
1031
|
-
var hook = this._cleanupHooks[i];
|
|
1032
|
-
if (hook.envObject === envObject && hook.fn === fn && hook.arg === arg) {
|
|
1033
|
-
this._cleanupHooks.splice(i, 1);
|
|
1034
|
-
return;
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
};
|
|
1038
|
-
CleanupQueue$1.prototype.drain = function() {
|
|
1039
|
-
var hooks = this._cleanupHooks.slice();
|
|
1040
|
-
hooks.sort(function(a, b) {
|
|
1041
|
-
return b.order - a.order;
|
|
1042
|
-
});
|
|
1043
|
-
for (var i = 0; i < hooks.length; ++i) {
|
|
1044
|
-
var cb = hooks[i];
|
|
1045
|
-
if (typeof cb.fn === "number") cb.envObject.makeDynCall_vp(cb.fn)(cb.arg);
|
|
1046
|
-
else cb.fn(cb.arg);
|
|
1047
|
-
this._cleanupHooks.splice(this._cleanupHooks.indexOf(cb), 1);
|
|
1048
|
-
}
|
|
1049
|
-
};
|
|
1050
|
-
CleanupQueue$1.prototype.dispose = function() {
|
|
1051
|
-
this._cleanupHooks.length = 0;
|
|
1052
|
-
this._cleanupHookCounter = 0;
|
|
1053
|
-
};
|
|
1054
|
-
return CleanupQueue$1;
|
|
1055
|
-
}();
|
|
1056
|
-
var NodejsWaitingRequestCounter = /* @__PURE__ */ function() {
|
|
1057
|
-
function NodejsWaitingRequestCounter$1() {
|
|
1058
|
-
this.refHandle = new _MessageChannel().port1;
|
|
1059
|
-
this.count = 0;
|
|
1060
|
-
}
|
|
1061
|
-
NodejsWaitingRequestCounter$1.prototype.increase = function() {
|
|
1062
|
-
if (this.count === 0) {
|
|
1063
|
-
if (this.refHandle.ref) this.refHandle.ref();
|
|
1064
|
-
}
|
|
1065
|
-
this.count++;
|
|
1066
|
-
};
|
|
1067
|
-
NodejsWaitingRequestCounter$1.prototype.decrease = function() {
|
|
1068
|
-
if (this.count === 0) return;
|
|
1069
|
-
if (this.count === 1) {
|
|
1070
|
-
if (this.refHandle.unref) this.refHandle.unref();
|
|
1071
|
-
}
|
|
1072
|
-
this.count--;
|
|
1073
|
-
};
|
|
1074
|
-
return NodejsWaitingRequestCounter$1;
|
|
1075
|
-
}();
|
|
1076
|
-
var Context = /* @__PURE__ */ function() {
|
|
1077
|
-
function Context$1() {
|
|
1078
|
-
var _this = this;
|
|
1079
|
-
this._isStopping = false;
|
|
1080
|
-
this._canCallIntoJs = true;
|
|
1081
|
-
this._suppressDestroy = false;
|
|
1082
|
-
this.envStore = new Store();
|
|
1083
|
-
this.scopeStore = new ScopeStore();
|
|
1084
|
-
this.refStore = new Store();
|
|
1085
|
-
this.deferredStore = new Store();
|
|
1086
|
-
this.handleStore = new HandleStore();
|
|
1087
|
-
this.feature = {
|
|
1088
|
-
supportReflect,
|
|
1089
|
-
supportFinalizer,
|
|
1090
|
-
supportWeakSymbol,
|
|
1091
|
-
supportBigInt,
|
|
1092
|
-
supportNewFunction,
|
|
1093
|
-
canSetFunctionName,
|
|
1094
|
-
setImmediate: _setImmediate,
|
|
1095
|
-
Buffer: _Buffer,
|
|
1096
|
-
MessageChannel: _MessageChannel
|
|
1097
|
-
};
|
|
1098
|
-
this.cleanupQueue = new CleanupQueue();
|
|
1099
|
-
if (typeof process === "object" && process !== null && typeof process.once === "function") {
|
|
1100
|
-
this.refCounter = new NodejsWaitingRequestCounter();
|
|
1101
|
-
process.once("beforeExit", function() {
|
|
1102
|
-
if (!_this._suppressDestroy) _this.destroy();
|
|
1103
|
-
});
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
/**
|
|
1107
|
-
* Suppress the destroy on `beforeExit` event in Node.js.
|
|
1108
|
-
* Call this method if you want to keep the context and
|
|
1109
|
-
* all associated {@link Env | Env} alive,
|
|
1110
|
-
* this also means that cleanup hooks will not be called.
|
|
1111
|
-
* After call this method, you should call
|
|
1112
|
-
* {@link Context.destroy | `Context.prototype.destroy`} method manually.
|
|
1113
|
-
*/
|
|
1114
|
-
Context$1.prototype.suppressDestroy = function() {
|
|
1115
|
-
this._suppressDestroy = true;
|
|
1116
|
-
};
|
|
1117
|
-
Context$1.prototype.getRuntimeVersions = function() {
|
|
1118
|
-
return {
|
|
1119
|
-
version,
|
|
1120
|
-
NODE_API_SUPPORTED_VERSION_MAX,
|
|
1121
|
-
NAPI_VERSION_EXPERIMENTAL,
|
|
1122
|
-
NODE_API_DEFAULT_MODULE_API_VERSION
|
|
1123
|
-
};
|
|
1124
|
-
};
|
|
1125
|
-
Context$1.prototype.createNotSupportWeakRefError = function(api, message) {
|
|
1126
|
-
return new NotSupportWeakRefError(api, message);
|
|
1127
|
-
};
|
|
1128
|
-
Context$1.prototype.createNotSupportBufferError = function(api, message) {
|
|
1129
|
-
return new NotSupportBufferError(api, message);
|
|
1130
|
-
};
|
|
1131
|
-
Context$1.prototype.createReference = function(envObject, handle_id, initialRefcount, ownership) {
|
|
1132
|
-
return Reference.create(envObject, handle_id, initialRefcount, ownership);
|
|
1133
|
-
};
|
|
1134
|
-
Context$1.prototype.createReferenceWithData = function(envObject, handle_id, initialRefcount, ownership, data) {
|
|
1135
|
-
return ReferenceWithData.create(envObject, handle_id, initialRefcount, ownership, data);
|
|
1136
|
-
};
|
|
1137
|
-
Context$1.prototype.createReferenceWithFinalizer = function(envObject, handle_id, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint) {
|
|
1138
|
-
if (finalize_callback === void 0) finalize_callback = 0;
|
|
1139
|
-
if (finalize_data === void 0) finalize_data = 0;
|
|
1140
|
-
if (finalize_hint === void 0) finalize_hint = 0;
|
|
1141
|
-
return ReferenceWithFinalizer.create(envObject, handle_id, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint);
|
|
1142
|
-
};
|
|
1143
|
-
Context$1.prototype.createDeferred = function(value) {
|
|
1144
|
-
return Deferred.create(this, value);
|
|
1145
|
-
};
|
|
1146
|
-
Context$1.prototype.createEnv = function(filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding) {
|
|
1147
|
-
return newEnv(this, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding);
|
|
1148
|
-
};
|
|
1149
|
-
Context$1.prototype.createTrackedFinalizer = function(envObject, finalize_callback, finalize_data, finalize_hint) {
|
|
1150
|
-
return TrackedFinalizer.create(envObject, finalize_callback, finalize_data, finalize_hint);
|
|
1151
|
-
};
|
|
1152
|
-
Context$1.prototype.getCurrentScope = function() {
|
|
1153
|
-
return this.scopeStore.currentScope;
|
|
1154
|
-
};
|
|
1155
|
-
Context$1.prototype.addToCurrentScope = function(value) {
|
|
1156
|
-
return this.scopeStore.currentScope.add(value);
|
|
1157
|
-
};
|
|
1158
|
-
Context$1.prototype.openScope = function(envObject) {
|
|
1159
|
-
var scope = this.scopeStore.openScope(this.handleStore);
|
|
1160
|
-
if (envObject) envObject.openHandleScopes++;
|
|
1161
|
-
return scope;
|
|
1162
|
-
};
|
|
1163
|
-
Context$1.prototype.closeScope = function(envObject, _scope) {
|
|
1164
|
-
if (envObject && envObject.openHandleScopes === 0) return;
|
|
1165
|
-
this.scopeStore.closeScope();
|
|
1166
|
-
if (envObject) envObject.openHandleScopes--;
|
|
1167
|
-
};
|
|
1168
|
-
Context$1.prototype.ensureHandle = function(value) {
|
|
1169
|
-
switch (value) {
|
|
1170
|
-
case void 0: return HandleStore.UNDEFINED;
|
|
1171
|
-
case null: return HandleStore.NULL;
|
|
1172
|
-
case true: return HandleStore.TRUE;
|
|
1173
|
-
case false: return HandleStore.FALSE;
|
|
1174
|
-
case _global: return HandleStore.GLOBAL;
|
|
1175
|
-
}
|
|
1176
|
-
return this.addToCurrentScope(value);
|
|
1177
|
-
};
|
|
1178
|
-
Context$1.prototype.addCleanupHook = function(envObject, fn, arg) {
|
|
1179
|
-
this.cleanupQueue.add(envObject, fn, arg);
|
|
1180
|
-
};
|
|
1181
|
-
Context$1.prototype.removeCleanupHook = function(envObject, fn, arg) {
|
|
1182
|
-
this.cleanupQueue.remove(envObject, fn, arg);
|
|
1183
|
-
};
|
|
1184
|
-
Context$1.prototype.runCleanup = function() {
|
|
1185
|
-
while (!this.cleanupQueue.empty()) this.cleanupQueue.drain();
|
|
1186
|
-
};
|
|
1187
|
-
Context$1.prototype.increaseWaitingRequestCounter = function() {
|
|
1188
|
-
var _a;
|
|
1189
|
-
(_a = this.refCounter) === null || _a === void 0 || _a.increase();
|
|
1190
|
-
};
|
|
1191
|
-
Context$1.prototype.decreaseWaitingRequestCounter = function() {
|
|
1192
|
-
var _a;
|
|
1193
|
-
(_a = this.refCounter) === null || _a === void 0 || _a.decrease();
|
|
1194
|
-
};
|
|
1195
|
-
Context$1.prototype.setCanCallIntoJs = function(value) {
|
|
1196
|
-
this._canCallIntoJs = value;
|
|
1197
|
-
};
|
|
1198
|
-
Context$1.prototype.setStopping = function(value) {
|
|
1199
|
-
this._isStopping = value;
|
|
1200
|
-
};
|
|
1201
|
-
Context$1.prototype.canCallIntoJs = function() {
|
|
1202
|
-
return this._canCallIntoJs && !this._isStopping;
|
|
1203
|
-
};
|
|
1204
|
-
/**
|
|
1205
|
-
* Destroy the context and call cleanup hooks.
|
|
1206
|
-
* Associated {@link Env | Env} will be destroyed.
|
|
1207
|
-
*/
|
|
1208
|
-
Context$1.prototype.destroy = function() {
|
|
1209
|
-
this.setStopping(true);
|
|
1210
|
-
this.setCanCallIntoJs(false);
|
|
1211
|
-
this.runCleanup();
|
|
1212
|
-
};
|
|
1213
|
-
return Context$1;
|
|
1214
|
-
}();
|
|
1215
|
-
var defaultContext;
|
|
1216
|
-
function createContext() {
|
|
1217
|
-
return new Context();
|
|
1218
|
-
}
|
|
1219
|
-
function getDefaultContext() {
|
|
1220
|
-
if (!defaultContext) defaultContext = createContext();
|
|
1221
|
-
return defaultContext;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
//#endregion
|
|
1225
|
-
export { getDefaultContext };
|