@vue/runtime-vapor 0.0.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/LICENSE +21 -0
- package/README.md +4 -0
- package/dist/runtime-vapor.esm-bundler.js +1707 -0
- package/index.js +7 -0
- package/package.json +41 -0
|
@@ -0,0 +1,1707 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vue/runtime-vapor v3.5.13
|
|
3
|
+
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
|
+
* @license MIT
|
|
5
|
+
**/
|
|
6
|
+
import { warn, queueJob, currentInstance as currentInstance$1, startMeasure, simpleSetCurrentInstance as simpleSetCurrentInstance$1, queuePostFlushCb, patchStyle, mergeProps, shouldSetAsProp, baseEmit, baseNormalizePropsOptions, pushWarningContext, validateProps, popWarningContext, isEmitListener, resolvePropValue, callWithErrorHandling, registerHMR, endMeasure, nextUid, EffectScope as EffectScope$1, expose, unregisterHMR, initFeatureFlags, setDevtoolsHook, createAppAPI, normalizeContainer, flushOnAppMount, resolveDynamicComponent, vShowOriginalDisplay, vShowHidden, vModelTextInit, onMounted, vModelCheckboxInit, vModelSelectInit, vModelTextUpdate, vModelCheckboxUpdate, vModelGetValue, vModelSetSelected, shallowRef as shallowRef$1 } from '@vue/runtime-dom';
|
|
7
|
+
import { invokeArrayFns, remove as remove$1, normalizeClass, normalizeStyle, isString, parseStringStyle, toDisplayString, isOn, canSetValueDirectly, isArray, EMPTY_OBJ, hasOwn, isFunction, EMPTY_ARR, camelize, NO, YES, getGlobalThis, isObject, getSequence, looseEqual } from '@vue/shared';
|
|
8
|
+
import { getCurrentScope, ReactiveEffect, onEffectCleanup, onScopeDispose, pauseTracking, EffectScope, resetTracking, proxyRefs, markRaw, unref, isReactive, isShallow, shallowReadArray, toReactive, shallowRef, isRef, traverse } from '@vue/reactivity';
|
|
9
|
+
|
|
10
|
+
function renderEffect(fn, noLifecycle = false) {
|
|
11
|
+
const instance = currentInstance$1;
|
|
12
|
+
const scope = getCurrentScope();
|
|
13
|
+
if (!!(process.env.NODE_ENV !== "production") && true && !isVaporComponent(instance)) {
|
|
14
|
+
warn("renderEffect called without active vapor instance.");
|
|
15
|
+
}
|
|
16
|
+
const hasUpdateHooks = instance && (instance.bu || instance.u);
|
|
17
|
+
const renderEffectFn = noLifecycle ? fn : () => {
|
|
18
|
+
if (!!(process.env.NODE_ENV !== "production") && instance) {
|
|
19
|
+
startMeasure(instance, `renderEffect`);
|
|
20
|
+
}
|
|
21
|
+
const prev = currentInstance$1;
|
|
22
|
+
simpleSetCurrentInstance$1(instance);
|
|
23
|
+
if (scope) scope.on();
|
|
24
|
+
if (hasUpdateHooks && instance.isMounted && !instance.isUpdating) {
|
|
25
|
+
instance.isUpdating = true;
|
|
26
|
+
instance.bu && invokeArrayFns(instance.bu);
|
|
27
|
+
fn();
|
|
28
|
+
queuePostFlushCb(() => {
|
|
29
|
+
instance.isUpdating = false;
|
|
30
|
+
instance.u && invokeArrayFns(instance.u);
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
fn();
|
|
34
|
+
}
|
|
35
|
+
if (scope) scope.off();
|
|
36
|
+
simpleSetCurrentInstance$1(prev, instance);
|
|
37
|
+
if (!!(process.env.NODE_ENV !== "production") && instance) {
|
|
38
|
+
startMeasure(instance, `renderEffect`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const effect = new ReactiveEffect(renderEffectFn);
|
|
42
|
+
const job = () => effect.dirty && effect.run();
|
|
43
|
+
if (instance) {
|
|
44
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
45
|
+
effect.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : undefined;
|
|
46
|
+
effect.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : undefined;
|
|
47
|
+
}
|
|
48
|
+
job.i = instance;
|
|
49
|
+
job.id = instance.uid;
|
|
50
|
+
}
|
|
51
|
+
effect.scheduler = () => queueJob(job);
|
|
52
|
+
effect.run();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function addEventListener(el, event, handler, options) {
|
|
56
|
+
el.addEventListener(event, handler, options);
|
|
57
|
+
return () => el.removeEventListener(event, handler, options);
|
|
58
|
+
}
|
|
59
|
+
function on(el, event, handlerGetter, options = {}) {
|
|
60
|
+
const handler = eventHandler(handlerGetter);
|
|
61
|
+
let cleanupEvent;
|
|
62
|
+
queuePostFlushCb(() => {
|
|
63
|
+
cleanupEvent = addEventListener(el, event, handler, options);
|
|
64
|
+
});
|
|
65
|
+
if (options.effect) {
|
|
66
|
+
onEffectCleanup(cleanup);
|
|
67
|
+
} else if (getCurrentScope()) {
|
|
68
|
+
onScopeDispose(cleanup);
|
|
69
|
+
}
|
|
70
|
+
function cleanup() {
|
|
71
|
+
cleanupEvent && cleanupEvent();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function delegate(el, event, handlerGetter) {
|
|
75
|
+
const handler = eventHandler(handlerGetter);
|
|
76
|
+
handler.delegate = true;
|
|
77
|
+
const cacheKey = `$evt${event}`;
|
|
78
|
+
const handlers = el[cacheKey] || (el[cacheKey] = []);
|
|
79
|
+
handlers.push(handler);
|
|
80
|
+
onScopeDispose(() => remove$1(handlers, handler));
|
|
81
|
+
}
|
|
82
|
+
function eventHandler(getter) {
|
|
83
|
+
return (...args) => {
|
|
84
|
+
let handler = getter();
|
|
85
|
+
if (!handler) return;
|
|
86
|
+
handler && handler(...args);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const delegatedEvents = /* @__PURE__ */ Object.create(null);
|
|
90
|
+
const delegateEvents = (...names) => {
|
|
91
|
+
for (const name of names) {
|
|
92
|
+
if (!delegatedEvents[name]) {
|
|
93
|
+
delegatedEvents[name] = true;
|
|
94
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const delegatedEventHandler = (e) => {
|
|
99
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
100
|
+
if (e.target !== node) {
|
|
101
|
+
Object.defineProperty(e, "target", {
|
|
102
|
+
configurable: true,
|
|
103
|
+
value: node
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
Object.defineProperty(e, "currentTarget", {
|
|
107
|
+
configurable: true,
|
|
108
|
+
get() {
|
|
109
|
+
return node || document;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
while (node !== null) {
|
|
113
|
+
const handlers = node[`$evt${e.type}`];
|
|
114
|
+
if (handlers) {
|
|
115
|
+
for (const handler of handlers) {
|
|
116
|
+
if (handler.delegate && !node.disabled) {
|
|
117
|
+
handler(e);
|
|
118
|
+
if (e.cancelBubble) return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
function setDynamicEvents(el, events) {
|
|
126
|
+
for (const name in events) {
|
|
127
|
+
on(el, name, () => events[name], { effect: true });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const hasFallthroughKey = (key) => currentInstance$1.hasFallthrough && key in currentInstance$1.attrs;
|
|
132
|
+
function setProp(el, key, value) {
|
|
133
|
+
if (key in el) {
|
|
134
|
+
setDOMProp(el, key, value);
|
|
135
|
+
} else {
|
|
136
|
+
setAttr(el, key, value);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function setAttr(el, key, value) {
|
|
140
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey(key)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (key === "true-value") {
|
|
144
|
+
el._trueValue = value;
|
|
145
|
+
} else if (key === "false-value") {
|
|
146
|
+
el._falseValue = value;
|
|
147
|
+
}
|
|
148
|
+
if (value !== el[`$${key}`]) {
|
|
149
|
+
el[`$${key}`] = value;
|
|
150
|
+
if (value != null) {
|
|
151
|
+
el.setAttribute(key, value);
|
|
152
|
+
} else {
|
|
153
|
+
el.removeAttribute(key);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function setDOMProp(el, key, value) {
|
|
158
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey(key)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const prev = el[key];
|
|
162
|
+
if (value === prev) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
let needRemove = false;
|
|
166
|
+
if (value === "" || value == null) {
|
|
167
|
+
const type = typeof prev;
|
|
168
|
+
if (value == null && type === "string") {
|
|
169
|
+
value = "";
|
|
170
|
+
needRemove = true;
|
|
171
|
+
} else if (type === "number") {
|
|
172
|
+
value = 0;
|
|
173
|
+
needRemove = true;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
el[key] = value;
|
|
178
|
+
} catch (e) {
|
|
179
|
+
if (!!(process.env.NODE_ENV !== "production") && !needRemove) {
|
|
180
|
+
warn(
|
|
181
|
+
`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: value ${value} is invalid.`,
|
|
182
|
+
e
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
needRemove && el.removeAttribute(key);
|
|
187
|
+
}
|
|
188
|
+
function setClass(el, value) {
|
|
189
|
+
if (el.$root) {
|
|
190
|
+
setClassIncremental(el, value);
|
|
191
|
+
} else if ((value = normalizeClass(value)) !== el.$cls) {
|
|
192
|
+
el.className = el.$cls = value;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function setClassIncremental(el, value) {
|
|
196
|
+
const cacheKey = `$clsi${isApplyingFallthroughProps ? "$" : ""}`;
|
|
197
|
+
const prev = el[cacheKey];
|
|
198
|
+
if ((value = el[cacheKey] = normalizeClass(value)) !== prev) {
|
|
199
|
+
const nextList = value.split(/\s+/);
|
|
200
|
+
el.classList.add(...nextList);
|
|
201
|
+
if (prev) {
|
|
202
|
+
for (const cls of prev.split(/\s+/)) {
|
|
203
|
+
if (!nextList.includes(cls)) el.classList.remove(cls);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function setStyle(el, value) {
|
|
209
|
+
if (el.$root) {
|
|
210
|
+
setStyleIncremental(el, value);
|
|
211
|
+
} else {
|
|
212
|
+
const prev = el.$sty;
|
|
213
|
+
value = el.$sty = normalizeStyle(value);
|
|
214
|
+
patchStyle(el, prev, value);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
function setStyleIncremental(el, value) {
|
|
218
|
+
const cacheKey = `$styi${isApplyingFallthroughProps ? "$" : ""}`;
|
|
219
|
+
const prev = el[cacheKey];
|
|
220
|
+
value = el[cacheKey] = isString(value) ? parseStringStyle(value) : normalizeStyle(value);
|
|
221
|
+
patchStyle(el, prev, value);
|
|
222
|
+
return value;
|
|
223
|
+
}
|
|
224
|
+
function setValue(el, value) {
|
|
225
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey("value")) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
el._value = value;
|
|
229
|
+
const oldValue = el.tagName === "OPTION" ? el.getAttribute("value") : el.value;
|
|
230
|
+
const newValue = value == null ? "" : value;
|
|
231
|
+
if (oldValue !== newValue) {
|
|
232
|
+
el.value = newValue;
|
|
233
|
+
}
|
|
234
|
+
if (value == null) {
|
|
235
|
+
el.removeAttribute("value");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function setText(el, ...values) {
|
|
239
|
+
const value = values.length > 1 ? values.map(toDisplayString).join("") : toDisplayString(values[0]);
|
|
240
|
+
if (el.$txt !== value) {
|
|
241
|
+
el.textContent = el.$txt = value;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function setHtml(el, value) {
|
|
245
|
+
value = value == null ? "" : value;
|
|
246
|
+
if (el.$html !== value) {
|
|
247
|
+
el.innerHTML = el.$html = value;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function setDynamicProps(el, args) {
|
|
251
|
+
const props = args.length > 1 ? mergeProps(...args) : args[0];
|
|
252
|
+
const cacheKey = `$dprops${isApplyingFallthroughProps ? "$" : ""}`;
|
|
253
|
+
const prevKeys = el[cacheKey];
|
|
254
|
+
if (prevKeys) {
|
|
255
|
+
for (const key of prevKeys) {
|
|
256
|
+
if (!(key in props)) {
|
|
257
|
+
setDynamicProp(el, key, null);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
for (const key of el[cacheKey] = Object.keys(props)) {
|
|
262
|
+
setDynamicProp(el, key, props[key]);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function setDynamicProp(el, key, value) {
|
|
266
|
+
const isSVG = false;
|
|
267
|
+
if (key === "class") {
|
|
268
|
+
setClass(el, value);
|
|
269
|
+
} else if (key === "style") {
|
|
270
|
+
setStyle(el, value);
|
|
271
|
+
} else if (isOn(key)) {
|
|
272
|
+
on(el, key[2].toLowerCase() + key.slice(3), () => value, { effect: true });
|
|
273
|
+
} else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, value, isSVG)) {
|
|
274
|
+
if (key === "innerHTML") {
|
|
275
|
+
setHtml(el, value);
|
|
276
|
+
} else if (key === "textContent") {
|
|
277
|
+
setText(el, value);
|
|
278
|
+
} else if (key === "value" && canSetValueDirectly(el.tagName)) {
|
|
279
|
+
setValue(el, value);
|
|
280
|
+
} else {
|
|
281
|
+
setDOMProp(el, key, value);
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
setAttr(el, key, value);
|
|
285
|
+
}
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function createTextNode(values) {
|
|
290
|
+
const node = document.createTextNode("");
|
|
291
|
+
if (values) {
|
|
292
|
+
if (isArray(values)) {
|
|
293
|
+
setText(node, ...values);
|
|
294
|
+
} else {
|
|
295
|
+
renderEffect(() => setText(node, ...values()));
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return node;
|
|
299
|
+
}
|
|
300
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
301
|
+
// @__NO_SIDE_EFFECTS__
|
|
302
|
+
function createComment(data) {
|
|
303
|
+
return document.createComment(data);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
class Fragment {
|
|
307
|
+
constructor(nodes) {
|
|
308
|
+
this.nodes = nodes;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
class DynamicFragment extends Fragment {
|
|
312
|
+
constructor(anchorLabel) {
|
|
313
|
+
super([]);
|
|
314
|
+
this.anchor = !!(process.env.NODE_ENV !== "production") && anchorLabel ? createComment(anchorLabel) : document.createTextNode("");
|
|
315
|
+
}
|
|
316
|
+
update(render, key = render) {
|
|
317
|
+
if (key === this.current) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
this.current = key;
|
|
321
|
+
pauseTracking();
|
|
322
|
+
const parent = this.anchor.parentNode;
|
|
323
|
+
if (this.scope) {
|
|
324
|
+
this.scope.stop();
|
|
325
|
+
parent && remove(this.nodes, parent);
|
|
326
|
+
}
|
|
327
|
+
if (render) {
|
|
328
|
+
this.scope = new EffectScope();
|
|
329
|
+
this.nodes = this.scope.run(render) || [];
|
|
330
|
+
if (parent) insert(this.nodes, parent, this.anchor);
|
|
331
|
+
} else {
|
|
332
|
+
this.scope = undefined;
|
|
333
|
+
this.nodes = [];
|
|
334
|
+
}
|
|
335
|
+
if (this.fallback && !isValidBlock(this.nodes)) {
|
|
336
|
+
parent && remove(this.nodes, parent);
|
|
337
|
+
this.nodes = (this.scope || (this.scope = new EffectScope())).run(this.fallback) || [];
|
|
338
|
+
parent && insert(this.nodes, parent, this.anchor);
|
|
339
|
+
}
|
|
340
|
+
resetTracking();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function isFragment(val) {
|
|
344
|
+
return val instanceof Fragment;
|
|
345
|
+
}
|
|
346
|
+
function isBlock(val) {
|
|
347
|
+
return val instanceof Node || isArray(val) || isVaporComponent(val) || isFragment(val);
|
|
348
|
+
}
|
|
349
|
+
function isValidBlock(block) {
|
|
350
|
+
if (block instanceof Node) {
|
|
351
|
+
return !(block instanceof Comment);
|
|
352
|
+
} else if (isVaporComponent(block)) {
|
|
353
|
+
return isValidBlock(block.block);
|
|
354
|
+
} else if (isArray(block)) {
|
|
355
|
+
return block.length > 0 && block.every(isValidBlock);
|
|
356
|
+
} else {
|
|
357
|
+
return isValidBlock(block.nodes);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function insert(block, parent, anchor = null) {
|
|
361
|
+
anchor = anchor === 0 ? parent.firstChild : anchor;
|
|
362
|
+
if (block instanceof Node) {
|
|
363
|
+
parent.insertBefore(block, anchor);
|
|
364
|
+
} else if (isVaporComponent(block)) {
|
|
365
|
+
mountComponent(block, parent, anchor);
|
|
366
|
+
} else if (isArray(block)) {
|
|
367
|
+
for (let i = 0; i < block.length; i++) {
|
|
368
|
+
insert(block[i], parent, anchor);
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
insert(block.nodes, parent, anchor);
|
|
372
|
+
if (block.anchor) insert(block.anchor, parent, anchor);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function prepend(parent, ...blocks) {
|
|
376
|
+
let i = blocks.length;
|
|
377
|
+
while (i--) insert(blocks[i], parent, 0);
|
|
378
|
+
}
|
|
379
|
+
let parentsWithUnmountedChildren = null;
|
|
380
|
+
function remove(block, parent) {
|
|
381
|
+
const isRoot = !parentsWithUnmountedChildren;
|
|
382
|
+
if (isRoot) {
|
|
383
|
+
parentsWithUnmountedChildren = /* @__PURE__ */ new Set();
|
|
384
|
+
}
|
|
385
|
+
if (block instanceof Node) {
|
|
386
|
+
parent.removeChild(block);
|
|
387
|
+
} else if (isVaporComponent(block)) {
|
|
388
|
+
unmountComponent(block, parent);
|
|
389
|
+
} else if (isArray(block)) {
|
|
390
|
+
for (let i = 0; i < block.length; i++) {
|
|
391
|
+
remove(block[i], parent);
|
|
392
|
+
}
|
|
393
|
+
} else {
|
|
394
|
+
remove(block.nodes, parent);
|
|
395
|
+
if (block.anchor) remove(block.anchor, parent);
|
|
396
|
+
if (block.scope) {
|
|
397
|
+
block.scope.stop();
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (isRoot) {
|
|
401
|
+
for (const i of parentsWithUnmountedChildren) {
|
|
402
|
+
i.children = i.children.filter((n) => !n.isUnmounted);
|
|
403
|
+
}
|
|
404
|
+
parentsWithUnmountedChildren = null;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function normalizeBlock(block) {
|
|
408
|
+
if (!!!(process.env.NODE_ENV !== "production") && true) {
|
|
409
|
+
throw new Error(
|
|
410
|
+
"normalizeBlock should not be used in production code paths"
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
const nodes = [];
|
|
414
|
+
if (block instanceof Node) {
|
|
415
|
+
nodes.push(block);
|
|
416
|
+
} else if (isArray(block)) {
|
|
417
|
+
block.forEach((child) => nodes.push(...normalizeBlock(child)));
|
|
418
|
+
} else if (isVaporComponent(block)) {
|
|
419
|
+
nodes.push(...normalizeBlock(block.block));
|
|
420
|
+
} else {
|
|
421
|
+
nodes.push(...normalizeBlock(block.nodes));
|
|
422
|
+
block.anchor && nodes.push(block.anchor);
|
|
423
|
+
}
|
|
424
|
+
return nodes;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function normalizeEmitsOptions(comp) {
|
|
428
|
+
const cached = comp.__emitsOptions;
|
|
429
|
+
if (cached) return cached;
|
|
430
|
+
const raw = comp.emits;
|
|
431
|
+
if (!raw) return null;
|
|
432
|
+
let normalized;
|
|
433
|
+
if (isArray(raw)) {
|
|
434
|
+
normalized = {};
|
|
435
|
+
for (const key of raw) normalized[key] = null;
|
|
436
|
+
} else {
|
|
437
|
+
normalized = raw;
|
|
438
|
+
}
|
|
439
|
+
return comp.__emitsOptions = normalized;
|
|
440
|
+
}
|
|
441
|
+
function emit(instance, event, ...rawArgs) {
|
|
442
|
+
baseEmit(
|
|
443
|
+
instance,
|
|
444
|
+
instance.rawProps || EMPTY_OBJ,
|
|
445
|
+
propGetter,
|
|
446
|
+
event,
|
|
447
|
+
...rawArgs
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
function propGetter(rawProps, key) {
|
|
451
|
+
const dynamicSources = rawProps.$;
|
|
452
|
+
if (dynamicSources) {
|
|
453
|
+
let i = dynamicSources.length;
|
|
454
|
+
while (i--) {
|
|
455
|
+
const source = resolveSource(dynamicSources[i]);
|
|
456
|
+
if (hasOwn(source, key)) return resolveSource(source[key]);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
return rawProps[key] && resolveSource(rawProps[key]);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function resolveSource(source) {
|
|
463
|
+
return isFunction(source) ? source() : source;
|
|
464
|
+
}
|
|
465
|
+
function getPropsProxyHandlers(comp) {
|
|
466
|
+
if (comp.__propsHandlers) {
|
|
467
|
+
return comp.__propsHandlers;
|
|
468
|
+
}
|
|
469
|
+
const propsOptions = normalizePropsOptions(comp)[0];
|
|
470
|
+
const emitsOptions = normalizeEmitsOptions(comp);
|
|
471
|
+
const isProp = propsOptions ? (key) => isString(key) && hasOwn(propsOptions, camelize(key)) : NO;
|
|
472
|
+
const isAttr = propsOptions ? (key) => key !== "$" && !isProp(key) && !isEmitListener(emitsOptions, key) : YES;
|
|
473
|
+
const getProp = (instance, key) => {
|
|
474
|
+
if (!isProp(key)) return;
|
|
475
|
+
const rawProps = instance.rawProps;
|
|
476
|
+
const dynamicSources = rawProps.$;
|
|
477
|
+
if (dynamicSources) {
|
|
478
|
+
let i = dynamicSources.length;
|
|
479
|
+
let source, isDynamic, rawKey;
|
|
480
|
+
while (i--) {
|
|
481
|
+
source = dynamicSources[i];
|
|
482
|
+
isDynamic = isFunction(source);
|
|
483
|
+
source = isDynamic ? source() : source;
|
|
484
|
+
for (rawKey in source) {
|
|
485
|
+
if (camelize(rawKey) === key) {
|
|
486
|
+
return resolvePropValue(
|
|
487
|
+
propsOptions,
|
|
488
|
+
key,
|
|
489
|
+
isDynamic ? source[rawKey] : source[rawKey](),
|
|
490
|
+
instance,
|
|
491
|
+
resolveDefault
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
for (const rawKey in rawProps) {
|
|
498
|
+
if (camelize(rawKey) === key) {
|
|
499
|
+
return resolvePropValue(
|
|
500
|
+
propsOptions,
|
|
501
|
+
key,
|
|
502
|
+
rawProps[rawKey](),
|
|
503
|
+
instance,
|
|
504
|
+
resolveDefault
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return resolvePropValue(
|
|
509
|
+
propsOptions,
|
|
510
|
+
key,
|
|
511
|
+
undefined,
|
|
512
|
+
instance,
|
|
513
|
+
resolveDefault,
|
|
514
|
+
true
|
|
515
|
+
);
|
|
516
|
+
};
|
|
517
|
+
const propsHandlers = propsOptions ? {
|
|
518
|
+
get: (target, key) => getProp(target, key),
|
|
519
|
+
has: (_, key) => isProp(key),
|
|
520
|
+
ownKeys: () => Object.keys(propsOptions),
|
|
521
|
+
getOwnPropertyDescriptor(target, key) {
|
|
522
|
+
if (isProp(key)) {
|
|
523
|
+
return {
|
|
524
|
+
configurable: true,
|
|
525
|
+
enumerable: true,
|
|
526
|
+
get: () => getProp(target, key)
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
} : null;
|
|
531
|
+
if (!!(process.env.NODE_ENV !== "production") && propsOptions) {
|
|
532
|
+
Object.assign(propsHandlers, {
|
|
533
|
+
set: propsSetDevTrap,
|
|
534
|
+
deleteProperty: propsDeleteDevTrap
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
const getAttr = (target, key) => {
|
|
538
|
+
if (!isProp(key) && !isEmitListener(emitsOptions, key)) {
|
|
539
|
+
return getAttrFromRawProps(target, key);
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
const hasAttr = (target, key) => {
|
|
543
|
+
if (isAttr(key)) {
|
|
544
|
+
return hasAttrFromRawProps(target, key);
|
|
545
|
+
} else {
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
const attrsHandlers = {
|
|
550
|
+
get: (target, key) => getAttr(target.rawProps, key),
|
|
551
|
+
has: (target, key) => hasAttr(target.rawProps, key),
|
|
552
|
+
ownKeys: (target) => getKeysFromRawProps(target.rawProps).filter(isAttr),
|
|
553
|
+
getOwnPropertyDescriptor(target, key) {
|
|
554
|
+
if (hasAttr(target.rawProps, key)) {
|
|
555
|
+
return {
|
|
556
|
+
configurable: true,
|
|
557
|
+
enumerable: true,
|
|
558
|
+
get: () => getAttr(target.rawProps, key)
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
};
|
|
563
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
564
|
+
Object.assign(attrsHandlers, {
|
|
565
|
+
set: propsSetDevTrap,
|
|
566
|
+
deleteProperty: propsDeleteDevTrap
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
return comp.__propsHandlers = [propsHandlers, attrsHandlers];
|
|
570
|
+
}
|
|
571
|
+
function getAttrFromRawProps(rawProps, key) {
|
|
572
|
+
if (key === "$") return;
|
|
573
|
+
const merged = key === "class" || key === "style" ? [] : undefined;
|
|
574
|
+
const dynamicSources = rawProps.$;
|
|
575
|
+
if (dynamicSources) {
|
|
576
|
+
let i = dynamicSources.length;
|
|
577
|
+
let source, isDynamic;
|
|
578
|
+
while (i--) {
|
|
579
|
+
source = dynamicSources[i];
|
|
580
|
+
isDynamic = isFunction(source);
|
|
581
|
+
source = isDynamic ? source() : source;
|
|
582
|
+
if (hasOwn(source, key)) {
|
|
583
|
+
const value = isDynamic ? source[key] : source[key]();
|
|
584
|
+
if (merged) {
|
|
585
|
+
merged.push(value);
|
|
586
|
+
} else {
|
|
587
|
+
return value;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
if (hasOwn(rawProps, key)) {
|
|
593
|
+
if (merged) {
|
|
594
|
+
merged.push(rawProps[key]());
|
|
595
|
+
} else {
|
|
596
|
+
return rawProps[key]();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return merged;
|
|
600
|
+
}
|
|
601
|
+
function hasAttrFromRawProps(rawProps, key) {
|
|
602
|
+
if (key === "$") return false;
|
|
603
|
+
const dynamicSources = rawProps.$;
|
|
604
|
+
if (dynamicSources) {
|
|
605
|
+
let i = dynamicSources.length;
|
|
606
|
+
while (i--) {
|
|
607
|
+
if (hasOwn(resolveSource(dynamicSources[i]), key)) {
|
|
608
|
+
return true;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return hasOwn(rawProps, key);
|
|
613
|
+
}
|
|
614
|
+
function getKeysFromRawProps(rawProps) {
|
|
615
|
+
const keys = [];
|
|
616
|
+
for (const key in rawProps) {
|
|
617
|
+
if (key !== "$") keys.push(key);
|
|
618
|
+
}
|
|
619
|
+
const dynamicSources = rawProps.$;
|
|
620
|
+
if (dynamicSources) {
|
|
621
|
+
let i = dynamicSources.length;
|
|
622
|
+
let source;
|
|
623
|
+
while (i--) {
|
|
624
|
+
source = resolveSource(dynamicSources[i]);
|
|
625
|
+
for (const key in source) {
|
|
626
|
+
keys.push(key);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return Array.from(new Set(keys));
|
|
631
|
+
}
|
|
632
|
+
function normalizePropsOptions(comp) {
|
|
633
|
+
const cached = comp.__propsOptions;
|
|
634
|
+
if (cached) return cached;
|
|
635
|
+
const raw = comp.props;
|
|
636
|
+
if (!raw) return EMPTY_ARR;
|
|
637
|
+
const normalized = {};
|
|
638
|
+
const needCastKeys = [];
|
|
639
|
+
baseNormalizePropsOptions(raw, normalized, needCastKeys);
|
|
640
|
+
return comp.__propsOptions = [normalized, needCastKeys];
|
|
641
|
+
}
|
|
642
|
+
function resolveDefault(factory, instance) {
|
|
643
|
+
const prev = currentInstance$1;
|
|
644
|
+
simpleSetCurrentInstance$1(instance);
|
|
645
|
+
const res = factory.call(null, instance.props);
|
|
646
|
+
simpleSetCurrentInstance$1(prev, instance);
|
|
647
|
+
return res;
|
|
648
|
+
}
|
|
649
|
+
function hasFallthroughAttrs(comp, rawProps) {
|
|
650
|
+
if (rawProps) {
|
|
651
|
+
if (rawProps.$ || !comp.props) {
|
|
652
|
+
return true;
|
|
653
|
+
} else {
|
|
654
|
+
const propsOptions = normalizePropsOptions(comp)[0];
|
|
655
|
+
for (const key in rawProps) {
|
|
656
|
+
if (!hasOwn(propsOptions, camelize(key))) {
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
function setupPropsValidation(instance) {
|
|
665
|
+
const rawProps = instance.rawProps;
|
|
666
|
+
if (!rawProps) return;
|
|
667
|
+
renderEffect(
|
|
668
|
+
() => {
|
|
669
|
+
pushWarningContext(instance);
|
|
670
|
+
validateProps(
|
|
671
|
+
resolveDynamicProps(rawProps),
|
|
672
|
+
instance.props,
|
|
673
|
+
normalizePropsOptions(instance.type)[0]
|
|
674
|
+
);
|
|
675
|
+
popWarningContext();
|
|
676
|
+
},
|
|
677
|
+
true
|
|
678
|
+
/* noLifecycle */
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
function resolveDynamicProps(props) {
|
|
682
|
+
const mergedRawProps = {};
|
|
683
|
+
for (const key in props) {
|
|
684
|
+
if (key !== "$") {
|
|
685
|
+
mergedRawProps[key] = props[key]();
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (props.$) {
|
|
689
|
+
for (const source of props.$) {
|
|
690
|
+
const isDynamic = isFunction(source);
|
|
691
|
+
const resolved = isDynamic ? source() : source;
|
|
692
|
+
for (const key in resolved) {
|
|
693
|
+
const value = isDynamic ? resolved[key] : resolved[key]();
|
|
694
|
+
if (key === "class" || key === "style") {
|
|
695
|
+
const existing = mergedRawProps[key];
|
|
696
|
+
if (isArray(existing)) {
|
|
697
|
+
existing.push(value);
|
|
698
|
+
} else {
|
|
699
|
+
mergedRawProps[key] = [existing, value];
|
|
700
|
+
}
|
|
701
|
+
} else {
|
|
702
|
+
mergedRawProps[key] = value;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return mergedRawProps;
|
|
708
|
+
}
|
|
709
|
+
function propsSetDevTrap(_, key) {
|
|
710
|
+
warn(
|
|
711
|
+
`Attempt to mutate prop ${JSON.stringify(key)} failed. Props are readonly.`
|
|
712
|
+
);
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
function propsDeleteDevTrap(_, key) {
|
|
716
|
+
warn(
|
|
717
|
+
`Attempt to delete prop ${JSON.stringify(key)} failed. Props are readonly.`
|
|
718
|
+
);
|
|
719
|
+
return true;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
let currentInstance = null;
|
|
723
|
+
{
|
|
724
|
+
const g = getGlobalThis();
|
|
725
|
+
const registerGlobalSetter = (key, setter) => {
|
|
726
|
+
let setters;
|
|
727
|
+
if (!(setters = g[key])) setters = g[key] = [];
|
|
728
|
+
setters.push(setter);
|
|
729
|
+
return (v) => {
|
|
730
|
+
if (setters.length > 1) setters.forEach((set) => set(v));
|
|
731
|
+
else setters[0](v);
|
|
732
|
+
};
|
|
733
|
+
};
|
|
734
|
+
registerGlobalSetter(
|
|
735
|
+
`__VUE_INSTANCE_SETTERS__`,
|
|
736
|
+
(v) => currentInstance = v
|
|
737
|
+
);
|
|
738
|
+
registerGlobalSetter(
|
|
739
|
+
`__VUE_SSR_SETTERS__`,
|
|
740
|
+
(v) => v
|
|
741
|
+
);
|
|
742
|
+
}
|
|
743
|
+
const simpleSetCurrentInstance = (i, unset) => {
|
|
744
|
+
currentInstance = i;
|
|
745
|
+
if (unset) {
|
|
746
|
+
unset.scope.off();
|
|
747
|
+
} else if (i) {
|
|
748
|
+
i.scope.on();
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
const dynamicSlotsProxyHandlers = {
|
|
753
|
+
get: getSlot,
|
|
754
|
+
has: (target, key) => !!getSlot(target, key),
|
|
755
|
+
getOwnPropertyDescriptor(target, key) {
|
|
756
|
+
const slot = getSlot(target, key);
|
|
757
|
+
if (slot) {
|
|
758
|
+
return {
|
|
759
|
+
configurable: true,
|
|
760
|
+
enumerable: true,
|
|
761
|
+
value: slot
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
ownKeys(target) {
|
|
766
|
+
let keys = Object.keys(target);
|
|
767
|
+
const dynamicSources = target.$;
|
|
768
|
+
if (dynamicSources) {
|
|
769
|
+
keys = keys.filter((k) => k !== "$");
|
|
770
|
+
for (const source of dynamicSources) {
|
|
771
|
+
if (isFunction(source)) {
|
|
772
|
+
const slot = source();
|
|
773
|
+
if (isArray(slot)) {
|
|
774
|
+
for (const s of slot) keys.push(String(s.name));
|
|
775
|
+
} else {
|
|
776
|
+
keys.push(String(slot.name));
|
|
777
|
+
}
|
|
778
|
+
} else {
|
|
779
|
+
keys.push(...Object.keys(source));
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
return keys;
|
|
784
|
+
},
|
|
785
|
+
set: NO,
|
|
786
|
+
deleteProperty: NO
|
|
787
|
+
};
|
|
788
|
+
function getSlot(target, key) {
|
|
789
|
+
if (key === "$") return;
|
|
790
|
+
const dynamicSources = target.$;
|
|
791
|
+
if (dynamicSources) {
|
|
792
|
+
let i = dynamicSources.length;
|
|
793
|
+
let source;
|
|
794
|
+
while (i--) {
|
|
795
|
+
source = dynamicSources[i];
|
|
796
|
+
if (isFunction(source)) {
|
|
797
|
+
const slot = source();
|
|
798
|
+
if (slot) {
|
|
799
|
+
if (isArray(slot)) {
|
|
800
|
+
for (const s of slot) {
|
|
801
|
+
if (String(s.name) === key) return s.fn;
|
|
802
|
+
}
|
|
803
|
+
} else if (String(slot.name) === key) {
|
|
804
|
+
return slot.fn;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
} else if (hasOwn(source, key)) {
|
|
808
|
+
return source[key];
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
if (hasOwn(target, key)) {
|
|
813
|
+
return target[key];
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
const dynamicSlotsPropsProxyHandlers = {
|
|
817
|
+
get: getAttrFromRawProps,
|
|
818
|
+
has: hasAttrFromRawProps,
|
|
819
|
+
ownKeys: getKeysFromRawProps,
|
|
820
|
+
getOwnPropertyDescriptor(target, key) {
|
|
821
|
+
if (hasAttrFromRawProps(target, key)) {
|
|
822
|
+
return {
|
|
823
|
+
configurable: true,
|
|
824
|
+
enumerable: true,
|
|
825
|
+
get: () => getAttrFromRawProps(target, key)
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
function createSlot(name, rawProps, fallback) {
|
|
831
|
+
const instance = currentInstance;
|
|
832
|
+
const rawSlots = instance.rawSlots;
|
|
833
|
+
const isDynamicName = isFunction(name);
|
|
834
|
+
const fragment = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("slot") : new DynamicFragment();
|
|
835
|
+
const slotProps = rawProps ? new Proxy(rawProps, dynamicSlotsPropsProxyHandlers) : EMPTY_OBJ;
|
|
836
|
+
const renderSlot = () => {
|
|
837
|
+
const slot = getSlot(rawSlots, isFunction(name) ? name() : name);
|
|
838
|
+
if (slot) {
|
|
839
|
+
fragment.update(
|
|
840
|
+
slot._bound || (slot._bound = () => {
|
|
841
|
+
const slotContent = slot(slotProps);
|
|
842
|
+
if (slotContent instanceof DynamicFragment) {
|
|
843
|
+
slotContent.fallback = fallback;
|
|
844
|
+
}
|
|
845
|
+
return slotContent;
|
|
846
|
+
})
|
|
847
|
+
);
|
|
848
|
+
} else {
|
|
849
|
+
fragment.update(fallback);
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
if (isDynamicName || rawSlots.$) {
|
|
853
|
+
renderEffect(renderSlot);
|
|
854
|
+
} else {
|
|
855
|
+
renderSlot();
|
|
856
|
+
}
|
|
857
|
+
return fragment;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function hmrRerender(instance) {
|
|
861
|
+
const normalized = normalizeBlock(instance.block);
|
|
862
|
+
const parent = normalized[0].parentNode;
|
|
863
|
+
const anchor = normalized[normalized.length - 1].nextSibling;
|
|
864
|
+
remove(instance.block, parent);
|
|
865
|
+
const prev = currentInstance;
|
|
866
|
+
simpleSetCurrentInstance(instance);
|
|
867
|
+
devRender(instance);
|
|
868
|
+
simpleSetCurrentInstance(prev, instance);
|
|
869
|
+
insert(instance.block, parent, anchor);
|
|
870
|
+
}
|
|
871
|
+
function hmrReload(instance, newComp) {
|
|
872
|
+
const normalized = normalizeBlock(instance.block);
|
|
873
|
+
const parent = normalized[0].parentNode;
|
|
874
|
+
const anchor = normalized[normalized.length - 1].nextSibling;
|
|
875
|
+
unmountComponent(instance, parent);
|
|
876
|
+
const prev = currentInstance;
|
|
877
|
+
simpleSetCurrentInstance(instance.parent);
|
|
878
|
+
const newInstance = createComponent(
|
|
879
|
+
newComp,
|
|
880
|
+
instance.rawProps,
|
|
881
|
+
instance.rawSlots,
|
|
882
|
+
instance.isSingleRoot
|
|
883
|
+
);
|
|
884
|
+
simpleSetCurrentInstance(prev, instance.parent);
|
|
885
|
+
mountComponent(newInstance, parent, anchor);
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext) {
|
|
889
|
+
if (isSingleRoot && component.inheritAttrs !== false && isVaporComponent(currentInstance$1) && currentInstance$1.hasFallthrough) {
|
|
890
|
+
const attrs = currentInstance$1.attrs;
|
|
891
|
+
if (rawProps) {
|
|
892
|
+
(rawProps.$ || (rawProps.$ = [])).push(
|
|
893
|
+
() => attrs
|
|
894
|
+
);
|
|
895
|
+
} else {
|
|
896
|
+
rawProps = { $: [() => attrs] };
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
const instance = new VaporComponentInstance(
|
|
900
|
+
component,
|
|
901
|
+
rawProps,
|
|
902
|
+
rawSlots,
|
|
903
|
+
appContext
|
|
904
|
+
);
|
|
905
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
906
|
+
pushWarningContext(instance);
|
|
907
|
+
startMeasure(instance, `init`);
|
|
908
|
+
}
|
|
909
|
+
const prev = currentInstance$1;
|
|
910
|
+
simpleSetCurrentInstance$1(instance);
|
|
911
|
+
pauseTracking();
|
|
912
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
913
|
+
setupPropsValidation(instance);
|
|
914
|
+
}
|
|
915
|
+
const setupFn = isFunction(component) ? component : component.setup;
|
|
916
|
+
const setupResult = setupFn ? callWithErrorHandling(setupFn, instance, 0, [
|
|
917
|
+
instance.props,
|
|
918
|
+
instance
|
|
919
|
+
]) || EMPTY_OBJ : EMPTY_OBJ;
|
|
920
|
+
if (!!(process.env.NODE_ENV !== "production") && !isBlock(setupResult)) {
|
|
921
|
+
if (isFunction(component)) {
|
|
922
|
+
warn(`Functional vapor component must return a block directly.`);
|
|
923
|
+
instance.block = [];
|
|
924
|
+
} else if (!component.render) {
|
|
925
|
+
warn(
|
|
926
|
+
`Vapor component setup() returned non-block value, and has no render function.`
|
|
927
|
+
);
|
|
928
|
+
instance.block = [];
|
|
929
|
+
} else {
|
|
930
|
+
instance.devtoolsRawSetupState = setupResult;
|
|
931
|
+
instance.setupState = proxyRefs(setupResult);
|
|
932
|
+
devRender(instance);
|
|
933
|
+
if (component.__hmrId) {
|
|
934
|
+
registerHMR(instance);
|
|
935
|
+
instance.isSingleRoot = isSingleRoot;
|
|
936
|
+
instance.hmrRerender = hmrRerender.bind(null, instance);
|
|
937
|
+
instance.hmrReload = hmrReload.bind(null, instance);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
} else {
|
|
941
|
+
if (!setupFn && component.render) {
|
|
942
|
+
instance.block = callWithErrorHandling(
|
|
943
|
+
component.render,
|
|
944
|
+
instance,
|
|
945
|
+
1
|
|
946
|
+
);
|
|
947
|
+
} else {
|
|
948
|
+
instance.block = setupResult;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
if (instance.hasFallthrough && component.inheritAttrs !== false && instance.block instanceof Element && Object.keys(instance.attrs).length) {
|
|
952
|
+
renderEffect(() => {
|
|
953
|
+
isApplyingFallthroughProps = true;
|
|
954
|
+
setDynamicProps(instance.block, [instance.attrs]);
|
|
955
|
+
isApplyingFallthroughProps = false;
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
resetTracking();
|
|
959
|
+
simpleSetCurrentInstance$1(prev, instance);
|
|
960
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
961
|
+
popWarningContext();
|
|
962
|
+
endMeasure(instance, "init");
|
|
963
|
+
}
|
|
964
|
+
return instance;
|
|
965
|
+
}
|
|
966
|
+
let isApplyingFallthroughProps = false;
|
|
967
|
+
function devRender(instance) {
|
|
968
|
+
instance.block = callWithErrorHandling(
|
|
969
|
+
instance.type.render,
|
|
970
|
+
instance,
|
|
971
|
+
1,
|
|
972
|
+
[
|
|
973
|
+
instance.setupState,
|
|
974
|
+
instance.props,
|
|
975
|
+
instance.emit,
|
|
976
|
+
instance.attrs,
|
|
977
|
+
instance.slots
|
|
978
|
+
]
|
|
979
|
+
) || [];
|
|
980
|
+
}
|
|
981
|
+
const emptyContext = {
|
|
982
|
+
app: null,
|
|
983
|
+
config: {},
|
|
984
|
+
provides: /* @__PURE__ */ Object.create(null)
|
|
985
|
+
};
|
|
986
|
+
class VaporComponentInstance {
|
|
987
|
+
constructor(comp, rawProps, rawSlots, appContext) {
|
|
988
|
+
this.vapor = true;
|
|
989
|
+
this.uid = nextUid();
|
|
990
|
+
this.type = comp;
|
|
991
|
+
this.parent = currentInstance$1;
|
|
992
|
+
this.children = [];
|
|
993
|
+
if (currentInstance$1) {
|
|
994
|
+
if (isVaporComponent(currentInstance$1)) {
|
|
995
|
+
currentInstance$1.children.push(this);
|
|
996
|
+
}
|
|
997
|
+
this.appContext = currentInstance$1.appContext;
|
|
998
|
+
this.provides = currentInstance$1.provides;
|
|
999
|
+
this.ids = currentInstance$1.ids;
|
|
1000
|
+
} else {
|
|
1001
|
+
this.appContext = appContext || emptyContext;
|
|
1002
|
+
this.provides = Object.create(this.appContext.provides);
|
|
1003
|
+
this.ids = ["", 0, 0];
|
|
1004
|
+
}
|
|
1005
|
+
this.block = null;
|
|
1006
|
+
this.scope = new EffectScope$1(true);
|
|
1007
|
+
this.emit = emit.bind(null, this);
|
|
1008
|
+
this.expose = expose.bind(null, this);
|
|
1009
|
+
this.refs = EMPTY_OBJ;
|
|
1010
|
+
this.emitted = this.exposed = this.exposeProxy = this.propsDefaults = this.suspense = null;
|
|
1011
|
+
this.isMounted = this.isUnmounted = this.isUpdating = this.isDeactivated = false;
|
|
1012
|
+
this.rawProps = rawProps || EMPTY_OBJ;
|
|
1013
|
+
this.hasFallthrough = hasFallthroughAttrs(comp, rawProps);
|
|
1014
|
+
if (rawProps || comp.props) {
|
|
1015
|
+
const [propsHandlers, attrsHandlers] = getPropsProxyHandlers(comp);
|
|
1016
|
+
this.attrs = new Proxy(this, attrsHandlers);
|
|
1017
|
+
this.props = comp.props ? new Proxy(this, propsHandlers) : isFunction(comp) ? this.attrs : EMPTY_OBJ;
|
|
1018
|
+
} else {
|
|
1019
|
+
this.props = this.attrs = EMPTY_OBJ;
|
|
1020
|
+
}
|
|
1021
|
+
this.rawSlots = rawSlots || EMPTY_OBJ;
|
|
1022
|
+
this.slots = rawSlots ? rawSlots.$ ? new Proxy(rawSlots, dynamicSlotsProxyHandlers) : rawSlots : EMPTY_OBJ;
|
|
1023
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1024
|
+
this.propsOptions = normalizePropsOptions(comp);
|
|
1025
|
+
this.emitsOptions = normalizeEmitsOptions(comp);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
/**
|
|
1029
|
+
* Expose `getKeysFromRawProps` on the instance so it can be used in code
|
|
1030
|
+
* paths where it's needed, e.g. `useModel`
|
|
1031
|
+
*/
|
|
1032
|
+
rawKeys() {
|
|
1033
|
+
return getKeysFromRawProps(this.rawProps);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
function isVaporComponent(value) {
|
|
1037
|
+
return value instanceof VaporComponentInstance;
|
|
1038
|
+
}
|
|
1039
|
+
function createComponentWithFallback(comp, rawProps, rawSlots, isSingleRoot) {
|
|
1040
|
+
if (!isString(comp)) {
|
|
1041
|
+
return createComponent(comp, rawProps, rawSlots, isSingleRoot);
|
|
1042
|
+
}
|
|
1043
|
+
const el = document.createElement(comp);
|
|
1044
|
+
el.$root = isSingleRoot;
|
|
1045
|
+
if (rawProps) {
|
|
1046
|
+
renderEffect(() => {
|
|
1047
|
+
setDynamicProps(el, [resolveDynamicProps(rawProps)]);
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
if (rawSlots) {
|
|
1051
|
+
if (rawSlots.$) ; else {
|
|
1052
|
+
insert(getSlot(rawSlots, "default")(), el);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return el;
|
|
1056
|
+
}
|
|
1057
|
+
function mountComponent(instance, parent, anchor) {
|
|
1058
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1059
|
+
startMeasure(instance, `mount`);
|
|
1060
|
+
}
|
|
1061
|
+
if (!instance.isMounted) {
|
|
1062
|
+
if (instance.bm) invokeArrayFns(instance.bm);
|
|
1063
|
+
insert(instance.block, parent, anchor);
|
|
1064
|
+
if (instance.m) queuePostFlushCb(() => invokeArrayFns(instance.m));
|
|
1065
|
+
instance.isMounted = true;
|
|
1066
|
+
} else {
|
|
1067
|
+
insert(instance.block, parent, anchor);
|
|
1068
|
+
}
|
|
1069
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1070
|
+
endMeasure(instance, `mount`);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
function unmountComponent(instance, parentNode) {
|
|
1074
|
+
if (instance.isMounted && !instance.isUnmounted) {
|
|
1075
|
+
if (!!(process.env.NODE_ENV !== "production") && instance.type.__hmrId) {
|
|
1076
|
+
unregisterHMR(instance);
|
|
1077
|
+
}
|
|
1078
|
+
if (instance.bum) {
|
|
1079
|
+
invokeArrayFns(instance.bum);
|
|
1080
|
+
}
|
|
1081
|
+
instance.scope.stop();
|
|
1082
|
+
for (const c of instance.children) {
|
|
1083
|
+
unmountComponent(c);
|
|
1084
|
+
}
|
|
1085
|
+
instance.children = EMPTY_ARR;
|
|
1086
|
+
if (parentNode) {
|
|
1087
|
+
remove(instance.block, parentNode);
|
|
1088
|
+
const parentInstance = instance.parent;
|
|
1089
|
+
instance.parent = null;
|
|
1090
|
+
if (isVaporComponent(parentInstance)) {
|
|
1091
|
+
if (parentsWithUnmountedChildren) {
|
|
1092
|
+
parentsWithUnmountedChildren.add(parentInstance);
|
|
1093
|
+
} else {
|
|
1094
|
+
remove$1(parentInstance.children, instance);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
if (instance.um) {
|
|
1099
|
+
queuePostFlushCb(() => invokeArrayFns(instance.um));
|
|
1100
|
+
}
|
|
1101
|
+
instance.isUnmounted = true;
|
|
1102
|
+
} else if (parentNode) {
|
|
1103
|
+
remove(instance.block, parentNode);
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
function getExposed(instance) {
|
|
1107
|
+
if (instance.exposed) {
|
|
1108
|
+
return instance.exposeProxy || (instance.exposeProxy = new Proxy(markRaw(instance.exposed), {
|
|
1109
|
+
get: (target, key) => unref(target[key])
|
|
1110
|
+
}));
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
let _createApp;
|
|
1115
|
+
const mountApp = (app, container) => {
|
|
1116
|
+
if (container.nodeType === 1) {
|
|
1117
|
+
container.textContent = "";
|
|
1118
|
+
}
|
|
1119
|
+
const instance = createComponent(
|
|
1120
|
+
app._component,
|
|
1121
|
+
app._props,
|
|
1122
|
+
null,
|
|
1123
|
+
false,
|
|
1124
|
+
app._context
|
|
1125
|
+
);
|
|
1126
|
+
mountComponent(instance, container);
|
|
1127
|
+
flushOnAppMount();
|
|
1128
|
+
return instance;
|
|
1129
|
+
};
|
|
1130
|
+
const unmountApp = (app) => {
|
|
1131
|
+
unmountComponent(app._instance, app._container);
|
|
1132
|
+
};
|
|
1133
|
+
const createVaporApp = (comp, props) => {
|
|
1134
|
+
{
|
|
1135
|
+
initFeatureFlags();
|
|
1136
|
+
}
|
|
1137
|
+
const target = getGlobalThis();
|
|
1138
|
+
target.__VUE__ = true;
|
|
1139
|
+
if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
|
|
1140
|
+
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
|
1141
|
+
}
|
|
1142
|
+
if (!_createApp) _createApp = createAppAPI(mountApp, unmountApp, getExposed);
|
|
1143
|
+
const app = _createApp(comp, props);
|
|
1144
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1145
|
+
app.config.globalProperties = new Proxy(
|
|
1146
|
+
{},
|
|
1147
|
+
{
|
|
1148
|
+
set() {
|
|
1149
|
+
warn(`app.config.globalProperties is not supported in vapor mode.`);
|
|
1150
|
+
return false;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
const mount = app.mount;
|
|
1156
|
+
app.mount = (container, ...args) => {
|
|
1157
|
+
container = normalizeContainer(container);
|
|
1158
|
+
return mount(container, ...args);
|
|
1159
|
+
};
|
|
1160
|
+
return app;
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1163
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
1164
|
+
// @__NO_SIDE_EFFECTS__
|
|
1165
|
+
function defineVaporComponent(comp) {
|
|
1166
|
+
comp.__vapor = true;
|
|
1167
|
+
return comp;
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
1171
|
+
// @__NO_SIDE_EFFECTS__
|
|
1172
|
+
function template(html, root) {
|
|
1173
|
+
let node;
|
|
1174
|
+
const create = () => {
|
|
1175
|
+
const t = document.createElement("template");
|
|
1176
|
+
t.innerHTML = html;
|
|
1177
|
+
return t.content.firstChild;
|
|
1178
|
+
};
|
|
1179
|
+
return () => {
|
|
1180
|
+
const ret = (node || (node = create())).cloneNode(true);
|
|
1181
|
+
if (root) ret.$root = true;
|
|
1182
|
+
return ret;
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
1186
|
+
// @__NO_SIDE_EFFECTS__
|
|
1187
|
+
function children(node, ...paths) {
|
|
1188
|
+
for (const idx of paths) {
|
|
1189
|
+
node = idx === 0 ? node.firstChild : idx === 1 ? node.firstChild.nextSibling : node.childNodes[idx];
|
|
1190
|
+
}
|
|
1191
|
+
return node;
|
|
1192
|
+
}
|
|
1193
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
1194
|
+
// @__NO_SIDE_EFFECTS__
|
|
1195
|
+
function next(node, offset) {
|
|
1196
|
+
for (let i = 0; i < offset; i++) {
|
|
1197
|
+
node = node.nextSibling;
|
|
1198
|
+
}
|
|
1199
|
+
return node;
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
function createIf(condition, b1, b2, once) {
|
|
1203
|
+
const frag = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("if") : new DynamicFragment();
|
|
1204
|
+
if (once) {
|
|
1205
|
+
frag.update(condition() ? b1 : b2);
|
|
1206
|
+
} else {
|
|
1207
|
+
renderEffect(() => frag.update(condition() ? b1 : b2));
|
|
1208
|
+
}
|
|
1209
|
+
return frag;
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
class ForBlock extends Fragment {
|
|
1213
|
+
constructor(nodes, scope, item, key, index, renderKey) {
|
|
1214
|
+
super(nodes);
|
|
1215
|
+
this.scope = scope;
|
|
1216
|
+
this.itemRef = item;
|
|
1217
|
+
this.keyRef = key;
|
|
1218
|
+
this.indexRef = index;
|
|
1219
|
+
this.key = renderKey;
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
1223
|
+
const createFor = /* @__NO_SIDE_EFFECTS__ */ (src, renderItem, getKey, isComponent = false, once) => {
|
|
1224
|
+
let isMounted = false;
|
|
1225
|
+
let oldBlocks = [];
|
|
1226
|
+
let newBlocks;
|
|
1227
|
+
let parent;
|
|
1228
|
+
const parentAnchor = !!(process.env.NODE_ENV !== "production") ? createComment("for") : createTextNode();
|
|
1229
|
+
const ref = new Fragment(oldBlocks);
|
|
1230
|
+
const instance = currentInstance$1;
|
|
1231
|
+
if (!!(process.env.NODE_ENV !== "production") && !instance) {
|
|
1232
|
+
warn("createFor() can only be used inside setup()");
|
|
1233
|
+
}
|
|
1234
|
+
const renderList = () => {
|
|
1235
|
+
const source = normalizeSource(src());
|
|
1236
|
+
const newLength = source.values.length;
|
|
1237
|
+
const oldLength = oldBlocks.length;
|
|
1238
|
+
newBlocks = new Array(newLength);
|
|
1239
|
+
if (!isMounted) {
|
|
1240
|
+
isMounted = true;
|
|
1241
|
+
for (let i = 0; i < newLength; i++) {
|
|
1242
|
+
mount(source, i);
|
|
1243
|
+
}
|
|
1244
|
+
} else {
|
|
1245
|
+
parent = parent || parentAnchor.parentNode;
|
|
1246
|
+
if (!oldLength) {
|
|
1247
|
+
for (let i = 0; i < newLength; i++) {
|
|
1248
|
+
mount(source, i);
|
|
1249
|
+
}
|
|
1250
|
+
} else if (!newLength) {
|
|
1251
|
+
for (let i = 0; i < oldLength; i++) {
|
|
1252
|
+
unmount(oldBlocks[i]);
|
|
1253
|
+
}
|
|
1254
|
+
} else if (!getKey) {
|
|
1255
|
+
const commonLength = Math.min(newLength, oldLength);
|
|
1256
|
+
for (let i = 0; i < commonLength; i++) {
|
|
1257
|
+
update(newBlocks[i] = oldBlocks[i], getItem(source, i)[0]);
|
|
1258
|
+
}
|
|
1259
|
+
for (let i = oldLength; i < newLength; i++) {
|
|
1260
|
+
mount(source, i);
|
|
1261
|
+
}
|
|
1262
|
+
for (let i = newLength; i < oldLength; i++) {
|
|
1263
|
+
unmount(oldBlocks[i]);
|
|
1264
|
+
}
|
|
1265
|
+
} else {
|
|
1266
|
+
let i = 0;
|
|
1267
|
+
let e1 = oldLength - 1;
|
|
1268
|
+
let e2 = newLength - 1;
|
|
1269
|
+
while (i <= e1 && i <= e2) {
|
|
1270
|
+
if (tryPatchIndex(source, i)) {
|
|
1271
|
+
i++;
|
|
1272
|
+
} else {
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
while (i <= e1 && i <= e2) {
|
|
1277
|
+
if (tryPatchIndex(source, i)) {
|
|
1278
|
+
e1--;
|
|
1279
|
+
e2--;
|
|
1280
|
+
} else {
|
|
1281
|
+
break;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (i > e1) {
|
|
1285
|
+
if (i <= e2) {
|
|
1286
|
+
const nextPos = e2 + 1;
|
|
1287
|
+
const anchor = nextPos < newLength ? normalizeAnchor(newBlocks[nextPos].nodes) : parentAnchor;
|
|
1288
|
+
while (i <= e2) {
|
|
1289
|
+
mount(source, i, anchor);
|
|
1290
|
+
i++;
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
} else if (i > e2) {
|
|
1294
|
+
while (i <= e1) {
|
|
1295
|
+
unmount(oldBlocks[i]);
|
|
1296
|
+
i++;
|
|
1297
|
+
}
|
|
1298
|
+
} else {
|
|
1299
|
+
const s1 = i;
|
|
1300
|
+
const s2 = i;
|
|
1301
|
+
const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
|
1302
|
+
for (i = s2; i <= e2; i++) {
|
|
1303
|
+
keyToNewIndexMap.set(getKey(...getItem(source, i)), i);
|
|
1304
|
+
}
|
|
1305
|
+
let j;
|
|
1306
|
+
let patched = 0;
|
|
1307
|
+
const toBePatched = e2 - s2 + 1;
|
|
1308
|
+
let moved = false;
|
|
1309
|
+
let maxNewIndexSoFar = 0;
|
|
1310
|
+
const newIndexToOldIndexMap = new Array(toBePatched).fill(0);
|
|
1311
|
+
for (i = s1; i <= e1; i++) {
|
|
1312
|
+
const prevBlock = oldBlocks[i];
|
|
1313
|
+
if (patched >= toBePatched) {
|
|
1314
|
+
unmount(prevBlock);
|
|
1315
|
+
} else {
|
|
1316
|
+
const newIndex = keyToNewIndexMap.get(prevBlock.key);
|
|
1317
|
+
if (newIndex == null) {
|
|
1318
|
+
unmount(prevBlock);
|
|
1319
|
+
} else {
|
|
1320
|
+
newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
|
1321
|
+
if (newIndex >= maxNewIndexSoFar) {
|
|
1322
|
+
maxNewIndexSoFar = newIndex;
|
|
1323
|
+
} else {
|
|
1324
|
+
moved = true;
|
|
1325
|
+
}
|
|
1326
|
+
update(
|
|
1327
|
+
newBlocks[newIndex] = prevBlock,
|
|
1328
|
+
...getItem(source, newIndex)
|
|
1329
|
+
);
|
|
1330
|
+
patched++;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : [];
|
|
1335
|
+
j = increasingNewIndexSequence.length - 1;
|
|
1336
|
+
for (i = toBePatched - 1; i >= 0; i--) {
|
|
1337
|
+
const nextIndex = s2 + i;
|
|
1338
|
+
const anchor = nextIndex + 1 < newLength ? normalizeAnchor(newBlocks[nextIndex + 1].nodes) : parentAnchor;
|
|
1339
|
+
if (newIndexToOldIndexMap[i] === 0) {
|
|
1340
|
+
mount(source, nextIndex, anchor);
|
|
1341
|
+
} else if (moved) {
|
|
1342
|
+
if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
|
1343
|
+
insert(newBlocks[nextIndex].nodes, parent, anchor);
|
|
1344
|
+
} else {
|
|
1345
|
+
j--;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
}
|
|
1352
|
+
ref.nodes = [oldBlocks = newBlocks];
|
|
1353
|
+
if (parentAnchor) {
|
|
1354
|
+
ref.nodes.push(parentAnchor);
|
|
1355
|
+
}
|
|
1356
|
+
};
|
|
1357
|
+
const needKey = renderItem.length > 1;
|
|
1358
|
+
const needIndex = renderItem.length > 2;
|
|
1359
|
+
const mount = (source, idx, anchor = parentAnchor) => {
|
|
1360
|
+
const [item, key, index] = getItem(source, idx);
|
|
1361
|
+
const itemRef = shallowRef(item);
|
|
1362
|
+
const keyRef = needKey ? shallowRef(key) : undefined;
|
|
1363
|
+
const indexRef = needIndex ? shallowRef(index) : undefined;
|
|
1364
|
+
let nodes;
|
|
1365
|
+
let scope;
|
|
1366
|
+
if (isComponent) {
|
|
1367
|
+
nodes = renderItem(itemRef, keyRef, indexRef);
|
|
1368
|
+
} else {
|
|
1369
|
+
scope = new EffectScope();
|
|
1370
|
+
nodes = scope.run(
|
|
1371
|
+
() => renderItem(itemRef, keyRef, indexRef)
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
const block = newBlocks[idx] = new ForBlock(
|
|
1375
|
+
nodes,
|
|
1376
|
+
scope,
|
|
1377
|
+
itemRef,
|
|
1378
|
+
keyRef,
|
|
1379
|
+
indexRef,
|
|
1380
|
+
getKey && getKey(item, key, index)
|
|
1381
|
+
);
|
|
1382
|
+
if (parent) insert(block.nodes, parent, anchor);
|
|
1383
|
+
return block;
|
|
1384
|
+
};
|
|
1385
|
+
const tryPatchIndex = (source, idx) => {
|
|
1386
|
+
const block = oldBlocks[idx];
|
|
1387
|
+
const [item, key, index] = getItem(source, idx);
|
|
1388
|
+
if (block.key === getKey(item, key, index)) {
|
|
1389
|
+
update(newBlocks[idx] = block, item);
|
|
1390
|
+
return true;
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
const update = ({ itemRef, keyRef, indexRef }, newItem, newKey, newIndex) => {
|
|
1394
|
+
if (newIndex !== itemRef.value) {
|
|
1395
|
+
itemRef.value = newItem;
|
|
1396
|
+
}
|
|
1397
|
+
if (keyRef && newKey !== undefined && newKey !== keyRef.value) {
|
|
1398
|
+
keyRef.value = newKey;
|
|
1399
|
+
}
|
|
1400
|
+
if (indexRef && newIndex !== undefined && newIndex !== indexRef.value) {
|
|
1401
|
+
indexRef.value = newIndex;
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
const unmount = ({ nodes, scope }) => {
|
|
1405
|
+
remove(nodes, parent);
|
|
1406
|
+
scope && scope.stop();
|
|
1407
|
+
};
|
|
1408
|
+
once ? renderList() : renderEffect(renderList);
|
|
1409
|
+
return ref;
|
|
1410
|
+
};
|
|
1411
|
+
function createForSlots(rawSource, getSlot) {
|
|
1412
|
+
const source = normalizeSource(rawSource);
|
|
1413
|
+
const sourceLength = source.values.length;
|
|
1414
|
+
const slots = new Array(sourceLength);
|
|
1415
|
+
for (let i = 0; i < sourceLength; i++) {
|
|
1416
|
+
slots[i] = getSlot(...getItem(source, i));
|
|
1417
|
+
}
|
|
1418
|
+
return slots;
|
|
1419
|
+
}
|
|
1420
|
+
function normalizeSource(source) {
|
|
1421
|
+
let values = source;
|
|
1422
|
+
let needsWrap = false;
|
|
1423
|
+
let keys;
|
|
1424
|
+
if (isArray(source)) {
|
|
1425
|
+
if (isReactive(source)) {
|
|
1426
|
+
needsWrap = !isShallow(source);
|
|
1427
|
+
values = shallowReadArray(source);
|
|
1428
|
+
}
|
|
1429
|
+
} else if (isString(source)) {
|
|
1430
|
+
values = source.split("");
|
|
1431
|
+
} else if (typeof source === "number") {
|
|
1432
|
+
if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
|
|
1433
|
+
warn(`The v-for range expect an integer value but got ${source}.`);
|
|
1434
|
+
}
|
|
1435
|
+
values = new Array(source);
|
|
1436
|
+
for (let i = 0; i < source; i++) values[i] = i + 1;
|
|
1437
|
+
} else if (isObject(source)) {
|
|
1438
|
+
if (source[Symbol.iterator]) {
|
|
1439
|
+
values = Array.from(source);
|
|
1440
|
+
} else {
|
|
1441
|
+
keys = Object.keys(source);
|
|
1442
|
+
values = new Array(keys.length);
|
|
1443
|
+
for (let i = 0, l = keys.length; i < l; i++) {
|
|
1444
|
+
values[i] = source[keys[i]];
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
return { values, needsWrap, keys };
|
|
1449
|
+
}
|
|
1450
|
+
function getItem({ keys, values, needsWrap }, idx) {
|
|
1451
|
+
const value = needsWrap ? toReactive(values[idx]) : values[idx];
|
|
1452
|
+
if (keys) {
|
|
1453
|
+
return [value, keys[idx], idx];
|
|
1454
|
+
} else {
|
|
1455
|
+
return [value, idx, undefined];
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
function normalizeAnchor(node) {
|
|
1459
|
+
if (node instanceof Node) {
|
|
1460
|
+
return node;
|
|
1461
|
+
} else if (isArray(node)) {
|
|
1462
|
+
return normalizeAnchor(node[0]);
|
|
1463
|
+
} else if (isVaporComponent(node)) {
|
|
1464
|
+
return normalizeAnchor(node.block);
|
|
1465
|
+
} else {
|
|
1466
|
+
return normalizeAnchor(node.nodes);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function getRestElement(val, keys) {
|
|
1470
|
+
const res = {};
|
|
1471
|
+
for (const key in val) {
|
|
1472
|
+
if (!keys.includes(key)) res[key] = val[key];
|
|
1473
|
+
}
|
|
1474
|
+
return res;
|
|
1475
|
+
}
|
|
1476
|
+
function getDefaultValue(val, defaultVal) {
|
|
1477
|
+
return val === undefined ? defaultVal : val;
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
function createTemplateRefSetter() {
|
|
1481
|
+
const instance = currentInstance$1;
|
|
1482
|
+
return (...args) => setRef(instance, ...args);
|
|
1483
|
+
}
|
|
1484
|
+
function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
1485
|
+
if (!instance || instance.isUnmounted) return;
|
|
1486
|
+
const setupState = !!(process.env.NODE_ENV !== "production") ? instance.setupState || {} : null;
|
|
1487
|
+
const refValue = isVaporComponent(el) ? getExposed(el) || el : el;
|
|
1488
|
+
const refs = instance.refs === EMPTY_OBJ ? instance.refs = {} : instance.refs;
|
|
1489
|
+
if (oldRef != null && oldRef !== ref) {
|
|
1490
|
+
if (isString(oldRef)) {
|
|
1491
|
+
refs[oldRef] = null;
|
|
1492
|
+
if (!!(process.env.NODE_ENV !== "production") && hasOwn(setupState, oldRef)) {
|
|
1493
|
+
setupState[oldRef] = null;
|
|
1494
|
+
}
|
|
1495
|
+
} else if (isRef(oldRef)) {
|
|
1496
|
+
oldRef.value = null;
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
if (isFunction(ref)) {
|
|
1500
|
+
const invokeRefSetter = (value) => {
|
|
1501
|
+
callWithErrorHandling(ref, currentInstance$1, 12, [
|
|
1502
|
+
value,
|
|
1503
|
+
refs
|
|
1504
|
+
]);
|
|
1505
|
+
};
|
|
1506
|
+
invokeRefSetter(refValue);
|
|
1507
|
+
onScopeDispose(() => invokeRefSetter());
|
|
1508
|
+
} else {
|
|
1509
|
+
const _isString = isString(ref);
|
|
1510
|
+
const _isRef = isRef(ref);
|
|
1511
|
+
let existing;
|
|
1512
|
+
if (_isString || _isRef) {
|
|
1513
|
+
const doSet = () => {
|
|
1514
|
+
if (refFor) {
|
|
1515
|
+
existing = _isString ? !!(process.env.NODE_ENV !== "production") && hasOwn(setupState, ref) ? setupState[ref] : refs[ref] : ref.value;
|
|
1516
|
+
if (!isArray(existing)) {
|
|
1517
|
+
existing = [refValue];
|
|
1518
|
+
if (_isString) {
|
|
1519
|
+
refs[ref] = existing;
|
|
1520
|
+
if (!!(process.env.NODE_ENV !== "production") && hasOwn(setupState, ref)) {
|
|
1521
|
+
setupState[ref] = refs[ref];
|
|
1522
|
+
existing = setupState[ref];
|
|
1523
|
+
}
|
|
1524
|
+
} else {
|
|
1525
|
+
ref.value = existing;
|
|
1526
|
+
}
|
|
1527
|
+
} else if (!existing.includes(refValue)) {
|
|
1528
|
+
existing.push(refValue);
|
|
1529
|
+
}
|
|
1530
|
+
} else if (_isString) {
|
|
1531
|
+
refs[ref] = refValue;
|
|
1532
|
+
if (!!(process.env.NODE_ENV !== "production") && hasOwn(setupState, ref)) {
|
|
1533
|
+
setupState[ref] = refValue;
|
|
1534
|
+
}
|
|
1535
|
+
} else if (_isRef) {
|
|
1536
|
+
ref.value = refValue;
|
|
1537
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1538
|
+
warn("Invalid template ref type:", ref, `(${typeof ref})`);
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
doSet.id = -1;
|
|
1542
|
+
queuePostFlushCb(doSet);
|
|
1543
|
+
onScopeDispose(() => {
|
|
1544
|
+
queuePostFlushCb(() => {
|
|
1545
|
+
if (isArray(existing)) {
|
|
1546
|
+
remove$1(existing, refValue);
|
|
1547
|
+
} else if (_isString) {
|
|
1548
|
+
refs[ref] = null;
|
|
1549
|
+
if (!!(process.env.NODE_ENV !== "production") && hasOwn(setupState, ref)) {
|
|
1550
|
+
setupState[ref] = null;
|
|
1551
|
+
}
|
|
1552
|
+
} else if (_isRef) {
|
|
1553
|
+
ref.value = null;
|
|
1554
|
+
}
|
|
1555
|
+
});
|
|
1556
|
+
});
|
|
1557
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1558
|
+
warn("Invalid template ref type:", ref, `(${typeof ref})`);
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
return ref;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
function createDynamicComponent(getter, rawProps, rawSlots, isSingleRoot) {
|
|
1565
|
+
const frag = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("dynamic-component") : new DynamicFragment();
|
|
1566
|
+
renderEffect(() => {
|
|
1567
|
+
const value = getter();
|
|
1568
|
+
frag.update(
|
|
1569
|
+
() => createComponentWithFallback(
|
|
1570
|
+
resolveDynamicComponent(value),
|
|
1571
|
+
rawProps,
|
|
1572
|
+
rawSlots,
|
|
1573
|
+
isSingleRoot
|
|
1574
|
+
),
|
|
1575
|
+
value
|
|
1576
|
+
);
|
|
1577
|
+
});
|
|
1578
|
+
return frag;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
function applyVShow(target, source) {
|
|
1582
|
+
if (isVaporComponent(target)) {
|
|
1583
|
+
return applyVShow(target.block, source);
|
|
1584
|
+
}
|
|
1585
|
+
if (isArray(target) && target.length === 1) {
|
|
1586
|
+
return applyVShow(target[0], source);
|
|
1587
|
+
}
|
|
1588
|
+
if (target instanceof DynamicFragment) {
|
|
1589
|
+
const update = target.update;
|
|
1590
|
+
target.update = (render, key) => {
|
|
1591
|
+
update.call(target, render, key);
|
|
1592
|
+
setDisplay(target, source());
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
renderEffect(() => setDisplay(target, source()));
|
|
1596
|
+
}
|
|
1597
|
+
function setDisplay(target, value) {
|
|
1598
|
+
if (isVaporComponent(target)) {
|
|
1599
|
+
return setDisplay(target, value);
|
|
1600
|
+
}
|
|
1601
|
+
if (isArray(target) && target.length === 1) {
|
|
1602
|
+
return setDisplay(target[0], value);
|
|
1603
|
+
}
|
|
1604
|
+
if (target instanceof DynamicFragment) {
|
|
1605
|
+
return setDisplay(target.nodes, value);
|
|
1606
|
+
}
|
|
1607
|
+
if (target instanceof Element) {
|
|
1608
|
+
const el = target;
|
|
1609
|
+
if (!(vShowOriginalDisplay in el)) {
|
|
1610
|
+
el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
|
|
1611
|
+
}
|
|
1612
|
+
el.style.display = value ? el[vShowOriginalDisplay] : "none";
|
|
1613
|
+
el[vShowHidden] = !value;
|
|
1614
|
+
} else if (!!(process.env.NODE_ENV !== "production")) {
|
|
1615
|
+
warn(
|
|
1616
|
+
`v-show used on component with non-single-element root node and will be ignored.`
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
const applyTextModel = (el, get, set, { trim, number, lazy } = {}) => {
|
|
1622
|
+
vModelTextInit(el, trim, number, lazy, set);
|
|
1623
|
+
onMounted(() => {
|
|
1624
|
+
let value;
|
|
1625
|
+
renderEffect(() => {
|
|
1626
|
+
vModelTextUpdate(el, value, value = get(), trim, number, lazy);
|
|
1627
|
+
});
|
|
1628
|
+
});
|
|
1629
|
+
};
|
|
1630
|
+
const applyCheckboxModel = (el, get, set) => {
|
|
1631
|
+
vModelCheckboxInit(el, set);
|
|
1632
|
+
onMounted(() => {
|
|
1633
|
+
let value;
|
|
1634
|
+
renderEffect(() => {
|
|
1635
|
+
vModelCheckboxUpdate(
|
|
1636
|
+
el,
|
|
1637
|
+
value,
|
|
1638
|
+
// #4096 array checkboxes need to be deep traversed
|
|
1639
|
+
traverse(value = get())
|
|
1640
|
+
);
|
|
1641
|
+
});
|
|
1642
|
+
});
|
|
1643
|
+
};
|
|
1644
|
+
const applyRadioModel = (el, get, set) => {
|
|
1645
|
+
addEventListener(el, "change", () => set(vModelGetValue(el)));
|
|
1646
|
+
onMounted(() => {
|
|
1647
|
+
let value;
|
|
1648
|
+
renderEffect(() => {
|
|
1649
|
+
if (value !== (value = get())) {
|
|
1650
|
+
el.checked = looseEqual(value, vModelGetValue(el));
|
|
1651
|
+
}
|
|
1652
|
+
});
|
|
1653
|
+
});
|
|
1654
|
+
};
|
|
1655
|
+
const applySelectModel = (el, get, set, modifiers) => {
|
|
1656
|
+
vModelSelectInit(el, get(), modifiers && modifiers.number, set);
|
|
1657
|
+
onMounted(() => {
|
|
1658
|
+
renderEffect(() => vModelSetSelected(el, traverse(get())));
|
|
1659
|
+
});
|
|
1660
|
+
};
|
|
1661
|
+
const applyDynamicModel = (el, get, set, modifiers) => {
|
|
1662
|
+
let apply = applyTextModel;
|
|
1663
|
+
if (el.tagName === "SELECT") {
|
|
1664
|
+
apply = applySelectModel;
|
|
1665
|
+
} else if (el.tagName === "TEXTAREA") {
|
|
1666
|
+
apply = applyTextModel;
|
|
1667
|
+
} else if (el.type === "checkbox") {
|
|
1668
|
+
apply = applyCheckboxModel;
|
|
1669
|
+
} else if (el.type === "radio") {
|
|
1670
|
+
apply = applyRadioModel;
|
|
1671
|
+
}
|
|
1672
|
+
apply(el, get, set, modifiers);
|
|
1673
|
+
};
|
|
1674
|
+
|
|
1675
|
+
const vaporInVDOMInterface = {
|
|
1676
|
+
mount(vnode, container, anchor, parentComponent) {
|
|
1677
|
+
const selfAnchor = vnode.anchor = document.createComment("vapor");
|
|
1678
|
+
container.insertBefore(selfAnchor, anchor);
|
|
1679
|
+
const prev = currentInstance$1;
|
|
1680
|
+
simpleSetCurrentInstance$1(parentComponent);
|
|
1681
|
+
const propsRef = shallowRef$1(vnode.props);
|
|
1682
|
+
const instance = vnode.component = createComponent(vnode.type, {
|
|
1683
|
+
$: [() => propsRef.value]
|
|
1684
|
+
});
|
|
1685
|
+
instance.rawPropsRef = propsRef;
|
|
1686
|
+
mountComponent(instance, container, selfAnchor);
|
|
1687
|
+
simpleSetCurrentInstance$1(prev);
|
|
1688
|
+
return instance;
|
|
1689
|
+
},
|
|
1690
|
+
update(n1, n2) {
|
|
1691
|
+
n2.component = n1.component;
|
|
1692
|
+
n2.component.rawPropsRef.value = n2.props;
|
|
1693
|
+
},
|
|
1694
|
+
unmount(vnode, doRemove) {
|
|
1695
|
+
const container = doRemove ? vnode.anchor.parentNode : undefined;
|
|
1696
|
+
unmountComponent(vnode.component, container);
|
|
1697
|
+
},
|
|
1698
|
+
move(vnode, container, anchor) {
|
|
1699
|
+
insert(vnode.component, container, anchor);
|
|
1700
|
+
insert(vnode.anchor, container, anchor);
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
const vaporInteropPlugin = (app) => {
|
|
1704
|
+
app.config.vapor = vaporInVDOMInterface;
|
|
1705
|
+
};
|
|
1706
|
+
|
|
1707
|
+
export { applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow, children, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createForSlots, createIf, createSlot, createTemplateRefSetter, createTextNode, createVaporApp, defineVaporComponent, delegate, delegateEvents, getDefaultValue, getRestElement, insert, mountComponent, next, on, prepend, remove, renderEffect, setAttr, setClass, setDOMProp, setDynamicEvents, setDynamicProps, setHtml, setProp, setStyle, setText, setValue, template, unmountComponent, vaporInteropPlugin };
|