@univa/core 0.0.5 → 0.0.7

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.js CHANGED
@@ -1,333 +1,359 @@
1
+ // src/config/index.ts
2
+ function defineConfig(config) {
3
+ return config;
4
+ }
5
+
1
6
  // src/plugins/index.ts
2
7
  import Uni from "@uni-helper/plugin-uni";
3
- import UniHelperLayouts from "@uni-helper/vite-plugin-uni-layouts";
4
- import UniOptimization from "@uni-ku/bundle-optimizer";
5
- import UnivaRoot from "@univa/root";
6
- import UniPolyfill from "vite-plugin-uni-polyfill";
8
+ import VitePluginUniComponents from "@uni-helper/vite-plugin-uni-components";
9
+ import { VitePluginUniLayouts } from "@uni-helper/vite-plugin-uni-layouts";
10
+ import UniKuRoot from "@uni-ku/root";
11
+ import UnoCSS from "unocss/vite";
12
+ import AutoImport from "unplugin-auto-import/vite";
7
13
 
8
14
  // src/constant.ts
9
- var DTS_DIR = "./.univa";
10
- var COMPONENT_ASYNC_ROOT = "components-async";
15
+ var ID = "univa";
16
+ var UNIVA_DIR_NAME = `.${ID}`;
11
17
 
12
- // src/plugins/autoImport.ts
13
- import AutoImport from "unplugin-auto-import/vite";
14
- function createAutoImportPlugin(options) {
15
- const defaultAutoImportOptions = {
16
- imports: [
17
- "vue",
18
- "pinia",
19
- "uni-app",
20
- {
21
- from: "@univa/core/hooks",
22
- imports: ["usePageContext"]
23
- }
24
- ],
25
- dirs: [
26
- "src/hooks/**",
27
- "!src/hooks/**/_*/**",
28
- "src/store/**",
29
- "!src/store/**/_*/**",
30
- "src/constants/**"
31
- ],
32
- vueTemplate: true,
33
- dts: `${DTS_DIR}/auto-imports.d.ts`
34
- };
35
- const userAutoImportOptions = typeof options.autoImport === "object" ? options.autoImport : {};
36
- const mergedOptions = {
37
- ...defaultAutoImportOptions,
38
- ...userAutoImportOptions
39
- };
40
- if (userAutoImportOptions.imports) {
41
- const userImports = Array.isArray(userAutoImportOptions.imports) ? userAutoImportOptions.imports : [userAutoImportOptions.imports];
42
- mergedOptions.imports = [...defaultAutoImportOptions.imports, ...userImports];
43
- }
44
- if (userAutoImportOptions.dirs) {
45
- const userDirs = Array.isArray(userAutoImportOptions.dirs) ? userAutoImportOptions.dirs : [userAutoImportOptions.dirs];
46
- mergedOptions.dirs = [...defaultAutoImportOptions.dirs, ...userDirs];
18
+ // src/utils/fs.ts
19
+ import { existsSync, mkdirSync } from "fs";
20
+ import { join } from "path";
21
+ function ensureDir(dir) {
22
+ if (!existsSync(dir)) {
23
+ mkdirSync(dir, { recursive: true });
47
24
  }
48
- return AutoImport(mergedOptions);
25
+ }
26
+ function getUnivaDir(cwd) {
27
+ return join(cwd, UNIVA_DIR_NAME);
28
+ }
29
+ function ensureUnivaDir(cwd) {
30
+ const dir = getUnivaDir(cwd);
31
+ ensureDir(dir);
32
+ return dir;
49
33
  }
50
34
 
51
- // src/plugins/components.ts
52
- import UniHelperComponents from "@uni-helper/vite-plugin-uni-components";
53
- function createComponentsPlugin(options) {
54
- const defaultComponentsOptions = {
55
- dirs: ["src/components", "src/components-biz"],
56
- exclude: ["**/components/**/*.*"],
57
- directoryAsNamespace: true,
58
- globalNamespaces: ["components", "common"],
59
- dts: `${DTS_DIR}/components.d.ts`
60
- };
61
- const userComponentsOptions = typeof options.components === "object" ? options.components : {};
62
- const mergedOptions = {
63
- ...defaultComponentsOptions,
64
- ...userComponentsOptions
65
- };
66
- if (userComponentsOptions.dirs) {
67
- const userDirs = Array.isArray(userComponentsOptions.dirs) ? userComponentsOptions.dirs : [userComponentsOptions.dirs];
68
- mergedOptions.dirs = [...defaultComponentsOptions.dirs, ...userDirs];
69
- }
70
- if (userComponentsOptions.exclude) {
71
- const userExclude = Array.isArray(userComponentsOptions.exclude) ? userComponentsOptions.exclude : [userComponentsOptions.exclude];
72
- mergedOptions.exclude = [...defaultComponentsOptions.exclude, ...userExclude];
73
- }
74
- if (userComponentsOptions.globalNamespaces) {
75
- const userGlobalNamespaces = Array.isArray(userComponentsOptions.globalNamespaces) ? userComponentsOptions.globalNamespaces : [userComponentsOptions.globalNamespaces];
76
- mergedOptions.globalNamespaces = [...defaultComponentsOptions.globalNamespaces, ...userGlobalNamespaces];
35
+ // src/plugins/context.ts
36
+ import { existsSync as existsSync3, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
37
+ import { join as join3 } from "path";
38
+ import { slash } from "@antfu/utils";
39
+ import { loadConfig } from "c12";
40
+ import { createJiti } from "jiti";
41
+
42
+ // src/utils/merge.ts
43
+ import { createDefu } from "defu";
44
+ var mergeWithArrayOverride = createDefu((originObj, key, updates) => {
45
+ if (Array.isArray(originObj[key]) && Array.isArray(updates)) {
46
+ originObj[key] = updates;
47
+ return true;
77
48
  }
78
- return UniHelperComponents(mergedOptions);
79
- }
49
+ });
80
50
 
81
- // src/plugins/manifest.ts
82
- import { VitePluginUniManifest } from "@univa/manifest";
83
- function createManifestPlugin(options) {
84
- return VitePluginUniManifest({
85
- rewrite: (config) => {
86
- return options?.manifest || config;
51
+ // src/plugins/pages.ts
52
+ import { existsSync as existsSync2, readFileSync, writeFileSync } from "fs";
53
+ import { join as join2 } from "path";
54
+ import { VitePluginUniPages } from "@uni-helper/vite-plugin-uni-pages";
55
+ function getPagesConfigPath(root) {
56
+ return join2(getUnivaDir(root), "pages-config.ts");
57
+ }
58
+ function generatePagesConfigContent(content) {
59
+ const { pages, subPackages, ...rest } = content;
60
+ void pages;
61
+ void subPackages;
62
+ return `// Auto-generated by @univa/core
63
+ // \u6765\u6E90\uFF1Auniva.config.ts \u7684 pages \u5B57\u6BB5
64
+ export default ${JSON.stringify(rest, null, 2)}
65
+ `;
66
+ }
67
+ function generatePagesConfigFile(content, root) {
68
+ const pagesConfigPath = getPagesConfigPath(root);
69
+ const newContent = generatePagesConfigContent(content);
70
+ if (existsSync2(pagesConfigPath)) {
71
+ const existingContent = readFileSync(pagesConfigPath, "utf-8");
72
+ if (existingContent === newContent) {
73
+ return;
87
74
  }
75
+ }
76
+ writeFileSync(pagesConfigPath, newContent, "utf-8");
77
+ }
78
+ function createPagesPlugin(pluginOptions) {
79
+ const result = VitePluginUniPages({
80
+ dts: `${UNIVA_DIR_NAME}/uni-pages.d.ts`,
81
+ exclude: ["**/components/**/*.*"],
82
+ configSource: `${UNIVA_DIR_NAME}/pages-config.ts`,
83
+ ...pluginOptions
88
84
  });
85
+ return Array.isArray(result) ? result : [result];
89
86
  }
90
87
 
91
- // src/plugins/pages.ts
92
- import UniHelperPages from "@uni-helper/vite-plugin-uni-pages";
93
- function _pathToName(path, partToReplace = "", prefix = "") {
94
- const parts = path.replace(/\.\w+$/, "").split("/").filter(Boolean);
95
- const toPascalCase = (parts2) => {
96
- return parts2.map(
97
- (part) => part.split("-").map((subPart) => subPart.charAt(0).toUpperCase() + subPart.slice(1)).join("")
98
- ).join("");
99
- };
100
- if (!partToReplace) {
101
- return toPascalCase(parts);
102
- }
103
- const indexToReplace = parts.findIndex((part) => part.toLowerCase() === partToReplace.toLowerCase());
104
- if (indexToReplace === -1) {
105
- return prefix + toPascalCase(parts);
88
+ // src/plugins/context.ts
89
+ var DEFAULT_ROOT_FILE_NAME = "App.ku.vue";
90
+ var APP_KU_VUE_TEMPLATE = `<!-- Auto-generated by @univa/core -->
91
+ <!-- UniKuRoot \u865A\u62DF\u6839\u7EC4\u4EF6\uFF0C\u53EF\u5728\u6B64\u6DFB\u52A0\u5168\u5C40\u7EC4\u4EF6\uFF08\u5982 Toast\u3001ConfigProvider \u7B49\uFF09 -->
92
+ <template>
93
+ <KuRootView />
94
+ </template>
95
+ `;
96
+ function ensureRootComponent(config, root) {
97
+ const srcDir = config?.srcDir || "src";
98
+ const rootFileName = config?.overrides?.root?.rootFileName || DEFAULT_ROOT_FILE_NAME;
99
+ const rootComponentPath = join3(root, srcDir, rootFileName);
100
+ if (existsSync3(rootComponentPath)) {
101
+ return;
106
102
  }
107
- parts[indexToReplace] = prefix;
108
- return toPascalCase(parts);
103
+ writeFileSync2(rootComponentPath, APP_KU_VUE_TEMPLATE, "utf-8");
104
+ console.log(`[univa] \u5DF2\u751F\u6210\u865A\u62DF\u6839\u7EC4\u4EF6\uFF1A${slash(rootComponentPath)}`);
109
105
  }
110
- function processPageName(ctx) {
111
- ctx.pageMetaData.forEach((page) => {
112
- if (page.name) {
106
+ var UnivaContext = class {
107
+ _server;
108
+ config;
109
+ configPath;
110
+ root;
111
+ constructor(options) {
112
+ this.root = options.root;
113
+ }
114
+ /**
115
+ * 同步加载用户配置(univa.config.ts)
116
+ */
117
+ loadUserConfigSync() {
118
+ const jiti = createJiti(this.root);
119
+ const configFile = join3(this.root, `${ID}.config`);
120
+ try {
121
+ const configModule = jiti(configFile);
122
+ const userConfig = configModule?.default || configModule;
123
+ this.config = mergeWithArrayOverride({}, userConfig);
124
+ this.configPath = jiti.resolve(configFile);
125
+ } catch {
126
+ }
127
+ }
128
+ /**
129
+ * 异步加载用户配置(c12 支持更多格式与合并能力)
130
+ */
131
+ async loadUserConfigAsync() {
132
+ const { config: userConfig, configFile } = await loadConfig({
133
+ name: ID,
134
+ cwd: this.root,
135
+ defaults: this.config || {},
136
+ merger: mergeWithArrayOverride
137
+ });
138
+ this.config = userConfig;
139
+ this.configPath = configFile || "";
140
+ }
141
+ /**
142
+ * 设置 Vite 开发服务器
143
+ */
144
+ setupViteServer(server) {
145
+ if (this._server === server)
146
+ return;
147
+ this._server = server;
148
+ this.setupWatcher(server.watcher);
149
+ }
150
+ /**
151
+ * 设置文件监听器
152
+ *
153
+ * 监听 univa.config.ts 变化,重新生成 .univa/pages.ts
154
+ */
155
+ setupWatcher(watcher) {
156
+ if (!this.configPath) {
113
157
  return;
114
158
  }
115
- page.name = _pathToName(page.path, "pages");
116
- });
117
- ctx.subPageMetaData.forEach((subPackage) => {
118
- const root = subPackage.root;
119
- const isAsyncComponent = root.startsWith(COMPONENT_ASYNC_ROOT);
120
- subPackage.pages.forEach((page) => {
121
- if (page.name) {
122
- return;
123
- }
124
- if (!page.path) {
125
- console.warn(`[vite-plugin-uni-pages] Page path is missing in subPackage: ${root}`);
159
+ watcher.add(this.configPath);
160
+ watcher.on("change", async (filePath) => {
161
+ filePath = slash(filePath);
162
+ const configPath = slash(this.configPath || "");
163
+ if (filePath !== configPath) {
126
164
  return;
127
165
  }
128
- if (isAsyncComponent) {
129
- page.layout = false;
130
- }
131
- page.name = _pathToName(`${root}/${page.path}`, "pages-sub", "Sub");
166
+ await this.updateConfig();
167
+ this.onUpdate();
132
168
  });
133
- });
134
- }
135
- function resolveUserPagesConfig(config) {
136
- if (!config.tabBar) {
137
- return config;
138
169
  }
139
- const tabBar = config.tabBar || {};
140
- if (config.tabBarMode === "CUSTOM") {
141
- tabBar.custom = true;
142
- if (tabBar.list && tabBar.list.length > 0) {
143
- tabBar.list = tabBar.list.map((item) => {
144
- const filtered = { ...item };
145
- filtered.customIconPath = filtered.iconPath;
146
- filtered.customSelectedIconPath = filtered.selectedIconPath;
147
- if (!filtered.iconPath?.startsWith("static/")) {
148
- delete filtered.iconPath;
149
- }
150
- if (!filtered.selectedIconPath?.startsWith("static/")) {
151
- delete filtered.selectedIconPath;
152
- }
153
- return filtered;
154
- });
155
- }
170
+ async updateConfig() {
171
+ await this.loadUserConfigAsync();
172
+ this.updateGeneratedFiles();
156
173
  }
157
- return {
158
- ...config,
159
- tabBar
160
- };
161
- }
162
- function createPagesPlugin(options) {
163
- const pages = options.pages || {};
164
- let tabBarConfig = null;
165
- const moduleId = "\0virtual:univa-tabbar";
166
- return [
167
- {
168
- name: "vite-plugin-univa-pages-tabbar",
169
- enforce: "pre",
170
- resolveId(id) {
171
- if (id === "virtual:univa-tabbar") {
172
- return moduleId;
173
- }
174
- },
175
- load(id) {
176
- if (id === moduleId) {
177
- return `export default ${JSON.stringify(tabBarConfig)}`;
178
- }
174
+ /**
175
+ * 更新生成的文件
176
+ *
177
+ * 读取 univa.config.ts 的 pages 字段(应用级配置),
178
+ * 生成 .univa/pages.ts 供 VitePluginUniPages 消费。
179
+ * 同时确保 UniKuRoot 虚拟根组件文件存在。
180
+ */
181
+ updateGeneratedFiles() {
182
+ const pagesConfig = this.config?.pages;
183
+ if (pagesConfig) {
184
+ generatePagesConfigFile(pagesConfig, this.root);
185
+ }
186
+ const pagesTsPath = getPagesConfigPath(this.root);
187
+ const emptyContent = `// Auto-generated by @univa/core
188
+ export default {}
189
+ `;
190
+ if (!existsSync3(pagesTsPath)) {
191
+ writeFileSync2(pagesTsPath, emptyContent, "utf-8");
192
+ } else if (!pagesConfig) {
193
+ if (readFileSync2(pagesTsPath, "utf-8") !== emptyContent) {
194
+ writeFileSync2(pagesTsPath, emptyContent, "utf-8");
179
195
  }
180
- },
181
- UniHelperPages({
182
- configSource: pages.config ? {
183
- files: "vite.config",
184
- rewrite: () => resolveUserPagesConfig(pages.config)
185
- } : {
186
- files: "pages.config",
187
- extensions: ["ts", "mts", "cts", "js", "cjs", "mjs", "json"]
188
- },
189
- subPackages: [
190
- ...pages.subPackages || []
191
- ],
192
- exclude: [
193
- ...pages?.exclude || [],
194
- "**/components/**/*.*"
195
- ],
196
- onAfterMergePageMetaData(ctx) {
197
- processPageName(ctx);
198
- const tabBar = ctx.pagesGlobConfig?.tabBar;
199
- if (!tabBar) {
200
- tabBarConfig = null;
201
- return;
202
- }
203
- const clonedTabBar = { ...tabBar };
204
- if (clonedTabBar.list) {
205
- clonedTabBar.list = clonedTabBar.list.map((item) => {
206
- const filtered = { ...item };
207
- if (filtered.customIconPath) {
208
- filtered.iconPath = filtered.customIconPath;
209
- delete filtered.customIconPath;
210
- }
211
- if (filtered.customSelectedIconPath) {
212
- filtered.selectedIconPath = filtered.customSelectedIconPath;
213
- delete filtered.customSelectedIconPath;
214
- }
215
- return filtered;
216
- });
217
- }
218
- tabBarConfig = clonedTabBar;
219
- },
220
- dts: `${DTS_DIR}/uni-pages.d.ts`
221
- })
222
- ];
223
- }
224
- function definePagesConfig(config) {
225
- return config;
226
- }
196
+ }
197
+ ensureRootComponent(this.config, this.root);
198
+ }
199
+ /**
200
+ * 更新回调
201
+ * 触发 HMR
202
+ */
203
+ onUpdate() {
204
+ if (!this._server) {
205
+ return;
206
+ }
207
+ this._server.ws.send({
208
+ type: "full-reload"
209
+ });
210
+ }
211
+ };
227
212
 
228
- // src/plugins/unocss.ts
229
- import { presetUni } from "@uni-helper/unocss-preset-uni";
230
- import presetLegacyCompat from "@unocss/preset-legacy-compat";
231
- import { presetIcons, transformerDirectives, transformerVariantGroup } from "unocss";
232
- import UnoCSS from "unocss/vite";
233
- function createUnocssPlugin() {
234
- return UnoCSS({
235
- presets: [
236
- presetUniva()
237
- ]
238
- });
239
- }
240
- function presetUniva() {
213
+ // src/plugins/options.ts
214
+ var DEFAULT_DIRS = {
215
+ pages: "pages",
216
+ subPackages: ["pages-sub/*"],
217
+ layouts: "layouts"
218
+ };
219
+ var DEFAULT_IMPORTS = {
220
+ apis: ["vue", "uni-app", "composables/**", "stores/**", "hooks/**", "constants/**"],
221
+ components: ["components/**", "components-biz/**"]
222
+ };
223
+ function resolveOptions(userOptions) {
224
+ const srcDir = userOptions.srcDir || "src";
225
+ const dirs = {
226
+ pages: userOptions.dirs?.pages ?? DEFAULT_DIRS.pages,
227
+ subPackages: userOptions.dirs?.subPackages ?? DEFAULT_DIRS.subPackages,
228
+ layouts: userOptions.dirs?.layouts ?? DEFAULT_DIRS.layouts
229
+ };
230
+ const imports = {
231
+ apis: userOptions.imports?.apis ?? DEFAULT_IMPORTS.apis,
232
+ components: userOptions.imports?.components ?? DEFAULT_IMPORTS.components
233
+ };
241
234
  return {
242
- name: "univa-preset",
243
- presets: [
244
- presetUni({
245
- attributify: false
246
- }),
247
- presetIcons({
248
- scale: 1.2,
249
- warn: true,
250
- extraProperties: {
251
- "display": "inline-block",
252
- "vertical-align": "middle"
253
- }
254
- }),
255
- // 处理低端安卓机的样式问题,eg: `rgb(255 0 0)` -> `rgb(255, 0, 0)`
256
- presetLegacyCompat({
257
- commaStyleColorFunction: true,
258
- legacyColorSpace: true
259
- })
260
- ],
261
- shortcuts: [
262
- ["border-s", "border border-solid"],
263
- ["wh-full", "w-full h-full"],
264
- ["f-c-c", "flex justify-center items-center"],
265
- ["f-col-c", "flex-col justify-center items-center"],
266
- ["flex-items", "flex items-center"],
267
- ["flex-justify", "flex justify-center"],
268
- ["flex-col", "flex flex-col"]
269
- ],
270
- transformers: [
271
- transformerDirectives(),
272
- transformerVariantGroup()
273
- ],
274
- rules: [
275
- [
276
- "p-safe",
277
- {
278
- padding: "env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)"
279
- }
280
- ],
281
- ["pt-safe", { "padding-top": "env(safe-area-inset-top)" }],
282
- ["pb-safe", { "padding-bottom": "env(safe-area-inset-bottom)" }]
283
- ]
235
+ srcDir,
236
+ dirs,
237
+ imports,
238
+ overrides: userOptions.overrides
284
239
  };
285
240
  }
286
241
 
287
242
  // src/plugins/index.ts
288
- function createUnivaPlugins(options) {
289
- const pluginFactory = {
290
- plugins: [
291
- ...createPagesPlugin(options),
292
- UniHelperLayouts()
293
- ],
294
- register(condition, plugin) {
295
- if (condition) {
296
- this.plugins.push(plugin);
297
- }
243
+ var context;
244
+ function createCorePlugin() {
245
+ return {
246
+ name: "vite-plugin-univa",
247
+ enforce: "pre",
248
+ async configResolved() {
249
+ await context.loadUserConfigAsync();
250
+ context.updateGeneratedFiles();
251
+ },
252
+ configureServer(server) {
253
+ context.setupViteServer(server);
298
254
  }
299
255
  };
300
- pluginFactory.register(options.appRoot !== false, UnivaRoot({
301
- enabledVirtualHost: true,
302
- rootFileName: "App.univa",
256
+ }
257
+ function isPresetName(from) {
258
+ if (/[*?[\]{}]/.test(from))
259
+ return false;
260
+ if (/^@[\w.-]+\/[\w.-]+$/.test(from))
261
+ return true;
262
+ if (/[/\\]/.test(from))
263
+ return false;
264
+ return true;
265
+ }
266
+ function resolveApiSources(sources, srcDir) {
267
+ const presets = [];
268
+ const dirs = [];
269
+ for (const source of sources) {
270
+ if (typeof source !== "string") {
271
+ presets.push(source);
272
+ } else if (source.startsWith("!")) {
273
+ dirs.push(`!${srcDir}/${source.slice(1)}`);
274
+ } else if (isPresetName(source)) {
275
+ presets.push(source);
276
+ } else {
277
+ dirs.push(`${srcDir}/${source}`);
278
+ }
279
+ }
280
+ return { presets, dirs };
281
+ }
282
+ function createUnivaPlugins(resolved) {
283
+ const plugins = [];
284
+ const { srcDir } = resolved;
285
+ plugins.push(createCorePlugin());
286
+ plugins.push(...createPagesPlugin({
287
+ dir: `${srcDir}/${resolved.dirs.pages}`,
288
+ subPackages: resolved.dirs.subPackages.map((p) => `${srcDir}/${p}`),
289
+ ...resolved.overrides?.pages
290
+ }));
291
+ plugins.push(VitePluginUniLayouts({
292
+ layoutDir: `${srcDir}/${resolved.dirs.layouts}`,
293
+ ...resolved.overrides?.layouts
294
+ }));
295
+ plugins.push(UniKuRoot({
303
296
  enabledGlobalRef: true,
304
- autoCreateRoot: true,
305
297
  excludePages: [
306
- `${COMPONENT_ASYNC_ROOT}/**/*.*`
307
- ]
298
+ "components-async/**/*.*"
299
+ ],
300
+ ...resolved.overrides?.root
301
+ }));
302
+ plugins.push(VitePluginUniComponents({
303
+ dirs: resolved.imports.components.map((c) => `${srcDir}/${c}`),
304
+ dts: `${UNIVA_DIR_NAME}/components.d.ts`,
305
+ globalNamespaces: ["components", "common"],
306
+ directoryAsNamespace: true,
307
+ ...resolved.overrides?.components
308
308
  }));
309
- pluginFactory.register(true, createManifestPlugin(options));
310
- pluginFactory.register(options.components !== false, createComponentsPlugin(options));
311
- pluginFactory.register(true, UniOptimization());
312
- pluginFactory.register(true, Uni());
313
- pluginFactory.register(true, createUnocssPlugin());
314
- pluginFactory.register(options.autoImport !== false, createAutoImportPlugin(options));
315
- pluginFactory.register(true, UniPolyfill());
316
- return pluginFactory.plugins;
309
+ plugins.push(...Uni());
310
+ plugins.push(...UnoCSS());
311
+ const { presets, dirs } = resolveApiSources(resolved.imports.apis, srcDir);
312
+ const autoImportPlugin = AutoImport({
313
+ imports: presets,
314
+ dirs,
315
+ dts: `${UNIVA_DIR_NAME}/auto-imports.d.ts`,
316
+ ...resolved.overrides?.autoImport
317
+ });
318
+ if (Array.isArray(autoImportPlugin)) {
319
+ plugins.push(...autoImportPlugin);
320
+ } else {
321
+ plugins.push(autoImportPlugin);
322
+ }
323
+ return plugins;
317
324
  }
318
-
319
- // src/index.ts
320
- function Univa(config) {
321
- return createUnivaPlugins({
322
- components: config?.components ?? true,
323
- autoImport: config?.autoImport ?? true,
324
- appRoot: config?.appRoot ?? true,
325
- pages: config?.pages,
326
- manifest: config?.manifest
325
+ function Univa() {
326
+ context = new UnivaContext({
327
+ root: process.cwd()
327
328
  });
329
+ ensureUnivaDir(context.root);
330
+ context.loadUserConfigSync();
331
+ const resolved = resolveOptions(context.config || {});
332
+ console.log("[univa] \u5DF2\u52A0\u8F7D\u914D\u7F6E\uFF1A", context.configPath || "\u9ED8\u8BA4\u914D\u7F6E");
333
+ return createUnivaPlugins(resolved);
328
334
  }
335
+ var plugins_default = Univa;
336
+
337
+ // src/index.ts
338
+ import { presetUni } from "@uni-helper/unocss-preset-uni";
339
+ import { camelCase, kebabCase, pascalCase } from "@uni-helper/vite-plugin-uni-components";
340
+ import { default as default2 } from "@uni-helper/vite-plugin-uni-components";
341
+ import { VitePluginUniLayouts as VitePluginUniLayouts2 } from "@uni-helper/vite-plugin-uni-layouts";
342
+ import { PageContext, VitePluginUniPages as VitePluginUniPages2 } from "@uni-helper/vite-plugin-uni-pages";
343
+ import { default as default3 } from "@uni-ku/root";
344
+ import { default as default4 } from "unplugin-auto-import/vite";
329
345
  export {
330
- Univa,
331
- definePagesConfig,
332
- presetUniva
346
+ default4 as AutoImport,
347
+ PageContext,
348
+ default3 as UniKuRoot,
349
+ plugins_default as Univa,
350
+ default2 as VitePluginUniComponents,
351
+ VitePluginUniLayouts2 as VitePluginUniLayouts,
352
+ VitePluginUniPages2 as VitePluginUniPages,
353
+ camelCase,
354
+ createUnivaPlugins,
355
+ defineConfig,
356
+ kebabCase,
357
+ pascalCase,
358
+ presetUni
333
359
  };