narraleaf-react 0.1.7 → 0.2.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 (48) hide show
  1. package/dist/game/nlcore/action/action.d.ts +4 -1
  2. package/dist/game/nlcore/action/actionTypes.d.ts +24 -6
  3. package/dist/game/nlcore/action/actionable.d.ts +1 -1
  4. package/dist/game/nlcore/action/actions/characterAction.d.ts +3 -0
  5. package/dist/game/nlcore/action/actions/conditionAction.d.ts +2 -1
  6. package/dist/game/nlcore/action/actions/controlAction.d.ts +2 -1
  7. package/dist/game/nlcore/action/actions/displayableAction.d.ts +15 -0
  8. package/dist/game/nlcore/action/actions/imageAction.d.ts +2 -1
  9. package/dist/game/nlcore/action/actions/menuAction.d.ts +2 -1
  10. package/dist/game/nlcore/action/actions/persistentAction.d.ts +12 -0
  11. package/dist/game/nlcore/action/actions/sceneAction.d.ts +9 -4
  12. package/dist/game/nlcore/action/actions/textAction.d.ts +1 -1
  13. package/dist/game/nlcore/action/actions.d.ts +2 -1
  14. package/dist/game/nlcore/action/logicAction.d.ts +12 -8
  15. package/dist/game/nlcore/action/srcManager.d.ts +16 -1
  16. package/dist/game/nlcore/action/tree/actionTree.d.ts +1 -0
  17. package/dist/game/nlcore/common/Utils.d.ts +12 -2
  18. package/dist/game/nlcore/common/elements.d.ts +15 -3
  19. package/dist/game/nlcore/common/game.d.ts +1 -1
  20. package/dist/game/nlcore/common/types.d.ts +1 -0
  21. package/dist/game/nlcore/elements/character/sentence.d.ts +1 -0
  22. package/dist/game/nlcore/elements/condition.d.ts +6 -23
  23. package/dist/game/nlcore/elements/displayable/displayable.d.ts +38 -0
  24. package/dist/game/nlcore/elements/{image.d.ts → displayable/image.d.ts} +43 -22
  25. package/dist/game/nlcore/elements/{text.d.ts → displayable/text.d.ts} +9 -11
  26. package/dist/game/nlcore/{store → elements/persistent}/storable.d.ts +5 -2
  27. package/dist/game/nlcore/elements/persistent.d.ts +67 -0
  28. package/dist/game/nlcore/elements/scene.d.ts +23 -10
  29. package/dist/game/nlcore/elements/script.d.ts +1 -1
  30. package/dist/game/nlcore/elements/sound.d.ts +2 -0
  31. package/dist/game/nlcore/elements/story.d.ts +26 -1
  32. package/dist/game/nlcore/elements/transition/baseTransitions.d.ts +2 -0
  33. package/dist/game/nlcore/elements/type.d.ts +5 -0
  34. package/dist/game/nlcore/gameTypes.d.ts +36 -8
  35. package/dist/game/nlcore/liveGame.d.ts +3 -3
  36. package/dist/game/player/elements/displayable/Displayables.d.ts +1 -1
  37. package/dist/game/player/elements/displayable/Text.d.ts +1 -1
  38. package/dist/game/player/elements/image/Image.d.ts +1 -1
  39. package/dist/game/player/elements/type.d.ts +1 -1
  40. package/dist/game/player/gameState.d.ts +17 -9
  41. package/dist/game/player/lib/ImageCacheManager.d.ts +21 -0
  42. package/dist/game/player/lib/Preloaded.d.ts +1 -1
  43. package/dist/game/player/provider/preloaded.d.ts +2 -0
  44. package/dist/main.js +1 -1
  45. package/dist/util/data.d.ts +43 -13
  46. package/dist/util/logger.d.ts +18 -0
  47. package/package.json +1 -1
  48. /package/dist/game/nlcore/{store → elements/persistent}/type.d.ts +0 -0
@@ -3,6 +3,7 @@ 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
+ import { Story } from "../elements/story";
6
7
  export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement, Type extends string = any> {
7
8
  static ActionTypes: {
8
9
  action: string;
@@ -16,5 +17,7 @@ export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElem
16
17
  executeAction(_state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
17
18
  getId(): string;
18
19
  setId(id: string): void;
19
- getFutureActions(): LogicAction.Actions[];
20
+ setContent(content: ContentNodeType): this;
21
+ setContentNode(contentNode: ContentNode<ContentNodeType>): this;
22
+ getFutureActions(_story: Story): LogicAction.Actions[];
20
23
  }
@@ -5,13 +5,13 @@ import { CommonDisplayable, ImageColor, ImageSrc } from "../types";
5
5
  import { Transform } from "../elements/transform/transform";
6
6
  import type { Scene } from "../elements/scene";
7
7
  import type { MenuData } from "../elements/menu";
8
- import { Awaitable } from "../../../util/data";
9
- import { ITransition } from "../elements/transition/type";
8
+ import { Awaitable, FlexibleTuple, SelectElementFromEach } from "../../../util/data";
9
+ import { IImageTransition, ITransition } from "../elements/transition/type";
10
10
  import type { Sound } from "../elements/sound";
11
11
  import type { Script } from "../elements/script";
12
12
  import { Sentence } from "../elements/character/sentence";
13
13
  import type { TransformDefinitions } from "../elements/transform/type";
14
- import { Image } from "../elements/image";
14
+ import { Image, TagGroupDefinition } from "../elements/displayable/image";
15
15
  export declare const CharacterActionTypes: {
16
16
  readonly say: "character:say";
17
17
  readonly action: "character:action";
@@ -24,7 +24,6 @@ export declare const SceneActionTypes: {
24
24
  readonly action: "scene:action";
25
25
  readonly setBackground: "scene:setBackground";
26
26
  readonly sleep: "scene:sleep";
27
- readonly setTransition: "scene:setTransition";
28
27
  readonly applyTransition: "scene:applyTransition";
29
28
  readonly init: "scene:init";
30
29
  readonly exit: "scene:exit";
@@ -32,9 +31,10 @@ export declare const SceneActionTypes: {
32
31
  readonly setBackgroundMusic: "scene:setBackgroundMusic";
33
32
  readonly preUnmount: "scene:preUnmount";
34
33
  readonly applyTransform: "scene:applyTransform";
34
+ readonly transitionToScene: "scene:transitionToScene";
35
35
  };
36
36
  export type SceneActionContentType = {
37
- [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;
37
+ [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["applyTransition"] ? [ITransition] : K extends typeof SceneActionTypes["init"] ? [Scene | string] : K extends typeof SceneActionTypes["exit"] ? [] : K extends typeof SceneActionTypes["jumpTo"] ? [Scene | string] : K extends typeof SceneActionTypes["setBackgroundMusic"] ? [Sound | null, number?] : K extends typeof SceneActionTypes["preUnmount"] ? [] : K extends typeof SceneActionTypes["applyTransform"] ? [Transform] : K extends typeof SceneActionTypes["transitionToScene"] ? [IImageTransition, Scene | string | undefined, ImageSrc | ImageColor | undefined] : any;
38
38
  };
39
39
  export declare const StoryActionTypes: {
40
40
  readonly action: "story:action";
@@ -58,9 +58,10 @@ export declare const ImageActionTypes: {
58
58
  readonly applyTransition: "image:applyTransition";
59
59
  readonly flush: "image:flush";
60
60
  readonly initWearable: "image:initWearable";
61
+ readonly setAppearance: "image:setAppearance";
61
62
  };
62
63
  export type ImageActionContentType = {
63
- [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" ? [] : K extends "image:initWearable" ? [Image] : any;
64
+ [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" ? [] : K extends "image:initWearable" ? [Image] : K extends "image:setAppearance" ? [FlexibleTuple<SelectElementFromEach<TagGroupDefinition>> | string[], IImageTransition | undefined] : any;
64
65
  };
65
66
  export declare const ConditionActionTypes: {
66
67
  readonly action: "condition:action";
@@ -125,3 +126,20 @@ export declare const TextActionTypes: {
125
126
  export type TextActionContentType = {
126
127
  [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;
127
128
  };
129
+ export declare const DisplayableActionTypes: {
130
+ readonly action: "displayable:action";
131
+ readonly layerMoveUp: "displayable:layerMoveUp";
132
+ readonly layerMoveDown: "displayable:layerMoveDown";
133
+ readonly layerMoveTop: "displayable:layerMoveTop";
134
+ readonly layerMoveBottom: "displayable:layerMoveBottom";
135
+ };
136
+ export type DisplayableActionContentType = {
137
+ [K in typeof DisplayableActionTypes[keyof typeof DisplayableActionTypes]]: K extends "displayable:layerMoveUp" ? [void] : K extends "displayable:layerMoveDown" ? [void] : K extends "displayable:layerMoveTop" ? [void] : K extends "displayable:layerMoveBottom" ? [void] : any;
138
+ };
139
+ export declare const PersistentActionTypes: {
140
+ readonly action: "persistent:action";
141
+ readonly set: "persistent:set";
142
+ };
143
+ export type PersistentActionContentType = {
144
+ [K in typeof PersistentActionTypes[keyof typeof PersistentActionTypes]]: K extends "persistent:action" ? any : K extends "persistent:set" ? [string, any] : any;
145
+ };
@@ -1,5 +1,5 @@
1
1
  import { LogicAction } from "../action/logicAction";
2
2
  import { Chainable } from "../action/chain";
3
- export declare class Actionable<StateData extends Record<string, any> = Record<string, any>, Self extends Actionable = any> extends Chainable<LogicAction.Actions, Self> {
3
+ export declare class Actionable<StateData extends Record<string, any> | null = Record<string, any>, Self extends Actionable = any> extends Chainable<LogicAction.Actions, Self> {
4
4
  constructor();
5
5
  }
@@ -3,12 +3,15 @@ import type { Character } from "../../elements/character";
3
3
  import { GameState } from "../../../player/gameState";
4
4
  import type { CalledActionResult } from "../../gameTypes";
5
5
  import { Awaitable } from "../../../../util/data";
6
+ import { Sentence } from "../../elements/character/sentence";
6
7
  import { TypedAction } from "../../action/actions";
8
+ import { Sound } from "../../elements/sound";
7
9
  export declare class CharacterAction<T extends typeof CharacterActionTypes[keyof typeof CharacterActionTypes] = typeof CharacterActionTypes[keyof typeof CharacterActionTypes]> extends TypedAction<CharacterActionContentType, T, Character> {
8
10
  static ActionTypes: {
9
11
  readonly say: "character:say";
10
12
  readonly action: "character:action";
11
13
  readonly setName: "character:setName";
12
14
  };
15
+ static getVoice(state: GameState, sentence: Sentence): Sound | null;
13
16
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
14
17
  }
@@ -3,6 +3,7 @@ import type { Condition } from "../../elements/condition";
3
3
  import { GameState } from "../../../player/gameState";
4
4
  import { LogicAction } from "../../action/logicAction";
5
5
  import { TypedAction } from "../../action/actions";
6
+ import { Story } from "../../elements/story";
6
7
  export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
7
8
  static ActionTypes: {
8
9
  readonly action: "condition:action";
@@ -11,5 +12,5 @@ export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof
11
12
  type: any;
12
13
  node: import("../tree/actionTree").RenderableNode | null;
13
14
  };
14
- getFutureActions(): LogicAction.Actions[];
15
+ getFutureActions(story: Story): LogicAction.Actions[];
15
16
  }
@@ -6,6 +6,7 @@ import { Awaitable } from "../../../../util/data";
6
6
  import type { CalledActionResult } from "../../gameTypes";
7
7
  import { ContentNode } from "../../action/tree/actionTree";
8
8
  import { TypedAction } from "../../action/actions";
9
+ import { Story } from "../../elements/story";
9
10
  export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
10
11
  static ActionTypes: {
11
12
  readonly action: "control:action";
@@ -28,5 +29,5 @@ export declare class ControlAction<T extends typeof ControlActionTypes[keyof typ
28
29
  node: ContentNode<any> | null;
29
30
  } | Awaitable<CalledActionResult<any>, any> | Awaitable<any, any>;
30
31
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult>;
31
- getFutureActions(): LogicAction.Actions[];
32
+ getFutureActions(story: Story): LogicAction.Actions[];
32
33
  }
@@ -0,0 +1,15 @@
1
+ import { DisplayableActionContentType, DisplayableActionTypes } from "../../action/actionTypes";
2
+ import { GameState } from "../../../player/gameState";
3
+ import { TypedAction } from "../../action/actions";
4
+ import { Values } from "../../../../util/data";
5
+ import { Displayable } from "../../elements/displayable/displayable";
6
+ export declare class DisplayableAction<T extends Values<typeof DisplayableActionTypes> = Values<typeof DisplayableActionTypes>, Self extends Displayable<any, any> = Displayable<any, any>> extends TypedAction<DisplayableActionContentType, T, Self> {
7
+ static ActionTypes: {
8
+ readonly action: "displayable:action";
9
+ readonly layerMoveUp: "displayable:layerMoveUp";
10
+ readonly layerMoveDown: "displayable:layerMoveDown";
11
+ readonly layerMoveTop: "displayable:layerMoveTop";
12
+ readonly layerMoveBottom: "displayable:layerMoveBottom";
13
+ };
14
+ executeAction(gameState: GameState): import("../../gameTypes").CalledActionResult<any> | import("../../../../util/data").Awaitable<import("../../gameTypes").CalledActionResult<any>, any>;
15
+ }
@@ -1,5 +1,5 @@
1
1
  import { ImageActionContentType, ImageActionTypes } from "../../action/actionTypes";
2
- import { Image } from "../../elements/image";
2
+ import { Image } from "../../elements/displayable/image";
3
3
  import { GameState } from "../../../player/gameState";
4
4
  import type { CalledActionResult } from "../../gameTypes";
5
5
  import { Awaitable } from "../../../../util/data";
@@ -18,6 +18,7 @@ export declare class ImageAction<T extends typeof ImageActionTypes[keyof typeof
18
18
  readonly applyTransition: "image:applyTransition";
19
19
  readonly flush: "image:flush";
20
20
  readonly initWearable: "image:initWearable";
21
+ readonly setAppearance: "image:setAppearance";
21
22
  };
22
23
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
23
24
  }
@@ -4,10 +4,11 @@ import { GameState } from "../../../player/gameState";
4
4
  import { Awaitable } from "../../../../util/data";
5
5
  import type { CalledActionResult } from "../../gameTypes";
6
6
  import { TypedAction } from "../../action/actions";
7
+ import { Story } from "../../elements/story";
7
8
  export declare class MenuAction<T extends typeof MenuActionTypes[keyof typeof MenuActionTypes] = typeof MenuActionTypes[keyof typeof MenuActionTypes]> extends TypedAction<MenuActionContentType, T, Menu> {
8
9
  static ActionTypes: {
9
10
  readonly action: "menu:action";
10
11
  };
11
12
  executeAction(state: GameState): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
12
- getFutureActions(): import("../logicAction").LogicAction.Actions[];
13
+ getFutureActions(story: Story): import("../logicAction").LogicAction.Actions[];
13
14
  }
@@ -0,0 +1,12 @@
1
+ import { PersistentActionContentType, PersistentActionTypes } from "../../action/actionTypes";
2
+ import { GameState } from "../../../player/gameState";
3
+ import { TypedAction } from "../../action/actions";
4
+ import { Values } from "../../../../util/data";
5
+ import { Persistent } from "../../elements/persistent";
6
+ export declare class PersistentAction<T extends Values<typeof PersistentActionTypes> = Values<typeof PersistentActionTypes>> extends TypedAction<PersistentActionContentType, T, Persistent<any>> {
7
+ static ActionTypes: {
8
+ readonly action: "persistent:action";
9
+ readonly set: "persistent:set";
10
+ };
11
+ executeAction(gameState: GameState): import("../../gameTypes").CalledActionResult<any> | import("../../../../util/data").Awaitable<import("../../gameTypes").CalledActionResult<any>, any>;
12
+ }
@@ -5,12 +5,13 @@ import { Awaitable } from "../../../../util/data";
5
5
  import type { CalledActionResult } from "../../gameTypes";
6
6
  import { LogicAction } from "../../action/logicAction";
7
7
  import { TypedAction } from "../../action/actions";
8
+ import { ITransition } from "../../elements/transition/type";
9
+ import { Story } from "../../elements/story";
8
10
  export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof SceneActionTypes] = typeof SceneActionTypes[keyof typeof SceneActionTypes]> extends TypedAction<SceneActionContentType, T, Scene> {
9
11
  static ActionTypes: {
10
12
  readonly action: "scene:action";
11
13
  readonly setBackground: "scene:setBackground";
12
14
  readonly sleep: "scene:sleep";
13
- readonly setTransition: "scene:setTransition";
14
15
  readonly applyTransition: "scene:applyTransition";
15
16
  readonly init: "scene:init";
16
17
  readonly exit: "scene:exit";
@@ -18,12 +19,16 @@ export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof
18
19
  readonly setBackgroundMusic: "scene:setBackgroundMusic";
19
20
  readonly preUnmount: "scene:preUnmount";
20
21
  readonly applyTransform: "scene:applyTransform";
22
+ readonly transitionToScene: "scene:transitionToScene";
21
23
  };
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
+ static handleSceneInit(sceneAction: SceneAction<typeof SceneActionTypes["init"]>, state: GameState, awaitable: Awaitable<CalledActionResult, any>): Awaitable<CalledActionResult<any>, any> | {
25
+ type: "scene:init";
24
26
  node: import("../../action/tree/actionTree").RenderableNode | null;
25
27
  };
26
28
  static registerEventListeners(scene: Scene, state: GameState, onInit?: () => void): void;
29
+ applyTransition(state: GameState, transition: ITransition): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
27
30
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
28
- getFutureActions(): LogicAction.Actions[];
31
+ getFutureActions(story: Story): LogicAction.Actions[];
32
+ _sceneNotFoundError(sceneId: string): Error;
33
+ getSceneName(scene: Scene | string): string;
29
34
  }
@@ -3,7 +3,7 @@ import { TypedAction } from "../../action/actions";
3
3
  import { GameState } from "../../../player/gameState";
4
4
  import { CalledActionResult } from "../../gameTypes";
5
5
  import { Awaitable } from "../../../../util/data";
6
- import { Text } from "../../elements/text";
6
+ import { Text } from "../../elements/displayable/text";
7
7
  export declare class TextAction<T extends typeof TextActionTypes[keyof typeof TextActionTypes] = typeof TextActionTypes[keyof typeof TextActionTypes]> extends TypedAction<TextActionContentType, T, Text> {
8
8
  static ActionTypes: {
9
9
  readonly action: "text:action";
@@ -7,6 +7,7 @@ import { CalledActionResult } from "../gameTypes";
7
7
  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> {
8
8
  callee: Callee;
9
9
  constructor(callee: Proxied<Callee, Chained<LogicAction.Actions, Callee>>, type: T, contentNode: ContentNode<ContentType[T]>);
10
- unknownType(): void;
10
+ unknownTypeError(): void;
11
11
  resolveAwaitable<T extends CalledActionResult = any>(handler: (resolve: ((value: T) => void), awaitable: Awaitable<CalledActionResult, T>) => Promise<void> | void, awaitable?: Awaitable<CalledActionResult, T>): Awaitable<CalledActionResult, T>;
12
+ is<T extends LogicAction.Actions>(parent: new (...args: any[]) => T, type: string): this is T;
12
13
  }
@@ -1,7 +1,7 @@
1
1
  import type { Character } from "../elements/character";
2
2
  import type { Scene } from "../elements/scene";
3
3
  import type { Story } from "../elements/story";
4
- import type { Image } from "../elements/image";
4
+ import type { Image } from "../elements/displayable/image";
5
5
  import type { Condition } from "../elements/condition";
6
6
  import type { Script } from "../elements/script";
7
7
  import type { Menu } from "../elements/menu";
@@ -9,7 +9,7 @@ import { Values } from "../../../util/data";
9
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, TextActionContentType } from "../action/actionTypes";
12
+ import { CharacterActionContentType, CharacterActionTypes, ConditionActionContentType, ConditionActionTypes, ControlActionContentType, DisplayableActionContentType, DisplayableActionTypes, ImageActionContentType, ImageActionTypes, MenuActionContentType, MenuActionTypes, PersistentActionContentType, PersistentActionTypes, SceneActionContentType, SceneActionTypes, ScriptActionContentType, ScriptActionTypes, SoundActionContentType, StoryActionContentType, StoryActionTypes, TextActionContentType } from "../action/actionTypes";
13
13
  import { CharacterAction } from "../action/actions/characterAction";
14
14
  import { SceneAction } from "../action/actions/sceneAction";
15
15
  import { StoryAction } from "../action/actions/storyAction";
@@ -19,12 +19,16 @@ import { ScriptAction } from "../action/actions/scriptAction";
19
19
  import { MenuAction } from "../action/actions/menuAction";
20
20
  import { SoundAction } from "../action/actions/soundAction";
21
21
  import { ControlAction } from "../action/actions/controlAction";
22
- import { Text } from "../elements/text";
22
+ import { Text } from "../elements/displayable/text";
23
23
  import { TextAction } from "../action/actions/textAction";
24
+ import { Displayable as AbstractDisplayable } from "../elements/displayable/displayable";
25
+ import { DisplayableAction } from "../action/actions/displayableAction";
26
+ import { Persistent } from "../elements/persistent";
27
+ import { PersistentAction } from "../action/actions/persistentAction";
24
28
  export declare namespace LogicAction {
25
- type Displayable = Text | Image;
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;
29
+ type DisplayableElements = Text | Image | AbstractDisplayable<any, any>;
30
+ type GameElement = Character | Scene | Story | Image | Condition | Script | Menu | Sound | Control | Text | AbstractDisplayable<any, any> | Persistent<any>;
31
+ type Actions = TypedAction | CharacterAction | ConditionAction | ImageAction | SceneAction | ScriptAction | StoryAction | MenuAction | SoundAction | ControlAction | TextAction | DisplayableAction | PersistentAction;
32
+ 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> | Values<typeof DisplayableActionTypes> | Values<typeof PersistentActionTypes>;
33
+ type ActionContents = CharacterActionContentType & ConditionActionContentType & ImageActionContentType & SceneActionContentType & ScriptActionContentType & StoryActionContentType & MenuActionContentType & SoundActionContentType & ControlActionContentType & TextActionContentType & DisplayableActionContentType & PersistentActionContentType;
30
34
  }
@@ -1,6 +1,8 @@
1
1
  import { Sound } from "../elements/sound";
2
- import { Image } from "../elements/image";
2
+ import { Image } from "../elements/displayable/image";
3
+ import { Story } from "../common/core";
3
4
  import { StaticImageData } from "../types";
5
+ import { LogicAction } from "../action/logicAction";
4
6
  export type SrcType = "image" | "video" | "audio";
5
7
  export type Src = {
6
8
  type: "image";
@@ -12,10 +14,22 @@ export type Src = {
12
14
  type: "audio";
13
15
  src: Sound;
14
16
  };
17
+ export type ActiveSrc<T extends "scene" | "once" = "scene" | "once"> = Src & {
18
+ activeType: T;
19
+ };
15
20
  export declare class SrcManager {
16
21
  static SrcTypes: {
17
22
  [key in SrcType]: key;
18
23
  };
24
+ static catSrc(src: Src[]): {
25
+ image: Image[];
26
+ video: string[];
27
+ audio: Sound[];
28
+ };
29
+ static getSrc(src: Src | string | Image): string;
30
+ static getPreloadableSrc(story: Story, action: LogicAction.Actions): (Src & {
31
+ activeType: "scene" | "once";
32
+ }) | null;
19
33
  src: Src[];
20
34
  future: SrcManager[];
21
35
  register(src: Src): this;
@@ -28,4 +42,5 @@ export declare class SrcManager {
28
42
  getSrcByType(type: SrcType): Src[];
29
43
  registerFuture(srcManager: SrcManager): this;
30
44
  hasFuture(s: SrcManager): boolean;
45
+ getFutureSrc(): Src[];
31
46
  }
@@ -21,6 +21,7 @@ export type ContentNodeData = {
21
21
  data: any;
22
22
  };
23
23
  export declare class ContentNode<T = any> extends Node<T> {
24
+ static create<T>(content: T): ContentNode<T>;
24
25
  static forEachParent(node: RenderableNode, callback: (node: RenderableNode) => void): void;
25
26
  static forEachChild(node: RenderableNode, callback: (node: RenderableNode) => void): void;
26
27
  action: LogicAction.Actions | null;
@@ -1,6 +1,8 @@
1
1
  import type { Background, color, HexColor, ImageColor, ImageSrc, NextJSStaticImageData } from "../types";
2
2
  import type { Scene } from "../elements/scene";
3
- import type { Image } from "../elements/image";
3
+ import type { Image } from "../elements/displayable/image";
4
+ import { Action } from "../action/action";
5
+ import { Story } from "../elements/story";
4
6
  export declare class RGBColor {
5
7
  static isHexString(color: any): color is HexColor;
6
8
  static fromHex(hex: HexColor): RGBColor;
@@ -46,8 +48,16 @@ type ImageState = {
46
48
  export declare class StaticChecker {
47
49
  private readonly scene;
48
50
  constructor(target: Scene);
49
- run(): Map<Image, ImageState> | null;
51
+ run(story: Story): Map<Image<import("../elements/displayable/image").TagGroupDefinition | null>, ImageState> | null;
50
52
  private checkAction;
51
53
  private checkImage;
52
54
  }
55
+ export declare class RuntimeScriptError extends Error {
56
+ static toMessage(msg: string | string[], trace?: Action | Action[]): string;
57
+ static getActionTrace(action: Action): string;
58
+ constructor(message: string | string[], trace?: Action | Action[]);
59
+ }
60
+ export declare class RuntimeGameError extends Error {
61
+ constructor(message: string);
62
+ }
53
63
  export {};
@@ -1,7 +1,7 @@
1
1
  import { Character } from "../elements/character";
2
2
  import { Condition, Lambda } from "../elements/condition";
3
3
  import { Control } from "../elements/control";
4
- import { Image } from "../elements/image";
4
+ import { Image as ImageClass, RichImageUserConfig, TagDefinitions, TagGroupDefinition, TagSrcResolver } from "../elements/displayable/image";
5
5
  import { Menu } from "../elements/menu";
6
6
  import { Scene } from "../elements/scene";
7
7
  import { Script } from "../elements/script";
@@ -10,6 +10,18 @@ import { Story } from "../elements/story";
10
10
  import { Transform } from "../elements/transform/transform";
11
11
  import { Sentence } from "../elements/character/sentence";
12
12
  import { Word } from "../elements/character/word";
13
- import { Text } from "../elements/text";
13
+ import { Text } from "../elements/displayable/text";
14
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 };
15
+ import { StaticImageData } from "../types";
16
+ import { Persistent } from "../elements/persistent";
17
+ interface ImageConstructor {
18
+ new <T extends TagGroupDefinition | null>(config: Omit<Partial<RichImageUserConfig<T>>, "src"> & (T extends null ? {
19
+ src: string | StaticImageData;
20
+ tag?: never;
21
+ } : T extends TagGroupDefinition ? {
22
+ src: TagSrcResolver<T>;
23
+ tag: TagDefinitions<T>;
24
+ } : never)): ImageClass<T>;
25
+ }
26
+ declare const Image: ImageConstructor;
27
+ export { Character, Condition, Control, Image, Lambda, Menu, Scene, Script, Sentence, Sound, SoundType, Story, Transform, Word, Text, Pause, Persistent, };
@@ -1,5 +1,5 @@
1
1
  import { Game } from "../game";
2
2
  import { GameState } from "../../player/gameState";
3
- import { Storable, Namespace } from "../store/storable";
3
+ import { Storable, Namespace } from "../elements/persistent/storable";
4
4
  import { LiveGame } from "../liveGame";
5
5
  export { LiveGame, GameState, Game, Storable, Namespace, };
@@ -1,2 +1,3 @@
1
1
  import { TransformDefinitions } from "../elements/transform/type";
2
+ export * from "../elements/type";
2
3
  export type { TransformDefinitions, };
@@ -8,6 +8,7 @@ export type SentenceConfig = {
8
8
  pause?: boolean | number;
9
9
  voice: Sound | null;
10
10
  character: Character | null;
11
+ voiceId: string | number | null;
11
12
  } & Color & Font;
12
13
  export type SentenceDataRaw = {
13
14
  state: SentenceState;
@@ -1,23 +1,8 @@
1
1
  import { LogicAction } from "../action/logicAction";
2
2
  import { Actionable } from "../action/actionable";
3
- import { GameState } from "../../player/gameState";
4
3
  import { Chained, ChainedActions, Proxied } from "../action/chain";
5
- import { ScriptCtx } from "../elements/script";
6
- export type ConditionConfig = {};
7
- interface LambdaCtx extends ScriptCtx {
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;
4
+ import { LambdaHandler } from "../elements/type";
5
+ export declare class Lambda<T = any> {
21
6
  }
22
7
  export type ConditionData = {
23
8
  If: {
@@ -32,19 +17,17 @@ export type ConditionData = {
32
17
  action: (LogicAction.Actions[]) | null;
33
18
  };
34
19
  };
35
- export declare class Condition extends Actionable {
36
- constructor(config?: ConditionConfig);
20
+ export declare class Condition<Closed extends true | false = false> extends Actionable {
37
21
  /**
38
22
  * @chainable
39
23
  */
40
- If(condition: Lambda | LambdaHandler<boolean>, action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
24
+ static If(condition: Lambda | LambdaHandler<boolean>, action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
41
25
  /**
42
26
  * @chainable
43
27
  */
44
- ElseIf(condition: Lambda | LambdaHandler<boolean>, action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
28
+ ElseIf(condition: Closed extends false ? (Lambda | LambdaHandler<boolean>) : never, action: Closed extends false ? ChainedActions : never): Closed extends false ? Proxied<Condition, Chained<LogicAction.Actions>> : never;
45
29
  /**
46
30
  * @chainable
47
31
  */
48
- Else(action: ChainedActions): Proxied<Condition, Chained<LogicAction.Actions>>;
32
+ Else(action: Closed extends false ? ChainedActions : never): Closed extends false ? Proxied<Condition<true>, Chained<LogicAction.Actions>> : never;
49
33
  }
50
- export {};
@@ -0,0 +1,38 @@
1
+ import { Actionable } from "../../action/actionable";
2
+ import { EventfulDisplayable } from "../../types";
3
+ import { Transform } from "../../elements/transform/transform";
4
+ import { Values } from "../../../../util/data";
5
+ import { ITransition } from "../../elements/transition/type";
6
+ import { DisplayableAction } from "../../action/actions/displayableAction";
7
+ import { DisplayableActionTypes } from "../../action/actionTypes";
8
+ import { Chained, Proxied } from "../../action/chain";
9
+ import { LogicAction } from "../../action/logicAction";
10
+ export type DisplayableEventTypes = {
11
+ "event:displayable.applyTransition": [ITransition];
12
+ "event:displayable.applyTransform": [Transform];
13
+ "event:displayable.init": [];
14
+ };
15
+ export declare abstract class Displayable<StateData extends Record<string, any>, Self extends Actionable> extends Actionable<StateData, Self> implements EventfulDisplayable {
16
+ abstract toDisplayableTransform(): Transform;
17
+ /**
18
+ * Move the layer up
19
+ * @chainable
20
+ */
21
+ layerMoveUp(): Proxied<Self, Chained<LogicAction.Actions>>;
22
+ /**
23
+ * Move the layer down
24
+ * @chainable
25
+ */
26
+ layerMoveDown(): Proxied<Self, Chained<LogicAction.Actions>>;
27
+ /**
28
+ * Move the layer to the top
29
+ * @chainable
30
+ */
31
+ layerMoveTop(): Proxied<Self, Chained<LogicAction.Actions>>;
32
+ /**
33
+ * Move the layer to the bottom
34
+ * @chainable
35
+ */
36
+ layerMoveBottom(): Proxied<Self, Chained<LogicAction.Actions>>;
37
+ protected constructLayerAction<T extends Values<typeof DisplayableActionTypes>>(chain: Proxied<Self, Chained<LogicAction.Actions>>, type: T): DisplayableAction;
38
+ }