@unocss/core 0.15.5 → 0.16.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.cjs +50 -2
- package/dist/index.d.ts +14 -1
- package/dist/index.mjs +49 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -240,11 +240,57 @@ function warnOnce(msg) {
|
|
|
240
240
|
warned.add(msg);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
function createValueHandler(handlers) {
|
|
244
|
+
const handler = function(str) {
|
|
245
|
+
const s = this.__options?.sequence || [];
|
|
246
|
+
this.__options.sequence = [];
|
|
247
|
+
for (const n of s) {
|
|
248
|
+
const res = handlers[n](str);
|
|
249
|
+
if (res != null)
|
|
250
|
+
return res;
|
|
251
|
+
}
|
|
252
|
+
return void 0;
|
|
253
|
+
};
|
|
254
|
+
function addProcessor(that, name) {
|
|
255
|
+
if (!that.__options) {
|
|
256
|
+
that.__options = {
|
|
257
|
+
sequence: []
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
that.__options.sequence.push(name);
|
|
261
|
+
return that;
|
|
262
|
+
}
|
|
263
|
+
for (const name of Object.keys(handlers)) {
|
|
264
|
+
Object.defineProperty(handler, name, {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get() {
|
|
267
|
+
return addProcessor(this, name);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return handler;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const splitCode = (code) => code.split(/[\s'"`;>=]+/g).filter(isValidSelector);
|
|
243
275
|
const extractorSplit = {
|
|
244
276
|
name: "split",
|
|
245
277
|
order: 0,
|
|
246
278
|
extract({ code }) {
|
|
247
|
-
return new Set(code
|
|
279
|
+
return new Set(splitCode(code));
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
const extractorSvelte = {
|
|
284
|
+
name: "svelte",
|
|
285
|
+
order: 0,
|
|
286
|
+
extract({ code, id }) {
|
|
287
|
+
let result = splitCode(code);
|
|
288
|
+
if (id && id.endsWith(".svelte")) {
|
|
289
|
+
result = result.map((r) => {
|
|
290
|
+
return r.startsWith("class:") ? r.slice(6) : r;
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return new Set(result);
|
|
248
294
|
}
|
|
249
295
|
};
|
|
250
296
|
|
|
@@ -313,7 +359,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
313
359
|
};
|
|
314
360
|
}
|
|
315
361
|
|
|
316
|
-
const version = "0.
|
|
362
|
+
const version = "0.16.2";
|
|
317
363
|
|
|
318
364
|
class UnoGenerator {
|
|
319
365
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -640,12 +686,14 @@ exports.UnoGenerator = UnoGenerator;
|
|
|
640
686
|
exports.attributifyRE = attributifyRE;
|
|
641
687
|
exports.clearIdenticalEntries = clearIdenticalEntries;
|
|
642
688
|
exports.createGenerator = createGenerator;
|
|
689
|
+
exports.createValueHandler = createValueHandler;
|
|
643
690
|
exports.e = e;
|
|
644
691
|
exports.entriesToCss = entriesToCss;
|
|
645
692
|
exports.escapeRegExp = escapeRegExp;
|
|
646
693
|
exports.escapeSelector = escapeSelector;
|
|
647
694
|
exports.expandVariantGroup = expandVariantGroup;
|
|
648
695
|
exports.extractorSplit = extractorSplit;
|
|
696
|
+
exports.extractorSvelte = extractorSvelte;
|
|
649
697
|
exports.hasScopePlaceholder = hasScopePlaceholder;
|
|
650
698
|
exports.hex2rgba = hex2rgba;
|
|
651
699
|
exports.isAttributifySelector = isAttributifySelector;
|
package/dist/index.d.ts
CHANGED
|
@@ -371,6 +371,19 @@ declare function expandVariantGroup(str: string): string;
|
|
|
371
371
|
|
|
372
372
|
declare function warnOnce(msg: string): void;
|
|
373
373
|
|
|
374
|
+
declare type ValueHandlerCallback = (str: string) => string | number | undefined;
|
|
375
|
+
declare type ValueHandler<K extends string> = {
|
|
376
|
+
[S in K]: ValueHandler<K>;
|
|
377
|
+
} & {
|
|
378
|
+
(str: string): string | undefined;
|
|
379
|
+
__options: {
|
|
380
|
+
sequence: K[];
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
declare function createValueHandler<K extends string>(handlers: Record<K, ValueHandlerCallback>): ValueHandler<K>;
|
|
384
|
+
|
|
374
385
|
declare const extractorSplit: Extractor;
|
|
375
386
|
|
|
376
|
-
|
|
387
|
+
declare const extractorSvelte: Extractor;
|
|
388
|
+
|
|
389
|
+
export { ArgumentType, Awaitable, BetterMap, BlocklistRule, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedUtil, PartialByKeys, PluginOptions, Preflight, Preset, RawUtil, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, TwoKeyMap, UnoGenerator, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, ValueHandler, ValueHandlerCallback, Variant, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -236,11 +236,57 @@ function warnOnce(msg) {
|
|
|
236
236
|
warned.add(msg);
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
function createValueHandler(handlers) {
|
|
240
|
+
const handler = function(str) {
|
|
241
|
+
const s = this.__options?.sequence || [];
|
|
242
|
+
this.__options.sequence = [];
|
|
243
|
+
for (const n of s) {
|
|
244
|
+
const res = handlers[n](str);
|
|
245
|
+
if (res != null)
|
|
246
|
+
return res;
|
|
247
|
+
}
|
|
248
|
+
return void 0;
|
|
249
|
+
};
|
|
250
|
+
function addProcessor(that, name) {
|
|
251
|
+
if (!that.__options) {
|
|
252
|
+
that.__options = {
|
|
253
|
+
sequence: []
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
that.__options.sequence.push(name);
|
|
257
|
+
return that;
|
|
258
|
+
}
|
|
259
|
+
for (const name of Object.keys(handlers)) {
|
|
260
|
+
Object.defineProperty(handler, name, {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
get() {
|
|
263
|
+
return addProcessor(this, name);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
return handler;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const splitCode = (code) => code.split(/[\s'"`;>=]+/g).filter(isValidSelector);
|
|
239
271
|
const extractorSplit = {
|
|
240
272
|
name: "split",
|
|
241
273
|
order: 0,
|
|
242
274
|
extract({ code }) {
|
|
243
|
-
return new Set(code
|
|
275
|
+
return new Set(splitCode(code));
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const extractorSvelte = {
|
|
280
|
+
name: "svelte",
|
|
281
|
+
order: 0,
|
|
282
|
+
extract({ code, id }) {
|
|
283
|
+
let result = splitCode(code);
|
|
284
|
+
if (id && id.endsWith(".svelte")) {
|
|
285
|
+
result = result.map((r) => {
|
|
286
|
+
return r.startsWith("class:") ? r.slice(6) : r;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
return new Set(result);
|
|
244
290
|
}
|
|
245
291
|
};
|
|
246
292
|
|
|
@@ -309,7 +355,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
309
355
|
};
|
|
310
356
|
}
|
|
311
357
|
|
|
312
|
-
const version = "0.
|
|
358
|
+
const version = "0.16.2";
|
|
313
359
|
|
|
314
360
|
class UnoGenerator {
|
|
315
361
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -630,4 +676,4 @@ function toEscapedSelector(raw) {
|
|
|
630
676
|
return `.${e(raw)}`;
|
|
631
677
|
}
|
|
632
678
|
|
|
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 };
|
|
679
|
+
export { BetterMap, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractorSplit, extractorSvelte, hasScopePlaceholder, hex2rgba, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, mergeDeep, mergeSet, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, toArray, uniq, validateFilterRE, warnOnce, withLayer };
|