narraleaf-react 0.0.5 → 0.1.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 (62) hide show
  1. package/dist/game/nlcore/action/action.d.ts +3 -3
  2. package/dist/game/nlcore/action/actionTypes.d.ts +22 -6
  3. package/dist/game/nlcore/action/actions/characterAction.d.ts +14 -0
  4. package/dist/game/nlcore/action/actions/conditionAction.d.ts +15 -0
  5. package/dist/game/nlcore/action/actions/controlAction.d.ts +32 -0
  6. package/dist/game/nlcore/action/actions/imageAction.d.ts +22 -0
  7. package/dist/game/nlcore/action/actions/menuAction.d.ts +13 -0
  8. package/dist/game/nlcore/action/actions/sceneAction.d.ts +29 -0
  9. package/dist/game/nlcore/action/actions/scriptAction.d.ts +10 -0
  10. package/dist/game/nlcore/action/actions/soundAction.d.ts +20 -0
  11. package/dist/game/nlcore/action/actions/storyAction.d.ts +8 -0
  12. package/dist/game/nlcore/action/actions/textAction.d.ts +19 -0
  13. package/dist/game/nlcore/action/actions.d.ts +2 -127
  14. package/dist/game/nlcore/action/logicAction.d.ts +19 -7
  15. package/dist/game/nlcore/common/Utils.d.ts +21 -2
  16. package/dist/game/nlcore/common/elements.d.ts +6 -2
  17. package/dist/game/nlcore/common/transition.d.ts +7 -7
  18. package/dist/game/nlcore/elements/character/pause.d.ts +9 -0
  19. package/dist/game/nlcore/elements/character/sentence.d.ts +29 -0
  20. package/dist/game/nlcore/elements/character/word.d.ts +11 -0
  21. package/dist/game/nlcore/elements/character.d.ts +40 -0
  22. package/dist/game/nlcore/elements/condition.d.ts +0 -2
  23. package/dist/game/nlcore/elements/control.d.ts +11 -0
  24. package/dist/game/nlcore/elements/image.d.ts +11 -23
  25. package/dist/game/nlcore/elements/menu.d.ts +4 -8
  26. package/dist/game/nlcore/elements/scene.d.ts +24 -19
  27. package/dist/game/nlcore/elements/sound.d.ts +1 -1
  28. package/dist/game/nlcore/elements/story.d.ts +1 -1
  29. package/dist/game/nlcore/elements/text.d.ts +67 -55
  30. package/dist/game/nlcore/elements/transform/position.d.ts +3 -3
  31. package/dist/game/nlcore/elements/transform/transform.d.ts +8 -53
  32. package/dist/game/nlcore/elements/transform/type.d.ts +7 -8
  33. package/dist/game/nlcore/elements/transition/{base.d.ts → baseTransitions.d.ts} +10 -3
  34. package/dist/game/nlcore/elements/transition/imageTransitions/dissolve.d.ts +25 -0
  35. package/dist/game/nlcore/elements/transition/imageTransitions/fade.d.ts +19 -0
  36. package/dist/game/nlcore/elements/transition/imageTransitions/fadeIn.d.ts +27 -0
  37. package/dist/game/nlcore/elements/transition/textTransitions/fontSizeTransition.d.ts +15 -0
  38. package/dist/game/nlcore/elements/transition/type.d.ts +11 -6
  39. package/dist/game/nlcore/game.d.ts +3 -4
  40. package/dist/game/nlcore/gameTypes.d.ts +34 -9
  41. package/dist/game/nlcore/types.d.ts +22 -1
  42. package/dist/game/player/elements/displayable/Displayable.d.ts +23 -0
  43. package/dist/game/player/elements/displayable/Displayables.d.ts +7 -0
  44. package/dist/game/player/elements/displayable/Text.d.ts +7 -0
  45. package/dist/game/player/elements/displayable/type.d.ts +15 -0
  46. package/dist/game/player/elements/image/Image.d.ts +1 -2
  47. package/dist/game/player/elements/menu/type.d.ts +1 -1
  48. package/dist/game/player/elements/say/Sentence.d.ts +12 -0
  49. package/dist/game/player/elements/say/TypingEffect.d.ts +4 -0
  50. package/dist/game/player/elements/say/type.d.ts +2 -1
  51. package/dist/game/player/gameState.d.ts +26 -3
  52. package/dist/game/player/gameState.type.d.ts +2 -1
  53. package/dist/game/player/lib/Preloaded.d.ts +1 -1
  54. package/dist/game/player/libElements.d.ts +1 -2
  55. package/dist/main.js +2 -2
  56. package/dist/util/data.d.ts +23 -2
  57. package/package.json +3 -4
  58. package/dist/game/nlcore/elements/transition/dissolve.d.ts +0 -34
  59. package/dist/game/nlcore/elements/transition/fade.d.ts +0 -28
  60. package/dist/game/nlcore/elements/transition/fadeIn.d.ts +0 -35
  61. package/dist/game/player/elements/menu/Sentence.d.ts +0 -6
  62. /package/dist/game/nlcore/{elements → action}/srcManager.d.ts +0 -0
@@ -3,16 +3,16 @@ import { ContentNode } from "../action/tree/actionTree";
3
3
  import type { CalledActionResult } from "../gameTypes";
4
4
  import { Awaitable } from "../../../util/data";
5
5
  import { GameState } from "../../player/gameState";
6
- export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement> {
6
+ export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement, Type extends string = any> {
7
7
  static ActionTypes: {
8
8
  action: string;
9
9
  };
10
10
  callee: Callee;
11
- type: ContentNodeType;
11
+ type: Type;
12
12
  contentNode: ContentNode<ContentNodeType>;
13
13
  _id: string;
14
14
  readonly __stack: string;
15
- constructor(callee: Callee, type: ContentNodeType, contentNode: ContentNode<ContentNodeType>);
15
+ constructor(callee: Callee, type: Type, contentNode: ContentNode<ContentNodeType>);
16
16
  executeAction(_state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
17
17
  getId(): string;
18
18
  setId(id: string): void;
@@ -1,21 +1,23 @@
1
1
  import { LogicAction } from "../action/logicAction";
2
2
  import type { Story } from "../elements/story";
3
3
  import type { ConditionData } from "../elements/condition";
4
- import { Background, CommonImage } from "../types";
4
+ import { CommonDisplayable, ImageColor, ImageSrc } from "../types";
5
5
  import { Transform } from "../elements/transform/transform";
6
6
  import type { Scene } from "../elements/scene";
7
- import type { Sentence } from "../elements/text";
8
7
  import type { MenuData } from "../elements/menu";
9
8
  import { Awaitable } from "../../../util/data";
10
9
  import { ITransition } from "../elements/transition/type";
11
10
  import type { Sound } from "../elements/sound";
12
11
  import type { Script } from "../elements/script";
12
+ import { Sentence } from "../elements/character/sentence";
13
+ import type { TransformDefinitions } from "../elements/transform/type";
13
14
  export declare const CharacterActionTypes: {
14
15
  readonly say: "character:say";
15
16
  readonly action: "character:action";
17
+ readonly setName: "character:setName";
16
18
  };
17
19
  export type CharacterActionContentType = {
18
- [K in typeof CharacterActionTypes[keyof typeof CharacterActionTypes]]: K extends "character:say" ? Sentence : K extends "character:action" ? any : any;
20
+ [K in typeof CharacterActionTypes[keyof typeof CharacterActionTypes]]: K extends "character:say" ? Sentence : K extends "character:action" ? any : K extends "character:setName" ? [string] : any;
19
21
  };
20
22
  export declare const SceneActionTypes: {
21
23
  readonly action: "scene:action";
@@ -31,7 +33,7 @@ export declare const SceneActionTypes: {
31
33
  readonly applyTransform: "scene:applyTransform";
32
34
  };
33
35
  export type SceneActionContentType = {
34
- [K in typeof SceneActionTypes[keyof typeof SceneActionTypes]]: K extends typeof SceneActionTypes["action"] ? Scene : K extends typeof SceneActionTypes["sleep"] ? number | Promise<any> | Awaitable<any, any> : K extends typeof SceneActionTypes["setBackground"] ? [Background["background"]] : K extends typeof SceneActionTypes["setTransition"] ? [ITransition | null] : K extends typeof SceneActionTypes["applyTransition"] ? [ITransition] : K extends typeof SceneActionTypes["init"] ? [] : 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["applyTransform"] ? [Transform] : any;
36
+ [K in typeof SceneActionTypes[keyof typeof SceneActionTypes]]: K extends typeof SceneActionTypes["action"] ? Scene : K extends typeof SceneActionTypes["sleep"] ? number | Promise<any> | Awaitable<any, any> : K extends typeof SceneActionTypes["setBackground"] ? [ImageSrc | ImageColor] : K extends typeof SceneActionTypes["setTransition"] ? [ITransition | null] : K extends typeof SceneActionTypes["applyTransition"] ? [ITransition] : K extends typeof SceneActionTypes["init"] ? [] : 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["applyTransform"] ? [Transform] : any;
35
37
  };
36
38
  export declare const StoryActionTypes: {
37
39
  readonly action: "story:action";
@@ -56,7 +58,7 @@ export declare const ImageActionTypes: {
56
58
  readonly flush: "image:flush";
57
59
  };
58
60
  export type ImageActionContentType = {
59
- [K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [string] : K extends "image:setPosition" ? [CommonImage["position"], Transform] : K extends "image:show" ? [void, Transform] : K extends "image:hide" ? [void, Transform] : K extends "image:applyTransform" ? [void, Transform, string] : K extends "image:init" ? [Scene?] : K extends "image:dispose" ? [] : K extends "image:setTransition" ? [ITransition | null] : K extends "image:applyTransition" ? [ITransition] : K extends "image:flush" ? [] : any;
61
+ [K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [string] : K extends "image:setPosition" ? [CommonDisplayable["position"], Transform<TransformDefinitions.ImageTransformProps>] : K extends "image:show" ? [void, Transform<TransformDefinitions.ImageTransformProps>] : K extends "image:hide" ? [void, Transform<TransformDefinitions.ImageTransformProps>] : K extends "image:applyTransform" ? [void, Transform<TransformDefinitions.ImageTransformProps>, string] : K extends "image:init" ? [Scene?] : K extends "image:dispose" ? [] : K extends "image:setTransition" ? [ITransition | null] : K extends "image:applyTransition" ? [ITransition] : K extends "image:flush" ? [] : any;
60
62
  };
61
63
  export declare const ConditionActionTypes: {
62
64
  readonly action: "condition:action";
@@ -103,7 +105,21 @@ export declare const ControlActionTypes: {
103
105
  readonly all: "control:all";
104
106
  readonly allAsync: "control:allAsync";
105
107
  readonly repeat: "control:repeat";
108
+ readonly sleep: "control:sleep";
106
109
  };
107
110
  export type ControlActionContentType = {
108
- [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] : any;
111
+ [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;
112
+ };
113
+ export declare const TextActionTypes: {
114
+ readonly action: "text:action";
115
+ readonly setText: "text:setText";
116
+ readonly show: "text:show";
117
+ readonly hide: "text:hide";
118
+ readonly applyTransform: "text:applyTransform";
119
+ readonly init: "text:init";
120
+ readonly applyTransition: "text:applyTransition";
121
+ readonly setFontSize: "text:setFontSize";
122
+ };
123
+ export type TextActionContentType = {
124
+ [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:applyTransition" ? [ITransition] : K extends "text:setFontSize" ? [number] : any;
109
125
  };
@@ -0,0 +1,14 @@
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 { TypedAction } from "../../action/actions";
7
+ export declare class CharacterAction<T extends typeof CharacterActionTypes[keyof typeof CharacterActionTypes] = typeof CharacterActionTypes[keyof typeof CharacterActionTypes]> extends TypedAction<CharacterActionContentType, T, Character> {
8
+ static ActionTypes: {
9
+ readonly say: "character:say";
10
+ readonly action: "character:action";
11
+ readonly setName: "character:setName";
12
+ };
13
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
14
+ }
@@ -0,0 +1,15 @@
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
+ export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
7
+ static ActionTypes: {
8
+ readonly action: "condition:action";
9
+ };
10
+ executeAction(gameState: GameState): {
11
+ type: any;
12
+ node: import("../tree/actionTree").RenderableNode | null;
13
+ };
14
+ getFutureActions(): LogicAction.Actions[];
15
+ }
@@ -0,0 +1,32 @@
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 { ContentNode } from "../../action/tree/actionTree";
8
+ import { TypedAction } from "../../action/actions";
9
+ export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
10
+ static ActionTypes: {
11
+ readonly action: "control:action";
12
+ readonly do: "control:do";
13
+ readonly doAsync: "control:doAsync";
14
+ readonly any: "control:any";
15
+ readonly all: "control:all";
16
+ readonly allAsync: "control:allAsync";
17
+ readonly repeat: "control:repeat";
18
+ readonly sleep: "control:sleep";
19
+ };
20
+ /**
21
+ * Execute all actions in the content node
22
+ * will wait for awaitable actions to resolve
23
+ */
24
+ executeAllActions(state: GameState, action: LogicAction.Actions): Promise<void>;
25
+ executeSingleAction(state: GameState, action: LogicAction.Actions): Promise<TypedAction<Record<string, any>, string, LogicAction.GameElement> | import("./menuAction").MenuAction<"menu:action"> | ControlAction<"control:action" | "control:do" | "control:doAsync" | "control:any" | "control:all" | "control:allAsync" | "control:repeat" | "control:sleep"> | ContentNode<any> | null>;
26
+ execute(state: GameState, awaitable: Awaitable<any, any>, content: LogicAction.Actions[]): {
27
+ type: any;
28
+ node: ContentNode<any> | null;
29
+ } | Awaitable<CalledActionResult<any>, any> | Awaitable<any, any>;
30
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult>;
31
+ getFutureActions(): LogicAction.Actions[];
32
+ }
@@ -0,0 +1,22 @@
1
+ import { ImageActionContentType, ImageActionTypes } from "../../action/actionTypes";
2
+ import { Image } from "../../elements/image";
3
+ import { GameState } from "../../../player/gameState";
4
+ import type { CalledActionResult } from "../../gameTypes";
5
+ import { Awaitable } from "../../../../util/data";
6
+ import { TypedAction } from "../../action/actions";
7
+ export declare class ImageAction<T extends typeof ImageActionTypes[keyof typeof ImageActionTypes] = typeof ImageActionTypes[keyof typeof ImageActionTypes]> extends TypedAction<ImageActionContentType, T, Image> {
8
+ static ActionTypes: {
9
+ readonly action: "image:action";
10
+ readonly setSrc: "image:setSrc";
11
+ readonly setPosition: "image:setPosition";
12
+ readonly show: "image:show";
13
+ readonly hide: "image:hide";
14
+ readonly applyTransform: "image:applyTransform";
15
+ readonly init: "image:init";
16
+ readonly dispose: "image:dispose";
17
+ readonly setTransition: "image:setTransition";
18
+ readonly applyTransition: "image:applyTransition";
19
+ readonly flush: "image:flush";
20
+ };
21
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
22
+ }
@@ -0,0 +1,13 @@
1
+ import { MenuActionContentType, MenuActionTypes } from "../../action/actionTypes";
2
+ import type { Menu } from "../../elements/menu";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { Awaitable } from "../../../../util/data";
5
+ import type { CalledActionResult } from "../../gameTypes";
6
+ import { TypedAction } from "../../action/actions";
7
+ export declare class MenuAction<T extends typeof MenuActionTypes[keyof typeof MenuActionTypes] = typeof MenuActionTypes[keyof typeof MenuActionTypes]> extends TypedAction<MenuActionContentType, T, Menu> {
8
+ static ActionTypes: {
9
+ readonly action: "menu:action";
10
+ };
11
+ executeAction(state: GameState): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
12
+ getFutureActions(): import("../logicAction").LogicAction.Actions[];
13
+ }
@@ -0,0 +1,29 @@
1
+ import { SceneActionContentType, SceneActionTypes } from "../../action/actionTypes";
2
+ import type { Scene } from "../../elements/scene";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { Awaitable } from "../../../../util/data";
5
+ import type { CalledActionResult } from "../../gameTypes";
6
+ import { LogicAction } from "../../action/logicAction";
7
+ import { TypedAction } from "../../action/actions";
8
+ export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof SceneActionTypes] = typeof SceneActionTypes[keyof typeof SceneActionTypes]> extends TypedAction<SceneActionContentType, T, Scene> {
9
+ static ActionTypes: {
10
+ readonly action: "scene:action";
11
+ readonly setBackground: "scene:setBackground";
12
+ readonly sleep: "scene:sleep";
13
+ readonly setTransition: "scene:setTransition";
14
+ readonly applyTransition: "scene:applyTransition";
15
+ readonly init: "scene:init";
16
+ readonly exit: "scene:exit";
17
+ readonly jumpTo: "scene:jumpTo";
18
+ readonly setBackgroundMusic: "scene:setBackgroundMusic";
19
+ readonly preUnmount: "scene:preUnmount";
20
+ readonly applyTransform: "scene:applyTransform";
21
+ };
22
+ static handleSceneInit(sceneAction: SceneAction, state: GameState, awaitable: Awaitable<CalledActionResult, any>): Awaitable<CalledActionResult<any>, any> | {
23
+ type: "scene:action" | "scene:setBackground" | "scene:sleep" | "scene:setTransition" | "scene:applyTransition" | "scene:init" | "scene:exit" | "scene:jumpTo" | "scene:setBackgroundMusic" | "scene:preUnmount" | "scene:applyTransform";
24
+ node: import("../../action/tree/actionTree").RenderableNode | null;
25
+ };
26
+ static registerEventListeners(scene: Scene, state: GameState, onInit?: () => void): void;
27
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
28
+ getFutureActions(): LogicAction.Actions[];
29
+ }
@@ -0,0 +1,10 @@
1
+ import { ScriptActionContentType, ScriptActionTypes } from "../../action/actionTypes";
2
+ import type { Script } from "../../elements/script";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { TypedAction } from "../../action/actions";
5
+ export declare class ScriptAction<T extends typeof ScriptActionTypes[keyof typeof ScriptActionTypes] = typeof ScriptActionTypes[keyof typeof ScriptActionTypes]> extends TypedAction<ScriptActionContentType, T, Script> {
6
+ static ActionTypes: {
7
+ readonly action: "script:action";
8
+ };
9
+ executeAction(gameState: GameState): import("../../gameTypes").CalledActionResult<any> | import("../../../../util/data").Awaitable<import("../../gameTypes").CalledActionResult<any>, any>;
10
+ }
@@ -0,0 +1,20 @@
1
+ import { SoundActionContentType, SoundActionTypes } from "../../action/actionTypes";
2
+ import type { Sound } from "../../elements/sound";
3
+ import { GameState } from "../../../player/gameState";
4
+ import type { CalledActionResult } from "../../gameTypes";
5
+ import { Awaitable } from "../../../../util/data";
6
+ import { TypedAction } from "../../action/actions";
7
+ export declare class SoundAction<T extends typeof SoundActionTypes[keyof typeof SoundActionTypes] = typeof SoundActionTypes[keyof typeof SoundActionTypes]> extends TypedAction<SoundActionContentType, T, Sound> {
8
+ static ActionTypes: {
9
+ readonly action: "sound:action";
10
+ readonly play: "sound:play";
11
+ readonly stop: "sound:stop";
12
+ readonly fade: "sound:fade";
13
+ readonly setVolume: "sound:setVolume";
14
+ readonly setRate: "sound:setRate";
15
+ readonly pause: "sound:pause";
16
+ readonly resume: "sound:resume";
17
+ };
18
+ static initSound(state: GameState, sound: Sound): void;
19
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
20
+ }
@@ -0,0 +1,8 @@
1
+ import { StoryActionContentType, StoryActionTypes } from "../../action/actionTypes";
2
+ import type { Story } from "../../elements/story";
3
+ import { TypedAction } from "../../action/actions";
4
+ export declare class StoryAction<T extends typeof StoryActionTypes[keyof typeof StoryActionTypes] = typeof StoryActionTypes[keyof typeof StoryActionTypes]> extends TypedAction<StoryActionContentType, T, Story> {
5
+ static ActionTypes: {
6
+ readonly action: "story:action";
7
+ };
8
+ }
@@ -0,0 +1,19 @@
1
+ import { TextActionContentType, TextActionTypes } from "../../action/actionTypes";
2
+ import { TypedAction } from "../../action/actions";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { CalledActionResult } from "../../gameTypes";
5
+ import { Awaitable } from "../../../../util/data";
6
+ import { Text } from "../../elements/text";
7
+ export declare class TextAction<T extends typeof TextActionTypes[keyof typeof TextActionTypes] = typeof TextActionTypes[keyof typeof TextActionTypes]> extends TypedAction<TextActionContentType, T, Text> {
8
+ static ActionTypes: {
9
+ readonly action: "text:action";
10
+ readonly setText: "text:setText";
11
+ readonly show: "text:show";
12
+ readonly hide: "text:hide";
13
+ readonly applyTransform: "text:applyTransform";
14
+ readonly init: "text:init";
15
+ readonly applyTransition: "text:applyTransition";
16
+ readonly setFontSize: "text:setFontSize";
17
+ };
18
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
19
+ }
@@ -1,134 +1,9 @@
1
1
  import { ContentNode } from "../action/tree/actionTree";
2
- import { Awaitable } from "../../../util/data";
3
- import { Image } from "../elements/image";
4
2
  import { LogicAction } from "../action/logicAction";
5
3
  import { Action } from "../action/action";
6
- import type { Character } from "../elements/text";
7
- import type { Scene } from "../elements/scene";
8
- import type { Story } from "../elements/story";
9
- import type { Script } from "../elements/script";
10
- import type { Menu } from "../elements/menu";
11
- import type { Condition } from "../elements/condition";
12
- import type { CalledActionResult } from "../gameTypes";
13
- import { GameState } from "../../player/gameState";
14
- import type { Sound } from "../elements/sound";
15
- import { Control } from "../elements/control";
16
- import { CharacterActionContentType, CharacterActionTypes, ConditionActionContentType, ConditionActionTypes, ControlActionContentType, ControlActionTypes, ImageActionContentType, ImageActionTypes, MenuActionContentType, MenuActionTypes, SceneActionContentType, SceneActionTypes, ScriptActionContentType, ScriptActionTypes, SoundActionContentType, SoundActionTypes, StoryActionContentType, StoryActionTypes } from "../action/actionTypes";
17
4
  import { Chained, Proxied } from "../action/chain";
18
- export declare class TypedAction<ContentType extends Record<string, any> = Record<string, any>, T extends keyof ContentType & string = keyof ContentType & string, Callee extends LogicAction.GameElement = LogicAction.GameElement> extends Action<ContentType[T], Callee> {
5
+ export declare class TypedAction<ContentType extends Record<string, any> = Record<string, any>, T extends keyof ContentType & string = keyof ContentType & string, Callee extends LogicAction.GameElement = LogicAction.GameElement> extends Action<ContentType[T], Callee, T> {
19
6
  callee: Callee;
20
- constructor(callee: Proxied<Callee, Chained<LogicAction.Actions, Callee>>, type: any, contentNode: ContentNode<ContentType[T]>);
7
+ constructor(callee: Proxied<Callee, Chained<LogicAction.Actions, Callee>>, type: T, contentNode: ContentNode<ContentType[T]>);
21
8
  unknownType(): void;
22
9
  }
23
- export declare class CharacterAction<T extends typeof CharacterActionTypes[keyof typeof CharacterActionTypes] = typeof CharacterActionTypes[keyof typeof CharacterActionTypes]> extends TypedAction<CharacterActionContentType, T, Character> {
24
- static ActionTypes: {
25
- readonly say: "character:say";
26
- readonly action: "character:action";
27
- };
28
- executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
29
- }
30
- export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof SceneActionTypes] = typeof SceneActionTypes[keyof typeof SceneActionTypes]> extends TypedAction<SceneActionContentType, T, Scene> {
31
- static ActionTypes: {
32
- readonly action: "scene:action";
33
- readonly setBackground: "scene:setBackground";
34
- readonly sleep: "scene:sleep";
35
- readonly setTransition: "scene:setTransition";
36
- readonly applyTransition: "scene:applyTransition";
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 applyTransform: "scene:applyTransform";
43
- };
44
- static handleSceneInit(sceneAction: SceneAction, state: GameState, awaitable: Awaitable<CalledActionResult, any>): Awaitable<CalledActionResult<any>, any> | {
45
- type: number | Scene | [] | [import("../common/transition").ITransition<{}> | null] | [import("../common/transition").ITransition<{}>] | [import("../types").StaticImageData | {
46
- url: string;
47
- } | import("../types").color | null | undefined] | Promise<any> | Awaitable<any, any> | [Scene] | [Sound | null, (number | undefined)?] | [import("../common/elements").Transform<import("../common/types").TransformDefinitions.ImageTransformProps>];
48
- node: import("../action/tree/actionTree").RenderableNode | null;
49
- };
50
- static registerEventListeners(scene: Scene, state: GameState, onInit?: () => void): void;
51
- executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
52
- getFutureActions(): LogicAction.Actions[];
53
- }
54
- export declare class StoryAction<T extends typeof StoryActionTypes[keyof typeof StoryActionTypes] = typeof StoryActionTypes[keyof typeof StoryActionTypes]> extends TypedAction<StoryActionContentType, T, Story> {
55
- static ActionTypes: {
56
- readonly action: "story:action";
57
- };
58
- }
59
- export declare class ImageAction<T extends typeof ImageActionTypes[keyof typeof ImageActionTypes] = typeof ImageActionTypes[keyof typeof ImageActionTypes]> extends TypedAction<ImageActionContentType, T, Image> {
60
- static ActionTypes: {
61
- readonly action: "image:action";
62
- readonly setSrc: "image:setSrc";
63
- readonly setPosition: "image:setPosition";
64
- readonly show: "image:show";
65
- readonly hide: "image:hide";
66
- readonly applyTransform: "image:applyTransform";
67
- readonly init: "image:init";
68
- readonly dispose: "image:dispose";
69
- readonly setTransition: "image:setTransition";
70
- readonly applyTransition: "image:applyTransition";
71
- readonly flush: "image:flush";
72
- };
73
- executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
74
- }
75
- export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
76
- static ActionTypes: {
77
- readonly action: "condition:action";
78
- };
79
- executeAction(gameState: GameState): {
80
- type: any;
81
- node: import("../action/tree/actionTree").RenderableNode | null;
82
- };
83
- getFutureActions(): LogicAction.Actions[];
84
- }
85
- export declare class ScriptAction<T extends typeof ScriptActionTypes[keyof typeof ScriptActionTypes] = typeof ScriptActionTypes[keyof typeof ScriptActionTypes]> extends TypedAction<ScriptActionContentType, T, Script> {
86
- static ActionTypes: {
87
- readonly action: "script:action";
88
- };
89
- executeAction(gameState: GameState): CalledActionResult<any> | Awaitable<CalledActionResult<any>, any>;
90
- }
91
- export declare class MenuAction<T extends typeof MenuActionTypes[keyof typeof MenuActionTypes] = typeof MenuActionTypes[keyof typeof MenuActionTypes]> extends TypedAction<MenuActionContentType, T, Menu> {
92
- static ActionTypes: {
93
- readonly action: "menu:action";
94
- };
95
- executeAction(state: GameState): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
96
- getFutureActions(): LogicAction.Actions[];
97
- }
98
- export declare class SoundAction<T extends typeof SoundActionTypes[keyof typeof SoundActionTypes] = typeof SoundActionTypes[keyof typeof SoundActionTypes]> extends TypedAction<SoundActionContentType, T, Sound> {
99
- static ActionTypes: {
100
- readonly action: "sound:action";
101
- readonly play: "sound:play";
102
- readonly stop: "sound:stop";
103
- readonly fade: "sound:fade";
104
- readonly setVolume: "sound:setVolume";
105
- readonly setRate: "sound:setRate";
106
- readonly pause: "sound:pause";
107
- readonly resume: "sound:resume";
108
- };
109
- static initSound(state: GameState, sound: Sound): void;
110
- executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
111
- }
112
- export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
113
- static ActionTypes: {
114
- readonly action: "control:action";
115
- readonly do: "control:do";
116
- readonly doAsync: "control:doAsync";
117
- readonly any: "control:any";
118
- readonly all: "control:all";
119
- readonly allAsync: "control:allAsync";
120
- readonly repeat: "control:repeat";
121
- };
122
- /**
123
- * Execute all actions in the content node
124
- * will wait for awaitable actions to resolve
125
- */
126
- executeAllActions(state: GameState, action: LogicAction.Actions): Promise<void>;
127
- executeSingleAction(state: GameState, action: LogicAction.Actions): Promise<TypedAction<Record<string, any>, string, LogicAction.GameElement> | MenuAction<"menu:action"> | ControlAction<"control:action" | "control:do" | "control:doAsync" | "control:any" | "control:all" | "control:allAsync" | "control:repeat"> | ContentNode<any> | null>;
128
- execute(state: GameState, awaitable: Awaitable<any, any>, content: LogicAction.Actions[]): Awaitable<any, any> | {
129
- type: any;
130
- node: ContentNode<any> | null;
131
- } | Awaitable<CalledActionResult<any>, any>;
132
- executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult>;
133
- getFutureActions(): LogicAction.Actions[];
134
- }
@@ -1,4 +1,4 @@
1
- import type { Character } from "../elements/text";
1
+ import type { Character } from "../elements/character";
2
2
  import type { Scene } from "../elements/scene";
3
3
  import type { Story } from "../elements/story";
4
4
  import type { Image } from "../elements/image";
@@ -6,13 +6,25 @@ import type { Condition } from "../elements/condition";
6
6
  import type { Script } from "../elements/script";
7
7
  import type { Menu } from "../elements/menu";
8
8
  import { Values } from "../../../util/data";
9
- import { CharacterAction, ConditionAction, ControlAction, ImageAction, MenuAction, SceneAction, ScriptAction, SoundAction, StoryAction, TypedAction } from "../action/actions";
9
+ import { TypedAction } from "../action/actions";
10
10
  import { Sound } from "../elements/sound";
11
11
  import { Control } from "../elements/control";
12
- import { CharacterActionContentType, CharacterActionTypes, ConditionActionContentType, ConditionActionTypes, ControlActionContentType, ImageActionContentType, ImageActionTypes, MenuActionContentType, MenuActionTypes, SceneActionContentType, SceneActionTypes, ScriptActionContentType, ScriptActionTypes, SoundActionContentType, StoryActionContentType, StoryActionTypes } from "../action/actionTypes";
12
+ import { CharacterActionContentType, CharacterActionTypes, ConditionActionContentType, ConditionActionTypes, ControlActionContentType, ImageActionContentType, ImageActionTypes, MenuActionContentType, MenuActionTypes, SceneActionContentType, SceneActionTypes, ScriptActionContentType, ScriptActionTypes, SoundActionContentType, StoryActionContentType, StoryActionTypes, TextActionContentType } from "../action/actionTypes";
13
+ import { CharacterAction } from "../action/actions/characterAction";
14
+ import { SceneAction } from "../action/actions/sceneAction";
15
+ import { StoryAction } from "../action/actions/storyAction";
16
+ import { ImageAction } from "../action/actions/imageAction";
17
+ import { ConditionAction } from "../action/actions/conditionAction";
18
+ import { ScriptAction } from "../action/actions/scriptAction";
19
+ import { MenuAction } from "../action/actions/menuAction";
20
+ import { SoundAction } from "../action/actions/soundAction";
21
+ import { ControlAction } from "../action/actions/controlAction";
22
+ import { Text } from "../elements/text";
23
+ import { TextAction } from "../action/actions/textAction";
13
24
  export declare namespace LogicAction {
14
- type GameElement = Character | Scene | Story | Image | Condition | Script | Menu | Sound | Control;
15
- type Actions = (TypedAction | CharacterAction | ConditionAction | ImageAction | SceneAction | ScriptAction | StoryAction | MenuAction | SoundAction | ControlAction);
16
- type ActionTypes = Values<typeof CharacterActionTypes> | Values<typeof ConditionActionTypes> | Values<typeof ImageActionTypes> | Values<typeof SceneActionTypes> | Values<typeof ScriptActionTypes> | Values<typeof StoryActionTypes> | Values<typeof MenuActionTypes> | Values<typeof SoundAction.ActionTypes> | Values<typeof ControlAction.ActionTypes>;
17
- type ActionContents = CharacterActionContentType & ConditionActionContentType & ImageActionContentType & SceneActionContentType & ScriptActionContentType & StoryActionContentType & MenuActionContentType & SoundActionContentType & ControlActionContentType;
25
+ type Displayable = Text;
26
+ type GameElement = Character | Scene | Story | Image | Condition | Script | Menu | Sound | Control | Text;
27
+ type Actions = (TypedAction | CharacterAction | ConditionAction | ImageAction | SceneAction | ScriptAction | StoryAction | MenuAction | SoundAction | ControlAction | TextAction);
28
+ type ActionTypes = Values<typeof CharacterActionTypes> | Values<typeof ConditionActionTypes> | Values<typeof ImageActionTypes> | Values<typeof SceneActionTypes> | Values<typeof ScriptActionTypes> | Values<typeof StoryActionTypes> | Values<typeof MenuActionTypes> | Values<typeof SoundAction.ActionTypes> | Values<typeof ControlAction.ActionTypes> | Values<typeof TextAction.ActionTypes>;
29
+ type ActionContents = CharacterActionContentType & ConditionActionContentType & ImageActionContentType & SceneActionContentType & ScriptActionContentType & StoryActionContentType & MenuActionContentType & SoundActionContentType & ControlActionContentType & TextActionContentType;
18
30
  }
@@ -1,12 +1,31 @@
1
- import type { Background, NextJSStaticImageData } from "../types";
1
+ import type { Background, color, HexColor, ImageColor, ImageSrc, NextJSStaticImageData } from "../types";
2
2
  import type { Scene } from "../elements/scene";
3
3
  import type { Image } from "../elements/image";
4
+ export declare class RGBColor {
5
+ static isHexString(color: any): color is HexColor;
6
+ static fromHex(hex: HexColor): RGBColor;
7
+ r: number;
8
+ g: number;
9
+ b: number;
10
+ a: number;
11
+ constructor(r: number, g: number, b: number, a?: number);
12
+ toString(): string;
13
+ toHex(): string;
14
+ toImageColor(): ImageColor;
15
+ }
4
16
  export declare class Utils {
17
+ static RGBColor: typeof RGBColor;
5
18
  static srcToString(src: string | NextJSStaticImageData): string;
6
19
  static staticImageDataToSrc(image: NextJSStaticImageData | string): string;
7
20
  static isStaticImageData(src: any): src is NextJSStaticImageData;
8
- static backgroundToSrc(background: Background["background"]): any;
21
+ static backgroundToSrc(background: Background["background"]): string | null;
9
22
  static isExternalSrc(src: string): boolean;
23
+ static isImageSrc(src: any): src is ImageSrc;
24
+ static isImageColor(color: any): color is ImageColor;
25
+ static isPlainColor(color: any): color is color;
26
+ static isHexString(color: any): color is HexColor;
27
+ static toBackgroundSrc(src: ImageSrc): string;
28
+ static toHex(color: ImageColor): HexColor;
10
29
  }
11
30
  export declare class UseError<T = Record<string, any>> extends Error {
12
31
  static isUseError(error: any): error is UseError;
@@ -1,4 +1,4 @@
1
- import { Character, Sentence, Word } from "../elements/text";
1
+ import { Character } from "../elements/character";
2
2
  import { Condition, Lambda } from "../elements/condition";
3
3
  import { Control } from "../elements/control";
4
4
  import { Image } from "../elements/image";
@@ -8,4 +8,8 @@ import { Script } from "../elements/script";
8
8
  import { Sound, SoundType } from "../elements/sound";
9
9
  import { Story } from "../elements/story";
10
10
  import { Transform } from "../elements/transform/transform";
11
- export { Character, Condition, Control, Image, Lambda, Menu, Scene, Script, Sentence, Sound, SoundType, Story, Transform, Word };
11
+ import { Sentence } from "../elements/character/sentence";
12
+ import { Word } from "../elements/character/word";
13
+ import { Text } from "../elements/text";
14
+ import { Pause } from "../elements/character/pause";
15
+ export { Character, Condition, Control, Image, Lambda, Menu, Scene, Script, Sentence, Sound, SoundType, Story, Transform, Word, Text, Pause };
@@ -1,7 +1,7 @@
1
- import { ITransition } from "../elements/transition/type";
2
- import { Fade } from "../elements/transition/fade";
3
- import { FadeIn } from "../elements/transition/fadeIn";
4
- import { Dissolve } from "../elements/transition/dissolve";
5
- import { Base } from "../elements/transition/base";
6
- export { Fade, FadeIn, Dissolve, Base };
7
- export type { ITransition };
1
+ import { IImageTransition, ITextTransition, ITransition } from "../elements/transition/type";
2
+ import { BaseImageTransition, BaseTextTransition, BaseTransition } from "../elements/transition/baseTransitions";
3
+ import { Fade } from "../elements/transition/imageTransitions/fade";
4
+ import { FadeIn } from "../elements/transition/imageTransitions/fadeIn";
5
+ import { Dissolve } from "../elements/transition/imageTransitions/dissolve";
6
+ export { Fade, FadeIn, Dissolve, BaseTransition, BaseImageTransition, BaseTextTransition, };
7
+ export type { ITransition, IImageTransition, ITextTransition, };
@@ -0,0 +1,9 @@
1
+ export type PauseConfig = {
2
+ duration?: number;
3
+ };
4
+ export type PausingShortcut = typeof Pause;
5
+ export type Pausing = Pause | PausingShortcut;
6
+ export declare class Pause {
7
+ static wait(duration: number): Pause;
8
+ constructor(config?: Partial<PauseConfig>);
9
+ }
@@ -0,0 +1,29 @@
1
+ import { Sound } from "../../elements/sound";
2
+ import type { Character } from "../../elements/character";
3
+ import { Word } from "../../elements/character/word";
4
+ import { Color, Font } from "../../types";
5
+ import type { ScriptCtx } from "../../elements/script";
6
+ import { Pausing } from "../../elements/character/pause";
7
+ export type SentenceConfig = {
8
+ pause?: boolean | number;
9
+ voice: Sound | null;
10
+ character: Character | null;
11
+ } & Color & Font;
12
+ export type SentenceDataRaw = {
13
+ state: SentenceState;
14
+ };
15
+ export type SentenceState = {
16
+ display: boolean;
17
+ };
18
+ export type SentenceUserConfig = Partial<Omit<SentenceConfig, "voice"> & {
19
+ voice: Sound | string | null | undefined;
20
+ }>;
21
+ export type DynamicWord = (ctx: ScriptCtx) => DynamicWordResult;
22
+ export type DynamicWordResult = string | Word | Pausing | (string | Word | Pausing)[];
23
+ export type StaticWord<T extends string | DynamicWord | Pausing = string | DynamicWord | Pausing> = string | Pausing | Word<T>;
24
+ export type SingleWord = StaticWord | DynamicWord;
25
+ export type SentencePrompt = SingleWord[] | SingleWord;
26
+ export declare class Sentence {
27
+ constructor(text: SentencePrompt, config?: SentenceUserConfig);
28
+ copy(): Sentence;
29
+ }
@@ -0,0 +1,11 @@
1
+ import { Color, Font } from "../../types";
2
+ import { DynamicWord } from "../../elements/character/sentence";
3
+ import { Pausing } from "../../elements/character/pause";
4
+ export type WordConfig = {
5
+ className?: string;
6
+ ruby?: string;
7
+ } & Color & Font;
8
+ export declare class Word<T extends string | DynamicWord | Pausing = string | DynamicWord | Pausing> {
9
+ static isWord(obj: any): obj is Word;
10
+ constructor(text: T, config?: Partial<WordConfig>);
11
+ }