Skip to content

4.5.19#929

Merged
MakinoharaShoko merged 47 commits intomainfrom
dev
Apr 11, 2026
Merged

4.5.19#929
MakinoharaShoko merged 47 commits intomainfrom
dev

Conversation

@MakinoharaShoko
Copy link
Copy Markdown
Member

No description provided.

xiaoxustudio and others added 30 commits January 3, 2026 18:20
- 新增 webgal-engine.json 引擎描述文件,包含引擎元数据
- 新增 update-engine-version.js 脚本,自动同步版本号
- 修改构建流程,在构建前自动更新引擎描述文件版本
- 为第三方工具提供标准化的引擎识别和版本管理支持
fix: remove animation before set effect
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying webgal-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9df6af2
Status: ✅  Deploy successful!
Preview URL: https://a71da497.webgal-dev.pages.dev

View logs

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the WebGAL engine to version 4.5.19, introducing significant UI refinements, improved iOS/Safari support, and a refactored Service Worker for better asset caching. New features include regex validation for user input, Spine skin support, and additional visual filters. The code review identifies opportunities to improve event handling by using addEventListener instead of onkeydown, optimize animation removal logic to avoid O(n^2) complexity, and prevent potential string replacement bugs in user input dialogs by using a function-based replacement in replaceAll.

Comment on lines +310 to +316
document.onkeydown = (e) => {
if (e && e.key === 'F11') {
setTimeout(() => {
scheduleResize();
}, 100);
}
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Assigning to document.onkeydown overwrites any existing keydown handlers. It is generally better practice to use addEventListener to allow multiple listeners to coexist without interference.

Suggested change
document.onkeydown = (e) => {
if (e && e.key === 'F11') {
setTimeout(() => {
scheduleResize();
}, 100);
}
};
document.addEventListener('keydown', (e) => {
if (e && e.key === 'F11') {
setTimeout(() => {
scheduleResize();
}, 100);
}
});

Comment on lines +306 to +312
public removeAnimationByTargetKey(targetKey: string) {
let index = this.stageAnimations.findIndex((e) => e.targetKey === targetKey);
while (index !== -1) {
this.removeAnimationByIndex(index);
index = this.stageAnimations.findIndex((e) => e.targetKey === targetKey);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current implementation of removeAnimationByTargetKey is inefficient because it repeatedly calls findIndex from the start of the array within a while loop, resulting in $O(n^2)$ complexity. Iterating backwards through the array once is a more efficient and standard way to remove multiple elements while ensuring all necessary cleanup (via removeAnimationByIndex) is performed.

Suggested change
public removeAnimationByTargetKey(targetKey: string) {
let index = this.stageAnimations.findIndex((e) => e.targetKey === targetKey);
while (index !== -1) {
this.removeAnimationByIndex(index);
index = this.stageAnimations.findIndex((e) => e.targetKey === targetKey);
}
}
public removeAnimationByTargetKey(targetKey: string) {
for (let i = this.stageAnimations.length - 1; i >= 0; i--) {
if (this.stageAnimations[i].targetKey === targetKey) {
this.removeAnimationByIndex(i);
}
}
}

if (reg && !reg.test(userInput.value)) {
if (ruleText)
showGlogalDialog({
title: ruleText.replaceAll(/\$0/g, userInput.value),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using a string as the second argument to replaceAll can lead to unexpected behavior if the user input contains special replacement patterns (e.g., $&, $$, $1). For example, if a user enters $&, it might result in the literal $0 being inserted instead of the user's actual input. Using a function as the second argument ensures the input is treated as a literal string.

Suggested change
title: ruleText.replaceAll(/\$0/g, userInput.value),
title: ruleText.replaceAll(/\$0/g, () => userInput.value),

@MakinoharaShoko MakinoharaShoko merged commit dd35587 into main Apr 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants