payload-live-preview 1.8.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +301 -93
- package/dist/adapters/astro/PreviewBoundary.astro +66 -0
- package/dist/adapters/astro/RichText.astro +6 -0
- package/dist/adapters/astro/index.d.ts +165 -134
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.d.ts +4 -9
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.d.ts +13 -80
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +46 -106
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +10 -75
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/client.cjs +2 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +747 -0
- package/dist/client.d.ts +747 -0
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -0
- package/dist/codegen-astro.d.ts +5 -27
- package/dist/codegen-astro.js +1 -1
- package/dist/codegen-astro.js.map +1 -1
- package/dist/codegen-cli.d.ts +3 -16
- package/dist/codegen-cli.js +1 -1
- package/dist/codegen-cli.js.map +1 -1
- package/dist/codegen.cjs +1 -1
- package/dist/codegen.cjs.map +1 -1
- package/dist/codegen.d.cts +37 -124
- package/dist/codegen.d.ts +37 -124
- package/dist/codegen.js +1 -1
- package/dist/codegen.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +647 -1100
- package/dist/core.d.ts +647 -1100
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/doctor-cli.d.ts +3 -28
- package/dist/doctor-cli.js +1 -1
- package/dist/doctor-cli.js.map +1 -1
- package/dist/doctor.d.ts +16 -32
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/fragment.cjs +2 -0
- package/dist/fragment.cjs.map +1 -0
- package/dist/fragment.d.cts +333 -0
- package/dist/fragment.d.ts +333 -0
- package/dist/fragment.js +2 -0
- package/dist/fragment.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +885 -1531
- package/dist/index.d.ts +885 -1531
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical.cjs +2 -0
- package/dist/lexical.cjs.map +1 -0
- package/dist/lexical.d.cts +90 -0
- package/dist/lexical.d.ts +90 -0
- package/dist/lexical.js +2 -0
- package/dist/lexical.js.map +1 -0
- package/dist/middleware-CEPsY1P7.d.ts +40 -0
- package/dist/migrate.d.ts +73 -0
- package/dist/migrate.js +2 -0
- package/dist/migrate.js.map +1 -0
- package/dist/options-CEzzfHJu.d.ts +197 -0
- package/dist/payload.cjs +1 -1
- package/dist/payload.cjs.map +1 -1
- package/dist/payload.d.cts +11 -80
- package/dist/payload.d.ts +11 -80
- package/dist/payload.js +1 -1
- package/dist/payload.js.map +1 -1
- package/dist/plugins.cjs +2 -0
- package/dist/plugins.cjs.map +1 -0
- package/dist/plugins.d.cts +509 -0
- package/dist/plugins.d.ts +509 -0
- package/dist/plugins.js +2 -0
- package/dist/plugins.js.map +1 -0
- package/dist/{probe-tMHdim5y.d.ts → probe-CYtvj_Lm.d.ts} +43 -77
- package/dist/server.cjs +2 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +435 -0
- package/dist/server.d.ts +435 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/structural.cjs +3 -0
- package/dist/structural.cjs.map +1 -0
- package/dist/structural.d.cts +243 -0
- package/dist/structural.d.ts +243 -0
- package/dist/structural.js +3 -0
- package/dist/structural.js.map +1 -0
- package/package.json +86 -7
- package/dist/middleware-DD4Hwomt.d.ts +0 -189
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every diagnostic code the runtime and tools emit, so a consumer can branch
|
|
3
|
+
* on `e.code` instead of matching message text. A code is never reused for a
|
|
4
|
+
* different meaning; a retired one stays reserved.
|
|
5
|
+
*
|
|
6
|
+
* Browser-side reporting sites write the literal (`code: 'LP0603'`) rather than
|
|
7
|
+
* reading it from this record: the frozen table would then ship in the inline
|
|
8
|
+
* runtime for the sake of six characters. Server-side tools may import it.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Every diagnostic code the runtime can report, by name.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* client.events.on('error', (e) => {
|
|
15
|
+
* if (e.code === DIAGNOSTIC_CODES.TransformThrew) reportToSentry(e.error);
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const DIAGNOSTIC_CODES: Readonly<{
|
|
20
|
+
/** No trusted origin configured in production; nothing will be accepted. */
|
|
21
|
+
readonly NoTrustedOrigin: "LP0101";
|
|
22
|
+
/** Origin trust rests on `document.referrer`, so any framing site is trusted. */
|
|
23
|
+
readonly ReferrerOnlyTrust: "LP0102";
|
|
24
|
+
/** A plugin declares a runtime range this runtime does not satisfy; it was refused. */
|
|
25
|
+
readonly PluginIncompatible: "LP0103";
|
|
26
|
+
/** An update named a field with no binding anchor on the page. */
|
|
27
|
+
readonly OrphanField: "LP0201";
|
|
28
|
+
/** Owner scoping is on and the update names no document it could belong to. */
|
|
29
|
+
readonly UnattributableUpdate: "LP0202";
|
|
30
|
+
/** The visibility gate held offscreen writes back until they scroll into view. */
|
|
31
|
+
readonly VisibilityGateDeferred: "LP0301";
|
|
32
|
+
/** A value was refused because the attribute or the value itself is unsafe. */
|
|
33
|
+
readonly UnsafeAttributeWrite: "LP0401";
|
|
34
|
+
/** A text element has structured children, so replacing its text was skipped. */
|
|
35
|
+
readonly TextTargetHasChildren: "LP0402";
|
|
36
|
+
/** A structural container has no array template, so the update was skipped. */
|
|
37
|
+
readonly MissingArrayTemplate: "LP0403";
|
|
38
|
+
/** A structural item has no `id`; it pairs positionally, so an insert re-renders every row after it. */
|
|
39
|
+
readonly StructuralItemUnkeyed: "LP0404";
|
|
40
|
+
/** Two structural items share a key; later ones pair positionally. */
|
|
41
|
+
readonly StructuralDuplicateKey: "LP0405";
|
|
42
|
+
/** Every structural key changed while the length did not; the source generates keys per message. */
|
|
43
|
+
readonly StructuralUnstableKeys: "LP0406";
|
|
44
|
+
/** A binding asks for a delivery strategy this release does not have; it is left unchanged. */
|
|
45
|
+
readonly UnsupportedStrategy: "LP0407";
|
|
46
|
+
/** A message was rejected before it reached the update pipeline. */
|
|
47
|
+
readonly MessageRejected: "LP0501";
|
|
48
|
+
/** A preview token was rejected. */
|
|
49
|
+
readonly TokenRejected: "LP0502";
|
|
50
|
+
/** A consumer event handler threw. */
|
|
51
|
+
readonly HandlerThrew: "LP0601";
|
|
52
|
+
/** A consumer transform threw; the original value was kept. */
|
|
53
|
+
readonly TransformThrew: "LP0602";
|
|
54
|
+
/** A renderer threw while writing a value. */
|
|
55
|
+
readonly RendererThrew: "LP0603";
|
|
56
|
+
/** Runtime startup failed. */
|
|
57
|
+
readonly StartupFailed: "LP0605";
|
|
58
|
+
/** Sending the ready handshake failed. */
|
|
59
|
+
readonly ReadyFailed: "LP0606";
|
|
60
|
+
/** The audit found no runtime in a response that carried preview intent. */
|
|
61
|
+
readonly AuditRuntimeMissing: "LP0701";
|
|
62
|
+
/** The preview response declares no `frame-ancestors`. */
|
|
63
|
+
readonly AuditNoFrameAncestors: "LP0702";
|
|
64
|
+
/** `X-Frame-Options` forbids framing, which no CSP can undo. */
|
|
65
|
+
readonly AuditFrameOptionsBlocks: "LP0703";
|
|
66
|
+
/** Binding attributes are served to anonymous visitors. */
|
|
67
|
+
readonly AuditBindingsExposed: "LP0704";
|
|
68
|
+
/** More bindings than the default visibility gate will write eagerly. */
|
|
69
|
+
readonly AuditGateThresholdExceeded: "LP0705";
|
|
70
|
+
/** Owner markers exist, but some bindings are outside all of them. */
|
|
71
|
+
readonly AuditUnownedBindings: "LP0706";
|
|
72
|
+
/** The preview response carries no bindings at all. */
|
|
73
|
+
readonly AuditNoBindings: "LP0707";
|
|
74
|
+
/** The URL did not return an HTML page, so nothing else can be judged. */
|
|
75
|
+
readonly AuditNotAPage: "LP0708";
|
|
76
|
+
/** A fragment request failed (network, timeout, server error); the boundary was patched instead. */
|
|
77
|
+
readonly FragmentRequestFailed: "LP0801";
|
|
78
|
+
/** The fragment response had the wrong content type or shape; the boundary was patched instead. */
|
|
79
|
+
readonly FragmentResponseInvalid: "LP0802";
|
|
80
|
+
/** The fragment endpoint refused the preview (not authorized); the boundary was patched instead. */
|
|
81
|
+
readonly FragmentUnauthorized: "LP0803";
|
|
82
|
+
/** A fragment response arrived for a revision that was already superseded and was discarded. */
|
|
83
|
+
readonly FragmentSuperseded: "LP0804";
|
|
84
|
+
/** A route refresh was requested again for the same revision; the loop guard stopped it. */
|
|
85
|
+
readonly RouteRefreshLoop: "LP0805";
|
|
86
|
+
/** A boundary asks for the fragment strategy but no fragment handler is configured; it is patched. */
|
|
87
|
+
readonly FragmentStrategyUnavailable: "LP0806";
|
|
88
|
+
/** A readiness row is not yet at its 2.0 value; `pll doctor --v2` reports it. */
|
|
89
|
+
readonly V2ReadinessGap: "LP0709";
|
|
90
|
+
/** The preview runtime is served to anonymous visitors, not only inside the admin frame. */
|
|
91
|
+
readonly RuntimeOnPublicPage: "LP0710";
|
|
92
|
+
}>;
|
|
93
|
+
/** A diagnostic code, as it appears in log output and on the `error` event. */
|
|
94
|
+
type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[keyof typeof DIAGNOSTIC_CODES];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* How a bound region is brought up to date: the runtime patches it, a server
|
|
98
|
+
* renders a `data-payload-fragment` boundary from the unsaved form state, or
|
|
99
|
+
* the whole route refreshes. Core carries only the seam — which boundaries a
|
|
100
|
+
* strategy owns and what it may do — so a patch-only page pays for nothing
|
|
101
|
+
* more; the orchestration lives in `payload-live-preview/fragment`.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/** What produced an update: the runtime's DOM patching, a server-rendered fragment, or a route refresh. */
|
|
105
|
+
type UpdateSource = 'patch' | 'fragment' | 'route';
|
|
106
|
+
/** Marks a server-rendered boundary; the value is the registry id the server may render. */
|
|
107
|
+
declare const FRAGMENT_ATTRIBUTE = "data-payload-fragment";
|
|
108
|
+
/** One revision, as a strategy sees it, with the runtime capabilities it may use. */
|
|
109
|
+
interface FragmentContext {
|
|
110
|
+
readonly root: ParentNode;
|
|
111
|
+
readonly revision: number;
|
|
112
|
+
readonly receivedAt: number;
|
|
113
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
114
|
+
readonly locale: string | undefined;
|
|
115
|
+
readonly collectionSlug: string | undefined;
|
|
116
|
+
readonly globalSlug: string | undefined;
|
|
117
|
+
/** Aborted when a newer revision arrives or the runtime stops. */
|
|
118
|
+
readonly signal: AbortSignal;
|
|
119
|
+
/** Whether this revision is still the current one. */
|
|
120
|
+
readonly isCurrent: () => boolean;
|
|
121
|
+
/** Morph server-rendered HTML into a boundary (Trusted Types and the keyed morph apply). */
|
|
122
|
+
readonly morph: (boundary: Element, html: string) => void;
|
|
123
|
+
/** Patch the boundary's own bindings from this revision — the deterministic fallback. */
|
|
124
|
+
readonly patch: (boundary: Element) => void;
|
|
125
|
+
/** Debug log through the runtime's logger, with the diagnostic code. */
|
|
126
|
+
readonly log: (code: DiagnosticCode, detail: string) => void;
|
|
127
|
+
/** Report a boundary rendered. */
|
|
128
|
+
readonly rendered: (boundary: Element, id: string, key: string | undefined) => void;
|
|
129
|
+
/** Report a boundary failed and patched instead; emits the `error` and `fragmentRender` events. */
|
|
130
|
+
readonly failed: (boundary: Element, id: string, key: string | undefined, code: DiagnosticCode, reason: string) => void;
|
|
131
|
+
}
|
|
132
|
+
interface FragmentReport {
|
|
133
|
+
readonly rendered: number;
|
|
134
|
+
readonly failed: number;
|
|
135
|
+
readonly superseded: number;
|
|
136
|
+
}
|
|
137
|
+
/** A fragment strategy: which boundaries it owns for a revision, and how it renders them. */
|
|
138
|
+
interface FragmentStrategy {
|
|
139
|
+
/** The boundaries this update re-renders; their inner bindings are left to the strategy. */
|
|
140
|
+
readonly plan: (root: ParentNode, changedFields: ReadonlySet<string>) => readonly Element[];
|
|
141
|
+
/** Render the planned boundaries; resolves once every one settled. */
|
|
142
|
+
readonly render: (context: FragmentContext, boundaries: readonly Element[]) => Promise<FragmentReport>;
|
|
143
|
+
}
|
|
144
|
+
/** One revision, as the route strategy sees it. */
|
|
145
|
+
interface RouteContext {
|
|
146
|
+
readonly revision: number;
|
|
147
|
+
readonly receivedAt: number;
|
|
148
|
+
/** Aborted when a newer revision arrives or the runtime stops. */
|
|
149
|
+
readonly signal: AbortSignal;
|
|
150
|
+
readonly isCurrent: () => boolean;
|
|
151
|
+
readonly log: (code: DiagnosticCode, detail: string) => void;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Whether a revision needs the whole route re-rendered, and how. After a
|
|
155
|
+
* refresh the runtime rescans and re-applies the revision, so the unsaved
|
|
156
|
+
* state lands on the fresh markup.
|
|
157
|
+
*/
|
|
158
|
+
interface RouteStrategy {
|
|
159
|
+
readonly plan: (root: ParentNode, changedFields: ReadonlySet<string>) => boolean;
|
|
160
|
+
readonly refresh: (context: RouteContext) => Promise<'refreshed' | 'failed' | 'superseded'>;
|
|
161
|
+
}
|
|
162
|
+
interface StrategyHandlers {
|
|
163
|
+
readonly fragment?: FragmentStrategy;
|
|
164
|
+
readonly route?: RouteStrategy;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Explicit `data-payload-strategy` wins; otherwise a binding inside a fragment
|
|
168
|
+
* boundary belongs to the fragment, one in `<head>` to the route, the rest is
|
|
169
|
+
* patched. An unknown explicit value resolves to `undefined` (LP0407).
|
|
170
|
+
*/
|
|
171
|
+
declare function resolveStrategy(element: Element): UpdateSource | undefined;
|
|
172
|
+
|
|
173
|
+
/** Fragment boundaries: how a `data-payload-fragment` element is read and which ones an update touches. */
|
|
174
|
+
|
|
175
|
+
/** Distinguishes several boundaries of one registry id; unique among siblings. */
|
|
176
|
+
declare const FRAGMENT_KEY_ATTRIBUTE = "data-payload-fragment-key";
|
|
177
|
+
interface FragmentBoundary {
|
|
178
|
+
readonly element: Element;
|
|
179
|
+
/** Registry id — never a path, module or function name. */
|
|
180
|
+
readonly id: string;
|
|
181
|
+
readonly key: string | undefined;
|
|
182
|
+
/** Fields whose change re-renders the boundary; empty means any field. */
|
|
183
|
+
readonly dependsOn: readonly string[];
|
|
184
|
+
}
|
|
185
|
+
/** One revision's request to a per-boundary handler. */
|
|
186
|
+
interface StrategyRequest {
|
|
187
|
+
readonly revision: number;
|
|
188
|
+
readonly receivedAt: number;
|
|
189
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
190
|
+
readonly locale: string | undefined;
|
|
191
|
+
readonly collectionSlug: string | undefined;
|
|
192
|
+
readonly globalSlug: string | undefined;
|
|
193
|
+
/** Aborted when a newer revision arrives or the runtime stops. */
|
|
194
|
+
readonly signal: AbortSignal;
|
|
195
|
+
}
|
|
196
|
+
type FragmentOutcome = {
|
|
197
|
+
readonly status: 'rendered';
|
|
198
|
+
/** The boundary's new inner HTML. */
|
|
199
|
+
readonly html: string;
|
|
200
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
201
|
+
} | {
|
|
202
|
+
readonly status: 'failed';
|
|
203
|
+
readonly code: DiagnosticCode;
|
|
204
|
+
readonly reason: string;
|
|
205
|
+
} | {
|
|
206
|
+
readonly status: 'superseded';
|
|
207
|
+
};
|
|
208
|
+
/** Renders one boundary for one revision. Must honour `request.signal`. */
|
|
209
|
+
type FragmentHandler = (request: StrategyRequest, boundary: FragmentBoundary) => Promise<FragmentOutcome>;
|
|
210
|
+
declare function describeBoundary(element: Element): FragmentBoundary | null;
|
|
211
|
+
/** The boundaries under `root` that `changedFields` touch; one inside an island is the island's business. */
|
|
212
|
+
declare function collectFragmentBoundaries(root: ParentNode, changedFields: ReadonlySet<string>): readonly FragmentBoundary[];
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The HTTP handler behind `createFragmentStrategy()`: one POST per boundary and
|
|
216
|
+
* revision, shared, gated, timed out and size-bounded. Every failure is an
|
|
217
|
+
* `LP08xx` outcome, never an exception. See ADR 0011.
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
interface FragmentStrategyOptions {
|
|
221
|
+
/** Same-origin path of the fragment endpoint, e.g. `/payload/fragment`. */
|
|
222
|
+
readonly endpoint: string;
|
|
223
|
+
/** `fetch` to use; defaults to the global one. */
|
|
224
|
+
readonly fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
225
|
+
/** Per-request timeout. Default 5000 ms. */
|
|
226
|
+
readonly timeoutMs?: number;
|
|
227
|
+
/** Requests in flight at once; further boundaries wait. Default 4. */
|
|
228
|
+
readonly maxConcurrent?: number;
|
|
229
|
+
/** Largest response body accepted, in bytes. Default 512 KiB. */
|
|
230
|
+
readonly maxResponseBytes?: number;
|
|
231
|
+
/** Extra request headers, e.g. a CSRF token the site already uses. */
|
|
232
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
233
|
+
/** Where the page lives; defaults to `location`. */
|
|
234
|
+
readonly location?: {
|
|
235
|
+
readonly pathname: string;
|
|
236
|
+
readonly search: string;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
declare function createFragmentHandler(options: FragmentStrategyOptions): FragmentHandler;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The route strategy: when a revision touches what no smaller strategy can
|
|
243
|
+
* render, fetch the route again and morph it in place. A refresh inside
|
|
244
|
+
* `minIntervalMs` is refused as LP0805. See ADR 0011.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
/** Sent with every refresh so a server can tell a preview refresh from navigation. */
|
|
248
|
+
declare const ROUTE_REFRESH_HEADER = "x-payload-live-preview";
|
|
249
|
+
interface RouteStrategyOptions {
|
|
250
|
+
/** `fetch` to use; defaults to the global one. */
|
|
251
|
+
readonly fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
252
|
+
/** Per-refresh timeout. Default 8000 ms. */
|
|
253
|
+
readonly timeoutMs?: number;
|
|
254
|
+
/** Shortest gap between two refreshes; one inside it is refused with LP0805. Default 1000 ms. */
|
|
255
|
+
readonly minIntervalMs?: number;
|
|
256
|
+
/** The document to refresh; defaults to `document`. */
|
|
257
|
+
readonly document?: Document;
|
|
258
|
+
/** Where the page lives; defaults to `location`. */
|
|
259
|
+
readonly location?: {
|
|
260
|
+
readonly href: string;
|
|
261
|
+
};
|
|
262
|
+
/** Scroll access; defaults to `window`. */
|
|
263
|
+
readonly window?: {
|
|
264
|
+
readonly scrollX: number;
|
|
265
|
+
readonly scrollY: number;
|
|
266
|
+
readonly scrollTo: (x: number, y: number) => void;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/** An explicit `data-payload-strategy="route"`, or a binding in `<head>`. */
|
|
270
|
+
declare function isRouteBound(element: Element): boolean;
|
|
271
|
+
declare function createRouteStrategy(options?: RouteStrategyOptions): RouteStrategy;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The fragment wire protocol: what the browser posts to a fragment endpoint
|
|
275
|
+
* and what it answers. Both sides validate the shape; nothing on the wire
|
|
276
|
+
* names code, paths or templates. See ADR 0011.
|
|
277
|
+
*/
|
|
278
|
+
/** Bumped when the request or response shape changes incompatibly. */
|
|
279
|
+
declare const FRAGMENT_PROTOCOL_VERSION = 1;
|
|
280
|
+
declare const FRAGMENT_VERSION_HEADER = "x-payload-fragment-version";
|
|
281
|
+
interface FragmentRequestBody {
|
|
282
|
+
/** Registry id of the boundary (`data-payload-fragment`). */
|
|
283
|
+
readonly fragment: string;
|
|
284
|
+
/** `data-payload-fragment-key`, when several boundaries share one id. */
|
|
285
|
+
readonly key?: string;
|
|
286
|
+
/** The page route the boundary belongs to; authorization is bound to it. */
|
|
287
|
+
readonly route: string;
|
|
288
|
+
/** The page's query string, so a `previewToken` in the URL reaches the endpoint. */
|
|
289
|
+
readonly search: string;
|
|
290
|
+
readonly revision: number;
|
|
291
|
+
readonly locale?: string;
|
|
292
|
+
readonly collectionSlug?: string;
|
|
293
|
+
readonly globalSlug?: string;
|
|
294
|
+
/** The unsaved form state as the admin posted it, after the runtime's merge. */
|
|
295
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
296
|
+
}
|
|
297
|
+
interface FragmentResponseBody {
|
|
298
|
+
/** The boundary's new inner HTML. */
|
|
299
|
+
readonly html: string;
|
|
300
|
+
readonly boundary: {
|
|
301
|
+
readonly id: string;
|
|
302
|
+
readonly key?: string;
|
|
303
|
+
};
|
|
304
|
+
/** Echoes the request; the client discards a response for another revision. */
|
|
305
|
+
readonly revision: number;
|
|
306
|
+
readonly metadata: {
|
|
307
|
+
readonly renderedAt: string;
|
|
308
|
+
/** What rendered it, e.g. `astro-container`. */
|
|
309
|
+
readonly renderer: string;
|
|
310
|
+
readonly durationMs?: number;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/** Shape check for a request body; `null` when it is not one. */
|
|
314
|
+
declare function parseFragmentRequest(value: unknown): FragmentRequestBody | null;
|
|
315
|
+
/** Shape check for a response body; `null` when it is not one. */
|
|
316
|
+
declare function parseFragmentResponse(value: unknown): FragmentResponseBody | null;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* `payload-live-preview/fragment` — the fragment and route strategies. The
|
|
320
|
+
* core carries only the seam (`@core/strategies`); this entry owns the
|
|
321
|
+
* orchestration and never sends code, paths or templates. See ADR 0011.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The strategy the runtime drives, built on a per-boundary handler: plan the
|
|
326
|
+
* boundaries, render each, morph a success, patch a failure. A late or
|
|
327
|
+
* aborted render is dropped, never applied.
|
|
328
|
+
*/
|
|
329
|
+
declare function fragmentStrategyFrom(handler: FragmentHandler): FragmentStrategy;
|
|
330
|
+
/** The strategy for a fragment endpoint: hand it to the runtime as `strategies.fragment`. */
|
|
331
|
+
declare function createFragmentStrategy(options: FragmentStrategyOptions): FragmentStrategy;
|
|
332
|
+
|
|
333
|
+
export { DIAGNOSTIC_CODES, type DiagnosticCode, FRAGMENT_ATTRIBUTE, FRAGMENT_KEY_ATTRIBUTE, FRAGMENT_PROTOCOL_VERSION, FRAGMENT_VERSION_HEADER, type FragmentBoundary, type FragmentContext, type FragmentHandler, type FragmentOutcome, type FragmentReport, type FragmentRequestBody, type FragmentResponseBody, type FragmentStrategy, type FragmentStrategyOptions, ROUTE_REFRESH_HEADER, type RouteContext, type RouteStrategy, type RouteStrategyOptions, type StrategyHandlers, type StrategyRequest, type UpdateSource, collectFragmentBoundaries, createFragmentHandler, createFragmentStrategy, createRouteStrategy, describeBoundary, fragmentStrategyFrom, isRouteBound, parseFragmentRequest, parseFragmentResponse, resolveStrategy };
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every diagnostic code the runtime and tools emit, so a consumer can branch
|
|
3
|
+
* on `e.code` instead of matching message text. A code is never reused for a
|
|
4
|
+
* different meaning; a retired one stays reserved.
|
|
5
|
+
*
|
|
6
|
+
* Browser-side reporting sites write the literal (`code: 'LP0603'`) rather than
|
|
7
|
+
* reading it from this record: the frozen table would then ship in the inline
|
|
8
|
+
* runtime for the sake of six characters. Server-side tools may import it.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Every diagnostic code the runtime can report, by name.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* client.events.on('error', (e) => {
|
|
15
|
+
* if (e.code === DIAGNOSTIC_CODES.TransformThrew) reportToSentry(e.error);
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
declare const DIAGNOSTIC_CODES: Readonly<{
|
|
20
|
+
/** No trusted origin configured in production; nothing will be accepted. */
|
|
21
|
+
readonly NoTrustedOrigin: "LP0101";
|
|
22
|
+
/** Origin trust rests on `document.referrer`, so any framing site is trusted. */
|
|
23
|
+
readonly ReferrerOnlyTrust: "LP0102";
|
|
24
|
+
/** A plugin declares a runtime range this runtime does not satisfy; it was refused. */
|
|
25
|
+
readonly PluginIncompatible: "LP0103";
|
|
26
|
+
/** An update named a field with no binding anchor on the page. */
|
|
27
|
+
readonly OrphanField: "LP0201";
|
|
28
|
+
/** Owner scoping is on and the update names no document it could belong to. */
|
|
29
|
+
readonly UnattributableUpdate: "LP0202";
|
|
30
|
+
/** The visibility gate held offscreen writes back until they scroll into view. */
|
|
31
|
+
readonly VisibilityGateDeferred: "LP0301";
|
|
32
|
+
/** A value was refused because the attribute or the value itself is unsafe. */
|
|
33
|
+
readonly UnsafeAttributeWrite: "LP0401";
|
|
34
|
+
/** A text element has structured children, so replacing its text was skipped. */
|
|
35
|
+
readonly TextTargetHasChildren: "LP0402";
|
|
36
|
+
/** A structural container has no array template, so the update was skipped. */
|
|
37
|
+
readonly MissingArrayTemplate: "LP0403";
|
|
38
|
+
/** A structural item has no `id`; it pairs positionally, so an insert re-renders every row after it. */
|
|
39
|
+
readonly StructuralItemUnkeyed: "LP0404";
|
|
40
|
+
/** Two structural items share a key; later ones pair positionally. */
|
|
41
|
+
readonly StructuralDuplicateKey: "LP0405";
|
|
42
|
+
/** Every structural key changed while the length did not; the source generates keys per message. */
|
|
43
|
+
readonly StructuralUnstableKeys: "LP0406";
|
|
44
|
+
/** A binding asks for a delivery strategy this release does not have; it is left unchanged. */
|
|
45
|
+
readonly UnsupportedStrategy: "LP0407";
|
|
46
|
+
/** A message was rejected before it reached the update pipeline. */
|
|
47
|
+
readonly MessageRejected: "LP0501";
|
|
48
|
+
/** A preview token was rejected. */
|
|
49
|
+
readonly TokenRejected: "LP0502";
|
|
50
|
+
/** A consumer event handler threw. */
|
|
51
|
+
readonly HandlerThrew: "LP0601";
|
|
52
|
+
/** A consumer transform threw; the original value was kept. */
|
|
53
|
+
readonly TransformThrew: "LP0602";
|
|
54
|
+
/** A renderer threw while writing a value. */
|
|
55
|
+
readonly RendererThrew: "LP0603";
|
|
56
|
+
/** Runtime startup failed. */
|
|
57
|
+
readonly StartupFailed: "LP0605";
|
|
58
|
+
/** Sending the ready handshake failed. */
|
|
59
|
+
readonly ReadyFailed: "LP0606";
|
|
60
|
+
/** The audit found no runtime in a response that carried preview intent. */
|
|
61
|
+
readonly AuditRuntimeMissing: "LP0701";
|
|
62
|
+
/** The preview response declares no `frame-ancestors`. */
|
|
63
|
+
readonly AuditNoFrameAncestors: "LP0702";
|
|
64
|
+
/** `X-Frame-Options` forbids framing, which no CSP can undo. */
|
|
65
|
+
readonly AuditFrameOptionsBlocks: "LP0703";
|
|
66
|
+
/** Binding attributes are served to anonymous visitors. */
|
|
67
|
+
readonly AuditBindingsExposed: "LP0704";
|
|
68
|
+
/** More bindings than the default visibility gate will write eagerly. */
|
|
69
|
+
readonly AuditGateThresholdExceeded: "LP0705";
|
|
70
|
+
/** Owner markers exist, but some bindings are outside all of them. */
|
|
71
|
+
readonly AuditUnownedBindings: "LP0706";
|
|
72
|
+
/** The preview response carries no bindings at all. */
|
|
73
|
+
readonly AuditNoBindings: "LP0707";
|
|
74
|
+
/** The URL did not return an HTML page, so nothing else can be judged. */
|
|
75
|
+
readonly AuditNotAPage: "LP0708";
|
|
76
|
+
/** A fragment request failed (network, timeout, server error); the boundary was patched instead. */
|
|
77
|
+
readonly FragmentRequestFailed: "LP0801";
|
|
78
|
+
/** The fragment response had the wrong content type or shape; the boundary was patched instead. */
|
|
79
|
+
readonly FragmentResponseInvalid: "LP0802";
|
|
80
|
+
/** The fragment endpoint refused the preview (not authorized); the boundary was patched instead. */
|
|
81
|
+
readonly FragmentUnauthorized: "LP0803";
|
|
82
|
+
/** A fragment response arrived for a revision that was already superseded and was discarded. */
|
|
83
|
+
readonly FragmentSuperseded: "LP0804";
|
|
84
|
+
/** A route refresh was requested again for the same revision; the loop guard stopped it. */
|
|
85
|
+
readonly RouteRefreshLoop: "LP0805";
|
|
86
|
+
/** A boundary asks for the fragment strategy but no fragment handler is configured; it is patched. */
|
|
87
|
+
readonly FragmentStrategyUnavailable: "LP0806";
|
|
88
|
+
/** A readiness row is not yet at its 2.0 value; `pll doctor --v2` reports it. */
|
|
89
|
+
readonly V2ReadinessGap: "LP0709";
|
|
90
|
+
/** The preview runtime is served to anonymous visitors, not only inside the admin frame. */
|
|
91
|
+
readonly RuntimeOnPublicPage: "LP0710";
|
|
92
|
+
}>;
|
|
93
|
+
/** A diagnostic code, as it appears in log output and on the `error` event. */
|
|
94
|
+
type DiagnosticCode = (typeof DIAGNOSTIC_CODES)[keyof typeof DIAGNOSTIC_CODES];
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* How a bound region is brought up to date: the runtime patches it, a server
|
|
98
|
+
* renders a `data-payload-fragment` boundary from the unsaved form state, or
|
|
99
|
+
* the whole route refreshes. Core carries only the seam — which boundaries a
|
|
100
|
+
* strategy owns and what it may do — so a patch-only page pays for nothing
|
|
101
|
+
* more; the orchestration lives in `payload-live-preview/fragment`.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
/** What produced an update: the runtime's DOM patching, a server-rendered fragment, or a route refresh. */
|
|
105
|
+
type UpdateSource = 'patch' | 'fragment' | 'route';
|
|
106
|
+
/** Marks a server-rendered boundary; the value is the registry id the server may render. */
|
|
107
|
+
declare const FRAGMENT_ATTRIBUTE = "data-payload-fragment";
|
|
108
|
+
/** One revision, as a strategy sees it, with the runtime capabilities it may use. */
|
|
109
|
+
interface FragmentContext {
|
|
110
|
+
readonly root: ParentNode;
|
|
111
|
+
readonly revision: number;
|
|
112
|
+
readonly receivedAt: number;
|
|
113
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
114
|
+
readonly locale: string | undefined;
|
|
115
|
+
readonly collectionSlug: string | undefined;
|
|
116
|
+
readonly globalSlug: string | undefined;
|
|
117
|
+
/** Aborted when a newer revision arrives or the runtime stops. */
|
|
118
|
+
readonly signal: AbortSignal;
|
|
119
|
+
/** Whether this revision is still the current one. */
|
|
120
|
+
readonly isCurrent: () => boolean;
|
|
121
|
+
/** Morph server-rendered HTML into a boundary (Trusted Types and the keyed morph apply). */
|
|
122
|
+
readonly morph: (boundary: Element, html: string) => void;
|
|
123
|
+
/** Patch the boundary's own bindings from this revision — the deterministic fallback. */
|
|
124
|
+
readonly patch: (boundary: Element) => void;
|
|
125
|
+
/** Debug log through the runtime's logger, with the diagnostic code. */
|
|
126
|
+
readonly log: (code: DiagnosticCode, detail: string) => void;
|
|
127
|
+
/** Report a boundary rendered. */
|
|
128
|
+
readonly rendered: (boundary: Element, id: string, key: string | undefined) => void;
|
|
129
|
+
/** Report a boundary failed and patched instead; emits the `error` and `fragmentRender` events. */
|
|
130
|
+
readonly failed: (boundary: Element, id: string, key: string | undefined, code: DiagnosticCode, reason: string) => void;
|
|
131
|
+
}
|
|
132
|
+
interface FragmentReport {
|
|
133
|
+
readonly rendered: number;
|
|
134
|
+
readonly failed: number;
|
|
135
|
+
readonly superseded: number;
|
|
136
|
+
}
|
|
137
|
+
/** A fragment strategy: which boundaries it owns for a revision, and how it renders them. */
|
|
138
|
+
interface FragmentStrategy {
|
|
139
|
+
/** The boundaries this update re-renders; their inner bindings are left to the strategy. */
|
|
140
|
+
readonly plan: (root: ParentNode, changedFields: ReadonlySet<string>) => readonly Element[];
|
|
141
|
+
/** Render the planned boundaries; resolves once every one settled. */
|
|
142
|
+
readonly render: (context: FragmentContext, boundaries: readonly Element[]) => Promise<FragmentReport>;
|
|
143
|
+
}
|
|
144
|
+
/** One revision, as the route strategy sees it. */
|
|
145
|
+
interface RouteContext {
|
|
146
|
+
readonly revision: number;
|
|
147
|
+
readonly receivedAt: number;
|
|
148
|
+
/** Aborted when a newer revision arrives or the runtime stops. */
|
|
149
|
+
readonly signal: AbortSignal;
|
|
150
|
+
readonly isCurrent: () => boolean;
|
|
151
|
+
readonly log: (code: DiagnosticCode, detail: string) => void;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Whether a revision needs the whole route re-rendered, and how. After a
|
|
155
|
+
* refresh the runtime rescans and re-applies the revision, so the unsaved
|
|
156
|
+
* state lands on the fresh markup.
|
|
157
|
+
*/
|
|
158
|
+
interface RouteStrategy {
|
|
159
|
+
readonly plan: (root: ParentNode, changedFields: ReadonlySet<string>) => boolean;
|
|
160
|
+
readonly refresh: (context: RouteContext) => Promise<'refreshed' | 'failed' | 'superseded'>;
|
|
161
|
+
}
|
|
162
|
+
interface StrategyHandlers {
|
|
163
|
+
readonly fragment?: FragmentStrategy;
|
|
164
|
+
readonly route?: RouteStrategy;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Explicit `data-payload-strategy` wins; otherwise a binding inside a fragment
|
|
168
|
+
* boundary belongs to the fragment, one in `<head>` to the route, the rest is
|
|
169
|
+
* patched. An unknown explicit value resolves to `undefined` (LP0407).
|
|
170
|
+
*/
|
|
171
|
+
declare function resolveStrategy(element: Element): UpdateSource | undefined;
|
|
172
|
+
|
|
173
|
+
/** Fragment boundaries: how a `data-payload-fragment` element is read and which ones an update touches. */
|
|
174
|
+
|
|
175
|
+
/** Distinguishes several boundaries of one registry id; unique among siblings. */
|
|
176
|
+
declare const FRAGMENT_KEY_ATTRIBUTE = "data-payload-fragment-key";
|
|
177
|
+
interface FragmentBoundary {
|
|
178
|
+
readonly element: Element;
|
|
179
|
+
/** Registry id — never a path, module or function name. */
|
|
180
|
+
readonly id: string;
|
|
181
|
+
readonly key: string | undefined;
|
|
182
|
+
/** Fields whose change re-renders the boundary; empty means any field. */
|
|
183
|
+
readonly dependsOn: readonly string[];
|
|
184
|
+
}
|
|
185
|
+
/** One revision's request to a per-boundary handler. */
|
|
186
|
+
interface StrategyRequest {
|
|
187
|
+
readonly revision: number;
|
|
188
|
+
readonly receivedAt: number;
|
|
189
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
190
|
+
readonly locale: string | undefined;
|
|
191
|
+
readonly collectionSlug: string | undefined;
|
|
192
|
+
readonly globalSlug: string | undefined;
|
|
193
|
+
/** Aborted when a newer revision arrives or the runtime stops. */
|
|
194
|
+
readonly signal: AbortSignal;
|
|
195
|
+
}
|
|
196
|
+
type FragmentOutcome = {
|
|
197
|
+
readonly status: 'rendered';
|
|
198
|
+
/** The boundary's new inner HTML. */
|
|
199
|
+
readonly html: string;
|
|
200
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
201
|
+
} | {
|
|
202
|
+
readonly status: 'failed';
|
|
203
|
+
readonly code: DiagnosticCode;
|
|
204
|
+
readonly reason: string;
|
|
205
|
+
} | {
|
|
206
|
+
readonly status: 'superseded';
|
|
207
|
+
};
|
|
208
|
+
/** Renders one boundary for one revision. Must honour `request.signal`. */
|
|
209
|
+
type FragmentHandler = (request: StrategyRequest, boundary: FragmentBoundary) => Promise<FragmentOutcome>;
|
|
210
|
+
declare function describeBoundary(element: Element): FragmentBoundary | null;
|
|
211
|
+
/** The boundaries under `root` that `changedFields` touch; one inside an island is the island's business. */
|
|
212
|
+
declare function collectFragmentBoundaries(root: ParentNode, changedFields: ReadonlySet<string>): readonly FragmentBoundary[];
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The HTTP handler behind `createFragmentStrategy()`: one POST per boundary and
|
|
216
|
+
* revision, shared, gated, timed out and size-bounded. Every failure is an
|
|
217
|
+
* `LP08xx` outcome, never an exception. See ADR 0011.
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
interface FragmentStrategyOptions {
|
|
221
|
+
/** Same-origin path of the fragment endpoint, e.g. `/payload/fragment`. */
|
|
222
|
+
readonly endpoint: string;
|
|
223
|
+
/** `fetch` to use; defaults to the global one. */
|
|
224
|
+
readonly fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
225
|
+
/** Per-request timeout. Default 5000 ms. */
|
|
226
|
+
readonly timeoutMs?: number;
|
|
227
|
+
/** Requests in flight at once; further boundaries wait. Default 4. */
|
|
228
|
+
readonly maxConcurrent?: number;
|
|
229
|
+
/** Largest response body accepted, in bytes. Default 512 KiB. */
|
|
230
|
+
readonly maxResponseBytes?: number;
|
|
231
|
+
/** Extra request headers, e.g. a CSRF token the site already uses. */
|
|
232
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
233
|
+
/** Where the page lives; defaults to `location`. */
|
|
234
|
+
readonly location?: {
|
|
235
|
+
readonly pathname: string;
|
|
236
|
+
readonly search: string;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
declare function createFragmentHandler(options: FragmentStrategyOptions): FragmentHandler;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* The route strategy: when a revision touches what no smaller strategy can
|
|
243
|
+
* render, fetch the route again and morph it in place. A refresh inside
|
|
244
|
+
* `minIntervalMs` is refused as LP0805. See ADR 0011.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
/** Sent with every refresh so a server can tell a preview refresh from navigation. */
|
|
248
|
+
declare const ROUTE_REFRESH_HEADER = "x-payload-live-preview";
|
|
249
|
+
interface RouteStrategyOptions {
|
|
250
|
+
/** `fetch` to use; defaults to the global one. */
|
|
251
|
+
readonly fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
252
|
+
/** Per-refresh timeout. Default 8000 ms. */
|
|
253
|
+
readonly timeoutMs?: number;
|
|
254
|
+
/** Shortest gap between two refreshes; one inside it is refused with LP0805. Default 1000 ms. */
|
|
255
|
+
readonly minIntervalMs?: number;
|
|
256
|
+
/** The document to refresh; defaults to `document`. */
|
|
257
|
+
readonly document?: Document;
|
|
258
|
+
/** Where the page lives; defaults to `location`. */
|
|
259
|
+
readonly location?: {
|
|
260
|
+
readonly href: string;
|
|
261
|
+
};
|
|
262
|
+
/** Scroll access; defaults to `window`. */
|
|
263
|
+
readonly window?: {
|
|
264
|
+
readonly scrollX: number;
|
|
265
|
+
readonly scrollY: number;
|
|
266
|
+
readonly scrollTo: (x: number, y: number) => void;
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/** An explicit `data-payload-strategy="route"`, or a binding in `<head>`. */
|
|
270
|
+
declare function isRouteBound(element: Element): boolean;
|
|
271
|
+
declare function createRouteStrategy(options?: RouteStrategyOptions): RouteStrategy;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The fragment wire protocol: what the browser posts to a fragment endpoint
|
|
275
|
+
* and what it answers. Both sides validate the shape; nothing on the wire
|
|
276
|
+
* names code, paths or templates. See ADR 0011.
|
|
277
|
+
*/
|
|
278
|
+
/** Bumped when the request or response shape changes incompatibly. */
|
|
279
|
+
declare const FRAGMENT_PROTOCOL_VERSION = 1;
|
|
280
|
+
declare const FRAGMENT_VERSION_HEADER = "x-payload-fragment-version";
|
|
281
|
+
interface FragmentRequestBody {
|
|
282
|
+
/** Registry id of the boundary (`data-payload-fragment`). */
|
|
283
|
+
readonly fragment: string;
|
|
284
|
+
/** `data-payload-fragment-key`, when several boundaries share one id. */
|
|
285
|
+
readonly key?: string;
|
|
286
|
+
/** The page route the boundary belongs to; authorization is bound to it. */
|
|
287
|
+
readonly route: string;
|
|
288
|
+
/** The page's query string, so a `previewToken` in the URL reaches the endpoint. */
|
|
289
|
+
readonly search: string;
|
|
290
|
+
readonly revision: number;
|
|
291
|
+
readonly locale?: string;
|
|
292
|
+
readonly collectionSlug?: string;
|
|
293
|
+
readonly globalSlug?: string;
|
|
294
|
+
/** The unsaved form state as the admin posted it, after the runtime's merge. */
|
|
295
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
296
|
+
}
|
|
297
|
+
interface FragmentResponseBody {
|
|
298
|
+
/** The boundary's new inner HTML. */
|
|
299
|
+
readonly html: string;
|
|
300
|
+
readonly boundary: {
|
|
301
|
+
readonly id: string;
|
|
302
|
+
readonly key?: string;
|
|
303
|
+
};
|
|
304
|
+
/** Echoes the request; the client discards a response for another revision. */
|
|
305
|
+
readonly revision: number;
|
|
306
|
+
readonly metadata: {
|
|
307
|
+
readonly renderedAt: string;
|
|
308
|
+
/** What rendered it, e.g. `astro-container`. */
|
|
309
|
+
readonly renderer: string;
|
|
310
|
+
readonly durationMs?: number;
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
/** Shape check for a request body; `null` when it is not one. */
|
|
314
|
+
declare function parseFragmentRequest(value: unknown): FragmentRequestBody | null;
|
|
315
|
+
/** Shape check for a response body; `null` when it is not one. */
|
|
316
|
+
declare function parseFragmentResponse(value: unknown): FragmentResponseBody | null;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* `payload-live-preview/fragment` — the fragment and route strategies. The
|
|
320
|
+
* core carries only the seam (`@core/strategies`); this entry owns the
|
|
321
|
+
* orchestration and never sends code, paths or templates. See ADR 0011.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* The strategy the runtime drives, built on a per-boundary handler: plan the
|
|
326
|
+
* boundaries, render each, morph a success, patch a failure. A late or
|
|
327
|
+
* aborted render is dropped, never applied.
|
|
328
|
+
*/
|
|
329
|
+
declare function fragmentStrategyFrom(handler: FragmentHandler): FragmentStrategy;
|
|
330
|
+
/** The strategy for a fragment endpoint: hand it to the runtime as `strategies.fragment`. */
|
|
331
|
+
declare function createFragmentStrategy(options: FragmentStrategyOptions): FragmentStrategy;
|
|
332
|
+
|
|
333
|
+
export { DIAGNOSTIC_CODES, type DiagnosticCode, FRAGMENT_ATTRIBUTE, FRAGMENT_KEY_ATTRIBUTE, FRAGMENT_PROTOCOL_VERSION, FRAGMENT_VERSION_HEADER, type FragmentBoundary, type FragmentContext, type FragmentHandler, type FragmentOutcome, type FragmentReport, type FragmentRequestBody, type FragmentResponseBody, type FragmentStrategy, type FragmentStrategyOptions, ROUTE_REFRESH_HEADER, type RouteContext, type RouteStrategy, type RouteStrategyOptions, type StrategyHandlers, type StrategyRequest, type UpdateSource, collectFragmentBoundaries, createFragmentHandler, createFragmentStrategy, createRouteStrategy, describeBoundary, fragmentStrategyFrom, isRouteBound, parseFragmentRequest, parseFragmentResponse, resolveStrategy };
|