pubo-node 1.0.31 → 1.0.33

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,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["pubo-node"]=n():t["pubo-node"]=n()}(this,(function(){return function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=3)}([function(t,n){t.exports=require("pubo-utils")},function(t,n){t.exports=require("child_process")},function(t,n){t.exports=require("crypto")},function(t,n,e){"use strict";e.r(n),e.d(n,"initRtspVideos",(function(){return g})),e.d(n,"md5",(function(){return p})),e.d(n,"FtpClient",(function(){return l}));var r=e(0),o=function(){return(o=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},i=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}s((r=r.apply(t,n||[])).next())}))},u=function(t,n){var e,r,o,i,u={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(i){return function(c){return function(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=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=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}},c=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e},s=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},a=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(s(arguments[n]));return t},l=function(){function t(t){var n=t.driver,e=c(t,["driver"]);this.queue=new r.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=n,this.options=e}return t.prototype._push=function(t){var n=this;return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return n.queue.push((function(){return t.call.apply(t,a([n],e))}))}},t.prototype._bind=function(t){var n=this;return this._push((function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return i(n,void 0,void 0,(function(){var n;return u(this,(function(r){switch(r.label){case 0:return[4,this.connect()];case 1:return n=r.sent(),[2,this._run(t,n,e)]}}))}))}))},t.prototype._run=function(t,n,e){return new Promise((function(r,o){n[t].apply(n,a(e,[function(e,i){e?(o(e),n.end()):(r(i||"operation successful."),"get"===t?i.once("close",(function(){return n.end()})):n.end())}]))}))},t.prototype.connect=function(){var t=this;return new Promise((function(n,e){var r=new t.driver;r.once("ready",(function(){n(r)})),r.once("error",(function(t){e(t),r.end()})),r.connect(o({},t.options))}))},t}(),f=e(2),p=function(t){return Object(f.createHash)("md5").update(t).digest("hex")},h=e(1),d=function(){return(d=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t}).apply(this,arguments)},y=function(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u},v=function(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(y(arguments[n]));return t},b=function(){function t(t,n){var e=this;this.eventEmitter=new r.Emitter,this.dog=new r.WatchDog({limit:10,onTimeout:function(){return e.connect()}}),this.url=t,this.options=d({},n),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 n=v(this.options.input,[this.url],this.options.output,["-"]);this.s=Object(h.spawn)("ffmpeg",n,{detached:!1}),this.s.stderr.on("data",(function(n){return t.onMessage(n)})),this.s.stdout.on("data",(function(n){return t.eventEmitter.emit("data",n)}))},t.prototype.on=function(t,n){return this.eventEmitter.on(t,n)},t.prototype.cancel=function(t){this.eventEmitter.cancel(t)},t}(),m=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e},g=function(t){var n=t.app,e=t.server,r=t.videos,o=t.path,i=t.expressWs,u=r.map((function(t){var n=t.url,e=m(t,["url"]);return new b(n,e)}));return n.ws||i(n,e),n.ws(o,(function(t,n){var e=n.query.channel,r=void 0===e?0:e,o=null;u[r]&&(o=u[r].on("data",(function(n){t.send(n)}))),t.on("close",(function(){o&&u[r].cancel(o)}))})),u}}])}));
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=5)}([function(t,e){t.exports=require("pubo-utils")},function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("pako")},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 y})),n.d(e,"FtpClient",(function(){return w})),n.d(e,"md5",(function(){return x}));var r=n(1),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}(),c=n(3),s=n(0),a=function(){return(a=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).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},l=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(f(arguments[e]));return t},p=function(){function t(t,e){var n=this;this.eventEmitter=new s.Emitter,this.dog=new s.WatchDog({limit:10,onTimeout:function(){return n.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: "+this.url+" try to reconnect;"),this.s.kill(),this.s=null)},t.prototype.connect=function(){var t=this;this.closeOld();var e=l(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}(),h=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},y=function(t){var e=t.app,n=t.server,r=t.videos,o=t.path,i=t.expressWs,u=r.map((function(t){var e=t.url,n=h(t,["url"]);return new p(e,n)}));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[r]&&(o=u[r].on("data",(function(e){t.send(e)}))),t.on("close",(function(){o&&u[r].cancel(o)}))})),u},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}).apply(this,arguments)},v=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function u(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(u,c)}s((r=r.apply(t,e||[])).next())}))},b=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:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){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,c])}}},g=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},m=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},O=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(m(arguments[e]));return t},w=function(){function t(t){var e=t.driver,n=g(t,["driver"]);this.queue=new s.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,O([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 v(e,void 0,void 0,(function(){var e;return b(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,O(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(d({},t.options))}))},t}(),j=n(4),x=function(t){return Object(j.createHash)("md5").update(t).digest("hex")}}])}));
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FtpClient } from './ftp-client';
2
- import { md5 } from './md5';
3
- import { initRtspVideos } from './rtsp-video';
4
- export { initRtspVideos, md5, FtpClient };
1
+ export { JsonStorage } from './storage/json';
2
+ export { initRtspVideos } from './rtsp-video';
3
+ export { FtpClient } from './ftp-client';
4
+ export { md5 } from './md5';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FtpClient } from './ftp-client';
2
- import { md5 } from './md5';
3
- import { initRtspVideos } from './rtsp-video';
4
- export { initRtspVideos, md5, FtpClient };
1
+ export { JsonStorage } from './storage/json';
2
+ export { initRtspVideos } from './rtsp-video';
3
+ export { FtpClient } from './ftp-client';
4
+ export { md5 } from './md5';
@@ -0,0 +1,11 @@
1
+ export declare class JsonStorage {
2
+ private readonly path;
3
+ private _state;
4
+ constructor(path: string);
5
+ private init;
6
+ private set state(value);
7
+ private get state();
8
+ get(key?: string): any;
9
+ set(key: string, values: any): void;
10
+ merge(values: any): void;
11
+ }
@@ -0,0 +1,79 @@
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
+
6
+ for (var p in s) {
7
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
8
+ }
9
+ }
10
+
11
+ return t;
12
+ };
13
+
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ import { readFileSync, writeFile } from 'fs';
18
+ import * as pako from 'pako';
19
+
20
+ var JsonStorage =
21
+ /** @class */
22
+ function () {
23
+ function JsonStorage(path) {
24
+ this._state = {};
25
+ this.path = path;
26
+ this.init();
27
+ }
28
+
29
+ JsonStorage.prototype.init = function () {
30
+ try {
31
+ var buf = readFileSync(this.path);
32
+ var data = pako.inflate(buf, {
33
+ to: 'string'
34
+ });
35
+ this._state = JSON.parse(data);
36
+ } catch (err) {
37
+ this.state = {};
38
+ }
39
+ };
40
+
41
+ Object.defineProperty(JsonStorage.prototype, "state", {
42
+ get: function get() {
43
+ return this._state;
44
+ },
45
+ set: function set(values) {
46
+ var data = pako.deflate(JSON.stringify(values));
47
+ var buf = Buffer.from(data);
48
+ writeFile(this.path, buf, function (err) {
49
+ return err && console.log(err);
50
+ });
51
+ this._state = values;
52
+ },
53
+ enumerable: false,
54
+ configurable: true
55
+ });
56
+
57
+ JsonStorage.prototype.get = function (key) {
58
+ if (!key) {
59
+ return __assign({}, this.state);
60
+ } else {
61
+ return this.state[key];
62
+ }
63
+ };
64
+
65
+ JsonStorage.prototype.set = function (key, values) {
66
+ var temp = __assign({}, this.state);
67
+
68
+ temp[key] = values;
69
+ this.state = temp;
70
+ };
71
+
72
+ JsonStorage.prototype.merge = function (values) {
73
+ this.state = __assign(__assign({}, this._state), values);
74
+ };
75
+
76
+ return JsonStorage;
77
+ }();
78
+
79
+ export { JsonStorage };
package/lib/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { FtpClient } from './ftp-client';
2
- import { md5 } from './md5';
3
- import { initRtspVideos } from './rtsp-video';
4
- export { initRtspVideos, md5, FtpClient };
1
+ export { JsonStorage } from './storage/json';
2
+ export { initRtspVideos } from './rtsp-video';
3
+ export { FtpClient } from './ftp-client';
4
+ export { md5 } from './md5';
package/lib/index.js CHANGED
@@ -3,31 +3,39 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.FtpClient = exports.md5 = exports.initRtspVideos = void 0;
7
6
 
8
- var ftp_client_1 = require("./ftp-client");
7
+ var json_1 = require("./storage/json");
9
8
 
10
- Object.defineProperty(exports, "FtpClient", {
9
+ Object.defineProperty(exports, "JsonStorage", {
11
10
  enumerable: true,
12
11
  get: function get() {
13
- return ftp_client_1.FtpClient;
12
+ return json_1.JsonStorage;
14
13
  }
15
14
  });
16
15
 
17
- var md5_1 = require("./md5");
16
+ var rtsp_video_1 = require("./rtsp-video");
18
17
 
19
- Object.defineProperty(exports, "md5", {
18
+ Object.defineProperty(exports, "initRtspVideos", {
20
19
  enumerable: true,
21
20
  get: function get() {
22
- return md5_1.md5;
21
+ return rtsp_video_1.initRtspVideos;
23
22
  }
24
23
  });
25
24
 
26
- var rtsp_video_1 = require("./rtsp-video");
25
+ var ftp_client_1 = require("./ftp-client");
27
26
 
28
- Object.defineProperty(exports, "initRtspVideos", {
27
+ Object.defineProperty(exports, "FtpClient", {
29
28
  enumerable: true,
30
29
  get: function get() {
31
- return rtsp_video_1.initRtspVideos;
30
+ return ftp_client_1.FtpClient;
31
+ }
32
+ });
33
+
34
+ var md5_1 = require("./md5");
35
+
36
+ Object.defineProperty(exports, "md5", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return md5_1.md5;
32
40
  }
33
41
  });
@@ -0,0 +1,11 @@
1
+ export declare class JsonStorage {
2
+ private readonly path;
3
+ private _state;
4
+ constructor(path: string);
5
+ private init;
6
+ private set state(value);
7
+ private get state();
8
+ get(key?: string): any;
9
+ set(key: string, values: any): void;
10
+ merge(values: any): void;
11
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
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
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ Object.defineProperty(o, k2, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return m[k];
25
+ }
26
+ });
27
+ } : function (o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ });
31
+
32
+ var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
33
+ Object.defineProperty(o, "default", {
34
+ enumerable: true,
35
+ value: v
36
+ });
37
+ } : function (o, v) {
38
+ o["default"] = v;
39
+ });
40
+
41
+ var __importStar = this && this.__importStar || function (mod) {
42
+ if (mod && mod.__esModule) return mod;
43
+ var result = {};
44
+ if (mod != null) for (var k in mod) {
45
+ if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
46
+ }
47
+
48
+ __setModuleDefault(result, mod);
49
+
50
+ return result;
51
+ };
52
+
53
+ Object.defineProperty(exports, "__esModule", {
54
+ value: true
55
+ });
56
+ exports.JsonStorage = void 0;
57
+
58
+ var fs_1 = require("fs");
59
+
60
+ var pako = __importStar(require("pako"));
61
+
62
+ var JsonStorage =
63
+ /** @class */
64
+ function () {
65
+ function JsonStorage(path) {
66
+ this._state = {};
67
+ this.path = path;
68
+ this.init();
69
+ }
70
+
71
+ JsonStorage.prototype.init = function () {
72
+ try {
73
+ var buf = fs_1.readFileSync(this.path);
74
+ var data = pako.inflate(buf, {
75
+ to: 'string'
76
+ });
77
+ this._state = JSON.parse(data);
78
+ } catch (err) {
79
+ this.state = {};
80
+ }
81
+ };
82
+
83
+ Object.defineProperty(JsonStorage.prototype, "state", {
84
+ get: function get() {
85
+ return this._state;
86
+ },
87
+ set: function set(values) {
88
+ var data = pako.deflate(JSON.stringify(values));
89
+ var buf = Buffer.from(data);
90
+ fs_1.writeFile(this.path, buf, function (err) {
91
+ return err && console.log(err);
92
+ });
93
+ this._state = values;
94
+ },
95
+ enumerable: false,
96
+ configurable: true
97
+ });
98
+
99
+ JsonStorage.prototype.get = function (key) {
100
+ if (!key) {
101
+ return __assign({}, this.state);
102
+ } else {
103
+ return this.state[key];
104
+ }
105
+ };
106
+
107
+ JsonStorage.prototype.set = function (key, values) {
108
+ var temp = __assign({}, this.state);
109
+
110
+ temp[key] = values;
111
+ this.state = temp;
112
+ };
113
+
114
+ JsonStorage.prototype.merge = function (values) {
115
+ this.state = __assign(__assign({}, this._state), values);
116
+ };
117
+
118
+ return JsonStorage;
119
+ }();
120
+
121
+ exports.JsonStorage = JsonStorage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-node",
3
- "version": "1.0.31",
3
+ "version": "1.0.33",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -20,7 +20,8 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@types/node": "^17.0.25",
23
- "pubo-utils": "^1.0.31"
23
+ "pako": "^2.0.4",
24
+ "pubo-utils": "^1.0.33"
24
25
  },
25
- "gitHead": "0c059c643c1c93dcbaeb3a5b47335c3c36200fe3"
26
+ "gitHead": "c6ca5e15ecf69336c5614aac127c74186e7c25c9"
26
27
  }