@vue/compat 3.2.13 → 3.2.17

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/vue.cjs.js CHANGED
@@ -1076,8 +1076,6 @@ const shallowReadonlyHandlers = /*#__PURE__*/ extend({}, readonlyHandlers, {
1076
1076
  get: shallowReadonlyGet
1077
1077
  });
1078
1078
 
1079
- const toReactive = (value) => isObject(value) ? reactive(value) : value;
1080
- const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1081
1079
  const toShallow = (value) => value;
1082
1080
  const getProto = (v) => Reflect.getPrototypeOf(v);
1083
1081
  function get$1(target, key, isReadonly = false, isShallow = false) {
@@ -1465,7 +1463,9 @@ function toRaw(observed) {
1465
1463
  function markRaw(value) {
1466
1464
  def(value, "__v_skip" /* SKIP */, true);
1467
1465
  return value;
1468
- }
1466
+ }
1467
+ const toReactive = (value) => isObject(value) ? reactive(value) : value;
1468
+ const toReadonly = (value) => isObject(value) ? readonly(value) : value;
1469
1469
 
1470
1470
  function trackRefValue(ref) {
1471
1471
  if (isTracking()) {
@@ -1495,7 +1495,6 @@ function triggerRefValue(ref, newVal) {
1495
1495
  }
1496
1496
  }
1497
1497
  }
1498
- const convert = (val) => isObject(val) ? reactive(val) : val;
1499
1498
  function isRef(r) {
1500
1499
  return Boolean(r && r.__v_isRef === true);
1501
1500
  }
@@ -1505,13 +1504,19 @@ function ref(value) {
1505
1504
  function shallowRef(value) {
1506
1505
  return createRef(value, true);
1507
1506
  }
1507
+ function createRef(rawValue, shallow) {
1508
+ if (isRef(rawValue)) {
1509
+ return rawValue;
1510
+ }
1511
+ return new RefImpl(rawValue, shallow);
1512
+ }
1508
1513
  class RefImpl {
1509
1514
  constructor(value, _shallow) {
1510
1515
  this._shallow = _shallow;
1511
1516
  this.dep = undefined;
1512
1517
  this.__v_isRef = true;
1513
1518
  this._rawValue = _shallow ? value : toRaw(value);
1514
- this._value = _shallow ? value : convert(value);
1519
+ this._value = _shallow ? value : toReactive(value);
1515
1520
  }
1516
1521
  get value() {
1517
1522
  trackRefValue(this);
@@ -1521,17 +1526,11 @@ class RefImpl {
1521
1526
  newVal = this._shallow ? newVal : toRaw(newVal);
1522
1527
  if (hasChanged(newVal, this._rawValue)) {
1523
1528
  this._rawValue = newVal;
1524
- this._value = this._shallow ? newVal : convert(newVal);
1529
+ this._value = this._shallow ? newVal : toReactive(newVal);
1525
1530
  triggerRefValue(this, newVal);
1526
1531
  }
1527
1532
  }
1528
1533
  }
1529
- function createRef(rawValue, shallow) {
1530
- if (isRef(rawValue)) {
1531
- return rawValue;
1532
- }
1533
- return new RefImpl(rawValue, shallow);
1534
- }
1535
1534
  function triggerRef(ref) {
1536
1535
  triggerRefValue(ref, ref.value );
1537
1536
  }
@@ -1662,14 +1661,7 @@ const hmrDirtyComponents = new Set();
1662
1661
  // Note: for a component to be eligible for HMR it also needs the __hmrId option
1663
1662
  // to be set so that its instances can be registered / removed.
1664
1663
  {
1665
- const globalObject = typeof global !== 'undefined'
1666
- ? global
1667
- : typeof self !== 'undefined'
1668
- ? self
1669
- : typeof window !== 'undefined'
1670
- ? window
1671
- : {};
1672
- globalObject.__VUE_HMR_RUNTIME__ = {
1664
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
1673
1665
  createRecord: tryWrap(createRecord),
1674
1666
  rerender: tryWrap(rerender),
1675
1667
  reload: tryWrap(reload)
@@ -1790,14 +1782,32 @@ function tryWrap(fn) {
1790
1782
  }
1791
1783
 
1792
1784
  let devtools;
1793
- function setDevtoolsHook(hook) {
1785
+ let buffer = [];
1786
+ function emit(event, ...args) {
1787
+ if (devtools) {
1788
+ devtools.emit(event, ...args);
1789
+ }
1790
+ else {
1791
+ buffer.push({ event, args });
1792
+ }
1793
+ }
1794
+ function setDevtoolsHook(hook, target) {
1794
1795
  devtools = hook;
1796
+ if (devtools) {
1797
+ devtools.enabled = true;
1798
+ buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1799
+ buffer = [];
1800
+ }
1801
+ else {
1802
+ const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1803
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1804
+ replay.push((newHook) => {
1805
+ setDevtoolsHook(newHook, target);
1806
+ });
1807
+ }
1795
1808
  }
1796
1809
  function devtoolsInitApp(app, version) {
1797
- // TODO queue if devtools is undefined
1798
- if (!devtools)
1799
- return;
1800
- devtools.emit("app:init" /* APP_INIT */, app, version, {
1810
+ emit("app:init" /* APP_INIT */, app, version, {
1801
1811
  Fragment,
1802
1812
  Text,
1803
1813
  Comment,
@@ -1805,9 +1815,7 @@ function devtoolsInitApp(app, version) {
1805
1815
  });
1806
1816
  }
1807
1817
  function devtoolsUnmountApp(app) {
1808
- if (!devtools)
1809
- return;
1810
- devtools.emit("app:unmount" /* APP_UNMOUNT */, app);
1818
+ emit("app:unmount" /* APP_UNMOUNT */, app);
1811
1819
  }
1812
1820
  const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* COMPONENT_ADDED */);
1813
1821
  const devtoolsComponentUpdated =
@@ -1816,24 +1824,18 @@ const devtoolsComponentRemoved =
1816
1824
  /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* COMPONENT_REMOVED */);
1817
1825
  function createDevtoolsComponentHook(hook) {
1818
1826
  return (component) => {
1819
- if (!devtools)
1820
- return;
1821
- devtools.emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
1827
+ emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
1822
1828
  };
1823
1829
  }
1824
1830
  const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* PERFORMANCE_START */);
1825
1831
  const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* PERFORMANCE_END */);
1826
1832
  function createDevtoolsPerformanceHook(hook) {
1827
1833
  return (component, type, time) => {
1828
- if (!devtools)
1829
- return;
1830
- devtools.emit(hook, component.appContext.app, component.uid, component, type, time);
1834
+ emit(hook, component.appContext.app, component.uid, component, type, time);
1831
1835
  };
1832
1836
  }
1833
1837
  function devtoolsComponentEmit(component, event, params) {
1834
- if (!devtools)
1835
- return;
1836
- devtools.emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
1838
+ emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params);
1837
1839
  }
1838
1840
 
1839
1841
  const deprecationData = {
@@ -2293,7 +2295,7 @@ function off(instance, event, fn) {
2293
2295
  events[event] = cbs.filter(cb => !(cb === fn || cb.fn === fn));
2294
2296
  return vm;
2295
2297
  }
2296
- function emit(instance, event, args) {
2298
+ function emit$1(instance, event, args) {
2297
2299
  const cbs = getRegistry(instance)[event];
2298
2300
  if (cbs) {
2299
2301
  callWithAsyncErrorHandling(cbs.map(cb => cb.bind(instance.proxy)), instance, 6 /* COMPONENT_EVENT_HANDLER */, args);
@@ -2346,7 +2348,7 @@ function compatModelEmit(instance, event, args) {
2346
2348
  }
2347
2349
  }
2348
2350
 
2349
- function emit$1(instance, event, ...rawArgs) {
2351
+ function emit$2(instance, event, ...rawArgs) {
2350
2352
  const props = instance.vnode.props || EMPTY_OBJ;
2351
2353
  {
2352
2354
  const { emitsOptions, propsOptions: [propsOptions] } = instance;
@@ -2422,7 +2424,7 @@ function emit$1(instance, event, ...rawArgs) {
2422
2424
  }
2423
2425
  {
2424
2426
  compatModelEmit(instance, event, args);
2425
- return emit(instance, event, args);
2427
+ return emit$1(instance, event, args);
2426
2428
  }
2427
2429
  }
2428
2430
  function normalizeEmitsOptions(comp, appContext, asMixin = false) {
@@ -5421,7 +5423,7 @@ function createCompatVue(createApp, createSingletonApp) {
5421
5423
  return vm;
5422
5424
  }
5423
5425
  }
5424
- Vue.version = "3.2.13";
5426
+ Vue.version = "3.2.17";
5425
5427
  Vue.config = singletonApp.config;
5426
5428
  Vue.use = (p, ...options) => {
5427
5429
  if (p && isFunction(p.install)) {
@@ -6419,10 +6421,10 @@ function createHydrationRenderer(options) {
6419
6421
  }
6420
6422
  // implementation
6421
6423
  function baseCreateRenderer(options, createHydrationFns) {
6424
+ const target = getGlobalThis();
6425
+ target.__VUE__ = true;
6422
6426
  {
6423
- const target = getGlobalThis();
6424
- target.__VUE__ = true;
6425
- setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__);
6427
+ setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
6426
6428
  }
6427
6429
  const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, setScopeId: hostSetScopeId = NOOP, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
6428
6430
  // Note: functions inside this closure should use `const xxx = () => {}`
@@ -9607,7 +9609,7 @@ function createComponentInstance(vnode, parent, suspense) {
9607
9609
  instance.ctx = createDevRenderContext(instance);
9608
9610
  }
9609
9611
  instance.root = parent ? parent.root : instance;
9610
- instance.emit = emit$1.bind(null, instance);
9612
+ instance.emit = emit$2.bind(null, instance);
9611
9613
  // apply custom element special handling
9612
9614
  if (vnode.ce) {
9613
9615
  vnode.ce(instance);
@@ -9772,19 +9774,11 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
9772
9774
  }
9773
9775
  }
9774
9776
  // template / render function normalization
9775
- if (isSSR) {
9776
- // 1. the render function may already exist, returned by `setup`
9777
- // 2. otherwise try to use the `Component.render`
9778
- // 3. if the component doesn't have a render function,
9779
- // set `instance.render` to NOOP so that it can inherit the render
9780
- // function from mixins/extend
9781
- instance.render = (instance.render ||
9782
- Component.render ||
9783
- NOOP);
9784
- }
9785
- else if (!instance.render) {
9786
- // could be set from setup()
9787
- if (compile && !Component.render) {
9777
+ // could be already set when returned from setup()
9778
+ if (!instance.render) {
9779
+ // only do on-the-fly compile if not in SSR - SSR on-the-fly compliation
9780
+ // is done by server-renderer
9781
+ if (!isSSR && compile && !Component.render) {
9788
9782
  const template = (instance.vnode.props &&
9789
9783
  instance.vnode.props['inline-template']) ||
9790
9784
  Component.template;
@@ -11021,7 +11015,7 @@ function isMemoSame(cached, memo) {
11021
11015
  }
11022
11016
 
11023
11017
  // Core API ------------------------------------------------------------------
11024
- const version = "3.2.13";
11018
+ const version = "3.2.17";
11025
11019
  const _ssrUtils = {
11026
11020
  createComponentInstance,
11027
11021
  setupComponent,
@@ -12469,8 +12463,9 @@ function callModelHook(el, binding, vnode, prevVNode, hook) {
12469
12463
  const fn = modelToUse[hook];
12470
12464
  fn && fn(el, binding, vnode, prevVNode);
12471
12465
  }
12472
- // SSR vnode transforms
12473
- {
12466
+ // SSR vnode transforms, only used when user includes client-oriented render
12467
+ // function in SSR
12468
+ function initVModelForSSR() {
12474
12469
  vModelText.getSSRProps = ({ value }) => ({ value });
12475
12470
  vModelRadio.getSSRProps = ({ value }, vnode) => {
12476
12471
  if (vnode.props && looseEqual(vnode.props.value, value)) {
@@ -12618,15 +12613,17 @@ const vShow = {
12618
12613
  setDisplay(el, value);
12619
12614
  }
12620
12615
  };
12621
- {
12616
+ function setDisplay(el, value) {
12617
+ el.style.display = value ? el._vod : 'none';
12618
+ }
12619
+ // SSR vnode transforms, only used when user includes client-oriented render
12620
+ // function in SSR
12621
+ function initVShowForSSR() {
12622
12622
  vShow.getSSRProps = ({ value }) => {
12623
12623
  if (!value) {
12624
12624
  return { style: { display: 'none' } };
12625
12625
  }
12626
12626
  };
12627
- }
12628
- function setDisplay(el, value) {
12629
- el.style.display = value ? el._vod : 'none';
12630
12627
  }
12631
12628
 
12632
12629
  const rendererOptions = extend({ patchProp }, nodeOps);
@@ -12761,7 +12758,19 @@ function normalizeContainer(container) {
12761
12758
  warn$1(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
12762
12759
  }
12763
12760
  return container;
12764
- }
12761
+ }
12762
+ let ssrDirectiveInitialized = false;
12763
+ /**
12764
+ * @internal
12765
+ */
12766
+ const initDirectivesForSSR = () => {
12767
+ if (!ssrDirectiveInitialized) {
12768
+ ssrDirectiveInitialized = true;
12769
+ initVModelForSSR();
12770
+ initVShowForSSR();
12771
+ }
12772
+ }
12773
+ ;
12765
12774
 
12766
12775
  var runtimeDom = /*#__PURE__*/Object.freeze({
12767
12776
  __proto__: null,
@@ -12769,6 +12778,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
12769
12778
  hydrate: hydrate,
12770
12779
  createApp: createApp,
12771
12780
  createSSRApp: createSSRApp,
12781
+ initDirectivesForSSR: initDirectivesForSSR,
12772
12782
  defineCustomElement: defineCustomElement,
12773
12783
  defineSSRCustomElement: defineSSRCustomElement,
12774
12784
  VueElement: VueElement,
@@ -13005,7 +13015,7 @@ const errorMessages = {
13005
13015
  [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
13006
13016
  [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
13007
13017
  [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
13008
- // just to fullfill types
13018
+ // just to fulfill types
13009
13019
  [50 /* __EXTEND_POINT__ */]: ``
13010
13020
  };
13011
13021
 
@@ -13250,27 +13260,22 @@ function isCoreComponent(tag) {
13250
13260
  }
13251
13261
  const nonIdentifierRE = /^\d|[^\$\w]/;
13252
13262
  const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
13253
- const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/;
13254
13263
  const isMemberExpressionNode = (path, context) => {
13255
- path = path.trim();
13256
- if (!validFirstIdentCharRE.test(path[0])) {
13257
- return false;
13258
- }
13259
- try {
13260
- let ret = parser.parseExpression(path, {
13261
- plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
13262
- });
13263
- if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
13264
- ret = ret.expression;
13264
+ try {
13265
+ let ret = parser.parseExpression(path, {
13266
+ plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
13267
+ });
13268
+ if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
13269
+ ret = ret.expression;
13270
+ }
13271
+ return (ret.type === 'MemberExpression' ||
13272
+ ret.type === 'OptionalMemberExpression' ||
13273
+ ret.type === 'Identifier');
13265
13274
  }
13266
- return (ret.type === 'MemberExpression' ||
13267
- ret.type === 'OptionalMemberExpression' ||
13268
- ret.type === 'Identifier');
13269
- }
13270
- catch (e) {
13271
- return false;
13272
- }
13273
- };
13275
+ catch (e) {
13276
+ return false;
13277
+ }
13278
+ };
13274
13279
  const isMemberExpression = isMemberExpressionNode;
13275
13280
  function getInnerRange(loc, offset, length) {
13276
13281
  const source = loc.source.substr(offset, length);
@@ -15058,7 +15063,7 @@ function createStructuralDirectiveTransform(name, fn) {
15058
15063
  }
15059
15064
 
15060
15065
  const PURE_ANNOTATION = `/*#__PURE__*/`;
15061
- function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
15066
+ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap: sourceMap$1 = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
15062
15067
  const context = {
15063
15068
  mode,
15064
15069
  prefixIdentifiers,
@@ -15068,6 +15073,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
15068
15073
  optimizeImports,
15069
15074
  runtimeGlobalName,
15070
15075
  runtimeModuleName,
15076
+ ssrRuntimeModuleName,
15071
15077
  ssr,
15072
15078
  isTS,
15073
15079
  inSSR,
@@ -15244,7 +15250,7 @@ function generate(ast, options = {}) {
15244
15250
  };
15245
15251
  }
15246
15252
  function genFunctionPreamble(ast, context) {
15247
- const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
15253
+ const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
15248
15254
  const VueBinding = ssr
15249
15255
  ? `require(${JSON.stringify(runtimeModuleName)})`
15250
15256
  : runtimeGlobalName;
@@ -15284,14 +15290,14 @@ function genFunctionPreamble(ast, context) {
15284
15290
  // ssr guarantees prefixIdentifier: true
15285
15291
  push(`const { ${ast.ssrHelpers
15286
15292
  .map(aliasHelper)
15287
- .join(', ')} } = require("@vue/server-renderer")\n`);
15293
+ .join(', ')} } = require("${ssrRuntimeModuleName}")\n`);
15288
15294
  }
15289
15295
  genHoists(ast.hoists, context);
15290
15296
  newline();
15291
15297
  push(`return `);
15292
15298
  }
15293
15299
  function genModulePreamble(ast, context, genScopeId, inline) {
15294
- const { push, newline, optimizeImports, runtimeModuleName } = context;
15300
+ const { push, newline, optimizeImports, runtimeModuleName, ssrRuntimeModuleName } = context;
15295
15301
  if (genScopeId && ast.hoists.length) {
15296
15302
  ast.helpers.push(PUSH_SCOPE_ID, POP_SCOPE_ID);
15297
15303
  }
@@ -15319,7 +15325,7 @@ function genModulePreamble(ast, context, genScopeId, inline) {
15319
15325
  if (ast.ssrHelpers && ast.ssrHelpers.length) {
15320
15326
  push(`import { ${ast.ssrHelpers
15321
15327
  .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
15322
- .join(', ')} } from "@vue/server-renderer"\n`);
15328
+ .join(', ')} } from "${ssrRuntimeModuleName}"\n`);
15323
15329
  }
15324
15330
  if (ast.imports.length) {
15325
15331
  genImports(ast.imports, context);
@@ -17427,7 +17433,7 @@ function buildProps(node, context, props = node.props, ssr = false) {
17427
17433
  hasRef = true;
17428
17434
  // in inline mode there is no setupState object, so we can't use string
17429
17435
  // keys to set the ref. Instead, we need to transform it to pass the
17430
- // acrtual ref instead.
17436
+ // actual ref instead.
17431
17437
  if (context.inline && (value === null || value === void 0 ? void 0 : value.content)) {
17432
17438
  valueNode = createFunctionExpression(['_value', '_refs']);
17433
17439
  valueNode.body = createBlockStatement(processInlineRef(context, value.content));
@@ -18151,9 +18157,9 @@ const transformModel = (dir, node, context) => {
18151
18157
  if (bindingType === "setup-ref" /* SETUP_REF */) {
18152
18158
  // v-model used on known ref.
18153
18159
  assignmentExp = createCompoundExpression([
18154
- `${eventArg} => (`,
18160
+ `${eventArg} => ((`,
18155
18161
  createSimpleExpression(rawExp, false, exp.loc),
18156
- `.value = $event)`
18162
+ `).value = $event)`
18157
18163
  ]);
18158
18164
  }
18159
18165
  else {
@@ -18161,17 +18167,17 @@ const transformModel = (dir, node, context) => {
18161
18167
  // the assignment needs to check whether the binding is actually a ref.
18162
18168
  const altAssignment = bindingType === "setup-let" /* SETUP_LET */ ? `${rawExp} = $event` : `null`;
18163
18169
  assignmentExp = createCompoundExpression([
18164
- `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? `,
18170
+ `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
18165
18171
  createSimpleExpression(rawExp, false, exp.loc),
18166
- `.value = $event : ${altAssignment})`
18172
+ `).value = $event : ${altAssignment})`
18167
18173
  ]);
18168
18174
  }
18169
18175
  }
18170
18176
  else {
18171
18177
  assignmentExp = createCompoundExpression([
18172
- `${eventArg} => (`,
18178
+ `${eventArg} => ((`,
18173
18179
  exp,
18174
- ` = $event)`
18180
+ `) = $event)`
18175
18181
  ]);
18176
18182
  }
18177
18183
  const props = [