kipphi 2.1.2 → 2.1.3-beta.2

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/index.d.ts CHANGED
@@ -75,10 +75,25 @@ declare module "chartTypes" {
75
75
  * Sets the Z index for the hit effects of the note. Defaults to 7.
76
76
  */
77
77
  zIndexHitEffects?: number;
78
- /** Sets the tint for the hit effects of the note. Defaults to null. */
78
+ /**
79
+ * Sets the tint for the hit effects of the note. Defaults to null.
80
+ *
81
+ * @alias color
82
+ */
79
83
  tint?: RGB;
84
+ /**
85
+ * @see {@linkcode tint}
86
+ */
87
+ color?: RGB;
80
88
  tintHitEffects?: RGB;
81
- /** Determines the width of the judgment area of the note. Defaults to size. */
89
+ /**
90
+ * Determines the width of the judgment area of the note. Defaults to size.
91
+ * @alias judgeSize
92
+ */
93
+ judgeArea?: number;
94
+ /**
95
+ * @see {@linkcode judgeArea}
96
+ */
82
97
  judgeSize?: number;
83
98
  }
84
99
  export interface NoteDataKPA {
@@ -102,7 +117,11 @@ declare module "chartTypes" {
102
117
  type: NoteType;
103
118
  /** 音符可视时间(打击前多少秒开始显现,默认99999.0) */
104
119
  visibleTime?: number;
105
- /** y值偏移,使音符被打击时的位置偏离判定线 */
120
+ /**
121
+ * y值偏移,使音符被打击时的位置偏离判定线
122
+ *
123
+ * @deprecated 使用{@linkcode absoluteYOffset}代替。
124
+ */
106
125
  yOffset: number;
107
126
  /** Sets the Z index for the object. */
108
127
  zIndex?: number;
@@ -110,10 +129,11 @@ declare module "chartTypes" {
110
129
  * Sets the Z index for the hit effects of the note. Defaults to 7.
111
130
  */
112
131
  zIndexHitEffects?: number;
113
- /** Sets the tint for the hit effects of the note. Defaults to null. */
132
+ /**
133
+ * Sets the tint for the hit effects of the note. Defaults to null.
134
+ */
114
135
  tint?: RGB;
115
136
  tintHitEffects?: RGB;
116
- /** Determines the width of the judgment area of the note. Defaults to size. */
117
137
  judgeSize?: number;
118
138
  visibleBeats?: number;
119
139
  absoluteYOffset: number;
@@ -533,7 +553,7 @@ declare module "chartTypes" {
533
553
  export type ExtendedEventTypeName = "scaleX" | "scaleY" | "text" | "color";
534
554
  }
535
555
  declare module "version" {
536
- export const VERSION = 212;
556
+ export const VERSION = 213;
537
557
  export const SCHEMA = "https://cdn.jsdelivr.net/npm/kipphi@2.1.0/chartType2.schema.json";
538
558
  }
539
559
  declare module "util" {
@@ -684,7 +704,12 @@ declare module "bpm" {
684
704
  /**
685
705
  * BPM序列类,管理BPM变化序列
686
706
  * 拥有与事件类似的逻辑,每对节点之间代表一个BPM相同的片段
687
- * 片段之间BPM可以发生改变
707
+ * 片段之间BPM可以发生改变。
708
+ *
709
+ * @example
710
+ * const bpmList = [{ startTime: [0, 0, 0], bpm: 120 }];
711
+ * const bpmSequence = new BPMSequence(bpmList, 180);
712
+ * // JumpArray 在构造器中自动初始化。
688
713
  */
689
714
  export class BPMSequence extends EventNodeSequence {
690
715
  duration: number;
@@ -707,7 +732,9 @@ declare module "bpm" {
707
732
  */
708
733
  initJump(): void;
709
734
  /**
710
- * 更新秒跳转数组
735
+ * 更新秒跳转数组。
736
+ *
737
+ * 缓存每个节点的秒数发生在这里。
711
738
  */
712
739
  updateSecondJump(): void;
713
740
  /**
@@ -729,14 +756,24 @@ declare module "bpm" {
729
756
  dumpBPM(): BPMSegmentData[];
730
757
  /**
731
758
  * 根据拍数获取节点
759
+ *
732
760
  * @param beats 拍数
733
- * @param usePrev 是否使用前一个节点
761
+ * @param usePrev 是否使用前一个节点。假设有两个BPM片段,0-2拍,2-无穷,`getNodeAt(2, true)` 会返回第一个片段的开始节点
734
762
  * @returns 对应的BPM起始节点
735
763
  */
736
764
  getNodeAt(beats: number, usePrev?: boolean): BPMStartNode;
737
765
  }
738
766
  /**
739
767
  * 时间计算器类,用于处理拍数与秒数之间的转换
768
+ *
769
+ * @example
770
+ * const bpmList = = [
771
+ * { bpm: 120, startTime: [0, 0, 1] }
772
+ * ];
773
+ * const tc = new TimeCalculator();
774
+ * tc.bpmList = bpmList;
775
+ * tc.duration = 131; // 这两者都是必需的。
776
+ * tc.initSequence();
740
777
  */
741
778
  export class TimeCalculator {
742
779
  /** BPM片段数据列表 */
@@ -1197,6 +1234,7 @@ declare module "judgeline" {
1197
1234
  */
1198
1235
  getValues(beats: number, usePrev?: boolean): [x: number, y: number, theta: number, alpha: number];
1199
1236
  getStackedValue(type: keyof EventLayer, beats: number, usePrev?: boolean): number;
1237
+ getStackedValueBySeconds(type: keyof EventLayer, beats: number, seconds: number, timeCalculator: TimeCalculator, usePrev?: boolean): number;
1200
1238
  /**
1201
1239
  * 获取指定时间点的FloorPosition。
1202
1240
  *
@@ -1329,6 +1367,7 @@ declare module "evaluator" {
1329
1367
  import type { EventStartNode, NonLastStartNode } from "event";
1330
1368
  import { EventValueTypeOfType, InterpreteAs, MacroEvaluatorBodyData, MacroEvaluatorDataKPA2, type ColorEasedEvaluatorKPA2, type EvaluatorDataKPA2, type EventValueESType, type ExpressionEvaluatorDataKPA2, type NumericEasedEvaluatorKPA2, type RGB, type TextEasedEvaluatorKPA2 } from "chartTypes";
1331
1369
  import { Chart } from "chart";
1370
+ import { type TimeCalculator } from "bpm";
1332
1371
  /**
1333
1372
  * **求值器**
1334
1373
  *
@@ -1340,12 +1379,14 @@ declare module "evaluator" {
1340
1379
  */
1341
1380
  export abstract class Evaluator<T extends EventValueESType> {
1342
1381
  abstract eval(event: NonLastStartNode<T>, beats: number): T;
1382
+ abstract eval(event: NonLastStartNode<T>, seconds: number, timeCalculator: TimeCalculator): T;
1343
1383
  abstract dumpFor(node: EventStartNode<T>): EvaluatorDataKPA2<T>;
1344
1384
  }
1345
1385
  export abstract class EasedEvaluator<T extends EventValueESType> extends Evaluator<T> {
1346
1386
  readonly easing: Easing;
1347
1387
  constructor(easing: Easing);
1348
1388
  eval(startNode: NonLastStartNode<T>, beats: number): T;
1389
+ eval(startNode: NonLastStartNode<T>, seconds: number, timeCalculator: TimeCalculator): T;
1349
1390
  abstract convert(start: T, end: T, progress: number): T;
1350
1391
  /**
1351
1392
  * 派生一个类型相同但使用不同缓动的求值器
@@ -1397,7 +1438,8 @@ declare module "evaluator" {
1397
1438
  constructor(expression: string, id: string);
1398
1439
  compile(node: EventStartNode<T>, chart: Chart): ExpressionEvaluator<T>;
1399
1440
  assignTo(node: EventStartNode<T>, chart: Chart): void;
1400
- eval(event: NonLastStartNode<T>, beats: number): T;
1441
+ eval(startNode: NonLastStartNode<T>, beats: number): T;
1442
+ eval(startNode: NonLastStartNode<T>, seconds: number, timeCalculator: TimeCalculator): T;
1401
1443
  dumpFor(node: EventStartNode<T>): MacroEvaluatorDataKPA2;
1402
1444
  dumpContent(): MacroEvaluatorBodyData;
1403
1445
  }
@@ -1406,6 +1448,7 @@ declare module "evaluator" {
1406
1448
  readonly func: (t: number) => T;
1407
1449
  constructor(jsExpr: string);
1408
1450
  eval(startNode: NonLastStartNode<T>, beats: number): T;
1451
+ eval(startNode: NonLastStartNode<T>, seconds: number, timeCalculator: TimeCalculator): T;
1409
1452
  dumpFor(): ExpressionEvaluatorDataKPA2;
1410
1453
  }
1411
1454
  }
@@ -1530,6 +1573,8 @@ declare module "easing" {
1530
1573
  dump(): TemplateEasingData;
1531
1574
  get valueDelta(): number;
1532
1575
  get headValue(): number;
1576
+ segmentedValueGetter(easingLeft: number, easingRight: number): (t: number) => number;
1577
+ static checkCircularReference(seq: EventNodeSequence, template: TemplateEasing): boolean;
1533
1578
  }
1534
1579
  export class WrapperEasing extends Easing {
1535
1580
  evaluator: ExpressionEvaluator<number>;
@@ -1652,7 +1697,7 @@ declare module "easing" {
1652
1697
  }
1653
1698
  declare module "chart" {
1654
1699
  import { TimeCalculator } from "bpm";
1655
- import { Easing, TemplateEasingLib } from "easing";
1700
+ import { Easing, SegmentedEasing, TemplateEasing, TemplateEasingLib } from "easing";
1656
1701
  import { EventNodeSequence, EventStartNode, EventEndNode, EventNode } from "event";
1657
1702
  import { JudgeLine } from "judgeline";
1658
1703
  import { NNNList, NNNode } from "note";
@@ -1720,6 +1765,12 @@ declare module "chart" {
1720
1765
  nameAttach: JudgeLine | null;
1721
1766
  /** 难度等级显示绑定的判定线 */
1722
1767
  levelAttach: JudgeLine | null;
1768
+ /** 仅用于构造时检查
1769
+ * @internal
1770
+ */
1771
+ segmentedTemplates: Map<(SegmentedEasing & {
1772
+ easing: TemplateEasing;
1773
+ }), [string, TimeT]>;
1723
1774
  constructor();
1724
1775
  /**
1725
1776
  * 获取有效节拍数
@@ -1853,6 +1904,11 @@ declare module "chart" {
1853
1904
  bindTimeMacro(node: EventStartNode<any>, macroData: MacroData, pos: string): any;
1854
1905
  bindValueMacro(node: EventNode<any>, macroData: MacroData, pos: string): any;
1855
1906
  linkMacro(node: EventNode<EventValueESType>, linkData: MacroLink, pos: string): any;
1907
+ checkErrors(): void;
1908
+ /**
1909
+ * 用于构造谱面时检查
1910
+ */
1911
+ protected checkSegmentedTemplates(): void;
1856
1912
  }
1857
1913
  /**
1858
1914
  * 表示一组判定线的容器
@@ -2023,6 +2079,7 @@ declare module "event" {
2023
2079
  */
2024
2080
  dump(): EventDataKPA2<VT>;
2025
2081
  dumpAsFinal(): FinalEventStartNodeDataKPA2<VT>;
2082
+ getValueAt(seconds: number, timeCalculator: TimeCalculator): VT;
2026
2083
  getValueAt(beats: number): VT;
2027
2084
  getSpeedValueAt(this: EventStartNode<number>, beats: number): number;
2028
2085
  /**
@@ -2154,6 +2211,7 @@ declare module "event" {
2154
2211
  updateJump(from: ENOrHead<VT>, to: ENOrTail<VT>): void;
2155
2212
  getNodeAt(beats: number, usePrev?: boolean): EventStartNode<VT>;
2156
2213
  getValueAt(beats: number, usePrev?: boolean): VT;
2214
+ getValueAtBySecs(beats: number, seconds: number, timeCalculator: TimeCalculator, usePrev?: boolean): VT;
2157
2215
  getFloorPositionAt(this: EventNodeSequence<number>, beats: number, timeCalculator: TimeCalculator): number;
2158
2216
  /**
2159
2217
  * 更新某个速度节点之后的FP
@@ -2182,6 +2240,7 @@ declare module "event" {
2182
2240
  */
2183
2241
  static mergeSequences(sequences: EventNodeSequence[]): EventNodeSequence<number>;
2184
2242
  checkErrors(): void;
2243
+ hasReferenceTo(this: EventNodeSequence<number>, seq: EventNodeSequence<number>): boolean;
2185
2244
  }
2186
2245
  export type SpeedENS = EventNodeSequence<number> & {
2187
2246
  type: EventType.speed;
@@ -2213,6 +2272,8 @@ declare module "env" {
2213
2272
  NODES_NOT_CONTINUOUS = 2609,
2214
2273
  NODES_NOT_BELONG_TO_SAME_SEQUENCE = 2610,
2215
2274
  NODES_HAS_ZERO_DELTA = 2611,
2275
+ TEMPLATE_EASING_CIRCULAR_REFERENCE = 2612,
2276
+ EASING_DELTA_CANNOT_BE_ZERO = 2613,
2216
2277
  CANNOT_DIVIDE_EXPRESSION_EVALUATOR = 2352,
2217
2278
  MISSING_MACRO_EVALUATOR_KEY = 2336,
2218
2279
  MACRO_EVALUATOR_NOT_FOUND = 2337,
@@ -2263,6 +2324,8 @@ declare module "env" {
2263
2324
  MACRO_NOT_PARAMETRIC: (macroId: string, pos: any) => string;
2264
2325
  EVENT_NODE_NOT_DENSE: (pos: string) => string;
2265
2326
  HOLD_HAS_NO_DURATION: () => string;
2327
+ TEMPLATE_EASING_CIRCULAR_REFERENCE: (temEasName: string) => string;
2328
+ EASING_DELTA_CANNOT_BE_ZERO: (seqName: string, time: TimeT) => string;
2266
2329
  };
2267
2330
  interface ErrorMap extends Record<keyof typeof ERROR_IDS, Array<any>> {
2268
2331
  EVENT_NODE_NOT_DENSE: [EventNode];
@@ -2328,6 +2391,8 @@ declare module "env" {
2328
2391
  MACRO_NOT_PARAMETRIC: (macroId: string, pos: any) => KPAError<ERROR_IDS.MACRO_NOT_PARAMETRIC>;
2329
2392
  EVENT_NODE_NOT_DENSE: (pos: string) => KPAError<ERROR_IDS.EVENT_NODE_NOT_DENSE>;
2330
2393
  HOLD_HAS_NO_DURATION: () => KPAError<ERROR_IDS.HOLD_HAS_NO_DURATION>;
2394
+ TEMPLATE_EASING_CIRCULAR_REFERENCE: (temEasName: string) => KPAError<ERROR_IDS.TEMPLATE_EASING_CIRCULAR_REFERENCE>;
2395
+ EASING_DELTA_CANNOT_BE_ZERO: (seqName: string, time: TimeT) => KPAError<ERROR_IDS.EASING_DELTA_CANNOT_BE_ZERO>;
2331
2396
  };
2332
2397
  freeze(): void;
2333
2398
  };
@@ -3027,6 +3092,7 @@ declare module "rpeChartCompiler" {
3027
3092
  chart: Chart;
3028
3093
  sequenceMap: Map<EventNodeSequence<any>, EventNodeSequence<any>>;
3029
3094
  interpolationStep: TimeT;
3095
+ deletesEmptyLines: boolean;
3030
3096
  constructor(chart: Chart);
3031
3097
  compileChart(): ChartDataRPE;
3032
3098
  compileJudgeLine(judgeLine: JudgeLine): JudgeLineDataRPE;