solid-js 2.0.0-beta.6 → 2.0.0-beta.8
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/dev.cjs +66 -104
- package/dist/dev.js +66 -104
- package/dist/server.cjs +331 -132
- package/dist/server.js +331 -132
- package/dist/solid.cjs +66 -104
- package/dist/solid.js +66 -104
- package/package.json +78 -30
- package/types/client/flow.d.ts +34 -13
- package/types/client/hydration.d.ts +35 -9
- package/types/jsx-properties.d.ts +92 -0
- package/types/jsx.d.ts +390 -314
- package/types/server/flow.d.ts +40 -7
- package/types/server/hydration.d.ts +18 -1
- package/types/server/signals.d.ts +33 -15
- package/types-cjs/client/component.d.cts +75 -0
- package/types-cjs/client/core.d.cts +58 -0
- package/types-cjs/client/flow.d.cts +163 -0
- package/types-cjs/client/hydration.d.cts +121 -0
- package/types-cjs/index.d.cts +17 -0
- package/types-cjs/jsx-properties.d.cts +92 -0
- package/types-cjs/jsx.d.cts +4294 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server/component.d.cts +67 -0
- package/types-cjs/server/core.d.cts +44 -0
- package/types-cjs/server/flow.d.cts +115 -0
- package/types-cjs/server/hydration.d.cts +63 -0
- package/types-cjs/server/index.d.cts +12 -0
- package/types-cjs/server/shared.d.cts +50 -0
- package/types-cjs/server/signals.d.cts +87 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type-level helpers used to derive `prop:*` attribute typings from
|
|
3
|
+
* DOM element interfaces (e.g. `HTMLInputElement`, `HTMLButtonElement`).
|
|
4
|
+
*
|
|
5
|
+
* The wrapping of each value (`FunctionMaybe<T>` in `jsx-h.d.ts` vs. the
|
|
6
|
+
* raw value in `jsx.d.ts`) is applied by each consumer when composing its
|
|
7
|
+
* own `Properties<T>` mapped type. That way this file stays identical in
|
|
8
|
+
* both reactive and non-reactive contexts and only needs to exist once.
|
|
9
|
+
*
|
|
10
|
+
* originally from
|
|
11
|
+
* @url https://github.com/potahtml/pota
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** Base-class properties shared by all elements — skipped from `prop:*`. */
|
|
15
|
+
export type SkipPropsFrom = HTMLUnknownElement & HTMLElement & Element & Node;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Value types allowed on a `prop:*`. Primitives plus the writable
|
|
19
|
+
* non-primitive DOM-object props worth exposing:
|
|
20
|
+
*
|
|
21
|
+
* - `HTMLMediaElement.srcObject`
|
|
22
|
+
* - `HTMLButtonElement.popoverTargetElement` / `commandForElement` (and the same via
|
|
23
|
+
* `PopoverTargetAttributes` mixin on `HTMLInputElement`)
|
|
24
|
+
*/
|
|
25
|
+
export type PropValue =
|
|
26
|
+
| string
|
|
27
|
+
| number
|
|
28
|
+
| boolean
|
|
29
|
+
| null
|
|
30
|
+
| MediaStream
|
|
31
|
+
| MediaSource
|
|
32
|
+
| Blob
|
|
33
|
+
| File
|
|
34
|
+
| Element;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Ergonomics widening for emitted `prop:*` value types:
|
|
38
|
+
*
|
|
39
|
+
* - general `string` → `string | number` (HTML coerces numbers)
|
|
40
|
+
* - string literal unions (`'on' | 'off'`) stay exact, so users still get autocomplete /
|
|
41
|
+
* narrowing
|
|
42
|
+
* - other types pass through unchanged
|
|
43
|
+
*/
|
|
44
|
+
type WidenString<V> = string extends V ? string | number : V;
|
|
45
|
+
export type WidenPropValue<V> = [V] extends [string] ? WidenString<V> : V;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Structurally identical → `Y`; distinct → `N`. Used by `IsReadonlyKey` to detect
|
|
49
|
+
* readonly keys by comparing `Pick<T, K>` with `Readonly<Pick<T, K>>`.
|
|
50
|
+
*/
|
|
51
|
+
export type IfEquals<A, B, Y = unknown, N = never> =
|
|
52
|
+
(<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? Y : N;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* True when `K` is readonly on `T`. Singleton-constant properties (e.g.
|
|
56
|
+
* `tagName: "INPUT"`, `nodeType: 1`) are always `readonly` in `lib.dom.d.ts`, so this
|
|
57
|
+
* single check covers both readonly and singleton-literal cases.
|
|
58
|
+
*/
|
|
59
|
+
export type IsReadonlyKey<T, K extends keyof T> = IfEquals<
|
|
60
|
+
Pick<T, K>,
|
|
61
|
+
Readonly<Pick<T, K>>,
|
|
62
|
+
true,
|
|
63
|
+
false
|
|
64
|
+
>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Resolves to the `prop:K` string literal when `K` is a writable, element-specific
|
|
68
|
+
* property suitable for a `prop:*` attribute; otherwise resolves to `never` so the
|
|
69
|
+
* key is filtered out of the resulting mapped type.
|
|
70
|
+
*
|
|
71
|
+
* Filters out:
|
|
72
|
+
*
|
|
73
|
+
* - base-class keys (via `SkipPropsFrom`)
|
|
74
|
+
* - aria-* keys (already typed via `AriaAttributes`)
|
|
75
|
+
* - readonly keys
|
|
76
|
+
* - keys whose value types fall outside `PropValue`
|
|
77
|
+
* - the generic `string` index signature (e.g. `HTMLFormElement[name: string]: any`),
|
|
78
|
+
* which would otherwise shadow every key with an `any`-typed `prop:*`
|
|
79
|
+
*/
|
|
80
|
+
export type PropKey<T, K extends keyof T> = K extends keyof SkipPropsFrom
|
|
81
|
+
? never
|
|
82
|
+
: K extends string
|
|
83
|
+
? string extends K
|
|
84
|
+
? never
|
|
85
|
+
: K extends `aria${string}`
|
|
86
|
+
? never
|
|
87
|
+
: T[K] extends PropValue
|
|
88
|
+
? IsReadonlyKey<T, K> extends true
|
|
89
|
+
? never
|
|
90
|
+
: `prop:${K}`
|
|
91
|
+
: never
|
|
92
|
+
: never;
|