@unocss/inspector 0.55.7 → 0.56.1
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/client/assets/_id_-b381cd51.js +1 -0
- package/dist/client/assets/index-5d526d08.js +283 -0
- package/dist/client/assets/{repl-2ba4778a.js → repl-3d8664ea.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/index.cjs +7 -211
- package/dist/index.mjs +4 -209
- package/package.json +3 -2
- package/dist/client/assets/_id_-8f7c9f71.js +0 -1
- package/dist/client/assets/index-58944dc9.js +0 -283
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{d as x,r as S,u as b,a as k,b as V,f as B,o as h,c as w,e as s,g as a,w as m,h as C,i as p,v as R,j as e,k as P,n as f,_ as E,l as N,m as U,p as $,q as I}from"./index-
|
|
1
|
+
import{d as x,r as S,u as b,a as k,b as V,f as B,o as h,c as w,e as s,g as a,w as m,h as C,i as p,v as R,j as e,k as P,n as f,_ as E,l as N,m as U,p as $,q as I}from"./index-5d526d08.js";const L={"h-full":"",grid:"~ rows-[max-content_1fr]","of-hidden":""},M=s("div",null," REPL Playground ",-1),T=s("div",{op60:""}," Edit your code below to test and play UnoCSS's matching and generating. ",-1),j={"h-full":"","of-hidden":"",grid:"","grid-cols-2":""},q=x({__name:"ReplPlayground",setup(y){const r=S(null),l=b(r,"repl-scrolls"),t=k("unocss:inspector:repl",`<div class="text-sm hover:text-red">
|
|
2
2
|
Hello World
|
|
3
3
|
</div>`),o=V("unocss-inspector-safelist",!1),{data:d}=B(t,o);return(H,n)=>{var i,_;const v=E,g=N,u=U;return h(),w("div",L,[s("div",{ref_key:"status",ref:r},[a(v,null,{default:m(()=>[M,T]),_:1}),a(g,{border:"b gray-400/20",title:""},{default:m(()=>[s("label",null,[C(s("input",{"onUpdate:modelValue":n[0]||(n[0]=c=>p(o)?o.value=c:null),type:"checkbox"},null,512),[[R,e(o)]]),P(" Include safelist ")])]),_:1})],512),s("div",j,[a(u,{modelValue:e(t),"onUpdate:modelValue":n[1]||(n[1]=c=>p(t)?t.value=c:null),mode:"html",matched:((i=e(d))==null?void 0:i.matched)||[],class:"scrolls repl-scrolls",style:f(e(l))},null,8,["modelValue","matched","style"]),a(u,{border:"l main","model-value":((_=e(d))==null?void 0:_.css)||"/* empty */","read-only":!0,mode:"css",class:"scrolls repl-scrolls",style:f(e(l))},null,8,["model-value","style"])])])}}}),z={};function D(y,r){const l=q;return h(),I(l)}const A=$(z,[["render",D]]);export{A as default};
|
package/dist/client/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
9
9
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
10
10
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;400&family=Fira+Code&display=swap" rel="stylesheet" />
|
|
11
|
-
<script type="module" crossorigin src="/__unocss/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/__unocss/assets/index-5d526d08.js"></script>
|
|
12
12
|
<link rel="stylesheet" href="/__unocss/assets/index-b22884c3.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,9 @@ const node_url = require('node:url');
|
|
|
5
5
|
const sirv = require('sirv');
|
|
6
6
|
const core = require('@unocss/core');
|
|
7
7
|
const gzipSize = require('gzip-size');
|
|
8
|
+
const ruleUtils = require('@unocss/rule-utils');
|
|
8
9
|
|
|
10
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
9
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
10
12
|
|
|
11
13
|
const sirv__default = /*#__PURE__*/_interopDefaultCompat(sirv);
|
|
@@ -304,7 +306,7 @@ const valueHandlers = {
|
|
|
304
306
|
time: time
|
|
305
307
|
};
|
|
306
308
|
|
|
307
|
-
const handler =
|
|
309
|
+
const handler = ruleUtils.createValueHandler(valueHandlers);
|
|
308
310
|
const h = handler;
|
|
309
311
|
|
|
310
312
|
function getThemeColor(theme, colors) {
|
|
@@ -335,7 +337,7 @@ function splitShorthand(body, type) {
|
|
|
335
337
|
}
|
|
336
338
|
return split;
|
|
337
339
|
}
|
|
338
|
-
function parseColor
|
|
340
|
+
function parseColor(body, theme) {
|
|
339
341
|
const [main, opacity] = splitShorthand(body, "color");
|
|
340
342
|
const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
341
343
|
const [name] = colors;
|
|
@@ -386,216 +388,10 @@ function parseColor$1(body, theme) {
|
|
|
386
388
|
name,
|
|
387
389
|
no,
|
|
388
390
|
color,
|
|
389
|
-
cssColor: parseCssColor(color),
|
|
391
|
+
cssColor: ruleUtils.parseCssColor(color),
|
|
390
392
|
alpha: h.bracket.cssvar.percent(opacity ?? "")
|
|
391
393
|
};
|
|
392
394
|
}
|
|
393
|
-
function getComponent(str, open, close, separators) {
|
|
394
|
-
if (str === "")
|
|
395
|
-
return;
|
|
396
|
-
if (core.isString(separators))
|
|
397
|
-
separators = [separators];
|
|
398
|
-
if (separators.length === 0)
|
|
399
|
-
return;
|
|
400
|
-
const l = str.length;
|
|
401
|
-
let parenthesis = 0;
|
|
402
|
-
for (let i = 0; i < l; i++) {
|
|
403
|
-
switch (str[i]) {
|
|
404
|
-
case open:
|
|
405
|
-
parenthesis++;
|
|
406
|
-
break;
|
|
407
|
-
case close:
|
|
408
|
-
if (--parenthesis < 0)
|
|
409
|
-
return;
|
|
410
|
-
break;
|
|
411
|
-
default:
|
|
412
|
-
for (const separator of separators) {
|
|
413
|
-
const separatorLength = separator.length;
|
|
414
|
-
if (separatorLength && separator === str.slice(i, i + separatorLength) && parenthesis === 0) {
|
|
415
|
-
if (i === 0 || i === l - separatorLength)
|
|
416
|
-
return;
|
|
417
|
-
return [
|
|
418
|
-
str.slice(0, i),
|
|
419
|
-
str.slice(i + separatorLength)
|
|
420
|
-
];
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
return [
|
|
426
|
-
str,
|
|
427
|
-
""
|
|
428
|
-
];
|
|
429
|
-
}
|
|
430
|
-
function getComponents(str, separators, limit) {
|
|
431
|
-
limit = limit ?? 10;
|
|
432
|
-
const components = [];
|
|
433
|
-
let i = 0;
|
|
434
|
-
while (str !== "") {
|
|
435
|
-
if (++i > limit)
|
|
436
|
-
return;
|
|
437
|
-
const componentPair = getComponent(str, "(", ")", separators);
|
|
438
|
-
if (!componentPair)
|
|
439
|
-
return;
|
|
440
|
-
const [component, rest] = componentPair;
|
|
441
|
-
components.push(component);
|
|
442
|
-
str = rest;
|
|
443
|
-
}
|
|
444
|
-
if (components.length > 0)
|
|
445
|
-
return components;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
449
|
-
const alphaPlaceholders = ["%alpha", "<alpha-value>"];
|
|
450
|
-
new RegExp(alphaPlaceholders.map((v) => core.escapeRegExp(v)).join("|"));
|
|
451
|
-
function parseCssColor(str = "") {
|
|
452
|
-
const color = parseColor(str);
|
|
453
|
-
if (color == null || color === false)
|
|
454
|
-
return;
|
|
455
|
-
const { type: casedType, components, alpha } = color;
|
|
456
|
-
const type = casedType.toLowerCase();
|
|
457
|
-
if (components.length === 0)
|
|
458
|
-
return;
|
|
459
|
-
if (["rgba", "hsla"].includes(type) && alpha == null)
|
|
460
|
-
return;
|
|
461
|
-
if (cssColorFunctions.includes(type) && ![1, 3].includes(components.length))
|
|
462
|
-
return;
|
|
463
|
-
return {
|
|
464
|
-
type,
|
|
465
|
-
components: components.map((c) => typeof c === "string" ? c.trim() : c),
|
|
466
|
-
alpha: typeof alpha === "string" ? alpha.trim() : alpha
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
function parseColor(str) {
|
|
470
|
-
if (!str)
|
|
471
|
-
return;
|
|
472
|
-
let color = parseHexColor(str);
|
|
473
|
-
if (color != null)
|
|
474
|
-
return color;
|
|
475
|
-
color = cssColorKeyword(str);
|
|
476
|
-
if (color != null)
|
|
477
|
-
return color;
|
|
478
|
-
color = parseCssCommaColorFunction(str);
|
|
479
|
-
if (color != null)
|
|
480
|
-
return color;
|
|
481
|
-
color = parseCssSpaceColorFunction(str);
|
|
482
|
-
if (color != null)
|
|
483
|
-
return color;
|
|
484
|
-
color = parseCssColorFunction(str);
|
|
485
|
-
if (color != null)
|
|
486
|
-
return color;
|
|
487
|
-
}
|
|
488
|
-
function parseHexColor(str) {
|
|
489
|
-
const [, body] = str.match(/^#([\da-f]+)$/i) || [];
|
|
490
|
-
if (!body)
|
|
491
|
-
return;
|
|
492
|
-
switch (body.length) {
|
|
493
|
-
case 3:
|
|
494
|
-
case 4:
|
|
495
|
-
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
496
|
-
return {
|
|
497
|
-
type: "rgb",
|
|
498
|
-
components: digits.slice(0, 3),
|
|
499
|
-
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
500
|
-
};
|
|
501
|
-
case 6:
|
|
502
|
-
case 8:
|
|
503
|
-
const value = Number.parseInt(body, 16);
|
|
504
|
-
return {
|
|
505
|
-
type: "rgb",
|
|
506
|
-
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
507
|
-
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
function cssColorKeyword(str) {
|
|
512
|
-
const color = {
|
|
513
|
-
rebeccapurple: [102, 51, 153, 1]
|
|
514
|
-
}[str];
|
|
515
|
-
if (color != null) {
|
|
516
|
-
return {
|
|
517
|
-
type: "rgb",
|
|
518
|
-
components: color.slice(0, 3),
|
|
519
|
-
alpha: color[3]
|
|
520
|
-
};
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
function parseCssCommaColorFunction(color) {
|
|
524
|
-
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
525
|
-
if (!match)
|
|
526
|
-
return;
|
|
527
|
-
const [, type, componentString] = match;
|
|
528
|
-
const components = getComponents(componentString, ",", 5);
|
|
529
|
-
if (components) {
|
|
530
|
-
if ([3, 4].includes(components.length)) {
|
|
531
|
-
return {
|
|
532
|
-
type,
|
|
533
|
-
components: components.slice(0, 3),
|
|
534
|
-
alpha: components[3]
|
|
535
|
-
};
|
|
536
|
-
} else if (components.length !== 1) {
|
|
537
|
-
return false;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
const cssColorFunctionsRe = new RegExp(`^(${cssColorFunctions.join("|")})\\((.+)\\)$`, "i");
|
|
542
|
-
function parseCssSpaceColorFunction(color) {
|
|
543
|
-
const match = color.match(cssColorFunctionsRe);
|
|
544
|
-
if (!match)
|
|
545
|
-
return;
|
|
546
|
-
const [, fn, componentString] = match;
|
|
547
|
-
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
548
|
-
if (parsed) {
|
|
549
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
550
|
-
return {
|
|
551
|
-
type,
|
|
552
|
-
components,
|
|
553
|
-
alpha
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
function parseCssColorFunction(color) {
|
|
558
|
-
const match = color.match(/^color\((.+)\)$/);
|
|
559
|
-
if (!match)
|
|
560
|
-
return;
|
|
561
|
-
const parsed = parseCssSpaceColorValues(match[1]);
|
|
562
|
-
if (parsed) {
|
|
563
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
564
|
-
return {
|
|
565
|
-
type,
|
|
566
|
-
components,
|
|
567
|
-
alpha
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
function parseCssSpaceColorValues(componentString) {
|
|
572
|
-
const components = getComponents(componentString, " ");
|
|
573
|
-
if (!components)
|
|
574
|
-
return;
|
|
575
|
-
let totalComponents = components.length;
|
|
576
|
-
if (components[totalComponents - 2] === "/") {
|
|
577
|
-
return {
|
|
578
|
-
components: components.slice(0, totalComponents - 2),
|
|
579
|
-
alpha: components[totalComponents - 1]
|
|
580
|
-
};
|
|
581
|
-
}
|
|
582
|
-
if (components[totalComponents - 2] != null && (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/"))) {
|
|
583
|
-
const removed = components.splice(totalComponents - 2);
|
|
584
|
-
components.push(removed.join(" "));
|
|
585
|
-
--totalComponents;
|
|
586
|
-
}
|
|
587
|
-
const withAlpha = getComponents(components[totalComponents - 1], "/", 2);
|
|
588
|
-
if (!withAlpha)
|
|
589
|
-
return;
|
|
590
|
-
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
591
|
-
return { components };
|
|
592
|
-
const alpha = withAlpha.pop();
|
|
593
|
-
components[totalComponents - 1] = withAlpha.join("/");
|
|
594
|
-
return {
|
|
595
|
-
components,
|
|
596
|
-
alpha
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
395
|
|
|
600
396
|
const staticUtilities = {
|
|
601
397
|
"box-border": "boxSizing",
|
|
@@ -940,7 +736,7 @@ async function analyzer(modules, ctx) {
|
|
|
940
736
|
if (baseSelector) {
|
|
941
737
|
const category = layer !== "default" ? layer : getSelectorCategory(baseSelector);
|
|
942
738
|
const body = baseSelector.replace(/^ring-offset|outline-solid|outline-dotted/, "head").replace(/^\w+-/, "");
|
|
943
|
-
const parsedColor = parseColor
|
|
739
|
+
const parsedColor = parseColor(body, ctx.uno.config.theme);
|
|
944
740
|
if (parsedColor?.color && !ignoredColors.includes(parsedColor?.color)) {
|
|
945
741
|
const existing = colors.find((c) => c.name === parsedColor.name && c.no === parsedColor.no);
|
|
946
742
|
if (existing) {
|
|
@@ -984,7 +780,7 @@ async function analyzer(modules, ctx) {
|
|
|
984
780
|
};
|
|
985
781
|
}
|
|
986
782
|
|
|
987
|
-
const _dirname = typeof __dirname !== "undefined" ? __dirname : node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
783
|
+
const _dirname = typeof __dirname !== "undefined" ? __dirname : node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
|
|
988
784
|
function UnocssInspector(ctx) {
|
|
989
785
|
async function configureServer(server) {
|
|
990
786
|
await ctx.ready;
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { dirname, resolve } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import sirv from 'sirv';
|
|
4
|
-
import { escapeSelector,
|
|
4
|
+
import { escapeSelector, CountableSet, BetterMap } from '@unocss/core';
|
|
5
5
|
import gzipSize from 'gzip-size';
|
|
6
|
+
import { createValueHandler, parseCssColor } from '@unocss/rule-utils';
|
|
6
7
|
|
|
7
8
|
const SKIP_START_COMMENT = "@unocss-skip-start";
|
|
8
9
|
const SKIP_END_COMMENT = "@unocss-skip-end";
|
|
@@ -328,7 +329,7 @@ function splitShorthand(body, type) {
|
|
|
328
329
|
}
|
|
329
330
|
return split;
|
|
330
331
|
}
|
|
331
|
-
function parseColor
|
|
332
|
+
function parseColor(body, theme) {
|
|
332
333
|
const [main, opacity] = splitShorthand(body, "color");
|
|
333
334
|
const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
334
335
|
const [name] = colors;
|
|
@@ -383,212 +384,6 @@ function parseColor$1(body, theme) {
|
|
|
383
384
|
alpha: h.bracket.cssvar.percent(opacity ?? "")
|
|
384
385
|
};
|
|
385
386
|
}
|
|
386
|
-
function getComponent(str, open, close, separators) {
|
|
387
|
-
if (str === "")
|
|
388
|
-
return;
|
|
389
|
-
if (isString(separators))
|
|
390
|
-
separators = [separators];
|
|
391
|
-
if (separators.length === 0)
|
|
392
|
-
return;
|
|
393
|
-
const l = str.length;
|
|
394
|
-
let parenthesis = 0;
|
|
395
|
-
for (let i = 0; i < l; i++) {
|
|
396
|
-
switch (str[i]) {
|
|
397
|
-
case open:
|
|
398
|
-
parenthesis++;
|
|
399
|
-
break;
|
|
400
|
-
case close:
|
|
401
|
-
if (--parenthesis < 0)
|
|
402
|
-
return;
|
|
403
|
-
break;
|
|
404
|
-
default:
|
|
405
|
-
for (const separator of separators) {
|
|
406
|
-
const separatorLength = separator.length;
|
|
407
|
-
if (separatorLength && separator === str.slice(i, i + separatorLength) && parenthesis === 0) {
|
|
408
|
-
if (i === 0 || i === l - separatorLength)
|
|
409
|
-
return;
|
|
410
|
-
return [
|
|
411
|
-
str.slice(0, i),
|
|
412
|
-
str.slice(i + separatorLength)
|
|
413
|
-
];
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
return [
|
|
419
|
-
str,
|
|
420
|
-
""
|
|
421
|
-
];
|
|
422
|
-
}
|
|
423
|
-
function getComponents(str, separators, limit) {
|
|
424
|
-
limit = limit ?? 10;
|
|
425
|
-
const components = [];
|
|
426
|
-
let i = 0;
|
|
427
|
-
while (str !== "") {
|
|
428
|
-
if (++i > limit)
|
|
429
|
-
return;
|
|
430
|
-
const componentPair = getComponent(str, "(", ")", separators);
|
|
431
|
-
if (!componentPair)
|
|
432
|
-
return;
|
|
433
|
-
const [component, rest] = componentPair;
|
|
434
|
-
components.push(component);
|
|
435
|
-
str = rest;
|
|
436
|
-
}
|
|
437
|
-
if (components.length > 0)
|
|
438
|
-
return components;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
442
|
-
const alphaPlaceholders = ["%alpha", "<alpha-value>"];
|
|
443
|
-
new RegExp(alphaPlaceholders.map((v) => escapeRegExp(v)).join("|"));
|
|
444
|
-
function parseCssColor(str = "") {
|
|
445
|
-
const color = parseColor(str);
|
|
446
|
-
if (color == null || color === false)
|
|
447
|
-
return;
|
|
448
|
-
const { type: casedType, components, alpha } = color;
|
|
449
|
-
const type = casedType.toLowerCase();
|
|
450
|
-
if (components.length === 0)
|
|
451
|
-
return;
|
|
452
|
-
if (["rgba", "hsla"].includes(type) && alpha == null)
|
|
453
|
-
return;
|
|
454
|
-
if (cssColorFunctions.includes(type) && ![1, 3].includes(components.length))
|
|
455
|
-
return;
|
|
456
|
-
return {
|
|
457
|
-
type,
|
|
458
|
-
components: components.map((c) => typeof c === "string" ? c.trim() : c),
|
|
459
|
-
alpha: typeof alpha === "string" ? alpha.trim() : alpha
|
|
460
|
-
};
|
|
461
|
-
}
|
|
462
|
-
function parseColor(str) {
|
|
463
|
-
if (!str)
|
|
464
|
-
return;
|
|
465
|
-
let color = parseHexColor(str);
|
|
466
|
-
if (color != null)
|
|
467
|
-
return color;
|
|
468
|
-
color = cssColorKeyword(str);
|
|
469
|
-
if (color != null)
|
|
470
|
-
return color;
|
|
471
|
-
color = parseCssCommaColorFunction(str);
|
|
472
|
-
if (color != null)
|
|
473
|
-
return color;
|
|
474
|
-
color = parseCssSpaceColorFunction(str);
|
|
475
|
-
if (color != null)
|
|
476
|
-
return color;
|
|
477
|
-
color = parseCssColorFunction(str);
|
|
478
|
-
if (color != null)
|
|
479
|
-
return color;
|
|
480
|
-
}
|
|
481
|
-
function parseHexColor(str) {
|
|
482
|
-
const [, body] = str.match(/^#([\da-f]+)$/i) || [];
|
|
483
|
-
if (!body)
|
|
484
|
-
return;
|
|
485
|
-
switch (body.length) {
|
|
486
|
-
case 3:
|
|
487
|
-
case 4:
|
|
488
|
-
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
489
|
-
return {
|
|
490
|
-
type: "rgb",
|
|
491
|
-
components: digits.slice(0, 3),
|
|
492
|
-
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
493
|
-
};
|
|
494
|
-
case 6:
|
|
495
|
-
case 8:
|
|
496
|
-
const value = Number.parseInt(body, 16);
|
|
497
|
-
return {
|
|
498
|
-
type: "rgb",
|
|
499
|
-
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
500
|
-
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
function cssColorKeyword(str) {
|
|
505
|
-
const color = {
|
|
506
|
-
rebeccapurple: [102, 51, 153, 1]
|
|
507
|
-
}[str];
|
|
508
|
-
if (color != null) {
|
|
509
|
-
return {
|
|
510
|
-
type: "rgb",
|
|
511
|
-
components: color.slice(0, 3),
|
|
512
|
-
alpha: color[3]
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
function parseCssCommaColorFunction(color) {
|
|
517
|
-
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
518
|
-
if (!match)
|
|
519
|
-
return;
|
|
520
|
-
const [, type, componentString] = match;
|
|
521
|
-
const components = getComponents(componentString, ",", 5);
|
|
522
|
-
if (components) {
|
|
523
|
-
if ([3, 4].includes(components.length)) {
|
|
524
|
-
return {
|
|
525
|
-
type,
|
|
526
|
-
components: components.slice(0, 3),
|
|
527
|
-
alpha: components[3]
|
|
528
|
-
};
|
|
529
|
-
} else if (components.length !== 1) {
|
|
530
|
-
return false;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
const cssColorFunctionsRe = new RegExp(`^(${cssColorFunctions.join("|")})\\((.+)\\)$`, "i");
|
|
535
|
-
function parseCssSpaceColorFunction(color) {
|
|
536
|
-
const match = color.match(cssColorFunctionsRe);
|
|
537
|
-
if (!match)
|
|
538
|
-
return;
|
|
539
|
-
const [, fn, componentString] = match;
|
|
540
|
-
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
541
|
-
if (parsed) {
|
|
542
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
543
|
-
return {
|
|
544
|
-
type,
|
|
545
|
-
components,
|
|
546
|
-
alpha
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
function parseCssColorFunction(color) {
|
|
551
|
-
const match = color.match(/^color\((.+)\)$/);
|
|
552
|
-
if (!match)
|
|
553
|
-
return;
|
|
554
|
-
const parsed = parseCssSpaceColorValues(match[1]);
|
|
555
|
-
if (parsed) {
|
|
556
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
557
|
-
return {
|
|
558
|
-
type,
|
|
559
|
-
components,
|
|
560
|
-
alpha
|
|
561
|
-
};
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function parseCssSpaceColorValues(componentString) {
|
|
565
|
-
const components = getComponents(componentString, " ");
|
|
566
|
-
if (!components)
|
|
567
|
-
return;
|
|
568
|
-
let totalComponents = components.length;
|
|
569
|
-
if (components[totalComponents - 2] === "/") {
|
|
570
|
-
return {
|
|
571
|
-
components: components.slice(0, totalComponents - 2),
|
|
572
|
-
alpha: components[totalComponents - 1]
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
if (components[totalComponents - 2] != null && (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/"))) {
|
|
576
|
-
const removed = components.splice(totalComponents - 2);
|
|
577
|
-
components.push(removed.join(" "));
|
|
578
|
-
--totalComponents;
|
|
579
|
-
}
|
|
580
|
-
const withAlpha = getComponents(components[totalComponents - 1], "/", 2);
|
|
581
|
-
if (!withAlpha)
|
|
582
|
-
return;
|
|
583
|
-
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
584
|
-
return { components };
|
|
585
|
-
const alpha = withAlpha.pop();
|
|
586
|
-
components[totalComponents - 1] = withAlpha.join("/");
|
|
587
|
-
return {
|
|
588
|
-
components,
|
|
589
|
-
alpha
|
|
590
|
-
};
|
|
591
|
-
}
|
|
592
387
|
|
|
593
388
|
const staticUtilities = {
|
|
594
389
|
"box-border": "boxSizing",
|
|
@@ -933,7 +728,7 @@ async function analyzer(modules, ctx) {
|
|
|
933
728
|
if (baseSelector) {
|
|
934
729
|
const category = layer !== "default" ? layer : getSelectorCategory(baseSelector);
|
|
935
730
|
const body = baseSelector.replace(/^ring-offset|outline-solid|outline-dotted/, "head").replace(/^\w+-/, "");
|
|
936
|
-
const parsedColor = parseColor
|
|
731
|
+
const parsedColor = parseColor(body, ctx.uno.config.theme);
|
|
937
732
|
if (parsedColor?.color && !ignoredColors.includes(parsedColor?.color)) {
|
|
938
733
|
const existing = colors.find((c) => c.name === parsedColor.name && c.no === parsedColor.no);
|
|
939
734
|
if (existing) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/inspector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.1",
|
|
4
4
|
"description": "The inspector UI for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"gzip-size": "^6.0.0",
|
|
38
|
-
"sirv": "^2.0.3"
|
|
38
|
+
"sirv": "^2.0.3",
|
|
39
|
+
"@unocss/rule-utils": "0.56.1"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "unbuild",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as U,t as N,d as W,x as Z,y as q,r as R,u as G,z as H,A as K,B as J,j as s,c as P,g as A,w as k,q as I,C as z,_ as L,D as Q,o as S,e as f,k as w,E as C,i as M,F as B,n as F,h as X,v as Y,M as ee,G as te,H as le,m as re,l as se,I as ae}from"./index-58944dc9.js";const j=/^(?!.*\[(?:[^:]+):(?:.+)\]$)((?:.+:)?!?)?(.*)$/;function ne(e={}){const m=e.prefix??"un-",l=e.prefixedOnly??!1,v=e.trueToNonValued??!1;let c;return{name:"attributify",match(a,{generator:b}){var h,n;const o=U(a);if(!o)return;let t=o[1];if(t.startsWith(m))t=t.slice(m.length);else if(l)return;const i=o[2],[,_="",x=i]=i.match(j)||[];if(x==="~"||v&&x==="true"||!x)return`${_}${t}`;if(c==null){const r=(n=(h=b==null?void 0:b.config)==null?void 0:h.separators)==null?void 0:n.join("|");r?c=new RegExp(`^(.*\\](?:${r}))(\\[[^\\]]+?\\])$`):c=!1}if(c){const[,r,u]=i.match(c)||[];if(u)return`${r}${_}${t}-${u}`}return`${_}${t}-${x}`}}}const ce=/(<\w[\w:\.$-]*\s)((?:'[^>]*?'|"[^>]*?"|`[^>]*?`|\{[^>]*?\}|[^>]*?)*)/g,oe=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-]+)(?:=("[^"]*|'[^']*))?/g,O=/[\s'"`;>]+/;function ie(e){return{name:"attributify",extract:({content:m,cursor:l})=>{const v=m.matchAll(ce);let c,a=0;for(const d of v){const[,y,g]=d,$=d.index+y.length;if(l>$&&l<=$+g.length){a=$,c=g;break}}if(!c)return null;const b=c.matchAll(oe);let o=0,t,i;for(const d of b){const[y,g,$]=d,E=a+d.index;if(l>E&&l<=E+y.length){o=E,t=g,i=$==null?void 0:$.slice(1);break}}if(!t||t==="class"||t==="className"||t===":class")return null;const _=!!(e!=null&&e.prefix)&&t.startsWith(e.prefix);if(e!=null&&e.prefixedOnly&&!_)return null;const x=_?t.slice(e.prefix.length):t;if(i===void 0)return{extracted:x,resolveReplacement(d){const y=_?e.prefix.length:0;return{start:o+y,end:o+t.length,replacement:d}}};const h=o+t.length+2;let n=O.exec(i),r=0,u;for(;n;){const[d]=n;if(l>h+r&&l<=h+r+n.index){u=i.slice(r,r+n.index);break}r+=n.index+d.length,n=O.exec(i.slice(r))}u===void 0&&(u=i.slice(r));const[,p="",V]=u.match(j)||[];return{extracted:`${p}${x}-${V}`,transformSuggestions(d){return d.filter(y=>y.startsWith(`${p}${x}-`)).map(y=>p+y.slice(p.length+x.length+1))},resolveReplacement(d){return{start:r+h,end:r+h+u.length,replacement:p+d.slice(p.length+x.length+1)}}}}}}const ue=["v-bind:",":"],T=/[\s'"`;]+/g,de=/<[^>\s]*\s((?:'.*?'|".*?"|`.*?`|\{.*?\}|[^>]*?)*)/g,fe=/([?]|(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:!%-.~<]+)=?(?:["]([^"]*)["]|[']([^']*)[']|[{]([^}]*)[}])?/gms,D=["placeholder","fill","opacity","stroke-opacity"];function me(e){const m=(e==null?void 0:e.ignoreAttributes)??D,l=(e==null?void 0:e.nonValuedAttribute)??!0,v=(e==null?void 0:e.trueToNonValued)??!1;return{name:"@unocss/preset-attributify/extractor",extract({code:c}){return Array.from(c.matchAll(de)).flatMap(a=>Array.from((a[1]||"").matchAll(fe))).flatMap(([,a,...b])=>{const o=b.filter(Boolean).join("");if(m.includes(a))return[];for(const t of ue)if(a.startsWith(t)){a=a.slice(t.length);break}if(!o){if(N(a)&&l!==!1){const t=[`[${a}=""]`];return v&&t.push(`[${a}="true"]`),t}return[]}return["class","className"].includes(a)?o.split(T).filter(N):e!=null&&e.prefixedOnly&&e.prefix&&!a.startsWith(e.prefix)?[]:o.split(T).filter(t=>!!t&&t!==":").map(t=>`[${a}~="${t}"]`)})}}}function he(e={}){e.strict=e.strict??!1,e.prefix=e.prefix??"un-",e.prefixedOnly=e.prefixedOnly??!1,e.nonValuedAttribute=e.nonValuedAttribute??!0,e.ignoreAttributes=e.ignoreAttributes??D;const m=[ne(e)],l=[me(e)],v=[ie(e)];return{name:"@unocss/preset-attributify",enforce:"post",variants:m,extractors:l,options:e,autocomplete:{extractors:v},extractorDefault:e.strict?!1:void 0}}const _e={key:0,"h-full":"","of-hidden":"",flex:"","flex-col":""},xe={p:"4",grid:"~ cols-4 gap-4"},pe=f("div",{op50:""}," Module ",-1),ye=f("div",{"i-carbon-launch":""},null,-1),ve=f("div",{op50:""}," Matched Rules ",-1),be=f("div",{op50:""}," CSS Size ",-1),ge=f("span",{op50:""},"gzipped",-1),$e={key:0,"row-span-3":""},Ae=f("div",{op50:""}," Potentially Unmatched ",-1),Ve={key:0,"h-full":"","of-hidden":""},ke=W({__name:"ModuleInfo",props:{id:{}},setup(e){const m=e,{data:l}=Z(q(m,"id")),v=m.id.split(/\./g).pop(),c=R(null),a=G(c,"module-scrolls");function b(){fetch(`/__open-in-editor?file=${encodeURIComponent(m.id)}`)}const{extractors:o}=he({strict:!0}),t=H(async()=>{var n;const h=new Set;if(o){const r={code:((n=l.value)==null?void 0:n.code)||""};for(const u of o){const p=await u.extract(r);p==null||p.forEach(V=>h.add(V))}}return Array.from(h).filter(r=>!r.startsWith("[")).filter(r=>{var u;return!((u=l.value)!=null&&u.matched.includes(r))})}),i=R(!1),_=R("source"),x=K(J(()=>{var h;return(h=l.value)==null?void 0:h.css}),i);return(h,n)=>{const r=te,u=le,p=L,V=re,d=se,y=Q;return s(l)?(S(),P("div",_e,[A(p,{ref_key:"status",ref:c,p0:""},{default:k(()=>{var g;return[f("div",xe,[f("div",null,[pe,f("a",{"cursor-pointer":"",op80:"","hover:op100":"",onClick:b},[A(r,{id:s(l).id,"mr-1":""},null,8,["id"]),ye])]),f("div",null,[ve,w(" "+C(s(l).matched.length),1)]),f("div",null,[be,w(" "+C(((((g=s(l))==null?void 0:g.gzipSize)||0)/1024).toFixed(2))+" KiB ",1),ge]),s(t).length?(S(),P("div",$e,[Ae,f("code",null,C(s(t).join(", ")),1)])):z("",!0)]),A(u,{modelValue:s(_),"onUpdate:modelValue":n[0]||(n[0]=$=>M(_)?_.value=$:null)},null,8,["modelValue"])]}),_:1},512),s(_)==="source"?(S(),P("div",Ve,[A(s(ee),null,{default:k(()=>[A(s(B),{size:"50"},{default:k(()=>[A(V,{"h-full":"","model-value":s(l).code,"read-only":!0,mode:s(v),matched:s(l).matched,class:"scrolls module-scrolls",style:F(s(a))},null,8,["model-value","mode","matched","style"])]),_:1}),A(s(B),{size:"50"},{default:k(()=>[f("div",null,[A(d,{border:"l b gray-400/20",title:"Output CSS"},{default:k(()=>[f("label",null,[X(f("input",{"onUpdate:modelValue":n[1]||(n[1]=g=>M(i)?i.value=g:null),type:"checkbox"},null,512),[[Y,s(i)]]),w(" Prettify ")])]),_:1}),A(V,{"h-full":"",border:"l main","model-value":s(x),"read-only":!0,mode:"css",class:"scrolls module-scrolls",style:F(s(a))},null,8,["model-value","style"])])]),_:1})]),_:1})])):(S(),I(y,{key:1,"flex-grow":"","overflow-y-auto":"",selectors:s(l).matched,colors:s(l).colors},null,8,["selectors","colors"]))])):z("",!0)}}}),Ee=W({__name:"[id]",setup(e){const m=ae();return(l,v)=>{const c=ke;return S(),I(c,{id:s(m).params.id},null,8,["id"])}}});export{Ee as default};
|