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