diff --git a/package.json b/package.json index 58abc33..ea458e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sim-phi/extends", - "version": "0.3.2", + "version": "0.3.3", "description": "Third-party chart format conversion functions for sim-phi.", "type": "module", "main": "dist/index.js", @@ -30,13 +30,13 @@ "@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-terser": "^0.4.4", - "@stylistic/eslint-plugin": "^1.4.1", - "@typescript-eslint/eslint-plugin": "^6.12.0", - "eslint": "^8.54.0", + "@stylistic/eslint-plugin": "^1.5.4", + "@typescript-eslint/eslint-plugin": "^6.19.0", + "eslint": "^8.56.0", "eslint-plugin-rulesdir": "^0.2.2", - "typescript": "^5.3.2", - "vite": "^5.0.2", - "vite-plugin-dts": "^3.6.3" + "typescript": "^5.3.3", + "vite": "^5.0.12", + "vite-plugin-dts": "^3.7.1" }, "files": [ "dist" diff --git a/src/pec/rpe2json.ts b/src/pec/rpe2json.ts index 2bc5f50..c4495ac 100644 --- a/src/pec/rpe2json.ts +++ b/src/pec/rpe2json.ts @@ -595,41 +595,42 @@ export function parse(pec: string, filename: string): { lineRPE.pushNote(type, time, positionX, holdTime, speed, note.above === 1, note.isFake !== 0, note.alpha === 0); } } - for (const e of i.eventLayers) { - if (!e) continue; // 有可能是null + for (const evts of i.eventLayers) { + if (!evts) continue; // 有可能是null const layer = new EventLayer1(); - for (const j of e.moveXEvents || []) { - const startTime = bpmList.calc2(j.startTime); - const endTime = bpmList.calc2(j.endTime); - const { fn, code } = getEasingFn(j, startTime, endTime); - getWarning(code, j); - layer.pushMoveXEvent(startTime, endTime, j.start, j.end, fn); + for (const evt of evts.moveXEvents || []) { + const startTime = bpmList.calc2(evt.startTime); + const endTime = bpmList.calc2(evt.endTime); + const { fn, code } = getEasingFn(evt, startTime, endTime); + getEasingWarning(code, evt); + layer.pushMoveXEvent(startTime, endTime, evt.start, evt.end, fn); } - for (const j of e.moveYEvents || []) { - const startTime = bpmList.calc2(j.startTime); - const endTime = bpmList.calc2(j.endTime); - const { fn, code } = getEasingFn(j, startTime, endTime); - getWarning(code, j); - layer.pushMoveYEvent(startTime, endTime, j.start, j.end, fn); + for (const evt of evts.moveYEvents || []) { + const startTime = bpmList.calc2(evt.startTime); + const endTime = bpmList.calc2(evt.endTime); + const { fn, code } = getEasingFn(evt, startTime, endTime); + getEasingWarning(code, evt); + layer.pushMoveYEvent(startTime, endTime, evt.start, evt.end, fn); } - for (const j of e.rotateEvents || []) { - const startTime = bpmList.calc2(j.startTime); - const endTime = bpmList.calc2(j.endTime); - const { fn, code } = getEasingFn(j, startTime, endTime); - getWarning(code, j); - layer.pushRotateEvent(startTime, endTime, j.start, j.end, fn); + for (const evt of evts.rotateEvents || []) { + const startTime = bpmList.calc2(evt.startTime); + const endTime = bpmList.calc2(evt.endTime); + const { fn, code } = getEasingFn(evt, startTime, endTime); + getEasingWarning(code, evt); + layer.pushRotateEvent(startTime, endTime, evt.start, evt.end, fn); } - for (const j of e.alphaEvents || []) { - const startTime = bpmList.calc2(j.startTime); - const endTime = bpmList.calc2(j.endTime); - const { fn, code } = getEasingFn(j, startTime, endTime); - getWarning(code, j); - layer.pushAlphaEvent(startTime, endTime, j.start, j.end, fn); + for (const evt of evts.alphaEvents || []) { + const startTime = bpmList.calc2(evt.startTime); + const endTime = bpmList.calc2(evt.endTime); + const { fn, code } = getEasingFn(evt, startTime, endTime); + if (evt.start < 0 || evt.end < 0) warn(1, 'LineAlphaWarning', `检测到负数alpha(将被视为0)\n位于:"${JSON.stringify(evt)}"`); + getEasingWarning(code, evt); + layer.pushAlphaEvent(startTime, endTime, evt.start, evt.end, fn); } - for (const j of e.speedEvents || []) { - const startTime = bpmList.calc2(j.startTime); - const endTime = bpmList.calc2(j.endTime); - layer.pushSpeedEvent(startTime, endTime, j.start, j.end); + for (const evt of evts.speedEvents || []) { + const startTime = bpmList.calc2(evt.startTime); + const endTime = bpmList.calc2(evt.endTime); + layer.pushSpeedEvent(startTime, endTime, evt.start, evt.end); } lineRPE.eventLayers.push(layer); } @@ -647,7 +648,7 @@ export function parse(pec: string, filename: string): { result.numOfNotes! += judgeLine.numOfNotes; } return { data: result, messages: warnings, info, line, format }; - function getWarning(code: EasingCode, le: LineEventRPE) { + function getEasingWarning(code: EasingCode, le: LineEventRPE) { if (code === EasingCode.TypeNotSupported) warn(1, 'EasingTypeWarning', `未知的缓动类型:${le.easingType}(将被视为1)\n位于:"${JSON.stringify(le)}"`); if (code === EasingCode.LeftEqualsRight) warn(1, 'EasingClipWarning', `检测到easingLeft等于easingRight(将被视为线性)\n位于:"${JSON.stringify(le)}"`); if (code === EasingCode.ValueNotFinite) warn(1, 'EasingClipWarning', `非法的缓动函数(将被视为线性)\n位于:"${JSON.stringify(le)}"`); diff --git a/tools/eslint-config.cjs b/tools/eslint-config.cjs index 8572dce..f9d167e 100644 --- a/tools/eslint-config.cjs +++ b/tools/eslint-config.cjs @@ -25,7 +25,7 @@ module.exports = { '@stylistic/multiline-ternary': ['error', 'never'], '@stylistic/newline-per-chained-call': 'off', // qwq '@stylistic/no-confusing-arrow': 'off', // qwq - '@stylistic/no-extra-parens': ['error', 'all', { enforceForSequenceExpressions: false }], + '@stylistic/no-extra-parens': ['error', 'all'], '@stylistic/no-mixed-operators': 'off', // qwq '@stylistic/no-multiple-empty-lines': ['error', { max: 0 }], '@stylistic/object-curly-spacing': ['error', 'always'],