@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
@@ -1,10 +1,39 @@
1
1
  import { type BorderRadius, type BorderStyle, type StyleEffects, type AnimationSettings, type ElementText, type Styles, type AnimationEvents, type AnimationEventHandler, AddColorString, type OnEvent, NewOmit, SingleBorderStyle, type DollarString } from './intrinsicTypes.js';
2
2
  import States, { type NodeStates } from './states.js';
3
- import type { RendererMain, INode, AnimateProps, IAnimationController, LinearGradientProps, RadialGradientProps } from '@solidtv/renderer';
3
+ import type { RendererMain, INode, AnimateProps, DashedBorderProps, IAnimationController, LinearGradientProps, RadialGradientProps } from '@solidtv/renderer';
4
4
  import { TextNode } from './nodeTypes.js';
5
5
  import { ForwardFocusHandler, FocusNode } from './focusManager.js';
6
6
  import { IRendererNode, IRendererShader, IRendererShaderProps, IRendererTextNode } from './dom-renderer/domRendererTypes.js';
7
7
  export declare function enqueueDelete(node: ElementNode, n: number): void;
8
+ /**
9
+ * What Solid knows of a `<text>` it measures (`ElementNode._text`), made the
10
+ * first time: only texts in a container that lays out have one. Its sizes
11
+ * start as doubles, so storing a measured size allocates nothing.
12
+ */
13
+ declare class TextMeasure {
14
+ /** A prop its layout reads was written since it was last measured; queued. */
15
+ due: boolean;
16
+ /** Its font was missing when measured (`_waitForFont`). */
17
+ waiting: boolean;
18
+ /** Width and height, as flex reads them, when last measured; NaN before. */
19
+ w: number;
20
+ h: number;
21
+ /**
22
+ * Hears every layout (`_listenTextLoaded`): a text Solid animated a layout
23
+ * prop of, and every measured text in DOM builds. For its lifetime.
24
+ */
25
+ listening: boolean;
26
+ constructor();
27
+ /**
28
+ * Measures the texts that waited for a font (`_waitForFont`): one whose
29
+ * font is there now stops waiting and, if its size changed, queues its
30
+ * parent; one whose font is still missing waits again. A method, not a
31
+ * module function: the post-mutation pass is its one caller, and terser's
32
+ * default `reduce_funcs` turns such a function into a closure per call.
33
+ * (Its own: the try would keep that pass from being optimized.)
34
+ */
35
+ static measureFontWaiting(): void;
36
+ }
8
37
  export declare function convertToShader(node: ElementNode, v: StyleEffects): IRendererShader;
9
38
  declare global {
10
39
  interface HTMLElement {
@@ -26,6 +55,23 @@ export interface ElementNode extends RendererNode, FocusNode {
26
55
  _animationSettings?: AnimationSettings;
27
56
  _autofocus?: any;
28
57
  _containsFlexGrow?: boolean | null;
58
+ /** @internal flexGrow/flexShrink record (B8): the size before the last growth or shrink. */
59
+ _flexBase?: number;
60
+ /** @internal flexGrow/flexShrink record (B8): the size the last growth or shrink wrote. */
61
+ _flexGrown?: number;
62
+ /** @internal the last x, y, width, height flex wrote with a transition */
63
+ _flexX?: number;
64
+ _flexY?: number;
65
+ _flexW?: number;
66
+ _flexH?: number;
67
+ /** @internal in the layout queue (queueLayout) */
68
+ _layoutQueued: boolean;
69
+ /**
70
+ * @internal a `<text>` in a container that lays out: what Solid's text
71
+ * measurement knows of it (`_textLayoutDirty`, `_measureText`); undefined
72
+ * until it is first queued or measured
73
+ */
74
+ _text: TextMeasure | undefined;
29
75
  _hasRenderedChildren?: boolean;
30
76
  _effects?: Record<string, any>;
31
77
  /** The props of a shader convertToShader made, kept to swap its type. */
@@ -38,10 +84,23 @@ export interface ElementNode extends RendererNode, FocusNode {
38
84
  _rendererProps?: any;
39
85
  _states?: States;
40
86
  _style?: Styles;
87
+ /** @internal text-only props written to an element that is not a `<text>` (B20) */
88
+ _textProps?: Record<string, unknown>;
89
+ /**
90
+ * @internal removed from its parent's children and not inserted since. Its
91
+ * `parent` link stays (1.6: keys and events still bubble through it), but
92
+ * it does not lay out that parent.
93
+ */
94
+ _detached: boolean;
41
95
  _theme?: Styles;
42
96
  _lastAnyKeyPressTime?: number;
43
97
  _type: 'element' | 'textNode';
98
+ /** @internal The keys state changes wrote, in first-write order: undo walks them. Reused, never shrunk. */
44
99
  _undoStyles?: string[];
100
+ /** @internal How many entries of `_undoStyles` are live. */
101
+ _undoCount: number;
102
+ /** @internal Per key in `_undoStyles`, the value the last state change wrote. */
103
+ _applied?: Record<string, unknown>;
45
104
  _display?: 'flex' | 'block';
46
105
  _onLayout?: (this: ElementNode, target: ElementNode) => void;
47
106
  _requiresLayout: boolean;
@@ -99,12 +158,10 @@ export interface ElementNode extends RendererNode, FocusNode {
99
158
  /**
100
159
  * Defines the ability for a flex item to shrink if necessary.
101
160
  * Defaults to 0 since existing legacy implementations did not shrink layout boxes.
102
- * Only available in NEW flex layout.
103
161
  */
104
162
  flexShrink?: number;
105
163
  /**
106
164
  * Defines the default size of an element before the remaining space is distributed.
107
- * Only available in NEW flex layout.
108
165
  */
109
166
  flexBasis?: number | string;
110
167
  /**
@@ -286,6 +343,14 @@ export interface ElementNode extends RendererNode, FocusNode {
286
343
  * @see https://solid-tv.github.io/solid/#/essentials/effects
287
344
  */
288
345
  radialGradient?: RadialGradientProps;
346
+ /**
347
+ * Clips the element to a rounded rectangle and draws a dashed border
348
+ * inside its edge. The DOM renderer draws it with CSS gradients: dash and
349
+ * gap lengths match, and each rounded corner is drawn as one dash.
350
+ *
351
+ * @see https://solid-tv.github.io/solid/#/essentials/effects
352
+ */
353
+ dashedBorder?: AddColorString<Partial<DashedBorderProps>>;
289
354
  /**
290
355
  * The margin on the bottom side of the element for a flexItem.
291
356
  *
@@ -443,7 +508,6 @@ export interface ElementNode extends RendererNode, FocusNode {
443
508
  /**
444
509
  * The individual padding on each side of an element, acting as an override to the `padding` array property.
445
510
  * `paddingTop`, `paddingRight`, `paddingBottom`, `paddingLeft`.
446
- * Only in the new flex engine.
447
511
  *
448
512
  * @see https://solid-tv.github.io/solid/#/flow/layout?id=flex
449
513
  */
@@ -471,7 +535,8 @@ export declare class ElementNode {
471
535
  * Swap a shader convertToShader made when its border width moves to or
472
536
  * from 0. For an animated write, `change` holds what animates: a border
473
537
  * it adds is swapped in before the animation reads its start values, one
474
- * it removes stays until the animation stops.
538
+ * it removes stays until the animation stops. A type the app did not
539
+ * register (createShader returns null) keeps the current shader.
475
540
  */
476
541
  _syncShaderType(change?: Record<string, unknown>): void;
477
542
  set effects(v: StyleEffects);
@@ -489,14 +554,28 @@ export declare class ElementNode {
489
554
  get fontFamily(): string | undefined;
490
555
  /**
491
556
  * The renderer's family name from `fontFamily` and `fontWeight`, resolved
492
- * in one place so either JSX order gives the same name (B17).
557
+ * in one place so either JSX order gives the same name (B17). Only a
558
+ * `<text>` has a font: another element keeps both on the ElementNode and
559
+ * writes nothing to its renderer node (B20).
493
560
  */
494
561
  _writeFontFamily(): void;
495
562
  insertChild(node: ElementNode | ElementText | TextNode, beforeNode?: ElementNode | ElementText | TextNode | null): void;
563
+ /**
564
+ * After `render()` made `node`'s renderer node (it appends), move it before
565
+ * the renderer node of its next rendered sibling (B19). solidOpts calls it
566
+ * for a node inserted before an anchor.
567
+ */
568
+ _drawInOrder(node: ElementNode): void;
496
569
  removeChild(node: ElementNode | ElementText | TextNode): void;
497
570
  get selectedNode(): ElementNode | undefined;
498
571
  set shader(shaderProps: IRendererShader | [kind: string, props: IRendererShaderProps]);
499
- _sendToLightningAnimatable(name: string, value: number): IAnimationController | undefined;
572
+ /**
573
+ * The transition path of an animatable prop's setter, which calls it only
574
+ * when the node has a `transition`. Returns true when the write became an
575
+ * animation; false when the setter stores the value itself (the common
576
+ * case is a direct store in the setter, under its own name).
577
+ */
578
+ _sendToLightningAnimatable(name: string, value: number): boolean;
500
579
  _fireAnimationEvents(name: string, value: number, animationSettings?: AnimationSettings): void;
501
580
  animate(props: Partial<AnimateProps>, animationSettings?: AnimationSettings): IAnimationController;
502
581
  chain(props: Partial<AnimateProps>, animationSettings?: AnimationSettings): this;
@@ -504,6 +583,69 @@ export declare class ElementNode {
504
583
  emit(event: string, ...args: any[]): boolean;
505
584
  setFocus(): void;
506
585
  _layoutOnLoad(): void;
586
+ /**
587
+ * @internal A prop the text layout reads was written on this element:
588
+ * `text`, `fontFamily`/`fontWeight`, `fontSize`, `lineHeight`,
589
+ * `letterSpacing`, `maxWidth`/`width`, `maxHeight`/`height`, `maxLines`,
590
+ * `wordBreak`, `overflowSuffix`. A rendered `<text>` whose parent lays out
591
+ * is measured again in the post-mutation pass, and its parent laid out if
592
+ * its size changed. Anything else returns at once.
593
+ */
594
+ _textLayoutDirty(): void;
595
+ /**
596
+ * @internal Size this rendered `<text>` for its parent's layout now, with
597
+ * the renderer's synchronous `measure()` (renderer v2 lays it out into its
598
+ * layout cache, and the walk reuses that layout). Returns whether its
599
+ * width or height, as flex reads them (`maxWidth || w`, `maxHeight || h`),
600
+ * changed since the last call. A text with both max sizes is that large to
601
+ * flex whatever its layout: the walk lays it out. While its font is
602
+ * missing it waits (`_waitForFont`).
603
+ */
604
+ _measureText(): boolean;
605
+ /**
606
+ * @internal Development only, on `loaded`: a layout Solid did not ask for
607
+ * (the walk's) changed the size of a text Solid measures, so its parent's
608
+ * flex has the old one. A prop the layout reads was written on the
609
+ * renderer node (`el.lng`) rather than on the element, or animated there.
610
+ */
611
+ _warnUnmeasuredLayout(): void;
612
+ /**
613
+ * @internal `measure()` found no font description: hear `loaded` once,
614
+ * when the walk lays the text out (the renderer wakes the nodes it
615
+ * visited), and wait for loadFonts() to say a font loaded (for one no walk
616
+ * visits). Either way measureFontWaiting measures it again.
617
+ */
618
+ _waitForFont(m: TextMeasure): void;
619
+ /**
620
+ * @internal Solid animated a prop this text's layout reads
621
+ * (`_sendToLightningAnimatable`, `animate()`): from now on, for the text's
622
+ * lifetime, each layout the walk makes of an animated value lays its
623
+ * container out again in that frame, as 1.6's `loaded` listener did.
624
+ * Lifetime, not the animation's: Solid does not see a controller started
625
+ * later, or again (`animate()` returns it to the app).
626
+ */
627
+ _textLayoutAnimated(): void;
628
+ /**
629
+ * @internal Hear every layout of this text: one whose size, as flex reads
630
+ * it, Solid did not measure lays the container out in that frame. One
631
+ * closure per text, made once and kept for its lifetime, on its renderer
632
+ * node only (nothing else holds it, so it goes with the node). A layout
633
+ * Solid measured changes nothing, and asks for no second walk.
634
+ */
635
+ _listenTextLoaded(): void;
636
+ /**
637
+ * @internal The listener `_listenTextLoaded` adds, once per text. A method
638
+ * of its own: an arrow's `this` is allocated in a context on every call of
639
+ * the method that holds it, and that one runs on every animated write.
640
+ */
641
+ _hearTextLayouts(): void;
642
+ /**
643
+ * @internal After a layout Solid did not make (the walk's, of an animated
644
+ * value; the DOM renderer's late re-measure): whether this text's size, as
645
+ * flex reads it, changed since Solid last saw it. If so, it is recorded
646
+ * and the caller lays the parent out. False while a measure is due.
647
+ */
648
+ _textSizeChanged(): boolean;
507
649
  getText(this: ElementText): string;
508
650
  destroy(): void;
509
651
  _destroy(): void;
@@ -512,8 +654,9 @@ export declare class ElementNode {
512
654
  set theme(styles: Styles | undefined);
513
655
  get theme(): Styles;
514
656
  get hasChildren(): boolean;
515
- set src(src: string | null | undefined);
516
- get src(): string | null | undefined;
657
+ set src(src: string | Blob | null | undefined);
658
+ /** An image URL, or a Blob holding the image (e.g. a fetch() response's). */
659
+ get src(): string | Blob | null | undefined;
517
660
  getChildById(id: string): ElementNode | ElementText | undefined;
518
661
  searchChildrenById(id: string): ElementNode | undefined;
519
662
  set states(states: NodeStates);
@@ -553,7 +696,30 @@ export declare class ElementNode {
553
696
  set updateLayoutOn(_v: unknown);
554
697
  get updateLayoutOn(): unknown;
555
698
  updateLayout(): void;
699
+ /**
700
+ * Apply the `$state` blocks of the active states (design 3.3). The keys
701
+ * any state wrote since the states were last empty are tracked in
702
+ * `_undoStyles`, in first-write order; each takes its value from the
703
+ * active block of highest precedence, else the base value (`theme`, then
704
+ * `style`, then undefined: pinned). After render a key is written only
705
+ * when that value differs from the one written last (`_applied`); before
706
+ * render every key is written, into the props bag, as before 1.7.
707
+ */
556
708
  _stateChanged(): void;
709
+ /**
710
+ * The state-style loops of `_stateChanged`, for `n` active states: a
711
+ * method of its own, so that `_stateChanged`, which runs for every path
712
+ * element of every focus change, stays the short early-return above. Each
713
+ * key is written through its setter, as before 1.7: a border or shadow
714
+ * object merges into the shader props, the later write of a sub-prop
715
+ * winning.
716
+ */
717
+ _writeStates(n: number): void;
718
+ /**
719
+ * Write every tracked border-family key again, in tracked order, with the
720
+ * value the state change resolved for it (`_applied`): see `_writeStates`.
721
+ */
722
+ _rewriteBorderKeys(count: number): void;
557
723
  render(topNode?: boolean): void;
558
724
  }
559
725
  export declare function createRawShaderAccessor<T>(key: keyof StyleEffects): {
@@ -564,3 +730,4 @@ export declare function shaderAccessor<T extends Record<string, any> | number>(k
564
730
  set(this: ElementNode, value: T): void;
565
731
  get(this: ElementNode): any;
566
732
  };
733
+ export {};