@vue/compat 3.6.0-alpha.5 → 3.6.0-alpha.7

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
- * @vue/compat v3.6.0-alpha.5
2
+ * @vue/compat v3.6.0-alpha.7
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1874,6 +1874,16 @@ class EffectScope {
1874
1874
  return;
1875
1875
  }
1876
1876
  this.flags = 1024;
1877
+ this.reset();
1878
+ const sub = this.subs;
1879
+ if (sub !== void 0) {
1880
+ unlink(sub);
1881
+ }
1882
+ }
1883
+ /**
1884
+ * @internal
1885
+ */
1886
+ reset() {
1877
1887
  let dep = this.deps;
1878
1888
  while (dep !== void 0) {
1879
1889
  const node = dep.dep;
@@ -1884,10 +1894,6 @@ class EffectScope {
1884
1894
  dep = unlink(dep, this);
1885
1895
  }
1886
1896
  }
1887
- const sub = this.subs;
1888
- if (sub !== void 0) {
1889
- unlink(sub);
1890
- }
1891
1897
  cleanup(this);
1892
1898
  }
1893
1899
  }
@@ -2189,9 +2195,119 @@ function traverse(value, depth = Infinity, seen) {
2189
2195
  return value;
2190
2196
  }
2191
2197
 
2198
+ const stack$1 = [];
2192
2199
  function pushWarningContext(ctx) {
2200
+ stack$1.push(ctx);
2193
2201
  }
2194
2202
  function popWarningContext() {
2203
+ stack$1.pop();
2204
+ }
2205
+ let isWarning = false;
2206
+ function warn$2(msg, ...args) {
2207
+ if (isWarning) return;
2208
+ isWarning = true;
2209
+ const prevSub = setActiveSub();
2210
+ const entry = stack$1.length ? stack$1[stack$1.length - 1] : null;
2211
+ const instance = isVNode(entry) ? entry.component : entry;
2212
+ const appWarnHandler = instance && instance.appContext.config.warnHandler;
2213
+ const trace = getComponentTrace();
2214
+ if (appWarnHandler) {
2215
+ callWithErrorHandling(
2216
+ appWarnHandler,
2217
+ instance,
2218
+ 11,
2219
+ [
2220
+ // eslint-disable-next-line no-restricted-syntax
2221
+ msg + args.map((a) => {
2222
+ var _a, _b;
2223
+ return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
2224
+ }).join(""),
2225
+ instance && instance.proxy || instance,
2226
+ trace.map(
2227
+ ({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`
2228
+ ).join("\n"),
2229
+ trace
2230
+ ]
2231
+ );
2232
+ } else {
2233
+ const warnArgs = [`[Vue warn]: ${msg}`, ...args];
2234
+ if (trace.length && // avoid spamming console during tests
2235
+ true) {
2236
+ warnArgs.push(`
2237
+ `, ...formatTrace(trace));
2238
+ }
2239
+ console.warn(...warnArgs);
2240
+ }
2241
+ setActiveSub(prevSub);
2242
+ isWarning = false;
2243
+ }
2244
+ function getComponentTrace() {
2245
+ let currentCtx = stack$1[stack$1.length - 1];
2246
+ if (!currentCtx) {
2247
+ return [];
2248
+ }
2249
+ const normalizedStack = [];
2250
+ while (currentCtx) {
2251
+ const last = normalizedStack[0];
2252
+ if (last && last.ctx === currentCtx) {
2253
+ last.recurseCount++;
2254
+ } else {
2255
+ normalizedStack.push({
2256
+ ctx: currentCtx,
2257
+ recurseCount: 0
2258
+ });
2259
+ }
2260
+ if (isVNode(currentCtx)) {
2261
+ const parent = currentCtx.component && currentCtx.component.parent;
2262
+ currentCtx = parent && parent.vnode || parent;
2263
+ } else {
2264
+ currentCtx = currentCtx.parent;
2265
+ }
2266
+ }
2267
+ return normalizedStack;
2268
+ }
2269
+ function formatTrace(trace) {
2270
+ const logs = [];
2271
+ trace.forEach((entry, i) => {
2272
+ logs.push(...i === 0 ? [] : [`
2273
+ `], ...formatTraceEntry(entry));
2274
+ });
2275
+ return logs;
2276
+ }
2277
+ function formatTraceEntry({ ctx, recurseCount }) {
2278
+ const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
2279
+ const instance = isVNode(ctx) ? ctx.component : ctx;
2280
+ const isRoot = instance ? instance.parent == null : false;
2281
+ const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
2282
+ const close = `>` + postfix;
2283
+ return ctx.props ? [open, ...formatProps(ctx.props), close] : [open + close];
2284
+ }
2285
+ function formatProps(props) {
2286
+ const res = [];
2287
+ const keys = Object.keys(props);
2288
+ keys.slice(0, 3).forEach((key) => {
2289
+ res.push(...formatProp(key, props[key]));
2290
+ });
2291
+ if (keys.length > 3) {
2292
+ res.push(` ...`);
2293
+ }
2294
+ return res;
2295
+ }
2296
+ function formatProp(key, value, raw) {
2297
+ if (isString(value)) {
2298
+ value = JSON.stringify(value);
2299
+ return raw ? value : [`${key}=${value}`];
2300
+ } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
2301
+ return raw ? value : [`${key}=${value}`];
2302
+ } else if (isRef(value)) {
2303
+ value = formatProp(key, toRaw(value.value), true);
2304
+ return raw ? value : [`${key}=Ref<`, value, `>`];
2305
+ } else if (isFunction(value)) {
2306
+ return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
2307
+ } else {
2308
+ value = toRaw(value);
2309
+ return raw ? value : [`${key}=`, value];
2310
+ }
2195
2311
  }
2196
2312
  function assertNumber(val, type) {
2197
2313
  return;
@@ -3232,7 +3348,7 @@ const BaseTransitionPropsValidators = {
3232
3348
  onAppearCancelled: TransitionHookValidator
3233
3349
  };
3234
3350
  const recursiveGetSubtree = (instance) => {
3235
- const subTree = instance.type.__vapor ? instance.block : instance.subTree;
3351
+ const subTree = isVaporComponent(instance.type) ? instance.block : instance.subTree;
3236
3352
  return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
3237
3353
  };
3238
3354
  const BaseTransitionImpl = {
@@ -3534,7 +3650,7 @@ function getInnerChild$1(vnode) {
3534
3650
  }
3535
3651
  function setTransitionHooks(vnode, hooks) {
3536
3652
  if (vnode.shapeFlag & 6 && vnode.component) {
3537
- if (vnode.type.__vapor) {
3653
+ if (isVaporComponent(vnode.type)) {
3538
3654
  getVaporInterface(vnode.component, vnode).setTransitionHooks(
3539
3655
  vnode.component,
3540
3656
  hooks
@@ -3884,7 +4000,8 @@ function createHydrationFunctions(rendererInternals) {
3884
4000
  node,
3885
4001
  container,
3886
4002
  null,
3887
- parentComponent
4003
+ parentComponent,
4004
+ parentSuspense
3888
4005
  );
3889
4006
  } else {
3890
4007
  mountComponent(
@@ -6198,7 +6315,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6198
6315
  return vm;
6199
6316
  }
6200
6317
  }
6201
- Vue.version = `2.6.14-compat:${"3.6.0-alpha.5"}`;
6318
+ Vue.version = `2.6.14-compat:${"3.6.0-alpha.7"}`;
6202
6319
  Vue.config = singletonApp.config;
6203
6320
  Vue.use = (plugin, ...options) => {
6204
6321
  if (plugin && isFunction(plugin.install)) {
@@ -7040,7 +7157,7 @@ function renderComponentRoot(instance) {
7040
7157
  const proxyToUse = withProxy || proxy;
7041
7158
  const thisProxy = false ? new Proxy(proxyToUse, {
7042
7159
  get(target, key, receiver) {
7043
- warn(
7160
+ warn$2(
7044
7161
  `Property '${String(
7045
7162
  key
7046
7163
  )}' was accessed via 'this'. Avoid using 'this' in templates.`
@@ -7742,7 +7859,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7742
7859
  );
7743
7860
  break;
7744
7861
  case VaporSlot:
7745
- getVaporInterface(parentComponent, n2).slot(n1, n2, container, anchor);
7862
+ getVaporInterface(parentComponent, n2).slot(
7863
+ n1,
7864
+ n2,
7865
+ container,
7866
+ anchor,
7867
+ parentComponent
7868
+ );
7746
7869
  break;
7747
7870
  default:
7748
7871
  if (shapeFlag & 1) {
@@ -8216,7 +8339,8 @@ function baseCreateRenderer(options, createHydrationFns) {
8216
8339
  n2,
8217
8340
  container,
8218
8341
  anchor,
8219
- parentComponent
8342
+ parentComponent,
8343
+ parentSuspense
8220
8344
  );
8221
8345
  }
8222
8346
  } else {
@@ -8264,7 +8388,36 @@ function baseCreateRenderer(options, createHydrationFns) {
8264
8388
  setupComponent(instance, false, optimized);
8265
8389
  }
8266
8390
  if (instance.asyncDep) {
8267
- parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
8391
+ if (parentSuspense) {
8392
+ const hydratedEl = instance.vnode.el;
8393
+ parentSuspense.registerDep(instance, (setupResult) => {
8394
+ const { vnode } = instance;
8395
+ handleSetupResult(instance, setupResult, false);
8396
+ if (hydratedEl) {
8397
+ vnode.el = hydratedEl;
8398
+ }
8399
+ const placeholder = !hydratedEl && instance.subTree.el;
8400
+ setupRenderEffect(
8401
+ instance,
8402
+ vnode,
8403
+ // component may have been moved before resolve.
8404
+ // if this is not a hydration, instance.subTree will be the comment
8405
+ // placeholder.
8406
+ hostParentNode(hydratedEl || instance.subTree.el),
8407
+ // anchor will not be used if this is hydration, so only need to
8408
+ // consider the comment placeholder case.
8409
+ hydratedEl ? null : getNextHostNode(instance.subTree),
8410
+ parentSuspense,
8411
+ namespace,
8412
+ optimized
8413
+ );
8414
+ if (placeholder) {
8415
+ vnode.placeholder = null;
8416
+ hostRemove(placeholder);
8417
+ }
8418
+ updateHOCHostEl(instance, vnode.el);
8419
+ });
8420
+ }
8268
8421
  if (!initialVNode.el) {
8269
8422
  const placeholder = instance.subTree = createVNode(Comment);
8270
8423
  processCommentNode(null, placeholder, container, anchor);
@@ -8803,7 +8956,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8803
8956
  const move = (vnode, container, anchor, moveType, parentComponent, parentSuspense = null) => {
8804
8957
  const { el, type, transition, children, shapeFlag } = vnode;
8805
8958
  if (shapeFlag & 6) {
8806
- if (type.__vapor) {
8959
+ if (isVaporComponent(type)) {
8807
8960
  getVaporInterface(parentComponent, vnode).move(vnode, container, anchor);
8808
8961
  } else {
8809
8962
  move(
@@ -8913,7 +9066,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8913
9066
  parentComponent.renderCache[cacheIndex] = void 0;
8914
9067
  }
8915
9068
  if (shapeFlag & 256) {
8916
- if (vnode.type.__vapor) {
9069
+ if (isVaporComponent(vnode.type)) {
8917
9070
  getVaporInterface(parentComponent, vnode).deactivate(
8918
9071
  vnode,
8919
9072
  parentComponent.ctx.getStorageContainer()
@@ -8930,7 +9083,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8930
9083
  invokeVNodeHook(vnodeHook, parentComponent, vnode);
8931
9084
  }
8932
9085
  if (shapeFlag & 6) {
8933
- if (type.__vapor) {
9086
+ if (isVaporComponent(type)) {
8934
9087
  getVaporInterface(parentComponent, vnode).unmount(vnode, doRemove);
8935
9088
  return;
8936
9089
  } else {
@@ -9058,7 +9211,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9058
9211
  };
9059
9212
  const getNextHostNode = (vnode) => {
9060
9213
  if (vnode.shapeFlag & 6) {
9061
- if (vnode.type.__vapor) {
9214
+ if (isVaporComponent(vnode.type)) {
9062
9215
  return hostNextSibling(vnode.anchor);
9063
9216
  }
9064
9217
  return getNextHostNode(vnode.component.subTree);
@@ -9231,6 +9384,9 @@ function getVaporInterface(instance, vnode) {
9231
9384
  const res = ctx && ctx.vapor;
9232
9385
  return res;
9233
9386
  }
9387
+ function isVaporComponent(type) {
9388
+ return type.__vapor;
9389
+ }
9234
9390
  function getInheritedScopeIds(vnode, parentComponent) {
9235
9391
  const inheritedScopeIds = [];
9236
9392
  let currentParent = parentComponent;
@@ -9520,7 +9676,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9520
9676
  m: move,
9521
9677
  um: unmount,
9522
9678
  n: next,
9523
- o: { parentNode, remove }
9679
+ o: { parentNode }
9524
9680
  } = rendererInternals;
9525
9681
  let parentSuspenseId;
9526
9682
  const isSuspensible = isVNodeSuspensible(vnode);
@@ -9680,12 +9836,11 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9680
9836
  next() {
9681
9837
  return suspense.activeBranch && next(suspense.activeBranch);
9682
9838
  },
9683
- registerDep(instance, setupRenderEffect, optimized2) {
9839
+ registerDep(instance, onResolve) {
9684
9840
  const isInPendingSuspense = !!suspense.pendingBranch;
9685
9841
  if (isInPendingSuspense) {
9686
9842
  suspense.deps++;
9687
9843
  }
9688
- const hydratedEl = instance.vnode.el;
9689
9844
  instance.asyncDep.catch((err) => {
9690
9845
  handleError(err, instance, 0);
9691
9846
  }).then((asyncSetupResult) => {
@@ -9693,31 +9848,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
9693
9848
  return;
9694
9849
  }
9695
9850
  instance.asyncResolved = true;
9696
- const { vnode: vnode2 } = instance;
9697
- handleSetupResult(instance, asyncSetupResult, false);
9698
- if (hydratedEl) {
9699
- vnode2.el = hydratedEl;
9700
- }
9701
- const placeholder = !hydratedEl && instance.subTree.el;
9702
- setupRenderEffect(
9703
- instance,
9704
- vnode2,
9705
- // component may have been moved before resolve.
9706
- // if this is not a hydration, instance.subTree will be the comment
9707
- // placeholder.
9708
- parentNode(hydratedEl || instance.subTree.el),
9709
- // anchor will not be used if this is hydration, so only need to
9710
- // consider the comment placeholder case.
9711
- hydratedEl ? null : next(instance.subTree),
9712
- suspense,
9713
- namespace,
9714
- optimized2
9715
- );
9716
- if (placeholder) {
9717
- vnode2.placeholder = null;
9718
- remove(placeholder);
9719
- }
9720
- updateHOCHostEl(instance, vnode2.el);
9851
+ onResolve(asyncSetupResult);
9721
9852
  if (isInPendingSuspense && --suspense.deps === 0) {
9722
9853
  suspense.resolve();
9723
9854
  }
@@ -10547,9 +10678,33 @@ function getComponentPublicInstance(instance) {
10547
10678
  return instance.proxy;
10548
10679
  }
10549
10680
  }
10681
+ const classifyRE = /(?:^|[-_])\w/g;
10682
+ const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
10550
10683
  function getComponentName(Component, includeInferred = true) {
10551
10684
  return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
10552
10685
  }
10686
+ function formatComponentName(instance, Component, isRoot = false) {
10687
+ let name = getComponentName(Component);
10688
+ if (!name && Component.__file) {
10689
+ const match = Component.__file.match(/([^/\\]+)\.\w+$/);
10690
+ if (match) {
10691
+ name = match[1];
10692
+ }
10693
+ }
10694
+ if (!name && instance) {
10695
+ const inferFromRegistry = (registry) => {
10696
+ for (const key in registry) {
10697
+ if (registry[key] === Component) {
10698
+ return key;
10699
+ }
10700
+ }
10701
+ };
10702
+ name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(
10703
+ instance.parent.type.components
10704
+ ) || inferFromRegistry(instance.appContext.components);
10705
+ }
10706
+ return name ? classify(name) : isRoot ? `App` : `Anonymous`;
10707
+ }
10553
10708
  function isClassComponent(value) {
10554
10709
  return isFunction(value) && "__vccOpts" in value;
10555
10710
  }
@@ -10616,7 +10771,7 @@ function isMemoSame(cached, memo) {
10616
10771
  return true;
10617
10772
  }
10618
10773
 
10619
- const version = "3.6.0-alpha.5";
10774
+ const version = "3.6.0-alpha.7";
10620
10775
  const warn$1 = NOOP;
10621
10776
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
10622
10777
  const devtools = void 0;
@@ -19171,7 +19326,9 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
19171
19326
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
19172
19327
  );
19173
19328
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
19174
- const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
19329
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(
19330
+ `onkeyup,onkeydown,onkeypress`
19331
+ );
19175
19332
  const resolveModifiers = (key, modifiers, context, loc) => {
19176
19333
  const keyModifiers = [];
19177
19334
  const nonKeyModifiers = [];