@nsnanocat/util 0.0.0-preview-2c5e49e → 0.0.0-preview-7be35e5
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.cjs +3 -17
- package/dist/getStorage.js +3 -3
- package/dist/lib/done.cjs +5 -21
- package/dist/lib/done.js +5 -6
- package/dist/lib/index.cjs +2 -2
- package/dist/polyfill/Lodash.cjs +96 -38
- package/dist/polyfill/Lodash.d.ts +18 -39
- package/dist/polyfill/Lodash.js +71 -18
- package/dist/polyfill/Storage.cjs +4 -22
- package/dist/polyfill/Storage.js +4 -6
- package/dist/polyfill/fetch.cjs +5 -19
- package/dist/polyfill/fetch.js +5 -5
- package/package.json +2 -3
package/dist/getStorage.cjs
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = function(module) {
|
|
5
|
-
var getter = module && module.__esModule ? function() {
|
|
6
|
-
return module['default'];
|
|
7
|
-
} : function() {
|
|
8
|
-
return module;
|
|
9
|
-
};
|
|
10
|
-
__webpack_require__.d(getter, {
|
|
11
|
-
a: getter
|
|
12
|
-
});
|
|
13
|
-
return getter;
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
3
|
(()=>{
|
|
17
4
|
__webpack_require__.d = function(exports1, definition) {
|
|
18
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -41,8 +28,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
41
28
|
__webpack_require__.d(__webpack_exports__, {
|
|
42
29
|
getStorage: ()=>getStorage
|
|
43
30
|
});
|
|
44
|
-
const
|
|
45
|
-
var set_default = /*#__PURE__*/ __webpack_require__.n(set_namespaceObject);
|
|
31
|
+
const Lodash_cjs_namespaceObject = require("./polyfill/Lodash.cjs");
|
|
46
32
|
const Storage_cjs_namespaceObject = require("./polyfill/Storage.cjs");
|
|
47
33
|
function getStorage(key, names, database) {
|
|
48
34
|
var _database_Default, _database_Default1;
|
|
@@ -67,8 +53,8 @@ function getStorage(key, names, database) {
|
|
|
67
53
|
});
|
|
68
54
|
if ('string' == typeof $argument) {
|
|
69
55
|
const parsedArgument = Object.fromEntries($argument.split('&').map((item)=>item.split('=', 2).map((i)=>i.replace(/\"/g, ''))));
|
|
70
|
-
Object.keys(parsedArgument).forEach((key)=>
|
|
71
|
-
} else if ('object' == typeof $argument) Object.keys($argument).forEach((key)=>
|
|
56
|
+
Object.keys(parsedArgument).forEach((key)=>(0, Lodash_cjs_namespaceObject.set)(Store.Settings, key, parsedArgument[key]));
|
|
57
|
+
} else if ('object' == typeof $argument) Object.keys($argument).forEach((key)=>(0, Lodash_cjs_namespaceObject.set)(Store.Settings, key, $argument[key]));
|
|
72
58
|
const BoxJs = Storage_cjs_namespaceObject.Storage.getItem(key);
|
|
73
59
|
if (BoxJs) nameList.forEach((name)=>{
|
|
74
60
|
var _BoxJs_name, _BoxJs_name1;
|
package/dist/getStorage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__ from "./polyfill/Lodash.js";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_Storage_js__ from "./polyfill/Storage.js";
|
|
3
3
|
function getStorage(key, names, database) {
|
|
4
4
|
var _database_Default, _database_Default1;
|
|
@@ -23,8 +23,8 @@ function getStorage(key, names, database) {
|
|
|
23
23
|
});
|
|
24
24
|
if ('string' == typeof $argument) {
|
|
25
25
|
const parsedArgument = Object.fromEntries($argument.split('&').map((item)=>item.split('=', 2).map((i)=>i.replace(/\"/g, ''))));
|
|
26
|
-
Object.keys(parsedArgument).forEach((key)=>(0,
|
|
27
|
-
} else if ('object' == typeof $argument) Object.keys($argument).forEach((key)=>(0,
|
|
26
|
+
Object.keys(parsedArgument).forEach((key)=>(0, __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__.set)(Store.Settings, key, parsedArgument[key]));
|
|
27
|
+
} else if ('object' == typeof $argument) Object.keys($argument).forEach((key)=>(0, __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__.set)(Store.Settings, key, $argument[key]));
|
|
28
28
|
const BoxJs = __WEBPACK_EXTERNAL_MODULE__polyfill_Storage_js__.Storage.getItem(key);
|
|
29
29
|
if (BoxJs) nameList.forEach((name)=>{
|
|
30
30
|
var _BoxJs_name, _BoxJs_name1;
|
package/dist/lib/done.cjs
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = function(module) {
|
|
5
|
-
var getter = module && module.__esModule ? function() {
|
|
6
|
-
return module['default'];
|
|
7
|
-
} : function() {
|
|
8
|
-
return module;
|
|
9
|
-
};
|
|
10
|
-
__webpack_require__.d(getter, {
|
|
11
|
-
a: getter
|
|
12
|
-
});
|
|
13
|
-
return getter;
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
3
|
(()=>{
|
|
17
4
|
__webpack_require__.d = function(exports1, definition) {
|
|
18
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -41,10 +28,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
41
28
|
__webpack_require__.d(__webpack_exports__, {
|
|
42
29
|
done: ()=>done
|
|
43
30
|
});
|
|
44
|
-
const
|
|
45
|
-
var set_default = /*#__PURE__*/ __webpack_require__.n(set_namespaceObject);
|
|
46
|
-
const pick_namespaceObject = require("lodash/pick");
|
|
47
|
-
var pick_default = /*#__PURE__*/ __webpack_require__.n(pick_namespaceObject);
|
|
31
|
+
const Lodash_cjs_namespaceObject = require("../polyfill/Lodash.cjs");
|
|
48
32
|
const Console_cjs_namespaceObject = require("../polyfill/Console.cjs");
|
|
49
33
|
const StatusTexts_cjs_namespaceObject = require("../polyfill/StatusTexts.cjs");
|
|
50
34
|
const external_app_cjs_namespaceObject = require("./app.cjs");
|
|
@@ -78,7 +62,7 @@ function done(object = {}) {
|
|
|
78
62
|
const handleDone = handleDoneFactory(startTime);
|
|
79
63
|
switch(external_app_cjs_namespaceObject.$app){
|
|
80
64
|
case 'Surge':
|
|
81
|
-
if (object.policy)
|
|
65
|
+
if (object.policy) (0, Lodash_cjs_namespaceObject.set)(object, 'headers.X-Surge-Policy', object.policy);
|
|
82
66
|
handleDone(object);
|
|
83
67
|
break;
|
|
84
68
|
case 'Loon':
|
|
@@ -86,7 +70,7 @@ function done(object = {}) {
|
|
|
86
70
|
handleDone(object);
|
|
87
71
|
break;
|
|
88
72
|
case 'Stash':
|
|
89
|
-
if (object.policy)
|
|
73
|
+
if (object.policy) (0, Lodash_cjs_namespaceObject.set)(object, 'headers.X-Stash-Selected-Proxy', encodeURI(object.policy));
|
|
90
74
|
handleDone(object);
|
|
91
75
|
break;
|
|
92
76
|
case 'Egern':
|
|
@@ -98,7 +82,7 @@ function done(object = {}) {
|
|
|
98
82
|
case 'Quantumult X':
|
|
99
83
|
{
|
|
100
84
|
const transformedObject = {
|
|
101
|
-
...
|
|
85
|
+
...(0, Lodash_cjs_namespaceObject.pick)(object, [
|
|
102
86
|
'status',
|
|
103
87
|
'url',
|
|
104
88
|
'headers',
|
|
@@ -108,7 +92,7 @@ function done(object = {}) {
|
|
|
108
92
|
...transformQuantumultXStatus(object),
|
|
109
93
|
...transformQuantumultXBody(object)
|
|
110
94
|
};
|
|
111
|
-
if (object.policy)
|
|
95
|
+
if (object.policy) (0, Lodash_cjs_namespaceObject.set)(transformedObject, 'opts.policy', object.policy);
|
|
112
96
|
handleDone(transformedObject);
|
|
113
97
|
break;
|
|
114
98
|
}
|
package/dist/lib/done.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_lodash_pick__ from "lodash/pick";
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__ from "../polyfill/Lodash.js";
|
|
3
2
|
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_Console_js__ from "../polyfill/Console.js";
|
|
4
3
|
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_StatusTexts_js__ from "../polyfill/StatusTexts.js";
|
|
5
4
|
import * as __WEBPACK_EXTERNAL_MODULE__app_js__ from "./app.js";
|
|
@@ -33,7 +32,7 @@ function done(object = {}) {
|
|
|
33
32
|
const handleDone = handleDoneFactory(startTime);
|
|
34
33
|
switch(__WEBPACK_EXTERNAL_MODULE__app_js__.$app){
|
|
35
34
|
case 'Surge':
|
|
36
|
-
if (object.policy) (0,
|
|
35
|
+
if (object.policy) (0, __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__.set)(object, 'headers.X-Surge-Policy', object.policy);
|
|
37
36
|
handleDone(object);
|
|
38
37
|
break;
|
|
39
38
|
case 'Loon':
|
|
@@ -41,7 +40,7 @@ function done(object = {}) {
|
|
|
41
40
|
handleDone(object);
|
|
42
41
|
break;
|
|
43
42
|
case 'Stash':
|
|
44
|
-
if (object.policy) (0,
|
|
43
|
+
if (object.policy) (0, __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__.set)(object, 'headers.X-Stash-Selected-Proxy', encodeURI(object.policy));
|
|
45
44
|
handleDone(object);
|
|
46
45
|
break;
|
|
47
46
|
case 'Egern':
|
|
@@ -53,7 +52,7 @@ function done(object = {}) {
|
|
|
53
52
|
case 'Quantumult X':
|
|
54
53
|
{
|
|
55
54
|
const transformedObject = {
|
|
56
|
-
...(0,
|
|
55
|
+
...(0, __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__.pick)(object, [
|
|
57
56
|
'status',
|
|
58
57
|
'url',
|
|
59
58
|
'headers',
|
|
@@ -63,7 +62,7 @@ function done(object = {}) {
|
|
|
63
62
|
...transformQuantumultXStatus(object),
|
|
64
63
|
...transformQuantumultXBody(object)
|
|
65
64
|
};
|
|
66
|
-
if (object.policy) (0,
|
|
65
|
+
if (object.policy) (0, __WEBPACK_EXTERNAL_MODULE__polyfill_Lodash_js__.set)(transformedObject, 'opts.policy', object.policy);
|
|
67
66
|
handleDone(transformedObject);
|
|
68
67
|
break;
|
|
69
68
|
}
|
package/dist/lib/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
"./app
|
|
3
|
+
"./app": function(module) {
|
|
4
4
|
module.exports = require("./app.cjs");
|
|
5
5
|
},
|
|
6
6
|
"./done": function(module) {
|
|
@@ -64,7 +64,7 @@ function __webpack_require__(moduleId) {
|
|
|
64
64
|
})();
|
|
65
65
|
var __webpack_exports__ = {};
|
|
66
66
|
__webpack_require__.r(__webpack_exports__);
|
|
67
|
-
var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./app
|
|
67
|
+
var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./app");
|
|
68
68
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
69
69
|
for(var __WEBPACK_IMPORT_KEY__ in _app__WEBPACK_IMPORTED_MODULE_0__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
70
70
|
return _app__WEBPACK_IMPORTED_MODULE_0__[key];
|
package/dist/polyfill/Lodash.cjs
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = function(module) {
|
|
5
|
-
var getter = module && module.__esModule ? function() {
|
|
6
|
-
return module['default'];
|
|
7
|
-
} : function() {
|
|
8
|
-
return module;
|
|
9
|
-
};
|
|
10
|
-
__webpack_require__.d(getter, {
|
|
11
|
-
a: getter
|
|
12
|
-
});
|
|
13
|
-
return getter;
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
3
|
(()=>{
|
|
17
4
|
__webpack_require__.d = function(exports1, definition) {
|
|
18
5
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -39,33 +26,104 @@ var __webpack_require__ = {};
|
|
|
39
26
|
var __webpack_exports__ = {};
|
|
40
27
|
__webpack_require__.r(__webpack_exports__);
|
|
41
28
|
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
-
Lodash: ()
|
|
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
|
+
}
|
|
43
56
|
});
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
57
|
+
const ESCAPE_MAP = {
|
|
58
|
+
'&': '&',
|
|
59
|
+
'<': '<',
|
|
60
|
+
'>': '>',
|
|
61
|
+
'"': '"',
|
|
62
|
+
"'": '''
|
|
63
|
+
};
|
|
64
|
+
const UNESCAPE_MAP = {
|
|
65
|
+
'&': '&',
|
|
66
|
+
'<': '<',
|
|
67
|
+
'>': '>',
|
|
68
|
+
'"': '"',
|
|
69
|
+
''': "'"
|
|
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
|
+
}, {});
|
|
60
118
|
const Lodash = {
|
|
61
|
-
escape
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
set
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
119
|
+
escape,
|
|
120
|
+
unescape,
|
|
121
|
+
toPath,
|
|
122
|
+
get,
|
|
123
|
+
set,
|
|
124
|
+
unset,
|
|
125
|
+
omit,
|
|
126
|
+
pick
|
|
69
127
|
};
|
|
70
128
|
var __webpack_export_target__ = exports;
|
|
71
129
|
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
@@ -1,41 +1,20 @@
|
|
|
1
|
+
import type { ToPath } from 'type-fest/source/get';
|
|
2
|
+
import type { Get, Paths, PickDeep } from 'type-fest';
|
|
3
|
+
export declare const escape: (str: string) => string;
|
|
4
|
+
export declare const unescape: (str: string) => string;
|
|
5
|
+
export declare const toPath: <T extends string>(value: T) => ToPath<T>;
|
|
6
|
+
export declare const get: <T, Path extends string>(obj: T, path: Path, defaultValue?: Get<T, Path>) => any;
|
|
7
|
+
export declare const set: <T, Path extends string>(obj: T, path: Path, value: Get<T, Path>) => T;
|
|
8
|
+
export declare const unset: <T, Path extends string>(obj: T, path: Path) => any;
|
|
9
|
+
export declare const omit: <T extends object, PathArray extends Array<Paths<T> & string>>(obj: T, paths: PathArray) => Omit<T, PathArray[number]>;
|
|
10
|
+
export declare const pick: <T extends object, PathArray extends Array<Paths<T> & string>>(obj: T, paths: PathArray) => PickDeep<T, PathArray[number]>;
|
|
1
11
|
export declare const Lodash: {
|
|
2
|
-
escape: (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1], TKey3 extends keyof TObject[TKey1][TKey2]>(object: TObject, path: [TKey1, TKey2, TKey3]): TObject[TKey1][TKey2][TKey3];
|
|
11
|
-
<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof NonNullable<TObject[TKey1]>, TKey3 extends keyof NonNullable<NonNullable<TObject[TKey1]>[TKey2]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3]): NonNullable<NonNullable<TObject[TKey1]>[TKey2]>[TKey3] | undefined;
|
|
12
|
-
<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof NonNullable<TObject[TKey1]>, TKey3 extends keyof NonNullable<NonNullable<TObject[TKey1]>[TKey2]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3], defaultValue: TDefault): Exclude<NonNullable<NonNullable<TObject[TKey1]>[TKey2]>[TKey3], undefined> | TDefault;
|
|
13
|
-
<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof TObject[TKey1], TKey3 extends keyof TObject[TKey1][TKey2], TKey4 extends keyof TObject[TKey1][TKey2][TKey3]>(object: TObject, path: [TKey1, TKey2, TKey3, TKey4]): TObject[TKey1][TKey2][TKey3][TKey4];
|
|
14
|
-
<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof NonNullable<TObject[TKey1]>, TKey3 extends keyof NonNullable<NonNullable<TObject[TKey1]>[TKey2]>, TKey4 extends keyof NonNullable<NonNullable<NonNullable<TObject[TKey1]>[TKey2]>[TKey3]>>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4]): NonNullable<NonNullable<NonNullable<TObject[TKey1]>[TKey2]>[TKey3]>[TKey4] | undefined;
|
|
15
|
-
<TObject extends object, TKey1 extends keyof TObject, TKey2 extends keyof NonNullable<TObject[TKey1]>, TKey3 extends keyof NonNullable<NonNullable<TObject[TKey1]>[TKey2]>, TKey4 extends keyof NonNullable<NonNullable<NonNullable<TObject[TKey1]>[TKey2]>[TKey3]>, TDefault>(object: TObject | null | undefined, path: [TKey1, TKey2, TKey3, TKey4], defaultValue: TDefault): Exclude<NonNullable<NonNullable<NonNullable<TObject[TKey1]>[TKey2]>[TKey3]>[TKey4], undefined> | TDefault;
|
|
16
|
-
<T>(object: import("lodash").NumericDictionary<T>, path: number): T;
|
|
17
|
-
<T>(object: import("lodash").NumericDictionary<T> | null | undefined, path: number): T | undefined;
|
|
18
|
-
<T, TDefault>(object: import("lodash").NumericDictionary<T> | null | undefined, path: number, defaultValue: TDefault): T | TDefault;
|
|
19
|
-
<TDefault>(object: null | undefined, path: import("lodash").PropertyPath, defaultValue: TDefault): TDefault;
|
|
20
|
-
(object: null | undefined, path: import("lodash").PropertyPath): undefined;
|
|
21
|
-
<TObject, TPath extends string>(data: TObject, path: TPath): string extends TPath ? any : import("lodash").GetFieldType<TObject, TPath>;
|
|
22
|
-
<TObject, TPath extends string, TDefault = import("lodash").GetFieldType<TObject, TPath, "Path">>(data: TObject, path: TPath, defaultValue: TDefault): Exclude<import("lodash").GetFieldType<TObject, TPath>, null | undefined> | TDefault;
|
|
23
|
-
(object: any, path: import("lodash").PropertyPath, defaultValue?: any): any;
|
|
24
|
-
};
|
|
25
|
-
omit: {
|
|
26
|
-
<T extends object, K extends import("lodash").PropertyName[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
|
|
27
|
-
<T extends object, K extends keyof T>(object: T | null | undefined, ...paths: Array<import("lodash").Many<K>>): import("lodash").Omit<T, K>;
|
|
28
|
-
<T extends object>(object: T | null | undefined, ...paths: Array<import("lodash").Many<import("lodash").PropertyName>>): import("lodash").PartialObject<T>;
|
|
29
|
-
};
|
|
30
|
-
pick: {
|
|
31
|
-
<T extends object, U extends keyof T>(object: T, ...props: Array<import("lodash").Many<U>>): Pick<T, U>;
|
|
32
|
-
<T>(object: T | null | undefined, ...props: Array<import("lodash").Many<import("lodash").PropertyPath>>): import("lodash").PartialObject<T>;
|
|
33
|
-
};
|
|
34
|
-
set: {
|
|
35
|
-
<T extends object>(object: T, path: import("lodash").PropertyPath, value: any): T;
|
|
36
|
-
<TResult>(object: object, path: import("lodash").PropertyPath, value: any): TResult;
|
|
37
|
-
};
|
|
38
|
-
toPath: (value: any) => string[];
|
|
39
|
-
unescape: (string?: string) => string;
|
|
40
|
-
unset: (object: any, path: import("lodash").PropertyPath) => boolean;
|
|
12
|
+
escape: (str: string) => string;
|
|
13
|
+
unescape: (str: string) => string;
|
|
14
|
+
toPath: <T extends string>(value: T) => ToPath<T>;
|
|
15
|
+
get: <T, Path extends string>(obj: T, path: Path, defaultValue?: Get<T, Path>) => any;
|
|
16
|
+
set: <T, Path extends string>(obj: T, path: Path, value: Get<T, Path>) => T;
|
|
17
|
+
unset: <T, Path extends string>(obj: T, path: Path) => any;
|
|
18
|
+
omit: <T extends object, PathArray extends Array<Paths<T> & string>>(obj: T, paths: PathArray) => Omit<T, PathArray[number]>;
|
|
19
|
+
pick: <T extends object, PathArray extends Array<Paths<T> & string>>(obj: T, paths: PathArray) => PickDeep<T, PathArray[number]>;
|
|
41
20
|
};
|
package/dist/polyfill/Lodash.js
CHANGED
|
@@ -1,19 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
const ESCAPE_MAP = {
|
|
2
|
+
'&': '&',
|
|
3
|
+
'<': '<',
|
|
4
|
+
'>': '>',
|
|
5
|
+
'"': '"',
|
|
6
|
+
"'": '''
|
|
7
|
+
};
|
|
8
|
+
const UNESCAPE_MAP = {
|
|
9
|
+
'&': '&',
|
|
10
|
+
'<': '<',
|
|
11
|
+
'>': '>',
|
|
12
|
+
'"': '"',
|
|
13
|
+
''': "'"
|
|
14
|
+
};
|
|
15
|
+
const ESCAPE_REGEX = /[&<>"']/g;
|
|
16
|
+
const UNESCAPE_REGEX = /&(amp|lt|gt|quot|#39);/g;
|
|
17
|
+
const Lodash_rslib_entry_escape = (str)=>{
|
|
18
|
+
if (!ESCAPE_REGEX.test(str)) return str;
|
|
19
|
+
ESCAPE_REGEX.lastIndex = 0;
|
|
20
|
+
return str.replace(ESCAPE_REGEX, (match)=>ESCAPE_MAP[match]);
|
|
21
|
+
};
|
|
22
|
+
const Lodash_rslib_entry_unescape = (str)=>{
|
|
23
|
+
if (!UNESCAPE_REGEX.test(str)) return str;
|
|
24
|
+
UNESCAPE_REGEX.lastIndex = 0;
|
|
25
|
+
return str.replace(UNESCAPE_REGEX, (match)=>UNESCAPE_MAP[match]);
|
|
26
|
+
};
|
|
27
|
+
const toPath = (value)=>value.replace(/\[(\d+)\]/g, '.$1').split('.').filter(Boolean);
|
|
28
|
+
const get = (obj, path, defaultValue)=>{
|
|
29
|
+
const getPath = Array.isArray(path) ? path : toPath(path);
|
|
30
|
+
const result = getPath.reduce((previousValue, currentValue)=>Object(previousValue)[currentValue], obj);
|
|
31
|
+
return void 0 === result ? defaultValue : result;
|
|
32
|
+
};
|
|
33
|
+
const set = (obj, path, value)=>{
|
|
34
|
+
const setPath = Array.isArray(path) ? path : toPath(path);
|
|
35
|
+
setPath.slice(0, -1).reduce((prev, key, index)=>{
|
|
36
|
+
if ('object' != typeof prev[key] || null === prev[key]) prev[key] = /^\d+$/.test(setPath[index + 1]) ? [] : {};
|
|
37
|
+
return prev[key];
|
|
38
|
+
}, obj)[setPath[setPath.length - 1]] = value;
|
|
39
|
+
return obj;
|
|
40
|
+
};
|
|
41
|
+
const unset = (obj, path)=>{
|
|
42
|
+
const unsetPath = Array.isArray(path) ? path : toPath(path);
|
|
43
|
+
return unsetPath.reduce((previousValue, currentValue, currentIndex)=>{
|
|
44
|
+
if (currentIndex === path.length - 1) {
|
|
45
|
+
delete previousValue[currentValue];
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return Object(previousValue)[currentValue];
|
|
49
|
+
}, obj);
|
|
50
|
+
};
|
|
51
|
+
const omit = (obj, paths)=>{
|
|
52
|
+
const result = {
|
|
53
|
+
...obj
|
|
54
|
+
};
|
|
55
|
+
paths.forEach((path)=>unset(result, path));
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
const pick = (obj, paths)=>Object.entries(obj).filter(([key])=>paths.includes(key)).reduce((result, [key, value])=>{
|
|
59
|
+
result[key] = value;
|
|
60
|
+
return result;
|
|
61
|
+
}, {});
|
|
9
62
|
const Lodash = {
|
|
10
|
-
escape:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
set
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
export { Lodash };
|
|
63
|
+
escape: Lodash_rslib_entry_escape,
|
|
64
|
+
unescape: Lodash_rslib_entry_unescape,
|
|
65
|
+
toPath,
|
|
66
|
+
get,
|
|
67
|
+
set,
|
|
68
|
+
unset,
|
|
69
|
+
omit,
|
|
70
|
+
pick
|
|
71
|
+
};
|
|
72
|
+
export { Lodash, Lodash_rslib_entry_escape as escape, get, omit, pick, set, toPath, Lodash_rslib_entry_unescape as unescape, unset };
|
|
@@ -17,19 +17,6 @@ function __webpack_require__(moduleId) {
|
|
|
17
17
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
18
|
return module.exports;
|
|
19
19
|
}
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.n = function(module) {
|
|
22
|
-
var getter = module && module.__esModule ? function() {
|
|
23
|
-
return module['default'];
|
|
24
|
-
} : function() {
|
|
25
|
-
return module;
|
|
26
|
-
};
|
|
27
|
-
__webpack_require__.d(getter, {
|
|
28
|
-
a: getter
|
|
29
|
-
});
|
|
30
|
-
return getter;
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
20
|
(()=>{
|
|
34
21
|
__webpack_require__.d = function(exports1, definition) {
|
|
35
22
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -59,12 +46,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
59
46
|
StorageClass: ()=>StorageClass,
|
|
60
47
|
Storage: ()=>Storage
|
|
61
48
|
});
|
|
62
|
-
const
|
|
63
|
-
var unset_default = /*#__PURE__*/ __webpack_require__.n(unset_namespaceObject);
|
|
64
|
-
const set_namespaceObject = require("lodash/set");
|
|
65
|
-
var set_default = /*#__PURE__*/ __webpack_require__.n(set_namespaceObject);
|
|
66
|
-
const get_namespaceObject = require("lodash/get");
|
|
67
|
-
var get_default = /*#__PURE__*/ __webpack_require__.n(get_namespaceObject);
|
|
49
|
+
const external_Lodash_cjs_namespaceObject = require("./Lodash.cjs");
|
|
68
50
|
const app_cjs_namespaceObject = require("../lib/app.cjs");
|
|
69
51
|
function _check_private_redeclaration(obj, privateCollection) {
|
|
70
52
|
if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
@@ -97,7 +79,7 @@ class StorageClass {
|
|
|
97
79
|
if (key) {
|
|
98
80
|
let value = this.getItem(key, {});
|
|
99
81
|
if ('object' != typeof value) value = {};
|
|
100
|
-
keyValue =
|
|
82
|
+
keyValue = (0, external_Lodash_cjs_namespaceObject.get)(value, path);
|
|
101
83
|
try {
|
|
102
84
|
keyValue = JSON.parse(keyValue);
|
|
103
85
|
} catch {}
|
|
@@ -137,7 +119,7 @@ class StorageClass {
|
|
|
137
119
|
if (key) {
|
|
138
120
|
let value = this.getItem(key, {});
|
|
139
121
|
if ('object' != typeof value) value = {};
|
|
140
|
-
|
|
122
|
+
(0, external_Lodash_cjs_namespaceObject.set)(value, path, keyValue);
|
|
141
123
|
return this.setItem(keyName, value);
|
|
142
124
|
}
|
|
143
125
|
} else switch(app_cjs_namespaceObject.$app){
|
|
@@ -166,7 +148,7 @@ class StorageClass {
|
|
|
166
148
|
if (key) {
|
|
167
149
|
let value = this.getItem(key);
|
|
168
150
|
if ('object' != typeof value) value = {};
|
|
169
|
-
|
|
151
|
+
(0, external_Lodash_cjs_namespaceObject.unset)(value, path);
|
|
170
152
|
return this.setItem(key, value);
|
|
171
153
|
}
|
|
172
154
|
} else switch(app_cjs_namespaceObject.$app){
|
package/dist/polyfill/Storage.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs__ from "node:fs";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
3
|
-
import * as
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_lodash_set__ from "lodash/set";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_lodash_get__ from "lodash/get";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__Lodash_js__ from "./Lodash.js";
|
|
6
4
|
import * as __WEBPACK_EXTERNAL_MODULE__lib_app_js__ from "../lib/app.js";
|
|
7
5
|
var __webpack_modules__ = {
|
|
8
6
|
"node:fs": function(module) {
|
|
@@ -53,7 +51,7 @@ class StorageClass {
|
|
|
53
51
|
if (key) {
|
|
54
52
|
let value = this.getItem(key, {});
|
|
55
53
|
if ('object' != typeof value) value = {};
|
|
56
|
-
keyValue = (0,
|
|
54
|
+
keyValue = (0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.get)(value, path);
|
|
57
55
|
try {
|
|
58
56
|
keyValue = JSON.parse(keyValue);
|
|
59
57
|
} catch {}
|
|
@@ -93,7 +91,7 @@ class StorageClass {
|
|
|
93
91
|
if (key) {
|
|
94
92
|
let value = this.getItem(key, {});
|
|
95
93
|
if ('object' != typeof value) value = {};
|
|
96
|
-
(0,
|
|
94
|
+
(0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.set)(value, path, keyValue);
|
|
97
95
|
return this.setItem(keyName, value);
|
|
98
96
|
}
|
|
99
97
|
} else switch(__WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app){
|
|
@@ -122,7 +120,7 @@ class StorageClass {
|
|
|
122
120
|
if (key) {
|
|
123
121
|
let value = this.getItem(key);
|
|
124
122
|
if ('object' != typeof value) value = {};
|
|
125
|
-
(0,
|
|
123
|
+
(0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.unset)(value, path);
|
|
126
124
|
return this.setItem(key, value);
|
|
127
125
|
}
|
|
128
126
|
} else switch(__WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app){
|
package/dist/polyfill/fetch.cjs
CHANGED
|
@@ -17,19 +17,6 @@ function __webpack_require__(moduleId) {
|
|
|
17
17
|
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
18
|
return module.exports;
|
|
19
19
|
}
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.n = function(module) {
|
|
22
|
-
var getter = module && module.__esModule ? function() {
|
|
23
|
-
return module['default'];
|
|
24
|
-
} : function() {
|
|
25
|
-
return module;
|
|
26
|
-
};
|
|
27
|
-
__webpack_require__.d(getter, {
|
|
28
|
-
a: getter
|
|
29
|
-
});
|
|
30
|
-
return getter;
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
20
|
(()=>{
|
|
34
21
|
__webpack_require__.d = function(exports1, definition) {
|
|
35
22
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -58,8 +45,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
58
45
|
__webpack_require__.d(__webpack_exports__, {
|
|
59
46
|
fetch: ()=>fetch_rslib_entry_fetch
|
|
60
47
|
});
|
|
61
|
-
const
|
|
62
|
-
var set_default = /*#__PURE__*/ __webpack_require__.n(set_namespaceObject);
|
|
48
|
+
const external_Lodash_cjs_namespaceObject = require("./Lodash.cjs");
|
|
63
49
|
const app_cjs_namespaceObject = require("../lib/app.cjs");
|
|
64
50
|
const external_StatusTexts_cjs_namespaceObject = require("./StatusTexts.cjs");
|
|
65
51
|
const binaryMimeTypes = [
|
|
@@ -100,8 +86,8 @@ async function fetch_rslib_entry_fetch(resource, options = {
|
|
|
100
86
|
if (params.timeout > 500) params.timeout = Math.round(params.timeout / 1000);
|
|
101
87
|
}
|
|
102
88
|
if ('Quantumult X' === app_cjs_namespaceObject.$app) {
|
|
103
|
-
if (params.policy)
|
|
104
|
-
if ('boolean' == typeof params['auto-redirect'])
|
|
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']);
|
|
105
91
|
if (params.body instanceof ArrayBuffer) {
|
|
106
92
|
params.bodyBytes = params.body;
|
|
107
93
|
params.body = void 0;
|
|
@@ -177,10 +163,10 @@ async function fetch_rslib_entry_fetch(resource, options = {
|
|
|
177
163
|
params.node = params.policy;
|
|
178
164
|
break;
|
|
179
165
|
case 'Stash':
|
|
180
|
-
|
|
166
|
+
(0, external_Lodash_cjs_namespaceObject.set)(params, 'headers.X-Stash-Selected-Proxy', encodeURI(params.policy));
|
|
181
167
|
break;
|
|
182
168
|
case 'Shadowrocket':
|
|
183
|
-
|
|
169
|
+
(0, external_Lodash_cjs_namespaceObject.set)(params, 'headers.X-Surge-Proxy', params.policy);
|
|
184
170
|
break;
|
|
185
171
|
default:
|
|
186
172
|
break;
|
package/dist/polyfill/fetch.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__Lodash_js__ from "./Lodash.js";
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE__lib_app_js__ from "../lib/app.js";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__StatusTexts_js__ from "./StatusTexts.js";
|
|
4
4
|
const binaryMimeTypes = [
|
|
@@ -39,8 +39,8 @@ async function fetch_rslib_entry_fetch(resource, options = {
|
|
|
39
39
|
if (params.timeout > 500) params.timeout = Math.round(params.timeout / 1000);
|
|
40
40
|
}
|
|
41
41
|
if ('Quantumult X' === __WEBPACK_EXTERNAL_MODULE__lib_app_js__.$app) {
|
|
42
|
-
if (params.policy) (0,
|
|
43
|
-
if ('boolean' == typeof params['auto-redirect']) (0,
|
|
42
|
+
if (params.policy) (0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.set)(params, 'opts.policy', params.policy);
|
|
43
|
+
if ('boolean' == typeof params['auto-redirect']) (0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.set)(params, 'opts.redirection', params['auto-redirect']);
|
|
44
44
|
if (params.body instanceof ArrayBuffer) {
|
|
45
45
|
params.bodyBytes = params.body;
|
|
46
46
|
params.body = void 0;
|
|
@@ -116,10 +116,10 @@ async function fetch_rslib_entry_fetch(resource, options = {
|
|
|
116
116
|
params.node = params.policy;
|
|
117
117
|
break;
|
|
118
118
|
case 'Stash':
|
|
119
|
-
(0,
|
|
119
|
+
(0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.set)(params, 'headers.X-Stash-Selected-Proxy', encodeURI(params.policy));
|
|
120
120
|
break;
|
|
121
121
|
case 'Shadowrocket':
|
|
122
|
-
(0,
|
|
122
|
+
(0, __WEBPACK_EXTERNAL_MODULE__Lodash_js__.set)(params, 'headers.X-Surge-Proxy', params.policy);
|
|
123
123
|
break;
|
|
124
124
|
default:
|
|
125
125
|
break;
|
package/package.json
CHANGED
|
@@ -54,12 +54,11 @@
|
|
|
54
54
|
"dist"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"
|
|
57
|
+
"type-fest": "^4.31.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@biomejs/biome": "^1.9.2",
|
|
61
61
|
"@rslib/core": "^0.2.2",
|
|
62
|
-
"@types/lodash": "^4.17.13",
|
|
63
62
|
"@types/node": "^22.10.2",
|
|
64
63
|
"fetch-cookie": "^3.1.0",
|
|
65
64
|
"node-fetch": "^3.3.2",
|
|
@@ -69,5 +68,5 @@
|
|
|
69
68
|
"fetch-cookie": "^3.1.0",
|
|
70
69
|
"node-fetch": "^3.3.2"
|
|
71
70
|
},
|
|
72
|
-
"version": "0.0.0-preview-
|
|
71
|
+
"version": "0.0.0-preview-7be35e5"
|
|
73
72
|
}
|