@sevenfold/setto-client 0.47.0 → 0.49.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/LanguageSwitcher.d.ts +11 -0
- package/dist/blog/SettoBlog.d.ts +18 -1
- package/dist/chunks/{SettoChat-C4QpE5Gm.js → SettoChat-SqJlsGXL.js} +42 -3
- package/dist/chunks/{SettoChat-C4QpE5Gm.js.map → SettoChat-SqJlsGXL.js.map} +1 -1
- package/dist/modules/chat/SettoChat.d.ts +3 -0
- package/dist/modules/chat/realtime.d.ts +17 -0
- package/dist/setto-client.js +46 -16
- package/dist/setto-client.js.map +1 -1
- package/dist/vite/static.d.ts +3 -1
- package/dist/vite.js +11 -4
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
|
@@ -42,6 +42,9 @@ export type NearbyHuman = {
|
|
|
42
42
|
no?: string | null;
|
|
43
43
|
en?: string | null;
|
|
44
44
|
} | null;
|
|
45
|
+
/** When they stop being online, and drop off the list (setto-server 0.121); absent from an older server. */
|
|
46
|
+
onlineUntil?: string | null;
|
|
47
|
+
nearbyUntil?: string | null;
|
|
45
48
|
};
|
|
46
49
|
/** The browser's language for the server's translation, within its 35-character limit. */
|
|
47
50
|
export declare function browserLanguage(): string | undefined;
|
|
@@ -102,3 +102,20 @@ export type RefreshTicket = {
|
|
|
102
102
|
export declare function refreshOutcome(started: RefreshTicket, current: RefreshTicket & {
|
|
103
103
|
busy: boolean;
|
|
104
104
|
}): 'apply' | 'defer' | 'drop';
|
|
105
|
+
/** Who is near the chat, read this often without the presence doorbell (as before 0.48). */
|
|
106
|
+
export declare const AVAILABILITY_POLL_MS = 30000;
|
|
107
|
+
/** And this often while it is subscribed: a safety net only. */
|
|
108
|
+
export declare const AVAILABILITY_POLL_LIVE_MS = 120000;
|
|
109
|
+
/** Only a server-issued presence topic is joined (setto-server 20261117090000). */
|
|
110
|
+
export declare function presenceTopic(value: unknown): string | null;
|
|
111
|
+
/**
|
|
112
|
+
* The next moment the list changes on its own: someone online stops being so,
|
|
113
|
+
* or someone drops off it. A lapsing lease writes nothing on the server, so
|
|
114
|
+
* nothing rings then; the widget reads the list again at this moment. Null
|
|
115
|
+
* when no such moment is ahead (an older server sends neither field).
|
|
116
|
+
*/
|
|
117
|
+
export declare function nextAvailabilityChange(humans: ReadonlyArray<{
|
|
118
|
+
online: boolean;
|
|
119
|
+
onlineUntil?: string | null;
|
|
120
|
+
nearbyUntil?: string | null;
|
|
121
|
+
}>, now: number): number | null;
|
package/dist/setto-client.js
CHANGED
|
@@ -1783,7 +1783,7 @@ const chatModule = {
|
|
|
1783
1783
|
label: "Chat"
|
|
1784
1784
|
};
|
|
1785
1785
|
const SettoChatWidget = lazy(
|
|
1786
|
-
() => import("./chunks/SettoChat-
|
|
1786
|
+
() => import("./chunks/SettoChat-SqJlsGXL.js").then((module) => ({ default: module.SettoChatWidget }))
|
|
1787
1787
|
);
|
|
1788
1788
|
class ChatBoundary extends Component {
|
|
1789
1789
|
state = { failed: false };
|
|
@@ -1933,6 +1933,7 @@ function SettoProvider({ config, children }) {
|
|
|
1933
1933
|
}, [i18n, languages]);
|
|
1934
1934
|
useEffect(() => {
|
|
1935
1935
|
if (languages.length < 2) return;
|
|
1936
|
+
if (document.head.querySelector('link[rel="alternate"][hreflang]:not([data-setto-alternate])')) return;
|
|
1936
1937
|
const links = alternateLinks(window.location.origin, window.location.pathname, languages);
|
|
1937
1938
|
const added = links.map(({ hreflang, href }) => {
|
|
1938
1939
|
const el = document.createElement("link");
|
|
@@ -1999,9 +2000,10 @@ function SettoProvider({ config, children }) {
|
|
|
1999
2000
|
guestEdit,
|
|
2000
2001
|
setGuestEdit
|
|
2001
2002
|
};
|
|
2003
|
+
const inlineLanguages = useRef({ drawn: false }).current;
|
|
2002
2004
|
const editShellActive = editMode && !!value.store;
|
|
2003
2005
|
const menuShown = canEdit && !!value.store;
|
|
2004
|
-
return /* @__PURE__ */ jsx(SettoContext.Provider, { value, children: /* @__PURE__ */ jsxs(
|
|
2006
|
+
return /* @__PURE__ */ jsx(SettoContext.Provider, { value, children: /* @__PURE__ */ jsxs(InlineLanguagesContext.Provider, { value: inlineLanguages, children: [
|
|
2005
2007
|
/* @__PURE__ */ jsx(EditModeShell, { active: editShellActive, menu: menuShown, themeStore: value.themeStore, children }),
|
|
2006
2008
|
/* @__PURE__ */ jsx(SettoChrome, {}),
|
|
2007
2009
|
/* @__PURE__ */ jsx(SettoChat, {}),
|
|
@@ -2035,6 +2037,7 @@ function useVisitorView() {
|
|
|
2035
2037
|
return visitorView({ authLoading, hasSession: !!session, sitesLoaded: sites !== null, canEdit, guestEdit });
|
|
2036
2038
|
}
|
|
2037
2039
|
const INLINE_MARKER = "data-setto-languages-inline";
|
|
2040
|
+
const InlineLanguagesContext = createContext(null);
|
|
2038
2041
|
function SettoLanguages({ languages: given, inline = false }) {
|
|
2039
2042
|
const { i18n } = useTranslation();
|
|
2040
2043
|
const setto = useContext(SettoContext);
|
|
@@ -2044,6 +2047,8 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
2044
2047
|
const [hover, setHover] = useState(false);
|
|
2045
2048
|
const [surface, setSurface] = useState(null);
|
|
2046
2049
|
const ref = useRef(null);
|
|
2050
|
+
const drawnInline = useContext(InlineLanguagesContext);
|
|
2051
|
+
if (inline && drawnInline) drawnInline.drawn = true;
|
|
2047
2052
|
useEffect(() => {
|
|
2048
2053
|
if (!inline) return;
|
|
2049
2054
|
const root = document.documentElement;
|
|
@@ -2128,7 +2133,8 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
2128
2133
|
] });
|
|
2129
2134
|
}
|
|
2130
2135
|
function AutoLanguageSwitcher({ languages }) {
|
|
2131
|
-
const
|
|
2136
|
+
const drawnInline = useContext(InlineLanguagesContext);
|
|
2137
|
+
const [inlineElsewhere, setInlineElsewhere] = useState(() => drawnInline?.drawn ?? false);
|
|
2132
2138
|
useEffect(() => {
|
|
2133
2139
|
const check = () => setInlineElsewhere(document.documentElement.hasAttribute(INLINE_MARKER));
|
|
2134
2140
|
check();
|
|
@@ -3775,15 +3781,16 @@ function YouTubeEmbed({ id, title, language }) {
|
|
|
3775
3781
|
] });
|
|
3776
3782
|
}
|
|
3777
3783
|
const LATEST_COUNT = 3;
|
|
3778
|
-
function useBlogContext() {
|
|
3784
|
+
function useBlogContext(path) {
|
|
3779
3785
|
const { config } = useSetto();
|
|
3780
3786
|
const { i18n, t } = useTranslation();
|
|
3781
3787
|
const manifest = usePageManifest();
|
|
3782
3788
|
const language = i18n.language || config.languages?.[0] || "no";
|
|
3783
3789
|
const fallbackLanguage = config.languages?.[0] ?? "no";
|
|
3784
|
-
const
|
|
3785
|
-
const
|
|
3786
|
-
|
|
3790
|
+
const languages = config.languages ?? [fallbackLanguage];
|
|
3791
|
+
const route = typeof window === "undefined" ? { basename: language === fallbackLanguage || !languages.includes(language) ? "" : `/${language}`, rest: "/" } : languageFromPath(window.location.pathname, languages);
|
|
3792
|
+
const href = (to) => `${route.basename}${to}`;
|
|
3793
|
+
return { config, t, manifest, language, fallbackLanguage, strings: blogStrings(language), path: path ?? route.rest, href };
|
|
3787
3794
|
}
|
|
3788
3795
|
function blogPathOf(manifest) {
|
|
3789
3796
|
return manifest && blogPage(manifest)?.page.path || BLOG_ROUTE;
|
|
@@ -3799,16 +3806,21 @@ function SettoBlogSection({ sectionId, first }) {
|
|
|
3799
3806
|
const clear = useClearFixedHeader(inner, first);
|
|
3800
3807
|
return /* @__PURE__ */ jsx(SettoSection, { sectionId, className: "setto-blog", children: /* @__PURE__ */ jsx("div", { className: "setto-blog__inner", ref: inner, style: clear ? { paddingTop: clear } : void 0, children: slug ? /* @__PURE__ */ jsx(BlogPostView, { slug, blogPath, ctx }) : /* @__PURE__ */ jsx(BlogIndexView, { title, first, blogPath, ctx }) }) });
|
|
3801
3808
|
}
|
|
3802
|
-
function SettoBlog({
|
|
3809
|
+
function SettoBlog({
|
|
3810
|
+
basePath = BLOG_ROUTE,
|
|
3811
|
+
title,
|
|
3812
|
+
path,
|
|
3813
|
+
initialPost
|
|
3814
|
+
}) {
|
|
3803
3815
|
useBlogStyles();
|
|
3804
|
-
const ctx = useBlogContext();
|
|
3816
|
+
const ctx = useBlogContext(path);
|
|
3805
3817
|
const base = normalisePath(basePath);
|
|
3806
3818
|
const here = normalisePath(ctx.path);
|
|
3807
3819
|
const rest = here.startsWith(`${base}/`) ? here.slice(base.length + 1) : "";
|
|
3808
3820
|
const slug = rest && isValidBlogSlug(rest) ? rest : null;
|
|
3809
3821
|
const inner = useRef(null);
|
|
3810
3822
|
const clear = useClearFixedHeader(inner, true);
|
|
3811
|
-
return /* @__PURE__ */ jsx("section", { className: "setto-blog", children: /* @__PURE__ */ jsx("div", { className: "setto-blog__inner", ref: inner, style: clear ? { paddingTop: clear } : void 0, children: slug ? /* @__PURE__ */ jsx(BlogPostView, { slug, blogPath: base, ctx }) : /* @__PURE__ */ jsx(BlogIndexView, { title: title ?? ctx.strings.blog, first: true, blogPath: base, ctx }) }) });
|
|
3823
|
+
return /* @__PURE__ */ jsx("section", { className: "setto-blog", children: /* @__PURE__ */ jsx("div", { className: "setto-blog__inner", ref: inner, style: clear ? { paddingTop: clear } : void 0, children: slug ? /* @__PURE__ */ jsx(BlogPostView, { slug, blogPath: base, ctx, initialPost }) : /* @__PURE__ */ jsx(BlogIndexView, { title: title ?? ctx.strings.blog, first: true, blogPath: base, ctx }) }) });
|
|
3812
3824
|
}
|
|
3813
3825
|
function useClearFixedHeader(ref, enabled) {
|
|
3814
3826
|
const [clear, setClear] = useState(0);
|
|
@@ -3868,16 +3880,31 @@ function PostCard({
|
|
|
3868
3880
|
] })
|
|
3869
3881
|
] });
|
|
3870
3882
|
}
|
|
3871
|
-
function
|
|
3883
|
+
function isPostFor(post, summary) {
|
|
3884
|
+
return !!post && !!summary && post.frontmatter.slug === summary.slug && post.frontmatter.locale === summary.locale;
|
|
3885
|
+
}
|
|
3886
|
+
function BlogPostView({
|
|
3887
|
+
slug,
|
|
3888
|
+
blogPath,
|
|
3889
|
+
ctx,
|
|
3890
|
+
initialPost
|
|
3891
|
+
}) {
|
|
3872
3892
|
const blog = ctx.config.blog;
|
|
3873
3893
|
const summary = blog ? postForSlug(blog.posts, slug, ctx.language, ctx.fallbackLanguage) : null;
|
|
3874
|
-
const [post, setPost] = useState(null);
|
|
3875
|
-
const [state, setState] = useState(
|
|
3894
|
+
const [post, setPost] = useState(() => isPostFor(initialPost, summary) ? initialPost : null);
|
|
3895
|
+
const [state, setState] = useState(
|
|
3896
|
+
() => !summary ? "missing" : isPostFor(initialPost, summary) ? "ready" : "loading"
|
|
3897
|
+
);
|
|
3876
3898
|
useEffect(() => {
|
|
3877
3899
|
if (!blog || !summary) {
|
|
3878
3900
|
setState("missing");
|
|
3879
3901
|
return;
|
|
3880
3902
|
}
|
|
3903
|
+
if (isPostFor(initialPost, summary)) {
|
|
3904
|
+
setPost(initialPost);
|
|
3905
|
+
setState("ready");
|
|
3906
|
+
return;
|
|
3907
|
+
}
|
|
3881
3908
|
let live = true;
|
|
3882
3909
|
setState("loading");
|
|
3883
3910
|
blog.load(summary.slug, summary.locale).then((loaded) => {
|
|
@@ -3902,7 +3929,7 @@ function BlogPostView({ slug, blogPath, ctx }) {
|
|
|
3902
3929
|
] });
|
|
3903
3930
|
}
|
|
3904
3931
|
const fm = post?.frontmatter ?? summary;
|
|
3905
|
-
return /* @__PURE__ */ jsx(PostArticle, { frontmatter: fm, ctx, before: back, after: /* @__PURE__ */ jsx(ShareBar, { title: fm.title, strings: ctx.strings }), children: state === "ready" && post ? /* @__PURE__ */ jsx(BlogBody, { nodes: post.body.children, language: ctx.language }) : /* @__PURE__ */ jsx("p", { className: "setto-blog__loading", "aria-live": "polite", children: ctx.strings.loading }) });
|
|
3932
|
+
return /* @__PURE__ */ jsx(PostArticle, { frontmatter: fm, ctx, before: back, after: /* @__PURE__ */ jsx(ShareBar, { title: fm.title, strings: ctx.strings }), children: state === "ready" && isPostFor(post, summary) ? /* @__PURE__ */ jsx(BlogBody, { nodes: post.body.children, language: ctx.language }) : /* @__PURE__ */ jsx("p", { className: "setto-blog__loading", "aria-live": "polite", children: ctx.strings.loading }) });
|
|
3906
3933
|
}
|
|
3907
3934
|
function PostArticle({
|
|
3908
3935
|
frontmatter: fm,
|
|
@@ -3947,8 +3974,11 @@ function usePostTitle(title, siteName) {
|
|
|
3947
3974
|
function ShareBar({ title, strings }) {
|
|
3948
3975
|
const [copied, setCopied] = useState(false);
|
|
3949
3976
|
const [native, setNative] = useState(false);
|
|
3950
|
-
|
|
3951
|
-
|
|
3977
|
+
const [url, setUrl] = useState("");
|
|
3978
|
+
useEffect(() => {
|
|
3979
|
+
setNative(typeof navigator !== "undefined" && typeof navigator.share === "function");
|
|
3980
|
+
setUrl(`${window.location.origin}${window.location.pathname}`);
|
|
3981
|
+
}, []);
|
|
3952
3982
|
const u = encodeURIComponent(url);
|
|
3953
3983
|
const t = encodeURIComponent(title);
|
|
3954
3984
|
return /* @__PURE__ */ jsxs("div", { className: "setto-blog__share", "aria-label": strings.share, children: [
|