@vue/runtime-vapor 3.6.0-alpha.1 → 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,34 +1,83 @@
1
- import { GenericComponentInstance, GenericAppContext, EffectScope as EffectScope$1, EmitFn, SuspenseBoundary, LifecycleHook, NormalizedPropsOptions, ObjectEmitsOptions, ComponentInternalOptions, ComponentPropsOptions, EmitsOptions, CreateAppFunction, Plugin, 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
 
60
+ declare const interopKey: unique symbol;
61
+ export declare const vaporInteropPlugin: Plugin;
62
+
27
63
  type RawProps = Record<string, () => unknown> & {
28
- $?: DynamicPropsSource[];
64
+ $?: DynamicPropsSource[] & {
65
+ [interopKey]?: boolean;
66
+ };
29
67
  };
30
68
  type DynamicPropsSource = (() => Record<string, unknown>) | Record<string, () => unknown>;
31
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
+
32
81
  type RawSlots = Record<string, VaporSlot> & {
33
82
  $?: DynamicSlotSource[];
34
83
  };
@@ -40,14 +89,58 @@ type DynamicSlot = {
40
89
  };
41
90
  type DynamicSlotFn = () => DynamicSlot | DynamicSlot[];
42
91
  type DynamicSlotSource = StaticSlots | DynamicSlotFn;
43
- 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
+ }
44
137
 
45
138
  type VaporComponent = FunctionalVaporComponent | ObjectVaporComponent;
46
139
  type VaporSetupFn = (props: any, ctx: Pick<VaporComponentInstance, 'slots' | 'attrs' | 'emit' | 'expose'>) => Block | Record<string, any> | undefined;
47
140
  type FunctionalVaporComponent = VaporSetupFn & Omit<ObjectVaporComponent, 'setup'> & {
48
141
  displayName?: string;
49
142
  } & SharedInternalOptions;
50
- interface ObjectVaporComponent extends ComponentInternalOptions, SharedInternalOptions {
143
+ interface ObjectVaporComponent extends ComponentInternalOptions, AsyncComponentInternalOptions<ObjectVaporComponent, VaporComponentInstance>, SharedInternalOptions {
51
144
  setup?: VaporSetupFn;
52
145
  inheritAttrs?: boolean;
53
146
  props?: ComponentPropsOptions;
@@ -78,7 +171,7 @@ type LooseRawProps = Record<string, (() => unknown) | DynamicPropsSource[]> & {
78
171
  type LooseRawSlots = Record<string, VaporSlot | DynamicSlotSource[]> & {
79
172
  $?: DynamicSlotSource[];
80
173
  };
81
- 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;
82
175
  declare class VaporComponentInstance implements GenericComponentInstance {
83
176
  vapor: true;
84
177
  uid: number;
@@ -128,10 +221,13 @@ declare class VaporComponentInstance implements GenericComponentInstance {
128
221
  devtoolsRawSetupState?: any;
129
222
  hmrRerender?: () => void;
130
223
  hmrReload?: (newComp: VaporComponent) => void;
224
+ renderEffects?: RenderEffect[];
225
+ parentTeleport?: TeleportFragment | null;
131
226
  propsOptions?: NormalizedPropsOptions;
132
227
  emitsOptions?: ObjectEmitsOptions | null;
133
228
  isSingleRoot?: boolean;
134
- 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);
135
231
  /**
136
232
  * Expose `getKeysFromRawProps` on the instance so it can be used in code
137
233
  * paths where it's needed, e.g. `useModel`
@@ -144,7 +240,7 @@ export declare function isVaporComponent(value: unknown): value is VaporComponen
144
240
  * and needs rely on runtime resolution - where it might fallback to a plain
145
241
  * element if the resolution fails.
146
242
  */
147
- 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;
148
244
 
149
245
  export declare const createVaporApp: CreateAppFunction<ParentNode, VaporComponent>;
150
246
  export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporComponent>;
@@ -152,7 +248,7 @@ export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporCompo
152
248
  /*! #__NO_SIDE_EFFECTS__ */
153
249
  export declare function defineVaporComponent(comp: VaporComponent, extraOptions?: Omit<ObjectVaporComponent, 'setup'>): VaporComponent;
154
250
 
155
- export declare const vaporInteropPlugin: Plugin;
251
+ export declare function defineVaporAsyncComponent<T extends VaporComponent>(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T;
156
252
 
157
253
  export type VaporDirective = (node: Element | VaporComponentInstance, value?: () => any, argument?: string, modifiers?: DirectiveModifiers) => (() => void) | void;
158
254
  type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirective | undefined, () => any] | [VaporDirective | undefined, (() => any) | undefined, argument: string] | [
@@ -163,28 +259,41 @@ type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirect
163
259
  ]>;
164
260
  export declare function withVaporDirectives(node: Element | VaporComponentInstance, dirs: VaporDirectiveArguments): void;
165
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
+ };
166
271
  /**
167
272
  * This function is called before a block type that requires insertion
168
273
  * (component, slot outlet, if, for) is created. The state is used for actual
169
274
  * insertion on client-side render, and used for node adoption during hydration.
170
275
  */
171
- export declare function setInsertionState(parent: ParentNode, anchor?: Node | 0): void;
172
-
173
- 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;
174
279
 
175
280
  /*! #__NO_SIDE_EFFECTS__ */
176
281
  export declare function template(html: string, root?: boolean): () => Node & {
177
282
  $root?: true;
178
283
  };
179
284
 
180
- /*! #__NO_SIDE_EFFECTS__ */
181
285
  export declare function createTextNode(value?: string): Text;
182
- /*! #__NO_SIDE_EFFECTS__ */
183
- export declare function child(node: ParentNode): Node;
184
- /*! #__NO_SIDE_EFFECTS__ */
185
- export declare function nthChild(node: Node, i: number): Node;
186
- /*! #__NO_SIDE_EFFECTS__ */
187
- 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>;
188
297
 
189
298
  type TargetElement = Element & {
190
299
  $root?: true;
@@ -196,10 +305,10 @@ type TargetElement = Element & {
196
305
  };
197
306
  export declare function setProp(el: any, key: string, value: any): void;
198
307
  export declare function setAttr(el: any, key: string, value: any): void;
199
- 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;
200
309
  export declare function setClass(el: TargetElement, value: any): void;
201
310
  export declare function setStyle(el: TargetElement, value: any): void;
202
- export declare function setValue(el: TargetElement, value: any): void;
311
+ export declare function setValue(el: TargetElement, value: any, forceHydrate?: boolean): void;
203
312
  /**
204
313
  * Only called on text nodes!
205
314
  * Compiler should also ensure value passed here is already converted by
@@ -208,7 +317,19 @@ export declare function setValue(el: TargetElement, value: any): void;
208
317
  export declare function setText(el: Text & {
209
318
  $txt?: string;
210
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;
211
329
  export declare function setHtml(el: TargetElement, value: any): void;
330
+ export declare function setBlockHtml(block: Block & {
331
+ $html?: string;
332
+ }, value: any): void;
212
333
  export declare function setDynamicProps(el: any, args: any[]): void;
213
334
 
214
335
  export declare function on(el: Element, event: string, handler: (e: Event) => any, options?: AddEventListenerOptions & {
@@ -220,18 +341,17 @@ export declare function setDynamicEvents(el: HTMLElement, events: Record<string,
220
341
 
221
342
  export declare function createIf(condition: () => any, b1: BlockFn, b2?: BlockFn, once?: boolean): Block;
222
343
 
344
+ export declare function createKeyedFragment(key: () => any, render: BlockFn): Block;
345
+
223
346
  type Source = any[] | Record<any, any> | number | Set<any> | Map<any, any>;
224
- 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) => VaporFragment;
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?: (_: {
348
+ createSelector: (source: () => any) => (cb: () => void) => void;
349
+ }) => void) => ForFragment;
225
350
  export declare function createForSlots(rawSource: Source, getSlot: (item: any, key: any, index?: number) => DynamicSlot): DynamicSlot[];
226
351
  export declare function getRestElement(val: any, keys: string[]): any;
227
352
  export declare function getDefaultValue(val: any, defaultVal: any): any;
228
353
 
229
- type NodeRef = string | Ref | ((ref: Element) => void);
230
- type RefEl = Element | VaporComponentInstance;
231
- type setRefFn = (el: RefEl, ref: NodeRef, oldRef?: NodeRef, refFor?: boolean) => NodeRef | undefined;
232
- export declare function createTemplateRefSetter(): setRefFn;
233
-
234
- 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;
235
355
 
236
356
  export declare function applyVShow(target: Block, source: () => any): void;
237
357
 
@@ -244,4 +364,8 @@ export declare const applyRadioModel: VaporModelDirective<HTMLInputElement>;
244
364
  export declare const applySelectModel: VaporModelDirective<HTMLSelectElement, 'number'>;
245
365
  export declare const applyDynamicModel: VaporModelDirective;
246
366
 
367
+ export declare const VaporTransition: FunctionalVaporComponent;
368
+
369
+ export declare const VaporTransitionGroup: ObjectVaporComponent;
247
370
 
371
+ export { VaporKeepAliveImpl as VaporKeepAlive, VaporTeleportImpl as VaporTeleport, };