wevu 1.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -5
- package/package.json +3 -15
- package/dist/compiler.cjs +0 -1
- package/dist/compiler.d.cts +0 -26
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +0 -1198
- package/dist/jsx-runtime.cjs +0 -0
- package/dist/jsx-runtime.d.cts +0 -586
package/dist/index.d.cts
DELETED
|
@@ -1,1198 +0,0 @@
|
|
|
1
|
-
import { Ref as Ref$1 } from "@vue/reactivity";
|
|
2
|
-
import { AllowedComponentProps, ComponentCustomProps, ComponentOptionsMixin, DefineComponent, ObjectDirective, PublicProps, ShallowUnwrapRef, VNode, VNodeProps } from "vue";
|
|
3
|
-
|
|
4
|
-
//#region src/reactivity/ref.d.ts
|
|
5
|
-
type Ref<T$1 = any, S = T$1> = Ref$1<T$1, S>;
|
|
6
|
-
declare function isRef(value: unknown): value is Ref<any>;
|
|
7
|
-
declare function ref<T$1>(value: T$1): Ref<T$1>;
|
|
8
|
-
declare function unref<T$1>(value: T$1 | Ref<T$1>): T$1;
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/reactivity/computed.d.ts
|
|
11
|
-
type ComputedGetter<T$1> = () => T$1;
|
|
12
|
-
type ComputedSetter<T$1> = (value: T$1) => void;
|
|
13
|
-
interface BaseComputedRef<T$1, S = T$1> extends Ref<T$1, S> {
|
|
14
|
-
[key: symbol]: any;
|
|
15
|
-
}
|
|
16
|
-
interface ComputedRef<T$1 = any> extends BaseComputedRef<T$1> {
|
|
17
|
-
readonly value: T$1;
|
|
18
|
-
}
|
|
19
|
-
interface WritableComputedRef<T$1, S = T$1> extends BaseComputedRef<T$1, S> {
|
|
20
|
-
value: T$1;
|
|
21
|
-
}
|
|
22
|
-
interface WritableComputedOptions<T$1> {
|
|
23
|
-
get: ComputedGetter<T$1>;
|
|
24
|
-
set: ComputedSetter<T$1>;
|
|
25
|
-
}
|
|
26
|
-
declare function computed<T$1>(getter: ComputedGetter<T$1>): ComputedRef<T$1>;
|
|
27
|
-
declare function computed<T$1>(options: WritableComputedOptions<T$1>): WritableComputedRef<T$1>;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/scheduler.d.ts
|
|
30
|
-
declare function nextTick<T$1>(fn?: () => T$1): Promise<T$1>;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/reactivity/core.d.ts
|
|
33
|
-
type EffectScheduler = () => void;
|
|
34
|
-
type Dep = Set<ReactiveEffect>;
|
|
35
|
-
interface ReactiveEffect<T$1 = any> {
|
|
36
|
-
(): T$1;
|
|
37
|
-
deps: Dep[];
|
|
38
|
-
scheduler?: EffectScheduler;
|
|
39
|
-
active: boolean;
|
|
40
|
-
_running: boolean;
|
|
41
|
-
_fn: () => T$1;
|
|
42
|
-
onStop?: () => void;
|
|
43
|
-
}
|
|
44
|
-
declare function startBatch(): void;
|
|
45
|
-
declare function endBatch(): void;
|
|
46
|
-
declare function batch<T$1>(fn: () => T$1): T$1;
|
|
47
|
-
declare function stop(runner: ReactiveEffect): void;
|
|
48
|
-
interface EffectScope {
|
|
49
|
-
active: boolean;
|
|
50
|
-
effects: ReactiveEffect[];
|
|
51
|
-
cleanups: (() => void)[];
|
|
52
|
-
run: <T$1>(fn: () => T$1) => T$1 | undefined;
|
|
53
|
-
stop: () => void;
|
|
54
|
-
}
|
|
55
|
-
declare function effectScope(detached?: boolean): EffectScope;
|
|
56
|
-
declare function getCurrentScope(): EffectScope | undefined;
|
|
57
|
-
declare function onScopeDispose(fn: () => void): void;
|
|
58
|
-
interface EffectOptions {
|
|
59
|
-
scheduler?: EffectScheduler;
|
|
60
|
-
lazy?: boolean;
|
|
61
|
-
onStop?: () => void;
|
|
62
|
-
}
|
|
63
|
-
declare function effect<T$1 = any>(fn: () => T$1, options?: EffectOptions): ReactiveEffect<T$1>;
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/reactivity/reactive/mutation.d.ts
|
|
66
|
-
type MutationOp = 'set' | 'delete';
|
|
67
|
-
type MutationKind = 'property' | 'array';
|
|
68
|
-
interface MutationRecord {
|
|
69
|
-
root: object;
|
|
70
|
-
kind: MutationKind;
|
|
71
|
-
op: MutationOp;
|
|
72
|
-
/**
|
|
73
|
-
* dot path (e.g. `a.b.c`); undefined when path is not reliable.
|
|
74
|
-
*/
|
|
75
|
-
path?: string;
|
|
76
|
-
/**
|
|
77
|
-
* Top-level keys to fallback when path is not unique.
|
|
78
|
-
*/
|
|
79
|
-
fallbackTopKeys?: string[];
|
|
80
|
-
}
|
|
81
|
-
type MutationRecorder = (record: MutationRecord) => void;
|
|
82
|
-
declare function addMutationRecorder(recorder: MutationRecorder): void;
|
|
83
|
-
declare function removeMutationRecorder(recorder: MutationRecorder): void;
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/reactivity/reactive/patch.d.ts
|
|
86
|
-
interface PrelinkReactiveTreeOptions {
|
|
87
|
-
shouldIncludeTopKey?: (key: string) => boolean;
|
|
88
|
-
maxDepth?: number;
|
|
89
|
-
maxKeys?: number;
|
|
90
|
-
}
|
|
91
|
-
declare function prelinkReactiveTree(root: object, options?: PrelinkReactiveTreeOptions): void;
|
|
92
|
-
/**
|
|
93
|
-
* 让 effect 订阅整个对象的“版本号”,无需深度遍历即可对任何字段变化做出响应。
|
|
94
|
-
*/
|
|
95
|
-
declare function touchReactive(target: object): void;
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/reactivity/reactive/shallow.d.ts
|
|
98
|
-
/**
|
|
99
|
-
* 创建一个浅层响应式代理:仅跟踪第一层属性变更,不深度递归嵌套对象。
|
|
100
|
-
*
|
|
101
|
-
* @param target 待转换的对象
|
|
102
|
-
* @returns 浅层响应式代理
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* const state = shallowReactive({ nested: { count: 0 } })
|
|
107
|
-
*
|
|
108
|
-
* state.nested.count++ // 不会触发 effect(嵌套对象未深度代理)
|
|
109
|
-
* state.nested = { count: 1 } // 会触发 effect(顶层属性变更)
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
declare function shallowReactive<T$1 extends object>(target: T$1): T$1;
|
|
113
|
-
/**
|
|
114
|
-
* 判断一个值是否为 shallowReactive 创建的浅层响应式对象
|
|
115
|
-
*/
|
|
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;
|
|
125
|
-
/**
|
|
126
|
-
* 标记对象为“原始”状态,后续不会被转换为响应式,返回原对象本身。
|
|
127
|
-
*
|
|
128
|
-
* @param value 需要标记的对象
|
|
129
|
-
* @returns 带有跳过标记的原对象
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* ```ts
|
|
133
|
-
* const foo = markRaw({
|
|
134
|
-
* nested: {}
|
|
135
|
-
* })
|
|
136
|
-
*
|
|
137
|
-
* const state = reactive({
|
|
138
|
-
* foo
|
|
139
|
-
* })
|
|
140
|
-
*
|
|
141
|
-
* state.foo // 不是响应式对象
|
|
142
|
-
* ```
|
|
143
|
-
*/
|
|
144
|
-
declare function markRaw<T$1 extends object>(value: T$1): T$1;
|
|
145
|
-
/**
|
|
146
|
-
* 判断某个值是否被标记为原始(即不应转换为响应式)。
|
|
147
|
-
*
|
|
148
|
-
* @param value 待检测的值
|
|
149
|
-
* @returns 若含有跳过标记则返回 true
|
|
150
|
-
*/
|
|
151
|
-
declare function isRaw(value: unknown): boolean;
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/reactivity/readonly.d.ts
|
|
154
|
-
/**
|
|
155
|
-
* readonly 会为对象/数组创建一个“浅层”只读代理,并为 Ref 创建只读包装。
|
|
156
|
-
* 选择浅层而非深层递归,是为了在小程序环境中保持实现和运行时开销最小,
|
|
157
|
-
* 仅阻止直接属性写入/删除,嵌套对象仍按原样透传。
|
|
158
|
-
*/
|
|
159
|
-
declare function readonly<T$1 extends object>(target: T$1): T$1;
|
|
160
|
-
declare function readonly<T$1>(target: Ref<T$1>): Readonly<Ref<T$1>>;
|
|
161
|
-
//#endregion
|
|
162
|
-
//#region src/reactivity/shallowRef.d.ts
|
|
163
|
-
declare function shallowRef<T$1>(value: T$1): Ref<T$1>;
|
|
164
|
-
declare function shallowRef<T$1>(value: T$1, defaultValue: T$1): Ref<T$1>;
|
|
165
|
-
/**
|
|
166
|
-
* 判断传入值是否为浅层 ref。
|
|
167
|
-
*
|
|
168
|
-
* @param r 待判断的值
|
|
169
|
-
* @returns 若为浅层 ref 则返回 true
|
|
170
|
-
*/
|
|
171
|
-
declare function isShallowRef(r: any): r is Ref<any>;
|
|
172
|
-
/**
|
|
173
|
-
* 主动触发一次浅层 ref 的更新(无需深度比较)。
|
|
174
|
-
*
|
|
175
|
-
* @param ref 需要触发的 ref
|
|
176
|
-
*/
|
|
177
|
-
declare function triggerRef<T$1>(ref: Ref<T$1>): void;
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/reactivity/toRefs.d.ts
|
|
180
|
-
/**
|
|
181
|
-
* 为源响应式对象的单个属性创建 ref,可读可写并与原属性保持同步。
|
|
182
|
-
*
|
|
183
|
-
* @param object 源响应式对象
|
|
184
|
-
* @param key 属性名
|
|
185
|
-
* @returns 指向该属性的 ref
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```ts
|
|
189
|
-
* const state = reactive({ foo: 1 })
|
|
190
|
-
* const fooRef = toRef(state, 'foo')
|
|
191
|
-
*
|
|
192
|
-
* fooRef.value++
|
|
193
|
-
* console.log(state.foo) // 2
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
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]>;
|
|
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>;
|
|
214
|
-
/**
|
|
215
|
-
* toRefs 返回值的类型辅助
|
|
216
|
-
*/
|
|
217
|
-
type ToRefs<T$1 extends object> = { [K in keyof T$1]: Ref<T$1[K]> };
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region src/reactivity/traverse.d.ts
|
|
220
|
-
declare function traverse(value: any, seen?: Set<object>): any;
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/reactivity/watch.d.ts
|
|
223
|
-
interface WatchOptions {
|
|
224
|
-
immediate?: boolean;
|
|
225
|
-
deep?: boolean;
|
|
226
|
-
}
|
|
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]>>;
|
|
231
|
-
type WatchStopHandle = () => void;
|
|
232
|
-
type DeepWatchStrategy = 'version' | 'traverse';
|
|
233
|
-
declare function setDeepWatchStrategy(strategy: DeepWatchStrategy): void;
|
|
234
|
-
declare function getDeepWatchStrategy(): DeepWatchStrategy;
|
|
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;
|
|
238
|
-
/**
|
|
239
|
-
* watchEffect 注册一个响应式副作用,可选清理函数。
|
|
240
|
-
* 副作用会立即执行,并在依赖变化时重新运行。
|
|
241
|
-
*/
|
|
242
|
-
declare function watchEffect(effectFn: (onCleanup: (cleanupFn: () => void) => void) => void): WatchStopHandle;
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/runtime/types/core.d.ts
|
|
245
|
-
type ComputedDefinitions = Record<string, ComputedGetter<any> | WritableComputedOptions<any>>;
|
|
246
|
-
type MethodDefinitions = Record<string, (...args: any[]) => any>;
|
|
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 };
|
|
248
|
-
type ExtractMethods<M extends MethodDefinitions> = { [K in keyof M]: M[K] extends ((...args: infer P) => infer R) ? (...args: P) => R : never };
|
|
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;
|
|
257
|
-
}
|
|
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>;
|
|
263
|
-
}
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/runtime/types/miniprogram.d.ts
|
|
266
|
-
interface MiniProgramAdapter {
|
|
267
|
-
setData?: (payload: Record<string, any>) => void | Promise<void>;
|
|
268
|
-
}
|
|
269
|
-
type MiniProgramComponentBehaviorOptions = WechatMiniprogram.Component.ComponentOptions;
|
|
270
|
-
type MpComponentOptions = WechatMiniprogram.Component.TrivialOption;
|
|
271
|
-
type MiniProgramBehaviorIdentifier = WechatMiniprogram.Behavior.BehaviorIdentifier | string;
|
|
272
|
-
interface MiniProgramComponentOptions {
|
|
273
|
-
/**
|
|
274
|
-
* 类似于 mixins/traits 的组件间代码复用机制(behaviors)。
|
|
275
|
-
*/
|
|
276
|
-
behaviors?: MiniProgramBehaviorIdentifier[];
|
|
277
|
-
/**
|
|
278
|
-
* 组件接受的外部样式类。
|
|
279
|
-
*/
|
|
280
|
-
externalClasses?: MpComponentOptions['externalClasses'];
|
|
281
|
-
/**
|
|
282
|
-
* 组件间关系定义。
|
|
283
|
-
*/
|
|
284
|
-
relations?: MpComponentOptions['relations'];
|
|
285
|
-
/**
|
|
286
|
-
* 组件数据字段监听器,用于监听 properties 和 data 的变化。
|
|
287
|
-
*/
|
|
288
|
-
observers?: MpComponentOptions['observers'];
|
|
289
|
-
/**
|
|
290
|
-
* 组件生命周期声明对象:
|
|
291
|
-
* `created`/`attached`/`ready`/`moved`/`detached`/`error`。
|
|
292
|
-
*
|
|
293
|
-
* 注意:wevu 会在 `attached/ready/detached/moved/error` 阶段做桥接与包装,
|
|
294
|
-
* 但 `created` 发生在 setup() 之前。
|
|
295
|
-
*/
|
|
296
|
-
lifetimes?: MpComponentOptions['lifetimes'];
|
|
297
|
-
/**
|
|
298
|
-
* 组件所在页面的生命周期声明对象:`show`/`hide`/`resize`/`routeDone`。
|
|
299
|
-
*/
|
|
300
|
-
pageLifetimes?: MpComponentOptions['pageLifetimes'];
|
|
301
|
-
/**
|
|
302
|
-
* 组件选项(multipleSlots/styleIsolation/pureDataPattern/virtualHost 等)。
|
|
303
|
-
*/
|
|
304
|
-
options?: MpComponentOptions['options'];
|
|
305
|
-
/**
|
|
306
|
-
* 定义段过滤器,用于自定义组件扩展。
|
|
307
|
-
*/
|
|
308
|
-
definitionFilter?: MpComponentOptions['definitionFilter'];
|
|
309
|
-
/**
|
|
310
|
-
* 组件自定义导出:当使用 `behavior: wx://component-export` 时,
|
|
311
|
-
* 可用于指定组件被 selectComponent 调用时的返回值。
|
|
312
|
-
*
|
|
313
|
-
* wevu 默认会将 setup() 中通过 `expose()` 写入的内容作为 export() 返回值,
|
|
314
|
-
* 因此大多数情况下无需手动编写 export();若同时提供 export(),则会与 expose() 结果浅合并。
|
|
315
|
-
*/
|
|
316
|
-
export?: MpComponentOptions['export'];
|
|
317
|
-
/**
|
|
318
|
-
* 原生 properties(与 wevu 的 props 不同)。
|
|
319
|
-
*
|
|
320
|
-
* - 推荐:使用 wevu 的 `props` 选项,让运行时规范化为小程序 `properties`。
|
|
321
|
-
* - 兼容:也可以直接传入小程序 `properties`。
|
|
322
|
-
*/
|
|
323
|
-
properties?: MpComponentOptions['properties'];
|
|
324
|
-
/**
|
|
325
|
-
* 旧式生命周期(基础库 `2.2.3` 起推荐使用 `lifetimes` 字段)。
|
|
326
|
-
* 保留以增强类型提示与兼容性。
|
|
327
|
-
*/
|
|
328
|
-
created?: MpComponentOptions['created'];
|
|
329
|
-
attached?: MpComponentOptions['attached'];
|
|
330
|
-
ready?: MpComponentOptions['ready'];
|
|
331
|
-
moved?: MpComponentOptions['moved'];
|
|
332
|
-
detached?: MpComponentOptions['detached'];
|
|
333
|
-
error?: MpComponentOptions['error'];
|
|
334
|
-
}
|
|
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
|
|
344
|
-
interface AppConfig {
|
|
345
|
-
globalProperties: Record<string, any>;
|
|
346
|
-
}
|
|
347
|
-
type WevuPlugin = ((app: RuntimeApp<any, any, any>, ...options: any[]) => any) | {
|
|
348
|
-
install: (app: RuntimeApp<any, any, any>, ...options: any[]) => any;
|
|
349
|
-
};
|
|
350
|
-
interface RuntimeApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> {
|
|
351
|
-
mount: (adapter?: MiniProgramAdapter) => RuntimeInstance<D, C, M>;
|
|
352
|
-
use: (plugin: WevuPlugin, ...options: any[]) => RuntimeApp<D, C, M>;
|
|
353
|
-
config: AppConfig;
|
|
354
|
-
}
|
|
355
|
-
interface RuntimeInstance<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> {
|
|
356
|
-
readonly state: D;
|
|
357
|
-
readonly proxy: ComponentPublicInstance<D, C, M>;
|
|
358
|
-
readonly methods: ExtractMethods<M>;
|
|
359
|
-
readonly computed: Readonly<ExtractComputed<C>>;
|
|
360
|
-
readonly adapter?: MiniProgramAdapter;
|
|
361
|
-
bindModel: <T$1 = any>(path: string, options?: ModelBindingOptions<T$1>) => ModelBinding<T$1>;
|
|
362
|
-
watch: <T$1>(source: (() => T$1) | Record<string, any>, cb: (value: T$1, oldValue: T$1) => void, options?: WatchOptions) => WatchStopHandle;
|
|
363
|
-
snapshot: () => Record<string, any>;
|
|
364
|
-
unmount: () => void;
|
|
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
|
|
376
|
-
type PropMethod<T$1, TConstructor = any> = [T$1] extends [((...args: any) => any) | undefined] ? {
|
|
377
|
-
new (): TConstructor;
|
|
378
|
-
(): T$1;
|
|
379
|
-
readonly prototype: TConstructor;
|
|
380
|
-
} : never;
|
|
381
|
-
type PropConstructor<T$1 = any> = {
|
|
382
|
-
new (...args: any[]): T$1 & object;
|
|
383
|
-
} | {
|
|
384
|
-
(): T$1;
|
|
385
|
-
} | PropMethod<T$1>;
|
|
386
|
-
type PropType<T$1> = PropConstructor<T$1> | PropConstructor<T$1>[];
|
|
387
|
-
type ComponentPropsOptions = Record<string, PropOptions<any> | PropType<any> | null>;
|
|
388
|
-
interface PropOptions<T$1 = any> {
|
|
389
|
-
type?: PropType<T$1> | true | null;
|
|
390
|
-
/**
|
|
391
|
-
* 默认值(对齐 Vue 的 `default`;会被赋给小程序 property 的 `value`)
|
|
392
|
-
*/
|
|
393
|
-
default?: T$1 | (() => T$1);
|
|
394
|
-
/**
|
|
395
|
-
* 小程序 `value` 的别名
|
|
396
|
-
*/
|
|
397
|
-
value?: T$1 | (() => T$1);
|
|
398
|
-
required?: boolean;
|
|
399
|
-
}
|
|
400
|
-
type HasDefault<T$1> = T$1 extends {
|
|
401
|
-
default: infer D;
|
|
402
|
-
} ? D extends (() => undefined) | undefined ? false : true : T$1 extends {
|
|
403
|
-
value: infer V;
|
|
404
|
-
} ? V extends (() => undefined) | undefined ? false : true : false;
|
|
405
|
-
type IsBooleanProp<T$1> = T$1 extends {
|
|
406
|
-
type?: infer U;
|
|
407
|
-
} ? IsBooleanProp<U> : T$1 extends readonly any[] ? true extends IsBooleanProp<T$1[number]> ? true : false : T$1 extends BooleanConstructor ? true : false;
|
|
408
|
-
type RequiredKeys<T$1> = { [K in keyof T$1]: T$1[K] extends {
|
|
409
|
-
required: true;
|
|
410
|
-
} ? K : HasDefault<T$1[K]> extends true ? K : IsBooleanProp<T$1[K]> extends true ? K : never }[keyof T$1];
|
|
411
|
-
type OptionalKeys<T$1> = Exclude<keyof T$1, RequiredKeys<T$1>>;
|
|
412
|
-
type InferPropType<O> = O extends null ? any : O extends {
|
|
413
|
-
type?: infer T;
|
|
414
|
-
} ? InferPropConstructor<T> : O extends PropType<infer V> ? V : InferPropConstructor<O>;
|
|
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;
|
|
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>;
|
|
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;
|
|
420
|
-
interface SetupContext<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions, P$1 extends ComponentPropsOptions = ComponentPropsOptions> {
|
|
421
|
-
/**
|
|
422
|
-
* 组件 props(来自小程序 properties)
|
|
423
|
-
*/
|
|
424
|
-
props: InferProps<P$1>;
|
|
425
|
-
/**
|
|
426
|
-
* 运行时实例
|
|
427
|
-
*/
|
|
428
|
-
runtime: RuntimeInstance<D, C, M>;
|
|
429
|
-
/**
|
|
430
|
-
* 响应式状态
|
|
431
|
-
*/
|
|
432
|
-
state: D;
|
|
433
|
-
/**
|
|
434
|
-
* 公开实例代理
|
|
435
|
-
*/
|
|
436
|
-
proxy: RuntimeInstance<D, C, M>['proxy'];
|
|
437
|
-
/**
|
|
438
|
-
* 双向绑定辅助方法
|
|
439
|
-
*/
|
|
440
|
-
bindModel: RuntimeInstance<D, C, M>['bindModel'];
|
|
441
|
-
/**
|
|
442
|
-
* watch 辅助方法
|
|
443
|
-
*/
|
|
444
|
-
watch: RuntimeInstance<D, C, M>['watch'];
|
|
445
|
-
/**
|
|
446
|
-
* 小程序内部实例
|
|
447
|
-
*/
|
|
448
|
-
instance: InternalRuntimeState;
|
|
449
|
-
/**
|
|
450
|
-
* 通过小程序 `triggerEvent(eventName, detail?, options?)` 派发事件。
|
|
451
|
-
*
|
|
452
|
-
* 注意:不同于 Vue 3 的 `emit(event, ...args)`,小程序事件只携带一个 `detail` 载荷;
|
|
453
|
-
* `options` 用于控制事件传播行为(`bubbles`/`composed`/`capturePhase`)。
|
|
454
|
-
*/
|
|
455
|
-
emit: (event: string, detail?: any, options?: TriggerEventOptions) => void;
|
|
456
|
-
/**
|
|
457
|
-
* Vue 3 对齐:expose 公共属性
|
|
458
|
-
*/
|
|
459
|
-
expose: (exposed: Record<string, any>) => void;
|
|
460
|
-
/**
|
|
461
|
-
* Vue 3 对齐:attrs(小程序场景兜底为空对象)
|
|
462
|
-
*/
|
|
463
|
-
attrs: Record<string, any>;
|
|
464
|
-
/**
|
|
465
|
-
* Vue 3 对齐:slots(小程序场景兜底为空对象)
|
|
466
|
-
*/
|
|
467
|
-
slots: Record<string, any>;
|
|
468
|
-
}
|
|
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;
|
|
571
|
-
}
|
|
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
|
|
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 {
|
|
585
|
-
/**
|
|
586
|
-
* 页面特性开关(用于按需注入 Page 事件处理函数)。
|
|
587
|
-
*
|
|
588
|
-
* 说明:小程序的部分页面事件/菜单项具有“按需派发/按需展示”特性,
|
|
589
|
-
* 只有定义了对应的 `onXXX` 方法才会触发/展示(如 `onPageScroll`、`onShareTimeline`)。
|
|
590
|
-
* 因此 wevu 需要在注册阶段(Component())就决定是否注入这些 onXXX。
|
|
591
|
-
*
|
|
592
|
-
* - 若你在 options 中显式定义了原生 `onXXX`,wevu 会自动桥接对应 hook(无需 features)。
|
|
593
|
-
* - 若你只想在 `setup()` 里使用 wevu hook(不额外写原生 `onXXX`),则通过 `features` 显式开启注入。
|
|
594
|
-
*/
|
|
595
|
-
features?: PageFeatures;
|
|
596
|
-
/**
|
|
597
|
-
* 类 Vue 的 props 定义(会被规范化为小程序 `properties`)
|
|
598
|
-
*/
|
|
599
|
-
props?: P$1;
|
|
600
|
-
watch?: Record<string, any>;
|
|
601
|
-
setup?: SetupFunction<P$1, D, C, M>;
|
|
602
|
-
/**
|
|
603
|
-
* 组件 data(建议使用函数返回初始值)。
|
|
604
|
-
*/
|
|
605
|
-
data?: () => D;
|
|
606
|
-
/**
|
|
607
|
-
* 组件 computed(会参与快照 diff)。
|
|
608
|
-
*/
|
|
609
|
-
computed?: C;
|
|
610
|
-
/**
|
|
611
|
-
* setData 快照控制选项(用于优化性能与 payload)。
|
|
612
|
-
*/
|
|
613
|
-
setData?: SetDataSnapshotOptions;
|
|
614
|
-
/**
|
|
615
|
-
* 组件 methods(会绑定到 public instance 上)。
|
|
616
|
-
*/
|
|
617
|
-
methods?: M;
|
|
618
|
-
/**
|
|
619
|
-
* 透传/扩展字段:允许携带其他小程序原生 Component 选项或自定义字段。
|
|
620
|
-
* 说明:为保持兼容性保留 index signature,但仍会对已知字段提供智能提示。
|
|
621
|
-
*/
|
|
622
|
-
[key: string]: any;
|
|
623
|
-
}
|
|
624
|
-
interface DefineAppOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> extends MiniProgramAppOptions {
|
|
625
|
-
watch?: Record<string, any>;
|
|
626
|
-
setup?: (ctx: SetupContext<D, C, M>) => Record<string, any> | void;
|
|
627
|
-
[key: string]: any;
|
|
628
|
-
}
|
|
629
|
-
interface CreateAppOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> extends MiniProgramAppOptions {
|
|
630
|
-
data?: () => D;
|
|
631
|
-
computed?: C;
|
|
632
|
-
methods?: M;
|
|
633
|
-
setData?: SetDataSnapshotOptions;
|
|
634
|
-
watch?: Record<string, any>;
|
|
635
|
-
setup?: (ctx: SetupContext<D, C, M>) => Record<string, any> | void;
|
|
636
|
-
[key: string]: any;
|
|
637
|
-
}
|
|
638
|
-
interface PageFeatures {
|
|
639
|
-
/**
|
|
640
|
-
* 启用页面滚动事件(注入 `onPageScroll`)。
|
|
641
|
-
*/
|
|
642
|
-
enableOnPageScroll?: boolean;
|
|
643
|
-
/**
|
|
644
|
-
* 启用下拉刷新事件(注入 `onPullDownRefresh`;仍需在页面配置开启 enablePullDownRefresh)。
|
|
645
|
-
*/
|
|
646
|
-
enableOnPullDownRefresh?: boolean;
|
|
647
|
-
/**
|
|
648
|
-
* 启用触底事件(注入 `onReachBottom`)。
|
|
649
|
-
*/
|
|
650
|
-
enableOnReachBottom?: boolean;
|
|
651
|
-
/**
|
|
652
|
-
* 启用路由动画完成事件(注入 `onRouteDone`)。
|
|
653
|
-
*/
|
|
654
|
-
enableOnRouteDone?: boolean;
|
|
655
|
-
/**
|
|
656
|
-
* 启用 Tab 点击事件(注入 `onTabItemTap`)。
|
|
657
|
-
*/
|
|
658
|
-
enableOnTabItemTap?: boolean;
|
|
659
|
-
/**
|
|
660
|
-
* 启用窗口尺寸变化事件(注入 `onResize`)。
|
|
661
|
-
*/
|
|
662
|
-
enableOnResize?: boolean;
|
|
663
|
-
/**
|
|
664
|
-
* 启用“转发/分享给朋友”(注入 `onShareAppMessage`,使右上角菜单显示“转发”)。
|
|
665
|
-
*/
|
|
666
|
-
enableOnShareAppMessage?: boolean;
|
|
667
|
-
/**
|
|
668
|
-
* 启用“分享到朋友圈”(注入 `onShareTimeline`,使右上角菜单显示“分享到朋友圈”)。
|
|
669
|
-
*/
|
|
670
|
-
enableOnShareTimeline?: boolean;
|
|
671
|
-
/**
|
|
672
|
-
* 启用“收藏”(注入 `onAddToFavorites`)。
|
|
673
|
-
*/
|
|
674
|
-
enableOnAddToFavorites?: boolean;
|
|
675
|
-
/**
|
|
676
|
-
* 启用“退出状态保存”(注入 `onSaveExitState`)。
|
|
677
|
-
*/
|
|
678
|
-
enableOnSaveExitState?: boolean;
|
|
679
|
-
}
|
|
680
|
-
//#endregion
|
|
681
|
-
//#region src/runtime/types.d.ts
|
|
682
|
-
interface GlobalComponents {}
|
|
683
|
-
interface GlobalDirectives {}
|
|
684
|
-
//#endregion
|
|
685
|
-
//#region src/runtime/app.d.ts
|
|
686
|
-
declare function createApp<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: CreateAppOptions<D, C, M>): RuntimeApp<D, C, M>;
|
|
687
|
-
//#endregion
|
|
688
|
-
//#region src/runtime/defaults.d.ts
|
|
689
|
-
interface WevuDefaults {
|
|
690
|
-
app?: Partial<CreateAppOptions<any, any, any>>;
|
|
691
|
-
component?: Partial<DefineComponentOptions<any, any, any, any>>;
|
|
692
|
-
}
|
|
693
|
-
declare function setWevuDefaults(next: WevuDefaults): void;
|
|
694
|
-
declare function resetWevuDefaults(): void;
|
|
695
|
-
//#endregion
|
|
696
|
-
//#region src/runtime/define.d.ts
|
|
697
|
-
/**
|
|
698
|
-
* defineComponent 返回的组件定义描述,用于手动注册或高级用法。
|
|
699
|
-
*/
|
|
700
|
-
interface ComponentDefinition<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions> {
|
|
701
|
-
/**
|
|
702
|
-
* 内部 runtime app(高级能力使用),不对外暴露正式 API。
|
|
703
|
-
* @internal
|
|
704
|
-
*/
|
|
705
|
-
__wevu_runtime: RuntimeApp<D, C, M>;
|
|
706
|
-
/**
|
|
707
|
-
* 内部选项快照(高级能力使用),包含 data/computed/methods 等。
|
|
708
|
-
* @internal
|
|
709
|
-
*/
|
|
710
|
-
__wevu_options: {
|
|
711
|
-
data: () => D;
|
|
712
|
-
computed: C;
|
|
713
|
-
methods: M;
|
|
714
|
-
setData: SetDataSnapshotOptions | undefined;
|
|
715
|
-
watch: Record<string, any> | undefined;
|
|
716
|
-
setup: DefineComponentOptions<ComponentPropsOptions, D, C, M>['setup'];
|
|
717
|
-
mpOptions: MiniProgramComponentRawOptions;
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
/**
|
|
721
|
-
* 按 Vue 3 风格定义一个小程序组件/页面。
|
|
722
|
-
*
|
|
723
|
-
* - 统一注册为 `Component()`
|
|
724
|
-
*
|
|
725
|
-
* @param options 组件定义项
|
|
726
|
-
* @returns 可手动注册的组件定义
|
|
727
|
-
*
|
|
728
|
-
* @example
|
|
729
|
-
* ```ts
|
|
730
|
-
* defineComponent({
|
|
731
|
-
* data: () => ({ count: 0 }),
|
|
732
|
-
* setup() {
|
|
733
|
-
* onMounted(() => console.log('已挂载'))
|
|
734
|
-
* }
|
|
735
|
-
* })
|
|
736
|
-
* ```
|
|
737
|
-
*
|
|
738
|
-
* @example
|
|
739
|
-
* ```ts
|
|
740
|
-
* defineComponent({
|
|
741
|
-
* setup() {
|
|
742
|
-
* onPageScroll(() => {})
|
|
743
|
-
* }
|
|
744
|
-
* })
|
|
745
|
-
* ```
|
|
746
|
-
*/
|
|
747
|
-
declare function defineComponent<P$1 extends ComponentPropsOptions = ComponentPropsOptions, D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions>(options: DefineComponentOptions<P$1, D, C, M>): ComponentDefinition<D, C, M>;
|
|
748
|
-
/**
|
|
749
|
-
* 从 Vue SFC 选项创建 wevu 组件,供 weapp-vite 编译产物直接调用的兼容入口。
|
|
750
|
-
*
|
|
751
|
-
* @param options 组件选项,可能包含小程序特有的 properties
|
|
752
|
-
*/
|
|
753
|
-
declare function createWevuComponent<D extends object, C extends ComputedDefinitions, M extends MethodDefinitions>(options: DefineComponentOptions<ComponentPropsOptions, D, C, M> & {
|
|
754
|
-
properties?: WechatMiniprogram.Component.PropertyOption;
|
|
755
|
-
}): void;
|
|
756
|
-
declare function createWevuScopedSlotComponent(overrides?: {
|
|
757
|
-
computed?: ComputedDefinitions;
|
|
758
|
-
}): void;
|
|
759
|
-
//#endregion
|
|
760
|
-
//#region src/runtime/hooks.d.ts
|
|
761
|
-
declare function getCurrentInstance<T$1 extends InternalRuntimeState = InternalRuntimeState>(): T$1 | undefined;
|
|
762
|
-
declare function setCurrentInstance(inst: InternalRuntimeState | undefined): void;
|
|
763
|
-
declare function getCurrentSetupContext<T$1 = any>(): T$1 | undefined;
|
|
764
|
-
declare function setCurrentSetupContext(ctx: any | undefined): void;
|
|
765
|
-
declare function callHookList(target: InternalRuntimeState, name: string, args?: any[]): void;
|
|
766
|
-
declare function callHookReturn(target: InternalRuntimeState, name: string, args?: any[]): any;
|
|
767
|
-
declare function onLaunch(handler: (options: WechatMiniprogram.App.LaunchShowOption) => void): void;
|
|
768
|
-
declare function onPageNotFound(handler: (options: WechatMiniprogram.App.PageNotFoundOption) => void): void;
|
|
769
|
-
declare function onUnhandledRejection(handler: WechatMiniprogram.OnUnhandledRejectionCallback): void;
|
|
770
|
-
declare function onThemeChange(handler: WechatMiniprogram.OnThemeChangeCallback): void;
|
|
771
|
-
declare function onShow(handler: () => void): void;
|
|
772
|
-
declare function onShow(handler: (options: WechatMiniprogram.App.LaunchShowOption) => void): void;
|
|
773
|
-
declare function onLoad(handler: WechatMiniprogram.Page.ILifetime['onLoad']): void;
|
|
774
|
-
declare function onHide(handler: () => void): void;
|
|
775
|
-
declare function onUnload(handler: () => void): void;
|
|
776
|
-
declare function onReady(handler: () => void): void;
|
|
777
|
-
declare function onPullDownRefresh(handler: WechatMiniprogram.Page.ILifetime['onPullDownRefresh']): void;
|
|
778
|
-
declare function onReachBottom(handler: WechatMiniprogram.Page.ILifetime['onReachBottom']): void;
|
|
779
|
-
declare function onPageScroll(handler: (opt: WechatMiniprogram.Page.IPageScrollOption) => void): void;
|
|
780
|
-
declare function onRouteDone(handler: WechatMiniprogram.Page.ILifetime['onRouteDone'] | ((opt?: unknown) => void)): void;
|
|
781
|
-
declare function onTabItemTap(handler: (opt: WechatMiniprogram.Page.ITabItemTapOption) => void): void;
|
|
782
|
-
declare function onResize(handler: (opt: WechatMiniprogram.Page.IResizeOption) => void): void;
|
|
783
|
-
declare function onMoved(handler: () => void): void;
|
|
784
|
-
declare function onError(handler: (err: any) => void): void;
|
|
785
|
-
declare function onSaveExitState(handler: () => WechatMiniprogram.Page.ISaveExitState): void;
|
|
786
|
-
declare function onShareAppMessage(handler: WechatMiniprogram.Page.ILifetime['onShareAppMessage']): void;
|
|
787
|
-
declare function onShareTimeline(handler: WechatMiniprogram.Page.ILifetime['onShareTimeline']): void;
|
|
788
|
-
declare function onAddToFavorites(handler: WechatMiniprogram.Page.ILifetime['onAddToFavorites']): void;
|
|
789
|
-
/**
|
|
790
|
-
* Vue 3 对齐:组件/页面已挂载,映射小程序 onReady
|
|
791
|
-
*/
|
|
792
|
-
declare function onMounted(handler: () => void): void;
|
|
793
|
-
/**
|
|
794
|
-
* Vue 3 对齐:组件/页面更新后触发。
|
|
795
|
-
* 小程序没有专用 update 生命周期,这里在每次 setData 完成后调用。
|
|
796
|
-
*/
|
|
797
|
-
declare function onUpdated(handler: () => void): void;
|
|
798
|
-
/**
|
|
799
|
-
* Vue 3 对齐:卸载前触发。
|
|
800
|
-
* 小程序无 before-unload 生命周期,setup 时同步执行以保持语义。
|
|
801
|
-
*/
|
|
802
|
-
declare function onBeforeUnmount(handler: () => void): void;
|
|
803
|
-
/**
|
|
804
|
-
* Vue 3 对齐:组件/页面卸载;映射到页面 onUnload 或组件 detached
|
|
805
|
-
*/
|
|
806
|
-
declare function onUnmounted(handler: () => void): void;
|
|
807
|
-
/**
|
|
808
|
-
* Vue 3 对齐:挂载前;setup 时同步触发以模拟 beforeMount 语义
|
|
809
|
-
*/
|
|
810
|
-
declare function onBeforeMount(handler: () => void): void;
|
|
811
|
-
/**
|
|
812
|
-
* Vue 3 对齐:更新前;在每次 setData 前触发
|
|
813
|
-
*/
|
|
814
|
-
declare function onBeforeUpdate(handler: () => void): void;
|
|
815
|
-
/**
|
|
816
|
-
* Vue 3 对齐:错误捕获;映射到小程序 onError
|
|
817
|
-
*/
|
|
818
|
-
declare function onErrorCaptured(handler: (err: any, instance: any, info: string) => void): void;
|
|
819
|
-
/**
|
|
820
|
-
* Vue 3 对齐:组件激活;映射到小程序 onShow
|
|
821
|
-
*/
|
|
822
|
-
declare function onActivated(handler: () => void): void;
|
|
823
|
-
/**
|
|
824
|
-
* Vue 3 对齐:组件失活;映射到小程序 onHide
|
|
825
|
-
*/
|
|
826
|
-
declare function onDeactivated(handler: () => void): void;
|
|
827
|
-
/**
|
|
828
|
-
* Vue 3 对齐:服务端渲染前置钩子。
|
|
829
|
-
* 小程序无此场景,保留空实现以保持 API 兼容。
|
|
830
|
-
*/
|
|
831
|
-
declare function onServerPrefetch(_handler: () => void): void;
|
|
832
|
-
declare function callUpdateHooks(target: InternalRuntimeState, phase: 'before' | 'after'): void;
|
|
833
|
-
//#endregion
|
|
834
|
-
//#region src/runtime/noSetData.d.ts
|
|
835
|
-
declare function markNoSetData<T$1 extends object>(value: T$1): T$1;
|
|
836
|
-
declare function isNoSetData(value: unknown): boolean;
|
|
837
|
-
//#endregion
|
|
838
|
-
//#region src/runtime/provide.d.ts
|
|
839
|
-
/**
|
|
840
|
-
* 在组件上下文中向后代注入值(与 Vue 3 行为兼容),若没有当前实例则回落到全局存储。
|
|
841
|
-
*
|
|
842
|
-
* @param key 注入键,可为字符串、Symbol 或对象
|
|
843
|
-
* @param value 提供的值
|
|
844
|
-
*
|
|
845
|
-
* @example
|
|
846
|
-
* ```ts
|
|
847
|
-
* defineComponent({
|
|
848
|
-
* setup() {
|
|
849
|
-
* provide(TOKEN_KEY, { data: 'value' })
|
|
850
|
-
* }
|
|
851
|
-
* })
|
|
852
|
-
* ```
|
|
853
|
-
*/
|
|
854
|
-
declare function provide<T$1>(key: any, value: T$1): void;
|
|
855
|
-
/**
|
|
856
|
-
* 从祖先组件(或全局存储)读取提供的值。
|
|
857
|
-
*
|
|
858
|
-
* @param key 注入键,需与 provide 使用的键保持一致
|
|
859
|
-
* @param defaultValue 未找到提供者时的默认值
|
|
860
|
-
* @returns 匹配到的值或默认值
|
|
861
|
-
*
|
|
862
|
-
* @example
|
|
863
|
-
* ```ts
|
|
864
|
-
* defineComponent({
|
|
865
|
-
* setup() {
|
|
866
|
-
* const data = inject(TOKEN_KEY)
|
|
867
|
-
* const value = inject('key', 'default')
|
|
868
|
-
* }
|
|
869
|
-
* })
|
|
870
|
-
* ```
|
|
871
|
-
*/
|
|
872
|
-
declare function inject<T$1>(key: any, defaultValue?: T$1): T$1;
|
|
873
|
-
/**
|
|
874
|
-
* 全局注入值,适用于组件外部调用场景。
|
|
875
|
-
*/
|
|
876
|
-
declare function provideGlobal<T$1>(key: any, value: T$1): void;
|
|
877
|
-
/**
|
|
878
|
-
* 从全局存储读取值,适用于组件外部调用场景。
|
|
879
|
-
*/
|
|
880
|
-
declare function injectGlobal<T$1>(key: any, defaultValue?: T$1): T$1;
|
|
881
|
-
//#endregion
|
|
882
|
-
//#region src/runtime/register/watch.d.ts
|
|
883
|
-
type WatchHandler = (this: any, value: any, oldValue: any) => void;
|
|
884
|
-
type WatchDescriptor = WatchHandler | string | {
|
|
885
|
-
handler: WatchHandler | string;
|
|
886
|
-
immediate?: boolean;
|
|
887
|
-
deep?: boolean;
|
|
888
|
-
};
|
|
889
|
-
type WatchMap = Record<string, WatchDescriptor>;
|
|
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?: {
|
|
900
|
-
deferSetData?: boolean;
|
|
901
|
-
}): RuntimeInstance<D, C, M>;
|
|
902
|
-
declare function teardownRuntimeInstance(target: InternalRuntimeState): void;
|
|
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;
|
|
911
|
-
//#endregion
|
|
912
|
-
//#region src/runtime/vueCompat.d.ts
|
|
913
|
-
declare function useAttrs(): Record<string, any>;
|
|
914
|
-
declare function useSlots(): Record<string, any>;
|
|
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>;
|
|
926
|
-
declare function mergeModels<T$1>(a: T$1, b: T$1): T$1;
|
|
927
|
-
//#endregion
|
|
928
|
-
//#region src/macros.d.ts
|
|
929
|
-
type Prettify<T$1> = { [K in keyof T$1]: T$1[K] } & {};
|
|
930
|
-
type LooseRequired<T$1> = { [P in keyof (T$1 & Required<T$1>)]: T$1[P] };
|
|
931
|
-
type IfAny<T$1, Y, N> = 0 extends 1 & T$1 ? Y : N;
|
|
932
|
-
type ComponentObjectPropsOptions = ComponentPropsOptions;
|
|
933
|
-
type ExtractPropTypes$1<P$1 extends ComponentObjectPropsOptions> = InferProps<P$1>;
|
|
934
|
-
type DefineProps<T$1, BKeys extends keyof T$1> = Readonly<T$1> & { readonly [K in BKeys]-?: boolean };
|
|
935
|
-
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;
|
|
936
|
-
/**
|
|
937
|
-
* wevu + Volar 类型检查使用的 script-setup 宏。
|
|
938
|
-
*
|
|
939
|
-
* 这些只是类型声明,运行时不存在。
|
|
940
|
-
* 请确保 `vueCompilerOptions.lib = "wevu"`,让 Volar 从本文件解析它们。
|
|
941
|
-
*
|
|
942
|
-
* 常见搭配示例(仅类型层):
|
|
943
|
-
* - defineProps + withDefaults:声明 Props 并补默认值
|
|
944
|
-
* - defineEmits:约束事件与负载类型
|
|
945
|
-
* - defineSlots:约束插槽与插槽参数
|
|
946
|
-
* - defineModel:声明双向绑定字段
|
|
947
|
-
*/
|
|
948
|
-
/**
|
|
949
|
-
* defineProps 数组语法。
|
|
950
|
-
*
|
|
951
|
-
* @example
|
|
952
|
-
* ```ts
|
|
953
|
-
* const props = defineProps(['title', 'count'])
|
|
954
|
-
* const { title } = defineProps(['title'])
|
|
955
|
-
* ```
|
|
956
|
-
*/
|
|
957
|
-
declare function defineProps<PropNames extends string = string>(props: PropNames[]): Prettify<Readonly<{ [key in PropNames]?: any }>>;
|
|
958
|
-
/**
|
|
959
|
-
* defineProps 运行时 props 配置。
|
|
960
|
-
*
|
|
961
|
-
* @example
|
|
962
|
-
* ```ts
|
|
963
|
-
* const props = defineProps({
|
|
964
|
-
* title: String,
|
|
965
|
-
* count: Number,
|
|
966
|
-
* active: Boolean,
|
|
967
|
-
* color: {
|
|
968
|
-
* type: String,
|
|
969
|
-
* default: 'red',
|
|
970
|
-
* },
|
|
971
|
-
* })
|
|
972
|
-
* ```
|
|
973
|
-
*/
|
|
974
|
-
declare function defineProps<PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions>(props: PP): Prettify<Readonly<ExtractPropTypes$1<PP>>>;
|
|
975
|
-
/**
|
|
976
|
-
* defineProps 泛型类型声明。
|
|
977
|
-
*
|
|
978
|
-
* @example
|
|
979
|
-
* ```ts
|
|
980
|
-
* const props = defineProps<{
|
|
981
|
-
* title?: string
|
|
982
|
-
* count: number
|
|
983
|
-
* active?: boolean
|
|
984
|
-
* }>()
|
|
985
|
-
*
|
|
986
|
-
* const props2 = defineProps<{
|
|
987
|
-
* size?: 'sm' | 'md' | 'lg'
|
|
988
|
-
* }>()
|
|
989
|
-
* ```
|
|
990
|
-
*/
|
|
991
|
-
declare function defineProps<TypeProps>(): DefineProps<LooseRequired<TypeProps>, BooleanKey<TypeProps>>;
|
|
992
|
-
type NotUndefined<T$1> = T$1 extends undefined ? never : T$1;
|
|
993
|
-
type MappedOmit<T$1, K$1 extends keyof any> = { [P in keyof T$1 as P extends K$1 ? never : P]: T$1[P] };
|
|
994
|
-
type InferDefaults<T$1> = { [K in keyof T$1]?: InferDefault<T$1, T$1[K]> };
|
|
995
|
-
type NativeType = null | undefined | number | string | boolean | symbol | Function;
|
|
996
|
-
type InferDefault<P$1, T$1> = ((props: P$1) => T$1 & {}) | (T$1 extends NativeType ? T$1 : never);
|
|
997
|
-
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;
|
|
998
|
-
/**
|
|
999
|
-
* withDefaults 为 defineProps 指定默认值(仅类型层)。
|
|
1000
|
-
* 默认值会影响可选/必选推导,但不生成运行时代码。
|
|
1001
|
-
*
|
|
1002
|
-
* @example
|
|
1003
|
-
* ```ts
|
|
1004
|
-
* const props = withDefaults(defineProps<{
|
|
1005
|
-
* title?: string
|
|
1006
|
-
* size?: 'sm' | 'md' | 'lg'
|
|
1007
|
-
* }>(), {
|
|
1008
|
-
* title: 'Empty',
|
|
1009
|
-
* size: 'md',
|
|
1010
|
-
* })
|
|
1011
|
-
* ```
|
|
1012
|
-
*/
|
|
1013
|
-
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>;
|
|
1014
|
-
type EmitsOptions = Record<string, ((...args: any[]) => any) | null> | string[];
|
|
1015
|
-
/**
|
|
1016
|
-
* defineEmits 字符串数组或映射写法。
|
|
1017
|
-
*
|
|
1018
|
-
* @example
|
|
1019
|
-
* ```ts
|
|
1020
|
-
* const emit = defineEmits(['change', 'open'])
|
|
1021
|
-
* emit('change', { id: 1 })
|
|
1022
|
-
*
|
|
1023
|
-
* const emit2 = defineEmits({
|
|
1024
|
-
* change: (payload: { id: number }) => true,
|
|
1025
|
-
* close: null,
|
|
1026
|
-
* })
|
|
1027
|
-
* emit2('change', { id: 2 })
|
|
1028
|
-
*
|
|
1029
|
-
* const emit3 = defineEmits(['tap', 'confirm'])
|
|
1030
|
-
* emit3('confirm')
|
|
1031
|
-
* ```
|
|
1032
|
-
*/
|
|
1033
|
-
declare function defineEmits<EE extends string = string>(emits?: EE[]): (event: EE, detail?: any) => void;
|
|
1034
|
-
declare function defineEmits<E extends Record<string, ((...args: any[]) => any) | null>>(emits?: E): (event: keyof E & string, detail?: any) => void;
|
|
1035
|
-
/**
|
|
1036
|
-
* defineEmits 显式签名写法。
|
|
1037
|
-
*
|
|
1038
|
-
* @example
|
|
1039
|
-
* ```ts
|
|
1040
|
-
* const emit = defineEmits<(e: 'save' | 'cancel', id?: number) => void>()
|
|
1041
|
-
* emit('save', 1)
|
|
1042
|
-
* ```
|
|
1043
|
-
*/
|
|
1044
|
-
declare function defineEmits<T$1 extends (...args: any[]) => any>(): T$1;
|
|
1045
|
-
/**
|
|
1046
|
-
* defineExpose 向父级 ref 暴露成员。
|
|
1047
|
-
* 仅影响类型提示,不会生成运行时代码。
|
|
1048
|
-
*
|
|
1049
|
-
* @example
|
|
1050
|
-
* ```ts
|
|
1051
|
-
* defineExpose({
|
|
1052
|
-
* focus,
|
|
1053
|
-
* reset,
|
|
1054
|
-
* })
|
|
1055
|
-
* ```
|
|
1056
|
-
*/
|
|
1057
|
-
declare function defineExpose<T$1 extends Record<string, any> = Record<string, any>>(exposed?: T$1): void;
|
|
1058
|
-
type ScriptSetupDefineOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> = Omit<DefineComponentOptions<ComponentPropsOptions, D, C, M>, 'props' | 'options'> & {
|
|
1059
|
-
/**
|
|
1060
|
-
* props should be defined via defineProps().
|
|
1061
|
-
*/
|
|
1062
|
-
props?: never;
|
|
1063
|
-
/**
|
|
1064
|
-
* emits should be defined via defineEmits().
|
|
1065
|
-
*/
|
|
1066
|
-
emits?: never;
|
|
1067
|
-
/**
|
|
1068
|
-
* expose should be defined via defineExpose().
|
|
1069
|
-
*/
|
|
1070
|
-
expose?: never;
|
|
1071
|
-
/**
|
|
1072
|
-
* slots should be defined via defineSlots().
|
|
1073
|
-
*/
|
|
1074
|
-
slots?: never;
|
|
1075
|
-
/**
|
|
1076
|
-
* Mini-program Component options (multipleSlots/styleIsolation/etc).
|
|
1077
|
-
*/
|
|
1078
|
-
options?: WechatMiniprogram.Component.ComponentOptions;
|
|
1079
|
-
};
|
|
1080
|
-
/**
|
|
1081
|
-
* defineOptions 设置组件选项。
|
|
1082
|
-
* 适合声明组件名、样式隔离等静态选项(仅 <script setup> 宏)。
|
|
1083
|
-
*
|
|
1084
|
-
* 仅用于无法通过 Composition API / 其他宏表达的选项,如:
|
|
1085
|
-
* - `name`
|
|
1086
|
-
* - `inheritAttrs`
|
|
1087
|
-
* - 小程序 `options`(multipleSlots/styleIsolation/etc)
|
|
1088
|
-
*
|
|
1089
|
-
* 注意:`props/emits/expose/slots` 应分别使用对应宏声明。
|
|
1090
|
-
*
|
|
1091
|
-
* @example
|
|
1092
|
-
* ```ts
|
|
1093
|
-
* defineOptions({
|
|
1094
|
-
* name: 'EmptyState',
|
|
1095
|
-
* inheritAttrs: false,
|
|
1096
|
-
* options: {
|
|
1097
|
-
* multipleSlots: true,
|
|
1098
|
-
* },
|
|
1099
|
-
* })
|
|
1100
|
-
* ```
|
|
1101
|
-
*/
|
|
1102
|
-
declare function defineOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions>(options?: ScriptSetupDefineOptions<D, C, M>): void;
|
|
1103
|
-
/**
|
|
1104
|
-
* defineSlots 声明 slots 类型。
|
|
1105
|
-
* 用于限定插槽名称与插槽参数结构。
|
|
1106
|
-
*
|
|
1107
|
-
* @example
|
|
1108
|
-
* ```ts
|
|
1109
|
-
* const slots = defineSlots<{
|
|
1110
|
-
* default?: (props: { text: string }) => any
|
|
1111
|
-
* footer?: () => any
|
|
1112
|
-
* }>()
|
|
1113
|
-
* ```
|
|
1114
|
-
*/
|
|
1115
|
-
declare function defineSlots<T$1 extends Record<string, any> = Record<string, any>>(): T$1;
|
|
1116
|
-
/**
|
|
1117
|
-
* defineModel 声明 v-model 绑定(weapp 变体)。
|
|
1118
|
-
* 支持默认字段与自定义字段名。
|
|
1119
|
-
*
|
|
1120
|
-
* @example
|
|
1121
|
-
* ```ts
|
|
1122
|
-
* const modelValue = defineModel<string>()
|
|
1123
|
-
* const checked = defineModel<boolean>('checked')
|
|
1124
|
-
* const count = defineModel<number>('count', { default: 0 })
|
|
1125
|
-
* ```
|
|
1126
|
-
*/
|
|
1127
|
-
declare function defineModel<T$1 = any>(name?: string, options?: Record<string, any>): Ref<T$1 | undefined>;
|
|
1128
|
-
//#endregion
|
|
1129
|
-
//#region src/store/types.d.ts
|
|
1130
|
-
type MutationType = 'patch object' | 'patch function';
|
|
1131
|
-
interface SubscriptionCallback<S = any> {
|
|
1132
|
-
(mutation: {
|
|
1133
|
-
type: MutationType;
|
|
1134
|
-
storeId: string;
|
|
1135
|
-
}, state: S): void;
|
|
1136
|
-
}
|
|
1137
|
-
interface ActionSubscriber<TStore = any> {
|
|
1138
|
-
(context: {
|
|
1139
|
-
name: string;
|
|
1140
|
-
store: TStore;
|
|
1141
|
-
args: any[];
|
|
1142
|
-
after: (cb: (result: any) => void) => void;
|
|
1143
|
-
onError: (cb: (error: any) => void) => void;
|
|
1144
|
-
}): void;
|
|
1145
|
-
}
|
|
1146
|
-
interface StoreManager {
|
|
1147
|
-
install: (app: any) => void;
|
|
1148
|
-
_stores: Map<string, any>;
|
|
1149
|
-
use: (plugin: (context: {
|
|
1150
|
-
store: any;
|
|
1151
|
-
}) => void) => StoreManager;
|
|
1152
|
-
_plugins: Array<(context: {
|
|
1153
|
-
store: any;
|
|
1154
|
-
}) => void>;
|
|
1155
|
-
}
|
|
1156
|
-
type GetterTree<S extends Record<string, any>> = Record<string, (state: S) => any>;
|
|
1157
|
-
type StoreGetters<G extends GetterTree<any>> = { [K in keyof G]: G[K] extends ((...args: any[]) => infer R) ? R : never };
|
|
1158
|
-
interface DefineStoreOptions<S extends Record<string, any>, G extends GetterTree<S>, A extends Record<string, any>> {
|
|
1159
|
-
state: () => S;
|
|
1160
|
-
getters?: G & Record<string, (state: S) => any> & ThisType<S & StoreGetters<G> & A>;
|
|
1161
|
-
actions?: A & ThisType<S & StoreGetters<G> & A>;
|
|
1162
|
-
}
|
|
1163
|
-
//#endregion
|
|
1164
|
-
//#region src/store/define.d.ts
|
|
1165
|
-
type SetupDefinition<T$1> = () => T$1;
|
|
1166
|
-
declare function defineStore<T$1 extends Record<string, any>>(id: string, setup: SetupDefinition<T$1>): () => T$1 & {
|
|
1167
|
-
$id: string;
|
|
1168
|
-
$patch: (patch: Record<string, any> | ((state: any) => void)) => void;
|
|
1169
|
-
$subscribe: (cb: (mutation: {
|
|
1170
|
-
type: MutationType;
|
|
1171
|
-
storeId: string;
|
|
1172
|
-
}, state: any) => void, opts?: {
|
|
1173
|
-
detached?: boolean;
|
|
1174
|
-
}) => () => void;
|
|
1175
|
-
$onAction: (cb: (context: any) => void) => () => void;
|
|
1176
|
-
};
|
|
1177
|
-
declare function defineStore<S extends Record<string, any>, G extends Record<string, any>, A extends Record<string, any>>(id: string, options: DefineStoreOptions<S, G, A>): () => S & StoreGetters<G> & A & {
|
|
1178
|
-
$id: string;
|
|
1179
|
-
$state: S;
|
|
1180
|
-
$patch: (patch: Partial<S> | ((state: S) => void)) => void;
|
|
1181
|
-
$reset: () => void;
|
|
1182
|
-
$subscribe: (cb: (mutation: {
|
|
1183
|
-
type: MutationType;
|
|
1184
|
-
storeId: string;
|
|
1185
|
-
}, state: S) => void, opts?: {
|
|
1186
|
-
detached?: boolean;
|
|
1187
|
-
}) => () => void;
|
|
1188
|
-
$onAction: (cb: (context: any) => () => void) => () => void;
|
|
1189
|
-
};
|
|
1190
|
-
//#endregion
|
|
1191
|
-
//#region src/store/manager.d.ts
|
|
1192
|
-
declare function createStore(): StoreManager;
|
|
1193
|
-
//#endregion
|
|
1194
|
-
//#region src/store/storeToRefs.d.ts
|
|
1195
|
-
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]> };
|
|
1196
|
-
declare function storeToRefs<T$1 extends Record<string, any>>(store: T$1): StoreToRefsResult<T$1>;
|
|
1197
|
-
//#endregion
|
|
1198
|
-
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 };
|