@univa/core 0.0.8 → 0.1.0

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.
package/dist/global.d.ts CHANGED
@@ -1,4 +1,5 @@
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" />
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" />
5
+ /// <reference types="@uni-ku/bundle-optimizer/client" />
package/dist/index.cjs CHANGED
@@ -31,7 +31,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  AutoImport: () => import_vite4.default,
34
- PageContext: () => import_vite_plugin_uni_pages2.PageContext,
35
34
  UniKuRoot: () => import_root2.default,
36
35
  Univa: () => plugins_default,
37
36
  VitePluginUniComponents: () => import_vite_plugin_uni_components3.default,
@@ -42,7 +41,7 @@ __export(index_exports, {
42
41
  defineConfig: () => defineConfig,
43
42
  kebabCase: () => import_vite_plugin_uni_components2.kebabCase,
44
43
  pascalCase: () => import_vite_plugin_uni_components2.pascalCase,
45
- presetUni: () => import_unocss_preset_uni.presetUni
44
+ presetUni: () => import_unocss_preset_uni2.presetUni
46
45
  });
47
46
  module.exports = __toCommonJS(index_exports);
48
47
 
@@ -55,14 +54,17 @@ function defineConfig(config) {
55
54
  var import_plugin_uni = __toESM(require("@uni-helper/plugin-uni"), 1);
56
55
  var import_vite_plugin_uni_components = __toESM(require("@uni-helper/vite-plugin-uni-components"), 1);
57
56
  var import_vite_plugin_uni_layouts = require("@uni-helper/vite-plugin-uni-layouts");
57
+ var import_bundle_optimizer = __toESM(require("@uni-ku/bundle-optimizer"), 1);
58
58
  var import_root = __toESM(require("@uni-ku/root"), 1);
59
- var import_vite2 = __toESM(require("unocss/vite"), 1);
60
59
  var import_vite3 = __toESM(require("unplugin-auto-import/vite"), 1);
60
+ var import_vite_plugin_uni_polyfill = __toESM(require("vite-plugin-uni-polyfill"), 1);
61
61
 
62
62
  // src/constant.ts
63
63
  var ID = "univa";
64
64
  var UNIVA_DIR_NAME = `.${ID}`;
65
65
  var ROOT_NAME = `${ID}.root`;
66
+ var COMPONENTS_ASYNC_DIR_NAME = "components-async";
67
+ var SUB_PACKAGE_DIR_NAME = "app";
66
68
 
67
69
  // src/utils/fs.ts
68
70
  var import_node_fs = require("fs");
@@ -80,6 +82,21 @@ function ensureUnivaDir(cwd) {
80
82
  ensureDir(dir);
81
83
  return dir;
82
84
  }
85
+ function getSubDirectories(dirPath) {
86
+ if (!(0, import_node_fs.existsSync)(dirPath)) {
87
+ return [];
88
+ }
89
+ const entries = (0, import_node_fs.readdirSync)(dirPath);
90
+ return entries.filter((entry) => {
91
+ const fullPath = (0, import_node_path.join)(dirPath, entry);
92
+ return (0, import_node_fs.statSync)(fullPath).isDirectory();
93
+ });
94
+ }
95
+ function scanSubPackages(srcDir, subPackageRoot) {
96
+ const rootPath = (0, import_node_path.join)(srcDir, subPackageRoot);
97
+ const subDirs = getSubDirectories(rootPath);
98
+ return subDirs.map((name) => import_node_path.posix.join(subPackageRoot, name));
99
+ }
83
100
 
84
101
  // src/utils/logger.ts
85
102
  var debugMode = false;
@@ -223,7 +240,6 @@ function generatePagesConfigContent(content) {
223
240
  void pages;
224
241
  void subPackages;
225
242
  return `// Auto-generated by @univa/core
226
- // \u6765\u6E90\uFF1Auniva.config.ts \u7684 pages \u5B57\u6BB5
227
243
  export default ${JSON.stringify(rest, null, 2)}
228
244
  `;
229
245
  }
@@ -243,10 +259,39 @@ function createPagesPlugin(pluginOptions) {
243
259
  dts: `${UNIVA_DIR_NAME}/uni-pages.d.ts`,
244
260
  exclude: ["**/components/**/*.*"],
245
261
  configSource: `${UNIVA_DIR_NAME}/pages-config.ts`,
262
+ onAfterMergePageMetaData: (ctx) => {
263
+ normalizePageNames(ctx);
264
+ },
246
265
  ...pluginOptions
247
266
  });
248
267
  return Array.isArray(result) ? result : [result];
249
268
  }
269
+ function pathToPascalCase(path) {
270
+ if (!path) {
271
+ return "";
272
+ }
273
+ return path.split(/[/.-]/).filter(Boolean).map((str) => str.charAt(0).toUpperCase() + str.slice(1)).join("");
274
+ }
275
+ function normalizePageNames(pageContext) {
276
+ pageContext.pageMetaData.forEach((page) => {
277
+ if (page.name) {
278
+ return;
279
+ }
280
+ page.name = pathToPascalCase(page.path);
281
+ });
282
+ pageContext.subPageMetaData.forEach((subPage) => {
283
+ subPage.pages.forEach((page) => {
284
+ if (subPage.root.startsWith(COMPONENTS_ASYNC_DIR_NAME)) {
285
+ page.layout = false;
286
+ }
287
+ if (page.name) {
288
+ return;
289
+ }
290
+ const fullPath = [subPage.root, page.path].filter(Boolean).join("/");
291
+ page.name = pathToPascalCase(fullPath);
292
+ });
293
+ });
294
+ }
250
295
 
251
296
  // src/plugins/context.ts
252
297
  var APP_KU_VUE_TEMPLATE = `<!-- Auto-generated by @univa/core -->
@@ -389,34 +434,113 @@ export default {}
389
434
  };
390
435
 
391
436
  // src/plugins/options.ts
437
+ var import_node_path5 = require("path");
392
438
  var DEFAULT_DIRS = {
393
439
  pages: "pages",
394
- subPackages: ["pages-sub/*"],
440
+ subPackages: [],
395
441
  layouts: "layouts"
396
442
  };
397
443
  var DEFAULT_IMPORTS = {
398
- apis: ["vue", "uni-app", "composables/**", "stores/**", "hooks/**", "constants/**"],
399
- components: ["components/**", "components-biz/**"]
444
+ apis: ["vue", "uni-app", "composables/**", "store/**", "hooks/**", "constants/**"],
445
+ components: ["components", "components-biz"]
446
+ };
447
+ var DEFAULT_UNI_PRESET = {
448
+ attributify: false
400
449
  };
401
- function resolveOptions2(userOptions) {
450
+ function resolveOptions2(userOptions, root) {
402
451
  const srcDir = userOptions.srcDir || "src";
452
+ const srcDirAbs = (0, import_node_path5.resolve)(root, srcDir);
453
+ const autoScanPackages = scanSubPackages(srcDirAbs, SUB_PACKAGE_DIR_NAME);
454
+ const autoScanCompAsyncPackages = scanSubPackages(srcDirAbs, COMPONENTS_ASYNC_DIR_NAME);
455
+ const userSubPackages = userOptions.dirs?.subPackages ?? [];
456
+ const subPackages = [...userSubPackages, ...autoScanPackages, ...autoScanCompAsyncPackages];
457
+ log(`autoScanPackages: ${JSON.stringify({ subPackages })}`);
403
458
  const dirs = {
404
459
  pages: userOptions.dirs?.pages ?? DEFAULT_DIRS.pages,
405
- subPackages: userOptions.dirs?.subPackages ?? DEFAULT_DIRS.subPackages,
460
+ subPackages,
406
461
  layouts: userOptions.dirs?.layouts ?? DEFAULT_DIRS.layouts
407
462
  };
408
463
  const imports = {
409
464
  apis: userOptions.imports?.apis ?? DEFAULT_IMPORTS.apis,
410
465
  components: userOptions.imports?.components ?? DEFAULT_IMPORTS.components
411
466
  };
467
+ const unocss = {
468
+ presetLegacyCompat: userOptions.unocss?.presetLegacyCompat ?? true,
469
+ uniPreset: userOptions.unocss?.uniPreset ?? DEFAULT_UNI_PRESET,
470
+ safelist: userOptions.unocss?.safelist ?? [],
471
+ themeColors: userOptions.unocss?.themeColors ?? {}
472
+ };
412
473
  return {
413
474
  srcDir,
414
475
  dirs,
476
+ unocss,
415
477
  imports,
416
478
  overrides: userOptions.overrides
417
479
  };
418
480
  }
419
481
 
482
+ // src/plugins/unocss.ts
483
+ var import_unocss_preset_uni = require("@uni-helper/unocss-preset-uni");
484
+ var import_preset_legacy_compat = __toESM(require("@unocss/preset-legacy-compat"), 1);
485
+ var import_unocss = require("unocss");
486
+ var import_vite2 = __toESM(require("unocss/vite"), 1);
487
+ function presetUniva(userOptions) {
488
+ const presets = [];
489
+ if (userOptions.presetLegacyCompat) {
490
+ presets.push((0, import_preset_legacy_compat.default)({
491
+ commaStyleColorFunction: true,
492
+ legacyColorSpace: true
493
+ }));
494
+ }
495
+ return {
496
+ name: `${ID}-preset`,
497
+ presets: [
498
+ (0, import_unocss_preset_uni.presetUni)(userOptions.uniPreset),
499
+ (0, import_unocss.presetIcons)({
500
+ scale: 1.2,
501
+ warn: true,
502
+ extraProperties: {
503
+ "display": "inline-block",
504
+ "vertical-align": "middle"
505
+ }
506
+ }),
507
+ ...presets
508
+ ],
509
+ shortcuts: [
510
+ ["border-s", "border border-solid"],
511
+ ["wh-full", "w-full h-full"],
512
+ ["f-c-c", "flex justify-center items-center"],
513
+ ["f-col-c", "flex-col justify-center items-center"],
514
+ ["flex-items", "flex items-center"],
515
+ ["flex-justify", "flex justify-center"],
516
+ ["flex-col", "flex flex-col"]
517
+ ],
518
+ transformers: [(0, import_unocss.transformerDirectives)(), (0, import_unocss.transformerVariantGroup)()],
519
+ rules: [
520
+ [
521
+ "p-safe",
522
+ {
523
+ padding: "env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)"
524
+ }
525
+ ],
526
+ ["pt-safe", { "padding-top": "env(safe-area-inset-top)" }],
527
+ ["pb-safe", { "padding-bottom": "env(safe-area-inset-bottom)" }]
528
+ ],
529
+ safelist: userOptions.safelist,
530
+ theme: {
531
+ colors: userOptions.themeColors
532
+ }
533
+ };
534
+ }
535
+ function createUnocssPlugin(univaOptions, unocssOptions = {}) {
536
+ return (0, import_vite2.default)({
537
+ presets: [
538
+ presetUniva(univaOptions)
539
+ ],
540
+ ...unocssOptions
541
+ });
542
+ }
543
+
420
544
  // src/plugins/index.ts
421
545
  var context;
422
546
  function createCorePlugin() {
@@ -475,7 +599,7 @@ function createUnivaPlugins(resolved) {
475
599
  enabledGlobalRef: true,
476
600
  rootFileName: ROOT_NAME,
477
601
  excludePages: [
478
- "components-async/**/*.*"
602
+ `${COMPONENTS_ASYNC_DIR_NAME}/**/*.*`
479
603
  ],
480
604
  ...resolved.overrides?.root
481
605
  }));
@@ -490,7 +614,13 @@ function createUnivaPlugins(resolved) {
490
614
  ...resolved.overrides?.manifest
491
615
  }));
492
616
  plugins.push(...(0, import_plugin_uni.default)());
493
- plugins.push(...(0, import_vite2.default)());
617
+ plugins.push((0, import_vite_plugin_uni_polyfill.default)());
618
+ plugins.push(createUnocssPlugin(resolved.unocss, resolved.overrides?.unocss));
619
+ plugins.push((0, import_bundle_optimizer.default)({
620
+ enable: true,
621
+ logger: resolved.debug,
622
+ ...resolved.overrides?.optimization
623
+ }));
494
624
  const { presets, dirs } = resolveApiSources(resolved.imports.apis, srcDir);
495
625
  const autoImportPlugin = (0, import_vite3.default)({
496
626
  imports: presets,
@@ -513,14 +643,14 @@ function Univa() {
513
643
  context.loadUserConfigSync();
514
644
  setDebug(context.config?.debug ?? false);
515
645
  context.ensureRootComponent(`${ROOT_NAME}.vue`);
516
- const resolved = resolveOptions2(context.config || {});
646
+ const resolved = resolveOptions2(context.config || {}, context.root);
517
647
  log("\u5DF2\u52A0\u8F7D\u914D\u7F6E\uFF1A", context.configPath || "\u9ED8\u8BA4\u914D\u7F6E");
518
648
  return createUnivaPlugins(resolved);
519
649
  }
520
650
  var plugins_default = Univa;
521
651
 
522
652
  // src/index.ts
523
- var import_unocss_preset_uni = require("@uni-helper/unocss-preset-uni");
653
+ var import_unocss_preset_uni2 = require("@uni-helper/unocss-preset-uni");
524
654
  var import_vite_plugin_uni_components2 = require("@uni-helper/vite-plugin-uni-components");
525
655
  var import_vite_plugin_uni_components3 = __toESM(require("@uni-helper/vite-plugin-uni-components"), 1);
526
656
  var import_vite_plugin_uni_layouts2 = require("@uni-helper/vite-plugin-uni-layouts");
@@ -530,7 +660,6 @@ var import_vite4 = __toESM(require("unplugin-auto-import/vite"), 1);
530
660
  // Annotate the CommonJS export names for ESM import in node:
531
661
  0 && (module.exports = {
532
662
  AutoImport,
533
- PageContext,
534
663
  UniKuRoot,
535
664
  Univa,
536
665
  VitePluginUniComponents,
package/dist/index.d.cts CHANGED
@@ -1,14 +1,18 @@
1
1
  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
+ import { UserUniPresetOptions } from '@uni-helper/unocss-preset-uni';
4
+ export { UserUniPresetOptions, presetUni } from '@uni-helper/unocss-preset-uni';
3
5
  import { Options } from '@uni-helper/vite-plugin-uni-components';
4
6
  export { ComponentInfo, ComponentResolver, Options as ComponentsOptions, ResolvedOptions as ComponentsResolvedOptions, ImportInfo, default as VitePluginUniComponents, camelCase, kebabCase, pascalCase } from '@uni-helper/vite-plugin-uni-components';
5
7
  import { UserManifestConfig } from '@uni-helper/vite-plugin-uni-manifest';
6
8
  import { UserOptions } from '@uni-helper/vite-plugin-uni-pages';
7
9
  export { PageContext, PagePath, UserOptions as PagesPluginOptions, ResolvedOptions as PagesResolvedOptions, SubPageMetaDatum, VitePluginUniPages, definePage } from '@uni-helper/vite-plugin-uni-pages';
10
+ import { OptimizationOptions } from '@uni-ku/bundle-optimizer';
11
+ import { ConfigBase } from 'unocss';
12
+ export { ConfigBase as UnoCSSConfigBase } from 'unocss';
8
13
  import { Options as Options$1 } from 'unplugin-auto-import/types';
9
14
  export { Options as AutoImportOptions } from 'unplugin-auto-import/types';
10
15
  import { PluginOption } from 'vite';
11
- export { presetUni } from '@uni-helper/unocss-preset-uni';
12
16
  export { VitePluginUniLayouts } from '@uni-helper/vite-plugin-uni-layouts';
13
17
  export { default as UniKuRoot } from '@uni-ku/root';
14
18
  export { default as AutoImport } from 'unplugin-auto-import/vite';
@@ -58,6 +62,13 @@ interface UnivaDirs {
58
62
  /** 布局目录,默认 'layouts' */
59
63
  layouts?: string;
60
64
  }
65
+ interface UnivaUnocss {
66
+ /** 是否开启兼容模式,默认 false */
67
+ presetLegacyCompat?: boolean;
68
+ uniPreset?: UserUniPresetOptions;
69
+ safelist?: string[];
70
+ themeColors?: Record<string, string>;
71
+ }
61
72
  /**
62
73
  * 自动导入配置
63
74
  */
@@ -91,6 +102,12 @@ interface ResolvedUnivaDirs {
91
102
  subPackages: string[];
92
103
  layouts: string;
93
104
  }
105
+ interface ResolvedUnivaUnocss {
106
+ presetLegacyCompat: boolean;
107
+ uniPreset: UserUniPresetOptions;
108
+ safelist: string[];
109
+ themeColors: Record<string, string>;
110
+ }
94
111
  /**
95
112
  * 解析后的自动导入配置(字段必填,已应用默认值)
96
113
  */
@@ -118,10 +135,7 @@ interface RootOptions {
118
135
  /**
119
136
  * UnoCSS 模块底层选项(用于 overrides)
120
137
  */
121
- interface UnoCSSOptions {
122
- presets?: unknown[];
123
- rules?: unknown[];
124
- shortcuts?: Record<string, string | string[]>;
138
+ interface UnoCSSOptions extends ConfigBase {
125
139
  }
126
140
  /**
127
141
  * 底层插件逃生口
@@ -144,6 +158,8 @@ interface UnivaOverrides {
144
158
  unocss?: UnoCSSOptions;
145
159
  /** @uni-helper/vite-plugin-uni-manifest 完整选项 */
146
160
  manifest?: UserManifestOptions;
161
+ /** @uni-ku/bundle-optimizer 完整选项 */
162
+ optimization?: OptimizationOptions;
147
163
  }
148
164
  /**
149
165
  * Univa 统一配置接口(工程级约定)
@@ -170,6 +186,7 @@ interface UnivaOptions {
170
186
  pages?: Partial<PagesConfig>;
171
187
  /** 应用级 manifest.json 配置 */
172
188
  manifest?: Partial<UserManifestConfig>;
189
+ unocss?: UnivaUnocss;
173
190
  /** 底层插件逃生口(覆盖融合层默认,高级用户使用) */
174
191
  overrides?: UnivaOverrides;
175
192
  }
@@ -186,6 +203,7 @@ interface ResolvedOptions extends Omit<UnivaOptions, 'dirs' | 'imports' | 'srcDi
186
203
  dirs: ResolvedUnivaDirs;
187
204
  /** 自动导入配置(已应用默认值,字段必填) */
188
205
  imports: ResolvedUnivaImports;
206
+ unocss: ResolvedUnivaUnocss;
189
207
  }
190
208
 
191
209
  /**
@@ -219,4 +237,4 @@ declare function createUnivaPlugins(resolved: ResolvedOptions): PluginOption[];
219
237
  */
220
238
  declare function Univa(): PluginOption[];
221
239
 
222
- export { type LayoutsOptions, type ResolvedOptions, type ResolvedUnivaDirs, type ResolvedUnivaImports, type RootOptions, Univa, type UnivaDirs, type UnivaImports, type UnivaOptions, type UnivaOverrides, type UnoCSSOptions, createUnivaPlugins, defineConfig };
240
+ export { type LayoutsOptions, type ResolvedOptions, type ResolvedUnivaDirs, type ResolvedUnivaImports, type ResolvedUnivaUnocss, type RootOptions, Univa, type UnivaDirs, type UnivaImports, type UnivaOptions, type UnivaOverrides, type UnivaUnocss, type UnoCSSOptions, createUnivaPlugins, defineConfig };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
1
  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
+ import { UserUniPresetOptions } from '@uni-helper/unocss-preset-uni';
4
+ export { UserUniPresetOptions, presetUni } from '@uni-helper/unocss-preset-uni';
3
5
  import { Options } from '@uni-helper/vite-plugin-uni-components';
4
6
  export { ComponentInfo, ComponentResolver, Options as ComponentsOptions, ResolvedOptions as ComponentsResolvedOptions, ImportInfo, default as VitePluginUniComponents, camelCase, kebabCase, pascalCase } from '@uni-helper/vite-plugin-uni-components';
5
7
  import { UserManifestConfig } from '@uni-helper/vite-plugin-uni-manifest';
6
8
  import { UserOptions } from '@uni-helper/vite-plugin-uni-pages';
7
9
  export { PageContext, PagePath, UserOptions as PagesPluginOptions, ResolvedOptions as PagesResolvedOptions, SubPageMetaDatum, VitePluginUniPages, definePage } from '@uni-helper/vite-plugin-uni-pages';
10
+ import { OptimizationOptions } from '@uni-ku/bundle-optimizer';
11
+ import { ConfigBase } from 'unocss';
12
+ export { ConfigBase as UnoCSSConfigBase } from 'unocss';
8
13
  import { Options as Options$1 } from 'unplugin-auto-import/types';
9
14
  export { Options as AutoImportOptions } from 'unplugin-auto-import/types';
10
15
  import { PluginOption } from 'vite';
11
- export { presetUni } from '@uni-helper/unocss-preset-uni';
12
16
  export { VitePluginUniLayouts } from '@uni-helper/vite-plugin-uni-layouts';
13
17
  export { default as UniKuRoot } from '@uni-ku/root';
14
18
  export { default as AutoImport } from 'unplugin-auto-import/vite';
@@ -58,6 +62,13 @@ interface UnivaDirs {
58
62
  /** 布局目录,默认 'layouts' */
59
63
  layouts?: string;
60
64
  }
65
+ interface UnivaUnocss {
66
+ /** 是否开启兼容模式,默认 false */
67
+ presetLegacyCompat?: boolean;
68
+ uniPreset?: UserUniPresetOptions;
69
+ safelist?: string[];
70
+ themeColors?: Record<string, string>;
71
+ }
61
72
  /**
62
73
  * 自动导入配置
63
74
  */
@@ -91,6 +102,12 @@ interface ResolvedUnivaDirs {
91
102
  subPackages: string[];
92
103
  layouts: string;
93
104
  }
105
+ interface ResolvedUnivaUnocss {
106
+ presetLegacyCompat: boolean;
107
+ uniPreset: UserUniPresetOptions;
108
+ safelist: string[];
109
+ themeColors: Record<string, string>;
110
+ }
94
111
  /**
95
112
  * 解析后的自动导入配置(字段必填,已应用默认值)
96
113
  */
@@ -118,10 +135,7 @@ interface RootOptions {
118
135
  /**
119
136
  * UnoCSS 模块底层选项(用于 overrides)
120
137
  */
121
- interface UnoCSSOptions {
122
- presets?: unknown[];
123
- rules?: unknown[];
124
- shortcuts?: Record<string, string | string[]>;
138
+ interface UnoCSSOptions extends ConfigBase {
125
139
  }
126
140
  /**
127
141
  * 底层插件逃生口
@@ -144,6 +158,8 @@ interface UnivaOverrides {
144
158
  unocss?: UnoCSSOptions;
145
159
  /** @uni-helper/vite-plugin-uni-manifest 完整选项 */
146
160
  manifest?: UserManifestOptions;
161
+ /** @uni-ku/bundle-optimizer 完整选项 */
162
+ optimization?: OptimizationOptions;
147
163
  }
148
164
  /**
149
165
  * Univa 统一配置接口(工程级约定)
@@ -170,6 +186,7 @@ interface UnivaOptions {
170
186
  pages?: Partial<PagesConfig>;
171
187
  /** 应用级 manifest.json 配置 */
172
188
  manifest?: Partial<UserManifestConfig>;
189
+ unocss?: UnivaUnocss;
173
190
  /** 底层插件逃生口(覆盖融合层默认,高级用户使用) */
174
191
  overrides?: UnivaOverrides;
175
192
  }
@@ -186,6 +203,7 @@ interface ResolvedOptions extends Omit<UnivaOptions, 'dirs' | 'imports' | 'srcDi
186
203
  dirs: ResolvedUnivaDirs;
187
204
  /** 自动导入配置(已应用默认值,字段必填) */
188
205
  imports: ResolvedUnivaImports;
206
+ unocss: ResolvedUnivaUnocss;
189
207
  }
190
208
 
191
209
  /**
@@ -219,4 +237,4 @@ declare function createUnivaPlugins(resolved: ResolvedOptions): PluginOption[];
219
237
  */
220
238
  declare function Univa(): PluginOption[];
221
239
 
222
- export { type LayoutsOptions, type ResolvedOptions, type ResolvedUnivaDirs, type ResolvedUnivaImports, type RootOptions, Univa, type UnivaDirs, type UnivaImports, type UnivaOptions, type UnivaOverrides, type UnoCSSOptions, createUnivaPlugins, defineConfig };
240
+ export { type LayoutsOptions, type ResolvedOptions, type ResolvedUnivaDirs, type ResolvedUnivaImports, type ResolvedUnivaUnocss, type RootOptions, Univa, type UnivaDirs, type UnivaImports, type UnivaOptions, type UnivaOverrides, type UnivaUnocss, type UnoCSSOptions, createUnivaPlugins, defineConfig };