narraleaf-react 0.47.2 → 1.0.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.
@@ -10,7 +10,7 @@ export declare namespace TransformDefinitions {
10
10
  delay: number;
11
11
  at: TransformDefinitions.SequenceAtDefinition;
12
12
  } & {
13
- /**@deprecated */
13
+ /**@deprecated Has no effect: nothing reads it. */
14
14
  sync?: boolean;
15
15
  };
16
16
  /**
@@ -24,5 +24,10 @@ export type SoundPlayOptions = FadeOptions & {
24
24
  waitForEnd?: boolean;
25
25
  };
26
26
  export type ChainedActions = (Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>> | LogicAction.Actions)[];
27
- export type ActionStatements = ChainedActions | string[];
27
+ /**
28
+ * What a scene, a menu choice, a condition branch or a control block runs. Each entry is read on
29
+ * its own: an action or chained element runs as itself, and a plain string is a line of narration,
30
+ * so the two can sit side by side in one list.
31
+ */
32
+ export type ActionStatements = (ChainedActions[number] | string)[];
28
33
  export type { TransitionAnimationType, TransitionTask, };
@@ -1,10 +1,76 @@
1
1
  import { Image as GameImage } from "../../../nlcore/elements/displayable/image";
2
2
  import React from "react";
3
3
  import { GameState } from "../../gameState";
4
+ import { ElementProp, TransitionTask } from "../../../nlcore/elements/transition/type";
4
5
  export type ImageEvents = {
5
6
  "event:image.onLoad": [];
6
7
  };
8
+ /** A laid-out size, in CSS pixels. */
9
+ export type GroupSize = {
10
+ width: number;
11
+ height: number;
12
+ };
13
+ /**
14
+ * Where a transition puts a group that does not size the box: on the very pixels it will cover
15
+ * once it is the image at rest. `null` means exactly where a picture at rest sits.
16
+ *
17
+ * The box takes the sizing group's size, and the wrapper around it is placed by a layout anchor (a
18
+ * percentage of the stage, measured from the top - or from the bottom on an inverted axis) plus a
19
+ * `translate` of half its own size. The stage is scaled by a non-integer factor, so these lengths
20
+ * fall between device pixels, and the browser snaps layout positions to the pixel grid while
21
+ * leaving translations where they are. A group of the box's size therefore sits in it exactly as
22
+ * an image at rest does - by layout, on its corner, with no transform of its own - and comes out
23
+ * on the same pixels. That is the common case (two backgrounds of one size, a picture fading into
24
+ * itself, a character's expressions), and adding anything to it, even a translate of nothing, can
25
+ * change how a scaled wrapper's content is sampled.
26
+ *
27
+ * A group of another size has to make up the difference inside the box, and how it does so decides
28
+ * what the browser draws. Centred by layout (`top: 50%`, a flex box, auto margins), or by a
29
+ * transform alone, it lands within a pixel of its resting place but on the other side of a
30
+ * rounding; it is drawn resampled at a slightly different offset, and when the transition ends and
31
+ * the box takes its size, the whole picture steps by a fraction of a pixel and changes sharpness.
32
+ * So the difference is split the way the wrapper will split it at rest. On an axis anchored at the
33
+ * top or left the wrapper's layout position does not depend on its size: the group sits on that
34
+ * edge of the box and a translate moves it by half the size difference - the half the wrapper's own
35
+ * translate stops adding once the box has the group's size. On an inverted axis the wrapper is
36
+ * anchored at its bottom or right edge, so its layout position moves with its size: the group sits
37
+ * on that edge instead, which puts its layout position where the wrapper's will be, and the
38
+ * translate takes the other half back. Every length that gets snapped is then one that will be
39
+ * snapped at rest, and the unsnapped ones add up to the translate the wrapper will carry.
40
+ *
41
+ * Under a wrapper that also scales or rotates, the browser drops the fraction of the wrapper's own
42
+ * layout position before transforming, so on an inverted axis a group of another size can still be
43
+ * sampled a little differently from the way it will be at rest; it is never displaced.
44
+ *
45
+ * Transitions that move a group write the independent `translate` property, which composes with
46
+ * this.
47
+ */
48
+ export declare function transitionGroupPlacement(box: GroupSize, own: GroupSize, invertX: boolean, invertY: boolean): React.CSSProperties | null;
7
49
  export declare function stackStyle(darkness: number): React.CSSProperties;
50
+ /**
51
+ * The props each group of a running transition sits on, index-aligned with the transition's
52
+ * resolvers; a resolver's own frame is merged over them.
53
+ *
54
+ * The group that sizes the box stays exactly as it is at rest, and every other group the transition
55
+ * shows sits where it will rest once it sizes the box itself (see `transitionGroupPlacement`), so
56
+ * neither moves, nor changes how it is sampled, when the transition starts or when it ends. A
57
+ * group whose size is not known yet has not loaded and shows nothing; it is placed as at rest until
58
+ * it has. A keyed resolver drives a picture - a stack wrapper on the layered path - and an unkeyed
59
+ * one drives an element of the transition's own (ThroughColor's colour frame), centred over the box
60
+ * and gone once the transition ends.
61
+ *
62
+ * None of these names a `src`: each side's resolver carries its own. A base that named one would
63
+ * point the outgoing picture somewhere else for the moment between the two writes, which is long
64
+ * enough for the browser to drop the decoded picture and paint a frame without it.
65
+ */
66
+ export declare function transitionGroupProps(resolve: TransitionTask<HTMLImageElement, any>["resolve"], options: {
67
+ layered: boolean;
68
+ darkness: number;
69
+ invertX: boolean;
70
+ invertY: boolean;
71
+ /** The laid-out size of each group, index-aligned with `resolve`, where it is known. */
72
+ sizes: (GroupSize | undefined)[];
73
+ }): ElementProp<HTMLImageElement>[];
8
74
  declare function ImageComponent({ image, state, }: Readonly<{
9
75
  image: GameImage;
10
76
  state: GameState;
@@ -468,10 +468,10 @@ export declare class GameState {
468
468
  getStorable(): Storable;
469
469
  getSceneByName(name: string): Scene | null;
470
470
  getStory(): Story;
471
- setInterval(callback: () => void, delay: number): NodeJS.Timeout;
472
- clearInterval(interval: NodeJS.Timeout): void;
473
- setTimeout(callback: () => void, delay: number): NodeJS.Timeout;
474
- clearTimeout(timeout: NodeJS.Timeout): void;
471
+ setInterval(callback: () => void, delay: number): ReturnType<typeof setInterval>;
472
+ clearInterval(interval: ReturnType<typeof setInterval>): void;
473
+ setTimeout(callback: () => void, delay: number): ReturnType<typeof setTimeout>;
474
+ clearTimeout(timeout: ReturnType<typeof setTimeout>): void;
475
475
  forceAnimation(): Awaitable;
476
476
  /**
477
477
  * Mounts a new state to the game state manager