@univa/core 0.0.7 → 0.0.9

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.
@@ -0,0 +1,216 @@
1
+ # Third-Party Notices
2
+
3
+ This file contains acknowledgments for third-party software used in the Univa project.
4
+
5
+ ---
6
+
7
+ ## Vite
8
+
9
+ - **License**: MIT
10
+ - **Repository**: https://github.com/vitejs/vite
11
+ - **Copyright**: Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
12
+
13
+ ---
14
+
15
+ ## UnoCSS
16
+
17
+ - **License**: MIT
18
+ - **Repository**: https://github.com/unocss/unocss
19
+ - **Copyright**: Copyright (c) 2021-PRESENT Anthony Fu
20
+
21
+ ---
22
+
23
+ ## uni-helper
24
+
25
+ ### @uni-helper/plugin-uni
26
+ - **License**: MIT
27
+ - **Repository**: https://github.com/uni-helper/plugin-uni
28
+
29
+ ### @uni-helper/vite-plugin-uni-pages
30
+ - **License**: MIT
31
+ - **Repository**: https://github.com/uni-helper/vite-plugin-uni-pages
32
+
33
+ ### @uni-helper/vite-plugin-uni-components
34
+ - **License**: MIT
35
+ - **Repository**: https://github.com/uni-helper/vite-plugin-uni-components
36
+
37
+ ### @uni-helper/vite-plugin-uni-layouts
38
+ - **License**: MIT
39
+ - **Repository**: https://github.com/uni-helper/vite-plugin-uni-layouts
40
+
41
+ ### @uni-helper/vite-plugin-uni-manifest
42
+ - **License**: MIT
43
+ - **Repository**: https://github.com/uni-helper/vite-plugin-uni-manifest
44
+
45
+ ### @uni-helper/unocss-preset-uni
46
+ - **License**: MIT
47
+ - **Repository**: https://github.com/uni-helper/unocss-preset-uni
48
+
49
+ ### @uni-helper/uni-types
50
+ - **License**: MIT
51
+ - **Repository**: https://github.com/uni-helper/uni-types
52
+
53
+ ### @uni-helper/uni-pages-types
54
+ - **License**: MIT
55
+ - **Repository**: https://github.com/uni-helper/uni-pages-types
56
+
57
+ ### @uni-helper/eslint-config
58
+ - **License**: MIT
59
+ - **Repository**: https://github.com/uni-helper/eslint-config
60
+
61
+ ---
62
+
63
+ ## unplugin-auto-import
64
+
65
+ - **License**: MIT
66
+ - **Repository**: https://github.com/unjs/unplugin-auto-import
67
+ - **Copyright**: Copyright (c) 2021-PRESENT Anthony Fu
68
+
69
+ ---
70
+
71
+ ## @antfu/utils
72
+
73
+ - **License**: MIT
74
+ - **Repository**: https://github.com/antfu/utils
75
+ - **Copyright**: Copyright (c) 2021-PRESENT Anthony Fu
76
+
77
+ ---
78
+
79
+ ## @antfu/eslint-config
80
+
81
+ - **License**: MIT
82
+ - **Repository**: https://github.com/antfu/eslint-config
83
+ - **Copyright**: Copyright (c) 2019-PRESENT Anthony Fu
84
+
85
+ ---
86
+
87
+ ## Sass
88
+
89
+ - **License**: MIT
90
+ - **Repository**: https://github.com/sass/dart-sass
91
+ - **Copyright**: Copyright (c) 2016 Google Inc.
92
+
93
+ ---
94
+
95
+ ## c12
96
+
97
+ - **License**: MIT
98
+ - **Repository**: https://github.com/unjs/c12
99
+ - **Copyright**: Copyright (c) Pooya Parsa
100
+
101
+ ---
102
+
103
+ ## defu
104
+
105
+ - **License**: MIT
106
+ - **Repository**: https://github.com/unjs/defu
107
+ - **Copyright**: Copyright (c) Pooya Parsa
108
+
109
+ ---
110
+
111
+ ## jiti
112
+
113
+ - **License**: MIT
114
+ - **Repository**: https://github.com/unjs/jiti
115
+ - **Copyright**: Copyright (c) Pooya Parsa
116
+
117
+ ---
118
+
119
+ ## @dcloudio/types
120
+
121
+ - **License**: Apache-2.0
122
+ - **Repository**: https://github.com/dcloudio/uni-app
123
+
124
+ ---
125
+
126
+ ## @uni-ku/root
127
+
128
+ - **License**: MIT
129
+ - **Repository**: https://github.com/uni-ku/root
130
+
131
+ ---
132
+
133
+ ## vite-plugin-uni-polyfill
134
+
135
+ - **License**: MIT
136
+ - **Repository**: https://github.com/uni-helper/vite-plugin-uni-polyfill
137
+
138
+ ---
139
+
140
+ ## husky
141
+
142
+ - **License**: MIT
143
+ - **Repository**: https://github.com/typicode/husky
144
+ - **Copyright**: Copyright (c) 2016-2023 Typicode
145
+
146
+ ---
147
+
148
+ ## lint-staged
149
+
150
+ - **License**: MIT
151
+ - **Repository**: https://github.com/lint-staged/lint-staged
152
+ - **Copyright**: Copyright (c) 2011-2023 Andrey Okonetchnikov
153
+
154
+ ---
155
+
156
+ ## commitlint
157
+
158
+ - **License**: MIT
159
+ - **Repository**: https://github.com/conventional-changelog/commitlint
160
+ - **Copyright**: Copyright (c) 2016-2023 by Mario Nebl and contributors
161
+
162
+ ---
163
+
164
+ ## standard-version
165
+
166
+ - **License**: ISC
167
+ - **Repository**: https://github.com/conventional-changelog/standard-version
168
+ - **Copyright**: Copyright (c) 2017-2019, Mario Nebl and contributors
169
+
170
+ ---
171
+
172
+ ## ESLint
173
+
174
+ - **License**: MIT
175
+ - **Repository**: https://github.com/eslint/eslint
176
+ - **Copyright**: Copyright OpenJS Foundation and other contributors
177
+
178
+ ---
179
+
180
+ ## inquirer
181
+
182
+ - **License**: MIT
183
+ - **Repository**: https://github.com/SBoudrias/Inquirer.js
184
+ - **Copyright**: Copyright (c) 2016 Simon Boudrias
185
+
186
+ ---
187
+
188
+ ## TypeScript
189
+
190
+ - **License**: Apache-2.0
191
+ - **Repository**: https://github.com/microsoft/TypeScript
192
+ - **Copyright**: Copyright (c) Microsoft Corporation
193
+
194
+ ---
195
+
196
+ ## tsup
197
+
198
+ - **License**: MIT
199
+ - **Repository**: https://github.com/egoist/tsup
200
+ - **Copyright**: Copyright (c) 2018 EGOIST
201
+
202
+ ---
203
+
204
+ ## Vue
205
+
206
+ - **License**: MIT
207
+ - **Repository**: https://github.com/vuejs/core
208
+ - **Copyright**: Copyright (c) 2018-present, Yuxi (Evan) You
209
+
210
+ ---
211
+
212
+ ## Acknowledgments
213
+
214
+ This project stands on the shoulders of giants. We are grateful to all the open-source contributors who have made these amazing tools available to the community.
215
+
216
+ If you believe any attribution is missing or incorrect, please submit an issue or pull request.
@@ -0,0 +1,4 @@
1
+ /// <reference types="@dcloudio/types" />
2
+ /// <reference types="vite/client" />
3
+ /// <reference types="@uni-helper/vite-plugin-uni-pages/client" />
4
+ /// <reference types="@uni-helper/uni-types" />
package/dist/index.cjs CHANGED
@@ -30,7 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
- AutoImport: () => import_vite3.default,
33
+ AutoImport: () => import_vite4.default,
34
34
  PageContext: () => import_vite_plugin_uni_pages2.PageContext,
35
35
  UniKuRoot: () => import_root2.default,
36
36
  Univa: () => plugins_default,
@@ -56,12 +56,13 @@ var import_plugin_uni = __toESM(require("@uni-helper/plugin-uni"), 1);
56
56
  var import_vite_plugin_uni_components = __toESM(require("@uni-helper/vite-plugin-uni-components"), 1);
57
57
  var import_vite_plugin_uni_layouts = require("@uni-helper/vite-plugin-uni-layouts");
58
58
  var import_root = __toESM(require("@uni-ku/root"), 1);
59
- var import_vite = __toESM(require("unocss/vite"), 1);
60
- var import_vite2 = __toESM(require("unplugin-auto-import/vite"), 1);
59
+ var import_vite2 = __toESM(require("unocss/vite"), 1);
60
+ var import_vite3 = __toESM(require("unplugin-auto-import/vite"), 1);
61
61
 
62
62
  // src/constant.ts
63
63
  var ID = "univa";
64
64
  var UNIVA_DIR_NAME = `.${ID}`;
65
+ var ROOT_NAME = `${ID}.root`;
65
66
 
66
67
  // src/utils/fs.ts
67
68
  var import_node_fs = require("fs");
@@ -80,11 +81,22 @@ function ensureUnivaDir(cwd) {
80
81
  return dir;
81
82
  }
82
83
 
84
+ // src/utils/logger.ts
85
+ var debugMode = false;
86
+ function setDebug(enabled) {
87
+ debugMode = enabled;
88
+ }
89
+ function log(message, ...args) {
90
+ if (debugMode) {
91
+ console.log(`[${ID}]`, message, ...args);
92
+ }
93
+ }
94
+
83
95
  // src/plugins/context.ts
84
- var import_node_fs3 = require("fs");
85
- var import_node_path3 = require("path");
96
+ var import_node_fs4 = require("fs");
97
+ var import_node_path4 = require("path");
86
98
  var import_utils = require("@antfu/utils");
87
- var import_c12 = require("c12");
99
+ var import_c122 = require("c12");
88
100
  var import_jiti = require("jiti");
89
101
 
90
102
  // src/utils/merge.ts
@@ -96,12 +108,115 @@ var mergeWithArrayOverride = (0, import_defu.createDefu)((originObj, key, update
96
108
  }
97
109
  });
98
110
 
99
- // src/plugins/pages.ts
111
+ // src/plugins/manifest.ts
100
112
  var import_node_fs2 = require("fs");
101
113
  var import_node_path2 = require("path");
114
+ var import_node_process = __toESM(require("process"), 1);
115
+ var import_vite_plugin_uni_manifest = require("@uni-helper/vite-plugin-uni-manifest");
116
+ var import_c12 = require("c12");
117
+ var import_vite = require("vite");
118
+ function resolveOptions(userOptions) {
119
+ return {
120
+ minify: false,
121
+ insertFinalNewline: false,
122
+ cwd: import_node_process.default.env.VITE_ROOT_DIR,
123
+ merge: true,
124
+ ...userOptions
125
+ };
126
+ }
127
+ function writeManifestJson(config = {}, opts) {
128
+ const path = resolveManifestJsonPath();
129
+ let mergeContent = {};
130
+ if (opts?.merge && (0, import_node_fs2.existsSync)(path)) {
131
+ try {
132
+ const content2 = (0, import_node_fs2.readFileSync)(path, "utf-8");
133
+ mergeContent = JSON.parse(content2);
134
+ } catch (error) {
135
+ log(`manifest.json parse error: ${error}`);
136
+ }
137
+ }
138
+ const content = JSON.stringify(opts?.merge ? mergeWithArrayOverride(config, mergeContent) : config, null, opts?.minify ? 0 : 2) + (opts?.insertFinalNewline ? "\n" : "");
139
+ if ((0, import_node_fs2.existsSync)(path) && (0, import_node_fs2.readFileSync)(path, "utf-8") === content) {
140
+ return;
141
+ }
142
+ (0, import_node_fs2.writeFileSync)(path, content);
143
+ }
144
+ function resolveManifestJsonPath() {
145
+ return (0, import_vite.normalizePath)(
146
+ (0, import_node_path2.resolve)(import_node_process.default.env.UNI_INPUT_DIR || `${import_node_process.default.cwd()}/src`, "manifest.json")
147
+ );
148
+ }
149
+ var ManifestContext = class {
150
+ options;
151
+ unwatch;
152
+ constructor(options) {
153
+ this.options = resolveOptions(options);
154
+ }
155
+ /**
156
+ * Start watching config sources and perform initial write.
157
+ * Must be called after construction.
158
+ */
159
+ async setup() {
160
+ log(`manifest cwd: ${this.options.cwd}`);
161
+ const { config, unwatch } = await (0, import_c12.watchConfig)({
162
+ cwd: this.options.cwd,
163
+ name: "manifest",
164
+ rcFile: false,
165
+ packageJson: false,
166
+ onUpdate: (config2) => {
167
+ writeManifestJson(config2.newConfig.config, this.options);
168
+ }
169
+ });
170
+ writeManifestJson(config, this.options);
171
+ this.unwatch = unwatch;
172
+ }
173
+ };
174
+ function VitePluginUniManifest(userOptions = {}) {
175
+ let ctx;
176
+ return {
177
+ name: "vite-plugin-uni-manifest",
178
+ // Run before other plugins to ensure manifest.json is ready
179
+ enforce: "pre",
180
+ async configResolved() {
181
+ (0, import_vite_plugin_uni_manifest.ensureManifestJsonExists)();
182
+ ctx = new ManifestContext(userOptions);
183
+ await ctx.setup();
184
+ },
185
+ buildEnd: () => ctx?.unwatch()
186
+ };
187
+ }
188
+ function generateManifestConfigContent(content = {}) {
189
+ return `// Auto-generated by @univa/core
190
+ export default ${JSON.stringify(content, null, 2)}
191
+ `;
192
+ }
193
+ function generateManifestConfigFile(content = {}, root) {
194
+ const configPath = getManifestConfigPath(root);
195
+ const newContent = generateManifestConfigContent(content);
196
+ if ((0, import_node_fs2.existsSync)(configPath)) {
197
+ const existingContent = (0, import_node_fs2.readFileSync)(configPath, "utf-8");
198
+ if (existingContent === newContent) {
199
+ return;
200
+ }
201
+ }
202
+ (0, import_node_fs2.writeFileSync)(configPath, newContent, "utf-8");
203
+ }
204
+ function getManifestConfigPath(root) {
205
+ return (0, import_node_path2.join)(getUnivaDir(root), "manifest.config.ts");
206
+ }
207
+ function createManifestPlugin(userOptions = {}) {
208
+ return VitePluginUniManifest({
209
+ cwd: (0, import_node_path2.join)(import_node_process.default.env.VITE_ROOT_DIR || "", UNIVA_DIR_NAME),
210
+ ...userOptions
211
+ });
212
+ }
213
+
214
+ // src/plugins/pages.ts
215
+ var import_node_fs3 = require("fs");
216
+ var import_node_path3 = require("path");
102
217
  var import_vite_plugin_uni_pages = require("@uni-helper/vite-plugin-uni-pages");
103
218
  function getPagesConfigPath(root) {
104
- return (0, import_node_path2.join)(getUnivaDir(root), "pages-config.ts");
219
+ return (0, import_node_path3.join)(getUnivaDir(root), "pages-config.ts");
105
220
  }
106
221
  function generatePagesConfigContent(content) {
107
222
  const { pages, subPackages, ...rest } = content;
@@ -115,13 +230,13 @@ export default ${JSON.stringify(rest, null, 2)}
115
230
  function generatePagesConfigFile(content, root) {
116
231
  const pagesConfigPath = getPagesConfigPath(root);
117
232
  const newContent = generatePagesConfigContent(content);
118
- if ((0, import_node_fs2.existsSync)(pagesConfigPath)) {
119
- const existingContent = (0, import_node_fs2.readFileSync)(pagesConfigPath, "utf-8");
233
+ if ((0, import_node_fs3.existsSync)(pagesConfigPath)) {
234
+ const existingContent = (0, import_node_fs3.readFileSync)(pagesConfigPath, "utf-8");
120
235
  if (existingContent === newContent) {
121
236
  return;
122
237
  }
123
238
  }
124
- (0, import_node_fs2.writeFileSync)(pagesConfigPath, newContent, "utf-8");
239
+ (0, import_node_fs3.writeFileSync)(pagesConfigPath, newContent, "utf-8");
125
240
  }
126
241
  function createPagesPlugin(pluginOptions) {
127
242
  const result = (0, import_vite_plugin_uni_pages.VitePluginUniPages)({
@@ -134,23 +249,11 @@ function createPagesPlugin(pluginOptions) {
134
249
  }
135
250
 
136
251
  // src/plugins/context.ts
137
- var DEFAULT_ROOT_FILE_NAME = "App.ku.vue";
138
252
  var APP_KU_VUE_TEMPLATE = `<!-- Auto-generated by @univa/core -->
139
- <!-- UniKuRoot \u865A\u62DF\u6839\u7EC4\u4EF6\uFF0C\u53EF\u5728\u6B64\u6DFB\u52A0\u5168\u5C40\u7EC4\u4EF6\uFF08\u5982 Toast\u3001ConfigProvider \u7B49\uFF09 -->
140
253
  <template>
141
254
  <KuRootView />
142
255
  </template>
143
256
  `;
144
- function ensureRootComponent(config, root) {
145
- const srcDir = config?.srcDir || "src";
146
- const rootFileName = config?.overrides?.root?.rootFileName || DEFAULT_ROOT_FILE_NAME;
147
- const rootComponentPath = (0, import_node_path3.join)(root, srcDir, rootFileName);
148
- if ((0, import_node_fs3.existsSync)(rootComponentPath)) {
149
- return;
150
- }
151
- (0, import_node_fs3.writeFileSync)(rootComponentPath, APP_KU_VUE_TEMPLATE, "utf-8");
152
- console.log(`[univa] \u5DF2\u751F\u6210\u865A\u62DF\u6839\u7EC4\u4EF6\uFF1A${(0, import_utils.slash)(rootComponentPath)}`);
153
- }
154
257
  var UnivaContext = class {
155
258
  _server;
156
259
  config;
@@ -159,12 +262,32 @@ var UnivaContext = class {
159
262
  constructor(options) {
160
263
  this.root = options.root;
161
264
  }
265
+ /**
266
+ * 确保虚拟根组件文件存在
267
+ *
268
+ * UniKuRoot 插件依赖 src 下的虚拟根组件文件(默认 App.ku.vue)。
269
+ * 若不存在则生成最小模板,避免插件注入 import 时解析失败。
270
+ *
271
+ * 必须在 Vite 启动前调用(Univa() 初始化阶段),
272
+ * 否则在 configResolved 阶段创建 src 下新文件会触发 watcher add 事件,
273
+ * 导致 Vite 重编译与 VitePluginUniPages 的 pages.json 写入冲突(EPERM)。
274
+ */
275
+ ensureRootComponent(fileName) {
276
+ const srcDir = this.config?.srcDir || "src";
277
+ const rootFileName = this.config?.overrides?.root?.rootFileName || fileName;
278
+ const rootComponentPath = (0, import_node_path4.join)(this.root, srcDir, rootFileName);
279
+ if ((0, import_node_fs4.existsSync)(rootComponentPath)) {
280
+ return;
281
+ }
282
+ (0, import_node_fs4.writeFileSync)(rootComponentPath, APP_KU_VUE_TEMPLATE, "utf-8");
283
+ log(`\u5DF2\u751F\u6210\u865A\u62DF\u6839\u7EC4\u4EF6\uFF1A${(0, import_utils.slash)(rootComponentPath)}`);
284
+ }
162
285
  /**
163
286
  * 同步加载用户配置(univa.config.ts)
164
287
  */
165
288
  loadUserConfigSync() {
166
289
  const jiti = (0, import_jiti.createJiti)(this.root);
167
- const configFile = (0, import_node_path3.join)(this.root, `${ID}.config`);
290
+ const configFile = (0, import_node_path4.join)(this.root, `${ID}.config`);
168
291
  try {
169
292
  const configModule = jiti(configFile);
170
293
  const userConfig = configModule?.default || configModule;
@@ -177,7 +300,7 @@ var UnivaContext = class {
177
300
  * 异步加载用户配置(c12 支持更多格式与合并能力)
178
301
  */
179
302
  async loadUserConfigAsync() {
180
- const { config: userConfig, configFile } = await (0, import_c12.loadConfig)({
303
+ const { config: userConfig, configFile } = await (0, import_c122.loadConfig)({
181
304
  name: ID,
182
305
  cwd: this.root,
183
306
  defaults: this.config || {},
@@ -223,26 +346,33 @@ var UnivaContext = class {
223
346
  * 更新生成的文件
224
347
  *
225
348
  * 读取 univa.config.ts 的 pages 字段(应用级配置),
226
- * 生成 .univa/pages.ts 供 VitePluginUniPages 消费。
227
- * 同时确保 UniKuRoot 虚拟根组件文件存在。
349
+ * 生成 .univa/pages-config.ts 供 VitePluginUniPages 消费。
350
+ *
351
+ * 注意:不在此处生成 src/App.ku.vue,避免在 configResolved 阶段
352
+ * 创建 src 下新文件触发 watcher add 事件,导致 Vite 重编译
353
+ * 与 VitePluginUniPages 的 pages.json 写入冲突(EPERM)。
354
+ * App.ku.vue 的生成在 Univa() 初始化阶段完成。
228
355
  */
229
356
  updateGeneratedFiles() {
230
357
  const pagesConfig = this.config?.pages;
231
358
  if (pagesConfig) {
232
359
  generatePagesConfigFile(pagesConfig, this.root);
233
360
  }
361
+ const manifestConfig = this.config?.manifest;
362
+ if (manifestConfig) {
363
+ generateManifestConfigFile(manifestConfig, this.root);
364
+ }
234
365
  const pagesTsPath = getPagesConfigPath(this.root);
235
366
  const emptyContent = `// Auto-generated by @univa/core
236
367
  export default {}
237
368
  `;
238
- if (!(0, import_node_fs3.existsSync)(pagesTsPath)) {
239
- (0, import_node_fs3.writeFileSync)(pagesTsPath, emptyContent, "utf-8");
369
+ if (!(0, import_node_fs4.existsSync)(pagesTsPath)) {
370
+ (0, import_node_fs4.writeFileSync)(pagesTsPath, emptyContent, "utf-8");
240
371
  } else if (!pagesConfig) {
241
- if ((0, import_node_fs3.readFileSync)(pagesTsPath, "utf-8") !== emptyContent) {
242
- (0, import_node_fs3.writeFileSync)(pagesTsPath, emptyContent, "utf-8");
372
+ if ((0, import_node_fs4.readFileSync)(pagesTsPath, "utf-8") !== emptyContent) {
373
+ (0, import_node_fs4.writeFileSync)(pagesTsPath, emptyContent, "utf-8");
243
374
  }
244
375
  }
245
- ensureRootComponent(this.config, this.root);
246
376
  }
247
377
  /**
248
378
  * 更新回调
@@ -268,7 +398,7 @@ var DEFAULT_IMPORTS = {
268
398
  apis: ["vue", "uni-app", "composables/**", "stores/**", "hooks/**", "constants/**"],
269
399
  components: ["components/**", "components-biz/**"]
270
400
  };
271
- function resolveOptions(userOptions) {
401
+ function resolveOptions2(userOptions) {
272
402
  const srcDir = userOptions.srcDir || "src";
273
403
  const dirs = {
274
404
  pages: userOptions.dirs?.pages ?? DEFAULT_DIRS.pages,
@@ -341,7 +471,9 @@ function createUnivaPlugins(resolved) {
341
471
  ...resolved.overrides?.layouts
342
472
  }));
343
473
  plugins.push((0, import_root.default)({
474
+ enabledVirtualHost: true,
344
475
  enabledGlobalRef: true,
476
+ rootFileName: ROOT_NAME,
345
477
  excludePages: [
346
478
  "components-async/**/*.*"
347
479
  ],
@@ -354,10 +486,13 @@ function createUnivaPlugins(resolved) {
354
486
  directoryAsNamespace: true,
355
487
  ...resolved.overrides?.components
356
488
  }));
489
+ plugins.push(createManifestPlugin({
490
+ ...resolved.overrides?.manifest
491
+ }));
357
492
  plugins.push(...(0, import_plugin_uni.default)());
358
- plugins.push(...(0, import_vite.default)());
493
+ plugins.push(...(0, import_vite2.default)());
359
494
  const { presets, dirs } = resolveApiSources(resolved.imports.apis, srcDir);
360
- const autoImportPlugin = (0, import_vite2.default)({
495
+ const autoImportPlugin = (0, import_vite3.default)({
361
496
  imports: presets,
362
497
  dirs,
363
498
  dts: `${UNIVA_DIR_NAME}/auto-imports.d.ts`,
@@ -376,8 +511,10 @@ function Univa() {
376
511
  });
377
512
  ensureUnivaDir(context.root);
378
513
  context.loadUserConfigSync();
379
- const resolved = resolveOptions(context.config || {});
380
- console.log("[univa] \u5DF2\u52A0\u8F7D\u914D\u7F6E\uFF1A", context.configPath || "\u9ED8\u8BA4\u914D\u7F6E");
514
+ setDebug(context.config?.debug ?? false);
515
+ context.ensureRootComponent(`${ROOT_NAME}.vue`);
516
+ const resolved = resolveOptions2(context.config || {});
517
+ log("\u5DF2\u52A0\u8F7D\u914D\u7F6E\uFF1A", context.configPath || "\u9ED8\u8BA4\u914D\u7F6E");
381
518
  return createUnivaPlugins(resolved);
382
519
  }
383
520
  var plugins_default = Univa;
@@ -389,7 +526,7 @@ var import_vite_plugin_uni_components3 = __toESM(require("@uni-helper/vite-plugi
389
526
  var import_vite_plugin_uni_layouts2 = require("@uni-helper/vite-plugin-uni-layouts");
390
527
  var import_vite_plugin_uni_pages2 = require("@uni-helper/vite-plugin-uni-pages");
391
528
  var import_root2 = __toESM(require("@uni-ku/root"), 1);
392
- var import_vite3 = __toESM(require("unplugin-auto-import/vite"), 1);
529
+ var import_vite4 = __toESM(require("unplugin-auto-import/vite"), 1);
393
530
  // Annotate the CommonJS export names for ESM import in node:
394
531
  0 && (module.exports = {
395
532
  AutoImport,
package/dist/index.d.cts CHANGED
@@ -2,6 +2,7 @@ import { PagesConfig } from '@uni-helper/uni-pages-types';
2
2
  export { Condition, EasyCom, GlobalStyle, PageMetaDatum, PagesConfig, SubPackage, TabBar, TabBarItem } from '@uni-helper/uni-pages-types';
3
3
  import { Options } from '@uni-helper/vite-plugin-uni-components';
4
4
  export { ComponentInfo, ComponentResolver, Options as ComponentsOptions, ResolvedOptions as ComponentsResolvedOptions, ImportInfo, default as VitePluginUniComponents, camelCase, kebabCase, pascalCase } from '@uni-helper/vite-plugin-uni-components';
5
+ import { UserManifestConfig } from '@uni-helper/vite-plugin-uni-manifest';
5
6
  import { UserOptions } from '@uni-helper/vite-plugin-uni-pages';
6
7
  export { PageContext, PagePath, UserOptions as PagesPluginOptions, ResolvedOptions as PagesResolvedOptions, SubPageMetaDatum, VitePluginUniPages, definePage } from '@uni-helper/vite-plugin-uni-pages';
7
8
  import { Options as Options$1 } from 'unplugin-auto-import/types';
@@ -12,6 +13,32 @@ export { VitePluginUniLayouts } from '@uni-helper/vite-plugin-uni-layouts';
12
13
  export { default as UniKuRoot } from '@uni-ku/root';
13
14
  export { default as AutoImport } from 'unplugin-auto-import/vite';
14
15
 
16
+ interface ManifestOptions {
17
+ /**
18
+ * minify the `manifest.json`
19
+ * @default false
20
+ */
21
+ minify: boolean;
22
+ /**
23
+ * insert newline at the end of the `manifest.json`
24
+ * @default false
25
+ */
26
+ insertFinalNewline: boolean;
27
+ /**
28
+ * Resolve configuration from this working directory.
29
+ * @default process.env.VITE_ROOT_DIR
30
+ */
31
+ cwd?: string;
32
+ /**
33
+ * Merge the manifest config with the default config.
34
+ * @default false
35
+ */
36
+ merge?: boolean;
37
+ }
38
+ /** User-facing options — all fields are optional. */
39
+ interface UserManifestOptions extends Partial<ManifestOptions> {
40
+ }
41
+
15
42
  /**
16
43
  * Univa 类型定义统一导出
17
44
  *
@@ -115,6 +142,8 @@ interface UnivaOverrides {
115
142
  autoImport?: Options$1;
116
143
  /** unocss/vite 完整选项 */
117
144
  unocss?: UnoCSSOptions;
145
+ /** @uni-helper/vite-plugin-uni-manifest 完整选项 */
146
+ manifest?: UserManifestOptions;
118
147
  }
119
148
  /**
120
149
  * Univa 统一配置接口(工程级约定)
@@ -124,6 +153,8 @@ interface UnivaOverrides {
124
153
  interface UnivaOptions {
125
154
  /** 源码目录,相对 Vite root,默认 'src' */
126
155
  srcDir?: string;
156
+ /** 开启调试日志,默认 false */
157
+ debug?: boolean;
127
158
  /** 目录约定,相对 srcDir */
128
159
  dirs?: UnivaDirs;
129
160
  /** 自动导入配置 */
@@ -137,6 +168,8 @@ interface UnivaOptions {
137
168
  * 注意:pages / subPackages 由目录扫描自动填充,请勿在此手写。
138
169
  */
139
170
  pages?: Partial<PagesConfig>;
171
+ /** 应用级 manifest.json 配置 */
172
+ manifest?: Partial<UserManifestConfig>;
140
173
  /** 底层插件逃生口(覆盖融合层默认,高级用户使用) */
141
174
  overrides?: UnivaOverrides;
142
175
  }