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
@@ -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,39 +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
- import { GameHistoryManager } from "./gameHistory";
6
- export type ActionHistory<T extends Array<unknown> = any> = {
7
- action: Action;
8
- timeline?: Timeline;
9
- args: T;
10
- id: string;
11
- undo?: (...args: T) => void;
12
- };
13
- export declare class ActionHistoryManager {
14
- private history;
15
- private readonly maxHistorySize;
16
- private hooks;
17
- constructor(maxHistorySize?: number);
18
- /**
19
- * Push an action to the history
20
- */
21
- push<T extends Array<any> = Array<any>>(action: Action, onUndo?: (...args: T) => void, args?: T, timeline?: Timeline): {
22
- id: string;
23
- };
24
- /**
25
- * Undo all actions until the given id
26
- *
27
- * If the given id is not found, nothing will happen
28
- * @param id random id generated by push
29
- */
30
- undoUntil(id: string): LogicAction.Actions | null;
31
- undo(gameHistory: GameHistoryManager): LogicAction.Actions | null;
32
- ableToUndo(gameHistory: GameHistoryManager): boolean;
33
- onUndo(callback: (affected: ActionHistory<any>[]) => void): LiveGameEventToken;
34
- offUndo(callback: (affected: ActionHistory<any>[]) => void): void;
35
- getHistory(): ActionHistory<any>[];
36
- onHistoryLimit(callback: (removed: ActionHistory<any>[]) => void): LiveGameEventToken;
37
- offHistoryLimit(callback: (removed: ActionHistory<any>[]) => void): void;
38
- reset(): void;
39
- }
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,142 +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
- 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
+ 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
+ }
@@ -1,38 +1,26 @@
1
- import { ControlActionContentType, ControlActionTypes } from "../../action/actionTypes";
2
- import { Control } from "../../elements/control";
3
- import { GameState } from "../../../player/gameState";
4
- import { LogicAction } from "../../action/logicAction";
5
- import { Awaitable } from "../../../../util/data";
6
- import type { CalledActionResult } from "../../gameTypes";
7
- import { TypedAction } from "../../action/actions";
8
- import { Story } from "../../elements/story";
9
- import { ActionSearchOptions } from "../../types";
10
- import { Timeline } from "../../../player/Tasks";
11
- export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
12
- static ActionTypes: {
13
- readonly action: "control:action";
14
- readonly do: "control:do";
15
- readonly doAsync: "control:doAsync";
16
- readonly any: "control:any";
17
- readonly all: "control:all";
18
- readonly allAsync: "control:allAsync";
19
- readonly repeat: "control:repeat";
20
- readonly sleep: "control:sleep";
21
- };
22
- /**
23
- * Perform an action and all its children. Due to bidirectional bubbling, the Awaitable interrupt returned by the function affects the children who're executing.
24
- *
25
- * At the same time, the child interrupt will bubble up to the Awaitable returned by this function and interrupt the execution of the Timeline.
26
- * This is because all later results of this function depend on the previous result, so it isn't possible to silently ignore interrupted sub operations.
27
- *
28
- * @template T The type of the result returned by the onResolved callback.
29
- * @param {GameState} gameState - The current game state.
30
- * @param {LogicAction.Actions} action - The action to be executed.
31
- * @param {function(CalledActionResult): T} onResolved - A callback function that processes the result of the action. The awaitable will be resolved to the value returned by this callback.
32
- * @returns {[Awaitable<T>, Timeline]} A tuple containing the Awaitable and the Timeline.
33
- */
34
- executeActionSeries<T>(gameState: GameState, action: LogicAction.Actions, onResolved: (result: CalledActionResult) => T): [awaitable: Awaitable<T>, timeline: Timeline];
35
- executeSingleAction(gameState: GameState, action: LogicAction.Actions): Awaitable<CalledActionResult> | LogicAction.Actions | null;
36
- executeAction(gameState: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult>;
37
- getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
38
- }
1
+ import { TypedAction } from "../../action/actions";
2
+ import { ControlActionContentType, ControlActionTypes } from "../../action/actionTypes";
3
+ import { LogicAction } from "../../action/logicAction";
4
+ import { Control } from "../../elements/control";
5
+ import { Story } from "../../elements/story";
6
+ import { ActionSearchOptions } from "../../types";
7
+ import { Awaitable } from "../../../../util/data";
8
+ import { GameState } from "../../../player/gameState";
9
+ import { ActionExecutionInjection, ExecutedActionResult } from "../../action/action";
10
+ export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
11
+ static ActionTypes: {
12
+ readonly action: "control:action";
13
+ readonly do: "control:do";
14
+ readonly doAsync: "control:doAsync";
15
+ readonly any: "control:any";
16
+ readonly all: "control:all";
17
+ readonly allAsync: "control:allAsync";
18
+ readonly repeat: "control:repeat";
19
+ readonly sleep: "control:sleep";
20
+ };
21
+ static executeActionsAsync(gameState: GameState, action: LogicAction.Actions): Awaitable<void>;
22
+ checkActionChain(actions: LogicAction.Actions[]): LogicAction.Actions[];
23
+ executeAction(gameState: GameState, injection: ActionExecutionInjection): ExecutedActionResult;
24
+ getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
25
+ stringify(story: Story, _seen: Set<LogicAction.Actions>, _strict: boolean): string;
26
+ }