@vue/runtime-vapor 3.6.0-alpha.1 → 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/dist/runtime-vapor.d.ts +10 -5
- package/dist/runtime-vapor.esm-bundler.js +628 -631
- package/package.json +4 -4
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/runtime-vapor v3.6.0-alpha.
|
|
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,
|
|
7
|
-
import { isArray,
|
|
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';
|
|
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
10
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
11
11
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -244,41 +244,6 @@ function normalizeBlock(block) {
|
|
|
244
244
|
return nodes;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
function normalizeEmitsOptions(comp) {
|
|
248
|
-
const cached = comp.__emitsOptions;
|
|
249
|
-
if (cached) return cached;
|
|
250
|
-
const raw = comp.emits;
|
|
251
|
-
if (!raw) return null;
|
|
252
|
-
let normalized;
|
|
253
|
-
if (isArray(raw)) {
|
|
254
|
-
normalized = {};
|
|
255
|
-
for (const key of raw) normalized[key] = null;
|
|
256
|
-
} else {
|
|
257
|
-
normalized = raw;
|
|
258
|
-
}
|
|
259
|
-
return comp.__emitsOptions = normalized;
|
|
260
|
-
}
|
|
261
|
-
function emit(instance, event, ...rawArgs) {
|
|
262
|
-
baseEmit(
|
|
263
|
-
instance,
|
|
264
|
-
instance.rawProps || EMPTY_OBJ,
|
|
265
|
-
propGetter,
|
|
266
|
-
event,
|
|
267
|
-
...rawArgs
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
function propGetter(rawProps, key) {
|
|
271
|
-
const dynamicSources = rawProps.$;
|
|
272
|
-
if (dynamicSources) {
|
|
273
|
-
let i = dynamicSources.length;
|
|
274
|
-
while (i--) {
|
|
275
|
-
const source = resolveSource(dynamicSources[i]);
|
|
276
|
-
if (hasOwn(source, key)) return resolveSource(source[key]);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return rawProps[key] && resolveSource(rawProps[key]);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
247
|
class RenderEffect extends ReactiveEffect {
|
|
283
248
|
constructor(render) {
|
|
284
249
|
super();
|
|
@@ -342,378 +307,101 @@ function renderEffect(fn, noLifecycle = false) {
|
|
|
342
307
|
effect.run();
|
|
343
308
|
}
|
|
344
309
|
|
|
345
|
-
function
|
|
346
|
-
|
|
310
|
+
function addEventListener(el, event, handler, options) {
|
|
311
|
+
el.addEventListener(event, handler, options);
|
|
312
|
+
return () => el.removeEventListener(event, handler, options);
|
|
347
313
|
}
|
|
348
|
-
function
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const emitsOptions = normalizeEmitsOptions(comp);
|
|
354
|
-
const isProp = propsOptions ? (key) => isString(key) && hasOwn(propsOptions, camelize(key)) : NO;
|
|
355
|
-
const isAttr = propsOptions ? (key) => key !== "$" && !isProp(key) && !isEmitListener(emitsOptions, key) : YES;
|
|
356
|
-
const getProp = (instance, key) => {
|
|
357
|
-
if (key === "__v_isReactive") return true;
|
|
358
|
-
if (!isProp(key)) return;
|
|
359
|
-
const rawProps = instance.rawProps;
|
|
360
|
-
const dynamicSources = rawProps.$;
|
|
361
|
-
if (dynamicSources) {
|
|
362
|
-
let i = dynamicSources.length;
|
|
363
|
-
let source, isDynamic, rawKey;
|
|
364
|
-
while (i--) {
|
|
365
|
-
source = dynamicSources[i];
|
|
366
|
-
isDynamic = isFunction(source);
|
|
367
|
-
source = isDynamic ? source() : source;
|
|
368
|
-
for (rawKey in source) {
|
|
369
|
-
if (camelize(rawKey) === key) {
|
|
370
|
-
return resolvePropValue(
|
|
371
|
-
propsOptions,
|
|
372
|
-
key,
|
|
373
|
-
isDynamic ? source[rawKey] : source[rawKey](),
|
|
374
|
-
instance,
|
|
375
|
-
resolveDefault
|
|
376
|
-
);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
for (const rawKey in rawProps) {
|
|
382
|
-
if (camelize(rawKey) === key) {
|
|
383
|
-
return resolvePropValue(
|
|
384
|
-
propsOptions,
|
|
385
|
-
key,
|
|
386
|
-
rawProps[rawKey](),
|
|
387
|
-
instance,
|
|
388
|
-
resolveDefault
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
return resolvePropValue(
|
|
393
|
-
propsOptions,
|
|
394
|
-
key,
|
|
395
|
-
void 0,
|
|
396
|
-
instance,
|
|
397
|
-
resolveDefault,
|
|
398
|
-
true
|
|
399
|
-
);
|
|
400
|
-
};
|
|
401
|
-
const propsHandlers = propsOptions ? {
|
|
402
|
-
get: (target, key) => getProp(target, key),
|
|
403
|
-
has: (_, key) => isProp(key),
|
|
404
|
-
ownKeys: () => Object.keys(propsOptions),
|
|
405
|
-
getOwnPropertyDescriptor(target, key) {
|
|
406
|
-
if (isProp(key)) {
|
|
407
|
-
return {
|
|
408
|
-
configurable: true,
|
|
409
|
-
enumerable: true,
|
|
410
|
-
get: () => getProp(target, key)
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
} : null;
|
|
415
|
-
if (!!(process.env.NODE_ENV !== "production") && propsOptions) {
|
|
416
|
-
Object.assign(propsHandlers, {
|
|
417
|
-
set: propsSetDevTrap,
|
|
418
|
-
deleteProperty: propsDeleteDevTrap
|
|
314
|
+
function on(el, event, handler, options = {}) {
|
|
315
|
+
addEventListener(el, event, handler, options);
|
|
316
|
+
if (options.effect) {
|
|
317
|
+
onEffectCleanup(() => {
|
|
318
|
+
el.removeEventListener(event, handler, options);
|
|
419
319
|
});
|
|
420
320
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
return hasAttrFromRawProps(target, key);
|
|
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);
|
|
429
328
|
} else {
|
|
430
|
-
|
|
329
|
+
el[key] = [existing, handler];
|
|
431
330
|
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
get: () => getAttr(target.rawProps, key)
|
|
443
|
-
};
|
|
444
|
-
}
|
|
331
|
+
} else {
|
|
332
|
+
el[key] = handler;
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const delegatedEvents = /* @__PURE__ */ Object.create(null);
|
|
336
|
+
const delegateEvents = (...names) => {
|
|
337
|
+
for (const name of names) {
|
|
338
|
+
if (!delegatedEvents[name]) {
|
|
339
|
+
delegatedEvents[name] = true;
|
|
340
|
+
document.addEventListener(name, delegatedEventHandler);
|
|
445
341
|
}
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
const delegatedEventHandler = (e) => {
|
|
345
|
+
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
346
|
+
if (e.target !== node) {
|
|
347
|
+
Object.defineProperty(e, "target", {
|
|
348
|
+
configurable: true,
|
|
349
|
+
value: node
|
|
451
350
|
});
|
|
452
351
|
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
if (merged) {
|
|
469
|
-
merged.push(value);
|
|
470
|
-
} else {
|
|
471
|
-
return value;
|
|
352
|
+
Object.defineProperty(e, "currentTarget", {
|
|
353
|
+
configurable: true,
|
|
354
|
+
get() {
|
|
355
|
+
return node || document;
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
while (node !== null) {
|
|
359
|
+
const handlers = node[`$evt${e.type}`];
|
|
360
|
+
if (handlers) {
|
|
361
|
+
if (isArray(handlers)) {
|
|
362
|
+
for (const handler of handlers) {
|
|
363
|
+
if (!node.disabled) {
|
|
364
|
+
handler(e);
|
|
365
|
+
if (e.cancelBubble) return;
|
|
366
|
+
}
|
|
472
367
|
}
|
|
368
|
+
} else {
|
|
369
|
+
handlers(e);
|
|
370
|
+
if (e.cancelBubble) return;
|
|
473
371
|
}
|
|
474
372
|
}
|
|
373
|
+
node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
|
|
475
374
|
}
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
return rawProps[key]();
|
|
481
|
-
}
|
|
375
|
+
};
|
|
376
|
+
function setDynamicEvents(el, events) {
|
|
377
|
+
for (const name in events) {
|
|
378
|
+
on(el, name, events[name], { effect: true });
|
|
482
379
|
}
|
|
483
|
-
|
|
484
|
-
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const hasFallthroughKey = (key) => currentInstance.hasFallthrough && key in currentInstance.attrs;
|
|
383
|
+
function setProp(el, key, value) {
|
|
384
|
+
if (key in el) {
|
|
385
|
+
setDOMProp(el, key, value);
|
|
386
|
+
} else {
|
|
387
|
+
setAttr(el, key, value);
|
|
485
388
|
}
|
|
486
389
|
}
|
|
487
|
-
function
|
|
488
|
-
if (
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
const keys = [];
|
|
503
|
-
for (const key in rawProps) {
|
|
504
|
-
if (key !== "$") keys.push(key);
|
|
505
|
-
}
|
|
506
|
-
const dynamicSources = rawProps.$;
|
|
507
|
-
if (dynamicSources) {
|
|
508
|
-
let i = dynamicSources.length;
|
|
509
|
-
let source;
|
|
510
|
-
while (i--) {
|
|
511
|
-
source = resolveSource(dynamicSources[i]);
|
|
512
|
-
for (const key in source) {
|
|
513
|
-
keys.push(key);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return Array.from(new Set(keys));
|
|
518
|
-
}
|
|
519
|
-
function normalizePropsOptions(comp) {
|
|
520
|
-
const cached = comp.__propsOptions;
|
|
521
|
-
if (cached) return cached;
|
|
522
|
-
const raw = comp.props;
|
|
523
|
-
if (!raw) return EMPTY_ARR;
|
|
524
|
-
const normalized = {};
|
|
525
|
-
const needCastKeys = [];
|
|
526
|
-
baseNormalizePropsOptions(raw, normalized, needCastKeys);
|
|
527
|
-
return comp.__propsOptions = [normalized, needCastKeys];
|
|
528
|
-
}
|
|
529
|
-
function resolveDefault(factory, instance) {
|
|
530
|
-
const prev = setCurrentInstance(instance);
|
|
531
|
-
const res = factory.call(null, instance.props);
|
|
532
|
-
setCurrentInstance(...prev);
|
|
533
|
-
return res;
|
|
534
|
-
}
|
|
535
|
-
function hasFallthroughAttrs(comp, rawProps) {
|
|
536
|
-
if (rawProps) {
|
|
537
|
-
if (rawProps.$ || !comp.props) {
|
|
538
|
-
return true;
|
|
539
|
-
} else {
|
|
540
|
-
const propsOptions = normalizePropsOptions(comp)[0];
|
|
541
|
-
for (const key in rawProps) {
|
|
542
|
-
if (!hasOwn(propsOptions, camelize(key))) {
|
|
543
|
-
return true;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
return false;
|
|
549
|
-
}
|
|
550
|
-
function setupPropsValidation(instance) {
|
|
551
|
-
const rawProps = instance.rawProps;
|
|
552
|
-
if (!rawProps) return;
|
|
553
|
-
renderEffect(
|
|
554
|
-
() => {
|
|
555
|
-
pushWarningContext(instance);
|
|
556
|
-
validateProps(
|
|
557
|
-
resolveDynamicProps(rawProps),
|
|
558
|
-
instance.props,
|
|
559
|
-
normalizePropsOptions(instance.type)[0]
|
|
560
|
-
);
|
|
561
|
-
popWarningContext();
|
|
562
|
-
},
|
|
563
|
-
true
|
|
564
|
-
/* noLifecycle */
|
|
565
|
-
);
|
|
566
|
-
}
|
|
567
|
-
function resolveDynamicProps(props) {
|
|
568
|
-
const mergedRawProps = {};
|
|
569
|
-
for (const key in props) {
|
|
570
|
-
if (key !== "$") {
|
|
571
|
-
mergedRawProps[key] = props[key]();
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
if (props.$) {
|
|
575
|
-
for (const source of props.$) {
|
|
576
|
-
const isDynamic = isFunction(source);
|
|
577
|
-
const resolved = isDynamic ? source() : source;
|
|
578
|
-
for (const key in resolved) {
|
|
579
|
-
const value = isDynamic ? resolved[key] : resolved[key]();
|
|
580
|
-
if (key === "class" || key === "style") {
|
|
581
|
-
const existing = mergedRawProps[key];
|
|
582
|
-
if (isArray(existing)) {
|
|
583
|
-
existing.push(value);
|
|
584
|
-
} else {
|
|
585
|
-
mergedRawProps[key] = [existing, value];
|
|
586
|
-
}
|
|
587
|
-
} else {
|
|
588
|
-
mergedRawProps[key] = value;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
return mergedRawProps;
|
|
594
|
-
}
|
|
595
|
-
function propsSetDevTrap(_, key) {
|
|
596
|
-
warn(
|
|
597
|
-
`Attempt to mutate prop ${JSON.stringify(key)} failed. Props are readonly.`
|
|
598
|
-
);
|
|
599
|
-
return true;
|
|
600
|
-
}
|
|
601
|
-
function propsDeleteDevTrap(_, key) {
|
|
602
|
-
warn(
|
|
603
|
-
`Attempt to delete prop ${JSON.stringify(key)} failed. Props are readonly.`
|
|
604
|
-
);
|
|
605
|
-
return true;
|
|
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
|
-
};
|
|
621
|
-
|
|
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);
|
|
390
|
+
function setAttr(el, key, value) {
|
|
391
|
+
if (!isApplyingFallthroughProps && el.$root && hasFallthroughKey(key)) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (key === "true-value") {
|
|
395
|
+
el._trueValue = value;
|
|
396
|
+
} else if (key === "false-value") {
|
|
397
|
+
el._falseValue = value;
|
|
398
|
+
}
|
|
399
|
+
if (value !== el[`$${key}`]) {
|
|
400
|
+
el[`$${key}`] = value;
|
|
401
|
+
if (value != null) {
|
|
402
|
+
el.setAttribute(key, value);
|
|
403
|
+
} else {
|
|
404
|
+
el.removeAttribute(key);
|
|
717
405
|
}
|
|
718
406
|
}
|
|
719
407
|
}
|
|
@@ -849,20 +537,544 @@ function setDynamicProp(el, key, value) {
|
|
|
849
537
|
} else {
|
|
850
538
|
setDOMProp(el, key, value);
|
|
851
539
|
}
|
|
852
|
-
} else {
|
|
853
|
-
setAttr(el, key, value);
|
|
540
|
+
} else {
|
|
541
|
+
setAttr(el, key, value);
|
|
542
|
+
}
|
|
543
|
+
return value;
|
|
544
|
+
}
|
|
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 = "";
|
|
553
|
+
}
|
|
554
|
+
|
|
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;
|
|
591
|
+
}
|
|
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);
|
|
599
|
+
}
|
|
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);
|
|
613
|
+
} else {
|
|
614
|
+
n2.el = n2.anchor = n1.anchor;
|
|
615
|
+
n2.vb = n1.vb;
|
|
616
|
+
(n2.vs.ref = n1.vs.ref).value = n2.props;
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
move(vnode, container, anchor) {
|
|
620
|
+
insert(vnode.vb || vnode.component, container, anchor);
|
|
621
|
+
insert(vnode.anchor, container, anchor);
|
|
622
|
+
}
|
|
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);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
const vaporSlotsProxyHandler = {
|
|
636
|
+
get(target, key) {
|
|
637
|
+
const slot = target[key];
|
|
638
|
+
if (isFunction(slot)) {
|
|
639
|
+
slot.__vapor = true;
|
|
640
|
+
}
|
|
641
|
+
return slot;
|
|
642
|
+
}
|
|
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
|
+
}
|
|
662
|
+
}
|
|
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
|
+
);
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
frag.remove = unmount;
|
|
694
|
+
return frag;
|
|
695
|
+
}
|
|
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;
|
|
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
|
+
};
|
|
765
|
+
|
|
766
|
+
function normalizeEmitsOptions(comp) {
|
|
767
|
+
const cached = comp.__emitsOptions;
|
|
768
|
+
if (cached) return cached;
|
|
769
|
+
const raw = comp.emits;
|
|
770
|
+
if (!raw) return null;
|
|
771
|
+
let normalized;
|
|
772
|
+
if (isArray(raw)) {
|
|
773
|
+
normalized = {};
|
|
774
|
+
for (const key of raw) normalized[key] = null;
|
|
775
|
+
} else {
|
|
776
|
+
normalized = raw;
|
|
777
|
+
}
|
|
778
|
+
return comp.__emitsOptions = normalized;
|
|
779
|
+
}
|
|
780
|
+
function emit(instance, event, ...rawArgs) {
|
|
781
|
+
baseEmit(
|
|
782
|
+
instance,
|
|
783
|
+
instance.rawProps || EMPTY_OBJ,
|
|
784
|
+
propGetter,
|
|
785
|
+
event,
|
|
786
|
+
...rawArgs
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
function propGetter(rawProps, key) {
|
|
790
|
+
const dynamicSources = rawProps.$;
|
|
791
|
+
if (dynamicSources) {
|
|
792
|
+
let i = dynamicSources.length;
|
|
793
|
+
while (i--) {
|
|
794
|
+
const source = resolveSource(dynamicSources[i]);
|
|
795
|
+
if (hasOwn(source, key))
|
|
796
|
+
return dynamicSources[interopKey] ? source[key] : resolveSource(source[key]);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return rawProps[key] && resolveSource(rawProps[key]);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function resolveSource(source) {
|
|
803
|
+
return isFunction(source) ? source() : source;
|
|
804
|
+
}
|
|
805
|
+
function getPropsProxyHandlers(comp) {
|
|
806
|
+
if (comp.__propsHandlers) {
|
|
807
|
+
return comp.__propsHandlers;
|
|
808
|
+
}
|
|
809
|
+
const propsOptions = normalizePropsOptions(comp)[0];
|
|
810
|
+
const emitsOptions = normalizeEmitsOptions(comp);
|
|
811
|
+
const isProp = propsOptions ? (key) => isString(key) && hasOwn(propsOptions, camelize(key)) : NO;
|
|
812
|
+
const isAttr = propsOptions ? (key) => key !== "$" && !isProp(key) && !isEmitListener(emitsOptions, key) : YES;
|
|
813
|
+
const getProp = (instance, key) => {
|
|
814
|
+
if (key === "__v_isReactive") return true;
|
|
815
|
+
if (!isProp(key)) return;
|
|
816
|
+
const rawProps = instance.rawProps;
|
|
817
|
+
const dynamicSources = rawProps.$;
|
|
818
|
+
if (dynamicSources) {
|
|
819
|
+
let i = dynamicSources.length;
|
|
820
|
+
let source, isDynamic, rawKey;
|
|
821
|
+
while (i--) {
|
|
822
|
+
source = dynamicSources[i];
|
|
823
|
+
isDynamic = isFunction(source);
|
|
824
|
+
source = isDynamic ? source() : source;
|
|
825
|
+
for (rawKey in source) {
|
|
826
|
+
if (camelize(rawKey) === key) {
|
|
827
|
+
return resolvePropValue(
|
|
828
|
+
propsOptions,
|
|
829
|
+
key,
|
|
830
|
+
isDynamic ? source[rawKey] : source[rawKey](),
|
|
831
|
+
instance,
|
|
832
|
+
resolveDefault
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
for (const rawKey in rawProps) {
|
|
839
|
+
if (camelize(rawKey) === key) {
|
|
840
|
+
return resolvePropValue(
|
|
841
|
+
propsOptions,
|
|
842
|
+
key,
|
|
843
|
+
rawProps[rawKey](),
|
|
844
|
+
instance,
|
|
845
|
+
resolveDefault
|
|
846
|
+
);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return resolvePropValue(
|
|
850
|
+
propsOptions,
|
|
851
|
+
key,
|
|
852
|
+
void 0,
|
|
853
|
+
instance,
|
|
854
|
+
resolveDefault,
|
|
855
|
+
true
|
|
856
|
+
);
|
|
857
|
+
};
|
|
858
|
+
const propsHandlers = propsOptions ? {
|
|
859
|
+
get: (target, key) => getProp(target, key),
|
|
860
|
+
has: (_, key) => isProp(key),
|
|
861
|
+
ownKeys: () => Object.keys(propsOptions),
|
|
862
|
+
getOwnPropertyDescriptor(target, key) {
|
|
863
|
+
if (isProp(key)) {
|
|
864
|
+
return {
|
|
865
|
+
configurable: true,
|
|
866
|
+
enumerable: true,
|
|
867
|
+
get: () => getProp(target, key)
|
|
868
|
+
};
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
} : null;
|
|
872
|
+
if (!!(process.env.NODE_ENV !== "production") && propsOptions) {
|
|
873
|
+
Object.assign(propsHandlers, {
|
|
874
|
+
set: propsSetDevTrap,
|
|
875
|
+
deleteProperty: propsDeleteDevTrap
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
const getAttr = (target, key) => {
|
|
879
|
+
if (!isProp(key) && !isEmitListener(emitsOptions, key)) {
|
|
880
|
+
return getAttrFromRawProps(target, key);
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
const hasAttr = (target, key) => {
|
|
884
|
+
if (isAttr(key)) {
|
|
885
|
+
return hasAttrFromRawProps(target, key);
|
|
886
|
+
} else {
|
|
887
|
+
return false;
|
|
888
|
+
}
|
|
889
|
+
};
|
|
890
|
+
const attrsHandlers = {
|
|
891
|
+
get: (target, key) => getAttr(target.rawProps, key),
|
|
892
|
+
has: (target, key) => hasAttr(target.rawProps, key),
|
|
893
|
+
ownKeys: (target) => getKeysFromRawProps(target.rawProps).filter(isAttr),
|
|
894
|
+
getOwnPropertyDescriptor(target, key) {
|
|
895
|
+
if (hasAttr(target.rawProps, key)) {
|
|
896
|
+
return {
|
|
897
|
+
configurable: true,
|
|
898
|
+
enumerable: true,
|
|
899
|
+
get: () => getAttr(target.rawProps, key)
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
};
|
|
904
|
+
if (!!(process.env.NODE_ENV !== "production")) {
|
|
905
|
+
Object.assign(attrsHandlers, {
|
|
906
|
+
set: propsSetDevTrap,
|
|
907
|
+
deleteProperty: propsDeleteDevTrap
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
return comp.__propsHandlers = [propsHandlers, attrsHandlers];
|
|
911
|
+
}
|
|
912
|
+
function getAttrFromRawProps(rawProps, key) {
|
|
913
|
+
if (key === "$") return;
|
|
914
|
+
const merged = key === "class" || key === "style" ? [] : void 0;
|
|
915
|
+
const dynamicSources = rawProps.$;
|
|
916
|
+
if (dynamicSources) {
|
|
917
|
+
let i = dynamicSources.length;
|
|
918
|
+
let source, isDynamic;
|
|
919
|
+
while (i--) {
|
|
920
|
+
source = dynamicSources[i];
|
|
921
|
+
isDynamic = isFunction(source);
|
|
922
|
+
source = isDynamic ? source() : source;
|
|
923
|
+
if (source && hasOwn(source, key)) {
|
|
924
|
+
const value = isDynamic ? source[key] : source[key]();
|
|
925
|
+
if (merged) {
|
|
926
|
+
merged.push(value);
|
|
927
|
+
} else {
|
|
928
|
+
return value;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (hasOwn(rawProps, key)) {
|
|
934
|
+
if (merged) {
|
|
935
|
+
merged.push(rawProps[key]());
|
|
936
|
+
} else {
|
|
937
|
+
return rawProps[key]();
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
if (merged && merged.length) {
|
|
941
|
+
return merged;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
function hasAttrFromRawProps(rawProps, key) {
|
|
945
|
+
if (key === "$") return false;
|
|
946
|
+
const dynamicSources = rawProps.$;
|
|
947
|
+
if (dynamicSources) {
|
|
948
|
+
let i = dynamicSources.length;
|
|
949
|
+
while (i--) {
|
|
950
|
+
const source = resolveSource(dynamicSources[i]);
|
|
951
|
+
if (source && hasOwn(source, key)) {
|
|
952
|
+
return true;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
return hasOwn(rawProps, key);
|
|
957
|
+
}
|
|
958
|
+
function getKeysFromRawProps(rawProps) {
|
|
959
|
+
const keys = [];
|
|
960
|
+
for (const key in rawProps) {
|
|
961
|
+
if (key !== "$") keys.push(key);
|
|
962
|
+
}
|
|
963
|
+
const dynamicSources = rawProps.$;
|
|
964
|
+
if (dynamicSources) {
|
|
965
|
+
let i = dynamicSources.length;
|
|
966
|
+
let source;
|
|
967
|
+
while (i--) {
|
|
968
|
+
source = resolveSource(dynamicSources[i]);
|
|
969
|
+
for (const key in source) {
|
|
970
|
+
keys.push(key);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
return Array.from(new Set(keys));
|
|
975
|
+
}
|
|
976
|
+
function normalizePropsOptions(comp) {
|
|
977
|
+
const cached = comp.__propsOptions;
|
|
978
|
+
if (cached) return cached;
|
|
979
|
+
const raw = comp.props;
|
|
980
|
+
if (!raw) return EMPTY_ARR;
|
|
981
|
+
const normalized = {};
|
|
982
|
+
const needCastKeys = [];
|
|
983
|
+
baseNormalizePropsOptions(raw, normalized, needCastKeys);
|
|
984
|
+
return comp.__propsOptions = [normalized, needCastKeys];
|
|
985
|
+
}
|
|
986
|
+
function resolveDefault(factory, instance) {
|
|
987
|
+
const prev = setCurrentInstance(instance);
|
|
988
|
+
const res = factory.call(null, instance.props);
|
|
989
|
+
setCurrentInstance(...prev);
|
|
990
|
+
return res;
|
|
991
|
+
}
|
|
992
|
+
function hasFallthroughAttrs(comp, rawProps) {
|
|
993
|
+
if (rawProps) {
|
|
994
|
+
if (rawProps.$ || !comp.props) {
|
|
995
|
+
return true;
|
|
996
|
+
} else {
|
|
997
|
+
const propsOptions = normalizePropsOptions(comp)[0];
|
|
998
|
+
for (const key in rawProps) {
|
|
999
|
+
if (!hasOwn(propsOptions, camelize(key))) {
|
|
1000
|
+
return true;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
function setupPropsValidation(instance) {
|
|
1008
|
+
const rawProps = instance.rawProps;
|
|
1009
|
+
if (!rawProps) return;
|
|
1010
|
+
renderEffect(
|
|
1011
|
+
() => {
|
|
1012
|
+
pushWarningContext(instance);
|
|
1013
|
+
validateProps(
|
|
1014
|
+
resolveDynamicProps(rawProps),
|
|
1015
|
+
instance.props,
|
|
1016
|
+
normalizePropsOptions(instance.type)[0]
|
|
1017
|
+
);
|
|
1018
|
+
popWarningContext();
|
|
1019
|
+
},
|
|
1020
|
+
true
|
|
1021
|
+
/* noLifecycle */
|
|
1022
|
+
);
|
|
1023
|
+
}
|
|
1024
|
+
function resolveDynamicProps(props) {
|
|
1025
|
+
const mergedRawProps = {};
|
|
1026
|
+
for (const key in props) {
|
|
1027
|
+
if (key !== "$") {
|
|
1028
|
+
mergedRawProps[key] = props[key]();
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
if (props.$) {
|
|
1032
|
+
for (const source of props.$) {
|
|
1033
|
+
const isDynamic = isFunction(source);
|
|
1034
|
+
const resolved = isDynamic ? source() : source;
|
|
1035
|
+
for (const key in resolved) {
|
|
1036
|
+
const value = isDynamic ? resolved[key] : resolved[key]();
|
|
1037
|
+
if (key === "class" || key === "style") {
|
|
1038
|
+
const existing = mergedRawProps[key];
|
|
1039
|
+
if (isArray(existing)) {
|
|
1040
|
+
existing.push(value);
|
|
1041
|
+
} else {
|
|
1042
|
+
mergedRawProps[key] = [existing, value];
|
|
1043
|
+
}
|
|
1044
|
+
} else {
|
|
1045
|
+
mergedRawProps[key] = value;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
854
1049
|
}
|
|
855
|
-
return
|
|
1050
|
+
return mergedRawProps;
|
|
856
1051
|
}
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
1052
|
+
function propsSetDevTrap(_, key) {
|
|
1053
|
+
warn(
|
|
1054
|
+
`Attempt to mutate prop ${JSON.stringify(key)} failed. Props are readonly.`
|
|
1055
|
+
);
|
|
1056
|
+
return true;
|
|
1057
|
+
}
|
|
1058
|
+
function propsDeleteDevTrap(_, key) {
|
|
1059
|
+
warn(
|
|
1060
|
+
`Attempt to delete prop ${JSON.stringify(key)} failed. Props are readonly.`
|
|
1061
|
+
);
|
|
1062
|
+
return true;
|
|
865
1063
|
}
|
|
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
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
866
1078
|
|
|
867
1079
|
const dynamicSlotsProxyHandlers = {
|
|
868
1080
|
get: getSlot,
|
|
@@ -1105,7 +1317,7 @@ function createComponent(component, rawProps, rawSlots, isSingleRoot, appContext
|
|
|
1105
1317
|
popWarningContext();
|
|
1106
1318
|
endMeasure(instance, "init");
|
|
1107
1319
|
}
|
|
1108
|
-
onScopeDispose(() => unmountComponent(instance), true);
|
|
1320
|
+
onScopeDispose$1(() => unmountComponent(instance), true);
|
|
1109
1321
|
if (!isHydrating && _insertionParent) {
|
|
1110
1322
|
mountComponent(instance, _insertionParent, _insertionAnchor);
|
|
1111
1323
|
}
|
|
@@ -1320,17 +1532,6 @@ function prepareApp() {
|
|
|
1320
1532
|
}
|
|
1321
1533
|
}
|
|
1322
1534
|
function postPrepareApp(app) {
|
|
1323
|
-
if (!!(process.env.NODE_ENV !== "production")) {
|
|
1324
|
-
app.config.globalProperties = new Proxy(
|
|
1325
|
-
{},
|
|
1326
|
-
{
|
|
1327
|
-
set() {
|
|
1328
|
-
warn(`app.config.globalProperties is not supported in vapor mode.`);
|
|
1329
|
-
return false;
|
|
1330
|
-
}
|
|
1331
|
-
}
|
|
1332
|
-
);
|
|
1333
|
-
}
|
|
1334
1535
|
app.vapor = true;
|
|
1335
1536
|
const mount = app.mount;
|
|
1336
1537
|
app.mount = (container, ...args) => {
|
|
@@ -1367,212 +1568,6 @@ function defineVaporComponent(comp, extraOptions) {
|
|
|
1367
1568
|
return comp;
|
|
1368
1569
|
}
|
|
1369
1570
|
|
|
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
1571
|
let t;
|
|
1577
1572
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
1578
1573
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -1630,7 +1625,7 @@ class ForBlock extends VaporFragment {
|
|
|
1630
1625
|
this.key = renderKey;
|
|
1631
1626
|
}
|
|
1632
1627
|
}
|
|
1633
|
-
const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
1628
|
+
const createFor = (src, renderItem, getKey, flags = 0, setup) => {
|
|
1634
1629
|
const _insertionParent = insertionParent;
|
|
1635
1630
|
const _insertionAnchor = insertionAnchor;
|
|
1636
1631
|
if (isHydrating) {
|
|
@@ -1889,6 +1884,9 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
1889
1884
|
}
|
|
1890
1885
|
}
|
|
1891
1886
|
};
|
|
1887
|
+
if (setup) {
|
|
1888
|
+
setup({ createSelector });
|
|
1889
|
+
}
|
|
1892
1890
|
if (flags & 4) {
|
|
1893
1891
|
renderList();
|
|
1894
1892
|
} else {
|
|
@@ -1897,9 +1895,8 @@ const createFor = (src, renderItem, getKey, flags = 0) => {
|
|
|
1897
1895
|
if (!isHydrating && _insertionParent) {
|
|
1898
1896
|
insert(frag, _insertionParent, _insertionAnchor);
|
|
1899
1897
|
}
|
|
1900
|
-
frag.useSelector = useSelector;
|
|
1901
1898
|
return frag;
|
|
1902
|
-
function
|
|
1899
|
+
function createSelector(source) {
|
|
1903
1900
|
let operMap = /* @__PURE__ */ new Map();
|
|
1904
1901
|
let activeKey = source();
|
|
1905
1902
|
let activeOpers;
|
|
@@ -2046,7 +2043,7 @@ function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
|
2046
2043
|
]);
|
|
2047
2044
|
};
|
|
2048
2045
|
invokeRefSetter(refValue);
|
|
2049
|
-
onScopeDispose(() => invokeRefSetter());
|
|
2046
|
+
onScopeDispose$1(() => invokeRefSetter());
|
|
2050
2047
|
} else {
|
|
2051
2048
|
const _isString = isString(ref);
|
|
2052
2049
|
const _isRef = isRef$1(ref);
|
|
@@ -2081,7 +2078,7 @@ function setRef(instance, el, ref, oldRef, refFor = false) {
|
|
|
2081
2078
|
}
|
|
2082
2079
|
};
|
|
2083
2080
|
queuePostFlushCb(doSet, -1);
|
|
2084
|
-
onScopeDispose(() => {
|
|
2081
|
+
onScopeDispose$1(() => {
|
|
2085
2082
|
queuePostFlushCb(() => {
|
|
2086
2083
|
if (isArray(existing)) {
|
|
2087
2084
|
remove$1(existing, refValue);
|
|
@@ -2242,7 +2239,7 @@ function withVaporDirectives(node, dirs) {
|
|
|
2242
2239
|
for (const [dir, value, argument, modifiers] of dirs) {
|
|
2243
2240
|
if (dir) {
|
|
2244
2241
|
const ret = dir(node, value, argument, modifiers);
|
|
2245
|
-
if (ret) onScopeDispose
|
|
2242
|
+
if (ret) onScopeDispose(ret);
|
|
2246
2243
|
}
|
|
2247
2244
|
}
|
|
2248
2245
|
}
|