@vixt/uni 0.11.2 → 0.12.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.
@@ -26,9 +26,9 @@ var node_default = createVixtPlugin({ defaults: {
26
26
  compilerOptions: { types: [
27
27
  "@vixt/uni/types",
28
28
  "@dcloudio/types",
29
- "@uni-helper/uni-app-types"
29
+ "@uni-helper/uni-types"
30
30
  ] },
31
- vueCompilerOptions: { plugins: ["@uni-helper/uni-app-types/volar-plugin"] }
31
+ vueCompilerOptions: { plugins: ["@uni-helper/uni-types/volar-plugin"] }
32
32
  } },
33
33
  vite: { optimizeDeps: { exclude: plugins } }
34
34
  } });
@@ -27,7 +27,7 @@ var preset_uni_default = defineVixtModule({
27
27
  uni_layouts_default(options.uniLayouts),
28
28
  Components(options.uniComponents),
29
29
  uni_patch_default(),
30
- (Uni?.default ?? Uni)(options.uni)
30
+ Uni(options.uni)
31
31
  ];
32
32
  }
33
33
  });
@@ -1,13 +1,2 @@
1
- //#region src/node/modules/uni-modules.d.ts
2
- declare module '@vixt/core' {
3
- interface VixtOptions {
4
- uniModules?: ModuleOptions;
5
- }
6
- }
7
- interface ModuleOptions {
8
- include?: string[];
9
- exclude?: string[];
10
- }
11
- declare const _default: import("@vixt/core").VixtModule<import("@vixt/core").ModuleOptions>;
12
- //#endregion
13
- export { ModuleOptions, _default as default };
1
+ import { n as _default, t as UniModulesOptions } from "../uni-modules-DKxzU50K.mjs";
2
+ export { UniModulesOptions, _default as default };
@@ -1,6 +1,13 @@
1
1
  import { ResolvedConfig } from "vite";
2
2
 
3
3
  //#region src/node/modules/uni-patch.d.ts
4
+ /** 移除路径中的'../' */
5
+ declare function overrideNormalizeNodeModules(): void;
6
+ /**
7
+ * fix `@uni-helper/vite-plugin-uni-pages` client types
8
+ * @see https://github.com/uni-helper/vite-plugin-uni-pages/blob/v0.3.24/packages/core/client.d.ts#L4
9
+ */
10
+ declare function overrideUniPagesTypes(): void;
4
11
  /** 增加小程序中vueuse的运行所需 */
5
12
  declare function transformMpRuntime(code: string, id: string): string;
6
13
  /**
@@ -10,29 +17,22 @@ declare function transformMpRuntime(code: string, id: string): string;
10
17
  declare function transformH5Runtime(code: string, id: string): string;
11
18
  /** 修复app运行白屏,原因是pinia调用了@vue/devtools-kit的setupDevToolsPlugin */
12
19
  declare function transformPinia(code: string, id: string): string;
13
- /** 移除路径中的'../' */
14
- declare function patchNormalizeNodeModules(): void;
20
+ /**
21
+ * fix `@uni-helper/vite-plugin-uni-components` load slowly
22
+ * @see https://github.com/uni-helper/vite-plugin-uni-components/blob/v0.2.6/packages/core/src/index.ts#L27
23
+ */
24
+ declare function modifyUniComponentsConfig(config: ResolvedConfig): void;
15
25
  /**
16
26
  * 兼容 unocss^66.1.0 小程序平台的css文件后缀名
17
27
  * @see https://github.com/dcloudio/uni-app/pull/5605/files
28
+ * @fixed 官方已修复
18
29
  */
19
- declare function patchAdjustCssExtname(config: ResolvedConfig): void;
20
30
  /**
21
31
  * fix unocss^66.1.0 hot reload fail `[unocss:global:build:scan] Could not load xxx/src/__uno.css`
22
32
  * @see https://github.com/unocss/unocss/issues/4616
23
33
  * @see https://github.com/unocss/unocss/pull/4737
34
+ * @fixed 官方已修复
24
35
  */
25
- declare function patchUnocssGlobalBuildScan(config: ResolvedConfig): void;
26
- /**
27
- * fix `@uni-helper/vite-plugin-uni-components` load slowly
28
- * @see https://github.com/uni-helper/vite-plugin-uni-components/blob/main/packages/core/src/index.ts#L27
29
- */
30
- declare function patchUniComponents(config: ResolvedConfig): void;
31
- /**
32
- * fix `@uni-helper/vite-plugin-uni-pages` client types
33
- * @see https://github.com/uni-helper/vite-plugin-uni-pages/blob/main/packages/core/client.d.ts#L4
34
- */
35
- declare function patchUniPagesTypes(): void;
36
36
  declare const _default: (options?: any) => import("vite").PluginOption;
37
37
  //#endregion
38
- export { _default as default, patchAdjustCssExtname, patchNormalizeNodeModules, patchUniComponents, patchUniPagesTypes, patchUnocssGlobalBuildScan, transformH5Runtime, transformMpRuntime, transformPinia };
38
+ export { _default as default, modifyUniComponentsConfig, overrideNormalizeNodeModules, overrideUniPagesTypes, transformH5Runtime, transformMpRuntime, transformPinia };
@@ -4,6 +4,31 @@ import { resolvePathSync } from "mlly";
4
4
  import path from "pathe";
5
5
  import { normalizePath } from "vite";
6
6
  //#region src/node/modules/uni-patch.ts
7
+ /** 移除路径中的'../' */
8
+ function overrideNormalizeNodeModules() {
9
+ const matched = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');`;
10
+ const replaced = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules').replace(/\\.\\.\\//g, '');`;
11
+ const codePath = resolvePathSync("@dcloudio/uni-cli-shared/dist/utils.js");
12
+ let code = fs.readFileSync(codePath, "utf-8");
13
+ if (code.includes(matched)) {
14
+ code = code.replace(matched, replaced);
15
+ fs.writeFileSync(codePath, code);
16
+ }
17
+ }
18
+ /**
19
+ * fix `@uni-helper/vite-plugin-uni-pages` client types
20
+ * @see https://github.com/uni-helper/vite-plugin-uni-pages/blob/v0.3.24/packages/core/client.d.ts#L4
21
+ */
22
+ function overrideUniPagesTypes() {
23
+ const matched = ` import type { SubPackage } from './src/config/types/index'\n import type { PageMetaDatum } from './src/types'`;
24
+ const replaced = ` import type { PageMetaDatum, SubPackage } from '@uni-helper/vite-plugin-uni-pages'`;
25
+ const codePath = path.resolve(resolvePathSync("@uni-helper/vite-plugin-uni-pages"), "../../client.d.ts");
26
+ let code = codePath && fs.readFileSync(codePath, "utf-8");
27
+ if (code.includes(matched)) {
28
+ code = code.replace(matched, replaced);
29
+ fs.outputFileSync(codePath, code);
30
+ }
31
+ }
7
32
  /** 增加小程序中vueuse的运行所需 */
8
33
  function transformMpRuntime(code, id) {
9
34
  if (!id.endsWith("@dcloudio/uni-mp-vue/dist/vue.runtime.esm.js")) return code;
@@ -28,94 +53,40 @@ function transformPinia(code, id) {
28
53
  code = code.replace(`import { setupDevtoolsPlugin } from '@vue/devtools-api';`, `function setupDevtoolsPlugin() {};`);
29
54
  return code;
30
55
  }
31
- /** 移除路径中的'../' */
32
- function patchNormalizeNodeModules() {
33
- const matched = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules');`;
34
- const replaced = `str = normalizePath(str).replace(NODE_MODULES_REGEX, 'node-modules').replace(/\\.\\.\\//g, '');`;
35
- const codePath = resolvePathSync("@dcloudio/uni-cli-shared/dist/utils.js");
36
- let code = fs.readFileSync(codePath, "utf-8");
37
- if (code.includes(matched)) {
38
- code = code.replace(matched, replaced);
39
- fs.writeFileSync(codePath, code);
40
- }
56
+ /**
57
+ * fix `@uni-helper/vite-plugin-uni-components` load slowly
58
+ * @see https://github.com/uni-helper/vite-plugin-uni-components/blob/v0.2.6/packages/core/src/index.ts#L27
59
+ */
60
+ function modifyUniComponentsConfig(config) {
61
+ if (JSON.stringify(config.build.watch) === "{}") config.build.watch = null;
41
62
  }
42
63
  /**
43
64
  * 兼容 unocss^66.1.0 小程序平台的css文件后缀名
44
65
  * @see https://github.com/dcloudio/uni-app/pull/5605/files
66
+ * @fixed 官方已修复
45
67
  */
46
- function patchAdjustCssExtname(config) {
47
- const plugin = config.plugins.find((p) => p.name === "uni:adjust-css-extname");
48
- if (plugin && typeof plugin.generateBundle === "function") plugin.generateBundle = {
49
- order: "post",
50
- handler: plugin.generateBundle
51
- };
52
- }
53
68
  /**
54
69
  * fix unocss^66.1.0 hot reload fail `[unocss:global:build:scan] Could not load xxx/src/__uno.css`
55
70
  * @see https://github.com/unocss/unocss/issues/4616
56
71
  * @see https://github.com/unocss/unocss/pull/4737
72
+ * @fixed 官方已修复
57
73
  */
58
- function patchUnocssGlobalBuildScan(config) {
59
- const plugin = config.plugins.find((p) => p.name === "unocss:global:build:scan");
60
- if (plugin) plugin.shouldTransformCachedModule = ({ code }) => code.includes("virtual:uno.css");
61
- }
62
- /**
63
- * fix `@uni-helper/vite-plugin-uni-components` load slowly
64
- * @see https://github.com/uni-helper/vite-plugin-uni-components/blob/main/packages/core/src/index.ts#L27
65
- */
66
- function patchUniComponents(config) {
67
- if (JSON.stringify(config.build.watch) === "{}") config.build.watch = null;
68
- }
69
- /**
70
- * fix `@uni-helper/vite-plugin-uni-pages` client types
71
- * @see https://github.com/uni-helper/vite-plugin-uni-pages/blob/main/packages/core/client.d.ts#L4
72
- */
73
- function patchUniPagesTypes() {
74
- const matched = ` import type { SubPackage } from './src/config/types/index'\n import type { PageMetaDatum } from './src/types'`;
75
- const replaced = ` import type { PageMetaDatum, SubPackage } from '@uni-helper/vite-plugin-uni-pages'`;
76
- const codePath = path.resolve(resolvePathSync("@uni-helper/vite-plugin-uni-pages"), "../../client.d.ts");
77
- let code = codePath && fs.readFileSync(codePath, "utf-8");
78
- if (code.includes(matched)) {
79
- code = code.replace(matched, replaced);
80
- fs.outputFileSync(codePath, code);
81
- }
82
- }
83
74
  var uni_patch_default = defineVitePlugin(() => {
84
- patchNormalizeNodeModules();
85
- patchUniPagesTypes();
86
- return [
87
- {
88
- name: "vixt:uni-patch-runtime",
89
- transform(code, id) {
90
- id = normalizePath(id);
91
- code = transformMpRuntime(code, id);
92
- code = transformH5Runtime(code, id);
93
- code = transformPinia(code, id);
94
- return code;
95
- }
75
+ overrideNormalizeNodeModules();
76
+ overrideUniPagesTypes();
77
+ return {
78
+ name: "vixt:uni-patch",
79
+ transform(code, id) {
80
+ id = normalizePath(id);
81
+ code = transformMpRuntime(code, id);
82
+ code = transformH5Runtime(code, id);
83
+ code = transformPinia(code, id);
84
+ return code;
96
85
  },
97
- {
98
- name: "vixt:uni-patch-uni-components",
99
- configResolved(config) {
100
- patchUniComponents(config);
101
- }
102
- },
103
- {
104
- name: "vixt:uni-patch-unocss-global-build-scan",
105
- apply: "build",
106
- enforce: "pre",
107
- configResolved(config) {
108
- patchUnocssGlobalBuildScan(config);
109
- }
110
- },
111
- {
112
- name: "vixt:uni-patch-adjust-css-extname",
113
- enforce: "post",
114
- configResolved(config) {
115
- patchAdjustCssExtname(config);
116
- }
86
+ configResolved(config) {
87
+ modifyUniComponentsConfig(config);
117
88
  }
118
- ];
89
+ };
119
90
  });
120
91
  //#endregion
121
- export { uni_patch_default as default, patchAdjustCssExtname, patchNormalizeNodeModules, patchUniComponents, patchUniPagesTypes, patchUnocssGlobalBuildScan, transformH5Runtime, transformMpRuntime, transformPinia };
92
+ export { uni_patch_default as default, modifyUniComponentsConfig, overrideNormalizeNodeModules, overrideUniPagesTypes, transformH5Runtime, transformMpRuntime, transformPinia };
@@ -1,4 +1,5 @@
1
1
  import { t as UniLayoutsOptions } from "./uni-layouts-DiqR237-.mjs";
2
+ import { t as UniModulesOptions } from "./uni-modules-DKxzU50K.mjs";
2
3
  import { ExtractPluginOptions } from "@vixt/core";
3
4
  import Uni from "@dcloudio/vite-plugin-uni";
4
5
  import Components from "@uni-helper/vite-plugin-uni-components";
@@ -13,6 +14,8 @@ interface UniVixtOptions {
13
14
  uniLayouts?: UniLayoutsOptions;
14
15
  /** https://github.com/uni-helper/vite-plugin-uni-components */
15
16
  uniComponents?: ExtractPluginOptions<typeof Components>;
17
+ /** Options for extends `uni-modules` */
18
+ uniModules?: UniModulesOptions;
16
19
  }
17
20
  declare module '@vixt/core' {
18
21
  interface VixtOptions extends UniVixtOptions {}
@@ -0,0 +1,13 @@
1
+ //#region src/node/modules/uni-modules.d.ts
2
+ declare module '@vixt/core' {
3
+ interface VixtOptions {
4
+ uniModules?: UniModulesOptions;
5
+ }
6
+ }
7
+ interface UniModulesOptions {
8
+ include?: string[];
9
+ exclude?: string[];
10
+ }
11
+ declare const _default: import("@vixt/core").VixtModule<import("@vixt/core").ModuleOptions>;
12
+ //#endregion
13
+ export { _default as n, UniModulesOptions as t };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/uni",
3
3
  "type": "module",
4
- "version": "0.11.2",
4
+ "version": "0.12.0",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://soullyoko.github.io/vixt/",
@@ -27,16 +27,27 @@
27
27
  "files": [
28
28
  "dist"
29
29
  ],
30
+ "peerDependencies": {
31
+ "@dcloudio/vite-plugin-uni": "*",
32
+ "pinia": "*"
33
+ },
30
34
  "dependencies": {
31
35
  "@dcloudio/types": "^3.4.28",
32
- "@uni-helper/uni-app-types": "^1.0.1",
33
- "@uni-helper/uni-use": "^0.19.17",
34
- "@uni-helper/unocss-preset-uni": "^0.2.11",
36
+ "@uni-helper/uni-types": "^1.1.0",
35
37
  "@uni-helper/vite-plugin-uni-components": "0.2.6",
36
38
  "@uni-helper/vite-plugin-uni-layouts": "^0.1.11",
37
39
  "@uni-helper/vite-plugin-uni-pages": "^0.3.24",
38
- "unocss-applet": "^0.12.2",
39
- "@vixt/core": "0.11.2",
40
- "@vixt/vue": "0.11.2"
40
+ "defu": "^6.1.7",
41
+ "fast-glob": "^3.3.3",
42
+ "fs-extra": "^11.3.6",
43
+ "mlly": "^1.8.2",
44
+ "pathe": "^2.0.3",
45
+ "vite": "^7.3.6",
46
+ "vue": "^3.5.39",
47
+ "@vixt/core": "0.12.0"
48
+ },
49
+ "devDependencies": {
50
+ "@dcloudio/vite-plugin-uni": "3.0.0-5000720260410001",
51
+ "pinia": "^3.0.4"
41
52
  }
42
53
  }