origam 2.37.32 → 2.37.34

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.
@@ -7,6 +7,7 @@ exports.applyTheme = applyTheme;
7
7
  exports.applyThemes = applyThemes;
8
8
  exports.installedThemesFromList = installedThemesFromList;
9
9
  exports.isModePinned = isModePinned;
10
+ exports.knownBrand = knownBrand;
10
11
  exports.resolveThemeVars = resolveThemeVars;
11
12
  exports.semanticTreeToVars = semanticTreeToVars;
12
13
  exports.themeSelector = themeSelector;
@@ -97,6 +98,12 @@ function isModePinned(cookieValue, defaultMode) {
97
98
  const concrete = v => v === "light" || v === "dark";
98
99
  return concrete(cookieValue) || concrete(defaultMode);
99
100
  }
101
+ function knownBrand(value, themes) {
102
+ if (!value) {
103
+ return null;
104
+ }
105
+ return value === "auto" || (themes ?? []).some(t => t.name === value) ? value : null;
106
+ }
100
107
  function themeToUnpinnedCss(theme) {
101
108
  if (theme.mode !== "light" && theme.mode !== "dark") return "";
102
109
  const vars = resolveThemeVars(theme);
@@ -53,6 +53,20 @@ export declare function themeToCss(theme: IOrigamTheme): string;
53
53
  * Shared by both Nuxt plugins so server and client never disagree on it (#1103).
54
54
  ********************************************************/
55
55
  export declare function isModePinned(cookieValue: string | null | undefined, defaultMode: string | undefined): boolean;
56
+ /*********************************************************
57
+ * knownBrand
58
+ *
59
+ * @description
60
+ * Trust boundary for the brand cookie (#1120): the value is returned only when
61
+ * it is `auto` or names an INSTALLED theme, otherwise `null` so the caller
62
+ * falls back to the configured default. A whitelist scan (`some`), never a
63
+ * property lookup, so `__proto__` / `constructor` are just unknown names.
64
+ * @description
65
+ * Shared by both Nuxt plugins so server and client never disagree on it.
66
+ ********************************************************/
67
+ export declare function knownBrand(value: string | null | undefined, themes: readonly {
68
+ name?: string;
69
+ }[] | undefined): string | null;
56
70
  /*********************************************************
57
71
  * themeToUnpinnedCss
58
72
  *
@@ -76,6 +76,12 @@ export function isModePinned(cookieValue, defaultMode) {
76
76
  const concrete = (v) => v === "light" || v === "dark";
77
77
  return concrete(cookieValue) || concrete(defaultMode);
78
78
  }
79
+ export function knownBrand(value, themes) {
80
+ if (!value) {
81
+ return null;
82
+ }
83
+ return value === "auto" || (themes ?? []).some((t) => t.name === value) ? value : null;
84
+ }
79
85
  export function themeToUnpinnedCss(theme) {
80
86
  if (theme.mode !== "light" && theme.mode !== "dark") return "";
81
87
  const vars = resolveThemeVars(theme);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "origam",
3
- "version": "2.37.32",
3
+ "version": "2.37.34",
4
4
  "type": "module",
5
5
  "description": "origam — a Vue 3 design system with multi-theme design tokens, CSS-first components and TypeScript types.",
6
6
  "keywords": [