narraleaf-react 0.17.1 → 0.18.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.
@@ -3,6 +3,7 @@ import { Chained, Proxied } from "../../action/chain";
3
3
  import { GameState } from "../../common/game";
4
4
  import { LogicAction } from "../../game";
5
5
  import type { LiveGameEventToken } from "../../types";
6
+ import { Image } from "../displayable/image";
6
7
  import { Layer } from "../layer";
7
8
  import { DynamicPersistent, Persistent } from "../persistent";
8
9
  import { Scene } from "../scene";
@@ -23,6 +24,15 @@ export declare class DevTools {
23
24
  static wrapAction(action: LogicAction.Actions[] | Proxied<LogicAction.GameElement, Chained<LogicAction.Actions>>): ControlAction;
24
25
  static getNamespaceName(persistent: Persistent<any>): string;
25
26
  static getCurrentScene(gameState: GameState): Scene | null;
27
+ /**
28
+ * The src of each of a layered image's layers, bottom to top, for the given tags (the image's
29
+ * current ones when omitted). `null` entries are layers that draw nothing; a non-layered image
30
+ * yields an empty array.
31
+ *
32
+ * A layered image has no single src to read — it is a stack — so an editor host that renders
33
+ * its own thumbnail of an on-stage element has to composite these itself, in order.
34
+ */
35
+ static getLayerSrcs(image: Image, tags?: string[]): (string | null)[];
26
36
  /**
27
37
  * Register a displayable into a scene's render tree without emitting a `displayable:init`
28
38
  * action. The element renders immediately at its constructor-config transform state
@@ -49,10 +49,21 @@ export type TagSrcResolver<T extends TagGroupDefinition> = (...tags: SelectEleme
49
49
  * A set of mutually exclusive variants for one layer, keyed by tag.
50
50
  *
51
51
  * `null` means the layer draws nothing for that tag.
52
+ *
53
+ * The tag set is the group's identity: every layer offering the *same* set of tags is driven by
54
+ * one group, which is how a single `char(["angry"])` moves the brows, the eyes and the mouth at
55
+ * once. To follow a group, repeat its whole tag set on the layer and use `null` for the tags
56
+ * where that layer draws nothing. Offering only part of a set instead declares a *different*
57
+ * group, and the shared tags then collide.
52
58
  */
53
59
  export type LayerVariants = Record<string, string | null>;
54
60
  /**
55
61
  * Derives a layer's src from the currently active tags. Declares no tags of its own.
62
+ *
63
+ * A resolver is opaque, so the srcs it can return are invisible to the preloader and are fetched
64
+ * on first use. Prefer {@link LayerVariants} — including for a layer that follows another layer's
65
+ * group, which no longer needs a resolver — and keep resolvers for sources that genuinely cannot
66
+ * be enumerated.
56
67
  */
57
68
  export type LayerResolver = (tags: ReadonlySet<string>) => string | null;
58
69
  /**
@@ -74,7 +85,8 @@ export type LayeredDefinition<L extends LayerGroupDefinition = LayerGroupDefinit
74
85
  */
75
86
  layers: L;
76
87
  /**
77
- * One tag per variant layer, in any order.
88
+ * One tag per group, in any order. Layers that offer the same tag set share a group and so
89
+ * share that one default.
78
90
  */
79
91
  defaults: readonly LayerTagsOf<L>[];
80
92
  };
@@ -88,10 +100,14 @@ export declare class Image<Tags extends TagGroupDefinition | null = TagGroupDefi
88
100
  * src: {
89
101
  * layers: [
90
102
  * "body.png",
91
- * {happy: "happy.png", sad: "sad.png"},
92
103
  * {shirt: "shirt.png", coat: "coat.png"},
104
+ * // Both layers offer {happy, sad}, so one group drives them together.
105
+ * {happy: "brows_happy.png", sad: "brows_sad.png"},
106
+ * {happy: "mouth_happy.png", sad: "mouth_sad.png"},
107
+ * // Follows the same group, and draws nothing while happy.
108
+ * {happy: null, sad: "tears.png"},
93
109
  * ],
94
- * defaults: ["happy", "shirt"],
110
+ * defaults: ["shirt", "happy"],
95
111
  * }
96
112
  * });
97
113
  * ```