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

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,59 @@
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';
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 } from '@vue/runtime-dom';
2
+ import { Ref, EffectScope, ReactiveEffect, ShallowRef } from '@vue/reactivity';
3
3
  import { 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
+ }
47
+ interface TransitionOptions {
48
+ $key?: any;
49
+ $transition?: VaporTransitionHooks;
50
+ }
51
+ type Block = Node | VaporFragment | DynamicFragment | VaporComponentInstance | Block[];
52
+ type BlockFn = (...args: any[]) => Block;
53
+ export declare function insert(block: Block, parent: ParentNode & {
54
+ $fc?: Node | null;
55
+ }, anchor?: Node | null | 0, // 0 means prepend
56
+ parentSuspense?: any): void;
24
57
  export declare function prepend(parent: ParentNode, ...blocks: Block[]): void;
25
58
  export declare function remove(block: Block, parent?: ParentNode): void;
26
59
 
@@ -34,6 +67,17 @@ type RawProps = Record<string, () => unknown> & {
34
67
  };
35
68
  type DynamicPropsSource = (() => Record<string, unknown>) | Record<string, () => unknown>;
36
69
 
70
+ declare class RenderEffect extends ReactiveEffect {
71
+ render: () => void;
72
+ i: VaporComponentInstance | null;
73
+ job: SchedulerJob;
74
+ updateJob: SchedulerJob;
75
+ constructor(render: () => void);
76
+ fn(): void;
77
+ notify(): void;
78
+ }
79
+ export declare function renderEffect(fn: () => void, noLifecycle?: boolean): void;
80
+
37
81
  type RawSlots = Record<string, VaporSlot> & {
38
82
  $?: DynamicSlotSource[];
39
83
  };
@@ -45,14 +89,58 @@ type DynamicSlot = {
45
89
  };
46
90
  type DynamicSlotFn = () => DynamicSlot | DynamicSlot[];
47
91
  type DynamicSlotSource = StaticSlots | DynamicSlotFn;
48
- export declare function createSlot(name: string | (() => string), rawProps?: LooseRawProps | null, fallback?: VaporSlot): Block;
92
+ /**
93
+ * Wraps a slot function to execute in the parent component's context.
94
+ *
95
+ * This ensures that:
96
+ * 1. Reactive effects created inside the slot (e.g., `renderEffect`) bind to the
97
+ * parent's instance, so the parent's lifecycle hooks fire when the slot's
98
+ * reactive dependencies change.
99
+ * 2. Elements created in the slot inherit the parent's scopeId for proper style
100
+ * scoping in scoped CSS.
101
+ *
102
+ * **Rationale**: Slots are defined in the parent's template, so the parent should
103
+ * own the rendering context and be aware of updates.
104
+ *
105
+ */
106
+ export declare function withVaporCtx(fn: Function): BlockFn;
107
+ export declare function createSlot(name: string | (() => string), rawProps?: LooseRawProps | null, fallback?: VaporSlot, noSlotted?: boolean): Block;
108
+
109
+ export declare const VaporTeleportImpl: {
110
+ name: string;
111
+ __isTeleport: boolean;
112
+ __vapor: boolean;
113
+ process(props: LooseRawProps, slots: LooseRawSlots): TeleportFragment;
114
+ };
115
+ declare class TeleportFragment extends VaporFragment {
116
+ anchor?: Node;
117
+ private rawProps?;
118
+ private resolvedProps?;
119
+ private rawSlots?;
120
+ target?: ParentNode | null;
121
+ targetAnchor?: Node | null;
122
+ targetStart?: Node | null;
123
+ placeholder?: Node;
124
+ mountContainer?: ParentNode | null;
125
+ mountAnchor?: Node | null;
126
+ constructor(props: LooseRawProps, slots: LooseRawSlots);
127
+ get parent(): ParentNode | null;
128
+ private initChildren;
129
+ private handleChildrenUpdate;
130
+ private handlePropsUpdate;
131
+ insert: (container: ParentNode, anchor: Node | null) => void;
132
+ remove: (parent?: ParentNode | undefined) => void;
133
+ private hydrateDisabledTeleport;
134
+ private mount;
135
+ hydrate: () => void;
136
+ }
49
137
 
50
138
  type VaporComponent = FunctionalVaporComponent | ObjectVaporComponent;
51
139
  type VaporSetupFn = (props: any, ctx: Pick<VaporComponentInstance, 'slots' | 'attrs' | 'emit' | 'expose'>) => Block | Record<string, any> | undefined;
52
140
  type FunctionalVaporComponent = VaporSetupFn & Omit<ObjectVaporComponent, 'setup'> & {
53
141
  displayName?: string;
54
142
  } & SharedInternalOptions;
55
- interface ObjectVaporComponent extends ComponentInternalOptions, SharedInternalOptions {
143
+ interface ObjectVaporComponent extends ComponentInternalOptions, AsyncComponentInternalOptions<ObjectVaporComponent, VaporComponentInstance>, SharedInternalOptions {
56
144
  setup?: VaporSetupFn;
57
145
  inheritAttrs?: boolean;
58
146
  props?: ComponentPropsOptions;
@@ -83,7 +171,7 @@ type LooseRawProps = Record<string, (() => unknown) | DynamicPropsSource[]> & {
83
171
  type LooseRawSlots = Record<string, VaporSlot | DynamicSlotSource[]> & {
84
172
  $?: DynamicSlotSource[];
85
173
  };
86
- export declare function createComponent(component: VaporComponent, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, appContext?: GenericAppContext): VaporComponentInstance;
174
+ export declare function createComponent(component: VaporComponent, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, once?: boolean, appContext?: GenericAppContext): VaporComponentInstance;
87
175
  declare class VaporComponentInstance implements GenericComponentInstance {
88
176
  vapor: true;
89
177
  uid: number;
@@ -133,10 +221,13 @@ declare class VaporComponentInstance implements GenericComponentInstance {
133
221
  devtoolsRawSetupState?: any;
134
222
  hmrRerender?: () => void;
135
223
  hmrReload?: (newComp: VaporComponent) => void;
224
+ renderEffects?: RenderEffect[];
225
+ parentTeleport?: TeleportFragment | null;
136
226
  propsOptions?: NormalizedPropsOptions;
137
227
  emitsOptions?: ObjectEmitsOptions | null;
138
228
  isSingleRoot?: boolean;
139
- constructor(comp: VaporComponent, rawProps?: RawProps | null, rawSlots?: RawSlots | null, appContext?: GenericAppContext);
229
+ shapeFlag?: number;
230
+ constructor(comp: VaporComponent, rawProps?: RawProps | null, rawSlots?: RawSlots | null, appContext?: GenericAppContext, once?: boolean);
140
231
  /**
141
232
  * Expose `getKeysFromRawProps` on the instance so it can be used in code
142
233
  * paths where it's needed, e.g. `useModel`
@@ -149,7 +240,7 @@ export declare function isVaporComponent(value: unknown): value is VaporComponen
149
240
  * and needs rely on runtime resolution - where it might fallback to a plain
150
241
  * element if the resolution fails.
151
242
  */
152
- export declare function createComponentWithFallback(comp: VaporComponent | string, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean): HTMLElement | VaporComponentInstance;
243
+ export declare function createComponentWithFallback(comp: VaporComponent | string, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, once?: boolean, appContext?: GenericAppContext): HTMLElement | VaporComponentInstance;
153
244
 
154
245
  export declare const createVaporApp: CreateAppFunction<ParentNode, VaporComponent>;
155
246
  export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporComponent>;
@@ -157,6 +248,8 @@ export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporCompo
157
248
  /*! #__NO_SIDE_EFFECTS__ */
158
249
  export declare function defineVaporComponent(comp: VaporComponent, extraOptions?: Omit<ObjectVaporComponent, 'setup'>): VaporComponent;
159
250
 
251
+ export declare function defineVaporAsyncComponent<T extends VaporComponent>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T;
252
+
160
253
  export type VaporDirective = (node: Element | VaporComponentInstance, value?: () => any, argument?: string, modifiers?: DirectiveModifiers) => (() => void) | void;
161
254
  type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirective | undefined, () => any] | [VaporDirective | undefined, (() => any) | undefined, argument: string] | [
162
255
  VaporDirective | undefined,
@@ -166,28 +259,41 @@ type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirect
166
259
  ]>;
167
260
  export declare function withVaporDirectives(node: Element | VaporComponentInstance, dirs: VaporDirectiveArguments): void;
168
261
 
262
+ export declare const VaporKeepAliveImpl: ObjectVaporComponent;
263
+
264
+ type InsertionParent = ParentNode & {
265
+ $fc?: Node | null;
266
+ $llc?: Node | null;
267
+ $lpn?: Node | null;
268
+ $lan?: Node | null;
269
+ $curIdx?: number;
270
+ };
169
271
  /**
170
272
  * This function is called before a block type that requires insertion
171
273
  * (component, slot outlet, if, for) is created. The state is used for actual
172
274
  * insertion on client-side render, and used for node adoption during hydration.
173
275
  */
174
- export declare function setInsertionState(parent: ParentNode, anchor?: Node | 0): void;
175
-
176
- export declare function renderEffect(fn: () => void, noLifecycle?: boolean): void;
276
+ export declare function setInsertionState(parent: ParentNode & {
277
+ $fc?: Node | null;
278
+ }, anchor?: Node | 0 | null | number, last?: boolean): void;
177
279
 
178
280
  /*! #__NO_SIDE_EFFECTS__ */
179
281
  export declare function template(html: string, root?: boolean): () => Node & {
180
282
  $root?: true;
181
283
  };
182
284
 
183
- /*! #__NO_SIDE_EFFECTS__ */
184
285
  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;
286
+ declare const _txt: typeof _child;
287
+ declare function _child(node: InsertionParent): Node;
288
+ declare function _nthChild(node: InsertionParent, i: number): Node;
289
+ declare function _next(node: Node): Node;
290
+ type DelegatedFunction<T extends (...args: any[]) => any> = T & {
291
+ impl: T;
292
+ };
293
+ export declare const txt: DelegatedFunction<typeof _txt>;
294
+ export declare const child: DelegatedFunction<typeof _child>;
295
+ export declare const next: DelegatedFunction<typeof _next>;
296
+ export declare const nthChild: DelegatedFunction<typeof _nthChild>;
191
297
 
192
298
  type TargetElement = Element & {
193
299
  $root?: true;
@@ -199,10 +305,10 @@ type TargetElement = Element & {
199
305
  };
200
306
  export declare function setProp(el: any, key: string, value: any): void;
201
307
  export declare function setAttr(el: any, key: string, value: any): void;
202
- export declare function setDOMProp(el: any, key: string, value: any): void;
308
+ export declare function setDOMProp(el: any, key: string, value: any, forceHydrate?: boolean): void;
203
309
  export declare function setClass(el: TargetElement, value: any): void;
204
310
  export declare function setStyle(el: TargetElement, value: any): void;
205
- export declare function setValue(el: TargetElement, value: any): void;
311
+ export declare function setValue(el: TargetElement, value: any, forceHydrate?: boolean): void;
206
312
  /**
207
313
  * Only called on text nodes!
208
314
  * Compiler should also ensure value passed here is already converted by
@@ -211,7 +317,19 @@ export declare function setValue(el: TargetElement, value: any): void;
211
317
  export declare function setText(el: Text & {
212
318
  $txt?: string;
213
319
  }, value: string): void;
320
+ /**
321
+ * Used by setDynamicProps only, so need to guard with `toDisplayString`
322
+ */
323
+ export declare function setElementText(el: Node & {
324
+ $txt?: string;
325
+ }, value: unknown): void;
326
+ export declare function setBlockText(block: Block & {
327
+ $txt?: string;
328
+ }, value: unknown): void;
214
329
  export declare function setHtml(el: TargetElement, value: any): void;
330
+ export declare function setBlockHtml(block: Block & {
331
+ $html?: string;
332
+ }, value: any): void;
215
333
  export declare function setDynamicProps(el: any, args: any[]): void;
216
334
 
217
335
  export declare function on(el: Element, event: string, handler: (e: Event) => any, options?: AddEventListenerOptions & {
@@ -223,20 +341,17 @@ export declare function setDynamicEvents(el: HTMLElement, events: Record<string,
223
341
 
224
342
  export declare function createIf(condition: () => any, b1: BlockFn, b2?: BlockFn, once?: boolean): Block;
225
343
 
344
+ export declare function createKeyedFragment(key: () => any, render: BlockFn): Block;
345
+
226
346
  type Source = any[] | Record<any, any> | number | Set<any> | Map<any, any>;
227
347
  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
348
  createSelector: (source: () => any) => (cb: () => void) => void;
229
- }) => void) => VaporFragment;
349
+ }) => void) => ForFragment;
230
350
  export declare function createForSlots(rawSource: Source, getSlot: (item: any, key: any, index?: number) => DynamicSlot): DynamicSlot[];
231
351
  export declare function getRestElement(val: any, keys: string[]): any;
232
352
  export declare function getDefaultValue(val: any, defaultVal: any): any;
233
353
 
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;
354
+ export declare function createDynamicComponent(getter: () => any, rawProps?: RawProps | null, rawSlots?: RawSlots | null, isSingleRoot?: boolean, once?: boolean): VaporFragment;
240
355
 
241
356
  export declare function applyVShow(target: Block, source: () => any): void;
242
357
 
@@ -249,4 +364,8 @@ export declare const applyRadioModel: VaporModelDirective<HTMLInputElement>;
249
364
  export declare const applySelectModel: VaporModelDirective<HTMLSelectElement, 'number'>;
250
365
  export declare const applyDynamicModel: VaporModelDirective;
251
366
 
367
+ export declare const VaporTransition: FunctionalVaporComponent;
368
+
369
+ export declare const VaporTransitionGroup: ObjectVaporComponent;
252
370
 
371
+ export { VaporKeepAliveImpl as VaporKeepAlive, VaporTeleportImpl as VaporTeleport, };