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