pubo-node 1.0.103 → 1.0.108

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,(()=>(()=>{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:()=>p,JsonStorage:()=>i,PuboFileSystem:()=>w,SIGKILL:()=>S,createRpcClient:()=>v,isPortAvailable:()=>_,pitch:()=>P});const t=require("fs"),e=require("pubo-utils");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(n){var r=this;this._state={},this.path=n,this.restore(),this.sync=(0,e.debounce)((function(){try{(0,t.writeFileSync)(r.path,JSON.stringify(r._state))}catch(t){console.log(t)}}),1e3)}return Object.defineProperty(n.prototype,"state",{get:function(){return this._state},set:function(t){this._state=t,this.sync()},enumerable:!1,configurable:!0}),n.prototype.restore=function(){try{var e=(0,t.readFileSync)(this.path);this._state=JSON.parse(e.toString())}catch(e){console.log(e);var n="win32"===process.platform?"\\":"/";(0,t.mkdirSync)(this.path.split(n).slice(0,-1).join(n),{recursive:!0}),this._state={}}},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}(),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)},c=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,c)}u((r=r.apply(t,e||[])).next())}))},u=function(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,r=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){s.label=c[1];break}if(6===c[0]&&s.label<o[1]){s.label=o[1],o=c;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(c);break}o[2]&&s.ops.pop(),s.trys.pop();continue}c=e.call(t,s)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}},a=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},l=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},f=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 n=t.driver,r=a(t,["driver"]);this.state={running:!1,connected:!1,destroyed:!1,connecting:!1},this._len=0,this.id=(0,e.random)(),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.driver=n,this.options=r}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 c(this,void 0,void 0,(function(){var t=this;return u(this,(function(n){switch(n.label){case 0:return this.client||(this.client=new this.driver),this.state.destroyed=!1,this.state.connecting?[4,(0,e.waitFor)((function(){return t.state.connected}),{checkTime:1e3,timeout:1e4})]:[3,2];case 1:return n.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 n=t.fn,r=t.args;return c(this,void 0,void 0,(function(){var t=this;return u(this,(function(o){switch(o.label){case 0:return this.len+=1,this.state.connected?[3,2]:[4,this.connect()];case 1:o.sent(),o.label=2;case 2:return this.state.running?[4,(0,e.waitFor)((function(){return!t.state.running}),{checkTime:1e3,timeout:6e6})]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.state.running=!0,[2,new Promise((function(e,o){var i;(i=t.client)[n].apply(i,f(f([],l(r),!1),[function(t,n){t?o(t):e(n)}],!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 c(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 c(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}(),p=function(){function t(t){var e=t.maxConnection,n=void 0===e?5:e,r=a(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 c(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,f([],l(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}(),d=function(){return d=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},d.apply(this,arguments)},y=function(){function t(t){var e,n=t.url,r=t.options,o=void 0===r?{}:r,i=t.Grpc,s=t.cert;this.url=n,this.Grpc=i;var c=d({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},o),u=s?i.credentials.createSsl(s):i.credentials.createInsecure();this.credentials=u,this.options=c,this.options.timeout=null!==(e=this.options.timeout)&&void 0!==e?e:5e3,this.client=new i.Client(n,u,c)}return t.prototype.reset=function(){this.client&&(this.client.close(),delete this.client),this.client=new this.Grpc.Client(this.url,this.credentials,this.options)},t.prototype.passThrough=function(t){return t},t.prototype.request=function(t,e,n){var r,o=this,i="/".concat(t,"/").concat(e),s=!1;return new Promise((function(t,e){var c=o.client.makeUnaryRequest(i,o.passThrough,o.passThrough,n,(function(n,i){s||(clearTimeout(r),n?(o.reset(),e(n)):t(i))}));o.options.timeout<0||(r=setTimeout((function(){s=!0,c.cancel(),o.reset(),e(new Error("timeout"))}),o.options.timeout))}))},t}();function v(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,s=t.cert,c=new y({url:e,options:r,Grpc:i,cert:s});return new o({request:c.request.bind(c)})}var b=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)s.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 s},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),S=function(t){O()(t,"SIGKILL")},_=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()}))}))},P=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
+ !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={163: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=163,t.exports=e},278: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:()=>f,FtpClientPool:()=>h,JsonStorage:()=>o,PuboFileSystem:()=>m,SIGKILL:()=>O,createRpcClient:()=>y,isPortAvailable:()=>S,pitch:()=>_});const t=require("fs"),e=require("pubo-utils");var o=function(){function n(n){var r=this;this._state={},this.path=n,this.restore(),this.sync=(0,e.debounce)((function(){try{(0,t.writeFileSync)(r.path,JSON.stringify(r._state))}catch(t){console.log(t)}}),1e3)}return Object.defineProperty(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),n.prototype.restore=function(){try{var e=(0,t.readFileSync)(this.path);this._state=JSON.parse(e.toString())}catch(e){console.log(e);var n="win32"===process.platform?"\\":"/";(0,t.mkdirSync)(this.path.split(n).slice(0,-1).join(n),{recursive:!0}),this._state={}}},n.prototype.get=function(t){return t?this.state[t]:this.state},n.prototype.set=function(t,e){this._state[t]=e,this.sync()},n.prototype.merge=function(t){var e,n;try{for(var r=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(Object.keys(t)),o=r.next();!o.done;o=r.next()){var i=o.value;this._state[i]=t[i]}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}this.sync()},n}(),i=function(){return i=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},i.apply(this,arguments)},c=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function c(t){try{u(r.next(t))}catch(t){i(t)}}function s(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(c,s)}u((r=r.apply(t,e||[])).next())}))},s=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(u){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,u])}}},u=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},a=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},l=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))},f=function(){function t(t){var n=t.driver,r=u(t,["driver"]);this.state={running:!1,connected:!1,destroyed:!1,connecting:!1},this._len=0,this.id=(0,e.random)(),this.put=this.bind("put"),this.delete=this.bind("delete"),this.list=this.bind("list"),this.rename=this.bind("rename"),this.driver=n,this.options=r}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 c(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this.client||(this.client=new this.driver),this.state.destroyed=!1,this.state.connecting?[4,(0,e.waitFor)((function(){return t.state.connected}),{checkTime:1e3,timeout:1e4})]:[3,2];case 1:return n.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(i({},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 n=t.fn,r=t.args;return c(this,void 0,void 0,(function(){var t=this;return s(this,(function(o){switch(o.label){case 0:return this.len+=1,this.state.connected?[3,2]:[4,this.connect()];case 1:o.sent(),o.label=2;case 2:return this.state.running?[4,(0,e.waitFor)((function(){return!t.state.running}),{checkTime:1e3,timeout:6e6})]:[3,4];case 3:o.sent(),o.label=4;case 4:return this.state.running=!0,[2,new Promise((function(e,o){var i;(i=t.client)[n].apply(i,l(l([],a(r),!1),[function(t,n){t?o(t):e(n)}],!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 c(e,void 0,void 0,(function(){var e;return s(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 c(this,void 0,void 0,(function(){var e,n,r=this;return s(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}(),h=function(){function t(t){var e=t.maxConnection,n=void 0===e?5:e,r=u(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 f(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 c(e,void 0,void 0,(function(){var e,r,o;return s(this,(function(i){switch(i.label){case 0:return[4,(e=this.client)[t].apply(e,l([],a(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}(),p=function(){return p=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},p.apply(this,arguments)},d=function(){function t(t){var e,n=t.url,r=t.options,o=void 0===r?{}:r,i=t.Grpc,c=t.cert;this.url=n,this.Grpc=i;var s=p({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},o),u=c?i.credentials.createSsl(c):i.credentials.createInsecure();this.credentials=u,this.options=s,this.options.timeout=null!==(e=this.options.timeout)&&void 0!==e?e:5e3,this.client=new i.Client(n,u,s)}return t.prototype.reset=function(){this.client&&(this.client.close(),delete this.client),this.client=new this.Grpc.Client(this.url,this.credentials,this.options)},t.prototype.passThrough=function(t){return t},t.prototype.request=function(t,e,n){var r,o=this,i="/".concat(t,"/").concat(e),c=!1;return new Promise((function(t,e){var s=o.client.makeUnaryRequest(i,o.passThrough,o.passThrough,n,(function(n,i){c||(clearTimeout(r),n?(o.reset(),e(n)):t(i))}));o.options.timeout<0||(r=setTimeout((function(){c=!0,s.cancel(),o.reset(),e(new Error("timeout"))}),o.options.timeout))}))},t}();function y(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,s=new d({url:e,options:r,Grpc:i,cert:c});return new o({request:s.request.bind(s)})}var v=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},b=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))},g=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,b(b([],v(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(b([],v(e),!1))}],!1))}))}},m={read:g(t.read),readFile:g(t.readFile),writeFile:g(t.writeFile),readdir:g(t.readdir),open:g(t.open),close:g(t.close),write:g(t.write),stat:g(t.stat)};const w=require("tree-kill");var x=n.n(w),O=function(t){x()(t,"SIGKILL")},S=function(t){return new Promise((function(e){var r=n(278).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(163),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(163)(global._0x2f(t))}}})(),r})()));
@@ -3,7 +3,6 @@ export declare class JsonStorage {
3
3
  private _state;
4
4
  private readonly sync;
5
5
  get state(): any;
6
- set state(values: any);
7
6
  constructor(path: string);
8
7
  private restore;
9
8
  get(key?: string): any;
@@ -1,12 +1,18 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
1
+ var __values = this && this.__values || function (o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator,
3
+ m = s && o[s],
4
+ i = 0;
5
+ if (m) return m.call(o);
6
+ if (o && typeof o.length === "number") return {
7
+ next: function next() {
8
+ if (o && i >= o.length) o = void 0;
9
+ return {
10
+ value: o && o[i++],
11
+ done: !o
12
+ };
6
13
  }
7
- return t;
8
14
  };
9
- return __assign.apply(this, arguments);
15
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
10
16
  };
11
17
  import { readFileSync, writeFileSync, mkdirSync } from 'fs';
12
18
  import { debounce } from 'pubo-utils';
@@ -28,10 +34,6 @@ var JsonStorage = /** @class */function () {
28
34
  get: function get() {
29
35
  return this._state;
30
36
  },
31
- set: function set(values) {
32
- this._state = values;
33
- this.sync();
34
- },
35
37
  enumerable: false,
36
38
  configurable: true
37
39
  });
@@ -50,18 +52,34 @@ var JsonStorage = /** @class */function () {
50
52
  };
51
53
  JsonStorage.prototype.get = function (key) {
52
54
  if (!key) {
53
- return __assign({}, this.state);
55
+ return this.state;
54
56
  } else {
55
57
  return this.state[key];
56
58
  }
57
59
  };
58
60
  JsonStorage.prototype.set = function (key, values) {
59
- var temp = __assign({}, this.state);
60
- temp[key] = values;
61
- this.state = temp;
61
+ this._state[key] = values;
62
+ this.sync();
62
63
  };
63
64
  JsonStorage.prototype.merge = function (values) {
64
- this.state = __assign(__assign({}, this.state), values);
65
+ var e_1, _a;
66
+ try {
67
+ for (var _b = __values(Object.keys(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
68
+ var key = _c.value;
69
+ this._state[key] = values[key];
70
+ }
71
+ } catch (e_1_1) {
72
+ e_1 = {
73
+ error: e_1_1
74
+ };
75
+ } finally {
76
+ try {
77
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
78
+ } finally {
79
+ if (e_1) throw e_1.error;
80
+ }
81
+ }
82
+ this.sync();
65
83
  };
66
84
  return JsonStorage;
67
85
  }();
@@ -3,7 +3,6 @@ export declare class JsonStorage {
3
3
  private _state;
4
4
  private readonly sync;
5
5
  get state(): any;
6
- set state(values: any);
7
6
  constructor(path: string);
8
7
  private restore;
9
8
  get(key?: string): any;
@@ -1,14 +1,20 @@
1
1
  "use strict";
2
2
 
3
- var __assign = this && this.__assign || function () {
4
- __assign = Object.assign || function (t) {
5
- for (var s, i = 1, n = arguments.length; i < n; i++) {
6
- s = arguments[i];
7
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
3
+ var __values = this && this.__values || function (o) {
4
+ var s = typeof Symbol === "function" && Symbol.iterator,
5
+ m = s && o[s],
6
+ i = 0;
7
+ if (m) return m.call(o);
8
+ if (o && typeof o.length === "number") return {
9
+ next: function next() {
10
+ if (o && i >= o.length) o = void 0;
11
+ return {
12
+ value: o && o[i++],
13
+ done: !o
14
+ };
8
15
  }
9
- return t;
10
16
  };
11
- return __assign.apply(this, arguments);
17
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
18
  };
13
19
  Object.defineProperty(exports, "__esModule", {
14
20
  value: true
@@ -34,10 +40,6 @@ var JsonStorage = /** @class */function () {
34
40
  get: function get() {
35
41
  return this._state;
36
42
  },
37
- set: function set(values) {
38
- this._state = values;
39
- this.sync();
40
- },
41
43
  enumerable: false,
42
44
  configurable: true
43
45
  });
@@ -56,18 +58,34 @@ var JsonStorage = /** @class */function () {
56
58
  };
57
59
  JsonStorage.prototype.get = function (key) {
58
60
  if (!key) {
59
- return __assign({}, this.state);
61
+ return this.state;
60
62
  } else {
61
63
  return this.state[key];
62
64
  }
63
65
  };
64
66
  JsonStorage.prototype.set = function (key, values) {
65
- var temp = __assign({}, this.state);
66
- temp[key] = values;
67
- this.state = temp;
67
+ this._state[key] = values;
68
+ this.sync();
68
69
  };
69
70
  JsonStorage.prototype.merge = function (values) {
70
- this.state = __assign(__assign({}, this.state), values);
71
+ var e_1, _a;
72
+ try {
73
+ for (var _b = __values(Object.keys(values)), _c = _b.next(); !_c.done; _c = _b.next()) {
74
+ var key = _c.value;
75
+ this._state[key] = values[key];
76
+ }
77
+ } catch (e_1_1) {
78
+ e_1 = {
79
+ error: e_1_1
80
+ };
81
+ } finally {
82
+ try {
83
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
84
+ } finally {
85
+ if (e_1) throw e_1.error;
86
+ }
87
+ }
88
+ this.sync();
71
89
  };
72
90
  return JsonStorage;
73
91
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-node",
3
- "version": "1.0.103",
3
+ "version": "1.0.108",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -21,8 +21,33 @@
21
21
  "dependencies": {
22
22
  "@types/node": "^17.0.25",
23
23
  "pako": "^2.0.4",
24
- "pubo-utils": "^1.0.98",
24
+ "pubo-utils": "^1.0.108",
25
25
  "tree-kill": "^1.2.2"
26
26
  },
27
- "gitHead": "68da30ebe79e41302c2b5ad6caa47ba114505015"
27
+ "gitHead": "4d23c9debe3ea10fc382174ca60b0c4f4c287ccd",
28
+ "devDependencies": {
29
+ "@babel/cli": "^7.10.1",
30
+ "@babel/core": "^7.10.2",
31
+ "@babel/preset-env": "^7.20.2",
32
+ "babel-loader": "^8.1.0",
33
+ "babel-plugin-import": "^1.12.0",
34
+ "babel-plugin-transform-async-to-promises": "^0.8.15",
35
+ "del": "^5.1.0",
36
+ "eslint": "^8.42.0",
37
+ "eslint-plugin-react-hooks": "^4.0.8",
38
+ "gulp": "^4.0.2",
39
+ "gulp-babel": "^8.0.0",
40
+ "gulp-typescript": "^6.0.0-alpha.1",
41
+ "jest": "^26.0.1",
42
+ "jest-fetch-mock": "^3.0.3",
43
+ "jest-localstorage-mock": "^2.4.18",
44
+ "prettier": "^2.8.8",
45
+ "pretty-quick": "^2.0.1",
46
+ "surge": "^0.21.3",
47
+ "ts-jest": "^26.1.0",
48
+ "typescript": "^4.9.5",
49
+ "webpack": "^5.75.0",
50
+ "webpack-cli": "^5.0.1",
51
+ "webpack-merge": "^5.8.0"
52
+ }
28
53
  }