narraleaf-react 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,15 @@ export declare class VfxAction<T extends Values<typeof VfxActionTypes> = Values<
18
18
  readonly setRate: "vfx:setRate";
19
19
  };
20
20
  executeAction(gameState: GameState, injection: ActionExecutionInjection): Awaitable<CalledActionResult>;
21
+ /**
22
+ * A pause, a resume or a rate change aimed at an overlay that is no longer on the stage.
23
+ *
24
+ * An overlay leaves the stage with the scene that started it, so a handle kept in script and used
25
+ * after that scene is gone has nothing to talk to. It does nothing and says so - what `hide` on an
26
+ * overlay that is not shown has always done, and what a clip's transport does - rather than
27
+ * stopping the story.
28
+ */
29
+ private skipOffStage;
21
30
  private changeStateBase;
22
31
  private changeState;
23
32
  private changeStateAsync;
@@ -20,6 +20,16 @@ export declare class VideoAction<T extends Values<typeof VideoActionTypes> = Val
20
20
  readonly seek: "video:seek";
21
21
  };
22
22
  executeAction(gameState: GameState, injection: ActionExecutionInjection): Awaitable<CalledActionResult>;
23
+ /**
24
+ * A transport row - pause, resume, seek, stop - aimed at a clip that is no longer on the stage.
25
+ *
26
+ * There is nothing to talk to, and nothing it could have done: a clip that has left has stopped,
27
+ * and the next show puts it back from the start. Which side of the clip leaving such a row lands
28
+ * on is not always the author's to decide - a clip played without waiting for it leaves when it
29
+ * ends, at a moment set by how fast the player reads - so a row that would have worked a click
30
+ * earlier must not stop the story a click later. The same answer `hide` gives.
31
+ */
32
+ private skipOffStage;
23
33
  private changeStateBase;
24
34
  /**
25
35
  * {@link changeStateBase} for a fade, which the player can walk away from halfway.
@@ -54,8 +54,13 @@ export type VfxStateRaw = {
54
54
  * A full-screen looping video overlay for particle and ambience effects
55
55
  * (falling petals, light dust, rain, snow, fog, light flares).
56
56
  *
57
- * The effect is a pre-rendered video that plays above the scenes and videos of the
58
- * stage; camera transforms apply to it like any other stage content.
57
+ * The effect is a pre-rendered video that plays over the scene that shows it, above that scene's
58
+ * sprites and videos; camera transforms apply to it like any other stage content.
59
+ *
60
+ * Like everything else on the stage, an overlay belongs to the scene that shows it: rain started in
61
+ * one scene stops when the story jumps to another, waits hidden and paused while its scene has
62
+ * called another, and comes back when the call returns. A scene that wants the rain to go on shows
63
+ * it itself.
59
64
  */
60
65
  export declare class Vfx extends Actionable<VfxStateRaw> {
61
66
  /**
@@ -104,8 +109,8 @@ export declare class Vfx extends Actionable<VfxStateRaw> {
104
109
  *
105
110
  * A paused video decodes nothing, so a hidden overlay costs no frame time — and keeping the
106
111
  * element means the next {@link show} has a decoder already holding the clip instead of starting
107
- * over. Both halves of the same decision: stop the work, keep the warmth. Only a new game or a
108
- * load clears the stage.
112
+ * over. Both halves of the same decision: stop the work, keep the warmth. The overlay leaves the
113
+ * stage when its scene does.
109
114
  *
110
115
  * The action waits for the fade-out to finish. Calling it while the overlay is
111
116
  * not shown is a no-op (a weak warning is logged).
@@ -133,6 +133,22 @@ export type PlayerStateData = {
133
133
  * { [layerName]: [displayableId][] }
134
134
  */
135
135
  layers: Record<string, string[]>;
136
+ /**
137
+ * The ids of the clips this scene put on the stage. Their state is in
138
+ * {@link PlayerStateData.videos}; this says which scene each one leaves with.
139
+ *
140
+ * Written only when the scene has any. Absent in saves written before clips belonged to
141
+ * scenes, and a clip no scene names is given to the scene the story is running in.
142
+ */
143
+ videos?: string[];
144
+ /**
145
+ * The ids of the overlays this scene put on the stage, the same way
146
+ * {@link videos} names its clips. Their state is in {@link PlayerStateData.vfx}.
147
+ *
148
+ * Written only when the scene has any. Absent in saves written before overlays belonged
149
+ * to scenes, and an overlay no scene names is given to the scene the story is running in.
150
+ */
151
+ vfx?: string[];
136
152
  };
137
153
  }[];
138
154
  audio: AudioManagerDataRaw;
@@ -156,6 +172,20 @@ export type PlayerStateElementSnapshot = {
156
172
  * scene that is on the stage and one that is on the stage waiting for a call to return.
157
173
  */
158
174
  suspended?: boolean;
175
+ /**
176
+ * The clips this scene had on the stage, each with its state, in stage order.
177
+ *
178
+ * A clip is drawn over the scene rather than inside one of its layers, but it belongs to the
179
+ * scene that put it there all the same, and leaves with it. Absent in snapshots taken before
180
+ * clips belonged to scenes; read as none.
181
+ */
182
+ videos?: [Video, VideoStateRaw][];
183
+ /**
184
+ * The overlays this scene had on the stage, each with its state, in stage order - for the same
185
+ * reason as {@link videos}. Absent in snapshots taken before overlays belonged to scenes; read as
186
+ * none.
187
+ */
188
+ vfx?: [Vfx, VfxStateRaw][];
159
189
  };
160
190
  export type PlayerAction = CalledActionResult;
161
191
  interface StageUtils {
@@ -210,6 +240,22 @@ export declare class GameState {
210
240
  * See {@link VideoWarmQueue}.
211
241
  */
212
242
  private readonly videoWarmQueue;
243
+ /**
244
+ * Which scene each of the story's clips belongs to: the one running when the clip went on.
245
+ *
246
+ * A clip is not on one of the scene's layers - it is a sibling of the scene's root, so that a clip
247
+ * the preloader warmed can be taken over without being remounted - so nothing about where it sits
248
+ * says whose it is. And it has to be somebody's, because a scene takes everything it put on the
249
+ * stage with it when it leaves. Kept beside {@link PlayerState.videos} rather than in it, because
250
+ * the stage order of clips is not grouped by scene.
251
+ */
252
+ private videoOwners;
253
+ /**
254
+ * Which scene each overlay on the stage belongs to: the one running when it went on. An overlay
255
+ * is a stage object like any other - rain started in a scene stops when the scene is left - and
256
+ * it is drawn beside its scene's root for the reason a clip is (see {@link videoOwners}).
257
+ */
258
+ private vfxOwners;
213
259
  private videoMissingReporter;
214
260
  /** Sources already reported as unwarmed, so one clip in a loop does not report every pass. */
215
261
  private readonly reportedUnwarmedVideos;
@@ -547,6 +593,26 @@ export declare class GameState {
547
593
  * excluded explicitly rather than by trusting that route to stay closed.
548
594
  */
549
595
  private resetLayers;
596
+ /**
597
+ * The clip half of leaving a scene: every clip the scene put on the stage leaves with it, and
598
+ * goes back to its authored state, exactly as the sprites on its layers do in
599
+ * {@link resetLayers}.
600
+ *
601
+ * Without this a clip outlived its scene, and since a clip paints over its scene's sprites, one
602
+ * that stopped on its last frame covered the whole of the next scene - where nothing could take it
603
+ * down, because a host that names stage objects per scene cannot even name it.
604
+ *
605
+ * Every path that takes a scene off the stage comes through here - a plain jump's exit, a call
606
+ * returning, a jump giving up the callers parked behind it, stepping back over a scene's entrance
607
+ * - and each of them snapshots the scene first (see {@link createElementSnapshot}), so the clips
608
+ * come back with it when the step is undone.
609
+ */
610
+ private releaseVideosOf;
611
+ /**
612
+ * The overlay half of leaving a scene, the same as {@link releaseVideosOf}: rain the scene started
613
+ * stops when the scene is left, and the overlay goes back to its authored state.
614
+ */
615
+ private releaseVfxOf;
550
616
  private syncNvlDerivedState;
551
617
  private emitNvlStateChange;
552
618
  private resolveNvlAdvance;
@@ -0,0 +1 @@
1
+ export {};