@drincs/pixi-vn-json 1.12.0 → 1.13.0

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.
@@ -2,16 +2,35 @@ import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps,
2
2
  import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
3
3
  import { UPDATE_PRIORITY } from 'pixi.js';
4
4
 
5
+ /**
6
+ * A single element that can appear inside a step-switch, which may be a direct value,
7
+ * a conditional statement, or a result-to-combine.
8
+ */
5
9
  type PixiVNJsonStepSwitchElementType<Then> = Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>;
10
+ /**
11
+ * The elements collection of a step-switch — either a plain array or a conditional that produces an array.
12
+ */
6
13
  type PixiVNJsonStepSwitchElementsType<Then> = PixiVNJsonStepSwitchElementType<Then>[] | PixiVNJsonConditionalStatements<Then[]>;
14
+ /**
15
+ * Picks one element at random each time the step is visited.
16
+ */
7
17
  interface PixiVNJsonRandom<Then> {
8
18
  type: "stepswitch";
9
19
  choiceType: "random";
20
+ /**
21
+ * The pool of elements to choose from randomly.
22
+ */
10
23
  elements: PixiVNJsonStepSwitchElementsType<Then>;
11
24
  }
25
+ /**
26
+ * Picks elements in a random order, advancing through the list across visits (no repeats until exhausted).
27
+ */
12
28
  interface PixiVNJsonSequentialRandom<Then> {
13
29
  type: "stepswitch";
14
30
  choiceType: "sequentialrandom";
31
+ /**
32
+ * The pool of elements to iterate through in randomised order.
33
+ */
15
34
  elements: PixiVNJsonStepSwitchElementsType<Then>;
16
35
  /**
17
36
  * When the sequential ends, what should be the value? If undefined, it will return undefined.
@@ -19,13 +38,19 @@ interface PixiVNJsonSequentialRandom<Then> {
19
38
  */
20
39
  end: undefined | "lastItem";
21
40
  /**
22
- * The subId is used for manager nested switches
41
+ * The subId is used for managing nested switches
23
42
  */
24
43
  nestedId?: string;
25
44
  }
45
+ /**
46
+ * Advances through the elements list one by one on each visit (in order).
47
+ */
26
48
  interface PixiVNJsonSequential<Then> {
27
49
  type: "stepswitch";
28
50
  choiceType: "sequential";
51
+ /**
52
+ * The ordered list of elements to iterate through.
53
+ */
29
54
  elements: PixiVNJsonStepSwitchElementsType<Then>;
30
55
  /**
31
56
  * When the sequential ends, what should be the value? If undefined, it will return undefined.
@@ -33,16 +58,28 @@ interface PixiVNJsonSequential<Then> {
33
58
  */
34
59
  end: undefined | "lastItem";
35
60
  /**
36
- * The subId is used for manager nested switches
61
+ * The subId is used for managing nested switches
37
62
  */
38
63
  nestedId?: string;
39
64
  }
65
+ /**
66
+ * Loops through the elements list indefinitely, cycling back to the first element after the last.
67
+ */
40
68
  interface PixiVNJsonLoop<Then> {
41
69
  type: "stepswitch";
42
70
  choiceType: "loop";
71
+ /**
72
+ * The list of elements to cycle through.
73
+ */
43
74
  elements: PixiVNJsonStepSwitchElementsType<Then>;
75
+ /**
76
+ * The subId is used for managing nested switches
77
+ */
44
78
  nestedId?: string;
45
79
  }
80
+ /**
81
+ * A step-switch selects one element from a list using a defined strategy (random, sequential, loop, or sequential-random).
82
+ */
46
83
  type PixiVNJsonStepSwitch<Then> = PixiVNJsonRandom<Then> | PixiVNJsonSequential<Then> | PixiVNJsonLoop<Then> | PixiVNJsonSequentialRandom<Then>;
47
84
 
48
85
  /**
@@ -52,15 +89,33 @@ type PixiVNJsonStepSwitch<Then> = PixiVNJsonRandom<Then> | PixiVNJsonSequential<
52
89
  type PixiVNJsonConditionalResultToCombine<T> = {
53
90
  type: "resulttocombine";
54
91
  /**
55
- * This variable is interpreted differently by Pixi'VN depending on the value
92
+ * Defines how the two results are combined:
93
+ * - `"cross"` — cartesian product / pairwise combination of both results
94
+ * - `"union"` — concatenation / merge of both results into a single collection
56
95
  */
57
96
  combine: "cross" | "union";
97
+ /**
98
+ * The first (primary) result item, used as a fallback if the second conditional produces no result.
99
+ */
58
100
  firstItem?: T;
101
+ /**
102
+ * The second conditional item(s) whose result will be combined with {@link firstItem}.
103
+ */
59
104
  secondConditionalItem?: PixiVNJsonStepSwitchElementType<T>[];
60
105
  };
61
106
 
107
+ /**
108
+ * A conditional statement that evaluates to a value of type `Then`.
109
+ * It can be either:
110
+ * - a {@link PixiVNJsonStepSwitch} — selects a result from a list based on a strategy (random, sequential, loop)
111
+ * - a {@link PixiVNJsonIfElse} — evaluates a condition and returns the matching branch result,
112
+ * which may itself be another conditional or a {@link PixiVNJsonConditionalResultToCombine}
113
+ */
62
114
  type PixiVNJsonConditionalStatements<Then> = PixiVNJsonStepSwitch<Then> | PixiVNJsonIfElse<Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>>;
63
115
 
116
+ /**
117
+ * Retrieves a value from the persistent storage, flag storage, or temporary storage.
118
+ */
64
119
  type PixiVNJsonStorageGet = {
65
120
  type: "value";
66
121
  storageOperationType: "get";
@@ -78,11 +133,14 @@ type PixiVNJsonParamGet = {
78
133
  type: "value";
79
134
  storageOperationType: "get";
80
135
  /**
81
- * Key of the storage
136
+ * Index of the parameter in the params array.
82
137
  */
83
138
  key: number;
84
139
  storageType: "params";
85
140
  };
141
+ /**
142
+ * Retrieves the number of times a label has been opened.
143
+ */
86
144
  type PixiVNJsonLabelGet = {
87
145
  type: "value";
88
146
  storageOperationType: "get";
@@ -95,6 +153,9 @@ type PixiVNJsonLabelGet = {
95
153
  */
96
154
  storageType: "label";
97
155
  };
156
+ /**
157
+ * Retrieves the number of times a specific choice has been selected.
158
+ */
98
159
  type PixiVNJsonChoiceGet = {
99
160
  type: "value";
100
161
  storageOperationType: "get";
@@ -107,13 +168,41 @@ type PixiVNJsonChoiceGet = {
107
168
  */
108
169
  storageType: "choice";
109
170
  };
171
+ /**
172
+ * Retrieves a value from the logic/arithmetic layer (result of a computation or condition).
173
+ */
110
174
  type PixiVNJsonLogicGet = {
111
175
  type: "value";
112
176
  storageOperationType: "get";
177
+ /**
178
+ * The arithmetic or conditional operation whose result is the retrieved value.
179
+ */
113
180
  operation: PixiVNJsonArithmeticOperations | PixiVNJsonConditions;
114
181
  storageType: "logic";
115
182
  };
116
- type PixiVNJsonValueGet = PixiVNJsonStorageGet | PixiVNJsonParamGet | PixiVNJsonLabelGet | PixiVNJsonChoiceGet | PixiVNJsonLogicGet;
183
+ /**
184
+ * Union of all "get value" operations — reads from storage, params, labels, choices, or a logic expression.
185
+ */
186
+ type PixiVNJsonValueGet = PixiVNJsonStorageGet | PixiVNJsonParamGet | PixiVNJsonLabelGet | PixiVNJsonChoiceGet | PixiVNJsonLogicGet | PixiVNJsonFunction;
187
+ /**
188
+ * Invokes a named function and returns its result.
189
+ * Functions are registered in the Pixi'VN runtime and can receive typed arguments.
190
+ */
191
+ type PixiVNJsonFunction = {
192
+ type: "function";
193
+ /**
194
+ * The name of the registered function to call.
195
+ */
196
+ functionName: string;
197
+ /**
198
+ * Arguments to pass to the function. Each argument can be a condition, a raw value,
199
+ * a value-get operation, or an arithmetic expression.
200
+ */
201
+ args: (PixiVNJsonConditions | StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations)[];
202
+ };
203
+ /**
204
+ * Sets a value in either the persistent storage or the temporary (session) storage.
205
+ */
117
206
  type PixiVNJsonOnlyStorageSet = {
118
207
  type: "value";
119
208
  storageOperationType: "set";
@@ -130,19 +219,26 @@ type PixiVNJsonOnlyStorageSet = {
130
219
  */
131
220
  storageType: "storage" | "tempstorage";
132
221
  };
222
+ /**
223
+ * Sets a positional parameter value in the params temporary storage.
224
+ */
133
225
  type PixiVNJsonOnlyParamSet = {
134
226
  type: "value";
135
227
  storageOperationType: "set";
136
228
  /**
137
- * Key of the storage
229
+ * Index of the parameter in the params array to set.
138
230
  */
139
231
  key: number;
140
232
  /**
141
- * Value to be set in the storage
233
+ * Value to be set at the given param index.
142
234
  */
143
235
  value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType>;
144
236
  storageType: "params";
145
237
  };
238
+ /**
239
+ * Sets a boolean flag in the flag storage.
240
+ * Flag storage is a dedicated boolean key-value store queried with {@link getFlag}.
241
+ */
146
242
  type PixiVNJsonFlagSet = {
147
243
  type: "value";
148
244
  storageOperationType: "set";
@@ -159,8 +255,14 @@ type PixiVNJsonFlagSet = {
159
255
  */
160
256
  storageType: "flagStorage";
161
257
  };
258
+ /**
259
+ * Union of all "set value" operations — writes to storage, flag storage, or params.
260
+ */
162
261
  type PixiVNJsonValueSet = PixiVNJsonOnlyStorageSet | PixiVNJsonFlagSet | PixiVNJsonOnlyParamSet;
163
262
 
263
+ /**
264
+ * Binary arithmetic operation between two values (left OP right).
265
+ */
164
266
  interface PixiVNJsonArithmeticOperationsArithmetic {
165
267
  type: "arithmetic";
166
268
  /**
@@ -172,10 +274,20 @@ interface PixiVNJsonArithmeticOperationsArithmetic {
172
274
  */
173
275
  rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
174
276
  /**
175
- * Operator of the arithmetic operation
277
+ * Operator of the arithmetic operation:
278
+ * - `"*"` multiplication
279
+ * - `"/"` division
280
+ * - `"+"` addition
281
+ * - `"-"` subtraction
282
+ * - `"%"` modulo
283
+ * - `"POW"` exponentiation
284
+ * - `"RANDOM"` random integer between leftValue and rightValue (inclusive)
176
285
  */
177
286
  operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
178
287
  }
288
+ /**
289
+ * Unary arithmetic operation applied to a single value (e.g. INT, FLOOR, FLOAT).
290
+ */
179
291
  interface PixiVNJsonArithmeticOperationsArithmeticSingle {
180
292
  type: "arithmeticsingle";
181
293
  /**
@@ -183,7 +295,10 @@ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
183
295
  */
184
296
  leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
185
297
  /**
186
- * Operator of the arithmetic operation
298
+ * Operator of the arithmetic operation:
299
+ * - `"INT"` truncates the value to an integer (removes the decimal part)
300
+ * - `"FLOOR"` rounds down to the nearest integer
301
+ * - `"FLOAT"` converts the value to a floating-point number
187
302
  */
188
303
  operator: "INT" | "FLOOR" | "FLOAT";
189
304
  }
@@ -192,18 +307,48 @@ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
192
307
  */
193
308
  type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
194
309
 
310
+ /**
311
+ * Combines multiple conditions with a logical AND or OR.
312
+ */
195
313
  type PixiVNJsonUnionConditionAndOr = {
196
314
  type: "union";
315
+ /**
316
+ * The list of conditions to combine.
317
+ */
197
318
  conditions: PixiVNJsonConditions[];
319
+ /**
320
+ * - `"and"` — all conditions must be true
321
+ * - `"or"` — at least one condition must be true
322
+ */
198
323
  unionType: "and" | "or";
199
324
  };
325
+ /**
326
+ * Negates a single condition with a logical NOT.
327
+ */
200
328
  type PixiVNJsonUnionConditionNot = {
201
329
  type: "union";
330
+ /**
331
+ * The condition to negate.
332
+ */
202
333
  condition: PixiVNJsonConditions;
203
334
  unionType: "not";
204
335
  };
336
+ /**
337
+ * Union of AND/OR and NOT logical operators over conditions.
338
+ */
205
339
  type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
206
340
 
341
+ /**
342
+ * Supported comparison operators.
343
+ * - `"=="` equal
344
+ * - `"!="` not equal
345
+ * - `"<"` less than
346
+ * - `"<="` less than or equal
347
+ * - `">"` greater than
348
+ * - `">="` greater than or equal
349
+ * - `"CONTAINS"` checks whether the left string/array contains the right value
350
+ */
351
+ type PixiVNJsonComparationOperatorsType = "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
207
352
  /**
208
353
  * Comparation for PixiVNJson.
209
354
  * In this comparation, the values to be converted to string and compared.
@@ -221,11 +366,18 @@ type PixiVNJsonComparation = {
221
366
  /**
222
367
  * Operator of the comparation
223
368
  */
224
- operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
369
+ operator: PixiVNJsonComparationOperatorsType;
225
370
  };
371
+ /**
372
+ * A plain value condition — truthy/falsy evaluation of a raw value or a value-get result.
373
+ */
226
374
  type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
227
375
  /**
228
- * Conditions for PixiVNJson
376
+ * Union of all condition types supported by PixiVNJson:
377
+ * - {@link PixiVNJsonComparation} — binary comparison between two values
378
+ * - {@link PixiVNJsonValueCondition} — truthy/falsy check on a plain value
379
+ * - {@link PixiVNJsonUnionCondition} — logical AND, OR, or NOT of other conditions
380
+ * - {@link PixiVNJsonArithmeticOperations} — arithmetic result used as a boolean (non-zero = true)
229
381
  */
230
382
  type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
231
383
 
@@ -248,182 +400,470 @@ interface PixiVNJsonIfElse<Then> {
248
400
  else?: Then | PixiVNJsonIfElse<Then>;
249
401
  }
250
402
 
403
+ /**
404
+ * Animates one or more canvas elements simultaneously using keyframe-based animation.
405
+ */
251
406
  type PixiVNJsonAnimateBase<T extends CanvasBaseInterface<any>> = {
252
407
  type: "animate";
408
+ /**
409
+ * Alias (or list of aliases) of the canvas elements to animate.
410
+ */
253
411
  alias: string | string[];
412
+ /**
413
+ * The keyframes that define the animation values over time.
414
+ */
254
415
  keyframes: KeyframesType<T>;
416
+ /**
417
+ * Additional options controlling the animation (duration, easing, repeat, etc.).
418
+ */
255
419
  options?: AnimationOptions;
420
+ /**
421
+ * Pixi.js update priority for this animation ticker callback.
422
+ */
256
423
  priority?: UPDATE_PRIORITY;
257
424
  };
425
+ /**
426
+ * Animates a canvas element using a sequence of segments (timeline-based animation).
427
+ */
258
428
  type PixiVNJsonAnimateSequence<T extends CanvasBaseInterface<any>> = {
259
429
  type: "animate-sequence";
430
+ /**
431
+ * Alias of the canvas element to animate.
432
+ */
260
433
  alias: string;
434
+ /**
435
+ * Ordered list of animation segments, each optionally including a transition.
436
+ */
261
437
  sequence: (ObjectSegment<T> | ObjectSegmentWithTransition<T>)[];
438
+ /**
439
+ * Additional options controlling the sequence playback.
440
+ */
262
441
  options?: SequenceOptions;
442
+ /**
443
+ * Pixi.js update priority for this animation ticker callback.
444
+ */
263
445
  priority?: UPDATE_PRIORITY;
264
446
  };
447
+ /**
448
+ * Union of all canvas animation operations — keyframe-based or sequence-based.
449
+ */
265
450
  type PixiVNJsonCanvasAnimate<T extends CanvasBaseInterface<any> = ImageSprite> = PixiVNJsonAnimateBase<T> | PixiVNJsonAnimateSequence<T>;
266
451
 
452
+ /**
453
+ * Applies a shake effect to a canvas element.
454
+ */
267
455
  type PixiVNJsonEffectShake = {
268
456
  type: "shake";
457
+ /**
458
+ * Alias of the canvas element to apply the shake effect to.
459
+ */
269
460
  alias: string;
461
+ /**
462
+ * Configuration properties for the shake effect (amplitude, duration, etc.).
463
+ */
270
464
  props: ShakeEffectProps;
465
+ /**
466
+ * Pixi.js update priority for the effect ticker callback.
467
+ */
271
468
  priority?: UPDATE_PRIORITY;
272
469
  };
470
+ /**
471
+ * Union of all canvas visual effects.
472
+ */
273
473
  type PixiVNJsonCanvasEffect = PixiVNJsonEffectShake;
274
474
 
475
+ /**
476
+ * Cross-dissolve transition — blends the element in or out by gradually changing its opacity.
477
+ */
275
478
  type DissolveTransition = {
276
479
  type: "dissolve";
480
+ /**
481
+ * Configuration options for the dissolve transition.
482
+ */
277
483
  props?: ShowWithDissolveTransitionProps;
484
+ /**
485
+ * Pixi.js update priority for the transition ticker callback.
486
+ */
278
487
  priority?: UPDATE_PRIORITY;
279
488
  };
489
+ /**
490
+ * Fade transition — fades the element in or out by animating its alpha value.
491
+ */
280
492
  type FadeTransition = {
281
493
  type: "fade";
494
+ /**
495
+ * Configuration options for the fade transition.
496
+ */
282
497
  props?: ShowWithFadeTransitionProps;
498
+ /**
499
+ * Pixi.js update priority for the transition ticker callback.
500
+ */
283
501
  priority?: UPDATE_PRIORITY;
284
502
  };
503
+ /**
504
+ * Move-in / Move-out transition — slides the element into or out of the viewport.
505
+ */
285
506
  type MoveInOutTransition = {
286
507
  type: "movein" | "moveout";
508
+ /**
509
+ * Configuration options for the move transition (direction, duration, easing, etc.).
510
+ */
287
511
  props?: MoveInOutProps;
512
+ /**
513
+ * Pixi.js update priority for the transition ticker callback.
514
+ */
288
515
  priority?: UPDATE_PRIORITY;
289
516
  };
517
+ /**
518
+ * Zoom-in / Zoom-out transition — scales the element into or out of view.
519
+ */
290
520
  type ZoomInOutTransition = {
291
521
  type: "zoomin" | "zoomout";
522
+ /**
523
+ * Configuration options for the zoom transition (scale, duration, easing, etc.).
524
+ */
292
525
  props?: ZoomInOutProps;
526
+ /**
527
+ * Pixi.js update priority for the transition ticker callback.
528
+ */
293
529
  priority?: UPDATE_PRIORITY;
294
530
  };
531
+ /**
532
+ * Push-in / Push-out transition — pushes the element onto or off the viewport, displacing the current content.
533
+ */
295
534
  type PushInOutTransition = {
296
535
  type: "pushin" | "pushout";
536
+ /**
537
+ * Configuration options for the push transition (direction, duration, easing, etc.).
538
+ */
297
539
  props?: PushInOutProps;
540
+ /**
541
+ * Pixi.js update priority for the transition ticker callback.
542
+ */
298
543
  priority?: UPDATE_PRIORITY;
299
544
  };
545
+ /**
546
+ * Union of all supported canvas media transitions.
547
+ */
300
548
  type PixiVNJsonMediaTransiotions = DissolveTransition | FadeTransition | MoveInOutTransition | ZoomInOutTransition | PushInOutTransition;
301
549
 
550
+ /**
551
+ * Shows an image or video asset on the canvas.
552
+ */
302
553
  type PixiVNJsonCanvasImageVideoShow = {
303
554
  type: "image" | "video";
304
555
  operationType: "show";
556
+ /**
557
+ * Unique identifier (alias) used to reference this element on the canvas.
558
+ */
305
559
  alias: string;
306
560
  /**
307
561
  * The url of the image or video.
308
562
  * If the url is not provided, the url will be set to the alias.
309
563
  */
310
564
  url?: string;
565
+ /**
566
+ * Display options (position, scale, alpha, etc.) for the image or video sprite.
567
+ */
311
568
  props?: ImageSpriteOptions;
569
+ /**
570
+ * Optional transition effect applied when the element appears on screen.
571
+ */
312
572
  transition?: PixiVNJsonMediaTransiotions;
313
573
  };
574
+ /**
575
+ * Shows an image container (a group of layered images) on the canvas.
576
+ */
314
577
  type PixiVNJsonCanvasImageContainerShow = {
315
578
  type: "imagecontainer";
316
579
  operationType: "show";
580
+ /**
581
+ * Unique identifier (alias) used to reference this element on the canvas.
582
+ */
317
583
  alias: string;
584
+ /**
585
+ * The ordered list of image URLs that compose the container layers.
586
+ */
318
587
  urls: string[];
588
+ /**
589
+ * Display options for the image container.
590
+ */
319
591
  props?: ImageContainerOptions<ImageSprite>;
592
+ /**
593
+ * Optional transition effect applied when the element appears on screen.
594
+ */
320
595
  transition?: PixiVNJsonMediaTransiotions;
321
596
  };
597
+ /**
598
+ * Shows a text element on the canvas.
599
+ */
322
600
  type PixiVNJsonCanvasTextShow = {
323
601
  type: "text";
324
602
  operationType: "show";
603
+ /**
604
+ * Unique identifier (alias) used to reference this element on the canvas.
605
+ */
325
606
  alias: string;
607
+ /**
608
+ * The string content to display.
609
+ */
326
610
  text: string;
611
+ /**
612
+ * Display options (font, style, position, etc.) for the text element.
613
+ */
327
614
  props?: TextOptions;
615
+ /**
616
+ * Optional transition effect applied when the element appears on screen.
617
+ */
328
618
  transition?: PixiVNJsonMediaTransiotions;
329
619
  };
620
+ /**
621
+ * Edits the properties of an existing image sprite on the canvas.
622
+ */
330
623
  type PixiVNJsonImageEdit = {
331
624
  type: "image";
332
625
  operationType: "edit";
626
+ /**
627
+ * Alias of the canvas element to edit.
628
+ */
333
629
  alias: string;
630
+ /**
631
+ * Partial memory/state properties to update on the image sprite.
632
+ */
334
633
  props?: Partial<ImageSpriteMemory>;
335
634
  };
635
+ /**
636
+ * Edits the properties of an existing video sprite on the canvas.
637
+ */
336
638
  type PixiVNJsonVideoEdit = {
337
639
  type: "video";
338
640
  operationType: "edit";
641
+ /**
642
+ * Alias of the canvas element to edit.
643
+ */
339
644
  alias: string;
645
+ /**
646
+ * Partial memory/state properties to update on the video sprite.
647
+ */
340
648
  props?: Partial<VideoSpriteMemory>;
341
649
  };
650
+ /**
651
+ * Edits the properties of an existing image container on the canvas.
652
+ */
342
653
  type PixiVNJsonImageContainerEdit = {
343
654
  type: "imagecontainer";
344
655
  operationType: "edit";
656
+ /**
657
+ * Alias of the canvas element to edit.
658
+ */
345
659
  alias: string;
660
+ /**
661
+ * Partial memory/state properties to update on the image container.
662
+ */
346
663
  props?: Partial<ImageContainerMemory>;
347
664
  };
665
+ /**
666
+ * Edits the properties of an existing text element on the canvas.
667
+ */
348
668
  type PixiVNJsonTextEdit = {
349
669
  type: "text";
350
670
  operationType: "edit";
671
+ /**
672
+ * Alias of the canvas element to edit.
673
+ */
351
674
  alias: string;
675
+ /**
676
+ * Partial memory/state properties to update on the text element.
677
+ */
352
678
  props?: Partial<TextMemory>;
353
679
  };
680
+ /**
681
+ * Edits the properties of an unknown/generic canvas element.
682
+ * Use this when the specific element type is not one of the built-in kinds.
683
+ */
354
684
  type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
355
685
  type: "canvaselement";
356
686
  operationType: "edit";
687
+ /**
688
+ * Alias of the canvas element to edit.
689
+ */
357
690
  alias: string;
691
+ /**
692
+ * Partial options/properties to update on the canvas element.
693
+ */
358
694
  props?: Partial<T>;
359
695
  };
696
+ /**
697
+ * Removes a canvas element from the stage, optionally with a transition.
698
+ */
360
699
  type PixiVNJsonCanvasRemove = {
361
700
  type: "image" | "video" | "imagecontainer" | "canvaselement" | "text";
362
701
  operationType: "remove";
702
+ /**
703
+ * Alias of the canvas element to remove.
704
+ */
363
705
  alias: string;
706
+ /**
707
+ * Optional transition effect applied while the element disappears.
708
+ */
364
709
  transition?: PixiVNJsonMediaTransiotions;
365
710
  };
711
+ /**
712
+ * Pauses or resumes playback of a video sprite on the canvas.
713
+ */
366
714
  type PixiVNJsonVideoPauseResume = {
367
715
  type: "video";
368
716
  operationType: "pause" | "resume";
717
+ /**
718
+ * Alias of the video element to pause or resume.
719
+ */
369
720
  alias: string;
370
721
  };
722
+ /**
723
+ * Loads or lazy-loads asset bundles or individual assets into memory.
724
+ */
371
725
  type PixiVNJsonAssetsLoad = {
372
726
  type: "assets" | "bundle";
373
727
  operationType: "load" | "lazyload";
728
+ /**
729
+ * List of asset aliases (or bundle names) to load.
730
+ */
374
731
  aliases: string[];
375
732
  };
376
733
  type PixiVNJsonCanvasShow = PixiVNJsonCanvasImageContainerShow | PixiVNJsonCanvasImageVideoShow | PixiVNJsonCanvasTextShow;
734
+ /**
735
+ * Union of all canvas-element edit operations.
736
+ */
377
737
  type PixiVNJsonCanvasEdit = PixiVNJsonImageEdit | PixiVNJsonVideoEdit | PixiVNJsonImageContainerEdit | PixiVNJsonTextEdit | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory | TextMemory>;
738
+ /**
739
+ * Union of all canvas operations — show, edit, remove, animate, apply effects, and asset loading.
740
+ */
378
741
  type PixiVNJsonCanvas = PixiVNJsonCanvasShow | PixiVNJsonCanvasEdit | PixiVNJsonCanvasRemove | PixiVNJsonVideoPauseResume | PixiVNJsonAssetsLoad | PixiVNJsonCanvasAnimate | PixiVNJsonCanvasEffect;
379
742
 
743
+ /**
744
+ * Requests user input during the narrative.
745
+ * When this operation is encountered, the engine pauses and waits for the player to provide a value.
746
+ */
380
747
  type PixiVNJsonInputRequest = {
381
748
  type: "input";
382
749
  operationType: "request";
750
+ /**
751
+ * The expected value type for the input (e.g. `"string"`, `"number"`, `"boolean"`).
752
+ * Used by the engine to validate or cast the player's answer.
753
+ */
383
754
  valueType?: string;
755
+ /**
756
+ * A default value that will be used if the player does not provide any input.
757
+ */
384
758
  defaultValue?: any;
385
759
  };
760
+ /**
761
+ * Clears (resets) the current dialogue state.
762
+ * This is typically used to wipe any displayed text before showing new content.
763
+ */
386
764
  type PixiVNJsonDialogue = {
387
765
  type: "dialogue";
388
766
  operationType: "clean";
389
767
  };
768
+ /**
769
+ * Narration operation — either a dialogue clear or a user-input request.
770
+ */
390
771
  type PixiVNJsonNarration = PixiVNJsonDialogue | PixiVNJsonInputRequest;
391
772
 
773
+ /**
774
+ * Starts playback of a sound asset.
775
+ */
392
776
  type PixiVNJsonSoundPlay = {
393
777
  type: "sound";
394
778
  operationType: "play";
779
+ /**
780
+ * Unique identifier (alias) used to reference this sound.
781
+ */
395
782
  alias: string;
783
+ /**
784
+ * URL of the sound file. If omitted, the alias is used as the URL.
785
+ */
396
786
  url?: string;
787
+ /**
788
+ * Playback options such as volume, loop, channel, and start offset.
789
+ */
397
790
  props?: SoundPlayOptionsWithChannel;
398
791
  };
792
+ /**
793
+ * Stops a playing sound and removes it from the audio context.
794
+ */
399
795
  type PixiVNJsonSoundRemove = {
400
796
  type: "sound";
401
797
  operationType: "stop";
798
+ /**
799
+ * Alias of the sound to stop.
800
+ */
402
801
  alias: string;
403
802
  };
803
+ /**
804
+ * Pauses or resumes a sound, a channel, or all audio.
805
+ */
404
806
  type PixiVNJsonSoundPauseResume = {
405
807
  type: "sound" | "channel";
406
808
  operationType: "pause" | "resume";
809
+ /**
810
+ * Alias of the sound or channel to pause/resume.
811
+ */
407
812
  alias: string;
408
813
  } | {
409
814
  type: "all";
410
815
  operationType: "pause" | "resume" | "stop";
411
816
  };
817
+ /**
818
+ * Edits the properties of a currently playing sound (volume, speed, muted, loop, etc.).
819
+ */
412
820
  type PixiVNJsonSoundEdit = {
413
821
  type: "sound";
414
822
  operationType: "edit";
823
+ /**
824
+ * Alias of the sound to edit.
825
+ */
415
826
  alias: string;
416
- props: Partial<Pick<MediaInterface, "speed" | "volume" | "muted" | "loop" | "paused">>;
827
+ /**
828
+ * Partial set of properties to apply to the sound.
829
+ */
830
+ props: Partial<Pick<MediaInterface, "speed" | "muted" | "loop" | "paused"> & Pick<SoundPlayOptionsWithChannel, "volume">>;
417
831
  };
832
+ /**
833
+ * Union of all sound operations — play, stop, pause/resume, and edit.
834
+ */
418
835
  type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
419
836
 
837
+ /**
838
+ * An operation string that holds a list of string/value fragments to be concatenated at runtime.
839
+ * Used internally to represent string interpolation expressions before they are fully resolved.
840
+ */
420
841
  type PixiVNJsonOperationString = {
421
842
  type: "operationtoconvert";
843
+ /**
844
+ * The ordered list of string fragments and/or value-get expressions to concatenate.
845
+ */
422
846
  values: (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet>)[];
423
847
  };
424
- type PixiVNJsonOperation = PixiVNJsonValueSet | PixiVNJsonCanvas | PixiVNJsonSound | PixiVNJsonNarration;
848
+ /**
849
+ * A single resolved operation — a value set, canvas operation, sound operation,
850
+ * narration operation, or function call — optionally annotated with an origin string.
851
+ */
852
+ type PixiVNJsonOperation = (PixiVNJsonValueSet | PixiVNJsonCanvas | PixiVNJsonSound | PixiVNJsonNarration | PixiVNJsonFunction) & {
853
+ /**
854
+ * This value is used by the system to know where this operation is from, for example, if is generated from a string operation.
855
+ */
856
+ $origin?: string;
857
+ };
858
+ /**
859
+ * A conditional operation — either a plain operation, an if-else that resolves to one,
860
+ * or an operation-string (string interpolation expression).
861
+ */
425
862
  type PixiVNJsonConditionalOperation = PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString;
426
863
 
864
+ /**
865
+ * A player-presentable choice in a menu.
866
+ */
427
867
  type PixiVNJsonChoice = {
428
868
  /**
429
869
  * The text to be displayed.
@@ -454,8 +894,20 @@ type PixiVNJsonChoice = {
454
894
  */
455
895
  autoSelect?: boolean;
456
896
  };
897
+ /**
898
+ * A list of choices (possibly conditional) that are shown to the player as a menu.
899
+ */
457
900
  type PixiVNJsonChoices = (PixiVNJsonChoice | PixiVNJsonConditionalStatements<PixiVNJsonChoice>)[];
901
+ /**
902
+ * The text content of a dialogue line.
903
+ * Can be a plain string, a dynamic value-get, a conditional expression, or an array of any of these
904
+ * (which will be concatenated into a single string at runtime).
905
+ */
458
906
  type PixiVNJsonDialogText = string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet | string[]> | (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet | string[]>)[];
907
+ /**
908
+ * A dialogue line, optionally attributed to a character.
909
+ * When a plain `Text` value is used, no character attribution is included.
910
+ */
459
911
  type PixiVNJsonDialog<Text = string> = {
460
912
  /**
461
913
  * The character id that will speak.
@@ -466,7 +918,10 @@ type PixiVNJsonDialog<Text = string> = {
466
918
  */
467
919
  text: Text;
468
920
  } | Text;
469
- type PixiVNJsonLabelToOpen<T extends {} = {}> = {
921
+ /**
922
+ * Describes a label that should be opened (called or jumped to) during a step.
923
+ */
924
+ type PixiVNJsonLabelToOpen<T extends {} = object> = {
470
925
  /**
471
926
  * The id of the label to open.
472
927
  */
@@ -483,7 +938,7 @@ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
483
938
  * **It is not recommended to use it, use it only if necessary**. The parameters to be passed to the label. If you want to pass an object, use the {@link PixiVNJsonLabelToOpen.props} attribute.
484
939
  * "params" attribute will be stored in the temp storage with the key: {@link PIXIVNJSON_PARAM_ID} + ({@link narration.openedLabels.length} - 1).
485
940
  */
486
- params?: any[];
941
+ params?: unknown[];
487
942
  };
488
943
  /**
489
944
  * Steps of a label.
@@ -495,6 +950,9 @@ type PixiVNJsonLabelToOpen<T extends {} = {}> = {
495
950
  * 5. end the label if {@link PixiVNJsonLabelStep.end} is "label_end"
496
951
  */
497
952
  type PixiVNJsonLabelStep = {
953
+ /**
954
+ * Operations to execute at the start of this step (storage writes, canvas updates, sound, etc.).
955
+ */
498
956
  operations?: PixiVNJsonConditionalOperation[];
499
957
  /**
500
958
  * Variable used to display a choice menu.
@@ -523,17 +981,56 @@ type PixiVNJsonLabelStep = {
523
981
  * - label_end: ends the label
524
982
  */
525
983
  end?: "game_end" | "label_end" | PixiVNJsonConditionalStatements<"game_end" | "label_end">;
984
+ /**
985
+ * If set, this step is replaced by the result of evaluating the given conditional statement.
986
+ * Allows an entire step to be chosen at runtime based on a condition or step-switch strategy.
987
+ */
526
988
  conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
527
989
  };
528
990
 
991
+ /**
992
+ * Manages the translation pipeline for all text displayed by pixi-vn-json.
993
+ *
994
+ * The pipeline applies three optional hooks in order:
995
+ * 1. `beforeToTranslate` – pre-processes the key before translation.
996
+ * 2. `translate` – the main translation function (identity by default).
997
+ * 3. `afterToTranslate` – post-processes the translated string.
998
+ *
999
+ * Use {@link TranslatorManager.t} to translate a key or array of keys.
1000
+ */
529
1001
  declare class TranslatorManager {
530
1002
  private static _beforeToTranslate;
531
1003
  private static _translate;
532
1004
  private static _afterToTranslate;
1005
+ /**
1006
+ * Translates a single key or an array of keys using the registered pipeline.
1007
+ * Returns the same type (`string` or `string[]`) as the input.
1008
+ *
1009
+ * @param key - The string key or array of string keys to translate.
1010
+ * @returns The translated string(s).
1011
+ */
533
1012
  static t<T = string | string[]>(key: T): T;
1013
+ /**
1014
+ * Sets a hook that runs **before** the main translation function.
1015
+ * Useful for key normalization (e.g. trimming, lowercasing).
1016
+ */
534
1017
  static set beforeToTranslate(value: (key: string) => string);
1018
+ /**
1019
+ * Sets the main translation function.
1020
+ * Defaults to an identity function (returns the key unchanged).
1021
+ *
1022
+ * @example
1023
+ * ```ts
1024
+ * translator.translate = (key) => i18n.t(key);
1025
+ * ```
1026
+ */
535
1027
  static set translate(value: (key: string) => string);
1028
+ /** Returns the composed translation pipeline (before → translate → after). */
536
1029
  static get translate(): (key: string) => string;
1030
+ /**
1031
+ * Sets a hook that runs **after** the main translation function.
1032
+ * Useful for post-processing translated strings (e.g. replacing placeholders).
1033
+ */
537
1034
  static set afterToTranslate(value: (key: string) => string);
538
1035
  private static addKey;
539
1036
  private static getConditionalsThenElse;