pubo-node 1.0.67 → 1.0.69
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/file-system/index.d.ts +3 -0
- package/es/file-system/index.js +14 -25
- package/es/ftp-client/index.d.ts +6 -5
- package/es/ftp-client/index.js +80 -146
- package/es/grpc/index.js +6 -18
- package/es/rtsp-video/index.js +24 -64
- package/es/rtsp-video/rtsp2mpeg.js +15 -44
- package/es/storage/json.js +2 -19
- package/lib/file-system/index.d.ts +3 -0
- package/lib/file-system/index.js +25 -40
- package/lib/ftp-client/index.d.ts +6 -5
- package/lib/ftp-client/index.js +80 -147
- package/lib/grpc/index.js +6 -20
- package/lib/index.js +1 -12
- package/lib/md5/index.js +4 -5
- package/lib/rtsp-video/index.js +30 -73
- package/lib/rtsp-video/rtsp2mpeg.js +16 -47
- package/lib/storage/json.js +15 -37
- package/package.json +3 -4
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,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=6)}([function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("pubo-utils")},function(t,e){t.exports=require("pako")},function(t,e){t.exports=require("path")},function(t,e){t.exports=require("child_process")},function(t,e){t.exports=require("crypto")},function(t,e,n){"use strict";n.r(e),n.d(e,"JsonStorage",(function(){return u})),n.d(e,"initRtspVideos",(function(){return w})),n.d(e,"RtspVideosManager",(function(){return g})),n.d(e,"FtpClient",(function(){return E})),n.d(e,"md5",(function(){return F})),n.d(e,"createRpcClient",(function(){return M})),n.d(e,"PuboFileSystem",(function(){return R}));var r=n(0),o=n(2),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}).apply(this,arguments)},u=function(){function t(t){this._state={},this.path=t,this.init()}return t.prototype.init=function(){try{var t=Object(r.readFileSync)(this.path),e=o.inflate(t,{to:"string"});this._state=JSON.parse(e)}catch(t){this.state={}}},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(t){var e=o.deflate(JSON.stringify(t)),n=Buffer.from(e);Object(r.writeFile)(this.path,n,(function(t){return t&&console.log(t)})),this._state=t},enumerable:!1,configurable:!0}),t.prototype.get=function(t){return t?this.state[t]:i({},this.state)},t.prototype.set=function(t,e){var n=i({},this.state);n[t]=e,this.state=n},t.prototype.merge=function(t){this.state=i(i({},this._state),t)},t}(),s=n(3),c=n(4),a=n(1),l=function(){return(l=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}).apply(this,arguments)},f=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},p=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(f(arguments[e]));return t},h=function(){function t(t,e){var n=this;this.eventEmitter=new a.Emitter,this.dog=new a.WatchDog({limit:10,onTimeout:function(){return n.connect()}}),this.url=t,this.options=l({},e),this.options.input||(this.options.input=["-rtsp_transport","tcp","-i"]),this.options.output||(this.options.output=["-f","mpegts","-codec:v","mpeg1video"]),this.connect(),this.dog.init()}return t.prototype.onMessage=function(t){this.dog.feed(),this.eventEmitter.emit("message",t.toString())},t.prototype.closeOld=function(){this.s&&(console.log("LOG Video-Server: "+this.url+" try to reconnect;"),this.s.kill(),this.s=null)},t.prototype.connect=function(){var t=this;this.closeOld();var e=p(this.options.input,[this.url],this.options.output,["-"]);this.s=Object(c.spawn)("ffmpeg",e,{detached:!1}),this.s.stderr.on("data",(function(e){return t.onMessage(e)})),this.s.stdout.on("data",(function(e){return t.eventEmitter.emit("data",e)}))},t.prototype.on=function(t,e){return this.eventEmitter.on(t,e)},t.prototype.cancel=function(t){this.eventEmitter.cancel(t)},t.prototype.destroy=function(){this.eventEmitter.clear(),this.dog.stop(),this.s&&(this.s.kill(),this.s=null)},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}).apply(this,arguments)},d=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},v=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},m=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(v(arguments[e]));return t},b=function(){function t(){this.path=Object(s.resolve)("resources/temp/videos.json")}return t.prototype.async=function(t){try{Object(r.writeFileSync)(this.path,JSON.stringify(t))}catch(t){console.log(t)}},Object.defineProperty(t.prototype,"data",{get:function(){try{var t=Object(r.readFileSync)(this.path);return console.log(t.toString()),JSON.parse(t.toString())}catch(t){return console.log(t),null}},enumerable:!1,configurable:!0}),t}(),g=function(){function t(t){this._system=[],this._customer=[],this.system=[],this.customer=[],this.storage=new b,this._system=t.map((function(t){return y(y({},t),{system:!0})})),this._customer=this.storage.data||[],this.system=t.map((function(t){var e=t.url,n=d(t,["url"]);return new h(e,n)})),this.customer=this._customer.map((function(t){var e=t.url,n=d(t,["url"]);return new h(e,n)}))}return Object.defineProperty(t.prototype,"list",{get:function(){return m(this.system,this.customer)},enumerable:!1,configurable:!0}),t.prototype.getVideos=function(){return m(this._system,this._customer)},t.prototype.create=function(t){if(this._customer.some((function(e){return e.url===t.url})))throw new Error("该地址已存在");var e=new h(t.url,t);this._customer.push(t),this.customer.push(e),this.storage.async(this._customer)},t.prototype.remove=function(t){if(t<this.system.length)throw new Error("系统配置不可删除");if(t>this.system.length+this.customer.length-1)throw new Error("超限");this._customer.splice(t-this.system.length-1,1),this.customer.splice(t-this.system.length-1,1)[0].destroy(),this.storage.async(this._customer)},t}(),w=function(t){var e=t.app,n=t.server,r=t.videos,o=t.path,i=t.expressWs,u=new g(r);return e.ws||i(e,n),e.ws(o,(function(t,e){var n=e.query.channel,r=void 0===n?0:n,o=null;u.list[r]&&(o=u.list[r].on("data",(function(e){t.send(e)}))),t.on("close",(function(){o&&u.list[r]&&u.list[r].cancel(o)}))})),u},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}).apply(this,arguments)},_=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,s)}c((r=r.apply(t,e||[])).next())}))},j=function(t,e){var n,r,o,i,u={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(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},S=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},x=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},P=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(x(arguments[e]));return t},E=function(){function t(t){var e=t.driver,n=S(t,["driver"]);this.queue=new a.SyncQueue,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.driver=e,this.options=n}return t.prototype._push=function(t){var e=this;return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.queue.push((function(){return t.call.apply(t,P([e],n))}))}},t.prototype._bind=function(t){var e=this;return this._push((function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return _(e,void 0,void 0,(function(){var e;return j(this,(function(r){switch(r.label){case 0:return[4,this.connect()];case 1:return e=r.sent(),[2,this._run(t,e,n)]}}))}))}))},t.prototype._run=function(t,e,n){return new Promise((function(r,o){e[t].apply(e,P(n,[function(n,i){n?(o(n),e.end()):(r(i||"operation successful."),"get"===t?i.once("close",(function(){return e.end()})):e.end())}]))}))},t.prototype.connect=function(){var t=this;return new Promise((function(e,n){var r=new t.driver;r.once("ready",(function(){e(r)})),r.once("error",(function(t){n(t),r.end()})),r.connect(O({},t.options))}))},t}(),q=n(5),F=function(t){return Object(q.createHash)("md5").update(t).digest("hex")},k=function(){return(k=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}).apply(this,arguments)};function M(t){var e=t.url,n=t.options,r=void 0===n?{}:n,o=t.ServiceImp,i=t.Grpc,u=k({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},r),s=new i.Client(e,i.credentials.createInsecure(),u);return new o({request:function(t,e,n){var r="/"+t+"/"+e;return new Promise((function(t,e){var o=function(t){return t};s.makeUnaryRequest(r,o,o,n,(function(n,r){n?e(n):t(r)}))}))}})}var J=function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.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 u},I=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(J(arguments[e]));return t},N=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,I(e,[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(I(e))}]))}))}},R={read:N(r.read),readFile:N(r.readFile),writeFile:N(r.writeFile),readdir:N(r.readdir),open:N(r.open),close:N(r.close),write:N(r.write)}}])}));
|
|
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={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{FtpClient:()=>x,JsonStorage:()=>i,PuboFileSystem:()=>I,RtspVideosManager:()=>g,createRpcClient:()=>k,initRtspVideos:()=>b,md5:()=>q});const r=require("fs"),n=require("pako");var o=function(){return o=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)},i=function(){function t(t){this._state={},this.path=t,this.init()}return t.prototype.init=function(){try{var t=(0,r.readFileSync)(this.path),e=n.inflate(t,{to:"string"});this._state=JSON.parse(e)}catch(t){this.state={}}},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},set:function(t){var e=n.deflate(JSON.stringify(t)),o=Buffer.from(e);(0,r.writeFile)(this.path,o,(function(t){return t&&console.log(t)})),this._state=t},enumerable:!1,configurable:!0}),t.prototype.get=function(t){return t?this.state[t]:o({},this.state)},t.prototype.set=function(t,e){var r=o({},this.state);r[t]=e,this.state=r},t.prototype.merge=function(t){this.state=o(o({},this._state),t)},t}();const s=require("path"),c=require("child_process"),u=require("pubo-utils");var a=function(){return a=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},a.apply(this,arguments)},l=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},p=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},f=function(){function t(t,e){var r=this;this.eventEmitter=new u.Emitter,this.dog=new u.WatchDog({limit:10,onTimeout:function(){return r.connect()}}),this.url=t,this.options=a({},e),this.options.input||(this.options.input=["-rtsp_transport","tcp","-i"]),this.options.output||(this.options.output=["-f","mpegts","-codec:v","mpeg1video"]),this.connect(),this.dog.init()}return t.prototype.onMessage=function(t){this.dog.feed(),this.eventEmitter.emit("message",t.toString())},t.prototype.closeOld=function(){this.s&&(console.log("LOG Video-Server: ".concat(this.url," try to reconnect;")),this.s.kill(),this.s=null)},t.prototype.connect=function(){var t=this;this.closeOld();var e=p(p(p(p([],l(this.options.input),!1),[this.url],!1),l(this.options.output),!1),["-"],!1);this.s=(0,c.spawn)("ffmpeg",e,{detached:!1}),this.s.stderr.on("data",(function(e){return t.onMessage(e)})),this.s.stdout.on("data",(function(e){return t.eventEmitter.emit("data",e)}))},t.prototype.on=function(t,e){return this.eventEmitter.on(t,e)},t.prototype.cancel=function(t){this.eventEmitter.cancel(t)},t.prototype.destroy=function(){this.eventEmitter.clear(),this.dog.stop(),this.s&&(this.s.kill(),this.s=null)},t}(),h=function(){return h=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},h.apply(this,arguments)},y=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},d=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},v=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},m=function(){function t(){this.path=(0,s.resolve)("resources/temp/videos.json")}return t.prototype.async=function(t){try{(0,r.writeFileSync)(this.path,JSON.stringify(t))}catch(t){console.log(t)}},Object.defineProperty(t.prototype,"data",{get:function(){try{var t=(0,r.readFileSync)(this.path);return console.log(t.toString()),JSON.parse(t.toString())}catch(t){return console.log(t),null}},enumerable:!1,configurable:!0}),t}(),g=function(){function t(t){this._system=[],this._customer=[],this.system=[],this.customer=[],this.storage=new m,this._system=t.map((function(t){return h(h({},t),{system:!0})})),this._customer=this.storage.data||[],this.system=t.map((function(t){var e=t.url,r=y(t,["url"]);return new f(e,r)})),this.customer=this._customer.map((function(t){var e=t.url,r=y(t,["url"]);return new f(e,r)}))}return Object.defineProperty(t.prototype,"list",{get:function(){return v(v([],d(this.system),!1),d(this.customer),!1)},enumerable:!1,configurable:!0}),t.prototype.getVideos=function(){return v(v([],d(this._system),!1),d(this._customer),!1)},t.prototype.create=function(t){if(this._customer.some((function(e){return e.url===t.url})))throw new Error("该地址已存在");var e=new f(t.url,t);this._customer.push(t),this.customer.push(e),this.storage.async(this._customer)},t.prototype.remove=function(t){if(t<this.system.length)throw new Error("系统配置不可删除");if(t>this.system.length+this.customer.length-1)throw new Error("超限");this._customer.splice(t-this.system.length-1,1),this.customer.splice(t-this.system.length-1,1)[0].destroy(),this.storage.async(this._customer)},t}(),b=function(t){var e=t.app,r=t.server,n=t.videos,o=t.path,i=t.expressWs,s=new g(n);return e.ws||i(e,r),e.ws(o,(function(t,e){var r=e.query.channel,n=void 0===r?0:r,o=null;s.list[n]&&(o=s.list[n].on("data",(function(e){t.send(e)}))),t.on("close",(function(){o&&s.list[n]&&s.list[n].cancel(o)}))})),s},w=function(){return w=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},w.apply(this,arguments)},O=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function c(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,c)}u((n=n.apply(t,e||[])).next())}))},_=function(t,e){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}},S=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r},j=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},P=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},x=function(){function t(t){var e=t.driver,r=S(t,["driver"]);this.queue=new u.SyncQueue,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.driver=e,this.options=r}return t.prototype._push=function(t){var e=this;return function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return e.queue.push((function(){return t.call.apply(t,P([e],j(r),!1))}))}},t.prototype._bind=function(t){var e=this;return this._push((function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return O(e,void 0,void 0,(function(){var e;return _(this,(function(n){switch(n.label){case 0:return[4,this.connect()];case 1:return e=n.sent(),[2,this._run(t,e,r)]}}))}))}))},t.prototype._run=function(t,e,r){return new Promise((function(n,o){e[t].apply(e,P(P([],j(r),!1),[function(r,i){r?(o(r),e.end()):(n(i||"operation successful."),"get"===t?i.once("close",(function(){return e.end()})):e.end())}],!1))}))},t.prototype.connect=function(){var t=this;return new Promise((function(e,r){var n=new t.driver;n.once("ready",(function(){e(n)})),n.once("error",(function(t){r(t),n.end()})),n.connect(w({},t.options))}))},t}();const E=require("crypto");var q=function(t){return(0,E.createHash)("md5").update(t).digest("hex")},F=function(){return F=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},F.apply(this,arguments)};function k(t){var e=t.url,r=t.options,n=void 0===r?{}:r,o=t.ServiceImp,i=t.Grpc,s=F({"grpc.max_send_message_length":-1,"grpc.max_receive_message_length":-1},n),c=new i.Client(e,i.credentials.createInsecure(),s);return new o({request:function(t,e,r){var n="/".concat(t,"/").concat(e);return new Promise((function(t,e){var o=function(t){return t};c.makeUnaryRequest(n,o,o,r,(function(r,n){r?e(r):t(n)}))}))}})}var A=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s},J=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},M=function(t){return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new Promise((function(r,n){t.apply(void 0,J(J([],A(e),!1),[function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];t&&n(t),e.length<2?r(e[0]):r(J([],A(e),!1))}],!1))}))}},I={read:M(r.read),readFile:M(r.readFile),writeFile:M(r.writeFile),readdir:M(r.readdir),open:M(r.open),close:M(r.close),write:M(r.write)};return e})()));
|
package/es/file-system/index.js
CHANGED
|
@@ -2,14 +2,11 @@ var __read = this && this.__read || function (o, n) {
|
|
|
2
2
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
3
|
if (!m) return o;
|
|
4
4
|
var i = m.call(o),
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
r,
|
|
6
|
+
ar = [],
|
|
7
|
+
e;
|
|
9
8
|
try {
|
|
10
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
11
|
-
ar.push(r.value);
|
|
12
|
-
}
|
|
9
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
13
10
|
} catch (error) {
|
|
14
11
|
e = {
|
|
15
12
|
error: error
|
|
@@ -21,50 +18,42 @@ var __read = this && this.__read || function (o, n) {
|
|
|
21
18
|
if (e) throw e.error;
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
return ar;
|
|
26
22
|
};
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
}
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
return ar;
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
34
31
|
};
|
|
35
|
-
|
|
36
32
|
import * as fs from 'fs';
|
|
37
|
-
|
|
38
33
|
var callbackToPromise = function callbackToPromise(fn) {
|
|
39
34
|
return function () {
|
|
40
35
|
var args = [];
|
|
41
|
-
|
|
42
36
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
43
37
|
args[_i] = arguments[_i];
|
|
44
38
|
}
|
|
45
|
-
|
|
46
39
|
return new Promise(function (resolve, reject) {
|
|
47
|
-
fn.apply(void 0,
|
|
40
|
+
fn.apply(void 0, __spreadArray(__spreadArray([], __read(args), false), [function (err) {
|
|
48
41
|
var rest = [];
|
|
49
|
-
|
|
50
42
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
51
43
|
rest[_i - 1] = arguments[_i];
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
if (err) {
|
|
55
46
|
reject(err);
|
|
56
47
|
}
|
|
57
|
-
|
|
58
48
|
if (rest.length < 2) {
|
|
59
49
|
resolve(rest[0]);
|
|
60
50
|
} else {
|
|
61
|
-
resolve(
|
|
51
|
+
resolve(__spreadArray([], __read(rest), false));
|
|
62
52
|
}
|
|
63
|
-
}]));
|
|
53
|
+
}], false));
|
|
64
54
|
});
|
|
65
55
|
};
|
|
66
56
|
};
|
|
67
|
-
|
|
68
57
|
export var PuboFileSystem = {
|
|
69
58
|
read: callbackToPromise(fs.read),
|
|
70
59
|
readFile: callbackToPromise(fs.readFile),
|
package/es/ftp-client/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import type { Stream } from 'stream';
|
|
3
4
|
interface FtpFile {
|
|
4
5
|
name: string;
|
|
@@ -13,11 +14,11 @@ interface FtpConnectOptions {
|
|
|
13
14
|
host: string;
|
|
14
15
|
password: string;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
type GetFile = (path: string) => Promise<Stream>;
|
|
18
|
+
type PutFile = (input: string | Buffer | Stream, path: string) => Promise<string>;
|
|
19
|
+
type DeleteFile = (path: string) => Promise<string>;
|
|
20
|
+
type ListFiles = (path: string) => Promise<FtpFile[]>;
|
|
21
|
+
type RenameFile = (path: string, old: string) => Promise<string>;
|
|
21
22
|
export declare class FtpClient {
|
|
22
23
|
private readonly driver;
|
|
23
24
|
private readonly options;
|
package/es/ftp-client/index.js
CHANGED
|
@@ -2,25 +2,18 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
|
-
for (var p in s) {
|
|
7
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
-
}
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
6
|
}
|
|
10
|
-
|
|
11
7
|
return t;
|
|
12
8
|
};
|
|
13
|
-
|
|
14
9
|
return __assign.apply(this, arguments);
|
|
15
10
|
};
|
|
16
|
-
|
|
17
11
|
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
18
12
|
function adopt(value) {
|
|
19
13
|
return value instanceof P ? value : new P(function (resolve) {
|
|
20
14
|
resolve(value);
|
|
21
15
|
});
|
|
22
16
|
}
|
|
23
|
-
|
|
24
17
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
25
18
|
function fulfilled(value) {
|
|
26
19
|
try {
|
|
@@ -29,7 +22,6 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
29
22
|
reject(e);
|
|
30
23
|
}
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
function rejected(value) {
|
|
34
26
|
try {
|
|
35
27
|
step(generator["throw"](value));
|
|
@@ -37,29 +29,26 @@ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, gene
|
|
|
37
29
|
reject(e);
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
function step(result) {
|
|
42
33
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
46
36
|
});
|
|
47
37
|
};
|
|
48
|
-
|
|
49
38
|
var __generator = this && this.__generator || function (thisArg, body) {
|
|
50
39
|
var _ = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
label: 0,
|
|
41
|
+
sent: function sent() {
|
|
42
|
+
if (t[0] & 1) throw t[1];
|
|
43
|
+
return t[1];
|
|
44
|
+
},
|
|
45
|
+
trys: [],
|
|
46
|
+
ops: []
|
|
55
47
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
y,
|
|
61
|
-
t,
|
|
62
|
-
g;
|
|
48
|
+
f,
|
|
49
|
+
y,
|
|
50
|
+
t,
|
|
51
|
+
g;
|
|
63
52
|
return g = {
|
|
64
53
|
next: verb(0),
|
|
65
54
|
"throw": verb(1),
|
|
@@ -67,88 +56,66 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
67
56
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
68
57
|
return this;
|
|
69
58
|
}), g;
|
|
70
|
-
|
|
71
59
|
function verb(n) {
|
|
72
60
|
return function (v) {
|
|
73
61
|
return step([n, v]);
|
|
74
62
|
};
|
|
75
63
|
}
|
|
76
|
-
|
|
77
64
|
function step(op) {
|
|
78
65
|
if (f) throw new TypeError("Generator is already executing.");
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
66
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
67
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
68
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
+
switch (op[0]) {
|
|
70
|
+
case 0:
|
|
71
|
+
case 1:
|
|
72
|
+
t = op;
|
|
73
|
+
break;
|
|
74
|
+
case 4:
|
|
75
|
+
_.label++;
|
|
76
|
+
return {
|
|
77
|
+
value: op[1],
|
|
78
|
+
done: false
|
|
79
|
+
};
|
|
80
|
+
case 5:
|
|
81
|
+
_.label++;
|
|
82
|
+
y = op[1];
|
|
83
|
+
op = [0];
|
|
84
|
+
continue;
|
|
85
|
+
case 7:
|
|
86
|
+
op = _.ops.pop();
|
|
87
|
+
_.trys.pop();
|
|
88
|
+
continue;
|
|
89
|
+
default:
|
|
90
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
91
|
+
_ = 0;
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
95
|
+
_.label = op[1];
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
99
|
+
_.label = t[1];
|
|
88
100
|
t = op;
|
|
89
101
|
break;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
_.label
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
_.label++;
|
|
100
|
-
y = op[1];
|
|
101
|
-
op = [0];
|
|
102
|
-
continue;
|
|
103
|
-
|
|
104
|
-
case 7:
|
|
105
|
-
op = _.ops.pop();
|
|
106
|
-
|
|
107
|
-
_.trys.pop();
|
|
108
|
-
|
|
109
|
-
continue;
|
|
110
|
-
|
|
111
|
-
default:
|
|
112
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
113
|
-
_ = 0;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
118
|
-
_.label = op[1];
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
123
|
-
_.label = t[1];
|
|
124
|
-
t = op;
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (t && _.label < t[2]) {
|
|
129
|
-
_.label = t[2];
|
|
130
|
-
|
|
131
|
-
_.ops.push(op);
|
|
132
|
-
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (t[2]) _.ops.pop();
|
|
137
|
-
|
|
138
|
-
_.trys.pop();
|
|
139
|
-
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
op = body.call(thisArg, _);
|
|
144
|
-
} catch (e) {
|
|
145
|
-
op = [6, e];
|
|
146
|
-
y = 0;
|
|
147
|
-
} finally {
|
|
148
|
-
f = t = 0;
|
|
102
|
+
}
|
|
103
|
+
if (t && _.label < t[2]) {
|
|
104
|
+
_.label = t[2];
|
|
105
|
+
_.ops.push(op);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
if (t[2]) _.ops.pop();
|
|
109
|
+
_.trys.pop();
|
|
110
|
+
continue;
|
|
149
111
|
}
|
|
112
|
+
op = body.call(thisArg, _);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
op = [6, e];
|
|
115
|
+
y = 0;
|
|
116
|
+
} finally {
|
|
117
|
+
f = t = 0;
|
|
150
118
|
}
|
|
151
|
-
|
|
152
119
|
if (op[0] & 5) throw op[1];
|
|
153
120
|
return {
|
|
154
121
|
value: op[0] ? op[1] : void 0,
|
|
@@ -156,32 +123,23 @@ var __generator = this && this.__generator || function (thisArg, body) {
|
|
|
156
123
|
};
|
|
157
124
|
}
|
|
158
125
|
};
|
|
159
|
-
|
|
160
126
|
var __rest = this && this.__rest || function (s, e) {
|
|
161
127
|
var t = {};
|
|
162
|
-
|
|
163
|
-
for (var p in s) {
|
|
164
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
165
|
-
}
|
|
166
|
-
|
|
128
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
167
129
|
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
168
130
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
169
131
|
}
|
|
170
132
|
return t;
|
|
171
133
|
};
|
|
172
|
-
|
|
173
134
|
var __read = this && this.__read || function (o, n) {
|
|
174
135
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
175
136
|
if (!m) return o;
|
|
176
137
|
var i = m.call(o),
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
138
|
+
r,
|
|
139
|
+
ar = [],
|
|
140
|
+
e;
|
|
181
141
|
try {
|
|
182
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
183
|
-
ar.push(r.value);
|
|
184
|
-
}
|
|
142
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
185
143
|
} catch (error) {
|
|
186
144
|
e = {
|
|
187
145
|
error: error
|
|
@@ -193,27 +151,22 @@ var __read = this && this.__read || function (o, n) {
|
|
|
193
151
|
if (e) throw e.error;
|
|
194
152
|
}
|
|
195
153
|
}
|
|
196
|
-
|
|
197
154
|
return ar;
|
|
198
155
|
};
|
|
199
|
-
|
|
200
|
-
var
|
|
201
|
-
|
|
202
|
-
|
|
156
|
+
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
157
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
158
|
+
if (ar || !(i in from)) {
|
|
159
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
160
|
+
ar[i] = from[i];
|
|
161
|
+
}
|
|
203
162
|
}
|
|
204
|
-
|
|
205
|
-
return ar;
|
|
163
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
206
164
|
};
|
|
207
|
-
|
|
208
165
|
import { SyncQueue } from 'pubo-utils';
|
|
209
|
-
|
|
210
|
-
var FtpClient =
|
|
211
|
-
/** @class */
|
|
212
|
-
function () {
|
|
166
|
+
var FtpClient = /** @class */function () {
|
|
213
167
|
function FtpClient(_a) {
|
|
214
168
|
var driver = _a.driver,
|
|
215
|
-
|
|
216
|
-
|
|
169
|
+
options = __rest(_a, ["driver"]);
|
|
217
170
|
this.queue = new SyncQueue();
|
|
218
171
|
this.get = this._bind('get');
|
|
219
172
|
this.put = this._bind('put');
|
|
@@ -223,62 +176,47 @@ function () {
|
|
|
223
176
|
this.driver = driver;
|
|
224
177
|
this.options = options;
|
|
225
178
|
}
|
|
226
|
-
|
|
227
179
|
FtpClient.prototype._push = function (cb) {
|
|
228
180
|
var _this = this;
|
|
229
|
-
|
|
230
181
|
return function () {
|
|
231
182
|
var args = [];
|
|
232
|
-
|
|
233
183
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
234
184
|
args[_i] = arguments[_i];
|
|
235
185
|
}
|
|
236
|
-
|
|
237
186
|
return _this.queue.push(function () {
|
|
238
|
-
return cb.call.apply(cb,
|
|
187
|
+
return cb.call.apply(cb, __spreadArray([_this], __read(args), false));
|
|
239
188
|
});
|
|
240
189
|
};
|
|
241
190
|
};
|
|
242
|
-
|
|
243
191
|
FtpClient.prototype._bind = function (fn) {
|
|
244
192
|
var _this = this;
|
|
245
|
-
|
|
246
193
|
return this._push(function () {
|
|
247
194
|
var args = [];
|
|
248
|
-
|
|
249
195
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
250
196
|
args[_i] = arguments[_i];
|
|
251
197
|
}
|
|
252
|
-
|
|
253
198
|
return __awaiter(_this, void 0, void 0, function () {
|
|
254
199
|
var c;
|
|
255
200
|
return __generator(this, function (_a) {
|
|
256
201
|
switch (_a.label) {
|
|
257
202
|
case 0:
|
|
258
|
-
return [4
|
|
259
|
-
/*yield*/
|
|
260
|
-
, this.connect()];
|
|
261
|
-
|
|
203
|
+
return [4 /*yield*/, this.connect()];
|
|
262
204
|
case 1:
|
|
263
205
|
c = _a.sent();
|
|
264
|
-
return [2
|
|
265
|
-
/*return*/
|
|
266
|
-
, this._run(fn, c, args)];
|
|
206
|
+
return [2 /*return*/, this._run(fn, c, args)];
|
|
267
207
|
}
|
|
268
208
|
});
|
|
269
209
|
});
|
|
270
210
|
});
|
|
271
211
|
};
|
|
272
|
-
|
|
273
212
|
FtpClient.prototype._run = function (fn, c, args) {
|
|
274
213
|
return new Promise(function (resolve, reject) {
|
|
275
|
-
c[fn].apply(c,
|
|
214
|
+
c[fn].apply(c, __spreadArray(__spreadArray([], __read(args), false), [function (err, res) {
|
|
276
215
|
if (err) {
|
|
277
216
|
reject(err);
|
|
278
217
|
c.end();
|
|
279
218
|
} else {
|
|
280
219
|
resolve(res || 'operation successful.');
|
|
281
|
-
|
|
282
220
|
if (fn === 'get') {
|
|
283
221
|
res.once('close', function () {
|
|
284
222
|
return c.end();
|
|
@@ -287,13 +225,11 @@ function () {
|
|
|
287
225
|
c.end();
|
|
288
226
|
}
|
|
289
227
|
}
|
|
290
|
-
}]));
|
|
228
|
+
}], false));
|
|
291
229
|
});
|
|
292
230
|
};
|
|
293
|
-
|
|
294
231
|
FtpClient.prototype.connect = function () {
|
|
295
232
|
var _this = this;
|
|
296
|
-
|
|
297
233
|
return new Promise(function (resolve, reject) {
|
|
298
234
|
var c = new _this.driver();
|
|
299
235
|
c.once('ready', function () {
|
|
@@ -306,8 +242,6 @@ function () {
|
|
|
306
242
|
c.connect(__assign({}, _this.options));
|
|
307
243
|
});
|
|
308
244
|
};
|
|
309
|
-
|
|
310
245
|
return FtpClient;
|
|
311
246
|
}();
|
|
312
|
-
|
|
313
247
|
export { FtpClient };
|
package/es/grpc/index.js
CHANGED
|
@@ -2,34 +2,25 @@ var __assign = this && this.__assign || function () {
|
|
|
2
2
|
__assign = Object.assign || function (t) {
|
|
3
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
4
|
s = arguments[i];
|
|
5
|
-
|
|
6
|
-
for (var p in s) {
|
|
7
|
-
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
8
|
-
}
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
6
|
}
|
|
10
|
-
|
|
11
7
|
return t;
|
|
12
8
|
};
|
|
13
|
-
|
|
14
9
|
return __assign.apply(this, arguments);
|
|
15
10
|
};
|
|
16
|
-
|
|
17
11
|
export function createRpcClient(_a) {
|
|
18
12
|
var url = _a.url,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
_b = _a.options,
|
|
14
|
+
options = _b === void 0 ? {} : _b,
|
|
15
|
+
ServiceImp = _a.ServiceImp,
|
|
16
|
+
Grpc = _a.Grpc;
|
|
24
17
|
var opt = __assign({
|
|
25
18
|
'grpc.max_send_message_length': -1,
|
|
26
19
|
'grpc.max_receive_message_length': -1
|
|
27
20
|
}, options);
|
|
28
|
-
|
|
29
21
|
var connection = new Grpc.Client(url, Grpc.credentials.createInsecure(), opt);
|
|
30
|
-
|
|
31
22
|
var request = function request(service, method, data) {
|
|
32
|
-
var path = "/"
|
|
23
|
+
var path = "/".concat(service, "/").concat(method);
|
|
33
24
|
return new Promise(function (resolve, reject) {
|
|
34
25
|
var resultCallback = function resultCallback(err, res) {
|
|
35
26
|
if (err) {
|
|
@@ -38,15 +29,12 @@ export function createRpcClient(_a) {
|
|
|
38
29
|
resolve(res);
|
|
39
30
|
}
|
|
40
31
|
};
|
|
41
|
-
|
|
42
32
|
var passThrough = function passThrough(argument) {
|
|
43
33
|
return argument;
|
|
44
34
|
};
|
|
45
|
-
|
|
46
35
|
connection.makeUnaryRequest(path, passThrough, passThrough, data, resultCallback);
|
|
47
36
|
});
|
|
48
37
|
};
|
|
49
|
-
|
|
50
38
|
return new ServiceImp({
|
|
51
39
|
request: request
|
|
52
40
|
});
|