efficient-easel 0.101.1 → 0.103.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 +51 -0
- package/dist/LinkPicker-W2Rtxetz.d.ts +111 -0
- package/dist/autosave/index.d.ts +6 -3
- package/dist/autosave/index.js +1 -1
- package/dist/chrome/index.d.ts +3 -2
- package/dist/chrome/index.js +1 -25
- package/dist/chunk-26OOWIJJ.js +1 -0
- package/dist/chunk-2LK54I4E.js +1 -0
- package/dist/chunk-3M3A3DN2.js +4 -0
- package/dist/chunk-3QVB4AG2.js +3 -0
- package/dist/chunk-3WSPDAK2.js +1 -0
- package/dist/chunk-4ES5JGGX.js +1 -0
- package/dist/chunk-4MXFKJUY.js +1 -0
- package/dist/chunk-57DJOKXT.js +1 -0
- package/dist/chunk-5MZ3RNQQ.js +13 -0
- package/dist/chunk-5ZBY24K7.js +1 -0
- package/dist/chunk-66ICOE3I.js +8 -0
- package/dist/chunk-6DJHRLCU.js +25 -0
- package/dist/chunk-6FY3PZS3.js +1 -0
- package/dist/chunk-6TZTKAB5.js +1 -0
- package/dist/chunk-6UJ3Y6FC.js +1 -0
- package/dist/chunk-6W7WLPZH.js +1 -0
- package/dist/chunk-7F52SZOI.js +2 -0
- package/dist/chunk-7MU3RJ6S.js +1 -0
- package/dist/chunk-A7ZJII7O.js +1 -0
- package/dist/chunk-AJBJ74ME.js +1 -0
- package/dist/chunk-AKFJK65Z.js +1 -0
- package/dist/chunk-AKZWUV5Z.js +1 -0
- package/dist/chunk-BDTITTMW.js +1 -0
- package/dist/chunk-BSPCSC45.js +1 -0
- package/dist/chunk-BXZ6WLHC.js +22 -0
- package/dist/chunk-DUVRZ456.js +1 -0
- package/dist/chunk-F6CCTEIX.js +1 -0
- package/dist/chunk-FGNR22NY.js +1 -0
- package/dist/chunk-FUDHI5I4.js +1 -0
- package/dist/chunk-GENAF3P6.js +1 -0
- package/dist/chunk-GOTN2KY4.js +2 -0
- package/dist/chunk-GXN65JMA.js +1 -0
- package/dist/chunk-GXQCZJOP.js +1 -0
- package/dist/chunk-GZO72N3Q.js +0 -0
- package/dist/chunk-HDKTR5TZ.js +62 -0
- package/dist/chunk-HMX55DYT.js +1 -0
- package/dist/chunk-HQ4VVRIC.js +1 -0
- package/dist/chunk-HWW4XJOH.js +1 -0
- package/dist/chunk-I54UCYOU.js +1 -0
- package/dist/chunk-IQ5TA7AM.js +1 -0
- package/dist/chunk-IWAPPEL4.js +6 -0
- package/dist/chunk-IYT6NN2J.js +1 -0
- package/dist/chunk-KCBEE2MC.js +2 -0
- package/dist/chunk-KDYIMJTZ.js +1 -0
- package/dist/chunk-KQMML6JM.js +4 -0
- package/dist/chunk-LG436UTD.js +1 -0
- package/dist/chunk-MSBF7IW3.js +2 -0
- package/dist/chunk-NBJ2YY6Y.js +4 -0
- package/dist/chunk-OM67AJQC.js +1 -0
- package/dist/chunk-OORDMLL4.js +5 -0
- package/dist/chunk-OYX47SL7.js +1 -0
- package/dist/chunk-P67FP7PG.js +9 -0
- package/dist/chunk-PWZOS45R.js +2 -0
- package/dist/chunk-Q2HPBMG5.js +1 -0
- package/dist/chunk-Q3SQBNJB.js +1 -0
- package/dist/chunk-R2HLPNQF.js +1 -0
- package/dist/chunk-R5L2E7JX.js +1 -0
- package/dist/chunk-R5ZVNJLJ.js +2 -0
- package/dist/chunk-RLBXE4EU.js +1 -0
- package/dist/chunk-RW4XBUUW.js +1 -0
- package/dist/chunk-SERF2FAU.js +1 -0
- package/dist/chunk-TTJ54QGG.js +18 -0
- package/dist/chunk-VV5ADNBR.js +1 -0
- package/dist/chunk-YJXEHK6I.js +2 -0
- package/dist/chunk-Z3KBLIEH.js +10 -0
- package/dist/chunk-ZE7I3PLX.js +1 -0
- package/dist/chunk-ZWK3CBRU.js +1 -0
- package/dist/chunk-ZZ7VLIHQ.js +1 -0
- package/dist/drag/index.d.ts +3 -41
- package/dist/drag/index.js +1 -18
- package/dist/easel/index.js +1 -9
- package/dist/{words-BMzV04b1.d.ts → engine-DBxp_v6B.d.ts} +1 -58
- package/dist/fields/index.d.ts +2 -109
- package/dist/fields/index.js +1 -22
- package/dist/gold/index.d.ts +4 -2
- package/dist/host-DJ8Gzsx7.d.ts +552 -0
- package/dist/menu/index.js +1 -1
- package/dist/node-ops/index.js +1 -1
- package/dist/panelWidths-D9hTLR25.d.ts +66 -0
- package/dist/screen/components/AddBlockRow.d.ts +14 -0
- package/dist/screen/components/AddBlockRow.js +1 -0
- package/dist/screen/components/AddChildRow.d.ts +39 -0
- package/dist/screen/components/AddChildRow.js +1 -0
- package/dist/screen/components/AddSidePanel.d.ts +54 -0
- package/dist/screen/components/AddSidePanel.js +1 -0
- package/dist/screen/components/MediaSidePanel.d.ts +47 -0
- package/dist/screen/components/MediaSidePanel.js +1 -0
- package/dist/screen/components/NodeContextMenu.d.ts +364 -0
- package/dist/screen/components/NodeContextMenu.js +1 -0
- package/dist/screen/components/PageEditGuardNotices.d.ts +5 -0
- package/dist/screen/components/PageEditGuardNotices.js +1 -0
- package/dist/screen/components/PanelToggleIcon.d.ts +14 -0
- package/dist/screen/components/PanelToggleIcon.js +1 -0
- package/dist/screen/components/PreviewDeviceContext.d.ts +28 -0
- package/dist/screen/components/PreviewDeviceContext.js +1 -0
- package/dist/screen/components/PreviewPartsContext.d.ts +33 -0
- package/dist/screen/components/PreviewPartsContext.js +1 -0
- package/dist/screen/components/ScreenChrome.d.ts +5 -0
- package/dist/screen/components/ScreenChrome.js +1 -0
- package/dist/screen/components/ScreenDocumentContext.d.ts +20 -0
- package/dist/screen/components/ScreenDocumentContext.js +1 -0
- package/dist/screen/components/ScreenMount.d.ts +76 -0
- package/dist/screen/components/ScreenMount.js +1 -0
- package/dist/screen/components/ScreenStoreProvider.d.ts +63 -0
- package/dist/screen/components/ScreenStoreProvider.js +1 -0
- package/dist/screen/components/SectionScreenShell.d.ts +5 -0
- package/dist/screen/components/SectionScreenShell.js +16 -0
- package/dist/screen/components/SidePanelHead.d.ts +81 -0
- package/dist/screen/components/SidePanelHead.js +1 -0
- package/dist/screen/components/SlotChildActionsContext.d.ts +41 -0
- package/dist/screen/components/SlotChildActionsContext.js +1 -0
- package/dist/screen/components/UiIcon.d.ts +52 -0
- package/dist/screen/components/UiIcon.js +1 -0
- package/dist/screen/components/panel-widths.d.ts +37 -0
- package/dist/screen/components/panel-widths.js +1 -0
- package/dist/screen/components/usePartBridge.d.ts +66 -0
- package/dist/screen/components/usePartBridge.js +1 -0
- package/dist/screen/index.d.ts +31 -0
- package/dist/screen/index.js +1 -0
- package/dist/screen/lib/admin-bridge.d.ts +105 -0
- package/dist/screen/lib/admin-bridge.js +1 -0
- package/dist/screen/lib/backend-error.d.ts +106 -0
- package/dist/screen/lib/backend-error.js +1 -0
- package/dist/screen/lib/chrome-theme.d.ts +21 -0
- package/dist/screen/lib/chrome-theme.js +1 -0
- package/dist/screen/lib/client-only.d.ts +24 -0
- package/dist/screen/lib/client-only.js +1 -0
- package/dist/screen/lib/content/view-tiers.d.ts +25 -0
- package/dist/screen/lib/content/view-tiers.js +1 -0
- package/dist/screen/lib/document-addressing.d.ts +20 -0
- package/dist/screen/lib/document-addressing.js +1 -0
- package/dist/screen/lib/document-contract.d.ts +237 -0
- package/dist/screen/lib/document-contract.js +1 -0
- package/dist/screen/lib/document-hooks.d.ts +71 -0
- package/dist/screen/lib/document-hooks.js +0 -0
- package/dist/screen/lib/document-switch.d.ts +74 -0
- package/dist/screen/lib/document-switch.js +1 -0
- package/dist/screen/lib/failure.d.ts +54 -0
- package/dist/screen/lib/failure.js +1 -0
- package/dist/screen/lib/host-chrome.d.ts +181 -0
- package/dist/screen/lib/host-chrome.js +1 -0
- package/dist/screen/lib/host-inbound.d.ts +20 -0
- package/dist/screen/lib/host-inbound.js +1 -0
- package/dist/screen/lib/host.d.ts +20 -0
- package/dist/screen/lib/host.js +1 -0
- package/dist/screen/lib/key-scope.d.ts +23 -0
- package/dist/screen/lib/key-scope.js +1 -0
- package/dist/screen/lib/links/link-filters.d.ts +41 -0
- package/dist/screen/lib/links/link-filters.js +0 -0
- package/dist/screen/lib/load-error.d.ts +29 -0
- package/dist/screen/lib/load-error.js +1 -0
- package/dist/screen/lib/media-panel.d.ts +94 -0
- package/dist/screen/lib/media-panel.js +1 -0
- package/dist/screen/lib/media-picker.d.ts +68 -0
- package/dist/screen/lib/media-picker.js +1 -0
- package/dist/screen/lib/page-lock.d.ts +5 -0
- package/dist/screen/lib/page-lock.js +1 -0
- package/dist/screen/lib/puck/add-target-types.d.ts +55 -0
- package/dist/screen/lib/puck/add-target-types.js +0 -0
- package/dist/screen/lib/puck/block-choice.d.ts +52 -0
- package/dist/screen/lib/puck/block-choice.js +1 -0
- package/dist/screen/lib/puck/block-types-in.d.ts +39 -0
- package/dist/screen/lib/puck/block-types-in.js +1 -0
- package/dist/screen/lib/puck/content-tree.d.ts +196 -0
- package/dist/screen/lib/puck/content-tree.js +1 -0
- package/dist/screen/lib/puck/device-fields.d.ts +128 -0
- package/dist/screen/lib/puck/device-fields.js +1 -0
- package/dist/screen/lib/puck/field-buckets.d.ts +22 -0
- package/dist/screen/lib/puck/field-buckets.js +1 -0
- package/dist/screen/lib/puck/field-markers.d.ts +205 -0
- package/dist/screen/lib/puck/field-markers.js +1 -0
- package/dist/screen/lib/puck/hidable.d.ts +44 -0
- package/dist/screen/lib/puck/hidable.js +1 -0
- package/dist/screen/lib/puck/palette-sections.d.ts +96 -0
- package/dist/screen/lib/puck/palette-sections.js +1 -0
- package/dist/screen/lib/puck/panel-fields.d.ts +47 -0
- package/dist/screen/lib/puck/panel-fields.js +1 -0
- package/dist/screen/lib/puck/panel-no-control-mark.d.ts +74 -0
- package/dist/screen/lib/puck/panel-no-control-mark.js +1 -0
- package/dist/screen/lib/puck/part-id.d.ts +23 -0
- package/dist/screen/lib/puck/part-id.js +1 -0
- package/dist/screen/lib/puck/preview-click.d.ts +49 -0
- package/dist/screen/lib/puck/preview-click.js +1 -0
- package/dist/screen/lib/puck/preview-dom.d.ts +8 -0
- package/dist/screen/lib/puck/preview-dom.js +1 -0
- package/dist/screen/lib/puck/preview-events.d.ts +25 -0
- package/dist/screen/lib/puck/preview-events.js +1 -0
- package/dist/screen/lib/puck/preview-selection-context.d.ts +72 -0
- package/dist/screen/lib/puck/preview-selection-context.js +1 -0
- package/dist/screen/lib/puck/section-doc.d.ts +20 -0
- package/dist/screen/lib/puck/section-doc.js +1 -0
- package/dist/screen/lib/puck/slot-child-name.d.ts +186 -0
- package/dist/screen/lib/puck/slot-child-name.js +1 -0
- package/dist/screen/lib/puck/slot-heal.d.ts +5 -0
- package/dist/screen/lib/puck/slot-heal.js +1 -0
- package/dist/screen/lib/puck/slot-section-spec.d.ts +96 -0
- package/dist/screen/lib/puck/slot-section-spec.js +0 -0
- package/dist/screen/lib/puck/style-clipboard.d.ts +78 -0
- package/dist/screen/lib/puck/style-clipboard.js +1 -0
- package/dist/screen/lib/puck/text-control-kinds.d.ts +71 -0
- package/dist/screen/lib/puck/text-control-kinds.js +1 -0
- package/dist/screen/lib/puck/tree-reveal.d.ts +62 -0
- package/dist/screen/lib/puck/tree-reveal.js +1 -0
- package/dist/screen/lib/puck/use-section-ops.d.ts +86 -0
- package/dist/screen/lib/puck/use-section-ops.js +1 -0
- package/dist/screen/lib/screen-parts.d.ts +748 -0
- package/dist/screen/lib/screen-parts.js +1 -0
- package/dist/screen/lib/section-template-types.d.ts +49 -0
- package/dist/screen/lib/section-template-types.js +0 -0
- package/dist/screen/lib/section-templates.d.ts +23 -0
- package/dist/screen/lib/section-templates.js +1 -0
- package/dist/screen/lib/session-context.d.ts +30 -0
- package/dist/screen/lib/session-context.js +1 -0
- package/dist/screen/lib/session.d.ts +255 -0
- package/dist/screen/lib/session.js +1 -0
- package/dist/screen/screen.css +1102 -0
- package/dist/screen/words.d.ts +42 -0
- package/dist/screen/words.js +1 -0
- package/dist/session-DSQFmIvx.d.ts +43 -0
- package/dist/strings/catalogue.d.ts +13 -4
- package/dist/strings/catalogue.js +1 -1
- package/dist/strings/index.d.ts +5 -2
- package/dist/strings/index.js +1 -1
- package/dist/style-clipboard/index.js +1 -1
- package/dist/{types-DGcCsxs8.d.ts → types-CqY85foL.d.ts} +3 -65
- package/dist/words-D_Lnw1Gr.d.ts +59 -0
- package/package.json +348 -2
- package/dist/chunk-IG3U5NWJ.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{SELECTION_MODE,ScreenPartsProvider,sameInspectorMode,useScreenBlockLook,useScreenBlockRules,useScreenBridges,useScreenCanvasFrame,useScreenDevices,useScreenDocumentPass,useScreenInspectorPanel,useScreenLeftView,useScreenOwnerName,useScreenParts,useScreenPinned,useScreenSaveSwitch,useStandaloneScreenBridges}from"../../chunk-NBJ2YY6Y.js";import"../../chunk-P67FP7PG.js";import"../../chunk-AELNNAFM.js";import"../../chunk-BXZ6WLHC.js";import"../../chunk-EOJNJCMJ.js";import"../../chunk-ZFDCDJNZ.js";import"../../chunk-ZNS7727Y.js";import"../../chunk-3EDSDPIP.js";import"../../chunk-QTLAVDJE.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-KTVH2ZRL.js";import"../../chunk-D2BCHTQR.js";import"../../chunk-EWVJSRRY.js";import"../../chunk-P6O363EE.js";import"../../chunk-FPOKPNO4.js";import"../../chunk-MFIRYGHW.js";import"../../chunk-BZ5ASXOL.js";import"../../chunk-67GNT6PF.js";import"../../chunk-ZNCEOSXO.js";import"../../chunk-L5KW4HG5.js";import"../../chunk-KRXQM65X.js";import"../../chunk-NKB3KVAB.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TreeItem } from './puck/content-tree.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A SAVED SECTION, AND THE STORE THE EDITOR KEEPS THEM IN — the types alone.
|
|
5
|
+
*
|
|
6
|
+
* Declared with the website builder (doc/adr/0002): the editor's "Saved
|
|
7
|
+
* sections" and the backend contract's `sectionTemplates` group
|
|
8
|
+
* (lib/web-backend) are written against these, and a backend implements them.
|
|
9
|
+
* EFFICIENT's implementation is `lib/api/section-templates`, which re-exports
|
|
10
|
+
* them — so there is one declaration, and the builder imports no API client to
|
|
11
|
+
* name a type.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
interface SectionTemplateRecord {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
component_type: string;
|
|
18
|
+
node: TreeItem | null;
|
|
19
|
+
created_at: string;
|
|
20
|
+
updated_at: string;
|
|
21
|
+
}
|
|
22
|
+
/** A template with a design — what the port hands its callers to render or
|
|
23
|
+
* insert. */
|
|
24
|
+
interface SectionTemplate extends SectionTemplateRecord {
|
|
25
|
+
node: TreeItem;
|
|
26
|
+
}
|
|
27
|
+
interface SectionTemplateStore {
|
|
28
|
+
/** The designed templates, newest first. A card with no design yet is left
|
|
29
|
+
* out: there is nothing to insert. */
|
|
30
|
+
list(): Promise<SectionTemplate[]>;
|
|
31
|
+
/** The record at `id`, designed or not; null when there is none. */
|
|
32
|
+
get(id: string): Promise<SectionTemplateRecord | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the template at `id` with its design, seeding `name` + the starter
|
|
35
|
+
* `node` when it has none. The admin generates the id when it adds a card
|
|
36
|
+
* (which may already exist, with no design yet) or opens a built-in block
|
|
37
|
+
* (`section-block-<type>`, which may not exist at all), and the shop seeds the
|
|
38
|
+
* design the first time the standalone editor opens it (create-on-first-open).
|
|
39
|
+
*/
|
|
40
|
+
ensure(id: string, name: string, node: TreeItem): Promise<SectionTemplate>;
|
|
41
|
+
/** Create a template from a section node; returns the stored record. */
|
|
42
|
+
save(name: string, node: TreeItem): Promise<SectionTemplate>;
|
|
43
|
+
/** Persist an edited section node (the standalone editor's autosave path). */
|
|
44
|
+
update(id: string, node: TreeItem): Promise<SectionTemplate>;
|
|
45
|
+
rename(id: string, name: string): Promise<SectionTemplateRecord>;
|
|
46
|
+
remove(id: string): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type { SectionTemplate, SectionTemplateRecord, SectionTemplateStore };
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SectionTemplateStore } from './section-template-types.js';
|
|
2
|
+
import './puck/content-tree.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The section templates of the editor on this page — whichever store its
|
|
6
|
+
* backend offers (`WebsiteBackend.sectionTemplates`).
|
|
7
|
+
*
|
|
8
|
+
* Under the EFFICIENT backend that is the store it always was
|
|
9
|
+
* (lib/api/section-templates, `/api/storefront/section-templates/`). Under an
|
|
10
|
+
* embedder's own backend it is the embedder's — and when that backend has none,
|
|
11
|
+
* it is an EMPTY store: nothing to list, so the Add panel draws no "Your
|
|
12
|
+
* templates" group, and nothing to open, so the standalone section editor says
|
|
13
|
+
* it could not open the section. No caller asks "is there a store?"; an empty
|
|
14
|
+
* one answers every question they have.
|
|
15
|
+
*
|
|
16
|
+
* Read per call, never captured: the editor is remounted for another website
|
|
17
|
+
* with another backend, and a store kept from the first mount would write one
|
|
18
|
+
* website's sections into the other's.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
declare const sectionTemplates: SectionTemplateStore;
|
|
22
|
+
|
|
23
|
+
export { sectionTemplates };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{sectionTemplates}from"../../chunk-4MXFKJUY.js";import"../../chunk-KDYIMJTZ.js";import"../../chunk-AJBJ74ME.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { EaselSession } from './session.js';
|
|
4
|
+
import '../../blocks/index.js';
|
|
5
|
+
import '../../types-E3HrTPg2.js';
|
|
6
|
+
import '../../data/index.js';
|
|
7
|
+
import '../../types-41704JE4.js';
|
|
8
|
+
import '../../resolve-D68pb3Bx.js';
|
|
9
|
+
import '../../plan-DChbUXdS.js';
|
|
10
|
+
import './host-chrome.js';
|
|
11
|
+
import './links/link-filters.js';
|
|
12
|
+
import '../../LinkPicker-W2Rtxetz.js';
|
|
13
|
+
import './document-contract.js';
|
|
14
|
+
import './document-hooks.js';
|
|
15
|
+
import './section-template-types.js';
|
|
16
|
+
import './puck/content-tree.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Hand `session` to the editor below, and make it the page's current one for
|
|
20
|
+
* as long as this is mounted (see `activateEaselSession` for why it happens in
|
|
21
|
+
* render AND in an effect).
|
|
22
|
+
*/
|
|
23
|
+
declare function EaselSessionProvider({ session, children }: {
|
|
24
|
+
session: EaselSession;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}): react.JSX.Element;
|
|
27
|
+
/** The session of the editor this component renders in. */
|
|
28
|
+
declare function useEaselSession(): EaselSession;
|
|
29
|
+
|
|
30
|
+
export { EaselSessionProvider, useEaselSession };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{EaselSessionProvider,useEaselSession}from"../../chunk-6TZTKAB5.js";import"../../chunk-AJBJ74ME.js";
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { Config } from '../../blocks/index.js';
|
|
2
|
+
import { EaselChrome } from './host-chrome.js';
|
|
3
|
+
import { WebsiteEditLock } from './document-contract.js';
|
|
4
|
+
import { EaselDocumentHooks } from './document-hooks.js';
|
|
5
|
+
import { SectionTemplateStore } from './section-template-types.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import '../../types-E3HrTPg2.js';
|
|
8
|
+
import '../../data/index.js';
|
|
9
|
+
import '../../types-41704JE4.js';
|
|
10
|
+
import '../../resolve-D68pb3Bx.js';
|
|
11
|
+
import '../../plan-DChbUXdS.js';
|
|
12
|
+
import './links/link-filters.js';
|
|
13
|
+
import '../../LinkPicker-W2Rtxetz.js';
|
|
14
|
+
import './puck/content-tree.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The editor SESSION — everything one mounted editor knows that no prop reaches:
|
|
18
|
+
* the backend it talks to, the console's sign-in, the website being edited, and
|
|
19
|
+
* the caches that belong to this editor and no other.
|
|
20
|
+
*
|
|
21
|
+
* Until efficient-web 0.4.0 each of those was a module singleton of its own
|
|
22
|
+
* (lib/editor-auth, lib/editor-site, lib/editor-site-slug, …), written by one
|
|
23
|
+
* part of the editor and read by another with nothing saying they belonged
|
|
24
|
+
* together. That holds while one editor is mounted for the life of the page. It
|
|
25
|
+
* stops holding the moment an embedder REMOUNTS the editor for a different
|
|
26
|
+
* website: the previous website's token, site id and cached answers were all
|
|
27
|
+
* still there, and nothing was the one place to clear them.
|
|
28
|
+
*
|
|
29
|
+
* So there is one object per mounted editor. The embedder's `EditorFrame`
|
|
30
|
+
* (packages/website/src/index.tsx) creates it when the editor mounts and lets it
|
|
31
|
+
* go when the editor unmounts; a new mount starts from an empty one.
|
|
32
|
+
*
|
|
33
|
+
* ONE EDITOR AT A TIME IS STILL THE RULE. Puck custom fields and the loaders
|
|
34
|
+
* they call render where no React context reaches, so they read the session of
|
|
35
|
+
* "the editor on this page" — {@link currentEaselSession}. Code that DOES sit
|
|
36
|
+
* under the editor's React tree reads its own session through
|
|
37
|
+
* `useEaselSession()` (lib/session-context), which is what keeps an
|
|
38
|
+
* editor's last writes — the autosave's flush on unmount, the lock's release —
|
|
39
|
+
* on its own backend and token while the next editor is already mounting.
|
|
40
|
+
*
|
|
41
|
+
* WHERE NO EDITOR IS MOUNTED — the shop's own pages, a dev harness, a guard —
|
|
42
|
+
* there is the AMBIENT session: the EFFICIENT client, no token until somebody
|
|
43
|
+
* sets one. That is exactly what the old singletons were.
|
|
44
|
+
*
|
|
45
|
+
* LEAF DISCIPLINE: no React, no HTTP client, no other module of this repo at
|
|
46
|
+
* runtime. lib/api reads the site id from here (through lib/editor-site), and
|
|
47
|
+
* the published site imports lib/api on the server.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* THE BACKEND, AS THE SESSION HOLDS IT: what the editor's own machinery reads
|
|
52
|
+
* of it, and nothing more. The rest is the layer's, read by the layer under
|
|
53
|
+
* its own type — the website's is `WebsiteBackend` (lib/web-backend), and it
|
|
54
|
+
* reads its sessions' backend as one through lib/website-session.
|
|
55
|
+
*
|
|
56
|
+
* The session is the screen's and moves into efficient-easel with it
|
|
57
|
+
* (doc/adr/0004), where a second editor hands it a backend of its own; so it
|
|
58
|
+
* names no website's backend. It keeps the object it was handed and hands that
|
|
59
|
+
* same object back, so a layer's backend loses nothing by passing through.
|
|
60
|
+
*/
|
|
61
|
+
interface SessionBackend {
|
|
62
|
+
/** Present when the documents it stores carry an advisory edit lock: the
|
|
63
|
+
* document's provider asks, of a page it is about to open, whether it has
|
|
64
|
+
* one to claim. */
|
|
65
|
+
lock?: WebsiteEditLock;
|
|
66
|
+
/** Where the editor's saved sections are kept (lib/section-templates).
|
|
67
|
+
* Without it there are none to list and none to open. */
|
|
68
|
+
sectionTemplates?: SectionTemplateStore;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The mark `createEfficientBackend` puts on what it returns, so a session can
|
|
72
|
+
* tell the EFFICIENT client from an embedder's own backend without importing it
|
|
73
|
+
* (lib/efficient-backend imports lib/api, which imports this module's readers).
|
|
74
|
+
* `Symbol.for`, so two copies of this module in one page agree; enumerable on
|
|
75
|
+
* the object, so `{ ...createEfficientBackend(), pages }` keeps it.
|
|
76
|
+
*/
|
|
77
|
+
declare const EFFICIENT_BACKEND: unique symbol;
|
|
78
|
+
/** Whether `backend` is (or is spread from) the EFFICIENT client. */
|
|
79
|
+
declare function isEfficientBackend(backend: SessionBackend | null | undefined): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* A host's choice of blocks, as the session carries it: the shape of the
|
|
82
|
+
* website's `EditorBlocks` (lib/editor-blocks, where the module comment says
|
|
83
|
+
* what each member does) with its set names as plain strings, so the screen's
|
|
84
|
+
* session names none of a layer's block sets (doc/adr/0004). The website's
|
|
85
|
+
* type is assignable to it; the website layer reads the sets back in its own
|
|
86
|
+
* terms (lib/editor-blocks `offeredSets`).
|
|
87
|
+
*/
|
|
88
|
+
interface SessionBlocks {
|
|
89
|
+
readonly sets?: readonly string[];
|
|
90
|
+
readonly allow?: readonly string[];
|
|
91
|
+
readonly deny?: readonly string[];
|
|
92
|
+
readonly host?: Readonly<Record<string, unknown>>;
|
|
93
|
+
readonly categories?: readonly {
|
|
94
|
+
key: string;
|
|
95
|
+
title: string;
|
|
96
|
+
components: string[];
|
|
97
|
+
before?: string;
|
|
98
|
+
}[];
|
|
99
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
100
|
+
}
|
|
101
|
+
interface EaselSession {
|
|
102
|
+
/**
|
|
103
|
+
* The backend the EMBEDDER supplied, or null when it supplied none — the
|
|
104
|
+
* host's default then (EFFICIENT's client, `provideDefaultBackend`). Read the
|
|
105
|
+
* backend in force through `backendOf(session)`, never from here.
|
|
106
|
+
*/
|
|
107
|
+
readonly hostBackend: SessionBackend | null;
|
|
108
|
+
/**
|
|
109
|
+
* Whether the backend is authorised by the console's bridged token (the
|
|
110
|
+
* `storefront-editor:auth` message). True for the EFFICIENT client; false for
|
|
111
|
+
* an embedder's own backend, which authorises its calls itself — the editor
|
|
112
|
+
* then waits for no token and may call it from its first render.
|
|
113
|
+
*/
|
|
114
|
+
readonly usesBridgedToken: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Which blocks the EMBEDDER chose to offer, and its own (lib/editor-blocks),
|
|
117
|
+
* or null when it chose nothing — every block then, as before the option
|
|
118
|
+
* existed. Read once, with the backend. `metadata` is the one member that is
|
|
119
|
+
* NOT read from here: it is followed live (lib/editor-block-metadata).
|
|
120
|
+
*/
|
|
121
|
+
readonly blocks: SessionBlocks | null;
|
|
122
|
+
/**
|
|
123
|
+
* The block registry this editor works from — the page root, the palette's
|
|
124
|
+
* groups and every block (lib/puck/registry). Whoever mounts the editor hands
|
|
125
|
+
* it over: the storefront's is `lib/puck/config`, with its commerce and
|
|
126
|
+
* service blocks registered among the general ones. The editor imports no
|
|
127
|
+
* registry of its own, so it never imports a block it does not own
|
|
128
|
+
* (doc/adr/0002). Read once, with the backend — through
|
|
129
|
+
* {@link sessionRegistry}, which refuses an editor that was handed none.
|
|
130
|
+
*/
|
|
131
|
+
readonly registry: Config | null;
|
|
132
|
+
/**
|
|
133
|
+
* What the host stands round the editor — its own providers, primers and
|
|
134
|
+
* panels, handed over as components (lib/host-chrome, doc/adr/0004) — or
|
|
135
|
+
* null when it brings none. Read once, with the backend.
|
|
136
|
+
*/
|
|
137
|
+
readonly chrome: EaselChrome | null;
|
|
138
|
+
/**
|
|
139
|
+
* What the host does to a document as it opens and as an edit is stored
|
|
140
|
+
* (lib/document-hooks) — the storefront seeds and feeds its catalogue
|
|
141
|
+
* blocks — or null when it does nothing. Read once, with the backend.
|
|
142
|
+
*/
|
|
143
|
+
readonly documentHooks: EaselDocumentHooks | null;
|
|
144
|
+
/** The console's sign-in: the admin JWT and the legacy brand scope. */
|
|
145
|
+
readonly auth: {
|
|
146
|
+
token: string | null;
|
|
147
|
+
brandId: string | null;
|
|
148
|
+
};
|
|
149
|
+
/** The website being edited — see lib/editor-site for why there are two. */
|
|
150
|
+
readonly site: {
|
|
151
|
+
documentId: string | null;
|
|
152
|
+
bridgedId: string | null;
|
|
153
|
+
};
|
|
154
|
+
/** `site.documentId ?? site.bridgedId`: the website a call is scoped to. */
|
|
155
|
+
siteId(): string | null;
|
|
156
|
+
/**
|
|
157
|
+
* One value per key for the life of this editor — a list fetched once, a
|
|
158
|
+
* lookup in flight. Dropped with the session, so the next editor (another
|
|
159
|
+
* website, another person) never reads this one's answers.
|
|
160
|
+
*/
|
|
161
|
+
cache<T>(key: string, make: () => T): T;
|
|
162
|
+
/** Forget one cached value, or all of them. */
|
|
163
|
+
forget(key?: string): void;
|
|
164
|
+
}
|
|
165
|
+
/** What makes the backend of a session whose embedder supplied none. */
|
|
166
|
+
type DefaultBackend = (session: EaselSession) => SessionBackend;
|
|
167
|
+
/**
|
|
168
|
+
* Name the backend an editor talks to when its embedder passes none. Called
|
|
169
|
+
* ONCE, by the host's own backend module as it loads: EFFICIENT's is
|
|
170
|
+
* `lib/efficient-backend`, which the storefront's registry imports.
|
|
171
|
+
*
|
|
172
|
+
* A registration rather than an import, because the direction matters: the
|
|
173
|
+
* editor is the builder's and a host's client is the host's (doc/adr/0002).
|
|
174
|
+
* It is one default for the app, not a choice per editor — an embedder that
|
|
175
|
+
* wants another backend for one editor passes `backend`, as before.
|
|
176
|
+
*/
|
|
177
|
+
declare function provideDefaultBackend(make: DefaultBackend): void;
|
|
178
|
+
/**
|
|
179
|
+
* The backend one editor session talks to: the embedder's own when it supplied
|
|
180
|
+
* one, else the host's default — one client per session, built the first time
|
|
181
|
+
* it is asked for and bound to THAT session's token and website.
|
|
182
|
+
*
|
|
183
|
+
* Throws when there is neither: an editor with no backend can load and save
|
|
184
|
+
* nothing, and falling back to "no pages" would look like an empty website.
|
|
185
|
+
*
|
|
186
|
+
* Typed as the session holds it ({@link SessionBackend}); the website's code
|
|
187
|
+
* reads the same object as its own through lib/website-session `backendOf`.
|
|
188
|
+
*/
|
|
189
|
+
declare function backendOf(session?: EaselSession): SessionBackend;
|
|
190
|
+
/**
|
|
191
|
+
* The registry an editor's session was created with. Throws on a session that
|
|
192
|
+
* was handed none: an editor with no registry has no blocks and no page root,
|
|
193
|
+
* and one that quietly fell back to SOME registry would draw a host's pages
|
|
194
|
+
* with holes where its own blocks belong.
|
|
195
|
+
*/
|
|
196
|
+
declare function sessionRegistry(session: EaselSession): Config;
|
|
197
|
+
declare function createEaselSession(options?: {
|
|
198
|
+
backend?: SessionBackend | null;
|
|
199
|
+
blocks?: SessionBlocks | null;
|
|
200
|
+
registry?: Config | null;
|
|
201
|
+
chrome?: EaselChrome | null;
|
|
202
|
+
documentHooks?: EaselDocumentHooks | null;
|
|
203
|
+
}): EaselSession;
|
|
204
|
+
/** Record the website a session's open document belongs to. */
|
|
205
|
+
declare function setSessionDocumentSite(session: EaselSession, siteId: string | null | undefined): void;
|
|
206
|
+
/** Record the website the host bridged in with an auth grant. */
|
|
207
|
+
declare function setSessionBridgedSite(session: EaselSession, siteId: string | null | undefined): void;
|
|
208
|
+
/** The session of the editor mounted on this page — the ambient one when none is. */
|
|
209
|
+
declare function currentEaselSession(): EaselSession;
|
|
210
|
+
/**
|
|
211
|
+
* Make `session` the page's current one. IDEMPOTENT, and called from two places
|
|
212
|
+
* on purpose: while the editor RENDERS (so a child's effect — which runs before
|
|
213
|
+
* its parent's — already reads the right session) and from the editor's own
|
|
214
|
+
* effect (which is what survives React StrictMode's mount, unmount, mount).
|
|
215
|
+
*/
|
|
216
|
+
declare function activateEaselSession(session: EaselSession): void;
|
|
217
|
+
/**
|
|
218
|
+
* The editor that owned `session` unmounted.
|
|
219
|
+
*
|
|
220
|
+
* Deferred by a microtask rather than done at once: StrictMode unmounts and
|
|
221
|
+
* re-mounts every effect in one synchronous pass, children first, so clearing
|
|
222
|
+
* the session in the cleanup would leave the children's re-run effects reading
|
|
223
|
+
* the ambient session — the EFFICIENT client — in an editor that was given its
|
|
224
|
+
* own backend. A session that was activated again in the meantime, or that a
|
|
225
|
+
* newer editor has already replaced, is left alone.
|
|
226
|
+
*
|
|
227
|
+
* The session OBJECT is not emptied: the unmounting editor's own last calls (a
|
|
228
|
+
* final autosave, the lock's release) hold it by reference and still need its
|
|
229
|
+
* backend and token. It is simply no longer the page's current one, and is
|
|
230
|
+
* collected with the closures that hold it.
|
|
231
|
+
*/
|
|
232
|
+
declare function deactivateEaselSession(session: EaselSession): void;
|
|
233
|
+
/**
|
|
234
|
+
* Whether this repo's own HTTP client has a server to talk to on this page.
|
|
235
|
+
*
|
|
236
|
+
* It always has — except while the mounted editor runs over an EMBEDDER'S OWN
|
|
237
|
+
* backend (doc/adr/0002). The sections and settings that still call the
|
|
238
|
+
* EFFICIENT API by themselves (the catalog a product grid lists, the cart's
|
|
239
|
+
* bundles, a link picker's blog posts) would then be asking a server that is
|
|
240
|
+
* not there: the embedder's origin, which serves none of those routes and
|
|
241
|
+
* whose users hold no EFFICIENT session. So the client is CLOSED for that
|
|
242
|
+
* editor — `apiFetch` and the two shop-origin fetchers refuse before they touch
|
|
243
|
+
* the network, exactly as they fail when the server is unreachable, and every
|
|
244
|
+
* caller degrades the way it already does for an outage.
|
|
245
|
+
*
|
|
246
|
+
* This is what makes "the package itself makes no request" true by construction
|
|
247
|
+
* under an embedder's backend, rather than true of the call sites somebody
|
|
248
|
+
* remembered to gate. On the published site, the shop's own pages and under the
|
|
249
|
+
* EFFICIENT backend it is always open.
|
|
250
|
+
*/
|
|
251
|
+
declare function efficientClientOpen(): boolean;
|
|
252
|
+
/** Start the ambient session again from nothing (tests; a guard between cases). */
|
|
253
|
+
declare function resetAmbientEaselSession(): void;
|
|
254
|
+
|
|
255
|
+
export { EFFICIENT_BACKEND, type EaselSession, type SessionBackend, type SessionBlocks, activateEaselSession, backendOf, createEaselSession, currentEaselSession, deactivateEaselSession, efficientClientOpen, isEfficientBackend, provideDefaultBackend, resetAmbientEaselSession, sessionRegistry, setSessionBridgedSite, setSessionDocumentSite };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{EFFICIENT_BACKEND,activateEaselSession,backendOf,createEaselSession,currentEaselSession,deactivateEaselSession,efficientClientOpen,isEfficientBackend,provideDefaultBackend,resetAmbientEaselSession,sessionRegistry,setSessionBridgedSite,setSessionDocumentSite}from"../../chunk-AJBJ74ME.js";
|