@cabloy/vue-runtime-core 3.5.11 → 3.5.14

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @cabloy/vue-runtime-core v3.5.6
2
+ * @cabloy/vue-runtime-core v3.5.13
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -273,10 +273,8 @@ function logError(err, type, contextVNode, throwInDev = true, throwInProd = fals
273
273
  }
274
274
  }
275
275
 
276
- let isFlushing = false;
277
- let isFlushPending = false;
278
276
  const queue = [];
279
- let flushIndex = 0;
277
+ let flushIndex = -1;
280
278
  const pendingPostFlushCbs = [];
281
279
  let activePostFlushCbs = null;
282
280
  let postFlushIndex = 0;
@@ -288,7 +286,7 @@ function nextTick(fn) {
288
286
  return fn ? p.then(this ? fn.bind(this) : fn) : p;
289
287
  }
290
288
  function findInsertionIndex(id) {
291
- let start = isFlushing ? flushIndex + 1 : 0;
289
+ let start = flushIndex + 1;
292
290
  let end = queue.length;
293
291
  while (start < end) {
294
292
  const middle = start + end >>> 1;
@@ -317,8 +315,7 @@ function queueJob(job) {
317
315
  }
318
316
  }
319
317
  function queueFlush() {
320
- if (!isFlushing && !isFlushPending) {
321
- isFlushPending = true;
318
+ if (!currentFlushPromise) {
322
319
  currentFlushPromise = resolvedPromise.then(flushJobs);
323
320
  }
324
321
  }
@@ -335,7 +332,7 @@ function queuePostFlushCb(cb) {
335
332
  }
336
333
  queueFlush();
337
334
  }
338
- function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
335
+ function flushPreFlushCbs(instance, seen, i = flushIndex + 1) {
339
336
  {
340
337
  seen = seen || /* @__PURE__ */ new Map();
341
338
  }
@@ -354,7 +351,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
354
351
  cb.flags &= ~1;
355
352
  }
356
353
  cb();
357
- cb.flags &= ~1;
354
+ if (!(cb.flags & 4)) {
355
+ cb.flags &= ~1;
356
+ }
358
357
  }
359
358
  }
360
359
  }
@@ -389,8 +388,6 @@ function flushPostFlushCbs(seen) {
389
388
  }
390
389
  const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
391
390
  function flushJobs(seen) {
392
- isFlushPending = false;
393
- isFlushing = true;
394
391
  {
395
392
  seen = seen || /* @__PURE__ */ new Map();
396
393
  }
@@ -410,7 +407,9 @@ function flushJobs(seen) {
410
407
  job.i,
411
408
  job.i ? 15 : 14
412
409
  );
413
- job.flags &= ~1;
410
+ if (!(job.flags & 4)) {
411
+ job.flags &= ~1;
412
+ }
414
413
  }
415
414
  }
416
415
  } finally {
@@ -420,10 +419,9 @@ function flushJobs(seen) {
420
419
  job.flags &= ~1;
421
420
  }
422
421
  }
423
- flushIndex = 0;
422
+ flushIndex = -1;
424
423
  queue.length = 0;
425
424
  flushPostFlushCbs(seen);
426
- isFlushing = false;
427
425
  currentFlushPromise = null;
428
426
  if (queue.length || pendingPostFlushCbs.length) {
429
427
  flushJobs(seen);
@@ -845,7 +843,7 @@ const TeleportImpl = {
845
843
  }
846
844
  if (!disabled) {
847
845
  mount(target, targetAnchor);
848
- updateCssVars(n2);
846
+ updateCssVars(n2, false);
849
847
  }
850
848
  } else if (!disabled) {
851
849
  warn$1(
@@ -857,14 +855,35 @@ const TeleportImpl = {
857
855
  };
858
856
  if (disabled) {
859
857
  mount(container, mainAnchor);
860
- updateCssVars(n2);
858
+ updateCssVars(n2, true);
861
859
  }
862
860
  if (isTeleportDeferred(n2.props)) {
863
- queuePostRenderEffect(mountToTarget, parentSuspense);
861
+ queuePostRenderEffect(() => {
862
+ mountToTarget();
863
+ n2.el.__isMounted = true;
864
+ }, parentSuspense);
864
865
  } else {
865
866
  mountToTarget();
866
867
  }
867
868
  } else {
869
+ if (isTeleportDeferred(n2.props) && !n1.el.__isMounted) {
870
+ queuePostRenderEffect(() => {
871
+ TeleportImpl.process(
872
+ n1,
873
+ n2,
874
+ container,
875
+ anchor,
876
+ parentComponent,
877
+ parentSuspense,
878
+ namespace,
879
+ slotScopeIds,
880
+ optimized,
881
+ internals
882
+ );
883
+ delete n1.el.__isMounted;
884
+ }, parentSuspense);
885
+ return;
886
+ }
868
887
  n2.el = n1.el;
869
888
  n2.targetStart = n1.targetStart;
870
889
  const mainAnchor = n2.anchor = n1.anchor;
@@ -947,7 +966,7 @@ const TeleportImpl = {
947
966
  );
948
967
  }
949
968
  }
950
- updateCssVars(n2);
969
+ updateCssVars(n2, disabled);
951
970
  }
952
971
  },
953
972
  remove(vnode, parentComponent, parentSuspense, { um: unmount, o: { remove: hostRemove } }, doRemove) {
@@ -1015,9 +1034,10 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
1015
1034
  querySelector
1016
1035
  );
1017
1036
  if (target) {
1037
+ const disabled = isTeleportDisabled(vnode.props);
1018
1038
  const targetNode = target._lpa || target.firstChild;
1019
1039
  if (vnode.shapeFlag & 16) {
1020
- if (isTeleportDisabled(vnode.props)) {
1040
+ if (disabled) {
1021
1041
  vnode.anchor = hydrateChildren(
1022
1042
  nextSibling(node),
1023
1043
  vnode,
@@ -1058,16 +1078,23 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
1058
1078
  );
1059
1079
  }
1060
1080
  }
1061
- updateCssVars(vnode);
1081
+ updateCssVars(vnode, disabled);
1062
1082
  }
1063
1083
  return vnode.anchor && nextSibling(vnode.anchor);
1064
1084
  }
1065
1085
  const Teleport = TeleportImpl;
1066
- function updateCssVars(vnode) {
1086
+ function updateCssVars(vnode, isDisabled) {
1067
1087
  const ctx = vnode.ctx;
1068
1088
  if (ctx && ctx.ut) {
1069
- let node = vnode.targetStart;
1070
- while (node && node !== vnode.targetAnchor) {
1089
+ let node, anchor;
1090
+ if (isDisabled) {
1091
+ node = vnode.el;
1092
+ anchor = vnode.anchor;
1093
+ } else {
1094
+ node = vnode.targetStart;
1095
+ anchor = vnode.targetAnchor;
1096
+ }
1097
+ while (node && node !== anchor) {
1071
1098
  if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx.uid);
1072
1099
  node = node.nextSibling;
1073
1100
  }
@@ -1162,10 +1189,9 @@ const BaseTransitionImpl = {
1162
1189
  if (innerChild.type !== Comment) {
1163
1190
  setTransitionHooks(innerChild, enterHooks);
1164
1191
  }
1165
- const oldChild = instance.subTree;
1166
- const oldInnerChild = oldChild && getInnerChild$1(oldChild);
1192
+ let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree);
1167
1193
  if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
1168
- const leavingHooks = resolveTransitionHooks(
1194
+ let leavingHooks = resolveTransitionHooks(
1169
1195
  oldInnerChild,
1170
1196
  rawProps,
1171
1197
  state,
@@ -1180,6 +1206,7 @@ const BaseTransitionImpl = {
1180
1206
  instance.update();
1181
1207
  }
1182
1208
  delete leavingHooks.afterLeave;
1209
+ oldInnerChild = void 0;
1183
1210
  };
1184
1211
  return emptyPlaceholder(child);
1185
1212
  } else if (mode === "in-out" && innerChild.type !== Comment) {
@@ -1193,10 +1220,19 @@ const BaseTransitionImpl = {
1193
1220
  earlyRemove();
1194
1221
  el[leaveCbKey] = void 0;
1195
1222
  delete enterHooks.delayedLeave;
1223
+ oldInnerChild = void 0;
1224
+ };
1225
+ enterHooks.delayedLeave = () => {
1226
+ delayedLeave();
1227
+ delete enterHooks.delayedLeave;
1228
+ oldInnerChild = void 0;
1196
1229
  };
1197
- enterHooks.delayedLeave = delayedLeave;
1198
1230
  };
1231
+ } else {
1232
+ oldInnerChild = void 0;
1199
1233
  }
1234
+ } else if (oldInnerChild) {
1235
+ oldInnerChild = void 0;
1200
1236
  }
1201
1237
  return child;
1202
1238
  };
@@ -1453,6 +1489,7 @@ function useId() {
1453
1489
  `useId() is called when there is no active component instance to be associated with.`
1454
1490
  );
1455
1491
  }
1492
+ return "";
1456
1493
  }
1457
1494
  function markAsyncBoundary(instance) {
1458
1495
  instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
@@ -1500,6 +1537,9 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1500
1537
  return;
1501
1538
  }
1502
1539
  if (isAsyncWrapper(vnode) && !isUnmount) {
1540
+ if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
1541
+ setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
1542
+ }
1503
1543
  return;
1504
1544
  }
1505
1545
  const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
@@ -1516,8 +1556,15 @@ function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
1516
1556
  const setupState = owner.setupState;
1517
1557
  const rawSetupState = reactivity.toRaw(setupState);
1518
1558
  const canSetSetupRef = setupState === shared.EMPTY_OBJ ? () => false : (key) => {
1519
- if (knownTemplateRefs.has(rawSetupState[key])) {
1520
- return false;
1559
+ {
1560
+ if (shared.hasOwn(rawSetupState, key) && !reactivity.isRef(rawSetupState[key])) {
1561
+ warn$1(
1562
+ `Template ref "${key}" used on a non-ref value. It will not work in the production build.`
1563
+ );
1564
+ }
1565
+ if (knownTemplateRefs.has(rawSetupState[key])) {
1566
+ return false;
1567
+ }
1521
1568
  }
1522
1569
  return shared.hasOwn(rawSetupState, key);
1523
1570
  };
@@ -1747,7 +1794,7 @@ function createHydrationFunctions(rendererInternals) {
1747
1794
  getContainerType(container),
1748
1795
  optimized
1749
1796
  );
1750
- if (isAsyncWrapper(vnode)) {
1797
+ if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
1751
1798
  let subTree;
1752
1799
  if (isFragmentStart) {
1753
1800
  subTree = createVNode(Fragment);
@@ -1810,7 +1857,11 @@ function createHydrationFunctions(rendererInternals) {
1810
1857
  }
1811
1858
  let needCallTransitionHooks = false;
1812
1859
  if (isTemplateNode(el)) {
1813
- needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
1860
+ needCallTransitionHooks = needTransition(
1861
+ null,
1862
+ // no need check parentSuspense in hydration
1863
+ transition
1864
+ ) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
1814
1865
  const content = el.content.firstChild;
1815
1866
  if (needCallTransitionHooks) {
1816
1867
  transition.beforeEnter(content);
@@ -2037,6 +2088,10 @@ Server rendered element contains fewer child nodes than client vdom.`
2037
2088
  getContainerType(container),
2038
2089
  slotScopeIds
2039
2090
  );
2091
+ if (parentComponent) {
2092
+ parentComponent.vnode.el = vnode.el;
2093
+ updateHOCHostEl(parentComponent, vnode.el);
2094
+ }
2040
2095
  return next;
2041
2096
  };
2042
2097
  const locateClosingAnchor = (node, open = "[", close = "]") => {
@@ -2222,10 +2277,17 @@ function isMismatchAllowed(el, allowedType) {
2222
2277
  }
2223
2278
  }
2224
2279
 
2280
+ const requestIdleCallback = shared.getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
2281
+ const cancelIdleCallback = shared.getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
2225
2282
  const hydrateOnIdle = (timeout = 1e4) => (hydrate) => {
2226
2283
  const id = requestIdleCallback(hydrate, { timeout });
2227
2284
  return () => cancelIdleCallback(id);
2228
2285
  };
2286
+ function elementIsVisibleInViewport(el) {
2287
+ const { top, left, bottom, right } = el.getBoundingClientRect();
2288
+ const { innerHeight, innerWidth } = window;
2289
+ return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
2290
+ }
2229
2291
  const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2230
2292
  const ob = new IntersectionObserver((entries) => {
2231
2293
  for (const e of entries) {
@@ -2235,7 +2297,15 @@ const hydrateOnVisible = (opts) => (hydrate, forEach) => {
2235
2297
  break;
2236
2298
  }
2237
2299
  }, opts);
2238
- forEach((el) => ob.observe(el));
2300
+ forEach((el) => {
2301
+ if (!(el instanceof Element)) return;
2302
+ if (elementIsVisibleInViewport(el)) {
2303
+ hydrate();
2304
+ ob.disconnect();
2305
+ return false;
2306
+ }
2307
+ ob.observe(el);
2308
+ });
2239
2309
  return () => ob.disconnect();
2240
2310
  };
2241
2311
  const hydrateOnMediaQuery = (query) => (hydrate) => {
@@ -2280,7 +2350,10 @@ function forEachElement(node, cb) {
2280
2350
  let next = node.nextSibling;
2281
2351
  while (next) {
2282
2352
  if (next.nodeType === 1) {
2283
- cb(next);
2353
+ const result = cb(next);
2354
+ if (result === false) {
2355
+ break;
2356
+ }
2284
2357
  } else if (isComment(next)) {
2285
2358
  if (next.data === "]") {
2286
2359
  if (--depth === 0) break;
@@ -2922,12 +2995,13 @@ function renderSlot(slots, name, props = {}, fallback, noSlotted) {
2922
2995
  }
2923
2996
  openBlock();
2924
2997
  const validSlotContent = slot && ensureValidVNode(slot(props));
2998
+ const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
2999
+ // key attached in the `createSlots` helper, respect that
3000
+ validSlotContent && validSlotContent.key;
2925
3001
  const rendered = createBlock(
2926
3002
  Fragment,
2927
3003
  {
2928
- key: (props.key || // slot content array of a dynamic conditional slot may have a branch
2929
- // key attached in the `createSlots` helper, respect that
2930
- validSlotContent && validSlotContent.key || `_${name}`) + // #7256 force differentiate fallback content from actual content
3004
+ key: (slotKey && !shared.isSymbol(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
2931
3005
  (!validSlotContent && fallback ? "_fb" : "")
2932
3006
  },
2933
3007
  validSlotContent || (fallback ? fallback() : []),
@@ -4285,6 +4359,7 @@ function getType(ctor) {
4285
4359
  function validateProps(rawProps, props, instance) {
4286
4360
  const resolvedValues = reactivity.toRaw(props);
4287
4361
  const options = instance.propsOptions[0];
4362
+ const camelizePropsKey = Object.keys(rawProps).map((key) => shared.camelize(key));
4288
4363
  for (const key in options) {
4289
4364
  let opt = options[key];
4290
4365
  if (opt == null) continue;
@@ -4293,7 +4368,7 @@ function validateProps(rawProps, props, instance) {
4293
4368
  resolvedValues[key],
4294
4369
  opt,
4295
4370
  reactivity.shallowReadonly(resolvedValues) ,
4296
- !shared.hasOwn(rawProps, key) && !shared.hasOwn(rawProps, shared.hyphenate(key))
4371
+ !camelizePropsKey.includes(key)
4297
4372
  );
4298
4373
  }
4299
4374
  }
@@ -6108,14 +6183,13 @@ function doWatch(source, cb, options = shared.EMPTY_OBJ) {
6108
6183
  }
6109
6184
  const baseWatchOptions = shared.extend({}, options);
6110
6185
  baseWatchOptions.onWarn = warn$1;
6186
+ const runsImmediately = cb && immediate || !cb && flush !== "post";
6111
6187
  let ssrCleanup;
6112
6188
  if (isInSSRComponentSetup) {
6113
6189
  if (flush === "sync") {
6114
6190
  const ctx = useSSRContext();
6115
6191
  ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
6116
- } else if (!cb || immediate) {
6117
- baseWatchOptions.once = true;
6118
- } else {
6192
+ } else if (!runsImmediately) {
6119
6193
  const watchStopHandle = () => {
6120
6194
  };
6121
6195
  watchStopHandle.stop = shared.NOOP;
@@ -6154,7 +6228,13 @@ function doWatch(source, cb, options = shared.EMPTY_OBJ) {
6154
6228
  }
6155
6229
  };
6156
6230
  const watchHandle = reactivity.watch(source, cb, baseWatchOptions);
6157
- if (ssrCleanup) ssrCleanup.push(watchHandle);
6231
+ if (isInSSRComponentSetup) {
6232
+ if (ssrCleanup) {
6233
+ ssrCleanup.push(watchHandle);
6234
+ } else if (runsImmediately) {
6235
+ watchHandle();
6236
+ }
6237
+ }
6158
6238
  return watchHandle;
6159
6239
  }
6160
6240
  function instanceWatch(source, value, options) {
@@ -6189,19 +6269,19 @@ function useModel(props, name, options = shared.EMPTY_OBJ) {
6189
6269
  warn$1(`useModel() called without active instance.`);
6190
6270
  return reactivity.ref();
6191
6271
  }
6192
- if (!i.propsOptions[0][name]) {
6272
+ const camelizedName = shared.camelize(name);
6273
+ if (!i.propsOptions[0][camelizedName]) {
6193
6274
  warn$1(`useModel() called with prop "${name}" which is not declared.`);
6194
6275
  return reactivity.ref();
6195
6276
  }
6196
- const camelizedName = shared.camelize(name);
6197
6277
  const hyphenatedName = shared.hyphenate(name);
6198
- const modifiers = getModelModifiers(props, name);
6278
+ const modifiers = getModelModifiers(props, camelizedName);
6199
6279
  const res = reactivity.customRef((track, trigger) => {
6200
6280
  let localValue;
6201
6281
  let prevSetValue = shared.EMPTY_OBJ;
6202
6282
  let prevEmittedValue;
6203
6283
  watchSyncEffect(() => {
6204
- const propValue = props[name];
6284
+ const propValue = props[camelizedName];
6205
6285
  if (shared.hasChanged(localValue, propValue)) {
6206
6286
  localValue = propValue;
6207
6287
  trigger();
@@ -6500,7 +6580,7 @@ function renderComponentRoot(instance) {
6500
6580
  }
6501
6581
  if (extraAttrs.length) {
6502
6582
  warn$1(
6503
- `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
6583
+ `Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text or teleport root nodes.`
6504
6584
  );
6505
6585
  }
6506
6586
  if (eventAttrs.length) {
@@ -7283,9 +7363,9 @@ function closeBlock() {
7283
7363
  currentBlock = blockStack[blockStack.length - 1] || null;
7284
7364
  }
7285
7365
  let isBlockTreeEnabled = 1;
7286
- function setBlockTracking(value) {
7366
+ function setBlockTracking(value, inVOnce = false) {
7287
7367
  isBlockTreeEnabled += value;
7288
- if (value < 0 && currentBlock) {
7368
+ if (value < 0 && currentBlock && inVOnce) {
7289
7369
  currentBlock.hasOnce = true;
7290
7370
  }
7291
7371
  }
@@ -7561,7 +7641,7 @@ function normalizeVNode(child) {
7561
7641
  // #3666, avoid reference pollution when reusing vnode
7562
7642
  child.slice()
7563
7643
  );
7564
- } else if (typeof child === "object") {
7644
+ } else if (isVNode(child)) {
7565
7645
  return cloneIfMounted(child);
7566
7646
  } else {
7567
7647
  return createVNode(Text, null, String(child));
@@ -7828,9 +7908,9 @@ function setupStatefulComponent(instance, isSSR) {
7828
7908
  }
7829
7909
  const { setup } = Component;
7830
7910
  if (setup) {
7911
+ reactivity.pauseTracking();
7831
7912
  const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
7832
7913
  const reset = setCurrentInstance(instance);
7833
- reactivity.pauseTracking();
7834
7914
  const setupResult = callWithErrorHandling(
7835
7915
  setup,
7836
7916
  instance,
@@ -7840,10 +7920,13 @@ function setupStatefulComponent(instance, isSSR) {
7840
7920
  setupContext
7841
7921
  ]
7842
7922
  );
7923
+ const isAsyncSetup = shared.isPromise(setupResult);
7843
7924
  reactivity.resetTracking();
7844
7925
  reset();
7845
- if (shared.isPromise(setupResult)) {
7846
- if (!isAsyncWrapper(instance)) markAsyncBoundary(instance);
7926
+ if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) {
7927
+ markAsyncBoundary(instance);
7928
+ }
7929
+ if (isAsyncSetup) {
7847
7930
  setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
7848
7931
  if (isSSR) {
7849
7932
  return setupResult.then((resolvedResult) => {
@@ -8306,7 +8389,7 @@ function isMemoSame(cached, memo) {
8306
8389
  return true;
8307
8390
  }
8308
8391
 
8309
- const version = "3.5.6";
8392
+ const version = "3.5.13";
8310
8393
  const warn = warn$1 ;
8311
8394
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
8312
8395
  const devtools = devtools$1 ;