Skip to content

Commit 50cfd75

Browse files
committed
feat: $app & Console
Update boxjs.settings.json Update CHANGELOG.md Update setCaptions.mjs Update response.dev.js Update request.dev.js Update database.mjs Update response.js Update request.js
1 parent 7462fb4 commit 50cfd75

16 files changed

+773
-764
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "src/utils"]
2-
path = src/utils
3-
url = https://github.com/NanoCat-Me/utils.git
41
[submodule "src/protobuf"]
52
path = src/protobuf
63
url = https://github.com/DualSubs/protobuf.git

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
### 🛠️ Bug Fixes
2-
* 修复 `Surge` 模块内置`参数面板`
3-
* 修复 `Loon` 插件内置`设置面板`
42
* 修复 `$argument``$persistentStore` 载入顺序颠倒的问题
53
* 正确顺序为先读取 `$argument` 再读取 `$persistentStore (BoxJs)`
64
* 即,有相同键名时,`$persistentStore (BoxJs)` 的值会覆盖 `$argument` 的值
7-
### 🔄 Other Changes
8-
* util 由 `submodule` 更改为 `package`
5+
6+
### 🔣 Dependencies
7+
* 升级了 `@nsnanocat/url`
8+
* 使用了全新的 `URL``URLSearchParams` polyfill
9+
* 升级了 `@nsnanocat/util`
10+
* `util``submodule` 更改为 `package`
11+
* `$platform` 改为 `$app`
12+
* 使用了全新的 `Console` polyfill

arguments-builder.config.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ export default defineConfig({
3232
},
3333
},
3434
args: [
35-
{
36-
key: "Switch",
37-
name: "总功能开关",
38-
defaultValue: true,
39-
type: "boolean",
40-
description: "是否启用此APP修改",
41-
exclude: ["surge", "loon"],
42-
},
4335
{
4436
key: "Type",
4537
name: "[字幕] 启用类型",

biome.json

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"files": {
4+
"ignore": [
5+
"**/*.bundle.js"
6+
],
7+
"ignoreUnknown": false
8+
},
9+
"formatter": {
10+
"enabled": true,
11+
"indentStyle": "tab",
12+
"indentWidth": 2,
13+
"lineEnding": "lf",
14+
"lineWidth": 320
15+
},
16+
"javascript": {
17+
"formatter": {
18+
"arrowParentheses": "asNeeded",
19+
"bracketSameLine": true,
20+
"quoteStyle": "double"
21+
}
22+
},
23+
"json": {
24+
"parser": {
25+
"allowComments": true,
26+
"allowTrailingCommas": true
27+
}
28+
},
29+
"linter": {
30+
"enabled": true,
31+
"rules": {
32+
"complexity": {
33+
"noForEach": "off",
34+
"noStaticOnlyClass": "off",
35+
"noUselessSwitchCase": "off",
36+
"useArrowFunction": "info",
37+
"useFlatMap": "off",
38+
"useLiteralKeys": "info"
39+
},
40+
"correctness": {
41+
"noInnerDeclarations": "info",
42+
"noSelfAssign": "off",
43+
"noSwitchDeclarations": "info",
44+
"noUnsafeOptionalChaining": "info"
45+
},
46+
"performance": {
47+
"noDelete": "info"
48+
},
49+
"recommended": true,
50+
"style": {
51+
"noNegationElse": "off",
52+
"noParameterAssign": "off",
53+
"noUselessElse": "off",
54+
"noVar": "info",
55+
"useDefaultParameterLast": "info",
56+
"useForOf": "error",
57+
"useNodejsImportProtocol": "error",
58+
"useNumberNamespace": "error",
59+
"useSingleVarDeclarator": "off"
60+
},
61+
"suspicious": {
62+
"noAssignInExpressions": "info",
63+
"noDoubleEquals": "info",
64+
"noFallthroughSwitchClause": "info",
65+
"noGlobalIsNan": "off",
66+
"useDefaultSwitchClauseLast": "off"
67+
}
68+
}
69+
},
70+
"organizeImports": {
71+
"enabled": true
72+
},
73+
"vcs": {
74+
"clientKind": "git",
75+
"enabled": true,
76+
"useIgnoreFile": true
77+
}
78+
}

rspack.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export default defineConfig({
1515
new NodePolyfillPlugin({
1616
//additionalAliases: ['console'],
1717
}),
18+
new rspack.BannerPlugin({
19+
banner: `console.log('Date: ${new Date().toLocaleString("zh-CN", { timeZone: "PRC" })}');`,
20+
raw: true,
21+
}),
1822
new rspack.BannerPlugin({
1923
banner: `console.log('Version: ${pkg.version}');`,
2024
raw: true,
@@ -24,13 +28,14 @@ export default defineConfig({
2428
raw: true,
2529
}),
2630
new rspack.BannerPlugin({
27-
banner: "console.log('🍿️ DualSubs: ▶️ YouTube');",
31+
banner: `console.log('${pkg.displayName}');`,
2832
raw: true,
2933
}),
3034
new rspack.BannerPlugin({
31-
banner: "https://DualSubs.github.io",
35+
banner: pkg.homepage,
3236
}),
3337
],
38+
devtool: false,
3439
performance: false,
3540
module: {
3641
rules: [

rspack.dev.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ export default defineConfig({
1515
new NodePolyfillPlugin({
1616
//additionalAliases: ['console'],
1717
}),
18+
new rspack.BannerPlugin({
19+
banner: `console.log('Date: ${new Date().toLocaleString("zh-CN", { timeZone: "PRC" })}');`,
20+
raw: true,
21+
}),
1822
new rspack.BannerPlugin({
1923
banner: `console.log('Version: ${pkg.version}');`,
2024
raw: true,
@@ -24,13 +28,14 @@ export default defineConfig({
2428
raw: true,
2529
}),
2630
new rspack.BannerPlugin({
27-
banner: "console.log('🍿️ DualSubs: ▶️ YouTube β');",
31+
banner: `console.log('${pkg.displayName}');`,
2832
raw: true,
2933
}),
3034
new rspack.BannerPlugin({
31-
banner: "https://DualSubs.github.io",
35+
banner: pkg.homepage,
3236
}),
3337
],
38+
devtool: false,
3439
performance: false,
3540
module: {
3641
rules: [

src/function/database.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export default {
22
Default: {
33
Settings: {
4-
Switch: true,
54
Type: "Translate",
65
Types: ["Official", "Translate"],
76
Languages: ["EN", "ZH"],
@@ -20,7 +19,6 @@ export default {
2019
},
2120
YouTube: {
2221
Settings: {
23-
Switch: true,
2422
Type: "Official",
2523
Types: ["Translate", "External"],
2624
Languages: ["AUTO", "ZH"],

src/function/setCache.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { log } from "@nsnanocat/util";
1+
import { Console } from "@nsnanocat/util";
2+
23
/**
34
* Set Cache
45
* @author VirgilClyne
@@ -7,9 +8,9 @@ import { log } from "@nsnanocat/util";
78
* @return {Boolean} isSaved
89
*/
910
export default function setCache(cache, cacheSize = 100) {
10-
log(`☑️ Set Cache, cacheSize: ${cacheSize}`, "");
11+
Console.log("☑️ Set Cache", `cacheSize: ${cacheSize}`);
1112
cache = Array.from(cache || []); // Map转Array
1213
cache = cache.slice(-cacheSize); // 限制缓存大小
13-
log(`✅ Set Cache`, "");
14+
Console.log("✅ Set Cache");
1415
return cache;
1516
};

src/function/setCaptions.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { log } from "@nsnanocat/util";
1+
import { Console } from "@nsnanocat/util";
22

3-
export default function setCaptions(captions, translationLanguages) {
4-
log(`☑️ Set Captions`);
3+
export default function setCaptions(captions, translationLanguages, hostname) {
4+
Console.log("☑️ Set Captions");
55
// 有播放器字幕列表渲染器
6-
if (captions?.playerCaptionsTracklistRenderer) {
7-
log(`⚠ Tracklist`);
6+
if (captions?.playerCaptionsTracklistRenderer) { // 有播放器字幕列表渲染器
7+
Console.info("Tracklist");
88
if (captions?.playerCaptionsTracklistRenderer?.captionTracks) {
99
// 改字幕可用性
1010
captions.playerCaptionsTracklistRenderer.captionTracks = captions?.playerCaptionsTracklistRenderer.captionTracks.map(caption => {
@@ -22,7 +22,7 @@ export default function setCaptions(captions, translationLanguages) {
2222
});
2323
};
2424
// 增加自动翻译可用语言
25-
switch (HOST) {
25+
switch (hostname) {
2626
case "www.youtube.com":
2727
case "tv.youtube.com":
2828
default:
@@ -38,6 +38,6 @@ export default function setCaptions(captions, translationLanguages) {
3838
captions.playerCaptionsTracklistRenderer.defaultCaptionTrackIndex = 0;
3939
};
4040
};
41-
log(`✅ Set Captions, `);
41+
Console.log("✅ Set Captions");
4242
return captions;
4343
};

src/function/setENV.mjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getStorage, Lodash as _, log } from "@nsnanocat/util";
1+
import { Console, getStorage, Lodash as _ } from "@nsnanocat/util";
22

33
/**
44
* Set Environment Variables
@@ -10,19 +10,20 @@ import { getStorage, Lodash as _, log } from "@nsnanocat/util";
1010
* @return {Object} { Settings, Caches, Configs }
1111
*/
1212
export default function setENV(name, platforms, database) {
13-
log(`☑️ Set Environment Variables`, "");
14-
let { Settings, Caches, Configs } = getStorage(name, platforms, database);
13+
Console.log("☑️ Set Environment Variables");
14+
const { Settings, Caches, Configs } = getStorage(name, platforms, database);
1515
/***************** Settings *****************/
1616
if (!Array.isArray(Settings?.Types)) Settings.Types = (Settings.Types) ? [Settings.Types] : []; // 只有一个选项时,无逗号分隔
17-
log(`✅ Set Environment Variables, Settings: ${typeof Settings}, Settings内容: ${JSON.stringify(Settings)}`, "");
17+
Console.debug(`typeof Settings: ${typeof Settings}`, `Settings: ${JSON.stringify(Settings)}`);
1818
/***************** Caches *****************/
19-
//log(`✅ Set Environment Variables, Caches: ${typeof Caches}, Caches内容: ${JSON.stringify(Caches)}`, "");
19+
//Console.debug(`typeof Caches: ${typeof Caches}`, `Caches: ${JSON.stringify(Caches)}`);
2020
if (typeof Caches?.Playlists !== "object" || Array.isArray(Caches?.Playlists)) Caches.Playlists = {}; // 创建Playlists缓存
2121
Caches.Playlists.Master = new Map(JSON.parse(Caches?.Playlists?.Master || "[]")); // Strings转Array转Map
2222
Caches.Playlists.Subtitle = new Map(JSON.parse(Caches?.Playlists?.Subtitle || "[]")); // Strings转Array转Map
2323
if (typeof Caches?.Subtitles !== "object") Caches.Subtitles = new Map(JSON.parse(Caches?.Subtitles || "[]")); // Strings转Array转Map
2424
if (typeof Caches?.Metadatas !== "object" || Array.isArray(Caches?.Metadatas)) Caches.Metadatas = {}; // 创建Playlists缓存
2525
if (typeof Caches?.Metadatas?.Tracks !== "object") Caches.Metadatas.Tracks = new Map(JSON.parse(Caches?.Metadatas?.Tracks || "[]")); // Strings转Array转Map
2626
/***************** Configs *****************/
27+
Console.log("✅ Set Environment Variables");
2728
return { Settings, Caches, Configs };
2829
};

0 commit comments

Comments
 (0)