@sevenfold/setto-client 0.13.0 → 0.15.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/chrome.d.ts CHANGED
@@ -24,12 +24,25 @@ export interface SettoChromeHandshake {
24
24
  /**
25
25
  * The same, for the page at `/setto`.
26
26
  *
27
- * A second slot because the dashboard is not an overlay: it belongs in the
28
- * host's own route, where the customer navigated to it. Registering nothing
29
- * leaves the bundled dashboard in place, which is what keeps a chrome that
30
- * fails to load from taking the admin down with it.
27
+ * @deprecated Use `mountSlot('admin', …)`. Kept because a chrome bundle
28
+ * older than this file may still call it, and the whole point of this file
29
+ * is that it never has to change again.
31
30
  */
32
31
  mountAdmin: (Component: React.ComponentType) => void;
32
+ /**
33
+ * Offer a component for a named place in the host: `admin` for the page at
34
+ * `/setto`, `toolbar` for the editor's floating menu.
35
+ *
36
+ * Named rather than one method per surface, because every new method here
37
+ * costs a re-pin of the whole fleet — the exact price this file exists to
38
+ * avoid paying. A new surface is now a string the host already understands,
39
+ * or one it will simply ignore.
40
+ *
41
+ * Registering nothing leaves the host's own version in place. That is what
42
+ * keeps a chrome bundle that fails to load, or throws while rendering, from
43
+ * taking the editor down with it.
44
+ */
45
+ mountSlot: (name: string, Component: React.ComponentType) => void;
33
46
  /**
34
47
  * The host's own `useSetto`, callable from the chrome.
35
48
  *
@@ -58,6 +71,8 @@ export interface SettoChromeHandshake {
58
71
  } | null;
59
72
  sitesLoaded: boolean;
60
73
  editMode: boolean;
74
+ /** A signed-out visitor trying the editor on setto.no. */
75
+ guestEdit: boolean;
61
76
  authLoading: boolean;
62
77
  };
63
78
  /** Told whenever that state changes. Returns an unsubscribe. */
@@ -70,8 +85,11 @@ declare global {
70
85
  }
71
86
  }
72
87
  /**
73
- * What the host should render at `/setto`, or null while the chrome has not
74
- * offered anything. Callers fall back to their bundled dashboard.
88
+ * What the host should render in a named place, or null while the chrome has
89
+ * offered nothing — including after it offered something that threw. Callers
90
+ * render their own version when this is null; every one of them must have one.
75
91
  */
92
+ export declare function useSettoChromeSlot(name: string): React.ComponentType | null;
93
+ /** @deprecated Use `useSettoChromeSlot('admin')`. */
76
94
  export declare function useSettoAdminChrome(): React.ComponentType | null;
77
95
  export declare function SettoChrome(): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1 @@
1
+ export declare function ToolbarUnavailable(): import("react/jsx-runtime").JSX.Element | null;
@@ -1,16 +1,22 @@
1
- import { type ReactNode } from 'react';
2
- interface GuestEditContextValue {
3
- active: boolean;
4
- start: () => void;
5
- stop: () => void;
6
- }
1
+ import type { ReactNode } from 'react';
7
2
  /**
8
3
  * Lets visitors inline-edit a marketing site (e.g. setto.no) without auth —
9
4
  * text, section/block colours, icons and list items. Changes are session-only
10
5
  * and never published. Real Setto edit mode always takes precedence.
6
+ *
7
+ * A provider in name only since 2026-09-09: the state moved into the main
8
+ * context so the chrome could see it, and what is left here is the one thing
9
+ * guest mode adds — the section toolbar, over a page nobody is signed in to.
10
+ * The component comes from Setto like the rest of the editing chrome, so there
11
+ * is nothing to draw until it arrives, and nothing to draw at all if it does
12
+ * not. That is the right failure for a demo.
11
13
  */
12
14
  export declare function GuestEditProvider({ children }: {
13
15
  children: ReactNode;
14
16
  }): import("react/jsx-runtime").JSX.Element;
17
+ export interface GuestEditContextValue {
18
+ active: boolean;
19
+ start: () => void;
20
+ stop: () => void;
21
+ }
15
22
  export declare function useGuestEdit(): GuestEditContextValue;
16
- export {};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { SettoProvider, useSetto } from './provider';
2
2
  export { GuestEditProvider, useGuestEdit } from './guest-edit';
3
3
  export { SettoPreviewBar, isPreviewHost, previewBarState } from './preview-bar';
4
- export { SettoChrome } from './chrome';
4
+ export { SettoChrome, useSettoChromeSlot } from './chrome';
5
5
  export type { SettoChromeHandshake } from './chrome';
6
6
  export { T } from './T';
7
7
  export { SettoSection } from './SettoSection';
@@ -35,4 +35,10 @@ export { extractContentKeys, type ContentKeyRequirements, } from './block-tree/e
35
35
  export { BLOCK_REGISTRY, BLOCK_TYPES, nodeChildren } from './block-tree/registry';
36
36
  export type { BlockTypeMeta } from './block-tree/registry';
37
37
  export { SETTO_BASE, siteHomeUrl, isAdminRoute, isAdminDeploymentView, adminViewUrl, currentAdminView, isAdminPanelView, adminRedirectUrl, CHECKOUT_INTENT, checkoutIntentUrl, wantsCheckout, withoutCheckoutIntent, } from './lib/urls';
38
- export { IN_PROGRESS_STATUSES, isDeploymentInProgress, isDeploymentStale, STALE_PENDING_MS, STALE_BUILDING_MS, fetchInProgressDeploymentId, waitForDeploymentByCommit, useDeploymentStatus, PublishProgressBar, } from './edit-mode/deployment-status';
38
+ export { SettoMark } from './edit-mode/setto-mark';
39
+ export { isLinkContext } from './lib/link-context';
40
+ export { useCoarsePointer } from './lib/use-coarse-pointer';
41
+ export { FAB_SIZE, FAB_INSET } from './edit-mode/constants';
42
+ export { EMPTY_I18N_STORE_SNAPSHOT } from './lib/i18n-store';
43
+ export type { I18nStoreSnapshot } from './lib/i18n-store';
44
+ export { IN_PROGRESS_STATUSES, isDeploymentInProgress, isDeploymentStale, STALE_PENDING_MS, STALE_BUILDING_MS, fetchInProgressDeploymentId, waitForDeploymentByCommit, useDeploymentStatus, PublishProgressBar, PublishProgressSteps, } from './edit-mode/deployment-status';
@@ -56,6 +56,16 @@ export declare class I18nStore {
56
56
  namespace?: string;
57
57
  });
58
58
  snapshot(): I18nStoreSnapshot;
59
+ /**
60
+ * Put a locale file into i18next as the published baseline.
61
+ *
62
+ * Same reason as `languages`: the editor chrome cannot reach the live
63
+ * i18next instance from its own bundle, and this store already holds it.
64
+ * Deep and overwriting, which is what seeding a baseline means — the file
65
+ * from the repository is the truth, and any draft on top of it lives here,
66
+ * not in i18next.
67
+ */
68
+ addBaselineBundle(lng: string, resources: Record<string, unknown>): void;
59
69
  subscribe(listener: Listener): () => void;
60
70
  /**
61
71
  * Returns the current rendered value for a key in a given language,
@@ -111,7 +121,20 @@ export declare class I18nStore {
111
121
  serialiseBundles(): Record<string, unknown>;
112
122
  /** Runs `fn` and notifies consumers once, however many edits it makes. */
113
123
  batch(fn: () => void): void;
114
- private languages;
124
+ /**
125
+ * Every language this site has content for, in i18next's own order.
126
+ *
127
+ * Public because the editor chrome needs it and cannot get it the usual way:
128
+ * that code runs in a second bundle whose `react-i18next` is a different
129
+ * module instance from the host's, so its `useTranslation` finds no
130
+ * initialised i18next and reports no languages at all. This store is the
131
+ * host's own object, handed across by reference, and it already holds the
132
+ * live instance.
133
+ *
134
+ * Deduplicated, because i18next appends its fallback chain and every caller
135
+ * was doing that itself.
136
+ */
137
+ languages(fallback: string): string[];
115
138
  private valueOrUndefined;
116
139
  private setOrDelete;
117
140
  /** Every string key under `prefix`, nested to any depth. */
@@ -25,6 +25,18 @@ export interface SettoContextValue {
25
25
  store: I18nStore | null;
26
26
  themeStore: ThemeStore | null;
27
27
  assetStore: AssetStore | null;
28
+ /** The section the editor has selected, or null. */
29
+ selectedSectionId: string | null;
30
+ selectSection: (id: string | null) => void;
31
+ /**
32
+ * True while a signed-out visitor is trying the editor (setto.no).
33
+ *
34
+ * Here beside `editMode` rather than in `GuestEditProvider`'s own context
35
+ * for the same reason the selected section is: the chrome that draws the
36
+ * section toolbar sits above that provider and can call only `useSetto`.
37
+ */
38
+ guestEdit: boolean;
39
+ setGuestEdit: (on: boolean) => void;
28
40
  }
29
41
  /**
30
42
  * Exported for one caller: the chrome bundle.
@@ -1,10 +1,15 @@
1
- import { type ReactNode } from 'react';
2
- interface SectionEditContextValue {
1
+ /**
2
+ * Which section the editor has selected.
3
+ *
4
+ * A context of its own until 2026-09-09, when the section toolbar moved out to
5
+ * the chrome served by setto-server. That bundle can call exactly one hook of
6
+ * the host's — `useSetto` — so the state moved into the main context and this
7
+ * became an adapter. Kept because `SettoSection` and `SettoBlock` read it on
8
+ * every render of every page, and renaming that in thirteen pinned sites buys
9
+ * nothing.
10
+ */
11
+ export interface SectionEditContextValue {
3
12
  selectedId: string | null;
4
13
  selectSection: (id: string | null) => void;
5
14
  }
6
- export declare function SectionEditProvider({ children }: {
7
- children: ReactNode;
8
- }): import("react/jsx-runtime").JSX.Element;
9
15
  export declare function useSectionEdit(): SectionEditContextValue;
10
- export {};