@plitzi/sdk-server 0.39.11 → 0.39.13
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 +24 -0
- package/dist/cache.js +1 -1
- package/dist/chunks/{buildBody-Bm398uxH.js → buildBody-Dg4acjni.js} +64 -9
- package/dist/chunks/{core-CoKORAOg.js → core-CxgbkcXo.js} +131 -5
- package/dist/chunks/{createServer-DyjYdSq0.js → createServer-99dZ2sjd.js} +12 -5
- package/dist/chunks/{platform-B6C07M-P.js → platform-j6joAbxu.js} +1 -1
- package/dist/chunks/{token-XEz1n4jp.js → token-BruOglXr.js} +1 -1
- package/dist/deploy.js +1 -1
- package/dist/handlers.js +1 -1
- package/dist/helpers/audiences.d.ts +22 -0
- package/dist/helpers/cache/keys.d.ts +18 -4
- package/dist/helpers/clock.d.ts +10 -0
- package/dist/helpers/experiments.d.ts +35 -0
- package/dist/helpers/rollout.d.ts +15 -0
- package/dist/index.js +3 -3
- package/dist/modules/ssr/Component.d.ts +16 -1
- package/dist/modules/ssr/buildBody.d.ts +2 -0
- package/dist/modules/ssr/prepareRender.d.ts +5 -0
- package/dist/oauth.js +1 -1
- package/dist/platform.js +1 -1
- package/dist/project.js +3 -3
- package/dist/spaces.js +1 -1
- package/dist/ssr.js +1 -1
- package/package.json +6 -6
- package/skills/plitzi-authoring/recipes/accordion.ts +39 -42
- package/skills/plitzi-authoring/reference/accessibility.md +7 -4
- package/skills/plitzi-authoring/reference/auth.md +15 -0
- package/skills/plitzi-authoring/reference/authoring-errors.md +21 -0
- package/skills/plitzi-authoring/reference/feature-flags.md +67 -0
- package/skills/plitzi-authoring/reference/flows.md +4 -1
- package/skills/plitzi-authoring/reference/index.md +1 -1
- package/skills/plitzi-authoring/reference/templates.md +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @plitzi/sdk-server
|
|
2
2
|
|
|
3
|
+
## 0.39.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 919736b: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
8
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
9
|
+
- Updated dependencies [919736b]
|
|
10
|
+
- @plitzi/plitzi-sdk@0.39.13
|
|
11
|
+
- @plitzi/sdk-actions@0.39.13
|
|
12
|
+
- @plitzi/sdk-kernel@0.39.13
|
|
13
|
+
- @plitzi/sdk-shared@0.39.13
|
|
14
|
+
|
|
15
|
+
## 0.39.12
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 2f5b44d: Released with every `@plitzi` package at this version. What changed in each, and what to do when you upgrade, is in
|
|
20
|
+
`@plitzi/cli`'s `CHANGELOG.md`: one copy of the notes, not one per package.
|
|
21
|
+
- Updated dependencies [2f5b44d]
|
|
22
|
+
- @plitzi/plitzi-sdk@0.39.12
|
|
23
|
+
- @plitzi/sdk-actions@0.39.12
|
|
24
|
+
- @plitzi/sdk-kernel@0.39.12
|
|
25
|
+
- @plitzi/sdk-shared@0.39.12
|
|
26
|
+
|
|
3
27
|
## 0.39.11
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/cache.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { _t as DEFAULT_IGNORED_QUERY_PARAMS, U as createCacheInvalidator, t as createRedisPageStore } from "./chunks/core-CxgbkcXo.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as googleFontsUrlOf, C as requestExperiments, D as requestVisitorFacts, F as partTextOf, I as sentInParts, J as hydrationPayload, L as createOfflineDataLoader, M as scriptTemplateParams, O as spaceAudiences, P as pageSchemaOf, S as resolveDebugMode, T as buildServerInfo, X as spaceDocument, Y as offlineDataWith, ht as readCookie, mt as visitorScheme, q as digest$1, ut as offlineDataCacheKeyOf, w as spaceReadsTheClock, x as requestRollout, yt as requestPaintedStateWithDefaults } from "./core-CxgbkcXo.js";
|
|
2
2
|
import { n as pageAssets, r as resolveSdkAssetsDir } from "./sdkAssets-CXGoc_WE.js";
|
|
3
3
|
import { fetchOutbound, privateOriginsOf } from "@plitzi/sdk-kernel/outbound";
|
|
4
4
|
import { collectServerElements, isOgType, jsonForScript, mayReceive, notFoundProvider, pageElementTypes, pageHeadTags, pageNotFound, pageSeoText, pageServerContext, pageStructuredData, pageWithheldOf, spaceIdentity, withholdPages } from "@plitzi/sdk-shared/schema";
|
|
@@ -1296,7 +1296,7 @@ var withRefusal = (result, refused) => {
|
|
|
1296
1296
|
if (refused && result.redirect === void 0 && result.status === void 0) result.status = refused === "unauthenticated" ? 401 : 403;
|
|
1297
1297
|
};
|
|
1298
1298
|
// src/modules/ssr/Component.tsx
|
|
1299
|
-
var Component = ({ server, renderMode = "raw", previewMode = true, offlineData, environment = "main", plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode = false, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags }) => {
|
|
1299
|
+
var Component = ({ server, renderMode = "raw", previewMode = true, offlineData, environment = "main", plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode = false, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags, serverExperiments, forcedExperiments, drawnExperiments, serverRollout, serverVisitor, renderedAt }) => {
|
|
1300
1300
|
const serverWithResult = {
|
|
1301
1301
|
...server,
|
|
1302
1302
|
ssr: {
|
|
@@ -1322,6 +1322,12 @@ var Component = ({ server, renderMode = "raw", previewMode = true, offlineData,
|
|
|
1322
1322
|
...state === void 0 ? {} : { state },
|
|
1323
1323
|
...serverFlags === void 0 ? {} : { serverFlags },
|
|
1324
1324
|
...forcedFlags === void 0 ? {} : { forcedFlags },
|
|
1325
|
+
...serverExperiments === void 0 ? {} : { serverExperiments },
|
|
1326
|
+
...forcedExperiments === void 0 ? {} : { forcedExperiments },
|
|
1327
|
+
...drawnExperiments === void 0 ? {} : { drawnExperiments },
|
|
1328
|
+
...serverRollout === void 0 ? {} : { serverRollout },
|
|
1329
|
+
...serverVisitor === void 0 ? {} : { serverVisitor },
|
|
1330
|
+
...renderedAt === void 0 ? {} : { renderedAt },
|
|
1325
1331
|
children: plugins && Object.keys(plugins).map((key) => /* @__PURE__ */ jsx(PlitziSdk.Plugin, {
|
|
1326
1332
|
renderType: key,
|
|
1327
1333
|
component: plugins[key].component,
|
|
@@ -1895,7 +1901,40 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
1895
1901
|
const pageMatch = schema !== void 0 ? matchRscPage(schema, req.path, req.ctx.user) : void 0;
|
|
1896
1902
|
const refused = pageMatch ? pageWithheldOf(schema?.flat[pageMatch.pageId]?.attributes) : void 0;
|
|
1897
1903
|
const rscEnabled = rscPath !== void 0 && schema !== void 0 && schema.rsc?.enabled !== false;
|
|
1898
|
-
const
|
|
1904
|
+
const isPreviewRender = Boolean(req.query[PREVIEW_TOKEN_PARAM]);
|
|
1905
|
+
const debugAuthorized = !isPreviewRender && authorizesDebugging(config, schema?.settings);
|
|
1906
|
+
/**
|
|
1907
|
+
* The variant of each of the space's A/B tests this visitor is shown: kept in their cookie, or drawn now and kept from
|
|
1908
|
+
* this response on — and over them, on a page allowed to debug, what a tester forced. The server draws only that
|
|
1909
|
+
* variant, and the page hydrates with the same — never a draw of its own.
|
|
1910
|
+
*/
|
|
1911
|
+
const experiments = requestExperiments(req, rawOfflineData?.schema, {
|
|
1912
|
+
draws: !isPreviewRender && offlineDataOverride === void 0,
|
|
1913
|
+
debugAuthorized
|
|
1914
|
+
});
|
|
1915
|
+
const serverExperiments = Object.keys(experiments.assignments).length > 0 ? experiments.assignments : void 0;
|
|
1916
|
+
const forcedExperiments = experiments.forced;
|
|
1917
|
+
const drawnExperiments = experiments.drawn;
|
|
1918
|
+
/**
|
|
1919
|
+
* Where the visitor stands in the space's gradual rollouts: the places their cookie kept, or drawn now — kept from this
|
|
1920
|
+
* response on, and told to the server data read alongside (`ctx.rolloutBuckets`), which their cookie cannot tell yet.
|
|
1921
|
+
*/
|
|
1922
|
+
const rollout = requestRollout(req, rawOfflineData?.schema.flags, !isPreviewRender && offlineDataOverride === void 0);
|
|
1923
|
+
req.ctx.rolloutBuckets = rollout.buckets;
|
|
1924
|
+
const serverRollout = Object.keys(rollout.buckets).length > 0 ? rollout.buckets : void 0;
|
|
1925
|
+
const setCookies = [experiments.setCookie, rollout.setCookie].filter((cookie) => cookie !== void 0);
|
|
1926
|
+
/**
|
|
1927
|
+
* What the space's audiences read of the visitor — returning, language, device — from this request, handed to the
|
|
1928
|
+
* browser so it hydrates the variant drawn. A page they drew is kept only under those facts (`ctx.audienceKey`, set
|
|
1929
|
+
* when this server already held the space); asked before the space was held, it is kept for nobody.
|
|
1930
|
+
*/
|
|
1931
|
+
const audiences = rawOfflineData ? spaceAudiences(rawOfflineData.schema) : {
|
|
1932
|
+
has: false,
|
|
1933
|
+
used: []
|
|
1934
|
+
};
|
|
1935
|
+
const serverVisitor = audiences.has ? requestVisitorFacts(req) : void 0;
|
|
1936
|
+
const audienceUnkeyed = audiences.used.length > 0 && req.ctx.audienceKey === void 0;
|
|
1937
|
+
const renderedAt = rawOfflineData && spaceReadsTheClock(rawOfflineData.schema) ? Date.now() : void 0;
|
|
1899
1938
|
const flagOverrides = await requestFlagOverrides(config, {
|
|
1900
1939
|
cookie: req.headers.cookie,
|
|
1901
1940
|
authority: requestAuthority(req)
|
|
@@ -1908,7 +1947,8 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
1908
1947
|
hostname: req.hostname,
|
|
1909
1948
|
routeParams: pageMatch.routeParams,
|
|
1910
1949
|
queryParams: req.query,
|
|
1911
|
-
user: flagUserFromSSR(req.ctx.user)
|
|
1950
|
+
user: flagUserFromSSR(req.ctx.user),
|
|
1951
|
+
rollout: rollout.buckets
|
|
1912
1952
|
}, flagOverrides)) : void 0;
|
|
1913
1953
|
const serverElements = rscEnabled && pageMatch !== void 0 ? collectServerElements(schema, pageMatch.pageId, void 0, pageFlags) : [];
|
|
1914
1954
|
const hasTargets = serverElements.length > 0;
|
|
@@ -2074,7 +2114,13 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
2074
2114
|
...runStatus ? { runStatus } : {},
|
|
2075
2115
|
...inspector ? { inspector } : {},
|
|
2076
2116
|
...serverFlags ? { serverFlags } : {},
|
|
2077
|
-
...forcedFlags ? { forcedFlags } : {}
|
|
2117
|
+
...forcedFlags ? { forcedFlags } : {},
|
|
2118
|
+
...serverExperiments ? { serverExperiments } : {},
|
|
2119
|
+
...forcedExperiments ? { forcedExperiments } : {},
|
|
2120
|
+
...drawnExperiments ? { drawnExperiments } : {},
|
|
2121
|
+
...serverRollout ? { serverRollout } : {},
|
|
2122
|
+
...serverVisitor ? { serverVisitor } : {},
|
|
2123
|
+
...renderedAt === void 0 ? {} : { renderedAt }
|
|
2078
2124
|
}, {
|
|
2079
2125
|
apart: spaceDocumentPath !== void 0,
|
|
2080
2126
|
linkStyle
|
|
@@ -2145,7 +2191,13 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
2145
2191
|
...scheme ? { scheme } : {},
|
|
2146
2192
|
...paintedState ? { state: paintedState } : {},
|
|
2147
2193
|
...serverFlags ? { serverFlags } : {},
|
|
2148
|
-
...forcedFlags ? { forcedFlags } : {}
|
|
2194
|
+
...forcedFlags ? { forcedFlags } : {},
|
|
2195
|
+
...serverExperiments ? { serverExperiments } : {},
|
|
2196
|
+
...forcedExperiments ? { forcedExperiments } : {},
|
|
2197
|
+
...drawnExperiments ? { drawnExperiments } : {},
|
|
2198
|
+
...serverRollout ? { serverRollout } : {},
|
|
2199
|
+
...serverVisitor ? { serverVisitor } : {},
|
|
2200
|
+
...renderedAt === void 0 ? {} : { renderedAt }
|
|
2149
2201
|
},
|
|
2150
2202
|
entries,
|
|
2151
2203
|
templateParams: {
|
|
@@ -2190,8 +2242,9 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
|
|
|
2190
2242
|
...config.livePages === true && offlineDataOverride !== void 0 ? { liveDraft: readDraftToken(req) } : {},
|
|
2191
2243
|
offlineData: offlineDataStr
|
|
2192
2244
|
},
|
|
2193
|
-
cacheable: actionRuns === void 0 && forcedFlags === void 0 && req.ctx.readAsVisitor !== true && !(environment === "main" && hasTargets),
|
|
2245
|
+
cacheable: actionRuns === void 0 && forcedFlags === void 0 && req.ctx.readAsVisitor !== true && !(environment === "main" && hasTargets) && setCookies.length === 0 && !audienceUnkeyed && forcedExperiments === void 0,
|
|
2194
2246
|
notFound,
|
|
2247
|
+
...setCookies.length > 0 ? { setCookies } : {},
|
|
2195
2248
|
...refused ? { refused } : {}
|
|
2196
2249
|
};
|
|
2197
2250
|
};
|
|
@@ -2210,7 +2263,8 @@ var buildBody = async (req, config, spaceId, environment, revision, renderFn, pl
|
|
|
2210
2263
|
if (result.redirect !== void 0) return {
|
|
2211
2264
|
result,
|
|
2212
2265
|
cacheable: prep.cacheable,
|
|
2213
|
-
nonce: ""
|
|
2266
|
+
nonce: "",
|
|
2267
|
+
...prep.setCookies ? { setCookies: prep.setCookies } : {}
|
|
2214
2268
|
};
|
|
2215
2269
|
const templateStart = metrics ? performance.now() : 0;
|
|
2216
2270
|
const body = renderFn({
|
|
@@ -2223,7 +2277,8 @@ var buildBody = async (req, config, spaceId, environment, revision, renderFn, pl
|
|
|
2223
2277
|
body,
|
|
2224
2278
|
result,
|
|
2225
2279
|
cacheable: prep.cacheable,
|
|
2226
|
-
nonce: prep.templateParams.nonce ?? ""
|
|
2280
|
+
nonce: prep.templateParams.nonce ?? "",
|
|
2281
|
+
...prep.setCookies ? { setCookies: prep.setCookies } : {}
|
|
2227
2282
|
};
|
|
2228
2283
|
};
|
|
2229
2284
|
export { DRAFT_STORE_METHODS as C, invalidatePluginComponentCache as D, takeDraftOverride as E, matchRscPage as O, PluginManager as S, draftSessionCookie as T, resolveServices as _, applySSRResult as a, spaceIconsOf as b, withNotFound as c, SPACE_DOCUMENT_PATH as d, answerCurrentSpacePreflight as f, resolveRscEndpoint as g, meterPage as h, Component as i, withRefusal as l, handleSpaceDocument as m, prepareRender as n, isReusable as o, handleCurrentSpace as p, imagesStage as r, renderParamsOf as s, buildBody as t, CURRENT_SPACE_PATH as u, resolvePageSeo as v, createMemoryDraftStore as w, iconGlyphsAt as x, ICONS_PATH as y };
|
|
@@ -2,18 +2,22 @@ import { schemaForPage, schemaFromWire, splitSchema } from "@plitzi/sdk-shared/s
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { compressBody, frameAncestorsOf, requestAuthority, requestOrigin } from "@plitzi/sdk-kernel/http";
|
|
4
4
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
5
|
-
import { flagsCookieName } from "@plitzi/sdk-shared/flags";
|
|
5
|
+
import { assignRollout, flagsCookieName, keptRollout, rolloutCookie, rolloutCookieName } from "@plitzi/sdk-shared/flags";
|
|
6
6
|
import { TRUSTED_TYPES_POLICIES, getKeyDecoded, isRecord } from "@plitzi/sdk-shared/helpers";
|
|
7
7
|
import { paintedKeys, paintedStateCookieName, paintedStateFor, pickPainted } from "@plitzi/sdk-shared/state";
|
|
8
8
|
import { frameAncestors, sessionCookieParams, sessionHintCookieName } from "@plitzi/sdk-kernel/identity";
|
|
9
9
|
import { TtlCache } from "@plitzi/sdk-kernel/cache";
|
|
10
10
|
import { debugCookieName } from "@plitzi/sdk-shared/devTools";
|
|
11
|
+
import { FORCED_EXPERIMENTS_PARAM, assignExperiments, declaredExperiments, experimentsCookie, experimentsCookieName, forcedExperimentsCookieName, forcedExperimentsFor, forcedExperimentsOf, keptExperiments } from "@plitzi/sdk-shared/experiments";
|
|
11
12
|
import { requestScheme, themeFromCookies } from "@plitzi/sdk-shared/theme/cookie";
|
|
12
13
|
import { brotliDecompressSync, gunzipSync } from "node:zlib";
|
|
13
14
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
14
15
|
import { styleSheetCss, styleSheetHref, styleSheetLinkable } from "@plitzi/sdk-shared/style";
|
|
15
16
|
import { fileURLToPath } from "node:url";
|
|
16
17
|
import { readFileSync, statSync, writeFileSync } from "node:fs";
|
|
18
|
+
import { COUNTRY_HEADERS, audienceFactsUsed, audienceKeyOf, visitorFactsOf } from "@plitzi/sdk-shared/audiences";
|
|
19
|
+
import { chooseByOf, variantsElementsOf } from "@plitzi/sdk-shared/variants";
|
|
20
|
+
import { readsTheClock } from "@plitzi/sdk-shared/timeWindows";
|
|
17
21
|
import { CLIENT_HEADER, CURRENT_HEADER, behindText, clientHeaderValue } from "@plitzi/sdk-shared/clients";
|
|
18
22
|
// src/helpers/paintedCookie.ts
|
|
19
23
|
/**
|
|
@@ -174,8 +178,12 @@ var HTML_KEY_FIELDS = [
|
|
|
174
178
|
"theme",
|
|
175
179
|
"scheme",
|
|
176
180
|
"painted",
|
|
181
|
+
"experiments",
|
|
182
|
+
"rollout",
|
|
183
|
+
"audience",
|
|
177
184
|
"debugHidden",
|
|
178
185
|
"forcedFlags",
|
|
186
|
+
"forcedExperiments",
|
|
179
187
|
"hostname",
|
|
180
188
|
"path",
|
|
181
189
|
"search"
|
|
@@ -196,9 +204,16 @@ var HTML_KEY_FIELDS = [
|
|
|
196
204
|
* values, so a page drawn with one visitor's toolbar must not be served to the next. Keyed by its raw value — this
|
|
197
205
|
* key does not know which keys a space declares, and a space that declares none has no such cookie to split on.
|
|
198
206
|
*
|
|
199
|
-
* So are the
|
|
200
|
-
* the
|
|
201
|
-
*
|
|
207
|
+
* So are the variants of the space's A/B tests the visitor keeps: the page draws only the one each shows them. Keyed by
|
|
208
|
+
* the cookie's raw value, so visitors shown the same variants share a page. A visitor with none of a test kept is drawn
|
|
209
|
+
* one there and then, and that page is never kept (`prepareRender`'s `cacheable`): the next such visitor is drawn their
|
|
210
|
+
* own. The same for the visitor's places in the space's gradual rollouts (`plitzi_rollout`): the flags they answer are
|
|
211
|
+
* drawn into the page. And for what the space's audiences read of the visitor (`ctx.audienceKey`: their device, their
|
|
212
|
+
* language, whether they came before), only where its audiences read it.
|
|
213
|
+
*
|
|
214
|
+
* So are the feature flags and the A/B variants a tester forced from the dev tools, on a page that authorizes
|
|
215
|
+
* debugging: drawn with them, the page is not everybody's, and a tester holding the cookie must never be handed a page
|
|
216
|
+
* drawn without it. Keyed by its raw value, like the kept state.
|
|
202
217
|
*
|
|
203
218
|
* So is what the space's flags are at (`flagsVersion` on the resolved deployment), for a deployment that changes them
|
|
204
219
|
* apart from its revisions: a flag turned in production must reach the next visitor, while the revision is the same.
|
|
@@ -219,8 +234,12 @@ var buildHtmlCacheKey = (accessToken = "anonymous", spaceId, environment, revisi
|
|
|
219
234
|
theme: themeFromCookies(req.headers.cookie) ?? "",
|
|
220
235
|
scheme: [void 0, "system"].includes(themeFromCookies(req.headers.cookie)) ? visitorScheme(req) ?? "" : "",
|
|
221
236
|
painted: readCookie(req.headers.cookie, ssrPaintedCookieName(requestAuthority(req))) ?? "",
|
|
237
|
+
experiments: readCookie(req.headers.cookie, experimentsCookieName(requestAuthority(req))) ?? "",
|
|
238
|
+
rollout: readCookie(req.headers.cookie, rolloutCookieName(requestAuthority(req))) ?? "",
|
|
239
|
+
audience: req.ctx?.audienceKey ?? "",
|
|
222
240
|
debugHidden: readCookie(req.headers.cookie, debugCookieName(requestAuthority(req))) === "false" ? "debug-off" : "",
|
|
223
241
|
forcedFlags: readCookie(req.headers.cookie, flagsCookieName(requestAuthority(req))) ?? "",
|
|
242
|
+
forcedExperiments: readCookie(req.headers.cookie, forcedExperimentsCookieName(requestAuthority(req))) ?? "",
|
|
224
243
|
hostname: req.hostname,
|
|
225
244
|
path: req.path,
|
|
226
245
|
search: canonicalSearch(req.search, ignoredQueryParams)
|
|
@@ -277,6 +296,7 @@ var RSC_KEY_FIELDS = [
|
|
|
277
296
|
"environment",
|
|
278
297
|
"revision",
|
|
279
298
|
"flags",
|
|
299
|
+
"rollout",
|
|
280
300
|
"user",
|
|
281
301
|
"ids",
|
|
282
302
|
"hostname",
|
|
@@ -289,6 +309,7 @@ var buildRscCacheKey = (spaceId, environment, revision, userId, idsParam, req) =
|
|
|
289
309
|
environment,
|
|
290
310
|
revision: String(revision),
|
|
291
311
|
flags: flagsVersionOf(req),
|
|
312
|
+
rollout: readCookie(req.headers.cookie, rolloutCookieName(requestAuthority(req))) ?? "",
|
|
292
313
|
user: userId === void 0 ? "anon" : String(userId),
|
|
293
314
|
ids: idsParam ?? "",
|
|
294
315
|
hostname: req.hostname,
|
|
@@ -1162,6 +1183,43 @@ var googleFontsStage = async (ctx) => {
|
|
|
1162
1183
|
ctx.res.send(answer.body);
|
|
1163
1184
|
return true;
|
|
1164
1185
|
};
|
|
1186
|
+
// src/helpers/audiences.ts
|
|
1187
|
+
/** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
|
|
1188
|
+
var audiencesOf = /* @__PURE__ */ new WeakMap();
|
|
1189
|
+
/** Whether a space has Variants elements chosen by rules (its audiences) at all, and the visitor facts their rules read. */
|
|
1190
|
+
var spaceAudiences = (schema) => {
|
|
1191
|
+
const known = audiencesOf.get(schema);
|
|
1192
|
+
if (known) return known;
|
|
1193
|
+
const found = {
|
|
1194
|
+
has: variantsElementsOf(schema).some(({ element }) => chooseByOf(element.attributes) === "rules"),
|
|
1195
|
+
used: audienceFactsUsed(schema)
|
|
1196
|
+
};
|
|
1197
|
+
audiencesOf.set(schema, found);
|
|
1198
|
+
return found;
|
|
1199
|
+
};
|
|
1200
|
+
var headerOf = (value) => Array.isArray(value) ? value[0] : value;
|
|
1201
|
+
/**
|
|
1202
|
+
* This request's visitor, as an audience's rules read them: their first visit's cookie, their agent, their languages,
|
|
1203
|
+
* and the country the CDN in front said (`COUNTRY_HEADERS`).
|
|
1204
|
+
*/
|
|
1205
|
+
var requestVisitorFacts = (req) => visitorFactsOf({
|
|
1206
|
+
cookies: req.headers.cookie,
|
|
1207
|
+
host: requestAuthority(req),
|
|
1208
|
+
userAgent: headerOf(req.headers["user-agent"]),
|
|
1209
|
+
mobileHint: headerOf(req.headers["sec-ch-ua-mobile"]),
|
|
1210
|
+
acceptLanguage: headerOf(req.headers["accept-language"]),
|
|
1211
|
+
country: COUNTRY_HEADERS.map((name) => headerOf(req.headers[name])).find(Boolean),
|
|
1212
|
+
now: Date.now()
|
|
1213
|
+
});
|
|
1214
|
+
/**
|
|
1215
|
+
* What a page of this space is kept apart by for this request, asked before the cache is: the facts its audiences read,
|
|
1216
|
+
* from the space this server holds already. `undefined` when it holds none — the render that reads it keeps nothing.
|
|
1217
|
+
*/
|
|
1218
|
+
var audienceKeyFor = (req, held) => {
|
|
1219
|
+
if (!held) return;
|
|
1220
|
+
const { used } = spaceAudiences(held);
|
|
1221
|
+
return used.length > 0 ? audienceKeyOf(requestVisitorFacts(req), used) : "";
|
|
1222
|
+
};
|
|
1165
1223
|
// src/helpers/buildServerInfo.ts
|
|
1166
1224
|
var getEnvironment = (env = "production", server) => {
|
|
1167
1225
|
switch (env) {
|
|
@@ -1249,6 +1307,57 @@ var buildServerInfo = (req, config, ssr) => {
|
|
|
1249
1307
|
ssr
|
|
1250
1308
|
});
|
|
1251
1309
|
};
|
|
1310
|
+
// src/helpers/clock.ts
|
|
1311
|
+
/** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
|
|
1312
|
+
var known = /* @__PURE__ */ new WeakMap();
|
|
1313
|
+
/**
|
|
1314
|
+
* Whether a space shows or says anything by the time — a time window, a countdown, a template on the page's clock — so
|
|
1315
|
+
* a page of it is drawn at an instant the browser hydrates at.
|
|
1316
|
+
*/
|
|
1317
|
+
var spaceReadsTheClock = (schema) => {
|
|
1318
|
+
const found = known.get(schema);
|
|
1319
|
+
if (found !== void 0) return found;
|
|
1320
|
+
const reads = readsTheClock(schema);
|
|
1321
|
+
known.set(schema, reads);
|
|
1322
|
+
return reads;
|
|
1323
|
+
};
|
|
1324
|
+
// src/helpers/experiments.ts
|
|
1325
|
+
/** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
|
|
1326
|
+
var declaredOf = /* @__PURE__ */ new WeakMap();
|
|
1327
|
+
var experimentsOf = (schema) => {
|
|
1328
|
+
const known = declaredOf.get(schema);
|
|
1329
|
+
if (known) return known;
|
|
1330
|
+
const declared = declaredExperiments(schema);
|
|
1331
|
+
declaredOf.set(schema, declared);
|
|
1332
|
+
return declared;
|
|
1333
|
+
};
|
|
1334
|
+
/**
|
|
1335
|
+
* The variant of each of the space's A/B tests for this request — every one in the space, not this page's alone, so a
|
|
1336
|
+
* visitor who goes on to the next page in the browser finds theirs already kept: what their cookie holds, and a draw
|
|
1337
|
+
* for what it does not. Over them, what a tester forced (`plitzi_ab_qa`, `?ab=`) — read only where `debugAuthorized`,
|
|
1338
|
+
* shown and never kept as the visitor's.
|
|
1339
|
+
*
|
|
1340
|
+
* A render nobody visits — a preview for a picture, a draft's unsaved edits — draws nothing and keeps nothing: what
|
|
1341
|
+
* the visitor has not kept is shown as its first variant still shown (A, the control), the same in every picture.
|
|
1342
|
+
*/
|
|
1343
|
+
var requestExperiments = (req, schema, { draws, debugAuthorized }) => {
|
|
1344
|
+
const declared = schema ? experimentsOf(schema) : {};
|
|
1345
|
+
if (Object.keys(declared).length === 0) return { assignments: {} };
|
|
1346
|
+
const host = requestAuthority(req);
|
|
1347
|
+
const { assignments, kept, drawn } = assignExperiments(declared, keptExperiments(req.headers.cookie, host), draws ? Math.random : () => 0);
|
|
1348
|
+
const forced = debugAuthorized ? forcedExperimentsFor(declared, forcedExperimentsOf(req.headers.cookie, host, req.query[FORCED_EXPERIMENTS_PARAM])).applied : {};
|
|
1349
|
+
const tested = Object.keys(forced).length > 0 ? { forced } : {};
|
|
1350
|
+
if (!draws || drawn.length === 0) return {
|
|
1351
|
+
assignments,
|
|
1352
|
+
...tested
|
|
1353
|
+
};
|
|
1354
|
+
return {
|
|
1355
|
+
assignments,
|
|
1356
|
+
setCookie: experimentsCookie(host, kept, { secure: req.protocol === "https" }),
|
|
1357
|
+
drawn,
|
|
1358
|
+
...tested
|
|
1359
|
+
};
|
|
1360
|
+
};
|
|
1252
1361
|
// src/helpers/resolveDebugMode.ts
|
|
1253
1362
|
/**
|
|
1254
1363
|
* Whether a render may expose debugging: the panel, element ids in the markup, the store.
|
|
@@ -1260,6 +1369,23 @@ var buildServerInfo = (req, config, ssr) => {
|
|
|
1260
1369
|
* and get the debug render.
|
|
1261
1370
|
*/
|
|
1262
1371
|
var resolveDebugMode = (authorized, debugCookie) => Boolean(authorized) && debugCookie !== "false";
|
|
1372
|
+
// src/helpers/rollout.ts
|
|
1373
|
+
/**
|
|
1374
|
+
* Where this request's visitor stands in the space's gradual rollouts: the places their cookie kept, and one drawn now
|
|
1375
|
+
* for a flag it does not hold — kept from this response on. A render nobody visits (a picture, a draft's unsaved edits)
|
|
1376
|
+
* draws nothing: a rollout's flag answers its own value there.
|
|
1377
|
+
*/
|
|
1378
|
+
var requestRollout = (req, flags, draws) => {
|
|
1379
|
+
const host = requestAuthority(req);
|
|
1380
|
+
const kept = keptRollout(req.headers.cookie, host);
|
|
1381
|
+
if (!draws) return { buckets: kept };
|
|
1382
|
+
const { buckets, drawn } = assignRollout(flags, kept);
|
|
1383
|
+
if (drawn.length === 0) return { buckets };
|
|
1384
|
+
return {
|
|
1385
|
+
buckets,
|
|
1386
|
+
setCookie: rolloutCookie(host, buckets, { secure: req.protocol === "https" })
|
|
1387
|
+
};
|
|
1388
|
+
};
|
|
1263
1389
|
// src/helpers/escapeHtml.ts
|
|
1264
1390
|
/** Text set inside HTML as text: never markup, whatever it holds. */
|
|
1265
1391
|
var escapeHtml = (value) => value.replace(/[&<>"']/gu, (character) => {
|
|
@@ -2323,4 +2449,4 @@ var createRedisPageStore = (client, { prefix = "plitzi:{pages}:", maxBytes = byt
|
|
|
2323
2449
|
return typeof count === "number" ? count : 0;
|
|
2324
2450
|
}
|
|
2325
2451
|
});
|
|
2326
|
-
export {
|
|
2452
|
+
export { DEFAULT_RENDER_WAIT_MS as $, googleFontsUrlOf as A, normalizePlugins as B, requestExperiments as C, requestVisitorFacts as D, audienceKeyFor as E, partTextOf as F, createServerCaches as G, cacheFilterOf as H, sentInParts as I, hydrationPayload as J, destroyServerCaches as K, createOfflineDataLoader as L, scriptTemplateParams as M, sendScriptPolicy as N, spaceAudiences as O, pageSchemaOf as P, escapeJson as Q, reportReactBuild as R, resolveDebugMode as S, buildServerInfo as T, createCacheInvalidator as U, cacheLimitsOf as V, shareCache as W, spaceDocument as X, offlineDataWith as Y, styleSheetOf as Z, createCloudAdapters as _, DEFAULT_IGNORED_QUERY_PARAMS as _t, previewLabel as a, toSharedPage as at, escapeHtml as b, fixedSpace as c, buildRscCacheKey as ct, verifiedDomain as d, ignoredQueryParamsOf as dt, renderLimitFor as et, wildcardSubdomain as f, renderedQuery as ft, createJsonAdapters as g, DEFAULT_CACHE_BYTES as gt, createAuthAdapters as h, readCookie as ht, parsePreviewLabel as i, pageHtml as it, CSP_REPORT_PATH as j, googleFontsStage as k, presentsCredential as l, keepsVersion as lt, refuse as m, visitorScheme as mt, createSpaceAdapters as n, fromSharedPage as nt, snapshotPreview as o, buildCacheManager as ot, createMemoryCache as p, SCHEME_HINT_HEADER as pt, digest as q, PREVIEW_KEY_LENGTH as r, keepPage as rt, authoringPreview as s, buildHtmlCacheKey as st, createRedisPageStore as t, renderLimitOf as tt, renderGrant as u, offlineDataCacheKeyOf as ut, ownVersion as v, DEFAULT_TTL_MS as vt, spaceReadsTheClock as w, requestRollout as x, RequestMetrics as y, requestPaintedStateWithDefaults as yt, normalizePluginSource as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as DRAFT_STORE_METHODS, D as invalidatePluginComponentCache, E as takeDraftOverride, O as matchRscPage, S as PluginManager, T as draftSessionCookie, _ as resolveServices, a as applySSRResult, b as spaceIconsOf, c as withNotFound, f as answerCurrentSpacePreflight, g as resolveRscEndpoint, h as meterPage, i as Component, l as withRefusal, m as handleSpaceDocument, n as prepareRender, o as isReusable, p as handleCurrentSpace, r as imagesStage, s as renderParamsOf, t as buildBody, v as resolvePageSeo, w as createMemoryDraftStore, x as iconGlyphsAt, y as ICONS_PATH } from "./buildBody-
|
|
2
|
-
import {
|
|
1
|
+
import { C as DRAFT_STORE_METHODS, D as invalidatePluginComponentCache, E as takeDraftOverride, O as matchRscPage, S as PluginManager, T as draftSessionCookie, _ as resolveServices, a as applySSRResult, b as spaceIconsOf, c as withNotFound, f as answerCurrentSpacePreflight, g as resolveRscEndpoint, h as meterPage, i as Component, l as withRefusal, m as handleSpaceDocument, n as prepareRender, o as isReusable, p as handleCurrentSpace, r as imagesStage, s as renderParamsOf, t as buildBody, v as resolvePageSeo, w as createMemoryDraftStore, x as iconGlyphsAt, y as ICONS_PATH } from "./buildBody-Dg4acjni.js";
|
|
2
|
+
import { B as normalizePlugins, E as audienceKeyFor, G as createServerCaches, H as cacheFilterOf, K as destroyServerCaches, L as createOfflineDataLoader, N as sendScriptPolicy, R as reportReactBuild, V as cacheLimitsOf, W as shareCache, Z as styleSheetOf, at as toSharedPage, b as escapeHtml, ct as buildRscCacheKey, dt as ignoredQueryParamsOf, et as renderLimitFor, ft as renderedQuery, gt as DEFAULT_CACHE_BYTES, it as pageHtml, k as googleFontsStage, lt as keepsVersion, nt as fromSharedPage, ot as buildCacheManager, pt as SCHEME_HINT_HEADER, rt as keepPage, st as buildHtmlCacheKey, tt as renderLimitOf, ut as offlineDataCacheKeyOf, vt as DEFAULT_TTL_MS, y as RequestMetrics, yt as requestPaintedStateWithDefaults, z as normalizePluginSource } from "./core-CxgbkcXo.js";
|
|
3
3
|
import { n as renewForNavigation, t as isDocumentNavigation } from "./renewal-D98v6-Jd.js";
|
|
4
4
|
import { t as compileTemplate } from "./template-M3IEZ6os.js";
|
|
5
5
|
import { n as createRateLimit, t as RATE_LIMIT_METHODS } from "./throttle-CRiZB6_A.js";
|
|
@@ -17,7 +17,7 @@ import { configureServerLog, defaultLogLevel, isLogged, logLevelOf, serverLog }
|
|
|
17
17
|
import { evaluateRuleGroup } from "@plitzi/sdk-shared/conditions";
|
|
18
18
|
import { getSourceName } from "@plitzi/sdk-shared/dataSource/helpers";
|
|
19
19
|
import { resolveVariables } from "@plitzi/sdk-shared/dataSource/variables";
|
|
20
|
-
import { flagUserFromSSR, flagValues, forcedFlagsFromCookies, requestFlagOverrides, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
20
|
+
import { flagUserFromSSR, flagValues, forcedFlagsFromCookies, keptRollout, requestFlagOverrides, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
21
21
|
import { sitemapPages, sitemapPaths } from "@plitzi/sdk-shared/navigation";
|
|
22
22
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
23
23
|
import { knowHostDeployment } from "@plitzi/sdk-kernel/deployment";
|
|
@@ -337,7 +337,8 @@ var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, reso
|
|
|
337
337
|
hostname: req.hostname,
|
|
338
338
|
routeParams,
|
|
339
339
|
queryParams: req.query,
|
|
340
|
-
user: flagUserFromSSR(user)
|
|
340
|
+
user: flagUserFromSSR(user),
|
|
341
|
+
rollout: req.ctx.rolloutBuckets ?? keptRollout(req.headers.cookie, requestAuthority(req))
|
|
341
342
|
}, flagOverrides));
|
|
342
343
|
const all = collectServerElements(drawn, pageId, void 0, flags);
|
|
343
344
|
const asked = ids ? new Set(ids) : void 0;
|
|
@@ -1435,6 +1436,7 @@ var renderingNow = (slot) => slot.caches.rendering.get(slot.key);
|
|
|
1435
1436
|
var SSR_SENTINEL = "<!--SSR_CONTENT-->";
|
|
1436
1437
|
var streamBody = async (req, res, config, spaceId, environment, revision, renderFn, pluginManager, offlineDataCache, keep, metrics, offlineDataOverride, published) => {
|
|
1437
1438
|
const prep = await prepareRender(req, config, spaceId, environment, revision, pluginManager, offlineDataCache, metrics, offlineDataOverride, published);
|
|
1439
|
+
if (prep.setCookies) res.setHeader("Set-Cookie", prep.setCookies);
|
|
1438
1440
|
const templateStart = metrics ? performance.now() : 0;
|
|
1439
1441
|
const fullTemplate = renderFn({
|
|
1440
1442
|
...prep.templateParams,
|
|
@@ -1553,7 +1555,11 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches, publis
|
|
|
1553
1555
|
}
|
|
1554
1556
|
const htmlCache = keepsVersion(req.ctx.spaceDeployment) && !offlineDataOverride ? caches.html : void 0;
|
|
1555
1557
|
const ignored = ignoredQueryParamsOf(config);
|
|
1556
|
-
if (htmlCache)
|
|
1558
|
+
if (htmlCache) {
|
|
1559
|
+
req.query = renderedQuery(req.query, ignored);
|
|
1560
|
+
const held = caches.offlineData?.get(offlineDataCacheKeyOf(req.ctx.spaceDeployment) ?? "");
|
|
1561
|
+
req.ctx.audienceKey = audienceKeyFor(req, held?.schema);
|
|
1562
|
+
}
|
|
1557
1563
|
const compression = resolveCompression(config.compression);
|
|
1558
1564
|
const slot = htmlCache ? pageSlot(config, caches, buildHtmlCacheKey(req.ctx.user?.token, spaceId, environment, revision, req, ignored), {
|
|
1559
1565
|
spaceId,
|
|
@@ -1608,6 +1614,7 @@ var renderSSR = async (req, res, config, renderFn, pluginManager, caches, publis
|
|
|
1608
1614
|
res.setHeader("Server-Timing", metrics.toServerTimingHeader());
|
|
1609
1615
|
metrics.log(`${req.method} ${req.path}`);
|
|
1610
1616
|
}
|
|
1617
|
+
if (rendered.setCookies) res.setHeader("Set-Cookie", rendered.setCookies);
|
|
1611
1618
|
if (applySSRResult(res, rendered.result, renderParamsOf(req.query))) return;
|
|
1612
1619
|
sendScriptPolicy(res, config, rendered.nonce, req.ctx.spaceDeployment);
|
|
1613
1620
|
res.send(rendered.body ?? "", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createServer } from "./createServer-
|
|
1
|
+
import { t as createServer } from "./createServer-99dZ2sjd.js";
|
|
2
2
|
import { dataDirLookup } from "@plitzi/sdk-kernel/data";
|
|
3
3
|
import { createPageEngine } from "@plitzi/sdk-actions/worker";
|
|
4
4
|
// src/core/platform.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as escapeHtml } from "./core-
|
|
1
|
+
import { b as escapeHtml } from "./core-CxgbkcXo.js";
|
|
2
2
|
import { forwardedIp, requestAuthority, requestOrigin } from "@plitzi/sdk-kernel/http";
|
|
3
3
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
4
4
|
// src/core/oauth/consentPage.ts
|
package/dist/deploy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as resolveSdkAssetsDir } from "./chunks/sdkAssets-CXGoc_WE.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Q as escapeJson, b as escapeHtml, v as ownVersion } from "./chunks/core-CxgbkcXo.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import path from "node:path";
|
package/dist/handlers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as authRoutes, n as renewForNavigation, r as applySessionOutcome, t as isDocumentNavigation } from "./chunks/renewal-D98v6-Jd.js";
|
|
2
|
-
import { a as handleRegister, b as protectedResourceMetadata, i as handleAuthorizeSubmit, l as sendErrorJson, n as handleToken, r as handleAuthorizeStart, t as handleRevoke, y as authorizationServerMetadata } from "./chunks/token-
|
|
2
|
+
import { a as handleRegister, b as protectedResourceMetadata, i as handleAuthorizeSubmit, l as sendErrorJson, n as handleToken, r as handleAuthorizeStart, t as handleRevoke, y as authorizationServerMetadata } from "./chunks/token-BruOglXr.js";
|
|
3
3
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
4
4
|
import { authFailureMessage, carrierOf, createAuthorizer, csrfFailureMessage } from "@plitzi/sdk-kernel/identity";
|
|
5
5
|
// src/core/handlers/authRouteHandlers.ts
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
2
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
3
|
+
import { VisitorFact, VisitorFacts } from '@plitzi/sdk-shared/audiences';
|
|
4
|
+
/** What the experiments are read off: the pages' tree and the components'. */
|
|
5
|
+
type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>>;
|
|
6
|
+
type SpaceAudiences = {
|
|
7
|
+
has: boolean;
|
|
8
|
+
used: VisitorFact[];
|
|
9
|
+
};
|
|
10
|
+
/** Whether a space has Variants elements chosen by rules (its audiences) at all, and the visitor facts their rules read. */
|
|
11
|
+
export declare const spaceAudiences: (schema: SpaceTrees) => SpaceAudiences;
|
|
12
|
+
/**
|
|
13
|
+
* This request's visitor, as an audience's rules read them: their first visit's cookie, their agent, their languages,
|
|
14
|
+
* and the country the CDN in front said (`COUNTRY_HEADERS`).
|
|
15
|
+
*/
|
|
16
|
+
export declare const requestVisitorFacts: (req: Pick<SSRRequest, "headers">) => VisitorFacts;
|
|
17
|
+
/**
|
|
18
|
+
* What a page of this space is kept apart by for this request, asked before the cache is: the facts its audiences read,
|
|
19
|
+
* from the space this server holds already. `undefined` when it holds none — the render that reads it keeps nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare const audienceKeyFor: (req: Pick<SSRRequest, "headers">, held: SpaceTrees | undefined) => string | undefined;
|
|
22
|
+
export {};
|
|
@@ -8,6 +8,7 @@ type CacheKeyRequest = {
|
|
|
8
8
|
flagsVersion?: string;
|
|
9
9
|
draftVersion?: string;
|
|
10
10
|
};
|
|
11
|
+
audienceKey?: string;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
@@ -26,9 +27,16 @@ type CacheKeyRequest = {
|
|
|
26
27
|
* values, so a page drawn with one visitor's toolbar must not be served to the next. Keyed by its raw value — this
|
|
27
28
|
* key does not know which keys a space declares, and a space that declares none has no such cookie to split on.
|
|
28
29
|
*
|
|
29
|
-
* So are the
|
|
30
|
-
* the
|
|
31
|
-
*
|
|
30
|
+
* So are the variants of the space's A/B tests the visitor keeps: the page draws only the one each shows them. Keyed by
|
|
31
|
+
* the cookie's raw value, so visitors shown the same variants share a page. A visitor with none of a test kept is drawn
|
|
32
|
+
* one there and then, and that page is never kept (`prepareRender`'s `cacheable`): the next such visitor is drawn their
|
|
33
|
+
* own. The same for the visitor's places in the space's gradual rollouts (`plitzi_rollout`): the flags they answer are
|
|
34
|
+
* drawn into the page. And for what the space's audiences read of the visitor (`ctx.audienceKey`: their device, their
|
|
35
|
+
* language, whether they came before), only where its audiences read it.
|
|
36
|
+
*
|
|
37
|
+
* So are the feature flags and the A/B variants a tester forced from the dev tools, on a page that authorizes
|
|
38
|
+
* debugging: drawn with them, the page is not everybody's, and a tester holding the cookie must never be handed a page
|
|
39
|
+
* drawn without it. Keyed by its raw value, like the kept state.
|
|
32
40
|
*
|
|
33
41
|
* So is what the space's flags are at (`flagsVersion` on the resolved deployment), for a deployment that changes them
|
|
34
42
|
* apart from its revisions: a flag turned in production must reach the next visitor, while the revision is the same.
|
|
@@ -83,6 +91,12 @@ export declare const keepsVersion: (deployment: DeploymentVersion | undefined) =
|
|
|
83
91
|
/** Where the space a request resolves to is kept between renders, or nothing when it may not be (`keepsVersion`). */
|
|
84
92
|
export declare const offlineDataCacheKeyOf: (deployment: DeploymentVersion | undefined) => string | undefined;
|
|
85
93
|
export declare const readOfflineDataCacheKey: (key: string) => CacheKeyFacts;
|
|
86
|
-
export declare const buildRscCacheKey: (spaceId: number, environment: string, revision: number, userId: string | number | undefined, idsParam: string | undefined, req: CacheKeyRequest
|
|
94
|
+
export declare const buildRscCacheKey: (spaceId: number, environment: string, revision: number, userId: string | number | undefined, idsParam: string | undefined, req: CacheKeyRequest & {
|
|
95
|
+
headers: {
|
|
96
|
+
cookie?: string;
|
|
97
|
+
host?: string;
|
|
98
|
+
":authority"?: string;
|
|
99
|
+
};
|
|
100
|
+
}) => string;
|
|
87
101
|
export declare const readRscCacheKey: (key: string) => CacheKeyFacts;
|
|
88
102
|
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
2
|
+
type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>> & {
|
|
3
|
+
settings?: Partial<Pick<Schema['settings'], 'computed'>>;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Whether a space shows or says anything by the time — a time window, a countdown, a template on the page's clock — so
|
|
7
|
+
* a page of it is drawn at an instant the browser hydrates at.
|
|
8
|
+
*/
|
|
9
|
+
export declare const spaceReadsTheClock: (schema: SpaceTrees) => boolean;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
2
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
3
|
+
import { ExperimentAssignments } from '@plitzi/sdk-shared/experiments';
|
|
4
|
+
/** What the experiments are read off: the pages' tree and the components'. */
|
|
5
|
+
type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>>;
|
|
6
|
+
export type RequestExperiments = {
|
|
7
|
+
/**
|
|
8
|
+
* Every A/B test's variant for this visitor — theirs, never a tester's: the page hydrates with them as the variants it
|
|
9
|
+
* keeps, and shows what a tester forced over them (`forced`).
|
|
10
|
+
*/
|
|
11
|
+
assignments: ExperimentAssignments;
|
|
12
|
+
/**
|
|
13
|
+
* The `Set-Cookie` that keeps the variants drawn for this visitor just now. Its page is theirs alone: never kept for
|
|
14
|
+
* anybody else, who would be shown a variant they were never drawn.
|
|
15
|
+
*/
|
|
16
|
+
setCookie?: string;
|
|
17
|
+
/** The variants a tester forced that this space can show: shown over `assignments`, never kept as the visitor's. */
|
|
18
|
+
forced?: ExperimentAssignments;
|
|
19
|
+
/** The experiments drawn for this visitor just now — what the page reports to the space's analytics, once. */
|
|
20
|
+
drawn?: string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The variant of each of the space's A/B tests for this request — every one in the space, not this page's alone, so a
|
|
24
|
+
* visitor who goes on to the next page in the browser finds theirs already kept: what their cookie holds, and a draw
|
|
25
|
+
* for what it does not. Over them, what a tester forced (`plitzi_ab_qa`, `?ab=`) — read only where `debugAuthorized`,
|
|
26
|
+
* shown and never kept as the visitor's.
|
|
27
|
+
*
|
|
28
|
+
* A render nobody visits — a preview for a picture, a draft's unsaved edits — draws nothing and keeps nothing: what
|
|
29
|
+
* the visitor has not kept is shown as its first variant still shown (A, the control), the same in every picture.
|
|
30
|
+
*/
|
|
31
|
+
export declare const requestExperiments: (req: Pick<SSRRequest, "headers" | "protocol" | "query">, schema: SpaceTrees | undefined, { draws, debugAuthorized }: {
|
|
32
|
+
draws: boolean;
|
|
33
|
+
debugAuthorized: boolean;
|
|
34
|
+
}) => RequestExperiments;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SSRRequest } from '@plitzi/sdk-kernel/types';
|
|
2
|
+
import { Schema } from '@plitzi/sdk-shared';
|
|
3
|
+
import { RolloutBuckets } from '@plitzi/sdk-shared/flags';
|
|
4
|
+
export type RequestRollout = {
|
|
5
|
+
/** The visitor's place in every flag the space rolls out to part of its visitors. */
|
|
6
|
+
buckets: RolloutBuckets;
|
|
7
|
+
/** The `Set-Cookie` that keeps the places drawn for this visitor just now: their page is theirs alone. */
|
|
8
|
+
setCookie?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Where this request's visitor stands in the space's gradual rollouts: the places their cookie kept, and one drawn now
|
|
12
|
+
* for a flag it does not hold — kept from this response on. A render nobody visits (a picture, a draft's unsaved edits)
|
|
13
|
+
* draws nothing: a rollout's flag answers its own value there.
|
|
14
|
+
*/
|
|
15
|
+
export declare const requestRollout: (req: Pick<SSRRequest, "headers" | "protocol">, flags: Schema["flags"], draws: boolean) => RequestRollout;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as resolveRscData, t as createServer } from "./chunks/createServer-
|
|
2
|
-
import {
|
|
3
|
-
import { E as takeDraftOverride, _ as resolveServices, w as createMemoryDraftStore } from "./chunks/buildBody-
|
|
1
|
+
import { r as resolveRscData, t as createServer } from "./chunks/createServer-99dZ2sjd.js";
|
|
2
|
+
import { U as createCacheInvalidator, _ as createCloudAdapters, _t as DEFAULT_IGNORED_QUERY_PARAMS, c as fixedSpace, d as verifiedDomain, f as wildcardSubdomain, g as createJsonAdapters, h as createAuthAdapters, l as presentsCredential, m as refuse, n as createSpaceAdapters, p as createMemoryCache, s as authoringPreview, t as createRedisPageStore, u as renderGrant } from "./chunks/core-CxgbkcXo.js";
|
|
3
|
+
import { E as takeDraftOverride, _ as resolveServices, w as createMemoryDraftStore } from "./chunks/buildBody-Dg4acjni.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
6
6
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { SSRPlugin } from '../../types';
|
|
2
2
|
import { BadgeLinks, OfflineDataRaw, Environment, RenderMode, Server, SSRRenderResult, Theme, ColorScheme } from '@plitzi/sdk-shared';
|
|
3
|
+
import { VisitorFacts } from '@plitzi/sdk-shared/audiences';
|
|
4
|
+
import { ExperimentAssignments } from '@plitzi/sdk-shared/experiments';
|
|
5
|
+
import { RolloutBuckets } from '@plitzi/sdk-shared/flags';
|
|
3
6
|
export type ComponentProps = {
|
|
4
7
|
server: Partial<Server>;
|
|
5
8
|
renderMode?: Extract<RenderMode, 'raw'>;
|
|
@@ -27,6 +30,18 @@ export type ComponentProps = {
|
|
|
27
30
|
serverFlags?: Record<string, boolean>;
|
|
28
31
|
/** The flags a tester forced, for a page allowed to debug. See `prepareRender`. */
|
|
29
32
|
forcedFlags?: Record<string, boolean>;
|
|
33
|
+
/** The variant each of the space's A/B tests is drawn with for this visitor. See `prepareRender`. */
|
|
34
|
+
serverExperiments?: ExperimentAssignments;
|
|
35
|
+
/** The variants a tester forced, for a page allowed to debug. See `prepareRender`. */
|
|
36
|
+
forcedExperiments?: ExperimentAssignments;
|
|
37
|
+
/** The experiments drawn for this visitor by this render. See `prepareRender`. */
|
|
38
|
+
drawnExperiments?: string[];
|
|
39
|
+
/** The visitor's places in the space's gradual rollouts. See `prepareRender`. */
|
|
40
|
+
serverRollout?: RolloutBuckets;
|
|
41
|
+
/** What the space's audiences read of the visitor. See `prepareRender`. */
|
|
42
|
+
serverVisitor?: VisitorFacts;
|
|
43
|
+
/** The instant the page is drawn at, for a space that shows things by the time. See `prepareRender`. */
|
|
44
|
+
renderedAt?: number;
|
|
30
45
|
};
|
|
31
|
-
declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags }: ComponentProps) => import('react').JSX.Element;
|
|
46
|
+
declare const Component: ({ server, renderMode, previewMode, offlineData, environment, plugins, ssrResult, sdkDevToolsStylePath, sdkIconsStylePath, debugMode, overQuota, quotaNear, badge, theme, scheme, state, serverFlags, forcedFlags, serverExperiments, forcedExperiments, drawnExperiments, serverRollout, serverVisitor, renderedAt }: ComponentProps) => import('react').JSX.Element;
|
|
32
47
|
export default Component;
|
|
@@ -12,5 +12,7 @@ export type BuildBodyResult = {
|
|
|
12
12
|
cacheable: boolean;
|
|
13
13
|
/** The nonce the page's own scripts were rendered with — what its script policy names; empty without one. */
|
|
14
14
|
nonce: string;
|
|
15
|
+
/** What the page is sent with for this visitor alone (`RenderPrep.setCookies`). */
|
|
16
|
+
setCookies?: string[];
|
|
15
17
|
};
|
|
16
18
|
export declare const buildBody: (req: SSRRequest, config: SSRPageServerConfig, spaceId: number, environment: Environment, revision: number, renderFn: SSRTemplateFn, pluginManager: PluginManager, offlineDataCache?: TtlCache<OfflineDataRaw>, metrics?: RequestMetrics, offlineDataOverride?: OfflineDataRaw, published?: PageEngine["published"]) => Promise<BuildBodyResult>;
|
|
@@ -20,6 +20,11 @@ export type RenderPrep = {
|
|
|
20
20
|
cacheable: boolean;
|
|
21
21
|
/** A server provider of the page said its address shows nothing (`notFound`): sent with status 404. */
|
|
22
22
|
notFound: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Sent with the page: what was drawn for this visitor just now and is kept in their cookies — the variants of the
|
|
25
|
+
* space's A/B tests, their places in its gradual rollouts.
|
|
26
|
+
*/
|
|
27
|
+
setCookies?: string[];
|
|
23
28
|
/** The page asked for was withheld from this visitor (`access`): sent with 401 or 403, its refusal drawn. */
|
|
24
29
|
refused?: PageWithheld;
|
|
25
30
|
};
|
package/dist/oauth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as dropPending, D as putCode, E as getPending, O as putPending, S as scopesOf, T as getClient, a as handleRegister, b as protectedResourceMetadata, c as redirectWithError, d as randomId, f as verifyChallenge, g as REGISTER_PATH, h as PROTECTED_RESOURCE_PATH, i as handleAuthorizeSubmit, l as sendErrorJson, m as AUTHORIZE_PATH, n as handleToken, o as redirectToSignIn, p as AUTHORIZATION_SERVER_PATH, r as handleAuthorizeStart, s as redirectWithCode, t as handleRevoke, u as sendJson, v as TOKEN_PATH, w as getAccess, x as resourceMetadataUrl, y as authorizationServerMetadata } from "./chunks/token-
|
|
1
|
+
import { C as dropPending, D as putCode, E as getPending, O as putPending, S as scopesOf, T as getClient, a as handleRegister, b as protectedResourceMetadata, c as redirectWithError, d as randomId, f as verifyChallenge, g as REGISTER_PATH, h as PROTECTED_RESOURCE_PATH, i as handleAuthorizeSubmit, l as sendErrorJson, m as AUTHORIZE_PATH, n as handleToken, o as redirectToSignIn, p as AUTHORIZATION_SERVER_PATH, r as handleAuthorizeStart, s as redirectWithCode, t as handleRevoke, u as sendJson, v as TOKEN_PATH, w as getAccess, x as resourceMetadataUrl, y as authorizationServerMetadata } from "./chunks/token-BruOglXr.js";
|
|
2
2
|
import { readRawBody } from "@plitzi/sdk-kernel/http";
|
|
3
3
|
// src/core/oauth/challenge.ts
|
|
4
4
|
/** The credential on an MCP request. `Authorization: Bearer` is what RFC 6750 defines and what a remote host
|
package/dist/platform.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createPlatform } from "./chunks/platform-
|
|
1
|
+
export { t as createPlatform } from "./chunks/platform-j6joAbxu.js";
|
package/dist/project.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as LIVE_PAGES_PATH } from "./chunks/createServer-
|
|
2
|
-
import { _ as createCloudAdapters, b as escapeHtml, g as createJsonAdapters } from "./chunks/core-
|
|
3
|
-
import { t as createPlatform } from "./chunks/platform-
|
|
1
|
+
import { n as LIVE_PAGES_PATH } from "./chunks/createServer-99dZ2sjd.js";
|
|
2
|
+
import { _ as createCloudAdapters, b as escapeHtml, g as createJsonAdapters } from "./chunks/core-CxgbkcXo.js";
|
|
3
|
+
import { t as createPlatform } from "./chunks/platform-j6joAbxu.js";
|
|
4
4
|
import { reachOwnServer } from "@plitzi/sdk-kernel/outbound";
|
|
5
5
|
import { EMPTY_SCHEMA } from "@plitzi/sdk-shared/schema";
|
|
6
6
|
import { mkdir, writeFile } from "node:fs/promises";
|
package/dist/spaces.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as PREVIEW_KEY_LENGTH, s as authoringPreview, p as createMemoryCache, n as createSpaceAdapters, c as fixedSpace, i as parsePreviewLabel, l as presentsCredential, a as previewLabel, m as refuse, u as renderGrant, o as snapshotPreview, d as verifiedDomain, f as wildcardSubdomain } from "./chunks/core-
|
|
1
|
+
export { r as PREVIEW_KEY_LENGTH, s as authoringPreview, p as createMemoryCache, n as createSpaceAdapters, c as fixedSpace, i as parsePreviewLabel, l as presentsCredential, a as previewLabel, m as refuse, u as renderGrant, o as snapshotPreview, d as verifiedDomain, f as wildcardSubdomain } from "./chunks/core-CxgbkcXo.js";
|
package/dist/ssr.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { S as PluginManager, t as buildBody, w as createMemoryDraftStore, E as takeDraftOverride } from "./chunks/buildBody-
|
|
1
|
+
export { S as PluginManager, t as buildBody, w as createMemoryDraftStore, E as takeDraftOverride } from "./chunks/buildBody-Dg4acjni.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.39.
|
|
3
|
+
"version": "0.39.13",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
"./dist/env.js"
|
|
96
96
|
],
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@plitzi/plitzi-sdk": "0.39.
|
|
99
|
-
"@plitzi/sdk-actions": "0.39.
|
|
100
|
-
"@plitzi/sdk-kernel": "0.39.
|
|
101
|
-
"@plitzi/sdk-shared": "0.39.
|
|
98
|
+
"@plitzi/plitzi-sdk": "0.39.13",
|
|
99
|
+
"@plitzi/sdk-actions": "0.39.13",
|
|
100
|
+
"@plitzi/sdk-kernel": "0.39.13",
|
|
101
|
+
"@plitzi/sdk-shared": "0.39.13",
|
|
102
102
|
"ejs": "^7.0.2",
|
|
103
103
|
"esbuild": "^0.28.2",
|
|
104
104
|
"jsonwebtoken": "^9.0.3",
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
117
|
"devDependencies": {
|
|
118
|
-
"@plitzi/sdk-runtime": "0.39.
|
|
118
|
+
"@plitzi/sdk-runtime": "0.39.13",
|
|
119
119
|
"@types/ejs": "^3.1.5",
|
|
120
120
|
"@types/jsonwebtoken": "^9.0.10",
|
|
121
121
|
"@types/node": "^26.6.6",
|
|
@@ -1,61 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* An accordion — questions whose answers open one at a time
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* revealed by the state, so it starts hidden.
|
|
2
|
+
* An accordion — questions whose answers open one at a time — a `list` over the questions, its row a `disclosure` of
|
|
3
|
+
* one group (`name: 'faq'`), so opening one closes the one that was open. Each is the browser's `<details>`: it opens before the page's script runs, find-in-page opens the one holding what was found, and
|
|
4
|
+
* the closed answers are still in the page for search engines. Its summary is the control and its name, and the marker
|
|
5
|
+
* at its end turns as it opens — no state, no `ariaExpanded`.
|
|
7
6
|
*/
|
|
8
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
container,
|
|
9
|
+
disclosure,
|
|
10
|
+
disclosureSummary,
|
|
11
|
+
list,
|
|
12
|
+
listItem,
|
|
13
|
+
paragraph,
|
|
14
|
+
styles,
|
|
15
|
+
text
|
|
16
|
+
} from '@plitzi/sdk-authoring';
|
|
9
17
|
|
|
10
18
|
import type { ElementSpec, SpaceSpec } from '@plitzi/sdk-authoring';
|
|
11
19
|
|
|
12
20
|
const QUESTIONS = [
|
|
13
|
-
{
|
|
14
|
-
{
|
|
15
|
-
{
|
|
21
|
+
{ question: 'How long does shipping take?', answer: 'Three working days, anywhere in Europe.' },
|
|
22
|
+
{ question: 'Can I return an order?', answer: 'Within thirty days, unopened, at no cost.' },
|
|
23
|
+
{ question: 'Is there a warranty?', answer: 'Two years on every product we sell.' }
|
|
16
24
|
];
|
|
17
25
|
|
|
26
|
+
const questions = styles('faq-questions', { padding: '0px', margin: '0px', 'list-style': 'none' });
|
|
27
|
+
|
|
18
28
|
const question = styles('faq-question', {
|
|
19
|
-
css: {
|
|
20
|
-
display: 'flex',
|
|
21
|
-
'justify-content': 'space-between',
|
|
22
|
-
width: '100%',
|
|
23
|
-
padding: '16px 0px',
|
|
24
|
-
border: 'none',
|
|
25
|
-
'background-color': 'transparent',
|
|
26
|
-
'font-size': '16px',
|
|
27
|
-
'font-weight': '600',
|
|
28
|
-
cursor: 'pointer'
|
|
29
|
-
},
|
|
29
|
+
css: { padding: '16px 0px', 'font-size': '16px', 'font-weight': '600' },
|
|
30
30
|
states: { 'focus-visible': { outline: '2px solid currentColor', 'outline-offset': '2px' } }
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
const answer = styles('faq-answer', { 'padding-bottom': '16px', margin: '0px' });
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
];
|
|
35
|
+
/** The questions as data, one row each: its summary, what is pressed, and the answer it shows. */
|
|
36
|
+
const faq: ElementSpec = list({
|
|
37
|
+
id: 'faq',
|
|
38
|
+
class: questions,
|
|
39
|
+
items: QUESTIONS,
|
|
40
|
+
row: row =>
|
|
41
|
+
listItem({
|
|
42
|
+
children: [
|
|
43
|
+
disclosure({
|
|
44
|
+
name: 'faq',
|
|
45
|
+
children: [
|
|
46
|
+
disclosureSummary({ class: question, children: [text({ from: `${row.item}.question` })] }),
|
|
47
|
+
paragraph({ from: `${row.item}.answer`, class: answer })
|
|
48
|
+
]
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
});
|
|
54
53
|
|
|
55
54
|
export const recipe: SpaceSpec = {
|
|
56
55
|
name: 'Questions',
|
|
57
56
|
permanentUrl: 'questions',
|
|
58
|
-
pages: [
|
|
59
|
-
{ id: 'home', name: 'Home', slug: '', body: [container({ subType: 'main', children: QUESTIONS.flatMap(faqItem) })] }
|
|
60
|
-
]
|
|
57
|
+
pages: [{ id: 'home', name: 'Home', slug: '', body: [container({ subType: 'main', children: [faq] })] }]
|
|
61
58
|
};
|
|
@@ -82,12 +82,15 @@ button({ content: 'Menu', bind: { ariaExpanded: 'state.menuOpen' }, flows: [[onC
|
|
|
82
82
|
|
|
83
83
|
An "active" variant is for the eyes. `ariaPressed` and `ariaExpanded` are for everyone else. Use both. A button that
|
|
84
84
|
opens a panel also names it — `controls: 'menu-panel'`, the panel's id (authoring gives the panel the anchor
|
|
85
|
-
`aria-controls` needs
|
|
85
|
+
`aria-controls` needs). In a list's row, both are the row's own: each
|
|
86
86
|
row's panel is drawn as `<id>-<row>`, and the row's button points at its own. Words that change while somebody is on the page
|
|
87
87
|
— a count, a total, a status — sit in `container({ live: 'polite', … })`, so a screen reader says them when they change.
|
|
88
|
-
A part that opens and closes
|
|
89
|
-
`
|
|
90
|
-
|
|
88
|
+
A part that opens and closes — a question and its answer, a menu, "show more" — is a `disclosure`, and needs no state
|
|
89
|
+
nor `ariaExpanded`: `disclosure({ children: [disclosureSummary([text({ content: 'Question' })]), …what it shows] })`.
|
|
90
|
+
It is the browser's own `<details>`, announced as one; the summary is the control and its name (words in it, never a
|
|
91
|
+
button), and lights the `expanded` state while open. One `name` for several makes them an accordion, one open at a time
|
|
92
|
+
([recipes/accordion.ts](../recipes/accordion.ts)); Escape closes it, and so does a press outside with
|
|
93
|
+
`closeOnClickOutside` (a menu).
|
|
91
94
|
Results, a menu or a set of options someone goes through with the keyboard sit in `focusGroup({ label, children })`:
|
|
92
95
|
↑/↓ move between the controls inside, ←/→ to the first of the next or previous list, and ↓ from a search field inside
|
|
93
96
|
goes down into them — Tab alone took a stop per result.
|
|
@@ -18,6 +18,21 @@ console (`[plitzi] auth.login: …`) — read it before suspecting the form.
|
|
|
18
18
|
On the platform, `userProvider: 'server'` signs in by leaving the page: a `link` with `mode: 'external'` to
|
|
19
19
|
`/auth/sign-in?return=/` sends the visitor to sign in and back, signed in on the space's own host.
|
|
20
20
|
|
|
21
|
+
## The elements
|
|
22
|
+
|
|
23
|
+
Three elements say who is visiting, in the builder's User category — use them before writing a sign-in by hand:
|
|
24
|
+
|
|
25
|
+
- `signInForm({ redirectTo: '/dashboard' })` — the sign-in itself: one button through a provider that signs in out and
|
|
26
|
+
back (`server`, Plitzi's), an email and a password against the space's own (`basic`), then the code of a second factor
|
|
27
|
+
when the account has one. Each refusal is said for what it is (`wrongMessage`, `unverifiedMessage`…); signed in, the
|
|
28
|
+
visitor goes to `redirectTo`, or back to the `?redirect=` of this site they were sent with.
|
|
29
|
+
- `account({ signInHref: '/sign-in', children: [link({ href: '/profile', content: 'Profile' })] })` — a top bar's
|
|
30
|
+
corner: "Sign in" for a guest (to `signInHref` with `?redirect=`, or the provider's own when empty — a `basic` space
|
|
31
|
+
needs the page: `account-sign-in-unreachable`), and for somebody signed in their initials opening a menu with their
|
|
32
|
+
name, address, its children and "Sign out". Nothing while the session is being found out.
|
|
33
|
+
- `avatar({ name: '{{ auth.details.username }}', src })` — a person: their picture, or their initials on a colour of
|
|
34
|
+
their own; `decorative` beside their name.
|
|
35
|
+
|
|
21
36
|
## The steps
|
|
22
37
|
|
|
23
38
|
```ts
|
|
@@ -66,18 +66,25 @@ The space is not written until these are fixed.
|
|
|
66
66
|
| `condition-template` | a `when` rule with a template in its field or value — `value: '{{ list_genres.item.id }}'` — compared as that text, so it never holds | a path: `field: 'state.picks'`; another path as the value, `value: 'list_genres.item.id', isBinding: true`; an expression, a computed value |
|
|
67
67
|
| `controls-other-row` | a button's `controls` naming an element a list draws in its rows, from outside that row | the button in the same row as what it shows and hides, or `controls` naming an element outside the list |
|
|
68
68
|
| `controls-unknown` | a button's `controls` naming no element of the space | the id of the element it shows and hides: `controls: 'faq-answer'` |
|
|
69
|
+
| `countdown-to` | a `countdown`'s `to` that is not an instant with its offset — never read, so it counts to nothing | `to: '2026-12-01T09:00:00Z'` (or `+01:00`); empty inside a `timeWindow` to count to its `endsAt` |
|
|
69
70
|
| `css-property-twice` | one property written twice in a rule set — `paddingTop` beside `'padding-top'` — so one would silently win | keep one |
|
|
70
71
|
| `css-property-unknown` | a CSS property that does not exist | the property it suggests; a custom property starts with `--` |
|
|
71
72
|
| `css-value` | an empty CSS value, or one with `;` or `{}` | one value per property; leave a property out instead of writing it empty |
|
|
72
73
|
| `declared-callback-target` | a `declaredCallback` target with a key beside `on` and `params` — read nowhere, so the step runs without it | the value in `params`: `{ on: 'calendar', params: { date } }` |
|
|
74
|
+
| `disclosure-summary-control` | a button, a link or a field inside a `disclosureSummary` — the summary is the control: one inside it is a control within a control, which a keyboard and a screen reader cannot tell apart, and pressing it opens the disclosure too | words in the summary (a text, a heading); the button or the link in what the disclosure shows, or beside it |
|
|
75
|
+
| `disclosure-summary-first` | a `disclosure` whose first child is not its `disclosureSummary` — the browser opens it by its first `<summary>` alone, and draws "Details" of its own otherwise | `disclosure({ children: [disclosureSummary([…]), …what it shows] })`: one summary, first |
|
|
73
76
|
| `element-ids-target` | a step refreshing containers by id (`invalidateElements`, `invalidateQueries({ elements })`) naming one the space does not have, or one that is not an `apiContainer` | the id of the `apiContainer` whose data the step changes: `invalidateElements: ['posts']` |
|
|
74
77
|
| `element-load-strategy` | a `loadStrategy` the element does not take | one of the values the message lists |
|
|
75
78
|
| `element-rejected` | an element the schema refused to hold | the problem listed with it |
|
|
76
79
|
| `element-runtime` | a `runtime` the element does not run in | one of the values the message lists |
|
|
77
80
|
| `element-shape` | an element that is not an object with a `type`, `attributes` and a list of `children` | build elements with their factories — `text(…)`, `container(…)` |
|
|
78
81
|
| `element-slot-unknown` | a `slots` key the element type does not have — its class would dress nothing | one of the slots `plitzi explain <type>` lists; the element itself takes `class` |
|
|
82
|
+
| `experiment-name` | by chance, a `variants`' `experiment` that a template cannot read as `experiments.x` | letters, digits and `_`, starting with a letter or `_` — or empty, for the element's own name |
|
|
83
|
+
| `experiment-unknown` | a template, a binding or a `when` reading an experiment no `variants` chosen by chance runs | the name it suggests, or a `variants` with that `experiment` |
|
|
84
|
+
| `experiment-weight` | by chance, a `variantItem`'s `weight` that is not a whole number from 0 to 100, or variants that all weigh 0 | `weight: 50`; 0 shows a variant to nobody, and at least one has to show |
|
|
79
85
|
| `flag-gate` | an element's or a page's `flag` that is not a flag name | `flag: 'newCheckout'`, or `flag: '!newCheckout'` for "only while off" |
|
|
80
86
|
| `flag-name` | a flag whose name a template cannot read as `flags.x` | letters, digits and `_` |
|
|
87
|
+
| `flag-rollout` | a flag's `rollout` that is not `{ percent, value }` — a whole share from 0 to 100 and the answer it gives | `rollout: { percent: 10, value: true }` |
|
|
81
88
|
| `flag-rule-shape` | a flag rule that is not `{ when, value }`, or whose `value` is not `true` or `false` | `{ when: { … }, value: true }` |
|
|
82
89
|
| `flag-shape` | a flag whose `value` is not `true` or `false` | `{ value: false, rules: [] }` |
|
|
83
90
|
| `flag-undeclared` | a gate on a flag the space does not declare — it reads as off, so the element never (or always) renders | declare it in `flags`, or remove the gate |
|
|
@@ -180,6 +187,7 @@ The space is not written until these are fixed.
|
|
|
180
187
|
| `template-text-into-value` | a template, which renders text, feeding an attribute that holds a list or an object | `bindTemplate('items', source, '{{ … }}', { returns: 'value' })` |
|
|
181
188
|
| `template-unknown-name` | a name in a template that is not a source, a variable or a route param | the full source name (`list_rows.item`), `navigation.queryParams.x`, or `source` for the bound value |
|
|
182
189
|
| `template-unreadable` | a template with an operator, a filter or a function that does not exist, or broken syntax | an operator, a filter or a function the interpreter has — the message names the one it could not read; `matches` never exists |
|
|
190
|
+
| `time-window-bound` | a `timeWindow`'s `startsAt` or `endsAt` that is not an instant with its offset — never read, so no bound | `startsAt: '2026-12-01T09:00:00Z'` (or `+01:00`); empty for no bound |
|
|
183
191
|
| `transformer-params` | a transformer param that does not exist, or a value outside its options | the params and values it lists |
|
|
184
192
|
| `trigger-interval` | an `onInterval` that never ticks: not a whole number of milliseconds, or below 250 | `onInterval(5000)` |
|
|
185
193
|
| `trigger-keys` | an `onKey` shortcut that cannot fire: two keys at once, only modifiers, or a name that is not a key | `onKey('f')`, `onKey('shift+f')`, `onKey('mod+k, escape')` |
|
|
@@ -193,6 +201,9 @@ The space is not written until these are fixed.
|
|
|
193
201
|
| `unknown-transformer` | a transformer that does not exist | one of the transformers it lists |
|
|
194
202
|
| `utility-module` | a utility sent to a module — a utility takes none | drop the `on` |
|
|
195
203
|
| `variant-bound-twice` | two bindings (`variantFrom`, `activeOn`, `activeWhen`) setting the variant of one class on one element — the second always wins | one `variantFrom` whose template answers every case: `{{ wide ? 'roomy' : current ? 'active' : 'idle' }}`; two things that change apart (a size, a lit state) are two classes, each with its own `variantFrom` |
|
|
204
|
+
| `variants-choose-by` | a `variants`' `chooseBy` that is neither `'chance'` nor `'rules'` — it chooses by chance | `chooseBy: 'chance'` or `chooseBy: 'rules'` |
|
|
205
|
+
| `variants-items` | a `variants` holding something beside its `variantItem`s, or too few — two to five by chance, one by rules | `variants({ children: [variantItem([…]), variantItem([…])] })` |
|
|
206
|
+
| `variants-rule` | a `variantItem`'s `when` that is not a rule group | `when: { combinator: 'and', rules: [{ field: 'visitor.device', operator: '=', value: 'mobile' }] }` |
|
|
196
207
|
| `visibility-as-attribute` | `visibility` bound as an attribute, which no element reads | `visible: { source, template }` |
|
|
197
208
|
| `visible-expression` | `visible` written as an expression (`"state.plan == 'pro'"`, `"a && !b"`) — it takes a source, read as one, which resolves to nothing | `visible: { source: 'state.plan', template: "{{ state.plan == 'pro' }}" }` — or a source alone, `'state.open'`, `'!state.open'` |
|
|
198
209
|
| `visitor-roles` | `settings.visitorRoles` written in a shape the runtime does not read | the shape the message gives |
|
|
@@ -206,6 +217,7 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
206
217
|
|
|
207
218
|
| Code | What was wrong | Write instead |
|
|
208
219
|
| --- | --- | --- |
|
|
220
|
+
| `account-sign-in-unreachable` | an `account` with no `signInHref` in a space that signs in with its own provider (`userProvider: "basic"`) — a sign-in there needs a form, so its "Sign in" leads nowhere | `signInHref: '/sign-in'`, the page with the space's `signInForm` |
|
|
209
221
|
| `action-output-path` | a read of `.data` on a provider fed by a server action — it publishes the action’s output at its root, and `.data` is a `query` provider’s answer | the output’s own field — `apiContainer_feed.stories`, not `apiContainer_feed.data.stories` |
|
|
210
222
|
| `animation-name-unknown` | `animation-name` naming keyframes the space does not declare — nothing plays | declare them in the space's `keyframes`, or name one it has |
|
|
211
223
|
| `browser-state-without-keep-state` | `browserState` without `keepState` — nothing is kept in the first place | `settings.keepState: true`, or remove `browserState` |
|
|
@@ -215,9 +227,14 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
215
227
|
| `control-in-decorative` | a control inside a `decorative` container — Tab lands on something nothing announces | move it out of the illustration |
|
|
216
228
|
| `control-without-name` | a button or a link with no words, or a field nothing names | `title` on the button, `label` on the link, `label` (with `hideLabel: true`) on the field |
|
|
217
229
|
| `controls-no-anchor` | a button's `controls` naming no anchor — `aria-controls` points at nothing | an `anchor` on the element it shows and hides, and `controls` naming it |
|
|
230
|
+
| `countdown-units` | a `countdown` whose `smallest` unit is larger than its `largest` — it says the `largest` alone | `largest` the larger: `largest: 'days', smallest: 'minutes'` |
|
|
231
|
+
| `countdown-without-end` | a `countdown` with no `to` and no `timeWindow` around it with an `endsAt` — it shows zeros | `to: '2026-12-01T09:00:00Z'`, or the countdown inside the `timeWindow` whose end it counts to |
|
|
218
232
|
| `default-content-beside-children` | a button printing its default "Button" beside its children | `content: ''` |
|
|
233
|
+
| `disclosure-summary-unnamed` | a `disclosureSummary` with nothing in it — a screen reader announces a control with no name | a text or a heading inside it: what opening it shows |
|
|
219
234
|
| `dropdown-without-control` | a dropdown opened from a box or an icon — no keyboard opens it | a `button` as what opens it (`title` if it is only an icon) |
|
|
220
235
|
| `embed-without-title` | an `embed` with no `title` — a frame a screen reader cannot describe | say what it shows in `title` |
|
|
236
|
+
| `experiment-weights-differ` | two `variants` running the same test with different weights — they share it, so one set is ignored | the same weights on both, or a test name of its own for each |
|
|
237
|
+
| `experiment-weights-total` | by chance, `variant`s whose `weight`s do not add up to 100 — each is read as its part of their total | percents adding up to 100: 50/25/20/5, or the proportions the warning gives |
|
|
221
238
|
| `flag-rule-empty` | a flag rule with no conditions — skipped, never read as "always" | give it a condition, or set the flag's `value` instead |
|
|
222
239
|
| `flag-unused` | a declared flag nothing gates on and no template reads | gate what it switches (`flag: 'x'`), or remove it once the feature has shipped |
|
|
223
240
|
| `focus-on-field-box` | a `focus` or `focus-visible` state on a text field's or a select's `input` slot — the box the field is drawn in, which never takes focus, so no ring is ever shown | `'focus-within'` on the same class, or the state on the `field` slot |
|
|
@@ -259,12 +276,16 @@ The space renders, and renders something you probably did not mean. Fix every on
|
|
|
259
276
|
| `template-or-value` | a template's `or` (or `and`) beside a text or a number — `sort or 'listeners'` — which answers true or false, never the value | a fallback value with `??`: `sort ?? 'listeners'`; a test with `or` between two conditions |
|
|
260
277
|
| `test-account-role-gone` | a test account holds a visitor role the space does not declare in `settings.visitorRoles` — removed since, or never there: a journey plays it without that role, and one that needed what it gave fails | one of the space’s roles for the account — or the role declared again |
|
|
261
278
|
| `test-unreadable` | a test of the space — an element check or a flow — that cannot be read as it is written: a page no page of the space answers, an element it no longer has, a relation that is none. A snapshot and a publish wait for it | the test as the message says — or the space back to what the test expects |
|
|
279
|
+
| `time-window-empty` | a `timeWindow` that ends before it starts — it never shows what it holds | `endsAt` after `startsAt` |
|
|
262
280
|
| `transient-state-without-keep-state` | `transientState` without `keepState` — nothing is kept in the first place | `settings.keepState: true`, or remove `transientState` |
|
|
263
281
|
| `unknown-element-type` | a type no built-in element has | the built-in it suggests; a plugin's declaration goes in `authorSpace(space, { plugins: [declaration] })` |
|
|
264
282
|
| `unknown-global-callback` | a global callback no built-in source declares — it runs only if something registers it | the built-in it suggests, or make sure a plugin or module of the space registers it |
|
|
265
283
|
| `unknown-utility` | a utility that is not one of the built-in ones | one of the built-in utilities |
|
|
266
284
|
| `unknown-variable` | a `var(--x)` nothing in the space declares — the property it is in is dropped | declare it under `variables`, fix the name, or give it a fallback: `var(--x, …)` |
|
|
267
285
|
| `unknown-variant` | a variant no class of the element and no style of its type declares — nothing applies | declare it (`styles(name, { variants: { … } })`), or name one that is |
|
|
286
|
+
| `variants-builder-variant` | a `variants`' `builderVariant` that is not the place of one of its variants — the builder shows the first | the place of a variant it has, from 0 |
|
|
287
|
+
| `variants-no-fallback` | by rules, a `variants` whose every variant has a rule: a visitor matching none is shown nothing | end it with a `variantItem` with no `when`, for everybody else |
|
|
288
|
+
| `variants-unreachable` | by rules, a `variantItem` after one with no rule, which takes everybody left — it is never shown | move the variant with no rule last, or give it one |
|
|
268
289
|
|
|
269
290
|
## Suggested
|
|
270
291
|
|
|
@@ -58,6 +58,13 @@ declare is an error (`flag-unknown`).
|
|
|
58
58
|
Prefer a gate to `visible: 'flags.x'`: a visibility bound to a flag still renders the hidden half and ships it in the
|
|
59
59
|
HTML. Reach for the source only for what a gate cannot say — a label that changes, a step that branches.
|
|
60
60
|
|
|
61
|
+
## Rolling out gradually
|
|
62
|
+
|
|
63
|
+
`rollout: { percent: 10, value: true }` on a flag turns it on for 10% of the visitors when none of its rules matches;
|
|
64
|
+
the rest get its `value`. Each visitor keeps their place (a cookie), so raising the percent keeps everyone who was in —
|
|
65
|
+
10, then 50, then 100, then remove the flag. Rules still come first: a rule for staff answers before the rollout. Not
|
|
66
|
+
access control — a visitor's place is theirs to change. A malformed one is `flag-rollout`.
|
|
67
|
+
|
|
61
68
|
## Who decides
|
|
62
69
|
|
|
63
70
|
The space's declaration answers first. Above it, in order, each may override a flag — only one the space declares:
|
|
@@ -76,3 +83,63 @@ and a self-hosted server keeps the last ones it fetched — so a published site
|
|
|
76
83
|
|
|
77
84
|
Remove the gate from what stays, delete what it replaced, and remove the flag. A declared flag nothing reads is a
|
|
78
85
|
warning (`flag-unused`): it is a switch nobody can see the effect of.
|
|
86
|
+
|
|
87
|
+
## Variants: A/B tests and audiences
|
|
88
|
+
|
|
89
|
+
A flag shows the same side to everyone its rules match; `variants` shows each visitor one of its `variantItem`s, chosen
|
|
90
|
+
**by chance** (an A/B test, the default) or **by rules** (who the visitor is). Only the variant shown is drawn.
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
variants({
|
|
94
|
+
children: [
|
|
95
|
+
variantItem({ weight: 90, children: [heading({ content: 'Build faster' })] }), // A: 90% of the visitors
|
|
96
|
+
variantItem({ weight: 10, children: [heading({ content: 'Ship today' })] }) // B: 10%
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**By chance**, it holds two to five variants — A first, then B… A `weight` is the percent of the visitors it
|
|
102
|
+
is shown to, and the variants' add up to 100 — 50/25/20/5, any split (`experiment-weights-total` warns otherwise; 50
|
|
103
|
+
each by default). The server draws the visitor's variant and keeps it in a cookie, so a reload or a later visit shows the same,
|
|
104
|
+
and a visitor keeps theirs when the shares change; 0 shows a variant to nobody, one left with a share ends the test. Its
|
|
105
|
+
`experiment` names the test — left empty, the element's id does (`pricing-test` runs `pricing_test`) — and two with the
|
|
106
|
+
same name show a visitor the same variant (`experiment-weights-differ` warns when their shares disagree). Count a
|
|
107
|
+
conversion with the `reachGoal('signup')` step: Plitzi's analytics shows each variant's visitors, conversions and rate
|
|
108
|
+
against A's. `{{ experiments.<name> }}` is `'a'`, `'b'`… for a flow. To see a variant you were not drawn, where debugging
|
|
109
|
+
is authorized: the dev tools' **Experiments** tab, or `?ab=heroTest:b` in the address.
|
|
110
|
+
|
|
111
|
+
**By rules** — `chooseBy: 'rules'` — it shows the first variant whose `when` the visitor matches: a rule group over what a
|
|
112
|
+
flag's rules see, `queryParams.utm_source` included, and the visitor: `visitor.returning`, `visitor.language` (`es`),
|
|
113
|
+
`visitor.device` (`mobile`, `tablet`, `desktop`), `visitor.country` (`ES`, `MX` — what the CDN in front of the server
|
|
114
|
+
says; empty without one, so end with an "everybody else"). End it with a variant with no `when`, for everybody else
|
|
115
|
+
(`variants-no-fallback` warns otherwise):
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
variants({
|
|
119
|
+
chooseBy: 'rules',
|
|
120
|
+
children: [
|
|
121
|
+
variantItem({
|
|
122
|
+
when: { combinator: 'and', rules: [{ field: 'visitor.device', operator: '=', value: 'mobile' }] },
|
|
123
|
+
children: [text({ content: 'Get the app' })]
|
|
124
|
+
}),
|
|
125
|
+
variantItem([text({ content: 'Welcome' })])
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A variant keeps its `weight` and its `when` whichever way it chooses, so switching loses neither. In the builder its
|
|
131
|
+
settings list the variants with their share or their rule; the canvas shows the one picked there (`builderVariant`, its
|
|
132
|
+
place from 0) while editing, and the preview the visitor chosen in the State Manager's **Visitor** tab.
|
|
133
|
+
|
|
134
|
+
## Showing something for a while
|
|
135
|
+
|
|
136
|
+
`timeWindow({ startsAt: '2026-12-01T09:00:00Z', endsAt: '2026-12-08T09:00:00Z', children })` shows what it holds only
|
|
137
|
+
between the two instants — ISO 8601 with the offset, never a local time (`time-window-bound`); either empty is no
|
|
138
|
+
bound. An open page shows or hides it when the window opens or closes. In the builder it always shows while editing;
|
|
139
|
+
the preview reads it at the date chosen in the Visitor tab.
|
|
140
|
+
|
|
141
|
+
`countdown({ to: '2026-12-01T09:00:00Z' })` says how long is left — days to seconds, named in the space's language
|
|
142
|
+
(`labels: 'short'` or `'none'`; `largest: 'hours'` says 49 hours) — and `countdown()` inside a `timeWindow` counts to its
|
|
143
|
+
`endsAt`, so the date is written once. At zero it stays at zero and runs `onCountdownEnd`: reveal what waited with a
|
|
144
|
+
flow, or hide the countdown with the window around it. Style its slots — `unit`, `value`, `label` — for boxes or a line.
|
|
145
|
+
|
|
@@ -149,7 +149,10 @@ the submit, and the browser says which.
|
|
|
149
149
|
The toast carries no class of the space's, so this — not a `.Toastify__*` rule in `customCss` — is where it is
|
|
150
150
|
dressed.
|
|
151
151
|
|
|
152
|
-
Copy link: `copyToClipboard('{{ navigation.href }}')`, then the toast — it fails with no clipboard.
|
|
152
|
+
Copy link: `copyToClipboard('{{ navigation.href }}')`, then the toast — it fails with no clipboard. Share:
|
|
153
|
+
`named('sent', share({ title: 'Our launch' }))` opens the device's sheet for this page, or copies the address where
|
|
154
|
+
there is none — a toast on `sent.copied` says "Link copied" only then. `fullscreen('map')` shows an element on the whole
|
|
155
|
+
screen and back (`'enter'`, `'exit'` one way); where the browser cannot, the step fails into `onFailure`.
|
|
153
156
|
|
|
154
157
|
## Modals, dropdowns, tabs
|
|
155
158
|
|
|
@@ -15,7 +15,7 @@ Read one only when the task names its subject.
|
|
|
15
15
|
| [data-and-visibility.md](data-and-visibility.md) | Bindings, providers, offline data, loading/empty/error states, live data, caching, showing and hiding, kept state |
|
|
16
16
|
| [kept-state.md](kept-state.md) | State that outlives a reload: `keepState`, transient and painted keys |
|
|
17
17
|
| [auth.md](auth.md) | Signing people in: providers, `authLogin`, `auth.*`, visitor roles |
|
|
18
|
-
| [feature-flags.md](feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships |
|
|
18
|
+
| [feature-flags.md](feature-flags.md) | Switching a part of the space on or off — a beta, a rollout, the old version kept until the new one ships; an A/B test; an audience; a time window |
|
|
19
19
|
| [lists.md](lists.md) | Rendering rows, filtering and sorting them, a detail page for one record, carousels |
|
|
20
20
|
| [typed-sources.md](typed-sources.md) | Data typed by a sample of it: `source()`, typed rows, `twig` for templates |
|
|
21
21
|
| [validation.md](validation.md) | How `authorSpace` checks, the loop that wastes no attempts, and what it cannot see |
|
|
@@ -39,7 +39,7 @@ A text template feeding `items` is refused: the list would receive the array wri
|
|
|
39
39
|
## Naming sources inside a template
|
|
40
40
|
|
|
41
41
|
Always the full name — the element's kind, an underscore, its id: `apiContainer_stats`, `list_rows`,
|
|
42
|
-
`modalContainer_credits`. The globals (`state`, `auth`, `navigation`, `variables`, `host`, `theme`, `flags`, `computed`) are
|
|
42
|
+
`modalContainer_credits`. The globals (`state`, `auth`, `navigation`, `variables`, `host`, `theme`, `flags`, `experiments`, `time`, `computed`) are
|
|
43
43
|
named as themselves — `{{ flags.newCheckout }}` is `true` or `false`, see [feature flags](feature-flags.md). In a flow, an earlier step is read by the name given with `named('quote', …)`: `{{ quote.output.total }}`.
|
|
44
44
|
|
|
45
45
|
An id with a hyphen is one name inside a template — `{{ apiContainer_tn-data.data.total }}` reads that provider. So
|
|
@@ -116,6 +116,8 @@ A lookup across two sources — a row joined to the stats around it:
|
|
|
116
116
|
- **Now** is `'now'`: `{{ 'now'|date('F Y', 'UTC') }}` is the month the page is rendered in — on the server, then again
|
|
117
117
|
in the browser, so keep it to the day or coarser (a minute can pass between the two). An age, a "this month", a
|
|
118
118
|
countdown reads it instead of a date written into the page.
|
|
119
|
-
- For "3 minutes ago" or "in 2 hours", `|ago` (`|ago('es')` in another language) —
|
|
120
|
-
|
|
119
|
+
- For "3 minutes ago" or "in 2 hours", `|ago` (`|ago('es')` in another language) — told by the page's clock, so it
|
|
120
|
+
moves on each minute while the page is open, and the server and the browser say the same thing (within the minute it
|
|
121
|
+
is "now"). The clock itself is `time`: `{{ time.now }}` (the start of the minute, ms) and `{{ time.today }}` (the day,
|
|
122
|
+
UTC) — "open now", today's entries — and nothing reading it renders more than once a minute. A transformer of a binding does the same: `dateConverter` with
|
|
121
123
|
`{ asAge: true }` (`isUnix: false` for an ISO string).
|