@solidjs/web 2.0.0-beta.3 → 2.0.0-beta.30

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 (73) hide show
  1. package/README.md +27 -4
  2. package/dist/dev.cjs +1211 -205
  3. package/dist/dev.js +1175 -199
  4. package/dist/server.cjs +1342 -234
  5. package/dist/server.js +1304 -231
  6. package/dist/web.cjs +1195 -196
  7. package/dist/web.js +1159 -190
  8. package/frames/dist/client.cjs +1746 -0
  9. package/frames/dist/client.dev.cjs +1759 -0
  10. package/frames/dist/client.dev.js +1747 -0
  11. package/frames/dist/client.js +1734 -0
  12. package/frames/dist/server.cjs +2426 -0
  13. package/frames/dist/server.js +2414 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +287 -38
  16. package/serialization/dist/serialization.cjs +169 -0
  17. package/serialization/dist/serialization.js +159 -0
  18. package/serialization/package.json +20 -0
  19. package/serialization/types/index.d.ts +157 -0
  20. package/serialization/types-cjs/index.d.cts +157 -0
  21. package/serialization/types-cjs/package.json +3 -0
  22. package/server-functions/dist/client.cjs +613 -0
  23. package/server-functions/dist/client.js +585 -0
  24. package/server-functions/dist/server.cjs +904 -0
  25. package/server-functions/dist/server.js +875 -0
  26. package/server-functions/package.json +30 -0
  27. package/storage/package.json +8 -3
  28. package/storage/types/index.d.ts +26 -0
  29. package/storage/types-cjs/index.d.cts +28 -0
  30. package/storage/types-cjs/package.json +3 -0
  31. package/types/client.d.ts +125 -21
  32. package/types/core.d.ts +4 -3
  33. package/types/frames/client.d.ts +20 -0
  34. package/types/frames/frame-client.d.ts +270 -0
  35. package/types/frames/frame-sink.d.ts +168 -0
  36. package/types/frames/frame-transport.d.ts +196 -0
  37. package/types/frames/serializer.d.ts +157 -0
  38. package/types/frames/server.d.ts +30 -0
  39. package/types/index.d.ts +211 -26
  40. package/types/jsx-properties.d.ts +93 -0
  41. package/types/jsx.d.ts +4150 -1
  42. package/types/response.d.ts +129 -0
  43. package/types/serializer.d.ts +157 -0
  44. package/types/server-functions/client.d.ts +200 -0
  45. package/types/server-functions/flash.d.ts +38 -0
  46. package/types/server-functions/server.d.ts +490 -0
  47. package/types/server-functions/shared.d.ts +445 -0
  48. package/types/server-mock.d.ts +93 -0
  49. package/types/server.d.ts +221 -28
  50. package/types-cjs/client.d.cts +192 -0
  51. package/types-cjs/core.d.cts +4 -0
  52. package/types-cjs/frames/client.d.cts +20 -0
  53. package/types-cjs/frames/frame-client.d.cts +270 -0
  54. package/types-cjs/frames/frame-sink.d.cts +168 -0
  55. package/types-cjs/frames/frame-transport.d.cts +196 -0
  56. package/types-cjs/frames/serializer.d.cts +157 -0
  57. package/types-cjs/frames/server.d.cts +30 -0
  58. package/types-cjs/index.d.cts +231 -0
  59. package/types-cjs/jsx-properties.d.cts +93 -0
  60. package/types-cjs/jsx.d.cts +4150 -0
  61. package/types-cjs/package.json +3 -0
  62. package/types-cjs/response.d.cts +129 -0
  63. package/types-cjs/serializer.d.cts +157 -0
  64. package/types-cjs/server-functions/client.d.cts +200 -0
  65. package/types-cjs/server-functions/flash.d.cts +38 -0
  66. package/types-cjs/server-functions/server.d.cts +490 -0
  67. package/types-cjs/server-functions/shared.d.cts +445 -0
  68. package/types-cjs/server-mock.d.cts +165 -0
  69. package/types-cjs/server.d.cts +349 -0
  70. package/storage/types/src/client.d.ts +0 -1
  71. package/storage/types/src/index.d.ts +0 -46
  72. package/storage/types/src/server-mock.d.ts +0 -72
  73. package/storage/types/storage/src/index.d.ts +0 -2
package/types/index.d.ts CHANGED
@@ -1,46 +1,231 @@
1
- import { hydrate as hydrateCore, render as renderCore } from "./client.js";
2
- import { JSX, ComponentProps, ValidComponent } from "solid-js";
1
+ import { hydrate as hydrateCore } from "./client.js";
2
+ import { Component } from "solid-js";
3
+ import type { JSX } from "./jsx.js";
3
4
  export * from "./client.js";
4
- export declare function render(...args: Parameters<typeof renderCore>): ReturnType<typeof renderCore>;
5
- export { For, Show, Switch, Match, Errored, Loading, NoHydration, Hydration, merge as mergeProps } from "solid-js";
6
5
  export * from "./server-mock.js";
6
+ export * from "./response.js";
7
+ export type { JSX } from "./jsx.js";
8
+ export { For, Show, Switch, Match, Errored, Loading, Repeat, Reveal, NoHydration, Hydration } from "solid-js";
9
+ import { merge } from "solid-js";
10
+ /**
11
+ * Compiler-emitted prop-spread helper. The JSX transform (in
12
+ * `dom-expressions`) emits `mergeProps(...)` calls when compiling prop
13
+ * spreads on components — it is *not* a user-facing API. Application code
14
+ * should import `merge` from `solid-js` directly.
15
+ *
16
+ * @internal
17
+ */
18
+ export declare const mergeProps: typeof merge;
19
+ /**
20
+ * Build-time constant indicating whether code is running on the server. This
21
+ * client entry sets it to `false`; the matching server entry (`@solidjs/web`
22
+ * resolved through the `solid` server export condition) sets it to `true`.
23
+ *
24
+ * Bundlers can dead-code-eliminate branches gated on `isServer`, so guarding
25
+ * browser-only code with `if (!isServer) {…}` keeps it out of the SSR bundle
26
+ * entirely.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { isServer } from "@solidjs/web";
31
+ *
32
+ * if (!isServer) {
33
+ * // Browser-only: tree-shaken out of the SSR bundle.
34
+ * window.addEventListener("resize", onResize);
35
+ * }
36
+ * ```
37
+ */
7
38
  export declare const isServer: boolean;
8
- export declare const isDev: boolean;
9
- export declare const hydrate: typeof hydrateCore;
10
39
  /**
11
- * Renders components somewhere else in the DOM
40
+ * Build-time constant indicating whether code is running in a dev build.
41
+ * Replaced statically (`_SOLID_DEV_`) by the bundler integration, so guards
42
+ * like `if (isDev) {…}` are stripped from production builds.
12
43
  *
13
- * Useful for inserting modals and tooltips outside of an cropping layout. If no mount point is given, the portal is inserted in document.body; it is wrapped in a `<div>` unless the target is document.head or `isSVG` is true. setting `useShadow` to true places the element in a shadow root to isolate styles.
44
+ * Use this to gate dev-only diagnostics, warnings, or expensive invariants
45
+ * that should never ship to production.
14
46
  *
15
- * @description https://docs.solidjs.com/reference/components/portal
47
+ * @example
48
+ * ```ts
49
+ * import { isDev } from "@solidjs/web";
50
+ *
51
+ * if (isDev) {
52
+ * console.warn("debug-only path");
53
+ * }
54
+ * ```
16
55
  */
17
- export declare function Portal<T extends boolean = false, S extends boolean = false>(props: {
18
- mount?: Element;
19
- children: JSX.Element;
20
- }): Text;
56
+ export declare const isDev: boolean;
57
+ type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
58
+ export type IntrinsicElement = Extract<keyof JSX.IntrinsicElements, string>;
59
+ export type ValidComponent = IntrinsicElement | Component<any> | (string & {});
60
+ export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
21
61
  export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
22
62
  [K in keyof P]: P[K];
23
63
  } & {
24
- component: T | undefined;
64
+ component: T | null | undefined | false;
25
65
  };
26
66
  /**
27
- * Renders an arbitrary component or element with the given props
67
+ * Renders a component tree into a DOM element. Returns a dispose function
68
+ * that tears the tree down and cleans up reactive scopes when called.
69
+ *
70
+ * @example
71
+ * ```tsx
72
+ * import { render } from "@solidjs/web";
28
73
  *
29
- * This is a lower level version of the `Dynamic` component, useful for
30
- * performance optimizations in libraries. Do not use this unless you know
31
- * what you are doing.
32
- * ```typescript
33
- * const element = () => multiline() ? 'textarea' : 'input';
34
- * createDynamic(element, { value: value() });
74
+ * const dispose = render(() => <App />, document.getElementById("root")!);
75
+ *
76
+ * // Later, to unmount:
77
+ * dispose();
35
78
  * ```
36
- * @description https://docs.solidjs.com/reference/components/dynamic
79
+ *
80
+ * @remarks
81
+ * The top-level insert is queued via `insertOptions: { schedule: true }` so
82
+ * its initial DOM attach goes through the effect queue rather than executing
83
+ * inline. This lets the mount participate in transitions: if an uncaught
84
+ * async read surfaces during the initial render (no `Loading` ancestor
85
+ * absorbs it), the mount is held by the transition and attaches atomically
86
+ * once all pending settles. On the no-async happy path the tail `flush()`
87
+ * drains the queued callback so the attach is synchronous by the time
88
+ * `render()` returns. The dev enforcement window scopes
89
+ * `ASYNC_OUTSIDE_LOADING_BOUNDARY` to the initial mount only.
37
90
  */
38
- export declare function createDynamic<T extends ValidComponent>(component: () => T | undefined, props: ComponentProps<T>): JSX.Element;
91
+ export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
92
+ renderId?: string;
93
+ }): () => void;
39
94
  /**
40
- * Renders an arbitrary custom or native component and passes the other props
41
- * ```typescript
42
- * <Dynamic component={multiline() ? 'textarea' : 'input'} value={value()} />
95
+ * Resumes a server-rendered tree on the client, attaching event listeners
96
+ * and reactive bindings without reconstructing the DOM. Returns a `dispose`
97
+ * function that tears down reactive scopes (DOM nodes are left in place).
98
+ *
99
+ * Use this when the page HTML was produced by `renderToString`,
100
+ * `renderToStringAsync`, or `renderToStream`. For client-only apps, use
101
+ * `render` instead.
102
+ *
103
+ * Pass `options.renderId` to hydrate one of multiple roots emitted by a
104
+ * server render that used the same id.
105
+ *
106
+ * @example
107
+ * ```tsx
108
+ * import { hydrate } from "@solidjs/web";
109
+ *
110
+ * hydrate(() => <App />, document.getElementById("root")!);
43
111
  * ```
112
+ */
113
+ export declare const hydrate: typeof hydrateCore;
114
+ /**
115
+ * Renders its children into a different part of the DOM (modal roots,
116
+ * tooltips, layers that need to escape an `overflow: hidden` ancestor).
117
+ *
118
+ * If `mount` is omitted, the portal attaches to `document.body`. The portal
119
+ * still participates in the parent's reactive scope and disposes when the
120
+ * parent does.
121
+ *
122
+ * Portals are client-only islands: the server renders nothing for them, and
123
+ * under hydration the children render fresh once hydration settles. Async
124
+ * read inside a portal therefore starts on the client — data that should be
125
+ * fetched on the server belongs above the portal (hoist the read, not the
126
+ * render), and async UI inside one wants its own `<Loading>` boundary.
127
+ *
128
+ * @example
129
+ * ```tsx
130
+ * <Portal mount={document.getElementById("modal-root")!}>
131
+ * <Dialog />
132
+ * </Portal>
133
+ * ```
134
+ *
135
+ * @description https://docs.solidjs.com/reference/components/portal
136
+ */
137
+ export declare function Portal(props: {
138
+ mount?: Element;
139
+ children: JSX.Element;
140
+ }): JSX.Element;
141
+ export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
142
+ /**
143
+ * Renders an arbitrary custom or native component and forwards the other
144
+ * props. JSX form of `dynamic()` — same primitive, picked at the JSX site.
145
+ *
146
+ * @example
147
+ * ```tsx
148
+ * <Dynamic
149
+ * component={multiline() ? RichTextEditor : "input"}
150
+ * value={value()}
151
+ * onInput={onInput}
152
+ * />
153
+ * ```
154
+ *
44
155
  * @description https://docs.solidjs.com/reference/components/dynamic
45
156
  */
46
157
  export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
158
+ /**
159
+ * Wraps a dynamically imported component so it renders only in the browser.
160
+ * The server renders `props.fallback` (and nothing else); the client shows
161
+ * the fallback until the import resolves and the tree has mounted, then
162
+ * swaps the real component in.
163
+ *
164
+ * Unlike `lazy()`, this avoids Suspense entirely and never server-renders
165
+ * the wrapped component — only the fallback — so the component participates
166
+ * in no hydration asset manifest and its code is guaranteed to never run on
167
+ * the server (safe for browser-only libraries touching `window`, DOM
168
+ * measurement, etc.). The mount gate keeps hydration safe: during hydration
169
+ * the fallback is rendered exactly as the server did, and the swap happens
170
+ * only after settle, so there is no mismatch.
171
+ *
172
+ * By default the import starts as soon as `clientOnly` is called (module
173
+ * load); pass `{ lazy: true }` to defer the import to the component's first
174
+ * render.
175
+ *
176
+ * @example
177
+ * ```tsx
178
+ * const Chart = clientOnly(() => import("./Chart.jsx"));
179
+ * // <Chart fallback={<div>Loading chart…</div>} data={data()} />
180
+ * ```
181
+ */
182
+ export declare function clientOnly<T extends Component<any>>(fn: () => Promise<{
183
+ default: T;
184
+ }>, options?: {
185
+ lazy?: boolean;
186
+ }, _moduleUrl?: string): Component<ComponentProps<T> & {
187
+ fallback?: JSX.Element;
188
+ }>;
189
+ /**
190
+ * Declares the HTTP response status (and optional status text) for the
191
+ * lifetime of the current reactive scope during SSR — call it bare in a
192
+ * component or reactive-scope body where the status is decided (a 404
193
+ * route, an error fallback). Client build: a no-op — the response head was
194
+ * sent long ago.
195
+ *
196
+ * Naming note — this is a scope-tied *declaration*, not a mutation: "while
197
+ * this reactive scope is live, the response has this status." Solid
198
+ * reserves `set*` verbs for event-time mutation; like
199
+ * `createSignal`/`onCleanup` this is called in scope bodies and un-declares
200
+ * on scope disposal.
201
+ *
202
+ * Retraction semantics (server): the write snapshots the previous
203
+ * `event.response` status at write time and restores it when the owning
204
+ * scope is disposed — so a boundary that errored, declared a status, and
205
+ * then recovered retracts its write instead of stomping a status a
206
+ * surviving part of the tree legitimately set. Once the integration marks
207
+ * the response head `committed` (head derived/sent), writes and
208
+ * retractions are no-ops.
209
+ */
210
+ export declare function httpStatus(_code: number, _text?: string): void;
211
+ /**
212
+ * Declares an HTTP response header (or with `append`, appends to one) for
213
+ * the lifetime of the current reactive scope during SSR — call it bare in a
214
+ * component or reactive-scope body. Client build: a no-op — the response
215
+ * head was sent long ago.
216
+ *
217
+ * Naming note — this is a scope-tied *declaration*, not a mutation: "while
218
+ * this reactive scope is live, the response has this header." Solid
219
+ * reserves `set*` verbs for event-time mutation; like
220
+ * `createSignal`/`onCleanup` this is called in scope bodies and un-declares
221
+ * on scope disposal.
222
+ *
223
+ * Retraction semantics (server): the header's prior value is snapshotted at
224
+ * write time and restored when the owning scope is disposed (deleted if
225
+ * there was none) — a boundary that errors or recovers retracts its writes.
226
+ * Once the integration marks the response head `committed` (head
227
+ * derived/sent), writes and retractions are no-ops.
228
+ */
229
+ export declare function httpHeader(_name: string, _value: string, _options?: {
230
+ append?: boolean;
231
+ }): void;
@@ -0,0 +1,93 @@
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
+ | Date
35
+ | Element;
36
+
37
+ /**
38
+ * Ergonomics widening for emitted `prop:*` value types:
39
+ *
40
+ * - general `string` → `string | number` (HTML coerces numbers)
41
+ * - string literal unions (`'on' | 'off'`) stay exact, so users still get autocomplete /
42
+ * narrowing
43
+ * - other types pass through unchanged
44
+ */
45
+ type WidenString<V> = string extends V ? string | number : V;
46
+ export type WidenPropValue<V> = [V] extends [string] ? WidenString<V> : V;
47
+
48
+ /**
49
+ * Structurally identical → `Y`; distinct → `N`. Used by `IsReadonlyKey` to detect
50
+ * readonly keys by comparing `Pick<T, K>` with `Readonly<Pick<T, K>>`.
51
+ */
52
+ export type IfEquals<A, B, Y = unknown, N = never> =
53
+ (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? Y : N;
54
+
55
+ /**
56
+ * True when `K` is readonly on `T`. Singleton-constant properties (e.g.
57
+ * `tagName: "INPUT"`, `nodeType: 1`) are always `readonly` in `lib.dom.d.ts`, so this
58
+ * single check covers both readonly and singleton-literal cases.
59
+ */
60
+ export type IsReadonlyKey<T, K extends keyof T> = IfEquals<
61
+ Pick<T, K>,
62
+ Readonly<Pick<T, K>>,
63
+ true,
64
+ false
65
+ >;
66
+
67
+ /**
68
+ * Resolves to the `prop:K` string literal when `K` is a writable, element-specific
69
+ * property suitable for a `prop:*` attribute; otherwise resolves to `never` so the
70
+ * key is filtered out of the resulting mapped type.
71
+ *
72
+ * Filters out:
73
+ *
74
+ * - base-class keys (via `SkipPropsFrom`)
75
+ * - aria-* keys (already typed via `AriaAttributes`)
76
+ * - readonly keys
77
+ * - keys whose value types fall outside `PropValue`
78
+ * - the generic `string` index signature (e.g. `HTMLFormElement[name: string]: any`),
79
+ * which would otherwise shadow every key with an `any`-typed `prop:*`
80
+ */
81
+ export type PropKey<T, K extends keyof T> = K extends keyof SkipPropsFrom
82
+ ? never
83
+ : K extends string
84
+ ? string extends K
85
+ ? never
86
+ : K extends `aria${string}`
87
+ ? never
88
+ : T[K] extends PropValue
89
+ ? IsReadonlyKey<T, K> extends true
90
+ ? never
91
+ : `prop:${K}`
92
+ : never
93
+ : never;