@unocss/core 0.14.1 → 0.15.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/{index.js → index.cjs} +83 -158
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +50 -115
- package/package.json +5 -5
|
@@ -1,48 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
__markAsModule(target);
|
|
5
|
-
for (var name in all)
|
|
6
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
|
-
};
|
|
1
|
+
'use strict';
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
__export(exports, {
|
|
11
|
-
BetterMap: () => BetterMap,
|
|
12
|
-
TwoKeyMap: () => TwoKeyMap,
|
|
13
|
-
UnoGenerator: () => UnoGenerator,
|
|
14
|
-
attributifyRE: () => attributifyRE,
|
|
15
|
-
clearIdenticalEntries: () => clearIdenticalEntries,
|
|
16
|
-
createGenerator: () => createGenerator,
|
|
17
|
-
e: () => e,
|
|
18
|
-
entriesToCss: () => entriesToCss,
|
|
19
|
-
escapeRegExp: () => escapeRegExp,
|
|
20
|
-
escapeSelector: () => escapeSelector,
|
|
21
|
-
expandVariantGroup: () => expandVariantGroup,
|
|
22
|
-
extractorSplit: () => extractorSplit,
|
|
23
|
-
hasScopePlaceholder: () => hasScopePlaceholder,
|
|
24
|
-
hex2rgba: () => hex2rgba,
|
|
25
|
-
isAttributifySelector: () => isAttributifySelector,
|
|
26
|
-
isObject: () => isObject,
|
|
27
|
-
isRawUtil: () => isRawUtil,
|
|
28
|
-
isStaticRule: () => isStaticRule,
|
|
29
|
-
isStaticShortcut: () => isStaticShortcut,
|
|
30
|
-
isValidSelector: () => isValidSelector,
|
|
31
|
-
mergeDeep: () => mergeDeep,
|
|
32
|
-
mergeSet: () => mergeSet,
|
|
33
|
-
normalizeCSSEntries: () => normalizeCSSEntries,
|
|
34
|
-
normalizeCSSValues: () => normalizeCSSValues,
|
|
35
|
-
normalizeVariant: () => normalizeVariant,
|
|
36
|
-
notNull: () => notNull,
|
|
37
|
-
regexClassGroup: () => regexClassGroup,
|
|
38
|
-
toArray: () => toArray,
|
|
39
|
-
uniq: () => uniq,
|
|
40
|
-
validateFilterRE: () => validateFilterRE,
|
|
41
|
-
warnOnce: () => warnOnce,
|
|
42
|
-
withLayer: () => withLayer
|
|
43
|
-
});
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
44
4
|
|
|
45
|
-
// src/utils/escape.ts
|
|
46
5
|
function escapeRegExp(string) {
|
|
47
6
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
48
7
|
}
|
|
@@ -78,9 +37,8 @@ function escapeSelector(str) {
|
|
|
78
37
|
}
|
|
79
38
|
return result;
|
|
80
39
|
}
|
|
81
|
-
|
|
40
|
+
const e = escapeSelector;
|
|
82
41
|
|
|
83
|
-
// src/utils/object.ts
|
|
84
42
|
function normalizeCSSEntries(obj) {
|
|
85
43
|
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
86
44
|
}
|
|
@@ -96,6 +54,8 @@ function normalizeCSSValues(obj) {
|
|
|
96
54
|
}
|
|
97
55
|
function clearIdenticalEntries(entry) {
|
|
98
56
|
return entry.filter(([k, v], idx) => {
|
|
57
|
+
if (k.startsWith("$$"))
|
|
58
|
+
return false;
|
|
99
59
|
for (let i = idx - 1; i >= 0; i--) {
|
|
100
60
|
if (entry[i][0] === k && entry[i][1] === v)
|
|
101
61
|
return false;
|
|
@@ -140,7 +100,6 @@ function isStaticShortcut(sc) {
|
|
|
140
100
|
return typeof sc[0] === "string";
|
|
141
101
|
}
|
|
142
102
|
|
|
143
|
-
// src/utils/basic.ts
|
|
144
103
|
function toArray(value = []) {
|
|
145
104
|
return Array.isArray(value) ? value : [value];
|
|
146
105
|
}
|
|
@@ -152,8 +111,7 @@ function mergeSet(target, append) {
|
|
|
152
111
|
return target;
|
|
153
112
|
}
|
|
154
113
|
|
|
155
|
-
|
|
156
|
-
var hexRE = /^#?([\da-f]+)$/i;
|
|
114
|
+
const hexRE = /^#?([\da-f]+)$/i;
|
|
157
115
|
function hex2rgba(hex = "") {
|
|
158
116
|
const [, body] = hex.match(hexRE) || [];
|
|
159
117
|
if (!body)
|
|
@@ -175,9 +133,8 @@ function hex2rgba(hex = "") {
|
|
|
175
133
|
}
|
|
176
134
|
}
|
|
177
135
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
var validateFilterRE = /[a-z?]/;
|
|
136
|
+
const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
|
|
137
|
+
const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
|
|
181
138
|
function isAttributifySelector(selector) {
|
|
182
139
|
return selector.match(attributifyRE);
|
|
183
140
|
}
|
|
@@ -194,10 +151,9 @@ function notNull(value) {
|
|
|
194
151
|
return value != null;
|
|
195
152
|
}
|
|
196
153
|
|
|
197
|
-
|
|
198
|
-
var TwoKeyMap = class {
|
|
154
|
+
class TwoKeyMap {
|
|
199
155
|
constructor() {
|
|
200
|
-
this._map = new Map();
|
|
156
|
+
this._map = /* @__PURE__ */ new Map();
|
|
201
157
|
}
|
|
202
158
|
get(key1, key2) {
|
|
203
159
|
const m2 = this._map.get(key1);
|
|
@@ -207,7 +163,7 @@ var TwoKeyMap = class {
|
|
|
207
163
|
getFallback(key1, key2, fallback) {
|
|
208
164
|
let m2 = this._map.get(key1);
|
|
209
165
|
if (!m2) {
|
|
210
|
-
m2 = new Map();
|
|
166
|
+
m2 = /* @__PURE__ */ new Map();
|
|
211
167
|
this._map.set(key1, m2);
|
|
212
168
|
}
|
|
213
169
|
if (!m2.has(key2))
|
|
@@ -217,19 +173,17 @@ var TwoKeyMap = class {
|
|
|
217
173
|
set(key1, key2, value) {
|
|
218
174
|
let m2 = this._map.get(key1);
|
|
219
175
|
if (!m2) {
|
|
220
|
-
m2 = new Map();
|
|
176
|
+
m2 = /* @__PURE__ */ new Map();
|
|
221
177
|
this._map.set(key1, m2);
|
|
222
178
|
}
|
|
223
179
|
m2.set(key2, value);
|
|
224
180
|
return this;
|
|
225
181
|
}
|
|
226
182
|
has(key1, key2) {
|
|
227
|
-
|
|
228
|
-
return (_a = this._map.get(key1)) == null ? void 0 : _a.has(key2);
|
|
183
|
+
return this._map.get(key1)?.has(key2);
|
|
229
184
|
}
|
|
230
185
|
delete(key1, key2) {
|
|
231
|
-
|
|
232
|
-
return ((_a = this._map.get(key1)) == null ? void 0 : _a.delete(key2)) || false;
|
|
186
|
+
return this._map.get(key1)?.delete(key2) || false;
|
|
233
187
|
}
|
|
234
188
|
deleteTop(key1) {
|
|
235
189
|
return this._map.delete(key1);
|
|
@@ -239,8 +193,8 @@ var TwoKeyMap = class {
|
|
|
239
193
|
return fn(v, k1, k2);
|
|
240
194
|
}));
|
|
241
195
|
}
|
|
242
|
-
}
|
|
243
|
-
|
|
196
|
+
}
|
|
197
|
+
class BetterMap extends Map {
|
|
244
198
|
map(mapFn) {
|
|
245
199
|
const result = [];
|
|
246
200
|
this.forEach((v, k) => {
|
|
@@ -248,9 +202,8 @@ var BetterMap = class extends Map {
|
|
|
248
202
|
});
|
|
249
203
|
return result;
|
|
250
204
|
}
|
|
251
|
-
}
|
|
205
|
+
}
|
|
252
206
|
|
|
253
|
-
// src/utils/layer.ts
|
|
254
207
|
function withLayer(layer, rules) {
|
|
255
208
|
rules.forEach((r) => {
|
|
256
209
|
if (!r[2])
|
|
@@ -261,8 +214,7 @@ function withLayer(layer, rules) {
|
|
|
261
214
|
return rules;
|
|
262
215
|
}
|
|
263
216
|
|
|
264
|
-
|
|
265
|
-
var regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
217
|
+
const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
266
218
|
function expandVariantGroup(str) {
|
|
267
219
|
const replaces = [];
|
|
268
220
|
let match;
|
|
@@ -280,8 +232,7 @@ function expandVariantGroup(str) {
|
|
|
280
232
|
return result;
|
|
281
233
|
}
|
|
282
234
|
|
|
283
|
-
|
|
284
|
-
var warned = new Set();
|
|
235
|
+
const warned = /* @__PURE__ */ new Set();
|
|
285
236
|
function warnOnce(msg) {
|
|
286
237
|
if (warned.has(msg))
|
|
287
238
|
return;
|
|
@@ -289,8 +240,7 @@ function warnOnce(msg) {
|
|
|
289
240
|
warned.add(msg);
|
|
290
241
|
}
|
|
291
242
|
|
|
292
|
-
|
|
293
|
-
var extractorSplit = {
|
|
243
|
+
const extractorSplit = {
|
|
294
244
|
name: "split",
|
|
295
245
|
order: 0,
|
|
296
246
|
extract({ code }) {
|
|
@@ -298,7 +248,6 @@ var extractorSplit = {
|
|
|
298
248
|
}
|
|
299
249
|
};
|
|
300
250
|
|
|
301
|
-
// src/config.ts
|
|
302
251
|
function resolveShortcuts(shortcuts) {
|
|
303
252
|
return toArray(shortcuts).flatMap((s) => {
|
|
304
253
|
if (Array.isArray(s))
|
|
@@ -306,13 +255,13 @@ function resolveShortcuts(shortcuts) {
|
|
|
306
255
|
return Object.entries(s);
|
|
307
256
|
});
|
|
308
257
|
}
|
|
309
|
-
|
|
258
|
+
const defaultLayers = {
|
|
310
259
|
shortcuts: -1,
|
|
311
260
|
default: 0
|
|
312
261
|
};
|
|
313
262
|
function resolveConfig(userConfig = {}, defaults = {}) {
|
|
314
263
|
const config = Object.assign({}, defaults, userConfig);
|
|
315
|
-
const rawPresets = config.presets || [];
|
|
264
|
+
const rawPresets = (config.presets || []).flatMap(toArray);
|
|
316
265
|
const sortedPresets = [
|
|
317
266
|
...rawPresets.filter((p) => p.enforce === "pre"),
|
|
318
267
|
...rawPresets.filter((p) => !p.enforce),
|
|
@@ -347,9 +296,9 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
347
296
|
warn: true,
|
|
348
297
|
blocklist: [],
|
|
349
298
|
safelist: [],
|
|
350
|
-
presets: [],
|
|
351
299
|
sortLayers: (layers2) => layers2,
|
|
352
300
|
...config,
|
|
301
|
+
presets: sortedPresets,
|
|
353
302
|
envMode: config.envMode || "build",
|
|
354
303
|
shortcutsLayer: config.shortcutsLayer || "shortcuts",
|
|
355
304
|
layers,
|
|
@@ -364,18 +313,16 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
364
313
|
};
|
|
365
314
|
}
|
|
366
315
|
|
|
367
|
-
|
|
368
|
-
var version = "0.14.1";
|
|
316
|
+
const version = "0.15.1";
|
|
369
317
|
|
|
370
|
-
|
|
371
|
-
var UnoGenerator = class {
|
|
318
|
+
class UnoGenerator {
|
|
372
319
|
constructor(userConfig = {}, defaults = {}) {
|
|
373
320
|
this.userConfig = userConfig;
|
|
374
321
|
this.defaults = defaults;
|
|
375
322
|
this.version = version;
|
|
376
|
-
this._cache = new Map();
|
|
377
|
-
this.blocked = new Set();
|
|
378
|
-
this.parentOrders = new Map();
|
|
323
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
324
|
+
this.blocked = /* @__PURE__ */ new Set();
|
|
325
|
+
this.parentOrders = /* @__PURE__ */ new Map();
|
|
379
326
|
this.config = resolveConfig(userConfig, defaults);
|
|
380
327
|
}
|
|
381
328
|
setConfig(userConfig, defaults) {
|
|
@@ -389,7 +336,7 @@ var UnoGenerator = class {
|
|
|
389
336
|
this.parentOrders.clear();
|
|
390
337
|
this._cache.clear();
|
|
391
338
|
}
|
|
392
|
-
async applyExtractors(code, id, set = new Set()) {
|
|
339
|
+
async applyExtractors(code, id, set = /* @__PURE__ */ new Set()) {
|
|
393
340
|
const context = {
|
|
394
341
|
get original() {
|
|
395
342
|
return code;
|
|
@@ -399,7 +346,7 @@ var UnoGenerator = class {
|
|
|
399
346
|
};
|
|
400
347
|
for (const extractor of this.config.extractors) {
|
|
401
348
|
const result = await extractor.extract(context);
|
|
402
|
-
result
|
|
349
|
+
result?.forEach((t) => set.add(t));
|
|
403
350
|
}
|
|
404
351
|
return set;
|
|
405
352
|
}
|
|
@@ -414,11 +361,10 @@ var UnoGenerator = class {
|
|
|
414
361
|
if (safelist)
|
|
415
362
|
this.config.safelist.forEach((s) => tokens.add(s));
|
|
416
363
|
const nl = minify ? "" : "\n";
|
|
417
|
-
const layerSet = new Set(["default"]);
|
|
418
|
-
const matched = new Set();
|
|
419
|
-
const sheet = new Map();
|
|
364
|
+
const layerSet = /* @__PURE__ */ new Set(["default"]);
|
|
365
|
+
const matched = /* @__PURE__ */ new Set();
|
|
366
|
+
const sheet = /* @__PURE__ */ new Map();
|
|
420
367
|
const hit = (raw, payload) => {
|
|
421
|
-
var _a;
|
|
422
368
|
this._cache.set(raw, payload);
|
|
423
369
|
matched.add(raw);
|
|
424
370
|
for (const item of payload) {
|
|
@@ -426,7 +372,7 @@ var UnoGenerator = class {
|
|
|
426
372
|
if (!sheet.has(parent))
|
|
427
373
|
sheet.set(parent, []);
|
|
428
374
|
sheet.get(parent).push(item);
|
|
429
|
-
if (
|
|
375
|
+
if (item[4]?.layer)
|
|
430
376
|
layerSet.add(item[4].layer);
|
|
431
377
|
}
|
|
432
378
|
};
|
|
@@ -435,7 +381,6 @@ var UnoGenerator = class {
|
|
|
435
381
|
this._cache.set(raw, null);
|
|
436
382
|
};
|
|
437
383
|
await Promise.all(Array.from(tokens).map(async (raw) => {
|
|
438
|
-
var _a;
|
|
439
384
|
if (matched.has(raw) || this.blocked.has(raw))
|
|
440
385
|
return;
|
|
441
386
|
if (this._cache.has(raw)) {
|
|
@@ -463,11 +408,11 @@ var UnoGenerator = class {
|
|
|
463
408
|
const expanded = this.expandShortcut(applied[1], context);
|
|
464
409
|
if (expanded) {
|
|
465
410
|
const utils = await this.stringifyShortcuts(applied, context, expanded[0], expanded[1]);
|
|
466
|
-
if (utils
|
|
411
|
+
if (utils?.length)
|
|
467
412
|
return hit(raw, utils);
|
|
468
413
|
} else {
|
|
469
|
-
const utils = (
|
|
470
|
-
if (utils
|
|
414
|
+
const utils = (await this.parseUtil(applied, context))?.map((i) => this.stringifyUtil(i)).filter(notNull);
|
|
415
|
+
if (utils?.length)
|
|
471
416
|
return hit(raw, utils);
|
|
472
417
|
}
|
|
473
418
|
this._cache.set(raw, null);
|
|
@@ -479,22 +424,13 @@ var UnoGenerator = class {
|
|
|
479
424
|
});
|
|
480
425
|
}
|
|
481
426
|
const layerCache = {};
|
|
482
|
-
const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) =>
|
|
483
|
-
var _a, _b;
|
|
484
|
-
return ((_a = this.config.layers[a]) != null ? _a : 0) - ((_b = this.config.layers[b]) != null ? _b : 0) || a.localeCompare(b);
|
|
485
|
-
}));
|
|
427
|
+
const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
|
|
486
428
|
const getLayer = (layer) => {
|
|
487
429
|
if (layerCache[layer])
|
|
488
430
|
return layerCache[layer];
|
|
489
431
|
let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) || 0) - (this.parentOrders.get(b[0]) || 0)).map(([parent, items]) => {
|
|
490
432
|
const size = items.length;
|
|
491
|
-
const sorted = items.filter((i) =>
|
|
492
|
-
var _a;
|
|
493
|
-
return (((_a = i[4]) == null ? void 0 : _a.layer) || "default") === layer;
|
|
494
|
-
}).sort((a, b) => {
|
|
495
|
-
var _a;
|
|
496
|
-
return a[0] - b[0] || ((_a = a[1]) == null ? void 0 : _a.localeCompare(b[1] || "")) || 0;
|
|
497
|
-
}).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
433
|
+
const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
498
434
|
if (!sorted.length)
|
|
499
435
|
return void 0;
|
|
500
436
|
const rules = sorted.reverse().map(([selector, body], idx) => {
|
|
@@ -520,7 +456,7 @@ var UnoGenerator = class {
|
|
|
520
456
|
return layerCache[layer] = !minify && css ? `/* layer: ${layer} */${nl}${css}` : css;
|
|
521
457
|
};
|
|
522
458
|
const getLayers = (includes = layers, excludes) => {
|
|
523
|
-
return includes.filter((i) => !
|
|
459
|
+
return includes.filter((i) => !excludes?.includes(i)).map((i) => getLayer(i) || "").filter(Boolean).join(nl);
|
|
524
460
|
};
|
|
525
461
|
return {
|
|
526
462
|
get css() {
|
|
@@ -533,7 +469,7 @@ var UnoGenerator = class {
|
|
|
533
469
|
};
|
|
534
470
|
}
|
|
535
471
|
matchVariants(raw, current) {
|
|
536
|
-
const usedVariants = new Set();
|
|
472
|
+
const usedVariants = /* @__PURE__ */ new Set();
|
|
537
473
|
const handlers = [];
|
|
538
474
|
let processed = current || raw;
|
|
539
475
|
let applied = false;
|
|
@@ -565,15 +501,10 @@ var UnoGenerator = class {
|
|
|
565
501
|
return [raw, processed, handlers];
|
|
566
502
|
}
|
|
567
503
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
504
|
+
const entries = variantHandlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
|
|
568
505
|
return [
|
|
569
|
-
variantHandlers.reduce((p, v) =>
|
|
570
|
-
|
|
571
|
-
return ((_a = v.selector) == null ? void 0 : _a.call(v, p)) || p;
|
|
572
|
-
}, toEscapedSelector(raw)),
|
|
573
|
-
variantHandlers.reduce((p, v) => {
|
|
574
|
-
var _a;
|
|
575
|
-
return ((_a = v.body) == null ? void 0 : _a.call(v, p)) || p;
|
|
576
|
-
}, parsed[2]),
|
|
506
|
+
variantHandlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
|
|
507
|
+
entries,
|
|
577
508
|
variantHandlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
|
|
578
509
|
];
|
|
579
510
|
}
|
|
@@ -586,11 +517,10 @@ var UnoGenerator = class {
|
|
|
586
517
|
return cssBody;
|
|
587
518
|
}
|
|
588
519
|
async parseUtil(input, context, internal = false) {
|
|
589
|
-
var _a, _b;
|
|
590
520
|
const [raw, processed, variantHandlers] = typeof input === "string" ? this.matchVariants(input) : input;
|
|
591
521
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
592
522
|
if (staticMatch) {
|
|
593
|
-
if (staticMatch[1] && (internal || !
|
|
523
|
+
if (staticMatch[1] && (internal || !staticMatch[2]?.internal))
|
|
594
524
|
return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
|
|
595
525
|
}
|
|
596
526
|
context.variantHandlers = variantHandlers;
|
|
@@ -599,7 +529,7 @@ var UnoGenerator = class {
|
|
|
599
529
|
const rule = rulesDynamic[i];
|
|
600
530
|
if (!rule)
|
|
601
531
|
continue;
|
|
602
|
-
if (
|
|
532
|
+
if (rule[2]?.internal && !internal)
|
|
603
533
|
continue;
|
|
604
534
|
const [matcher, handler, meta] = rule;
|
|
605
535
|
const match = processed.match(matcher);
|
|
@@ -653,10 +583,7 @@ var UnoGenerator = class {
|
|
|
653
583
|
if (!result)
|
|
654
584
|
return;
|
|
655
585
|
return [
|
|
656
|
-
result.flatMap((r) =>
|
|
657
|
-
var _a;
|
|
658
|
-
return ((_a = this.expandShortcut(r, context, depth - 1)) == null ? void 0 : _a[0]) || [r];
|
|
659
|
-
}),
|
|
586
|
+
result.flatMap((r) => this.expandShortcut(r, context, depth - 1)?.[0] || [r]),
|
|
660
587
|
meta
|
|
661
588
|
];
|
|
662
589
|
}
|
|
@@ -688,12 +615,12 @@ var UnoGenerator = class {
|
|
|
688
615
|
isBlocked(raw) {
|
|
689
616
|
return !raw || this.config.blocklist.some((e2) => typeof e2 === "string" ? e2 === raw : e2.test(raw));
|
|
690
617
|
}
|
|
691
|
-
}
|
|
618
|
+
}
|
|
692
619
|
function createGenerator(config, defaults) {
|
|
693
620
|
return new UnoGenerator(config, defaults);
|
|
694
621
|
}
|
|
695
|
-
|
|
696
|
-
|
|
622
|
+
const reScopePlaceholder = / \$\$ /;
|
|
623
|
+
const hasScopePlaceholder = (css) => css.match(reScopePlaceholder);
|
|
697
624
|
function applyScope(css, scope) {
|
|
698
625
|
if (hasScopePlaceholder(css))
|
|
699
626
|
return css.replace(reScopePlaceholder, scope ? ` ${scope} ` : " ");
|
|
@@ -706,38 +633,36 @@ function toEscapedSelector(raw) {
|
|
|
706
633
|
else
|
|
707
634
|
return `.${e(raw)}`;
|
|
708
635
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
withLayer
|
|
743
|
-
});
|
|
636
|
+
|
|
637
|
+
exports.BetterMap = BetterMap;
|
|
638
|
+
exports.TwoKeyMap = TwoKeyMap;
|
|
639
|
+
exports.UnoGenerator = UnoGenerator;
|
|
640
|
+
exports.attributifyRE = attributifyRE;
|
|
641
|
+
exports.clearIdenticalEntries = clearIdenticalEntries;
|
|
642
|
+
exports.createGenerator = createGenerator;
|
|
643
|
+
exports.e = e;
|
|
644
|
+
exports.entriesToCss = entriesToCss;
|
|
645
|
+
exports.escapeRegExp = escapeRegExp;
|
|
646
|
+
exports.escapeSelector = escapeSelector;
|
|
647
|
+
exports.expandVariantGroup = expandVariantGroup;
|
|
648
|
+
exports.extractorSplit = extractorSplit;
|
|
649
|
+
exports.hasScopePlaceholder = hasScopePlaceholder;
|
|
650
|
+
exports.hex2rgba = hex2rgba;
|
|
651
|
+
exports.isAttributifySelector = isAttributifySelector;
|
|
652
|
+
exports.isObject = isObject;
|
|
653
|
+
exports.isRawUtil = isRawUtil;
|
|
654
|
+
exports.isStaticRule = isStaticRule;
|
|
655
|
+
exports.isStaticShortcut = isStaticShortcut;
|
|
656
|
+
exports.isValidSelector = isValidSelector;
|
|
657
|
+
exports.mergeDeep = mergeDeep;
|
|
658
|
+
exports.mergeSet = mergeSet;
|
|
659
|
+
exports.normalizeCSSEntries = normalizeCSSEntries;
|
|
660
|
+
exports.normalizeCSSValues = normalizeCSSValues;
|
|
661
|
+
exports.normalizeVariant = normalizeVariant;
|
|
662
|
+
exports.notNull = notNull;
|
|
663
|
+
exports.regexClassGroup = regexClassGroup;
|
|
664
|
+
exports.toArray = toArray;
|
|
665
|
+
exports.uniq = uniq;
|
|
666
|
+
exports.validateFilterRE = validateFilterRE;
|
|
667
|
+
exports.warnOnce = warnOnce;
|
|
668
|
+
exports.withLayer = withLayer;
|
package/dist/index.d.ts
CHANGED
|
@@ -111,7 +111,7 @@ interface VariantHandler {
|
|
|
111
111
|
/**
|
|
112
112
|
* Rewrite the output selector. Often be used to append pesudo classes or parents.
|
|
113
113
|
*/
|
|
114
|
-
selector?: (input: string) => string | undefined;
|
|
114
|
+
selector?: (input: string, body: CSSEntries) => string | undefined;
|
|
115
115
|
/**
|
|
116
116
|
* Rewrite the output css body. The input come in [key,value][] pairs.
|
|
117
117
|
*/
|
|
@@ -221,7 +221,7 @@ interface UserOnlyOptions<Theme extends {} = {}> {
|
|
|
221
221
|
/**
|
|
222
222
|
* Presets
|
|
223
223
|
*/
|
|
224
|
-
presets?: Preset[];
|
|
224
|
+
presets?: (Preset | Preset[])[];
|
|
225
225
|
/**
|
|
226
226
|
* Environment mode
|
|
227
227
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// src/utils/escape.ts
|
|
2
1
|
function escapeRegExp(string) {
|
|
3
2
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4
3
|
}
|
|
@@ -34,9 +33,8 @@ function escapeSelector(str) {
|
|
|
34
33
|
}
|
|
35
34
|
return result;
|
|
36
35
|
}
|
|
37
|
-
|
|
36
|
+
const e = escapeSelector;
|
|
38
37
|
|
|
39
|
-
// src/utils/object.ts
|
|
40
38
|
function normalizeCSSEntries(obj) {
|
|
41
39
|
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
42
40
|
}
|
|
@@ -52,6 +50,8 @@ function normalizeCSSValues(obj) {
|
|
|
52
50
|
}
|
|
53
51
|
function clearIdenticalEntries(entry) {
|
|
54
52
|
return entry.filter(([k, v], idx) => {
|
|
53
|
+
if (k.startsWith("$$"))
|
|
54
|
+
return false;
|
|
55
55
|
for (let i = idx - 1; i >= 0; i--) {
|
|
56
56
|
if (entry[i][0] === k && entry[i][1] === v)
|
|
57
57
|
return false;
|
|
@@ -96,7 +96,6 @@ function isStaticShortcut(sc) {
|
|
|
96
96
|
return typeof sc[0] === "string";
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// src/utils/basic.ts
|
|
100
99
|
function toArray(value = []) {
|
|
101
100
|
return Array.isArray(value) ? value : [value];
|
|
102
101
|
}
|
|
@@ -108,8 +107,7 @@ function mergeSet(target, append) {
|
|
|
108
107
|
return target;
|
|
109
108
|
}
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
var hexRE = /^#?([\da-f]+)$/i;
|
|
110
|
+
const hexRE = /^#?([\da-f]+)$/i;
|
|
113
111
|
function hex2rgba(hex = "") {
|
|
114
112
|
const [, body] = hex.match(hexRE) || [];
|
|
115
113
|
if (!body)
|
|
@@ -131,9 +129,8 @@ function hex2rgba(hex = "") {
|
|
|
131
129
|
}
|
|
132
130
|
}
|
|
133
131
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var validateFilterRE = /[a-z?]/;
|
|
132
|
+
const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
|
|
133
|
+
const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
|
|
137
134
|
function isAttributifySelector(selector) {
|
|
138
135
|
return selector.match(attributifyRE);
|
|
139
136
|
}
|
|
@@ -150,10 +147,9 @@ function notNull(value) {
|
|
|
150
147
|
return value != null;
|
|
151
148
|
}
|
|
152
149
|
|
|
153
|
-
|
|
154
|
-
var TwoKeyMap = class {
|
|
150
|
+
class TwoKeyMap {
|
|
155
151
|
constructor() {
|
|
156
|
-
this._map = new Map();
|
|
152
|
+
this._map = /* @__PURE__ */ new Map();
|
|
157
153
|
}
|
|
158
154
|
get(key1, key2) {
|
|
159
155
|
const m2 = this._map.get(key1);
|
|
@@ -163,7 +159,7 @@ var TwoKeyMap = class {
|
|
|
163
159
|
getFallback(key1, key2, fallback) {
|
|
164
160
|
let m2 = this._map.get(key1);
|
|
165
161
|
if (!m2) {
|
|
166
|
-
m2 = new Map();
|
|
162
|
+
m2 = /* @__PURE__ */ new Map();
|
|
167
163
|
this._map.set(key1, m2);
|
|
168
164
|
}
|
|
169
165
|
if (!m2.has(key2))
|
|
@@ -173,19 +169,17 @@ var TwoKeyMap = class {
|
|
|
173
169
|
set(key1, key2, value) {
|
|
174
170
|
let m2 = this._map.get(key1);
|
|
175
171
|
if (!m2) {
|
|
176
|
-
m2 = new Map();
|
|
172
|
+
m2 = /* @__PURE__ */ new Map();
|
|
177
173
|
this._map.set(key1, m2);
|
|
178
174
|
}
|
|
179
175
|
m2.set(key2, value);
|
|
180
176
|
return this;
|
|
181
177
|
}
|
|
182
178
|
has(key1, key2) {
|
|
183
|
-
|
|
184
|
-
return (_a = this._map.get(key1)) == null ? void 0 : _a.has(key2);
|
|
179
|
+
return this._map.get(key1)?.has(key2);
|
|
185
180
|
}
|
|
186
181
|
delete(key1, key2) {
|
|
187
|
-
|
|
188
|
-
return ((_a = this._map.get(key1)) == null ? void 0 : _a.delete(key2)) || false;
|
|
182
|
+
return this._map.get(key1)?.delete(key2) || false;
|
|
189
183
|
}
|
|
190
184
|
deleteTop(key1) {
|
|
191
185
|
return this._map.delete(key1);
|
|
@@ -195,8 +189,8 @@ var TwoKeyMap = class {
|
|
|
195
189
|
return fn(v, k1, k2);
|
|
196
190
|
}));
|
|
197
191
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
192
|
+
}
|
|
193
|
+
class BetterMap extends Map {
|
|
200
194
|
map(mapFn) {
|
|
201
195
|
const result = [];
|
|
202
196
|
this.forEach((v, k) => {
|
|
@@ -204,9 +198,8 @@ var BetterMap = class extends Map {
|
|
|
204
198
|
});
|
|
205
199
|
return result;
|
|
206
200
|
}
|
|
207
|
-
}
|
|
201
|
+
}
|
|
208
202
|
|
|
209
|
-
// src/utils/layer.ts
|
|
210
203
|
function withLayer(layer, rules) {
|
|
211
204
|
rules.forEach((r) => {
|
|
212
205
|
if (!r[2])
|
|
@@ -217,8 +210,7 @@ function withLayer(layer, rules) {
|
|
|
217
210
|
return rules;
|
|
218
211
|
}
|
|
219
212
|
|
|
220
|
-
|
|
221
|
-
var regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
213
|
+
const regexClassGroup = /([!\w+:_/-]+?)([:-])\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm;
|
|
222
214
|
function expandVariantGroup(str) {
|
|
223
215
|
const replaces = [];
|
|
224
216
|
let match;
|
|
@@ -236,8 +228,7 @@ function expandVariantGroup(str) {
|
|
|
236
228
|
return result;
|
|
237
229
|
}
|
|
238
230
|
|
|
239
|
-
|
|
240
|
-
var warned = new Set();
|
|
231
|
+
const warned = /* @__PURE__ */ new Set();
|
|
241
232
|
function warnOnce(msg) {
|
|
242
233
|
if (warned.has(msg))
|
|
243
234
|
return;
|
|
@@ -245,8 +236,7 @@ function warnOnce(msg) {
|
|
|
245
236
|
warned.add(msg);
|
|
246
237
|
}
|
|
247
238
|
|
|
248
|
-
|
|
249
|
-
var extractorSplit = {
|
|
239
|
+
const extractorSplit = {
|
|
250
240
|
name: "split",
|
|
251
241
|
order: 0,
|
|
252
242
|
extract({ code }) {
|
|
@@ -254,7 +244,6 @@ var extractorSplit = {
|
|
|
254
244
|
}
|
|
255
245
|
};
|
|
256
246
|
|
|
257
|
-
// src/config.ts
|
|
258
247
|
function resolveShortcuts(shortcuts) {
|
|
259
248
|
return toArray(shortcuts).flatMap((s) => {
|
|
260
249
|
if (Array.isArray(s))
|
|
@@ -262,13 +251,13 @@ function resolveShortcuts(shortcuts) {
|
|
|
262
251
|
return Object.entries(s);
|
|
263
252
|
});
|
|
264
253
|
}
|
|
265
|
-
|
|
254
|
+
const defaultLayers = {
|
|
266
255
|
shortcuts: -1,
|
|
267
256
|
default: 0
|
|
268
257
|
};
|
|
269
258
|
function resolveConfig(userConfig = {}, defaults = {}) {
|
|
270
259
|
const config = Object.assign({}, defaults, userConfig);
|
|
271
|
-
const rawPresets = config.presets || [];
|
|
260
|
+
const rawPresets = (config.presets || []).flatMap(toArray);
|
|
272
261
|
const sortedPresets = [
|
|
273
262
|
...rawPresets.filter((p) => p.enforce === "pre"),
|
|
274
263
|
...rawPresets.filter((p) => !p.enforce),
|
|
@@ -303,9 +292,9 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
303
292
|
warn: true,
|
|
304
293
|
blocklist: [],
|
|
305
294
|
safelist: [],
|
|
306
|
-
presets: [],
|
|
307
295
|
sortLayers: (layers2) => layers2,
|
|
308
296
|
...config,
|
|
297
|
+
presets: sortedPresets,
|
|
309
298
|
envMode: config.envMode || "build",
|
|
310
299
|
shortcutsLayer: config.shortcutsLayer || "shortcuts",
|
|
311
300
|
layers,
|
|
@@ -320,18 +309,16 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
320
309
|
};
|
|
321
310
|
}
|
|
322
311
|
|
|
323
|
-
|
|
324
|
-
var version = "0.14.1";
|
|
312
|
+
const version = "0.15.1";
|
|
325
313
|
|
|
326
|
-
|
|
327
|
-
var UnoGenerator = class {
|
|
314
|
+
class UnoGenerator {
|
|
328
315
|
constructor(userConfig = {}, defaults = {}) {
|
|
329
316
|
this.userConfig = userConfig;
|
|
330
317
|
this.defaults = defaults;
|
|
331
318
|
this.version = version;
|
|
332
|
-
this._cache = new Map();
|
|
333
|
-
this.blocked = new Set();
|
|
334
|
-
this.parentOrders = new Map();
|
|
319
|
+
this._cache = /* @__PURE__ */ new Map();
|
|
320
|
+
this.blocked = /* @__PURE__ */ new Set();
|
|
321
|
+
this.parentOrders = /* @__PURE__ */ new Map();
|
|
335
322
|
this.config = resolveConfig(userConfig, defaults);
|
|
336
323
|
}
|
|
337
324
|
setConfig(userConfig, defaults) {
|
|
@@ -345,7 +332,7 @@ var UnoGenerator = class {
|
|
|
345
332
|
this.parentOrders.clear();
|
|
346
333
|
this._cache.clear();
|
|
347
334
|
}
|
|
348
|
-
async applyExtractors(code, id, set = new Set()) {
|
|
335
|
+
async applyExtractors(code, id, set = /* @__PURE__ */ new Set()) {
|
|
349
336
|
const context = {
|
|
350
337
|
get original() {
|
|
351
338
|
return code;
|
|
@@ -355,7 +342,7 @@ var UnoGenerator = class {
|
|
|
355
342
|
};
|
|
356
343
|
for (const extractor of this.config.extractors) {
|
|
357
344
|
const result = await extractor.extract(context);
|
|
358
|
-
result
|
|
345
|
+
result?.forEach((t) => set.add(t));
|
|
359
346
|
}
|
|
360
347
|
return set;
|
|
361
348
|
}
|
|
@@ -370,11 +357,10 @@ var UnoGenerator = class {
|
|
|
370
357
|
if (safelist)
|
|
371
358
|
this.config.safelist.forEach((s) => tokens.add(s));
|
|
372
359
|
const nl = minify ? "" : "\n";
|
|
373
|
-
const layerSet = new Set(["default"]);
|
|
374
|
-
const matched = new Set();
|
|
375
|
-
const sheet = new Map();
|
|
360
|
+
const layerSet = /* @__PURE__ */ new Set(["default"]);
|
|
361
|
+
const matched = /* @__PURE__ */ new Set();
|
|
362
|
+
const sheet = /* @__PURE__ */ new Map();
|
|
376
363
|
const hit = (raw, payload) => {
|
|
377
|
-
var _a;
|
|
378
364
|
this._cache.set(raw, payload);
|
|
379
365
|
matched.add(raw);
|
|
380
366
|
for (const item of payload) {
|
|
@@ -382,7 +368,7 @@ var UnoGenerator = class {
|
|
|
382
368
|
if (!sheet.has(parent))
|
|
383
369
|
sheet.set(parent, []);
|
|
384
370
|
sheet.get(parent).push(item);
|
|
385
|
-
if (
|
|
371
|
+
if (item[4]?.layer)
|
|
386
372
|
layerSet.add(item[4].layer);
|
|
387
373
|
}
|
|
388
374
|
};
|
|
@@ -391,7 +377,6 @@ var UnoGenerator = class {
|
|
|
391
377
|
this._cache.set(raw, null);
|
|
392
378
|
};
|
|
393
379
|
await Promise.all(Array.from(tokens).map(async (raw) => {
|
|
394
|
-
var _a;
|
|
395
380
|
if (matched.has(raw) || this.blocked.has(raw))
|
|
396
381
|
return;
|
|
397
382
|
if (this._cache.has(raw)) {
|
|
@@ -419,11 +404,11 @@ var UnoGenerator = class {
|
|
|
419
404
|
const expanded = this.expandShortcut(applied[1], context);
|
|
420
405
|
if (expanded) {
|
|
421
406
|
const utils = await this.stringifyShortcuts(applied, context, expanded[0], expanded[1]);
|
|
422
|
-
if (utils
|
|
407
|
+
if (utils?.length)
|
|
423
408
|
return hit(raw, utils);
|
|
424
409
|
} else {
|
|
425
|
-
const utils = (
|
|
426
|
-
if (utils
|
|
410
|
+
const utils = (await this.parseUtil(applied, context))?.map((i) => this.stringifyUtil(i)).filter(notNull);
|
|
411
|
+
if (utils?.length)
|
|
427
412
|
return hit(raw, utils);
|
|
428
413
|
}
|
|
429
414
|
this._cache.set(raw, null);
|
|
@@ -435,22 +420,13 @@ var UnoGenerator = class {
|
|
|
435
420
|
});
|
|
436
421
|
}
|
|
437
422
|
const layerCache = {};
|
|
438
|
-
const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) =>
|
|
439
|
-
var _a, _b;
|
|
440
|
-
return ((_a = this.config.layers[a]) != null ? _a : 0) - ((_b = this.config.layers[b]) != null ? _b : 0) || a.localeCompare(b);
|
|
441
|
-
}));
|
|
423
|
+
const layers = this.config.sortLayers(Array.from(layerSet).sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
|
|
442
424
|
const getLayer = (layer) => {
|
|
443
425
|
if (layerCache[layer])
|
|
444
426
|
return layerCache[layer];
|
|
445
427
|
let css = Array.from(sheet).sort((a, b) => (this.parentOrders.get(a[0]) || 0) - (this.parentOrders.get(b[0]) || 0)).map(([parent, items]) => {
|
|
446
428
|
const size = items.length;
|
|
447
|
-
const sorted = items.filter((i) =>
|
|
448
|
-
var _a;
|
|
449
|
-
return (((_a = i[4]) == null ? void 0 : _a.layer) || "default") === layer;
|
|
450
|
-
}).sort((a, b) => {
|
|
451
|
-
var _a;
|
|
452
|
-
return a[0] - b[0] || ((_a = a[1]) == null ? void 0 : _a.localeCompare(b[1] || "")) || 0;
|
|
453
|
-
}).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
429
|
+
const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => a[0] - b[0] || a[1]?.localeCompare(b[1] || "") || 0).map((a) => [a[1] ? applyScope(a[1], scope) : a[1], a[2]]);
|
|
454
430
|
if (!sorted.length)
|
|
455
431
|
return void 0;
|
|
456
432
|
const rules = sorted.reverse().map(([selector, body], idx) => {
|
|
@@ -476,7 +452,7 @@ var UnoGenerator = class {
|
|
|
476
452
|
return layerCache[layer] = !minify && css ? `/* layer: ${layer} */${nl}${css}` : css;
|
|
477
453
|
};
|
|
478
454
|
const getLayers = (includes = layers, excludes) => {
|
|
479
|
-
return includes.filter((i) => !
|
|
455
|
+
return includes.filter((i) => !excludes?.includes(i)).map((i) => getLayer(i) || "").filter(Boolean).join(nl);
|
|
480
456
|
};
|
|
481
457
|
return {
|
|
482
458
|
get css() {
|
|
@@ -489,7 +465,7 @@ var UnoGenerator = class {
|
|
|
489
465
|
};
|
|
490
466
|
}
|
|
491
467
|
matchVariants(raw, current) {
|
|
492
|
-
const usedVariants = new Set();
|
|
468
|
+
const usedVariants = /* @__PURE__ */ new Set();
|
|
493
469
|
const handlers = [];
|
|
494
470
|
let processed = current || raw;
|
|
495
471
|
let applied = false;
|
|
@@ -521,15 +497,10 @@ var UnoGenerator = class {
|
|
|
521
497
|
return [raw, processed, handlers];
|
|
522
498
|
}
|
|
523
499
|
applyVariants(parsed, variantHandlers = parsed[4], raw = parsed[1]) {
|
|
500
|
+
const entries = variantHandlers.reduce((p, v) => v.body?.(p) || p, parsed[2]);
|
|
524
501
|
return [
|
|
525
|
-
variantHandlers.reduce((p, v) =>
|
|
526
|
-
|
|
527
|
-
return ((_a = v.selector) == null ? void 0 : _a.call(v, p)) || p;
|
|
528
|
-
}, toEscapedSelector(raw)),
|
|
529
|
-
variantHandlers.reduce((p, v) => {
|
|
530
|
-
var _a;
|
|
531
|
-
return ((_a = v.body) == null ? void 0 : _a.call(v, p)) || p;
|
|
532
|
-
}, parsed[2]),
|
|
502
|
+
variantHandlers.reduce((p, v) => v.selector?.(p, entries) || p, toEscapedSelector(raw)),
|
|
503
|
+
entries,
|
|
533
504
|
variantHandlers.reduce((p, v) => Array.isArray(v.parent) ? v.parent[0] : v.parent || p, void 0)
|
|
534
505
|
];
|
|
535
506
|
}
|
|
@@ -542,11 +513,10 @@ var UnoGenerator = class {
|
|
|
542
513
|
return cssBody;
|
|
543
514
|
}
|
|
544
515
|
async parseUtil(input, context, internal = false) {
|
|
545
|
-
var _a, _b;
|
|
546
516
|
const [raw, processed, variantHandlers] = typeof input === "string" ? this.matchVariants(input) : input;
|
|
547
517
|
const staticMatch = this.config.rulesStaticMap[processed];
|
|
548
518
|
if (staticMatch) {
|
|
549
|
-
if (staticMatch[1] && (internal || !
|
|
519
|
+
if (staticMatch[1] && (internal || !staticMatch[2]?.internal))
|
|
550
520
|
return [[staticMatch[0], raw, normalizeCSSEntries(staticMatch[1]), staticMatch[2], variantHandlers]];
|
|
551
521
|
}
|
|
552
522
|
context.variantHandlers = variantHandlers;
|
|
@@ -555,7 +525,7 @@ var UnoGenerator = class {
|
|
|
555
525
|
const rule = rulesDynamic[i];
|
|
556
526
|
if (!rule)
|
|
557
527
|
continue;
|
|
558
|
-
if (
|
|
528
|
+
if (rule[2]?.internal && !internal)
|
|
559
529
|
continue;
|
|
560
530
|
const [matcher, handler, meta] = rule;
|
|
561
531
|
const match = processed.match(matcher);
|
|
@@ -609,10 +579,7 @@ var UnoGenerator = class {
|
|
|
609
579
|
if (!result)
|
|
610
580
|
return;
|
|
611
581
|
return [
|
|
612
|
-
result.flatMap((r) =>
|
|
613
|
-
var _a;
|
|
614
|
-
return ((_a = this.expandShortcut(r, context, depth - 1)) == null ? void 0 : _a[0]) || [r];
|
|
615
|
-
}),
|
|
582
|
+
result.flatMap((r) => this.expandShortcut(r, context, depth - 1)?.[0] || [r]),
|
|
616
583
|
meta
|
|
617
584
|
];
|
|
618
585
|
}
|
|
@@ -644,12 +611,12 @@ var UnoGenerator = class {
|
|
|
644
611
|
isBlocked(raw) {
|
|
645
612
|
return !raw || this.config.blocklist.some((e2) => typeof e2 === "string" ? e2 === raw : e2.test(raw));
|
|
646
613
|
}
|
|
647
|
-
}
|
|
614
|
+
}
|
|
648
615
|
function createGenerator(config, defaults) {
|
|
649
616
|
return new UnoGenerator(config, defaults);
|
|
650
617
|
}
|
|
651
|
-
|
|
652
|
-
|
|
618
|
+
const reScopePlaceholder = / \$\$ /;
|
|
619
|
+
const hasScopePlaceholder = (css) => css.match(reScopePlaceholder);
|
|
653
620
|
function applyScope(css, scope) {
|
|
654
621
|
if (hasScopePlaceholder(css))
|
|
655
622
|
return css.replace(reScopePlaceholder, scope ? ` ${scope} ` : " ");
|
|
@@ -662,37 +629,5 @@ function toEscapedSelector(raw) {
|
|
|
662
629
|
else
|
|
663
630
|
return `.${e(raw)}`;
|
|
664
631
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
TwoKeyMap,
|
|
668
|
-
UnoGenerator,
|
|
669
|
-
attributifyRE,
|
|
670
|
-
clearIdenticalEntries,
|
|
671
|
-
createGenerator,
|
|
672
|
-
e,
|
|
673
|
-
entriesToCss,
|
|
674
|
-
escapeRegExp,
|
|
675
|
-
escapeSelector,
|
|
676
|
-
expandVariantGroup,
|
|
677
|
-
extractorSplit,
|
|
678
|
-
hasScopePlaceholder,
|
|
679
|
-
hex2rgba,
|
|
680
|
-
isAttributifySelector,
|
|
681
|
-
isObject,
|
|
682
|
-
isRawUtil,
|
|
683
|
-
isStaticRule,
|
|
684
|
-
isStaticShortcut,
|
|
685
|
-
isValidSelector,
|
|
686
|
-
mergeDeep,
|
|
687
|
-
mergeSet,
|
|
688
|
-
normalizeCSSEntries,
|
|
689
|
-
normalizeCSSValues,
|
|
690
|
-
normalizeVariant,
|
|
691
|
-
notNull,
|
|
692
|
-
regexClassGroup,
|
|
693
|
-
toArray,
|
|
694
|
-
uniq,
|
|
695
|
-
validateFilterRE,
|
|
696
|
-
warnOnce,
|
|
697
|
-
withLayer
|
|
698
|
-
};
|
|
632
|
+
|
|
633
|
+
export { BetterMap, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, createGenerator, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"require": "./dist/index.
|
|
28
|
+
"require": "./dist/index.cjs",
|
|
29
29
|
"import": "./dist/index.mjs",
|
|
30
30
|
"types": "./dist/index.d.ts"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"main": "dist/index.
|
|
33
|
+
"main": "dist/index.cjs",
|
|
34
34
|
"module": "dist/index.mjs",
|
|
35
35
|
"types": "dist/index.d.ts",
|
|
36
36
|
"files": [
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "
|
|
41
|
-
"
|
|
40
|
+
"build": "unbuild",
|
|
41
|
+
"stub": "unbuild --stub"
|
|
42
42
|
}
|
|
43
43
|
}
|