narraleaf-react 0.5.0 → 0.7.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 (151) hide show
  1. package/dist/game/nlcore/action/action.d.ts +29 -24
  2. package/dist/game/nlcore/action/actionHistory.d.ts +48 -39
  3. package/dist/game/nlcore/action/actionTypes.d.ts +142 -142
  4. package/dist/game/nlcore/action/actionable.d.ts +5 -5
  5. package/dist/game/nlcore/action/actions/characterAction.d.ts +19 -17
  6. package/dist/game/nlcore/action/actions/conditionAction.d.ts +26 -17
  7. package/dist/game/nlcore/action/actions/controlAction.d.ts +26 -38
  8. package/dist/game/nlcore/action/actions/displayableAction.d.ts +26 -22
  9. package/dist/game/nlcore/action/actions/imageAction.d.ts +25 -23
  10. package/dist/game/nlcore/action/actions/layerAction.d.ts +16 -13
  11. package/dist/game/nlcore/action/actions/menuAction.d.ts +21 -16
  12. package/dist/game/nlcore/action/actions/persistentAction.d.ts +17 -13
  13. package/dist/game/nlcore/action/actions/sceneAction.d.ts +47 -44
  14. package/dist/game/nlcore/action/actions/scriptAction.d.ts +14 -10
  15. package/dist/game/nlcore/action/actions/soundAction.d.ts +20 -18
  16. package/dist/game/nlcore/action/actions/storyAction.d.ts +8 -8
  17. package/dist/game/nlcore/action/actions/textAction.d.ts +16 -14
  18. package/dist/game/nlcore/action/actions/videoAction.d.ts +26 -22
  19. package/dist/game/nlcore/action/actions.d.ts +20 -13
  20. package/dist/game/nlcore/action/baseElement.d.ts +2 -2
  21. package/dist/game/nlcore/action/chain.d.ts +17 -17
  22. package/dist/game/nlcore/action/constructable.d.ts +5 -5
  23. package/dist/game/nlcore/action/gameHistory.d.ts +32 -32
  24. package/dist/game/nlcore/action/logicAction.d.ts +52 -52
  25. package/dist/game/nlcore/action/serviceAction.d.ts +24 -11
  26. package/dist/game/nlcore/action/srcManager.d.ts +47 -47
  27. package/dist/game/nlcore/action/stackModel.d.ts +106 -0
  28. package/dist/game/nlcore/action/tree/actionTree.d.ts +56 -56
  29. package/dist/game/nlcore/common/Utils.d.ts +25 -25
  30. package/dist/game/nlcore/common/core.d.ts +8 -8
  31. package/dist/game/nlcore/common/elements.d.ts +19 -19
  32. package/dist/game/nlcore/common/game.d.ts +9 -7
  33. package/dist/game/nlcore/common/player.d.ts +9 -7
  34. package/dist/game/nlcore/common/position.d.ts +2 -2
  35. package/dist/game/nlcore/common/transition.d.ts +6 -6
  36. package/dist/game/nlcore/common/types.d.ts +13 -9
  37. package/dist/game/nlcore/elements/character/pause.d.ts +8 -8
  38. package/dist/game/nlcore/elements/character/sentence.d.ts +25 -25
  39. package/dist/game/nlcore/elements/character/word.d.ts +18 -18
  40. package/dist/game/nlcore/elements/character.d.ts +56 -52
  41. package/dist/game/nlcore/elements/condition.d.ts +20 -20
  42. package/dist/game/nlcore/elements/control.d.ts +76 -76
  43. package/dist/game/nlcore/elements/displayable/displayable.d.ts +76 -76
  44. package/dist/game/nlcore/elements/displayable/image.d.ts +102 -102
  45. package/dist/game/nlcore/elements/displayable/text.d.ts +74 -74
  46. package/dist/game/nlcore/elements/layer.d.ts +33 -33
  47. package/dist/game/nlcore/elements/menu.d.ts +45 -45
  48. package/dist/game/nlcore/elements/persistent/storable.d.ts +24 -24
  49. package/dist/game/nlcore/elements/persistent/type.d.ts +3 -3
  50. package/dist/game/nlcore/elements/persistent.d.ts +86 -86
  51. package/dist/game/nlcore/elements/scene.d.ts +76 -76
  52. package/dist/game/nlcore/elements/script.d.ts +16 -16
  53. package/dist/game/nlcore/elements/service.d.ts +59 -59
  54. package/dist/game/nlcore/elements/sound.d.ts +89 -89
  55. package/dist/game/nlcore/elements/story.d.ts +92 -78
  56. package/dist/game/nlcore/elements/transform/position.d.ts +99 -103
  57. package/dist/game/nlcore/elements/transform/transform.d.ts +119 -119
  58. package/dist/game/nlcore/elements/transform/type.d.ts +32 -32
  59. package/dist/game/nlcore/elements/transition/transition.d.ts +29 -29
  60. package/dist/game/nlcore/elements/transition/transitions/image/darkness.d.ts +20 -20
  61. package/dist/game/nlcore/elements/transition/transitions/image/dissolve.d.ts +17 -17
  62. package/dist/game/nlcore/elements/transition/transitions/image/fadeIn.d.ts +20 -20
  63. package/dist/game/nlcore/elements/transition/transitions/image/imageTransition.d.ts +28 -28
  64. package/dist/game/nlcore/elements/transition/transitions/text/fontSize.d.ts +13 -13
  65. package/dist/game/nlcore/elements/transition/transitions/text/textTransition.d.ts +10 -10
  66. package/dist/game/nlcore/elements/transition/type.d.ts +51 -51
  67. package/dist/game/nlcore/elements/type.d.ts +16 -16
  68. package/dist/game/nlcore/elements/video.d.ts +23 -23
  69. package/dist/game/nlcore/game/keyMap.d.ts +82 -0
  70. package/dist/game/nlcore/game/liveGame.d.ts +148 -138
  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/types.d.ts +22 -0
  74. package/dist/game/nlcore/game.d.ts +86 -116
  75. package/dist/game/nlcore/gameTypes.d.ts +432 -337
  76. package/dist/game/nlcore/types.d.ts +67 -67
  77. package/dist/game/player/Tasks.d.ts +125 -106
  78. package/dist/game/player/elements/Player.d.ts +4 -4
  79. package/dist/game/player/elements/displayable/Displayable.d.ts +1 -1
  80. package/dist/game/player/elements/displayable/Displayables.d.ts +1 -1
  81. package/dist/game/player/elements/displayable/Text.d.ts +1 -1
  82. package/dist/game/player/elements/displayable/type.d.ts +1 -1
  83. package/dist/game/player/elements/elements.d.ts +8 -8
  84. package/dist/game/player/elements/image/AspectScaleImage.d.ts +1 -1
  85. package/dist/game/player/elements/image/Image.d.ts +3 -3
  86. package/dist/game/player/elements/menu/PlayerMenu.d.ts +3 -3
  87. package/dist/game/player/elements/menu/UIMenu/Item.d.ts +12 -12
  88. package/dist/game/player/elements/menu/UIMenu/Menu.d.ts +6 -6
  89. package/dist/game/player/elements/menu/UIMenu/context.d.ts +23 -23
  90. package/dist/game/player/elements/menu/type.d.ts +16 -16
  91. package/dist/game/player/elements/notification/Notifications.d.ts +3 -3
  92. package/dist/game/player/elements/notification/PlayerNotification.d.ts +4 -4
  93. package/dist/game/player/elements/notification/context.d.ts +11 -11
  94. package/dist/game/player/elements/notification/type.d.ts +18 -19
  95. package/dist/game/player/elements/player/KeyEventAnnouncer.d.ts +1 -1
  96. package/dist/game/player/elements/player/Layer.d.ts +8 -8
  97. package/dist/game/player/elements/player/PreferenceUpdateAnnouncer.d.ts +4 -4
  98. package/dist/game/player/elements/player/RenderEventAnnoucer.d.ts +4 -4
  99. package/dist/game/player/elements/player/SizeUpdateAnnouncer.d.ts +1 -1
  100. package/dist/game/player/elements/preload/Preload.d.ts +1 -1
  101. package/dist/game/player/elements/say/Dialog.d.ts +13 -13
  102. package/dist/game/player/elements/say/Nametag.d.ts +2 -2
  103. package/dist/game/player/elements/say/Sentence.d.ts +37 -37
  104. package/dist/game/player/elements/say/UIDialog.d.ts +72 -71
  105. package/dist/game/player/elements/say/context.d.ts +4 -4
  106. package/dist/game/player/elements/say/type.d.ts +53 -53
  107. package/dist/game/player/elements/say/useDialog.d.ts +18 -18
  108. package/dist/game/player/elements/scene/Scene.d.ts +1 -1
  109. package/dist/game/player/elements/type.d.ts +59 -53
  110. package/dist/game/player/elements/video/video.d.ts +1 -1
  111. package/dist/game/player/gameState.d.ts +192 -191
  112. package/dist/game/player/gameState.type.d.ts +1 -1
  113. package/dist/game/player/guard.d.ts +24 -24
  114. package/dist/game/player/lib/AspectRatio.d.ts +7 -7
  115. package/dist/game/player/lib/AudioManager.d.ts +50 -50
  116. package/dist/game/player/lib/Cursor.d.ts +6 -6
  117. package/dist/game/player/lib/ErrorBoundary.d.ts +25 -24
  118. package/dist/game/player/lib/ErrorFallback.d.ts +5 -5
  119. package/dist/game/player/lib/ImageCacheManager.d.ts +26 -26
  120. package/dist/game/player/lib/Inspect.d.ts +36 -36
  121. package/dist/game/player/lib/PageRouter/AnimatePresence.d.ts +5 -4
  122. package/dist/game/player/lib/PageRouter/Layout.d.ts +48 -0
  123. package/dist/game/player/lib/PageRouter/Page.d.ts +46 -9
  124. package/dist/game/player/lib/PageRouter/Stage.d.ts +6 -6
  125. package/dist/game/player/lib/PageRouter/router.d.ts +638 -23
  126. package/dist/game/player/lib/PageRouter/routerHooks.d.ts +6 -0
  127. package/dist/game/player/lib/PlayerFrames.d.ts +10 -10
  128. package/dist/game/player/lib/Preloaded.d.ts +48 -48
  129. package/dist/game/player/lib/flush.d.ts +5 -5
  130. package/dist/game/player/lib/isolated.d.ts +7 -7
  131. package/dist/game/player/lib/keyMap.d.ts +3 -0
  132. package/dist/game/player/lib/notification.d.ts +47 -47
  133. package/dist/game/player/lib/preferences.d.ts +8 -8
  134. package/dist/game/player/lib/useConstant.d.ts +1 -0
  135. package/dist/game/player/lib/useElementVisibility.d.ts +5 -5
  136. package/dist/game/player/lib/useExposeState.d.ts +10 -10
  137. package/dist/game/player/lib/useLiveGame.d.ts +1 -1
  138. package/dist/game/player/libElements.d.ts +15 -12
  139. package/dist/game/player/provider/game-state.d.ts +24 -24
  140. package/dist/game/player/provider/preloaded.d.ts +1 -1
  141. package/dist/game/player/provider/providers.d.ts +7 -7
  142. package/dist/game/player/provider/ratio.d.ts +1 -1
  143. package/dist/game/player/type.d.ts +68 -68
  144. package/dist/index.d.ts +3 -3
  145. package/dist/main.js +44 -78
  146. package/dist/util/config.d.ts +37 -37
  147. package/dist/util/data.d.ts +346 -309
  148. package/dist/util/logger.d.ts +21 -21
  149. package/dist/util/singleton.d.ts +5 -5
  150. package/package.json +8 -5
  151. package/dist/game/player/lib/PageRouter/PageRouter.d.ts +0 -27
@@ -0,0 +1,22 @@
1
+ /**
2
+ * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
3
+ *
4
+ * Case-insensitive
5
+ */
6
+ export type WebKeyboardKey = string;
7
+ export declare enum KeyBindingType {
8
+ /**
9
+ * When the player presses one of these keys, the game will show the next sentence
10
+ *
11
+ * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
12
+ * @default [" "]
13
+ */
14
+ skipAction = "skipAction",
15
+ /**
16
+ * When the player presses one of these keys, the game will skip the current action
17
+ *
18
+ * See [Key_Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values)
19
+ * @default ["Control"]
20
+ */
21
+ nextAction = "nextAction"
22
+ }
@@ -1,116 +1,86 @@
1
- import type { GameConfig } from "./gameTypes";
2
- import { DeepPartial, Hooks } from "../../util/data";
3
- import { LogicAction } from "./action/logicAction";
4
- import { LiveGame } from "./game/liveGame";
5
- import { Preference } from "./game/preference";
6
- import { Plugins, IGamePluginRegistry } from "./game/plugin/plugin";
7
- declare enum GameSettingsNamespace {
8
- game = "game"
9
- }
10
- export type GamePreference = {
11
- /**
12
- * If true, the game will automatically forward to the next sentence when the player has finished the current sentence
13
- * @default false
14
- */
15
- autoForward: boolean;
16
- /**
17
- * If true, the game will allow the player to skip the dialog
18
- * @default true
19
- */
20
- skip: boolean;
21
- /**
22
- * If true, the game will show the dialog
23
- * @default true
24
- */
25
- showDialog: boolean;
26
- /**
27
- * The multiplier of the dialog speed
28
- *
29
- * Dialog speed will apply to:
30
- * - The text speed
31
- * - The auto-forward delay
32
- * @default 1.0
33
- */
34
- gameSpeed: number;
35
- /**
36
- * The speed of the text effects in characters per second.
37
- * @default 10
38
- */
39
- cps: number;
40
- /**
41
- * The volume of the voice
42
- * @default 1
43
- */
44
- voiceVolume: number;
45
- /**
46
- * The volume of the background music
47
- * @default 1
48
- */
49
- bgmVolume: number;
50
- /**
51
- * The volume of the sound effects
52
- * @default 1
53
- */
54
- soundVolume: number;
55
- /**
56
- * The volume of the global audio
57
- * @default 1
58
- */
59
- globalVolume: number;
60
- };
61
- export type GameHooks = {
62
- /**
63
- * Hook when the game is initialized
64
- *
65
- * This hook's behavior is similar to the `useEffect` hook in React. It will be called twice when the strict mode is enabled.
66
- * It is used to configure the game.
67
- */
68
- "init": [];
69
- /**
70
- * Hook when preloading images
71
- *
72
- * @param src - The source of the image
73
- * @param set - Calling this function will set the src and options of the fetch request. This is useful to proxy
74
- * - **Note**: "signal" is preserved from the original options
75
- */
76
- "preloadImage": [src: string, set: (src: string, options?: RequestInit) => void];
77
- };
78
- export declare class Game {
79
- static GameSettingsNamespace: typeof GameSettingsNamespace;
80
- readonly hooks: Hooks<GameHooks>;
81
- /**
82
- * Game settings
83
- */
84
- preference: Preference<GamePreference>;
85
- /**
86
- * Plugin registry
87
- */
88
- plugins: Plugins;
89
- /**
90
- * Create a new game
91
- * @param config - Game configuration
92
- */
93
- constructor(config: DeepPartial<GameConfig>);
94
- /**
95
- * Configure the game
96
- */
97
- configure(config: DeepPartial<GameConfig>): this;
98
- /**
99
- * Use a plugin
100
- * @param plugin - The plugin to use
101
- */
102
- use(plugin: IGamePluginRegistry): this;
103
- getLiveGame(): LiveGame;
104
- /**
105
- * Dispose the game and all its resources
106
- *
107
- * **Note**: This action is irreversible.
108
- */
109
- dispose(): void;
110
- }
111
- declare const _default: {
112
- Game: typeof Game;
113
- LiveGame: typeof LiveGame;
114
- };
115
- export default _default;
116
- export type { LogicAction };
1
+ import type { GameConfig, GamePreference } from "./gameTypes";
2
+ import { DeepPartial, Hooks, StringKeyOf } from "../../util/data";
3
+ import { LogicAction } from "./action/logicAction";
4
+ import { LiveGame } from "./game/liveGame";
5
+ import { Preference } from "./game/preference";
6
+ import { Plugins, IGamePluginRegistry } from "./game/plugin/plugin";
7
+ import { LayoutRouter } from "../player/lib/PageRouter/router";
8
+ import { KeyMap } from "./game/keyMap";
9
+ declare enum GameSettingsNamespace {
10
+ game = "game"
11
+ }
12
+ export type GameHooks = {
13
+ /**
14
+ * Hook when the game is initialized
15
+ *
16
+ * This hook's behavior is similar to the `useEffect` hook in React. It will be called twice when the strict mode is enabled.
17
+ * It is used to configure the game.
18
+ */
19
+ "init": [];
20
+ /**
21
+ * Hook when preloading images
22
+ *
23
+ * @param src - The source of the image
24
+ * @param set - Calling this function will set the src and options of the fetch request. This is useful to proxy
25
+ * - **Note**: "signal" is preserved from the original options
26
+ */
27
+ "preloadImage": [src: string, set: (src: string, options?: RequestInit) => void];
28
+ };
29
+ export declare class Game {
30
+ static GameSettingsNamespace: typeof GameSettingsNamespace;
31
+ readonly hooks: Hooks<GameHooks>;
32
+ /**
33
+ * Game settings
34
+ */
35
+ preference: Preference<GamePreference>;
36
+ /**
37
+ * Game key bindings
38
+ */
39
+ keyMap: KeyMap;
40
+ /**
41
+ * Plugin registry
42
+ */
43
+ plugins: Plugins;
44
+ router: LayoutRouter;
45
+ /**
46
+ * Create a new game
47
+ * @param config - Game configuration
48
+ */
49
+ constructor(config: DeepPartial<GameConfig>);
50
+ /**
51
+ * Configure the game
52
+ */
53
+ configure(config: DeepPartial<GameConfig>): this;
54
+ /**
55
+ * Configure the game and freeze the fields
56
+ *
57
+ * This method is not recommended to be used without using NarraLeaf Engine or Plugin Environment.
58
+ * @param config - Game configuration
59
+ */
60
+ configureAndFreeze(config: DeepPartial<GameConfig>): this;
61
+ /**
62
+ * Freeze the fields
63
+ *
64
+ * This method is not recommended to be used without using NarraLeaf Engine or Plugin Environment.
65
+ * @param fields - The fields to freeze
66
+ */
67
+ freeze(fields: (StringKeyOf<GameConfig>)[]): this;
68
+ /**
69
+ * Use a plugin
70
+ * @param plugin - The plugin to use
71
+ */
72
+ use(plugin: IGamePluginRegistry): this;
73
+ getLiveGame(): LiveGame;
74
+ /**
75
+ * Dispose the game and all its resources
76
+ *
77
+ * **Note**: This action is irreversible.
78
+ */
79
+ dispose(): void;
80
+ }
81
+ declare const _default: {
82
+ Game: typeof Game;
83
+ LiveGame: typeof LiveGame;
84
+ };
85
+ export default _default;
86
+ export type { LogicAction };