@univer-cli/daemon 1.0.0-rc.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 _0x6aafea=_0x409b;(function(_0x2a0de4,_0x2d68a2){const _0x3d889b=_0x409b,_0x8282f9=_0x2a0de4();while(!![]){try{const _0x25128c=parseInt(_0x3d889b(0xa9))/0x1*(parseInt(_0x3d889b(0xae))/0x2)+parseInt(_0x3d889b(0xfd))/0x3+parseInt(_0x3d889b(0xc3))/0x4*(parseInt(_0x3d889b(0xfc))/0x5)+-parseInt(_0x3d889b(0xc4))/0x6*(-parseInt(_0x3d889b(0xa2))/0x7)+parseInt(_0x3d889b(0xfe))/0x8+parseInt(_0x3d889b(0xd9))/0x9+-parseInt(_0x3d889b(0xbc))/0xa*(parseInt(_0x3d889b(0x10d))/0xb);if(_0x25128c===_0x2d68a2)break;else _0x8282f9['push'](_0x8282f9['shift']());}catch(_0x3433b6){_0x8282f9['push'](_0x8282f9['shift']());}}}(_0x124f,0x4f47c));import{randomUUID as _0x583222}from'node:crypto';import{spawn as _0x27085b}from'node:child_process';function _0x409b(_0x1a6124,_0x40a43f){_0x1a6124=_0x1a6124-0x9b;const _0x124fc2=_0x124f();let _0x409b1b=_0x124fc2[_0x1a6124];return _0x409b1b;}import{connect as _0x4b6dac,createServer as _0x1905dd}from'node:net';import{fileURLToPath as _0x56ccad}from'node:url';import{lstat as _0xf3c8e8,mkdir as _0x3ecaad,unlink as _0xcd84fb}from'node:fs/promises';import{dirname as _0x1d52f9}from'node:path';function l(_0x32f25f){const _0x41fcee=_0x409b;return JSON[_0x41fcee(0xa0)](_0x32f25f)+'\x0a';}function u(_0x646464){let _0xbd8009='';return{'end'(){const _0x4ffbbe=_0x409b;_0xbd8009[_0x4ffbbe(0xf2)]()['length']>0x0&&_0x646464(_0xbd8009),_0xbd8009='';},'push'(_0xf48f2){const _0xa5d3fa=_0x409b;for(_0xbd8009+=_0xf48f2[_0xa5d3fa(0xe5)](_0xa5d3fa(0xdb));;){let _0x330d36=_0xbd8009[_0xa5d3fa(0xef)]('\x0a');if(_0x330d36<0x0)return;let _0x1e965e=_0xbd8009['slice'](0x0,_0x330d36);_0xbd8009=_0xbd8009[_0xa5d3fa(0xe7)](_0x330d36+0x1),_0x1e965e[_0xa5d3fa(0xf2)]()[_0xa5d3fa(0xb7)]>0x0&&_0x646464(_0x1e965e);}}};}var d=_0x6aafea(0xf7);function _0x124f(){const _0x3a93bd=['A\x20daemon\x20is\x20already\x20listening\x20on\x20','assign','code','reason','stopTimeoutMs','EADDRINUSE','Refusing\x20to\x20replace\x20non-socket\x20path\x20','identity','Invalid\x20daemon\x20response','message','Error','stringify','unreachable','458521FBubYM','isArray','off','\x20must\x20be\x20a\x20finite\x20positive\x20number','requestTimeoutMs','method','end','2095YIHMnF','Invalid\x20daemon\x20request','string','DAEMON_STOP_TIMEOUT','running','226LonIvJ','socketPath','execPath','type','clear','identity.id','\x20is\x20already\x20registered','pid','Daemon\x20method\x20must\x20not\x20be\x20empty','length','protocol-mismatch','diagnostic','incompatible','identity.buildId','37580kmJitu','ENOTCONN','Daemon\x20server\x20is\x20closed','connect','DAEMON_CONNECTION_CLOSED','start','buildId','8KYsqAf','42yKzcjy','actual','write','startsWith','push','now','build-id-mismatch','version-mismatch','daemon.status','env','daemon.shutdown','result','status','ECONNRESET','parse','Daemon\x20did\x20not\x20stop\x20within\x20','isNaN','unknown','\x20must\x20not\x20be\x20empty','DAEMON_INVALID_REQUEST','payload','4286268yECchf','legacy-protocol','utf8','file:','number','get','ready','daemon.','isSocket','DAEMON_UNREACHABLE','startTimeoutMs','timeoutMs','toString','once','slice','DAEMON_METHOD_NOT_FOUND','href','ENOENT','options','state','Daemon\x20entry\x20must\x20be\x20an\x20absolute\x20file\x20URL','DAEMON_REQUEST_TIMEOUT','indexOf','protocolVersion','identity.version','trim','isSafeInteger','stopped','object','invalid-health','UNIVER_CLI_SDK_DAEMON_SOCKET','unref','close','destroy','DAEMON_CONTROL_INVALID_RESPONSE','1359220QarJJH','186780ALWgsb','4462448cAQUDK','identity-mismatch','ECONNREFUSED','entry','error','startedAt','Daemon\x20method\x20namespace\x20is\x20reserved:\x20','listen','DAEMON_INCOMPATIBLE','version','EPIPE','name','data','Daemon\x20server\x20has\x20not\x20started\x20listening','Daemon\x20request\x20timed\x20out\x20after\x20','5885gLXiRH'];_0x124f=function(){return _0x3a93bd;};return _0x124f();}async function f(_0x4bf494){const _0x538ed2=_0x6aafea;_0x27085b(process[_0x538ed2(0xb0)],[_0x56ccad(_0x4bf494[_0x538ed2(0x101)])],{'detached':!0x0,'env':{...process.env,..._0x4bf494['options'][_0x538ed2(0xcd)],[d]:_0x4bf494[_0x538ed2(0xeb)][_0x538ed2(0xaf)]},'stdio':'ignore'})[_0x538ed2(0xf8)]();let _0x30a145=Date[_0x538ed2(0xc9)]();for(;Date[_0x538ed2(0xc9)]()-_0x30a145<_0x4bf494[_0x538ed2(0xe4)];){try{return await _0x4bf494[_0x538ed2(0xdf)]();}catch(_0x197769){if(!h(_0x197769))throw _0x197769;}await new Promise(_0x334823=>setTimeout(_0x334823,0x19));}throw Object[_0x538ed2(0x10f)](Error('Daemon\x20did\x20not\x20start\x20within\x20'+String(_0x4bf494['timeoutMs'])+'ms'),{'code':'DAEMON_START_TIMEOUT'});}function p(_0x2efb6c,_0x3346c9,_0xd73900,_0x3a8093){return new Promise((_0x337e9f,_0x37957d)=>{const _0x24b4c2=_0x409b;let _0x30870a=_0x4b6dac(_0x2efb6c),_0x573743=_0x583222(),_0x46c65b=!0x1,_0x3a6289=setTimeout(()=>{const _0xf0b176=_0x409b;_0x30870a[_0xf0b176(0xfa)](),_0x37957d(Object[_0xf0b176(0x10f)](Error(_0xf0b176(0x10c)+String(_0x3a8093)+'ms'),{'code':_0xf0b176(0xee)}));},_0x3a8093),_0x4fd2bb=_0xd29c8d=>{_0x46c65b||(_0x46c65b=!0x0,clearTimeout(_0x3a6289),_0xd29c8d());},_0x3154f6=u(_0x4c3134=>{try{let _0x43767d=_(_0x4c3134,_0x573743);_0x4fd2bb(()=>{const _0xfbd32d=_0x409b;_0x30870a[_0xfbd32d(0xa8)](),_0x43767d['type']===_0xfbd32d(0x102)?_0x37957d(v(_0x43767d[_0xfbd32d(0x102)])):_0x337e9f(_0x43767d['result']);});}catch(_0x1c4717){_0x4fd2bb(()=>{const _0x4b52f0=_0x409b;_0x30870a[_0x4b52f0(0xfa)](),_0x37957d(_0x1c4717);});}});_0x30870a['once'](_0x24b4c2(0x102),_0x42cec2=>_0x4fd2bb(()=>{const _0x221fe7=_0x24b4c2;_0x30870a[_0x221fe7(0xfa)](),_0x37957d(_0x42cec2);})),_0x30870a['on'](_0x24b4c2(0x10a),_0x1e8cfc=>_0x3154f6['push'](_0x1e8cfc)),_0x30870a['on'](_0x24b4c2(0xa8),()=>{const _0x559bb6=_0x24b4c2;_0x3154f6[_0x559bb6(0xa8)](),_0x4fd2bb(()=>{const _0xf6efbb=_0x559bb6;_0x30870a[_0xf6efbb(0xfa)](),_0x37957d(g());});}),_0x30870a['on'](_0x24b4c2(0xf9),()=>_0x4fd2bb(()=>{const _0x5dccb6=_0x24b4c2;_0x30870a[_0x5dccb6(0xfa)](),_0x37957d(g());})),_0x30870a[_0x24b4c2(0xe6)](_0x24b4c2(0xbf),()=>{const _0x28593d=_0x24b4c2;_0x30870a[_0x28593d(0xc6)](l({'id':_0x573743,'method':_0x3346c9,'payload':_0xd73900}));});});}function m(_0x32089d){const _0x3264a9=_0x6aafea;let _0x308f10=_0x32089d instanceof URL?_0x32089d[_0x3264a9(0xe9)]:_0x32089d;try{let _0x1065dc=new URL(_0x308f10);if(_0x1065dc['protocol']!==_0x3264a9(0xdc))throw Error();return _0x1065dc[_0x3264a9(0xe9)];}catch{throw Error(_0x3264a9(0xed));}}function h(_0x4d2756){const _0x5a1f17=_0x6aafea;return y(_0x4d2756)?_0x4d2756[_0x5a1f17(0x110)]===_0x5a1f17(0xea)||_0x4d2756[_0x5a1f17(0x110)]===_0x5a1f17(0x100):!0x1;}function g(){const _0x492862=_0x6aafea;return Object['assign'](Error('Daemon\x20connection\x20closed\x20before\x20a\x20response\x20was\x20received'),{'code':_0x492862(0xc0)});}function _(_0x270475,_0xb2ea43){const _0x308e1f=_0x6aafea;let _0x326109=JSON[_0x308e1f(0xd2)](_0x270475);if(!y(_0x326109)||_0x326109['id']!==_0xb2ea43)throw Error(_0x308e1f(0x9d));if(_0x326109[_0x308e1f(0xb1)]===_0x308e1f(0xcf)&&_0x308e1f(0xcf)in _0x326109||_0x326109[_0x308e1f(0xb1)]===_0x308e1f(0x102)&&y(_0x326109[_0x308e1f(0x102)]))return _0x326109;throw Error(_0x308e1f(0x9d));}function v(_0x3a4c3a){const _0x226ca4=_0x6aafea;let _0x291cef=Error(_0x3a4c3a[_0x226ca4(0x9e)]);return _0x3a4c3a[_0x226ca4(0x110)]!==void 0x0&&Object['assign'](_0x291cef,{'code':_0x3a4c3a[_0x226ca4(0x110)]}),_0x291cef[_0x226ca4(0x109)]=_0x3a4c3a[_0x226ca4(0x109)],_0x291cef;}function y(_0x3b0908){const _0x5ad03a=_0x6aafea;return typeof _0x3b0908==_0x5ad03a(0xf5)&&!!_0x3b0908&&!Array[_0x5ad03a(0xa3)](_0x3b0908);}function b(_0x53c57e){const _0x5aa301=_0x6aafea;S(_0x53c57e['id'],_0x5aa301(0xb3)),S(_0x53c57e[_0x5aa301(0x107)],_0x5aa301(0xf1)),_0x53c57e[_0x5aa301(0xc2)]!==void 0x0&&S(_0x53c57e['buildId'],_0x5aa301(0xbb));}function x(_0x40b20f){const _0x4687cd=_0x6aafea;return ee(_0x40b20f)&&typeof _0x40b20f['id']==_0x4687cd(0xab)&&_0x40b20f['id'][_0x4687cd(0xb7)]>0x0&&typeof _0x40b20f[_0x4687cd(0x107)]==_0x4687cd(0xab)&&_0x40b20f['version'][_0x4687cd(0xb7)]>0x0&&(_0x40b20f[_0x4687cd(0xc2)]===void 0x0||typeof _0x40b20f[_0x4687cd(0xc2)]==_0x4687cd(0xab)&&_0x40b20f['buildId']['length']>0x0);}function S(_0x4c64a9,_0x20bb64){const _0x459866=_0x6aafea;if(_0x4c64a9[_0x459866(0xb7)]===0x0)throw Error(_0x20bb64+_0x459866(0xd6));}function ee(_0x3c682a){const _0x3ee3cd=_0x6aafea;return typeof _0x3c682a==_0x3ee3cd(0xf5)&&!!_0x3c682a&&!Array[_0x3ee3cd(0xa3)](_0x3c682a);}var C=0x1,w=_0x6aafea(0xcc),T=_0x6aafea(0xce);function E(_0x163305){const _0x328010=_0x6aafea;return _0x163305[_0x328010(0xc7)](_0x328010(0xe0));}var D=0x2710,O=0x19;function k(_0x6069e8){const _0x414746=_0x6aafea;b(_0x6069e8[_0x414746(0x9c)]);let _0x430da2=m(_0x6069e8[_0x414746(0x101)]),_0x47de2d=_0x6069e8[_0x414746(0xa6)]??0x7530,_0x9385a6=_0x6069e8['startTimeoutMs']??0x2710,_0x38cc65=_0x6069e8['stopTimeoutMs']??D;z(_0x47de2d,_0x414746(0xa6)),z(_0x9385a6,_0x414746(0xe3)),z(_0x38cc65,_0x414746(0x112));let _0x1f7209=()=>({'socketPath':_0x6069e8[_0x414746(0xaf)],'state':_0x414746(0xf4)}),_0x1f5396=async()=>{const _0x5d2100=_0x414746;try{let _0x3bd3a5=N(await p(_0x6069e8[_0x5d2100(0xaf)],w,null,_0x47de2d),_0x6069e8[_0x5d2100(0xaf)]),_0x3bf7c3=te(_0x6069e8[_0x5d2100(0x9c)],_0x3bd3a5);return _0x3bf7c3===void 0x0?_0x3bd3a5:ne(_0x6069e8[_0x5d2100(0x9c)],_0x3bd3a5,_0x3bf7c3,_0x6069e8[_0x5d2100(0xaf)]);}catch(_0x1fb9d4){if(h(_0x1fb9d4))return _0x1f7209();let _0x29a137=L(_0x1fb9d4);return _0x29a137[_0x5d2100(0x110)]==='DAEMON_METHOD_NOT_FOUND'?j(_0x6069e8['identity'],_0x5d2100(0xda),_0x6069e8[_0x5d2100(0xaf)],_0x29a137):_0x29a137[_0x5d2100(0x110)]===_0x5d2100(0xfb)?j(_0x6069e8[_0x5d2100(0x9c)],_0x5d2100(0xf6),_0x6069e8[_0x5d2100(0xaf)],_0x29a137):{'diagnostic':_0x29a137,'socketPath':_0x6069e8['socketPath'],'state':_0x5d2100(0xa1)};}},_0x4f3f48=async()=>{const _0x1640b4=_0x414746;let _0x214dc9=await _0x1f5396();if(_0x214dc9['state']==='running')return{..._0x214dc9,'started':!0x1};if(_0x214dc9[_0x1640b4(0xec)]!==_0x1640b4(0xf4))throw M(_0x214dc9);return{...await f({'entry':_0x430da2,'options':_0x6069e8,'ready':async()=>{const _0x223000=_0x1640b4;let _0x1f8323=await _0x1f5396();if(_0x1f8323[_0x223000(0xec)]===_0x223000(0xf4))throw F(_0x6069e8[_0x223000(0xaf)]);if(_0x1f8323[_0x223000(0xec)]!==_0x223000(0xad))throw M(_0x1f8323);return _0x1f8323;},'timeoutMs':_0x9385a6}),'started':!0x0};},_0x88e298=async()=>{const _0x2566f0=_0x414746;let _0x4086df=await _0x1f5396();if(_0x4086df[_0x2566f0(0xec)]===_0x2566f0(0xf4))return{..._0x4086df,'stopped':!0x1};if(_0x4086df['state']!==_0x2566f0(0xad)&&!A(_0x4086df))throw M(_0x4086df);try{await p(_0x6069e8[_0x2566f0(0xaf)],T,null,_0x47de2d);}catch(_0x3847cf){if(!I(_0x3847cf))throw _0x3847cf;}return await P(_0x1f5396,_0x38cc65),{..._0x1f7209(),'stopped':!0x0};};return{async 'restart'(){const _0x4c085e=_0x414746;let _0x4d7500=await _0x1f5396();if(_0x4d7500['state']!==_0x4c085e(0xad)&&_0x4d7500[_0x4c085e(0xec)]!==_0x4c085e(0xf4)&&!A(_0x4d7500))throw M(_0x4d7500);(_0x4d7500[_0x4c085e(0xec)]===_0x4c085e(0xad)||A(_0x4d7500))&&await _0x88e298();let _0x59ecbf=await _0x4f3f48(),_0x3d564d=_0x4d7500[_0x4c085e(0xec)]==='running'?_0x4d7500[_0x4c085e(0xb5)]:A(_0x4d7500)?_0x4d7500[_0x4c085e(0xc5)]['pid']:void 0x0;return{'identity':_0x59ecbf[_0x4c085e(0x9c)],'pid':_0x59ecbf[_0x4c085e(0xb5)],..._0x3d564d===void 0x0?{}:{'previousPid':_0x3d564d},'restarted':_0x4d7500['state']!==_0x4c085e(0xf4),'protocolVersion':_0x59ecbf[_0x4c085e(0xf0)],'socketPath':_0x59ecbf[_0x4c085e(0xaf)],'startedAt':_0x59ecbf[_0x4c085e(0x103)],'state':_0x4c085e(0xad)};},'start':_0x4f3f48,'status':_0x1f5396,'stop':_0x88e298};}function A(_0x4393fe){const _0x4f8e9=_0x6aafea;return _0x4393fe[_0x4f8e9(0xec)]===_0x4f8e9(0xba)&&_0x4393fe[_0x4f8e9(0xc5)]!==void 0x0&&(_0x4393fe[_0x4f8e9(0x111)]===_0x4f8e9(0xcb)||_0x4393fe[_0x4f8e9(0x111)]===_0x4f8e9(0xca));}function te(_0x129764,_0x4b4a11){const _0xe54e0a=_0x6aafea;if(_0x4b4a11['protocolVersion']!==0x1)return _0xe54e0a(0xb8);if(_0x4b4a11[_0xe54e0a(0x9c)]['id']!==_0x129764['id'])return _0xe54e0a(0xff);if(_0x4b4a11[_0xe54e0a(0x9c)][_0xe54e0a(0x107)]!==_0x129764['version'])return _0xe54e0a(0xcb);if(_0x129764[_0xe54e0a(0xc2)]!==void 0x0&&_0x4b4a11['identity'][_0xe54e0a(0xc2)]!==_0x129764[_0xe54e0a(0xc2)])return _0xe54e0a(0xca);}function ne(_0x53227a,_0x4b0f06,_0x26528e,_0x183fa7){const _0xf4f8c3=_0x6aafea;return{'actual':{'identity':_0x4b0f06['identity'],'pid':_0x4b0f06[_0xf4f8c3(0xb5)],'protocolVersion':_0x4b0f06[_0xf4f8c3(0xf0)],'socketPath':_0x4b0f06[_0xf4f8c3(0xaf)],'startedAt':_0x4b0f06[_0xf4f8c3(0x103)]},'expected':{'identity':_0x53227a,'protocolVersion':0x1},'reason':_0x26528e,'socketPath':_0x183fa7,'state':_0xf4f8c3(0xba)};}function j(_0x378ddc,_0x373385,_0x1613dc,_0x18332d){const _0xae6da9=_0x6aafea;return{'diagnostic':_0x18332d,'expected':{'identity':_0x378ddc,'protocolVersion':0x1},'reason':_0x373385,'socketPath':_0x1613dc,'state':_0xae6da9(0xba)};}function M(_0x1ec752){const _0xed9efc=_0x6aafea;let _0x4d21f9=_0x1ec752['state']==='incompatible'?_0x1ec752['reason']:_0x1ec752[_0xed9efc(0xb9)][_0xed9efc(0x9e)];return R(_0x1ec752[_0xed9efc(0xec)]===_0xed9efc(0xba)?_0xed9efc(0x106):_0xed9efc(0xe2),'Daemon\x20is\x20not\x20ready:\x20'+_0x4d21f9);}function N(_0x1ee71,_0x3d6b8f){const _0x53c680=_0x6aafea;if(!B(_0x1ee71)||_0x1ee71[_0x53c680(0xec)]!==_0x53c680(0xad)||_0x1ee71[_0x53c680(0xaf)]!==_0x3d6b8f||!x(_0x1ee71[_0x53c680(0x9c)])||typeof _0x1ee71[_0x53c680(0xb5)]!=_0x53c680(0xdd)||!Number['isSafeInteger'](_0x1ee71[_0x53c680(0xb5)])||_0x1ee71[_0x53c680(0xb5)]<=0x0||typeof _0x1ee71[_0x53c680(0xf0)]!='number'||!Number[_0x53c680(0xf3)](_0x1ee71[_0x53c680(0xf0)])||_0x1ee71[_0x53c680(0xf0)]<=0x0||typeof _0x1ee71['startedAt']!=_0x53c680(0xab)||Number[_0x53c680(0xd4)](Date[_0x53c680(0xd2)](_0x1ee71['startedAt'])))throw R(_0x53c680(0xfb),'Daemon\x20status\x20response\x20is\x20invalid');return{'identity':_0x1ee71[_0x53c680(0x9c)],'pid':_0x1ee71[_0x53c680(0xb5)],'protocolVersion':_0x1ee71['protocolVersion'],'socketPath':_0x3d6b8f,'startedAt':_0x1ee71['startedAt'],'state':'running'};}async function P(_0x360782,_0x456ac2){const _0x19edb5=_0x6aafea;let _0x42b5f1=Date['now']();for(;Date[_0x19edb5(0xc9)]()-_0x42b5f1<_0x456ac2;){if((await _0x360782())['state']===_0x19edb5(0xf4))return;await new Promise(_0x486a9d=>setTimeout(_0x486a9d,O));}throw R(_0x19edb5(0xac),_0x19edb5(0xd3)+String(_0x456ac2)+'ms');}function F(_0x3b10cd){return Object['assign'](Error('Daemon\x20is\x20not\x20listening\x20on\x20'+_0x3b10cd),{'code':'ECONNREFUSED'});}function I(_0x2b0759){const _0x34b43f=_0x6aafea;return h(_0x2b0759)||B(_0x2b0759)&&(_0x2b0759[_0x34b43f(0x110)]===_0x34b43f(0xc0)||_0x2b0759[_0x34b43f(0x110)]===_0x34b43f(0xd1)||_0x2b0759[_0x34b43f(0x110)]===_0x34b43f(0xbd)||_0x2b0759[_0x34b43f(0x110)]===_0x34b43f(0x108));}function L(_0x3f8f00){const _0x564ba1=_0x6aafea;let _0x460021=_0x3f8f00 instanceof Error?_0x3f8f00[_0x564ba1(0x9e)]:String(_0x3f8f00);return B(_0x3f8f00)&&typeof _0x3f8f00['code']=='string'?{'code':_0x3f8f00[_0x564ba1(0x110)],'message':_0x460021}:{'message':_0x460021};}function R(_0x1daaa6,_0x279b79){return Object['assign'](Error(_0x279b79),{'code':_0x1daaa6});}function z(_0x3aa573,_0x11b52f){const _0xe7ccfb=_0x6aafea;if(!Number['isFinite'](_0x3aa573)||_0x3aa573<=0x0)throw Error(_0x11b52f+_0xe7ccfb(0xa5));}function B(_0x57c82e){const _0x52c9ff=_0x6aafea;return typeof _0x57c82e==_0x52c9ff(0xf5)&&!!_0x57c82e&&!Array[_0x52c9ff(0xa3)](_0x57c82e);}function V(_0x55be7a){const _0x4c162b=_0x6aafea;let _0x5de06a=_0x55be7a[_0x4c162b(0xa6)]??0x7530,_0x5a267c=k(_0x55be7a),_0x5a5d6d,_0x4d4172=async()=>{const _0x587f06=_0x4c162b;let _0x41cd7d=await _0x5a267c[_0x587f06(0xd0)]();if(_0x41cd7d['state']==='running')return _0x41cd7d;if(_0x41cd7d[_0x587f06(0xec)]!==_0x587f06(0xf4))throw M(_0x41cd7d);let _0x26ef4b=_0x5a5d6d??=_0x5a267c[_0x587f06(0xc1)]();try{return await _0x26ef4b;}finally{_0x5a5d6d===_0x26ef4b&&(_0x5a5d6d=void 0x0);}};return{async 'request'(_0x28a972,_0x50128d){const _0x4f1094=_0x4c162b;if(_0x28a972[_0x4f1094(0xb7)]===0x0)throw Error('Daemon\x20method\x20must\x20not\x20be\x20empty');await _0x4d4172();try{return await p(_0x55be7a[_0x4f1094(0xaf)],_0x28a972,_0x50128d,_0x5de06a);}catch(_0x1157b2){if(!h(_0x1157b2))throw _0x1157b2;}return await _0x4d4172(),await p(_0x55be7a[_0x4f1094(0xaf)],_0x28a972,_0x50128d,_0x5de06a);}};}function H(_0x342b9e){const _0x340816=_0x6aafea;oe(_0x342b9e['socketPath']),b(_0x342b9e[_0x340816(0x9c)]);let _0x3b964b=new Map(),_0x5e0bd5=new Set(),_0x53716d,_0x1cb736=!0x1,_0x3dc4cd,_0xdf78bb,_0x1986ce={async 'close'(){_0x3dc4cd??=_0x2b790a(),await _0x3dc4cd;},'handle'(_0x2c24fb,_0x3eff18){const _0x58f8f4=_0x340816;if(_0x1cb736)throw Error('Daemon\x20handlers\x20must\x20be\x20registered\x20before\x20listen()');if(_0x2c24fb[_0x58f8f4(0xb7)]===0x0)throw Error(_0x58f8f4(0xb6));if(E(_0x2c24fb))throw Error(_0x58f8f4(0x104)+_0x2c24fb);if(_0x3b964b['has'](_0x2c24fb))throw Error('Daemon\x20method\x20'+_0x2c24fb+_0x58f8f4(0xb4));_0x3b964b['set'](_0x2c24fb,_0x3eff18);},async 'listen'(){const _0x533628=_0x340816;if(!_0x1cb736){if(_0x3dc4cd)throw Error(_0x533628(0xbe));await _0x3ecaad(_0x1d52f9(_0x342b9e[_0x533628(0xaf)]),{'recursive':!0x0}),await Y(_0x342b9e[_0x533628(0xaf)]),_0x53716d=_0x1905dd(_0xd1e2e=>U(_0xd1e2e,_0x3b964b,_0x5e0bd5,{'shutdown':()=>{const _0x52f7ce=_0x533628;_0x1986ce[_0x52f7ce(0xf9)]()['catch'](()=>{process['exitCode']=0x1;});},'status':()=>G(_0x342b9e[_0x533628(0x9c)],_0x342b9e[_0x533628(0xaf)],_0xdf78bb)})),await new Promise((_0x27fe68,_0x51df63)=>{const _0x15daaa=_0x533628;let _0x586fda=_0x53716d,_0x2f698c=_0x2418b1=>_0x51df63(ae(_0x2418b1)?Z(_0x342b9e[_0x15daaa(0xaf)]):_0x2418b1);_0x586fda[_0x15daaa(0xe6)](_0x15daaa(0x102),_0x2f698c),_0x586fda[_0x15daaa(0x105)](_0x342b9e['socketPath'],()=>{const _0x527608=_0x15daaa;_0x586fda[_0x527608(0xa4)](_0x527608(0x102),_0x2f698c),_0x1cb736=!0x0,_0xdf78bb=new Date()['toISOString'](),_0x27fe68();});});}}};return _0x1986ce;async function _0x2b790a(){const _0x1184fe=_0x340816;for(let _0x1dfbf3 of _0x5e0bd5)_0x1dfbf3[_0x1184fe(0xfa)]();_0x5e0bd5[_0x1184fe(0xb2)](),_0x53716d&&_0x1cb736&&await new Promise((_0x4f4329,_0x3841fe)=>{const _0x42433b=_0x1184fe;_0x53716d[_0x42433b(0xf9)](_0x378791=>_0x378791?_0x3841fe(_0x378791):_0x4f4329());}),_0x1cb736=!0x1;try{await _0x342b9e['onShutdown']?.();}finally{await re(_0x342b9e[_0x1184fe(0xaf)]);}}}function U(_0x57c6c6,_0x753645,_0x43613e,_0x4a7aaa){const _0x57b75b=_0x6aafea;_0x43613e['add'](_0x57c6c6);let _0x20e616=!0x1,_0x291f7b=u(_0x5e97f0=>{_0x20e616||(_0x20e616=!0x0,W(_0x57c6c6,_0x5e97f0,_0x753645,_0x4a7aaa));});_0x57c6c6['on'](_0x57b75b(0x10a),_0x9e2af3=>_0x291f7b[_0x57b75b(0xc8)](_0x9e2af3)),_0x57c6c6['on']('end',()=>_0x291f7b[_0x57b75b(0xa8)]()),_0x57c6c6['on'](_0x57b75b(0xf9),()=>_0x43613e['delete'](_0x57c6c6)),_0x57c6c6['on'](_0x57b75b(0x102),()=>_0x57c6c6[_0x57b75b(0xfa)]());}async function W(_0xcb3cc7,_0x27f065,_0x26258b,_0x3001f9){const _0x3e5b1a=_0x6aafea;let _0x3b86b5=_0x3e5b1a(0xd5),_0xb883ed,_0x4900a7=!0x1;try{let _0x444dee=K(_0x27f065);_0x3b86b5=_0x444dee['id'];let _0x511411;if(_0x444dee[_0x3e5b1a(0xa7)]==='daemon.status'){let _0x2704c9=_0x3001f9['status']();_0x511411={'identity':{..._0x2704c9[_0x3e5b1a(0x9c)][_0x3e5b1a(0xc2)]===void 0x0?{}:{'buildId':_0x2704c9[_0x3e5b1a(0x9c)][_0x3e5b1a(0xc2)]},'id':_0x2704c9[_0x3e5b1a(0x9c)]['id'],'version':_0x2704c9[_0x3e5b1a(0x9c)][_0x3e5b1a(0x107)]},'pid':_0x2704c9[_0x3e5b1a(0xb5)],'protocolVersion':_0x2704c9[_0x3e5b1a(0xf0)],'socketPath':_0x2704c9[_0x3e5b1a(0xaf)],'startedAt':_0x2704c9[_0x3e5b1a(0x103)],'state':_0x2704c9['state']};}else{if(_0x444dee[_0x3e5b1a(0xa7)]===_0x3e5b1a(0xce))_0x511411=null,_0x4900a7=!0x0;else{let _0x4ebd38=_0x26258b[_0x3e5b1a(0xde)](_0x444dee['method']);if(!_0x4ebd38)throw J(_0x3e5b1a(0xe8),'Unknown\x20daemon\x20method\x20'+_0x444dee['method']);_0x511411=await _0x4ebd38(_0x444dee[_0x3e5b1a(0xd8)]);}}_0xb883ed={'id':_0x3b86b5,'result':_0x511411,'type':_0x3e5b1a(0xcf)};}catch(_0x468cf3){_0xb883ed={'error':q(_0x468cf3),'id':_0x3b86b5,'type':_0x3e5b1a(0x102)};}_0xcb3cc7[_0x3e5b1a(0xa8)](l(_0xb883ed),()=>{_0x4900a7&&_0x3001f9['shutdown']();});}function G(_0x1d2137,_0x32c3bd,_0x27231e){const _0x1e6827=_0x6aafea;if(_0x27231e===void 0x0)throw Error(_0x1e6827(0x10b));return{'identity':_0x1d2137,'pid':process['pid'],'protocolVersion':0x1,'socketPath':_0x32c3bd,'startedAt':_0x27231e,'state':'running'};}function K(_0x613689){const _0x18875e=_0x6aafea;let _0x3faaae=JSON[_0x18875e(0xd2)](_0x613689);if(!$(_0x3faaae)||typeof _0x3faaae['id']!=_0x18875e(0xab)||typeof _0x3faaae['method']!=_0x18875e(0xab)||!(_0x18875e(0xd8)in _0x3faaae))throw J(_0x18875e(0xd7),_0x18875e(0xaa));return _0x3faaae;}function q(_0x23b859){const _0x3e67ad=_0x6aafea;if(_0x23b859 instanceof Error){let _0x1467cd=_0x23b859[_0x3e67ad(0x110)];return{...typeof _0x1467cd=='string'?{'code':_0x1467cd}:{},'message':_0x23b859['message'],'name':_0x23b859[_0x3e67ad(0x109)]};}return{'message':String(_0x23b859),'name':_0x3e67ad(0x9f)};}function J(_0x4f22d,_0x26b110){const _0x757b64=_0x6aafea;return Object[_0x757b64(0x10f)](Error(_0x26b110),{'code':_0x4f22d});}async function Y(_0x5f5d9b){const _0x5ad3e8=_0x6aafea;try{if(!(await _0xf3c8e8(_0x5f5d9b))['isSocket']())throw Error(_0x5ad3e8(0x9b)+_0x5f5d9b);if(await X(_0x5f5d9b))throw Z(_0x5f5d9b);await _0xcd84fb(_0x5f5d9b);}catch(_0x59a5e4){if(Q(_0x59a5e4))return;throw _0x59a5e4;}}function X(_0xd7b168){return new Promise((_0x46736a,_0x18104c)=>{const _0x273d32=_0x409b;let _0x3fe5ec=_0x4b6dac(_0xd7b168);_0x3fe5ec[_0x273d32(0xe6)](_0x273d32(0xbf),()=>{const _0x53705a=_0x273d32;_0x3fe5ec[_0x53705a(0xfa)](),_0x46736a(!0x0);}),_0x3fe5ec[_0x273d32(0xe6)](_0x273d32(0x102),_0x5e08a4=>{const _0x492022=_0x273d32;_0x3fe5ec[_0x492022(0xfa)](),ie(_0x5e08a4)||Q(_0x5e08a4)?_0x46736a(!0x1):_0x18104c(_0x5e08a4);});});}function Z(_0x34f66f){const _0x280740=_0x6aafea;return Object[_0x280740(0x10f)](Error(_0x280740(0x10e)+_0x34f66f),{'code':'DAEMON_ALREADY_RUNNING'});}async function re(_0x49956d){const _0x258ad2=_0x6aafea;try{(await _0xf3c8e8(_0x49956d))[_0x258ad2(0xe1)]()&&await _0xcd84fb(_0x49956d);}catch(_0x348ff9){if(!Q(_0x348ff9))throw _0x348ff9;}}function Q(_0x3675e8){const _0x54d16d=_0x6aafea;return $(_0x3675e8)&&_0x3675e8['code']===_0x54d16d(0xea);}function ie(_0x23f2a1){const _0x4f5e63=_0x6aafea;return $(_0x23f2a1)&&_0x23f2a1[_0x4f5e63(0x110)]===_0x4f5e63(0x100);}function ae(_0x2adb3d){const _0x537307=_0x6aafea;return $(_0x2adb3d)&&_0x2adb3d[_0x537307(0x110)]===_0x537307(0x113);}function oe(_0x11ad85){const _0x36835b=_0x6aafea;if(_0x11ad85[_0x36835b(0xb7)]===0x0)throw Error('socketPath\x20must\x20not\x20be\x20empty');}function $(_0x41e365){const _0x331b7e=_0x6aafea;return typeof _0x41e365==_0x331b7e(0xf5)&&!!_0x41e365&&!Array[_0x331b7e(0xa3)](_0x41e365);}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 _0xb61e7b=_0x5236;(function(_0x2741e2,_0x131cd4){const _0x3d8280=_0x5236,_0x63c1c=_0x2741e2();while(!![]){try{const _0x4b1cd1=-parseInt(_0x3d8280(0x17a))/0x1*(parseInt(_0x3d8280(0x199))/0x2)+-parseInt(_0x3d8280(0x1c3))/0x3+-parseInt(_0x3d8280(0x191))/0x4+parseInt(_0x3d8280(0x1a0))/0x5*(parseInt(_0x3d8280(0x1d0))/0x6)+-parseInt(_0x3d8280(0x1b6))/0x7+parseInt(_0x3d8280(0x1d1))/0x8*(-parseInt(_0x3d8280(0x1cc))/0x9)+parseInt(_0x3d8280(0x1ba))/0xa;if(_0x4b1cd1===_0x131cd4)break;else _0x63c1c['push'](_0x63c1c['shift']());}catch(_0xc5b552){_0x63c1c['push'](_0x63c1c['shift']());}}}(_0x2116,0xb8c13));import{randomUUID as _0x185db3}from'node:crypto';import{spawn as _0x4b60cb}from'node:child_process';import{connect as _0x209893,createServer as _0x37ad10}from'node:net';import{fileURLToPath as _0x2a7430}from'node:url';import{lstat as _0xf2bcb1,mkdir as _0x5736d8,unlink as _0x23a158}from'node:fs/promises';import{dirname as _0x1636c7}from'node:path';function l(_0x5165eb){return JSON['stringify'](_0x5165eb)+'\x0a';}function u(_0x515aff){let _0x120537='';return{'end'(){const _0x32a2af=_0x5236;_0x120537[_0x32a2af(0x1d2)]()[_0x32a2af(0x190)]>0x0&&_0x515aff(_0x120537),_0x120537='';},'push'(_0x4336e7){const _0x8162e8=_0x5236;for(_0x120537+=_0x4336e7[_0x8162e8(0x18f)](_0x8162e8(0x17c));;){let _0x4934f6=_0x120537[_0x8162e8(0x1b8)]('\x0a');if(_0x4934f6<0x0)return;let _0xd021b5=_0x120537['slice'](0x0,_0x4934f6);_0x120537=_0x120537[_0x8162e8(0x172)](_0x4934f6+0x1),_0xd021b5[_0x8162e8(0x1d2)]()['length']>0x0&&_0x515aff(_0xd021b5);}}};}function _0x5236(_0xeb9836,_0x127bec){_0xeb9836=_0xeb9836-0x15d;const _0x2116ca=_0x2116();let _0x523605=_0x2116ca[_0xeb9836];return _0x523605;}var d='UNIVER_CLI_SDK_DAEMON_SOCKET';async function f(_0x3893e2){const _0x3ae2ca=_0x5236;_0x4b60cb(process['execPath'],[_0x2a7430(_0x3893e2[_0x3ae2ca(0x16b)])],{'detached':!0x0,'env':{...process.env,..._0x3893e2['options'][_0x3ae2ca(0x1c0)],[d]:_0x3893e2[_0x3ae2ca(0x1a1)]['socketPath']},'stdio':'ignore'})[_0x3ae2ca(0x1b2)]();let _0x7830ab=Date[_0x3ae2ca(0x181)]();for(;Date['now']()-_0x7830ab<_0x3893e2[_0x3ae2ca(0x1bb)];){try{return await _0x3893e2[_0x3ae2ca(0x182)]();}catch(_0x2eecce){if(!h(_0x2eecce))throw _0x2eecce;}await new Promise(_0x444395=>setTimeout(_0x444395,0x19));}throw Object['assign'](Error(_0x3ae2ca(0x19c)+String(_0x3893e2['timeoutMs'])+'ms'),{'code':_0x3ae2ca(0x15f)});}function p(_0x27ace5,_0x5daa05,_0x16d689,_0x5a1534){return new Promise((_0x20b42d,_0xcfeac9)=>{const _0x1c038b=_0x5236;let _0x561678=_0x209893(_0x27ace5),_0x205465=_0x185db3(),_0x1d68df=!0x1,_0x3780df=setTimeout(()=>{const _0x587112=_0x5236;_0x561678[_0x587112(0x196)](),_0xcfeac9(Object[_0x587112(0x160)](Error('Daemon\x20request\x20timed\x20out\x20after\x20'+String(_0x5a1534)+'ms'),{'code':_0x587112(0x1c2)}));},_0x5a1534),_0xf54c38=_0x48ccec=>{_0x1d68df||(_0x1d68df=!0x0,clearTimeout(_0x3780df),_0x48ccec());},_0x27375a=u(_0x157b3f=>{try{let _0x4436d8=_(_0x157b3f,_0x205465);_0xf54c38(()=>{const _0x489aa7=_0x5236;_0x561678[_0x489aa7(0x187)](),_0x4436d8[_0x489aa7(0x1b9)]===_0x489aa7(0x164)?_0xcfeac9(v(_0x4436d8[_0x489aa7(0x164)])):_0x20b42d(_0x4436d8[_0x489aa7(0x1cd)]);});}catch(_0x3e409e){_0xf54c38(()=>{const _0x2af43c=_0x5236;_0x561678[_0x2af43c(0x196)](),_0xcfeac9(_0x3e409e);});}});_0x561678[_0x1c038b(0x1ac)]('error',_0xb0aebf=>_0xf54c38(()=>{const _0x5cc1d8=_0x1c038b;_0x561678[_0x5cc1d8(0x196)](),_0xcfeac9(_0xb0aebf);})),_0x561678['on'](_0x1c038b(0x16f),_0x4e2905=>_0x27375a[_0x1c038b(0x1c8)](_0x4e2905)),_0x561678['on'](_0x1c038b(0x187),()=>{_0x27375a['end'](),_0xf54c38(()=>{_0x561678['destroy'](),_0xcfeac9(g());});}),_0x561678['on'](_0x1c038b(0x16c),()=>_0xf54c38(()=>{const _0x23f137=_0x1c038b;_0x561678[_0x23f137(0x196)](),_0xcfeac9(g());})),_0x561678[_0x1c038b(0x1ac)]('connect',()=>{const _0x27a9a8=_0x1c038b;_0x561678[_0x27a9a8(0x188)](l({'id':_0x205465,'method':_0x5daa05,'payload':_0x16d689}));});});}function m(_0xd48173){const _0xb15090=_0x5236;let _0x474f4a=_0xd48173 instanceof URL?_0xd48173['href']:_0xd48173;try{let _0x154a76=new URL(_0x474f4a);if(_0x154a76[_0xb15090(0x163)]!=='file:')throw Error();return _0x154a76[_0xb15090(0x186)];}catch{throw Error('Daemon\x20entry\x20must\x20be\x20an\x20absolute\x20file\x20URL');}}function h(_0x5ada65){const _0x237a41=_0x5236;return y(_0x5ada65)?_0x5ada65[_0x237a41(0x18c)]===_0x237a41(0x192)||_0x5ada65[_0x237a41(0x18c)]===_0x237a41(0x1b0):!0x1;}function g(){const _0x21f273=_0x5236;return Object[_0x21f273(0x160)](Error('Daemon\x20connection\x20closed\x20before\x20a\x20response\x20was\x20received'),{'code':'DAEMON_CONNECTION_CLOSED'});}function _(_0x5b7b06,_0x4f2a7b){const _0xe23653=_0x5236;let _0x4412fb=JSON[_0xe23653(0x18e)](_0x5b7b06);if(!y(_0x4412fb)||_0x4412fb['id']!==_0x4f2a7b)throw Error('Invalid\x20daemon\x20response');if(_0x4412fb[_0xe23653(0x1b9)]==='result'&&'result'in _0x4412fb||_0x4412fb[_0xe23653(0x1b9)]===_0xe23653(0x164)&&y(_0x4412fb[_0xe23653(0x164)]))return _0x4412fb;throw Error(_0xe23653(0x1c4));}function v(_0x130555){const _0x361cf6=_0x5236;let _0x28b150=Error(_0x130555['message']);return _0x130555[_0x361cf6(0x18c)]!==void 0x0&&Object[_0x361cf6(0x160)](_0x28b150,{'code':_0x130555['code']}),_0x28b150[_0x361cf6(0x18b)]=_0x130555[_0x361cf6(0x18b)],_0x28b150;}function y(_0x482701){const _0x5a1511=_0x5236;return typeof _0x482701==_0x5a1511(0x1be)&&!!_0x482701&&!Array[_0x5a1511(0x1cb)](_0x482701);}function b(_0xa77397){const _0x9cd39b=_0x5236;S(_0xa77397['id'],_0x9cd39b(0x1b3)),S(_0xa77397[_0x9cd39b(0x169)],'identity.version'),_0xa77397[_0x9cd39b(0x1b5)]!==void 0x0&&S(_0xa77397[_0x9cd39b(0x1b5)],'identity.buildId');}function x(_0x29d67e){const _0x157253=_0x5236;return ee(_0x29d67e)&&typeof _0x29d67e['id']==_0x157253(0x1cf)&&_0x29d67e['id'][_0x157253(0x190)]>0x0&&typeof _0x29d67e[_0x157253(0x169)]==_0x157253(0x1cf)&&_0x29d67e[_0x157253(0x169)][_0x157253(0x190)]>0x0&&(_0x29d67e[_0x157253(0x1b5)]===void 0x0||typeof _0x29d67e[_0x157253(0x1b5)]=='string'&&_0x29d67e[_0x157253(0x1b5)][_0x157253(0x190)]>0x0);}function S(_0x128d09,_0x527b5e){const _0xe98922=_0x5236;if(_0x128d09['length']===0x0)throw Error(_0x527b5e+_0xe98922(0x175));}function ee(_0x565aca){const _0x104166=_0x5236;return typeof _0x565aca==_0x104166(0x1be)&&!!_0x565aca&&!Array['isArray'](_0x565aca);}var C=0x1,w=_0xb61e7b(0x189),T=_0xb61e7b(0x19b);function E(_0x4732aa){const _0xc72092=_0xb61e7b;return _0x4732aa[_0xc72092(0x1a2)](_0xc72092(0x162));}var D=0x2710,O=0x19;function k(_0x281d5e){const _0x1a20c3=_0xb61e7b;b(_0x281d5e[_0x1a20c3(0x17e)]);let _0x353597=m(_0x281d5e['entry']),_0x12cb45=_0x281d5e[_0x1a20c3(0x1c1)]??0x7530,_0x152598=_0x281d5e[_0x1a20c3(0x17b)]??0x2710,_0x122c56=_0x281d5e[_0x1a20c3(0x171)]??D;z(_0x12cb45,'requestTimeoutMs'),z(_0x152598,_0x1a20c3(0x17b)),z(_0x122c56,_0x1a20c3(0x171));let _0x57e266=()=>({'socketPath':_0x281d5e[_0x1a20c3(0x18a)],'state':_0x1a20c3(0x1b1)}),_0x17b170=async()=>{const _0x7e477a=_0x1a20c3;try{let _0x48e3c3=N(await p(_0x281d5e[_0x7e477a(0x18a)],w,null,_0x12cb45),_0x281d5e[_0x7e477a(0x18a)]),_0x166ce9=te(_0x281d5e[_0x7e477a(0x17e)],_0x48e3c3);return _0x166ce9===void 0x0?_0x48e3c3:ne(_0x281d5e[_0x7e477a(0x17e)],_0x48e3c3,_0x166ce9,_0x281d5e[_0x7e477a(0x18a)]);}catch(_0x817deb){if(h(_0x817deb))return _0x57e266();let _0x152221=L(_0x817deb);return _0x152221[_0x7e477a(0x18c)]===_0x7e477a(0x16a)?j(_0x281d5e[_0x7e477a(0x17e)],'legacy-protocol',_0x281d5e[_0x7e477a(0x18a)],_0x152221):_0x152221[_0x7e477a(0x18c)]===_0x7e477a(0x197)?j(_0x281d5e[_0x7e477a(0x17e)],'invalid-health',_0x281d5e['socketPath'],_0x152221):{'diagnostic':_0x152221,'socketPath':_0x281d5e[_0x7e477a(0x18a)],'state':_0x7e477a(0x167)};}},_0x46df46=async()=>{const _0x293826=_0x1a20c3;let _0x426f66=await _0x17b170();if(_0x426f66[_0x293826(0x173)]===_0x293826(0x1a5))return{..._0x426f66,'started':!0x1};if(_0x426f66[_0x293826(0x173)]!==_0x293826(0x1b1))throw M(_0x426f66);return{...await f({'entry':_0x353597,'options':_0x281d5e,'ready':async()=>{const _0x188b2a=_0x293826;let _0x144c66=await _0x17b170();if(_0x144c66['state']===_0x188b2a(0x1b1))throw F(_0x281d5e['socketPath']);if(_0x144c66['state']!==_0x188b2a(0x1a5))throw M(_0x144c66);return _0x144c66;},'timeoutMs':_0x152598}),'started':!0x0};},_0xa6bcec=async()=>{const _0x1fd061=_0x1a20c3;let _0x337058=await _0x17b170();if(_0x337058[_0x1fd061(0x173)]===_0x1fd061(0x1b1))return{..._0x337058,'stopped':!0x1};if(_0x337058[_0x1fd061(0x173)]!==_0x1fd061(0x1a5)&&!A(_0x337058))throw M(_0x337058);try{await p(_0x281d5e['socketPath'],T,null,_0x12cb45);}catch(_0x2477fe){if(!I(_0x2477fe))throw _0x2477fe;}return await P(_0x17b170,_0x122c56),{..._0x57e266(),'stopped':!0x0};};return{async 'restart'(){const _0x235ce1=_0x1a20c3;let _0x1abfa6=await _0x17b170();if(_0x1abfa6[_0x235ce1(0x173)]!==_0x235ce1(0x1a5)&&_0x1abfa6[_0x235ce1(0x173)]!==_0x235ce1(0x1b1)&&!A(_0x1abfa6))throw M(_0x1abfa6);(_0x1abfa6['state']===_0x235ce1(0x1a5)||A(_0x1abfa6))&&await _0xa6bcec();let _0x1f929c=await _0x46df46(),_0x6b4a51=_0x1abfa6[_0x235ce1(0x173)]===_0x235ce1(0x1a5)?_0x1abfa6[_0x235ce1(0x16d)]:A(_0x1abfa6)?_0x1abfa6['actual']['pid']:void 0x0;return{'identity':_0x1f929c[_0x235ce1(0x17e)],'pid':_0x1f929c['pid'],..._0x6b4a51===void 0x0?{}:{'previousPid':_0x6b4a51},'restarted':_0x1abfa6[_0x235ce1(0x173)]!==_0x235ce1(0x1b1),'protocolVersion':_0x1f929c[_0x235ce1(0x178)],'socketPath':_0x1f929c[_0x235ce1(0x18a)],'startedAt':_0x1f929c['startedAt'],'state':'running'};},'start':_0x46df46,'status':_0x17b170,'stop':_0xa6bcec};}function A(_0x325b2d){const _0x198aed=_0xb61e7b;return _0x325b2d[_0x198aed(0x173)]==='incompatible'&&_0x325b2d[_0x198aed(0x1ce)]!==void 0x0&&(_0x325b2d[_0x198aed(0x170)]===_0x198aed(0x1c6)||_0x325b2d[_0x198aed(0x170)]==='build-id-mismatch');}function te(_0x5627d6,_0x1db4d2){const _0x1b1998=_0xb61e7b;if(_0x1db4d2[_0x1b1998(0x178)]!==0x1)return _0x1b1998(0x1bf);if(_0x1db4d2[_0x1b1998(0x17e)]['id']!==_0x5627d6['id'])return _0x1b1998(0x16e);if(_0x1db4d2[_0x1b1998(0x17e)][_0x1b1998(0x169)]!==_0x5627d6[_0x1b1998(0x169)])return _0x1b1998(0x1c6);if(_0x5627d6[_0x1b1998(0x1b5)]!==void 0x0&&_0x1db4d2['identity'][_0x1b1998(0x1b5)]!==_0x5627d6[_0x1b1998(0x1b5)])return _0x1b1998(0x1c7);}function ne(_0x5352ab,_0x4032f6,_0x3ddb3b,_0x599ac3){const _0x2a83fa=_0xb61e7b;return{'actual':{'identity':_0x4032f6[_0x2a83fa(0x17e)],'pid':_0x4032f6[_0x2a83fa(0x16d)],'protocolVersion':_0x4032f6[_0x2a83fa(0x178)],'socketPath':_0x4032f6[_0x2a83fa(0x18a)],'startedAt':_0x4032f6[_0x2a83fa(0x1a8)]},'expected':{'identity':_0x5352ab,'protocolVersion':0x1},'reason':_0x3ddb3b,'socketPath':_0x599ac3,'state':_0x2a83fa(0x19e)};}function j(_0x2f8567,_0x4abab2,_0x384c0e,_0x395535){const _0x13d881=_0xb61e7b;return{'diagnostic':_0x395535,'expected':{'identity':_0x2f8567,'protocolVersion':0x1},'reason':_0x4abab2,'socketPath':_0x384c0e,'state':_0x13d881(0x19e)};}function M(_0x318211){const _0x3e2e4c=_0xb61e7b;let _0x1ccbec=_0x318211[_0x3e2e4c(0x173)]===_0x3e2e4c(0x19e)?_0x318211[_0x3e2e4c(0x170)]:_0x318211[_0x3e2e4c(0x177)][_0x3e2e4c(0x1a6)];return R(_0x318211[_0x3e2e4c(0x173)]===_0x3e2e4c(0x19e)?_0x3e2e4c(0x165):_0x3e2e4c(0x15e),_0x3e2e4c(0x180)+_0x1ccbec);}function N(_0x43e523,_0x494159){const _0x3edf7e=_0xb61e7b;if(!B(_0x43e523)||_0x43e523[_0x3edf7e(0x173)]!==_0x3edf7e(0x1a5)||_0x43e523[_0x3edf7e(0x18a)]!==_0x494159||!x(_0x43e523[_0x3edf7e(0x17e)])||typeof _0x43e523[_0x3edf7e(0x16d)]!=_0x3edf7e(0x1af)||!Number['isSafeInteger'](_0x43e523[_0x3edf7e(0x16d)])||_0x43e523[_0x3edf7e(0x16d)]<=0x0||typeof _0x43e523[_0x3edf7e(0x178)]!=_0x3edf7e(0x1af)||!Number[_0x3edf7e(0x19a)](_0x43e523[_0x3edf7e(0x178)])||_0x43e523[_0x3edf7e(0x178)]<=0x0||typeof _0x43e523['startedAt']!=_0x3edf7e(0x1cf)||Number[_0x3edf7e(0x184)](Date[_0x3edf7e(0x18e)](_0x43e523[_0x3edf7e(0x1a8)])))throw R('DAEMON_CONTROL_INVALID_RESPONSE',_0x3edf7e(0x1ae));return{'identity':_0x43e523['identity'],'pid':_0x43e523[_0x3edf7e(0x16d)],'protocolVersion':_0x43e523[_0x3edf7e(0x178)],'socketPath':_0x494159,'startedAt':_0x43e523[_0x3edf7e(0x1a8)],'state':'running'};}async function P(_0x572aa3,_0x335f81){const _0x4db011=_0xb61e7b;let _0x1d8071=Date['now']();for(;Date[_0x4db011(0x181)]()-_0x1d8071<_0x335f81;){if((await _0x572aa3())[_0x4db011(0x173)]===_0x4db011(0x1b1))return;await new Promise(_0x477f35=>setTimeout(_0x477f35,O));}throw R(_0x4db011(0x1c9),_0x4db011(0x198)+String(_0x335f81)+'ms');}function F(_0x5265e5){const _0x45d8ea=_0xb61e7b;return Object[_0x45d8ea(0x160)](Error('Daemon\x20is\x20not\x20listening\x20on\x20'+_0x5265e5),{'code':_0x45d8ea(0x1b0)});}function I(_0x22da65){const _0x407cee=_0xb61e7b;return h(_0x22da65)||B(_0x22da65)&&(_0x22da65['code']===_0x407cee(0x19f)||_0x22da65[_0x407cee(0x18c)]===_0x407cee(0x1d3)||_0x22da65[_0x407cee(0x18c)]===_0x407cee(0x176)||_0x22da65[_0x407cee(0x18c)]===_0x407cee(0x179));}function L(_0x8e2665){const _0x4be8e8=_0xb61e7b;let _0x4447ba=_0x8e2665 instanceof Error?_0x8e2665[_0x4be8e8(0x1a6)]:String(_0x8e2665);return B(_0x8e2665)&&typeof _0x8e2665[_0x4be8e8(0x18c)]=='string'?{'code':_0x8e2665[_0x4be8e8(0x18c)],'message':_0x4447ba}:{'message':_0x4447ba};}function R(_0x53bdda,_0x3169b4){const _0xd6ba2e=_0xb61e7b;return Object[_0xd6ba2e(0x160)](Error(_0x3169b4),{'code':_0x53bdda});}function z(_0x5b23a3,_0x5da565){const _0x2f7415=_0xb61e7b;if(!Number[_0x2f7415(0x1b4)](_0x5b23a3)||_0x5b23a3<=0x0)throw Error(_0x5da565+'\x20must\x20be\x20a\x20finite\x20positive\x20number');}function B(_0x4e4a6d){const _0x281168=_0xb61e7b;return typeof _0x4e4a6d==_0x281168(0x1be)&&!!_0x4e4a6d&&!Array[_0x281168(0x1cb)](_0x4e4a6d);}function V(_0x54c4ab){const _0x17a2e8=_0xb61e7b;let _0x3307b2=_0x54c4ab[_0x17a2e8(0x1c1)]??0x7530,_0x25404b=k(_0x54c4ab),_0x503b17,_0x3bb325=async()=>{const _0x29e26b=_0x17a2e8;let _0x547409=await _0x25404b['status']();if(_0x547409[_0x29e26b(0x173)]===_0x29e26b(0x1a5))return _0x547409;if(_0x547409[_0x29e26b(0x173)]!==_0x29e26b(0x1b1))throw M(_0x547409);let _0x522a01=_0x503b17??=_0x25404b[_0x29e26b(0x166)]();try{return await _0x522a01;}finally{_0x503b17===_0x522a01&&(_0x503b17=void 0x0);}};return{async 'request'(_0x274c92,_0x954983){const _0x913236=_0x17a2e8;if(_0x274c92['length']===0x0)throw Error('Daemon\x20method\x20must\x20not\x20be\x20empty');await _0x3bb325();try{return await p(_0x54c4ab[_0x913236(0x18a)],_0x274c92,_0x954983,_0x3307b2);}catch(_0x1706c7){if(!h(_0x1706c7))throw _0x1706c7;}return await _0x3bb325(),await p(_0x54c4ab[_0x913236(0x18a)],_0x274c92,_0x954983,_0x3307b2);}};}function H(_0x4bb1fc){const _0xe786cf=_0xb61e7b;oe(_0x4bb1fc[_0xe786cf(0x18a)]),b(_0x4bb1fc[_0xe786cf(0x17e)]);let _0x3e197f=new Map(),_0x3febcd=new Set(),_0xe9a7d7,_0x1dc761=!0x1,_0x31c252,_0x127407,_0x1d43b3={async 'close'(){_0x31c252??=_0x4ed526(),await _0x31c252;},'handle'(_0x53e375,_0x57026a){const _0x1e6574=_0xe786cf;if(_0x1dc761)throw Error(_0x1e6574(0x195));if(_0x53e375[_0x1e6574(0x190)]===0x0)throw Error('Daemon\x20method\x20must\x20not\x20be\x20empty');if(E(_0x53e375))throw Error(_0x1e6574(0x1a3)+_0x53e375);if(_0x3e197f[_0x1e6574(0x1ca)](_0x53e375))throw Error(_0x1e6574(0x1a4)+_0x53e375+_0x1e6574(0x183));_0x3e197f[_0x1e6574(0x1ad)](_0x53e375,_0x57026a);},async 'listen'(){const _0x283b41=_0xe786cf;if(!_0x1dc761){if(_0x31c252)throw Error(_0x283b41(0x1aa));await _0x5736d8(_0x1636c7(_0x4bb1fc[_0x283b41(0x18a)]),{'recursive':!0x0}),await Y(_0x4bb1fc[_0x283b41(0x18a)]),_0xe9a7d7=_0x37ad10(_0x3340fd=>U(_0x3340fd,_0x3e197f,_0x3febcd,{'shutdown':()=>{const _0x4f5e07=_0x283b41;_0x1d43b3[_0x4f5e07(0x16c)]()[_0x4f5e07(0x15d)](()=>{process['exitCode']=0x1;});},'status':()=>G(_0x4bb1fc[_0x283b41(0x17e)],_0x4bb1fc[_0x283b41(0x18a)],_0x127407)})),await new Promise((_0x5cd589,_0x4096b2)=>{const _0x1c901b=_0x283b41;let _0x55e18d=_0xe9a7d7,_0x5d1c47=_0x54b66c=>_0x4096b2(ae(_0x54b66c)?Z(_0x4bb1fc['socketPath']):_0x54b66c);_0x55e18d[_0x1c901b(0x1ac)](_0x1c901b(0x164),_0x5d1c47),_0x55e18d['listen'](_0x4bb1fc[_0x1c901b(0x18a)],()=>{const _0x3c0f10=_0x1c901b;_0x55e18d[_0x3c0f10(0x194)](_0x3c0f10(0x164),_0x5d1c47),_0x1dc761=!0x0,_0x127407=new Date()['toISOString'](),_0x5cd589();});});}}};return _0x1d43b3;async function _0x4ed526(){const _0x56df30=_0xe786cf;for(let _0x246ce5 of _0x3febcd)_0x246ce5[_0x56df30(0x196)]();_0x3febcd['clear'](),_0xe9a7d7&&_0x1dc761&&await new Promise((_0x44959b,_0x3b97ba)=>{const _0x4ff515=_0x56df30;_0xe9a7d7[_0x4ff515(0x16c)](_0x26e72b=>_0x26e72b?_0x3b97ba(_0x26e72b):_0x44959b());}),_0x1dc761=!0x1;try{await _0x4bb1fc['onShutdown']?.();}finally{await re(_0x4bb1fc[_0x56df30(0x18a)]);}}}function U(_0x2d8f14,_0x3bf7e4,_0x5cf488,_0x25c511){const _0x26ed62=_0xb61e7b;_0x5cf488[_0x26ed62(0x1b7)](_0x2d8f14);let _0x43b6cc=!0x1,_0xd4a5df=u(_0x38b131=>{_0x43b6cc||(_0x43b6cc=!0x0,W(_0x2d8f14,_0x38b131,_0x3bf7e4,_0x25c511));});_0x2d8f14['on']('data',_0x43e85e=>_0xd4a5df[_0x26ed62(0x1c8)](_0x43e85e)),_0x2d8f14['on'](_0x26ed62(0x187),()=>_0xd4a5df[_0x26ed62(0x187)]()),_0x2d8f14['on'](_0x26ed62(0x16c),()=>_0x5cf488[_0x26ed62(0x193)](_0x2d8f14)),_0x2d8f14['on'](_0x26ed62(0x164),()=>_0x2d8f14[_0x26ed62(0x196)]());}async function W(_0x64ffdf,_0xb96db1,_0x4d037e,_0xea001f){const _0x5cb9ce=_0xb61e7b;let _0x3ba288='unknown',_0x5aceec,_0x592cce=!0x1;try{let _0x1aa2b3=K(_0xb96db1);_0x3ba288=_0x1aa2b3['id'];let _0x4ba334;if(_0x1aa2b3['method']===_0x5cb9ce(0x189)){let _0x500039=_0xea001f[_0x5cb9ce(0x185)]();_0x4ba334={'identity':{..._0x500039[_0x5cb9ce(0x17e)]['buildId']===void 0x0?{}:{'buildId':_0x500039[_0x5cb9ce(0x17e)][_0x5cb9ce(0x1b5)]},'id':_0x500039[_0x5cb9ce(0x17e)]['id'],'version':_0x500039['identity']['version']},'pid':_0x500039[_0x5cb9ce(0x16d)],'protocolVersion':_0x500039[_0x5cb9ce(0x178)],'socketPath':_0x500039[_0x5cb9ce(0x18a)],'startedAt':_0x500039['startedAt'],'state':_0x500039['state']};}else{if(_0x1aa2b3[_0x5cb9ce(0x1a9)]===_0x5cb9ce(0x19b))_0x4ba334=null,_0x592cce=!0x0;else{let _0x52c687=_0x4d037e[_0x5cb9ce(0x1bd)](_0x1aa2b3[_0x5cb9ce(0x1a9)]);if(!_0x52c687)throw J(_0x5cb9ce(0x16a),'Unknown\x20daemon\x20method\x20'+_0x1aa2b3[_0x5cb9ce(0x1a9)]);_0x4ba334=await _0x52c687(_0x1aa2b3['payload']);}}_0x5aceec={'id':_0x3ba288,'result':_0x4ba334,'type':_0x5cb9ce(0x1cd)};}catch(_0x2654c0){_0x5aceec={'error':q(_0x2654c0),'id':_0x3ba288,'type':'error'};}_0x64ffdf[_0x5cb9ce(0x187)](l(_0x5aceec),()=>{_0x592cce&&_0xea001f['shutdown']();});}function G(_0x1c7714,_0x42ec88,_0x42f507){const _0x32779f=_0xb61e7b;if(_0x42f507===void 0x0)throw Error(_0x32779f(0x17d));return{'identity':_0x1c7714,'pid':process[_0x32779f(0x16d)],'protocolVersion':0x1,'socketPath':_0x42ec88,'startedAt':_0x42f507,'state':_0x32779f(0x1a5)};}function K(_0x2e3e3f){const _0x1d1f7c=_0xb61e7b;let _0x2de8b9=JSON[_0x1d1f7c(0x18e)](_0x2e3e3f);if(!$(_0x2de8b9)||typeof _0x2de8b9['id']!=_0x1d1f7c(0x1cf)||typeof _0x2de8b9[_0x1d1f7c(0x1a9)]!=_0x1d1f7c(0x1cf)||!(_0x1d1f7c(0x1ab)in _0x2de8b9))throw J(_0x1d1f7c(0x161),_0x1d1f7c(0x1c5));return _0x2de8b9;}function q(_0x570c0e){const _0x11be80=_0xb61e7b;if(_0x570c0e instanceof Error){let _0x26f831=_0x570c0e[_0x11be80(0x18c)];return{...typeof _0x26f831==_0x11be80(0x1cf)?{'code':_0x26f831}:{},'message':_0x570c0e[_0x11be80(0x1a6)],'name':_0x570c0e[_0x11be80(0x18b)]};}return{'message':String(_0x570c0e),'name':'Error'};}function J(_0x5a0b15,_0xaa6141){const _0x5d0c0b=_0xb61e7b;return Object[_0x5d0c0b(0x160)](Error(_0xaa6141),{'code':_0x5a0b15});}async function Y(_0x1be09d){const _0x44cb09=_0xb61e7b;try{if(!(await _0xf2bcb1(_0x1be09d))['isSocket']())throw Error(_0x44cb09(0x168)+_0x1be09d);if(await X(_0x1be09d))throw Z(_0x1be09d);await _0x23a158(_0x1be09d);}catch(_0x12b1dc){if(Q(_0x12b1dc))return;throw _0x12b1dc;}}function X(_0x4b2ec9){return new Promise((_0x3b9b7c,_0x2e4185)=>{const _0x3664f9=_0x5236;let _0x3ff931=_0x209893(_0x4b2ec9);_0x3ff931['once'](_0x3664f9(0x174),()=>{const _0x50adc3=_0x3664f9;_0x3ff931[_0x50adc3(0x196)](),_0x3b9b7c(!0x0);}),_0x3ff931[_0x3664f9(0x1ac)](_0x3664f9(0x164),_0x37c114=>{_0x3ff931['destroy'](),ie(_0x37c114)||Q(_0x37c114)?_0x3b9b7c(!0x1):_0x2e4185(_0x37c114);});});}function Z(_0x22c300){const _0x3d0330=_0xb61e7b;return Object['assign'](Error(_0x3d0330(0x1bc)+_0x22c300),{'code':_0x3d0330(0x1a7)});}async function re(_0x4efa4d){const _0x3d5626=_0xb61e7b;try{(await _0xf2bcb1(_0x4efa4d))[_0x3d5626(0x19d)]()&&await _0x23a158(_0x4efa4d);}catch(_0x30b88a){if(!Q(_0x30b88a))throw _0x30b88a;}}function Q(_0x243c02){const _0x25c048=_0xb61e7b;return $(_0x243c02)&&_0x243c02[_0x25c048(0x18c)]===_0x25c048(0x192);}function _0x2116(){const _0x2ca348=['version-mismatch','build-id-mismatch','push','DAEMON_STOP_TIMEOUT','has','isArray','9fMZKqt','result','actual','string','6558XFBNqw','7986584lbfjRE','trim','ECONNRESET','catch','DAEMON_UNREACHABLE','DAEMON_START_TIMEOUT','assign','DAEMON_INVALID_REQUEST','daemon.','protocol','error','DAEMON_INCOMPATIBLE','start','unreachable','Refusing\x20to\x20replace\x20non-socket\x20path\x20','version','DAEMON_METHOD_NOT_FOUND','entry','close','pid','identity-mismatch','data','reason','stopTimeoutMs','slice','state','connect','\x20must\x20not\x20be\x20empty','ENOTCONN','diagnostic','protocolVersion','EPIPE','5567xVPdvU','startTimeoutMs','utf8','Daemon\x20server\x20has\x20not\x20started\x20listening','identity','EADDRINUSE','Daemon\x20is\x20not\x20ready:\x20','now','ready','\x20is\x20already\x20registered','isNaN','status','href','end','write','daemon.status','socketPath','name','code','socketPath\x20must\x20not\x20be\x20empty','parse','toString','length','1654080xRxmug','ENOENT','delete','off','Daemon\x20handlers\x20must\x20be\x20registered\x20before\x20listen()','destroy','DAEMON_CONTROL_INVALID_RESPONSE','Daemon\x20did\x20not\x20stop\x20within\x20','292nBJtov','isSafeInteger','daemon.shutdown','Daemon\x20did\x20not\x20start\x20within\x20','isSocket','incompatible','DAEMON_CONNECTION_CLOSED','4960UGFJSA','options','startsWith','Daemon\x20method\x20namespace\x20is\x20reserved:\x20','Daemon\x20method\x20','running','message','DAEMON_ALREADY_RUNNING','startedAt','method','Daemon\x20server\x20is\x20closed','payload','once','set','Daemon\x20status\x20response\x20is\x20invalid','number','ECONNREFUSED','stopped','unref','identity.id','isFinite','buildId','7713748srvrhd','add','indexOf','type','31350740xIVSNN','timeoutMs','A\x20daemon\x20is\x20already\x20listening\x20on\x20','get','object','protocol-mismatch','env','requestTimeoutMs','DAEMON_REQUEST_TIMEOUT','407958rgxlWv','Invalid\x20daemon\x20response','Invalid\x20daemon\x20request'];_0x2116=function(){return _0x2ca348;};return _0x2116();}function ie(_0xcdc62c){const _0x5f3f20=_0xb61e7b;return $(_0xcdc62c)&&_0xcdc62c[_0x5f3f20(0x18c)]===_0x5f3f20(0x1b0);}function ae(_0x1b6308){const _0x50363a=_0xb61e7b;return $(_0x1b6308)&&_0x1b6308[_0x50363a(0x18c)]===_0x50363a(0x17f);}function oe(_0x11acfa){const _0x1b51dc=_0xb61e7b;if(_0x11acfa['length']===0x0)throw Error(_0x1b51dc(0x18d));}function $(_0x76ed5f){const _0x429468=_0xb61e7b;return typeof _0x76ed5f==_0x429468(0x1be)&&!!_0x76ed5f&&!Array['isArray'](_0x76ed5f);}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.0-rc.0",
4
+ "version": "1.0.0",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",