@unocss/inspector 0.57.5 → 0.57.6

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/dist/index.cjs CHANGED
@@ -306,8 +306,8 @@ const valueHandlers = {
306
306
  const handler = ruleUtils.createValueHandler(valueHandlers);
307
307
  const h = handler;
308
308
 
309
- function getThemeColor(theme, colors) {
310
- let obj = theme.colors;
309
+ function getThemeColorForKey(theme, colors, key = "colors") {
310
+ let obj = theme[key];
311
311
  let index = -1;
312
312
  for (const c of colors) {
313
313
  index += 1;
@@ -324,6 +324,9 @@ function getThemeColor(theme, colors) {
324
324
  }
325
325
  return obj;
326
326
  }
327
+ function getThemeColor(theme, colors, key) {
328
+ return getThemeColorForKey(theme, colors, key) || getThemeColorForKey(theme, colors, "colors");
329
+ }
327
330
  function splitShorthand(body, type) {
328
331
  const split = body.split(/(?:\/|:)/);
329
332
  if (split[0] === `[${type}`) {
@@ -334,7 +337,7 @@ function splitShorthand(body, type) {
334
337
  }
335
338
  return split;
336
339
  }
337
- function parseColor(body, theme) {
340
+ function parseColor(body, theme, key) {
338
341
  const [main, opacity] = splitShorthand(body, "color");
339
342
  const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
340
343
  const [name] = colors;
@@ -353,7 +356,7 @@ function parseColor(body, theme) {
353
356
  color = h.cssvar(main);
354
357
  color = color || bracket;
355
358
  if (!color) {
356
- const colorData = getThemeColor(theme, [main]);
359
+ const colorData = getThemeColor(theme, [main], key);
357
360
  if (typeof colorData === "string")
358
361
  color = colorData;
359
362
  }
@@ -363,16 +366,16 @@ function parseColor(body, theme) {
363
366
  const [scale] = colors.slice(-1);
364
367
  if (scale.match(/^\d+$/)) {
365
368
  no = scale;
366
- colorData = getThemeColor(theme, colors.slice(0, -1));
369
+ colorData = getThemeColor(theme, colors.slice(0, -1), key);
367
370
  if (!colorData || typeof colorData === "string")
368
371
  color = void 0;
369
372
  else
370
373
  color = colorData[no];
371
374
  } else {
372
- colorData = getThemeColor(theme, colors);
375
+ colorData = getThemeColor(theme, colors, key);
373
376
  if (!colorData && colors.length <= 2) {
374
377
  [, no = no] = colors;
375
- colorData = getThemeColor(theme, [name]);
378
+ colorData = getThemeColor(theme, [name], key);
376
379
  }
377
380
  if (typeof colorData === "string")
378
381
  color = colorData;
@@ -735,7 +738,7 @@ async function analyzer(modules, ctx) {
735
738
  if (baseSelector) {
736
739
  const category = layer !== "default" ? layer : getSelectorCategory(baseSelector);
737
740
  const body = baseSelector.replace(/^ring-offset|outline-solid|outline-dotted/, "head").replace(/^\w+-/, "");
738
- const parsedColor = parseColor(body, ctx.uno.config.theme);
741
+ const parsedColor = parseColor(body, ctx.uno.config.theme, "colors");
739
742
  if (parsedColor?.color && !ignoredColors.includes(parsedColor?.color)) {
740
743
  const existing = colors.find((c) => c.name === parsedColor.name && c.no === parsedColor.no);
741
744
  if (existing) {
package/dist/index.mjs CHANGED
@@ -298,8 +298,8 @@ const valueHandlers = {
298
298
  const handler = createValueHandler(valueHandlers);
299
299
  const h = handler;
300
300
 
301
- function getThemeColor(theme, colors) {
302
- let obj = theme.colors;
301
+ function getThemeColorForKey(theme, colors, key = "colors") {
302
+ let obj = theme[key];
303
303
  let index = -1;
304
304
  for (const c of colors) {
305
305
  index += 1;
@@ -316,6 +316,9 @@ function getThemeColor(theme, colors) {
316
316
  }
317
317
  return obj;
318
318
  }
319
+ function getThemeColor(theme, colors, key) {
320
+ return getThemeColorForKey(theme, colors, key) || getThemeColorForKey(theme, colors, "colors");
321
+ }
319
322
  function splitShorthand(body, type) {
320
323
  const split = body.split(/(?:\/|:)/);
321
324
  if (split[0] === `[${type}`) {
@@ -326,7 +329,7 @@ function splitShorthand(body, type) {
326
329
  }
327
330
  return split;
328
331
  }
329
- function parseColor(body, theme) {
332
+ function parseColor(body, theme, key) {
330
333
  const [main, opacity] = splitShorthand(body, "color");
331
334
  const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
332
335
  const [name] = colors;
@@ -345,7 +348,7 @@ function parseColor(body, theme) {
345
348
  color = h.cssvar(main);
346
349
  color = color || bracket;
347
350
  if (!color) {
348
- const colorData = getThemeColor(theme, [main]);
351
+ const colorData = getThemeColor(theme, [main], key);
349
352
  if (typeof colorData === "string")
350
353
  color = colorData;
351
354
  }
@@ -355,16 +358,16 @@ function parseColor(body, theme) {
355
358
  const [scale] = colors.slice(-1);
356
359
  if (scale.match(/^\d+$/)) {
357
360
  no = scale;
358
- colorData = getThemeColor(theme, colors.slice(0, -1));
361
+ colorData = getThemeColor(theme, colors.slice(0, -1), key);
359
362
  if (!colorData || typeof colorData === "string")
360
363
  color = void 0;
361
364
  else
362
365
  color = colorData[no];
363
366
  } else {
364
- colorData = getThemeColor(theme, colors);
367
+ colorData = getThemeColor(theme, colors, key);
365
368
  if (!colorData && colors.length <= 2) {
366
369
  [, no = no] = colors;
367
- colorData = getThemeColor(theme, [name]);
370
+ colorData = getThemeColor(theme, [name], key);
368
371
  }
369
372
  if (typeof colorData === "string")
370
373
  color = colorData;
@@ -727,7 +730,7 @@ async function analyzer(modules, ctx) {
727
730
  if (baseSelector) {
728
731
  const category = layer !== "default" ? layer : getSelectorCategory(baseSelector);
729
732
  const body = baseSelector.replace(/^ring-offset|outline-solid|outline-dotted/, "head").replace(/^\w+-/, "");
730
- const parsedColor = parseColor(body, ctx.uno.config.theme);
733
+ const parsedColor = parseColor(body, ctx.uno.config.theme, "colors");
731
734
  if (parsedColor?.color && !ignoredColors.includes(parsedColor?.color)) {
732
735
  const existing = colors.find((c) => c.name === parsedColor.name && c.no === parsedColor.no);
733
736
  if (existing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/inspector",
3
- "version": "0.57.5",
3
+ "version": "0.57.6",
4
4
  "description": "The inspector UI for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "gzip-size": "^6.0.0",
38
38
  "sirv": "^2.0.3",
39
- "@unocss/core": "0.57.5",
40
- "@unocss/rule-utils": "0.57.5"
39
+ "@unocss/core": "0.57.6",
40
+ "@unocss/rule-utils": "0.57.6"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "unbuild",