Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@emnapi/runtime

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emnapi/runtime - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

4

dist/emnapi.cjs.js

@@ -205,3 +205,3 @@ const EMPTY_ARGS = [];

})();
const version = "1.3.0";
const version = "1.3.1";
const NODE_API_SUPPORTED_VERSION_MIN = 1;

@@ -248,2 +248,4 @@ const NODE_API_SUPPORTED_VERSION_MAX = 9;

isBuffer(BufferConstructor) {
if (ArrayBuffer.isView(this.value))
return true;
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);

@@ -250,0 +252,0 @@ return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);

@@ -1,1 +0,1 @@

const e=[];class t{constructor(e,t,i,s,n,r,o){this.id=e,this.parent=t,this.child=i,this.thiz=s,this.data=n,this.args=r,this.fn=o}getNewTarget(e){const t=this.thiz;return null==t||null==t.constructor?0:t instanceof this.fn?e.ensureHandleId(t.constructor):0}dispose(){void 0!==this.thiz&&(this.thiz=void 0),this.args=e,this.fn=null}}const i=new t(0,null,null,null,0,null,null);class s{constructor(){this.current=i}get(e){if(1===e)return i.child;let t=i;for(let i=0;i<e;++i)if(t=t.child,null===t)return null;return t===i?null:t}pop(){const e=this.current;e!==i&&(this.current=e.parent,e.dispose())}push(e,i,s,n){let r=this.current.child;return r?(r.thiz=e,r.data=i,r.args=s,r.fn=n):(r=new t(this.current.id+1,this.current,null,e,i,s,n),this.current.child=r),this.current=r,r.id}dispose(){this.current=null}}const n=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),r=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 o{constructor(){this._exception=void 0,this._caught=!1}isEmpty(){return!this._caught}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 a=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),l="object"==typeof Reflect,c="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,h=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),u="undefined"!=typeof BigInt;function p(e){return"object"==typeof e&&null!==e||"function"==typeof e}const d=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}(),f="function"==typeof MessageChannel?MessageChannel:function(){try{return d("worker_threads").MessageChannel}catch(e){}}(),_="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(f){let t=new f;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},v="function"==typeof Buffer?Buffer:function(){try{return d("buffer").Buffer}catch(e){}}(),g="1.3.0",y=2147483647;class x{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 p(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(e){return null!=e||(e=v),"function"==typeof e&&e.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 z extends x{constructor(e,t){super(e,t)}dispose(){}}function b(){Object.setPrototypeOf(this,null)}b.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,s=this._values;return i<s.length?(t=s[i],t.value=e):(t=new x(i,e),s[i]=t),this._next++,t}erase(e,t){this._next=e;const i=this._values;for(let s=e;s<t;++s)i[s].dispose()}get(e){return this._values[e]}swap(e,t){const i=this._values,s=i[e];i[e]=i[t],i[e].id=Number(e),i[t]=s,s.id=Number(t)}dispose(){this._values.length=k.MIN_ID,this._next=k.MIN_ID}}k.UNDEFINED=new z(1,void 0),k.NULL=new z(2,null),k.FALSE=new z(3,!1),k.TRUE=new z(4,!0),k.GLOBAL=new z(5,r),k.MIN_ID=6;class S{constructor(e,t,i,s,n=s){this.handleStore=e,this.id=t,this.parent=i,this.child=null,null!==i&&(i.child=this),this.start=s,this.end=n,this._escapeCalled=!1}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e,t){const i=new b,s=e.ctx.handleStore.push(i);return e.initObjectBinding(i).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 w{constructor(){this._rootScope=new S(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 S(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 m{constructor(){this._next=null,this._prev=null}dispose(){}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,i=0,s=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=i,this._finalizeHint=s,this._makeDynCall_vppp=e.makeDynCall_vppp}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetEnv(){this.envObject=void 0}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}callFinalizer(){const e=this._finalizeCallback,t=this._finalizeData,i=this._finalizeHint;if(this.resetFinalizer(),!e)return;const s=Number(e);this.envObject?this.envObject.callFinalizer(s,t,i):this._makeDynCall_vppp(s)(0,t,i)}dispose(){this.envObject=void 0,this._makeDynCall_vppp=void 0}}class E extends m{static create(e,t,i,s){const n=new E(e,t,i,s);return n.link(e.finalizing_reflist),n}constructor(e,t,i,s){super(),this._finalizer=new C(e,t,i,s)}data(){return this._finalizer.data()}dispose(){this._finalizer&&(this.unlink(),this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),this._finalizer=void 0,super.dispose())}finalize(){let e;this.unlink();let t=!1;try{this._finalizer.callFinalizer()}catch(i){t=!0,e=i}if(this.dispose(),t)throw e}}function F(e,t){if(!e.terminatedOrTerminating())throw t}class I{constructor(e,t,i,s,n){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=i,this.makeDynCall_vp=s,this.abort=n,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new o,this.refs=1,this.reflist=new m,this.finalizing_reflist=new m,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this.inGcFinalizer=!1,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 s=this.lastError;return s.errorCode!==e&&(s.errorCode=e),s.engineErrorCode!==t&&(s.engineErrorCode=t),s.engineReserved!==i&&(s.engineReserved=i),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=F){const i=this.openHandleScopes;this.clearLastError();const s=e(this);if(i!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return s}invokeFinalizerFromGC(e){if(this.moduleApiVersion!==y)this.enqueueFinalizer(e);else{const t=this.inGcFinalizer;this.inGcFinalizer=!0;try{e.finalize()}finally{this.inGcFinalizer=t}}}checkGCAccess(){this.moduleApiVersion===y&&this.inGcFinalizer&&this.abort("Finalizer is calling a function that may affect GC state.\nThe finalizers are run directly from GC and must not affect GC state.\nUse `node_api_post_finalizer` from inside of the finalizer to work around this issue.\nIt schedules the call as a new task in the event loop.")}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.finalizing_reflist.dispose(),this.reflist.dispose(),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=E.create(this,t,e,i)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class O extends I{constructor(e,t,i,s,n,r,o){super(e,i,s,n,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return super.canCallIntoJs()&&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 s="object"==typeof process&&null!==process,n=!!s&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy"));if(t.moduleApiVersion<y&&!n&&!e){(s&&"function"==typeof process.emitWarning?process.emitWarning:function(e,t,i){if(e instanceof Error)console.warn(e.toString());else{const s=i?`[${i}] `:"";console.warn(`${s}${t||"Warning"}: ${e}`)}})("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")}else t.triggerFatalException(i)}))}callFinalizer(e,t,i){this.callFinalizerInternal(1,e,t,i)}callFinalizerInternal(e,t,i,s){const n=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),(()=>{n(r,i,s)}))}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),_((()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()})))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function D(e,t,i,s,n,r,o){(i="number"!=typeof i?8:i)<8?i=8:i>9&&i!==y&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version 9 add-ons.`)}(t,i);const a=new O(e,t,i,s,n,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 R extends N{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(R.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class H 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(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class j{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class A{constructor(e){this._ref=new j(e)}setWeak(e,t){if(!c||void 0===this._ref||this._ref instanceof WeakRef)return;const i=this._ref.deref();try{A._registry.register(i,this,this);const s=new WeakRef(i);this._ref.dispose(),this._ref=s,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof i)throw e}}clearWeak(){if(c&&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 j(e)}}reset(){if(c)try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof j&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}var B;A._registry=c?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,exports.ReferenceOwnership=void 0,(B=exports.ReferenceOwnership||(exports.ReferenceOwnership={}))[B.kRuntime=0]="kRuntime",B[B.kUserland=1]="kUserland";class M extends m{static weakCallback(e){e.persistent.reset(),e.invokeFinalizerFromGC()}static create(e,t,i,s,n,r,o){const a=new M(e,t,i,s);return e.ctx.refStore.add(a),a.link(e.reflist),a}constructor(e,t,i,s){super(),this.envObject=e,this._refcount=i,this._ownership=s;const n=e.ctx.handleStore.get(t);var r;this.canBeWeak=(r=n).isObject()||r.isFunction()||r.isSymbol(),this.persistent=new A(n.value),this.id=0,0===i&&this._setWeak()}ref(){return this.persistent.isEmpty()?0:(1==++this._refcount&&this.canBeWeak&&this.persistent.clearWeak(),this._refcount)}unref(){return this.persistent.isEmpty()||0===this._refcount?0:(0==--this._refcount&&this._setWeak(),this._refcount)}get(e=this.envObject){if(this.persistent.isEmpty())return 0;const t=this.persistent.deref();return e.ensureHandle(t).id}resetFinalizer(){}data(){return 0}refcount(){return this._refcount}ownership(){return this._ownership}callUserFinalizer(){}invokeFinalizerFromGC(){this.finalize()}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,M.weakCallback):this.persistent.reset()}finalize(){this.persistent.reset();const e=this._ownership===exports.ReferenceOwnership.kRuntime;this.unlink(),this.callUserFinalizer(),e&&this.dispose()}dispose(){0!==this.id&&(this.unlink(),this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.envObject=void 0,this.id=0)}}class T extends M{static create(e,t,i,s,n){const r=new T(e,t,i,s,n);return e.ctx.refStore.add(r),r.link(e.reflist),r}constructor(e,t,i,s,n){super(e,t,i,s),this._data=n}data(){return this._data}}class W extends M{static create(e,t,i,s,n,r,o){const a=new W(e,t,i,s,n,r,o);return e.ctx.refStore.add(a),a.link(e.finalizing_reflist),a}constructor(e,t,i,s,n,r,o){super(e,t,i,s),this._finalizer=new C(e,n,r,o)}resetFinalizer(){this._finalizer.resetFinalizer()}data(){return this._finalizer.data()}callUserFinalizer(){this._finalizer.callFinalizer()}invokeFinalizerFromGC(){this._finalizer.envObject.invokeFinalizerFromGC(this)}dispose(){this._finalizer&&(this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),super.dispose(),this._finalizer=void 0)}}class L{static create(e,t){const i=new L(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 P{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 U{constructor(e,t,i,s){this.envObject=e,this.fn=t,this.arg=i,this.order=s}}class G{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,i){if(this._cleanupHooks.filter((s=>s.envObject===e&&s.fn===t&&s.arg===i)).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new U(e,t,i,this._cleanupHookCounter++))}remove(e,t,i){for(let s=0;s<this._cleanupHooks.length;++s){const n=this._cleanupHooks[s];if(n.envObject===e&&n.fn===t&&n.arg===i)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 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 V{constructor(){this.refHandle=(new f).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._suppressDestroy=!1,this.envStore=new P,this.scopeStore=new w,this.refStore=new P,this.deferredStore=new P,this.handleStore=new k,this.cbinfoStack=new s,this.feature={supportReflect:l,supportFinalizer:c,supportWeakSymbol:h,supportBigInt:u,supportNewFunction:n,canSetFunctionName:a,setImmediate:_,Buffer:v,MessageChannel:f},this.cleanupQueue=new G,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new V,process.once("beforeExit",(()=>{this._suppressDestroy||this.destroy()})))}suppressDestroy(){this._suppressDestroy=!0}getRuntimeVersions(){return{version:g,NODE_API_SUPPORTED_VERSION_MAX:9,NAPI_VERSION_EXPERIMENTAL:y,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new R(e,t)}createNotSupportBufferError(e,t){return new H(e,t)}createReference(e,t,i,s){return M.create(e,t,i,s)}createReferenceWithData(e,t,i,s,n){return T.create(e,t,i,s,n)}createReferenceWithFinalizer(e,t,i,s,n=0,r=0,o=0){return W.create(e,t,i,s,n,r,o)}createDeferred(e){return L.create(this,e)}createEnv(e,t,i,s,n,r){return D(this,e,t,i,s,n,r)}createTrackedFinalizer(e,t,i,s){return E.create(e,t,i,s)}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 r: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 $;function J(){return new q}exports.CallbackInfo=t,exports.CallbackInfoStack=s,exports.ConstHandle=z,exports.Context=q,exports.Deferred=L,exports.EmnapiError=N,exports.Env=I,exports.Finalizer=C,exports.Handle=x,exports.HandleScope=S,exports.HandleStore=k,exports.NAPI_VERSION_EXPERIMENTAL=y,exports.NODE_API_DEFAULT_MODULE_API_VERSION=8,exports.NODE_API_SUPPORTED_VERSION_MAX=9,exports.NODE_API_SUPPORTED_VERSION_MIN=1,exports.NodeEnv=O,exports.NotSupportBufferError=H,exports.NotSupportWeakRefError=R,exports.Persistent=A,exports.RefTracker=m,exports.Reference=M,exports.ReferenceWithData=T,exports.ReferenceWithFinalizer=W,exports.ScopeStore=w,exports.Store=P,exports.TrackedFinalizer=E,exports.TryCatch=o,exports.createContext=J,exports.getDefaultContext=function(){return $||($=J()),$},exports.isReferenceType=p,exports.version=g;
const e=[];class t{constructor(e,t,i,s,n,r,o){this.id=e,this.parent=t,this.child=i,this.thiz=s,this.data=n,this.args=r,this.fn=o}getNewTarget(e){const t=this.thiz;return null==t||null==t.constructor?0:t instanceof this.fn?e.ensureHandleId(t.constructor):0}dispose(){void 0!==this.thiz&&(this.thiz=void 0),this.args=e,this.fn=null}}const i=new t(0,null,null,null,0,null,null);class s{constructor(){this.current=i}get(e){if(1===e)return i.child;let t=i;for(let i=0;i<e;++i)if(t=t.child,null===t)return null;return t===i?null:t}pop(){const e=this.current;e!==i&&(this.current=e.parent,e.dispose())}push(e,i,s,n){let r=this.current.child;return r?(r.thiz=e,r.data=i,r.args=s,r.fn=n):(r=new t(this.current.id+1,this.current,null,e,i,s,n),this.current.child=r),this.current=r,r.id}dispose(){this.current=null}}const n=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),r=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 o{constructor(){this._exception=void 0,this._caught=!1}isEmpty(){return!this._caught}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 a=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),l="object"==typeof Reflect,c="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,h=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),u="undefined"!=typeof BigInt;function p(e){return"object"==typeof e&&null!==e||"function"==typeof e}const d=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}(),f="function"==typeof MessageChannel?MessageChannel:function(){try{return d("worker_threads").MessageChannel}catch(e){}}(),_="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(f){let t=new f;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},v="function"==typeof Buffer?Buffer:function(){try{return d("buffer").Buffer}catch(e){}}(),g="1.3.1",y=2147483647;class x{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 p(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(e){return!!ArrayBuffer.isView(this.value)||(null!=e||(e=v),"function"==typeof e&&e.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 z extends x{constructor(e,t){super(e,t)}dispose(){}}function b(){Object.setPrototypeOf(this,null)}b.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,s=this._values;return i<s.length?(t=s[i],t.value=e):(t=new x(i,e),s[i]=t),this._next++,t}erase(e,t){this._next=e;const i=this._values;for(let s=e;s<t;++s)i[s].dispose()}get(e){return this._values[e]}swap(e,t){const i=this._values,s=i[e];i[e]=i[t],i[e].id=Number(e),i[t]=s,s.id=Number(t)}dispose(){this._values.length=k.MIN_ID,this._next=k.MIN_ID}}k.UNDEFINED=new z(1,void 0),k.NULL=new z(2,null),k.FALSE=new z(3,!1),k.TRUE=new z(4,!0),k.GLOBAL=new z(5,r),k.MIN_ID=6;class S{constructor(e,t,i,s,n=s){this.handleStore=e,this.id=t,this.parent=i,this.child=null,null!==i&&(i.child=this),this.start=s,this.end=n,this._escapeCalled=!1}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e,t){const i=new b,s=e.ctx.handleStore.push(i);return e.initObjectBinding(i).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 w{constructor(){this._rootScope=new S(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 S(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 m{constructor(){this._next=null,this._prev=null}dispose(){}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,i=0,s=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=i,this._finalizeHint=s,this._makeDynCall_vppp=e.makeDynCall_vppp}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetEnv(){this.envObject=void 0}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}callFinalizer(){const e=this._finalizeCallback,t=this._finalizeData,i=this._finalizeHint;if(this.resetFinalizer(),!e)return;const s=Number(e);this.envObject?this.envObject.callFinalizer(s,t,i):this._makeDynCall_vppp(s)(0,t,i)}dispose(){this.envObject=void 0,this._makeDynCall_vppp=void 0}}class E extends m{static create(e,t,i,s){const n=new E(e,t,i,s);return n.link(e.finalizing_reflist),n}constructor(e,t,i,s){super(),this._finalizer=new C(e,t,i,s)}data(){return this._finalizer.data()}dispose(){this._finalizer&&(this.unlink(),this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),this._finalizer=void 0,super.dispose())}finalize(){let e;this.unlink();let t=!1;try{this._finalizer.callFinalizer()}catch(i){t=!0,e=i}if(this.dispose(),t)throw e}}function F(e,t){if(!e.terminatedOrTerminating())throw t}class I{constructor(e,t,i,s,n){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=i,this.makeDynCall_vp=s,this.abort=n,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new o,this.refs=1,this.reflist=new m,this.finalizing_reflist=new m,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this.inGcFinalizer=!1,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 s=this.lastError;return s.errorCode!==e&&(s.errorCode=e),s.engineErrorCode!==t&&(s.engineErrorCode=t),s.engineReserved!==i&&(s.engineReserved=i),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=F){const i=this.openHandleScopes;this.clearLastError();const s=e(this);if(i!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return s}invokeFinalizerFromGC(e){if(this.moduleApiVersion!==y)this.enqueueFinalizer(e);else{const t=this.inGcFinalizer;this.inGcFinalizer=!0;try{e.finalize()}finally{this.inGcFinalizer=t}}}checkGCAccess(){this.moduleApiVersion===y&&this.inGcFinalizer&&this.abort("Finalizer is calling a function that may affect GC state.\nThe finalizers are run directly from GC and must not affect GC state.\nUse `node_api_post_finalizer` from inside of the finalizer to work around this issue.\nIt schedules the call as a new task in the event loop.")}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.finalizing_reflist.dispose(),this.reflist.dispose(),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=E.create(this,t,e,i)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class O extends I{constructor(e,t,i,s,n,r,o){super(e,i,s,n,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return super.canCallIntoJs()&&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 s="object"==typeof process&&null!==process,n=!!s&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy"));if(t.moduleApiVersion<y&&!n&&!e){(s&&"function"==typeof process.emitWarning?process.emitWarning:function(e,t,i){if(e instanceof Error)console.warn(e.toString());else{const s=i?`[${i}] `:"";console.warn(`${s}${t||"Warning"}: ${e}`)}})("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")}else t.triggerFatalException(i)}))}callFinalizer(e,t,i){this.callFinalizerInternal(1,e,t,i)}callFinalizerInternal(e,t,i,s){const n=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),(()=>{n(r,i,s)}))}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),_((()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()})))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function D(e,t,i,s,n,r,o){(i="number"!=typeof i?8:i)<8?i=8:i>9&&i!==y&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version 9 add-ons.`)}(t,i);const a=new O(e,t,i,s,n,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 R extends N{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(R.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class A 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(A.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class H{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class j{constructor(e){this._ref=new H(e)}setWeak(e,t){if(!c||void 0===this._ref||this._ref instanceof WeakRef)return;const i=this._ref.deref();try{j._registry.register(i,this,this);const s=new WeakRef(i);this._ref.dispose(),this._ref=s,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof i)throw e}}clearWeak(){if(c&&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 H(e)}}reset(){if(c)try{j._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof H&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}var B;j._registry=c?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,exports.ReferenceOwnership=void 0,(B=exports.ReferenceOwnership||(exports.ReferenceOwnership={}))[B.kRuntime=0]="kRuntime",B[B.kUserland=1]="kUserland";class M extends m{static weakCallback(e){e.persistent.reset(),e.invokeFinalizerFromGC()}static create(e,t,i,s,n,r,o){const a=new M(e,t,i,s);return e.ctx.refStore.add(a),a.link(e.reflist),a}constructor(e,t,i,s){super(),this.envObject=e,this._refcount=i,this._ownership=s;const n=e.ctx.handleStore.get(t);var r;this.canBeWeak=(r=n).isObject()||r.isFunction()||r.isSymbol(),this.persistent=new j(n.value),this.id=0,0===i&&this._setWeak()}ref(){return this.persistent.isEmpty()?0:(1==++this._refcount&&this.canBeWeak&&this.persistent.clearWeak(),this._refcount)}unref(){return this.persistent.isEmpty()||0===this._refcount?0:(0==--this._refcount&&this._setWeak(),this._refcount)}get(e=this.envObject){if(this.persistent.isEmpty())return 0;const t=this.persistent.deref();return e.ensureHandle(t).id}resetFinalizer(){}data(){return 0}refcount(){return this._refcount}ownership(){return this._ownership}callUserFinalizer(){}invokeFinalizerFromGC(){this.finalize()}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,M.weakCallback):this.persistent.reset()}finalize(){this.persistent.reset();const e=this._ownership===exports.ReferenceOwnership.kRuntime;this.unlink(),this.callUserFinalizer(),e&&this.dispose()}dispose(){0!==this.id&&(this.unlink(),this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.envObject=void 0,this.id=0)}}class T extends M{static create(e,t,i,s,n){const r=new T(e,t,i,s,n);return e.ctx.refStore.add(r),r.link(e.reflist),r}constructor(e,t,i,s,n){super(e,t,i,s),this._data=n}data(){return this._data}}class W extends M{static create(e,t,i,s,n,r,o){const a=new W(e,t,i,s,n,r,o);return e.ctx.refStore.add(a),a.link(e.finalizing_reflist),a}constructor(e,t,i,s,n,r,o){super(e,t,i,s),this._finalizer=new C(e,n,r,o)}resetFinalizer(){this._finalizer.resetFinalizer()}data(){return this._finalizer.data()}callUserFinalizer(){this._finalizer.callFinalizer()}invokeFinalizerFromGC(){this._finalizer.envObject.invokeFinalizerFromGC(this)}dispose(){this._finalizer&&(this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),super.dispose(),this._finalizer=void 0)}}class L{static create(e,t){const i=new L(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 P{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 U{constructor(e,t,i,s){this.envObject=e,this.fn=t,this.arg=i,this.order=s}}class G{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,i){if(this._cleanupHooks.filter((s=>s.envObject===e&&s.fn===t&&s.arg===i)).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new U(e,t,i,this._cleanupHookCounter++))}remove(e,t,i){for(let s=0;s<this._cleanupHooks.length;++s){const n=this._cleanupHooks[s];if(n.envObject===e&&n.fn===t&&n.arg===i)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 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 V{constructor(){this.refHandle=(new f).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._suppressDestroy=!1,this.envStore=new P,this.scopeStore=new w,this.refStore=new P,this.deferredStore=new P,this.handleStore=new k,this.cbinfoStack=new s,this.feature={supportReflect:l,supportFinalizer:c,supportWeakSymbol:h,supportBigInt:u,supportNewFunction:n,canSetFunctionName:a,setImmediate:_,Buffer:v,MessageChannel:f},this.cleanupQueue=new G,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new V,process.once("beforeExit",(()=>{this._suppressDestroy||this.destroy()})))}suppressDestroy(){this._suppressDestroy=!0}getRuntimeVersions(){return{version:g,NODE_API_SUPPORTED_VERSION_MAX:9,NAPI_VERSION_EXPERIMENTAL:y,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new R(e,t)}createNotSupportBufferError(e,t){return new A(e,t)}createReference(e,t,i,s){return M.create(e,t,i,s)}createReferenceWithData(e,t,i,s,n){return T.create(e,t,i,s,n)}createReferenceWithFinalizer(e,t,i,s,n=0,r=0,o=0){return W.create(e,t,i,s,n,r,o)}createDeferred(e){return L.create(this,e)}createEnv(e,t,i,s,n,r){return D(this,e,t,i,s,n,r)}createTrackedFinalizer(e,t,i,s){return E.create(e,t,i,s)}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 r: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 $;function J(){return new q}exports.CallbackInfo=t,exports.CallbackInfoStack=s,exports.ConstHandle=z,exports.Context=q,exports.Deferred=L,exports.EmnapiError=N,exports.Env=I,exports.Finalizer=C,exports.Handle=x,exports.HandleScope=S,exports.HandleStore=k,exports.NAPI_VERSION_EXPERIMENTAL=y,exports.NODE_API_DEFAULT_MODULE_API_VERSION=8,exports.NODE_API_SUPPORTED_VERSION_MAX=9,exports.NODE_API_SUPPORTED_VERSION_MIN=1,exports.NodeEnv=O,exports.NotSupportBufferError=A,exports.NotSupportWeakRefError=R,exports.Persistent=j,exports.RefTracker=m,exports.Reference=M,exports.ReferenceWithData=T,exports.ReferenceWithFinalizer=W,exports.ScopeStore=w,exports.Store=P,exports.TrackedFinalizer=E,exports.TryCatch=o,exports.createContext=J,exports.getDefaultContext=function(){return $||($=J()),$},exports.isReferenceType=p,exports.version=g;

@@ -213,3 +213,3 @@ import { __extends } from 'tslib';

})();
var version = "1.3.0";
var version = "1.3.1";
var NODE_API_SUPPORTED_VERSION_MIN = 1 /* Version.NODE_API_SUPPORTED_VERSION_MIN */;

@@ -256,2 +256,4 @@ var NODE_API_SUPPORTED_VERSION_MAX = 9 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;

Handle.prototype.isBuffer = function (BufferConstructor) {
if (ArrayBuffer.isView(this.value))
return true;
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);

@@ -258,0 +260,0 @@ return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);

@@ -249,3 +249,3 @@ var emnapi = (function (exports) {

})();
var version = "1.3.0";
var version = "1.3.1";
var NODE_API_SUPPORTED_VERSION_MIN = 1 /* Version.NODE_API_SUPPORTED_VERSION_MIN */;

@@ -292,2 +292,4 @@ var NODE_API_SUPPORTED_VERSION_MAX = 9 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;

Handle.prototype.isBuffer = function (BufferConstructor) {
if (ArrayBuffer.isView(this.value))
return true;
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);

@@ -294,0 +296,0 @@ return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);

@@ -252,3 +252,3 @@ (function (global, factory) {

})();
var version = "1.3.0";
var version = "1.3.1";
var NODE_API_SUPPORTED_VERSION_MIN = 1 /* Version.NODE_API_SUPPORTED_VERSION_MIN */;

@@ -295,2 +295,4 @@ var NODE_API_SUPPORTED_VERSION_MAX = 9 /* Version.NODE_API_SUPPORTED_VERSION_MAX */;

Handle.prototype.isBuffer = function (BufferConstructor) {
if (ArrayBuffer.isView(this.value))
return true;
BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);

@@ -297,0 +299,0 @@ return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);

@@ -1,1 +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=[],n=function(){function t(t,e,n,i,r,o,s){this.id=t,this.parent=e,this.child=n,this.thiz=i,this.data=r,this.args=o,this.fn=s}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.prototype.dispose=function(){void 0!==this.thiz&&(this.thiz=void 0),this.args=e,this.fn=null},t}(),i=new n(0,null,null,null,0,null,null),r=function(){function t(){this.current=i}return t.prototype.get=function(t){if(1===t)return i.child;for(var e=i,n=0;n<t;++n)if(null===(e=e.child))return null;return e===i?null:e},t.prototype.pop=function(){var t=this.current;t!==i&&(this.current=t.parent,t.dispose())},t.prototype.push=function(t,e,i,r){var o=this.current.child;return o?(o.thiz=t,o.data=e,o.args=i,o.fn=r):(o=new n(this.current.id+1,this.current,null,t,e,i,r),this.current.child=o),this.current=o,o.id},t.prototype.dispose=function(){this.current=null},t}(),o=function(t,e){return o=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])},o(t,e)};function s(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}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}"function"==typeof SuppressedError&&SuppressedError;var a=function(){var t;try{t=new Function}catch(t){return!1}return"function"==typeof t}(),u=function(){if("undefined"!=typeof globalThis)return globalThis;var t=function(){return this}();if(!t&&a)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}(),c=function(){function t(){this._exception=void 0,this._caught=!1}return t.prototype.isEmpty=function(){return!this._caught},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}(),p=function(){var t;try{return Boolean(null===(t=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===t?void 0:t.configurable)}catch(t){return!1}}(),l="object"==typeof Reflect,f="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,h=function(){try{var t=Symbol();new WeakRef(t),(new WeakMap).set(t,void 0)}catch(t){return!1}return!0}(),d="undefined"!=typeof BigInt;function y(t){return"object"==typeof t&&null!==t||"function"==typeof t}var _=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}(),v="function"==typeof MessageChannel?MessageChannel:function(){try{return _("worker_threads").MessageChannel}catch(t){}}(),g="function"==typeof setImmediate?setImmediate:function(t){if("function"!=typeof t)throw new TypeError('The "callback" argument must be of type function');if(v){var e=new v;e.port1.onmessage=function(){e.port1.onmessage=null,e=void 0,t()},e.port2.postMessage(null)}else setTimeout(t,0)},b="function"==typeof Buffer?Buffer:function(){try{return _("buffer").Buffer}catch(t){}}(),z="1.3.0",k=2147483647,S=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 y(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(t){return null!=t||(t=b),"function"==typeof t&&t.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}(),w=function(t){function e(e,n){return t.call(this,e,n)||this}return s(e,t),e.prototype.dispose=function(){},e}(S);function m(){Object.setPrototypeOf(this,null)}m.prototype=null;var C=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 S(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 w(1,void 0),t.NULL=new w(2,null),t.FALSE=new w(3,!1),t.TRUE=new w(4,!0),t.GLOBAL=new w(5,u),t.MIN_ID=6,t}(),E=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 m,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}(),F=function(){function t(){this._rootScope=new E(null,0,null,1,C.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 E(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=C.MIN_ID,t.end=C.MIN_ID,t._escapeCalled=!1;var e=t.child;t.child=null,t=e}this.currentScope=null},t}(),x=function(){function t(){this._next=null,this._prev=null}return t.prototype.dispose=function(){},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}(),O=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,this._makeDynCall_vppp=t.makeDynCall_vppp}return t.prototype.callback=function(){return this._finalizeCallback},t.prototype.data=function(){return this._finalizeData},t.prototype.hint=function(){return this._finalizeHint},t.prototype.resetEnv=function(){this.envObject=void 0},t.prototype.resetFinalizer=function(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0},t.prototype.callFinalizer=function(){var t=this._finalizeCallback,e=this._finalizeData,n=this._finalizeHint;if(this.resetFinalizer(),t){var i=Number(t);this.envObject?this.envObject.callFinalizer(i,e,n):this._makeDynCall_vppp(i)(0,e,n)}},t.prototype.dispose=function(){this.envObject=void 0,this._makeDynCall_vppp=void 0},t}(),I=function(t){function e(e,n,i,r){var o=t.call(this)||this;return o._finalizer=new O(e,n,i,r),o}return s(e,t),e.create=function(t,n,i,r){var o=new e(t,n,i,r);return o.link(t.finalizing_reflist),o},e.prototype.data=function(){return this._finalizer.data()},e.prototype.dispose=function(){this._finalizer&&(this.unlink(),this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),this._finalizer=void 0,t.prototype.dispose.call(this))},e.prototype.finalize=function(){var t;this.unlink();var e=!1;try{this._finalizer.callFinalizer()}catch(n){e=!0,t=n}if(this.dispose(),e)throw t},e}(x);function D(t,e){if(!t.terminatedOrTerminating())throw e}var N=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 c,this.refs=1,this.reflist=new x,this.finalizing_reflist=new x,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this.inGcFinalizer=!1,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=D);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.invokeFinalizerFromGC=function(t){if(this.moduleApiVersion!==k)this.enqueueFinalizer(t);else{var e=this.inGcFinalizer;this.inGcFinalizer=!0;try{t.finalize()}finally{this.inGcFinalizer=e}}},t.prototype.checkGCAccess=function(){this.moduleApiVersion===k&&this.inGcFinalizer&&this.abort("Finalizer is calling a function that may affect GC state.\nThe finalizers are run directly from GC and must not affect GC state.\nUse `node_api_post_finalizer` from inside of the finalizer to work around this issue.\nIt schedules the call as a new task in the event loop.")},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(){x.finalizeAll(this.finalizing_reflist),x.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)},t.prototype.dispose=function(){0!==this.id&&(this.deleteMe(),this.finalizing_reflist.dispose(),this.reflist.dispose(),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=I.create(this,e,t,n)},t.prototype.getInstanceData=function(){return this.instanceData?this.instanceData.data():0},t}(),R=function(t){function e(e,n,i,r,o,s,a){var u=t.call(this,e,i,r,o,s)||this;return u.filename=n,u.nodeBinding=a,u.destructing=!1,u.finalizationScheduled=!1,u}return s(e,t),e.prototype.deleteMe=function(){this.destructing=!0,this.drainFinalizerQueue(),t.prototype.deleteMe.call(this)},e.prototype.canCallIntoJs=function(){return t.prototype.canCallIntoJs.call(this)&&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,r=!!i&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy"));if(e.moduleApiVersion<k&&!r&&!t)(i&&"function"==typeof process.emitWarning?process.emitWarning:function(t,e,n){if(t instanceof Error)console.warn(t.toString());else{var i=n?"[".concat(n,"] "):"";console.warn("".concat(i).concat(e||"Warning",": ").concat(t))}})("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");else 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(),g((function(){n.finalizationScheduled=!1,n.unref(),n.drainFinalizerQueue()})))},e.prototype.drainFinalizerQueue=function(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}},e}(N);function j(t,e,n,i,r,o,s){(n="number"!=typeof n?8:n)<8?n=8:n>9&&n!==k&&function(t,e){var n="".concat(t," requires Node-API version ").concat(e,", but this version of Node.js only supports version ").concat(9," add-ons.");throw new Error(n)}(e,n);var a=new R(t,e,n,i,r,o,s);return t.envStore.add(a),t.addCleanupHook(a,(function(){a.unref()}),0),a}var A=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 a=Object.setPrototypeOf;"function"==typeof a?a.call(Object,r,s):r.__proto__=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,o)}return r}return s(e,t),e}(Error);Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});var H=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 s(e,t),e}(A);Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});var T=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 s(e,t),e}(A);Object.defineProperty(T.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});var B,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}(),P=function(){function t(t){this._ref=new M(t)}return t.prototype.setWeak=function(e,n){if(f&&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(f&&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(f)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=f?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}();t.ReferenceOwnership=void 0,(B=t.ReferenceOwnership||(t.ReferenceOwnership={}))[B.kRuntime=0]="kRuntime",B[B.kUserland=1]="kUserland";var W,L=function(e){function n(t,n,i,r){var o=e.call(this)||this;o.envObject=t,o._refcount=i,o._ownership=r;var s,a=t.ctx.handleStore.get(n);return o.canBeWeak=(s=a).isObject()||s.isFunction()||s.isSymbol(),o.persistent=new P(a.value),o.id=0,0===i&&o._setWeak(),o}return s(n,e),n.weakCallback=function(t){t.persistent.reset(),t.invokeFinalizerFromGC()},n.create=function(t,e,i,r,o,s,a){var u=new n(t,e,i,r);return t.ctx.refStore.add(u),u.link(t.reflist),u},n.prototype.ref=function(){return this.persistent.isEmpty()?0:(1==++this._refcount&&this.canBeWeak&&this.persistent.clearWeak(),this._refcount)},n.prototype.unref=function(){return this.persistent.isEmpty()||0===this._refcount?0:(0==--this._refcount&&this._setWeak(),this._refcount)},n.prototype.get=function(t){if(void 0===t&&(t=this.envObject),this.persistent.isEmpty())return 0;var e=this.persistent.deref();return t.ensureHandle(e).id},n.prototype.resetFinalizer=function(){},n.prototype.data=function(){return 0},n.prototype.refcount=function(){return this._refcount},n.prototype.ownership=function(){return this._ownership},n.prototype.callUserFinalizer=function(){},n.prototype.invokeFinalizerFromGC=function(){this.finalize()},n.prototype._setWeak=function(){this.canBeWeak?this.persistent.setWeak(this,n.weakCallback):this.persistent.reset()},n.prototype.finalize=function(){this.persistent.reset();var e=this._ownership===t.ReferenceOwnership.kRuntime;this.unlink(),this.callUserFinalizer(),e&&this.dispose()},n.prototype.dispose=function(){0!==this.id&&(this.unlink(),this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),e.prototype.dispose.call(this),this.envObject=void 0,this.id=0)},n}(x),U=function(t){function e(e,n,i,r,o){var s=t.call(this,e,n,i,r)||this;return s._data=o,s}return s(e,t),e.create=function(t,n,i,r,o){var s=new e(t,n,i,r,o);return t.ctx.refStore.add(s),s.link(t.reflist),s},e.prototype.data=function(){return this._data},e}(L),G=function(t){function e(e,n,i,r,o,s,a){var u=t.call(this,e,n,i,r)||this;return u._finalizer=new O(e,o,s,a),u}return s(e,t),e.create=function(t,n,i,r,o,s,a){var u=new e(t,n,i,r,o,s,a);return t.ctx.refStore.add(u),u.link(t.finalizing_reflist),u},e.prototype.resetFinalizer=function(){this._finalizer.resetFinalizer()},e.prototype.data=function(){return this._finalizer.data()},e.prototype.callUserFinalizer=function(){this._finalizer.callFinalizer()},e.prototype.invokeFinalizerFromGC=function(){this._finalizer.envObject.invokeFinalizerFromGC(this)},e.prototype.dispose=function(){this._finalizer&&(this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),t.prototype.dispose.call(this),this._finalizer=void 0)},e}(L),V=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}(),J=function(){return function(t,e,n,i){this.envObject=t,this.fn=e,this.arg=n,this.order=i}}(),Q=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 J(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}(),X=function(){function t(){this.refHandle=(new v).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}(),K=function(){function t(){var t=this;this._isStopping=!1,this._canCallIntoJs=!0,this._suppressDestroy=!1,this.envStore=new q,this.scopeStore=new F,this.refStore=new q,this.deferredStore=new q,this.handleStore=new C,this.cbinfoStack=new r,this.feature={supportReflect:l,supportFinalizer:f,supportWeakSymbol:h,supportBigInt:d,supportNewFunction:a,canSetFunctionName:p,setImmediate:g,Buffer:b,MessageChannel:v},this.cleanupQueue=new Q,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new X,process.once("beforeExit",(function(){t._suppressDestroy||t.destroy()})))}return t.prototype.suppressDestroy=function(){this._suppressDestroy=!0},t.prototype.getRuntimeVersions=function(){return{version:z,NODE_API_SUPPORTED_VERSION_MAX:9,NAPI_VERSION_EXPERIMENTAL:k,NODE_API_DEFAULT_MODULE_API_VERSION:8}},t.prototype.createNotSupportWeakRefError=function(t,e){return new H(t,e)},t.prototype.createNotSupportBufferError=function(t,e){return new T(t,e)},t.prototype.createReference=function(t,e,n,i){return L.create(t,e,n,i)},t.prototype.createReferenceWithData=function(t,e,n,i,r){return U.create(t,e,n,i,r)},t.prototype.createReferenceWithFinalizer=function(t,e,n,i,r,o,s){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=0),G.create(t,e,n,i,r,o,s)},t.prototype.createDeferred=function(t){return V.create(this,t)},t.prototype.createEnv=function(t,e,n,i,r,o){return j(this,t,e,n,i,r,o)},t.prototype.createTrackedFinalizer=function(t,e,n,i){return I.create(t,e,n,i)},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 C.UNDEFINED;case null:return C.NULL;case!0:return C.TRUE;case!1:return C.FALSE;case u:return C.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 Y(){return new K}t.CallbackInfo=n,t.CallbackInfoStack=r,t.ConstHandle=w,t.Context=K,t.Deferred=V,t.EmnapiError=A,t.Env=N,t.Finalizer=O,t.Handle=S,t.HandleScope=E,t.HandleStore=C,t.NAPI_VERSION_EXPERIMENTAL=k,t.NODE_API_DEFAULT_MODULE_API_VERSION=8,t.NODE_API_SUPPORTED_VERSION_MAX=9,t.NODE_API_SUPPORTED_VERSION_MIN=1,t.NodeEnv=R,t.NotSupportBufferError=T,t.NotSupportWeakRefError=H,t.Persistent=P,t.RefTracker=x,t.Reference=L,t.ReferenceWithData=U,t.ReferenceWithFinalizer=G,t.ScopeStore=F,t.Store=q,t.TrackedFinalizer=I,t.TryCatch=c,t.createContext=Y,t.getDefaultContext=function(){return W||(W=Y()),W},t.isReferenceType=y,t.version=z}));
!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=[],n=function(){function t(t,e,n,i,r,o,s){this.id=t,this.parent=e,this.child=n,this.thiz=i,this.data=r,this.args=o,this.fn=s}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.prototype.dispose=function(){void 0!==this.thiz&&(this.thiz=void 0),this.args=e,this.fn=null},t}(),i=new n(0,null,null,null,0,null,null),r=function(){function t(){this.current=i}return t.prototype.get=function(t){if(1===t)return i.child;for(var e=i,n=0;n<t;++n)if(null===(e=e.child))return null;return e===i?null:e},t.prototype.pop=function(){var t=this.current;t!==i&&(this.current=t.parent,t.dispose())},t.prototype.push=function(t,e,i,r){var o=this.current.child;return o?(o.thiz=t,o.data=e,o.args=i,o.fn=r):(o=new n(this.current.id+1,this.current,null,t,e,i,r),this.current.child=o),this.current=o,o.id},t.prototype.dispose=function(){this.current=null},t}(),o=function(t,e){return o=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])},o(t,e)};function s(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}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}"function"==typeof SuppressedError&&SuppressedError;var a=function(){var t;try{t=new Function}catch(t){return!1}return"function"==typeof t}(),u=function(){if("undefined"!=typeof globalThis)return globalThis;var t=function(){return this}();if(!t&&a)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}(),c=function(){function t(){this._exception=void 0,this._caught=!1}return t.prototype.isEmpty=function(){return!this._caught},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}(),p=function(){var t;try{return Boolean(null===(t=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===t?void 0:t.configurable)}catch(t){return!1}}(),l="object"==typeof Reflect,f="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,h=function(){try{var t=Symbol();new WeakRef(t),(new WeakMap).set(t,void 0)}catch(t){return!1}return!0}(),d="undefined"!=typeof BigInt;function y(t){return"object"==typeof t&&null!==t||"function"==typeof t}var _=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}(),v="function"==typeof MessageChannel?MessageChannel:function(){try{return _("worker_threads").MessageChannel}catch(t){}}(),g="function"==typeof setImmediate?setImmediate:function(t){if("function"!=typeof t)throw new TypeError('The "callback" argument must be of type function');if(v){var e=new v;e.port1.onmessage=function(){e.port1.onmessage=null,e=void 0,t()},e.port2.postMessage(null)}else setTimeout(t,0)},b="function"==typeof Buffer?Buffer:function(){try{return _("buffer").Buffer}catch(t){}}(),z="1.3.1",k=2147483647,S=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 y(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(t){return!!ArrayBuffer.isView(this.value)||(null!=t||(t=b),"function"==typeof t&&t.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}(),w=function(t){function e(e,n){return t.call(this,e,n)||this}return s(e,t),e.prototype.dispose=function(){},e}(S);function m(){Object.setPrototypeOf(this,null)}m.prototype=null;var C=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 S(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 w(1,void 0),t.NULL=new w(2,null),t.FALSE=new w(3,!1),t.TRUE=new w(4,!0),t.GLOBAL=new w(5,u),t.MIN_ID=6,t}(),E=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 m,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}(),F=function(){function t(){this._rootScope=new E(null,0,null,1,C.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 E(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=C.MIN_ID,t.end=C.MIN_ID,t._escapeCalled=!1;var e=t.child;t.child=null,t=e}this.currentScope=null},t}(),x=function(){function t(){this._next=null,this._prev=null}return t.prototype.dispose=function(){},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}(),O=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,this._makeDynCall_vppp=t.makeDynCall_vppp}return t.prototype.callback=function(){return this._finalizeCallback},t.prototype.data=function(){return this._finalizeData},t.prototype.hint=function(){return this._finalizeHint},t.prototype.resetEnv=function(){this.envObject=void 0},t.prototype.resetFinalizer=function(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0},t.prototype.callFinalizer=function(){var t=this._finalizeCallback,e=this._finalizeData,n=this._finalizeHint;if(this.resetFinalizer(),t){var i=Number(t);this.envObject?this.envObject.callFinalizer(i,e,n):this._makeDynCall_vppp(i)(0,e,n)}},t.prototype.dispose=function(){this.envObject=void 0,this._makeDynCall_vppp=void 0},t}(),I=function(t){function e(e,n,i,r){var o=t.call(this)||this;return o._finalizer=new O(e,n,i,r),o}return s(e,t),e.create=function(t,n,i,r){var o=new e(t,n,i,r);return o.link(t.finalizing_reflist),o},e.prototype.data=function(){return this._finalizer.data()},e.prototype.dispose=function(){this._finalizer&&(this.unlink(),this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),this._finalizer=void 0,t.prototype.dispose.call(this))},e.prototype.finalize=function(){var t;this.unlink();var e=!1;try{this._finalizer.callFinalizer()}catch(n){e=!0,t=n}if(this.dispose(),e)throw t},e}(x);function D(t,e){if(!t.terminatedOrTerminating())throw e}var N=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 c,this.refs=1,this.reflist=new x,this.finalizing_reflist=new x,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this.inGcFinalizer=!1,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=D);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.invokeFinalizerFromGC=function(t){if(this.moduleApiVersion!==k)this.enqueueFinalizer(t);else{var e=this.inGcFinalizer;this.inGcFinalizer=!0;try{t.finalize()}finally{this.inGcFinalizer=e}}},t.prototype.checkGCAccess=function(){this.moduleApiVersion===k&&this.inGcFinalizer&&this.abort("Finalizer is calling a function that may affect GC state.\nThe finalizers are run directly from GC and must not affect GC state.\nUse `node_api_post_finalizer` from inside of the finalizer to work around this issue.\nIt schedules the call as a new task in the event loop.")},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(){x.finalizeAll(this.finalizing_reflist),x.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)},t.prototype.dispose=function(){0!==this.id&&(this.deleteMe(),this.finalizing_reflist.dispose(),this.reflist.dispose(),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=I.create(this,e,t,n)},t.prototype.getInstanceData=function(){return this.instanceData?this.instanceData.data():0},t}(),R=function(t){function e(e,n,i,r,o,s,a){var u=t.call(this,e,i,r,o,s)||this;return u.filename=n,u.nodeBinding=a,u.destructing=!1,u.finalizationScheduled=!1,u}return s(e,t),e.prototype.deleteMe=function(){this.destructing=!0,this.drainFinalizerQueue(),t.prototype.deleteMe.call(this)},e.prototype.canCallIntoJs=function(){return t.prototype.canCallIntoJs.call(this)&&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,r=!!i&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy"));if(e.moduleApiVersion<k&&!r&&!t)(i&&"function"==typeof process.emitWarning?process.emitWarning:function(t,e,n){if(t instanceof Error)console.warn(t.toString());else{var i=n?"[".concat(n,"] "):"";console.warn("".concat(i).concat(e||"Warning",": ").concat(t))}})("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");else 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(),g((function(){n.finalizationScheduled=!1,n.unref(),n.drainFinalizerQueue()})))},e.prototype.drainFinalizerQueue=function(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}},e}(N);function j(t,e,n,i,r,o,s){(n="number"!=typeof n?8:n)<8?n=8:n>9&&n!==k&&function(t,e){var n="".concat(t," requires Node-API version ").concat(e,", but this version of Node.js only supports version ").concat(9," add-ons.");throw new Error(n)}(e,n);var a=new R(t,e,n,i,r,o,s);return t.envStore.add(a),t.addCleanupHook(a,(function(){a.unref()}),0),a}var A=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 a=Object.setPrototypeOf;"function"==typeof a?a.call(Object,r,s):r.__proto__=s,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,o)}return r}return s(e,t),e}(Error);Object.defineProperty(A.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});var H=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 s(e,t),e}(A);Object.defineProperty(H.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});var B=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 s(e,t),e}(A);Object.defineProperty(B.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});var T,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}(),P=function(){function t(t){this._ref=new M(t)}return t.prototype.setWeak=function(e,n){if(f&&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(f&&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(f)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=f?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}();t.ReferenceOwnership=void 0,(T=t.ReferenceOwnership||(t.ReferenceOwnership={}))[T.kRuntime=0]="kRuntime",T[T.kUserland=1]="kUserland";var W,L=function(e){function n(t,n,i,r){var o=e.call(this)||this;o.envObject=t,o._refcount=i,o._ownership=r;var s,a=t.ctx.handleStore.get(n);return o.canBeWeak=(s=a).isObject()||s.isFunction()||s.isSymbol(),o.persistent=new P(a.value),o.id=0,0===i&&o._setWeak(),o}return s(n,e),n.weakCallback=function(t){t.persistent.reset(),t.invokeFinalizerFromGC()},n.create=function(t,e,i,r,o,s,a){var u=new n(t,e,i,r);return t.ctx.refStore.add(u),u.link(t.reflist),u},n.prototype.ref=function(){return this.persistent.isEmpty()?0:(1==++this._refcount&&this.canBeWeak&&this.persistent.clearWeak(),this._refcount)},n.prototype.unref=function(){return this.persistent.isEmpty()||0===this._refcount?0:(0==--this._refcount&&this._setWeak(),this._refcount)},n.prototype.get=function(t){if(void 0===t&&(t=this.envObject),this.persistent.isEmpty())return 0;var e=this.persistent.deref();return t.ensureHandle(e).id},n.prototype.resetFinalizer=function(){},n.prototype.data=function(){return 0},n.prototype.refcount=function(){return this._refcount},n.prototype.ownership=function(){return this._ownership},n.prototype.callUserFinalizer=function(){},n.prototype.invokeFinalizerFromGC=function(){this.finalize()},n.prototype._setWeak=function(){this.canBeWeak?this.persistent.setWeak(this,n.weakCallback):this.persistent.reset()},n.prototype.finalize=function(){this.persistent.reset();var e=this._ownership===t.ReferenceOwnership.kRuntime;this.unlink(),this.callUserFinalizer(),e&&this.dispose()},n.prototype.dispose=function(){0!==this.id&&(this.unlink(),this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),e.prototype.dispose.call(this),this.envObject=void 0,this.id=0)},n}(x),U=function(t){function e(e,n,i,r,o){var s=t.call(this,e,n,i,r)||this;return s._data=o,s}return s(e,t),e.create=function(t,n,i,r,o){var s=new e(t,n,i,r,o);return t.ctx.refStore.add(s),s.link(t.reflist),s},e.prototype.data=function(){return this._data},e}(L),G=function(t){function e(e,n,i,r,o,s,a){var u=t.call(this,e,n,i,r)||this;return u._finalizer=new O(e,o,s,a),u}return s(e,t),e.create=function(t,n,i,r,o,s,a){var u=new e(t,n,i,r,o,s,a);return t.ctx.refStore.add(u),u.link(t.finalizing_reflist),u},e.prototype.resetFinalizer=function(){this._finalizer.resetFinalizer()},e.prototype.data=function(){return this._finalizer.data()},e.prototype.callUserFinalizer=function(){this._finalizer.callFinalizer()},e.prototype.invokeFinalizerFromGC=function(){this._finalizer.envObject.invokeFinalizerFromGC(this)},e.prototype.dispose=function(){this._finalizer&&(this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),t.prototype.dispose.call(this),this._finalizer=void 0)},e}(L),V=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}(),J=function(){return function(t,e,n,i){this.envObject=t,this.fn=e,this.arg=n,this.order=i}}(),Q=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 J(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}(),X=function(){function t(){this.refHandle=(new v).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}(),K=function(){function t(){var t=this;this._isStopping=!1,this._canCallIntoJs=!0,this._suppressDestroy=!1,this.envStore=new q,this.scopeStore=new F,this.refStore=new q,this.deferredStore=new q,this.handleStore=new C,this.cbinfoStack=new r,this.feature={supportReflect:l,supportFinalizer:f,supportWeakSymbol:h,supportBigInt:d,supportNewFunction:a,canSetFunctionName:p,setImmediate:g,Buffer:b,MessageChannel:v},this.cleanupQueue=new Q,"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new X,process.once("beforeExit",(function(){t._suppressDestroy||t.destroy()})))}return t.prototype.suppressDestroy=function(){this._suppressDestroy=!0},t.prototype.getRuntimeVersions=function(){return{version:z,NODE_API_SUPPORTED_VERSION_MAX:9,NAPI_VERSION_EXPERIMENTAL:k,NODE_API_DEFAULT_MODULE_API_VERSION:8}},t.prototype.createNotSupportWeakRefError=function(t,e){return new H(t,e)},t.prototype.createNotSupportBufferError=function(t,e){return new B(t,e)},t.prototype.createReference=function(t,e,n,i){return L.create(t,e,n,i)},t.prototype.createReferenceWithData=function(t,e,n,i,r){return U.create(t,e,n,i,r)},t.prototype.createReferenceWithFinalizer=function(t,e,n,i,r,o,s){return void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=0),G.create(t,e,n,i,r,o,s)},t.prototype.createDeferred=function(t){return V.create(this,t)},t.prototype.createEnv=function(t,e,n,i,r,o){return j(this,t,e,n,i,r,o)},t.prototype.createTrackedFinalizer=function(t,e,n,i){return I.create(t,e,n,i)},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 C.UNDEFINED;case null:return C.NULL;case!0:return C.TRUE;case!1:return C.FALSE;case u:return C.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 Y(){return new K}t.CallbackInfo=n,t.CallbackInfoStack=r,t.ConstHandle=w,t.Context=K,t.Deferred=V,t.EmnapiError=A,t.Env=N,t.Finalizer=O,t.Handle=S,t.HandleScope=E,t.HandleStore=C,t.NAPI_VERSION_EXPERIMENTAL=k,t.NODE_API_DEFAULT_MODULE_API_VERSION=8,t.NODE_API_SUPPORTED_VERSION_MAX=9,t.NODE_API_SUPPORTED_VERSION_MIN=1,t.NodeEnv=R,t.NotSupportBufferError=B,t.NotSupportWeakRefError=H,t.Persistent=P,t.RefTracker=x,t.Reference=L,t.ReferenceWithData=U,t.ReferenceWithFinalizer=G,t.ScopeStore=F,t.Store=q,t.TrackedFinalizer=I,t.TryCatch=c,t.createContext=Y,t.getDefaultContext=function(){return W||(W=Y()),W},t.isReferenceType=y,t.version=z}));
{
"name": "@emnapi/runtime",
"version": "1.3.0",
"version": "1.3.1",
"description": "emnapi runtime",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc