@uni-helper/vite-plugin-uni-pages 0.3.24 → 0.4.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.d.cts CHANGED
@@ -1,3020 +1,312 @@
1
- import { Logger, ViteDevServer, Plugin } from 'vite';
2
- import { CommentJSONValue } from 'comment-json';
3
- import { LoadConfigSource } from 'unconfig';
4
- import { FSWatcher } from 'chokidar';
5
- import { SFCParseOptions, SFCDescriptor, SFCBlock } from '@vue/compiler-sfc';
6
- import * as t from '@babel/types';
7
- import babelGenerator from '@babel/generator';
8
- import Debug from 'debug';
9
- import fs from 'node:fs';
1
+ import { Logger, Plugin, ViteDevServer } from "vite";
2
+ import { LoadConfigSource } from "unconfig";
3
+ import { DefinePage, ExcludeIndexSignature, MaybeCallable, MaybePromise, MaybePromiseCallable, PageMetaDatum, SubPageMetaDatum, UserPageMeta, UserPagesConfig, UserTabBarItem, definePage } from "@uni-helper/uni-pages-types";
4
+ import { FSWatcher } from "chokidar";
5
+ import { SFCDescriptor, SFCParseOptions } from "@vue/compiler-sfc";
6
+ import * as t from "@babel/types";
7
+ import babelGenerator from "@babel/generator";
8
+ import Debug from "debug";
9
+ import fs from "node:fs";
10
+ export * from "@uni-helper/uni-pages-types";
10
11
 
11
- interface ConditionItem {
12
- /**
13
- * 启动模式名称
14
- */
15
- name: string;
16
- /**
17
- * 启动页面路径
18
- */
19
- path: string;
20
- /**
21
- * 启动参数,可在页面的 onLoad 函数里获得
22
- */
23
- query?: string;
12
+ //#region \0rolldown/runtime.js
13
+ declare namespace index_d_exports$1 {
14
+ export { defineUniPages };
24
15
  }
25
- interface Condition {
26
- /**
27
- * 当前激活的模式,list 节点的索引值
28
- */
29
- current: number;
30
- /**
31
- * 启动模式列表
32
- */
33
- list: Partial<ConditionItem>[];
34
- }
35
-
36
- interface EasyCom {
37
- /**
38
- * 是否开启自动扫描,开启后将会自动扫描符合 `components/组件名称/组件名称.vue` 目录结构的组件
39
- *
40
- * @default true
41
- */
42
- autoscan?: boolean;
43
- /**
44
- * 以正则方式自定义组件匹配规则
45
- *
46
- * 如果 `autoscan` 不能满足需求,可以使用 `custom` 自定义匹配规则
47
- *
48
- * @example
49
- * "custom": {
50
- * "^uni-(.*)": "@/components/uni-$1.vue", // 匹配 components 目录内的 vue 文件
51
- * "^vue-file-(.*)": "packageName/path/to/vue-file-$1.vue" // 匹配 node_modules 内的 vue 文件
52
- * }
53
- }
54
- */
55
- custom?: Record<string, string>;
56
- }
57
-
58
- type RGBAColor = `rgba(${number}, ${number}, ${number}, ${number})`;
59
- type HEXColor = `#${string}`;
60
- type PxSize = `${number}px`;
61
- type PercentageSize = `${number}%`;
62
- type ThemeVar = `@${string}`;
16
+ import * as import__uni_helper_uni_pages_types from "@uni-helper/uni-pages-types";
63
17
  /**
64
- * 窗口动画,详见 [窗口动画](https://uniapp.dcloud.net.cn/api/router.html#animation)
65
- */
66
- type AnimationType = 'slide-in-right' | 'slide-in-left' | 'slide-in-top' | 'slide-in-bottom' | 'pop-in' | 'fade-in' | 'zoom-out' | 'zoom-fade-out' | 'none';
67
- interface TitleNViewButton {
68
- /**
69
- * 自定义按钮样式,详见 [自定义按钮样式](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview-buttons-type)
70
- *
71
- * "forward" 前进按钮
72
- *
73
- * "back" 后退按钮
74
- *
75
- * "share" 分享按钮
76
- *
77
- * "favorite" 收藏按钮
78
- *
79
- * "home" 主页按钮
80
- *
81
- * "menu" 菜单按钮
82
- *
83
- * "close" 关闭按钮
84
- *
85
- * "none" 无样式,需通过 text 属性设置按钮上显示的内容、通过 fontSrc 属性设置使用的字体库
86
- *
87
- * @default "none"
88
- */
89
- type?: 'forward' | 'back' | 'share' | 'favorite' | 'home' | 'menu' | 'close' | 'none';
90
- /**
91
- * 自定义按钮文字颜色,支持 HEX 颜色
92
- *
93
- * @default 与标题文字样式一样
94
- *
95
- * @format color
96
- */
97
- color?: HEXColor;
98
- /**
99
- * 自定义按钮背景色,仅在标题栏 type 为 "transparent" 时生效,支持 HEX 和 RGBA 颜色
100
- *
101
- * @default 灰色半透明
102
- *
103
- * @format color
104
- */
105
- background?: HEXColor | RGBAColor;
106
- /**
107
- * 自定义按钮按下状态文字颜色,支持 HEX 和 RGBA 颜色
108
- *
109
- * @default color 属性值自动调整透明度为 0.3
110
- *
111
- * @format color
112
- */
113
- colorPressed?: HEXColor | RGBAColor;
114
- /**
115
- * 自定义按钮在标题栏的显示位置,仅支持 "right" / "left"
116
- *
117
- * "right" 右侧
118
- *
119
- * "left" 左侧
120
- *
121
- * @default "right"
122
- */
123
- float?: 'right' | 'left';
124
- /**
125
- * 自定义按钮文字粗细,仅支持 "normal" | "bold"
126
- *
127
- * "normal" 标准
128
- *
129
- * "bold" 加粗
130
- *
131
- * @default "normal"
132
- */
133
- fontWeight?: 'normal' | 'bold';
134
- /**
135
- * 自定义按钮文字大小
136
- */
137
- fontSize?: string;
138
- /**
139
- * 自定义按钮字体文件路径,只支持本地地址
140
- */
141
- fontSrc?: string;
142
- /**
143
- * 自定义按钮是否显示选择指示图标(向下箭头),常用于城市选择
144
- *
145
- * @default false
146
- */
147
- select?: boolean;
148
- /**
149
- * 自定义按钮文字内容。使用字体图标时 unicode 字符表示必须以"\\u" 开头,如 "\\ue123"
150
- */
151
- text?: string;
152
- /**
153
- * 自定义按钮文字宽度,支持单位为 px 的逻辑像素值或 "auto",按钮内容居中显示
154
- *
155
- * @default "44px"
156
- */
157
- width?: PxSize | 'auto';
158
- }
159
-
160
- interface AppPlus {
161
- /**
162
- * 窗体背景色,支持 HEX 颜色
163
- *
164
- * 无论 vue 页面还是 nvue 页面,在 App 上都有一个父级原生窗体,该窗体的背景色生效时间快于页面里的 css 生效时间
165
- *
166
- * @default "#FFFFFF"
167
- *
168
- * @desc App (vue 页面需要将 body 背景色设为透明)
169
- *
170
- * @format color
171
- */
172
- background?: HEXColor;
173
- /**
174
- * 导航栏,详见 [导航栏](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview)
175
- *
176
- * 当 navigationStyle 设为 "custom" 或 titleNView 设为 false时,原生导航栏不显示,详见 [自定义导航栏使用注意](https://uniapp.dcloud.net.cn/collocation/pages#customnav)
177
- */
178
- titleNView?: false | {
179
- /**
180
- * 背景颜色,支持 HEX 和 RGBA 颜色,App 端仅悬浮导航栏支持 RGBA 颜色
181
- *
182
- * @default "#F7F7F7"
183
- *
184
- * @format color
185
- */
186
- backgroundColor?: HEXColor | RGBAColor;
187
- /**
188
- * 自定义按钮,详见 [自定义按钮](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview-buttons)
189
- *
190
- * @desc 纯 nvue 即 render:native 时暂不支持
191
- */
192
- buttons?: TitleNViewButton[];
193
- /**
194
- * 标题文字颜色,支持 HEX 颜色
195
- *
196
- * @default "#000000"
197
- *
198
- * @format color
199
- */
200
- titleColor?: HEXColor;
201
- /**
202
- * 标题文字超出显示区域时处理方式
203
- *
204
- * "ellipsis" 超出显示区域时尾部显示省略标记(...)
205
- *
206
- * "clip" 超出显示区域时内容裁剪
207
- *
208
- * @default "ellipsis"
209
- */
210
- titleOverflow?: 'ellipsis' | 'clip';
211
- /**
212
- * 标题文字内容
213
- */
214
- titleText?: string;
215
- /**
216
- * 标题文字大小
217
- */
218
- titleSize?: string;
219
- /**
220
- * 导航栏样式
221
- *
222
- * "default" 默认样式
223
- *
224
- * "transparent" 滚动透明渐变
225
- *
226
- * "float" 悬浮导航栏
227
- *
228
- * @default "default"
229
- */
230
- type?: 'default' | 'transparent' | 'float';
231
- /**
232
- * 原生 View 增强,详见 [5+ View 控件](http://www.html5plus.org/doc/zh_cn/nativeobj.html#plus.nativeObj.ViewDrawTagStyles)
233
- */
234
- tags?: {
235
- /**
236
- * 绘制操作标识
237
- *
238
- * 可通过 view 对象的 drawBitmap / drawRect / drawText / clearRect 方法进行更新
239
- */
240
- id?: string;
241
- /**
242
- * 绘制操作类型
243
- *
244
- * "img" 绘制图片,与 drawBitmap 操作一致,此时 id、src、position、sprite 属性值有效
245
- *
246
- * "rect" 绘制矩形区域,与 drawRect 操作一致,此时 id、color、position、rectStyles 属性值有效
247
- *
248
- * "font" 绘制文本内容,与 drawText 操作一致,此时 id、position、text、textStyles 属性值有效
249
- *
250
- * "richtext" 绘制富文本内容,与 drawRichText 操作一致,此时 id、position、text、richTextStyles 属性值有效
251
- *
252
- * "input" 绘制输入框内容,此时 id、position、inputStyles 属性值有效
253
- */
254
- tag?: 'img' | 'rect' | 'font' | 'richtext' | 'input';
255
- /**
256
- * 矩形区域颜色,支持 HEX 和 RGBA 颜色
257
- *
258
- * 不推荐使用,推荐使用 rectStyles
259
- *
260
- * 当 tag 属性值为 "rect" 时有效,用于指定矩形区域颜色
261
- *
262
- * @default "#FFFFFF"
263
- *
264
- * @format color
265
- */
266
- color?: HEXColor | RGBAColor;
267
- /**
268
- * 绘制输入框的样式
269
- *
270
- * 当 tag 属性值为 "input" 时有效,用于指定绘制输入框的样式、大小位置等信息
271
- */
272
- inputStyles?: {
273
- /**
274
- * 输入框类型
275
- *
276
- * "email" 邮箱地址输入框
277
- *
278
- * "number" 数字输入框
279
- *
280
- * "search" 搜索文本输入框
281
- *
282
- * "tel" 电话号码输入框
283
- *
284
- * "text" 普通文本输入框
285
- *
286
- * "url" URL地址输入框
287
- *
288
- * @default "text"
289
- */
290
- type?: 'email' | 'number' | 'search' | 'tel' | 'text' | 'url';
291
- /**
292
- * 输入框的提示文本
293
- *
294
- * 当用户未输入内容时显示在编辑框中(灰色文字)。
295
- */
296
- placeholder?: string;
297
- /**
298
- * 输入框的字体大小,单位为 px
299
- *
300
- * @default "16px"
301
- */
302
- fontSize?: PxSize;
303
- /**
304
- * 输入框的边框颜色,支持 HEX 颜色
305
- *
306
- * @default "#000000"
307
- *
308
- * @format color
309
- */
310
- borderColor?: HEXColor;
311
- /**
312
- * 输入框的边框圆角半径,单位为 px
313
- *
314
- * @default "0px"
315
- */
316
- borderRadius?: PxSize;
317
- /**
318
- * 输入框的边框宽度,单位为 px
319
- *
320
- * @default "1px"
321
- */
322
- borderWidth?: PxSize;
323
- [x: string]: any;
324
- };
325
- /**
326
- * 绘制内容区域,相对于 View 控件的区域信息
327
- *
328
- * 当 tag 属性值为 "img" 时,用于指定绘制图片的目标区域
329
- *
330
- * 当 tag 属性值为 "rect" 时,用于指定绘制的矩形区域
331
- *
332
- * 当 tag 属性值为 "font" 时,用于指定绘制文本的目标区域,此时 height 属性值支持设置为 "wrap_content",表示文本高度根据内容自动计算,此时通过 top 来定位文本绘制的起始位置
333
- *
334
- * @default { top: '0px', left: '0px', width: '100%', height: '100%' }
335
- */
336
- position?: {
337
- /**
338
- * 区域顶部相对于作用对象或容器向下的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
339
- *
340
- * @default "0px"
341
- */
342
- top?: PxSize | PercentageSize | 'auto';
343
- /**
344
- * 区域顶部相对于作用对象或容器向右的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
345
- *
346
- * @default "0px"
347
- */
348
- left?: PxSize | PercentageSize | 'auto';
349
- /**
350
- * 区域宽度,相对于作用对象或容器的宽度,支持单位为 px 的逻辑像素值或百分比
351
- *
352
- * @default "100%"
353
- */
354
- width?: PxSize | PercentageSize;
355
- /**
356
- * 区域高度,相对于作用对象或容器的高度,支持单位为 px 的逻辑像素值或百分比
357
- *
358
- * @default "100%"
359
- */
360
- height?: PxSize | PercentageSize;
361
- /**
362
- * 区域顶部相对于作用对象或容器向上的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
363
- *
364
- * 当设置了 top 和 height 值时,忽略此属性值
365
- *
366
- * 当未设置 top 值时,可通过 bottom 属性值来确定区域的垂直位置
367
- *
368
- * 当未设置 height 值时,可通过 top 和 bottom 属性值来确定区域的高度
369
- */
370
- bottom?: PxSize | PercentageSize | 'auto';
371
- /**
372
- * 区域顶部相对于作用对象或容器向左的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
373
- *
374
- * 当设置了 left 和 width 值时,忽略此属性值
375
- *
376
- * 当未设置 left 值时,可通过 right 属性值来确定区域的水平位置
377
- *
378
- * 当未设置 width 值时,可通过 left 和 right 属性值来确定区域的宽度
379
- */
380
- right?: PxSize | PercentageSize | 'auto';
381
- [x: string]: any;
382
- };
383
- /**
384
- * 绘制区域的样式
385
- *
386
- * 当 tag 属性值为 "rect" 时有效,用于指定绘制区域的样式、填充颜色、圆角大小等信息
387
- */
388
- rectStyles?: {
389
- /**
390
- * 绘制颜色,矩形填充区域的颜色,支持 HEX 和 RGBA 颜色
391
- *
392
- * @default "#FFFFFF"
393
- *
394
- * @format color
395
- */
396
- color?: HEXColor | RGBAColor;
397
- /**
398
- * 矩形区域的圆角半径,单位为 px
399
- *
400
- * @default "0px"
401
- */
402
- radius?: PxSize;
403
- /**
404
- * 矩形边框颜色,绘制矩形边框的颜色,支持 HEX 和 RGBA 颜色
405
- *
406
- * @default color 属性值
407
- *
408
- * @format color
409
- */
410
- borderColor?: HEXColor | RGBAColor;
411
- /**
412
- * 矩形边框宽度,单位为 px
413
- *
414
- * @default "0px"
415
- */
416
- borderWidth?: PxSize;
417
- [x: string]: any;
418
- };
419
- /**
420
- * 绘制的图片资源
421
- *
422
- * 当 tag 属性值为 "img" 时有效,可以是图片资源路径(字符串类型)或者图片对象(plus.nativeObj.Bitmap对象)
423
- *
424
- * src 路径支持 gif 图片,设置的图片路径文件使用 ".gif" 后缀时则认为是 gif 图片,如"_www/loading.gif"
425
- */
426
- src?: string;
427
- /**
428
- * 图片源的绘制区域
429
- *
430
- * 当 tag 属性值为 "img" 时有效,用于指定图片源的绘制区域,相对于图片的区域信息
431
- *
432
- * @default { top: '0px', left: '0px', width: '100%', height: '100%' }
433
- */
434
- sprite?: {
435
- /**
436
- * 区域顶部相对于作用对象或容器向下的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
437
- *
438
- * @default "0px"
439
- */
440
- top?: PxSize | PercentageSize | 'auto';
441
- /**
442
- * 区域顶部相对于作用对象或容器向右的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
443
- *
444
- * @default "0px"
445
- */
446
- left?: PxSize | PercentageSize | 'auto';
447
- /**
448
- * 区域宽度,相对于作用对象或容器的宽度,支持单位为 px 的逻辑像素值或百分比
449
- *
450
- * @default "100%"
451
- */
452
- width?: PxSize | PercentageSize;
453
- /**
454
- * 区域高度,相对于作用对象或容器的高度,支持单位为 px 的逻辑像素值或百分比
455
- *
456
- * @default "100%"
457
- */
458
- height?: PxSize | PercentageSize;
459
- /**
460
- * 区域顶部相对于作用对象或容器向上的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
461
- *
462
- * 当设置了 top 和 height 值时,忽略此属性值
463
- *
464
- * 当未设置 top 值时,可通过 bottom 属性值来确定区域的垂直位置
465
- *
466
- * 当未设置 height 值时,可通过 top 和 bottom 属性值来确定区域的高度
467
- */
468
- bottom?: PxSize | PercentageSize | 'auto';
469
- /**
470
- * 区域顶部相对于作用对象或容器向左的偏移量,支持单位为 px 的逻辑像素值、百分比(相对于作用对象或容器的高度)或 "auto"
471
- *
472
- * 当设置了 left 和 width 值时,忽略此属性值
473
- *
474
- * 当未设置 left 值时,可通过 right 属性值来确定区域的水平位置
475
- *
476
- * 当未设置 width 值时,可通过 left 和 right 属性值来确定区域的宽度
477
- */
478
- right?: PxSize | PercentageSize | 'auto';
479
- [x: string]: any;
480
- };
481
- /**
482
- * 绘制的文本内容
483
- *
484
- * 当 tag 属性值为 "font" 时有效,用于保存绘制的文本内容
485
- */
486
- text?: string;
487
- /**
488
- * 绘制文本的样式
489
- *
490
- * 当 tag 属性值为 "font" 时有效,用于指定绘制文本内容的字体大小、字体颜色、字体类型等信息
491
- */
492
- textStyles?: {
493
- /**
494
- * 水平对齐方式
495
- *
496
- * "left" 字体在指定的区域中水平居左对齐
497
- *
498
- * "center" 字体在指定的区域中水平居中对齐
499
- *
500
- * "right" 字体在指定的区域中水平居右对齐
501
- *
502
- * @default "center"
503
- */
504
- align?: 'left' | 'right' | 'center';
505
- /**
506
- * 字体颜色,支持 HEX 和 RGBA 颜色
507
- *
508
- * @default "#000000"
509
- *
510
- * @format color
511
- */
512
- color?: HEXColor | RGBAColor;
513
- /**
514
- * 文本装饰
515
- *
516
- * "none" 无装饰效果
517
- *
518
- * "underline" 文本带下划线效果
519
- *
520
- * "line-through" 文本带贯穿线(删除线)效果
521
- *
522
- * @default "none"
523
- */
524
- decoration?: 'none' | 'underline' | 'line-through';
525
- /**
526
- * 字体名称,如果指定名称的字体不存在,则使用默认字体
527
- */
528
- family?: string;
529
- /**
530
- * 字体文件路径
531
- */
532
- fontSrc?: string;
533
- /**
534
- * 文本行间距,支持单位为 px 的逻辑像素值或百分比
535
- *
536
- * @default "20%"
537
- */
538
- lineSpacing?: PxSize | PercentageSize;
539
- /**
540
- * 文本间距,用于设置字体在绘制目标区域四个方向(top / right / bottom / left)的边距,支持单位为 px 的逻辑像素值或百分比(相对于绘制目标区域)
541
- *
542
- * @default "0px"
543
- */
544
- margin?: string;
545
- /**
546
- * 文本内容超出显示区域时处理方式
547
- *
548
- * "clip" 超出显示区域时内容裁剪
549
- *
550
- * "ellipsis" 超出显示区域时尾部显示省略标记(...)
551
- *
552
- * @default "clip"
553
- */
554
- overflow?: 'clip' | 'ellipsis';
555
- /**
556
- * 字体大小,单位为 px
557
- *
558
- * @default "16px"
559
- */
560
- size?: PxSize;
561
- /**
562
- * 字体样式
563
- *
564
- * "normal" 正常样式
565
- *
566
- * "italic" 斜体样式
567
- *
568
- * @default "normal"
569
- */
570
- style?: 'normal' | 'italic';
571
- /**
572
- * 垂直对齐方式,文本内容在指定绘制区域中的垂直对齐方式
573
- *
574
- * "top" 垂直居顶对齐
575
- *
576
- * "middle" 垂直居中对齐
577
- *
578
- * "bottom" - 垂直居底对齐
579
- *
580
- * @default "middle"
581
- */
582
- verticalAlign?: 'top' | 'middle' | 'bottom';
583
- /**
584
- * 字体粗细
585
- *
586
- * "normal" 正常
587
- *
588
- * "bold" 粗体
589
- *
590
- * @default "normal"
591
- */
592
- weight?: 'normal' | 'bold';
593
- /**
594
- * 文本换行模式
595
- *
596
- * "nowrap" 不换行,将所有文本在一行中绘制,忽略换行符("\n")
597
- *
598
- * "normal" 自动换行,当指定的宽度无法绘制所有文本时自动换行绘制,碰到 "\n" 字符时强制换行
599
- *
600
- * @default "nowrap"
601
- */
602
- whiteSpace?: 'normal' | 'nowrap';
603
- [x: string]: any;
604
- };
605
- /**
606
- * 绘制富文本的样式
607
- *
608
- * 当 tag 属性值为 "richtext" 时有效,用于指定绘制富文本内容的默认字体颜色、字体类型等信息
609
- */
610
- richTextStyles?: {
611
- /**
612
- * 富文本内容的水平对齐方式,对整体内容有效,无法单独控制每行的内容
613
- *
614
- * "left" 字体在指定的区域中水平居左对齐
615
- *
616
- * "center" 字体在指定的区域中水平居中对齐
617
- *
618
- * "right" 字体在指定的区域中水平居右对齐
619
- *
620
- * @default "left"
621
- */
622
- align?: 'left' | 'right' | 'center';
623
- /**
624
- * 富文本默认使用的字体名称,如果指定名称的字体不存在,则使用默认字体
625
- */
626
- family?: string;
627
- /**
628
- * 富文本默认使用的字体文件路径,必须为本地路径,如果指定的文件路径无效,则使用系统默认字体
629
- */
630
- fontSrc?: string;
631
- [x: string]: any;
632
- };
633
- [x: string]: any;
634
- }[];
635
- /**
636
- * 原生导航栏上的搜索框配置,详见 [searchInput](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview-searchinput)
637
- *
638
- * @desc 1.6.0
639
- */
640
- searchInput?: {
641
- /**
642
- * 是否自动获取焦点
643
- *
644
- * @default false
645
- */
646
- autoFocus?: boolean;
647
- /**
648
- * 非输入状态下文本的对齐方式
649
- *
650
- * "left" 居左对齐
651
- *
652
- * "right" 居右对齐
653
- *
654
- * "center" 居中对齐
655
- *
656
- * @default "center"
657
- */
658
- align?: 'center' | 'left' | 'right';
659
- /**
660
- * 背景颜色,支持 HEX 和 RGBA 颜色
661
- *
662
- * @default "rgba(255,255,255,0.5)"
663
- *
664
- * @format color
665
- */
666
- backgroundColor?: HEXColor | RGBAColor;
667
- /**
668
- * 输入框的圆角半径,单位为 px
669
- *
670
- * @default "0px"
671
- */
672
- borderRadius?: PxSize;
673
- /**
674
- * 提示文本
675
- */
676
- placeholder?: string;
677
- /**
678
- * 提示文本颜色,支持 HEX 颜色
679
- *
680
- * @default "#CCCCCC"
681
- *
682
- * @format color
683
- */
684
- placeholderColor?: HEXColor;
685
- /**
686
- * 是否禁止输入
687
- *
688
- * @default false
689
- */
690
- disabled?: boolean;
691
- [x: string]: any;
692
- };
693
- /**
694
- * 标题栏控件是否显示 Home 按钮
695
- *
696
- * @default false
697
- */
698
- homeButton?: boolean;
699
- /**
700
- * 标题栏控件是否显示左侧返回按钮
701
- *
702
- * @desc App 2.6.3+
703
- *
704
- * @default true
705
- */
706
- autoBackButton?: boolean;
707
- /**
708
- * 返回按钮的样式,详见 [backButton](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview-backbuttonstyles)
709
- *
710
- * @desc App 2.6.3
711
- */
712
- backButton?: {
713
- /**
714
- * 背景颜色,仅在标题栏 type 为 "transparent" 时生效,当标题栏透明时按钮显示的背景颜色,支持 HEX 和 RGBA 颜色
715
- *
716
- * @default 灰色半透明
717
- *
718
- * @format color
719
- */
720
- background?: HEXColor | RGBAColor;
721
- /**
722
- * 角标文本,最多显示3个字符,超过则显示为 ...
723
- */
724
- badgeText?: string;
725
- /**
726
- * 图标和标题颜色,支持 HEX 和 RGBA 颜色
727
- *
728
- * @default 窗口标题栏控件的标题文字颜色
729
- *
730
- * @format color
731
- */
732
- color?: HEXColor | RGBAColor;
733
- /**
734
- * 按下状态按钮文字颜色,支持 HEX 和 RGBA 颜色
735
- *
736
- * @default color 属性值自动调整透明度为 0.3
737
- *
738
- * @format color
739
- */
740
- colorPressed?: HEXColor | RGBAColor;
741
- /**
742
- * 返回图标的粗细
743
- *
744
- * "normal" 正常
745
- *
746
- * "bold" 粗体
747
- *
748
- * @default "normal"
749
- */
750
- fontWeight?: 'normal' | 'bold';
751
- /**
752
- * 返回图标文字大小,单位为 px
753
- *
754
- * 窗口标题栏为透明样式 type 为 "transparent" 时,默认值为 "22px"
755
- *
756
- * 窗口标题栏为默认样式 type 为 "default" 时,默认值为 "27px"
757
- */
758
- fontSize?: PxSize;
759
- /**
760
- * 是否显示红点,当设置了角标文本时红点不显示
761
- *
762
- * @default false
763
- */
764
- redDot?: boolean;
765
- /**
766
- * 返回按钮上的标题,显示在返回图标(字体图标)后
767
- *
768
- * @default ""
769
- */
770
- title?: string;
771
- /**
772
- * 返回按钮上标题的粗细
773
- *
774
- * "normal" 正常
775
- *
776
- * "bold" 粗体
777
- */
778
- titleWeight?: 'normal' | 'bold';
779
- [x: string]: any;
780
- };
781
- /**
782
- * 背景图片
783
- *
784
- * 背景图片路径,如 "/static/img.png",仅支持本地文件绝对路径,根据实际标题栏宽高拉伸绘制
785
- *
786
- * 渐变色,仅支持线性渐变,两种颜色的渐变,如 "linear-gradient(to top, #a80077, #66ff00)",其中第一个参数为渐变方向,可选 "to right"(从左向右渐变)/ "to left"(从右向左渐变)/ "to bottom"(从上到下渐变)/ "to top"(从下到上渐变)/ "to bottom right"(从左上到右下渐变)/"to top left"(从左上到右下渐变)
787
- */
788
- backgroundImage?: string;
789
- /**
790
- * 仅在 backgroundImage 设置为图片路径时有效
791
- *
792
- * "repeat" 背景图片在垂直方向和水平方向平铺
793
- *
794
- * "repeat-x" 背景图片在水平方向平铺,垂直方向拉伸
795
- *
796
- * "repeat-y" 背景图片在垂直方向平铺,水平方向拉伸
797
- *
798
- * "no-repeat" 背景图片在垂直方向和水平方向都拉伸
799
- *
800
- * @default "no-repeat"
801
- */
802
- backgroundRepeat?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
803
- /**
804
- * 文本对齐方式
805
- *
806
- * "center" 居中对齐
807
- *
808
- * "left" 居左对齐
809
- *
810
- * "auto" 根据平台自动选择(Android 平台居左对齐,iOS 平台居中对齐)
811
- *
812
- * @default "auto"
813
- */
814
- titleAlign?: 'auto' | 'center' | 'left';
815
- /**
816
- * 高斯模糊效果,仅在 type 为 "transparent" 或 "float" 时有效
817
- *
818
- * 使用模糊效果时应避免设置背景颜色,设置背景颜色可能覆盖模糊效果
819
- *
820
- * "dark" 暗风格模糊,对应 iOS 原生 UIBlurEffectStyleDark 效果
821
- *
822
- * "extralight" 高亮风格模糊,对应 iOS 原生 UIBlurEffectStyleExtraLight 效果
823
- *
824
- * "light" 亮风格模糊,对应 iOS 原生 UIBlurEffectStyleLight 效果
825
- *
826
- * "none" 无模糊效果
827
- *
828
- * @default "none"
829
- */
830
- blurEffect?: 'dark' | 'extralight' | 'light' | 'none';
831
- /**
832
- * 标题栏控件变化作用范围,仅在 type 为 "transparent" 时有效,页面滚动时标题栏背景透明度将发生变化
833
- *
834
- * 当页面滚动到指定偏移量时标题栏背景变为完全不透明
835
- *
836
- * 支持单位为 px 的逻辑像素值、百分比
837
- *
838
- * @default "132px"
839
- */
840
- coverage?: PxSize | PercentageSize;
841
- /**
842
- * 是否显示标题栏的底部分割线
843
- *
844
- * @desc 2.6.6
845
- *
846
- * @default false
847
- */
848
- splitLine?: boolean | {
849
- /**
850
- * 底部分割线颜色,支持 HEX 和 RGBA 颜色
851
- *
852
- * @default "#CCCCCC"
853
- *
854
- * @format color
855
- */
856
- color?: HEXColor | RGBAColor;
857
- /**
858
- * 底部分割线高度,支持单位为 px 的逻辑像素值、百分比
859
- *
860
- * @default "1px"
861
- */
862
- height?: PxSize | PercentageSize;
863
- [x: string]: any;
864
- };
865
- /**
866
- * 副标题文字颜色,支持 HEX 和 RGBA 颜色
867
- *
868
- * @desc 2.6.6
869
- *
870
- * @default 与主标题文字颜色一致
871
- *
872
- * @format color
873
- */
874
- subtitleColor?: HEXColor | RGBAColor;
875
- /**
876
- * 副标题文字字体大小,单位为 px
877
- *
878
- * "auto" 自动计算,约为 12px
879
- *
880
- * @desc 2.6.6
881
- *
882
- * @default "auto"
883
- */
884
- subtitleSize?: PxSize | 'auto';
885
- /**
886
- * 标题文字超出显示区域时处理方式
887
- *
888
- * "clip" 超出显示区域时内容裁剪
889
- *
890
- * "ellipsis" 超出显示区域时尾部显示省略标记(...)
891
- *
892
- * @desc 2.6.6
893
- *
894
- * @default "ellipsis"
895
- */
896
- subtitleOverflow?: 'clip' | 'ellipsis';
897
- /**
898
- * 副标题文字内容,设置副标题后将显示两行标题,副标题显示在主标题(titleText)下方
899
- *
900
- * 设置副标题后将居左显示
901
- *
902
- * @desc 2.6.6
903
- */
904
- subtitleText?: string;
905
- /**
906
- * 标题图标,图标路径如 "./img/t.png",仅支持本地文件路径,相对路径,相对于当前页面的 host 位置,固定宽高为逻辑像素值 "34px"
907
- *
908
- * 图片的宽高需要相同
909
- *
910
- * 设置标题图标后标题将居左显示
911
- *
912
- * @desc 2.6.6
913
- */
914
- titleIcon?: string;
915
- /**
916
- * 标题图标圆角,单位为 px
917
- *
918
- * @default "0px"
919
- */
920
- titleIconRadius?: PxSize;
921
- [x: string]: any;
922
- };
923
- /**
924
- * 原生子窗体,详见 [原生子窗体](https://uniapp.dcloud.net.cn/collocation/pages#app-subNVues)
925
- *
926
- * @desc App 1.9.10+
927
- */
928
- subNVues?: {
929
- /**
930
- * 原生子窗体的标识
931
- */
932
- id?: string;
933
- /**
934
- * 配置 nvue 文件路径,nvue 文件需放置到使用 subNVue 的页面文件目录下,cli 项目需要去掉 .nvue 后缀,只保留文件名
935
- */
936
- path?: string;
937
- /**
938
- * 原生子窗口内置样式
939
- *
940
- * "popup" 弹出层
941
- *
942
- * "navigationBar" 导航栏
943
- */
944
- type?: string;
945
- /**
946
- * 原生子窗体的样式
947
- */
948
- style?: {
949
- /**
950
- * 原生子窗体的排版位置,排版位置决定原生子窗体在父窗口中的定位方式
951
- *
952
- * "static" 原生子窗体在页面中正常定位,如果页面存在滚动条则随窗口内容滚动
953
- *
954
- * "absolute" 原生子窗体在页面中绝对定位,如果页面存在滚动条不随窗口内容滚动
955
- *
956
- * "dock" 原生子窗体在页面中停靠,停靠位置由 dock 属性值决定
957
- *
958
- * @default "absolute"
959
- */
960
- position?: 'static' | 'absolute' | 'dock';
961
- /**
962
- * 原生子窗体停靠位置,仅 position 为 "dock" 时生效
963
- *
964
- * "top" 原生子窗体停靠在页面顶部
965
- *
966
- * "bottom" 原生子窗体停靠在页面底部
967
- *
968
- * "right" 原生子窗体停靠在页面右侧
969
- *
970
- * "left" 原生子窗体停靠在页面左侧
971
- *
972
- * @default "bottom"
973
- */
974
- dock?: 'top' | 'bottom' | 'right' | 'left';
975
- /**
976
- * 原生子窗体的遮罩层,仅当原生子窗体 type 为 "popup" 时生效,支持 RGBA 颜色
977
- *
978
- * @default "rgba(0,0,0,0.5)"
979
- *
980
- * @format color
981
- */
982
- mask?: RGBAColor;
983
- /**
984
- * 原生子窗体的宽度,支持以 px 为单位的逻辑像素值或百分比
985
- *
986
- * 未设置时,可同时设置 left 和 right 属性值改变窗口的默认宽度
987
- *
988
- * @default "100%"
989
- */
990
- width?: PxSize | PercentageSize;
991
- /**
992
- * 原生子窗体的高度,支持以 px 为单位的逻辑像素值或百分比
993
- *
994
- * 未设置时,可同时设置 top 和 bottom 属性值改变窗口的默认高度
995
- *
996
- * @default "100%"
997
- */
998
- height?: PxSize | PercentageSize;
999
- /**
1000
- * 原生子窗体垂直向下的偏移量,支持以 px 为单位的逻辑像素值或百分比
1001
- *
1002
- * 未设置 top 属性值时,优先通过 bottom 和 height 属性值来计算原生子窗体的 top 位置
1003
- *
1004
- * @default "0px"
1005
- */
1006
- top?: PxSize | PercentageSize;
1007
- /**
1008
- * 原生子窗体垂直向上的偏移量,支持以 px 为单位的逻辑像素值或百分比
1009
- *
1010
- * 同时设置了 top 和 height 值时,忽略此属性值
1011
- *
1012
- * 未设置 height 时,通过 top 和 bottom 属性值来确定原生子窗体的高度
1013
- *
1014
- * @default 根据 top 和 height 属性值自动计算
1015
- */
1016
- bottom?: PxSize | PercentageSize;
1017
- /**
1018
- * 原生子窗体水平向左的偏移量,支持以 px 为单位的逻辑像素值或百分比
1019
- *
1020
- * 未设置 left 属性值时,优先通过 right 和 width 属性值来计算原生子窗体的 left 位置
1021
- *
1022
- * @default "0px"
1023
- */
1024
- left?: PxSize | PercentageSize;
1025
- /**
1026
- * 原生子窗体水平向右的偏移量,支持以 px 为单位的逻辑像素值或百分比
1027
- *
1028
- * 同时设置了 left 和 height 值时,忽略此属性值
1029
- *
1030
- * 未设置 width 时,通过 left 和 bottom 属性值来确定原生子窗体的宽度
1031
- *
1032
- * @default 根据 left 和 width 属性值来自动计算
1033
- */
1034
- right?: PxSize | PercentageSize;
1035
- /**
1036
- * 原生子窗体的边距,用于定位原生子窗体的位置,若设置了 left、right、top、bottom 则对应的边距值失效
1037
- *
1038
- * "auto" 居中
1039
- */
1040
- margin?: string;
1041
- /**
1042
- * 原生子窗体的窗口的堆叠顺序值,拥有更高堆叠顺序的窗口总是会处于堆叠顺序较低的窗口的前面,拥有相同堆叠顺序的窗口后调用 show 方法则在前面
1043
- */
1044
- zindex?: number;
1045
- /**
1046
- * 窗口的背景颜色,支持 Hex 颜色
1047
- *
1048
- * Android 平台 4.0 以上系统支持 "transparent" 背景透明样式,比如 subNVue 为圆角时需要设置为 "transparent" 才能看到正确的效果
1049
- *
1050
- * @default "#FFFFFF"
1051
- *
1052
- * @format color
1053
- */
1054
- background?: HEXColor | 'transparent';
1055
- [x: string]: any;
1056
- };
1057
- [x: string]: any;
1058
- }[];
1059
- /**
1060
- * 页面回弹效果,设置为 "none" 时关闭效果
1061
- *
1062
- * @desc App-vue(nvue Android 无页面级bounce效果,仅 list、recycle-list、waterfall 等滚动组件有 bounce 效果)
1063
- */
1064
- bounce?: string;
1065
- /**
1066
- * 侧滑返回功能,仅支持 "close" / "none"
1067
- *
1068
- * "close" 启用侧滑返回
1069
- *
1070
- * "none" 禁用侧滑返回
1071
- *
1072
- * @default "close"
1073
- *
1074
- * @desc App-iOS
1075
- */
1076
- popGesture?: 'close' | 'none';
1077
- /**
1078
- * iOS 软键盘上完成工具栏的显示模式,设置为 "none" 时关闭工具栏
1079
- *
1080
- * @default "auto"
1081
- *
1082
- * @desc App-iOS
1083
- */
1084
- softInputNavBar?: 'auto' | 'none';
1085
- /**
1086
- * 软键盘弹出模式,仅支持 "adjustResize" / "adjustPan"
1087
- *
1088
- * @default "adjustPan"
1089
- *
1090
- * @desc App
1091
- */
1092
- softInputMode?: 'adjustResize' | 'adjustPan';
1093
- /**
1094
- * 下拉刷新
1095
- *
1096
- * @desc App
1097
- */
1098
- pullToRefresh?: {
1099
- /**
1100
- * 是否开启窗口下拉刷新
1101
- *
1102
- * @default false
1103
- */
1104
- support?: boolean;
1105
- /**
1106
- * 下拉刷新控件颜色,仅 style 为 "circle" 时有效,支持 HEX 颜色
1107
- *
1108
- * @default "#2BD009"
1109
- *
1110
- * @format color
1111
- */
1112
- color?: HEXColor;
1113
- /**
1114
- * 下拉刷新控件样式
1115
- *
1116
- * "default" 下拉拖动时页面内容跟随
1117
- *
1118
- * "circle" 下拉拖动时仅刷新控件跟随
1119
- *
1120
- * @default Android 为 "circle",iOS 为 "default"
1121
- */
1122
- style?: 'default' | 'circle';
1123
- /**
1124
- * 下拉刷新控件进入刷新状态的拉拽高度,支持以 px 为单位的逻辑像素值或百分比
1125
- */
1126
- height?: PxSize | PercentageSize;
1127
- /**
1128
- * 窗口可下拉拖拽的范围,支持以 px 为单位的逻辑像素值或百分比
1129
- */
1130
- range?: PxSize | PercentageSize;
1131
- /**
1132
- * 下拉刷新控件的起始位置,仅 style 为 "circle" 时有效,用于定义刷新控件下拉时的起始位置,支持以 px 为单位的逻辑像素值或百分比
1133
- *
1134
- * 如使用了非原生 title 且需要原生下拉刷新,一般都设置 style 为 "circle" 并将 offset 设置为自定义 title 的高度
1135
- */
1136
- offset?: PxSize | PercentageSize;
1137
- /**
1138
- * 下拉可刷新状态时配置,仅 style 为 "default" 时有效
1139
- */
1140
- contentdown?: {
1141
- /**
1142
- * 下拉可刷新状态时下拉刷新控件标题内容
1143
- */
1144
- caption?: string;
1145
- [x: string]: any;
1146
- };
1147
- /**
1148
- * 释放可刷新状态时配置,仅 style 为 "default" 时有效
1149
- */
1150
- contentover?: {
1151
- /**
1152
- * 释放可刷新状态时下拉刷新控件标题内容
1153
- */
1154
- caption?: string;
1155
- [x: string]: any;
1156
- };
1157
- /**
1158
- * 正在刷新状态时配置,仅 style 为 "default" 时有效
1159
- */
1160
- contentrefresh?: {
1161
- /**
1162
- * 正在刷新状态时下拉刷新控件标题内容
1163
- */
1164
- caption?: string;
1165
- [x: string]: any;
1166
- };
1167
- [x: string]: any;
1168
- };
1169
- /**
1170
- * 滚动条显示策略,设置为 "none" 时不显示滚动条
1171
- *
1172
- * @desc App
1173
- */
1174
- scrollIndicator?: string;
1175
- /**
1176
- * 窗口显示的动画效果,详见 [窗口动画](https://uniapp.dcloud.net.cn/api/router#animation)
1177
- *
1178
- * @default "pop-in"
1179
- *
1180
- * @desc App
1181
- */
1182
- animationType?: AnimationType;
1183
- /**
1184
- * 窗口显示动画的持续时间,单位为 ms
1185
- *
1186
- * @default 300
1187
- *
1188
- * @desc App
1189
- */
1190
- animationDuration?: number;
1191
- [x: string]: any;
1192
- }
1193
-
1194
- interface H5 {
1195
- /**
1196
- * 导航栏,详见 [导航栏](https://uniapp.dcloud.net.cn/collocation/pages#h5-titlenview)
1197
- */
1198
- titleNView?: false | {
1199
- /**
1200
- * 背景颜色,支持 HEX 颜色
1201
- *
1202
- * @default "#F7F7F7"
1203
- *
1204
- * @format color
1205
- */
1206
- backgroundColor?: HEXColor;
1207
- /**
1208
- * 自定义按钮,详见 [自定义按钮](https://uniapp.dcloud.net.cn/collocation/pages#app-titlenview-buttons)
1209
- */
1210
- buttons?: TitleNViewButton[];
1211
- /**
1212
- * 标题文字颜色,支持 HEX 颜色
1213
- *
1214
- * @default "#000000"
1215
- *
1216
- * @format color
1217
- */
1218
- titleColor?: HEXColor;
1219
- /**
1220
- * 标题文字内容
1221
- */
1222
- titleText?: string;
1223
- /**
1224
- * 标题文字大小
1225
- */
1226
- titleSize?: string;
1227
- /**
1228
- * 导航栏样式
1229
- *
1230
- * "default" 默认样式
1231
- *
1232
- * "transparent" 滚动透明渐变
1233
- *
1234
- * @default "default"
1235
- */
1236
- type?: 'default' | 'transparent';
1237
- /**
1238
- * 导航栏上的搜索框配置,详见 [searchInput](https://uniapp.dcloud.net.cn/collocation/pages#h5-searchinput)
1239
- *
1240
- * @desc 1.6.5
1241
- */
1242
- searchInput?: {
1243
- /**
1244
- * 是否自动获取焦点
1245
- *
1246
- * @default false
1247
- */
1248
- autoFocus?: boolean;
1249
- /**
1250
- * 非输入状态下文本的对齐方式
1251
- *
1252
- * "left" 居左对齐
1253
- *
1254
- * "right" 居右对齐
1255
- *
1256
- * "center" 居中对齐
1257
- *
1258
- * @default "center"
1259
- */
1260
- align?: 'center' | 'left' | 'right';
1261
- /**
1262
- * 背景颜色,支持 HEX 和 RGBA 颜色
1263
- *
1264
- * @default "rgba(255,255,255,0.5)"
1265
- *
1266
- * @format color
1267
- */
1268
- backgroundColor?: HEXColor | RGBAColor;
1269
- /**
1270
- * 输入框的圆角半径,单位为 px
1271
- *
1272
- * @default "0px"
1273
- */
1274
- borderRadius?: PxSize;
1275
- /**
1276
- * 提示文本
1277
- */
1278
- placeholder?: string;
1279
- /**
1280
- * 提示文本颜色,支持 HEX 颜色
1281
- *
1282
- * @default "#CCCCCC"
1283
- *
1284
- * @format color
1285
- */
1286
- placeholderColor?: HEXColor;
1287
- /**
1288
- * 是否禁止输入
1289
- *
1290
- * @default false
1291
- */
1292
- disabled?: boolean;
1293
- [x: string]: any;
1294
- };
1295
- [x: string]: any;
1296
- };
1297
- /**
1298
- * 下拉刷新,详见 [下拉刷新](https://uniapp.dcloud.net.cn/collocation/pages#h5-pulltorefresh)
1299
- */
1300
- pullToRefresh?: {
1301
- /**
1302
- * 下拉刷新控件颜色,支持 HEX 颜色
1303
- *
1304
- * @default "#2BD009"
1305
- */
1306
- color?: HEXColor;
1307
- /**
1308
- * 下拉刷新控件起始位置,支持支持单位为 px 的逻辑像素值或百分比
1309
- *
1310
- * @default "0px"
1311
- */
1312
- offset?: PxSize | PercentageSize;
1313
- [x: string]: any;
1314
- };
1315
- [x: string]: any;
1316
- }
1317
-
1318
- /**
1319
- * 设置编译到 mp-alipay 平台的特定样式,配置项参考 [MP-ALIPAY](https://uniapp.dcloud.net.cn/collocation/pages#mp-alipay) 和 <https://opendocs.alipay.com/mini/framework/app-json#window>
18
+ * Define uni-pages configuration
19
+ * Used in pages.config.ts configuration file to provide type hints and validation
1320
20
  *
1321
- * 相应的类型是 MpAlipay
1322
- *
1323
- * @desc 支付宝小程序
21
+ * @param config - Page configuration object
22
+ * @returns Configuration object
1324
23
  */
1325
- interface MpAlipay {
1326
- /**
1327
- * 是否允许向下拉拽
1328
- *
1329
- * @default "YES"
1330
- */
1331
- allowsBounceVertical?: 'YES' | 'NO';
1332
- /**
1333
- * 窗口的背景色,支持 HEX 颜色
1334
- *
1335
- * @format color
1336
- */
1337
- backgroundColor?: HEXColor | ThemeVar;
1338
- /**
1339
- * 下拉露出显示背景图的底色,仅 Android 有效,iOS 下页面背景图底色会使用 backgroundColor 的值
1340
- *
1341
- * @format color
1342
- */
1343
- backgroundImageColor?: HEXColor;
1344
- /**
1345
- * 下拉露出显示背景图的链接,支持网络地址和本地地址,尽量使用绝对地址
1346
- */
1347
- backgroundImageUrl?: string;
1348
- /**
1349
- * 页面默认标题
1350
- */
1351
- defaultTitle?: string;
1352
- /**
1353
- * 仅支持 Android,是否显示 WebView 滚动条
1354
- *
1355
- * @default "YES"
1356
- */
1357
- enableScrollBar?: 'YES' | 'NO';
1358
- /**
1359
- * 仅支持 iOS,是否支持手势返回
1360
- *
1361
- * @default "YES"
1362
- */
1363
- gestureBack?: 'YES' | 'NO';
1364
- /**
1365
- * 页面上拉触底时触发时距离页面底部的距离,单位为 px,详情可查看 [页面事件处理函数](https://opendocs.alipay.com/mini/framework/page-detail#%E9%A1%B5%E9%9D%A2%E4%BA%8B%E4%BB%B6%E5%A4%84%E7%90%86%E5%87%BD%E6%95%B0)
1366
- *
1367
- * @desc [1.19.0](https://opendocs.alipay.com/mini/framework/compatibility),目前 iOS 在 page.json 下设置无效,只能全局设置
1368
- */
1369
- onReachBottomDistance?: number;
1370
- /**
1371
- * 是否允许下拉刷新,allowsBounceVertical 值需要为 "YES",全局配置后全局生效,但是如果单个页面配置了该参数,以页面的配置为准
1372
- *
1373
- * @default false
1374
- */
1375
- pullRefresh?: boolean;
1376
- /**
1377
- * rpx 单位是否宽度自适应
1378
- *
1379
- * 当设置为 false 时,2 rpx 将恒等于 1 px,不再根据屏幕宽度进行自适应,此时 750 rpx 将不再等于 100% 宽度
1380
- *
1381
- * @desc [1.23.0](https://opendocs.alipay.com/mini/framework/compatibility)
1382
- *
1383
- * @default true
1384
- */
1385
- responsive?: boolean;
1386
- /**
1387
- * 是否进入时显示导航栏的 loading
1388
- *
1389
- * @default "NO"
1390
- */
1391
- showTitleLoading?: 'YES' | 'NO';
1392
- /**
1393
- * 导航栏透明设置
1394
- *
1395
- * always 一直透明
1396
- *
1397
- * auto 滑动自适应
1398
- *
1399
- * none 不透明
1400
- *
1401
- * @default "none"
1402
- */
1403
- transparentTitle?: 'always' | 'auto' | 'none';
1404
- /**
1405
- * 导航栏点击穿透
1406
- *
1407
- * @default "NO"
1408
- */
1409
- titlePenetrate?: 'YES' | 'NO';
1410
- /**
1411
- * 导航栏图片地址,会替换当前文字标题,只支持 https 图片链接
1412
- */
1413
- titleImage?: string;
1414
- /**
1415
- * 导航栏背景色,支持 HEX 颜色
1416
- */
1417
- titleBarColor?: HEXColor;
1418
- /**
1419
- * 导航栏前景色
1420
- *
1421
- * @desc [支付宝客户端 10.5.30](https://opendocs.alipay.com/mini/framework/compatibility)
1422
- */
1423
- navigationBarFrontColor?: 'black' | 'white';
1424
- [x: string]: any;
1425
- }
1426
-
24
+ declare function defineUniPages(config: UserPagesConfig): UserPagesConfig;
25
+ //#endregion
26
+ //#region src/page.d.ts
1427
27
  /**
1428
- * 设置编译到 mp-baidu 平台的特定样式,配置项参考 [MP-BAIDU](https://uniapp.dcloud.net.cn/collocation/pages.html#mp-baidu) 和 <https://smartprogram.baidu.com/docs/develop/framework/process/#window>
1429
- *
1430
- * 相应的类型是 MpBaidu
28
+ * Page class representing a Vue page file
1431
29
  *
1432
- * @desc 百度小程序
30
+ * Responsibilities:
31
+ * 1. Read page file content
32
+ * 2. Parse page metadata defined by definePage macro
33
+ * 3. Provide tabBar configuration information
34
+ * 4. Track page file change status
1433
35
  */
1434
- interface MpBaidu {
1435
- /**
1436
- * 导航栏背景颜色,支持 HEX 颜色
1437
- *
1438
- * @default "#000000"
1439
- *
1440
- * @format color
1441
- */
1442
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
1443
- /**
1444
- * 导航栏标题、状态栏颜色
1445
- *
1446
- * @default "white"
1447
- */
1448
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
1449
- /**
1450
- * 导航栏标题文字内容
1451
- */
1452
- navigationBarTitleText?: string;
1453
- /**
1454
- * 导航栏样式
1455
- *
1456
- * "default" 默认样式
1457
- *
1458
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
1459
- *
1460
- * @desc 2.10.34
1461
- *
1462
- * @default "default"
1463
- */
1464
- navigationStyle?: 'default' | 'custom';
1465
- /**
1466
- * 窗口的背景色,支持 HEX 颜色
1467
- *
1468
- * @default "#FFFFFF"
1469
- */
1470
- backgroundColor?: HEXColor | ThemeVar;
1471
- /**
1472
- * 下拉 loading 的样式,仅支持 "dark" / "light"
1473
- *
1474
- * @default "dark"
1475
- */
1476
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
1477
- /**
1478
- * 顶部窗口的背景色,仅 iOS 支持
1479
- *
1480
- * @default "#FFFFFF"
1481
- */
1482
- backgroundColorTop?: HEXColor | ThemeVar;
1483
- /**
1484
- * 底部窗口的背景色,仅 iOS 支持
1485
- *
1486
- * @default "#FFFFFF"
1487
- */
1488
- backgroundColorBottom?: HEXColor | ThemeVar;
1489
- /**
1490
- * 是否开启全局的下拉刷新
1491
- *
1492
- * @default false
1493
- */
1494
- enablePullDownRefresh?: boolean;
1495
- /**
1496
- * 页面上拉触底事件触发时距页面底部距离,单位为 px
1497
- *
1498
- * @default 50
1499
- */
1500
- onReachBottomDistance?: number;
1501
- /**
1502
- * 小程序页面是否禁止响应字体大小的设置
1503
- *
1504
- * "auto" 默认响应
1505
- *
1506
- * "none" 不响应
1507
- *
1508
- * @desc 基础库版本 3.200.1
1509
- *
1510
- * @default "auto"
1511
- */
1512
- textSizeAdjust?: 'auto' | 'none';
1513
- /**
1514
- * 屏幕旋转设置,支持 auto / portrait / landscape
1515
- *
1516
- * "auto" 自动
1517
- *
1518
- * "portrait" 竖屏
1519
- *
1520
- * "landscape" 横屏
1521
- *
1522
- * @desc 基础库版本 3.450.8,web 化暂不支持
1523
- *
1524
- * @default "portrait"
1525
- */
1526
- pageOrientation?: 'auto' | 'portrait' | 'landscape';
1527
- [x: string]: any;
36
+ declare class Page {
37
+ /** Page context instance */
38
+ ctx: PageContext;
39
+ /** Page path information containing relative and absolute paths */
40
+ path: PagePath;
41
+ /** Page URI used for pages.json path field */
42
+ uri: string;
43
+ /** Whether the page has changed, used for incremental update judgment */
44
+ changed: boolean;
45
+ /** Raw JSON string of page metadata for change detection */
46
+ private raw;
47
+ /** Parsed page metadata */
48
+ private meta;
49
+ /**
50
+ * Create a page instance
51
+ * @param ctx - Page context instance
52
+ * @param path - Page path information
53
+ */
54
+ constructor(ctx: PageContext, path: PagePath);
55
+ /**
56
+ * Get page metadata
57
+ * Parse configuration defined by definePage macro and return metadata for pages.json
58
+ *
59
+ * @param forceUpdate - Whether to force update, ignoring cache
60
+ * @returns Page metadata object
61
+ */
62
+ getPageMeta(forceUpdate?: boolean): Promise<PageMetaDatum>;
63
+ /**
64
+ * Get page tabBar configuration
65
+ * Extract tabBar related configuration from definePage macro
66
+ *
67
+ * @param forceUpdate - Whether to force update, ignoring cache
68
+ * @returns tabBar configuration object, or undefined if page doesn't define tabBar
69
+ */
70
+ getTabBar(forceUpdate?: boolean): Promise<index_d_exports$1.TabBarItem & {
71
+ index: number;
72
+ } | undefined>;
73
+ /**
74
+ * Check if the page has changed
75
+ * @returns Whether the page has changed
76
+ */
77
+ hasChanged(): boolean;
78
+ /**
79
+ * Read page file and parse metadata
80
+ * Extract configuration defined by definePage macro from Vue SFC
81
+ */
82
+ read(): Promise<void>;
83
+ private readPageMetaFromFile;
1528
84
  }
1529
-
1530
85
  /**
1531
- * 设置编译到 mp-jd 平台的特定样式,配置项参考 <https://mp-docs.jd.com/doc/dev/framework/504#heading-3>
86
+ * Parse Vue Single File Component (SFC)
87
+ * Compatible with different versions of @vue/compiler-sfc
1532
88
  *
1533
- * 相应的类型是 MpJd
1534
- *
1535
- * @desc 京东小程序
89
+ * @param code - Vue SFC source code
90
+ * @param options - Parse options
91
+ * @returns SFC descriptor object
1536
92
  */
1537
- interface MpJd {
1538
- /**
1539
- * 导航栏背景颜色,支持 HEX 颜色
1540
- *
1541
- * @default "#000000"
1542
- *
1543
- * @format color
1544
- */
1545
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
1546
- /**
1547
- * 导航栏标题、状态栏颜色
1548
- *
1549
- * @default "white"
1550
- */
1551
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
1552
- /**
1553
- * 导航栏标题文字内容
1554
- */
1555
- navigationBarTitleText?: string;
1556
- /**
1557
- * 导航栏样式
1558
- *
1559
- * "default" 默认样式
1560
- *
1561
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
1562
- *
1563
- * @default "default"
1564
- */
1565
- navigationStyle?: 'default' | 'custom';
1566
- /**
1567
- * 下拉窗口的背景色,不是页面的背景颜色
1568
- *
1569
- * @default "#FFFFFF"
1570
- */
1571
- backgroundColor?: HEXColor | ThemeVar;
1572
- /**
1573
- * 下拉 loading 的样式,仅支持 "dark" / "light"
1574
- *
1575
- * @default "dark"
1576
- */
1577
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
1578
- /**
1579
- * 顶部窗口的背景色,仅 iOS 支持
1580
- *
1581
- * @default "#FFFFFF"
1582
- */
1583
- backgroundColorTop?: HEXColor | ThemeVar;
1584
- /**
1585
- * 底部窗口的背景色,仅 iOS 支持
1586
- *
1587
- * @default "#FFFFFF"
1588
- */
1589
- backgroundColorBottom?: HEXColor | ThemeVar;
1590
- /**
1591
- * 是否开启全局的下拉刷新,详见 [Page.onPullDownRefresh](https://mp-docs.jd.com/doc/dev/framework/520#heading-10)
1592
- *
1593
- * @default false
1594
- */
1595
- enablePullDownRefresh?: boolean;
1596
- [x: string]: any;
1597
- }
1598
-
93
+ declare function parseSFC(code: string, options?: SFCParseOptions): SFCDescriptor;
1599
94
  /**
1600
- * 设置编译到 mp-kuaishou 平台的特定样式,配置项参考 <https://mp.kuaishou.com/docs/develop/frame/config/conf_appjson.html#window>
95
+ * Try to extract page metadata defined by definePage macro from SFC
96
+ * Support using definePage in script setup or regular script
1601
97
  *
1602
- * 相应的类型是 MpKuaishou
1603
- *
1604
- * @desc 快手小程序
98
+ * @param sfc - Vue SFC descriptor
99
+ * @returns Page metadata object, or undefined if definePage is not found
1605
100
  */
1606
- interface MpKuaishou {
1607
- /**
1608
- * 导航栏背景颜色,支持 HEX 颜色
1609
- *
1610
- * @default "#000000"
1611
- *
1612
- * @format color
1613
- */
1614
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
1615
- /**
1616
- * 导航栏标题、状态栏颜色
1617
- *
1618
- * @default "white"
1619
- */
1620
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
1621
- /**
1622
- * 导航栏标题文字内容
1623
- */
1624
- navigationBarTitleText?: string;
1625
- /**
1626
- * 导航栏样式
1627
- *
1628
- * "default" 默认样式
1629
- *
1630
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
1631
- *
1632
- * @default "default"
1633
- */
1634
- navigationStyle?: 'default' | 'custom';
1635
- /**
1636
- * 窗口的背景色,支持 HEX 颜色
1637
- *
1638
- * @default "#FFFFFF"
1639
- */
1640
- backgroundColor?: HEXColor | ThemeVar;
1641
- /**
1642
- * 下拉 loading 的样式,仅支持 "dark" / "light"
1643
- *
1644
- * @default "dark"
1645
- */
1646
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
1647
- /**
1648
- * 顶部窗口的背景色,仅 iOS 支持
1649
- *
1650
- * @default "#FFFFFF"
1651
- */
1652
- backgroundColorTop?: HEXColor | ThemeVar;
1653
- /**
1654
- * 底部窗口的背景色,仅 iOS 支持
1655
- *
1656
- * @default "#FFFFFF"
1657
- */
1658
- backgroundColorBottom?: HEXColor | ThemeVar;
1659
- /**
1660
- * 是否开启全局的下拉刷新,详见 [Page.onPullDownRefresh](https://mp.kuaishou.com/docs/develop/frame/page/page_page.html#onpulldownrefresh)
1661
- *
1662
- * @default false
1663
- */
1664
- enablePullDownRefresh?: boolean;
1665
- /**
1666
- * 页面上拉触底事件触发时距页面底部距离,单位为 px,详见 [Page.onReachBottom](https://mp.kuaishou.com/docs/develop/frame/page/page_page.html#onreachbottom)
1667
- *
1668
- * @default 50
1669
- */
1670
- onReachBottomDistance?: number;
1671
- /**
1672
- * 屏幕旋转设置,支持 auto / portrait / landscape,详见 [响应显示区域变化](https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html)
1673
- *
1674
- * "auto" 自动
1675
- *
1676
- * "portrait" 竖屏
1677
- *
1678
- * "landscape" 横屏
1679
- *
1680
- * @default "portrait"
1681
- */
1682
- pageOrientation?: 'auto' | 'portrait' | 'landscape';
1683
- [x: string]: any;
1684
- }
1685
-
101
+ declare function tryPageMetaFromMacro(sfc: SFCDescriptor): Promise<UserPageMeta | undefined>;
1686
102
  /**
1687
- * 设置编译到 mp-lark 平台的特定样式,配置项参考 <https://open.feishu.cn/document/client-docs/gadget/introduction/global-settings#a172b7dd>
103
+ * Find definePage macro call in AST
104
+ * Support function expressions, arrow functions and object expressions as arguments
1688
105
  *
1689
- * 相应的类型是 MpLark
1690
- *
1691
- * @desc 飞书小程序
106
+ * @param stmts - AST statement array
107
+ * @param filename - Filename for error reporting
108
+ * @returns definePage call expression, or undefined if not found
1692
109
  */
1693
- interface MpLark {
1694
- /**
1695
- * 导航栏背景颜色,支持 HEX 颜色
1696
- *
1697
- * @desc iOS, Android
1698
- *
1699
- * @default "#000000"
1700
- *
1701
- * @format color
1702
- */
1703
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
1704
- /**
1705
- * 导航栏标题、状态栏颜色
1706
- *
1707
- * @desc iOS, Android
1708
- *
1709
- * @default "white"
1710
- */
1711
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
1712
- /**
1713
- * 导航栏标题文字内容
1714
- *
1715
- * @desc iOS, Android, PC
1716
- */
1717
- navigationBarTitleText?: string;
1718
- /**
1719
- * 导航栏透明设置
1720
- *
1721
- * "always" 一直透明
1722
- *
1723
- * "auto" 滑动自适应
1724
- *
1725
- * "none" 不透明
1726
- *
1727
- * @desc iOS, Android
1728
- *
1729
- * @default "none"
1730
- */
1731
- transparentTitle?: 'always' | 'auto' | 'none';
1732
- /**
1733
- * 导航栏样式
1734
- *
1735
- * "default" 默认样式
1736
- *
1737
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
1738
- *
1739
- * @desc iOS, Android, PC
1740
- *
1741
- * @default "default"
1742
- */
1743
- navigationStyle?: 'default' | 'custom';
1744
- /**
1745
- * 窗口的背景色,支持 HEX 颜色
1746
- *
1747
- * @desc iOS, Android, PC(3.14.0+)
1748
- *
1749
- * @default "#FFFFFF"
1750
- */
1751
- backgroundColor?: HEXColor | ThemeVar;
1752
- /**
1753
- * 下拉 loading 的样式,仅支持 "dark" / "light"
1754
- *
1755
- * @desc iOS, Android
1756
- *
1757
- * @default "dark"
1758
- */
1759
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
1760
- /**
1761
- * 顶部窗口的背景色
1762
- *
1763
- * @desc iOS
1764
- *
1765
- * @default "#FFFFFF"
1766
- */
1767
- backgroundColorTop?: HEXColor | ThemeVar;
1768
- /**
1769
- * 底部窗口的背景色
1770
- *
1771
- * @desc iOS
1772
- *
1773
- * @default "#FFFFFF"
1774
- */
1775
- backgroundColorBottom?: HEXColor | ThemeVar;
1776
- /**
1777
- * 是否开启全局的下拉刷新
1778
- *
1779
- * @desc iOS, Android
1780
- *
1781
- * @default false
1782
- */
1783
- enablePullDownRefresh?: boolean;
1784
- /**
1785
- * 页面上拉触底事件触发时距页面底部距离,单位为 px
1786
- *
1787
- * @desc iOS, Android
1788
- *
1789
- * @default 50
1790
- */
1791
- onReachBottomDistance?: number;
1792
- /**
1793
- * PCMode 模式下特定的窗口配置,支持的属性与通用 window 配置属性一致,仅当在 ext 内配置了 defaultPages.PCMode 时生效
1794
- */
1795
- PCMode?: Omit<MpLark, 'PCMode'>;
1796
- [x: string]: any;
1797
- }
1798
-
110
+ declare function findMacro(stmts: t.Statement[], filename: string): t.CallExpression | undefined;
1799
111
  /**
1800
- * 设置编译到 mp-qq 平台的特定样式,配置项参考 <https://q.qq.com/wiki/develop/miniprogram/frame/dispose.html#window>
1801
- *
1802
- * 相应的类型是 MpQq
112
+ * Extract all import declarations from AST
113
+ * Used to provide necessary imports when executing definePage arguments
1803
114
  *
1804
- * @desc QQ 小程序
115
+ * @param stmts - AST statement array
116
+ * @returns Import declaration array
1805
117
  */
1806
- interface MpQq {
1807
- /**
1808
- * 导航栏背景颜色,支持 HEX 颜色
1809
- *
1810
- * @default "#000000"
1811
- *
1812
- * @format color
1813
- */
1814
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
1815
- /**
1816
- * 导航栏标题、状态栏颜色
1817
- *
1818
- * @default "white"
1819
- */
1820
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
1821
- /**
1822
- * 导航栏标题文字内容
1823
- */
1824
- navigationBarTitleText?: string;
1825
- /**
1826
- * 导航栏样式
1827
- *
1828
- * "default" 默认样式
1829
- *
1830
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
1831
- *
1832
- * @default "default"
1833
- */
1834
- navigationStyle?: 'default' | 'custom';
1835
- /**
1836
- * 窗口的背景色,支持 HEX 颜色
1837
- *
1838
- * @default "#FFFFFF"
1839
- */
1840
- backgroundColor?: HEXColor | ThemeVar;
1841
- /**
1842
- * 下拉 loading 的样式,仅支持 "dark" / "light"
1843
- *
1844
- * @default "dark"
1845
- */
1846
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
1847
- /**
1848
- * 顶部窗口的背景色,仅 iOS 支持
1849
- *
1850
- * @default "#FFFFFF"
1851
- */
1852
- backgroundColorTop?: HEXColor | ThemeVar;
1853
- /**
1854
- * 底部窗口的背景色,仅 iOS 支持
1855
- *
1856
- * @default "#FFFFFF"
1857
- */
1858
- backgroundColorBottom?: HEXColor | ThemeVar;
1859
- /**
1860
- * 是否开启全局的下拉刷新,详见 [Page.onPullDownRefresh](https://q.qq.com/wiki/develop/miniprogram/frame/logic/logic_register_page.html#onPullDownRefresh)
1861
- *
1862
- * @default false
1863
- */
1864
- enablePullDownRefresh?: boolean;
1865
- /**
1866
- * 屏幕旋转设置,支持 auto / portrait / landscape,详见 [响应显示区域变化](https://q.qq.com/wiki/develop/miniprogram/frame/view/view_section_change.html)
1867
- *
1868
- * "auto" 自动
1869
- *
1870
- * "portrait" 竖屏
1871
- *
1872
- * "landscape" 横屏
1873
- *
1874
- * @default "portrait"
1875
- */
1876
- pageOrientation?: 'auto' | 'portrait' | 'landscape';
1877
- [x: string]: any;
1878
- }
1879
-
118
+ declare function findImports(stmts: t.Statement[]): t.ImportDeclaration[];
119
+ //#endregion
120
+ //#region src/context.d.ts
1880
121
  /**
1881
- * 设置编译到 mp-toutiao 平台的特定样式,配置项参考 <https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/framework/general-configuration#window>
1882
- *
1883
- * 相应的类型是 MpToutiao
122
+ * Page context class responsible for page scanning, config loading, page metadata merging and pages.json generation
1884
123
  *
1885
- * @desc 抖音小程序
124
+ * Core responsibilities:
125
+ * 1. Scan page directories and collect page files
126
+ * 2. Load user configuration files (pages.config.ts, etc.)
127
+ * 3. Parse page metadata (definePage macro)
128
+ * 4. Merge page configurations and generate pages.json
129
+ * 5. Provide virtual module and HMR support
1886
130
  */
1887
- interface MpToutiao {
1888
- /**
1889
- * 导航栏背景颜色,支持 HEX 颜色
1890
- *
1891
- * @default "#000000"
1892
- *
1893
- * @format color
1894
- */
1895
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
1896
- /**
1897
- * 导航栏标题颜色,同时影响标题颜色、右胶囊颜色、左返回箭头颜色
1898
- *
1899
- * @default "white"
1900
- */
1901
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
1902
- /**
1903
- * 导航栏标题文字内容
1904
- */
1905
- navigationBarTitleText?: string;
1906
- /**
1907
- * 导航栏样式
1908
- *
1909
- * "default" 默认样式
1910
- *
1911
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
1912
- *
1913
- * @default "default"
1914
- */
1915
- navigationStyle?: 'default' | 'custom';
1916
- /**
1917
- * 窗口的背景色,支持 HEX 颜色
1918
- *
1919
- * @default "#FFFFFF"
1920
- */
1921
- backgroundColor?: HEXColor | ThemeVar;
1922
- /**
1923
- * 下拉 loading 的样式,仅支持 "dark" / "light"
1924
- *
1925
- * @default "dark"
1926
- */
1927
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
1928
- /**
1929
- * 顶部窗口的背景色,仅 iOS 支持
1930
- *
1931
- * @default 同 backgroundColor
1932
- */
1933
- backgroundColorTop?: HEXColor | ThemeVar;
1934
- /**
1935
- * 底部窗口的背景色,仅 iOS 支持
1936
- *
1937
- * @default 同 backgroundColor
1938
- */
1939
- backgroundColorBottom?: HEXColor | ThemeVar;
1940
- /**
1941
- * 是否开启全局的下拉刷新
1942
- *
1943
- * @default false
1944
- */
1945
- enablePullDownRefresh?: boolean;
1946
- /**
1947
- * 页面上拉触底事件触发时距页面底部距离,单位为 px
1948
- *
1949
- * @default 50
1950
- */
1951
- onReachBottomDistance?: number;
1952
- /**
1953
- * 仅在 navigationStyle 为 "default" 时生效,用来控制导航栏透明设置
1954
- *
1955
- * "always" 一直透明
1956
- *
1957
- * "auto" 滑动自适应
1958
- *
1959
- * "none" 不透明
1960
- *
1961
- * @default "none"
1962
- */
1963
- transparentTitle?: 'always' | 'auto' | 'none';
1964
- /**
1965
- * 框架骨架屏配置,仅支持配置 config 属性,优先级高于 app.json,详见 [小程序框架骨架屏](https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/guide/experience-optimization/list/skeleton)
1966
- *
1967
- * @desc 2.47.0
1968
- */
1969
- skeleton?: {
1970
- /**
1971
- * 包含超时移除及自动生成配置等
1972
- */
1973
- config?: {
1974
- /**
1975
- * 设置骨架屏超时移除时间,单位为 ms,为 0 时关闭超时移除
1976
- *
1977
- * @default 2000
1978
- */
1979
- timeout?: number;
1980
- /**
1981
- * 骨架屏显示时的动画
1982
- *
1983
- * @default 'spin'
1984
- */
1985
- loading?: 'spin' | 'chiaroscuro' | 'shine';
1986
- /**
1987
- * 骨架页面中图片块配置
1988
- *
1989
- * @default { shape: 'rect', color: '#efefef' }
1990
- */
1991
- image?: {
1992
- /**
1993
- * 骨架页面中图片块形状
1994
- *
1995
- * circle 圆形
1996
- *
1997
- * rect 矩形
1998
- *
1999
- * @default "rect"
2000
- */
2001
- shape?: 'circle' | 'rect';
2002
- /**
2003
- * 骨架页面中图片块颜色,支持 HEX 颜色
2004
- *
2005
- * @default "#efefef"
2006
- *
2007
- * @format color
2008
- */
2009
- color?: HEXColor;
2010
- [x: string]: any;
2011
- };
2012
- /**
2013
- * 骨架页面中被视为按钮块的配置
2014
- *
2015
- * @default { color: '#efefef }
2016
- */
2017
- button?: {
2018
- /**
2019
- * 骨架页面中被视为按钮块的颜色,支持 HEX 颜色
2020
- *
2021
- * @default "#efefef"
2022
- *
2023
- * @format color
2024
- */
2025
- color?: HEXColor;
2026
- [x: string]: any;
2027
- };
2028
- /**
2029
- * 骨架屏背景色,支持 HEX 颜色
2030
- *
2031
- * @default "#fff"
2032
- *
2033
- * @format color
2034
- */
2035
- backgroundColor?: HEXColor;
2036
- /**
2037
- * 默认为使用绝对定位占满全屏
2038
- *
2039
- * 当对自定义组件使用,作为局部加载的样式时,可设置为 "auto",高度随内容高度撑开
2040
- *
2041
- * @default "fullscreen"
2042
- */
2043
- mode?: 'fullscreen' | 'auto';
2044
- /**
2045
- * CSS单位,元素绝对定位都使用 "vw" 与 "vh"
2046
- *
2047
- * @default "vw"
2048
- */
2049
- cssUnit?: 'px' | 'rem' | 'vw' | 'vh' | 'vmin' | 'vmax';
2050
- /**
2051
- * 生成骨架屏页面中 css 值保留的小数点位数,默认为 4
2052
- *
2053
- * @default 4
2054
- */
2055
- decimal?: number;
2056
- [x: string]: any;
2057
- };
2058
- /**
2059
- * 页面路径同骨架屏文件的对应关系
2060
- */
2061
- page?: Record<string, string>;
2062
- [x: string]: any;
2063
- };
2064
- [x: string]: any;
2065
- }
2066
-
131
+ declare class PageContext {
132
+ private _server;
133
+ /** Parsed configuration object from user config file (pages.config.ts) */
134
+ pagesGlobConfig: index_d_exports$1.PagesConfig | undefined;
135
+ /** Source path list of user configuration files */
136
+ pagesConfigSourcePaths: string[];
137
+ /** Main package page map, key is the absolute path of the page file */
138
+ pages: Map<string, Page>;
139
+ /** Sub-package page map, key is the sub-package root directory, value is the page map under that sub-package */
140
+ subPages: Map<string, Map<string, Page>>;
141
+ /** Main package page metadata array for generating pages.json pages field */
142
+ pageMetaData: PageMetaDatum[];
143
+ /** Sub-package page metadata array for generating pages.json subPackages field */
144
+ subPageMetaData: SubPageMetaDatum[];
145
+ /** Generated pages.json file path */
146
+ resolvedPagesJSONPath: string;
147
+ private resolvedPagesJSONIndent?;
148
+ private resolvedPagesJSONNewline?;
149
+ private resolvedPagesJSONEofNewline?;
150
+ /** Original options passed by the user */
151
+ rawOptions: UserOptions;
152
+ /** Project root directory */
153
+ root: string;
154
+ /** Resolved configuration options */
155
+ options: ResolvedOptions;
156
+ logger?: Logger;
157
+ /** Whether to work with vite-plugin-uni-platform plugin */
158
+ withUniPlatform: boolean;
159
+ /** Cached previous pages.json content to avoid redundant writes */
160
+ private lastPagesJson;
161
+ /**
162
+ * Create a PageContext instance
163
+ * @param userOptions - User configuration options
164
+ * @param viteRoot - Vite project root directory, defaults to current working directory
165
+ */
166
+ constructor(userOptions: UserOptions, viteRoot?: string);
167
+ /**
168
+ * Set the Vite logger
169
+ * @param logger - Vite logger instance
170
+ */
171
+ setLogger(logger: Logger): void;
172
+ /**
173
+ * Load user page configuration file (e.g. pages.config.ts)
174
+ * Uses unconfig to load configuration, supporting multiple config file formats
175
+ */
176
+ loadUserPagesConfig(): Promise<void>;
177
+ /**
178
+ * Scan main package page directories and collect all page file paths
179
+ * Scan corresponding directories based on the configured dirs option
180
+ */
181
+ scanPages(): Promise<void>;
182
+ /**
183
+ * Scan sub-package page directories and collect all sub-package page file paths
184
+ * Scan corresponding directories based on the configured subPackages option
185
+ */
186
+ scanSubPages(): Promise<void>;
187
+ /**
188
+ * Set up Vite dev server for HMR and file watching
189
+ * @param server - Vite dev server instance
190
+ */
191
+ setupViteServer(server: ViteDevServer): void;
192
+ /**
193
+ * Set up file watcher to monitor page file and config file changes
194
+ * Automatically update pages.json when page files or config files change
195
+ * @param watcher - chokidar file watcher instance
196
+ */
197
+ setupWatcher(watcher: FSWatcher): Promise<void>;
198
+ /**
199
+ * Page update callback, triggered when page files or configuration changes
200
+ * Responsible for invalidating virtual modules and notifying the browser to do a full reload
201
+ */
202
+ onUpdate(): void;
203
+ /**
204
+ * parse pages rules && set page type
205
+ * @param pages page path array
206
+ * @param type page type
207
+ * @param overrides custom page config
208
+ * @returns pages rules
209
+ */
210
+ parsePages(pages: Map<string, Page>, type: 'main' | 'sub', overrides?: PageMetaDatum[]): Promise<PageMetaDatum[]>;
211
+ /**
212
+ * set home page
213
+ * @param result pages rules array
214
+ * @returns pages rules
215
+ */
216
+ setHomePage(result: PageMetaDatum[]): PageMetaDatum[];
217
+ /**
218
+ * Merge main package page metadata
219
+ * Filter out pages belonging to sub-packages, then parse page metadata and merge user configuration
220
+ */
221
+ mergePageMetaData(): Promise<void>;
222
+ /**
223
+ * Merge sub-package page metadata
224
+ * Parse page metadata for each sub-package and handle sub-package configuration inheritance
225
+ * Preserves sub-package level properties like plugins from user config
226
+ */
227
+ mergeSubPageMetaData(): Promise<void>;
228
+ /**
229
+ * Update pages.json file
230
+ * This is the core method responsible for coordinating the entire page configuration generation flow:
231
+ * 1. Check file changes (if filepath is specified)
232
+ * 2. Load user configuration
233
+ * 3. Scan page files
234
+ * 4. Merge page metadata
235
+ * 5. Generate and write pages.json
236
+ * @param filepath - Changed file path for incremental update judgment
237
+ * @returns Whether pages.json was successfully updated
238
+ */
239
+ updatePagesJSON(filepath?: string): Promise<boolean>;
240
+ /**
241
+ * Generate virtual module content
242
+ * Returns JavaScript code containing pages and subPackages exports
243
+ * @returns Virtual module code string
244
+ */
245
+ virtualModule(): string;
246
+ /**
247
+ * Resolve main package route data to JSON string
248
+ * @returns JSON string of main package page metadata
249
+ */
250
+ resolveRoutes(): string;
251
+ /**
252
+ * Resolve sub-package route data to JSON string
253
+ * @returns JSON string of sub-package page metadata
254
+ */
255
+ resolveSubRoutes(): string;
256
+ /**
257
+ * Resolve tabBar configuration
258
+ * Merges page-defined tabBar items with config-defined tabBar
259
+ * @returns Merged tabBar configuration object, or undefined if no tabBar exists
260
+ */
261
+ resolveTabBar(): Promise<index_d_exports$1.TabBar | undefined>;
262
+ /**
263
+ * Generate TypeScript declaration file
264
+ * Generate type definitions for page paths to provide type hints during navigation
265
+ */
266
+ generateDeclaration(): Promise<void> | undefined;
267
+ private genratePagesJSON;
268
+ private readInfoFromPagesJSON;
269
+ private getIndent;
270
+ private getNewline;
271
+ private getEndOfLine;
272
+ }
273
+ //#endregion
274
+ //#region src/utils.d.ts
2067
275
  /**
2068
- * 设置编译到 mp-weixin 平台的特定样式,配置项参考 [MP-WEIXIN](https://uniapp.dcloud.net.cn/collocation/pages#mp-weixin) 和 <https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#window>
2069
- *
2070
- * 相应的类型是 MpWeixin
276
+ * Invalidate virtual module to trigger HMR update
277
+ * When page configuration changes, the virtual module needs to be invalidated to regenerate content
2071
278
  *
2072
- * @desc 微信小程序
279
+ * @param server - Vite dev server instance
2073
280
  */
2074
- interface MpWeixin {
2075
- /**
2076
- * 导航栏背景颜色,支持 HEX 颜色
2077
- *
2078
- * @default "#000000"
2079
- *
2080
- * @format color
2081
- */
2082
- navigationBarBackgroundColor?: HEXColor | ThemeVar;
2083
- /**
2084
- * 导航栏标题、状态栏颜色
2085
- *
2086
- * @default "white"
2087
- */
2088
- navigationBarTextStyle?: 'black' | 'white' | ThemeVar;
2089
- /**
2090
- * 导航栏标题文字内容
2091
- */
2092
- navigationBarTitleText?: string;
2093
- /**
2094
- * 导航栏样式
2095
- *
2096
- * "default" 默认样式
2097
- *
2098
- * "custom" 自定义导航栏,只保留右上角胶囊按钮
2099
- *
2100
- * @desc iOS / Android 微信客户端 6.6.0,Windows 微信客户端不支持
2101
- *
2102
- * @default "default"
2103
- */
2104
- navigationStyle?: 'default' | 'custom';
2105
- /**
2106
- * 在非首页、非页面栈最底层页面或非 tabbar 内页面中的导航栏展示 home 键
2107
- *
2108
- * @desc 微信客户端 8.0.24
2109
- *
2110
- * @default false
2111
- */
2112
- homeButton?: boolean;
2113
- /**
2114
- * 窗口的背景色,支持 HEX 颜色
2115
- *
2116
- * @default "#FFFFFF"
2117
- */
2118
- backgroundColor?: HEXColor | ThemeVar;
2119
- /**
2120
- * 下拉 loading 的样式,仅支持 "dark" / "light"
2121
- *
2122
- * @default "dark"
2123
- */
2124
- backgroundTextStyle?: 'dark' | 'light' | ThemeVar;
2125
- /**
2126
- * 顶部窗口的背景色,仅 iOS 支持
2127
- *
2128
- * @desc 微信客户端 6.5.16
2129
- *
2130
- * @default "#FFFFFF"
2131
- */
2132
- backgroundColorTop?: HEXColor | ThemeVar;
2133
- /**
2134
- * 底部窗口的背景色,仅 iOS 支持
2135
- *
2136
- * @desc 微信客户端 6.5.16
2137
- *
2138
- * @default "#FFFFFF"
2139
- */
2140
- backgroundColorBottom?: HEXColor | ThemeVar;
2141
- /**
2142
- * 是否开启全局的下拉刷新,详见 [Page.onPullDownRefresh](https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onpulldownrefresh)
2143
- *
2144
- * @default false
2145
- */
2146
- enablePullDownRefresh?: boolean;
2147
- /**
2148
- * 页面上拉触底事件触发时距页面底部距离,单位为 px,详见 [Page.onReachBottom](https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#onreachbottom)
2149
- *
2150
- * @default 50
2151
- */
2152
- onReachBottomDistance?: number;
2153
- /**
2154
- * 屏幕旋转设置,支持 auto / portrait / landscape,详见 [响应显示区域变化](https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html)
2155
- *
2156
- * "auto" 自动
2157
- *
2158
- * "portrait" 竖屏
2159
- *
2160
- * "landscape" 横屏
2161
- *
2162
- * @desc [2.4.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) (auto) / [2.5.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) (landscape)
2163
- *
2164
- * @default "portrait"
2165
- */
2166
- pageOrientation?: 'auto' | 'portrait' | 'landscape';
2167
- /**
2168
- * 重新启动策略配置
2169
- *
2170
- * "homePage" 如果从这个页面退出小程序,下次将从首页冷启动
2171
- *
2172
- * "homePageAndLatestPage" 如果从这个页面退出小程序,下次冷启动后立刻加载这个页面,页面的参数保持不变(不可用于 tab 页)
2173
- *
2174
- * @desc [2.8.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
2175
- */
2176
- restartStrategy?: 'homePage' | 'homePageAndLatestPage';
2177
- /**
2178
- * 页面初始渲染缓存配置,详见 [初始渲染缓存](https://developers.weixin.qq.com/miniprogram/dev/framework/view/initial-rendering-cache.html)
2179
- *
2180
- * @desc [2.11.1](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
2181
- */
2182
- initialRenderingCache?: 'static' | 'dynamic';
2183
- /**
2184
- * 切入系统后台时,隐藏页面内容,保护用户隐私
2185
- *
2186
- * @desc [2.15.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
2187
- *
2188
- * @default "none"
2189
- */
2190
- visualEffectInBackground?: 'hidden' | 'none';
2191
- /**
2192
- * 控制预加载下个页面的时机,详见 [控制预加载下个页面的时机](https://developers.weixin.qq.com/miniprogram/dev/framework/performance/tips/runtime_nav.html#_2-4-%E6%8E%A7%E5%88%B6%E9%A2%84%E5%8A%A0%E8%BD%BD%E4%B8%8B%E4%B8%AA%E9%A1%B5%E9%9D%A2%E7%9A%84%E6%97%B6%E6%9C%BA)
2193
- *
2194
- * "static" 在当前页面 onReady 触发 200ms 后触发预加载
2195
- *
2196
- * "auto" 渲染线程空闲时进行预加载,由基础库根据一段时间内 requestAnimationFrame 的触发频率算法判断
2197
- *
2198
- * "manual" 由开发者通过调用 [wx.preloadWebview](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadWebview.html) 触发,开发者可以在页面主要内容的 setData 结束后手动触发
2199
- *
2200
- * @desc [2.15.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
2201
- *
2202
- * @default "static"
2203
- */
2204
- handleWebviewPreload?: 'static' | 'manual' | 'auto';
2205
- [x: string]: any;
2206
- }
2207
-
2208
- interface GlobalStyle {
2209
- /**
2210
- * 导航栏背景颜色(同状态栏背景色),支持 HEX 颜色
2211
- *
2212
- * @desc APP 与 H5 为 #F8F8F8,小程序平台请参考相应小程序文档
2213
- *
2214
- * @format color
2215
- */
2216
- 'navigationBarBackgroundColor'?: HEXColor | ThemeVar;
2217
- /**
2218
- * 导航栏标题颜色及状态栏前景颜色,仅支持 "black" / "white"
2219
- *
2220
- * @default "black"
2221
- *
2222
- * @desc 支付宝小程序不支持,请使用 my.setNavigationBar
2223
- */
2224
- 'navigationBarTextStyle'?: 'black' | 'white' | ThemeVar;
2225
- /**
2226
- * 导航栏标题文字内容
2227
- */
2228
- 'navigationBarTitleText'?: string;
2229
- /**
2230
- * 导航栏阴影
2231
- */
2232
- 'navigationBarShadow'?: {
2233
- /**
2234
- * 阴影颜色
2235
- */
2236
- colorType?: 'grey' | 'blue' | 'green' | 'orange' | 'red' | 'yellow';
2237
- };
2238
- /**
2239
- * 导航栏样式,仅支持 "default" / "custom"
2240
- *
2241
- * "custom" 即取消默认的原生导航栏,详看 [使用注意](https://uniapp.dcloud.net.cn/collocation/pages#customnav)
2242
- *
2243
- * @default "default"
2244
- *
2245
- * @desc 微信小程序 7.0+、百度小程序、H5、App(2.0.3+)
2246
- */
2247
- 'navigationStyle'?: 'default' | 'custom';
2248
- /**
2249
- * 下拉显示出来的窗口的背景色,支持 HEX 颜色
2250
- *
2251
- * @default "#ffffff"
2252
- *
2253
- * @desc 微信小程序
2254
- *
2255
- * @format color
2256
- */
2257
- 'backgroundColor'?: HEXColor | ThemeVar;
2258
- /**
2259
- * 下拉 loading 的样式,仅支持 "dark" / "light"
2260
- *
2261
- * @default "dark"
2262
- *
2263
- * @desc 微信小程序
2264
- */
2265
- 'backgroundTextStyle'?: 'dark' | 'light' | ThemeVar;
2266
- /**
2267
- * 是否开启下拉刷新,详见 [页面生命周期](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
2268
- *
2269
- * @default false
2270
- */
2271
- 'enablePullDownRefresh'?: boolean;
2272
- /**
2273
- * 页面上拉触底事件触发时距页面底部距离,单位为 px,详见 [页面生命周期](https://uniapp.dcloud.net.cn/tutorial/page.html#lifecycle)
2274
- *
2275
- * @default 50
2276
- */
2277
- 'onReachBottomDistance'?: number;
2278
- /**
2279
- * 顶部窗口的背景色(bounce回弹区域)
2280
- *
2281
- * @default "#ffffff"
2282
- *
2283
- * @desc iOS
2284
- *
2285
- * @format color
2286
- */
2287
- 'backgroundColorTop'?: HEXColor | ThemeVar;
2288
- /**
2289
- * 底部窗口的背景色(bounce回弹区域)
2290
- *
2291
- * @default "#ffffff"
2292
- *
2293
- * @desc iOS
2294
- *
2295
- * @format color
2296
- */
2297
- 'backgroundColorBottom'?: HEXColor | ThemeVar;
2298
- /**
2299
- * 导航栏图片地址(替换当前文字标题)
2300
- *
2301
- * 支付宝小程序内必须使用 https 图片链接地址
2302
- *
2303
- * @desc 支付宝小程序、H5、APP
2304
- */
2305
- 'titleImage'?: string;
2306
- /**
2307
- * 导航栏整体(前景、背景)透明设置,仅支持 "always" / "auto" / "none
2308
- *
2309
- * "always" 一直透明
2310
- *
2311
- * "auto" 滑动自适应
2312
- *
2313
- * "none" 不透明
2314
- *
2315
- * @default "none"
2316
- *
2317
- * @desc 支付宝小程序、H5、APP
2318
- */
2319
- 'transparentTitle'?: 'always' | 'auto' | 'none';
2320
- /**
2321
- * 导航栏点击穿透
2322
- *
2323
- * @default "NO"
2324
- *
2325
- * @desc 支付宝小程序、H5
2326
- */
2327
- 'titlePenetrate'?: 'YES' | 'NO';
2328
- /**
2329
- * 横屏配置,屏幕旋转设置,仅支持 "auto" / "portrait" / "landscape",详见 [响应显示区域变化](https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html)
2330
- *
2331
- * "auto" 自动
2332
- *
2333
- * "portrait" 竖屏
2334
- *
2335
- * "landscape" 横屏
2336
- *
2337
- * @default "portrait"
2338
- *
2339
- * @desc App 2.4.7+、微信小程序、QQ小程序
2340
- */
2341
- 'pageOrientation'?: string;
2342
- /**
2343
- * 窗口显示的动画效果,详见 [窗口动画](https://uniapp.dcloud.net.cn/api/router#animation)
2344
- *
2345
- * @default "pop-in"
2346
- *
2347
- * @desc App
2348
- */
2349
- 'animationType'?: AnimationType;
2350
- /**
2351
- * 窗口显示动画的持续时间,单位为 ms
2352
- *
2353
- * @default 300
2354
- *
2355
- * @desc App
2356
- */
2357
- 'animationDuration'?: number;
2358
- /**
2359
- * 设置编译到 App 平台的特定样式,配置项参考 [app-plus](https://uniapp.dcloud.net.cn/collocation/pages#app-plus)
2360
- *
2361
- * 相应的类型是 AppPlus
2362
- *
2363
- * @desc App
2364
- */
2365
- 'app-plus'?: AppPlus;
2366
- /**
2367
- * 设置编译到 H5 平台的特定样式,配置项参考 [H5](https://uniapp.dcloud.net.cn/collocation/pages#h5)
2368
- *
2369
- * 相应的类型是 H5
2370
- *
2371
- * @desc H5
2372
- */
2373
- 'h5'?: H5;
2374
- /**
2375
- * 设置编译到 mp-alipay 平台的特定样式,配置项参考 [MP-ALIPAY](https://uniapp.dcloud.net.cn/collocation/pages#mp-alipay) 和 <https://opendocs.alipay.com/mini/framework/app-json#window>
2376
- *
2377
- * 相应的类型是 MpAlipay
2378
- *
2379
- * @desc 支付宝小程序
2380
- */
2381
- 'mp-alipay'?: MpAlipay;
2382
- /**
2383
- * 设置编译到 mp-weixin 平台的特定样式,配置项参考 [MP-WEIXIN](https://uniapp.dcloud.net.cn/collocation/pages#mp-weixin) 和 <https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#window>
2384
- *
2385
- * 相应的类型是 MpWeixin
2386
- *
2387
- * @desc 微信小程序
2388
- */
2389
- 'mp-weixin'?: MpWeixin;
2390
- /**
2391
- * 设置编译到 mp-baidu 平台的特定样式,配置项参考 [MP-BAIDU](https://uniapp.dcloud.net.cn/collocation/pages.html#mp-baidu) 和 <https://smartprogram.baidu.com/docs/develop/framework/process/#window>
2392
- *
2393
- * 相应的类型是 MpBaidu
2394
- *
2395
- * @desc 百度小程序
2396
- */
2397
- 'mp-baidu'?: MpBaidu;
2398
- /**
2399
- * 设置编译到 mp-toutiao 平台的特定样式,配置项参考 <https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/framework/general-configuration#window>
2400
- *
2401
- * 相应的类型是 MpToutiao
2402
- *
2403
- * @desc 抖音小程序
2404
- */
2405
- 'mp-toutiao'?: MpToutiao;
2406
- /**
2407
- * 设置编译到 mp-lark 平台的特定样式
2408
- *
2409
- * 相应的类型是 MpLark
2410
- *
2411
- * @desc 飞书小程序
2412
- */
2413
- 'mp-lark'?: MpLark;
2414
- /**
2415
- * 设置编译到 mp-qq 平台的特定样式
2416
- *
2417
- * 相应的类型是 MpQq
2418
- *
2419
- * @desc QQ 小程序
2420
- */
2421
- 'mp-qq'?: MpQq;
2422
- /**
2423
- * 设置编译到 mp-kuaishou 平台的特定样式
2424
- *
2425
- * 相应的类型是 MpKuaishou
2426
- *
2427
- * @desc 快手小程序
2428
- */
2429
- 'mp-kuaishou'?: MpKuaishou;
2430
- /**
2431
- * 设置编译到 mp-jd 平台的特定样式
2432
- *
2433
- * 相应的类型是 MpJd
2434
- *
2435
- * @desc 京东小程序
2436
- */
2437
- 'mp-jd'?: MpJd;
2438
- /**
2439
- * 引用小程序组件,详见 [小程序组件](https://uniapp.dcloud.net.cn/tutorial/miniprogram-subject.html#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E6%94%AF%E6%8C%81)
2440
- *
2441
- * @desc App、微信小程序、支付宝小程序、百度小程序、京东小程序
2442
- */
2443
- 'usingComponents'?: Record<string, string>;
2444
- /**
2445
- * 同层渲染,webrtc(实时音视频)无法正常时尝试配置为 "seperated" 强制关掉同层渲染
2446
- *
2447
- * @desc 微信小程序
2448
- */
2449
- 'renderingMode'?: string;
2450
- /**
2451
- * 当存在 leftWindow 时,默认是否显示 leftWindow,详见 [topWindow](https://uniapp.dcloud.net.cn/collocation/pages.html#topwindow)
2452
- *
2453
- * @default true
2454
- *
2455
- * @desc H5
2456
- */
2457
- 'leftWindow'?: boolean;
2458
- /**
2459
- * 当存在 topWindow 时,默认是否显示 topWindow,详见 [topWindow](https://uniapp.dcloud.net.cn/collocation/pages.html#topwindow)
2460
- *
2461
- * @default true
2462
- *
2463
- * @desc H5
2464
- */
2465
- 'topWindow'?: boolean;
2466
- /**
2467
- * 当存在 rightWindow 时,默认是否显示 rightWindow,详见 [topWindow](https://uniapp.dcloud.net.cn/collocation/pages.html#topwindow)
2468
- *
2469
- * @default true
2470
- *
2471
- * @desc H5
2472
- */
2473
- 'rightWindow'?: boolean;
2474
- /**
2475
- * rpx 计算所支持的最大设备宽度,单位为 px
2476
- *
2477
- * @default 960
2478
- *
2479
- * @desc App(vue2 且不含 nvue)、H5(2.8.12+)
2480
- */
2481
- 'rpxCalcMaxDeviceWidth'?: number;
2482
- /**
2483
- * rpx 计算使用的基准设备宽度,设备实际宽度超出 rpx 计算所支持的最大设备宽度时将按基准宽度计算,单位为 px
2484
- *
2485
- * @default 375
2486
- *
2487
- * @desc App(vue2 且不含 nvue)、H5(2.8.12+)
2488
- */
2489
- 'rpxCalcBaseDeviceWidth'?: number;
2490
- /**
2491
- * rpx 计算特殊处理的值,始终按实际的设备宽度计算,单位为 rpx
2492
- *
2493
- * @default 750
2494
- *
2495
- * @desc App(vue2 且不含 nvue)、H5(2.8.12+)
2496
- */
2497
- 'rpxCalcIncludeWidth'?: number;
2498
- /**
2499
- * 是否使用动态 rpx,屏幕大小变化会重新渲染 rpx
2500
- *
2501
- * @default false
2502
- *
2503
- * @desc App-nvue(vue3 固定值为 true) 3.2.13+
2504
- */
2505
- 'dynamicRpx'?: boolean;
2506
- /**
2507
- * 当浏览器可见区域宽度大于 maxWidth 时两侧留白,当小于等于 maxWidth 时页面铺满,单位为 px
2508
- *
2509
- * 不同页面支持配置不同的 maxWidth
2510
- *
2511
- * maxWidth = leftWindow(可选)+ page(页面主体)+ rightWindow(可选)
2512
- *
2513
- * 使用时,页面内 fixed 元素需要使用 --window-left 和 --window-right 来保证布局位置正确
2514
- *
2515
- * @desc H5(2.9.9+)
2516
- */
2517
- 'maxWidth'?: number;
2518
- [x: string]: any;
2519
- }
2520
-
2521
- interface SubPackage {
2522
- /**
2523
- * 子包的根目录
2524
- */
2525
- root: string;
2526
- /**
2527
- * 子包由哪些页面组成,参数同 pages
2528
- */
2529
- pages: PageMetaDatum[];
2530
- /**
2531
- * 分包插件
2532
- */
2533
- plugins?: {
2534
- [pluginName: string]: {
2535
- version: string;
2536
- provider: string;
2537
- export?: string;
2538
- [key: string]: any;
2539
- };
2540
- };
2541
- }
2542
- type SubPackages = SubPackage[];
2543
-
2544
- interface TabBarIconFont {
2545
- /**
2546
- * 字库 Unicode 码
2547
- */
2548
- text?: string;
2549
- /**
2550
- * 选中后字库 Unicode 码
2551
- */
2552
- selectedText?: string;
2553
- /**
2554
- * 字体图标字号,单位为 px
2555
- */
2556
- fontSize?: string;
2557
- /**
2558
- * 字体图标颜色
2559
- */
2560
- color?: HEXColor;
2561
- /**
2562
- * 字体图标选中颜色
2563
- */
2564
- selectedColor?: HEXColor;
2565
- [x: string]: any;
2566
- }
2567
- interface TabBarItem {
2568
- /**
2569
- * 页面路径,必须在 pages 中先定义
2570
- */
2571
- pagePath: string;
2572
- /**
2573
- * tab 上按钮文字,在 App 和 H5 平台为非必填,例如中间可放一个没有文字的 + 号图标
2574
- */
2575
- text?: string;
2576
- /**
2577
- * 图片路径,icon 大小限制为 40 kb,建议尺寸为 81px * 81px
2578
- *
2579
- * 当 position 为 "top" 时,此参数无效
2580
- *
2581
- * 不支持网络图片,不支持字体图标
2582
- */
2583
- iconPath?: string | ThemeVar;
2584
- /**
2585
- * 选中时的图片路径,icon 大小限制为 40 kb,建议尺寸为 81px * 81px
2586
- *
2587
- * 当 position 为 "top" 时,此参数无效
2588
- *
2589
- * 不支持网络图片,不支持字体图标
2590
- */
2591
- selectedIconPath?: string | ThemeVar;
2592
- /**
2593
- * 该项是否显示,默认显示
2594
- *
2595
- * @desc App (3.2.10+)、H5 (3.2.10+)
2596
- */
2597
- visible?: boolean;
2598
- /**
2599
- * 字体图标,优先级高于 iconPath
2600
- *
2601
- * @desc App(3.4.4+)、H5 (3.5.3+)
2602
- */
2603
- iconfont?: TabBarIconFont;
2604
- [x: string]: any;
2605
- }
2606
- interface TabBarMidButton {
2607
- /**
2608
- * 中间按钮的宽度,tabBar 其它项为减去此宽度后平分,默认值为与其它项平分宽度
2609
- *
2610
- * @default "80px"
2611
- */
2612
- width?: string;
2613
- /**
2614
- * 中间按钮的高度,可以大于 tabBar 高度,达到中间凸起的效果
2615
- *
2616
- * @default "50px"
2617
- */
2618
- height?: string;
2619
- /**
2620
- * 中间按钮的文字
2621
- */
2622
- text?: string;
2623
- /**
2624
- * 中间按钮的图片路径
2625
- */
2626
- iconPath?: string;
2627
- /**
2628
- * 图片宽度(高度等比例缩放)
2629
- *
2630
- * @default "24px"
2631
- */
2632
- iconWidth?: string;
2633
- /**
2634
- * 中间按钮的背景图片路径
2635
- */
2636
- backgroundImage?: string;
2637
- /**
2638
- * 字体图标,优先级高于 iconPath
2639
- *
2640
- * @desc App (3.4.4+)
2641
- */
2642
- iconfont?: TabBarIconFont;
2643
- [x: string]: any;
2644
- }
2645
- interface TabBar {
2646
- /**
2647
- * tab 上的文字默认颜色
2648
- *
2649
- * @format color
2650
- */
2651
- color?: HEXColor | ThemeVar;
2652
- /**
2653
- * tab 上的文字选中时的颜色
2654
- *
2655
- * @format color
2656
- */
2657
- selectedColor?: HEXColor | ThemeVar;
2658
- /**
2659
- * tab 的背景色
2660
- *
2661
- * @format color
2662
- */
2663
- backgroundColor?: HEXColor | ThemeVar;
2664
- /**
2665
- * tabBar 上边框的颜色
2666
- *
2667
- * @default "black"
2668
- *
2669
- * @desc App 2.3.4+、H5 3.0.0+
2670
- *
2671
- * @format color
2672
- */
2673
- borderStyle?: 'black' | 'white' | HEXColor | ThemeVar;
2674
- /**
2675
- * iOS 高斯模糊效果,参考 [使用说明](https://ask.dcloud.net.cn/article/36617)
2676
- *
2677
- * @default "none"
2678
- *
2679
- * @desc App 2.4.0+、H5 3.0.0+(只有最新版浏览器才支持)
2680
- */
2681
- blurEffect?: 'dark' | 'extralight' | 'light' | 'none';
2682
- /**
2683
- * tab 列表,最少 2个,最多 5 个,app 端没有该限制
2684
- *
2685
- * @type {TabBarItem[]}
2686
- */
2687
- list?: TabBarItem[];
2688
- /**
2689
- * tab 位置
2690
- *
2691
- * @default "bottom"
2692
- *
2693
- * @desc "top" 仅微信小程序支持
2694
- */
2695
- position?: 'bottom' | 'top';
2696
- /**
2697
- * 文字默认大小
2698
- *
2699
- * @default "10px"
2700
- *
2701
- * @desc App 2.3.4+、H5 3.0.0+
2702
- */
2703
- fontSize?: string;
2704
- /**
2705
- * 图标默认宽度(高度等比例缩放)
2706
- *
2707
- * @default "24px"
2708
- *
2709
- * @desc App 2.3.4+、H5 3.0.0+
2710
- */
2711
- iconWidth?: string;
2712
- /**
2713
- * 图标和文字的间距
2714
- *
2715
- * @default "3px"
2716
- *
2717
- * @desc App 2.3.4+、H5 3.0.0+
2718
- */
2719
- spacing?: string;
2720
- /**
2721
- * tabBar 默认高度
2722
- *
2723
- * @default "50px"
2724
- *
2725
- * @desc App 2.3.4+、H5 3.0.0+
2726
- */
2727
- height?: string;
2728
- /**
2729
- * 中间按钮 仅在 list 项为偶数时有效
2730
- *
2731
- * @desc App 2.3.4+、H5 3.0.0+
2732
- */
2733
- midButton?: TabBarMidButton;
2734
- /**
2735
- * list 设置 iconfont 属性时,需要指定字体文件路径
2736
- *
2737
- * @desc App 3.4.4+、H5 3.5.3+
2738
- */
2739
- iconfontSrc?: string;
2740
- /**
2741
- * 设置背景图片,优先级高于 backgroundColor
2742
- */
2743
- backgroundImage?: string;
2744
- /**
2745
- * 设置标题栏的背景图平铺方式
2746
- *
2747
- * "repeat" 背景图片在垂直方向和水平方向平铺
2748
- *
2749
- * "repeat-x" 背景图片在水平方向平铺,垂直方向拉伸
2750
- *
2751
- * "repeat-y" 背景图片在垂直方向平铺,水平方向拉伸
2752
- *
2753
- * "no-repeat" 背景图片在垂直方向和水平方向都拉伸
2754
- *
2755
- * @default "no-repeat"
2756
- */
2757
- backgroundRepeat?: 'no-repeat' | 'repeat' | 'repeat-x' | 'repeat-y';
2758
- /**
2759
- * tabBar上红点颜色
2760
- *
2761
- * @format color
2762
- */
2763
- redDotColor?: string;
2764
- [x: string]: any;
2765
- }
2766
-
2767
- interface TheWindow {
2768
- /**
2769
- * 配置页面路径
2770
- */
2771
- path: string;
2772
- /**
2773
- * 配置页面窗口表现,配置项参考 [pageStyle](https://uniapp.dcloud.net.cn/collocation/pages#style)
2774
- */
2775
- style?: GlobalStyle;
2776
- /**
2777
- * 配置显示该窗口的规则,配置项参考 [matchMedia](https://uniapp.dcloud.net.cn/collocation/pages#matchmedia)
2778
- */
2779
- matchMedia?: {
2780
- /**
2781
- * 当设备可见区域宽度 >= minWidth 时,显示该 window
2782
- *
2783
- * @default 768
2784
- */
2785
- minWidth?: number;
2786
- };
2787
- }
2788
-
2789
- interface UniIdRouter {
2790
- /**
2791
- * 登录页面路径
2792
- *
2793
- * @example "pages/index/index"
2794
- */
2795
- loginPage: string;
2796
- /**
2797
- * 需要登录才可以访问的页面列表,可以使用正则语法
2798
- *
2799
- * @example ["pages/detail/.*"]
2800
- */
2801
- needLogin: string[];
2802
- /**
2803
- * 是否是否自动解析云对象及 clientDB 的错误码,如果是客户端 token 不正确或 token 过期则自动跳转配置的登录页面
2804
- *
2805
- * @default true
2806
- */
2807
- resToLogin?: boolean;
2808
- }
2809
-
281
+ declare function invalidatePagesModule(server: ViteDevServer): void;
2810
282
  /**
2811
- * 对 uni-app 进行全局配置,决定页面文件的路径、窗口样式、原生的导航栏、底部的原生 tabBar 等,类似微信小程序中 app.json 的页面管理部分
2812
- *
2813
- * 注意定位权限申请等原属于 app.json 的内容,需要在 manifest 中配置
283
+ * Debug logging utility
284
+ * Uses debug package for leveled log output
285
+ * Enable via environment variable DEBUG=vite-plugin-uni-pages:*
2814
286
  */
2815
- interface PagesConfig {
2816
- /**
2817
- * 设置默认页面的窗口表现
2818
- */
2819
- globalStyle?: GlobalStyle;
2820
- /**
2821
- * 设置页面路径及窗口表现
2822
- */
2823
- pages?: PageMetaDatum[];
2824
- /**
2825
- * 组件自动引入规则
2826
- *
2827
- * @desc 2.5.5+
2828
- */
2829
- easycom?: EasyCom;
2830
- /**
2831
- * 设置底部 tab 的表现
2832
- */
2833
- tabBar?: TabBar;
2834
- /**
2835
- * 启动模式配置,仅开发期间生效
2836
- */
2837
- condition?: Condition;
2838
- /**
2839
- * 分包加载配置
2840
- *
2841
- * @desc H5 不支持
2842
- */
2843
- subPackages?: SubPackages;
2844
- /**
2845
- * 分包预下载规则
2846
- *
2847
- * @desc 微信小程序
2848
- */
2849
- preloadRule?: {
2850
- /**
2851
- * 页面路径
2852
- */
2853
- [path: string]: {
2854
- /**
2855
- * 进入页面后预下载分包的 root 或 name
2856
- *
2857
- * __APP__ 表示主包
2858
- */
2859
- packages: string[];
2860
- /**
2861
- * 在指定网络下预下载
2862
- *
2863
- * "all" 不限网络
2864
- *
2865
- * "wifi" 仅 wifi 下预下载
2866
- *
2867
- * @default "wifi"
2868
- */
2869
- network?: 'all' | 'wifi';
2870
- };
2871
- };
2872
- /**
2873
- * `Worker` 代码放置的目录
2874
- *
2875
- * @desc 微信小程序
2876
- */
2877
- workers?: string | {
2878
- /**
2879
- * `Worker` 代码放置的目录
2880
- */
2881
- path: string;
2882
- /**
2883
- * 是否打包为分包
2884
- *
2885
- * @desc 微信小程序基础库 v2.27.3
2886
- *
2887
- * @default false
2888
- */
2889
- isSubpackage?: boolean;
2890
- };
2891
- /**
2892
- * 大屏左侧窗口
2893
- *
2894
- * @desc H5
2895
- */
2896
- leftWindow?: TheWindow;
2897
- /**
2898
- * 大屏顶部窗口
2899
- *
2900
- * @desc H5
2901
- */
2902
- topWindow?: TheWindow;
2903
- /**
2904
- * 大屏右侧窗口
2905
- *
2906
- * @desc H5
2907
- */
2908
- rightWindow?: TheWindow;
2909
- /**
2910
- * 自动跳转相关配置,新增于 HBuilderX 3.5.0
2911
- *
2912
- * @desc uni-app 3.5.0+、uni-app-x 3.99+
2913
- */
2914
- uniIdRouter?: UniIdRouter;
2915
- /**
2916
- * 默认启动首页,新增于 HBuilderX 3.7.0
2917
- *
2918
- * @desc 微信小程序、支付宝小程序
2919
- */
2920
- entryPagePath?: string;
2921
- [x: string]: any;
2922
- }
2923
- interface UserPagesConfig extends PagesConfig {
2924
- }
2925
-
2926
- declare function defineUniPages(config: UserPagesConfig): UserPagesConfig;
2927
-
2928
- declare class Page {
2929
- ctx: PageContext;
2930
- path: PagePath;
2931
- uri: string;
2932
- changed: boolean;
2933
- private raw;
2934
- private meta;
2935
- constructor(ctx: PageContext, path: PagePath);
2936
- getPageMeta(forceUpdate?: boolean): Promise<PageMetaDatum>;
2937
- getTabBar(forceUpdate?: boolean): Promise<TabBarItem & {
2938
- index: number;
2939
- } | undefined>;
2940
- hasChanged(): boolean;
2941
- read(): Promise<void>;
2942
- private readPageMetaFromFile;
2943
- }
2944
- declare function parseSFC(code: string, options?: SFCParseOptions): SFCDescriptor;
2945
- declare function tryPageMetaFromMacro(sfc: SFCDescriptor): Promise<UserPageMeta | undefined>;
2946
- declare function tryPageMetaFromCustomBlock(sfc: SFCDescriptor, routeBlockLang: RouteBlockLang): Promise<UserPageMeta>;
2947
- declare function findMacro(stmts: t.Statement[], filename: string): t.CallExpression | undefined;
2948
- declare function findImports(stmts: t.Statement[]): t.ImportDeclaration[];
2949
-
2950
- declare class PageContext {
2951
- private _server;
2952
- pagesGlobConfig: PagesConfig | undefined;
2953
- pagesConfigSourcePaths: string[];
2954
- pages: Map<string, Page>;
2955
- subPages: Map<string, Map<string, Page>>;
2956
- pageMetaData: PageMetaDatum[];
2957
- subPageMetaData: SubPageMetaDatum[];
2958
- resolvedPagesJSONPath: string;
2959
- private resolvedPagesJSONIndent?;
2960
- private resolvedPagesJSONNewline?;
2961
- private resolvedPagesJSONEofNewline?;
2962
- rawOptions: UserOptions;
2963
- root: string;
2964
- options: ResolvedOptions;
2965
- logger?: Logger;
2966
- withUniPlatform: boolean;
2967
- private lastPagesJson;
2968
- constructor(userOptions: UserOptions, viteRoot?: string);
2969
- setLogger(logger: Logger): void;
2970
- loadUserPagesConfig(): Promise<void>;
2971
- scanPages(): Promise<void>;
2972
- scanSubPages(): Promise<void>;
2973
- setupViteServer(server: ViteDevServer): void;
2974
- setupWatcher(watcher: FSWatcher): Promise<void>;
2975
- onUpdate(): void;
2976
- /**
2977
- * parse pages rules && set page type
2978
- * @param pages page path array
2979
- * @param type page type
2980
- * @param overrides custom page config
2981
- * @returns pages rules
2982
- */
2983
- parsePages(pages: Map<string, Page>, type: 'main' | 'sub', overrides?: PageMetaDatum[]): Promise<PageMetaDatum[]>;
2984
- /**
2985
- * set home page
2986
- * @param result pages rules array
2987
- * @returns pages rules
2988
- */
2989
- setHomePage(result: PageMetaDatum[]): PageMetaDatum[];
2990
- mergePageMetaData(): Promise<void>;
2991
- mergeSubPageMetaData(): Promise<void>;
2992
- private getTabBarMerged;
2993
- updatePagesJSON(filepath?: string): Promise<boolean>;
2994
- virtualModule(): string;
2995
- resolveRoutes(): string;
2996
- resolveSubRoutes(): string;
2997
- generateDeclaration(): Promise<void> | undefined;
2998
- private genratePagesJSON;
2999
- private readInfoFromPagesJSON;
3000
- private getIndent;
3001
- private getNewline;
3002
- private getEndOfLine;
3003
- }
3004
-
3005
- declare function invalidatePagesModule(server: ViteDevServer): void;
3006
287
  declare const debug: {
3007
- hmr: Debug.Debugger;
3008
- routeBlock: Debug.Debugger;
3009
- options: Debug.Debugger;
3010
- pages: Debug.Debugger;
3011
- subPages: Debug.Debugger;
3012
- error: Debug.Debugger;
3013
- cache: Debug.Debugger;
3014
- declaration: Debug.Debugger;
3015
- definePage: Debug.Debugger;
288
+ /** HMR related logs */hmr: Debug.Debugger; /** Configuration options related logs */
289
+ options: Debug.Debugger; /** Main package page scanning logs */
290
+ pages: Debug.Debugger; /** Sub-package page scanning logs */
291
+ subPages: Debug.Debugger; /** Error logs */
292
+ error: Debug.Debugger; /** Cache related logs */
293
+ cache: Debug.Debugger; /** Declaration file generation logs */
294
+ declaration: Debug.Debugger; /** definePage macro parsing logs */
295
+ definePage: Debug.Debugger;
3016
296
  };
297
+ /**
298
+ * Convert file extensions array to glob pattern
299
+ * @param extensions - File extensions array
300
+ * @returns Glob pattern string
301
+ */
3017
302
  declare function extsToGlob(extensions: string[]): string;
303
+ /**
304
+ * Check if file is a target page file
305
+ * Determine if the file extension is in the supported page file types list
306
+ *
307
+ * @param path - File path
308
+ * @returns Whether it's a target file
309
+ */
3018
310
  declare function isTargetFile(path: string): boolean;
3019
311
  /**
3020
312
  * merge page meta data array by path and assign style
@@ -3023,198 +315,237 @@ declare function isTargetFile(path: string): boolean;
3023
315
  */
3024
316
  declare function mergePageMetaDataArray(pageMetaData: PageMetaDatum[]): PageMetaDatum[];
3025
317
  /**
3026
- * 将 TypeScript / JavaScript 脚本代码,转换为对象/函数
318
+ * Convert TypeScript / JavaScript script code to object/function
3027
319
  *
3028
- * @param options - 执行脚本所需的配置项
3029
- * @param options.imports - 需要引入的模块导入语句列表
3030
- * @param options.code - 实际要执行的 TypeScript 代码内容
3031
- * @param options.filename - 脚本文件名,用于错误定位和上下文环境
3032
- * @returns 返回脚本执行后的结果,若导出的是函数则执行后返回其返回值
320
+ * @param options - Configuration required for script execution
321
+ * @param options.imports - List of module import statements to include
322
+ * @param options.code - TypeScript code content to execute
323
+ * @param options.filename - Script filename for error location and context
324
+ * @returns Script execution result, if export is a function then execute and return its return value
3033
325
  */
3034
326
  declare function parseCode(options: {
3035
- imports: string[];
3036
- code: string;
3037
- filename: string;
327
+ imports: string[];
328
+ code: string;
329
+ filename: string;
3038
330
  }): Promise<any>;
331
+ /**
332
+ * Async sleep function
333
+ * @param ms - Sleep duration in milliseconds
334
+ * @returns Promise object
335
+ */
3039
336
  declare function sleep(ms: number): Promise<unknown>;
337
+ /** Babel code generator for converting AST back to code */
3040
338
  declare const babelGenerate: typeof babelGenerator;
3041
-
3042
- interface CustomBlock {
3043
- attr: Record<string, any>;
3044
- content: Record<string, any> | CommentJSONValue;
3045
- }
339
+ declare function stripType<T extends Record<string, unknown>>(item: T): Omit<T, 'type'>;
340
+ //#endregion
341
+ //#region src/types.d.ts
342
+ /** Debug log type, corresponding to methods in the debug object */
3046
343
  type debugType = keyof typeof debug;
3047
- type ConfigSource = string | LoadConfigSource<PagesConfig> | LoadConfigSource<PagesConfig>[];
3048
- type RouteBlockLang = 'json5' | 'jsonc' | 'json' | 'yaml' | 'yml';
344
+ /** Configuration source type, supports string path or unconfig LoadConfigSource object */
345
+ type ConfigSource = string | LoadConfigSource<index_d_exports$1.PagesConfig> | LoadConfigSource<index_d_exports$1.PagesConfig>[];
346
+ /**
347
+ * Plugin configuration options interface
348
+ * Defines all configuration options that users can pass in
349
+ */
3049
350
  interface Options {
3050
- /**
3051
- * Generate TypeScript declaration for pages path
3052
- *
3053
- * Accept boolean or a path related to project root
3054
- *
3055
- * @default true
3056
- */
3057
- dts?: boolean | string;
3058
- /**
3059
- * Load from configs files
3060
- *
3061
- * @default 'pages.config.(ts|mts|cts|js|cjs|mjs|json)',
3062
- */
3063
- configSource: ConfigSource;
3064
- /**
3065
- * The default application entry page is the home page
3066
- * @default 'pages/index' or 'pages/index/index'
3067
- */
3068
- homePage: string;
3069
- /**
3070
- * Whether to merge pages in pages.json
3071
- * @default true
3072
- */
3073
- mergePages: boolean;
3074
- /**
3075
- * Paths to the directory to search for page components.
3076
- * @default 'src/pages'
3077
- */
3078
- dir: string;
3079
- /**
3080
- * all root directories loaded by subPackages
3081
- * @default []
3082
- */
3083
- subPackages: string[];
3084
- /**
3085
- * pages.json dir
3086
- * @default "src"
3087
- */
3088
- outDir: string;
3089
- /**
3090
- * exclude page
3091
- * @default []
3092
- */
3093
- exclude: string[];
3094
- /**
3095
- * Set the default route block parser, or use `<route lang="xxx">` in SFC route block
3096
- * @default 'json5'
3097
- */
3098
- routeBlockLang: RouteBlockLang;
3099
- /**
3100
- * minify the `pages.json`
3101
- * @default false
3102
- */
3103
- minify: boolean;
3104
- /**
3105
- * enable debug log
3106
- */
3107
- debug: boolean | debugType;
3108
- onBeforeLoadUserConfig: (ctx: PageContext) => void;
3109
- onAfterLoadUserConfig: (ctx: PageContext) => void;
3110
- onBeforeScanPages: (ctx: PageContext) => void;
3111
- onAfterScanPages: (ctx: PageContext) => void;
3112
- onBeforeMergePageMetaData: (ctx: PageContext) => void;
3113
- onAfterMergePageMetaData: (ctx: PageContext) => void;
3114
- onBeforeWriteFile: (ctx: PageContext) => void;
3115
- onAfterWriteFile: (ctx: PageContext) => void;
3116
- }
351
+ /**
352
+ * Generate TypeScript declaration for pages path
353
+ *
354
+ * Accept boolean or a path related to project root
355
+ *
356
+ * @default true
357
+ */
358
+ dts?: boolean | string;
359
+ /**
360
+ * Load from configs files
361
+ *
362
+ * @default 'pages.config.(ts|mts|cts|js|cjs|mjs|json)',
363
+ */
364
+ configSource: ConfigSource;
365
+ /**
366
+ * The default application entry page is the home page
367
+ * @default 'pages/index' or 'pages/index/index'
368
+ */
369
+ homePage: string;
370
+ /**
371
+ * Whether to merge pages in pages.json
372
+ * @default true
373
+ */
374
+ mergePages: boolean;
375
+ /**
376
+ * Paths to the directory to search for page components.
377
+ * @default 'src/pages'
378
+ */
379
+ dir: string;
380
+ /**
381
+ * Sub-package page directories for uni-app sub-package loading
382
+ *
383
+ * Supports string format (directory path) or object format (custom root in pages.json)
384
+ *
385
+ * In monorepo projects, pages may be located outside the project root.
386
+ * Use object format to specify a custom root that appears in pages.json,
387
+ * avoiding '..' in the generated root path.
388
+ *
389
+ * @see https://github.com/uni-helper/vite-plugin-uni-pages/issues/271
390
+ * @default []
391
+ */
392
+ subPackages: (string | SubPackageConfig)[];
393
+ /**
394
+ * pages.json dir
395
+ * @default "src"
396
+ */
397
+ outDir: string;
398
+ /**
399
+ * pages to be excluded, based on [tinyglobby ignore option](https://superchupu.dev/tinyglobby/documentation#ignore)
400
+ * @default []
401
+ */
402
+ exclude: string[];
403
+ /**
404
+ * minify the `pages.json`
405
+ * @default false
406
+ */
407
+ minify: boolean;
408
+ /**
409
+ * enable debug log
410
+ */
411
+ debug: boolean | debugType;
412
+ onBeforeLoadUserConfig: (ctx: PageContext) => void;
413
+ onAfterLoadUserConfig: (ctx: PageContext) => void;
414
+ onBeforeScanPages: (ctx: PageContext) => void;
415
+ onAfterScanPages: (ctx: PageContext) => void;
416
+ onBeforeMergePageMetaData: (ctx: PageContext) => void;
417
+ onAfterMergePageMetaData: (ctx: PageContext) => void;
418
+ onBeforeWriteFile: (ctx: PageContext) => void;
419
+ onAfterWriteFile: (ctx: PageContext) => void;
420
+ }
421
+ /** User configuration options type, all options are optional */
3117
422
  type UserOptions = Partial<Options>;
3118
- interface ResolvedOptions extends Omit<Options, 'dir' | 'homePage' | 'configSource' | 'dts'> {
3119
- /**
3120
- * Resolves to the `root` value from Vite config.
3121
- * @default config.root
3122
- */
3123
- root: string;
3124
- dts: string | false;
3125
- /**
3126
- * Resolved page dirs
3127
- */
3128
- dirs: string[];
3129
- /**
3130
- * Resolved entry page
3131
- */
3132
- homePage: string[];
3133
- configSource: LoadConfigSource<PagesConfig>[];
3134
- }
3135
- interface PagePath {
3136
- relativePath: string;
3137
- absolutePath: string;
3138
- }
3139
- interface PageMetaDatum {
3140
- /**
3141
- * 配置页面路径
3142
- */
3143
- path: string;
3144
- type?: string;
3145
- /**
3146
- * 配置页面窗口表现,配置项参考下方 pageStyle
3147
- */
3148
- style?: GlobalStyle;
3149
- /**
3150
- * 当前页面是否需要登录才可以访问,此配置优先级高于 uniIdRouter 下的 needLogin
3151
- */
3152
- needLogin?: boolean;
3153
- [x: string]: any;
3154
- }
3155
- type ExcludeIndexSignature<T> = {
3156
- [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
3157
- };
3158
- interface SubPageMetaDatum {
3159
- root: string;
3160
- pages: PageMetaDatum[];
3161
- }
3162
- interface UserTabBarItem extends Partial<TabBarItem> {
3163
- /**
3164
- * 配置页面路径
3165
- * @deprecated 可选,将会根据文件路径自动生成
3166
- */
3167
- pagePath?: string;
3168
- /**
3169
- * 排序,数字越小越靠前
3170
- */
3171
- index?: number;
423
+ /**
424
+ * Resolved configuration options interface
425
+ * Configuration processed by resolveOptions, all paths resolved to absolute paths
426
+ */
427
+ interface ResolvedOptions extends Omit<Options, 'dir' | 'homePage' | 'configSource' | 'dts' | 'subPackages'> {
428
+ /**
429
+ * Resolves to the `root` value from Vite config.
430
+ * @default config.root
431
+ */
432
+ root: string;
433
+ dts: string | false;
434
+ /**
435
+ * Resolved page dirs
436
+ */
437
+ dirs: string[];
438
+ /**
439
+ * Resolved entry page
440
+ */
441
+ homePage: string[];
442
+ configSource: LoadConfigSource<index_d_exports$1.PagesConfig>[];
443
+ /**
444
+ * Resolved sub-package directories
445
+ */
446
+ subPackages: string[];
447
+ /**
448
+ * Custom root mapping for sub-packages (dir -> root)
449
+ * Used for monorepo support to specify custom root paths in pages.json
450
+ */
451
+ subPackageRootMap: Map<string, string>;
3172
452
  }
3173
- interface UserPageMeta extends Partial<PageMetaDatum> {
3174
- /**
3175
- * 配置页面路径
3176
- * @deprecated 可选,将会根据文件路径自动生成
3177
- */
3178
- path?: string;
3179
- /**
3180
- * 底部 tabBar 的子项 [tabBar](https://uniapp.dcloud.net.cn/collocation/pages#tabBar)
3181
- */
3182
- tabBar?: UserTabBarItem;
453
+ /**
454
+ * Sub-package configuration interface
455
+ * Allows customizing the root path in pages.json for monorepo support
456
+ *
457
+ * In monorepo projects, pages may be located outside the project root (e.g., ../../packages/login/src/pages).
458
+ * By default, the plugin generates root paths with '..', which uni-app does not support.
459
+ * Use this config to specify a custom root that appears in pages.json instead.
460
+ *
461
+ * @example
462
+ * ```ts
463
+ * subPackages: [
464
+ * {
465
+ * dir: '../../packages/login/src/pages', // Physical directory to scan
466
+ * root: 'packages/login/src/pages', // Custom root in pages.json
467
+ * }
468
+ * ]
469
+ * ```
470
+ */
471
+ interface SubPackageConfig {
472
+ /** Physical directory path to scan for page files */
473
+ dir: string;
474
+ /** Custom root path that appears in pages.json subPackages.root */
475
+ root: string;
3183
476
  }
3184
- type MaybePromise<T> = T | Promise<T>;
3185
- type MaybeCallable<T> = T | (() => T);
3186
- type MaybePromiseCallable<T> = T | (() => T) | (() => Promise<T>);
3187
- declare function definePage(options: MaybePromiseCallable<UserPageMeta>): void;
3188
- type DefinePage = typeof definePage;
3189
-
477
+ /**
478
+ * Page path information interface
479
+ * Contains relative and absolute paths of page files
480
+ */
481
+ interface PagePath {
482
+ /** Path relative to the output directory */
483
+ relativePath: string;
484
+ /** Absolute path of the page file */
485
+ absolutePath: string;
486
+ }
487
+ //#endregion
488
+ //#region src/constant.d.ts
489
+ /** Virtual module identifier for Vite module resolution */
3190
490
  declare const MODULE_ID_VIRTUAL = "virtual:uni-pages";
491
+ /** Resolved virtual module identifier with \0 prefix to avoid conflicts with other modules */
3191
492
  declare const RESOLVED_MODULE_ID_VIRTUAL = "\0virtual:uni-pages";
493
+ /** Output filename, the uni-app page configuration file */
3192
494
  declare const OUTPUT_NAME = "pages.json";
495
+ /** Supported page file extensions */
3193
496
  declare const FILE_EXTENSIONS: string[];
3194
-
3195
- declare function parseCustomBlock(block: SFCBlock, filePath: string, routeBlockLang: RouteBlockLang): CustomBlock | undefined;
3196
- declare function getRouteSfcBlock(sfc?: SFCDescriptor): SFCBlock | undefined;
3197
- declare function getRouteBlock(path: string, blockStr: SFCBlock | undefined, routeBlockLang: RouteBlockLang): CustomBlock | undefined;
3198
-
497
+ //#endregion
498
+ //#region src/files.d.ts
3199
499
  /**
3200
500
  * Resolves the files that are valid pages for the given context.
3201
501
  */
3202
502
  declare function getPageFiles(path: string, options: ResolvedOptions): string[];
3203
503
  /**
3204
- * 检查指定路径的 pages.json 文件,如果文件不存在或不是有效文件则创建一个空的 pages.json 文件
3205
- * @param path - 要检查的文件路径
3206
- * @returns boolean - 返回操作是否成功
504
+ * Check the pages.json file at the specified path, create an empty pages.json file if it doesn't exist or is not a valid file
505
+ * @param path - File path to check
506
+ * @returns boolean - Whether the operation was successful
3207
507
  */
3208
508
  declare function checkPagesJsonFileSync(path: fs.PathLike): boolean;
509
+ /**
510
+ * Safely write file using file lock
511
+ * Avoid data corruption caused by concurrent writes through file lock
512
+ * Use atomic write to ensure file write integrity
513
+ *
514
+ * @param path - File path
515
+ * @param content - File content
516
+ * @param retry - Number of retries when lock acquisition fails, defaults to 3
517
+ */
3209
518
  declare function writeFileWithLock(path: string, content: string, retry?: number): Promise<void>;
3210
-
519
+ //#endregion
520
+ //#region src/options.d.ts
521
+ /**
522
+ * Resolve user configuration options
523
+ * Merge user-provided configuration with default values and handle path resolution
524
+ *
525
+ * @param userOptions - User configuration options
526
+ * @param viteRoot - Vite project root directory
527
+ * @returns Resolved configuration options
528
+ */
3211
529
  declare function resolveOptions(userOptions: UserOptions, viteRoot?: string): ResolvedOptions;
3212
530
  /**
3213
531
  * Resolves the page dirs for its for its given globs
3214
532
  */
3215
533
  declare function resolvePageDirs(dir: string, root: string, exclude: string[]): string[];
3216
-
534
+ declare namespace index_d_exports {
535
+ export { ConfigSource, DefinePage, ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, MaybeCallable, MaybePromise, MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, SubPageMetaDatum, UserOptions, UserPageMeta, UserTabBarItem, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, debugType, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, stripType, tryPageMetaFromMacro, writeFileWithLock };
536
+ }
537
+ /**
538
+ * vite-plugin-uni-pages plugin main entry
539
+ *
540
+ * Automatically scan page directories and generate pages.json configuration file
541
+ * Support definePage macro for defining page metadata
542
+ * Support multi-platform conditional compilation
543
+ * Support sub-package configuration
544
+ * Support TypeScript declaration file generation
545
+ *
546
+ * @param userOptions - User configuration options
547
+ * @returns Vite plugin instance
548
+ */
3217
549
  declare function VitePluginUniPages(userOptions?: UserOptions): Plugin;
3218
-
3219
- export { FILE_EXTENSIONS, MODULE_ID_VIRTUAL, OUTPUT_NAME, Page, PageContext, RESOLVED_MODULE_ID_VIRTUAL, VitePluginUniPages, babelGenerate, checkPagesJsonFileSync, debug, VitePluginUniPages as default, definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, getRouteBlock, getRouteSfcBlock, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseCustomBlock, parseSFC, resolveOptions, resolvePageDirs, sleep, tryPageMetaFromCustomBlock, tryPageMetaFromMacro, writeFileWithLock };
3220
- export type { Condition, ConditionItem, ConfigSource, CustomBlock, DefinePage, EasyCom, ExcludeIndexSignature, GlobalStyle, MaybeCallable, MaybePromise, MaybePromiseCallable, Options, PageMetaDatum, PagePath, PagesConfig, ResolvedOptions, RouteBlockLang, SubPackage, SubPackages, SubPageMetaDatum, TabBar, TabBarIconFont, TabBarItem, TabBarMidButton, TheWindow, UniIdRouter, UserOptions, UserPageMeta, UserPagesConfig, UserTabBarItem, debugType };
550
+ //#endregion
551
+ export { ConfigSource, type DefinePage, type ExcludeIndexSignature, FILE_EXTENSIONS, MODULE_ID_VIRTUAL, type MaybeCallable, type MaybePromise, type MaybePromiseCallable, OUTPUT_NAME, Options, Page, PageContext, type PageMetaDatum, PagePath, RESOLVED_MODULE_ID_VIRTUAL, ResolvedOptions, SubPackageConfig, type SubPageMetaDatum, UserOptions, type UserPageMeta, type UserTabBarItem, VitePluginUniPages, VitePluginUniPages as default, babelGenerate, checkPagesJsonFileSync, debug, debugType, type definePage, defineUniPages, extsToGlob, findImports, findMacro, getPageFiles, invalidatePagesModule, isTargetFile, mergePageMetaDataArray, parseCode, parseSFC, resolveOptions, resolvePageDirs, sleep, stripType, tryPageMetaFromMacro, writeFileWithLock };