Skip to content

Commit 95a62f1

Browse files
Merge branch 'dev' into pr/915
2 parents 34fba0d + 5e902ea commit 95a62f1

118 files changed

Lines changed: 2304 additions & 779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ WebGAL 是一款开源软件,因此你可以免费在 MPL-2.0 开源协议的
6464

6565
[赞助本项目](https://docs.openwebgal.com/sponsor/)
6666

67+
## WebGAL 相关项目
68+
69+
- [webgal-craft](https://github.com/A-kirami/webgal-craft): 社区开发中的 WebGAL 可视化编辑器。
70+
- [Webgal_transformEditor](https://github.com/KonshinHaoshin/Webgal_transformEditor): 用于可视化编辑 `setTransform``changeFigure` 的运镜脚本工具。
71+
- [webgal-language-tools](https://github.com/xiaoxustudio/webgal-language-tools): 基于 Volar.js 的 WebGAL 语言工具链,提供 LSP、VS Code 扩展和 Monaco 支持。
72+
- [webgal-tool-l2dw](https://github.com/LostWaym/webgal-tool-l2dw): 面向 WebGAL 的 Live2D 工具,可调整模型与动作并导出相关指令。
73+
- [webgal-mygo](https://github.com/boomwwww/webgal-mygo): 面向 MyGO 项目的 WebGAL 专版引擎维护分支。
74+
6775
# Sponsors
6876

6977
<a href="https://openwebgal.com/">

README_EN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ Even so, your sponsorship can provide motivation for the developers to move forw
6262

6363
[Sponsor this project](https://docs.openwebgal.com/en/sponsor/)
6464

65+
## Related Projects
66+
67+
- [webgal-craft](https://github.com/A-kirami/webgal-craft): A community WIP visual editor for WebGAL.
68+
- [Webgal_transformEditor](https://github.com/KonshinHaoshin/Webgal_transformEditor): A visual editor for `setTransform` and `changeFigure` scene scripting.
69+
- [webgal-language-tools](https://github.com/xiaoxustudio/webgal-language-tools): Volar.js-based language tools for WebGAL, with LSP, VS Code extension, and Monaco support.
70+
- [webgal-tool-l2dw](https://github.com/LostWaym/webgal-tool-l2dw): A Live2D utility for WebGAL to adjust models and motions and export related commands.
71+
- [webgal-mygo](https://github.com/boomwwww/webgal-mygo): A MyGO-specific maintenance fork of the WebGAL engine.
72+
6573
# Sponsors
6674

6775
<a href="https://openwebgal.com/">

README_JP.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ WebGAL はオープンソース ソフトウェアであるため、MPL-2.0 オ
5555

5656
[このプロジェクトのスポンサー](https://docs.openwebgal.com/ja/sponsor/)
5757

58+
## WebGAL 関連プロジェクト
59+
60+
- [webgal-craft](https://github.com/A-kirami/webgal-craft): コミュニティ開発中の WebGAL 向けビジュアルエディターです。
61+
- [Webgal_transformEditor](https://github.com/KonshinHaoshin/Webgal_transformEditor): `setTransform``changeFigure` を視覚的に編集できるツールです。
62+
- [webgal-language-tools](https://github.com/xiaoxustudio/webgal-language-tools): Volar.js ベースの WebGAL 言語ツール群で、LSP、VS Code 拡張、Monaco に対応しています。
63+
- [webgal-tool-l2dw](https://github.com/LostWaym/webgal-tool-l2dw): Live2D モデルやモーションを調整し、WebGAL 向け命令を出力できるツールです。
64+
- [webgal-mygo](https://github.com/boomwwww/webgal-mygo): MyGO 向けに保守されている WebGAL 専用エンジンのフォークです。
65+
5866
# Sponsors
5967

6068
<a href="https://openwebgal.com/">

packages/parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"dependencies": {
2121
"chevrotain": "^10.5.0",
2222
"cloudlogjs": "^1.0.11",
23-
"lodash": "^4.17.21",
23+
"lodash": "^4.17.23",
2424
"tsx": "^3.12.7"
2525
},
2626
"devDependencies": {

packages/parser/src/sceneParser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ export const sceneParser = (
3838
let assetsList: Array<IAsset> = []; // 场景资源列表
3939
let subSceneList: Array<string> = []; // 子场景列表
4040
const sentenceList: Array<ISentence> = rawSentenceListWithoutEmpty.map(
41-
(sentence) => {
41+
(sentence, index) => {
4242
const returnSentence: ISentence = scriptParser(
4343
sentence,
4444
assetSetter,
4545
ADD_NEXT_ARG_LIST,
4646
SCRIPT_CONFIG_MAP,
47+
index,
4748
);
4849
// 在这里解析出语句可能携带的资源和场景,合并到 assetsList 和 subSceneList
4950
assetsList = [...assetsList, ...returnSentence.sentenceAssets];

packages/parser/src/scriptParser/assetsScanner.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const assetsScanner = (
1212
command: commandType,
1313
content: string,
1414
args: Array<arg>,
15+
lineNumber: number,
1516
): Array<IAsset> => {
1617
let hasVocalArg = false;
1718
const returnAssetsList: Array<IAsset> = [];
@@ -22,7 +23,7 @@ export const assetsScanner = (
2223
returnAssetsList.push({
2324
name: e.value as string,
2425
url: e.value as string,
25-
lineNumber: 0,
26+
lineNumber,
2627
type: fileType.vocal,
2728
});
2829
}
@@ -36,39 +37,39 @@ export const assetsScanner = (
3637
returnAssetsList.push({
3738
name: content,
3839
url: content,
39-
lineNumber: 0,
40+
lineNumber,
4041
type: fileType.background,
4142
});
4243
}
4344
if (command === commandType.changeFigure) {
4445
returnAssetsList.push({
4546
name: content,
4647
url: content,
47-
lineNumber: 0,
48+
lineNumber,
4849
type: fileType.figure,
4950
});
5051
}
5152
if (command === commandType.miniAvatar) {
5253
returnAssetsList.push({
5354
name: content,
5455
url: content,
55-
lineNumber: 0,
56+
lineNumber,
5657
type: fileType.figure,
5758
});
5859
}
5960
if (command === commandType.video) {
6061
returnAssetsList.push({
6162
name: content,
6263
url: content,
63-
lineNumber: 0,
64+
lineNumber,
6465
type: fileType.video,
6566
});
6667
}
6768
if (command === commandType.bgm) {
6869
returnAssetsList.push({
6970
name: content,
7071
url: content,
71-
lineNumber: 0,
72+
lineNumber,
7273
type: fileType.bgm,
7374
});
7475
}

packages/parser/src/scriptParser/scriptParser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const scriptParser = (
2424
assetSetter: any,
2525
ADD_NEXT_ARG_LIST: commandType[],
2626
SCRIPT_CONFIG_MAP: ConfigMap,
27+
lineNumber = 0,
2728
): ISentence => {
2829
let command: commandType; // 默认为对话
2930
let content: string; // 语句内容
@@ -105,7 +106,7 @@ export const scriptParser = (
105106
}
106107

107108
content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
108-
sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
109+
sentenceAssets = assetsScanner(command, content, args, lineNumber); // 扫描语句携带资源
109110
subScene = subSceneScanner(command, content); // 扫描语句携带子场景
110111
return {
111112
command: command, // 语句类型

packages/parser/test/parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test("args", async () => {
4949
{ key: "left", value: true },
5050
{ key: "next", value: true }
5151
],
52-
sentenceAssets: [{ name: "m2.png", url: 'm2.png', type: fileType.figure, lineNumber: 0 }],
52+
sentenceAssets: [{ name: "m2.png", url: 'm2.png', type: fileType.figure, lineNumber: 24 }],
5353
subScene: [],
5454
inlineComment: ""
5555
};

packages/webgal/index.html

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,68 @@
320320
<script>
321321
(() => {
322322
const isIOS = window.__WEBGAL_DEVICE_INFO__?.isIOS ?? false;
323-
if ('serviceWorker' in navigator && !isIOS) {
324-
navigator.serviceWorker
325-
.register('./webgal-serviceworker.js')
326-
.then((reg) => {
327-
console.log('Registration succeeded. Scope is ' + reg.scope);
328-
})
329-
.catch((error) => {
330-
console.log('Registration failed with ' + error);
331-
});
323+
const localHostnames = ['localhost', '127.0.0.1', '::1'];
324+
const isLocalPreview = localHostnames.includes(window.location.hostname) || window.location.protocol === 'file:';
325+
const isElectron = Boolean(window.electronFuncs) || /Electron/i.test(navigator.userAgent || '');
326+
const shouldBypassServiceWorker = isIOS || isLocalPreview || isElectron;
327+
const webgalServiceWorkerUrl = new URL('./webgal-serviceworker.js', window.location.href).href;
328+
const bypassReloadKey = 'webgal-sw-bypass-reloaded';
329+
const isWebGALRegistration = (registration) => {
330+
const workers = [registration.active, registration.installing, registration.waiting];
331+
return workers.some((worker) => worker?.scriptURL === webgalServiceWorkerUrl);
332+
};
333+
const markBypassReload = () => {
334+
try {
335+
if (sessionStorage.getItem(bypassReloadKey) === 'true') {
336+
return false;
337+
}
338+
sessionStorage.setItem(bypassReloadKey, 'true');
339+
return true;
340+
} catch {
341+
return false;
342+
}
343+
};
344+
const clearBypassReloadMark = () => {
345+
try {
346+
sessionStorage.removeItem(bypassReloadKey);
347+
} catch {}
348+
};
349+
const clearWebGALServiceWorker = async () => {
350+
try {
351+
const registrations = await navigator.serviceWorker.getRegistrations();
352+
const webgalRegistrations = registrations.filter(isWebGALRegistration);
353+
const hasWebGALController = navigator.serviceWorker.controller?.scriptURL === webgalServiceWorkerUrl;
354+
await Promise.all(webgalRegistrations.map((registration) => registration.unregister()));
355+
if ('caches' in window) {
356+
const cacheKeys = await caches.keys();
357+
await Promise.all(cacheKeys.filter((key) => key.startsWith('webgal-')).map((key) => caches.delete(key)));
358+
}
359+
if ((webgalRegistrations.length > 0 || hasWebGALController) && navigator.serviceWorker.controller && markBypassReload()) {
360+
window.location.reload();
361+
}
362+
} catch (error) {
363+
console.warn('Failed to clear WebGAL Service Worker cache', error);
364+
}
365+
};
366+
if (!('serviceWorker' in navigator)) {
367+
return;
368+
}
369+
if (shouldBypassServiceWorker) {
370+
clearWebGALServiceWorker();
371+
return;
332372
}
373+
if (!window.isSecureContext) {
374+
return;
375+
}
376+
clearBypassReloadMark();
377+
navigator.serviceWorker
378+
.register('./webgal-serviceworker.js')
379+
.then((reg) => {
380+
console.log('Registration succeeded. Scope is ' + reg.scope);
381+
})
382+
.catch((error) => {
383+
console.log('Registration failed with ' + error);
384+
});
333385
})();
334386
</script>
335387
<!-- 首屏加载 -->

packages/webgal/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "webgal-engine",
3-
"version": "4.5.18",
3+
"version": "4.5.19",
44
"scripts": {
55
"dev": "vite --host --port 3000",
6-
"build": "cross-env NODE_ENV=production tsc && vite build --base=./",
6+
"build": "node scripts/update-engine-version.js && cross-env NODE_ENV=production tsc && vite build --base=./",
77
"preview": "vite preview",
88
"lint": "eslint src/** --fix",
99
"prepublishOnly": "npm run build"
@@ -13,12 +13,12 @@
1313
"@icon-park/react": "^1.4.2",
1414
"@reduxjs/toolkit": "^1.8.1",
1515
"angular-expressions": "^1.4.3",
16-
"axios": "^0.30.2",
16+
"axios": "^1.13.5",
1717
"cloudlogjs": "^1.0.9",
1818
"gifuct-js": "^2.1.2",
1919
"i18next": "^22.4.15",
2020
"localforage": "^1.10.0",
21-
"lodash": "^4.17.21",
21+
"lodash": "^4.17.23",
2222
"mitt": "^3.0.0",
2323
"modern-css-reset": "^1.4.0",
2424
"pixi-filters": "^4.2.0",
@@ -39,11 +39,11 @@
3939
"@types/react": "^17.0.33",
4040
"@types/react-dom": "^17.0.10",
4141
"@types/uuid": "^8.3.4",
42-
"@typescript-eslint/eslint-plugin": "^5.18.0",
43-
"@typescript-eslint/parser": "^5.18.0",
42+
"@typescript-eslint/eslint-plugin": "^8.0.0",
43+
"@typescript-eslint/parser": "^8.0.0",
4444
"@vitejs/plugin-react": "^4.0.4",
4545
"cross-env": "^7.0.3",
46-
"eslint": "^8.13.0",
46+
"eslint": "^9.26.0",
4747
"eslint-config-alloy": "^4.5.1",
4848
"eslint-config-prettier": "^8.5.0",
4949
"eslint-plugin-prettier": "^4.2.1",
@@ -53,7 +53,7 @@
5353
"rollup-plugin-visualizer": "^5.6.0",
5454
"typescript": "^4.5.4",
5555
"unplugin-info": "^1.2.2",
56-
"vite": "^4.5.5",
56+
"vite": "^5.4.21",
5757
"vite-plugin-compression": "^0.5.1"
5858
}
5959
}

0 commit comments

Comments
 (0)