@drincs/pixi-vn 1.8.4 → 1.8.7
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/ContainerMemory-BjcfYRU7.d.cts +392 -0
- package/dist/ContainerMemory-BjcfYRU7.d.ts +392 -0
- package/dist/HistoryChoiceMenuOption-CEmjDDJH.d.cts +53 -0
- package/dist/HistoryChoiceMenuOption-CN7NkcxU.d.ts +53 -0
- package/dist/HistoryGameState-3ztYdv84.d.cts +12 -0
- package/dist/HistoryGameState-D4t2fY9x.d.ts +12 -0
- package/dist/HistoryStep-DtOryKAZ.d.cts +76 -0
- package/dist/HistoryStep-DtOryKAZ.d.ts +76 -0
- package/dist/OpenedLabel-DJby8qPc.d.ts +8 -0
- package/dist/OpenedLabel-t6PvSzaL.d.cts +8 -0
- package/dist/SoundManagerInterface-TgOPqm2L.d.cts +436 -0
- package/dist/SoundManagerInterface-TgOPqm2L.d.ts +436 -0
- package/dist/StepLabelType-CN97wZzm.d.cts +27 -0
- package/dist/StepLabelType-CN97wZzm.d.ts +27 -0
- package/dist/StorageGameState-BJy57o6K.d.ts +27 -0
- package/dist/StorageGameState-CtjNJpvE.d.cts +27 -0
- package/dist/{StoredClassModel-C9mQxPg-.d.cts → StoredClassModel-Bykjdn8S.d.cts} +1 -1
- package/dist/{StoredClassModel-upXPNQTp.d.ts → StoredClassModel-uMifeNzV.d.ts} +1 -1
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +54 -464
- package/dist/canvas.d.ts +54 -464
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.d.cts +5 -5
- package/dist/characters.d.ts +5 -5
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-Z4GZCINS.mjs → chunk-3M6A7TU2.mjs} +1 -1
- package/dist/chunk-BQRPDCUT.mjs +1 -0
- package/dist/{chunk-YCWXA3OR.mjs → chunk-IFPF4NRX.mjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +5 -114
- package/dist/core.d.ts +5 -114
- package/dist/core.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +7 -11
- package/dist/history.d.ts +7 -11
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +20 -826
- package/dist/index.d.ts +20 -826
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +1 -1
- package/dist/narration.d.cts +57 -22
- package/dist/narration.d.ts +57 -22
- package/dist/narration.mjs +1 -1
- package/dist/pixi/index.d.cts +12 -0
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +4 -435
- package/dist/sound.d.ts +4 -435
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +4 -27
- package/dist/storage.d.ts +4 -27
- package/dist/storage.mjs +1 -1
- package/dist/vite-listener.d.cts +1 -1
- package/dist/vite-listener.d.ts +1 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/package.json +1 -1
- package/dist/HistoryChoiceMenuOption-CS41KG13.d.ts +0 -182
- package/dist/HistoryChoiceMenuOption-DdwePsOm.d.cts +0 -182
- package/dist/chunk-V34PMA2H.mjs +0 -1
package/dist/narration.d.cts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
+
import { LabelProps as LabelProps$1, NarrationManagerInterface as NarrationManagerInterface$1 } from '@drincs/pixi-vn/canvas';
|
|
1
2
|
import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
|
|
2
3
|
import { a as StorageObjectType, S as StorageElementType } from './StorageElementType-C7ETezlL.cjs';
|
|
3
|
-
import { L as
|
|
4
|
-
export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-
|
|
4
|
+
import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-CEmjDDJH.cjs';
|
|
5
|
+
export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-CEmjDDJH.cjs';
|
|
6
|
+
import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-DtOryKAZ.cjs';
|
|
7
|
+
import { b as StepLabelType, S as StepLabelPropsType, a as StepLabelResultType } from './StepLabelType-CN97wZzm.cjs';
|
|
8
|
+
import { O as OpenedLabel } from './OpenedLabel-t6PvSzaL.cjs';
|
|
5
9
|
import 'microdiff';
|
|
6
10
|
|
|
11
|
+
interface ChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
|
|
12
|
+
/**
|
|
13
|
+
* Label Id to be opened when the option is selected
|
|
14
|
+
*/
|
|
15
|
+
label: LabelIdType;
|
|
16
|
+
/**
|
|
17
|
+
* Type of the label to be opened
|
|
18
|
+
*/
|
|
19
|
+
type: LabelRunModeType;
|
|
20
|
+
}
|
|
21
|
+
interface CloseChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
|
|
22
|
+
/**
|
|
23
|
+
* Type of the label to be opened
|
|
24
|
+
*/
|
|
25
|
+
type: CloseType;
|
|
26
|
+
/**
|
|
27
|
+
* If true, the current label will be closed
|
|
28
|
+
*/
|
|
29
|
+
closeCurrentLabel?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type StoredChoiceInterface = ChoiceOptionInterface | CloseChoiceOptionInterface;
|
|
32
|
+
type StoredIndexedChoiceInterface = StoredChoiceInterface & {
|
|
33
|
+
/**
|
|
34
|
+
* Is the index of the choice in the menu. It is used to identify the choice when it is selected.
|
|
35
|
+
*/
|
|
36
|
+
choiceIndex: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
7
39
|
interface LabelProps<T, StepIdType = number> {
|
|
8
40
|
/**
|
|
9
41
|
* A function executed before each `step`.
|
|
@@ -107,7 +139,7 @@ declare abstract class LabelAbstract<TLabel, TProps extends {} = {}, StepIdType
|
|
|
107
139
|
* Label is a class that contains a list of steps, which will be performed as the game continues.
|
|
108
140
|
* For Ren'py this is the equivalent of a label.
|
|
109
141
|
* @example
|
|
110
|
-
* ```
|
|
142
|
+
* ```ts
|
|
111
143
|
* const START_LABEL_ID = "StartLabel"
|
|
112
144
|
*
|
|
113
145
|
* export const startLabel = newLabel(START_LABEL_ID,
|
|
@@ -135,7 +167,7 @@ declare class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {
|
|
|
135
167
|
* @param steps is the list of steps that the label will perform
|
|
136
168
|
* @param props is the properties of the label
|
|
137
169
|
*/
|
|
138
|
-
constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>);
|
|
170
|
+
constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps$1<Label<T>>);
|
|
139
171
|
private _steps;
|
|
140
172
|
/**
|
|
141
173
|
* Get the steps of the label.
|
|
@@ -153,7 +185,7 @@ interface ChoiceMenuOptionOptions extends Omit<ChoiceInterface$1, "text" | "labe
|
|
|
153
185
|
/**
|
|
154
186
|
* Function to create a new choice menu option.
|
|
155
187
|
* @example
|
|
156
|
-
* ```
|
|
188
|
+
* ```ts
|
|
157
189
|
* newChoiceOption("Hello", HelloLabel, {})
|
|
158
190
|
* ```
|
|
159
191
|
*/
|
|
@@ -168,7 +200,7 @@ interface ChoiceMenuOptionCloseOptions extends Omit<ChoiceInterface$1, "text" |
|
|
|
168
200
|
/**
|
|
169
201
|
* Function to create a new choice menu option that will close the menu.
|
|
170
202
|
* @example
|
|
171
|
-
* ```
|
|
203
|
+
* ```ts
|
|
172
204
|
* newCloseChoiceOption("Return")
|
|
173
205
|
* ```
|
|
174
206
|
*/
|
|
@@ -266,7 +298,7 @@ interface NarrationManagerInterface {
|
|
|
266
298
|
* **Attention**: if the step index is edited or the code of step is edited, the counter will be reset.
|
|
267
299
|
*
|
|
268
300
|
* You can restart the counter in this way:
|
|
269
|
-
* ```
|
|
301
|
+
* ```ts
|
|
270
302
|
* narration.currentStepTimesCounter = 0
|
|
271
303
|
* ```
|
|
272
304
|
*/
|
|
@@ -340,7 +372,10 @@ interface NarrationManagerInterface {
|
|
|
340
372
|
*/
|
|
341
373
|
addCurrentStepToHistory(): void;
|
|
342
374
|
/**
|
|
343
|
-
* Return if can go to the next step.
|
|
375
|
+
* Return if can go to the next step. It's `false` when:
|
|
376
|
+
* - A `step` is running
|
|
377
|
+
* - The player must "make a choice"
|
|
378
|
+
* - The player must "enter a value"
|
|
344
379
|
* @returns True if can go to the next step.
|
|
345
380
|
*/
|
|
346
381
|
readonly canContinue: boolean;
|
|
@@ -351,7 +386,7 @@ interface NarrationManagerInterface {
|
|
|
351
386
|
* @param options The options.
|
|
352
387
|
* @returns StepLabelResultType or undefined.
|
|
353
388
|
* @example
|
|
354
|
-
* ```
|
|
389
|
+
* ```ts
|
|
355
390
|
* function nextOnClick() {
|
|
356
391
|
* setLoading(true)
|
|
357
392
|
* narration.continue(yourParams)
|
|
@@ -382,13 +417,13 @@ interface NarrationManagerInterface {
|
|
|
382
417
|
runNow?: boolean;
|
|
383
418
|
}) => Promise<StepLabelResultType>;
|
|
384
419
|
/**
|
|
385
|
-
* Execute the label
|
|
420
|
+
* Execute the label, add the label to the history and execute the next step of the label.
|
|
386
421
|
* @param label The label to execute or the id of the label
|
|
387
422
|
* @param props The props to pass to the label.
|
|
388
423
|
* @returns StepLabelResultType or undefined.
|
|
389
424
|
* @throws {PixiError} when the label is not found in the registered labels.
|
|
390
425
|
* @example
|
|
391
|
-
* ```
|
|
426
|
+
* ```ts
|
|
392
427
|
* narration.call(startLabel, yourParams).then((result) => {
|
|
393
428
|
* if (result) {
|
|
394
429
|
* // your code
|
|
@@ -396,7 +431,7 @@ interface NarrationManagerInterface {
|
|
|
396
431
|
* })
|
|
397
432
|
* ```
|
|
398
433
|
* @example
|
|
399
|
-
* ```
|
|
434
|
+
* ```ts
|
|
400
435
|
* // if you use it in a step label you should return the result.
|
|
401
436
|
* return narration.call(startLabel).then((result) => {
|
|
402
437
|
* return result
|
|
@@ -405,13 +440,13 @@ interface NarrationManagerInterface {
|
|
|
405
440
|
*/
|
|
406
441
|
call<T extends {} = {}>(label: LabelAbstract<any, T> | LabelIdType, props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
|
|
407
442
|
/**
|
|
408
|
-
* Execute the label,
|
|
443
|
+
* Execute the label, replace the current label in the history with the new label and execute the next step of the label.
|
|
409
444
|
* @param label The label to execute.
|
|
410
445
|
* @param props The props to pass to the label or the id of the label
|
|
411
446
|
* @returns StepLabelResultType or undefined.
|
|
412
447
|
* @throws {PixiError} when the label is not found in the registered labels.
|
|
413
448
|
* @example
|
|
414
|
-
* ```
|
|
449
|
+
* ```ts
|
|
415
450
|
* narration.jump(startLabel, yourParams).then((result) => {
|
|
416
451
|
* if (result) {
|
|
417
452
|
* // your code
|
|
@@ -419,7 +454,7 @@ interface NarrationManagerInterface {
|
|
|
419
454
|
* })
|
|
420
455
|
* ```
|
|
421
456
|
* @example
|
|
422
|
-
* ```
|
|
457
|
+
* ```ts
|
|
423
458
|
* // if you use it in a step label you should return the result.
|
|
424
459
|
* return narration.jump(startLabel).then((result) => {
|
|
425
460
|
* return result
|
|
@@ -434,7 +469,7 @@ interface NarrationManagerInterface {
|
|
|
434
469
|
* @returns
|
|
435
470
|
* @throws {PixiError} when the choice type is not `"call"`, `"jump"`, or `"close"`.
|
|
436
471
|
* @example
|
|
437
|
-
* ```
|
|
472
|
+
* ```ts
|
|
438
473
|
* narration.selectChoice(item, {
|
|
439
474
|
* navigate: navigate,
|
|
440
475
|
* // your props
|
|
@@ -462,7 +497,7 @@ interface NarrationManagerInterface {
|
|
|
462
497
|
/**
|
|
463
498
|
* The options to be shown in the game
|
|
464
499
|
* @example
|
|
465
|
-
* ```
|
|
500
|
+
* ```ts
|
|
466
501
|
* narration.choices = [
|
|
467
502
|
* newChoiceOption("Events Test", EventsTestLabel, {}),
|
|
468
503
|
* newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
|
|
@@ -477,7 +512,7 @@ interface NarrationManagerInterface {
|
|
|
477
512
|
* The options to be shown in the game
|
|
478
513
|
* @throws {PixiError} when a choice contains functions or class instances that cannot be serialized to JSON.
|
|
479
514
|
* @example
|
|
480
|
-
* ```
|
|
515
|
+
* ```ts
|
|
481
516
|
* narration.choices = [
|
|
482
517
|
* newChoiceOption("Events Test", EventsTestLabel, {}),
|
|
483
518
|
* newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
|
|
@@ -532,7 +567,7 @@ interface NarrationManagerInterface {
|
|
|
532
567
|
* You can override this interface to add your own props.
|
|
533
568
|
* @default {}
|
|
534
569
|
* @example
|
|
535
|
-
* ```
|
|
570
|
+
* ```ts
|
|
536
571
|
* // pixi-vn.d.ts
|
|
537
572
|
* declare module '@drincs/pixi-vn' {
|
|
538
573
|
* interface StepLabelProps {
|
|
@@ -551,7 +586,7 @@ interface StepLabelProps {
|
|
|
551
586
|
* You can override this interface to add your own return types.
|
|
552
587
|
* @default {}
|
|
553
588
|
* @example
|
|
554
|
-
* ```
|
|
589
|
+
* ```ts
|
|
555
590
|
* // pixi-vn.d.ts
|
|
556
591
|
* declare module '@drincs/pixi-vn' {
|
|
557
592
|
* interface StepLabelResult {
|
|
@@ -669,6 +704,6 @@ type InputInfo = {
|
|
|
669
704
|
type?: string;
|
|
670
705
|
};
|
|
671
706
|
|
|
672
|
-
declare const narration: NarrationManagerInterface;
|
|
707
|
+
declare const narration: NarrationManagerInterface$1;
|
|
673
708
|
|
|
674
|
-
export { type ChoiceInterface, ChoiceOptionInterface, CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, StoredChoiceInterface, StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
|
|
709
|
+
export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
|
package/dist/narration.d.ts
CHANGED
|
@@ -1,9 +1,41 @@
|
|
|
1
|
+
import { LabelProps as LabelProps$1, NarrationManagerInterface as NarrationManagerInterface$1 } from '@drincs/pixi-vn/canvas';
|
|
1
2
|
import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
|
|
2
3
|
import { a as StorageObjectType, S as StorageElementType } from './StorageElementType-C7ETezlL.js';
|
|
3
|
-
import { L as
|
|
4
|
-
export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-
|
|
4
|
+
import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-CN7NkcxU.js';
|
|
5
|
+
export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-CN7NkcxU.js';
|
|
6
|
+
import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-DtOryKAZ.js';
|
|
7
|
+
import { b as StepLabelType, S as StepLabelPropsType, a as StepLabelResultType } from './StepLabelType-CN97wZzm.js';
|
|
8
|
+
import { O as OpenedLabel } from './OpenedLabel-DJby8qPc.js';
|
|
5
9
|
import 'microdiff';
|
|
6
10
|
|
|
11
|
+
interface ChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
|
|
12
|
+
/**
|
|
13
|
+
* Label Id to be opened when the option is selected
|
|
14
|
+
*/
|
|
15
|
+
label: LabelIdType;
|
|
16
|
+
/**
|
|
17
|
+
* Type of the label to be opened
|
|
18
|
+
*/
|
|
19
|
+
type: LabelRunModeType;
|
|
20
|
+
}
|
|
21
|
+
interface CloseChoiceOptionInterface extends Omit<ChoiceInterface$1, "label" | "type" | "closeCurrentLabel"> {
|
|
22
|
+
/**
|
|
23
|
+
* Type of the label to be opened
|
|
24
|
+
*/
|
|
25
|
+
type: CloseType;
|
|
26
|
+
/**
|
|
27
|
+
* If true, the current label will be closed
|
|
28
|
+
*/
|
|
29
|
+
closeCurrentLabel?: boolean;
|
|
30
|
+
}
|
|
31
|
+
type StoredChoiceInterface = ChoiceOptionInterface | CloseChoiceOptionInterface;
|
|
32
|
+
type StoredIndexedChoiceInterface = StoredChoiceInterface & {
|
|
33
|
+
/**
|
|
34
|
+
* Is the index of the choice in the menu. It is used to identify the choice when it is selected.
|
|
35
|
+
*/
|
|
36
|
+
choiceIndex: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
7
39
|
interface LabelProps<T, StepIdType = number> {
|
|
8
40
|
/**
|
|
9
41
|
* A function executed before each `step`.
|
|
@@ -107,7 +139,7 @@ declare abstract class LabelAbstract<TLabel, TProps extends {} = {}, StepIdType
|
|
|
107
139
|
* Label is a class that contains a list of steps, which will be performed as the game continues.
|
|
108
140
|
* For Ren'py this is the equivalent of a label.
|
|
109
141
|
* @example
|
|
110
|
-
* ```
|
|
142
|
+
* ```ts
|
|
111
143
|
* const START_LABEL_ID = "StartLabel"
|
|
112
144
|
*
|
|
113
145
|
* export const startLabel = newLabel(START_LABEL_ID,
|
|
@@ -135,7 +167,7 @@ declare class Label<T extends {} = {}> extends LabelAbstract<Label<T>, T> {
|
|
|
135
167
|
* @param steps is the list of steps that the label will perform
|
|
136
168
|
* @param props is the properties of the label
|
|
137
169
|
*/
|
|
138
|
-
constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps<Label<T>>);
|
|
170
|
+
constructor(id: LabelIdType, steps: StepLabelType<T>[] | (() => StepLabelType<T>[]), props?: LabelProps$1<Label<T>>);
|
|
139
171
|
private _steps;
|
|
140
172
|
/**
|
|
141
173
|
* Get the steps of the label.
|
|
@@ -153,7 +185,7 @@ interface ChoiceMenuOptionOptions extends Omit<ChoiceInterface$1, "text" | "labe
|
|
|
153
185
|
/**
|
|
154
186
|
* Function to create a new choice menu option.
|
|
155
187
|
* @example
|
|
156
|
-
* ```
|
|
188
|
+
* ```ts
|
|
157
189
|
* newChoiceOption("Hello", HelloLabel, {})
|
|
158
190
|
* ```
|
|
159
191
|
*/
|
|
@@ -168,7 +200,7 @@ interface ChoiceMenuOptionCloseOptions extends Omit<ChoiceInterface$1, "text" |
|
|
|
168
200
|
/**
|
|
169
201
|
* Function to create a new choice menu option that will close the menu.
|
|
170
202
|
* @example
|
|
171
|
-
* ```
|
|
203
|
+
* ```ts
|
|
172
204
|
* newCloseChoiceOption("Return")
|
|
173
205
|
* ```
|
|
174
206
|
*/
|
|
@@ -266,7 +298,7 @@ interface NarrationManagerInterface {
|
|
|
266
298
|
* **Attention**: if the step index is edited or the code of step is edited, the counter will be reset.
|
|
267
299
|
*
|
|
268
300
|
* You can restart the counter in this way:
|
|
269
|
-
* ```
|
|
301
|
+
* ```ts
|
|
270
302
|
* narration.currentStepTimesCounter = 0
|
|
271
303
|
* ```
|
|
272
304
|
*/
|
|
@@ -340,7 +372,10 @@ interface NarrationManagerInterface {
|
|
|
340
372
|
*/
|
|
341
373
|
addCurrentStepToHistory(): void;
|
|
342
374
|
/**
|
|
343
|
-
* Return if can go to the next step.
|
|
375
|
+
* Return if can go to the next step. It's `false` when:
|
|
376
|
+
* - A `step` is running
|
|
377
|
+
* - The player must "make a choice"
|
|
378
|
+
* - The player must "enter a value"
|
|
344
379
|
* @returns True if can go to the next step.
|
|
345
380
|
*/
|
|
346
381
|
readonly canContinue: boolean;
|
|
@@ -351,7 +386,7 @@ interface NarrationManagerInterface {
|
|
|
351
386
|
* @param options The options.
|
|
352
387
|
* @returns StepLabelResultType or undefined.
|
|
353
388
|
* @example
|
|
354
|
-
* ```
|
|
389
|
+
* ```ts
|
|
355
390
|
* function nextOnClick() {
|
|
356
391
|
* setLoading(true)
|
|
357
392
|
* narration.continue(yourParams)
|
|
@@ -382,13 +417,13 @@ interface NarrationManagerInterface {
|
|
|
382
417
|
runNow?: boolean;
|
|
383
418
|
}) => Promise<StepLabelResultType>;
|
|
384
419
|
/**
|
|
385
|
-
* Execute the label
|
|
420
|
+
* Execute the label, add the label to the history and execute the next step of the label.
|
|
386
421
|
* @param label The label to execute or the id of the label
|
|
387
422
|
* @param props The props to pass to the label.
|
|
388
423
|
* @returns StepLabelResultType or undefined.
|
|
389
424
|
* @throws {PixiError} when the label is not found in the registered labels.
|
|
390
425
|
* @example
|
|
391
|
-
* ```
|
|
426
|
+
* ```ts
|
|
392
427
|
* narration.call(startLabel, yourParams).then((result) => {
|
|
393
428
|
* if (result) {
|
|
394
429
|
* // your code
|
|
@@ -396,7 +431,7 @@ interface NarrationManagerInterface {
|
|
|
396
431
|
* })
|
|
397
432
|
* ```
|
|
398
433
|
* @example
|
|
399
|
-
* ```
|
|
434
|
+
* ```ts
|
|
400
435
|
* // if you use it in a step label you should return the result.
|
|
401
436
|
* return narration.call(startLabel).then((result) => {
|
|
402
437
|
* return result
|
|
@@ -405,13 +440,13 @@ interface NarrationManagerInterface {
|
|
|
405
440
|
*/
|
|
406
441
|
call<T extends {} = {}>(label: LabelAbstract<any, T> | LabelIdType, props: StepLabelPropsType<T>): Promise<StepLabelResultType>;
|
|
407
442
|
/**
|
|
408
|
-
* Execute the label,
|
|
443
|
+
* Execute the label, replace the current label in the history with the new label and execute the next step of the label.
|
|
409
444
|
* @param label The label to execute.
|
|
410
445
|
* @param props The props to pass to the label or the id of the label
|
|
411
446
|
* @returns StepLabelResultType or undefined.
|
|
412
447
|
* @throws {PixiError} when the label is not found in the registered labels.
|
|
413
448
|
* @example
|
|
414
|
-
* ```
|
|
449
|
+
* ```ts
|
|
415
450
|
* narration.jump(startLabel, yourParams).then((result) => {
|
|
416
451
|
* if (result) {
|
|
417
452
|
* // your code
|
|
@@ -419,7 +454,7 @@ interface NarrationManagerInterface {
|
|
|
419
454
|
* })
|
|
420
455
|
* ```
|
|
421
456
|
* @example
|
|
422
|
-
* ```
|
|
457
|
+
* ```ts
|
|
423
458
|
* // if you use it in a step label you should return the result.
|
|
424
459
|
* return narration.jump(startLabel).then((result) => {
|
|
425
460
|
* return result
|
|
@@ -434,7 +469,7 @@ interface NarrationManagerInterface {
|
|
|
434
469
|
* @returns
|
|
435
470
|
* @throws {PixiError} when the choice type is not `"call"`, `"jump"`, or `"close"`.
|
|
436
471
|
* @example
|
|
437
|
-
* ```
|
|
472
|
+
* ```ts
|
|
438
473
|
* narration.selectChoice(item, {
|
|
439
474
|
* navigate: navigate,
|
|
440
475
|
* // your props
|
|
@@ -462,7 +497,7 @@ interface NarrationManagerInterface {
|
|
|
462
497
|
/**
|
|
463
498
|
* The options to be shown in the game
|
|
464
499
|
* @example
|
|
465
|
-
* ```
|
|
500
|
+
* ```ts
|
|
466
501
|
* narration.choices = [
|
|
467
502
|
* newChoiceOption("Events Test", EventsTestLabel, {}),
|
|
468
503
|
* newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
|
|
@@ -477,7 +512,7 @@ interface NarrationManagerInterface {
|
|
|
477
512
|
* The options to be shown in the game
|
|
478
513
|
* @throws {PixiError} when a choice contains functions or class instances that cannot be serialized to JSON.
|
|
479
514
|
* @example
|
|
480
|
-
* ```
|
|
515
|
+
* ```ts
|
|
481
516
|
* narration.choices = [
|
|
482
517
|
* newChoiceOption("Events Test", EventsTestLabel, {}),
|
|
483
518
|
* newChoiceOption("Show Image Test", ShowImageTest, { image: "imageId" }, "call"),
|
|
@@ -532,7 +567,7 @@ interface NarrationManagerInterface {
|
|
|
532
567
|
* You can override this interface to add your own props.
|
|
533
568
|
* @default {}
|
|
534
569
|
* @example
|
|
535
|
-
* ```
|
|
570
|
+
* ```ts
|
|
536
571
|
* // pixi-vn.d.ts
|
|
537
572
|
* declare module '@drincs/pixi-vn' {
|
|
538
573
|
* interface StepLabelProps {
|
|
@@ -551,7 +586,7 @@ interface StepLabelProps {
|
|
|
551
586
|
* You can override this interface to add your own return types.
|
|
552
587
|
* @default {}
|
|
553
588
|
* @example
|
|
554
|
-
* ```
|
|
589
|
+
* ```ts
|
|
555
590
|
* // pixi-vn.d.ts
|
|
556
591
|
* declare module '@drincs/pixi-vn' {
|
|
557
592
|
* interface StepLabelResult {
|
|
@@ -669,6 +704,6 @@ type InputInfo = {
|
|
|
669
704
|
type?: string;
|
|
670
705
|
};
|
|
671
706
|
|
|
672
|
-
declare const narration: NarrationManagerInterface;
|
|
707
|
+
declare const narration: NarrationManagerInterface$1;
|
|
673
708
|
|
|
674
|
-
export { type ChoiceInterface, ChoiceOptionInterface, CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, StoredChoiceInterface, StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
|
|
709
|
+
export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
|
package/dist/narration.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-YCWXA3OR.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {e,d,c,f,g as g$1}from'./chunk-Z4GZCINS.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var I=new e({cacheSize:10}),O;(a=>{function y(p){let u=I.get(p);if(!u){f.error(`Label "${p}" not found`);return}return u}a.get=y;function e(p){if(Array.isArray(p)){p.forEach(u=>{e(u);});return}I.has(p.id)&&f.info(`Label "${p.id}" already exists, it will be overwritten`),I.set(p.id,p);}a.add=e;function t(){return Array.from(I.values())}a.values=t;function r(p){return I.has(p)}a.has=r;function n(){return Array.from(I.keys())}a.keys=n;})(O||(O={}));var L=O;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return f.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return f.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let p=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!==p)&&(u[n$1][r]={stepSha1:p}),u[n$1][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n$1=r+e,a=i.currentLabelId;if(!a||r===null){f.error("currentLabelId or currentLabelStepIndex is null");return}let p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};p[a]||(p[a]={}),p[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,p);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return f.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(p=>p===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let p=i.getCurrentStepTimesCounterData(n);if(!p)return;let u=p.usedRandomNumbers||{},S=Array.from({length:t-e+1},(_,w)=>w+e).filter(_=>!u[`${e}-${t}`]?.includes(_));if(S.length===0)return;let m=Math.floor(Math.random()*S.length),b=S[m];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),p.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,p),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n$1=i.currentLabelId;if(!n$1||t===null){f.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return g$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=g$1(e);}static get originalOpenedLabels(){return g$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=g$1(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,p=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);p<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[p].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;var R=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,p,u,S=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let m=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:p,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:m};o.originalOpenedLabels=m,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){f.warn("No label to close");return}if(!this.currentLabel){f.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(f.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&f.warn("The player must make a choice"),false):this.isRequiredInput?(t&&f.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){f.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){f.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(p){throw f.error("Error continuing",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});f.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){f.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){f.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){f.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e);return}let p=a.getStepById(n);if(!p){f.error("step not found");return}let u=a.getStepSha(n);u||(f.warn("stepSha not found, setting to ERROR"),u="error");let S,m;try{S=await p(e,{labelId:a.id});}catch(b){f.error("Error running step",b),m=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let _=b[0];S=await this.selectChoice(_,e);}}catch(b){f.error("Error auto-selecting choice",b),m||(m=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(f.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){f.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){f.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){f.warn("Error running onStepEnd",b);}return m&&this.onStepError&&await this.onStepError(m,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;f.error("currentLabelId not found");}}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let p;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw f.error("Error calling label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let p;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw f.error("Error jumping to label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async selectChoice(e,t){this.choices=void 0;let r=e.type;switch(r){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw f.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw f.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e.choiceIndex=="number"&&(r=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e,t)=>{try{await GameUnifier.runOnError(e,t);}catch(r){f.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,e.character=e.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,g$1({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw f.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,p)=>({...a,choiceIndex:p})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,p)=>a.oneTime&&n?.includes(p)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,g$1(e)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw f.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:g$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):f.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?o._stepCounter=e.stepCounter:f.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){f.error("Error running onLoadingLabel",r);}}catch(r){f.error("Error importing data",r);}}};function Y(y,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:y,type:r?.type||"call"}}var x="close";function V(y,e){return {...e,type:x,text:y}}var N=c(a(),1);var g=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var E=class extends g{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return f.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,N.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return f.warn("stepSha not found, setting to ERROR",r),"error"}}};function A(y,e,t){let r=new E(y,e,t);return L.add(r),r}var he=new R;
|
|
1
|
+
import {a}from'./chunk-IFPF4NRX.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {e,d,c,f,g as g$1}from'./chunk-3M6A7TU2.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var I=new e({cacheSize:10}),M;(a=>{function y(p){let u=I.get(p);if(!u){f.error(`Label "${p}" not found`);return}return u}a.get=y;function e(p){if(Array.isArray(p)){p.forEach(u=>{e(u);});return}I.has(p.id)&&f.info(`Label "${p.id}" already exists, it will be overwritten`),I.set(p.id,p);}a.add=e;function t(){return Array.from(I.values())}a.values=t;function r(p){return I.has(p)}a.has=r;function n(){return Array.from(I.keys())}a.keys=n;})(M||={});var L=M;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return f.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return f.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let p=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!==p)&&(u[n$1][r]={stepSha1:p}),u[n$1][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n$1=r+e,a=i.currentLabelId;if(!a||r===null){f.error("currentLabelId or currentLabelStepIndex is null");return}let p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};p[a]||(p[a]={}),p[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,p);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return f.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(p=>p===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let p=i.getCurrentStepTimesCounterData(n);if(!p)return;let u=p.usedRandomNumbers||{},S=Array.from({length:t-e+1},(_,w)=>w+e).filter(_=>!u[`${e}-${t}`]?.includes(_));if(S.length===0)return;let m=Math.floor(Math.random()*S.length),b=S[m];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),p.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,p),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n$1=i.currentLabelId;if(!n$1||t===null){f.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return g$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=g$1(e);}static get originalOpenedLabels(){return g$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=g$1(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,p=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);p<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[p].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;var R=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,p,u,S=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let m=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:p,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:m};o.originalOpenedLabels=m,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){f.warn("No label to close");return}if(!this.currentLabel){f.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(f.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&f.warn("The player must make a choice"),false):this.isRequiredInput?(t&&f.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){f.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){f.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(p){throw f.error("Error continuing",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});f.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){f.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){f.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){f.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e);return}let p=a.getStepById(n);if(!p){f.error("step not found");return}let u=a.getStepSha(n);u||(f.warn("stepSha not found, setting to ERROR"),u="error");let S,m;try{S=await p(e,{labelId:a.id});}catch(b){f.error("Error running step",b),m=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let _=b[0];S=await this.selectChoice(_,e);}}catch(b){f.error("Error auto-selecting choice",b),m||(m=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(f.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){f.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){f.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){f.warn("Error running onStepEnd",b);}return m&&this.onStepError&&await this.onStepError(m,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;f.error("currentLabelId not found");}}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let p;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw f.error("Error calling label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let p;try{let u=L.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw f.error("Error jumping to label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async selectChoice(e,t){this.choices=void 0;let r=e.type;switch(r){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw f.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw f.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e.choiceIndex=="number"&&(r=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e,t)=>{try{await GameUnifier.runOnError(e,t);}catch(r){f.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,e.character=e.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,g$1({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw f.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,p)=>({...a,choiceIndex:p})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,p)=>a.oneTime&&n?.includes(p)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,g$1(e)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw f.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:g$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):f.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?o._stepCounter=e.stepCounter:f.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){f.error("Error running onLoadingLabel",r);}}catch(r){f.error("Error importing data",r);}}};function Y(y,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:y,type:r?.type||"call"}}var x="close";function V(y,e){return {...e,type:x,text:y}}var N=c(a(),1);var g=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var E=class extends g{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return f.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,N.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return f.warn("stepSha not found, setting to ERROR",r),"error"}}};function A(y,e,t){let r=new E(y,e,t);return L.add(r),r}var he=new R;
|
|
2
2
|
export{E as Label,g as LabelAbstract,o as NarrationManagerStatic,L as RegisteredLabels,he as narration,Y as newChoiceOption,V as newCloseChoiceOption,A as newLabel};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as bundler from 'pixi.js';
|
|
2
|
+
export * from 'pixi.js';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
const __VITE__: boolean | undefined;
|
|
6
|
+
const __ROLLUP_PLUGIN__: boolean | undefined;
|
|
7
|
+
const __webpack_require__: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const impl: typeof bundler;
|
|
11
|
+
|
|
12
|
+
export { impl as default };
|