@plitzi/sdk-shared 0.38.9 → 0.38.10
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 +81 -0
- package/dist/authoring/declare.d.ts +8 -0
- package/dist/index.mjs +24 -24
- package/dist/schema/index.mjs +3 -3
- package/dist/schema/serverElements.d.ts +26 -5
- package/dist/schema/serverElements.mjs +21 -13
- package/dist/theme/ThemeProvider.mjs +47 -38
- package/dist/theme/ThemeScope.d.ts +21 -1
- package/dist/theme/ThemeScope.mjs +7 -4
- package/dist/theme/index.mjs +5 -5
- package/dist/theme/themeStore.d.ts +6 -0
- package/dist/theme/themeStore.mjs +7 -4
- package/dist/theme/useTheme.mjs +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.38.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 200da2f: - **`focus-on-field-box`** (`@plitzi/sdk-authoring`): a warning for a `focus` or `focus-visible` state on a text
|
|
8
|
+
field's or a select's `input` slot. That slot is the box the field is drawn in, a `<div>` that never takes focus, so
|
|
9
|
+
the rule was never seen and a keyboard user tabbing to the field found no ring. The fix it names: `'focus-within'` on
|
|
10
|
+
the same class, or the state on the `field` slot.
|
|
11
|
+
- **`modalContainer` says how it is laid out** (`@plitzi/sdk-elements`): its description now names its slots and how
|
|
12
|
+
they sit — the dim layer and the dialog side by side, not one inside the other; the dialog centred by `top`/`left`
|
|
13
|
+
50% and a `translate`. A space styled the dim layer as a flex container to place the dialog, which moved nothing.
|
|
14
|
+
- **A field shows where the keyboard is** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`): a text field's or a select's
|
|
15
|
+
box is ringed (`2px solid currentColor`) while the field inside has keyboard focus, and a textarea while it has. No
|
|
16
|
+
text field or select showed any focus at all: the box had `outline: none`, and the field inherited it. One class of
|
|
17
|
+
specificity, so whatever a space writes about the outline wins; never in the builder's canvas, where the selection is
|
|
18
|
+
the ring. The field no longer inherits the box's outline — the box draws it.
|
|
19
|
+
- **The dim layer of a modal and a dialog is `rgb(0 0 0 / 50%)`** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`), not
|
|
20
|
+
black at `opacity: 0.5`: the default looks the same, and a colour a space gives the layer is drawn as it is — it was
|
|
21
|
+
halved. A space that set its own colour sees it darker: the one it wrote.
|
|
22
|
+
- **`required-message-unused`** (`@plitzi/sdk-authoring`): a warning for a `requiredMessage` on a field nothing requires —
|
|
23
|
+
since 0.38.9 a field is optional unless `required: true`, so the message is never shown and an empty answer is sent.
|
|
24
|
+
The formControl's description, the cheat sheet and the forms recipe say the default.
|
|
25
|
+
- **A page's title can say its record** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`, `@plitzi/sdk-elements`,
|
|
26
|
+
`@plitzi/sdk-authoring`): `seoTitle` and `seoDescription` may be templates over the page's `runtime: 'server'`
|
|
27
|
+
providers (its layouts' too) and `navigation` — `'{{ apiContainer_post.title }} — Blog'`. The server evaluates them
|
|
28
|
+
as it writes the head, from the answers it already has; the browser evaluates the same over `rsc.data`, so the tab
|
|
29
|
+
follows a navigation from record to record. One that reads anything else — a browser provider, `state` — is refused
|
|
30
|
+
(`page-template`): it was written into the head as it was, braces included. A declaration's `serverTemplates` names
|
|
31
|
+
the attributes the page server evaluates against a context of its own (a page's title and description, a provider's
|
|
32
|
+
`notFound`): the element runtime leaves them as written — interpolated where the page renders, a `|default(…)`
|
|
33
|
+
resolved to its fallback before the head could read the providers — and the authoring lint reads the same list.
|
|
34
|
+
- **A page says when its address shows nothing** (`@plitzi/sdk-server`, `@plitzi/sdk-authoring`): `notFound` on the
|
|
35
|
+
page, one expression over the same answers its title reads — `"{{ not (apiContainer_feed.topics|find('slug',
|
|
36
|
+
navigation.routeParams.slug)) }}"` — sends it with status 404, rendered as written. A provider's own `notFound` reads
|
|
37
|
+
only its answer, and one in a layout is every page's: a record read from the layout had no way to say it was not
|
|
38
|
+
there, and the page answered 200.
|
|
39
|
+
- **The Export keeps the flows of a plugin hosted by `custom`** (`@plitzi/sdk-authoring`): `specFromSpace` judged such
|
|
40
|
+
an element by `custom`'s own triggers and callbacks, and dropped a flow on the component's event (`onChange` on an
|
|
41
|
+
editor) as one "a custom never fires" — the space read back was not the space written.
|
|
42
|
+
- **`page check` reads every word on the page, in the colour the browser paints it** (`@plitzi/sdk-authoring`): what a
|
|
43
|
+
plugin draws inside an element of the space is measured too, named by the element and a selector; the measure is
|
|
44
|
+
WCAG's contrast (under 2:1 is unreadable), not "nearly the same colour"; and a colour the browser answers as
|
|
45
|
+
`oklch()`, `oklab()` or `color(srgb …)` — every token and every `color-mix()` — is read as that, where it was read as
|
|
46
|
+
`rgb()` numbers and came out near black. A plugin's dark-on-dark status line passed as "nothing wrong".
|
|
47
|
+
- **`verify` checks every theme the space can be painted in** (`@plitzi/cli`): light and dark, unless the space says
|
|
48
|
+
light only — "48 checks at 1440 and 390 px, light and dark". A page unreadable in the dark theme passed in the light
|
|
49
|
+
one; a failure names the theme it was found in.
|
|
50
|
+
- **`plitzi upgrade` says where fields became optional** (`@plitzi/cli`): for a project last upgraded before 0.38.9,
|
|
51
|
+
each `formControl(…)` with no `required`, at its file and line — said, never written. And a `.gitkeep` is asked for
|
|
52
|
+
only in a folder with nothing else in it: `upgrade` wrote one beside code, and `doctor` called it missing once deleted
|
|
53
|
+
as AGENTS.md asks ("nothing unused") — the three now say the same.
|
|
54
|
+
- **`devMode` and `devReload` are the project's** (`@plitzi/sdk-server`): `src/config/serverOptions.ts` may set them,
|
|
55
|
+
over `NODE_ENV`, which they still follow when left out. A deployment started without `NODE_ENV` (a container's `CMD`)
|
|
56
|
+
says `devMode: false`, and a public action answers with its output alone.
|
|
57
|
+
- **`page shot --from load`** (`@plitzi/cli`): `--frames` start as soon as the page's HTML is in, not once it settles —
|
|
58
|
+
an entrance that plays while the page loads had ended before the first picture.
|
|
59
|
+
- **`heavy-animation` says where each animation is** (`@plitzi/sdk-authoring`): the class and its variant, state or
|
|
60
|
+
slot — or the `customCss` rule — and writes the fix against that selector. It said "in `customCss`" for an animation
|
|
61
|
+
declared on a class's variant, and offered `.glow`, a class no space has.
|
|
62
|
+
- **`page shot --steps`** (`@plitzi/cli`): an interaction played step by step — `click`, `type`, `press`, `wait`,
|
|
63
|
+
`wait-for`, `shot [label]`, `frames <n> [ms]`, separated by `;` or written in a file (`@file`) — each picture labelled
|
|
64
|
+
with its step and the time since the first, and said when nothing changed since the one before. A queue filling, a
|
|
65
|
+
restart, an opening frame by frame took a Playwright script of the project's own. Targets take Playwright's selectors
|
|
66
|
+
too (`text=Saved`).
|
|
67
|
+
- **A space's task may take a `number` param** (`@plitzi/sdk-server`): saved functions refused it ("a type the builder
|
|
68
|
+
cannot draw") while a project's server ran it, so code that worked self-hosted failed on the platform — and the
|
|
69
|
+
builder draws one, a callback's. A step's params now arrive as the types the task declares, on every server: a
|
|
70
|
+
`number` written as text is the number, a `boolean` written `'true'` is `true`, as the browser reads a callback's.
|
|
71
|
+
- **`page shot --as <username>`** (`@plitzi/cli`): signs in first, as `page check --as` does, the password from
|
|
72
|
+
`PLITZI_CHECK_PASSWORD` in `.env`. A page for signed-in visitors was pictured as the sign-in page it sent the browser
|
|
73
|
+
to, without a word; `page shot` now says when the page sent it elsewhere, and that the picture is of that page.
|
|
74
|
+
- **A capture is of the page at rest** (`@plitzi/sdk-mcp`): the local screenshot client takes every picture with
|
|
75
|
+
`prefers-reduced-motion: reduce`, as the browser pod now does — the declared motion and a space's own keyframes that
|
|
76
|
+
honour the query are shown finished. A splash still covering its page, or an arrival caught halfway, was what a
|
|
77
|
+
thumbnail or a `plitzi_look` showed of a page that animates as it loads.
|
|
78
|
+
- **The server renders in the visitor's theme, not only the class** (`@plitzi/sdk-shared`): `ThemeProvider` set the
|
|
79
|
+
starting theme from a layout effect, which never runs on a server, so a page was drawn from the theme store's own
|
|
80
|
+
start — `{{ theme.resolved }}` was `light` under a `<html class="dark">`, and whatever named the scheme (a picture's
|
|
81
|
+
address, a `when` rule) was swapped for the other one as the page hydrated. The theme a host supplies (the cookie) is
|
|
82
|
+
now the server's snapshot of the store, and the hydration's; the shared store is never written on the server.
|
|
83
|
+
|
|
3
84
|
## 0.38.9
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
|
@@ -67,6 +67,14 @@ export interface ElementDeclarationData {
|
|
|
67
67
|
* `plitzi page check`), which would otherwise wait for it to be on screen and report it hidden.
|
|
68
68
|
*/
|
|
69
69
|
drawsNothing?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* The attributes the page server evaluates against a context of its own, never where the element renders: a
|
|
72
|
+
* provider's `notFound`, read against its answer; a page's title and description, read against its server providers.
|
|
73
|
+
* Interpolated in the element's own scope they resolved to nothing — a `|default(…)` to its fallback — before the
|
|
74
|
+
* reader that has their names could see them. Read by the element runtime, which leaves them as written, and by the
|
|
75
|
+
* authoring lint, which holds them to that context.
|
|
76
|
+
*/
|
|
77
|
+
serverTemplates?: readonly string[];
|
|
70
78
|
content?: {
|
|
71
79
|
attributes?: Record<string, unknown>;
|
|
72
80
|
definition?: {
|
package/dist/index.mjs
CHANGED
|
@@ -70,27 +70,27 @@ import jn from "./schema/SchemaContext.mjs";
|
|
|
70
70
|
import { ANCHOR_PATTERN as Mn, anchorOf as Nn, isAnchor as Pn, uniqueAnchor as Fn } from "./schema/anchor.mjs";
|
|
71
71
|
import { COMPONENT_PROPS_SOURCE as In, EMPTY_SCHEMA as Ln, VARIABLE_REGEX as Rn } from "./schema/schemaConstants.mjs";
|
|
72
72
|
import { findLayoutCycle as zn, resolveLayoutChain as Bn } from "./schema/layoutChain.mjs";
|
|
73
|
-
import { collectServerElements as Vn, hasServerElements as Hn, notFoundProvider as Un } from "./schema/serverElements.mjs";
|
|
74
|
-
import { isSnippet as
|
|
75
|
-
import
|
|
76
|
-
import
|
|
77
|
-
import { elementFromWire as
|
|
78
|
-
import { SpaceEvents as
|
|
79
|
-
import
|
|
80
|
-
import
|
|
81
|
-
import
|
|
82
|
-
import
|
|
83
|
-
import
|
|
84
|
-
import
|
|
85
|
-
import { THEME_CLASSES as
|
|
86
|
-
import
|
|
87
|
-
import { useThemeStore as
|
|
88
|
-
import
|
|
89
|
-
import
|
|
90
|
-
import
|
|
91
|
-
import
|
|
92
|
-
import
|
|
93
|
-
import
|
|
94
|
-
import { PAINTED_STATE_BUDGET as
|
|
95
|
-
import { runtimeStatePersist as
|
|
96
|
-
export { Mn as ANCHOR_PATTERN, x as BODYLESS_METHODS, y as BuilderContext,
|
|
73
|
+
import { collectServerElements as Vn, hasServerElements as Hn, notFoundProvider as Un, pageNotFound as Wn, pageSeoText as Gn, pageServerContext as Kn } from "./schema/serverElements.mjs";
|
|
74
|
+
import { isSnippet as qn } from "./schema/snippet.mjs";
|
|
75
|
+
import Jn from "./network/NetworkContext.mjs";
|
|
76
|
+
import Yn from "./network/NetworkInternalContext.mjs";
|
|
77
|
+
import { elementFromWire as Xn, schemaFromWire as Zn, schemaToWire as Qn } from "./schema/wire.mjs";
|
|
78
|
+
import { SpaceEvents as $n, spaceEventSchemas as er, validateSpaceEvent as tr } from "./network/spaceEvents.mjs";
|
|
79
|
+
import nr from "./network/graphql/builder/Mutations/index.mjs";
|
|
80
|
+
import rr from "./network/graphql/builder/Queries/index.mjs";
|
|
81
|
+
import ir from "./network/graphql/builder/Subscriptions/index.mjs";
|
|
82
|
+
import ar from "./network/graphql/sdk/Mutations/index.mjs";
|
|
83
|
+
import or from "./network/graphql/sdk/Queries/index.mjs";
|
|
84
|
+
import sr, { RTEvent as cr, RTEventCloseCode as lr, getInstance as ur, isRTEvent as dr, isRTEventCloseCode as fr, setInstance as pr } from "./websockets/RTCodec.mjs";
|
|
85
|
+
import { THEME_CLASSES as mr, THEME_COOKIE_NAME as hr, applyThemeClass as gr, isTheme as _r, readThemeCookie as vr, themeFromCookies as yr, writeThemeCookie as br } from "./theme/themeCookie.mjs";
|
|
86
|
+
import xr, { createThemeState as Sr, createThemeStore as Cr, resolveScheme as wr, setAreaTheme as Tr, setMachineScheme as Er, setThemeMode as Dr, startingThemeState as Or, themeFor as kr } from "./theme/themeStore.mjs";
|
|
87
|
+
import { ThemeStartContext as Ar, useThemeState as jr, useThemeStore as Mr } from "./theme/ThemeScope.mjs";
|
|
88
|
+
import Nr from "./theme/ThemeProvider.mjs";
|
|
89
|
+
import Pr, { SPACE_THEME_AREA as Fr } from "./theme/useTheme.mjs";
|
|
90
|
+
import Ir from "./server/actions/useActionsSync.mjs";
|
|
91
|
+
import Lr, { cancelRsc as Rr, currentRscLocation as zr, releaseRscRequests as Br, rscDataPath as Vr } from "./server/rsc/refreshRsc.mjs";
|
|
92
|
+
import Hr from "./server/rsc/useRscRefresh.mjs";
|
|
93
|
+
import Ur from "./server/rsc/useRscSync.mjs";
|
|
94
|
+
import { PAINTED_STATE_BUDGET as Wr, clearPaintedEntry as Gr, paintedEntryFromCookies as Kr, paintedKeys as qr, paintedStateCookieName as Jr, paintedStateFor as Yr, pickPainted as Xr, readPaintedEntry as Zr, writePaintedEntry as Qr } from "./state/paintedState.mjs";
|
|
95
|
+
import { runtimeStatePersist as $r, stateOwner as ei } from "./state/runtimeStatePersist.mjs";
|
|
96
|
+
export { Mn as ANCHOR_PATTERN, x as BODYLESS_METHODS, y as BuilderContext, nr as BuilderMutations, rr as BuilderQueries, In as COMPONENT_PROPS_SOURCE, N as COMPUTED_GLOBALS, S as CONNECTOR_HTTP_METHODS, an as CONTENT_PSEUDOS, mn as CURRENT_SELECTOR, Me as ComponentContext, C as DEFAULT_READ_ENDPOINT, Te as DEV_TOOLS_ATTRIBUTE, St as DISPLAY_MODES, gt as DISPLAY_MODE_MIN_WIDTH, we as DevToolsContext, w as EMPTY_RESPONSE_METHODS, Ln as EMPTY_SCHEMA, ft as EMPTY_STYLE_SCHEMA, hn as EXPANDED_SELECTOR, Ne as FLAG_GATE_PATTERN, Ue as FLAG_LAYERS, Pe as FLAG_NAME_PATTERN, Ft as FontValidationError, on as GENERATED_PSEUDOS, P as GLOBAL_SOURCES, gn as HIDDEN_CLASS, Ee as HIDE_DEV_TOOLS_CSS, ee as INTERVAL_TRIGGER, zt as LAYOUT_GRIDS, m as MAX_PARAM_PASSES, te as MIN_INTERVAL_MS, Yt as MOTION_CONDITIONS, Jn as NetworkContext, Yn as NetworkInternalContext, Wr as PAINTED_STATE_BUDGET, _n as PARENT_ANCESTOR, yt as PLUGIN_CSS_LAYER, sn as PSEUDO_PROPERTIES, oe as ParamsFromURL, ke as PlitziConsole, ot as PlitziServiceContext, st as PlitziServiceProvider, T as READ_ENDPOINT_NAMES, sr as RTCodec, cr as RTEvent, lr as RTEventCloseCode, bt as RUNTIME_CSS_LAYER, Ht as RUNTIME_STYLE_ID, Fr as SPACE_THEME_AREA, Xt as STYLE_CONDITION_LABELS, Zt as STYLE_MOTION_CONDITIONS, cn as STYLE_PSEUDOS, ln as STYLE_PSEUDO_LABELS, vn as STYLE_STATES, yn as STYLE_STATE_LABELS, Tt as SYSTEM_FONTS, jn as SchemaContext, ar as SdkMutations, or as SdkQueries, ir as SpaceEventSubscription, $n as SpaceEvents, pt as StyleBindingsAllowed, lt as StyleVariableCategory, mr as THEME_CLASSES, hr as THEME_COOKIE_NAME, Nr as ThemeProvider, Ar as ThemeStartContext, Rn as VARIABLE_REGEX, a as VISITOR_NAME, ct as WHILE_RUNNING_MODES, E as WRITE_ENDPOINT_NAMES, Nn as anchorOf, gr as applyThemeClass, t as authFailureFromResponse, Et as availableFonts, mt as baseDefaultValue, Rr as cancelRsc, Qt as canonicalCondition, o as checkVisitorRoles, Gr as clearPaintedEntry, Vn as collectServerElements, $t as conditionAtRule, en as conditionLabel, tn as conditionOfAtRule, k as connectorPresets, D as connectorTokens, b as contexts, B as cookieFromHeader, Ae as createStoreDevToolsLogger, Sr as createThemeState, Cr as createThemeStore, zr as currentRscLocation, De as debugCookieName, se as delay, Xe as describeChange, $e as diffSchema, et as diffStyle, he as disableReactDevTools, _t as displayModeAt, vt as displayModeWidthRem, V as documentCookies, Xn as elementFromWire, H as elementOf, A as emptyManifest, ce as emptyObject, F as evaluateComputed, ae as evaluateRuleGroup, Lt as fallbackForFamily, Dt as familiesInCss, L as fetchManifest, Ze as fieldChanges, c as filters, zn as findLayoutCycle, We as flagUserFromSSR, Ge as flagValues, Le as flagsCookieName, Ot as fontFamilyStack, wt as fontLinkAssets, kt as fontUrlResolver, Rt as fontsFromCss, At as fontsToHead, Re as forcedFlagsFromCookies, K as formatDate, q as formatDateUTC, J as formatFromNow, Y as formatUTCToLocal, R as generateFacade, ve as getBindingsDetails, O as getConnectorTokens, le as getDisplayName, X as getDurationMs, ur as getInstance, ue as getKeyDecoded, de as getPathsFromObeject, ye as getSourceName, jt as googleCss2Url, Mt as googleTextSubsetUrl, Ke as hasConditions, Hn as hasServerElements, f as hasTemplateSyntax, p as hasValidToken, fe as hexToRGB, bn as inCascadeOrder, xt as inPluginLayer, ht as inheritableAttributesBase, g as inspectTemplate, ne as intervalOf, Pn as isAnchor, j as isConnectorManifestDraft, un as isContentValue, re as isDate, Ct as isDisplayMode, U as isElementTarget, Fe as isFlagName, pe as isInViewport, Oe as isInteractionFlow, xn as isKnownState, W as isNodeTarget, Sn as isParentAncestor, dr as isRTEvent, fr as isRTEventCloseCode, e as isRecord, Nt as isSafeFontUrl, Ie as isSchemaFlag, qn as isSnippet, Cn as isStartingState, nn as isStyleCondition, dn as isStylePseudo, Tn as isStyleRules, ut as isStyleVariableCategory, _r as isTheme, ie as isUserEdit, Z as isValidFormat, tt as jsonCopy, Bt as layoutGridCss, Vt as layoutGridLook, I as liveSources, me as makeId, Ut as markStyleCache, Kt as mergeSnippetStyle, G as nodeOf, Un as notFoundProvider, n as onAuthFailure, je as pConsole, Wn as pageNotFound, Gn as pageSeoText, Kn as pageServerContext, Kr as paintedEntryFromCookies, qr as paintedKeys, Jr as paintedStateCookieName, Yr as paintedStateFor, rn as parseContainerCondition, Q as parseDate, ze as parseFlagList, It as parseSpaceFont, qe as passesFlagGate, Xr as pickPainted, Pt as primaryFamily, l as processTwig, u as processTwigParam, d as processTwigValue, fn as pseudoHonours, pn as pseudoSuffix, Zr as readPaintedEntry, vr as readThemeCookie, Lr as refreshRsc, Br as releaseRscRequests, r as reportAuthFailure, Je as resolveFlags, Bn as resolveLayoutChain, wr as resolveScheme, h as resolveStepParam, Se as resolveVariables, Vr as rscDataPath, $r as runtimeStatePersist, i as sameRegistrableDomain, qt as sameSelector, nt as sameValue, Zn as schemaFromWire, Qn as schemaToWire, Jt as selectorsOf, Be as serializeFlagList, Tr as setAreaTheme, En as setAtKeys, pr as setInstance, Er as setMachineScheme, Dr as setThemeMode, er as spaceEventSchemas, Or as startingThemeState, ei as stateOwner, wn as stateSuffix, Wt as styleCacheFromDocument, Gt as styleCacheTravelsInDocument, dt as styleConstants, Dn as styleTargetKeys, On as styleTargetProblem, kn as styleTargetRules, z as syntaxHighlight, _ as templatePaths, v as templateRootNames, kr as themeFor, yr as themeFromCookies, xr as themeStore, $ as toUnixSeconds, Ye as undeclaredFlagOverrides, Fn as uniqueAnchor, Qe as uniqueLines, Ir as useActionsSync, rt as useFontHead, it as useNetwork, at as usePlitziServiceContext, be as useRegisterSource, Ce as useResolvedVariables, Hr as useRscRefresh, Ur as useRscSync, xe as useStableValue, Pr as useTheme, jr as useThemeState, Mr as useThemeStore, ge as utility, _e as utilityOptions, M as validateConnectorManifest, tr as validateSpaceEvent, An as valueAtKeys, s as visitorAccess, Ve as withForcedFlag, He as writeForcedFlags, Qr as writePaintedEntry, br as writeThemeCookie };
|
package/dist/schema/index.mjs
CHANGED
|
@@ -2,6 +2,6 @@ import e from "./SchemaContext.mjs";
|
|
|
2
2
|
import { ANCHOR_PATTERN as t, anchorOf as n, isAnchor as r, uniqueAnchor as i } from "./anchor.mjs";
|
|
3
3
|
import { COMPONENT_PROPS_SOURCE as a, EMPTY_SCHEMA as o, VARIABLE_REGEX as s } from "./schemaConstants.mjs";
|
|
4
4
|
import { findLayoutCycle as c, resolveLayoutChain as l } from "./layoutChain.mjs";
|
|
5
|
-
import { collectServerElements as u, hasServerElements as d, notFoundProvider as f } from "./serverElements.mjs";
|
|
6
|
-
import { isSnippet as
|
|
7
|
-
export { t as ANCHOR_PATTERN, a as COMPONENT_PROPS_SOURCE, o as EMPTY_SCHEMA, e as SchemaContext, s as VARIABLE_REGEX, n as anchorOf, u as collectServerElements, c as findLayoutCycle, d as hasServerElements, r as isAnchor,
|
|
5
|
+
import { collectServerElements as u, hasServerElements as d, notFoundProvider as f, pageNotFound as p, pageSeoText as m, pageServerContext as h } from "./serverElements.mjs";
|
|
6
|
+
import { isSnippet as g } from "./snippet.mjs";
|
|
7
|
+
export { t as ANCHOR_PATTERN, a as COMPONENT_PROPS_SOURCE, o as EMPTY_SCHEMA, e as SchemaContext, s as VARIABLE_REGEX, n as anchorOf, u as collectServerElements, c as findLayoutCycle, d as hasServerElements, r as isAnchor, g as isSnippet, f as notFoundProvider, p as pageNotFound, m as pageSeoText, h as pageServerContext, l as resolveLayoutChain, i as uniqueAnchor };
|
|
@@ -20,9 +20,14 @@ import { Element, Schema } from '../types';
|
|
|
20
20
|
* Given the flags as they resolved, an element gated off by one is skipped with its whole subtree — it will not be
|
|
21
21
|
* rendered, so nothing in it wants data, and resolving it would put a feature that is off into the payload anyway.
|
|
22
22
|
*/
|
|
23
|
-
export declare const collectServerElements: (schema: Schema, pageId: string | undefined, ids?: string[], flags?: Record<string, boolean>) => Element[];
|
|
23
|
+
export declare const collectServerElements: (schema: Pick<Schema, "flat">, pageId: string | undefined, ids?: string[], flags?: Record<string, boolean>) => Element[];
|
|
24
24
|
/** Whether anything on this page consumes server data at all — the question both RSC gates actually ask. */
|
|
25
25
|
export declare const hasServerElements: (schema: Schema, pageId: string | undefined, flags?: Record<string, boolean>) => boolean;
|
|
26
|
+
/** Where the visitor is: what a template on the server reads beside the page's data, as `navigation`. */
|
|
27
|
+
export type ServerNavigation = {
|
|
28
|
+
routeParams: Record<string, unknown>;
|
|
29
|
+
queryParams: Record<string, unknown>;
|
|
30
|
+
};
|
|
26
31
|
/**
|
|
27
32
|
* The server provider of a page whose answer says the address shows nothing — its `notFound`, a template against
|
|
28
33
|
* that answer (`{{ source.found == false }}`) — by id; the page is then sent with status 404, rendered as written.
|
|
@@ -30,7 +35,23 @@ export declare const hasServerElements: (schema: Schema, pageId: string | undefi
|
|
|
30
35
|
* Only `true` counts: a template that does not evaluate comes back as its own text, and a typo must leave the page
|
|
31
36
|
* found rather than turn every visit into a 404.
|
|
32
37
|
*/
|
|
33
|
-
export declare const notFoundProvider: (elements: Element[], serverData: Record<string, unknown>, navigation:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
export declare const notFoundProvider: (elements: Element[], serverData: Record<string, unknown>, navigation: ServerNavigation) => string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* What a page's own templates read — its title, its description, its `notFound`: every server provider of the page and
|
|
41
|
+
* of the shells around it, by the name its descendants read it by (`apiContainer_capsule`), with its answer — and
|
|
42
|
+
* `navigation`. The server has both before it writes the head, and the browser has the same answer in `rsc.data`, so
|
|
43
|
+
* the two write one title.
|
|
44
|
+
*/
|
|
45
|
+
export declare const pageServerContext: (elements: Element[], serverData: Record<string, unknown>, navigation: ServerNavigation) => Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* A page's title or description as the head carries it: its words, or its template evaluated against
|
|
48
|
+
* `pageServerContext`. Blank, or a template that did not evaluate — it comes back as its own text — is nothing, and the
|
|
49
|
+
* deployment's own title stays: braces never reach a tab or a link preview.
|
|
50
|
+
*/
|
|
51
|
+
export declare const pageSeoText: (value: unknown, context: Record<string, unknown>) => string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Whether a page's own `notFound` — a template over `pageServerContext` — says the address shows nothing: a record
|
|
54
|
+
* read by a provider the page shares with others, in its layout, which cannot say it for any one page itself. Only
|
|
55
|
+
* `true` counts, as for a provider's.
|
|
56
|
+
*/
|
|
57
|
+
export declare const pageNotFound: (template: unknown, context: Record<string, unknown>) => boolean;
|
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
import { processTwigValue as e } from "../helpers/twigWrapper/processTwig/processTwig.mjs";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import t from "../dataSource/helpers/getSourceName.mjs";
|
|
3
|
+
import { passesFlagGate as n } from "../flags/resolveFlags.mjs";
|
|
4
|
+
import { resolveLayoutChain as r } from "./layoutChain.mjs";
|
|
4
5
|
//#region src/schema/serverElements.ts
|
|
5
|
-
var
|
|
6
|
-
if (
|
|
7
|
-
let o = i ? new Set(i) : void 0, s = [], c = /* @__PURE__ */ new Set(), l = e.flat[
|
|
6
|
+
var i = (e, t, i, a) => {
|
|
7
|
+
if (t === void 0) return [];
|
|
8
|
+
let o = i ? new Set(i) : void 0, s = [], c = /* @__PURE__ */ new Set(), l = e.flat[t], u = (e) => typeof e == "string" ? e : "", d = [t, ...l ? r((t) => e.flat[t], u(l.attributes.layout), u(l.attributes.layoutContainer)).map((e) => e.layout) : []];
|
|
8
9
|
for (; d.length > 0;) {
|
|
9
|
-
let
|
|
10
|
-
if (
|
|
11
|
-
c.add(
|
|
12
|
-
let r = e.flat[
|
|
13
|
-
if (!r || a && !
|
|
10
|
+
let t = d.pop();
|
|
11
|
+
if (t === void 0 || c.has(t)) continue;
|
|
12
|
+
c.add(t);
|
|
13
|
+
let r = e.flat[t];
|
|
14
|
+
if (!r || a && !n(r.definition.flag, a)) continue;
|
|
14
15
|
r.definition.runtime === "server" && (!o || o.has(r.id)) && s.push(r);
|
|
15
16
|
let { items: i } = r.definition;
|
|
16
17
|
i && d.push(...i);
|
|
17
18
|
}
|
|
18
19
|
return s;
|
|
19
|
-
},
|
|
20
|
+
}, a = (e, t, n) => i(e, t, void 0, n).length > 0, o = (t, n, r) => t.find((t) => {
|
|
20
21
|
let i = t.attributes.notFound;
|
|
21
22
|
return typeof i == "string" && i !== "" && Object.hasOwn(n, t.id) && e(i, {
|
|
22
23
|
source: n[t.id],
|
|
23
24
|
navigation: r
|
|
24
25
|
}) === !0;
|
|
25
|
-
})?.id
|
|
26
|
+
})?.id, s = (e, n, r) => ({
|
|
27
|
+
...Object.fromEntries(e.filter((e) => Object.hasOwn(n, e.id)).map((e) => [t(e.definition.type, e.id), n[e.id]])),
|
|
28
|
+
navigation: r
|
|
29
|
+
}), c = /\{[{%]/, l = (t, n) => {
|
|
30
|
+
if (typeof t != "string") return;
|
|
31
|
+
let r = c.test(t) ? e(t, n) : t, i = typeof r == "string" || typeof r == "number" ? String(r).trim() : "";
|
|
32
|
+
return i === "" || c.test(i) ? void 0 : i;
|
|
33
|
+
}, u = (t, n) => typeof t == "string" && t !== "" && e(t, n) === !0;
|
|
26
34
|
//#endregion
|
|
27
|
-
export {
|
|
35
|
+
export { i as collectServerElements, a as hasServerElements, o as notFoundProvider, u as pageNotFound, l as pageSeoText, s as pageServerContext };
|
|
@@ -1,60 +1,69 @@
|
|
|
1
1
|
import { useCommonStoreSync as e } from "../store/index.mjs";
|
|
2
2
|
import { THEME_COOKIE_NAME as t, applyThemeClass as n, readThemeCookie as r, writeThemeCookie as i } from "./themeCookie.mjs";
|
|
3
3
|
import a, { createThemeStore as o, resolveScheme as s, setMachineScheme as c, setThemeMode as l } from "./themeStore.mjs";
|
|
4
|
-
import u from "./ThemeScope.mjs";
|
|
5
|
-
import { use as
|
|
6
|
-
import { StoreContext as
|
|
7
|
-
import {
|
|
4
|
+
import u, { ThemeStartContext as d, useThemeState as f } from "./ThemeScope.mjs";
|
|
5
|
+
import { use as p, useEffect as m, useId as h, useRef as g, useState as _ } from "react";
|
|
6
|
+
import { StoreContext as v, useIsomorphicLayoutEffect as y } from "@plitzi/nexus/react";
|
|
7
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
8
8
|
//#region src/theme/ThemeProvider.tsx
|
|
9
|
-
var S = "(prefers-color-scheme: dark)", C = () => window.matchMedia(S).matches ? "dark" : "light", w = ({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
var S = "(prefers-color-scheme: dark)", C = () => window.matchMedia(S).matches ? "dark" : "light", w = ({ store: t }) => {
|
|
10
|
+
let n = f(t);
|
|
11
|
+
return e([
|
|
12
|
+
"theme.mode",
|
|
13
|
+
"theme.resolved",
|
|
14
|
+
"theme.areas"
|
|
15
|
+
], [
|
|
16
|
+
n.mode,
|
|
17
|
+
s(n.mode, n.scheme),
|
|
18
|
+
n.areas
|
|
19
|
+
]), null;
|
|
20
|
+
}, T = ({ defaultTheme: e = "system", theme: s, scope: f = "document", cookieName: T = t, children: E }) => {
|
|
21
|
+
let D = f === "container", O = h(), [k] = _(() => D ? o(`theme${O}`) : void 0), A = k ?? a, j = g({
|
|
19
22
|
mode: e,
|
|
20
23
|
remembered: !1
|
|
21
24
|
});
|
|
22
|
-
|
|
23
|
-
let t =
|
|
24
|
-
|
|
25
|
+
y(() => {
|
|
26
|
+
let t = D ? void 0 : r(T), n = s ?? t ?? e;
|
|
27
|
+
j.current = {
|
|
25
28
|
mode: n,
|
|
26
29
|
remembered: t !== void 0
|
|
27
|
-
},
|
|
28
|
-
c(C(),
|
|
30
|
+
}, A.batch(() => {
|
|
31
|
+
c(C(), A), l(n, A);
|
|
29
32
|
});
|
|
30
33
|
}, [
|
|
31
34
|
e,
|
|
32
35
|
s,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
T,
|
|
37
|
+
D,
|
|
38
|
+
A
|
|
36
39
|
]);
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
let e = window.matchMedia(S), t = () => c(e.matches ? "dark" : "light",
|
|
40
|
+
let M = s ?? e, N = p(v) !== void 0;
|
|
41
|
+
m(() => {
|
|
42
|
+
let e = window.matchMedia(S), t = () => c(e.matches ? "dark" : "light", A);
|
|
40
43
|
return e.addEventListener("change", t), t(), () => e.removeEventListener("change", t);
|
|
41
|
-
}, [
|
|
42
|
-
if (
|
|
44
|
+
}, [A]), m(() => {
|
|
45
|
+
if (D) return;
|
|
43
46
|
let e = () => {
|
|
44
|
-
let { mode: e } =
|
|
45
|
-
(
|
|
47
|
+
let { mode: e } = A.getState();
|
|
48
|
+
(j.current.remembered || e !== j.current.mode) && (i(e, T), j.current.remembered = !0), n(e, document.documentElement);
|
|
46
49
|
};
|
|
47
|
-
return e(),
|
|
50
|
+
return e(), A.subscribe(e);
|
|
48
51
|
}, [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
T,
|
|
53
|
+
D,
|
|
54
|
+
A
|
|
52
55
|
]);
|
|
53
|
-
let
|
|
54
|
-
return
|
|
55
|
-
value:
|
|
56
|
-
children:
|
|
57
|
-
|
|
56
|
+
let P = N ? /* @__PURE__ */ b(w, { store: A }) : null;
|
|
57
|
+
return D ? /* @__PURE__ */ b(u, {
|
|
58
|
+
value: k,
|
|
59
|
+
children: /* @__PURE__ */ x(d, {
|
|
60
|
+
value: M,
|
|
61
|
+
children: [P, E]
|
|
62
|
+
})
|
|
63
|
+
}) : /* @__PURE__ */ x(d, {
|
|
64
|
+
value: M,
|
|
65
|
+
children: [P, E]
|
|
66
|
+
});
|
|
58
67
|
};
|
|
59
68
|
//#endregion
|
|
60
69
|
export { T as default };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ThemeStoreInstance } from './themeStore';
|
|
2
|
+
import { Theme, ThemeState } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Which theme store the tree under here reads.
|
|
4
5
|
*
|
|
@@ -11,6 +12,25 @@ import { ThemeStoreInstance } from './themeStore';
|
|
|
11
12
|
* Deliberately NOT the way ordinary consumers reach the theme: a panel in a shadow root and an editor in a portal
|
|
12
13
|
* are under no provider at all, and they still have to get an answer. That is what the fall-through is for.
|
|
13
14
|
*/
|
|
14
|
-
declare const ThemeScopeContext: import('react').Context<import('@plitzi/nexus').StoreApi<
|
|
15
|
+
declare const ThemeScopeContext: import('react').Context<import('@plitzi/nexus').StoreApi<ThemeState> | undefined>;
|
|
15
16
|
export declare const useThemeStore: () => ThemeStoreInstance;
|
|
16
17
|
export default ThemeScopeContext;
|
|
18
|
+
/**
|
|
19
|
+
* The mode the surface under a `ThemeProvider` starts in: the theme its host supplied — the cookie a server read — or
|
|
20
|
+
* else its default.
|
|
21
|
+
*
|
|
22
|
+
* For the render that runs before any effect can: the server's, and the hydration that has to agree with it. The
|
|
23
|
+
* provider sets the store from a layout effect, which never runs on a server — so the page was rendered from the
|
|
24
|
+
* store's own starting state, `system` resolving to `light`, whatever the cookie said. The class on `<html>` was right
|
|
25
|
+
* and `{{ theme.resolved }}` was not: a picture whose address names the scheme was the light one, swapped for the dark
|
|
26
|
+
* one as the page hydrated.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ThemeStartContext: import('react').Context<Theme | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* The theme store's state, as the server rendered it until the surface is live.
|
|
31
|
+
*
|
|
32
|
+
* The starting state is the server snapshot, so the server renders with it and the hydration reads the same — it is
|
|
33
|
+
* never written into the store there, which on a server is one module-level singleton every request shares. Once
|
|
34
|
+
* hydrated, the store answers, which the provider has set by then.
|
|
35
|
+
*/
|
|
36
|
+
export declare const useThemeState: (store: ThemeStoreInstance) => ThemeState;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { sharedContext as e } from "../helpers/sharedContext.mjs";
|
|
2
|
-
import t from "./themeStore.mjs";
|
|
3
|
-
import { use as
|
|
2
|
+
import t, { startingThemeState as n } from "./themeStore.mjs";
|
|
3
|
+
import { use as r, useMemo as i, useSyncExternalStore as a } from "react";
|
|
4
4
|
//#region src/theme/ThemeScope.ts
|
|
5
|
-
var
|
|
5
|
+
var o = e("ThemeScopeContext", void 0), s = () => r(o) ?? t, c = e("ThemeStartContext", void 0), l = (e) => {
|
|
6
|
+
let t = r(c), o = i(() => t === void 0 ? void 0 : n(t), [t]);
|
|
7
|
+
return a(e.subscribe, e.getState, () => o ?? e.getState());
|
|
8
|
+
};
|
|
6
9
|
//#endregion
|
|
7
|
-
export {
|
|
10
|
+
export { c as ThemeStartContext, o as default, l as useThemeState, s as useThemeStore };
|
package/dist/theme/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { THEME_CLASSES as e, THEME_COOKIE_NAME as t, applyThemeClass as n, isTheme as r, readThemeCookie as i, themeFromCookies as a, writeThemeCookie as o } from "./themeCookie.mjs";
|
|
2
|
-
import s, { createThemeState as c, createThemeStore as l, resolveScheme as u, setAreaTheme as d, setMachineScheme as f, setThemeMode as p,
|
|
3
|
-
import { useThemeStore as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
export {
|
|
2
|
+
import s, { createThemeState as c, createThemeStore as l, resolveScheme as u, setAreaTheme as d, setMachineScheme as f, setThemeMode as p, startingThemeState as m, themeFor as h } from "./themeStore.mjs";
|
|
3
|
+
import { ThemeStartContext as g, useThemeState as _, useThemeStore as v } from "./ThemeScope.mjs";
|
|
4
|
+
import y from "./ThemeProvider.mjs";
|
|
5
|
+
import b, { SPACE_THEME_AREA as x } from "./useTheme.mjs";
|
|
6
|
+
export { x as SPACE_THEME_AREA, e as THEME_CLASSES, t as THEME_COOKIE_NAME, y as ThemeProvider, g as ThemeStartContext, n as applyThemeClass, c as createThemeState, l as createThemeStore, r as isTheme, i as readThemeCookie, u as resolveScheme, d as setAreaTheme, f as setMachineScheme, p as setThemeMode, m as startingThemeState, h as themeFor, a as themeFromCookies, s as themeStore, b as useTheme, _ as useThemeState, v as useThemeStore, o as writeThemeCookie };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { ColorScheme, Theme, ThemeState } from '../types';
|
|
2
2
|
export declare const createThemeState: () => ThemeState;
|
|
3
|
+
/**
|
|
4
|
+
* The state a surface starts in, before anything could ask the machine: the mode it opens with, and `light` for what a
|
|
5
|
+
* `system` mode resolves to until the browser answers — the one guess a server has to make, and the one the
|
|
6
|
+
* stylesheet's media queries correct without a class.
|
|
7
|
+
*/
|
|
8
|
+
export declare const startingThemeState: (mode: Theme) => ThemeState;
|
|
3
9
|
/**
|
|
4
10
|
* The theme, as a store rather than a context.
|
|
5
11
|
*
|
|
@@ -4,14 +4,17 @@ var t = () => ({
|
|
|
4
4
|
mode: "system",
|
|
5
5
|
scheme: "light",
|
|
6
6
|
areas: {}
|
|
7
|
-
}), n = (
|
|
7
|
+
}), n = (e) => ({
|
|
8
|
+
...t(),
|
|
9
|
+
mode: e
|
|
10
|
+
}), r = (n = "theme") => e(t(), { id: n }), i = r(), a = (e, t) => e === "system" ? t : e, o = (e, t) => (t ? e.areas[t] : void 0) ?? e.mode, s = (e, t = i) => {
|
|
8
11
|
t.batch(() => {
|
|
9
12
|
t.setState("mode", e), t.setState("areas", {});
|
|
10
13
|
});
|
|
11
|
-
},
|
|
14
|
+
}, c = (e, t, n = i) => {
|
|
12
15
|
n.setState(`areas.${e}`, t);
|
|
13
|
-
},
|
|
16
|
+
}, l = (e, t = i) => {
|
|
14
17
|
t.setState("scheme", e);
|
|
15
18
|
};
|
|
16
19
|
//#endregion
|
|
17
|
-
export { t as createThemeState,
|
|
20
|
+
export { t as createThemeState, r as createThemeStore, i as default, a as resolveScheme, c as setAreaTheme, l as setMachineScheme, s as setThemeMode, n as startingThemeState, o as themeFor };
|
package/dist/theme/useTheme.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { resolveScheme as e, setAreaTheme as t, setThemeMode as n, themeFor as r } from "./themeStore.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { useCallback as
|
|
2
|
+
import { useThemeState as i, useThemeStore as a } from "./ThemeScope.mjs";
|
|
3
|
+
import { useCallback as o, useMemo as s } from "react";
|
|
4
4
|
//#region src/theme/useTheme.ts
|
|
5
5
|
var c = "canvas", l = (c) => {
|
|
6
|
-
let l =
|
|
7
|
-
return
|
|
6
|
+
let l = a(), u = i(l), d = r(u, c), f = e(d, u.scheme), p = o((e) => c ? t(c, e, l) : n(e, l), [c, l]), m = o(() => p(f === "dark" ? "light" : "dark"), [f, p]);
|
|
7
|
+
return s(() => ({
|
|
8
8
|
theme: d,
|
|
9
9
|
resolvedTheme: f,
|
|
10
10
|
setTheme: p,
|