vite-plugin-uni-inject 0.3.0 → 0.3.1

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 CHANGED
@@ -169,6 +169,8 @@ function hasPagesJsonChanged(current, next) {
169
169
  });
170
170
  }
171
171
  function getPagesByFileRoute(routes, pagesJson, subPackageRoots) {
172
+ const originPages = pagesJson.pages ?? [];
173
+ const originSubPackages = pagesJson.subPackages ?? [];
172
174
  const mainRoutes = [];
173
175
  const subRouteMap = /* @__PURE__ */ new Map();
174
176
  const normalizedSubRoots = subPackageRoots.map(normalizeDir);
@@ -183,12 +185,17 @@ function getPagesByFileRoute(routes, pagesJson, subPackageRoots) {
183
185
  subRouteMap.set(matchedRoot, list);
184
186
  } else mainRoutes.push(route);
185
187
  }
186
- const pages = mergePages(mainRoutes, pagesJson.pages ?? []);
187
- const existSubs = pagesJson.subPackages ?? [];
188
+ const homePage = originPages[0]?.path;
189
+ if (mainRoutes.includes(homePage)) {
190
+ const idx = mainRoutes.indexOf(homePage);
191
+ mainRoutes.splice(idx, 1);
192
+ mainRoutes.unshift(homePage);
193
+ }
194
+ const pages = mergePages(mainRoutes, originPages);
188
195
  const subPackages = normalizedSubRoots.map((root) => {
189
196
  return {
190
197
  root,
191
- pages: mergePages(subRouteMap.get(root) ?? [], existSubs.find((s) => {
198
+ pages: mergePages(subRouteMap.get(root) ?? [], originSubPackages.find((s) => {
192
199
  return normalizeDir(s.root) === root;
193
200
  })?.pages ?? [])
194
201
  };
package/dist/index.d.cts CHANGED
@@ -3,12 +3,17 @@
3
3
  interface InjectPluginOptions {
4
4
  /**
5
5
  * 注入的文件路径
6
- * @default 'src/App.inject.vue'
6
+ * @default './App.inject.vue'
7
7
  */
8
8
  path?: string;
9
9
  }
10
10
  /** 自动补全 pages 插件配置 */
11
11
  interface AutoPagesPluginOptions {
12
+ /**
13
+ * 输出类型
14
+ * @default './uni-pages.d.ts'
15
+ */
16
+ dts?: string;
12
17
  /**
13
18
  * 扫描目录
14
19
  * @default 'pages'
@@ -19,11 +24,6 @@ interface AutoPagesPluginOptions {
19
24
  * @default []
20
25
  */
21
26
  subPackages?: string[];
22
- /**
23
- * 生成类型声明
24
- * @default 'src/uni-pages.d.ts'
25
- */
26
- dts?: string;
27
27
  }
28
28
  //#endregion
29
29
  //#region src/inject.d.ts
package/dist/index.d.mts CHANGED
@@ -3,12 +3,17 @@
3
3
  interface InjectPluginOptions {
4
4
  /**
5
5
  * 注入的文件路径
6
- * @default 'src/App.inject.vue'
6
+ * @default './App.inject.vue'
7
7
  */
8
8
  path?: string;
9
9
  }
10
10
  /** 自动补全 pages 插件配置 */
11
11
  interface AutoPagesPluginOptions {
12
+ /**
13
+ * 输出类型
14
+ * @default './uni-pages.d.ts'
15
+ */
16
+ dts?: string;
12
17
  /**
13
18
  * 扫描目录
14
19
  * @default 'pages'
@@ -19,11 +24,6 @@ interface AutoPagesPluginOptions {
19
24
  * @default []
20
25
  */
21
26
  subPackages?: string[];
22
- /**
23
- * 生成类型声明
24
- * @default 'src/uni-pages.d.ts'
25
- */
26
- dts?: string;
27
27
  }
28
28
  //#endregion
29
29
  //#region src/inject.d.ts
package/dist/index.mjs CHANGED
@@ -143,6 +143,8 @@ function hasPagesJsonChanged(current, next) {
143
143
  });
144
144
  }
145
145
  function getPagesByFileRoute(routes, pagesJson, subPackageRoots) {
146
+ const originPages = pagesJson.pages ?? [];
147
+ const originSubPackages = pagesJson.subPackages ?? [];
146
148
  const mainRoutes = [];
147
149
  const subRouteMap = /* @__PURE__ */ new Map();
148
150
  const normalizedSubRoots = subPackageRoots.map(normalizeDir);
@@ -157,12 +159,17 @@ function getPagesByFileRoute(routes, pagesJson, subPackageRoots) {
157
159
  subRouteMap.set(matchedRoot, list);
158
160
  } else mainRoutes.push(route);
159
161
  }
160
- const pages = mergePages(mainRoutes, pagesJson.pages ?? []);
161
- const existSubs = pagesJson.subPackages ?? [];
162
+ const homePage = originPages[0]?.path;
163
+ if (mainRoutes.includes(homePage)) {
164
+ const idx = mainRoutes.indexOf(homePage);
165
+ mainRoutes.splice(idx, 1);
166
+ mainRoutes.unshift(homePage);
167
+ }
168
+ const pages = mergePages(mainRoutes, originPages);
162
169
  const subPackages = normalizedSubRoots.map((root) => {
163
170
  return {
164
171
  root,
165
- pages: mergePages(subRouteMap.get(root) ?? [], existSubs.find((s) => {
172
+ pages: mergePages(subRouteMap.get(root) ?? [], originSubPackages.find((s) => {
166
173
  return normalizeDir(s.root) === root;
167
174
  })?.pages ?? [])
168
175
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Kriac",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "version": "0.3.0",
7
+ "version": "0.3.1",
8
8
  "homepage": "https://github.com/Kriac/vite-plugin-uni-inject",
9
9
  "repository": {
10
10
  "type": "git",