@nsnanocat/util 0.0.0-preview-2c5e49e
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/LICENSE +201 -0
- package/README.md +1 -0
- package/dist/env.d.cjs +6 -0
- package/dist/env.d.js +0 -0
- package/dist/getStorage.cjs +110 -0
- package/dist/getStorage.d.ts +8 -0
- package/dist/getStorage.js +62 -0
- package/dist/index.cjs +155 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/lib/app.cjs +48 -0
- package/dist/lib/app.d.ts +4 -0
- package/dist/lib/app.js +12 -0
- package/dist/lib/done.cjs +125 -0
- package/dist/lib/done.d.ts +17 -0
- package/dist/lib/done.js +76 -0
- package/dist/lib/environment.cjs +70 -0
- package/dist/lib/environment.d.ts +8 -0
- package/dist/lib/environment.js +36 -0
- package/dist/lib/index.cjs +101 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.js +5 -0
- package/dist/lib/notification.cjs +135 -0
- package/dist/lib/notification.d.ts +20 -0
- package/dist/lib/notification.js +101 -0
- package/dist/lib/runScript.cjs +67 -0
- package/dist/lib/runScript.d.ts +3 -0
- package/dist/lib/runScript.js +33 -0
- package/dist/lib/time.cjs +54 -0
- package/dist/lib/time.d.ts +13 -0
- package/dist/lib/time.js +18 -0
- package/dist/lib/wait.cjs +40 -0
- package/dist/lib/wait.d.ts +4 -0
- package/dist/lib/wait.js +4 -0
- package/dist/polyfill/Console.cjs +250 -0
- package/dist/polyfill/Console.d.ts +21 -0
- package/dist/polyfill/Console.js +216 -0
- package/dist/polyfill/Lodash.cjs +74 -0
- package/dist/polyfill/Lodash.d.ts +41 -0
- package/dist/polyfill/Lodash.js +19 -0
- package/dist/polyfill/StatusTexts.cjs +99 -0
- package/dist/polyfill/StatusTexts.d.ts +62 -0
- package/dist/polyfill/StatusTexts.js +63 -0
- package/dist/polyfill/Storage.cjs +221 -0
- package/dist/polyfill/Storage.d.ts +12 -0
- package/dist/polyfill/Storage.js +173 -0
- package/dist/polyfill/fetch.cjs +214 -0
- package/dist/polyfill/fetch.d.ts +25 -0
- package/dist/polyfill/fetch.js +149 -0
- package/dist/polyfill/index.cjs +101 -0
- package/dist/polyfill/index.d.ts +5 -0
- package/dist/polyfill/index.js +5 -0
- package/package.json +73 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = function(obj, prop) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.r = function(exports1) {
|
|
31
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __webpack_exports__ = {};
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
done: ()=>done
|
|
43
|
+
});
|
|
44
|
+
const set_namespaceObject = require("lodash/set");
|
|
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);
|
|
48
|
+
const Console_cjs_namespaceObject = require("../polyfill/Console.cjs");
|
|
49
|
+
const StatusTexts_cjs_namespaceObject = require("../polyfill/StatusTexts.cjs");
|
|
50
|
+
const external_app_cjs_namespaceObject = require("./app.cjs");
|
|
51
|
+
const transformQuantumultXBody = (object)=>{
|
|
52
|
+
if (object.body instanceof ArrayBuffer) return {
|
|
53
|
+
bodyBytes: object.body,
|
|
54
|
+
body: void 0
|
|
55
|
+
};
|
|
56
|
+
if (ArrayBuffer.isView(object.body)) return {
|
|
57
|
+
bodyBytes: object.body.buffer.slice(object.body.byteOffset, object.body.byteOffset + object.body.byteLength),
|
|
58
|
+
body: void 0
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
bodyBytes: void 0
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
const transformQuantumultXStatus = (object)=>{
|
|
65
|
+
if ('number' == typeof object.status) return {
|
|
66
|
+
status: `HTTP/1.1 ${object.status} ${StatusTexts_cjs_namespaceObject.StatusTexts[object.status]}`
|
|
67
|
+
};
|
|
68
|
+
if ('string' != typeof object.status && void 0 !== object.status) throw new TypeError(`${done.name}: εζ°η±»ειθ――, status εΏ
ι‘»δΈΊζ°εζε符串`);
|
|
69
|
+
return {};
|
|
70
|
+
};
|
|
71
|
+
const handleDoneFactory = (startTime)=>(result)=>{
|
|
72
|
+
Console_cjs_namespaceObject.Console.log('π© ζ§θ‘η»ζ!', startTime ? `π ${((Date.now() - startTime) / 1000).toFixed(3)} η§` : void 0);
|
|
73
|
+
$done(result);
|
|
74
|
+
};
|
|
75
|
+
function done(object = {}) {
|
|
76
|
+
let startTime = null == $script ? void 0 : $script.startTime;
|
|
77
|
+
if ('Surge' === external_app_cjs_namespaceObject.$app) startTime *= 1000;
|
|
78
|
+
const handleDone = handleDoneFactory(startTime);
|
|
79
|
+
switch(external_app_cjs_namespaceObject.$app){
|
|
80
|
+
case 'Surge':
|
|
81
|
+
if (object.policy) set_default()(object, 'headers.X-Surge-Policy', object.policy);
|
|
82
|
+
handleDone(object);
|
|
83
|
+
break;
|
|
84
|
+
case 'Loon':
|
|
85
|
+
if (object.policy) object.node = object.policy;
|
|
86
|
+
handleDone(object);
|
|
87
|
+
break;
|
|
88
|
+
case 'Stash':
|
|
89
|
+
if (object.policy) set_default()(object, 'headers.X-Stash-Selected-Proxy', encodeURI(object.policy));
|
|
90
|
+
handleDone(object);
|
|
91
|
+
break;
|
|
92
|
+
case 'Egern':
|
|
93
|
+
handleDone(object);
|
|
94
|
+
break;
|
|
95
|
+
case 'Shadowrocket':
|
|
96
|
+
handleDone(object);
|
|
97
|
+
break;
|
|
98
|
+
case 'Quantumult X':
|
|
99
|
+
{
|
|
100
|
+
const transformedObject = {
|
|
101
|
+
...pick_default()(object, [
|
|
102
|
+
'status',
|
|
103
|
+
'url',
|
|
104
|
+
'headers',
|
|
105
|
+
'body',
|
|
106
|
+
'bodyBytes'
|
|
107
|
+
]),
|
|
108
|
+
...transformQuantumultXStatus(object),
|
|
109
|
+
...transformQuantumultXBody(object)
|
|
110
|
+
};
|
|
111
|
+
if (object.policy) set_default()(transformedObject, 'opts.policy', object.policy);
|
|
112
|
+
handleDone(transformedObject);
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
case 'Node.js':
|
|
116
|
+
default:
|
|
117
|
+
Console_cjs_namespaceObject.Console.log('π© ζ§θ‘η»ζ!');
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var __webpack_export_target__ = exports;
|
|
122
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
123
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
124
|
+
value: true
|
|
125
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface DoneObject {
|
|
2
|
+
status?: number | string;
|
|
3
|
+
url?: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
body?: ArrayBuffer | ArrayBufferView | string;
|
|
6
|
+
bodyBytes?: ArrayBuffer;
|
|
7
|
+
policy?: string;
|
|
8
|
+
node?: string;
|
|
9
|
+
opts?: {
|
|
10
|
+
policy?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Complete the script execution
|
|
15
|
+
*/
|
|
16
|
+
export declare function done(object?: DoneObject): void;
|
|
17
|
+
export {};
|
package/dist/lib/done.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash_set__ from "lodash/set";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_lodash_pick__ from "lodash/pick";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_Console_js__ from "../polyfill/Console.js";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE__polyfill_StatusTexts_js__ from "../polyfill/StatusTexts.js";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__app_js__ from "./app.js";
|
|
6
|
+
const transformQuantumultXBody = (object)=>{
|
|
7
|
+
if (object.body instanceof ArrayBuffer) return {
|
|
8
|
+
bodyBytes: object.body,
|
|
9
|
+
body: void 0
|
|
10
|
+
};
|
|
11
|
+
if (ArrayBuffer.isView(object.body)) return {
|
|
12
|
+
bodyBytes: object.body.buffer.slice(object.body.byteOffset, object.body.byteOffset + object.body.byteLength),
|
|
13
|
+
body: void 0
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
bodyBytes: void 0
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
const transformQuantumultXStatus = (object)=>{
|
|
20
|
+
if ('number' == typeof object.status) return {
|
|
21
|
+
status: `HTTP/1.1 ${object.status} ${__WEBPACK_EXTERNAL_MODULE__polyfill_StatusTexts_js__.StatusTexts[object.status]}`
|
|
22
|
+
};
|
|
23
|
+
if ('string' != typeof object.status && void 0 !== object.status) throw new TypeError(`${done.name}: εζ°η±»ειθ――, status εΏ
ι‘»δΈΊζ°εζε符串`);
|
|
24
|
+
return {};
|
|
25
|
+
};
|
|
26
|
+
const handleDoneFactory = (startTime)=>(result)=>{
|
|
27
|
+
__WEBPACK_EXTERNAL_MODULE__polyfill_Console_js__.Console.log('π© ζ§θ‘η»ζ!', startTime ? `π ${((Date.now() - startTime) / 1000).toFixed(3)} η§` : void 0);
|
|
28
|
+
$done(result);
|
|
29
|
+
};
|
|
30
|
+
function done(object = {}) {
|
|
31
|
+
let startTime = null == $script ? void 0 : $script.startTime;
|
|
32
|
+
if ('Surge' === __WEBPACK_EXTERNAL_MODULE__app_js__.$app) startTime *= 1000;
|
|
33
|
+
const handleDone = handleDoneFactory(startTime);
|
|
34
|
+
switch(__WEBPACK_EXTERNAL_MODULE__app_js__.$app){
|
|
35
|
+
case 'Surge':
|
|
36
|
+
if (object.policy) (0, __WEBPACK_EXTERNAL_MODULE_lodash_set__["default"])(object, 'headers.X-Surge-Policy', object.policy);
|
|
37
|
+
handleDone(object);
|
|
38
|
+
break;
|
|
39
|
+
case 'Loon':
|
|
40
|
+
if (object.policy) object.node = object.policy;
|
|
41
|
+
handleDone(object);
|
|
42
|
+
break;
|
|
43
|
+
case 'Stash':
|
|
44
|
+
if (object.policy) (0, __WEBPACK_EXTERNAL_MODULE_lodash_set__["default"])(object, 'headers.X-Stash-Selected-Proxy', encodeURI(object.policy));
|
|
45
|
+
handleDone(object);
|
|
46
|
+
break;
|
|
47
|
+
case 'Egern':
|
|
48
|
+
handleDone(object);
|
|
49
|
+
break;
|
|
50
|
+
case 'Shadowrocket':
|
|
51
|
+
handleDone(object);
|
|
52
|
+
break;
|
|
53
|
+
case 'Quantumult X':
|
|
54
|
+
{
|
|
55
|
+
const transformedObject = {
|
|
56
|
+
...(0, __WEBPACK_EXTERNAL_MODULE_lodash_pick__["default"])(object, [
|
|
57
|
+
'status',
|
|
58
|
+
'url',
|
|
59
|
+
'headers',
|
|
60
|
+
'body',
|
|
61
|
+
'bodyBytes'
|
|
62
|
+
]),
|
|
63
|
+
...transformQuantumultXStatus(object),
|
|
64
|
+
...transformQuantumultXBody(object)
|
|
65
|
+
};
|
|
66
|
+
if (object.policy) (0, __WEBPACK_EXTERNAL_MODULE_lodash_set__["default"])(transformedObject, 'opts.policy', object.policy);
|
|
67
|
+
handleDone(transformedObject);
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 'Node.js':
|
|
71
|
+
default:
|
|
72
|
+
__WEBPACK_EXTERNAL_MODULE__polyfill_Console_js__.Console.log('π© ζ§θ‘η»ζ!');
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export { done };
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
environment: ()=>environment_rslib_entry_environment
|
|
30
|
+
});
|
|
31
|
+
const external_app_cjs_namespaceObject = require("./app.cjs");
|
|
32
|
+
function environment_rslib_entry_environment() {
|
|
33
|
+
switch(external_app_cjs_namespaceObject.$app){
|
|
34
|
+
case 'Surge':
|
|
35
|
+
$environment.app = 'Surge';
|
|
36
|
+
return $environment;
|
|
37
|
+
case 'Stash':
|
|
38
|
+
$environment.app = 'Stash';
|
|
39
|
+
return $environment;
|
|
40
|
+
case 'Egern':
|
|
41
|
+
$environment.app = 'Egern';
|
|
42
|
+
return $environment;
|
|
43
|
+
case 'Loon':
|
|
44
|
+
{
|
|
45
|
+
const environment = $loon.split(' ');
|
|
46
|
+
return {
|
|
47
|
+
device: environment[0],
|
|
48
|
+
ios: environment[1],
|
|
49
|
+
'loon-version': environment[2],
|
|
50
|
+
app: 'Loon'
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
case 'Quantumult X':
|
|
54
|
+
return {
|
|
55
|
+
app: 'Quantumult X'
|
|
56
|
+
};
|
|
57
|
+
case 'Node.js':
|
|
58
|
+
return {
|
|
59
|
+
...process.env,
|
|
60
|
+
app: 'Node.js'
|
|
61
|
+
};
|
|
62
|
+
default:
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
var __webpack_export_target__ = exports;
|
|
67
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
68
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
69
|
+
value: true
|
|
70
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__app_js__ from "./app.js";
|
|
2
|
+
function environment_rslib_entry_environment() {
|
|
3
|
+
switch(__WEBPACK_EXTERNAL_MODULE__app_js__.$app){
|
|
4
|
+
case 'Surge':
|
|
5
|
+
$environment.app = 'Surge';
|
|
6
|
+
return $environment;
|
|
7
|
+
case 'Stash':
|
|
8
|
+
$environment.app = 'Stash';
|
|
9
|
+
return $environment;
|
|
10
|
+
case 'Egern':
|
|
11
|
+
$environment.app = 'Egern';
|
|
12
|
+
return $environment;
|
|
13
|
+
case 'Loon':
|
|
14
|
+
{
|
|
15
|
+
const environment = $loon.split(' ');
|
|
16
|
+
return {
|
|
17
|
+
device: environment[0],
|
|
18
|
+
ios: environment[1],
|
|
19
|
+
'loon-version': environment[2],
|
|
20
|
+
app: 'Loon'
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
case 'Quantumult X':
|
|
24
|
+
return {
|
|
25
|
+
app: 'Quantumult X'
|
|
26
|
+
};
|
|
27
|
+
case 'Node.js':
|
|
28
|
+
return {
|
|
29
|
+
...process.env,
|
|
30
|
+
app: 'Node.js'
|
|
31
|
+
};
|
|
32
|
+
default:
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export { environment_rslib_entry_environment as environment };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./app.js": function(module) {
|
|
4
|
+
module.exports = require("./app.cjs");
|
|
5
|
+
},
|
|
6
|
+
"./done": function(module) {
|
|
7
|
+
module.exports = require("./done.cjs");
|
|
8
|
+
},
|
|
9
|
+
"./notification": function(module) {
|
|
10
|
+
module.exports = require("./notification.cjs");
|
|
11
|
+
},
|
|
12
|
+
"./time": function(module) {
|
|
13
|
+
module.exports = require("./time.cjs");
|
|
14
|
+
},
|
|
15
|
+
"./wait": function(module) {
|
|
16
|
+
module.exports = require("./wait.cjs");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var __webpack_module_cache__ = {};
|
|
20
|
+
function __webpack_require__(moduleId) {
|
|
21
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
22
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
23
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
24
|
+
exports: {}
|
|
25
|
+
};
|
|
26
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
27
|
+
return module.exports;
|
|
28
|
+
}
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.n = function(module) {
|
|
31
|
+
var getter = module && module.__esModule ? function() {
|
|
32
|
+
return module['default'];
|
|
33
|
+
} : function() {
|
|
34
|
+
return module;
|
|
35
|
+
};
|
|
36
|
+
__webpack_require__.d(getter, {
|
|
37
|
+
a: getter
|
|
38
|
+
});
|
|
39
|
+
return getter;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
(()=>{
|
|
43
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
44
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: definition[key]
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
(()=>{
|
|
51
|
+
__webpack_require__.o = function(obj, prop) {
|
|
52
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
55
|
+
(()=>{
|
|
56
|
+
__webpack_require__.r = function(exports1) {
|
|
57
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
58
|
+
value: 'Module'
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
61
|
+
value: true
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
})();
|
|
65
|
+
var __webpack_exports__ = {};
|
|
66
|
+
__webpack_require__.r(__webpack_exports__);
|
|
67
|
+
var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./app.js");
|
|
68
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
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
|
+
return _app__WEBPACK_IMPORTED_MODULE_0__[key];
|
|
71
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
72
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
73
|
+
var _done__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./done");
|
|
74
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
75
|
+
for(var __WEBPACK_IMPORT_KEY__ in _done__WEBPACK_IMPORTED_MODULE_1__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
76
|
+
return _done__WEBPACK_IMPORTED_MODULE_1__[key];
|
|
77
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
78
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
79
|
+
var _notification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./notification");
|
|
80
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
81
|
+
for(var __WEBPACK_IMPORT_KEY__ in _notification__WEBPACK_IMPORTED_MODULE_2__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
82
|
+
return _notification__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
83
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
84
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
85
|
+
var _time__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./time");
|
|
86
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
87
|
+
for(var __WEBPACK_IMPORT_KEY__ in _time__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
88
|
+
return _time__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
89
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
90
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
91
|
+
var _wait__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./wait");
|
|
92
|
+
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
93
|
+
for(var __WEBPACK_IMPORT_KEY__ in _wait__WEBPACK_IMPORTED_MODULE_4__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
94
|
+
return _wait__WEBPACK_IMPORTED_MODULE_4__[key];
|
|
95
|
+
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
96
|
+
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
97
|
+
var __webpack_export_target__ = exports;
|
|
98
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
99
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
100
|
+
value: true
|
|
101
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface NotificationContent {
|
|
2
|
+
open?: string;
|
|
3
|
+
'open-url'?: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
openUrl?: string;
|
|
6
|
+
copy?: string;
|
|
7
|
+
'update-pasteboard'?: string;
|
|
8
|
+
updatePasteboard?: string;
|
|
9
|
+
media?: string;
|
|
10
|
+
'media-url'?: string;
|
|
11
|
+
mediaUrl?: string;
|
|
12
|
+
'auto-dismiss'?: boolean;
|
|
13
|
+
sound?: string;
|
|
14
|
+
mime?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* η³»η»ιη₯
|
|
18
|
+
*/
|
|
19
|
+
export declare function notification(title?: string, subtitle?: string, body?: string, content?: string | number | boolean | NotificationContent): void;
|
|
20
|
+
export {};
|