@uni-helper/vite-plugin-uni-pages 0.2.1 → 0.2.3

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/client.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  declare module "virtual:uni-pages" {
2
- export const pages: {
3
- path: string;
4
- type: "home" | "page";
5
- style: any;
6
- }[];
2
+ import { PageMetaDatum } from "./src/types";
3
+ import { SubPackage } from "./src/config/types/index";
4
+ export const pages: PageMetaDatum[];
5
+ export const subPackages: SubPackage[];
7
6
  }
package/dist/index.cjs CHANGED
@@ -221,12 +221,10 @@ ${err.message}`
221
221
  );
222
222
  }
223
223
  }
224
- if (content) {
225
- return {
226
- attr,
227
- content
228
- };
229
- }
224
+ return {
225
+ attr,
226
+ content: content ?? {}
227
+ };
230
228
  }
231
229
  async function getRouteBlock(path, options) {
232
230
  const content = fs__default.readFileSync(path, "utf8");
@@ -423,12 +421,17 @@ class PageContext {
423
421
  writeFileSync(this.resolvedPagesJSONPath, pagesJson);
424
422
  this.options.onAfterWriteFile(this);
425
423
  }
426
- async virtualModule() {
427
- return `export const pages = ${this.resolveRoutes()};`;
424
+ virtualModule() {
425
+ const pages = `export const pages = ${this.resolveRoutes()};`;
426
+ const subPackages = `export const subPackages = ${this.resolveSubRoutes()};`;
427
+ return [pages, subPackages].join("\n");
428
428
  }
429
429
  resolveRoutes() {
430
430
  return JSON.stringify(this.pageMetaData, null, 2);
431
431
  }
432
+ resolveSubRoutes() {
433
+ return JSON.stringify(this.subPageMetaData, null, 2);
434
+ }
432
435
  }
433
436
  function getPagePaths(dir, options) {
434
437
  const pagesDirPath = slash(path__default.resolve(options.root, dir));
package/dist/index.d.ts CHANGED
@@ -661,8 +661,9 @@ declare class PageContext {
661
661
  mergePageMetaData(): Promise<void>;
662
662
  mergeSubPageMetaData(): Promise<void>;
663
663
  updatePagesJSON(): Promise<void>;
664
- virtualModule(): Promise<string>;
664
+ virtualModule(): string;
665
665
  resolveRoutes(): string;
666
+ resolveSubRoutes(): string;
666
667
  }
667
668
 
668
669
  declare function invalidatePagesModule(server: ViteDevServer): void;
package/dist/index.mjs CHANGED
@@ -207,12 +207,10 @@ ${err.message}`
207
207
  );
208
208
  }
209
209
  }
210
- if (content) {
211
- return {
212
- attr,
213
- content
214
- };
215
- }
210
+ return {
211
+ attr,
212
+ content: content ?? {}
213
+ };
216
214
  }
217
215
  async function getRouteBlock(path, options) {
218
216
  const content = fs.readFileSync(path, "utf8");
@@ -409,12 +407,17 @@ class PageContext {
409
407
  writeFileSync(this.resolvedPagesJSONPath, pagesJson);
410
408
  this.options.onAfterWriteFile(this);
411
409
  }
412
- async virtualModule() {
413
- return `export const pages = ${this.resolveRoutes()};`;
410
+ virtualModule() {
411
+ const pages = `export const pages = ${this.resolveRoutes()};`;
412
+ const subPackages = `export const subPackages = ${this.resolveSubRoutes()};`;
413
+ return [pages, subPackages].join("\n");
414
414
  }
415
415
  resolveRoutes() {
416
416
  return JSON.stringify(this.pageMetaData, null, 2);
417
417
  }
418
+ resolveSubRoutes() {
419
+ return JSON.stringify(this.subPageMetaData, null, 2);
420
+ }
418
421
  }
419
422
  function getPagePaths(dir, options) {
420
423
  const pagesDirPath = slash(path.resolve(options.root, dir));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uni-helper/vite-plugin-uni-pages",
3
3
  "type": "module",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "description": "File system based routing for uni-app applications using Vite",
6
6
  "author": "KeJun",
7
7
  "license": "MIT",