narraleaf-react 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/game/nlcore/action/action.d.ts +3 -3
  2. package/dist/game/nlcore/action/actionTypes.d.ts +22 -6
  3. package/dist/game/nlcore/action/actions/characterAction.d.ts +14 -0
  4. package/dist/game/nlcore/action/actions/conditionAction.d.ts +15 -0
  5. package/dist/game/nlcore/action/actions/controlAction.d.ts +32 -0
  6. package/dist/game/nlcore/action/actions/imageAction.d.ts +22 -0
  7. package/dist/game/nlcore/action/actions/menuAction.d.ts +13 -0
  8. package/dist/game/nlcore/action/actions/sceneAction.d.ts +29 -0
  9. package/dist/game/nlcore/action/actions/scriptAction.d.ts +10 -0
  10. package/dist/game/nlcore/action/actions/soundAction.d.ts +20 -0
  11. package/dist/game/nlcore/action/actions/storyAction.d.ts +8 -0
  12. package/dist/game/nlcore/action/actions/textAction.d.ts +19 -0
  13. package/dist/game/nlcore/action/actions.d.ts +2 -127
  14. package/dist/game/nlcore/action/logicAction.d.ts +19 -7
  15. package/dist/game/nlcore/common/Utils.d.ts +21 -2
  16. package/dist/game/nlcore/common/elements.d.ts +6 -2
  17. package/dist/game/nlcore/common/transition.d.ts +7 -7
  18. package/dist/game/nlcore/elements/character/pause.d.ts +9 -0
  19. package/dist/game/nlcore/elements/character/sentence.d.ts +29 -0
  20. package/dist/game/nlcore/elements/character/word.d.ts +11 -0
  21. package/dist/game/nlcore/elements/character.d.ts +40 -0
  22. package/dist/game/nlcore/elements/condition.d.ts +0 -2
  23. package/dist/game/nlcore/elements/control.d.ts +11 -0
  24. package/dist/game/nlcore/elements/image.d.ts +11 -23
  25. package/dist/game/nlcore/elements/menu.d.ts +4 -8
  26. package/dist/game/nlcore/elements/scene.d.ts +24 -19
  27. package/dist/game/nlcore/elements/sound.d.ts +1 -1
  28. package/dist/game/nlcore/elements/story.d.ts +1 -1
  29. package/dist/game/nlcore/elements/text.d.ts +67 -55
  30. package/dist/game/nlcore/elements/transform/position.d.ts +3 -3
  31. package/dist/game/nlcore/elements/transform/transform.d.ts +8 -53
  32. package/dist/game/nlcore/elements/transform/type.d.ts +7 -8
  33. package/dist/game/nlcore/elements/transition/{base.d.ts → baseTransitions.d.ts} +10 -3
  34. package/dist/game/nlcore/elements/transition/imageTransitions/dissolve.d.ts +25 -0
  35. package/dist/game/nlcore/elements/transition/imageTransitions/fade.d.ts +19 -0
  36. package/dist/game/nlcore/elements/transition/imageTransitions/fadeIn.d.ts +27 -0
  37. package/dist/game/nlcore/elements/transition/textTransitions/fontSizeTransition.d.ts +15 -0
  38. package/dist/game/nlcore/elements/transition/type.d.ts +11 -6
  39. package/dist/game/nlcore/game.d.ts +3 -4
  40. package/dist/game/nlcore/gameTypes.d.ts +34 -9
  41. package/dist/game/nlcore/types.d.ts +22 -1
  42. package/dist/game/player/elements/displayable/Displayable.d.ts +23 -0
  43. package/dist/game/player/elements/displayable/Displayables.d.ts +7 -0
  44. package/dist/game/player/elements/displayable/Text.d.ts +7 -0
  45. package/dist/game/player/elements/displayable/type.d.ts +15 -0
  46. package/dist/game/player/elements/image/Image.d.ts +1 -2
  47. package/dist/game/player/elements/menu/type.d.ts +1 -1
  48. package/dist/game/player/elements/say/Sentence.d.ts +12 -0
  49. package/dist/game/player/elements/say/TypingEffect.d.ts +4 -0
  50. package/dist/game/player/elements/say/type.d.ts +2 -1
  51. package/dist/game/player/gameState.d.ts +26 -3
  52. package/dist/game/player/gameState.type.d.ts +2 -1
  53. package/dist/game/player/lib/Preloaded.d.ts +1 -1
  54. package/dist/game/player/libElements.d.ts +1 -2
  55. package/dist/main.js +2 -2
  56. package/dist/util/data.d.ts +23 -2
  57. package/package.json +3 -4
  58. package/dist/game/nlcore/elements/transition/dissolve.d.ts +0 -34
  59. package/dist/game/nlcore/elements/transition/fade.d.ts +0 -28
  60. package/dist/game/nlcore/elements/transition/fadeIn.d.ts +0 -35
  61. package/dist/game/player/elements/menu/Sentence.d.ts +0 -6
  62. /package/dist/game/nlcore/{elements → action}/srcManager.d.ts +0 -0
@@ -0,0 +1,40 @@
1
+ import { LogicAction } from "../game";
2
+ import { Color } from "../types";
3
+ import { DeepPartial } from "../../../util/data";
4
+ import { Actionable } from "../action/actionable";
5
+ import { Chained, Proxied } from "../action/chain";
6
+ import { Sentence, SentencePrompt, SentenceUserConfig } from "../elements/character/sentence";
7
+ export type CharacterConfig = {} & Color;
8
+ export type CharacterStateData = {
9
+ name: string;
10
+ };
11
+ export type CharacterState = {
12
+ name: string;
13
+ };
14
+ export declare class Character extends Actionable<CharacterStateData, Character> {
15
+ constructor(name: string | null, config?: DeepPartial<CharacterConfig>);
16
+ /**
17
+ * Say something
18
+ * @example
19
+ * ```typescript
20
+ * character.say("Hello, world!");
21
+ * ```
22
+ * @example
23
+ * ```typescript
24
+ * character
25
+ * .say("Hello, world!")
26
+ * .say("Hello, world!");
27
+ * ```
28
+ * @example
29
+ * ```typescript
30
+ * character.say(new Sentence(character, [
31
+ * "Hello, ",
32
+ * new Word("world", {color: "#f00"}), // Some words can be colored
33
+ * ]));
34
+ * @chainable
35
+ */
36
+ say(content: string, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>;
37
+ say(content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>;
38
+ say(content: SentencePrompt, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>;
39
+ setName(name: string): Proxied<Character, Chained<LogicAction.Actions>>;
40
+ }
@@ -33,8 +33,6 @@ export type ConditionData = {
33
33
  };
34
34
  };
35
35
  export declare class Condition extends Actionable {
36
- static defaultConfig: ConditionConfig;
37
- static getInitialState(): ConditionData;
38
36
  constructor(config?: ConditionConfig);
39
37
  /**
40
38
  * @chainable
@@ -1,5 +1,6 @@
1
1
  import { Actionable } from "../action/actionable";
2
2
  import { LogicAction } from "../action/logicAction";
3
+ import { Awaitable } from "../../../util/data";
3
4
  import { Chained, ChainedActions, Proxied } from "../action/chain";
4
5
  type ChainedControl = Proxied<Control, Chained<LogicAction.Actions>>;
5
6
  export declare class Control extends Actionable {
@@ -33,6 +34,11 @@ export declare class Control extends Actionable {
33
34
  * @chainable
34
35
  */
35
36
  static repeat(times: number, actions: ChainedActions): ChainedControl;
37
+ /**
38
+ * Sleep for a duration
39
+ * @chainable
40
+ */
41
+ static sleep(duration: number | Awaitable<any> | Promise<any>): ChainedControl;
36
42
  constructor();
37
43
  /**
38
44
  * Execute actions in order, waiting for each action to complete
@@ -64,5 +70,10 @@ export declare class Control extends Actionable {
64
70
  * @chainable
65
71
  */
66
72
  repeat(times: number, actions: ChainedActions): ChainedControl;
73
+ /**
74
+ * Sleep for a duration
75
+ * @chainable
76
+ */
77
+ sleep(duration: number | Awaitable<any> | Promise<any>): ChainedControl;
67
78
  }
68
79
  export {};
@@ -2,44 +2,32 @@ import React from "react";
2
2
  import type { TransformDefinitions } from "../elements/transform/type";
3
3
  import { Actionable } from "../action/actionable";
4
4
  import { Transform } from "./transform/transform";
5
- import { CommonImage, StaticImageData } from "../types";
5
+ import { CommonDisplayable, EventfulDisplayable, StaticImageData } from "../types";
6
6
  import { LogicAction } from "../game";
7
- import { ITransition } from "../elements/transition/type";
7
+ import { IImageTransition, ITransition } from "../elements/transition/type";
8
8
  import { DeepPartial } from "../../../util/data";
9
9
  import { Chained, Proxied } from "../action/chain";
10
10
  export type ImageConfig = {
11
11
  src: string | StaticImageData;
12
12
  display: boolean;
13
13
  disposed?: boolean;
14
- } & CommonImage;
14
+ } & CommonDisplayable;
15
15
  export type ImageDataRaw = {
16
16
  state: Record<string, any>;
17
17
  };
18
18
  export type ImageEventTypes = {
19
- "event:image.show": [Transform];
20
- "event:image.hide": [Transform];
21
19
  "event:image.init": [];
22
- "event:image.applyTransform": [Transform];
23
20
  "event:image.mount": [];
24
21
  "event:image.unmount": [];
25
22
  "event:image.ready": [React.MutableRefObject<HTMLDivElement | null>];
26
23
  "event:image.elementLoaded": [];
27
- "event:image.applyTransition": [ITransition];
28
24
  "event:image.flush": [];
29
25
  "event:image.flushComponent": [];
26
+ "event:displayable.applyTransition": [ITransition];
27
+ "event:displayable.applyTransform": [Transform];
28
+ "event:displayable.init": [];
30
29
  };
31
- export declare class Image extends Actionable<ImageDataRaw, Image> {
32
- static EventTypes: {
33
- [K in keyof ImageEventTypes]: K;
34
- };
35
- static defaultConfig: ImageConfig;
36
- static ImagePosition: {
37
- center: "center";
38
- left: "left";
39
- right: "right";
40
- };
41
- static serializeImageState(state: Record<string, any>): Record<string, any>;
42
- static deserializeImageState(state: Record<string, any>): ImageConfig;
30
+ export declare class Image extends Actionable<ImageDataRaw, Image> implements EventfulDisplayable {
43
31
  constructor(name: string, config: DeepPartial<ImageConfig>);
44
32
  constructor(config: DeepPartial<ImageConfig>);
45
33
  /**
@@ -64,7 +52,7 @@ export declare class Image extends Actionable<ImageDataRaw, Image> {
64
52
  * ```
65
53
  * @chainable
66
54
  */
67
- setSrc(src: string | StaticImageData, transition?: ITransition): Proxied<Image, Chained<LogicAction.Actions>>;
55
+ setSrc(src: string | StaticImageData, transition?: IImageTransition): Proxied<Image, Chained<LogicAction.Actions>>;
68
56
  /**
69
57
  * Apply a transform to the image
70
58
  * @example
@@ -98,7 +86,7 @@ export declare class Image extends Actionable<ImageDataRaw, Image> {
98
86
  * ```
99
87
  * @chainable
100
88
  */
101
- applyTransform(transform: Transform): Proxied<Image, Chained<LogicAction.Actions>>;
89
+ applyTransform(transform: Transform<TransformDefinitions.ImageTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
102
90
  /**
103
91
  * Show the image
104
92
  *
@@ -112,14 +100,14 @@ export declare class Image extends Actionable<ImageDataRaw, Image> {
112
100
  * @chainable
113
101
  */
114
102
  show(): Proxied<Image, Chained<LogicAction.Actions>>;
115
- show(options: Transform): Proxied<Image, Chained<LogicAction.Actions>>;
103
+ show(options: Transform<TransformDefinitions.ImageTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
116
104
  show(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
117
105
  /**
118
106
  * Hide the image
119
107
  * @chainable
120
108
  */
121
109
  hide(): Proxied<Image, Chained<LogicAction.Actions>>;
122
- hide(transform: Transform): Proxied<Image, Chained<LogicAction.Actions>>;
110
+ hide(transform: Transform<TransformDefinitions.ImageTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
123
111
  hide(transform: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Image, Chained<LogicAction.Actions>>;
124
112
  copy(): Image;
125
113
  }
@@ -1,18 +1,16 @@
1
- import { Sentence, Word } from "./text";
2
1
  import { LogicAction } from "../action/logicAction";
3
- import { MenuAction } from "../action/actions";
4
2
  import { Actionable } from "../action/actionable";
5
3
  import { Chained, Proxied } from "../action/chain";
4
+ import { Sentence, SentencePrompt } from "../elements/character/sentence";
6
5
  import Actions = LogicAction.Actions;
7
6
  import GameElement = LogicAction.GameElement;
8
7
  export type MenuConfig = {};
9
8
  export type MenuChoice = {
10
9
  action: ChainedActions;
11
- prompt: UnSentencePrompt | Sentence;
10
+ prompt: SentencePrompt | Sentence;
12
11
  };
13
12
  type ChainedAction = Proxied<GameElement, Chained<LogicAction.Actions>>;
14
13
  type ChainedActions = (ChainedAction | ChainedAction[] | Actions | Actions[])[];
15
- type UnSentencePrompt = (string | Word)[] | (string | Word);
16
14
  export type Choice = {
17
15
  action: Actions[];
18
16
  prompt: Sentence;
@@ -22,9 +20,7 @@ export type MenuData = {
22
20
  choices: Choice[];
23
21
  };
24
22
  export declare class Menu extends Actionable<any, Menu> {
25
- static defaultConfig: MenuConfig;
26
- static targetAction: typeof MenuAction;
27
- constructor(prompt: UnSentencePrompt, config?: MenuConfig);
23
+ constructor(prompt: SentencePrompt, config?: MenuConfig);
28
24
  constructor(prompt: Sentence, config?: MenuConfig);
29
25
  /**
30
26
  * Add a choice to the menu
@@ -36,6 +32,6 @@ export declare class Menu extends Actionable<any, Menu> {
36
32
  */
37
33
  choose(choice: MenuChoice): Proxied<Menu, Chained<LogicAction.Actions>>;
38
34
  choose(prompt: Sentence, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
39
- choose(prompt: UnSentencePrompt, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
35
+ choose(prompt: SentencePrompt, action: ChainedActions): Proxied<Menu, Chained<LogicAction.Actions>>;
40
36
  }
41
37
  export {};
@@ -1,27 +1,37 @@
1
1
  import { Constructable } from "../action/constructable";
2
- import { Awaitable, DeepPartial } from "../../../util/data";
3
- import { Background } from "../types";
2
+ import { Awaitable } from "../../../util/data";
3
+ import { Background, EventfulDisplayable, ImageColor, ImageSrc } from "../types";
4
4
  import { LogicAction } from "../action/logicAction";
5
5
  import { Transform } from "../elements/transform/transform";
6
- import { ITransition } from "../elements/transition/type";
6
+ import { IImageTransition, ITransition } from "../elements/transition/type";
7
7
  import { Sound, SoundDataRaw } from "../elements/sound";
8
8
  import { TransformDefinitions } from "../elements/transform/type";
9
- import { ImageDataRaw } from "../elements/image";
9
+ import { Image, ImageDataRaw } from "../elements/image";
10
10
  import { Chained, Proxied } from "../action/chain";
11
+ import { RGBColor } from "../common/Utils";
11
12
  import Actions = LogicAction.Actions;
12
13
  import ImageTransformProps = TransformDefinitions.ImageTransformProps;
13
14
  import GameElement = LogicAction.GameElement;
15
+ export type UserImageInput = ImageSrc | RGBColor | ImageColor;
14
16
  export type SceneConfig = {
15
17
  invertY: boolean;
16
18
  invertX: boolean;
17
19
  backgroundMusic: Sound | null;
18
20
  backgroundMusicFade: number;
19
- } & Background;
20
- export type SceneState = {
21
- backgroundMusic?: Sound | null;
21
+ backgroundImage: Image;
22
+ } & {
23
+ background: ImageSrc | ImageColor | null;
22
24
  };
25
+ export interface ISceneConfig {
26
+ invertY: boolean;
27
+ invertX: boolean;
28
+ backgroundMusic: Sound | null;
29
+ backgroundMusicFade: number;
30
+ background?: ImageSrc | ImageColor;
31
+ }
32
+ export type SceneState = {};
23
33
  export type JumpConfig = {
24
- transition: ITransition;
34
+ transition: IImageTransition;
25
35
  };
26
36
  type ChainableAction = Proxied<GameElement, Chained<LogicAction.Actions>> | Actions;
27
37
  type ChainedScene = Proxied<Scene, Chained<LogicAction.Actions>>;
@@ -33,7 +43,6 @@ export type SceneDataRaw = {
33
43
  backgroundImageState?: ImageDataRaw | null;
34
44
  };
35
45
  export type SceneEventTypes = {
36
- "event:scene.applyTransition": [ITransition | null];
37
46
  "event:scene.remove": [];
38
47
  "event:scene.load": [];
39
48
  "event:scene.unload": [];
@@ -41,17 +50,13 @@ export type SceneEventTypes = {
41
50
  "event:scene.unmount": [];
42
51
  "event:scene.preUnmount": [];
43
52
  "event:scene.imageLoaded": [];
44
- "event:scene.initTransform": [Transform<ImageTransformProps>];
45
53
  "event:scene.setBackgroundMusic": [Sound | null, number];
46
- "event:scene.applyTransform": [Transform<ImageTransformProps>];
54
+ "event:displayable.applyTransition": [ITransition];
55
+ "event:displayable.applyTransform": [Transform];
56
+ "event:displayable.init": [];
47
57
  };
48
- export declare class Scene extends Constructable<Actions, Scene> {
49
- static EventTypes: {
50
- [K in keyof SceneEventTypes]: K;
51
- };
52
- static defaultConfig: SceneConfig;
53
- static defaultState: SceneState;
54
- constructor(name: string, config?: DeepPartial<SceneConfig>);
58
+ export declare class Scene extends Constructable<Actions, Scene> implements EventfulDisplayable {
59
+ constructor(name: string, config?: Partial<ISceneConfig>);
55
60
  /**
56
61
  * Activate the scene
57
62
  *
@@ -70,7 +75,7 @@ export declare class Scene extends Constructable<Actions, Scene> {
70
75
  * Set background, if {@link transition} is provided, it will be applied
71
76
  * @chainable
72
77
  */
73
- setBackground(background: Background["background"], transition?: ITransition): ChainedScene;
78
+ setBackground(background: UserImageInput, transition?: IImageTransition): ChainedScene;
74
79
  /**
75
80
  * Apply a transform to the scene
76
81
  *
@@ -34,8 +34,8 @@ export type SoundConfig = {
34
34
  streaming?: boolean;
35
35
  };
36
36
  export declare class Sound extends Actionable<SoundDataRaw> {
37
- static defaultConfig: SoundConfig;
38
37
  constructor(config?: DeepPartial<SoundConfig>);
38
+ constructor(src?: string);
39
39
  /**
40
40
  * @chainable
41
41
  */
@@ -1,6 +1,6 @@
1
1
  import { Constructable } from "../action/constructable";
2
- import { SceneAction } from "../action/actions";
3
2
  import { Scene } from "../elements/scene";
3
+ import { SceneAction } from "../action/actions/sceneAction";
4
4
  export type StoryConfig = {};
5
5
  export type ElementStateRaw = Record<string, any>;
6
6
  export type NodeChildIdMap = Map<string, string>;
@@ -1,68 +1,80 @@
1
- import { LogicAction } from "../game";
2
- import { color, Color } from "../types";
3
- import { DeepPartial } from "../../../util/data";
1
+ import { color, CommonDisplayable, EventfulDisplayable } from "../types";
4
2
  import { Actionable } from "../action/actionable";
5
- import type { Sound } from "../elements/sound";
6
3
  import { Chained, Proxied } from "../action/chain";
7
- export type SentenceConfig = {
8
- pause?: boolean | number;
9
- voice: Sound | string | null | undefined;
10
- } & Color;
11
- export type WordConfig = {} & Color;
12
- export type SentenceDataRaw = {
13
- state: SentenceState;
14
- };
15
- export type SentenceState = {
4
+ import { LogicAction } from "../action/logicAction";
5
+ import { Transform } from "../elements/transform/transform";
6
+ import type { TransformDefinitions } from "../elements/transform/type";
7
+ import { ITextTransition, ITransition } from "../elements/transition/type";
8
+ export type TextConfig = {
9
+ alignX: "left" | "center" | "right";
10
+ alignY: "top" | "center" | "bottom";
11
+ className?: string;
12
+ fontSize: number;
13
+ fontColor: color;
16
14
  display: boolean;
15
+ text: string;
16
+ } & CommonDisplayable;
17
+ export type TextDataRaw = {
18
+ state: Record<string, any>;
17
19
  };
18
- type UnSentencePrompt = (string | Word)[] | (string | Word);
19
- export declare class Sentence {
20
- static defaultConfig: SentenceConfig;
21
- static defaultState: SentenceState;
22
- static isSentence(obj: any): obj is Sentence;
23
- static toSentence(prompt: UnSentencePrompt | Sentence): Sentence;
24
- constructor(character: Character | null, text: (string | Word)[] | (string | Word), config?: Partial<SentenceConfig>);
25
- }
26
- export declare class Word {
27
- static defaultConfig: Partial<WordConfig>;
28
- static defaultColor: color;
29
- static isWord(obj: any): obj is Word;
30
- constructor(text: string, config?: Partial<WordConfig>);
31
- }
32
- export declare enum CharacterMode {
33
- "adv" = "adv",
34
- "nvl" = "nvl"
35
- }
36
- export type CharacterConfig = {
37
- mode: CharacterMode;
20
+ export type TextEventTypes = {
21
+ "event:text.show": [Transform];
22
+ "event:text.hide": [Transform];
23
+ "event:displayable.applyTransition": [ITransition];
24
+ "event:displayable.applyTransform": [Transform];
25
+ "event:displayable.init": [];
38
26
  };
39
- export type CharacterStateData = {};
40
- export declare class Character extends Actionable<CharacterStateData, Character> {
41
- static Modes: typeof CharacterMode;
42
- static defaultConfig: CharacterConfig;
43
- constructor(name: string | null, config?: DeepPartial<CharacterConfig>);
27
+ export declare class Text extends Actionable<TextDataRaw, Text> implements EventfulDisplayable {
28
+ constructor(config: Partial<TextConfig>);
29
+ constructor(text: string, config?: Partial<TextConfig>);
30
+ /**
31
+ * Apply a transform to the Text
32
+ * @chainable
33
+ */
34
+ applyTransform(transform: Transform<TransformDefinitions.TextTransformProps>): Proxied<Text, Chained<LogicAction.Actions>>;
35
+ /**
36
+ * Apply a transition to the Text
37
+ * @chainable
38
+ */
39
+ applyTransition(transition: ITextTransition): Proxied<Text, Chained<LogicAction.Actions>>;
44
40
  /**
45
- * Say something
41
+ * Show the Text
42
+ *
43
+ * if options is provided, the text will show with the provided transform options
46
44
  * @example
47
- * ```typescript
48
- * character.say("Hello, world!");
45
+ * ```ts
46
+ * text.show({
47
+ * duration: 1000,
48
+ * });
49
49
  * ```
50
+ * @chainable
51
+ */
52
+ show(): Proxied<Text, Chained<LogicAction.Actions>>;
53
+ show(options: Transform<TransformDefinitions.TextTransformProps>): Proxied<Text, Chained<LogicAction.Actions>>;
54
+ show(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Text, Chained<LogicAction.Actions>>;
55
+ /**
56
+ * Hide the Text
57
+ *
58
+ * if options is provided, the text will hide with the provided transform options
50
59
  * @example
51
- * ```typescript
52
- * character
53
- * .say("Hello, world!")
54
- * .say("Hello, world!");
60
+ * ```ts
61
+ * text.hide({
62
+ * duration: 1000,
63
+ * });
55
64
  * ```
56
- * @example
57
- * ```typescript
58
- * character.say(new Sentence(character, [
59
- * "Hello, ",
60
- * new Word("world", {color: "#f00"}), // Some words can be colored
61
- * ]));
62
65
  * @chainable
63
66
  */
64
- say(content: string): Proxied<Character, Chained<LogicAction.Actions>>;
65
- say(content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>;
66
- say(content: (string | Word)[]): Proxied<Character, Chained<LogicAction.Actions>>;
67
+ hide(): Proxied<Text, Chained<LogicAction.Actions>>;
68
+ hide(options: Transform<TransformDefinitions.TextTransformProps>): Proxied<Text, Chained<LogicAction.Actions>>;
69
+ hide(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Text, Chained<LogicAction.Actions>>;
70
+ /**
71
+ * Set the text of the Text
72
+ * @chainable
73
+ */
74
+ setText(text: string): Proxied<Text, Chained<LogicAction.Actions>>;
75
+ /**
76
+ * Set the font color of the Text
77
+ * @chainable
78
+ */
79
+ setFontSize(fontSize: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
67
80
  }
68
- export {};
@@ -15,11 +15,11 @@ export interface IPosition {
15
15
  export type Coord2DPosition = {
16
16
  x: number | `${"-" | ""}${number}%`;
17
17
  y: number | `${"-" | ""}${number}%`;
18
- } & OffsetPosition;
18
+ } & Partial<OffsetPosition>;
19
19
  export type AlignPosition = {
20
20
  xalign: number;
21
21
  yalign: number;
22
- } & OffsetPosition;
22
+ } & Partial<OffsetPosition>;
23
23
  export type OffsetPosition = {
24
24
  xoffset: number;
25
25
  yoffset: number;
@@ -52,7 +52,7 @@ export declare class PositionUtils {
52
52
  static isRawCommonPositionType(arg: any): arg is CommonPositionType;
53
53
  static isRawCoord2DPosition(arg: any): arg is Coord2DPosition;
54
54
  static isRawAlignPosition(arg: any): arg is AlignPosition;
55
- static isRawPosition(arg: any): arg is IPosition;
55
+ static isRawPosition(arg: any): arg is RawPosition;
56
56
  static isPosition(arg: any): arg is IPosition;
57
57
  static rawPositionToCoord2D(arg: any): Coord2D;
58
58
  static tryParsePosition(arg: any): IPosition;
@@ -1,18 +1,12 @@
1
- import type { Background, CommonImage, CommonImagePosition } from "../../types";
2
- import type { AnimationPlaybackControls, DOMKeyframesDefinition, DynamicAnimationOptions } from "framer-motion";
3
- import { DeepPartial } from "../../../../util/data";
4
- import { GameState } from "../../../player/gameState";
1
+ import type { Background, color, CommonDisplayable } from "../../types";
2
+ import type { DOMKeyframesDefinition } from "framer-motion";
5
3
  import { TransformDefinitions } from "./type";
6
- import { Align, Coord2D, IPosition, RawPosition } from "./position";
7
- import { CSSProps } from "../../elements/transition/type";
8
4
  import Sequence = TransformDefinitions.Sequence;
9
5
  import SequenceProps = TransformDefinitions.SequenceProps;
10
- import React from "react";
11
- import { Image } from "../../elements/image";
12
- export type Transformers = "position" | "opacity" | "scale" | "rotation" | "display" | "src" | "backgroundColor" | "backgroundOpacity" | "transform";
6
+ export type Transformers = "position" | "opacity" | "scale" | "rotation" | "display" | "src" | "backgroundColor" | "backgroundOpacity" | "transform" | "fontSize" | "fontColor";
13
7
  export type TransformHandler<T> = (value: T) => DOMKeyframesDefinition;
14
8
  export type TransformersMap = {
15
- "position": CommonImage["position"];
9
+ "position": CommonDisplayable["position"];
16
10
  "opacity": number;
17
11
  "scale": number;
18
12
  "rotation": number;
@@ -21,19 +15,10 @@ export type TransformersMap = {
21
15
  "backgroundColor": Background["background"];
22
16
  "backgroundOpacity": number;
23
17
  "transform": TransformDefinitions.Types;
18
+ "fontSize": number;
19
+ "fontColor": color;
24
20
  };
25
- export declare class Transform<T extends TransformDefinitions.Types = TransformDefinitions.ImageTransformProps> {
26
- static defaultSequenceOptions: Partial<TransformDefinitions.CommonSequenceProps>;
27
- static defaultOptions: TransformDefinitions.SequenceProps<any>;
28
- static CommonImagePositionMap: {
29
- readonly left: "25.33%";
30
- readonly center: "50%";
31
- readonly right: "75.66%";
32
- };
33
- private readonly sequenceOptions;
34
- private sequences;
35
- private control;
36
- private transformers;
21
+ export declare class Transform<T extends TransformDefinitions.Types = object> {
37
22
  /**
38
23
  * @example
39
24
  * ```ts
@@ -46,31 +31,8 @@ export declare class Transform<T extends TransformDefinitions.Types = TransformD
46
31
  * });
47
32
  * ```
48
33
  */
49
- constructor(sequences: Sequence<T>[], sequenceOptions?: Partial<TransformDefinitions.TransformConfig>);
34
+ constructor(sequences: Sequence<T>[], transformConfig?: Partial<TransformDefinitions.TransformConfig>);
50
35
  constructor(props: SequenceProps<T>, options?: Partial<TransformDefinitions.CommonTransformProps>);
51
- static isPosition(position: any): position is (CommonImagePosition | Coord2D | Align);
52
- static positionToCSS(position: IPosition, invertY?: boolean | undefined, invertX?: boolean | undefined): CSSProps;
53
- static backgroundToCSS(background: Background["background"]): {
54
- backgroundImage?: string;
55
- backgroundColor?: string;
56
- };
57
- static mergePosition(a: RawPosition | undefined, b: RawPosition | undefined): Coord2D;
58
- static mergeState<T>(state: any, props: any): DeepPartial<T>;
59
- /**
60
- * @example
61
- * ```ts
62
- * const [scope, animate] = useAnimation();
63
- * transform.animate(scope, animate);
64
- * return <div ref={scope} />
65
- * ```
66
- */
67
- animate({ scope, overwrites, image }: {
68
- scope: React.MutableRefObject<HTMLDivElement | null>;
69
- overwrites?: Partial<{
70
- [K in Transformers]?: TransformHandler<any>;
71
- }>;
72
- image: Image;
73
- }, gameState: GameState, initState?: SequenceProps<T>, after?: (state: DeepPartial<T>) => void): Promise<void>;
74
36
  /**
75
37
  * @example
76
38
  * ```ts
@@ -93,12 +55,5 @@ export declare class Transform<T extends TransformDefinitions.Types = TransformD
93
55
  * ```
94
56
  */
95
57
  overwrite<T extends keyof TransformersMap = any>(key: T, transformer: TransformHandler<TransformersMap[T]>): this;
96
- propToCSS(state: GameState, prop: DeepPartial<T>, overwrites?: Partial<{
97
- [K in Transformers]?: TransformHandler<any>;
98
- }>): DOMKeyframesDefinition;
99
- optionsToFramerMotionOptions(options?: Partial<TransformDefinitions.CommonTransformProps>): DynamicAnimationOptions | void;
100
- propToCSSTransform(state: GameState, prop: Record<string, any>): string;
101
- setControl(control: AnimationPlaybackControls | null): this;
102
- getControl(): AnimationPlaybackControls | null;
103
58
  copy(): Transform<T>;
104
59
  }
@@ -1,4 +1,4 @@
1
- import { Background, CommonImage } from "../../types";
1
+ import { color, CommonDisplayable } from "../../types";
2
2
  import { DeepPartial } from "../../../../util/data";
3
3
  import type { AnimationPlaybackControls, AnimationScope, AnimationSequence, DOMKeyframesDefinition, DynamicAnimationOptions, ElementOrSelector, MotionValue, ValueAnimationTransition } from "framer-motion";
4
4
  export declare namespace TransformDefinitions {
@@ -27,15 +27,14 @@ export declare namespace TransformDefinitions {
27
27
  sync: boolean;
28
28
  repeat: number;
29
29
  };
30
- type SceneBackgroundTransformProps = {
31
- background: Background["background"];
32
- backgroundOpacity: number;
33
- };
34
- type ImageTransformProps = CommonImage & {
30
+ type ImageTransformProps = CommonDisplayable & {
35
31
  display: boolean;
36
- position: CommonImage["position"];
32
+ position: CommonDisplayable["position"];
33
+ };
34
+ type TextTransformProps = ImageTransformProps & {
35
+ fontColor: color;
37
36
  };
38
- type Types = ImageTransformProps | SceneBackgroundTransformProps;
37
+ type Types = ImageTransformProps | TextTransformProps | object;
39
38
  type SequenceProps<T> = DeepPartial<T>;
40
39
  type SequenceOptions = Partial<CommonTransformProps>;
41
40
  type Sequence<T> = {
@@ -1,12 +1,13 @@
1
1
  import { EventDispatcher } from "../../../../util/data";
2
- import { ElementProp, EventTypes, ITransition } from "./type";
2
+ import { ElementProp, EventTypes, IImageTransition, ITransition } from "./type";
3
3
  import type { AnimationPlaybackControls, ValueAnimationTransition } from "framer-motion";
4
- export declare class Base<T extends ElementProp> implements ITransition<T> {
4
+ import { ImageColor, ImageSrc } from "../../types";
5
+ export declare class BaseTransition<T extends ElementProp> implements ITransition<T> {
5
6
  controller: AnimationPlaybackControls | null | undefined;
6
7
  events: EventDispatcher<EventTypes<[T[]]>>;
7
8
  start(_onComplete?: () => void): void;
8
9
  toElementProps(): T[];
9
- setSrc(_src: string): void;
10
+ copy(): ITransition<T>;
10
11
  protected requestAnimation({ start, end, duration }: {
11
12
  start: number;
12
13
  end: number;
@@ -15,5 +16,11 @@ export declare class Base<T extends ElementProp> implements ITransition<T> {
15
16
  onComplete?: () => void;
16
17
  onUpdate?: (value: number) => void;
17
18
  }, options?: ValueAnimationTransition<number>): AnimationPlaybackControls;
19
+ }
20
+ export declare class BaseImageTransition<T extends ElementProp> extends BaseTransition<T> implements IImageTransition<T> {
21
+ setSrc(_src?: ImageSrc | ImageColor): this;
22
+ copy(): IImageTransition<T>;
23
+ }
24
+ export declare class BaseTextTransition<T extends ElementProp> extends BaseTransition<T> implements ITransition<T> {
18
25
  copy(): ITransition<T>;
19
26
  }
@@ -0,0 +1,25 @@
1
+ import { IImageTransition, ImgElementProp } from "../type";
2
+ import { BaseImageTransition } from "../baseTransitions";
3
+ import { ImageColor, ImageSrc } from "../../../types";
4
+ import { TransformDefinitions } from "../../../elements/transform/type";
5
+ /**
6
+ * @class Dissolve
7
+ * @implements ITransition
8
+ * @extends BaseTransition
9
+ * @description Dissolve transition effect
10
+ */
11
+ export declare class Dissolve extends BaseImageTransition<ImgElementProp> implements IImageTransition {
12
+ static Frames: [number, number];
13
+ private readonly duration;
14
+ private state;
15
+ private src?;
16
+ private readonly easing;
17
+ /**
18
+ * Image will dissolve from one image to another
19
+ */
20
+ constructor(duration?: number, easing?: TransformDefinitions.EasingDefinition);
21
+ setSrc(src: ImageSrc | ImageColor | undefined): this;
22
+ start(onComplete?: () => void): void;
23
+ toElementProps(): ImgElementProp[];
24
+ copy(): Dissolve;
25
+ }