@plitzi/sdk-server 0.39.2 → 0.39.4
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 +21 -0
- package/README.md +49 -7
- package/dist/auth.d.ts +3 -2
- package/dist/auth.js +26 -107
- package/dist/cache.js +1 -1
- package/dist/chunks/{buildBody-W9D8ySNY.js → buildBody-BSC0UbjP.js} +352 -110
- package/dist/chunks/{core-TlrWmT4B.js → core-w7FIMpgv.js} +86 -4
- package/dist/chunks/{createServer-Bd_b7T3k.js → createServer-BQ0KE0Qu.js} +157 -34
- package/dist/chunks/{platform-DhdFYWm5.js → platform-C0AVlwpB.js} +2 -2
- package/dist/chunks/throttle-CRiZB6_A.js +330 -0
- package/dist/chunks/{token-B2uY9JzU.js → token-CBUubxtm.js} +1 -1
- package/dist/chunks/views/template.ejs +7 -0
- package/dist/core/auth/api/context.d.ts +4 -4
- package/dist/core/auth/api/values.d.ts +6 -0
- package/dist/core/auth/createAuth.d.ts +1 -1
- package/dist/core/auth/throttle.d.ts +54 -4
- package/dist/core/createServer.d.ts +1 -1
- package/dist/core/platform.d.ts +1 -1
- package/dist/core/services/iconFaces.d.ts +3 -0
- package/dist/core/services/llmsTxt.d.ts +15 -0
- package/dist/core/services/robotsTxt.d.ts +2 -8
- package/dist/core/services/securityTxt.d.ts +10 -0
- package/dist/handlers.js +1 -1
- package/dist/helpers/documentParts.d.ts +10 -0
- package/dist/helpers/paintedCookie.d.ts +15 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/modules/icons/glyphs.d.ts +21 -0
- package/dist/modules/icons/handler.d.ts +11 -0
- package/dist/modules/icons/spaceIcons.d.ts +26 -0
- package/dist/modules/rsc/connectorRscData.d.ts +4 -2
- package/dist/modules/rsc/resolveRscData.d.ts +4 -1
- package/dist/modules/ssr/csrfHint.d.ts +12 -0
- package/dist/modules/ssr/defaultFavicon.d.ts +1 -1
- package/dist/modules/ssr/spaceDocument.d.ts +8 -1
- package/dist/oauth.js +1 -1
- package/dist/platform.d.ts +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/dist/types/config.d.ts +24 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +10 -8
- package/skills/plitzi-authoring/recipes/accordion.ts +3 -1
- package/skills/plitzi-authoring/recipes/carousel.ts +68 -63
- package/skills/plitzi-authoring/recipes/detail-page.ts +43 -33
- package/skills/plitzi-authoring/recipes/embed-and-svg.ts +16 -11
- package/skills/plitzi-authoring/recipes/every-few-seconds.ts +52 -42
- package/skills/plitzi-authoring/recipes/feature-flag.ts +7 -2
- package/skills/plitzi-authoring/recipes/filter-a-list.ts +39 -31
- package/skills/plitzi-authoring/recipes/forms-and-modals.ts +34 -28
- package/skills/plitzi-authoring/recipes/from-tailwind.ts +11 -6
- package/skills/plitzi-authoring/recipes/link-to-a-section.ts +11 -6
- package/skills/plitzi-authoring/recipes/link-with-data.ts +21 -16
- package/skills/plitzi-authoring/recipes/marquee.ts +17 -12
- package/skills/plitzi-authoring/recipes/plugin.ts +16 -10
- package/skills/plitzi-authoring/recipes/scroll-a-row.ts +30 -25
- package/skills/plitzi-authoring/recipes/server-data.ts +15 -10
- package/skills/plitzi-authoring/recipes/show-data.ts +32 -24
- package/skills/plitzi-authoring/recipes/style-a-page.ts +9 -4
- package/skills/plitzi-authoring/recipes/typed-data.ts +26 -21
- package/skills/plitzi-authoring/recipes/usable-without-sight.ts +16 -11
- package/skills/plitzi-authoring/reference/authoring-errors.md +3 -0
- package/skills/plitzi-authoring/reference/efficiency.md +2 -1
- package/dist/chunks/throttle-BH7JLIOF.js +0 -108
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { schemaFromWire } from "@plitzi/sdk-shared/schema";
|
|
1
|
+
import { schemaForPage, schemaFromWire, splitSchema } from "@plitzi/sdk-shared/schema";
|
|
2
2
|
import { compressBody, frameAncestorsOf, requestAuthority, requestOrigin } from "@plitzi/sdk-kernel/http";
|
|
3
3
|
import { serverLog } from "@plitzi/sdk-kernel/log";
|
|
4
4
|
import { flagsCookieName } from "@plitzi/sdk-shared/flags";
|
|
5
5
|
import { TRUSTED_TYPES_POLICIES, getKeyDecoded, isRecord } from "@plitzi/sdk-shared/helpers";
|
|
6
|
-
import { paintedKeys, paintedStateCookieName, paintedStateFor } from "@plitzi/sdk-shared/state";
|
|
6
|
+
import { paintedKeys, paintedStateCookieName, paintedStateFor, pickPainted } from "@plitzi/sdk-shared/state";
|
|
7
7
|
import { frameAncestors, sessionCookieParams, sessionHintCookieName } from "@plitzi/sdk-kernel/identity";
|
|
8
8
|
import { TtlCache } from "@plitzi/sdk-kernel/cache";
|
|
9
9
|
import { debugCookieName } from "@plitzi/sdk-shared/devTools";
|
|
@@ -38,6 +38,44 @@ var requestPaintedState = (req, settings, account) => {
|
|
|
38
38
|
state: paintedStateFor(req.headers.cookie, ssrPaintedCookieName(requestAuthority(req)), settings, account)
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
+
/** One answer a request: the render and its server providers read the same, and the deployment is asked once. */
|
|
42
|
+
var resolved = /* @__PURE__ */ new WeakMap();
|
|
43
|
+
/**
|
|
44
|
+
* `requestPaintedState` with the deployment's defaults (`paintedDefaults`) for the keys the cookie holds none of — for
|
|
45
|
+
* an account the request proved, never a guest: a guest's page is cached for every guest, and a default is an
|
|
46
|
+
* account's. Another account's entry holds nothing for this one (`paintedStateFor`), so after a change of account the
|
|
47
|
+
* defaults are this account's. A deployment that fails to answer is said in the log, and the page is drawn without.
|
|
48
|
+
*/
|
|
49
|
+
var requestPaintedStateWithDefaults = (req, settings, scope, defaults) => {
|
|
50
|
+
const known = resolved.get(req);
|
|
51
|
+
if (known) return known;
|
|
52
|
+
const { account } = scope;
|
|
53
|
+
const painted = requestPaintedState(req, settings, account);
|
|
54
|
+
const missing = [...painted.keys].filter((key) => painted.state?.[key] === void 0);
|
|
55
|
+
const answer = !defaults || account === void 0 || missing.length === 0 ? Promise.resolve(painted) : (async () => {
|
|
56
|
+
try {
|
|
57
|
+
const given = await defaults({
|
|
58
|
+
spaceId: scope.spaceId,
|
|
59
|
+
environment: scope.environment,
|
|
60
|
+
account,
|
|
61
|
+
keys: missing
|
|
62
|
+
});
|
|
63
|
+
const added = pickPainted(given, new Set(missing));
|
|
64
|
+
return Object.keys(added).length > 0 ? {
|
|
65
|
+
keys: painted.keys,
|
|
66
|
+
state: {
|
|
67
|
+
...painted.state,
|
|
68
|
+
...added
|
|
69
|
+
}
|
|
70
|
+
} : painted;
|
|
71
|
+
} catch (error) {
|
|
72
|
+
serverLog.error("SSR", `paintedDefaults did not answer for ${missing.join(", ")}: drawn without`, error);
|
|
73
|
+
return painted;
|
|
74
|
+
}
|
|
75
|
+
})();
|
|
76
|
+
resolved.set(req, answer);
|
|
77
|
+
return answer;
|
|
78
|
+
};
|
|
41
79
|
// src/helpers/cache/defaults.ts
|
|
42
80
|
var DEFAULT_TTL_MS = {
|
|
43
81
|
html: 3e5,
|
|
@@ -501,7 +539,7 @@ var styleSheetOf = (offlineData) => {
|
|
|
501
539
|
sheets.set(offlineData.style, null);
|
|
502
540
|
return;
|
|
503
541
|
}
|
|
504
|
-
const css = styleSheetCss(offlineData.style.cache);
|
|
542
|
+
const css = styleSheetCss(offlineData.style.cache, offlineData.schema.settings.customCss);
|
|
505
543
|
const hash = digest(css);
|
|
506
544
|
const sheet = {
|
|
507
545
|
css,
|
|
@@ -535,6 +573,13 @@ var spaceDocument = (offlineData, { linkStyle = true } = {}) => {
|
|
|
535
573
|
const sheet = linkStyle ? styleSheetOf(offlineData) : void 0;
|
|
536
574
|
const data = sheet ? {
|
|
537
575
|
...offlineData,
|
|
576
|
+
schema: {
|
|
577
|
+
...offlineData.schema,
|
|
578
|
+
settings: {
|
|
579
|
+
...offlineData.schema.settings,
|
|
580
|
+
customCss: ""
|
|
581
|
+
}
|
|
582
|
+
},
|
|
538
583
|
style: {
|
|
539
584
|
...offlineData.style,
|
|
540
585
|
cache: "",
|
|
@@ -761,6 +806,43 @@ var createOfflineDataLoader = (read) => {
|
|
|
761
806
|
let pending;
|
|
762
807
|
return () => pending ??= read();
|
|
763
808
|
};
|
|
809
|
+
// src/helpers/documentParts.ts
|
|
810
|
+
var served = /* @__PURE__ */ new WeakMap();
|
|
811
|
+
/** A part as it is fetched: its root and its elements, escaped as the document is. */
|
|
812
|
+
var textOf = (part) => escapeJson(JSON.stringify(part));
|
|
813
|
+
var servedOf = (schema, withheld) => {
|
|
814
|
+
const known = served.get(schema);
|
|
815
|
+
if (known) return known;
|
|
816
|
+
const texts = /* @__PURE__ */ new Map();
|
|
817
|
+
const parts = {
|
|
818
|
+
split: splitSchema(schema, (part) => {
|
|
819
|
+
const text = textOf(part);
|
|
820
|
+
const name = digest(text);
|
|
821
|
+
texts.set(name, text);
|
|
822
|
+
return name;
|
|
823
|
+
}, withheld),
|
|
824
|
+
texts,
|
|
825
|
+
pages: /* @__PURE__ */ new Map()
|
|
826
|
+
};
|
|
827
|
+
served.set(schema, parts);
|
|
828
|
+
return parts;
|
|
829
|
+
};
|
|
830
|
+
/**
|
|
831
|
+
* Whether this space is sent in parts: unless it asks for the whole (`settings.wholeDocument`), or has a single page —
|
|
832
|
+
* nothing to fetch later, so the shell would only be split for nothing.
|
|
833
|
+
*/
|
|
834
|
+
var sentInParts = (schema) => schema.settings.wholeDocument !== true && schema.pages.length > 1;
|
|
835
|
+
/** The schema a page is sent with: the shell, that page's part and its layouts' — the same object for every visit. */
|
|
836
|
+
var pageSchemaOf = (schema, withheld, pageId) => {
|
|
837
|
+
const parts = servedOf(schema, withheld);
|
|
838
|
+
const known = parts.pages.get(pageId);
|
|
839
|
+
if (known) return known;
|
|
840
|
+
const page = schemaForPage(parts.split, pageId);
|
|
841
|
+
parts.pages.set(pageId, page);
|
|
842
|
+
return page;
|
|
843
|
+
};
|
|
844
|
+
/** A part's text by its name, for this group of visitors; none for a name their shell does not give. */
|
|
845
|
+
var partTextOf = (schema, withheld, name) => servedOf(schema, withheld).texts.get(name);
|
|
764
846
|
// src/modules/ssr/scriptPolicy.ts
|
|
765
847
|
/** Where a browser reports what the page's script policy would have refused (`cspReportStage`). */
|
|
766
848
|
var CSP_REPORT_PATH = "/_plitzi/csp-report";
|
|
@@ -2115,4 +2197,4 @@ var createRedisPageStore = (client, { prefix = "plitzi:{pages}:", maxBytes = byt
|
|
|
2115
2197
|
return typeof count === "number" ? count : 0;
|
|
2116
2198
|
}
|
|
2117
2199
|
});
|
|
2118
|
-
export {
|
|
2200
|
+
export { ignoredQueryParamsOf as $, cacheLimitsOf as A, styleSheetOf as B, pageSchemaOf as C, reportReactBuild as D, createOfflineDataLoader as E, destroyServerCaches as F, keepPage as G, renderLimitFor as H, digest as I, buildCacheManager as J, pageHtml as K, hydrationPayload as L, createCacheInvalidator as M, shareCache as N, normalizePluginSource as O, createServerCaches as P, offlineDataCacheKeyOf as Q, offlineDataWith as R, sendScriptPolicy as S, sentInParts as T, renderLimitOf as U, DEFAULT_RENDER_WAIT_MS as V, fromSharedPage as W, buildRscCacheKey as X, buildHtmlCacheKey as Y, keepsVersion as Z, buildServerInfo as _, presentsCredential as a, DEFAULT_IGNORED_QUERY_PARAMS as at, CSP_REPORT_PATH as b, wildcardSubdomain as c, createAuthAdapters as d, renderedQuery as et, createJsonAdapters as f, resolveDebugMode as g, escapeHtml as h, fixedSpace as i, DEFAULT_CACHE_BYTES as it, cacheFilterOf as j, normalizePlugins as k, createMemoryCache as l, RequestMetrics as m, createSpaceAdapters as n, visitorScheme as nt, renderGrant as o, DEFAULT_TTL_MS as ot, createCloudAdapters as p, toSharedPage as q, authoringPreview as r, readCookie as rt, verifiedDomain as s, requestPaintedStateWithDefaults as st, createRedisPageStore as t, SCHEME_HINT_HEADER as tt, refuse as u, googleFontsStage as v, partTextOf as w, scriptTemplateParams as x, googleFontsUrlOf as y, spaceDocument as z };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { C as draftSessionCookie, E as
|
|
2
|
-
import {
|
|
1
|
+
import { A as matchRscPage, C as spaceIconsOf, D as draftSessionCookie, E as createMemoryDraftStore, O as takeDraftOverride, S as ICONS_PATH, T as DRAFT_STORE_METHODS, _ as resolveServices, a as applySSRResult, b as pageAssets, c as withNotFound, f as answerCurrentSpacePreflight, g as resolveRscEndpoint, h as meterPage, i as Component, k as invalidatePluginComponentCache, 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 iconGlyphsAt, x as resolveSdkAssetsDir } from "./buildBody-BSC0UbjP.js";
|
|
2
|
+
import { $ as ignoredQueryParamsOf, A as cacheLimitsOf, B as styleSheetOf, D as reportReactBuild, E as createOfflineDataLoader, F as destroyServerCaches, G as keepPage, H as renderLimitFor, J as buildCacheManager, K as pageHtml, N as shareCache, O as normalizePluginSource, P as createServerCaches, Q as offlineDataCacheKeyOf, S as sendScriptPolicy, U as renderLimitOf, W as fromSharedPage, X as buildRscCacheKey, Y as buildHtmlCacheKey, Z as keepsVersion, et as renderedQuery, h as escapeHtml, it as DEFAULT_CACHE_BYTES, j as cacheFilterOf, k as normalizePlugins, m as RequestMetrics, ot as DEFAULT_TTL_MS$1, q as toSharedPage, st as requestPaintedStateWithDefaults, tt as SCHEME_HINT_HEADER, v as googleFontsStage } from "./core-w7FIMpgv.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
|
-
import { n as
|
|
5
|
+
import { n as createRateLimit, t as RATE_LIMIT_METHODS } from "./throttle-CRiZB6_A.js";
|
|
6
6
|
import { dataDirLookup } from "@plitzi/sdk-kernel/data";
|
|
7
7
|
import { cappedResponse, fetchOutbound, privateOriginsOf } from "@plitzi/sdk-kernel/outbound";
|
|
8
|
-
import { DEFAULT_FAVICON, RSC_FAILURE, collectServerElements, inputProviders, inputReadings, pageAccessOf, pageAccessRefusal, serverInputOf, serverProviderSource, serverQueryOf, serverWhenValues, whenOf, whenProviders, whenUnknownToServer, withholdPages } from "@plitzi/sdk-shared/schema";
|
|
8
|
+
import { DEFAULT_FAVICON, PLITZI_MARK_SVG, RSC_FAILURE, blockedAiCrawlers, collectServerElements, inputProviders, inputReadings, pageAccessOf, pageAccessRefusal, serverInputOf, serverProviderSource, serverQueryOf, serverWhenValues, whenOf, whenProviders, whenUnknownToServer, withholdPages } from "@plitzi/sdk-shared/schema";
|
|
9
9
|
import http from "node:http";
|
|
10
10
|
import https from "node:https";
|
|
11
11
|
import fs, { readFile } from "node:fs/promises";
|
|
@@ -17,7 +17,7 @@ import { evaluateRuleGroup } from "@plitzi/sdk-shared/conditions";
|
|
|
17
17
|
import { getSourceName } from "@plitzi/sdk-shared/dataSource/helpers";
|
|
18
18
|
import { resolveVariables } from "@plitzi/sdk-shared/dataSource/variables";
|
|
19
19
|
import { flagUserFromSSR, flagValues, forcedFlagsFromCookies, requestFlagOverrides, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
20
|
-
import { sitemapPaths } from "@plitzi/sdk-shared/navigation";
|
|
20
|
+
import { sitemapPages, sitemapPaths } from "@plitzi/sdk-shared/navigation";
|
|
21
21
|
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
22
22
|
import { knowHostDeployment } from "@plitzi/sdk-kernel/deployment";
|
|
23
23
|
import { PREVIEW_TOKEN_PARAM, appendCookies, clearSessionCookies, readCookies, readDraftToken, readRenewalGuard, readSessionHint, readSessionToken, resolveDebugAuthorization, writeRenewalGuard, writeSessionCookies } from "@plitzi/sdk-kernel/identity";
|
|
@@ -328,7 +328,7 @@ var withBudget = async (run, timeoutMs, label, asked) => {
|
|
|
328
328
|
* and the route params are what the browser will see. Each `runtime: 'server'` element resolves independently:
|
|
329
329
|
* a provider that fails or hangs costs its own slice and nothing else.
|
|
330
330
|
*/
|
|
331
|
-
var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, resolveElement, flagOverrides, timeoutMs = DEFAULT_ELEMENT_TIMEOUT_MS, signal, sayFailures = false }) => {
|
|
331
|
+
var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, resolveElement, flagOverrides, timeoutMs = DEFAULT_ELEMENT_TIMEOUT_MS, signal, sayFailures = false, paintedDefaults }) => {
|
|
332
332
|
if (schema.rsc?.enabled === false) return {};
|
|
333
333
|
const match = matchRscPage(schema, req.path, user);
|
|
334
334
|
if (!match) return { serverData: {} };
|
|
@@ -345,7 +345,11 @@ var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, reso
|
|
|
345
345
|
const asked = ids ? new Set(ids) : void 0;
|
|
346
346
|
const targets = asked ? all.filter((element) => asked.has(element.id)) : all;
|
|
347
347
|
if (targets.length === 0) return { serverData: {} };
|
|
348
|
-
const painted =
|
|
348
|
+
const painted = await requestPaintedStateWithDefaults(req, schema.settings, {
|
|
349
|
+
spaceId,
|
|
350
|
+
environment,
|
|
351
|
+
account: user?.id
|
|
352
|
+
}, paintedDefaults);
|
|
349
353
|
const templateData = {
|
|
350
354
|
variables: resolveVariables(schema.variables, {
|
|
351
355
|
routeParams,
|
|
@@ -450,7 +454,7 @@ var resolveRscData = async ({ schema, req, spaceId, environment, user, ids, reso
|
|
|
450
454
|
*
|
|
451
455
|
* A deployment that resolves server elements some other way still supplies its own `getRscData`, and that one wins.
|
|
452
456
|
*/
|
|
453
|
-
var connectorRscData = ({ engine, publicDir, data, elementTimeoutMs, sayFailures = false, outbound, visitorCredentials }) => {
|
|
457
|
+
var connectorRscData = ({ engine, publicDir, data, elementTimeoutMs, sayFailures = false, outbound, visitorCredentials, paintedDefaults }) => {
|
|
454
458
|
const resolvePublicFile = publicDir ? publicFileResolver(publicDir) : void 0;
|
|
455
459
|
const resolveDataFile = data ? dataLookupResolver(data) : void 0;
|
|
456
460
|
const readExternal = externalQueryReader({
|
|
@@ -501,6 +505,7 @@ var connectorRscData = ({ engine, publicDir, data, elementTimeoutMs, sayFailures
|
|
|
501
505
|
...flagOverrides ? { flagOverrides } : {},
|
|
502
506
|
...signal ? { signal } : {},
|
|
503
507
|
...elementTimeoutMs === void 0 ? {} : { timeoutMs: elementTimeoutMs },
|
|
508
|
+
...paintedDefaults ? { paintedDefaults } : {},
|
|
504
509
|
sayFailures
|
|
505
510
|
});
|
|
506
511
|
};
|
|
@@ -1501,6 +1506,68 @@ var createLivePages = () => {
|
|
|
1501
1506
|
}
|
|
1502
1507
|
};
|
|
1503
1508
|
};
|
|
1509
|
+
// src/modules/icons/handler.ts
|
|
1510
|
+
var FACE_PATH = new RegExp(`^${ICONS_PATH.replace(/\//g, "\\/")}([\\w-]{16})-(solid|regular|brands)\\.woff2$`);
|
|
1511
|
+
/** The faces cut, by hash and face: a few kilobytes each, the same for every replica that cuts them. */
|
|
1512
|
+
var CUT_KEEP = 128;
|
|
1513
|
+
var cut = /* @__PURE__ */ new Map();
|
|
1514
|
+
var cutFace = (sdkDir, face, key) => {
|
|
1515
|
+
const known = cut.get(key);
|
|
1516
|
+
if (known) return known;
|
|
1517
|
+
const made = (async () => {
|
|
1518
|
+
const { default: subsetFont } = await import("subset-font");
|
|
1519
|
+
return subsetFont(await readFile(path.join(sdkDir, "webfonts", face.file)), String.fromCodePoint(...face.codepoints), { targetFormat: "woff2" });
|
|
1520
|
+
})();
|
|
1521
|
+
cut.set(key, made);
|
|
1522
|
+
made.catch(() => cut.delete(key));
|
|
1523
|
+
if (cut.size > CUT_KEEP) {
|
|
1524
|
+
const oldest = cut.keys().next().value;
|
|
1525
|
+
if (oldest !== void 0) cut.delete(oldest);
|
|
1526
|
+
}
|
|
1527
|
+
return made;
|
|
1528
|
+
};
|
|
1529
|
+
var notFound = (res, message) => {
|
|
1530
|
+
res.setStatus(404);
|
|
1531
|
+
res.setHeader("Cache-Control", "no-store");
|
|
1532
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
1533
|
+
res.send(message);
|
|
1534
|
+
};
|
|
1535
|
+
/**
|
|
1536
|
+
* A face of the icon font cut to the glyphs the space names (`spaceIconsOf`), linked by its pages' heads — answered by
|
|
1537
|
+
* whichever replica the request reaches, from the space as the request resolves it, as the stylesheet is. The name is
|
|
1538
|
+
* the glyphs': asked for by the name it has now, it is kept for good; by an older one, it answers the space's glyphs as
|
|
1539
|
+
* they are, kept by nobody — a glyph either lacks is drawn from the whole font all the same.
|
|
1540
|
+
*/
|
|
1541
|
+
var handleIconFace = async (req, res, config, sdkDir, offlineDataCache) => {
|
|
1542
|
+
const asked = FACE_PATH.exec(req.path);
|
|
1543
|
+
if (!asked || !sdkDir) {
|
|
1544
|
+
notFound(res, sdkDir ? "No such icon face" : "This server has no SDK installed to cut icon faces from");
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
const [, hash, key] = asked;
|
|
1548
|
+
const { environment = "main", revision = 0 } = req.ctx.spaceDeployment ?? {};
|
|
1549
|
+
const spaceId = req.ctx.spaceDeployment?.spaceId ?? 1;
|
|
1550
|
+
const cacheKey = offlineDataCacheKeyOf(req.ctx.spaceDeployment);
|
|
1551
|
+
const offlineData = (cacheKey ? offlineDataCache?.get(cacheKey) : void 0) ?? await config.adapters.getOfflineData(spaceId, environment, revision);
|
|
1552
|
+
const icons = offlineData ? spaceIconsOf(offlineData, iconGlyphsAt(sdkDir)) : void 0;
|
|
1553
|
+
const face = icons?.faces.find((candidate) => candidate.key === key);
|
|
1554
|
+
if (!icons || !face) {
|
|
1555
|
+
notFound(res, `Space ${String(spaceId)} (${environment}) names no ${key} icon`);
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
const font = await cutFace(sdkDir, face, `${icons.hash}-${key}`);
|
|
1559
|
+
res.setHeader("Content-Type", "font/woff2");
|
|
1560
|
+
res.setHeader("Cache-Control", icons.hash === hash ? "public, max-age=31536000, immutable" : "no-store");
|
|
1561
|
+
res.send(font);
|
|
1562
|
+
};
|
|
1563
|
+
// src/core/services/iconFaces.ts
|
|
1564
|
+
var iconFacesStage = async (ctx) => {
|
|
1565
|
+
const { config, req } = ctx;
|
|
1566
|
+
if (req.method !== "GET" || !req.path.startsWith("/_plitzi/icons/")) return false;
|
|
1567
|
+
ctx.operation = "icons";
|
|
1568
|
+
await handleIconFace(req, ctx.res, config, resolveSdkAssetsDir(), ctx.caches.offlineData);
|
|
1569
|
+
return true;
|
|
1570
|
+
};
|
|
1504
1571
|
// src/core/services/servedSpace.ts
|
|
1505
1572
|
/**
|
|
1506
1573
|
* The space a page at this address renders (no deployment: the server's one space), for a file the server answers from
|
|
@@ -1514,32 +1581,61 @@ var servedSpace = async (ctx, file) => {
|
|
|
1514
1581
|
serverLog.warn("SSR", `${file} answered without the space: space ${String(spaceId)} could not be read`, error);
|
|
1515
1582
|
});
|
|
1516
1583
|
};
|
|
1584
|
+
// src/core/services/llmsTxt.ts
|
|
1585
|
+
var LLMS_TXT_PATH = "/llms.txt";
|
|
1586
|
+
/** A line of Markdown that cannot break the list it is in: no line break, no bracket that closes a link early. */
|
|
1587
|
+
var inline = (value) => value.replace(/\s+/g, " ").replace(/[[\]]/g, "").trim();
|
|
1588
|
+
/**
|
|
1589
|
+
* The index an assistant reads (llmstxt.org): the site's name, the home page's description as its summary, and a link
|
|
1590
|
+
* to each page the sitemap lists with its SEO title and description — the same words a search result shows.
|
|
1591
|
+
*/
|
|
1592
|
+
var llmsTxtOf = (schema, origin) => {
|
|
1593
|
+
const pages = sitemapPages(schema).map((page) => ({
|
|
1594
|
+
...page,
|
|
1595
|
+
seo: resolvePageSeo(schema, page.pageId)
|
|
1596
|
+
}));
|
|
1597
|
+
const home = pages.find((page) => page.path === "/");
|
|
1598
|
+
const name = inline(schema.settings.siteName ?? home?.seo.title ?? new URL(origin).hostname);
|
|
1599
|
+
const summary = home?.seo.description ? inline(home.seo.description) : "";
|
|
1600
|
+
const links = pages.map(({ path, seo }) => {
|
|
1601
|
+
return `- [${inline(seo.title ?? path)}](${origin}${path})${seo.description ? `: ${inline(seo.description)}` : ""}`;
|
|
1602
|
+
});
|
|
1603
|
+
return [
|
|
1604
|
+
`# ${name}`,
|
|
1605
|
+
...summary ? [`> ${summary}`] : [],
|
|
1606
|
+
"## Pages",
|
|
1607
|
+
links.join("\n")
|
|
1608
|
+
].join("\n\n");
|
|
1609
|
+
};
|
|
1610
|
+
/**
|
|
1611
|
+
* `/llms.txt`: the space's own (`settings.llmsTxt`), or the one its pages make (`llmsTxtOf`). A space that keeps
|
|
1612
|
+
* assistants out (`blockAiCrawlers: ['assistants']`) answers 404 — an index for them invites what it refuses. Never the
|
|
1613
|
+
* space's page for that address, which an assistant would read as the index.
|
|
1614
|
+
*/
|
|
1615
|
+
var llmsTxtStage = async (ctx) => {
|
|
1616
|
+
const { req } = ctx;
|
|
1617
|
+
if (req.method !== "GET" || req.path !== "/llms.txt") return false;
|
|
1618
|
+
ctx.operation = "llms";
|
|
1619
|
+
const schema = (await servedSpace(ctx, LLMS_TXT_PATH))?.schema;
|
|
1620
|
+
const origin = requestOrigin(req);
|
|
1621
|
+
ctx.res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
1622
|
+
if (!schema || !origin || schema.settings.blockAiCrawlers?.includes("assistants")) {
|
|
1623
|
+
ctx.res.setStatus(404);
|
|
1624
|
+
ctx.res.send("This site publishes no llms.txt.\n");
|
|
1625
|
+
return true;
|
|
1626
|
+
}
|
|
1627
|
+
const own = schema.settings.llmsTxt?.trim();
|
|
1628
|
+
ctx.res.setStatus(200);
|
|
1629
|
+
ctx.res.send(`${own || llmsTxtOf(schema, origin)}\n`);
|
|
1630
|
+
return true;
|
|
1631
|
+
};
|
|
1517
1632
|
// src/core/services/robotsTxt.ts
|
|
1518
1633
|
/** What a space that says nothing answers: everything may be crawled. */
|
|
1519
1634
|
var DEFAULT_ROBOTS_TXT = "User-agent: *\nAllow: /\n";
|
|
1520
|
-
/**
|
|
1521
|
-
* The crawlers that gather pages to train AI models, by the user agent each reads `/robots.txt` as — what a space that
|
|
1522
|
-
* says `blockAiCrawlers` keeps out. A search engine's own crawler is none of them: Googlebot reads on, Google-Extended
|
|
1523
|
-
* (the one that trains) does not.
|
|
1524
|
-
*/
|
|
1525
|
-
var AI_CRAWLERS = [
|
|
1526
|
-
"GPTBot",
|
|
1527
|
-
"ChatGPT-User",
|
|
1528
|
-
"OAI-SearchBot",
|
|
1529
|
-
"ClaudeBot",
|
|
1530
|
-
"anthropic-ai",
|
|
1531
|
-
"Google-Extended",
|
|
1532
|
-
"Applebot-Extended",
|
|
1533
|
-
"CCBot",
|
|
1534
|
-
"PerplexityBot",
|
|
1535
|
-
"Bytespider",
|
|
1536
|
-
"Amazonbot",
|
|
1537
|
-
"meta-externalagent"
|
|
1538
|
-
];
|
|
1539
1635
|
var SITEMAP_LINE = /^\s*sitemap\s*:/im;
|
|
1540
1636
|
/**
|
|
1541
|
-
* `/robots.txt`: the space's own (`settings.robotsTxt`) or one that lets crawlers read everything, then
|
|
1542
|
-
* keeps
|
|
1637
|
+
* `/robots.txt`: the space's own (`settings.robotsTxt`) or one that lets crawlers read everything, then a `Disallow: /`
|
|
1638
|
+
* for each AI crawler of the kinds the space keeps out (`settings.blockAiCrawlers`), and the address of its sitemap
|
|
1543
1639
|
* unless its own text names one. Never the space's page for an address it has none for: a crawler reads a 404 page as
|
|
1544
1640
|
* "no rules", and an HTML page as rules it cannot parse.
|
|
1545
1641
|
*/
|
|
@@ -1552,7 +1648,7 @@ var robotsTxtStage = async (ctx) => {
|
|
|
1552
1648
|
const origin = requestOrigin(req);
|
|
1553
1649
|
const sections = [
|
|
1554
1650
|
own,
|
|
1555
|
-
...settings?.blockAiCrawlers
|
|
1651
|
+
...blockedAiCrawlers(settings?.blockAiCrawlers).map((agent) => `User-agent: ${agent}\nDisallow: /`),
|
|
1556
1652
|
...origin && !SITEMAP_LINE.test(own) ? [`Sitemap: ${origin}/sitemap.xml`] : []
|
|
1557
1653
|
];
|
|
1558
1654
|
ctx.res.setStatus(200);
|
|
@@ -1739,6 +1835,29 @@ var rscStage = async (ctx) => {
|
|
|
1739
1835
|
await handleRsc(req, ctx.res, config, ctx.pluginManager, ctx.caches.rsc, ctx.signal);
|
|
1740
1836
|
return true;
|
|
1741
1837
|
};
|
|
1838
|
+
// src/core/services/securityTxt.ts
|
|
1839
|
+
var SECURITY_TXT_PATH = "/.well-known/security.txt";
|
|
1840
|
+
/**
|
|
1841
|
+
* `/.well-known/security.txt` (RFC 9116): the space's own words (`settings.securityTxt`), as plain text — where somebody
|
|
1842
|
+
* who found a flaw writes, and until when that holds. A space that says nothing answers 404: a contact the site never
|
|
1843
|
+
* gave would send a researcher's report nowhere. Never the space's page for that address, which a reader takes for the
|
|
1844
|
+
* file.
|
|
1845
|
+
*/
|
|
1846
|
+
var securityTxtStage = async (ctx) => {
|
|
1847
|
+
const { req } = ctx;
|
|
1848
|
+
if (req.method !== "GET" || req.path !== "/.well-known/security.txt") return false;
|
|
1849
|
+
ctx.operation = "security";
|
|
1850
|
+
const own = (await servedSpace(ctx, SECURITY_TXT_PATH))?.schema.settings.securityTxt?.trim();
|
|
1851
|
+
ctx.res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
1852
|
+
if (!own) {
|
|
1853
|
+
ctx.res.setStatus(404);
|
|
1854
|
+
ctx.res.send("This site publishes no security.txt.\n");
|
|
1855
|
+
return true;
|
|
1856
|
+
}
|
|
1857
|
+
ctx.res.setStatus(200);
|
|
1858
|
+
ctx.res.send(`${own}\n`);
|
|
1859
|
+
return true;
|
|
1860
|
+
};
|
|
1742
1861
|
// src/core/services/sitemapXml.ts
|
|
1743
1862
|
var XML_ESCAPES = {
|
|
1744
1863
|
"&": "&",
|
|
@@ -2616,7 +2735,7 @@ var cspReportStage = async (ctx) => {
|
|
|
2616
2735
|
* Kept as text rather than a file beside the module: the server's build moves its modules into chunks, and a deployment
|
|
2617
2736
|
* bundles them again (a project's server, `bundleProject`) — a string goes wherever its module goes.
|
|
2618
2737
|
*/
|
|
2619
|
-
var DEFAULT_FAVICON_SVG =
|
|
2738
|
+
var DEFAULT_FAVICON_SVG = PLITZI_MARK_SVG;
|
|
2620
2739
|
// src/core/http/stages/defaultFavicon.ts
|
|
2621
2740
|
/** Plitzi's icon, at the address a page that names none points its tab at — see `DEFAULT_FAVICON_SVG`. */
|
|
2622
2741
|
var defaultFaviconStage = (ctx) => {
|
|
@@ -2702,6 +2821,7 @@ var buildPagePipeline = (services, extensions = {}, engine) => {
|
|
|
2702
2821
|
publicDirStage,
|
|
2703
2822
|
defaultFaviconStage,
|
|
2704
2823
|
cspReportStage,
|
|
2824
|
+
...services.ssr ? [securityTxtStage] : [],
|
|
2705
2825
|
wellKnownStage,
|
|
2706
2826
|
pluginAssetsStage,
|
|
2707
2827
|
fontAssetsStage,
|
|
@@ -2721,8 +2841,10 @@ var buildPagePipeline = (services, extensions = {}, engine) => {
|
|
|
2721
2841
|
if (services.ssr) {
|
|
2722
2842
|
stages.push(spaceDocumentStage);
|
|
2723
2843
|
stages.push(styleSheetStage);
|
|
2844
|
+
stages.push(iconFacesStage);
|
|
2724
2845
|
stages.push(robotsTxtStage);
|
|
2725
2846
|
stages.push(sitemapXmlStage);
|
|
2847
|
+
stages.push(llmsTxtStage);
|
|
2726
2848
|
}
|
|
2727
2849
|
stages.push(services.ssr ? ssrStage : notFoundStage);
|
|
2728
2850
|
return stages;
|
|
@@ -2825,7 +2947,7 @@ var createPageServer = (config, services, extensions, engine) => {
|
|
|
2825
2947
|
fleetStores: {
|
|
2826
2948
|
...engine?.fleetStores,
|
|
2827
2949
|
"ssr.drafts": hostable(createMemoryDraftStore, DRAFT_STORE_METHODS),
|
|
2828
|
-
"auth.rateLimit": hostable(() => ({ check:
|
|
2950
|
+
"auth.rateLimit": hostable(() => ({ check: createRateLimit() }), RATE_LIMIT_METHODS)
|
|
2829
2951
|
},
|
|
2830
2952
|
onStopping: () => {
|
|
2831
2953
|
engine?.stopping?.();
|
|
@@ -2862,7 +2984,7 @@ var createPageServer = (config, services, extensions, engine) => {
|
|
|
2862
2984
|
// src/core/createServer.ts
|
|
2863
2985
|
/**
|
|
2864
2986
|
* What a page server is not configured with: the actions engine's own configuration, which `createPlatform` builds the
|
|
2865
|
-
* engine from and hands the server (`engine`), or a worker runs elsewhere (
|
|
2987
|
+
* engine from and hands the server (`engine`), or a worker runs elsewhere (docs/en/server-packages.md, D12).
|
|
2866
2988
|
*/
|
|
2867
2989
|
var ENGINE_KEYS = [
|
|
2868
2990
|
"action",
|
|
@@ -2903,7 +3025,8 @@ var withRsc = (config, engine) => {
|
|
|
2903
3025
|
elementTimeoutMs: config.rsc?.elementTimeoutMs,
|
|
2904
3026
|
sayFailures: config.devMode === true,
|
|
2905
3027
|
outbound: { privateOrigins: privateOriginsOf(config.outbound?.privateOrigins) },
|
|
2906
|
-
visitorCredentials: config.rsc?.visitorCredentials
|
|
3028
|
+
visitorCredentials: config.rsc?.visitorCredentials,
|
|
3029
|
+
...config.paintedDefaults ? { paintedDefaults: config.paintedDefaults } : {}
|
|
2907
3030
|
})
|
|
2908
3031
|
}
|
|
2909
3032
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createServer } from "./createServer-
|
|
1
|
+
import { t as createServer } from "./createServer-BQ0KE0Qu.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
|
|
@@ -13,7 +13,7 @@ var engineLookups = (lookups, dataDir, auth) => ({
|
|
|
13
13
|
...!lookups.getVisitor && auth ? { getVisitor: (_space, _environment, who) => auth.publicAccount(who) } : {}
|
|
14
14
|
});
|
|
15
15
|
/**
|
|
16
|
-
* Pages and actions in one process (
|
|
16
|
+
* Pages and actions in one process (docs/en/server-packages.md, D11): the actions engine built from `action`, `functions`, `connectors`
|
|
17
17
|
* and `realtime`, and handed to the page server `createServer` makes of the rest. What `yarn start`, a project's own
|
|
18
18
|
* server and most self-hosted deployments run; a deployment whose actions run on a worker of their own uses
|
|
19
19
|
* `createServer` for its pages.
|