@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.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.0";
|
|
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;
|
|
@@ -288,6 +240,8 @@ var emnapi = (function (exports) {
|
|
|
288
240
|
return (ArrayBuffer.isView(this.value)) && !(this.value instanceof DataView);
|
|
289
241
|
};
|
|
290
242
|
Handle.prototype.isBuffer = function (BufferConstructor) {
|
|
243
|
+
if (ArrayBuffer.isView(this.value))
|
|
244
|
+
return true;
|
|
291
245
|
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);
|
|
292
246
|
return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);
|
|
293
247
|
};
|
|
@@ -325,10 +279,6 @@ var emnapi = (function (exports) {
|
|
|
325
279
|
ConstHandle.prototype.dispose = function () { };
|
|
326
280
|
return ConstHandle;
|
|
327
281
|
}(Handle));
|
|
328
|
-
function External() {
|
|
329
|
-
Object.setPrototypeOf(this, null);
|
|
330
|
-
}
|
|
331
|
-
External.prototype = null;
|
|
332
282
|
var HandleStore = /*#__PURE__*/ (function () {
|
|
333
283
|
function HandleStore() {
|
|
334
284
|
this._values = [
|
|
@@ -399,21 +349,24 @@ var emnapi = (function (exports) {
|
|
|
399
349
|
this.start = start;
|
|
400
350
|
this.end = end;
|
|
401
351
|
this._escapeCalled = false;
|
|
352
|
+
this.callbackInfo = {
|
|
353
|
+
thiz: undefined,
|
|
354
|
+
data: 0,
|
|
355
|
+
args: undefined,
|
|
356
|
+
fn: undefined
|
|
357
|
+
};
|
|
402
358
|
}
|
|
403
359
|
HandleScope.prototype.add = function (value) {
|
|
404
360
|
var h = this.handleStore.push(value);
|
|
405
361
|
this.end++;
|
|
406
362
|
return h;
|
|
407
363
|
};
|
|
408
|
-
HandleScope.prototype.addExternal = function (
|
|
409
|
-
|
|
410
|
-
var h = envObject.ctx.handleStore.push(value);
|
|
411
|
-
var binding = envObject.initObjectBinding(value);
|
|
412
|
-
binding.data = data;
|
|
413
|
-
this.end++;
|
|
414
|
-
return h;
|
|
364
|
+
HandleScope.prototype.addExternal = function (data) {
|
|
365
|
+
return this.add(new External(data));
|
|
415
366
|
};
|
|
416
367
|
HandleScope.prototype.dispose = function () {
|
|
368
|
+
if (this._escapeCalled)
|
|
369
|
+
this._escapeCalled = false;
|
|
417
370
|
if (this.start === this.end)
|
|
418
371
|
return;
|
|
419
372
|
this.handleStore.erase(this.start, this.end);
|
|
@@ -441,27 +394,21 @@ var emnapi = (function (exports) {
|
|
|
441
394
|
function ScopeStore() {
|
|
442
395
|
this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
|
|
443
396
|
this.currentScope = this._rootScope;
|
|
397
|
+
this._values = [undefined];
|
|
444
398
|
}
|
|
445
399
|
ScopeStore.prototype.get = function (id) {
|
|
446
|
-
|
|
447
|
-
var scope = this.currentScope;
|
|
448
|
-
while (scope !== this._rootScope) {
|
|
449
|
-
if (scope.id === id) {
|
|
450
|
-
return scope;
|
|
451
|
-
}
|
|
452
|
-
scope = scope.parent;
|
|
453
|
-
}
|
|
454
|
-
return undefined;
|
|
400
|
+
return this._values[id];
|
|
455
401
|
};
|
|
456
402
|
ScopeStore.prototype.openScope = function (envObject) {
|
|
457
403
|
var currentScope = this.currentScope;
|
|
458
404
|
var scope = currentScope.child;
|
|
459
405
|
if (scope !== null) {
|
|
460
406
|
scope.start = scope.end = currentScope.end;
|
|
461
|
-
scope._escapeCalled = false;
|
|
462
407
|
}
|
|
463
408
|
else {
|
|
464
|
-
|
|
409
|
+
var id = currentScope.id + 1;
|
|
410
|
+
scope = new HandleScope(envObject.ctx.handleStore, id, currentScope, currentScope.end);
|
|
411
|
+
this._values[id] = scope;
|
|
465
412
|
}
|
|
466
413
|
this.currentScope = scope;
|
|
467
414
|
envObject.openHandleScopes++;
|
|
@@ -476,19 +423,8 @@ var emnapi = (function (exports) {
|
|
|
476
423
|
envObject.openHandleScopes--;
|
|
477
424
|
};
|
|
478
425
|
ScopeStore.prototype.dispose = function () {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
scope.handleStore = null;
|
|
482
|
-
scope.id = 0;
|
|
483
|
-
scope.parent = null;
|
|
484
|
-
scope.start = HandleStore.MIN_ID;
|
|
485
|
-
scope.end = HandleStore.MIN_ID;
|
|
486
|
-
scope._escapeCalled = false;
|
|
487
|
-
var child = scope.child;
|
|
488
|
-
scope.child = null;
|
|
489
|
-
scope = child;
|
|
490
|
-
}
|
|
491
|
-
this.currentScope = null;
|
|
426
|
+
this.currentScope = this._rootScope;
|
|
427
|
+
this._values.length = 1;
|
|
492
428
|
};
|
|
493
429
|
return ScopeStore;
|
|
494
430
|
}());
|
|
@@ -765,8 +701,7 @@ var emnapi = (function (exports) {
|
|
|
765
701
|
Env.prototype.initObjectBinding = function (value) {
|
|
766
702
|
var binding = {
|
|
767
703
|
wrapped: 0,
|
|
768
|
-
tag: null
|
|
769
|
-
data: 0
|
|
704
|
+
tag: null
|
|
770
705
|
};
|
|
771
706
|
this._bindingMap.set(value, binding);
|
|
772
707
|
return binding;
|
|
@@ -830,7 +765,7 @@ var emnapi = (function (exports) {
|
|
|
830
765
|
}
|
|
831
766
|
var hasProcess = typeof process === 'object' && process !== null;
|
|
832
767
|
var hasForceFlag = hasProcess ? Boolean(process.execArgv && (process.execArgv.indexOf('--force-node-api-uncaught-exceptions-policy') !== -1)) : false;
|
|
833
|
-
if (envObject.moduleApiVersion <
|
|
768
|
+
if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
|
|
834
769
|
var warn = hasProcess && typeof process.emitWarning === 'function'
|
|
835
770
|
? process.emitWarning
|
|
836
771
|
: function (warning, type, code) {
|
|
@@ -1361,7 +1296,6 @@ var emnapi = (function (exports) {
|
|
|
1361
1296
|
this.refStore = new Store();
|
|
1362
1297
|
this.deferredStore = new Store();
|
|
1363
1298
|
this.handleStore = new HandleStore();
|
|
1364
|
-
this.cbinfoStack = new CallbackInfoStack();
|
|
1365
1299
|
this.feature = {
|
|
1366
1300
|
supportReflect: supportReflect,
|
|
1367
1301
|
supportFinalizer: supportFinalizer,
|
|
@@ -1502,13 +1436,12 @@ var emnapi = (function (exports) {
|
|
|
1502
1436
|
return defaultContext;
|
|
1503
1437
|
}
|
|
1504
1438
|
|
|
1505
|
-
exports.CallbackInfo = CallbackInfo;
|
|
1506
|
-
exports.CallbackInfoStack = CallbackInfoStack;
|
|
1507
1439
|
exports.ConstHandle = ConstHandle;
|
|
1508
1440
|
exports.Context = Context;
|
|
1509
1441
|
exports.Deferred = Deferred;
|
|
1510
1442
|
exports.EmnapiError = EmnapiError;
|
|
1511
1443
|
exports.Env = Env;
|
|
1444
|
+
exports.External = External;
|
|
1512
1445
|
exports.Finalizer = Finalizer;
|
|
1513
1446
|
exports.Handle = Handle;
|
|
1514
1447
|
exports.HandleScope = HandleScope;
|
|
@@ -1531,6 +1464,8 @@ var emnapi = (function (exports) {
|
|
|
1531
1464
|
exports.TryCatch = TryCatch;
|
|
1532
1465
|
exports.createContext = createContext;
|
|
1533
1466
|
exports.getDefaultContext = getDefaultContext;
|
|
1467
|
+
exports.getExternalValue = getExternalValue;
|
|
1468
|
+
exports.isExternal = isExternal;
|
|
1534
1469
|
exports.isReferenceType = isReferenceType;
|
|
1535
1470
|
exports.version = version;
|
|
1536
1471
|
|
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.0";
|
|
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;
|
|
@@ -291,6 +243,8 @@
|
|
|
291
243
|
return (ArrayBuffer.isView(this.value)) && !(this.value instanceof DataView);
|
|
292
244
|
};
|
|
293
245
|
Handle.prototype.isBuffer = function (BufferConstructor) {
|
|
246
|
+
if (ArrayBuffer.isView(this.value))
|
|
247
|
+
return true;
|
|
294
248
|
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);
|
|
295
249
|
return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);
|
|
296
250
|
};
|
|
@@ -328,10 +282,6 @@
|
|
|
328
282
|
ConstHandle.prototype.dispose = function () { };
|
|
329
283
|
return ConstHandle;
|
|
330
284
|
}(Handle));
|
|
331
|
-
function External() {
|
|
332
|
-
Object.setPrototypeOf(this, null);
|
|
333
|
-
}
|
|
334
|
-
External.prototype = null;
|
|
335
285
|
var HandleStore = /*#__PURE__*/ (function () {
|
|
336
286
|
function HandleStore() {
|
|
337
287
|
this._values = [
|
|
@@ -402,21 +352,24 @@
|
|
|
402
352
|
this.start = start;
|
|
403
353
|
this.end = end;
|
|
404
354
|
this._escapeCalled = false;
|
|
355
|
+
this.callbackInfo = {
|
|
356
|
+
thiz: undefined,
|
|
357
|
+
data: 0,
|
|
358
|
+
args: undefined,
|
|
359
|
+
fn: undefined
|
|
360
|
+
};
|
|
405
361
|
}
|
|
406
362
|
HandleScope.prototype.add = function (value) {
|
|
407
363
|
var h = this.handleStore.push(value);
|
|
408
364
|
this.end++;
|
|
409
365
|
return h;
|
|
410
366
|
};
|
|
411
|
-
HandleScope.prototype.addExternal = function (
|
|
412
|
-
|
|
413
|
-
var h = envObject.ctx.handleStore.push(value);
|
|
414
|
-
var binding = envObject.initObjectBinding(value);
|
|
415
|
-
binding.data = data;
|
|
416
|
-
this.end++;
|
|
417
|
-
return h;
|
|
367
|
+
HandleScope.prototype.addExternal = function (data) {
|
|
368
|
+
return this.add(new External(data));
|
|
418
369
|
};
|
|
419
370
|
HandleScope.prototype.dispose = function () {
|
|
371
|
+
if (this._escapeCalled)
|
|
372
|
+
this._escapeCalled = false;
|
|
420
373
|
if (this.start === this.end)
|
|
421
374
|
return;
|
|
422
375
|
this.handleStore.erase(this.start, this.end);
|
|
@@ -444,27 +397,21 @@
|
|
|
444
397
|
function ScopeStore() {
|
|
445
398
|
this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
|
|
446
399
|
this.currentScope = this._rootScope;
|
|
400
|
+
this._values = [undefined];
|
|
447
401
|
}
|
|
448
402
|
ScopeStore.prototype.get = function (id) {
|
|
449
|
-
|
|
450
|
-
var scope = this.currentScope;
|
|
451
|
-
while (scope !== this._rootScope) {
|
|
452
|
-
if (scope.id === id) {
|
|
453
|
-
return scope;
|
|
454
|
-
}
|
|
455
|
-
scope = scope.parent;
|
|
456
|
-
}
|
|
457
|
-
return undefined;
|
|
403
|
+
return this._values[id];
|
|
458
404
|
};
|
|
459
405
|
ScopeStore.prototype.openScope = function (envObject) {
|
|
460
406
|
var currentScope = this.currentScope;
|
|
461
407
|
var scope = currentScope.child;
|
|
462
408
|
if (scope !== null) {
|
|
463
409
|
scope.start = scope.end = currentScope.end;
|
|
464
|
-
scope._escapeCalled = false;
|
|
465
410
|
}
|
|
466
411
|
else {
|
|
467
|
-
|
|
412
|
+
var id = currentScope.id + 1;
|
|
413
|
+
scope = new HandleScope(envObject.ctx.handleStore, id, currentScope, currentScope.end);
|
|
414
|
+
this._values[id] = scope;
|
|
468
415
|
}
|
|
469
416
|
this.currentScope = scope;
|
|
470
417
|
envObject.openHandleScopes++;
|
|
@@ -479,19 +426,8 @@
|
|
|
479
426
|
envObject.openHandleScopes--;
|
|
480
427
|
};
|
|
481
428
|
ScopeStore.prototype.dispose = function () {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
scope.handleStore = null;
|
|
485
|
-
scope.id = 0;
|
|
486
|
-
scope.parent = null;
|
|
487
|
-
scope.start = HandleStore.MIN_ID;
|
|
488
|
-
scope.end = HandleStore.MIN_ID;
|
|
489
|
-
scope._escapeCalled = false;
|
|
490
|
-
var child = scope.child;
|
|
491
|
-
scope.child = null;
|
|
492
|
-
scope = child;
|
|
493
|
-
}
|
|
494
|
-
this.currentScope = null;
|
|
429
|
+
this.currentScope = this._rootScope;
|
|
430
|
+
this._values.length = 1;
|
|
495
431
|
};
|
|
496
432
|
return ScopeStore;
|
|
497
433
|
}());
|
|
@@ -768,8 +704,7 @@
|
|
|
768
704
|
Env.prototype.initObjectBinding = function (value) {
|
|
769
705
|
var binding = {
|
|
770
706
|
wrapped: 0,
|
|
771
|
-
tag: null
|
|
772
|
-
data: 0
|
|
707
|
+
tag: null
|
|
773
708
|
};
|
|
774
709
|
this._bindingMap.set(value, binding);
|
|
775
710
|
return binding;
|
|
@@ -833,7 +768,7 @@
|
|
|
833
768
|
}
|
|
834
769
|
var hasProcess = typeof process === 'object' && process !== null;
|
|
835
770
|
var hasForceFlag = hasProcess ? Boolean(process.execArgv && (process.execArgv.indexOf('--force-node-api-uncaught-exceptions-policy') !== -1)) : false;
|
|
836
|
-
if (envObject.moduleApiVersion <
|
|
771
|
+
if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
|
|
837
772
|
var warn = hasProcess && typeof process.emitWarning === 'function'
|
|
838
773
|
? process.emitWarning
|
|
839
774
|
: function (warning, type, code) {
|
|
@@ -1364,7 +1299,6 @@
|
|
|
1364
1299
|
this.refStore = new Store();
|
|
1365
1300
|
this.deferredStore = new Store();
|
|
1366
1301
|
this.handleStore = new HandleStore();
|
|
1367
|
-
this.cbinfoStack = new CallbackInfoStack();
|
|
1368
1302
|
this.feature = {
|
|
1369
1303
|
supportReflect: supportReflect,
|
|
1370
1304
|
supportFinalizer: supportFinalizer,
|
|
@@ -1505,13 +1439,12 @@
|
|
|
1505
1439
|
return defaultContext;
|
|
1506
1440
|
}
|
|
1507
1441
|
|
|
1508
|
-
exports.CallbackInfo = CallbackInfo;
|
|
1509
|
-
exports.CallbackInfoStack = CallbackInfoStack;
|
|
1510
1442
|
exports.ConstHandle = ConstHandle;
|
|
1511
1443
|
exports.Context = Context;
|
|
1512
1444
|
exports.Deferred = Deferred;
|
|
1513
1445
|
exports.EmnapiError = EmnapiError;
|
|
1514
1446
|
exports.Env = Env;
|
|
1447
|
+
exports.External = External;
|
|
1515
1448
|
exports.Finalizer = Finalizer;
|
|
1516
1449
|
exports.Handle = Handle;
|
|
1517
1450
|
exports.HandleScope = HandleScope;
|
|
@@ -1534,6 +1467,8 @@
|
|
|
1534
1467
|
exports.TryCatch = TryCatch;
|
|
1535
1468
|
exports.createContext = createContext;
|
|
1536
1469
|
exports.getDefaultContext = getDefaultContext;
|
|
1470
|
+
exports.getExternalValue = getExternalValue;
|
|
1471
|
+
exports.isExternal = isExternal;
|
|
1537
1472
|
exports.isReferenceType = isReferenceType;
|
|
1538
1473
|
exports.version = version;
|
|
1539
1474
|
|