wevu 1.0.3 → 1.0.6
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/README.md +32 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +401 -188
- package/dist/index.d.mts +401 -188
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.cjs +0 -0
- package/dist/jsx-runtime.d.cts +586 -0
- package/dist/jsx-runtime.d.mts +586 -0
- package/dist/jsx-runtime.mjs +1 -0
- package/package.json +12 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ref as Ref$1 } from "@vue/reactivity";
|
|
2
|
-
import { ComponentOptionsMixin, DefineComponent, PublicProps } from "vue";
|
|
2
|
+
import { AllowedComponentProps, ComponentCustomProps, ComponentOptionsMixin, DefineComponent, ObjectDirective, PublicProps, ShallowUnwrapRef, VNode, VNodeProps } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/reactivity/ref.d.ts
|
|
5
5
|
type Ref<T$1 = any, S = T$1> = Ref$1<T$1, S>;
|
|
@@ -44,6 +44,7 @@ interface ReactiveEffect<T$1 = any> {
|
|
|
44
44
|
declare function startBatch(): void;
|
|
45
45
|
declare function endBatch(): void;
|
|
46
46
|
declare function batch<T$1>(fn: () => T$1): T$1;
|
|
47
|
+
declare function stop(runner: ReactiveEffect): void;
|
|
47
48
|
interface EffectScope {
|
|
48
49
|
active: boolean;
|
|
49
50
|
effects: ReactiveEffect[];
|
|
@@ -60,10 +61,8 @@ interface EffectOptions {
|
|
|
60
61
|
onStop?: () => void;
|
|
61
62
|
}
|
|
62
63
|
declare function effect<T$1 = any>(fn: () => T$1, options?: EffectOptions): ReactiveEffect<T$1>;
|
|
63
|
-
declare function stop(runner: ReactiveEffect): void;
|
|
64
64
|
//#endregion
|
|
65
|
-
//#region src/reactivity/reactive.d.ts
|
|
66
|
-
declare function getReactiveVersion(target: object): number;
|
|
65
|
+
//#region src/reactivity/reactive/mutation.d.ts
|
|
67
66
|
type MutationOp = 'set' | 'delete';
|
|
68
67
|
type MutationKind = 'property' | 'array';
|
|
69
68
|
interface MutationRecord {
|
|
@@ -71,20 +70,19 @@ interface MutationRecord {
|
|
|
71
70
|
kind: MutationKind;
|
|
72
71
|
op: MutationOp;
|
|
73
72
|
/**
|
|
74
|
-
* dot path
|
|
73
|
+
* dot path (e.g. `a.b.c`); undefined when path is not reliable.
|
|
75
74
|
*/
|
|
76
75
|
path?: string;
|
|
77
76
|
/**
|
|
78
|
-
*
|
|
77
|
+
* Top-level keys to fallback when path is not unique.
|
|
79
78
|
*/
|
|
80
79
|
fallbackTopKeys?: string[];
|
|
81
80
|
}
|
|
82
81
|
type MutationRecorder = (record: MutationRecord) => void;
|
|
83
82
|
declare function addMutationRecorder(recorder: MutationRecorder): void;
|
|
84
83
|
declare function removeMutationRecorder(recorder: MutationRecorder): void;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
declare function toRaw<T$1>(observed: T$1): T$1;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/reactivity/reactive/patch.d.ts
|
|
88
86
|
interface PrelinkReactiveTreeOptions {
|
|
89
87
|
shouldIncludeTopKey?: (key: string) => boolean;
|
|
90
88
|
maxDepth?: number;
|
|
@@ -95,6 +93,8 @@ declare function prelinkReactiveTree(root: object, options?: PrelinkReactiveTree
|
|
|
95
93
|
* 让 effect 订阅整个对象的“版本号”,无需深度遍历即可对任何字段变化做出响应。
|
|
96
94
|
*/
|
|
97
95
|
declare function touchReactive(target: object): void;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/reactivity/reactive/shallow.d.ts
|
|
98
98
|
/**
|
|
99
99
|
* 创建一个浅层响应式代理:仅跟踪第一层属性变更,不深度递归嵌套对象。
|
|
100
100
|
*
|
|
@@ -114,6 +114,14 @@ declare function shallowReactive<T$1 extends object>(target: T$1): T$1;
|
|
|
114
114
|
* 判断一个值是否为 shallowReactive 创建的浅层响应式对象
|
|
115
115
|
*/
|
|
116
116
|
declare function isShallowReactive(value: unknown): boolean;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/reactivity/reactive/shared.d.ts
|
|
119
|
+
declare function toRaw<T$1>(observed: T$1): T$1;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/reactivity/reactive.d.ts
|
|
122
|
+
declare function getReactiveVersion(target: object): number;
|
|
123
|
+
declare function reactive<T$1 extends object>(target: T$1): T$1;
|
|
124
|
+
declare function isReactive(value: unknown): boolean;
|
|
117
125
|
/**
|
|
118
126
|
* 标记对象为“原始”状态,后续不会被转换为响应式,返回原对象本身。
|
|
119
127
|
*
|
|
@@ -152,20 +160,6 @@ declare function readonly<T$1 extends object>(target: T$1): T$1;
|
|
|
152
160
|
declare function readonly<T$1>(target: Ref<T$1>): Readonly<Ref<T$1>>;
|
|
153
161
|
//#endregion
|
|
154
162
|
//#region src/reactivity/shallowRef.d.ts
|
|
155
|
-
/**
|
|
156
|
-
* 创建一个“浅层” ref:它只在 .value 被整体替换时触发依赖,不会对内部对象做深层响应式处理。
|
|
157
|
-
*
|
|
158
|
-
* @param value 初始值
|
|
159
|
-
* @param defaultValue 传递给 customRef 的默认值,可用于兜底
|
|
160
|
-
* @returns 仅跟踪自身 .value 变更的浅层 ref
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```ts
|
|
164
|
-
* const state = shallowRef({ count: 0 })
|
|
165
|
-
* state.value = { count: 1 } // 会触发依赖
|
|
166
|
-
* state.value.count++ // 不会触发依赖(内部属性未被深度代理)
|
|
167
|
-
* ```
|
|
168
|
-
*/
|
|
169
163
|
declare function shallowRef<T$1>(value: T$1): Ref<T$1>;
|
|
170
164
|
declare function shallowRef<T$1>(value: T$1, defaultValue: T$1): Ref<T$1>;
|
|
171
165
|
/**
|
|
@@ -183,22 +177,6 @@ declare function isShallowRef(r: any): r is Ref<any>;
|
|
|
183
177
|
declare function triggerRef<T$1>(ref: Ref<T$1>): void;
|
|
184
178
|
//#endregion
|
|
185
179
|
//#region src/reactivity/toRefs.d.ts
|
|
186
|
-
/**
|
|
187
|
-
* 将一个响应式对象转换成“同结构的普通对象”,其中每个字段都是指向原对象对应属性的 ref。
|
|
188
|
-
*
|
|
189
|
-
* @param object 待转换的响应式对象
|
|
190
|
-
* @returns 包含若干 ref 的普通对象
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* ```ts
|
|
194
|
-
* const state = reactive({ foo: 1, bar: 2 })
|
|
195
|
-
* const stateAsRefs = toRefs(state)
|
|
196
|
-
*
|
|
197
|
-
* stateAsRefs.foo.value++ // 2
|
|
198
|
-
* state.foo // 2
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
declare function toRefs<T$1 extends object>(object: T$1): ToRefs<T$1>;
|
|
202
180
|
/**
|
|
203
181
|
* 为源响应式对象的单个属性创建 ref,可读可写并与原属性保持同步。
|
|
204
182
|
*
|
|
@@ -217,6 +195,22 @@ declare function toRefs<T$1 extends object>(object: T$1): ToRefs<T$1>;
|
|
|
217
195
|
*/
|
|
218
196
|
declare function toRef<T$1 extends object, K$1 extends keyof T$1>(object: T$1, key: K$1): Ref<T$1[K$1]>;
|
|
219
197
|
declare function toRef<T$1 extends object, K$1 extends keyof T$1>(object: T$1, key: K$1, defaultValue: T$1[K$1]): Ref<T$1[K$1]>;
|
|
198
|
+
/**
|
|
199
|
+
* 将一个响应式对象转换成“同结构的普通对象”,其中每个字段都是指向原对象对应属性的 ref。
|
|
200
|
+
*
|
|
201
|
+
* @param object 待转换的响应式对象
|
|
202
|
+
* @returns 包含若干 ref 的普通对象
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* const state = reactive({ foo: 1, bar: 2 })
|
|
207
|
+
* const stateAsRefs = toRefs(state)
|
|
208
|
+
*
|
|
209
|
+
* stateAsRefs.foo.value++ // 2
|
|
210
|
+
* state.foo // 2
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare function toRefs<T$1 extends object>(object: T$1): ToRefs<T$1>;
|
|
220
214
|
/**
|
|
221
215
|
* toRefs 返回值的类型辅助
|
|
222
216
|
*/
|
|
@@ -230,137 +224,47 @@ interface WatchOptions {
|
|
|
230
224
|
immediate?: boolean;
|
|
231
225
|
deep?: boolean;
|
|
232
226
|
}
|
|
233
|
-
type WatchSource<T$1 = any> = (() => T$1) | Ref<T$1
|
|
227
|
+
type WatchSource<T$1 = any> = (() => T$1) | Ref<T$1>;
|
|
228
|
+
type WatchSourceValue<S> = S extends Ref<infer V> ? V : S extends (() => infer V) ? V : S extends object ? S : never;
|
|
229
|
+
type IsTuple<T$1 extends ReadonlyArray<any>> = number extends T$1['length'] ? false : true;
|
|
230
|
+
type WatchMultiSources<T$1 extends ReadonlyArray<WatchSource<any>>> = IsTuple<T$1> extends true ? { [K in keyof T$1]: WatchSourceValue<T$1[K]> } : Array<WatchSourceValue<T$1[number]>>;
|
|
234
231
|
type WatchStopHandle = () => void;
|
|
235
232
|
type DeepWatchStrategy = 'version' | 'traverse';
|
|
236
233
|
declare function setDeepWatchStrategy(strategy: DeepWatchStrategy): void;
|
|
237
234
|
declare function getDeepWatchStrategy(): DeepWatchStrategy;
|
|
238
235
|
declare function watch<T$1>(source: WatchSource<T$1>, cb: (value: T$1, oldValue: T$1, onCleanup: (cleanupFn: () => void) => void) => void, options?: WatchOptions): WatchStopHandle;
|
|
236
|
+
declare function watch<T$1 extends object>(source: T$1 extends ReadonlyArray<any> ? never : T$1, cb: (value: T$1, oldValue: T$1, onCleanup: (cleanupFn: () => void) => void) => void, options?: WatchOptions): WatchStopHandle;
|
|
237
|
+
declare function watch<T$1 extends ReadonlyArray<WatchSource<any>>>(source: T$1, cb: (value: WatchMultiSources<T$1>, oldValue: WatchMultiSources<T$1>, onCleanup: (cleanupFn: () => void) => void) => void, options?: WatchOptions): WatchStopHandle;
|
|
239
238
|
/**
|
|
240
239
|
* watchEffect 注册一个响应式副作用,可选清理函数。
|
|
241
240
|
* 副作用会立即执行,并在依赖变化时重新运行。
|
|
242
241
|
*/
|
|
243
242
|
declare function watchEffect(effectFn: (onCleanup: (cleanupFn: () => void) => void) => void): WatchStopHandle;
|
|
244
243
|
//#endregion
|
|
245
|
-
//#region src/runtime/types.d.ts
|
|
244
|
+
//#region src/runtime/types/core.d.ts
|
|
246
245
|
type ComputedDefinitions = Record<string, ComputedGetter<any> | WritableComputedOptions<any>>;
|
|
247
246
|
type MethodDefinitions = Record<string, (...args: any[]) => any>;
|
|
248
247
|
type ExtractComputed<C extends ComputedDefinitions> = { [K in keyof C]: C[K] extends ComputedGetter<infer R> ? R : C[K] extends WritableComputedOptions<infer R> ? R : never };
|
|
249
248
|
type ExtractMethods<M extends MethodDefinitions> = { [K in keyof M]: M[K] extends ((...args: infer P) => infer R) ? (...args: P) => R : never };
|
|
250
|
-
type ComponentPublicInstance<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> = D & ExtractComputed<C> & ExtractMethods<M
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
type ComponentPublicInstance<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> = D & ExtractComputed<C> & ExtractMethods<M> & {
|
|
250
|
+
$attrs: Record<string, any>;
|
|
251
|
+
};
|
|
252
|
+
interface ModelBindingOptions<T$1 = any, Event extends string = string, ValueProp extends string = string, Formatted = T$1> {
|
|
253
|
+
event?: Event;
|
|
254
|
+
valueProp?: ValueProp;
|
|
255
|
+
parser?: (payload: any) => T$1;
|
|
256
|
+
formatter?: (value: T$1) => Formatted;
|
|
253
257
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
*/
|
|
260
|
-
strategy?: 'diff' | 'patch';
|
|
261
|
-
/**
|
|
262
|
-
* 仅下发指定的顶层字段(包含 data/setup 返回值与 computed)。
|
|
263
|
-
* 若为空则默认下发所有字段。
|
|
264
|
-
*/
|
|
265
|
-
pick?: string[];
|
|
266
|
-
/**
|
|
267
|
-
* 排除指定的顶层字段(包含 data/setup 返回值与 computed)。
|
|
268
|
-
*/
|
|
269
|
-
omit?: string[];
|
|
270
|
-
/**
|
|
271
|
-
* 是否将 computed 的结果参与 setData(默认 true)。
|
|
272
|
-
*/
|
|
273
|
-
includeComputed?: boolean;
|
|
274
|
-
/**
|
|
275
|
-
* patch 模式阈值:当本轮变更路径数量超过该值时,自动回退到 diff。
|
|
276
|
-
* 说明:大量路径变更时,全量快照 diff 往往更快/更小。
|
|
277
|
-
*/
|
|
278
|
-
maxPatchKeys?: number;
|
|
279
|
-
/**
|
|
280
|
-
* patch 模式阈值:当本轮 payload 估算字节数超过该值时,自动回退到 diff。
|
|
281
|
-
* 说明:该估算基于 `JSON.stringify(payload).length`,仅用于启发式降级。
|
|
282
|
-
*/
|
|
283
|
-
maxPayloadBytes?: number;
|
|
284
|
-
/**
|
|
285
|
-
* patch 模式优化:当同一父路径下存在多个子路径变更时,合并为父路径整体下发。
|
|
286
|
-
*
|
|
287
|
-
* 例如:`a.b` 与 `a.c` 同时变更,且 `mergeSiblingThreshold = 2` 时,会下发 `a`。
|
|
288
|
-
*
|
|
289
|
-
* 注意:当子路径包含删除(null)时,为避免删除语义不一致,将不会触发合并。
|
|
290
|
-
*/
|
|
291
|
-
mergeSiblingThreshold?: number;
|
|
292
|
-
/**
|
|
293
|
-
* 同级合并的“负优化”防护:若合并后的父路径估算体积大于子路径体积之和 * ratio,则不合并。
|
|
294
|
-
*/
|
|
295
|
-
mergeSiblingMaxInflationRatio?: number;
|
|
296
|
-
/**
|
|
297
|
-
* 同级合并的“负优化”防护:若父路径估算体积超过该值,则不合并。
|
|
298
|
-
*/
|
|
299
|
-
mergeSiblingMaxParentBytes?: number;
|
|
300
|
-
/**
|
|
301
|
-
* 是否在父值为数组时跳过同级合并(默认 true)。
|
|
302
|
-
*/
|
|
303
|
-
mergeSiblingSkipArray?: boolean;
|
|
304
|
-
/**
|
|
305
|
-
* patch 模式优化:computed 变更对比策略。
|
|
306
|
-
*
|
|
307
|
-
* - reference:仅 `Object.is` 比较(最快,可能会多下发)
|
|
308
|
-
* - shallow:仅比较数组/对象第一层(折中)
|
|
309
|
-
* - deep:深比较(可能较慢,适合小对象);会受 `computedCompareMaxDepth/maxKeys` 限制
|
|
310
|
-
*/
|
|
311
|
-
computedCompare?: 'reference' | 'shallow' | 'deep';
|
|
312
|
-
/**
|
|
313
|
-
* computed 深比较最大深度(仅在 `computedCompare = "deep"` 时生效)。
|
|
314
|
-
*/
|
|
315
|
-
computedCompareMaxDepth?: number;
|
|
316
|
-
/**
|
|
317
|
-
* computed 深比较最多比较 key 数(仅在 `computedCompare = "deep"` 时生效)。
|
|
318
|
-
*/
|
|
319
|
-
computedCompareMaxKeys?: number;
|
|
320
|
-
/**
|
|
321
|
-
* 限制 patch 模式的预链接(prelinkReactiveTree)开销:最多向下遍历的深度(root 为 0)。
|
|
322
|
-
*/
|
|
323
|
-
prelinkMaxDepth?: number;
|
|
324
|
-
/**
|
|
325
|
-
* 限制 patch 模式的预链接(prelinkReactiveTree)开销:最多索引的节点数。
|
|
326
|
-
*/
|
|
327
|
-
prelinkMaxKeys?: number;
|
|
328
|
-
/**
|
|
329
|
-
* setData 调试信息回调(用于观测 patch 命中率/回退原因/payload 大小)。
|
|
330
|
-
*/
|
|
331
|
-
debug?: (info: SetDataDebugInfo) => void;
|
|
332
|
-
/**
|
|
333
|
-
* debug 触发时机:
|
|
334
|
-
* - fallback:仅在回退 diff / 超阈值时触发(默认)
|
|
335
|
-
* - always:每次 flush 都触发
|
|
336
|
-
*/
|
|
337
|
-
debugWhen?: 'fallback' | 'always';
|
|
338
|
-
/**
|
|
339
|
-
* debug 采样率(0-1),用于降低 debug 频率与开销(默认 1)。
|
|
340
|
-
*/
|
|
341
|
-
debugSampleRate?: number;
|
|
342
|
-
/**
|
|
343
|
-
* patch 模式优化:当某个顶层字段下的变更路径数量过多时,直接提升为顶层字段整体替换。
|
|
344
|
-
*/
|
|
345
|
-
elevateTopKeyThreshold?: number;
|
|
346
|
-
/**
|
|
347
|
-
* setData 序列化上限:最大递归深度(root 为 0)。超过时将停止深拷贝,保留更浅层结构。
|
|
348
|
-
*/
|
|
349
|
-
toPlainMaxDepth?: number;
|
|
350
|
-
/**
|
|
351
|
-
* setData 序列化上限:最多处理的对象 key 数(累计)。超过时将停止深拷贝,保留更浅层结构。
|
|
352
|
-
*/
|
|
353
|
-
toPlainMaxKeys?: number;
|
|
258
|
+
type ModelBindingPayload<T$1 = any, Event extends string = 'input', ValueProp extends string = 'value', Formatted = T$1> = { [K in ValueProp]: Formatted } & { [K in `on${Capitalize<Event>}`]: (event: any) => void };
|
|
259
|
+
interface ModelBinding<T$1 = any> {
|
|
260
|
+
value: T$1;
|
|
261
|
+
update: (value: T$1) => void;
|
|
262
|
+
model: <Event extends string = 'input', ValueProp extends string = 'value', Formatted = T$1>(options?: ModelBindingOptions<T$1, Event, ValueProp, Formatted>) => ModelBindingPayload<T$1, Event, ValueProp, Formatted>;
|
|
354
263
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
payloadKeys: number;
|
|
360
|
-
estimatedBytes?: number;
|
|
361
|
-
bytes?: number;
|
|
362
|
-
mergedSiblingParents?: number;
|
|
363
|
-
computedDirtyKeys?: number;
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/runtime/types/miniprogram.d.ts
|
|
266
|
+
interface MiniProgramAdapter {
|
|
267
|
+
setData?: (payload: Record<string, any>) => void | Promise<void>;
|
|
364
268
|
}
|
|
365
269
|
type MiniProgramComponentBehaviorOptions = WechatMiniprogram.Component.ComponentOptions;
|
|
366
270
|
type MpComponentOptions = WechatMiniprogram.Component.TrivialOption;
|
|
@@ -428,24 +332,21 @@ interface MiniProgramComponentOptions {
|
|
|
428
332
|
detached?: MpComponentOptions['detached'];
|
|
429
333
|
error?: MpComponentOptions['error'];
|
|
430
334
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
model: (options?: ModelBindingOptions<T$1>) => Record<string, any>;
|
|
441
|
-
}
|
|
335
|
+
type MiniProgramAppOptions<T$1 extends Record<string, any> = Record<string, any>> = WechatMiniprogram.App.Options<T$1>;
|
|
336
|
+
type TriggerEventOptions = WechatMiniprogram.Component.TriggerEventOption;
|
|
337
|
+
type MiniProgramInstance = WechatMiniprogram.Component.TrivialInstance | WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.App.TrivialInstance;
|
|
338
|
+
type MiniProgramPageLifetimes = Partial<WechatMiniprogram.Page.ILifetime>;
|
|
339
|
+
type MiniProgramComponentRawOptions = Omit<WechatMiniprogram.Component.TrivialOption, 'behaviors'> & {
|
|
340
|
+
behaviors?: MiniProgramBehaviorIdentifier[];
|
|
341
|
+
} & MiniProgramPageLifetimes & Record<string, any>;
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/runtime/types/runtime.d.ts
|
|
442
344
|
interface AppConfig {
|
|
443
345
|
globalProperties: Record<string, any>;
|
|
444
346
|
}
|
|
445
347
|
type WevuPlugin = ((app: RuntimeApp<any, any, any>, ...options: any[]) => any) | {
|
|
446
348
|
install: (app: RuntimeApp<any, any, any>, ...options: any[]) => any;
|
|
447
349
|
};
|
|
448
|
-
type MiniProgramAppOptions<T$1 extends Record<string, any> = Record<string, any>> = WechatMiniprogram.App.Options<T$1>;
|
|
449
350
|
interface RuntimeApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> {
|
|
450
351
|
mount: (adapter?: MiniProgramAdapter) => RuntimeInstance<D, C, M>;
|
|
451
352
|
use: (plugin: WevuPlugin, ...options: any[]) => RuntimeApp<D, C, M>;
|
|
@@ -462,6 +363,16 @@ interface RuntimeInstance<D extends object, C extends ComputedDefinitions, M ext
|
|
|
462
363
|
snapshot: () => Record<string, any>;
|
|
463
364
|
unmount: () => void;
|
|
464
365
|
}
|
|
366
|
+
interface InternalRuntimeStateFields {
|
|
367
|
+
__wevu?: RuntimeInstance<any, any, any>;
|
|
368
|
+
__wevuWatchStops?: WatchStopHandle[];
|
|
369
|
+
$wevu?: RuntimeInstance<any, any, any>;
|
|
370
|
+
__wevuHooks?: Record<string, any>;
|
|
371
|
+
__wevuExposed?: Record<string, any>;
|
|
372
|
+
}
|
|
373
|
+
type InternalRuntimeState = InternalRuntimeStateFields & Partial<MiniProgramInstance>;
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/runtime/types/props.d.ts
|
|
465
376
|
type PropMethod<T$1, TConstructor = any> = [T$1] extends [((...args: any) => any) | undefined] ? {
|
|
466
377
|
new (): TConstructor;
|
|
467
378
|
(): T$1;
|
|
@@ -503,6 +414,8 @@ type InferPropType<O> = O extends null ? any : O extends {
|
|
|
503
414
|
} ? InferPropConstructor<T> : O extends PropType<infer V> ? V : InferPropConstructor<O>;
|
|
504
415
|
type InferPropConstructor<T$1> = T$1 extends readonly any[] ? InferPropConstructor<T$1[number]> : T$1 extends undefined ? any : T$1 extends null ? any : T$1 extends BooleanConstructor ? boolean : T$1 extends NumberConstructor ? number : T$1 extends StringConstructor ? string : T$1 extends DateConstructor ? Date : T$1 extends ArrayConstructor ? any[] : T$1 extends ObjectConstructor ? Record<string, any> : T$1 extends PropConstructor<infer V> ? V : any;
|
|
505
416
|
type InferProps<P$1 extends ComponentPropsOptions = ComponentPropsOptions> = { [K in keyof Pick<P$1, RequiredKeys<P$1>>]: HasDefault<P$1[K]> extends true ? Exclude<InferPropType<P$1[K]>, undefined> : InferPropType<P$1[K]> } & { [K in keyof Pick<P$1, OptionalKeys<P$1>>]?: InferPropType<P$1[K]> };
|
|
417
|
+
type ExtractPropTypes<P$1 extends ComponentPropsOptions = ComponentPropsOptions> = InferProps<P$1>;
|
|
418
|
+
type ExtractPublicPropTypes<P$1 extends ComponentPropsOptions = ComponentPropsOptions> = InferProps<P$1>;
|
|
506
419
|
type SetupFunction<P$1 extends ComponentPropsOptions, D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> = (props: InferProps<P$1>, ctx: SetupContext<D, C, M, P$1>) => Record<string, any> | void;
|
|
507
420
|
interface SetupContext<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions, P$1 extends ComponentPropsOptions = ComponentPropsOptions> {
|
|
508
421
|
/**
|
|
@@ -520,7 +433,7 @@ interface SetupContext<D extends object, C extends ComputedDefinitions, M extend
|
|
|
520
433
|
/**
|
|
521
434
|
* 公开实例代理
|
|
522
435
|
*/
|
|
523
|
-
proxy:
|
|
436
|
+
proxy: RuntimeInstance<D, C, M>['proxy'];
|
|
524
437
|
/**
|
|
525
438
|
* 双向绑定辅助方法
|
|
526
439
|
*/
|
|
@@ -553,20 +466,121 @@ interface SetupContext<D extends object, C extends ComputedDefinitions, M extend
|
|
|
553
466
|
*/
|
|
554
467
|
slots: Record<string, any>;
|
|
555
468
|
}
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/runtime/types/setData.d.ts
|
|
471
|
+
interface SetDataSnapshotOptions {
|
|
472
|
+
/**
|
|
473
|
+
* setData 策略:
|
|
474
|
+
* - diff:全量快照 + diff(默认,兼容性最好)
|
|
475
|
+
* - patch:按变更路径增量产出 payload(性能更好;在共享引用等场景会自动回退 diff)
|
|
476
|
+
*/
|
|
477
|
+
strategy?: 'diff' | 'patch';
|
|
478
|
+
/**
|
|
479
|
+
* 仅下发指定的顶层字段(包含 data/setup 返回值与 computed)。
|
|
480
|
+
* 若为空则默认下发所有字段。
|
|
481
|
+
*/
|
|
482
|
+
pick?: string[];
|
|
483
|
+
/**
|
|
484
|
+
* 排除指定的顶层字段(包含 data/setup 返回值与 computed)。
|
|
485
|
+
*/
|
|
486
|
+
omit?: string[];
|
|
487
|
+
/**
|
|
488
|
+
* 是否将 computed 的结果参与 setData(默认 true)。
|
|
489
|
+
*/
|
|
490
|
+
includeComputed?: boolean;
|
|
491
|
+
/**
|
|
492
|
+
* patch 模式阈值:当本轮变更路径数量超过该值时,自动回退到 diff。
|
|
493
|
+
* 说明:大量路径变更时,全量快照 diff 往往更快/更小。
|
|
494
|
+
*/
|
|
495
|
+
maxPatchKeys?: number;
|
|
496
|
+
/**
|
|
497
|
+
* patch 模式阈值:当本轮 payload 估算字节数超过该值时,自动回退到 diff。
|
|
498
|
+
* 说明:该估算基于 `JSON.stringify(payload).length`,仅用于启发式降级。
|
|
499
|
+
*/
|
|
500
|
+
maxPayloadBytes?: number;
|
|
501
|
+
/**
|
|
502
|
+
* patch 模式优化:当同一父路径下存在多个子路径变更时,合并为父路径整体下发。
|
|
503
|
+
*
|
|
504
|
+
* 例如:`a.b` 与 `a.c` 同时变更,且 `mergeSiblingThreshold = 2` 时,会下发 `a`。
|
|
505
|
+
*
|
|
506
|
+
* 注意:当子路径包含删除(null)时,为避免删除语义不一致,将不会触发合并。
|
|
507
|
+
*/
|
|
508
|
+
mergeSiblingThreshold?: number;
|
|
509
|
+
/**
|
|
510
|
+
* 同级合并的“负优化”防护:若合并后的父路径估算体积大于子路径体积之和 * ratio,则不合并。
|
|
511
|
+
*/
|
|
512
|
+
mergeSiblingMaxInflationRatio?: number;
|
|
513
|
+
/**
|
|
514
|
+
* 同级合并的“负优化”防护:若父路径估算体积超过该值,则不合并。
|
|
515
|
+
*/
|
|
516
|
+
mergeSiblingMaxParentBytes?: number;
|
|
517
|
+
/**
|
|
518
|
+
* 是否在父值为数组时跳过同级合并(默认 true)。
|
|
519
|
+
*/
|
|
520
|
+
mergeSiblingSkipArray?: boolean;
|
|
521
|
+
/**
|
|
522
|
+
* patch 模式优化:computed 变更对比策略。
|
|
523
|
+
*
|
|
524
|
+
* - reference:仅 `Object.is` 比较(最快,可能会多下发)
|
|
525
|
+
* - shallow:仅比较数组/对象第一层(折中)
|
|
526
|
+
* - deep:深比较(可能较慢,适合小对象);会受 `computedCompareMaxDepth/maxKeys` 限制
|
|
527
|
+
*/
|
|
528
|
+
computedCompare?: 'reference' | 'shallow' | 'deep';
|
|
529
|
+
/**
|
|
530
|
+
* computed 深比较最大深度(仅在 `computedCompare = "deep"` 时生效)。
|
|
531
|
+
*/
|
|
532
|
+
computedCompareMaxDepth?: number;
|
|
533
|
+
/**
|
|
534
|
+
* computed 深比较最多比较 key 数(仅在 `computedCompare = "deep"` 时生效)。
|
|
535
|
+
*/
|
|
536
|
+
computedCompareMaxKeys?: number;
|
|
537
|
+
/**
|
|
538
|
+
* 限制 patch 模式的预链接(prelinkReactiveTree)开销:最多向下遍历的深度(root 为 0)。
|
|
539
|
+
*/
|
|
540
|
+
prelinkMaxDepth?: number;
|
|
541
|
+
/**
|
|
542
|
+
* 限制 patch 模式的预链接(prelinkReactiveTree)开销:最多索引的节点数。
|
|
543
|
+
*/
|
|
544
|
+
prelinkMaxKeys?: number;
|
|
545
|
+
/**
|
|
546
|
+
* setData 调试信息回调(用于观测 patch 命中率/回退原因/payload 大小)。
|
|
547
|
+
*/
|
|
548
|
+
debug?: (info: SetDataDebugInfo) => void;
|
|
549
|
+
/**
|
|
550
|
+
* debug 触发时机:
|
|
551
|
+
* - fallback:仅在回退 diff / 超阈值时触发(默认)
|
|
552
|
+
* - always:每次 flush 都触发
|
|
553
|
+
*/
|
|
554
|
+
debugWhen?: 'fallback' | 'always';
|
|
555
|
+
/**
|
|
556
|
+
* debug 采样率(0-1),用于降低 debug 频率与开销(默认 1)。
|
|
557
|
+
*/
|
|
558
|
+
debugSampleRate?: number;
|
|
559
|
+
/**
|
|
560
|
+
* patch 模式优化:当某个顶层字段下的变更路径数量过多时,直接提升为顶层字段整体替换。
|
|
561
|
+
*/
|
|
562
|
+
elevateTopKeyThreshold?: number;
|
|
563
|
+
/**
|
|
564
|
+
* setData 序列化上限:最大递归深度(root 为 0)。超过时将停止深拷贝,保留更浅层结构。
|
|
565
|
+
*/
|
|
566
|
+
toPlainMaxDepth?: number;
|
|
567
|
+
/**
|
|
568
|
+
* setData 序列化上限:最多处理的对象 key 数(累计)。超过时将停止深拷贝,保留更浅层结构。
|
|
569
|
+
*/
|
|
570
|
+
toPlainMaxKeys?: number;
|
|
563
571
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
572
|
+
interface SetDataDebugInfo {
|
|
573
|
+
mode: 'patch' | 'diff';
|
|
574
|
+
reason: 'patch' | 'diff' | 'needsFullSnapshot' | 'maxPatchKeys' | 'maxPayloadBytes';
|
|
575
|
+
pendingPatchKeys: number;
|
|
576
|
+
payloadKeys: number;
|
|
577
|
+
estimatedBytes?: number;
|
|
578
|
+
bytes?: number;
|
|
579
|
+
mergedSiblingParents?: number;
|
|
580
|
+
computedDirtyKeys?: number;
|
|
581
|
+
}
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/runtime/types/options.d.ts
|
|
570
584
|
interface DefineComponentOptions<P$1 extends ComponentPropsOptions = ComponentPropsOptions, D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> extends MiniProgramComponentOptions, MiniProgramPageLifetimes {
|
|
571
585
|
/**
|
|
572
586
|
* 页面特性开关(用于按需注入 Page 事件处理函数)。
|
|
@@ -664,6 +678,10 @@ interface PageFeatures {
|
|
|
664
678
|
enableOnSaveExitState?: boolean;
|
|
665
679
|
}
|
|
666
680
|
//#endregion
|
|
681
|
+
//#region src/runtime/types.d.ts
|
|
682
|
+
interface GlobalComponents {}
|
|
683
|
+
interface GlobalDirectives {}
|
|
684
|
+
//#endregion
|
|
667
685
|
//#region src/runtime/app.d.ts
|
|
668
686
|
declare function createApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: CreateAppOptions<D, C, M>): RuntimeApp<D, C, M>;
|
|
669
687
|
//#endregion
|
|
@@ -712,7 +730,7 @@ interface ComponentDefinition<D extends object, C extends ComputedDefinitions, M
|
|
|
712
730
|
* defineComponent({
|
|
713
731
|
* data: () => ({ count: 0 }),
|
|
714
732
|
* setup() {
|
|
715
|
-
* onMounted(() => console.log('
|
|
733
|
+
* onMounted(() => console.log('已挂载'))
|
|
716
734
|
* }
|
|
717
735
|
* })
|
|
718
736
|
* ```
|
|
@@ -735,7 +753,9 @@ declare function defineComponent<P$1 extends ComponentPropsOptions = ComponentPr
|
|
|
735
753
|
declare function createWevuComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: DefineComponentOptions<ComponentPropsOptions, D, C, M> & {
|
|
736
754
|
properties?: WechatMiniprogram.Component.PropertyOption;
|
|
737
755
|
}): void;
|
|
738
|
-
declare function createWevuScopedSlotComponent(
|
|
756
|
+
declare function createWevuScopedSlotComponent(overrides?: {
|
|
757
|
+
computed?: ComputedDefinitions;
|
|
758
|
+
}): void;
|
|
739
759
|
//#endregion
|
|
740
760
|
//#region src/runtime/hooks.d.ts
|
|
741
761
|
declare function getCurrentInstance<T$1 extends InternalRuntimeState = InternalRuntimeState>(): T$1 | undefined;
|
|
@@ -859,7 +879,7 @@ declare function provideGlobal<T$1>(key: any, value: T$1): void;
|
|
|
859
879
|
*/
|
|
860
880
|
declare function injectGlobal<T$1>(key: any, defaultValue?: T$1): T$1;
|
|
861
881
|
//#endregion
|
|
862
|
-
//#region src/runtime/register.d.ts
|
|
882
|
+
//#region src/runtime/register/watch.d.ts
|
|
863
883
|
type WatchHandler = (this: any, value: any, oldValue: any) => void;
|
|
864
884
|
type WatchDescriptor = WatchHandler | string | {
|
|
865
885
|
handler: WatchHandler | string;
|
|
@@ -867,19 +887,42 @@ type WatchDescriptor = WatchHandler | string | {
|
|
|
867
887
|
deep?: boolean;
|
|
868
888
|
};
|
|
869
889
|
type WatchMap = Record<string, WatchDescriptor>;
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
declare function
|
|
890
|
+
//#endregion
|
|
891
|
+
//#region src/runtime/register/app.d.ts
|
|
892
|
+
declare function registerApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(runtimeApp: RuntimeApp<D, C, M>, methods: MethodDefinitions, watch: WatchMap | undefined, setup: DefineAppOptions<D, C, M>['setup'], mpOptions: MiniProgramAppOptions): void;
|
|
893
|
+
//#endregion
|
|
894
|
+
//#region src/runtime/register/component.d.ts
|
|
895
|
+
declare function registerComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(runtimeApp: RuntimeApp<D, C, M>, methods: MethodDefinitions, watch: WatchMap | undefined, setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'], mpOptions: MiniProgramComponentRawOptions): void;
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/runtime/register/runtimeInstance.d.ts
|
|
898
|
+
type RuntimeSetupFunction$1<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> = DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'] | DefineAppOptions<D, C, M>['setup'];
|
|
899
|
+
declare function mountRuntimeInstance<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(target: InternalRuntimeState, runtimeApp: RuntimeApp<D, C, M>, watchMap: WatchMap | undefined, setup?: RuntimeSetupFunction$1<D, C, M>, options?: {
|
|
873
900
|
deferSetData?: boolean;
|
|
874
901
|
}): RuntimeInstance<D, C, M>;
|
|
875
902
|
declare function teardownRuntimeInstance(target: InternalRuntimeState): void;
|
|
876
|
-
|
|
877
|
-
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/runtime/register/setup.d.ts
|
|
905
|
+
type RuntimeSetupFunction<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> = DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'] | DefineAppOptions<D, C, M>['setup'];
|
|
906
|
+
declare function runSetupFunction(setup: RuntimeSetupFunction<any, any, any> | undefined, props: Record<string, any>, context: any): void | Record<string, any>;
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/runtime/template.d.ts
|
|
909
|
+
declare function normalizeStyle(value: any): string;
|
|
910
|
+
declare function normalizeClass(value: any): string;
|
|
878
911
|
//#endregion
|
|
879
912
|
//#region src/runtime/vueCompat.d.ts
|
|
880
913
|
declare function useAttrs(): Record<string, any>;
|
|
881
914
|
declare function useSlots(): Record<string, any>;
|
|
882
915
|
declare function useModel<T$1 = any>(props: Record<string, any>, name: string): Ref<T$1>;
|
|
916
|
+
/**
|
|
917
|
+
* useBindModel 返回绑定到当前运行时实例的 bindModel。
|
|
918
|
+
* 该方法必须在 setup() 的同步阶段调用。
|
|
919
|
+
*/
|
|
920
|
+
type BindModelWithHelper<DefaultEvent extends string = 'input', DefaultValueProp extends string = 'value'> = (<T$1 = any>(path: string, options?: ModelBindingOptions<T$1>) => ModelBinding<T$1>) & {
|
|
921
|
+
model: <T$1 = any, Event extends string = DefaultEvent, ValueProp extends string = DefaultValueProp, Formatted = T$1>(path: string, options?: ModelBindingOptions<T$1, Event, ValueProp, Formatted>) => ModelBindingPayload<T$1, Event, ValueProp, Formatted>;
|
|
922
|
+
value: <T$1 = any, Event extends string = DefaultEvent, ValueProp extends string = DefaultValueProp, Formatted = T$1>(path: string, options?: ModelBindingOptions<T$1, Event, ValueProp, Formatted>) => Formatted;
|
|
923
|
+
on: <T$1 = any, Event extends string = DefaultEvent, ValueProp extends string = DefaultValueProp, Formatted = T$1>(path: string, options?: ModelBindingOptions<T$1, Event, ValueProp, Formatted>) => (event: any) => void;
|
|
924
|
+
};
|
|
925
|
+
declare function useBindModel<DefaultEvent extends string = 'input', DefaultValueProp extends string = 'value'>(defaultOptions?: ModelBindingOptions<any, DefaultEvent, DefaultValueProp, any>): BindModelWithHelper<DefaultEvent, DefaultValueProp>;
|
|
883
926
|
declare function mergeModels<T$1>(a: T$1, b: T$1): T$1;
|
|
884
927
|
//#endregion
|
|
885
928
|
//#region src/store/types.d.ts
|
|
@@ -951,4 +994,174 @@ declare function createStore(): StoreManager;
|
|
|
951
994
|
type StoreToRefsResult<T$1 extends Record<string, any>> = { [K in keyof T$1]: T$1[K] extends ((...args: any[]) => any) ? T$1[K] : T$1[K] extends Ref<infer V> ? Ref<V> : Ref<T$1[K]> };
|
|
952
995
|
declare function storeToRefs<T$1 extends Record<string, any>>(store: T$1): StoreToRefsResult<T$1>;
|
|
953
996
|
//#endregion
|
|
954
|
-
|
|
997
|
+
//#region src/index.d.ts
|
|
998
|
+
type Prettify<T$1> = { [K in keyof T$1]: T$1[K] } & {};
|
|
999
|
+
type LooseRequired<T$1> = { [P in keyof (T$1 & Required<T$1>)]: T$1[P] };
|
|
1000
|
+
type IfAny<T$1, Y, N> = 0 extends 1 & T$1 ? Y : N;
|
|
1001
|
+
type ComponentObjectPropsOptions = ComponentPropsOptions;
|
|
1002
|
+
type ExtractPropTypes$1<P$1 extends ComponentObjectPropsOptions> = InferProps<P$1>;
|
|
1003
|
+
type DefineProps<T$1, BKeys extends keyof T$1> = Readonly<T$1> & { readonly [K in BKeys]-?: boolean };
|
|
1004
|
+
type BooleanKey<T$1, K$1 extends keyof T$1 = keyof T$1> = K$1 extends any ? T$1[K$1] extends boolean | undefined ? T$1[K$1] extends never | undefined ? never : K$1 : never : never;
|
|
1005
|
+
/**
|
|
1006
|
+
* wevu + Volar 类型检查使用的 script-setup 宏。
|
|
1007
|
+
*
|
|
1008
|
+
* 这些只是类型声明,运行时不存在。
|
|
1009
|
+
* 请确保 `vueCompilerOptions.lib = "wevu"`,让 Volar 从本文件解析它们。
|
|
1010
|
+
*
|
|
1011
|
+
* 常见搭配示例(仅类型层):
|
|
1012
|
+
* - defineProps + withDefaults:声明 Props 并补默认值
|
|
1013
|
+
* - defineEmits:约束事件与负载类型
|
|
1014
|
+
* - defineSlots:约束插槽与插槽参数
|
|
1015
|
+
* - defineModel:声明双向绑定字段
|
|
1016
|
+
*/
|
|
1017
|
+
/**
|
|
1018
|
+
* defineProps 数组语法。
|
|
1019
|
+
*
|
|
1020
|
+
* @example
|
|
1021
|
+
* ```ts
|
|
1022
|
+
* const props = defineProps(['title', 'count'])
|
|
1023
|
+
* const { title } = defineProps(['title'])
|
|
1024
|
+
* ```
|
|
1025
|
+
*/
|
|
1026
|
+
declare function defineProps<PropNames extends string = string>(props: PropNames[]): Prettify<Readonly<{ [key in PropNames]?: any }>>;
|
|
1027
|
+
/**
|
|
1028
|
+
* defineProps 运行时 props 配置。
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const props = defineProps({
|
|
1033
|
+
* title: String,
|
|
1034
|
+
* count: Number,
|
|
1035
|
+
* active: Boolean,
|
|
1036
|
+
* color: {
|
|
1037
|
+
* type: String,
|
|
1038
|
+
* default: 'red',
|
|
1039
|
+
* },
|
|
1040
|
+
* })
|
|
1041
|
+
* ```
|
|
1042
|
+
*/
|
|
1043
|
+
declare function defineProps<PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions>(props: PP): Prettify<Readonly<ExtractPropTypes$1<PP>>>;
|
|
1044
|
+
/**
|
|
1045
|
+
* defineProps 泛型类型声明。
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```ts
|
|
1049
|
+
* const props = defineProps<{
|
|
1050
|
+
* title?: string
|
|
1051
|
+
* count: number
|
|
1052
|
+
* active?: boolean
|
|
1053
|
+
* }>()
|
|
1054
|
+
*
|
|
1055
|
+
* const props2 = defineProps<{
|
|
1056
|
+
* size?: 'sm' | 'md' | 'lg'
|
|
1057
|
+
* }>()
|
|
1058
|
+
* ```
|
|
1059
|
+
*/
|
|
1060
|
+
declare function defineProps<TypeProps>(): DefineProps<LooseRequired<TypeProps>, BooleanKey<TypeProps>>;
|
|
1061
|
+
type NotUndefined<T$1> = T$1 extends undefined ? never : T$1;
|
|
1062
|
+
type MappedOmit<T$1, K$1 extends keyof any> = { [P in keyof T$1 as P extends K$1 ? never : P]: T$1[P] };
|
|
1063
|
+
type InferDefaults<T$1> = { [K in keyof T$1]?: InferDefault<T$1, T$1[K]> };
|
|
1064
|
+
type NativeType = null | undefined | number | string | boolean | symbol | Function;
|
|
1065
|
+
type InferDefault<P$1, T$1> = ((props: P$1) => T$1 & {}) | (T$1 extends NativeType ? T$1 : never);
|
|
1066
|
+
type PropsWithDefaults<T$1, Defaults extends InferDefaults<T$1>, BKeys extends keyof T$1> = T$1 extends unknown ? Readonly<MappedOmit<T$1, keyof Defaults>> & { readonly [K in keyof Defaults as K extends keyof T$1 ? K : never]-?: K extends keyof T$1 ? Defaults[K] extends undefined ? IfAny<Defaults[K], NotUndefined<T$1[K]>, T$1[K]> : NotUndefined<T$1[K]> : never } & { readonly [K in BKeys]-?: K extends keyof Defaults ? Defaults[K] extends undefined ? boolean | undefined : boolean : boolean } : never;
|
|
1067
|
+
/**
|
|
1068
|
+
* withDefaults 为 defineProps 指定默认值(仅类型层)。
|
|
1069
|
+
* 默认值会影响可选/必选推导,但不生成运行时代码。
|
|
1070
|
+
*
|
|
1071
|
+
* @example
|
|
1072
|
+
* ```ts
|
|
1073
|
+
* const props = withDefaults(defineProps<{
|
|
1074
|
+
* title?: string
|
|
1075
|
+
* size?: 'sm' | 'md' | 'lg'
|
|
1076
|
+
* }>(), {
|
|
1077
|
+
* title: 'Empty',
|
|
1078
|
+
* size: 'md',
|
|
1079
|
+
* })
|
|
1080
|
+
* ```
|
|
1081
|
+
*/
|
|
1082
|
+
declare function withDefaults<T$1, BKeys extends keyof T$1, Defaults extends InferDefaults<T$1>>(props: DefineProps<T$1, BKeys>, defaults: Defaults): PropsWithDefaults<T$1, Defaults, BKeys>;
|
|
1083
|
+
type EmitsOptions = Record<string, ((...args: any[]) => any) | null> | string[];
|
|
1084
|
+
/**
|
|
1085
|
+
* defineEmits 字符串数组或映射写法。
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```ts
|
|
1089
|
+
* const emit = defineEmits(['change', 'open'])
|
|
1090
|
+
* emit('change', { id: 1 })
|
|
1091
|
+
*
|
|
1092
|
+
* const emit2 = defineEmits({
|
|
1093
|
+
* change: (payload: { id: number }) => true,
|
|
1094
|
+
* close: null,
|
|
1095
|
+
* })
|
|
1096
|
+
* emit2('change', { id: 2 })
|
|
1097
|
+
*
|
|
1098
|
+
* const emit3 = defineEmits(['tap', 'confirm'])
|
|
1099
|
+
* emit3('confirm')
|
|
1100
|
+
* ```
|
|
1101
|
+
*/
|
|
1102
|
+
declare function defineEmits<EE extends string = string>(emits?: EE[]): (event: EE, detail?: any) => void;
|
|
1103
|
+
declare function defineEmits<E extends Record<string, ((...args: any[]) => any) | null>>(emits?: E): (event: keyof E & string, detail?: any) => void;
|
|
1104
|
+
/**
|
|
1105
|
+
* defineEmits 显式签名写法。
|
|
1106
|
+
*
|
|
1107
|
+
* @example
|
|
1108
|
+
* ```ts
|
|
1109
|
+
* const emit = defineEmits<(e: 'save' | 'cancel', id?: number) => void>()
|
|
1110
|
+
* emit('save', 1)
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
declare function defineEmits<T$1 extends (...args: any[]) => any>(): T$1;
|
|
1114
|
+
/**
|
|
1115
|
+
* defineExpose 向父级 ref 暴露成员。
|
|
1116
|
+
* 仅影响类型提示,不会生成运行时代码。
|
|
1117
|
+
*
|
|
1118
|
+
* @example
|
|
1119
|
+
* ```ts
|
|
1120
|
+
* defineExpose({
|
|
1121
|
+
* focus,
|
|
1122
|
+
* reset,
|
|
1123
|
+
* })
|
|
1124
|
+
* ```
|
|
1125
|
+
*/
|
|
1126
|
+
declare function defineExpose<T$1 extends Record<string, any> = Record<string, any>>(exposed?: T$1): void;
|
|
1127
|
+
/**
|
|
1128
|
+
* defineOptions 设置组件选项。
|
|
1129
|
+
* 适合声明组件名、样式隔离等静态选项。
|
|
1130
|
+
*
|
|
1131
|
+
* @example
|
|
1132
|
+
* ```ts
|
|
1133
|
+
* defineOptions({
|
|
1134
|
+
* name: 'EmptyState',
|
|
1135
|
+
* inheritAttrs: false,
|
|
1136
|
+
* virtualHost: true,
|
|
1137
|
+
* })
|
|
1138
|
+
* ```
|
|
1139
|
+
*/
|
|
1140
|
+
declare function defineOptions(options: Record<string, any>): void;
|
|
1141
|
+
/**
|
|
1142
|
+
* defineSlots 声明 slots 类型。
|
|
1143
|
+
* 用于限定插槽名称与插槽参数结构。
|
|
1144
|
+
*
|
|
1145
|
+
* @example
|
|
1146
|
+
* ```ts
|
|
1147
|
+
* const slots = defineSlots<{
|
|
1148
|
+
* default?: (props: { text: string }) => any
|
|
1149
|
+
* footer?: () => any
|
|
1150
|
+
* }>()
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
declare function defineSlots<T$1 extends Record<string, any> = Record<string, any>>(): T$1;
|
|
1154
|
+
/**
|
|
1155
|
+
* defineModel 声明 v-model 绑定(weapp 变体)。
|
|
1156
|
+
* 支持默认字段与自定义字段名。
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```ts
|
|
1160
|
+
* const modelValue = defineModel<string>()
|
|
1161
|
+
* const checked = defineModel<boolean>('checked')
|
|
1162
|
+
* const count = defineModel<number>('count', { default: 0 })
|
|
1163
|
+
* ```
|
|
1164
|
+
*/
|
|
1165
|
+
declare function defineModel<T$1 = any>(name?: string, options?: Record<string, any>): Ref<T$1 | undefined>;
|
|
1166
|
+
//#endregion
|
|
1167
|
+
export { ActionSubscriber, type AllowedComponentProps, type AppConfig, type ComponentCustomProps, ComponentDefinition, type ComponentOptionsMixin, type ComponentPropsOptions, type ComponentPublicInstance, type ComputedDefinitions, ComputedGetter, ComputedRef, ComputedSetter, type CreateAppOptions, type DefineAppOptions, type DefineComponent, type DefineComponentOptions, DefineStoreOptions, EffectScope, EmitsOptions, type ExtractComputed, type ExtractMethods, type ExtractPropTypes, type ExtractPublicPropTypes, GlobalComponents, GlobalDirectives, type InferPropType, type InferProps, type InternalRuntimeState, type InternalRuntimeStateFields, type MethodDefinitions, type MiniProgramAdapter, type MiniProgramAppOptions, type MiniProgramBehaviorIdentifier, type MiniProgramComponentBehaviorOptions, type MiniProgramComponentOptions, type MiniProgramComponentRawOptions, type MiniProgramInstance, type MiniProgramPageLifetimes, type ModelBinding, type ModelBindingOptions, type ModelBindingPayload, type MutationKind, type MutationOp, type MutationRecord, MutationType, type ObjectDirective, type PageFeatures, type PrelinkReactiveTreeOptions, type PropConstructor, type PropOptions, type PropType, type PublicProps, Ref, type RuntimeApp, type RuntimeInstance, type SetDataDebugInfo, type SetDataSnapshotOptions, type SetupContext, type SetupFunction, type ShallowUnwrapRef, StoreManager, SubscriptionCallback, ToRefs, type TriggerEventOptions, type VNode, type VNodeProps, WatchOptions, WatchStopHandle, WevuDefaults, type WevuPlugin, WritableComputedOptions, WritableComputedRef, addMutationRecorder, batch, callHookList, callHookReturn, callUpdateHooks, computed, createApp, createStore, createWevuComponent, createWevuScopedSlotComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, defineStore, effect, effectScope, endBatch, getCurrentInstance, getCurrentScope, getCurrentSetupContext, getDeepWatchStrategy, getReactiveVersion, inject, injectGlobal, isNoSetData, isRaw, isReactive, isRef, isShallowReactive, isShallowRef, markNoSetData, markRaw, mergeModels, mountRuntimeInstance, nextTick, normalizeClass, normalizeStyle, onActivated, onAddToFavorites, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onLoad, onMounted, onMoved, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onRouteDone, onSaveExitState, onScopeDispose, onServerPrefetch, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, prelinkReactiveTree, provide, provideGlobal, reactive, readonly, ref, registerApp, registerComponent, removeMutationRecorder, resetWevuDefaults, runSetupFunction, setCurrentInstance, setCurrentSetupContext, setDeepWatchStrategy, setWevuDefaults, shallowReactive, shallowRef, startBatch, stop, storeToRefs, teardownRuntimeInstance, toRaw, toRef, toRefs, touchReactive, traverse, triggerRef, unref, useAttrs, useBindModel, useModel, useSlots, watch, watchEffect, withDefaults };
|