@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.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.
Files changed (78) hide show
  1. package/dist/dev.cjs +86 -61
  2. package/dist/dev.js +81 -60
  3. package/dist/server.cjs +34 -17
  4. package/dist/server.js +35 -19
  5. package/dist/web.cjs +83 -59
  6. package/dist/web.js +78 -58
  7. package/frames/dist/client.cjs +8 -8
  8. package/frames/dist/client.dev.cjs +8 -8
  9. package/frames/dist/client.dev.js +8 -8
  10. package/frames/dist/client.js +8 -8
  11. package/frames/dist/server.cjs +28 -18
  12. package/frames/dist/server.js +29 -19
  13. package/package.json +20 -22
  14. package/serialization/dist/decode.cjs +3 -3
  15. package/serialization/dist/decode.js +3 -3
  16. package/serialization/dist/serialization.cjs +7 -11
  17. package/serialization/dist/serialization.js +7 -6
  18. package/serialization/types/index.d.ts +69 -157
  19. package/serialization/types/serializer-decode.d.ts +89 -112
  20. package/serialization/types/serializer.d.ts +94 -0
  21. package/serialization/types-cjs/index.d.cts +69 -157
  22. package/serialization/types-cjs/serializer-decode.d.cts +89 -112
  23. package/serialization/types-cjs/serializer.d.cts +94 -0
  24. package/types/client.d.ts +150 -290
  25. package/types/constants.d.ts +18 -0
  26. package/types/cookies.d.ts +31 -75
  27. package/types/frames/frame-client.d.ts +287 -277
  28. package/types/frames/frame-container-plugin.d.ts +71 -0
  29. package/types/frames/frame-sink.d.ts +58 -160
  30. package/types/frames/frame-transport.d.ts +161 -194
  31. package/types/frames/serializer-decode.d.ts +159 -0
  32. package/types/frames/serializer.d.ts +69 -157
  33. package/types/head.d.ts +16 -0
  34. package/types/index.d.ts +0 -65
  35. package/types/index.server.d.ts +125 -0
  36. package/types/jsx.d.ts +5 -13
  37. package/types/reconcile.d.ts +1 -0
  38. package/types/render.d.ts +4 -0
  39. package/types/response.d.ts +41 -153
  40. package/types/serializer-decode.d.ts +89 -112
  41. package/types/serializer.d.ts +69 -157
  42. package/types/server-functions/client.d.ts +93 -222
  43. package/types/server-functions/flash.d.ts +10 -30
  44. package/types/server-functions/registry.d.ts +63 -0
  45. package/types/server-functions/rich-args.d.ts +1 -10
  46. package/types/server-functions/server.d.ts +292 -574
  47. package/types/server-functions/shared.d.ts +112 -458
  48. package/types/server-mock.d.ts +2 -2
  49. package/types/server.d.ts +242 -434
  50. package/types-cjs/client.d.cts +150 -290
  51. package/types-cjs/constants.d.cts +18 -0
  52. package/types-cjs/cookies.d.cts +31 -75
  53. package/types-cjs/frames/frame-client.d.cts +287 -277
  54. package/types-cjs/frames/frame-container-plugin.d.cts +71 -0
  55. package/types-cjs/frames/frame-sink.d.cts +58 -160
  56. package/types-cjs/frames/frame-transport.d.cts +161 -194
  57. package/types-cjs/frames/serializer-decode.d.cts +159 -0
  58. package/types-cjs/frames/serializer.d.cts +69 -157
  59. package/types-cjs/head.d.cts +16 -0
  60. package/types-cjs/index.d.cts +0 -65
  61. package/types-cjs/index.server.d.cts +125 -0
  62. package/types-cjs/jsx.d.cts +5 -13
  63. package/types-cjs/reconcile.d.cts +1 -0
  64. package/types-cjs/render.d.cts +4 -0
  65. package/types-cjs/response.d.cts +41 -153
  66. package/types-cjs/serializer-decode.d.cts +89 -112
  67. package/types-cjs/serializer.d.cts +69 -157
  68. package/types-cjs/server-functions/client.d.cts +93 -222
  69. package/types-cjs/server-functions/flash.d.cts +10 -30
  70. package/types-cjs/server-functions/registry.d.cts +63 -0
  71. package/types-cjs/server-functions/rich-args.d.cts +1 -10
  72. package/types-cjs/server-functions/server.d.cts +292 -574
  73. package/types-cjs/server-functions/shared.d.cts +112 -458
  74. package/types-cjs/server-mock.d.cts +2 -2
  75. package/types-cjs/server.d.cts +242 -434
  76. package/LICENSE +0 -21
  77. package/types/core.d.ts +0 -9
  78. package/types-cjs/core.d.cts +0 -9
@@ -1,23 +1,3 @@
1
- // The DECODE half of the serialization surface (published as
2
- // `@solidjs/web/serialization/decode`): what reading a serialized payload
3
- // needs — `fromCrossJSON`-backed deserializers and the shared plugin set —
4
- // with none of the encode machinery. Lazy client consumers (the frames
5
- // data tables, `deserializeStream`) load this module so the encode half
6
- // never ships to a browser that only reads. The full serializer.d.ts
7
- // re-exports everything here; see its banner for the stability contract
8
- // (integration-facing, exempt from the 2.0 stability guarantee).
9
- // ---- Plugin types ----
10
- //
11
- // Declared here by hand (seroval's published d.ts use extensionless
12
- // ESM-relative imports that `moduleResolution: "nodenext"` cannot follow —
13
- // a bare type re-export would silently degrade the surface to `any` under
14
- // skipLibCheck, and an import would make every entry whose types reach
15
- // this module — the MAIN client entry included, via the server-function
16
- // seam's `JSONCodecOptions` — unimportable from a strict Node16 CJS
17
- // consumer). The declarations mirror seroval ~1.5 exactly; the `~` pin is
18
- // what makes mirroring safe. Plugin AUTHORING (`createPlugin`,
19
- // `OpaqueReference`) lives on the full serialization entry.
20
-
21
1
  /**
22
2
  * Seroval's node shape — the intermediate representation `serializeJSON`
23
3
  * emits and `createJSONDeserializer` consumes. Safe to `JSON.stringify`.
@@ -29,59 +9,53 @@
29
9
  * Integration-facing; may change (see the entry banner).
30
10
  */
31
11
  export interface SerovalNode {
32
- /** Node type tag (seroval-internal enum). */
33
- t: number;
34
- /** Reference id, when the node participates in cross-referencing. */
35
- i?: number | undefined;
36
- [key: string]: unknown;
12
+ /** Node type tag (seroval-internal enum). */
13
+ t: number;
14
+ /** Reference id, when the node participates in cross-referencing. */
15
+ i?: number | undefined;
16
+ [key: string]: unknown;
37
17
  }
38
-
39
18
  /** Per-plugin bookkeeping seroval hands each plugin callback. */
40
19
  export interface PluginData {
41
- id: number;
20
+ id: number;
42
21
  }
43
-
44
22
  /**
45
23
  * The shape of a plugin's parsed payload: a map of `SerovalNode`s produced
46
24
  * by the parse contexts, consumed by `serialize`/`deserialize`.
47
25
  */
48
- export type PluginInfo = { [key: string]: SerovalNode };
49
-
26
+ export type PluginInfo = {
27
+ [key: string]: SerovalNode;
28
+ };
50
29
  /** Parse context for `parse.sync`: turns child values into nodes. */
51
30
  export interface SyncParsePluginContext {
52
- parse<T>(current: T): SerovalNode;
31
+ parse<T>(current: T): SerovalNode;
53
32
  }
54
-
55
33
  /** Parse context for `parse.async`: like sync, but child parses await. */
56
34
  export interface AsyncParsePluginContext {
57
- parse<T>(current: T): Promise<SerovalNode>;
35
+ parse<T>(current: T): Promise<SerovalNode>;
58
36
  }
59
-
60
37
  /**
61
38
  * Parse context for `parse.stream`: sync parsing plus the streaming
62
39
  * lifecycle (pending-state tracking, late node emission, cleanup).
63
40
  */
64
41
  export interface StreamParsePluginContext {
65
- parse<T>(current: T): SerovalNode;
66
- parseWithError<T>(current: T): SerovalNode | undefined;
67
- isAlive(): boolean;
68
- pushPendingState(): void;
69
- popPendingState(): void;
70
- onParse(node: SerovalNode): void;
71
- onError(error: unknown): void;
72
- addCleanup(callback: () => void): void;
42
+ parse<T>(current: T): SerovalNode;
43
+ parseWithError<T>(current: T): SerovalNode | undefined;
44
+ isAlive(): boolean;
45
+ pushPendingState(): void;
46
+ popPendingState(): void;
47
+ onParse(node: SerovalNode): void;
48
+ onError(error: unknown): void;
49
+ addCleanup(callback: () => void): void;
73
50
  }
74
-
75
51
  /** Serialize context: renders child nodes to JS source. */
76
52
  export interface SerializePluginContext {
77
- serialize(node: SerovalNode): string;
53
+ serialize(node: SerovalNode): string;
78
54
  }
79
-
80
55
  /** Deserialize context: revives child nodes to runtime values. */
81
56
  export interface DeserializePluginContext {
82
- deserialize<T>(node: SerovalNode): T;
57
+ deserialize<T>(node: SerovalNode): T;
83
58
  }
84
-
85
59
  /**
86
60
  * A Seroval plugin usable with the web serializers — teaches the codec how
87
61
  * to encode/decode a custom value type (`Value` is the value it matches,
@@ -92,44 +66,23 @@ export interface DeserializePluginContext {
92
66
  * Integration-facing; may change (see the entry banner).
93
67
  */
94
68
  export interface SerializerPlugin<Value = any, Info extends PluginInfo = any> {
95
- /** A unique string identifying the plugin — namespace it (`"app/Thing"`). */
96
- tag: string;
97
- /** Dependency plugins, resolved ahead of this one. */
98
- extends?: SerializerPlugin[];
99
- /** Whether `value` is this plugin's to encode. */
100
- test(value: unknown): boolean;
101
- /** Parsing modes — provide the ones the transports you target use. */
102
- parse: {
103
- sync?: (value: Value, ctx: SyncParsePluginContext, data: PluginData) => Info;
104
- async?: (value: Value, ctx: AsyncParsePluginContext, data: PluginData) => Promise<Info>;
105
- stream?: (value: Value, ctx: StreamParsePluginContext, data: PluginData) => Info;
106
- };
107
- /** Renders the parsed payload as JS source (script-injection form). */
108
- serialize(node: Info, ctx: SerializePluginContext, data: PluginData): string;
109
- /** Revives the parsed payload back into the runtime value. */
110
- deserialize(node: Info, ctx: DeserializePluginContext, data: PluginData): Value;
69
+ /** A unique string identifying the plugin — namespace it (`"app/Thing"`). */
70
+ tag: string;
71
+ /** Dependency plugins, resolved ahead of this one. */
72
+ extends?: SerializerPlugin[];
73
+ /** Whether `value` is this plugin's to encode. */
74
+ test(value: unknown): boolean;
75
+ /** Parsing modes — provide the ones the transports you target use. */
76
+ parse: {
77
+ sync?: (value: Value, ctx: SyncParsePluginContext, data: PluginData) => Info;
78
+ async?: (value: Value, ctx: AsyncParsePluginContext, data: PluginData) => Promise<Info>;
79
+ stream?: (value: Value, ctx: StreamParsePluginContext, data: PluginData) => Info;
80
+ };
81
+ /** Renders the parsed payload as JS source (script-injection form). */
82
+ serialize(node: Info, ctx: SerializePluginContext, data: PluginData): string;
83
+ /** Revives the parsed payload back into the runtime value. */
84
+ deserialize(node: Info, ctx: DeserializePluginContext, data: PluginData): Value;
111
85
  }
112
-
113
- /**
114
- * Baseline plugin set for serializing web-platform values (AbortSignal,
115
- * Event, FormData, Headers, ReadableStream, Request, Response, URL, ...).
116
- * Applied by every serializer in this module; custom plugins compose ahead
117
- * of it via `resolveSerializerPlugins`.
118
- *
119
- * Integration-facing; may change (see the entry banner).
120
- */
121
- export const DEFAULT_WEB_PLUGINS: readonly SerializerPlugin[];
122
-
123
- /**
124
- * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
125
- * first so they can shadow a default for values both would match. Returns a
126
- * fresh array; the defaults are never mutated. Useful when handing a full
127
- * plugin list to another serialization layer.
128
- *
129
- * Integration-facing; may change (see the entry banner).
130
- */
131
- export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
132
-
133
86
  /**
134
87
  * Options shared by both halves of the JSON codec. All of them must match
135
88
  * on the serializing and deserializing peer or payloads will not
@@ -139,32 +92,20 @@ export function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): Se
139
92
  * Integration-facing; may change (see the entry banner).
140
93
  */
141
94
  export interface JSONCodecOptions {
142
- /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
143
- plugins?: SerializerPlugin[];
144
- /**
145
- * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
146
- * (payloads may come from an untrusted peer). Must match on both peers.
147
- * Outside development, the encoding side additionally strips
148
- * `Error.prototype.stack` on top of any override — serialized stacks leak
149
- * server paths to the client. Decoding stays permissive, so payloads from
150
- * a development peer still round-trip.
151
- */
152
- disabledFeatures?: number;
153
- /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
154
- depthLimit?: number;
95
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. Must match on both peers. */
96
+ plugins?: SerializerPlugin[];
97
+ /**
98
+ * Seroval feature bitflags to exclude. Defaults to disabling `RegExp`
99
+ * (payloads may come from an untrusted peer). Must match on both peers.
100
+ * Outside development, the encoding side additionally strips
101
+ * `Error.prototype.stack` on top of any override — serialized stacks leak
102
+ * server paths to the client. Decoding stays permissive, so payloads from
103
+ * a development peer still round-trip.
104
+ */
105
+ disabledFeatures?: number;
106
+ /** Maximum parse/deserialize depth. Defaults to 64. Must match on both peers. */
107
+ depthLimit?: number;
155
108
  }
156
-
157
- /**
158
- * Creates the decoding counterpart of `serializeJSON`. Cross-references
159
- * between chunks resolve through state shared across calls, so all chunks
160
- * from one stream must go through the same deserializer instance. The first
161
- * chunk's return value is the decoded source value; feeding later chunks
162
- * settles the async values referenced inside it.
163
- *
164
- * Integration-facing; may change (see the entry banner).
165
- */
166
- export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
167
-
168
109
  /**
169
110
  * A resident, response-scoped decode table over the keyed JSON codec: apply
170
111
  * each frame `data` chunk with `apply`, resolve `{ $ref }` slot args with
@@ -176,7 +117,43 @@ export function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: Se
176
117
  * it internally rather than re-exporting it.
177
118
  */
178
119
  export interface JSONDataTable {
179
- apply(chunk: { key?: string; node?: unknown; initial?: boolean }): void;
180
- resolve<T = unknown>(ref: { $ref: string }): T;
120
+ apply(chunk: {
121
+ key?: string;
122
+ node?: unknown;
123
+ initial?: boolean;
124
+ }): void;
125
+ resolve<T = unknown>(ref: {
126
+ $ref: string;
127
+ }): T;
181
128
  }
182
- export function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
129
+ /**
130
+ * Baseline plugin set for serializing web-platform values. Shared by the
131
+ * hydration serializer and any consumer building its own serializer (e.g.
132
+ * server function transports). Plugin objects carry both their serialize
133
+ * and deserialize halves, so the set lives on the decode side and the
134
+ * encode module composes over it.
135
+ */
136
+ export declare const DEFAULT_WEB_PLUGINS: any; /**
137
+ * Composes custom plugins with `DEFAULT_WEB_PLUGINS`. Custom plugins come
138
+ * first so they can shadow a default for values both would match. Returns a
139
+ * fresh array; the defaults are never mutated. Useful when handing a full
140
+ * plugin list to another serialization layer.
141
+ *
142
+ * Integration-facing; may change (see the entry banner).
143
+ */
144
+ export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
145
+ export declare function resolveCodecOptions({ plugins, disabledFeatures, depthLimit }?: JSONCodecOptions): {
146
+ plugins: SerializerPlugin<any, any>[];
147
+ disabledFeatures: any;
148
+ depthLimit: number;
149
+ }; /**
150
+ * Creates the decoding counterpart of `serializeJSON`. Cross-references
151
+ * between chunks resolve through state shared across calls, so all chunks
152
+ * from one stream must go through the same deserializer instance. The first
153
+ * chunk's return value is the decoded source value; feeding later chunks
154
+ * settles the async values referenced inside it.
155
+ *
156
+ * Integration-facing; may change (see the entry banner).
157
+ */
158
+ export declare function createJSONDeserializer(options?: JSONCodecOptions): <T>(node: SerovalNode) => T;
159
+ export declare function createJSONDataTable(options?: JSONCodecOptions): JSONDataTable;
@@ -0,0 +1,94 @@
1
+ import { Serializer } from "seroval";
2
+ import type { JSONCodecOptions, PluginInfo, SerializerPlugin, SerovalNode } from "./serializer-decode.cjs";
3
+ export { DEFAULT_WEB_PLUGINS, createJSONDataTable, createJSONDeserializer, resolveSerializerPlugins } from "./serializer-decode.cjs";
4
+ export type * from "./serializer-decode.cjs";
5
+ /**
6
+ * Options for `createSerializer`.
7
+ *
8
+ * Integration-facing; may change (see the entry banner).
9
+ */
10
+ export interface WebSerializerOptions {
11
+ /** Name of the global object the emitted scripts write resolved values into. */
12
+ globalIdentifier: string;
13
+ /** Cross-reference scope id, for isolating multiple streams on one page. */
14
+ scopeId?: string;
15
+ /**
16
+ * Seroval feature bitflags to exclude from output. Defaults to disabling
17
+ * post-ES2017 features (AggregateError, BigInt typed arrays). Outside
18
+ * development, `Error.prototype.stack` is additionally stripped on top of
19
+ * any override — serialized stacks leak server paths to the client.
20
+ */
21
+ disabledFeatures?: number;
22
+ /** Extra plugins, composed ahead of `DEFAULT_WEB_PLUGINS`. */
23
+ plugins?: SerializerPlugin[];
24
+ /** Receives each emitted script chunk. */
25
+ onData: (result: string) => void;
26
+ onError?: (error: unknown) => void;
27
+ /** Fires once all async values have settled. */
28
+ onDone?: () => void;
29
+ }
30
+ /**
31
+ * Options for `createHydrationSerializer` — `WebSerializerOptions` minus
32
+ * the knobs hydration pins (`globalIdentifier`, `disabledFeatures`).
33
+ * @internal
34
+ */
35
+ export type HydrationSerializerOptions = Omit<WebSerializerOptions, "globalIdentifier" | "disabledFeatures">;
36
+ /**
37
+ * Options for `serializeJSON`.
38
+ *
39
+ * Integration-facing; may change (see the entry banner).
40
+ */
41
+ export interface JSONSerializeOptions extends JSONCodecOptions {
42
+ /**
43
+ * Receives each serialized node; `initial` is true for the first chunk
44
+ * (the source value itself). Async values produce additional chunks as
45
+ * they resolve.
46
+ */
47
+ onParse: (node: SerovalNode, initial: boolean) => void;
48
+ onError?: (error: unknown) => void;
49
+ /** Fires once all async values have settled. */
50
+ onDone?: () => void;
51
+ }
52
+ /** Options for `createJSONSerializer`. */
53
+ export interface JSONSerializerOptions extends JSONCodecOptions {
54
+ /**
55
+ * Receives each keyed record — `initial` is true for a key's first node
56
+ * (the written value itself); async values patch through later records
57
+ * under the same key. The decoding peer is `createJSONDataTable`.
58
+ */
59
+ onData: (record: {
60
+ key: string;
61
+ node: SerovalNode;
62
+ initial: boolean;
63
+ }) => void;
64
+ onError?: (error: unknown) => void;
65
+ /** Fires once `flush()` has been called and every pending value settled. */
66
+ onDone?: () => void;
67
+ }
68
+ export declare const createPlugin: <Value, Info extends PluginInfo>(plugin: SerializerPlugin<Value, Info>) => SerializerPlugin<Value, Info>;
69
+ export interface OpaqueReference<V = unknown, R = undefined> {
70
+ readonly value: V;
71
+ readonly replacement?: R;
72
+ }
73
+ export declare const OpaqueReference: {
74
+ new <V, R = undefined>(value: V, replacement?: R): OpaqueReference<V, R>;
75
+ };
76
+ /**
77
+ * Creates a streaming Seroval serializer preconfigured with the web plugin
78
+ * set and the default feature policy. Emits JavaScript chunks (through
79
+ * `onData`) that reconstruct the values under `globalIdentifier` when
80
+ * evaluated — the script-injection form of serialization renderers build
81
+ * on. For a JSON-based wire codec (no eval on the receiving side), use
82
+ * `serializeJSON` / `createJSONDeserializer` instead.
83
+ *
84
+ * Integration-facing; may change (see the entry banner).
85
+ */
86
+ export declare function createSerializer(options: WebSerializerOptions): Serializer;
87
+ export declare function createHydrationSerializer(options: HydrationSerializerOptions): Serializer;
88
+ export declare function getLocalHeaderScript(id?: string): string;
89
+ export declare function serializeJSON(value: unknown, options: JSONSerializeOptions): () => void;
90
+ export declare function createJSONSerializer(options: JSONSerializerOptions): {
91
+ write(key: string, value: unknown): void;
92
+ flush(): void;
93
+ close(): void;
94
+ };