@unocss/inspector 0.58.9 → 0.59.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.
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/inspector",
3
- "version": "0.58.9",
3
+ "type": "module",
4
+ "version": "0.59.0",
4
5
  "description": "The inspector UI for UnoCSS",
5
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
7
  "license": "MIT",
@@ -22,12 +23,11 @@
22
23
  "sideEffects": false,
23
24
  "exports": {
24
25
  ".": {
25
- "types": "./dist/index.d.ts",
26
- "import": "./dist/index.mjs",
27
- "require": "./dist/index.cjs"
26
+ "types": "./dist/index.d.mts",
27
+ "default": "./dist/index.mjs"
28
28
  }
29
29
  },
30
- "main": "./dist/index.cjs",
30
+ "main": "./dist/index.mjs",
31
31
  "module": "./dist/index.mjs",
32
32
  "types": "./dist/index.d.ts",
33
33
  "files": [
@@ -36,8 +36,8 @@
36
36
  "dependencies": {
37
37
  "gzip-size": "^6.0.0",
38
38
  "sirv": "^2.0.4",
39
- "@unocss/core": "0.58.9",
40
- "@unocss/rule-utils": "0.58.9"
39
+ "@unocss/rule-utils": "0.59.0",
40
+ "@unocss/core": "0.59.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "unbuild",
package/dist/index.cjs DELETED
@@ -1,904 +0,0 @@
1
- 'use strict';
2
-
3
- const node_path = require('node:path');
4
- const node_url = require('node:url');
5
- const sirv = require('sirv');
6
- const core = require('@unocss/core');
7
- const gzipSize = require('gzip-size');
8
- const ruleUtils = require('@unocss/rule-utils');
9
-
10
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
-
13
- const sirv__default = /*#__PURE__*/_interopDefaultCompat(sirv);
14
- const gzipSize__default = /*#__PURE__*/_interopDefaultCompat(gzipSize);
15
-
16
- const SKIP_START_COMMENT = "@unocss-skip-start";
17
- const SKIP_END_COMMENT = "@unocss-skip-end";
18
- const SKIP_COMMENT_RE = new RegExp(`(//\\s*?${SKIP_START_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_START_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_START_COMMENT}\\s*?-->)[\\s\\S]*?(//\\s*?${SKIP_END_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_END_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_END_COMMENT}\\s*?-->)`, "g");
19
-
20
- const basePositionMap = [
21
- "top",
22
- "top center",
23
- "top left",
24
- "top right",
25
- "bottom",
26
- "bottom center",
27
- "bottom left",
28
- "bottom right",
29
- "left",
30
- "left center",
31
- "left top",
32
- "left bottom",
33
- "right",
34
- "right center",
35
- "right top",
36
- "right bottom",
37
- "center",
38
- "center top",
39
- "center bottom",
40
- "center left",
41
- "center right",
42
- "center center"
43
- ];
44
- Object.assign(
45
- {},
46
- ...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })),
47
- ...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p }))
48
- );
49
- const globalKeywords = [
50
- "inherit",
51
- "initial",
52
- "revert",
53
- "revert-layer",
54
- "unset"
55
- ];
56
-
57
- const numberWithUnitRE = /^(-?\d*(?:\.\d+)?)(px|pt|pc|%|r?(?:em|ex|lh|cap|ch|ic)|(?:[sld]?v|cq)(?:[whib]|min|max)|in|cm|mm|rpx)?$/i;
58
- const numberRE = /^(-?\d*(?:\.\d+)?)$/i;
59
- const unitOnlyRE = /^(px|[sld]?v[wh])$/i;
60
- const unitOnlyMap = {
61
- px: 1,
62
- vw: 100,
63
- vh: 100,
64
- svw: 100,
65
- svh: 100,
66
- dvw: 100,
67
- dvh: 100,
68
- lvh: 100,
69
- lvw: 100
70
- };
71
- const bracketTypeRe = /^\[(color|length|size|position|quoted|string):/i;
72
-
73
- const cssProps = [
74
- // basic props
75
- "color",
76
- "border-color",
77
- "background-color",
78
- "flex-grow",
79
- "flex",
80
- "flex-shrink",
81
- "caret-color",
82
- "font",
83
- "gap",
84
- "opacity",
85
- "visibility",
86
- "z-index",
87
- "font-weight",
88
- "zoom",
89
- "text-shadow",
90
- "transform",
91
- "box-shadow",
92
- // positions
93
- "background-position",
94
- "left",
95
- "right",
96
- "top",
97
- "bottom",
98
- "object-position",
99
- // sizes
100
- "max-height",
101
- "min-height",
102
- "max-width",
103
- "min-width",
104
- "height",
105
- "width",
106
- "border-width",
107
- "margin",
108
- "padding",
109
- "outline-width",
110
- "outline-offset",
111
- "font-size",
112
- "line-height",
113
- "text-indent",
114
- "vertical-align",
115
- "border-spacing",
116
- "letter-spacing",
117
- "word-spacing",
118
- // enhances
119
- "stroke",
120
- "filter",
121
- "backdrop-filter",
122
- "fill",
123
- "mask",
124
- "mask-size",
125
- "mask-border",
126
- "clip-path",
127
- "clip",
128
- "border-radius"
129
- ];
130
- function round(n) {
131
- return n.toFixed(10).replace(/\.0+$/, "").replace(/(\.\d+?)0+$/, "$1");
132
- }
133
- function numberWithUnit(str) {
134
- const match = str.match(numberWithUnitRE);
135
- if (!match)
136
- return;
137
- const [, n, unit] = match;
138
- const num = Number.parseFloat(n);
139
- if (unit && !Number.isNaN(num))
140
- return `${round(num)}${unit}`;
141
- }
142
- function auto(str) {
143
- if (str === "auto" || str === "a")
144
- return "auto";
145
- }
146
- function rem(str) {
147
- if (!str)
148
- return;
149
- if (unitOnlyRE.test(str))
150
- return `${unitOnlyMap[str]}${str}`;
151
- const match = str.match(numberWithUnitRE);
152
- if (!match)
153
- return;
154
- const [, n, unit] = match;
155
- const num = Number.parseFloat(n);
156
- if (!Number.isNaN(num)) {
157
- if (num === 0)
158
- return "0";
159
- return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
160
- }
161
- }
162
- function px(str) {
163
- if (unitOnlyRE.test(str))
164
- return `${unitOnlyMap[str]}${str}`;
165
- const match = str.match(numberWithUnitRE);
166
- if (!match)
167
- return;
168
- const [, n, unit] = match;
169
- const num = Number.parseFloat(n);
170
- if (!Number.isNaN(num))
171
- return unit ? `${round(num)}${unit}` : `${round(num)}px`;
172
- }
173
- function number(str) {
174
- if (!numberRE.test(str))
175
- return;
176
- const num = Number.parseFloat(str);
177
- if (!Number.isNaN(num))
178
- return round(num);
179
- }
180
- function percent(str) {
181
- if (str.endsWith("%"))
182
- str = str.slice(0, -1);
183
- if (!numberRE.test(str))
184
- return;
185
- const num = Number.parseFloat(str);
186
- if (!Number.isNaN(num))
187
- return `${round(num / 100)}`;
188
- }
189
- function fraction(str) {
190
- if (!str)
191
- return;
192
- if (str === "full")
193
- return "100%";
194
- const [left, right] = str.split("/");
195
- const num = Number.parseFloat(left) / Number.parseFloat(right);
196
- if (!Number.isNaN(num)) {
197
- if (num === 0)
198
- return "0";
199
- return `${round(num * 100)}%`;
200
- }
201
- }
202
- function bracketWithType(str, requiredType) {
203
- if (str && str.startsWith("[") && str.endsWith("]")) {
204
- let base;
205
- let hintedType;
206
- const match = str.match(bracketTypeRe);
207
- if (!match) {
208
- base = str.slice(1, -1);
209
- } else {
210
- if (!requiredType)
211
- hintedType = match[1];
212
- base = str.slice(match[0].length, -1);
213
- }
214
- if (!base)
215
- return;
216
- if (base === '=""')
217
- return;
218
- if (base.startsWith("--"))
219
- base = `var(${base})`;
220
- let curly = 0;
221
- for (const i of base) {
222
- if (i === "[") {
223
- curly += 1;
224
- } else if (i === "]") {
225
- curly -= 1;
226
- if (curly < 0)
227
- return;
228
- }
229
- }
230
- if (curly)
231
- return;
232
- switch (hintedType) {
233
- case "string":
234
- return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_");
235
- case "quoted":
236
- return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(["\\])/g, "\\$1").replace(/^(.+)$/, '"$1"');
237
- }
238
- return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (match2) => {
239
- const vars = [];
240
- return match2.replace(/var\((--.+?)[,)]/g, (match3, g1) => {
241
- vars.push(g1);
242
- return match3.replace(g1, "--un-calc");
243
- }).replace(/(-?\d*\.?\d(?!\b-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(/--un-calc/g, () => vars.shift());
244
- });
245
- }
246
- }
247
- function bracket(str) {
248
- return bracketWithType(str);
249
- }
250
- function bracketOfColor(str) {
251
- return bracketWithType(str, "color");
252
- }
253
- function bracketOfLength(str) {
254
- return bracketWithType(str, "length");
255
- }
256
- function bracketOfPosition(str) {
257
- return bracketWithType(str, "position");
258
- }
259
- function cssvar(str) {
260
- if (/^\$[^\s'"`;{}]/.test(str)) {
261
- const [name, defaultValue] = str.slice(1).split(",");
262
- return `var(--${core.escapeSelector(name)}${defaultValue ? `, ${defaultValue}` : ""})`;
263
- }
264
- }
265
- function time(str) {
266
- const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
267
- if (!match)
268
- return;
269
- const [, n, unit] = match;
270
- const num = Number.parseFloat(n);
271
- if (!Number.isNaN(num)) {
272
- if (num === 0 && !unit)
273
- return "0s";
274
- return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
275
- }
276
- }
277
- function degree(str) {
278
- const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
279
- if (!match)
280
- return;
281
- const [, n, unit] = match;
282
- const num = Number.parseFloat(n);
283
- if (!Number.isNaN(num)) {
284
- if (num === 0)
285
- return "0";
286
- return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
287
- }
288
- }
289
- function global(str) {
290
- if (globalKeywords.includes(str))
291
- return str;
292
- }
293
- function properties(str) {
294
- if (str.split(",").every((prop) => cssProps.includes(prop)))
295
- return str;
296
- }
297
- function position(str) {
298
- if (["top", "left", "right", "bottom", "center"].includes(str))
299
- return str;
300
- }
301
-
302
- const valueHandlers = {
303
- __proto__: null,
304
- auto: auto,
305
- bracket: bracket,
306
- bracketOfColor: bracketOfColor,
307
- bracketOfLength: bracketOfLength,
308
- bracketOfPosition: bracketOfPosition,
309
- cssvar: cssvar,
310
- degree: degree,
311
- fraction: fraction,
312
- global: global,
313
- number: number,
314
- numberWithUnit: numberWithUnit,
315
- percent: percent,
316
- position: position,
317
- properties: properties,
318
- px: px,
319
- rem: rem,
320
- time: time
321
- };
322
-
323
- const handler = ruleUtils.createValueHandler(valueHandlers);
324
- const h = handler;
325
-
326
- function getThemeColorForKey(theme, colors, key = "colors") {
327
- let obj = theme[key];
328
- let index = -1;
329
- for (const c of colors) {
330
- index += 1;
331
- if (obj && typeof obj !== "string") {
332
- const camel = colors.slice(index).join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase());
333
- if (obj[camel])
334
- return obj[camel];
335
- if (obj[c]) {
336
- obj = obj[c];
337
- continue;
338
- }
339
- }
340
- return void 0;
341
- }
342
- return obj;
343
- }
344
- function getThemeColor(theme, colors, key) {
345
- return getThemeColorForKey(theme, colors, key) || getThemeColorForKey(theme, colors, "colors");
346
- }
347
- function splitShorthand(body, type) {
348
- const [front, rest] = ruleUtils.getStringComponent(body, "[", "]", ["/", ":"]) ?? [];
349
- if (front != null) {
350
- const match = (front.match(bracketTypeRe) ?? [])[1];
351
- if (match == null || match === type)
352
- return [front, rest];
353
- }
354
- }
355
- function parseColor(body, theme, key) {
356
- const split = splitShorthand(body, "color");
357
- if (!split)
358
- return;
359
- const [main, opacity] = split;
360
- const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
361
- const [name] = colors;
362
- if (!name)
363
- return;
364
- let color;
365
- const bracket = h.bracketOfColor(main);
366
- const bracketOrMain = bracket || main;
367
- if (h.numberWithUnit(bracketOrMain))
368
- return;
369
- if (/^#[\da-fA-F]+$/.test(bracketOrMain))
370
- color = bracketOrMain;
371
- else if (/^hex-[\da-fA-F]+$/.test(bracketOrMain))
372
- color = `#${bracketOrMain.slice(4)}`;
373
- else if (main.startsWith("$"))
374
- color = h.cssvar(main);
375
- color = color || bracket;
376
- if (!color) {
377
- const colorData = getThemeColor(theme, [main], key);
378
- if (typeof colorData === "string")
379
- color = colorData;
380
- }
381
- let no = "DEFAULT";
382
- if (!color) {
383
- let colorData;
384
- const [scale] = colors.slice(-1);
385
- if (/^\d+$/.test(scale)) {
386
- no = scale;
387
- colorData = getThemeColor(theme, colors.slice(0, -1), key);
388
- if (!colorData || typeof colorData === "string")
389
- color = void 0;
390
- else
391
- color = colorData[no];
392
- } else {
393
- colorData = getThemeColor(theme, colors, key);
394
- if (!colorData && colors.length <= 2) {
395
- [, no = no] = colors;
396
- colorData = getThemeColor(theme, [name], key);
397
- }
398
- if (typeof colorData === "string")
399
- color = colorData;
400
- else if (no && colorData)
401
- color = colorData[no];
402
- }
403
- }
404
- return {
405
- opacity,
406
- name,
407
- no,
408
- color,
409
- cssColor: ruleUtils.parseCssColor(color),
410
- alpha: h.bracket.cssvar.percent(opacity ?? "")
411
- };
412
- }
413
-
414
- const staticUtilities = {
415
- "box-border": "boxSizing",
416
- "box-content": "boxSizing",
417
- "b": "border",
418
- "border": "border",
419
- "rounded": "border",
420
- "block": "display",
421
- "inline-block": "display",
422
- "inline": "display",
423
- "flex": "display",
424
- "inline-flex": "display",
425
- "table": "display",
426
- "table-caption": "display",
427
- "table-cell": "display",
428
- "table-column": "display",
429
- "table-column-group": "display",
430
- "table-footer-group": "display",
431
- "table-header-group": "display",
432
- "table-row-group": "display",
433
- "table-row": "display",
434
- "flow-root": "display",
435
- "grid": "display",
436
- "inline-grid": "display",
437
- "contents": "display",
438
- "hidden": "display",
439
- "float-right": "float",
440
- "float-left": "float",
441
- "float-none": "float",
442
- "clear-left": "clear",
443
- "clear-right": "clear",
444
- "clear-both": "clear",
445
- "clear-none": "clear",
446
- "object-contain": "objectFit",
447
- "object-cover": "objectFit",
448
- "object-fill": "objectFit",
449
- "object-none": "objectFit",
450
- "object-scale-down": "objectFit",
451
- "overflow-auto": "overflow",
452
- "overflow-hidden": "overflow",
453
- "overflow-visible": "overflow",
454
- "overflow-scroll": "overflow",
455
- "overflow-x-auto": "overflow",
456
- "overflow-y-auto": "overflow",
457
- "overflow-x-hidden": "overflow",
458
- "overflow-y-hidden": "overflow",
459
- "overflow-x-visible": "overflow",
460
- "overflow-y-visible": "overflow",
461
- "overflow-x-scroll": "overflow",
462
- "overflow-y-scroll": "overflow",
463
- "of-auto": "overflow",
464
- "of-hidden": "overflow",
465
- "of-visible": "overflow",
466
- "of-scroll": "overflow",
467
- "of-x-auto": "overflow",
468
- "of-y-auto": "overflow",
469
- "of-x-hidden": "overflow",
470
- "of-y-hidden": "overflow",
471
- "of-x-visible": "overflow",
472
- "of-y-visible": "overflow",
473
- "of-x-scroll": "overflow",
474
- "of-y-scroll": "overflow",
475
- "overscroll-auto": "overscrollBehavior",
476
- "overscroll-contain": "overscrollBehavior",
477
- "overscroll-none": "overscrollBehavior",
478
- "overscroll-y-auto": "overscrollBehavior",
479
- "overscroll-y-contain": "overscrollBehavior",
480
- "overscroll-y-none": "overscrollBehavior",
481
- "overscroll-x-auto": "overscrollBehavior",
482
- "overscroll-x-contain": "overscrollBehavior",
483
- "overscroll-x-none": "overscrollBehavior",
484
- "static": "position",
485
- "fixed": "position",
486
- "absolute": "position",
487
- "relative": "position",
488
- "sticky": "position",
489
- "visible": "visibility",
490
- "invisible": "visibility",
491
- "flex-row": "flex",
492
- "flex-row-reverse": "flex",
493
- "flex-col": "flex",
494
- "flex-col-reverse": "flex",
495
- "flex-wrap": "flex",
496
- "flex-wrap-reverse": "flex",
497
- "flex-nowrap": "flex",
498
- "col-auto": "grid",
499
- "row-auto": "grid",
500
- "grid-flow-row": "grid",
501
- "grid-flow-col": "grid",
502
- "grid-flow-row-dense": "grid",
503
- "grid-flow-col-dense": "grid",
504
- "justify-start": "justifyContent",
505
- "justify-end": "justifyContent",
506
- "justify-center": "justifyContent",
507
- "justify-between": "justifyContent",
508
- "justify-around": "justifyContent",
509
- "justify-evenly": "justifyContent",
510
- "justify-left": "justifyContent",
511
- "justify-right": "justifyContent",
512
- "justify-items-auto": "justifyItems",
513
- "justify-items-start": "justifyItems",
514
- "justify-items-end": "justifyItems",
515
- "justify-items-center": "justifyItems",
516
- "justify-items-stretch": "justifyItems",
517
- "justify-self-auto": "justifySelf",
518
- "justify-self-start": "justifySelf",
519
- "justify-self-end": "justifySelf",
520
- "justify-self-center": "justifySelf",
521
- "justify-self-stretch": "justifySelf",
522
- "content-center": "alignContent",
523
- "content-start": "alignContent",
524
- "content-end": "alignContent",
525
- "content-between": "alignContent",
526
- "content-around": "alignContent",
527
- "content-evenly": "alignContent",
528
- "items-start": "alignItems",
529
- "items-end": "alignItems",
530
- "items-center": "alignItems",
531
- "items-baseline": "alignItems",
532
- "items-stretch": "alignItems",
533
- "self-auto": "alignSelf",
534
- "self-start": "alignSelf",
535
- "self-end": "alignSelf",
536
- "self-center": "alignSelf",
537
- "self-stretch": "alignSelf",
538
- "place-content-center": "placeContent",
539
- "place-content-start": "placeContent",
540
- "place-content-end": "placeContent",
541
- "place-content-between": "placeContent",
542
- "place-content-around": "placeContent",
543
- "place-content-evenly": "placeContent",
544
- "place-content-stretch": "placeContent",
545
- "place-items-auto": "placeItems",
546
- "place-items-start": "placeItems",
547
- "place-items-end": "placeItems",
548
- "place-items-center": "placeItems",
549
- "place-items-stretch": "placeItems",
550
- "place-self-auto": "placeSelf",
551
- "place-self-start": "placeSelf",
552
- "place-self-end": "placeSelf",
553
- "place-self-center": "placeSelf",
554
- "place-self-stretch": "placeSelf",
555
- "antialiased": "fontSmoothing",
556
- "subpixel-antialiased": "font",
557
- "italic": "font",
558
- "not-italic": "font",
559
- "normal-nums": "font",
560
- "ordinal": "font",
561
- "slashed-zero": "font",
562
- "lining-nums": "font",
563
- "oldstyle-nums": "font",
564
- "proportional-nums": "font",
565
- "tabular-nums": "font",
566
- "diagonal-fractions": "font",
567
- "stacked-fractions": "font",
568
- "list-inside": "listStylePosition",
569
- "list-outside": "listStylePosition",
570
- "text-left": "textAlign",
571
- "text-center": "textAlign",
572
- "text-right": "textAlign",
573
- "text-justify": "textAlign",
574
- "underline": "textDecoration",
575
- "line-through": "textDecoration",
576
- "no-underline": "textDecoration",
577
- "uppercase": "textTransform",
578
- "lowercase": "textTransform",
579
- "capitalize": "textTransform",
580
- "normal-case": "textTransform",
581
- "truncate": "textOverflow",
582
- "overflow-ellipsis": "textOverflow",
583
- "overflow-clip": "textOverflow",
584
- "align-baseline": "verticalAlign",
585
- "align-top": "verticalAlign",
586
- "align-middle": "verticalAlign",
587
- "align-bottom": "verticalAlign",
588
- "align-text-top": "verticalAlign",
589
- "align-text-bottom": "verticalAlign",
590
- "whitespace-normal": "whitespace",
591
- "whitespace-nowrap": "whitespace",
592
- "whitespace-pre": "whitespace",
593
- "whitespace-pre-line": "whitespace",
594
- "whitespace-pre-wrap": "whitespace",
595
- "ws-normal": "whitespace",
596
- "ws-nowrap": "whitespace",
597
- "ws-pre": "whitespace",
598
- "ws-pre-line": "whitespace",
599
- "ws-pre-wrap": "whitespace",
600
- "break-normal": "wordBreak",
601
- "break-words": "wordBreak",
602
- "break-all": "wordBreak",
603
- "bg-fixed": "background",
604
- "bg-local": "background",
605
- "bg-scroll": "background",
606
- "bg-clip-border": "background",
607
- "bg-clip-padding": "background",
608
- "bg-clip-content": "background",
609
- "bg-clip-text": "background",
610
- "bg-repeat": "background",
611
- "bg-no-repeat": "background",
612
- "bg-repeat-x": "background",
613
- "bg-repeat-y": "background",
614
- "bg-repeat-round": "background",
615
- "bg-repeat-space": "background",
616
- "border-solid": "border",
617
- "border-dashed": "border",
618
- "border-dotted": "border",
619
- "border-double": "border",
620
- "border-none": "border",
621
- "border-collapse": "border",
622
- "border-separate": "border",
623
- "table-auto": "table",
624
- "table-fixed": "table",
625
- "transform": "transform",
626
- "transform-gpu": "transform",
627
- "transform-none": "transform",
628
- "appearance-none": "appearance",
629
- "pointer-events-none": "pointerEvents",
630
- "pointer-events-auto": "pointerEvents",
631
- "resize-none": "resize",
632
- "resize-y": "resize",
633
- "resize-x": "resize",
634
- "resize": "resize",
635
- "select-none": "userSelect",
636
- "select-text": "userSelect",
637
- "select-all": "userSelect",
638
- "select-auto": "userSelect",
639
- "fill-current": "fill",
640
- "stroke-current": "stroke",
641
- "sr-only": "accessibility",
642
- "not-sr-only": "accessibility",
643
- "filter": "filter",
644
- "invert": "filter"
645
- };
646
- const dynamicUtilities = {
647
- container: "container",
648
- space: "space",
649
- divide: "divide",
650
- bg: "background",
651
- from: "gradientColor",
652
- via: "gradientColor",
653
- to: "gradientColor",
654
- border: "border",
655
- b: "border",
656
- rounded: "borderRadius",
657
- cursor: "cursor",
658
- flex: "flex",
659
- shrink: "flex",
660
- order: "order",
661
- font: "font",
662
- h: "size",
663
- leading: "lineHeight",
664
- list: "listStyleType",
665
- m: "margin",
666
- my: "margin",
667
- mx: "margin",
668
- mt: "margin",
669
- mr: "margin",
670
- mb: "margin",
671
- ml: "margin",
672
- min: "size",
673
- max: "size",
674
- object: "objectPosition",
675
- op: "opacity",
676
- opacity: "opacity",
677
- outline: "outline",
678
- p: "padding",
679
- py: "padding",
680
- px: "padding",
681
- pt: "padding",
682
- pr: "padding",
683
- pb: "padding",
684
- pl: "padding",
685
- placeholder: "placeholder",
686
- inset: "inset",
687
- top: "position",
688
- right: "position",
689
- bottom: "position",
690
- left: "position",
691
- shadow: "boxShadow",
692
- ring: "ring",
693
- fill: "fill",
694
- stroke: "stroke",
695
- text: "text",
696
- tracking: "letterSpacing",
697
- w: "size",
698
- z: "zIndex",
699
- gap: "gap",
700
- auto: "grid",
701
- grid: "grid",
702
- col: "grid",
703
- row: "grid",
704
- origin: "transform",
705
- scale: "transform",
706
- rotate: "transform",
707
- translate: "transform",
708
- skew: "transform",
709
- transition: "animation",
710
- ease: "animation",
711
- duration: "animation",
712
- delay: "animation",
713
- animate: "animation",
714
- filter: "filter",
715
- backdrop: "filter",
716
- invert: "filter"
717
- };
718
-
719
- function getSelectorCategory(selector) {
720
- return staticUtilities[selector] || Object.entries(dynamicUtilities).find(([name]) => new RegExp(`^${name}+(-.+|[0-9]+)$`).test(selector))?.[1];
721
- }
722
-
723
- const ignoredColors = [
724
- "transparent",
725
- "current",
726
- "currentColor",
727
- "inherit",
728
- "initial",
729
- "unset",
730
- "none"
731
- ];
732
- function uniq(array) {
733
- return [...new Set(array)];
734
- }
735
- async function analyzer(modules, ctx) {
736
- const matched = [];
737
- const colors = [];
738
- const tokensInfo = /* @__PURE__ */ new Map();
739
- await Promise.all(modules.map(async (code, id) => {
740
- const result = await ctx.uno.generate(code, { id, extendedInfo: true, preflights: false });
741
- for (const [key, value] of result.matched.entries()) {
742
- const prev = tokensInfo.get(key);
743
- tokensInfo.set(key, {
744
- data: value.data,
745
- count: prev?.modules?.length ? value.count + prev.count : value.count,
746
- modules: uniq([...prev?.modules || [], id])
747
- });
748
- }
749
- }));
750
- for (const [rawSelector, { data, count, modules: _modules }] of tokensInfo.entries()) {
751
- const ruleContext = data[data.length - 1][5];
752
- const ruleMeta = data[data.length - 1][4];
753
- const baseSelector = ruleContext?.currentSelector;
754
- const variants = ruleContext?.variants?.map((v) => v.name).filter(Boolean);
755
- const layer = ruleMeta?.layer || "default";
756
- if (baseSelector) {
757
- const category = layer !== "default" ? layer : getSelectorCategory(baseSelector);
758
- const body = baseSelector.replace(/^ring-offset|outline-solid|outline-dotted/, "head").replace(/^\w+-/, "");
759
- const parsedColor = parseColor(body, ctx.uno.config.theme, "colors");
760
- if (parsedColor?.color && !ignoredColors.includes(parsedColor?.color)) {
761
- const existing = colors.find((c) => c.name === parsedColor.name && c.no === parsedColor.no);
762
- if (existing) {
763
- existing.count += count;
764
- existing.modules = uniq([...existing.modules, ..._modules]);
765
- } else {
766
- colors.push({
767
- name: parsedColor.name,
768
- no: parsedColor.no,
769
- color: parsedColor.color,
770
- count,
771
- modules: _modules
772
- });
773
- }
774
- }
775
- if (category) {
776
- matched.push({
777
- name: rawSelector,
778
- rawSelector,
779
- baseSelector,
780
- category,
781
- variants,
782
- count,
783
- ruleMeta,
784
- modules: _modules
785
- });
786
- continue;
787
- }
788
- }
789
- matched.push({
790
- name: rawSelector,
791
- rawSelector,
792
- category: "other",
793
- count,
794
- modules: _modules
795
- });
796
- }
797
- return {
798
- matched,
799
- colors
800
- };
801
- }
802
-
803
- 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))));
804
- function UnocssInspector(ctx) {
805
- async function configureServer(server) {
806
- await ctx.ready;
807
- server.middlewares.use("/__unocss", sirv__default(node_path.resolve(_dirname, "../dist/client"), {
808
- single: true,
809
- dev: true
810
- }));
811
- server.middlewares.use("/__unocss_api", async (req, res, next) => {
812
- if (!req.url)
813
- return next();
814
- if (req.url === "/") {
815
- const info = {
816
- version: ctx.uno.version,
817
- // use the resolved config from the dev server
818
- root: server.config.root,
819
- modules: Array.from(ctx.modules.keys()),
820
- config: ctx.uno.config,
821
- configSources: (await ctx.ready).sources
822
- };
823
- res.setHeader("Content-Type", "application/json");
824
- res.write(JSON.stringify(info, getCircularReplacer(), 2));
825
- res.end();
826
- return;
827
- }
828
- if (req.url.startsWith("/module")) {
829
- const query = new URLSearchParams(req.url.slice(8));
830
- const id = query.get("id") || "";
831
- const code = ctx.modules.get(id);
832
- if (code == null) {
833
- res.statusCode = 404;
834
- res.end();
835
- return;
836
- }
837
- const tokens = new core.CountableSet();
838
- await ctx.uno.applyExtractors(code.replace(SKIP_COMMENT_RE, ""), id, tokens);
839
- const result = await ctx.uno.generate(tokens, { id, extendedInfo: true, preflights: false });
840
- const analyzed = await analyzer(new core.BetterMap([[id, code]]), ctx);
841
- const mod = {
842
- ...result,
843
- ...analyzed,
844
- gzipSize: await gzipSize__default(result.css),
845
- code,
846
- id
847
- };
848
- res.setHeader("Content-Type", "application/json");
849
- res.write(JSON.stringify(mod, null, 2));
850
- res.end();
851
- return;
852
- }
853
- if (req.url.startsWith("/repl")) {
854
- const query = new URLSearchParams(req.url.slice(5));
855
- const token = query.get("token") || "";
856
- const includeSafelist = JSON.parse(query.get("safelist") ?? "false");
857
- const result = await ctx.uno.generate(token, { preflights: false, safelist: includeSafelist });
858
- const mod = {
859
- ...result,
860
- matched: Array.from(result.matched)
861
- };
862
- res.setHeader("Content-Type", "application/json");
863
- res.write(JSON.stringify(mod, null, 2));
864
- res.end();
865
- return;
866
- }
867
- if (req.url.startsWith("/overview")) {
868
- const result = await ctx.uno.generate(ctx.tokens, { preflights: false });
869
- const analyzed = await analyzer(ctx.modules, ctx);
870
- const mod = {
871
- ...result,
872
- colors: analyzed.colors.map((s) => ({ ...s, modules: [...s.modules] })),
873
- matched: analyzed.matched.map((s) => ({ ...s, modules: [...s.modules] })),
874
- gzipSize: await gzipSize__default(result.css)
875
- };
876
- res.setHeader("Content-Type", "application/json");
877
- res.write(JSON.stringify(mod, null, 2));
878
- res.end();
879
- return;
880
- }
881
- next();
882
- });
883
- }
884
- return {
885
- name: "unocss:inspector",
886
- apply: "serve",
887
- configureServer
888
- };
889
- }
890
- function getCircularReplacer() {
891
- const ancestors = [];
892
- return function(key, value) {
893
- if (typeof value !== "object" || value === null)
894
- return value;
895
- while (ancestors.length > 0 && ancestors.at(-1) !== this)
896
- ancestors.pop();
897
- if (ancestors.includes(value))
898
- return "[Circular]";
899
- ancestors.push(value);
900
- return value;
901
- };
902
- }
903
-
904
- module.exports = UnocssInspector;
package/dist/index.d.cts DELETED
@@ -1,6 +0,0 @@
1
- import { Plugin } from 'vite';
2
- import { UnocssPluginContext } from '@unocss/core';
3
-
4
- declare function UnocssInspector(ctx: UnocssPluginContext): Plugin;
5
-
6
- export { UnocssInspector as default };