@unocss/nuxt 66.5.10-beta.1 → 66.5.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 +176 -0
- package/dist/index.d.cts +1743 -0
- package/dist/index.d.mts +1713 -93
- package/dist/index.mjs +128 -150
- package/package.json +25 -22
- package/dist/index.d.ts +0 -123
- package/index.cjs +0 -10
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
let node_path = require("node:path");
|
|
29
|
+
let node_process = require("node:process");
|
|
30
|
+
node_process = __toESM(node_process);
|
|
31
|
+
let node_url = require("node:url");
|
|
32
|
+
let _nuxt_kit = require("@nuxt/kit");
|
|
33
|
+
let _unocss_config = require("@unocss/config");
|
|
34
|
+
let _unocss_core = require("@unocss/core");
|
|
35
|
+
let _unocss_preset_attributify = require("@unocss/preset-attributify");
|
|
36
|
+
_unocss_preset_attributify = __toESM(_unocss_preset_attributify);
|
|
37
|
+
let _unocss_preset_icons = require("@unocss/preset-icons");
|
|
38
|
+
_unocss_preset_icons = __toESM(_unocss_preset_icons);
|
|
39
|
+
let _unocss_preset_tagify = require("@unocss/preset-tagify");
|
|
40
|
+
_unocss_preset_tagify = __toESM(_unocss_preset_tagify);
|
|
41
|
+
let _unocss_preset_typography = require("@unocss/preset-typography");
|
|
42
|
+
_unocss_preset_typography = __toESM(_unocss_preset_typography);
|
|
43
|
+
let _unocss_preset_web_fonts = require("@unocss/preset-web-fonts");
|
|
44
|
+
_unocss_preset_web_fonts = __toESM(_unocss_preset_web_fonts);
|
|
45
|
+
let _unocss_preset_wind3 = require("@unocss/preset-wind3");
|
|
46
|
+
_unocss_preset_wind3 = __toESM(_unocss_preset_wind3);
|
|
47
|
+
let _unocss_preset_wind4 = require("@unocss/preset-wind4");
|
|
48
|
+
_unocss_preset_wind4 = __toESM(_unocss_preset_wind4);
|
|
49
|
+
|
|
50
|
+
//#region ../../virtual-shared/integration/src/defaults.ts
|
|
51
|
+
const defaultPipelineExclude = [_unocss_core.cssIdRE];
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/options.ts
|
|
55
|
+
function resolveOptions(options) {
|
|
56
|
+
if (options.wind3 && options.wind4) {
|
|
57
|
+
console.warn("[unocss/nuxt]: wind3 and wind4 presets are mutually exclusive. wind3 will be disabled in favor of wind4.");
|
|
58
|
+
options.wind3 = false;
|
|
59
|
+
}
|
|
60
|
+
if (options.presets == null) {
|
|
61
|
+
options.presets = [];
|
|
62
|
+
const presetMap = {
|
|
63
|
+
wind3: _unocss_preset_wind3.default,
|
|
64
|
+
wind4: _unocss_preset_wind4.default,
|
|
65
|
+
attributify: _unocss_preset_attributify.default,
|
|
66
|
+
icons: _unocss_preset_icons.default,
|
|
67
|
+
webFonts: _unocss_preset_web_fonts.default,
|
|
68
|
+
typography: _unocss_preset_typography.default,
|
|
69
|
+
tagify: _unocss_preset_tagify.default
|
|
70
|
+
};
|
|
71
|
+
for (const [key, preset] of Object.entries(presetMap)) {
|
|
72
|
+
const option = options[key];
|
|
73
|
+
if (option) options.presets.push(preset(typeof option === "boolean" ? {} : option));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
options.content ??= {};
|
|
77
|
+
options.content.pipeline ??= {};
|
|
78
|
+
if (options.content.pipeline !== false) {
|
|
79
|
+
options.content.pipeline.exclude ??= defaultPipelineExclude;
|
|
80
|
+
if (Array.isArray(options.content.pipeline.exclude)) options.content.pipeline.exclude.push(/\?macro=true/);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/index.ts
|
|
86
|
+
const dir = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
87
|
+
var src_default = (0, _nuxt_kit.defineNuxtModule)({
|
|
88
|
+
meta: {
|
|
89
|
+
name: "unocss",
|
|
90
|
+
configKey: "unocss"
|
|
91
|
+
},
|
|
92
|
+
defaults: {
|
|
93
|
+
mode: "global",
|
|
94
|
+
autoImport: true,
|
|
95
|
+
preflight: false,
|
|
96
|
+
components: true,
|
|
97
|
+
disableNuxtInlineStyle: true,
|
|
98
|
+
nuxtLayers: false,
|
|
99
|
+
attributify: false,
|
|
100
|
+
webFonts: false,
|
|
101
|
+
icons: false,
|
|
102
|
+
wind3: true,
|
|
103
|
+
wind4: false
|
|
104
|
+
},
|
|
105
|
+
async setup(options, nuxt) {
|
|
106
|
+
resolveOptions(options);
|
|
107
|
+
const loadConfig = (0, _unocss_config.createRecoveryConfigLoader)();
|
|
108
|
+
options.mode ??= "global";
|
|
109
|
+
const InjectModes = ["global", "dist-chunk"];
|
|
110
|
+
if (options.disableNuxtInlineStyle) {
|
|
111
|
+
nuxt.options.features ||= {};
|
|
112
|
+
nuxt.options.features.inlineStyles = false;
|
|
113
|
+
}
|
|
114
|
+
if (options.injectPosition != null) console.warn("[unocss/nuxt] options `injectPosition` is temporary removed due to the incompatibility with Nuxt 3.9. We are seeking for better solution. It's not effective at this moment.");
|
|
115
|
+
if (options.autoImport) (0, _nuxt_kit.addPluginTemplate)({
|
|
116
|
+
filename: "unocss.mjs",
|
|
117
|
+
getContents: () => {
|
|
118
|
+
const lines = [InjectModes.includes(options.mode) ? "import 'uno.css'" : "", "import { defineNuxtPlugin } from '#imports'; export default defineNuxtPlugin(() => {})"];
|
|
119
|
+
if (options.preflight) lines.unshift("import '@unocss/reset/tailwind.css'");
|
|
120
|
+
return lines.join("\n");
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
if (options.components) (0, _nuxt_kit.addComponentsDir)({
|
|
124
|
+
path: (0, node_path.resolve)(dir, "../runtime"),
|
|
125
|
+
watch: false
|
|
126
|
+
});
|
|
127
|
+
if (options.nuxtLayers) (0, _nuxt_kit.addTemplate)({
|
|
128
|
+
filename: "uno.config.mjs",
|
|
129
|
+
async getContents() {
|
|
130
|
+
const configPaths = (await Promise.all(nuxt.options._layers.slice(1).map((layer) => (0, _nuxt_kit.findPath)(options.configFile || ["uno.config", "unocss.config"], { cwd: layer.config.rootDir })))).filter(Boolean).reverse();
|
|
131
|
+
return `import { mergeConfigs } from '@unocss/core'
|
|
132
|
+
${configPaths.map((path, index) => `import cfg${index} from '${path}'`.trimStart()).join("\n").trimEnd()}
|
|
133
|
+
|
|
134
|
+
export default mergeConfigs([${configPaths.map((_, index) => `cfg${index}`).join(", ")}])
|
|
135
|
+
`;
|
|
136
|
+
},
|
|
137
|
+
write: true
|
|
138
|
+
});
|
|
139
|
+
nuxt.hook("build:before", async () => {
|
|
140
|
+
const { config: unoConfig } = await loadConfig(node_process.default.cwd(), { configFile: options.configFile }, [], options);
|
|
141
|
+
if ((0, _nuxt_kit.isNuxtMajorVersion)(3, nuxt) && nuxt.options.builder === "@nuxt/vite-builder" && nuxt.options.postcss.plugins.cssnano && unoConfig.transformers?.some((t) => t.name === "@unocss/transformer-directives" && t.enforce !== "pre")) {
|
|
142
|
+
const preset = nuxt.options.postcss.plugins.cssnano.preset;
|
|
143
|
+
nuxt.options.postcss.plugins.cssnano = { preset: [preset?.[0] || "default", Object.assign({
|
|
144
|
+
mergeRules: false,
|
|
145
|
+
normalizeWhitespace: false,
|
|
146
|
+
discardComments: false
|
|
147
|
+
}, preset?.[1])] };
|
|
148
|
+
}
|
|
149
|
+
await nuxt.callHook("unocss:config", unoConfig);
|
|
150
|
+
(0, _nuxt_kit.extendViteConfig)(async (config) => {
|
|
151
|
+
const { default: VitePlugin } = await import("@unocss/vite");
|
|
152
|
+
config.plugins = config.plugins || [];
|
|
153
|
+
config.plugins.unshift(...VitePlugin({ mode: options.mode }, unoConfig));
|
|
154
|
+
});
|
|
155
|
+
(0, _nuxt_kit.extendWebpackConfig)(async (config) => {
|
|
156
|
+
const { default: WebpackPlugin } = await import("@unocss/webpack");
|
|
157
|
+
config.plugins = config.plugins || [];
|
|
158
|
+
config.plugins.unshift(WebpackPlugin({}, unoConfig));
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
if (nuxt.options.dev) nuxt.hook("devtools:customTabs", (tabs) => {
|
|
162
|
+
tabs.push({
|
|
163
|
+
title: "UnoCSS",
|
|
164
|
+
name: "unocss",
|
|
165
|
+
icon: "/__unocss/favicon.svg",
|
|
166
|
+
view: {
|
|
167
|
+
type: "iframe",
|
|
168
|
+
src: "/__unocss/"
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
module.exports = src_default;
|