narraleaf-react 0.9.0-beta.5 → 0.9.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 (56) hide show
  1. package/LICENSE +373 -373
  2. package/README.md +165 -147
  3. package/dist/built-in.d.ts +3 -0
  4. package/dist/built-in.js +1 -0
  5. package/dist/game/nlcore/action/action.d.ts +9 -5
  6. package/dist/game/nlcore/action/actionTypes.d.ts +21 -12
  7. package/dist/game/nlcore/action/actions/controlAction.d.ts +1 -0
  8. package/dist/game/nlcore/action/actions/menuAction.d.ts +1 -4
  9. package/dist/game/nlcore/action/actions/sceneAction.d.ts +7 -2
  10. package/dist/game/nlcore/action/logicAction.d.ts +29 -29
  11. package/dist/game/nlcore/action/stackModel.d.ts +1 -1
  12. package/dist/game/nlcore/common/elements.d.ts +5 -2
  13. package/dist/game/nlcore/common/transition.d.ts +2 -1
  14. package/dist/game/nlcore/elements/built-in/DevTools.d.ts +2 -0
  15. package/dist/game/nlcore/elements/built-in/built-in.d.ts +2 -0
  16. package/dist/game/nlcore/elements/built-in/screenEffects.d.ts +31 -0
  17. package/dist/game/nlcore/elements/character/avatar.d.ts +35 -0
  18. package/dist/game/nlcore/elements/character/sentence.d.ts +14 -0
  19. package/dist/game/nlcore/elements/character.d.ts +30 -0
  20. package/dist/game/nlcore/elements/control.d.ts +15 -0
  21. package/dist/game/nlcore/elements/displayable/displayable.d.ts +84 -0
  22. package/dist/game/nlcore/elements/displayable/image.d.ts +2 -2
  23. package/dist/game/nlcore/elements/displayable/text.d.ts +2 -2
  24. package/dist/game/nlcore/elements/layer.d.ts +1 -2
  25. package/dist/game/nlcore/elements/nvl.d.ts +41 -0
  26. package/dist/game/nlcore/elements/scene.d.ts +29 -1
  27. package/dist/game/nlcore/elements/transform/transform.d.ts +26 -3
  28. package/dist/game/nlcore/elements/transform/type.d.ts +30 -2
  29. package/dist/game/nlcore/elements/transition/transitions/image/maskTransition.d.ts +38 -0
  30. package/dist/game/nlcore/gameTypes.d.ts +6 -1
  31. package/dist/game/player/Tasks.d.ts +4 -1
  32. package/dist/game/player/elements/Player.d.ts +1 -1
  33. package/dist/game/player/elements/elements.d.ts +2 -0
  34. package/dist/game/player/elements/menu/type.d.ts +1 -0
  35. package/dist/game/player/elements/nvl/DefaultNvlContainer.d.ts +4 -0
  36. package/dist/game/player/elements/nvl/NvlContainer.d.ts +5 -0
  37. package/dist/game/player/elements/nvl/NvlContext.d.ts +13 -0
  38. package/dist/game/player/elements/nvl/NvlDialogList.d.ts +7 -0
  39. package/dist/game/player/elements/nvl/type.d.ts +49 -0
  40. package/dist/game/player/elements/nvl/useNvlDialogState.d.ts +14 -0
  41. package/dist/game/player/elements/player/StageClickAnnouncer.d.ts +1 -0
  42. package/dist/game/player/elements/say/Avatar.d.ts +13 -0
  43. package/dist/game/player/elements/say/Nametag.d.ts +8 -1
  44. package/dist/game/player/elements/say/Sentence.d.ts +79 -2
  45. package/dist/game/player/elements/say/UIDialog.d.ts +6 -2
  46. package/dist/game/player/elements/say/type.d.ts +4 -2
  47. package/dist/game/player/elements/say/useDialog.d.ts +3 -0
  48. package/dist/game/player/elements/type.d.ts +10 -0
  49. package/dist/game/player/gameState.d.ts +134 -0
  50. package/dist/game/player/lib/AudioManager.d.ts +1 -0
  51. package/dist/game/player/lib/ErrorFallback.d.ts +5 -1
  52. package/dist/game/player/libElements.d.ts +9 -2
  53. package/dist/game/player/provider/game-state.d.ts +1 -0
  54. package/dist/main.js +45 -43
  55. package/dist/util/data.d.ts +15 -2
  56. package/package.json +12 -5
@@ -1,6 +1,7 @@
1
1
  import { Dissolve } from "../elements/transition/transitions/image/dissolve";
2
2
  import { FadeIn } from "../elements/transition/transitions/image/fadeIn";
3
+ import { MaskTransition } from "../elements/transition/transitions/image/maskTransition";
3
4
  import { Transition } from "../elements/transition/transition";
4
5
  import { ImageTransition } from "../elements/transition/transitions/image/imageTransition";
5
6
  import { TextTransition } from "../elements/transition/transitions/text/textTransition";
6
- export { Transition, ImageTransition, TextTransition, Dissolve, FadeIn, };
7
+ export { Transition, ImageTransition, TextTransition, Dissolve, FadeIn, MaskTransition, };
@@ -7,6 +7,8 @@ import { Scene } from "../scene";
7
7
  export declare class DevTools {
8
8
  static getActionId(action: LogicAction.Actions): string;
9
9
  static setActionId(action: LogicAction.Actions, id: string): LogicAction.Actions;
10
+ static getStaticId(action: LogicAction.Actions): string | null;
11
+ static setStaticId(action: LogicAction.Actions, id: string | null): LogicAction.Actions;
10
12
  static chainToActions(chain: Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>>): LogicAction.Actions[];
11
13
  static wrapAction(action: LogicAction.Actions[] | Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>>): ControlAction;
12
14
  static getNamespaceName(persistent: Persistent<any>): string;
@@ -1,2 +1,4 @@
1
1
  export { Gallery } from "./Gallery";
2
2
  export { DevTools } from "./DevTools";
3
+ export { blink, effectLayer, vignette, } from "./screenEffects";
4
+ export type { BlinkOptions, EffectLayerOptions, ScreenEffectColor, VignetteOptions, } from "./screenEffects";
@@ -0,0 +1,31 @@
1
+ import { Control, Layer } from "narraleaf-react";
2
+ import type { Scene, TransformDefinitions } from "narraleaf-react";
3
+ export type ScreenEffectColor = string | {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ a?: number;
8
+ };
9
+ export type EffectLayerOptions = {
10
+ name?: string;
11
+ zIndex?: number;
12
+ };
13
+ export type BlinkOptions = {
14
+ closeDuration?: number;
15
+ hold?: number;
16
+ openDuration?: number;
17
+ easing?: TransformDefinitions.EasingDefinition;
18
+ color?: ScreenEffectColor;
19
+ };
20
+ export type VignetteOptions = {
21
+ duration?: number;
22
+ opacity?: number;
23
+ color?: ScreenEffectColor;
24
+ inner?: string;
25
+ outer?: string;
26
+ hold?: number;
27
+ easing?: TransformDefinitions.EasingDefinition;
28
+ };
29
+ export declare function effectLayer(scene: Scene, options?: EffectLayerOptions): Layer;
30
+ export declare function blink(scene: Scene, options?: BlinkOptions): ReturnType<typeof Control.do>;
31
+ export declare function vignette(scene: Scene, options?: VignetteOptions): ReturnType<typeof Control.do>;
@@ -0,0 +1,35 @@
1
+ import type { ImageSrc } from "../../types";
2
+ import type { Character } from "../../elements/character";
3
+ import type { Image } from "../../elements/displayable/image";
4
+ import type { Sentence } from "../../elements/character/sentence";
5
+ import type { GameState } from "../../../player/gameState";
6
+ export type DialogAvatarSource = ImageSrc | null;
7
+ export type DialogAvatarResolverContext = {
8
+ character: Character;
9
+ sentence: Sentence | null;
10
+ portrait: Image | null;
11
+ currentSrc: string | null;
12
+ tags: string[] | null;
13
+ gameState: GameState;
14
+ };
15
+ export type DialogAvatarResolver = (ctx: DialogAvatarResolverContext) => DialogAvatarSource | undefined;
16
+ export type DialogAvatar = DialogAvatarSource | DialogAvatarResolver;
17
+ export type CharacterPortraitConfig = {
18
+ image: Image;
19
+ avatar?: DialogAvatar;
20
+ };
21
+ export type NormalizedCharacterPortraitConfig = {
22
+ image: Image;
23
+ avatar?: DialogAvatar;
24
+ };
25
+ export type DialogAvatarResolution = {
26
+ source: DialogAvatarSource;
27
+ character: Character | null;
28
+ portrait: Image | null;
29
+ };
30
+ export declare function normalizeCharacterPortraitConfig(portrait: Image | CharacterPortraitConfig): NormalizedCharacterPortraitConfig;
31
+ export declare function resolveDialogAvatar(ctx: DialogAvatarResolverContext & {
32
+ sentenceAvatar?: DialogAvatar | false;
33
+ portraitAvatar?: DialogAvatar;
34
+ characterAvatar?: DialogAvatar | false;
35
+ }): DialogAvatarResolution;
@@ -4,12 +4,22 @@ import { Word } from "../../elements/character/word";
4
4
  import type { ScriptCtx } from "../../elements/script";
5
5
  import { Sound } from "../../elements/sound";
6
6
  import { Color, Font } from "../../types";
7
+ import type { DialogAvatar } from "../../elements/character/avatar";
8
+ /**
9
+ * User-provided runtime metadata attached to a sentence; not serialized with saves.
10
+ * Use plain serializable values when possible.
11
+ */
12
+ export type SentenceMetadata = Record<string, unknown>;
7
13
  export type SentenceConfig = {
8
14
  pause?: boolean | number;
9
15
  voice: Sound | null;
10
16
  character: Character | null;
11
17
  voiceId: string | number | null;
12
18
  color?: Color;
19
+ /** Optional runtime-only metadata for UI hooks and integrations */
20
+ metadata?: SentenceMetadata;
21
+ /** Optional per-line dialog avatar override. Use `false` to hide the avatar for this sentence. */
22
+ avatar?: DialogAvatar | false;
13
23
  } & Font;
14
24
  export type SentenceUserConfig = Partial<Omit<SentenceConfig, "voice"> & {
15
25
  voice: Sound | string | null | undefined;
@@ -20,6 +30,10 @@ export type StaticWord<T extends string | DynamicWord | Pausing = string | Dynam
20
30
  export type SingleWord = StaticWord | DynamicWord;
21
31
  export type SentencePrompt = SingleWord[] | SingleWord;
22
32
  export declare class Sentence {
33
+ /**
34
+ * Returns runtime-only user metadata from sentence config; undefined when not set.
35
+ */
36
+ getMetadata(): SentenceMetadata | undefined;
23
37
  /**
24
38
  * Build a new sentence from a prompt or mix of words, pauses, and dynamic data.
25
39
  * @param text - The sentence prompt used to render the dialogue.
@@ -4,8 +4,12 @@ import { DeepPartial } from "../../../util/data";
4
4
  import { Actionable } from "../action/actionable";
5
5
  import { Chained, Proxied } from "../action/chain";
6
6
  import { Sentence, SentencePrompt, SentenceUserConfig, SingleWord } from "../elements/character/sentence";
7
+ import type { CharacterPortraitConfig, DialogAvatar } from "../elements/character/avatar";
8
+ import type { Image } from "../elements/displayable/image";
7
9
  export type CharacterConfig = {
8
10
  color?: Color;
11
+ avatar?: DialogAvatar | false;
12
+ portraits: (Image | CharacterPortraitConfig)[];
9
13
  };
10
14
  export interface Character {
11
15
  (content: string, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>;
@@ -58,6 +62,32 @@ export declare class Character extends Actionable<CharacterStateData, Character>
58
62
  * ```
59
63
  */
60
64
  setName(name: string): Proxied<Character, Chained<LogicAction.Actions>>;
65
+ /**
66
+ * Set the avatar strategy used by dialogs for this character.
67
+ * @param avatar - Image source, resolver, `false` to hide by default, or `null` for no avatar.
68
+ * @example
69
+ * ```ts
70
+ * character.setAvatar("alice-avatar.png");
71
+ * ```
72
+ */
73
+ setAvatar(avatar: DialogAvatar | false | null): this;
74
+ /**
75
+ * Register a portrait image as a possible visual source for this character's dialog avatar.
76
+ * @param image - The stage image that represents the character.
77
+ * @param config - Optional avatar override for this portrait.
78
+ * @example
79
+ * ```ts
80
+ * character.addPortrait(aliceSprite, { avatar: "alice-happy-avatar.png" });
81
+ * ```
82
+ */
83
+ addPortrait(image: Image, config?: {
84
+ avatar?: DialogAvatar;
85
+ }): this;
86
+ /**
87
+ * Replace all portrait bindings for this character.
88
+ * @param portraits - Stage images or image/avatar pairs.
89
+ */
90
+ setPortraits(portraits: (Image | CharacterPortraitConfig)[]): this;
61
91
  apply(content: string, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>;
62
92
  apply(content: Sentence): Proxied<Character, Chained<LogicAction.Actions>>;
63
93
  apply(content: SentencePrompt, config?: SentenceUserConfig): Proxied<Character, Chained<LogicAction.Actions>>;
@@ -79,6 +79,16 @@ export declare class Control extends Actionable {
79
79
  * @chainable
80
80
  */
81
81
  static sleep(duration: number | Awaitable<any> | Promise<any>): ChainedControl;
82
+ /**
83
+ * Pause execution until the user clicks anywhere on the stage (excluding GUI/Page elements).
84
+ * Similar to inserting a pause with no duration in a Sentence.
85
+ * @chainable
86
+ * @example
87
+ * ```ts
88
+ * Control.waitForClick();
89
+ * ```
90
+ */
91
+ static waitForClick(): ChainedControl;
82
92
  constructor(/**@internal */ config?: Partial<ControlConfig>);
83
93
  /**
84
94
  * Execute actions in order, waiting for each action to complete
@@ -126,4 +136,9 @@ export declare class Control extends Actionable {
126
136
  * @chainable
127
137
  */
128
138
  sleep(duration: number | Awaitable<any> | Promise<any>): ChainedControl;
139
+ /**
140
+ * Wait for user to click the stage (excluding GUI elements)
141
+ * @chainable
142
+ */
143
+ waitForClick(): ChainedControl;
129
144
  }
@@ -4,6 +4,7 @@ import { Chained, Proxied } from "../../action/chain";
4
4
  import { LogicAction } from "../../action/logicAction";
5
5
  import { EventfulDisplayable } from "../../../player/elements/displayable/type";
6
6
  import type { TransformDefinitions } from "../../elements/transform/type";
7
+ import type { ImageSrc } from "../../types";
7
8
  export declare abstract class Displayable<StateData extends Record<string, any>, Self extends Displayable<any, any, any>, TransformType extends TransformDefinitions.Types = TransformDefinitions.Types> extends Actionable<StateData, Self> implements EventfulDisplayable {
8
9
  /**
9
10
  * Set Image Position
@@ -92,6 +93,83 @@ export declare abstract class Displayable<StateData extends Record<string, any>,
92
93
  * ```
93
94
  */
94
95
  opacity(opacity: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
96
+ /**
97
+ * Apply visual effects to the Displayable.
98
+ *
99
+ * This is the low-level effect entry. Resource-aware helpers such as
100
+ * {@link Displayable.mask} should be preferred when an effect depends on an image source.
101
+ *
102
+ * @chainable
103
+ */
104
+ effect(effect: TransformDefinitions.VisualEffectTransformProps, options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
105
+ /**
106
+ * Apply an image mask to the Displayable.
107
+ *
108
+ * The source is registered for image preload and resolved to a CSS `url(...)` mask image.
109
+ *
110
+ * @chainable
111
+ */
112
+ mask(src: ImageSrc, options?: TransformDefinitions.MaskOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
113
+ /**
114
+ * Clear the current CSS mask from the Displayable.
115
+ *
116
+ * @chainable
117
+ */
118
+ clearMask(options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
119
+ /**
120
+ * Apply a CSS clip-path to the Displayable.
121
+ *
122
+ * @chainable
123
+ */
124
+ clip(clipPath: TransformDefinitions.VisualEffectTransformProps["clipPath"], options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
125
+ /**
126
+ * Clear the current CSS clip-path from the Displayable.
127
+ *
128
+ * @chainable
129
+ */
130
+ clearClip(options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
131
+ /**
132
+ * Reveal the Displayable with an animated circular clip-path.
133
+ *
134
+ * @chainable
135
+ */
136
+ circleReveal(options?: TransformDefinitions.CircleRevealOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
137
+ /**
138
+ * Close the Displayable with an animated circular clip-path.
139
+ *
140
+ * @chainable
141
+ */
142
+ circleClose(options?: TransformDefinitions.CircleCloseOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
143
+ /**
144
+ * Reveal or close the Displayable with an animated directional wipe.
145
+ *
146
+ * @chainable
147
+ */
148
+ wipe(options?: TransformDefinitions.WipeOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
149
+ /**
150
+ * Apply a CSS filter to the Displayable.
151
+ *
152
+ * @chainable
153
+ */
154
+ filter(filter: TransformDefinitions.VisualEffectTransformProps["filter"], options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
155
+ /**
156
+ * Clear the current CSS filter from the Displayable.
157
+ *
158
+ * @chainable
159
+ */
160
+ clearFilter(options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
161
+ /**
162
+ * Apply a CSS backdrop-filter to the Displayable.
163
+ *
164
+ * @chainable
165
+ */
166
+ backdrop(backdropFilter: TransformDefinitions.VisualEffectTransformProps["backdropFilter"], options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
167
+ /**
168
+ * Apply a CSS mix-blend-mode to the Displayable.
169
+ *
170
+ * @chainable
171
+ */
172
+ blend(mixBlendMode: TransformDefinitions.VisualEffectTransformProps["mixBlendMode"], options?: TransformDefinitions.VisualEffectOptions): Proxied<Self, Chained<LogicAction.Actions, Self>>;
95
173
  /**
96
174
  * Apply a transform to the Displayable
97
175
  * @chainable
@@ -101,6 +179,12 @@ export declare abstract class Displayable<StateData extends Record<string, any>,
101
179
  * ```
102
180
  */
103
181
  transform(transform: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions, Self>>;
182
+ private registerEffectSrc;
183
+ private static toCSSUrl;
184
+ private static extractCSSUrls;
185
+ private static createClipPathTransform;
186
+ private static circleClipPath;
187
+ private static wipeClipPath;
104
188
  /**
105
189
  * Show the Displayable
106
190
  *
@@ -1,5 +1,5 @@
1
1
  import type { TransformDefinitions } from "../../elements/transform/type";
2
- import { Color, CommonDisplayableConfig, ImageSrc } from "../../types";
2
+ import { Color, ImageSrc } from "../../types";
3
3
  import { LogicAction } from "../../game";
4
4
  import { FlexibleTuple, SelectElementFromEach } from "../../../../util/data";
5
5
  import { Chained, Proxied } from "../../action/chain";
@@ -14,7 +14,7 @@ export type TagDefinitionObject<T extends TagGroupDefinition> = {
14
14
  resolve: TagSrcResolver<T>;
15
15
  };
16
16
  type ImageSrcType<T extends TagGroupDefinition | null = TagGroupDefinition | null> = T extends TagGroupDefinition ? TagDefinition<T> : (Color | ImageSrc);
17
- export interface IImageUserConfig<Tag extends TagGroupDefinition | null = TagGroupDefinition | null> extends CommonDisplayableConfig {
17
+ export interface IImageUserConfig<Tag extends TagGroupDefinition | null = TagGroupDefinition | null> extends TransformDefinitions.ImageTransformProps {
18
18
  /**
19
19
  * The name of the image, only for debugging purposes
20
20
  */
@@ -1,4 +1,4 @@
1
- import { Color, CommonDisplayableConfig } from "../../types";
1
+ import { Color } from "../../types";
2
2
  import { Chained, Proxied } from "../../action/chain";
3
3
  import { LogicAction } from "../../action/logicAction";
4
4
  import type { TransformDefinitions } from "../../elements/transform/type";
@@ -16,7 +16,7 @@ export type TextState = {
16
16
  display: boolean;
17
17
  text: string;
18
18
  };
19
- export interface ITextUserConfig extends CommonDisplayableConfig {
19
+ export interface ITextUserConfig extends TransformDefinitions.TextTransformProps {
20
20
  /**
21
21
  * Where to align the text horizontally
22
22
  * @default "center"
@@ -1,4 +1,3 @@
1
- import { CommonDisplayableConfig } from "../types";
2
1
  import { LogicAction } from "../action/logicAction";
3
2
  import { TransformDefinitions } from "../elements/transform/type";
4
3
  import { Displayable } from "../elements/displayable/displayable";
@@ -6,7 +5,7 @@ import { EventfulDisplayable } from "../../player/elements/displayable/type";
6
5
  import { Image } from "../elements/displayable/image";
7
6
  import { Text } from "../elements/displayable/text";
8
7
  import { Chained, Proxied } from "../action/chain";
9
- export interface ILayerUserConfig extends CommonDisplayableConfig {
8
+ export interface ILayerUserConfig extends TransformDefinitions.ImageTransformProps {
10
9
  /**
11
10
  * The z-index of the layer, higher z-index will be rendered on top of the lower z-index, allows negative values.
12
11
  *
@@ -0,0 +1,41 @@
1
+ import { Actionable } from "../action/actionable";
2
+ import { LogicAction } from "../action/logicAction";
3
+ import { Chained, Proxied } from "../action/chain";
4
+ import type { TransformDefinitions } from "../elements/transform/type";
5
+ import type { Scene } from "../elements/scene";
6
+ type ChainedNVL = Proxied<NVLToken, Chained<LogicAction.Actions>>;
7
+ export declare class NVLToken extends Actionable<null, NVLToken> {
8
+ constructor(scene: Scene);
9
+ /**
10
+ * Show the NVL layer with optional transition
11
+ * @param options - Optional transition properties for showing the NVL layer
12
+ * @chainable
13
+ * @example
14
+ * ```ts
15
+ * nvl.show({ duration: 500 });
16
+ * ```
17
+ */
18
+ show(options?: Partial<TransformDefinitions.CommonTransformProps>): ChainedNVL;
19
+ /**
20
+ * Hide the NVL layer with optional transition
21
+ * Does not exit NVL mode or clear dialogs
22
+ * @param options - Optional transition properties for hiding the NVL layer
23
+ * @chainable
24
+ * @example
25
+ * ```ts
26
+ * nvl.hide({ duration: 500 });
27
+ * ```
28
+ */
29
+ hide(options?: Partial<TransformDefinitions.CommonTransformProps>): ChainedNVL;
30
+ /**
31
+ * Force exit NVL mode immediately
32
+ * Clears all accumulated dialogs and hides the NVL layer
33
+ * @chainable
34
+ * @example
35
+ * ```ts
36
+ * nvl.end();
37
+ * ```
38
+ */
39
+ end(): ChainedNVL;
40
+ }
41
+ export {};
@@ -3,10 +3,13 @@ import { Color, ImageSrc } from "../types";
3
3
  import { LogicAction } from "../action/logicAction";
4
4
  import { Sound, VoiceIdMap, VoiceSrcGenerator } from "../elements/sound";
5
5
  import { Image } from "../elements/displayable/image";
6
- import { ActionStatements, Persistent } from "../common/core";
7
6
  import { Chained, Proxied } from "../action/chain";
8
7
  import { ImageTransition } from "../elements/transition/transitions/image/imageTransition";
9
8
  import { Layer } from "../elements/layer";
9
+ import { NVLToken } from "./nvl";
10
+ import type { TransformDefinitions } from "../elements/transform/type";
11
+ import type { ActionStatements } from "../elements/type";
12
+ import type { Persistent } from "../elements/persistent";
10
13
  export interface ISceneUserConfig {
11
14
  /**
12
15
  * Background music
@@ -79,6 +82,31 @@ export declare class Scene extends Constructable<LogicAction.Actions, Scene> {
79
82
  * ```
80
83
  */
81
84
  setBackgroundMusic(sound: Sound | null, fade?: number): ChainedScene;
85
+ /**
86
+ * Create an NVL (Novel) mode block for displaying accumulated dialog.
87
+ * In NVL mode, dialogs are stacked on screen rather than replacing each other.
88
+ * @param actions - Actions to execute within NVL mode, or a callback receiving an NVLToken
89
+ * @chainable
90
+ * @example
91
+ * ```ts
92
+ * scene.nvl([
93
+ * character.say("First line"),
94
+ * character.say("Second line"),
95
+ * character.say("Third line"),
96
+ * ]);
97
+ * ```
98
+ * @example
99
+ * ```ts
100
+ * scene.nvl(nvl => [
101
+ * nvl.show({ duration: 500 }),
102
+ * character.say("Line 1"),
103
+ * character.say("Line 2"),
104
+ * nvl.hide({ duration: 500 }),
105
+ * ]);
106
+ * ```
107
+ */
108
+ nvl(actions: ActionStatements | ((nvl: NVLToken) => ActionStatements)): ChainableAction;
109
+ nvl(options: Partial<TransformDefinitions.CommonTransformProps>, actions: ActionStatements | ((nvl: NVLToken) => ActionStatements)): ChainableAction;
82
110
  /**
83
111
  * Register the list of actions (or an action-generating callback) that this scene will execute.
84
112
  * @param actions - Either a list of actions or a factory that receives the scene and returns actions.
@@ -1,4 +1,3 @@
1
- import type { CommonDisplayableConfig } from "../../types";
2
1
  import { TransformDefinitions } from "./type";
3
2
  import { CSSProps } from "../../elements/transition/type";
4
3
  type OverwriteMap = {
@@ -8,7 +7,7 @@ export type OverwriteDefinition = {
8
7
  [K in keyof OverwriteMap]?: OverwriteHandler<OverwriteMap[K]>;
9
8
  };
10
9
  type OverwriteHandler<T> = (value: Partial<TransformDefinitions.Types>) => T;
11
- export declare class Transform<T extends TransformDefinitions.Types = CommonDisplayableConfig> {
10
+ export declare class Transform<T extends TransformDefinitions.Types = TransformDefinitions.Types> {
12
11
  /**
13
12
  * Apply transform immediately
14
13
  */
@@ -30,7 +29,7 @@ export declare class Transform<T extends TransformDefinitions.Types = CommonDisp
30
29
  * @param config - The config for the transform.
31
30
  * @returns A new transform with the given config.
32
31
  */
33
- static create<T extends TransformDefinitions.Types = CommonDisplayableConfig>(config?: Partial<TransformDefinitions.TransformConfig>): Transform<T>;
32
+ static create<T extends TransformDefinitions.Types = TransformDefinitions.Types>(config?: Partial<TransformDefinitions.TransformConfig>): Transform<T>;
34
33
  /**
35
34
  * @example
36
35
  * ```ts
@@ -124,5 +123,29 @@ export declare class Transform<T extends TransformDefinitions.Types = CommonDisp
124
123
  * @returns {this} The current Transform instance for method chaining.
125
124
  */
126
125
  fontColor(fontColor: TransformDefinitions.Types["fontColor"]): this;
126
+ /**
127
+ * Set visual effect fields in the current staging sequence.
128
+ */
129
+ effect(effect: TransformDefinitions.VisualEffectTransformProps): this;
130
+ /**
131
+ * Set the CSS mask image of the current staging sequence.
132
+ */
133
+ maskImage(maskImage: TransformDefinitions.Types["maskImage"]): this;
134
+ /**
135
+ * Set the CSS clip-path of the current staging sequence.
136
+ */
137
+ clipPath(clipPath: TransformDefinitions.Types["clipPath"]): this;
138
+ /**
139
+ * Set the CSS filter of the current staging sequence.
140
+ */
141
+ filter(filter: TransformDefinitions.Types["filter"]): this;
142
+ /**
143
+ * Set the CSS backdrop-filter of the current staging sequence.
144
+ */
145
+ backdropFilter(backdropFilter: TransformDefinitions.Types["backdropFilter"]): this;
146
+ /**
147
+ * Set the CSS mix-blend-mode of the current staging sequence.
148
+ */
149
+ mixBlendMode(mixBlendMode: TransformDefinitions.Types["mixBlendMode"]): this;
127
150
  }
128
151
  export {};
@@ -1,4 +1,5 @@
1
1
  import { Color, CommonDisplayableConfig } from "../../types";
2
+ import type React from "react";
2
3
  export declare namespace TransformDefinitions {
3
4
  type BezierDefinition = [number, number, number, number];
4
5
  type CustomEasingFunction = (t: number) => number;
@@ -17,10 +18,37 @@ export declare namespace TransformDefinitions {
17
18
  repeat?: number;
18
19
  repeatDelay?: number;
19
20
  };
20
- type ImageTransformProps = CommonDisplayableConfig & {};
21
+ type VisualEffectTransformProps = {
22
+ maskImage?: React.CSSProperties["maskImage"];
23
+ maskSize?: React.CSSProperties["maskSize"];
24
+ maskPosition?: React.CSSProperties["maskPosition"];
25
+ maskRepeat?: React.CSSProperties["maskRepeat"];
26
+ maskMode?: React.CSSProperties["maskMode"];
27
+ clipPath?: React.CSSProperties["clipPath"];
28
+ filter?: React.CSSProperties["filter"];
29
+ backdropFilter?: React.CSSProperties["backdropFilter"];
30
+ mixBlendMode?: React.CSSProperties["mixBlendMode"];
31
+ };
32
+ type VisualEffectOptions = Partial<CommonTransformProps>;
33
+ type MaskOptions = VisualEffectOptions & Pick<VisualEffectTransformProps, "maskSize" | "maskPosition" | "maskRepeat" | "maskMode">;
34
+ type WipeDirection = "left" | "right" | "top" | "bottom";
35
+ type CircleClipOptions = VisualEffectOptions & {
36
+ center?: string;
37
+ from?: number;
38
+ to?: number;
39
+ clearClip?: boolean;
40
+ };
41
+ type CircleRevealOptions = CircleClipOptions;
42
+ type CircleCloseOptions = CircleClipOptions;
43
+ type WipeOptions = VisualEffectOptions & {
44
+ direction?: WipeDirection;
45
+ reverse?: boolean;
46
+ clearClip?: boolean;
47
+ };
48
+ type ImageTransformProps = CommonDisplayableConfig & VisualEffectTransformProps;
21
49
  type TextTransformProps = CommonDisplayableConfig & {
22
50
  fontColor?: Color;
23
- };
51
+ } & VisualEffectTransformProps;
24
52
  type Types = CommonDisplayableConfig & ImageTransformProps & TextTransformProps;
25
53
  type SequenceProps<T> = Partial<T>;
26
54
  type SequenceOptions = Partial<CommonTransformProps>;
@@ -0,0 +1,38 @@
1
+ import { TransitionAnimationType, TransitionTask } from "../../../../elements/transition/type";
2
+ import { TransformDefinitions } from "../../../../elements/transform/type";
3
+ import { ImageTransition } from "../../../../elements/transition/transitions/image/imageTransition";
4
+ type AnimationType = [TransitionAnimationType.Number];
5
+ export type MaskTransitionCircleOptions = {
6
+ duration: number;
7
+ easing?: TransformDefinitions.EasingDefinition;
8
+ center?: string;
9
+ from?: number;
10
+ to?: number;
11
+ };
12
+ export type MaskTransitionWipeOptions = {
13
+ duration: number;
14
+ easing?: TransformDefinitions.EasingDefinition;
15
+ direction?: TransformDefinitions.WipeDirection;
16
+ reverse?: boolean;
17
+ };
18
+ export declare class MaskTransition extends ImageTransition<AnimationType> {
19
+ private duration;
20
+ private easing;
21
+ private clipPathResolver;
22
+ private constructor();
23
+ /**
24
+ * Reveal the target image through an animated circular clip-path.
25
+ */
26
+ static circle(options: MaskTransitionCircleOptions): MaskTransition;
27
+ /**
28
+ * Reveal or close the target image through an animated directional wipe.
29
+ */
30
+ static wipe(options: MaskTransitionWipeOptions): MaskTransition;
31
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
32
+ copy(): MaskTransition;
33
+ private static lerp;
34
+ private static circleClipPath;
35
+ private static wipeClipPath;
36
+ private static formatNumber;
37
+ }
38
+ export {};
@@ -7,7 +7,7 @@ import { PlayerStateData } from "../player/gameState";
7
7
  import { GuardConfig } from "../player/guard";
8
8
  import React from "react";
9
9
  import { StackModel, StackModelRawData } from "./action/stackModel";
10
- import { MenuComponent, NotificationComponent, SayComponent } from "./common/player";
10
+ import { MenuComponent, NotificationComponent, NvlDialogComponent, SayComponent } from "./common/player";
11
11
  import { Color, LiveGameEventToken } from "./types";
12
12
  export interface SavedGameMetaData {
13
13
  /**
@@ -276,6 +276,11 @@ export type GameConfig = {
276
276
  * @default DefaultSay
277
277
  */
278
278
  dialog: SayComponent;
279
+ /**
280
+ * The component to use for NVL mode dialog
281
+ * @default DefaultNvlContainer
282
+ */
283
+ nvlDialog: NvlDialogComponent;
279
284
  /**
280
285
  * The function to call when an error occurs
281
286
  * @default () => {}
@@ -1,6 +1,6 @@
1
1
  import { Awaitable } from "../../util/data";
2
2
  import { GameStateGuard } from "./guard";
3
- type TimelineStatus = "pending" | "cancelled" | "resolved";
3
+ type TimelineStatus = "pending" | "cancelled" | "resolved" | "failed";
4
4
  export declare class Timeline {
5
5
  awaitable: Awaitable;
6
6
  guard?: GameStateGuard | undefined;
@@ -74,6 +74,7 @@ export declare class Timeline {
74
74
  private children;
75
75
  private _onResolved;
76
76
  private _onCancelled;
77
+ private _onFailed;
77
78
  private _onTimelineRegistered;
78
79
  private _ableToAttach;
79
80
  private _status;
@@ -82,8 +83,10 @@ export declare class Timeline {
82
83
  isSettled(): boolean;
83
84
  isResolved(): boolean;
84
85
  isCancelled(): boolean;
86
+ isFailed(): boolean;
85
87
  onResolved(callback: () => void): void;
86
88
  onCancelled(callback: () => void): void;
89
+ onFailed(callback: (error: unknown) => void): void;
87
90
  onSettled(callback: () => void): void;
88
91
  abort(): void;
89
92
  attachChild(arg0: Awaitable | Timeline): this;
@@ -1,4 +1,4 @@
1
1
  import "client-only";
2
2
  import { PlayerProps } from "../elements/type";
3
3
  import React from "react";
4
- export default function Player({ story, width, height, className, onReady, onEnd, onError, children, active, }: Readonly<PlayerProps>): React.JSX.Element;
4
+ export default function Player({ story, width, height, className, onReady, onPreloadedReady, onEnd, onError, children, active, }: Readonly<PlayerProps>): React.JSX.Element;
@@ -1,8 +1,10 @@
1
1
  import { DefaultDialog } from "../../../game/player/elements/say/Dialog";
2
2
  import { DefaultMenu } from "../../../game/player/elements/menu/PlayerMenu";
3
3
  import { DefaultNotification } from "../elements/notification/PlayerNotification";
4
+ import { DefaultNvlContainer } from "../elements/nvl/DefaultNvlContainer";
4
5
  export declare const DefaultElements: {
5
6
  readonly say: typeof DefaultDialog;
6
7
  readonly menu: typeof DefaultMenu;
7
8
  readonly notification: typeof DefaultNotification;
9
+ readonly nvlDialog: typeof DefaultNvlContainer;
8
10
  };
@@ -10,6 +10,7 @@ export interface MenuElementProps {
10
10
  afterChoose: (choice: Chosen) => void;
11
11
  state: GameState;
12
12
  words: Word<Pausing | string>[] | null;
13
+ renderPrompt?: boolean;
13
14
  }
14
15
  export interface IUserMenuProps {
15
16
  items: number[];