@unocss/core 66.5.12 → 66.6.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 +26 -0
- package/dist/index.mjs +12 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -695,6 +695,12 @@ interface OutputCssLayersOptions {
|
|
|
695
695
|
* Return `null` to specify that the layer should not be output to any css layer.
|
|
696
696
|
*/
|
|
697
697
|
cssLayerName?: (internalLayer: string) => string | undefined | null;
|
|
698
|
+
/**
|
|
699
|
+
* Force output all css layers, even if they are not used.
|
|
700
|
+
*
|
|
701
|
+
* @example `@layer theme, preflights, [unused-layer], default;`
|
|
702
|
+
*/
|
|
703
|
+
allLayers?: boolean;
|
|
698
704
|
}
|
|
699
705
|
type AutoCompleteTemplate = string;
|
|
700
706
|
type AutoCompleteFunction = (input: string) => Awaitable<string[]>;
|
|
@@ -1021,6 +1027,26 @@ type PreparedRule = readonly [selector: [string, number][], body: string, noMerg
|
|
|
1021
1027
|
interface CliEntryItem {
|
|
1022
1028
|
patterns: string[];
|
|
1023
1029
|
outFile: string;
|
|
1030
|
+
/**
|
|
1031
|
+
* Whether to rewrite the transformed utilities.
|
|
1032
|
+
*
|
|
1033
|
+
* - For css: if rewrite is true, it will not generate a new file, but directly modify the original file content.
|
|
1034
|
+
* - For other files: if rewrite is true, it replaces the original file with the transformed content.
|
|
1035
|
+
*
|
|
1036
|
+
* @default false
|
|
1037
|
+
*/
|
|
1038
|
+
rewrite?: boolean;
|
|
1039
|
+
/**
|
|
1040
|
+
* Whether to output CSS files scanned from patterns to outFile
|
|
1041
|
+
*
|
|
1042
|
+
* - false: Do not output CSS files
|
|
1043
|
+
* - true: Transform and output scanned CSS file contents to outFile
|
|
1044
|
+
* - 'multi': Output each CSS file separately with filename format `${originFile}-[hash]`
|
|
1045
|
+
* - 'single': Merge multiple CSS files into one output file named `outFile-merged.css`
|
|
1046
|
+
*
|
|
1047
|
+
* @default true
|
|
1048
|
+
*/
|
|
1049
|
+
splitCss?: boolean | 'multi' | 'single';
|
|
1024
1050
|
}
|
|
1025
1051
|
interface UtilObject {
|
|
1026
1052
|
selector: string;
|
package/dist/index.mjs
CHANGED
|
@@ -617,7 +617,7 @@ function definePreset(preset) {
|
|
|
617
617
|
|
|
618
618
|
//#endregion
|
|
619
619
|
//#region package.json
|
|
620
|
-
var version = "66.
|
|
620
|
+
var version = "66.6.0-beta.1";
|
|
621
621
|
|
|
622
622
|
//#endregion
|
|
623
623
|
//#region src/generator.ts
|
|
@@ -770,8 +770,8 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
770
770
|
theme: this.config.theme
|
|
771
771
|
};
|
|
772
772
|
this.config.safelist.flatMap((s) => typeof s === "function" ? s(safelistContext) : s).forEach((s) => {
|
|
773
|
-
const
|
|
774
|
-
if (
|
|
773
|
+
const trimmedS = s.trim();
|
|
774
|
+
if (trimmedS && !tokens.has(trimmedS)) tokens.add(trimmedS);
|
|
775
775
|
});
|
|
776
776
|
}
|
|
777
777
|
const nl = minify ? "" : "\n";
|
|
@@ -812,7 +812,8 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
812
812
|
return [layer, (await Promise.all(this.config.preflights.filter((i) => (i.layer || LAYER_PREFLIGHTS) === layer).map(async (i) => await i.getCSS(preflightContext)))).filter(Boolean).join(nl)];
|
|
813
813
|
})));
|
|
814
814
|
})();
|
|
815
|
-
const
|
|
815
|
+
const sortLayers = (layers$1) => this.config.sortLayers(layers$1.sort((a, b) => (this.config.layers[a] ?? 0) - (this.config.layers[b] ?? 0) || a.localeCompare(b)));
|
|
816
|
+
const layers = sortLayers(Array.from(layerSet));
|
|
816
817
|
const layerCache = {};
|
|
817
818
|
const outputCssLayers = this.config.outputToCssLayers;
|
|
818
819
|
const getLayerAlias = (layer) => {
|
|
@@ -861,7 +862,13 @@ var UnoGeneratorInternal = class UnoGeneratorInternal {
|
|
|
861
862
|
};
|
|
862
863
|
const getLayers = (includes = layers, excludes) => {
|
|
863
864
|
const layers$1 = includes.filter((i) => !excludes?.includes(i));
|
|
864
|
-
|
|
865
|
+
const css = layers$1.map(getLayer).filter(Boolean);
|
|
866
|
+
if (outputCssLayers) {
|
|
867
|
+
let layerNames = layers$1;
|
|
868
|
+
if (typeof outputCssLayers === "object" && outputCssLayers.allLayers) layerNames = sortLayers(Object.keys(this.config.layers));
|
|
869
|
+
if (layerNames.length > 0) css.unshift(`@layer ${layerNames.map(getLayerAlias).filter(notNull).join(", ")};`);
|
|
870
|
+
}
|
|
871
|
+
return css.join(nl);
|
|
865
872
|
};
|
|
866
873
|
const setLayer = async (layer, callback) => {
|
|
867
874
|
const content = await callback(getLayer(layer));
|