narraleaf-react 0.30.0 → 0.31.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.
@@ -27,5 +27,15 @@ export type VignetteOptions = {
27
27
  easing?: TransformDefinitions.EasingDefinition;
28
28
  };
29
29
  export declare function effectLayer(scene: Scene, options?: EffectLayerOptions): Layer;
30
+ /**
31
+ * @deprecated Superseded by the camera lens in 0.31.0. This draws into a scene-level layer,
32
+ * which sits inside the camera transform, so it scales and rotates with the camera; it is also
33
+ * tied to a scene while the camera is tied to the story. Use `Camera.shutter()` instead.
34
+ */
30
35
  export declare function blink(scene: Scene, options?: BlinkOptions): ReturnType<typeof Control.do>;
36
+ /**
37
+ * @deprecated Superseded by the camera lens in 0.31.0. This draws into a scene-level layer,
38
+ * which sits inside the camera transform, so it scales and rotates with the camera; it is also
39
+ * tied to a scene while the camera is tied to the story. Use `Camera.vignette()` instead.
40
+ */
31
41
  export declare function vignette(scene: Scene, options?: VignetteOptions): ReturnType<typeof Control.do>;
@@ -8,9 +8,10 @@ import { Chained, Proxied } from "../action/chain";
8
8
  *
9
9
  * A camera is transformed exactly like any other displayable, so its initial pose is described
10
10
  * with the same {@link TransformDefinitions.ImageTransformProps} fields (position, zoom, scale,
11
- * rotation, opacity, filter, ...).
11
+ * rotation, opacity, filter, ...), plus the lens channels
12
+ * ({@link TransformDefinitions.CameraLensProps}) only a camera has.
12
13
  */
13
- export type ICameraUserConfig = TransformDefinitions.ImageTransformProps;
14
+ export type ICameraUserConfig = TransformDefinitions.CameraTransformProps;
14
15
  export type CameraDataRaw = {
15
16
  transformState: Record<string, any>;
16
17
  };
@@ -35,7 +36,7 @@ export type CameraDataRaw = {
35
36
  * ]);
36
37
  * ```
37
38
  */
38
- export declare class Camera extends Displayable<CameraDataRaw, Camera, TransformDefinitions.ImageTransformProps> implements EventfulDisplayable {
39
+ export declare class Camera extends Displayable<CameraDataRaw, Camera, TransformDefinitions.CameraTransformProps> implements EventfulDisplayable {
39
40
  /**
40
41
  * Create a camera. A story already owns a default one ({@link Story.camera}); construct your
41
42
  * own only to override the initial pose via the story config.
@@ -66,8 +67,64 @@ export declare class Camera extends Displayable<CameraDataRaw, Camera, Transform
66
67
  */
67
68
  darken(darkness: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Camera, Chained<LogicAction.Actions, Camera>>;
68
69
  /**
69
- * Return the camera to its neutral pose: centred, zoom `1`, no rotation, fully opaque and no
70
- * filter (which also clears {@link Camera.darken}).
70
+ * Close or open the shutter: two blades that meet in the middle of the frame.
71
+ *
72
+ * `1` is fully shut and `0` fully open, and everything between is a partial cover — which makes
73
+ * a small standing value a letterbox rather than a blink, `0.12` being about a cinematic matte.
74
+ * A blink is this driven to `1` and back; the timing of one is the story's to choose, so the
75
+ * engine offers the channel rather than a named routine.
76
+ *
77
+ * @param shutter - Coverage between `0` (open) and `1` (shut). Out-of-range values are clamped.
78
+ * @chainable
79
+ * @example
80
+ * ```ts
81
+ * scene.action([
82
+ * story.camera.shutter(1, 180, "easeInOut"),
83
+ * story.camera.shutter(0, 220, "easeInOut"),
84
+ * ]);
85
+ * ```
86
+ */
87
+ shutter(shutter: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Camera, Chained<LogicAction.Actions, Camera>>;
88
+ /**
89
+ * Darken the corners of the frame.
90
+ *
91
+ * Unlike {@link Camera.darken}, which is a filter over the picture, this is a plate over the
92
+ * *view*: it does not move with the camera, so a vignette holds still while the stage
93
+ * underneath it zooms, pans and rotates. Adjust its falloff with {@link Camera.lens}.
94
+ *
95
+ * @param vignette - Strength between `0` (none) and `1`. Out-of-range values are clamped.
96
+ * @chainable
97
+ * @example
98
+ * ```ts
99
+ * scene.action([
100
+ * story.camera.vignette(0.72, 300, "easeInOut"),
101
+ * jS`Everything narrowed to the middle of the room.`,
102
+ * story.camera.vignette(0, 300, "easeInOut"),
103
+ * ]);
104
+ * ```
105
+ */
106
+ vignette(vignette: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Camera, Chained<LogicAction.Actions, Camera>>;
107
+ /**
108
+ * Set any of the lens channels at once — the two strengths and the colour and falloff geometry
109
+ * they are drawn with.
110
+ *
111
+ * The geometry fields take effect the next time the strength they belong to is above `0`, so
112
+ * they are usually set as a cut before the effect is faded in.
113
+ *
114
+ * @chainable
115
+ * @example
116
+ * ```ts
117
+ * scene.action([
118
+ * story.camera.lens({vignetteColor: "#1a0b2e", vignetteInner: "20%", vignetteOuter: "95%"}),
119
+ * story.camera.vignette(0.9, 400),
120
+ * ]);
121
+ * ```
122
+ */
123
+ lens(lens: TransformDefinitions.CameraLensProps, options?: TransformDefinitions.VisualEffectOptions): Proxied<Camera, Chained<LogicAction.Actions, Camera>>;
124
+ /**
125
+ * Return the camera to its neutral pose: centred, zoom `1`, no rotation, fully opaque, no
126
+ * filter (which also clears {@link Camera.darken}) and no lens effect — the shutter opens and
127
+ * the vignette lifts.
71
128
  *
72
129
  * Named `resetCamera` rather than `reset` because every element already owns an internal
73
130
  * `reset()` lifecycle hook — the one the engine calls when a new game starts — and an authoring
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import React from "react";
1
2
  import { TransformDefinitions } from "./type";
2
3
  import { CSSProps } from "../../elements/transition/type";
3
4
  type OverwriteMap = {
@@ -7,6 +8,30 @@ export type OverwriteDefinition = {
7
8
  [K in keyof OverwriteMap]?: OverwriteHandler<OverwriteMap[K]>;
8
9
  };
9
10
  type OverwriteHandler<T> = (value: Partial<TransformDefinitions.Types>) => T;
11
+ /**
12
+ * An element that is animated *alongside* the transform's own element, from the same transform
13
+ * state, in the same `motion` sequence.
14
+ *
15
+ * The transform pipeline drives exactly one element, and its style is built by
16
+ * {@link Transform.constructStyle} — a literal, so a prop it does not know about goes nowhere. A
17
+ * companion is the escape hatch for props whose picture belongs to a *different* element than the
18
+ * one being transformed: the camera's lens overlay, which must not inherit the camera's transform,
19
+ * is the case this exists for.
20
+ *
21
+ * `project` turns the accumulated state of a segment into that element's style for that segment.
22
+ */
23
+ export type TransformCompanion = {
24
+ el: Element;
25
+ project: (props: Partial<TransformDefinitions.Types>) => CSSProps;
26
+ };
27
+ /**
28
+ * The same thing before the elements are known — what a React host holds, resolved to
29
+ * {@link TransformCompanion} at the moment the animation is built.
30
+ */
31
+ export type TransformCompanionRef = {
32
+ ref: React.RefObject<HTMLElement | null>;
33
+ project: (props: Partial<TransformDefinitions.Types>) => CSSProps;
34
+ };
10
35
  export declare class Transform<T extends TransformDefinitions.Types = TransformDefinitions.Types> {
11
36
  /**
12
37
  * Apply transform immediately
@@ -127,6 +152,19 @@ export declare class Transform<T extends TransformDefinitions.Types = TransformD
127
152
  * Set visual effect fields in the current staging sequence.
128
153
  */
129
154
  effect(effect: TransformDefinitions.VisualEffectTransformProps): this;
155
+ /**
156
+ * Set camera lens fields in the current staging sequence.
157
+ *
158
+ * Only a {@link Camera} draws these; on any other displayable they are carried in the state and
159
+ * never painted.
160
+ * @example
161
+ * ```ts
162
+ * Transform.create<TransformDefinitions.CameraTransformProps>()
163
+ * .lens({shutter: 1}).commit({duration: 180, ease: "easeInOut"})
164
+ * .lens({shutter: 0}).commit({duration: 220, ease: "easeInOut"});
165
+ * ```
166
+ */
167
+ lens(lens: TransformDefinitions.CameraLensProps): this;
130
168
  /**
131
169
  * Set the CSS mask image of the current staging sequence.
132
170
  */
@@ -29,6 +29,50 @@ export declare namespace TransformDefinitions {
29
29
  backdropFilter?: React.CSSProperties["backdropFilter"];
30
30
  mixBlendMode?: React.CSSProperties["mixBlendMode"];
31
31
  };
32
+ /**
33
+ * The camera's lens channels.
34
+ *
35
+ * These describe things a *lens* does, not things the picture does, which is why they are not
36
+ * part of {@link VisualEffectTransformProps} and never reach an element's own style: they are
37
+ * drawn by an overlay pinned to the viewport, outside the camera's transform, so a vignette
38
+ * stays put while the camera it belongs to zooms, pans and rotates underneath it.
39
+ */
40
+ type CameraLensProps = {
41
+ /**
42
+ * How far the shutter is closed, between `0` (open) and `1` (shut).
43
+ *
44
+ * Two blades close symmetrically from the top and bottom of the frame, so at `1` each
45
+ * covers half of it. Small values are a letterbox rather than a blink: `0.12` is a
46
+ * cinematic matte.
47
+ * @default 0
48
+ */
49
+ shutter?: number;
50
+ /**
51
+ * Colour of the shutter blades.
52
+ * @default "#000"
53
+ */
54
+ shutterColor?: string;
55
+ /**
56
+ * Strength of the vignette, between `0` (none) and `1` (opaque at the edges).
57
+ * @default 0
58
+ */
59
+ vignette?: number;
60
+ /**
61
+ * Colour of the vignette.
62
+ * @default "#000"
63
+ */
64
+ vignetteColor?: string;
65
+ /**
66
+ * Radius at which the vignette starts, as a CSS length or percentage of the frame.
67
+ * @default "44%"
68
+ */
69
+ vignetteInner?: string;
70
+ /**
71
+ * Radius at which the vignette reaches full strength.
72
+ * @default "78%"
73
+ */
74
+ vignetteOuter?: string;
75
+ };
32
76
  type VisualEffectOptions = Partial<CommonTransformProps>;
33
77
  type MaskOptions = VisualEffectOptions & Pick<VisualEffectTransformProps, "maskSize" | "maskPosition" | "maskRepeat" | "maskMode">;
34
78
  type WipeDirection = "left" | "right" | "top" | "bottom";
@@ -49,7 +93,16 @@ export declare namespace TransformDefinitions {
49
93
  type TextTransformProps = CommonDisplayableConfig & {
50
94
  fontColor?: Color;
51
95
  } & VisualEffectTransformProps;
52
- type Types = CommonDisplayableConfig & ImageTransformProps & TextTransformProps;
96
+ /**
97
+ * What a camera can be transformed by: everything an image can, plus the lens channels.
98
+ */
99
+ type CameraTransformProps = ImageTransformProps & CameraLensProps;
100
+ /**
101
+ * The closed set of keys a {@link Transform} can stage a change for. Every prop any displayable
102
+ * understands has to appear here, camera-only ones included, or the chainable setters cannot
103
+ * name it.
104
+ */
105
+ type Types = CommonDisplayableConfig & ImageTransformProps & TextTransformProps & CameraLensProps;
53
106
  type SequenceProps<T> = Partial<T>;
54
107
  type SequenceOptions = Partial<CommonTransformProps>;
55
108
  type Sequence<T> = {