@emnapi/runtime 1.3.1 → 1.4.1
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 +47 -110
- 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 +50 -114
- package/dist/emnapi.iife.d.ts +29 -26
- package/dist/emnapi.iife.js +55 -118
- package/dist/emnapi.js +55 -118
- 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 +45 -109
- package/package.json +1 -1
package/dist/emnapi.iife.js
CHANGED
|
@@ -1,75 +1,5 @@
|
|
|
1
1
|
var emnapi = (function (exports) {
|
|
2
2
|
|
|
3
|
-
var EMPTY_ARGS = [];
|
|
4
|
-
var CallbackInfo = /*#__PURE__*/ (function () {
|
|
5
|
-
function CallbackInfo(id, parent, child, thiz, data, args, fn) {
|
|
6
|
-
this.id = id;
|
|
7
|
-
this.parent = parent;
|
|
8
|
-
this.child = child;
|
|
9
|
-
this.thiz = thiz;
|
|
10
|
-
this.data = data;
|
|
11
|
-
this.args = args;
|
|
12
|
-
this.fn = fn;
|
|
13
|
-
}
|
|
14
|
-
CallbackInfo.prototype.getNewTarget = function (envObject) {
|
|
15
|
-
var thiz = this.thiz;
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
17
|
-
if (thiz == null || thiz.constructor == null)
|
|
18
|
-
return 0;
|
|
19
|
-
return thiz instanceof this.fn ? envObject.ensureHandleId(thiz.constructor) : 0;
|
|
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;
|
|
33
|
-
}
|
|
34
|
-
CallbackInfoStack.prototype.get = function (id) {
|
|
35
|
-
if (id === 1)
|
|
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
|
-
}());
|
|
72
|
-
|
|
73
3
|
/******************************************************************************
|
|
74
4
|
Copyright (c) Microsoft Corporation.
|
|
75
5
|
|
|
@@ -106,6 +36,28 @@ var emnapi = (function (exports) {
|
|
|
106
36
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
107
37
|
};
|
|
108
38
|
|
|
39
|
+
var externalValue = new WeakMap();
|
|
40
|
+
/** @public */
|
|
41
|
+
function isExternal(object) {
|
|
42
|
+
return externalValue.has(object);
|
|
43
|
+
}
|
|
44
|
+
/** @public */ // eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
45
|
+
var External = (function () {
|
|
46
|
+
function External(value) {
|
|
47
|
+
Object.setPrototypeOf(this, null);
|
|
48
|
+
externalValue.set(this, value);
|
|
49
|
+
}
|
|
50
|
+
External.prototype = null;
|
|
51
|
+
return External;
|
|
52
|
+
})();
|
|
53
|
+
/** @public */
|
|
54
|
+
function getExternalValue(external) {
|
|
55
|
+
if (!isExternal(external)) {
|
|
56
|
+
throw new TypeError('not external');
|
|
57
|
+
}
|
|
58
|
+
return externalValue.get(external);
|
|
59
|
+
}
|
|
60
|
+
|
|
109
61
|
var supportNewFunction = /*#__PURE__*/ (function () {
|
|
110
62
|
var f;
|
|
111
63
|
try {
|
|
@@ -246,9 +198,9 @@ var emnapi = (function (exports) {
|
|
|
246
198
|
catch (_) { }
|
|
247
199
|
return undefined;
|
|
248
200
|
})();
|
|
249
|
-
var version = "1.
|
|
201
|
+
var version = "1.4.1";
|
|
250
202
|
var NODE_API_SUPPORTED_VERSION_MIN = 1 /* Version.NODE_API_SUPPORTED_VERSION_MIN */;
|
|
251
|
-
var NODE_API_SUPPORTED_VERSION_MAX =
|
|
203
|
+
var NODE_API_SUPPORTED_VERSION_MAX = 10 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;
|
|
252
204
|
var NAPI_VERSION_EXPERIMENTAL = 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */;
|
|
253
205
|
var NODE_API_DEFAULT_MODULE_API_VERSION = 8 /* Version.NODE_API_DEFAULT_MODULE_API_VERSION */;
|
|
254
206
|
|
|
@@ -257,8 +209,8 @@ var emnapi = (function (exports) {
|
|
|
257
209
|
this.id = id;
|
|
258
210
|
this.value = value;
|
|
259
211
|
}
|
|
260
|
-
Handle.prototype.data = function (
|
|
261
|
-
return
|
|
212
|
+
Handle.prototype.data = function () {
|
|
213
|
+
return getExternalValue(this.value);
|
|
262
214
|
};
|
|
263
215
|
Handle.prototype.isNumber = function () {
|
|
264
216
|
return typeof this.value === 'number';
|
|
@@ -273,7 +225,7 @@ var emnapi = (function (exports) {
|
|
|
273
225
|
return typeof this.value === 'function';
|
|
274
226
|
};
|
|
275
227
|
Handle.prototype.isExternal = function () {
|
|
276
|
-
return (
|
|
228
|
+
return isExternal(this.value);
|
|
277
229
|
};
|
|
278
230
|
Handle.prototype.isObject = function () {
|
|
279
231
|
return typeof this.value === 'object' && this.value !== null;
|
|
@@ -327,10 +279,6 @@ var emnapi = (function (exports) {
|
|
|
327
279
|
ConstHandle.prototype.dispose = function () { };
|
|
328
280
|
return ConstHandle;
|
|
329
281
|
}(Handle));
|
|
330
|
-
function External() {
|
|
331
|
-
Object.setPrototypeOf(this, null);
|
|
332
|
-
}
|
|
333
|
-
External.prototype = null;
|
|
334
282
|
var HandleStore = /*#__PURE__*/ (function () {
|
|
335
283
|
function HandleStore() {
|
|
336
284
|
this._values = [
|
|
@@ -401,21 +349,24 @@ var emnapi = (function (exports) {
|
|
|
401
349
|
this.start = start;
|
|
402
350
|
this.end = end;
|
|
403
351
|
this._escapeCalled = false;
|
|
352
|
+
this.callbackInfo = {
|
|
353
|
+
thiz: undefined,
|
|
354
|
+
data: 0,
|
|
355
|
+
args: undefined,
|
|
356
|
+
fn: undefined
|
|
357
|
+
};
|
|
404
358
|
}
|
|
405
359
|
HandleScope.prototype.add = function (value) {
|
|
406
360
|
var h = this.handleStore.push(value);
|
|
407
361
|
this.end++;
|
|
408
362
|
return h;
|
|
409
363
|
};
|
|
410
|
-
HandleScope.prototype.addExternal = function (
|
|
411
|
-
|
|
412
|
-
var h = envObject.ctx.handleStore.push(value);
|
|
413
|
-
var binding = envObject.initObjectBinding(value);
|
|
414
|
-
binding.data = data;
|
|
415
|
-
this.end++;
|
|
416
|
-
return h;
|
|
364
|
+
HandleScope.prototype.addExternal = function (data) {
|
|
365
|
+
return this.add(new External(data));
|
|
417
366
|
};
|
|
418
367
|
HandleScope.prototype.dispose = function () {
|
|
368
|
+
if (this._escapeCalled)
|
|
369
|
+
this._escapeCalled = false;
|
|
419
370
|
if (this.start === this.end)
|
|
420
371
|
return;
|
|
421
372
|
this.handleStore.erase(this.start, this.end);
|
|
@@ -443,27 +394,21 @@ var emnapi = (function (exports) {
|
|
|
443
394
|
function ScopeStore() {
|
|
444
395
|
this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
|
|
445
396
|
this.currentScope = this._rootScope;
|
|
397
|
+
this._values = [undefined];
|
|
446
398
|
}
|
|
447
399
|
ScopeStore.prototype.get = function (id) {
|
|
448
|
-
|
|
449
|
-
var scope = this.currentScope;
|
|
450
|
-
while (scope !== this._rootScope) {
|
|
451
|
-
if (scope.id === id) {
|
|
452
|
-
return scope;
|
|
453
|
-
}
|
|
454
|
-
scope = scope.parent;
|
|
455
|
-
}
|
|
456
|
-
return undefined;
|
|
400
|
+
return this._values[id];
|
|
457
401
|
};
|
|
458
402
|
ScopeStore.prototype.openScope = function (envObject) {
|
|
459
403
|
var currentScope = this.currentScope;
|
|
460
404
|
var scope = currentScope.child;
|
|
461
405
|
if (scope !== null) {
|
|
462
406
|
scope.start = scope.end = currentScope.end;
|
|
463
|
-
scope._escapeCalled = false;
|
|
464
407
|
}
|
|
465
408
|
else {
|
|
466
|
-
|
|
409
|
+
var id = currentScope.id + 1;
|
|
410
|
+
scope = new HandleScope(envObject.ctx.handleStore, id, currentScope, currentScope.end);
|
|
411
|
+
this._values[id] = scope;
|
|
467
412
|
}
|
|
468
413
|
this.currentScope = scope;
|
|
469
414
|
envObject.openHandleScopes++;
|
|
@@ -478,19 +423,8 @@ var emnapi = (function (exports) {
|
|
|
478
423
|
envObject.openHandleScopes--;
|
|
479
424
|
};
|
|
480
425
|
ScopeStore.prototype.dispose = function () {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
scope.handleStore = null;
|
|
484
|
-
scope.id = 0;
|
|
485
|
-
scope.parent = null;
|
|
486
|
-
scope.start = HandleStore.MIN_ID;
|
|
487
|
-
scope.end = HandleStore.MIN_ID;
|
|
488
|
-
scope._escapeCalled = false;
|
|
489
|
-
var child = scope.child;
|
|
490
|
-
scope.child = null;
|
|
491
|
-
scope = child;
|
|
492
|
-
}
|
|
493
|
-
this.currentScope = null;
|
|
426
|
+
this.currentScope = this._rootScope;
|
|
427
|
+
this._values.length = 1;
|
|
494
428
|
};
|
|
495
429
|
return ScopeStore;
|
|
496
430
|
}());
|
|
@@ -767,8 +701,7 @@ var emnapi = (function (exports) {
|
|
|
767
701
|
Env.prototype.initObjectBinding = function (value) {
|
|
768
702
|
var binding = {
|
|
769
703
|
wrapped: 0,
|
|
770
|
-
tag: null
|
|
771
|
-
data: 0
|
|
704
|
+
tag: null
|
|
772
705
|
};
|
|
773
706
|
this._bindingMap.set(value, binding);
|
|
774
707
|
return binding;
|
|
@@ -832,7 +765,7 @@ var emnapi = (function (exports) {
|
|
|
832
765
|
}
|
|
833
766
|
var hasProcess = typeof process === 'object' && process !== null;
|
|
834
767
|
var hasForceFlag = hasProcess ? Boolean(process.execArgv && (process.execArgv.indexOf('--force-node-api-uncaught-exceptions-policy') !== -1)) : false;
|
|
835
|
-
if (envObject.moduleApiVersion <
|
|
768
|
+
if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
|
|
836
769
|
var warn = hasProcess && typeof process.emitWarning === 'function'
|
|
837
770
|
? process.emitWarning
|
|
838
771
|
: function (warning, type, code) {
|
|
@@ -1338,7 +1271,9 @@ var emnapi = (function (exports) {
|
|
|
1338
1271
|
}
|
|
1339
1272
|
NodejsWaitingRequestCounter.prototype.increase = function () {
|
|
1340
1273
|
if (this.count === 0) {
|
|
1341
|
-
this.refHandle.ref
|
|
1274
|
+
if (this.refHandle.ref) {
|
|
1275
|
+
this.refHandle.ref();
|
|
1276
|
+
}
|
|
1342
1277
|
}
|
|
1343
1278
|
this.count++;
|
|
1344
1279
|
};
|
|
@@ -1346,7 +1281,9 @@ var emnapi = (function (exports) {
|
|
|
1346
1281
|
if (this.count === 0)
|
|
1347
1282
|
return;
|
|
1348
1283
|
if (this.count === 1) {
|
|
1349
|
-
this.refHandle.unref
|
|
1284
|
+
if (this.refHandle.unref) {
|
|
1285
|
+
this.refHandle.unref();
|
|
1286
|
+
}
|
|
1350
1287
|
}
|
|
1351
1288
|
this.count--;
|
|
1352
1289
|
};
|
|
@@ -1363,7 +1300,6 @@ var emnapi = (function (exports) {
|
|
|
1363
1300
|
this.refStore = new Store();
|
|
1364
1301
|
this.deferredStore = new Store();
|
|
1365
1302
|
this.handleStore = new HandleStore();
|
|
1366
|
-
this.cbinfoStack = new CallbackInfoStack();
|
|
1367
1303
|
this.feature = {
|
|
1368
1304
|
supportReflect: supportReflect,
|
|
1369
1305
|
supportFinalizer: supportFinalizer,
|
|
@@ -1504,13 +1440,12 @@ var emnapi = (function (exports) {
|
|
|
1504
1440
|
return defaultContext;
|
|
1505
1441
|
}
|
|
1506
1442
|
|
|
1507
|
-
exports.CallbackInfo = CallbackInfo;
|
|
1508
|
-
exports.CallbackInfoStack = CallbackInfoStack;
|
|
1509
1443
|
exports.ConstHandle = ConstHandle;
|
|
1510
1444
|
exports.Context = Context;
|
|
1511
1445
|
exports.Deferred = Deferred;
|
|
1512
1446
|
exports.EmnapiError = EmnapiError;
|
|
1513
1447
|
exports.Env = Env;
|
|
1448
|
+
exports.External = External;
|
|
1514
1449
|
exports.Finalizer = Finalizer;
|
|
1515
1450
|
exports.Handle = Handle;
|
|
1516
1451
|
exports.HandleScope = HandleScope;
|
|
@@ -1533,6 +1468,8 @@ var emnapi = (function (exports) {
|
|
|
1533
1468
|
exports.TryCatch = TryCatch;
|
|
1534
1469
|
exports.createContext = createContext;
|
|
1535
1470
|
exports.getDefaultContext = getDefaultContext;
|
|
1471
|
+
exports.getExternalValue = getExternalValue;
|
|
1472
|
+
exports.isExternal = isExternal;
|
|
1536
1473
|
exports.isReferenceType = isReferenceType;
|
|
1537
1474
|
exports.version = version;
|
|
1538
1475
|
|
package/dist/emnapi.js
CHANGED
|
@@ -3,76 +3,6 @@
|
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.emnapi = {}));
|
|
5
5
|
})(this, (function (exports) {
|
|
6
|
-
var EMPTY_ARGS = [];
|
|
7
|
-
var CallbackInfo = /*#__PURE__*/ (function () {
|
|
8
|
-
function CallbackInfo(id, parent, child, thiz, data, args, fn) {
|
|
9
|
-
this.id = id;
|
|
10
|
-
this.parent = parent;
|
|
11
|
-
this.child = child;
|
|
12
|
-
this.thiz = thiz;
|
|
13
|
-
this.data = data;
|
|
14
|
-
this.args = args;
|
|
15
|
-
this.fn = fn;
|
|
16
|
-
}
|
|
17
|
-
CallbackInfo.prototype.getNewTarget = function (envObject) {
|
|
18
|
-
var thiz = this.thiz;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
|
|
20
|
-
if (thiz == null || thiz.constructor == null)
|
|
21
|
-
return 0;
|
|
22
|
-
return thiz instanceof this.fn ? envObject.ensureHandleId(thiz.constructor) : 0;
|
|
23
|
-
};
|
|
24
|
-
CallbackInfo.prototype.dispose = function () {
|
|
25
|
-
if (this.thiz !== undefined)
|
|
26
|
-
this.thiz = undefined;
|
|
27
|
-
this.args = EMPTY_ARGS;
|
|
28
|
-
this.fn = null;
|
|
29
|
-
};
|
|
30
|
-
return CallbackInfo;
|
|
31
|
-
}());
|
|
32
|
-
var ROOT_CBINFO = new CallbackInfo(0, null, null, null, 0, null, null);
|
|
33
|
-
var CallbackInfoStack = /*#__PURE__*/ (function () {
|
|
34
|
-
function CallbackInfoStack() {
|
|
35
|
-
this.current = ROOT_CBINFO;
|
|
36
|
-
}
|
|
37
|
-
CallbackInfoStack.prototype.get = function (id) {
|
|
38
|
-
if (id === 1)
|
|
39
|
-
return ROOT_CBINFO.child;
|
|
40
|
-
var info = ROOT_CBINFO;
|
|
41
|
-
for (var i = 0; i < id; ++i) {
|
|
42
|
-
info = info.child;
|
|
43
|
-
if (info === null)
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
return info === ROOT_CBINFO ? null : info;
|
|
47
|
-
};
|
|
48
|
-
CallbackInfoStack.prototype.pop = function () {
|
|
49
|
-
var current = this.current;
|
|
50
|
-
if (current === ROOT_CBINFO)
|
|
51
|
-
return;
|
|
52
|
-
this.current = current.parent;
|
|
53
|
-
current.dispose();
|
|
54
|
-
};
|
|
55
|
-
CallbackInfoStack.prototype.push = function (thiz, data, args, fn) {
|
|
56
|
-
var info = this.current.child;
|
|
57
|
-
if (info) {
|
|
58
|
-
info.thiz = thiz;
|
|
59
|
-
info.data = data;
|
|
60
|
-
info.args = args;
|
|
61
|
-
info.fn = fn;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
info = new CallbackInfo(this.current.id + 1, this.current, null, thiz, data, args, fn);
|
|
65
|
-
this.current.child = info;
|
|
66
|
-
}
|
|
67
|
-
this.current = info;
|
|
68
|
-
return info.id;
|
|
69
|
-
};
|
|
70
|
-
CallbackInfoStack.prototype.dispose = function () {
|
|
71
|
-
this.current = null;
|
|
72
|
-
};
|
|
73
|
-
return CallbackInfoStack;
|
|
74
|
-
}());
|
|
75
|
-
|
|
76
6
|
/******************************************************************************
|
|
77
7
|
Copyright (c) Microsoft Corporation.
|
|
78
8
|
|
|
@@ -109,6 +39,28 @@
|
|
|
109
39
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
110
40
|
};
|
|
111
41
|
|
|
42
|
+
var externalValue = new WeakMap();
|
|
43
|
+
/** @public */
|
|
44
|
+
function isExternal(object) {
|
|
45
|
+
return externalValue.has(object);
|
|
46
|
+
}
|
|
47
|
+
/** @public */ // eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
48
|
+
var External = (function () {
|
|
49
|
+
function External(value) {
|
|
50
|
+
Object.setPrototypeOf(this, null);
|
|
51
|
+
externalValue.set(this, value);
|
|
52
|
+
}
|
|
53
|
+
External.prototype = null;
|
|
54
|
+
return External;
|
|
55
|
+
})();
|
|
56
|
+
/** @public */
|
|
57
|
+
function getExternalValue(external) {
|
|
58
|
+
if (!isExternal(external)) {
|
|
59
|
+
throw new TypeError('not external');
|
|
60
|
+
}
|
|
61
|
+
return externalValue.get(external);
|
|
62
|
+
}
|
|
63
|
+
|
|
112
64
|
var supportNewFunction = /*#__PURE__*/ (function () {
|
|
113
65
|
var f;
|
|
114
66
|
try {
|
|
@@ -249,9 +201,9 @@
|
|
|
249
201
|
catch (_) { }
|
|
250
202
|
return undefined;
|
|
251
203
|
})();
|
|
252
|
-
var version = "1.
|
|
204
|
+
var version = "1.4.1";
|
|
253
205
|
var NODE_API_SUPPORTED_VERSION_MIN = 1 /* Version.NODE_API_SUPPORTED_VERSION_MIN */;
|
|
254
|
-
var NODE_API_SUPPORTED_VERSION_MAX =
|
|
206
|
+
var NODE_API_SUPPORTED_VERSION_MAX = 10 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;
|
|
255
207
|
var NAPI_VERSION_EXPERIMENTAL = 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */;
|
|
256
208
|
var NODE_API_DEFAULT_MODULE_API_VERSION = 8 /* Version.NODE_API_DEFAULT_MODULE_API_VERSION */;
|
|
257
209
|
|
|
@@ -260,8 +212,8 @@
|
|
|
260
212
|
this.id = id;
|
|
261
213
|
this.value = value;
|
|
262
214
|
}
|
|
263
|
-
Handle.prototype.data = function (
|
|
264
|
-
return
|
|
215
|
+
Handle.prototype.data = function () {
|
|
216
|
+
return getExternalValue(this.value);
|
|
265
217
|
};
|
|
266
218
|
Handle.prototype.isNumber = function () {
|
|
267
219
|
return typeof this.value === 'number';
|
|
@@ -276,7 +228,7 @@
|
|
|
276
228
|
return typeof this.value === 'function';
|
|
277
229
|
};
|
|
278
230
|
Handle.prototype.isExternal = function () {
|
|
279
|
-
return (
|
|
231
|
+
return isExternal(this.value);
|
|
280
232
|
};
|
|
281
233
|
Handle.prototype.isObject = function () {
|
|
282
234
|
return typeof this.value === 'object' && this.value !== null;
|
|
@@ -330,10 +282,6 @@
|
|
|
330
282
|
ConstHandle.prototype.dispose = function () { };
|
|
331
283
|
return ConstHandle;
|
|
332
284
|
}(Handle));
|
|
333
|
-
function External() {
|
|
334
|
-
Object.setPrototypeOf(this, null);
|
|
335
|
-
}
|
|
336
|
-
External.prototype = null;
|
|
337
285
|
var HandleStore = /*#__PURE__*/ (function () {
|
|
338
286
|
function HandleStore() {
|
|
339
287
|
this._values = [
|
|
@@ -404,21 +352,24 @@
|
|
|
404
352
|
this.start = start;
|
|
405
353
|
this.end = end;
|
|
406
354
|
this._escapeCalled = false;
|
|
355
|
+
this.callbackInfo = {
|
|
356
|
+
thiz: undefined,
|
|
357
|
+
data: 0,
|
|
358
|
+
args: undefined,
|
|
359
|
+
fn: undefined
|
|
360
|
+
};
|
|
407
361
|
}
|
|
408
362
|
HandleScope.prototype.add = function (value) {
|
|
409
363
|
var h = this.handleStore.push(value);
|
|
410
364
|
this.end++;
|
|
411
365
|
return h;
|
|
412
366
|
};
|
|
413
|
-
HandleScope.prototype.addExternal = function (
|
|
414
|
-
|
|
415
|
-
var h = envObject.ctx.handleStore.push(value);
|
|
416
|
-
var binding = envObject.initObjectBinding(value);
|
|
417
|
-
binding.data = data;
|
|
418
|
-
this.end++;
|
|
419
|
-
return h;
|
|
367
|
+
HandleScope.prototype.addExternal = function (data) {
|
|
368
|
+
return this.add(new External(data));
|
|
420
369
|
};
|
|
421
370
|
HandleScope.prototype.dispose = function () {
|
|
371
|
+
if (this._escapeCalled)
|
|
372
|
+
this._escapeCalled = false;
|
|
422
373
|
if (this.start === this.end)
|
|
423
374
|
return;
|
|
424
375
|
this.handleStore.erase(this.start, this.end);
|
|
@@ -446,27 +397,21 @@
|
|
|
446
397
|
function ScopeStore() {
|
|
447
398
|
this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
|
|
448
399
|
this.currentScope = this._rootScope;
|
|
400
|
+
this._values = [undefined];
|
|
449
401
|
}
|
|
450
402
|
ScopeStore.prototype.get = function (id) {
|
|
451
|
-
|
|
452
|
-
var scope = this.currentScope;
|
|
453
|
-
while (scope !== this._rootScope) {
|
|
454
|
-
if (scope.id === id) {
|
|
455
|
-
return scope;
|
|
456
|
-
}
|
|
457
|
-
scope = scope.parent;
|
|
458
|
-
}
|
|
459
|
-
return undefined;
|
|
403
|
+
return this._values[id];
|
|
460
404
|
};
|
|
461
405
|
ScopeStore.prototype.openScope = function (envObject) {
|
|
462
406
|
var currentScope = this.currentScope;
|
|
463
407
|
var scope = currentScope.child;
|
|
464
408
|
if (scope !== null) {
|
|
465
409
|
scope.start = scope.end = currentScope.end;
|
|
466
|
-
scope._escapeCalled = false;
|
|
467
410
|
}
|
|
468
411
|
else {
|
|
469
|
-
|
|
412
|
+
var id = currentScope.id + 1;
|
|
413
|
+
scope = new HandleScope(envObject.ctx.handleStore, id, currentScope, currentScope.end);
|
|
414
|
+
this._values[id] = scope;
|
|
470
415
|
}
|
|
471
416
|
this.currentScope = scope;
|
|
472
417
|
envObject.openHandleScopes++;
|
|
@@ -481,19 +426,8 @@
|
|
|
481
426
|
envObject.openHandleScopes--;
|
|
482
427
|
};
|
|
483
428
|
ScopeStore.prototype.dispose = function () {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
scope.handleStore = null;
|
|
487
|
-
scope.id = 0;
|
|
488
|
-
scope.parent = null;
|
|
489
|
-
scope.start = HandleStore.MIN_ID;
|
|
490
|
-
scope.end = HandleStore.MIN_ID;
|
|
491
|
-
scope._escapeCalled = false;
|
|
492
|
-
var child = scope.child;
|
|
493
|
-
scope.child = null;
|
|
494
|
-
scope = child;
|
|
495
|
-
}
|
|
496
|
-
this.currentScope = null;
|
|
429
|
+
this.currentScope = this._rootScope;
|
|
430
|
+
this._values.length = 1;
|
|
497
431
|
};
|
|
498
432
|
return ScopeStore;
|
|
499
433
|
}());
|
|
@@ -770,8 +704,7 @@
|
|
|
770
704
|
Env.prototype.initObjectBinding = function (value) {
|
|
771
705
|
var binding = {
|
|
772
706
|
wrapped: 0,
|
|
773
|
-
tag: null
|
|
774
|
-
data: 0
|
|
707
|
+
tag: null
|
|
775
708
|
};
|
|
776
709
|
this._bindingMap.set(value, binding);
|
|
777
710
|
return binding;
|
|
@@ -835,7 +768,7 @@
|
|
|
835
768
|
}
|
|
836
769
|
var hasProcess = typeof process === 'object' && process !== null;
|
|
837
770
|
var hasForceFlag = hasProcess ? Boolean(process.execArgv && (process.execArgv.indexOf('--force-node-api-uncaught-exceptions-policy') !== -1)) : false;
|
|
838
|
-
if (envObject.moduleApiVersion <
|
|
771
|
+
if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
|
|
839
772
|
var warn = hasProcess && typeof process.emitWarning === 'function'
|
|
840
773
|
? process.emitWarning
|
|
841
774
|
: function (warning, type, code) {
|
|
@@ -1341,7 +1274,9 @@
|
|
|
1341
1274
|
}
|
|
1342
1275
|
NodejsWaitingRequestCounter.prototype.increase = function () {
|
|
1343
1276
|
if (this.count === 0) {
|
|
1344
|
-
this.refHandle.ref
|
|
1277
|
+
if (this.refHandle.ref) {
|
|
1278
|
+
this.refHandle.ref();
|
|
1279
|
+
}
|
|
1345
1280
|
}
|
|
1346
1281
|
this.count++;
|
|
1347
1282
|
};
|
|
@@ -1349,7 +1284,9 @@
|
|
|
1349
1284
|
if (this.count === 0)
|
|
1350
1285
|
return;
|
|
1351
1286
|
if (this.count === 1) {
|
|
1352
|
-
this.refHandle.unref
|
|
1287
|
+
if (this.refHandle.unref) {
|
|
1288
|
+
this.refHandle.unref();
|
|
1289
|
+
}
|
|
1353
1290
|
}
|
|
1354
1291
|
this.count--;
|
|
1355
1292
|
};
|
|
@@ -1366,7 +1303,6 @@
|
|
|
1366
1303
|
this.refStore = new Store();
|
|
1367
1304
|
this.deferredStore = new Store();
|
|
1368
1305
|
this.handleStore = new HandleStore();
|
|
1369
|
-
this.cbinfoStack = new CallbackInfoStack();
|
|
1370
1306
|
this.feature = {
|
|
1371
1307
|
supportReflect: supportReflect,
|
|
1372
1308
|
supportFinalizer: supportFinalizer,
|
|
@@ -1507,13 +1443,12 @@
|
|
|
1507
1443
|
return defaultContext;
|
|
1508
1444
|
}
|
|
1509
1445
|
|
|
1510
|
-
exports.CallbackInfo = CallbackInfo;
|
|
1511
|
-
exports.CallbackInfoStack = CallbackInfoStack;
|
|
1512
1446
|
exports.ConstHandle = ConstHandle;
|
|
1513
1447
|
exports.Context = Context;
|
|
1514
1448
|
exports.Deferred = Deferred;
|
|
1515
1449
|
exports.EmnapiError = EmnapiError;
|
|
1516
1450
|
exports.Env = Env;
|
|
1451
|
+
exports.External = External;
|
|
1517
1452
|
exports.Finalizer = Finalizer;
|
|
1518
1453
|
exports.Handle = Handle;
|
|
1519
1454
|
exports.HandleScope = HandleScope;
|
|
@@ -1536,6 +1471,8 @@
|
|
|
1536
1471
|
exports.TryCatch = TryCatch;
|
|
1537
1472
|
exports.createContext = createContext;
|
|
1538
1473
|
exports.getDefaultContext = getDefaultContext;
|
|
1474
|
+
exports.getExternalValue = getExternalValue;
|
|
1475
|
+
exports.isExternal = isExternal;
|
|
1539
1476
|
exports.isReferenceType = isReferenceType;
|
|
1540
1477
|
exports.version = version;
|
|
1541
1478
|
|