payload-live-preview 2.0.0-beta.0 → 2.0.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 +60 -775
- package/dist/adapters/astro/PreviewBoundary.astro +2 -2
- package/dist/adapters/astro/index.d.ts +28 -154
- 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 -2
- 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 +247 -6
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.d.ts +58 -3
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/nuxt/module.d.ts +82 -0
- package/dist/adapters/nuxt/module.js +2 -0
- package/dist/adapters/nuxt/module.js.map +1 -0
- package/dist/adapters/react/index.d.ts +110 -0
- package/dist/adapters/react/index.js +3 -0
- package/dist/adapters/react/index.js.map +1 -0
- package/dist/adapters/sveltekit/index.d.ts +65 -7
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/adapters/vue/index.d.ts +56 -0
- package/dist/adapters/vue/index.js +2 -0
- package/dist/adapters/vue/index.js.map +1 -0
- package/dist/annotate.d.ts +161 -0
- package/dist/annotate.js +2 -0
- package/dist/annotate.js.map +1 -0
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +182 -9
- package/dist/client.d.ts +182 -9
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/codegen-astro.js +1 -1
- package/dist/codegen-astro.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 +129 -4
- package/dist/codegen.d.ts +129 -4
- 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 +264 -73
- package/dist/core.d.ts +264 -73
- 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 +7 -6
- package/dist/doctor.js +1 -1
- package/dist/doctor.js.map +1 -1
- package/dist/document-session-BfBfLVpg.d.ts +53 -0
- package/dist/fragment-endpoint-3Mlz7GDz.d.ts +189 -0
- package/dist/fragment.cjs +1 -1
- package/dist/fragment.cjs.map +1 -1
- package/dist/fragment.d.cts +64 -18
- package/dist/fragment.d.ts +64 -18
- package/dist/fragment.js +1 -1
- 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 +422 -83
- package/dist/index.d.ts +422 -83
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +2 -0
- package/dist/lean.cjs.map +1 -0
- package/dist/lean.d.cts +44 -0
- package/dist/lean.d.ts +44 -0
- package/dist/lean.js +2 -0
- package/dist/lean.js.map +1 -0
- package/dist/lexical.cjs +1 -1
- package/dist/lexical.cjs.map +1 -1
- package/dist/lexical.d.cts +19 -1
- package/dist/lexical.d.ts +19 -1
- package/dist/lexical.js +1 -1
- package/dist/lexical.js.map +1 -1
- package/dist/locals-DBXDMxOA.d.ts +45 -0
- package/dist/{middleware-CEPsY1P7.d.ts → middleware-Bx9I7PXW.d.ts} +14 -14
- package/dist/migrate.d.ts +4 -3
- package/dist/migrate.js +1 -1
- package/dist/migrate.js.map +1 -1
- package/dist/{options-CEzzfHJu.d.ts → options-BW1eqXvc.d.ts} +90 -2
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.d.cts +111 -6
- package/dist/plugins.d.ts +111 -6
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/dist/{probe-CYtvj_Lm.d.ts → probe-CELeUciC.d.ts} +26 -4
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +67 -13
- package/dist/server.d.ts +67 -13
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/structural.cjs +2 -2
- package/dist/structural.cjs.map +1 -1
- package/dist/structural.d.cts +47 -4
- package/dist/structural.d.ts +47 -4
- package/dist/structural.js +2 -2
- package/dist/structural.js.map +1 -1
- package/package.json +77 -9
package/dist/client.d.ts
CHANGED
|
@@ -80,6 +80,23 @@ interface InspectionBindings {
|
|
|
80
80
|
readonly ownerScoped: boolean;
|
|
81
81
|
/** Distinct document owners currently on the page, sorted. */
|
|
82
82
|
readonly owners: readonly string[];
|
|
83
|
+
/**
|
|
84
|
+
* Bindings the runtime found by value on the connection's first message
|
|
85
|
+
* (`autoBind: 'unique'`, ADR 0014), sorted by field, each with the value it
|
|
86
|
+
* matched on and the attribute it matched in — `undefined` for a text match.
|
|
87
|
+
* These are the elements that change without a `data-payload-field` in the
|
|
88
|
+
* template; every one of them carries `data-payload-guessed` in the DOM.
|
|
89
|
+
*/
|
|
90
|
+
readonly guessed: readonly {
|
|
91
|
+
readonly field: string;
|
|
92
|
+
readonly matched: string;
|
|
93
|
+
readonly attribute: string | undefined;
|
|
94
|
+
}[];
|
|
95
|
+
/** `autoBind` as configured, and what the one search cost; `searchMs` is `undefined` until it ran. */
|
|
96
|
+
readonly autoBind: {
|
|
97
|
+
readonly mode: 'off' | 'unique';
|
|
98
|
+
readonly searchMs: number | undefined;
|
|
99
|
+
};
|
|
83
100
|
}
|
|
84
101
|
/** Scheduler work in progress. */
|
|
85
102
|
interface InspectionScheduler {
|
|
@@ -119,14 +136,49 @@ interface LivePreviewInspection {
|
|
|
119
136
|
readonly plugins: readonly PluginInspection[];
|
|
120
137
|
/** Server-rendered fragment boundaries: whether a handler exists and what happened to renders. */
|
|
121
138
|
readonly fragments: InspectionFragments;
|
|
122
|
-
/** Route refreshes: whether a strategy exists, how many ran, failed, or were stopped by the loop guard. */
|
|
139
|
+
/** Route refreshes: whether a strategy exists, how many ran, failed, were paced, or were stopped by the loop guard. */
|
|
123
140
|
readonly route: InspectionRoute;
|
|
141
|
+
/** Patches the runtime knew could not match the server's render, and what became of them. */
|
|
142
|
+
readonly fidelity: InspectionFidelity;
|
|
143
|
+
/**
|
|
144
|
+
* Whether the page declared a framework that hydrates it, and how far the
|
|
145
|
+
* wait for its first commit — React's, or Vue's mount — got (ADR 0015).
|
|
146
|
+
* `waiting` is why a preview on a Next or Nuxt page is not connected yet;
|
|
147
|
+
* `timed-out` is LP0607.
|
|
148
|
+
*/
|
|
149
|
+
readonly hydration: {
|
|
150
|
+
readonly mode: 'off' | 'react' | 'vue';
|
|
151
|
+
readonly state: 'idle' | 'waiting' | 'committed' | 'timed-out';
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* The fidelity verdicts as `inspect()` reports them (LP0411). A positive
|
|
156
|
+
* `unfaithful` beside `escalated: 0` is a page that keeps a degraded patch —
|
|
157
|
+
* because `mode` says so, or because neither `fragments.handler` nor
|
|
158
|
+
* `route.handler` is there to escalate to.
|
|
159
|
+
*/
|
|
160
|
+
interface InspectionFidelity {
|
|
161
|
+
/** `onUnfaithfulPatch` as resolved from both of its names. */
|
|
162
|
+
readonly mode: 'ignore' | 'warn' | 'escalate';
|
|
163
|
+
/** Bindings reported unfaithful since start — once per element, like LP0411, and under every mode. */
|
|
164
|
+
readonly unfaithful: number;
|
|
165
|
+
/** Of those, how many were handed to the fragment or route strategy. */
|
|
166
|
+
readonly escalated: number;
|
|
167
|
+
/** The field names behind `unfaithful`, sorted. Cumulative. */
|
|
168
|
+
readonly fields: readonly string[];
|
|
124
169
|
}
|
|
125
170
|
/** The route strategy as `inspect()` reports it. */
|
|
126
171
|
interface InspectionRoute {
|
|
127
172
|
readonly handler: boolean;
|
|
128
173
|
readonly refreshes: number;
|
|
174
|
+
/** Refreshes that broke: the request, the answer, or the morph. */
|
|
129
175
|
readonly failed: number;
|
|
176
|
+
/**
|
|
177
|
+
* Refreshes the strategy's own minimum interval held back (LP0805). Each is
|
|
178
|
+
* run once the window closes unless a newer revision takes its place, so this
|
|
179
|
+
* counts pacing and not loss — and it is deliberately not `failed`.
|
|
180
|
+
*/
|
|
181
|
+
readonly refused: number;
|
|
130
182
|
/** Second refresh requests for one revision, refused with LP0805. */
|
|
131
183
|
readonly loopStopped: number;
|
|
132
184
|
}
|
|
@@ -203,7 +255,9 @@ type PayloadFieldCondition = (data: unknown, siblingData: unknown) => boolean;
|
|
|
203
255
|
*
|
|
204
256
|
* Browser-side reporting sites write the literal (`code: 'LP0603'`) rather than
|
|
205
257
|
* reading it from this record: the frozen table would then ship in the inline
|
|
206
|
-
* runtime for the sake of six characters
|
|
258
|
+
* runtime for the sake of six characters — it did, 1 287 B in every page, for
|
|
259
|
+
* the one read Z6 left in the strategy runner, and `diagnostic-codes.test.ts`
|
|
260
|
+
* now holds the artifact free of it. Server-side tools may import it.
|
|
207
261
|
*/
|
|
208
262
|
/**
|
|
209
263
|
* Every diagnostic code the runtime can report, by name.
|
|
@@ -221,6 +275,8 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
221
275
|
readonly ReferrerOnlyTrust: "LP0102";
|
|
222
276
|
/** A plugin declares a runtime range this runtime does not satisfy; it was refused. */
|
|
223
277
|
readonly PluginIncompatible: "LP0103";
|
|
278
|
+
/** The page carries the lean runtime and needs a feature that profile leaves out. */
|
|
279
|
+
readonly ProfileFeatureOmitted: "LP0104";
|
|
224
280
|
/** An update named a field with no binding anchor on the page. */
|
|
225
281
|
readonly OrphanField: "LP0201";
|
|
226
282
|
/** Owner scoping is on and the update names no document it could belong to. */
|
|
@@ -241,10 +297,24 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
241
297
|
readonly StructuralUnstableKeys: "LP0406";
|
|
242
298
|
/** A binding asks for a delivery strategy this release does not have; it is left unchanged. */
|
|
243
299
|
readonly UnsupportedStrategy: "LP0407";
|
|
300
|
+
/** `data-payload-format` names a format the vocabulary does not contain; the default formatting was used instead. */
|
|
301
|
+
readonly UnknownValueFormat: "LP0408";
|
|
302
|
+
/** The strict sanitizer removed an attribute the 1.x `'compat'` policy kept. */
|
|
303
|
+
readonly SanitizerDroppedAttribute: "LP0409";
|
|
304
|
+
/** A Lexical block has no renderer; the markup the server rendered for it is kept instead. */
|
|
305
|
+
readonly UnrenderedBlockKept: "LP0410";
|
|
306
|
+
/** A patch cannot reach what the server would have drawn; `onUnfaithfulPatch` decided what happens next. */
|
|
307
|
+
readonly UnfaithfulPatch: "LP0411";
|
|
308
|
+
/** The first write to a date, number or checkbox binding replaced a different reading of the same value. */
|
|
309
|
+
readonly ServerFormatReplaced: "LP0412";
|
|
310
|
+
/** A Lexical block has no renderer, and the write could not keep the markup the server rendered for it; it is gone. */
|
|
311
|
+
readonly UnrenderedBlockLost: "LP0413";
|
|
244
312
|
/** A message was rejected before it reached the update pipeline. */
|
|
245
313
|
readonly MessageRejected: "LP0501";
|
|
246
314
|
/** A preview token was rejected. */
|
|
247
315
|
readonly TokenRejected: "LP0502";
|
|
316
|
+
/** A trusted origin sent a message this protocol version does not recognise. */
|
|
317
|
+
readonly ProtocolShapeUnknown: "LP0503";
|
|
248
318
|
/** A consumer event handler threw. */
|
|
249
319
|
readonly HandlerThrew: "LP0601";
|
|
250
320
|
/** A consumer transform threw; the original value was kept. */
|
|
@@ -255,11 +325,13 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
255
325
|
readonly StartupFailed: "LP0605";
|
|
256
326
|
/** Sending the ready handshake failed. */
|
|
257
327
|
readonly ReadyFailed: "LP0606";
|
|
328
|
+
/** The page declared hydration, but no React commit or Vue mount came within the cap; the runtime started without waiting. */
|
|
329
|
+
readonly HydrationWaitTimedOut: "LP0607";
|
|
258
330
|
/** The audit found no runtime in a response that carried preview intent. */
|
|
259
331
|
readonly AuditRuntimeMissing: "LP0701";
|
|
260
332
|
/** The preview response declares no `frame-ancestors`. */
|
|
261
333
|
readonly AuditNoFrameAncestors: "LP0702";
|
|
262
|
-
/** `X-Frame-Options` forbids framing, which no CSP can undo. */
|
|
334
|
+
/** `X-Frame-Options` forbids framing, which no CSP can undo; `SAMEORIGIN` forbids it from another origin only. */
|
|
263
335
|
readonly AuditFrameOptionsBlocks: "LP0703";
|
|
264
336
|
/** Binding attributes are served to anonymous visitors. */
|
|
265
337
|
readonly AuditBindingsExposed: "LP0704";
|
|
@@ -279,10 +351,12 @@ declare const DIAGNOSTIC_CODES: Readonly<{
|
|
|
279
351
|
readonly FragmentUnauthorized: "LP0803";
|
|
280
352
|
/** A fragment response arrived for a revision that was already superseded and was discarded. */
|
|
281
353
|
readonly FragmentSuperseded: "LP0804";
|
|
282
|
-
/** A route refresh was
|
|
354
|
+
/** A route refresh was refused: the loop guard, or the strategy's minimum interval. */
|
|
283
355
|
readonly RouteRefreshLoop: "LP0805";
|
|
284
356
|
/** A boundary asks for the fragment strategy but no fragment handler is configured; it is patched. */
|
|
285
357
|
readonly FragmentStrategyUnavailable: "LP0806";
|
|
358
|
+
/** A revision changed a field with no binding; `onUnfaithfulPatch` refreshed the route. */
|
|
359
|
+
readonly UnboundChangeRefresh: "LP0807";
|
|
286
360
|
/** A readiness row is not yet at its 2.0 value; `pll doctor --v2` reports it. */
|
|
287
361
|
readonly V2ReadinessGap: "LP0709";
|
|
288
362
|
/** The preview runtime is served to anonymous visitors, not only inside the admin frame. */
|
|
@@ -345,7 +419,21 @@ interface RouteContext {
|
|
|
345
419
|
readonly signal: AbortSignal;
|
|
346
420
|
readonly isCurrent: () => boolean;
|
|
347
421
|
readonly log: (code: DiagnosticCode, detail: string) => void;
|
|
422
|
+
/**
|
|
423
|
+
* Ask to be run again in `delayMs`, once. A strategy that refuses a refresh
|
|
424
|
+
* because it is rate-limiting itself uses this: the window is a rate limit
|
|
425
|
+
* and not a filter, so what falls inside it still has to reach the preview.
|
|
426
|
+
* The runtime runs at most one such request, and only while the revision that
|
|
427
|
+
* asked is still the current one.
|
|
428
|
+
*/
|
|
429
|
+
readonly retryAfter?: (delayMs: number) => void;
|
|
348
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* What one refresh did. `refused` is the strategy's own brake and not a
|
|
433
|
+
* failure — it is counted separately, because a number that mixes a planned
|
|
434
|
+
* pause with a broken request cannot be read.
|
|
435
|
+
*/
|
|
436
|
+
type RouteOutcome = 'refreshed' | 'failed' | 'refused' | 'superseded';
|
|
349
437
|
/**
|
|
350
438
|
* Whether a revision needs the whole route re-rendered, and how. After a
|
|
351
439
|
* refresh the runtime rescans and re-applies the revision, so the unsaved
|
|
@@ -353,7 +441,7 @@ interface RouteContext {
|
|
|
353
441
|
*/
|
|
354
442
|
interface RouteStrategy {
|
|
355
443
|
readonly plan: (root: ParentNode, changedFields: ReadonlySet<string>) => boolean;
|
|
356
|
-
readonly refresh: (context: RouteContext) => Promise<
|
|
444
|
+
readonly refresh: (context: RouteContext) => Promise<RouteOutcome>;
|
|
357
445
|
}
|
|
358
446
|
interface StrategyHandlers {
|
|
359
447
|
readonly fragment?: FragmentStrategy;
|
|
@@ -426,7 +514,15 @@ interface LivePreviewEventMap {
|
|
|
426
514
|
readonly documentSave: {
|
|
427
515
|
readonly timestamp: number;
|
|
428
516
|
};
|
|
429
|
-
/**
|
|
517
|
+
/**
|
|
518
|
+
* A save in another document reached the page through
|
|
519
|
+
* `externallyUpdatedRelationship` — an admin-drawer edit. Fires once per
|
|
520
|
+
* such save, not once per message: the panel repeats its last document
|
|
521
|
+
* event in every later message, including its own saves of the previewed
|
|
522
|
+
* document, and neither of those is news. That update re-renders every
|
|
523
|
+
* bound field even under `skipUnchanged`, because a drawer edit changes
|
|
524
|
+
* populated values while the form values stay put.
|
|
525
|
+
*/
|
|
430
526
|
readonly relationshipUpdate: {
|
|
431
527
|
readonly detail: PayloadDocumentEventDetail;
|
|
432
528
|
readonly timestamp: number;
|
|
@@ -472,6 +568,12 @@ declare class EventEmitter<TMap extends object = LivePreviewEventMap> {
|
|
|
472
568
|
eventNames(): (keyof TMap)[];
|
|
473
569
|
}
|
|
474
570
|
|
|
571
|
+
/**
|
|
572
|
+
* `'strict'` (default) strips `id`, `name` and `data-payload-*` and passes
|
|
573
|
+
* other `data-*` only via `allowedDataAttributes`; `'compat'` keeps them.
|
|
574
|
+
*/
|
|
575
|
+
type SanitizerPolicyMode = 'compat' | 'strict';
|
|
576
|
+
|
|
475
577
|
/** Types shared by the runtime primitives. */
|
|
476
578
|
|
|
477
579
|
/** Payload's field set plus the DOM-binding categories `html`, `url`, `image` and `structural-array`. */
|
|
@@ -508,7 +610,7 @@ interface CachedElement {
|
|
|
508
610
|
/** Nearest enclosing `data-payload-fragment` boundary. Resolved by the cache. */
|
|
509
611
|
readonly fragmentBoundary?: Element;
|
|
510
612
|
/** `data-payload-boundary`: an anchor that hides itself while its field is empty. */
|
|
511
|
-
readonly
|
|
613
|
+
readonly hidesWhenEmpty?: boolean;
|
|
512
614
|
/** Write the value into this attribute instead of the content; policed writes. */
|
|
513
615
|
readonly targetAttribute?: string;
|
|
514
616
|
/** Optional sibling-field path bound to the element's `href` attribute. */
|
|
@@ -523,8 +625,16 @@ interface CachedElement {
|
|
|
523
625
|
readonly arraySeparator?: string;
|
|
524
626
|
/** Optional locale code locked onto this element (overrides the global locale). */
|
|
525
627
|
readonly locale?: string;
|
|
628
|
+
/** Raw `data-payload-format`; the date and number renderers read the vocabulary. */
|
|
629
|
+
readonly format?: string;
|
|
526
630
|
/** The document this binding belongs to, from the nearest `data-payload-owner`. */
|
|
527
631
|
readonly owner?: string;
|
|
632
|
+
/**
|
|
633
|
+
* The value an auto-binding matched on (`data-payload-guessed`), for a
|
|
634
|
+
* binding the runtime found by value rather than one the template declared.
|
|
635
|
+
* Absent for a declared binding.
|
|
636
|
+
*/
|
|
637
|
+
readonly guessed?: string;
|
|
528
638
|
}
|
|
529
639
|
/** What a renderer is given; `allFields` lets it resolve a sibling field. */
|
|
530
640
|
interface RenderContext {
|
|
@@ -536,6 +646,20 @@ interface RenderContext {
|
|
|
536
646
|
readonly schema: PayloadFieldSchema | undefined;
|
|
537
647
|
/** The project's rich-text renderer, when the client was configured with one. */
|
|
538
648
|
readonly renderRichText?: RichTextRenderer;
|
|
649
|
+
/**
|
|
650
|
+
* This instance's sanitizer policy, for every HTML write the renderer makes.
|
|
651
|
+
* Absent, the process default set by `setSanitizerPolicy()` applies.
|
|
652
|
+
*/
|
|
653
|
+
readonly sanitizerPolicy?: SanitizerPolicyMode;
|
|
654
|
+
/**
|
|
655
|
+
* Say that this write cannot reproduce what the server drew, so
|
|
656
|
+
* `onUnfaithfulPatch` can have a strategy render the region instead of
|
|
657
|
+
* leaving a degraded patch on the page. The built-in rich-text renderer
|
|
658
|
+
* calls it for a Lexical block whose markup it had to drop; a project
|
|
659
|
+
* renderer may call it for any value it can only approximate. `reason`
|
|
660
|
+
* completes the sentence 'field "x" …' in LP0411.
|
|
661
|
+
*/
|
|
662
|
+
readonly reportUnfaithful?: (target: CachedElement, reason: string) => void;
|
|
539
663
|
}
|
|
540
664
|
/**
|
|
541
665
|
* A renderer writes one value into its element. It must not throw: one bad
|
|
@@ -612,6 +736,10 @@ interface LivePreviewPlugin {
|
|
|
612
736
|
* one side — the adapter's request decision or the browser runtime — and a
|
|
613
737
|
* test asserts the profile assigns every readiness row that has an option, so
|
|
614
738
|
* a row added later cannot be forgotten. See ADR 0007.
|
|
739
|
+
*
|
|
740
|
+
* It lives in the leaf `types` domain, like `merge-depth.ts`, because the
|
|
741
|
+
* inline generator resolves the profile too, and the generator is server-side
|
|
742
|
+
* code that may not reach the browser runtime in `core`.
|
|
615
743
|
*/
|
|
616
744
|
/** `'v2'` is the 2.0 default; `'v1'` is the 1.x table. */
|
|
617
745
|
type DefaultsProfile = 'v1' | 'v2';
|
|
@@ -648,6 +776,13 @@ interface LivePreviewClientConfig {
|
|
|
648
776
|
readonly skipUnchanged?: boolean;
|
|
649
777
|
/** Scroll the preview to the field being edited when its value changes. Default `false`. */
|
|
650
778
|
readonly revealEditedField?: boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Find bindings by value on the connection's first message: a scalar whose
|
|
781
|
+
* value is the whole content of exactly one element is bound to it as if
|
|
782
|
+
* `data-payload-field` stood there; every guess is stamped `data-payload-guessed`
|
|
783
|
+
* and listed in `inspect().bindings.guessed`. Default `'off'`.
|
|
784
|
+
*/
|
|
785
|
+
readonly autoBind?: 'off' | 'unique';
|
|
651
786
|
/** Fields whose change re-applies other bindings regardless of their own value: `{ price: ['priceLabel'] }`. Used with `skipUnchanged`. */
|
|
652
787
|
readonly dependencies?: Readonly<Record<string, readonly string[]>>;
|
|
653
788
|
/** Strategy handlers beyond patching; `createFragmentStrategy()` from `payload-live-preview/fragment` builds one. */
|
|
@@ -672,7 +807,11 @@ interface LivePreviewClientConfig {
|
|
|
672
807
|
readonly disableLocalhostMatching?: boolean;
|
|
673
808
|
/** Which windows may post updates. Default `'parent-or-opener'`; `defaults: 'v1'` sets `'any'`. */
|
|
674
809
|
readonly eventSourcePolicy?: EventSourcePolicy;
|
|
675
|
-
/**
|
|
810
|
+
/**
|
|
811
|
+
* Sanitizer policy for this client's rich text and HTML writes. Default
|
|
812
|
+
* `'strict'`; `defaults: 'v1'` sets `'compat'`. Per instance: it leaves the
|
|
813
|
+
* process default that `setSanitizerPolicy()` sets for direct `sanitizeHtml()` calls alone.
|
|
814
|
+
*/
|
|
676
815
|
readonly sanitizerPolicy?: 'compat' | 'strict';
|
|
677
816
|
/** `'v2'` (default) is the 2.0 table; `'v1'` restores every 1.x row at once. Explicit options win. */
|
|
678
817
|
readonly defaults?: DefaultsProfile;
|
|
@@ -735,6 +874,7 @@ declare function initLivePreview(config?: LivePreviewClientConfig): LivePreviewC
|
|
|
735
874
|
interface FocusReportTarget {
|
|
736
875
|
postMessage: (message: unknown, targetOrigin: string) => void;
|
|
737
876
|
}
|
|
877
|
+
/** @internal */
|
|
738
878
|
interface PreviewFocusMessage {
|
|
739
879
|
readonly type: 'payload-live-preview-focus';
|
|
740
880
|
readonly field: string;
|
|
@@ -744,4 +884,37 @@ declare function reportPreviewFocus(target: FocusReportTarget, field: string, ta
|
|
|
744
884
|
/** A reporter bound to a preview window and origin; `resolveTarget` runs per report, so a re-created iframe is addressed freshly. */
|
|
745
885
|
declare function createPreviewFocusReporter(resolveTarget: () => FocusReportTarget | null | undefined, targetOrigin: string): (field: string) => void;
|
|
746
886
|
|
|
747
|
-
|
|
887
|
+
/**
|
|
888
|
+
* The seam between a host framework's own router and the route strategy.
|
|
889
|
+
*
|
|
890
|
+
* The route strategy answers a revision by fetching the route and morphing it
|
|
891
|
+
* into the living page. On a page whose DOM belongs to a reconciler that is
|
|
892
|
+
* working against the framework, and it was seen to break once: `removeChild`
|
|
893
|
+
* on `null` inside React's commit phase, over markup this package had patched.
|
|
894
|
+
* A host that re-renders the route itself does the same job without the morph
|
|
895
|
+
* and without the second HTML request, so it is given the chance to.
|
|
896
|
+
*
|
|
897
|
+
* Why a named slot on `window` and not a reference: the runtime is an inline
|
|
898
|
+
* script that builds its strategy before any application code has hydrated, so
|
|
899
|
+
* there is nothing to hand a component; `window.__livePreview`, the only other
|
|
900
|
+
* public surface, is created later and not at all outside a preview; and the
|
|
901
|
+
* two richer extension points — plugins and events — are reachable only through
|
|
902
|
+
* the programmatic client, which a page using an adapter does not have. One
|
|
903
|
+
* slot, written by whoever mounts and read at the moment of a refresh, is the
|
|
904
|
+
* smallest thing that survives both orders of arrival.
|
|
905
|
+
*/
|
|
906
|
+
/**
|
|
907
|
+
* A host's own route refresh. It must settle once the fresh markup is
|
|
908
|
+
* committed: the runtime re-applies the revision on top of it, and doing that
|
|
909
|
+
* against the markup being replaced would write into nodes about to be dropped.
|
|
910
|
+
*/
|
|
911
|
+
type RouteRefresh = () => void | Promise<void>;
|
|
912
|
+
/**
|
|
913
|
+
* Lend the runtime the host's route refresh; the return value undoes it, for a
|
|
914
|
+
* component's cleanup. A later registration wins, and undoing one that has
|
|
915
|
+
* already been replaced does nothing — two components on one page would
|
|
916
|
+
* otherwise take the slot from each other on unmount.
|
|
917
|
+
*/
|
|
918
|
+
declare function registerRouteRefresh(refresh: RouteRefresh): () => void;
|
|
919
|
+
|
|
920
|
+
export { type CachedElement, type ConnectionStatus, type CustomRendererKey, DIAGNOSTIC_CODES, type DefaultsProfile, type DiagnosticCode, EventEmitter, type EventHandler, type EventSourcePolicy, type FieldRenderer, type FieldTransform, type FieldType, type FocusReportTarget, type FragmentContext, type FragmentReport, type FragmentStrategy, type InspectionBindings, type InspectionFidelity, type InspectionFragments, type InspectionOrigins, type InspectionProtocol, type InspectionRevisions, type InspectionRoute, type InspectionScheduler, LivePreviewClient, type LivePreviewClientConfig, type LivePreviewEventMap, type LivePreviewInspection, type LivePreviewPlugin, type PayloadBlockSchema, type PayloadDocumentEventDetail, type PayloadFieldCondition, type PayloadFieldSchema, type PayloadFieldType, type PayloadLivePreviewData, type PluginCompatibility, type PluginContext, type PluginDisposer, type PluginEvents, type PluginInspection, type PreviewFocusMessage, type RenderContext, type RendererKey, type RichTextRenderer, type RouteContext, type RouteOutcome, type RouteRefresh, type RouteStrategy, type SanitizerPolicyMode, type StrategyHandlers, type Unsubscribe, type UpdateSource, createPreviewFocusReporter, initLivePreview, registerRouteRefresh, reportPreviewFocus };
|