@drincs/pixi-vn-json 1.12.1 → 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.
@@ -1,18 +1,36 @@
1
- import { LabelAbstract, LabelProps, StepLabelPropsType as StepLabelPropsType$1, StepLabelType } from '@drincs/pixi-vn/narration';
2
1
  import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
3
2
  import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
4
3
  import { UPDATE_PRIORITY } from 'pixi.js';
5
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
+ */
6
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
+ */
7
13
  type PixiVNJsonStepSwitchElementsType<Then> = PixiVNJsonStepSwitchElementType<Then>[] | PixiVNJsonConditionalStatements<Then[]>;
14
+ /**
15
+ * Picks one element at random each time the step is visited.
16
+ */
8
17
  interface PixiVNJsonRandom<Then> {
9
18
  type: "stepswitch";
10
19
  choiceType: "random";
20
+ /**
21
+ * The pool of elements to choose from randomly.
22
+ */
11
23
  elements: PixiVNJsonStepSwitchElementsType<Then>;
12
24
  }
25
+ /**
26
+ * Picks elements in a random order, advancing through the list across visits (no repeats until exhausted).
27
+ */
13
28
  interface PixiVNJsonSequentialRandom<Then> {
14
29
  type: "stepswitch";
15
30
  choiceType: "sequentialrandom";
31
+ /**
32
+ * The pool of elements to iterate through in randomised order.
33
+ */
16
34
  elements: PixiVNJsonStepSwitchElementsType<Then>;
17
35
  /**
18
36
  * When the sequential ends, what should be the value? If undefined, it will return undefined.
@@ -20,13 +38,19 @@ interface PixiVNJsonSequentialRandom<Then> {
20
38
  */
21
39
  end: undefined | "lastItem";
22
40
  /**
23
- * The subId is used for manager nested switches
41
+ * The subId is used for managing nested switches
24
42
  */
25
43
  nestedId?: string;
26
44
  }
45
+ /**
46
+ * Advances through the elements list one by one on each visit (in order).
47
+ */
27
48
  interface PixiVNJsonSequential<Then> {
28
49
  type: "stepswitch";
29
50
  choiceType: "sequential";
51
+ /**
52
+ * The ordered list of elements to iterate through.
53
+ */
30
54
  elements: PixiVNJsonStepSwitchElementsType<Then>;
31
55
  /**
32
56
  * When the sequential ends, what should be the value? If undefined, it will return undefined.
@@ -34,16 +58,28 @@ interface PixiVNJsonSequential<Then> {
34
58
  */
35
59
  end: undefined | "lastItem";
36
60
  /**
37
- * The subId is used for manager nested switches
61
+ * The subId is used for managing nested switches
38
62
  */
39
63
  nestedId?: string;
40
64
  }
65
+ /**
66
+ * Loops through the elements list indefinitely, cycling back to the first element after the last.
67
+ */
41
68
  interface PixiVNJsonLoop<Then> {
42
69
  type: "stepswitch";
43
70
  choiceType: "loop";
71
+ /**
72
+ * The list of elements to cycle through.
73
+ */
44
74
  elements: PixiVNJsonStepSwitchElementsType<Then>;
75
+ /**
76
+ * The subId is used for managing nested switches
77
+ */
45
78
  nestedId?: string;
46
79
  }
80
+ /**
81
+ * A step-switch selects one element from a list using a defined strategy (random, sequential, loop, or sequential-random).
82
+ */
47
83
  type PixiVNJsonStepSwitch<Then> = PixiVNJsonRandom<Then> | PixiVNJsonSequential<Then> | PixiVNJsonLoop<Then> | PixiVNJsonSequentialRandom<Then>;
48
84
 
49
85
  /**
@@ -53,15 +89,33 @@ type PixiVNJsonStepSwitch<Then> = PixiVNJsonRandom<Then> | PixiVNJsonSequential<
53
89
  type PixiVNJsonConditionalResultToCombine<T> = {
54
90
  type: "resulttocombine";
55
91
  /**
56
- * 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
57
95
  */
58
96
  combine: "cross" | "union";
97
+ /**
98
+ * The first (primary) result item, used as a fallback if the second conditional produces no result.
99
+ */
59
100
  firstItem?: T;
101
+ /**
102
+ * The second conditional item(s) whose result will be combined with {@link firstItem}.
103
+ */
60
104
  secondConditionalItem?: PixiVNJsonStepSwitchElementType<T>[];
61
105
  };
62
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
+ */
63
114
  type PixiVNJsonConditionalStatements<Then> = PixiVNJsonStepSwitch<Then> | PixiVNJsonIfElse<Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>>;
64
115
 
116
+ /**
117
+ * Retrieves a value from the persistent storage, flag storage, or temporary storage.
118
+ */
65
119
  type PixiVNJsonStorageGet = {
66
120
  type: "value";
67
121
  storageOperationType: "get";
@@ -79,11 +133,14 @@ type PixiVNJsonParamGet = {
79
133
  type: "value";
80
134
  storageOperationType: "get";
81
135
  /**
82
- * Key of the storage
136
+ * Index of the parameter in the params array.
83
137
  */
84
138
  key: number;
85
139
  storageType: "params";
86
140
  };
141
+ /**
142
+ * Retrieves the number of times a label has been opened.
143
+ */
87
144
  type PixiVNJsonLabelGet = {
88
145
  type: "value";
89
146
  storageOperationType: "get";
@@ -96,6 +153,9 @@ type PixiVNJsonLabelGet = {
96
153
  */
97
154
  storageType: "label";
98
155
  };
156
+ /**
157
+ * Retrieves the number of times a specific choice has been selected.
158
+ */
99
159
  type PixiVNJsonChoiceGet = {
100
160
  type: "value";
101
161
  storageOperationType: "get";
@@ -108,13 +168,41 @@ type PixiVNJsonChoiceGet = {
108
168
  */
109
169
  storageType: "choice";
110
170
  };
171
+ /**
172
+ * Retrieves a value from the logic/arithmetic layer (result of a computation or condition).
173
+ */
111
174
  type PixiVNJsonLogicGet = {
112
175
  type: "value";
113
176
  storageOperationType: "get";
177
+ /**
178
+ * The arithmetic or conditional operation whose result is the retrieved value.
179
+ */
114
180
  operation: PixiVNJsonArithmeticOperations | PixiVNJsonConditions;
115
181
  storageType: "logic";
116
182
  };
117
- 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
+ */
118
206
  type PixiVNJsonOnlyStorageSet = {
119
207
  type: "value";
120
208
  storageOperationType: "set";
@@ -131,19 +219,26 @@ type PixiVNJsonOnlyStorageSet = {
131
219
  */
132
220
  storageType: "storage" | "tempstorage";
133
221
  };
222
+ /**
223
+ * Sets a positional parameter value in the params temporary storage.
224
+ */
134
225
  type PixiVNJsonOnlyParamSet = {
135
226
  type: "value";
136
227
  storageOperationType: "set";
137
228
  /**
138
- * Key of the storage
229
+ * Index of the parameter in the params array to set.
139
230
  */
140
231
  key: number;
141
232
  /**
142
- * Value to be set in the storage
233
+ * Value to be set at the given param index.
143
234
  */
144
235
  value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType>;
145
236
  storageType: "params";
146
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
+ */
147
242
  type PixiVNJsonFlagSet = {
148
243
  type: "value";
149
244
  storageOperationType: "set";
@@ -160,8 +255,14 @@ type PixiVNJsonFlagSet = {
160
255
  */
161
256
  storageType: "flagStorage";
162
257
  };
258
+ /**
259
+ * Union of all "set value" operations — writes to storage, flag storage, or params.
260
+ */
163
261
  type PixiVNJsonValueSet = PixiVNJsonOnlyStorageSet | PixiVNJsonFlagSet | PixiVNJsonOnlyParamSet;
164
262
 
263
+ /**
264
+ * Binary arithmetic operation between two values (left OP right).
265
+ */
165
266
  interface PixiVNJsonArithmeticOperationsArithmetic {
166
267
  type: "arithmetic";
167
268
  /**
@@ -173,10 +274,20 @@ interface PixiVNJsonArithmeticOperationsArithmetic {
173
274
  */
174
275
  rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
175
276
  /**
176
- * 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)
177
285
  */
178
286
  operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
179
287
  }
288
+ /**
289
+ * Unary arithmetic operation applied to a single value (e.g. INT, FLOOR, FLOAT).
290
+ */
180
291
  interface PixiVNJsonArithmeticOperationsArithmeticSingle {
181
292
  type: "arithmeticsingle";
182
293
  /**
@@ -184,7 +295,10 @@ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
184
295
  */
185
296
  leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
186
297
  /**
187
- * 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
188
302
  */
189
303
  operator: "INT" | "FLOOR" | "FLOAT";
190
304
  }
@@ -193,18 +307,48 @@ interface PixiVNJsonArithmeticOperationsArithmeticSingle {
193
307
  */
194
308
  type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
195
309
 
310
+ /**
311
+ * Combines multiple conditions with a logical AND or OR.
312
+ */
196
313
  type PixiVNJsonUnionConditionAndOr = {
197
314
  type: "union";
315
+ /**
316
+ * The list of conditions to combine.
317
+ */
198
318
  conditions: PixiVNJsonConditions[];
319
+ /**
320
+ * - `"and"` — all conditions must be true
321
+ * - `"or"` — at least one condition must be true
322
+ */
199
323
  unionType: "and" | "or";
200
324
  };
325
+ /**
326
+ * Negates a single condition with a logical NOT.
327
+ */
201
328
  type PixiVNJsonUnionConditionNot = {
202
329
  type: "union";
330
+ /**
331
+ * The condition to negate.
332
+ */
203
333
  condition: PixiVNJsonConditions;
204
334
  unionType: "not";
205
335
  };
336
+ /**
337
+ * Union of AND/OR and NOT logical operators over conditions.
338
+ */
206
339
  type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
207
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";
208
352
  /**
209
353
  * Comparation for PixiVNJson.
210
354
  * In this comparation, the values to be converted to string and compared.
@@ -222,11 +366,18 @@ type PixiVNJsonComparation = {
222
366
  /**
223
367
  * Operator of the comparation
224
368
  */
225
- operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
369
+ operator: PixiVNJsonComparationOperatorsType;
226
370
  };
371
+ /**
372
+ * A plain value condition — truthy/falsy evaluation of a raw value or a value-get result.
373
+ */
227
374
  type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
228
375
  /**
229
- * 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)
230
381
  */
231
382
  type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
232
383
 
@@ -249,187 +400,470 @@ interface PixiVNJsonIfElse<Then> {
249
400
  else?: Then | PixiVNJsonIfElse<Then>;
250
401
  }
251
402
 
403
+ /**
404
+ * Animates one or more canvas elements simultaneously using keyframe-based animation.
405
+ */
252
406
  type PixiVNJsonAnimateBase<T extends CanvasBaseInterface<any>> = {
253
407
  type: "animate";
408
+ /**
409
+ * Alias (or list of aliases) of the canvas elements to animate.
410
+ */
254
411
  alias: string | string[];
412
+ /**
413
+ * The keyframes that define the animation values over time.
414
+ */
255
415
  keyframes: KeyframesType<T>;
416
+ /**
417
+ * Additional options controlling the animation (duration, easing, repeat, etc.).
418
+ */
256
419
  options?: AnimationOptions;
420
+ /**
421
+ * Pixi.js update priority for this animation ticker callback.
422
+ */
257
423
  priority?: UPDATE_PRIORITY;
258
424
  };
425
+ /**
426
+ * Animates a canvas element using a sequence of segments (timeline-based animation).
427
+ */
259
428
  type PixiVNJsonAnimateSequence<T extends CanvasBaseInterface<any>> = {
260
429
  type: "animate-sequence";
430
+ /**
431
+ * Alias of the canvas element to animate.
432
+ */
261
433
  alias: string;
434
+ /**
435
+ * Ordered list of animation segments, each optionally including a transition.
436
+ */
262
437
  sequence: (ObjectSegment<T> | ObjectSegmentWithTransition<T>)[];
438
+ /**
439
+ * Additional options controlling the sequence playback.
440
+ */
263
441
  options?: SequenceOptions;
442
+ /**
443
+ * Pixi.js update priority for this animation ticker callback.
444
+ */
264
445
  priority?: UPDATE_PRIORITY;
265
446
  };
447
+ /**
448
+ * Union of all canvas animation operations — keyframe-based or sequence-based.
449
+ */
266
450
  type PixiVNJsonCanvasAnimate<T extends CanvasBaseInterface<any> = ImageSprite> = PixiVNJsonAnimateBase<T> | PixiVNJsonAnimateSequence<T>;
267
451
 
452
+ /**
453
+ * Applies a shake effect to a canvas element.
454
+ */
268
455
  type PixiVNJsonEffectShake = {
269
456
  type: "shake";
457
+ /**
458
+ * Alias of the canvas element to apply the shake effect to.
459
+ */
270
460
  alias: string;
461
+ /**
462
+ * Configuration properties for the shake effect (amplitude, duration, etc.).
463
+ */
271
464
  props: ShakeEffectProps;
465
+ /**
466
+ * Pixi.js update priority for the effect ticker callback.
467
+ */
272
468
  priority?: UPDATE_PRIORITY;
273
469
  };
470
+ /**
471
+ * Union of all canvas visual effects.
472
+ */
274
473
  type PixiVNJsonCanvasEffect = PixiVNJsonEffectShake;
275
474
 
475
+ /**
476
+ * Cross-dissolve transition — blends the element in or out by gradually changing its opacity.
477
+ */
276
478
  type DissolveTransition = {
277
479
  type: "dissolve";
480
+ /**
481
+ * Configuration options for the dissolve transition.
482
+ */
278
483
  props?: ShowWithDissolveTransitionProps;
484
+ /**
485
+ * Pixi.js update priority for the transition ticker callback.
486
+ */
279
487
  priority?: UPDATE_PRIORITY;
280
488
  };
489
+ /**
490
+ * Fade transition — fades the element in or out by animating its alpha value.
491
+ */
281
492
  type FadeTransition = {
282
493
  type: "fade";
494
+ /**
495
+ * Configuration options for the fade transition.
496
+ */
283
497
  props?: ShowWithFadeTransitionProps;
498
+ /**
499
+ * Pixi.js update priority for the transition ticker callback.
500
+ */
284
501
  priority?: UPDATE_PRIORITY;
285
502
  };
503
+ /**
504
+ * Move-in / Move-out transition — slides the element into or out of the viewport.
505
+ */
286
506
  type MoveInOutTransition = {
287
507
  type: "movein" | "moveout";
508
+ /**
509
+ * Configuration options for the move transition (direction, duration, easing, etc.).
510
+ */
288
511
  props?: MoveInOutProps;
512
+ /**
513
+ * Pixi.js update priority for the transition ticker callback.
514
+ */
289
515
  priority?: UPDATE_PRIORITY;
290
516
  };
517
+ /**
518
+ * Zoom-in / Zoom-out transition — scales the element into or out of view.
519
+ */
291
520
  type ZoomInOutTransition = {
292
521
  type: "zoomin" | "zoomout";
522
+ /**
523
+ * Configuration options for the zoom transition (scale, duration, easing, etc.).
524
+ */
293
525
  props?: ZoomInOutProps;
526
+ /**
527
+ * Pixi.js update priority for the transition ticker callback.
528
+ */
294
529
  priority?: UPDATE_PRIORITY;
295
530
  };
531
+ /**
532
+ * Push-in / Push-out transition — pushes the element onto or off the viewport, displacing the current content.
533
+ */
296
534
  type PushInOutTransition = {
297
535
  type: "pushin" | "pushout";
536
+ /**
537
+ * Configuration options for the push transition (direction, duration, easing, etc.).
538
+ */
298
539
  props?: PushInOutProps;
540
+ /**
541
+ * Pixi.js update priority for the transition ticker callback.
542
+ */
299
543
  priority?: UPDATE_PRIORITY;
300
544
  };
545
+ /**
546
+ * Union of all supported canvas media transitions.
547
+ */
301
548
  type PixiVNJsonMediaTransiotions = DissolveTransition | FadeTransition | MoveInOutTransition | ZoomInOutTransition | PushInOutTransition;
302
549
 
550
+ /**
551
+ * Shows an image or video asset on the canvas.
552
+ */
303
553
  type PixiVNJsonCanvasImageVideoShow = {
304
554
  type: "image" | "video";
305
555
  operationType: "show";
556
+ /**
557
+ * Unique identifier (alias) used to reference this element on the canvas.
558
+ */
306
559
  alias: string;
307
560
  /**
308
561
  * The url of the image or video.
309
562
  * If the url is not provided, the url will be set to the alias.
310
563
  */
311
564
  url?: string;
565
+ /**
566
+ * Display options (position, scale, alpha, etc.) for the image or video sprite.
567
+ */
312
568
  props?: ImageSpriteOptions;
569
+ /**
570
+ * Optional transition effect applied when the element appears on screen.
571
+ */
313
572
  transition?: PixiVNJsonMediaTransiotions;
314
573
  };
574
+ /**
575
+ * Shows an image container (a group of layered images) on the canvas.
576
+ */
315
577
  type PixiVNJsonCanvasImageContainerShow = {
316
578
  type: "imagecontainer";
317
579
  operationType: "show";
580
+ /**
581
+ * Unique identifier (alias) used to reference this element on the canvas.
582
+ */
318
583
  alias: string;
584
+ /**
585
+ * The ordered list of image URLs that compose the container layers.
586
+ */
319
587
  urls: string[];
588
+ /**
589
+ * Display options for the image container.
590
+ */
320
591
  props?: ImageContainerOptions<ImageSprite>;
592
+ /**
593
+ * Optional transition effect applied when the element appears on screen.
594
+ */
321
595
  transition?: PixiVNJsonMediaTransiotions;
322
596
  };
597
+ /**
598
+ * Shows a text element on the canvas.
599
+ */
323
600
  type PixiVNJsonCanvasTextShow = {
324
601
  type: "text";
325
602
  operationType: "show";
603
+ /**
604
+ * Unique identifier (alias) used to reference this element on the canvas.
605
+ */
326
606
  alias: string;
607
+ /**
608
+ * The string content to display.
609
+ */
327
610
  text: string;
611
+ /**
612
+ * Display options (font, style, position, etc.) for the text element.
613
+ */
328
614
  props?: TextOptions;
615
+ /**
616
+ * Optional transition effect applied when the element appears on screen.
617
+ */
329
618
  transition?: PixiVNJsonMediaTransiotions;
330
619
  };
620
+ /**
621
+ * Edits the properties of an existing image sprite on the canvas.
622
+ */
331
623
  type PixiVNJsonImageEdit = {
332
624
  type: "image";
333
625
  operationType: "edit";
626
+ /**
627
+ * Alias of the canvas element to edit.
628
+ */
334
629
  alias: string;
630
+ /**
631
+ * Partial memory/state properties to update on the image sprite.
632
+ */
335
633
  props?: Partial<ImageSpriteMemory>;
336
634
  };
635
+ /**
636
+ * Edits the properties of an existing video sprite on the canvas.
637
+ */
337
638
  type PixiVNJsonVideoEdit = {
338
639
  type: "video";
339
640
  operationType: "edit";
641
+ /**
642
+ * Alias of the canvas element to edit.
643
+ */
340
644
  alias: string;
645
+ /**
646
+ * Partial memory/state properties to update on the video sprite.
647
+ */
341
648
  props?: Partial<VideoSpriteMemory>;
342
649
  };
650
+ /**
651
+ * Edits the properties of an existing image container on the canvas.
652
+ */
343
653
  type PixiVNJsonImageContainerEdit = {
344
654
  type: "imagecontainer";
345
655
  operationType: "edit";
656
+ /**
657
+ * Alias of the canvas element to edit.
658
+ */
346
659
  alias: string;
660
+ /**
661
+ * Partial memory/state properties to update on the image container.
662
+ */
347
663
  props?: Partial<ImageContainerMemory>;
348
664
  };
665
+ /**
666
+ * Edits the properties of an existing text element on the canvas.
667
+ */
349
668
  type PixiVNJsonTextEdit = {
350
669
  type: "text";
351
670
  operationType: "edit";
671
+ /**
672
+ * Alias of the canvas element to edit.
673
+ */
352
674
  alias: string;
675
+ /**
676
+ * Partial memory/state properties to update on the text element.
677
+ */
353
678
  props?: Partial<TextMemory>;
354
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
+ */
355
684
  type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
356
685
  type: "canvaselement";
357
686
  operationType: "edit";
687
+ /**
688
+ * Alias of the canvas element to edit.
689
+ */
358
690
  alias: string;
691
+ /**
692
+ * Partial options/properties to update on the canvas element.
693
+ */
359
694
  props?: Partial<T>;
360
695
  };
696
+ /**
697
+ * Removes a canvas element from the stage, optionally with a transition.
698
+ */
361
699
  type PixiVNJsonCanvasRemove = {
362
700
  type: "image" | "video" | "imagecontainer" | "canvaselement" | "text";
363
701
  operationType: "remove";
702
+ /**
703
+ * Alias of the canvas element to remove.
704
+ */
364
705
  alias: string;
706
+ /**
707
+ * Optional transition effect applied while the element disappears.
708
+ */
365
709
  transition?: PixiVNJsonMediaTransiotions;
366
710
  };
711
+ /**
712
+ * Pauses or resumes playback of a video sprite on the canvas.
713
+ */
367
714
  type PixiVNJsonVideoPauseResume = {
368
715
  type: "video";
369
716
  operationType: "pause" | "resume";
717
+ /**
718
+ * Alias of the video element to pause or resume.
719
+ */
370
720
  alias: string;
371
721
  };
722
+ /**
723
+ * Loads or lazy-loads asset bundles or individual assets into memory.
724
+ */
372
725
  type PixiVNJsonAssetsLoad = {
373
726
  type: "assets" | "bundle";
374
727
  operationType: "load" | "lazyload";
728
+ /**
729
+ * List of asset aliases (or bundle names) to load.
730
+ */
375
731
  aliases: string[];
376
732
  };
377
733
  type PixiVNJsonCanvasShow = PixiVNJsonCanvasImageContainerShow | PixiVNJsonCanvasImageVideoShow | PixiVNJsonCanvasTextShow;
734
+ /**
735
+ * Union of all canvas-element edit operations.
736
+ */
378
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
+ */
379
741
  type PixiVNJsonCanvas = PixiVNJsonCanvasShow | PixiVNJsonCanvasEdit | PixiVNJsonCanvasRemove | PixiVNJsonVideoPauseResume | PixiVNJsonAssetsLoad | PixiVNJsonCanvasAnimate | PixiVNJsonCanvasEffect;
380
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
+ */
381
747
  type PixiVNJsonInputRequest = {
382
748
  type: "input";
383
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
+ */
384
754
  valueType?: string;
755
+ /**
756
+ * A default value that will be used if the player does not provide any input.
757
+ */
385
758
  defaultValue?: any;
386
759
  };
760
+ /**
761
+ * Clears (resets) the current dialogue state.
762
+ * This is typically used to wipe any displayed text before showing new content.
763
+ */
387
764
  type PixiVNJsonDialogue = {
388
765
  type: "dialogue";
389
766
  operationType: "clean";
390
767
  };
768
+ /**
769
+ * Narration operation — either a dialogue clear or a user-input request.
770
+ */
391
771
  type PixiVNJsonNarration = PixiVNJsonDialogue | PixiVNJsonInputRequest;
392
772
 
773
+ /**
774
+ * Starts playback of a sound asset.
775
+ */
393
776
  type PixiVNJsonSoundPlay = {
394
777
  type: "sound";
395
778
  operationType: "play";
779
+ /**
780
+ * Unique identifier (alias) used to reference this sound.
781
+ */
396
782
  alias: string;
783
+ /**
784
+ * URL of the sound file. If omitted, the alias is used as the URL.
785
+ */
397
786
  url?: string;
787
+ /**
788
+ * Playback options such as volume, loop, channel, and start offset.
789
+ */
398
790
  props?: SoundPlayOptionsWithChannel;
399
791
  };
792
+ /**
793
+ * Stops a playing sound and removes it from the audio context.
794
+ */
400
795
  type PixiVNJsonSoundRemove = {
401
796
  type: "sound";
402
797
  operationType: "stop";
798
+ /**
799
+ * Alias of the sound to stop.
800
+ */
403
801
  alias: string;
404
802
  };
803
+ /**
804
+ * Pauses or resumes a sound, a channel, or all audio.
805
+ */
405
806
  type PixiVNJsonSoundPauseResume = {
406
807
  type: "sound" | "channel";
407
808
  operationType: "pause" | "resume";
809
+ /**
810
+ * Alias of the sound or channel to pause/resume.
811
+ */
408
812
  alias: string;
409
813
  } | {
410
814
  type: "all";
411
815
  operationType: "pause" | "resume" | "stop";
412
816
  };
817
+ /**
818
+ * Edits the properties of a currently playing sound (volume, speed, muted, loop, etc.).
819
+ */
413
820
  type PixiVNJsonSoundEdit = {
414
821
  type: "sound";
415
822
  operationType: "edit";
823
+ /**
824
+ * Alias of the sound to edit.
825
+ */
416
826
  alias: string;
827
+ /**
828
+ * Partial set of properties to apply to the sound.
829
+ */
417
830
  props: Partial<Pick<MediaInterface, "speed" | "muted" | "loop" | "paused"> & Pick<SoundPlayOptionsWithChannel, "volume">>;
418
831
  };
832
+ /**
833
+ * Union of all sound operations — play, stop, pause/resume, and edit.
834
+ */
419
835
  type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
420
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
+ */
421
841
  type PixiVNJsonOperationString = {
422
842
  type: "operationtoconvert";
843
+ /**
844
+ * The ordered list of string fragments and/or value-get expressions to concatenate.
845
+ */
423
846
  values: (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet>)[];
424
847
  };
425
- 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) & {
426
853
  /**
427
854
  * This value is used by the system to know where this operation is from, for example, if is generated from a string operation.
428
855
  */
429
856
  $origin?: string;
430
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
+ */
431
862
  type PixiVNJsonConditionalOperation = PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString;
432
863
 
864
+ /**
865
+ * A player-presentable choice in a menu.
866
+ */
433
867
  type PixiVNJsonChoice = {
434
868
  /**
435
869
  * The text to be displayed.
@@ -460,8 +894,20 @@ type PixiVNJsonChoice = {
460
894
  */
461
895
  autoSelect?: boolean;
462
896
  };
897
+ /**
898
+ * A list of choices (possibly conditional) that are shown to the player as a menu.
899
+ */
463
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
+ */
464
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
+ */
465
911
  type PixiVNJsonDialog<Text = string> = {
466
912
  /**
467
913
  * The character id that will speak.
@@ -472,6 +918,9 @@ type PixiVNJsonDialog<Text = string> = {
472
918
  */
473
919
  text: Text;
474
920
  } | Text;
921
+ /**
922
+ * Describes a label that should be opened (called or jumped to) during a step.
923
+ */
475
924
  type PixiVNJsonLabelToOpen<T extends {} = object> = {
476
925
  /**
477
926
  * The id of the label to open.
@@ -501,6 +950,9 @@ type PixiVNJsonLabelToOpen<T extends {} = object> = {
501
950
  * 5. end the label if {@link PixiVNJsonLabelStep.end} is "label_end"
502
951
  */
503
952
  type PixiVNJsonLabelStep = {
953
+ /**
954
+ * Operations to execute at the start of this step (storage writes, canvas updates, sound, etc.).
955
+ */
504
956
  operations?: PixiVNJsonConditionalOperation[];
505
957
  /**
506
958
  * Variable used to display a choice menu.
@@ -529,69 +981,11 @@ type PixiVNJsonLabelStep = {
529
981
  * - label_end: ends the label
530
982
  */
531
983
  end?: "game_end" | "label_end" | PixiVNJsonConditionalStatements<"game_end" | "label_end">;
532
- conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
533
- };
534
-
535
- /**
536
- * Collection of labels to be used in the narrative.
537
- */
538
- type PixiVNJsonLabels = {
539
- [labelId: string]: PixiVNJsonLabelStep[];
540
- };
541
-
542
- /**
543
- * PixiVNJson It can be defined as a programming language to write a narrative written in json.
544
- */
545
- interface PixiVNJson {
546
- /**
547
- * The operations to be executed before the narrative starts.
548
- * For the set storage: They will be set only if there are no variables with the same key already.
549
- * For the det tempstorage: if there are variables with the same key already, they will be overwritten.
550
- */
551
- initialOperations?: (PixiVNJsonValueSet | PixiVNJsonIfElse<PixiVNJsonValueSet>)[];
552
- /**
553
- * The labels to be used in the narrative. They will be added to the system
554
- */
555
- labels?: PixiVNJsonLabels;
556
- }
557
-
558
- type LabelJsonOptions = {
559
984
  /**
560
- * Function that converts a string to a {@link PixiVNJsonOperation}.
561
- * If is a special operation you can return undefined and can run the operation.
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.
562
987
  */
563
- operationStringConvert?: (value: string, step: PixiVNJsonLabelStep, props: StepLabelPropsType$1 | object) => Promise<PixiVNJsonOperation | undefined>;
564
- /**
565
- * If true and a dialog is empty or has only spaces, {@link PixiVNJsonLabelStep.goNextStep} will be set to true.
566
- */
567
- skipEmptyDialogs?: boolean;
988
+ conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
568
989
  };
569
- declare class LabelJson<T extends {} = object> extends LabelAbstract<LabelJson<T>, T> {
570
- /**
571
- * @param id is the id of the label
572
- * @param steps is the list of steps that the label will perform
573
- * @param props is the properties of the label
574
- */
575
- constructor(id: string, steps: (PixiVNJsonLabelStep | (() => PixiVNJsonLabelStep))[], props?: LabelProps<LabelJson<T>>, options?: LabelJsonOptions);
576
- private _steps;
577
- get steps(): StepLabelType<T>[];
578
- get stepCount(): number;
579
- getStepById(stepId: number): StepLabelType<T> | undefined;
580
- private operationStringConvert?;
581
- private skipEmptyDialogs;
582
- getStepSha(index: number): string | undefined;
583
- private getDialogueText;
584
- private getDialogue;
585
- private getChoices;
586
- private stepConverter;
587
- }
588
-
589
- /**
590
- * Import a Pixi'VN JSON to the system.
591
- * This feature was created to give other developers the ability to create tools that can generate Pixi'VN labels or that generate Pixi'VN after extracting information from a programming language designed for writing narratives.
592
- * @param values The Pixi'VN JSON to be imported
593
- * @returns
594
- */
595
- declare function importPixiVNJson(values: PixiVNJson | string | (PixiVNJson | string)[], options?: LabelJsonOptions): Promise<void>;
596
990
 
597
- export { LabelJson, importPixiVNJson };
991
+ export type { PixiVNJsonLabelStep as P, PixiVNJsonValueSet as a, PixiVNJsonIfElse as b, PixiVNJsonOperation as c, PixiVNJsonOperationString as d, PixiVNJsonCanvasAnimate as e, PixiVNJsonUnknownEdit as f, PixiVNJsonCanvasRemove as g, PixiVNJsonCanvasEffect as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonImageContainerEdit as j, PixiVNJsonCanvasImageVideoShow as k, PixiVNJsonImageEdit as l, PixiVNJsonCanvasTextShow as m, PixiVNJsonTextEdit as n, PixiVNJsonVideoEdit as o, PixiVNJsonVideoPauseResume as p, PixiVNJsonNarration as q, PixiVNJsonSound as r, PixiVNJsonValueGet as s, PixiVNJsonArithmeticOperations as t, PixiVNJsonConditions as u, PixiVNJsonFunction as v, PixiVNJsonConditionalStatements as w, PixiVNJsonConditionalResultToCombine as x, PixiVNJsonOnlyStorageSet as y };