@drincs/pixi-vn-json 1.7.3 → 1.7.5
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/importer.cjs +1 -3
- package/dist/importer.d.cts +550 -4
- package/dist/importer.d.ts +550 -4
- package/dist/importer.mjs +1 -3
- package/dist/translator.d.cts +548 -2
- package/dist/translator.d.ts +548 -2
- package/package.json +3 -2
- package/dist/PixiVNJsonLabelStep-CNFnTNr1.d.cts +0 -550
- package/dist/PixiVNJsonLabelStep-CNFnTNr1.d.ts +0 -550
package/dist/importer.d.ts
CHANGED
|
@@ -1,6 +1,552 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StepLabelPropsType, LabelAbstract, LabelProps, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
3
|
-
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, KeyframesType, AnimationOptions, UPDATE_PRIORITY, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions, ShakeEffectProps, FadeAlphaTickerProps, MoveTickerProps, RotateTickerProps, ZoomTickerProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, ContainerOptions, ContainerMemory, SoundPlayOptions, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
|
+
import { StepLabelPropsType as StepLabelPropsType$1, LabelAbstract, LabelProps, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
3
|
+
|
|
4
|
+
type PixiVNJsonStepSwitchElementType<Then> = Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>;
|
|
5
|
+
type PixiVNJsonStepSwitchElementsType<Then> = PixiVNJsonStepSwitchElementType<Then>[] | PixiVNJsonConditionalStatements<Then[]>;
|
|
6
|
+
interface PixiVNJsonRandom<Then> {
|
|
7
|
+
type: "stepswitch";
|
|
8
|
+
choiceType: "random";
|
|
9
|
+
elements: PixiVNJsonStepSwitchElementsType<Then>;
|
|
10
|
+
}
|
|
11
|
+
interface PixiVNJsonSequentialRandom<Then> {
|
|
12
|
+
type: "stepswitch";
|
|
13
|
+
choiceType: "sequentialrandom";
|
|
14
|
+
elements: PixiVNJsonStepSwitchElementsType<Then>;
|
|
15
|
+
/**
|
|
16
|
+
* When the sequential ends, what should be the value? If undefined, it will return undefined.
|
|
17
|
+
* If "lastItem", it will return the last item in the array.
|
|
18
|
+
*/
|
|
19
|
+
end: undefined | "lastItem";
|
|
20
|
+
/**
|
|
21
|
+
* The subId is used for manager nested switches
|
|
22
|
+
*/
|
|
23
|
+
nestedId?: string;
|
|
24
|
+
}
|
|
25
|
+
interface PixiVNJsonSequential<Then> {
|
|
26
|
+
type: "stepswitch";
|
|
27
|
+
choiceType: "sequential";
|
|
28
|
+
elements: PixiVNJsonStepSwitchElementsType<Then>;
|
|
29
|
+
/**
|
|
30
|
+
* When the sequential ends, what should be the value? If undefined, it will return undefined.
|
|
31
|
+
* If "lastItem", it will return the last item in the array.
|
|
32
|
+
*/
|
|
33
|
+
end: undefined | "lastItem";
|
|
34
|
+
/**
|
|
35
|
+
* The subId is used for manager nested switches
|
|
36
|
+
*/
|
|
37
|
+
nestedId?: string;
|
|
38
|
+
}
|
|
39
|
+
interface PixiVNJsonLoop<Then> {
|
|
40
|
+
type: "stepswitch";
|
|
41
|
+
choiceType: "loop";
|
|
42
|
+
elements: PixiVNJsonStepSwitchElementsType<Then>;
|
|
43
|
+
nestedId?: string;
|
|
44
|
+
}
|
|
45
|
+
type PixiVNJsonStepSwitch<Then> = PixiVNJsonRandom<Then> | PixiVNJsonSequential<Then> | PixiVNJsonLoop<Then> | PixiVNJsonSequentialRandom<Then>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This element is used in case a {@link PixiVNJsonConditionalStatements} gives a result that must be combined with another calculated through other {@link PixiVNJsonConditionalStatements}.
|
|
49
|
+
* in case this possibility is not managed, it will be taken into consideration {@link PixiVNJsonConditionalResultToCombine.firstItem}
|
|
50
|
+
*/
|
|
51
|
+
type PixiVNJsonConditionalResultToCombine<T> = {
|
|
52
|
+
type: "resulttocombine";
|
|
53
|
+
/**
|
|
54
|
+
* This variable is interpreted differently by Pixi'VN depending on the value
|
|
55
|
+
*/
|
|
56
|
+
combine: "cross" | "union";
|
|
57
|
+
firstItem?: T;
|
|
58
|
+
secondConditionalItem?: PixiVNJsonStepSwitchElementType<T>[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type PixiVNJsonStorageGet = {
|
|
62
|
+
type: "value";
|
|
63
|
+
storageOperationType: "get";
|
|
64
|
+
/**
|
|
65
|
+
* Key of the storage
|
|
66
|
+
*/
|
|
67
|
+
key: string;
|
|
68
|
+
/**
|
|
69
|
+
* Type of the storage, if it is a flagStorage or a storage.
|
|
70
|
+
* If it is a flagStorage, the value will be get with the function {@link getFlag}
|
|
71
|
+
*/
|
|
72
|
+
storageType: "storage" | "flagStorage" | "tempstorage";
|
|
73
|
+
};
|
|
74
|
+
type PixiVNJsonParamGet = {
|
|
75
|
+
type: "value";
|
|
76
|
+
storageOperationType: "get";
|
|
77
|
+
/**
|
|
78
|
+
* Key of the storage
|
|
79
|
+
*/
|
|
80
|
+
key: number;
|
|
81
|
+
storageType: "params";
|
|
82
|
+
};
|
|
83
|
+
type PixiVNJsonLabelGet = {
|
|
84
|
+
type: "value";
|
|
85
|
+
storageOperationType: "get";
|
|
86
|
+
/**
|
|
87
|
+
* Id of the label
|
|
88
|
+
*/
|
|
89
|
+
label: string;
|
|
90
|
+
/**
|
|
91
|
+
* If it is a label, the value will be get with the function {@link narration.getTimesLabelOpened}
|
|
92
|
+
*/
|
|
93
|
+
storageType: "label";
|
|
94
|
+
};
|
|
95
|
+
type PixiVNJsonChoiceGet = {
|
|
96
|
+
type: "value";
|
|
97
|
+
storageOperationType: "get";
|
|
98
|
+
/**
|
|
99
|
+
* index of the choice
|
|
100
|
+
*/
|
|
101
|
+
index: number;
|
|
102
|
+
/**
|
|
103
|
+
* If it is a choice, the value will be get with the function {@link narration.getTimesChoiceOpened}
|
|
104
|
+
*/
|
|
105
|
+
storageType: "choice";
|
|
106
|
+
};
|
|
107
|
+
type PixiVNJsonLogicGet = {
|
|
108
|
+
type: "value";
|
|
109
|
+
storageOperationType: "get";
|
|
110
|
+
operation: PixiVNJsonArithmeticOperations | PixiVNJsonConditions;
|
|
111
|
+
storageType: "logic";
|
|
112
|
+
};
|
|
113
|
+
type PixiVNJsonValueGet = PixiVNJsonStorageGet | PixiVNJsonParamGet | PixiVNJsonLabelGet | PixiVNJsonChoiceGet | PixiVNJsonLogicGet;
|
|
114
|
+
type PixiVNJsonOnlyStorageSet = {
|
|
115
|
+
type: "value";
|
|
116
|
+
storageOperationType: "set";
|
|
117
|
+
/**
|
|
118
|
+
* Key of the storage
|
|
119
|
+
*/
|
|
120
|
+
key: string;
|
|
121
|
+
/**
|
|
122
|
+
* Value to be set in the storage
|
|
123
|
+
*/
|
|
124
|
+
value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType>;
|
|
125
|
+
/**
|
|
126
|
+
* Type of the storage, if it is a flagStorage or a storage.
|
|
127
|
+
*/
|
|
128
|
+
storageType: "storage" | "tempstorage";
|
|
129
|
+
};
|
|
130
|
+
type PixiVNJsonOnlyParamSet = {
|
|
131
|
+
type: "value";
|
|
132
|
+
storageOperationType: "set";
|
|
133
|
+
/**
|
|
134
|
+
* Key of the storage
|
|
135
|
+
*/
|
|
136
|
+
key: number;
|
|
137
|
+
/**
|
|
138
|
+
* Value to be set in the storage
|
|
139
|
+
*/
|
|
140
|
+
value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType>;
|
|
141
|
+
storageType: "params";
|
|
142
|
+
};
|
|
143
|
+
type PixiVNJsonFlagSet = {
|
|
144
|
+
type: "value";
|
|
145
|
+
storageOperationType: "set";
|
|
146
|
+
/**
|
|
147
|
+
* Key of the storage
|
|
148
|
+
*/
|
|
149
|
+
key: string;
|
|
150
|
+
/**
|
|
151
|
+
* Value to be set in the storage
|
|
152
|
+
*/
|
|
153
|
+
value: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Type of the storage, if it is a flagStorage or a storage.
|
|
156
|
+
*/
|
|
157
|
+
storageType: "flagStorage";
|
|
158
|
+
};
|
|
159
|
+
type PixiVNJsonValueSet = PixiVNJsonOnlyStorageSet | PixiVNJsonFlagSet | PixiVNJsonOnlyParamSet;
|
|
160
|
+
|
|
161
|
+
interface PixiVNJsonArithmeticOperationsArithmetic {
|
|
162
|
+
type: "arithmetic";
|
|
163
|
+
/**
|
|
164
|
+
* Left value of the arithmetic operation
|
|
165
|
+
*/
|
|
166
|
+
leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
|
|
167
|
+
/**
|
|
168
|
+
* Right value of the arithmetic operation
|
|
169
|
+
*/
|
|
170
|
+
rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
|
|
171
|
+
/**
|
|
172
|
+
* Operator of the arithmetic operation
|
|
173
|
+
*/
|
|
174
|
+
operator: "*" | "/" | "+" | "-" | "%" | "POW" | "RANDOM";
|
|
175
|
+
}
|
|
176
|
+
interface PixiVNJsonArithmeticOperationsArithmeticSingle {
|
|
177
|
+
type: "arithmeticsingle";
|
|
178
|
+
/**
|
|
179
|
+
* Left value of the arithmetic operation
|
|
180
|
+
*/
|
|
181
|
+
leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditionalStatements<StorageElementType | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations>;
|
|
182
|
+
/**
|
|
183
|
+
* Operator of the arithmetic operation
|
|
184
|
+
*/
|
|
185
|
+
operator: "INT" | "FLOOR" | "FLOAT";
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Arithmetic operations for the PixiVNJson
|
|
189
|
+
*/
|
|
190
|
+
type PixiVNJsonArithmeticOperations = PixiVNJsonArithmeticOperationsArithmeticSingle | PixiVNJsonArithmeticOperationsArithmetic;
|
|
191
|
+
|
|
192
|
+
type PixiVNJsonUnionConditionAndOr = {
|
|
193
|
+
type: "union";
|
|
194
|
+
conditions: PixiVNJsonConditions[];
|
|
195
|
+
unionType: "and" | "or";
|
|
196
|
+
};
|
|
197
|
+
type PixiVNJsonUnionConditionNot = {
|
|
198
|
+
type: "union";
|
|
199
|
+
condition: PixiVNJsonConditions;
|
|
200
|
+
unionType: "not";
|
|
201
|
+
};
|
|
202
|
+
type PixiVNJsonUnionCondition = PixiVNJsonUnionConditionAndOr | PixiVNJsonUnionConditionNot;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Comparation for PixiVNJson.
|
|
206
|
+
* In this comparation, the values to be converted to string and compared.
|
|
207
|
+
*/
|
|
208
|
+
type PixiVNJsonComparation = {
|
|
209
|
+
type: "compare";
|
|
210
|
+
/**
|
|
211
|
+
* Left value of the comparation
|
|
212
|
+
*/
|
|
213
|
+
leftValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
|
|
214
|
+
/**
|
|
215
|
+
* Right value of the comparation
|
|
216
|
+
*/
|
|
217
|
+
rightValue: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions;
|
|
218
|
+
/**
|
|
219
|
+
* Operator of the comparation
|
|
220
|
+
*/
|
|
221
|
+
operator: "==" | "!=" | "<" | "<=" | ">" | ">=" | "CONTAINS";
|
|
222
|
+
};
|
|
223
|
+
type PixiVNJsonValueCondition = StorageElementType | PixiVNJsonValueGet;
|
|
224
|
+
/**
|
|
225
|
+
* Conditions for PixiVNJson
|
|
226
|
+
*/
|
|
227
|
+
type PixiVNJsonConditions = PixiVNJsonComparation | PixiVNJsonValueCondition | PixiVNJsonUnionCondition | PixiVNJsonArithmeticOperations;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* If-Else condition for PixiVNJson
|
|
231
|
+
*/
|
|
232
|
+
interface PixiVNJsonIfElse<Then> {
|
|
233
|
+
type: "ifelse";
|
|
234
|
+
/**
|
|
235
|
+
* The list of conditions to be checked.
|
|
236
|
+
*/
|
|
237
|
+
condition: PixiVNJsonConditions;
|
|
238
|
+
/**
|
|
239
|
+
* The value to be returned if the condition is true.
|
|
240
|
+
*/
|
|
241
|
+
then: Then | PixiVNJsonIfElse<Then>;
|
|
242
|
+
/**
|
|
243
|
+
* The value to be returned if the condition is false.
|
|
244
|
+
*/
|
|
245
|
+
else?: Then | PixiVNJsonIfElse<Then>;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
type PixiVNJsonConditionalStatements<Then> = PixiVNJsonStepSwitch<Then> | PixiVNJsonIfElse<Then | PixiVNJsonConditionalStatements<Then> | PixiVNJsonConditionalResultToCombine<Then>>;
|
|
249
|
+
|
|
250
|
+
type PixiVNJsonAnimateBase<T extends CanvasBaseInterface<any>> = {
|
|
251
|
+
type: "animate";
|
|
252
|
+
alias: string | string[];
|
|
253
|
+
keyframes: KeyframesType<T>;
|
|
254
|
+
options?: AnimationOptions;
|
|
255
|
+
priority?: UPDATE_PRIORITY;
|
|
256
|
+
};
|
|
257
|
+
type PixiVNJsonAnimateSequence<T extends CanvasBaseInterface<any>> = {
|
|
258
|
+
type: "animate-sequence";
|
|
259
|
+
alias: string;
|
|
260
|
+
sequence: (ObjectSegment<T> | ObjectSegmentWithTransition<T>)[];
|
|
261
|
+
options?: SequenceOptions;
|
|
262
|
+
priority?: UPDATE_PRIORITY;
|
|
263
|
+
};
|
|
264
|
+
type PixiVNJsonCanvasAnimate<T extends CanvasBaseInterface<any> = ImageSprite> = PixiVNJsonAnimateBase<T> | PixiVNJsonAnimateSequence<T>;
|
|
265
|
+
|
|
266
|
+
type PixiVNJsonEffectShake = {
|
|
267
|
+
type: "shake";
|
|
268
|
+
alias: string;
|
|
269
|
+
props: ShakeEffectProps;
|
|
270
|
+
priority?: UPDATE_PRIORITY;
|
|
271
|
+
};
|
|
272
|
+
type PixiVNJsonCanvasEffect = PixiVNJsonEffectShake;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @deprecated
|
|
276
|
+
*/
|
|
277
|
+
type PixiVNJsonTickerFade = {
|
|
278
|
+
type: "fade";
|
|
279
|
+
alias: string | string[];
|
|
280
|
+
duration?: number;
|
|
281
|
+
props: FadeAlphaTickerProps;
|
|
282
|
+
priority?: UPDATE_PRIORITY;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* @deprecated
|
|
286
|
+
*/
|
|
287
|
+
type PixiVNJsonTickerMove = {
|
|
288
|
+
type: "move";
|
|
289
|
+
alias: string | string[];
|
|
290
|
+
duration?: number;
|
|
291
|
+
props: MoveTickerProps;
|
|
292
|
+
priority?: UPDATE_PRIORITY;
|
|
293
|
+
};
|
|
294
|
+
/**
|
|
295
|
+
* @deprecated
|
|
296
|
+
*/
|
|
297
|
+
type PixiVNJsonTickerRotate = {
|
|
298
|
+
type: "rotate";
|
|
299
|
+
alias: string | string[];
|
|
300
|
+
duration?: number;
|
|
301
|
+
props: RotateTickerProps;
|
|
302
|
+
priority?: UPDATE_PRIORITY;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* @deprecated
|
|
306
|
+
*/
|
|
307
|
+
type PixiVNJsonTickerZoom = {
|
|
308
|
+
type: "zoom";
|
|
309
|
+
alias: string | string[];
|
|
310
|
+
duration?: number;
|
|
311
|
+
props: ZoomTickerProps;
|
|
312
|
+
priority?: UPDATE_PRIORITY;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* @deprecated
|
|
316
|
+
*/
|
|
317
|
+
type PixiVNJsonCanvasTicker = PixiVNJsonTickerFade | PixiVNJsonTickerMove | PixiVNJsonTickerRotate | PixiVNJsonTickerZoom;
|
|
318
|
+
|
|
319
|
+
type DissolveTransition = {
|
|
320
|
+
type: "dissolve";
|
|
321
|
+
props?: ShowWithDissolveTransitionProps;
|
|
322
|
+
priority?: UPDATE_PRIORITY;
|
|
323
|
+
};
|
|
324
|
+
type FadeTransition = {
|
|
325
|
+
type: "fade";
|
|
326
|
+
props?: ShowWithFadeTransitionProps;
|
|
327
|
+
priority?: UPDATE_PRIORITY;
|
|
328
|
+
};
|
|
329
|
+
type MoveInOutTransition = {
|
|
330
|
+
type: "movein" | "moveout";
|
|
331
|
+
props?: MoveInOutProps;
|
|
332
|
+
priority?: UPDATE_PRIORITY;
|
|
333
|
+
};
|
|
334
|
+
type ZoomInOutTransition = {
|
|
335
|
+
type: "zoomin" | "zoomout";
|
|
336
|
+
props?: ZoomInOutProps;
|
|
337
|
+
priority?: UPDATE_PRIORITY;
|
|
338
|
+
};
|
|
339
|
+
type PushInOutTransition = {
|
|
340
|
+
type: "pushin" | "pushout";
|
|
341
|
+
props?: PushInOutProps;
|
|
342
|
+
priority?: UPDATE_PRIORITY;
|
|
343
|
+
};
|
|
344
|
+
type PixiVNJsonMediaTransiotions = DissolveTransition | FadeTransition | MoveInOutTransition | ZoomInOutTransition | PushInOutTransition;
|
|
345
|
+
|
|
346
|
+
type PixiVNJsonCanvasImageVideoShow = {
|
|
347
|
+
type: "image" | "video";
|
|
348
|
+
operationType: "show";
|
|
349
|
+
alias: string;
|
|
350
|
+
/**
|
|
351
|
+
* The url of the image or video.
|
|
352
|
+
* If the url is not provided, the url will be set to the alias.
|
|
353
|
+
*/
|
|
354
|
+
url?: string;
|
|
355
|
+
props?: ImageSpriteOptions;
|
|
356
|
+
transition?: PixiVNJsonMediaTransiotions;
|
|
357
|
+
};
|
|
358
|
+
type PixiVNJsonCanvasImageContainerShow = {
|
|
359
|
+
type: "imagecontainer";
|
|
360
|
+
operationType: "show";
|
|
361
|
+
alias: string;
|
|
362
|
+
urls: string[];
|
|
363
|
+
props?: ImageContainerOptions<ImageSprite>;
|
|
364
|
+
transition?: PixiVNJsonMediaTransiotions;
|
|
365
|
+
};
|
|
366
|
+
type PixiVNJsonImageEdit = {
|
|
367
|
+
type: "image";
|
|
368
|
+
operationType: "edit";
|
|
369
|
+
alias: string;
|
|
370
|
+
props?: Partial<ImageSpriteMemory>;
|
|
371
|
+
};
|
|
372
|
+
type PixiVNJsonVideoEdit = {
|
|
373
|
+
type: "video";
|
|
374
|
+
operationType: "edit";
|
|
375
|
+
alias: string;
|
|
376
|
+
props?: Partial<VideoSpriteMemory>;
|
|
377
|
+
};
|
|
378
|
+
type PixiVNJsonImageContainerEdit = {
|
|
379
|
+
type: "imagecontainer";
|
|
380
|
+
operationType: "edit";
|
|
381
|
+
alias: string;
|
|
382
|
+
props?: Partial<ImageContainerMemory>;
|
|
383
|
+
};
|
|
384
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions> = {
|
|
385
|
+
type: "canvaselement";
|
|
386
|
+
operationType: "edit";
|
|
387
|
+
alias: string;
|
|
388
|
+
props?: Partial<T>;
|
|
389
|
+
};
|
|
390
|
+
type PixiVNJsonCanvasRemove = {
|
|
391
|
+
type: "image" | "video" | "imagecontainer" | "canvaselement";
|
|
392
|
+
operationType: "remove";
|
|
393
|
+
alias: string;
|
|
394
|
+
transition?: PixiVNJsonMediaTransiotions;
|
|
395
|
+
};
|
|
396
|
+
type PixiVNJsonVideoPauseResume = {
|
|
397
|
+
type: "video";
|
|
398
|
+
operationType: "pause" | "resume";
|
|
399
|
+
alias: string;
|
|
400
|
+
};
|
|
401
|
+
type PixiVNJsonAssetsLoad = {
|
|
402
|
+
type: "assets" | "bundle";
|
|
403
|
+
operationType: "load" | "lazyload";
|
|
404
|
+
aliases: string[];
|
|
405
|
+
};
|
|
406
|
+
type PixiVNJsonCanvasShow = PixiVNJsonCanvasImageContainerShow | PixiVNJsonCanvasImageVideoShow;
|
|
407
|
+
type PixiVNJsonCanvasEdit = PixiVNJsonImageEdit | PixiVNJsonVideoEdit | PixiVNJsonImageContainerEdit | PixiVNJsonUnknownEdit<ImageSpriteMemory | VideoSpriteMemory | ContainerMemory>;
|
|
408
|
+
type PixiVNJsonCanvas = PixiVNJsonCanvasShow | PixiVNJsonCanvasEdit | PixiVNJsonCanvasRemove | PixiVNJsonVideoPauseResume | PixiVNJsonAssetsLoad | PixiVNJsonCanvasTicker | PixiVNJsonCanvasAnimate | PixiVNJsonCanvasEffect;
|
|
409
|
+
|
|
410
|
+
type PixiVNJsonInputRequest = {
|
|
411
|
+
type: "input";
|
|
412
|
+
operationType: "request";
|
|
413
|
+
valueType?: string;
|
|
414
|
+
defaultValue?: any;
|
|
415
|
+
};
|
|
416
|
+
type PixiVNJsonInput = PixiVNJsonInputRequest;
|
|
417
|
+
|
|
418
|
+
type PixiVNJsonSoundPlay = {
|
|
419
|
+
type: "sound";
|
|
420
|
+
operationType: "play";
|
|
421
|
+
alias: string;
|
|
422
|
+
props?: SoundPlayOptions;
|
|
423
|
+
};
|
|
424
|
+
type PixiVNJsonSoundRemove = {
|
|
425
|
+
type: "sound";
|
|
426
|
+
operationType: "stop";
|
|
427
|
+
alias: string;
|
|
428
|
+
};
|
|
429
|
+
type PixiVNJsonSoundPauseResume = {
|
|
430
|
+
type: "sound";
|
|
431
|
+
operationType: "pause" | "resume";
|
|
432
|
+
alias: string;
|
|
433
|
+
};
|
|
434
|
+
type PixiVNJsonSoundVolume = {
|
|
435
|
+
type: "sound";
|
|
436
|
+
operationType: "volume";
|
|
437
|
+
alias: string;
|
|
438
|
+
value: number;
|
|
439
|
+
};
|
|
440
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundVolume;
|
|
441
|
+
|
|
442
|
+
type PixiVNJsonOperationString = {
|
|
443
|
+
type: "operationtoconvert";
|
|
444
|
+
values: (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet>)[];
|
|
445
|
+
};
|
|
446
|
+
type PixiVNJsonOperation = PixiVNJsonValueSet | PixiVNJsonCanvas | PixiVNJsonSound | PixiVNJsonInput;
|
|
447
|
+
type PixiVNJsonConditionalOperation = PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString;
|
|
448
|
+
|
|
449
|
+
type PixiVNJsonChoice = {
|
|
450
|
+
/**
|
|
451
|
+
* The text to be displayed.
|
|
452
|
+
*/
|
|
453
|
+
text: PixiVNJsonDialogText;
|
|
454
|
+
/**
|
|
455
|
+
* The label id to be opened.
|
|
456
|
+
*/
|
|
457
|
+
label: string;
|
|
458
|
+
/**
|
|
459
|
+
* Label opening mode
|
|
460
|
+
*/
|
|
461
|
+
type: LabelRunModeType;
|
|
462
|
+
/**
|
|
463
|
+
* The properties to be passed to the label.
|
|
464
|
+
*/
|
|
465
|
+
props: StorageObjectType;
|
|
466
|
+
/**
|
|
467
|
+
* If this is true, the choice can only be made once.
|
|
468
|
+
*/
|
|
469
|
+
oneTime?: boolean;
|
|
470
|
+
/**
|
|
471
|
+
* If this is true, the choice can see only if there are no other choices. For example, all choices are one-time choices and they are already selected.
|
|
472
|
+
*/
|
|
473
|
+
onlyHaveNoChoice?: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* If this is true and if is the only choice, it will be automatically selected, and call/jump to the label.
|
|
476
|
+
*/
|
|
477
|
+
autoSelect?: boolean;
|
|
478
|
+
};
|
|
479
|
+
type PixiVNJsonChoices = (PixiVNJsonChoice | PixiVNJsonConditionalStatements<PixiVNJsonChoice>)[];
|
|
480
|
+
type PixiVNJsonDialogText = string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet | string[]> | (string | PixiVNJsonValueGet | PixiVNJsonConditionalStatements<string | PixiVNJsonValueGet | string[]>)[];
|
|
481
|
+
type PixiVNJsonDialog<Text = string> = {
|
|
482
|
+
/**
|
|
483
|
+
* The character id that will speak.
|
|
484
|
+
*/
|
|
485
|
+
character: string;
|
|
486
|
+
/**
|
|
487
|
+
* The text to be displayed.
|
|
488
|
+
*/
|
|
489
|
+
text: Text;
|
|
490
|
+
} | Text;
|
|
491
|
+
type PixiVNJsonLabelToOpen<T extends {} = {}> = {
|
|
492
|
+
/**
|
|
493
|
+
* The id of the label to open.
|
|
494
|
+
*/
|
|
495
|
+
label: string | PixiVNJsonValueGet;
|
|
496
|
+
/**
|
|
497
|
+
* Label opening mode
|
|
498
|
+
*/
|
|
499
|
+
type: LabelRunModeType;
|
|
500
|
+
/**
|
|
501
|
+
* The properties to be passed to the label. if you don't want to pass a object, but a list of parameters, you can use the {@link PixiVNJsonLabelToOpen.params} attribute.
|
|
502
|
+
*/
|
|
503
|
+
props?: StepLabelPropsType<T>;
|
|
504
|
+
/**
|
|
505
|
+
* **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.
|
|
506
|
+
* "params" attribute will be stored in the temp storage with the key: {@link PIXIVNJSON_PARAM_ID} + ({@link narration.openedLabels.length} - 1).
|
|
507
|
+
*/
|
|
508
|
+
params?: any[];
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Steps of a label.
|
|
512
|
+
* Order of operations:
|
|
513
|
+
* 1. run all {@link PixiVNJsonLabelStep.operations}
|
|
514
|
+
* 2. set {@link PixiVNJsonLabelStep.choices}, {@link PixiVNJsonLabelStep.dialogue}, {@link PixiVNJsonLabelStep.glueEnabled}
|
|
515
|
+
* 3. open {@link PixiVNJsonLabelStep.labelToOpen}
|
|
516
|
+
* 4. go to next step if {@link PixiVNJsonLabelStep.goNextStep} is true
|
|
517
|
+
* 5. end the label if {@link PixiVNJsonLabelStep.end} is "label_end"
|
|
518
|
+
*/
|
|
519
|
+
type PixiVNJsonLabelStep = {
|
|
520
|
+
operations?: PixiVNJsonConditionalOperation[];
|
|
521
|
+
/**
|
|
522
|
+
* Variable used to display a choice menu.
|
|
523
|
+
*/
|
|
524
|
+
choices?: PixiVNJsonChoices | PixiVNJsonConditionalStatements<PixiVNJsonChoices>;
|
|
525
|
+
/**
|
|
526
|
+
* Variable used to display a dialog.
|
|
527
|
+
*/
|
|
528
|
+
dialogue?: PixiVNJsonDialog<PixiVNJsonDialogText> | PixiVNJsonConditionalStatements<PixiVNJsonDialog<PixiVNJsonDialogText>>;
|
|
529
|
+
/**
|
|
530
|
+
* This variable is used to add the next dialog text into the current dialog memory.
|
|
531
|
+
* This value was added to introduce Ink Glue functionality https://github.com/inkle/ink/blob/master/Documentation/WritingWithInk.md#glue
|
|
532
|
+
*/
|
|
533
|
+
glueEnabled?: boolean | PixiVNJsonConditionalStatements<boolean>;
|
|
534
|
+
/**
|
|
535
|
+
* Variable used to open a label.
|
|
536
|
+
*/
|
|
537
|
+
labelToOpen?: PixiVNJsonLabelToOpen | PixiVNJsonConditionalStatements<PixiVNJsonLabelToOpen> | (PixiVNJsonLabelToOpen | PixiVNJsonConditionalStatements<PixiVNJsonLabelToOpen>)[];
|
|
538
|
+
/**
|
|
539
|
+
* If is true, the next step will be executed automatically.
|
|
540
|
+
*/
|
|
541
|
+
goNextStep?: boolean | PixiVNJsonConditionalStatements<boolean>;
|
|
542
|
+
/**
|
|
543
|
+
* Variable used to end some elements of the narrative.
|
|
544
|
+
* - game_end: ends the game
|
|
545
|
+
* - label_end: ends the label
|
|
546
|
+
*/
|
|
547
|
+
end?: "game_end" | "label_end" | PixiVNJsonConditionalStatements<"game_end" | "label_end">;
|
|
548
|
+
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
549
|
+
};
|
|
4
550
|
|
|
5
551
|
/**
|
|
6
552
|
* Collection of labels to be used in the narrative.
|
|
@@ -30,7 +576,7 @@ type LabelJsonOptions = {
|
|
|
30
576
|
* Function that converts a string to a {@link PixiVNJsonOperation}.
|
|
31
577
|
* If is a special operation you can return undefined and can run the operation.
|
|
32
578
|
*/
|
|
33
|
-
operationStringConvert?: (value: string, step: PixiVNJsonLabelStep, props: StepLabelPropsType | {}) => Promise<PixiVNJsonOperation | undefined>;
|
|
579
|
+
operationStringConvert?: (value: string, step: PixiVNJsonLabelStep, props: StepLabelPropsType$1 | {}) => Promise<PixiVNJsonOperation | undefined>;
|
|
34
580
|
/**
|
|
35
581
|
* If true and a dialog is empty or has only spaces, {@link PixiVNJsonLabelStep.goNextStep} will be set to true.
|
|
36
582
|
*/
|
package/dist/importer.mjs
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import {RegisteredLabels,LabelAbstract,narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';var ae=Object.create;var W=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var fe=(i,e,t)=>e in i?W(i,e,{enumerable:true,configurable:true,writable:true,value:t}):i[e]=t;var X=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Q=(i,e)=>()=>(e||i((e={exports:{}}).exports,e),e.exports);var ue=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of le(e))!pe.call(i,o)&&o!==t&&W(i,o,{get:()=>e[o],enumerable:!(r=se(e,o))||r.enumerable});return i};var de=(i,e,t)=>(t=i!=null?ae(ce(i)):{},ue(W(t,"default",{value:i,enumerable:true}),i));var S=(i,e,t)=>fe(i,typeof e!="symbol"?e+"":e,t);var te=Q((H,ee)=>{(function(i,e){typeof H=="object"?ee.exports=H=e():typeof define=="function"&&define.amd?define([],e):i.CryptoJS=e();})(H,function(){var i=i||(function(e,t){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof X=="function")try{r=X("crypto");}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||(function(){function n(){}return function(a){var p;return n.prototype=a,p=new n,n.prototype=null,p}})(),l={},c=l.lib={},u=c.Base=(function(){return {extend:function(n){var a=s(this);return n&&a.mixIn(n),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var a in n)n.hasOwnProperty(a)&&(this[a]=n[a]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),x=c.WordArray=u.extend({init:function(n,a){n=this.words=n||[],a!=t?this.sigBytes=a:this.sigBytes=n.length*4;},toString:function(n){return (n||V).stringify(this)},concat:function(n){var a=this.words,p=n.words,h=this.sigBytes,C=n.sigBytes;if(this.clamp(),h%4)for(var E=0;E<C;E++){var M=p[E>>>2]>>>24-E%4*8&255;a[h+E>>>2]|=M<<24-(h+E)%4*8;}else for(var L=0;L<C;L+=4)a[h+L>>>2]=p[L>>>2];return this.sigBytes+=C,this},clamp:function(){var n=this.words,a=this.sigBytes;n[a>>>2]&=4294967295<<32-a%4*8,n.length=e.ceil(a/4);},clone:function(){var n=u.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var a=[],p=0;p<n;p+=4)a.push(o());return new x.init(a,n)}}),d=l.enc={},V=d.Hex={stringify:function(n){for(var a=n.words,p=n.sigBytes,h=[],C=0;C<p;C++){var E=a[C>>>2]>>>24-C%4*8&255;h.push((E>>>4).toString(16)),h.push((E&15).toString(16));}return h.join("")},parse:function(n){for(var a=n.length,p=[],h=0;h<a;h+=2)p[h>>>3]|=parseInt(n.substr(h,2),16)<<24-h%8*4;return new x.init(p,a/2)}},y=d.Latin1={stringify:function(n){for(var a=n.words,p=n.sigBytes,h=[],C=0;C<p;C++){var E=a[C>>>2]>>>24-C%4*8&255;h.push(String.fromCharCode(E));}return h.join("")},parse:function(n){for(var a=n.length,p=[],h=0;h<a;h++)p[h>>>2]|=(n.charCodeAt(h)&255)<<24-h%4*8;return new x.init(p,a)}},v=d.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},N=c.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new x.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=v.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var a,p=this._data,h=p.words,C=p.sigBytes,E=this.blockSize,M=E*4,L=C/M;n?L=e.ceil(L):L=e.max((L|0)-this._minBufferSize,0);var B=L*E,U=e.min(B*4,C);if(B){for(var K=0;K<B;K+=E)this._doProcessBlock(h,K);a=h.splice(0,B),p.sigBytes-=U;}return new x.init(a,U)},clone:function(){var n=u.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});c.Hasher=N.extend({cfg:u.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){N.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(n){return function(a,p){return new n.init(p).finalize(a)}},_createHmacHelper:function(n){return function(a,p){return new b.HMAC.init(n,p).finalize(a)}}});var b=l.algo={};return l})(Math);return i});});var ne=Q(($,ie)=>{(function(i,e){typeof $=="object"?ie.exports=$=e(te()):typeof define=="function"&&define.amd?define(["./core"],e):e(i.CryptoJS);})($,function(i){return (function(){var e=i,t=e.lib,r=t.WordArray,o=t.Hasher,s=e.algo,l=[],c=s.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,x){for(var d=this._hash.words,V=d[0],y=d[1],v=d[2],N=d[3],T=d[4],b=0;b<80;b++){if(b<16)l[b]=u[x+b]|0;else {var n=l[b-3]^l[b-8]^l[b-14]^l[b-16];l[b]=n<<1|n>>>31;}var a=(V<<5|V>>>27)+T+l[b];b<20?a+=(y&v|~y&N)+1518500249:b<40?a+=(y^v^N)+1859775393:b<60?a+=(y&v|y&N|v&N)-1894007588:a+=(y^v^N)-899497514,T=N,N=v,v=y<<30|y>>>2,y=V,V=a;}d[0]=d[0]+V|0,d[1]=d[1]+y|0,d[2]=d[2]+v|0,d[3]=d[3]+N|0,d[4]=d[4]+T|0;},_doFinalize:function(){var u=this._data,x=u.words,d=this._nDataBytes*8,V=u.sigBytes*8;return x[V>>>5]|=128<<24-V%32,x[(V+64>>>9<<4)+14]=Math.floor(d/4294967296),x[(V+64>>>9<<4)+15]=d,u.sigBytes=x.length*4,this._process(),this._hash},clone:function(){var u=o.clone.call(this);return u._hash=this._hash.clone(),u}});e.SHA1=o._createHelper(c),e.HmacSHA1=o._createHmacHelper(c);})(),i.SHA1});});var J;(o=>(o.log=(s,...l)=>console.log(`[Pixi\u2019VN Json] ${s}`,...l),o.warn=(s,...l)=>console.warn(`[Pixi\u2019VN Json] ${s}`,...l),o.error=(s,...l)=>console.error(`[Pixi\u2019VN Json] ${s}`,...l),o.info=(s,...l)=>console.info(`[Pixi\u2019VN Json] ${s}`,...l)))(J||(J={}));var f=class f{static t(e){return Array.isArray(e)?e.map(t=>f.translate(`${t}`)):f.translate(`${e}`)}static set beforeToTranslate(e){f._beforeToTranslate=e;}static set translate(e){f._translate=e;}static get translate(){return e=>{let t=e;return f._beforeToTranslate&&(t=f._beforeToTranslate(t)),t=f._translate(t),f._afterToTranslate&&(t=f._afterToTranslate(t)),t}}static set afterToTranslate(e){f._afterToTranslate=e;}static addKey(e,t,r){let o=r.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(s=>{e[s]===void 0&&(o==="empty_string"?e[s]="":o==="copy_key"&&(f._beforeToTranslate?e[s]=f._beforeToTranslate(s):e[s]=s));});}static getConditionalsThenElse(e,t=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&f.getConditionalsThenElse(e.then,t),e.else&&f.getConditionalsThenElse(e.else,t);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(r=>{f.getConditionalsThenElse(r,t);});else if(e.elements.type==="ifelse"){let r=[];f.getConditionalsThenElse(e.elements,r),r.forEach(o=>{t.push(...o);});}else if(e.elements.type==="stepswitch"){let r=[];f.getConditionalsThenElse(e.elements,r),r.forEach(o=>{t.push(...o);});}else f.getConditionalsThenElse(e.elements,t);}else e.type==="resulttocombine"?(e.firstItem&&f.getConditionalsThenElse(e.firstItem,t),e.secondConditionalItem&&e.secondConditionalItem.forEach(r=>{f.getConditionalsThenElse(r,t);})):t.push(e);else e&&t.push(e);return t}static generateJsonTranslation(e,t={},r={}){let{defaultValue:o="copy_key"}=r;return e.forEach(s=>{if(s.choices){let l=[];Array.isArray(s.choices)?l=[s.choices]:l=f.getConditionalsThenElse(s.choices),l.forEach(c=>c.forEach(u=>{if("type"in u){let x=[];u.type==="ifelse"||u.type==="stepswitch"?f.getConditionalsThenElse(u,x):x=[u],x.map(V=>f.getConditionalsThenElse(V.text)).forEach(V=>{Array.isArray(V)&&V.forEach(y=>{Array.isArray(y)?y.forEach(v=>{typeof v=="string"?f.addKey(t,v,{defaultValue:o}):f.getConditionalsThenElse(v).forEach(N=>{Array.isArray(N)?N.forEach(T=>{typeof T=="string"&&f.addKey(t,T,{defaultValue:o});}):typeof N=="string"&&f.addKey(t,N,{defaultValue:o});});}):typeof y=="string"&&f.addKey(t,y,{defaultValue:o});});});}}));}if(s.dialogue){let l=[];Array.isArray(s.dialogue)?l=[s.dialogue]:l=f.getConditionalsThenElse(s.dialogue),l.forEach(c=>{if(typeof c=="string")f.addKey(t,c,{defaultValue:o});else if("text"in c){let u=f.getConditionalsThenElse(c.text);typeof u=="string"&&(u=[u]),u.forEach(x=>{typeof x=="string"?f.addKey(t,x,{defaultValue:o}):f.getConditionalsThenElse(x).forEach(V=>{typeof V=="string"?f.addKey(t,V,{defaultValue:o}):Array.isArray(V)&&V.forEach(y=>{typeof y=="string"?f.addKey(t,y,{defaultValue:o}):f.getConditionalsThenElse(y).forEach(v=>{typeof v=="string"&&f.addKey(t,v,{defaultValue:o});});});});});}});}s.conditionalStep&&f.getConditionalsThenElse(s.conditionalStep).forEach(c=>{Array.isArray(c)?f.generateJsonTranslation(c,t,r):f.generateJsonTranslation([c],t,r);});}),t}};S(f,"_beforeToTranslate"),S(f,"_translate",e=>e),S(f,"_afterToTranslate");var D=f;var w=D;var _="___param___";function G(i){try{if(typeof i>"u")return i;let e=JSON.stringify(i);return JSON.parse(e)}catch(e){throw J.error("Error creating exportable element",i,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function Z(i){let e=P(i.value),t;switch(e&&typeof e=="object"&&"type"in e?t=P(e):t=e,i.storageType){case "flagStorage":storage.setFlag(i.key,i.value);break;case "storage":storage.setVariable(i.key,t);break;case "tempstorage":storage.setTempVariable(i.key,t);break;case "params":let r=storage.getVariable(`${_}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=t),storage.setTempVariable(`${_}${narration.openedLabels.length-1}`,r);break}}function P(i){let e=ye(i);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return he(e);case "arithmetic":case "arithmeticsingle":return ge(e);case "compare":case "valueCondition":case "union":return xe(e)}return e}function ge(i){let e=P(i.leftValue);switch(i.type){case "arithmetic":let t=P(i.rightValue);switch(i.operator){case "*":return e*t;case "/":return e/t;case "+":return e+t;case "-":return e-t;case "%":return e%t;case "POW":return Math.pow(e,t);case "RANDOM":return narration.getRandomNumber(e,t)}case "arithmeticsingle":switch(i.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function he(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case "storage":case "tempstorage":return storage.getVariable(i.key);case "flagStorage":return storage.getFlag(i.key);case "label":return narration.getTimesLabelOpened(i.label);case "choice":return narration.getTimesChoiceMade(i.index);case "logic":return P(i.operation);case "params":let e=storage.getVariable(`${_}${narration.openedLabels.length-1}`)||[];if(e&&e.length>i.key)return e[i.key];J.warn("getValue params not found");return}return i}function xe(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let e=P(i.leftValue),t=P(i.rightValue);switch(i.operator){case "==":return e===t;case "!=":return e!==t;case "<":return e<t;case "<=":return e<=t;case ">":return e>t;case ">=":return e>=t;case "CONTAINS":return e.toString().includes(t.toString())}break;case "valueCondition":return !!P(i.value);case "union":return me(i)}return !!i}function me(i){if(i.unionType==="not")return !P(i.condition);let e=i.unionType==="and";for(let t=0;t<i.conditions.length;t++)if(e=P(i.conditions[t])||false,i.unionType==="and"){if(!e)return false}else if(e)return true;return e}function Ve(i,e){return Math.floor(Math.random()*(e-i+1)+i)}function ye(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return Pe(i);case "ifelse":return P(i.condition)?P(i.then):P(i.else);case "stepswitch":let t=P(i.elements)||[];if(t.length===0){J.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let r=Ve(0,t.length-1);return P(t[r]);case "loop":let o=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return o>t.length-1&&(o=o%t.length),P(t[o]);case "sequential":let s,l=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(s=P(t[t.length-1])),l>t.length-1?s:P(t[l]);case "sequentialrandom":let c=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:i.nestedId,onceOnly:true});if(c==null&&i.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!u||!u?.usedRandomNumbers){J.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=u.usedRandomNumbers[`0-${t.length-1}`];return P(t[x[x.length-1]])}if(c==null){J.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return P(t[c])}}return i}function z(i){if(i.conditionalStep){let e=G(P(i.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let t={...i,conditionalStep:void 0,...e};return z(t)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return i}function Pe(i){let e=i.firstItem,t=[];i.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(s=>{let l=P(s);t.push(l);});else {let s=P(o);t.push(s);}});let r=e?[e,...t]:t;if(r.length===0){J.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return w.t(r);if(typeof r[0]=="object"){let o=r,s,l=o.map((n,a)=>{n=z(n);let p=P(n.dialogue)||"";return a===0?(s=P(n.glueEnabled)||false,p):(typeof p=="object"&&"text"in p&&(p=p.character+": "+p.text),s===false&&(p=`
|
|
2
|
-
|
|
3
|
-
`+p),s=P(n.glueEnabled)||false,p)}),c=P(l[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,x=l.flatMap(n=>{let a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let p;return Array.isArray(a)?p=a.map(h=>{let C=P(h);return w.t(`${C}`)}):p=P(a)||"",w.t(p)}),d=o.find(n=>n.end),V=o.find(n=>n.choices),y=false,v=false;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),y=o[o.length-1].glueEnabled,v=o.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let N=o.find(n=>n.labelToOpen),T=[];return o.forEach(n=>{n.operations&&T.forEach(a=>{T.push(a);});}),{dialogue:u?{character:u,text:x}:x,end:d?.end,choices:V?.choices,glueEnabled:y,goNextStep:v,labelToOpen:N?.labelToOpen,operations:T}}}var g=class g{static init(e){g._loadAssets=e.loadAssets,g._soundOperation=e.soundOperation,g._imageOperation=e.imageOperation,g._videoOperation=e.videoOperation,g._imageContainerOperation=e.imageContainerOperation,g._canvasElementOperation=e.canvasElementOperation,g._setStorageValue=e.setStorageValue,g._inputOperation=e.inputOperation,g._tickerOperation=e.tickerOperation,g._effectOperation=e.effectOperation,g._animateOperation=e.animateOperation,g._getLogichValue=e.getLogichValue,g._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return g._loadAssets}static get soundOperation(){return g._soundOperation}static get imageOperation(){return g._imageOperation}static get videoOperation(){return g._videoOperation}static get imageContainerOperation(){return g._imageContainerOperation}static get canvasElementOperation(){return g._canvasElementOperation}static get setStorageValue(){return g._setStorageValue}static get inputOperation(){return g._inputOperation}static get tickerOperation(){return g._tickerOperation}static get effectOperation(){return g._effectOperation}static get animateOperation(){return g._animateOperation}static get getLogichValue(){return g._getLogichValue}static get getConditionalStep(){return g._getConditionalStep}};S(g,"_loadAssets",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_soundOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_imageOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_videoOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_imageContainerOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_canvasElementOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_setStorageValue",Z),S(g,"_inputOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_tickerOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_effectOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_animateOperation",()=>{throw J.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),S(g,"_getLogichValue",P),S(g,"_getConditionalStep",z);var m=g;async function R(i,e){let t=m.getLogichValue(i);if(t)switch(t.type){case "sound":m.soundOperation(t);break;case "assets":case "bundle":await m.loadAssets(t);break;case "image":await m.imageOperation(t);break;case "video":await m.videoOperation(t);break;case "imagecontainer":await m.imageContainerOperation(t);break;case "canvaselement":await m.canvasElementOperation(t);break;case "value":m.setStorageValue(t);break;case "operationtoconvert":if(e){let r="";t.values.forEach(s=>{if(typeof s=="string")r+=s;else {let l=m.getLogichValue(s);r+=`${l}`;}});let o=await e(r);o&&await R(o,e);}break;case "input":m.inputOperation(t);break;case "fade":case "move":case "rotate":case "zoom":m.tickerOperation(t);break;case "shake":await m.effectOperation(t);break;case "animate":case "animate-sequence":m.animateOperation(t);break}}async function Te(i,e={}){let{operationStringConvert:t,skipEmptyDialogs:r}=e;if(!Array.isArray(i))if(typeof i=="object"||typeof i=="string")i=[i];else {J.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=i.map(async c=>{if(typeof c=="string")try{c=JSON.parse(c);}catch(u){J.error("Error parsing imported Pixi'VN JSON",u),c={};}return c}),l=(await Promise.all(o)).map(async c=>{let u=[];if(c.initialOperations){c.initialOperations.forEach(d=>{let V=R(d,t?y=>t(y,{},{}):void 0);u.push(V);});let x={};[...storage.storage.keys()].forEach((d,V)=>{x[d]=storage.storage.get(d);}),storage.startingStorage=x;}if(c.labels){let x=c.labels;for(let d in x)try{let V=x[d],y=new k(d,V,void 0,e);RegisteredLabels.add(y);}catch(V){J.error(`Error creating JSON label ${d}`,V);}}return Promise.all(u)});await Promise.all(l);}var re=de(ne());var k=class extends LabelAbstract{constructor(t,r,o,s={}){o||(o={}),o.onLoadingLabel=async()=>{for(let l of r){let c;if(typeof l=="function"?c=l():c=l,c=m.getConditionalStep(c),c.operations){let u=c.operations.map(x=>m.loadAssets(x));await Promise.all(u);}}};super(t,o);S(this,"_steps");S(this,"operationStringConvert");S(this,"skipEmptyDialogs",false);this._steps=r,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let r=this._steps[t];return this.stepConverter(r)}getStepSha(t){if(t<0||t>=this.steps.length)return;let r=this._steps[t];return (0, re.default)(r.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let r="";if(Array.isArray(t)){let o=[];t.forEach(s=>{if(typeof s=="string")o.push(s);else if(s&&typeof s=="object"){let l=m.getLogichValue(s);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=m.getLogichValue(l)||""),Array.isArray(l)?o=o.concat(l):o.push(`${l}`)):o.push(`${s}`);}}),r=o;}else {let o=m.getLogichValue(t)||"";o&&!Array.isArray(o)&&typeof o=="object"&&(o=m.getLogichValue(o)||""),r=o;}return `${r}`}getDialogue(t){if(t==null)return;let r=m.getLogichValue(t);return r==null?"":typeof r=="object"&&"character"in r&&"text"in r?{character:r.character,text:w.t(this.getDialogueText(r.text))}:w.t(this.getDialogueText(r))}getChoices(t){return m.getLogichValue(t)?.map(s=>m.getLogichValue(s)).filter(s=>s!==void 0)}stepConverter(t){return async r=>{let o=typeof t=="function"?t():t;o=G(o),o=m.getConditionalStep(o);let s=this.operationStringConvert?N=>this.operationStringConvert(N,o,r):void 0,{operations:l=[]}=o;for(let N of l)await R(N,s);let{labelToOpen:c=[]}=o,u=this.getChoices(o.choices),x=m.getLogichValue(o.glueEnabled),d=this.getDialogue(o.dialogue),V=[];Array.isArray(c)||(c=[c]),c.forEach(N=>{let T=m.getLogichValue(N);T&&V.push(T);});let y=m.getLogichValue(o.goNextStep),v=m.getLogichValue(o.end);if(u){let N=u.map(T=>{let b="";if(Array.isArray(T.text)){let a=[];T.text.forEach(p=>{if(typeof p=="string")a.push(w.t(p));else if(p&&typeof p=="object"){let h=m.getLogichValue(p);h&&!Array.isArray(h)&&typeof h=="object"&&(h=m.getLogichValue(h)||""),h&&(Array.isArray(h)?a=a.concat(w.t(h)):a.push(w.t(h)));}}),b=a;}else typeof T.text=="string"&&(b=w.t(T.text));return {label:T.label,text:b,props:T.props,type:T.type,oneTime:T.oneTime,onlyHaveNoChoice:T.onlyHaveNoChoice,autoSelect:T.autoSelect}});narration.choiceMenuOptions=N;}else narration.choiceMenuOptions=void 0;d!==void 0&&(narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(y=true)),x?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):x===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let N of V){let T=N.label;typeof T=="object"&&(T=m.getLogichValue(T)||"");let b=N.params?.map(n=>m.getLogichValue(n));r={...r,...N.props},N.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${_}${narration.openedLabels.length}`,b),await narration.callLabel(T,r)):(storage.setTempVariable(`${_}${narration.openedLabels.length}`,b),await narration.callLabel(T,r));}v==="game_end"?(narration.closeAllLabels(),await narration.goNext(r,{runNow:true})):v==="label_end"&&narration.closeCurrentLabel(),y&&await narration.goNext(r,{runNow:true});}}};export{k as LabelJson,Te as importPixiVNJson};
|
|
1
|
+
import {RegisteredLabels,LabelAbstract,narration}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';import {JsonUnifier}from'@drincs/pixi-vn-json/unifier';import {translator}from'@drincs/pixi-vn-json/translator';var K=Object.create;var I=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ie=(a,n,t)=>n in a?I(a,n,{enumerable:true,configurable:true,writable:true,value:t}):a[n]=t;var R=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(n,t)=>(typeof require<"u"?require:n)[t]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var W=(a,n)=>()=>(n||a((n={exports:{}}).exports,n),n.exports);var re=(a,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Z(n))!te.call(a,r)&&r!==t&&I(a,r,{get:()=>n[r],enumerable:!(o=Q(n,r))||o.enumerable});return a};var ne=(a,n,t)=>(t=a!=null?K(ee(a)):{},re(I(t,"default",{value:a,enumerable:true}),a));var E=(a,n,t)=>ie(a,typeof n!="symbol"?n+"":n,t);var F=W((A,U)=>{(function(a,n){typeof A=="object"?U.exports=A=n():typeof define=="function"&&define.amd?define([],n):a.CryptoJS=n();})(A,function(){var a=a||(function(n,t){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof R=="function")try{o=R("crypto");}catch{}var r=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||(function(){function e(){}return function(i){var p;return e.prototype=i,p=new e,e.prototype=null,p}})(),s={},u=s.lib={},g=u.Base=(function(){return {extend:function(e){var i=c(this);return e&&i.mixIn(e),(!i.hasOwnProperty("init")||this.init===i.init)&&(i.init=function(){i.$super.init.apply(this,arguments);}),i.init.prototype=i,i.$super=this,i},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var i in e)e.hasOwnProperty(i)&&(this[i]=e[i]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=u.WordArray=g.extend({init:function(e,i){e=this.words=e||[],i!=t?this.sigBytes=i:this.sigBytes=e.length*4;},toString:function(e){return (e||x).stringify(this)},concat:function(e){var i=this.words,p=e.words,f=this.sigBytes,S=e.sigBytes;if(this.clamp(),f%4)for(var V=0;V<S;V++){var k=p[V>>>2]>>>24-V%4*8&255;i[f+V>>>2]|=k<<24-(f+V)%4*8;}else for(var _=0;_<S;_+=4)i[f+_>>>2]=p[_>>>2];return this.sigBytes+=S,this},clamp:function(){var e=this.words,i=this.sigBytes;e[i>>>2]&=4294967295<<32-i%4*8,e.length=n.ceil(i/4);},clone:function(){var e=g.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var i=[],p=0;p<e;p+=4)i.push(r());return new y.init(i,e)}}),l=s.enc={},x=l.Hex={stringify:function(e){for(var i=e.words,p=e.sigBytes,f=[],S=0;S<p;S++){var V=i[S>>>2]>>>24-S%4*8&255;f.push((V>>>4).toString(16)),f.push((V&15).toString(16));}return f.join("")},parse:function(e){for(var i=e.length,p=[],f=0;f<i;f+=2)p[f>>>3]|=parseInt(e.substr(f,2),16)<<24-f%8*4;return new y.init(p,i/2)}},b=l.Latin1={stringify:function(e){for(var i=e.words,p=e.sigBytes,f=[],S=0;S<p;S++){var V=i[S>>>2]>>>24-S%4*8&255;f.push(String.fromCharCode(V));}return f.join("")},parse:function(e){for(var i=e.length,p=[],f=0;f<i;f++)p[f>>>2]|=(e.charCodeAt(f)&255)<<24-f%4*8;return new y.init(p,i)}},P=l.Utf8={stringify:function(e){try{return decodeURIComponent(escape(b.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return b.parse(unescape(encodeURIComponent(e)))}},h=u.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(e){typeof e=="string"&&(e=P.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(e){var i,p=this._data,f=p.words,S=p.sigBytes,V=this.blockSize,k=V*4,_=S/k;e?_=n.ceil(_):_=n.max((_|0)-this._minBufferSize,0);var C=_*V,z=n.min(C*4,S);if(C){for(var H=0;H<C;H+=V)this._doProcessBlock(f,H);i=f.splice(0,C),p.sigBytes-=z;}return new y.init(i,z)},clone:function(){var e=g.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});u.Hasher=h.extend({cfg:g.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset();},reset:function(){h.reset.call(this),this._doReset();},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var i=this._doFinalize();return i},blockSize:512/32,_createHelper:function(e){return function(i,p){return new e.init(p).finalize(i)}},_createHmacHelper:function(e){return function(i,p){return new m.HMAC.init(e,p).finalize(i)}}});var m=s.algo={};return s})(Math);return a});});var M=W((B,G)=>{(function(a,n){typeof B=="object"?G.exports=B=n(F()):typeof define=="function"&&define.amd?define(["./core"],n):n(a.CryptoJS);})(B,function(a){return (function(){var n=a,t=n.lib,o=t.WordArray,r=t.Hasher,c=n.algo,s=[],u=c.SHA1=r.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,y){for(var l=this._hash.words,x=l[0],b=l[1],P=l[2],h=l[3],d=l[4],m=0;m<80;m++){if(m<16)s[m]=g[y+m]|0;else {var e=s[m-3]^s[m-8]^s[m-14]^s[m-16];s[m]=e<<1|e>>>31;}var i=(x<<5|x>>>27)+d+s[m];m<20?i+=(b&P|~b&h)+1518500249:m<40?i+=(b^P^h)+1859775393:m<60?i+=(b&P|b&h|P&h)-1894007588:i+=(b^P^h)-899497514,d=h,h=P,P=b<<30|b>>>2,b=x,x=i;}l[0]=l[0]+x|0,l[1]=l[1]+b|0,l[2]=l[2]+P|0,l[3]=l[3]+h|0,l[4]=l[4]+d|0;},_doFinalize:function(){var g=this._data,y=g.words,l=this._nDataBytes*8,x=g.sigBytes*8;return y[x>>>5]|=128<<24-x%32,y[(x+64>>>9<<4)+14]=Math.floor(l/4294967296),y[(x+64>>>9<<4)+15]=l,g.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var g=r.clone.call(this);return g._hash=this._hash.clone(),g}});n.SHA1=r._createHelper(u),n.HmacSHA1=r._createHmacHelper(u);})(),a.SHA1});});var L;(r=>(r.log=(c,...s)=>console.log(`[Pixi\u2019VN Json] ${c}`,...s),r.warn=(c,...s)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...s),r.error=(c,...s)=>console.error(`[Pixi\u2019VN Json] ${c}`,...s),r.info=(c,...s)=>console.info(`[Pixi\u2019VN Json] ${c}`,...s)))(L||(L={}));async function T(a,n){let t=JsonUnifier.getLogichValue(a);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t);break;case "operationtoconvert":if(n){let o="";t.values.forEach(c=>{if(typeof c=="string")o+=c;else {let s=JsonUnifier.getLogichValue(c);o+=`${s}`;}});let r=await n(o);r&&await T(r,n);}break;case "input":JsonUnifier.inputOperation(t);break;case "fade":case "move":case "rotate":case "zoom":JsonUnifier.tickerOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break}}async function ae(a,n={}){let{operationStringConvert:t,skipEmptyDialogs:o}=n;if(!Array.isArray(a))if(typeof a=="object"||typeof a=="string")a=[a];else {L.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=a.map(async u=>{if(typeof u=="string")try{u=JSON.parse(u);}catch(g){L.error("Error parsing imported Pixi'VN JSON",g),u={};}return u}),s=(await Promise.all(r)).map(async u=>{let g=[];if(u.initialOperations){u.initialOperations.forEach(l=>{let x=T(l,t?b=>t(b,{},{}):void 0);g.push(x);});let y={};[...storage.storage.keys()].forEach((l,x)=>{y[l]=storage.storage.get(l);}),storage.startingStorage=y;}if(u.labels){let y=u.labels;for(let l in y)try{let x=y[l],b=new w(l,x,void 0,n);RegisteredLabels.add(b);}catch(x){L.error(`Error creating JSON label ${l}`,x);}}return Promise.all(g)});await Promise.all(s);}var Y=ne(M());var j="___param___";function X(a){try{if(typeof a>"u")return a;let n=JSON.stringify(a);return JSON.parse(n)}catch(n){throw L.error("Error creating exportable element",a,n),new Error("[Pixi\u2019VN] Error creating exportable element")}}var w=class extends LabelAbstract{constructor(t,o,r,c={}){r||(r={}),r.onLoadingLabel=async()=>{for(let s of o){let u;if(typeof s=="function"?u=s():u=s,u=JsonUnifier.getConditionalStep(u),u.operations){let g=u.operations.map(y=>JsonUnifier.loadAssets(y));await Promise.all(g);}}};super(t,r);E(this,"_steps");E(this,"operationStringConvert");E(this,"skipEmptyDialogs",false);this._steps=o,this.operationStringConvert=c.operationStringConvert,this.skipEmptyDialogs=c.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let o=this._steps[t];return this.stepConverter(o)}getStepSha(t){if(t<0||t>=this.steps.length)return;let o=this._steps[t];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let o="";if(Array.isArray(t)){let r=[];t.forEach(c=>{if(typeof c=="string")r.push(c);else if(c&&typeof c=="object"){let s=JsonUnifier.getLogichValue(c);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=JsonUnifier.getLogichValue(s)||""),Array.isArray(s)?r=r.concat(s):r.push(`${s}`)):r.push(`${c}`);}}),o=r;}else {let r=JsonUnifier.getLogichValue(t)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=JsonUnifier.getLogichValue(r)||""),o=r;}return `${o}`}getDialogue(t){if(t==null)return;let o=JsonUnifier.getLogichValue(t);return o==null?"":typeof o=="object"&&"character"in o&&"text"in o?{character:o.character,text:translator.t(this.getDialogueText(o.text))}:translator.t(this.getDialogueText(o))}getChoices(t){return JsonUnifier.getLogichValue(t)?.map(c=>JsonUnifier.getLogichValue(c)).filter(c=>c!==void 0)}stepConverter(t){return async o=>{let r=typeof t=="function"?t():t;r=X(r),r=JsonUnifier.getConditionalStep(r);let c=this.operationStringConvert?h=>this.operationStringConvert(h,r,o):void 0,{operations:s=[]}=r;for(let h of s)await T(h,c);let{labelToOpen:u=[]}=r,g=this.getChoices(r.choices),y=JsonUnifier.getLogichValue(r.glueEnabled),l=this.getDialogue(r.dialogue),x=[];Array.isArray(u)||(u=[u]),u.forEach(h=>{let d=JsonUnifier.getLogichValue(h);d&&x.push(d);});let b=JsonUnifier.getLogichValue(r.goNextStep),P=JsonUnifier.getLogichValue(r.end);if(g){let h=g.map(d=>{let m="";if(Array.isArray(d.text)){let i=[];d.text.forEach(p=>{if(typeof p=="string")i.push(translator.t(p));else if(p&&typeof p=="object"){let f=JsonUnifier.getLogichValue(p);f&&!Array.isArray(f)&&typeof f=="object"&&(f=JsonUnifier.getLogichValue(f)||""),f&&(Array.isArray(f)?i=i.concat(translator.t(f)):i.push(translator.t(f)));}}),m=i;}else typeof d.text=="string"&&(m=translator.t(d.text));return {label:d.label,text:m,props:d.props,type:d.type,oneTime:d.oneTime,onlyHaveNoChoice:d.onlyHaveNoChoice,autoSelect:d.autoSelect}});narration.choiceMenuOptions=h;}else narration.choiceMenuOptions=void 0;l!==void 0&&(narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(b=true)),y?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):y===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let h of x){let d=h.label;typeof d=="object"&&(d=JsonUnifier.getLogichValue(d)||"");let m=h.params?.map(e=>JsonUnifier.getLogichValue(e));o={...o,...h.props},h.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${j}${narration.openedLabels.length}`,m),await narration.callLabel(d,o)):(storage.setTempVariable(`${j}${narration.openedLabels.length}`,m),await narration.callLabel(d,o));}P==="game_end"?(narration.closeAllLabels(),await narration.goNext(o,{runNow:true})):P==="label_end"&&narration.closeCurrentLabel(),b&&await narration.goNext(o,{runNow:true});}}};export{w as LabelJson,ae as importPixiVNJson};
|