@emnapi/runtime 0.39.0 → 0.40.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.
@@ -1,5 +1,3 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
-
3
1
  class CallbackInfo {
4
2
  constructor(parent, thiz, data, args, fn) {
5
3
  this.parent = parent;
@@ -169,7 +167,7 @@ const _Buffer = typeof Buffer === 'function'
169
167
  catch (_) { }
170
168
  return undefined;
171
169
  })();
172
- const version = "0.39.0";
170
+ const version = "0.40.0";
173
171
  const NAPI_VERSION = 9;
174
172
  const NAPI_VERSION_EXPERIMENTAL = 2147483647;
175
173
  const NODE_API_DEFAULT_MODULE_API_VERSION = 8;
@@ -459,14 +457,6 @@ class Finalizer {
459
457
  }
460
458
 
461
459
  class RefBase extends Finalizer {
462
- constructor(envObject, initial_refcount, ownership, finalize_callback, finalize_data, finalize_hint) {
463
- super(envObject, finalize_callback, finalize_data, finalize_hint);
464
- this._next = null;
465
- this._prev = null;
466
- this._refcount = initial_refcount;
467
- this._ownership = ownership;
468
- this.link(!finalize_callback ? envObject.reflist : envObject.finalizing_reflist);
469
- }
470
460
  static finalizeAll(list) {
471
461
  RefTracker.finalizeAll(list);
472
462
  }
@@ -476,6 +466,14 @@ class RefBase extends Finalizer {
476
466
  unlink() {
477
467
  RefTracker.prototype.unlink.call(this);
478
468
  }
469
+ constructor(envObject, initial_refcount, ownership, finalize_callback, finalize_data, finalize_hint) {
470
+ super(envObject, finalize_callback, finalize_data, finalize_hint);
471
+ this._next = null;
472
+ this._prev = null;
473
+ this._refcount = initial_refcount;
474
+ this._ownership = ownership;
475
+ this.link(!finalize_callback ? envObject.reflist : envObject.finalizing_reflist);
476
+ }
479
477
  dispose() {
480
478
  this.unlink();
481
479
  this.envObject.dequeueFinalizer(this);
@@ -925,10 +923,6 @@ function canBeHeldWeakly(value) {
925
923
  return value.isObject() || value.isFunction() || value.isSymbol();
926
924
  }
927
925
  class Reference extends RefBase {
928
- constructor(envObject, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
929
- super(envObject, initialRefcount >>> 0, ownership, finalize_callback, finalize_data, finalize_hint);
930
- this.id = 0;
931
- }
932
926
  static create(envObject, handle_id, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
933
927
  const handle = envObject.ctx.handleStore.get(handle_id);
934
928
  const ref = new Reference(envObject, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint);
@@ -940,6 +934,10 @@ class Reference extends RefBase {
940
934
  }
941
935
  return ref;
942
936
  }
937
+ constructor(envObject, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
938
+ super(envObject, initialRefcount >>> 0, ownership, finalize_callback, finalize_data, finalize_hint);
939
+ this.id = 0;
940
+ }
943
941
  ref() {
944
942
  if (this.persistent.isEmpty()) {
945
943
  return 0;
@@ -992,16 +990,16 @@ class Reference extends RefBase {
992
990
  }
993
991
 
994
992
  class Deferred {
995
- constructor(ctx, value) {
996
- this.id = 0;
997
- this.ctx = ctx;
998
- this.value = value;
999
- }
1000
993
  static create(ctx, value) {
1001
994
  const deferred = new Deferred(ctx, value);
1002
995
  ctx.deferredStore.add(deferred);
1003
996
  return deferred;
1004
997
  }
998
+ constructor(ctx, value) {
999
+ this.id = 0;
1000
+ this.ctx = ctx;
1001
+ this.value = value;
1002
+ }
1005
1003
  resolve(value) {
1006
1004
  this.value.resolve(value);
1007
1005
  this.dispose();
@@ -1 +1 @@
1
- Object.defineProperty(exports,"__esModule",{value:!0});class e{constructor(e,t,s,n,i){this.parent=e,this.thiz=t,this.data=s,this.args=n,this.fn=i}getNewTarget(e){const t=this.thiz;return null==t||null==t.constructor?0:t instanceof this.fn?e.ensureHandleId(t.constructor):0}}class t{constructor(){this.current=null}pop(){const e=this.current;null!==e&&(this.current=e.parent)}push(t,s,n,i){const r=new e(this.current,t,s,n,i);return this.current=r,r}dispose(){this.current=null}}const s=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),n=function(){if("undefined"!=typeof globalThis)return globalThis;let e=function(){return this}();if(!e&&s)try{e=new Function("return this")()}catch(e){}if(!e){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return e}();class i{constructor(){this._exception=void 0,this._caught=!1}hasCaught(){return this._caught}exception(){return this._exception}setError(e){this._caught=!0,this._exception=e}reset(){this._caught=!1,this._exception=void 0}extractException(){const e=this._exception;return this.reset(),e}}const r=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),o="object"==typeof Reflect,a="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,l=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),c="undefined"!=typeof BigInt;function u(e){return"object"==typeof e&&null!==e||"function"==typeof e}const h=function(){let e;return e="undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0,e}(),p="function"==typeof MessageChannel?MessageChannel:function(){try{return h("worker_threads").MessageChannel}catch(e){}}(),d="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(p){let t=new p;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},f="function"==typeof Buffer?Buffer:function(){try{return h("buffer").Buffer}catch(e){}}(),_="0.39.0",v=9,g=2147483647;class y{constructor(e,t){this.id=e,this.value=t}data(e){return e.getObjectBinding(this.value).data}isNumber(){return"number"==typeof this.value}isBigInt(){return"bigint"==typeof this.value}isString(){return"string"==typeof this.value}isFunction(){return"function"==typeof this.value}isExternal(){return u(this.value)&&null===Object.getPrototypeOf(this.value)}isObject(){return"object"==typeof this.value&&null!==this.value}isArray(){return Array.isArray(this.value)}isArrayBuffer(){return this.value instanceof ArrayBuffer}isTypedArray(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)}isBuffer(){return"function"==typeof f&&f.isBuffer(this.value)}isDataView(){return this.value instanceof DataView}isDate(){return this.value instanceof Date}isPromise(){return this.value instanceof Promise}isBoolean(){return"boolean"==typeof this.value}isUndefined(){return void 0===this.value}isSymbol(){return"symbol"==typeof this.value}isNull(){return null===this.value}dispose(){this.value=void 0}}class x extends y{constructor(e,t){super(e,t)}dispose(){}}function b(){Object.setPrototypeOf(this,null)}b.prototype=null;class S{constructor(){this._values=[void 0,S.UNDEFINED,S.NULL,S.FALSE,S.TRUE,S.GLOBAL],this._next=S.MIN_ID}push(e){let t;const s=this._next,n=this._values;return s<n.length?(t=n[s],t.value=e):(t=new y(s,e),n[s]=t),this._next++,t}erase(e,t){this._next=e;const s=this._values;for(let n=e;n<t;++n)s[n].dispose()}get(e){return this._values[e]}swap(e,t){const s=this._values,n=s[e];s[e]=s[t],s[e].id=Number(e),s[t]=n,n.id=Number(t)}dispose(){this._values.length=S.MIN_ID,this._next=S.MIN_ID}}S.UNDEFINED=new x(1,void 0),S.NULL=new x(2,null),S.FALSE=new x(3,!1),S.TRUE=new x(4,!0),S.GLOBAL=new x(5,n),S.MIN_ID=6;class w{constructor(e,t,s,n,i=n){this.handleStore=e,this.id=t,this.parent=s,this.child=null,null!==s&&(s.child=this),this.start=n,this.end=i,this._escapeCalled=!1}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e,t){const s=new b,n=e.ctx.handleStore.push(s);return e.initObjectBinding(s).data=t,this.end++,n}dispose(){this.start!==this.end&&this.handleStore.erase(this.start,this.end)}escape(e){if(this._escapeCalled)return null;if(this._escapeCalled=!0,e<this.start||e>=this.end)return null;this.handleStore.swap(e,this.start);const t=this.handleStore.get(this.start);return this.start++,this.parent.end++,t}escapeCalled(){return this._escapeCalled}}class k{constructor(){this._rootScope=new w(null,0,null,1,S.MIN_ID),this.currentScope=this._rootScope}get(e){e=Number(e);let t=this.currentScope;for(;t!==this._rootScope;){if(t.id===e)return t;t=t.parent}}openScope(e){const t=this.currentScope;let s=t.child;return null!==s?(s.start=s.end=t.end,s._escapeCalled=!1):s=new w(e.ctx.handleStore,t.id+1,t,t.end),this.currentScope=s,e.openHandleScopes++,s}closeScope(e){if(0===e.openHandleScopes)return;const t=this.currentScope;this.currentScope=t.parent,t.dispose(),e.openHandleScopes--}dispose(){let e=this.currentScope;for(;null!==e;){e.handleStore=null,e.id=0,e.parent=null,e.start=S.MIN_ID,e.end=S.MIN_ID,e._escapeCalled=!1;const t=e.child;e.child=null,e=t}this.currentScope=null}}class E{constructor(){this._next=null,this._prev=null}finalize(){}link(e){this._prev=e,this._next=e._next,null!==this._next&&(this._next._prev=this),e._next=this}unlink(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null}static finalizeAll(e){for(;null!==e._next;)e._next.finalize()}}class C{constructor(e,t=0,s=0,n=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=s,this._finalizeHint=n}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}dispose(){this.envObject=void 0}}class m extends C{constructor(e,t,s,n,i,r){super(e,n,i,r),this._next=null,this._prev=null,this._refcount=t,this._ownership=s,this.link(n?e.finalizing_reflist:e.reflist)}static finalizeAll(e){E.finalizeAll(e)}link(e){E.prototype.link.call(this,e)}unlink(){E.prototype.unlink.call(this)}dispose(){this.unlink(),this.envObject.dequeueFinalizer(this),super.dispose()}data(){return this._finalizeData}ref(){return++this._refcount}unref(){return 0===this._refcount?0:--this._refcount}refCount(){return this._refcount}ownership(){return this._ownership}finalize(){const e=this._ownership,t=this._finalizeCallback,s=this._finalizeData,n=this._finalizeHint;let i;this.resetFinalizer(),this.unlink();let r=!1;if(t){const e=Number(t);try{this.envObject.callFinalizer(e,s,n)}catch(e){r=!0,i=e}}if(0===e&&this.dispose(),r)throw i}}function I(e,t){if(!e.terminatedOrTerminating())throw t}class z{constructor(e,t,s,n,r){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=s,this.makeDynCall_vp=n,this.abort=r,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new i,this.refs=1,this.reflist=new E,this.finalizing_reflist=new E,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this._bindingMap=new WeakMap,this.id=0}canCallIntoJs(){return!0}terminatedOrTerminating(){return!this.canCallIntoJs()}ref(){this.refs++}unref(){this.refs--,0===this.refs&&this.dispose()}ensureHandle(e){return this.ctx.ensureHandle(e)}ensureHandleId(e){return this.ensureHandle(e).id}clearLastError(){const e=this.lastError;return 0!==e.errorCode&&(e.errorCode=0),0!==e.engineErrorCode&&(e.engineErrorCode=0),0!==e.engineReserved&&(e.engineReserved=0),0}setLastError(e,t=0,s=0){const n=this.lastError;return n.errorCode!==e&&(n.errorCode=e),n.engineErrorCode!==t&&(n.engineErrorCode=t),n.engineReserved!==s&&(n.engineReserved=s),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=I){const s=this.openHandleScopes;this.clearLastError();const n=e(this);if(s!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return n}callFinalizer(e,t,s){const n=this.makeDynCall_vppp(e),i=this.id,r=this.ctx.openScope(this);try{this.callIntoModule((()=>{n(i,t,s)}))}finally{this.ctx.closeScope(this,r)}}enqueueFinalizer(e){-1===this.pendingFinalizers.indexOf(e)&&this.pendingFinalizers.push(e)}dequeueFinalizer(e){const t=this.pendingFinalizers.indexOf(e);-1!==t&&this.pendingFinalizers.splice(t,1)}deleteMe(){m.finalizeAll(this.finalizing_reflist),m.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)}dispose(){0!==this.id&&(this.deleteMe(),this.id=0)}initObjectBinding(e){const t={wrapped:0,tag:null,data:0};return this._bindingMap.set(e,t),t}getObjectBinding(e){return this._bindingMap.has(e)?this._bindingMap.get(e):this.initObjectBinding(e)}setInstanceData(e,t,s){this.instanceData&&this.instanceData.dispose(),this.instanceData=new m(this,0,0,t,e,s)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class N extends z{constructor(e,t,s,n,i,r,o){super(e,s,n,i,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return this.ctx.canCallIntoJs()}triggerFatalException(e){if(this.nodeBinding)this.nodeBinding.napi.fatalException(e);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw e;process._fatalException(e)||(console.error(e),process.exit(1))}}callbackIntoModule(e,t){return this.callIntoModule(t,((t,s)=>{if(t.terminatedOrTerminating())return;const n="object"==typeof process&&null!==process;if(!(!!n&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy")))&&!e){if(!n||"function"!=typeof process.emitWarning)throw s;process.emitWarning("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")}t.triggerFatalException(s)}))}callFinalizer(e,t,s){this.callFinalizerInternal(1,e,t,s)}callFinalizerInternal(e,t,s,n){const i=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),(()=>{i(r,s,n)}))}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),d((()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()})))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function O(e,t,s,n,i,r,o){(s="number"!=typeof s?8:s)<8?s=8:s>v&&s!==g&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version ${v} add-ons.`)}(t,s);const a=new N(e,t,s,n,i,r,o);return e.envStore.add(a),e.addCleanupHook(a,(()=>{a.unref()}),0),a}class D extends Error{constructor(e){super(e);const t=new.target,s=t.prototype;if(!(this instanceof D)){const e=Object.setPrototypeOf;"function"==typeof e?e.call(Object,this,s):this.__proto__=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}}}Object.defineProperty(D.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});class F extends D{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(F.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class H extends D{constructor(e,t){super(`${e}: The current runtime does not support "BigInt".${t?` ${t}`:""}`)}}Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBigIntError"});class B extends D{constructor(e,t){super(`${e}: The current runtime does not support "Buffer". Consider using buffer polyfill to make sure \`globalThis.Buffer\` is defined.${t?` ${t}`:""}`)}}Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class R{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class j{constructor(e){this._ref=new R(e)}setWeak(e,t){if(!a||void 0===this._ref||this._ref instanceof WeakRef)return;const s=this._ref.deref();try{j._registry.register(s,this,this);const n=new WeakRef(s);this._ref.dispose(),this._ref=n,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof s)throw e}}clearWeak(){if(a&&void 0!==this._ref&&this._ref instanceof WeakRef){try{j._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0;const e=this._ref.deref();this._ref=void 0===e?e:new R(e)}}reset(){if(a)try{j._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof R&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}function A(e){e.persistent.reset(),e.envObject.enqueueFinalizer(e)}j._registry=a?new FinalizationRegistry((e=>{e._ref=void 0;const t=e._callback,s=e._param;e._callback=void 0,e._param=void 0,"function"==typeof t&&t(s)})):void 0;class M extends m{constructor(e,t,s,n=0,i=0,r=0){super(e,t>>>0,s,n,i,r),this.id=0}static create(e,t,s,n,i=0,r=0,o=0){const a=e.ctx.handleStore.get(t),l=new M(e,s,n,i,r,o);var c;return e.ctx.refStore.add(l),l.canBeWeak=(c=a).isObject()||c.isFunction()||c.isSymbol(),l.persistent=new j(a.value),0===s&&l._setWeak(),l}ref(){if(this.persistent.isEmpty())return 0;const e=super.ref();return 1===e&&this.canBeWeak&&this.persistent.clearWeak(),e}unref(){if(this.persistent.isEmpty())return 0;const e=this.refCount(),t=super.unref();return 1===e&&0===t&&this._setWeak(),t}get(){if(this.persistent.isEmpty())return 0;const e=this.persistent.deref();return this.envObject.ensureHandle(e).id}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,A):this.persistent.reset()}finalize(){this.persistent.reset(),super.finalize()}dispose(){0!==this.id&&(this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.id=0)}}class L{constructor(e,t){this.id=0,this.ctx=e,this.value=t}static create(e,t){const s=new L(e,t);return e.deferredStore.add(s),s}resolve(e){this.value.resolve(e),this.dispose()}reject(e){this.value.reject(e),this.dispose()}dispose(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null}}class T{constructor(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}add(e){let t;if(this._freeList.length)t=this._freeList.shift();else{t=this._size,this._size++;const e=this._values.length;t>=e&&(this._values.length=e+(e>>1)+16)}e.id=t,this._values[t]=e}get(e){return this._values[e]}has(e){return void 0!==this._values[e]}remove(e){const t=this._values[e];t&&(t.id=0,this._values[e]=void 0,this._freeList.push(Number(e)))}dispose(){for(let e=1;e<this._size;++e){const t=this._values[e];null==t||t.dispose()}this._values=[void 0],this._size=1,this._freeList=[]}}class W{constructor(e,t,s,n){this.envObject=e,this.fn=t,this.arg=s,this.order=n}}class P{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,s){if(this._cleanupHooks.filter((n=>n.envObject===e&&n.fn===t&&n.arg===s)).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new W(e,t,s,this._cleanupHookCounter++))}remove(e,t,s){for(let n=0;n<this._cleanupHooks.length;++n){const i=this._cleanupHooks[n];if(i.envObject===e&&i.fn===t&&i.arg===s)return void this._cleanupHooks.splice(n,1)}}drain(){const e=this._cleanupHooks.slice();e.sort(((e,t)=>t.order-e.order));for(let t=0;t<e.length;++t){const s=e[t];"number"==typeof s.fn?s.envObject.makeDynCall_vp(s.fn)(s.arg):s.fn(s.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(s),1)}}dispose(){this._cleanupHooks.length=0,this._cleanupHookCounter=0}}class U{constructor(){this.refHandle=(new p).port1,this.count=0}increase(){0===this.count&&this.refHandle.ref(),this.count++}decrease(){0!==this.count&&(1===this.count&&this.refHandle.unref(),this.count--)}}class q{constructor(){this._isStopping=!1,this._canCallIntoJs=!0,this.envStore=new T,this.scopeStore=new k,this.refStore=new T,this.deferredStore=new T,this.handleStore=new S,this.cbinfoStack=new t,this.feature={supportReflect:o,supportFinalizer:a,supportWeakSymbol:l,supportBigInt:c,supportNewFunction:s,canSetFunctionName:r,setImmediate:d,Buffer:f,MessageChannel:p},this.cleanupQueue=new P,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new U,process.once("beforeExit",(()=>{this.destroy()})))}getRuntimeVersions(){return{version:_,NAPI_VERSION:v,NAPI_VERSION_EXPERIMENTAL:g,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new F(e,t)}createNotSupportBigIntError(e,t){return new H(e,t)}createNotSupportBufferError(e,t){return new B(e,t)}createReference(e,t,s,n,i=0,r=0,o=0){return M.create(e,t,s,n,i,r,o)}createDeferred(e){return L.create(this,e)}createEnv(e,t,s,n,i,r){return O(this,e,t,s,n,i,r)}getCurrentScope(){return this.scopeStore.currentScope}addToCurrentScope(e){return this.scopeStore.currentScope.add(e)}openScope(e){return this.scopeStore.openScope(e)}closeScope(e,t){this.scopeStore.closeScope(e)}ensureHandle(e){switch(e){case void 0:return S.UNDEFINED;case null:return S.NULL;case!0:return S.TRUE;case!1:return S.FALSE;case n:return S.GLOBAL}return this.addToCurrentScope(e)}addCleanupHook(e,t,s){this.cleanupQueue.add(e,t,s)}removeCleanupHook(e,t,s){this.cleanupQueue.remove(e,t,s)}runCleanup(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()}increaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.increase()}decreaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.decrease()}setCanCallIntoJs(e){this._canCallIntoJs=e}setStopping(e){this._isStopping=e}canCallIntoJs(){return this._canCallIntoJs&&!this._isStopping}destroy(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()}}let V;function $(){return new q}exports.CallbackInfo=e,exports.CallbackInfoStack=t,exports.ConstHandle=x,exports.Context=q,exports.Deferred=L,exports.EmnapiError=D,exports.Env=z,exports.Finalizer=C,exports.Handle=y,exports.HandleScope=w,exports.HandleStore=S,exports.NAPI_VERSION=v,exports.NAPI_VERSION_EXPERIMENTAL=g,exports.NODE_API_DEFAULT_MODULE_API_VERSION=8,exports.NodeEnv=N,exports.NotSupportBigIntError=H,exports.NotSupportBufferError=B,exports.NotSupportWeakRefError=F,exports.Persistent=j,exports.RefBase=m,exports.RefTracker=E,exports.Reference=M,exports.ScopeStore=k,exports.Store=T,exports.TryCatch=i,exports.createContext=$,exports.getDefaultContext=function(){return V||(V=$()),V},exports.isReferenceType=u,exports.version=_;
1
+ class e{constructor(e,t,n,s,i){this.parent=e,this.thiz=t,this.data=n,this.args=s,this.fn=i}getNewTarget(e){const t=this.thiz;return null==t||null==t.constructor?0:t instanceof this.fn?e.ensureHandleId(t.constructor):0}}class t{constructor(){this.current=null}pop(){const e=this.current;null!==e&&(this.current=e.parent)}push(t,n,s,i){const r=new e(this.current,t,n,s,i);return this.current=r,r}dispose(){this.current=null}}const n=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),s=function(){if("undefined"!=typeof globalThis)return globalThis;let e=function(){return this}();if(!e&&n)try{e=new Function("return this")()}catch(e){}if(!e){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return e}();class i{constructor(){this._exception=void 0,this._caught=!1}hasCaught(){return this._caught}exception(){return this._exception}setError(e){this._caught=!0,this._exception=e}reset(){this._caught=!1,this._exception=void 0}extractException(){const e=this._exception;return this.reset(),e}}const r=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),o="object"==typeof Reflect,a="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,l=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),c="undefined"!=typeof BigInt;function u(e){return"object"==typeof e&&null!==e||"function"==typeof e}const h=function(){let e;return e="undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0,e}(),p="function"==typeof MessageChannel?MessageChannel:function(){try{return h("worker_threads").MessageChannel}catch(e){}}(),d="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(p){let t=new p;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},f="function"==typeof Buffer?Buffer:function(){try{return h("buffer").Buffer}catch(e){}}(),_="0.40.0",v=9,g=2147483647;class y{constructor(e,t){this.id=e,this.value=t}data(e){return e.getObjectBinding(this.value).data}isNumber(){return"number"==typeof this.value}isBigInt(){return"bigint"==typeof this.value}isString(){return"string"==typeof this.value}isFunction(){return"function"==typeof this.value}isExternal(){return u(this.value)&&null===Object.getPrototypeOf(this.value)}isObject(){return"object"==typeof this.value&&null!==this.value}isArray(){return Array.isArray(this.value)}isArrayBuffer(){return this.value instanceof ArrayBuffer}isTypedArray(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)}isBuffer(){return"function"==typeof f&&f.isBuffer(this.value)}isDataView(){return this.value instanceof DataView}isDate(){return this.value instanceof Date}isPromise(){return this.value instanceof Promise}isBoolean(){return"boolean"==typeof this.value}isUndefined(){return void 0===this.value}isSymbol(){return"symbol"==typeof this.value}isNull(){return null===this.value}dispose(){this.value=void 0}}class x extends y{constructor(e,t){super(e,t)}dispose(){}}function b(){Object.setPrototypeOf(this,null)}b.prototype=null;class S{constructor(){this._values=[void 0,S.UNDEFINED,S.NULL,S.FALSE,S.TRUE,S.GLOBAL],this._next=S.MIN_ID}push(e){let t;const n=this._next,s=this._values;return n<s.length?(t=s[n],t.value=e):(t=new y(n,e),s[n]=t),this._next++,t}erase(e,t){this._next=e;const n=this._values;for(let s=e;s<t;++s)n[s].dispose()}get(e){return this._values[e]}swap(e,t){const n=this._values,s=n[e];n[e]=n[t],n[e].id=Number(e),n[t]=s,s.id=Number(t)}dispose(){this._values.length=S.MIN_ID,this._next=S.MIN_ID}}S.UNDEFINED=new x(1,void 0),S.NULL=new x(2,null),S.FALSE=new x(3,!1),S.TRUE=new x(4,!0),S.GLOBAL=new x(5,s),S.MIN_ID=6;class w{constructor(e,t,n,s,i=s){this.handleStore=e,this.id=t,this.parent=n,this.child=null,null!==n&&(n.child=this),this.start=s,this.end=i,this._escapeCalled=!1}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e,t){const n=new b,s=e.ctx.handleStore.push(n);return e.initObjectBinding(n).data=t,this.end++,s}dispose(){this.start!==this.end&&this.handleStore.erase(this.start,this.end)}escape(e){if(this._escapeCalled)return null;if(this._escapeCalled=!0,e<this.start||e>=this.end)return null;this.handleStore.swap(e,this.start);const t=this.handleStore.get(this.start);return this.start++,this.parent.end++,t}escapeCalled(){return this._escapeCalled}}class k{constructor(){this._rootScope=new w(null,0,null,1,S.MIN_ID),this.currentScope=this._rootScope}get(e){e=Number(e);let t=this.currentScope;for(;t!==this._rootScope;){if(t.id===e)return t;t=t.parent}}openScope(e){const t=this.currentScope;let n=t.child;return null!==n?(n.start=n.end=t.end,n._escapeCalled=!1):n=new w(e.ctx.handleStore,t.id+1,t,t.end),this.currentScope=n,e.openHandleScopes++,n}closeScope(e){if(0===e.openHandleScopes)return;const t=this.currentScope;this.currentScope=t.parent,t.dispose(),e.openHandleScopes--}dispose(){let e=this.currentScope;for(;null!==e;){e.handleStore=null,e.id=0,e.parent=null,e.start=S.MIN_ID,e.end=S.MIN_ID,e._escapeCalled=!1;const t=e.child;e.child=null,e=t}this.currentScope=null}}class E{constructor(){this._next=null,this._prev=null}finalize(){}link(e){this._prev=e,this._next=e._next,null!==this._next&&(this._next._prev=this),e._next=this}unlink(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null}static finalizeAll(e){for(;null!==e._next;)e._next.finalize()}}class C{constructor(e,t=0,n=0,s=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=n,this._finalizeHint=s}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}dispose(){this.envObject=void 0}}class m extends C{static finalizeAll(e){E.finalizeAll(e)}link(e){E.prototype.link.call(this,e)}unlink(){E.prototype.unlink.call(this)}constructor(e,t,n,s,i,r){super(e,s,i,r),this._next=null,this._prev=null,this._refcount=t,this._ownership=n,this.link(s?e.finalizing_reflist:e.reflist)}dispose(){this.unlink(),this.envObject.dequeueFinalizer(this),super.dispose()}data(){return this._finalizeData}ref(){return++this._refcount}unref(){return 0===this._refcount?0:--this._refcount}refCount(){return this._refcount}ownership(){return this._ownership}finalize(){const e=this._ownership,t=this._finalizeCallback,n=this._finalizeData,s=this._finalizeHint;let i;this.resetFinalizer(),this.unlink();let r=!1;if(t){const e=Number(t);try{this.envObject.callFinalizer(e,n,s)}catch(e){r=!0,i=e}}if(0===e&&this.dispose(),r)throw i}}function I(e,t){if(!e.terminatedOrTerminating())throw t}class z{constructor(e,t,n,s,r){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=n,this.makeDynCall_vp=s,this.abort=r,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new i,this.refs=1,this.reflist=new E,this.finalizing_reflist=new E,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this._bindingMap=new WeakMap,this.id=0}canCallIntoJs(){return!0}terminatedOrTerminating(){return!this.canCallIntoJs()}ref(){this.refs++}unref(){this.refs--,0===this.refs&&this.dispose()}ensureHandle(e){return this.ctx.ensureHandle(e)}ensureHandleId(e){return this.ensureHandle(e).id}clearLastError(){const e=this.lastError;return 0!==e.errorCode&&(e.errorCode=0),0!==e.engineErrorCode&&(e.engineErrorCode=0),0!==e.engineReserved&&(e.engineReserved=0),0}setLastError(e,t=0,n=0){const s=this.lastError;return s.errorCode!==e&&(s.errorCode=e),s.engineErrorCode!==t&&(s.engineErrorCode=t),s.engineReserved!==n&&(s.engineReserved=n),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=I){const n=this.openHandleScopes;this.clearLastError();const s=e(this);if(n!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return s}callFinalizer(e,t,n){const s=this.makeDynCall_vppp(e),i=this.id,r=this.ctx.openScope(this);try{this.callIntoModule((()=>{s(i,t,n)}))}finally{this.ctx.closeScope(this,r)}}enqueueFinalizer(e){-1===this.pendingFinalizers.indexOf(e)&&this.pendingFinalizers.push(e)}dequeueFinalizer(e){const t=this.pendingFinalizers.indexOf(e);-1!==t&&this.pendingFinalizers.splice(t,1)}deleteMe(){m.finalizeAll(this.finalizing_reflist),m.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)}dispose(){0!==this.id&&(this.deleteMe(),this.id=0)}initObjectBinding(e){const t={wrapped:0,tag:null,data:0};return this._bindingMap.set(e,t),t}getObjectBinding(e){return this._bindingMap.has(e)?this._bindingMap.get(e):this.initObjectBinding(e)}setInstanceData(e,t,n){this.instanceData&&this.instanceData.dispose(),this.instanceData=new m(this,0,0,t,e,n)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class N extends z{constructor(e,t,n,s,i,r,o){super(e,n,s,i,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return this.ctx.canCallIntoJs()}triggerFatalException(e){if(this.nodeBinding)this.nodeBinding.napi.fatalException(e);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw e;process._fatalException(e)||(console.error(e),process.exit(1))}}callbackIntoModule(e,t){return this.callIntoModule(t,((t,n)=>{if(t.terminatedOrTerminating())return;const s="object"==typeof process&&null!==process;if(!(!!s&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy")))&&!e){if(!s||"function"!=typeof process.emitWarning)throw n;process.emitWarning("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")}t.triggerFatalException(n)}))}callFinalizer(e,t,n){this.callFinalizerInternal(1,e,t,n)}callFinalizerInternal(e,t,n,s){const i=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),(()=>{i(r,n,s)}))}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),d((()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()})))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function O(e,t,n,s,i,r,o){(n="number"!=typeof n?8:n)<8?n=8:n>v&&n!==g&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version ${v} add-ons.`)}(t,n);const a=new N(e,t,n,s,i,r,o);return e.envStore.add(a),e.addCleanupHook(a,(()=>{a.unref()}),0),a}class D extends Error{constructor(e){super(e);const t=new.target,n=t.prototype;if(!(this instanceof D)){const e=Object.setPrototypeOf;"function"==typeof e?e.call(Object,this,n):this.__proto__=n,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}}}Object.defineProperty(D.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});class F extends D{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(F.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class H extends D{constructor(e,t){super(`${e}: The current runtime does not support "BigInt".${t?` ${t}`:""}`)}}Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBigIntError"});class B extends D{constructor(e,t){super(`${e}: The current runtime does not support "Buffer". Consider using buffer polyfill to make sure \`globalThis.Buffer\` is defined.${t?` ${t}`:""}`)}}Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class R{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class j{constructor(e){this._ref=new R(e)}setWeak(e,t){if(!a||void 0===this._ref||this._ref instanceof WeakRef)return;const n=this._ref.deref();try{j._registry.register(n,this,this);const s=new WeakRef(n);this._ref.dispose(),this._ref=s,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof n)throw e}}clearWeak(){if(a&&void 0!==this._ref&&this._ref instanceof WeakRef){try{j._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0;const e=this._ref.deref();this._ref=void 0===e?e:new R(e)}}reset(){if(a)try{j._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof R&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}function A(e){e.persistent.reset(),e.envObject.enqueueFinalizer(e)}j._registry=a?new FinalizationRegistry((e=>{e._ref=void 0;const t=e._callback,n=e._param;e._callback=void 0,e._param=void 0,"function"==typeof t&&t(n)})):void 0;class M extends m{static create(e,t,n,s,i=0,r=0,o=0){const a=e.ctx.handleStore.get(t),l=new M(e,n,s,i,r,o);var c;return e.ctx.refStore.add(l),l.canBeWeak=(c=a).isObject()||c.isFunction()||c.isSymbol(),l.persistent=new j(a.value),0===n&&l._setWeak(),l}constructor(e,t,n,s=0,i=0,r=0){super(e,t>>>0,n,s,i,r),this.id=0}ref(){if(this.persistent.isEmpty())return 0;const e=super.ref();return 1===e&&this.canBeWeak&&this.persistent.clearWeak(),e}unref(){if(this.persistent.isEmpty())return 0;const e=this.refCount(),t=super.unref();return 1===e&&0===t&&this._setWeak(),t}get(){if(this.persistent.isEmpty())return 0;const e=this.persistent.deref();return this.envObject.ensureHandle(e).id}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,A):this.persistent.reset()}finalize(){this.persistent.reset(),super.finalize()}dispose(){0!==this.id&&(this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.id=0)}}class L{static create(e,t){const n=new L(e,t);return e.deferredStore.add(n),n}constructor(e,t){this.id=0,this.ctx=e,this.value=t}resolve(e){this.value.resolve(e),this.dispose()}reject(e){this.value.reject(e),this.dispose()}dispose(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null}}class T{constructor(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}add(e){let t;if(this._freeList.length)t=this._freeList.shift();else{t=this._size,this._size++;const e=this._values.length;t>=e&&(this._values.length=e+(e>>1)+16)}e.id=t,this._values[t]=e}get(e){return this._values[e]}has(e){return void 0!==this._values[e]}remove(e){const t=this._values[e];t&&(t.id=0,this._values[e]=void 0,this._freeList.push(Number(e)))}dispose(){for(let e=1;e<this._size;++e){const t=this._values[e];null==t||t.dispose()}this._values=[void 0],this._size=1,this._freeList=[]}}class W{constructor(e,t,n,s){this.envObject=e,this.fn=t,this.arg=n,this.order=s}}class P{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,n){if(this._cleanupHooks.filter((s=>s.envObject===e&&s.fn===t&&s.arg===n)).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new W(e,t,n,this._cleanupHookCounter++))}remove(e,t,n){for(let s=0;s<this._cleanupHooks.length;++s){const i=this._cleanupHooks[s];if(i.envObject===e&&i.fn===t&&i.arg===n)return void this._cleanupHooks.splice(s,1)}}drain(){const e=this._cleanupHooks.slice();e.sort(((e,t)=>t.order-e.order));for(let t=0;t<e.length;++t){const n=e[t];"number"==typeof n.fn?n.envObject.makeDynCall_vp(n.fn)(n.arg):n.fn(n.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(n),1)}}dispose(){this._cleanupHooks.length=0,this._cleanupHookCounter=0}}class U{constructor(){this.refHandle=(new p).port1,this.count=0}increase(){0===this.count&&this.refHandle.ref(),this.count++}decrease(){0!==this.count&&(1===this.count&&this.refHandle.unref(),this.count--)}}class q{constructor(){this._isStopping=!1,this._canCallIntoJs=!0,this.envStore=new T,this.scopeStore=new k,this.refStore=new T,this.deferredStore=new T,this.handleStore=new S,this.cbinfoStack=new t,this.feature={supportReflect:o,supportFinalizer:a,supportWeakSymbol:l,supportBigInt:c,supportNewFunction:n,canSetFunctionName:r,setImmediate:d,Buffer:f,MessageChannel:p},this.cleanupQueue=new P,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new U,process.once("beforeExit",(()=>{this.destroy()})))}getRuntimeVersions(){return{version:_,NAPI_VERSION:v,NAPI_VERSION_EXPERIMENTAL:g,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new F(e,t)}createNotSupportBigIntError(e,t){return new H(e,t)}createNotSupportBufferError(e,t){return new B(e,t)}createReference(e,t,n,s,i=0,r=0,o=0){return M.create(e,t,n,s,i,r,o)}createDeferred(e){return L.create(this,e)}createEnv(e,t,n,s,i,r){return O(this,e,t,n,s,i,r)}getCurrentScope(){return this.scopeStore.currentScope}addToCurrentScope(e){return this.scopeStore.currentScope.add(e)}openScope(e){return this.scopeStore.openScope(e)}closeScope(e,t){this.scopeStore.closeScope(e)}ensureHandle(e){switch(e){case void 0:return S.UNDEFINED;case null:return S.NULL;case!0:return S.TRUE;case!1:return S.FALSE;case s:return S.GLOBAL}return this.addToCurrentScope(e)}addCleanupHook(e,t,n){this.cleanupQueue.add(e,t,n)}removeCleanupHook(e,t,n){this.cleanupQueue.remove(e,t,n)}runCleanup(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()}increaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.increase()}decreaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.decrease()}setCanCallIntoJs(e){this._canCallIntoJs=e}setStopping(e){this._isStopping=e}canCallIntoJs(){return this._canCallIntoJs&&!this._isStopping}destroy(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()}}let V;function $(){return new q}exports.CallbackInfo=e,exports.CallbackInfoStack=t,exports.ConstHandle=x,exports.Context=q,exports.Deferred=L,exports.EmnapiError=D,exports.Env=z,exports.Finalizer=C,exports.Handle=y,exports.HandleScope=w,exports.HandleStore=S,exports.NAPI_VERSION=v,exports.NAPI_VERSION_EXPERIMENTAL=g,exports.NODE_API_DEFAULT_MODULE_API_VERSION=8,exports.NodeEnv=N,exports.NotSupportBigIntError=H,exports.NotSupportBufferError=B,exports.NotSupportWeakRefError=F,exports.Persistent=j,exports.RefBase=m,exports.RefTracker=E,exports.Reference=M,exports.ScopeStore=k,exports.Store=T,exports.TryCatch=i,exports.createContext=$,exports.getDefaultContext=function(){return V||(V=$()),V},exports.isReferenceType=u,exports.version=_;
@@ -174,7 +174,7 @@ var _Buffer = typeof Buffer === 'function'
174
174
  catch (_) { }
175
175
  return undefined;
176
176
  })();
177
- var version = "0.39.0";
177
+ var version = "0.40.0";
178
178
  var NAPI_VERSION = 9 /* Version.NAPI_VERSION */;
179
179
  var NAPI_VERSION_EXPERIMENTAL = 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */;
180
180
  var NODE_API_DEFAULT_MODULE_API_VERSION = 8 /* Version.NODE_API_DEFAULT_MODULE_API_VERSION */;
@@ -205,7 +205,7 @@ var emnapi = (function (exports) {
205
205
  catch (_) { }
206
206
  return undefined;
207
207
  })();
208
- var version = "0.39.0";
208
+ var version = "0.40.0";
209
209
  var NAPI_VERSION = 9 /* Version.NAPI_VERSION */;
210
210
  var NAPI_VERSION_EXPERIMENTAL = 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */;
211
211
  var NODE_API_DEFAULT_MODULE_API_VERSION = 8 /* Version.NODE_API_DEFAULT_MODULE_API_VERSION */;
@@ -1389,8 +1389,6 @@ var emnapi = (function (exports) {
1389
1389
  exports.isReferenceType = isReferenceType;
1390
1390
  exports.version = version;
1391
1391
 
1392
- Object.defineProperty(exports, '__esModule', { value: true });
1393
-
1394
1392
  return exports;
1395
1393
 
1396
1394
  })({});
package/dist/emnapi.js CHANGED
@@ -208,7 +208,7 @@
208
208
  catch (_) { }
209
209
  return undefined;
210
210
  })();
211
- var version = "0.39.0";
211
+ var version = "0.40.0";
212
212
  var NAPI_VERSION = 9 /* Version.NAPI_VERSION */;
213
213
  var NAPI_VERSION_EXPERIMENTAL = 2147483647 /* Version.NAPI_VERSION_EXPERIMENTAL */;
214
214
  var NODE_API_DEFAULT_MODULE_API_VERSION = 8 /* Version.NODE_API_DEFAULT_MODULE_API_VERSION */;
@@ -1392,6 +1392,4 @@
1392
1392
  exports.isReferenceType = isReferenceType;
1393
1393
  exports.version = version;
1394
1394
 
1395
- Object.defineProperty(exports, '__esModule', { value: true });
1396
-
1397
1395
  }));
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).emnapi={})}(this,(function(t){var e=function(){function t(t,e,n,i,r){this.parent=t,this.thiz=e,this.data=n,this.args=i,this.fn=r}return t.prototype.getNewTarget=function(t){var e=this.thiz;return null==e||null==e.constructor?0:e instanceof this.fn?t.ensureHandleId(e.constructor):0},t}(),n=function(){function t(){this.current=null}return t.prototype.pop=function(){var t=this.current;null!==t&&(this.current=t.parent)},t.prototype.push=function(t,n,i,r){var o=new e(this.current,t,n,i,r);return this.current=o,o},t.prototype.dispose=function(){this.current=null},t}(),i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){var t;try{t=new Function}catch(t){return!1}return"function"==typeof t}(),s=function(){if("undefined"!=typeof globalThis)return globalThis;var t=function(){return this}();if(!t&&o)try{t=new Function("return this")()}catch(t){}if(!t){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return t}(),u=function(){function t(){this._exception=void 0,this._caught=!1}return t.prototype.hasCaught=function(){return this._caught},t.prototype.exception=function(){return this._exception},t.prototype.setError=function(t){this._caught=!0,this._exception=t},t.prototype.reset=function(){this._caught=!1,this._exception=void 0},t.prototype.extractException=function(){var t=this._exception;return this.reset(),t},t}(),a=function(){var t;try{return Boolean(null===(t=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===t?void 0:t.configurable)}catch(t){return!1}}(),p="object"==typeof Reflect,c="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,f=function(){try{var t=Symbol();new WeakRef(t),(new WeakMap).set(t,void 0)}catch(t){return!1}return!0}(),l="undefined"!=typeof BigInt;function h(t){return"object"==typeof t&&null!==t||"function"==typeof t}var d=function(){return"undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0}(),y="function"==typeof MessageChannel?MessageChannel:function(){try{return d("worker_threads").MessageChannel}catch(t){}}(),_="function"==typeof setImmediate?setImmediate:function(t){if("function"!=typeof t)throw new TypeError('The "callback" argument must be of type function');if(y){var e=new y;e.port1.onmessage=function(){e.port1.onmessage=null,e=void 0,t()},e.port2.postMessage(null)}else setTimeout(t,0)},v="function"==typeof Buffer?Buffer:function(){try{return d("buffer").Buffer}catch(t){}}(),g="0.39.0",b=9,S=2147483647,w=function(){function t(t,e){this.id=t,this.value=e}return t.prototype.data=function(t){return t.getObjectBinding(this.value).data},t.prototype.isNumber=function(){return"number"==typeof this.value},t.prototype.isBigInt=function(){return"bigint"==typeof this.value},t.prototype.isString=function(){return"string"==typeof this.value},t.prototype.isFunction=function(){return"function"==typeof this.value},t.prototype.isExternal=function(){return h(this.value)&&null===Object.getPrototypeOf(this.value)},t.prototype.isObject=function(){return"object"==typeof this.value&&null!==this.value},t.prototype.isArray=function(){return Array.isArray(this.value)},t.prototype.isArrayBuffer=function(){return this.value instanceof ArrayBuffer},t.prototype.isTypedArray=function(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)},t.prototype.isBuffer=function(){return"function"==typeof v&&v.isBuffer(this.value)},t.prototype.isDataView=function(){return this.value instanceof DataView},t.prototype.isDate=function(){return this.value instanceof Date},t.prototype.isPromise=function(){return this.value instanceof Promise},t.prototype.isBoolean=function(){return"boolean"==typeof this.value},t.prototype.isUndefined=function(){return void 0===this.value},t.prototype.isSymbol=function(){return"symbol"==typeof this.value},t.prototype.isNull=function(){return null===this.value},t.prototype.dispose=function(){this.value=void 0},t}(),E=function(t){function e(e,n){return t.call(this,e,n)||this}return r(e,t),e.prototype.dispose=function(){},e}(w);function k(){Object.setPrototypeOf(this,null)}k.prototype=null;var m=function(){function t(){this._values=[void 0,t.UNDEFINED,t.NULL,t.FALSE,t.TRUE,t.GLOBAL],this._next=t.MIN_ID}return t.prototype.push=function(t){var e,n=this._next,i=this._values;return n<i.length?(e=i[n]).value=t:(e=new w(n,t),i[n]=e),this._next++,e},t.prototype.erase=function(t,e){this._next=t;for(var n=this._values,i=t;i<e;++i)n[i].dispose()},t.prototype.get=function(t){return this._values[t]},t.prototype.swap=function(t,e){var n=this._values,i=n[t];n[t]=n[e],n[t].id=Number(t),n[e]=i,i.id=Number(e)},t.prototype.dispose=function(){this._values.length=t.MIN_ID,this._next=t.MIN_ID},t.UNDEFINED=new E(1,void 0),t.NULL=new E(2,null),t.FALSE=new E(3,!1),t.TRUE=new E(4,!0),t.GLOBAL=new E(5,s),t.MIN_ID=6,t}(),C=function(){function t(t,e,n,i,r){void 0===r&&(r=i),this.handleStore=t,this.id=e,this.parent=n,this.child=null,null!==n&&(n.child=this),this.start=i,this.end=r,this._escapeCalled=!1}return t.prototype.add=function(t){var e=this.handleStore.push(t);return this.end++,e},t.prototype.addExternal=function(t,e){var n=new k,i=t.ctx.handleStore.push(n);return t.initObjectBinding(n).data=e,this.end++,i},t.prototype.dispose=function(){this.start!==this.end&&this.handleStore.erase(this.start,this.end)},t.prototype.escape=function(t){if(this._escapeCalled)return null;if(this._escapeCalled=!0,t<this.start||t>=this.end)return null;this.handleStore.swap(t,this.start);var e=this.handleStore.get(this.start);return this.start++,this.parent.end++,e},t.prototype.escapeCalled=function(){return this._escapeCalled},t}(),x=function(){function t(){this._rootScope=new C(null,0,null,1,m.MIN_ID),this.currentScope=this._rootScope}return t.prototype.get=function(t){t=Number(t);for(var e=this.currentScope;e!==this._rootScope;){if(e.id===t)return e;e=e.parent}},t.prototype.openScope=function(t){var e=this.currentScope,n=e.child;return null!==n?(n.start=n.end=e.end,n._escapeCalled=!1):n=new C(t.ctx.handleStore,e.id+1,e,e.end),this.currentScope=n,t.openHandleScopes++,n},t.prototype.closeScope=function(t){if(0!==t.openHandleScopes){var e=this.currentScope;this.currentScope=e.parent,e.dispose(),t.openHandleScopes--}},t.prototype.dispose=function(){for(var t=this.currentScope;null!==t;){t.handleStore=null,t.id=0,t.parent=null,t.start=m.MIN_ID,t.end=m.MIN_ID,t._escapeCalled=!1;var e=t.child;t.child=null,t=e}this.currentScope=null},t}(),I=function(){function t(){this._next=null,this._prev=null}return t.prototype.finalize=function(){},t.prototype.link=function(t){this._prev=t,this._next=t._next,null!==this._next&&(this._next._prev=this),t._next=this},t.prototype.unlink=function(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null},t.finalizeAll=function(t){for(;null!==t._next;)t._next.finalize()},t}(),z=function(){function t(t,e,n,i){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),this.envObject=t,this._finalizeCallback=e,this._finalizeData=n,this._finalizeHint=i}return t.prototype.callback=function(){return this._finalizeCallback},t.prototype.data=function(){return this._finalizeData},t.prototype.hint=function(){return this._finalizeHint},t.prototype.resetFinalizer=function(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0},t.prototype.dispose=function(){this.envObject=void 0},t}(),O=function(t){function e(e,n,i,r,o,s){var u=t.call(this,e,r,o,s)||this;return u._next=null,u._prev=null,u._refcount=n,u._ownership=i,u.link(r?e.finalizing_reflist:e.reflist),u}return r(e,t),e.finalizeAll=function(t){I.finalizeAll(t)},e.prototype.link=function(t){I.prototype.link.call(this,t)},e.prototype.unlink=function(){I.prototype.unlink.call(this)},e.prototype.dispose=function(){this.unlink(),this.envObject.dequeueFinalizer(this),t.prototype.dispose.call(this)},e.prototype.data=function(){return this._finalizeData},e.prototype.ref=function(){return++this._refcount},e.prototype.unref=function(){return 0===this._refcount?0:--this._refcount},e.prototype.refCount=function(){return this._refcount},e.prototype.ownership=function(){return this._ownership},e.prototype.finalize=function(){var t,e=this._ownership,n=this._finalizeCallback,i=this._finalizeData,r=this._finalizeHint;this.resetFinalizer(),this.unlink();var o=!1;if(n){var s=Number(n);try{this.envObject.callFinalizer(s,i,r)}catch(e){o=!0,t=e}}if(0===e&&this.dispose(),o)throw t},e}(z);function N(t,e){if(!t.terminatedOrTerminating())throw e}var D=function(){function t(t,e,n,i,r){this.ctx=t,this.moduleApiVersion=e,this.makeDynCall_vppp=n,this.makeDynCall_vp=i,this.abort=r,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new u,this.refs=1,this.reflist=new I,this.finalizing_reflist=new I,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this._bindingMap=new WeakMap,this.id=0}return t.prototype.canCallIntoJs=function(){return!0},t.prototype.terminatedOrTerminating=function(){return!this.canCallIntoJs()},t.prototype.ref=function(){this.refs++},t.prototype.unref=function(){this.refs--,0===this.refs&&this.dispose()},t.prototype.ensureHandle=function(t){return this.ctx.ensureHandle(t)},t.prototype.ensureHandleId=function(t){return this.ensureHandle(t).id},t.prototype.clearLastError=function(){var t=this.lastError;return 0!==t.errorCode&&(t.errorCode=0),0!==t.engineErrorCode&&(t.engineErrorCode=0),0!==t.engineReserved&&(t.engineReserved=0),0},t.prototype.setLastError=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0);var i=this.lastError;return i.errorCode!==t&&(i.errorCode=t),i.engineErrorCode!==e&&(i.engineErrorCode=e),i.engineReserved!==n&&(i.engineReserved=n),t},t.prototype.getReturnStatus=function(){return this.tryCatch.hasCaught()?this.setLastError(10):0},t.prototype.callIntoModule=function(t,e){void 0===e&&(e=N);var n=this.openHandleScopes;this.clearLastError();var i=t(this);(n!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught())&&e(this,this.tryCatch.extractException());return i},t.prototype.callFinalizer=function(t,e,n){var i=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callIntoModule((function(){i(r,e,n)}))}finally{this.ctx.closeScope(this,o)}},t.prototype.enqueueFinalizer=function(t){-1===this.pendingFinalizers.indexOf(t)&&this.pendingFinalizers.push(t)},t.prototype.dequeueFinalizer=function(t){var e=this.pendingFinalizers.indexOf(t);-1!==e&&this.pendingFinalizers.splice(e,1)},t.prototype.deleteMe=function(){O.finalizeAll(this.finalizing_reflist),O.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)},t.prototype.dispose=function(){0!==this.id&&(this.deleteMe(),this.id=0)},t.prototype.initObjectBinding=function(t){var e={wrapped:0,tag:null,data:0};return this._bindingMap.set(t,e),e},t.prototype.getObjectBinding=function(t){return this._bindingMap.has(t)?this._bindingMap.get(t):this.initObjectBinding(t)},t.prototype.setInstanceData=function(t,e,n){this.instanceData&&this.instanceData.dispose(),this.instanceData=new O(this,0,0,e,t,n)},t.prototype.getInstanceData=function(){return this.instanceData?this.instanceData.data():0},t}(),F=function(t){function e(e,n,i,r,o,s,u){var a=t.call(this,e,i,r,o,s)||this;return a.filename=n,a.nodeBinding=u,a.destructing=!1,a.finalizationScheduled=!1,a}return r(e,t),e.prototype.deleteMe=function(){this.destructing=!0,this.drainFinalizerQueue(),t.prototype.deleteMe.call(this)},e.prototype.canCallIntoJs=function(){return this.ctx.canCallIntoJs()},e.prototype.triggerFatalException=function(t){if(this.nodeBinding)this.nodeBinding.napi.fatalException(t);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw t;process._fatalException(t)||(console.error(t),process.exit(1))}},e.prototype.callbackIntoModule=function(t,e){return this.callIntoModule(e,(function(e,n){if(!e.terminatedOrTerminating()){var i="object"==typeof process&&null!==process;if(!(!!i&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy")))&&!t){if(!i||"function"!=typeof process.emitWarning)throw n;process.emitWarning("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")}e.triggerFatalException(n)}}))},e.prototype.callFinalizer=function(t,e,n){this.callFinalizerInternal(1,t,e,n)},e.prototype.callFinalizerInternal=function(t,e,n,i){var r=this.makeDynCall_vppp(e),o=this.id,s=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(t),(function(){r(o,n,i)}))}finally{this.ctx.closeScope(this,s)}},e.prototype.enqueueFinalizer=function(e){var n=this;t.prototype.enqueueFinalizer.call(this,e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),_((function(){n.finalizationScheduled=!1,n.unref(),n.drainFinalizerQueue()})))},e.prototype.drainFinalizerQueue=function(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}},e}(D);function j(t,e,n,i,r,o,s){(n="number"!=typeof n?8:n)<8?n=8:n>b&&n!==S&&function(t,e){var n="".concat(t," requires Node-API version ").concat(e,", but this version of Node.js only supports version ").concat(b," add-ons.");throw new Error(n)}(e,n);var u=new F(t,e,n,i,r,o,s);return t.envStore.add(u),t.addCleanupHook(u,(function(){u.unref()}),0),u}var H=function(t){function e(n){var i=this.constructor,r=t.call(this,n)||this,o=i,s=o.prototype;if(!(r instanceof e)){var u=Object.setPrototypeOf;"function"==typeof u?u.call(Object,r,s):r.__proto__=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,o)}return r}return r(e,t),e}(Error);Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});var B=function(t){function e(e,n){return t.call(this,"".concat(e,': The current runtime does not support "FinalizationRegistry" and "WeakRef".').concat(n?" ".concat(n):""))||this}return r(e,t),e}(H);Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});var R=function(t){function e(e,n){return t.call(this,"".concat(e,': The current runtime does not support "BigInt".').concat(n?" ".concat(n):""))||this}return r(e,t),e}(H);Object.defineProperty(R.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBigIntError"});var A=function(t){function e(e,n){return t.call(this,"".concat(e,': The current runtime does not support "Buffer". Consider using buffer polyfill to make sure `globalThis.Buffer` is defined.').concat(n?" ".concat(n):""))||this}return r(e,t),e}(H);Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});var M=function(){function t(t){this._value=t}return t.prototype.deref=function(){return this._value},t.prototype.dispose=function(){this._value=void 0},t}(),T=function(){function t(t){this._ref=new M(t)}return t.prototype.setWeak=function(e,n){if(c&&void 0!==this._ref&&!(this._ref instanceof WeakRef)){var i=this._ref.deref();try{t._registry.register(i,this,this);var r=new WeakRef(i);this._ref.dispose(),this._ref=r,this._param=e,this._callback=n}catch(t){if("symbol"!=typeof i)throw t}}},t.prototype.clearWeak=function(){if(c&&void 0!==this._ref&&this._ref instanceof WeakRef){try{t._registry.unregister(this)}catch(t){}this._param=void 0,this._callback=void 0;var e=this._ref.deref();this._ref=void 0===e?e:new M(e)}},t.prototype.reset=function(){if(c)try{t._registry.unregister(this)}catch(t){}this._param=void 0,this._callback=void 0,this._ref instanceof M&&this._ref.dispose(),this._ref=void 0},t.prototype.isEmpty=function(){return void 0===this._ref},t.prototype.deref=function(){if(void 0!==this._ref)return this._ref.deref()},t._registry=c?new FinalizationRegistry((function(t){t._ref=void 0;var e=t._callback,n=t._param;t._callback=void 0,t._param=void 0,"function"==typeof e&&e(n)})):void 0,t}();function L(t){t.persistent.reset(),t.envObject.enqueueFinalizer(t)}var P,W=function(t){function e(e,n,i,r,o,s){void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=0);var u=t.call(this,e,n>>>0,i,r,o,s)||this;return u.id=0,u}return r(e,t),e.create=function(t,n,i,r,o,s,u){void 0===o&&(o=0),void 0===s&&(s=0),void 0===u&&(u=0);var a,p=t.ctx.handleStore.get(n),c=new e(t,i,r,o,s,u);return t.ctx.refStore.add(c),c.canBeWeak=(a=p).isObject()||a.isFunction()||a.isSymbol(),c.persistent=new T(p.value),0===i&&c._setWeak(),c},e.prototype.ref=function(){if(this.persistent.isEmpty())return 0;var e=t.prototype.ref.call(this);return 1===e&&this.canBeWeak&&this.persistent.clearWeak(),e},e.prototype.unref=function(){if(this.persistent.isEmpty())return 0;var e=this.refCount(),n=t.prototype.unref.call(this);return 1===e&&0===n&&this._setWeak(),n},e.prototype.get=function(){if(this.persistent.isEmpty())return 0;var t=this.persistent.deref();return this.envObject.ensureHandle(t).id},e.prototype._setWeak=function(){this.canBeWeak?this.persistent.setWeak(this,L):this.persistent.reset()},e.prototype.finalize=function(){this.persistent.reset(),t.prototype.finalize.call(this)},e.prototype.dispose=function(){0!==this.id&&(this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),t.prototype.dispose.call(this),this.id=0)},e}(O),U=function(){function t(t,e){this.id=0,this.ctx=t,this.value=e}return t.create=function(e,n){var i=new t(e,n);return e.deferredStore.add(i),i},t.prototype.resolve=function(t){this.value.resolve(t),this.dispose()},t.prototype.reject=function(t){this.value.reject(t),this.dispose()},t.prototype.dispose=function(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null},t}(),q=function(){function t(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}return t.prototype.add=function(t){var e;if(this._freeList.length)e=this._freeList.shift();else{e=this._size,this._size++;var n=this._values.length;e>=n&&(this._values.length=n+(n>>1)+16)}t.id=e,this._values[e]=t},t.prototype.get=function(t){return this._values[t]},t.prototype.has=function(t){return void 0!==this._values[t]},t.prototype.remove=function(t){var e=this._values[t];e&&(e.id=0,this._values[t]=void 0,this._freeList.push(Number(t)))},t.prototype.dispose=function(){for(var t=1;t<this._size;++t){var e=this._values[t];null==e||e.dispose()}this._values=[void 0],this._size=1,this._freeList=[]},t}(),V=function(){return function(t,e,n,i){this.envObject=t,this.fn=e,this.arg=n,this.order=i}}(),J=function(){function t(){this._cleanupHooks=[],this._cleanupHookCounter=0}return t.prototype.empty=function(){return 0===this._cleanupHooks.length},t.prototype.add=function(t,e,n){if(this._cleanupHooks.filter((function(i){return i.envObject===t&&i.fn===e&&i.arg===n})).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new V(t,e,n,this._cleanupHookCounter++))},t.prototype.remove=function(t,e,n){for(var i=0;i<this._cleanupHooks.length;++i){var r=this._cleanupHooks[i];if(r.envObject===t&&r.fn===e&&r.arg===n)return void this._cleanupHooks.splice(i,1)}},t.prototype.drain=function(){var t=this._cleanupHooks.slice();t.sort((function(t,e){return e.order-t.order}));for(var e=0;e<t.length;++e){var n=t[e];"number"==typeof n.fn?n.envObject.makeDynCall_vp(n.fn)(n.arg):n.fn(n.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(n),1)}},t.prototype.dispose=function(){this._cleanupHooks.length=0,this._cleanupHookCounter=0},t}(),Q=function(){function t(){this.refHandle=(new y).port1,this.count=0}return t.prototype.increase=function(){0===this.count&&this.refHandle.ref(),this.count++},t.prototype.decrease=function(){0!==this.count&&(1===this.count&&this.refHandle.unref(),this.count--)},t}(),G=function(){function t(){var t=this;this._isStopping=!1,this._canCallIntoJs=!0,this.envStore=new q,this.scopeStore=new x,this.refStore=new q,this.deferredStore=new q,this.handleStore=new m,this.cbinfoStack=new n,this.feature={supportReflect:p,supportFinalizer:c,supportWeakSymbol:f,supportBigInt:l,supportNewFunction:o,canSetFunctionName:a,setImmediate:_,Buffer:v,MessageChannel:y},this.cleanupQueue=new J,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new Q,process.once("beforeExit",(function(){t.destroy()})))}return t.prototype.getRuntimeVersions=function(){return{version:g,NAPI_VERSION:b,NAPI_VERSION_EXPERIMENTAL:S,NODE_API_DEFAULT_MODULE_API_VERSION:8}},t.prototype.createNotSupportWeakRefError=function(t,e){return new B(t,e)},t.prototype.createNotSupportBigIntError=function(t,e){return new R(t,e)},t.prototype.createNotSupportBufferError=function(t,e){return new A(t,e)},t.prototype.createReference=function(t,e,n,i,r,o,s){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=0),W.create(t,e,n,i,r,o,s)},t.prototype.createDeferred=function(t){return U.create(this,t)},t.prototype.createEnv=function(t,e,n,i,r,o){return j(this,t,e,n,i,r,o)},t.prototype.getCurrentScope=function(){return this.scopeStore.currentScope},t.prototype.addToCurrentScope=function(t){return this.scopeStore.currentScope.add(t)},t.prototype.openScope=function(t){return this.scopeStore.openScope(t)},t.prototype.closeScope=function(t,e){this.scopeStore.closeScope(t)},t.prototype.ensureHandle=function(t){switch(t){case void 0:return m.UNDEFINED;case null:return m.NULL;case!0:return m.TRUE;case!1:return m.FALSE;case s:return m.GLOBAL}return this.addToCurrentScope(t)},t.prototype.addCleanupHook=function(t,e,n){this.cleanupQueue.add(t,e,n)},t.prototype.removeCleanupHook=function(t,e,n){this.cleanupQueue.remove(t,e,n)},t.prototype.runCleanup=function(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()},t.prototype.increaseWaitingRequestCounter=function(){var t;null===(t=this.refCounter)||void 0===t||t.increase()},t.prototype.decreaseWaitingRequestCounter=function(){var t;null===(t=this.refCounter)||void 0===t||t.decrease()},t.prototype.setCanCallIntoJs=function(t){this._canCallIntoJs=t},t.prototype.setStopping=function(t){this._isStopping=t},t.prototype.canCallIntoJs=function(){return this._canCallIntoJs&&!this._isStopping},t.prototype.destroy=function(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()},t}();function X(){return new G}t.CallbackInfo=e,t.CallbackInfoStack=n,t.ConstHandle=E,t.Context=G,t.Deferred=U,t.EmnapiError=H,t.Env=D,t.Finalizer=z,t.Handle=w,t.HandleScope=C,t.HandleStore=m,t.NAPI_VERSION=b,t.NAPI_VERSION_EXPERIMENTAL=S,t.NODE_API_DEFAULT_MODULE_API_VERSION=8,t.NodeEnv=F,t.NotSupportBigIntError=R,t.NotSupportBufferError=A,t.NotSupportWeakRefError=B,t.Persistent=T,t.RefBase=O,t.RefTracker=I,t.Reference=W,t.ScopeStore=x,t.Store=q,t.TryCatch=u,t.createContext=X,t.getDefaultContext=function(){return P||(P=X()),P},t.isReferenceType=h,t.version=g,Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).emnapi={})}(this,(function(t){var e=function(){function t(t,e,n,i,r){this.parent=t,this.thiz=e,this.data=n,this.args=i,this.fn=r}return t.prototype.getNewTarget=function(t){var e=this.thiz;return null==e||null==e.constructor?0:e instanceof this.fn?t.ensureHandleId(e.constructor):0},t}(),n=function(){function t(){this.current=null}return t.prototype.pop=function(){var t=this.current;null!==t&&(this.current=t.parent)},t.prototype.push=function(t,n,i,r){var o=new e(this.current,t,n,i,r);return this.current=o,o},t.prototype.dispose=function(){this.current=null},t}(),i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){var t;try{t=new Function}catch(t){return!1}return"function"==typeof t}(),s=function(){if("undefined"!=typeof globalThis)return globalThis;var t=function(){return this}();if(!t&&o)try{t=new Function("return this")()}catch(t){}if(!t){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return t}(),u=function(){function t(){this._exception=void 0,this._caught=!1}return t.prototype.hasCaught=function(){return this._caught},t.prototype.exception=function(){return this._exception},t.prototype.setError=function(t){this._caught=!0,this._exception=t},t.prototype.reset=function(){this._caught=!1,this._exception=void 0},t.prototype.extractException=function(){var t=this._exception;return this.reset(),t},t}(),a=function(){var t;try{return Boolean(null===(t=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===t?void 0:t.configurable)}catch(t){return!1}}(),p="object"==typeof Reflect,c="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,f=function(){try{var t=Symbol();new WeakRef(t),(new WeakMap).set(t,void 0)}catch(t){return!1}return!0}(),l="undefined"!=typeof BigInt;function h(t){return"object"==typeof t&&null!==t||"function"==typeof t}var d=function(){return"undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0}(),y="function"==typeof MessageChannel?MessageChannel:function(){try{return d("worker_threads").MessageChannel}catch(t){}}(),_="function"==typeof setImmediate?setImmediate:function(t){if("function"!=typeof t)throw new TypeError('The "callback" argument must be of type function');if(y){var e=new y;e.port1.onmessage=function(){e.port1.onmessage=null,e=void 0,t()},e.port2.postMessage(null)}else setTimeout(t,0)},v="function"==typeof Buffer?Buffer:function(){try{return d("buffer").Buffer}catch(t){}}(),g="0.40.0",b=9,S=2147483647,w=function(){function t(t,e){this.id=t,this.value=e}return t.prototype.data=function(t){return t.getObjectBinding(this.value).data},t.prototype.isNumber=function(){return"number"==typeof this.value},t.prototype.isBigInt=function(){return"bigint"==typeof this.value},t.prototype.isString=function(){return"string"==typeof this.value},t.prototype.isFunction=function(){return"function"==typeof this.value},t.prototype.isExternal=function(){return h(this.value)&&null===Object.getPrototypeOf(this.value)},t.prototype.isObject=function(){return"object"==typeof this.value&&null!==this.value},t.prototype.isArray=function(){return Array.isArray(this.value)},t.prototype.isArrayBuffer=function(){return this.value instanceof ArrayBuffer},t.prototype.isTypedArray=function(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)},t.prototype.isBuffer=function(){return"function"==typeof v&&v.isBuffer(this.value)},t.prototype.isDataView=function(){return this.value instanceof DataView},t.prototype.isDate=function(){return this.value instanceof Date},t.prototype.isPromise=function(){return this.value instanceof Promise},t.prototype.isBoolean=function(){return"boolean"==typeof this.value},t.prototype.isUndefined=function(){return void 0===this.value},t.prototype.isSymbol=function(){return"symbol"==typeof this.value},t.prototype.isNull=function(){return null===this.value},t.prototype.dispose=function(){this.value=void 0},t}(),E=function(t){function e(e,n){return t.call(this,e,n)||this}return r(e,t),e.prototype.dispose=function(){},e}(w);function k(){Object.setPrototypeOf(this,null)}k.prototype=null;var m=function(){function t(){this._values=[void 0,t.UNDEFINED,t.NULL,t.FALSE,t.TRUE,t.GLOBAL],this._next=t.MIN_ID}return t.prototype.push=function(t){var e,n=this._next,i=this._values;return n<i.length?(e=i[n]).value=t:(e=new w(n,t),i[n]=e),this._next++,e},t.prototype.erase=function(t,e){this._next=t;for(var n=this._values,i=t;i<e;++i)n[i].dispose()},t.prototype.get=function(t){return this._values[t]},t.prototype.swap=function(t,e){var n=this._values,i=n[t];n[t]=n[e],n[t].id=Number(t),n[e]=i,i.id=Number(e)},t.prototype.dispose=function(){this._values.length=t.MIN_ID,this._next=t.MIN_ID},t.UNDEFINED=new E(1,void 0),t.NULL=new E(2,null),t.FALSE=new E(3,!1),t.TRUE=new E(4,!0),t.GLOBAL=new E(5,s),t.MIN_ID=6,t}(),C=function(){function t(t,e,n,i,r){void 0===r&&(r=i),this.handleStore=t,this.id=e,this.parent=n,this.child=null,null!==n&&(n.child=this),this.start=i,this.end=r,this._escapeCalled=!1}return t.prototype.add=function(t){var e=this.handleStore.push(t);return this.end++,e},t.prototype.addExternal=function(t,e){var n=new k,i=t.ctx.handleStore.push(n);return t.initObjectBinding(n).data=e,this.end++,i},t.prototype.dispose=function(){this.start!==this.end&&this.handleStore.erase(this.start,this.end)},t.prototype.escape=function(t){if(this._escapeCalled)return null;if(this._escapeCalled=!0,t<this.start||t>=this.end)return null;this.handleStore.swap(t,this.start);var e=this.handleStore.get(this.start);return this.start++,this.parent.end++,e},t.prototype.escapeCalled=function(){return this._escapeCalled},t}(),x=function(){function t(){this._rootScope=new C(null,0,null,1,m.MIN_ID),this.currentScope=this._rootScope}return t.prototype.get=function(t){t=Number(t);for(var e=this.currentScope;e!==this._rootScope;){if(e.id===t)return e;e=e.parent}},t.prototype.openScope=function(t){var e=this.currentScope,n=e.child;return null!==n?(n.start=n.end=e.end,n._escapeCalled=!1):n=new C(t.ctx.handleStore,e.id+1,e,e.end),this.currentScope=n,t.openHandleScopes++,n},t.prototype.closeScope=function(t){if(0!==t.openHandleScopes){var e=this.currentScope;this.currentScope=e.parent,e.dispose(),t.openHandleScopes--}},t.prototype.dispose=function(){for(var t=this.currentScope;null!==t;){t.handleStore=null,t.id=0,t.parent=null,t.start=m.MIN_ID,t.end=m.MIN_ID,t._escapeCalled=!1;var e=t.child;t.child=null,t=e}this.currentScope=null},t}(),I=function(){function t(){this._next=null,this._prev=null}return t.prototype.finalize=function(){},t.prototype.link=function(t){this._prev=t,this._next=t._next,null!==this._next&&(this._next._prev=this),t._next=this},t.prototype.unlink=function(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null},t.finalizeAll=function(t){for(;null!==t._next;)t._next.finalize()},t}(),z=function(){function t(t,e,n,i){void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),this.envObject=t,this._finalizeCallback=e,this._finalizeData=n,this._finalizeHint=i}return t.prototype.callback=function(){return this._finalizeCallback},t.prototype.data=function(){return this._finalizeData},t.prototype.hint=function(){return this._finalizeHint},t.prototype.resetFinalizer=function(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0},t.prototype.dispose=function(){this.envObject=void 0},t}(),O=function(t){function e(e,n,i,r,o,s){var u=t.call(this,e,r,o,s)||this;return u._next=null,u._prev=null,u._refcount=n,u._ownership=i,u.link(r?e.finalizing_reflist:e.reflist),u}return r(e,t),e.finalizeAll=function(t){I.finalizeAll(t)},e.prototype.link=function(t){I.prototype.link.call(this,t)},e.prototype.unlink=function(){I.prototype.unlink.call(this)},e.prototype.dispose=function(){this.unlink(),this.envObject.dequeueFinalizer(this),t.prototype.dispose.call(this)},e.prototype.data=function(){return this._finalizeData},e.prototype.ref=function(){return++this._refcount},e.prototype.unref=function(){return 0===this._refcount?0:--this._refcount},e.prototype.refCount=function(){return this._refcount},e.prototype.ownership=function(){return this._ownership},e.prototype.finalize=function(){var t,e=this._ownership,n=this._finalizeCallback,i=this._finalizeData,r=this._finalizeHint;this.resetFinalizer(),this.unlink();var o=!1;if(n){var s=Number(n);try{this.envObject.callFinalizer(s,i,r)}catch(e){o=!0,t=e}}if(0===e&&this.dispose(),o)throw t},e}(z);function N(t,e){if(!t.terminatedOrTerminating())throw e}var D=function(){function t(t,e,n,i,r){this.ctx=t,this.moduleApiVersion=e,this.makeDynCall_vppp=n,this.makeDynCall_vp=i,this.abort=r,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new u,this.refs=1,this.reflist=new I,this.finalizing_reflist=new I,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this._bindingMap=new WeakMap,this.id=0}return t.prototype.canCallIntoJs=function(){return!0},t.prototype.terminatedOrTerminating=function(){return!this.canCallIntoJs()},t.prototype.ref=function(){this.refs++},t.prototype.unref=function(){this.refs--,0===this.refs&&this.dispose()},t.prototype.ensureHandle=function(t){return this.ctx.ensureHandle(t)},t.prototype.ensureHandleId=function(t){return this.ensureHandle(t).id},t.prototype.clearLastError=function(){var t=this.lastError;return 0!==t.errorCode&&(t.errorCode=0),0!==t.engineErrorCode&&(t.engineErrorCode=0),0!==t.engineReserved&&(t.engineReserved=0),0},t.prototype.setLastError=function(t,e,n){void 0===e&&(e=0),void 0===n&&(n=0);var i=this.lastError;return i.errorCode!==t&&(i.errorCode=t),i.engineErrorCode!==e&&(i.engineErrorCode=e),i.engineReserved!==n&&(i.engineReserved=n),t},t.prototype.getReturnStatus=function(){return this.tryCatch.hasCaught()?this.setLastError(10):0},t.prototype.callIntoModule=function(t,e){void 0===e&&(e=N);var n=this.openHandleScopes;this.clearLastError();var i=t(this);(n!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught())&&e(this,this.tryCatch.extractException());return i},t.prototype.callFinalizer=function(t,e,n){var i=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callIntoModule((function(){i(r,e,n)}))}finally{this.ctx.closeScope(this,o)}},t.prototype.enqueueFinalizer=function(t){-1===this.pendingFinalizers.indexOf(t)&&this.pendingFinalizers.push(t)},t.prototype.dequeueFinalizer=function(t){var e=this.pendingFinalizers.indexOf(t);-1!==e&&this.pendingFinalizers.splice(e,1)},t.prototype.deleteMe=function(){O.finalizeAll(this.finalizing_reflist),O.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)},t.prototype.dispose=function(){0!==this.id&&(this.deleteMe(),this.id=0)},t.prototype.initObjectBinding=function(t){var e={wrapped:0,tag:null,data:0};return this._bindingMap.set(t,e),e},t.prototype.getObjectBinding=function(t){return this._bindingMap.has(t)?this._bindingMap.get(t):this.initObjectBinding(t)},t.prototype.setInstanceData=function(t,e,n){this.instanceData&&this.instanceData.dispose(),this.instanceData=new O(this,0,0,e,t,n)},t.prototype.getInstanceData=function(){return this.instanceData?this.instanceData.data():0},t}(),F=function(t){function e(e,n,i,r,o,s,u){var a=t.call(this,e,i,r,o,s)||this;return a.filename=n,a.nodeBinding=u,a.destructing=!1,a.finalizationScheduled=!1,a}return r(e,t),e.prototype.deleteMe=function(){this.destructing=!0,this.drainFinalizerQueue(),t.prototype.deleteMe.call(this)},e.prototype.canCallIntoJs=function(){return this.ctx.canCallIntoJs()},e.prototype.triggerFatalException=function(t){if(this.nodeBinding)this.nodeBinding.napi.fatalException(t);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw t;process._fatalException(t)||(console.error(t),process.exit(1))}},e.prototype.callbackIntoModule=function(t,e){return this.callIntoModule(e,(function(e,n){if(!e.terminatedOrTerminating()){var i="object"==typeof process&&null!==process;if(!(!!i&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy")))&&!t){if(!i||"function"!=typeof process.emitWarning)throw n;process.emitWarning("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")}e.triggerFatalException(n)}}))},e.prototype.callFinalizer=function(t,e,n){this.callFinalizerInternal(1,t,e,n)},e.prototype.callFinalizerInternal=function(t,e,n,i){var r=this.makeDynCall_vppp(e),o=this.id,s=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(t),(function(){r(o,n,i)}))}finally{this.ctx.closeScope(this,s)}},e.prototype.enqueueFinalizer=function(e){var n=this;t.prototype.enqueueFinalizer.call(this,e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),_((function(){n.finalizationScheduled=!1,n.unref(),n.drainFinalizerQueue()})))},e.prototype.drainFinalizerQueue=function(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}},e}(D);function H(t,e,n,i,r,o,s){(n="number"!=typeof n?8:n)<8?n=8:n>b&&n!==S&&function(t,e){var n="".concat(t," requires Node-API version ").concat(e,", but this version of Node.js only supports version ").concat(b," add-ons.");throw new Error(n)}(e,n);var u=new F(t,e,n,i,r,o,s);return t.envStore.add(u),t.addCleanupHook(u,(function(){u.unref()}),0),u}var j=function(t){function e(n){var i=this.constructor,r=t.call(this,n)||this,o=i,s=o.prototype;if(!(r instanceof e)){var u=Object.setPrototypeOf;"function"==typeof u?u.call(Object,r,s):r.__proto__=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,o)}return r}return r(e,t),e}(Error);Object.defineProperty(j.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});var B=function(t){function e(e,n){return t.call(this,"".concat(e,': The current runtime does not support "FinalizationRegistry" and "WeakRef".').concat(n?" ".concat(n):""))||this}return r(e,t),e}(j);Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});var R=function(t){function e(e,n){return t.call(this,"".concat(e,': The current runtime does not support "BigInt".').concat(n?" ".concat(n):""))||this}return r(e,t),e}(j);Object.defineProperty(R.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBigIntError"});var A=function(t){function e(e,n){return t.call(this,"".concat(e,': The current runtime does not support "Buffer". Consider using buffer polyfill to make sure `globalThis.Buffer` is defined.').concat(n?" ".concat(n):""))||this}return r(e,t),e}(j);Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});var M=function(){function t(t){this._value=t}return t.prototype.deref=function(){return this._value},t.prototype.dispose=function(){this._value=void 0},t}(),T=function(){function t(t){this._ref=new M(t)}return t.prototype.setWeak=function(e,n){if(c&&void 0!==this._ref&&!(this._ref instanceof WeakRef)){var i=this._ref.deref();try{t._registry.register(i,this,this);var r=new WeakRef(i);this._ref.dispose(),this._ref=r,this._param=e,this._callback=n}catch(t){if("symbol"!=typeof i)throw t}}},t.prototype.clearWeak=function(){if(c&&void 0!==this._ref&&this._ref instanceof WeakRef){try{t._registry.unregister(this)}catch(t){}this._param=void 0,this._callback=void 0;var e=this._ref.deref();this._ref=void 0===e?e:new M(e)}},t.prototype.reset=function(){if(c)try{t._registry.unregister(this)}catch(t){}this._param=void 0,this._callback=void 0,this._ref instanceof M&&this._ref.dispose(),this._ref=void 0},t.prototype.isEmpty=function(){return void 0===this._ref},t.prototype.deref=function(){if(void 0!==this._ref)return this._ref.deref()},t._registry=c?new FinalizationRegistry((function(t){t._ref=void 0;var e=t._callback,n=t._param;t._callback=void 0,t._param=void 0,"function"==typeof e&&e(n)})):void 0,t}();function L(t){t.persistent.reset(),t.envObject.enqueueFinalizer(t)}var W,P=function(t){function e(e,n,i,r,o,s){void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=0);var u=t.call(this,e,n>>>0,i,r,o,s)||this;return u.id=0,u}return r(e,t),e.create=function(t,n,i,r,o,s,u){void 0===o&&(o=0),void 0===s&&(s=0),void 0===u&&(u=0);var a,p=t.ctx.handleStore.get(n),c=new e(t,i,r,o,s,u);return t.ctx.refStore.add(c),c.canBeWeak=(a=p).isObject()||a.isFunction()||a.isSymbol(),c.persistent=new T(p.value),0===i&&c._setWeak(),c},e.prototype.ref=function(){if(this.persistent.isEmpty())return 0;var e=t.prototype.ref.call(this);return 1===e&&this.canBeWeak&&this.persistent.clearWeak(),e},e.prototype.unref=function(){if(this.persistent.isEmpty())return 0;var e=this.refCount(),n=t.prototype.unref.call(this);return 1===e&&0===n&&this._setWeak(),n},e.prototype.get=function(){if(this.persistent.isEmpty())return 0;var t=this.persistent.deref();return this.envObject.ensureHandle(t).id},e.prototype._setWeak=function(){this.canBeWeak?this.persistent.setWeak(this,L):this.persistent.reset()},e.prototype.finalize=function(){this.persistent.reset(),t.prototype.finalize.call(this)},e.prototype.dispose=function(){0!==this.id&&(this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),t.prototype.dispose.call(this),this.id=0)},e}(O),U=function(){function t(t,e){this.id=0,this.ctx=t,this.value=e}return t.create=function(e,n){var i=new t(e,n);return e.deferredStore.add(i),i},t.prototype.resolve=function(t){this.value.resolve(t),this.dispose()},t.prototype.reject=function(t){this.value.reject(t),this.dispose()},t.prototype.dispose=function(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null},t}(),q=function(){function t(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}return t.prototype.add=function(t){var e;if(this._freeList.length)e=this._freeList.shift();else{e=this._size,this._size++;var n=this._values.length;e>=n&&(this._values.length=n+(n>>1)+16)}t.id=e,this._values[e]=t},t.prototype.get=function(t){return this._values[t]},t.prototype.has=function(t){return void 0!==this._values[t]},t.prototype.remove=function(t){var e=this._values[t];e&&(e.id=0,this._values[t]=void 0,this._freeList.push(Number(t)))},t.prototype.dispose=function(){for(var t=1;t<this._size;++t){var e=this._values[t];null==e||e.dispose()}this._values=[void 0],this._size=1,this._freeList=[]},t}(),V=function(){return function(t,e,n,i){this.envObject=t,this.fn=e,this.arg=n,this.order=i}}(),J=function(){function t(){this._cleanupHooks=[],this._cleanupHookCounter=0}return t.prototype.empty=function(){return 0===this._cleanupHooks.length},t.prototype.add=function(t,e,n){if(this._cleanupHooks.filter((function(i){return i.envObject===t&&i.fn===e&&i.arg===n})).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new V(t,e,n,this._cleanupHookCounter++))},t.prototype.remove=function(t,e,n){for(var i=0;i<this._cleanupHooks.length;++i){var r=this._cleanupHooks[i];if(r.envObject===t&&r.fn===e&&r.arg===n)return void this._cleanupHooks.splice(i,1)}},t.prototype.drain=function(){var t=this._cleanupHooks.slice();t.sort((function(t,e){return e.order-t.order}));for(var e=0;e<t.length;++e){var n=t[e];"number"==typeof n.fn?n.envObject.makeDynCall_vp(n.fn)(n.arg):n.fn(n.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(n),1)}},t.prototype.dispose=function(){this._cleanupHooks.length=0,this._cleanupHookCounter=0},t}(),Q=function(){function t(){this.refHandle=(new y).port1,this.count=0}return t.prototype.increase=function(){0===this.count&&this.refHandle.ref(),this.count++},t.prototype.decrease=function(){0!==this.count&&(1===this.count&&this.refHandle.unref(),this.count--)},t}(),G=function(){function t(){var t=this;this._isStopping=!1,this._canCallIntoJs=!0,this.envStore=new q,this.scopeStore=new x,this.refStore=new q,this.deferredStore=new q,this.handleStore=new m,this.cbinfoStack=new n,this.feature={supportReflect:p,supportFinalizer:c,supportWeakSymbol:f,supportBigInt:l,supportNewFunction:o,canSetFunctionName:a,setImmediate:_,Buffer:v,MessageChannel:y},this.cleanupQueue=new J,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new Q,process.once("beforeExit",(function(){t.destroy()})))}return t.prototype.getRuntimeVersions=function(){return{version:g,NAPI_VERSION:b,NAPI_VERSION_EXPERIMENTAL:S,NODE_API_DEFAULT_MODULE_API_VERSION:8}},t.prototype.createNotSupportWeakRefError=function(t,e){return new B(t,e)},t.prototype.createNotSupportBigIntError=function(t,e){return new R(t,e)},t.prototype.createNotSupportBufferError=function(t,e){return new A(t,e)},t.prototype.createReference=function(t,e,n,i,r,o,s){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=0),P.create(t,e,n,i,r,o,s)},t.prototype.createDeferred=function(t){return U.create(this,t)},t.prototype.createEnv=function(t,e,n,i,r,o){return H(this,t,e,n,i,r,o)},t.prototype.getCurrentScope=function(){return this.scopeStore.currentScope},t.prototype.addToCurrentScope=function(t){return this.scopeStore.currentScope.add(t)},t.prototype.openScope=function(t){return this.scopeStore.openScope(t)},t.prototype.closeScope=function(t,e){this.scopeStore.closeScope(t)},t.prototype.ensureHandle=function(t){switch(t){case void 0:return m.UNDEFINED;case null:return m.NULL;case!0:return m.TRUE;case!1:return m.FALSE;case s:return m.GLOBAL}return this.addToCurrentScope(t)},t.prototype.addCleanupHook=function(t,e,n){this.cleanupQueue.add(t,e,n)},t.prototype.removeCleanupHook=function(t,e,n){this.cleanupQueue.remove(t,e,n)},t.prototype.runCleanup=function(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()},t.prototype.increaseWaitingRequestCounter=function(){var t;null===(t=this.refCounter)||void 0===t||t.increase()},t.prototype.decreaseWaitingRequestCounter=function(){var t;null===(t=this.refCounter)||void 0===t||t.decrease()},t.prototype.setCanCallIntoJs=function(t){this._canCallIntoJs=t},t.prototype.setStopping=function(t){this._isStopping=t},t.prototype.canCallIntoJs=function(){return this._canCallIntoJs&&!this._isStopping},t.prototype.destroy=function(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()},t}();function X(){return new G}t.CallbackInfo=e,t.CallbackInfoStack=n,t.ConstHandle=E,t.Context=G,t.Deferred=U,t.EmnapiError=j,t.Env=D,t.Finalizer=z,t.Handle=w,t.HandleScope=C,t.HandleStore=m,t.NAPI_VERSION=b,t.NAPI_VERSION_EXPERIMENTAL=S,t.NODE_API_DEFAULT_MODULE_API_VERSION=8,t.NodeEnv=F,t.NotSupportBigIntError=R,t.NotSupportBufferError=A,t.NotSupportWeakRefError=B,t.Persistent=T,t.RefBase=O,t.RefTracker=I,t.Reference=P,t.ScopeStore=x,t.Store=q,t.TryCatch=u,t.createContext=X,t.getDefaultContext=function(){return W||(W=X()),W},t.isReferenceType=h,t.version=g}));
@@ -1 +1 @@
1
- class e{constructor(e,t,i,n,s){this.parent=e,this.thiz=t,this.data=i,this.args=n,this.fn=s}getNewTarget(e){const t=this.thiz;return null==t||null==t.constructor?0:t instanceof this.fn?e.ensureHandleId(t.constructor):0}}class t{constructor(){this.current=null}pop(){const e=this.current;null!==e&&(this.current=e.parent)}push(t,i,n,s){const r=new e(this.current,t,i,n,s);return this.current=r,r}dispose(){this.current=null}}const i=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),n=function(){if("undefined"!=typeof globalThis)return globalThis;let e=function(){return this}();if(!e&&i)try{e=new Function("return this")()}catch(e){}if(!e){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return e}();class s{constructor(){this._exception=void 0,this._caught=!1}hasCaught(){return this._caught}exception(){return this._exception}setError(e){this._caught=!0,this._exception=e}reset(){this._caught=!1,this._exception=void 0}extractException(){const e=this._exception;return this.reset(),e}}const r=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),o="object"==typeof Reflect,a="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,l=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),c="undefined"!=typeof BigInt;function u(e){return"object"==typeof e&&null!==e||"function"==typeof e}const h=function(){let e;return e="undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0,e}(),p="function"==typeof MessageChannel?MessageChannel:function(){try{return h("worker_threads").MessageChannel}catch(e){}}(),d="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(p){let t=new p;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},f="function"==typeof Buffer?Buffer:function(){try{return h("buffer").Buffer}catch(e){}}(),_="0.39.0",v=9,g=2147483647,y=8;class b{constructor(e,t){this.id=e,this.value=t}data(e){return e.getObjectBinding(this.value).data}isNumber(){return"number"==typeof this.value}isBigInt(){return"bigint"==typeof this.value}isString(){return"string"==typeof this.value}isFunction(){return"function"==typeof this.value}isExternal(){return u(this.value)&&null===Object.getPrototypeOf(this.value)}isObject(){return"object"==typeof this.value&&null!==this.value}isArray(){return Array.isArray(this.value)}isArrayBuffer(){return this.value instanceof ArrayBuffer}isTypedArray(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)}isBuffer(){return"function"==typeof f&&f.isBuffer(this.value)}isDataView(){return this.value instanceof DataView}isDate(){return this.value instanceof Date}isPromise(){return this.value instanceof Promise}isBoolean(){return"boolean"==typeof this.value}isUndefined(){return void 0===this.value}isSymbol(){return"symbol"==typeof this.value}isNull(){return null===this.value}dispose(){this.value=void 0}}class S extends b{constructor(e,t){super(e,t)}dispose(){}}function w(){Object.setPrototypeOf(this,null)}w.prototype=null;class k{constructor(){this._values=[void 0,k.UNDEFINED,k.NULL,k.FALSE,k.TRUE,k.GLOBAL],this._next=k.MIN_ID}push(e){let t;const i=this._next,n=this._values;return i<n.length?(t=n[i],t.value=e):(t=new b(i,e),n[i]=t),this._next++,t}erase(e,t){this._next=e;const i=this._values;for(let n=e;n<t;++n)i[n].dispose()}get(e){return this._values[e]}swap(e,t){const i=this._values,n=i[e];i[e]=i[t],i[e].id=Number(e),i[t]=n,n.id=Number(t)}dispose(){this._values.length=k.MIN_ID,this._next=k.MIN_ID}}k.UNDEFINED=new S(1,void 0),k.NULL=new S(2,null),k.FALSE=new S(3,!1),k.TRUE=new S(4,!0),k.GLOBAL=new S(5,n),k.MIN_ID=6;class x{constructor(e,t,i,n,s=n){this.handleStore=e,this.id=t,this.parent=i,this.child=null,null!==i&&(i.child=this),this.start=n,this.end=s,this._escapeCalled=!1}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e,t){const i=new w,n=e.ctx.handleStore.push(i);return e.initObjectBinding(i).data=t,this.end++,n}dispose(){this.start!==this.end&&this.handleStore.erase(this.start,this.end)}escape(e){if(this._escapeCalled)return null;if(this._escapeCalled=!0,e<this.start||e>=this.end)return null;this.handleStore.swap(e,this.start);const t=this.handleStore.get(this.start);return this.start++,this.parent.end++,t}escapeCalled(){return this._escapeCalled}}class m{constructor(){this._rootScope=new x(null,0,null,1,k.MIN_ID),this.currentScope=this._rootScope}get(e){e=Number(e);let t=this.currentScope;for(;t!==this._rootScope;){if(t.id===e)return t;t=t.parent}}openScope(e){const t=this.currentScope;let i=t.child;return null!==i?(i.start=i.end=t.end,i._escapeCalled=!1):i=new x(e.ctx.handleStore,t.id+1,t,t.end),this.currentScope=i,e.openHandleScopes++,i}closeScope(e){if(0===e.openHandleScopes)return;const t=this.currentScope;this.currentScope=t.parent,t.dispose(),e.openHandleScopes--}dispose(){let e=this.currentScope;for(;null!==e;){e.handleStore=null,e.id=0,e.parent=null,e.start=k.MIN_ID,e.end=k.MIN_ID,e._escapeCalled=!1;const t=e.child;e.child=null,e=t}this.currentScope=null}}class C{constructor(){this._next=null,this._prev=null}finalize(){}link(e){this._prev=e,this._next=e._next,null!==this._next&&(this._next._prev=this),e._next=this}unlink(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null}static finalizeAll(e){for(;null!==e._next;)e._next.finalize()}}class z{constructor(e,t=0,i=0,n=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=i,this._finalizeHint=n}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}dispose(){this.envObject=void 0}}class E extends z{constructor(e,t,i,n,s,r){super(e,n,s,r),this._next=null,this._prev=null,this._refcount=t,this._ownership=i,this.link(n?e.finalizing_reflist:e.reflist)}static finalizeAll(e){C.finalizeAll(e)}link(e){C.prototype.link.call(this,e)}unlink(){C.prototype.unlink.call(this)}dispose(){this.unlink(),this.envObject.dequeueFinalizer(this),super.dispose()}data(){return this._finalizeData}ref(){return++this._refcount}unref(){return 0===this._refcount?0:--this._refcount}refCount(){return this._refcount}ownership(){return this._ownership}finalize(){const e=this._ownership,t=this._finalizeCallback,i=this._finalizeData,n=this._finalizeHint;let s;this.resetFinalizer(),this.unlink();let r=!1;if(t){const e=Number(t);try{this.envObject.callFinalizer(e,i,n)}catch(e){r=!0,s=e}}if(0===e&&this.dispose(),r)throw s}}function I(e,t){if(!e.terminatedOrTerminating())throw t}class O{constructor(e,t,i,n,r){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=i,this.makeDynCall_vp=n,this.abort=r,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new s,this.refs=1,this.reflist=new C,this.finalizing_reflist=new C,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this._bindingMap=new WeakMap,this.id=0}canCallIntoJs(){return!0}terminatedOrTerminating(){return!this.canCallIntoJs()}ref(){this.refs++}unref(){this.refs--,0===this.refs&&this.dispose()}ensureHandle(e){return this.ctx.ensureHandle(e)}ensureHandleId(e){return this.ensureHandle(e).id}clearLastError(){const e=this.lastError;return 0!==e.errorCode&&(e.errorCode=0),0!==e.engineErrorCode&&(e.engineErrorCode=0),0!==e.engineReserved&&(e.engineReserved=0),0}setLastError(e,t=0,i=0){const n=this.lastError;return n.errorCode!==e&&(n.errorCode=e),n.engineErrorCode!==t&&(n.engineErrorCode=t),n.engineReserved!==i&&(n.engineReserved=i),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=I){const i=this.openHandleScopes;this.clearLastError();const n=e(this);if(i!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return n}callFinalizer(e,t,i){const n=this.makeDynCall_vppp(e),s=this.id,r=this.ctx.openScope(this);try{this.callIntoModule((()=>{n(s,t,i)}))}finally{this.ctx.closeScope(this,r)}}enqueueFinalizer(e){-1===this.pendingFinalizers.indexOf(e)&&this.pendingFinalizers.push(e)}dequeueFinalizer(e){const t=this.pendingFinalizers.indexOf(e);-1!==t&&this.pendingFinalizers.splice(t,1)}deleteMe(){E.finalizeAll(this.finalizing_reflist),E.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)}dispose(){0!==this.id&&(this.deleteMe(),this.id=0)}initObjectBinding(e){const t={wrapped:0,tag:null,data:0};return this._bindingMap.set(e,t),t}getObjectBinding(e){return this._bindingMap.has(e)?this._bindingMap.get(e):this.initObjectBinding(e)}setInstanceData(e,t,i){this.instanceData&&this.instanceData.dispose(),this.instanceData=new E(this,0,0,t,e,i)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class D extends O{constructor(e,t,i,n,s,r,o){super(e,i,n,s,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return this.ctx.canCallIntoJs()}triggerFatalException(e){if(this.nodeBinding)this.nodeBinding.napi.fatalException(e);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw e;process._fatalException(e)||(console.error(e),process.exit(1))}}callbackIntoModule(e,t){return this.callIntoModule(t,((t,i)=>{if(t.terminatedOrTerminating())return;const n="object"==typeof process&&null!==process;if(!(!!n&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy")))&&!e){if(!n||"function"!=typeof process.emitWarning)throw i;process.emitWarning("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")}t.triggerFatalException(i)}))}callFinalizer(e,t,i){this.callFinalizerInternal(1,e,t,i)}callFinalizerInternal(e,t,i,n){const s=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),(()=>{s(r,i,n)}))}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),d((()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()})))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function F(e,t,i,n,s,r,o){(i="number"!=typeof i?8:i)<8?i=8:i>v&&i!==g&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version ${v} add-ons.`)}(t,i);const a=new D(e,t,i,n,s,r,o);return e.envStore.add(a),e.addCleanupHook(a,(()=>{a.unref()}),0),a}class N extends Error{constructor(e){super(e);const t=new.target,i=t.prototype;if(!(this instanceof N)){const e=Object.setPrototypeOf;"function"==typeof e?e.call(Object,this,i):this.__proto__=i,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}}}Object.defineProperty(N.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});class B extends N{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class H extends N{constructor(e,t){super(`${e}: The current runtime does not support "BigInt".${t?` ${t}`:""}`)}}Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBigIntError"});class j extends N{constructor(e,t){super(`${e}: The current runtime does not support "Buffer". Consider using buffer polyfill to make sure \`globalThis.Buffer\` is defined.${t?` ${t}`:""}`)}}Object.defineProperty(j.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class R{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class A{constructor(e){this._ref=new R(e)}setWeak(e,t){if(!a||void 0===this._ref||this._ref instanceof WeakRef)return;const i=this._ref.deref();try{A._registry.register(i,this,this);const n=new WeakRef(i);this._ref.dispose(),this._ref=n,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof i)throw e}}clearWeak(){if(a&&void 0!==this._ref&&this._ref instanceof WeakRef){try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0;const e=this._ref.deref();this._ref=void 0===e?e:new R(e)}}reset(){if(a)try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof R&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}function M(e){e.persistent.reset(),e.envObject.enqueueFinalizer(e)}A._registry=a?new FinalizationRegistry((e=>{e._ref=void 0;const t=e._callback,i=e._param;e._callback=void 0,e._param=void 0,"function"==typeof t&&t(i)})):void 0;class L extends E{constructor(e,t,i,n=0,s=0,r=0){super(e,t>>>0,i,n,s,r),this.id=0}static create(e,t,i,n,s=0,r=0,o=0){const a=e.ctx.handleStore.get(t),l=new L(e,i,n,s,r,o);var c;return e.ctx.refStore.add(l),l.canBeWeak=(c=a).isObject()||c.isFunction()||c.isSymbol(),l.persistent=new A(a.value),0===i&&l._setWeak(),l}ref(){if(this.persistent.isEmpty())return 0;const e=super.ref();return 1===e&&this.canBeWeak&&this.persistent.clearWeak(),e}unref(){if(this.persistent.isEmpty())return 0;const e=this.refCount(),t=super.unref();return 1===e&&0===t&&this._setWeak(),t}get(){if(this.persistent.isEmpty())return 0;const e=this.persistent.deref();return this.envObject.ensureHandle(e).id}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,M):this.persistent.reset()}finalize(){this.persistent.reset(),super.finalize()}dispose(){0!==this.id&&(this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.id=0)}}class W{constructor(e,t){this.id=0,this.ctx=e,this.value=t}static create(e,t){const i=new W(e,t);return e.deferredStore.add(i),i}resolve(e){this.value.resolve(e),this.dispose()}reject(e){this.value.reject(e),this.dispose()}dispose(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null}}class T{constructor(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}add(e){let t;if(this._freeList.length)t=this._freeList.shift();else{t=this._size,this._size++;const e=this._values.length;t>=e&&(this._values.length=e+(e>>1)+16)}e.id=t,this._values[t]=e}get(e){return this._values[e]}has(e){return void 0!==this._values[e]}remove(e){const t=this._values[e];t&&(t.id=0,this._values[e]=void 0,this._freeList.push(Number(e)))}dispose(){for(let e=1;e<this._size;++e){const t=this._values[e];null==t||t.dispose()}this._values=[void 0],this._size=1,this._freeList=[]}}class P{constructor(e,t,i,n){this.envObject=e,this.fn=t,this.arg=i,this.order=n}}class q{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,i){if(this._cleanupHooks.filter((n=>n.envObject===e&&n.fn===t&&n.arg===i)).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new P(e,t,i,this._cleanupHookCounter++))}remove(e,t,i){for(let n=0;n<this._cleanupHooks.length;++n){const s=this._cleanupHooks[n];if(s.envObject===e&&s.fn===t&&s.arg===i)return void this._cleanupHooks.splice(n,1)}}drain(){const e=this._cleanupHooks.slice();e.sort(((e,t)=>t.order-e.order));for(let t=0;t<e.length;++t){const i=e[t];"number"==typeof i.fn?i.envObject.makeDynCall_vp(i.fn)(i.arg):i.fn(i.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(i),1)}}dispose(){this._cleanupHooks.length=0,this._cleanupHookCounter=0}}class U{constructor(){this.refHandle=(new p).port1,this.count=0}increase(){0===this.count&&this.refHandle.ref(),this.count++}decrease(){0!==this.count&&(1===this.count&&this.refHandle.unref(),this.count--)}}class ${constructor(){this._isStopping=!1,this._canCallIntoJs=!0,this.envStore=new T,this.scopeStore=new m,this.refStore=new T,this.deferredStore=new T,this.handleStore=new k,this.cbinfoStack=new t,this.feature={supportReflect:o,supportFinalizer:a,supportWeakSymbol:l,supportBigInt:c,supportNewFunction:i,canSetFunctionName:r,setImmediate:d,Buffer:f,MessageChannel:p},this.cleanupQueue=new q,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new U,process.once("beforeExit",(()=>{this.destroy()})))}getRuntimeVersions(){return{version:_,NAPI_VERSION:v,NAPI_VERSION_EXPERIMENTAL:g,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new B(e,t)}createNotSupportBigIntError(e,t){return new H(e,t)}createNotSupportBufferError(e,t){return new j(e,t)}createReference(e,t,i,n,s=0,r=0,o=0){return L.create(e,t,i,n,s,r,o)}createDeferred(e){return W.create(this,e)}createEnv(e,t,i,n,s,r){return F(this,e,t,i,n,s,r)}getCurrentScope(){return this.scopeStore.currentScope}addToCurrentScope(e){return this.scopeStore.currentScope.add(e)}openScope(e){return this.scopeStore.openScope(e)}closeScope(e,t){this.scopeStore.closeScope(e)}ensureHandle(e){switch(e){case void 0:return k.UNDEFINED;case null:return k.NULL;case!0:return k.TRUE;case!1:return k.FALSE;case n:return k.GLOBAL}return this.addToCurrentScope(e)}addCleanupHook(e,t,i){this.cleanupQueue.add(e,t,i)}removeCleanupHook(e,t,i){this.cleanupQueue.remove(e,t,i)}runCleanup(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()}increaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.increase()}decreaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.decrease()}setCanCallIntoJs(e){this._canCallIntoJs=e}setStopping(e){this._isStopping=e}canCallIntoJs(){return this._canCallIntoJs&&!this._isStopping}destroy(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()}}let J;function V(){return new $}function Q(){return J||(J=V()),J}export{e as CallbackInfo,t as CallbackInfoStack,S as ConstHandle,$ as Context,W as Deferred,N as EmnapiError,O as Env,z as Finalizer,b as Handle,x as HandleScope,k as HandleStore,v as NAPI_VERSION,g as NAPI_VERSION_EXPERIMENTAL,y as NODE_API_DEFAULT_MODULE_API_VERSION,D as NodeEnv,H as NotSupportBigIntError,j as NotSupportBufferError,B as NotSupportWeakRefError,A as Persistent,E as RefBase,C as RefTracker,L as Reference,m as ScopeStore,T as Store,s as TryCatch,V as createContext,Q as getDefaultContext,u as isReferenceType,_ as version};
1
+ class e{constructor(e,t,i,n,s){this.parent=e,this.thiz=t,this.data=i,this.args=n,this.fn=s}getNewTarget(e){const t=this.thiz;return null==t||null==t.constructor?0:t instanceof this.fn?e.ensureHandleId(t.constructor):0}}class t{constructor(){this.current=null}pop(){const e=this.current;null!==e&&(this.current=e.parent)}push(t,i,n,s){const r=new e(this.current,t,i,n,s);return this.current=r,r}dispose(){this.current=null}}const i=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),n=function(){if("undefined"!=typeof globalThis)return globalThis;let e=function(){return this}();if(!e&&i)try{e=new Function("return this")()}catch(e){}if(!e){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return e}();class s{constructor(){this._exception=void 0,this._caught=!1}hasCaught(){return this._caught}exception(){return this._exception}setError(e){this._caught=!0,this._exception=e}reset(){this._caught=!1,this._exception=void 0}extractException(){const e=this._exception;return this.reset(),e}}const r=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),o="object"==typeof Reflect,a="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,l=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),c="undefined"!=typeof BigInt;function u(e){return"object"==typeof e&&null!==e||"function"==typeof e}const h=function(){let e;return e="undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0,e}(),p="function"==typeof MessageChannel?MessageChannel:function(){try{return h("worker_threads").MessageChannel}catch(e){}}(),d="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(p){let t=new p;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},f="function"==typeof Buffer?Buffer:function(){try{return h("buffer").Buffer}catch(e){}}(),_="0.40.0",v=9,g=2147483647,y=8;class b{constructor(e,t){this.id=e,this.value=t}data(e){return e.getObjectBinding(this.value).data}isNumber(){return"number"==typeof this.value}isBigInt(){return"bigint"==typeof this.value}isString(){return"string"==typeof this.value}isFunction(){return"function"==typeof this.value}isExternal(){return u(this.value)&&null===Object.getPrototypeOf(this.value)}isObject(){return"object"==typeof this.value&&null!==this.value}isArray(){return Array.isArray(this.value)}isArrayBuffer(){return this.value instanceof ArrayBuffer}isTypedArray(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)}isBuffer(){return"function"==typeof f&&f.isBuffer(this.value)}isDataView(){return this.value instanceof DataView}isDate(){return this.value instanceof Date}isPromise(){return this.value instanceof Promise}isBoolean(){return"boolean"==typeof this.value}isUndefined(){return void 0===this.value}isSymbol(){return"symbol"==typeof this.value}isNull(){return null===this.value}dispose(){this.value=void 0}}class S extends b{constructor(e,t){super(e,t)}dispose(){}}function w(){Object.setPrototypeOf(this,null)}w.prototype=null;class k{constructor(){this._values=[void 0,k.UNDEFINED,k.NULL,k.FALSE,k.TRUE,k.GLOBAL],this._next=k.MIN_ID}push(e){let t;const i=this._next,n=this._values;return i<n.length?(t=n[i],t.value=e):(t=new b(i,e),n[i]=t),this._next++,t}erase(e,t){this._next=e;const i=this._values;for(let n=e;n<t;++n)i[n].dispose()}get(e){return this._values[e]}swap(e,t){const i=this._values,n=i[e];i[e]=i[t],i[e].id=Number(e),i[t]=n,n.id=Number(t)}dispose(){this._values.length=k.MIN_ID,this._next=k.MIN_ID}}k.UNDEFINED=new S(1,void 0),k.NULL=new S(2,null),k.FALSE=new S(3,!1),k.TRUE=new S(4,!0),k.GLOBAL=new S(5,n),k.MIN_ID=6;class x{constructor(e,t,i,n,s=n){this.handleStore=e,this.id=t,this.parent=i,this.child=null,null!==i&&(i.child=this),this.start=n,this.end=s,this._escapeCalled=!1}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e,t){const i=new w,n=e.ctx.handleStore.push(i);return e.initObjectBinding(i).data=t,this.end++,n}dispose(){this.start!==this.end&&this.handleStore.erase(this.start,this.end)}escape(e){if(this._escapeCalled)return null;if(this._escapeCalled=!0,e<this.start||e>=this.end)return null;this.handleStore.swap(e,this.start);const t=this.handleStore.get(this.start);return this.start++,this.parent.end++,t}escapeCalled(){return this._escapeCalled}}class m{constructor(){this._rootScope=new x(null,0,null,1,k.MIN_ID),this.currentScope=this._rootScope}get(e){e=Number(e);let t=this.currentScope;for(;t!==this._rootScope;){if(t.id===e)return t;t=t.parent}}openScope(e){const t=this.currentScope;let i=t.child;return null!==i?(i.start=i.end=t.end,i._escapeCalled=!1):i=new x(e.ctx.handleStore,t.id+1,t,t.end),this.currentScope=i,e.openHandleScopes++,i}closeScope(e){if(0===e.openHandleScopes)return;const t=this.currentScope;this.currentScope=t.parent,t.dispose(),e.openHandleScopes--}dispose(){let e=this.currentScope;for(;null!==e;){e.handleStore=null,e.id=0,e.parent=null,e.start=k.MIN_ID,e.end=k.MIN_ID,e._escapeCalled=!1;const t=e.child;e.child=null,e=t}this.currentScope=null}}class C{constructor(){this._next=null,this._prev=null}finalize(){}link(e){this._prev=e,this._next=e._next,null!==this._next&&(this._next._prev=this),e._next=this}unlink(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null}static finalizeAll(e){for(;null!==e._next;)e._next.finalize()}}class z{constructor(e,t=0,i=0,n=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=i,this._finalizeHint=n}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}dispose(){this.envObject=void 0}}class E extends z{static finalizeAll(e){C.finalizeAll(e)}link(e){C.prototype.link.call(this,e)}unlink(){C.prototype.unlink.call(this)}constructor(e,t,i,n,s,r){super(e,n,s,r),this._next=null,this._prev=null,this._refcount=t,this._ownership=i,this.link(n?e.finalizing_reflist:e.reflist)}dispose(){this.unlink(),this.envObject.dequeueFinalizer(this),super.dispose()}data(){return this._finalizeData}ref(){return++this._refcount}unref(){return 0===this._refcount?0:--this._refcount}refCount(){return this._refcount}ownership(){return this._ownership}finalize(){const e=this._ownership,t=this._finalizeCallback,i=this._finalizeData,n=this._finalizeHint;let s;this.resetFinalizer(),this.unlink();let r=!1;if(t){const e=Number(t);try{this.envObject.callFinalizer(e,i,n)}catch(e){r=!0,s=e}}if(0===e&&this.dispose(),r)throw s}}function I(e,t){if(!e.terminatedOrTerminating())throw t}class O{constructor(e,t,i,n,r){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=i,this.makeDynCall_vp=n,this.abort=r,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new s,this.refs=1,this.reflist=new C,this.finalizing_reflist=new C,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this._bindingMap=new WeakMap,this.id=0}canCallIntoJs(){return!0}terminatedOrTerminating(){return!this.canCallIntoJs()}ref(){this.refs++}unref(){this.refs--,0===this.refs&&this.dispose()}ensureHandle(e){return this.ctx.ensureHandle(e)}ensureHandleId(e){return this.ensureHandle(e).id}clearLastError(){const e=this.lastError;return 0!==e.errorCode&&(e.errorCode=0),0!==e.engineErrorCode&&(e.engineErrorCode=0),0!==e.engineReserved&&(e.engineReserved=0),0}setLastError(e,t=0,i=0){const n=this.lastError;return n.errorCode!==e&&(n.errorCode=e),n.engineErrorCode!==t&&(n.engineErrorCode=t),n.engineReserved!==i&&(n.engineReserved=i),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=I){const i=this.openHandleScopes;this.clearLastError();const n=e(this);if(i!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return n}callFinalizer(e,t,i){const n=this.makeDynCall_vppp(e),s=this.id,r=this.ctx.openScope(this);try{this.callIntoModule((()=>{n(s,t,i)}))}finally{this.ctx.closeScope(this,r)}}enqueueFinalizer(e){-1===this.pendingFinalizers.indexOf(e)&&this.pendingFinalizers.push(e)}dequeueFinalizer(e){const t=this.pendingFinalizers.indexOf(e);-1!==t&&this.pendingFinalizers.splice(t,1)}deleteMe(){E.finalizeAll(this.finalizing_reflist),E.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)}dispose(){0!==this.id&&(this.deleteMe(),this.id=0)}initObjectBinding(e){const t={wrapped:0,tag:null,data:0};return this._bindingMap.set(e,t),t}getObjectBinding(e){return this._bindingMap.has(e)?this._bindingMap.get(e):this.initObjectBinding(e)}setInstanceData(e,t,i){this.instanceData&&this.instanceData.dispose(),this.instanceData=new E(this,0,0,t,e,i)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class D extends O{constructor(e,t,i,n,s,r,o){super(e,i,n,s,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return this.ctx.canCallIntoJs()}triggerFatalException(e){if(this.nodeBinding)this.nodeBinding.napi.fatalException(e);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw e;process._fatalException(e)||(console.error(e),process.exit(1))}}callbackIntoModule(e,t){return this.callIntoModule(t,((t,i)=>{if(t.terminatedOrTerminating())return;const n="object"==typeof process&&null!==process;if(!(!!n&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy")))&&!e){if(!n||"function"!=typeof process.emitWarning)throw i;process.emitWarning("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")}t.triggerFatalException(i)}))}callFinalizer(e,t,i){this.callFinalizerInternal(1,e,t,i)}callFinalizerInternal(e,t,i,n){const s=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),(()=>{s(r,i,n)}))}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),d((()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()})))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function F(e,t,i,n,s,r,o){(i="number"!=typeof i?8:i)<8?i=8:i>v&&i!==g&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version ${v} add-ons.`)}(t,i);const a=new D(e,t,i,n,s,r,o);return e.envStore.add(a),e.addCleanupHook(a,(()=>{a.unref()}),0),a}class N extends Error{constructor(e){super(e);const t=new.target,i=t.prototype;if(!(this instanceof N)){const e=Object.setPrototypeOf;"function"==typeof e?e.call(Object,this,i):this.__proto__=i,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}}}Object.defineProperty(N.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});class B extends N{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class H extends N{constructor(e,t){super(`${e}: The current runtime does not support "BigInt".${t?` ${t}`:""}`)}}Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBigIntError"});class j extends N{constructor(e,t){super(`${e}: The current runtime does not support "Buffer". Consider using buffer polyfill to make sure \`globalThis.Buffer\` is defined.${t?` ${t}`:""}`)}}Object.defineProperty(j.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class R{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class A{constructor(e){this._ref=new R(e)}setWeak(e,t){if(!a||void 0===this._ref||this._ref instanceof WeakRef)return;const i=this._ref.deref();try{A._registry.register(i,this,this);const n=new WeakRef(i);this._ref.dispose(),this._ref=n,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof i)throw e}}clearWeak(){if(a&&void 0!==this._ref&&this._ref instanceof WeakRef){try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0;const e=this._ref.deref();this._ref=void 0===e?e:new R(e)}}reset(){if(a)try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof R&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}function M(e){e.persistent.reset(),e.envObject.enqueueFinalizer(e)}A._registry=a?new FinalizationRegistry((e=>{e._ref=void 0;const t=e._callback,i=e._param;e._callback=void 0,e._param=void 0,"function"==typeof t&&t(i)})):void 0;class L extends E{static create(e,t,i,n,s=0,r=0,o=0){const a=e.ctx.handleStore.get(t),l=new L(e,i,n,s,r,o);var c;return e.ctx.refStore.add(l),l.canBeWeak=(c=a).isObject()||c.isFunction()||c.isSymbol(),l.persistent=new A(a.value),0===i&&l._setWeak(),l}constructor(e,t,i,n=0,s=0,r=0){super(e,t>>>0,i,n,s,r),this.id=0}ref(){if(this.persistent.isEmpty())return 0;const e=super.ref();return 1===e&&this.canBeWeak&&this.persistent.clearWeak(),e}unref(){if(this.persistent.isEmpty())return 0;const e=this.refCount(),t=super.unref();return 1===e&&0===t&&this._setWeak(),t}get(){if(this.persistent.isEmpty())return 0;const e=this.persistent.deref();return this.envObject.ensureHandle(e).id}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,M):this.persistent.reset()}finalize(){this.persistent.reset(),super.finalize()}dispose(){0!==this.id&&(this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.id=0)}}class W{static create(e,t){const i=new W(e,t);return e.deferredStore.add(i),i}constructor(e,t){this.id=0,this.ctx=e,this.value=t}resolve(e){this.value.resolve(e),this.dispose()}reject(e){this.value.reject(e),this.dispose()}dispose(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null}}class T{constructor(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}add(e){let t;if(this._freeList.length)t=this._freeList.shift();else{t=this._size,this._size++;const e=this._values.length;t>=e&&(this._values.length=e+(e>>1)+16)}e.id=t,this._values[t]=e}get(e){return this._values[e]}has(e){return void 0!==this._values[e]}remove(e){const t=this._values[e];t&&(t.id=0,this._values[e]=void 0,this._freeList.push(Number(e)))}dispose(){for(let e=1;e<this._size;++e){const t=this._values[e];null==t||t.dispose()}this._values=[void 0],this._size=1,this._freeList=[]}}class P{constructor(e,t,i,n){this.envObject=e,this.fn=t,this.arg=i,this.order=n}}class q{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,i){if(this._cleanupHooks.filter((n=>n.envObject===e&&n.fn===t&&n.arg===i)).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new P(e,t,i,this._cleanupHookCounter++))}remove(e,t,i){for(let n=0;n<this._cleanupHooks.length;++n){const s=this._cleanupHooks[n];if(s.envObject===e&&s.fn===t&&s.arg===i)return void this._cleanupHooks.splice(n,1)}}drain(){const e=this._cleanupHooks.slice();e.sort(((e,t)=>t.order-e.order));for(let t=0;t<e.length;++t){const i=e[t];"number"==typeof i.fn?i.envObject.makeDynCall_vp(i.fn)(i.arg):i.fn(i.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(i),1)}}dispose(){this._cleanupHooks.length=0,this._cleanupHookCounter=0}}class U{constructor(){this.refHandle=(new p).port1,this.count=0}increase(){0===this.count&&this.refHandle.ref(),this.count++}decrease(){0!==this.count&&(1===this.count&&this.refHandle.unref(),this.count--)}}class ${constructor(){this._isStopping=!1,this._canCallIntoJs=!0,this.envStore=new T,this.scopeStore=new m,this.refStore=new T,this.deferredStore=new T,this.handleStore=new k,this.cbinfoStack=new t,this.feature={supportReflect:o,supportFinalizer:a,supportWeakSymbol:l,supportBigInt:c,supportNewFunction:i,canSetFunctionName:r,setImmediate:d,Buffer:f,MessageChannel:p},this.cleanupQueue=new q,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new U,process.once("beforeExit",(()=>{this.destroy()})))}getRuntimeVersions(){return{version:_,NAPI_VERSION:v,NAPI_VERSION_EXPERIMENTAL:g,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new B(e,t)}createNotSupportBigIntError(e,t){return new H(e,t)}createNotSupportBufferError(e,t){return new j(e,t)}createReference(e,t,i,n,s=0,r=0,o=0){return L.create(e,t,i,n,s,r,o)}createDeferred(e){return W.create(this,e)}createEnv(e,t,i,n,s,r){return F(this,e,t,i,n,s,r)}getCurrentScope(){return this.scopeStore.currentScope}addToCurrentScope(e){return this.scopeStore.currentScope.add(e)}openScope(e){return this.scopeStore.openScope(e)}closeScope(e,t){this.scopeStore.closeScope(e)}ensureHandle(e){switch(e){case void 0:return k.UNDEFINED;case null:return k.NULL;case!0:return k.TRUE;case!1:return k.FALSE;case n:return k.GLOBAL}return this.addToCurrentScope(e)}addCleanupHook(e,t,i){this.cleanupQueue.add(e,t,i)}removeCleanupHook(e,t,i){this.cleanupQueue.remove(e,t,i)}runCleanup(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()}increaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.increase()}decreaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.decrease()}setCanCallIntoJs(e){this._canCallIntoJs=e}setStopping(e){this._isStopping=e}canCallIntoJs(){return this._canCallIntoJs&&!this._isStopping}destroy(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()}}let J;function V(){return new $}function Q(){return J||(J=V()),J}export{e as CallbackInfo,t as CallbackInfoStack,S as ConstHandle,$ as Context,W as Deferred,N as EmnapiError,O as Env,z as Finalizer,b as Handle,x as HandleScope,k as HandleStore,v as NAPI_VERSION,g as NAPI_VERSION_EXPERIMENTAL,y as NODE_API_DEFAULT_MODULE_API_VERSION,D as NodeEnv,H as NotSupportBigIntError,j as NotSupportBufferError,B as NotSupportWeakRefError,A as Persistent,E as RefBase,C as RefTracker,L as Reference,m as ScopeStore,T as Store,s as TryCatch,V as createContext,Q as getDefaultContext,u as isReferenceType,_ as version};
package/dist/emnapi.mjs CHANGED
@@ -167,7 +167,7 @@ const _Buffer = typeof Buffer === 'function'
167
167
  catch (_) { }
168
168
  return undefined;
169
169
  })();
170
- const version = "0.39.0";
170
+ const version = "0.40.0";
171
171
  const NAPI_VERSION = 9;
172
172
  const NAPI_VERSION_EXPERIMENTAL = 2147483647;
173
173
  const NODE_API_DEFAULT_MODULE_API_VERSION = 8;
@@ -457,14 +457,6 @@ class Finalizer {
457
457
  }
458
458
 
459
459
  class RefBase extends Finalizer {
460
- constructor(envObject, initial_refcount, ownership, finalize_callback, finalize_data, finalize_hint) {
461
- super(envObject, finalize_callback, finalize_data, finalize_hint);
462
- this._next = null;
463
- this._prev = null;
464
- this._refcount = initial_refcount;
465
- this._ownership = ownership;
466
- this.link(!finalize_callback ? envObject.reflist : envObject.finalizing_reflist);
467
- }
468
460
  static finalizeAll(list) {
469
461
  RefTracker.finalizeAll(list);
470
462
  }
@@ -474,6 +466,14 @@ class RefBase extends Finalizer {
474
466
  unlink() {
475
467
  RefTracker.prototype.unlink.call(this);
476
468
  }
469
+ constructor(envObject, initial_refcount, ownership, finalize_callback, finalize_data, finalize_hint) {
470
+ super(envObject, finalize_callback, finalize_data, finalize_hint);
471
+ this._next = null;
472
+ this._prev = null;
473
+ this._refcount = initial_refcount;
474
+ this._ownership = ownership;
475
+ this.link(!finalize_callback ? envObject.reflist : envObject.finalizing_reflist);
476
+ }
477
477
  dispose() {
478
478
  this.unlink();
479
479
  this.envObject.dequeueFinalizer(this);
@@ -923,10 +923,6 @@ function canBeHeldWeakly(value) {
923
923
  return value.isObject() || value.isFunction() || value.isSymbol();
924
924
  }
925
925
  class Reference extends RefBase {
926
- constructor(envObject, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
927
- super(envObject, initialRefcount >>> 0, ownership, finalize_callback, finalize_data, finalize_hint);
928
- this.id = 0;
929
- }
930
926
  static create(envObject, handle_id, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
931
927
  const handle = envObject.ctx.handleStore.get(handle_id);
932
928
  const ref = new Reference(envObject, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint);
@@ -938,6 +934,10 @@ class Reference extends RefBase {
938
934
  }
939
935
  return ref;
940
936
  }
937
+ constructor(envObject, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
938
+ super(envObject, initialRefcount >>> 0, ownership, finalize_callback, finalize_data, finalize_hint);
939
+ this.id = 0;
940
+ }
941
941
  ref() {
942
942
  if (this.persistent.isEmpty()) {
943
943
  return 0;
@@ -990,16 +990,16 @@ class Reference extends RefBase {
990
990
  }
991
991
 
992
992
  class Deferred {
993
- constructor(ctx, value) {
994
- this.id = 0;
995
- this.ctx = ctx;
996
- this.value = value;
997
- }
998
993
  static create(ctx, value) {
999
994
  const deferred = new Deferred(ctx, value);
1000
995
  ctx.deferredStore.add(deferred);
1001
996
  return deferred;
1002
997
  }
998
+ constructor(ctx, value) {
999
+ this.id = 0;
1000
+ this.ctx = ctx;
1001
+ this.value = value;
1002
+ }
1003
1003
  resolve(value) {
1004
1004
  this.value.resolve(value);
1005
1005
  this.dispose();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emnapi/runtime",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "emnapi runtime",
5
5
  "main": "index.js",
6
6
  "module": "./dist/emnapi.esm-bundler.js",
@@ -27,11 +27,11 @@
27
27
  "tslib": "^2.4.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@microsoft/api-extractor": "^7.33.7",
31
- "@rollup/plugin-node-resolve": "^13.3.0",
30
+ "@microsoft/api-extractor": "^7.35.3",
31
+ "@rollup/plugin-node-resolve": "^15.1.0",
32
32
  "@rollup/plugin-replace": "^5.0.2",
33
- "rollup": "^2.77.2",
34
- "rollup-plugin-terser": "^7.0.2"
33
+ "@rollup/plugin-terser": "^0.4.3",
34
+ "rollup": "^3.25.1"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "node ./script/build.js"