@solidtv/solid 1.1.1 → 1.1.3
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 +1 -13
- package/dist/src/core/config.js +10 -2
- 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 +254 -67
- package/dist/src/core/dom-renderer/domRenderer.js.map +1 -1
- package/dist/src/core/elementNode.d.ts +20 -7
- package/dist/src/core/elementNode.js +54 -14
- package/dist/src/core/elementNode.js.map +1 -1
- package/dist/src/core/focusManager.js +5 -3
- 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 +6 -6
- package/dist/src/core/lightningInit.js.map +1 -1
- package/dist/src/core/utils.js +4 -4
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/primitives/Column.jsx +1 -1
- package/dist/src/primitives/Column.jsx.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.d.ts +4 -3
- package/dist/src/primitives/KeepAlive.jsx +60 -23
- 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/Row.jsx +1 -1
- package/dist/src/primitives/Row.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 +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/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 +21 -16
- 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 +2 -1
- package/dist/src/render.js.map +1 -1
- package/dist/src/solidOpts.d.ts +1 -1
- package/dist/src/solidOpts.js +4 -2
- 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 +6 -20
- package/src/core/dom-renderer/domRenderer.ts +307 -89
- package/src/core/dom-renderer/domRendererTypes.ts +9 -6
- package/src/core/elementNode.ts +80 -26
- package/src/core/focusManager.ts +16 -8
- package/src/core/intrinsicTypes.ts +19 -7
- package/src/core/lightningInit.ts +20 -18
- package/src/core/utils.ts +4 -4
- package/src/primitives/Column.tsx +0 -1
- package/src/primitives/FPSCounter.tsx +14 -10
- package/src/primitives/Image.tsx +18 -9
- package/src/primitives/KeepAlive.tsx +88 -44
- package/src/primitives/LazyImport.ts +8 -6
- package/src/primitives/Preserve.tsx +13 -8
- package/src/primitives/Row.tsx +0 -1
- package/src/primitives/Suspense.tsx +10 -9
- package/src/primitives/Virtual.tsx +1 -9
- 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/utils/chainFunctions.ts +31 -11
- package/src/primitives/utils/createBlurredImage.ts +58 -40
- package/src/primitives/utils/handleNavigation.ts +29 -18
- package/src/primitives/utils/withScrolling.ts +3 -5
- package/src/render.ts +4 -4
- package/src/solidOpts.ts +9 -7
- package/src/types.ts +0 -1
- package/src/utils.ts +12 -10
|
@@ -5,12 +5,15 @@ import { chainFunctions } from './utils/chainFunctions.js';
|
|
|
5
5
|
|
|
6
6
|
export interface KeepAliveElement {
|
|
7
7
|
id: string;
|
|
8
|
-
owner
|
|
9
|
-
|
|
8
|
+
// owner / children / dispose are populated lazily — the preload path
|
|
9
|
+
// creates a partial entry holding only `id` + `isAlive` until the route
|
|
10
|
+
// mounts, so callers must null-check before use.
|
|
11
|
+
owner?: s.Owner | null;
|
|
12
|
+
children?: s.JSX.Element;
|
|
10
13
|
routeSignal?: s.Signal<unknown>;
|
|
11
14
|
isAlive?: s.Accessor<boolean>;
|
|
12
15
|
setIsAlive?: (v: boolean) => void;
|
|
13
|
-
dispose
|
|
16
|
+
dispose?: () => void;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
const keepAliveElements = new Map<string, KeepAliveElement>();
|
|
@@ -40,7 +43,7 @@ const _removeKeepAlive = (
|
|
|
40
43
|
): void => {
|
|
41
44
|
const element = map.get(id);
|
|
42
45
|
if (element) {
|
|
43
|
-
(element.children as unknown as ElementNode)?.destroy();
|
|
46
|
+
(element.children as unknown as ElementNode | undefined)?.destroy();
|
|
44
47
|
element.dispose?.();
|
|
45
48
|
map.delete(id);
|
|
46
49
|
}
|
|
@@ -53,7 +56,7 @@ export const removeKeepAliveRoute = (id: string): void =>
|
|
|
53
56
|
|
|
54
57
|
const _clearKeepAlive = (map: Map<string, KeepAliveElement>): void => {
|
|
55
58
|
map.forEach((element) => {
|
|
56
|
-
(element.children as unknown as ElementNode)?.destroy();
|
|
59
|
+
(element.children as unknown as ElementNode | undefined)?.destroy();
|
|
57
60
|
element.dispose?.();
|
|
58
61
|
});
|
|
59
62
|
map.clear();
|
|
@@ -109,13 +112,13 @@ const createKeepAliveComponent = (
|
|
|
109
112
|
) => {
|
|
110
113
|
return (props: s.ParentProps<KeepAliveProps>) => {
|
|
111
114
|
let existing = map.get(props.id);
|
|
115
|
+
const existingChild = existing?.children as ElementNode | undefined;
|
|
112
116
|
|
|
113
117
|
if (
|
|
114
118
|
existing &&
|
|
115
|
-
(props.shouldDispose?.(props.id) ||
|
|
116
|
-
(existing.children as unknown as ElementNode)?.destroyed)
|
|
119
|
+
(props.shouldDispose?.(props.id) || existingChild?.destroyed)
|
|
117
120
|
) {
|
|
118
|
-
|
|
121
|
+
existingChild?.destroy();
|
|
119
122
|
existing.dispose?.();
|
|
120
123
|
map.delete(props.id);
|
|
121
124
|
existing = undefined;
|
|
@@ -138,8 +141,8 @@ const createKeepAliveComponent = (
|
|
|
138
141
|
});
|
|
139
142
|
return children;
|
|
140
143
|
});
|
|
141
|
-
} else if (
|
|
142
|
-
existing.children = s.runWithOwner(existing.owner, () =>
|
|
144
|
+
} else if (!existing.children) {
|
|
145
|
+
existing.children = s.runWithOwner(existing.owner ?? null, () =>
|
|
143
146
|
wrapChildren(props, existing.setIsAlive),
|
|
144
147
|
);
|
|
145
148
|
}
|
|
@@ -156,6 +159,23 @@ const KeepAliveRouteInternal = createKeepAliveComponent(
|
|
|
156
159
|
storeKeepAliveRoute,
|
|
157
160
|
);
|
|
158
161
|
|
|
162
|
+
// Cache the resolved <Route> JSX per key. Solid Router uses the routeDef
|
|
163
|
+
// object itself as the route key (see @solidjs/router index.js:455), so if
|
|
164
|
+
// KeepAliveRoute ever gets re-evaluated, a new routeDef would drift the key
|
|
165
|
+
// and force routeStates to dispose + recreate sibling contexts (which would
|
|
166
|
+
// re-invoke their components). Returning the same JSX reference keeps the
|
|
167
|
+
// route key stable across re-evaluations.
|
|
168
|
+
//
|
|
169
|
+
// Note: this captures `props` at first invocation. If you rely on dynamic
|
|
170
|
+
// changes to KeepAliveRoute props (e.g., a reactive `transition` or `preload`
|
|
171
|
+
// reference), use a stable wrapper around them or clear this cache when
|
|
172
|
+
// they change.
|
|
173
|
+
const keepAliveRouteCache = new Map<string, s.JSX.Element>();
|
|
174
|
+
|
|
175
|
+
export const clearKeepAliveRouteCache = (): void => {
|
|
176
|
+
keepAliveRouteCache.clear();
|
|
177
|
+
};
|
|
178
|
+
|
|
159
179
|
export const KeepAliveRoute = <S extends string>(
|
|
160
180
|
props: RouteProps<S> & {
|
|
161
181
|
id?: string;
|
|
@@ -173,24 +193,26 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
173
193
|
},
|
|
174
194
|
) => {
|
|
175
195
|
const key = props.id || props.path;
|
|
196
|
+
|
|
197
|
+
const cached = keepAliveRouteCache.get(key);
|
|
198
|
+
if (cached) {
|
|
199
|
+
return cached;
|
|
200
|
+
}
|
|
201
|
+
|
|
176
202
|
let savedFocusedElement: ElementNode | undefined;
|
|
177
203
|
|
|
178
|
-
const getExisting = () => {
|
|
204
|
+
const getExisting = (): KeepAliveElement => {
|
|
179
205
|
let existing = keepAliveRouteElements.get(key);
|
|
180
206
|
if (!existing) {
|
|
181
207
|
const [isAlive, setIsAlive] = s.createSignal(true);
|
|
182
|
-
existing = {
|
|
183
|
-
|
|
184
|
-
isAlive,
|
|
185
|
-
setIsAlive,
|
|
186
|
-
} as any;
|
|
187
|
-
keepAliveRouteElements.set(key, existing!);
|
|
208
|
+
existing = { id: key, isAlive, setIsAlive };
|
|
209
|
+
keepAliveRouteElements.set(key, existing);
|
|
188
210
|
}
|
|
189
|
-
return existing
|
|
211
|
+
return existing;
|
|
190
212
|
};
|
|
191
213
|
|
|
192
214
|
const onRemove = chainFunctions(props.onRemove, (elm: ElementNode) => {
|
|
193
|
-
savedFocusedElement = activeElement()
|
|
215
|
+
savedFocusedElement = activeElement();
|
|
194
216
|
elm.alpha = 0;
|
|
195
217
|
});
|
|
196
218
|
|
|
@@ -216,13 +238,15 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
216
238
|
const preload = props.preload
|
|
217
239
|
? (preloadProps: RoutePreloadFuncArgs) => {
|
|
218
240
|
let existing = getExisting();
|
|
241
|
+
const existingChild = existing.children as unknown as
|
|
242
|
+
| ElementNode
|
|
243
|
+
| undefined;
|
|
219
244
|
|
|
220
245
|
if (
|
|
221
|
-
|
|
222
|
-
(props.shouldDispose?.(key) ||
|
|
223
|
-
(existing.children as unknown as ElementNode)?.destroyed)
|
|
246
|
+
existingChild &&
|
|
247
|
+
(props.shouldDispose?.(key) || existingChild.destroyed)
|
|
224
248
|
) {
|
|
225
|
-
|
|
249
|
+
existingChild.destroy();
|
|
226
250
|
existing.dispose?.();
|
|
227
251
|
keepAliveRouteElements.delete(key);
|
|
228
252
|
existing = getExisting();
|
|
@@ -232,11 +256,17 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
232
256
|
return s.createRoot((dispose) => {
|
|
233
257
|
existing.owner = s.getOwner();
|
|
234
258
|
existing.dispose = dispose;
|
|
235
|
-
return props.preload!({
|
|
259
|
+
return props.preload!({
|
|
260
|
+
...preloadProps,
|
|
261
|
+
isAlive: existing.isAlive!,
|
|
262
|
+
});
|
|
236
263
|
});
|
|
237
264
|
} else if (existing.children) {
|
|
238
|
-
(existing.children as unknown as ElementNode)
|
|
239
|
-
return props.preload!({
|
|
265
|
+
(existing.children as unknown as ElementNode).setFocus();
|
|
266
|
+
return props.preload!({
|
|
267
|
+
...preloadProps,
|
|
268
|
+
isAlive: existing.isAlive!,
|
|
269
|
+
});
|
|
240
270
|
} else {
|
|
241
271
|
return props.preload!({
|
|
242
272
|
...preloadProps,
|
|
@@ -246,23 +276,37 @@ export const KeepAliveRoute = <S extends string>(
|
|
|
246
276
|
}
|
|
247
277
|
: undefined;
|
|
248
278
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
279
|
+
const componentWrapper = (childProps: RouteProps<S>) => {
|
|
280
|
+
const existing = getExisting();
|
|
281
|
+
// Do NOT spread `childProps`: it has a `children` getter (the router's
|
|
282
|
+
// outlet) that would be invoked eagerly, creating a <Show> subscribed to
|
|
283
|
+
// the next routeStates index. That stale Show would then fire when the
|
|
284
|
+
// user navigates to a sibling route whose matches populate that index,
|
|
285
|
+
// causing the sibling's component to be created from the preserved
|
|
286
|
+
// KeepAlive subtree. Inherit via prototype so the getter is preserved.
|
|
287
|
+
const innerProps = Object.create(childProps, {
|
|
288
|
+
isAlive: {
|
|
289
|
+
value: existing.isAlive!,
|
|
290
|
+
enumerable: true,
|
|
291
|
+
configurable: true,
|
|
292
|
+
},
|
|
293
|
+
}) as RouteProps<S> & { isAlive: s.Accessor<boolean> };
|
|
294
|
+
return (
|
|
295
|
+
<KeepAliveRouteInternal
|
|
296
|
+
id={key}
|
|
297
|
+
onRemove={onRemove}
|
|
298
|
+
onRender={onRender}
|
|
299
|
+
transition={props.transition}
|
|
300
|
+
>
|
|
301
|
+
{props.component(innerProps)}
|
|
302
|
+
</KeepAliveRouteInternal>
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const routeElement = (
|
|
307
|
+
<Route {...props} preload={preload} component={componentWrapper} />
|
|
267
308
|
);
|
|
309
|
+
|
|
310
|
+
keepAliveRouteCache.set(key, routeElement);
|
|
311
|
+
return routeElement;
|
|
268
312
|
};
|
|
@@ -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;
|
package/src/primitives/Row.tsx
CHANGED
|
@@ -33,7 +33,6 @@ export const Row: Component<RowProps> = (props) => {
|
|
|
33
33
|
<view
|
|
34
34
|
transitionLeft={defaultTransitionBack}
|
|
35
35
|
transitionRight={defaultTransitionForward}
|
|
36
|
-
transition={/* @once */ {}}
|
|
37
36
|
{...props}
|
|
38
37
|
selected={props.selected || 0}
|
|
39
38
|
onLeft={/* @once */ chainFunctions(props.onLeft, onLeft)}
|
|
@@ -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;
|
|
@@ -540,7 +533,6 @@ function createVirtual<T>(
|
|
|
540
533
|
|
|
541
534
|
return (
|
|
542
535
|
<view
|
|
543
|
-
transition={/* @once */ {}}
|
|
544
536
|
transitionLeft={isRow ? defaultTransitionBack : undefined}
|
|
545
537
|
transitionRight={isRow ? defaultTransitionForward : undefined}
|
|
546
538
|
transitionUp={!isRow ? defaultTransitionUp : undefined}
|
|
@@ -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
|
}
|
|
@@ -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
|
};
|