@solidjs/web 2.0.0-experimental.9 → 2.0.0-rc.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 (85) hide show
  1. package/README.md +22 -4
  2. package/dist/dev.cjs +1588 -224
  3. package/dist/dev.js +1513 -200
  4. package/dist/server.cjs +2722 -254
  5. package/dist/server.js +2659 -245
  6. package/dist/web.cjs +1524 -218
  7. package/dist/web.js +1449 -194
  8. package/frames/dist/client.cjs +1916 -0
  9. package/frames/dist/client.dev.cjs +1933 -0
  10. package/frames/dist/client.dev.js +1921 -0
  11. package/frames/dist/client.js +1904 -0
  12. package/frames/dist/server.cjs +3756 -0
  13. package/frames/dist/server.js +3743 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +350 -37
  16. package/serialization/decode/package.json +20 -0
  17. package/serialization/dist/decode.cjs +122 -0
  18. package/serialization/dist/decode.js +116 -0
  19. package/serialization/dist/serialization.cjs +244 -0
  20. package/serialization/dist/serialization.js +227 -0
  21. package/serialization/package.json +20 -0
  22. package/serialization/types/index.d.ts +182 -0
  23. package/serialization/types/serializer-decode.d.ts +182 -0
  24. package/serialization/types-cjs/index.d.cts +182 -0
  25. package/serialization/types-cjs/package.json +3 -0
  26. package/serialization/types-cjs/serializer-decode.d.cts +182 -0
  27. package/server-functions/dist/client.cjs +793 -0
  28. package/server-functions/dist/client.js +763 -0
  29. package/server-functions/dist/rich-args.cjs +11 -0
  30. package/server-functions/dist/rich-args.js +9 -0
  31. package/server-functions/dist/server.cjs +1171 -0
  32. package/server-functions/dist/server.dev.cjs +1171 -0
  33. package/server-functions/dist/server.dev.js +1137 -0
  34. package/server-functions/dist/server.js +1137 -0
  35. package/server-functions/package.json +40 -0
  36. package/server-functions/rich-args/package.json +20 -0
  37. package/storage/package.json +8 -3
  38. package/storage/types/index.d.ts +26 -0
  39. package/storage/types-cjs/index.d.cts +28 -0
  40. package/storage/types-cjs/package.json +3 -0
  41. package/types/client.d.ts +290 -27
  42. package/types/cookies.d.ts +93 -0
  43. package/types/core.d.ts +6 -2
  44. package/types/frames/client.d.ts +36 -0
  45. package/types/frames/frame-client.d.ts +338 -0
  46. package/types/frames/frame-sink.d.ts +194 -0
  47. package/types/frames/frame-transport.d.ts +222 -0
  48. package/types/frames/serializer.d.ts +182 -0
  49. package/types/frames/server.d.ts +52 -0
  50. package/types/index.d.ts +223 -24
  51. package/types/jsx-properties.d.ts +93 -0
  52. package/types/jsx.d.ts +4159 -1
  53. package/types/response.d.ts +174 -0
  54. package/types/serializer-decode.d.ts +182 -0
  55. package/types/serializer.d.ts +182 -0
  56. package/types/server-functions/client.d.ts +231 -0
  57. package/types/server-functions/flash.d.ts +38 -0
  58. package/types/server-functions/rich-args.d.ts +10 -0
  59. package/types/server-functions/server.d.ts +616 -0
  60. package/types/server-functions/shared.d.ts +523 -0
  61. package/types/server-mock.d.ts +249 -12
  62. package/types/server.d.ts +424 -51
  63. package/types-cjs/client.d.cts +337 -0
  64. package/types-cjs/cookies.d.cts +93 -0
  65. package/types-cjs/core.d.cts +6 -0
  66. package/types-cjs/frames/client.d.cts +36 -0
  67. package/types-cjs/frames/frame-client.d.cts +338 -0
  68. package/types-cjs/frames/frame-sink.d.cts +194 -0
  69. package/types-cjs/frames/frame-transport.d.cts +222 -0
  70. package/types-cjs/frames/serializer.d.cts +182 -0
  71. package/types-cjs/frames/server.d.cts +52 -0
  72. package/types-cjs/index.d.cts +244 -0
  73. package/types-cjs/jsx-properties.d.cts +93 -0
  74. package/types-cjs/jsx.d.cts +4159 -0
  75. package/types-cjs/package.json +3 -0
  76. package/types-cjs/response.d.cts +174 -0
  77. package/types-cjs/serializer-decode.d.cts +182 -0
  78. package/types-cjs/serializer.d.cts +182 -0
  79. package/types-cjs/server-functions/client.d.cts +231 -0
  80. package/types-cjs/server-functions/flash.d.cts +38 -0
  81. package/types-cjs/server-functions/rich-args.d.cts +10 -0
  82. package/types-cjs/server-functions/server.d.cts +616 -0
  83. package/types-cjs/server-functions/shared.d.cts +523 -0
  84. package/types-cjs/server-mock.d.cts +277 -0
  85. package/types-cjs/server.d.cts +523 -0
@@ -0,0 +1,244 @@
1
+ import { hydrate as hydrateCore } from "./client.cjs";
2
+ import { Component } from "solid-js";
3
+ import type { JSX } from "./jsx.cjs";
4
+ export * from "./client.cjs";
5
+ export * from "./server-mock.cjs";
6
+ export * from "./response.cjs";
7
+ export type { JSX } from "./jsx.cjs";
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
+ */
38
+ export declare const isServer: boolean;
39
+ /**
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.
43
+ *
44
+ * Use this to gate dev-only diagnostics, warnings, or expensive invariants
45
+ * that should never ship to production.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { isDev } from "@solidjs/web";
50
+ *
51
+ * if (isDev) {
52
+ * console.warn("debug-only path");
53
+ * }
54
+ * ```
55
+ */
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>;
61
+ export type DynamicProps<T extends ValidComponent, P = ComponentProps<T>> = {
62
+ [K in keyof P]: P[K];
63
+ } & {
64
+ component: T | null | undefined | false;
65
+ };
66
+ /**
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";
73
+ *
74
+ * const dispose = render(() => <App />, document.getElementById("root")!);
75
+ *
76
+ * // Later, to unmount:
77
+ * dispose();
78
+ * ```
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.
90
+ */
91
+ export declare function render(code: () => JSX.Element, element: MountableElement, init?: unknown, options?: {
92
+ renderId?: string;
93
+ }): () => void;
94
+ /**
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` or
100
+ * `renderToStream`. For client-only apps, use `render` instead.
101
+ *
102
+ * Pass `options.renderId` to hydrate one of multiple roots emitted by a
103
+ * server render that used the same id.
104
+ *
105
+ * When the server renders a full document but the client hydrates only the
106
+ * app subtree, the server must give that subtree its own id namespace: wrap
107
+ * the document shell in `<NoHydration>` and re-enter with `<Hydration>`
108
+ * around the app. Otherwise the app's hydration ids are allocated under the
109
+ * document component's owner tree and this walk can never claim them.
110
+ *
111
+ * @example
112
+ * ```tsx
113
+ * import { hydrate } from "@solidjs/web";
114
+ *
115
+ * hydrate(() => <App />, document.getElementById("root")!);
116
+ * ```
117
+ */
118
+ export declare const hydrate: typeof hydrateCore;
119
+ /**
120
+ * Renders its children into a different part of the DOM (modal roots,
121
+ * tooltips, layers that need to escape an `overflow: hidden` ancestor).
122
+ *
123
+ * If `mount` is omitted, the portal attaches to `document.body`. The portal
124
+ * still participates in the parent's reactive scope and disposes when the
125
+ * parent does.
126
+ *
127
+ * Portals are client-only islands: the server renders nothing for them, and
128
+ * under hydration the children render fresh once hydration settles. Async
129
+ * read inside a portal therefore starts on the client — data that should be
130
+ * fetched on the server belongs above the portal (hoist the read, not the
131
+ * render), and async UI inside one wants its own `<Loading>` boundary.
132
+ *
133
+ * @example
134
+ * ```tsx
135
+ * <Portal mount={document.getElementById("modal-root")!}>
136
+ * <Dialog />
137
+ * </Portal>
138
+ * ```
139
+ *
140
+ * @description https://docs.solidjs.com/reference/components/portal
141
+ */
142
+ export declare function Portal(props: {
143
+ mount?: Element;
144
+ children: JSX.Element;
145
+ }): JSX.Element;
146
+ export declare function dynamic<T extends ValidComponent>(source: () => T | Promise<T> | null | undefined | false): Component<ComponentProps<T>>;
147
+ /**
148
+ * Renders an arbitrary custom or native component and forwards the other
149
+ * props. JSX form of `dynamic()` — same primitive, picked at the JSX site.
150
+ *
151
+ * @example
152
+ * ```tsx
153
+ * <Dynamic
154
+ * component={multiline() ? RichTextEditor : "input"}
155
+ * value={value()}
156
+ * onInput={onInput}
157
+ * />
158
+ * ```
159
+ *
160
+ * @description https://docs.solidjs.com/reference/components/dynamic
161
+ */
162
+ export declare function Dynamic<T extends ValidComponent>(props: DynamicProps<T>): JSX.Element;
163
+ /**
164
+ * Wraps a dynamically imported component so it renders only in the browser.
165
+ * The server renders `props.fallback` (and nothing else); the client shows
166
+ * the fallback until the import resolves and the tree has mounted, then
167
+ * swaps the real component in.
168
+ *
169
+ * Unlike `lazy()`, this avoids Suspense entirely and never server-renders
170
+ * the wrapped component — only the fallback — so the component participates
171
+ * in no hydration asset manifest and its code is guaranteed to never run on
172
+ * the server (safe for browser-only libraries touching `window`, DOM
173
+ * measurement, etc.). The mount gate keeps hydration safe: during hydration
174
+ * the fallback is rendered exactly as the server did, and the swap happens
175
+ * only after settle, so there is no mismatch.
176
+ *
177
+ * By default the import starts as soon as `clientOnly` is called (module
178
+ * load); pass `{ lazy: true }` to defer the import to the component's first
179
+ * render. Pass `{ export: "Name" }` to use a named export of the resolved
180
+ * module instead of its default (mirrors `lazy()`'s option).
181
+ *
182
+ * @example
183
+ * ```tsx
184
+ * const Chart = clientOnly(() => import("./Chart.jsx"));
185
+ * // <Chart fallback={<div>Loading chart…</div>} data={data()} />
186
+ * ```
187
+ */
188
+ export declare function clientOnly<M extends Record<string, any>, K extends keyof M & string>(fn: () => Promise<M>, options: {
189
+ lazy?: boolean;
190
+ export: K;
191
+ }, moduleUrl?: string): Component<ComponentProps<M[K]> & {
192
+ fallback?: JSX.Element;
193
+ }>;
194
+ export declare function clientOnly<T extends Component<any>>(fn: () => Promise<{
195
+ default: T;
196
+ }>, options?: {
197
+ lazy?: boolean;
198
+ export?: string;
199
+ }, moduleUrl?: string): Component<ComponentProps<T> & {
200
+ fallback?: JSX.Element;
201
+ }>;
202
+ /**
203
+ * Declares the HTTP response status (and optional status text) for the
204
+ * lifetime of the current reactive scope during SSR — call it bare in a
205
+ * component or reactive-scope body where the status is decided (a 404
206
+ * route, an error fallback). Client build: a no-op — the response head was
207
+ * sent long ago.
208
+ *
209
+ * Naming note — this is a scope-tied *declaration*, not a mutation: "while
210
+ * this reactive scope is live, the response has this status." Solid
211
+ * reserves `set*` verbs for event-time mutation; like
212
+ * `createSignal`/`onCleanup` this is called in scope bodies and un-declares
213
+ * on scope disposal.
214
+ *
215
+ * Retraction semantics (server): the write snapshots the previous
216
+ * `event.response` status at write time and restores it when the owning
217
+ * scope is disposed — so a boundary that errored, declared a status, and
218
+ * then recovered retracts its write instead of stomping a status a
219
+ * surviving part of the tree legitimately set. Once the integration marks
220
+ * the response head `committed` (head derived/sent), writes and
221
+ * retractions are no-ops.
222
+ */
223
+ export declare function httpStatus(_code: number, _text?: string): void;
224
+ /**
225
+ * Declares an HTTP response header (or with `append`, appends to one) for
226
+ * the lifetime of the current reactive scope during SSR — call it bare in a
227
+ * component or reactive-scope body. Client build: a no-op — the response
228
+ * head was sent long ago.
229
+ *
230
+ * Naming note — this is a scope-tied *declaration*, not a mutation: "while
231
+ * this reactive scope is live, the response has this header." Solid
232
+ * reserves `set*` verbs for event-time mutation; like
233
+ * `createSignal`/`onCleanup` this is called in scope bodies and un-declares
234
+ * on scope disposal.
235
+ *
236
+ * Retraction semantics (server): the header's prior value is snapshotted at
237
+ * write time and restored when the owning scope is disposed (deleted if
238
+ * there was none) — a boundary that errors or recovers retracts its writes.
239
+ * Once the integration marks the response head `committed` (head
240
+ * derived/sent), writes and retractions are no-ops.
241
+ */
242
+ export declare function httpHeader(_name: string, _value: string, _options?: {
243
+ append?: boolean;
244
+ }): 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;