@unocss/core 0.32.9 → 0.32.11
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 +19 -2
- package/dist/index.d.ts +64 -1
- package/dist/index.mjs +19 -3
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -134,6 +134,7 @@ function mergeSet(target, append) {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
|
|
137
|
+
const cssIdRE = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
137
138
|
const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
|
|
138
139
|
const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
|
|
139
140
|
function isAttributifySelector(selector) {
|
|
@@ -370,6 +371,18 @@ const extractorSvelte = {
|
|
|
370
371
|
}
|
|
371
372
|
};
|
|
372
373
|
|
|
374
|
+
let createNanoEvents = () => ({
|
|
375
|
+
events: {},
|
|
376
|
+
emit(event, ...args) {
|
|
377
|
+
(this.events[event] || []).forEach(i => i(...args));
|
|
378
|
+
},
|
|
379
|
+
on(event, cb) {
|
|
380
|
+
(this.events[event] = this.events[event] || []).push(cb);
|
|
381
|
+
return () =>
|
|
382
|
+
(this.events[event] = (this.events[event] || []).filter(i => i !== cb))
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
373
386
|
function resolveShortcuts(shortcuts) {
|
|
374
387
|
return toArray(shortcuts).flatMap((s) => {
|
|
375
388
|
if (Array.isArray(s))
|
|
@@ -443,7 +456,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
443
456
|
};
|
|
444
457
|
}
|
|
445
458
|
|
|
446
|
-
const version = "0.32.
|
|
459
|
+
const version = "0.32.11";
|
|
447
460
|
|
|
448
461
|
class UnoGenerator {
|
|
449
462
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -453,7 +466,9 @@ class UnoGenerator {
|
|
|
453
466
|
this._cache = /* @__PURE__ */ new Map();
|
|
454
467
|
this.blocked = /* @__PURE__ */ new Set();
|
|
455
468
|
this.parentOrders = /* @__PURE__ */ new Map();
|
|
469
|
+
this.events = createNanoEvents();
|
|
456
470
|
this.config = resolveConfig(userConfig, defaults);
|
|
471
|
+
this.events.emit("config", this.config);
|
|
457
472
|
}
|
|
458
473
|
setConfig(userConfig, defaults) {
|
|
459
474
|
if (!userConfig)
|
|
@@ -461,10 +476,11 @@ class UnoGenerator {
|
|
|
461
476
|
if (defaults)
|
|
462
477
|
this.defaults = defaults;
|
|
463
478
|
this.userConfig = userConfig;
|
|
464
|
-
this.config = resolveConfig(userConfig, this.defaults);
|
|
465
479
|
this.blocked.clear();
|
|
466
480
|
this.parentOrders.clear();
|
|
467
481
|
this._cache.clear();
|
|
482
|
+
this.config = resolveConfig(userConfig, this.defaults);
|
|
483
|
+
this.events.emit("config", this.config);
|
|
468
484
|
}
|
|
469
485
|
async applyExtractors(code, id, set = /* @__PURE__ */ new Set()) {
|
|
470
486
|
const context = {
|
|
@@ -839,6 +855,7 @@ exports.clearIdenticalEntries = clearIdenticalEntries;
|
|
|
839
855
|
exports.clone = clone;
|
|
840
856
|
exports.createGenerator = createGenerator;
|
|
841
857
|
exports.createValueHandler = createValueHandler;
|
|
858
|
+
exports.cssIdRE = cssIdRE;
|
|
842
859
|
exports.e = e;
|
|
843
860
|
exports.entriesToCss = entriesToCss;
|
|
844
861
|
exports.escapeRegExp = escapeRegExp;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,65 @@
|
|
|
1
1
|
import { LoadConfigResult } from 'unconfig';
|
|
2
2
|
import MagicString from 'magic-string';
|
|
3
3
|
|
|
4
|
+
interface EventsMap {
|
|
5
|
+
[event: string]: any
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface DefaultEvents extends EventsMap {
|
|
9
|
+
[event: string]: (...args: any) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Unsubscribe {
|
|
13
|
+
(): void
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare class Emitter<Events extends EventsMap = DefaultEvents> {
|
|
17
|
+
/**
|
|
18
|
+
* Event names in keys and arrays with listeners in values.
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* emitter1.events = emitter2.events
|
|
22
|
+
* emitter2.events = { }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
events: Partial<{ [E in keyof Events]: Events[E][] }>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Add a listener for a given event.
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* const unbind = ee.on('tick', (tickType, tickDuration) => {
|
|
32
|
+
* count += 1
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* disable () {
|
|
36
|
+
* unbind()
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param event The event name.
|
|
41
|
+
* @param cb The listener function.
|
|
42
|
+
* @returns Unbind listener from event.
|
|
43
|
+
*/
|
|
44
|
+
on<K extends keyof Events>(this: this, event: K, cb: Events[K]): Unsubscribe
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Calls each of the listeners registered for a given event.
|
|
48
|
+
*
|
|
49
|
+
* ```js
|
|
50
|
+
* ee.emit('tick', tickType, tickDuration)
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param event The event name.
|
|
54
|
+
* @param args The arguments for listeners.
|
|
55
|
+
*/
|
|
56
|
+
emit<K extends keyof Events>(
|
|
57
|
+
this: this,
|
|
58
|
+
event: K,
|
|
59
|
+
...args: Parameters<Events[K]>
|
|
60
|
+
): void
|
|
61
|
+
}
|
|
62
|
+
|
|
4
63
|
declare class UnoGenerator {
|
|
5
64
|
userConfig: UserConfig;
|
|
6
65
|
defaults: UserConfigDefaults;
|
|
@@ -9,6 +68,9 @@ declare class UnoGenerator {
|
|
|
9
68
|
config: ResolvedConfig;
|
|
10
69
|
blocked: Set<string>;
|
|
11
70
|
parentOrders: Map<string, number>;
|
|
71
|
+
events: Emitter<{
|
|
72
|
+
config: (config: ResolvedConfig) => void;
|
|
73
|
+
}>;
|
|
12
74
|
constructor(userConfig?: UserConfig, defaults?: UserConfigDefaults);
|
|
13
75
|
setConfig(userConfig?: UserConfig, defaults?: UserConfigDefaults): void;
|
|
14
76
|
applyExtractors(code: string, id?: string, set?: Set<string>): Promise<Set<string>>;
|
|
@@ -51,6 +113,7 @@ declare function uniq<T>(value: T[]): T[];
|
|
|
51
113
|
declare function mergeSet<T>(target: Set<T>, append: Set<T>): Set<T>;
|
|
52
114
|
|
|
53
115
|
declare const attributifyRE: RegExp;
|
|
116
|
+
declare const cssIdRE: RegExp;
|
|
54
117
|
declare const validateFilterRE: RegExp;
|
|
55
118
|
declare const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
|
|
56
119
|
declare function isAttributifySelector(selector: string): RegExpMatchArray | null;
|
|
@@ -667,4 +730,4 @@ declare const extractorSplit: Extractor;
|
|
|
667
730
|
|
|
668
731
|
declare const extractorSvelte: Extractor;
|
|
669
732
|
|
|
670
|
-
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DetailString, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtractStringOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, Range, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
733
|
+
export { ArgumentType, Arrayable, AutoCompleteExtractor, AutoCompleteExtractorContext, AutoCompleteExtractorResult, AutoCompleteFunction, AutoCompleteTemplate, Awaitable, BetterMap, BlocklistRule, CONTROL_SHORTCUT_NO_MERGE, CSSColorValue, CSSEntries, CSSObject, CSSValues, ConfigBase, DeepPartial, DetailString, DynamicMatcher, DynamicRule, DynamicShortcut, DynamicShortcutMatcher, ExtractStringOptions, Extractor, ExtractorContext, FilterPattern, FlatObjectTuple, GenerateOptions, GenerateResult, GeneratorOptions, ParsedColorValue, ParsedUtil, PartialByKeys, PluginOptions, Postprocessor, Preflight, PreflightContext, Preprocessor, Preset, PresetOptions, RGBAColorValue, Range, RawUtil, Replacement, RequiredByKey, ResolvedConfig, RestArgs, Rule, RuleContext, RuleMeta, Shift, Shortcut, SourceCodeTransformer, SourceMap, StaticRule, StaticShortcut, StaticShortcutMap, StringifiedUtil, SuggestResult, ThemeExtender, TransformResult, TwoKeyMap, UnoGenerator, UnocssPluginContext, UserConfig, UserConfigDefaults, UserOnlyOptions, UserShortcuts, UtilObject, ValueHandler, ValueHandlerCallback, Variant, VariantContext, VariantFunction, VariantHandler, VariantMatchedResult, VariantObject, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/dist/index.mjs
CHANGED
|
@@ -130,6 +130,7 @@ function mergeSet(target, append) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
|
|
133
|
+
const cssIdRE = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
133
134
|
const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
|
|
134
135
|
const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
|
|
135
136
|
function isAttributifySelector(selector) {
|
|
@@ -366,6 +367,18 @@ const extractorSvelte = {
|
|
|
366
367
|
}
|
|
367
368
|
};
|
|
368
369
|
|
|
370
|
+
let createNanoEvents = () => ({
|
|
371
|
+
events: {},
|
|
372
|
+
emit(event, ...args) {
|
|
373
|
+
(this.events[event] || []).forEach(i => i(...args));
|
|
374
|
+
},
|
|
375
|
+
on(event, cb) {
|
|
376
|
+
(this.events[event] = this.events[event] || []).push(cb);
|
|
377
|
+
return () =>
|
|
378
|
+
(this.events[event] = (this.events[event] || []).filter(i => i !== cb))
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
|
|
369
382
|
function resolveShortcuts(shortcuts) {
|
|
370
383
|
return toArray(shortcuts).flatMap((s) => {
|
|
371
384
|
if (Array.isArray(s))
|
|
@@ -439,7 +452,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
439
452
|
};
|
|
440
453
|
}
|
|
441
454
|
|
|
442
|
-
const version = "0.32.
|
|
455
|
+
const version = "0.32.11";
|
|
443
456
|
|
|
444
457
|
class UnoGenerator {
|
|
445
458
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -449,7 +462,9 @@ class UnoGenerator {
|
|
|
449
462
|
this._cache = /* @__PURE__ */ new Map();
|
|
450
463
|
this.blocked = /* @__PURE__ */ new Set();
|
|
451
464
|
this.parentOrders = /* @__PURE__ */ new Map();
|
|
465
|
+
this.events = createNanoEvents();
|
|
452
466
|
this.config = resolveConfig(userConfig, defaults);
|
|
467
|
+
this.events.emit("config", this.config);
|
|
453
468
|
}
|
|
454
469
|
setConfig(userConfig, defaults) {
|
|
455
470
|
if (!userConfig)
|
|
@@ -457,10 +472,11 @@ class UnoGenerator {
|
|
|
457
472
|
if (defaults)
|
|
458
473
|
this.defaults = defaults;
|
|
459
474
|
this.userConfig = userConfig;
|
|
460
|
-
this.config = resolveConfig(userConfig, this.defaults);
|
|
461
475
|
this.blocked.clear();
|
|
462
476
|
this.parentOrders.clear();
|
|
463
477
|
this._cache.clear();
|
|
478
|
+
this.config = resolveConfig(userConfig, this.defaults);
|
|
479
|
+
this.events.emit("config", this.config);
|
|
464
480
|
}
|
|
465
481
|
async applyExtractors(code, id, set = /* @__PURE__ */ new Set()) {
|
|
466
482
|
const context = {
|
|
@@ -826,4 +842,4 @@ function toEscapedSelector(raw) {
|
|
|
826
842
|
return `.${e(raw)}`;
|
|
827
843
|
}
|
|
828
844
|
|
|
829
|
-
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
|
845
|
+
export { BetterMap, CONTROL_SHORTCUT_NO_MERGE, TwoKeyMap, UnoGenerator, attributifyRE, clearIdenticalEntries, clone, createGenerator, createValueHandler, cssIdRE, e, entriesToCss, escapeRegExp, escapeSelector, expandVariantGroup, extractQuoted, extractorSplit, extractorSvelte, hasScopePlaceholder, isAttributifySelector, isObject, isRawUtil, isStaticRule, isStaticShortcut, isValidSelector, matchingPair, mergeDeep, mergeSet, noop, normalizeCSSEntries, normalizeCSSValues, normalizeVariant, notNull, regexClassGroup, regexScopePlaceholder, toArray, toEscapedSelector, uniq, validateFilterRE, warnOnce, withLayer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.11",
|
|
4
4
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"unocss",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"sideEffects": false,
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"magic-string": "^0.26.1",
|
|
41
|
+
"nanoevents": "^6.0.2",
|
|
41
42
|
"unconfig": "^0.3.3"
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|