@solidjs/web 2.0.0-rc.21 → 2.0.0-rc.23

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.
@@ -210,6 +210,20 @@ function mergeServerTiming(target, value) {
210
210
  target.append("Server-Timing", trimmed);
211
211
  }
212
212
  }
213
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
214
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
215
+ }
216
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
217
+ function mayStore(value, asks) {
218
+ if (value === null) return false;
219
+ let shared = !asks;
220
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
221
+ const name = directive.toLowerCase();
222
+ if (name === "no-store" || name === "private" && !argument) return false;
223
+ if (name === "public" || name === "s-maxage") shared = true;
224
+ }
225
+ return shared;
226
+ }
213
227
 
214
228
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
215
229
  function records() {
@@ -2017,6 +2031,7 @@ function withBufferedBody(request, body) {
2017
2031
  });
2018
2032
  }
2019
2033
  const KNOWN_BODY_FORMATS = new Set(Object.values(BodyFormat));
2034
+ const EMPTY_BODY_FORMATS = new Set([BodyFormat.String, BodyFormat.URLSearchParams, BodyFormat.Blob, BodyFormat.ArrayBuffer, BodyFormat.Uint8Array]);
2020
2035
  const FORMAT_SKEW = Symbol("solid.serverFunction.formatSkew");
2021
2036
  function unknownFormatError(tag) {
2022
2037
  const error = new TypeError(`Server function body carries an unrecognized ${BODY_FORMAT_HEADER} tag ("${tag}"): the ` + "caller encodes a newer wire format than this build can decode (version skew), or an " + "intermediary duplicated the header. The body was refused rather than reinterpreted.");
@@ -2080,11 +2095,13 @@ async function parseArguments(request, url, scripted, codec, buffered) {
2080
2095
  } else if (!args && url.search && (request.method === "GET" || request.method === "HEAD")) {
2081
2096
  parsed.push(url.searchParams);
2082
2097
  }
2083
- if (request.method === "POST" && request.body !== null) {
2098
+ if (request.method === "POST" && (request.body !== null || EMPTY_BODY_FORMATS.has(bodyFormat))) {
2084
2099
  if (bodyFormat !== null && !KNOWN_BODY_FORMATS.has(bodyFormat)) {
2085
2100
  throw unknownFormatError(bodyFormat);
2086
2101
  }
2087
- const body = request.clone();
2102
+ const body = request.body !== null ? request.clone() : new Response(null, {
2103
+ headers: request.headers
2104
+ });
2088
2105
  let decoded;
2089
2106
  if (bodyFormat === BodyFormat.Serialized) {
2090
2107
  let argumentCodec = argumentCodecFor(codec);
@@ -3371,7 +3388,7 @@ async function handleServerFunctionRequest(request, options = {}) {
3371
3388
  return finish(protectsRequest ? withCSRFVary(response) : response);
3372
3389
  }
3373
3390
  const commitResponse = raw => {
3374
- if ((method === "GET" || method === "HEAD") && (sharedCacheMayStore(departingHeader(raw, event, "Cache-Control")) || cdnMayStore(departingHeader(raw, event, "CDN-Cache-Control")))) {
3391
+ if ((method === "GET" || method === "HEAD") && sharedCacheMayStore(departingHeader(raw, event, "Cache-Control"), departingHeader(raw, event, "CDN-Cache-Control"))) {
3375
3392
  withholdTrace(event);
3376
3393
  }
3377
3394
  return commitEventResponse(raw, event);
@@ -3614,41 +3631,6 @@ function departingHeader(response, event, name) {
3614
3631
  const stub = event.response;
3615
3632
  return stub && stub.headers && !stub.committed ? stub.headers.get(name) : null;
3616
3633
  }
3617
- function cdnMayStore(cdnCacheControl) {
3618
- return cdnCacheControl !== null && !forbidsStoring(cdnCacheControl);
3619
- }
3620
- function sharedCacheMayStore(cacheControl) {
3621
- let shared = false;
3622
- return !!cacheControl && !eachDirective(cacheControl, name => {
3623
- if (name === "public" || name === "s-maxage") shared = true;
3624
- }) && shared;
3625
- }
3626
- function forbidsStoring(value) {
3627
- return eachDirective(value, () => {});
3628
- }
3629
- function eachDirective(value, visit) {
3630
- let start = 0;
3631
- let quoted = false;
3632
- for (let i = 0; i <= value.length; i++) {
3633
- const c = value[i];
3634
- if (quoted) {
3635
- if (c === "\\") i++;else if (c === '"') quoted = false;
3636
- continue;
3637
- }
3638
- if (c === '"') {
3639
- quoted = true;
3640
- continue;
3641
- }
3642
- if (c !== "," && i < value.length) continue;
3643
- const directive = value.slice(start, i);
3644
- start = i + 1;
3645
- const eq = directive.indexOf("=");
3646
- const name = (eq === -1 ? directive : directive.slice(0, eq)).trim().toLowerCase();
3647
- if (name === "no-store" || name === "private" && eq === -1) return true;
3648
- visit(name);
3649
- }
3650
- return false;
3651
- }
3652
3634
  function withholdTrace(event) {
3653
3635
  if (event.response && event.response.committed) return;
3654
3636
  traceForEvent(event).emit = false;
@@ -181,6 +181,20 @@ function mergeServerTiming(target, value) {
181
181
  target.append("Server-Timing", trimmed);
182
182
  }
183
183
  }
184
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
185
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
186
+ }
187
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
188
+ function mayStore(value, asks) {
189
+ if (value === null) return false;
190
+ let shared = !asks;
191
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
192
+ const name = directive.toLowerCase();
193
+ if (name === "no-store" || name === "private" && !argument) return false;
194
+ if (name === "public" || name === "s-maxage") shared = true;
195
+ }
196
+ return shared;
197
+ }
184
198
 
185
199
  function records() {
186
200
  return undefined;
@@ -1935,6 +1949,7 @@ function withBufferedBody(request, body) {
1935
1949
  });
1936
1950
  }
1937
1951
  const KNOWN_BODY_FORMATS = new Set(Object.values(BodyFormat));
1952
+ const EMPTY_BODY_FORMATS = new Set([BodyFormat.String, BodyFormat.URLSearchParams, BodyFormat.Blob, BodyFormat.ArrayBuffer, BodyFormat.Uint8Array]);
1938
1953
  const FORMAT_SKEW = Symbol("solid.serverFunction.formatSkew");
1939
1954
  function unknownFormatError(tag) {
1940
1955
  const error = new TypeError(`Server function body carries an unrecognized ${BODY_FORMAT_HEADER} tag ("${tag}"): the ` + "caller encodes a newer wire format than this build can decode (version skew), or an " + "intermediary duplicated the header. The body was refused rather than reinterpreted.");
@@ -1998,11 +2013,13 @@ async function parseArguments(request, url, scripted, codec, buffered) {
1998
2013
  } else if (!args && url.search && (request.method === "GET" || request.method === "HEAD")) {
1999
2014
  parsed.push(url.searchParams);
2000
2015
  }
2001
- if (request.method === "POST" && request.body !== null) {
2016
+ if (request.method === "POST" && (request.body !== null || EMPTY_BODY_FORMATS.has(bodyFormat))) {
2002
2017
  if (bodyFormat !== null && !KNOWN_BODY_FORMATS.has(bodyFormat)) {
2003
2018
  throw unknownFormatError(bodyFormat);
2004
2019
  }
2005
- const body = request.clone();
2020
+ const body = request.body !== null ? request.clone() : new Response(null, {
2021
+ headers: request.headers
2022
+ });
2006
2023
  let decoded;
2007
2024
  if (bodyFormat === BodyFormat.Serialized) {
2008
2025
  let argumentCodec = argumentCodecFor(codec);
@@ -3278,7 +3295,7 @@ async function handleServerFunctionRequest(request, options = {}) {
3278
3295
  return finish(protectsRequest ? withCSRFVary(response) : response);
3279
3296
  }
3280
3297
  const commitResponse = raw => {
3281
- if ((method === "GET" || method === "HEAD") && (sharedCacheMayStore(departingHeader(raw, event, "Cache-Control")) || cdnMayStore(departingHeader(raw, event, "CDN-Cache-Control")))) {
3298
+ if ((method === "GET" || method === "HEAD") && sharedCacheMayStore(departingHeader(raw, event, "Cache-Control"), departingHeader(raw, event, "CDN-Cache-Control"))) {
3282
3299
  withholdTrace(event);
3283
3300
  }
3284
3301
  return commitEventResponse(raw, event);
@@ -3521,41 +3538,6 @@ function departingHeader(response, event, name) {
3521
3538
  const stub = event.response;
3522
3539
  return stub && stub.headers && !stub.committed ? stub.headers.get(name) : null;
3523
3540
  }
3524
- function cdnMayStore(cdnCacheControl) {
3525
- return cdnCacheControl !== null && !forbidsStoring(cdnCacheControl);
3526
- }
3527
- function sharedCacheMayStore(cacheControl) {
3528
- let shared = false;
3529
- return !!cacheControl && !eachDirective(cacheControl, name => {
3530
- if (name === "public" || name === "s-maxage") shared = true;
3531
- }) && shared;
3532
- }
3533
- function forbidsStoring(value) {
3534
- return eachDirective(value, () => {});
3535
- }
3536
- function eachDirective(value, visit) {
3537
- let start = 0;
3538
- let quoted = false;
3539
- for (let i = 0; i <= value.length; i++) {
3540
- const c = value[i];
3541
- if (quoted) {
3542
- if (c === "\\") i++;else if (c === '"') quoted = false;
3543
- continue;
3544
- }
3545
- if (c === '"') {
3546
- quoted = true;
3547
- continue;
3548
- }
3549
- if (c !== "," && i < value.length) continue;
3550
- const directive = value.slice(start, i);
3551
- start = i + 1;
3552
- const eq = directive.indexOf("=");
3553
- const name = (eq === -1 ? directive : directive.slice(0, eq)).trim().toLowerCase();
3554
- if (name === "no-store" || name === "private" && eq === -1) return true;
3555
- visit(name);
3556
- }
3557
- return false;
3558
- }
3559
3541
  function withholdTrace(event) {
3560
3542
  if (event.response && event.response.committed) return;
3561
3543
  traceForEvent(event).emit = false;
@@ -210,6 +210,20 @@ function mergeServerTiming(target, value) {
210
210
  target.append("Server-Timing", trimmed);
211
211
  }
212
212
  }
213
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
214
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
215
+ }
216
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
217
+ function mayStore(value, asks) {
218
+ if (value === null) return false;
219
+ let shared = !asks;
220
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
221
+ const name = directive.toLowerCase();
222
+ if (name === "no-store" || name === "private" && !argument) return false;
223
+ if (name === "public" || name === "s-maxage") shared = true;
224
+ }
225
+ return shared;
226
+ }
213
227
 
214
228
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
215
229
  function records() {
@@ -1987,6 +2001,7 @@ function withBufferedBody(request, body) {
1987
2001
  });
1988
2002
  }
1989
2003
  const KNOWN_BODY_FORMATS = new Set(Object.values(BodyFormat));
2004
+ const EMPTY_BODY_FORMATS = new Set([BodyFormat.String, BodyFormat.URLSearchParams, BodyFormat.Blob, BodyFormat.ArrayBuffer, BodyFormat.Uint8Array]);
1990
2005
  const FORMAT_SKEW = Symbol("solid.serverFunction.formatSkew");
1991
2006
  function unknownFormatError(tag) {
1992
2007
  const error = new TypeError(`Server function body carries an unrecognized ${BODY_FORMAT_HEADER} tag ("${tag}"): the ` + "caller encodes a newer wire format than this build can decode (version skew), or an " + "intermediary duplicated the header. The body was refused rather than reinterpreted.");
@@ -2050,11 +2065,13 @@ async function parseArguments(request, url, scripted, codec, buffered) {
2050
2065
  } else if (!args && url.search && (request.method === "GET" || request.method === "HEAD")) {
2051
2066
  parsed.push(url.searchParams);
2052
2067
  }
2053
- if (request.method === "POST" && request.body !== null) {
2068
+ if (request.method === "POST" && (request.body !== null || EMPTY_BODY_FORMATS.has(bodyFormat))) {
2054
2069
  if (bodyFormat !== null && !KNOWN_BODY_FORMATS.has(bodyFormat)) {
2055
2070
  throw unknownFormatError(bodyFormat);
2056
2071
  }
2057
- const body = request.clone();
2072
+ const body = request.body !== null ? request.clone() : new Response(null, {
2073
+ headers: request.headers
2074
+ });
2058
2075
  let decoded;
2059
2076
  if (bodyFormat === BodyFormat.Serialized) {
2060
2077
  let argumentCodec = argumentCodecFor(codec);
@@ -3341,7 +3358,7 @@ async function handleServerFunctionRequest(request, options = {}) {
3341
3358
  return finish(protectsRequest ? withCSRFVary(response) : response);
3342
3359
  }
3343
3360
  const commitResponse = raw => {
3344
- if ((method === "GET" || method === "HEAD") && (sharedCacheMayStore(departingHeader(raw, event, "Cache-Control")) || cdnMayStore(departingHeader(raw, event, "CDN-Cache-Control")))) {
3361
+ if ((method === "GET" || method === "HEAD") && sharedCacheMayStore(departingHeader(raw, event, "Cache-Control"), departingHeader(raw, event, "CDN-Cache-Control"))) {
3345
3362
  withholdTrace(event);
3346
3363
  }
3347
3364
  return commitEventResponse(raw, event);
@@ -3584,41 +3601,6 @@ function departingHeader(response, event, name) {
3584
3601
  const stub = event.response;
3585
3602
  return stub && stub.headers && !stub.committed ? stub.headers.get(name) : null;
3586
3603
  }
3587
- function cdnMayStore(cdnCacheControl) {
3588
- return cdnCacheControl !== null && !forbidsStoring(cdnCacheControl);
3589
- }
3590
- function sharedCacheMayStore(cacheControl) {
3591
- let shared = false;
3592
- return !!cacheControl && !eachDirective(cacheControl, name => {
3593
- if (name === "public" || name === "s-maxage") shared = true;
3594
- }) && shared;
3595
- }
3596
- function forbidsStoring(value) {
3597
- return eachDirective(value, () => {});
3598
- }
3599
- function eachDirective(value, visit) {
3600
- let start = 0;
3601
- let quoted = false;
3602
- for (let i = 0; i <= value.length; i++) {
3603
- const c = value[i];
3604
- if (quoted) {
3605
- if (c === "\\") i++;else if (c === '"') quoted = false;
3606
- continue;
3607
- }
3608
- if (c === '"') {
3609
- quoted = true;
3610
- continue;
3611
- }
3612
- if (c !== "," && i < value.length) continue;
3613
- const directive = value.slice(start, i);
3614
- start = i + 1;
3615
- const eq = directive.indexOf("=");
3616
- const name = (eq === -1 ? directive : directive.slice(0, eq)).trim().toLowerCase();
3617
- if (name === "no-store" || name === "private" && eq === -1) return true;
3618
- visit(name);
3619
- }
3620
- return false;
3621
- }
3622
3604
  function withholdTrace(event) {
3623
3605
  if (event.response && event.response.committed) return;
3624
3606
  traceForEvent(event).emit = false;
package/types/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
2
2
  import type { ClientErrorHook, Owner } from "solid-js";
3
+ import { heldRead } from "solid-js/internal";
3
4
  import { effect, memo } from "./render.js";
4
5
  import { JSX } from "./jsx.js";
5
6
  import type { RequestEventLocals, HydrationWriter, HydrationValue, LinkClaimHandler } from "./server.js";
@@ -100,6 +101,15 @@ export declare function HydrationScript(_props?: {
100
101
  eventNames?: string[];
101
102
  }): null;
102
103
  export { effect, memo, untrack, getOwner, createComponent };
104
+ /**
105
+ * Compiled grouped effects read it after their values: a stateful DOM prop
106
+ * (`value`, `checked`, …) whose value did not change is not written again
107
+ * while the effect is a stale reader of an open hold (#4872). The hold's
108
+ * landing re-runs the effect and writes the bound value.
109
+ *
110
+ * @internal Compiler output only.
111
+ */
112
+ export { heldRead };
103
113
  /**
104
114
  * Compiler-emitted prop-spread helper. The JSX transform emits
105
115
  * `mergeProps(...)` when compiling prop spreads on components — not a
@@ -175,6 +185,33 @@ export declare function render(code: () => JSX.Element, element: MountableElemen
175
185
  */
176
186
  onError?: ClientErrorHook;
177
187
  }): () => void;
188
+ /**
189
+ * Sets the Trusted Types policy that HTML is parsed through.
190
+ *
191
+ * A page that enforces `require-trusted-types-for 'script'` rejects a plain
192
+ * string assigned to `innerHTML`. With a policy set, the runtime assigns the
193
+ * `TrustedHTML` that `policy.createHTML(html)` returns. It is asked for two
194
+ * kinds of HTML: the static markup the compiler emitted for a template, and
195
+ * the HTML a server component sends, which the frames client parses. The app
196
+ * creates the policy, so its name and its checks stay under the app's
197
+ * Content Security Policy:
198
+ *
199
+ * ```ts
200
+ * setTrustedTypesPolicy(trustedTypes.createPolicy("my-app", { createHTML: html => html }));
201
+ * ```
202
+ *
203
+ * Call it before the first render. `undefined` goes back to plain strings.
204
+ */
205
+ export declare function setTrustedTypesPolicy(policy: {
206
+ createHTML(html: string): unknown;
207
+ } | undefined): void;
208
+ /**
209
+ * What a parse assigns to `innerHTML` for `html`: the policy's `TrustedHTML`
210
+ * when `setTrustedTypesPolicy` set one, otherwise the string. Integration
211
+ * plumbing for the frames client, which parses outside this module.
212
+ * @internal
213
+ */
214
+ export declare function trustedHTML(html: string): string;
178
215
  export declare function template(html: string, flag?: 1 | 2): () => Element;
179
216
  export declare function delegateEvents(eventNames: string[]): void;
180
217
  export declare function registerDelegatedRoot(root: MountableElement): void;
@@ -215,6 +252,19 @@ export declare function setProperty(node: Element, name: string, value: any): vo
215
252
  * @internal Compiler output only.
216
253
  */
217
254
  export declare function setStatefulProperty(node: Element, name: string, value: any): void;
255
+ /**
256
+ * An event handler expression from dev-compiled DOM output (#1742):
257
+ * `onClick={props.onClick}` compiles to `strictHandler(() => props.onClick)`
258
+ * where production output inlines `props.onClick`. A handler is bound once,
259
+ * where its element is created, so a reactive read in the expression is a
260
+ * mistake: dev warns `STRICT_READ_UNTRACKED` (a pending async read throws
261
+ * `PENDING_ASYNC_UNTRACKED_READ`). The read still tracks, so dev re-mounts
262
+ * on a change exactly as production does. Production compile output never
263
+ * imports it, so it tree-shakes away.
264
+ *
265
+ * @internal Compiler output only.
266
+ */
267
+ export declare function strictHandler<T>(fn: () => T): T;
218
268
  /**
219
269
  * Options for `registerElementClaim`.
220
270
  * @internal
@@ -275,8 +325,8 @@ export declare function style(node: Element, value: {
275
325
  * read per key; a clsx-style class array is re-mapped element-wise (className
276
326
  * allocates for an array anyway; measured at parity).
277
327
  *
278
- * The proxy's keys are read with `Reflect.ownKeys` directly — what
279
- * `sourceKeys(value, SOURCE_PROXY)` resolves to by definition (`leafOf` is
328
+ * The proxy's keys are read with `Reflect.ownKeys` directly — the keys
329
+ * `sourceKeys(value, SOURCE_PROXY)` returns by definition (`leafOf` is
280
330
  * the identity for a proxy kind; `leafKeys` answers a proxy with one
281
331
  * `ownKeys` trap) — rather than through `sourceKeys`, whose kind argument is
282
332
  * a runtime value: calling it here retained the merge/omit view walkers
@@ -294,6 +344,8 @@ export declare function applyRef<T extends Element = Element>(r: ((element: NoIn
294
344
  export declare function ref(fn: () => ((element: Element) => void) | ((element: Element) => void)[], element: Element): void;
295
345
  /** Compiler-emitted primitive; not for hand-written code. @internal */
296
346
  export declare function scope<T extends () => any>(fn: T): T;
347
+ /** Integration plumbing for Portal. @internal */
348
+ export declare function installHostTagging(): void;
297
349
  export declare function installHydrationRuntime(): void;
298
350
  /**
299
351
  * Compiler-emitted primitive; not for hand-written code.
@@ -8,6 +8,7 @@ declare const DOMWithState: Record<string, Record<string, 1 | 2>>;
8
8
  declare const ChildProperties: Set<string>;
9
9
  declare const LinkAttributes: Set<string>;
10
10
  declare const $$SLOT: unique symbol;
11
+ declare const $$INDEX: unique symbol;
11
12
  declare const $$HOST: unique symbol;
12
13
  declare const DelegatedEvents: Set<string>;
13
14
  declare const SVGElements: Set<string>;
@@ -19,4 +20,4 @@ declare const DOMElements: Set<string>;
19
20
  declare const COMPOSED_BODY_FRAMING: ReadonlySet<string>;
20
21
  declare function isHttpNavigationTarget(target: string): boolean;
21
22
  declare function isEventName(name: string): boolean;
22
- export { DOMWithState, ChildProperties, LinkAttributes, DelegatedEvents, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DOMElements, $$SLOT, $$HOST, COMPOSED_BODY_FRAMING, isHttpNavigationTarget, isEventName };
23
+ export { DOMWithState, ChildProperties, LinkAttributes, DelegatedEvents, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DOMElements, $$SLOT, $$INDEX, $$HOST, COMPOSED_BODY_FRAMING, isHttpNavigationTarget, isEventName };
@@ -500,6 +500,8 @@ export declare function makeFrameElement(id: any): HTMLElement;
500
500
  /** Whether `node` is a frame boundary/region element (carries our id attr).
501
501
  * @internal */
502
502
  export declare function isFrameElement(node: any): any;
503
+ /** @internal */
504
+ export declare function setTrustedHTML(wrap: ((html: string) => unknown) | undefined): void;
503
505
  /** Parse an HTML string into a document fragment, preserving comments. */
504
506
  export declare function parseFragment(html: any): DocumentFragment;
505
507
  /** The `<!--pl-KEY-->` comment closing a placeholder range, or null. */
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
127
127
  * reference a slot the client never filled and resolve `undefined`; it
128
128
  * parses the value again and fails on its own. seroval takes the next index
129
129
  * from `refs.size`, so the size counts every index ever taken.
130
+ *
131
+ * `plain(key)` answers with a message when the failure is the key's own
132
+ * rejection and the renderer sends a plain `Error` in its place (#4709): an
133
+ * `<Errored>` drew its fallback from that error, so the promise is rejected
134
+ * with the message and marked the way seroval marks a rejection. The
135
+ * hydrating read then throws it in the claim pass, against the fallback's
136
+ * markup.
130
137
  * @internal
131
138
  */
132
- export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
139
+ export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
133
140
  * Renderer primitive — returns the cross-reference bootstrap script SSR
134
141
  * emits ahead of hydration data for a render scope. Not meant for
135
142
  * hand-written code.
@@ -26,6 +26,13 @@
26
26
  * the first pass — a cycle revisits its nodes on every level down to the
27
27
  * catch — and every node of the clone pass answer from the record, so a
28
28
  * visitor's side effects run once per node whichever way the walk went.
29
+ * The clone pass is copy-on-write too (#4846): it first marks, a strongly
30
+ * connected component at a time, the containers a replacement is reachable
31
+ * from, and copies only those. A subtree with nothing to replace keeps its
32
+ * identity on the cyclic path as on the acyclic one, so a value the
33
+ * serializer also writes in another record (an async memo's answer a store
34
+ * holds) stays one reference, and a cycle with nothing to replace comes
35
+ * back as itself.
29
36
  * Walks that replace nothing never pay the lookup. A value reachable at two
30
37
  * paths is one node: its replacement is shared (one seat for one iterable —
31
38
  * the identity the input had, which the serializer writes once and the
@@ -127,9 +127,16 @@ export declare function createHydrationSerializer(options: HydrationSerializerOp
127
127
  * reference a slot the client never filled and resolve `undefined`; it
128
128
  * parses the value again and fails on its own. seroval takes the next index
129
129
  * from `refs.size`, so the size counts every index ever taken.
130
+ *
131
+ * `plain(key)` answers with a message when the failure is the key's own
132
+ * rejection and the renderer sends a plain `Error` in its place (#4709): an
133
+ * `<Errored>` drew its fallback from that error, so the promise is rejected
134
+ * with the message and marked the way seroval marks a rejection. The
135
+ * hydrating read then throws it in the claim pass, against the fallback's
136
+ * markup.
130
137
  * @internal
131
138
  */
132
- export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any): (key: any, value: any, callbacks: any, live: any) => any; /**
139
+ export declare function rejectUnserializedKey(serialize: any, refs: any, onData: any, scopeId: any, plain: any): (key: any, value: any, callbacks: any, live: any) => any; /**
133
140
  * Renderer primitive — returns the cross-reference bootstrap script SSR
134
141
  * emits ahead of hydration data for a render scope. Not meant for
135
142
  * hand-written code.
@@ -200,8 +200,9 @@ export declare function hasFlightMetadata(response: Response): boolean;
200
200
  * value. Pending entries in the slices (values the collector folded while
201
201
  * still in flight, streamed after the response head) are settled before
202
202
  * any consumer runs. A consumer whose source was not folded is skipped —
203
- * unless the response carries integration metadata, in which case it runs
204
- * with `data` `undefined` to apply the metadata. Consumers are looked up
203
+ * unless the response carries integration metadata, or the server folded
204
+ * nothing at all (a plain mutation, #4883), in which case it runs with
205
+ * `data` `undefined` to apply the metadata or its default. Consumers are looked up
205
206
  * per delivery: an awaited consumer may unsubscribe another (a provider
206
207
  * tearing down under a navigation).
207
208
  *
package/types/server.d.ts CHANGED
@@ -284,10 +284,10 @@ export declare function renderToStream<T>(fn: () => T, options?: {
284
284
  * (see `ServerErrorHook`): every failure the render handles — an
285
285
  * `<Errored>` fallback (`handling: "fallback"`), a rejected fragment
286
286
  * (`"client"`), a hydration value that would not serialize
287
- * (`"serialize"`: an async value that fails before the first flush
288
- * also fails the render, with no `onCompleteAll`; after it, its key
289
- * rejects on the client — #4647) — and the one that fails the request
290
- * (`"failed"`),
287
+ * (`"serialize"`: a default serializer failure before the first flush
288
+ * also fails the render, with no `onCompleteAll` (#4709); after it,
289
+ * published values reject on the client (#4647)), and the one that fails
290
+ * the request (`"failed"`),
291
291
  * once per error per kind per request (per render outside one), with
292
292
  * where it was met. A one-argument listener still
293
293
  * works; it hears them all — filter on `context.handling` for the
@@ -419,6 +419,38 @@ export declare function createLiveHoles(sink: any, scoped: any, settled: any, er
419
419
  /** The shared id counter — `ssr()` mints an attr address at injection
420
420
  * time, before its capture completes. */
421
421
  mint(): number;
422
+ /**
423
+ * Open an attr capture for the tag whose open ends at `off` in `text`
424
+ * (`ssr()`'s tag-open segment): mint its address and splice
425
+ * ` data-lha="N"` in, or — a boundary resume re-rendering a tag whose
426
+ * capture went pending (see `retry`), where the address is already on
427
+ * the element — take that address over, so the pending capture never
428
+ * registers. Returns the capture, its segment's new text on `text`.
429
+ */
430
+ open(text: any, off: any, hole: any): {
431
+ id: any;
432
+ parts: any[];
433
+ base: any;
434
+ inject: any;
435
+ waiting: number;
436
+ text: any;
437
+ };
438
+ /**
439
+ * An in-tag hole that escalated (its value is still pending) resolves later
440
+ * as a retry fn, one of two ways. A boundary resume re-renders the open tag
441
+ * through `ssr(pending.t, ...pending.h)`, which captures it again. At the
442
+ * top of a render there is no boundary: the tree resolver pulls the retry
443
+ * as a function node, which it otherwise treats as content and routes
444
+ * through the live-hole engine, so its markers would land inside the tag
445
+ * (`<div<!--lh:N--> style="…"<!--lh:/N-->>`) or inside the attribute value.
446
+ * The retry is tagged (`$lhInTag`, carried through re-wraps) so the engine
447
+ * never marks it. When the tag was being captured, the capture stays open
448
+ * as pending (`$lhAttr`): its address stays on the element, and the engine
449
+ * registers its binding once the tag's last retry resolves, with the text
450
+ * at that moment as the baseline. A boundary resume adopts the address
451
+ * instead (see `open`), so the element carries one.
452
+ */
453
+ retry(fn: any, cap: any): void;
422
454
  /** Whether interception may arm at the current evaluation point —
423
455
  * `ssr()` asks before opening an attr capture (the `data-lha`
424
456
  * injection must not touch out-of-scope bytes, nor address an element
@@ -475,8 +507,12 @@ export type LinkClaimHandler = (attrs: Readonly<Record<string, unknown>>) => str
475
507
  * @internal
476
508
  */
477
509
  export declare function ssrLinkClaim(attrs: Readonly<Record<string, unknown>>): string;
478
- export declare function ssrSelectValues(): void;
479
- export declare function resolveSSRSelectValues(html: any): any;
510
+ /** Compiler-emitted primitive; not for hand-written code. @internal */
511
+ export declare function ssrSelect(value: any): any;
512
+ /** Compiler-emitted primitive; not for hand-written code. @internal */
513
+ export declare function ssrIn<T>(state: any, fn: () => T): T;
514
+ /** Compiler-emitted primitive; not for hand-written code. @internal */
515
+ export declare function ssrOption(value: any, state?: any, own?: any): string;
480
516
  export declare function escape(s: any, attr?: boolean): any;
481
517
  export declare function getHydrationKey(): string | undefined;
482
518
  export declare function applyRef(r: ((element: any) => void) | ((element: any) => void)[], element: any): void;
@@ -715,9 +751,14 @@ export type ElementClaimOptions = {
715
751
  * register isomorphically. Returns a no-op unregister function.
716
752
  */
717
753
  export declare function registerElementClaim(handler: (element: Element) => void, options?: ElementClaimOptions): () => void;
754
+ export declare function setTrustedTypesPolicy(policy: {
755
+ createHTML(html: string): unknown;
756
+ } | undefined): void;
757
+ /** Server: markup stays a string. @internal */
758
+ export declare function trustedHTML(html: string): string;
718
759
  export declare function claimElement<T extends Element>(node: T, owner?: Owner | null): T;
719
760
  export declare function claimElementTree<T extends Node>(root: T): T;
720
761
  /** Server: `fn()`. No event is dispatched during SSR, so there is no interaction to join. */
721
762
  export declare function dispatchAsInteraction<T>(_e: Event, fn: () => T): T;
722
- export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as setStatefulProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
763
+ export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as setStatefulProperty, notSup as heldRead, notSup as strictHandler, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
723
764
  declare function notSup(): void;
package/types/trace.d.ts CHANGED
@@ -125,3 +125,21 @@ export declare function mergeServerTiming(target: Headers, value: string): void;
125
125
  * prelude (after charset/base). Empty when the browser is not told.
126
126
  */
127
127
  export declare function traceMetaMarkup(record: TraceRecord): string;
128
+ export declare function sharedCacheMayStore(cacheControl: string | null, cdnCacheControl: string | null): boolean;
129
+ /**
130
+ * #4938: a document a shared cache may store, by the head it will leave with
131
+ * (the request event's response stub), tells no viewer the request's trace —
132
+ * neither `<meta>` nor `Server-Timing`. The cache replays that one response
133
+ * to every viewer, so each would parent its browser spans to the request
134
+ * that filled the cache, and per-request bytes in the body defeat ETag
135
+ * revalidation. Decided where the shell head is written, which reads the
136
+ * stub after the shell rendered (an `httpHeader("Cache-Control", …)` in the
137
+ * shell is there); the commit then reads the same record. The server-function
138
+ * road decides the same at its own commit (#4022). `getTraceContext()` is
139
+ * untouched.
140
+ */
141
+ export declare function withholdForSharedCache(record: TraceRecord, event: {
142
+ response?: {
143
+ headers?: Headers;
144
+ };
145
+ } | undefined): void;