@wardic/dom 1.3.2 → 1.5.0-next.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.
Files changed (112) hide show
  1. package/dist/Color.d.ts +2 -1
  2. package/dist/Color.d.ts.map +1 -1
  3. package/dist/Color.js +3 -1
  4. package/dist/Color.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/batch-writer.d.ts.map +1 -1
  10. package/dist/internal/batch-writer.js +9 -13
  11. package/dist/internal/batch-writer.js.map +1 -1
  12. package/dist/internal/clock.d.ts +3 -3
  13. package/dist/internal/clock.d.ts.map +1 -1
  14. package/dist/internal/clock.js +25 -7
  15. package/dist/internal/clock.js.map +1 -1
  16. package/dist/internal/colorSpaces.d.ts +8 -0
  17. package/dist/internal/colorSpaces.d.ts.map +1 -0
  18. package/dist/internal/colorSpaces.js +26 -0
  19. package/dist/internal/colorSpaces.js.map +1 -0
  20. package/dist/internal/colors.d.ts +0 -7
  21. package/dist/internal/colors.d.ts.map +1 -1
  22. package/dist/internal/colors.js +3 -15
  23. package/dist/internal/colors.js.map +1 -1
  24. package/dist/internal/default-transition.d.ts +2 -2
  25. package/dist/internal/default-transition.d.ts.map +1 -1
  26. package/dist/internal/default-transition.js +23 -9
  27. package/dist/internal/default-transition.js.map +1 -1
  28. package/dist/internal/input.d.ts.map +1 -1
  29. package/dist/internal/input.js +18 -0
  30. package/dist/internal/input.js.map +1 -1
  31. package/dist/internal/layout-box.d.ts +29 -0
  32. package/dist/internal/layout-box.d.ts.map +1 -0
  33. package/dist/internal/layout-box.js +48 -0
  34. package/dist/internal/layout-box.js.map +1 -0
  35. package/dist/internal/measure.d.ts +1 -19
  36. package/dist/internal/measure.d.ts.map +1 -1
  37. package/dist/internal/measure.js +4 -47
  38. package/dist/internal/measure.js.map +1 -1
  39. package/dist/internal/projection.d.ts +5 -1
  40. package/dist/internal/projection.d.ts.map +1 -1
  41. package/dist/internal/projection.js +45 -10
  42. package/dist/internal/projection.js.map +1 -1
  43. package/dist/internal/renderer.d.ts +36 -14
  44. package/dist/internal/renderer.d.ts.map +1 -1
  45. package/dist/internal/renderer.js +213 -118
  46. package/dist/internal/renderer.js.map +1 -1
  47. package/dist/internal/reorder.d.ts +7 -0
  48. package/dist/internal/reorder.d.ts.map +1 -1
  49. package/dist/internal/reorder.js +41 -21
  50. package/dist/internal/reorder.js.map +1 -1
  51. package/dist/internal/starting-style.js +5 -5
  52. package/dist/internal/transform-keys.d.ts +3 -2
  53. package/dist/internal/transform-keys.d.ts.map +1 -1
  54. package/dist/internal/transform-keys.js +21 -9
  55. package/dist/internal/transform-keys.js.map +1 -1
  56. package/dist/unstable/BatchMembers.js +1 -1
  57. package/dist/unstable/DragTrack.d.ts +1 -1
  58. package/dist/unstable/DragTrack.d.ts.map +1 -1
  59. package/dist/unstable/DragTrack.js +16 -4
  60. package/dist/unstable/DragTrack.js.map +1 -1
  61. package/dist/unstable/ElementSetup.js +1 -1
  62. package/dist/unstable/Feature.d.ts +3 -2
  63. package/dist/unstable/Feature.d.ts.map +1 -1
  64. package/dist/unstable/Feature.js +3 -2
  65. package/dist/unstable/Feature.js.map +1 -1
  66. package/dist/unstable/GestureFeatures.d.ts +6 -1
  67. package/dist/unstable/GestureFeatures.d.ts.map +1 -1
  68. package/dist/unstable/GestureFeatures.js +8 -3
  69. package/dist/unstable/GestureFeatures.js.map +1 -1
  70. package/dist/unstable/GestureInfo.d.ts +11 -0
  71. package/dist/unstable/GestureInfo.d.ts.map +1 -1
  72. package/dist/unstable/GestureInfo.js +8 -0
  73. package/dist/unstable/GestureInfo.js.map +1 -1
  74. package/dist/unstable/Imperative.d.ts +1 -1
  75. package/dist/unstable/Imperative.d.ts.map +1 -1
  76. package/dist/unstable/Imperative.js.map +1 -1
  77. package/dist/unstable/MemberHold.js +1 -1
  78. package/dist/unstable/MemberHold.js.map +1 -1
  79. package/dist/unstable/PresenceController.d.ts +36 -0
  80. package/dist/unstable/PresenceController.d.ts.map +1 -1
  81. package/dist/unstable/PresenceController.js +41 -17
  82. package/dist/unstable/PresenceController.js.map +1 -1
  83. package/dist/unstable/WardConfig.d.ts +5 -5
  84. package/dist/unstable/WardConfig.d.ts.map +1 -1
  85. package/dist/unstable/features/TimelineKeys.js +1 -1
  86. package/package.json +3 -3
  87. package/src/Color.ts +2 -1
  88. package/src/index.ts +2 -2
  89. package/src/internal/batch-writer.ts +9 -14
  90. package/src/internal/clock.ts +25 -7
  91. package/src/internal/colorSpaces.ts +27 -0
  92. package/src/internal/colors.ts +3 -36
  93. package/src/internal/default-transition.ts +22 -8
  94. package/src/internal/input.ts +18 -0
  95. package/src/internal/layout-box.ts +57 -0
  96. package/src/internal/measure.ts +4 -47
  97. package/src/internal/projection.ts +58 -12
  98. package/src/internal/renderer.ts +243 -122
  99. package/src/internal/reorder.ts +51 -24
  100. package/src/internal/starting-style.ts +5 -5
  101. package/src/internal/transform-keys.ts +21 -9
  102. package/src/unstable/BatchMembers.ts +1 -1
  103. package/src/unstable/DragTrack.ts +25 -5
  104. package/src/unstable/ElementSetup.ts +1 -1
  105. package/src/unstable/Feature.ts +4 -3
  106. package/src/unstable/GestureFeatures.ts +15 -3
  107. package/src/unstable/GestureInfo.ts +24 -0
  108. package/src/unstable/Imperative.ts +1 -0
  109. package/src/unstable/MemberHold.ts +1 -1
  110. package/src/unstable/PresenceController.ts +42 -19
  111. package/src/unstable/WardConfig.ts +5 -5
  112. package/src/unstable/features/TimelineKeys.ts +1 -1
@@ -19,8 +19,30 @@
19
19
  */
20
20
  import type * as Point from "@wardic/core/Point";
21
21
  import * as Renderer from "@wardic/core/Renderer";
22
+ import * as Projector from "@wardic/core/unstable/Projector";
22
23
  import * as Layer from "effect/Layer";
23
24
  import * as Option from "effect/Option";
25
+ /** Default unit appended to a bare numeric transform value, by transform key. */
26
+ type TransformUnit = "px" | "deg" | "";
27
+ /** A transform key's default unit; none for a key the table doesn't name. */
28
+ export declare const unitOf: (key: string) => TransformUnit;
29
+ /** A transform function `project` draws, and the text either side of its value, made once. */
30
+ export interface TransformFunc {
31
+ /** The property name accepted on engine values, shorthands `x`/`y`/`z` included. */
32
+ readonly key: string;
33
+ /** The CSS function name it renders as. */
34
+ readonly fn: string;
35
+ /** The value at which `project` leaves the key out (ADR-0023). */
36
+ readonly identity: number;
37
+ /** What goes before its value as the transform's first function: `translateX(`. */
38
+ readonly open: string;
39
+ /** What goes before its value after another function: ` translateX(`. */
40
+ readonly openAfter: string;
41
+ /** What goes after a number of it: its unit, and the bracket, `px)`. */
42
+ readonly close: string;
43
+ }
44
+ /** The element's own depth's function, `perspective()`: a plain render, a projection and a Batch draw it first. */
45
+ export declare const DEPTH_FUNC: TransformFunc;
24
46
  /**
25
47
  * CSS transform functions in their canonical emission order: the element's own
26
48
  * depth, then the translate group, then scale, then rotate, then skew. `project` walks this list and emits a
@@ -28,24 +50,16 @@ import * as Option from "effect/Option";
28
50
  * resulting `transform` string is always grouped in this order regardless of
29
51
  * input key order.
30
52
  *
31
- * `key` is the property name accepted on engine values (shorthands `x`/`y`/`z`
32
- * included); `fn` is the CSS function name it renders as; `identity` is the DOM's
33
- * (core's, ADR-0022, and the DOM's own), the value at which `project` leaves the key out (ADR-0023).
34
- * The element's own depth is left out below it too (`TransformKeys.drawsDepth`).
53
+ * `identity` is the DOM's (core's, ADR-0022, and the DOM's own). The element's own depth is left out below it
54
+ * too (`TransformKeys.drawsDepth`).
35
55
  */
36
- export declare const TRANSFORM_FUNCS: ReadonlyArray<{
37
- readonly key: string;
38
- readonly fn: string;
39
- readonly identity: number;
40
- }>;
56
+ export declare const TRANSFORM_FUNCS: ReadonlyArray<TransformFunc>;
41
57
  /**
42
58
  * Whether `key`'s `value` adds to the element's `transform` (#240): a transform key it draws, a
43
59
  * `transform` string, the projection's value or a Transform template. A Timeline value drawing
44
60
  * `transform` runs only while nothing else does. Per frame: statements.
45
61
  */
46
62
  export declare const addsToTransform: (key: string, value: unknown) => boolean;
47
- /** Default unit appended to a bare numeric transform value, by transform key. */
48
- type TransformUnit = "px" | "deg" | "";
49
63
  export { LENGTH_KEYS, type LengthKey } from "./length-keys.ts";
50
64
  /**
51
65
  * `key`'s own transform function for `value`, drawn even at its identity: a Timeline value's keyframe
@@ -53,8 +67,6 @@ export { LENGTH_KEYS, type LengthKey } from "./length-keys.ts";
53
67
  * that isn't a transform key.
54
68
  */
55
69
  export declare const transformFunctionOf: (key: string, value: unknown) => Option.Option<string>;
56
- /** A transform key's default unit; none for a key the table doesn't name. */
57
- export declare const unitOf: (key: string) => TransformUnit;
58
70
  /**
59
71
  * The unit {@link project} draws a bare number of `key` in: a transform key's (`px`, `deg`, or none
60
72
  * for a scale), `px` for a length key, none for the rest. The Appear sampler judges its stops in it
@@ -122,6 +134,16 @@ export declare const heldTransformOf: (values: Readonly<Record<string, unknown>>
122
134
  * DomRenderer.project({ x: 0, scale: 1, width: 200 }) // { transform: "none", width: "200px" }
123
135
  */
124
136
  export declare const project: (values: Readonly<Record<string, unknown>>) => Renderer.Patch;
125
- /** Core's `Renderer` for the DOM: `project` and a `commit` that writes a patch onto an element's style. It needs nothing. */
137
+ /**
138
+ * One element's projector (#1030): its values drawn as {@link project} draws them, each number as the text
139
+ * `commit` writes, into a patch of its own that it rewrites in place at its next call. Its patch stays the
140
+ * same object while the element's keys do; when they change, a new one holds them, so a key that went is
141
+ * never written again. The gate makes one for each element it registers.
142
+ */
143
+ export declare const makeProjector: () => Projector.Projector;
144
+ /**
145
+ * Core's `Renderer` for the DOM: `project` and a `commit` that writes a patch onto an element's style, with a
146
+ * projector for each element the Flush gate draws. It needs nothing.
147
+ */
126
148
  export declare const RendererDomLive: Layer.Layer<Renderer.Renderer>;
127
149
  //# sourceMappingURL=renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/internal/renderer.ts"],"names":[],"mappings":"AAA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AAM,WAAW,WAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAG,MAAoC,CAAA;AAE5G;;;;GAIG;AAEH,eAAO,MAAM,YAAY,WAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAG,MAAqC,CAAA;AA8D9G;;;;GAIG;AAEH,eAAO,MAAM,YAAY,uBAAuB,CAAA;AAEhD;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;AAyHhH;;;;GAIG;AAEH,eAAO,MAAM,eAAe,WAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAG,MAI3E,CAAA;AAoBD;;;;;;;;;;GAUG;AAGH,eAAO,MAAM,OAAO,WAAY,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAG,QAAQ,CAAC,KAI5E,CAAA;AAoFD;;;;;GAKG;AAGH,eAAO,MAAM,aAAa,QAAO,SAAS,CAAC,SAiB1C,CAAA;AA4BD;;;GAGG;AAGH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAA0F,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import * as Projection from "@wardic/core/Projection";
2
2
  import * as Renderer from "@wardic/core/Renderer";
3
+ import * as Projector from "@wardic/core/unstable/Projector";
3
4
  import { dashCase, isSvgInner, setSvgAttrs, splitPatch } from "./svg.js";
4
5
  import { LENGTH_KEY_SET } from "./length-keys.js";
5
6
  import * as TransformKeys from "./transform-keys.js";
@@ -9,6 +10,52 @@ import * as Layer from "effect/Layer";
9
10
  import * as Option from "effect/Option";
10
11
  import * as Predicate from "effect/Predicate";
11
12
  import * as UndefinedOr from "effect/UndefinedOr";
13
+ /**
14
+ * Default-unit map for transform values: translate (and the x/y/z shorthands)
15
+ * are lengths → `px`, as is the element's own depth; rotate/skew are angles → `deg`; scale* are unitless.
16
+ * A value that is already a string is used verbatim (explicit units honoured),
17
+ * so this map only drives the formatting of bare numbers.
18
+ */
19
+ const TRANSFORM_UNITS = {
20
+ [TransformKeys.PERSPECTIVE]: "px",
21
+ x: "px",
22
+ y: "px",
23
+ z: "px",
24
+ translateX: "px",
25
+ translateY: "px",
26
+ translateZ: "px",
27
+ scale: "",
28
+ scaleX: "",
29
+ scaleY: "",
30
+ scaleZ: "",
31
+ rotate: "deg",
32
+ pathRotation: "deg",
33
+ rotateX: "deg",
34
+ rotateY: "deg",
35
+ rotateZ: "deg",
36
+ skewX: "deg",
37
+ skewY: "deg",
38
+ };
39
+ /** A transform key's default unit; none for a key the table doesn't name. */
40
+ // Exported for the Batch writer (#665).
41
+ export const unitOf = (key) => {
42
+ const unit = TRANSFORM_UNITS[key];
43
+ if (Predicate.isUndefined(unit))
44
+ return "";
45
+ return unit;
46
+ };
47
+ /** `key`'s transform function, drawn as `fn`, with its identity and its text. */
48
+ const funcOf = (key, fn) => ({
49
+ key,
50
+ fn,
51
+ identity: UndefinedOr.getOrThrow(TransformKeys.TRANSFORM_IDENTITY[key]),
52
+ open: `${fn}(`,
53
+ openAfter: ` ${fn}(`,
54
+ close: `${unitOf(key)})`,
55
+ });
56
+ /** The element's own depth's function, `perspective()`: a plain render, a projection and a Batch draw it first. */
57
+ // Exported for the Batch writer (#665).
58
+ export const DEPTH_FUNC = funcOf(TransformKeys.PERSPECTIVE, "perspective");
12
59
  /**
13
60
  * CSS transform functions in their canonical emission order: the element's own
14
61
  * depth, then the translate group, then scale, then rotate, then skew. `project` walks this list and emits a
@@ -16,38 +63,37 @@ import * as UndefinedOr from "effect/UndefinedOr";
16
63
  * resulting `transform` string is always grouped in this order regardless of
17
64
  * input key order.
18
65
  *
19
- * `key` is the property name accepted on engine values (shorthands `x`/`y`/`z`
20
- * included); `fn` is the CSS function name it renders as; `identity` is the DOM's
21
- * (core's, ADR-0022, and the DOM's own), the value at which `project` leaves the key out (ADR-0023).
22
- * The element's own depth is left out below it too (`TransformKeys.drawsDepth`).
66
+ * `identity` is the DOM's (core's, ADR-0022, and the DOM's own). The element's own depth is left out below it
67
+ * too (`TransformKeys.drawsDepth`).
23
68
  */
24
- // Exported for the Batch writer (#665), which draws a member's transform in the same order.
69
+ // Exported for the Batch writer (#665), which draws a member's transform in the same order. #1030: each
70
+ // function's text is made here once, so a frame's transform costs its numbers' text and the joins alone.
25
71
  export const TRANSFORM_FUNCS = [
26
72
  // The element's own depth (#887), Motion's `transformPerspective`: first, so it projects what follows.
27
- { key: TransformKeys.PERSPECTIVE, fn: "perspective" },
73
+ DEPTH_FUNC,
28
74
  // translate group — shorthands x/y/z map onto translateX/Y/Z
29
- { key: "x", fn: "translateX" },
30
- { key: "y", fn: "translateY" },
31
- { key: "z", fn: "translateZ" },
32
- { key: "translateX", fn: "translateX" },
33
- { key: "translateY", fn: "translateY" },
34
- { key: "translateZ", fn: "translateZ" },
75
+ funcOf("x", "translateX"),
76
+ funcOf("y", "translateY"),
77
+ funcOf("z", "translateZ"),
78
+ funcOf("translateX", "translateX"),
79
+ funcOf("translateY", "translateY"),
80
+ funcOf("translateZ", "translateZ"),
35
81
  // scale group — `scale` is uniform scale(v); scaleX/scaleY are per-axis (flip)
36
- { key: "scale", fn: "scale" },
37
- { key: "scaleX", fn: "scaleX" },
38
- { key: "scaleY", fn: "scaleY" },
82
+ funcOf("scale", "scale"),
83
+ funcOf("scaleX", "scaleX"),
84
+ funcOf("scaleY", "scaleY"),
39
85
  // A scene's third scale (#883), core's transform key since ADR-0069 decision 4: CSS's `scaleZ()`.
40
- { key: "scaleZ", fn: "scaleZ" },
86
+ funcOf("scaleZ", "scaleZ"),
41
87
  // rotate group: a path's turn after the element's own (#438), which `rotate(a) rotate(b)` adds up
42
- { key: "rotate", fn: "rotate" },
43
- { key: "pathRotation", fn: "rotate" },
44
- { key: "rotateX", fn: "rotateX" },
45
- { key: "rotateY", fn: "rotateY" },
46
- { key: "rotateZ", fn: "rotateZ" },
88
+ funcOf("rotate", "rotate"),
89
+ funcOf("pathRotation", "rotate"),
90
+ funcOf("rotateX", "rotateX"),
91
+ funcOf("rotateY", "rotateY"),
92
+ funcOf("rotateZ", "rotateZ"),
47
93
  // skew group
48
- { key: "skewX", fn: "skewX" },
49
- { key: "skewY", fn: "skewY" },
50
- ].map((f) => ({ ...f, identity: UndefinedOr.getOrThrow(TransformKeys.TRANSFORM_IDENTITY[f.key]) }));
94
+ funcOf("skewX", "skewX"),
95
+ funcOf("skewY", "skewY"),
96
+ ];
51
97
  /**
52
98
  * What a plain render walks: every transform function but the element's own depth, which it draws ahead
53
99
  * of them in a statement of its own.
@@ -88,32 +134,6 @@ const numberOr = (value, fallback) => {
88
134
  return value;
89
135
  return fallback;
90
136
  };
91
- /**
92
- * Default-unit map for transform values: translate (and the x/y/z shorthands)
93
- * are lengths → `px`, as is the element's own depth; rotate/skew are angles → `deg`; scale* are unitless.
94
- * A value that is already a string is used verbatim (explicit units honoured),
95
- * so this map only drives the formatting of bare numbers.
96
- */
97
- const TRANSFORM_UNITS = {
98
- [TransformKeys.PERSPECTIVE]: "px",
99
- x: "px",
100
- y: "px",
101
- z: "px",
102
- translateX: "px",
103
- translateY: "px",
104
- translateZ: "px",
105
- scale: "",
106
- scaleX: "",
107
- scaleY: "",
108
- scaleZ: "",
109
- rotate: "deg",
110
- pathRotation: "deg",
111
- rotateX: "deg",
112
- rotateY: "deg",
113
- rotateZ: "deg",
114
- skewX: "deg",
115
- skewY: "deg",
116
- };
117
137
  // The lengths a bare number on is drawn in px: a module of their own, which `LiveStyle` reads too without
118
138
  // bringing the renderer (#887; a three Stage's apps ship `LiveStyle`, not the renderer).
119
139
  export { LENGTH_KEYS } from "./length-keys.js";
@@ -128,20 +148,40 @@ const formatTransformValue = (key, value) => {
128
148
  return `${value}${unitOf(key)}`;
129
149
  return String(value);
130
150
  };
151
+ /**
152
+ * `transform` with `func` drawn after it at `value`: a number in the function's unit, a string verbatim, as
153
+ * {@link formatTransformValue} formats it. Per frame: the function's text is its own, made once, so this
154
+ * makes the value's text and the joins alone.
155
+ */
156
+ // #1030 (Q6): the loop's form, prefix and suffix made once; byte for byte what the template literal drew.
157
+ const withFunction = (transform, func, value) => {
158
+ const open = termOf(transform, func.open, func.openAfter);
159
+ if (Predicate.isNumber(value))
160
+ return open + value + func.close;
161
+ if (Predicate.isString(value))
162
+ return open + value + ")";
163
+ return open + String(value) + ")";
164
+ };
165
+ /** `transform` and `term` after it, with a space between them: either alone when the other is `""`. */
166
+ const spaced = (transform, term) => {
167
+ if (term === "")
168
+ return transform;
169
+ if (transform === "")
170
+ return term;
171
+ return transform + " " + term;
172
+ };
173
+ /** `transform` and what opens a term after it: `first` when it's the first, else `after`, its text with a space ahead. */
174
+ const termOf = (transform, first, after) => {
175
+ if (transform === "")
176
+ return first;
177
+ return transform + after;
178
+ };
131
179
  /**
132
180
  * `key`'s own transform function for `value`, drawn even at its identity: a Timeline value's keyframe
133
181
  * (#240), so each blends with its neighbours as one function, as the gate's values do. `None` for a key
134
182
  * that isn't a transform key.
135
183
  */
136
- export const transformFunctionOf = (key, value) => Option.map(Arr.findFirst(TRANSFORM_FUNCS, (f) => f.key === key), ({ fn }) => `${fn}(${formatTransformValue(key, value)})`);
137
- /** A transform key's default unit; none for a key the table doesn't name. */
138
- // Exported for the Batch writer (#665).
139
- export const unitOf = (key) => {
140
- const unit = TRANSFORM_UNITS[key];
141
- if (Predicate.isUndefined(unit))
142
- return "";
143
- return unit;
144
- };
184
+ export const transformFunctionOf = (key, value) => Option.map(Arr.findFirst(TRANSFORM_FUNCS, (f) => f.key === key), (func) => withFunction("", func, value));
145
185
  /**
146
186
  * The unit {@link project} draws a bare number of `key` in: a transform key's (`px`, `deg`, or none
147
187
  * for a scale), `px` for a length key, none for the rest. The Appear sampler judges its stops in it
@@ -157,6 +197,8 @@ const formatStyleValue = (key, value) => {
157
197
  return `${value}px`;
158
198
  return value;
159
199
  };
200
+ /** The keys {@link PROJECTION_WOVEN} weaves. */
201
+ const WOVEN_KEYS = new Set(["rotate", "pathRotation", "rotateX", "rotateY", "rotateZ", "skewX", "skewY"]);
160
202
  /**
161
203
  * User-animated transform funcs woven INTO a projection transform (ADR-0009,
162
204
  * Motion's `buildProjectionTransform`): `rotate`/`skew` compose with a layout
@@ -166,15 +208,8 @@ const formatStyleValue = (key, value) => {
166
208
  * `scale`/`scaleX`/`scaleY` multiply the element scale ({@link ownScale}), and `z` is folded
167
209
  * into the projection's `translate3d` (handled inline).
168
210
  */
169
- const PROJECTION_WOVEN = [
170
- { key: "rotate", fn: "rotate" },
171
- { key: "pathRotation", fn: "rotate" },
172
- { key: "rotateX", fn: "rotateX" },
173
- { key: "rotateY", fn: "rotateY" },
174
- { key: "rotateZ", fn: "rotateZ" },
175
- { key: "skewX", fn: "skewX" },
176
- { key: "skewY", fn: "skewY" },
177
- ];
211
+ // The table's own entries, in its order, so each one's text is made once (#1030).
212
+ const PROJECTION_WOVEN = Arr.filter(TRANSFORM_FUNCS, (f) => WOVEN_KEYS.has(f.key));
178
213
  /**
179
214
  * The element's own scale on one axis (ADR-0009 *Amendment (Reorder)*): `scale` times
180
215
  * `scaleX` (or `scaleY`), 1 for an absent or non-numeric value. Motion renders a
@@ -274,7 +309,19 @@ export const ownOpacityOf = (values) => numberOr(values.opacity, 1);
274
309
  * result is `"none"` (an identity projection carrying no woven transform).
275
310
  */
276
311
  const buildProjectionTransform = (delta, treeScale, latest, rotate) => {
277
- const funcs = [];
312
+ // #1030 (Q10): built term by term in its order, each term's text made once, with no array joined: what
313
+ // `funcs.join(" ")` drew, byte for byte. Per element per frame, while a layout animation moves it.
314
+ let transform = "";
315
+ // The element's own depth heads it all, as Motion's `buildProjectionTransform` puts it, so it projects
316
+ // what follows (#887).
317
+ const depth = latest[TransformKeys.PERSPECTIVE];
318
+ if (Predicate.isNotUndefined(depth) && TransformKeys.drawsDepth(depth))
319
+ transform = withFunction(transform, DEPTH_FUNC, depth);
320
+ // An own translate in another unit than px (`x: "-100%"`) can't be added to the projection's pixels,
321
+ // so it's drawn before them, and the browser resolves it against the element's own box (#594). The
322
+ // projection's own math (a handover's start) counts it as 0.
323
+ transform = spaced(transform, otherUnitTranslate(latest["x"], latest["y"]));
324
+ transform = spaced(transform, otherUnitTranslate(latest["translateX"], latest["translateY"]));
278
325
  // The element's own translate, in page pixels, on the projection's: divided by the tree scale
279
326
  // together, as Motion's target box carries it (#363).
280
327
  const tx = (delta.x.translate + ownTranslate(latest, "x", "translateX")) / treeScale.x;
@@ -282,42 +329,30 @@ const buildProjectionTransform = (delta, treeScale, latest, rotate) => {
282
329
  const z = latest["z"];
283
330
  const translateZ = latest["translateZ"];
284
331
  if (tx !== 0 || ty !== 0 || (Predicate.isNotUndefined(z) && !isIdentity(z, 0)) || (Predicate.isNotUndefined(translateZ) && !isIdentity(translateZ, 0))) {
285
- funcs.push(`translate3d(${tx}px, ${ty}px, ${zArgOf(z, translateZ)})`);
332
+ transform = termOf(transform, "translate3d(", " translate3d(") + tx + "px, " + ty + "px, " + zArgOf(z, translateZ) + ")";
286
333
  }
287
334
  if (treeScale.x !== 1 || treeScale.y !== 1) {
288
- funcs.push(`scale(${1 / treeScale.x}, ${1 / treeScale.y})`);
335
+ transform = termOf(transform, "scale(", " scale(") + 1 / treeScale.x + ", " + 1 / treeScale.y + ")";
289
336
  }
290
- for (const { key, fn } of PROJECTION_WOVEN) {
337
+ for (let i = 0; i < PROJECTION_WOVEN.length; i++) {
338
+ const func = PROJECTION_WOVEN[i];
339
+ const key = func.key;
291
340
  // A handover's blended rotation stands in for the element's own (ADR-0010, *Amendment (#166)*).
292
341
  if (key === "rotate" && Predicate.isNotUndefined(rotate)) {
293
342
  if (rotate !== 0)
294
- funcs.push(`rotate(${formatTransformValue(key, rotate)})`);
343
+ transform = withFunction(transform, func, rotate);
295
344
  continue;
296
345
  }
297
346
  if (Object.hasOwn(latest, key) && !isIdentity(latest[key], 0))
298
- funcs.push(`${fn}(${formatTransformValue(key, latest[key])})`);
347
+ transform = withFunction(transform, func, latest[key]);
299
348
  }
300
349
  const sx = delta.x.scale * treeScale.x * ownScale(latest, "scaleX");
301
350
  const sy = delta.y.scale * treeScale.y * ownScale(latest, "scaleY");
302
351
  if (sx !== 1 || sy !== 1)
303
- funcs.push(`scale(${sx}, ${sy})`);
304
- // An own translate in another unit than px (`x: "-100%"`) can't be added to the projection's pixels,
305
- // so it's drawn before them, and the browser resolves it against the element's own box (#594). The
306
- // projection's own math (a handover's start) counts it as 0.
307
- const ownByUnit = otherUnitTranslate(latest["x"], latest["y"]);
308
- const translateByUnit = otherUnitTranslate(latest["translateX"], latest["translateY"]);
309
- if (translateByUnit !== "")
310
- funcs.unshift(translateByUnit);
311
- if (ownByUnit !== "")
312
- funcs.unshift(ownByUnit);
313
- // The element's own depth heads it all, as Motion's `buildProjectionTransform` puts it, so it projects
314
- // what follows (#887).
315
- const depth = latest[TransformKeys.PERSPECTIVE];
316
- if (Predicate.isNotUndefined(depth) && TransformKeys.drawsDepth(depth))
317
- funcs.unshift(`perspective(${formatTransformValue(TransformKeys.PERSPECTIVE, depth)})`);
318
- if (funcs.length === 0)
352
+ transform = termOf(transform, "scale(", " scale(") + sx + ", " + sy + ")";
353
+ if (transform === "")
319
354
  return "none";
320
- return funcs.join(" ");
355
+ return transform;
321
356
  };
322
357
  /**
323
358
  * The key an element's transform template rides under in its values, as its projection rides under
@@ -396,25 +431,22 @@ const projectsNothing = (projection) => {
396
431
  */
397
432
  const plainTransformOf = (values) => {
398
433
  let transform = "";
399
- let separator = "";
400
434
  let present = false;
401
435
  const depth = values[TransformKeys.PERSPECTIVE];
402
436
  if (Predicate.isNotUndefined(depth)) {
403
437
  present = true;
404
- if (TransformKeys.drawsDepth(depth)) {
405
- transform = `perspective(${formatTransformValue(TransformKeys.PERSPECTIVE, depth)})`;
406
- separator = " ";
407
- }
438
+ if (TransformKeys.drawsDepth(depth))
439
+ transform = withFunction(transform, DEPTH_FUNC, depth);
408
440
  }
409
- for (const { key, fn, identity } of WALKED_FUNCS) {
410
- if (!Object.hasOwn(values, key))
441
+ for (let i = 0; i < WALKED_FUNCS.length; i++) {
442
+ const func = WALKED_FUNCS[i];
443
+ if (!Object.hasOwn(values, func.key))
411
444
  continue;
412
445
  present = true;
413
- const value = values[key];
414
- if (isIdentity(value, identity))
446
+ const value = values[func.key];
447
+ if (isIdentity(value, func.identity))
415
448
  continue;
416
- transform = `${transform}${separator}${fn}(${formatTransformValue(key, value)})`;
417
- separator = " ";
449
+ transform = withFunction(transform, func, value);
418
450
  }
419
451
  if (!present)
420
452
  return undefined;
@@ -500,24 +532,56 @@ const projectedOpacity = (projection, values) => {
500
532
  * @example
501
533
  * DomRenderer.project({ x: 0, scale: 1, width: 200 }) // { transform: "none", width: "200px" }
502
534
  */
535
+ // The same function `RendererDomLive` provides (ADR-0021, decision 2), with each element's projector for the
536
+ // gate (#1030). Tier 2, for binding authors.
537
+ export const project = (values) => {
538
+ const patch = {};
539
+ drawInto(values, patch, undefined);
540
+ return patch;
541
+ };
542
+ /**
543
+ * `value` under `key` in `patch`: as it is for {@link project}; for a projector, a number as its text, and the
544
+ * key checked against its last draw's.
545
+ */
546
+ const put = (patch, drawn, key, value) => {
547
+ if (Predicate.isUndefined(drawn)) {
548
+ patch[key] = value;
549
+ return;
550
+ }
551
+ patch[key] = textOf(value);
552
+ if (drawn.keys[drawn.at] !== key) {
553
+ drawn.keys[drawn.at] = key;
554
+ drawn.changed = true;
555
+ }
556
+ drawn.at++;
557
+ };
558
+ /**
559
+ * A projector's patch value (#1030, Q7): a number as its text, which `commit` would write anyway; anything
560
+ * else as it is.
561
+ */
562
+ const textOf = (value) => {
563
+ if (Predicate.isNumber(value))
564
+ return String(value);
565
+ return value;
566
+ };
567
+ /** `values` drawn into `patch` as {@link project} draws them, through `drawn` for a projector. */
503
568
  // Two modes. PROJECTION (ADR-0009): the transform is assembled by `buildProjectionTransform` from the
504
569
  // node's `delta`/`treeScale`, adding the element's own translate (`x`, `y`, `translate*`, #363), weaving
505
570
  // its own animated `rotate`/`skew` and multiplying in its own `scale`/`scaleX`/`scaleY`. NORMAL: the
506
- // value-spine path, `none` at every identity (ADR-0023). The same function `RendererDomLive` provides
507
- // (ADR-0021, decision 2). Tier 2, for binding authors.
508
- export const project = (values) => {
509
- const patch = {};
571
+ // value-spine path, `none` at every identity (ADR-0023). Its one call that can throw, a Transform
572
+ // template's, comes before its first write, so a draw that throws leaves a projector's patch as it was.
573
+ const drawInto = (values, patch, drawn) => {
510
574
  const projection = values[Projection.KEY];
511
575
  if (Predicate.isNotUndefined(projection)) {
512
576
  // Projection owns the transform; weave this element's rotate/skew from `values`, through its
513
577
  // Transform template when it has one (#443).
514
- patch.transform = projectedTransformOf(projection, values);
578
+ put(patch, drawn, "transform", projectedTransformOf(projection, values));
515
579
  // Copy non-transform style keys (transform keys are consumed by the weave /
516
580
  // owned by the projection; the reserved keys never render).
517
581
  for (const key in values) {
518
582
  if (key === Projection.KEY || key === TEMPLATE_KEY || TransformKeys.TRANSFORM_KEYS.has(key))
519
583
  continue;
520
- patch[key] = formatStyleValue(key, values[key]);
584
+ put(patch, drawn, key, formatStyleValue(key, values[key]));
521
585
  }
522
586
  // Shared-element crossfade (ADR-0010): compose the crossfade factor with the
523
587
  // user's opacity — `finalOpacity = (userOpacity ?? 1) × factor`. Pure: both
@@ -525,30 +589,57 @@ export const project = (values) => {
525
589
  // A Switch's blended opacity is drawn as it is (ADR-0010, *Amendment (#166)*).
526
590
  const opacity = projectedOpacity(projection, values);
527
591
  if (Predicate.isNotUndefined(opacity))
528
- patch.opacity = opacity;
592
+ put(patch, drawn, "opacity", opacity);
529
593
  // A dragged node's raise (ADR-0016 *Amendment (Reorder)*): kebab-case, as the
530
594
  // scale correctors' keys are, so the commit's `setProperty` takes it.
531
595
  if (Predicate.isNotUndefined(projection.raise))
532
- patch["z-index"] = projection.raise;
596
+ put(patch, drawn, "z-index", projection.raise);
533
597
  // A Follower takes no pointer input (`Projection`'s `passesPointer`, ADR-0010, *Amendment
534
598
  // (#165)*; Motion's): `pointer-events: none`. A Lead's write leaves the key out, and the gate
535
599
  // gives the element its own value back.
536
600
  if (projection.passesPointer === true)
537
- patch["pointer-events"] = "none";
538
- return patch;
601
+ put(patch, drawn, "pointer-events", "none");
602
+ return;
539
603
  }
540
604
  // Grouped transform: the present keys in the canonical order, through the Transform template
541
605
  // when the element has one (#443).
542
606
  const transform = drawnTransformOf(values);
543
607
  if (Predicate.isNotUndefined(transform))
544
- patch.transform = transform;
608
+ put(patch, drawn, "transform", transform);
545
609
  // Non-transform keys: copy across with default-unit handling.
546
610
  for (const key in values) {
547
611
  if (key === TEMPLATE_KEY || TransformKeys.TRANSFORM_KEYS.has(key))
548
612
  continue;
549
- patch[key] = formatStyleValue(key, values[key]);
613
+ put(patch, drawn, key, formatStyleValue(key, values[key]));
550
614
  }
551
- return patch;
615
+ };
616
+ /**
617
+ * One element's projector (#1030): its values drawn as {@link project} draws them, each number as the text
618
+ * `commit` writes, into a patch of its own that it rewrites in place at its next call. Its patch stays the
619
+ * same object while the element's keys do; when they change, a new one holds them, so a key that went is
620
+ * never written again. The gate makes one for each element it registers.
621
+ */
622
+ // ADR-0034, *Amendment (#1030)*. Q8: a new patch, never a `delete` (which takes it to dictionary mode) nor
623
+ // an `undefined` key (which `commit` and the gate would read as written).
624
+ export const makeProjector = () => {
625
+ let patch = {};
626
+ const drawn = { keys: [], at: 0, changed: false };
627
+ return (values) => {
628
+ const before = drawn.keys.length;
629
+ drawn.at = 0;
630
+ drawn.changed = false;
631
+ drawInto(values, patch, drawn);
632
+ if (!drawn.changed && drawn.at === before)
633
+ return patch;
634
+ drawn.keys.length = drawn.at;
635
+ // Its first draw: nothing in its patch that this one didn't write.
636
+ if (before === 0)
637
+ return patch;
638
+ patch = {};
639
+ drawn.at = 0;
640
+ drawInto(values, patch, drawn);
641
+ return patch;
642
+ };
552
643
  };
553
644
  /**
554
645
  * Imperative: write a `Patch` onto `target`, now. The engine treats `target` as
@@ -575,7 +666,11 @@ const writeStyle = (style, patch) => {
575
666
  for (const key in patch)
576
667
  style.setProperty(dashCase(key), String(patch[key]));
577
668
  };
578
- /** Core's `Renderer` for the DOM: `project` and a `commit` that writes a patch onto an element's style. It needs nothing. */
579
- // `project` and `commit` have no service dependencies, so this is a plain `Layer.succeed`.
580
- export const RendererDomLive = Layer.succeed(Renderer.Renderer, { project, commit });
669
+ /**
670
+ * Core's `Renderer` for the DOM: `project` and a `commit` that writes a patch onto an element's style, with a
671
+ * projector for each element the Flush gate draws. It needs nothing.
672
+ */
673
+ // `project` and `commit` have no service dependencies, so this is a plain `Layer.succeed`. The projector
674
+ // rides on the value (#1030, core's `unstable/Projector`), so a Renderer provided over this one has none.
675
+ export const RendererDomLive = Layer.succeed(Renderer.Renderer, Projector.attach({ project, commit }, makeProjector));
581
676
  //# sourceMappingURL=renderer.js.map