narraleaf-react 0.4.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +31 -33
  2. package/dist/game/nlcore/action/action.d.ts +29 -24
  3. package/dist/game/nlcore/action/actionHistory.d.ts +48 -37
  4. package/dist/game/nlcore/action/actionTypes.d.ts +142 -140
  5. package/dist/game/nlcore/action/actionable.d.ts +5 -5
  6. package/dist/game/nlcore/action/actions/characterAction.d.ts +19 -17
  7. package/dist/game/nlcore/action/actions/conditionAction.d.ts +26 -17
  8. package/dist/game/nlcore/action/actions/controlAction.d.ts +26 -38
  9. package/dist/game/nlcore/action/actions/displayableAction.d.ts +26 -22
  10. package/dist/game/nlcore/action/actions/imageAction.d.ts +25 -22
  11. package/dist/game/nlcore/action/actions/layerAction.d.ts +16 -12
  12. package/dist/game/nlcore/action/actions/menuAction.d.ts +21 -16
  13. package/dist/game/nlcore/action/actions/persistentAction.d.ts +17 -13
  14. package/dist/game/nlcore/action/actions/sceneAction.d.ts +47 -44
  15. package/dist/game/nlcore/action/actions/scriptAction.d.ts +14 -10
  16. package/dist/game/nlcore/action/actions/soundAction.d.ts +20 -18
  17. package/dist/game/nlcore/action/actions/storyAction.d.ts +8 -8
  18. package/dist/game/nlcore/action/actions/textAction.d.ts +16 -14
  19. package/dist/game/nlcore/action/actions/videoAction.d.ts +26 -22
  20. package/dist/game/nlcore/action/actions.d.ts +20 -13
  21. package/dist/game/nlcore/action/baseElement.d.ts +2 -2
  22. package/dist/game/nlcore/action/chain.d.ts +17 -17
  23. package/dist/game/nlcore/action/constructable.d.ts +5 -5
  24. package/dist/game/nlcore/action/gameHistory.d.ts +32 -28
  25. package/dist/game/nlcore/action/logicAction.d.ts +52 -52
  26. package/dist/game/nlcore/action/serviceAction.d.ts +24 -11
  27. package/dist/game/nlcore/action/srcManager.d.ts +47 -47
  28. package/dist/game/nlcore/action/stackModel.d.ts +106 -0
  29. package/dist/game/nlcore/action/tree/actionTree.d.ts +56 -56
  30. package/dist/game/nlcore/common/Utils.d.ts +25 -25
  31. package/dist/game/nlcore/common/core.d.ts +8 -8
  32. package/dist/game/nlcore/common/elements.d.ts +19 -19
  33. package/dist/game/nlcore/common/game.d.ts +8 -7
  34. package/dist/game/nlcore/common/player.d.ts +7 -7
  35. package/dist/game/nlcore/common/position.d.ts +2 -2
  36. package/dist/game/nlcore/common/transition.d.ts +6 -6
  37. package/dist/game/nlcore/common/types.d.ts +9 -9
  38. package/dist/game/nlcore/elements/character/pause.d.ts +8 -8
  39. package/dist/game/nlcore/elements/character/sentence.d.ts +25 -25
  40. package/dist/game/nlcore/elements/character/word.d.ts +18 -18
  41. package/dist/game/nlcore/elements/character.d.ts +56 -51
  42. package/dist/game/nlcore/elements/condition.d.ts +20 -20
  43. package/dist/game/nlcore/elements/control.d.ts +76 -76
  44. package/dist/game/nlcore/elements/displayable/displayable.d.ts +76 -76
  45. package/dist/game/nlcore/elements/displayable/image.d.ts +102 -91
  46. package/dist/game/nlcore/elements/displayable/text.d.ts +74 -74
  47. package/dist/game/nlcore/elements/layer.d.ts +33 -23
  48. package/dist/game/nlcore/elements/menu.d.ts +45 -43
  49. package/dist/game/nlcore/elements/persistent/storable.d.ts +24 -24
  50. package/dist/game/nlcore/elements/persistent/type.d.ts +3 -3
  51. package/dist/game/nlcore/elements/persistent.d.ts +86 -86
  52. package/dist/game/nlcore/elements/scene.d.ts +76 -76
  53. package/dist/game/nlcore/elements/script.d.ts +16 -16
  54. package/dist/game/nlcore/elements/service.d.ts +59 -59
  55. package/dist/game/nlcore/elements/sound.d.ts +89 -75
  56. package/dist/game/nlcore/elements/story.d.ts +92 -78
  57. package/dist/game/nlcore/elements/transform/position.d.ts +99 -101
  58. package/dist/game/nlcore/elements/transform/transform.d.ts +119 -119
  59. package/dist/game/nlcore/elements/transform/type.d.ts +32 -32
  60. package/dist/game/nlcore/elements/transition/transition.d.ts +29 -29
  61. package/dist/game/nlcore/elements/transition/transitions/image/darkness.d.ts +20 -0
  62. package/dist/game/nlcore/elements/transition/transitions/image/dissolve.d.ts +17 -17
  63. package/dist/game/nlcore/elements/transition/transitions/image/fadeIn.d.ts +20 -20
  64. package/dist/game/nlcore/elements/transition/transitions/image/imageTransition.d.ts +28 -28
  65. package/dist/game/nlcore/elements/transition/transitions/text/fontSize.d.ts +13 -13
  66. package/dist/game/nlcore/elements/transition/transitions/text/textTransition.d.ts +10 -10
  67. package/dist/game/nlcore/elements/transition/type.d.ts +51 -51
  68. package/dist/game/nlcore/elements/type.d.ts +16 -15
  69. package/dist/game/nlcore/elements/video.d.ts +23 -23
  70. package/dist/game/nlcore/game/liveGame.d.ts +148 -124
  71. package/dist/game/nlcore/game/plugin/plugin.d.ts +16 -16
  72. package/dist/game/nlcore/game/preference.d.ts +32 -32
  73. package/dist/game/nlcore/game.d.ts +79 -90
  74. package/dist/game/nlcore/gameTypes.d.ts +439 -334
  75. package/dist/game/nlcore/types.d.ts +67 -66
  76. package/dist/game/player/Tasks.d.ts +125 -106
  77. package/dist/game/player/elements/Player.d.ts +4 -4
  78. package/dist/game/player/elements/displayable/Displayable.d.ts +1 -1
  79. package/dist/game/player/elements/displayable/Displayables.d.ts +1 -1
  80. package/dist/game/player/elements/displayable/Text.d.ts +1 -1
  81. package/dist/game/player/elements/displayable/type.d.ts +1 -1
  82. package/dist/game/player/elements/elements.d.ts +8 -8
  83. package/dist/game/player/elements/image/AspectScaleImage.d.ts +1 -1
  84. package/dist/game/player/elements/image/Image.d.ts +3 -3
  85. package/dist/game/player/elements/menu/PlayerMenu.d.ts +3 -3
  86. package/dist/game/player/elements/menu/UIMenu/Item.d.ts +12 -12
  87. package/dist/game/player/elements/menu/UIMenu/Menu.d.ts +6 -6
  88. package/dist/game/player/elements/menu/UIMenu/context.d.ts +23 -23
  89. package/dist/game/player/elements/menu/type.d.ts +16 -16
  90. package/dist/game/player/elements/notification/Notifications.d.ts +3 -3
  91. package/dist/game/player/elements/notification/PlayerNotification.d.ts +4 -4
  92. package/dist/game/player/elements/notification/context.d.ts +11 -11
  93. package/dist/game/player/elements/notification/type.d.ts +18 -19
  94. package/dist/game/player/elements/player/KeyEventAnnouncer.d.ts +1 -1
  95. package/dist/game/player/elements/player/Layer.d.ts +8 -8
  96. package/dist/game/player/elements/player/PreferenceUpdateAnnouncer.d.ts +4 -0
  97. package/dist/game/player/elements/player/RenderEventAnnoucer.d.ts +4 -0
  98. package/dist/game/player/elements/player/SizeUpdateAnnouncer.d.ts +1 -1
  99. package/dist/game/player/elements/preload/Preload.d.ts +1 -1
  100. package/dist/game/player/elements/say/Dialog.d.ts +13 -13
  101. package/dist/game/player/elements/say/Nametag.d.ts +2 -2
  102. package/dist/game/player/elements/say/Sentence.d.ts +37 -37
  103. package/dist/game/player/elements/say/UIDialog.d.ts +72 -69
  104. package/dist/game/player/elements/say/context.d.ts +4 -4
  105. package/dist/game/player/elements/say/type.d.ts +53 -53
  106. package/dist/game/player/elements/say/useDialog.d.ts +18 -16
  107. package/dist/game/player/elements/scene/Scene.d.ts +1 -1
  108. package/dist/game/player/elements/type.d.ts +53 -53
  109. package/dist/game/player/elements/video/video.d.ts +1 -1
  110. package/dist/game/player/gameState.d.ts +193 -186
  111. package/dist/game/player/gameState.type.d.ts +1 -1
  112. package/dist/game/player/guard.d.ts +24 -24
  113. package/dist/game/player/lib/AspectRatio.d.ts +7 -7
  114. package/dist/game/player/lib/AudioManager.d.ts +50 -42
  115. package/dist/game/player/lib/Cursor.d.ts +6 -6
  116. package/dist/game/player/lib/ErrorBoundary.d.ts +24 -24
  117. package/dist/game/player/lib/ErrorFallback.d.ts +5 -5
  118. package/dist/game/player/lib/ImageCacheManager.d.ts +26 -26
  119. package/dist/game/player/lib/Inspect.d.ts +36 -36
  120. package/dist/game/player/lib/PageRouter/AnimatePresence.d.ts +4 -0
  121. package/dist/game/player/lib/PageRouter/Page.d.ts +9 -9
  122. package/dist/game/player/lib/PageRouter/PageRouter.d.ts +27 -27
  123. package/dist/game/player/lib/PageRouter/Stage.d.ts +6 -6
  124. package/dist/game/player/lib/PageRouter/router.d.ts +28 -23
  125. package/dist/game/player/lib/PlayerFrames.d.ts +10 -10
  126. package/dist/game/player/lib/Preloaded.d.ts +48 -48
  127. package/dist/game/player/lib/flush.d.ts +5 -5
  128. package/dist/game/player/lib/isolated.d.ts +7 -7
  129. package/dist/game/player/lib/notification.d.ts +47 -47
  130. package/dist/game/player/lib/preferences.d.ts +8 -8
  131. package/dist/game/player/lib/useElementVisibility.d.ts +5 -5
  132. package/dist/game/player/lib/useExposeState.d.ts +10 -10
  133. package/dist/game/player/lib/useLiveGame.d.ts +1 -1
  134. package/dist/game/player/libElements.d.ts +12 -12
  135. package/dist/game/player/provider/game-state.d.ts +24 -24
  136. package/dist/game/player/provider/preloaded.d.ts +1 -1
  137. package/dist/game/player/provider/providers.d.ts +7 -7
  138. package/dist/game/player/provider/ratio.d.ts +1 -1
  139. package/dist/game/player/type.d.ts +68 -64
  140. package/dist/index.d.ts +3 -3
  141. package/dist/main.js +54 -53
  142. package/dist/util/config.d.ts +37 -37
  143. package/dist/util/data.d.ts +346 -308
  144. package/dist/util/logger.d.ts +21 -21
  145. package/dist/util/singleton.d.ts +5 -5
  146. package/package.json +5 -3
@@ -1,334 +1,439 @@
1
- import { LogicAction } from "./action/logicAction";
2
- import { ContentNode, RawData } from "./action/tree/actionTree";
3
- import { StorableData } from "./elements/persistent/type";
4
- import { ElementStateRaw } from "./elements/story";
5
- import { StringKeyOf } from "../../util/data";
6
- import { PlayerStateData } from "../player/gameState";
7
- import { GuardConfig } from "../player/guard";
8
- import React from "react";
9
- import { MenuComponent, NotificationComponent, SayComponent } from "./common/player";
10
- import { Color } from "./types";
11
- export interface SavedGame {
12
- name: string;
13
- meta: {
14
- created: number;
15
- updated: number;
16
- id: string;
17
- };
18
- game: {
19
- store: {
20
- [key: string]: StorableData;
21
- };
22
- elementStates: RawData<ElementStateRaw>[];
23
- stage: PlayerStateData;
24
- currentAction: string | null;
25
- services: {
26
- [key: string]: unknown;
27
- };
28
- };
29
- }
30
- export type GameConfig = {
31
- /**
32
- * The id of the container element for the game
33
- * @default "__narraleaf_content"
34
- */
35
- contentContainerId: string;
36
- /**
37
- * The aspect ratio of the game
38
- * Ex: 16/9, 4/3, 1/1
39
- * @default 16/9
40
- */
41
- aspectRatio: number;
42
- /**
43
- * The minimum width and height of the player in pixels
44
- * @default 800
45
- */
46
- minWidth: number;
47
- /**
48
- * The minimum width and height of the player in pixels
49
- * @default 450
50
- */
51
- minHeight: number;
52
- /**
53
- * Base width of the player in pixels, Image scale will be calculated based on this value
54
- *
55
- * For 16/9, the recommended value is 1920
56
- * @default 1920
57
- */
58
- width: number;
59
- /**
60
- * Base height of the player in pixels, Image scale will be calculated based on this value
61
- *
62
- * For 16/9, the recommended value is 1080
63
- * @default 1080
64
- */
65
- height: number;
66
- /**
67
- * When the player presses one of these keys, the game will skip the current action
68
- *
69
- * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
70
- * @default ["Control"]
71
- */
72
- skipKey: React.KeyboardEvent["key"][];
73
- /**
74
- * The interval in milliseconds between each skip action.
75
- * ex: 100 ms means the player can skip 10 actions per second.
76
- * higher value means faster skipping.
77
- * @default 100
78
- */
79
- skipInterval: number;
80
- /**
81
- * The debounced interval in milliseconds for updating the aspect ratio
82
- *
83
- * Set to 0 to update the ratio immediately on every resize event.
84
- * @default 50
85
- */
86
- ratioUpdateInterval: number;
87
- /**
88
- * The game will preload the image with this delay between each preload task
89
- *
90
- * A single preload task may contain {@link GameConfig.preloadConcurrency} images
91
- * @default 100
92
- */
93
- preloadDelay: number;
94
- /**
95
- * Maximum number of images to preload at the same time
96
- * @default 5
97
- */
98
- preloadConcurrency: number;
99
- /**
100
- * Wait for the images to load before showing the game
101
- * @default true
102
- */
103
- waitForPreload: boolean;
104
- /**
105
- * Preload all possible images in the scene
106
- *
107
- * Enabling this may have a performance impact but is better for the user experience
108
- * @default true
109
- */
110
- preloadAllImages: boolean;
111
- /**
112
- * Force the game to clear the cache when the scene changes
113
- * @default false
114
- */
115
- forceClearCache: boolean;
116
- /**
117
- * The number of actions will be predicted and preloaded
118
- * @default 10
119
- */
120
- maxPreloadActions: number;
121
- /**
122
- * Src of the cursor image, if null, the game will show the default cursor
123
- * @default null
124
- */
125
- cursor: string | null;
126
- /**
127
- * Cursor width in pixels
128
- * @default 30
129
- */
130
- cursorWidth: number;
131
- /**
132
- * Cursor height in pixels
133
- * @default 30
134
- */
135
- cursorHeight: number;
136
- /**
137
- * Show overflowed content on player components
138
- * @default false
139
- */
140
- showOverflow: boolean;
141
- /**
142
- * Max history size for the page router
143
- * @default 10
144
- */
145
- maxRouterHistory: number;
146
- /**
147
- * Quality of the screenshot, between 0 and 1
148
- * @default 1
149
- */
150
- screenshotQuality: number;
151
- /**
152
- * When the player presses one of these keys, the game will show the next sentence
153
- *
154
- * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
155
- * @default [" "]
156
- */
157
- nextKey: React.KeyboardEvent["key"][];
158
- /**
159
- * The speed of the text effects in characters per second.
160
- * @default 10
161
- */
162
- cps: number;
163
- /**
164
- * If true, the game will scale the dialog to fit the screen
165
- *
166
- * Text will look smaller when this is enabled
167
- * @default true
168
- */
169
- useAspectScale: boolean;
170
- /**
171
- * The delay in milliseconds before the game automatically shows the next sentence
172
- *
173
- * Only works when the player preference "autoForward" is enabled
174
- * @default 3000
175
- */
176
- autoForwardDelay: number;
177
- /**
178
- * The default pause duration in milliseconds when auto-forward is enabled
179
- *
180
- * When auto-forward is enabled, any Pause without a custom duration will use this value
181
- * @default 1000
182
- */
183
- autoForwardDefaultPause: number;
184
- /**
185
- * If true, when you press [GameConfig.player.skipKey], the game will skip the image transform
186
- * @default true
187
- */
188
- allowSkipImageTransform: boolean;
189
- /**
190
- * If true, when you press [GameConfig.player.skipKey], the game will skip the image transition
191
- * @default true
192
- */
193
- allowSkipImageTransition: boolean;
194
- /**
195
- * If true, when you press [GameConfig.player.skipKey], the game will skip the background transform
196
- * @default true
197
- */
198
- allowSkipBackgroundTransform: boolean;
199
- /**
200
- * If true, when you press [GameConfig.player.skipKey], the game will skip the background transition
201
- * @default false
202
- */
203
- allowSkipBackgroundTransition: boolean;
204
- /**
205
- * If true, when you press [GameConfig.player.skipKey], the game will skip the text transform
206
- * @default true
207
- */
208
- allowSkipTextTransform: boolean;
209
- /**
210
- * If true, when you press [GameConfig.player.skipKey], the game will skip the text transition
211
- * @default true
212
- */
213
- allowSkipTextTransition: boolean;
214
- /**
215
- * Base width of the dialog in pixels
216
- *
217
- * For 16/9, the recommended value is 1920
218
- * @default 1920
219
- */
220
- dialogWidth: number;
221
- /**
222
- * Base height of the dialog in pixels
223
- *
224
- * For 16/9, the recommended value is 1080 * 0.2 (20% of the screen height)
225
- * @default 1080 * 0.2
226
- */
227
- dialogHeight: number;
228
- /**
229
- * If true, when you press [GameConfig.player.skipKey], the game will skip the text transform
230
- * @default true
231
- */
232
- allowSkipLayersTransform: boolean;
233
- /**
234
- * If true, when you press [GameConfig.player.skipKey], the game will skip the video transform
235
- *
236
- * This will only skip the "play" action
237
- *
238
- * @default false
239
- */
240
- allowSkipVideo: boolean;
241
- /**
242
- * The default text color for the dialog
243
- * @default "#000"
244
- */
245
- defaultTextColor: Color;
246
- /**
247
- * The default text color for the character nametag
248
- * @default "#000"
249
- */
250
- defaultNametagColor: Color;
251
- /**
252
- * The component to use for the notification
253
- * @default DefaultNotification
254
- */
255
- notification: NotificationComponent;
256
- /**
257
- * The component to use for the menu
258
- * @default DefaultMenu
259
- */
260
- menu: MenuComponent;
261
- /**
262
- * The component to use for the say
263
- * @default DefaultSay
264
- */
265
- dialog: SayComponent;
266
- /**
267
- * The function to call when an error occurs
268
- * @default () => {}
269
- */
270
- onError: (error: Error) => void;
271
- app: {
272
- debug: boolean;
273
- /**
274
- * Log level for the logger
275
- * Set to true to enable all logs
276
- */
277
- logger: {
278
- log: boolean;
279
- info: boolean;
280
- warn: boolean;
281
- error: boolean;
282
- debug: boolean;
283
- trace: boolean;
284
- verbose: boolean;
285
- } | boolean;
286
- /**
287
- * If true, the game will show the inspector when you hover over the element
288
- */
289
- inspector: boolean;
290
- /**
291
- * The config of {@link GameStateGuard}
292
- */
293
- guard: GuardConfig;
294
- };
295
- /**
296
- * Default font size for the game
297
- * @default "16px"
298
- */
299
- fontSize: React.CSSProperties["fontSize"];
300
- /**
301
- * Default font weight for the game
302
- * @default 400
303
- */
304
- fontWeight: number;
305
- /**
306
- * Default font weight for the game
307
- * @default 700
308
- */
309
- fontWeightBold: number;
310
- /**
311
- * Default font family for the game
312
- * @default "sans-serif"
313
- */
314
- fontFamily: React.CSSProperties["fontFamily"];
315
- /**
316
- * Override the default stage
317
- * @default null
318
- */
319
- stage: React.ReactNode | null;
320
- /**
321
- * The default color for the menu choices
322
- * @default "#000"
323
- */
324
- defaultMenuChoiceColor: Color;
325
- };
326
- export type GameSettings = {
327
- volume: number;
328
- };
329
- export type CalledActionResult<T extends keyof LogicAction.ActionContents = any> = {
330
- [K in StringKeyOf<LogicAction.ActionContents>]: {
331
- type: T extends undefined ? K : T;
332
- node: ContentNode<LogicAction.ActionContents[T extends undefined ? K : T]> | null;
333
- };
334
- }[StringKeyOf<LogicAction.ActionContents>];
1
+ import { LogicAction } from "./action/logicAction";
2
+ import { ContentNode, RawData } from "./action/tree/actionTree";
3
+ import { StorableData } from "./elements/persistent/type";
4
+ import { ElementStateRaw } from "./elements/story";
5
+ import { StringKeyOf } from "../../util/data";
6
+ import { PlayerStateData } from "../player/gameState";
7
+ import { GuardConfig } from "../player/guard";
8
+ import React from "react";
9
+ import { StackModel, StackModelRawData } from "./action/stackModel";
10
+ import { MenuComponent, NotificationComponent, SayComponent } from "./common/player";
11
+ import { Color, LiveGameEventToken } from "./types";
12
+ export interface SavedGameMetaData {
13
+ /**
14
+ * The timestamp of when the game was created
15
+ */
16
+ created: number;
17
+ /**
18
+ * The timestamp of when the game was last updated
19
+ */
20
+ updated: number;
21
+ /**
22
+ * The id of the game, unique to each saved game
23
+ */
24
+ id: string;
25
+ /**
26
+ * The last sentence that was spoken
27
+ */
28
+ lastSentence: string | null;
29
+ /**
30
+ * The last speaker that spoke
31
+ */
32
+ lastSpeaker: string | null;
33
+ /**
34
+ * The hash of the story is used to check whether the stories are compatible.
35
+ */
36
+ storyHash: string;
37
+ }
38
+ export interface SavedGame {
39
+ name: string;
40
+ meta: SavedGameMetaData;
41
+ game: {
42
+ store: {
43
+ [key: string]: StorableData;
44
+ };
45
+ elementStates: RawData<ElementStateRaw>[];
46
+ stage: PlayerStateData;
47
+ services: {
48
+ [key: string]: unknown;
49
+ };
50
+ stackModel: StackModelRawData;
51
+ asyncStackModels: StackModelRawData[];
52
+ };
53
+ }
54
+ export type GameConfig = {
55
+ /**
56
+ * The id of the container element for the game
57
+ * @default "__narraleaf_content"
58
+ */
59
+ contentContainerId: string;
60
+ /**
61
+ * The aspect ratio of the game
62
+ * Ex: 16/9, 4/3, 1/1
63
+ * @default 16/9
64
+ */
65
+ aspectRatio: number;
66
+ /**
67
+ * The minimum width and height of the player in pixels
68
+ * @default 800
69
+ */
70
+ minWidth: number;
71
+ /**
72
+ * The minimum width and height of the player in pixels
73
+ * @default 450
74
+ */
75
+ minHeight: number;
76
+ /**
77
+ * Base width of the player in pixels, Image scale will be calculated based on this value
78
+ *
79
+ * For 16/9, the recommended value is 1920
80
+ * @default 1920
81
+ */
82
+ width: number;
83
+ /**
84
+ * Base height of the player in pixels, Image scale will be calculated based on this value
85
+ *
86
+ * For 16/9, the recommended value is 1080
87
+ * @default 1080
88
+ */
89
+ height: number;
90
+ /**
91
+ * When the player presses one of these keys, the game will skip the current action
92
+ *
93
+ * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
94
+ * @default ["Control"]
95
+ */
96
+ skipKey: React.KeyboardEvent["key"][];
97
+ /**
98
+ * If true, the game will listen to the window events instead of the player element
99
+ *
100
+ * Using this will allow the game to listen to the keyboard events even when the player is not focused
101
+ * Resulting in a better user experience on skipping actions
102
+ * @default true
103
+ */
104
+ useWindowListener: boolean;
105
+ /**
106
+ * The debounced interval in milliseconds for updating the aspect ratio
107
+ *
108
+ * Set to 0 to update the ratio immediately on every resize event.
109
+ * @default 50
110
+ */
111
+ ratioUpdateInterval: number;
112
+ /**
113
+ * The game will preload the image with this delay between each preload task
114
+ *
115
+ * A single preload task may contain {@link GameConfig.preloadConcurrency} images
116
+ * @default 100
117
+ */
118
+ preloadDelay: number;
119
+ /**
120
+ * Maximum number of images to preload at the same time
121
+ * @default 5
122
+ */
123
+ preloadConcurrency: number;
124
+ /**
125
+ * Wait for the images to load before showing the game
126
+ * @default true
127
+ */
128
+ waitForPreload: boolean;
129
+ /**
130
+ * Preload all possible images in the scene
131
+ *
132
+ * Enabling this may have a performance impact but is better for the user experience
133
+ * @default true
134
+ */
135
+ preloadAllImages: boolean;
136
+ /**
137
+ * Force the game to clear the cache when the scene changes
138
+ * @default false
139
+ */
140
+ forceClearCache: boolean;
141
+ /**
142
+ * The number of actions will be predicted and preloaded
143
+ * @default 10
144
+ */
145
+ maxPreloadActions: number;
146
+ /**
147
+ * Src of the cursor image, if null, the game will show the default cursor
148
+ * @default null
149
+ */
150
+ cursor: string | null;
151
+ /**
152
+ * Cursor width in pixels
153
+ * @default 30
154
+ */
155
+ cursorWidth: number;
156
+ /**
157
+ * Cursor height in pixels
158
+ * @default 30
159
+ */
160
+ cursorHeight: number;
161
+ /**
162
+ * Show overflowed content on player components
163
+ * @default false
164
+ */
165
+ showOverflow: boolean;
166
+ /**
167
+ * Max history size for the page router
168
+ * @default 10
169
+ */
170
+ maxRouterHistory: number;
171
+ /**
172
+ * Quality of the screenshot, between 0 and 1
173
+ * @default 1
174
+ */
175
+ screenshotQuality: number;
176
+ /**
177
+ * When the player presses one of these keys, the game will show the next sentence
178
+ *
179
+ * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
180
+ * @default [" "]
181
+ */
182
+ nextKey: React.KeyboardEvent["key"][];
183
+ /**
184
+ * If true, the game will scale the dialog to fit the screen
185
+ *
186
+ * Text will look smaller when this is enabled
187
+ * @default true
188
+ */
189
+ useAspectScale: boolean;
190
+ /**
191
+ * The delay in milliseconds before the game automatically shows the next sentence
192
+ *
193
+ * Only works when the player preference "autoForward" is enabled
194
+ * @default 3000
195
+ */
196
+ autoForwardDelay: number;
197
+ /**
198
+ * The default pause duration in milliseconds when auto-forward is enabled
199
+ *
200
+ * When auto-forward is enabled, any Pause without a custom duration will use this value
201
+ * @default 1000
202
+ */
203
+ autoForwardDefaultPause: number;
204
+ /**
205
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the image transform
206
+ * @default true
207
+ */
208
+ allowSkipImageTransform: boolean;
209
+ /**
210
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the image transition
211
+ * @default true
212
+ */
213
+ allowSkipImageTransition: boolean;
214
+ /**
215
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the background transform
216
+ * @default true
217
+ */
218
+ allowSkipBackgroundTransform: boolean;
219
+ /**
220
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the background transition
221
+ * @default false
222
+ */
223
+ allowSkipBackgroundTransition: boolean;
224
+ /**
225
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the text transform
226
+ * @default true
227
+ */
228
+ allowSkipTextTransform: boolean;
229
+ /**
230
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the text transition
231
+ * @default true
232
+ */
233
+ allowSkipTextTransition: boolean;
234
+ /**
235
+ * Base width of the dialog in pixels
236
+ *
237
+ * For 16/9, the recommended value is 1920
238
+ * @default 1920
239
+ */
240
+ dialogWidth: number;
241
+ /**
242
+ * Base height of the dialog in pixels
243
+ *
244
+ * For 16/9, the recommended value is 1080 * 0.2 (20% of the screen height)
245
+ * @default 1080 * 0.2
246
+ */
247
+ dialogHeight: number;
248
+ /**
249
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the text transform
250
+ * @default true
251
+ */
252
+ allowSkipLayersTransform: boolean;
253
+ /**
254
+ * If true, when you press [GameConfig.player.skipKey], the game will skip the video transform
255
+ *
256
+ * This will only skip the "play" action
257
+ *
258
+ * @default false
259
+ */
260
+ allowSkipVideo: boolean;
261
+ /**
262
+ * The default text color for the dialog
263
+ * @default "#000"
264
+ */
265
+ defaultTextColor: Color;
266
+ /**
267
+ * The default text color for the character nametag
268
+ * @default "#000"
269
+ */
270
+ defaultNametagColor: Color;
271
+ /**
272
+ * The component to use for the notification
273
+ * @default DefaultNotification
274
+ */
275
+ notification: NotificationComponent;
276
+ /**
277
+ * The component to use for the menu
278
+ * @default DefaultMenu
279
+ */
280
+ menu: MenuComponent;
281
+ /**
282
+ * The component to use for the say
283
+ * @default DefaultSay
284
+ */
285
+ dialog: SayComponent;
286
+ /**
287
+ * The function to call when an error occurs
288
+ * @default () => {}
289
+ */
290
+ onError: (error: Error) => void;
291
+ app: {
292
+ debug: boolean;
293
+ /**
294
+ * Log level for the logger
295
+ * Set to true to enable all logs
296
+ */
297
+ logger: {
298
+ log: boolean;
299
+ info: boolean;
300
+ warn: boolean;
301
+ error: boolean;
302
+ debug: boolean;
303
+ trace: boolean;
304
+ verbose: boolean;
305
+ } | boolean;
306
+ /**
307
+ * If true, the game will show the inspector when you hover over the element
308
+ */
309
+ inspector: boolean;
310
+ /**
311
+ * The config of {@link GameStateGuard}
312
+ */
313
+ guard: GuardConfig;
314
+ };
315
+ /**
316
+ * Default font size for the game
317
+ * @default "16px"
318
+ */
319
+ fontSize: React.CSSProperties["fontSize"];
320
+ /**
321
+ * Default font weight for the game
322
+ * @default 400
323
+ */
324
+ fontWeight: number;
325
+ /**
326
+ * Default font weight for the game
327
+ * @default 700
328
+ */
329
+ fontWeightBold: number;
330
+ /**
331
+ * Default font family for the game
332
+ * @default "sans-serif"
333
+ */
334
+ fontFamily: React.CSSProperties["fontFamily"];
335
+ /**
336
+ * Override the default stage
337
+ * @default null
338
+ */
339
+ stage: React.ReactNode | null;
340
+ /**
341
+ * The default color for the menu choices
342
+ * @default "#000"
343
+ */
344
+ defaultMenuChoiceColor: Color;
345
+ /**
346
+ * The maximum number of times a stack model can loop
347
+ * @default 1000
348
+ */
349
+ maxStackModelLoop: number;
350
+ /**
351
+ * The maximum number of actions to store in the action history
352
+ * @default 100
353
+ */
354
+ maxActionHistory: number;
355
+ };
356
+ export type GameSettings = {
357
+ volume: number;
358
+ };
359
+ export type StackModelWaiting = {
360
+ type: "any" | "all";
361
+ stackModels: StackModel[];
362
+ };
363
+ export type CalledActionResult<T extends keyof LogicAction.ActionContents = any> = {
364
+ [K in StringKeyOf<LogicAction.ActionContents>]: {
365
+ type: T extends undefined ? K : T;
366
+ node: ContentNode<LogicAction.ActionContents[T extends undefined ? K : T]> | null;
367
+ wait?: StackModelWaiting | null;
368
+ };
369
+ }[StringKeyOf<LogicAction.ActionContents>];
370
+ export interface NotificationToken extends LiveGameEventToken {
371
+ promise: Promise<void>;
372
+ }
373
+ export type GamePreference = {
374
+ /**
375
+ * If true, the game will automatically forward to the next sentence when the player has finished the current sentence
376
+ * @default false
377
+ */
378
+ autoForward: boolean;
379
+ /**
380
+ * If true, the game will allow the player to skip the dialog
381
+ * @default true
382
+ */
383
+ skip: boolean;
384
+ /**
385
+ * If true, the game will show the dialog
386
+ * @default true
387
+ */
388
+ showDialog: boolean;
389
+ /**
390
+ * The multiplier of the dialog speed
391
+ *
392
+ * Dialog speed will apply to:
393
+ * - The text speed
394
+ * - The auto-forward delay
395
+ * @default 1.0
396
+ */
397
+ gameSpeed: number;
398
+ /**
399
+ * The speed of the text effects in characters per second.
400
+ * @default 10
401
+ */
402
+ cps: number;
403
+ /**
404
+ * The volume of the voice
405
+ * @default 1
406
+ */
407
+ voiceVolume: number;
408
+ /**
409
+ * The volume of the background music
410
+ * @default 1
411
+ */
412
+ bgmVolume: number;
413
+ /**
414
+ * The volume of the sound effects
415
+ * @default 1
416
+ */
417
+ soundVolume: number;
418
+ /**
419
+ * The volume of the global audio
420
+ * @default 1
421
+ */
422
+ globalVolume: number;
423
+ /**
424
+ * The delay in milliseconds before the game starts skipping actions
425
+ *
426
+ * This is used to prevent the game from skipping actions too quickly when the player presses the skip key.
427
+ *
428
+ * Set to 0 to skip actions immediately when the player presses the skip key.
429
+ * @default 500
430
+ */
431
+ skipDelay: number;
432
+ /**
433
+ * The interval in milliseconds between each skip action.
434
+ * ex: 100 ms means the player can skip 10 actions per second.
435
+ * higher value means slower skipping.
436
+ * @default 100
437
+ */
438
+ skipInterval: number;
439
+ };