@thescaffold/jsx-core 0.0.0
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/README.md +61 -0
- package/error/index.d.ts +1 -0
- package/index.d.ts +8 -0
- package/index.js +8 -0
- package/jsx-core.cjs.development.js +1133 -0
- package/jsx-core.cjs.development.js.map +1 -0
- package/jsx-core.cjs.production.min.js +2 -0
- package/jsx-core.cjs.production.min.js.map +1 -0
- package/jsx-core.esm.js +1113 -0
- package/jsx-core.esm.js.map +1 -0
- package/package.json +16 -0
- package/request/index.d.ts +1 -0
- package/request/request.d.ts +4 -0
- package/request/request.service.d.ts +16 -0
- package/storage/index.d.ts +3 -0
- package/storage/local.storage.d.ts +13 -0
- package/storage/session.storage.d.ts +14 -0
- package/storage/storage.d.ts +11 -0
- package/store/file.store.d.ts +7 -0
- package/store/index.d.ts +3 -0
- package/store/memory.store.d.ts +8 -0
- package/store/store.d.ts +8 -0
- package/utils/functions.d.ts +13 -0
- package/utils/index.d.ts +2 -0
- package/utils/values.d.ts +197 -0
|
@@ -0,0 +1,1133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('fs/promises');
|
|
4
|
+
var os = require('os');
|
|
5
|
+
|
|
6
|
+
var _stackTrace = function stackTrace() {
|
|
7
|
+
var error;
|
|
8
|
+
if (typeof Error.captureStackTrace === 'function') {
|
|
9
|
+
error = {};
|
|
10
|
+
Error.captureStackTrace(error, _stackTrace);
|
|
11
|
+
} else {
|
|
12
|
+
error = new Error();
|
|
13
|
+
}
|
|
14
|
+
return error.stack || '';
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
18
|
+
try {
|
|
19
|
+
var i = n[a](c),
|
|
20
|
+
u = i.value;
|
|
21
|
+
} catch (n) {
|
|
22
|
+
return void e(n);
|
|
23
|
+
}
|
|
24
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
25
|
+
}
|
|
26
|
+
function _asyncToGenerator(n) {
|
|
27
|
+
return function () {
|
|
28
|
+
var t = this,
|
|
29
|
+
e = arguments;
|
|
30
|
+
return new Promise(function (r, o) {
|
|
31
|
+
var a = n.apply(t, e);
|
|
32
|
+
function _next(n) {
|
|
33
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
34
|
+
}
|
|
35
|
+
function _throw(n) {
|
|
36
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
37
|
+
}
|
|
38
|
+
_next(void 0);
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function _extends() {
|
|
43
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
44
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
45
|
+
var t = arguments[e];
|
|
46
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
47
|
+
}
|
|
48
|
+
return n;
|
|
49
|
+
}, _extends.apply(null, arguments);
|
|
50
|
+
}
|
|
51
|
+
function _regeneratorRuntime() {
|
|
52
|
+
_regeneratorRuntime = function () {
|
|
53
|
+
return e;
|
|
54
|
+
};
|
|
55
|
+
var t,
|
|
56
|
+
e = {},
|
|
57
|
+
r = Object.prototype,
|
|
58
|
+
n = r.hasOwnProperty,
|
|
59
|
+
o = Object.defineProperty || function (t, e, r) {
|
|
60
|
+
t[e] = r.value;
|
|
61
|
+
},
|
|
62
|
+
i = "function" == typeof Symbol ? Symbol : {},
|
|
63
|
+
a = i.iterator || "@@iterator",
|
|
64
|
+
c = i.asyncIterator || "@@asyncIterator",
|
|
65
|
+
u = i.toStringTag || "@@toStringTag";
|
|
66
|
+
function define(t, e, r) {
|
|
67
|
+
return Object.defineProperty(t, e, {
|
|
68
|
+
value: r,
|
|
69
|
+
enumerable: !0,
|
|
70
|
+
configurable: !0,
|
|
71
|
+
writable: !0
|
|
72
|
+
}), t[e];
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
define({}, "");
|
|
76
|
+
} catch (t) {
|
|
77
|
+
define = function (t, e, r) {
|
|
78
|
+
return t[e] = r;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function wrap(t, e, r, n) {
|
|
82
|
+
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
83
|
+
a = Object.create(i.prototype),
|
|
84
|
+
c = new Context(n || []);
|
|
85
|
+
return o(a, "_invoke", {
|
|
86
|
+
value: makeInvokeMethod(t, r, c)
|
|
87
|
+
}), a;
|
|
88
|
+
}
|
|
89
|
+
function tryCatch(t, e, r) {
|
|
90
|
+
try {
|
|
91
|
+
return {
|
|
92
|
+
type: "normal",
|
|
93
|
+
arg: t.call(e, r)
|
|
94
|
+
};
|
|
95
|
+
} catch (t) {
|
|
96
|
+
return {
|
|
97
|
+
type: "throw",
|
|
98
|
+
arg: t
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
e.wrap = wrap;
|
|
103
|
+
var h = "suspendedStart",
|
|
104
|
+
l = "suspendedYield",
|
|
105
|
+
f = "executing",
|
|
106
|
+
s = "completed",
|
|
107
|
+
y = {};
|
|
108
|
+
function Generator() {}
|
|
109
|
+
function GeneratorFunction() {}
|
|
110
|
+
function GeneratorFunctionPrototype() {}
|
|
111
|
+
var p = {};
|
|
112
|
+
define(p, a, function () {
|
|
113
|
+
return this;
|
|
114
|
+
});
|
|
115
|
+
var d = Object.getPrototypeOf,
|
|
116
|
+
v = d && d(d(values([])));
|
|
117
|
+
v && v !== r && n.call(v, a) && (p = v);
|
|
118
|
+
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
119
|
+
function defineIteratorMethods(t) {
|
|
120
|
+
["next", "throw", "return"].forEach(function (e) {
|
|
121
|
+
define(t, e, function (t) {
|
|
122
|
+
return this._invoke(e, t);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function AsyncIterator(t, e) {
|
|
127
|
+
function invoke(r, o, i, a) {
|
|
128
|
+
var c = tryCatch(t[r], t, o);
|
|
129
|
+
if ("throw" !== c.type) {
|
|
130
|
+
var u = c.arg,
|
|
131
|
+
h = u.value;
|
|
132
|
+
return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
133
|
+
invoke("next", t, i, a);
|
|
134
|
+
}, function (t) {
|
|
135
|
+
invoke("throw", t, i, a);
|
|
136
|
+
}) : e.resolve(h).then(function (t) {
|
|
137
|
+
u.value = t, i(u);
|
|
138
|
+
}, function (t) {
|
|
139
|
+
return invoke("throw", t, i, a);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
a(c.arg);
|
|
143
|
+
}
|
|
144
|
+
var r;
|
|
145
|
+
o(this, "_invoke", {
|
|
146
|
+
value: function (t, n) {
|
|
147
|
+
function callInvokeWithMethodAndArg() {
|
|
148
|
+
return new e(function (e, r) {
|
|
149
|
+
invoke(t, n, e, r);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function makeInvokeMethod(e, r, n) {
|
|
157
|
+
var o = h;
|
|
158
|
+
return function (i, a) {
|
|
159
|
+
if (o === f) throw Error("Generator is already running");
|
|
160
|
+
if (o === s) {
|
|
161
|
+
if ("throw" === i) throw a;
|
|
162
|
+
return {
|
|
163
|
+
value: t,
|
|
164
|
+
done: !0
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
for (n.method = i, n.arg = a;;) {
|
|
168
|
+
var c = n.delegate;
|
|
169
|
+
if (c) {
|
|
170
|
+
var u = maybeInvokeDelegate(c, n);
|
|
171
|
+
if (u) {
|
|
172
|
+
if (u === y) continue;
|
|
173
|
+
return u;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
177
|
+
if (o === h) throw o = s, n.arg;
|
|
178
|
+
n.dispatchException(n.arg);
|
|
179
|
+
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
180
|
+
o = f;
|
|
181
|
+
var p = tryCatch(e, r, n);
|
|
182
|
+
if ("normal" === p.type) {
|
|
183
|
+
if (o = n.done ? s : l, p.arg === y) continue;
|
|
184
|
+
return {
|
|
185
|
+
value: p.arg,
|
|
186
|
+
done: n.done
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function maybeInvokeDelegate(e, r) {
|
|
194
|
+
var n = r.method,
|
|
195
|
+
o = e.iterator[n];
|
|
196
|
+
if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
197
|
+
var i = tryCatch(o, e.iterator, r.arg);
|
|
198
|
+
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
199
|
+
var a = i.arg;
|
|
200
|
+
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
201
|
+
}
|
|
202
|
+
function pushTryEntry(t) {
|
|
203
|
+
var e = {
|
|
204
|
+
tryLoc: t[0]
|
|
205
|
+
};
|
|
206
|
+
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
207
|
+
}
|
|
208
|
+
function resetTryEntry(t) {
|
|
209
|
+
var e = t.completion || {};
|
|
210
|
+
e.type = "normal", delete e.arg, t.completion = e;
|
|
211
|
+
}
|
|
212
|
+
function Context(t) {
|
|
213
|
+
this.tryEntries = [{
|
|
214
|
+
tryLoc: "root"
|
|
215
|
+
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
216
|
+
}
|
|
217
|
+
function values(e) {
|
|
218
|
+
if (e || "" === e) {
|
|
219
|
+
var r = e[a];
|
|
220
|
+
if (r) return r.call(e);
|
|
221
|
+
if ("function" == typeof e.next) return e;
|
|
222
|
+
if (!isNaN(e.length)) {
|
|
223
|
+
var o = -1,
|
|
224
|
+
i = function next() {
|
|
225
|
+
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
226
|
+
return next.value = t, next.done = !0, next;
|
|
227
|
+
};
|
|
228
|
+
return i.next = i;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
throw new TypeError(typeof e + " is not iterable");
|
|
232
|
+
}
|
|
233
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
234
|
+
value: GeneratorFunctionPrototype,
|
|
235
|
+
configurable: !0
|
|
236
|
+
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
237
|
+
value: GeneratorFunction,
|
|
238
|
+
configurable: !0
|
|
239
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
240
|
+
var e = "function" == typeof t && t.constructor;
|
|
241
|
+
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
242
|
+
}, e.mark = function (t) {
|
|
243
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
244
|
+
}, e.awrap = function (t) {
|
|
245
|
+
return {
|
|
246
|
+
__await: t
|
|
247
|
+
};
|
|
248
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
249
|
+
return this;
|
|
250
|
+
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
251
|
+
void 0 === i && (i = Promise);
|
|
252
|
+
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
253
|
+
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
254
|
+
return t.done ? t.value : a.next();
|
|
255
|
+
});
|
|
256
|
+
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
257
|
+
return this;
|
|
258
|
+
}), define(g, "toString", function () {
|
|
259
|
+
return "[object Generator]";
|
|
260
|
+
}), e.keys = function (t) {
|
|
261
|
+
var e = Object(t),
|
|
262
|
+
r = [];
|
|
263
|
+
for (var n in e) r.push(n);
|
|
264
|
+
return r.reverse(), function next() {
|
|
265
|
+
for (; r.length;) {
|
|
266
|
+
var t = r.pop();
|
|
267
|
+
if (t in e) return next.value = t, next.done = !1, next;
|
|
268
|
+
}
|
|
269
|
+
return next.done = !0, next;
|
|
270
|
+
};
|
|
271
|
+
}, e.values = values, Context.prototype = {
|
|
272
|
+
constructor: Context,
|
|
273
|
+
reset: function (e) {
|
|
274
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
275
|
+
},
|
|
276
|
+
stop: function () {
|
|
277
|
+
this.done = !0;
|
|
278
|
+
var t = this.tryEntries[0].completion;
|
|
279
|
+
if ("throw" === t.type) throw t.arg;
|
|
280
|
+
return this.rval;
|
|
281
|
+
},
|
|
282
|
+
dispatchException: function (e) {
|
|
283
|
+
if (this.done) throw e;
|
|
284
|
+
var r = this;
|
|
285
|
+
function handle(n, o) {
|
|
286
|
+
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
287
|
+
}
|
|
288
|
+
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
289
|
+
var i = this.tryEntries[o],
|
|
290
|
+
a = i.completion;
|
|
291
|
+
if ("root" === i.tryLoc) return handle("end");
|
|
292
|
+
if (i.tryLoc <= this.prev) {
|
|
293
|
+
var c = n.call(i, "catchLoc"),
|
|
294
|
+
u = n.call(i, "finallyLoc");
|
|
295
|
+
if (c && u) {
|
|
296
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
297
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
298
|
+
} else if (c) {
|
|
299
|
+
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
300
|
+
} else {
|
|
301
|
+
if (!u) throw Error("try statement without catch or finally");
|
|
302
|
+
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
abrupt: function (t, e) {
|
|
308
|
+
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
309
|
+
var o = this.tryEntries[r];
|
|
310
|
+
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
311
|
+
var i = o;
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
316
|
+
var a = i ? i.completion : {};
|
|
317
|
+
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
318
|
+
},
|
|
319
|
+
complete: function (t, e) {
|
|
320
|
+
if ("throw" === t.type) throw t.arg;
|
|
321
|
+
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
322
|
+
},
|
|
323
|
+
finish: function (t) {
|
|
324
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
325
|
+
var r = this.tryEntries[e];
|
|
326
|
+
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
catch: function (t) {
|
|
330
|
+
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
331
|
+
var r = this.tryEntries[e];
|
|
332
|
+
if (r.tryLoc === t) {
|
|
333
|
+
var n = r.completion;
|
|
334
|
+
if ("throw" === n.type) {
|
|
335
|
+
var o = n.arg;
|
|
336
|
+
resetTryEntry(r);
|
|
337
|
+
}
|
|
338
|
+
return o;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
throw Error("illegal catch attempt");
|
|
342
|
+
},
|
|
343
|
+
delegateYield: function (e, r, n) {
|
|
344
|
+
return this.delegate = {
|
|
345
|
+
iterator: values(e),
|
|
346
|
+
resultName: r,
|
|
347
|
+
nextLoc: n
|
|
348
|
+
}, "next" === this.method && (this.arg = t), y;
|
|
349
|
+
}
|
|
350
|
+
}, e;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
var axios = /*#__PURE__*/require('axios');
|
|
354
|
+
var RequestService = /*#__PURE__*/function () {
|
|
355
|
+
function RequestService(interceptors) {
|
|
356
|
+
if (interceptors === void 0) {
|
|
357
|
+
interceptors = [];
|
|
358
|
+
}
|
|
359
|
+
this.http = axios.create();
|
|
360
|
+
this.setupInterceptors(interceptors);
|
|
361
|
+
}
|
|
362
|
+
RequestService.singleton = function singleton(interceptors) {
|
|
363
|
+
if (interceptors === void 0) {
|
|
364
|
+
interceptors = [];
|
|
365
|
+
}
|
|
366
|
+
if (!RequestService.instance) {
|
|
367
|
+
RequestService.instance = new RequestService(interceptors);
|
|
368
|
+
}
|
|
369
|
+
return RequestService.instance;
|
|
370
|
+
};
|
|
371
|
+
var _proto = RequestService.prototype;
|
|
372
|
+
_proto.request = /*#__PURE__*/function () {
|
|
373
|
+
var _request = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(method, url, body, queries, headers) {
|
|
374
|
+
var _response$data$title, _response$data, _response$data$messag, _response$data2, _response$data$data, _response$data3, _request2, response, _response$data$title2, _response$data4, _response$data$messag2, _response$data5, _response$data$data2, _response$data6, _response;
|
|
375
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
376
|
+
while (1) switch (_context.prev = _context.next) {
|
|
377
|
+
case 0:
|
|
378
|
+
_context.prev = 0;
|
|
379
|
+
_request2 = {
|
|
380
|
+
method: method,
|
|
381
|
+
url: url,
|
|
382
|
+
headers: _extends({}, headers, {
|
|
383
|
+
'content-type': 'application/json'
|
|
384
|
+
}),
|
|
385
|
+
data: body,
|
|
386
|
+
params: queries
|
|
387
|
+
};
|
|
388
|
+
_context.next = 4;
|
|
389
|
+
return this.http.request(_request2, {
|
|
390
|
+
validateStatus: function validateStatus(status) {
|
|
391
|
+
return !(response.status < 200 || response.status > 299);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
case 4:
|
|
395
|
+
response = _context.sent;
|
|
396
|
+
return _context.abrupt("return", [true, response.status, (_response$data$title = (_response$data = response.data) == null ? void 0 : _response$data.title) != null ? _response$data$title : response.statusText, (_response$data$messag = (_response$data2 = response.data) == null ? void 0 : _response$data2.message) != null ? _response$data$messag : response.status + " - " + response.statusText, (_response$data$data = (_response$data3 = response.data) == null ? void 0 : _response$data3.data) != null ? _response$data$data : response.data]);
|
|
397
|
+
case 8:
|
|
398
|
+
_context.prev = 8;
|
|
399
|
+
_context.t0 = _context["catch"](0);
|
|
400
|
+
if (!_context.t0.response) {
|
|
401
|
+
_context.next = 15;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
// The request was made and the server responded with a status code
|
|
405
|
+
// that falls out of the range of 2xx
|
|
406
|
+
_response = _context.t0.response;
|
|
407
|
+
return _context.abrupt("return", [false, _response.status, (_response$data$title2 = (_response$data4 = _response.data) == null ? void 0 : _response$data4.title) != null ? _response$data$title2 : _response.statusText, (_response$data$messag2 = (_response$data5 = _response.data) == null ? void 0 : _response$data5.message) != null ? _response$data$messag2 : _response.status + " - " + _response.statusText, (_response$data$data2 = (_response$data6 = _response.data) == null ? void 0 : _response$data6.data) != null ? _response$data$data2 : _response.data]);
|
|
408
|
+
case 15:
|
|
409
|
+
if (!_context.t0.request) {
|
|
410
|
+
_context.next = 19;
|
|
411
|
+
break;
|
|
412
|
+
}
|
|
413
|
+
return _context.abrupt("return", [false, 503, 'Service is Down', 'Unable to get any response from the ', _context.t0]);
|
|
414
|
+
case 19:
|
|
415
|
+
return _context.abrupt("return", [false, 403, 'Service is Down', 'Could not make the request, check and try again.', _context.t0]);
|
|
416
|
+
case 20:
|
|
417
|
+
case "end":
|
|
418
|
+
return _context.stop();
|
|
419
|
+
}
|
|
420
|
+
}, _callee, this, [[0, 8]]);
|
|
421
|
+
}));
|
|
422
|
+
function request(_x, _x2, _x3, _x4, _x5) {
|
|
423
|
+
return _request.apply(this, arguments);
|
|
424
|
+
}
|
|
425
|
+
return request;
|
|
426
|
+
}();
|
|
427
|
+
_proto.requestWithError = /*#__PURE__*/function () {
|
|
428
|
+
var _requestWithError = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(method, url, body, queries, headers) {
|
|
429
|
+
var _yield$this$request, status, httpStatus, title, message, response, _response$message;
|
|
430
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
431
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
432
|
+
case 0:
|
|
433
|
+
_context2.next = 2;
|
|
434
|
+
return this.request(method, url, body, queries, headers);
|
|
435
|
+
case 2:
|
|
436
|
+
_yield$this$request = _context2.sent;
|
|
437
|
+
status = _yield$this$request[0];
|
|
438
|
+
httpStatus = _yield$this$request[1];
|
|
439
|
+
title = _yield$this$request[2];
|
|
440
|
+
message = _yield$this$request[3];
|
|
441
|
+
response = _yield$this$request[4];
|
|
442
|
+
if (!(status !== true)) {
|
|
443
|
+
_context2.next = 10;
|
|
444
|
+
break;
|
|
445
|
+
}
|
|
446
|
+
throw new Error(httpStatus + ": " + title + " " + ((_response$message = response == null ? void 0 : response.message) != null ? _response$message : message));
|
|
447
|
+
case 10:
|
|
448
|
+
return _context2.abrupt("return", response);
|
|
449
|
+
case 11:
|
|
450
|
+
case "end":
|
|
451
|
+
return _context2.stop();
|
|
452
|
+
}
|
|
453
|
+
}, _callee2, this);
|
|
454
|
+
}));
|
|
455
|
+
function requestWithError(_x6, _x7, _x8, _x9, _x10) {
|
|
456
|
+
return _requestWithError.apply(this, arguments);
|
|
457
|
+
}
|
|
458
|
+
return requestWithError;
|
|
459
|
+
}();
|
|
460
|
+
_proto.post = function post(url, body, queries, headers) {
|
|
461
|
+
return this.request('POST', url, body, queries, headers);
|
|
462
|
+
};
|
|
463
|
+
_proto.get = function get(url, queries, headers) {
|
|
464
|
+
return this.request('GET', url, null, queries, headers);
|
|
465
|
+
};
|
|
466
|
+
_proto.patch = function patch(url, body, queries, headers) {
|
|
467
|
+
return this.request('PATCH', url, body, queries, headers);
|
|
468
|
+
};
|
|
469
|
+
_proto.put = function put(url, body, queries, headers) {
|
|
470
|
+
return this.request('PUT', url, body, queries, headers);
|
|
471
|
+
};
|
|
472
|
+
_proto["delete"] = function _delete(url, body, queries, headers) {
|
|
473
|
+
return this.request('DELETE', url, body, queries, headers);
|
|
474
|
+
};
|
|
475
|
+
_proto.setupInterceptors = function setupInterceptors(interceptors) {
|
|
476
|
+
for (var index = 0; index < interceptors.length; index++) {
|
|
477
|
+
var interceptor = interceptors[index];
|
|
478
|
+
switch (interceptor.type) {
|
|
479
|
+
case 'request':
|
|
480
|
+
this.http.interceptors.request.use(interceptor.fn, function (error) {
|
|
481
|
+
return Promise.reject(error);
|
|
482
|
+
});
|
|
483
|
+
break;
|
|
484
|
+
case 'response':
|
|
485
|
+
this.http.interceptors.response.use(interceptor.fn, function (error) {
|
|
486
|
+
return Promise.reject(error);
|
|
487
|
+
});
|
|
488
|
+
break;
|
|
489
|
+
case 'both':
|
|
490
|
+
this.http.interceptors.request.use(interceptor.fn, function (error) {
|
|
491
|
+
return Promise.reject(error);
|
|
492
|
+
});
|
|
493
|
+
this.http.interceptors.response.use(interceptor.fn, function (error) {
|
|
494
|
+
return Promise.reject(error);
|
|
495
|
+
});
|
|
496
|
+
break;
|
|
497
|
+
default:
|
|
498
|
+
throw new Error("Interceptor type \"" + interceptor.type + "\" is not supported.");
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
return RequestService;
|
|
503
|
+
}();
|
|
504
|
+
RequestService.instance = void 0;
|
|
505
|
+
var requestService = function requestService(interceptors) {
|
|
506
|
+
if (interceptors === void 0) {
|
|
507
|
+
interceptors = [];
|
|
508
|
+
}
|
|
509
|
+
return RequestService.singleton(interceptors);
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
var FileStore = /*#__PURE__*/function () {
|
|
513
|
+
function FileStore(path) {
|
|
514
|
+
this.path = void 0;
|
|
515
|
+
this.path = path;
|
|
516
|
+
}
|
|
517
|
+
var _proto = FileStore.prototype;
|
|
518
|
+
_proto.save = /*#__PURE__*/function () {
|
|
519
|
+
var _save = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
|
|
520
|
+
var jsonData;
|
|
521
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
522
|
+
while (1) switch (_context.prev = _context.next) {
|
|
523
|
+
case 0:
|
|
524
|
+
_context.prev = 0;
|
|
525
|
+
jsonData = JSON.stringify(data, null, 2);
|
|
526
|
+
_context.next = 4;
|
|
527
|
+
return promises.writeFile(this.path, jsonData, 'utf8');
|
|
528
|
+
case 4:
|
|
529
|
+
_context.next = 9;
|
|
530
|
+
break;
|
|
531
|
+
case 6:
|
|
532
|
+
_context.prev = 6;
|
|
533
|
+
_context.t0 = _context["catch"](0);
|
|
534
|
+
throw new Error("Failed to save data: " + _context.t0.message);
|
|
535
|
+
case 9:
|
|
536
|
+
case "end":
|
|
537
|
+
return _context.stop();
|
|
538
|
+
}
|
|
539
|
+
}, _callee, this, [[0, 6]]);
|
|
540
|
+
}));
|
|
541
|
+
function save(_x) {
|
|
542
|
+
return _save.apply(this, arguments);
|
|
543
|
+
}
|
|
544
|
+
return save;
|
|
545
|
+
}();
|
|
546
|
+
_proto.retrieve = /*#__PURE__*/function () {
|
|
547
|
+
var _retrieve = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
548
|
+
var data;
|
|
549
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
550
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
551
|
+
case 0:
|
|
552
|
+
_context2.prev = 0;
|
|
553
|
+
_context2.next = 3;
|
|
554
|
+
return promises.readFile(this.path, 'utf8');
|
|
555
|
+
case 3:
|
|
556
|
+
data = _context2.sent;
|
|
557
|
+
return _context2.abrupt("return", JSON.parse(data));
|
|
558
|
+
case 7:
|
|
559
|
+
_context2.prev = 7;
|
|
560
|
+
_context2.t0 = _context2["catch"](0);
|
|
561
|
+
if (!(_context2.t0.code === 'ENOENT')) {
|
|
562
|
+
_context2.next = 11;
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
return _context2.abrupt("return", null);
|
|
566
|
+
case 11:
|
|
567
|
+
throw new Error("Failed to retrieve data: " + _context2.t0.message);
|
|
568
|
+
case 12:
|
|
569
|
+
case "end":
|
|
570
|
+
return _context2.stop();
|
|
571
|
+
}
|
|
572
|
+
}, _callee2, this, [[0, 7]]);
|
|
573
|
+
}));
|
|
574
|
+
function retrieve() {
|
|
575
|
+
return _retrieve.apply(this, arguments);
|
|
576
|
+
}
|
|
577
|
+
return retrieve;
|
|
578
|
+
}();
|
|
579
|
+
return FileStore;
|
|
580
|
+
}();
|
|
581
|
+
|
|
582
|
+
var MemoryStore = /*#__PURE__*/function () {
|
|
583
|
+
function MemoryStore(path) {
|
|
584
|
+
this.path = void 0;
|
|
585
|
+
this.storage = {};
|
|
586
|
+
this.path = path;
|
|
587
|
+
this.storage[this.path] = {};
|
|
588
|
+
}
|
|
589
|
+
var _proto = MemoryStore.prototype;
|
|
590
|
+
_proto.save = /*#__PURE__*/function () {
|
|
591
|
+
var _save = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
|
|
592
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
593
|
+
while (1) switch (_context.prev = _context.next) {
|
|
594
|
+
case 0:
|
|
595
|
+
this.storage[this.path] = data;
|
|
596
|
+
case 1:
|
|
597
|
+
case "end":
|
|
598
|
+
return _context.stop();
|
|
599
|
+
}
|
|
600
|
+
}, _callee, this);
|
|
601
|
+
}));
|
|
602
|
+
function save(_x) {
|
|
603
|
+
return _save.apply(this, arguments);
|
|
604
|
+
}
|
|
605
|
+
return save;
|
|
606
|
+
}();
|
|
607
|
+
_proto.retrieve = /*#__PURE__*/function () {
|
|
608
|
+
var _retrieve = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
609
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
610
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
611
|
+
case 0:
|
|
612
|
+
return _context2.abrupt("return", this.storage[this.path]);
|
|
613
|
+
case 1:
|
|
614
|
+
case "end":
|
|
615
|
+
return _context2.stop();
|
|
616
|
+
}
|
|
617
|
+
}, _callee2, this);
|
|
618
|
+
}));
|
|
619
|
+
function retrieve() {
|
|
620
|
+
return _retrieve.apply(this, arguments);
|
|
621
|
+
}
|
|
622
|
+
return retrieve;
|
|
623
|
+
}();
|
|
624
|
+
return MemoryStore;
|
|
625
|
+
}();
|
|
626
|
+
|
|
627
|
+
exports.StoreType = void 0;
|
|
628
|
+
(function (StoreType) {
|
|
629
|
+
StoreType["File"] = "file";
|
|
630
|
+
StoreType["Memory"] = "memory";
|
|
631
|
+
})(exports.StoreType || (exports.StoreType = {}));
|
|
632
|
+
|
|
633
|
+
var LocalStorage = /*#__PURE__*/function () {
|
|
634
|
+
function LocalStorage(domain, path, storeType) {
|
|
635
|
+
if (storeType === void 0) {
|
|
636
|
+
storeType = exports.StoreType.Memory;
|
|
637
|
+
}
|
|
638
|
+
this.store = void 0;
|
|
639
|
+
this.domain = void 0;
|
|
640
|
+
this.domain = domain;
|
|
641
|
+
switch (storeType) {
|
|
642
|
+
case exports.StoreType.File:
|
|
643
|
+
this.store = new FileStore(path);
|
|
644
|
+
break;
|
|
645
|
+
case exports.StoreType.Memory:
|
|
646
|
+
default:
|
|
647
|
+
this.store = new MemoryStore(path);
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
var _proto = LocalStorage.prototype;
|
|
652
|
+
_proto.getStorage = /*#__PURE__*/function () {
|
|
653
|
+
var _getStorage = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
654
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
655
|
+
while (1) switch (_context.prev = _context.next) {
|
|
656
|
+
case 0:
|
|
657
|
+
_context.next = 2;
|
|
658
|
+
return this.store.retrieve();
|
|
659
|
+
case 2:
|
|
660
|
+
_context.t0 = _context.sent;
|
|
661
|
+
if (_context.t0) {
|
|
662
|
+
_context.next = 5;
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
_context.t0 = {};
|
|
666
|
+
case 5:
|
|
667
|
+
return _context.abrupt("return", _context.t0);
|
|
668
|
+
case 6:
|
|
669
|
+
case "end":
|
|
670
|
+
return _context.stop();
|
|
671
|
+
}
|
|
672
|
+
}, _callee, this);
|
|
673
|
+
}));
|
|
674
|
+
function getStorage() {
|
|
675
|
+
return _getStorage.apply(this, arguments);
|
|
676
|
+
}
|
|
677
|
+
return getStorage;
|
|
678
|
+
}();
|
|
679
|
+
_proto.setItem = /*#__PURE__*/function () {
|
|
680
|
+
var _setItem = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
681
|
+
var storage;
|
|
682
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
683
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
684
|
+
case 0:
|
|
685
|
+
_context2.next = 2;
|
|
686
|
+
return this.getStorage();
|
|
687
|
+
case 2:
|
|
688
|
+
storage = _context2.sent;
|
|
689
|
+
if (!storage[this.domain]) {
|
|
690
|
+
storage[this.domain] = {};
|
|
691
|
+
}
|
|
692
|
+
storage[this.domain][key] = value;
|
|
693
|
+
_context2.next = 7;
|
|
694
|
+
return this.store.save(storage);
|
|
695
|
+
case 7:
|
|
696
|
+
case "end":
|
|
697
|
+
return _context2.stop();
|
|
698
|
+
}
|
|
699
|
+
}, _callee2, this);
|
|
700
|
+
}));
|
|
701
|
+
function setItem(_x, _x2) {
|
|
702
|
+
return _setItem.apply(this, arguments);
|
|
703
|
+
}
|
|
704
|
+
return setItem;
|
|
705
|
+
}();
|
|
706
|
+
_proto.getItem = /*#__PURE__*/function () {
|
|
707
|
+
var _getItem = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key) {
|
|
708
|
+
var _storage$this$domain;
|
|
709
|
+
var storage;
|
|
710
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
711
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
712
|
+
case 0:
|
|
713
|
+
_context3.next = 2;
|
|
714
|
+
return this.getStorage();
|
|
715
|
+
case 2:
|
|
716
|
+
storage = _context3.sent;
|
|
717
|
+
return _context3.abrupt("return", ((_storage$this$domain = storage[this.domain]) == null ? void 0 : _storage$this$domain[key]) || null);
|
|
718
|
+
case 4:
|
|
719
|
+
case "end":
|
|
720
|
+
return _context3.stop();
|
|
721
|
+
}
|
|
722
|
+
}, _callee3, this);
|
|
723
|
+
}));
|
|
724
|
+
function getItem(_x3) {
|
|
725
|
+
return _getItem.apply(this, arguments);
|
|
726
|
+
}
|
|
727
|
+
return getItem;
|
|
728
|
+
}();
|
|
729
|
+
_proto.getAll = /*#__PURE__*/function () {
|
|
730
|
+
var _getAll = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
731
|
+
var storage;
|
|
732
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
733
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
734
|
+
case 0:
|
|
735
|
+
_context4.next = 2;
|
|
736
|
+
return this.getStorage();
|
|
737
|
+
case 2:
|
|
738
|
+
storage = _context4.sent;
|
|
739
|
+
return _context4.abrupt("return", storage[this.domain]);
|
|
740
|
+
case 4:
|
|
741
|
+
case "end":
|
|
742
|
+
return _context4.stop();
|
|
743
|
+
}
|
|
744
|
+
}, _callee4, this);
|
|
745
|
+
}));
|
|
746
|
+
function getAll() {
|
|
747
|
+
return _getAll.apply(this, arguments);
|
|
748
|
+
}
|
|
749
|
+
return getAll;
|
|
750
|
+
}();
|
|
751
|
+
_proto.removeItem = /*#__PURE__*/function () {
|
|
752
|
+
var _removeItem = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key) {
|
|
753
|
+
var storage;
|
|
754
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
755
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
756
|
+
case 0:
|
|
757
|
+
_context5.next = 2;
|
|
758
|
+
return this.getStorage();
|
|
759
|
+
case 2:
|
|
760
|
+
storage = _context5.sent;
|
|
761
|
+
if (!storage[this.domain]) {
|
|
762
|
+
_context5.next = 7;
|
|
763
|
+
break;
|
|
764
|
+
}
|
|
765
|
+
delete storage[this.domain][key];
|
|
766
|
+
_context5.next = 7;
|
|
767
|
+
return this.store.save(storage);
|
|
768
|
+
case 7:
|
|
769
|
+
case "end":
|
|
770
|
+
return _context5.stop();
|
|
771
|
+
}
|
|
772
|
+
}, _callee5, this);
|
|
773
|
+
}));
|
|
774
|
+
function removeItem(_x4) {
|
|
775
|
+
return _removeItem.apply(this, arguments);
|
|
776
|
+
}
|
|
777
|
+
return removeItem;
|
|
778
|
+
}();
|
|
779
|
+
_proto.clear = /*#__PURE__*/function () {
|
|
780
|
+
var _clear = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
781
|
+
var storage;
|
|
782
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
783
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
784
|
+
case 0:
|
|
785
|
+
_context6.next = 2;
|
|
786
|
+
return this.getStorage();
|
|
787
|
+
case 2:
|
|
788
|
+
storage = _context6.sent;
|
|
789
|
+
if (!storage[this.domain]) {
|
|
790
|
+
_context6.next = 7;
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
delete storage[this.domain];
|
|
794
|
+
_context6.next = 7;
|
|
795
|
+
return this.store.save(storage);
|
|
796
|
+
case 7:
|
|
797
|
+
case "end":
|
|
798
|
+
return _context6.stop();
|
|
799
|
+
}
|
|
800
|
+
}, _callee6, this);
|
|
801
|
+
}));
|
|
802
|
+
function clear() {
|
|
803
|
+
return _clear.apply(this, arguments);
|
|
804
|
+
}
|
|
805
|
+
return clear;
|
|
806
|
+
}();
|
|
807
|
+
return LocalStorage;
|
|
808
|
+
}();
|
|
809
|
+
|
|
810
|
+
var SessionStorage = /*#__PURE__*/function () {
|
|
811
|
+
function SessionStorage(domain, sessionId, path, storeType) {
|
|
812
|
+
this.store = void 0;
|
|
813
|
+
this.domain = void 0;
|
|
814
|
+
this.sessionId = void 0;
|
|
815
|
+
this.domain = domain;
|
|
816
|
+
this.sessionId = sessionId;
|
|
817
|
+
switch (storeType) {
|
|
818
|
+
case exports.StoreType.File:
|
|
819
|
+
this.store = new FileStore(path);
|
|
820
|
+
break;
|
|
821
|
+
case exports.StoreType.Memory:
|
|
822
|
+
default:
|
|
823
|
+
this.store = new MemoryStore(path);
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
var _proto = SessionStorage.prototype;
|
|
828
|
+
_proto.getStorage = /*#__PURE__*/function () {
|
|
829
|
+
var _getStorage = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
830
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
831
|
+
while (1) switch (_context.prev = _context.next) {
|
|
832
|
+
case 0:
|
|
833
|
+
_context.next = 2;
|
|
834
|
+
return this.store.retrieve();
|
|
835
|
+
case 2:
|
|
836
|
+
_context.t0 = _context.sent;
|
|
837
|
+
if (_context.t0) {
|
|
838
|
+
_context.next = 5;
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
_context.t0 = {};
|
|
842
|
+
case 5:
|
|
843
|
+
return _context.abrupt("return", _context.t0);
|
|
844
|
+
case 6:
|
|
845
|
+
case "end":
|
|
846
|
+
return _context.stop();
|
|
847
|
+
}
|
|
848
|
+
}, _callee, this);
|
|
849
|
+
}));
|
|
850
|
+
function getStorage() {
|
|
851
|
+
return _getStorage.apply(this, arguments);
|
|
852
|
+
}
|
|
853
|
+
return getStorage;
|
|
854
|
+
}();
|
|
855
|
+
_proto.setItem = /*#__PURE__*/function () {
|
|
856
|
+
var _setItem = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
857
|
+
var storage;
|
|
858
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
859
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
860
|
+
case 0:
|
|
861
|
+
_context2.next = 2;
|
|
862
|
+
return this.getStorage();
|
|
863
|
+
case 2:
|
|
864
|
+
storage = _context2.sent;
|
|
865
|
+
if (!storage[this.domain]) {
|
|
866
|
+
storage[this.domain] = {};
|
|
867
|
+
}
|
|
868
|
+
if (!storage[this.domain][this.sessionId]) {
|
|
869
|
+
storage[this.domain][this.sessionId] = {};
|
|
870
|
+
}
|
|
871
|
+
storage[this.domain][this.sessionId][key] = value;
|
|
872
|
+
_context2.next = 8;
|
|
873
|
+
return this.store.save(storage);
|
|
874
|
+
case 8:
|
|
875
|
+
case "end":
|
|
876
|
+
return _context2.stop();
|
|
877
|
+
}
|
|
878
|
+
}, _callee2, this);
|
|
879
|
+
}));
|
|
880
|
+
function setItem(_x, _x2) {
|
|
881
|
+
return _setItem.apply(this, arguments);
|
|
882
|
+
}
|
|
883
|
+
return setItem;
|
|
884
|
+
}();
|
|
885
|
+
_proto.getItem = /*#__PURE__*/function () {
|
|
886
|
+
var _getItem = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key) {
|
|
887
|
+
var _storage$this$domain;
|
|
888
|
+
var storage;
|
|
889
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
890
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
891
|
+
case 0:
|
|
892
|
+
_context3.next = 2;
|
|
893
|
+
return this.getStorage();
|
|
894
|
+
case 2:
|
|
895
|
+
storage = _context3.sent;
|
|
896
|
+
return _context3.abrupt("return", ((_storage$this$domain = storage[this.domain]) == null || (_storage$this$domain = _storage$this$domain[this.sessionId]) == null ? void 0 : _storage$this$domain[key]) || null);
|
|
897
|
+
case 4:
|
|
898
|
+
case "end":
|
|
899
|
+
return _context3.stop();
|
|
900
|
+
}
|
|
901
|
+
}, _callee3, this);
|
|
902
|
+
}));
|
|
903
|
+
function getItem(_x3) {
|
|
904
|
+
return _getItem.apply(this, arguments);
|
|
905
|
+
}
|
|
906
|
+
return getItem;
|
|
907
|
+
}();
|
|
908
|
+
_proto.getAll = /*#__PURE__*/function () {
|
|
909
|
+
var _getAll = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
910
|
+
var _storage$this$domain2;
|
|
911
|
+
var storage;
|
|
912
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
913
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
914
|
+
case 0:
|
|
915
|
+
_context4.next = 2;
|
|
916
|
+
return this.getStorage();
|
|
917
|
+
case 2:
|
|
918
|
+
storage = _context4.sent;
|
|
919
|
+
return _context4.abrupt("return", ((_storage$this$domain2 = storage[this.domain]) == null ? void 0 : _storage$this$domain2[this.sessionId]) || null);
|
|
920
|
+
case 4:
|
|
921
|
+
case "end":
|
|
922
|
+
return _context4.stop();
|
|
923
|
+
}
|
|
924
|
+
}, _callee4, this);
|
|
925
|
+
}));
|
|
926
|
+
function getAll() {
|
|
927
|
+
return _getAll.apply(this, arguments);
|
|
928
|
+
}
|
|
929
|
+
return getAll;
|
|
930
|
+
}();
|
|
931
|
+
_proto.removeItem = /*#__PURE__*/function () {
|
|
932
|
+
var _removeItem = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key) {
|
|
933
|
+
var _storage$this$domain3;
|
|
934
|
+
var storage;
|
|
935
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
936
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
937
|
+
case 0:
|
|
938
|
+
_context5.next = 2;
|
|
939
|
+
return this.getStorage();
|
|
940
|
+
case 2:
|
|
941
|
+
storage = _context5.sent;
|
|
942
|
+
if (!((_storage$this$domain3 = storage[this.domain]) != null && _storage$this$domain3[this.sessionId])) {
|
|
943
|
+
_context5.next = 7;
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
946
|
+
delete storage[this.domain][this.sessionId][key];
|
|
947
|
+
_context5.next = 7;
|
|
948
|
+
return this.store.save(storage);
|
|
949
|
+
case 7:
|
|
950
|
+
case "end":
|
|
951
|
+
return _context5.stop();
|
|
952
|
+
}
|
|
953
|
+
}, _callee5, this);
|
|
954
|
+
}));
|
|
955
|
+
function removeItem(_x4) {
|
|
956
|
+
return _removeItem.apply(this, arguments);
|
|
957
|
+
}
|
|
958
|
+
return removeItem;
|
|
959
|
+
}();
|
|
960
|
+
_proto.clear = /*#__PURE__*/function () {
|
|
961
|
+
var _clear = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
962
|
+
var _storage$this$domain4;
|
|
963
|
+
var storage;
|
|
964
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
965
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
966
|
+
case 0:
|
|
967
|
+
_context6.next = 2;
|
|
968
|
+
return this.getStorage();
|
|
969
|
+
case 2:
|
|
970
|
+
storage = _context6.sent;
|
|
971
|
+
if (!((_storage$this$domain4 = storage[this.domain]) != null && _storage$this$domain4[this.sessionId])) {
|
|
972
|
+
_context6.next = 7;
|
|
973
|
+
break;
|
|
974
|
+
}
|
|
975
|
+
delete storage[this.domain][this.sessionId];
|
|
976
|
+
_context6.next = 7;
|
|
977
|
+
return this.store.save(storage);
|
|
978
|
+
case 7:
|
|
979
|
+
case "end":
|
|
980
|
+
return _context6.stop();
|
|
981
|
+
}
|
|
982
|
+
}, _callee6, this);
|
|
983
|
+
}));
|
|
984
|
+
function clear() {
|
|
985
|
+
return _clear.apply(this, arguments);
|
|
986
|
+
}
|
|
987
|
+
return clear;
|
|
988
|
+
}();
|
|
989
|
+
return SessionStorage;
|
|
990
|
+
}();
|
|
991
|
+
|
|
992
|
+
exports.StorageType = void 0;
|
|
993
|
+
(function (StorageType) {
|
|
994
|
+
StorageType["Local"] = "local";
|
|
995
|
+
StorageType["Session"] = "session";
|
|
996
|
+
})(exports.StorageType || (exports.StorageType = {}));
|
|
997
|
+
|
|
998
|
+
var isNode = function isNode() {
|
|
999
|
+
return typeof window === 'undefined';
|
|
1000
|
+
};
|
|
1001
|
+
var isBrowser = function isBrowser() {
|
|
1002
|
+
return !isNode();
|
|
1003
|
+
};
|
|
1004
|
+
var isObject = function isObject(x) {
|
|
1005
|
+
return typeof x === 'object' && !Array.isArray(x) && x !== null;
|
|
1006
|
+
};
|
|
1007
|
+
var _recursiveMerge = function recursiveMerge(target) {
|
|
1008
|
+
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1009
|
+
sources[_key - 1] = arguments[_key];
|
|
1010
|
+
}
|
|
1011
|
+
for (var _i = 0, _sources = sources; _i < _sources.length; _i++) {
|
|
1012
|
+
var source = _sources[_i];
|
|
1013
|
+
for (var key in source) {
|
|
1014
|
+
if (isObject(source[key])) {
|
|
1015
|
+
if (!target[key]) {
|
|
1016
|
+
target[key] = {};
|
|
1017
|
+
}
|
|
1018
|
+
_recursiveMerge(target[key], source[key]);
|
|
1019
|
+
} else {
|
|
1020
|
+
target[key] = source[key];
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
return target;
|
|
1025
|
+
};
|
|
1026
|
+
var managedLog = function managedLog(title, message, config) {
|
|
1027
|
+
var _config$logs;
|
|
1028
|
+
for (var _len2 = arguments.length, types = new Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) {
|
|
1029
|
+
types[_key2 - 3] = arguments[_key2];
|
|
1030
|
+
}
|
|
1031
|
+
(_config$logs = config.logs) == null || _config$logs.forEach(function (allowed) {
|
|
1032
|
+
if (types.includes(allowed)) {
|
|
1033
|
+
if (config.debug === true) {
|
|
1034
|
+
console[allowed](title, message);
|
|
1035
|
+
} else {
|
|
1036
|
+
console[allowed](title);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
};
|
|
1041
|
+
var sleep = function sleep(ms) {
|
|
1042
|
+
return new Promise(function (resolve) {
|
|
1043
|
+
setTimeout(resolve, ms);
|
|
1044
|
+
});
|
|
1045
|
+
};
|
|
1046
|
+
function isFunction(value) {
|
|
1047
|
+
return typeof value === 'function';
|
|
1048
|
+
}
|
|
1049
|
+
function getUserHomeDirectory() {
|
|
1050
|
+
return os.homedir();
|
|
1051
|
+
}
|
|
1052
|
+
function getCurrentWorkingDirectory() {
|
|
1053
|
+
return process.cwd();
|
|
1054
|
+
}
|
|
1055
|
+
function getRootDomain(url) {
|
|
1056
|
+
try {
|
|
1057
|
+
var hostname = new URL(url).hostname;
|
|
1058
|
+
// Split hostname into parts
|
|
1059
|
+
var parts = hostname.split('.');
|
|
1060
|
+
// If it's an IP address, return as-is
|
|
1061
|
+
if (parts.every(function (part) {
|
|
1062
|
+
return /^\d+$/.test(part);
|
|
1063
|
+
})) {
|
|
1064
|
+
return hostname;
|
|
1065
|
+
}
|
|
1066
|
+
if (parts.length > 2) {
|
|
1067
|
+
return parts.slice(-3).join('.');
|
|
1068
|
+
}
|
|
1069
|
+
return parts.slice(-2).join('.');
|
|
1070
|
+
} catch (error) {
|
|
1071
|
+
throw new Error("Invalid URL: " + url);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
var clone = function clone(obj) {
|
|
1075
|
+
return Object.assign(Object.create(Object.getPrototypeOf(obj)), obj);
|
|
1076
|
+
};
|
|
1077
|
+
var splitIntoTwo = function splitIntoTwo(value, separator) {
|
|
1078
|
+
if (separator === void 0) {
|
|
1079
|
+
separator = '=';
|
|
1080
|
+
}
|
|
1081
|
+
var firstEqualsIndex = value.indexOf(separator);
|
|
1082
|
+
if (firstEqualsIndex === -1) {
|
|
1083
|
+
return [value];
|
|
1084
|
+
}
|
|
1085
|
+
var first = value.substring(0, firstEqualsIndex);
|
|
1086
|
+
var second = value.substring(firstEqualsIndex + 1);
|
|
1087
|
+
return [first, second];
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
exports.EventEntityType = void 0;
|
|
1091
|
+
(function (EventEntityType) {
|
|
1092
|
+
EventEntityType["Source"] = "source";
|
|
1093
|
+
EventEntityType["Channel"] = "channel";
|
|
1094
|
+
})(exports.EventEntityType || (exports.EventEntityType = {}));
|
|
1095
|
+
exports.CategoryType = void 0;
|
|
1096
|
+
(function (CategoryType) {
|
|
1097
|
+
CategoryType["Form"] = "form";
|
|
1098
|
+
CategoryType["File"] = "file";
|
|
1099
|
+
CategoryType["Webhook"] = "webhook";
|
|
1100
|
+
CategoryType["Job"] = "job";
|
|
1101
|
+
CategoryType["Event"] = "event";
|
|
1102
|
+
CategoryType["Log"] = "log";
|
|
1103
|
+
CategoryType["Motion"] = "motion";
|
|
1104
|
+
CategoryType["Message"] = "message";
|
|
1105
|
+
CategoryType["Others"] = "others";
|
|
1106
|
+
})(exports.CategoryType || (exports.CategoryType = {}));
|
|
1107
|
+
exports.LogType = void 0;
|
|
1108
|
+
(function (LogType) {
|
|
1109
|
+
LogType["INFO"] = "info";
|
|
1110
|
+
LogType["WARN"] = "warn";
|
|
1111
|
+
LogType["ERROR"] = "error";
|
|
1112
|
+
})(exports.LogType || (exports.LogType = {}));
|
|
1113
|
+
|
|
1114
|
+
exports.FileStore = FileStore;
|
|
1115
|
+
exports.LocalStorage = LocalStorage;
|
|
1116
|
+
exports.MemoryStore = MemoryStore;
|
|
1117
|
+
exports.RequestService = RequestService;
|
|
1118
|
+
exports.SessionStorage = SessionStorage;
|
|
1119
|
+
exports.clone = clone;
|
|
1120
|
+
exports.getCurrentWorkingDirectory = getCurrentWorkingDirectory;
|
|
1121
|
+
exports.getRootDomain = getRootDomain;
|
|
1122
|
+
exports.getUserHomeDirectory = getUserHomeDirectory;
|
|
1123
|
+
exports.isBrowser = isBrowser;
|
|
1124
|
+
exports.isFunction = isFunction;
|
|
1125
|
+
exports.isNode = isNode;
|
|
1126
|
+
exports.isObject = isObject;
|
|
1127
|
+
exports.managedLog = managedLog;
|
|
1128
|
+
exports.recursiveMerge = _recursiveMerge;
|
|
1129
|
+
exports.requestService = requestService;
|
|
1130
|
+
exports.sleep = sleep;
|
|
1131
|
+
exports.splitIntoTwo = splitIntoTwo;
|
|
1132
|
+
exports.stackTrace = _stackTrace;
|
|
1133
|
+
//# sourceMappingURL=jsx-core.cjs.development.js.map
|