@unocss/core 0.65.2 → 0.65.3
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.d.mts +24 -9
- package/dist/index.d.ts +24 -9
- package/dist/index.mjs +20 -41
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -136,15 +136,15 @@ declare const symbols: ControlSymbols;
|
|
|
136
136
|
declare class UnoGeneratorInternal<Theme extends object = object> {
|
|
137
137
|
userConfig: UserConfig<Theme>;
|
|
138
138
|
defaults: UserConfigDefaults<Theme>;
|
|
139
|
-
version: string;
|
|
140
|
-
|
|
139
|
+
readonly version: string;
|
|
140
|
+
readonly events: Emitter<{
|
|
141
|
+
config: (config: ResolvedConfig<Theme>) => void;
|
|
142
|
+
}>;
|
|
141
143
|
config: ResolvedConfig<Theme>;
|
|
144
|
+
cache: Map<string, StringifiedUtil<Theme>[] | null>;
|
|
142
145
|
blocked: Set<string>;
|
|
143
146
|
parentOrders: Map<string, number>;
|
|
144
147
|
activatedRules: Set<Rule<Theme>>;
|
|
145
|
-
events: Emitter<{
|
|
146
|
-
config: (config: ResolvedConfig<Theme>) => void;
|
|
147
|
-
}>;
|
|
148
148
|
protected constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
|
|
149
149
|
static create<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<UnoGeneratorInternal<Theme>>;
|
|
150
150
|
setConfig(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<void>;
|
|
@@ -772,15 +772,29 @@ interface CliOptions {
|
|
|
772
772
|
};
|
|
773
773
|
}
|
|
774
774
|
interface UnocssPluginContext<Config extends UserConfig = UserConfig> {
|
|
775
|
+
/**
|
|
776
|
+
* Singleton promise for config loading
|
|
777
|
+
*/
|
|
775
778
|
ready: Promise<LoadConfigResult<Config>>;
|
|
779
|
+
/**
|
|
780
|
+
* The UnoCSS generator instance. Should be used after `ready` resolved.
|
|
781
|
+
*/
|
|
776
782
|
uno: UnoGenerator;
|
|
777
|
-
/**
|
|
783
|
+
/**
|
|
784
|
+
* All tokens scanned
|
|
785
|
+
*/
|
|
778
786
|
tokens: Set<string>;
|
|
779
|
-
/**
|
|
787
|
+
/**
|
|
788
|
+
* Map for all module's raw content
|
|
789
|
+
*/
|
|
780
790
|
modules: BetterMap<string, string>;
|
|
781
|
-
/**
|
|
791
|
+
/**
|
|
792
|
+
* Module IDs that been affected by UnoCSS
|
|
793
|
+
*/
|
|
782
794
|
affectedModules: Set<string>;
|
|
783
|
-
/**
|
|
795
|
+
/**
|
|
796
|
+
* Pending promises
|
|
797
|
+
*/
|
|
784
798
|
tasks: Promise<any>[];
|
|
785
799
|
/**
|
|
786
800
|
* Await all pending tasks
|
|
@@ -1060,6 +1074,7 @@ declare function resolveConfig<Theme extends object = object>(userConfig?: UserC
|
|
|
1060
1074
|
*/
|
|
1061
1075
|
declare function mergeConfigs<Theme extends object = object>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
|
|
1062
1076
|
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
|
|
1077
|
+
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactoryAwaitable<Theme, Options>): PresetFactoryAwaitable<Theme, Options>;
|
|
1063
1078
|
declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
|
|
1064
1079
|
|
|
1065
1080
|
declare const defaultSplitRE: RegExp;
|
package/dist/index.d.ts
CHANGED
|
@@ -136,15 +136,15 @@ declare const symbols: ControlSymbols;
|
|
|
136
136
|
declare class UnoGeneratorInternal<Theme extends object = object> {
|
|
137
137
|
userConfig: UserConfig<Theme>;
|
|
138
138
|
defaults: UserConfigDefaults<Theme>;
|
|
139
|
-
version: string;
|
|
140
|
-
|
|
139
|
+
readonly version: string;
|
|
140
|
+
readonly events: Emitter<{
|
|
141
|
+
config: (config: ResolvedConfig<Theme>) => void;
|
|
142
|
+
}>;
|
|
141
143
|
config: ResolvedConfig<Theme>;
|
|
144
|
+
cache: Map<string, StringifiedUtil<Theme>[] | null>;
|
|
142
145
|
blocked: Set<string>;
|
|
143
146
|
parentOrders: Map<string, number>;
|
|
144
147
|
activatedRules: Set<Rule<Theme>>;
|
|
145
|
-
events: Emitter<{
|
|
146
|
-
config: (config: ResolvedConfig<Theme>) => void;
|
|
147
|
-
}>;
|
|
148
148
|
protected constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
|
|
149
149
|
static create<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<UnoGeneratorInternal<Theme>>;
|
|
150
150
|
setConfig(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<void>;
|
|
@@ -772,15 +772,29 @@ interface CliOptions {
|
|
|
772
772
|
};
|
|
773
773
|
}
|
|
774
774
|
interface UnocssPluginContext<Config extends UserConfig = UserConfig> {
|
|
775
|
+
/**
|
|
776
|
+
* Singleton promise for config loading
|
|
777
|
+
*/
|
|
775
778
|
ready: Promise<LoadConfigResult<Config>>;
|
|
779
|
+
/**
|
|
780
|
+
* The UnoCSS generator instance. Should be used after `ready` resolved.
|
|
781
|
+
*/
|
|
776
782
|
uno: UnoGenerator;
|
|
777
|
-
/**
|
|
783
|
+
/**
|
|
784
|
+
* All tokens scanned
|
|
785
|
+
*/
|
|
778
786
|
tokens: Set<string>;
|
|
779
|
-
/**
|
|
787
|
+
/**
|
|
788
|
+
* Map for all module's raw content
|
|
789
|
+
*/
|
|
780
790
|
modules: BetterMap<string, string>;
|
|
781
|
-
/**
|
|
791
|
+
/**
|
|
792
|
+
* Module IDs that been affected by UnoCSS
|
|
793
|
+
*/
|
|
782
794
|
affectedModules: Set<string>;
|
|
783
|
-
/**
|
|
795
|
+
/**
|
|
796
|
+
* Pending promises
|
|
797
|
+
*/
|
|
784
798
|
tasks: Promise<any>[];
|
|
785
799
|
/**
|
|
786
800
|
* Await all pending tasks
|
|
@@ -1060,6 +1074,7 @@ declare function resolveConfig<Theme extends object = object>(userConfig?: UserC
|
|
|
1060
1074
|
*/
|
|
1061
1075
|
declare function mergeConfigs<Theme extends object = object>(configs: UserConfig<Theme>[]): UserConfig<Theme>;
|
|
1062
1076
|
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactory<Theme, Options>): PresetFactory<Theme, Options>;
|
|
1077
|
+
declare function definePreset<Options extends object | undefined = undefined, Theme extends object = object>(preset: PresetFactoryAwaitable<Theme, Options>): PresetFactoryAwaitable<Theme, Options>;
|
|
1063
1078
|
declare function definePreset<Theme extends object = object>(preset: Preset<Theme>): Preset<Theme>;
|
|
1064
1079
|
|
|
1065
1080
|
declare const defaultSplitRE: RegExp;
|
package/dist/index.mjs
CHANGED
|
@@ -40,20 +40,14 @@ function isString(s) {
|
|
|
40
40
|
return typeof s === "string";
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
var __defProp$2 = Object.defineProperty;
|
|
44
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
45
|
-
var __publicField$2 = (obj, key, value) => {
|
|
46
|
-
__defNormalProp$2(obj, key + "" , value);
|
|
47
|
-
return value;
|
|
48
|
-
};
|
|
49
43
|
class CountableSet extends Set {
|
|
44
|
+
_map;
|
|
50
45
|
constructor(values) {
|
|
51
46
|
super(values);
|
|
52
|
-
|
|
53
|
-
this._map ?? (this._map = /* @__PURE__ */ new Map());
|
|
47
|
+
this._map ??= /* @__PURE__ */ new Map();
|
|
54
48
|
}
|
|
55
49
|
add(key) {
|
|
56
|
-
this._map
|
|
50
|
+
this._map ??= /* @__PURE__ */ new Map();
|
|
57
51
|
this._map.set(key, (this._map.get(key) ?? 0) + 1);
|
|
58
52
|
return super.add(key);
|
|
59
53
|
}
|
|
@@ -157,16 +151,8 @@ function withLayer(layer, rules) {
|
|
|
157
151
|
return rules;
|
|
158
152
|
}
|
|
159
153
|
|
|
160
|
-
var __defProp$1 = Object.defineProperty;
|
|
161
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
162
|
-
var __publicField$1 = (obj, key, value) => {
|
|
163
|
-
__defNormalProp$1(obj, key + "" , value);
|
|
164
|
-
return value;
|
|
165
|
-
};
|
|
166
154
|
class TwoKeyMap {
|
|
167
|
-
|
|
168
|
-
__publicField$1(this, "_map", /* @__PURE__ */ new Map());
|
|
169
|
-
}
|
|
155
|
+
_map = /* @__PURE__ */ new Map();
|
|
170
156
|
get(key1, key2) {
|
|
171
157
|
const m2 = this._map.get(key1);
|
|
172
158
|
if (m2)
|
|
@@ -289,8 +275,7 @@ function clone(val) {
|
|
|
289
275
|
let k, out, tmp;
|
|
290
276
|
if (Array.isArray(val)) {
|
|
291
277
|
out = Array.from({ length: k = val.length });
|
|
292
|
-
while (k--)
|
|
293
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
|
|
278
|
+
while (k--) out[k] = (tmp = val[k]) && typeof tmp === "object" ? clone(tmp) : tmp;
|
|
294
279
|
return out;
|
|
295
280
|
}
|
|
296
281
|
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
@@ -653,7 +638,7 @@ function definePreset(preset) {
|
|
|
653
638
|
return preset;
|
|
654
639
|
}
|
|
655
640
|
|
|
656
|
-
const version = "0.65.
|
|
641
|
+
const version = "0.65.3";
|
|
657
642
|
|
|
658
643
|
function createNanoEvents() {
|
|
659
644
|
return {
|
|
@@ -668,12 +653,6 @@ function createNanoEvents() {
|
|
|
668
653
|
};
|
|
669
654
|
}
|
|
670
655
|
|
|
671
|
-
var __defProp = Object.defineProperty;
|
|
672
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
673
|
-
var __publicField = (obj, key, value) => {
|
|
674
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
675
|
-
return value;
|
|
676
|
-
};
|
|
677
656
|
const symbols = {
|
|
678
657
|
shortcutsNoMerge: "$$symbol-shortcut-no-merge",
|
|
679
658
|
variants: "$$symbol-variants",
|
|
@@ -686,14 +665,14 @@ class UnoGeneratorInternal {
|
|
|
686
665
|
constructor(userConfig = {}, defaults = {}) {
|
|
687
666
|
this.userConfig = userConfig;
|
|
688
667
|
this.defaults = defaults;
|
|
689
|
-
__publicField(this, "version", version);
|
|
690
|
-
__publicField(this, "_cache", /* @__PURE__ */ new Map());
|
|
691
|
-
__publicField(this, "config");
|
|
692
|
-
__publicField(this, "blocked", /* @__PURE__ */ new Set());
|
|
693
|
-
__publicField(this, "parentOrders", /* @__PURE__ */ new Map());
|
|
694
|
-
__publicField(this, "activatedRules", /* @__PURE__ */ new Set());
|
|
695
|
-
__publicField(this, "events", createNanoEvents());
|
|
696
668
|
}
|
|
669
|
+
version = version;
|
|
670
|
+
events = createNanoEvents();
|
|
671
|
+
config = void 0;
|
|
672
|
+
cache = /* @__PURE__ */ new Map();
|
|
673
|
+
blocked = /* @__PURE__ */ new Set();
|
|
674
|
+
parentOrders = /* @__PURE__ */ new Map();
|
|
675
|
+
activatedRules = /* @__PURE__ */ new Set();
|
|
697
676
|
static async create(userConfig = {}, defaults = {}) {
|
|
698
677
|
const uno = new UnoGeneratorInternal(userConfig, defaults);
|
|
699
678
|
uno.config = await resolveConfig(uno.userConfig, uno.defaults);
|
|
@@ -709,7 +688,7 @@ class UnoGeneratorInternal {
|
|
|
709
688
|
this.blocked.clear();
|
|
710
689
|
this.parentOrders.clear();
|
|
711
690
|
this.activatedRules.clear();
|
|
712
|
-
this.
|
|
691
|
+
this.cache.clear();
|
|
713
692
|
this.config = await resolveConfig(userConfig, this.defaults);
|
|
714
693
|
this.events.emit("config", this.config);
|
|
715
694
|
}
|
|
@@ -752,20 +731,20 @@ class UnoGeneratorInternal {
|
|
|
752
731
|
if (this.blocked.has(raw))
|
|
753
732
|
return;
|
|
754
733
|
const cacheKey = `${raw}${alias ? ` ${alias}` : ""}`;
|
|
755
|
-
if (this.
|
|
756
|
-
return this.
|
|
734
|
+
if (this.cache.has(cacheKey))
|
|
735
|
+
return this.cache.get(cacheKey);
|
|
757
736
|
let current = raw;
|
|
758
737
|
for (const p of this.config.preprocess)
|
|
759
738
|
current = p(raw);
|
|
760
739
|
if (this.isBlocked(current)) {
|
|
761
740
|
this.blocked.add(raw);
|
|
762
|
-
this.
|
|
741
|
+
this.cache.set(cacheKey, null);
|
|
763
742
|
return;
|
|
764
743
|
}
|
|
765
744
|
const variantResults = await this.matchVariants(raw, current);
|
|
766
745
|
if (variantResults.every((i) => !i || this.isBlocked(i[1]))) {
|
|
767
746
|
this.blocked.add(raw);
|
|
768
|
-
this.
|
|
747
|
+
this.cache.set(cacheKey, null);
|
|
769
748
|
return;
|
|
770
749
|
}
|
|
771
750
|
const handleVariantResult = async (matched) => {
|
|
@@ -778,10 +757,10 @@ class UnoGeneratorInternal {
|
|
|
778
757
|
};
|
|
779
758
|
const result = (await Promise.all(variantResults.map((i) => handleVariantResult(i)))).flat().filter((x) => !!x);
|
|
780
759
|
if (result?.length) {
|
|
781
|
-
this.
|
|
760
|
+
this.cache.set(cacheKey, result);
|
|
782
761
|
return result;
|
|
783
762
|
}
|
|
784
|
-
this.
|
|
763
|
+
this.cache.set(cacheKey, null);
|
|
785
764
|
}
|
|
786
765
|
async generate(input, options = {}) {
|
|
787
766
|
const {
|