payload-live-preview 2.1.2 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -62
- package/dist/adapters/astro/index.d.ts +7 -7
- 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 +3 -3
- 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 +2 -2
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +4 -4
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/nuxt/module.d.ts +1 -1
- package/dist/adapters/react/index.d.ts +2 -2
- package/dist/adapters/react/index.js +1 -1
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.d.ts +5 -5
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +2 -2
- package/dist/adapters/vue/index.js +1 -1
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/annotate.d.ts +22 -15
- package/dist/annotate.js +1 -1
- package/dist/annotate.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +114 -114
- package/dist/client.d.ts +114 -114
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- 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 +14 -16
- package/dist/codegen.d.ts +14 -16
- 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 +178 -172
- package/dist/core.d.ts +178 -172
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/doctor-cli.d.ts +1 -1
- package/dist/doctor-cli.js +1 -1
- package/dist/doctor-cli.js.map +1 -1
- package/dist/doctor.d.ts +15 -2
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/{document-session-DWi9H3Qk.d.ts → document-session-Bkd181PV.d.ts} +3 -2
- package/dist/{fragment-endpoint-B2qcRw5T.d.ts → fragment-endpoint-DGGLIijM.d.ts} +1 -1
- package/dist/fragment.cjs.map +1 -1
- package/dist/fragment.d.cts +3 -3
- package/dist/fragment.d.ts +3 -3
- package/dist/fragment.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +183 -177
- package/dist/index.d.ts +183 -177
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +1 -1
- package/dist/lean.cjs.map +1 -1
- package/dist/lean.js +1 -1
- package/dist/lean.js.map +1 -1
- package/dist/lexical.cjs +1 -1
- package/dist/lexical.cjs.map +1 -1
- package/dist/lexical.js +1 -1
- package/dist/lexical.js.map +1 -1
- package/dist/{locals-B1mF3aTb.d.ts → locals-zz2gi9dj.d.ts} +1 -1
- package/dist/{middleware-BGobLN9P.d.ts → middleware-CI-UTf6R.d.ts} +2 -2
- package/dist/{options-Cm8fC7dj.d.ts → options-CnYybG51.d.ts} +8 -0
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{probe-DGPDsnbj.d.ts → probe-D-IHg9dF.d.ts} +3 -3
- package/dist/structural.cjs +2 -2
- package/dist/structural.cjs.map +1 -1
- package/dist/structural.d.cts +27 -27
- package/dist/structural.d.ts +27 -27
- package/dist/structural.js +2 -2
- package/dist/structural.js.map +1 -1
- package/package.json +11 -6
package/dist/client.d.cts
CHANGED
|
@@ -87,11 +87,11 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
87
87
|
readonly AuditFrameOptionsBlocks: "LP0703";
|
|
88
88
|
/** Binding attributes are served to anonymous visitors. */
|
|
89
89
|
readonly AuditBindingsExposed: "LP0704";
|
|
90
|
-
/** More bindings than the
|
|
90
|
+
/** More bindings than the visibility gate will write eagerly. */
|
|
91
91
|
readonly AuditGateThresholdExceeded: "LP0705";
|
|
92
92
|
/** Owner markers exist, but some bindings are outside all of them. */
|
|
93
93
|
readonly AuditUnownedBindings: "LP0706";
|
|
94
|
-
/** The preview response carries no bindings
|
|
94
|
+
/** The preview response carries no bindings and no fragment boundary. */
|
|
95
95
|
readonly AuditNoBindings: "LP0707";
|
|
96
96
|
/** The URL did not return an HTML page, so nothing else can be judged. */
|
|
97
97
|
readonly AuditNotAPage: "LP0708";
|
|
@@ -109,7 +109,7 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
109
109
|
readonly FragmentStrategyUnavailable: "LP0806";
|
|
110
110
|
/** A revision changed a field with no binding; `onUnfaithfulPatch` refreshed the route. */
|
|
111
111
|
readonly UnboundChangeRefresh: "LP0807";
|
|
112
|
-
/** `onUnfaithfulPatch: 'escalate'` found no route or fragment strategy to hand an unfaithful patch to; the page keeps it. */
|
|
112
|
+
/** `onUnfaithfulPatch: 'escalate'` found no route or fragment strategy, or no boundary, to hand an unfaithful patch to; the page keeps it. */
|
|
113
113
|
readonly EscalationUnavailable: "LP0808";
|
|
114
114
|
/** A fragment inserted an Astro island the page cannot start: it never loaded the island element or that client directive. */
|
|
115
115
|
readonly IslandStartUnavailable: "LP0809";
|
|
@@ -165,6 +165,116 @@ type PayloadFieldType = 'text' | 'textarea' | 'richText' | 'email' | 'number' |
|
|
|
165
165
|
/** `admin.condition` is a function in source and cannot cross `postMessage`; modelled, not consumed. */
|
|
166
166
|
type PayloadFieldCondition = (data: unknown, siblingData: unknown) => boolean;
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* `'strict'` (default) strips `id`, `name` and `data-payload-*` and passes
|
|
170
|
+
* other `data-*` only via `allowedDataAttributes`; `'compat'` keeps them.
|
|
171
|
+
*/
|
|
172
|
+
type SanitizerPolicyMode = 'compat' | 'strict';
|
|
173
|
+
|
|
174
|
+
/** Types shared by the runtime primitives. */
|
|
175
|
+
|
|
176
|
+
/** Payload's field set plus the DOM-binding categories `html`, `url`, `image` and `structural-array`. */
|
|
177
|
+
type FieldType = PayloadFieldType | 'html' | 'url' | 'image' | 'structural-array';
|
|
178
|
+
/** A namespaced project renderer key, so a typo of a built-in type can never become one. */
|
|
179
|
+
type CustomRendererKey = `${string}:${string}`;
|
|
180
|
+
/** What a renderer may be registered under and an element may ask for. */
|
|
181
|
+
type RendererKey = FieldType | CustomRendererKey;
|
|
182
|
+
/**
|
|
183
|
+
* A project rich-text renderer, shared by SSR and preview. Its output goes
|
|
184
|
+
* through the sanitizer; call the same `sanitizeHtml()` server-side for byte equality.
|
|
185
|
+
*/
|
|
186
|
+
type RichTextRenderer = (value: unknown, context: {
|
|
187
|
+
readonly fieldName: string;
|
|
188
|
+
readonly element: Element;
|
|
189
|
+
readonly locale: string | undefined;
|
|
190
|
+
}) => string;
|
|
191
|
+
/** One registered binding. Several may share a field name when it renders in several places. */
|
|
192
|
+
interface CachedElement {
|
|
193
|
+
/** The bound DOM element. */
|
|
194
|
+
readonly element: Element;
|
|
195
|
+
/** Payload field path, e.g., `title` or `hero.subtitle`. */
|
|
196
|
+
readonly fieldName: string;
|
|
197
|
+
/** Resolved from attributes and tag heuristics; the schema may override it unless explicit. */
|
|
198
|
+
readonly fieldType: RendererKey;
|
|
199
|
+
/** Whether `data-payload-type` set the type, in which case the schema must not override it. */
|
|
200
|
+
readonly explicitFieldType?: boolean;
|
|
201
|
+
/** Fields this binding depends on (`data-payload-depends`); a change in any re-applies it under `skipUnchanged`. */
|
|
202
|
+
readonly dependsOn?: readonly string[];
|
|
203
|
+
/** Raw `data-payload-strategy` value. */
|
|
204
|
+
readonly strategy?: string;
|
|
205
|
+
/** How the runtime brings this binding up to date; `'unknown'` for an unrecognised strategy. Resolved by the cache. */
|
|
206
|
+
readonly strategyKind?: UpdateSource | 'unknown';
|
|
207
|
+
/** Nearest enclosing `data-payload-fragment` boundary. Resolved by the cache. */
|
|
208
|
+
readonly fragmentBoundary?: Element;
|
|
209
|
+
/** `data-payload-boundary`: an anchor that hides itself while its field is empty. */
|
|
210
|
+
readonly hidesWhenEmpty?: boolean;
|
|
211
|
+
/** Write the value into this attribute instead of the content; policed writes. */
|
|
212
|
+
readonly targetAttribute?: string;
|
|
213
|
+
/** Optional sibling-field path bound to the element's `href` attribute. */
|
|
214
|
+
readonly hrefField?: string;
|
|
215
|
+
/** Optional sibling-field path bound to the element's `src` attribute. */
|
|
216
|
+
readonly srcField?: string;
|
|
217
|
+
/** Optional sibling-field path bound to the element's `alt` attribute. */
|
|
218
|
+
readonly altField?: string;
|
|
219
|
+
/** Optional inline template for array/blocks rendering. */
|
|
220
|
+
readonly arrayTemplate?: string;
|
|
221
|
+
/** Optional separator for primitive-array stringification. */
|
|
222
|
+
readonly arraySeparator?: string;
|
|
223
|
+
/** Optional locale code locked onto this element (overrides the global locale). */
|
|
224
|
+
readonly locale?: string;
|
|
225
|
+
/** Raw `data-payload-format`; the date and number renderers read the vocabulary. */
|
|
226
|
+
readonly format?: string;
|
|
227
|
+
/** The document this binding belongs to, from the nearest `data-payload-owner`. */
|
|
228
|
+
readonly owner?: string;
|
|
229
|
+
/**
|
|
230
|
+
* The value an auto-binding matched on (`data-payload-guessed`), for a
|
|
231
|
+
* binding the runtime found by value rather than one the template declared.
|
|
232
|
+
* Absent for a declared binding.
|
|
233
|
+
*/
|
|
234
|
+
readonly guessed?: string;
|
|
235
|
+
}
|
|
236
|
+
/** What a renderer is given; `allFields` lets it resolve a sibling field. */
|
|
237
|
+
interface RenderContext {
|
|
238
|
+
/** Full field map for the current update — used for sibling lookups. */
|
|
239
|
+
readonly allFields: Record<string, unknown>;
|
|
240
|
+
/** Active locale, or `undefined` when none is established. */
|
|
241
|
+
readonly locale: string | undefined;
|
|
242
|
+
/** Optional schema descriptor for the field, when available. */
|
|
243
|
+
readonly schema: PayloadFieldSchema | undefined;
|
|
244
|
+
/** The project's rich-text renderer, when the client was configured with one. */
|
|
245
|
+
readonly renderRichText?: RichTextRenderer;
|
|
246
|
+
/**
|
|
247
|
+
* The Payload server the runtime reads populated documents from (`serverURL`),
|
|
248
|
+
* absent without one. A renderer that writes a URL out of a media document
|
|
249
|
+
* resolves a path against it, as Payload's admin does; the built-in `upload`
|
|
250
|
+
* and `image` renderers do.
|
|
251
|
+
*/
|
|
252
|
+
readonly serverURL?: string;
|
|
253
|
+
/**
|
|
254
|
+
* This instance's sanitizer policy, for every HTML write the renderer makes.
|
|
255
|
+
* Absent, the process default set by `setSanitizerPolicy()` applies.
|
|
256
|
+
*/
|
|
257
|
+
readonly sanitizerPolicy?: SanitizerPolicyMode;
|
|
258
|
+
/**
|
|
259
|
+
* Say that this write cannot reproduce what the server drew, so
|
|
260
|
+
* `onUnfaithfulPatch` can have a strategy render the region instead of
|
|
261
|
+
* leaving a degraded patch on the page. The built-in rich-text renderer
|
|
262
|
+
* calls it for a Lexical block whose markup it had to drop; a project
|
|
263
|
+
* renderer may call it for any value it can only approximate. `reason`
|
|
264
|
+
* completes the sentence 'field "x" …' in LP0411.
|
|
265
|
+
*/
|
|
266
|
+
readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A renderer writes one value into its element. It must not throw: one bad
|
|
270
|
+
* field may not stop an update. The result stays `void` — the internal
|
|
271
|
+
* no-write sentinel is not part of the contract.
|
|
272
|
+
*/
|
|
273
|
+
interface FieldRenderer {
|
|
274
|
+
readonly name: RendererKey;
|
|
275
|
+
render(target: CachedElement, value: unknown, context: RenderContext): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
168
278
|
/**
|
|
169
279
|
* How a bound region is brought up to date: the runtime patches it, a server
|
|
170
280
|
* renders a `data-payload-fragment` boundary from the unsaved form state, or
|
|
@@ -391,116 +501,6 @@ declare class EventEmitter<TMap extends object = LivePreviewEventMap> {
|
|
|
391
501
|
eventNames(): (keyof TMap)[];
|
|
392
502
|
}
|
|
393
503
|
|
|
394
|
-
/**
|
|
395
|
-
* `'strict'` (default) strips `id`, `name` and `data-payload-*` and passes
|
|
396
|
-
* other `data-*` only via `allowedDataAttributes`; `'compat'` keeps them.
|
|
397
|
-
*/
|
|
398
|
-
type SanitizerPolicyMode = 'compat' | 'strict';
|
|
399
|
-
|
|
400
|
-
/** Types shared by the runtime primitives. */
|
|
401
|
-
|
|
402
|
-
/** Payload's field set plus the DOM-binding categories `html`, `url`, `image` and `structural-array`. */
|
|
403
|
-
type FieldType = PayloadFieldType | 'html' | 'url' | 'image' | 'structural-array';
|
|
404
|
-
/** A namespaced project renderer key, so a typo of a built-in type can never become one. */
|
|
405
|
-
type CustomRendererKey = `${string}:${string}`;
|
|
406
|
-
/** What a renderer may be registered under and an element may ask for. */
|
|
407
|
-
type RendererKey = FieldType | CustomRendererKey;
|
|
408
|
-
/**
|
|
409
|
-
* A project rich-text renderer, shared by SSR and preview. Its output goes
|
|
410
|
-
* through the sanitizer; call the same `sanitizeHtml()` server-side for byte equality.
|
|
411
|
-
*/
|
|
412
|
-
type RichTextRenderer = (value: unknown, context: {
|
|
413
|
-
readonly fieldName: string;
|
|
414
|
-
readonly element: Element;
|
|
415
|
-
readonly locale: string | undefined;
|
|
416
|
-
}) => string;
|
|
417
|
-
/** One registered binding. Several may share a field name when it renders in several places. */
|
|
418
|
-
interface CachedElement {
|
|
419
|
-
/** The bound DOM element. */
|
|
420
|
-
readonly element: Element;
|
|
421
|
-
/** Payload field path, e.g., `title` or `hero.subtitle`. */
|
|
422
|
-
readonly fieldName: string;
|
|
423
|
-
/** Resolved from attributes and tag heuristics; the schema may override it unless explicit. */
|
|
424
|
-
readonly fieldType: RendererKey;
|
|
425
|
-
/** Whether `data-payload-type` set the type, in which case the schema must not override it. */
|
|
426
|
-
readonly explicitFieldType?: boolean;
|
|
427
|
-
/** Fields this binding depends on (`data-payload-depends`); a change in any re-applies it under `skipUnchanged`. */
|
|
428
|
-
readonly dependsOn?: readonly string[];
|
|
429
|
-
/** Raw `data-payload-strategy` value. */
|
|
430
|
-
readonly strategy?: string;
|
|
431
|
-
/** How the runtime brings this binding up to date; `'unknown'` for an unrecognised strategy. Resolved by the cache. */
|
|
432
|
-
readonly strategyKind?: UpdateSource | 'unknown';
|
|
433
|
-
/** Nearest enclosing `data-payload-fragment` boundary. Resolved by the cache. */
|
|
434
|
-
readonly fragmentBoundary?: Element;
|
|
435
|
-
/** `data-payload-boundary`: an anchor that hides itself while its field is empty. */
|
|
436
|
-
readonly hidesWhenEmpty?: boolean;
|
|
437
|
-
/** Write the value into this attribute instead of the content; policed writes. */
|
|
438
|
-
readonly targetAttribute?: string;
|
|
439
|
-
/** Optional sibling-field path bound to the element's `href` attribute. */
|
|
440
|
-
readonly hrefField?: string;
|
|
441
|
-
/** Optional sibling-field path bound to the element's `src` attribute. */
|
|
442
|
-
readonly srcField?: string;
|
|
443
|
-
/** Optional sibling-field path bound to the element's `alt` attribute. */
|
|
444
|
-
readonly altField?: string;
|
|
445
|
-
/** Optional inline template for array/blocks rendering. */
|
|
446
|
-
readonly arrayTemplate?: string;
|
|
447
|
-
/** Optional separator for primitive-array stringification. */
|
|
448
|
-
readonly arraySeparator?: string;
|
|
449
|
-
/** Optional locale code locked onto this element (overrides the global locale). */
|
|
450
|
-
readonly locale?: string;
|
|
451
|
-
/** Raw `data-payload-format`; the date and number renderers read the vocabulary. */
|
|
452
|
-
readonly format?: string;
|
|
453
|
-
/** The document this binding belongs to, from the nearest `data-payload-owner`. */
|
|
454
|
-
readonly owner?: string;
|
|
455
|
-
/**
|
|
456
|
-
* The value an auto-binding matched on (`data-payload-guessed`), for a
|
|
457
|
-
* binding the runtime found by value rather than one the template declared.
|
|
458
|
-
* Absent for a declared binding.
|
|
459
|
-
*/
|
|
460
|
-
readonly guessed?: string;
|
|
461
|
-
}
|
|
462
|
-
/** What a renderer is given; `allFields` lets it resolve a sibling field. */
|
|
463
|
-
interface RenderContext {
|
|
464
|
-
/** Full field map for the current update — used for sibling lookups. */
|
|
465
|
-
readonly allFields: Record<string, unknown>;
|
|
466
|
-
/** Active locale, or `undefined` when none is established. */
|
|
467
|
-
readonly locale: string | undefined;
|
|
468
|
-
/** Optional schema descriptor for the field, when available. */
|
|
469
|
-
readonly schema: PayloadFieldSchema | undefined;
|
|
470
|
-
/** The project's rich-text renderer, when the client was configured with one. */
|
|
471
|
-
readonly renderRichText?: RichTextRenderer;
|
|
472
|
-
/**
|
|
473
|
-
* The Payload server the runtime reads populated documents from (`serverURL`),
|
|
474
|
-
* absent without one. A renderer that writes a URL out of a media document
|
|
475
|
-
* resolves a path against it, as Payload's admin does; the built-in `upload`
|
|
476
|
-
* and `image` renderers do.
|
|
477
|
-
*/
|
|
478
|
-
readonly serverURL?: string;
|
|
479
|
-
/**
|
|
480
|
-
* This instance's sanitizer policy, for every HTML write the renderer makes.
|
|
481
|
-
* Absent, the process default set by `setSanitizerPolicy()` applies.
|
|
482
|
-
*/
|
|
483
|
-
readonly sanitizerPolicy?: SanitizerPolicyMode;
|
|
484
|
-
/**
|
|
485
|
-
* Say that this write cannot reproduce what the server drew, so
|
|
486
|
-
* `onUnfaithfulPatch` can have a strategy render the region instead of
|
|
487
|
-
* leaving a degraded patch on the page. The built-in rich-text renderer
|
|
488
|
-
* calls it for a Lexical block whose markup it had to drop; a project
|
|
489
|
-
* renderer may call it for any value it can only approximate. `reason`
|
|
490
|
-
* completes the sentence 'field "x" …' in LP0411.
|
|
491
|
-
*/
|
|
492
|
-
readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* A renderer writes one value into its element. It must not throw: one bad
|
|
496
|
-
* field may not stop an update. The result stays `void` — the internal
|
|
497
|
-
* no-write sentinel is not part of the contract.
|
|
498
|
-
*/
|
|
499
|
-
interface FieldRenderer {
|
|
500
|
-
readonly name: RendererKey;
|
|
501
|
-
render(target: CachedElement, value: unknown, context: RenderContext): void;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
504
|
/** Connection status and the heartbeat that decides a disconnect. */
|
|
505
505
|
type ConnectionStatus = 'disconnected' | 'connecting' | 'connected';
|
|
506
506
|
|
|
@@ -720,7 +720,7 @@ interface InspectionFidelity {
|
|
|
720
720
|
readonly canEscalate: boolean;
|
|
721
721
|
/** Bindings reported unfaithful since start — once per element, like LP0411, and under every mode. */
|
|
722
722
|
readonly unfaithful: number;
|
|
723
|
-
/**
|
|
723
|
+
/** How many times one of those was handed to the fragment or route strategy; a later edit hands it again. */
|
|
724
724
|
readonly escalated: number;
|
|
725
725
|
/** The field names behind `unfaithful`, sorted. Cumulative. */
|
|
726
726
|
readonly fields: readonly string[];
|
package/dist/client.d.ts
CHANGED
|
@@ -87,11 +87,11 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
87
87
|
readonly AuditFrameOptionsBlocks: "LP0703";
|
|
88
88
|
/** Binding attributes are served to anonymous visitors. */
|
|
89
89
|
readonly AuditBindingsExposed: "LP0704";
|
|
90
|
-
/** More bindings than the
|
|
90
|
+
/** More bindings than the visibility gate will write eagerly. */
|
|
91
91
|
readonly AuditGateThresholdExceeded: "LP0705";
|
|
92
92
|
/** Owner markers exist, but some bindings are outside all of them. */
|
|
93
93
|
readonly AuditUnownedBindings: "LP0706";
|
|
94
|
-
/** The preview response carries no bindings
|
|
94
|
+
/** The preview response carries no bindings and no fragment boundary. */
|
|
95
95
|
readonly AuditNoBindings: "LP0707";
|
|
96
96
|
/** The URL did not return an HTML page, so nothing else can be judged. */
|
|
97
97
|
readonly AuditNotAPage: "LP0708";
|
|
@@ -109,7 +109,7 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
109
109
|
readonly FragmentStrategyUnavailable: "LP0806";
|
|
110
110
|
/** A revision changed a field with no binding; `onUnfaithfulPatch` refreshed the route. */
|
|
111
111
|
readonly UnboundChangeRefresh: "LP0807";
|
|
112
|
-
/** `onUnfaithfulPatch: 'escalate'` found no route or fragment strategy to hand an unfaithful patch to; the page keeps it. */
|
|
112
|
+
/** `onUnfaithfulPatch: 'escalate'` found no route or fragment strategy, or no boundary, to hand an unfaithful patch to; the page keeps it. */
|
|
113
113
|
readonly EscalationUnavailable: "LP0808";
|
|
114
114
|
/** A fragment inserted an Astro island the page cannot start: it never loaded the island element or that client directive. */
|
|
115
115
|
readonly IslandStartUnavailable: "LP0809";
|
|
@@ -165,6 +165,116 @@ type PayloadFieldType = 'text' | 'textarea' | 'richText' | 'email' | 'number' |
|
|
|
165
165
|
/** `admin.condition` is a function in source and cannot cross `postMessage`; modelled, not consumed. */
|
|
166
166
|
type PayloadFieldCondition = (data: unknown, siblingData: unknown) => boolean;
|
|
167
167
|
|
|
168
|
+
/**
|
|
169
|
+
* `'strict'` (default) strips `id`, `name` and `data-payload-*` and passes
|
|
170
|
+
* other `data-*` only via `allowedDataAttributes`; `'compat'` keeps them.
|
|
171
|
+
*/
|
|
172
|
+
type SanitizerPolicyMode = 'compat' | 'strict';
|
|
173
|
+
|
|
174
|
+
/** Types shared by the runtime primitives. */
|
|
175
|
+
|
|
176
|
+
/** Payload's field set plus the DOM-binding categories `html`, `url`, `image` and `structural-array`. */
|
|
177
|
+
type FieldType = PayloadFieldType | 'html' | 'url' | 'image' | 'structural-array';
|
|
178
|
+
/** A namespaced project renderer key, so a typo of a built-in type can never become one. */
|
|
179
|
+
type CustomRendererKey = `${string}:${string}`;
|
|
180
|
+
/** What a renderer may be registered under and an element may ask for. */
|
|
181
|
+
type RendererKey = FieldType | CustomRendererKey;
|
|
182
|
+
/**
|
|
183
|
+
* A project rich-text renderer, shared by SSR and preview. Its output goes
|
|
184
|
+
* through the sanitizer; call the same `sanitizeHtml()` server-side for byte equality.
|
|
185
|
+
*/
|
|
186
|
+
type RichTextRenderer = (value: unknown, context: {
|
|
187
|
+
readonly fieldName: string;
|
|
188
|
+
readonly element: Element;
|
|
189
|
+
readonly locale: string | undefined;
|
|
190
|
+
}) => string;
|
|
191
|
+
/** One registered binding. Several may share a field name when it renders in several places. */
|
|
192
|
+
interface CachedElement {
|
|
193
|
+
/** The bound DOM element. */
|
|
194
|
+
readonly element: Element;
|
|
195
|
+
/** Payload field path, e.g., `title` or `hero.subtitle`. */
|
|
196
|
+
readonly fieldName: string;
|
|
197
|
+
/** Resolved from attributes and tag heuristics; the schema may override it unless explicit. */
|
|
198
|
+
readonly fieldType: RendererKey;
|
|
199
|
+
/** Whether `data-payload-type` set the type, in which case the schema must not override it. */
|
|
200
|
+
readonly explicitFieldType?: boolean;
|
|
201
|
+
/** Fields this binding depends on (`data-payload-depends`); a change in any re-applies it under `skipUnchanged`. */
|
|
202
|
+
readonly dependsOn?: readonly string[];
|
|
203
|
+
/** Raw `data-payload-strategy` value. */
|
|
204
|
+
readonly strategy?: string;
|
|
205
|
+
/** How the runtime brings this binding up to date; `'unknown'` for an unrecognised strategy. Resolved by the cache. */
|
|
206
|
+
readonly strategyKind?: UpdateSource | 'unknown';
|
|
207
|
+
/** Nearest enclosing `data-payload-fragment` boundary. Resolved by the cache. */
|
|
208
|
+
readonly fragmentBoundary?: Element;
|
|
209
|
+
/** `data-payload-boundary`: an anchor that hides itself while its field is empty. */
|
|
210
|
+
readonly hidesWhenEmpty?: boolean;
|
|
211
|
+
/** Write the value into this attribute instead of the content; policed writes. */
|
|
212
|
+
readonly targetAttribute?: string;
|
|
213
|
+
/** Optional sibling-field path bound to the element's `href` attribute. */
|
|
214
|
+
readonly hrefField?: string;
|
|
215
|
+
/** Optional sibling-field path bound to the element's `src` attribute. */
|
|
216
|
+
readonly srcField?: string;
|
|
217
|
+
/** Optional sibling-field path bound to the element's `alt` attribute. */
|
|
218
|
+
readonly altField?: string;
|
|
219
|
+
/** Optional inline template for array/blocks rendering. */
|
|
220
|
+
readonly arrayTemplate?: string;
|
|
221
|
+
/** Optional separator for primitive-array stringification. */
|
|
222
|
+
readonly arraySeparator?: string;
|
|
223
|
+
/** Optional locale code locked onto this element (overrides the global locale). */
|
|
224
|
+
readonly locale?: string;
|
|
225
|
+
/** Raw `data-payload-format`; the date and number renderers read the vocabulary. */
|
|
226
|
+
readonly format?: string;
|
|
227
|
+
/** The document this binding belongs to, from the nearest `data-payload-owner`. */
|
|
228
|
+
readonly owner?: string;
|
|
229
|
+
/**
|
|
230
|
+
* The value an auto-binding matched on (`data-payload-guessed`), for a
|
|
231
|
+
* binding the runtime found by value rather than one the template declared.
|
|
232
|
+
* Absent for a declared binding.
|
|
233
|
+
*/
|
|
234
|
+
readonly guessed?: string;
|
|
235
|
+
}
|
|
236
|
+
/** What a renderer is given; `allFields` lets it resolve a sibling field. */
|
|
237
|
+
interface RenderContext {
|
|
238
|
+
/** Full field map for the current update — used for sibling lookups. */
|
|
239
|
+
readonly allFields: Record<string, unknown>;
|
|
240
|
+
/** Active locale, or `undefined` when none is established. */
|
|
241
|
+
readonly locale: string | undefined;
|
|
242
|
+
/** Optional schema descriptor for the field, when available. */
|
|
243
|
+
readonly schema: PayloadFieldSchema | undefined;
|
|
244
|
+
/** The project's rich-text renderer, when the client was configured with one. */
|
|
245
|
+
readonly renderRichText?: RichTextRenderer;
|
|
246
|
+
/**
|
|
247
|
+
* The Payload server the runtime reads populated documents from (`serverURL`),
|
|
248
|
+
* absent without one. A renderer that writes a URL out of a media document
|
|
249
|
+
* resolves a path against it, as Payload's admin does; the built-in `upload`
|
|
250
|
+
* and `image` renderers do.
|
|
251
|
+
*/
|
|
252
|
+
readonly serverURL?: string;
|
|
253
|
+
/**
|
|
254
|
+
* This instance's sanitizer policy, for every HTML write the renderer makes.
|
|
255
|
+
* Absent, the process default set by `setSanitizerPolicy()` applies.
|
|
256
|
+
*/
|
|
257
|
+
readonly sanitizerPolicy?: SanitizerPolicyMode;
|
|
258
|
+
/**
|
|
259
|
+
* Say that this write cannot reproduce what the server drew, so
|
|
260
|
+
* `onUnfaithfulPatch` can have a strategy render the region instead of
|
|
261
|
+
* leaving a degraded patch on the page. The built-in rich-text renderer
|
|
262
|
+
* calls it for a Lexical block whose markup it had to drop; a project
|
|
263
|
+
* renderer may call it for any value it can only approximate. `reason`
|
|
264
|
+
* completes the sentence 'field "x" …' in LP0411.
|
|
265
|
+
*/
|
|
266
|
+
readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* A renderer writes one value into its element. It must not throw: one bad
|
|
270
|
+
* field may not stop an update. The result stays `void` — the internal
|
|
271
|
+
* no-write sentinel is not part of the contract.
|
|
272
|
+
*/
|
|
273
|
+
interface FieldRenderer {
|
|
274
|
+
readonly name: RendererKey;
|
|
275
|
+
render(target: CachedElement, value: unknown, context: RenderContext): void;
|
|
276
|
+
}
|
|
277
|
+
|
|
168
278
|
/**
|
|
169
279
|
* How a bound region is brought up to date: the runtime patches it, a server
|
|
170
280
|
* renders a `data-payload-fragment` boundary from the unsaved form state, or
|
|
@@ -391,116 +501,6 @@ declare class EventEmitter<TMap extends object = LivePreviewEventMap> {
|
|
|
391
501
|
eventNames(): (keyof TMap)[];
|
|
392
502
|
}
|
|
393
503
|
|
|
394
|
-
/**
|
|
395
|
-
* `'strict'` (default) strips `id`, `name` and `data-payload-*` and passes
|
|
396
|
-
* other `data-*` only via `allowedDataAttributes`; `'compat'` keeps them.
|
|
397
|
-
*/
|
|
398
|
-
type SanitizerPolicyMode = 'compat' | 'strict';
|
|
399
|
-
|
|
400
|
-
/** Types shared by the runtime primitives. */
|
|
401
|
-
|
|
402
|
-
/** Payload's field set plus the DOM-binding categories `html`, `url`, `image` and `structural-array`. */
|
|
403
|
-
type FieldType = PayloadFieldType | 'html' | 'url' | 'image' | 'structural-array';
|
|
404
|
-
/** A namespaced project renderer key, so a typo of a built-in type can never become one. */
|
|
405
|
-
type CustomRendererKey = `${string}:${string}`;
|
|
406
|
-
/** What a renderer may be registered under and an element may ask for. */
|
|
407
|
-
type RendererKey = FieldType | CustomRendererKey;
|
|
408
|
-
/**
|
|
409
|
-
* A project rich-text renderer, shared by SSR and preview. Its output goes
|
|
410
|
-
* through the sanitizer; call the same `sanitizeHtml()` server-side for byte equality.
|
|
411
|
-
*/
|
|
412
|
-
type RichTextRenderer = (value: unknown, context: {
|
|
413
|
-
readonly fieldName: string;
|
|
414
|
-
readonly element: Element;
|
|
415
|
-
readonly locale: string | undefined;
|
|
416
|
-
}) => string;
|
|
417
|
-
/** One registered binding. Several may share a field name when it renders in several places. */
|
|
418
|
-
interface CachedElement {
|
|
419
|
-
/** The bound DOM element. */
|
|
420
|
-
readonly element: Element;
|
|
421
|
-
/** Payload field path, e.g., `title` or `hero.subtitle`. */
|
|
422
|
-
readonly fieldName: string;
|
|
423
|
-
/** Resolved from attributes and tag heuristics; the schema may override it unless explicit. */
|
|
424
|
-
readonly fieldType: RendererKey;
|
|
425
|
-
/** Whether `data-payload-type` set the type, in which case the schema must not override it. */
|
|
426
|
-
readonly explicitFieldType?: boolean;
|
|
427
|
-
/** Fields this binding depends on (`data-payload-depends`); a change in any re-applies it under `skipUnchanged`. */
|
|
428
|
-
readonly dependsOn?: readonly string[];
|
|
429
|
-
/** Raw `data-payload-strategy` value. */
|
|
430
|
-
readonly strategy?: string;
|
|
431
|
-
/** How the runtime brings this binding up to date; `'unknown'` for an unrecognised strategy. Resolved by the cache. */
|
|
432
|
-
readonly strategyKind?: UpdateSource | 'unknown';
|
|
433
|
-
/** Nearest enclosing `data-payload-fragment` boundary. Resolved by the cache. */
|
|
434
|
-
readonly fragmentBoundary?: Element;
|
|
435
|
-
/** `data-payload-boundary`: an anchor that hides itself while its field is empty. */
|
|
436
|
-
readonly hidesWhenEmpty?: boolean;
|
|
437
|
-
/** Write the value into this attribute instead of the content; policed writes. */
|
|
438
|
-
readonly targetAttribute?: string;
|
|
439
|
-
/** Optional sibling-field path bound to the element's `href` attribute. */
|
|
440
|
-
readonly hrefField?: string;
|
|
441
|
-
/** Optional sibling-field path bound to the element's `src` attribute. */
|
|
442
|
-
readonly srcField?: string;
|
|
443
|
-
/** Optional sibling-field path bound to the element's `alt` attribute. */
|
|
444
|
-
readonly altField?: string;
|
|
445
|
-
/** Optional inline template for array/blocks rendering. */
|
|
446
|
-
readonly arrayTemplate?: string;
|
|
447
|
-
/** Optional separator for primitive-array stringification. */
|
|
448
|
-
readonly arraySeparator?: string;
|
|
449
|
-
/** Optional locale code locked onto this element (overrides the global locale). */
|
|
450
|
-
readonly locale?: string;
|
|
451
|
-
/** Raw `data-payload-format`; the date and number renderers read the vocabulary. */
|
|
452
|
-
readonly format?: string;
|
|
453
|
-
/** The document this binding belongs to, from the nearest `data-payload-owner`. */
|
|
454
|
-
readonly owner?: string;
|
|
455
|
-
/**
|
|
456
|
-
* The value an auto-binding matched on (`data-payload-guessed`), for a
|
|
457
|
-
* binding the runtime found by value rather than one the template declared.
|
|
458
|
-
* Absent for a declared binding.
|
|
459
|
-
*/
|
|
460
|
-
readonly guessed?: string;
|
|
461
|
-
}
|
|
462
|
-
/** What a renderer is given; `allFields` lets it resolve a sibling field. */
|
|
463
|
-
interface RenderContext {
|
|
464
|
-
/** Full field map for the current update — used for sibling lookups. */
|
|
465
|
-
readonly allFields: Record<string, unknown>;
|
|
466
|
-
/** Active locale, or `undefined` when none is established. */
|
|
467
|
-
readonly locale: string | undefined;
|
|
468
|
-
/** Optional schema descriptor for the field, when available. */
|
|
469
|
-
readonly schema: PayloadFieldSchema | undefined;
|
|
470
|
-
/** The project's rich-text renderer, when the client was configured with one. */
|
|
471
|
-
readonly renderRichText?: RichTextRenderer;
|
|
472
|
-
/**
|
|
473
|
-
* The Payload server the runtime reads populated documents from (`serverURL`),
|
|
474
|
-
* absent without one. A renderer that writes a URL out of a media document
|
|
475
|
-
* resolves a path against it, as Payload's admin does; the built-in `upload`
|
|
476
|
-
* and `image` renderers do.
|
|
477
|
-
*/
|
|
478
|
-
readonly serverURL?: string;
|
|
479
|
-
/**
|
|
480
|
-
* This instance's sanitizer policy, for every HTML write the renderer makes.
|
|
481
|
-
* Absent, the process default set by `setSanitizerPolicy()` applies.
|
|
482
|
-
*/
|
|
483
|
-
readonly sanitizerPolicy?: SanitizerPolicyMode;
|
|
484
|
-
/**
|
|
485
|
-
* Say that this write cannot reproduce what the server drew, so
|
|
486
|
-
* `onUnfaithfulPatch` can have a strategy render the region instead of
|
|
487
|
-
* leaving a degraded patch on the page. The built-in rich-text renderer
|
|
488
|
-
* calls it for a Lexical block whose markup it had to drop; a project
|
|
489
|
-
* renderer may call it for any value it can only approximate. `reason`
|
|
490
|
-
* completes the sentence 'field "x" …' in LP0411.
|
|
491
|
-
*/
|
|
492
|
-
readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* A renderer writes one value into its element. It must not throw: one bad
|
|
496
|
-
* field may not stop an update. The result stays `void` — the internal
|
|
497
|
-
* no-write sentinel is not part of the contract.
|
|
498
|
-
*/
|
|
499
|
-
interface FieldRenderer {
|
|
500
|
-
readonly name: RendererKey;
|
|
501
|
-
render(target: CachedElement, value: unknown, context: RenderContext): void;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
504
|
/** Connection status and the heartbeat that decides a disconnect. */
|
|
505
505
|
type ConnectionStatus = 'disconnected' | 'connecting' | 'connected';
|
|
506
506
|
|
|
@@ -720,7 +720,7 @@ interface InspectionFidelity {
|
|
|
720
720
|
readonly canEscalate: boolean;
|
|
721
721
|
/** Bindings reported unfaithful since start — once per element, like LP0411, and under every mode. */
|
|
722
722
|
readonly unfaithful: number;
|
|
723
|
-
/**
|
|
723
|
+
/** How many times one of those was handed to the fragment or route strategy; a later edit hands it again. */
|
|
724
724
|
readonly escalated: number;
|
|
725
725
|
/** The field names behind `unfaithful`, sorted. Cumulative. */
|
|
726
726
|
readonly fields: readonly string[];
|