@nsnanocat/util 2.6.9 → 2.6.11
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/lib/environment.mjs +6 -6
- package/lib/notification.mjs +1 -2
- package/package.json +1 -1
- package/polyfill/Console.d.ts +2 -2
- package/polyfill/Console.mjs +7 -10
package/lib/environment.mjs
CHANGED
|
@@ -28,14 +28,14 @@ export const $environment = environment();
|
|
|
28
28
|
export function environment() {
|
|
29
29
|
switch ($app) {
|
|
30
30
|
case "Surge":
|
|
31
|
-
|
|
32
|
-
return
|
|
31
|
+
globalThis.$environment.app = "Surge";
|
|
32
|
+
return globalThis.$environment;
|
|
33
33
|
case "Stash":
|
|
34
|
-
|
|
35
|
-
return
|
|
34
|
+
globalThis.$environment.app = "Stash";
|
|
35
|
+
return globalThis.$environment;
|
|
36
36
|
case "Egern":
|
|
37
|
-
|
|
38
|
-
return
|
|
37
|
+
globalThis.$environment.app = "Egern";
|
|
38
|
+
return globalThis.$environment;
|
|
39
39
|
case "Loon": {
|
|
40
40
|
const environment = $loon.split(" ");
|
|
41
41
|
return {
|
package/lib/notification.mjs
CHANGED
|
@@ -42,7 +42,6 @@ import { $app } from "./app.mjs";
|
|
|
42
42
|
*/
|
|
43
43
|
export function notification(title = `ℹ️ ${$app} 通知`, subtitle = "", body = "", content = {}) {
|
|
44
44
|
const mutableContent = MutableContent(content);
|
|
45
|
-
const bodyLines = body.split(/\r?\n/u);
|
|
46
45
|
switch ($app) {
|
|
47
46
|
case "Surge":
|
|
48
47
|
case "Loon":
|
|
@@ -60,7 +59,7 @@ export function notification(title = `ℹ️ ${$app} 通知`, subtitle = "", bod
|
|
|
60
59
|
break;
|
|
61
60
|
}
|
|
62
61
|
Console.group("📣 系统通知");
|
|
63
|
-
Console.log(title, subtitle,
|
|
62
|
+
Console.log(title, subtitle, body, JSON.stringify(mutableContent, null, 2));
|
|
64
63
|
Console.groupEnd();
|
|
65
64
|
}
|
|
66
65
|
|
package/package.json
CHANGED
package/polyfill/Console.d.ts
CHANGED
|
@@ -94,8 +94,8 @@ export class Console {
|
|
|
94
94
|
*
|
|
95
95
|
* 说明:
|
|
96
96
|
* Notes:
|
|
97
|
-
* -
|
|
98
|
-
* -
|
|
97
|
+
* - 多行字符串参数会按换行拆分为多个独立日志项。
|
|
98
|
+
* - Multi-line string arguments are split into multiple log entries by line breaks.
|
|
99
99
|
*
|
|
100
100
|
* @param msg 日志内容 / Log payloads.
|
|
101
101
|
*/
|
package/polyfill/Console.mjs
CHANGED
|
@@ -226,31 +226,28 @@ export class Console {
|
|
|
226
226
|
*
|
|
227
227
|
* 说明:
|
|
228
228
|
* Notes:
|
|
229
|
-
* -
|
|
230
|
-
* -
|
|
229
|
+
* - 多行字符串参数会按换行拆分为多个独立日志项。
|
|
230
|
+
* - Multi-line string arguments are split into multiple log entries by line breaks.
|
|
231
231
|
*
|
|
232
232
|
* @param {...any} msg 日志内容 / Log messages.
|
|
233
233
|
* @returns {void}
|
|
234
234
|
*/
|
|
235
235
|
static log = (...msg) => {
|
|
236
236
|
if (Console.#level === 0) return;
|
|
237
|
-
msg = msg.flatMap(log =>
|
|
238
|
-
msg = msg.map(log => {
|
|
237
|
+
msg = msg.flatMap(log => {
|
|
239
238
|
switch (typeof log) {
|
|
240
239
|
case "object":
|
|
241
|
-
|
|
242
|
-
break;
|
|
240
|
+
return [JSON.stringify(log)];
|
|
243
241
|
case "bigint":
|
|
244
242
|
case "number":
|
|
245
243
|
case "boolean":
|
|
244
|
+
return [log.toString()];
|
|
246
245
|
case "string":
|
|
247
|
-
|
|
248
|
-
break;
|
|
246
|
+
return log.split(/\r?\n/u);
|
|
249
247
|
case "undefined":
|
|
250
248
|
default:
|
|
251
|
-
|
|
249
|
+
return [log];
|
|
252
250
|
}
|
|
253
|
-
return log;
|
|
254
251
|
});
|
|
255
252
|
Console.#groups.forEach(group => {
|
|
256
253
|
msg = msg.map(log => ` ${log}`);
|