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