@uni-helper/vite-plugin-uni-pages 0.0.6 → 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.
package/dist/index.d.ts CHANGED
@@ -1,44 +1,650 @@
1
- import { Plugin } from 'vite';
1
+ import { Logger, ViteDevServer, Plugin } from 'vite';
2
+ import { FSWatcher } from 'fs';
3
+ import Debug from 'debug';
4
+ import { SFCDescriptor, SFCBlock } from '@vue/compiler-sfc';
2
5
 
6
+ interface EasyCom {
7
+ autoscan: boolean;
8
+ custom: Record<string, string>;
9
+ }
10
+
11
+ type HEXColor = `#${string}`;
12
+
13
+ interface AppPlus {
14
+ /**
15
+ * 窗体背景色。无论vue页面还是nvue页面,在App上都有一个父级原生窗体,该窗体的背景色生效时间快于页面里的css生效时间
16
+ * @default "#FFFFFF"
17
+ * @desc App
18
+ */
19
+ background?: HEXColor;
20
+ /**
21
+ * 导航栏 ,详见?:导航栏
22
+ * @desc App、H5
23
+ */
24
+ titleNView?: object;
25
+ /**
26
+ * 原生子窗体,详见?:原生子窗体
27
+ * @desc App 1.9.10+
28
+ */
29
+ subNVues?: object;
30
+ /**
31
+ * 页面回弹效果,设置为 "none" 时关闭效果。
32
+ * @desc App-vue(nvue Android无页面级bounce效果,仅list、recycle-list、waterfall等滚动组件有bounce效果)
33
+ */
34
+ bounce?: string;
35
+ /**
36
+ * 侧滑返回功能,可选值:"close"(启用侧滑返回)、"none"(禁用侧滑返回)
37
+ * @default "close"
38
+ * @desc App-iOS
39
+ */
40
+ popGesture?: string;
41
+ /**
42
+ * iOS软键盘上完成工具栏的显示模式,设置为 "none" 时关闭工具栏。
43
+ * @default "auto"
44
+ * @desc App-iOS
45
+ */
46
+ softInputNavBar?: string;
47
+ /**
48
+ * 软键盘弹出模式,支持 adjustResize、adjustPan 两种模式
49
+ * @default "adjustPan"
50
+ * @desc App
51
+ */
52
+ softInputMode?: string;
53
+ /**
54
+ * 下拉刷新
55
+ * @desc App
56
+ */
57
+ pullToRefresh?: object;
58
+ /**
59
+ * 滚动条显示策略,设置为 "none" 时不显示滚动条。
60
+ * @desc App
61
+ */
62
+ scrollIndicator?: string;
63
+ /**
64
+ * 窗口显示的动画效果,详见:窗口动画。
65
+ * @default "pop-in"
66
+ * @desc App
67
+ */
68
+ animationType?: string;
69
+ /**
70
+ * 窗口显示动画的持续时间,单位为 ms。
71
+ * @default "300"
72
+ * @desc App
73
+ */
74
+ animationDuration?: number;
75
+ [x: string]: any;
76
+ }
77
+
78
+ interface H5 {
79
+ /**
80
+ * 背景颜色,颜色值格式为"#RRGGBB"。
81
+ * @default "#F7F7F7"
82
+ * @desc
83
+ */
84
+ backgroundColor?: HEXColor;
85
+ /**
86
+ * 自定义按钮,参考 buttons
87
+ * @desc
88
+ */
89
+ buttons?: any[];
90
+ /**
91
+ * 标题文字颜色
92
+ * @default "#000000"
93
+ * @desc
94
+ */
95
+ titleColor?: HEXColor;
96
+ /**
97
+ * 标题文字内容
98
+ * @desc
99
+ */
100
+ titleText?: string;
101
+ /**
102
+ * 标题文字字体大小
103
+ * @desc
104
+ */
105
+ titleSize?: string;
106
+ /**
107
+ * 导航栏样式。"default"-默认样式;"transparent"-透明渐变。
108
+ * @default "default"
109
+ * @desc
110
+ */
111
+ type?: string;
112
+ /**
113
+ * 导航栏上的搜索框样式,详见:searchInput
114
+ * @desc 1.6.5
115
+ */
116
+ searchInput?: object;
117
+ [x: string]: any;
118
+ }
119
+
120
+ interface GlobalStyle {
121
+ /**
122
+ * 导航栏背景颜色(同状态栏背景色)
123
+ * @default "#F7F7F7"
124
+ * @desc APP与H5为#F7F7F7,小程序平台请参考相应小程序文档
125
+ */
126
+ navigationBarBackgroundColor?: HEXColor;
127
+ /**
128
+ * 导航栏标题颜色及状态栏前景颜色,仅支持 black/white
129
+ * @default "white"
130
+ * @desc 支付宝小程序不支持,请使用 my.setNavigationBar
131
+ */
132
+ navigationBarTextStyle?: string;
133
+ /**
134
+ * 导航栏标题文字内容
135
+ * @desc
136
+ */
137
+ navigationBarTitleText?: string;
138
+ /**
139
+ * 导航栏样式,仅支持 default/custom。custom即取消默认的原生导航栏,需看使用注意
140
+ * @default "default"
141
+ * @desc 微信小程序 7.0+、百度小程序、H5、App(2.0.3+)
142
+ */
143
+ navigationStyle?: string;
144
+ /**
145
+ * 下拉显示出来的窗口的背景色
146
+ * @default "#ffffff"
147
+ * @desc 微信小程序
148
+ */
149
+ backgroundColor?: HEXColor;
150
+ /**
151
+ * 下拉 loading 的样式,仅支持 dark / light
152
+ * @default "dark"
153
+ * @desc 微信小程序
154
+ */
155
+ backgroundTextStyle?: string;
156
+ /**
157
+ * 是否开启下拉刷新,详见页面生命周期。
158
+ * @default "false"
159
+ * @desc
160
+ */
161
+ enablePullDownRefresh?: boolean;
162
+ /**
163
+ * 页面上拉触底事件触发时距页面底部距离,单位只支持px,详见页面生命周期
164
+ * @default "50"
165
+ * @desc
166
+ */
167
+ onReachBottomDistance?: number;
168
+ /**
169
+ * 顶部窗口的背景色(bounce回弹区域)
170
+ * @default "#ffffff"
171
+ * @desc 仅 iOS 平台
172
+ */
173
+ backgroundColorTop?: HEXColor;
174
+ /**
175
+ * 底部窗口的背景色(bounce回弹区域)
176
+ * @default "#ffffff"
177
+ * @desc 仅 iOS 平台
178
+ */
179
+ backgroundColorBottom?: HEXColor;
180
+ /**
181
+ * 导航栏图片地址(替换当前文字标题),支付宝小程序内必须使用https的图片链接地址
182
+ * @desc 支付宝小程序、H5、APP
183
+ */
184
+ titleImage?: string;
185
+ /**
186
+ * 导航栏整体(前景、背景)透明设置。支持 always 一直透明 / auto 滑动自适应 / none 不透明
187
+ * @default "none"
188
+ * @desc 支付宝小程序、H5、APP
189
+ */
190
+ transparentTitle?: string;
191
+ /**
192
+ * 导航栏点击穿透
193
+ * @default "NO"
194
+ * @desc 支付宝小程序、H5
195
+ */
196
+ titlePenetrate?: string;
197
+ /**
198
+ * 横屏配置,屏幕旋转设置,仅支持 auto / portrait / landscape 详见 响应显示区域变化
199
+ * @default "portrait"
200
+ * @desc App 2.4.7+、微信小程序、QQ小程序
201
+ */
202
+ pageOrientation?: string;
203
+ /**
204
+ * 窗口显示的动画效果,详见:窗口动画
205
+ * @default "pop-in"
206
+ * @desc App
207
+ */
208
+ animationType?: string;
209
+ /**
210
+ * 窗口显示动画的持续时间,单位为 ms
211
+ * @default "300"
212
+ * @desc App
213
+ */
214
+ animationDuration?: number;
215
+ /**
216
+ * 设置编译到 App 平台的特定样式,配置项参考下方 app-plus
217
+ * @desc App
218
+ */
219
+ 'app-plus'?: AppPlus;
220
+ /**
221
+ * 设置编译到 H5 平台的特定样式,配置项参考下方 H5
222
+ * @type H5
223
+ * @desc H5
224
+ */
225
+ h5?: H5;
226
+ /**
227
+ * 设置编译到 mp-alipay 平台的特定样式,配置项参考下方 MP-ALIPAY
228
+ * @desc 支付宝小程序
229
+ */
230
+ 'mp-alipay'?: object;
231
+ /**
232
+ * 设置编译到 mp-weixin 平台的特定样式
233
+ * @desc 微信小程序
234
+ */
235
+ 'mp-weixin'?: object;
236
+ /**
237
+ * 设置编译到 mp-baidu 平台的特定样式
238
+ * @desc 百度小程序
239
+ */
240
+ 'mp-baidu'?: object;
241
+ /**
242
+ * 设置编译到 mp-toutiao 平台的特定样式
243
+ * @desc 字节跳动小程序
244
+ */
245
+ 'mp-toutiao'?: object;
246
+ /**
247
+ * 设置编译到 mp-lark 平台的特定样式
248
+ * @desc 飞书小程序
249
+ */
250
+ 'mp-lark'?: object;
251
+ /**
252
+ * 设置编译到 mp-qq 平台的特定样式
253
+ * @desc QQ小程序
254
+ */
255
+ 'mp-qq'?: object;
256
+ /**
257
+ * 设置编译到 mp-kuaishou 平台的特定样式
258
+ * @desc 快手小程序
259
+ */
260
+ 'mp-kuaishou'?: object;
261
+ /**
262
+ * 设置编译到 mp-jd 平台的特定样式
263
+ * @desc 京东小程序
264
+ */
265
+ 'mp-jd'?: object;
266
+ /**
267
+ * 引用小程序组件,参考 小程序组件
268
+ * @type Record<string, string>
269
+ * @desc
270
+ */
271
+ usingComponents?: Record<string, string>;
272
+ /**
273
+ * 同层渲染,webrtc(实时音视频) 无法正常时尝试配置 seperated 强制关掉同层
274
+ * @desc 微信小程序
275
+ */
276
+ renderingMode?: string;
277
+ /**
278
+ * 当存在 leftWindow 时,默认是否显示 leftWindow
279
+ * @default "true"
280
+ * @desc H5
281
+ */
282
+ leftWindow?: boolean;
283
+ /**
284
+ * 当存在 topWindow 时,默认是否显示 topWindow
285
+ * @default "true"
286
+ * @desc H5
287
+ */
288
+ topWindow?: boolean;
289
+ /**
290
+ * 当存在 rightWindow 时,默认是否显示 rightWindow
291
+ * @default "true"
292
+ * @desc H5
293
+ */
294
+ rightWindow?: boolean;
295
+ /**
296
+ * rpx 计算所支持的最大设备宽度,单位 px
297
+ * @default "960"
298
+ * @desc App(vue2 且不含 nvue)、H5(2.8.12+)
299
+ */
300
+ rpxCalcMaxDeviceWidth?: number;
301
+ /**
302
+ * rpx 计算使用的基准设备宽度,设备实际宽度超出 rpx 计算所支持的最大设备宽度时将按基准宽度计算,单位 px
303
+ * @default "375"
304
+ * @desc App(vue2 且不含 nvue)、H5(2.8.12+)
305
+ */
306
+ rpxCalcBaseDeviceWidth?: number;
307
+ /**
308
+ * rpx 计算特殊处理的值,始终按实际的设备宽度计算,单位 rpx
309
+ * @default "750"
310
+ * @desc App(vue2 且不含 nvue)、H5(2.8.12+)
311
+ */
312
+ rpxCalcIncludeWidth?: number;
313
+ /**
314
+ * 动态 rpx,屏幕大小变化会重新渲染 rpx
315
+ * @default "false"
316
+ * @desc App-nvue(vue3 固定值为 true) 3.2.13+
317
+ */
318
+ dynamicRpx?: boolean;
319
+ /**
320
+ * 单位px,当浏览器可见区域宽度大于maxWidth时,两侧留白,当小于等于maxWidth时,页面铺满;不同页面支持配置不同的maxWidth;maxWidth = leftWindow(可选)+page(页面主体)+rightWindow(可选)
321
+ * @desc H5(2.9.9+)
322
+ */
323
+ maxWidth?: number;
324
+ [x: string]: any;
325
+ }
326
+
327
+ interface IconFont {
328
+ /**
329
+ * 字库 Unicode 码
330
+ */
331
+ text?: string;
332
+ /**
333
+ * 选中后字库 Unicode 码
334
+ */
335
+ selectedText?: string;
336
+ /**
337
+ * 字体图标字号(px)
338
+ */
339
+ fontSize?: string;
340
+ /**
341
+ * 字体图标颜色
342
+ */
343
+ color?: string;
344
+ /**
345
+ * 字体图标选中颜色
346
+ */
347
+ selectedColor?: string;
348
+ }
349
+ interface TabBarItem {
350
+ /**
351
+ * 页面路径,必须在 pages 中先定义
352
+ */
353
+ pagePath?: string;
354
+ /**
355
+ * tab 上按钮文字,在 App 和 H5 平台为非必填。例如中间可放一个没有文字的+号图标
356
+ */
357
+ text?: string;
358
+ /**
359
+ * 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,
360
+ * 当 position 为 top 时,此参数无效,不支持网络图片,不支持字体图标
361
+ */
362
+ iconPath?: string;
363
+ /**
364
+ * 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 position 为 top 时,此参数无效
365
+ */
366
+ selectedIconPath?: string;
367
+ /**
368
+ * 该项是否显示,默认显示
369
+ * @desc App (3.2.10+)、H5 (3.2.10+)
370
+ */
371
+ visible?: boolean;
372
+ /**
373
+ * 字体图标,优先级高于 iconPath
374
+ * @desc App(3.4.4+)、H5 (3.5.3+)
375
+ */
376
+ iconfont?: IconFont;
377
+ [x: string]: any;
378
+ }
379
+ interface MidButton {
380
+ /**
381
+ * 中间按钮的宽度,tabBar 其它项为减去此宽度后平分,默认值为与其它项平分宽度
382
+ * @default "80px"
383
+ */
384
+ width?: string;
385
+ /**
386
+ * 中间按钮的高度,可以大于 tabBar 高度,达到中间凸起的效果
387
+ * @default "50px"
388
+ */
389
+ height?: string;
390
+ /**
391
+ * 中间按钮的文字
392
+ */
393
+ text?: string;
394
+ /**
395
+ * 中间按钮的图片路径
396
+ */
397
+ iconPath?: string;
398
+ /**
399
+ * 图片宽度(高度等比例缩放)
400
+ * @default "24px"
401
+ */
402
+ iconWidth?: string;
403
+ /**
404
+ * 中间按钮的背景图片路径
405
+ */
406
+ backgroundImage?: string;
407
+ /**
408
+ * 字体图标,优先级高于 iconPath
409
+ */
410
+ iconfont?: IconFont;
411
+ }
412
+ interface TabBar {
413
+ /**
414
+ * tab 上的文字默认颜色
415
+ */
416
+ color?: HEXColor;
417
+ /**
418
+ * tab 上的文字选中时的颜色
419
+ */
420
+ selectedColor?: HEXColor;
421
+ /**
422
+ * tab 的背景色
423
+ */
424
+ backgroundColor?: HEXColor;
425
+ /**
426
+ * tabbar 上边框的颜色,可选值 black/white,也支持其他颜色值
427
+ * @default "black"
428
+ * @desc App 2.3.4+ 、H5 3.0.0+
429
+ */
430
+ borderStyle?: string;
431
+ /**
432
+ * iOS 高斯模糊效果,可选值 dark/extralight/light/none(参考?:使用说明)
433
+ * @default "none"
434
+ * @desc App 2.4.0+ 支持、H5 3.0.0+(只有最新版浏览器才支持)
435
+ */
436
+ blurEffect?: string;
437
+ /**
438
+ * tab 的列表,详见 list 属性说明,最少2个、最多5个 tab
439
+ * @type TabBarItem[]
440
+ */
441
+ list?: TabBarItem[];
442
+ /**
443
+ * 可选值 bottom、top
444
+ * @default "bottom"
445
+ * @desc top 值仅微信小程序支持
446
+ */
447
+ position?: string;
448
+ /**
449
+ * 文字默认大小
450
+ * @default "10px"
451
+ * @desc App 2.3.4+、H5 3.0.0+
452
+ */
453
+ fontSize?: string;
454
+ /**
455
+ * 图标默认宽度(高度等比例缩放)
456
+ * @default "24px"
457
+ * @desc App 2.3.4+、H5 3.0.0+
458
+ */
459
+ iconWidth?: string;
460
+ /**
461
+ * 图标和文字的间距
462
+ * @default "3px"
463
+ * @desc App 2.3.4+、H5 3.0.0+
464
+ */
465
+ spacing?: string;
466
+ /**
467
+ * tabBar 默认高度
468
+ * @default "50px"
469
+ * @desc App 2.3.4+、H5 3.0.0+
470
+ */
471
+ height?: string;
472
+ /**
473
+ * 中间按钮 仅在 list 项为偶数时有效
474
+ * @desc App 2.3.4+、H5 3.0.0+
475
+ */
476
+ midButton?: MidButton;
477
+ /**
478
+ * list设置 iconfont 属性时,需要指定字体文件路径
479
+ * @desc App 3.4.4+、H5 3.5.3+
480
+ */
481
+ iconfontSrc?: string;
482
+ [x: string]: any;
483
+ }
484
+
485
+ interface TheWindow {
486
+ /**
487
+ * 配置页面路径
488
+ */
489
+ path: string;
490
+ /**
491
+ * 配置页面窗口表现,配置项参考下方 pageStyle
492
+ */
493
+ style?: GlobalStyle;
494
+ /**
495
+ * 配置显示该窗口的规则,配置项参考下方 matchMedia
496
+ */
497
+ matchMedia?: {
498
+ /**
499
+ * 当设备可见区域宽度 >= minWidth 时,显示该 window
500
+ * @default "768"
501
+ */
502
+ minWidth?: number;
503
+ };
504
+ }
505
+ interface PreloadRule {
506
+ /**
507
+ * 进入页面后预下载分包的 root 或 name。__APP__ 表示主包。
508
+ */
509
+ packages?: string[];
510
+ /**
511
+ * 在指定网络下预下载,可选值为:all(不限网络)、wifi(仅wifi下预下载)
512
+ * @default "wifi"
513
+ */
514
+ network?: string;
515
+ }
516
+ interface SubPackage {
517
+ /**
518
+ * 子包的根目录
519
+ */
520
+ root?: string;
521
+ /**
522
+ * 子包由哪些页面组成,参数同 pages
523
+ */
524
+ pages?: any[];
525
+ }
526
+ interface ConditionItem {
527
+ /**
528
+ * 启动模式名称
529
+ */
530
+ name?: string;
531
+ /**
532
+ * 启动页面路径
533
+ */
534
+ path: string;
535
+ /**
536
+ * 启动参数,可在页面的 onLoad 函数里获得
537
+ */
538
+ query?: string;
539
+ }
540
+ interface Condition {
541
+ /**
542
+ * 当前激活的模式,list节点的索引值
543
+ */
544
+ current?: number;
545
+ /**
546
+ * 启动模式列表
547
+ */
548
+ list?: Partial<ConditionItem>[];
549
+ }
3
550
  interface PagesConfig {
4
- pages: any;
5
- globalStyle: any;
6
- easycom: any;
7
- tabBar: any;
8
- condition: any;
9
- subPackages: any;
10
- preloadRule: any;
11
- workers: any;
12
- leftWindow: any;
13
- topWindow: any;
14
- rightWindow: any;
15
- uniIdRouter: any;
16
- }
17
- interface UserPagesConfig extends Partial<PagesConfig> {
18
- }
19
-
20
- declare class Context {
551
+ /**
552
+ * 设置页面路径及窗口表现
553
+ */
554
+ pages?: PageMetaDatum[];
555
+ /**
556
+ * 设置默认页面的窗口表现
557
+ */
558
+ globalStyle?: GlobalStyle;
559
+ /**
560
+ * 组件自动引入规则
561
+ * @desc 2.5.5+
562
+ */
563
+ easycom?: EasyCom;
564
+ /**
565
+ * 设置底部 tab 的表现
566
+ */
567
+ tabBar?: TabBar;
568
+ /**
569
+ * 启动模式配置
570
+ */
571
+ condition?: Condition;
572
+ /**
573
+ * 分包加载配置
574
+ */
575
+ subPackages?: SubPackage[];
576
+ /**
577
+ * 分包预下载规则
578
+ * @desc 微信小程序
579
+ */
580
+ preloadRule?: PreloadRule;
581
+ /**
582
+ * `Worker` 代码放置的目录
583
+ * @desc 微信小程序
584
+ */
585
+ workers?: any;
586
+ /**
587
+ * 大屏左侧窗口
588
+ * @desc H5
589
+ */
590
+ leftWindow?: TheWindow;
591
+ /**
592
+ * 大屏顶部窗口
593
+ * @desc H5
594
+ */
595
+ topWindow?: TheWindow;
596
+ /**
597
+ * 大屏右侧窗口
598
+ * @desc H5
599
+ */
600
+ rightWindow?: TheWindow;
601
+ /**
602
+ * 自动跳转相关配置,新增于HBuilderX 3.5.0
603
+ */
604
+ uniIdRouter?: any;
605
+ [x: string]: any;
606
+ }
607
+ interface UserPagesConfig extends PagesConfig {
608
+ }
609
+
610
+ declare function defineUniPages(config: UserPagesConfig): UserPagesConfig;
611
+
612
+ declare class PageContext {
613
+ private _server;
614
+ pagesGlobConfig: PagesConfig | undefined;
615
+ pagesPath: PagePath[];
616
+ pageMetaData: PageMetaDatum[];
617
+ resolvedPagesJSONPath: string;
618
+ rawOptions: UserOptions;
619
+ root: string;
21
620
  options: ResolvedOptions;
22
- pagesConfig: PagesConfig;
23
- pagesPathInfo: PagePathInfo[];
24
- pagesMeta: PageMeta[];
25
- constructor(options: ResolvedOptions);
621
+ logger?: Logger;
622
+ constructor(userOptions: UserOptions, viteRoot?: string);
623
+ setLogger(logger: Logger): void;
26
624
  loadUserPagesConfig(): Promise<void>;
27
625
  scanPages(): Promise<void>;
28
- parsePage({ relative, absolute }: PagePathInfo): Promise<PageMeta>;
29
- mergePagesMeta(): Promise<void>;
30
- createOrUpdatePagesJSON(): Promise<void>;
626
+ setupViteServer(server: ViteDevServer): void;
627
+ setupWatcher(watcher: FSWatcher): void;
628
+ onUpdate(): void;
629
+ parsePage(page: PagePath): Promise<PageMetaDatum>;
630
+ mergePageMetaData(): Promise<void>;
631
+ updatePagesJSON(): Promise<void>;
31
632
  virtualModule(): Promise<string>;
32
- pagesConfigSourcePaths(): Promise<string[]>;
33
- get pagesJson(): string;
633
+ resolveRoutes(): string;
34
634
  }
35
635
 
636
+ type CustomBlock = Record<string, any>;
36
637
  interface Options {
37
638
  /**
38
- * pages dir
39
- * @default "src/pages"
639
+ * Whether to merge pages in pages.json
640
+ * @default true
40
641
  */
41
- pagesDir: string;
642
+ mergePages: boolean;
643
+ /**
644
+ * Paths to the directory to search for page components.
645
+ * @default 'src/pages'
646
+ */
647
+ dir: string;
42
648
  /**
43
649
  * pages.json dir
44
650
  * @default "src"
@@ -49,31 +655,89 @@ interface Options {
49
655
  * @default []
50
656
  */
51
657
  exclude: string[];
52
- onBeforeLoadUserConfig: (ctx: Context) => void;
53
- onAfterLoadUserConfig: (ctx: Context) => void;
54
- onBeforeScanPages: (ctx: Context) => void;
55
- onAfterScanPages: (ctx: Context) => void;
56
- onBeforeMergePagesMeta: (ctx: Context) => void;
57
- onAfterMergePagesMeta: (ctx: Context) => void;
58
- onBeforeWriteFile: (ctx: Context) => void;
59
- onAfterWriteFile: (ctx: Context) => void;
60
- }
61
- interface UserOptions extends Partial<Options> {
658
+ /**
659
+ * Set the default route block parser, or use `<route lang="xxx">` in SFC route block
660
+ * @default 'json5'
661
+ */
662
+ routeBlockLang: 'json5' | 'json' | 'yaml' | 'yml';
663
+ onBeforeLoadUserConfig: (ctx: PageContext) => void;
664
+ onAfterLoadUserConfig: (ctx: PageContext) => void;
665
+ onBeforeScanPages: (ctx: PageContext) => void;
666
+ onAfterScanPages: (ctx: PageContext) => void;
667
+ onBeforeMergePageMetaData: (ctx: PageContext) => void;
668
+ onAfterMergePageMetaData: (ctx: PageContext) => void;
669
+ onBeforeWriteFile: (ctx: PageContext) => void;
670
+ onAfterWriteFile: (ctx: PageContext) => void;
62
671
  }
63
- interface ResolvedOptions extends Options {
672
+ type UserOptions = Partial<Options>;
673
+ interface ResolvedOptions extends Omit<Options, 'dir'> {
674
+ /**
675
+ * Resolves to the `root` value from Vite config.
676
+ * @default config.root
677
+ */
678
+ root: string;
679
+ /**
680
+ * Resolved page dirs
681
+ */
682
+ dirs: string[];
64
683
  }
65
- interface PagePathInfo {
66
- relative: string;
67
- absolute: string;
684
+ interface PagePath {
685
+ relativePath: string;
686
+ absolutePath: string;
68
687
  }
69
- interface PageMeta {
688
+ interface PageMetaDatum {
689
+ /**
690
+ * 配置页面路径
691
+ */
70
692
  path: string;
71
- type: string;
693
+ type?: string;
694
+ /**
695
+ * 配置页面窗口表现,配置项参考下方 pageStyle
696
+ */
697
+ style?: GlobalStyle;
72
698
  [x: string]: any;
73
699
  }
74
700
 
75
- declare function definePages(config: UserPagesConfig): UserPagesConfig;
701
+ declare const MODULE_ID_VIRTUAL = "virtual:uni-pages";
702
+ declare const RESOLVED_MODULE_ID_VIRTUAL: string;
703
+ declare const OUTPUT_NAME = "pages.json";
704
+ declare const FILE_EXTENSIONS: string[];
705
+
706
+ declare function invalidatePagesModule(server: ViteDevServer): void;
707
+ declare const debug: {
708
+ hmr: Debug.Debugger;
709
+ routeBlock: Debug.Debugger;
710
+ options: Debug.Debugger;
711
+ pages: Debug.Debugger;
712
+ error: Debug.Debugger;
713
+ };
714
+ declare function extsToGlob(extensions: string[]): string;
715
+ declare function isTargetFile(path: string): boolean;
716
+ declare function isConfigFile(path: string): boolean;
717
+ /**
718
+ * merge page meta data array by path and assign style
719
+ * @param pageMetaData page meta data array
720
+ * TODO: support merge middleware
721
+ */
722
+ declare function mergePageMetaDataArray(pageMetaData: PageMetaDatum[]): PageMetaDatum[];
723
+
724
+ /**
725
+ * Resolves the files that are valid pages for the given context.
726
+ */
727
+ declare function getPageFiles(path: string, options: ResolvedOptions): string[];
728
+ declare function checkPagesJsonFile(path: string): void;
729
+ declare function writeFileSync(path: string, content: string): void;
730
+
731
+ declare function resolveOptions(userOptions: UserOptions, viteRoot?: string): ResolvedOptions;
732
+ /**
733
+ * Resolves the page dirs for its for its given globs
734
+ */
735
+ declare function resolvePageDirs(dir: string, root: string, exclude: string[]): string[];
736
+
737
+ declare function parseSFC(code: string): Promise<SFCDescriptor>;
738
+ declare function parseCustomBlock(block: SFCBlock, filePath: string, options: ResolvedOptions): any;
739
+ declare function getRouteBlock(path: string, options: ResolvedOptions): Promise<CustomBlock | undefined>;
76
740
 
77
- declare const VitePluginUniPages: (userOptions?: UserOptions) => Promise<Plugin>;
741
+ declare const VitePluginUniPages: (userOptions?: UserOptions) => Plugin;
78
742
 
79
- export { PagesConfig, UserPagesConfig, VitePluginUniPages, VitePluginUniPages as default, definePages };
743
+ 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 };