@pathscale/ui 1.1.32 → 1.1.33

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.
@@ -30,19 +30,12 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
30
30
  const store = (0, __WEBPACK_EXTERNAL_MODULE__hueShift_js_ca4235e5__.createHueShiftStore)(local.storagePrefix ?? "theme");
31
31
  const colorValue = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>hexToColorValue(store.themeColor()));
32
32
  const handleColorChange = (color)=>{
33
- console.log("[tcp] handleColorChange ENTER", {
34
- hex: color.hex,
35
- hsl: color.hsl,
36
- rgb: color.rgb
37
- });
38
33
  const { s, l } = color.hsl;
39
34
  if (s < 10 && l > 90) {
40
- console.log("[tcp] handleColorChange -> center swatch, clearing");
41
35
  store.setThemeColor(null);
42
36
  local.onColorChange?.(null, 100);
43
37
  return;
44
38
  }
45
- console.log("[tcp] handleColorChange -> setThemeColor", color.hex);
46
39
  store.setThemeColor(color.hex);
47
40
  local.onColorChange?.(color.hsl.h, color.hsl.s);
48
41
  };
@@ -79,13 +72,9 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
79
72
  }
80
73
  ];
81
74
  const handleGrayscale = (swatch)=>{
82
- console.log("[tcp] handleGrayscale ENTER", swatch);
83
- store.setThemeColor(null);
84
- (0, __WEBPACK_EXTERNAL_MODULE__hueShift_js_ca4235e5__.resetHueShift)();
85
- local.onColorChange?.(null, 0);
86
- console.log("[tcp] handleGrayscale -> onThemeSwitch", swatch.theme);
87
75
  local.onThemeSwitch?.(swatch.theme);
88
- console.log("[tcp] handleGrayscale AFTER onThemeSwitch, data-theme=", document.documentElement.getAttribute("data-theme"));
76
+ store.setThemeColor(swatch.hex);
77
+ local.onColorChange?.(null, 0);
89
78
  };
90
79
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
91
80
  if (!isOpen()) return;
@@ -6,6 +6,10 @@ export interface HueShiftStore {
6
6
  setThemeColor: (color: string | null) => void;
7
7
  isAvailable: () => boolean;
8
8
  }
9
+ /**
10
+ * Creates a theme color store with configurable storage prefix.
11
+ * @param storagePrefix - Prefix for localStorage keys (e.g., "myapp" becomes "myapp_theme_color")
12
+ */
9
13
  export declare function createHueShiftStore(storagePrefix: string): HueShiftStore;
10
14
  export declare function getDefaultHueShiftStore(): HueShiftStore;
11
15
  export { resetHueShift };
@@ -1,7 +1,4 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__ from "solid-js";
2
- const log = (...args)=>{
3
- console.log("[tcp]", ...args);
4
- };
5
2
  let cspAllowsInlineStyles = null;
6
3
  const checkCspAllowsInlineStyles = ()=>{
7
4
  if (null !== cspAllowsInlineStyles) return cspAllowsInlineStyles;
@@ -9,22 +6,16 @@ const checkCspAllowsInlineStyles = ()=>{
9
6
  try {
10
7
  const testEl = document.createElement("div");
11
8
  testEl.style.setProperty("--csp-test", "1");
12
- if (!document.body) {
13
- log("csp check: document.body missing, assuming allowed");
14
- cspAllowsInlineStyles = true;
15
- return true;
16
- }
9
+ if (!document.body) return true;
17
10
  document.body.appendChild(testEl);
18
11
  const computed = getComputedStyle(testEl).getPropertyValue("--csp-test");
19
12
  document.body.removeChild(testEl);
20
13
  cspAllowsInlineStyles = "1" === computed;
21
- } catch (err) {
22
- log("csp check: threw, disabling", err);
14
+ } catch {
23
15
  cspAllowsInlineStyles = false;
24
16
  }
25
- log("csp check result:", cspAllowsInlineStyles);
26
- if (!cspAllowsInlineStyles) console.info("[themeColor] CSP blocks inline styles - theme color customization disabled");
27
- return cspAllowsInlineStyles;
17
+ if (false === cspAllowsInlineStyles) console.info("[themeColor] CSP blocks inline styles - theme color customization disabled");
18
+ return cspAllowsInlineStyles ?? true;
28
19
  };
29
20
  const PRIMARY_VARS = [
30
21
  "--color-primary",
@@ -130,50 +121,24 @@ function pickContentColor(r, g, b) {
130
121
  return contrastWithWhite >= contrastWithDark ? "#ffffff" : "#111111";
131
122
  }
132
123
  function applyThemeColor(hex) {
133
- log("applyThemeColor ENTER", hex);
134
- if (!checkCspAllowsInlineStyles()) return void log("applyThemeColor BAILED: csp blocks");
124
+ if (!checkCspAllowsInlineStyles()) return;
135
125
  const rgb = parseHex(hex);
136
- if (!rgb) return void log("applyThemeColor BAILED: parseHex returned null for", hex);
126
+ if (!rgb) return;
137
127
  const root = document.documentElement;
138
128
  const content = pickContentColor(rgb.r, rgb.g, rgb.b);
139
129
  const resolvedTheme = getResolvedTheme();
140
- log("applyThemeColor resolvedTheme=", resolvedTheme, "content=", content);
141
- log("applyThemeColor data-theme attr=", root.getAttribute("data-theme"));
142
130
  for (const varName of PRIMARY_VARS)root.style.setProperty(varName, hex, "important");
143
131
  for (const varName of CONTENT_VARS)root.style.setProperty(varName, content, "important");
144
132
  for (const { name, anchor, mix } of BACKGROUND_VARS[resolvedTheme])root.style.setProperty(name, `color-mix(in oklab, ${hex} ${mix}%, ${anchor})`, "important");
145
- const inlineStyle = root.getAttribute("style") ?? "";
146
- log("applyThemeColor inline style attr length=", inlineStyle.length);
147
- log("applyThemeColor inline snippet:", inlineStyle.slice(0, 400) + (inlineStyle.length > 400 ? "\u2026" : ""));
148
- const cs = getComputedStyle(root);
149
- log("applyThemeColor computed --color-primary=", cs.getPropertyValue("--color-primary").trim());
150
- log("applyThemeColor computed --nf-accent=", cs.getPropertyValue("--nf-accent").trim());
151
- log("applyThemeColor computed --color-nf-accent=", cs.getPropertyValue("--color-nf-accent").trim());
152
- log("applyThemeColor computed --color-primary-content=", cs.getPropertyValue("--color-primary-content").trim());
153
- log("applyThemeColor computed --nf-on-accent=", cs.getPropertyValue("--nf-on-accent").trim());
154
- log("applyThemeColor computed --gradient-start=", cs.getPropertyValue("--gradient-start").trim());
155
- log("applyThemeColor computed --gradient-end=", cs.getPropertyValue("--gradient-end").trim());
156
- log("applyThemeColor computed --color-base-100=", cs.getPropertyValue("--color-base-100").trim());
157
- log("applyThemeColor EXIT");
158
133
  }
159
134
  function resetHueShift() {
160
- log("resetHueShift ENTER");
161
- if (!checkCspAllowsInlineStyles()) return void log("resetHueShift BAILED: csp blocks");
135
+ if (!checkCspAllowsInlineStyles()) return;
162
136
  const root = document.documentElement;
163
137
  for (const varName of PRIMARY_VARS)root.style.removeProperty(varName);
164
138
  for (const varName of CONTENT_VARS)root.style.removeProperty(varName);
165
139
  for (const { name } of BACKGROUND_VARS.light)root.style.removeProperty(name);
166
- const inlineStyle = root.getAttribute("style") ?? "";
167
- log("resetHueShift inline style attr length after=", inlineStyle.length);
168
- const cs = getComputedStyle(root);
169
- log("resetHueShift computed --nf-accent=", cs.getPropertyValue("--nf-accent").trim());
170
- log("resetHueShift computed --color-nf-accent=", cs.getPropertyValue("--color-nf-accent").trim());
171
- log("resetHueShift EXIT");
172
140
  }
173
- let storeInstanceCounter = 0;
174
141
  function createHueShiftStore(storagePrefix) {
175
- const storeId = ++storeInstanceCounter;
176
- log(`createHueShiftStore INIT id=${storeId} prefix=${storagePrefix}`);
177
142
  const STORAGE_KEY = `${storagePrefix}_theme_color`;
178
143
  const LEGACY_KEYS = [
179
144
  `${storagePrefix}_hue_shift`,
@@ -187,12 +152,9 @@ function createHueShiftStore(storagePrefix) {
187
152
  if (saved && parseHex(saved)) return saved;
188
153
  return null;
189
154
  };
190
- const initial = getInitial();
191
- log(`createHueShiftStore id=${storeId} initial localStorage value=`, initial);
192
- const [themeColor, setThemeColorInternal] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(initial);
155
+ const [themeColor, setThemeColorInternal] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(getInitial());
193
156
  (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
194
157
  const color = themeColor();
195
- log(`store id=${storeId} effect fired, themeColor=`, color);
196
158
  if ("undefined" == typeof window) return;
197
159
  if (null === color) {
198
160
  localStorage.removeItem(STORAGE_KEY);
@@ -204,14 +166,10 @@ function createHueShiftStore(storagePrefix) {
204
166
  });
205
167
  if ("undefined" != typeof window) {
206
168
  const observer = new MutationObserver((mutations)=>{
207
- for (const mutation of mutations)if ("attributes" === mutation.type && "data-theme" === mutation.attributeName) {
208
- log(`store id=${storeId} observer saw data-theme change to=`, document.documentElement.getAttribute("data-theme"));
209
- requestAnimationFrame(()=>{
210
- const color = themeColor();
211
- log(`store id=${storeId} observer rAF fired, themeColor=`, color);
212
- if (null !== color) applyThemeColor(color);
213
- });
214
- }
169
+ for (const mutation of mutations)if ("attributes" === mutation.type && "data-theme" === mutation.attributeName) requestAnimationFrame(()=>{
170
+ const color = themeColor();
171
+ if (null !== color) applyThemeColor(color);
172
+ });
215
173
  });
216
174
  observer.observe(document.documentElement, {
217
175
  attributes: true,
@@ -221,9 +179,8 @@ function createHueShiftStore(storagePrefix) {
221
179
  });
222
180
  }
223
181
  const setThemeColor = (color)=>{
224
- log(`store id=${storeId} setThemeColor called with=`, color);
225
182
  if (null === color) return void setThemeColorInternal(null);
226
- if (!parseHex(color)) return void log(`store id=${storeId} setThemeColor REJECTED (parseHex failed)`);
183
+ if (!parseHex(color)) return;
227
184
  setThemeColorInternal(color);
228
185
  };
229
186
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pathscale/ui",
3
- "version": "1.1.32",
3
+ "version": "1.1.33",
4
4
  "author": "pathscale",
5
5
  "repository": {
6
6
  "type": "git",