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
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <picture>
2
2
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-transparent.png">
3
3
  <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
4
- <img alt="Fallback image description" src="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
4
+ <img alt="NarraLeaf Logo" src="https://raw.githubusercontent.com/NarraLeaf/.github/refs/heads/master/doc/banner-md-light.png">
5
5
  </picture>
6
6
 
7
7
  <h1 align="center">NarraLeaf-React</h1>
@@ -31,49 +31,36 @@ NarraLeaf-React uses TypeScript for all scripting, so you don't have to learn a
31
31
  It also has a highly abstracted and easy-to-use API, for example:
32
32
 
33
33
  ```typescript
34
- import {Character, Menu, Scene, Word, c, b} from "narraleaf-react";
34
+ import {Character, Menu, Scene, c, b} from "narraleaf-react";
35
35
  ```
36
36
 
37
37
  ```typescript
38
- const scene1 = new Scene("scene1_hello_world", {
39
- background: "/background/scene1_hello_world.jpg",
38
+ const scene1 = new Scene("Scene1: Hello World", {
39
+ background: "/link/to/background.jpg",
40
40
  });
41
41
 
42
- const johnSmith = new Character("John Smith");
43
- const johnDoe = new Character("John Doe");
42
+ const jS = new Character("John Smith");
43
+ const jD = new Character("John Doe");
44
44
 
45
45
  scene1.action([
46
- /**
47
- * John Smith: Hello, world!
48
- * John Smith: This is my first **NarraLeaf** story.
49
- * John Smith: Start editing src/story.js and enjoy the journey!
50
- */
51
- johnSmith
52
- .say("Hello, world!")
53
- .say`This is my first ${b("NarraLeaf")} story.`
54
- .say`Start editing ${c("src/story.js", "#00f")} and enjoy the journey!`,
55
-
56
- /**
57
- * John Doe: Also, don't forget to check out the documentation!
58
- */
59
- johnDoe.say("Also, don't forget to check out the documentation!"),
60
-
61
- /**
62
- * Menu: Start the journey
63
- * > Yes I will!
64
- * - John Smith: Great! Let's start the journey!
65
- * - John Smith: You can open issues on GitHub if you have any questions.
66
- * > No, I'm going to check the documentation
67
- * - John Smith: Sure! Take your time!
68
- */
46
+ jS`Hello, world!`,
47
+ jS`This is my first ${b("NarraLeaf")} story.`,
48
+ jS`Start editing ${c("src/story.js", "#00f")} and enjoy the journey!`,
49
+
50
+ jD`Also, don't forget to check out the ${c("documentation", "#00f")}!`,
51
+
52
+ "By the way, the documentation is available on https://react.narraleaf.com/documentation",
53
+ "You can also visit the website for demo and more information.",
54
+
69
55
  Menu.prompt("Start the journey")
56
+
70
57
  .choose("Yes I will!", [
71
- johnSmith
72
- .say("Great! Let's start the journey!")
73
- .say("You can open issues on GitHub if you have any questions.")
58
+ jS`Great! Let's start the journey!`,
59
+ jS`You can open issues on GitHub if you have any questions.`
74
60
  ])
61
+
75
62
  .choose("No, I'm going to check the documentation", [
76
- johnSmith.say("Sure! Take your time!")
63
+ jS`Sure! Take your time!`
77
64
  ])
78
65
  ]);
79
66
  ```
@@ -133,6 +120,17 @@ npm install narraleaf-react
133
120
  - [Plugin](https://react.narraleaf.com/documentation/core/plugin)
134
121
  - [Utils](https://react.narraleaf.com/documentation/core/utils)
135
122
  - [Player](https://react.narraleaf.com/documentation/player)
123
+ - [Player](https://react.narraleaf.com/documentation/player/player)
124
+ - [GameProviders](https://react.narraleaf.com/documentation/player/game-providers)
125
+ - Hooks
126
+ - [useGame](https://react.narraleaf.com/documentation/player/hooks/useGame)
127
+ - [usePreferences](https://react.narraleaf.com/documentation/player/hooks/usePreferences)
128
+ - [useRouter](https://react.narraleaf.com/documentation/player/hooks/useRouter)
129
+ - [useDialog](https://react.narraleaf.com/documentation/player/hooks/useDialog)
130
+ - [Page Router](https://react.narraleaf.com/documentation/player/page-router)
131
+ - [Dialog](https://react.narraleaf.com/documentation/player/dialog)
132
+ - [Notification](https://react.narraleaf.com/documentation/player/notification)
133
+ - [Menu](https://react.narraleaf.com/documentation/player/menu)
136
134
  - About
137
135
  - [License](https://react.narraleaf.com/documentation/info/license)
138
136
  - [Incompatible Changes](https://react.narraleaf.com/documentation/info/incompatible-changes)
@@ -1,24 +1,29 @@
1
- import { LogicAction } from "./logicAction";
2
- import { ContentNode } from "../action/tree/actionTree";
3
- import type { CalledActionResult } from "../gameTypes";
4
- import { Awaitable } from "../../../util/data";
5
- import { GameState } from "../../player/gameState";
6
- import { Story } from "../elements/story";
7
- import { ActionSearchOptions } from "../types";
8
- export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement, Type extends string = any> {
9
- static ActionTypes: {
10
- action: string;
11
- };
12
- callee: Callee;
13
- type: Type;
14
- contentNode: ContentNode<ContentNodeType>;
15
- _id: string;
16
- readonly __stack: string;
17
- constructor(callee: Callee, type: Type, contentNode: ContentNode<ContentNodeType>);
18
- executeAction(_state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
19
- getId(): string;
20
- setId(id: string): void;
21
- setContent(content: ContentNodeType): this;
22
- setContentNode(contentNode: ContentNode<ContentNodeType>): this;
23
- getFutureActions(_story: Story, _options: ActionSearchOptions): LogicAction.Actions[];
24
- }
1
+ import { LogicAction } from "./logicAction";
2
+ import { ContentNode } from "../action/tree/actionTree";
3
+ import type { CalledActionResult } from "../gameTypes";
4
+ import { Awaitable } from "../../../util/data";
5
+ import { GameState } from "../../player/gameState";
6
+ import { Story } from "../elements/story";
7
+ import { ActionSearchOptions } from "../types";
8
+ import type { StackModel } from "./stackModel";
9
+ export type ActionExecutionInjection = {
10
+ stackModel: StackModel;
11
+ };
12
+ export type ExecutedActionResult = CalledActionResult | Awaitable<CalledActionResult, any> | (CalledActionResult | Awaitable<CalledActionResult, any>)[] | null;
13
+ export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement, Type extends string = any> {
14
+ static ActionTypes: {
15
+ action: string;
16
+ };
17
+ callee: Callee;
18
+ type: Type;
19
+ contentNode: ContentNode<ContentNodeType>;
20
+ _id: string;
21
+ readonly __stack: string;
22
+ constructor(callee: Callee, type: Type, contentNode: ContentNode<ContentNodeType>);
23
+ executeAction(_state: GameState, _injection: ActionExecutionInjection): ExecutedActionResult;
24
+ getId(): string;
25
+ setId(id: string): void;
26
+ setContent(content: ContentNodeType): this;
27
+ setContentNode(contentNode: ContentNode<ContentNodeType>): this;
28
+ getFutureActions(_story: Story, _options: ActionSearchOptions): LogicAction.Actions[];
29
+ }
@@ -1,37 +1,48 @@
1
- import { Timeline } from "../../../game/player/Tasks";
2
- import { Action } from "./action";
3
- import { LiveGameEventToken } from "../types";
4
- import { LogicAction } from "../game";
5
- export type ActionHistory<T extends Array<unknown> = any> = {
6
- action: Action;
7
- timeline?: Timeline;
8
- args: T;
9
- id: string;
10
- undo?: (...args: T) => void;
11
- };
12
- export declare class ActionHistoryManager {
13
- private history;
14
- private readonly maxHistorySize;
15
- private hooks;
16
- constructor(maxHistorySize?: number);
17
- /**
18
- * Push an action to the history
19
- */
20
- push<T extends Array<any> = Array<any>>(action: Action, onUndo?: (...args: T) => void, args?: T, timeline?: Timeline): {
21
- id: string;
22
- };
23
- /**
24
- * Undo all actions until the given id
25
- *
26
- * If the given id is not found, nothing will happen
27
- * @param id random id generated by push
28
- */
29
- undoUntil(id: string): LogicAction.Actions | null;
30
- undo(): LogicAction.Actions | null;
31
- onUndo(callback: (affected: ActionHistory<any>[]) => void): LiveGameEventToken;
32
- offUndo(callback: (affected: ActionHistory<any>[]) => void): void;
33
- getHistory(): ActionHistory<any>[];
34
- onHistoryLimit(callback: (removed: ActionHistory<any>[]) => void): LiveGameEventToken;
35
- offHistoryLimit(callback: (removed: ActionHistory<any>[]) => void): void;
36
- reset(): void;
37
- }
1
+ import { Timeline } from "../../../game/player/Tasks";
2
+ import { Action } from "./action";
3
+ import { LiveGameEventToken } from "../types";
4
+ import { GameHistoryManager } from "./gameHistory";
5
+ import { StackModel, StackModelRawData } from "./stackModel";
6
+ import type { LiveGame } from "../game/liveGame";
7
+ export type ActionHistory<T extends Array<unknown> = any> = {
8
+ action: Action;
9
+ timeline?: Timeline;
10
+ args: T;
11
+ id: string;
12
+ undo?: (...args: T) => void;
13
+ rootStackSnapshot: StackModelRawData;
14
+ stackModel: StackModel;
15
+ };
16
+ export type ActionHistoryPushOptions = {
17
+ timeline?: Timeline;
18
+ stackModel: StackModel;
19
+ action: Action;
20
+ };
21
+ export declare class ActionHistoryManager {
22
+ readonly liveGame: LiveGame;
23
+ private history;
24
+ private readonly maxHistorySize;
25
+ private hooks;
26
+ constructor(maxHistorySize: number | undefined, liveGame: LiveGame);
27
+ /**
28
+ * Push an action to the history
29
+ */
30
+ push<T extends Array<any> = Array<any>>(props: ActionHistoryPushOptions, onUndo?: (...args: T) => void, args?: T): {
31
+ id: string;
32
+ };
33
+ /**
34
+ * Undo all actions until the given id
35
+ *
36
+ * If the given id is not found, nothing will happen
37
+ * @param id random id generated by push
38
+ */
39
+ undoUntil(id: string): ActionHistory | null;
40
+ undo(gameHistory: GameHistoryManager): ActionHistory | null;
41
+ ableToUndo(gameHistory: GameHistoryManager): boolean;
42
+ onUndo(callback: (affected: ActionHistory<any>[]) => void): LiveGameEventToken;
43
+ offUndo(callback: (affected: ActionHistory<any>[]) => void): void;
44
+ getHistory(): ActionHistory<any>[];
45
+ onHistoryLimit(callback: (removed: ActionHistory<any>[]) => void): LiveGameEventToken;
46
+ offHistoryLimit(callback: (removed: ActionHistory<any>[]) => void): void;
47
+ reset(): void;
48
+ }
@@ -1,140 +1,142 @@
1
- import { LogicAction } from "../action/logicAction";
2
- import type { Story } from "../elements/story";
3
- import type { ConditionData } from "../elements/condition";
4
- import { Color, ImageSrc } from "../types";
5
- import { Transform } from "../elements/transform/transform";
6
- import type { Scene } from "../elements/scene";
7
- import type { MenuData } from "../elements/menu";
8
- import { Awaitable, FlexibleTuple, SelectElementFromEach } from "../../../util/data";
9
- import type { Sound } from "../elements/sound";
10
- import type { Script } from "../elements/script";
11
- import { Sentence } from "../elements/character/sentence";
12
- import type { TransformDefinitions } from "../elements/transform/type";
13
- import { Image, TagGroupDefinition } from "../elements/displayable/image";
14
- import { FadeOptions } from "../elements/type";
15
- import { Transition } from "../elements/transition/transition";
16
- import { ImageTransition } from "../elements/transition/transitions/image/imageTransition";
17
- import { Layer } from "../elements/layer";
18
- export declare const DisplayableActionTypes: {
19
- readonly action: "displayable:action";
20
- readonly applyTransform: "displayable:applyTransform";
21
- readonly applyTransition: "displayable:applyTransition";
22
- readonly init: "displayable:init";
23
- };
24
- export type DisplayableActionContentType<TransitionType extends Transition = Transition> = {
25
- [K in typeof DisplayableActionTypes[keyof typeof DisplayableActionTypes]]: K extends "displayable:applyTransform" ? [Transform] : K extends "displayable:applyTransition" ? [TransitionType, ((transition: TransitionType) => TransitionType)?] : K extends "displayable:init" ? [scene: Scene | null, layer: Layer | null, isElement?: boolean] : any;
26
- };
27
- export declare const CharacterActionTypes: {
28
- readonly say: "character:say";
29
- readonly action: "character:action";
30
- readonly setName: "character:setName";
31
- };
32
- export type CharacterActionContentType = {
33
- [K in typeof CharacterActionTypes[keyof typeof CharacterActionTypes]]: K extends "character:say" ? Sentence : K extends "character:action" ? any : K extends "character:setName" ? [string] : any;
34
- };
35
- export declare const SceneActionTypes: {
36
- readonly action: "scene:action";
37
- readonly init: "scene:init";
38
- readonly exit: "scene:exit";
39
- readonly jumpTo: "scene:jumpTo";
40
- readonly setBackgroundMusic: "scene:setBackgroundMusic";
41
- readonly preUnmount: "scene:preUnmount";
42
- readonly transitionToScene: "scene:transitionToScene";
43
- };
44
- export type SceneActionContentType = {
45
- [K in typeof SceneActionTypes[keyof typeof SceneActionTypes]]: K extends typeof SceneActionTypes["action"] ? Scene : K extends typeof SceneActionTypes["init"] ? [Scene] : K extends typeof SceneActionTypes["exit"] ? [] : K extends typeof SceneActionTypes["jumpTo"] ? [Scene] : K extends typeof SceneActionTypes["setBackgroundMusic"] ? [Sound | null, number?] : K extends typeof SceneActionTypes["preUnmount"] ? [] : K extends typeof SceneActionTypes["transitionToScene"] ? [ImageTransition, Scene | undefined, ImageSrc | Color | undefined] : any;
46
- };
47
- export declare const StoryActionTypes: {
48
- readonly action: "story:action";
49
- };
50
- export type StoryActionContentType = {
51
- [K in typeof StoryActionTypes[keyof typeof StoryActionTypes]]: K extends "story:action" ? Story : any;
52
- };
53
- export declare const ImageActionTypes: {
54
- readonly action: "image:action";
55
- readonly setSrc: "image:setSrc";
56
- readonly flush: "image:flush";
57
- readonly initWearable: "image:initWearable";
58
- readonly setAppearance: "image:setAppearance";
59
- };
60
- export type ImageActionContentType = {
61
- [K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [ImageSrc | Color] : K extends "image:flush" ? [] : K extends "image:initWearable" ? [Image] : K extends "image:setAppearance" ? [FlexibleTuple<SelectElementFromEach<TagGroupDefinition>> | string[], ImageTransition | undefined] : any;
62
- } & DisplayableActionContentType<ImageTransition>;
63
- export declare const ConditionActionTypes: {
64
- readonly action: "condition:action";
65
- };
66
- export type ConditionActionContentType = {
67
- [K in typeof ConditionActionTypes[keyof typeof ConditionActionTypes]]: K extends "condition:action" ? ConditionData : any;
68
- };
69
- export declare const ScriptActionTypes: {
70
- readonly action: "script:action";
71
- };
72
- export type ScriptActionContentType = {
73
- [K in typeof ScriptActionTypes[keyof typeof ScriptActionTypes]]: K extends "script:action" ? Script : any;
74
- };
75
- export declare const MenuActionTypes: {
76
- readonly action: "menu:action";
77
- };
78
- export type MenuActionContentType = {
79
- [K in typeof MenuActionTypes[keyof typeof MenuActionTypes]]: K extends "menu:action" ? MenuData : any;
80
- };
81
- export declare const SoundActionTypes: {
82
- readonly action: "sound:action";
83
- readonly play: "sound:play";
84
- readonly stop: "sound:stop";
85
- readonly setVolume: "sound:setVolume";
86
- readonly setRate: "sound:setRate";
87
- readonly pause: "sound:pause";
88
- readonly resume: "sound:resume";
89
- };
90
- export type SoundActionContentType = {
91
- [K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [FadeOptions] : K extends "sound:stop" ? [FadeOptions] : K extends "sound:setVolume" ? [volumn: number, duration: number] : K extends "sound:setRate" ? [number] : K extends "sound:pause" ? [FadeOptions] : K extends "sound:resume" ? [FadeOptions] : any;
92
- };
93
- export declare const ControlActionTypes: {
94
- readonly action: "control:action";
95
- readonly do: "control:do";
96
- readonly doAsync: "control:doAsync";
97
- readonly any: "control:any";
98
- readonly all: "control:all";
99
- readonly allAsync: "control:allAsync";
100
- readonly repeat: "control:repeat";
101
- readonly sleep: "control:sleep";
102
- };
103
- export type ControlActionContentType = {
104
- [K in typeof ControlActionTypes[keyof typeof ControlActionTypes]]: K extends "control:do" ? [LogicAction.Actions[]] : K extends "control:doAsync" ? [LogicAction.Actions[]] : K extends "control:any" ? [LogicAction.Actions[]] : K extends "control:all" ? [LogicAction.Actions[]] : K extends "control:parallel" ? [LogicAction.Actions[]] : K extends "control:allAsync" ? [LogicAction.Actions[]] : K extends "control:repeat" ? [LogicAction.Actions[], number] : K extends "control:sleep" ? [LogicAction.Actions[], number | Awaitable<any> | Promise<any>] : any;
105
- };
106
- export declare const TextActionTypes: {
107
- readonly action: "text:action";
108
- readonly setText: "text:setText";
109
- readonly setFontSize: "text:setFontSize";
110
- };
111
- export type TextActionContentType = {
112
- [K in typeof TextActionTypes[keyof typeof TextActionTypes]]: K extends "text:setText" ? [string] : K extends "text:show" ? [Transform<TransformDefinitions.TextTransformProps>] : K extends "text:hide" ? [Transform<TransformDefinitions.TextTransformProps>] : K extends "text:applyTransform" ? [Transform<TransformDefinitions.TextTransformProps>] : K extends "text:init" ? [Scene?] : K extends "text:setFontSize" ? [number] : any;
113
- };
114
- export declare const PersistentActionTypes: {
115
- readonly action: "persistent:action";
116
- readonly set: "persistent:set";
117
- readonly assign: "persistent:assign";
118
- };
119
- export type PersistentActionContentType = {
120
- [K in typeof PersistentActionTypes[keyof typeof PersistentActionTypes]]: K extends "persistent:action" ? any : K extends "persistent:set" ? [string, unknown | ((value: unknown) => unknown)] : K extends "persistent:assign" ? [Partial<unknown>] : any;
121
- };
122
- export declare const LayerActionTypes: {
123
- readonly action: "layer:action";
124
- };
125
- export type LayerActionContentType = {
126
- [K in typeof LayerActionTypes[keyof typeof LayerActionTypes]]: K extends "layer:action" ? any : any;
127
- };
128
- export declare const VideoActionTypes: {
129
- readonly action: "video:action";
130
- readonly show: "video:show";
131
- readonly hide: "video:hide";
132
- readonly play: "video:play";
133
- readonly pause: "video:pause";
134
- readonly resume: "video:resume";
135
- readonly stop: "video:stop";
136
- readonly seek: "video:seek";
137
- };
138
- export type VideoActionContentType = {
139
- [K in typeof VideoActionTypes[keyof typeof VideoActionTypes]]: K extends "video:action" ? any : K extends "video:show" | "video:hide" | "video:play" | "video:pause" | "video:stop" ? [] : K extends "video:seek" ? [number] : any;
140
- };
1
+ import { LogicAction } from "../action/logicAction";
2
+ import type { Story } from "../elements/story";
3
+ import type { ConditionData } from "../elements/condition";
4
+ import { Color, ImageSrc } from "../types";
5
+ import { Transform } from "../elements/transform/transform";
6
+ import type { Scene } from "../elements/scene";
7
+ import type { MenuData } from "../elements/menu";
8
+ import { Awaitable, FlexibleTuple, SelectElementFromEach } from "../../../util/data";
9
+ import type { Sound } from "../elements/sound";
10
+ import type { Script } from "../elements/script";
11
+ import { Sentence } from "../elements/character/sentence";
12
+ import type { TransformDefinitions } from "../elements/transform/type";
13
+ import { Image, TagGroupDefinition } from "../elements/displayable/image";
14
+ import { FadeOptions } from "../elements/type";
15
+ import { Transition } from "../elements/transition/transition";
16
+ import { ImageTransition } from "../elements/transition/transitions/image/imageTransition";
17
+ import { Layer } from "../elements/layer";
18
+ export declare const DisplayableActionTypes: {
19
+ readonly action: "displayable:action";
20
+ readonly applyTransform: "displayable:applyTransform";
21
+ readonly applyTransition: "displayable:applyTransition";
22
+ readonly init: "displayable:init";
23
+ };
24
+ export type DisplayableActionContentType<TransitionType extends Transition = Transition> = {
25
+ [K in typeof DisplayableActionTypes[keyof typeof DisplayableActionTypes]]: K extends "displayable:applyTransform" ? [Transform] : K extends "displayable:applyTransition" ? [TransitionType, ((transition: TransitionType) => TransitionType)?] : K extends "displayable:init" ? [scene: Scene | null, layer: Layer | null, isElement?: boolean] : any;
26
+ };
27
+ export declare const CharacterActionTypes: {
28
+ readonly say: "character:say";
29
+ readonly action: "character:action";
30
+ readonly setName: "character:setName";
31
+ };
32
+ export type CharacterActionContentType = {
33
+ [K in typeof CharacterActionTypes[keyof typeof CharacterActionTypes]]: K extends "character:say" ? Sentence : K extends "character:action" ? any : K extends "character:setName" ? [string] : any;
34
+ };
35
+ export declare const SceneActionTypes: {
36
+ readonly action: "scene:action";
37
+ readonly init: "scene:init";
38
+ readonly exit: "scene:exit";
39
+ readonly jumpTo: "scene:jumpTo";
40
+ readonly setBackgroundMusic: "scene:setBackgroundMusic";
41
+ readonly preUnmount: "scene:preUnmount";
42
+ readonly transitionToScene: "scene:transitionToScene";
43
+ };
44
+ export type SceneActionContentType = {
45
+ [K in typeof SceneActionTypes[keyof typeof SceneActionTypes]]: K extends typeof SceneActionTypes["action"] ? Scene : K extends typeof SceneActionTypes["init"] ? [Scene] : K extends typeof SceneActionTypes["exit"] ? [] : K extends typeof SceneActionTypes["jumpTo"] ? [Scene] : K extends typeof SceneActionTypes["setBackgroundMusic"] ? [Sound | null, number?] : K extends typeof SceneActionTypes["preUnmount"] ? [] : K extends typeof SceneActionTypes["transitionToScene"] ? [ImageTransition, Scene | undefined, ImageSrc | Color | undefined] : any;
46
+ };
47
+ export declare const StoryActionTypes: {
48
+ readonly action: "story:action";
49
+ };
50
+ export type StoryActionContentType = {
51
+ [K in typeof StoryActionTypes[keyof typeof StoryActionTypes]]: K extends "story:action" ? Story : any;
52
+ };
53
+ export declare const ImageActionTypes: {
54
+ readonly action: "image:action";
55
+ readonly setSrc: "image:setSrc";
56
+ readonly flush: "image:flush";
57
+ readonly initWearable: "image:initWearable";
58
+ readonly setAppearance: "image:setAppearance";
59
+ readonly setDarkness: "image:setDarkness";
60
+ };
61
+ export type ImageActionContentType = {
62
+ [K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [ImageSrc | Color] : K extends "image:flush" ? [] : K extends "image:initWearable" ? [Image] : K extends "image:setAppearance" ? [FlexibleTuple<SelectElementFromEach<TagGroupDefinition>> | string[], ImageTransition | undefined] : K extends "image:setDarkness" ? [darkness: number, duration?: number, easing?: TransformDefinitions.EasingDefinition] : any;
63
+ } & DisplayableActionContentType<ImageTransition>;
64
+ export declare const ConditionActionTypes: {
65
+ readonly action: "condition:action";
66
+ };
67
+ export type ConditionActionContentType = {
68
+ [K in typeof ConditionActionTypes[keyof typeof ConditionActionTypes]]: K extends "condition:action" ? ConditionData : any;
69
+ };
70
+ export declare const ScriptActionTypes: {
71
+ readonly action: "script:action";
72
+ };
73
+ export type ScriptActionContentType = {
74
+ [K in typeof ScriptActionTypes[keyof typeof ScriptActionTypes]]: K extends "script:action" ? Script : any;
75
+ };
76
+ export declare const MenuActionTypes: {
77
+ readonly action: "menu:action";
78
+ };
79
+ export type MenuActionContentType = {
80
+ [K in typeof MenuActionTypes[keyof typeof MenuActionTypes]]: K extends "menu:action" ? MenuData : any;
81
+ };
82
+ export declare const SoundActionTypes: {
83
+ readonly action: "sound:action";
84
+ readonly play: "sound:play";
85
+ readonly stop: "sound:stop";
86
+ readonly setVolume: "sound:setVolume";
87
+ readonly setRate: "sound:setRate";
88
+ readonly pause: "sound:pause";
89
+ readonly resume: "sound:resume";
90
+ };
91
+ export type SoundActionContentType = {
92
+ [K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [FadeOptions] : K extends "sound:stop" ? [FadeOptions] : K extends "sound:setVolume" ? [volumn: number, duration: number] : K extends "sound:setRate" ? [number] : K extends "sound:pause" ? [FadeOptions] : K extends "sound:resume" ? [FadeOptions] : any;
93
+ };
94
+ export declare const ControlActionTypes: {
95
+ readonly action: "control:action";
96
+ readonly do: "control:do";
97
+ readonly doAsync: "control:doAsync";
98
+ readonly any: "control:any";
99
+ readonly all: "control:all";
100
+ readonly allAsync: "control:allAsync";
101
+ readonly repeat: "control:repeat";
102
+ readonly sleep: "control:sleep";
103
+ };
104
+ export type ControlActionContentType = {
105
+ [K in typeof ControlActionTypes[keyof typeof ControlActionTypes]]: K extends "control:do" ? [LogicAction.Actions[]] : K extends "control:doAsync" ? [LogicAction.Actions[]] : K extends "control:any" ? [LogicAction.Actions[]] : K extends "control:all" ? [LogicAction.Actions[]] : K extends "control:parallel" ? [LogicAction.Actions[]] : K extends "control:allAsync" ? [LogicAction.Actions[]] : K extends "control:repeat" ? [LogicAction.Actions[], number] : K extends "control:sleep" ? [LogicAction.Actions[], number | Awaitable<any> | Promise<any>] : any;
106
+ };
107
+ export declare const TextActionTypes: {
108
+ readonly action: "text:action";
109
+ readonly setText: "text:setText";
110
+ readonly setFontSize: "text:setFontSize";
111
+ };
112
+ export type TextActionContentType = {
113
+ [K in typeof TextActionTypes[keyof typeof TextActionTypes]]: K extends "text:setText" ? [string] : K extends "text:show" ? [Transform<TransformDefinitions.TextTransformProps>] : K extends "text:hide" ? [Transform<TransformDefinitions.TextTransformProps>] : K extends "text:applyTransform" ? [Transform<TransformDefinitions.TextTransformProps>] : K extends "text:init" ? [Scene?] : K extends "text:setFontSize" ? [number] : any;
114
+ };
115
+ export declare const PersistentActionTypes: {
116
+ readonly action: "persistent:action";
117
+ readonly set: "persistent:set";
118
+ readonly assign: "persistent:assign";
119
+ };
120
+ export type PersistentActionContentType = {
121
+ [K in typeof PersistentActionTypes[keyof typeof PersistentActionTypes]]: K extends "persistent:action" ? any : K extends "persistent:set" ? [string, unknown | ((value: unknown) => unknown)] : K extends "persistent:assign" ? [Partial<unknown>] : any;
122
+ };
123
+ export declare const LayerActionTypes: {
124
+ readonly action: "layer:action";
125
+ readonly setZIndex: "layer:setZIndex";
126
+ };
127
+ export type LayerActionContentType = {
128
+ [K in typeof LayerActionTypes[keyof typeof LayerActionTypes]]: K extends "layer:action" ? any : K extends "layer:setZIndex" ? [number] : any;
129
+ };
130
+ export declare const VideoActionTypes: {
131
+ readonly action: "video:action";
132
+ readonly show: "video:show";
133
+ readonly hide: "video:hide";
134
+ readonly play: "video:play";
135
+ readonly pause: "video:pause";
136
+ readonly resume: "video:resume";
137
+ readonly stop: "video:stop";
138
+ readonly seek: "video:seek";
139
+ };
140
+ export type VideoActionContentType = {
141
+ [K in typeof VideoActionTypes[keyof typeof VideoActionTypes]]: K extends "video:action" ? any : K extends "video:show" | "video:hide" | "video:play" | "video:pause" | "video:stop" ? [] : K extends "video:seek" ? [number] : any;
142
+ };
@@ -1,5 +1,5 @@
1
- import { LogicAction } from "../action/logicAction";
2
- import { Chainable } from "../action/chain";
3
- export declare class Actionable<StateData extends Record<string, any> | null = Record<string, any>, Self extends Actionable = any> extends Chainable<LogicAction.Actions, Self> {
4
- constructor();
5
- }
1
+ import { LogicAction } from "../action/logicAction";
2
+ import { Chainable } from "../action/chain";
3
+ export declare class Actionable<StateData extends Record<string, any> | null = Record<string, any>, Self extends Actionable = any> extends Chainable<LogicAction.Actions, Self> {
4
+ constructor();
5
+ }
@@ -1,17 +1,19 @@
1
- import { CharacterActionContentType, CharacterActionTypes } from "../../action/actionTypes";
2
- import type { Character } from "../../elements/character";
3
- import { GameState } from "../../../player/gameState";
4
- import type { CalledActionResult } from "../../gameTypes";
5
- import { Awaitable } from "../../../../util/data";
6
- import { Sentence } from "../../elements/character/sentence";
7
- import { TypedAction } from "../../action/actions";
8
- import { Sound } from "../../elements/sound";
9
- export declare class CharacterAction<T extends typeof CharacterActionTypes[keyof typeof CharacterActionTypes] = typeof CharacterActionTypes[keyof typeof CharacterActionTypes]> extends TypedAction<CharacterActionContentType, T, Character> {
10
- static ActionTypes: {
11
- readonly say: "character:say";
12
- readonly action: "character:action";
13
- readonly setName: "character:setName";
14
- };
15
- static getVoice(state: GameState, sentence: Sentence): Sound | null;
16
- executeAction(gameState: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
17
- }
1
+ import { CharacterActionContentType, CharacterActionTypes } from "../../action/actionTypes";
2
+ import type { Character } from "../../elements/character";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { Sentence } from "../../elements/character/sentence";
5
+ import { TypedAction } from "../../action/actions";
6
+ import { Sound } from "../../elements/sound";
7
+ import { ActionExecutionInjection, ExecutedActionResult } from "../../action/action";
8
+ import { LogicAction } from "../../action/logicAction";
9
+ import { Story } from "../../elements/story";
10
+ export declare class CharacterAction<T extends typeof CharacterActionTypes[keyof typeof CharacterActionTypes] = typeof CharacterActionTypes[keyof typeof CharacterActionTypes]> extends TypedAction<CharacterActionContentType, T, Character> {
11
+ static ActionTypes: {
12
+ readonly say: "character:say";
13
+ readonly action: "character:action";
14
+ readonly setName: "character:setName";
15
+ };
16
+ static getVoice(state: GameState, sentence: Sentence): Sound | null;
17
+ executeAction(gameState: GameState, injection: ActionExecutionInjection): ExecutedActionResult;
18
+ stringify(_story: Story, _seen: Set<LogicAction.Actions>, _strict: boolean): string;
19
+ }
@@ -1,17 +1,26 @@
1
- import { ConditionActionContentType, ConditionActionTypes } from "../../action/actionTypes";
2
- import type { Condition } from "../../elements/condition";
3
- import { GameState } from "../../../player/gameState";
4
- import { LogicAction } from "../../action/logicAction";
5
- import { TypedAction } from "../../action/actions";
6
- import { Story } from "../../elements/story";
7
- import { ActionSearchOptions } from "../../types";
8
- export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
9
- static ActionTypes: {
10
- readonly action: "condition:action";
11
- };
12
- executeAction(gameState: GameState): {
13
- type: any;
14
- node: import("../tree/actionTree").RenderableNode | null;
15
- };
16
- getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
17
- }
1
+ import { ConditionActionContentType, ConditionActionTypes } from "../../action/actionTypes";
2
+ import type { Condition } from "../../elements/condition";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { LogicAction } from "../../action/logicAction";
5
+ import { TypedAction } from "../../action/actions";
6
+ import { Story } from "../../elements/story";
7
+ import { ActionSearchOptions } from "../../types";
8
+ export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
9
+ static ActionTypes: {
10
+ readonly action: "condition:action";
11
+ };
12
+ executeAction(gameState: GameState): ({
13
+ type: T;
14
+ node: import("../../action/tree/actionTree").RenderableNode | null;
15
+ wait?: undefined;
16
+ } | {
17
+ type: T;
18
+ node: null;
19
+ wait: {
20
+ type: "all";
21
+ stackModels: import("../stackModel").StackModel[];
22
+ };
23
+ })[];
24
+ getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
25
+ stringify(story: Story, seen: Set<LogicAction.Actions>, strict: boolean): string;
26
+ }