@unocss/vite 0.3.0 → 0.4.3
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.d.ts +8 -2
- package/dist/index.js +430 -181
- package/dist/index.mjs +416 -169
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -25,7 +25,9 @@ var __toModule = (module2) => {
|
|
|
25
25
|
// src/index.ts
|
|
26
26
|
__export(exports, {
|
|
27
27
|
ChunkModeBuildPlugin: () => ChunkModeBuildPlugin,
|
|
28
|
+
GlobalModeBuildPlugin: () => GlobalModeBuildPlugin,
|
|
28
29
|
GlobalModeDevPlugin: () => GlobalModeDevPlugin,
|
|
30
|
+
GlobalModePlugin: () => GlobalModePlugin,
|
|
29
31
|
PerModuleModePlugin: () => PerModuleModePlugin,
|
|
30
32
|
VueScopedPlugin: () => VueScopedPlugin,
|
|
31
33
|
default: () => UnocssPlugin
|
|
@@ -271,8 +273,7 @@ var variantMatcher = (name, selector) => {
|
|
|
271
273
|
|
|
272
274
|
// ../preset-uno/src/rules/color.ts
|
|
273
275
|
var import_core = __toModule(require("@unocss/core"));
|
|
274
|
-
var
|
|
275
|
-
var _a;
|
|
276
|
+
var extractColor = (body) => {
|
|
276
277
|
const [main, opacity2] = body.split(/(?:\/|:)/);
|
|
277
278
|
const [name, no = "DEFAULT"] = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
|
|
278
279
|
if (!name)
|
|
@@ -283,6 +284,17 @@ var colorResolver = (attribute, varName) => ([, body], { theme: theme2 }) => {
|
|
|
283
284
|
color = bracket2.slice(1);
|
|
284
285
|
if (bracket2.startsWith("hex-"))
|
|
285
286
|
color = bracket2.slice(4);
|
|
287
|
+
return { opacity: opacity2, name, no, color };
|
|
288
|
+
};
|
|
289
|
+
var colorResolver = (attribute, varName) => ([, body], { theme: theme2 }) => {
|
|
290
|
+
var _a;
|
|
291
|
+
const data = extractColor(body);
|
|
292
|
+
if (!data)
|
|
293
|
+
return;
|
|
294
|
+
const { opacity: opacity2, name, no, color } = data;
|
|
295
|
+
if (!name)
|
|
296
|
+
return;
|
|
297
|
+
let useColor = color;
|
|
286
298
|
if (!color) {
|
|
287
299
|
if (name === "transparent") {
|
|
288
300
|
return {
|
|
@@ -297,13 +309,13 @@ var colorResolver = (attribute, varName) => ([, body], { theme: theme2 }) => {
|
|
|
297
309
|
[attribute]: "currentColor"
|
|
298
310
|
};
|
|
299
311
|
}
|
|
300
|
-
|
|
301
|
-
if (no &&
|
|
302
|
-
|
|
312
|
+
useColor = (_a = theme2.colors) == null ? void 0 : _a[name];
|
|
313
|
+
if (no && useColor && typeof useColor !== "string")
|
|
314
|
+
useColor = useColor[no];
|
|
303
315
|
}
|
|
304
|
-
if (typeof
|
|
316
|
+
if (typeof useColor !== "string")
|
|
305
317
|
return;
|
|
306
|
-
const rgba = (0, import_core.hex2rgba)(
|
|
318
|
+
const rgba = (0, import_core.hex2rgba)(useColor);
|
|
307
319
|
if (rgba) {
|
|
308
320
|
const a = opacity2 ? opacity2[0] === "[" ? handler.bracket.percent(opacity2) : parseFloat(opacity2) / 100 : rgba[3];
|
|
309
321
|
if (a != null && !Number.isNaN(a)) {
|
|
@@ -385,6 +397,174 @@ function handlerRounded([, a, b], { theme: theme2 }) {
|
|
|
385
397
|
return cornerMap[d].map((i) => [`border${i}-radius`, v]);
|
|
386
398
|
}
|
|
387
399
|
|
|
400
|
+
// ../preset-uno/src/rules/background.ts
|
|
401
|
+
var import_core2 = __toModule(require("@unocss/core"));
|
|
402
|
+
var colorResolver2 = (mode) => ([, body], { theme: theme2 }) => {
|
|
403
|
+
var _a;
|
|
404
|
+
const data = extractColor(body);
|
|
405
|
+
if (!data)
|
|
406
|
+
return;
|
|
407
|
+
const { opacity: opacity2, name, no, color } = data;
|
|
408
|
+
if (!name)
|
|
409
|
+
return;
|
|
410
|
+
let useColor = color;
|
|
411
|
+
if (!color) {
|
|
412
|
+
if (name === "transparent") {
|
|
413
|
+
switch (mode) {
|
|
414
|
+
case "from":
|
|
415
|
+
return {
|
|
416
|
+
"--un-gradient-from": "transparent",
|
|
417
|
+
"--un-gradient-stops": "var(--un-gradient-from), var(--un-gradient-to, rgba(255, 255, 255, 0))"
|
|
418
|
+
};
|
|
419
|
+
case "via":
|
|
420
|
+
return {
|
|
421
|
+
"--un-gradient-stops": "var(--un-gradient-from), transparent, var(--un-gradient-to, rgba(255, 255, 255, 0))"
|
|
422
|
+
};
|
|
423
|
+
case "to":
|
|
424
|
+
return {
|
|
425
|
+
"--un-gradient-to": "transparent"
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
} else if (name === "current") {
|
|
429
|
+
switch (mode) {
|
|
430
|
+
case "from":
|
|
431
|
+
return {
|
|
432
|
+
"--un-gradient-from": "currentColor",
|
|
433
|
+
"--un-gradient-stops": "var(--un-gradient-from), var(--un-gradient-to, rgba(255, 255, 255, 0))"
|
|
434
|
+
};
|
|
435
|
+
case "via":
|
|
436
|
+
return {
|
|
437
|
+
"--un-gradient-stops": "var(--un-gradient-from), currentColor, var(--un-gradient-to, rgba(255, 255, 255, 0))"
|
|
438
|
+
};
|
|
439
|
+
case "to":
|
|
440
|
+
return {
|
|
441
|
+
"--un-gradient-to": "currentColor"
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
useColor = (_a = theme2.colors) == null ? void 0 : _a[name];
|
|
446
|
+
if (no && useColor && typeof useColor !== "string")
|
|
447
|
+
useColor = useColor[no];
|
|
448
|
+
}
|
|
449
|
+
if (typeof useColor !== "string")
|
|
450
|
+
return;
|
|
451
|
+
const rgba = (0, import_core2.hex2rgba)(useColor);
|
|
452
|
+
if (rgba) {
|
|
453
|
+
const a = opacity2 ? opacity2[0] === "[" ? handler.bracket.percent(opacity2) : parseFloat(opacity2) / 100 : rgba[3];
|
|
454
|
+
if (a != null && !Number.isNaN(a)) {
|
|
455
|
+
rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
|
|
456
|
+
useColor = rgba.join(",");
|
|
457
|
+
} else {
|
|
458
|
+
useColor = rgba.slice(0, 3).join(",");
|
|
459
|
+
}
|
|
460
|
+
switch (mode) {
|
|
461
|
+
case "from":
|
|
462
|
+
return {
|
|
463
|
+
"--un-gradient-from": `rgba(${useColor}, var(--un-from-opacity, 1))`,
|
|
464
|
+
"--un-gradient-stops": "var(--un-gradient-from), var(--un-gradient-to, rgba(255, 255, 255, 0))"
|
|
465
|
+
};
|
|
466
|
+
case "via":
|
|
467
|
+
return {
|
|
468
|
+
"--un-gradient-stops": `var(--un-gradient-from), rgba(${useColor}, var(--un-via-opacity, 1)), var(--un-gradient-to, rgba(255, 255, 255, 0))`
|
|
469
|
+
};
|
|
470
|
+
case "to":
|
|
471
|
+
return {
|
|
472
|
+
"--un-gradient-to": `rgba(${useColor}, var(--un-to-opacity, 1))`
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
};
|
|
477
|
+
var bgAttachments = [
|
|
478
|
+
["bg-fixed", { "background-attachment": "fixed" }],
|
|
479
|
+
["bg-local", { "background-attachment": "local" }],
|
|
480
|
+
["bg-scroll", { "background-attachment": "scroll" }]
|
|
481
|
+
];
|
|
482
|
+
var bgBlendModes = [
|
|
483
|
+
["bg-blend-normal", { "background-blend-mode": "normal" }],
|
|
484
|
+
["bg-blend-multiply", { "background-blend-mode": "multiply" }],
|
|
485
|
+
["bg-blend-screen", { "background-blend-mode": "screen" }],
|
|
486
|
+
["bg-blend-overlay", { "background-blend-mode": "overlay" }],
|
|
487
|
+
["bg-blend-darken", { "background-blend-mode": "darken" }],
|
|
488
|
+
["bg-blend-lighten", { "background-blend-mode": "lighten" }],
|
|
489
|
+
["bg-blend-color-dodge", { "background-blend-mode": "color-dodge" }],
|
|
490
|
+
["bg-blend-color-burn", { "background-blend-mode": "color-burn" }],
|
|
491
|
+
["bg-blend-hard-light", { "background-blend-mode": "hard-light" }],
|
|
492
|
+
["bg-blend-soft-light", { "background-blend-mode": "soft-light" }],
|
|
493
|
+
["bg-blend-difference", { "background-blend-mode": "difference" }],
|
|
494
|
+
["bg-blend-exclusion", { "background-blend-mode": "exclusion" }],
|
|
495
|
+
["bg-blend-hue", { "background-blend-mode": "hue" }],
|
|
496
|
+
["bg-blend-saturation", { "background-blend-mode": "saturation" }],
|
|
497
|
+
["bg-blend-color", { "background-blend-mode": "color" }],
|
|
498
|
+
["bg-blend-luminosity", { "background-blend-mode": "luminosity" }]
|
|
499
|
+
];
|
|
500
|
+
var bgClips = [
|
|
501
|
+
["bg-clip-border", { "-webkit-background-clip": "border-box", "background-attachment": "border-box" }],
|
|
502
|
+
["bg-clip-content", { "-webkit-background-clip": "content-box", "background-attachment": "content-box" }],
|
|
503
|
+
["bg-clip-padding", { "-webkit-background-clip": "padding-box", "background-attachment": "padding-box" }],
|
|
504
|
+
["bg-clip-text", { "-webkit-background-clip": "text", "background-attachment": "text" }]
|
|
505
|
+
];
|
|
506
|
+
var bgGradients = [
|
|
507
|
+
[/^from-(.+)$/, colorResolver2("from")],
|
|
508
|
+
[/^to-(.+)$/, colorResolver2("to")],
|
|
509
|
+
[/^via-(.+)$/, colorResolver2("via")]
|
|
510
|
+
];
|
|
511
|
+
var bgImages = [
|
|
512
|
+
["bg-none", { "background-image": "none" }],
|
|
513
|
+
["bg-gradient-to-t", {
|
|
514
|
+
"background-image": "linear-gradient(to top, var(--un-gradient-stops))"
|
|
515
|
+
}],
|
|
516
|
+
["bg-gradient-to-tr", {
|
|
517
|
+
"background-image": "linear-gradient(to top right, var(--un-gradient-stops))"
|
|
518
|
+
}],
|
|
519
|
+
["bg-gradient-to-r", {
|
|
520
|
+
"background-image": "linear-gradient(to right, var(--un-gradient-stops))"
|
|
521
|
+
}],
|
|
522
|
+
["bg-gradient-to-br", {
|
|
523
|
+
"background-image": "linear-gradient(to bottom right, var(--un-gradient-stops))"
|
|
524
|
+
}],
|
|
525
|
+
["bg-gradient-to-b", {
|
|
526
|
+
"background-image": "linear-gradient(to bottom, var(--un-gradient-stops))"
|
|
527
|
+
}],
|
|
528
|
+
["bg-gradient-to-bl", {
|
|
529
|
+
"background-image": "linear-gradient(to bottom left, var(--un-gradient-stops))"
|
|
530
|
+
}],
|
|
531
|
+
["bg-gradient-to-l", {
|
|
532
|
+
"background-image": "linear-gradient(to left, var(--un-gradient-stops))"
|
|
533
|
+
}],
|
|
534
|
+
["bg-gradient-to-tl", {
|
|
535
|
+
"background-image": "linear-gradient(to top left, var(--un-gradient-stops))"
|
|
536
|
+
}]
|
|
537
|
+
];
|
|
538
|
+
var bgOrigins = [
|
|
539
|
+
["bg-origin-border", { "background-origin": "border-box" }],
|
|
540
|
+
["bg-origin-padding", { "background-origin": "padding-box" }],
|
|
541
|
+
["bg-origin-content", { "background-origin": "content-box" }]
|
|
542
|
+
];
|
|
543
|
+
var bgPositions = [
|
|
544
|
+
["bg-bottom", { "background-position": "bottom" }],
|
|
545
|
+
["bg-center", { "background-position": "center" }],
|
|
546
|
+
["bg-left", { "background-position": "left" }],
|
|
547
|
+
["bg-left-bottom", { "background-position": "left bottom" }],
|
|
548
|
+
["bg-left-top", { "background-position": "left top" }],
|
|
549
|
+
["bg-right", { "background-position": "right" }],
|
|
550
|
+
["bg-right-bottom", { "background-position": "right bottom" }],
|
|
551
|
+
["bg-right-top", { "background-position": "right top" }],
|
|
552
|
+
["bg-top", { "background-position": "top" }]
|
|
553
|
+
];
|
|
554
|
+
var bgRepeats = [
|
|
555
|
+
["bg-repeat", { "background-repeat": "repeat" }],
|
|
556
|
+
["bg-no-repeat", { "background-repeat": "no-repeat" }],
|
|
557
|
+
["bg-repeat-x", { "background-position": "repeat-x" }],
|
|
558
|
+
["bg-repeat-y", { "background-position": "repeat-y" }],
|
|
559
|
+
["bg-repeat-round", { "background-position": "round" }],
|
|
560
|
+
["bg-repeat-space", { "background-position": "space" }]
|
|
561
|
+
];
|
|
562
|
+
var bgSizes = [
|
|
563
|
+
["bg-auto", { "background-size": "auto" }],
|
|
564
|
+
["bg-cover", { "background-repeat": "cover" }],
|
|
565
|
+
["bg-contain", { "background-position": "contain" }]
|
|
566
|
+
];
|
|
567
|
+
|
|
388
568
|
// ../preset-uno/src/rules/filters.ts
|
|
389
569
|
var filterContnet = "var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia) var(--un-drop-shadow)";
|
|
390
570
|
var init = {
|
|
@@ -429,7 +609,7 @@ var flex = [
|
|
|
429
609
|
];
|
|
430
610
|
|
|
431
611
|
// ../preset-uno/src/rules/font.ts
|
|
432
|
-
var
|
|
612
|
+
var import_core3 = __toModule(require("@unocss/core"));
|
|
433
613
|
var fontsFamilies = [
|
|
434
614
|
[/^font-(\w+)$/, ([, d], { theme: theme2 }) => {
|
|
435
615
|
var _a;
|
|
@@ -455,7 +635,7 @@ var weightMap = {
|
|
|
455
635
|
var fontSizes = [
|
|
456
636
|
[/^text-([^-]+)$/, ([, s = "base"], { theme: theme2 }) => {
|
|
457
637
|
var _a;
|
|
458
|
-
const result = (0,
|
|
638
|
+
const result = (0, import_core3.toArray)(((_a = theme2.fontSize) == null ? void 0 : _a[s]) || handler.bracket.rem(s));
|
|
459
639
|
if (result == null ? void 0 : result[0]) {
|
|
460
640
|
const [size, height = "1"] = result;
|
|
461
641
|
return {
|
|
@@ -526,10 +706,10 @@ var gaps = [
|
|
|
526
706
|
];
|
|
527
707
|
|
|
528
708
|
// ../preset-uno/src/rules/grid.ts
|
|
529
|
-
var
|
|
709
|
+
var import_core4 = __toModule(require("@unocss/core"));
|
|
530
710
|
var calSize = (s, theme2) => {
|
|
531
711
|
var _a;
|
|
532
|
-
return (0,
|
|
712
|
+
return (0, import_core4.toArray)(((_a = theme2.fontSize) == null ? void 0 : _a[s]) || handler.bracket.rem(s))[0];
|
|
533
713
|
};
|
|
534
714
|
var isNumber = (s) => !isNaN(Number(s));
|
|
535
715
|
var autoDirection = (selector, theme2) => {
|
|
@@ -896,7 +1076,16 @@ var rules = [
|
|
|
896
1076
|
margins,
|
|
897
1077
|
displays,
|
|
898
1078
|
opacity,
|
|
1079
|
+
bgAttachments,
|
|
1080
|
+
bgBlendModes,
|
|
1081
|
+
bgClips,
|
|
899
1082
|
bgColors,
|
|
1083
|
+
bgGradients,
|
|
1084
|
+
bgImages,
|
|
1085
|
+
bgOrigins,
|
|
1086
|
+
bgPositions,
|
|
1087
|
+
bgSizes,
|
|
1088
|
+
bgRepeats,
|
|
900
1089
|
borders,
|
|
901
1090
|
fonts,
|
|
902
1091
|
textOverflows,
|
|
@@ -1388,18 +1577,8 @@ var variantColorsClass = [
|
|
|
1388
1577
|
];
|
|
1389
1578
|
|
|
1390
1579
|
// ../preset-uno/src/variants/pseudo.ts
|
|
1391
|
-
var
|
|
1392
|
-
|
|
1393
|
-
return [
|
|
1394
|
-
variantMatcher(name, (input) => `${input}:${pseudo}`),
|
|
1395
|
-
variantMatcher(`not-${name}`, (input) => `${input}:not(:${pseudo})`),
|
|
1396
|
-
variantMatcher(`group-${name}`, (input) => `.group:${pseudo} ${input}`)
|
|
1397
|
-
];
|
|
1398
|
-
}
|
|
1399
|
-
function createPseudoElementVariant(name) {
|
|
1400
|
-
return variantMatcher(name, (input) => `${input}::${name}`);
|
|
1401
|
-
}
|
|
1402
|
-
var variantPseudoClasses = [
|
|
1580
|
+
var import_core5 = __toModule(require("@unocss/core"));
|
|
1581
|
+
var PseudoClasses = Object.fromEntries([
|
|
1403
1582
|
"active",
|
|
1404
1583
|
"checked",
|
|
1405
1584
|
"default",
|
|
@@ -1431,14 +1610,57 @@ var variantPseudoClasses = [
|
|
|
1431
1610
|
["even", "nth-child(even)"],
|
|
1432
1611
|
["odd-of-type", "nth-of-type(odd)"],
|
|
1433
1612
|
["odd", "nth-child(odd)"]
|
|
1434
|
-
].
|
|
1435
|
-
var
|
|
1613
|
+
].map(import_core5.toArray));
|
|
1614
|
+
var PseudoElements = [
|
|
1436
1615
|
"before",
|
|
1437
1616
|
"after",
|
|
1438
1617
|
"first-letter",
|
|
1439
1618
|
"first-line",
|
|
1440
1619
|
"selection"
|
|
1441
|
-
]
|
|
1620
|
+
];
|
|
1621
|
+
var PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
|
|
1622
|
+
var PseudoClassesStr = Object.keys(PseudoClasses).join("|");
|
|
1623
|
+
var PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
|
|
1624
|
+
var PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
|
|
1625
|
+
var PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
|
|
1626
|
+
var variantPseudoElements = (input) => {
|
|
1627
|
+
const match = input.match(PseudoElementsRE);
|
|
1628
|
+
if (match) {
|
|
1629
|
+
return {
|
|
1630
|
+
matcher: input.slice(match[1].length + 1),
|
|
1631
|
+
selector: (input2) => `${input2}::${match[1]}`
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
var variantPseudoClasses = {
|
|
1636
|
+
match: (input) => {
|
|
1637
|
+
let match = input.match(PseudoClassesRE);
|
|
1638
|
+
if (match) {
|
|
1639
|
+
const pseudo = PseudoClasses[match[1]] || match[1];
|
|
1640
|
+
return {
|
|
1641
|
+
matcher: input.slice(match[1].length + 1),
|
|
1642
|
+
selector: (input2) => `${input2}:${pseudo}`
|
|
1643
|
+
};
|
|
1644
|
+
}
|
|
1645
|
+
match = input.match(PseudoClassesNotRE);
|
|
1646
|
+
if (match) {
|
|
1647
|
+
const pseudo = PseudoClasses[match[1]] || match[1];
|
|
1648
|
+
return {
|
|
1649
|
+
matcher: input.slice(match[1].length + 5),
|
|
1650
|
+
selector: (input2) => `${input2}:not(:${pseudo})`
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
match = input.match(PseudoClassesGroupRE);
|
|
1654
|
+
if (match) {
|
|
1655
|
+
const pseudo = PseudoClasses[match[1]] || match[1];
|
|
1656
|
+
return {
|
|
1657
|
+
matcher: input.slice(match[1].length + 7),
|
|
1658
|
+
selector: (input2) => `.group:${pseudo} ${input2}`
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
},
|
|
1662
|
+
multiPass: true
|
|
1663
|
+
};
|
|
1442
1664
|
|
|
1443
1665
|
// ../preset-uno/src/variants/index.ts
|
|
1444
1666
|
var variantImportant = {
|
|
@@ -1480,8 +1702,8 @@ var variants = [
|
|
|
1480
1702
|
variantBreakpoints,
|
|
1481
1703
|
...variantChildren,
|
|
1482
1704
|
...variantColorsClass,
|
|
1483
|
-
|
|
1484
|
-
|
|
1705
|
+
variantPseudoClasses,
|
|
1706
|
+
variantPseudoElements
|
|
1485
1707
|
];
|
|
1486
1708
|
|
|
1487
1709
|
// ../preset-uno/src/index.ts
|
|
@@ -1493,16 +1715,16 @@ var preset = () => ({
|
|
|
1493
1715
|
var src_default = preset;
|
|
1494
1716
|
|
|
1495
1717
|
// ../preset-attributify/src/index.ts
|
|
1496
|
-
var
|
|
1718
|
+
var import_core8 = __toModule(require("@unocss/core"));
|
|
1497
1719
|
|
|
1498
1720
|
// ../preset-attributify/src/extractor.ts
|
|
1499
|
-
var
|
|
1721
|
+
var import_core6 = __toModule(require("@unocss/core"));
|
|
1500
1722
|
var strippedPrefixes = [
|
|
1501
1723
|
"v-bind:",
|
|
1502
1724
|
":"
|
|
1503
1725
|
];
|
|
1504
1726
|
var splitterRE = /[\s'"`;]+/g;
|
|
1505
|
-
var elementRE = /<[\w:\.$-]+\s((?:'[\s\S]*?'|"[\s\S]*?"|`[\s\S]*?`|\{[\s\S]*?\}|[\s\S]*?)*?)>/g;
|
|
1727
|
+
var elementRE = /<[\w][\w:\.$-]+\s((?:'[\s\S]*?'|"[\s\S]*?"|`[\s\S]*?`|\{[\s\S]*?\}|[\s\S]*?)*?)>/g;
|
|
1506
1728
|
var valuedAttributeRE = /([\w:-]+)(?:=(["'])([^\2]+?)\2)?/g;
|
|
1507
1729
|
var extractorAttributify = (options) => (code) => {
|
|
1508
1730
|
const result = Array.from(code.matchAll(elementRE)).flatMap((match) => Array.from((match[1] || "").matchAll(valuedAttributeRE))).flatMap(([, name, _, content]) => {
|
|
@@ -1513,12 +1735,12 @@ var extractorAttributify = (options) => (code) => {
|
|
|
1513
1735
|
}
|
|
1514
1736
|
}
|
|
1515
1737
|
if (!content) {
|
|
1516
|
-
if ((0,
|
|
1738
|
+
if ((0, import_core6.isValidSelector)(name) && (options == null ? void 0 : options.nonValuedAttribute) !== false)
|
|
1517
1739
|
return [`[${name}=""]`];
|
|
1518
1740
|
return [];
|
|
1519
1741
|
}
|
|
1520
1742
|
if (["class", "className"].includes(name)) {
|
|
1521
|
-
return content.split(splitterRE).filter(
|
|
1743
|
+
return content.split(splitterRE).filter(import_core6.isValidSelector);
|
|
1522
1744
|
} else {
|
|
1523
1745
|
return content.split(splitterRE).filter(Boolean).map((v) => `[${name}~="${v}"]`);
|
|
1524
1746
|
}
|
|
@@ -1527,13 +1749,13 @@ var extractorAttributify = (options) => (code) => {
|
|
|
1527
1749
|
};
|
|
1528
1750
|
|
|
1529
1751
|
// ../preset-attributify/src/variant.ts
|
|
1530
|
-
var
|
|
1752
|
+
var import_core7 = __toModule(require("@unocss/core"));
|
|
1531
1753
|
var variantsRE = /^(.+\:\!?)?(.*?)$/;
|
|
1532
1754
|
var variantAttributify = (options = {}) => {
|
|
1533
1755
|
var _a;
|
|
1534
1756
|
const prefix = (_a = options.prefix) != null ? _a : "un-";
|
|
1535
1757
|
return (input) => {
|
|
1536
|
-
const match = (0,
|
|
1758
|
+
const match = (0, import_core7.isAttributifySelector)(input);
|
|
1537
1759
|
if (!match)
|
|
1538
1760
|
return;
|
|
1539
1761
|
let name = match[1];
|
|
@@ -1559,7 +1781,7 @@ var preset2 = (options) => {
|
|
|
1559
1781
|
extractorAttributify(options)
|
|
1560
1782
|
];
|
|
1561
1783
|
if (!(options == null ? void 0 : options.strict))
|
|
1562
|
-
extractors.unshift(
|
|
1784
|
+
extractors.unshift(import_core8.extractorSplit);
|
|
1563
1785
|
return {
|
|
1564
1786
|
variants: variants2,
|
|
1565
1787
|
extractors
|
|
@@ -1598,7 +1820,7 @@ function createContext(uno, config, configFilepath) {
|
|
|
1598
1820
|
};
|
|
1599
1821
|
}
|
|
1600
1822
|
|
|
1601
|
-
// src/chunk-build.ts
|
|
1823
|
+
// src/modes/chunk-build.ts
|
|
1602
1824
|
var import_pluginutils = __toModule(require("@rollup/pluginutils"));
|
|
1603
1825
|
|
|
1604
1826
|
// src/utils.ts
|
|
@@ -1609,7 +1831,7 @@ function getHash(input, length = 8) {
|
|
|
1609
1831
|
return (0, import_crypto.createHash)("sha256").update(input).digest("hex").substr(0, length);
|
|
1610
1832
|
}
|
|
1611
1833
|
|
|
1612
|
-
// src/chunk-build.ts
|
|
1834
|
+
// src/modes/chunk-build.ts
|
|
1613
1835
|
function ChunkModeBuildPlugin({ uno, config }) {
|
|
1614
1836
|
let cssPlugin;
|
|
1615
1837
|
const filter = (0, import_pluginutils.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
@@ -1653,27 +1875,103 @@ function ChunkModeBuildPlugin({ uno, config }) {
|
|
|
1653
1875
|
};
|
|
1654
1876
|
}
|
|
1655
1877
|
|
|
1656
|
-
// src/global
|
|
1878
|
+
// src/modes/global/build.ts
|
|
1657
1879
|
var import_pluginutils2 = __toModule(require("@rollup/pluginutils"));
|
|
1880
|
+
|
|
1881
|
+
// src/modes/global/shared.ts
|
|
1658
1882
|
var VIRTUAL_ENTRY = "/@unocss-entry.css";
|
|
1883
|
+
var VIRTUAL_ENTRY_ALIAS = [
|
|
1884
|
+
"/@unocss-entry.css",
|
|
1885
|
+
"uno.css",
|
|
1886
|
+
"virtual:uno.css"
|
|
1887
|
+
];
|
|
1659
1888
|
var READY_CALLBACK = "/__unocss_ready";
|
|
1660
|
-
var
|
|
1889
|
+
var PLACEHOLDER = "#--unocss--{--unocss:true}";
|
|
1890
|
+
var PLACEHOLDER_RE = /#--unocss--\s*{\s*--unocss:\s*true;?\s*}/;
|
|
1891
|
+
|
|
1892
|
+
// src/modes/global/build.ts
|
|
1893
|
+
function GlobalModeBuildPlugin({ uno, config, scan, tokens }) {
|
|
1894
|
+
const filter = (0, import_pluginutils2.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
1895
|
+
const tasks = [];
|
|
1896
|
+
return [
|
|
1897
|
+
{
|
|
1898
|
+
name: "unocss:global:build:scan",
|
|
1899
|
+
apply: "build",
|
|
1900
|
+
enforce: "pre",
|
|
1901
|
+
transform(code, id) {
|
|
1902
|
+
if (filter(id))
|
|
1903
|
+
tasks.push(scan(code, id));
|
|
1904
|
+
return null;
|
|
1905
|
+
},
|
|
1906
|
+
transformIndexHtml: {
|
|
1907
|
+
enforce: "pre",
|
|
1908
|
+
transform(code, { path }) {
|
|
1909
|
+
tasks.push(scan(code, path));
|
|
1910
|
+
}
|
|
1911
|
+
},
|
|
1912
|
+
resolveId(id) {
|
|
1913
|
+
return VIRTUAL_ENTRY_ALIAS.includes(id) ? VIRTUAL_ENTRY : null;
|
|
1914
|
+
},
|
|
1915
|
+
async load(id) {
|
|
1916
|
+
if (id !== VIRTUAL_ENTRY)
|
|
1917
|
+
return null;
|
|
1918
|
+
return PLACEHOLDER;
|
|
1919
|
+
}
|
|
1920
|
+
},
|
|
1921
|
+
{
|
|
1922
|
+
name: "unocss:global:build:generate",
|
|
1923
|
+
apply(options, { command }) {
|
|
1924
|
+
var _a;
|
|
1925
|
+
return command === "build" && !((_a = options.build) == null ? void 0 : _a.ssr);
|
|
1926
|
+
},
|
|
1927
|
+
enforce: "post",
|
|
1928
|
+
async generateBundle(options, bundle) {
|
|
1929
|
+
const files = Object.keys(bundle).filter((i) => i.endsWith(".css"));
|
|
1930
|
+
if (!files.length)
|
|
1931
|
+
return;
|
|
1932
|
+
await Promise.all(tasks);
|
|
1933
|
+
const { css } = await uno.generate(tokens);
|
|
1934
|
+
let replaced = false;
|
|
1935
|
+
if (!css)
|
|
1936
|
+
return;
|
|
1937
|
+
for (const file of files) {
|
|
1938
|
+
const chunk = bundle[file];
|
|
1939
|
+
if (chunk.type === "asset" && typeof chunk.source === "string") {
|
|
1940
|
+
if (PLACEHOLDER_RE.test(chunk.source)) {
|
|
1941
|
+
chunk.source = chunk.source.replace(PLACEHOLDER_RE, css);
|
|
1942
|
+
replaced = true;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
if (!replaced)
|
|
1947
|
+
this.error(new Error("[unocss] does not found CSS placeholder in the generated chunks,\nthis is likely an internal bug of unocss vite plugin"));
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
];
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
// src/modes/global/dev.ts
|
|
1954
|
+
var import_pluginutils3 = __toModule(require("@rollup/pluginutils"));
|
|
1955
|
+
var WARN_TIMEOUT = 2e3;
|
|
1661
1956
|
function GlobalModeDevPlugin({ config, uno, tokens, onInvalidate, scan }) {
|
|
1662
1957
|
let server;
|
|
1663
|
-
const filter = (0,
|
|
1958
|
+
const filter = (0, import_pluginutils3.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
1664
1959
|
const tasks = [];
|
|
1665
|
-
let
|
|
1666
|
-
let lastUpdate =
|
|
1667
|
-
|
|
1960
|
+
let invalidateTimer;
|
|
1961
|
+
let lastUpdate = Date.now();
|
|
1962
|
+
let lastServed = 0;
|
|
1963
|
+
let resolved = false;
|
|
1964
|
+
let resolvedWarnTimer;
|
|
1965
|
+
function invalidate(timer = 10) {
|
|
1668
1966
|
if (!server)
|
|
1669
1967
|
return;
|
|
1670
1968
|
const mod = server.moduleGraph.getModuleById(VIRTUAL_ENTRY);
|
|
1671
1969
|
if (!mod)
|
|
1672
1970
|
return;
|
|
1673
|
-
lastUpdate =
|
|
1971
|
+
lastUpdate = Date.now();
|
|
1674
1972
|
server.moduleGraph.invalidateModule(mod);
|
|
1675
|
-
clearTimeout(
|
|
1676
|
-
|
|
1973
|
+
clearTimeout(invalidateTimer);
|
|
1974
|
+
invalidateTimer = setTimeout(sendUpdate, timer);
|
|
1677
1975
|
}
|
|
1678
1976
|
function sendUpdate() {
|
|
1679
1977
|
server.ws.send({
|
|
@@ -1686,69 +1984,97 @@ function GlobalModeDevPlugin({ config, uno, tokens, onInvalidate, scan }) {
|
|
|
1686
1984
|
}]
|
|
1687
1985
|
});
|
|
1688
1986
|
}
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
server = _server;
|
|
1700
|
-
server.middlewares.use(async (req, res, next) => {
|
|
1701
|
-
if (req.url === READY_CALLBACK) {
|
|
1702
|
-
sendUpdate();
|
|
1703
|
-
res.statusCode = 200;
|
|
1704
|
-
res.end();
|
|
1705
|
-
} else {
|
|
1706
|
-
return next();
|
|
1987
|
+
function setWarnTimer() {
|
|
1988
|
+
if (!resolved && !resolvedWarnTimer) {
|
|
1989
|
+
resolvedWarnTimer = setTimeout(() => {
|
|
1990
|
+
if (!resolved) {
|
|
1991
|
+
const msg = "[unocss] entry module not found, have you add `import 'uno.css'` in your main entry?";
|
|
1992
|
+
console.warn(msg);
|
|
1993
|
+
server.ws.send({
|
|
1994
|
+
type: "error",
|
|
1995
|
+
err: { message: msg, stack: "" }
|
|
1996
|
+
});
|
|
1707
1997
|
}
|
|
1708
|
-
});
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1998
|
+
}, WARN_TIMEOUT);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
onInvalidate(invalidate);
|
|
2002
|
+
return [
|
|
2003
|
+
{
|
|
2004
|
+
name: "unocss:global",
|
|
2005
|
+
apply: "serve",
|
|
2006
|
+
enforce: "pre",
|
|
2007
|
+
configureServer(_server) {
|
|
2008
|
+
server = _server;
|
|
2009
|
+
server.middlewares.use(async (req, res, next) => {
|
|
2010
|
+
var _a;
|
|
2011
|
+
setWarnTimer();
|
|
2012
|
+
if ((_a = req.url) == null ? void 0 : _a.startsWith(READY_CALLBACK)) {
|
|
2013
|
+
const servedTime = +req.url.slice(READY_CALLBACK.length + 1);
|
|
2014
|
+
if (servedTime < lastUpdate)
|
|
2015
|
+
invalidate(0);
|
|
2016
|
+
res.statusCode = 200;
|
|
2017
|
+
res.end();
|
|
2018
|
+
} else {
|
|
2019
|
+
return next();
|
|
1720
2020
|
}
|
|
1721
|
-
};
|
|
2021
|
+
});
|
|
2022
|
+
},
|
|
2023
|
+
transform(code, id) {
|
|
2024
|
+
if (filter(id))
|
|
2025
|
+
scan(code, id);
|
|
2026
|
+
return null;
|
|
2027
|
+
},
|
|
2028
|
+
transformIndexHtml: {
|
|
2029
|
+
enforce: "pre",
|
|
2030
|
+
transform(code, { path }) {
|
|
2031
|
+
scan(code, path);
|
|
2032
|
+
}
|
|
2033
|
+
},
|
|
2034
|
+
resolveId(id) {
|
|
2035
|
+
if (VIRTUAL_ENTRY_ALIAS.includes(id)) {
|
|
2036
|
+
resolved = true;
|
|
2037
|
+
return VIRTUAL_ENTRY;
|
|
2038
|
+
}
|
|
2039
|
+
},
|
|
2040
|
+
async load(id) {
|
|
2041
|
+
if (id !== VIRTUAL_ENTRY)
|
|
2042
|
+
return null;
|
|
2043
|
+
await Promise.all(tasks);
|
|
2044
|
+
const { css } = await uno.generate(tokens);
|
|
2045
|
+
lastServed = Date.now();
|
|
2046
|
+
return css;
|
|
1722
2047
|
}
|
|
1723
|
-
return null;
|
|
1724
2048
|
},
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
2049
|
+
{
|
|
2050
|
+
name: "unocss:global:post",
|
|
2051
|
+
apply: "serve",
|
|
2052
|
+
enforce: "post",
|
|
2053
|
+
transform(code, id) {
|
|
2054
|
+
if (id === VIRTUAL_ENTRY)
|
|
2055
|
+
return `${code}
|
|
2056
|
+
await fetch("${READY_CALLBACK}/${lastServed}")`;
|
|
1729
2057
|
}
|
|
1730
|
-
},
|
|
1731
|
-
resolveId(id) {
|
|
1732
|
-
return id === VIRTUAL_ENTRY ? id : null;
|
|
1733
|
-
},
|
|
1734
|
-
async load(id) {
|
|
1735
|
-
if (id !== VIRTUAL_ENTRY)
|
|
1736
|
-
return null;
|
|
1737
|
-
await Promise.all(tasks);
|
|
1738
|
-
const { css } = await uno.generate(tokens);
|
|
1739
|
-
return css;
|
|
1740
2058
|
}
|
|
1741
|
-
|
|
2059
|
+
];
|
|
1742
2060
|
}
|
|
1743
2061
|
|
|
1744
|
-
// src/
|
|
1745
|
-
|
|
2062
|
+
// src/modes/global/index.ts
|
|
2063
|
+
function GlobalModePlugin(ctx) {
|
|
2064
|
+
return [
|
|
2065
|
+
...GlobalModeBuildPlugin(ctx),
|
|
2066
|
+
...GlobalModeDevPlugin(ctx)
|
|
2067
|
+
];
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
// src/modes/per-module.ts
|
|
2071
|
+
var import_pluginutils4 = __toModule(require("@rollup/pluginutils"));
|
|
1746
2072
|
var VIRTUAL_PREFIX = "/@unocss/";
|
|
1747
2073
|
var SCOPE_IMPORT_RE = / from (['"])(@unocss\/scope)\1/;
|
|
1748
2074
|
function PerModuleModePlugin({ uno, config }) {
|
|
1749
2075
|
const moduleMap = new Map();
|
|
1750
2076
|
let server;
|
|
1751
|
-
const filter = (0,
|
|
2077
|
+
const filter = (0, import_pluginutils4.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
1752
2078
|
const invalidate = (hash) => {
|
|
1753
2079
|
if (!server)
|
|
1754
2080
|
return;
|
|
@@ -1807,10 +2133,10 @@ ${css}`;
|
|
|
1807
2133
|
};
|
|
1808
2134
|
}
|
|
1809
2135
|
|
|
1810
|
-
// src/vue-scoped.ts
|
|
1811
|
-
var
|
|
2136
|
+
// src/modes/vue-scoped.ts
|
|
2137
|
+
var import_pluginutils5 = __toModule(require("@rollup/pluginutils"));
|
|
1812
2138
|
function VueScopedPlugin({ uno, config }) {
|
|
1813
|
-
const filter = (0,
|
|
2139
|
+
const filter = (0, import_pluginutils5.createFilter)(config.include || [/\.vue$/], config.exclude || defaultExclude);
|
|
1814
2140
|
async function transformSFC(code) {
|
|
1815
2141
|
const { css } = await uno.generate(code);
|
|
1816
2142
|
if (!css)
|
|
@@ -1838,85 +2164,6 @@ function VueScopedPlugin({ uno, config }) {
|
|
|
1838
2164
|
};
|
|
1839
2165
|
}
|
|
1840
2166
|
|
|
1841
|
-
// src/global-build.ts
|
|
1842
|
-
var import_pluginutils5 = __toModule(require("@rollup/pluginutils"));
|
|
1843
|
-
var VIRTUAL_ENTRY2 = "/@unocss-entry.css";
|
|
1844
|
-
var PLACEHOLDER = "#--unocss--{--unocss:true}";
|
|
1845
|
-
var PLACEHOLDER_RE = /#--unocss--\s*{\s*--unocss:\s*true;?\s*}/;
|
|
1846
|
-
var JS_RE2 = /\.[mc]?[tj]sx?$/;
|
|
1847
|
-
function GlobalModeBuildPlugin({ uno, config, scan, tokens }) {
|
|
1848
|
-
const filter = (0, import_pluginutils5.createFilter)(config.include || defaultInclude, config.exclude || defaultExclude);
|
|
1849
|
-
let mainEntry;
|
|
1850
|
-
const tasks = [];
|
|
1851
|
-
return [
|
|
1852
|
-
{
|
|
1853
|
-
name: "unocss:global:build:scan",
|
|
1854
|
-
apply: "build",
|
|
1855
|
-
enforce: "pre",
|
|
1856
|
-
buildStart() {
|
|
1857
|
-
mainEntry = void 0;
|
|
1858
|
-
},
|
|
1859
|
-
transform(code, id) {
|
|
1860
|
-
if (filter(id))
|
|
1861
|
-
tasks.push(scan(code, id));
|
|
1862
|
-
if (mainEntry === id || mainEntry == null && !id.includes("node_modules/vite") && JS_RE2.test(id) && id.startsWith("/")) {
|
|
1863
|
-
mainEntry = id;
|
|
1864
|
-
return {
|
|
1865
|
-
code: `${code};import '${VIRTUAL_ENTRY2}';`,
|
|
1866
|
-
map: {
|
|
1867
|
-
mappings: ""
|
|
1868
|
-
}
|
|
1869
|
-
};
|
|
1870
|
-
}
|
|
1871
|
-
return null;
|
|
1872
|
-
},
|
|
1873
|
-
transformIndexHtml: {
|
|
1874
|
-
enforce: "pre",
|
|
1875
|
-
transform(code, { path }) {
|
|
1876
|
-
tasks.push(scan(code, path));
|
|
1877
|
-
}
|
|
1878
|
-
},
|
|
1879
|
-
resolveId(id) {
|
|
1880
|
-
return id === VIRTUAL_ENTRY2 ? id : null;
|
|
1881
|
-
},
|
|
1882
|
-
async load(id) {
|
|
1883
|
-
if (id !== VIRTUAL_ENTRY2)
|
|
1884
|
-
return null;
|
|
1885
|
-
return PLACEHOLDER;
|
|
1886
|
-
}
|
|
1887
|
-
},
|
|
1888
|
-
{
|
|
1889
|
-
name: "unocss:global:build:generate",
|
|
1890
|
-
apply(options, { command }) {
|
|
1891
|
-
var _a;
|
|
1892
|
-
return command === "build" && !((_a = options.build) == null ? void 0 : _a.ssr);
|
|
1893
|
-
},
|
|
1894
|
-
enforce: "post",
|
|
1895
|
-
async generateBundle(options, bundle) {
|
|
1896
|
-
const files = Object.keys(bundle).filter((i) => i.endsWith(".css"));
|
|
1897
|
-
if (!files.length)
|
|
1898
|
-
return;
|
|
1899
|
-
await Promise.all(tasks);
|
|
1900
|
-
const { css } = await uno.generate(tokens);
|
|
1901
|
-
let replaced = false;
|
|
1902
|
-
if (!css)
|
|
1903
|
-
return;
|
|
1904
|
-
for (const file of files) {
|
|
1905
|
-
const chunk = bundle[file];
|
|
1906
|
-
if (chunk.type === "asset" && typeof chunk.source === "string") {
|
|
1907
|
-
if (PLACEHOLDER_RE.test(chunk.source)) {
|
|
1908
|
-
chunk.source = chunk.source.replace(PLACEHOLDER_RE, css);
|
|
1909
|
-
replaced = true;
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
}
|
|
1913
|
-
if (!replaced)
|
|
1914
|
-
this.error(new Error("[unocss] does not found CSS placeholder in the generated chunks,\nthis is likely an internal bug of unocss vite plugin"));
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
];
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
2167
|
// src/config-hmr.ts
|
|
1921
2168
|
var import_config = __toModule(require("@unocss/config"));
|
|
1922
2169
|
function ConfigHMRPlugin({ uno, configFilepath: filepath, invalidate, tokens, modules }) {
|
|
@@ -1957,9 +2204,9 @@ function UnocssPlugin(configOrPath, defaults = {
|
|
|
1957
2204
|
} else if (mode === "vue-scoped") {
|
|
1958
2205
|
plugins.push(VueScopedPlugin(ctx));
|
|
1959
2206
|
} else if (mode === "global") {
|
|
1960
|
-
plugins.push(...
|
|
2207
|
+
plugins.push(...GlobalModePlugin(ctx));
|
|
1961
2208
|
} else if (mode === "dist-chunk") {
|
|
1962
|
-
plugins.push(ChunkModeBuildPlugin(ctx), GlobalModeDevPlugin(ctx));
|
|
2209
|
+
plugins.push(ChunkModeBuildPlugin(ctx), ...GlobalModeDevPlugin(ctx));
|
|
1963
2210
|
} else {
|
|
1964
2211
|
throw new Error(`[unocss] unknown mode "${mode}"`);
|
|
1965
2212
|
}
|
|
@@ -1968,7 +2215,9 @@ function UnocssPlugin(configOrPath, defaults = {
|
|
|
1968
2215
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1969
2216
|
0 && (module.exports = {
|
|
1970
2217
|
ChunkModeBuildPlugin,
|
|
2218
|
+
GlobalModeBuildPlugin,
|
|
1971
2219
|
GlobalModeDevPlugin,
|
|
2220
|
+
GlobalModePlugin,
|
|
1972
2221
|
PerModuleModePlugin,
|
|
1973
2222
|
VueScopedPlugin
|
|
1974
2223
|
});
|