narraleaf-react 0.11.0 → 0.12.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.
@@ -4,4 +4,17 @@ import { MaskTransition } from "../elements/transition/transitions/image/maskTra
4
4
  import { Transition } from "../elements/transition/transition";
5
5
  import { ImageTransition } from "../elements/transition/transitions/image/imageTransition";
6
6
  import { TextTransition } from "../elements/transition/transitions/text/textTransition";
7
- export { Transition, ImageTransition, TextTransition, Dissolve, FadeIn, MaskTransition, };
7
+ import { SoftWipe } from "../elements/transition/transitions/image/softWipe";
8
+ import { Blinds } from "../elements/transition/transitions/image/blinds";
9
+ import { SoftIris } from "../elements/transition/transitions/image/softIris";
10
+ import { BlurDissolve } from "../elements/transition/transitions/image/blurDissolve";
11
+ import { Push } from "../elements/transition/transitions/image/push";
12
+ import { ThroughColor } from "../elements/transition/transitions/image/throughColor";
13
+ export { Transition, ImageTransition, TextTransition, Dissolve, FadeIn, MaskTransition, SoftWipe, Blinds, SoftIris, BlurDissolve, Push, ThroughColor, };
14
+ export type { SoftWipeOptions } from "../elements/transition/transitions/image/softWipe";
15
+ export type { BlindsOptions } from "../elements/transition/transitions/image/blinds";
16
+ export type { SoftIrisOptions } from "../elements/transition/transitions/image/softIris";
17
+ export type { BlurDissolveOptions } from "../elements/transition/transitions/image/blurDissolve";
18
+ export type { PushOptions } from "../elements/transition/transitions/image/push";
19
+ export type { ThroughColorFadeOptions, ThroughColorWipeOptions, ThroughColorBlindsOptions, ThroughColorIrisOptions, } from "../elements/transition/transitions/image/throughColor";
20
+ export type { BlindsOrientation } from "../elements/transition/transitions/image/transitionMaskUtils";
@@ -2,6 +2,7 @@ import { ControlAction } from "../../action/actions/controlAction";
2
2
  import { Chained, Proxied } from "../../action/chain";
3
3
  import { GameState } from "../../common/game";
4
4
  import { LogicAction } from "../../game";
5
+ import { Layer } from "../layer";
5
6
  import { DynamicPersistent, Persistent } from "../persistent";
6
7
  import { Scene } from "../scene";
7
8
  export declare class DevTools {
@@ -13,5 +14,40 @@ export declare class DevTools {
13
14
  static wrapAction(action: LogicAction.Actions[] | Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>>): ControlAction;
14
15
  static getNamespaceName(persistent: Persistent<any>): string;
15
16
  static getCurrentScene(gameState: GameState): Scene | null;
17
+ /**
18
+ * Register a displayable into a scene's render tree without emitting a `displayable:init`
19
+ * action. The element renders immediately at its constructor-config transform state
20
+ * (visibility is governed by `opacity > 0`).
21
+ *
22
+ * Intended for editor hosts that pre-pose a stage: construct elements with their computed
23
+ * state as constructor config (config state survives `element.reset()` / `newGame()`), then
24
+ * register them from a `Script` action or after mount.
25
+ */
26
+ static registerDisplayable(gameState: GameState, displayable: LogicAction.DisplayableElements, scene?: Scene | null, layer?: Layer | null): void;
27
+ /**
28
+ * Assign an explicit element id. Elements reachable from a scene's action tree receive
29
+ * generated ids (`e-0`, `e-1`, ...) at story construction, but elements registered directly
30
+ * via {@link registerDisplayable} are outside the tree and would otherwise share the default
31
+ * id — colliding as React keys. Editor hosts should give those elements unique ids
32
+ * (use a distinct prefix so they never collide with generated ids).
33
+ */
34
+ static setElementId(element: LogicAction.GameElement, id: string): void;
35
+ /**
36
+ * Read a displayable's current transform-state props (position/opacity/zoom/rotation/scale/
37
+ * effects...). Returns a shallow copy. Intended for editor hosts capturing a live pose
38
+ * (e.g. prefilling a motion editor with an element's current stage state).
39
+ */
40
+ static getDisplayableTransformProps(displayable: LogicAction.DisplayableElements): Record<string, unknown>;
41
+ /**
42
+ * Overwrite a displayable's transform-state props with no animation and push the result to
43
+ * the DOM immediately when the element is mounted. With `merge: false` the previous state is
44
+ * discarded entirely; by default the given props are merged over the current state.
45
+ *
46
+ * Throws if the transform state is locked by an in-flight transform — editor hosts should
47
+ * only inject while the stage is idle.
48
+ */
49
+ static setDisplayableTransformProps(gameState: GameState, displayable: LogicAction.DisplayableElements, props: Record<string, unknown>, options?: {
50
+ merge?: boolean;
51
+ }): void;
16
52
  static DynamicPersistent: typeof DynamicPersistent;
17
53
  }
@@ -0,0 +1,28 @@
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
+ import { BlindsOrientation } from "../../../../elements/transition/transitions/image/transitionMaskUtils";
5
+ type AnimationType = [TransitionAnimationType.Number];
6
+ export type BlindsOptions = {
7
+ /** Duration in milliseconds. */
8
+ duration: number;
9
+ /** Slat orientation. @default "horizontal" */
10
+ orientation?: BlindsOrientation;
11
+ /** Number of slats. @default 8 */
12
+ slats?: number;
13
+ easing?: TransformDefinitions.EasingDefinition;
14
+ };
15
+ /**
16
+ * Venetian "blinds": the target image is revealed over the previous one through
17
+ * a set of hard-edged slats that widen until they cover the frame.
18
+ */
19
+ export declare class Blinds extends ImageTransition<AnimationType> {
20
+ private duration;
21
+ private orientation;
22
+ private slats;
23
+ private easing?;
24
+ constructor(options: BlindsOptions);
25
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
26
+ copy(): Blinds;
27
+ }
28
+ export {};
@@ -0,0 +1,24 @@
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 BlurDissolveOptions = {
6
+ /** Duration in milliseconds. */
7
+ duration: number;
8
+ /** Peak blur radius applied at the crossover, in pixels. @default 16 */
9
+ blur?: number;
10
+ easing?: TransformDefinitions.EasingDefinition;
11
+ };
12
+ /**
13
+ * A blur dissolve: the previous image blurs out and fades while the target one
14
+ * sharpens in — the dreamy crossfade used for flashbacks / dream states.
15
+ */
16
+ export declare class BlurDissolve extends ImageTransition<AnimationType> {
17
+ private duration;
18
+ private blur;
19
+ private easing?;
20
+ constructor(options: BlurDissolveOptions);
21
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
22
+ copy(): BlurDissolve;
23
+ }
24
+ export {};
@@ -0,0 +1,31 @@
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 PushOptions = {
6
+ /** Duration in milliseconds. */
7
+ duration: number;
8
+ /** Direction the previous image travels toward. @default "left" */
9
+ direction?: TransformDefinitions.WipeDirection;
10
+ easing?: TransformDefinitions.EasingDefinition;
11
+ };
12
+ /**
13
+ * A push / slide: the target image slides in from one edge while the previous
14
+ * image slides out the opposite way, as if the camera panned.
15
+ *
16
+ * The offset is applied via the independent CSS `translate` property (not
17
+ * `transform`) in viewport units. That composes additively with the layer's
18
+ * base positioning instead of overriding it, and is the identity at offset `0`,
19
+ * so neither image jumps at the start/end of the slide.
20
+ */
21
+ export declare class Push extends ImageTransition<AnimationType> {
22
+ private duration;
23
+ private direction;
24
+ private easing?;
25
+ constructor(options: PushOptions);
26
+ private axisUnit;
27
+ private translate;
28
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
29
+ copy(): Push;
30
+ }
31
+ export {};
@@ -0,0 +1,28 @@
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 SoftIrisOptions = {
6
+ /** Duration in milliseconds. */
7
+ duration: number;
8
+ /** Centre of the iris, as a CSS position. @default "50% 50%" */
9
+ center?: string;
10
+ /** Width of the soft (feathered) edge band, in percent. @default 12 */
11
+ feather?: number;
12
+ easing?: TransformDefinitions.EasingDefinition;
13
+ };
14
+ /**
15
+ * A soft, feathered iris: the target image is revealed over the previous one
16
+ * through an expanding `radial-gradient` circle with a feathered edge — the
17
+ * soft-edged counterpart of {@link MaskTransition.circle}.
18
+ */
19
+ export declare class SoftIris extends ImageTransition<AnimationType> {
20
+ private duration;
21
+ private center;
22
+ private feather;
23
+ private easing?;
24
+ constructor(options: SoftIrisOptions);
25
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
26
+ copy(): SoftIris;
27
+ }
28
+ export {};
@@ -0,0 +1,28 @@
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 SoftWipeOptions = {
6
+ /** Duration in milliseconds. */
7
+ duration: number;
8
+ /** Direction the wipe travels toward. @default "left" */
9
+ direction?: TransformDefinitions.WipeDirection;
10
+ /** Width of the soft (feathered) edge band, in percent. @default 12 */
11
+ feather?: number;
12
+ easing?: TransformDefinitions.EasingDefinition;
13
+ };
14
+ /**
15
+ * A soft, feathered directional wipe. The target image is revealed over the
16
+ * previous one through a moving `linear-gradient` alpha mask, giving a gradual
17
+ * erase rather than the hard geometric cut of {@link MaskTransition.wipe}.
18
+ */
19
+ export declare class SoftWipe extends ImageTransition<AnimationType> {
20
+ private duration;
21
+ private direction;
22
+ private feather;
23
+ private easing?;
24
+ constructor(options: SoftWipeOptions);
25
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
26
+ copy(): SoftWipe;
27
+ }
28
+ export {};
@@ -0,0 +1,67 @@
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
+ import { BlindsOrientation } from "../../../../elements/transition/transitions/image/transitionMaskUtils";
5
+ type AnimationType = [TransitionAnimationType.Number];
6
+ type ThroughColorBaseOptions = {
7
+ /** Duration in milliseconds. */
8
+ duration: number;
9
+ /** Hold colour. @default "#000000" */
10
+ color?: string;
11
+ /** Fraction (0–1) of the duration spent fully covered by the colour. @default 0.3 */
12
+ hold?: number;
13
+ easing?: TransformDefinitions.EasingDefinition;
14
+ };
15
+ export type ThroughColorFadeOptions = ThroughColorBaseOptions;
16
+ export type ThroughColorWipeOptions = ThroughColorBaseOptions & {
17
+ /** Direction the feathered edge travels toward. @default "left" */
18
+ direction?: TransformDefinitions.WipeDirection;
19
+ /** Width of the soft edge band, in percent. @default 12 */
20
+ feather?: number;
21
+ };
22
+ export type ThroughColorBlindsOptions = ThroughColorBaseOptions & {
23
+ /** Slat orientation. @default "horizontal" */
24
+ orientation?: BlindsOrientation;
25
+ /** Number of slats. @default 8 */
26
+ slats?: number;
27
+ };
28
+ export type ThroughColorIrisOptions = ThroughColorBaseOptions & {
29
+ /** Centre of the iris, as a CSS position. @default "50% 50%" */
30
+ center?: string;
31
+ /** Width of the soft edge band, in percent. @default 12 */
32
+ feather?: number;
33
+ };
34
+ /**
35
+ * The "through colour" engine. A colour overlay covers the frame using the
36
+ * chosen pattern, holds a solid-colour frame, then uncovers to reveal the
37
+ * target image — so the target never appears until *after* the colour hold. The
38
+ * previous/target images simply swap opacity at the midpoint, unseen behind the
39
+ * fully-covered frame.
40
+ *
41
+ * Created through its static factories (mirroring {@link MaskTransition}):
42
+ * - {@link ThroughColor.fade} — the overlay fades in/out (fade-to-black/white; `hold: 0` = flash).
43
+ * - {@link ThroughColor.wipe} — a feathered directional edge (soft wipe through the colour).
44
+ * - {@link ThroughColor.blinds} — venetian slats (blinds through the colour).
45
+ * - {@link ThroughColor.iris} — a circle closing from the rim in (iris to the colour).
46
+ */
47
+ export declare class ThroughColor extends ImageTransition<AnimationType> {
48
+ private duration;
49
+ private color;
50
+ private hold;
51
+ private coverMask;
52
+ private easing?;
53
+ private constructor();
54
+ /** Fade the frame to a solid colour, hold, then fade to the target. */
55
+ static fade(options: ThroughColorFadeOptions): ThroughColor;
56
+ /** Cover the frame with a feathered directional edge, hold, then uncover. */
57
+ static wipe(options: ThroughColorWipeOptions): ThroughColor;
58
+ /** Cover the frame with venetian slats, hold, then uncover. */
59
+ static blinds(options: ThroughColorBlindsOptions): ThroughColor;
60
+ /** Close a circle over the frame from the rim in, hold, then open it. */
61
+ static iris(options: ThroughColorIrisOptions): ThroughColor;
62
+ /** Style for the colour overlay at a given coverage (0 = clear, 1 = fully covered). */
63
+ private coverStyle;
64
+ createTask(): TransitionTask<HTMLImageElement, AnimationType>;
65
+ copy(): ThroughColor;
66
+ }
67
+ export {};
@@ -0,0 +1,30 @@
1
+ import { CSSProps } from "../../../../elements/transition/type";
2
+ import { TransformDefinitions } from "../../../../elements/transform/type";
3
+ /**
4
+ * Shared, side-effect-free helpers for the mask/gradient driven image
5
+ * transitions ({@link SoftWipe}, {@link Blinds}, {@link SoftIris},
6
+ * {@link ThroughColor}). Kept internal — not exported from the package barrel.
7
+ */
8
+ /** Orientation of {@link Blinds} slats / {@link ThroughColor} blinds pattern. */
9
+ export type BlindsOrientation = "horizontal" | "vertical";
10
+ /** Clamp a value into the `[0, 1]` range. */
11
+ export declare function clamp01(value: number): number;
12
+ /** The `mask-image` triplet, mirrored to the `-webkit-` prefix for WebKit. */
13
+ export declare function maskStyle(image: string): CSSProps;
14
+ /** Full-bleed positioning for a synthetic colour overlay layer. */
15
+ export declare function overlayBase(color: string): CSSProps;
16
+ /** CSS gradient direction keyword for a wipe travelling toward `direction`. */
17
+ export declare function wipeGradientDir(direction: TransformDefinitions.WipeDirection): string;
18
+ /** Gradient axis for blinds slats of a given orientation. */
19
+ export declare function blindsAxis(orientation: BlindsOrientation): string;
20
+ /**
21
+ * Feathered linear wipe mask. `progress` 0 → fully hidden, 1 → fully covered;
22
+ * the opaque edge sweeps with a soft transition band of width `feather` (%).
23
+ */
24
+ export declare function linearWipeMask(direction: TransformDefinitions.WipeDirection, feather: number, progress: number): string;
25
+ /** Venetian slats mask. `progress` 0 → open (hidden), 1 → shut (covered). */
26
+ export declare function blindsCoverMask(orientation: BlindsOrientation, slats: number, progress: number): string;
27
+ /** Iris that *covers* from the rim inward. `progress` 0 → hidden, 1 → covered. */
28
+ export declare function irisCoverMask(center: string, feather: number, progress: number): string;
29
+ /** Iris that *reveals* from the centre out. `progress` 0 → hidden, 1 → shown. */
30
+ export declare function irisRevealMask(center: string, feather: number, progress: number): string;