@plitzi/sdk-shared 0.37.1 → 0.37.2
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/CHANGELOG.md +142 -0
- package/dist/actions/cron.d.ts +21 -12
- package/dist/actions/cron.mjs +48 -17
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.mjs +7 -7
- package/dist/actions/triggers.d.ts +4 -0
- package/dist/actions/triggers.mjs +4 -1
- package/dist/authoring/declare.d.ts +21 -0
- package/dist/dataSource/getBindingsDetails.mjs +21 -20
- package/dist/dataSource/utility/checkboxParams.d.ts +11 -0
- package/dist/dataSource/utility/checkboxParams.mjs +12 -0
- package/dist/helpers/index.mjs +13 -12
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +21 -6
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +1 -1
- package/dist/helpers/twigWrapper/filters/filters.mjs +10 -5
- package/dist/helpers/twigWrapper/index.d.ts +1 -0
- package/dist/helpers/twigWrapper/index.mjs +4 -3
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.d.ts +9 -0
- package/dist/helpers/twigWrapper/tokens/hasTemplateSyntax.mjs +4 -0
- package/dist/hooks/usePlitziServiceContext.d.ts +1 -1
- package/dist/index.mjs +64 -63
- package/dist/navigation/routes.mjs +27 -27
- package/dist/schema/serverElements.d.ts +5 -0
- package/dist/schema/serverElements.mjs +15 -14
- package/dist/state/index.mjs +2 -2
- package/dist/state/runtimeStatePersist.d.ts +17 -0
- package/dist/state/runtimeStatePersist.mjs +62 -9
- package/dist/store/index.d.ts +33 -33
- package/dist/theme/ThemeProvider.d.ts +1 -1
- package/dist/types/ActionTypes.d.ts +189 -0
- package/dist/types/ServerTypes.d.ts +52 -1
- package/dist/types/StoreTypes.d.ts +1 -1
- package/package.json +20 -12
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a string is written in template syntax at all — any `{{ … }}` or `{% … %}`, well-formed token or not.
|
|
3
|
+
*
|
|
4
|
+
* `hasValidToken` answers a narrower question on purpose: whether an ATTRIBUTE holds a token worth resolving, where
|
|
5
|
+
* the text around it is often prose and a stray `{{` must not be evaluated. A step's params are the other case: they
|
|
6
|
+
* are templates by construction, so a condition (`{{ admin ? '1' : '' }}`) or a loop (`{% for %}…{% endfor %}`) is
|
|
7
|
+
* meant to run — read by the narrow test they were handed on as written, and a flag stored its own template text.
|
|
8
|
+
*/
|
|
9
|
+
export declare const hasTemplateSyntax: (value: unknown) => value is string;
|
|
@@ -34,6 +34,6 @@ declare const usePlitziServiceContext: <TEventBridge = any, TInteractions = any>
|
|
|
34
34
|
declare const PlitziServiceProvider: (props: {
|
|
35
35
|
children?: ReactNode;
|
|
36
36
|
value: PlitziServiceContextValue;
|
|
37
|
-
}) => import(
|
|
37
|
+
}) => import('react').JSX.Element;
|
|
38
38
|
export { PlitziServiceProvider, PlitziServiceContext };
|
|
39
39
|
export default usePlitziServiceContext;
|
package/dist/index.mjs
CHANGED
|
@@ -2,66 +2,67 @@ import { authFailureFromResponse as e, onAuthFailure as t, reportAuthFailure as
|
|
|
2
2
|
import { createAuthFailureLink as i } from "./auth/authFailureLink.mjs";
|
|
3
3
|
import { filters as a } from "./helpers/twigWrapper/filters/filters.mjs";
|
|
4
4
|
import { processTwig as o } from "./helpers/twigWrapper/processTwig/processTwig.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import l from "./
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import S from "./
|
|
14
|
-
import C from "./helpers/
|
|
15
|
-
import w from "./helpers/
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import X from "./dataSource/
|
|
24
|
-
import Z from "./dataSource/
|
|
25
|
-
import Q from "./dataSource/
|
|
26
|
-
import $ from "./dataSource/
|
|
27
|
-
import ee from "./
|
|
28
|
-
import
|
|
29
|
-
import ne from "./devTools/
|
|
30
|
-
import re
|
|
31
|
-
import oe from "./
|
|
32
|
-
import se from "./
|
|
33
|
-
import ce from "./hooks/
|
|
34
|
-
import le
|
|
35
|
-
import fe from "./hooks/
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import Re from "./
|
|
44
|
-
import
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import Ge from "./
|
|
48
|
-
import Ke from "./network/
|
|
49
|
-
import
|
|
50
|
-
import Xe from "./network/
|
|
51
|
-
import Ze from "./network/graphql/builder/
|
|
52
|
-
import Qe from "./network/graphql/builder/
|
|
53
|
-
import $e from "./network/graphql/
|
|
54
|
-
import et from "./network/graphql/sdk/
|
|
55
|
-
import tt from "./
|
|
56
|
-
import nt
|
|
57
|
-
import
|
|
58
|
-
import
|
|
59
|
-
import {
|
|
60
|
-
import wt from "./theme/
|
|
61
|
-
import Tt
|
|
62
|
-
import Dt from "./
|
|
63
|
-
import Ot
|
|
64
|
-
import jt from "./server/rsc/
|
|
65
|
-
import Mt from "./server/rsc/
|
|
66
|
-
import
|
|
67
|
-
|
|
5
|
+
import { hasTemplateSyntax as s } from "./helpers/twigWrapper/tokens/hasTemplateSyntax.mjs";
|
|
6
|
+
import { hasValidToken as c } from "./helpers/twigWrapper/tokens/hasValidToken.mjs";
|
|
7
|
+
import { templateRootNames as l } from "./helpers/twigWrapper/templateRoots.mjs";
|
|
8
|
+
import u from "./builder/contexts/BuilderContext.mjs";
|
|
9
|
+
import { contexts_exports as d } from "./builder/contexts/index.mjs";
|
|
10
|
+
import { BODYLESS_METHODS as f, CONNECTOR_HTTP_METHODS as p, DEFAULT_READ_ENDPOINT as m, EMPTY_RESPONSE_METHODS as h, READ_ENDPOINT_NAMES as g, WRITE_ENDPOINT_NAMES as _ } from "./connectors/constants.mjs";
|
|
11
|
+
import { connectorTokens as v, getConnectorTokens as y } from "./connectors/manifestTokens.mjs";
|
|
12
|
+
import { connectorPresets as b, emptyManifest as x } from "./connectors/presets.mjs";
|
|
13
|
+
import { validateConnectorManifest as S } from "./connectors/validateManifest.mjs";
|
|
14
|
+
import C from "./helpers/fetchManifest.mjs";
|
|
15
|
+
import w from "./helpers/generateFacade.mjs";
|
|
16
|
+
import T from "./helpers/syntaxHighlight.mjs";
|
|
17
|
+
import { formatDate as E, formatDateUTC as D, formatFromNow as O, formatUTCToLocal as k, getDurationMs as A, isDate as j, isValidFormat as M, parseDate as N, toUnixSeconds as P } from "./helpers/formatDate.mjs";
|
|
18
|
+
import { isUserEdit as F } from "./helpers/reducerOrigin.mjs";
|
|
19
|
+
import { evaluateRuleGroup as I } from "./helpers/ruleEvaluator.mjs";
|
|
20
|
+
import { ParamsFromURL as L, delay as R, emptyObject as z, getDisplayName as B, getKeyDecoded as V, getPathsFromObeject as H, hexToRGB as U, isInViewport as W, makeId as G } from "./helpers/utils.mjs";
|
|
21
|
+
import { disableReactDevTools as K } from "./helpers/security.mjs";
|
|
22
|
+
import { createStripTypenameLink as q, stripTypenameDeep as J } from "./helpers/stripTypename.mjs";
|
|
23
|
+
import Y, { utilityOptions as X } from "./dataSource/utility/index.mjs";
|
|
24
|
+
import Z from "./dataSource/getBindingsDetails.mjs";
|
|
25
|
+
import Q from "./dataSource/helpers/getSourceName.mjs";
|
|
26
|
+
import $ from "./dataSource/hooks/useRegisterSource.mjs";
|
|
27
|
+
import ee from "./dataSource/resolveVariables.mjs";
|
|
28
|
+
import te from "./devTools/DevToolsContext.mjs";
|
|
29
|
+
import { debugCookieName as ne } from "./devTools/debugCookie.mjs";
|
|
30
|
+
import re from "./devTools/interactionLog.mjs";
|
|
31
|
+
import ie, { createStoreDevToolsLogger as ae, pConsole as oe } from "./devTools/utils/PlitziConsole.mjs";
|
|
32
|
+
import se from "./elements/ComponentContext.mjs";
|
|
33
|
+
import ce from "./hooks/useFontHead.mjs";
|
|
34
|
+
import le from "./hooks/useNetwork.mjs";
|
|
35
|
+
import ue, { PlitziServiceContext as de, PlitziServiceProvider as fe } from "./hooks/usePlitziServiceContext.mjs";
|
|
36
|
+
import pe from "./hooks/useStableValue.mjs";
|
|
37
|
+
import { StyleVariableCategory as me } from "./types/StyleTypes.mjs";
|
|
38
|
+
import he, { EMPTY_STYLE_SCHEMA as ge, StyleBindingsAllowed as _e, baseDefaultValue as ve, inheritableAttributesBase as ye } from "./style/styleConstants.mjs";
|
|
39
|
+
import { fontLinkAssets as be } from "./style/fontAssets.mjs";
|
|
40
|
+
import { SYSTEM_FONTS as xe, availableFonts as Se, familiesInCss as Ce, fontFamilyStack as we, fontUrlResolver as Te, fontsToHead as Ee, googleCss2Url as De, googleTextSubsetUrl as Oe, isSafeFontUrl as ke, primaryFamily as Ae } from "./style/fonts.mjs";
|
|
41
|
+
import { FontValidationError as je, parseSpaceFont as Me } from "./style/fontValidation.mjs";
|
|
42
|
+
import { fallbackForFamily as Ne, fontsFromCss as Pe } from "./style/fontsFromCss.mjs";
|
|
43
|
+
import { STYLE_STATES as Fe, STYLE_STATE_LABELS as Ie, inCascadeOrder as Le, isKnownState as Re } from "./style/styleStates.mjs";
|
|
44
|
+
import ze from "./schema/SchemaContext.mjs";
|
|
45
|
+
import { EMPTY_SCHEMA as Be, VARIABLE_REGEX as Ve } from "./schema/schemaConstants.mjs";
|
|
46
|
+
import { findLayoutCycle as He, resolveLayoutChain as Ue } from "./schema/layoutChain.mjs";
|
|
47
|
+
import { collectServerElements as We, hasServerElements as Ge } from "./schema/serverElements.mjs";
|
|
48
|
+
import Ke from "./network/NetworkContext.mjs";
|
|
49
|
+
import qe from "./network/NetworkInternalContext.mjs";
|
|
50
|
+
import { SpaceEvents as Je, spaceEventSchemas as Ye, validateSpaceEvent as Xe } from "./network/spaceEvents.mjs";
|
|
51
|
+
import Ze from "./network/graphql/builder/Mutations/index.mjs";
|
|
52
|
+
import Qe from "./network/graphql/builder/Queries/index.mjs";
|
|
53
|
+
import $e from "./network/graphql/builder/Subscriptions/index.mjs";
|
|
54
|
+
import et from "./network/graphql/sdk/Mutations/index.mjs";
|
|
55
|
+
import tt from "./network/graphql/sdk/Queries/index.mjs";
|
|
56
|
+
import nt from "./segments/SegmentsContext.mjs";
|
|
57
|
+
import rt, { RTEvent as it, RTEventCloseCode as at, getInstance as ot, isRTEvent as st, setInstance as ct } from "./websockets/RTCodec.mjs";
|
|
58
|
+
import { THEME_CLASSES as lt, THEME_COOKIE_NAME as ut, applyThemeClass as dt, isTheme as ft, readThemeCookie as pt, themeFromCookies as mt, writeThemeCookie as ht } from "./theme/themeCookie.mjs";
|
|
59
|
+
import gt, { createThemeState as _t, createThemeStore as vt, resolveScheme as yt, setAreaTheme as bt, setMachineScheme as xt, setThemeMode as St, themeFor as Ct } from "./theme/themeStore.mjs";
|
|
60
|
+
import { useThemeStore as wt } from "./theme/ThemeScope.mjs";
|
|
61
|
+
import Tt from "./theme/ThemeProvider.mjs";
|
|
62
|
+
import Et, { SPACE_THEME_AREA as Dt } from "./theme/useTheme.mjs";
|
|
63
|
+
import Ot from "./server/actions/useActionsSync.mjs";
|
|
64
|
+
import kt, { currentRscLocation as At, rscDataPath as jt } from "./server/rsc/refreshRsc.mjs";
|
|
65
|
+
import Mt from "./server/rsc/useRscRefresh.mjs";
|
|
66
|
+
import Nt from "./server/rsc/useRscSync.mjs";
|
|
67
|
+
import { runtimeStatePersist as Pt, stateOwner as Ft } from "./state/runtimeStatePersist.mjs";
|
|
68
|
+
export { f as BODYLESS_METHODS, u as BuilderContext, Ze as BuilderMutations, Qe as BuilderQueries, p as CONNECTOR_HTTP_METHODS, se as ComponentContext, m as DEFAULT_READ_ENDPOINT, te as DevToolsContext, h as EMPTY_RESPONSE_METHODS, Be as EMPTY_SCHEMA, ge as EMPTY_STYLE_SCHEMA, je as FontValidationError, Ke as NetworkContext, qe as NetworkInternalContext, L as ParamsFromURL, ie as PlitziConsole, de as PlitziServiceContext, fe as PlitziServiceProvider, g as READ_ENDPOINT_NAMES, rt as RTCodec, it as RTEvent, at as RTEventCloseCode, Dt as SPACE_THEME_AREA, Fe as STYLE_STATES, Ie as STYLE_STATE_LABELS, xe as SYSTEM_FONTS, ze as SchemaContext, et as SdkMutations, tt as SdkQueries, nt as SegmentsContext, $e as SpaceEventSubscription, Je as SpaceEvents, _e as StyleBindingsAllowed, me as StyleVariableCategory, lt as THEME_CLASSES, ut as THEME_COOKIE_NAME, Tt as ThemeProvider, Ve as VARIABLE_REGEX, _ as WRITE_ENDPOINT_NAMES, dt as applyThemeClass, e as authFailureFromResponse, Se as availableFonts, ve as baseDefaultValue, We as collectServerElements, b as connectorPresets, v as connectorTokens, d as contexts, i as createAuthFailureLink, ae as createStoreDevToolsLogger, q as createStripTypenameLink, _t as createThemeState, vt as createThemeStore, At as currentRscLocation, ne as debugCookieName, R as delay, K as disableReactDevTools, x as emptyManifest, z as emptyObject, I as evaluateRuleGroup, Ne as fallbackForFamily, Ce as familiesInCss, C as fetchManifest, a as filters, He as findLayoutCycle, we as fontFamilyStack, be as fontLinkAssets, Te as fontUrlResolver, Pe as fontsFromCss, Ee as fontsToHead, E as formatDate, D as formatDateUTC, O as formatFromNow, k as formatUTCToLocal, w as generateFacade, Z as getBindingsDetails, y as getConnectorTokens, B as getDisplayName, A as getDurationMs, ot as getInstance, V as getKeyDecoded, H as getPathsFromObeject, Q as getSourceName, De as googleCss2Url, Oe as googleTextSubsetUrl, Ge as hasServerElements, s as hasTemplateSyntax, c as hasValidToken, U as hexToRGB, Le as inCascadeOrder, ye as inheritableAttributesBase, j as isDate, W as isInViewport, re as isInteractionFlow, Re as isKnownState, st as isRTEvent, ke as isSafeFontUrl, ft as isTheme, F as isUserEdit, M as isValidFormat, G as makeId, t as onAuthFailure, oe as pConsole, N as parseDate, Me as parseSpaceFont, Ae as primaryFamily, o as processTwig, pt as readThemeCookie, kt as refreshRsc, n as reportAuthFailure, Ue as resolveLayoutChain, yt as resolveScheme, ee as resolveVariables, jt as rscDataPath, Pt as runtimeStatePersist, r as sameRegistrableDomain, bt as setAreaTheme, ct as setInstance, xt as setMachineScheme, St as setThemeMode, Ye as spaceEventSchemas, Ft as stateOwner, J as stripTypenameDeep, he as styleConstants, T as syntaxHighlight, l as templateRootNames, Ct as themeFor, mt as themeFromCookies, gt as themeStore, P as toUnixSeconds, Ot as useActionsSync, ce as useFontHead, le as useNetwork, ue as usePlitziServiceContext, $ as useRegisterSource, Mt as useRscRefresh, Nt as useRscSync, pe as useStableValue, Et as useTheme, wt as useThemeStore, Y as utility, X as utilityOptions, S as validateConnectorManifest, Xe as validateSpaceEvent, ht as writeThemeCookie };
|
|
@@ -1,45 +1,45 @@
|
|
|
1
1
|
import { matchPath as e } from "./matchPath.mjs";
|
|
2
2
|
//#region src/navigation/routes.ts
|
|
3
|
-
var t = (e) => /^https?:\/\//i.test(e), n = (e) => t(e) || e.includes("{{"), r = (e) => e.replace(/{{([a-zA-Z0-9-_:*/]+)}}/i, ":$1")
|
|
3
|
+
var t = (e) => /^https?:\/\//i.test(e), n = (e) => t(e) || e.includes("{{"), r = (e) => e.replaceAll(/\/+/g, "/"), i = (e) => r(e.replace(/{{([a-zA-Z0-9-_:*/]+)}}/i, ":$1")), a = (e, t) => {
|
|
4
4
|
if (!t || !e[t]) return "";
|
|
5
5
|
let { slug: n, parentId: r } = e[t];
|
|
6
|
-
return r ? `${
|
|
6
|
+
return r ? `${a(e, r)}/${n}` : n;
|
|
7
7
|
};
|
|
8
|
-
function
|
|
9
|
-
let { slug:
|
|
10
|
-
slug:
|
|
8
|
+
function o(e, t, n, o = !1) {
|
|
9
|
+
let s = n.replace(/^\/+/, ""), { slug: c = "", folder: l, default: u } = e[s]?.attributes ?? {
|
|
10
|
+
slug: s,
|
|
11
11
|
folder: "",
|
|
12
12
|
default: !1
|
|
13
13
|
};
|
|
14
|
-
if (
|
|
14
|
+
if (u && !o) return {
|
|
15
15
|
"/": n,
|
|
16
16
|
[`/${n}`]: n
|
|
17
17
|
};
|
|
18
|
-
if (
|
|
19
|
-
if (!
|
|
20
|
-
[
|
|
21
|
-
[`/${n}`]: n
|
|
18
|
+
if (u && o) return "/";
|
|
19
|
+
if (!l && !o) return {
|
|
20
|
+
[i(`/${c}`)]: n,
|
|
21
|
+
[i(`/${n}`)]: n
|
|
22
22
|
};
|
|
23
|
-
if (!
|
|
24
|
-
if (!t.find((e) => e.id ===
|
|
25
|
-
[
|
|
26
|
-
[`/${n}`]: n
|
|
23
|
+
if (!l && o) return r(`/${c}`);
|
|
24
|
+
if (!t.find((e) => e.id === l)) return o ? r(`/${c}`) : {
|
|
25
|
+
[i(`/${c}`)]: n,
|
|
26
|
+
[i(`/${n}`)]: n
|
|
27
27
|
};
|
|
28
|
-
let
|
|
28
|
+
let d = [a(t.reduce((e, t) => ({
|
|
29
29
|
...e,
|
|
30
30
|
[t.id]: t
|
|
31
|
-
}), {}),
|
|
32
|
-
return
|
|
33
|
-
[`/${
|
|
34
|
-
[`/${n}`]: n
|
|
31
|
+
}), {}), l), c].filter(Boolean).join("/");
|
|
32
|
+
return o ? r(`/${d}`) : {
|
|
33
|
+
[i(`/${d}`)]: n,
|
|
34
|
+
[i(`/${n}`)]: n
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
var
|
|
37
|
+
var s = (e, t, n = !0) => !e || !n || t === void 0 || t && e === "authenticated" || !t && e === "public" ? !0 : t && e === "public" ? !1 : !e, c = (e = {}, t = [], r, i = "", a = !0, c = !0) => {
|
|
38
38
|
let l = Object.keys(e).reduce((c, l) => {
|
|
39
39
|
let { attributes: { accessLevel: u, enabled: d = !0, unauthorizedBehaviour: f } } = e[l], p = e[l].attributes.unauthorizedPageRedirect;
|
|
40
|
-
if (!d &&
|
|
41
|
-
p &&= n(p) ? p :
|
|
42
|
-
let m =
|
|
40
|
+
if (!d && a) return c;
|
|
41
|
+
p &&= n(p) ? p : o(e, t, p, !0);
|
|
42
|
+
let m = o(e, t, l), h = Object.keys(m).map((e) => ({
|
|
43
43
|
pageId: l,
|
|
44
44
|
path: `${i}${e}`.replaceAll("//", "/"),
|
|
45
45
|
accessLevel: u,
|
|
@@ -47,7 +47,7 @@ var o = (e, t, n = !0) => !e || !n || t === void 0 || t && e === "authenticated"
|
|
|
47
47
|
isRaw: `/${l}` === e,
|
|
48
48
|
unauthorizedBehaviour: f,
|
|
49
49
|
unauthorizedPageRedirect: p,
|
|
50
|
-
hasAccess:
|
|
50
|
+
hasAccess: s(u, r, a)
|
|
51
51
|
}));
|
|
52
52
|
return [...c, ...h];
|
|
53
53
|
}, []).filter((e) => e.path !== "*" || e.hasAccess).sort((e, t) => e.path === t.path ? e.accessLevel === "authenticated" ? -1 : 1 : e.path > t.path ? -1 : 1);
|
|
@@ -63,7 +63,7 @@ var o = (e, t, n = !0) => !e || !n || t === void 0 || t && e === "authenticated"
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
return l;
|
|
66
|
-
},
|
|
66
|
+
}, l = (t, n, r) => {
|
|
67
67
|
if (!n) return {
|
|
68
68
|
action: {
|
|
69
69
|
type: "accessDenied",
|
|
@@ -119,6 +119,6 @@ var o = (e, t, n = !0) => !e || !n || t === void 0 || t && e === "authenticated"
|
|
|
119
119
|
},
|
|
120
120
|
pathMatch: void 0
|
|
121
121
|
};
|
|
122
|
-
},
|
|
122
|
+
}, u = (e) => !e || typeof e != "string" ? [] : (e.match(/:[a-zA-Z0-9-_:*]+/gim) || []).map((e) => e.replace(":", ""));
|
|
123
123
|
//#endregion
|
|
124
|
-
export {
|
|
124
|
+
export { o as getPageFullPath, c as getPaths, u as getRouteParams, t as isAbsoluteUrl, s as isPageAuthored, l as matchRoutePath };
|
|
@@ -10,6 +10,11 @@ import { Element, Schema } from '../types';
|
|
|
10
10
|
*
|
|
11
11
|
* The walk is iterative to stay safe on deeply nested schemas, and follows `definition.items`, so a server element
|
|
12
12
|
* nested under any number of plain containers is still found.
|
|
13
|
+
*
|
|
14
|
+
* **It starts from the page AND every shell around it.** A layout is rendered with the page — its sidebar, its header
|
|
15
|
+
* — so a server element that lives in one is on this page as far as the visitor can tell. Walked from the page alone,
|
|
16
|
+
* a provider in the dashboard's sidebar was never resolved: the payload came back empty, the element rendered with
|
|
17
|
+
* nothing, and no layer reported it.
|
|
13
18
|
*/
|
|
14
19
|
export declare const collectServerElements: (schema: Schema, pageId: string | undefined, ids?: string[]) => Element[];
|
|
15
20
|
/** Whether anything on this page consumes server data at all — the question both RSC gates actually ask. */
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
+
import { resolveLayoutChain as e } from "./layoutChain.mjs";
|
|
1
2
|
//#region src/schema/serverElements.ts
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
let
|
|
5
|
-
for (;
|
|
6
|
-
let
|
|
7
|
-
if (
|
|
8
|
-
|
|
9
|
-
let n =
|
|
3
|
+
var t = (t, n, r) => {
|
|
4
|
+
if (n === void 0) return [];
|
|
5
|
+
let i = r ? new Set(r) : void 0, a = [], o = /* @__PURE__ */ new Set(), s = t.flat[n], c = (e) => typeof e == "string" ? e : "", l = [n, ...s ? e((e) => t.flat[e], c(s.attributes.layout), c(s.attributes.layoutContainer)).map((e) => e.layout) : []];
|
|
6
|
+
for (; l.length > 0;) {
|
|
7
|
+
let e = l.pop();
|
|
8
|
+
if (e === void 0 || o.has(e)) continue;
|
|
9
|
+
o.add(e);
|
|
10
|
+
let n = t.flat[e];
|
|
10
11
|
if (!n) continue;
|
|
11
|
-
n.definition.runtime === "server" && (!
|
|
12
|
-
let { items:
|
|
13
|
-
|
|
12
|
+
n.definition.runtime === "server" && (!i || i.has(n.id)) && a.push(n);
|
|
13
|
+
let { items: r } = n.definition;
|
|
14
|
+
r && l.push(...r);
|
|
14
15
|
}
|
|
15
|
-
return
|
|
16
|
-
},
|
|
16
|
+
return a;
|
|
17
|
+
}, n = (e, n) => t(e, n).length > 0;
|
|
17
18
|
//#endregion
|
|
18
|
-
export {
|
|
19
|
+
export { t as collectServerElements, n as hasServerElements };
|
package/dist/state/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { runtimeStatePersist as e } from "./runtimeStatePersist.mjs";
|
|
2
|
-
export { e as runtimeStatePersist };
|
|
1
|
+
import { runtimeStatePersist as e, stateOwner as t } from "./runtimeStatePersist.mjs";
|
|
2
|
+
export { e as runtimeStatePersist, t as stateOwner };
|
|
@@ -1,3 +1,20 @@
|
|
|
1
1
|
import { CommonState } from '../types';
|
|
2
2
|
import { StoreMiddleware } from '@plitzi/nexus';
|
|
3
|
+
/**
|
|
4
|
+
* Who `runtime.state` belongs to.
|
|
5
|
+
*
|
|
6
|
+
* Read from the `auth` source GlobalSources publishes, which every auth provider feeds the same way — so this is the
|
|
7
|
+
* whole vocabulary, whatever a space signs people in with. A space with no accounts at all (no provider, or none of its
|
|
8
|
+
* auth published) has one owner, the browser. Otherwise it is the signed-in account, or the guest.
|
|
9
|
+
*/
|
|
10
|
+
export type StateOwner = {
|
|
11
|
+
kind: 'browser';
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'guest';
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'account';
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
18
|
+
/** `undefined` while auth has not settled: nothing kept can be told apart yet from somebody else's. */
|
|
19
|
+
export declare const stateOwner: (state: CommonState) => StateOwner | undefined;
|
|
3
20
|
export declare const runtimeStatePersist: <TState extends CommonState>(webId: number) => StoreMiddleware<TState>;
|
|
@@ -1,13 +1,66 @@
|
|
|
1
1
|
import { persistMiddleware as e } from "@plitzi/nexus";
|
|
2
2
|
//#region src/state/runtimeStatePersist.ts
|
|
3
|
-
var t =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
var t = /* @__PURE__ */ new Set([
|
|
4
|
+
"init",
|
|
5
|
+
"initLoading",
|
|
6
|
+
"authenticating"
|
|
7
|
+
]), n = (e) => {
|
|
8
|
+
let n = e.runtime?.sources.auth;
|
|
9
|
+
if (!n || n.status === void 0) return { kind: "browser" };
|
|
10
|
+
if (!t.has(n.status)) return n.isAuthenticated && n.details?.id !== void 0 ? {
|
|
11
|
+
kind: "account",
|
|
12
|
+
id: String(n.details.id)
|
|
13
|
+
} : { kind: "guest" };
|
|
14
|
+
}, r = (e) => {
|
|
15
|
+
switch (e.kind) {
|
|
16
|
+
case "account": return `user:${e.id}`;
|
|
17
|
+
case "guest": return "guest";
|
|
18
|
+
case "browser": return "";
|
|
10
19
|
}
|
|
11
|
-
})
|
|
20
|
+
}, i = (e, t) => ({
|
|
21
|
+
getItem: (n) => {
|
|
22
|
+
let r = e.getItem(n);
|
|
23
|
+
if (r === null) return null;
|
|
24
|
+
try {
|
|
25
|
+
let e = JSON.parse(r);
|
|
26
|
+
if (e.owner === t && typeof e.payload == "string") return e.payload;
|
|
27
|
+
} catch {}
|
|
28
|
+
return e.removeItem(n), null;
|
|
29
|
+
},
|
|
30
|
+
setItem: (n, r) => e.setItem(n, JSON.stringify({
|
|
31
|
+
owner: t,
|
|
32
|
+
payload: r
|
|
33
|
+
})),
|
|
34
|
+
removeItem: (t) => e.removeItem(t)
|
|
35
|
+
}), a = (e) => {
|
|
36
|
+
try {
|
|
37
|
+
return e === "session" ? globalThis.sessionStorage : globalThis.localStorage;
|
|
38
|
+
} catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
}, o = (t) => {
|
|
42
|
+
let o = e({
|
|
43
|
+
key: `plitzi_${t}_state`,
|
|
44
|
+
paths: ["runtime.state"],
|
|
45
|
+
storage: (e) => {
|
|
46
|
+
let { schema: t, render: o } = e;
|
|
47
|
+
if (o?.isHydrating && !o.hydrated) return !1;
|
|
48
|
+
let s = t?.settings, c = n(e);
|
|
49
|
+
if (!s?.keepState || c === void 0) return !1;
|
|
50
|
+
let l = a(s.stateStorage === "sessionStorage" ? "session" : "local");
|
|
51
|
+
return l ? i(l, r(c)) : !1;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return (e) => {
|
|
55
|
+
let t = o(e), i = e.getState().runtime?.state, a = n(e.getState());
|
|
56
|
+
return {
|
|
57
|
+
...t,
|
|
58
|
+
onChange: (o) => {
|
|
59
|
+
let s = a, c = n(e.getState());
|
|
60
|
+
c !== void 0 && (a = c), s?.kind === "account" && c !== void 0 && r(c) !== r(s) && e.setState("runtime.state", i), t?.onChange?.(o);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
12
65
|
//#endregion
|
|
13
|
-
export {
|
|
66
|
+
export { o as runtimeStatePersist, n as stateOwner };
|