@plitzi/sdk-server 0.35.7 → 0.35.8

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,26 @@
1
1
  # @plitzi/sdk-server
2
2
 
3
+ ## 0.35.8
4
+
5
+ ### Patch Changes
6
+
7
+ - A space can switch the dev tools on for its own published site.
8
+
9
+ - **`settings.devTools`** in the space schema, set from the builder's Settings panel ("Dev tools on the published SSR
10
+ site (*.plitzi.app)"). It applies to sites served with SSR — usually a space's `*.plitzi.app` address, or a custom
11
+ domain pointed at it. A page server that left `debugMode` unset now authorizes debugging for a space that asked for it, as it
12
+ already did in `devMode`. A server that sets `debugMode` still decides for every space, and `false` cannot be
13
+ turned around by a space. Preview renders stay undebuggable either way.
14
+ - The space is read from the schema the server loaded, never from the request, and the visitor's cookie can still
15
+ only hide the panel.
16
+ - **The HTML cache keys whether a visitor hid the dev tools.** A cached page on a published environment used to be
17
+ keyed on the theme alone, so on a page authorizing dev tools the first visitor's choice — panel or no panel — was
18
+ served to everybody after them.
19
+
20
+ - Updated dependencies
21
+ - @plitzi/plitzi-sdk@0.35.8
22
+ - @plitzi/sdk-shared@0.35.8
23
+
3
24
  ## 0.35.7
4
25
 
5
26
  ### Patch Changes
@@ -5,8 +5,13 @@
5
5
  * writes it onto `<html>` and into the props the SDK hydrates with. Keyed without it, the first visitor's choice was
6
6
  * served to everybody behind them — a dark page for a visitor who chose light, then corrected on hydration.
7
7
  *
8
- * Read from the request here rather than handed in, so a call site cannot key the page without it. Only the theme
9
- * cookie is read: keying the whole header would split the cache on every analytics cookie a visitor carries.
8
+ * So is whether the visitor hid the dev tools, on a page that authorizes them: the render leaves the panel out for
9
+ * them and in for everybody else. It is the only value of that cookie that changes what is drawn, so it is the only
10
+ * one keyed — a space that switched dev tools on for its published site would otherwise hand the first visitor's
11
+ * choice to the rest.
12
+ *
13
+ * Read from the request here rather than handed in, so a call site cannot key the page without it. Only those two
14
+ * cookies are read: keying the whole header would split the cache on every analytics cookie a visitor carries.
10
15
  */
11
16
  export declare const buildHtmlCacheKey: (accessToken: string | undefined, spaceId: number | string | null, environment: string, revision: number, req: {
12
17
  hostname: string;
@@ -14,6 +19,7 @@ export declare const buildHtmlCacheKey: (accessToken: string | undefined, spaceI
14
19
  search: string;
15
20
  headers: {
16
21
  cookie?: string;
22
+ host?: string;
17
23
  };
18
24
  }) => string;
19
25
  export declare const buildOfflineDataCacheKey: (spaceId: number, environment: string, revision: number) => string;
@@ -1,3 +1,5 @@
1
+ import { readCookie } from "../readCookie.js";
2
+ import { debugCookieName } from "@plitzi/sdk-shared/devTools";
1
3
  import { themeFromCookies } from "@plitzi/sdk-shared/theme";
2
4
  //#region src/helpers/cache/keys.ts
3
5
  /**
@@ -7,10 +9,19 @@ import { themeFromCookies } from "@plitzi/sdk-shared/theme";
7
9
  * writes it onto `<html>` and into the props the SDK hydrates with. Keyed without it, the first visitor's choice was
8
10
  * served to everybody behind them — a dark page for a visitor who chose light, then corrected on hydration.
9
11
  *
10
- * Read from the request here rather than handed in, so a call site cannot key the page without it. Only the theme
11
- * cookie is read: keying the whole header would split the cache on every analytics cookie a visitor carries.
12
+ * So is whether the visitor hid the dev tools, on a page that authorizes them: the render leaves the panel out for
13
+ * them and in for everybody else. It is the only value of that cookie that changes what is drawn, so it is the only
14
+ * one keyed — a space that switched dev tools on for its published site would otherwise hand the first visitor's
15
+ * choice to the rest.
16
+ *
17
+ * Read from the request here rather than handed in, so a call site cannot key the page without it. Only those two
18
+ * cookies are read: keying the whole header would split the cache on every analytics cookie a visitor carries.
12
19
  */
13
- var buildHtmlCacheKey = (accessToken = "anonymous", spaceId, environment, revision, req) => `${accessToken}\0${spaceId ?? 1}\0${environment}\0${revision}\0${themeFromCookies(req.headers.cookie) ?? ""}\0${req.hostname}\0${req.path}\0${req.search}`;
20
+ var buildHtmlCacheKey = (accessToken = "anonymous", spaceId, environment, revision, req) => {
21
+ const theme = themeFromCookies(req.headers.cookie) ?? "";
22
+ const debugHidden = readCookie(req.headers.cookie, debugCookieName(req.headers.host)) === "false" ? "debug-off" : "";
23
+ return `${accessToken}\0${spaceId ?? 1}\0${environment}\0${revision}\0${theme}\0${debugHidden}\0${req.hostname}\0${req.path}\0${req.search}`;
24
+ };
14
25
  var buildOfflineDataCacheKey = (spaceId, environment, revision) => `${spaceId}|${environment}|${revision}`;
15
26
  var buildRscCacheKey = (spaceId, environment, revision, userId, idsParam, req) => `${spaceId}\0${environment}\0${revision}\0${userId ?? "anon"}\0${idsParam ?? ""}\0${req.hostname}\0${req.path}\0${req.search}`;
16
27
  //#endregion
@@ -1,4 +1,5 @@
1
1
  import { matchRscPage } from "../rsc/matchRscPage.js";
2
+ import { readCookie } from "../../helpers/readCookie.js";
2
3
  import { buildOfflineDataCacheKey } from "../../helpers/cache/keys.js";
3
4
  import { loadPluginComponents } from "./loadPluginComponents.js";
4
5
  import "../../core/previewToken.js";
@@ -9,11 +10,10 @@ import { resolvePageSeo } from "./resolvePageSeo.js";
9
10
  import { sdkAssetVersion } from "../../core/sdkAssets.js";
10
11
  import { buildServerInfo } from "../../helpers/buildServerInfo.js";
11
12
  import { escapeJson } from "../../helpers/escapeJson.js";
12
- import { readCookie } from "../../helpers/readCookie.js";
13
13
  import { resolveDebugMode } from "../../helpers/resolveDebugMode.js";
14
14
  import { hasServerElements } from "@plitzi/sdk-shared/schema/serverElements";
15
- import { themeFromCookies } from "@plitzi/sdk-shared/theme";
16
15
  import { debugCookieName } from "@plitzi/sdk-shared/devTools";
16
+ import { themeFromCookies } from "@plitzi/sdk-shared/theme";
17
17
  import { fontUrlResolver, fontsToHead } from "@plitzi/sdk-shared/style";
18
18
  //#region src/modules/ssr/prepareRender.tsx
19
19
  /** Last resort only: used for a page that declares no SEO title and a deployment that supplies none either. */
@@ -59,8 +59,12 @@ var prepareRender = async (req, config, spaceId, environment, revision, pluginMa
59
59
  *
60
60
  * `debugRendered` is what this particular render draws, preference included. The client derives the same
61
61
  * product from the same cookie on its first pass, so the markup it hydrates matches.
62
+ *
63
+ * Who may authorize it: the server first, through `debugMode`. When it said nothing, a development server does, and
64
+ * so does the space itself (`settings.devTools`) — an owner inspecting their own published site. The space is read
65
+ * from what this server loaded, never from the request, so a visitor has no say in it.
62
66
  */
63
- const debugAuthorized = !Boolean(req.query["__pt"]) && Boolean(config.debugMode ?? config.devMode);
67
+ const debugAuthorized = !Boolean(req.query["__pt"]) && (config.debugMode ?? (config.devMode === true || schema?.settings.devTools === true));
64
68
  const debugRendered = resolveDebugMode(debugAuthorized, readCookie(req.headers.cookie, debugCookieName(req.headers.host)));
65
69
  const { degrade, analytics } = req.ctx.meter ?? {};
66
70
  const clientAnalytics = analytics ? {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-server",
3
- "version": "0.35.7",
3
+ "version": "0.35.8",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -58,8 +58,8 @@
58
58
  "type": "module",
59
59
  "sideEffects": false,
60
60
  "dependencies": {
61
- "@plitzi/plitzi-sdk": "0.35.7",
62
- "@plitzi/sdk-shared": "0.35.7",
61
+ "@plitzi/plitzi-sdk": "0.35.8",
62
+ "@plitzi/sdk-shared": "0.35.8",
63
63
  "ejs": "^6.0.1",
64
64
  "esbuild": "^0.28.2",
65
65
  "jsonwebtoken": "^9.0.3",