@unocss/core 66.7.5 → 66.8.0-beta.1
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 +21 -9
- package/dist/index.mjs +160 -82
- package/package.json +3 -3
- package/LICENSE +0 -21
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import MagicString from "magic-string";
|
|
2
2
|
import { LoadConfigResult } from "unconfig";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/basic.d.ts
|
|
5
4
|
declare function toArray<T>(value?: T | T[]): T[];
|
|
6
5
|
declare function uniq<T>(value: T[]): T[];
|
|
@@ -44,7 +43,7 @@ declare class Emitter<Events extends EventsMap = DefaultEvents> {
|
|
|
44
43
|
* emitter2.events = { }
|
|
45
44
|
* ```
|
|
46
45
|
*/
|
|
47
|
-
events: Partial<{ [E in keyof Events]: Events[E][] }>;
|
|
46
|
+
events: Partial<{ [E in keyof Events]: Events[E][]; }>;
|
|
48
47
|
/**
|
|
49
48
|
* Add a listener for a given event.
|
|
50
49
|
*
|
|
@@ -171,16 +170,21 @@ declare class UnoGeneratorInternal<Theme extends object = object> {
|
|
|
171
170
|
config: (config: ResolvedConfig<Theme>) => void;
|
|
172
171
|
}>;
|
|
173
172
|
config: ResolvedConfig<Theme>;
|
|
174
|
-
|
|
175
|
-
blocked: Set<string>;
|
|
176
|
-
parentOrders: Map<string, number>;
|
|
177
|
-
activatedRules: Set<Rule<Theme>>;
|
|
173
|
+
private tokenProcessor;
|
|
178
174
|
protected constructor(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>);
|
|
179
175
|
static create<Theme extends object = object>(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<UnoGeneratorInternal<Theme>>;
|
|
180
176
|
setConfig(userConfig?: UserConfig<Theme>, defaults?: UserConfigDefaults<Theme>): Promise<void>;
|
|
181
177
|
applyExtractors(code: string, id?: string, extracted?: Set<string>): Promise<Set<string>>;
|
|
182
178
|
applyExtractors(code: string, id?: string, extracted?: CountableSet<string>): Promise<CountableSet<string>>;
|
|
183
179
|
makeContext(raw: string, applied: VariantMatchedResult<Theme>): RuleContext<Theme>;
|
|
180
|
+
/** @internal */
|
|
181
|
+
resetTokenProcessing(): void;
|
|
182
|
+
getParentOrder(parent: string): number | undefined;
|
|
183
|
+
getActivatedRules(): ReadonlySet<Rule<Theme>>;
|
|
184
|
+
getCachedTokens(input: string): string[];
|
|
185
|
+
getCachedAliases(token: string): string[] | undefined;
|
|
186
|
+
blockTokens(tokens: Iterable<string>): void;
|
|
187
|
+
invalidateToken(token: string): void;
|
|
184
188
|
parseToken(raw: string, alias?: string): Promise<StringifiedUtil<Theme>[] | undefined | null>;
|
|
185
189
|
generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<false>): Promise<GenerateResult<Set<string>>>;
|
|
186
190
|
generate(input: string | Set<string> | CountableSet<string> | string[], options?: GenerateOptions<true>): Promise<GenerateResult<Map<string, ExtendedTokenInfo<Theme>>>>;
|
|
@@ -213,8 +217,8 @@ type ToArray<T> = T extends (infer U)[] ? U[] : T[];
|
|
|
213
217
|
type ArgumentType<T> = T extends ((...args: infer A) => any) ? A : never;
|
|
214
218
|
type Shift<T> = T extends [_: any, ...args: infer A] ? A : never;
|
|
215
219
|
type RestArgs<T> = Shift<ArgumentType<T>>;
|
|
216
|
-
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]
|
|
217
|
-
type FlatObjectTuple<T> = { [K in keyof T]: T[K] };
|
|
220
|
+
type DeepPartial<T> = { [P in keyof T]?: DeepPartial<T[P]>; };
|
|
221
|
+
type FlatObjectTuple<T> = { [K in keyof T]: T[K]; };
|
|
218
222
|
type PartialByKeys<T, K extends keyof T = keyof T> = FlatObjectTuple<Partial<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
219
223
|
type RequiredByKey<T, K extends keyof T = keyof T> = FlatObjectTuple<Required<Pick<T, Extract<keyof T, K>>> & Omit<T, K>>;
|
|
220
224
|
type CSSObject = Record<string, string | number | undefined>;
|
|
@@ -335,7 +339,7 @@ interface ControlSymbolsValue {
|
|
|
335
339
|
[SymbolSort]: number;
|
|
336
340
|
[SymbolBody]: string;
|
|
337
341
|
}
|
|
338
|
-
type ObjectToEntry<T> = { [K in keyof T]: [K, T[K]] }[keyof T];
|
|
342
|
+
type ObjectToEntry<T> = { [K in keyof T]: [K, T[K]]; }[keyof T];
|
|
339
343
|
type ControlSymbolsEntry = ObjectToEntry<ControlSymbolsValue>;
|
|
340
344
|
interface VariantContext<Theme extends object = object> {
|
|
341
345
|
/**
|
|
@@ -788,6 +792,10 @@ interface Preset<Theme extends object = object> extends ConfigBase<Theme> {
|
|
|
788
792
|
* Custom metadata for the preset
|
|
789
793
|
*/
|
|
790
794
|
meta?: Record<string, any>;
|
|
795
|
+
/**
|
|
796
|
+
* Documentation URL for the preset
|
|
797
|
+
*/
|
|
798
|
+
docs?: string;
|
|
791
799
|
}
|
|
792
800
|
type PresetFactory<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Preset<Theme>;
|
|
793
801
|
type PresetFactoryAwaitable<Theme extends object = object, PresetOptions extends object | undefined = undefined> = (options?: PresetOptions) => Awaitable<Preset<Theme>>;
|
|
@@ -909,6 +917,10 @@ interface HighlightAnnotation {
|
|
|
909
917
|
type SourceCodeTransformerEnforce = 'pre' | 'post' | 'default';
|
|
910
918
|
interface SourceCodeTransformer {
|
|
911
919
|
name: string;
|
|
920
|
+
/**
|
|
921
|
+
* Documentation URL for the transformer
|
|
922
|
+
*/
|
|
923
|
+
docs?: string;
|
|
912
924
|
/**
|
|
913
925
|
* The order of transformer
|
|
914
926
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -252,9 +252,10 @@ function normalizeCSSEntries(obj) {
|
|
|
252
252
|
return (!Array.isArray(obj) ? Object.entries(obj) : obj).filter((i) => i[1] != null);
|
|
253
253
|
}
|
|
254
254
|
function normalizeCSSValues(obj) {
|
|
255
|
-
if (Array.isArray(obj))
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
if (Array.isArray(obj)) {
|
|
256
|
+
if (obj.some((i) => !Array.isArray(i) || Array.isArray(i[0]))) return obj.map((i) => normalizeCSSEntries(i));
|
|
257
|
+
else return [obj];
|
|
258
|
+
} else return [normalizeCSSEntries(obj)];
|
|
258
259
|
}
|
|
259
260
|
function clearIdenticalEntries(entry) {
|
|
260
261
|
return entry.filter(([k, v], idx) => {
|
|
@@ -277,8 +278,10 @@ function isObject(item) {
|
|
|
277
278
|
function mergeDeep(original, patch, mergeArray = false) {
|
|
278
279
|
const o = original;
|
|
279
280
|
const p = patch;
|
|
280
|
-
if (Array.isArray(p))
|
|
281
|
-
|
|
281
|
+
if (Array.isArray(p)) {
|
|
282
|
+
if (mergeArray && Array.isArray(p)) return [...o, ...p];
|
|
283
|
+
else return [...p];
|
|
284
|
+
}
|
|
282
285
|
const output = { ...o };
|
|
283
286
|
if (isObject(o) && isObject(p)) Object.keys(p).forEach((key) => {
|
|
284
287
|
if (isObject(o[key]) && isObject(p[key]) || Array.isArray(o[key]) && Array.isArray(p[key])) output[key] = mergeDeep(o[key], p[key], mergeArray);
|
|
@@ -628,7 +631,7 @@ function definePreset(preset) {
|
|
|
628
631
|
}
|
|
629
632
|
//#endregion
|
|
630
633
|
//#region package.json
|
|
631
|
-
var version = "66.
|
|
634
|
+
var version = "66.8.0-beta.1";
|
|
632
635
|
//#endregion
|
|
633
636
|
//#region src/generator.ts
|
|
634
637
|
const symbols = {
|
|
@@ -643,16 +646,91 @@ const symbols = {
|
|
|
643
646
|
body: "$$symbol-body"
|
|
644
647
|
};
|
|
645
648
|
const TOKEN_PARSE_BATCH_SIZE = 4096;
|
|
649
|
+
var TokenProcessor = class {
|
|
650
|
+
cache = /* @__PURE__ */ new Map();
|
|
651
|
+
blocked = /* @__PURE__ */ new Set();
|
|
652
|
+
parentOrders = /* @__PURE__ */ new Map();
|
|
653
|
+
activatedRules = /* @__PURE__ */ new Set();
|
|
654
|
+
async parse(generator, raw, alias) {
|
|
655
|
+
if (this.blocked.has(raw)) return;
|
|
656
|
+
const cacheKey = `${raw}${alias ? ` ${alias}` : ""}`;
|
|
657
|
+
if (this.cache.has(cacheKey)) return this.cache.get(cacheKey);
|
|
658
|
+
const current = generator.config.preprocess.reduce((acc, p) => p(acc) ?? acc, raw);
|
|
659
|
+
if (generator.isBlocked(current)) {
|
|
660
|
+
this.blocked.add(raw);
|
|
661
|
+
this.cache.set(cacheKey, null);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
const variantResults = await generator.matchVariants(raw, current);
|
|
665
|
+
if (variantResults.every((i) => !i || generator.isBlocked(i[1]))) {
|
|
666
|
+
this.blocked.add(raw);
|
|
667
|
+
this.cache.set(cacheKey, null);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
const data = (await Promise.all(variantResults.map(async (matched) => {
|
|
671
|
+
const context = generator.makeContext(raw, [
|
|
672
|
+
alias || matched[0],
|
|
673
|
+
matched[1],
|
|
674
|
+
matched[2],
|
|
675
|
+
matched[3]
|
|
676
|
+
]);
|
|
677
|
+
if (generator.config.details) context.variants = [...matched[3]];
|
|
678
|
+
const expanded = await generator.expandShortcut(context.currentSelector, context, 5, true);
|
|
679
|
+
return expanded ? await generator.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1]) : (await generator.parseUtil(context.variantMatch, context))?.flatMap((i) => generator.stringifyUtil(i, context)).filter(notNull);
|
|
680
|
+
}))).flat().filter(notNull);
|
|
681
|
+
this.cache.set(cacheKey, data.length ? data : null);
|
|
682
|
+
return data.length ? data : void 0;
|
|
683
|
+
}
|
|
684
|
+
isBlocked(raw, blocklist) {
|
|
685
|
+
if (!raw) return true;
|
|
686
|
+
for (const rule of blocklist) {
|
|
687
|
+
const value = Array.isArray(rule) ? rule[0] : rule;
|
|
688
|
+
if (typeof value === "function" ? value(raw) : isString(value) ? value === raw : value.test(raw)) return true;
|
|
689
|
+
}
|
|
690
|
+
return false;
|
|
691
|
+
}
|
|
692
|
+
getBlocked(raw, blocklist) {
|
|
693
|
+
const rule = blocklist.find((e) => {
|
|
694
|
+
const value = Array.isArray(e) ? e[0] : e;
|
|
695
|
+
return typeof value === "function" ? value(raw) : isString(value) ? value === raw : value.test(raw);
|
|
696
|
+
});
|
|
697
|
+
return rule ? Array.isArray(rule) ? rule : [rule, void 0] : void 0;
|
|
698
|
+
}
|
|
699
|
+
setParentOrder(parent, order) {
|
|
700
|
+
this.parentOrders.set(parent, order);
|
|
701
|
+
}
|
|
702
|
+
getParentOrder(parent) {
|
|
703
|
+
return this.parentOrders.get(parent);
|
|
704
|
+
}
|
|
705
|
+
activateRule(rule) {
|
|
706
|
+
this.activatedRules.add(rule);
|
|
707
|
+
}
|
|
708
|
+
getActivatedRules() {
|
|
709
|
+
return this.activatedRules;
|
|
710
|
+
}
|
|
711
|
+
getCachedTokens(input) {
|
|
712
|
+
return Array.from(this.cache).filter(([token, result]) => result && token.startsWith(input)).map(([token]) => token);
|
|
713
|
+
}
|
|
714
|
+
getCachedAliases(token) {
|
|
715
|
+
const target = this.cache.get(token);
|
|
716
|
+
if (!target) return;
|
|
717
|
+
return Array.from(this.cache).filter(([, utilities]) => utilities?.length === target.length && utilities.every((utility, index) => utility[2] === target[index][2])).map(([alias]) => alias);
|
|
718
|
+
}
|
|
719
|
+
block(tokens) {
|
|
720
|
+
for (const token of tokens) this.blocked.add(token);
|
|
721
|
+
}
|
|
722
|
+
invalidate(token) {
|
|
723
|
+
this.cache.delete(token);
|
|
724
|
+
this.blocked.delete(token);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
646
727
|
var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
647
728
|
userConfig;
|
|
648
729
|
defaults;
|
|
649
730
|
version = version;
|
|
650
731
|
events = createNanoEvents();
|
|
651
732
|
config = void 0;
|
|
652
|
-
|
|
653
|
-
blocked = /* @__PURE__ */ new Set();
|
|
654
|
-
parentOrders = /* @__PURE__ */ new Map();
|
|
655
|
-
activatedRules = /* @__PURE__ */ new Set();
|
|
733
|
+
tokenProcessor = new TokenProcessor();
|
|
656
734
|
constructor(userConfig = {}, defaults = {}) {
|
|
657
735
|
this.userConfig = userConfig;
|
|
658
736
|
this.defaults = defaults;
|
|
@@ -667,11 +745,8 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
667
745
|
if (!userConfig) return;
|
|
668
746
|
if (defaults) this.defaults = defaults;
|
|
669
747
|
this.userConfig = userConfig;
|
|
670
|
-
this.blocked.clear();
|
|
671
|
-
this.parentOrders.clear();
|
|
672
|
-
this.activatedRules.clear();
|
|
673
|
-
this.cache.clear();
|
|
674
748
|
this.config = await resolveConfig(userConfig, this.defaults);
|
|
749
|
+
this.resetTokenProcessing();
|
|
675
750
|
this.events.emit("config", this.config);
|
|
676
751
|
}
|
|
677
752
|
async applyExtractors(code, id, extracted = /* @__PURE__ */ new Set()) {
|
|
@@ -703,39 +778,30 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
703
778
|
};
|
|
704
779
|
return context;
|
|
705
780
|
}
|
|
781
|
+
/** @internal */
|
|
782
|
+
resetTokenProcessing() {
|
|
783
|
+
this.tokenProcessor = new TokenProcessor();
|
|
784
|
+
}
|
|
785
|
+
getParentOrder(parent) {
|
|
786
|
+
return this.tokenProcessor.getParentOrder(parent);
|
|
787
|
+
}
|
|
788
|
+
getActivatedRules() {
|
|
789
|
+
return new Set(this.tokenProcessor.getActivatedRules());
|
|
790
|
+
}
|
|
791
|
+
getCachedTokens(input) {
|
|
792
|
+
return this.tokenProcessor.getCachedTokens(input);
|
|
793
|
+
}
|
|
794
|
+
getCachedAliases(token) {
|
|
795
|
+
return this.tokenProcessor.getCachedAliases(token);
|
|
796
|
+
}
|
|
797
|
+
blockTokens(tokens) {
|
|
798
|
+
this.tokenProcessor.block(tokens);
|
|
799
|
+
}
|
|
800
|
+
invalidateToken(token) {
|
|
801
|
+
this.tokenProcessor.invalidate(token);
|
|
802
|
+
}
|
|
706
803
|
async parseToken(raw, alias) {
|
|
707
|
-
|
|
708
|
-
const cacheKey = `${raw}${alias ? ` ${alias}` : ""}`;
|
|
709
|
-
if (this.cache.has(cacheKey)) return this.cache.get(cacheKey);
|
|
710
|
-
const current = this.config.preprocess.reduce((acc, p) => p(acc) ?? acc, raw);
|
|
711
|
-
if (this.isBlocked(current)) {
|
|
712
|
-
this.blocked.add(raw);
|
|
713
|
-
this.cache.set(cacheKey, null);
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
const variantResults = await this.matchVariants(raw, current);
|
|
717
|
-
if (variantResults.every((i) => !i || this.isBlocked(i[1]))) {
|
|
718
|
-
this.blocked.add(raw);
|
|
719
|
-
this.cache.set(cacheKey, null);
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
const handleVariantResult = async (matched) => {
|
|
723
|
-
const context = this.makeContext(raw, [
|
|
724
|
-
alias || matched[0],
|
|
725
|
-
matched[1],
|
|
726
|
-
matched[2],
|
|
727
|
-
matched[3]
|
|
728
|
-
]);
|
|
729
|
-
if (this.config.details) context.variants = [...matched[3]];
|
|
730
|
-
const expanded = await this.expandShortcut(context.currentSelector, context, 5, true);
|
|
731
|
-
return expanded ? await this.stringifyShortcuts(context.variantMatch, context, expanded[0], expanded[1]) : (await this.parseUtil(context.variantMatch, context))?.flatMap((i) => this.stringifyUtil(i, context)).filter(notNull);
|
|
732
|
-
};
|
|
733
|
-
const result = (await Promise.all(variantResults.map((i) => handleVariantResult(i)))).flat().filter((x) => !!x);
|
|
734
|
-
if (result?.length) {
|
|
735
|
-
this.cache.set(cacheKey, result);
|
|
736
|
-
return result;
|
|
737
|
-
}
|
|
738
|
-
this.cache.set(cacheKey, null);
|
|
804
|
+
return this.tokenProcessor.parse(this, raw, alias);
|
|
739
805
|
}
|
|
740
806
|
async generate(input, options = {}) {
|
|
741
807
|
const { id, scope, preflights = true, safelist = true, minify = false, extendedInfo = false } = options;
|
|
@@ -757,23 +823,28 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
757
823
|
let preflightsMap = {};
|
|
758
824
|
const tokenList = Array.from(tokens);
|
|
759
825
|
for (let offset = 0; offset < tokenList.length; offset += TOKEN_PARSE_BATCH_SIZE) {
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
826
|
+
const batchSize = Math.min(TOKEN_PARSE_BATCH_SIZE, tokenList.length - offset);
|
|
827
|
+
const tokenPromises = [];
|
|
828
|
+
for (let index = 0; index < batchSize; index++) {
|
|
829
|
+
const raw = tokenList[offset + index];
|
|
830
|
+
tokenPromises[index] = (async () => {
|
|
831
|
+
if (matched.has(raw)) return;
|
|
832
|
+
const payload = await this.parseToken(raw);
|
|
833
|
+
if (payload == null) return;
|
|
834
|
+
if (matched instanceof Map) matched.set(raw, {
|
|
835
|
+
data: payload,
|
|
836
|
+
count: isCountableSet(tokens) ? tokens.getCount(raw) : -1
|
|
837
|
+
});
|
|
838
|
+
else matched.add(raw);
|
|
839
|
+
for (const item of payload) {
|
|
840
|
+
const parent = item[3] || "";
|
|
841
|
+
const layer = item[4]?.layer;
|
|
842
|
+
if (!sheet.has(parent)) sheet.set(parent, []);
|
|
843
|
+
sheet.get(parent).push(item);
|
|
844
|
+
if (layer) layerSet.add(layer);
|
|
845
|
+
}
|
|
846
|
+
})();
|
|
847
|
+
}
|
|
777
848
|
await Promise.all(tokenPromises);
|
|
778
849
|
}
|
|
779
850
|
await (async () => {
|
|
@@ -802,8 +873,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
802
873
|
};
|
|
803
874
|
const getLayer = (layer = LAYER_DEFAULT) => {
|
|
804
875
|
if (layerCache[layer]) return layerCache[layer];
|
|
805
|
-
let css = Array.from(sheet).sort((a, b) => (this.
|
|
806
|
-
const size = items.length;
|
|
876
|
+
let css = Array.from(sheet).sort((a, b) => (this.tokenProcessor.getParentOrder(a[0]) ?? 0) - (this.tokenProcessor.getParentOrder(b[0]) ?? 0) || a[0]?.localeCompare(b[0] || "") || 0).map(([parent, items]) => {
|
|
807
877
|
const sorted = items.filter((i) => (i[4]?.layer || "default") === layer).sort((a, b) => {
|
|
808
878
|
return a[0] - b[0] || (a[4]?.sort || 0) - (b[4]?.sort || 0) || a[5]?.currentSelector?.localeCompare(b[5]?.currentSelector ?? "") || a[1]?.localeCompare(b[1] || "") || a[2]?.localeCompare(b[2] || "") || 0;
|
|
809
879
|
}).map(([, selector, body, , meta, , variantNoMerge]) => {
|
|
@@ -814,14 +884,28 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
814
884
|
];
|
|
815
885
|
});
|
|
816
886
|
if (!sorted.length) return void 0;
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
887
|
+
sorted.reverse();
|
|
888
|
+
const mergedRules = /* @__PURE__ */ new Set();
|
|
889
|
+
if (this.config.mergeSelectors) {
|
|
890
|
+
const mergeIndex = /* @__PURE__ */ new Map();
|
|
891
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
892
|
+
const rule = sorted[i];
|
|
893
|
+
const [selectorSortPair, body, noMerge] = rule;
|
|
894
|
+
if (noMerge) continue;
|
|
895
|
+
const selectorIndex = selectorSortPair ? 1 : 0;
|
|
896
|
+
const candidates = mergeIndex.get(body) || [void 0, void 0];
|
|
897
|
+
const candidate = candidates[selectorIndex];
|
|
898
|
+
if (candidate) {
|
|
899
|
+
if (selectorSortPair && candidate[0]) candidate[0].push(...selectorSortPair);
|
|
900
|
+
mergedRules.add(rule);
|
|
901
|
+
} else {
|
|
902
|
+
candidates[selectorIndex] = rule;
|
|
903
|
+
mergeIndex.set(body, candidates);
|
|
823
904
|
}
|
|
824
905
|
}
|
|
906
|
+
}
|
|
907
|
+
const ruleLines = sorted.map(([selectorSortPair, body], idx) => {
|
|
908
|
+
if (mergedRules.has(sorted[idx])) return null;
|
|
825
909
|
const selectors = selectorSortPair ? uniq(selectorSortPair.sort((a, b) => a[1] - b[1] || a[0]?.localeCompare(b[0] || "") || 0).map((pair) => pair[0]).filter(Boolean)) : [];
|
|
826
910
|
return selectors.length ? `${selectors.join(`,${nl}`)}{${body}}` : body;
|
|
827
911
|
}).filter(Boolean);
|
|
@@ -944,7 +1028,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
944
1028
|
entries: parsed[2]
|
|
945
1029
|
});
|
|
946
1030
|
const { parent, parentOrder } = variantContextResult;
|
|
947
|
-
if (parent != null && parentOrder != null) this.
|
|
1031
|
+
if (parent != null && parentOrder != null) this.tokenProcessor.setParentOrder(parent, parentOrder);
|
|
948
1032
|
const obj = {
|
|
949
1033
|
selector: [
|
|
950
1034
|
variantContextResult.prefix,
|
|
@@ -1034,7 +1118,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
1034
1118
|
const entries = normalizeCSSValues(result).filter((i) => i.length);
|
|
1035
1119
|
if (entries.length) {
|
|
1036
1120
|
if (this.config.details) context.rules.push(rule);
|
|
1037
|
-
|
|
1121
|
+
this.tokenProcessor.activateRule(rule);
|
|
1038
1122
|
const meta = rule[2];
|
|
1039
1123
|
return entries.map((css) => {
|
|
1040
1124
|
if (isString(css)) return [
|
|
@@ -1076,9 +1160,7 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
1076
1160
|
case symbols.noScope:
|
|
1077
1161
|
setMeta({ noScope: entry[1] });
|
|
1078
1162
|
break;
|
|
1079
|
-
case symbols.body:
|
|
1080
|
-
entry[0] = VirtualKey;
|
|
1081
|
-
break;
|
|
1163
|
+
case symbols.body: entry[0] = VirtualKey;
|
|
1082
1164
|
}
|
|
1083
1165
|
return [
|
|
1084
1166
|
meta.__index,
|
|
@@ -1249,14 +1331,10 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
1249
1331
|
}).flat(2).filter(Boolean)));
|
|
1250
1332
|
}
|
|
1251
1333
|
isBlocked(raw) {
|
|
1252
|
-
return
|
|
1334
|
+
return this.tokenProcessor.isBlocked(raw, this.config.blocklist);
|
|
1253
1335
|
}
|
|
1254
1336
|
getBlocked(raw) {
|
|
1255
|
-
|
|
1256
|
-
const v = Array.isArray(e) ? e[0] : e;
|
|
1257
|
-
return typeof v === "function" ? v(raw) : isString(v) ? v === raw : v.test(raw);
|
|
1258
|
-
});
|
|
1259
|
-
return rule ? Array.isArray(rule) ? rule : [rule, void 0] : void 0;
|
|
1337
|
+
return this.tokenProcessor.getBlocked(raw, this.config.blocklist);
|
|
1260
1338
|
}
|
|
1261
1339
|
};
|
|
1262
1340
|
var UnoGenerator = class extends UnoGeneratorInternal {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "66.
|
|
4
|
+
"version": "66.8.0-beta.1",
|
|
5
5
|
"description": "The instant on-demand Atomic CSS engine.",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"magic-string": "^
|
|
36
|
+
"magic-string": "^1.2.0",
|
|
37
37
|
"unconfig": "^7.5.0"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
|
-
"bench": "pnpm --dir ../.. exec vitest bench packages-engine/core/test
|
|
40
|
+
"bench": "pnpm --dir ../.. exec vitest bench packages-engine/core/test --run --project unit",
|
|
41
41
|
"build": "tsdown",
|
|
42
42
|
"dev": "tsdown --watch"
|
|
43
43
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|