efficient-storefront-blocks 0.47.0 → 0.48.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/dist/index.d.ts CHANGED
@@ -17,15 +17,27 @@ export type EditorTarget =
17
17
  | { kind: "page"; slug: string; siteId?: string; originSlug?: string }
18
18
  | { kind: "template"; id: string; pageSlug?: string };
19
19
 
20
- /** The standalone one-section editor's target (a section template). */
21
- export type SectionEditorTarget = { kind: "section"; id: string; type?: string; name?: string };
22
-
23
- /** A media item the host's picker returns. */
24
- export interface HostPickedMedia {
25
- id: string;
26
- url: string;
27
- kind: "image" | "video";
28
- }
20
+ // The editor's host contract IS easel's (efficient-easel/screen/lib/host), under
21
+ // the names this package has always used: re-exported, never a second copy, so
22
+ // a message easel adds (`publish-failed`) reaches hosts with no line here.
23
+ import type {
24
+ EaselHost as EditorHost,
25
+ EaselHostAddress as EditorHostAddress,
26
+ EaselToHostMessage as EditorToHostMessage,
27
+ HostPickedMedia,
28
+ HostToEaselMessage as HostToEditorMessage,
29
+ } from "efficient-easel/screen/lib/host";
30
+ export type {
31
+ EaselHost as EditorHost,
32
+ EaselHostAddress as EditorHostAddress,
33
+ EaselMessageType as EditorMessageType,
34
+ EaselToHostMessage as EditorToHostMessage,
35
+ HostPickedMedia,
36
+ HostToEaselMessage as HostToEditorMessage,
37
+ InboundHostMessage,
38
+ SectionScreenTarget as SectionEditorTarget,
39
+ SendToHost,
40
+ } from "efficient-easel/screen/lib/host";
29
41
 
30
42
  /** What a field asked the media panel for. `file` is a file dropped straight on
31
43
  * the field: the host uploads it and picks it without waiting for a click. */
@@ -56,88 +68,6 @@ export interface MediaPanelProps {
56
68
  * panel (the rail's Media view, and every image field's pick mode). */
57
69
  export type MediaPanelComponent = ComponentType<MediaPanelProps>;
58
70
 
59
- /** Every message the editor sends its host. */
60
- export type EditorToHostMessage =
61
- | { type: "storefront-editor:ready" }
62
- | { type: "storefront-editor:auth-expired" }
63
- | { type: "storefront-editor:dirty" }
64
- | { type: "storefront-editor:saved" }
65
- | { type: "storefront-editor:published" }
66
- | { type: "storefront-editor:save-failed" }
67
- | { type: "storefront-editor:navigated"; target: EditorTarget }
68
- | {
69
- type: "storefront-editor:open-media-picker";
70
- requestId: string;
71
- accept: string;
72
- title: string;
73
- file?: File;
74
- }
75
- /** `mode: "create"` asks for a new form and carries a `requestId` to answer
76
- * with `form-saved` / `form-closed`. `mode: "edit"` opens the form builder on
77
- * `formId` and carries none: nothing waits on it. */
78
- | { type: "storefront-editor:open-form"; requestId?: string; mode: "create" | "edit"; formId?: string }
79
- | { type: "storefront-editor:open-category"; categoryId: string; name?: string }
80
- | { type: "storefront-editor:open-product"; slug: string; name?: string }
81
- | { type: "storefront-editor:open-post"; slug: string; title?: string }
82
- /** Open the website's Settings (`"settings"`, e.g. Selling, where the stock
83
- * rules live) or its Shipping (`"shipping"`, the pickup places) in the host,
84
- * from a panel row that reads a rule the editor does not own. Nothing
85
- * answers it. */
86
- | { type: "storefront-editor:open-site-section"; section: "settings" | "shipping" }
87
- | { type: "storefront-editor:open-menus"; menuId?: string | null }
88
- | { type: "storefront-editor:open-page"; slug: string }
89
- | { type: "storefront-editor:new-page" }
90
- | { type: "storefront-editor:save-as-template"; siteId: string; slug: string };
91
-
92
- /** Every message a host sends the editor. */
93
- export type HostToEditorMessage =
94
- | {
95
- type: "storefront-editor:auth";
96
- token: string;
97
- siteId?: string;
98
- brandId?: string;
99
- theme?: string;
100
- can?: { canCreatePlatformTemplate?: boolean };
101
- }
102
- | { type: "storefront-editor:navigate"; target: EditorTarget | SectionEditorTarget }
103
- | { type: "storefront-editor:category-updated"; categoryId?: string }
104
- | { type: "storefront-editor:menus-updated" }
105
- | { type: "storefront-editor:form-saved"; requestId?: string; form?: { id: string; slug: string } }
106
- | { type: "storefront-editor:form-closed"; requestId?: string }
107
- | { type: "storefront-editor:media-picked"; requestId: string; media: HostPickedMedia }
108
- | { type: "storefront-editor:media-pick-cancelled"; requestId: string };
109
-
110
- export type EditorMessageType = EditorToHostMessage["type"];
111
- type PayloadOf<T extends EditorMessageType> = Omit<Extract<EditorToHostMessage, { type: T }>, "type">;
112
-
113
- export type SendToHost = <T extends EditorMessageType>(
114
- type: T,
115
- ...payload: Record<string, never> extends PayloadOf<T> ? [PayloadOf<T>?] : [PayloadOf<T>]
116
- ) => void;
117
-
118
- export type InboundHostMessage = { type: string } & Record<string, unknown>;
119
-
120
- /** The editor's address — for an embedder, retargets of its own window. */
121
- export interface EditorHostAddress {
122
- /** The query the editor was opened with. An embedder that opens templates to
123
- * edit their layout answers `"?editTemplate=1"`. */
124
- search(): string;
125
- /** Keep the embedder's notion of "where" in step (no load). */
126
- show(target: EditorTarget | SectionEditorTarget): void;
127
- /** Leave for another document by LOADING it — re-mount the editor there. */
128
- load(target: EditorTarget): void;
129
- /** Reload the editor from scratch — re-mount it on the same target. */
130
- reload(): void;
131
- }
132
-
133
- export interface EditorHost {
134
- readonly connected: boolean;
135
- readonly ownsDocument: boolean;
136
- send: SendToHost;
137
- subscribe(listener: (message: InboundHostMessage) => void): () => void;
138
- readonly address: EditorHostAddress;
139
- }
140
-
141
71
  /** A host for an editor mounted in the embedder's own page. One per editor. */
142
72
  export function createEditorHost(options: {
143
73
  onMessage: (message: EditorToHostMessage) => void;