@sevenfold/setto-client 0.45.0 → 0.46.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 +1 -1
- package/dist/lib/visitor-view.d.ts +23 -0
- package/dist/provider.d.ts +8 -3
- package/dist/setto-client.js +11 -4
- package/dist/setto-client.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/support-session.d.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SettoLanguages } from './LanguageSwitcher.js';
|
|
2
2
|
export { DEFAULT_LANGUAGE, languageName, pickInitialLanguage, siteLanguages, } from './lib/languages.js';
|
|
3
3
|
export { alternateLinks, languageFromPath, pathForLanguage, redirectForVisitor, type LanguageRoute, } from './lib/language-routing.js';
|
|
4
|
-
export { SettoProvider, useSetto } from './provider.js';
|
|
4
|
+
export { SettoProvider, useSetto, useVisitorView } from './provider.js';
|
|
5
5
|
export { GuestEditProvider, useGuestEdit } from './guest-edit.js';
|
|
6
6
|
export { SettoChrome, useSettoChromeSlot } from './chrome.js';
|
|
7
7
|
export type { SettoChromeHandshake } from './chrome.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the page is being looked at by a visitor only, so a site may rewrite
|
|
3
|
+
* its own text in the DOM: GSAP's SplitText, a typewriter, anything that moves
|
|
4
|
+
* or replaces the nodes React put there.
|
|
5
|
+
*
|
|
6
|
+
* Text inside `<T>` belongs to React. Rewritten under it, React later removes
|
|
7
|
+
* a node that is no longer where it left it, and the whole page goes blank:
|
|
8
|
+
* that is what turning on editing did to a site whose headline SplitText had
|
|
9
|
+
* split and reverted (2026-10-26). An owner can switch editing on at any
|
|
10
|
+
* moment, so for them the answer is no for the whole visit.
|
|
11
|
+
*
|
|
12
|
+
* `null` while it is not known yet: the session is being read, or the site's
|
|
13
|
+
* membership fetched. A site waits for `true` before it rewrites anything,
|
|
14
|
+
* which for a visitor is a moment after the first paint.
|
|
15
|
+
*/
|
|
16
|
+
export declare function visitorView(state: {
|
|
17
|
+
authLoading: boolean;
|
|
18
|
+
hasSession: boolean;
|
|
19
|
+
/** Null while the signed-in person's sites are being fetched. */
|
|
20
|
+
sitesLoaded: boolean;
|
|
21
|
+
canEdit: boolean;
|
|
22
|
+
guestEdit: boolean;
|
|
23
|
+
}): boolean | null;
|
package/dist/provider.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface SettoContextValue {
|
|
|
61
61
|
* Exported for one caller: the chrome bundle.
|
|
62
62
|
*
|
|
63
63
|
* The dashboard is compiled into that bundle, so its `useSetto` reads *this*
|
|
64
|
-
* module's context
|
|
64
|
+
* module's context — a different instance from the one the host provider
|
|
65
65
|
* fills, which would otherwise throw "must be used within SettoProvider" the
|
|
66
66
|
* moment it rendered. Handing it the host's value through this provider is
|
|
67
67
|
* what lets the same components run on either side of the boundary.
|
|
@@ -80,8 +80,7 @@ export interface SettoProviderProps {
|
|
|
80
80
|
* The owner may edit (`canEdit`) when ALL of:
|
|
81
81
|
* 1. There is an authenticated Supabase session.
|
|
82
82
|
* 2. The user has access to `config.siteId` in the Setto sites table.
|
|
83
|
-
* 3. The
|
|
84
|
-
* 4. The current path is not the `/setto` admin SPA.
|
|
83
|
+
* 3. The current path is not the `/setto` admin SPA.
|
|
85
84
|
*
|
|
86
85
|
* Once an editor signs in via `/setto` they stay signed in until they sign out
|
|
87
86
|
* there. Whether they are editing is their own switch (`setEditing`): the
|
|
@@ -89,3 +88,9 @@ export interface SettoProviderProps {
|
|
|
89
88
|
*/
|
|
90
89
|
export declare function SettoProvider({ config, children }: SettoProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
91
90
|
export declare function useSetto(): SettoContextValue;
|
|
91
|
+
/**
|
|
92
|
+
* True once it is known that nobody on this page can edit it, false for an
|
|
93
|
+
* owner, null until it is known. Wait for `true` before rewriting text in the
|
|
94
|
+
* DOM (SplitText and the like): see `lib/visitor-view.ts`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function useVisitorView(): boolean | null;
|
package/dist/setto-client.js
CHANGED
|
@@ -22014,9 +22014,11 @@ function useSiteAccess(supabase, session, siteId) {
|
|
|
22014
22014
|
}, [supabase, session, siteId]);
|
|
22015
22015
|
return state;
|
|
22016
22016
|
}
|
|
22017
|
-
function
|
|
22018
|
-
|
|
22019
|
-
|
|
22017
|
+
function visitorView(state) {
|
|
22018
|
+
if (state.authLoading) return null;
|
|
22019
|
+
if (!state.hasSession) return !state.guestEdit;
|
|
22020
|
+
if (!state.sitesLoaded) return null;
|
|
22021
|
+
return !state.canEdit && !state.guestEdit;
|
|
22020
22022
|
}
|
|
22021
22023
|
const CHROME_CONTRACT = 1;
|
|
22022
22024
|
function chromeUrl(apiUrl) {
|
|
@@ -37308,7 +37310,7 @@ function SettoProvider({ config, children }) {
|
|
|
37308
37310
|
pageStoreRef.current = new PageStore(bundledManifest(config.pages));
|
|
37309
37311
|
setStoreReady(true);
|
|
37310
37312
|
}, [i18n, config.theme, config.pages]);
|
|
37311
|
-
const canEdit = !!session &&
|
|
37313
|
+
const canEdit = !!session && !!access.currentSite && !onAdminRoute && !authLoading && !access.loading;
|
|
37312
37314
|
const [editing, setEditingState] = useState(() => readEditing(config.siteId));
|
|
37313
37315
|
const setEditing = useCallback(
|
|
37314
37316
|
(on) => {
|
|
@@ -37379,6 +37381,10 @@ function useSetto() {
|
|
|
37379
37381
|
}
|
|
37380
37382
|
return ctx;
|
|
37381
37383
|
}
|
|
37384
|
+
function useVisitorView() {
|
|
37385
|
+
const { authLoading, session, sites, canEdit, guestEdit } = useSetto();
|
|
37386
|
+
return visitorView({ authLoading, hasSession: !!session, sitesLoaded: sites !== null, canEdit, guestEdit });
|
|
37387
|
+
}
|
|
37382
37388
|
const INLINE_MARKER = "data-setto-languages-inline";
|
|
37383
37389
|
function SettoLanguages({ languages: given, inline = false }) {
|
|
37384
37390
|
const { i18n } = useTranslation();
|
|
@@ -41479,6 +41485,7 @@ export {
|
|
|
41479
41485
|
useSetto,
|
|
41480
41486
|
useSettoChromeSlot,
|
|
41481
41487
|
useSettoMenu,
|
|
41488
|
+
useVisitorView,
|
|
41482
41489
|
validateBlockTree,
|
|
41483
41490
|
visibleMenu,
|
|
41484
41491
|
wantsCheckout,
|