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