@plitzi/sdk-shared 0.35.1 → 0.35.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 +22 -0
- package/dist/helpers/index.mjs +11 -10
- package/dist/helpers/twigWrapper/index.d.ts +1 -0
- package/dist/helpers/twigWrapper/index.mjs +2 -1
- package/dist/helpers/twigWrapper/templateRoots.d.ts +8 -0
- package/dist/helpers/twigWrapper/templateRoots.mjs +23 -0
- package/dist/index.mjs +59 -58
- package/dist/types/StoreTypes.d.ts +8 -2
- package/package.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.35.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 470aaf8: The theme is a data source, and a binding reads every source its template names.
|
|
8
|
+
|
|
9
|
+
- **`theme` global source.** `GlobalSources` publishes `runtime.sources.theme` as `{ mode, resolved }` for the area
|
|
10
|
+
the space paints in. `resolved` is always `light` or `dark`, so `{{ theme.resolved }}` is what a URL or a `when`
|
|
11
|
+
rule wants — a dashboard asking the API for a thumbnail in the visitor's scheme, for one. The comments that promised
|
|
12
|
+
`{{ theme.resolved }}` through the app store's `theme` mirror were wrong: nothing a binding reads lives there.
|
|
13
|
+
- **A binding subscribes to the roots of its `twigTemplate`.** It used to get only the head of its `source`, so a
|
|
14
|
+
binding on `list_spaces.item.id` whose template also said `{{ theme.resolved }}` or `{{ state.scope }}` resolved the
|
|
15
|
+
second name to nothing, silently. The names are read off the parsed template (`templateRootNames`, exported from
|
|
16
|
+
`@plitzi/sdk-shared/helpers/twigWrapper`). A name that is not a source is left out of the map rather than set to
|
|
17
|
+
`undefined`, so `{{ source }}` and the variables lifted to the template's root are never shadowed.
|
|
18
|
+
- **Authoring.** `theme` joins `GLOBAL_SOURCES`: `bind: { src: 'theme.resolved' }` is accepted, and an element can no
|
|
19
|
+
longer be named `theme`.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- v0.35.2
|
|
24
|
+
|
|
3
25
|
## 0.35.1
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { filters as e } from "./twigWrapper/filters/filters.mjs";
|
|
2
2
|
import { processTwig as t } from "./twigWrapper/processTwig/processTwig.mjs";
|
|
3
3
|
import { hasValidToken as n } from "./twigWrapper/tokens/hasValidToken.mjs";
|
|
4
|
-
import r from "./
|
|
5
|
-
import i from "./
|
|
6
|
-
import a from "./
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
4
|
+
import { templateRootNames as r } from "./twigWrapper/templateRoots.mjs";
|
|
5
|
+
import i from "./fetchManifest.mjs";
|
|
6
|
+
import a from "./generateFacade.mjs";
|
|
7
|
+
import o from "./syntaxHighlight.mjs";
|
|
8
|
+
import { formatDate as s, formatDateUTC as c, formatFromNow as l, formatUTCToLocal as u, getDurationMs as d, isDate as f, isValidFormat as p, parseDate as m, toUnixSeconds as h } from "./formatDate.mjs";
|
|
9
|
+
import { isUserEdit as g } from "./reducerOrigin.mjs";
|
|
10
|
+
import { evaluateRuleGroup as _ } from "./ruleEvaluator.mjs";
|
|
11
|
+
import { ParamsFromURL as v, delay as y, emptyObject as b, getDisplayName as x, getKeyDecoded as S, getPathsFromObeject as C, hexToRGB as w, isInViewport as T, makeId as E } from "./utils.mjs";
|
|
12
|
+
import { disableReactDevTools as D } from "./security.mjs";
|
|
13
|
+
import { createStripTypenameLink as O, stripTypenameDeep as k } from "./stripTypename.mjs";
|
|
14
|
+
export { v as ParamsFromURL, O as createStripTypenameLink, y as delay, D as disableReactDevTools, b as emptyObject, _ as evaluateRuleGroup, i as fetchManifest, e as filters, s as formatDate, c as formatDateUTC, l as formatFromNow, u as formatUTCToLocal, a as generateFacade, x as getDisplayName, d as getDurationMs, S as getKeyDecoded, C as getPathsFromObeject, n as hasValidToken, w as hexToRGB, f as isDate, T as isInViewport, g as isUserEdit, p as isValidFormat, E as makeId, m as parseDate, t as processTwig, k as stripTypenameDeep, o as syntaxHighlight, r as templateRootNames, h as toUnixSeconds };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { processTwig } from './processTwig';
|
|
2
2
|
export { hasValidToken } from './tokens/hasValidToken';
|
|
3
|
+
export { templateRootNames } from './templateRoots';
|
|
3
4
|
export { filters } from './filters/filters';
|
|
4
5
|
export type { ASTNode, Expression } from './AST';
|
|
5
6
|
export type { TwigFilter } from './filters/filters';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { filters as e } from "./filters/filters.mjs";
|
|
2
2
|
import { processTwig as t } from "./processTwig/processTwig.mjs";
|
|
3
3
|
import { hasValidToken as n } from "./tokens/hasValidToken.mjs";
|
|
4
|
-
|
|
4
|
+
import { templateRootNames as r } from "./templateRoots.mjs";
|
|
5
|
+
export { e as filters, n as hasValidToken, t as processTwig, r as templateRootNames };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every top-level name a template reads: `{{ theme.resolved }}` and `{% if state.open %}` both give their first segment.
|
|
3
|
+
*
|
|
4
|
+
* Read off the parsed template rather than matched with a pattern, so a name inside a filter argument, a ternary or a
|
|
5
|
+
* loop's collection counts, and one inside a string literal does not. Names the template binds itself — a loop
|
|
6
|
+
* variable, a `set` — come back too: they resolve to no source, and asking for a name that is not there costs nothing.
|
|
7
|
+
*/
|
|
8
|
+
export declare const templateRootNames: (template: string) => string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { resolveTokens as e } from "./TemplateCache/TemplateCache.mjs";
|
|
2
|
+
//#region src/helpers/twigWrapper/templateRoots.ts
|
|
3
|
+
var t = (e, n) => {
|
|
4
|
+
if (Array.isArray(e)) {
|
|
5
|
+
for (let r of e) t(r, n);
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (typeof e == "object" && e) {
|
|
9
|
+
if ("type" in e && e.type === "path" && "segments" in e && Array.isArray(e.segments)) {
|
|
10
|
+
let t = e.segments[0];
|
|
11
|
+
typeof t == "string" && n.add(t);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
for (let r of Object.values(e)) t(r, n);
|
|
15
|
+
}
|
|
16
|
+
}, n = (n) => {
|
|
17
|
+
let r = e(n);
|
|
18
|
+
if (!r) return [];
|
|
19
|
+
let i = /* @__PURE__ */ new Set();
|
|
20
|
+
return t(r.nodes ?? r.nodesWithSource, i), [...i];
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { n as templateRootNames };
|
package/dist/index.mjs
CHANGED
|
@@ -3,61 +3,62 @@ 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
5
|
import { hasValidToken as s } from "./helpers/twigWrapper/tokens/hasValidToken.mjs";
|
|
6
|
-
import c from "./
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import x from "./
|
|
13
|
-
import S from "./helpers/
|
|
14
|
-
import C from "./helpers/
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import
|
|
22
|
-
import Y from "./dataSource/
|
|
23
|
-
import X from "./dataSource/
|
|
24
|
-
import Z from "./dataSource/
|
|
25
|
-
import Q from "./dataSource/
|
|
26
|
-
import $ from "./
|
|
27
|
-
import
|
|
28
|
-
import te from "./devTools/
|
|
29
|
-
import ne
|
|
30
|
-
import ae from "./
|
|
31
|
-
import oe from "./
|
|
32
|
-
import se from "./hooks/
|
|
33
|
-
import ce
|
|
34
|
-
import {
|
|
35
|
-
import
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import Me from "./
|
|
41
|
-
import
|
|
42
|
-
import {
|
|
43
|
-
import Le from "./
|
|
44
|
-
import Re from "./network/
|
|
45
|
-
import
|
|
46
|
-
import He from "./network/
|
|
47
|
-
import Ue from "./network/graphql/builder/
|
|
48
|
-
import We from "./network/graphql/builder/
|
|
49
|
-
import Ge from "./network/graphql/
|
|
50
|
-
import Ke from "./network/graphql/sdk/
|
|
51
|
-
import qe from "./
|
|
52
|
-
import Je
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
import {
|
|
56
|
-
import gt from "./theme/
|
|
57
|
-
import _t
|
|
58
|
-
import yt from "./
|
|
59
|
-
import bt
|
|
60
|
-
import Ct from "./server/rsc/
|
|
61
|
-
import wt from "./server/rsc/
|
|
62
|
-
import
|
|
63
|
-
|
|
6
|
+
import { templateRootNames as c } from "./helpers/twigWrapper/templateRoots.mjs";
|
|
7
|
+
import l from "./builder/contexts/BuilderContext.mjs";
|
|
8
|
+
import { contexts_exports as u } from "./builder/contexts/index.mjs";
|
|
9
|
+
import { BODYLESS_METHODS as d, CONNECTOR_HTTP_METHODS as f, DEFAULT_READ_ENDPOINT as p, EMPTY_RESPONSE_METHODS as m, READ_ENDPOINT_NAMES as h, WRITE_ENDPOINT_NAMES as g } from "./connectors/constants.mjs";
|
|
10
|
+
import { connectorTokens as _, getConnectorTokens as v } from "./connectors/manifestTokens.mjs";
|
|
11
|
+
import { connectorPresets as y, emptyManifest as b } from "./connectors/presets.mjs";
|
|
12
|
+
import { validateConnectorManifest as x } from "./connectors/validateManifest.mjs";
|
|
13
|
+
import S from "./helpers/fetchManifest.mjs";
|
|
14
|
+
import C from "./helpers/generateFacade.mjs";
|
|
15
|
+
import w from "./helpers/syntaxHighlight.mjs";
|
|
16
|
+
import { formatDate as T, formatDateUTC as E, formatFromNow as D, formatUTCToLocal as O, getDurationMs as k, isDate as A, isValidFormat as j, parseDate as M, toUnixSeconds as N } from "./helpers/formatDate.mjs";
|
|
17
|
+
import { isUserEdit as P } from "./helpers/reducerOrigin.mjs";
|
|
18
|
+
import { evaluateRuleGroup as F } from "./helpers/ruleEvaluator.mjs";
|
|
19
|
+
import { ParamsFromURL as I, delay as L, emptyObject as R, getDisplayName as z, getKeyDecoded as B, getPathsFromObeject as V, hexToRGB as H, isInViewport as U, makeId as W } from "./helpers/utils.mjs";
|
|
20
|
+
import { disableReactDevTools as G } from "./helpers/security.mjs";
|
|
21
|
+
import { createStripTypenameLink as K, stripTypenameDeep as q } from "./helpers/stripTypename.mjs";
|
|
22
|
+
import J, { utilityOptions as Y } from "./dataSource/utility/index.mjs";
|
|
23
|
+
import X from "./dataSource/getBindingsDetails.mjs";
|
|
24
|
+
import Z from "./dataSource/helpers/getSourceName.mjs";
|
|
25
|
+
import Q from "./dataSource/hooks/useRegisterSource.mjs";
|
|
26
|
+
import $ from "./dataSource/resolveVariables.mjs";
|
|
27
|
+
import ee from "./devTools/DevToolsContext.mjs";
|
|
28
|
+
import { debugCookieName as te } from "./devTools/debugCookie.mjs";
|
|
29
|
+
import ne from "./devTools/interactionLog.mjs";
|
|
30
|
+
import re, { createStoreDevToolsLogger as ie, pConsole as ae } from "./devTools/utils/PlitziConsole.mjs";
|
|
31
|
+
import oe from "./elements/ComponentContext.mjs";
|
|
32
|
+
import se from "./hooks/useFontHead.mjs";
|
|
33
|
+
import ce from "./hooks/useNetwork.mjs";
|
|
34
|
+
import le, { PlitziServiceContext as ue, PlitziServiceProvider as de } from "./hooks/usePlitziServiceContext.mjs";
|
|
35
|
+
import { StyleVariableCategory as fe } from "./types/StyleTypes.mjs";
|
|
36
|
+
import pe, { EMPTY_STYLE_SCHEMA as me, StyleBindingsAllowed as he, baseDefaultValue as ge, inheritableAttributesBase as _e } from "./style/styleConstants.mjs";
|
|
37
|
+
import { fontLinkAssets as ve } from "./style/fontAssets.mjs";
|
|
38
|
+
import { SYSTEM_FONTS as ye, availableFonts as be, familiesInCss as xe, fontFamilyStack as Se, fontUrlResolver as Ce, fontsToHead as we, googleCss2Url as Te, googleTextSubsetUrl as Ee, isSafeFontUrl as De, primaryFamily as Oe } from "./style/fonts.mjs";
|
|
39
|
+
import { FontValidationError as ke, parseSpaceFont as Ae } from "./style/fontValidation.mjs";
|
|
40
|
+
import { fallbackForFamily as je, fontsFromCss as Me } from "./style/fontsFromCss.mjs";
|
|
41
|
+
import Ne from "./schema/SchemaContext.mjs";
|
|
42
|
+
import { EMPTY_SCHEMA as Pe, VARIABLE_REGEX as Fe } from "./schema/schemaConstants.mjs";
|
|
43
|
+
import { collectServerElements as Ie, hasServerElements as Le } from "./schema/serverElements.mjs";
|
|
44
|
+
import Re from "./network/NetworkContext.mjs";
|
|
45
|
+
import ze from "./network/NetworkInternalContext.mjs";
|
|
46
|
+
import { SpaceEvents as Be, spaceEventSchemas as Ve, validateSpaceEvent as He } from "./network/spaceEvents.mjs";
|
|
47
|
+
import Ue from "./network/graphql/builder/Mutations/index.mjs";
|
|
48
|
+
import We from "./network/graphql/builder/Queries/index.mjs";
|
|
49
|
+
import Ge from "./network/graphql/builder/Subscriptions/index.mjs";
|
|
50
|
+
import Ke from "./network/graphql/sdk/Mutations/index.mjs";
|
|
51
|
+
import qe from "./network/graphql/sdk/Queries/index.mjs";
|
|
52
|
+
import Je from "./segments/SegmentsContext.mjs";
|
|
53
|
+
import Ye, { RTEvent as Xe, RTEventCloseCode as Ze, getInstance as Qe, isRTEvent as $e, setInstance as et } from "./websockets/RTCodec.mjs";
|
|
54
|
+
import { THEME_CLASSES as tt, THEME_COOKIE_NAME as nt, applyThemeClass as rt, isTheme as it, readThemeCookie as at, themeFromCookies as ot, writeThemeCookie as st } from "./theme/themeCookie.mjs";
|
|
55
|
+
import ct, { createThemeState as lt, createThemeStore as ut, resolveScheme as dt, setAreaTheme as ft, setMachineScheme as pt, setThemeMode as mt, themeFor as ht } from "./theme/themeStore.mjs";
|
|
56
|
+
import { useThemeStore as gt } from "./theme/ThemeScope.mjs";
|
|
57
|
+
import _t from "./theme/ThemeProvider.mjs";
|
|
58
|
+
import vt, { SPACE_THEME_AREA as yt } from "./theme/useTheme.mjs";
|
|
59
|
+
import bt from "./server/actions/useActionsSync.mjs";
|
|
60
|
+
import xt, { currentRscLocation as St, rscDataPath as Ct } from "./server/rsc/refreshRsc.mjs";
|
|
61
|
+
import wt from "./server/rsc/useRscRefresh.mjs";
|
|
62
|
+
import Tt from "./server/rsc/useRscSync.mjs";
|
|
63
|
+
import { runtimeStatePersist as Et } from "./state/runtimeStatePersist.mjs";
|
|
64
|
+
export { d as BODYLESS_METHODS, l as BuilderContext, Ue as BuilderMutations, We as BuilderQueries, f as CONNECTOR_HTTP_METHODS, oe as ComponentContext, p as DEFAULT_READ_ENDPOINT, ee as DevToolsContext, m as EMPTY_RESPONSE_METHODS, Pe as EMPTY_SCHEMA, me as EMPTY_STYLE_SCHEMA, ke as FontValidationError, Re as NetworkContext, ze as NetworkInternalContext, I as ParamsFromURL, re as PlitziConsole, ue as PlitziServiceContext, de as PlitziServiceProvider, h as READ_ENDPOINT_NAMES, Ye as RTCodec, Xe as RTEvent, Ze as RTEventCloseCode, yt as SPACE_THEME_AREA, ye as SYSTEM_FONTS, Ne as SchemaContext, Ke as SdkMutations, qe as SdkQueries, Je as SegmentsContext, Ge as SpaceEventSubscription, Be as SpaceEvents, he as StyleBindingsAllowed, fe as StyleVariableCategory, tt as THEME_CLASSES, nt as THEME_COOKIE_NAME, _t as ThemeProvider, Fe as VARIABLE_REGEX, g as WRITE_ENDPOINT_NAMES, rt as applyThemeClass, e as authFailureFromResponse, be as availableFonts, ge as baseDefaultValue, Ie as collectServerElements, y as connectorPresets, _ as connectorTokens, u as contexts, i as createAuthFailureLink, ie as createStoreDevToolsLogger, K as createStripTypenameLink, lt as createThemeState, ut as createThemeStore, St as currentRscLocation, te as debugCookieName, L as delay, G as disableReactDevTools, b as emptyManifest, R as emptyObject, F as evaluateRuleGroup, je as fallbackForFamily, xe as familiesInCss, S as fetchManifest, a as filters, Se as fontFamilyStack, ve as fontLinkAssets, Ce as fontUrlResolver, Me as fontsFromCss, we as fontsToHead, T as formatDate, E as formatDateUTC, D as formatFromNow, O as formatUTCToLocal, C as generateFacade, X as getBindingsDetails, v as getConnectorTokens, z as getDisplayName, k as getDurationMs, Qe as getInstance, B as getKeyDecoded, V as getPathsFromObeject, Z as getSourceName, Te as googleCss2Url, Ee as googleTextSubsetUrl, Le as hasServerElements, s as hasValidToken, H as hexToRGB, _e as inheritableAttributesBase, A as isDate, U as isInViewport, ne as isInteractionFlow, $e as isRTEvent, De as isSafeFontUrl, it as isTheme, P as isUserEdit, j as isValidFormat, W as makeId, t as onAuthFailure, ae as pConsole, M as parseDate, Ae as parseSpaceFont, Oe as primaryFamily, o as processTwig, at as readThemeCookie, xt as refreshRsc, n as reportAuthFailure, dt as resolveScheme, $ as resolveVariables, Ct as rscDataPath, Et as runtimeStatePersist, r as sameRegistrableDomain, ft as setAreaTheme, et as setInstance, pt as setMachineScheme, mt as setThemeMode, Ve as spaceEventSchemas, q as stripTypenameDeep, pe as styleConstants, w as syntaxHighlight, c as templateRootNames, ht as themeFor, ot as themeFromCookies, ct as themeStore, N as toUnixSeconds, bt as useActionsSync, se as useFontHead, ce as useNetwork, le as usePlitziServiceContext, Q as useRegisterSource, wt as useRscRefresh, Tt as useRscSync, vt as useTheme, gt as useThemeStore, J as utility, Y as utilityOptions, x as validateConnectorManifest, He as validateSpaceEvent, st as writeThemeCookie };
|
|
@@ -17,6 +17,10 @@ export type RuntimeSourceValues = {
|
|
|
17
17
|
auth?: Record<string, unknown>;
|
|
18
18
|
state?: Record<string, unknown>;
|
|
19
19
|
host?: Record<string, unknown>;
|
|
20
|
+
theme?: {
|
|
21
|
+
mode: Theme;
|
|
22
|
+
resolved: ColorScheme;
|
|
23
|
+
};
|
|
20
24
|
};
|
|
21
25
|
export type CommonState = {
|
|
22
26
|
prevSchema?: Schema;
|
|
@@ -42,8 +46,10 @@ export type CommonState = {
|
|
|
42
46
|
actions?: ActionsState;
|
|
43
47
|
render?: RenderSettings;
|
|
44
48
|
/**
|
|
45
|
-
* The theme, mirrored from `themeStore` so
|
|
46
|
-
*
|
|
49
|
+
* The theme, mirrored from `themeStore` so the devtools store viewer answers "which theme is this" in one line.
|
|
50
|
+
*
|
|
51
|
+
* Bindings and `when` rules do NOT read this copy: like every other global they read `runtime.sources`, where
|
|
52
|
+
* `GlobalSources` publishes the `theme` source for the area the space paints in.
|
|
47
53
|
*
|
|
48
54
|
* A MIRROR and never the source. The theme has to be readable by things that are not under any provider — the
|
|
49
55
|
* dev-tools panel in its shadow root, an editor in a portal — which no app store can serve, so `themeStore` owns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-shared",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.2",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -400,6 +400,10 @@
|
|
|
400
400
|
"types": "./dist/helpers/twigWrapper/processTwig/processTwig.d.ts",
|
|
401
401
|
"import": "./dist/helpers/twigWrapper/processTwig/processTwig.mjs"
|
|
402
402
|
},
|
|
403
|
+
"./helpers/twigWrapper/templateRoots": {
|
|
404
|
+
"types": "./dist/helpers/twigWrapper/templateRoots.d.ts",
|
|
405
|
+
"import": "./dist/helpers/twigWrapper/templateRoots.mjs"
|
|
406
|
+
},
|
|
403
407
|
"./helpers/twigWrapper/tokens/hasValidToken": {
|
|
404
408
|
"types": "./dist/helpers/twigWrapper/tokens/hasValidToken.d.ts",
|
|
405
409
|
"import": "./dist/helpers/twigWrapper/tokens/hasValidToken.mjs"
|