narraleaf-react 0.0.1-beta.1

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 (61) hide show
  1. package/dist/game/nlcore/action/action.d.ts +19 -0
  2. package/dist/game/nlcore/action/actionTypes.d.ts +103 -0
  3. package/dist/game/nlcore/action/actionable.d.ts +19 -0
  4. package/dist/game/nlcore/action/actions.d.ts +126 -0
  5. package/dist/game/nlcore/action/constructable.d.ts +40 -0
  6. package/dist/game/nlcore/action/logicAction.d.ts +18 -0
  7. package/dist/game/nlcore/action/tree/actionTree.d.ts +62 -0
  8. package/dist/game/nlcore/common/Utils.d.ts +33 -0
  9. package/dist/game/nlcore/common/core.d.ts +8 -0
  10. package/dist/game/nlcore/common/elements.d.ts +13 -0
  11. package/dist/game/nlcore/common/game.d.ts +3 -0
  12. package/dist/game/nlcore/common/player.d.ts +4 -0
  13. package/dist/game/nlcore/common/position.d.ts +2 -0
  14. package/dist/game/nlcore/common/transition.d.ts +6 -0
  15. package/dist/game/nlcore/common/types.d.ts +2 -0
  16. package/dist/game/nlcore/elements/condition.d.ts +51 -0
  17. package/dist/game/nlcore/elements/control.d.ts +38 -0
  18. package/dist/game/nlcore/elements/image.d.ts +132 -0
  19. package/dist/game/nlcore/elements/menu.d.ts +44 -0
  20. package/dist/game/nlcore/elements/scene.d.ts +113 -0
  21. package/dist/game/nlcore/elements/script.d.ts +23 -0
  22. package/dist/game/nlcore/elements/sound.d.ts +58 -0
  23. package/dist/game/nlcore/elements/srcManager.d.ts +31 -0
  24. package/dist/game/nlcore/elements/story.d.ts +48 -0
  25. package/dist/game/nlcore/elements/text.d.ts +67 -0
  26. package/dist/game/nlcore/elements/transform/position.d.ts +110 -0
  27. package/dist/game/nlcore/elements/transform/transform.d.ts +97 -0
  28. package/dist/game/nlcore/elements/transform/type.d.ts +49 -0
  29. package/dist/game/nlcore/elements/transition/base.d.ts +18 -0
  30. package/dist/game/nlcore/elements/transition/dissolve.d.ts +34 -0
  31. package/dist/game/nlcore/elements/transition/fade.d.ts +28 -0
  32. package/dist/game/nlcore/elements/transition/fadeIn.d.ts +35 -0
  33. package/dist/game/nlcore/elements/transition/type.d.ts +24 -0
  34. package/dist/game/nlcore/game.d.ts +83 -0
  35. package/dist/game/nlcore/store/storable.d.ts +44 -0
  36. package/dist/game/nlcore/store/type.d.ts +21 -0
  37. package/dist/game/nlcore/types.d.ts +47 -0
  38. package/dist/game/player/elements/Player.d.ts +13 -0
  39. package/dist/game/player/elements/image/Image.d.ts +8 -0
  40. package/dist/game/player/elements/menu/Menu.d.ts +8 -0
  41. package/dist/game/player/elements/menu/Sentence.d.ts +5 -0
  42. package/dist/game/player/elements/preload/Preload.d.ts +6 -0
  43. package/dist/game/player/elements/say/Say.d.ts +10 -0
  44. package/dist/game/player/elements/say/TypingEffect.d.ts +8 -0
  45. package/dist/game/player/elements/scene/Background.d.ts +5 -0
  46. package/dist/game/player/elements/scene/BackgroundTransition.d.ts +8 -0
  47. package/dist/game/player/elements/scene/Scene.d.ts +9 -0
  48. package/dist/game/player/gameState.d.ts +102 -0
  49. package/dist/game/player/lib/Preloaded.d.ts +47 -0
  50. package/dist/game/player/lib/isolated.d.ts +6 -0
  51. package/dist/game/player/lib/main.d.ts +5 -0
  52. package/dist/game/player/provider/game-state.d.ts +12 -0
  53. package/dist/game/player/provider/preloaded.d.ts +10 -0
  54. package/dist/game/player/provider/providers.d.ts +5 -0
  55. package/dist/game/player/provider/ratio.d.ts +23 -0
  56. package/dist/index.d.ts +2 -0
  57. package/dist/index.js +21093 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/util/data.d.ts +65 -0
  60. package/dist/util/singleton.d.ts +5 -0
  61. package/package.json +78 -0
@@ -0,0 +1,19 @@
1
+ import { LogicAction } from "./logicAction";
2
+ import { ContentNode } from "../action/tree/actionTree";
3
+ import type { CalledActionResult } from "@core/gameTypes";
4
+ import { Awaitable } from "../../../util/data";
5
+ import { GameState } from "../../player/gameState";
6
+ export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement> {
7
+ static ActionTypes: {
8
+ action: string;
9
+ };
10
+ callee: Callee;
11
+ type: ContentNodeType;
12
+ contentNode: ContentNode<ContentNodeType>;
13
+ _id: string;
14
+ readonly __stack: string;
15
+ constructor(callee: Callee, type: ContentNodeType, contentNode: ContentNode<ContentNodeType>);
16
+ executeAction(_state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
17
+ getId(): string;
18
+ getFutureActions(): LogicAction.Actions[];
19
+ }
@@ -0,0 +1,103 @@
1
+ import { LogicAction } from "../action/logicAction";
2
+ import type { Story } from "../elements/story";
3
+ import type { ConditionData } from "../elements/condition";
4
+ import { Background, CommonImage } from "../types";
5
+ import { Transform } from "../elements/transform/transform";
6
+ import type { Scene } from "../elements/scene";
7
+ import type { Sentence } from "../elements/text";
8
+ import type { MenuData } from "../elements/menu";
9
+ import { Awaitable } from "../../../util/data";
10
+ import { ITransition } from "../elements/transition/type";
11
+ import type { Sound } from "../elements/sound";
12
+ import type { Script } from "../elements/script";
13
+ export declare const CharacterActionTypes: {
14
+ readonly say: "character:say";
15
+ readonly action: "character:action";
16
+ };
17
+ export type CharacterActionContentType = {
18
+ [K in typeof CharacterActionTypes[keyof typeof CharacterActionTypes]]: K extends "character:say" ? Sentence : K extends "character:action" ? any : any;
19
+ };
20
+ export declare const SceneActionTypes: {
21
+ readonly action: "scene:action";
22
+ readonly setBackground: "scene:setBackground";
23
+ readonly sleep: "scene:sleep";
24
+ readonly setTransition: "scene:setTransition";
25
+ readonly applyTransition: "scene:applyTransition";
26
+ readonly init: "scene:init";
27
+ readonly exit: "scene:exit";
28
+ readonly jumpTo: "scene:jumpTo";
29
+ readonly setBackgroundMusic: "scene:setBackgroundMusic";
30
+ readonly preUnmount: "scene:preUnmount";
31
+ readonly applyTransform: "scene:applyTransform";
32
+ };
33
+ 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, number?] : K extends typeof SceneActionTypes["preUnmount"] ? [] : K extends typeof SceneActionTypes["applyTransform"] ? [Transform] : any;
35
+ };
36
+ export declare const StoryActionTypes: {
37
+ readonly action: "story:action";
38
+ };
39
+ export type StoryActionContentType = {
40
+ [K in typeof StoryActionTypes[keyof typeof StoryActionTypes]]: K extends "story:action" ? Story : any;
41
+ };
42
+ export declare const ImageActionTypes: {
43
+ readonly action: "image:action";
44
+ readonly setSrc: "image:setSrc";
45
+ readonly setPosition: "image:setPosition";
46
+ readonly show: "image:show";
47
+ readonly hide: "image:hide";
48
+ readonly applyTransform: "image:applyTransform";
49
+ readonly init: "image:init";
50
+ readonly dispose: "image:dispose";
51
+ readonly setTransition: "image:setTransition";
52
+ readonly applyTransition: "image:applyTransition";
53
+ };
54
+ export type ImageActionContentType = {
55
+ [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] : any;
56
+ };
57
+ export declare const ConditionActionTypes: {
58
+ readonly action: "condition:action";
59
+ };
60
+ export type ConditionActionContentType = {
61
+ [K in typeof ConditionActionTypes[keyof typeof ConditionActionTypes]]: K extends "condition:action" ? ConditionData : any;
62
+ };
63
+ export declare const ScriptActionTypes: {
64
+ readonly action: "script:action";
65
+ };
66
+ export type ScriptActionContentType = {
67
+ [K in typeof ScriptActionTypes[keyof typeof ScriptActionTypes]]: K extends "script:action" ? Script : any;
68
+ };
69
+ export declare const MenuActionTypes: {
70
+ readonly action: "menu:action";
71
+ };
72
+ export type MenuActionContentType = {
73
+ [K in typeof MenuActionTypes[keyof typeof MenuActionTypes]]: K extends "menu:action" ? MenuData : any;
74
+ };
75
+ export declare const SoundActionTypes: {
76
+ readonly action: "sound:action";
77
+ readonly play: "sound:play";
78
+ readonly stop: "sound:stop";
79
+ readonly fade: "sound:fade";
80
+ readonly setVolume: "sound:setVolume";
81
+ readonly setRate: "sound:setRate";
82
+ };
83
+ export type SoundActionContentType = {
84
+ [K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [void] : K extends "sound:stop" ? [void] : K extends "sound:fade" ? [
85
+ {
86
+ start: number;
87
+ end: number;
88
+ duration: number;
89
+ }
90
+ ] : K extends "sound:setVolume" ? [number] : K extends "sound:setRate" ? [number] : any;
91
+ };
92
+ export declare const ControlActionTypes: {
93
+ readonly action: "control:action";
94
+ readonly do: "control:do";
95
+ readonly doAsync: "control:doAsync";
96
+ readonly any: "control:any";
97
+ readonly all: "control:all";
98
+ readonly allAsync: "control:allAsync";
99
+ readonly repeat: "control:repeat";
100
+ };
101
+ export type ControlActionContentType = {
102
+ [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;
103
+ };
@@ -0,0 +1,19 @@
1
+ import { LogicAction } from "../action/logicAction";
2
+ export declare class Actionable<StateData extends Record<string, any> = Record<string, any>> {
3
+ static IdPrefixes: {
4
+ readonly Actionable: "actionable";
5
+ readonly Condition: "$0";
6
+ readonly Control: "$1";
7
+ readonly Image: "$2";
8
+ readonly Script: "$3";
9
+ readonly Sound: "$4";
10
+ readonly Text: "$5";
11
+ readonly Menu: "$6";
12
+ };
13
+ readonly id: string;
14
+ protected actions: LogicAction.Actions[];
15
+ constructor(idPrefix?: string);
16
+ toActions(): LogicAction.Actions[];
17
+ toData(): StateData | null;
18
+ fromData(_: StateData): this;
19
+ }
@@ -0,0 +1,126 @@
1
+ import { ContentNode } from "../action/tree/actionTree";
2
+ import { Awaitable } from "../../../util/data";
3
+ import { Image } from "../elements/image";
4
+ import { LogicAction } from "../action/logicAction";
5
+ 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 "@core/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
+ 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> {
18
+ callee: Callee;
19
+ constructor(callee: Callee, type: any, contentNode: ContentNode<ContentType[T]>);
20
+ unknownType(): void;
21
+ }
22
+ export declare class CharacterAction<T extends typeof CharacterActionTypes[keyof typeof CharacterActionTypes] = typeof CharacterActionTypes[keyof typeof CharacterActionTypes]> extends TypedAction<CharacterActionContentType, T, Character> {
23
+ static ActionTypes: {
24
+ readonly say: "character:say";
25
+ readonly action: "character:action";
26
+ };
27
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
28
+ }
29
+ export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof SceneActionTypes] = typeof SceneActionTypes[keyof typeof SceneActionTypes]> extends TypedAction<SceneActionContentType, T, Scene> {
30
+ static ActionTypes: {
31
+ readonly action: "scene:action";
32
+ readonly setBackground: "scene:setBackground";
33
+ readonly sleep: "scene:sleep";
34
+ readonly setTransition: "scene:setTransition";
35
+ readonly applyTransition: "scene:applyTransition";
36
+ readonly init: "scene:init";
37
+ readonly exit: "scene:exit";
38
+ readonly jumpTo: "scene:jumpTo";
39
+ readonly setBackgroundMusic: "scene:setBackgroundMusic";
40
+ readonly preUnmount: "scene:preUnmount";
41
+ readonly applyTransform: "scene:applyTransform";
42
+ };
43
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
44
+ getFutureActions(): LogicAction.Actions[];
45
+ }
46
+ export declare class StoryAction<T extends typeof StoryActionTypes[keyof typeof StoryActionTypes] = typeof StoryActionTypes[keyof typeof StoryActionTypes]> extends TypedAction<StoryActionContentType, T, Story> {
47
+ static ActionTypes: {
48
+ readonly action: "story:action";
49
+ };
50
+ }
51
+ export declare class ImageAction<T extends typeof ImageActionTypes[keyof typeof ImageActionTypes] = typeof ImageActionTypes[keyof typeof ImageActionTypes]> extends TypedAction<ImageActionContentType, T, Image> {
52
+ static ActionTypes: {
53
+ readonly action: "image:action";
54
+ readonly setSrc: "image:setSrc";
55
+ readonly setPosition: "image:setPosition";
56
+ readonly show: "image:show";
57
+ readonly hide: "image:hide";
58
+ readonly applyTransform: "image:applyTransform";
59
+ readonly init: "image:init";
60
+ readonly dispose: "image:dispose";
61
+ readonly setTransition: "image:setTransition";
62
+ readonly applyTransition: "image:applyTransition";
63
+ };
64
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
65
+ }
66
+ export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
67
+ static ActionTypes: {
68
+ readonly action: "condition:action";
69
+ };
70
+ executeAction(gameState: GameState): {
71
+ type: any;
72
+ node: ContentNode<ConditionActionContentType[T]>;
73
+ };
74
+ getFutureActions(): LogicAction.Actions[];
75
+ }
76
+ export declare class ScriptAction<T extends typeof ScriptActionTypes[keyof typeof ScriptActionTypes] = typeof ScriptActionTypes[keyof typeof ScriptActionTypes]> extends TypedAction<ScriptActionContentType, T, Script> {
77
+ static ActionTypes: {
78
+ readonly action: "script:action";
79
+ };
80
+ executeAction(gameState: GameState): {
81
+ type: any;
82
+ node: ContentNode<ScriptActionContentType[T]>;
83
+ };
84
+ }
85
+ export declare class MenuAction<T extends typeof MenuActionTypes[keyof typeof MenuActionTypes] = typeof MenuActionTypes[keyof typeof MenuActionTypes]> extends TypedAction<MenuActionContentType, T, Menu> {
86
+ static ActionTypes: {
87
+ readonly action: "menu:action";
88
+ };
89
+ executeAction(state: GameState): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
90
+ getFutureActions(): LogicAction.Actions[];
91
+ }
92
+ export declare class SoundAction<T extends typeof SoundActionTypes[keyof typeof SoundActionTypes] = typeof SoundActionTypes[keyof typeof SoundActionTypes]> extends TypedAction<SoundActionContentType, T, Sound> {
93
+ static ActionTypes: {
94
+ readonly action: "sound:action";
95
+ readonly play: "sound:play";
96
+ readonly stop: "sound:stop";
97
+ readonly fade: "sound:fade";
98
+ readonly setVolume: "sound:setVolume";
99
+ readonly setRate: "sound:setRate";
100
+ };
101
+ static initSound(state: GameState, sound: Sound): void;
102
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
103
+ }
104
+ export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
105
+ static ActionTypes: {
106
+ readonly action: "control:action";
107
+ readonly do: "control:do";
108
+ readonly doAsync: "control:doAsync";
109
+ readonly any: "control:any";
110
+ readonly all: "control:all";
111
+ readonly allAsync: "control:allAsync";
112
+ readonly repeat: "control:repeat";
113
+ };
114
+ /**
115
+ * Execute all actions in the content node
116
+ * will wait for awaitable actions to resolve
117
+ */
118
+ executeAllActions(state: GameState, action: LogicAction.Actions): Promise<void>;
119
+ 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>;
120
+ execute(state: GameState, awaitable: Awaitable<any, any>, content: LogicAction.Actions[]): Awaitable<any, any> | {
121
+ type: any;
122
+ node: ContentNode<any> | null;
123
+ } | Awaitable<CalledActionResult<any>, any>;
124
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult>;
125
+ getFutureActions(): LogicAction.Actions[];
126
+ }
@@ -0,0 +1,40 @@
1
+ import { ContentNode, RenderableNode, RootNode } from "../action/tree/actionTree";
2
+ import { LogicAction } from "../action/logicAction";
3
+ export declare class Constructable<T extends typeof Constructable = any, TAction extends LogicAction.Actions = LogicAction.Actions, CAction extends LogicAction.Actions = LogicAction.Actions> {
4
+ static targetAction: any;
5
+ private readonly actions;
6
+ constructor();
7
+ setRoot(root: RootNode): LogicAction.Actions | undefined;
8
+ getActions(): TAction[];
9
+ setActions(actions: TAction[]): void;
10
+ /**@internal */
11
+ getAllActions(includeJumpTo?: boolean, actions?: LogicAction.Actions[]): LogicAction.Actions[];
12
+ /**@internal */
13
+ forEachAction(callback: (action: LogicAction.Actions) => void, includeJumpTo?: boolean, actions?: LogicAction.Actions[]): void;
14
+ /**@internal */
15
+ findActionById(id: string, actions?: LogicAction.Actions[]): LogicAction.Actions | null;
16
+ /**@internal */
17
+ getAllElements(actions?: LogicAction.Actions[]): LogicAction.GameElement[];
18
+ /**@internal */
19
+ getActionsByType(type: LogicAction.ActionTypes, actions?: LogicAction.Actions[]): LogicAction.Actions[];
20
+ /**@internal */
21
+ getAllNodes(actions?: LogicAction.Actions[]): ContentNode[];
22
+ /**@internal */
23
+ findNodeById(id: string, actions?: LogicAction.Actions[]): ContentNode | null;
24
+ /**@internal */
25
+ findElementById(id: string, elements: LogicAction.GameElement[]): LogicAction.GameElement | null;
26
+ /**
27
+ * @internal
28
+ * Find multiple elements by multiple IDs
29
+ */
30
+ findElementsByIds(ids: string[], elements: LogicAction.GameElement[]): LogicAction.GameElement[];
31
+ /**
32
+ * Adds an action to the current specified context instance
33
+ */
34
+ protected _action(actions: (callee: this) => (TAction | TAction[])[]): CAction;
35
+ protected _action(actions: (TAction | TAction[])[]): CAction;
36
+ /**
37
+ * Construct the actions into a tree
38
+ */
39
+ protected construct(parent?: RenderableNode): RenderableNode | null;
40
+ }
@@ -0,0 +1,18 @@
1
+ import type { Character } from "../elements/text";
2
+ import type { Scene } from "../elements/scene";
3
+ import type { Story } from "../elements/story";
4
+ import type { Image } from "../elements/image";
5
+ import type { Condition } from "../elements/condition";
6
+ import type { Script } from "../elements/script";
7
+ import type { Menu } from "../elements/menu";
8
+ import { Values } from "../../../util/data";
9
+ import { CharacterAction, ConditionAction, ControlAction, ImageAction, MenuAction, SceneAction, ScriptAction, SoundAction, StoryAction, TypedAction } from "../action/actions";
10
+ import { Sound } from "../elements/sound";
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";
13
+ 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;
18
+ }
@@ -0,0 +1,62 @@
1
+ import { LogicAction } from "../../action/logicAction";
2
+ export declare enum NodeType {
3
+ TreeNode = "TreeNode",
4
+ ContentNode = "ContentNode"
5
+ }
6
+ export type RawData<T> = {
7
+ id: string;
8
+ data: T;
9
+ };
10
+ export declare class Node<C = any> {
11
+ id: string;
12
+ type: string;
13
+ content: C | undefined;
14
+ constructor(id: string, type: string);
15
+ setContent(content: C): this;
16
+ getContent(): C;
17
+ }
18
+ export type RenderableNode = ContentNode;
19
+ export type RenderableNodeData = ContentNodeData | TreeNodeData;
20
+ export type ContentNodeData = {
21
+ id: string;
22
+ data: any;
23
+ };
24
+ export declare class ContentNode<T = any> extends Node<T> {
25
+ static forEachParent(node: RenderableNode, callback: (node: RenderableNode) => void): void;
26
+ static forEachChild(node: RenderableNode, callback: (node: RenderableNode) => void): void;
27
+ child?: RenderableNode | null;
28
+ initChild?: RenderableNode | null;
29
+ parent: RenderableNode | null;
30
+ action: LogicAction.Actions | null;
31
+ constructor(id: string, callee?: LogicAction.Actions, parent?: RenderableNode | null, child?: RenderableNode);
32
+ setParent(parent: RenderableNode | null): this;
33
+ setChild(child: RenderableNode | null): this;
34
+ getChild(): RenderableNode | null;
35
+ getParent(): RenderableNode | null;
36
+ /**
37
+ * To track the changes of the child
38
+ * should only be called when constructing the tree
39
+ */
40
+ setInitChild(child: RenderableNode): this;
41
+ /**
42
+ * Public method for setting the content of the node
43
+ * should only be called when changing the state in-game
44
+ */
45
+ addChild(child: RenderableNode | null): this;
46
+ removeChild(child: RenderableNode | null): this;
47
+ /**
48
+ * Remove this node from the parent's children
49
+ */
50
+ remove(): this;
51
+ hasChild(): boolean;
52
+ }
53
+ export declare class RootNode extends ContentNode {
54
+ constructor();
55
+ setParent(_: RenderableNode | null): this;
56
+ remove(): this;
57
+ forEach(callback: (node: RenderableNode) => void): void;
58
+ }
59
+ export type TreeNodeData = {
60
+ id: string;
61
+ data: any;
62
+ };
@@ -0,0 +1,33 @@
1
+ import type { Background, NextJSStaticImageData } from "../types";
2
+ import type { Scene } from "../elements/scene";
3
+ import type { Image } from "../elements/image";
4
+ export declare class Utils {
5
+ static srcToString(src: string | NextJSStaticImageData): string;
6
+ static staticImageDataToSrc(image: NextJSStaticImageData | string): string;
7
+ static isStaticImageData(src: any): src is NextJSStaticImageData;
8
+ static backgroundToSrc(background: Background["background"]): any;
9
+ static isExternalSrc(src: string): boolean;
10
+ }
11
+ export declare class UseError<T = Record<string, any>> extends Error {
12
+ private props;
13
+ constructor(message: string, props: T, name?: string);
14
+ static isUseError(error: any): error is UseError;
15
+ }
16
+ export declare class StaticScriptWarning extends UseError<{
17
+ stack?: string;
18
+ }> {
19
+ static isWarning(error: any): error is StaticScriptWarning;
20
+ constructor(message: string);
21
+ }
22
+ type ImageState = {
23
+ isDisposed: boolean;
24
+ usedExternalSrc: boolean;
25
+ };
26
+ export declare class StaticChecker {
27
+ private readonly scene;
28
+ constructor(target: Scene);
29
+ start(): Map<Image, ImageState> | null;
30
+ private checkAction;
31
+ private checkImage;
32
+ }
33
+ export {};
@@ -0,0 +1,8 @@
1
+ import { Utils } from "./Utils";
2
+ export * from "./elements";
3
+ export * from "./game";
4
+ export * from "./player";
5
+ export * from "./types";
6
+ export * from "./position";
7
+ export * from "./transition";
8
+ export { Utils };
@@ -0,0 +1,13 @@
1
+ import { Character, Sentence, Word } from "../elements/text";
2
+ import { Condition, Lambda } from "../elements/condition";
3
+ import { Control } from "../elements/control";
4
+ import { Game } from "../game";
5
+ import { Image } from "../elements/image";
6
+ import { Menu } from "../elements/menu";
7
+ import { Scene } from "../elements/scene";
8
+ import { Script } from "../elements/script";
9
+ import { Sound, SoundType } from "../elements/sound";
10
+ import { Story } from "../elements/story";
11
+ import { Transform } from "../elements/transform/transform";
12
+ import { Utils } from "./Utils";
13
+ export { Character, Condition, Control, Game, Image, Lambda, Menu, Scene, Script, Sentence, Sound, SoundType, Story, Transform, Utils, Word };
@@ -0,0 +1,3 @@
1
+ import { LiveGame } from "../game";
2
+ import { GameState } from "../../player/gameState";
3
+ export { LiveGame, GameState };
@@ -0,0 +1,4 @@
1
+ import Player from "../../player/elements/Player";
2
+ import GameProviders from "../../player/provider/providers";
3
+ import { GameState } from "../../player/gameState";
4
+ export { GameProviders, Player, GameState, };
@@ -0,0 +1,2 @@
1
+ import { Align, CommonPosition, Coord2D, CommonPositionType } from "../elements/transform/position";
2
+ export { Align, CommonPosition, Coord2D, CommonPositionType };
@@ -0,0 +1,6 @@
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
+ export { Fade, FadeIn, Dissolve };
6
+ export type { ITransition };
@@ -0,0 +1,2 @@
1
+ import { TransformDefinitions } from "../elements/transform/type";
2
+ export type { TransformDefinitions, };
@@ -0,0 +1,51 @@
1
+ import { RenderableNode } from "../action/tree/actionTree";
2
+ import { LogicAction } from "../action/logicAction";
3
+ import { Actionable } from "../action/actionable";
4
+ import { GameState } from "../../player/gameState";
5
+ export type ConditionConfig = {};
6
+ interface LambdaCtx {
7
+ gameState: GameState;
8
+ }
9
+ type LambdaHandler<T = any> = (ctx: LambdaCtx) => T;
10
+ export declare class Lambda {
11
+ handler: LambdaHandler;
12
+ constructor(handler: LambdaHandler);
13
+ evaluate({ gameState }: {
14
+ gameState: GameState;
15
+ }): {
16
+ value: any;
17
+ };
18
+ getCtx({ gameState }: {
19
+ gameState: GameState;
20
+ }): LambdaCtx;
21
+ }
22
+ export type ConditionData = {
23
+ If: {
24
+ condition: Lambda | null;
25
+ action: LogicAction.Actions[] | null;
26
+ };
27
+ ElseIf: {
28
+ condition: Lambda | null;
29
+ action: (LogicAction.Actions[]) | null;
30
+ }[];
31
+ Else: {
32
+ action: (LogicAction.Actions[]) | null;
33
+ };
34
+ };
35
+ export declare class Condition extends Actionable {
36
+ static defaultConfig: ConditionConfig;
37
+ readonly config: ConditionConfig;
38
+ conditions: ConditionData;
39
+ constructor(config?: ConditionConfig);
40
+ static getInitialState(): ConditionData;
41
+ If(condition: Lambda | LambdaHandler<boolean>, action: LogicAction.Actions | LogicAction.Actions[]): this;
42
+ ElseIf(condition: Lambda | LambdaHandler<boolean>, action: (LogicAction.Actions | LogicAction.Actions[])): this;
43
+ Else(action: (LogicAction.Actions | LogicAction.Actions[])): this;
44
+ evaluate(conditions: ConditionData, { gameState }: {
45
+ gameState: GameState;
46
+ }): LogicAction.Actions[] | null;
47
+ toActions(): LogicAction.Actions[];
48
+ construct(actions: LogicAction.Actions[], lastChild?: RenderableNode, parentChild?: RenderableNode): LogicAction.Actions[];
49
+ _getFutureActions(): LogicAction.Actions[];
50
+ }
51
+ export {};
@@ -0,0 +1,38 @@
1
+ import { Actionable } from "../action/actionable";
2
+ import { LogicAction } from "../action/logicAction";
3
+ import Actions = LogicAction.Actions;
4
+ export declare class Control extends Actionable {
5
+ /**
6
+ * Execute actions in order, waiting for each action to complete
7
+ */
8
+ static do(actions: (Actions | Actions[])[]): Control;
9
+ /**
10
+ * Execute actions in order, do not wait for this action to complete
11
+ */
12
+ static doAsync(actions: (Actions | Actions[])[]): Control;
13
+ /**
14
+ * Execute all actions at the same time, waiting for any one action to complete
15
+ */
16
+ static any(actions: (Actions | Actions[])[]): Control;
17
+ /**
18
+ * Execute all actions at the same time, waiting for all actions to complete
19
+ */
20
+ static all(actions: (Actions | Actions[])[]): Control;
21
+ /**
22
+ * Execute all actions at the same time, do not wait for all actions to complete
23
+ */
24
+ static allAsync(actions: (Actions | Actions[])[]): Control;
25
+ /**
26
+ * Execute actions multiple times
27
+ */
28
+ static repeat(times: number, actions: (Actions | Actions[])[]): Control;
29
+ constructor();
30
+ do(actions: (Actions | Actions[])[]): this;
31
+ doAsync(actions: (Actions | Actions[])[]): this;
32
+ any(actions: (Actions | Actions[])[]): this;
33
+ all(actions: (Actions | Actions[])[]): this;
34
+ allAsync(actions: (Actions | Actions[])[]): this;
35
+ repeat(times: number, actions: (Actions | Actions[])[]): this;
36
+ construct(actions: Actions[]): Actions[];
37
+ private push;
38
+ }