@solidtv/solid 1.7.4 → 1.8.0-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 (68) hide show
  1. package/MIGRATION-1.8.md +270 -0
  2. package/dist/src/core/dom-renderer/dashedBorderStyle.d.ts +20 -0
  3. package/dist/src/core/dom-renderer/dashedBorderStyle.js +104 -0
  4. package/dist/src/core/dom-renderer/dashedBorderStyle.js.map +1 -0
  5. package/dist/src/core/dom-renderer/domRenderer.d.ts +14 -0
  6. package/dist/src/core/dom-renderer/domRenderer.js +194 -12
  7. package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
  8. package/dist/src/core/dom-renderer/domRendererTypes.d.ts +12 -2
  9. package/dist/src/core/elementNode.d.ts +176 -9
  10. package/dist/src/core/elementNode.js +1906 -411
  11. package/dist/src/core/elementNode.js.map +1 -1
  12. package/dist/src/core/flexLayout.d.ts +6 -0
  13. package/dist/src/core/flexLayout.js +535 -218
  14. package/dist/src/core/flexLayout.js.map +1 -1
  15. package/dist/src/core/focusManager.js +70 -23
  16. package/dist/src/core/focusManager.js.map +1 -1
  17. package/dist/src/core/fontLoaded.d.ts +10 -0
  18. package/dist/src/core/fontLoaded.js +26 -0
  19. package/dist/src/core/fontLoaded.js.map +1 -0
  20. package/dist/src/core/intrinsicTypes.d.ts +2 -1
  21. package/dist/src/core/lightningInit.js +8 -1
  22. package/dist/src/core/lightningInit.js.map +1 -1
  23. package/dist/src/core/shaders.d.ts +5 -2
  24. package/dist/src/core/shaders.js +6 -0
  25. package/dist/src/core/shaders.js.map +1 -1
  26. package/dist/src/core/states.d.ts +2 -0
  27. package/dist/src/core/states.js +26 -7
  28. package/dist/src/core/states.js.map +1 -1
  29. package/dist/src/core/stylePlan.d.ts +39 -0
  30. package/dist/src/core/stylePlan.js +159 -0
  31. package/dist/src/core/stylePlan.js.map +1 -0
  32. package/dist/src/core/utils.js +2 -2
  33. package/dist/src/primitives/Grid.jsx +22 -3
  34. package/dist/src/primitives/Grid.jsx.map +1 -1
  35. package/dist/src/primitives/Virtual.jsx +16 -6
  36. package/dist/src/primitives/Virtual.jsx.map +1 -1
  37. package/dist/src/primitives/utils/handleNavigation.js +29 -6
  38. package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
  39. package/dist/src/primitives/utils/withScrolling.js +2 -1
  40. package/dist/src/primitives/utils/withScrolling.js.map +1 -1
  41. package/dist/src/solidOpts.js +22 -8
  42. package/dist/src/solidOpts.js.map +1 -1
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/docs/AI_CODING_GUIDELINES.md +7 -6
  45. package/docs/AI_UPGRADE_1.8.md +290 -0
  46. package/package.json +5 -3
  47. package/src/core/dom-renderer/dashedBorderStyle.ts +128 -0
  48. package/src/core/dom-renderer/domRenderer.ts +201 -10
  49. package/src/core/dom-renderer/domRendererTypes.ts +12 -0
  50. package/src/core/elementNode.ts +2124 -459
  51. package/src/core/flexLayout.ts +583 -231
  52. package/src/core/focusManager.ts +86 -27
  53. package/src/core/fontLoaded.ts +29 -0
  54. package/src/core/intrinsicTypes.ts +2 -0
  55. package/src/core/lightningInit.ts +8 -1
  56. package/src/core/shaders.ts +12 -0
  57. package/src/core/states.ts +29 -9
  58. package/src/core/stylePlan.ts +195 -0
  59. package/src/core/utils.ts +2 -2
  60. package/src/primitives/Grid.tsx +35 -9
  61. package/src/primitives/Virtual.tsx +20 -6
  62. package/src/primitives/utils/handleNavigation.ts +40 -6
  63. package/src/primitives/utils/withScrolling.ts +3 -2
  64. package/src/solidOpts.ts +23 -8
  65. package/dist/src/core/flex.d.ts +0 -2
  66. package/dist/src/core/flex.js +0 -285
  67. package/dist/src/core/flex.js.map +0 -1
  68. package/src/core/flex.ts +0 -332
@@ -0,0 +1,270 @@
1
+ # Migrating to @solidtv/solid 1.8
2
+
3
+ 1.8 rewrites Solid's internals to use less CPU and allocate less per key press:
4
+ one flex engine, text measured before the frame, draw order that follows the
5
+ child order, compiled state styles, and one reactive flush per focus change.
6
+ Apps written against `<view>`, `<text>` and the primitives keep their code,
7
+ except where this file says otherwise.
8
+
9
+ It needs `@solidtv/renderer` 2.0.11 or later (1.7.3 accepted 2.0.7): Solid
10
+ sizes text with the renderer's `TextNode.measure()`, orders siblings with
11
+ `Node.insertBefore`, registers the renderer's `DashedBorder` shader (2.0.9)
12
+ and reads `truncated` from a text's `loaded` (2.0.11). The renderer 2.0 breaks
13
+ themselves came with Solid 1.7; see the renderer's
14
+ `docs/upgrade-1.x-to-2.0.md`.
15
+
16
+ The measurements behind each change are in `docs/perf/log.md`.
17
+
18
+ ## Layout and flex
19
+
20
+ - **One flex engine.**
21
+ - **What changes:** `src/core/flex.ts` and `VITE_USE_NEW_FLEX` are gone;
22
+ every build runs the CSS-aligned engine (`flexLayout.ts`). It allocates
23
+ nothing during a layout pass and writes only the values that changed.
24
+ Apps that did not set the variable now get, where the engines differed:
25
+ - a number `padding` also offsets the cross axis (rows start at
26
+ `paddingTop` with `alignItems` or wrapping);
27
+ - padding arrays and `paddingLeft`/`Top`/`Right`/`Bottom` work (the old
28
+ engine produced NaN), and the `margin` array works;
29
+ - wrapped lines start at the cross padding, and the height adds the end
30
+ padding;
31
+ - `flexShrink` shrinks overflowing items and `flexBasis` replaces the
32
+ width or height for positioning (the old engine ignored both);
33
+ - a container whose items only have `flexShrink` gets
34
+ `flexBoundary: 'fixed'`, so it no longer sizes itself to its items;
35
+ - no `console.warn` when `flexGrow` has no free space;
36
+ - positions are float64 (no float32 rounding such as 109.70999908).
37
+ - **Upgrade step:** delete `VITE_USE_NEW_FLEX` from `.env` (it is ignored).
38
+ If your app ran on the old engine, check the layouts above.
39
+ - **Text in a layout container is sized by Solid, before the frame.**
40
+ - **What changes:** a `<text>` whose parent has `display="flex"` or an
41
+ `onLayout` is measured with the renderer's `measure()` in Solid's
42
+ post-mutation pass. The container's flex and `onLayout` run in that
43
+ microtask, before the frame, instead of after the text's `loaded` in a
44
+ later frame. Final positions are the same, and they are right in the first
45
+ frame that shows the change. A change that leaves a text's size unchanged
46
+ lays nothing out.
47
+ - **Reads right after mount see the laid-out values.** Code that reads a
48
+ flex-derived position or size in the same task as the mount (an
49
+ `onFocus` that fires at mount, an effect, a `ref` callback) now gets the
50
+ laid-out value. Before, it got the pre-layout value, often 0, so
51
+ something positioned from it may move to where it was meant to be.
52
+ - **`loaded`.** An `onEvent.loaded` on such a text still fires once per
53
+ layout, now after the container's relayout. On the DOM renderer it fires
54
+ for every new size, as before.
55
+ - **Animations.** A `transition` on a text's `fontSize`, `lineHeight`,
56
+ `width` or `height`, and `el.animate()` of its layout props, still lay
57
+ the container out on every animated frame, and it ends where the final
58
+ size puts it.
59
+ - **Writes that bypass Solid.** Layout props written or animated on the
60
+ renderer node (`el.lng.text = …`, `el.lng.fontSize = …`,
61
+ `el.lng.animate({ fontSize })`) no longer lay out the container: the
62
+ renderer lays the text out again, but Solid is not told. Development
63
+ builds warn when this happens.
64
+ - **Upgrade step:** write or animate text props on the element
65
+ (`el.fontSize`, a `transition`, `el.animate()`), not on `el.lng`.
66
+ - **Text under hidden or out-of-bounds ancestors is laid out eagerly.**
67
+ - **What changes:** text in a layout container is measured at mount and on
68
+ every change, even when an ancestor has alpha 0 or is outside the bounds
69
+ margin, so such containers have their final size before they are shown.
70
+ Before, they stayed unlaid until visible.
71
+ - A text whose font is not loaded yet waits, then lays out once. A font
72
+ loaded with `loadFonts()` lays out culled text when it arrives; one
73
+ loaded with `renderer.loadFont()` directly lays it out when shown, as
74
+ before.
75
+ - It costs one text layout per such text, and more use of the renderer's
76
+ text layout cache (`textLayoutCacheSize`, 250 entries by default). A
77
+ page whose texts in layout containers outnumber the cache thrashes it;
78
+ raise the size for such pages.
79
+ - **Upgrade step:** none.
80
+ - **A `loaded` relayout runs between the renderer's walks.**
81
+ - **What changes:** an autosize node's `loaded` queues its parent's layout
82
+ for the post-mutation pass instead of laying it out inside the event, and
83
+ a `loaded` that leaves the size unchanged lays nothing out. An app's
84
+ `onEvent.loaded` handler on such a node now runs before the parent's
85
+ relayout. On the DOM renderer the relayout is one microtask after the
86
+ event.
87
+ - **Upgrade step:** read the parent's layout from its `onLayout`, not from a
88
+ child's `loaded` handler.
89
+ - **Post-mutation scheduling is a microtask only.**
90
+ - **What changes:** Solid no longer asks the renderer for an in-frame run,
91
+ and a frame, on every mutation. Nodes an app inserts or removes inside a
92
+ renderer callback that runs between the walks (its own `onEvent`
93
+ handler, `loaded` included) are laid out one frame later.
94
+ - **Upgrade step:** none.
95
+ - **A `flexGrow` container calls `onLayout` once per layout,** after its grown
96
+ children are laid out again. Before, it was called twice, the first time
97
+ before the children were laid out. **Upgrade step:** do not count on two
98
+ calls.
99
+ - **DOM renderer: `measure()`.** `DOMText.measure()` sizes a text
100
+ synchronously with `getBoundingClientRect` once `document.fonts.check`
101
+ reports its font loaded, so a flex text is laid out in the post-mutation
102
+ microtask, not after the DOM renderer's timer. A web font that loads after
103
+ its text was measured still lays the container out again. **Upgrade step:**
104
+ none.
105
+
106
+ ### Flex bugs fixed
107
+
108
+ - **B5:** an unsized `<text flexItem={false}>` no longer blocks its
109
+ container's layout.
110
+ - **B6:** `justifyContent="center"` with padding centres inside the padding
111
+ (it was shifted by the start padding). Drop compensating offsets, if any.
112
+ - **B7:** cross-axis `alignItems`/`alignSelf` `center` and `flexEnd` stay
113
+ inside the cross padding (center was offset by `paddingTop`, flexEnd
114
+ overflowed by it). Drop compensating offsets, if any.
115
+ - **B8:** a `flexGrow` or `flexShrink` item is sized from its own size on
116
+ every layout: a grown item shrinks back when a sibling grows, a shrunk one
117
+ grows back when the overflow goes away, and neither keeps the size the last
118
+ layout gave it (a grown item kept its largest grown size; a shrunk one
119
+ shrank again on every layout).
120
+ - **B9:** a wrapping container with no cross size places wrapped items on
121
+ their own lines (they overlapped the first line).
122
+ - **B10:** `flexWrap="wrap-reverse"` wraps, first line at the end.
123
+ - **B11:** a `contain` text with no size subtracts its right and bottom
124
+ margins from the computed `maxWidth`/`maxHeight`.
125
+ - **B12:** `maxLines={1}` with a `lineHeight` of 3 or less reads it as a
126
+ multiplier: `maxHeight = lineHeight * fontSize` (it was the bare multiplier,
127
+ a 1.2 px tall text).
128
+ - **B13:** `flexGrow` and `flexShrink` share the space inside the
129
+ container's padding (grown items overflowed the end padding).
130
+ - **B14:** a row with no `height` fits its height to items placed by
131
+ `alignItems`/`alignSelf` plus the cross padding (the items overflowed it).
132
+
133
+ ## Keys and focus
134
+
135
+ - **One reactive flush per focus change.**
136
+ - **What changes:** `onFocus`, `onBlur` and `onFocusChanged` run in the same
137
+ order, but the whole focus change (the callbacks, `focusPath`,
138
+ `activeElement`) runs in one Solid `batch`.
139
+ - An effect or JSX binding triggered by a signal written in one of these
140
+ callbacks runs once, after the last callback of the change, instead of
141
+ right after each write. Memos read inside the callbacks are still
142
+ current.
143
+ - Effects on `focusPath` run in the same flush as those on
144
+ `activeElement`.
145
+ - A callback that writes a signal and then reads a node prop that an
146
+ effect sets from that signal sees the old value until the change ends.
147
+ - A focus change made from inside a focus callback no longer publishes the
148
+ intermediate `activeElement`/`focusPath` to effects: they see only the
149
+ final one.
150
+ - If a focus callback throws, the effects queued by earlier callbacks of
151
+ that change are dropped. The exception still propagates.
152
+ - **Upgrade step:** if a focus callback relied on an effect having run after
153
+ its own signal write, read the signal instead.
154
+
155
+ ## States and styles
156
+
157
+ - **`states` Array methods return plain arrays.** `states.slice()`,
158
+ `filter()`, `map()`, `splice()` and the other `Array` methods return a plain
159
+ `Array`, not a `States`. `States` itself is still an `Array` subclass.
160
+ **Upgrade step:** call `has`/`add`/`toggle` on `node.states`, not on a copy.
161
+ - **B2: `states.remove('focus')` and `toggle('focus')` match `'$focus'`,** as
162
+ `has('focus')` already did. Before, they did nothing when only `'$focus'` was
163
+ in the list. **Upgrade step:** none.
164
+ - **A state change writes only the keys whose value changed.**
165
+ - **What changes:** a key still resolves to the active state of highest
166
+ precedence that sets it, else `theme[key]`, else `style[key]`, else
167
+ `undefined`, but it is written only when that value differs from the one
168
+ the last state change wrote. Before, every state change, and every undo,
169
+ re-wrote every key of every active state.
170
+ - Adding a second state no longer restarts the first state's transition
171
+ (a `$focus` `scale` keeps animating when `$active` is added).
172
+ - A value the app writes to a key a state sets survives a later state
173
+ change that leaves that key's value unchanged.
174
+ - The border keys (`border`, `borderTop`, `borderRight`, `borderBottom`,
175
+ `borderLeft`) are the exception: when a state change writes one of them,
176
+ it writes all of them again in order, as before, so the sides and the
177
+ whole border combine as they did.
178
+ - The undo is a state change too: when a key's base value (`theme`, else
179
+ `style`) is `===` the value the state wrote, the undo skips it.
180
+ - **Upgrade step:** code that relied on a state change to overwrite its own
181
+ write to a key the state sets must write the key again.
182
+ - **Assigning an unchanged `states` list does nothing.** An array or string
183
+ with the same states in the same order, or an object that adds and removes
184
+ nothing, is a no-op. With `forwardStates`, a child that changed its own
185
+ states keeps them until the parent's list changes. And
186
+ `node.states = node.states` no longer empties the list. **Upgrade step:**
187
+ none.
188
+ - **A `$state` block, and a `border` or `shadow` object, are read once per
189
+ object.**
190
+ - **What changes:** their keys and values are compiled the first time they
191
+ are used and cached by object identity. Changing such an object afterwards
192
+ (`style.$focus.color = x`, or `myBorder.width = 4` and assigning the same
193
+ object again) is not seen. A getter in a `$state` block is still read each
194
+ time the block is applied; an object with a getter is not cached. A block
195
+ from a Solid store (`createStore`) is one: every key of a store reads
196
+ as a getter, so keys the store's setter adds or removes are seen too.
197
+ - **Upgrade step:** assign a new object instead of mutating one, or use a
198
+ getter.
199
+ - **Setting `linearGradient` or `radialGradient` again updates the node's
200
+ gradient shader** in place, instead of making a new one. A gradient shader
201
+ shared between nodes is updated for all of them. **Upgrade step:** none.
202
+ - **Setting `linearGradient`, `radialGradient` or `dashedBorder` to
203
+ `undefined` or `null` removes the shader the prop made.** Before, a
204
+ gradient set to `undefined` made a new shader with the type's defaults: it
205
+ drew the default gradient, in place of any other shader on the node. Now a
206
+ shader made another way (`borderRadius`, `border`, …) is left alone.
207
+ **Upgrade step:** if a screen relied on the default gradient showing, set
208
+ that gradient explicitly.
209
+
210
+ ## Primitives
211
+
212
+ - **Row and Column cache the merged `transition`.** After a press, a Row's or
213
+ Column's `transition` is a merged object cached per element and direction.
214
+ An in-place edit of the base `transition` object is not seen. **Upgrade
215
+ step:** assign a new `transition` object instead of mutating it.
216
+
217
+ ## Nodes
218
+
219
+ - **B19: draw order follows the child order.**
220
+ - **What changes:** overlapping siblings with equal `zIndex` draw in their
221
+ `children` order after every update, on both renderers: a `<Show>` that
222
+ appears between siblings, a `<For>` that adds in the middle or reorders,
223
+ and a Virtual window shift. Before, such a node was drawn after all its
224
+ siblings. An adjacent `<For>` swap also keeps the declared order now, for
225
+ flex positions and focus order too (a child inserted before itself stays
226
+ in place). When the anchor has a different `zIndex`, the renderer places
227
+ the node at the nearest place that keeps siblings sorted by `zIndex`.
228
+ - **Upgrade step:** if an app relied on an inserted node drawing last, give
229
+ it a higher `zIndex`.
230
+ - **B20: text props on a non-text element; `absX`/`absY`/`destroyed`
231
+ writes.** Text-only props (`fontSize`, `lineHeight`, `maxWidth`,
232
+ `maxHeight`, `text`, `contain`, `textAlign`, …) written to a `<view>` stay on
233
+ the ElementNode and no longer reach `view.lng`. Writing `absX`, `absY` or
234
+ `destroyed` on an element is ignored; it threw a `TypeError` on renderer 2.0.
235
+ **Upgrade step:** none.
236
+ - **A removed element does not lay out its old parent.** When a removed,
237
+ not yet destroyed element changes size (a text in a hidden
238
+ `Preserve`/`KeepAlive` root finishing its load, say), its old parent's flex
239
+ and `onLayout` no longer run. A removed element still keeps its `parent`,
240
+ and keys and events from a removed subtree still bubble through it.
241
+ **Upgrade step:** none.
242
+ - **A `Blob` `src` shows on both renderers.** `<view src={blob}>` drew
243
+ nothing before (the node turned transparent). The WebGL renderer loads the
244
+ Blob as `ImageTexture` does; the DOM renderer shows it through an object
245
+ URL the node owns and revokes. **Upgrade step:** none; an object URL the app
246
+ makes itself still works.
247
+
248
+ ## New in 1.8
249
+
250
+ None of these changes an existing app; each is opt-in.
251
+
252
+ - **`dashedBorder`**: a dashed border shader prop (`dash`, `gap`, `width`,
253
+ `color`, radius), registered by `registerDefaultShaders`. See
254
+ [Effects](docs/essentials/effects.md).
255
+ - **Grid `scroll="edge"`**: the grid stays still while focus moves through the
256
+ rows that fit, and scrolls only when focus leaves them (also in 1.7.4).
257
+ - **useMouse `respectClipping`**: the hit test reaches children drawn outside
258
+ a non-clipping parent (also in 1.7.4). See
259
+ [useMouse](docs/primitives/useMouse.md).
260
+ - **`truncated` on the DOM renderer's text**: its `loaded` payload and text
261
+ node carry `truncated`, as renderer 2.0.11's do.
262
+
263
+ ## Build
264
+
265
+ - **Recommended: terser `reduce_funcs: false`.** With terser's default
266
+ `reduce_funcs`, renderer 2.0's scene walk allocates on every node it visits.
267
+ Build with `build.minify: 'terser'` and
268
+ `build.terserOptions.compress.reduce_funcs = false`;
269
+ [Building for TVs](docs/deploy/build.md) has the Vite, webpack and CLI
270
+ forms. **Upgrade step:** set the option in your build.
@@ -0,0 +1,20 @@
1
+ import type { DashedBorderProps } from '@solidtv/renderer';
2
+ /**
3
+ * The DOM renderer's `dashedBorder`, in CSS only, so that `dash`, `gap`,
4
+ * `width`, `color` and `radius` draw as the WebGL shader draws them:
5
+ *
6
+ * - each straight side is a repeating linear gradient strip, `width` thick;
7
+ * - with a radius, each corner is a quarter ring (a radial gradient), drawn
8
+ * as one dash, and the straight sides run gap, dash, ..., dash, gap
9
+ * between them; without one, each side starts and ends with a dash, and
10
+ * the corners' dashes meet.
11
+ *
12
+ * On each side the dash and gap are stretched so that a whole number of
13
+ * them fits. A `gap` of 0 or less draws a solid border. Returns '' when
14
+ * nothing is drawn: a `dash`, `width` or colour alpha of 0 or less, or a
15
+ * node without size.
16
+ *
17
+ * Each gradient is written twice, the `-webkit-` syntax first, for older
18
+ * WebKit (e.g. PS4); a browser keeps the last declaration it can read.
19
+ */
20
+ export declare function dashedBorderStyle(w: number, h: number, props: Partial<DashedBorderProps>): string;
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The DOM renderer's `dashedBorder`, in CSS only, so that `dash`, `gap`,
3
+ * `width`, `color` and `radius` draw as the WebGL shader draws them:
4
+ *
5
+ * - each straight side is a repeating linear gradient strip, `width` thick;
6
+ * - with a radius, each corner is a quarter ring (a radial gradient), drawn
7
+ * as one dash, and the straight sides run gap, dash, ..., dash, gap
8
+ * between them; without one, each side starts and ends with a dash, and
9
+ * the corners' dashes meet.
10
+ *
11
+ * On each side the dash and gap are stretched so that a whole number of
12
+ * them fits. A `gap` of 0 or less draws a solid border. Returns '' when
13
+ * nothing is drawn: a `dash`, `width` or colour alpha of 0 or less, or a
14
+ * node without size.
15
+ *
16
+ * Each gradient is written twice, the `-webkit-` syntax first, for older
17
+ * WebKit (e.g. PS4); a browser keeps the last declaration it can read.
18
+ */
19
+ export function dashedBorderStyle(w, h, props) {
20
+ const width = props.width ?? 2;
21
+ const color = props.color ?? 0xffffffff;
22
+ const dash = props.dash ?? 10;
23
+ const gap = props.gap ?? 10;
24
+ if (w <= 0 || h <= 0 || width <= 0 || dash <= 0 || (color & 0xff) === 0) {
25
+ return '';
26
+ }
27
+ const rgba = `rgba(${(color >>> 24) & 0xff},${(color >>> 16) & 0xff},${(color >>> 8) & 0xff},${round((color & 0xff) / 255)})`;
28
+ const r = round(Math.max(0, Math.min(props.radius ?? 0, w / 2, h / 2)));
29
+ const px = `${width}px`;
30
+ // [-webkit- image, image, size, position]
31
+ const layers = [];
32
+ const side = (length, dirs, size, position) => {
33
+ const stops = strip(length, dash, gap, rgba, r > 0);
34
+ if (stops !== '') {
35
+ layers.push([
36
+ `-webkit-repeating-linear-gradient(${dirs[0]}, ${stops})`,
37
+ `repeating-linear-gradient(${dirs[1]}, ${stops})`,
38
+ size,
39
+ position,
40
+ ]);
41
+ }
42
+ };
43
+ const straightX = round(w - 2 * r);
44
+ const straightY = round(h - 2 * r);
45
+ side(straightX, ['left', 'to right'], `${straightX}px ${px}`, `${r}px 0`);
46
+ side(straightX, ['left', 'to right'], `${straightX}px ${px}`, `${r}px 100%`);
47
+ side(straightY, ['top', 'to bottom'], `${px} ${straightY}px`, `0 ${r}px`);
48
+ side(straightY, ['top', 'to bottom'], `${px} ${straightY}px`, `100% ${r}px`);
49
+ if (r > 0) {
50
+ // A quarter ring around the corner's centre; the layer's border-radius
51
+ // clips (and smooths) its outer edge.
52
+ const inner = round(r - width);
53
+ const ring = inner > 0
54
+ ? `transparent ${round(inner - 0.5)}px, ${rgba} ${round(inner + 0.5)}px, ${rgba} ${r}px, transparent ${r}px`
55
+ : `${rgba} 0, ${rgba} ${r}px, transparent ${r}px`;
56
+ // The corner box's position, and the ring's centre in that box
57
+ const corners = [
58
+ ['0 0', '100% 100%'],
59
+ ['100% 0', '0 100%'],
60
+ ['0 100%', '100% 0'],
61
+ ['100% 100%', '0 0'],
62
+ ];
63
+ for (const [position, centre] of corners) {
64
+ layers.push([
65
+ `-webkit-radial-gradient(${centre}, circle, ${ring})`,
66
+ `radial-gradient(circle at ${centre}, ${ring})`,
67
+ `${r}px ${r}px`,
68
+ position,
69
+ ]);
70
+ }
71
+ }
72
+ const list = (i) => layers.map((layer) => layer[i]).join(', ');
73
+ return (`background-image: ${list(0)};` +
74
+ `background-image: ${list(1)};` +
75
+ `background-size: ${list(2)};` +
76
+ `background-position: ${list(3)};` +
77
+ 'background-repeat: no-repeat;');
78
+ }
79
+ /**
80
+ * The colour stops of a straight side `length` long. Between rounded
81
+ * corners (which are dashes) it starts and ends with a gap: count dashes,
82
+ * count + 1 gaps. Without corners it starts and ends with a dash: count
83
+ * dashes, count - 1 gaps. '' when the side holds no dash.
84
+ */
85
+ function strip(length, dash, gap, rgba, betweenCorners) {
86
+ if (length <= 0)
87
+ return '';
88
+ if (gap <= 0)
89
+ return `${rgba} 0, ${rgba} ${length}px`;
90
+ const pair = dash + gap;
91
+ const gaps = betweenCorners ? 1 : -1;
92
+ const count = Math.max(betweenCorners ? 0 : 1, Math.round((length - gaps * gap) / pair));
93
+ if (count === 0)
94
+ return '';
95
+ const scale = length / (count * dash + (count + gaps) * gap);
96
+ const d = round(dash * scale);
97
+ const g = round(gap * scale);
98
+ const p = round(d + g);
99
+ return betweenCorners
100
+ ? `transparent 0, transparent ${g}px, ${rgba} ${g}px, ${rgba} ${p}px`
101
+ : `${rgba} 0, ${rgba} ${d}px, transparent ${d}px, transparent ${p}px`;
102
+ }
103
+ const round = (n) => Math.round(n * 1000) / 1000;
104
+ //# sourceMappingURL=dashedBorderStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashedBorderStyle.js","sourceRoot":"","sources":["../../../../src/core/dom-renderer/dashedBorderStyle.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,CAAS,EACT,CAAS,EACT,KAAiC;IAEjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,UAAU,CAAC;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,KAAK,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC;IAC9H,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,C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AI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI;QACrE,CAAC,CAAC,GAAG,IAAI,OAAO,IAAI,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,IAAI,CAAC;AAC1E,CAAC;AAED,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC"}
@@ -13,6 +13,11 @@ export declare class DOMNode extends EventEmitter implements IRendererNode {
13
13
  imageLoading: boolean;
14
14
  lazyImagePendingSrc: string | null;
15
15
  lazyImageSubTextureProps: InstanceType<lng.TextureMap['SubTexture']>['props'] | null;
16
+ /** The Blob image source shown through `blobUrl`, if the source is one. */
17
+ blobSrc: Blob | null;
18
+ blobUrl: string | null;
19
+ /** Object URLs this node made and has not revoked yet. */
20
+ blobUrls: Set<string> | null;
16
21
  boundsDirty: boolean;
17
22
  children: Set<DOMNode>;
18
23
  /** Cached result of the last updateNodeStyles call — avoids redundant setAttribute writes. */
@@ -26,6 +31,15 @@ export declare class DOMNode extends EventEmitter implements IRendererNode {
26
31
  private markDestroyed;
27
32
  get parent(): IRendererNode | null;
28
33
  set parent(value: IRendererNode | null);
34
+ /**
35
+ * Renderer v2's `Node.insertBefore`: makes `child` a child of this node,
36
+ * before `before` (`null`, or a node that is not a child, appends); a child
37
+ * of this node moves, and one placed before itself stays. A destroyed
38
+ * parent or child does nothing; a destroyed `before` appends. The div order
39
+ * is the paint order among equal z-index, as v2's sibling order is its
40
+ * draw order.
41
+ */
42
+ insertBefore(child: IRendererNode, before: IRendererNode | null): void;
29
43
  markChildrenBoundsDirty(): void;
30
44
  animate: typeof animate;
31
45
  updateRenderState(renderState: lng.CoreNodeRenderState): void;