@solidtv/solid 1.1.2 → 1.2.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.
- package/dist/src/core/clickInspector.d.ts +1 -0
- package/dist/src/core/clickInspector.js +69 -0
- package/dist/src/core/clickInspector.js.map +1 -0
- package/dist/src/core/config.d.ts +8 -14
- package/dist/src/core/config.js +17 -3
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/dom-renderer/domRenderer.d.ts +6 -1
- package/dist/src/core/dom-renderer/domRenderer.js +255 -67
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
- package/dist/src/core/dom-renderer/domRendererUtils.js +2 -2
- package/dist/src/core/dom-renderer/domRendererUtils.js.map +1 -1
- package/dist/src/core/elementNode.d.ts +30 -11
- package/dist/src/core/elementNode.js +113 -58
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/focusManager.d.ts +3 -9
- package/dist/src/core/focusManager.js +111 -101
- package/dist/src/core/focusManager.js.map +1 -1
- package/dist/src/core/intrinsicTypes.d.ts +2 -0
- package/dist/src/core/lightningInit.d.ts +1 -1
- package/dist/src/core/lightningInit.js +9 -9
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/core/shaders.js +10 -10
- package/dist/src/core/shaders.js.map +1 -1
- package/dist/src/core/utils.d.ts +0 -1
- package/dist/src/core/utils.js +4 -5
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/primitives/FPSCounter.jsx +5 -5
- package/dist/src/primitives/FPSCounter.jsx.map +1 -1
- package/dist/src/primitives/Image.jsx +6 -1
- package/dist/src/primitives/Image.jsx.map +1 -1
- package/dist/src/primitives/KeepAlive.jsx +13 -3
- package/dist/src/primitives/KeepAlive.jsx.map +1 -1
- package/dist/src/primitives/LazyImport.js +4 -2
- package/dist/src/primitives/LazyImport.js.map +1 -1
- package/dist/src/primitives/Preserve.jsx +10 -4
- package/dist/src/primitives/Preserve.jsx.map +1 -1
- package/dist/src/primitives/Suspense.jsx +7 -7
- package/dist/src/primitives/Suspense.jsx.map +1 -1
- package/dist/src/primitives/Virtual.jsx.map +1 -1
- package/dist/src/primitives/announcer/announcer.js +3 -2
- package/dist/src/primitives/announcer/announcer.js.map +1 -1
- package/dist/src/primitives/announcer/speech.js +2 -2
- package/dist/src/primitives/announcer/speech.js.map +1 -1
- package/dist/src/primitives/borderBox.jsx +2 -1
- package/dist/src/primitives/borderBox.jsx.map +1 -1
- package/dist/src/primitives/createTag.jsx +3 -3
- package/dist/src/primitives/createTag.jsx.map +1 -1
- package/dist/src/primitives/portal.jsx +4 -3
- package/dist/src/primitives/portal.jsx.map +1 -1
- package/dist/src/primitives/useFocusManager.d.ts +1 -5
- package/dist/src/primitives/useFocusManager.js +1 -20
- package/dist/src/primitives/useFocusManager.js.map +1 -1
- package/dist/src/primitives/useMouse.js +4 -4
- package/dist/src/primitives/useMouse.js.map +1 -1
- package/dist/src/primitives/utils/chainFunctions.js +35 -9
- package/dist/src/primitives/utils/chainFunctions.js.map +1 -1
- package/dist/src/primitives/utils/createBlurredImage.js +57 -37
- package/dist/src/primitives/utils/createBlurredImage.js.map +1 -1
- package/dist/src/primitives/utils/handleNavigation.js +8 -6
- package/dist/src/primitives/utils/handleNavigation.js.map +1 -1
- package/dist/src/primitives/utils/withScrolling.js +1 -3
- package/dist/src/primitives/utils/withScrolling.js.map +1 -1
- package/dist/src/render.d.ts +1 -1
- package/dist/src/render.js +3 -4
- package/dist/src/render.js.map +1 -1
- package/dist/src/solidOpts.d.ts +1 -1
- package/dist/src/solidOpts.js +8 -25
- package/dist/src/solidOpts.js.map +1 -1
- package/dist/src/utils.js +10 -5
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/README.md +2 -2
- package/package.json +28 -29
- package/src/core/clickInspector.ts +77 -0
- package/src/core/config.ts +15 -22
- package/src/core/dom-renderer/domRenderer.ts +308 -89
- package/src/core/dom-renderer/domRendererTypes.ts +9 -6
- package/src/core/dom-renderer/domRendererUtils.ts +2 -2
- package/src/core/elementNode.ts +145 -66
- package/src/core/focusManager.ts +171 -145
- package/src/core/intrinsicTypes.ts +19 -7
- package/src/core/lightningInit.ts +23 -21
- package/src/core/shaders.ts +10 -10
- package/src/core/utils.ts +4 -7
- package/src/index.ts +1 -1
- package/src/primitives/FPSCounter.tsx +14 -10
- package/src/primitives/Image.tsx +18 -9
- package/src/primitives/KeepAlive.tsx +18 -10
- package/src/primitives/LazyImport.ts +8 -6
- package/src/primitives/Preserve.tsx +13 -8
- package/src/primitives/Suspense.tsx +10 -9
- package/src/primitives/Virtual.tsx +1 -8
- package/src/primitives/announcer/announcer.ts +3 -2
- package/src/primitives/announcer/speech.ts +2 -2
- package/src/primitives/borderBox.tsx +7 -3
- package/src/primitives/createTag.tsx +23 -17
- package/src/primitives/portal.tsx +20 -10
- package/src/primitives/useFocusManager.ts +5 -44
- package/src/primitives/useMouse.ts +4 -4
- package/src/primitives/utils/chainFunctions.ts +31 -11
- package/src/primitives/utils/createBlurredImage.ts +58 -40
- package/src/primitives/utils/handleNavigation.ts +9 -7
- package/src/primitives/utils/withScrolling.ts +3 -5
- package/src/render.ts +5 -7
- package/src/solidOpts.ts +11 -30
- package/src/types.ts +0 -1
- package/src/utils.ts +12 -10
- package/dist/src/activeElement.d.ts +0 -2
- package/dist/src/activeElement.js +0 -3
- package/dist/src/activeElement.js.map +0 -1
- package/src/activeElement.ts +0 -5
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type * from '@solidtv/solid/jsx-runtime';
|
|
|
2
2
|
export * from './core/index.js';
|
|
3
3
|
export type * from './core/index.js';
|
|
4
4
|
export type { KeyHandler, KeyMap } from './core/focusManager.js';
|
|
5
|
-
export
|
|
5
|
+
export { activeElement, setActiveElement } from './core/focusManager.js';
|
|
6
6
|
export * from './utils.js';
|
|
7
7
|
export * from './render.js';
|
|
8
8
|
export * from './types.js';
|
|
@@ -9,18 +9,18 @@ const fpsStyle = {
|
|
|
9
9
|
y: 6,
|
|
10
10
|
mountX: 1,
|
|
11
11
|
alpha: 1,
|
|
12
|
-
zIndex: 100
|
|
12
|
+
zIndex: 100,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const fpsLabel = {
|
|
16
16
|
x: 10,
|
|
17
17
|
fontSize: 20,
|
|
18
|
-
textColor: 0xf6f6f6ff
|
|
18
|
+
textColor: 0xf6f6f6ff,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const fpsValue = {
|
|
22
22
|
fontSize: 22,
|
|
23
|
-
textColor: 0xf6f6f6ff
|
|
23
|
+
textColor: 0xf6f6f6ff,
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const [fps, setFps] = createSignal(0);
|
|
@@ -32,7 +32,8 @@ const [criticalThresholdSignal, setCriticalThresholdSignal] = createSignal('');
|
|
|
32
32
|
const [targetThresholdSignal, setTargetThresholdSignal] = createSignal('');
|
|
33
33
|
const [renderableMemUsedSignal, setRenderableMemUsedSignal] = createSignal('');
|
|
34
34
|
const [memUsedSignal, setMemUsedSignal] = createSignal('');
|
|
35
|
-
const [renderableTexturesLoadedSignal, setRenderableTexturesLoadedSignal] =
|
|
35
|
+
const [renderableTexturesLoadedSignal, setRenderableTexturesLoadedSignal] =
|
|
36
|
+
createSignal(0);
|
|
36
37
|
const [loadedTexturesSignal, setLoadedTexturesSignal] = createSignal(0);
|
|
37
38
|
const [renderOps, setRenderOps] = createSignal(0);
|
|
38
39
|
|
|
@@ -60,8 +61,8 @@ const calcFps = (fps: number) => {
|
|
|
60
61
|
if (!fps) return;
|
|
61
62
|
|
|
62
63
|
setFps(fps);
|
|
63
|
-
setMinFps(prev => Math.min(fps, prev));
|
|
64
|
-
setMaxFps(prev => Math.max(fps, prev));
|
|
64
|
+
setMinFps((prev) => Math.min(fps, prev));
|
|
65
|
+
setMaxFps((prev) => Math.max(fps, prev));
|
|
65
66
|
|
|
66
67
|
totalFps += fps;
|
|
67
68
|
count++;
|
|
@@ -94,10 +95,13 @@ export function setupFPS(root: any) {
|
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
|
|
97
|
-
root.renderer.on(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
root.renderer.on(
|
|
99
|
+
'renderUpdate',
|
|
100
|
+
(target: RendererMain, quadsData: RenderUpdatePayload) => {
|
|
101
|
+
setQuads(quadsData.quads);
|
|
102
|
+
setRenderOps(quadsData.renderOps);
|
|
103
|
+
},
|
|
104
|
+
);
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
export const FPSCounter = (props: NodeProps) => {
|
package/src/primitives/Image.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Component, createRenderEffect, createSignal } from 'solid-js';
|
|
2
|
-
import { renderer, type NodeProps
|
|
2
|
+
import { ImageTexture, renderer, type NodeProps } from '@solidtv/solid';
|
|
3
3
|
import { Config } from '../core/config.js';
|
|
4
4
|
|
|
5
5
|
export interface ImageProps extends NodeProps {
|
|
@@ -10,7 +10,7 @@ export interface ImageProps extends NodeProps {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const Image: Component<ImageProps> = (props) => {
|
|
13
|
-
const [texture, setTexture] = createSignal<
|
|
13
|
+
const [texture, setTexture] = createSignal<ImageTexture | null>(null);
|
|
14
14
|
const [src, setSrc] = createSignal<string | null>(props.placeholder || null);
|
|
15
15
|
|
|
16
16
|
createRenderEffect(() => {
|
|
@@ -43,14 +43,23 @@ export const Image: Component<ImageProps> = (props) => {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
srcTexture
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
srcTexture
|
|
47
|
+
.getTextureData()
|
|
48
|
+
.then((resp) => {
|
|
49
|
+
// if texture fails to load, this is still called after the failed handler
|
|
50
|
+
if (resp.data) setTexture(srcTexture);
|
|
51
|
+
})
|
|
52
|
+
.catch(() => {
|
|
53
|
+
// handle potential errors from getTextureData
|
|
54
|
+
});
|
|
55
|
+
});
|
|
52
56
|
|
|
53
57
|
return (
|
|
54
|
-
<view
|
|
58
|
+
<view
|
|
59
|
+
{...props}
|
|
60
|
+
src={src()}
|
|
61
|
+
color={props.color || 0xffffffff}
|
|
62
|
+
texture={texture()}
|
|
63
|
+
/>
|
|
55
64
|
);
|
|
56
65
|
};
|
|
@@ -212,7 +212,7 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
212
212
|
};
|
|
213
213
|
|
|
214
214
|
const onRemove = chainFunctions(props.onRemove, (elm: ElementNode) => {
|
|
215
|
-
savedFocusedElement = activeElement()
|
|
215
|
+
savedFocusedElement = activeElement();
|
|
216
216
|
elm.alpha = 0;
|
|
217
217
|
});
|
|
218
218
|
|
|
@@ -238,7 +238,9 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
238
238
|
const preload = props.preload
|
|
239
239
|
? (preloadProps: RoutePreloadFuncArgs) => {
|
|
240
240
|
let existing = getExisting();
|
|
241
|
-
const existingChild = existing.children as unknown as
|
|
241
|
+
const existingChild = existing.children as unknown as
|
|
242
|
+
| ElementNode
|
|
243
|
+
| undefined;
|
|
242
244
|
|
|
243
245
|
if (
|
|
244
246
|
existingChild &&
|
|
@@ -254,11 +256,17 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
254
256
|
return s.createRoot((dispose) => {
|
|
255
257
|
existing.owner = s.getOwner();
|
|
256
258
|
existing.dispose = dispose;
|
|
257
|
-
return props.preload!({
|
|
259
|
+
return props.preload!({
|
|
260
|
+
...preloadProps,
|
|
261
|
+
isAlive: existing.isAlive!,
|
|
262
|
+
});
|
|
258
263
|
});
|
|
259
264
|
} else if (existing.children) {
|
|
260
265
|
(existing.children as unknown as ElementNode).setFocus();
|
|
261
|
-
return props.preload!({
|
|
266
|
+
return props.preload!({
|
|
267
|
+
...preloadProps,
|
|
268
|
+
isAlive: existing.isAlive!,
|
|
269
|
+
});
|
|
262
270
|
} else {
|
|
263
271
|
return props.preload!({
|
|
264
272
|
...preloadProps,
|
|
@@ -277,7 +285,11 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
277
285
|
// causing the sibling's component to be created from the preserved
|
|
278
286
|
// KeepAlive subtree. Inherit via prototype so the getter is preserved.
|
|
279
287
|
const innerProps = Object.create(childProps, {
|
|
280
|
-
isAlive: {
|
|
288
|
+
isAlive: {
|
|
289
|
+
value: existing.isAlive!,
|
|
290
|
+
enumerable: true,
|
|
291
|
+
configurable: true,
|
|
292
|
+
},
|
|
281
293
|
}) as RouteProps<S> & { isAlive: s.Accessor<boolean> };
|
|
282
294
|
return (
|
|
283
295
|
<KeepAliveRouteInternal
|
|
@@ -292,11 +304,7 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
292
304
|
};
|
|
293
305
|
|
|
294
306
|
const routeElement = (
|
|
295
|
-
<Route
|
|
296
|
-
{...props}
|
|
297
|
-
preload={preload}
|
|
298
|
-
component={componentWrapper}
|
|
299
|
-
/>
|
|
307
|
+
<Route {...props} preload={preload} component={componentWrapper} />
|
|
300
308
|
);
|
|
301
309
|
|
|
302
310
|
keepAliveRouteCache.set(key, routeElement);
|
|
@@ -20,12 +20,14 @@ export function lazy<T extends Component<any>>(
|
|
|
20
20
|
const [s, set] = createSignal<T>();
|
|
21
21
|
sharedConfig.count || (sharedConfig.count = 0);
|
|
22
22
|
sharedConfig.count++;
|
|
23
|
-
(p || (p = fn()))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
(p || (p = fn()))
|
|
24
|
+
.then((mod) => {
|
|
25
|
+
!sharedConfig.done && (sharedConfig.context = ctx);
|
|
26
|
+
sharedConfig.count!--;
|
|
27
|
+
set(() => mod.default);
|
|
28
|
+
sharedConfig.context = undefined;
|
|
29
|
+
})
|
|
30
|
+
.catch(() => {});
|
|
29
31
|
comp = s;
|
|
30
32
|
} else if (!comp) {
|
|
31
33
|
const [s] = createResource<T>(() =>
|
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import * as s from 'solid-js'
|
|
2
|
-
import * as lng from '@solidtv/solid'
|
|
1
|
+
import * as s from 'solid-js';
|
|
2
|
+
import * as lng from '@solidtv/solid';
|
|
3
3
|
|
|
4
4
|
function Preserve(props: lng.NodeProps): s.JSX.Element {
|
|
5
|
-
|
|
6
|
-
const view = <view {...props} /> as any as lng.ElementNode
|
|
5
|
+
const view = (<view {...props} />) as unknown as lng.ElementNode;
|
|
7
6
|
|
|
8
7
|
view.preserve = true;
|
|
9
8
|
|
|
10
|
-
view.onRender ??= () => {
|
|
11
|
-
|
|
9
|
+
view.onRender ??= () => {
|
|
10
|
+
view.hidden = false;
|
|
11
|
+
};
|
|
12
|
+
view.onRemove ??= () => {
|
|
13
|
+
view.hidden = true;
|
|
14
|
+
};
|
|
12
15
|
|
|
13
|
-
s.onCleanup(() => {
|
|
16
|
+
s.onCleanup(() => {
|
|
17
|
+
view.destroy();
|
|
18
|
+
});
|
|
14
19
|
|
|
15
|
-
return view as
|
|
20
|
+
return view as unknown as s.JSX.Element;
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
export default Preserve;
|
|
@@ -21,19 +21,20 @@ export function Suspense(props: {
|
|
|
21
21
|
fallback?: s.JSX.Element;
|
|
22
22
|
children: s.JSX.Element;
|
|
23
23
|
}): s.JSX.Element {
|
|
24
|
-
|
|
25
24
|
let children: s.JSX.Element;
|
|
26
25
|
|
|
27
26
|
const suspense = s.Suspense({
|
|
28
27
|
get children() {
|
|
29
|
-
return [children = s.children(() => props.children) as any];
|
|
28
|
+
return [(children = s.children(() => props.children) as any)];
|
|
30
29
|
},
|
|
31
|
-
}) as
|
|
30
|
+
}) as unknown as () => s.JSX.Element;
|
|
32
31
|
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
{suspense() ?? props.fallback}
|
|
35
|
+
<view hidden forwardFocus={0}>
|
|
36
|
+
{suspense() ? null : children}
|
|
37
|
+
</view>
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
39
40
|
}
|
|
@@ -317,7 +317,6 @@ function createVirtual<T>(
|
|
|
317
317
|
}
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
320
|
-
|
|
321
320
|
case 'none':
|
|
322
321
|
default:
|
|
323
322
|
start = 0;
|
|
@@ -405,13 +404,7 @@ function createVirtual<T>(
|
|
|
405
404
|
originalPosition = originalPosition ?? elm[axis];
|
|
406
405
|
|
|
407
406
|
if (props.onSelectedChanged) {
|
|
408
|
-
props.onSelectedChanged.call(
|
|
409
|
-
this,
|
|
410
|
-
idx,
|
|
411
|
-
this,
|
|
412
|
-
active,
|
|
413
|
-
lastIdx,
|
|
414
|
-
);
|
|
407
|
+
props.onSelectedChanged.call(this, idx, this, active, lastIdx);
|
|
415
408
|
}
|
|
416
409
|
|
|
417
410
|
if (noChange) return;
|
|
@@ -148,7 +148,7 @@ export const Announcer: Announcer = {
|
|
|
148
148
|
lang: 'en-US',
|
|
149
149
|
aria: false,
|
|
150
150
|
cancel: function () {
|
|
151
|
-
currentlySpeaking
|
|
151
|
+
currentlySpeaking?.cancel();
|
|
152
152
|
},
|
|
153
153
|
clearPrevFocus: function (depth = 0) {
|
|
154
154
|
prevFocusPath = prevFocusPath.slice(0, depth);
|
|
@@ -178,8 +178,9 @@ export const Announcer: Announcer = {
|
|
|
178
178
|
},
|
|
179
179
|
refresh: function (depth = 0) {
|
|
180
180
|
Announcer.clearPrevFocus(depth);
|
|
181
|
-
Announcer.onFocusChange
|
|
181
|
+
if (Announcer.onFocusChange) {
|
|
182
182
|
Announcer.onFocusChange(untrack(() => focusPath()));
|
|
183
|
+
}
|
|
183
184
|
},
|
|
184
185
|
setupTimers: function ({
|
|
185
186
|
focusDebounce = 400,
|
|
@@ -154,7 +154,7 @@ function speak(
|
|
|
154
154
|
resolve();
|
|
155
155
|
};
|
|
156
156
|
utterance.onerror = (e) => {
|
|
157
|
-
reject(e);
|
|
157
|
+
reject(new Error(`Speech synthesis error: ${e.error}`));
|
|
158
158
|
};
|
|
159
159
|
utterances.push(utterance);
|
|
160
160
|
synth.speak(utterance);
|
|
@@ -328,7 +328,7 @@ export default function (
|
|
|
328
328
|
lang: string = 'en-US',
|
|
329
329
|
voice?: string,
|
|
330
330
|
) {
|
|
331
|
-
currentSeries
|
|
331
|
+
currentSeries?.cancel();
|
|
332
332
|
currentSeries = speakSeries(toSpeak, aria, lang, voice);
|
|
333
333
|
return currentSeries;
|
|
334
334
|
}
|
|
@@ -28,8 +28,12 @@ const borderComponent = (props: BorderProps) => {
|
|
|
28
28
|
el.alpha = 1;
|
|
29
29
|
}}
|
|
30
30
|
onDestroy={(el) => {
|
|
31
|
+
const transition = el.transition;
|
|
31
32
|
return el
|
|
32
|
-
.animate(
|
|
33
|
+
.animate(
|
|
34
|
+
{ alpha: 0 },
|
|
35
|
+
typeof transition === 'object' ? transition : undefined,
|
|
36
|
+
)
|
|
33
37
|
.start()
|
|
34
38
|
.waitUntilStopped();
|
|
35
39
|
}}
|
|
@@ -55,8 +59,8 @@ export function borderBox(
|
|
|
55
59
|
runWithOwner(owner, () => {
|
|
56
60
|
const props = accessor();
|
|
57
61
|
border = borderComponent(
|
|
58
|
-
props === true || props === undefined ?
|
|
59
|
-
) as
|
|
62
|
+
props === true || props === undefined ? {} : props,
|
|
63
|
+
) as unknown as ElementNode;
|
|
60
64
|
insertNode(el, border);
|
|
61
65
|
border.render();
|
|
62
66
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as s from 'solid-js'
|
|
2
|
-
import * as lng from '@solidtv/solid'
|
|
1
|
+
import * as s from 'solid-js';
|
|
2
|
+
import * as lng from '@solidtv/solid';
|
|
3
3
|
|
|
4
4
|
interface Destroyable {
|
|
5
5
|
(props: lng.NodeProps): s.JSX.Element;
|
|
@@ -7,21 +7,27 @@ interface Destroyable {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function createTag(children: s.JSX.Element): Destroyable {
|
|
10
|
-
const [texture, setTexture] = s.createSignal<lng.Texture | null | undefined>(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
const [texture, setTexture] = s.createSignal<lng.Texture | null | undefined>(
|
|
11
|
+
null,
|
|
12
|
+
);
|
|
13
|
+
const Tag = (
|
|
14
|
+
<view
|
|
15
|
+
x={lng.rootNode.w - 1}
|
|
16
|
+
y={lng.rootNode.h - 1}
|
|
17
|
+
display="flex"
|
|
18
|
+
onLayout={(n) => {
|
|
19
|
+
if (n.preFlexwidth && n.width !== n.preFlexwidth) {
|
|
20
|
+
n.rtt = true;
|
|
21
|
+
setTimeout(() => setTexture(n.texture), 1);
|
|
22
|
+
}
|
|
23
|
+
}}
|
|
24
|
+
parent={lng.rootNode}
|
|
25
|
+
children={children}
|
|
26
|
+
textureOptions={{
|
|
27
|
+
preventCleanup: true,
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
30
|
+
) as unknown as lng.ElementNode;
|
|
25
31
|
Tag.render(false);
|
|
26
32
|
|
|
27
33
|
const TagComponent = (props: lng.NodeProps) => {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { rootNode, type ElementNode, insert } from '@solidtv/solid';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createEffect,
|
|
4
|
+
createMemo,
|
|
5
|
+
createRoot,
|
|
6
|
+
createSignal,
|
|
7
|
+
getOwner,
|
|
8
|
+
JSX,
|
|
9
|
+
onCleanup,
|
|
10
|
+
runWithOwner,
|
|
11
|
+
} from 'solid-js';
|
|
3
12
|
|
|
4
13
|
export function Portal(props: { mount?: string; children: JSX.Element }) {
|
|
5
14
|
let content: undefined | (() => JSX.Element);
|
|
@@ -11,15 +20,16 @@ export function Portal(props: { mount?: string; children: JSX.Element }) {
|
|
|
11
20
|
return rootNode.searchChildrenById(mount) || rootNode;
|
|
12
21
|
}
|
|
13
22
|
|
|
14
|
-
createEffect(
|
|
15
|
-
()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
content ||
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
createEffect(() => {
|
|
24
|
+
const [clean, setClean] = createSignal(false);
|
|
25
|
+
const cleanup = () => setClean(true);
|
|
26
|
+
content =
|
|
27
|
+
content || runWithOwner(owner, () => createMemo(() => props.children));
|
|
28
|
+
createRoot((dispose) =>
|
|
29
|
+
insert(mount(), () => (!clean() ? content!() : dispose()), null),
|
|
30
|
+
);
|
|
31
|
+
onCleanup(cleanup);
|
|
32
|
+
});
|
|
23
33
|
|
|
24
34
|
return null;
|
|
25
35
|
}
|
|
@@ -1,47 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
activeElement,
|
|
5
|
+
setActiveElement,
|
|
13
6
|
type KeyMap,
|
|
14
7
|
type KeyHoldOptions,
|
|
15
8
|
} 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
|
-
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ElementNode,
|
|
5
5
|
activeElement,
|
|
6
6
|
isElementNode,
|
|
7
|
-
|
|
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
|
-
|
|
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 (
|
|
170
|
+
if (isFunction(clickedElement.onMouseClick)) {
|
|
171
171
|
clickedElement.onMouseClick(e, clickedElement);
|
|
172
172
|
return;
|
|
173
|
-
} else if (
|
|
173
|
+
} else if (isFunction(clickedElement.onEnter)) {
|
|
174
174
|
clickedElement.onEnter();
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
@@ -23,22 +23,42 @@ export function chainFunctions<T extends AnyFunction>(
|
|
|
23
23
|
export function chainFunctions(
|
|
24
24
|
...fns: (AnyFunction | undefined | null | false)[]
|
|
25
25
|
): AnyFunction | undefined {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// Inline filter to avoid the intermediate array allocation when most
|
|
27
|
+
// callers pass 2 args and one or both happen to be falsy.
|
|
28
|
+
let first: AnyFunction | undefined;
|
|
29
|
+
let onlyFunctions: AnyFunction[] | undefined;
|
|
30
|
+
for (let i = 0; i < fns.length; i++) {
|
|
31
|
+
const fn = fns[i];
|
|
32
|
+
if (typeof fn !== 'function') continue;
|
|
33
|
+
if (first === undefined) {
|
|
34
|
+
first = fn;
|
|
35
|
+
} else {
|
|
36
|
+
if (onlyFunctions === undefined) onlyFunctions = [first];
|
|
37
|
+
onlyFunctions.push(fn);
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
if (
|
|
32
|
-
|
|
41
|
+
if (first === undefined) return undefined;
|
|
42
|
+
if (onlyFunctions === undefined) return first;
|
|
43
|
+
|
|
44
|
+
// Fast path: exactly two functions — the common case for ref/handler
|
|
45
|
+
// forwarding (props.onX + local onX). Avoids the loop.
|
|
46
|
+
if (onlyFunctions.length === 2) {
|
|
47
|
+
const a = onlyFunctions[0]!;
|
|
48
|
+
const b = onlyFunctions[1]!;
|
|
49
|
+
return function (this: unknown, ...innerArgs) {
|
|
50
|
+
const result = a.apply(this, innerArgs);
|
|
51
|
+
if (result === true) return result;
|
|
52
|
+
return b.apply(this, innerArgs);
|
|
53
|
+
};
|
|
33
54
|
}
|
|
34
55
|
|
|
35
|
-
|
|
56
|
+
const chained = onlyFunctions;
|
|
57
|
+
return function (this: unknown, ...innerArgs) {
|
|
36
58
|
let result;
|
|
37
|
-
for (
|
|
38
|
-
result =
|
|
39
|
-
if (result === true)
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
59
|
+
for (let i = 0; i < chained.length; i++) {
|
|
60
|
+
result = chained[i]!.apply(this, innerArgs);
|
|
61
|
+
if (result === true) return result;
|
|
42
62
|
}
|
|
43
63
|
return result;
|
|
44
64
|
};
|