@vue/runtime-vapor 0.0.0 → 3.6.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # @vue/runtime-vapor
2
2
 
3
- > **Note**
4
- > Work in progress. Do not use yet.
3
+ This package only ships `esm-bundler` build because:
4
+
5
+ 1. Vapor mode requires SFC build.
6
+ 2. Vapor mode runtime only runs in the browser.
7
+
8
+ The main `vue` package ships `dist/vue.runtime-with-vapor.esm-browser.js` which inlines this package. It is used for the SFC Playground only.
@@ -0,0 +1,247 @@
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';
3
+ import { NormalizedStyle } from '@vue/shared';
4
+
5
+ type Block = Node | VaporFragment | DynamicFragment | VaporComponentInstance | Block[];
6
+ type BlockFn = (...args: any[]) => Block;
7
+ export declare class VaporFragment {
8
+ nodes: Block;
9
+ anchor?: Node;
10
+ insert?: (parent: ParentNode, anchor: Node | null) => void;
11
+ remove?: (parent?: ParentNode) => void;
12
+ constructor(nodes: Block);
13
+ }
14
+ declare class DynamicFragment extends VaporFragment {
15
+ anchor: Node;
16
+ scope: EffectScope | undefined;
17
+ current?: BlockFn;
18
+ fallback?: BlockFn;
19
+ constructor(anchorLabel?: string);
20
+ update(render?: BlockFn, key?: any): void;
21
+ }
22
+ export declare function isFragment(val: NonNullable<unknown>): val is VaporFragment;
23
+ export declare function insert(block: Block, parent: ParentNode, anchor?: Node | null | 0): void;
24
+ export declare function prepend(parent: ParentNode, ...blocks: Block[]): void;
25
+ export declare function remove(block: Block, parent?: ParentNode): void;
26
+
27
+ type RawProps = Record<string, () => unknown> & {
28
+ $?: DynamicPropsSource[];
29
+ };
30
+ type DynamicPropsSource = (() => Record<string, unknown>) | Record<string, () => unknown>;
31
+
32
+ type RawSlots = Record<string, VaporSlot> & {
33
+ $?: DynamicSlotSource[];
34
+ };
35
+ type StaticSlots = Record<string, VaporSlot>;
36
+ type VaporSlot = BlockFn;
37
+ type DynamicSlot = {
38
+ name: string;
39
+ fn: VaporSlot;
40
+ };
41
+ type DynamicSlotFn = () => DynamicSlot | DynamicSlot[];
42
+ type DynamicSlotSource = StaticSlots | DynamicSlotFn;
43
+ export declare function createSlot(name: string | (() => string), rawProps?: LooseRawProps | null, fallback?: VaporSlot): Block;
44
+
45
+ type VaporComponent = FunctionalVaporComponent | ObjectVaporComponent;
46
+ type VaporSetupFn = (props: any, ctx: Pick<VaporComponentInstance, 'slots' | 'attrs' | 'emit' | 'expose'>) => Block | Record<string, any> | undefined;
47
+ type FunctionalVaporComponent = VaporSetupFn & Omit<ObjectVaporComponent, 'setup'> & {
48
+ displayName?: string;
49
+ } & SharedInternalOptions;
50
+ interface ObjectVaporComponent extends ComponentInternalOptions, SharedInternalOptions {
51
+ setup?: VaporSetupFn;
52
+ inheritAttrs?: boolean;
53
+ props?: ComponentPropsOptions;
54
+ emits?: EmitsOptions;
55
+ render?(ctx: any, props?: any, emit?: EmitFn, attrs?: any, slots?: Record<string, VaporSlot>): Block;
56
+ name?: string;
57
+ vapor?: boolean;
58
+ }
59
+ interface SharedInternalOptions {
60
+ /**
61
+ * Cached normalized props options.
62
+ * In vapor mode there are no mixins so normalized options can be cached
63
+ * directly on the component
64
+ */
65
+ __propsOptions?: NormalizedPropsOptions;
66
+ /**
67
+ * Cached normalized props proxy handlers.
68
+ */
69
+ __propsHandlers?: [ProxyHandler<any> | null, ProxyHandler<any>];
70
+ /**
71
+ * Cached normalized emits options.
72
+ */
73
+ __emitsOptions?: ObjectEmitsOptions;
74
+ }
75
+ type LooseRawProps = Record<string, (() => unknown) | DynamicPropsSource[]> & {
76
+ $?: DynamicPropsSource[];
77
+ };
78
+ type LooseRawSlots = Record<string, VaporSlot | DynamicSlotSource[]> & {
79
+ $?: DynamicSlotSource[];
80
+ };
81
+ export declare function createComponent(component: VaporComponent, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean, appContext?: GenericAppContext): VaporComponentInstance;
82
+ declare class VaporComponentInstance implements GenericComponentInstance {
83
+ vapor: true;
84
+ uid: number;
85
+ type: VaporComponent;
86
+ root: GenericComponentInstance | null;
87
+ parent: GenericComponentInstance | null;
88
+ appContext: GenericAppContext;
89
+ block: Block;
90
+ scope: EffectScope$1;
91
+ rawProps: RawProps;
92
+ rawSlots: RawSlots;
93
+ props: Record<string, any>;
94
+ attrs: Record<string, any>;
95
+ propsDefaults: Record<string, any> | null;
96
+ slots: StaticSlots;
97
+ rawPropsRef?: ShallowRef<any>;
98
+ rawSlotsRef?: ShallowRef<any>;
99
+ emit: EmitFn;
100
+ emitted: Record<string, boolean> | null;
101
+ expose: (exposed: Record<string, any>) => void;
102
+ exposed: Record<string, any> | null;
103
+ exposeProxy: Record<string, any> | null;
104
+ refs: Record<string, any>;
105
+ provides: Record<string, any>;
106
+ ids: [string, number, number];
107
+ suspense: SuspenseBoundary | null;
108
+ hasFallthrough: boolean;
109
+ isMounted: boolean;
110
+ isUnmounted: boolean;
111
+ isDeactivated: boolean;
112
+ isUpdating: boolean;
113
+ bc?: LifecycleHook;
114
+ c?: LifecycleHook;
115
+ bm?: LifecycleHook;
116
+ m?: LifecycleHook;
117
+ bu?: LifecycleHook;
118
+ u?: LifecycleHook;
119
+ um?: LifecycleHook;
120
+ bum?: LifecycleHook;
121
+ da?: LifecycleHook;
122
+ a?: LifecycleHook;
123
+ rtg?: LifecycleHook;
124
+ rtc?: LifecycleHook;
125
+ ec?: LifecycleHook;
126
+ sp?: LifecycleHook<() => Promise<unknown>>;
127
+ setupState?: Record<string, any>;
128
+ devtoolsRawSetupState?: any;
129
+ hmrRerender?: () => void;
130
+ hmrReload?: (newComp: VaporComponent) => void;
131
+ propsOptions?: NormalizedPropsOptions;
132
+ emitsOptions?: ObjectEmitsOptions | null;
133
+ isSingleRoot?: boolean;
134
+ constructor(comp: VaporComponent, rawProps?: RawProps | null, rawSlots?: RawSlots | null, appContext?: GenericAppContext);
135
+ /**
136
+ * Expose `getKeysFromRawProps` on the instance so it can be used in code
137
+ * paths where it's needed, e.g. `useModel`
138
+ */
139
+ rawKeys(): string[];
140
+ }
141
+ export declare function isVaporComponent(value: unknown): value is VaporComponentInstance;
142
+ /**
143
+ * Used when a component cannot be resolved at compile time
144
+ * and needs rely on runtime resolution - where it might fallback to a plain
145
+ * element if the resolution fails.
146
+ */
147
+ export declare function createComponentWithFallback(comp: VaporComponent | string, rawProps?: LooseRawProps | null, rawSlots?: LooseRawSlots | null, isSingleRoot?: boolean): HTMLElement | VaporComponentInstance;
148
+
149
+ export declare const createVaporApp: CreateAppFunction<ParentNode, VaporComponent>;
150
+ export declare const createVaporSSRApp: CreateAppFunction<ParentNode, VaporComponent>;
151
+
152
+ /*! #__NO_SIDE_EFFECTS__ */
153
+ export declare function defineVaporComponent(comp: VaporComponent, extraOptions?: Omit<ObjectVaporComponent, 'setup'>): VaporComponent;
154
+
155
+ export declare const vaporInteropPlugin: Plugin;
156
+
157
+ export type VaporDirective = (node: Element | VaporComponentInstance, value?: () => any, argument?: string, modifiers?: DirectiveModifiers) => (() => void) | void;
158
+ type VaporDirectiveArguments = Array<[VaporDirective | undefined] | [VaporDirective | undefined, () => any] | [VaporDirective | undefined, (() => any) | undefined, argument: string] | [
159
+ VaporDirective | undefined,
160
+ value: (() => any) | undefined,
161
+ argument: string | undefined,
162
+ modifiers: DirectiveModifiers
163
+ ]>;
164
+ export declare function withVaporDirectives(node: Element | VaporComponentInstance, dirs: VaporDirectiveArguments): void;
165
+
166
+ /**
167
+ * This function is called before a block type that requires insertion
168
+ * (component, slot outlet, if, for) is created. The state is used for actual
169
+ * insertion on client-side render, and used for node adoption during hydration.
170
+ */
171
+ export declare function setInsertionState(parent: ParentNode, anchor?: Node | 0): void;
172
+
173
+ export declare function renderEffect(fn: () => void, noLifecycle?: boolean): void;
174
+
175
+ /*! #__NO_SIDE_EFFECTS__ */
176
+ export declare function template(html: string, root?: boolean): () => Node & {
177
+ $root?: true;
178
+ };
179
+
180
+ /*! #__NO_SIDE_EFFECTS__ */
181
+ 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;
188
+
189
+ type TargetElement = Element & {
190
+ $root?: true;
191
+ $html?: string;
192
+ $cls?: string;
193
+ $sty?: NormalizedStyle | string | undefined;
194
+ value?: string;
195
+ _value?: any;
196
+ };
197
+ export declare function setProp(el: any, key: string, value: any): void;
198
+ export declare function setAttr(el: any, key: string, value: any): void;
199
+ export declare function setDOMProp(el: any, key: string, value: any): void;
200
+ export declare function setClass(el: TargetElement, value: any): void;
201
+ export declare function setStyle(el: TargetElement, value: any): void;
202
+ export declare function setValue(el: TargetElement, value: any): void;
203
+ /**
204
+ * Only called on text nodes!
205
+ * Compiler should also ensure value passed here is already converted by
206
+ * `toDisplayString`
207
+ */
208
+ export declare function setText(el: Text & {
209
+ $txt?: string;
210
+ }, value: string): void;
211
+ export declare function setHtml(el: TargetElement, value: any): void;
212
+ export declare function setDynamicProps(el: any, args: any[]): void;
213
+
214
+ export declare function on(el: Element, event: string, handler: (e: Event) => any, options?: AddEventListenerOptions & {
215
+ effect?: boolean;
216
+ }): void;
217
+ export declare function delegate(el: any, event: string, handler: (e: Event) => any): void;
218
+ export declare const delegateEvents: (...names: string[]) => void;
219
+ export declare function setDynamicEvents(el: HTMLElement, events: Record<string, (...args: any[]) => any>): void;
220
+
221
+ export declare function createIf(condition: () => any, b1: BlockFn, b2?: BlockFn, once?: boolean): Block;
222
+
223
+ 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;
225
+ export declare function createForSlots(rawSource: Source, getSlot: (item: any, key: any, index?: number) => DynamicSlot): DynamicSlot[];
226
+ export declare function getRestElement(val: any, keys: string[]): any;
227
+ export declare function getDefaultValue(val: any, defaultVal: any): any;
228
+
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;
235
+
236
+ export declare function applyVShow(target: Block, source: () => any): void;
237
+
238
+ type VaporModelDirective<T extends HTMLElement = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement, Modifiers extends string = string> = (el: T, get: () => any, set: (v: any) => void, modifiers?: {
239
+ [key in Modifiers]?: true;
240
+ }) => void;
241
+ export declare const applyTextModel: VaporModelDirective<HTMLInputElement | HTMLTextAreaElement, 'trim' | 'number' | 'lazy'>;
242
+ export declare const applyCheckboxModel: VaporModelDirective<HTMLInputElement>;
243
+ export declare const applyRadioModel: VaporModelDirective<HTMLInputElement>;
244
+ export declare const applySelectModel: VaporModelDirective<HTMLSelectElement, 'number'>;
245
+ export declare const applyDynamicModel: VaporModelDirective;
246
+
247
+