@glissade/scene 0.19.0-pre.4 → 0.19.0-pre.5

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.
package/dist/describe.js CHANGED
@@ -22,7 +22,7 @@ import { easings, listValueTypes } from "@glissade/core";
22
22
  * never pulled onto the base embed path — a scene that never calls `describe()`
23
23
  * pays zero bytes for it.
24
24
  */
25
- const RAW_VERSION = "0.19.0-pre.4";
25
+ const RAW_VERSION = "0.19.0-pre.5";
26
26
  const PACKAGE_VERSION = RAW_VERSION.includes("GLISSADE_".concat("VERSION")) ? "0.0.0-dev" : RAW_VERSION;
27
27
  /** Arity of a value type's numeric repr: vec2/vec2-arc → 2, number → 1; others (color/paint/path/string/boolean) carry no scalar arity. */
28
28
  function arityOf(type) {
@@ -209,7 +209,7 @@ const BUILDER_METHODS = [
209
209
  },
210
210
  {
211
211
  name: "tracks",
212
- signature: "tracks(tracks: Track[]): TimelineBuilder"
212
+ signature: "tracks(tracks: Track[] | { tracks: Track[] }): TimelineBuilder"
213
213
  },
214
214
  {
215
215
  name: "set",
package/dist/type.d.ts CHANGED
@@ -21,6 +21,12 @@ interface SplitTextOpts {
21
21
  }
22
22
  /** One part of a split, in the source Text's draw space (group-local coords). */
23
23
  interface SplitPart {
24
+ /**
25
+ * The part's registered node id — `${id}/${i}`, the SAME string the child
26
+ * Text was constructed with. Bind a track straight against it:
27
+ * `parts.map((p) => p.id + '/revealFraction')` (or use `result.targets(prop)`).
28
+ */
29
+ id: string;
24
30
  /** The part's text (a word, a full line, or a single grapheme). */
25
31
  text: string;
26
32
  /** The generated child node (a left-aligned Text positioned at the part). */
@@ -42,6 +48,12 @@ interface SplitTextResult {
42
48
  children: Text[];
43
49
  /** Per-part geometry + node, in reading order. */
44
50
  parts: SplitPart[];
51
+ /**
52
+ * Ready-to-bind track targets — `[`${id}/0/${prop}`, `${id}/1/${prop}`, …]`
53
+ * in reading order. The blessed kinetic-typography recipe is one line:
54
+ * `tl.stagger(result.targets('revealFraction'), { from: 0, to: 1 }, { each: 0.1 })`.
55
+ */
56
+ targets(prop: string): string[];
45
57
  }
46
58
  declare class SplitTextError extends Error {
47
59
  constructor(message: string);
@@ -51,12 +63,14 @@ declare class SplitTextError extends Error {
51
63
  * Texts — one per word / line / grapheme. PURE build-time expansion to ordinary
52
64
  * nodes; the part geometry is a STATIC snapshot of the source's current layout.
53
65
  *
54
- * const split = splitText(title, { by: 'word', id: 'title' });
66
+ * const split = splitText(title, { by: 'word', id: 'title', measurer });
55
67
  * // scene children: [split.node] (REPLACES the original title)
56
- * // animate each word: split.children[i] / track('title/0/opacity', …)
68
+ * // animate each word: split.targets('revealFraction') === ['title/0/revealFraction', …]
69
+ * tl.stagger(split.targets('revealFraction'), { from: 0, to: 1 }, { each: 0.1 });
57
70
  *
58
- * Stagger a word-by-word reveal by fanning a clip across `split.children`, or
59
- * compose with `tl.stagger` over the `${id}/${i}` ids.
71
+ * Bind tracks against `split.targets(prop)` (ready ids, reading order) or
72
+ * `parts[i].id` / `parts[i].node` directly. `{ measurer }` is required for exact
73
+ * part geometry — see the dev-warning footgun below.
60
74
  */
61
75
  declare function splitText(source: Text | TextProps, opts?: SplitTextOpts): SplitTextResult;
62
76
  //#endregion
package/dist/type.js CHANGED
@@ -32,12 +32,14 @@ var SplitTextError = class extends Error {
32
32
  * Texts — one per word / line / grapheme. PURE build-time expansion to ordinary
33
33
  * nodes; the part geometry is a STATIC snapshot of the source's current layout.
34
34
  *
35
- * const split = splitText(title, { by: 'word', id: 'title' });
35
+ * const split = splitText(title, { by: 'word', id: 'title', measurer });
36
36
  * // scene children: [split.node] (REPLACES the original title)
37
- * // animate each word: split.children[i] / track('title/0/opacity', …)
37
+ * // animate each word: split.targets('revealFraction') === ['title/0/revealFraction', …]
38
+ * tl.stagger(split.targets('revealFraction'), { from: 0, to: 1 }, { each: 0.1 });
38
39
  *
39
- * Stagger a word-by-word reveal by fanning a clip across `split.children`, or
40
- * compose with `tl.stagger` over the `${id}/${i}` ids.
40
+ * Bind tracks against `split.targets(prop)` (ready ids, reading order) or
41
+ * `parts[i].id` / `parts[i].node` directly. `{ measurer }` is required for exact
42
+ * part geometry — see the dev-warning footgun below.
41
43
  */
42
44
  function splitText(source, opts = {}) {
43
45
  const text = source instanceof Text ? source : new Text(source);
@@ -81,8 +83,9 @@ function splitText(source, opts = {}) {
81
83
  const parts = [];
82
84
  for (let i = 0; i < boxes.length; i++) {
83
85
  const b = boxes[i];
86
+ const partId = `${id}/${i}`;
84
87
  const node = new Text({
85
- id: `${id}/${i}`,
88
+ id: partId,
86
89
  text: b.text,
87
90
  fill: font.fill,
88
91
  fontFamily: font.fontFamily,
@@ -95,6 +98,7 @@ function splitText(source, opts = {}) {
95
98
  });
96
99
  children.push(node);
97
100
  parts.push({
101
+ id: partId,
98
102
  text: b.text,
99
103
  node,
100
104
  line: b.line,
@@ -107,14 +111,17 @@ function splitText(source, opts = {}) {
107
111
  });
108
112
  }
109
113
  const [px, py] = text.position();
114
+ const node = new Group({
115
+ id,
116
+ children,
117
+ position: [px, py]
118
+ });
119
+ const targets = (prop) => parts.map((p) => `${p.id}/${prop}`);
110
120
  return {
111
- node: new Group({
112
- id,
113
- children,
114
- position: [px, py]
115
- }),
121
+ node,
116
122
  children,
117
- parts
123
+ parts,
124
+ targets
118
125
  };
119
126
  }
120
127
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/scene",
3
- "version": "0.19.0-pre.4",
3
+ "version": "0.19.0-pre.5",
4
4
  "description": "glissade scene graph: nodes, transforms, DisplayList emission. Renderer-agnostic; zero DOM/Node dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "engines": {
@@ -35,7 +35,7 @@
35
35
  ],
36
36
  "dependencies": {
37
37
  "yoga-layout": "^3.2.1",
38
- "@glissade/core": "0.19.0-pre.4"
38
+ "@glissade/core": "0.19.0-pre.5"
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",