narraleaf-react 0.2.4-beta.4 → 0.3.0-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 (83) hide show
  1. package/README.md +97 -12
  2. package/dist/game/nlcore/action/action.d.ts +2 -1
  3. package/dist/game/nlcore/action/actionTypes.d.ts +25 -42
  4. package/dist/game/nlcore/action/actions/conditionAction.d.ts +2 -1
  5. package/dist/game/nlcore/action/actions/controlAction.d.ts +2 -1
  6. package/dist/game/nlcore/action/actions/displayableAction.d.ts +14 -7
  7. package/dist/game/nlcore/action/actions/imageAction.d.ts +3 -8
  8. package/dist/game/nlcore/action/actions/layerAction.d.ts +12 -0
  9. package/dist/game/nlcore/action/actions/menuAction.d.ts +3 -1
  10. package/dist/game/nlcore/action/actions/sceneAction.d.ts +6 -7
  11. package/dist/game/nlcore/action/actions/soundAction.d.ts +0 -2
  12. package/dist/game/nlcore/action/actions/textAction.d.ts +0 -5
  13. package/dist/game/nlcore/action/logicAction.d.ts +13 -7
  14. package/dist/game/nlcore/action/serviceAction.d.ts +11 -0
  15. package/dist/game/nlcore/action/srcManager.d.ts +5 -4
  16. package/dist/game/nlcore/common/Utils.d.ts +14 -2
  17. package/dist/game/nlcore/common/core.d.ts +2 -2
  18. package/dist/game/nlcore/common/elements.d.ts +5 -15
  19. package/dist/game/nlcore/common/player.d.ts +2 -1
  20. package/dist/game/nlcore/common/transition.d.ts +6 -7
  21. package/dist/game/nlcore/common/types.d.ts +3 -1
  22. package/dist/game/nlcore/elements/character/sentence.d.ts +9 -0
  23. package/dist/game/nlcore/elements/character/word.d.ts +6 -5
  24. package/dist/game/nlcore/elements/character.d.ts +3 -1
  25. package/dist/game/nlcore/elements/control.d.ts +1 -1
  26. package/dist/game/nlcore/elements/displayable/displayable.d.ts +76 -1
  27. package/dist/game/nlcore/elements/displayable/image.d.ts +58 -95
  28. package/dist/game/nlcore/elements/displayable/text.d.ts +44 -40
  29. package/dist/game/nlcore/elements/layer.d.ts +23 -0
  30. package/dist/game/nlcore/elements/scene.d.ts +40 -48
  31. package/dist/game/nlcore/elements/service.d.ts +59 -0
  32. package/dist/game/nlcore/elements/sound.d.ts +37 -30
  33. package/dist/game/nlcore/elements/story.d.ts +21 -2
  34. package/dist/game/nlcore/elements/transform/position.d.ts +19 -0
  35. package/dist/game/nlcore/elements/transform/transform.d.ts +18 -32
  36. package/dist/game/nlcore/elements/transform/type.d.ts +12 -15
  37. package/dist/game/nlcore/elements/transition/transition.d.ts +29 -0
  38. package/dist/game/nlcore/elements/transition/transitions/image/dissolve.d.ts +17 -0
  39. package/dist/game/nlcore/elements/transition/transitions/image/fadeIn.d.ts +20 -0
  40. package/dist/game/nlcore/elements/transition/transitions/image/imageTransition.d.ts +28 -0
  41. package/dist/game/nlcore/elements/transition/transitions/text/fontSize.d.ts +13 -0
  42. package/dist/game/nlcore/elements/transition/transitions/text/textTransition.d.ts +10 -0
  43. package/dist/game/nlcore/elements/transition/type.d.ts +33 -9
  44. package/dist/game/nlcore/elements/type.d.ts +10 -0
  45. package/dist/game/nlcore/game/liveGame.d.ts +47 -1
  46. package/dist/game/nlcore/game.d.ts +4 -0
  47. package/dist/game/nlcore/gameTypes.d.ts +90 -15
  48. package/dist/game/nlcore/types.d.ts +28 -30
  49. package/dist/game/player/elements/Player.d.ts +2 -2
  50. package/dist/game/player/elements/image/Image.d.ts +3 -1
  51. package/dist/game/player/elements/player/Layer.d.ts +8 -0
  52. package/dist/game/player/elements/type.d.ts +2 -0
  53. package/dist/game/player/gameState.d.ts +58 -46
  54. package/dist/game/player/guard.d.ts +23 -0
  55. package/dist/game/player/lib/AspectRatio.d.ts +3 -1
  56. package/dist/game/player/lib/AudioManager.d.ts +42 -0
  57. package/dist/game/player/lib/ImageCacheManager.d.ts +4 -2
  58. package/dist/game/player/lib/Inspect.d.ts +2 -1
  59. package/dist/game/player/lib/PageRouter/Page.d.ts +9 -0
  60. package/dist/game/player/lib/PageRouter/PageRouter.d.ts +29 -0
  61. package/dist/game/player/lib/PageRouter/Stage.d.ts +6 -0
  62. package/dist/game/player/lib/PageRouter/router.d.ts +10 -0
  63. package/dist/game/player/lib/PlayerFrames.d.ts +4 -23
  64. package/dist/game/player/lib/Preloaded.d.ts +2 -1
  65. package/dist/game/player/lib/flush.d.ts +5 -0
  66. package/dist/game/player/lib/useExposeState.d.ts +3 -0
  67. package/dist/game/player/libElements.d.ts +3 -3
  68. package/dist/game/player/provider/game-state.d.ts +1 -0
  69. package/dist/game/player/type.d.ts +45 -0
  70. package/dist/main.js +13 -35696
  71. package/dist/util/config.d.ts +30 -0
  72. package/dist/util/data.d.ts +72 -16
  73. package/dist/util/logger.d.ts +3 -0
  74. package/package.json +4 -3
  75. package/dist/game/nlcore/elements/transition/baseTransitions.d.ts +0 -28
  76. package/dist/game/nlcore/elements/transition/imageTransitions/dissolve.d.ts +0 -25
  77. package/dist/game/nlcore/elements/transition/imageTransitions/fade.d.ts +0 -19
  78. package/dist/game/nlcore/elements/transition/imageTransitions/fadeIn.d.ts +0 -27
  79. package/dist/game/nlcore/elements/transition/textTransitions/fontSizeTransition.d.ts +0 -15
  80. package/dist/game/player/elements/scene/Background.d.ts +0 -1
  81. package/dist/game/player/elements/scene/BackgroundTransition.d.ts +0 -1
  82. package/dist/game/player/lib/UtilComponents.d.ts +0 -5
  83. package/dist/main.js.map +0 -1
package/README.md CHANGED
@@ -19,29 +19,114 @@ It doesn't use any rendering libraries and can be used on any web platform (e.g.
19
19
  - **Customizable**: You can customize the UI as you like, even replace the whole components.
20
20
  - **Easy to use**: It is easy to use and has a simple API that is built for developers. Based on OOP principles.
21
21
 
22
- ## Get Started
22
+ ### Scripting
23
23
 
24
- ### Install
24
+ NarraLeaf-React uses TypeScript for all scripting, so you don't have to learn a whole new language to use it.
25
25
 
26
- ```bash
27
- npm install narraleaf-react
26
+ It also has a highly abstracted and easy-to-use API, for example:
27
+
28
+ ```typescript
29
+ import {Character, Menu, Scene, Word} from "narraleaf-react";
28
30
  ```
29
31
 
30
- ### Documentation
32
+ ```typescript
33
+ const scene1 = new Scene("scene1_hello_world", {
34
+ background: "/background/scene1_hello_world.jpg",
35
+ });
36
+
37
+ const johnSmith = new Character("John Smith");
38
+ const johnDoe = new Character("John Doe");
39
+
40
+ scene1.action([
41
+ /**
42
+ * John Smith: Hello, world!
43
+ * John Smith: This is my first NarraLeaf story.
44
+ * John Smith: Start editing src/story.js and enjoy the journey!
45
+ */
46
+ johnSmith
47
+ .say("Hello, world!")
48
+ .say("This is my first NarraLeaf story.")
49
+ .say`Start editing ${Word.color("src/story.js", "#0000ff")} and enjoy the journey!`,
50
+
51
+ /**
52
+ * John Doe: Also, don't forget to check out the documentation!
53
+ */
54
+ johnDoe.say("Also, don't forget to check out the documentation!"),
55
+
56
+ /**
57
+ * Menu: Start the journey
58
+ * > Yes I will!
59
+ * - John Smith: Great! Let's start the journey!
60
+ * - John Smith: You can open issues on GitHub if you have any questions.
61
+ * > No, I'm going to check the documentation
62
+ * - John Smith: Sure! Take your time!
63
+ */
64
+ new Menu("Start the journey")
65
+ .choose("Yes I will!", [
66
+ johnSmith
67
+ .say("Great! Let's start the journey!")
68
+ .say("You can open issues on GitHub if you have any questions.")
69
+ ])
70
+ .choose("No, I'm going to check the documentation", [
71
+ johnSmith.say("Sure! Take your time!")
72
+ ])
73
+ ]);
74
+ ```
31
75
 
32
- Read more in [🛠React.NarraLeaf.com](https://react.narraleaf.com)
76
+ For more information, please visit [🛠React.NarraLeaf.com](https://react.narraleaf.com)
33
77
 
34
- ### Example
78
+ ## Get Started
79
+
80
+ ### Install
35
81
 
36
82
  ```bash
37
- npx create-react-app nlr-app --template my-first-narraleaf-app
83
+ npm install narraleaf-react
38
84
  ```
39
85
 
40
- to start
86
+ ### Documentation
87
+
88
+ - [Introduction](https://react.narraleaf.com/documentation/introduction)
89
+ - [Quick Start](https://react.narraleaf.com/documentation/quick-start)
90
+ - [Installation](https://react.narraleaf.com/documentation/installation)
91
+ - [Basic](https://react.narraleaf.com/documentation/basic)
92
+ - [Create a Scene](https://react.narraleaf.com/documentation/basic/create-scene)
93
+ - [Add Actions](https://react.narraleaf.com/documentation/basic/add-actions)
94
+ - [Show Dialog](https://react.narraleaf.com/documentation/basic/show-dialog)
95
+ - [Show Image](https://react.narraleaf.com/documentation/basic/show-image)
96
+ - [Play Story](https://react.narraleaf.com/documentation/basic/play-story)
97
+ - [Make Choices](https://react.narraleaf.com/documentation/basic/make-choices)
98
+ - [Play Sound](https://react.narraleaf.com/documentation/basic/sound)
99
+ - [Store Data](https://react.narraleaf.com/documentation/basic/store-data)
100
+ - [Conditional](https://react.narraleaf.com/documentation/basic/conditional)
101
+ - [Voice](https://react.narraleaf.com/documentation/basic/voice)
102
+ - [Manage Preferences](https://react.narraleaf.com/documentation/basic/manage-preferences)
103
+ - [Core](https://react.narraleaf.com/documentation/core)
104
+ - [Elements](https://react.narraleaf.com/documentation/core/elements)
105
+ - [Scene](https://react.narraleaf.com/documentation/core/elements/scene)
106
+ - [Character](https://react.narraleaf.com/documentation/core/elements/character)
107
+ - [Sentence](https://react.narraleaf.com/documentation/core/elements/character/sentence)
108
+ - [Word](https://react.narraleaf.com/documentation/core/elements/character/word)
109
+ - [Pause](https://react.narraleaf.com/documentation/core/elements/character/pause)
110
+ - [Image](https://react.narraleaf.com/documentation/core/elements/image)
111
+ - [Sound](https://react.narraleaf.com/documentation/core/elements/sound)
112
+ - [Menu](https://react.narraleaf.com/documentation/core/elements/menu)
113
+ - [Script](https://react.narraleaf.com/documentation/core/elements/script)
114
+ - [Condition](https://react.narraleaf.com/documentation/core/elements/condition)
115
+ - [Control](https://react.narraleaf.com/documentation/core/elements/control)
116
+ - [Text](https://react.narraleaf.com/documentation/core/elements/text)
117
+ - [Persistent](https://react.narraleaf.com/documentation/core/elements/persistent)
118
+ - [Story](https://react.narraleaf.com/documentation/core/elements/story)
119
+ - [Animation](https://react.narraleaf.com/documentation/core/animation)
120
+ - [Game](https://react.narraleaf.com/documentation/core/game)
121
+ - [Player](https://react.narraleaf.com/documentation/player)
122
+ - [Customization](https://react.narraleaf.com/documentation/custom)
123
+ - [Migration](https://react.narraleaf.com/documentation/migration)
124
+ - [From Ren'Py](https://react.narraleaf.com/documentation/migration/from-renpy)
125
+ - Info
126
+ - [License](https://react.narraleaf.com/documentation/info/license)
127
+ - [Incompatible Changes](https://react.narraleaf.com/documentation/info/incompatible-changes)
41
128
 
42
- ```bash
43
- npm start
44
- ```
129
+ Read more in [🛠React.NarraLeaf.com](https://react.narraleaf.com)
45
130
 
46
131
  ## License
47
132
 
@@ -4,6 +4,7 @@ import type { CalledActionResult } from "../gameTypes";
4
4
  import { Awaitable } from "../../../util/data";
5
5
  import { GameState } from "../../player/gameState";
6
6
  import { Story } from "../elements/story";
7
+ import { ActionSearchOptions } from "../types";
7
8
  export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElement, Type extends string = any> {
8
9
  static ActionTypes: {
9
10
  action: string;
@@ -19,5 +20,5 @@ export declare class Action<ContentNodeType = any, Callee = LogicAction.GameElem
19
20
  setId(id: string): void;
20
21
  setContent(content: ContentNodeType): this;
21
22
  setContentNode(contentNode: ContentNode<ContentNodeType>): this;
22
- getFutureActions(_story: Story): LogicAction.Actions[];
23
+ getFutureActions(_story: Story, _options: ActionSearchOptions): LogicAction.Actions[];
23
24
  }
@@ -1,17 +1,30 @@
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 { CommonDisplayable, ImageColor, ImageSrc } from "../types";
4
+ import { Color, 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
8
  import { Awaitable, FlexibleTuple, SelectElementFromEach } from "../../../util/data";
9
- import { IImageTransition, ITransition } from "../elements/transition/type";
9
+ import { 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
14
  import { Image, TagGroupDefinition } from "../elements/displayable/image";
15
+ import { FadeOptions } from "../elements/type";
16
+ import { Transition } from "../elements/transition/transition";
17
+ import { ImageTransition } from "../elements/transition/transitions/image/imageTransition";
18
+ import { Layer } from "../elements/layer";
19
+ export declare const DisplayableActionTypes: {
20
+ readonly action: "displayable:action";
21
+ readonly applyTransform: "displayable:applyTransform";
22
+ readonly applyTransition: "displayable:applyTransition";
23
+ readonly init: "displayable:init";
24
+ };
25
+ export type DisplayableActionContentType<TransitionType extends Transition = Transition> = {
26
+ [K in typeof DisplayableActionTypes[keyof typeof DisplayableActionTypes]]: K extends "displayable:applyTransform" ? [Transform] : K extends "displayable:applyTransition" ? [TransitionType, ((transition: TransitionType) => TransitionType)?] : K extends "displayable:init" ? [scene: Scene | null, layer: Layer | null, isElement?: boolean] : any;
27
+ };
15
28
  export declare const CharacterActionTypes: {
16
29
  readonly say: "character:say";
17
30
  readonly action: "character:action";
@@ -22,19 +35,16 @@ export type CharacterActionContentType = {
22
35
  };
23
36
  export declare const SceneActionTypes: {
24
37
  readonly action: "scene:action";
25
- readonly setBackground: "scene:setBackground";
26
38
  readonly sleep: "scene:sleep";
27
- readonly applyTransition: "scene:applyTransition";
28
39
  readonly init: "scene:init";
29
40
  readonly exit: "scene:exit";
30
41
  readonly jumpTo: "scene:jumpTo";
31
42
  readonly setBackgroundMusic: "scene:setBackgroundMusic";
32
43
  readonly preUnmount: "scene:preUnmount";
33
- readonly applyTransform: "scene:applyTransform";
34
44
  readonly transitionToScene: "scene:transitionToScene";
35
45
  };
36
46
  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["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;
47
+ [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["init"] ? [Scene] : K extends typeof SceneActionTypes["exit"] ? [] : K extends typeof SceneActionTypes["jumpTo"] ? [Scene] : K extends typeof SceneActionTypes["setBackgroundMusic"] ? [Sound | null, number?] : K extends typeof SceneActionTypes["preUnmount"] ? [] : K extends typeof SceneActionTypes["transitionToScene"] ? [ImageTransition, Scene | undefined, ImageSrc | Color | undefined] : any;
38
48
  };
39
49
  export declare const StoryActionTypes: {
40
50
  readonly action: "story:action";
@@ -45,24 +55,13 @@ export type StoryActionContentType = {
45
55
  export declare const ImageActionTypes: {
46
56
  readonly action: "image:action";
47
57
  readonly setSrc: "image:setSrc";
48
- readonly setPosition: "image:setPosition";
49
- readonly show: "image:show";
50
- readonly hide: "image:hide";
51
- readonly applyTransform: "image:applyTransform";
52
- readonly init: "image:init";
53
- readonly dispose: "image:dispose";
54
- /**
55
- * @deprecated
56
- */
57
- readonly setTransition: "image:setTransition";
58
- readonly applyTransition: "image:applyTransition";
59
58
  readonly flush: "image:flush";
60
59
  readonly initWearable: "image:initWearable";
61
60
  readonly setAppearance: "image:setAppearance";
62
61
  };
63
62
  export type ImageActionContentType = {
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;
65
- };
63
+ [K in typeof ImageActionTypes[keyof typeof ImageActionTypes]]: K extends "image:setSrc" ? [ImageSrc | Color] : K extends "image:flush" ? [] : K extends "image:initWearable" ? [Image] : K extends "image:setAppearance" ? [FlexibleTuple<SelectElementFromEach<TagGroupDefinition>> | string[], ImageTransition | undefined] : any;
64
+ } & DisplayableActionContentType<ImageTransition>;
66
65
  export declare const ConditionActionTypes: {
67
66
  readonly action: "condition:action";
68
67
  };
@@ -85,20 +84,13 @@ export declare const SoundActionTypes: {
85
84
  readonly action: "sound:action";
86
85
  readonly play: "sound:play";
87
86
  readonly stop: "sound:stop";
88
- readonly fade: "sound:fade";
89
87
  readonly setVolume: "sound:setVolume";
90
88
  readonly setRate: "sound:setRate";
91
89
  readonly pause: "sound:pause";
92
90
  readonly resume: "sound:resume";
93
91
  };
94
92
  export type SoundActionContentType = {
95
- [K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [void] : K extends "sound:stop" ? [void] : K extends "sound:fade" ? [
96
- {
97
- start?: number;
98
- end: number;
99
- duration: number;
100
- }
101
- ] : K extends "sound:setVolume" ? [number] : K extends "sound:setRate" ? [number] : K extends "sound:pause" ? [void] : K extends "sound:resume" ? [void] : any;
93
+ [K in typeof SoundActionTypes[keyof typeof SoundActionTypes]]: K extends "sound:play" ? [FadeOptions] : K extends "sound:stop" ? [FadeOptions] : K extends "sound:setVolume" ? [volumn: number, duration: number] : K extends "sound:setRate" ? [number] : K extends "sound:pause" ? [FadeOptions] : K extends "sound:resume" ? [FadeOptions] : any;
102
94
  };
103
95
  export declare const ControlActionTypes: {
104
96
  readonly action: "control:action";
@@ -116,26 +108,11 @@ export type ControlActionContentType = {
116
108
  export declare const TextActionTypes: {
117
109
  readonly action: "text:action";
118
110
  readonly setText: "text:setText";
119
- readonly show: "text:show";
120
- readonly hide: "text:hide";
121
- readonly applyTransform: "text:applyTransform";
122
- readonly init: "text:init";
123
- readonly applyTransition: "text:applyTransition";
124
111
  readonly setFontSize: "text:setFontSize";
125
112
  };
126
113
  export type TextActionContentType = {
127
114
  [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;
128
115
  };
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
116
  export declare const PersistentActionTypes: {
140
117
  readonly action: "persistent:action";
141
118
  readonly set: "persistent:set";
@@ -143,3 +120,9 @@ export declare const PersistentActionTypes: {
143
120
  export type PersistentActionContentType = {
144
121
  [K in typeof PersistentActionTypes[keyof typeof PersistentActionTypes]]: K extends "persistent:action" ? any : K extends "persistent:set" ? [string, unknown | ((value: unknown) => unknown)] : any;
145
122
  };
123
+ export declare const LayerActionTypes: {
124
+ readonly action: "layer:action";
125
+ };
126
+ export type LayerActionContentType = {
127
+ [K in typeof LayerActionTypes[keyof typeof LayerActionTypes]]: K extends "layer:action" ? any : any;
128
+ };
@@ -4,6 +4,7 @@ import { GameState } from "../../../player/gameState";
4
4
  import { LogicAction } from "../../action/logicAction";
5
5
  import { TypedAction } from "../../action/actions";
6
6
  import { Story } from "../../elements/story";
7
+ import { ActionSearchOptions } from "../../types";
7
8
  export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof typeof ConditionActionTypes] = typeof ConditionActionTypes[keyof typeof ConditionActionTypes]> extends TypedAction<ConditionActionContentType, T, Condition> {
8
9
  static ActionTypes: {
9
10
  readonly action: "condition:action";
@@ -12,5 +13,5 @@ export declare class ConditionAction<T extends typeof ConditionActionTypes[keyof
12
13
  type: any;
13
14
  node: import("../tree/actionTree").RenderableNode | null;
14
15
  };
15
- getFutureActions(story: Story): LogicAction.Actions[];
16
+ getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
16
17
  }
@@ -7,6 +7,7 @@ import type { CalledActionResult } from "../../gameTypes";
7
7
  import { ContentNode } from "../../action/tree/actionTree";
8
8
  import { TypedAction } from "../../action/actions";
9
9
  import { Story } from "../../elements/story";
10
+ import { ActionSearchOptions } from "../../types";
10
11
  export declare class ControlAction<T extends typeof ControlActionTypes[keyof typeof ControlActionTypes] = typeof ControlActionTypes[keyof typeof ControlActionTypes]> extends TypedAction<ControlActionContentType, T, Control> {
11
12
  static ActionTypes: {
12
13
  readonly action: "control:action";
@@ -29,5 +30,5 @@ export declare class ControlAction<T extends typeof ControlActionTypes[keyof typ
29
30
  node: ContentNode<any> | null;
30
31
  } | Awaitable<CalledActionResult<any>, any> | Awaitable<any, any>;
31
32
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, CalledActionResult>;
32
- getFutureActions(story: Story): LogicAction.Actions[];
33
+ getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
33
34
  }
@@ -1,15 +1,22 @@
1
1
  import { DisplayableActionContentType, DisplayableActionTypes } from "../../action/actionTypes";
2
2
  import { GameState } from "../../../player/gameState";
3
3
  import { TypedAction } from "../../action/actions";
4
- import { Values } from "../../../../util/data";
4
+ import { Awaitable, Values } from "../../../../util/data";
5
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> {
6
+ import type { CalledActionResult } from "../../gameTypes";
7
+ import { Scene } from "../../elements/scene";
8
+ import { Transform } from "../../elements/transform/transform";
9
+ import { Transition } from "../../elements/transition/transition";
10
+ import { Layer } from "../../elements/layer";
11
+ export declare class DisplayableAction<T extends Values<typeof DisplayableActionTypes> = Values<typeof DisplayableActionTypes>, Self extends Displayable<any, any, any> = Displayable<any, any>, TransitionType extends Transition = Transition> extends TypedAction<DisplayableActionContentType<TransitionType>, T, Self> {
7
12
  static ActionTypes: {
8
13
  readonly action: "displayable:action";
9
- readonly layerMoveUp: "displayable:layerMoveUp";
10
- readonly layerMoveDown: "displayable:layerMoveDown";
11
- readonly layerMoveTop: "displayable:layerMoveTop";
12
- readonly layerMoveBottom: "displayable:layerMoveBottom";
14
+ readonly applyTransform: "displayable:applyTransform";
15
+ readonly applyTransition: "displayable:applyTransition";
16
+ readonly init: "displayable:init";
13
17
  };
14
- executeAction(gameState: GameState): import("../../gameTypes").CalledActionResult<any> | import("../../../../util/data").Awaitable<import("../../gameTypes").CalledActionResult<any>, any>;
18
+ executeAction(gameState: GameState): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
19
+ applyTransform(state: GameState, element: Displayable<any, any>, transform: Transform, onFinished?: () => void): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
20
+ applyTransition(state: GameState, element: Displayable<any, any>, transition: TransitionType, onFinished?: () => void): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
21
+ initDisplayable(state: GameState, scene: Scene | null, element: Displayable<any, any>, layer: Layer | null, isElement?: boolean | undefined): Awaitable<CalledActionResult>;
15
22
  }
@@ -5,22 +5,17 @@ import type { CalledActionResult } from "../../gameTypes";
5
5
  import { Awaitable } from "../../../../util/data";
6
6
  import { ContentNode } from "../../action/tree/actionTree";
7
7
  import { TypedAction } from "../../action/actions";
8
+ import { Color } from "../../types";
8
9
  export declare class ImageAction<T extends typeof ImageActionTypes[keyof typeof ImageActionTypes] = typeof ImageActionTypes[keyof typeof ImageActionTypes]> extends TypedAction<ImageActionContentType, T, Image> {
9
10
  static ActionTypes: {
10
11
  readonly action: "image:action";
11
12
  readonly setSrc: "image:setSrc";
12
- readonly setPosition: "image:setPosition";
13
- readonly show: "image:show";
14
- readonly hide: "image:hide";
15
- readonly applyTransform: "image:applyTransform";
16
- readonly init: "image:init";
17
- readonly dispose: "image:dispose";
18
- readonly setTransition: "image:setTransition";
19
- readonly applyTransition: "image:applyTransition";
20
13
  readonly flush: "image:flush";
21
14
  readonly initWearable: "image:initWearable";
22
15
  readonly setAppearance: "image:setAppearance";
23
16
  };
17
+ static resolveTagSrc(image: Image, tags: string[]): string;
18
+ static resolveCurrentSrc(image: Image): string | Color;
24
19
  type: T;
25
20
  contentNode: ContentNode<ImageActionContentType[T]>;
26
21
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
@@ -0,0 +1,12 @@
1
+ import { LayerActionContentType, LayerActionTypes } from "../../action/actionTypes";
2
+ import { TypedAction } from "../../action/actions";
3
+ import { GameState } from "../../../player/gameState";
4
+ import { CalledActionResult } from "../../gameTypes";
5
+ import { Awaitable, Values } from "../../../../util/data";
6
+ import { Layer } from "../../elements/layer";
7
+ export declare class LayerAction<T extends Values<typeof LayerActionTypes> = Values<typeof LayerActionTypes>> extends TypedAction<LayerActionContentType, T, Layer> {
8
+ static ActionTypes: {
9
+ readonly action: "layer:action";
10
+ };
11
+ executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
12
+ }
@@ -5,10 +5,12 @@ import { Awaitable } from "../../../../util/data";
5
5
  import type { CalledActionResult } from "../../gameTypes";
6
6
  import { TypedAction } from "../../action/actions";
7
7
  import { Story } from "../../elements/story";
8
+ import { LogicAction } from "../../action/logicAction";
9
+ import { ActionSearchOptions } from "../../types";
8
10
  export declare class MenuAction<T extends typeof MenuActionTypes[keyof typeof MenuActionTypes] = typeof MenuActionTypes[keyof typeof MenuActionTypes]> extends TypedAction<MenuActionContentType, T, Menu> {
9
11
  static ActionTypes: {
10
12
  readonly action: "menu:action";
11
13
  };
12
14
  executeAction(state: GameState): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
13
- getFutureActions(story: Story): import("../logicAction").LogicAction.Actions[];
15
+ getFutureActions(story: Story, options: ActionSearchOptions): LogicAction.Actions[];
14
16
  }
@@ -5,30 +5,29 @@ 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
8
  import { Story } from "../../elements/story";
9
+ import { ImageTransition } from "../../elements/transition/transitions/image/imageTransition";
10
+ import { ActionSearchOptions } from "../../types";
11
+ import { ExposedState, ExposedStateType } from "../../../player/type";
10
12
  export declare class SceneAction<T extends typeof SceneActionTypes[keyof typeof SceneActionTypes] = typeof SceneActionTypes[keyof typeof SceneActionTypes]> extends TypedAction<SceneActionContentType, T, Scene> {
11
13
  static ActionTypes: {
12
14
  readonly action: "scene:action";
13
- readonly setBackground: "scene:setBackground";
14
15
  readonly sleep: "scene:sleep";
15
- readonly applyTransition: "scene:applyTransition";
16
16
  readonly init: "scene:init";
17
17
  readonly exit: "scene:exit";
18
18
  readonly jumpTo: "scene:jumpTo";
19
19
  readonly setBackgroundMusic: "scene:setBackgroundMusic";
20
20
  readonly preUnmount: "scene:preUnmount";
21
- readonly applyTransform: "scene:applyTransform";
22
21
  readonly transitionToScene: "scene:transitionToScene";
23
22
  };
24
23
  static handleSceneInit(sceneAction: SceneAction<typeof SceneActionTypes["init"]>, state: GameState, awaitable: Awaitable<CalledActionResult, any>): Awaitable<CalledActionResult<any>, any> | {
25
24
  type: "scene:init";
26
25
  node: import("../../action/tree/actionTree").RenderableNode | null;
27
26
  };
28
- static registerEventListeners(scene: Scene, state: GameState, onInit?: () => void): void;
29
- applyTransition(state: GameState, transition: ITransition): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
27
+ static initBackgroundMusic(scene: Scene, exposed: ExposedState[ExposedStateType.scene]): void;
28
+ applyTransition(state: GameState, transition: ImageTransition): Awaitable<CalledActionResult<any>, CalledActionResult<any>>;
30
29
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
31
- getFutureActions(story: Story): LogicAction.Actions[];
30
+ getFutureActions(story: Story, searchOptions?: ActionSearchOptions): LogicAction.Actions[];
32
31
  _sceneNotFoundError(sceneId: string): Error;
33
32
  getSceneName(scene: Scene | string): string;
34
33
  }
@@ -9,12 +9,10 @@ export declare class SoundAction<T extends typeof SoundActionTypes[keyof typeof
9
9
  readonly action: "sound:action";
10
10
  readonly play: "sound:play";
11
11
  readonly stop: "sound:stop";
12
- readonly fade: "sound:fade";
13
12
  readonly setVolume: "sound:setVolume";
14
13
  readonly setRate: "sound:setRate";
15
14
  readonly pause: "sound:pause";
16
15
  readonly resume: "sound:resume";
17
16
  };
18
- static initSound(state: GameState, sound: Sound): void;
19
17
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
20
18
  }
@@ -8,11 +8,6 @@ export declare class TextAction<T extends typeof TextActionTypes[keyof typeof Te
8
8
  static ActionTypes: {
9
9
  readonly action: "text:action";
10
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
11
  readonly setFontSize: "text:setFontSize";
17
12
  };
18
13
  executeAction(state: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
@@ -5,11 +5,11 @@ 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";
8
- import { Values } from "../../../util/data";
8
+ import { StringKeyOf, 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, DisplayableActionContentType, DisplayableActionTypes, ImageActionContentType, ImageActionTypes, MenuActionContentType, MenuActionTypes, PersistentActionContentType, PersistentActionTypes, SceneActionContentType, SceneActionTypes, ScriptActionContentType, ScriptActionTypes, SoundActionContentType, StoryActionContentType, StoryActionTypes, TextActionContentType } from "../action/actionTypes";
12
+ import { CharacterActionContentType, CharacterActionTypes, ConditionActionContentType, ConditionActionTypes, ControlActionContentType, DisplayableActionContentType, DisplayableActionTypes, ImageActionContentType, ImageActionTypes, LayerActionContentType, LayerActionTypes, 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";
@@ -25,10 +25,16 @@ import { Displayable as AbstractDisplayable } from "../elements/displayable/disp
25
25
  import { DisplayableAction } from "../action/actions/displayableAction";
26
26
  import { Persistent } from "../elements/persistent";
27
27
  import { PersistentAction } from "../action/actions/persistentAction";
28
+ import { ServiceSkeleton } from "../elements/service";
29
+ import { ServiceAction, ServiceActionContentType } from "../action/serviceAction";
30
+ import { Layer } from "../elements/layer";
31
+ import { LayerAction } from "../action/actions/layerAction";
32
+ import { ExposedStateType } from "../../player/type";
28
33
  export declare namespace LogicAction {
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;
34
+ type DisplayableElements = Text | Image | Layer | AbstractDisplayable<any, any>;
35
+ type DisplayableExposed = ExposedStateType.image | ExposedStateType.layer | ExposedStateType.text;
36
+ type GameElement = Character | Scene | Story | Image | Condition | Script | Menu | Sound | Control | Text | AbstractDisplayable<any, any> | Persistent<any> | ServiceSkeleton;
37
+ type Actions = TypedAction | CharacterAction | ConditionAction | ImageAction | SceneAction | ScriptAction | StoryAction | MenuAction | SoundAction | ControlAction | TextAction | DisplayableAction | PersistentAction | ServiceAction | LayerAction;
38
+ 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> | StringKeyOf<ServiceActionContentType> | Values<typeof LayerActionTypes>;
39
+ type ActionContents = CharacterActionContentType & ConditionActionContentType & ImageActionContentType & SceneActionContentType & ScriptActionContentType & StoryActionContentType & MenuActionContentType & SoundActionContentType & ControlActionContentType & TextActionContentType & DisplayableActionContentType & PersistentActionContentType & ServiceActionContentType & LayerActionContentType;
34
40
  }
@@ -0,0 +1,11 @@
1
+ import { TypedAction } from "../action/actions";
2
+ import { Awaitable, StringKeyOf } from "../../../util/data";
3
+ import { ServiceSkeleton } from "../elements/service";
4
+ import { GameState } from "../../player/gameState";
5
+ import { CalledActionResult } from "../gameTypes";
6
+ export type ServiceActionContentType = {
7
+ "service:action": [type: string, args: unknown[]];
8
+ };
9
+ export declare class ServiceAction extends TypedAction<ServiceActionContentType, StringKeyOf<ServiceActionContentType>, ServiceSkeleton> {
10
+ executeAction(gameState: GameState): CalledActionResult | Awaitable<CalledActionResult, any>;
11
+ }
@@ -6,7 +6,7 @@ import { LogicAction } from "../action/logicAction";
6
6
  export type SrcType = "image" | "video" | "audio";
7
7
  export type Src = {
8
8
  type: "image";
9
- src: Image;
9
+ src: Image | string;
10
10
  } | {
11
11
  type: "video";
12
12
  src: string;
@@ -22,11 +22,11 @@ export declare class SrcManager {
22
22
  [key in SrcType]: key;
23
23
  };
24
24
  static catSrc(src: Src[]): {
25
- image: Image[];
25
+ image: (Image | string)[];
26
26
  video: string[];
27
27
  audio: Sound[];
28
28
  };
29
- static getSrc(src: Src | string | Image): string;
29
+ static getSrc(src: Src | string | Image): string | null;
30
30
  static getPreloadableSrc(story: Story, action: LogicAction.Actions): (Src & {
31
31
  activeType: "scene" | "once";
32
32
  }) | null;
@@ -37,7 +37,8 @@ export declare class SrcManager {
37
37
  register(src: Sound): this;
38
38
  register(src: Image | StaticImageData): this;
39
39
  register(type: SrcType, src: Src["src"]): this;
40
- isSrcRegistered(src: string | Sound | Image): boolean;
40
+ registerRawSrc(src: string): this;
41
+ isSrcRegistered(src: string | Sound | Image | null): boolean;
41
42
  getSrc(): Src[];
42
43
  getSrcByType(type: SrcType): Src[];
43
44
  registerFuture(srcManager: SrcManager): this;
@@ -1,4 +1,5 @@
1
- import type { HexColor, ImageColor } from "../types";
1
+ import type { Color, HexColor } from "../types";
2
+ import { Word } from "../elements/character/word";
2
3
  export declare class RGBColor {
3
4
  static isHexString(color: any): color is HexColor;
4
5
  static fromHex(hex: HexColor): RGBColor;
@@ -9,5 +10,16 @@ export declare class RGBColor {
9
10
  constructor(r: number, g: number, b: number, a?: number);
10
11
  toString(): string;
11
12
  toHex(): string;
12
- toImageColor(): ImageColor;
13
13
  }
14
+ /**
15
+ * Alias for {@link Word.color}
16
+ */
17
+ export declare function c(text: string | Word, color: Color): Word;
18
+ /**
19
+ * Alias for {@link Word.bold}
20
+ */
21
+ export declare function b(text: string | Word): Word;
22
+ /**
23
+ * Alias for {@link Word.italic}
24
+ */
25
+ export declare function i(text: string | Word): Word;
@@ -1,8 +1,8 @@
1
- import { Utils } from "./Utils";
1
+ import { i, c, b } from "./Utils";
2
2
  export * from "./elements";
3
3
  export * from "./game";
4
4
  export * from "./player";
5
5
  export * from "./types";
6
6
  export * from "./position";
7
7
  export * from "./transition";
8
- export { Utils };
8
+ export { i, c, b, };