narraleaf-react 0.15.0 → 0.16.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 (44) hide show
  1. package/dist/game/nlcore/action/actionTypes.d.ts +15 -1
  2. package/dist/game/nlcore/action/actions/controlAction.d.ts +2 -0
  3. package/dist/game/nlcore/action/actions/vfxAction.d.ts +24 -0
  4. package/dist/game/nlcore/action/logicAction.d.ts +16 -13
  5. package/dist/game/nlcore/action/stackModel.d.ts +28 -0
  6. package/dist/game/nlcore/common/elements.d.ts +6 -1
  7. package/dist/game/nlcore/common/game.d.ts +2 -1
  8. package/dist/game/nlcore/common/transition.d.ts +8 -9
  9. package/dist/game/nlcore/elements/camera.d.ts +71 -0
  10. package/dist/game/nlcore/elements/character/sentence.d.ts +2 -1
  11. package/dist/game/nlcore/elements/character/textEvent.d.ts +67 -0
  12. package/dist/game/nlcore/elements/character/word.d.ts +2 -1
  13. package/dist/game/nlcore/elements/control.d.ts +62 -0
  14. package/dist/game/nlcore/elements/displayable/image.d.ts +2 -2
  15. package/dist/game/nlcore/elements/scene.d.ts +2 -2
  16. package/dist/game/nlcore/elements/story.d.ts +21 -1
  17. package/dist/game/nlcore/elements/transition/transitions/image/darkness.d.ts +16 -9
  18. package/dist/game/nlcore/elements/transition/transitions/image/dissolve.d.ts +9 -6
  19. package/dist/game/nlcore/elements/transition/transitions/image/fadeIn.d.ts +9 -8
  20. package/dist/game/nlcore/elements/transition/transitions/image/mask.d.ts +162 -0
  21. package/dist/game/nlcore/elements/transition/transitions/image/reveal.d.ts +33 -0
  22. package/dist/game/nlcore/elements/transition/transitions/image/throughColor.d.ts +34 -36
  23. package/dist/game/nlcore/elements/transition/transitions/image/transitionMaskUtils.d.ts +5 -16
  24. package/dist/game/nlcore/elements/transition/transitions/text/fontSize.d.ts +9 -2
  25. package/dist/game/nlcore/elements/vfx.d.ts +85 -0
  26. package/dist/game/nlcore/game/liveGame.d.ts +44 -5
  27. package/dist/game/player/elements/menu/type.d.ts +3 -2
  28. package/dist/game/player/elements/nvl/type.d.ts +2 -1
  29. package/dist/game/player/elements/nvl/useNvlDialogState.d.ts +2 -1
  30. package/dist/game/player/elements/player/Camera.d.ts +1 -0
  31. package/dist/game/player/elements/say/Sentence.d.ts +3 -2
  32. package/dist/game/player/elements/say/UIDialog.d.ts +2 -1
  33. package/dist/game/player/elements/say/textEventEffect.d.ts +19 -0
  34. package/dist/game/player/elements/say/type.d.ts +4 -3
  35. package/dist/game/player/elements/scene/SceneDialogs.d.ts +1 -0
  36. package/dist/game/player/elements/vfx/Vfx.d.ts +1 -0
  37. package/dist/game/player/gameState.d.ts +8 -0
  38. package/dist/game/player/type.d.ts +20 -1
  39. package/dist/main.js +44 -42
  40. package/package.json +1 -1
  41. package/dist/game/nlcore/elements/transition/transitions/image/blinds.d.ts +0 -28
  42. package/dist/game/nlcore/elements/transition/transitions/image/maskTransition.d.ts +0 -38
  43. package/dist/game/nlcore/elements/transition/transitions/image/softIris.d.ts +0 -28
  44. package/dist/game/nlcore/elements/transition/transitions/image/softWipe.d.ts +0 -28
@@ -0,0 +1,19 @@
1
+ import type { GameState } from "../../gameState";
2
+ import type { TextEvent } from "../../../nlcore/elements/character/textEvent";
3
+ /**
4
+ * Apply a {@link TextEvent}'s effect directly to element state — no transition, no action history,
5
+ * no stack model. This is the "reveal semantics" seam: the typewriter calls it the moment it
6
+ * uncovers a token. Because the effect lands on ordinary element state (which IS serialized) and
7
+ * never enters the stack model, it adds no save burden and re-fires naturally when the owning
8
+ * `say` action is re-evaluated.
9
+ *
10
+ * Mirrors {@link ImageAction}'s non-transition branch for the repaint (layered image → `flush`,
11
+ * otherwise → `updateStyleSync`).
12
+ */
13
+ export declare function dispatchTextEvent(event: TextEvent, state: GameState): void;
14
+ /**
15
+ * Fire a {@link TextEvent} at most once for a given typewriter run. `fired` is the per-run guard
16
+ * (contract 5): a render re-entry that re-visits the same token is a no-op, but a fresh run —
17
+ * a replay of the same `say` — starts with an empty set and fires again (contract 4).
18
+ */
19
+ export declare function fireTextEventOnce(event: TextEvent, fired: Set<TextEvent>, state: GameState): void;
@@ -3,13 +3,14 @@ import type { GameState } from "../../gameState";
3
3
  import { Sentence } from "../../../nlcore/elements/character/sentence";
4
4
  import { Word } from "../../../nlcore/elements/character/word";
5
5
  import { Pausing } from "../../../nlcore/elements/character/pause";
6
+ import { TextEvent } from "../../../nlcore/elements/character/textEvent";
6
7
  import React from "react";
7
8
  import type { HTMLMotionProps } from "motion/react";
8
9
  export interface SayElementProps {
9
10
  action: {
10
11
  sentence: Sentence | null;
11
12
  character: Character | null;
12
- words: Word<Pausing | string>[] | null;
13
+ words: Word<Pausing | string | TextEvent>[] | null;
13
14
  id?: string;
14
15
  };
15
16
  /**
@@ -43,13 +44,13 @@ export interface DialogContext {
43
44
  action: {
44
45
  sentence: Sentence | null;
45
46
  character: Character | null;
46
- words: Word<Pausing | string>[] | null;
47
+ words: Word<Pausing | string | TextEvent>[] | null;
47
48
  };
48
49
  state: DialogStateType;
49
50
  }
50
51
  export type DialogAction = {
51
52
  sentence: Sentence | null;
52
53
  character: Character | null;
53
- words: Word<Pausing | string>[] | null;
54
+ words: Word<Pausing | string | TextEvent>[] | null;
54
55
  id?: string;
55
56
  };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -21,6 +21,7 @@ import { GameStateGuard } from "./guard";
21
21
  import { LiveGameEventToken } from "../nlcore/types";
22
22
  import * as htmlToImage from "html-to-image";
23
23
  import { Video, VideoStateRaw } from "../nlcore/elements/video";
24
+ import { Vfx, VfxStateRaw } from "../nlcore/elements/vfx";
24
25
  import { Timelines } from "./Tasks";
25
26
  import { Notification, NotificationManager } from "./lib/notification";
26
27
  import { ActionHistoryManager } from "../../game/nlcore/action/actionHistory";
@@ -71,6 +72,7 @@ type ScheduleHandle = {
71
72
  export type PlayerState = {
72
73
  sounds: Sound[];
73
74
  videos: Video[];
75
+ vfx: Vfx[];
74
76
  srcManagers: SrcManager[];
75
77
  elements: PlayerStateElement[];
76
78
  };
@@ -113,6 +115,8 @@ export type PlayerStateData = {
113
115
  }[];
114
116
  audio: AudioManagerDataRaw;
115
117
  videos: [videoId: string, videoState: VideoStateRaw][];
118
+ /** Absent in saves created before 0.16.0; readers must tolerate the missing key. */
119
+ vfx?: [vfxId: string, vfxState: VfxStateRaw][];
116
120
  nvlState?: NvlStateData;
117
121
  };
118
122
  export type PresentationSnapshot = {
@@ -185,6 +189,10 @@ export declare class GameState {
185
189
  removeVideo(video: Video): this;
186
190
  isVideoAdded(video: Video): boolean;
187
191
  getVideos(): Video[];
192
+ addVfx(vfx: Vfx): this;
193
+ removeVfx(vfx: Vfx): this;
194
+ isVfxAdded(vfx: Vfx): boolean;
195
+ getVfx(): Vfx[];
188
196
  findElementByScene(scene: Scene): PlayerStateElement | null;
189
197
  findElementByDisplayable(displayable: LogicAction.DisplayableElements, layer?: Layer | null): PlayerStateElement | null;
190
198
  getLiveGame(): LiveGame;
@@ -5,11 +5,13 @@ import { ImageEvents } from "./elements/image/Image";
5
5
  import { Transform } from "../nlcore/elements/transform/transform";
6
6
  import { Transition } from "../nlcore/elements/transition/transition";
7
7
  import { Layer } from "../nlcore/elements/layer";
8
+ import { Camera } from "../nlcore/elements/camera";
8
9
  import { Text } from "../nlcore/elements/displayable/text";
9
10
  import { Displayable } from "../nlcore/elements/displayable/displayable";
10
11
  import { Scene } from "../nlcore/elements/scene";
11
12
  import { Sound } from "../nlcore/elements/sound";
12
13
  import { Video } from "../nlcore/elements/video";
14
+ import { Vfx, VfxFadeOptions } from "../nlcore/elements/vfx";
13
15
  import { Timeline } from "./Tasks";
14
16
  export * from "./elements/type";
15
17
  export type Chosen = Choice & {
@@ -20,7 +22,9 @@ export declare enum ExposedStateType {
20
22
  text = "narraleaf:text",
21
23
  layer = "narraleaf:layer",
22
24
  scene = "narraleaf:scene",
23
- video = "narraleaf:video"
25
+ video = "narraleaf:video",
26
+ vfx = "narraleaf:vfx",
27
+ camera = "narraleaf:camera"
24
28
  }
25
29
  export type ExposedState = {
26
30
  [ExposedStateType.image]: {
@@ -46,6 +50,12 @@ export type ExposedState = {
46
50
  applyTransition: (transition: Transition<any>, onResolve: () => void) => Timeline;
47
51
  updateStyleSync: () => void;
48
52
  };
53
+ [ExposedStateType.camera]: {
54
+ initDisplayable: (onResolve: () => void) => Timeline;
55
+ applyTransform: (transform: Transform, onResolve: () => void) => Timeline;
56
+ applyTransition: (transition: Transition<any>, onResolve: () => void) => Timeline;
57
+ updateStyleSync: () => void;
58
+ };
49
59
  [ExposedStateType.scene]: {
50
60
  setBackgroundMusic: (music: Sound | null, fade: number) => Promise<void>;
51
61
  };
@@ -58,12 +68,21 @@ export type ExposedState = {
58
68
  stop: () => void;
59
69
  seek: (time: number) => void;
60
70
  };
71
+ [ExposedStateType.vfx]: {
72
+ show: (options?: VfxFadeOptions) => Promise<void>;
73
+ hide: (options?: VfxFadeOptions) => Promise<void>;
74
+ pause: () => void;
75
+ resume: () => void;
76
+ setRate: (rate: number) => void;
77
+ };
61
78
  };
62
79
  export type ExposedKeys = {
63
80
  [ExposedStateType.image]: Image | Displayable<any, any>;
64
81
  [ExposedStateType.text]: Text | Displayable<any, any>;
65
82
  [ExposedStateType.layer]: Layer | Displayable<any, any>;
83
+ [ExposedStateType.camera]: Camera | Displayable<any, any>;
66
84
  [ExposedStateType.scene]: Scene;
67
85
  [ExposedStateType.video]: Video;
86
+ [ExposedStateType.vfx]: Vfx;
68
87
  };
69
88
  export type { INotificationsProps } from "./elements/notification/type";