@novely/core 0.29.0 → 0.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,448 +0,0 @@
1
- type Name<Keys extends string = string> = string | Record<Keys, string>;
2
- type Emotions<Keys extends string = string> = Record<Keys, string | string[]>;
3
- type Character<LanguageKeys extends string = string> = {
4
- name: Name<LanguageKeys>;
5
- color: string;
6
- emotions: Emotions;
7
- };
8
-
9
- type Thenable<T> = T | Promise<T>;
10
- type PathItem = [null, number | string] | ['jump', string] | ['choice', number] | ['choice:exit'] | ['condition', string] | ['condition:exit'] | ['exit'] | ['block', string] | ['block:exit'];
11
- type Path = PathItem[];
12
- type State = Record<string, any>;
13
- type Data = Record<string, any>;
14
- type SaveDate = number;
15
- type SaveType = 'manual' | 'auto';
16
- type SaveMeta = [date: SaveDate, type: SaveType];
17
- type Save = [path: Path, state: State, meta: SaveMeta];
18
- type Lang = string;
19
- type TypewriterSpeed = 'Slow' | 'Medium' | 'Fast' | 'Auto' | (string & Record<never, never>);
20
- type SoundVolume = number;
21
- type StorageMeta = [lang: Lang, typewriter_speed: TypewriterSpeed, music_volume: SoundVolume, sound_volume: SoundVolume, voice_volume: SoundVolume];
22
- type Migration = (save: unknown) => unknown;
23
- type StorageData = {
24
- saves: Save[];
25
- data: Data;
26
- meta: StorageMeta;
27
- };
28
- type NovelyScreen = 'mainmenu' | 'game' | 'saves' | 'settings';
29
- /**
30
- * @see https://pendletonjones.com/deep-partial
31
- */
32
- type DeepPartial<T> = unknown extends T ? T : T extends object ? {
33
- [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : DeepPartial<T[P]>;
34
- } : T;
35
- type NonEmptyRecord<T extends Record<PropertyKey, unknown>> = keyof T extends never ? never : T;
36
- type CoreData = {
37
- dataLoaded: boolean;
38
- };
39
- type UseStackFunctionReturnType = {
40
- /**
41
- * Save that was after current value before `back` was used
42
- */
43
- get previous(): Save | undefined;
44
- value: Save;
45
- back(): void;
46
- push(value: Save): void;
47
- clear(): void;
48
- };
49
- type StackHolder = Save[] & {
50
- previous: Save | undefined;
51
- };
52
-
53
- type ValidAction = ['choice', [number]] | ['clear', [Set<keyof DefaultActionProxyProvider>?, Set<string>?]] | ['condition', [() => boolean, Record<string, ValidAction[]>]] | ['dialog', [string | undefined, Unwrappable<string>, string | undefined]] | ['end', []] | ['showBackground', [string | NonEmptyRecord<BackgroundImage>]] | ['playMusic', [string]] | ['stopMusic', [string]] | ['voice', [string]] | ['stopVoice', []] | ['jump', [string]] | ['showCharacter', [string, keyof Character['emotions'], string?, string?]] | ['hideCharacter', [string, string?, string?, number?]] | ['animateCharacter', [string, number, ...string[]]] | ['wait', [FunctionableValue<number>]] | ['function', [() => Thenable<void>]] | ['input', [string, (meta: ActionInputOnInputMeta<string>) => void, ActionInputSetup?]] | ['custom', [CustomHandler]] | ['vibrate', [...number[]]] | ['next', []] | ['text', [...string[]]] | ['exit', []] | ['preload', [string]] | ['block', [string]] | ValidAction[];
54
- type Story = Record<string, ValidAction[]>;
55
- type Unwrappable<L extends string> = string | (() => string) | Record<L, string | (() => string)>;
56
- type FunctionableValue<T> = T | (() => T);
57
- type CustomHandlerGetResultDataFunction = {
58
- (data?: Record<string, unknown>): Record<string, unknown>;
59
- };
60
- type CustomHandlerGetResult<I extends boolean> = {
61
- delete: () => void;
62
- /**
63
- * Данные
64
- */
65
- data: CustomHandlerGetResultDataFunction;
66
- /**
67
- * Элемент слоя
68
- */
69
- element: I extends true ? HTMLDivElement : null;
70
- /**
71
- * Корневой элемент Novely
72
- */
73
- root: HTMLElement;
74
- /**
75
- * Устанавливает обработчик очистки
76
- */
77
- clear: (fn: () => void) => void;
78
- };
79
- type CustomHandlerFunctionGetFn = <I extends boolean = true>(insert?: I) => CustomHandlerGetResult<I>;
80
- type CustomHandlerFunctionParameters = {
81
- get: CustomHandlerFunctionGetFn;
82
- goingBack: boolean;
83
- preview: boolean;
84
- lang: string;
85
- };
86
- type CustomHandlerFunction = (parameters: CustomHandlerFunctionParameters) => Thenable<void>;
87
- type CustomHandler = CustomHandlerFunction & {
88
- callOnlyLatest?: boolean;
89
- requireUserAction?: boolean;
90
- skipClearOnGoingBack?: boolean;
91
- id?: string | symbol;
92
- key: string;
93
- };
94
- interface ActionInputOnInputMeta<L extends string> {
95
- /**
96
- * Input Element itself
97
- */
98
- input: HTMLInputElement;
99
- /**
100
- * Function to show error message or hide it
101
- * @param error Error message or empty string to remove it
102
- */
103
- error: (error: string) => void;
104
- /**
105
- * Input Event
106
- */
107
- event: InputEvent & {
108
- currentTarget: HTMLInputElement;
109
- };
110
- /**
111
- * Sanitized `input.value`
112
- */
113
- value: string;
114
- /**
115
- * Language
116
- */
117
- lang: L;
118
- }
119
- type ActionInputSetup = (input: HTMLInputElement, cleanup: (cb: () => void) => void) => void;
120
- type BackgroundImage = Partial<Record<'portrait' | 'landscape' | 'all', string>> & Record<string, string>;
121
- type ActionProxyProvider<Characters extends Record<string, Character>, Languages extends string> = {
122
- choice: {
123
- (...choices: ([Unwrappable<Languages>, ValidAction[]] | [Unwrappable<Languages>, ValidAction[], () => boolean])[]): ValidAction;
124
- (question: Unwrappable<Languages>, ...choices: ([Unwrappable<Languages>, ValidAction[]] | [Unwrappable<Languages>, ValidAction[], () => boolean])[]): ValidAction;
125
- };
126
- clear: (keep?: Set<keyof DefaultActionProxyProvider>, keepCharacters?: Set<string>, keepAudio?: {
127
- music: Set<string>;
128
- sounds: Set<string>;
129
- }) => ValidAction;
130
- condition: <T extends string | true | false>(condition: () => T, variants: Record<T extends true ? 'true' : T extends false ? 'false' : T, ValidAction[]>) => ValidAction;
131
- exit: () => ValidAction;
132
- dialog: {
133
- <C extends keyof Characters>(person: C, content: Unwrappable<Languages>, emotion?: keyof Characters[C]['emotions']): ValidAction;
134
- (person: undefined, content: Unwrappable<Languages>, emotion?: undefined): ValidAction;
135
- (person: string, content: Unwrappable<Languages>, emotion?: undefined): ValidAction;
136
- };
137
- end: () => ValidAction;
138
- showBackground: <T extends string | BackgroundImage>(background: T extends string ? T : T extends Record<PropertyKey, unknown> ? NonEmptyRecord<T> : never) => ValidAction;
139
- playMusic: (audio: string) => ValidAction;
140
- stopMusic: (audio: string) => ValidAction;
141
- playSound: (audio: string, loop?: boolean) => ValidAction;
142
- stopSound: (audio: string) => ValidAction;
143
- /**
144
- * Plays voice
145
- */
146
- voice: (voice: string) => ValidAction;
147
- /**
148
- * Stops currently playing voice
149
- */
150
- stopVoice: () => ValidAction;
151
- jump: (scene: string) => ValidAction;
152
- showCharacter: {
153
- <C extends keyof Characters>(character: C, emotion: keyof Characters[C]['emotions'], className?: string, style?: string): ValidAction;
154
- };
155
- hideCharacter: (character: keyof Characters, className?: string, style?: string, duration?: number) => ValidAction;
156
- animateCharacter: (character: keyof Characters, timeout: number, ...classes: string[]) => ValidAction;
157
- wait: (time: FunctionableValue<number>) => ValidAction;
158
- function: (fn: (restoring: boolean, goingBack: boolean, preview: boolean) => Thenable<void>) => ValidAction;
159
- input: (question: Unwrappable<Languages>, onInput: (meta: ActionInputOnInputMeta<Languages>) => void, setup?: ActionInputSetup) => ValidAction;
160
- custom: (handler: CustomHandler) => ValidAction;
161
- vibrate: (...pattern: number[]) => ValidAction;
162
- next: () => ValidAction;
163
- text: (...text: Unwrappable<Languages>[]) => ValidAction;
164
- preload: (source: string) => ValidAction;
165
- block: (scene: string) => ValidAction;
166
- };
167
- type DefaultActionProxyProvider = ActionProxyProvider<Record<string, Character>, string>;
168
- type GetActionParameters<T extends Capitalize<keyof DefaultActionProxyProvider>> = Parameters<DefaultActionProxyProvider[Uncapitalize<T>]>;
169
-
170
- declare const RU: {
171
- NewGame: string;
172
- HomeScreen: string;
173
- ToTheGame: string;
174
- Language: string;
175
- NoSaves: string;
176
- LoadSave: string;
177
- Saves: string;
178
- Settings: string;
179
- Sumbit: string;
180
- GoBack: string;
181
- DoSave: string;
182
- Auto: string;
183
- Stop: string;
184
- Exit: string;
185
- Automatic: string;
186
- Manual: string;
187
- Remove: string;
188
- LoadASaveFrom: string;
189
- DeleteASaveFrom: string;
190
- TextSpeed: string;
191
- TextSpeedSlow: string;
192
- TextSpeedMedium: string;
193
- TextSpeedFast: string;
194
- TextSpeedAuto: string;
195
- CompleteText: string;
196
- GoForward: string;
197
- ExitDialogWarning: string;
198
- ExitDialogExit: string;
199
- ExitDialogBack: string;
200
- OpenMenu: string;
201
- CloseMenu: string;
202
- MusicVolume: string;
203
- SoundVolume: string;
204
- VoiceVolume: string;
205
- };
206
- type BaseTranslationStrings = keyof typeof RU;
207
- declare const EN: Record<BaseTranslationStrings, string>;
208
- /**
209
- * Translated automatically
210
- */
211
- declare const KK: Record<BaseTranslationStrings, string>;
212
- /**
213
- * Translated automatically
214
- */
215
- declare const JP: Record<BaseTranslationStrings, string>;
216
-
217
- type Stored<T> = {
218
- subscribe: (cb: (value: T) => void) => () => void;
219
- update: (fn: (prev: T) => T) => void;
220
- set: (val: T) => void;
221
- get: () => T;
222
- };
223
-
224
- interface CharacterHandle {
225
- canvas: HTMLCanvasElement;
226
- ctx: CanvasRenderingContext2D;
227
- emotion: (emotion: string, render: boolean) => void;
228
- append: (className?: string, style?: string, restoring?: boolean) => void;
229
- remove: (className?: string, style?: string, duration?: number, restoring?: boolean) => Promise<void>;
230
- emotions: Record<string, HTMLImageElement[]>;
231
- }
232
- type AudioHandle = {
233
- stop: () => void;
234
- pause: () => void;
235
- play: () => void;
236
- };
237
- type Renderer = {
238
- misc: {
239
- /**
240
- * Function to preload images async and await for all images to load or fail
241
- * @param images Set of images to load
242
- */
243
- preloadImagesBlocking: (images: Set<string>) => Promise<PromiseSettledResult<unknown>[]>;
244
- /**
245
- * Function to preload image sync
246
- * @param image Image URL
247
- * @returns Image URL
248
- */
249
- preloadImage: <T extends string>(image: T) => T;
250
- /**
251
- * Function to preload audio
252
- * @param type kind of audio
253
- * @param source <url> pointing to the audio
254
- */
255
- preloadAudioBlocking: (type: 'music', source: string) => Promise<void>;
256
- };
257
- ui: {
258
- /**
259
- * Shows the screen
260
- */
261
- showScreen(name: NovelyScreen | 'loading'): void;
262
- /**
263
- * Returns current screen
264
- */
265
- getScreen(): NovelyScreen | 'loading' | (string & Record<never, never>);
266
- /**
267
- * Shows prompt to exit
268
- */
269
- showExitPrompt(): void;
270
- /**
271
- * Render the game
272
- */
273
- start(): {
274
- /**
275
- * Unmount
276
- */
277
- unmount(): void;
278
- };
279
- };
280
- getContext: (context: string) => {
281
- id: string;
282
- get root(): HTMLElement;
283
- set root(value: HTMLElement);
284
- character: (character: string) => CharacterHandle;
285
- background: (background: string | BackgroundImage) => void;
286
- dialog: (content: string, name: string, character: string | undefined, emotion: string | undefined, resolve: () => void) => void;
287
- choices: (question: string, choices: ([string, ValidAction[]] | [string, ValidAction[], () => boolean])[], resolve: (selected: number) => void) => void;
288
- input: (question: string, onInput: (meta: ActionInputOnInputMeta<string>) => void, setup: ActionInputSetup, resolve: () => void) => void;
289
- clear: (keep: Set<keyof DefaultActionProxyProvider>, keepCharacters: Set<string>, keepAudio: {
290
- music: Set<string>;
291
- sounds: Set<string>;
292
- }, resolve: () => void) => void;
293
- custom: (fn: Parameters<DefaultActionProxyProvider['custom']>[0], push: () => void) => Thenable<void>;
294
- clearCustom: (fn: Parameters<DefaultActionProxyProvider['custom']>[0]) => void;
295
- text: (str: string, resolve: () => void) => void;
296
- vibrate: (pattern: VibratePattern) => void;
297
- audio: {
298
- voice: (source: string) => void;
299
- voiceStop: () => void;
300
- music: (source: string, method: 'music' | 'sound', loop?: boolean) => AudioHandle;
301
- /**
302
- * Stop all sounds
303
- */
304
- clear: () => void;
305
- /**
306
- * Destroy
307
- */
308
- destroy: () => void;
309
- /**
310
- * Initialize audio service, attach events, etc
311
- */
312
- start: () => void;
313
- };
314
- meta: {
315
- get restoring(): boolean;
316
- set restoring(value: boolean);
317
- get preview(): boolean;
318
- set preview(value: boolean);
319
- get goingBack(): boolean;
320
- set goingBack(value: boolean);
321
- };
322
- store: unknown;
323
- setStore: unknown;
324
- getCharacter: (character: string) => CharacterHandle | undefined;
325
- };
326
- removeContext: (context: string) => void;
327
- };
328
- type Context = ReturnType<Renderer['getContext']>;
329
- type RendererInit = {
330
- characters: Record<string, Character>;
331
- set: (save: Save) => Promise<void>;
332
- restore: (save?: Save) => Promise<void>;
333
- save: (override?: boolean, type?: Save[2][1]) => void;
334
- newGame: () => void;
335
- exit: (force?: boolean) => void;
336
- back: () => Promise<void>;
337
- languages: string[];
338
- /**
339
- * Translation function
340
- */
341
- t: (key: BaseTranslationStrings, lang: string) => string;
342
- /**
343
- * Store that tracks data updates
344
- */
345
- $: Stored<StorageData>;
346
- /**
347
- * Store that used to communicate between renderer and core
348
- */
349
- $$: Stored<CoreData>;
350
- /**
351
- * There is different context, and the main one which is used for game
352
- */
353
- mainContextKey: string;
354
- preview: (save: Save, name: string) => Promise<void>;
355
- removeContext: (name: string) => void;
356
- };
357
-
358
- type MatchActionParams = {
359
- data: Record<string, unknown>;
360
- ctx: Context;
361
- };
362
- type MatchActionMap = {
363
- [Key in keyof DefaultActionProxyProvider]: (params: MatchActionParams, data: Parameters<DefaultActionProxyProvider[Key]>) => void;
364
- };
365
- type MatchActionMapComplete = Omit<MatchActionMap, 'custom'> & {
366
- custom: (params: MatchActionParams, value: [handler: CustomHandler]) => Thenable<void>;
367
- };
368
- type MatchActionParameters = {
369
- /**
370
- * Name of context or context
371
- */
372
- ctx: string | Context;
373
- /**
374
- * Data from the save
375
- */
376
- data: Record<string, unknown>;
377
- };
378
- declare const matchAction: <M extends MatchActionMapComplete>(getContext: (name: string) => Context, values: M) => (action: keyof MatchActionMapComplete, props: any, { ctx, data }: MatchActionParameters) => Thenable<void>;
379
- declare const isNumber: (val: unknown) => val is number;
380
- declare const isNull: (val: unknown) => val is null;
381
- declare const isString: (val: unknown) => val is string;
382
- declare const isFunction: (val: unknown) => val is (...parameters: any[]) => any;
383
- declare const isPromise: (val: unknown) => val is Promise<any>;
384
- declare const isEmpty: (val: unknown) => val is Record<PropertyKey, never>;
385
- declare const isCSSImage: (str: string) => boolean;
386
- declare const str: StringConstructor;
387
- declare const isUserRequiredAction: (action: keyof MatchActionMapComplete, meta: Parameters<MatchActionMapComplete[keyof MatchActionMapComplete]>) => boolean | undefined;
388
- declare const getLanguage: (languages: string[]) => string;
389
- /**
390
- * @copyright Techlead LLC
391
- * @see https://learn.javascript.ru/task/throttle
392
- */
393
- declare const throttle: <Fn extends (...args: any[]) => any>(fn: Fn, ms: number) => (...args: Parameters<Fn>) => void;
394
- declare const findLastIndex: <T>(array: T[], fn: (item: T, next?: T | undefined) => boolean) => number;
395
- declare const findLast: <T>(array: T[], fn: (item: T, next?: T | undefined) => boolean) => T;
396
- type ControlledPromise<T> = Promise<{
397
- value: T;
398
- cancelled: false;
399
- } | {
400
- value: null;
401
- cancelled: true;
402
- }>;
403
- type ControlledPromiseObj<T> = {
404
- resolve: (value: T | PromiseLike<T>) => void;
405
- reject: (reason?: any) => void;
406
- promise: ControlledPromise<T>;
407
- cancel: () => void;
408
- };
409
- declare const createControlledPromise: <T = void>() => ControlledPromiseObj<T>;
410
- declare const findLastPathItemBeforeItemOfType: (path: Path, name: PathItem[0]) => [null, number] | undefined;
411
- declare const isBlockStatement: (statement: unknown) => statement is "choice" | "condition" | "block";
412
- declare const isBlockExitStatement: (statement: unknown) => statement is "choice:exit" | "condition:exit" | "block:exit";
413
- declare const isSkippedDuringRestore: (item: unknown) => item is "choice" | "dialog" | "input" | "vibrate" | "text";
414
- declare const noop: () => void;
415
- declare const isAction: (element: unknown) => element is ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, value: [handler: CustomHandler]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [fn: (restoring: boolean, goingBack: boolean, preview: boolean) => Thenable<void>]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [scene: string]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [question: Unwrappable<string>, ...choices: ([Unwrappable<string>, ValidAction[]] | [Unwrappable<string>, ValidAction[], () => boolean])[]]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [condition: () => string | boolean, variants: Record<string, ValidAction[]>]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: []] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [scene: string]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [keep?: Set<keyof DefaultActionProxyProvider> | undefined, keepCharacters?: Set<string> | undefined, keepAudio?: {
416
- music: Set<string>;
417
- sounds: Set<string>;
418
- } | undefined]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [person: string, content: Unwrappable<string>, emotion?: undefined]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [background: string | BackgroundImage]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [audio: string]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [audio: string]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [audio: string, loop?: boolean | undefined]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [audio: string]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [voice: string]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [character: string, emotion: string, className?: string | undefined, style?: string | undefined]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [character: string, className?: string | undefined, style?: string | undefined, duration?: number | undefined]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [character: string, timeout: number, ...classes: string[]]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [time: FunctionableValue<number>]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [question: Unwrappable<string>, onInput: (meta: ActionInputOnInputMeta<string>) => void, setup?: ActionInputSetup | undefined]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: number[]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: Unwrappable<string>[]] | ["function" | "jump" | "choice" | "condition" | "exit" | "block" | "clear" | "dialog" | "end" | "showBackground" | "playMusic" | "stopMusic" | "playSound" | "stopSound" | "voice" | "stopVoice" | "showCharacter" | "hideCharacter" | "animateCharacter" | "wait" | "input" | "custom" | "vibrate" | "next" | "text" | "preload", params: MatchActionParams, data: [source: string]];
419
- /**
420
- * Transforms `(ValidAction | ValidAction[])[]` to `ValidAction[]`
421
- */
422
- declare const flattenStory: (story: Story) => any;
423
- /**
424
- * A wrapper on `fn` to make it run only once!
425
- * @param fn Function that needed to run no more than one time
426
- */
427
- declare const once: (fn: () => void) => () => void;
428
- declare const isExitImpossible: (path: Path) => boolean;
429
- declare const getOppositeAction: (action: 'showCharacter' | 'playSound' | 'playMusic' | 'voice' | any) => "stopMusic" | "stopSound" | "stopVoice" | "hideCharacter";
430
- declare const getActionsFromPath: (story: Story, path: Path, raw?: boolean) => [any, any][];
431
- declare const createQueueProcessor: (queue: [
432
- any,
433
- any
434
- ][]) => {
435
- run: (match: (action: keyof ActionProxyProvider<Record<string, Character>, string>, props: any) => Thenable<void>) => Promise<void>;
436
- getKeep: () => {
437
- keep: Set<unknown>;
438
- characters: Set<unknown>;
439
- audio: {
440
- music: Set<unknown>;
441
- sound: Set<unknown>;
442
- };
443
- };
444
- };
445
- declare const getStack: (ctx: Context) => StackHolder;
446
- declare const createUseStackFunction: (renderer: Renderer) => (context: Context | string) => UseStackFunctionReturnType;
447
-
448
- export { findLastPathItemBeforeItemOfType as $, type ActionProxyProvider as A, type BaseTranslationStrings as B, type Character as C, type Data as D, type Emotions as E, type FunctionableValue as F, type GetActionParameters as G, isEmpty as H, isCSSImage as I, JP as J, KK as K, type Lang as L, type Migration as M, type NovelyScreen as N, str as O, type Path as P, isUserRequiredAction as Q, type RendererInit as R, type StorageData as S, type Thenable as T, type Unwrappable as U, type ValidAction as V, throttle as W, isFunction as X, findLastIndex as Y, findLast as Z, createControlledPromise as _, type State as a, isBlockStatement as a0, isBlockExitStatement as a1, isSkippedDuringRestore as a2, noop as a3, isAction as a4, flattenStory as a5, once as a6, isExitImpossible as a7, getOppositeAction as a8, getActionsFromPath as a9, createQueueProcessor as aa, getStack as ab, createUseStackFunction as ac, type Story as b, type DeepPartial as c, type Renderer as d, type DefaultActionProxyProvider as e, type CustomHandler as f, getLanguage as g, type CustomHandlerGetResult as h, type CustomHandlerGetResultDataFunction as i, type CustomHandlerFunctionGetFn as j, type CustomHandlerFunctionParameters as k, type CharacterHandle as l, type AudioHandle as m, type Context as n, type StorageMeta as o, type TypewriterSpeed as p, type CoreData as q, type Save as r, type Stored as s, RU as t, EN as u, matchAction as v, isNumber as w, isNull as x, isString as y, isPromise as z };
package/dist/utils.d.ts DELETED
@@ -1 +0,0 @@
1
- export { _ as createControlledPromise, aa as createQueueProcessor, ac as createUseStackFunction, Z as findLast, Y as findLastIndex, $ as findLastPathItemBeforeItemOfType, a5 as flattenStory, a9 as getActionsFromPath, g as getLanguage, a8 as getOppositeAction, ab as getStack, a4 as isAction, a1 as isBlockExitStatement, a0 as isBlockStatement, I as isCSSImage, H as isEmpty, a7 as isExitImpossible, X as isFunction, x as isNull, w as isNumber, z as isPromise, a2 as isSkippedDuringRestore, y as isString, Q as isUserRequiredAction, v as matchAction, a3 as noop, a6 as once, O as str, W as throttle } from './utils-RKG56tcx.js';