@the-portland-company/shell 0.28.2 → 0.29.0

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,3 +1,16 @@
1
+ ## 0.29.0 — 2026-07-23
2
+
3
+ ### Added — `./runtime-tokens` (`ensureRuntimeBrandTokens`)
4
+
5
+ A static `<link>` to `/api/tokens?format=css` in `<head>` is not sufficient on
6
+ its own: an app's own bundled `chrome.css` can be injected AFTER it and win the
7
+ cascade. VRM linked the runtime sheet and still resolved `--color-accent` from
8
+ the build-time snapshot, so a Brand edit reached four apps and not the fifth.
9
+
10
+ `ensureRuntimeBrandTokens()` appends (or moves) the tokens link to the END of
11
+ `<head>` at startup, making the live Brand values last in the cascade for every
12
+ app. Idempotent, and the response's ETag + `max-age=60` means no extra fetch.
13
+
1
14
  ## 0.28.2 — 2026-07-23
2
15
 
3
16
  ### Fixed — the Chakra theme hardcoded the body font
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ // src/runtime-tokens.ts
4
+ var SPECS_TOKENS_HREF = "https://specs.politogyvrm.com/api/tokens?format=css";
5
+ function ensureRuntimeBrandTokens(href = SPECS_TOKENS_HREF) {
6
+ if (typeof document === "undefined") return;
7
+ const existing = document.querySelector(
8
+ `link[rel="stylesheet"][href*="api/tokens"]`
9
+ );
10
+ const link = existing ?? document.createElement("link");
11
+ link.rel = "stylesheet";
12
+ if (!existing) link.href = href;
13
+ document.head.appendChild(link);
14
+ }
15
+
16
+ exports.SPECS_TOKENS_HREF = SPECS_TOKENS_HREF;
17
+ exports.ensureRuntimeBrandTokens = ensureRuntimeBrandTokens;
18
+ //# sourceMappingURL=runtime-tokens.cjs.map
19
+ //# sourceMappingURL=runtime-tokens.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime-tokens.ts"],"names":[],"mappings":";;;AAaO,IAAM,iBAAA,GACX;AAEK,SAAS,wBAAA,CAAyB,OAAe,iBAAA,EAAyB;AAC/E,EAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,EAAA,MAAM,WAAW,QAAA,CAAS,aAAA;AAAA,IACxB,CAAA,0CAAA;AAAA,GACF;AACA,EAAA,MAAM,IAAA,GAAO,QAAA,IAAY,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA;AACtD,EAAA,IAAA,CAAK,GAAA,GAAM,YAAA;AACX,EAAA,IAAI,CAAC,QAAA,EAAU,IAAA,CAAK,IAAA,GAAO,IAAA;AAG3B,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,IAAI,CAAA;AAChC","file":"runtime-tokens.cjs","sourcesContent":["// Runtime Brand tokens — the loader every app shares.\n//\n// Global-Rules (\"Consume Brand tokens at RUNTIME, never baked in at build time\")\n// requires each app to load specs.politogyvrm.com/api/tokens?format=css so a\n// Brand edit goes live without a redeploy. A static <link> in <head> is not\n// enough on its own: the app's own bundled chrome.css can be injected AFTER it\n// and win the cascade, which is exactly what happened on VRM — it linked the\n// runtime sheet yet still resolved --color-accent from the build-time snapshot.\n//\n// Appending the link to the END of <head> at startup makes the runtime sheet the\n// last stylesheet, so the live Brand values win every time. Idempotent: an\n// existing runtime link is MOVED to the end rather than duplicated.\n\nexport const SPECS_TOKENS_HREF =\n 'https://specs.politogyvrm.com/api/tokens?format=css'\n\nexport function ensureRuntimeBrandTokens(href: string = SPECS_TOKENS_HREF): void {\n if (typeof document === 'undefined') return\n const existing = document.querySelector<HTMLLinkElement>(\n `link[rel=\"stylesheet\"][href*=\"api/tokens\"]`,\n )\n const link = existing ?? document.createElement('link')\n link.rel = 'stylesheet'\n if (!existing) link.href = href\n // Re-appending an already-present node moves it; the browser does not refetch\n // (and the response is ETag + max-age=60 cached regardless).\n document.head.appendChild(link)\n}\n"]}
@@ -0,0 +1,4 @@
1
+ declare const SPECS_TOKENS_HREF = "https://specs.politogyvrm.com/api/tokens?format=css";
2
+ declare function ensureRuntimeBrandTokens(href?: string): void;
3
+
4
+ export { SPECS_TOKENS_HREF, ensureRuntimeBrandTokens };
@@ -0,0 +1,4 @@
1
+ declare const SPECS_TOKENS_HREF = "https://specs.politogyvrm.com/api/tokens?format=css";
2
+ declare function ensureRuntimeBrandTokens(href?: string): void;
3
+
4
+ export { SPECS_TOKENS_HREF, ensureRuntimeBrandTokens };
@@ -0,0 +1,16 @@
1
+ // src/runtime-tokens.ts
2
+ var SPECS_TOKENS_HREF = "https://specs.politogyvrm.com/api/tokens?format=css";
3
+ function ensureRuntimeBrandTokens(href = SPECS_TOKENS_HREF) {
4
+ if (typeof document === "undefined") return;
5
+ const existing = document.querySelector(
6
+ `link[rel="stylesheet"][href*="api/tokens"]`
7
+ );
8
+ const link = existing ?? document.createElement("link");
9
+ link.rel = "stylesheet";
10
+ if (!existing) link.href = href;
11
+ document.head.appendChild(link);
12
+ }
13
+
14
+ export { SPECS_TOKENS_HREF, ensureRuntimeBrandTokens };
15
+ //# sourceMappingURL=runtime-tokens.js.map
16
+ //# sourceMappingURL=runtime-tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime-tokens.ts"],"names":[],"mappings":";AAaO,IAAM,iBAAA,GACX;AAEK,SAAS,wBAAA,CAAyB,OAAe,iBAAA,EAAyB;AAC/E,EAAA,IAAI,OAAO,aAAa,WAAA,EAAa;AACrC,EAAA,MAAM,WAAW,QAAA,CAAS,aAAA;AAAA,IACxB,CAAA,0CAAA;AAAA,GACF;AACA,EAAA,MAAM,IAAA,GAAO,QAAA,IAAY,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA;AACtD,EAAA,IAAA,CAAK,GAAA,GAAM,YAAA;AACX,EAAA,IAAI,CAAC,QAAA,EAAU,IAAA,CAAK,IAAA,GAAO,IAAA;AAG3B,EAAA,QAAA,CAAS,IAAA,CAAK,YAAY,IAAI,CAAA;AAChC","file":"runtime-tokens.js","sourcesContent":["// Runtime Brand tokens — the loader every app shares.\n//\n// Global-Rules (\"Consume Brand tokens at RUNTIME, never baked in at build time\")\n// requires each app to load specs.politogyvrm.com/api/tokens?format=css so a\n// Brand edit goes live without a redeploy. A static <link> in <head> is not\n// enough on its own: the app's own bundled chrome.css can be injected AFTER it\n// and win the cascade, which is exactly what happened on VRM — it linked the\n// runtime sheet yet still resolved --color-accent from the build-time snapshot.\n//\n// Appending the link to the END of <head> at startup makes the runtime sheet the\n// last stylesheet, so the live Brand values win every time. Idempotent: an\n// existing runtime link is MOVED to the end rather than duplicated.\n\nexport const SPECS_TOKENS_HREF =\n 'https://specs.politogyvrm.com/api/tokens?format=css'\n\nexport function ensureRuntimeBrandTokens(href: string = SPECS_TOKENS_HREF): void {\n if (typeof document === 'undefined') return\n const existing = document.querySelector<HTMLLinkElement>(\n `link[rel=\"stylesheet\"][href*=\"api/tokens\"]`,\n )\n const link = existing ?? document.createElement('link')\n link.rel = 'stylesheet'\n if (!existing) link.href = href\n // Re-appending an already-present node moves it; the browser does not refetch\n // (and the response is ETag + max-age=60 cached regardless).\n document.head.appendChild(link)\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@the-portland-company/shell",
3
- "version": "0.28.2",
3
+ "version": "0.29.0",
4
4
  "description": "Shared chrome (header, sidebar, footer, theme, auth) for politogy apps. Drop into any Vite SPA to inherit the politogy look and signed-in user.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -45,6 +45,11 @@
45
45
  "types": "./dist/app-icons.d.ts",
46
46
  "import": "./dist/app-icons.js",
47
47
  "require": "./dist/app-icons.cjs"
48
+ },
49
+ "./runtime-tokens": {
50
+ "types": "./dist/runtime-tokens.d.ts",
51
+ "import": "./dist/runtime-tokens.js",
52
+ "require": "./dist/runtime-tokens.cjs"
48
53
  }
49
54
  },
50
55
  "files": [