@abinnovision/payloadcms-viewfinder 1.0.0-beta.4 → 1.0.0-beta.5
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/dist/admin/bridge.d.mts
CHANGED
|
@@ -18,6 +18,5 @@ import { ReactNode } from "react";
|
|
|
18
18
|
* that setting and tells the preview what it is, both on change and whenever
|
|
19
19
|
* the preview announces itself.
|
|
20
20
|
*/
|
|
21
|
-
declare const ViewfinderFormBridge: () => ReactNode;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { ViewfinderFormBridge };
|
|
21
|
+
export declare const ViewfinderFormBridge: () => ReactNode;
|
|
22
|
+
//#endregion
|
package/dist/attributes.d.mts
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
* against its own form state. That is what keeps the frontend free of a
|
|
6
6
|
* content source map and the API unchanged.
|
|
7
7
|
*/
|
|
8
|
-
declare const BLOCK_ID_ATTRIBUTE = "data-vf-id";
|
|
8
|
+
export declare const BLOCK_ID_ATTRIBUTE = "data-vf-id";
|
|
9
9
|
/** Advisory only: the admin addresses blocks by id, never by type. */
|
|
10
|
-
declare const BLOCK_TYPE_ATTRIBUTE = "data-vf-type";
|
|
10
|
+
export declare const BLOCK_TYPE_ATTRIBUTE = "data-vf-type";
|
|
11
11
|
/** Resolved against the nearest marked block ancestor, so it stays index-free. */
|
|
12
|
-
declare const FIELD_ATTRIBUTE = "data-vf-field";
|
|
13
|
-
interface BlockMarkerAttributes {
|
|
12
|
+
export declare const FIELD_ATTRIBUTE = "data-vf-field";
|
|
13
|
+
export interface BlockMarkerAttributes {
|
|
14
14
|
readonly [BLOCK_ID_ATTRIBUTE]: string;
|
|
15
15
|
readonly [BLOCK_TYPE_ATTRIBUTE]?: string;
|
|
16
16
|
}
|
|
17
|
-
interface FieldMarkerAttributes {
|
|
17
|
+
export interface FieldMarkerAttributes {
|
|
18
18
|
readonly [FIELD_ATTRIBUTE]: string;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -26,12 +26,11 @@ interface FieldMarkerAttributes {
|
|
|
26
26
|
* That element is worth adding deliberately, since a real element has a real
|
|
27
27
|
* box and the highlight overlay measures it directly.
|
|
28
28
|
*/
|
|
29
|
-
declare const markBlock: (id: string, blockType?: string) => BlockMarkerAttributes;
|
|
29
|
+
export declare const markBlock: (id: string, blockType?: string) => BlockMarkerAttributes;
|
|
30
30
|
/**
|
|
31
31
|
* Attributes identifying one field within the enclosing block. `field` is
|
|
32
32
|
* relative to that block (`"heading"`, or `"items.0.label"` for something
|
|
33
33
|
* nested), never an absolute document path.
|
|
34
34
|
*/
|
|
35
|
-
declare const markField: (field: string) => FieldMarkerAttributes;
|
|
36
|
-
//#endregion
|
|
37
|
-
export { BLOCK_ID_ATTRIBUTE, BLOCK_TYPE_ATTRIBUTE, BlockMarkerAttributes, FIELD_ATTRIBUTE, FieldMarkerAttributes, markBlock, markField };
|
|
35
|
+
export declare const markField: (field: string) => FieldMarkerAttributes;
|
|
36
|
+
//#endregion
|
package/dist/client/bridge.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
//#region src/client/bridge.d.ts
|
|
3
|
-
interface ViewfinderBridgeProps {
|
|
3
|
+
export interface ViewfinderBridgeProps {
|
|
4
4
|
/**
|
|
5
5
|
* Origin of the Payload admin, e.g. `https://cms.example.com`. Required
|
|
6
6
|
* rather than defaulting to `"*"`: this window posts the ids of everything
|
|
@@ -22,6 +22,5 @@ interface ViewfinderBridgeProps {
|
|
|
22
22
|
* whenever it says off, this is an untouched page: no outline, and a link
|
|
23
23
|
* inside a marked block navigates the way it would for a visitor.
|
|
24
24
|
*/
|
|
25
|
-
declare const ViewfinderBridge: (props: ViewfinderBridgeProps) => ReactNode;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { ViewfinderBridge, ViewfinderBridgeProps };
|
|
25
|
+
export declare const ViewfinderBridge: (props: ViewfinderBridgeProps) => ReactNode;
|
|
26
|
+
//#endregion
|
package/dist/config/plugin.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "payload";
|
|
2
2
|
//#region src/config/plugin.d.ts
|
|
3
|
-
interface ViewfinderPluginArgs {
|
|
3
|
+
export interface ViewfinderPluginArgs {
|
|
4
4
|
/** Collection slugs to make addressable. Defaults to every collection. */
|
|
5
5
|
collections?: string[] | undefined;
|
|
6
6
|
/** Global slugs to make addressable. Defaults to every global. */
|
|
@@ -13,6 +13,5 @@ interface ViewfinderPluginArgs {
|
|
|
13
13
|
* enabling it for a collection that has no live preview configured costs
|
|
14
14
|
* nothing beyond the component itself.
|
|
15
15
|
*/
|
|
16
|
-
declare const viewfinderPlugin: (args?: ViewfinderPluginArgs) => Plugin;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { ViewfinderPluginArgs, viewfinderPlugin };
|
|
16
|
+
export declare const viewfinderPlugin: (args?: ViewfinderPluginArgs) => Plugin;
|
|
17
|
+
//#endregion
|
package/dist/protocol.d.mts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* carries a source tag and a version, and is validated structurally on
|
|
6
6
|
* arrival rather than cast.
|
|
7
7
|
*/
|
|
8
|
-
declare const VIEWFINDER_SOURCE = "viewfinder";
|
|
8
|
+
export declare const VIEWFINDER_SOURCE = "viewfinder";
|
|
9
9
|
/**
|
|
10
10
|
* Bumped only on a breaking envelope change. A mismatched version is dropped
|
|
11
11
|
* silently, so a stale frontend deployment cannot drive a newer admin.
|
|
@@ -15,12 +15,12 @@ declare const VIEWFINDER_SOURCE = "viewfinder";
|
|
|
15
15
|
* drops the message and keeps behaving as it did. Bumping the version for that
|
|
16
16
|
* would instead break every existing pairing at once.
|
|
17
17
|
*/
|
|
18
|
-
declare const VIEWFINDER_PROTOCOL_VERSION = 1;
|
|
18
|
+
export declare const VIEWFINDER_PROTOCOL_VERSION = 1;
|
|
19
19
|
/**
|
|
20
20
|
* What one message points at. `field` is relative to the block, which is what
|
|
21
21
|
* lets the same address survive the block moving to a different index.
|
|
22
22
|
*/
|
|
23
|
-
interface BlockAddress {
|
|
23
|
+
export interface BlockAddress {
|
|
24
24
|
id: string;
|
|
25
25
|
blockType?: string;
|
|
26
26
|
field?: string;
|
|
@@ -37,28 +37,27 @@ interface FlaggedEnvelope<TType extends string> extends Envelope<TType> {
|
|
|
37
37
|
enabled: boolean;
|
|
38
38
|
}
|
|
39
39
|
/** Sent by the rendered page, in the iframe, up to the admin. */
|
|
40
|
-
type PreviewMessage = AddressedEnvelope<"hover"> | AddressedEnvelope<"select"> | Envelope<"leave"> | Envelope<"ready">;
|
|
40
|
+
export type PreviewMessage = AddressedEnvelope<"hover"> | AddressedEnvelope<"select"> | Envelope<"leave"> | Envelope<"ready">;
|
|
41
41
|
/**
|
|
42
42
|
* Sent by the admin down into the preview iframe. `enabled` is the admin
|
|
43
43
|
* answering for the whole feature: the admin owns the setting, and the preview
|
|
44
44
|
* is told what it is, on connect and on every change.
|
|
45
45
|
*/
|
|
46
|
-
type AdminMessage = AddressedEnvelope<"highlight"> | AddressedEnvelope<"scrollTo"> | Envelope<"clear"> | FlaggedEnvelope<"enabled">;
|
|
46
|
+
export type AdminMessage = AddressedEnvelope<"highlight"> | AddressedEnvelope<"scrollTo"> | Envelope<"clear"> | FlaggedEnvelope<"enabled">;
|
|
47
47
|
/** Narrows the untrusted `event.data` of a `message` event from the iframe. */
|
|
48
|
-
declare const isPreviewMessage: (value: unknown) => value is PreviewMessage;
|
|
48
|
+
export declare const isPreviewMessage: (value: unknown) => value is PreviewMessage;
|
|
49
49
|
/** Narrows the untrusted `event.data` of a `message` event from the admin. */
|
|
50
|
-
declare const isAdminMessage: (value: unknown) => value is AdminMessage;
|
|
51
|
-
declare const previewMessage: {
|
|
50
|
+
export declare const isAdminMessage: (value: unknown) => value is AdminMessage;
|
|
51
|
+
export declare const previewMessage: {
|
|
52
52
|
readonly ready: () => PreviewMessage;
|
|
53
53
|
readonly leave: () => PreviewMessage;
|
|
54
54
|
readonly hover: (address: BlockAddress) => PreviewMessage;
|
|
55
55
|
readonly select: (address: BlockAddress) => PreviewMessage;
|
|
56
56
|
};
|
|
57
|
-
declare const adminMessage: {
|
|
57
|
+
export declare const adminMessage: {
|
|
58
58
|
readonly clear: () => AdminMessage;
|
|
59
59
|
readonly enabled: (enabled: boolean) => AdminMessage;
|
|
60
60
|
readonly highlight: (address: BlockAddress) => AdminMessage;
|
|
61
61
|
readonly scrollTo: (address: BlockAddress) => AdminMessage;
|
|
62
62
|
};
|
|
63
|
-
//#endregion
|
|
64
|
-
export { AdminMessage, BlockAddress, PreviewMessage, VIEWFINDER_PROTOCOL_VERSION, VIEWFINDER_SOURCE, adminMessage, isAdminMessage, isPreviewMessage, previewMessage };
|
|
63
|
+
//#endregion
|
package/dist/resolve-path.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ import { BlockAddress } from "./protocol.mjs";
|
|
|
10
10
|
* know the collection's schema. If a Payload upgrade changes the key shape,
|
|
11
11
|
* this file is the only one that has to move.
|
|
12
12
|
*/
|
|
13
|
-
type FormStateLike = Readonly<Record<string, {
|
|
13
|
+
export type FormStateLike = Readonly<Record<string, {
|
|
14
14
|
value?: unknown;
|
|
15
15
|
} | undefined>>;
|
|
16
16
|
/**
|
|
@@ -20,14 +20,14 @@ type FormStateLike = Readonly<Record<string, {
|
|
|
20
20
|
* shallowest path wins so the result stays deterministic rather than
|
|
21
21
|
* depending on key order.
|
|
22
22
|
*/
|
|
23
|
-
declare const resolveBlockPath: (formState: FormStateLike, id: string) => string | undefined;
|
|
23
|
+
export declare const resolveBlockPath: (formState: FormStateLike, id: string) => string | undefined;
|
|
24
24
|
/** Joins a block path and a block-relative field name into a form path. */
|
|
25
|
-
declare const resolveFieldPath: (blockPath: string, field: string) => string;
|
|
25
|
+
export declare const resolveFieldPath: (blockPath: string, field: string) => string;
|
|
26
26
|
/**
|
|
27
27
|
* Resolves a whole address to the form path the admin should reveal: the
|
|
28
28
|
* block itself, or a field inside it when the preview named one.
|
|
29
29
|
*/
|
|
30
|
-
declare const resolveAddressPath: (formState: FormStateLike, address: BlockAddress) => string | undefined;
|
|
30
|
+
export declare const resolveAddressPath: (formState: FormStateLike, address: BlockAddress) => string | undefined;
|
|
31
31
|
/**
|
|
32
32
|
* The inverse, for the admin-to-preview direction: given any form path, finds
|
|
33
33
|
* the id of the nearest enclosing block.
|
|
@@ -36,11 +36,10 @@ declare const resolveAddressPath: (formState: FormStateLike, address: BlockAddre
|
|
|
36
36
|
* what distinguishes a block row from a plain array row — array rows also
|
|
37
37
|
* carry an `id`, but the preview knows nothing about them.
|
|
38
38
|
*/
|
|
39
|
-
declare const resolveBlockIdForPath: (formState: FormStateLike, path: string) => string | undefined;
|
|
39
|
+
export declare const resolveBlockIdForPath: (formState: FormStateLike, path: string) => string | undefined;
|
|
40
40
|
/**
|
|
41
41
|
* The address to send into the preview for a form path, carrying the field
|
|
42
42
|
* suffix when the path pointed inside a block rather than at it.
|
|
43
43
|
*/
|
|
44
|
-
declare const resolveAddressForPath: (formState: FormStateLike, path: string) => BlockAddress | undefined;
|
|
45
|
-
//#endregion
|
|
46
|
-
export { FormStateLike, resolveAddressForPath, resolveAddressPath, resolveBlockIdForPath, resolveBlockPath, resolveFieldPath };
|
|
44
|
+
export declare const resolveAddressForPath: (formState: FormStateLike, path: string) => BlockAddress | undefined;
|
|
45
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@abinnovision/payloadcms-viewfinder",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.5",
|
|
5
5
|
"description": "Two-way block addressing between a rendered frontend and the Payload CMS admin form.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"payload",
|
|
@@ -68,20 +68,20 @@
|
|
|
68
68
|
"@abinnovision/prettier-config": "^2.2.0",
|
|
69
69
|
"@arethetypeswrong/core": "^0.18.5",
|
|
70
70
|
"@payloadcms/ui": "3.88.0",
|
|
71
|
-
"@swc/core": "^1.16.
|
|
72
|
-
"@types/node": "^26.
|
|
71
|
+
"@swc/core": "^1.16.2",
|
|
72
|
+
"@types/node": "^26.5.1",
|
|
73
73
|
"@types/react": "^19.2.18",
|
|
74
|
-
"@vitest/coverage-v8": "^
|
|
75
|
-
"eslint": "^10.
|
|
74
|
+
"@vitest/coverage-v8": "^5.0.0",
|
|
75
|
+
"eslint": "^10.10.0",
|
|
76
76
|
"payload": "3.88.0",
|
|
77
77
|
"prettier": "^3.9.5",
|
|
78
78
|
"publint": "^0.3.24",
|
|
79
79
|
"react": "^19.2.8",
|
|
80
80
|
"react-dom": "^19.2.8",
|
|
81
|
-
"tsdown": "^0.
|
|
81
|
+
"tsdown": "^0.23.0",
|
|
82
82
|
"typescript": "^6.0.3",
|
|
83
|
-
"unplugin-swc": "^1.
|
|
84
|
-
"vitest": "^
|
|
83
|
+
"unplugin-swc": "^1.6.0",
|
|
84
|
+
"vitest": "^5.0.0"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@payloadcms/ui": ">=3.88.0 <4",
|