@nsnanocat/util 0.0.0-preview-255840e → 0.0.0-preview-b0f521c

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.
Files changed (42) hide show
  1. package/dist/{getStorage.js → getStorage.mjs} +5 -5
  2. package/dist/index.js +11 -11
  3. package/dist/index.mjs +11 -0
  4. package/dist/lib/app.d.ts +1 -1
  5. package/dist/lib/{done.js → done.mjs} +13 -13
  6. package/dist/lib/{environment.js → environment.mjs} +2 -2
  7. package/dist/lib/{index.js → index.mjs} +6 -6
  8. package/dist/lib/{notification.js → notification.mjs} +10 -10
  9. package/dist/lib/{runScript.js → runScript.mjs} +7 -7
  10. package/dist/polyfill/{Console.js → Console.mjs} +2 -2
  11. package/dist/polyfill/Storage.d.ts +7 -11
  12. package/dist/polyfill/Storage.mjs +188 -0
  13. package/dist/polyfill/fetch-node.d.ts +1 -0
  14. package/dist/polyfill/fetch-node.mjs +8 -0
  15. package/dist/polyfill/{fetch.js → fetch.mjs} +14 -16
  16. package/dist/polyfill/index.mjs +5 -0
  17. package/package.json +8 -12
  18. package/dist/env.d.cjs +0 -6
  19. package/dist/env.d.js +0 -0
  20. package/dist/getStorage.cjs +0 -96
  21. package/dist/index.cjs +0 -155
  22. package/dist/lib/app.cjs +0 -48
  23. package/dist/lib/done.cjs +0 -109
  24. package/dist/lib/environment.cjs +0 -70
  25. package/dist/lib/index.cjs +0 -101
  26. package/dist/lib/notification.cjs +0 -135
  27. package/dist/lib/runScript.cjs +0 -67
  28. package/dist/lib/time.cjs +0 -54
  29. package/dist/lib/wait.cjs +0 -40
  30. package/dist/polyfill/Console.cjs +0 -250
  31. package/dist/polyfill/Lodash.cjs +0 -132
  32. package/dist/polyfill/StatusTexts.cjs +0 -99
  33. package/dist/polyfill/Storage.cjs +0 -213
  34. package/dist/polyfill/Storage.js +0 -161
  35. package/dist/polyfill/fetch.cjs +0 -200
  36. package/dist/polyfill/index.cjs +0 -101
  37. package/dist/polyfill/index.js +0 -5
  38. /package/dist/lib/{app.js → app.mjs} +0 -0
  39. /package/dist/lib/{time.js → time.mjs} +0 -0
  40. /package/dist/lib/{wait.js → wait.mjs} +0 -0
  41. /package/dist/polyfill/{Lodash.js → Lodash.mjs} +0 -0
  42. /package/dist/polyfill/{StatusTexts.js → StatusTexts.mjs} +0 -0
@@ -1,135 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.r = function(exports1) {
18
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
- value: 'Module'
20
- });
21
- Object.defineProperty(exports1, '__esModule', {
22
- value: true
23
- });
24
- };
25
- })();
26
- var __webpack_exports__ = {};
27
- __webpack_require__.r(__webpack_exports__);
28
- __webpack_require__.d(__webpack_exports__, {
29
- notification: ()=>notification
30
- });
31
- const Console_cjs_namespaceObject = require("../polyfill/Console.cjs");
32
- const external_app_cjs_namespaceObject = require("./app.cjs");
33
- function notification(title = `ℹ️ ${external_app_cjs_namespaceObject.$app} 通知`, subtitle = '', body = '', content = {}) {
34
- const mutableContent = getMutableContent(content);
35
- switch(external_app_cjs_namespaceObject.$app){
36
- case 'Quantumult X':
37
- $notify(title, subtitle, body, mutableContent);
38
- break;
39
- case 'Node.js':
40
- break;
41
- default:
42
- $notification.post(title, subtitle, body, mutableContent);
43
- break;
44
- }
45
- Console_cjs_namespaceObject.Console.group('📣 系统通知');
46
- Console_cjs_namespaceObject.Console.log(title, subtitle, body, JSON.stringify(mutableContent, null, 2));
47
- Console_cjs_namespaceObject.Console.groupEnd();
48
- }
49
- function getMutableContent(content) {
50
- const mutableContent = {};
51
- switch(typeof content){
52
- case 'string':
53
- case 'number':
54
- case 'boolean':
55
- assignSimpleContent(mutableContent, content);
56
- break;
57
- case 'object':
58
- if (content) assignObjectContent(mutableContent, content);
59
- break;
60
- default:
61
- Console_cjs_namespaceObject.Console.error(`不支持的通知参数类型: ${typeof content}`);
62
- break;
63
- }
64
- return mutableContent;
65
- }
66
- function assignSimpleContent(mutableContent, content) {
67
- switch(external_app_cjs_namespaceObject.$app){
68
- case 'Quantumult X':
69
- mutableContent['open-url'] = content;
70
- break;
71
- case 'Loon':
72
- case 'Shadowrocket':
73
- mutableContent.openUrl = content;
74
- break;
75
- default:
76
- mutableContent.url = content;
77
- break;
78
- }
79
- }
80
- function assignObjectContent(mutableContent, content) {
81
- const openUrl = content.open || content['open-url'] || content.url || content.openUrl;
82
- const copyUrl = content.copy || content['update-pasteboard'] || content.updatePasteboard;
83
- const mediaUrl = content.media || content['media-url'] || content.mediaUrl;
84
- switch(external_app_cjs_namespaceObject.$app){
85
- case 'Quantumult X':
86
- if (openUrl) mutableContent['open-url'] = openUrl;
87
- if (null == mediaUrl ? void 0 : mediaUrl.startsWith('http')) mutableContent['media-url'] = mediaUrl;
88
- if (copyUrl) mutableContent['update-pasteboard'] = copyUrl;
89
- break;
90
- case 'Loon':
91
- if (openUrl) mutableContent.openUrl = openUrl;
92
- if (null == mediaUrl ? void 0 : mediaUrl.startsWith('http')) mutableContent.mediaUrl = mediaUrl;
93
- break;
94
- default:
95
- if (openUrl) {
96
- mutableContent.action = 'open-url';
97
- mutableContent.url = openUrl;
98
- }
99
- if (copyUrl) {
100
- mutableContent.action = 'clipboard';
101
- mutableContent.text = copyUrl;
102
- }
103
- if (mediaUrl) handleMediaContent(mutableContent, mediaUrl, content.mime);
104
- if (content['auto-dismiss']) mutableContent['auto-dismiss'] = content['auto-dismiss'];
105
- if (content.sound) mutableContent.sound = content.sound;
106
- break;
107
- }
108
- }
109
- function handleMediaContent(mutableContent, mediaUrl, mime) {
110
- if (mediaUrl.startsWith('http')) mutableContent['media-url'] = mediaUrl;
111
- else if (mediaUrl.startsWith('data:')) {
112
- const base64RegExp = /^data:(?<MIME>\w+\/\w+);base64,(?<Base64>.+)/;
113
- const match = mediaUrl.match(base64RegExp);
114
- if (null == match ? void 0 : match.groups) {
115
- mutableContent['media-base64'] = match.groups.Base64;
116
- mutableContent['media-base64-mime'] = mime || match.groups.MIME;
117
- }
118
- } else {
119
- mutableContent['media-base64'] = mediaUrl;
120
- mutableContent['media-base64-mime'] = detectMimeType(mediaUrl);
121
- }
122
- }
123
- function detectMimeType(base64) {
124
- if (base64.startsWith('JVBERi0')) return 'application/pdf';
125
- if (base64.startsWith('R0lGODdh') || base64.startsWith('R0lGODlh')) return 'image/gif';
126
- if (base64.startsWith('iVBORw0KGgo')) return 'image/png';
127
- if (base64.startsWith('/9j/')) return 'image/jpeg';
128
- if (base64.startsWith('Qk02U')) return 'image/bmp';
129
- return 'application/octet-stream';
130
- }
131
- var __webpack_export_target__ = exports;
132
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
133
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
134
- value: true
135
- });
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.r = function(exports1) {
18
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
- value: 'Module'
20
- });
21
- Object.defineProperty(exports1, '__esModule', {
22
- value: true
23
- });
24
- };
25
- })();
26
- var __webpack_exports__ = {};
27
- __webpack_require__.r(__webpack_exports__);
28
- __webpack_require__.d(__webpack_exports__, {
29
- runScript: ()=>runScript
30
- });
31
- const Console_cjs_namespaceObject = require("../polyfill/Console.cjs");
32
- const Storage_cjs_namespaceObject = require("../polyfill/Storage.cjs");
33
- const fetch_cjs_namespaceObject = require("../polyfill/fetch.cjs");
34
- async function runScript(script, runOpts = {}) {
35
- try {
36
- var _Storage_getItem_replace, _Storage_getItem;
37
- const httpapi = null === (_Storage_getItem = Storage_cjs_namespaceObject.Storage.getItem('@chavy_boxjs_userCfgs.httpapi')) || void 0 === _Storage_getItem ? void 0 : null === (_Storage_getItem_replace = _Storage_getItem.replace(/\n/g, '')) || void 0 === _Storage_getItem_replace ? void 0 : _Storage_getItem_replace.trim();
38
- if (!httpapi) throw new Error('httpapi 配置未找到,请检查配置项!');
39
- const httpapiTimeoutFromConfig = Number.parseInt(Storage_cjs_namespaceObject.Storage.getItem('@chavy_boxjs_userCfgs.httpapi_timeout') || '20', 10);
40
- const timeout = runOpts.timeout ?? httpapiTimeoutFromConfig;
41
- const [password, address] = httpapi.split('@');
42
- if (!password || !address) throw new Error('httpapi 配置格式错误,应为 password@address 格式!');
43
- const request = {
44
- url: `http://${address}/v1/scripting/evaluate`,
45
- body: JSON.stringify({
46
- script_text: script,
47
- mock_type: 'cron',
48
- timeout
49
- }),
50
- headers: {
51
- 'X-Key': password,
52
- Accept: '*/*'
53
- },
54
- timeout
55
- };
56
- const response = await (0, fetch_cjs_namespaceObject.fetch)(request);
57
- return response.body;
58
- } catch (error) {
59
- Console_cjs_namespaceObject.Console.error('运行脚本时发生错误:', error.message);
60
- throw error;
61
- }
62
- }
63
- var __webpack_export_target__ = exports;
64
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
65
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
66
- value: true
67
- });
package/dist/lib/time.cjs DELETED
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.r = function(exports1) {
18
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
- value: 'Module'
20
- });
21
- Object.defineProperty(exports1, '__esModule', {
22
- value: true
23
- });
24
- };
25
- })();
26
- var __webpack_exports__ = {};
27
- __webpack_require__.r(__webpack_exports__);
28
- __webpack_require__.d(__webpack_exports__, {
29
- time: function() {
30
- return time;
31
- }
32
- });
33
- function time(format, ts) {
34
- const date = ts ? new Date(ts) : new Date();
35
- const Time = {
36
- YY: date.getFullYear().toString().substring(3),
37
- yyyy: date.getFullYear().toString(),
38
- MM: (date.getMonth() + 1).toString().padStart(2, '0'),
39
- dd: date.getDate().toString().padStart(2, '0'),
40
- HH: date.getHours().toString().padStart(2, '0'),
41
- mm: date.getMinutes().toString().padStart(2, '0'),
42
- sss: date.getMilliseconds().toString().padStart(3, '0'),
43
- ss: date.getSeconds().toString().padStart(2, '0'),
44
- S: `${Math.floor(date.getMonth() / 3) + 1}`
45
- };
46
- let result = format;
47
- for (const [key, value] of Object.entries(Time))result = result.replace(key, value);
48
- return result;
49
- }
50
- var __webpack_export_target__ = exports;
51
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
52
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
53
- value: true
54
- });
package/dist/lib/wait.cjs DELETED
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.r = function(exports1) {
18
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
- value: 'Module'
20
- });
21
- Object.defineProperty(exports1, '__esModule', {
22
- value: true
23
- });
24
- };
25
- })();
26
- var __webpack_exports__ = {};
27
- __webpack_require__.r(__webpack_exports__);
28
- __webpack_require__.d(__webpack_exports__, {
29
- wait: function() {
30
- return wait;
31
- }
32
- });
33
- function wait(delay = 1000) {
34
- return new Promise((resolve)=>setTimeout(resolve, delay));
35
- }
36
- var __webpack_export_target__ = exports;
37
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
38
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
39
- value: true
40
- });
@@ -1,250 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.r = function(exports1) {
18
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
- value: 'Module'
20
- });
21
- Object.defineProperty(exports1, '__esModule', {
22
- value: true
23
- });
24
- };
25
- })();
26
- var __webpack_exports__ = {};
27
- __webpack_require__.r(__webpack_exports__);
28
- __webpack_require__.d(__webpack_exports__, {
29
- Console: ()=>Console
30
- });
31
- const app_cjs_namespaceObject = require("../lib/app.cjs");
32
- function _check_private_redeclaration(obj, privateCollection) {
33
- if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
34
- }
35
- function _class_apply_descriptor_get(receiver, descriptor) {
36
- if (descriptor.get) return descriptor.get.call(receiver);
37
- return descriptor.value;
38
- }
39
- function _class_apply_descriptor_set(receiver, descriptor, value) {
40
- if (descriptor.set) descriptor.set.call(receiver, value);
41
- else {
42
- if (!descriptor.writable) throw new TypeError("attempted to set read only private field");
43
- descriptor.value = value;
44
- }
45
- }
46
- function _class_extract_field_descriptor(receiver, privateMap, action) {
47
- if (!privateMap.has(receiver)) throw new TypeError("attempted to " + action + " private field on non-instance");
48
- return privateMap.get(receiver);
49
- }
50
- function _class_private_field_get(receiver, privateMap) {
51
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
52
- return _class_apply_descriptor_get(receiver, descriptor);
53
- }
54
- function _class_private_field_init(obj, privateMap, value) {
55
- _check_private_redeclaration(obj, privateMap);
56
- privateMap.set(obj, value);
57
- }
58
- function _class_private_field_set(receiver, privateMap, value) {
59
- var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
60
- _class_apply_descriptor_set(receiver, descriptor, value);
61
- return value;
62
- }
63
- function _define_property(obj, key, value) {
64
- if (key in obj) Object.defineProperty(obj, key, {
65
- value: value,
66
- enumerable: true,
67
- configurable: true,
68
- writable: true
69
- });
70
- else obj[key] = value;
71
- return obj;
72
- }
73
- var _counts = /*#__PURE__*/ new WeakMap(), _groups = /*#__PURE__*/ new WeakMap(), _times = /*#__PURE__*/ new WeakMap(), _level = /*#__PURE__*/ new WeakMap();
74
- class ConsoleFactory {
75
- error(...msg) {
76
- if (_class_private_field_get(this, _level) < 1) return;
77
- switch(app_cjs_namespaceObject.$app){
78
- case 'Surge':
79
- case 'Loon':
80
- case 'Stash':
81
- case 'Egern':
82
- case 'Shadowrocket':
83
- case 'Quantumult X':
84
- case 'Node.js':
85
- this.log(...msg.map((m)=>{
86
- if (m instanceof Error) return `❌ ${m.stack}`;
87
- return `❌ ${m}`;
88
- }));
89
- break;
90
- default:
91
- this.log(...msg.map((m)=>`❌ ${m}`));
92
- break;
93
- }
94
- }
95
- info(...msg) {
96
- if (_class_private_field_get(this, _level) < 3) return;
97
- this.log(...msg.map((m)=>`ℹ️ ${m}`));
98
- }
99
- get logLevel() {
100
- switch(_class_private_field_get(this, _level)){
101
- case 0:
102
- return 'OFF';
103
- case 1:
104
- return 'ERROR';
105
- case 2:
106
- return 'WARN';
107
- case 4:
108
- return 'DEBUG';
109
- case 5:
110
- return 'ALL';
111
- case 3:
112
- default:
113
- return 'INFO';
114
- }
115
- }
116
- set logLevel(_level1) {
117
- let level = _level1;
118
- switch(typeof level){
119
- case 'string':
120
- level = level.toLowerCase();
121
- break;
122
- case 'number':
123
- break;
124
- case 'undefined':
125
- default:
126
- level = 'warn';
127
- break;
128
- }
129
- switch(level){
130
- case 0:
131
- case 'off':
132
- _class_private_field_set(this, _level, 0);
133
- break;
134
- case 1:
135
- case 'error':
136
- _class_private_field_set(this, _level, 1);
137
- break;
138
- case 3:
139
- case 'info':
140
- _class_private_field_set(this, _level, 3);
141
- break;
142
- case 4:
143
- case 'debug':
144
- _class_private_field_set(this, _level, 4);
145
- break;
146
- case 5:
147
- case 'all':
148
- _class_private_field_set(this, _level, 5);
149
- break;
150
- case 2:
151
- case 'warn':
152
- case 'warning':
153
- default:
154
- _class_private_field_set(this, _level, 2);
155
- break;
156
- }
157
- }
158
- warn(...args) {
159
- if (_class_private_field_get(this, _level) < 2) return;
160
- let msg = args;
161
- msg = msg.map((m)=>`⚠️ ${m}`);
162
- this.log(...msg);
163
- }
164
- constructor(){
165
- _class_private_field_init(this, _counts, {
166
- writable: true,
167
- value: new Map([])
168
- });
169
- _class_private_field_init(this, _groups, {
170
- writable: true,
171
- value: []
172
- });
173
- _class_private_field_init(this, _times, {
174
- writable: true,
175
- value: new Map([])
176
- });
177
- _define_property(this, "clear", ()=>{});
178
- _define_property(this, "count", (label = 'default')=>{
179
- if (_class_private_field_get(this, _counts).has(label)) _class_private_field_get(this, _counts).set(label, _class_private_field_get(this, _counts).get(label) ?? 1);
180
- else _class_private_field_get(this, _counts).set(label, 0);
181
- this.log(`${label}: ${_class_private_field_get(this, _counts).get(label)}`);
182
- });
183
- _define_property(this, "countReset", (label = 'default')=>{
184
- switch(_class_private_field_get(this, _counts).has(label)){
185
- case true:
186
- _class_private_field_get(this, _counts).set(label, 0);
187
- this.log(`${label}: ${_class_private_field_get(this, _counts).get(label)}`);
188
- break;
189
- case false:
190
- this.warn(`Counter "${label}" doesn’t exist`);
191
- break;
192
- }
193
- });
194
- _define_property(this, "debug", (...args)=>{
195
- if (_class_private_field_get(this, _level) < 4) return;
196
- this.log(...args.map((m)=>`🅱️ ${m}`));
197
- });
198
- _define_property(this, "exception", (...msg)=>this.error(...msg));
199
- _define_property(this, "group", (label)=>_class_private_field_get(this, _groups).unshift(label));
200
- _define_property(this, "groupEnd", ()=>_class_private_field_get(this, _groups).shift());
201
- _class_private_field_init(this, _level, {
202
- writable: true,
203
- value: 3
204
- });
205
- _define_property(this, "log", (...args)=>{
206
- if (0 === _class_private_field_get(this, _level)) return;
207
- let msg = args;
208
- msg = msg.map((item)=>{
209
- let log = item;
210
- switch(typeof log){
211
- case 'object':
212
- log = JSON.stringify(log);
213
- break;
214
- case 'bigint':
215
- case 'number':
216
- case 'boolean':
217
- case 'string':
218
- log = log.toString();
219
- break;
220
- case 'undefined':
221
- default:
222
- break;
223
- }
224
- return log;
225
- });
226
- _class_private_field_get(this, _groups).forEach((group)=>{
227
- msg = msg.map((log)=>` ${log}`);
228
- msg.unshift(`▼ ${group}:`);
229
- });
230
- msg = [
231
- '',
232
- ...msg
233
- ];
234
- console.log(msg.join('\n'));
235
- });
236
- _define_property(this, "time", (label = 'default')=>_class_private_field_get(this, _times).set(label, Date.now()));
237
- _define_property(this, "timeEnd", (label = 'default')=>_class_private_field_get(this, _times).delete(label));
238
- _define_property(this, "timeLog", (label = 'default')=>{
239
- const time = _class_private_field_get(this, _times).get(label);
240
- if (time) this.log(`${label}: ${Date.now() - time}ms`);
241
- else this.warn(`Timer "${label}" doesn’t exist`);
242
- });
243
- }
244
- }
245
- const Console = new ConsoleFactory();
246
- var __webpack_export_target__ = exports;
247
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
248
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
249
- value: true
250
- });
@@ -1,132 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = function(exports1, definition) {
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = function(obj, prop) {
13
- return Object.prototype.hasOwnProperty.call(obj, prop);
14
- };
15
- })();
16
- (()=>{
17
- __webpack_require__.r = function(exports1) {
18
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
19
- value: 'Module'
20
- });
21
- Object.defineProperty(exports1, '__esModule', {
22
- value: true
23
- });
24
- };
25
- })();
26
- var __webpack_exports__ = {};
27
- __webpack_require__.r(__webpack_exports__);
28
- __webpack_require__.d(__webpack_exports__, {
29
- Lodash: function() {
30
- return Lodash;
31
- },
32
- escape: function() {
33
- return escape;
34
- },
35
- get: function() {
36
- return get;
37
- },
38
- omit: function() {
39
- return omit;
40
- },
41
- pick: function() {
42
- return pick;
43
- },
44
- set: function() {
45
- return set;
46
- },
47
- toPath: function() {
48
- return toPath;
49
- },
50
- unescape: function() {
51
- return unescape;
52
- },
53
- unset: function() {
54
- return unset;
55
- }
56
- });
57
- const ESCAPE_MAP = {
58
- '&': '&amp;',
59
- '<': '&lt;',
60
- '>': '&gt;',
61
- '"': '&quot;',
62
- "'": '&#39;'
63
- };
64
- const UNESCAPE_MAP = {
65
- '&amp;': '&',
66
- '&lt;': '<',
67
- '&gt;': '>',
68
- '&quot;': '"',
69
- '&#39;': "'"
70
- };
71
- const ESCAPE_REGEX = /[&<>"']/g;
72
- const UNESCAPE_REGEX = /&(amp|lt|gt|quot|#39);/g;
73
- const escape = (str)=>{
74
- if (!ESCAPE_REGEX.test(str)) return str;
75
- ESCAPE_REGEX.lastIndex = 0;
76
- return str.replace(ESCAPE_REGEX, (match)=>ESCAPE_MAP[match]);
77
- };
78
- const unescape = (str)=>{
79
- if (!UNESCAPE_REGEX.test(str)) return str;
80
- UNESCAPE_REGEX.lastIndex = 0;
81
- return str.replace(UNESCAPE_REGEX, (match)=>UNESCAPE_MAP[match]);
82
- };
83
- const toPath = (value)=>value.replace(/\[(\d+)\]/g, '.$1').split('.').filter(Boolean);
84
- const get = (obj, path, defaultValue)=>{
85
- const getPath = Array.isArray(path) ? path : toPath(path);
86
- const result = getPath.reduce((previousValue, currentValue)=>Object(previousValue)[currentValue], obj);
87
- return void 0 === result ? defaultValue : result;
88
- };
89
- const set = (obj, path, value)=>{
90
- const setPath = Array.isArray(path) ? path : toPath(path);
91
- setPath.slice(0, -1).reduce((prev, key, index)=>{
92
- if ('object' != typeof prev[key] || null === prev[key]) prev[key] = /^\d+$/.test(setPath[index + 1]) ? [] : {};
93
- return prev[key];
94
- }, obj)[setPath[setPath.length - 1]] = value;
95
- return obj;
96
- };
97
- const unset = (obj, path)=>{
98
- const unsetPath = Array.isArray(path) ? path : toPath(path);
99
- return unsetPath.reduce((previousValue, currentValue, currentIndex)=>{
100
- if (currentIndex === path.length - 1) {
101
- delete previousValue[currentValue];
102
- return true;
103
- }
104
- return Object(previousValue)[currentValue];
105
- }, obj);
106
- };
107
- const omit = (obj, paths)=>{
108
- const result = {
109
- ...obj
110
- };
111
- paths.forEach((path)=>unset(result, path));
112
- return result;
113
- };
114
- const pick = (obj, paths)=>Object.entries(obj).filter(([key])=>paths.includes(key)).reduce((result, [key, value])=>{
115
- result[key] = value;
116
- return result;
117
- }, {});
118
- const Lodash = {
119
- escape,
120
- unescape,
121
- toPath,
122
- get,
123
- set,
124
- unset,
125
- omit,
126
- pick
127
- };
128
- var __webpack_export_target__ = exports;
129
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
130
- if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
131
- value: true
132
- });