@uni-helper/vite-plugin-uni-pages 0.1.3 → 0.1.4

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
@@ -65,6 +65,13 @@ function mergePageMetaDataArray(pageMetaData) {
65
65
  }
66
66
  return result;
67
67
  }
68
+ const getPagesConfigSourcePaths = async () => {
69
+ return await fg("pages.config.(ts|mts|cts|js|cjs|mjs|json)", {
70
+ deep: 0,
71
+ onlyFiles: true,
72
+ absolute: true
73
+ });
74
+ };
68
75
 
69
76
  function resolveOptions(userOptions, viteRoot) {
70
77
  const {
@@ -250,7 +257,11 @@ class PageContext {
250
257
  this._server = server;
251
258
  this.setupWatcher(server.watcher);
252
259
  }
253
- setupWatcher(watcher) {
260
+ async setupWatcher(watcher) {
261
+ if (process.env.UNI_PLATFORM !== "h5") {
262
+ const configs = await getPagesConfigSourcePaths();
263
+ watcher.add(configs);
264
+ }
254
265
  watcher.on("add", async (path2) => {
255
266
  path2 = slash(path2);
256
267
  if (!isTargetFile(path2))
@@ -392,6 +403,7 @@ exports.default = VitePluginUniPages;
392
403
  exports.defineUniPages = defineUniPages;
393
404
  exports.extsToGlob = extsToGlob;
394
405
  exports.getPageFiles = getPageFiles;
406
+ exports.getPagesConfigSourcePaths = getPagesConfigSourcePaths;
395
407
  exports.getRouteBlock = getRouteBlock;
396
408
  exports.invalidatePagesModule = invalidatePagesModule;
397
409
  exports.isConfigFile = isConfigFile;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Logger, ViteDevServer, Plugin } from 'vite';
2
- import { FSWatcher } from 'fs';
2
+ import { FSWatcher } from 'chokidar';
3
3
  import Debug from 'debug';
4
4
  import { SFCDescriptor, SFCBlock } from '@vue/compiler-sfc';
5
5
 
@@ -624,7 +624,7 @@ declare class PageContext {
624
624
  loadUserPagesConfig(): Promise<void>;
625
625
  scanPages(): Promise<void>;
626
626
  setupViteServer(server: ViteDevServer): void;
627
- setupWatcher(watcher: FSWatcher): void;
627
+ setupWatcher(watcher: FSWatcher): Promise<void>;
628
628
  onUpdate(): void;
629
629
  parsePage(page: PagePath): Promise<PageMetaDatum>;
630
630
  mergePageMetaData(): Promise<void>;
@@ -723,6 +723,7 @@ declare function isConfigFile(path: string): boolean;
723
723
  * TODO: support merge middleware
724
724
  */
725
725
  declare function mergePageMetaDataArray(pageMetaData: PageMetaDatum[]): PageMetaDatum[];
726
+ declare const getPagesConfigSourcePaths: () => Promise<string[]>;
726
727
 
727
728
  /**
728
729
  * Resolves the files that are valid pages for the given context.
@@ -743,4 +744,4 @@ declare function getRouteBlock(path: string, options: ResolvedOptions): Promise<
743
744
 
744
745
  declare const VitePluginUniPages: (userOptions?: UserOptions) => Plugin;
745
746
 
746
- export { Condition, ConditionItem, CustomBlock, EasyCom, FILE_EXTENSIONS, GlobalStyle, IconFont, MODULE_ID_VIRTUAL, MidButton, OUTPUT_NAME, Options, PageContext, PageMetaDatum, PagePath, PagesConfig, PreloadRule, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackage, TabBar, TabBarItem, TheWindow, UserOptions, UserPagesConfig, VitePluginUniPages, checkPagesJsonFile, debug, VitePluginUniPages as default, defineUniPages, extsToGlob, getPageFiles, getRouteBlock, invalidatePagesModule, isConfigFile, isTargetFile, mergePageMetaDataArray, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, writeFileSync };
747
+ export { Condition, ConditionItem, CustomBlock, EasyCom, FILE_EXTENSIONS, GlobalStyle, IconFont, MODULE_ID_VIRTUAL, MidButton, OUTPUT_NAME, Options, PageContext, PageMetaDatum, PagePath, PagesConfig, PreloadRule, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackage, TabBar, TabBarItem, TheWindow, UserOptions, UserPagesConfig, VitePluginUniPages, checkPagesJsonFile, debug, VitePluginUniPages as default, defineUniPages, extsToGlob, getPageFiles, getPagesConfigSourcePaths, getRouteBlock, invalidatePagesModule, isConfigFile, isTargetFile, mergePageMetaDataArray, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, writeFileSync };
package/dist/index.mjs CHANGED
@@ -61,6 +61,13 @@ function mergePageMetaDataArray(pageMetaData) {
61
61
  }
62
62
  return result;
63
63
  }
64
+ const getPagesConfigSourcePaths = async () => {
65
+ return await fg("pages.config.(ts|mts|cts|js|cjs|mjs|json)", {
66
+ deep: 0,
67
+ onlyFiles: true,
68
+ absolute: true
69
+ });
70
+ };
64
71
 
65
72
  function resolveOptions(userOptions, viteRoot) {
66
73
  const {
@@ -246,7 +253,11 @@ class PageContext {
246
253
  this._server = server;
247
254
  this.setupWatcher(server.watcher);
248
255
  }
249
- setupWatcher(watcher) {
256
+ async setupWatcher(watcher) {
257
+ if (process.env.UNI_PLATFORM !== "h5") {
258
+ const configs = await getPagesConfigSourcePaths();
259
+ watcher.add(configs);
260
+ }
250
261
  watcher.on("add", async (path2) => {
251
262
  path2 = slash(path2);
252
263
  if (!isTargetFile(path2))
@@ -376,4 +387,4 @@ const VitePluginUniPages = (userOptions = {}) => {
376
387
  };
377
388
  };
378
389
 
379
- export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, checkPagesJsonFile, debug, VitePluginUniPages as default, defineUniPages, extsToGlob, getPageFiles, getRouteBlock, invalidatePagesModule, isConfigFile, isTargetFile, mergePageMetaDataArray, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, writeFileSync };
390
+ export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, checkPagesJsonFile, debug, VitePluginUniPages as default, defineUniPages, extsToGlob, getPageFiles, getPagesConfigSourcePaths, getRouteBlock, invalidatePagesModule, isConfigFile, isTargetFile, mergePageMetaDataArray, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, writeFileSync };
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.1.3",
4
+ "version": "0.1.4",
5
5
  "packageManager": "pnpm@7.16.1",
6
6
  "description": "File system based routing for uni-app applications using Vite",
7
7
  "author": "KeJun",