@solidtv/solid 1.1.3 → 1.2.1

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 (69) hide show
  1. package/README.md +2 -2
  2. package/dist/src/core/activeElement.d.ts +17 -0
  3. package/dist/src/core/activeElement.js +18 -0
  4. package/dist/src/core/activeElement.js.map +1 -0
  5. package/dist/src/core/config.d.ts +20 -0
  6. package/dist/src/core/config.js +15 -1
  7. package/dist/src/core/config.js.map +1 -1
  8. package/dist/src/core/dom-renderer/domRenderer.d.ts +2 -2
  9. package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
  10. package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
  11. package/dist/src/core/elementNode.d.ts +10 -4
  12. package/dist/src/core/elementNode.js +59 -44
  13. package/dist/src/core/elementNode.js.map +1 -1
  14. package/dist/src/core/focusManager.d.ts +2 -9
  15. package/dist/src/core/focusManager.js +111 -97
  16. package/dist/src/core/focusManager.js.map +1 -1
  17. package/dist/src/core/lightningInit.js +3 -0
  18. package/dist/src/core/lightningInit.js.map +1 -1
  19. package/dist/src/core/shaders.js +10 -10
  20. package/dist/src/core/shaders.js.map +1 -1
  21. package/dist/src/core/utils.d.ts +0 -1
  22. package/dist/src/core/utils.js +0 -1
  23. package/dist/src/core/utils.js.map +1 -1
  24. package/dist/src/index.d.ts +2 -1
  25. package/dist/src/index.js +2 -1
  26. package/dist/src/index.js.map +1 -1
  27. package/dist/src/primitives/FadeInOut.jsx +1 -2
  28. package/dist/src/primitives/FadeInOut.jsx.map +1 -1
  29. package/dist/src/primitives/Rail.d.ts +27 -0
  30. package/dist/src/primitives/Rail.jsx +322 -0
  31. package/dist/src/primitives/Rail.jsx.map +1 -0
  32. package/dist/src/primitives/index.d.ts +1 -0
  33. package/dist/src/primitives/useFocusManager.d.ts +2 -5
  34. package/dist/src/primitives/useFocusManager.js +2 -20
  35. package/dist/src/primitives/useFocusManager.js.map +1 -1
  36. package/dist/src/primitives/useHold.d.ts +1 -1
  37. package/dist/src/primitives/useHold.js +1 -1
  38. package/dist/src/primitives/useMouse.js +4 -4
  39. package/dist/src/primitives/useMouse.js.map +1 -1
  40. package/dist/src/render.d.ts +6 -0
  41. package/dist/src/render.js +7 -3
  42. package/dist/src/render.js.map +1 -1
  43. package/dist/src/solidOpts.d.ts +1 -1
  44. package/dist/src/solidOpts.js +4 -23
  45. package/dist/src/solidOpts.js.map +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/docs/AI_CODING_GUIDELINES.md +7 -7
  48. package/package.json +2 -2
  49. package/src/core/activeElement.ts +21 -0
  50. package/src/core/config.ts +24 -1
  51. package/src/core/dom-renderer/domRendererUtils.ts +2 -2
  52. package/src/core/elementNode.ts +65 -40
  53. package/src/core/focusManager.ts +158 -136
  54. package/src/core/lightningInit.ts +3 -0
  55. package/src/core/shaders.ts +10 -10
  56. package/src/core/utils.ts +0 -3
  57. package/src/index.ts +2 -1
  58. package/src/primitives/FadeInOut.tsx +2 -2
  59. package/src/primitives/Rail.tsx +401 -0
  60. package/src/primitives/index.ts +1 -0
  61. package/src/primitives/useFocusManager.ts +8 -44
  62. package/src/primitives/useHold.ts +1 -1
  63. package/src/primitives/useMouse.ts +4 -4
  64. package/src/render.ts +7 -3
  65. package/src/solidOpts.ts +4 -25
  66. package/dist/src/activeElement.d.ts +0 -2
  67. package/dist/src/activeElement.js +0 -3
  68. package/dist/src/activeElement.js.map +0 -1
  69. package/src/activeElement.ts +0 -5
@@ -0,0 +1,401 @@
1
+ import * as s from 'solid-js';
2
+ import * as lng from '@solidtv/solid';
3
+ import * as lngp from '@solidtv/solid/primitives';
4
+ import * as utils from '../utils.js';
5
+ import {
6
+ defaultTransitionBack,
7
+ defaultTransitionForward,
8
+ defaultTransitionDown,
9
+ defaultTransitionUp,
10
+ } from './utils/handleNavigation.js';
11
+
12
+ export type RailProps<T> = lng.NewOmit<lngp.RowProps, 'children'> & {
13
+ each: readonly T[] | undefined | null | false;
14
+ /** Uniform child size along the axis (width for Row, height for Column).
15
+ * If omitted, measured from the first laid-out child. */
16
+ itemSize?: number;
17
+ /** Space between items along the axis. Default 30. */
18
+ gap?: number;
19
+ /** Container size along the axis. If omitted, falls back to props.width/height,
20
+ * then measured from the rail's own layout. */
21
+ viewportSize?: number;
22
+ /** Extra items rendered outside the visible region on each side. Default 1. */
23
+ bufferSize?: number;
24
+ /** Window position where the focused item is pinned. Default 0. */
25
+ scrollIndex?: number;
26
+ wrap?: boolean;
27
+ onEndReached?: () => void;
28
+ /** Items from the end at which onEndReached first fires. Default 0. */
29
+ onEndReachedThreshold?: number;
30
+ /** Account for the focus-state scale when measuring item size. */
31
+ factorScale?: boolean;
32
+ children: (item: s.Accessor<T>, index: s.Accessor<number>) => s.JSX.Element;
33
+ };
34
+
35
+ function createRail<T>(
36
+ isRow: boolean,
37
+ props: RailProps<T>,
38
+ keyHandlers: Record<string, lng.KeyHandler>,
39
+ ) {
40
+ const axis: 'x' | 'y' = isRow ? 'x' : 'y';
41
+ const sizeKey: 'width' | 'height' = isRow ? 'width' : 'height';
42
+
43
+ const items = s.createMemo(() => props.each || []);
44
+ const itemCount = s.createMemo(() => items().length);
45
+ const gap = s.createMemo(() => props.gap ?? 30);
46
+ const bufferSize = s.createMemo(() => Math.max(0, props.bufferSize ?? 1));
47
+ const scrollIndex = s.createMemo(() => Math.max(0, props.scrollIndex ?? 0));
48
+
49
+ const [cursor, setCursor] = s.createSignal(props.selected ?? 0);
50
+ const [measuredItem, setMeasuredItem] = s.createSignal(0);
51
+ const [measuredViewport, setMeasuredViewport] = s.createSignal(0);
52
+
53
+ const itemSize = s.createMemo(() => props.itemSize ?? measuredItem());
54
+ // stride is only meaningful once item size is known; gap alone is not
55
+ // enough to space items, so treat unmeasured itemSize as "no stride yet"
56
+ // and let the bootstrap window in `windowLength` render a tiny slice for
57
+ // the first child to measure against.
58
+ const stride = s.createMemo(() => {
59
+ const is = itemSize();
60
+ return is > 0 ? is + gap() : 0;
61
+ });
62
+ const viewportSize = s.createMemo(
63
+ () =>
64
+ props.viewportSize ??
65
+ (props[sizeKey] as number | undefined) ??
66
+ measuredViewport(),
67
+ );
68
+
69
+ // displaySize = how many items fit in the viewport (uniform sizes).
70
+ // Returns 0 until both stride and viewport size are known.
71
+ const displaySize = s.createMemo(() => {
72
+ const st = stride();
73
+ const vp = viewportSize();
74
+ if (!st || !vp) return 0;
75
+ return Math.max(1, Math.ceil(vp / st));
76
+ });
77
+
78
+ // While unmeasured, behave as if displaySize === 1 so the bootstrap slice
79
+ // is positioned sensibly around the cursor instead of walking past the end.
80
+ const safeDisplaySize = s.createMemo(() => Math.max(1, displaySize()));
81
+
82
+ // Absolute index of the leftmost visible item. Pinning formula.
83
+ const visibleStart = s.createMemo(() => {
84
+ const total = itemCount();
85
+ if (total === 0) return 0;
86
+ const ds = safeDisplaySize();
87
+ if (props.wrap) return utils.mod(cursor() - scrollIndex(), total);
88
+ if (total <= ds) return 0;
89
+ return utils.clamp(cursor() - scrollIndex(), 0, total - ds);
90
+ });
91
+
92
+ // First rendered slot, includes leading buffer.
93
+ const windowStart = s.createMemo(() => {
94
+ const total = itemCount();
95
+ if (total === 0) return 0;
96
+ if (props.wrap) return utils.mod(visibleStart() - bufferSize(), total);
97
+ return Math.max(0, visibleStart() - bufferSize());
98
+ });
99
+
100
+ // Pool size = visible + leading + trailing buffer. Capped by total.
101
+ const windowLength = s.createMemo(() => {
102
+ const total = itemCount();
103
+ if (total === 0) return 0;
104
+ const len = safeDisplaySize() + 2 * bufferSize();
105
+ if (props.wrap) return Math.min(len, total);
106
+ return Math.min(len, total - windowStart());
107
+ });
108
+
109
+ const windowItems = s.createMemo(() => {
110
+ const len = windowLength();
111
+ if (len === 0) return [] as T[];
112
+ const start = windowStart();
113
+ const all = items();
114
+ if (props.wrap) {
115
+ const total = all.length;
116
+ return Array.from(
117
+ { length: len },
118
+ (_, i) => all[utils.mod(start + i, total)]!,
119
+ );
120
+ }
121
+ return all.slice(start, start + len);
122
+ });
123
+
124
+ // Slot of the focused item inside the rendered pool.
125
+ const windowSelected = s.createMemo(() => {
126
+ if (props.wrap) {
127
+ const total = itemCount();
128
+ if (total === 0) return 0;
129
+ return utils.mod(cursor() - windowStart(), total);
130
+ }
131
+ return cursor() - windowStart();
132
+ });
133
+
134
+ // Camera offset: keep visibleStart aligned to the viewport's leading edge.
135
+ const targetOffset = s.createMemo(() => -visibleStart() * stride());
136
+
137
+ // Total extent along the axis covered by the currently-rendered pool. The
138
+ // renderer culls children whose global rect falls outside their parent's
139
+ // strictBound, so we grow the rail's own bound to enclose all items in the
140
+ // pool (including buffer slots). Combined with `clipping={false}` this
141
+ // keeps off-viewport buffer items renderable as the camera slides.
142
+ const contentExtent = s.createMemo(() => {
143
+ const st = stride();
144
+ if (!st) return 0;
145
+ return (windowStart() + windowLength()) * st;
146
+ });
147
+
148
+ // Final width/height we hand to the underlying view along the axis.
149
+ // Always at least the user-supplied size so the rail occupies its slot in
150
+ // parent layout when the pool is short / unmeasured.
151
+ const railWidth = s.createMemo(() => {
152
+ if (!isRow) return props.width;
153
+ const userW = (props.width as number | undefined) ?? 0;
154
+ return Math.max(userW, contentExtent());
155
+ });
156
+ const railHeight = s.createMemo(() => {
157
+ if (isRow) return props.height;
158
+ const userH = (props.height as number | undefined) ?? 0;
159
+ return Math.max(userH, contentExtent());
160
+ });
161
+
162
+ let viewRef!: lngp.NavigableElement;
163
+ let cachedAnim: lng.IAnimationController | undefined;
164
+ let lastNavTime = 0;
165
+ let endFired = false;
166
+ let initialised = false;
167
+
168
+ function getAdaptiveDuration(duration: number = 250) {
169
+ const now = performance.now();
170
+ const delta = now - lastNavTime;
171
+ lastNavTime = now;
172
+ if (delta < duration) return delta;
173
+ return duration;
174
+ }
175
+
176
+ function applyOffset(target: number, animated: boolean) {
177
+ if (!viewRef) return;
178
+ if (cachedAnim && cachedAnim.state === 'running') cachedAnim.stop();
179
+ if (animated && lng.Config.animationsEnabled) {
180
+ cachedAnim = viewRef
181
+ .animate(
182
+ { [axis]: target },
183
+ {
184
+ ...viewRef.animationSettings,
185
+ duration: getAdaptiveDuration(viewRef.animationSettings?.duration),
186
+ },
187
+ )
188
+ .start();
189
+ } else {
190
+ viewRef.lng[axis] = target;
191
+ }
192
+ }
193
+
194
+ function scrollToIndex(this: lng.ElementNode, index: number) {
195
+ s.untrack(() => {
196
+ if (itemCount() === 0) return;
197
+ setCursor(utils.clamp(index, 0, itemCount() - 1));
198
+ if (!lng.hasFocus(viewRef)) viewRef.setFocus();
199
+ });
200
+ }
201
+
202
+ const onSelectedChanged: lngp.OnSelectedChanged = function (
203
+ idx,
204
+ elm,
205
+ active,
206
+ lastIdx,
207
+ ) {
208
+ if (props.onSelectedChanged) {
209
+ props.onSelectedChanged.call(this, idx, this, active, lastIdx);
210
+ }
211
+ if (idx === lastIdx) return;
212
+
213
+ const total = itemCount();
214
+ if (total === 0) return;
215
+
216
+ const poolLen = elm.children.length;
217
+ const rawDelta = idx - (lastIdx ?? 0);
218
+ let delta = rawDelta;
219
+ if (props.wrap && poolLen > 0) {
220
+ const half = poolLen / 2;
221
+ if (delta > half) delta = delta - poolLen;
222
+ else if (delta < -half) delta = delta + poolLen;
223
+ }
224
+
225
+ const next = props.wrap
226
+ ? utils.mod(cursor() + delta, total)
227
+ : utils.clamp(cursor() + delta, 0, total - 1);
228
+ setCursor(next);
229
+
230
+ if (props.onEndReached) {
231
+ const threshold = props.onEndReachedThreshold ?? 0;
232
+ const crossed = next >= total - 1 - threshold;
233
+ if (crossed && !endFired) {
234
+ endFired = true;
235
+ props.onEndReached();
236
+ } else if (!crossed && endFired) {
237
+ endFired = false;
238
+ }
239
+ }
240
+ };
241
+
242
+ // Animate the camera when visibleStart shifts; snap on first frame.
243
+ s.createEffect(() => {
244
+ const target = targetOffset();
245
+ if (!viewRef) return;
246
+ applyOffset(target, initialised);
247
+ initialised = true;
248
+ });
249
+
250
+ // Drive `selected` (and focus) imperatively. A `createMemo` would skip
251
+ // emitting when the computed slot value is unchanged across a window shift
252
+ // (e.g. cursor 3→4 with scrollIndex=0, windowStart 0→1 keeps slot=3), which
253
+ // leaves `el.selected` stuck at whatever selectChild just wrote during
254
+ // navigation. Tracking the underlying signals here forces a write every
255
+ // time cursor / window changes, overriding selectChild and keeping
256
+ // focus on the right slot as the pool slides.
257
+ s.createEffect(() => {
258
+ if (!viewRef) return;
259
+ const len = windowLength();
260
+ const ws = windowStart();
261
+ const c = cursor();
262
+ const sel = len === 0 ? 0 : utils.clamp(c - ws, 0, len - 1);
263
+ viewRef.selected = sel;
264
+ if (lng.hasFocus(viewRef) && viewRef.children[sel]) {
265
+ viewRef.children[sel].setFocus();
266
+ }
267
+ });
268
+
269
+ // Clamp cursor if the data shrinks; reset latch.
270
+ s.createEffect(
271
+ s.on(items, () => {
272
+ const total = itemCount();
273
+ if (total === 0) return;
274
+ if (cursor() >= total) setCursor(Math.max(0, total - 1));
275
+ endFired = false;
276
+ }),
277
+ );
278
+
279
+ // React to external `selected` changes.
280
+ s.createEffect(
281
+ s.on(
282
+ () => props.selected,
283
+ (sel) => {
284
+ if (sel == null) return;
285
+ const total = itemCount();
286
+ if (total === 0) return;
287
+ const safe = utils.clamp(sel, 0, total - 1);
288
+ if (safe !== cursor()) setCursor(safe);
289
+ },
290
+ { defer: true },
291
+ ),
292
+ );
293
+
294
+ const onContainerLayout = function (
295
+ this: lng.ElementNode,
296
+ el: lng.ElementNode,
297
+ ) {
298
+ if (props.viewportSize == null && props[sizeKey] == null) {
299
+ const v = (el[sizeKey] as number) || 0;
300
+ if (v && v !== measuredViewport()) setMeasuredViewport(v);
301
+ }
302
+ props.onLayout?.call(this, el);
303
+ };
304
+
305
+ // Position each user-rendered child directly (no wrapper view). We assign
306
+ // x/y on viewRef.children[i] reactively so the slots track the sliding
307
+ // window without an extra node per item.
308
+ s.createEffect(() => {
309
+ if (!viewRef) return;
310
+ const ws = windowStart();
311
+ const st = stride();
312
+ const children = viewRef.children;
313
+ for (let i = 0; i < children.length; i++) {
314
+ const c = children[i];
315
+ if (!c) continue;
316
+ const p = (ws + i) * st;
317
+ if (isRow) c.x = p;
318
+ else c.y = p;
319
+ }
320
+ });
321
+
322
+ // Measure item size from the first rendered child if not provided.
323
+ s.createEffect(() => {
324
+ if (props.itemSize != null) return;
325
+ // Track window changes so we re-measure if the first item swaps.
326
+ windowItems();
327
+ if (!viewRef) return;
328
+ const first = viewRef.children[0];
329
+ if (!first) return;
330
+ let raw = (first[sizeKey] as number) || 0;
331
+ if (props.factorScale) {
332
+ const focusStyle = first.style?.focus as lng.NodeStyles | undefined;
333
+ const scale = focusStyle?.scale ?? first.scale ?? 1;
334
+ raw = raw * scale;
335
+ }
336
+ if (raw && raw !== measuredItem()) setMeasuredItem(raw);
337
+ });
338
+
339
+ return (
340
+ <view
341
+ transitionLeft={isRow ? defaultTransitionBack : undefined}
342
+ transitionRight={isRow ? defaultTransitionForward : undefined}
343
+ transitionUp={!isRow ? defaultTransitionUp : undefined}
344
+ transitionDown={!isRow ? defaultTransitionDown : undefined}
345
+ {...props}
346
+ {...keyHandlers}
347
+ selected={0}
348
+ ref={lngp.chainRefs((el) => {
349
+ viewRef = el as lngp.NavigableElement;
350
+ }, props.ref)}
351
+ forwardFocus={/* @once */ lngp.navigableForwardFocus}
352
+ scrollToIndex={/* @once */ scrollToIndex}
353
+ onSelectedChanged={/* @once */ onSelectedChanged}
354
+ onLayout={onContainerLayout}
355
+ clipping={false}
356
+ width={railWidth()}
357
+ height={railHeight()}
358
+ >
359
+ <s.Index each={windowItems()}>
360
+ {(item, i) => {
361
+ const absIndex = s.createMemo(() => {
362
+ const total = itemCount();
363
+ if (props.wrap && total > 0) {
364
+ return utils.mod(windowStart() + i, total);
365
+ }
366
+ return windowStart() + i;
367
+ });
368
+ // No wrapper view: the user's element is positioned directly via
369
+ // an effect that writes x/y onto viewRef.children[i].
370
+ return props.children(item, absIndex);
371
+ }}
372
+ </s.Index>
373
+ </view>
374
+ );
375
+ }
376
+
377
+ export function RailRow<T>(props: RailProps<T>) {
378
+ return createRail(true, props, {
379
+ onLeft: lngp.chainFunctions(
380
+ props.onLeft,
381
+ lngp.handleNavigation('left'),
382
+ ) as lng.KeyHandler,
383
+ onRight: lngp.chainFunctions(
384
+ props.onRight,
385
+ lngp.handleNavigation('right'),
386
+ ) as lng.KeyHandler,
387
+ });
388
+ }
389
+
390
+ export function RailColumn<T>(props: RailProps<T>) {
391
+ return createRail(false, props, {
392
+ onUp: lngp.chainFunctions(
393
+ props.onUp,
394
+ lngp.handleNavigation('up'),
395
+ ) as lng.KeyHandler,
396
+ onDown: lngp.chainFunctions(
397
+ props.onDown,
398
+ lngp.handleNavigation('down'),
399
+ ) as lng.KeyHandler,
400
+ });
401
+ }
@@ -33,3 +33,4 @@ export { createBlurredImage } from './utils/createBlurredImage.js';
33
33
 
34
34
  export type * from './types.js';
35
35
  export type { KeyHandler } from '../core/focusManager.js';
36
+ export type { SpeechType } from './announcer/speech.js';
@@ -1,47 +1,11 @@
1
- import {
2
- createEffect,
3
- on,
4
- createSignal,
5
- onCleanup,
6
- getOwner,
7
- runWithOwner,
8
- } from 'solid-js';
9
- import { Config } from '../core/index.js';
10
- import type { ElementNode } from '../core/index.js';
11
- import {
12
- useFocusManager as useFocusManagerCore,
1
+ export {
2
+ focusPath,
3
+ useFocusManager,
4
+ setActiveElement,
13
5
  type KeyMap,
14
6
  type KeyHoldOptions,
15
7
  } from '../core/focusManager.js';
16
- import { activeElement, setActiveElement } from '../activeElement.js';
17
-
18
- const [focusPath, setFocusPath] = createSignal<ElementNode[]>([]);
19
- export { focusPath };
20
-
21
- export const useFocusManager = (
22
- userKeyMap?: Partial<KeyMap>,
23
- keyHoldOptions?: KeyHoldOptions,
24
- ) => {
25
- const owner = getOwner();
26
- const ownerContext = runWithOwner.bind(this, owner);
27
- Config.setActiveElement = (activeElm) =>
28
- ownerContext(() => setActiveElement(activeElm));
29
-
30
- const { cleanup, focusPath: focusPathCore } = useFocusManagerCore({
31
- userKeyMap,
32
- keyHoldOptions,
33
- ownerContext,
34
- });
35
-
36
- createEffect(
37
- on(
38
- activeElement,
39
- () => {
40
- setFocusPath([...focusPathCore()]);
41
- },
42
- { defer: true },
43
- ),
44
- );
45
-
46
- onCleanup(cleanup);
47
- };
8
+ export {
9
+ activeElement,
10
+ setActiveElementSignal,
11
+ } from '../core/activeElement.js';
@@ -18,7 +18,7 @@ export type UseHoldProps = {
18
18
  * performOnEnterImmediately: true
19
19
  * });
20
20
  *
21
- * <View
21
+ * <view
22
22
  * onRight={holdRight}
23
23
  * onRightRelease={releaseRight}
24
24
  * />
@@ -4,7 +4,7 @@ import {
4
4
  ElementNode,
5
5
  activeElement,
6
6
  isElementNode,
7
- isFunc,
7
+ isFunction,
8
8
  rootNode,
9
9
  } from '../index.js';
10
10
  import { makeEventListener } from '@solid-primitives/event-listener';
@@ -128,7 +128,7 @@ function findElementByActiveElement(e: MouseEvent): ElementNode | null {
128
128
  let parent = active?.parent;
129
129
  while (parent) {
130
130
  if (
131
- isFunc(parent.onMouseClick) &&
131
+ isFunction(parent.onMouseClick) &&
132
132
  testCollision(
133
133
  px,
134
134
  py,
@@ -167,10 +167,10 @@ function handleElementClick(
167
167
  pressedElementRef.current = null;
168
168
  }
169
169
 
170
- if (isFunc(clickedElement.onMouseClick)) {
170
+ if (isFunction(clickedElement.onMouseClick)) {
171
171
  clickedElement.onMouseClick(e, clickedElement);
172
172
  return;
173
- } else if (isFunc(clickedElement.onEnter)) {
173
+ } else if (isFunction(clickedElement.onEnter)) {
174
174
  clickedElement.onEnter();
175
175
  return;
176
176
  }
package/src/render.ts CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  type Component,
19
19
  } from 'solid-js';
20
20
  import type { SolidNode } from './types.js';
21
- import { activeElement, setActiveElement } from './activeElement.js';
21
+ import { activeElement } from './core/activeElement.js';
22
22
 
23
23
  const solidRenderer = solidCreateRenderer<SolidNode>(nodeOpts);
24
24
 
@@ -37,8 +37,6 @@ export function createRenderer(
37
37
  const options = rendererOptions || Config.rendererOptions;
38
38
 
39
39
  renderer = startLightningRenderer(options!, node || 'app');
40
- //Prevent this from happening automatically
41
- Config.setActiveElement = setActiveElement;
42
40
  rootNode.lng = renderer.root!;
43
41
  rootNode.rendered = true;
44
42
  renderer.on('idle', () => {
@@ -146,12 +144,18 @@ export function Dynamic<T extends Record<string, any>>(
146
144
  }
147
145
 
148
146
  // Dont use JSX as it creates circular dependencies and causes trouble with the playground.
147
+ /**
148
+ * @deprecated Use the lowercase `<view>` intrinsic element instead. The `View` component will be removed in a future release.
149
+ */
149
150
  export const View = (props: NodeProps) => {
150
151
  const el = createElement('node');
151
152
  spread(el, props, false);
152
153
  return el as unknown as JSXElement;
153
154
  };
154
155
 
156
+ /**
157
+ * @deprecated Use the lowercase `<text>` intrinsic element instead. The `Text` component will be removed in a future release.
158
+ */
155
159
  export const Text = (props: TextProps) => {
156
160
  const el = createElement('text');
157
161
  spread(el, props, false);
package/src/solidOpts.ts CHANGED
@@ -5,31 +5,10 @@ import {
5
5
  TextNode,
6
6
  log,
7
7
  type ElementText,
8
- elementDeleteQueue,
9
- schedulePostMutation,
8
+ enqueueDelete,
10
9
  } from './core/index.js';
11
10
  import type { SolidNode, SolidRendererOptions } from './types.js';
12
11
 
13
- Object.defineProperty(ElementNode.prototype, 'preserve', {
14
- get(this: ElementNode): boolean | undefined {
15
- return this._queueDelete === 0;
16
- },
17
- set(this: ElementNode, v: boolean) {
18
- this._queueDelete = v ? 0 : undefined;
19
- },
20
- });
21
-
22
- function pushDeleteQueue(node: ElementNode, n: number): void {
23
- if (node._queueDelete === undefined) {
24
- node._queueDelete = n;
25
- if (elementDeleteQueue.push(node) === 1) {
26
- schedulePostMutation();
27
- }
28
- } else {
29
- node._queueDelete += n;
30
- }
31
- }
32
-
33
12
  export default {
34
13
  createElement(name: string): ElementNode {
35
14
  return new ElementNode(name);
@@ -45,7 +24,7 @@ export default {
45
24
  assertTruthy(parent);
46
25
  parent.text = parent.getText();
47
26
  },
48
- setProperty(node: ElementNode, name: string, value: any = true): void {
27
+ setProperty(node: ElementNode, name: string, value: any): void {
49
28
  node[name] = value;
50
29
  },
51
30
  insertNode(parent: ElementNode, node: SolidNode, anchor: SolidNode): void {
@@ -59,7 +38,7 @@ export default {
59
38
  node.render(true);
60
39
  }
61
40
  if (prevParent !== undefined) {
62
- pushDeleteQueue(node, 1);
41
+ enqueueDelete(node, 1);
63
42
  }
64
43
  } else if (isElementText(parent)) {
65
44
  // TextNodes can be placed outside of <text> nodes when <Show> is used as placeholder
@@ -75,7 +54,7 @@ export default {
75
54
  parent.removeChild(node);
76
55
 
77
56
  if (node instanceof ElementNode) {
78
- pushDeleteQueue(node, -1);
57
+ enqueueDelete(node, -1);
79
58
  } else if (isElementText(parent)) {
80
59
  // TextNodes can be placed outside of <text> nodes when <Show> is used as placeholder
81
60
  parent.text = parent.getText();
@@ -1,2 +0,0 @@
1
- import { type ElementNode } from './core/index.js';
2
- export declare const activeElement: import("solid-js").Accessor<ElementNode | undefined>, setActiveElement: import("solid-js").Setter<ElementNode | undefined>;
@@ -1,3 +0,0 @@
1
- import { createSignal } from 'solid-js';
2
- export const [activeElement, setActiveElement] = createSignal(undefined);
3
- //# sourceMappingURL=activeElement.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"activeElement.js","sourceRoot":"","sources":["../../src/activeElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,YAAY,CAE3D,SAAS,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- import { createSignal } from 'solid-js';
2
- import { type ElementNode } from './core/index.js';
3
- export const [activeElement, setActiveElement] = createSignal<
4
- ElementNode | undefined
5
- >(undefined);