@emnapi/runtime 1.3.0 → 1.4.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/dist/emnapi.cjs.js +43 -108
- package/dist/emnapi.cjs.min.d.ts +30 -27
- package/dist/emnapi.cjs.min.js +1 -1
- package/dist/emnapi.d.mts +30 -27
- package/dist/emnapi.d.ts +30 -27
- package/dist/emnapi.esm-bundler.js +46 -112
- package/dist/emnapi.iife.d.ts +29 -26
- package/dist/emnapi.iife.js +51 -116
- package/dist/emnapi.js +51 -116
- package/dist/emnapi.min.d.mts +30 -27
- package/dist/emnapi.min.js +1 -1
- package/dist/emnapi.min.mjs +1 -1
- package/dist/emnapi.mjs +41 -107
- package/package.json +1 -1
package/dist/emnapi.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare const enum GlobalHandle {
|
|
|
24
24
|
export declare const enum Version {
|
|
25
25
|
NODE_API_SUPPORTED_VERSION_MIN = 1,
|
|
26
26
|
NODE_API_DEFAULT_MODULE_API_VERSION = 8,
|
|
27
|
-
NODE_API_SUPPORTED_VERSION_MAX =
|
|
27
|
+
NODE_API_SUPPORTED_VERSION_MAX = 10,
|
|
28
28
|
NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
|
|
29
29
|
}
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -246,27 +246,6 @@ export declare const enum napi_threadsafe_function_release_mode {
|
|
|
246
246
|
napi_tsfn_release,
|
|
247
247
|
napi_tsfn_abort
|
|
248
248
|
}
|
|
249
|
-
export declare class CallbackInfo {
|
|
250
|
-
id: number;
|
|
251
|
-
parent: CallbackInfo;
|
|
252
|
-
child: CallbackInfo | null;
|
|
253
|
-
thiz: any;
|
|
254
|
-
data: void_p;
|
|
255
|
-
args: ArrayLike<any>;
|
|
256
|
-
fn: Function;
|
|
257
|
-
constructor(id: number, parent: CallbackInfo, child: CallbackInfo | null, thiz: any, data: void_p, args: ArrayLike<any>, fn: Function);
|
|
258
|
-
getNewTarget(envObject: Env): number;
|
|
259
|
-
dispose(): void;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export declare class CallbackInfoStack {
|
|
263
|
-
current: CallbackInfo;
|
|
264
|
-
get(id: number): CallbackInfo | null;
|
|
265
|
-
pop(): void;
|
|
266
|
-
push(thiz: any, data: void_p, args: ArrayLike<any>, fn: Function): number;
|
|
267
|
-
dispose(): void;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
249
|
export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
|
271
250
|
|
|
272
251
|
export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
|
@@ -283,7 +262,6 @@ export declare class Context {
|
|
|
283
262
|
refStore: Store<Reference>;
|
|
284
263
|
deferredStore: Store<Deferred<any>>;
|
|
285
264
|
handleStore: HandleStore;
|
|
286
|
-
cbinfoStack: CallbackInfoStack;
|
|
287
265
|
private readonly refCounter?;
|
|
288
266
|
private readonly cleanupQueue;
|
|
289
267
|
feature: {
|
|
@@ -411,6 +389,17 @@ export declare abstract class Env implements IStoreValue {
|
|
|
411
389
|
getInstanceData(): number;
|
|
412
390
|
}
|
|
413
391
|
|
|
392
|
+
/** @public */
|
|
393
|
+
declare interface External_2 extends Record<any, any> {
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** @public */
|
|
397
|
+
declare const External_2: {
|
|
398
|
+
new (value: number | bigint): External_2;
|
|
399
|
+
prototype: null;
|
|
400
|
+
};
|
|
401
|
+
export { External_2 as External }
|
|
402
|
+
|
|
414
403
|
export declare class Finalizer {
|
|
415
404
|
envObject: Env;
|
|
416
405
|
private _finalizeCallback;
|
|
@@ -429,11 +418,14 @@ export declare class Finalizer {
|
|
|
429
418
|
|
|
430
419
|
export declare function getDefaultContext(): Context;
|
|
431
420
|
|
|
421
|
+
/** @public */
|
|
422
|
+
export declare function getExternalValue(external: External_2): number | bigint;
|
|
423
|
+
|
|
432
424
|
export declare class Handle<S> {
|
|
433
425
|
id: number;
|
|
434
426
|
value: S;
|
|
435
427
|
constructor(id: number, value: S);
|
|
436
|
-
data(
|
|
428
|
+
data(): void_p;
|
|
437
429
|
isNumber(): boolean;
|
|
438
430
|
isBigInt(): boolean;
|
|
439
431
|
isString(): boolean;
|
|
@@ -461,10 +453,11 @@ export declare class HandleScope {
|
|
|
461
453
|
child: HandleScope | null;
|
|
462
454
|
start: number;
|
|
463
455
|
end: number;
|
|
464
|
-
_escapeCalled
|
|
456
|
+
private _escapeCalled;
|
|
457
|
+
callbackInfo: ICallbackInfo;
|
|
465
458
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
|
466
459
|
add<V>(value: V): Handle<V>;
|
|
467
|
-
addExternal(
|
|
460
|
+
addExternal(data: void_p): Handle<object>;
|
|
468
461
|
dispose(): void;
|
|
469
462
|
escape(handle: number): Handle<any> | null;
|
|
470
463
|
escapeCalled(): boolean;
|
|
@@ -486,6 +479,13 @@ export declare class HandleStore {
|
|
|
486
479
|
dispose(): void;
|
|
487
480
|
}
|
|
488
481
|
|
|
482
|
+
export declare interface ICallbackInfo {
|
|
483
|
+
thiz: any;
|
|
484
|
+
data: void_p;
|
|
485
|
+
args: ArrayLike<any>;
|
|
486
|
+
fn: Function;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
489
|
export declare interface IDeferrdValue<T = any> {
|
|
490
490
|
resolve: (value: T) => void;
|
|
491
491
|
reject: (reason?: any) => void;
|
|
@@ -494,9 +494,11 @@ export declare interface IDeferrdValue<T = any> {
|
|
|
494
494
|
export declare interface IReferenceBinding {
|
|
495
495
|
wrapped: number;
|
|
496
496
|
tag: Uint32Array | null;
|
|
497
|
-
data: void_p;
|
|
498
497
|
}
|
|
499
498
|
|
|
499
|
+
/** @public */
|
|
500
|
+
export declare function isExternal(object: unknown): object is External_2;
|
|
501
|
+
|
|
500
502
|
export declare function isReferenceType(v: any): v is object;
|
|
501
503
|
|
|
502
504
|
export declare interface IStoreValue {
|
|
@@ -616,6 +618,7 @@ export declare class RefTracker {
|
|
|
616
618
|
export declare class ScopeStore {
|
|
617
619
|
private readonly _rootScope;
|
|
618
620
|
currentScope: HandleScope;
|
|
621
|
+
private readonly _values;
|
|
619
622
|
constructor();
|
|
620
623
|
get(id: number): HandleScope | undefined;
|
|
621
624
|
openScope(envObject: Env): HandleScope;
|
|
@@ -1,74 +1,26 @@
|
|
|
1
1
|
import { __extends } from 'tslib';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this
|
|
12
|
-
this
|
|
3
|
+
var externalValue = new WeakMap();
|
|
4
|
+
/** @public */
|
|
5
|
+
function isExternal(object) {
|
|
6
|
+
return externalValue.has(object);
|
|
7
|
+
}
|
|
8
|
+
/** @public */ // eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
9
|
+
var External = (function () {
|
|
10
|
+
function External(value) {
|
|
11
|
+
Object.setPrototypeOf(this, null);
|
|
12
|
+
externalValue.set(this, value);
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
CallbackInfo.prototype.dispose = function () {
|
|
22
|
-
if (this.thiz !== undefined)
|
|
23
|
-
this.thiz = undefined;
|
|
24
|
-
this.args = EMPTY_ARGS;
|
|
25
|
-
this.fn = null;
|
|
26
|
-
};
|
|
27
|
-
return CallbackInfo;
|
|
28
|
-
}());
|
|
29
|
-
var ROOT_CBINFO = new CallbackInfo(0, null, null, null, 0, null, null);
|
|
30
|
-
var CallbackInfoStack = /*#__PURE__*/ (function () {
|
|
31
|
-
function CallbackInfoStack() {
|
|
32
|
-
this.current = ROOT_CBINFO;
|
|
14
|
+
External.prototype = null;
|
|
15
|
+
return External;
|
|
16
|
+
})();
|
|
17
|
+
/** @public */
|
|
18
|
+
function getExternalValue(external) {
|
|
19
|
+
if (!isExternal(external)) {
|
|
20
|
+
throw new TypeError('not external');
|
|
33
21
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return ROOT_CBINFO.child;
|
|
37
|
-
var info = ROOT_CBINFO;
|
|
38
|
-
for (var i = 0; i < id; ++i) {
|
|
39
|
-
info = info.child;
|
|
40
|
-
if (info === null)
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
return info === ROOT_CBINFO ? null : info;
|
|
44
|
-
};
|
|
45
|
-
CallbackInfoStack.prototype.pop = function () {
|
|
46
|
-
var current = this.current;
|
|
47
|
-
if (current === ROOT_CBINFO)
|
|
48
|
-
return;
|
|
49
|
-
this.current = current.parent;
|
|
50
|
-
current.dispose();
|
|
51
|
-
};
|
|
52
|
-
CallbackInfoStack.prototype.push = function (thiz, data, args, fn) {
|
|
53
|
-
var info = this.current.child;
|
|
54
|
-
if (info) {
|
|
55
|
-
info.thiz = thiz;
|
|
56
|
-
info.data = data;
|
|
57
|
-
info.args = args;
|
|
58
|
-
info.fn = fn;
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
info = new CallbackInfo(this.current.id + 1, this.current, null, thiz, data, args, fn);
|
|
62
|
-
this.current.child = info;
|
|
63
|
-
}
|
|
64
|
-
this.current = info;
|
|
65
|
-
return info.id;
|
|
66
|
-
};
|
|
67
|
-
CallbackInfoStack.prototype.dispose = function () {
|
|
68
|
-
this.current = null;
|
|
69
|
-
};
|
|
70
|
-
return CallbackInfoStack;
|
|
71
|
-
}());
|
|
22
|
+
return externalValue.get(external);
|
|
23
|
+
}
|
|
72
24
|
|
|
73
25
|
var supportNewFunction = /*#__PURE__*/ (function () {
|
|
74
26
|
var f;
|
|
@@ -210,9 +162,9 @@ var _Buffer = typeof Buffer === 'function'
|
|
|
210
162
|
catch (_) { }
|
|
211
163
|
return undefined;
|
|
212
164
|
})();
|
|
213
|
-
var version = "1.
|
|
165
|
+
var version = "1.4.0";
|
|
214
166
|
var NODE_API_SUPPORTED_VERSION_MIN = 1 /* Version.NODE_API_SUPPORTED_VERSION_MIN */;
|
|
215
|
-
var NODE_API_SUPPORTED_VERSION_MAX =
|
|
167
|
+
var NODE_API_SUPPORTED_VERSION_MAX = 10 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;
|
|
216
168
|
var NAPI_VERSION_EXPERIMENTAL = 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */;
|
|
217
169
|
var NODE_API_DEFAULT_MODULE_API_VERSION = 8 /* Version.NODE_API_DEFAULT_MODULE_API_VERSION */;
|
|
218
170
|
|
|
@@ -221,8 +173,8 @@ var Handle = /*#__PURE__*/ (function () {
|
|
|
221
173
|
this.id = id;
|
|
222
174
|
this.value = value;
|
|
223
175
|
}
|
|
224
|
-
Handle.prototype.data = function (
|
|
225
|
-
return
|
|
176
|
+
Handle.prototype.data = function () {
|
|
177
|
+
return getExternalValue(this.value);
|
|
226
178
|
};
|
|
227
179
|
Handle.prototype.isNumber = function () {
|
|
228
180
|
return typeof this.value === 'number';
|
|
@@ -237,7 +189,7 @@ var Handle = /*#__PURE__*/ (function () {
|
|
|
237
189
|
return typeof this.value === 'function';
|
|
238
190
|
};
|
|
239
191
|
Handle.prototype.isExternal = function () {
|
|
240
|
-
return (
|
|
192
|
+
return isExternal(this.value);
|
|
241
193
|
};
|
|
242
194
|
Handle.prototype.isObject = function () {
|
|
243
195
|
return typeof this.value === 'object' && this.value !== null;
|
|
@@ -252,6 +204,8 @@ var Handle = /*#__PURE__*/ (function () {
|
|
|
252
204
|
return (ArrayBuffer.isView(this.value)) && !(this.value instanceof DataView);
|
|
253
205
|
};
|
|
254
206
|
Handle.prototype.isBuffer = function (BufferConstructor) {
|
|
207
|
+
if (ArrayBuffer.isView(this.value))
|
|
208
|
+
return true;
|
|
255
209
|
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);
|
|
256
210
|
return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);
|
|
257
211
|
};
|
|
@@ -289,10 +243,6 @@ var ConstHandle = /*#__PURE__*/ (function (_super) {
|
|
|
289
243
|
ConstHandle.prototype.dispose = function () { };
|
|
290
244
|
return ConstHandle;
|
|
291
245
|
}(Handle));
|
|
292
|
-
function External() {
|
|
293
|
-
Object.setPrototypeOf(this, null);
|
|
294
|
-
}
|
|
295
|
-
External.prototype = null;
|
|
296
246
|
var HandleStore = /*#__PURE__*/ (function () {
|
|
297
247
|
function HandleStore() {
|
|
298
248
|
this._values = [
|
|
@@ -363,21 +313,24 @@ var HandleScope = /*#__PURE__*/ (function () {
|
|
|
363
313
|
this.start = start;
|
|
364
314
|
this.end = end;
|
|
365
315
|
this._escapeCalled = false;
|
|
316
|
+
this.callbackInfo = {
|
|
317
|
+
thiz: undefined,
|
|
318
|
+
data: 0,
|
|
319
|
+
args: undefined,
|
|
320
|
+
fn: undefined
|
|
321
|
+
};
|
|
366
322
|
}
|
|
367
323
|
HandleScope.prototype.add = function (value) {
|
|
368
324
|
var h = this.handleStore.push(value);
|
|
369
325
|
this.end++;
|
|
370
326
|
return h;
|
|
371
327
|
};
|
|
372
|
-
HandleScope.prototype.addExternal = function (
|
|
373
|
-
|
|
374
|
-
var h = envObject.ctx.handleStore.push(value);
|
|
375
|
-
var binding = envObject.initObjectBinding(value);
|
|
376
|
-
binding.data = data;
|
|
377
|
-
this.end++;
|
|
378
|
-
return h;
|
|
328
|
+
HandleScope.prototype.addExternal = function (data) {
|
|
329
|
+
return this.add(new External(data));
|
|
379
330
|
};
|
|
380
331
|
HandleScope.prototype.dispose = function () {
|
|
332
|
+
if (this._escapeCalled)
|
|
333
|
+
this._escapeCalled = false;
|
|
381
334
|
if (this.start === this.end)
|
|
382
335
|
return;
|
|
383
336
|
this.handleStore.erase(this.start, this.end);
|
|
@@ -405,27 +358,21 @@ var ScopeStore = /*#__PURE__*/ (function () {
|
|
|
405
358
|
function ScopeStore() {
|
|
406
359
|
this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
|
|
407
360
|
this.currentScope = this._rootScope;
|
|
361
|
+
this._values = [undefined];
|
|
408
362
|
}
|
|
409
363
|
ScopeStore.prototype.get = function (id) {
|
|
410
|
-
|
|
411
|
-
var scope = this.currentScope;
|
|
412
|
-
while (scope !== this._rootScope) {
|
|
413
|
-
if (scope.id === id) {
|
|
414
|
-
return scope;
|
|
415
|
-
}
|
|
416
|
-
scope = scope.parent;
|
|
417
|
-
}
|
|
418
|
-
return undefined;
|
|
364
|
+
return this._values[id];
|
|
419
365
|
};
|
|
420
366
|
ScopeStore.prototype.openScope = function (envObject) {
|
|
421
367
|
var currentScope = this.currentScope;
|
|
422
368
|
var scope = currentScope.child;
|
|
423
369
|
if (scope !== null) {
|
|
424
370
|
scope.start = scope.end = currentScope.end;
|
|
425
|
-
scope._escapeCalled = false;
|
|
426
371
|
}
|
|
427
372
|
else {
|
|
428
|
-
|
|
373
|
+
var id = currentScope.id + 1;
|
|
374
|
+
scope = new HandleScope(envObject.ctx.handleStore, id, currentScope, currentScope.end);
|
|
375
|
+
this._values[id] = scope;
|
|
429
376
|
}
|
|
430
377
|
this.currentScope = scope;
|
|
431
378
|
envObject.openHandleScopes++;
|
|
@@ -440,19 +387,8 @@ var ScopeStore = /*#__PURE__*/ (function () {
|
|
|
440
387
|
envObject.openHandleScopes--;
|
|
441
388
|
};
|
|
442
389
|
ScopeStore.prototype.dispose = function () {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
scope.handleStore = null;
|
|
446
|
-
scope.id = 0;
|
|
447
|
-
scope.parent = null;
|
|
448
|
-
scope.start = HandleStore.MIN_ID;
|
|
449
|
-
scope.end = HandleStore.MIN_ID;
|
|
450
|
-
scope._escapeCalled = false;
|
|
451
|
-
var child = scope.child;
|
|
452
|
-
scope.child = null;
|
|
453
|
-
scope = child;
|
|
454
|
-
}
|
|
455
|
-
this.currentScope = null;
|
|
390
|
+
this.currentScope = this._rootScope;
|
|
391
|
+
this._values.length = 1;
|
|
456
392
|
};
|
|
457
393
|
return ScopeStore;
|
|
458
394
|
}());
|
|
@@ -729,8 +665,7 @@ var Env = /*#__PURE__*/ (function () {
|
|
|
729
665
|
Env.prototype.initObjectBinding = function (value) {
|
|
730
666
|
var binding = {
|
|
731
667
|
wrapped: 0,
|
|
732
|
-
tag: null
|
|
733
|
-
data: 0
|
|
668
|
+
tag: null
|
|
734
669
|
};
|
|
735
670
|
this._bindingMap.set(value, binding);
|
|
736
671
|
return binding;
|
|
@@ -794,7 +729,7 @@ var NodeEnv = /*#__PURE__*/ (function (_super) {
|
|
|
794
729
|
}
|
|
795
730
|
var hasProcess = typeof process === 'object' && process !== null;
|
|
796
731
|
var hasForceFlag = hasProcess ? Boolean(process.execArgv && (process.execArgv.indexOf('--force-node-api-uncaught-exceptions-policy') !== -1)) : false;
|
|
797
|
-
if (envObject.moduleApiVersion <
|
|
732
|
+
if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
|
|
798
733
|
var warn = hasProcess && typeof process.emitWarning === 'function'
|
|
799
734
|
? process.emitWarning
|
|
800
735
|
: function (warning, type, code) {
|
|
@@ -1325,7 +1260,6 @@ var Context = /*#__PURE__*/ (function () {
|
|
|
1325
1260
|
this.refStore = new Store();
|
|
1326
1261
|
this.deferredStore = new Store();
|
|
1327
1262
|
this.handleStore = new HandleStore();
|
|
1328
|
-
this.cbinfoStack = new CallbackInfoStack();
|
|
1329
1263
|
this.feature = {
|
|
1330
1264
|
supportReflect: supportReflect,
|
|
1331
1265
|
supportFinalizer: supportFinalizer,
|
|
@@ -1466,4 +1400,4 @@ function getDefaultContext() {
|
|
|
1466
1400
|
return defaultContext;
|
|
1467
1401
|
}
|
|
1468
1402
|
|
|
1469
|
-
export {
|
|
1403
|
+
export { ConstHandle, Context, Deferred, EmnapiError, Env, External, Finalizer, Handle, HandleScope, HandleStore, NAPI_VERSION_EXPERIMENTAL, NODE_API_DEFAULT_MODULE_API_VERSION, NODE_API_SUPPORTED_VERSION_MAX, NODE_API_SUPPORTED_VERSION_MIN, NodeEnv, NotSupportBufferError, NotSupportWeakRefError, Persistent, RefTracker, Reference, ReferenceOwnership, ReferenceWithData, ReferenceWithFinalizer, ScopeStore, Store, TrackedFinalizer, TryCatch, createContext, getDefaultContext, getExternalValue, isExternal, isReferenceType, version };
|
package/dist/emnapi.iife.d.ts
CHANGED
|
@@ -1,26 +1,5 @@
|
|
|
1
1
|
declare namespace emnapi {
|
|
2
2
|
|
|
3
|
-
export class CallbackInfo {
|
|
4
|
-
id: number;
|
|
5
|
-
parent: CallbackInfo;
|
|
6
|
-
child: CallbackInfo | null;
|
|
7
|
-
thiz: any;
|
|
8
|
-
data: void_p;
|
|
9
|
-
args: ArrayLike<any>;
|
|
10
|
-
fn: Function;
|
|
11
|
-
constructor(id: number, parent: CallbackInfo, child: CallbackInfo | null, thiz: any, data: void_p, args: ArrayLike<any>, fn: Function);
|
|
12
|
-
getNewTarget(envObject: Env): number;
|
|
13
|
-
dispose(): void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export class CallbackInfoStack {
|
|
17
|
-
current: CallbackInfo;
|
|
18
|
-
get(id: number): CallbackInfo | null;
|
|
19
|
-
pop(): void;
|
|
20
|
-
push(thiz: any, data: void_p, args: ArrayLike<any>, fn: Function): number;
|
|
21
|
-
dispose(): void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
3
|
export type CleanupHookCallbackFunction = number | ((arg: number) => void);
|
|
25
4
|
|
|
26
5
|
export class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
|
|
@@ -37,7 +16,6 @@ export class Context {
|
|
|
37
16
|
refStore: Store<Reference>;
|
|
38
17
|
deferredStore: Store<Deferred<any>>;
|
|
39
18
|
handleStore: HandleStore;
|
|
40
|
-
cbinfoStack: CallbackInfoStack;
|
|
41
19
|
private readonly refCounter?;
|
|
42
20
|
private readonly cleanupQueue;
|
|
43
21
|
feature: {
|
|
@@ -165,6 +143,17 @@ export abstract class Env implements IStoreValue {
|
|
|
165
143
|
getInstanceData(): number;
|
|
166
144
|
}
|
|
167
145
|
|
|
146
|
+
/** @public */
|
|
147
|
+
interface External_2 extends Record<any, any> {
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** @public */
|
|
151
|
+
const External_2: {
|
|
152
|
+
new (value: number | bigint): External_2;
|
|
153
|
+
prototype: null;
|
|
154
|
+
};
|
|
155
|
+
export { External_2 as External }
|
|
156
|
+
|
|
168
157
|
export class Finalizer {
|
|
169
158
|
envObject: Env;
|
|
170
159
|
private _finalizeCallback;
|
|
@@ -183,11 +172,14 @@ export class Finalizer {
|
|
|
183
172
|
|
|
184
173
|
export function getDefaultContext(): Context;
|
|
185
174
|
|
|
175
|
+
/** @public */
|
|
176
|
+
export function getExternalValue(external: External_2): number | bigint;
|
|
177
|
+
|
|
186
178
|
export class Handle<S> {
|
|
187
179
|
id: number;
|
|
188
180
|
value: S;
|
|
189
181
|
constructor(id: number, value: S);
|
|
190
|
-
data(
|
|
182
|
+
data(): void_p;
|
|
191
183
|
isNumber(): boolean;
|
|
192
184
|
isBigInt(): boolean;
|
|
193
185
|
isString(): boolean;
|
|
@@ -215,10 +207,11 @@ export class HandleScope {
|
|
|
215
207
|
child: HandleScope | null;
|
|
216
208
|
start: number;
|
|
217
209
|
end: number;
|
|
218
|
-
_escapeCalled
|
|
210
|
+
private _escapeCalled;
|
|
211
|
+
callbackInfo: ICallbackInfo;
|
|
219
212
|
constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
|
|
220
213
|
add<V>(value: V): Handle<V>;
|
|
221
|
-
addExternal(
|
|
214
|
+
addExternal(data: void_p): Handle<object>;
|
|
222
215
|
dispose(): void;
|
|
223
216
|
escape(handle: number): Handle<any> | null;
|
|
224
217
|
escapeCalled(): boolean;
|
|
@@ -240,6 +233,13 @@ export class HandleStore {
|
|
|
240
233
|
dispose(): void;
|
|
241
234
|
}
|
|
242
235
|
|
|
236
|
+
export interface ICallbackInfo {
|
|
237
|
+
thiz: any;
|
|
238
|
+
data: void_p;
|
|
239
|
+
args: ArrayLike<any>;
|
|
240
|
+
fn: Function;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
243
|
export interface IDeferrdValue<T = any> {
|
|
244
244
|
resolve: (value: T) => void;
|
|
245
245
|
reject: (reason?: any) => void;
|
|
@@ -248,9 +248,11 @@ export interface IDeferrdValue<T = any> {
|
|
|
248
248
|
export interface IReferenceBinding {
|
|
249
249
|
wrapped: number;
|
|
250
250
|
tag: Uint32Array | null;
|
|
251
|
-
data: void_p;
|
|
252
251
|
}
|
|
253
252
|
|
|
253
|
+
/** @public */
|
|
254
|
+
export function isExternal(object: unknown): object is External_2;
|
|
255
|
+
|
|
254
256
|
export function isReferenceType(v: any): v is object;
|
|
255
257
|
|
|
256
258
|
export interface IStoreValue {
|
|
@@ -370,6 +372,7 @@ export class RefTracker {
|
|
|
370
372
|
export class ScopeStore {
|
|
371
373
|
private readonly _rootScope;
|
|
372
374
|
currentScope: HandleScope;
|
|
375
|
+
private readonly _values;
|
|
373
376
|
constructor();
|
|
374
377
|
get(id: number): HandleScope | undefined;
|
|
375
378
|
openScope(envObject: Env): HandleScope;
|