narraleaf-react 0.32.0 → 0.33.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.
@@ -149,6 +149,7 @@ export type LayerActionContentType = {
149
149
  };
150
150
  export declare const VideoActionTypes: {
151
151
  readonly action: "video:action";
152
+ readonly preload: "video:preload";
152
153
  readonly show: "video:show";
153
154
  readonly hide: "video:hide";
154
155
  readonly play: "video:play";
@@ -158,10 +159,11 @@ export declare const VideoActionTypes: {
158
159
  readonly seek: "video:seek";
159
160
  };
160
161
  export type VideoActionContentType = {
161
- [K in typeof VideoActionTypes[keyof typeof VideoActionTypes]]: K extends "video:action" ? any : K extends "video:show" | "video:hide" | "video:play" | "video:pause" | "video:stop" | "video:resume" ? [] : K extends "video:seek" ? [number] : any;
162
+ [K in typeof VideoActionTypes[keyof typeof VideoActionTypes]]: K extends "video:action" ? any : K extends "video:preload" | "video:show" | "video:hide" | "video:play" | "video:pause" | "video:stop" | "video:resume" ? [] : K extends "video:seek" ? [number] : any;
162
163
  };
163
164
  export declare const VfxActionTypes: {
164
165
  readonly action: "vfx:action";
166
+ readonly preload: "vfx:preload";
165
167
  readonly show: "vfx:show";
166
168
  readonly hide: "vfx:hide";
167
169
  readonly pause: "vfx:pause";
@@ -169,7 +171,7 @@ export declare const VfxActionTypes: {
169
171
  readonly setRate: "vfx:setRate";
170
172
  };
171
173
  export type VfxActionContentType = {
172
- [K in typeof VfxActionTypes[keyof typeof VfxActionTypes]]: K extends "vfx:action" ? any : K extends "vfx:show" | "vfx:hide" ? [VfxFadeOptions?] : K extends "vfx:pause" | "vfx:resume" ? [] : K extends "vfx:setRate" ? [number] : any;
174
+ [K in typeof VfxActionTypes[keyof typeof VfxActionTypes]]: K extends "vfx:action" ? any : K extends "vfx:show" | "vfx:hide" ? [VfxFadeOptions?] : K extends "vfx:preload" | "vfx:pause" | "vfx:resume" ? [] : K extends "vfx:setRate" ? [number] : any;
173
175
  };
174
176
  export declare const PuppetActionTypes: {
175
177
  readonly action: "puppet:action";
@@ -10,6 +10,7 @@ import { Story } from "../../elements/story";
10
10
  export declare class VfxAction<T extends Values<typeof VfxActionTypes> = Values<typeof VfxActionTypes>> extends TypedAction<VfxActionContentType, T, Vfx> {
11
11
  static ActionTypes: {
12
12
  readonly action: "vfx:action";
13
+ readonly preload: "vfx:preload";
13
14
  readonly show: "vfx:show";
14
15
  readonly hide: "vfx:hide";
15
16
  readonly pause: "vfx:pause";
@@ -10,6 +10,7 @@ import { Story } from "../../elements/story";
10
10
  export declare class VideoAction<T extends Values<typeof VideoActionTypes> = Values<typeof VideoActionTypes>> extends TypedAction<VideoActionContentType, T, Video> {
11
11
  static ActionTypes: {
12
12
  readonly action: "video:action";
13
+ readonly preload: "video:preload";
13
14
  readonly show: "video:show";
14
15
  readonly hide: "video:hide";
15
16
  readonly play: "video:play";
@@ -26,6 +26,22 @@ export type VfxConfig = {
26
26
  export type VfxFadeOptions = {
27
27
  duration?: number;
28
28
  easing?: TransformDefinitions.EasingDefinition;
29
+ /**
30
+ * Opacity to fade in to, for this showing only. Defaults to `config.opacity`.
31
+ *
32
+ * The overlay's own opacity is a property of the material — how strong that rain IS — while this
33
+ * is a property of the moment: the same rain reading faintly behind a memory and at full strength
34
+ * in the storm. Read by `show` only; a `hide` always fades to zero.
35
+ */
36
+ opacity?: number;
37
+ /**
38
+ * Playback speed for this showing only. Defaults to `config.playbackRate`.
39
+ *
40
+ * Every `show` restates the speed, so an override lasts exactly as long as the showing that
41
+ * asked for it and the next `show` is back to the configured rate. Like
42
+ * {@link Vfx.setPlaybackRate}, it is not persisted: a loaded save plays at `config.playbackRate`.
43
+ */
44
+ rate?: number;
29
45
  };
30
46
  export type VfxState = {
31
47
  display: boolean;
@@ -58,15 +74,38 @@ export declare class Vfx extends Actionable<VfxStateRaw> {
58
74
  src: string;
59
75
  });
60
76
  /**
61
- * Add the overlay to the stage, fade it in, and start looping playback.
77
+ * Put the overlay on the stage without showing it: the video element is created and starts
78
+ * buffering, at zero opacity and paused.
79
+ *
80
+ * This is what makes a later {@link show} instant. A video that is not in the document has not
81
+ * begun to load, let alone decode, so the first frame of an overlay shown from nothing arrives
82
+ * whenever the decoder gets there — and `show` waits for it rather than fading in an empty
83
+ * rectangle. Declaring the overlay early moves that wait somewhere the player is not looking.
84
+ *
85
+ * Resolves immediately: nothing is waited for, because the point is to stop the story from
86
+ * waiting later. Calling it on an overlay already on stage does nothing.
87
+ * @chainable
88
+ */
89
+ preload(): Proxied<Vfx, Chained<LogicAction.Actions>>;
90
+ /**
91
+ * Fade the overlay in and start looping playback, putting it on the stage first if
92
+ * {@link preload} has not already.
62
93
  *
63
94
  * The action waits for the fade-in to finish. Calling it while the overlay is
64
95
  * already shown is idempotent (the fade-in is re-applied).
96
+ *
97
+ * `options.opacity` and `options.rate` apply to this showing only; both fall back to the
98
+ * overlay's configured values, so a plain `show()` after an overridden one is back to normal.
65
99
  * @chainable
66
100
  */
67
101
  show(options?: VfxFadeOptions): Proxied<Vfx, Chained<LogicAction.Actions>>;
68
102
  /**
69
- * Fade the overlay out, then stop playback and remove it from the stage.
103
+ * Fade the overlay out and stop playback. It stays on the stage, invisible and paused.
104
+ *
105
+ * A paused video decodes nothing, so a hidden overlay costs no frame time — and keeping the
106
+ * 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.
70
109
  *
71
110
  * The action waits for the fade-out to finish. Calling it while the overlay is
72
111
  * not shown is a no-op (a weak warning is logged).
@@ -75,6 +114,11 @@ export declare class Vfx extends Actionable<VfxStateRaw> {
75
114
  hide(options?: VfxFadeOptions): Proxied<Vfx, Chained<LogicAction.Actions>>;
76
115
  /**
77
116
  * Freeze the overlay on its current frame.
117
+ *
118
+ * A freeze is explicit state, not a side effect of being invisible: it survives a
119
+ * {@link hide}/{@link show} pair, so an overlay paused and then hidden comes back still frozen
120
+ * and only {@link resume} starts it moving again. `hide` stops playback of its own accord and
121
+ * does not touch this.
78
122
  * @chainable
79
123
  */
80
124
  pause(): Proxied<Vfx, Chained<LogicAction.Actions>>;
@@ -21,6 +21,17 @@ export declare class Video extends Actionable<VideoStateRaw> {
21
21
  * ```
22
22
  */
23
23
  constructor(config: Partial<VideoConfig>);
24
+ /**
25
+ * Put the video element on the stage without showing it, so it can start buffering.
26
+ *
27
+ * A video that is not in the document has not begun to load. Declaring it ahead of the line
28
+ * that shows or plays it is what turns "the movie starts" into something immediate rather
29
+ * than a wait of unknown length on the player's connection.
30
+ *
31
+ * Resolves immediately, and does nothing to an element already on stage.
32
+ * @chainable
33
+ */
34
+ preload(): Proxied<Video, Chained<LogicAction.Actions>>;
24
35
  /**
25
36
  * Show the video element.
26
37
  * @chainable
@@ -282,6 +282,14 @@ export declare class GameState {
282
282
  */
283
283
  restoreNvlSnapshot(snapshot: NvlState): this;
284
284
  restorePresentationSnapshot(snapshot: PresentationSnapshot): this;
285
+ /**
286
+ * Resolve every element's loop anchor back to the transform the story holds.
287
+ *
288
+ * Idempotent and cheap - {@link Displayable._rebindLoop} returns at once for an element with no
289
+ * anchor or an already-resolved one - so it is safe after any restore. Running it after all of
290
+ * them is what keeps a half-resolved loop from ever reaching the player.
291
+ */
292
+ private rebindLoops;
285
293
  /**
286
294
  * Clear NVL dialogs
287
295
  */