@univer-cli/daemon 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.mjs +1 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- const _0xe1d5fe=_0x4e15;(function(_0x380d6d,_0x39ac03){const _0x399bff=_0x4e15,_0x4ed93e=_0x380d6d();while(!![]){try{const _0x21ec4c=parseInt(_0x399bff(0x207))/0x1+parseInt(_0x399bff(0x1e2))/0x2*(parseInt(_0x399bff(0x21d))/0x3)+parseInt(_0x399bff(0x201))/0x4*(-parseInt(_0x399bff(0x1e8))/0x5)+parseInt(_0x399bff(0x1c6))/0x6*(-parseInt(_0x399bff(0x1fc))/0x7)+parseInt(_0x399bff(0x22f))/0x8+parseInt(_0x399bff(0x229))/0x9+-parseInt(_0x399bff(0x237))/0xa*(-parseInt(_0x399bff(0x213))/0xb);if(_0x21ec4c===_0x39ac03)break;else _0x4ed93e['push'](_0x4ed93e['shift']());}catch(_0x31fbdf){_0x4ed93e['push'](_0x4ed93e['shift']());}}}(_0x2e88,0xa127a));import{randomUUID as _0x49402a}from'node:crypto';import{spawn as _0xdd10b3}from'node:child_process';import{connect as _0x198d50,createServer as _0x2d7721}from'node:net';import{fileURLToPath as _0xafc393}from'node:url';import{lstat as _0xad2aa4,mkdir as _0x4fc4af,unlink as _0x364a79}from'node:fs/promises';import{dirname as _0x3ca711}from'node:path';function l(_0x17221e){const _0x44d598=_0x4e15;return JSON[_0x44d598(0x1d9)](_0x17221e)+'\x0a';}function u(_0x3c6c8e){let _0x3fdeb8='';return{'end'(){_0x3fdeb8['trim']()['length']>0x0&&_0x3c6c8e(_0x3fdeb8),_0x3fdeb8='';},'push'(_0x58cf1f){const _0x4d638d=_0x4e15;for(_0x3fdeb8+=_0x58cf1f[_0x4d638d(0x1d7)](_0x4d638d(0x1d0));;){let _0x21c782=_0x3fdeb8['indexOf']('\x0a');if(_0x21c782<0x0)return;let _0x513ec7=_0x3fdeb8[_0x4d638d(0x1dd)](0x0,_0x21c782);_0x3fdeb8=_0x3fdeb8[_0x4d638d(0x1dd)](_0x21c782+0x1),_0x513ec7[_0x4d638d(0x1fb)]()[_0x4d638d(0x210)]>0x0&&_0x3c6c8e(_0x513ec7);}}};}var d=_0xe1d5fe(0x230);async function f(_0x338329){const _0xf26c56=_0xe1d5fe;_0xdd10b3(process[_0xf26c56(0x1d3)],[_0xafc393(_0x338329[_0xf26c56(0x1c7)])],{'detached':!0x0,'env':{...process.env,..._0x338329[_0xf26c56(0x1dc)]['env'],[d]:_0x338329[_0xf26c56(0x1dc)][_0xf26c56(0x1e1)]},'stdio':'ignore'})[_0xf26c56(0x215)]();let _0x14af6e=Date[_0xf26c56(0x1d5)]();for(;Date['now']()-_0x14af6e<_0x338329['timeoutMs'];){try{return await _0x338329[_0xf26c56(0x20a)]();}catch(_0x1c1f42){if(!h(_0x1c1f42))throw _0x1c1f42;}await new Promise(_0x175ae5=>setTimeout(_0x175ae5,0x19));}throw Object[_0xf26c56(0x22d)](Error(_0xf26c56(0x204)+String(_0x338329[_0xf26c56(0x222)])+'ms'),{'code':_0xf26c56(0x216)});}function p(_0x3a9099,_0xeea940,_0x41394d,_0x2b72a5){return new Promise((_0x582084,_0x23f9a5)=>{const _0x35423c=_0x4e15;let _0x5658c9=_0x198d50(_0x3a9099),_0xfa2571=_0x49402a(),_0x2e0617=!0x1,_0x3d42d5=setTimeout(()=>{const _0xbc9978=_0x4e15;_0x5658c9[_0xbc9978(0x232)](),_0x23f9a5(Object[_0xbc9978(0x22d)](Error(_0xbc9978(0x1f4)+String(_0x2b72a5)+'ms'),{'code':_0xbc9978(0x1ce)}));},_0x2b72a5),_0x58fb7f=_0x117eaf=>{_0x2e0617||(_0x2e0617=!0x0,clearTimeout(_0x3d42d5),_0x117eaf());},_0x40af14=u(_0x127c8c=>{try{let _0x416dad=_(_0x127c8c,_0xfa2571);_0x58fb7f(()=>{const _0x484b3a=_0x4e15;_0x5658c9[_0x484b3a(0x1db)](),_0x416dad['type']===_0x484b3a(0x206)?_0x23f9a5(v(_0x416dad[_0x484b3a(0x206)])):_0x582084(_0x416dad['result']);});}catch(_0x109e20){_0x58fb7f(()=>{const _0x34a44e=_0x4e15;_0x5658c9[_0x34a44e(0x232)](),_0x23f9a5(_0x109e20);});}});_0x5658c9[_0x35423c(0x228)](_0x35423c(0x206),_0x15a6b1=>_0x58fb7f(()=>{const _0x4a9fd5=_0x35423c;_0x5658c9[_0x4a9fd5(0x232)](),_0x23f9a5(_0x15a6b1);})),_0x5658c9['on']('data',_0x3142d8=>_0x40af14['push'](_0x3142d8)),_0x5658c9['on'](_0x35423c(0x1db),()=>{_0x40af14['end'](),_0x58fb7f(()=>{const _0x371ae1=_0x4e15;_0x5658c9[_0x371ae1(0x232)](),_0x23f9a5(g());});}),_0x5658c9['on']('close',()=>_0x58fb7f(()=>{_0x5658c9['destroy'](),_0x23f9a5(g());})),_0x5658c9[_0x35423c(0x228)](_0x35423c(0x21c),()=>{const _0xfca3d8=_0x35423c;_0x5658c9[_0xfca3d8(0x1fa)](l({'id':_0xfa2571,'method':_0xeea940,'payload':_0x41394d}));});});}function m(_0x1ff776){const _0x50bce3=_0xe1d5fe;let _0x1ded41=_0x1ff776 instanceof URL?_0x1ff776[_0x50bce3(0x1ec)]:_0x1ff776;try{let _0x1e31bb=new URL(_0x1ded41);if(_0x1e31bb[_0x50bce3(0x238)]!=='file:')throw Error();return _0x1e31bb[_0x50bce3(0x1ec)];}catch{throw Error('Daemon\x20entry\x20must\x20be\x20an\x20absolute\x20file\x20URL');}}function h(_0x5470bf){const _0x25e325=_0xe1d5fe;return y(_0x5470bf)?_0x5470bf[_0x25e325(0x1e7)]===_0x25e325(0x1e9)||_0x5470bf[_0x25e325(0x1e7)]===_0x25e325(0x1f1):!0x1;}function g(){const _0x491be3=_0xe1d5fe;return Object[_0x491be3(0x22d)](Error(_0x491be3(0x21a)),{'code':_0x491be3(0x1c8)});}function _0x2e88(){const _0x3a7341=['identity-mismatch','isSocket','11GrVwxu','A\x20daemon\x20is\x20already\x20listening\x20on\x20','unref','DAEMON_START_TIMEOUT','requestTimeoutMs','daemon.status','legacy-protocol','Daemon\x20connection\x20closed\x20before\x20a\x20response\x20was\x20received','actual','connect','3UBDvSM','Daemon\x20status\x20response\x20is\x20invalid','\x20must\x20be\x20a\x20finite\x20positive\x20number','diagnostic','ENOTCONN','timeoutMs','catch','payload','version','identity.buildId','pid','once','609678fnZfpq','DAEMON_INVALID_REQUEST','method','protocolVersion','assign','type','3811272putiIO','UNIVER_CLI_SDK_DAEMON_SOCKET','get','destroy','identity.id','unknown','version-mismatch','startedAt','7397660dmizSx','protocol','data','Daemon\x20server\x20has\x20not\x20started\x20listening','startTimeoutMs','DAEMON_ALREADY_RUNNING','DAEMON_INCOMPATIBLE','Refusing\x20to\x20replace\x20non-socket\x20path\x20','3924AaaUMV','entry','DAEMON_CONNECTION_CLOSED','listen','\x20must\x20not\x20be\x20empty','isSafeInteger','name','socketPath\x20must\x20not\x20be\x20empty','DAEMON_REQUEST_TIMEOUT','reason','utf8','identity','has','execPath','incompatible','now','EADDRINUSE','toString','onShutdown','stringify','Unknown\x20daemon\x20method\x20','end','options','slice','add','unreachable','startsWith','socketPath','943306SEBhhm','isFinite','DAEMON_METHOD_NOT_FOUND','\x20is\x20already\x20registered','number','code','1775HObxHj','ENOENT','running','result','href','Daemon\x20method\x20','stopped','Daemon\x20did\x20not\x20stop\x20within\x20','isArray','ECONNREFUSED','daemon.shutdown','string','Daemon\x20request\x20timed\x20out\x20after\x20','delete','stopTimeoutMs','object','state','push','write','trim','3220lsKkTu','parse','Invalid\x20daemon\x20response','identity.version','buildId','11992YzoCpw','Daemon\x20is\x20not\x20listening\x20on\x20','status','Daemon\x20did\x20not\x20start\x20within\x20','DAEMON_STOP_TIMEOUT','error','269650GqKKvI','DAEMON_CONTROL_INVALID_RESPONSE','DAEMON_UNREACHABLE','ready','protocol-mismatch','isNaN','Daemon\x20is\x20not\x20ready:\x20','close','Daemon\x20handlers\x20must\x20be\x20registered\x20before\x20listen()','length'];_0x2e88=function(){return _0x3a7341;};return _0x2e88();}function _(_0xd4dd20,_0x1f1f0d){const _0x4da4d0=_0xe1d5fe;let _0x13d645=JSON[_0x4da4d0(0x1fd)](_0xd4dd20);if(!y(_0x13d645)||_0x13d645['id']!==_0x1f1f0d)throw Error(_0x4da4d0(0x1fe));if(_0x13d645[_0x4da4d0(0x22e)]===_0x4da4d0(0x1eb)&&_0x4da4d0(0x1eb)in _0x13d645||_0x13d645[_0x4da4d0(0x22e)]==='error'&&y(_0x13d645[_0x4da4d0(0x206)]))return _0x13d645;throw Error(_0x4da4d0(0x1fe));}function v(_0x2007ad){const _0x4288a6=_0xe1d5fe;let _0x3ec1e6=Error(_0x2007ad['message']);return _0x2007ad[_0x4288a6(0x1e7)]!==void 0x0&&Object['assign'](_0x3ec1e6,{'code':_0x2007ad['code']}),_0x3ec1e6[_0x4288a6(0x1cc)]=_0x2007ad['name'],_0x3ec1e6;}function y(_0x10b364){const _0x3858b1=_0xe1d5fe;return typeof _0x10b364==_0x3858b1(0x1f7)&&!!_0x10b364&&!Array['isArray'](_0x10b364);}function b(_0xef1efd){const _0x165d90=_0xe1d5fe;S(_0xef1efd['id'],_0x165d90(0x233)),S(_0xef1efd[_0x165d90(0x225)],_0x165d90(0x1ff)),_0xef1efd[_0x165d90(0x200)]!==void 0x0&&S(_0xef1efd[_0x165d90(0x200)],_0x165d90(0x226));}function x(_0x547722){const _0x3b6522=_0xe1d5fe;return ee(_0x547722)&&typeof _0x547722['id']==_0x3b6522(0x1f3)&&_0x547722['id'][_0x3b6522(0x210)]>0x0&&typeof _0x547722[_0x3b6522(0x225)]==_0x3b6522(0x1f3)&&_0x547722['version'][_0x3b6522(0x210)]>0x0&&(_0x547722[_0x3b6522(0x200)]===void 0x0||typeof _0x547722[_0x3b6522(0x200)]=='string'&&_0x547722['buildId'][_0x3b6522(0x210)]>0x0);}function S(_0x46ece9,_0x62544e){const _0x10f2d4=_0xe1d5fe;if(_0x46ece9[_0x10f2d4(0x210)]===0x0)throw Error(_0x62544e+_0x10f2d4(0x1ca));}function ee(_0x3f10fd){const _0x33fc43=_0xe1d5fe;return typeof _0x3f10fd=='object'&&!!_0x3f10fd&&!Array[_0x33fc43(0x1f0)](_0x3f10fd);}var C=0x1,w=_0xe1d5fe(0x218),T=_0xe1d5fe(0x1f2);function E(_0xf6917d){const _0x52b26c=_0xe1d5fe;return _0xf6917d[_0x52b26c(0x1e0)]('daemon.');}var D=0x2710,O=0x19;function k(_0x19e8fd){const _0x2cd65f=_0xe1d5fe;b(_0x19e8fd['identity']);let _0x544c5b=m(_0x19e8fd[_0x2cd65f(0x1c7)]),_0x640e10=_0x19e8fd[_0x2cd65f(0x217)]??0x7530,_0xe074c5=_0x19e8fd['startTimeoutMs']??0x2710,_0x401fa3=_0x19e8fd[_0x2cd65f(0x1f6)]??D;z(_0x640e10,_0x2cd65f(0x217)),z(_0xe074c5,_0x2cd65f(0x1c2)),z(_0x401fa3,_0x2cd65f(0x1f6));let _0x579d0d=()=>({'socketPath':_0x19e8fd['socketPath'],'state':_0x2cd65f(0x1ee)}),_0x28abe9=async()=>{const _0x3607b5=_0x2cd65f;try{let _0xc9bfda=N(await p(_0x19e8fd[_0x3607b5(0x1e1)],w,null,_0x640e10),_0x19e8fd[_0x3607b5(0x1e1)]),_0x324090=te(_0x19e8fd[_0x3607b5(0x1d1)],_0xc9bfda);return _0x324090===void 0x0?_0xc9bfda:ne(_0x19e8fd[_0x3607b5(0x1d1)],_0xc9bfda,_0x324090,_0x19e8fd[_0x3607b5(0x1e1)]);}catch(_0x54fb76){if(h(_0x54fb76))return _0x579d0d();let _0x223e0c=L(_0x54fb76);return _0x223e0c['code']===_0x3607b5(0x1e4)?j(_0x19e8fd['identity'],_0x3607b5(0x219),_0x19e8fd[_0x3607b5(0x1e1)],_0x223e0c):_0x223e0c[_0x3607b5(0x1e7)]===_0x3607b5(0x208)?j(_0x19e8fd[_0x3607b5(0x1d1)],'invalid-health',_0x19e8fd[_0x3607b5(0x1e1)],_0x223e0c):{'diagnostic':_0x223e0c,'socketPath':_0x19e8fd[_0x3607b5(0x1e1)],'state':_0x3607b5(0x1df)};}},_0x16f9e8=async()=>{const _0x94213e=_0x2cd65f;let _0x32c9d4=await _0x28abe9();if(_0x32c9d4[_0x94213e(0x1f8)]===_0x94213e(0x1ea))return{..._0x32c9d4,'started':!0x1};if(_0x32c9d4['state']!==_0x94213e(0x1ee))throw M(_0x32c9d4);return{...await f({'entry':_0x544c5b,'options':_0x19e8fd,'ready':async()=>{const _0x30310a=_0x94213e;let _0x418c25=await _0x28abe9();if(_0x418c25[_0x30310a(0x1f8)]===_0x30310a(0x1ee))throw F(_0x19e8fd[_0x30310a(0x1e1)]);if(_0x418c25[_0x30310a(0x1f8)]!==_0x30310a(0x1ea))throw M(_0x418c25);return _0x418c25;},'timeoutMs':_0xe074c5}),'started':!0x0};},_0x5303e9=async()=>{const _0xdcad6=_0x2cd65f;let _0xcb798f=await _0x28abe9();if(_0xcb798f[_0xdcad6(0x1f8)]===_0xdcad6(0x1ee))return{..._0xcb798f,'stopped':!0x1};if(_0xcb798f[_0xdcad6(0x1f8)]!==_0xdcad6(0x1ea)&&!A(_0xcb798f))throw M(_0xcb798f);try{await p(_0x19e8fd['socketPath'],T,null,_0x640e10);}catch(_0x569dbd){if(!I(_0x569dbd))throw _0x569dbd;}return await P(_0x28abe9,_0x401fa3),{..._0x579d0d(),'stopped':!0x0};};return{async 'restart'(){const _0x572974=_0x2cd65f;let _0x475607=await _0x28abe9();if(_0x475607[_0x572974(0x1f8)]!==_0x572974(0x1ea)&&_0x475607[_0x572974(0x1f8)]!==_0x572974(0x1ee)&&!A(_0x475607))throw M(_0x475607);(_0x475607[_0x572974(0x1f8)]===_0x572974(0x1ea)||A(_0x475607))&&await _0x5303e9();let _0x39eccc=await _0x16f9e8(),_0x4686e9=_0x475607['state']===_0x572974(0x1ea)?_0x475607[_0x572974(0x227)]:A(_0x475607)?_0x475607[_0x572974(0x21b)][_0x572974(0x227)]:void 0x0;return{'identity':_0x39eccc['identity'],'pid':_0x39eccc[_0x572974(0x227)],..._0x4686e9===void 0x0?{}:{'previousPid':_0x4686e9},'restarted':_0x475607[_0x572974(0x1f8)]!==_0x572974(0x1ee),'protocolVersion':_0x39eccc['protocolVersion'],'socketPath':_0x39eccc[_0x572974(0x1e1)],'startedAt':_0x39eccc[_0x572974(0x236)],'state':_0x572974(0x1ea)};},'start':_0x16f9e8,'status':_0x28abe9,'stop':_0x5303e9};}function A(_0x27f31c){const _0x12f1d6=_0xe1d5fe;return _0x27f31c[_0x12f1d6(0x1f8)]===_0x12f1d6(0x1d4)&&_0x27f31c[_0x12f1d6(0x21b)]!==void 0x0&&(_0x27f31c[_0x12f1d6(0x1cf)]===_0x12f1d6(0x235)||_0x27f31c[_0x12f1d6(0x1cf)]==='build-id-mismatch');}function te(_0x5c479c,_0x4c60ce){const _0x2bbe02=_0xe1d5fe;if(_0x4c60ce[_0x2bbe02(0x22c)]!==0x1)return _0x2bbe02(0x20b);if(_0x4c60ce[_0x2bbe02(0x1d1)]['id']!==_0x5c479c['id'])return _0x2bbe02(0x211);if(_0x4c60ce['identity'][_0x2bbe02(0x225)]!==_0x5c479c[_0x2bbe02(0x225)])return'version-mismatch';if(_0x5c479c[_0x2bbe02(0x200)]!==void 0x0&&_0x4c60ce[_0x2bbe02(0x1d1)][_0x2bbe02(0x200)]!==_0x5c479c[_0x2bbe02(0x200)])return'build-id-mismatch';}function ne(_0x40d67e,_0x4c9fa9,_0x474e89,_0x304281){const _0xedc86c=_0xe1d5fe;return{'actual':{'identity':_0x4c9fa9[_0xedc86c(0x1d1)],'pid':_0x4c9fa9[_0xedc86c(0x227)],'protocolVersion':_0x4c9fa9[_0xedc86c(0x22c)],'socketPath':_0x4c9fa9[_0xedc86c(0x1e1)],'startedAt':_0x4c9fa9[_0xedc86c(0x236)]},'expected':{'identity':_0x40d67e,'protocolVersion':0x1},'reason':_0x474e89,'socketPath':_0x304281,'state':_0xedc86c(0x1d4)};}function j(_0x3da92a,_0x2e4df4,_0x1a1831,_0x22bbd3){const _0x5d081e=_0xe1d5fe;return{'diagnostic':_0x22bbd3,'expected':{'identity':_0x3da92a,'protocolVersion':0x1},'reason':_0x2e4df4,'socketPath':_0x1a1831,'state':_0x5d081e(0x1d4)};}function M(_0x1cd941){const _0x3c9014=_0xe1d5fe;let _0x49a779=_0x1cd941[_0x3c9014(0x1f8)]===_0x3c9014(0x1d4)?_0x1cd941['reason']:_0x1cd941[_0x3c9014(0x220)]['message'];return R(_0x1cd941[_0x3c9014(0x1f8)]===_0x3c9014(0x1d4)?_0x3c9014(0x1c4):_0x3c9014(0x209),_0x3c9014(0x20d)+_0x49a779);}function N(_0x3e6ae9,_0x43107b){const _0x522400=_0xe1d5fe;if(!B(_0x3e6ae9)||_0x3e6ae9['state']!=='running'||_0x3e6ae9[_0x522400(0x1e1)]!==_0x43107b||!x(_0x3e6ae9[_0x522400(0x1d1)])||typeof _0x3e6ae9['pid']!=_0x522400(0x1e6)||!Number[_0x522400(0x1cb)](_0x3e6ae9['pid'])||_0x3e6ae9['pid']<=0x0||typeof _0x3e6ae9[_0x522400(0x22c)]!='number'||!Number[_0x522400(0x1cb)](_0x3e6ae9['protocolVersion'])||_0x3e6ae9['protocolVersion']<=0x0||typeof _0x3e6ae9[_0x522400(0x236)]!='string'||Number[_0x522400(0x20c)](Date[_0x522400(0x1fd)](_0x3e6ae9[_0x522400(0x236)])))throw R('DAEMON_CONTROL_INVALID_RESPONSE',_0x522400(0x21e));return{'identity':_0x3e6ae9[_0x522400(0x1d1)],'pid':_0x3e6ae9['pid'],'protocolVersion':_0x3e6ae9[_0x522400(0x22c)],'socketPath':_0x43107b,'startedAt':_0x3e6ae9['startedAt'],'state':_0x522400(0x1ea)};}async function P(_0x57e287,_0x506e7d){const _0x39d9dc=_0xe1d5fe;let _0x597151=Date[_0x39d9dc(0x1d5)]();for(;Date[_0x39d9dc(0x1d5)]()-_0x597151<_0x506e7d;){if((await _0x57e287())[_0x39d9dc(0x1f8)]===_0x39d9dc(0x1ee))return;await new Promise(_0x8d8ff9=>setTimeout(_0x8d8ff9,O));}throw R(_0x39d9dc(0x205),_0x39d9dc(0x1ef)+String(_0x506e7d)+'ms');}function F(_0x13651c){const _0x1bb8f7=_0xe1d5fe;return Object['assign'](Error(_0x1bb8f7(0x202)+_0x13651c),{'code':'ECONNREFUSED'});}function I(_0x47f18c){const _0x8b04b=_0xe1d5fe;return h(_0x47f18c)||B(_0x47f18c)&&(_0x47f18c['code']===_0x8b04b(0x1c8)||_0x47f18c[_0x8b04b(0x1e7)]==='ECONNRESET'||_0x47f18c[_0x8b04b(0x1e7)]===_0x8b04b(0x221)||_0x47f18c[_0x8b04b(0x1e7)]==='EPIPE');}function L(_0x4c313a){const _0x380e30=_0xe1d5fe;let _0x5420c0=_0x4c313a instanceof Error?_0x4c313a['message']:String(_0x4c313a);return B(_0x4c313a)&&typeof _0x4c313a[_0x380e30(0x1e7)]=='string'?{'code':_0x4c313a[_0x380e30(0x1e7)],'message':_0x5420c0}:{'message':_0x5420c0};}function R(_0x3235b9,_0x3eb593){const _0x34873c=_0xe1d5fe;return Object[_0x34873c(0x22d)](Error(_0x3eb593),{'code':_0x3235b9});}function z(_0x1c401d,_0xef5c69){const _0x628c7=_0xe1d5fe;if(!Number[_0x628c7(0x1e3)](_0x1c401d)||_0x1c401d<=0x0)throw Error(_0xef5c69+_0x628c7(0x21f));}function B(_0x270a29){const _0x4c9d24=_0xe1d5fe;return typeof _0x270a29==_0x4c9d24(0x1f7)&&!!_0x270a29&&!Array[_0x4c9d24(0x1f0)](_0x270a29);}function V(_0xe8ada7){let _0x5a9420=_0xe8ada7['requestTimeoutMs']??0x7530,_0x356c3e=k(_0xe8ada7),_0x37b840,_0x588279=async()=>{const _0x1c0fcc=_0x4e15;let _0x2be2bf=await _0x356c3e[_0x1c0fcc(0x203)]();if(_0x2be2bf[_0x1c0fcc(0x1f8)]===_0x1c0fcc(0x1ea))return _0x2be2bf;if(_0x2be2bf[_0x1c0fcc(0x1f8)]!=='stopped')throw M(_0x2be2bf);let _0x545b43=_0x37b840??=_0x356c3e['start']();try{return await _0x545b43;}finally{_0x37b840===_0x545b43&&(_0x37b840=void 0x0);}};return{async 'request'(_0x198785,_0x33c651){const _0x409bbf=_0x4e15;if(_0x198785[_0x409bbf(0x210)]===0x0)throw Error('Daemon\x20method\x20must\x20not\x20be\x20empty');await _0x588279();try{return await p(_0xe8ada7[_0x409bbf(0x1e1)],_0x198785,_0x33c651,_0x5a9420);}catch(_0x568f3d){if(!h(_0x568f3d))throw _0x568f3d;}return await _0x588279(),await p(_0xe8ada7[_0x409bbf(0x1e1)],_0x198785,_0x33c651,_0x5a9420);}};}function H(_0x59cb1f){const _0x47b937=_0xe1d5fe;oe(_0x59cb1f[_0x47b937(0x1e1)]),b(_0x59cb1f['identity']);let _0x33c7f2=new Map(),_0x2bd588=new Set(),_0x318c42,_0x38c9c8=!0x1,_0x5e7f77,_0x5ca006,_0x527206={async 'close'(){_0x5e7f77??=_0x572209(),await _0x5e7f77;},'handle'(_0x420ef6,_0x3d52c8){const _0xe8a6c8=_0x47b937;if(_0x38c9c8)throw Error(_0xe8a6c8(0x20f));if(_0x420ef6[_0xe8a6c8(0x210)]===0x0)throw Error('Daemon\x20method\x20must\x20not\x20be\x20empty');if(E(_0x420ef6))throw Error('Daemon\x20method\x20namespace\x20is\x20reserved:\x20'+_0x420ef6);if(_0x33c7f2[_0xe8a6c8(0x1d2)](_0x420ef6))throw Error(_0xe8a6c8(0x1ed)+_0x420ef6+_0xe8a6c8(0x1e5));_0x33c7f2['set'](_0x420ef6,_0x3d52c8);},async 'listen'(){const _0x34024=_0x47b937;if(!_0x38c9c8){if(_0x5e7f77)throw Error('Daemon\x20server\x20is\x20closed');await _0x4fc4af(_0x3ca711(_0x59cb1f[_0x34024(0x1e1)]),{'recursive':!0x0}),await Y(_0x59cb1f['socketPath']),_0x318c42=_0x2d7721(_0x41863b=>U(_0x41863b,_0x33c7f2,_0x2bd588,{'shutdown':()=>{const _0x561abc=_0x34024;_0x527206[_0x561abc(0x20e)]()[_0x561abc(0x223)](()=>{process['exitCode']=0x1;});},'status':()=>G(_0x59cb1f['identity'],_0x59cb1f[_0x34024(0x1e1)],_0x5ca006)})),await new Promise((_0x1af260,_0x20f401)=>{const _0x3aa3d5=_0x34024;let _0x516f67=_0x318c42,_0x32764d=_0x2d609f=>_0x20f401(ae(_0x2d609f)?Z(_0x59cb1f[_0x3aa3d5(0x1e1)]):_0x2d609f);_0x516f67['once']('error',_0x32764d),_0x516f67[_0x3aa3d5(0x1c9)](_0x59cb1f[_0x3aa3d5(0x1e1)],()=>{_0x516f67['off']('error',_0x32764d),_0x38c9c8=!0x0,_0x5ca006=new Date()['toISOString'](),_0x1af260();});});}}};return _0x527206;async function _0x572209(){const _0x37ef0c=_0x47b937;for(let _0x3962cd of _0x2bd588)_0x3962cd['destroy']();_0x2bd588['clear'](),_0x318c42&&_0x38c9c8&&await new Promise((_0x11a08c,_0x1d31b5)=>{const _0x5b4545=_0x4e15;_0x318c42[_0x5b4545(0x20e)](_0x2bfd79=>_0x2bfd79?_0x1d31b5(_0x2bfd79):_0x11a08c());}),_0x38c9c8=!0x1;try{await _0x59cb1f[_0x37ef0c(0x1d8)]?.();}finally{await re(_0x59cb1f[_0x37ef0c(0x1e1)]);}}}function U(_0x66c11b,_0x35f277,_0x3bea8f,_0x3a1538){const _0x1eaf2e=_0xe1d5fe;_0x3bea8f[_0x1eaf2e(0x1de)](_0x66c11b);let _0x12e257=!0x1,_0x153920=u(_0x21a48b=>{_0x12e257||(_0x12e257=!0x0,W(_0x66c11b,_0x21a48b,_0x35f277,_0x3a1538));});_0x66c11b['on'](_0x1eaf2e(0x239),_0x4e088d=>_0x153920[_0x1eaf2e(0x1f9)](_0x4e088d)),_0x66c11b['on']('end',()=>_0x153920['end']()),_0x66c11b['on']('close',()=>_0x3bea8f[_0x1eaf2e(0x1f5)](_0x66c11b)),_0x66c11b['on']('error',()=>_0x66c11b[_0x1eaf2e(0x232)]());}async function W(_0xc14baa,_0xe504b8,_0x660b13,_0x57d530){const _0x275d53=_0xe1d5fe;let _0x4159cc=_0x275d53(0x234),_0x3523a3,_0x3f5fb6=!0x1;try{let _0x47f3b1=K(_0xe504b8);_0x4159cc=_0x47f3b1['id'];let _0x2e27c4;if(_0x47f3b1[_0x275d53(0x22b)]==='daemon.status'){let _0x48a009=_0x57d530[_0x275d53(0x203)]();_0x2e27c4={'identity':{..._0x48a009[_0x275d53(0x1d1)]['buildId']===void 0x0?{}:{'buildId':_0x48a009[_0x275d53(0x1d1)]['buildId']},'id':_0x48a009[_0x275d53(0x1d1)]['id'],'version':_0x48a009['identity'][_0x275d53(0x225)]},'pid':_0x48a009[_0x275d53(0x227)],'protocolVersion':_0x48a009[_0x275d53(0x22c)],'socketPath':_0x48a009[_0x275d53(0x1e1)],'startedAt':_0x48a009[_0x275d53(0x236)],'state':_0x48a009[_0x275d53(0x1f8)]};}else{if(_0x47f3b1[_0x275d53(0x22b)]===_0x275d53(0x1f2))_0x2e27c4=null,_0x3f5fb6=!0x0;else{let _0x4b823d=_0x660b13[_0x275d53(0x231)](_0x47f3b1['method']);if(!_0x4b823d)throw J('DAEMON_METHOD_NOT_FOUND',_0x275d53(0x1da)+_0x47f3b1[_0x275d53(0x22b)]);_0x2e27c4=await _0x4b823d(_0x47f3b1['payload']);}}_0x3523a3={'id':_0x4159cc,'result':_0x2e27c4,'type':'result'};}catch(_0x495d10){_0x3523a3={'error':q(_0x495d10),'id':_0x4159cc,'type':_0x275d53(0x206)};}_0xc14baa[_0x275d53(0x1db)](l(_0x3523a3),()=>{_0x3f5fb6&&_0x57d530['shutdown']();});}function G(_0x2426c9,_0xe2c45,_0x32aa5e){const _0x19ecb6=_0xe1d5fe;if(_0x32aa5e===void 0x0)throw Error(_0x19ecb6(0x1c1));return{'identity':_0x2426c9,'pid':process[_0x19ecb6(0x227)],'protocolVersion':0x1,'socketPath':_0xe2c45,'startedAt':_0x32aa5e,'state':_0x19ecb6(0x1ea)};}function K(_0xd3cdca){const _0x9045dc=_0xe1d5fe;let _0x1de749=JSON[_0x9045dc(0x1fd)](_0xd3cdca);if(!$(_0x1de749)||typeof _0x1de749['id']!=_0x9045dc(0x1f3)||typeof _0x1de749[_0x9045dc(0x22b)]!=_0x9045dc(0x1f3)||!(_0x9045dc(0x224)in _0x1de749))throw J(_0x9045dc(0x22a),'Invalid\x20daemon\x20request');return _0x1de749;}function q(_0x3cf9c5){const _0x469945=_0xe1d5fe;if(_0x3cf9c5 instanceof Error){let _0x2ab3ec=_0x3cf9c5[_0x469945(0x1e7)];return{...typeof _0x2ab3ec==_0x469945(0x1f3)?{'code':_0x2ab3ec}:{},'message':_0x3cf9c5['message'],'name':_0x3cf9c5[_0x469945(0x1cc)]};}return{'message':String(_0x3cf9c5),'name':'Error'};}function J(_0x544f8a,_0x47f155){const _0x2be7dc=_0xe1d5fe;return Object[_0x2be7dc(0x22d)](Error(_0x47f155),{'code':_0x544f8a});}async function Y(_0x38b52b){const _0x393dc9=_0xe1d5fe;try{if(!(await _0xad2aa4(_0x38b52b))[_0x393dc9(0x212)]())throw Error(_0x393dc9(0x1c5)+_0x38b52b);if(await X(_0x38b52b))throw Z(_0x38b52b);await _0x364a79(_0x38b52b);}catch(_0x3a3ab0){if(Q(_0x3a3ab0))return;throw _0x3a3ab0;}}function X(_0x2c1e6d){return new Promise((_0x528fa1,_0x5b4178)=>{const _0x203c54=_0x4e15;let _0x513010=_0x198d50(_0x2c1e6d);_0x513010[_0x203c54(0x228)](_0x203c54(0x21c),()=>{const _0x287ee5=_0x203c54;_0x513010[_0x287ee5(0x232)](),_0x528fa1(!0x0);}),_0x513010['once'](_0x203c54(0x206),_0x4d7940=>{const _0x11952e=_0x203c54;_0x513010[_0x11952e(0x232)](),ie(_0x4d7940)||Q(_0x4d7940)?_0x528fa1(!0x1):_0x5b4178(_0x4d7940);});});}function Z(_0x545aa2){const _0x33739c=_0xe1d5fe;return Object[_0x33739c(0x22d)](Error(_0x33739c(0x214)+_0x545aa2),{'code':_0x33739c(0x1c3)});}async function re(_0x2544c2){const _0x557271=_0xe1d5fe;try{(await _0xad2aa4(_0x2544c2))[_0x557271(0x212)]()&&await _0x364a79(_0x2544c2);}catch(_0x42ed46){if(!Q(_0x42ed46))throw _0x42ed46;}}function Q(_0x4e2cb3){const _0x5c837c=_0xe1d5fe;return $(_0x4e2cb3)&&_0x4e2cb3[_0x5c837c(0x1e7)]===_0x5c837c(0x1e9);}function _0x4e15(_0x10746a,_0x492a8a){_0x10746a=_0x10746a-0x1c1;const _0x2e88fd=_0x2e88();let _0x4e1566=_0x2e88fd[_0x10746a];return _0x4e1566;}function ie(_0x28a419){const _0x569ba5=_0xe1d5fe;return $(_0x28a419)&&_0x28a419[_0x569ba5(0x1e7)]==='ECONNREFUSED';}function ae(_0x46c360){const _0x76fac7=_0xe1d5fe;return $(_0x46c360)&&_0x46c360[_0x76fac7(0x1e7)]===_0x76fac7(0x1d6);}function oe(_0x55279c){const _0x33cc3a=_0xe1d5fe;if(_0x55279c[_0x33cc3a(0x210)]===0x0)throw Error(_0x33cc3a(0x1cd));}function $(_0x1526ea){const _0x5d950e=_0xe1d5fe;return typeof _0x1526ea=='object'&&!!_0x1526ea&&!Array[_0x5d950e(0x1f0)](_0x1526ea);}export{C as DAEMON_PROTOCOL_VERSION,T as DAEMON_SHUTDOWN_METHOD,d as DAEMON_SOCKET_ENV,w as DAEMON_STATUS_METHOD,V as createDaemonClient,k as createDaemonControl,H as createDaemonServer};
1
+ const _0x20a7fc=_0x58a8;(function(_0x1f66d9,_0x52852c){const _0x334aad=_0x58a8,_0x33381a=_0x1f66d9();while(!![]){try{const _0xb174bd=-parseInt(_0x334aad(0x1b9))/0x1+-parseInt(_0x334aad(0x19d))/0x2+-parseInt(_0x334aad(0x1a3))/0x3*(parseInt(_0x334aad(0x194))/0x4)+-parseInt(_0x334aad(0x18d))/0x5+-parseInt(_0x334aad(0x16a))/0x6*(parseInt(_0x334aad(0x1a1))/0x7)+-parseInt(_0x334aad(0x17d))/0x8*(parseInt(_0x334aad(0x193))/0x9)+parseInt(_0x334aad(0x1bd))/0xa*(parseInt(_0x334aad(0x15e))/0xb);if(_0xb174bd===_0x52852c)break;else _0x33381a['push'](_0x33381a['shift']());}catch(_0x22f5d8){_0x33381a['push'](_0x33381a['shift']());}}}(_0x5ca2,0x760b1));import{randomUUID as _0xcdab0b}from'node:crypto';import{spawn as _0x390b02}from'node:child_process';import{connect as _0xd5a2b2,createServer as _0x17ded6}from'node:net';import{fileURLToPath as _0x5b54ca}from'node:url';import{lstat as _0x4833a8,mkdir as _0x43614e,unlink as _0x6196e9}from'node:fs/promises';import{dirname as _0x1de26a}from'node:path';function l(_0x4f56cf){const _0x16b00f=_0x58a8;return JSON[_0x16b00f(0x1ae)](_0x4f56cf)+'\x0a';}function u(_0x3718da){let _0x4ab003='';return{'end'(){const _0x219981=_0x58a8;_0x4ab003['trim']()[_0x219981(0x1d5)]>0x0&&_0x3718da(_0x4ab003),_0x4ab003='';},'push'(_0x20bbdf){const _0x1a871c=_0x58a8;for(_0x4ab003+=_0x20bbdf[_0x1a871c(0x1cb)]('utf8');;){let _0x21002c=_0x4ab003[_0x1a871c(0x1ac)]('\x0a');if(_0x21002c<0x0)return;let _0x473565=_0x4ab003[_0x1a871c(0x182)](0x0,_0x21002c);_0x4ab003=_0x4ab003['slice'](_0x21002c+0x1),_0x473565['trim']()[_0x1a871c(0x1d5)]>0x0&&_0x3718da(_0x473565);}}};}var d=_0x20a7fc(0x16b);async function f(_0x53acec){const _0x9b9128=_0x20a7fc;_0x390b02(process[_0x9b9128(0x186)],[_0x5b54ca(_0x53acec[_0x9b9128(0x179)])],{'detached':!0x0,'env':{...process.env,..._0x53acec[_0x9b9128(0x15f)][_0x9b9128(0x1d3)],[d]:_0x53acec['options'][_0x9b9128(0x16e)]},'stdio':'ignore'})[_0x9b9128(0x1b3)]();let _0x1b381f=Date[_0x9b9128(0x18b)]();for(;Date[_0x9b9128(0x18b)]()-_0x1b381f<_0x53acec[_0x9b9128(0x184)];){try{return await _0x53acec[_0x9b9128(0x1ad)]();}catch(_0x5100fe){if(!h(_0x5100fe))throw _0x5100fe;}await new Promise(_0x54ad7c=>setTimeout(_0x54ad7c,0x19));}throw Object[_0x9b9128(0x17a)](Error(_0x9b9128(0x163)+String(_0x53acec[_0x9b9128(0x184)])+'ms'),{'code':'DAEMON_START_TIMEOUT'});}function _0x5ca2(){const _0x336ac8=['actual','invalid-health','Daemon\x20request\x20timed\x20out\x20after\x20','file:','unref','exitCode','unknown','daemon.status','DAEMON_UNREACHABLE','get','873593AxmdwQ','buildId','identity.version','Daemon\x20connection\x20closed\x20before\x20a\x20response\x20was\x20received','10UwQAQx','DAEMON_CONNECTION_CLOSED','Daemon\x20entry\x20must\x20be\x20an\x20absolute\x20file\x20URL','status','DAEMON_CONTROL_INVALID_RESPONSE','legacy-protocol','toISOString','\x20must\x20not\x20be\x20empty','ECONNRESET','build-id-mismatch','version-mismatch','name','DAEMON_METHOD_NOT_FOUND','identity.id','toString','onShutdown','DAEMON_INCOMPATIBLE','stopTimeoutMs','EADDRINUSE','has','close','data','env','add','length','protocolVersion','running','A\x20daemon\x20is\x20already\x20listening\x20on\x20','protocol','startsWith','DAEMON_STOP_TIMEOUT','isArray','startTimeoutMs','stopped','diagnostic','33323873SZDqOw','options','push','Daemon\x20is\x20not\x20listening\x20on\x20','start','Daemon\x20did\x20not\x20start\x20within\x20','Refusing\x20to\x20replace\x20non-socket\x20path\x20','number','Unknown\x20daemon\x20method\x20','Daemon\x20status\x20response\x20is\x20invalid','daemon.shutdown','object','21678lGleJh','UNIVER_CLI_SDK_DAEMON_SOCKET','once','ENOENT','socketPath','error','end','clear','requestTimeoutMs','Daemon\x20method\x20namespace\x20is\x20reserved:\x20','reason','isNaN','ECONNREFUSED','type','href','entry','assign','isFinite','startedAt','29080fWxyNy','Daemon\x20method\x20must\x20not\x20be\x20empty','Daemon\x20did\x20not\x20stop\x20within\x20','Invalid\x20daemon\x20request','Invalid\x20daemon\x20response','slice','delete','timeoutMs','message','execPath','off','Daemon\x20is\x20not\x20ready:\x20','parse','identity','now','connect','1822280BWlAZY','destroy','incompatible','state','string','listen','1854HJRkfV','1670444bTATpX','pid','catch','socketPath\x20must\x20not\x20be\x20empty','EPIPE','isSocket','payload','result','DAEMON_INVALID_REQUEST','116738fLcpWD','protocol-mismatch','set','identity.buildId','161qZVgLv','\x20is\x20already\x20registered','3UrbvlC','isSafeInteger','Daemon\x20server\x20has\x20not\x20started\x20listening','write','method','Daemon\x20handlers\x20must\x20be\x20registered\x20before\x20listen()','Daemon\x20method\x20','code','version','indexOf','ready','stringify'];_0x5ca2=function(){return _0x336ac8;};return _0x5ca2();}function p(_0x223e05,_0x22d219,_0x17da05,_0x5eb01c){return new Promise((_0x3e807a,_0x1ada43)=>{const _0x119a16=_0x58a8;let _0x2b5fc7=_0xd5a2b2(_0x223e05),_0x4d177d=_0xcdab0b(),_0x1ef6dd=!0x1,_0x377c94=setTimeout(()=>{const _0x25e8a1=_0x58a8;_0x2b5fc7[_0x25e8a1(0x18e)](),_0x1ada43(Object[_0x25e8a1(0x17a)](Error(_0x25e8a1(0x1b1)+String(_0x5eb01c)+'ms'),{'code':'DAEMON_REQUEST_TIMEOUT'}));},_0x5eb01c),_0x49007e=_0x31f51d=>{_0x1ef6dd||(_0x1ef6dd=!0x0,clearTimeout(_0x377c94),_0x31f51d());},_0x448c12=u(_0x43024d=>{try{let _0xc402fa=_(_0x43024d,_0x4d177d);_0x49007e(()=>{const _0x27a582=_0x58a8;_0x2b5fc7[_0x27a582(0x170)](),_0xc402fa[_0x27a582(0x177)]===_0x27a582(0x16f)?_0x1ada43(v(_0xc402fa[_0x27a582(0x16f)])):_0x3e807a(_0xc402fa['result']);});}catch(_0x29205c){_0x49007e(()=>{const _0x1fd662=_0x58a8;_0x2b5fc7[_0x1fd662(0x18e)](),_0x1ada43(_0x29205c);});}});_0x2b5fc7[_0x119a16(0x16c)]('error',_0x10e904=>_0x49007e(()=>{const _0x353f71=_0x119a16;_0x2b5fc7[_0x353f71(0x18e)](),_0x1ada43(_0x10e904);})),_0x2b5fc7['on'](_0x119a16(0x1d2),_0x2c0f9c=>_0x448c12[_0x119a16(0x160)](_0x2c0f9c)),_0x2b5fc7['on'](_0x119a16(0x170),()=>{const _0x349b47=_0x119a16;_0x448c12[_0x349b47(0x170)](),_0x49007e(()=>{const _0x2b0d16=_0x349b47;_0x2b5fc7[_0x2b0d16(0x18e)](),_0x1ada43(g());});}),_0x2b5fc7['on']('close',()=>_0x49007e(()=>{const _0x203d69=_0x119a16;_0x2b5fc7[_0x203d69(0x18e)](),_0x1ada43(g());})),_0x2b5fc7[_0x119a16(0x16c)]('connect',()=>{const _0x2a6310=_0x119a16;_0x2b5fc7[_0x2a6310(0x1a6)](l({'id':_0x4d177d,'method':_0x22d219,'payload':_0x17da05}));});});}function m(_0x29963c){const _0x1eb646=_0x20a7fc;let _0x16ddf1=_0x29963c instanceof URL?_0x29963c[_0x1eb646(0x178)]:_0x29963c;try{let _0x5cdb52=new URL(_0x16ddf1);if(_0x5cdb52[_0x1eb646(0x1d9)]!==_0x1eb646(0x1b2))throw Error();return _0x5cdb52[_0x1eb646(0x178)];}catch{throw Error(_0x1eb646(0x1bf));}}function h(_0x5ee7a3){const _0x3a618f=_0x20a7fc;return y(_0x5ee7a3)?_0x5ee7a3[_0x3a618f(0x1aa)]===_0x3a618f(0x16d)||_0x5ee7a3[_0x3a618f(0x1aa)]===_0x3a618f(0x176):!0x1;}function g(){const _0x1b309c=_0x20a7fc;return Object['assign'](Error(_0x1b309c(0x1bc)),{'code':_0x1b309c(0x1be)});}function _(_0x27da51,_0x4ccfa5){const _0x176dfb=_0x20a7fc;let _0x578d96=JSON['parse'](_0x27da51);if(!y(_0x578d96)||_0x578d96['id']!==_0x4ccfa5)throw Error('Invalid\x20daemon\x20response');if(_0x578d96[_0x176dfb(0x177)]===_0x176dfb(0x19b)&&_0x176dfb(0x19b)in _0x578d96||_0x578d96[_0x176dfb(0x177)]===_0x176dfb(0x16f)&&y(_0x578d96['error']))return _0x578d96;throw Error(_0x176dfb(0x181));}function v(_0x17e281){const _0x1305cc=_0x20a7fc;let _0x1bd90b=Error(_0x17e281[_0x1305cc(0x185)]);return _0x17e281[_0x1305cc(0x1aa)]!==void 0x0&&Object[_0x1305cc(0x17a)](_0x1bd90b,{'code':_0x17e281[_0x1305cc(0x1aa)]}),_0x1bd90b[_0x1305cc(0x1c8)]=_0x17e281[_0x1305cc(0x1c8)],_0x1bd90b;}function y(_0x308ea5){const _0x38709f=_0x20a7fc;return typeof _0x308ea5==_0x38709f(0x169)&&!!_0x308ea5&&!Array[_0x38709f(0x1dc)](_0x308ea5);}function b(_0x2cb8bc){const _0x1d38c3=_0x20a7fc;S(_0x2cb8bc['id'],_0x1d38c3(0x1ca)),S(_0x2cb8bc[_0x1d38c3(0x1ab)],_0x1d38c3(0x1bb)),_0x2cb8bc['buildId']!==void 0x0&&S(_0x2cb8bc['buildId'],_0x1d38c3(0x1a0));}function x(_0x3883e1){const _0xea975f=_0x20a7fc;return ee(_0x3883e1)&&typeof _0x3883e1['id']==_0xea975f(0x191)&&_0x3883e1['id'][_0xea975f(0x1d5)]>0x0&&typeof _0x3883e1[_0xea975f(0x1ab)]==_0xea975f(0x191)&&_0x3883e1[_0xea975f(0x1ab)][_0xea975f(0x1d5)]>0x0&&(_0x3883e1[_0xea975f(0x1ba)]===void 0x0||typeof _0x3883e1['buildId']==_0xea975f(0x191)&&_0x3883e1['buildId'][_0xea975f(0x1d5)]>0x0);}function S(_0xfca21d,_0x4f9c6f){const _0x3d8685=_0x20a7fc;if(_0xfca21d[_0x3d8685(0x1d5)]===0x0)throw Error(_0x4f9c6f+_0x3d8685(0x1c4));}function ee(_0x1dd593){const _0x1e1682=_0x20a7fc;return typeof _0x1dd593==_0x1e1682(0x169)&&!!_0x1dd593&&!Array[_0x1e1682(0x1dc)](_0x1dd593);}var C=0x1,w=_0x20a7fc(0x1b6),T=_0x20a7fc(0x168);function _0x58a8(_0x22959b,_0x59469b){_0x22959b=_0x22959b-0x15d;const _0x5ca2f8=_0x5ca2();let _0x58a88b=_0x5ca2f8[_0x22959b];return _0x58a88b;}function E(_0x385bfb){const _0x1ced8c=_0x20a7fc;return _0x385bfb[_0x1ced8c(0x1da)]('daemon.');}var D=0x2710,O=0x19;function k(_0x2f05da){const _0x11804a=_0x20a7fc;b(_0x2f05da[_0x11804a(0x18a)]);let _0x335b3f=m(_0x2f05da[_0x11804a(0x179)]),_0x4f4f16=_0x2f05da[_0x11804a(0x172)]??0x7530,_0x4a32fb=_0x2f05da[_0x11804a(0x1dd)]??0x2710,_0x4a35a8=_0x2f05da['stopTimeoutMs']??D;z(_0x4f4f16,_0x11804a(0x172)),z(_0x4a32fb,_0x11804a(0x1dd)),z(_0x4a35a8,_0x11804a(0x1ce));let _0x686e84=()=>({'socketPath':_0x2f05da['socketPath'],'state':_0x11804a(0x1de)}),_0x5790e9=async()=>{const _0x2873fa=_0x11804a;try{let _0x3c279d=N(await p(_0x2f05da['socketPath'],w,null,_0x4f4f16),_0x2f05da[_0x2873fa(0x16e)]),_0x5e8e00=te(_0x2f05da[_0x2873fa(0x18a)],_0x3c279d);return _0x5e8e00===void 0x0?_0x3c279d:ne(_0x2f05da[_0x2873fa(0x18a)],_0x3c279d,_0x5e8e00,_0x2f05da['socketPath']);}catch(_0x3593e1){if(h(_0x3593e1))return _0x686e84();let _0x3530eb=L(_0x3593e1);return _0x3530eb['code']===_0x2873fa(0x1c9)?j(_0x2f05da[_0x2873fa(0x18a)],_0x2873fa(0x1c2),_0x2f05da[_0x2873fa(0x16e)],_0x3530eb):_0x3530eb[_0x2873fa(0x1aa)]===_0x2873fa(0x1c1)?j(_0x2f05da[_0x2873fa(0x18a)],_0x2873fa(0x1b0),_0x2f05da[_0x2873fa(0x16e)],_0x3530eb):{'diagnostic':_0x3530eb,'socketPath':_0x2f05da['socketPath'],'state':'unreachable'};}},_0xfe519e=async()=>{const _0x532263=_0x11804a;let _0x2f834d=await _0x5790e9();if(_0x2f834d[_0x532263(0x190)]===_0x532263(0x1d7))return{..._0x2f834d,'started':!0x1};if(_0x2f834d[_0x532263(0x190)]!==_0x532263(0x1de))throw M(_0x2f834d);return{...await f({'entry':_0x335b3f,'options':_0x2f05da,'ready':async()=>{const _0x30564a=_0x532263;let _0xe7e712=await _0x5790e9();if(_0xe7e712['state']===_0x30564a(0x1de))throw F(_0x2f05da['socketPath']);if(_0xe7e712[_0x30564a(0x190)]!==_0x30564a(0x1d7))throw M(_0xe7e712);return _0xe7e712;},'timeoutMs':_0x4a32fb}),'started':!0x0};},_0x7e6167=async()=>{const _0x346920=_0x11804a;let _0x1ffebc=await _0x5790e9();if(_0x1ffebc[_0x346920(0x190)]===_0x346920(0x1de))return{..._0x1ffebc,'stopped':!0x1};if(_0x1ffebc['state']!==_0x346920(0x1d7)&&!A(_0x1ffebc))throw M(_0x1ffebc);try{await p(_0x2f05da[_0x346920(0x16e)],T,null,_0x4f4f16);}catch(_0x16d050){if(!I(_0x16d050))throw _0x16d050;}return await P(_0x5790e9,_0x4a35a8),{..._0x686e84(),'stopped':!0x0};};return{async 'restart'(){const _0x1f5689=_0x11804a;let _0x8e977a=await _0x5790e9();if(_0x8e977a[_0x1f5689(0x190)]!=='running'&&_0x8e977a[_0x1f5689(0x190)]!=='stopped'&&!A(_0x8e977a))throw M(_0x8e977a);(_0x8e977a[_0x1f5689(0x190)]===_0x1f5689(0x1d7)||A(_0x8e977a))&&await _0x7e6167();let _0x17a0ed=await _0xfe519e(),_0x9cfc40=_0x8e977a[_0x1f5689(0x190)]==='running'?_0x8e977a[_0x1f5689(0x195)]:A(_0x8e977a)?_0x8e977a['actual'][_0x1f5689(0x195)]:void 0x0;return{'identity':_0x17a0ed[_0x1f5689(0x18a)],'pid':_0x17a0ed[_0x1f5689(0x195)],..._0x9cfc40===void 0x0?{}:{'previousPid':_0x9cfc40},'restarted':_0x8e977a[_0x1f5689(0x190)]!==_0x1f5689(0x1de),'protocolVersion':_0x17a0ed['protocolVersion'],'socketPath':_0x17a0ed[_0x1f5689(0x16e)],'startedAt':_0x17a0ed[_0x1f5689(0x17c)],'state':'running'};},'start':_0xfe519e,'status':_0x5790e9,'stop':_0x7e6167};}function A(_0x1cc0fd){const _0x521516=_0x20a7fc;return _0x1cc0fd[_0x521516(0x190)]===_0x521516(0x18f)&&_0x1cc0fd[_0x521516(0x1af)]!==void 0x0&&(_0x1cc0fd[_0x521516(0x174)]===_0x521516(0x1c7)||_0x1cc0fd['reason']===_0x521516(0x1c6));}function te(_0xa13b33,_0x39896b){const _0x2714bc=_0x20a7fc;if(_0x39896b['protocolVersion']!==0x1)return _0x2714bc(0x19e);if(_0x39896b['identity']['id']!==_0xa13b33['id'])return'identity-mismatch';if(_0x39896b[_0x2714bc(0x18a)][_0x2714bc(0x1ab)]!==_0xa13b33['version'])return _0x2714bc(0x1c7);if(_0xa13b33[_0x2714bc(0x1ba)]!==void 0x0&&_0x39896b[_0x2714bc(0x18a)][_0x2714bc(0x1ba)]!==_0xa13b33['buildId'])return _0x2714bc(0x1c6);}function ne(_0x33f761,_0x3d70ff,_0x133ae8,_0x4a534a){const _0x38ef29=_0x20a7fc;return{'actual':{'identity':_0x3d70ff[_0x38ef29(0x18a)],'pid':_0x3d70ff[_0x38ef29(0x195)],'protocolVersion':_0x3d70ff[_0x38ef29(0x1d6)],'socketPath':_0x3d70ff[_0x38ef29(0x16e)],'startedAt':_0x3d70ff[_0x38ef29(0x17c)]},'expected':{'identity':_0x33f761,'protocolVersion':0x1},'reason':_0x133ae8,'socketPath':_0x4a534a,'state':_0x38ef29(0x18f)};}function j(_0x19674d,_0x1d76f7,_0x53daef,_0x2806ab){return{'diagnostic':_0x2806ab,'expected':{'identity':_0x19674d,'protocolVersion':0x1},'reason':_0x1d76f7,'socketPath':_0x53daef,'state':'incompatible'};}function M(_0x975b9a){const _0x31331c=_0x20a7fc;let _0x38a3c8=_0x975b9a[_0x31331c(0x190)]==='incompatible'?_0x975b9a[_0x31331c(0x174)]:_0x975b9a[_0x31331c(0x15d)][_0x31331c(0x185)];return R(_0x975b9a[_0x31331c(0x190)]===_0x31331c(0x18f)?_0x31331c(0x1cd):_0x31331c(0x1b7),_0x31331c(0x188)+_0x38a3c8);}function N(_0x57f80a,_0x4e21d0){const _0x50a721=_0x20a7fc;if(!B(_0x57f80a)||_0x57f80a['state']!=='running'||_0x57f80a[_0x50a721(0x16e)]!==_0x4e21d0||!x(_0x57f80a[_0x50a721(0x18a)])||typeof _0x57f80a[_0x50a721(0x195)]!=_0x50a721(0x165)||!Number['isSafeInteger'](_0x57f80a['pid'])||_0x57f80a['pid']<=0x0||typeof _0x57f80a[_0x50a721(0x1d6)]!='number'||!Number[_0x50a721(0x1a4)](_0x57f80a[_0x50a721(0x1d6)])||_0x57f80a[_0x50a721(0x1d6)]<=0x0||typeof _0x57f80a[_0x50a721(0x17c)]!=_0x50a721(0x191)||Number[_0x50a721(0x175)](Date[_0x50a721(0x189)](_0x57f80a[_0x50a721(0x17c)])))throw R(_0x50a721(0x1c1),_0x50a721(0x167));return{'identity':_0x57f80a[_0x50a721(0x18a)],'pid':_0x57f80a[_0x50a721(0x195)],'protocolVersion':_0x57f80a[_0x50a721(0x1d6)],'socketPath':_0x4e21d0,'startedAt':_0x57f80a[_0x50a721(0x17c)],'state':_0x50a721(0x1d7)};}async function P(_0x5c18c5,_0x561fd4){const _0x576fca=_0x20a7fc;let _0x207fc5=Date[_0x576fca(0x18b)]();for(;Date['now']()-_0x207fc5<_0x561fd4;){if((await _0x5c18c5())['state']===_0x576fca(0x1de))return;await new Promise(_0x456be1=>setTimeout(_0x456be1,O));}throw R(_0x576fca(0x1db),_0x576fca(0x17f)+String(_0x561fd4)+'ms');}function F(_0x3eb2f2){const _0x3955b6=_0x20a7fc;return Object[_0x3955b6(0x17a)](Error(_0x3955b6(0x161)+_0x3eb2f2),{'code':_0x3955b6(0x176)});}function I(_0x53487d){const _0x2f5196=_0x20a7fc;return h(_0x53487d)||B(_0x53487d)&&(_0x53487d[_0x2f5196(0x1aa)]===_0x2f5196(0x1be)||_0x53487d[_0x2f5196(0x1aa)]===_0x2f5196(0x1c5)||_0x53487d[_0x2f5196(0x1aa)]==='ENOTCONN'||_0x53487d['code']===_0x2f5196(0x198));}function L(_0x1e3a1a){const _0x40a1e2=_0x20a7fc;let _0x49452b=_0x1e3a1a instanceof Error?_0x1e3a1a[_0x40a1e2(0x185)]:String(_0x1e3a1a);return B(_0x1e3a1a)&&typeof _0x1e3a1a['code']==_0x40a1e2(0x191)?{'code':_0x1e3a1a[_0x40a1e2(0x1aa)],'message':_0x49452b}:{'message':_0x49452b};}function R(_0x4f95e5,_0xd1bc97){const _0x3493a3=_0x20a7fc;return Object[_0x3493a3(0x17a)](Error(_0xd1bc97),{'code':_0x4f95e5});}function z(_0x5954d5,_0x207745){const _0x5c4caf=_0x20a7fc;if(!Number[_0x5c4caf(0x17b)](_0x5954d5)||_0x5954d5<=0x0)throw Error(_0x207745+'\x20must\x20be\x20a\x20finite\x20positive\x20number');}function B(_0x13a341){const _0x3e6aff=_0x20a7fc;return typeof _0x13a341==_0x3e6aff(0x169)&&!!_0x13a341&&!Array[_0x3e6aff(0x1dc)](_0x13a341);}function V(_0x8e3974){let _0x53c6d6=_0x8e3974['requestTimeoutMs']??0x7530,_0x3cf398=k(_0x8e3974),_0x3c838c,_0x2ed81e=async()=>{const _0x396d71=_0x58a8;let _0x24a9a5=await _0x3cf398[_0x396d71(0x1c0)]();if(_0x24a9a5['state']===_0x396d71(0x1d7))return _0x24a9a5;if(_0x24a9a5[_0x396d71(0x190)]!==_0x396d71(0x1de))throw M(_0x24a9a5);let _0xbc72f5=_0x3c838c??=_0x3cf398[_0x396d71(0x162)]();try{return await _0xbc72f5;}finally{_0x3c838c===_0xbc72f5&&(_0x3c838c=void 0x0);}};return{async 'request'(_0x1bf930,_0x5015f7){const _0x5c2961=_0x58a8;if(_0x1bf930[_0x5c2961(0x1d5)]===0x0)throw Error('Daemon\x20method\x20must\x20not\x20be\x20empty');await _0x2ed81e();try{return await p(_0x8e3974['socketPath'],_0x1bf930,_0x5015f7,_0x53c6d6);}catch(_0x5c7bb9){if(!h(_0x5c7bb9))throw _0x5c7bb9;}return await _0x2ed81e(),await p(_0x8e3974[_0x5c2961(0x16e)],_0x1bf930,_0x5015f7,_0x53c6d6);}};}function H(_0x44d606){const _0x2a687a=_0x20a7fc;oe(_0x44d606[_0x2a687a(0x16e)]),b(_0x44d606[_0x2a687a(0x18a)]);let _0x258a68=new Map(),_0x351cec=new Set(),_0x2c2215,_0x2bd497=!0x1,_0x356afe,_0x41f952,_0x370719={async 'close'(){_0x356afe??=_0x2c8063(),await _0x356afe;},'handle'(_0x35d9fa,_0x3b87f9){const _0x5819db=_0x2a687a;if(_0x2bd497)throw Error(_0x5819db(0x1a8));if(_0x35d9fa[_0x5819db(0x1d5)]===0x0)throw Error(_0x5819db(0x17e));if(E(_0x35d9fa))throw Error(_0x5819db(0x173)+_0x35d9fa);if(_0x258a68[_0x5819db(0x1d0)](_0x35d9fa))throw Error(_0x5819db(0x1a9)+_0x35d9fa+_0x5819db(0x1a2));_0x258a68[_0x5819db(0x19f)](_0x35d9fa,_0x3b87f9);},async 'listen'(){const _0x23b4d1=_0x2a687a;if(!_0x2bd497){if(_0x356afe)throw Error('Daemon\x20server\x20is\x20closed');await _0x43614e(_0x1de26a(_0x44d606[_0x23b4d1(0x16e)]),{'recursive':!0x0}),await Y(_0x44d606[_0x23b4d1(0x16e)]),_0x2c2215=_0x17ded6(_0x26f78a=>U(_0x26f78a,_0x258a68,_0x351cec,{'shutdown':()=>{const _0x3d7f71=_0x23b4d1;_0x370719['close']()[_0x3d7f71(0x196)](()=>{const _0x52e4ea=_0x3d7f71;process[_0x52e4ea(0x1b4)]=0x1;});},'status':()=>G(_0x44d606['identity'],_0x44d606[_0x23b4d1(0x16e)],_0x41f952)})),await new Promise((_0x3ecd9d,_0x5dece5)=>{const _0x494085=_0x23b4d1;let _0xb03b46=_0x2c2215,_0x16bc6c=_0x3de676=>_0x5dece5(ae(_0x3de676)?Z(_0x44d606[_0x494085(0x16e)]):_0x3de676);_0xb03b46[_0x494085(0x16c)]('error',_0x16bc6c),_0xb03b46[_0x494085(0x192)](_0x44d606['socketPath'],()=>{const _0x8ab984=_0x494085;_0xb03b46[_0x8ab984(0x187)](_0x8ab984(0x16f),_0x16bc6c),_0x2bd497=!0x0,_0x41f952=new Date()[_0x8ab984(0x1c3)](),_0x3ecd9d();});});}}};return _0x370719;async function _0x2c8063(){const _0x4d5b7f=_0x2a687a;for(let _0x4487d3 of _0x351cec)_0x4487d3[_0x4d5b7f(0x18e)]();_0x351cec[_0x4d5b7f(0x171)](),_0x2c2215&&_0x2bd497&&await new Promise((_0x290929,_0x4fc156)=>{const _0x2ff647=_0x4d5b7f;_0x2c2215[_0x2ff647(0x1d1)](_0x5073f3=>_0x5073f3?_0x4fc156(_0x5073f3):_0x290929());}),_0x2bd497=!0x1;try{await _0x44d606[_0x4d5b7f(0x1cc)]?.();}finally{await re(_0x44d606[_0x4d5b7f(0x16e)]);}}}function U(_0x2f31b6,_0x4a0a0a,_0x3e69f5,_0x418ced){const _0x1bab8f=_0x20a7fc;_0x3e69f5[_0x1bab8f(0x1d4)](_0x2f31b6);let _0x110d78=!0x1,_0x9f063d=u(_0x386e18=>{_0x110d78||(_0x110d78=!0x0,W(_0x2f31b6,_0x386e18,_0x4a0a0a,_0x418ced));});_0x2f31b6['on'](_0x1bab8f(0x1d2),_0x5c51cb=>_0x9f063d['push'](_0x5c51cb)),_0x2f31b6['on']('end',()=>_0x9f063d['end']()),_0x2f31b6['on'](_0x1bab8f(0x1d1),()=>_0x3e69f5[_0x1bab8f(0x183)](_0x2f31b6)),_0x2f31b6['on'](_0x1bab8f(0x16f),()=>_0x2f31b6[_0x1bab8f(0x18e)]());}async function W(_0x13231b,_0x4f33e9,_0x2f2e96,_0x29d4e4){const _0x2cdbd6=_0x20a7fc;let _0x18b198=_0x2cdbd6(0x1b5),_0x50a5eb,_0x5f0123=!0x1;try{let _0x28469a=K(_0x4f33e9);_0x18b198=_0x28469a['id'];let _0x157442;if(_0x28469a[_0x2cdbd6(0x1a7)]==='daemon.status'){let _0x2a4c45=_0x29d4e4['status']();_0x157442={'identity':{..._0x2a4c45[_0x2cdbd6(0x18a)]['buildId']===void 0x0?{}:{'buildId':_0x2a4c45[_0x2cdbd6(0x18a)][_0x2cdbd6(0x1ba)]},'id':_0x2a4c45[_0x2cdbd6(0x18a)]['id'],'version':_0x2a4c45[_0x2cdbd6(0x18a)][_0x2cdbd6(0x1ab)]},'pid':_0x2a4c45[_0x2cdbd6(0x195)],'protocolVersion':_0x2a4c45[_0x2cdbd6(0x1d6)],'socketPath':_0x2a4c45[_0x2cdbd6(0x16e)],'startedAt':_0x2a4c45[_0x2cdbd6(0x17c)],'state':_0x2a4c45[_0x2cdbd6(0x190)]};}else{if(_0x28469a[_0x2cdbd6(0x1a7)]===_0x2cdbd6(0x168))_0x157442=null,_0x5f0123=!0x0;else{let _0x42726a=_0x2f2e96[_0x2cdbd6(0x1b8)](_0x28469a[_0x2cdbd6(0x1a7)]);if(!_0x42726a)throw J(_0x2cdbd6(0x1c9),_0x2cdbd6(0x166)+_0x28469a[_0x2cdbd6(0x1a7)]);_0x157442=await _0x42726a(_0x28469a[_0x2cdbd6(0x19a)]);}}_0x50a5eb={'id':_0x18b198,'result':_0x157442,'type':_0x2cdbd6(0x19b)};}catch(_0x4f18c9){_0x50a5eb={'error':q(_0x4f18c9),'id':_0x18b198,'type':'error'};}_0x13231b['end'](l(_0x50a5eb),()=>{_0x5f0123&&_0x29d4e4['shutdown']();});}function G(_0x3cfa6b,_0x85bf96,_0x25429c){const _0x4753a5=_0x20a7fc;if(_0x25429c===void 0x0)throw Error(_0x4753a5(0x1a5));return{'identity':_0x3cfa6b,'pid':process[_0x4753a5(0x195)],'protocolVersion':0x1,'socketPath':_0x85bf96,'startedAt':_0x25429c,'state':'running'};}function K(_0x39a923){const _0x2106a1=_0x20a7fc;let _0x56d696=JSON[_0x2106a1(0x189)](_0x39a923);if(!$(_0x56d696)||typeof _0x56d696['id']!=_0x2106a1(0x191)||typeof _0x56d696[_0x2106a1(0x1a7)]!=_0x2106a1(0x191)||!(_0x2106a1(0x19a)in _0x56d696))throw J(_0x2106a1(0x19c),_0x2106a1(0x180));return _0x56d696;}function q(_0x15f31d){const _0x2e90e9=_0x20a7fc;if(_0x15f31d instanceof Error){let _0x389363=_0x15f31d[_0x2e90e9(0x1aa)];return{...typeof _0x389363=='string'?{'code':_0x389363}:{},'message':_0x15f31d[_0x2e90e9(0x185)],'name':_0x15f31d['name']};}return{'message':String(_0x15f31d),'name':'Error'};}function J(_0x4682ba,_0x545985){const _0x3cf9dc=_0x20a7fc;return Object[_0x3cf9dc(0x17a)](Error(_0x545985),{'code':_0x4682ba});}async function Y(_0x4a59c8){const _0x44450f=_0x20a7fc;try{if(!(await _0x4833a8(_0x4a59c8))[_0x44450f(0x199)]())throw Error(_0x44450f(0x164)+_0x4a59c8);if(await X(_0x4a59c8))throw Z(_0x4a59c8);await _0x6196e9(_0x4a59c8);}catch(_0x2fe032){if(Q(_0x2fe032))return;throw _0x2fe032;}}function X(_0x417704){return new Promise((_0x356048,_0x450a7a)=>{const _0x4c37ce=_0x58a8;let _0x28e341=_0xd5a2b2(_0x417704);_0x28e341['once'](_0x4c37ce(0x18c),()=>{_0x28e341['destroy'](),_0x356048(!0x0);}),_0x28e341['once'](_0x4c37ce(0x16f),_0x10eb56=>{_0x28e341['destroy'](),ie(_0x10eb56)||Q(_0x10eb56)?_0x356048(!0x1):_0x450a7a(_0x10eb56);});});}function Z(_0x162953){const _0x26b5ec=_0x20a7fc;return Object['assign'](Error(_0x26b5ec(0x1d8)+_0x162953),{'code':'DAEMON_ALREADY_RUNNING'});}async function re(_0x29a7a2){const _0x5d4dbc=_0x20a7fc;try{(await _0x4833a8(_0x29a7a2))[_0x5d4dbc(0x199)]()&&await _0x6196e9(_0x29a7a2);}catch(_0x2e0232){if(!Q(_0x2e0232))throw _0x2e0232;}}function Q(_0xdacf95){const _0x3b7bbc=_0x20a7fc;return $(_0xdacf95)&&_0xdacf95[_0x3b7bbc(0x1aa)]===_0x3b7bbc(0x16d);}function ie(_0x3c34e6){const _0x5a2909=_0x20a7fc;return $(_0x3c34e6)&&_0x3c34e6[_0x5a2909(0x1aa)]==='ECONNREFUSED';}function ae(_0x35b93c){const _0xac2597=_0x20a7fc;return $(_0x35b93c)&&_0x35b93c[_0xac2597(0x1aa)]===_0xac2597(0x1cf);}function oe(_0x1c5a3d){const _0x375e8c=_0x20a7fc;if(_0x1c5a3d['length']===0x0)throw Error(_0x375e8c(0x197));}function $(_0x7cb8f4){const _0x3389ee=_0x20a7fc;return typeof _0x7cb8f4==_0x3389ee(0x169)&&!!_0x7cb8f4&&!Array[_0x3389ee(0x1dc)](_0x7cb8f4);}export{C as DAEMON_PROTOCOL_VERSION,T as DAEMON_SHUTDOWN_METHOD,d as DAEMON_SOCKET_ENV,w as DAEMON_STATUS_METHOD,V as createDaemonClient,k as createDaemonControl,H as createDaemonServer};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@univer-cli/daemon",
3
3
  "type": "module",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",