pubo-node 1.0.98 → 1.0.100
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 +1 -1
- package/es/storage/json.d.ts +0 -2
- package/es/storage/json.js +14 -19
- package/lib/storage/json.d.ts +0 -2
- package/lib/storage/json.js +14 -19
- package/package.json +2 -2
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:()=>p,FtpClientPool:()=>d,JsonStorage:()=>i,PuboFileSystem:()=>x,SIGKILL:()=>P,createRpcClient:()=>b,isPortAvailable:()=>_,pitch:()=>j});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(e){(0,t.mkdirSync)(this.path.split("/").slice(0,-1).join("/"),{recursive:!0}),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)},u=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())}))},a=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])}}},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 u(this,void 0,void 0,(function(){var t=this;return a(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 u(this,void 0,void 0,(function(){var t=this;return a(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 u(e,void 0,void 0,(function(){var e;return a(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 u(this,void 0,void 0,(function(){var e,n,r=this;return a(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 u(e,void 0,void 0,(function(){var e,r,o;return a(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}(),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)},v=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=y({"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 b(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,s=new v({url:e,options:r,Grpc:i,cert:c});return new o({request:s.request.bind(s)})}var g=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},m=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))},w=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,m(m([],g(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(m([],g(e),!1))}],!1))}))}},x={read:w(t.read),readFile:w(t.readFile),writeFile:w(t.writeFile),readdir:w(t.readdir),open:w(t.open),close:w(t.close),write:w(t.write),stat:w(t.stat)};const O=require("tree-kill");var S=n.n(O),P=function(t){S()(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()}))}))},j=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={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:()=>x,SIGKILL:()=>P,createRpcClient:()=>b,isPortAvailable:()=>j,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.path=t}return Object.defineProperty(n.prototype,"state",{get:function(){try{var n=(0,t.readFileSync)(this.path),r=e.inflate(n,{to:"string"});return JSON.parse(r)}catch(e){return console.log(e),(0,t.mkdirSync)(this.path.split("/").slice(0,-1).join("/"),{recursive:!0}),{}}},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)}))},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)},u=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())}))},a=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])}}},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 u(this,void 0,void 0,(function(){var t=this;return a(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 u(this,void 0,void 0,(function(){var t=this;return a(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 u(e,void 0,void 0,(function(){var e;return a(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 u(this,void 0,void 0,(function(){var e,n,r=this;return a(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 u(e,void 0,void 0,(function(){var e,r,o;return a(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)},v=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=y({"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 b(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,c=t.cert,s=new v({url:e,options:r,Grpc:i,cert:c});return new o({request:s.request.bind(s)})}var g=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},m=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))},w=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,m(m([],g(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(m([],g(e),!1))}],!1))}))}},x={read:w(t.read),readFile:w(t.readFile),writeFile:w(t.writeFile),readdir:w(t.readdir),open:w(t.open),close:w(t.close),write:w(t.write),stat:w(t.stat)};const O=require("tree-kill");var S=n.n(O),P=function(t){S()(t,"SIGKILL")},j=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})()));
|
package/es/storage/json.d.ts
CHANGED
package/es/storage/json.js
CHANGED
|
@@ -12,27 +12,23 @@ import { readFileSync, writeFile, mkdirSync } from 'fs';
|
|
|
12
12
|
import * as pako from 'pako';
|
|
13
13
|
var JsonStorage = /** @class */function () {
|
|
14
14
|
function JsonStorage(path) {
|
|
15
|
-
this._state = {};
|
|
16
15
|
this.path = path;
|
|
17
|
-
this.init();
|
|
18
16
|
}
|
|
19
|
-
JsonStorage.prototype.init = function () {
|
|
20
|
-
try {
|
|
21
|
-
var buf = readFileSync(this.path);
|
|
22
|
-
var data = pako.inflate(buf, {
|
|
23
|
-
to: 'string'
|
|
24
|
-
});
|
|
25
|
-
this._state = JSON.parse(data);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
mkdirSync(this.path.split('/').slice(0, -1).join('/'), {
|
|
28
|
-
recursive: true
|
|
29
|
-
});
|
|
30
|
-
this.state = {};
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
17
|
Object.defineProperty(JsonStorage.prototype, "state", {
|
|
34
18
|
get: function get() {
|
|
35
|
-
|
|
19
|
+
try {
|
|
20
|
+
var buf = readFileSync(this.path);
|
|
21
|
+
var data = pako.inflate(buf, {
|
|
22
|
+
to: 'string'
|
|
23
|
+
});
|
|
24
|
+
return JSON.parse(data);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.log(err);
|
|
27
|
+
mkdirSync(this.path.split('/').slice(0, -1).join('/'), {
|
|
28
|
+
recursive: true
|
|
29
|
+
});
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
36
32
|
},
|
|
37
33
|
set: function set(values) {
|
|
38
34
|
var data = pako.deflate(JSON.stringify(values));
|
|
@@ -40,7 +36,6 @@ var JsonStorage = /** @class */function () {
|
|
|
40
36
|
writeFile(this.path, buf, function (err) {
|
|
41
37
|
return err && console.log(err);
|
|
42
38
|
});
|
|
43
|
-
this._state = values;
|
|
44
39
|
},
|
|
45
40
|
enumerable: false,
|
|
46
41
|
configurable: true
|
|
@@ -58,7 +53,7 @@ var JsonStorage = /** @class */function () {
|
|
|
58
53
|
this.state = temp;
|
|
59
54
|
};
|
|
60
55
|
JsonStorage.prototype.merge = function (values) {
|
|
61
|
-
this.state = __assign(__assign({}, this.
|
|
56
|
+
this.state = __assign(__assign({}, this.state), values);
|
|
62
57
|
};
|
|
63
58
|
return JsonStorage;
|
|
64
59
|
}();
|
package/lib/storage/json.d.ts
CHANGED
package/lib/storage/json.js
CHANGED
|
@@ -49,27 +49,23 @@ var fs_1 = require("fs");
|
|
|
49
49
|
var pako = __importStar(require("pako"));
|
|
50
50
|
var JsonStorage = /** @class */function () {
|
|
51
51
|
function JsonStorage(path) {
|
|
52
|
-
this._state = {};
|
|
53
52
|
this.path = path;
|
|
54
|
-
this.init();
|
|
55
53
|
}
|
|
56
|
-
JsonStorage.prototype.init = function () {
|
|
57
|
-
try {
|
|
58
|
-
var buf = (0, fs_1.readFileSync)(this.path);
|
|
59
|
-
var data = pako.inflate(buf, {
|
|
60
|
-
to: 'string'
|
|
61
|
-
});
|
|
62
|
-
this._state = JSON.parse(data);
|
|
63
|
-
} catch (err) {
|
|
64
|
-
(0, fs_1.mkdirSync)(this.path.split('/').slice(0, -1).join('/'), {
|
|
65
|
-
recursive: true
|
|
66
|
-
});
|
|
67
|
-
this.state = {};
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
54
|
Object.defineProperty(JsonStorage.prototype, "state", {
|
|
71
55
|
get: function get() {
|
|
72
|
-
|
|
56
|
+
try {
|
|
57
|
+
var buf = (0, fs_1.readFileSync)(this.path);
|
|
58
|
+
var data = pako.inflate(buf, {
|
|
59
|
+
to: 'string'
|
|
60
|
+
});
|
|
61
|
+
return JSON.parse(data);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
console.log(err);
|
|
64
|
+
(0, fs_1.mkdirSync)(this.path.split('/').slice(0, -1).join('/'), {
|
|
65
|
+
recursive: true
|
|
66
|
+
});
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
73
69
|
},
|
|
74
70
|
set: function set(values) {
|
|
75
71
|
var data = pako.deflate(JSON.stringify(values));
|
|
@@ -77,7 +73,6 @@ var JsonStorage = /** @class */function () {
|
|
|
77
73
|
(0, fs_1.writeFile)(this.path, buf, function (err) {
|
|
78
74
|
return err && console.log(err);
|
|
79
75
|
});
|
|
80
|
-
this._state = values;
|
|
81
76
|
},
|
|
82
77
|
enumerable: false,
|
|
83
78
|
configurable: true
|
|
@@ -95,7 +90,7 @@ var JsonStorage = /** @class */function () {
|
|
|
95
90
|
this.state = temp;
|
|
96
91
|
};
|
|
97
92
|
JsonStorage.prototype.merge = function (values) {
|
|
98
|
-
this.state = __assign(__assign({}, this.
|
|
93
|
+
this.state = __assign(__assign({}, this.state), values);
|
|
99
94
|
};
|
|
100
95
|
return JsonStorage;
|
|
101
96
|
}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.100",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"pubo-utils": "^1.0.98",
|
|
25
25
|
"tree-kill": "^1.2.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "9da3e133aa57acf7f7ec8d5059e958276b15cfb5"
|
|
28
28
|
}
|