@plitzi/sdk-server 0.39.12 → 0.39.14

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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @plitzi/sdk-server
2
2
 
3
+ ## 0.39.14
4
+
5
+ ### Patch Changes
6
+
7
+ - f1922cf: 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 [f1922cf]
10
+ - @plitzi/plitzi-sdk@0.39.14
11
+ - @plitzi/sdk-actions@0.39.14
12
+ - @plitzi/sdk-kernel@0.39.14
13
+ - @plitzi/sdk-shared@0.39.14
14
+
15
+ ## 0.39.13
16
+
17
+ ### Patch Changes
18
+
19
+ - 919736b: 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 [919736b]
22
+ - @plitzi/plitzi-sdk@0.39.13
23
+ - @plitzi/sdk-actions@0.39.13
24
+ - @plitzi/sdk-kernel@0.39.13
25
+ - @plitzi/sdk-shared@0.39.13
26
+
3
27
  ## 0.39.12
4
28
 
5
29
  ### Patch Changes
package/dist/cache.js CHANGED
@@ -1 +1 @@
1
- export { _t as DEFAULT_IGNORED_QUERY_PARAMS, U as createCacheInvalidator, t as createRedisPageStore } from "./chunks/core-BJJ2GK64.js";
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 googleFontsUrlOf, C as resolveDebugMode, 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 requestRollout, T as buildServerInfo, X as spaceDocument, Y as offlineDataWith, ht as readCookie, mt as visitorScheme, q as digest$1, ut as offlineDataCacheKeyOf, w as requestExperiments, x as spaceTimeWindows, yt as requestPaintedStateWithDefaults } from "./core-BJJ2GK64.js";
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";
@@ -1934,7 +1934,7 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
1934
1934
  };
1935
1935
  const serverVisitor = audiences.has ? requestVisitorFacts(req) : void 0;
1936
1936
  const audienceUnkeyed = audiences.used.length > 0 && req.ctx.audienceKey === void 0;
1937
- const renderedAt = rawOfflineData && spaceTimeWindows(rawOfflineData.schema) ? Date.now() : void 0;
1937
+ const renderedAt = rawOfflineData && spaceReadsTheClock(rawOfflineData.schema) ? Date.now() : void 0;
1938
1938
  const flagOverrides = await requestFlagOverrides(config, {
1939
1939
  cookie: req.headers.cookie,
1940
1940
  authority: requestAuthority(req)
@@ -15,9 +15,9 @@ import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypt
15
15
  import { styleSheetCss, styleSheetHref, styleSheetLinkable } from "@plitzi/sdk-shared/style";
16
16
  import { fileURLToPath } from "node:url";
17
17
  import { readFileSync, statSync, writeFileSync } from "node:fs";
18
- import { audienceFactsUsed, audienceKeyOf, visitorFactsOf } from "@plitzi/sdk-shared/audiences";
18
+ import { COUNTRY_HEADERS, audienceFactsUsed, audienceKeyOf, visitorFactsOf } from "@plitzi/sdk-shared/audiences";
19
19
  import { chooseByOf, variantsElementsOf } from "@plitzi/sdk-shared/variants";
20
- import { hasTimeWindows } from "@plitzi/sdk-shared/timeWindows";
20
+ import { readsTheClock } from "@plitzi/sdk-shared/timeWindows";
21
21
  import { CLIENT_HEADER, CURRENT_HEADER, behindText, clientHeaderValue } from "@plitzi/sdk-shared/clients";
22
22
  // src/helpers/paintedCookie.ts
23
23
  /**
@@ -1198,13 +1198,17 @@ var spaceAudiences = (schema) => {
1198
1198
  return found;
1199
1199
  };
1200
1200
  var headerOf = (value) => Array.isArray(value) ? value[0] : value;
1201
- /** This request's visitor, as an audience's rules read them: their first visit's cookie, their agent, their languages. */
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
+ */
1202
1205
  var requestVisitorFacts = (req) => visitorFactsOf({
1203
1206
  cookies: req.headers.cookie,
1204
1207
  host: requestAuthority(req),
1205
1208
  userAgent: headerOf(req.headers["user-agent"]),
1206
1209
  mobileHint: headerOf(req.headers["sec-ch-ua-mobile"]),
1207
1210
  acceptLanguage: headerOf(req.headers["accept-language"]),
1211
+ country: COUNTRY_HEADERS.map((name) => headerOf(req.headers[name])).find(Boolean),
1208
1212
  now: Date.now()
1209
1213
  });
1210
1214
  /**
@@ -1303,6 +1307,20 @@ var buildServerInfo = (req, config, ssr) => {
1303
1307
  ssr
1304
1308
  });
1305
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
+ };
1306
1324
  // src/helpers/experiments.ts
1307
1325
  /** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
1308
1326
  var declaredOf = /* @__PURE__ */ new WeakMap();
@@ -1368,17 +1386,6 @@ var requestRollout = (req, flags, draws) => {
1368
1386
  setCookie: rolloutCookie(host, buckets, { secure: req.protocol === "https" })
1369
1387
  };
1370
1388
  };
1371
- // src/helpers/timeWindows.ts
1372
- /** Read once per space as it was read: the object is shared by every render of a revision (the offline-data cache). */
1373
- var known = /* @__PURE__ */ new WeakMap();
1374
- /** Whether a space shows things by the time — a page of it is drawn at an instant the browser hydrates at. */
1375
- var spaceTimeWindows = (schema) => {
1376
- const found = known.get(schema);
1377
- if (found !== void 0) return found;
1378
- const has = hasTimeWindows(schema);
1379
- known.set(schema, has);
1380
- return has;
1381
- };
1382
1389
  // src/helpers/escapeHtml.ts
1383
1390
  /** Text set inside HTML as text: never markup, whatever it holds. */
1384
1391
  var escapeHtml = (value) => value.replace(/[&<>"']/gu, (character) => {
@@ -2442,4 +2449,4 @@ var createRedisPageStore = (client, { prefix = "plitzi:{pages}:", maxBytes = byt
2442
2449
  return typeof count === "number" ? count : 0;
2443
2450
  }
2444
2451
  });
2445
- export { DEFAULT_RENDER_WAIT_MS as $, googleFontsUrlOf as A, normalizePlugins as B, resolveDebugMode 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, requestRollout 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, requestExperiments as w, spaceTimeWindows as x, RequestMetrics as y, requestPaintedStateWithDefaults as yt, normalizePluginSource as z };
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-Q0Io6XUw.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-BJJ2GK64.js";
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";
@@ -1,4 +1,4 @@
1
- import { t as createServer } from "./createServer-Bjy25_Ha.js";
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-BJJ2GK64.js";
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 { Q as escapeJson, b as escapeHtml, v as ownVersion } from "./chunks/core-BJJ2GK64.js";
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-COq-ufTp.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-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
@@ -9,7 +9,10 @@ type SpaceAudiences = {
9
9
  };
10
10
  /** Whether a space has Variants elements chosen by rules (its audiences) at all, and the visitor facts their rules read. */
11
11
  export declare const spaceAudiences: (schema: SpaceTrees) => SpaceAudiences;
12
- /** This request's visitor, as an audience's rules read them: their first visit's cookie, their agent, their languages. */
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
+ */
13
16
  export declare const requestVisitorFacts: (req: Pick<SSRRequest, "headers">) => VisitorFacts;
14
17
  /**
15
18
  * What a page of this space is kept apart by for this request, asked before the cache is: the facts its audiences read,
@@ -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 {};
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { r as resolveRscData, t as createServer } from "./chunks/createServer-Bjy25_Ha.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-BJJ2GK64.js";
3
- import { E as takeDraftOverride, _ as resolveServices, w as createMemoryDraftStore } from "./chunks/buildBody-Q0Io6XUw.js";
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";
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-COq-ufTp.js";
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-CZ2ShKb7.js";
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-Bjy25_Ha.js";
2
- import { _ as createCloudAdapters, b as escapeHtml, g as createJsonAdapters } from "./chunks/core-BJJ2GK64.js";
3
- import { t as createPlatform } from "./chunks/platform-CZ2ShKb7.js";
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-BJJ2GK64.js";
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-Q0Io6XUw.js";
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.12",
3
+ "version": "0.39.14",
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.12",
99
- "@plitzi/sdk-actions": "0.39.12",
100
- "@plitzi/sdk-kernel": "0.39.12",
101
- "@plitzi/sdk-shared": "0.39.12",
98
+ "@plitzi/plitzi-sdk": "0.39.14",
99
+ "@plitzi/sdk-actions": "0.39.14",
100
+ "@plitzi/sdk-kernel": "0.39.14",
101
+ "@plitzi/sdk-shared": "0.39.14",
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.12",
118
+ "@plitzi/sdk-runtime": "0.39.14",
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, a disclosure that expands and collapses, as `<details>`
3
- * would — written once and mapped over the questions: the open one
4
- * is a key in `state`, and each question reads it the same way. The button says whether its answer is open
5
- * (`ariaExpanded`) and which panel it opens (`controls`, by the panel's id), so a screen reader follows it; the panel is
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 { bindTemplate, button, container, onClick, paragraph, setState, styles } from '@plitzi/sdk-authoring';
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
- { id: 'shipping', question: 'How long does shipping take?', answer: 'Three working days, anywhere in Europe.' },
14
- { id: 'returns', question: 'Can I return an order?', answer: 'Within thirty days, unopened, at no cost.' },
15
- { id: 'warranty', question: 'Is there a warranty?', answer: 'Two years on every product we sell.' }
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
- /** One question: the button that opens it — closing the one open, or this one again — and the answer it opens. */
36
- const faqItem = ({ id, question: words, answer: text }: (typeof QUESTIONS)[number]): ElementSpec[] => [
37
- button({
38
- id: `${id}-question`,
39
- content: words,
40
- class: question,
41
- // Named by the panel's id: authoring gives the panel the anchor the page needs for `aria-controls`.
42
- controls: `${id}-answer`,
43
- ariaExpanded: false,
44
- bind: [bindTemplate('ariaExpanded', 'state.faq', `{{ source == '${id}' }}`, { returns: 'value' })],
45
- flows: [[onClick(), setState({ key: 'faq', type: 'text', value: `{{ state.faq == '${id}' ? '' : '${id}' }}` })]]
46
- }),
47
- // Revealed by the state, so it starts hidden: nothing flashes open before the page knows which one is.
48
- container({
49
- id: `${id}-answer`,
50
- visible: { source: 'state.faq', template: `{{ source == '${id}' }}` },
51
- children: [paragraph({ content: text, class: answer })]
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; [recipes/accordion.ts](../recipes/accordion.ts)). In a list's row, both are the row's own: each
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 on its own — a question and its answer, many open at once — needs no state at all:
89
- `container({ subType: 'details', children: [container({ subType: 'summary', children: [text('Question')] }), …] })`
90
- (`open: true` to start open), the browser's own disclosure, announced as one. The accordion recipe is for one-at-a-time.
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,10 +66,13 @@ 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 |
@@ -214,6 +217,7 @@ The space renders, and renders something you probably did not mean. Fix every on
214
217
 
215
218
  | Code | What was wrong | Write instead |
216
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` |
217
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` |
218
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 |
219
223
  | `browser-state-without-keep-state` | `browserState` without `keepState` — nothing is kept in the first place | `settings.keepState: true`, or remove `browserState` |
@@ -223,7 +227,10 @@ The space renders, and renders something you probably did not mean. Fix every on
223
227
  | `control-in-decorative` | a control inside a `decorative` container — Tab lands on something nothing announces | move it out of the illustration |
224
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 |
225
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 |
226
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 |
227
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) |
228
235
  | `embed-without-title` | an `embed` with no `title` — a frame a screen reader cannot describe | say what it shows in `title` |
229
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 |
@@ -110,7 +110,8 @@ is authorized: the dev tools' **Experiments** tab, or `?ab=heroTest:b` in the ad
110
110
 
111
111
  **By rules** — `chooseBy: 'rules'` — it shows the first variant whose `when` the visitor matches: a rule group over what a
112
112
  flag's rules see, `queryParams.utm_source` included, and the visitor: `visitor.returning`, `visitor.language` (`es`),
113
- `visitor.device` (`mobile`, `tablet`, `desktop`). End it with a variant with no `when`, for everybody else
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
114
115
  (`variants-no-fallback` warns otherwise):
115
116
 
116
117
  ```ts
@@ -137,3 +138,8 @@ between the two instants — ISO 8601 with the offset, never a local time (`time
137
138
  bound. An open page shows or hides it when the window opens or closes. In the builder it always shows while editing;
138
139
  the preview reads it at the date chosen in the Visitor tab.
139
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
 
@@ -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`, `experiments`, `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) — rendered on the server, then again
120
- in the browser, so it holds to the minute. A transformer of a binding does the same: `dateConverter` with
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).
@@ -1,5 +0,0 @@
1
- import { Schema } from '@plitzi/sdk-shared';
2
- type SpaceTrees = Pick<Schema, 'flat'> & Partial<Pick<Schema, 'components'>>;
3
- /** Whether a space shows things by the time — a page of it is drawn at an instant the browser hydrates at. */
4
- export declare const spaceTimeWindows: (schema: SpaceTrees) => boolean;
5
- export {};