@floegence/floe-webapp-core 0.101.52 → 0.102.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.
@@ -1,10 +1,10 @@
1
- import { createComponent as he } from "solid-js/web";
2
- import { untrack as ae, createSignal as p, createEffect as v, createMemo as w, onCleanup as H } from "solid-js";
1
+ import { createComponent as me } from "solid-js/web";
2
+ import { untrack as he, createSignal as p, createEffect as g, createMemo as w, onCleanup as H } from "solid-js";
3
3
  import { createSimpleContext as fe } from "./createSimpleContext.js";
4
4
  import { useResolvedFloeConfig as ue } from "./FloeConfigContext.js";
5
5
  import { isFloeSurfaceStyle as L, applySurfaceStyleAttribute as I, isThemeType as de, getSystemTheme as Se, applyTheme as ye, applyShellThemeAttribute as J, resolveThemeTokens as pe, syncThemeTokenOverrides as U } from "../styles/themes/index.js";
6
6
  import { normalizeShellThemeSelection as W, presetSupportsMode as X } from "../styles/themes/presets.js";
7
- function P(o, s, r) {
7
+ function v(o, s, r) {
8
8
  if (s.length !== 0)
9
9
  return o && s.some((n) => n.name === o) ? o : r && s.some((n) => n.name === r) ? r : s[0]?.name;
10
10
  }
@@ -16,9 +16,10 @@ function Y(o) {
16
16
  colorSchemePriority: o.style.getPropertyPriority("color-scheme"),
17
17
  material: o.getAttribute("data-floe-surface-style"),
18
18
  shell: o.getAttribute("data-floe-shell-theme"),
19
+ features: o.getAttribute("data-floe-theme-features"),
19
20
  themeScope: o.getAttribute("data-floe-theme")
20
- } : void 0, g = /* @__PURE__ */ new Map(), M = (e) => {
21
- const t = g.get(e);
21
+ } : void 0, P = /* @__PURE__ */ new Map(), M = (e) => {
22
+ const t = P.get(e);
22
23
  t?.value ? o?.style.setProperty(e, t.value, t.priority) : o?.style.removeProperty(e);
23
24
  };
24
25
  let $ = !1;
@@ -27,26 +28,26 @@ function Y(o) {
27
28
  const [F, _] = p(L(k) ? k : T), ee = (e) => {
28
29
  _(L(e) ? e : T);
29
30
  };
30
- v(() => I(F(), r));
31
- const te = () => s.config.theme.tokens, c = () => s.config.theme.presets ?? [], b = () => s.config.theme.presetStorageKey ?? `${f()}-preset`, u = () => P(s.config.theme.defaultPreset, c()), h = w(() => [...s.config.theme.shellPresets ?? [], ...s.config.theme.additionalShellPresets?.() ?? []]), V = () => s.config.theme.shellPresetStorageKey ?? `${f()}-shell-preset`, O = () => s.config.theme.defaultShellPreset ?? {}, j = s.persist.load(f(), E()), oe = de(j) ? j : E(), [x, se] = p(oe), re = s.persist.load(b(), u()), [A, q] = p(P(re, c(), u())), ne = s.persist.load(V(), void 0), [K, z] = p(W(ne, h(), O())), [le, ie] = p(Se());
31
+ g(() => I(F(), r));
32
+ const te = () => s.config.theme.tokens, c = () => s.config.theme.presets ?? [], b = () => s.config.theme.presetStorageKey ?? `${f()}-preset`, u = () => v(s.config.theme.defaultPreset, c()), m = w(() => [...s.config.theme.shellPresets ?? [], ...s.config.theme.additionalShellPresets?.() ?? []]), V = () => s.config.theme.shellPresetStorageKey ?? `${f()}-shell-preset`, j = () => s.config.theme.defaultShellPreset ?? {}, O = s.persist.load(f(), E()), oe = de(O) ? O : E(), [A, se] = p(oe), re = s.persist.load(b(), u()), [x, q] = p(v(re, c(), u())), ne = s.persist.load(V(), void 0), [K, z] = p(W(ne, m(), j())), [le, ie] = p(Se());
32
33
  let d = [];
33
34
  const Q = w(() => {
34
- const e = P(A(), c(), u());
35
+ const e = v(x(), c(), u());
35
36
  if (e)
36
37
  return c().find((t) => t.name === e);
37
38
  }), S = () => {
38
- const e = x();
39
+ const e = A();
39
40
  return e === "system" ? le() : e;
40
41
  }, R = (e) => {
41
42
  const t = K()[e];
42
43
  if (t)
43
- return h().find((l) => l.name === t && X(l, e));
44
+ return m().find((l) => l.name === t && X(l, e));
44
45
  }, B = w(() => R(S()));
45
- if (v(() => {
46
- const e = P(A(), c(), u());
47
- A() !== e && q(e);
48
- }), v(() => {
49
- const e = K(), t = W(e, h(), O());
46
+ if (g(() => {
47
+ const e = v(x(), c(), u());
48
+ x() !== e && q(e);
49
+ }), g(() => {
50
+ const e = K(), t = W(e, m(), j());
50
51
  (e.light !== t.light || e.dark !== t.dark) && z(t);
51
52
  }), typeof window < "u") {
52
53
  const e = window.matchMedia("(prefers-color-scheme: dark)"), t = (l) => {
@@ -54,18 +55,18 @@ function Y(o) {
54
55
  };
55
56
  e.addEventListener("change", t), H(() => e.removeEventListener("change", t));
56
57
  }
57
- v(() => {
58
- const e = x(), t = S(), l = B();
59
- o && o.setAttribute("data-floe-theme", ""), ye(e, r), J(l?.name, r);
60
- const m = pe(t, te(), l?.tokens, Q()?.tokens);
58
+ g(() => {
59
+ const e = A(), t = S(), l = B();
60
+ o && o.setAttribute("data-floe-theme", ""), ye(e, r), J(l?.name, r), r?.setAttribute("data-floe-theme-features", (l?.features ?? []).join(" "));
61
+ const a = pe(t, te(), l?.tokens, Q()?.tokens);
61
62
  if (o)
62
- for (const i of Object.keys(m))
63
- g.has(i) || g.set(i, {
63
+ for (const i of Object.keys(a))
64
+ P.has(i) || P.set(i, {
64
65
  value: o.style.getPropertyValue(i),
65
66
  priority: o.style.getPropertyPriority(i)
66
67
  });
67
68
  const y = d;
68
- if (d = U(m, y, r), o)
69
+ if (d = U(a, y, r), o)
69
70
  for (const i of y) d.includes(i) || M(i);
70
71
  r && queueMicrotask(() => {
71
72
  if ($) return;
@@ -73,18 +74,18 @@ function Y(o) {
73
74
  for (; ; ) {
74
75
  const G = (r.getAnimations?.({
75
76
  subtree: !0
76
- }) ?? []).filter((a) => !i.has(a) && "transitionProperty" in a && /(^|-)color$|^(fill|stroke|box-shadow)$/.test(String(a.transitionProperty)));
77
+ }) ?? []).filter((h) => !i.has(h) && "transitionProperty" in h && /(^|-)color$|^(fill|stroke|box-shadow)$/.test(String(h.transitionProperty)));
77
78
  if (G.length === 0) break;
78
- for (const a of G)
79
- i.add(a), a.finish();
79
+ for (const h of G)
80
+ i.add(h), h.finish();
80
81
  }
81
82
  });
82
83
  }), H(() => {
83
- if ($ = !0, I(void 0, r), J(void 0, r), d = U(void 0, d, r), o && n) {
84
+ if ($ = !0, I(void 0, r), J(void 0, r), r?.removeAttribute("data-floe-theme-features"), d = U(void 0, d, r), o && n) {
84
85
  o.classList.toggle("light", n.light), o.classList.toggle("dark", n.dark), n.colorScheme ? o.style.setProperty("color-scheme", n.colorScheme, n.colorSchemePriority) : o.style.removeProperty("color-scheme");
85
- for (const [e, t] of [["data-floe-surface-style", n.material], ["data-floe-shell-theme", n.shell], ["data-floe-theme", n.themeScope]])
86
+ for (const [e, t] of [["data-floe-surface-style", n.material], ["data-floe-shell-theme", n.shell], ["data-floe-theme-features", n.features], ["data-floe-theme", n.themeScope]])
86
87
  t === null ? o.removeAttribute(e) : o.setAttribute(e, t);
87
- for (const e of g.keys()) M(e);
88
+ for (const e of P.keys()) M(e);
88
89
  }
89
90
  });
90
91
  const C = (e) => {
@@ -92,20 +93,20 @@ function Y(o) {
92
93
  }, ce = () => {
93
94
  const e = S();
94
95
  C(e === "light" ? "dark" : "light");
95
- }, me = (e) => {
96
- const t = P(e, c(), u());
96
+ }, ae = (e) => {
97
+ const t = v(e, c(), u());
97
98
  if (q(t), !t) {
98
99
  s.persist.remove(b());
99
100
  return;
100
101
  }
101
102
  s.persist.debouncedSave(b(), t);
102
103
  }, D = (e, t) => {
103
- const l = h().find((i) => i.name === t && X(i, e));
104
+ const l = m().find((i) => i.name === t && X(i, e));
104
105
  if (!l) return !1;
105
- const m = K();
106
- if (m[e] === l.name) return !0;
106
+ const a = K();
107
+ if (a[e] === l.name) return !0;
107
108
  const y = {
108
- ...m,
109
+ ...a,
109
110
  version: 1,
110
111
  [e]: l.name
111
112
  };
@@ -114,18 +115,18 @@ function Y(o) {
114
115
  return {
115
116
  surfaceStyle: F,
116
117
  setSurfaceStyle: ee,
117
- theme: x,
118
+ theme: A,
118
119
  resolvedTheme: S,
119
120
  setTheme: C,
120
121
  toggleTheme: ce,
121
122
  themePresets: c,
122
123
  themePreset: Q,
123
- setThemePreset: me,
124
- shellPresets: h,
124
+ setThemePreset: ae,
125
+ shellPresets: m,
125
126
  shellPreset: B,
126
127
  shellPresetForMode: R,
127
128
  setShellPreset: (e) => {
128
- const t = h().find((m) => m.name === e);
129
+ const t = m().find((a) => a.name === e);
129
130
  if (!t) return;
130
131
  const l = t.mode === "light" || t.mode === "dark" ? t.mode : S();
131
132
  D(l, e);
@@ -140,8 +141,8 @@ const Z = fe({
140
141
  init: Y
141
142
  }), Ke = Z.use;
142
143
  function Ce(o) {
143
- const s = Y(ae(() => o.target));
144
- return he(Z.Context.Provider, {
144
+ const s = Y(he(() => o.target));
145
+ return me(Z.Context.Provider, {
145
146
  value: s,
146
147
  get children() {
147
148
  return o.children;
package/dist/floe.css CHANGED
@@ -1083,5 +1083,5 @@
1083
1083
  .floe-prompt-card-input { font-size: 1rem; }
1084
1084
  .floe-prompt-card .floe-prompt-card-selection { min-height: 2.75rem; }
1085
1085
  }
1086
- :root[data-floe-shell-theme='hc-light'] .floe-prompt-card { border: 1px solid var(--floe-line); }
1086
+ :root:is([data-floe-theme-features~='high-contrast'],[data-floe-shell-theme='hc-light']:where(:not([data-floe-theme-features]))) .floe-prompt-card { border: 1px solid var(--floe-line); }
1087
1087
  @media (forced-colors: active) { .floe-prompt-card { border: 1px solid CanvasText; } }
@@ -24,6 +24,7 @@ export interface FloeThemeTokenOverrides {
24
24
  }
25
25
  export interface FloeThemePreset {
26
26
  name: string;
27
+ features?: readonly string[];
27
28
  displayName: string;
28
29
  description?: string;
29
30
  mode?: FloeThemePresetMode;
@@ -0,0 +1,30 @@
1
+ import type { FloeMonacoTokenRule, FloeThemePreset } from './index';
2
+ type Strings = Record<string, string>;
3
+ export interface ThemeShadowLayer {
4
+ x: number;
5
+ y: number;
6
+ blur: number;
7
+ spread: number;
8
+ color: string;
9
+ }
10
+ export interface PortableShellTheme {
11
+ version: 2;
12
+ name: string;
13
+ mode: 'light' | 'dark';
14
+ features: string[];
15
+ palette: Strings;
16
+ colors: Strings;
17
+ shadow: ThemeShadowLayer[];
18
+ editor: Strings;
19
+ terminal?: Strings;
20
+ parts?: Strings;
21
+ syntax: FloeMonacoTokenRule[];
22
+ }
23
+ export declare const PORTABLE_THEME_LIMIT: number;
24
+ export declare const shellColorRoles: string[];
25
+ export declare const terminalThemeRoles: string[];
26
+ export declare function exportShellTheme(preset: FloeThemePreset): PortableShellTheme;
27
+ export declare function readPortableShellTheme(source: unknown): PortableShellTheme;
28
+ export declare function portableContrastIssue(doc: PortableShellTheme): string | undefined;
29
+ export declare function resolvePortableShellTheme(id: string, input: PortableShellTheme): FloeThemePreset;
30
+ export {};
@@ -0,0 +1,289 @@
1
+ import { builtInShellThemePresets as z, REQUIRED_SHELL_THEME_TOKENS as N } from "./presets.js";
2
+ import { resolveFloeThemeDocument as v, readFloeThemeDocument as M } from "./themeDocument.js";
3
+ const x = 128 * 1024, h = "--floe-window-shadow", C = [
4
+ ...new Set(
5
+ z.flatMap((t) => Object.keys(t.semanticTokens ?? {}))
6
+ )
7
+ ].filter((t) => t !== h).sort(), j = new Set(C), T = [
8
+ "background",
9
+ "foreground",
10
+ "cursor",
11
+ "cursorAccent",
12
+ "selectionBackground",
13
+ "selectionForeground",
14
+ ...["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"].flatMap((t) => [
15
+ t,
16
+ `bright${t[0].toUpperCase()}${t.slice(1)}`
17
+ ])
18
+ ], F = /* @__PURE__ */ new Set([
19
+ "--background",
20
+ "--foreground",
21
+ "--primary",
22
+ "--primary-foreground",
23
+ "--card",
24
+ "--card-foreground",
25
+ "--sidebar",
26
+ "--sidebar-foreground",
27
+ "--border",
28
+ "--muted",
29
+ "--muted-foreground",
30
+ "--success",
31
+ "--warning",
32
+ "--error",
33
+ "--info"
34
+ ]), I = N.filter((t) => t !== h), R = /^(?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?)%$/, A = /^#[a-f\d]{6}(?:[a-f\d]{2})?$/i, E = /^rgb\((?:\d{1,3} ){2}\d{1,3}(?: \/ (?:100|\d{1,2})%)?\)$/, B = /^(?:hsl\(\d{1,3} \d{1,3}% \d{1,3}%\)|oklch\((?:0(?:\.\d+)?|1) 0(?:\.\d+)? \d{1,3}\))$/, L = /^var\((--[a-z0-9-]+)\)$/, _ = /^color-mix\(in srgb, (var\(--[a-z0-9-]+\)|#[a-fA-F0-9]{6}) (\d{1,3}%), (var\(--[a-z0-9-]+\)|white|#[a-fA-F0-9]{6})\)$/, a = (t) => {
35
+ throw new Error(t);
36
+ }, w = (t) => !!t && typeof t == "object" && !Array.isArray(t), O = (t, r, n) => {
37
+ for (const s of Object.keys(t))
38
+ r.includes(s) || a(`${n}.${s.slice(0, 80)}`);
39
+ }, $ = (t) => t === 0 ? "0" : `${t}px`;
40
+ function K(t) {
41
+ return t === "none" ? [] : t.split(", ").map((r) => {
42
+ const n = /^(-?\d+)(?:px)? (-?\d+)(?:px)? (\d+)(?:px)?(?: (-?\d+)(?:px)?)? (.+)$/.exec(
43
+ r
44
+ );
45
+ return n ? {
46
+ x: +n[1],
47
+ y: +n[2],
48
+ blur: +n[3],
49
+ spread: Number(n[4] ?? 0),
50
+ color: n[5]
51
+ } : a(h);
52
+ });
53
+ }
54
+ function P(t) {
55
+ const r = t.mode;
56
+ if (r !== "light" && r !== "dark") return a("mode");
57
+ const n = t.monaco?.[r];
58
+ if (!n) return a("editor");
59
+ const s = Object.fromEntries(
60
+ Object.entries(t.semanticTokens ?? {}).filter(
61
+ (i) => typeof i[1] == "string"
62
+ )
63
+ ), d = K(s[h] ?? "none");
64
+ delete s[h];
65
+ const c = { ...n.colors };
66
+ for (const [i, f] of Object.entries({
67
+ "editor.background": "background",
68
+ "editorGutter.background": "background",
69
+ "editor.foreground": "foreground",
70
+ "editorCursor.foreground": "primary",
71
+ "editor.selectionBackground": "selection-bg",
72
+ "editor.selectionForeground": "selection-fg"
73
+ }))
74
+ c[i] === s[`--${f}`] && (c[i] = `@${f}`);
75
+ return {
76
+ version: 2,
77
+ name: t.displayName,
78
+ mode: r,
79
+ features: [...t.features ?? []],
80
+ palette: {},
81
+ colors: s,
82
+ shadow: d,
83
+ editor: c,
84
+ syntax: n.rules.map((i) => ({ ...i }))
85
+ };
86
+ }
87
+ function b(t, r, n, s) {
88
+ return !w(t) || Object.keys(t).length > s ? a(r) : Object.fromEntries(
89
+ Object.entries(t).map(([d, c]) => !n(d) || typeof c != "string" || c.length > 256 ? a(`${r}.${d.slice(0, 80)}`) : [d, c])
90
+ );
91
+ }
92
+ function S(t) {
93
+ const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set(), s = (e, o) => {
94
+ if (!e.startsWith("$") && !e.startsWith("@")) return e;
95
+ const m = r.get(e);
96
+ if (m !== void 0) return m;
97
+ const l = e.startsWith("$") ? t.palette : t.colors, y = (e.startsWith("@") ? "--" : "") + e.slice(1);
98
+ if (!Object.hasOwn(l, y) || n.has(e)) return a(`${o}: ${e}`);
99
+ n.add(e);
100
+ const p = s(l[y], o);
101
+ return n.delete(e), r.set(e, p), p;
102
+ }, d = (e, o, m) => {
103
+ const l = s(e, o);
104
+ return A.test(l) || m && (E.test(l) || B.test(l) || L.test(l) || _.test(l)) ? l : a(o);
105
+ };
106
+ for (const [e, o] of Object.entries(t.palette)) d(o, `palette.${e}`, !1);
107
+ const c = Object.fromEntries(
108
+ Object.entries(t.colors).map(([e, o]) => [
109
+ e,
110
+ e === "--floe-progress-primary-white-mix" ? R.test(o) ? o : a(e) : d(o, `colors.${e}`, !F.has(e))
111
+ ])
112
+ );
113
+ for (const [e, o] of Object.entries(t.terminal ?? {}))
114
+ c[`--terminal-${e.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}`] = d(
115
+ o,
116
+ `terminal.${e}`,
117
+ !1
118
+ );
119
+ for (const [e, o] of Object.entries(t.parts ?? {}))
120
+ c[`--theme-part-${e}`] = d(o, `parts.${e}`, !1);
121
+ const i = /* @__PURE__ */ new Set(), f = (e) => {
122
+ if (!i.has(e)) {
123
+ (n.has(e) || !Object.hasOwn(c, e)) && a(`colors.${e}`), n.add(e);
124
+ for (const o of c[e].matchAll(/var\((--[a-z0-9-]+)\)/g)) f(o[1]);
125
+ n.delete(e), i.add(e);
126
+ }
127
+ };
128
+ for (const e of Object.keys(c)) f(e);
129
+ c[h] = t.shadow.map(({ x: e, y: o, blur: m, spread: l, color: y }, p) => {
130
+ const k = s(y, `shadow.${p}.color`);
131
+ return !A.test(k) && !E.test(k) && a(`shadow.${p}.color`), [
132
+ $(e),
133
+ $(o),
134
+ $(m),
135
+ ...l ? [$(l)] : [],
136
+ k
137
+ ].join(" ");
138
+ }).join(", ") || "none";
139
+ const u = Object.fromEntries(
140
+ Object.entries(t.editor).map(([e, o]) => [e, d(o, `editor.${e}`, !1)])
141
+ ), g = t.syntax.map((e, o) => {
142
+ const m = d(e.foreground, `syntax.${o}.foreground`, !1);
143
+ return m.length !== 7 && a(`syntax.${o}.foreground`), { ...e, foreground: m };
144
+ });
145
+ return { tokens: c, editor: u, syntax: g };
146
+ }
147
+ function W(t) {
148
+ typeof t == "string" && (t.length > x || new TextEncoder().encode(t).length > x) && a("128 KiB");
149
+ const r = typeof t == "string" ? JSON.parse(t) : t;
150
+ if (!w(r)) return a("theme");
151
+ if (r.version === 1)
152
+ return P(v("migration", M(r)));
153
+ if (O(
154
+ r,
155
+ [
156
+ "version",
157
+ "name",
158
+ "mode",
159
+ "features",
160
+ "palette",
161
+ "colors",
162
+ "shadow",
163
+ "editor",
164
+ "syntax",
165
+ "terminal",
166
+ "parts"
167
+ ],
168
+ "theme"
169
+ ), r.version !== 2) return a("version");
170
+ if (typeof r.name != "string" || !r.name.trim() || r.name.length > 80 || /[\p{Cc}\p{Cf}]/u.test(r.name))
171
+ return a("name");
172
+ if (r.mode !== "light" && r.mode !== "dark") return a("mode");
173
+ if (!Array.isArray(r.features) || r.features.length > 32 || r.features.some(
174
+ (e) => typeof e != "string" || !/^[a-z][a-z0-9-]{0,63}$/.test(e)
175
+ ) || new Set(r.features).size !== r.features.length)
176
+ return a("features");
177
+ const n = b(
178
+ r.palette,
179
+ "palette",
180
+ (e) => /^[a-z][a-z0-9-]{0,63}$/.test(e),
181
+ 256
182
+ ), s = b(r.colors, "colors", (e) => j.has(e), j.size);
183
+ for (const e of I) Object.hasOwn(s, e) || a(`colors.${e}`);
184
+ if (!Array.isArray(r.shadow) || r.shadow.length > 8) return a("shadow");
185
+ const d = r.shadow.map((e, o) => {
186
+ if (!w(e)) return a(`shadow.${o}`);
187
+ O(e, ["x", "y", "blur", "spread", "color"], `shadow.${o}`);
188
+ for (const m of ["x", "y", "blur", "spread"]) {
189
+ const l = e[m];
190
+ (typeof l != "number" || !Number.isFinite(l) || Math.abs(l) > 256 || m === "blur" && l < 0) && a(`shadow.${o}.${m}`);
191
+ }
192
+ return typeof e.color != "string" || e.color.length > 100 ? a(`shadow.${o}.color`) : {
193
+ x: Number(e.x),
194
+ y: Number(e.y),
195
+ blur: Number(e.blur),
196
+ spread: Number(e.spread),
197
+ color: e.color
198
+ };
199
+ }), c = b(
200
+ r.editor,
201
+ "editor",
202
+ (e) => /^[a-zA-Z][\w-]{0,79}(?:\.[\w-]{1,80}){1,5}$/.test(e),
203
+ 512
204
+ ), i = r.terminal === void 0 ? void 0 : b(
205
+ r.terminal,
206
+ "terminal",
207
+ (e) => T.includes(e),
208
+ T.length
209
+ ), f = r.parts === void 0 ? void 0 : b(r.parts, "parts", (e) => /^[a-z][a-z0-9-]{0,79}$/.test(e), 256);
210
+ if (!Array.isArray(r.syntax) || r.syntax.length > 512) return a("syntax");
211
+ const u = r.syntax.map((e, o) => !w(e) || typeof e.token != "string" || !/^[\w.-]{0,128}$/.test(e.token) || typeof e.foreground != "string" || e.foreground.length > 128 ? a(`syntax.${o}`) : (O(e, ["token", "foreground", "fontStyle"], `syntax.${o}`), e.fontStyle !== void 0 && (typeof e.fontStyle != "string" || !/^(?:(?:bold|italic|underline|strikethrough)(?: |$)){0,4}$/.test(e.fontStyle)) ? a(`syntax.${o}.fontStyle`) : {
212
+ token: e.token,
213
+ foreground: e.foreground,
214
+ ...typeof e.fontStyle == "string" ? { fontStyle: e.fontStyle } : {}
215
+ })), g = {
216
+ version: 2,
217
+ name: r.name.trim(),
218
+ mode: r.mode,
219
+ features: [...r.features],
220
+ palette: n,
221
+ colors: s,
222
+ shadow: d,
223
+ editor: c,
224
+ syntax: u,
225
+ ...i && { terminal: i },
226
+ ...f && { parts: f }
227
+ };
228
+ return new TextEncoder().encode(JSON.stringify(g, null, 2) + `
229
+ `).length > x && a("128 KiB"), S(g), g;
230
+ }
231
+ function J(t) {
232
+ const { tokens: r } = S(t), n = (i) => [1, 3, 5, 7].map(
233
+ (f, u) => u === 3 && i.length === 7 ? 1 : parseInt(i.slice(f, f + 2), 16) / 255
234
+ ), s = (i, f) => i.slice(0, 3).map((u, g) => u * i[3] + f[g] * (1 - i[3])), d = (i) => i.reduce(
235
+ (f, u, g) => f + [0.2126, 0.7152, 0.0722][g] * (u <= 0.04045 ? u / 12.92 : ((u + 0.055) / 1.055) ** 2.4),
236
+ 0
237
+ ), c = s(n(r["--background"]), Array(3).fill(t.mode === "light" ? 1 : 0));
238
+ for (const [i, f] of [
239
+ ["--background", "--foreground"],
240
+ ["--card", "--card-foreground"],
241
+ ["--primary", "--primary-foreground"],
242
+ ["--sidebar", "--sidebar-foreground"]
243
+ ]) {
244
+ const u = i === "--background" ? c : s(n(r[i]), c), g = d(u), e = d(s(n(r[f]), u)), o = (Math.max(g, e) + 0.05) / (Math.min(g, e) + 0.05);
245
+ if (o < 4.5) return `${f} / ${i}: ${o.toFixed(2)}:1 < 4.5:1`;
246
+ }
247
+ }
248
+ function U(t, r) {
249
+ const n = W(r), { tokens: s, editor: d, syntax: c } = S(n);
250
+ return {
251
+ name: t,
252
+ displayName: n.name,
253
+ mode: n.mode,
254
+ features: n.features,
255
+ semanticTokens: s,
256
+ tokens: { [n.mode]: s },
257
+ preview: {
258
+ background: s["--background"],
259
+ surface: s["--card"],
260
+ sidebar: s["--sidebar"],
261
+ primary: s["--primary"],
262
+ border: s["--border"],
263
+ colors: [
264
+ s["--chart-1"],
265
+ s["--chart-2"],
266
+ s["--chart-3"],
267
+ s["--chart-4"],
268
+ s["--chart-5"]
269
+ ]
270
+ },
271
+ monaco: {
272
+ [n.mode]: {
273
+ base: n.mode === "light" ? "vs" : "vs-dark",
274
+ inherit: !0,
275
+ colors: d,
276
+ rules: c
277
+ }
278
+ }
279
+ };
280
+ }
281
+ export {
282
+ x as PORTABLE_THEME_LIMIT,
283
+ P as exportShellTheme,
284
+ J as portableContrastIssue,
285
+ W as readPortableShellTheme,
286
+ U as resolvePortableShellTheme,
287
+ C as shellColorRoles,
288
+ T as terminalThemeRoles
289
+ };
@@ -10,6 +10,7 @@ export type FloeShellThemeDefaults = Partial<Record<FloeShellThemeMode, string>>
10
10
  type ShellThemeTokenName = '--floe-window-background' | '--floe-window-foreground' | '--floe-window-muted-foreground' | '--floe-window-titlebar-background' | '--floe-window-border' | '--floe-window-shadow' | '--background' | '--foreground' | '--inline-code-foreground' | '--inline-code-background' | '--primary' | '--primary-foreground' | '--secondary' | '--secondary-foreground' | '--muted' | '--muted-foreground' | '--accent' | '--accent-foreground' | '--border' | '--input' | '--ring' | '--chrome-border' | '--top-bar-border' | '--activity-bar-border' | '--bottom-bar-border' | '--terminal-panel-border' | '--card' | '--card-foreground' | '--popover' | '--popover-foreground' | '--success' | '--success-foreground' | '--warning' | '--warning-foreground' | '--error' | '--error-foreground' | '--info' | '--info-foreground' | '--highlight-block-info-accent' | '--highlight-block-warning-accent' | '--highlight-block-success-accent' | '--highlight-block-error-accent' | '--highlight-block-note-accent' | '--highlight-block-tip-accent' | '--sidebar' | '--sidebar-foreground' | '--sidebar-primary' | '--sidebar-primary-foreground' | '--sidebar-accent' | '--sidebar-accent-foreground' | '--sidebar-border' | '--sidebar-ring' | '--activity-bar' | '--activity-bar-foreground' | '--activity-bar-foreground-active' | '--activity-bar-badge' | '--activity-bar-badge-foreground' | '--terminal-background' | '--terminal-foreground' | '--chart-1' | '--chart-2' | '--chart-3' | '--chart-4' | '--chart-5' | '--selection-bg' | '--selection-fg' | '--selection-on-primary-bg' | '--selection-on-primary-fg' | '--selection-code-bg' | '--selection-code-fg' | '--glow';
11
11
  export declare const REQUIRED_SHELL_THEME_TOKENS: readonly ShellThemeTokenName[];
12
12
  interface ShellThemePaletteDefinition {
13
+ features?: readonly string[];
13
14
  name: string;
14
15
  displayName: string;
15
16
  description: string;
@@ -81,6 +82,7 @@ export declare const builtInShellThemePresets: readonly [FloeThemePreset, FloeTh
81
82
  semanticTokens: Readonly<Partial<Record<`--${string}`, string>>>;
82
83
  tokens: undefined;
83
84
  name: string;
85
+ features?: readonly string[];
84
86
  displayName: string;
85
87
  description?: string;
86
88
  mode?: FloeThemePresetMode;
@@ -98,6 +100,7 @@ export declare const builtInShellThemePresets: readonly [FloeThemePreset, FloeTh
98
100
  semanticTokens: Readonly<Partial<Record<`--${string}`, string>>>;
99
101
  tokens: undefined;
100
102
  name: string;
103
+ features?: readonly string[];
101
104
  displayName: string;
102
105
  description?: string;
103
106
  mode?: FloeThemePresetMode;
@@ -187,6 +187,7 @@ function o(r) {
187
187
  g[`--floe-file-icon-${m}`] = b;
188
188
  return Object.assign(g, r.semanticTokens), {
189
189
  name: r.name,
190
+ features: r.features ?? [],
190
191
  displayName: r.displayName,
191
192
  description: r.description,
192
193
  mode: r.mode,
@@ -334,6 +335,7 @@ const C = {
334
335
  }, h = [
335
336
  o({
336
337
  name: "porcelain-light",
338
+ features: ["opaque-muted-ink"],
337
339
  inlineCode: { foreground: "#742D45", background: "#F4E7EB" },
338
340
  displayName: "Porcelain Light",
339
341
  description: "Clean porcelain whites, neutral layers, and restrained charcoal.",
@@ -709,6 +711,7 @@ const C = {
709
711
  }),
710
712
  o({
711
713
  name: "hc-light",
714
+ features: ["high-contrast"],
712
715
  inlineCode: { foreground: "#00499C", background: "#F4F7FB" },
713
716
  displayName: "High Contrast Light",
714
717
  description: "Maximum edge definition for bright environments and low vision.",