@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.
- package/dist/{getStorage.js → getStorage.mjs} +5 -5
- package/dist/index.js +11 -11
- package/dist/index.mjs +11 -0
- package/dist/lib/app.d.ts +1 -1
- package/dist/lib/{done.js → done.mjs} +13 -13
- package/dist/lib/{environment.js → environment.mjs} +2 -2
- package/dist/lib/{index.js → index.mjs} +6 -6
- package/dist/lib/{notification.js → notification.mjs} +10 -10
- package/dist/lib/{runScript.js → runScript.mjs} +7 -7
- package/dist/polyfill/{Console.js → Console.mjs} +2 -2
- package/dist/polyfill/Storage.d.ts +7 -11
- package/dist/polyfill/Storage.mjs +188 -0
- package/dist/polyfill/fetch-node.d.ts +1 -0
- package/dist/polyfill/fetch-node.mjs +8 -0
- package/dist/polyfill/{fetch.js → fetch.mjs} +14 -16
- package/dist/polyfill/index.mjs +5 -0
- package/package.json +8 -12
- package/dist/env.d.cjs +0 -6
- package/dist/env.d.js +0 -0
- package/dist/getStorage.cjs +0 -96
- package/dist/index.cjs +0 -155
- package/dist/lib/app.cjs +0 -48
- package/dist/lib/done.cjs +0 -109
- package/dist/lib/environment.cjs +0 -70
- package/dist/lib/index.cjs +0 -101
- package/dist/lib/notification.cjs +0 -135
- package/dist/lib/runScript.cjs +0 -67
- package/dist/lib/time.cjs +0 -54
- package/dist/lib/wait.cjs +0 -40
- package/dist/polyfill/Console.cjs +0 -250
- package/dist/polyfill/Lodash.cjs +0 -132
- package/dist/polyfill/StatusTexts.cjs +0 -99
- package/dist/polyfill/Storage.cjs +0 -213
- package/dist/polyfill/Storage.js +0 -161
- package/dist/polyfill/fetch.cjs +0 -200
- package/dist/polyfill/index.cjs +0 -101
- package/dist/polyfill/index.js +0 -5
- /package/dist/lib/{app.js → app.mjs} +0 -0
- /package/dist/lib/{time.js → time.mjs} +0 -0
- /package/dist/lib/{wait.js → wait.mjs} +0 -0
- /package/dist/polyfill/{Lodash.js → Lodash.mjs} +0 -0
- /package/dist/polyfill/{StatusTexts.js → StatusTexts.mjs} +0 -0
|
@@ -1,99 +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
|
-
StatusTexts: function() {
|
|
30
|
-
return StatusTexts;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
const StatusTexts = {
|
|
34
|
-
100: 'Continue',
|
|
35
|
-
101: 'Switching Protocols',
|
|
36
|
-
102: 'Processing',
|
|
37
|
-
103: 'Early Hints',
|
|
38
|
-
200: 'OK',
|
|
39
|
-
201: 'Created',
|
|
40
|
-
202: 'Accepted',
|
|
41
|
-
203: 'Non-Authoritative Information',
|
|
42
|
-
204: 'No Content',
|
|
43
|
-
205: 'Reset Content',
|
|
44
|
-
206: 'Partial Content',
|
|
45
|
-
207: 'Multi-Status',
|
|
46
|
-
208: 'Already Reported',
|
|
47
|
-
226: 'IM Used',
|
|
48
|
-
300: 'Multiple Choices',
|
|
49
|
-
301: 'Moved Permanently',
|
|
50
|
-
302: 'Found',
|
|
51
|
-
304: 'Not Modified',
|
|
52
|
-
307: 'Temporary Redirect',
|
|
53
|
-
308: 'Permanent Redirect',
|
|
54
|
-
400: 'Bad Request',
|
|
55
|
-
401: 'Unauthorized',
|
|
56
|
-
402: 'Payment Required',
|
|
57
|
-
403: 'Forbidden',
|
|
58
|
-
404: 'Not Found',
|
|
59
|
-
405: 'Method Not Allowed',
|
|
60
|
-
406: 'Not Acceptable',
|
|
61
|
-
407: 'Proxy Authentication Required',
|
|
62
|
-
408: 'Request Timeout',
|
|
63
|
-
409: 'Conflict',
|
|
64
|
-
410: 'Gone',
|
|
65
|
-
411: 'Length Required',
|
|
66
|
-
412: 'Precondition Failed',
|
|
67
|
-
413: 'Content Too Large',
|
|
68
|
-
414: 'URI Too Long',
|
|
69
|
-
415: 'Unsupported Media Type',
|
|
70
|
-
416: 'Range Not Satisfiable',
|
|
71
|
-
417: 'Expectation Failed',
|
|
72
|
-
418: "I'm a teapot",
|
|
73
|
-
421: 'Misdirected Request',
|
|
74
|
-
422: 'Unprocessable Entity',
|
|
75
|
-
423: 'Locked',
|
|
76
|
-
424: 'Failed Dependency',
|
|
77
|
-
425: 'Too Early',
|
|
78
|
-
426: 'Upgrade Required',
|
|
79
|
-
428: 'Precondition Required',
|
|
80
|
-
429: 'Too Many Requests',
|
|
81
|
-
431: 'Request Header Fields Too Large',
|
|
82
|
-
451: 'Unavailable For Legal Reasons',
|
|
83
|
-
500: 'Internal Server Error',
|
|
84
|
-
501: 'Not Implemented',
|
|
85
|
-
502: 'Bad Gateway',
|
|
86
|
-
503: 'Service Unavailable',
|
|
87
|
-
504: 'Gateway Timeout',
|
|
88
|
-
505: 'HTTP Version Not Supported',
|
|
89
|
-
506: 'Variant Also Negotiates',
|
|
90
|
-
507: 'Insufficient Storage',
|
|
91
|
-
508: 'Loop Detected',
|
|
92
|
-
510: 'Not Extended',
|
|
93
|
-
511: 'Network Authentication Required'
|
|
94
|
-
};
|
|
95
|
-
var __webpack_export_target__ = exports;
|
|
96
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
97
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
98
|
-
value: true
|
|
99
|
-
});
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_modules__ = {
|
|
3
|
-
"node:fs": function(module) {
|
|
4
|
-
module.exports = import("node:fs");
|
|
5
|
-
},
|
|
6
|
-
"node:path": function(module) {
|
|
7
|
-
module.exports = import("node:path");
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var __webpack_module_cache__ = {};
|
|
11
|
-
function __webpack_require__(moduleId) {
|
|
12
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
15
|
-
exports: {}
|
|
16
|
-
};
|
|
17
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
|
-
return module.exports;
|
|
19
|
-
}
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.d = function(exports1, definition) {
|
|
22
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: definition[key]
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
(()=>{
|
|
29
|
-
__webpack_require__.o = function(obj, prop) {
|
|
30
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
(()=>{
|
|
34
|
-
__webpack_require__.r = function(exports1) {
|
|
35
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
36
|
-
value: 'Module'
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
39
|
-
value: true
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
var __webpack_exports__ = {};
|
|
44
|
-
__webpack_require__.r(__webpack_exports__);
|
|
45
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
46
|
-
StorageClass: ()=>StorageClass,
|
|
47
|
-
Storage: ()=>Storage
|
|
48
|
-
});
|
|
49
|
-
const external_Lodash_cjs_namespaceObject = require("./Lodash.cjs");
|
|
50
|
-
const app_cjs_namespaceObject = require("../lib/app.cjs");
|
|
51
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
52
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
53
|
-
}
|
|
54
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
55
|
-
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
56
|
-
return fn;
|
|
57
|
-
}
|
|
58
|
-
function _class_private_method_init(obj, privateSet) {
|
|
59
|
-
_check_private_redeclaration(obj, privateSet);
|
|
60
|
-
privateSet.add(obj);
|
|
61
|
-
}
|
|
62
|
-
function _define_property(obj, key, value) {
|
|
63
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
64
|
-
value: value,
|
|
65
|
-
enumerable: true,
|
|
66
|
-
configurable: true,
|
|
67
|
-
writable: true
|
|
68
|
-
});
|
|
69
|
-
else obj[key] = value;
|
|
70
|
-
return obj;
|
|
71
|
-
}
|
|
72
|
-
var _getNodeModule = /*#__PURE__*/ new WeakSet(), _loadData = /*#__PURE__*/ new WeakSet(), _writeData = /*#__PURE__*/ new WeakSet();
|
|
73
|
-
class StorageClass {
|
|
74
|
-
getItem(keyName, defaultValue = null) {
|
|
75
|
-
let keyValue = defaultValue;
|
|
76
|
-
if (keyName.startsWith('@')) {
|
|
77
|
-
var _keyName_match;
|
|
78
|
-
const { key, path } = (null === (_keyName_match = keyName.match(this.nameRegex)) || void 0 === _keyName_match ? void 0 : _keyName_match.groups) || {};
|
|
79
|
-
if (key) {
|
|
80
|
-
let value = this.getItem(key, {});
|
|
81
|
-
if ('object' != typeof value) value = {};
|
|
82
|
-
keyValue = (0, external_Lodash_cjs_namespaceObject.get)(value, path);
|
|
83
|
-
try {
|
|
84
|
-
keyValue = JSON.parse(keyValue);
|
|
85
|
-
} catch {}
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
switch(app_cjs_namespaceObject.$app){
|
|
89
|
-
case 'Surge':
|
|
90
|
-
case 'Loon':
|
|
91
|
-
case 'Stash':
|
|
92
|
-
case 'Egern':
|
|
93
|
-
case 'Shadowrocket':
|
|
94
|
-
keyValue = $persistentStore.read(keyName);
|
|
95
|
-
break;
|
|
96
|
-
case 'Quantumult X':
|
|
97
|
-
keyValue = $prefs.valueForKey(keyName);
|
|
98
|
-
break;
|
|
99
|
-
case 'Node.js':
|
|
100
|
-
this.data = this.data || {};
|
|
101
|
-
keyValue = this.data[keyName];
|
|
102
|
-
break;
|
|
103
|
-
default:
|
|
104
|
-
keyValue = null;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
try {
|
|
108
|
-
keyValue = JSON.parse(keyValue);
|
|
109
|
-
} catch {}
|
|
110
|
-
}
|
|
111
|
-
return keyValue ?? defaultValue;
|
|
112
|
-
}
|
|
113
|
-
setItem(keyName, value) {
|
|
114
|
-
let keyValue = value;
|
|
115
|
-
keyValue = 'object' == typeof keyValue ? JSON.stringify(keyValue) : String(keyValue);
|
|
116
|
-
if (keyName.startsWith('@')) {
|
|
117
|
-
var _keyName_match;
|
|
118
|
-
const { key, path } = (null === (_keyName_match = keyName.match(this.nameRegex)) || void 0 === _keyName_match ? void 0 : _keyName_match.groups) || {};
|
|
119
|
-
if (key) {
|
|
120
|
-
let value = this.getItem(key, {});
|
|
121
|
-
if ('object' != typeof value) value = {};
|
|
122
|
-
(0, external_Lodash_cjs_namespaceObject.set)(value, path, keyValue);
|
|
123
|
-
return this.setItem(keyName, value);
|
|
124
|
-
}
|
|
125
|
-
} else switch(app_cjs_namespaceObject.$app){
|
|
126
|
-
case 'Surge':
|
|
127
|
-
case 'Loon':
|
|
128
|
-
case 'Stash':
|
|
129
|
-
case 'Egern':
|
|
130
|
-
case 'Shadowrocket':
|
|
131
|
-
return $persistentStore.write(keyValue, keyName);
|
|
132
|
-
case 'Quantumult X':
|
|
133
|
-
return $prefs.setValueForKey(keyValue, keyName);
|
|
134
|
-
case 'Node.js':
|
|
135
|
-
this.data = this.data || {};
|
|
136
|
-
this.data[keyName] = keyValue;
|
|
137
|
-
_class_private_method_get(this, _writeData, writeData).call(this, this.dataFile);
|
|
138
|
-
return true;
|
|
139
|
-
default:
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
removeItem(keyName) {
|
|
145
|
-
if (keyName.startsWith('@')) {
|
|
146
|
-
var _keyName_match;
|
|
147
|
-
const { key, path } = (null === (_keyName_match = keyName.match(this.nameRegex)) || void 0 === _keyName_match ? void 0 : _keyName_match.groups) || {};
|
|
148
|
-
if (key) {
|
|
149
|
-
let value = this.getItem(key);
|
|
150
|
-
if ('object' != typeof value) value = {};
|
|
151
|
-
(0, external_Lodash_cjs_namespaceObject.unset)(value, path);
|
|
152
|
-
return this.setItem(key, value);
|
|
153
|
-
}
|
|
154
|
-
} else switch(app_cjs_namespaceObject.$app){
|
|
155
|
-
case 'Quantumult X':
|
|
156
|
-
return $prefs.removeValueForKey(keyName);
|
|
157
|
-
default:
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
clear() {
|
|
163
|
-
switch(app_cjs_namespaceObject.$app){
|
|
164
|
-
case 'Quantumult X':
|
|
165
|
-
return $prefs.removeAllValues();
|
|
166
|
-
default:
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
constructor(){
|
|
171
|
-
_class_private_method_init(this, _getNodeModule);
|
|
172
|
-
_class_private_method_init(this, _loadData);
|
|
173
|
-
_class_private_method_init(this, _writeData);
|
|
174
|
-
_define_property(this, "data", null);
|
|
175
|
-
_define_property(this, "dataFile", 'box.dat');
|
|
176
|
-
_define_property(this, "nameRegex", /^@(?<key>[^.]+)(?:\.(?<path>.*))?$/);
|
|
177
|
-
if ('Node.js' === app_cjs_namespaceObject.$app) _class_private_method_get(this, _loadData, loadData).call(this, this.dataFile).then((res)=>{
|
|
178
|
-
this.data = res;
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
async function getNodeModule() {
|
|
183
|
-
if ('Node.js' === app_cjs_namespaceObject.$app) {
|
|
184
|
-
const fs = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:fs"));
|
|
185
|
-
const path = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node:path"));
|
|
186
|
-
return {
|
|
187
|
-
fs,
|
|
188
|
-
path
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
async function loadData(dataFile) {
|
|
194
|
-
const { fs, path } = await _class_private_method_get(this, _getNodeModule, getNodeModule).call(this) ?? {};
|
|
195
|
-
if (!fs || !path) return {};
|
|
196
|
-
const curDirDataFilePath = path.resolve(dataFile);
|
|
197
|
-
const rootDirDataFilePath = path.resolve(process.cwd(), dataFile);
|
|
198
|
-
if (fs.existsSync(curDirDataFilePath)) return JSON.parse(fs.readFileSync(curDirDataFilePath, 'utf-8')) || {};
|
|
199
|
-
if (fs.existsSync(rootDirDataFilePath)) return JSON.parse(fs.readFileSync(rootDirDataFilePath, 'utf-8')) || {};
|
|
200
|
-
return {};
|
|
201
|
-
}
|
|
202
|
-
async function writeData(dataFile) {
|
|
203
|
-
const { fs, path } = await _class_private_method_get(this, _getNodeModule, getNodeModule).call(this) ?? {};
|
|
204
|
-
if (!fs || !path) return;
|
|
205
|
-
const dataFilePath = path.resolve(dataFile);
|
|
206
|
-
fs.writeFileSync(dataFilePath, JSON.stringify(this.data), 'utf-8');
|
|
207
|
-
}
|
|
208
|
-
const Storage = new StorageClass();
|
|
209
|
-
var __webpack_export_target__ = exports;
|
|
210
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
211
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
212
|
-
value: true
|
|
213
|
-
});
|
package/dist/polyfill/Storage.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE__Lodash_js__ from "./Lodash.js";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__lib_app_js__ from "../lib/app.js";
|
|
3
|
-
function _check_private_redeclaration(obj, privateCollection) {
|
|
4
|
-
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
5
|
-
}
|
|
6
|
-
function _class_private_method_get(receiver, privateSet, fn) {
|
|
7
|
-
if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
|
|
8
|
-
return fn;
|
|
9
|
-
}
|
|
10
|
-
function _class_private_method_init(obj, privateSet) {
|
|
11
|
-
_check_private_redeclaration(obj, privateSet);
|
|
12
|
-
privateSet.add(obj);
|
|
13
|
-
}
|
|
14
|
-
function _define_property(obj, key, value) {
|
|
15
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
16
|
-
value: value,
|
|
17
|
-
enumerable: true,
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true
|
|
20
|
-
});
|
|
21
|
-
else obj[key] = value;
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
var _getNodeModule = /*#__PURE__*/ new WeakSet(), _loadData = /*#__PURE__*/ new WeakSet(), _writeData = /*#__PURE__*/ new WeakSet();
|
|
25
|
-
class StorageClass {
|
|
26
|
-
getItem(keyName, defaultValue = null) {
|
|
27
|
-
let keyValue = defaultValue;
|
|
28
|
-
if (keyName.startsWith('@')) {
|
|
29
|
-
var _keyName_match;
|
|
30
|
-
const { key, path } = (null === (_keyName_match = keyName.match(this.nameRegex)) || void 0 === _keyName_match ? void 0 : _keyName_match.groups) || {};
|
|
31
|
-
if (key) {
|
|
32
|
-
let value = this.getItem(key, {});
|
|
33
|
-
if ('object' != typeof value) value = {};
|
|
34
|
-
keyValue = (0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.get)(value, path);
|
|
35
|
-
try {
|
|
36
|
-
keyValue = JSON.parse(keyValue);
|
|
37
|
-
} catch {}
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
switch(__WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app){
|
|
41
|
-
case 'Surge':
|
|
42
|
-
case 'Loon':
|
|
43
|
-
case 'Stash':
|
|
44
|
-
case 'Egern':
|
|
45
|
-
case 'Shadowrocket':
|
|
46
|
-
keyValue = $persistentStore.read(keyName);
|
|
47
|
-
break;
|
|
48
|
-
case 'Quantumult X':
|
|
49
|
-
keyValue = $prefs.valueForKey(keyName);
|
|
50
|
-
break;
|
|
51
|
-
case 'Node.js':
|
|
52
|
-
this.data = this.data || {};
|
|
53
|
-
keyValue = this.data[keyName];
|
|
54
|
-
break;
|
|
55
|
-
default:
|
|
56
|
-
keyValue = null;
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
keyValue = JSON.parse(keyValue);
|
|
61
|
-
} catch {}
|
|
62
|
-
}
|
|
63
|
-
return keyValue ?? defaultValue;
|
|
64
|
-
}
|
|
65
|
-
setItem(keyName, value) {
|
|
66
|
-
let keyValue = value;
|
|
67
|
-
keyValue = 'object' == typeof keyValue ? JSON.stringify(keyValue) : String(keyValue);
|
|
68
|
-
if (keyName.startsWith('@')) {
|
|
69
|
-
var _keyName_match;
|
|
70
|
-
const { key, path } = (null === (_keyName_match = keyName.match(this.nameRegex)) || void 0 === _keyName_match ? void 0 : _keyName_match.groups) || {};
|
|
71
|
-
if (key) {
|
|
72
|
-
let value = this.getItem(key, {});
|
|
73
|
-
if ('object' != typeof value) value = {};
|
|
74
|
-
(0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.set)(value, path, keyValue);
|
|
75
|
-
return this.setItem(keyName, value);
|
|
76
|
-
}
|
|
77
|
-
} else switch(__WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app){
|
|
78
|
-
case 'Surge':
|
|
79
|
-
case 'Loon':
|
|
80
|
-
case 'Stash':
|
|
81
|
-
case 'Egern':
|
|
82
|
-
case 'Shadowrocket':
|
|
83
|
-
return $persistentStore.write(keyValue, keyName);
|
|
84
|
-
case 'Quantumult X':
|
|
85
|
-
return $prefs.setValueForKey(keyValue, keyName);
|
|
86
|
-
case 'Node.js':
|
|
87
|
-
this.data = this.data || {};
|
|
88
|
-
this.data[keyName] = keyValue;
|
|
89
|
-
_class_private_method_get(this, _writeData, writeData).call(this, this.dataFile);
|
|
90
|
-
return true;
|
|
91
|
-
default:
|
|
92
|
-
break;
|
|
93
|
-
}
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
removeItem(keyName) {
|
|
97
|
-
if (keyName.startsWith('@')) {
|
|
98
|
-
var _keyName_match;
|
|
99
|
-
const { key, path } = (null === (_keyName_match = keyName.match(this.nameRegex)) || void 0 === _keyName_match ? void 0 : _keyName_match.groups) || {};
|
|
100
|
-
if (key) {
|
|
101
|
-
let value = this.getItem(key);
|
|
102
|
-
if ('object' != typeof value) value = {};
|
|
103
|
-
(0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.unset)(value, path);
|
|
104
|
-
return this.setItem(key, value);
|
|
105
|
-
}
|
|
106
|
-
} else switch(__WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app){
|
|
107
|
-
case 'Quantumult X':
|
|
108
|
-
return $prefs.removeValueForKey(keyName);
|
|
109
|
-
default:
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
clear() {
|
|
115
|
-
switch(__WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app){
|
|
116
|
-
case 'Quantumult X':
|
|
117
|
-
return $prefs.removeAllValues();
|
|
118
|
-
default:
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
constructor(){
|
|
123
|
-
_class_private_method_init(this, _getNodeModule);
|
|
124
|
-
_class_private_method_init(this, _loadData);
|
|
125
|
-
_class_private_method_init(this, _writeData);
|
|
126
|
-
_define_property(this, "data", null);
|
|
127
|
-
_define_property(this, "dataFile", 'box.dat');
|
|
128
|
-
_define_property(this, "nameRegex", /^@(?<key>[^.]+)(?:\.(?<path>.*))?$/);
|
|
129
|
-
if ('Node.js' === __WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app) _class_private_method_get(this, _loadData, loadData).call(this, this.dataFile).then((res)=>{
|
|
130
|
-
this.data = res;
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
async function getNodeModule() {
|
|
135
|
-
if ('Node.js' === __WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app) {
|
|
136
|
-
const fs = await import("node:fs");
|
|
137
|
-
const path = await import("node:path");
|
|
138
|
-
return {
|
|
139
|
-
fs,
|
|
140
|
-
path
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
async function loadData(dataFile) {
|
|
146
|
-
const { fs, path } = await _class_private_method_get(this, _getNodeModule, getNodeModule).call(this) ?? {};
|
|
147
|
-
if (!fs || !path) return {};
|
|
148
|
-
const curDirDataFilePath = path.resolve(dataFile);
|
|
149
|
-
const rootDirDataFilePath = path.resolve(process.cwd(), dataFile);
|
|
150
|
-
if (fs.existsSync(curDirDataFilePath)) return JSON.parse(fs.readFileSync(curDirDataFilePath, 'utf-8')) || {};
|
|
151
|
-
if (fs.existsSync(rootDirDataFilePath)) return JSON.parse(fs.readFileSync(rootDirDataFilePath, 'utf-8')) || {};
|
|
152
|
-
return {};
|
|
153
|
-
}
|
|
154
|
-
async function writeData(dataFile) {
|
|
155
|
-
const { fs, path } = await _class_private_method_get(this, _getNodeModule, getNodeModule).call(this) ?? {};
|
|
156
|
-
if (!fs || !path) return;
|
|
157
|
-
const dataFilePath = path.resolve(dataFile);
|
|
158
|
-
fs.writeFileSync(dataFilePath, JSON.stringify(this.data), 'utf-8');
|
|
159
|
-
}
|
|
160
|
-
const Storage = new StorageClass();
|
|
161
|
-
export { Storage, StorageClass };
|
package/dist/polyfill/fetch.cjs
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_modules__ = {
|
|
3
|
-
"fetch-cookie": function(module) {
|
|
4
|
-
module.exports = import("fetch-cookie");
|
|
5
|
-
},
|
|
6
|
-
"node-fetch": function(module) {
|
|
7
|
-
module.exports = import("node-fetch");
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var __webpack_module_cache__ = {};
|
|
11
|
-
function __webpack_require__(moduleId) {
|
|
12
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
15
|
-
exports: {}
|
|
16
|
-
};
|
|
17
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
|
-
return module.exports;
|
|
19
|
-
}
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.d = function(exports1, definition) {
|
|
22
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: definition[key]
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
(()=>{
|
|
29
|
-
__webpack_require__.o = function(obj, prop) {
|
|
30
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
(()=>{
|
|
34
|
-
__webpack_require__.r = function(exports1) {
|
|
35
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
36
|
-
value: 'Module'
|
|
37
|
-
});
|
|
38
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
39
|
-
value: true
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
})();
|
|
43
|
-
var __webpack_exports__ = {};
|
|
44
|
-
__webpack_require__.r(__webpack_exports__);
|
|
45
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
46
|
-
fetch: ()=>fetch_rslib_entry_fetch
|
|
47
|
-
});
|
|
48
|
-
const external_Lodash_cjs_namespaceObject = require("./Lodash.cjs");
|
|
49
|
-
const app_cjs_namespaceObject = require("../lib/app.cjs");
|
|
50
|
-
const external_StatusTexts_cjs_namespaceObject = require("./StatusTexts.cjs");
|
|
51
|
-
const binaryMimeTypes = [
|
|
52
|
-
'application/protobuf',
|
|
53
|
-
'application/x-protobuf',
|
|
54
|
-
'application/vnd.google.protobuf',
|
|
55
|
-
'application/vnd.apple.flatbuffer',
|
|
56
|
-
'application/grpc',
|
|
57
|
-
'application/grpc+proto',
|
|
58
|
-
'application/octet-stream'
|
|
59
|
-
];
|
|
60
|
-
async function fetch_rslib_entry_fetch(resource, options = {
|
|
61
|
-
timeout: 5
|
|
62
|
-
}) {
|
|
63
|
-
var _split, _this, _params_headers, _params_headers1;
|
|
64
|
-
let params = {
|
|
65
|
-
...options
|
|
66
|
-
};
|
|
67
|
-
if ('string' == typeof resource) params.url = resource;
|
|
68
|
-
else if ('object' == typeof resource) params = {
|
|
69
|
-
...params,
|
|
70
|
-
...resource
|
|
71
|
-
};
|
|
72
|
-
else throw new TypeError(`${Function.name}: 参数类型错误, resource 必须为对象或字符串`);
|
|
73
|
-
if (!params.method) {
|
|
74
|
-
params.method = 'GET';
|
|
75
|
-
if (params.body || params.bodyBytes) params.method = 'POST';
|
|
76
|
-
}
|
|
77
|
-
if (params.headers) {
|
|
78
|
-
params.headers.Host = void 0;
|
|
79
|
-
params.headers[':authority'] = void 0;
|
|
80
|
-
params.headers['Content-Length'] = void 0;
|
|
81
|
-
params.headers['content-length'] = void 0;
|
|
82
|
-
}
|
|
83
|
-
const method = params.method.toLocaleLowerCase();
|
|
84
|
-
if (params.timeout) {
|
|
85
|
-
params.timeout = Number.parseInt(params.timeout.toString(), 10);
|
|
86
|
-
if (params.timeout > 500) params.timeout = Math.round(params.timeout / 1000);
|
|
87
|
-
}
|
|
88
|
-
if ('Quantumult X' === app_cjs_namespaceObject.$app) {
|
|
89
|
-
if (params.policy) (0, external_Lodash_cjs_namespaceObject.set)(params, 'opts.policy', params.policy);
|
|
90
|
-
if ('boolean' == typeof params['auto-redirect']) (0, external_Lodash_cjs_namespaceObject.set)(params, 'opts.redirection', params['auto-redirect']);
|
|
91
|
-
if (params.body instanceof ArrayBuffer) {
|
|
92
|
-
params.bodyBytes = params.body;
|
|
93
|
-
params.body = void 0;
|
|
94
|
-
} else if (ArrayBuffer.isView(params.body)) {
|
|
95
|
-
params.bodyBytes = params.body.buffer.slice(params.body.byteOffset, params.body.byteLength + params.body.byteOffset);
|
|
96
|
-
params.body = void 0;
|
|
97
|
-
} else if (params.body) params.bodyBytes = void 0;
|
|
98
|
-
return Promise.race([
|
|
99
|
-
await $task.fetch(params).then((response)=>{
|
|
100
|
-
var _split, _this, _response_headers, _response_headers1;
|
|
101
|
-
response.ok = /^2\d\d$/.test(response.statusCode);
|
|
102
|
-
response.status = response.statusCode;
|
|
103
|
-
response.statusText = external_StatusTexts_cjs_namespaceObject.StatusTexts[response.status];
|
|
104
|
-
if (binaryMimeTypes.includes(null === (_this = (null === (_response_headers = response.headers) || void 0 === _response_headers ? void 0 : _response_headers['Content-Type']) ?? (null === (_response_headers1 = response.headers) || void 0 === _response_headers1 ? void 0 : _response_headers1['content-type'])) || void 0 === _this ? void 0 : null === (_split = _this.split(';')) || void 0 === _split ? void 0 : _split[0])) response.body = response.bodyBytes;
|
|
105
|
-
response.bodyBytes = void 0;
|
|
106
|
-
return response;
|
|
107
|
-
}, (reason)=>Promise.reject(reason.error)),
|
|
108
|
-
new Promise((_, reject)=>{
|
|
109
|
-
setTimeout(()=>{
|
|
110
|
-
reject(new Error(`${Function.name}: 请求超时, 请检查网络后重试`));
|
|
111
|
-
}, params.timeout);
|
|
112
|
-
})
|
|
113
|
-
]);
|
|
114
|
-
}
|
|
115
|
-
if ('Node.js' === app_cjs_namespaceObject.$app) {
|
|
116
|
-
const nodeFetch = globalThis.fetch ? globalThis.fetch : await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "node-fetch")).then((module)=>module.default);
|
|
117
|
-
const fetchCookie = globalThis.fetchCookie ? globalThis.fetchCookie : await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "fetch-cookie")).then((module)=>module.default);
|
|
118
|
-
const fetch = fetchCookie(nodeFetch);
|
|
119
|
-
params.timeout = (params.timeout ?? 5) * 1000;
|
|
120
|
-
params.redirect = params.redirection ? 'follow' : 'manual';
|
|
121
|
-
const { url, ...options } = params;
|
|
122
|
-
return Promise.race([
|
|
123
|
-
await fetch(url, options).then(async (response)=>{
|
|
124
|
-
const bodyBytes = await response.arrayBuffer();
|
|
125
|
-
let headers;
|
|
126
|
-
try {
|
|
127
|
-
headers = response.headers.raw();
|
|
128
|
-
} catch {
|
|
129
|
-
headers = Array.from(response.headers.entries()).reduce((acc, item)=>{
|
|
130
|
-
const [key, value] = item;
|
|
131
|
-
acc[key] = acc[key] ? [
|
|
132
|
-
...acc[key],
|
|
133
|
-
value
|
|
134
|
-
] : [
|
|
135
|
-
value
|
|
136
|
-
];
|
|
137
|
-
return acc;
|
|
138
|
-
}, {});
|
|
139
|
-
}
|
|
140
|
-
return {
|
|
141
|
-
ok: response.ok ?? /^2\d\d$/.test(response.status),
|
|
142
|
-
status: response.status,
|
|
143
|
-
statusCode: response.status,
|
|
144
|
-
statusText: response.statusText,
|
|
145
|
-
body: new TextDecoder('utf-8').decode(bodyBytes),
|
|
146
|
-
bodyBytes: bodyBytes,
|
|
147
|
-
headers: Object.fromEntries(Object.entries(headers).map(([key, value])=>[
|
|
148
|
-
key,
|
|
149
|
-
'set-cookie' !== key.toLowerCase() ? value.toString() : value
|
|
150
|
-
]))
|
|
151
|
-
};
|
|
152
|
-
}).catch((error)=>Promise.reject(error.message)),
|
|
153
|
-
new Promise((resolve, reject)=>{
|
|
154
|
-
setTimeout(()=>{
|
|
155
|
-
reject(new Error(`${Function.name}: 请求超时, 请检查网络后重试`));
|
|
156
|
-
}, params.timeout);
|
|
157
|
-
})
|
|
158
|
-
]);
|
|
159
|
-
}
|
|
160
|
-
if ('Loon' === app_cjs_namespaceObject.$app) params.timeout *= 1000;
|
|
161
|
-
if (params.policy) switch(app_cjs_namespaceObject.$app){
|
|
162
|
-
case 'Loon':
|
|
163
|
-
params.node = params.policy;
|
|
164
|
-
break;
|
|
165
|
-
case 'Stash':
|
|
166
|
-
(0, external_Lodash_cjs_namespaceObject.set)(params, 'headers.X-Stash-Selected-Proxy', encodeURI(params.policy));
|
|
167
|
-
break;
|
|
168
|
-
case 'Shadowrocket':
|
|
169
|
-
(0, external_Lodash_cjs_namespaceObject.set)(params, 'headers.X-Surge-Proxy', params.policy);
|
|
170
|
-
break;
|
|
171
|
-
default:
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
if ('boolean' == typeof params.redirection) params['auto-redirect'] = params.redirection;
|
|
175
|
-
if (params.bodyBytes && !params.body) {
|
|
176
|
-
params.body = params.bodyBytes;
|
|
177
|
-
params.bodyBytes = void 0;
|
|
178
|
-
}
|
|
179
|
-
if (binaryMimeTypes.includes((null === (_this = (null === (_params_headers = params.headers) || void 0 === _params_headers ? void 0 : _params_headers.Accept) || (null === (_params_headers1 = params.headers) || void 0 === _params_headers1 ? void 0 : _params_headers1.accept)) || void 0 === _this ? void 0 : null === (_split = _this.split(';')) || void 0 === _split ? void 0 : _split[0]) ?? '')) params['binary-mode'] = true;
|
|
180
|
-
return new Promise((resolve, reject)=>{
|
|
181
|
-
$httpClient[method](params, (error, response, body)=>{
|
|
182
|
-
if (error) reject(error);
|
|
183
|
-
else {
|
|
184
|
-
response.ok = /^2\d\d$/.test(response.status);
|
|
185
|
-
response.statusCode = response.status;
|
|
186
|
-
response.statusText = external_StatusTexts_cjs_namespaceObject.StatusTexts[response.status];
|
|
187
|
-
if (body) {
|
|
188
|
-
response.body = body;
|
|
189
|
-
if (params['binary-mode']) response.bodyBytes = body;
|
|
190
|
-
}
|
|
191
|
-
resolve(response);
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
var __webpack_export_target__ = exports;
|
|
197
|
-
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
198
|
-
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
199
|
-
value: true
|
|
200
|
-
});
|