@unocss/core 0.32.7 → 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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/index.cjs +22 -9
- package/dist/index.d.ts +64 -1
- package/dist/index.mjs +22 -10
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
|
3
|
+
Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -81,14 +81,10 @@ function mergeDeep(original, patch) {
|
|
|
81
81
|
const output = { ...o };
|
|
82
82
|
if (isObject(o) && isObject(p)) {
|
|
83
83
|
Object.keys(p).forEach((key) => {
|
|
84
|
-
if (isObject(p[key]))
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
else
|
|
88
|
-
output[key] = mergeDeep(o[key], p[key]);
|
|
89
|
-
} else {
|
|
84
|
+
if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key]))
|
|
85
|
+
output[key] = mergeDeep(o[key], p[key]);
|
|
86
|
+
else
|
|
90
87
|
Object.assign(output, { [key]: p[key] });
|
|
91
|
-
}
|
|
92
88
|
});
|
|
93
89
|
}
|
|
94
90
|
return output;
|
|
@@ -138,6 +134,7 @@ function mergeSet(target, append) {
|
|
|
138
134
|
}
|
|
139
135
|
|
|
140
136
|
const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
|
|
137
|
+
const cssIdRE = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
141
138
|
const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
|
|
142
139
|
const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
|
|
143
140
|
function isAttributifySelector(selector) {
|
|
@@ -374,6 +371,18 @@ const extractorSvelte = {
|
|
|
374
371
|
}
|
|
375
372
|
};
|
|
376
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
|
+
|
|
377
386
|
function resolveShortcuts(shortcuts) {
|
|
378
387
|
return toArray(shortcuts).flatMap((s) => {
|
|
379
388
|
if (Array.isArray(s))
|
|
@@ -447,7 +456,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
447
456
|
};
|
|
448
457
|
}
|
|
449
458
|
|
|
450
|
-
const version = "0.32.
|
|
459
|
+
const version = "0.32.11";
|
|
451
460
|
|
|
452
461
|
class UnoGenerator {
|
|
453
462
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -457,7 +466,9 @@ class UnoGenerator {
|
|
|
457
466
|
this._cache = /* @__PURE__ */ new Map();
|
|
458
467
|
this.blocked = /* @__PURE__ */ new Set();
|
|
459
468
|
this.parentOrders = /* @__PURE__ */ new Map();
|
|
469
|
+
this.events = createNanoEvents();
|
|
460
470
|
this.config = resolveConfig(userConfig, defaults);
|
|
471
|
+
this.events.emit("config", this.config);
|
|
461
472
|
}
|
|
462
473
|
setConfig(userConfig, defaults) {
|
|
463
474
|
if (!userConfig)
|
|
@@ -465,10 +476,11 @@ class UnoGenerator {
|
|
|
465
476
|
if (defaults)
|
|
466
477
|
this.defaults = defaults;
|
|
467
478
|
this.userConfig = userConfig;
|
|
468
|
-
this.config = resolveConfig(userConfig, this.defaults);
|
|
469
479
|
this.blocked.clear();
|
|
470
480
|
this.parentOrders.clear();
|
|
471
481
|
this._cache.clear();
|
|
482
|
+
this.config = resolveConfig(userConfig, this.defaults);
|
|
483
|
+
this.events.emit("config", this.config);
|
|
472
484
|
}
|
|
473
485
|
async applyExtractors(code, id, set = /* @__PURE__ */ new Set()) {
|
|
474
486
|
const context = {
|
|
@@ -843,6 +855,7 @@ exports.clearIdenticalEntries = clearIdenticalEntries;
|
|
|
843
855
|
exports.clone = clone;
|
|
844
856
|
exports.createGenerator = createGenerator;
|
|
845
857
|
exports.createValueHandler = createValueHandler;
|
|
858
|
+
exports.cssIdRE = cssIdRE;
|
|
846
859
|
exports.e = e;
|
|
847
860
|
exports.entriesToCss = entriesToCss;
|
|
848
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
|
@@ -77,14 +77,10 @@ function mergeDeep(original, patch) {
|
|
|
77
77
|
const output = { ...o };
|
|
78
78
|
if (isObject(o) && isObject(p)) {
|
|
79
79
|
Object.keys(p).forEach((key) => {
|
|
80
|
-
if (isObject(p[key]))
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
else
|
|
84
|
-
output[key] = mergeDeep(o[key], p[key]);
|
|
85
|
-
} else {
|
|
80
|
+
if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key]))
|
|
81
|
+
output[key] = mergeDeep(o[key], p[key]);
|
|
82
|
+
else
|
|
86
83
|
Object.assign(output, { [key]: p[key] });
|
|
87
|
-
}
|
|
88
84
|
});
|
|
89
85
|
}
|
|
90
86
|
return output;
|
|
@@ -134,6 +130,7 @@ function mergeSet(target, append) {
|
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
const attributifyRE = /^\[(.+?)~?="(.*)"\]$/;
|
|
133
|
+
const cssIdRE = /\.(css|postcss|sass|scss|less|stylus|styl)$/;
|
|
137
134
|
const validateFilterRE = /(?!\d|-{2}|-\d)[a-zA-Z0-9\u00A0-\uFFFF-_:%-?]/;
|
|
138
135
|
const CONTROL_SHORTCUT_NO_MERGE = "$$shortcut-no-merge";
|
|
139
136
|
function isAttributifySelector(selector) {
|
|
@@ -370,6 +367,18 @@ const extractorSvelte = {
|
|
|
370
367
|
}
|
|
371
368
|
};
|
|
372
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
|
+
|
|
373
382
|
function resolveShortcuts(shortcuts) {
|
|
374
383
|
return toArray(shortcuts).flatMap((s) => {
|
|
375
384
|
if (Array.isArray(s))
|
|
@@ -443,7 +452,7 @@ function resolveConfig(userConfig = {}, defaults = {}) {
|
|
|
443
452
|
};
|
|
444
453
|
}
|
|
445
454
|
|
|
446
|
-
const version = "0.32.
|
|
455
|
+
const version = "0.32.11";
|
|
447
456
|
|
|
448
457
|
class UnoGenerator {
|
|
449
458
|
constructor(userConfig = {}, defaults = {}) {
|
|
@@ -453,7 +462,9 @@ class UnoGenerator {
|
|
|
453
462
|
this._cache = /* @__PURE__ */ new Map();
|
|
454
463
|
this.blocked = /* @__PURE__ */ new Set();
|
|
455
464
|
this.parentOrders = /* @__PURE__ */ new Map();
|
|
465
|
+
this.events = createNanoEvents();
|
|
456
466
|
this.config = resolveConfig(userConfig, defaults);
|
|
467
|
+
this.events.emit("config", this.config);
|
|
457
468
|
}
|
|
458
469
|
setConfig(userConfig, defaults) {
|
|
459
470
|
if (!userConfig)
|
|
@@ -461,10 +472,11 @@ class UnoGenerator {
|
|
|
461
472
|
if (defaults)
|
|
462
473
|
this.defaults = defaults;
|
|
463
474
|
this.userConfig = userConfig;
|
|
464
|
-
this.config = resolveConfig(userConfig, this.defaults);
|
|
465
475
|
this.blocked.clear();
|
|
466
476
|
this.parentOrders.clear();
|
|
467
477
|
this._cache.clear();
|
|
478
|
+
this.config = resolveConfig(userConfig, this.defaults);
|
|
479
|
+
this.events.emit("config", this.config);
|
|
468
480
|
}
|
|
469
481
|
async applyExtractors(code, id, set = /* @__PURE__ */ new Set()) {
|
|
470
482
|
const context = {
|
|
@@ -830,4 +842,4 @@ function toEscapedSelector(raw) {
|
|
|
830
842
|
return `.${e(raw)}`;
|
|
831
843
|
}
|
|
832
844
|
|
|
833
|
-
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,11 +38,11 @@
|
|
|
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": {
|
|
44
45
|
"build": "unbuild",
|
|
45
46
|
"stub": "unbuild --stub"
|
|
46
|
-
}
|
|
47
|
-
"readme": "# @unocss/core\n\nThe core engine of [UnoCSS](https://github.com/unocss/unocss) without any presets. It can be used as the engine of your own atomic CSS framework.\n\n## Usage\n\n```ts\nimport { createGenerator } from '@unocss/core'\n\nconst generator = createGenerator({ /* user options */ }, { /* default options */ })\n\nconst { css } = await generator.generate(code)\n```\n\n## License\n\nMIT License © 2021-PRESENT [Anthony Fu](https://github.com/antfu)\n\n"
|
|
47
|
+
}
|
|
48
48
|
}
|