@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 +6 -2
- package/dist/runtime-vapor.d.ts +247 -0
- package/dist/runtime-vapor.esm-bundler.js +1162 -619
- package/package.json +12 -6
- package/index.js +0 -7
|
@@ -1,324 +1,141 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/runtime-vapor v3.
|
|
2
|
+
* @vue/runtime-vapor v3.6.0-alpha.1
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
import { warn,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { warn, baseEmit, currentInstance, startMeasure, setCurrentInstance, queuePostFlushCb, queueJob, baseNormalizePropsOptions, pushWarningContext, validateProps, popWarningContext, resolvePropValue, isEmitListener, patchStyle, mergeProps, shouldSetAsProp, isRef, registerHMR, callWithErrorHandling, endMeasure, unregisterHMR, nextUid, EffectScope as EffectScope$1, expose, createAppAPI, initFeatureFlags, setDevtoolsHook, flushOnAppMount, normalizeContainer, ensureRenderer, shallowRef, simpleSetCurrentInstance, renderSlot, createVNode, shallowReactive, createInternalObject, onScopeDispose as onScopeDispose$1, resolveDynamicComponent, vShowOriginalDisplay, vShowHidden, vModelTextInit, vModelCheckboxInit, vModelSelectInit, onMounted, vModelTextUpdate, vModelCheckboxUpdate, vModelGetValue, vModelSetSelected } from '@vue/runtime-dom';
|
|
7
|
+
import { isArray, EMPTY_OBJ, hasOwn, invokeArrayFns, EMPTY_ARR, isFunction, camelize, isString, NO, YES, normalizeClass, normalizeStyle, parseStringStyle, isOn, canSetValueDirectly, toDisplayString, getGlobalThis, extend, isObject, remove as remove$1, looseEqual } from '@vue/shared';
|
|
8
|
+
import { setActiveSub, EffectScope, ReactiveEffect, onEffectCleanup, proxyRefs, onScopeDispose, markRaw, unref, watch, isReactive, isShallow, shallowReadArray, isReadonly, toReadonly, toReactive, shallowRef as shallowRef$1, isRef as isRef$1, traverse } from '@vue/reactivity';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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();
|
|
10
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
11
|
+
// @__NO_SIDE_EFFECTS__
|
|
12
|
+
function createTextNode(value = "") {
|
|
13
|
+
return document.createTextNode(value);
|
|
53
14
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return
|
|
15
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
16
|
+
// @__NO_SIDE_EFFECTS__
|
|
17
|
+
function createComment(data) {
|
|
18
|
+
return document.createComment(data);
|
|
58
19
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
};
|
|
20
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
21
|
+
// @__NO_SIDE_EFFECTS__
|
|
22
|
+
function child(node) {
|
|
23
|
+
return node.firstChild;
|
|
88
24
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
}
|
|
25
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
26
|
+
// @__NO_SIDE_EFFECTS__
|
|
27
|
+
function nthChild(node, i) {
|
|
28
|
+
return node.childNodes[i];
|
|
29
|
+
}
|
|
30
|
+
/*! #__NO_SIDE_EFFECTS__ */
|
|
31
|
+
// @__NO_SIDE_EFFECTS__
|
|
32
|
+
function next(node) {
|
|
33
|
+
return node.nextSibling;
|
|
129
34
|
}
|
|
130
35
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
setAttr(el, key, value);
|
|
137
|
-
}
|
|
36
|
+
let insertionParent;
|
|
37
|
+
let insertionAnchor;
|
|
38
|
+
function setInsertionState(parent, anchor) {
|
|
39
|
+
insertionParent = parent;
|
|
40
|
+
insertionAnchor = anchor;
|
|
138
41
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
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
|
-
}
|
|
42
|
+
function resetInsertionState() {
|
|
43
|
+
insertionParent = insertionAnchor = void 0;
|
|
156
44
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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);
|
|
45
|
+
|
|
46
|
+
let isHydrating = false;
|
|
47
|
+
let currentHydrationNode = null;
|
|
48
|
+
let isOptimized$1 = false;
|
|
49
|
+
function withHydration(container, fn) {
|
|
50
|
+
adoptTemplate = adoptTemplateImpl;
|
|
51
|
+
locateHydrationNode = locateHydrationNodeImpl;
|
|
52
|
+
if (!isOptimized$1) {
|
|
53
|
+
Comment.prototype.$fs = void 0;
|
|
54
|
+
isOptimized$1 = true;
|
|
55
|
+
}
|
|
56
|
+
isHydrating = true;
|
|
57
|
+
setInsertionState(container, 0);
|
|
58
|
+
const res = fn();
|
|
59
|
+
resetInsertionState();
|
|
60
|
+
currentHydrationNode = null;
|
|
61
|
+
isHydrating = false;
|
|
62
|
+
return res;
|
|
187
63
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
64
|
+
let adoptTemplate;
|
|
65
|
+
let locateHydrationNode;
|
|
66
|
+
const isComment = (node, data) => node.nodeType === 8 && node.data === data;
|
|
67
|
+
function adoptTemplateImpl(node, template) {
|
|
68
|
+
if (!(template[0] === "<" && template[1] === "!")) {
|
|
69
|
+
while (node.nodeType === 8) node = next(node);
|
|
193
70
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
}
|
|
71
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
72
|
+
const type = node.nodeType;
|
|
73
|
+
if (type === 8 && !template.startsWith("<!") || type === 1 && !template.startsWith(`<` + node.tagName.toLowerCase()) || type === 3 && template.trim() && !template.startsWith(node.data)) {
|
|
74
|
+
warn(`adopted: `, node);
|
|
75
|
+
warn(`template: ${template}`);
|
|
76
|
+
warn("hydration mismatch!");
|
|
205
77
|
}
|
|
206
78
|
}
|
|
79
|
+
currentHydrationNode = next(node);
|
|
80
|
+
return node;
|
|
207
81
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
82
|
+
function locateHydrationNodeImpl() {
|
|
83
|
+
let node;
|
|
84
|
+
if (insertionAnchor === 0) {
|
|
85
|
+
node = child(insertionParent);
|
|
211
86
|
} else {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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);
|
|
87
|
+
node = insertionAnchor ? insertionAnchor.previousSibling : insertionParent ? insertionParent.lastChild : currentHydrationNode;
|
|
88
|
+
if (node && isComment(node, "]")) {
|
|
89
|
+
if (node.$fs) {
|
|
90
|
+
node = node.$fs;
|
|
91
|
+
} else {
|
|
92
|
+
let cur = node;
|
|
93
|
+
let curFragEnd = node;
|
|
94
|
+
let fragDepth = 0;
|
|
95
|
+
node = null;
|
|
96
|
+
while (cur) {
|
|
97
|
+
cur = cur.previousSibling;
|
|
98
|
+
if (cur) {
|
|
99
|
+
if (isComment(cur, "[")) {
|
|
100
|
+
curFragEnd.$fs = cur;
|
|
101
|
+
if (!fragDepth) {
|
|
102
|
+
node = cur;
|
|
103
|
+
break;
|
|
104
|
+
} else {
|
|
105
|
+
fragDepth--;
|
|
106
|
+
}
|
|
107
|
+
} else if (isComment(cur, "]")) {
|
|
108
|
+
curFragEnd = cur;
|
|
109
|
+
fragDepth++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
258
113
|
}
|
|
259
114
|
}
|
|
260
115
|
}
|
|
261
|
-
|
|
262
|
-
|
|
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
|
-
}
|
|
116
|
+
if (!!(process.env.NODE_ENV !== "production") && !node) {
|
|
117
|
+
warn("Hydration mismatch in ", insertionParent);
|
|
297
118
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
301
|
-
// @__NO_SIDE_EFFECTS__
|
|
302
|
-
function createComment(data) {
|
|
303
|
-
return document.createComment(data);
|
|
119
|
+
resetInsertionState();
|
|
120
|
+
currentHydrationNode = node;
|
|
304
121
|
}
|
|
305
122
|
|
|
306
|
-
class
|
|
123
|
+
class VaporFragment {
|
|
307
124
|
constructor(nodes) {
|
|
308
125
|
this.nodes = nodes;
|
|
309
126
|
}
|
|
310
127
|
}
|
|
311
|
-
class DynamicFragment extends
|
|
128
|
+
class DynamicFragment extends VaporFragment {
|
|
312
129
|
constructor(anchorLabel) {
|
|
313
130
|
super([]);
|
|
314
|
-
this.anchor = !!(process.env.NODE_ENV !== "production") && anchorLabel ? createComment(anchorLabel) :
|
|
131
|
+
this.anchor = !!(process.env.NODE_ENV !== "production") && anchorLabel ? createComment(anchorLabel) : createTextNode();
|
|
315
132
|
}
|
|
316
133
|
update(render, key = render) {
|
|
317
134
|
if (key === this.current) {
|
|
318
135
|
return;
|
|
319
136
|
}
|
|
320
137
|
this.current = key;
|
|
321
|
-
|
|
138
|
+
const prevSub = setActiveSub();
|
|
322
139
|
const parent = this.anchor.parentNode;
|
|
323
140
|
if (this.scope) {
|
|
324
141
|
this.scope.stop();
|
|
@@ -329,7 +146,7 @@ class DynamicFragment extends Fragment {
|
|
|
329
146
|
this.nodes = this.scope.run(render) || [];
|
|
330
147
|
if (parent) insert(this.nodes, parent, this.anchor);
|
|
331
148
|
} else {
|
|
332
|
-
this.scope =
|
|
149
|
+
this.scope = void 0;
|
|
333
150
|
this.nodes = [];
|
|
334
151
|
}
|
|
335
152
|
if (this.fallback && !isValidBlock(this.nodes)) {
|
|
@@ -337,11 +154,11 @@ class DynamicFragment extends Fragment {
|
|
|
337
154
|
this.nodes = (this.scope || (this.scope = new EffectScope())).run(this.fallback) || [];
|
|
338
155
|
parent && insert(this.nodes, parent, this.anchor);
|
|
339
156
|
}
|
|
340
|
-
|
|
157
|
+
setActiveSub(prevSub);
|
|
341
158
|
}
|
|
342
159
|
}
|
|
343
160
|
function isFragment(val) {
|
|
344
|
-
return val instanceof
|
|
161
|
+
return val instanceof VaporFragment;
|
|
345
162
|
}
|
|
346
163
|
function isBlock(val) {
|
|
347
164
|
return val instanceof Node || isArray(val) || isVaporComponent(val) || isFragment(val);
|
|
@@ -360,15 +177,25 @@ function isValidBlock(block) {
|
|
|
360
177
|
function insert(block, parent, anchor = null) {
|
|
361
178
|
anchor = anchor === 0 ? parent.firstChild : anchor;
|
|
362
179
|
if (block instanceof Node) {
|
|
363
|
-
|
|
180
|
+
if (!isHydrating) {
|
|
181
|
+
parent.insertBefore(block, anchor);
|
|
182
|
+
}
|
|
364
183
|
} else if (isVaporComponent(block)) {
|
|
365
|
-
|
|
184
|
+
if (block.isMounted) {
|
|
185
|
+
insert(block.block, parent, anchor);
|
|
186
|
+
} else {
|
|
187
|
+
mountComponent(block, parent, anchor);
|
|
188
|
+
}
|
|
366
189
|
} else if (isArray(block)) {
|
|
367
|
-
for (
|
|
368
|
-
insert(
|
|
190
|
+
for (const b of block) {
|
|
191
|
+
insert(b, parent, anchor);
|
|
369
192
|
}
|
|
370
193
|
} else {
|
|
371
|
-
|
|
194
|
+
if (block.insert) {
|
|
195
|
+
block.insert(parent, anchor);
|
|
196
|
+
} else {
|
|
197
|
+
insert(block.nodes, parent, anchor);
|
|
198
|
+
}
|
|
372
199
|
if (block.anchor) insert(block.anchor, parent, anchor);
|
|
373
200
|
}
|
|
374
201
|
}
|
|
@@ -376,14 +203,9 @@ function prepend(parent, ...blocks) {
|
|
|
376
203
|
let i = blocks.length;
|
|
377
204
|
while (i--) insert(blocks[i], parent, 0);
|
|
378
205
|
}
|
|
379
|
-
let parentsWithUnmountedChildren = null;
|
|
380
206
|
function remove(block, parent) {
|
|
381
|
-
const isRoot = !parentsWithUnmountedChildren;
|
|
382
|
-
if (isRoot) {
|
|
383
|
-
parentsWithUnmountedChildren = /* @__PURE__ */ new Set();
|
|
384
|
-
}
|
|
385
207
|
if (block instanceof Node) {
|
|
386
|
-
parent.removeChild(block);
|
|
208
|
+
parent && parent.removeChild(block);
|
|
387
209
|
} else if (isVaporComponent(block)) {
|
|
388
210
|
unmountComponent(block, parent);
|
|
389
211
|
} else if (isArray(block)) {
|
|
@@ -391,18 +213,16 @@ function remove(block, parent) {
|
|
|
391
213
|
remove(block[i], parent);
|
|
392
214
|
}
|
|
393
215
|
} else {
|
|
394
|
-
|
|
216
|
+
if (block.remove) {
|
|
217
|
+
block.remove(parent);
|
|
218
|
+
} else {
|
|
219
|
+
remove(block.nodes, parent);
|
|
220
|
+
}
|
|
395
221
|
if (block.anchor) remove(block.anchor, parent);
|
|
396
222
|
if (block.scope) {
|
|
397
223
|
block.scope.stop();
|
|
398
224
|
}
|
|
399
225
|
}
|
|
400
|
-
if (isRoot) {
|
|
401
|
-
for (const i of parentsWithUnmountedChildren) {
|
|
402
|
-
i.children = i.children.filter((n) => !n.isUnmounted);
|
|
403
|
-
}
|
|
404
|
-
parentsWithUnmountedChildren = null;
|
|
405
|
-
}
|
|
406
226
|
}
|
|
407
227
|
function normalizeBlock(block) {
|
|
408
228
|
if (!!!(process.env.NODE_ENV !== "production") && true) {
|
|
@@ -459,6 +279,69 @@ function propGetter(rawProps, key) {
|
|
|
459
279
|
return rawProps[key] && resolveSource(rawProps[key]);
|
|
460
280
|
}
|
|
461
281
|
|
|
282
|
+
class RenderEffect extends ReactiveEffect {
|
|
283
|
+
constructor(render) {
|
|
284
|
+
super();
|
|
285
|
+
this.render = render;
|
|
286
|
+
const instance = currentInstance;
|
|
287
|
+
if (!!(process.env.NODE_ENV !== "production") && true && !this.subs && !isVaporComponent(instance)) {
|
|
288
|
+
warn("renderEffect called without active EffectScope or Vapor instance.");
|
|
289
|
+
}
|
|
290
|
+
const job = () => {
|
|
291
|
+
if (this.dirty) {
|
|
292
|
+
this.run();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
this.updateJob = () => {
|
|
296
|
+
instance.isUpdating = false;
|
|
297
|
+
instance.u && invokeArrayFns(instance.u);
|
|
298
|
+
};
|
|
299
|
+
if (instance) {
|
|
300
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
301
|
+
this.onTrack = instance.rtc ? (e) => invokeArrayFns(instance.rtc, e) : void 0;
|
|
302
|
+
this.onTrigger = instance.rtg ? (e) => invokeArrayFns(instance.rtg, e) : void 0;
|
|
303
|
+
}
|
|
304
|
+
job.i = instance;
|
|
305
|
+
}
|
|
306
|
+
this.job = job;
|
|
307
|
+
this.i = instance;
|
|
308
|
+
}
|
|
309
|
+
fn() {
|
|
310
|
+
const instance = this.i;
|
|
311
|
+
const scope = this.subs ? this.subs.sub : void 0;
|
|
312
|
+
const hasUpdateHooks = instance && (instance.bu || instance.u);
|
|
313
|
+
if (!!(process.env.NODE_ENV !== "production") && instance) {
|
|
314
|
+
startMeasure(instance, `renderEffect`);
|
|
315
|
+
}
|
|
316
|
+
const prev = setCurrentInstance(instance, scope);
|
|
317
|
+
if (hasUpdateHooks && instance.isMounted && !instance.isUpdating) {
|
|
318
|
+
instance.isUpdating = true;
|
|
319
|
+
instance.bu && invokeArrayFns(instance.bu);
|
|
320
|
+
this.render();
|
|
321
|
+
queuePostFlushCb(this.updateJob);
|
|
322
|
+
} else {
|
|
323
|
+
this.render();
|
|
324
|
+
}
|
|
325
|
+
setCurrentInstance(...prev);
|
|
326
|
+
if (!!(process.env.NODE_ENV !== "production") && instance) {
|
|
327
|
+
startMeasure(instance, `renderEffect`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
notify() {
|
|
331
|
+
const flags = this.flags;
|
|
332
|
+
if (!(flags & 256)) {
|
|
333
|
+
queueJob(this.job, this.i ? this.i.uid : void 0);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function renderEffect(fn, noLifecycle = false) {
|
|
338
|
+
const effect = new RenderEffect(fn);
|
|
339
|
+
if (noLifecycle) {
|
|
340
|
+
effect.fn = fn;
|
|
341
|
+
}
|
|
342
|
+
effect.run();
|
|
343
|
+
}
|
|
344
|
+
|
|
462
345
|
function resolveSource(source) {
|
|
463
346
|
return isFunction(source) ? source() : source;
|
|
464
347
|
}
|
|
@@ -471,6 +354,7 @@ function getPropsProxyHandlers(comp) {
|
|
|
471
354
|
const isProp = propsOptions ? (key) => isString(key) && hasOwn(propsOptions, camelize(key)) : NO;
|
|
472
355
|
const isAttr = propsOptions ? (key) => key !== "$" && !isProp(key) && !isEmitListener(emitsOptions, key) : YES;
|
|
473
356
|
const getProp = (instance, key) => {
|
|
357
|
+
if (key === "__v_isReactive") return true;
|
|
474
358
|
if (!isProp(key)) return;
|
|
475
359
|
const rawProps = instance.rawProps;
|
|
476
360
|
const dynamicSources = rawProps.$;
|
|
@@ -508,7 +392,7 @@ function getPropsProxyHandlers(comp) {
|
|
|
508
392
|
return resolvePropValue(
|
|
509
393
|
propsOptions,
|
|
510
394
|
key,
|
|
511
|
-
|
|
395
|
+
void 0,
|
|
512
396
|
instance,
|
|
513
397
|
resolveDefault,
|
|
514
398
|
true
|
|
@@ -570,7 +454,7 @@ function getPropsProxyHandlers(comp) {
|
|
|
570
454
|
}
|
|
571
455
|
function getAttrFromRawProps(rawProps, key) {
|
|
572
456
|
if (key === "$") return;
|
|
573
|
-
const merged = key === "class" || key === "style" ? [] :
|
|
457
|
+
const merged = key === "class" || key === "style" ? [] : void 0;
|
|
574
458
|
const dynamicSources = rawProps.$;
|
|
575
459
|
if (dynamicSources) {
|
|
576
460
|
let i = dynamicSources.length;
|
|
@@ -579,7 +463,7 @@ function getAttrFromRawProps(rawProps, key) {
|
|
|
579
463
|
source = dynamicSources[i];
|
|
580
464
|
isDynamic = isFunction(source);
|
|
581
465
|
source = isDynamic ? source() : source;
|
|
582
|
-
if (hasOwn(source, key)) {
|
|
466
|
+
if (source && hasOwn(source, key)) {
|
|
583
467
|
const value = isDynamic ? source[key] : source[key]();
|
|
584
468
|
if (merged) {
|
|
585
469
|
merged.push(value);
|
|
@@ -596,7 +480,9 @@ function getAttrFromRawProps(rawProps, key) {
|
|
|
596
480
|
return rawProps[key]();
|
|
597
481
|
}
|
|
598
482
|
}
|
|
599
|
-
|
|
483
|
+
if (merged && merged.length) {
|
|
484
|
+
return merged;
|
|
485
|
+
}
|
|
600
486
|
}
|
|
601
487
|
function hasAttrFromRawProps(rawProps, key) {
|
|
602
488
|
if (key === "$") return false;
|
|
@@ -604,7 +490,8 @@ function hasAttrFromRawProps(rawProps, key) {
|
|
|
604
490
|
if (dynamicSources) {
|
|
605
491
|
let i = dynamicSources.length;
|
|
606
492
|
while (i--) {
|
|
607
|
-
|
|
493
|
+
const source = resolveSource(dynamicSources[i]);
|
|
494
|
+
if (source && hasOwn(source, key)) {
|
|
608
495
|
return true;
|
|
609
496
|
}
|
|
610
497
|
}
|
|
@@ -640,10 +527,9 @@ function normalizePropsOptions(comp) {
|
|
|
640
527
|
return comp.__propsOptions = [normalized, needCastKeys];
|
|
641
528
|
}
|
|
642
529
|
function resolveDefault(factory, instance) {
|
|
643
|
-
const prev =
|
|
644
|
-
simpleSetCurrentInstance$1(instance);
|
|
530
|
+
const prev = setCurrentInstance(instance);
|
|
645
531
|
const res = factory.call(null, instance.props);
|
|
646
|
-
|
|
532
|
+
setCurrentInstance(...prev);
|
|
647
533
|
return res;
|
|
648
534
|
}
|
|
649
535
|
function hasFallthroughAttrs(comp, rawProps) {
|
|
@@ -718,36 +604,265 @@ function propsDeleteDevTrap(_, key) {
|
|
|
718
604
|
);
|
|
719
605
|
return true;
|
|
720
606
|
}
|
|
607
|
+
const rawPropsProxyHandlers = {
|
|
608
|
+
get: getAttrFromRawProps,
|
|
609
|
+
has: hasAttrFromRawProps,
|
|
610
|
+
ownKeys: getKeysFromRawProps,
|
|
611
|
+
getOwnPropertyDescriptor(target, key) {
|
|
612
|
+
if (hasAttrFromRawProps(target, key)) {
|
|
613
|
+
return {
|
|
614
|
+
configurable: true,
|
|
615
|
+
enumerable: true,
|
|
616
|
+
get: () => getAttrFromRawProps(target, key)
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
};
|
|
721
621
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
)
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
622
|
+
function addEventListener(el, event, handler, options) {
|
|
623
|
+
el.addEventListener(event, handler, options);
|
|
624
|
+
return () => el.removeEventListener(event, handler, options);
|
|
625
|
+
}
|
|
626
|
+
function on(el, event, handler, options = {}) {
|
|
627
|
+
addEventListener(el, event, handler, options);
|
|
628
|
+
if (options.effect) {
|
|
629
|
+
onEffectCleanup(() => {
|
|
630
|
+
el.removeEventListener(event, handler, options);
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function delegate(el, event, handler) {
|
|
635
|
+
const key = `$evt${event}`;
|
|
636
|
+
const existing = el[key];
|
|
637
|
+
if (existing) {
|
|
638
|
+
if (isArray(existing)) {
|
|
639
|
+
existing.push(handler);
|
|
640
|
+
} else {
|
|
641
|
+
el[key] = [existing, handler];
|
|
642
|
+
}
|
|
643
|
+
} else {
|
|
644
|
+
el[key] = handler;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
const delegatedEvents = /* @__PURE__ */ Object.create(null);
|
|
648
|
+
const delegateEvents = (...names) => {
|
|
649
|
+
for (const name of names) {
|
|
650
|
+
if (!delegatedEvents[name]) {
|
|
651
|
+
delegatedEvents[name] = true;
|
|
652
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
const delegatedEventHandler = (e) => {
|
|
657
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
658
|
+
if (e.target !== node) {
|
|
659
|
+
Object.defineProperty(e, "target", {
|
|
660
|
+
configurable: true,
|
|
661
|
+
value: node
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
Object.defineProperty(e, "currentTarget", {
|
|
665
|
+
configurable: true,
|
|
666
|
+
get() {
|
|
667
|
+
return node || document;
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
while (node !== null) {
|
|
671
|
+
const handlers = node[`$evt${e.type}`];
|
|
672
|
+
if (handlers) {
|
|
673
|
+
if (isArray(handlers)) {
|
|
674
|
+
for (const handler of handlers) {
|
|
675
|
+
if (!node.disabled) {
|
|
676
|
+
handler(e);
|
|
677
|
+
if (e.cancelBubble) return;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
} else {
|
|
681
|
+
handlers(e);
|
|
682
|
+
if (e.cancelBubble) return;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
function setDynamicEvents(el, events) {
|
|
689
|
+
for (const name in events) {
|
|
690
|
+
on(el, name, events[name], { effect: true });
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const hasFallthroughKey = (key) => currentInstance.hasFallthrough && key in currentInstance.attrs;
|
|
695
|
+
function setProp(el, key, value) {
|
|
696
|
+
if (key in el) {
|
|
697
|
+
setDOMProp(el, key, value);
|
|
698
|
+
} else {
|
|
699
|
+
setAttr(el, key, value);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function setAttr(el, key, value) {
|
|
703
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey(key)) {
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
if (key === "true-value") {
|
|
707
|
+
el._trueValue = value;
|
|
708
|
+
} else if (key === "false-value") {
|
|
709
|
+
el._falseValue = value;
|
|
710
|
+
}
|
|
711
|
+
if (value !== el[`$${key}`]) {
|
|
712
|
+
el[`$${key}`] = value;
|
|
713
|
+
if (value != null) {
|
|
714
|
+
el.setAttribute(key, value);
|
|
715
|
+
} else {
|
|
716
|
+
el.removeAttribute(key);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
function setDOMProp(el, key, value) {
|
|
721
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey(key)) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const prev = el[key];
|
|
725
|
+
if (value === prev) {
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
let needRemove = false;
|
|
729
|
+
if (value === "" || value == null) {
|
|
730
|
+
const type = typeof prev;
|
|
731
|
+
if (value == null && type === "string") {
|
|
732
|
+
value = "";
|
|
733
|
+
needRemove = true;
|
|
734
|
+
} else if (type === "number") {
|
|
735
|
+
value = 0;
|
|
736
|
+
needRemove = true;
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
try {
|
|
740
|
+
el[key] = value;
|
|
741
|
+
} catch (e) {
|
|
742
|
+
if (!!(process.env.NODE_ENV !== "production") && !needRemove) {
|
|
743
|
+
warn(
|
|
744
|
+
`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: value ${value} is invalid.`,
|
|
745
|
+
e
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
needRemove && el.removeAttribute(key);
|
|
750
|
+
}
|
|
751
|
+
function setClass(el, value) {
|
|
752
|
+
if (el.$root) {
|
|
753
|
+
setClassIncremental(el, value);
|
|
754
|
+
} else if ((value = normalizeClass(value)) !== el.$cls) {
|
|
755
|
+
el.className = el.$cls = value;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function setClassIncremental(el, value) {
|
|
759
|
+
const cacheKey = `$clsi${isApplyingFallthroughProps ? "$" : ""}`;
|
|
760
|
+
const prev = el[cacheKey];
|
|
761
|
+
if ((value = el[cacheKey] = normalizeClass(value)) !== prev) {
|
|
762
|
+
const nextList = value.split(/\s+/);
|
|
763
|
+
if (value) {
|
|
764
|
+
el.classList.add(...nextList);
|
|
765
|
+
}
|
|
766
|
+
if (prev) {
|
|
767
|
+
for (const cls of prev.split(/\s+/)) {
|
|
768
|
+
if (!nextList.includes(cls)) el.classList.remove(cls);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function setStyle(el, value) {
|
|
774
|
+
if (el.$root) {
|
|
775
|
+
setStyleIncremental(el, value);
|
|
776
|
+
} else {
|
|
777
|
+
const prev = el.$sty;
|
|
778
|
+
value = el.$sty = normalizeStyle(value);
|
|
779
|
+
patchStyle(el, prev, value);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function setStyleIncremental(el, value) {
|
|
783
|
+
const cacheKey = `$styi${isApplyingFallthroughProps ? "$" : ""}`;
|
|
784
|
+
const prev = el[cacheKey];
|
|
785
|
+
value = el[cacheKey] = isString(value) ? parseStringStyle(value) : normalizeStyle(value);
|
|
786
|
+
patchStyle(el, prev, value);
|
|
787
|
+
return value;
|
|
788
|
+
}
|
|
789
|
+
function setValue(el, value) {
|
|
790
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey("value")) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
el._value = value;
|
|
794
|
+
const oldValue = el.tagName === "OPTION" ? el.getAttribute("value") : el.value;
|
|
795
|
+
const newValue = value == null ? "" : value;
|
|
796
|
+
if (oldValue !== newValue) {
|
|
797
|
+
el.value = newValue;
|
|
798
|
+
}
|
|
799
|
+
if (value == null) {
|
|
800
|
+
el.removeAttribute("value");
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function setText(el, value) {
|
|
804
|
+
if (el.$txt !== value) {
|
|
805
|
+
el.nodeValue = el.$txt = value;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
function setElementText(el, value) {
|
|
809
|
+
if (el.$txt !== (value = toDisplayString(value))) {
|
|
810
|
+
el.textContent = el.$txt = value;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
function setHtml(el, value) {
|
|
814
|
+
value = value == null ? "" : value;
|
|
815
|
+
if (el.$html !== value) {
|
|
816
|
+
el.innerHTML = el.$html = value;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function setDynamicProps(el, args) {
|
|
820
|
+
const props = args.length > 1 ? mergeProps(...args) : args[0];
|
|
821
|
+
const cacheKey = `$dprops${isApplyingFallthroughProps ? "$" : ""}`;
|
|
822
|
+
const prevKeys = el[cacheKey];
|
|
823
|
+
if (prevKeys) {
|
|
824
|
+
for (const key of prevKeys) {
|
|
825
|
+
if (!(key in props)) {
|
|
826
|
+
setDynamicProp(el, key, null);
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
for (const key of el[cacheKey] = Object.keys(props)) {
|
|
831
|
+
setDynamicProp(el, key, props[key]);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
function setDynamicProp(el, key, value) {
|
|
835
|
+
const isSVG = false;
|
|
836
|
+
if (key === "class") {
|
|
837
|
+
setClass(el, value);
|
|
838
|
+
} else if (key === "style") {
|
|
839
|
+
setStyle(el, value);
|
|
840
|
+
} else if (isOn(key)) {
|
|
841
|
+
on(el, key[2].toLowerCase() + key.slice(3), value, { effect: true });
|
|
842
|
+
} else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, value, isSVG)) {
|
|
843
|
+
if (key === "innerHTML") {
|
|
844
|
+
setHtml(el, value);
|
|
845
|
+
} else if (key === "textContent") {
|
|
846
|
+
setElementText(el, value);
|
|
847
|
+
} else if (key === "value" && canSetValueDirectly(el.tagName)) {
|
|
848
|
+
setValue(el, value);
|
|
849
|
+
} else {
|
|
850
|
+
setDOMProp(el, key, value);
|
|
851
|
+
}
|
|
852
|
+
} else {
|
|
853
|
+
setAttr(el, key, value);
|
|
854
|
+
}
|
|
855
|
+
return value;
|
|
856
|
+
}
|
|
857
|
+
let isOptimized = false;
|
|
858
|
+
function optimizePropertyLookup() {
|
|
859
|
+
if (isOptimized) return;
|
|
860
|
+
isOptimized = true;
|
|
861
|
+
const proto = Element.prototype;
|
|
862
|
+
proto.$evtclick = void 0;
|
|
863
|
+
proto.$root = false;
|
|
864
|
+
proto.$html = proto.$txt = proto.$cls = proto.$sty = Text.prototype.$txt = "";
|
|
742
865
|
}
|
|
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
866
|
|
|
752
867
|
const dynamicSlotsProxyHandlers = {
|
|
753
868
|
get: getSlot,
|
|
@@ -813,46 +928,53 @@ function getSlot(target, key) {
|
|
|
813
928
|
return target[key];
|
|
814
929
|
}
|
|
815
930
|
}
|
|
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
931
|
function createSlot(name, rawProps, fallback) {
|
|
932
|
+
const _insertionParent = insertionParent;
|
|
933
|
+
const _insertionAnchor = insertionAnchor;
|
|
934
|
+
if (isHydrating) {
|
|
935
|
+
locateHydrationNode();
|
|
936
|
+
} else {
|
|
937
|
+
resetInsertionState();
|
|
938
|
+
}
|
|
831
939
|
const instance = currentInstance;
|
|
832
940
|
const rawSlots = instance.rawSlots;
|
|
833
|
-
const
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
);
|
|
941
|
+
const slotProps = rawProps ? new Proxy(rawProps, rawPropsProxyHandlers) : EMPTY_OBJ;
|
|
942
|
+
let fragment;
|
|
943
|
+
if (isRef(rawSlots._)) {
|
|
944
|
+
fragment = instance.appContext.vapor.vdomSlot(
|
|
945
|
+
rawSlots._,
|
|
946
|
+
name,
|
|
947
|
+
slotProps,
|
|
948
|
+
instance,
|
|
949
|
+
fallback
|
|
950
|
+
);
|
|
951
|
+
} else {
|
|
952
|
+
fragment = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("slot") : new DynamicFragment();
|
|
953
|
+
const isDynamicName = isFunction(name);
|
|
954
|
+
const renderSlot = () => {
|
|
955
|
+
const slot = getSlot(rawSlots, isFunction(name) ? name() : name);
|
|
956
|
+
if (slot) {
|
|
957
|
+
fragment.update(
|
|
958
|
+
slot._bound || (slot._bound = () => {
|
|
959
|
+
const slotContent = slot(slotProps);
|
|
960
|
+
if (slotContent instanceof DynamicFragment) {
|
|
961
|
+
slotContent.fallback = fallback;
|
|
962
|
+
}
|
|
963
|
+
return slotContent;
|
|
964
|
+
})
|
|
965
|
+
);
|
|
966
|
+
} else {
|
|
967
|
+
fragment.update(fallback);
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
if (isDynamicName || rawSlots.$) {
|
|
971
|
+
renderEffect(renderSlot);
|
|
848
972
|
} else {
|
|
849
|
-
|
|
973
|
+
renderSlot();
|
|
850
974
|
}
|
|
851
|
-
}
|
|
852
|
-
if (
|
|
853
|
-
|
|
854
|
-
} else {
|
|
855
|
-
renderSlot();
|
|
975
|
+
}
|
|
976
|
+
if (!isHydrating && _insertionParent) {
|
|
977
|
+
insert(fragment, _insertionParent, _insertionAnchor);
|
|
856
978
|
}
|
|
857
979
|
return fragment;
|
|
858
980
|
}
|
|
@@ -862,10 +984,11 @@ function hmrRerender(instance) {
|
|
|
862
984
|
const parent = normalized[0].parentNode;
|
|
863
985
|
const anchor = normalized[normalized.length - 1].nextSibling;
|
|
864
986
|
remove(instance.block, parent);
|
|
865
|
-
const prev =
|
|
866
|
-
|
|
987
|
+
const prev = setCurrentInstance(instance);
|
|
988
|
+
pushWarningContext(instance);
|
|
867
989
|
devRender(instance);
|
|
868
|
-
|
|
990
|
+
popWarningContext();
|
|
991
|
+
setCurrentInstance(...prev);
|
|
869
992
|
insert(instance.block, parent, anchor);
|
|
870
993
|
}
|
|
871
994
|
function hmrReload(instance, newComp) {
|
|
@@ -873,21 +996,38 @@ function hmrReload(instance, newComp) {
|
|
|
873
996
|
const parent = normalized[0].parentNode;
|
|
874
997
|
const anchor = normalized[normalized.length - 1].nextSibling;
|
|
875
998
|
unmountComponent(instance, parent);
|
|
876
|
-
const prev =
|
|
877
|
-
simpleSetCurrentInstance(instance.parent);
|
|
999
|
+
const prev = setCurrentInstance(instance.parent);
|
|
878
1000
|
const newInstance = createComponent(
|
|
879
1001
|
newComp,
|
|
880
1002
|
instance.rawProps,
|
|
881
1003
|
instance.rawSlots,
|
|
882
1004
|
instance.isSingleRoot
|
|
883
1005
|
);
|
|
884
|
-
|
|
1006
|
+
setCurrentInstance(...prev);
|
|
885
1007
|
mountComponent(newInstance, parent, anchor);
|
|
886
1008
|
}
|
|
887
1009
|
|
|
888
|
-
function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext) {
|
|
889
|
-
|
|
890
|
-
|
|
1010
|
+
function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext = currentInstance && currentInstance.appContext || emptyContext) {
|
|
1011
|
+
const _insertionParent = insertionParent;
|
|
1012
|
+
const _insertionAnchor = insertionAnchor;
|
|
1013
|
+
if (isHydrating) {
|
|
1014
|
+
locateHydrationNode();
|
|
1015
|
+
} else {
|
|
1016
|
+
resetInsertionState();
|
|
1017
|
+
}
|
|
1018
|
+
if (appContext.vapor && !component.__vapor) {
|
|
1019
|
+
const frag = appContext.vapor.vdomMount(
|
|
1020
|
+
component,
|
|
1021
|
+
rawProps,
|
|
1022
|
+
rawSlots
|
|
1023
|
+
);
|
|
1024
|
+
if (!isHydrating && _insertionParent) {
|
|
1025
|
+
insert(frag, _insertionParent, _insertionAnchor);
|
|
1026
|
+
}
|
|
1027
|
+
return frag;
|
|
1028
|
+
}
|
|
1029
|
+
if (isSingleRoot && component.inheritAttrs !== false && isVaporComponent(currentInstance) && currentInstance.hasFallthrough) {
|
|
1030
|
+
const attrs = currentInstance.attrs;
|
|
891
1031
|
if (rawProps) {
|
|
892
1032
|
(rawProps.$ || (rawProps.$ = [])).push(
|
|
893
1033
|
() => attrs
|
|
@@ -902,13 +1042,20 @@ function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext
|
|
|
902
1042
|
rawSlots,
|
|
903
1043
|
appContext
|
|
904
1044
|
);
|
|
1045
|
+
if (!!(process.env.NODE_ENV !== "production") && component.__hmrId) {
|
|
1046
|
+
registerHMR(instance);
|
|
1047
|
+
instance.isSingleRoot = isSingleRoot;
|
|
1048
|
+
instance.hmrRerender = hmrRerender.bind(null, instance);
|
|
1049
|
+
instance.hmrReload = hmrReload.bind(null, instance);
|
|
1050
|
+
}
|
|
905
1051
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
906
1052
|
pushWarningContext(instance);
|
|
907
1053
|
startMeasure(instance, `init`);
|
|
1054
|
+
instance.propsOptions = normalizePropsOptions(component);
|
|
1055
|
+
instance.emitsOptions = normalizeEmitsOptions(component);
|
|
908
1056
|
}
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
pauseTracking();
|
|
1057
|
+
const prevInstance = setCurrentInstance(instance);
|
|
1058
|
+
const prevSub = setActiveSub();
|
|
912
1059
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
913
1060
|
setupPropsValidation(instance);
|
|
914
1061
|
}
|
|
@@ -930,12 +1077,6 @@ function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext
|
|
|
930
1077
|
instance.devtoolsRawSetupState = setupResult;
|
|
931
1078
|
instance.setupState = proxyRefs(setupResult);
|
|
932
1079
|
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
1080
|
}
|
|
940
1081
|
} else {
|
|
941
1082
|
if (!setupFn && component.render) {
|
|
@@ -948,24 +1089,31 @@ function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext
|
|
|
948
1089
|
instance.block = setupResult;
|
|
949
1090
|
}
|
|
950
1091
|
}
|
|
951
|
-
if (instance.hasFallthrough && component.inheritAttrs !== false &&
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
1092
|
+
if (instance.hasFallthrough && component.inheritAttrs !== false && Object.keys(instance.attrs).length) {
|
|
1093
|
+
const el = getRootElement(instance);
|
|
1094
|
+
if (el) {
|
|
1095
|
+
renderEffect(() => {
|
|
1096
|
+
isApplyingFallthroughProps = true;
|
|
1097
|
+
setDynamicProps(el, [instance.attrs]);
|
|
1098
|
+
isApplyingFallthroughProps = false;
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
957
1101
|
}
|
|
958
|
-
|
|
959
|
-
|
|
1102
|
+
setActiveSub(prevSub);
|
|
1103
|
+
setCurrentInstance(...prevInstance);
|
|
960
1104
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
961
1105
|
popWarningContext();
|
|
962
1106
|
endMeasure(instance, "init");
|
|
963
1107
|
}
|
|
1108
|
+
onScopeDispose(() => unmountComponent(instance), true);
|
|
1109
|
+
if (!isHydrating && _insertionParent) {
|
|
1110
|
+
mountComponent(instance, _insertionParent, _insertionAnchor);
|
|
1111
|
+
}
|
|
964
1112
|
return instance;
|
|
965
1113
|
}
|
|
966
1114
|
let isApplyingFallthroughProps = false;
|
|
967
1115
|
function devRender(instance) {
|
|
968
|
-
instance.block = callWithErrorHandling(
|
|
1116
|
+
instance.block = (instance.type.render ? callWithErrorHandling(
|
|
969
1117
|
instance.type.render,
|
|
970
1118
|
instance,
|
|
971
1119
|
1,
|
|
@@ -976,7 +1124,20 @@ function devRender(instance) {
|
|
|
976
1124
|
instance.attrs,
|
|
977
1125
|
instance.slots
|
|
978
1126
|
]
|
|
979
|
-
)
|
|
1127
|
+
) : callWithErrorHandling(
|
|
1128
|
+
isFunction(instance.type) ? instance.type : instance.type.setup,
|
|
1129
|
+
instance,
|
|
1130
|
+
0,
|
|
1131
|
+
[
|
|
1132
|
+
instance.props,
|
|
1133
|
+
{
|
|
1134
|
+
slots: instance.slots,
|
|
1135
|
+
attrs: instance.attrs,
|
|
1136
|
+
emit: instance.emit,
|
|
1137
|
+
expose: instance.expose
|
|
1138
|
+
}
|
|
1139
|
+
]
|
|
1140
|
+
)) || [];
|
|
980
1141
|
}
|
|
981
1142
|
const emptyContext = {
|
|
982
1143
|
app: null,
|
|
@@ -988,15 +1149,12 @@ class VaporComponentInstance {
|
|
|
988
1149
|
this.vapor = true;
|
|
989
1150
|
this.uid = nextUid();
|
|
990
1151
|
this.type = comp;
|
|
991
|
-
this.parent = currentInstance
|
|
992
|
-
this.
|
|
993
|
-
if (currentInstance
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this.appContext = currentInstance$1.appContext;
|
|
998
|
-
this.provides = currentInstance$1.provides;
|
|
999
|
-
this.ids = currentInstance$1.ids;
|
|
1152
|
+
this.parent = currentInstance;
|
|
1153
|
+
this.root = currentInstance ? currentInstance.root : this;
|
|
1154
|
+
if (currentInstance) {
|
|
1155
|
+
this.appContext = currentInstance.appContext;
|
|
1156
|
+
this.provides = currentInstance.provides;
|
|
1157
|
+
this.ids = currentInstance.ids;
|
|
1000
1158
|
} else {
|
|
1001
1159
|
this.appContext = appContext || emptyContext;
|
|
1002
1160
|
this.provides = Object.create(this.appContext.provides);
|
|
@@ -1020,10 +1178,6 @@ class VaporComponentInstance {
|
|
|
1020
1178
|
}
|
|
1021
1179
|
this.rawSlots = rawSlots || EMPTY_OBJ;
|
|
1022
1180
|
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
1181
|
}
|
|
1028
1182
|
/**
|
|
1029
1183
|
* Expose `getKeysFromRawProps` on the instance so it can be used in code
|
|
@@ -1040,6 +1194,13 @@ function createComponentWithFallback(comp, rawProps, rawSlots, isSingleRoot) {
|
|
|
1040
1194
|
if (!isString(comp)) {
|
|
1041
1195
|
return createComponent(comp, rawProps, rawSlots, isSingleRoot);
|
|
1042
1196
|
}
|
|
1197
|
+
const _insertionParent = insertionParent;
|
|
1198
|
+
const _insertionAnchor = insertionAnchor;
|
|
1199
|
+
if (isHydrating) {
|
|
1200
|
+
locateHydrationNode();
|
|
1201
|
+
} else {
|
|
1202
|
+
resetInsertionState();
|
|
1203
|
+
}
|
|
1043
1204
|
const el = document.createElement(comp);
|
|
1044
1205
|
el.$root = isSingleRoot;
|
|
1045
1206
|
if (rawProps) {
|
|
@@ -1052,20 +1213,19 @@ function createComponentWithFallback(comp, rawProps, rawSlots, isSingleRoot) {
|
|
|
1052
1213
|
insert(getSlot(rawSlots, "default")(), el);
|
|
1053
1214
|
}
|
|
1054
1215
|
}
|
|
1216
|
+
if (!isHydrating && _insertionParent) {
|
|
1217
|
+
insert(el, _insertionParent, _insertionAnchor);
|
|
1218
|
+
}
|
|
1055
1219
|
return el;
|
|
1056
1220
|
}
|
|
1057
1221
|
function mountComponent(instance, parent, anchor) {
|
|
1058
1222
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1059
1223
|
startMeasure(instance, `mount`);
|
|
1060
1224
|
}
|
|
1061
|
-
if (
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
instance.isMounted = true;
|
|
1066
|
-
} else {
|
|
1067
|
-
insert(instance.block, parent, anchor);
|
|
1068
|
-
}
|
|
1225
|
+
if (instance.bm) invokeArrayFns(instance.bm);
|
|
1226
|
+
insert(instance.block, parent, anchor);
|
|
1227
|
+
if (instance.m) queuePostFlushCb(() => invokeArrayFns(instance.m));
|
|
1228
|
+
instance.isMounted = true;
|
|
1069
1229
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1070
1230
|
endMeasure(instance, `mount`);
|
|
1071
1231
|
}
|
|
@@ -1079,27 +1239,12 @@ function unmountComponent(instance, parentNode) {
|
|
|
1079
1239
|
invokeArrayFns(instance.bum);
|
|
1080
1240
|
}
|
|
1081
1241
|
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
1242
|
if (instance.um) {
|
|
1099
1243
|
queuePostFlushCb(() => invokeArrayFns(instance.um));
|
|
1100
1244
|
}
|
|
1101
1245
|
instance.isUnmounted = true;
|
|
1102
|
-
}
|
|
1246
|
+
}
|
|
1247
|
+
if (parentNode) {
|
|
1103
1248
|
remove(instance.block, parentNode);
|
|
1104
1249
|
}
|
|
1105
1250
|
}
|
|
@@ -1110,10 +1255,27 @@ function getExposed(instance) {
|
|
|
1110
1255
|
}));
|
|
1111
1256
|
}
|
|
1112
1257
|
}
|
|
1258
|
+
function getRootElement({
|
|
1259
|
+
block
|
|
1260
|
+
}) {
|
|
1261
|
+
if (block instanceof Element) {
|
|
1262
|
+
return block;
|
|
1263
|
+
}
|
|
1264
|
+
if (block instanceof DynamicFragment) {
|
|
1265
|
+
const { nodes } = block;
|
|
1266
|
+
if (nodes instanceof Element && nodes.$root) {
|
|
1267
|
+
return nodes;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1113
1271
|
|
|
1114
1272
|
let _createApp;
|
|
1115
1273
|
const mountApp = (app, container) => {
|
|
1274
|
+
optimizePropertyLookup();
|
|
1116
1275
|
if (container.nodeType === 1) {
|
|
1276
|
+
if (!!(process.env.NODE_ENV !== "production") && container.childNodes.length) {
|
|
1277
|
+
warn("mount target container is not empty and will be cleared.");
|
|
1278
|
+
}
|
|
1117
1279
|
container.textContent = "";
|
|
1118
1280
|
}
|
|
1119
1281
|
const instance = createComponent(
|
|
@@ -1127,10 +1289,27 @@ const mountApp = (app, container) => {
|
|
|
1127
1289
|
flushOnAppMount();
|
|
1128
1290
|
return instance;
|
|
1129
1291
|
};
|
|
1292
|
+
let _hydrateApp;
|
|
1293
|
+
const hydrateApp = (app, container) => {
|
|
1294
|
+
optimizePropertyLookup();
|
|
1295
|
+
let instance;
|
|
1296
|
+
withHydration(container, () => {
|
|
1297
|
+
instance = createComponent(
|
|
1298
|
+
app._component,
|
|
1299
|
+
app._props,
|
|
1300
|
+
null,
|
|
1301
|
+
false,
|
|
1302
|
+
app._context
|
|
1303
|
+
);
|
|
1304
|
+
mountComponent(instance, container);
|
|
1305
|
+
flushOnAppMount();
|
|
1306
|
+
});
|
|
1307
|
+
return instance;
|
|
1308
|
+
};
|
|
1130
1309
|
const unmountApp = (app) => {
|
|
1131
1310
|
unmountComponent(app._instance, app._container);
|
|
1132
1311
|
};
|
|
1133
|
-
|
|
1312
|
+
function prepareApp() {
|
|
1134
1313
|
{
|
|
1135
1314
|
initFeatureFlags();
|
|
1136
1315
|
}
|
|
@@ -1139,8 +1318,8 @@ const createVaporApp = (comp, props) => {
|
|
|
1139
1318
|
if (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_DEVTOOLS__) {
|
|
1140
1319
|
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
|
|
1141
1320
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1321
|
+
}
|
|
1322
|
+
function postPrepareApp(app) {
|
|
1144
1323
|
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1145
1324
|
app.config.globalProperties = new Proxy(
|
|
1146
1325
|
{},
|
|
@@ -1152,64 +1331,296 @@ const createVaporApp = (comp, props) => {
|
|
|
1152
1331
|
}
|
|
1153
1332
|
);
|
|
1154
1333
|
}
|
|
1334
|
+
app.vapor = true;
|
|
1155
1335
|
const mount = app.mount;
|
|
1156
1336
|
app.mount = (container, ...args) => {
|
|
1157
1337
|
container = normalizeContainer(container);
|
|
1158
1338
|
return mount(container, ...args);
|
|
1159
1339
|
};
|
|
1340
|
+
}
|
|
1341
|
+
const createVaporApp = (comp, props) => {
|
|
1342
|
+
prepareApp();
|
|
1343
|
+
if (!_createApp) _createApp = createAppAPI(mountApp, unmountApp, getExposed);
|
|
1344
|
+
const app = _createApp(comp, props);
|
|
1345
|
+
postPrepareApp(app);
|
|
1346
|
+
return app;
|
|
1347
|
+
};
|
|
1348
|
+
const createVaporSSRApp = (comp, props) => {
|
|
1349
|
+
prepareApp();
|
|
1350
|
+
if (!_hydrateApp)
|
|
1351
|
+
_hydrateApp = createAppAPI(hydrateApp, unmountApp, getExposed);
|
|
1352
|
+
const app = _hydrateApp(comp, props);
|
|
1353
|
+
postPrepareApp(app);
|
|
1160
1354
|
return app;
|
|
1161
1355
|
};
|
|
1162
1356
|
|
|
1163
1357
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
1164
1358
|
// @__NO_SIDE_EFFECTS__
|
|
1165
|
-
function defineVaporComponent(comp) {
|
|
1359
|
+
function defineVaporComponent(comp, extraOptions) {
|
|
1360
|
+
if (isFunction(comp)) {
|
|
1361
|
+
return /* @__PURE__ */ (() => extend({ name: comp.name }, extraOptions, {
|
|
1362
|
+
setup: comp,
|
|
1363
|
+
__vapor: true
|
|
1364
|
+
}))();
|
|
1365
|
+
}
|
|
1166
1366
|
comp.__vapor = true;
|
|
1167
1367
|
return comp;
|
|
1168
1368
|
}
|
|
1169
1369
|
|
|
1370
|
+
const vaporInteropImpl = {
|
|
1371
|
+
mount(vnode, container, anchor, parentComponent) {
|
|
1372
|
+
const selfAnchor = vnode.el = vnode.anchor = createTextNode();
|
|
1373
|
+
container.insertBefore(selfAnchor, anchor);
|
|
1374
|
+
const prev = currentInstance;
|
|
1375
|
+
simpleSetCurrentInstance(parentComponent);
|
|
1376
|
+
const propsRef = shallowRef(vnode.props);
|
|
1377
|
+
const slotsRef = shallowRef(vnode.children);
|
|
1378
|
+
const instance = vnode.component = createComponent(
|
|
1379
|
+
vnode.type,
|
|
1380
|
+
{
|
|
1381
|
+
$: [() => propsRef.value]
|
|
1382
|
+
},
|
|
1383
|
+
{
|
|
1384
|
+
_: slotsRef
|
|
1385
|
+
// pass the slots ref
|
|
1386
|
+
}
|
|
1387
|
+
);
|
|
1388
|
+
instance.rawPropsRef = propsRef;
|
|
1389
|
+
instance.rawSlotsRef = slotsRef;
|
|
1390
|
+
mountComponent(instance, container, selfAnchor);
|
|
1391
|
+
simpleSetCurrentInstance(prev);
|
|
1392
|
+
return instance;
|
|
1393
|
+
},
|
|
1394
|
+
update(n1, n2, shouldUpdate) {
|
|
1395
|
+
n2.component = n1.component;
|
|
1396
|
+
n2.el = n2.anchor = n1.anchor;
|
|
1397
|
+
if (shouldUpdate) {
|
|
1398
|
+
const instance = n2.component;
|
|
1399
|
+
instance.rawPropsRef.value = n2.props;
|
|
1400
|
+
instance.rawSlotsRef.value = n2.children;
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
unmount(vnode, doRemove) {
|
|
1404
|
+
const container = doRemove ? vnode.anchor.parentNode : void 0;
|
|
1405
|
+
if (vnode.component) {
|
|
1406
|
+
unmountComponent(vnode.component, container);
|
|
1407
|
+
} else if (vnode.vb) {
|
|
1408
|
+
remove(vnode.vb, container);
|
|
1409
|
+
}
|
|
1410
|
+
remove(vnode.anchor, container);
|
|
1411
|
+
},
|
|
1412
|
+
/**
|
|
1413
|
+
* vapor slot in vdom
|
|
1414
|
+
*/
|
|
1415
|
+
slot(n1, n2, container, anchor) {
|
|
1416
|
+
if (!n1) {
|
|
1417
|
+
const selfAnchor = n2.el = n2.anchor = createTextNode();
|
|
1418
|
+
insert(selfAnchor, container, anchor);
|
|
1419
|
+
const { slot, fallback } = n2.vs;
|
|
1420
|
+
const propsRef = n2.vs.ref = shallowRef(n2.props);
|
|
1421
|
+
const slotBlock = slot(new Proxy(propsRef, vaporSlotPropsProxyHandler));
|
|
1422
|
+
insert(n2.vb = slotBlock, container, selfAnchor);
|
|
1423
|
+
} else {
|
|
1424
|
+
n2.el = n2.anchor = n1.anchor;
|
|
1425
|
+
n2.vb = n1.vb;
|
|
1426
|
+
(n2.vs.ref = n1.vs.ref).value = n2.props;
|
|
1427
|
+
}
|
|
1428
|
+
},
|
|
1429
|
+
move(vnode, container, anchor) {
|
|
1430
|
+
insert(vnode.vb || vnode.component, container, anchor);
|
|
1431
|
+
insert(vnode.anchor, container, anchor);
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
const vaporSlotPropsProxyHandler = {
|
|
1435
|
+
get(target, key) {
|
|
1436
|
+
return target.value[key];
|
|
1437
|
+
},
|
|
1438
|
+
has(target, key) {
|
|
1439
|
+
return target.value[key];
|
|
1440
|
+
},
|
|
1441
|
+
ownKeys(target) {
|
|
1442
|
+
return Object.keys(target.value);
|
|
1443
|
+
}
|
|
1444
|
+
};
|
|
1445
|
+
const vaporSlotsProxyHandler = {
|
|
1446
|
+
get(target, key) {
|
|
1447
|
+
const slot = target[key];
|
|
1448
|
+
if (isFunction(slot)) {
|
|
1449
|
+
slot.__vapor = true;
|
|
1450
|
+
}
|
|
1451
|
+
return slot;
|
|
1452
|
+
}
|
|
1453
|
+
};
|
|
1454
|
+
function createVDOMComponent(internals, component, rawProps, rawSlots) {
|
|
1455
|
+
const frag = new VaporFragment([]);
|
|
1456
|
+
const vnode = createVNode(
|
|
1457
|
+
component,
|
|
1458
|
+
rawProps && new Proxy(rawProps, rawPropsProxyHandlers)
|
|
1459
|
+
);
|
|
1460
|
+
const wrapper = new VaporComponentInstance(
|
|
1461
|
+
{ props: component.props },
|
|
1462
|
+
rawProps,
|
|
1463
|
+
rawSlots
|
|
1464
|
+
);
|
|
1465
|
+
vnode.vi = (instance) => {
|
|
1466
|
+
instance.props = shallowReactive(wrapper.props);
|
|
1467
|
+
const attrs = instance.attrs = createInternalObject();
|
|
1468
|
+
for (const key in wrapper.attrs) {
|
|
1469
|
+
if (!isEmitListener(instance.emitsOptions, key)) {
|
|
1470
|
+
attrs[key] = wrapper.attrs[key];
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
instance.slots = wrapper.slots === EMPTY_OBJ ? EMPTY_OBJ : new Proxy(wrapper.slots, vaporSlotsProxyHandler);
|
|
1474
|
+
};
|
|
1475
|
+
let isMounted = false;
|
|
1476
|
+
const parentInstance = currentInstance;
|
|
1477
|
+
const unmount = (parentNode) => {
|
|
1478
|
+
internals.umt(vnode.component, null, !!parentNode);
|
|
1479
|
+
};
|
|
1480
|
+
frag.insert = (parentNode, anchor) => {
|
|
1481
|
+
if (!isMounted) {
|
|
1482
|
+
internals.mt(
|
|
1483
|
+
vnode,
|
|
1484
|
+
parentNode,
|
|
1485
|
+
anchor,
|
|
1486
|
+
parentInstance,
|
|
1487
|
+
null,
|
|
1488
|
+
void 0,
|
|
1489
|
+
false
|
|
1490
|
+
);
|
|
1491
|
+
onScopeDispose$1(unmount, true);
|
|
1492
|
+
isMounted = true;
|
|
1493
|
+
} else {
|
|
1494
|
+
internals.m(
|
|
1495
|
+
vnode,
|
|
1496
|
+
parentNode,
|
|
1497
|
+
anchor,
|
|
1498
|
+
2,
|
|
1499
|
+
parentInstance
|
|
1500
|
+
);
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
frag.remove = unmount;
|
|
1504
|
+
return frag;
|
|
1505
|
+
}
|
|
1506
|
+
function renderVDOMSlot(internals, slotsRef, name, props, parentComponent, fallback) {
|
|
1507
|
+
const frag = new VaporFragment([]);
|
|
1508
|
+
let isMounted = false;
|
|
1509
|
+
let fallbackNodes;
|
|
1510
|
+
let oldVNode = null;
|
|
1511
|
+
frag.insert = (parentNode, anchor) => {
|
|
1512
|
+
if (!isMounted) {
|
|
1513
|
+
renderEffect(() => {
|
|
1514
|
+
const vnode = renderSlot(
|
|
1515
|
+
slotsRef.value,
|
|
1516
|
+
isFunction(name) ? name() : name,
|
|
1517
|
+
props
|
|
1518
|
+
);
|
|
1519
|
+
if (vnode.children.length) {
|
|
1520
|
+
if (fallbackNodes) {
|
|
1521
|
+
remove(fallbackNodes, parentNode);
|
|
1522
|
+
fallbackNodes = void 0;
|
|
1523
|
+
}
|
|
1524
|
+
internals.p(
|
|
1525
|
+
oldVNode,
|
|
1526
|
+
vnode,
|
|
1527
|
+
parentNode,
|
|
1528
|
+
anchor,
|
|
1529
|
+
parentComponent
|
|
1530
|
+
);
|
|
1531
|
+
oldVNode = vnode;
|
|
1532
|
+
} else {
|
|
1533
|
+
if (fallback && !fallbackNodes) {
|
|
1534
|
+
if (oldVNode) {
|
|
1535
|
+
internals.um(oldVNode, parentComponent, null, true);
|
|
1536
|
+
}
|
|
1537
|
+
insert(fallbackNodes = fallback(props), parentNode, anchor);
|
|
1538
|
+
}
|
|
1539
|
+
oldVNode = null;
|
|
1540
|
+
}
|
|
1541
|
+
});
|
|
1542
|
+
isMounted = true;
|
|
1543
|
+
} else {
|
|
1544
|
+
internals.m(
|
|
1545
|
+
oldVNode,
|
|
1546
|
+
parentNode,
|
|
1547
|
+
anchor,
|
|
1548
|
+
2,
|
|
1549
|
+
parentComponent
|
|
1550
|
+
);
|
|
1551
|
+
}
|
|
1552
|
+
frag.remove = (parentNode2) => {
|
|
1553
|
+
if (fallbackNodes) {
|
|
1554
|
+
remove(fallbackNodes, parentNode2);
|
|
1555
|
+
} else if (oldVNode) {
|
|
1556
|
+
internals.um(oldVNode, parentComponent, null);
|
|
1557
|
+
}
|
|
1558
|
+
};
|
|
1559
|
+
};
|
|
1560
|
+
return frag;
|
|
1561
|
+
}
|
|
1562
|
+
const vaporInteropPlugin = (app) => {
|
|
1563
|
+
const internals = ensureRenderer().internals;
|
|
1564
|
+
app._context.vapor = extend(vaporInteropImpl, {
|
|
1565
|
+
vdomMount: createVDOMComponent.bind(null, internals),
|
|
1566
|
+
vdomUnmount: internals.umt,
|
|
1567
|
+
vdomSlot: renderVDOMSlot.bind(null, internals)
|
|
1568
|
+
});
|
|
1569
|
+
const mount = app.mount;
|
|
1570
|
+
app.mount = (...args) => {
|
|
1571
|
+
optimizePropertyLookup();
|
|
1572
|
+
return mount(...args);
|
|
1573
|
+
};
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
let t;
|
|
1170
1577
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
1171
1578
|
// @__NO_SIDE_EFFECTS__
|
|
1172
1579
|
function template(html, root) {
|
|
1173
1580
|
let node;
|
|
1174
|
-
const create = () => {
|
|
1175
|
-
const t = document.createElement("template");
|
|
1176
|
-
t.innerHTML = html;
|
|
1177
|
-
return t.content.firstChild;
|
|
1178
|
-
};
|
|
1179
1581
|
return () => {
|
|
1180
|
-
|
|
1582
|
+
if (isHydrating) {
|
|
1583
|
+
if (!!(process.env.NODE_ENV !== "production") && !currentHydrationNode) {
|
|
1584
|
+
throw new Error("No current hydration node");
|
|
1585
|
+
}
|
|
1586
|
+
return adoptTemplate(currentHydrationNode, html);
|
|
1587
|
+
}
|
|
1588
|
+
if (html[0] !== "<") {
|
|
1589
|
+
return createTextNode(html);
|
|
1590
|
+
}
|
|
1591
|
+
if (!node) {
|
|
1592
|
+
t = t || document.createElement("template");
|
|
1593
|
+
t.innerHTML = html;
|
|
1594
|
+
node = child(t.content);
|
|
1595
|
+
}
|
|
1596
|
+
const ret = node.cloneNode(true);
|
|
1181
1597
|
if (root) ret.$root = true;
|
|
1182
1598
|
return ret;
|
|
1183
1599
|
};
|
|
1184
1600
|
}
|
|
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
1601
|
|
|
1202
1602
|
function createIf(condition, b1, b2, once) {
|
|
1203
|
-
const
|
|
1603
|
+
const _insertionParent = insertionParent;
|
|
1604
|
+
const _insertionAnchor = insertionAnchor;
|
|
1605
|
+
if (isHydrating) {
|
|
1606
|
+
locateHydrationNode();
|
|
1607
|
+
} else {
|
|
1608
|
+
resetInsertionState();
|
|
1609
|
+
}
|
|
1610
|
+
let frag;
|
|
1204
1611
|
if (once) {
|
|
1205
|
-
frag
|
|
1612
|
+
frag = condition() ? b1() : b2 ? b2() : [];
|
|
1206
1613
|
} else {
|
|
1614
|
+
frag = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("if") : new DynamicFragment();
|
|
1207
1615
|
renderEffect(() => frag.update(condition() ? b1 : b2));
|
|
1208
1616
|
}
|
|
1617
|
+
if (!isHydrating && _insertionParent) {
|
|
1618
|
+
insert(frag, _insertionParent, _insertionAnchor);
|
|
1619
|
+
}
|
|
1209
1620
|
return frag;
|
|
1210
1621
|
}
|
|
1211
1622
|
|
|
1212
|
-
class ForBlock extends
|
|
1623
|
+
class ForBlock extends VaporFragment {
|
|
1213
1624
|
constructor(nodes, scope, item, key, index, renderKey) {
|
|
1214
1625
|
super(nodes);
|
|
1215
1626
|
this.scope = scope;
|
|
@@ -1219,15 +1630,25 @@ class ForBlock extends Fragment {
|
|
|
1219
1630
|
this.key = renderKey;
|
|
1220
1631
|
}
|
|
1221
1632
|
}
|
|
1222
|
-
|
|
1223
|
-
const
|
|
1633
|
+
const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
1634
|
+
const _insertionParent = insertionParent;
|
|
1635
|
+
const _insertionAnchor = insertionAnchor;
|
|
1636
|
+
if (isHydrating) {
|
|
1637
|
+
locateHydrationNode();
|
|
1638
|
+
} else {
|
|
1639
|
+
resetInsertionState();
|
|
1640
|
+
}
|
|
1224
1641
|
let isMounted = false;
|
|
1225
1642
|
let oldBlocks = [];
|
|
1226
1643
|
let newBlocks;
|
|
1227
1644
|
let parent;
|
|
1645
|
+
let currentKey;
|
|
1228
1646
|
const parentAnchor = !!(process.env.NODE_ENV !== "production") ? createComment("for") : createTextNode();
|
|
1229
|
-
const
|
|
1230
|
-
const instance = currentInstance
|
|
1647
|
+
const frag = new VaporFragment(oldBlocks);
|
|
1648
|
+
const instance = currentInstance;
|
|
1649
|
+
const canUseFastRemove = !!(flags & 1);
|
|
1650
|
+
const isComponent = !!(flags & 2);
|
|
1651
|
+
const selectors = [];
|
|
1231
1652
|
if (!!(process.env.NODE_ENV !== "production") && !instance) {
|
|
1232
1653
|
warn("createFor() can only be used inside setup()");
|
|
1233
1654
|
}
|
|
@@ -1236,6 +1657,7 @@ const createFor = /* @__NO_SIDE_EFFECTS__ */ (src, renderItem, getKey, isCompone
|
|
|
1236
1657
|
const newLength = source.values.length;
|
|
1237
1658
|
const oldLength = oldBlocks.length;
|
|
1238
1659
|
newBlocks = new Array(newLength);
|
|
1660
|
+
const prevSub = setActiveSub();
|
|
1239
1661
|
if (!isMounted) {
|
|
1240
1662
|
isMounted = true;
|
|
1241
1663
|
for (let i = 0; i < newLength; i++) {
|
|
@@ -1248,8 +1670,16 @@ const createFor = /* @__NO_SIDE_EFFECTS__ */ (src, renderItem, getKey, isCompone
|
|
|
1248
1670
|
mount(source, i);
|
|
1249
1671
|
}
|
|
1250
1672
|
} else if (!newLength) {
|
|
1673
|
+
for (const selector of selectors) {
|
|
1674
|
+
selector.cleanup();
|
|
1675
|
+
}
|
|
1676
|
+
const doRemove = !canUseFastRemove;
|
|
1251
1677
|
for (let i = 0; i < oldLength; i++) {
|
|
1252
|
-
unmount(oldBlocks[i]);
|
|
1678
|
+
unmount(oldBlocks[i], doRemove, false);
|
|
1679
|
+
}
|
|
1680
|
+
if (canUseFastRemove) {
|
|
1681
|
+
parent.textContent = "";
|
|
1682
|
+
parent.appendChild(parentAnchor);
|
|
1253
1683
|
}
|
|
1254
1684
|
} else if (!getKey) {
|
|
1255
1685
|
const commonLength = Math.min(newLength, oldLength);
|
|
@@ -1263,104 +1693,157 @@ const createFor = /* @__NO_SIDE_EFFECTS__ */ (src, renderItem, getKey, isCompone
|
|
|
1263
1693
|
unmount(oldBlocks[i]);
|
|
1264
1694
|
}
|
|
1265
1695
|
} else {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1696
|
+
const sharedBlockCount = Math.min(oldLength, newLength);
|
|
1697
|
+
const previousKeyIndexPairs = new Array(oldLength);
|
|
1698
|
+
const queuedBlocks = new Array(newLength);
|
|
1699
|
+
let anchorFallback = parentAnchor;
|
|
1700
|
+
let endOffset = 0;
|
|
1701
|
+
let startOffset = 0;
|
|
1702
|
+
let queuedBlocksInsertIndex = 0;
|
|
1703
|
+
let previousKeyIndexInsertIndex = 0;
|
|
1704
|
+
while (endOffset < sharedBlockCount) {
|
|
1705
|
+
const currentIndex = newLength - endOffset - 1;
|
|
1706
|
+
const currentItem = getItem(source, currentIndex);
|
|
1707
|
+
const currentKey2 = getKey(...currentItem);
|
|
1708
|
+
const existingBlock = oldBlocks[oldLength - endOffset - 1];
|
|
1709
|
+
if (existingBlock.key === currentKey2) {
|
|
1710
|
+
update(existingBlock, ...currentItem);
|
|
1711
|
+
newBlocks[currentIndex] = existingBlock;
|
|
1712
|
+
endOffset++;
|
|
1713
|
+
continue;
|
|
1274
1714
|
}
|
|
1715
|
+
if (endOffset !== 0) {
|
|
1716
|
+
anchorFallback = normalizeAnchor(newBlocks[currentIndex + 1].nodes);
|
|
1717
|
+
}
|
|
1718
|
+
break;
|
|
1275
1719
|
}
|
|
1276
|
-
while (
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1720
|
+
while (startOffset < sharedBlockCount - endOffset) {
|
|
1721
|
+
const currentItem = getItem(source, startOffset);
|
|
1722
|
+
const currentKey2 = getKey(...currentItem);
|
|
1723
|
+
const previousBlock = oldBlocks[startOffset];
|
|
1724
|
+
const previousKey = previousBlock.key;
|
|
1725
|
+
if (previousKey === currentKey2) {
|
|
1726
|
+
update(newBlocks[startOffset] = previousBlock, currentItem[0]);
|
|
1280
1727
|
} else {
|
|
1281
|
-
|
|
1728
|
+
queuedBlocks[queuedBlocksInsertIndex++] = [
|
|
1729
|
+
startOffset,
|
|
1730
|
+
currentItem,
|
|
1731
|
+
currentKey2
|
|
1732
|
+
];
|
|
1733
|
+
previousKeyIndexPairs[previousKeyIndexInsertIndex++] = [
|
|
1734
|
+
previousKey,
|
|
1735
|
+
startOffset
|
|
1736
|
+
];
|
|
1282
1737
|
}
|
|
1738
|
+
startOffset++;
|
|
1283
1739
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1740
|
+
for (let i = startOffset; i < oldLength - endOffset; i++) {
|
|
1741
|
+
previousKeyIndexPairs[previousKeyIndexInsertIndex++] = [
|
|
1742
|
+
oldBlocks[i].key,
|
|
1743
|
+
i
|
|
1744
|
+
];
|
|
1745
|
+
}
|
|
1746
|
+
const preparationBlockCount = Math.min(
|
|
1747
|
+
newLength - endOffset,
|
|
1748
|
+
sharedBlockCount
|
|
1749
|
+
);
|
|
1750
|
+
for (let i = startOffset; i < preparationBlockCount; i++) {
|
|
1751
|
+
const blockItem = getItem(source, i);
|
|
1752
|
+
const blockKey = getKey(...blockItem);
|
|
1753
|
+
queuedBlocks[queuedBlocksInsertIndex++] = [i, blockItem, blockKey];
|
|
1754
|
+
}
|
|
1755
|
+
if (!queuedBlocksInsertIndex && !previousKeyIndexInsertIndex) {
|
|
1756
|
+
for (let i = preparationBlockCount; i < newLength - endOffset; i++) {
|
|
1757
|
+
const blockItem = getItem(source, i);
|
|
1758
|
+
const blockKey = getKey(...blockItem);
|
|
1759
|
+
mount(source, i, anchorFallback, blockItem, blockKey);
|
|
1297
1760
|
}
|
|
1298
1761
|
} else {
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
unmount(prevBlock);
|
|
1762
|
+
queuedBlocks.length = queuedBlocksInsertIndex;
|
|
1763
|
+
previousKeyIndexPairs.length = previousKeyIndexInsertIndex;
|
|
1764
|
+
const previousKeyIndexMap = new Map(previousKeyIndexPairs);
|
|
1765
|
+
const blocksToMount = [];
|
|
1766
|
+
const relocateOrMountBlock = (blockIndex, blockItem, blockKey, anchorOffset) => {
|
|
1767
|
+
const previousIndex = previousKeyIndexMap.get(blockKey);
|
|
1768
|
+
if (previousIndex !== void 0) {
|
|
1769
|
+
const reusedBlock = newBlocks[blockIndex] = oldBlocks[previousIndex];
|
|
1770
|
+
update(reusedBlock, ...blockItem);
|
|
1771
|
+
insert(
|
|
1772
|
+
reusedBlock,
|
|
1773
|
+
parent,
|
|
1774
|
+
anchorOffset === -1 ? anchorFallback : normalizeAnchor(newBlocks[anchorOffset].nodes)
|
|
1775
|
+
);
|
|
1776
|
+
previousKeyIndexMap.delete(blockKey);
|
|
1315
1777
|
} else {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
maxNewIndexSoFar = newIndex;
|
|
1323
|
-
} else {
|
|
1324
|
-
moved = true;
|
|
1325
|
-
}
|
|
1326
|
-
update(
|
|
1327
|
-
newBlocks[newIndex] = prevBlock,
|
|
1328
|
-
...getItem(source, newIndex)
|
|
1329
|
-
);
|
|
1330
|
-
patched++;
|
|
1331
|
-
}
|
|
1778
|
+
blocksToMount.push([
|
|
1779
|
+
blockIndex,
|
|
1780
|
+
blockItem,
|
|
1781
|
+
blockKey,
|
|
1782
|
+
anchorOffset
|
|
1783
|
+
]);
|
|
1332
1784
|
}
|
|
1785
|
+
};
|
|
1786
|
+
for (let i = queuedBlocks.length - 1; i >= 0; i--) {
|
|
1787
|
+
const [blockIndex, blockItem, blockKey] = queuedBlocks[i];
|
|
1788
|
+
relocateOrMountBlock(
|
|
1789
|
+
blockIndex,
|
|
1790
|
+
blockItem,
|
|
1791
|
+
blockKey,
|
|
1792
|
+
blockIndex < preparationBlockCount - 1 ? blockIndex + 1 : -1
|
|
1793
|
+
);
|
|
1333
1794
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1795
|
+
for (let i = preparationBlockCount; i < newLength - endOffset; i++) {
|
|
1796
|
+
const blockItem = getItem(source, i);
|
|
1797
|
+
const blockKey = getKey(...blockItem);
|
|
1798
|
+
relocateOrMountBlock(i, blockItem, blockKey, -1);
|
|
1799
|
+
}
|
|
1800
|
+
const useFastRemove = blocksToMount.length === newLength;
|
|
1801
|
+
for (const leftoverIndex of previousKeyIndexMap.values()) {
|
|
1802
|
+
unmount(
|
|
1803
|
+
oldBlocks[leftoverIndex],
|
|
1804
|
+
!(useFastRemove && canUseFastRemove),
|
|
1805
|
+
!useFastRemove
|
|
1806
|
+
);
|
|
1807
|
+
}
|
|
1808
|
+
if (useFastRemove) {
|
|
1809
|
+
for (const selector of selectors) {
|
|
1810
|
+
selector.cleanup();
|
|
1811
|
+
}
|
|
1812
|
+
if (canUseFastRemove) {
|
|
1813
|
+
parent.textContent = "";
|
|
1814
|
+
parent.appendChild(parentAnchor);
|
|
1347
1815
|
}
|
|
1348
1816
|
}
|
|
1817
|
+
for (const [
|
|
1818
|
+
blockIndex,
|
|
1819
|
+
blockItem,
|
|
1820
|
+
blockKey,
|
|
1821
|
+
anchorOffset
|
|
1822
|
+
] of blocksToMount) {
|
|
1823
|
+
mount(
|
|
1824
|
+
source,
|
|
1825
|
+
blockIndex,
|
|
1826
|
+
anchorOffset === -1 ? anchorFallback : normalizeAnchor(newBlocks[anchorOffset].nodes),
|
|
1827
|
+
blockItem,
|
|
1828
|
+
blockKey
|
|
1829
|
+
);
|
|
1830
|
+
}
|
|
1349
1831
|
}
|
|
1350
1832
|
}
|
|
1351
1833
|
}
|
|
1352
|
-
|
|
1834
|
+
frag.nodes = [oldBlocks = newBlocks];
|
|
1353
1835
|
if (parentAnchor) {
|
|
1354
|
-
|
|
1836
|
+
frag.nodes.push(parentAnchor);
|
|
1355
1837
|
}
|
|
1838
|
+
setActiveSub(prevSub);
|
|
1356
1839
|
};
|
|
1357
1840
|
const needKey = renderItem.length > 1;
|
|
1358
1841
|
const needIndex = renderItem.length > 2;
|
|
1359
|
-
const mount = (source, idx, anchor = parentAnchor) => {
|
|
1360
|
-
const
|
|
1361
|
-
const
|
|
1362
|
-
const
|
|
1363
|
-
|
|
1842
|
+
const mount = (source, idx, anchor = parentAnchor, [item, key, index] = getItem(source, idx), key2 = getKey && getKey(item, key, index)) => {
|
|
1843
|
+
const itemRef = shallowRef$1(item);
|
|
1844
|
+
const keyRef = needKey ? shallowRef$1(key) : void 0;
|
|
1845
|
+
const indexRef = needIndex ? shallowRef$1(index) : void 0;
|
|
1846
|
+
currentKey = key2;
|
|
1364
1847
|
let nodes;
|
|
1365
1848
|
let scope;
|
|
1366
1849
|
if (isComponent) {
|
|
@@ -1377,36 +1860,88 @@ const createFor = /* @__NO_SIDE_EFFECTS__ */ (src, renderItem, getKey, isCompone
|
|
|
1377
1860
|
itemRef,
|
|
1378
1861
|
keyRef,
|
|
1379
1862
|
indexRef,
|
|
1380
|
-
|
|
1863
|
+
key2
|
|
1381
1864
|
);
|
|
1382
1865
|
if (parent) insert(block.nodes, parent, anchor);
|
|
1383
1866
|
return block;
|
|
1384
1867
|
};
|
|
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
1868
|
const update = ({ itemRef, keyRef, indexRef }, newItem, newKey, newIndex) => {
|
|
1394
|
-
if (
|
|
1869
|
+
if (newItem !== itemRef.value) {
|
|
1395
1870
|
itemRef.value = newItem;
|
|
1396
1871
|
}
|
|
1397
|
-
if (keyRef && newKey !==
|
|
1872
|
+
if (keyRef && newKey !== void 0 && newKey !== keyRef.value) {
|
|
1398
1873
|
keyRef.value = newKey;
|
|
1399
1874
|
}
|
|
1400
|
-
if (indexRef && newIndex !==
|
|
1875
|
+
if (indexRef && newIndex !== void 0 && newIndex !== indexRef.value) {
|
|
1401
1876
|
indexRef.value = newIndex;
|
|
1402
1877
|
}
|
|
1403
1878
|
};
|
|
1404
|
-
const unmount = (
|
|
1405
|
-
|
|
1406
|
-
|
|
1879
|
+
const unmount = (block, doRemove = true, doDeregister = true) => {
|
|
1880
|
+
if (!isComponent) {
|
|
1881
|
+
block.scope.stop();
|
|
1882
|
+
}
|
|
1883
|
+
if (doRemove) {
|
|
1884
|
+
remove(block.nodes, parent);
|
|
1885
|
+
}
|
|
1886
|
+
if (doDeregister) {
|
|
1887
|
+
for (const selector of selectors) {
|
|
1888
|
+
selector.deregister(block.key);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1407
1891
|
};
|
|
1408
|
-
|
|
1409
|
-
|
|
1892
|
+
if (flags & 4) {
|
|
1893
|
+
renderList();
|
|
1894
|
+
} else {
|
|
1895
|
+
renderEffect(renderList);
|
|
1896
|
+
}
|
|
1897
|
+
if (!isHydrating && _insertionParent) {
|
|
1898
|
+
insert(frag, _insertionParent, _insertionAnchor);
|
|
1899
|
+
}
|
|
1900
|
+
frag.useSelector = useSelector;
|
|
1901
|
+
return frag;
|
|
1902
|
+
function useSelector(source) {
|
|
1903
|
+
let operMap = /* @__PURE__ */ new Map();
|
|
1904
|
+
let activeKey = source();
|
|
1905
|
+
let activeOpers;
|
|
1906
|
+
watch(source, (newValue) => {
|
|
1907
|
+
if (activeOpers !== void 0) {
|
|
1908
|
+
for (const oper of activeOpers) {
|
|
1909
|
+
oper();
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
activeOpers = operMap.get(newValue);
|
|
1913
|
+
if (activeOpers !== void 0) {
|
|
1914
|
+
for (const oper of activeOpers) {
|
|
1915
|
+
oper();
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
selectors.push({ deregister, cleanup });
|
|
1920
|
+
return register;
|
|
1921
|
+
function cleanup() {
|
|
1922
|
+
operMap = /* @__PURE__ */ new Map();
|
|
1923
|
+
activeOpers = void 0;
|
|
1924
|
+
}
|
|
1925
|
+
function register(oper) {
|
|
1926
|
+
oper();
|
|
1927
|
+
let opers = operMap.get(currentKey);
|
|
1928
|
+
if (opers !== void 0) {
|
|
1929
|
+
opers.push(oper);
|
|
1930
|
+
} else {
|
|
1931
|
+
opers = [oper];
|
|
1932
|
+
operMap.set(currentKey, opers);
|
|
1933
|
+
if (currentKey === activeKey) {
|
|
1934
|
+
activeOpers = opers;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
function deregister(key) {
|
|
1939
|
+
operMap.delete(key);
|
|
1940
|
+
if (key === activeKey) {
|
|
1941
|
+
activeOpers = void 0;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1410
1945
|
};
|
|
1411
1946
|
function createForSlots(rawSource, getSlot) {
|
|
1412
1947
|
const source = normalizeSource(rawSource);
|
|
@@ -1420,11 +1955,13 @@ function createForSlots(rawSource, getSlot) {
|
|
|
1420
1955
|
function normalizeSource(source) {
|
|
1421
1956
|
let values = source;
|
|
1422
1957
|
let needsWrap = false;
|
|
1958
|
+
let isReadonlySource = false;
|
|
1423
1959
|
let keys;
|
|
1424
1960
|
if (isArray(source)) {
|
|
1425
1961
|
if (isReactive(source)) {
|
|
1426
1962
|
needsWrap = !isShallow(source);
|
|
1427
1963
|
values = shallowReadArray(source);
|
|
1964
|
+
isReadonlySource = isReadonly(source);
|
|
1428
1965
|
}
|
|
1429
1966
|
} else if (isString(source)) {
|
|
1430
1967
|
values = source.split("");
|
|
@@ -1445,14 +1982,19 @@ function normalizeSource(source) {
|
|
|
1445
1982
|
}
|
|
1446
1983
|
}
|
|
1447
1984
|
}
|
|
1448
|
-
return {
|
|
1985
|
+
return {
|
|
1986
|
+
values,
|
|
1987
|
+
needsWrap,
|
|
1988
|
+
isReadonlySource,
|
|
1989
|
+
keys
|
|
1990
|
+
};
|
|
1449
1991
|
}
|
|
1450
|
-
function getItem({ keys, values, needsWrap }, idx) {
|
|
1451
|
-
const value = needsWrap ? toReactive(values[idx]) : values[idx];
|
|
1992
|
+
function getItem({ keys, values, needsWrap, isReadonlySource }, idx) {
|
|
1993
|
+
const value = needsWrap ? isReadonlySource ? toReadonly(toReactive(values[idx])) : toReactive(values[idx]) : values[idx];
|
|
1452
1994
|
if (keys) {
|
|
1453
1995
|
return [value, keys[idx], idx];
|
|
1454
1996
|
} else {
|
|
1455
|
-
return [value, idx,
|
|
1997
|
+
return [value, idx, void 0];
|
|
1456
1998
|
}
|
|
1457
1999
|
}
|
|
1458
2000
|
function normalizeAnchor(node) {
|
|
@@ -1474,17 +2016,17 @@ function getRestElement(val, keys) {
|
|
|
1474
2016
|
return res;
|
|
1475
2017
|
}
|
|
1476
2018
|
function getDefaultValue(val, defaultVal) {
|
|
1477
|
-
return val ===
|
|
2019
|
+
return val === void 0 ? defaultVal : val;
|
|
1478
2020
|
}
|
|
1479
2021
|
|
|
1480
2022
|
function createTemplateRefSetter() {
|
|
1481
|
-
const instance = currentInstance
|
|
2023
|
+
const instance = currentInstance;
|
|
1482
2024
|
return (...args) => setRef(instance, ...args);
|
|
1483
2025
|
}
|
|
1484
2026
|
function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
1485
2027
|
if (!instance || instance.isUnmounted) return;
|
|
1486
2028
|
const setupState = !!(process.env.NODE_ENV !== "production") ? instance.setupState || {} : null;
|
|
1487
|
-
const refValue =
|
|
2029
|
+
const refValue = getRefValue(el);
|
|
1488
2030
|
const refs = instance.refs === EMPTY_OBJ ? instance.refs = {} : instance.refs;
|
|
1489
2031
|
if (oldRef != null && oldRef !== ref) {
|
|
1490
2032
|
if (isString(oldRef)) {
|
|
@@ -1492,13 +2034,13 @@ function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
|
1492
2034
|
if (!!(process.env.NODE_ENV !== "production") && hasOwn(setupState, oldRef)) {
|
|
1493
2035
|
setupState[oldRef] = null;
|
|
1494
2036
|
}
|
|
1495
|
-
} else if (isRef(oldRef)) {
|
|
2037
|
+
} else if (isRef$1(oldRef)) {
|
|
1496
2038
|
oldRef.value = null;
|
|
1497
2039
|
}
|
|
1498
2040
|
}
|
|
1499
2041
|
if (isFunction(ref)) {
|
|
1500
2042
|
const invokeRefSetter = (value) => {
|
|
1501
|
-
callWithErrorHandling(ref, currentInstance
|
|
2043
|
+
callWithErrorHandling(ref, currentInstance, 12, [
|
|
1502
2044
|
value,
|
|
1503
2045
|
refs
|
|
1504
2046
|
]);
|
|
@@ -1507,7 +2049,7 @@ function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
|
1507
2049
|
onScopeDispose(() => invokeRefSetter());
|
|
1508
2050
|
} else {
|
|
1509
2051
|
const _isString = isString(ref);
|
|
1510
|
-
const _isRef = isRef(ref);
|
|
2052
|
+
const _isRef = isRef$1(ref);
|
|
1511
2053
|
let existing;
|
|
1512
2054
|
if (_isString || _isRef) {
|
|
1513
2055
|
const doSet = () => {
|
|
@@ -1538,8 +2080,7 @@ function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
|
1538
2080
|
warn("Invalid template ref type:", ref, `(${typeof ref})`);
|
|
1539
2081
|
}
|
|
1540
2082
|
};
|
|
1541
|
-
doSet
|
|
1542
|
-
queuePostFlushCb(doSet);
|
|
2083
|
+
queuePostFlushCb(doSet, -1);
|
|
1543
2084
|
onScopeDispose(() => {
|
|
1544
2085
|
queuePostFlushCb(() => {
|
|
1545
2086
|
if (isArray(existing)) {
|
|
@@ -1560,8 +2101,23 @@ function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
|
1560
2101
|
}
|
|
1561
2102
|
return ref;
|
|
1562
2103
|
}
|
|
2104
|
+
const getRefValue = (el) => {
|
|
2105
|
+
if (isVaporComponent(el)) {
|
|
2106
|
+
return getExposed(el) || el;
|
|
2107
|
+
} else if (el instanceof DynamicFragment) {
|
|
2108
|
+
return getRefValue(el.nodes);
|
|
2109
|
+
}
|
|
2110
|
+
return el;
|
|
2111
|
+
};
|
|
1563
2112
|
|
|
1564
2113
|
function createDynamicComponent(getter, rawProps, rawSlots, isSingleRoot) {
|
|
2114
|
+
const _insertionParent = insertionParent;
|
|
2115
|
+
const _insertionAnchor = insertionAnchor;
|
|
2116
|
+
if (isHydrating) {
|
|
2117
|
+
locateHydrationNode();
|
|
2118
|
+
} else {
|
|
2119
|
+
resetInsertionState();
|
|
2120
|
+
}
|
|
1565
2121
|
const frag = !!(process.env.NODE_ENV !== "production") ? new DynamicFragment("dynamic-component") : new DynamicFragment();
|
|
1566
2122
|
renderEffect(() => {
|
|
1567
2123
|
const value = getter();
|
|
@@ -1575,6 +2131,9 @@ function createDynamicComponent(getter, rawProps, rawSlots, isSingleRoot) {
|
|
|
1575
2131
|
value
|
|
1576
2132
|
);
|
|
1577
2133
|
});
|
|
2134
|
+
if (!isHydrating && _insertionParent) {
|
|
2135
|
+
insert(frag, _insertionParent, _insertionAnchor);
|
|
2136
|
+
}
|
|
1578
2137
|
return frag;
|
|
1579
2138
|
}
|
|
1580
2139
|
|
|
@@ -1618,9 +2177,16 @@ function setDisplay(target, value) {
|
|
|
1618
2177
|
}
|
|
1619
2178
|
}
|
|
1620
2179
|
|
|
2180
|
+
function ensureMounted(cb) {
|
|
2181
|
+
if (currentInstance.isMounted) {
|
|
2182
|
+
cb();
|
|
2183
|
+
} else {
|
|
2184
|
+
onMounted(cb);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
1621
2187
|
const applyTextModel = (el, get, set, { trim, number, lazy } = {}) => {
|
|
1622
2188
|
vModelTextInit(el, trim, number, lazy, set);
|
|
1623
|
-
|
|
2189
|
+
ensureMounted(() => {
|
|
1624
2190
|
let value;
|
|
1625
2191
|
renderEffect(() => {
|
|
1626
2192
|
vModelTextUpdate(el, value, value = get(), trim, number, lazy);
|
|
@@ -1629,7 +2195,7 @@ const applyTextModel = (el, get, set, { trim, number, lazy } = {}) => {
|
|
|
1629
2195
|
};
|
|
1630
2196
|
const applyCheckboxModel = (el, get, set) => {
|
|
1631
2197
|
vModelCheckboxInit(el, set);
|
|
1632
|
-
|
|
2198
|
+
ensureMounted(() => {
|
|
1633
2199
|
let value;
|
|
1634
2200
|
renderEffect(() => {
|
|
1635
2201
|
vModelCheckboxUpdate(
|
|
@@ -1643,7 +2209,7 @@ const applyCheckboxModel = (el, get, set) => {
|
|
|
1643
2209
|
};
|
|
1644
2210
|
const applyRadioModel = (el, get, set) => {
|
|
1645
2211
|
addEventListener(el, "change", () => set(vModelGetValue(el)));
|
|
1646
|
-
|
|
2212
|
+
ensureMounted(() => {
|
|
1647
2213
|
let value;
|
|
1648
2214
|
renderEffect(() => {
|
|
1649
2215
|
if (value !== (value = get())) {
|
|
@@ -1654,7 +2220,7 @@ const applyRadioModel = (el, get, set) => {
|
|
|
1654
2220
|
};
|
|
1655
2221
|
const applySelectModel = (el, get, set, modifiers) => {
|
|
1656
2222
|
vModelSelectInit(el, get(), modifiers && modifiers.number, set);
|
|
1657
|
-
|
|
2223
|
+
ensureMounted(() => {
|
|
1658
2224
|
renderEffect(() => vModelSetSelected(el, traverse(get())));
|
|
1659
2225
|
});
|
|
1660
2226
|
};
|
|
@@ -1672,36 +2238,13 @@ const applyDynamicModel = (el, get, set, modifiers) => {
|
|
|
1672
2238
|
apply(el, get, set, modifiers);
|
|
1673
2239
|
};
|
|
1674
2240
|
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
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);
|
|
2241
|
+
function withVaporDirectives(node, dirs) {
|
|
2242
|
+
for (const [dir, value, argument, modifiers] of dirs) {
|
|
2243
|
+
if (dir) {
|
|
2244
|
+
const ret = dir(node, value, argument, modifiers);
|
|
2245
|
+
if (ret) onScopeDispose$1(ret);
|
|
2246
|
+
}
|
|
1701
2247
|
}
|
|
1702
|
-
}
|
|
1703
|
-
const vaporInteropPlugin = (app) => {
|
|
1704
|
-
app.config.vapor = vaporInVDOMInterface;
|
|
1705
|
-
};
|
|
2248
|
+
}
|
|
1706
2249
|
|
|
1707
|
-
export { applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow,
|
|
2250
|
+
export { VaporFragment, applyCheckboxModel, applyDynamicModel, applyRadioModel, applySelectModel, applyTextModel, applyVShow, child, createComponent, createComponentWithFallback, createDynamicComponent, createFor, createForSlots, createIf, createSlot, createTemplateRefSetter, createTextNode, createVaporApp, createVaporSSRApp, defineVaporComponent, delegate, delegateEvents, getDefaultValue, getRestElement, insert, isFragment, isVaporComponent, next, nthChild, on, prepend, remove, renderEffect, setAttr, setClass, setDOMProp, setDynamicEvents, setDynamicProps, setHtml, setInsertionState, setProp, setStyle, setText, setValue, template, vaporInteropPlugin, withVaporDirectives };
|