@vue/runtime-vapor 3.6.0-alpha.2 → 3.6.0-alpha.4

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.
@@ -1,26 +1,60 @@
1
- import { Plugin, GenericComponentInstance, GenericAppContext, EffectScope as EffectScope$1, EmitFn, SuspenseBoundary, LifecycleHook, NormalizedPropsOptions, ObjectEmitsOptions, ComponentInternalOptions, ComponentPropsOptions, EmitsOptions, CreateAppFunction, DirectiveModifiers } from '@vue/runtime-dom';
2
- import { EffectScope, ShallowRef, Ref } from '@vue/reactivity';
3
- import { NormalizedStyle } from '@vue/shared';
1
+ import { VNode, TransitionHooks, TransitionState, TransitionProps, Plugin, SchedulerJob, GenericComponentInstance, GenericAppContext, EffectScope as EffectScope$1, EmitFn, SuspenseBoundary, LifecycleHook, NormalizedPropsOptions, ObjectEmitsOptions, ComponentInternalOptions, AsyncComponentInternalOptions, ComponentPropsOptions, EmitsOptions, CreateAppFunction, AsyncComponentLoader, AsyncComponentOptions, DirectiveModifiers, VueElementBase, CustomElementOptions } from '@vue/runtime-dom';
2
+ import { Ref, EffectScope, ReactiveEffect, ShallowRef } from '@vue/reactivity';
3
+ import { Namespace, NormalizedStyle } from '@vue/shared';
4
4
 
5
- type Block = Node | VaporFragment | DynamicFragment | VaporComponentInstance | Block[];
6
- type BlockFn = (...args: any[]) => Block;
7
- export declare class VaporFragment {
8
- nodes: Block;
5
+ type NodeRef = string | Ref | ((ref: Element | VaporComponentInstance, refs: Record<string, any>) => void);
6
+ type RefEl = Element | VaporComponentInstance;
7
+ type setRefFn = (el: RefEl, ref: NodeRef, oldRef?: NodeRef, refFor?: boolean) => NodeRef | undefined;
8
+ export declare function createTemplateRefSetter(): setRefFn;
9
+
10
+ export declare class VaporFragment<T extends Block = Block> implements TransitionOptions {
11
+ $key?: any;
12
+ $transition?: VaporTransitionHooks | undefined;
13
+ nodes: T;
14
+ vnode?: VNode | null;
9
15
  anchor?: Node;
10
- insert?: (parent: ParentNode, anchor: Node | null) => void;
11
- remove?: (parent?: ParentNode) => void;
12
- constructor(nodes: Block);
16
+ fallback?: BlockFn;
17
+ insert?: (parent: ParentNode, anchor: Node | null, transitionHooks?: TransitionHooks) => void;
18
+ remove?: (parent?: ParentNode, transitionHooks?: TransitionHooks) => void;
19
+ hydrate?: (...args: any[]) => void;
20
+ setRef?: (instance: VaporComponentInstance, ref: NodeRef, refFor: boolean, refKey: string | undefined) => void;
21
+ constructor(nodes: T);
22
+ }
23
+ declare class ForFragment extends VaporFragment<Block[]> {
24
+ constructor(nodes: Block[]);
13
25
  }
14
26
  declare class DynamicFragment extends VaporFragment {
15
27
  anchor: Node;
16
28
  scope: EffectScope | undefined;
17
29
  current?: BlockFn;
18
30
  fallback?: BlockFn;
31
+ anchorLabel?: string;
32
+ inKeepAlive?: boolean;
33
+ keptAliveScopes?: Map<any, EffectScope>;
19
34
  constructor(anchorLabel?: string);
20
35
  update(render?: BlockFn, key?: any): void;
36
+ private render;
37
+ hydrate: (isEmpty?: boolean) => void;
21
38
  }
22
39
  export declare function isFragment(val: NonNullable<unknown>): val is VaporFragment;
23
- export declare function insert(block: Block, parent: ParentNode, anchor?: Node | null | 0): void;
40
+
41
+ interface VaporTransitionHooks extends TransitionHooks {
42
+ state: TransitionState;
43
+ props: TransitionProps;
44
+ instance: VaporComponentInstance;
45
+ disabled?: boolean;
46
+ group?: boolean;
47
+ }
48
+ interface TransitionOptions {
49
+ $key?: any;
50
+ $transition?: VaporTransitionHooks;
51
+ }
52
+ type Block = Node | VaporFragment | DynamicFragment | VaporComponentInstance | Block[];
53
+ type BlockFn = (...args: any[]) => Block;
54
+ export declare function insert(block: Block, parent: ParentNode & {
55
+ $fc?: Node | null;
56
+ }, anchor?: Node | null | 0, // 0 means prepend
57
+ parentSuspense?: any): void;
24
58
  export declare function prepend(parent: ParentNode, ...blocks: Block[]): void;
25
59
  export declare function remove(block: Block, parent?: ParentNode): void;
26
60
 
@@ -34,6 +68,17 @@ type RawProps = Record<string, () => unknown> & {
34
68
  };
35
69
  type DynamicPropsSource = (() => Record<string, unknown>) | Record<string, () => unknown>;
36
70
 
71
+ declare class RenderEffect extends ReactiveEffect {
72
+ render: () => void;
73
+ i: VaporComponentInstance | null;
74
+ job: SchedulerJob;
75
+ updateJob: SchedulerJob;
76
+ constructor(render: () => void);
77
+ fn(): void;
78
+ notify(): void;
79
+ }
80
+ export declare function renderEffect(fn: () => void, noLifecycle?: boolean): void;
81
+
37
82
  type RawSlots = Record<string, VaporSlot> & {
38
83
  $?: DynamicSlotSource[];
39
84
  };
@@ -45,14 +90,50 @@ type DynamicSlot = {
45
90
  };
46
91
  type DynamicSlotFn = () => DynamicSlot | DynamicSlot[];
47
92
  type DynamicSlotSource = StaticSlots | DynamicSlotFn;
48
- export declare function createSlot(name: string | (() => string), rawProps?: LooseRawProps | null, fallback?: VaporSlot): Block;
93
+ /**
94
+ * Wrap a slot function to memoize currentInstance
95
+ * 1. ensure correct currentInstance in forwarded slots
96
+ * 2. elements created in the slot inherit the slot owner's scopeId
97
+ */
98
+ export declare function withVaporCtx(fn: Function): BlockFn;
99
+ export declare function createSlot(name: string | (() => string), rawProps?: LooseRawProps | null, fallback?: VaporSlot, noSlotted?: boolean): Block;
100
+
101
+ export declare const VaporTeleportImpl: {
102
+ name: string;
103
+ __isTeleport: boolean;
104
+ __vapor: boolean;
105
+ process(props: LooseRawProps, slots: LooseRawSlots): TeleportFragment;
106
+ };
107
+ declare class TeleportFragment extends VaporFragment {
108
+ anchor?: Node;
109
+ private rawProps?;
110
+ private resolvedProps?;
111
+ private rawSlots?;
112
+ target?: ParentNode | null;
113
+ targetAnchor?: Node | null;
114
+ targetStart?: Node | null;
115
+ placeholder?: Node;
116
+ mountContainer?: ParentNode | null;
117
+ mountAnchor?: Node | null;
118
+ parentComponent: GenericComponentInstance;
119
+ constructor(props: LooseRawProps, slots: LooseRawSlots);
120
+ get parent(): ParentNode | null;
121
+ private initChildren;
122
+ private handleChildrenUpdate;
123
+ private handlePropsUpdate;
124
+ insert: (container: ParentNode, anchor: Node | null) => void;
125
+ remove: (parent?: ParentNode | undefined) => void;
126
+ private hydrateDisabledTeleport;
127
+ private mount;
128
+ hydrate: () => void;
129
+ }
49
130
 
50
131
  type VaporComponent = FunctionalVaporComponent | ObjectVaporComponent;
51
132
  type VaporSetupFn = (props: any, ctx: Pick<VaporComponentInstance, 'slots' | 'attrs' | 'emit' | 'expose'>) => Block | Record<string, any> | undefined;
52
133
  type FunctionalVaporComponent = VaporSetupFn & Omit<ObjectVaporComponent, 'setup'> & {
53
134
  displayName?: string;
54
135
  } & SharedInternalOptions;
55
- interface ObjectVaporComponent extends ComponentInternalOptions, SharedInternalOptions {
136
+ interface ObjectVaporComponent extends ComponentInternalOptions, AsyncComponentInternalOptions<ObjectVaporComponent, VaporComponentInstance>, SharedInternalOptions {
56
137
  setup?: VaporSetupFn;
57
138
  inheritAttrs?: boolean;
58
139
  props?: ComponentPropsOptions;
@@ -83,7 +164,7 @@ type LooseRawProps = Record<string, (() => unknown) | DynamicPropsSource[]> & {
83
164
  type LooseRawSlots = Record<string, VaporSlot | DynamicSlotSource[]> & {
84
165
  $?: DynamicSlotSource[];
85
166
  };
86
- export declare function createComponent(component: VaporComponent, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, appContext?: GenericAppContext): VaporComponentInstance;
167
+ export declare function createComponent(component: VaporComponent, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, once?: boolean, appContext?: GenericAppContext): VaporComponentInstance;
87
168
  declare class VaporComponentInstance implements GenericComponentInstance {
88
169
  vapor: true;
89
170
  uid: number;
@@ -99,6 +180,7 @@ declare class VaporComponentInstance implements GenericComponentInstance {
99
180
  attrs: Record<string, any>;
100
181
  propsDefaults: Record<string, any> | null;
101
182
  slots: StaticSlots;
183
+ scopeId?: string | null;
102
184
  rawPropsRef?: ShallowRef<any>;
103
185
  rawSlotsRef?: ShallowRef<any>;
104
186
  emit: EmitFn;
@@ -110,7 +192,9 @@ declare class VaporComponentInstance implements GenericComponentInstance {
110
192
  provides: Record<string, any>;
111
193
  ids: [string, number, number];
112
194
  suspense: SuspenseBoundary | null;
195
+ renderEffects?: RenderEffect[];
113
196
  hasFallthrough: boolean;
197
+ shapeFlag?: number;
114
198
  isMounted: boolean;
115
199
  isUnmounted: boolean;
116
200
  isDeactivated: boolean;
@@ -133,10 +217,11 @@ declare class VaporComponentInstance implements GenericComponentInstance {
133
217
  devtoolsRawSetupState?: any;
134
218
  hmrRerender?: () => void;
135
219
  hmrReload?: (newComp: VaporComponent) => void;
220
+ parentTeleport?: TeleportFragment | null;
136
221
  propsOptions?: NormalizedPropsOptions;
137
222
  emitsOptions?: ObjectEmitsOptions | null;
138
223
  isSingleRoot?: boolean;
139
- constructor(comp: VaporComponent, rawProps?: RawProps | null, rawSlots?: RawSlots | null, appContext?: GenericAppContext);
224
+ constructor(comp: VaporComponent, rawProps?: RawProps | null, rawSlots?: RawSlots | null, appContext?: GenericAppContext, once?: boolean, parent?: GenericComponentInstance | null);
140
225
  /**
141
226
  * Expose `getKeysFromRawProps` on the instance so it can be used in code
142
227
  * paths where it's needed, e.g. `useModel`
@@ -149,7 +234,8 @@ export declare function isVaporComponent(value: unknown): value is VaporComponen
149
234
  * and needs rely on runtime resolution - where it might fallback to a plain
150
235
  * element if the resolution fails.
151
236
  */
152
- export declare function createComponentWithFallback(comp: VaporComponent | string, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean): HTMLElement | VaporComponentInstance;
237
+ export declare function createComponentWithFallback(comp: VaporComponent | string, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, once?: boolean, appContext?: GenericAppContext): HTMLElement | VaporComponentInstance;
238
+ export declare function createPlainElement(comp: string, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, once?: boolean): HTMLElement;
153
239
 
154
240
  export declare const createVaporApp: CreateAppFunction<ParentNode, VaporComponent>;
155
241
  export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporComponent>;
@@ -157,6 +243,8 @@ export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporCompo
157
243
  /*! #__NO_SIDE_EFFECTS__ */
158
244
  export declare function defineVaporComponent(comp: VaporComponent, extraOptions?: Omit<ObjectVaporComponent, 'setup'>): VaporComponent;
159
245
 
246
+ export declare function defineVaporAsyncComponent<T extends VaporComponent>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T;
247
+
160
248
  export type VaporDirective = (node: Element | VaporComponentInstance, value?: () => any, argument?: string, modifiers?: DirectiveModifiers) => (() => void) | void;
161
249
  type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirective | undefined, () => any] | [VaporDirective | undefined, (() => any) | undefined, argument: string] | [
162
250
  VaporDirective | undefined,
@@ -166,28 +254,64 @@ type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirect
166
254
  ]>;
167
255
  export declare function withVaporDirectives(node: Element | VaporComponentInstance, dirs: VaporDirectiveArguments): void;
168
256
 
257
+ export declare const VaporKeepAliveImpl: ObjectVaporComponent;
258
+
259
+ type VaporElementConstructor<P = {}> = {
260
+ new (initialProps?: Record<string, any>): VaporElement & P;
261
+ };
262
+ export declare function defineVaporCustomElement(options: any, extraOptions?: Omit<ObjectVaporComponent, 'setup'>,
263
+ /**
264
+ * @internal
265
+ */
266
+ _createApp?: CreateAppFunction<ParentNode, VaporComponent>): VaporElementConstructor;
267
+ export declare const defineVaporSSRCustomElement: typeof defineVaporCustomElement;
268
+ type VaporInnerComponentDef = VaporComponent & CustomElementOptions;
269
+ declare class VaporElement extends VueElementBase<ParentNode, VaporComponent, VaporInnerComponentDef> {
270
+ constructor(def: VaporInnerComponentDef, props?: Record<string, any> | undefined, createAppFn?: CreateAppFunction<ParentNode, VaporComponent>);
271
+ protected _needsHydration(): boolean;
272
+ protected _mount(def: VaporInnerComponentDef): void;
273
+ protected _update(): void;
274
+ protected _unmount(): void;
275
+ /**
276
+ * Only called when shadowRoot is false
277
+ */
278
+ protected _updateSlotNodes(replacements: Map<Node, Node[]>): void;
279
+ private _createComponent;
280
+ }
281
+
282
+ type InsertionParent = ParentNode & {
283
+ $fc?: Node | null;
284
+ $llc?: Node | null;
285
+ $lpn?: Node | null;
286
+ $lan?: Node | null;
287
+ $curIdx?: number;
288
+ };
169
289
  /**
170
290
  * This function is called before a block type that requires insertion
171
291
  * (component, slot outlet, if, for) is created. The state is used for actual
172
292
  * insertion on client-side render, and used for node adoption during hydration.
173
293
  */
174
- export declare function setInsertionState(parent: ParentNode, anchor?: Node | 0): void;
175
-
176
- export declare function renderEffect(fn: () => void, noLifecycle?: boolean): void;
294
+ export declare function setInsertionState(parent: ParentNode & {
295
+ $fc?: Node | null;
296
+ }, anchor?: Node | 0 | null | number, last?: boolean): void;
177
297
 
178
298
  /*! #__NO_SIDE_EFFECTS__ */
179
- export declare function template(html: string, root?: boolean): () => Node & {
299
+ export declare function template(html: string, root?: boolean, ns?: Namespace): () => Node & {
180
300
  $root?: true;
181
301
  };
182
302
 
183
- /*! #__NO_SIDE_EFFECTS__ */
184
303
  export declare function createTextNode(value?: string): Text;
185
- /*! #__NO_SIDE_EFFECTS__ */
186
- export declare function child(node: ParentNode): Node;
187
- /*! #__NO_SIDE_EFFECTS__ */
188
- export declare function nthChild(node: Node, i: number): Node;
189
- /*! #__NO_SIDE_EFFECTS__ */
190
- export declare function next(node: Node): Node;
304
+ declare const _txt: typeof _child;
305
+ declare function _child(node: InsertionParent): Node;
306
+ declare function _nthChild(node: InsertionParent, i: number): Node;
307
+ declare function _next(node: Node): Node;
308
+ type DelegatedFunction<T extends (...args: any[]) => any> = T & {
309
+ impl: T;
310
+ };
311
+ export declare const txt: DelegatedFunction<typeof _txt>;
312
+ export declare const child: DelegatedFunction<typeof _child>;
313
+ export declare const next: DelegatedFunction<typeof _next>;
314
+ export declare const nthChild: DelegatedFunction<typeof _nthChild>;
191
315
 
192
316
  type TargetElement = Element & {
193
317
  $root?: true;
@@ -198,11 +322,11 @@ type TargetElement = Element & {
198
322
  _value?: any;
199
323
  };
200
324
  export declare function setProp(el: any, key: string, value: any): void;
201
- export declare function setAttr(el: any, key: string, value: any): void;
202
- export declare function setDOMProp(el: any, key: string, value: any): void;
203
- export declare function setClass(el: TargetElement, value: any): void;
325
+ export declare function setAttr(el: any, key: string, value: any, isSVG?: boolean): void;
326
+ export declare function setDOMProp(el: any, key: string, value: any, forceHydrate?: boolean, attrName?: string): void;
327
+ export declare function setClass(el: TargetElement, value: any, isSVG?: boolean): void;
204
328
  export declare function setStyle(el: TargetElement, value: any): void;
205
- export declare function setValue(el: TargetElement, value: any): void;
329
+ export declare function setValue(el: TargetElement, value: any, forceHydrate?: boolean): void;
206
330
  /**
207
331
  * Only called on text nodes!
208
332
  * Compiler should also ensure value passed here is already converted by
@@ -211,8 +335,20 @@ export declare function setValue(el: TargetElement, value: any): void;
211
335
  export declare function setText(el: Text & {
212
336
  $txt?: string;
213
337
  }, value: string): void;
338
+ /**
339
+ * Used by setDynamicProps only, so need to guard with `toDisplayString`
340
+ */
341
+ export declare function setElementText(el: Node & {
342
+ $txt?: string;
343
+ }, value: unknown): void;
344
+ export declare function setBlockText(block: Block & {
345
+ $txt?: string;
346
+ }, value: unknown): void;
214
347
  export declare function setHtml(el: TargetElement, value: any): void;
215
- export declare function setDynamicProps(el: any, args: any[]): void;
348
+ export declare function setBlockHtml(block: Block & {
349
+ $html?: string;
350
+ }, value: any): void;
351
+ export declare function setDynamicProps(el: any, args: any[], root?: boolean, isSVG?: boolean): void;
216
352
 
217
353
  export declare function on(el: Element, event: string, handler: (e: Event) => any, options?: AddEventListenerOptions & {
218
354
  effect?: boolean;
@@ -220,23 +356,21 @@ export declare function on(el: Element, event: string, handler: (e: Event) => an
220
356
  export declare function delegate(el: any, event: string, handler: (e: Event) => any): void;
221
357
  export declare const delegateEvents: (...names: string[]) => void;
222
358
  export declare function setDynamicEvents(el: HTMLElement, events: Record<string, (...args: any[]) => any>): void;
359
+ export declare function createInvoker(handler: (...args: any[]) => any): (...args: any[]) => any;
223
360
 
224
361
  export declare function createIf(condition: () => any, b1: BlockFn, b2?: BlockFn, once?: boolean): Block;
225
362
 
363
+ export declare function createKeyedFragment(key: () => any, render: BlockFn): Block;
364
+
226
365
  type Source = any[] | Record<any, any> | number | Set<any> | Map<any, any>;
227
366
  export declare const createFor: (src: () => Source, renderItem: (item: ShallowRef<any>, key: ShallowRef<any>, index: ShallowRef<number | undefined>) => Block, getKey?: (item: any, key: any, index?: number) => any, flags?: number, setup?: (_: {
228
367
  createSelector: (source: () => any) => (cb: () => void) => void;
229
- }) => void) => VaporFragment;
368
+ }) => void) => ForFragment;
230
369
  export declare function createForSlots(rawSource: Source, getSlot: (item: any, key: any, index?: number) => DynamicSlot): DynamicSlot[];
231
370
  export declare function getRestElement(val: any, keys: string[]): any;
232
371
  export declare function getDefaultValue(val: any, defaultVal: any): any;
233
372
 
234
- type NodeRef = string | Ref | ((ref: Element) => void);
235
- type RefEl = Element | VaporComponentInstance;
236
- type setRefFn = (el: RefEl, ref: NodeRef, oldRef?: NodeRef, refFor?: boolean) => NodeRef | undefined;
237
- export declare function createTemplateRefSetter(): setRefFn;
238
-
239
- export declare function createDynamicComponent(getter: () => any, rawProps?: RawProps | null, rawSlots?: RawSlots | null, isSingleRoot?: boolean): VaporFragment;
373
+ export declare function createDynamicComponent(getter: () => any, rawProps?: RawProps | null, rawSlots?: RawSlots | null, isSingleRoot?: boolean, once?: boolean): VaporFragment;
240
374
 
241
375
  export declare function applyVShow(target: Block, source: () => any): void;
242
376
 
@@ -249,4 +383,8 @@ export declare const applyRadioModel: VaporModelDirective<HTMLInputElement>;
249
383
  export declare const applySelectModel: VaporModelDirective<HTMLSelectElement, 'number'>;
250
384
  export declare const applyDynamicModel: VaporModelDirective;
251
385
 
386
+ export declare const VaporTransition: FunctionalVaporComponent;
387
+
388
+ export declare const VaporTransitionGroup: ObjectVaporComponent;
252
389
 
390
+ export { VaporKeepAliveImpl as VaporKeepAlive, VaporTeleportImpl as VaporTeleport, };