@vue/compat 3.6.0-alpha.3 → 3.6.0-alpha.4

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.3
2
+ * @vue/compat v3.6.0-alpha.4
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -84,6 +84,9 @@ var Vue = (function () {
84
84
  return s;
85
85
  }
86
86
  );
87
+ const getModifierPropName = (name) => {
88
+ return `${name === "modelValue" || name === "model-value" ? "model" : name}Modifiers${name === "model" ? "$" : ""}`;
89
+ };
87
90
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
88
91
  const invokeArrayFns = (fns, ...arg) => {
89
92
  for (let i = 0; i < fns.length; i++) {
@@ -2914,7 +2917,12 @@ var Vue = (function () {
2914
2917
  newComp = normalizeClassComponent(newComp);
2915
2918
  updateComponentDef(record.initialDef, newComp);
2916
2919
  const instances = [...record.instances];
2917
- if (newComp.__vapor) {
2920
+ if (newComp.__vapor && !instances.some((i) => i.ceReload)) {
2921
+ for (const instance of instances) {
2922
+ if (instance.root && instance.root.ce && instance !== instance.root) {
2923
+ instance.root.ce._removeChildStyle(instance.type);
2924
+ }
2925
+ }
2918
2926
  for (const instance of instances) {
2919
2927
  instance.hmrReload(newComp);
2920
2928
  }
@@ -7632,7 +7640,7 @@ If this is a native custom element, make sure to exclude it from component resol
7632
7640
  return vm;
7633
7641
  }
7634
7642
  }
7635
- Vue.version = `2.6.14-compat:${"3.6.0-alpha.3"}`;
7643
+ Vue.version = `2.6.14-compat:${"3.6.0-alpha.4"}`;
7636
7644
  Vue.config = singletonApp.config;
7637
7645
  Vue.use = (plugin, ...options) => {
7638
7646
  if (plugin && isFunction(plugin.install)) {
@@ -10809,7 +10817,7 @@ app.use(vaporInteropPlugin)
10809
10817
  return res;
10810
10818
  }
10811
10819
  const getModelModifiers = (props, modelName, getter) => {
10812
- return modelName === "modelValue" || modelName === "model-value" ? getter(props, "modelModifiers") : getter(props, `${modelName}Modifiers`) || getter(props, `${camelize(modelName)}Modifiers`) || getter(props, `${hyphenate(modelName)}Modifiers`);
10820
+ return getter(props, getModifierPropName(modelName)) || getter(props, `${camelize(modelName)}Modifiers`) || getter(props, `${hyphenate(modelName)}Modifiers`);
10813
10821
  };
10814
10822
 
10815
10823
  function emit(instance, event, ...rawArgs) {
@@ -12351,6 +12359,25 @@ Component that was made reactive: `,
12351
12359
  simpleSetCurrentInstance(instance);
12352
12360
  }
12353
12361
  };
12362
+ const internalOptions = ["ce", "type"];
12363
+ const useInstanceOption = (key, silent = false) => {
12364
+ const instance = getCurrentGenericInstance();
12365
+ if (!instance) {
12366
+ if (!silent) {
12367
+ warn$1(`useInstanceOption called without an active component instance.`);
12368
+ }
12369
+ return { hasInstance: false, value: void 0 };
12370
+ }
12371
+ if (!internalOptions.includes(key)) {
12372
+ {
12373
+ warn$1(
12374
+ `useInstanceOption only accepts ${internalOptions.map((k) => `'${k}'`).join(", ")} as key, got '${key}'.`
12375
+ );
12376
+ }
12377
+ return { hasInstance: true, value: void 0 };
12378
+ }
12379
+ return { hasInstance: true, value: instance[key] };
12380
+ };
12354
12381
 
12355
12382
  const emptyAppContext = createAppContext();
12356
12383
  let uid = 0;
@@ -12995,7 +13022,7 @@ Component that was made reactive: `,
12995
13022
  return true;
12996
13023
  }
12997
13024
 
12998
- const version = "3.6.0-alpha.3";
13025
+ const version = "3.6.0-alpha.4";
12999
13026
  const warn = warn$1 ;
13000
13027
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
13001
13028
  const devtools = devtools$1 ;
@@ -13907,12 +13934,9 @@ Expected function or array of functions, received type ${typeof value}.`
13907
13934
  });
13908
13935
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
13909
13936
  };
13910
- class VueElement extends BaseClass {
13911
- constructor(_def, _props = {}, _createApp = createApp) {
13937
+ class VueElementBase extends BaseClass {
13938
+ constructor(def, props = {}, createAppFn) {
13912
13939
  super();
13913
- this._def = _def;
13914
- this._props = _props;
13915
- this._createApp = _createApp;
13916
13940
  this._isVueCE = true;
13917
13941
  /**
13918
13942
  * @internal
@@ -13922,28 +13946,23 @@ Expected function or array of functions, received type ${typeof value}.`
13922
13946
  * @internal
13923
13947
  */
13924
13948
  this._app = null;
13925
- /**
13926
- * @internal
13927
- */
13928
- this._nonce = this._def.nonce;
13929
13949
  this._connected = false;
13930
13950
  this._resolved = false;
13931
- this._patching = false;
13932
- this._dirty = false;
13933
13951
  this._numberProps = null;
13934
13952
  this._styleChildren = /* @__PURE__ */ new WeakSet();
13953
+ this._patching = false;
13954
+ this._dirty = false;
13935
13955
  this._ob = null;
13936
- if (this.shadowRoot && _createApp !== createApp) {
13956
+ this._def = def;
13957
+ this._props = props;
13958
+ this._createApp = createAppFn;
13959
+ this._nonce = def.nonce;
13960
+ if (this._needsHydration()) {
13937
13961
  this._root = this.shadowRoot;
13938
13962
  } else {
13939
- if (this.shadowRoot) {
13940
- warn(
13941
- `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
13942
- );
13943
- }
13944
- if (_def.shadowRoot !== false) {
13963
+ if (def.shadowRoot !== false) {
13945
13964
  this.attachShadow(
13946
- extend({}, _def.shadowRootOptions, {
13965
+ extend({}, def.shadowRootOptions, {
13947
13966
  mode: "open"
13948
13967
  })
13949
13968
  );
@@ -13961,14 +13980,14 @@ Expected function or array of functions, received type ${typeof value}.`
13961
13980
  this._connected = true;
13962
13981
  let parent = this;
13963
13982
  while (parent = parent && (parent.parentNode || parent.host)) {
13964
- if (parent instanceof VueElement) {
13983
+ if (parent instanceof VueElementBase) {
13965
13984
  this._parent = parent;
13966
13985
  break;
13967
13986
  }
13968
13987
  }
13969
13988
  if (!this._instance) {
13970
13989
  if (this._resolved) {
13971
- this._mount(this._def);
13990
+ this._mountComponent(this._def);
13972
13991
  } else {
13973
13992
  if (parent && parent._pendingResolve) {
13974
13993
  this._pendingResolve = parent._pendingResolve.then(() => {
@@ -13981,20 +14000,6 @@ Expected function or array of functions, received type ${typeof value}.`
13981
14000
  }
13982
14001
  }
13983
14002
  }
13984
- _setParent(parent = this._parent) {
13985
- if (parent) {
13986
- this._instance.parent = parent._instance;
13987
- this._inheritParentContext(parent);
13988
- }
13989
- }
13990
- _inheritParentContext(parent = this._parent) {
13991
- if (parent && this._app) {
13992
- Object.setPrototypeOf(
13993
- this._app._context.provides,
13994
- parent._instance.provides
13995
- );
13996
- }
13997
- }
13998
14003
  disconnectedCallback() {
13999
14004
  this._connected = false;
14000
14005
  nextTick(() => {
@@ -14003,9 +14008,7 @@ Expected function or array of functions, received type ${typeof value}.`
14003
14008
  this._ob.disconnect();
14004
14009
  this._ob = null;
14005
14010
  }
14006
- this._app && this._app.unmount();
14007
- if (this._instance) this._instance.ce = void 0;
14008
- this._app = this._instance = null;
14011
+ this._unmount();
14009
14012
  if (this._teleportTargets) {
14010
14013
  this._teleportTargets.clear();
14011
14014
  this._teleportTargets = void 0;
@@ -14013,6 +14016,20 @@ Expected function or array of functions, received type ${typeof value}.`
14013
14016
  }
14014
14017
  });
14015
14018
  }
14019
+ _setParent(parent = this._parent) {
14020
+ if (parent && this._instance) {
14021
+ this._instance.parent = parent._instance;
14022
+ this._inheritParentContext(parent);
14023
+ }
14024
+ }
14025
+ _inheritParentContext(parent = this._parent) {
14026
+ if (parent && this._app) {
14027
+ Object.setPrototypeOf(
14028
+ this._app._context.provides,
14029
+ parent._instance.provides
14030
+ );
14031
+ }
14032
+ }
14016
14033
  _processMutations(mutations) {
14017
14034
  for (const m of mutations) {
14018
14035
  this._setAttr(m.attributeName);
@@ -14030,7 +14047,7 @@ Expected function or array of functions, received type ${typeof value}.`
14030
14047
  }
14031
14048
  this._ob = new MutationObserver(this._processMutations.bind(this));
14032
14049
  this._ob.observe(this, { attributes: true });
14033
- const resolve = (def, isAsync = false) => {
14050
+ const resolve = (def) => {
14034
14051
  this._resolved = true;
14035
14052
  this._pendingResolve = void 0;
14036
14053
  const { props, styles } = def;
@@ -14055,29 +14072,25 @@ Expected function or array of functions, received type ${typeof value}.`
14055
14072
  "Custom element style injection is not supported when using shadowRoot: false"
14056
14073
  );
14057
14074
  }
14058
- this._mount(def);
14075
+ this._mountComponent(def);
14059
14076
  };
14060
14077
  const asyncDef = this._def.__asyncLoader;
14061
14078
  if (asyncDef) {
14079
+ const { configureApp } = this._def;
14062
14080
  this._pendingResolve = asyncDef().then((def) => {
14063
- def.configureApp = this._def.configureApp;
14064
- resolve(this._def = def, true);
14081
+ def.configureApp = configureApp;
14082
+ this._def = def;
14083
+ resolve(def);
14065
14084
  });
14066
14085
  } else {
14067
14086
  resolve(this._def);
14068
14087
  }
14069
14088
  }
14070
- _mount(def) {
14071
- if (!def.name) {
14072
- def.name = "VueElement";
14073
- }
14074
- this._app = this._createApp(def);
14075
- this._inheritParentContext();
14076
- if (def.configureApp) {
14077
- def.configureApp(this._app);
14078
- }
14079
- this._app._ceVNode = this._createVNode();
14080
- this._app.mount(this._root);
14089
+ _mountComponent(def) {
14090
+ this._mount(def);
14091
+ this._processExposed();
14092
+ }
14093
+ _processExposed() {
14081
14094
  const exposed = this._instance && this._instance.exposed;
14082
14095
  if (!exposed) return;
14083
14096
  for (const key in exposed) {
@@ -14091,6 +14104,38 @@ Expected function or array of functions, received type ${typeof value}.`
14091
14104
  }
14092
14105
  }
14093
14106
  }
14107
+ _processInstance() {
14108
+ this._instance.ce = this;
14109
+ this._instance.isCE = true;
14110
+ {
14111
+ this._instance.ceReload = (newStyles) => {
14112
+ if (this._styles) {
14113
+ this._styles.forEach((s) => this._root.removeChild(s));
14114
+ this._styles.length = 0;
14115
+ }
14116
+ this._applyStyles(newStyles);
14117
+ if (!this._instance.vapor) {
14118
+ this._instance = null;
14119
+ }
14120
+ this._update();
14121
+ };
14122
+ }
14123
+ const dispatch = (event, args) => {
14124
+ this.dispatchEvent(
14125
+ new CustomEvent(
14126
+ event,
14127
+ isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
14128
+ )
14129
+ );
14130
+ };
14131
+ this._instance.emit = (event, ...args) => {
14132
+ dispatch(event, args);
14133
+ if (hyphenate(event) !== event) {
14134
+ dispatch(hyphenate(event), args);
14135
+ }
14136
+ };
14137
+ this._setParent();
14138
+ }
14094
14139
  _resolveProps(def) {
14095
14140
  const { props } = def;
14096
14141
  const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
@@ -14136,7 +14181,7 @@ Expected function or array of functions, received type ${typeof value}.`
14136
14181
  delete this._props[key];
14137
14182
  } else {
14138
14183
  this._props[key] = val;
14139
- if (key === "key" && this._app) {
14184
+ if (key === "key" && this._app && this._app._ceVNode) {
14140
14185
  this._app._ceVNode.key = val;
14141
14186
  }
14142
14187
  }
@@ -14160,52 +14205,6 @@ Expected function or array of functions, received type ${typeof value}.`
14160
14205
  }
14161
14206
  }
14162
14207
  }
14163
- _update() {
14164
- const vnode = this._createVNode();
14165
- if (this._app) vnode.appContext = this._app._context;
14166
- render(vnode, this._root);
14167
- }
14168
- _createVNode() {
14169
- const baseProps = {};
14170
- if (!this.shadowRoot) {
14171
- baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
14172
- }
14173
- const vnode = createVNode(this._def, extend(baseProps, this._props));
14174
- if (!this._instance) {
14175
- vnode.ce = (instance) => {
14176
- this._instance = instance;
14177
- instance.ce = this;
14178
- instance.isCE = true;
14179
- {
14180
- instance.ceReload = (newStyles) => {
14181
- if (this._styles) {
14182
- this._styles.forEach((s) => this._root.removeChild(s));
14183
- this._styles.length = 0;
14184
- }
14185
- this._applyStyles(newStyles);
14186
- this._instance = null;
14187
- this._update();
14188
- };
14189
- }
14190
- const dispatch = (event, args) => {
14191
- this.dispatchEvent(
14192
- new CustomEvent(
14193
- event,
14194
- isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
14195
- )
14196
- );
14197
- };
14198
- instance.emit = (event, ...args) => {
14199
- dispatch(event, args);
14200
- if (hyphenate(event) !== event) {
14201
- dispatch(hyphenate(event), args);
14202
- }
14203
- };
14204
- this._setParent();
14205
- };
14206
- }
14207
- return vnode;
14208
- }
14209
14208
  _applyStyles(styles, owner) {
14210
14209
  if (!styles) return;
14211
14210
  if (owner) {
@@ -14254,11 +14253,13 @@ Expected function or array of functions, received type ${typeof value}.`
14254
14253
  _renderSlots() {
14255
14254
  const outlets = this._getSlots();
14256
14255
  const scopeId = this._instance.type.__scopeId;
14256
+ const slotReplacements = /* @__PURE__ */ new Map();
14257
14257
  for (let i = 0; i < outlets.length; i++) {
14258
14258
  const o = outlets[i];
14259
14259
  const slotName = o.getAttribute("name") || "default";
14260
14260
  const content = this._slots[slotName];
14261
14261
  const parent = o.parentNode;
14262
+ const replacementNodes = [];
14262
14263
  if (content) {
14263
14264
  for (const n of content) {
14264
14265
  if (scopeId && n.nodeType === 1) {
@@ -14271,12 +14272,19 @@ Expected function or array of functions, received type ${typeof value}.`
14271
14272
  }
14272
14273
  }
14273
14274
  parent.insertBefore(n, o);
14275
+ replacementNodes.push(n);
14274
14276
  }
14275
14277
  } else {
14276
- while (o.firstChild) parent.insertBefore(o.firstChild, o);
14278
+ while (o.firstChild) {
14279
+ const child = o.firstChild;
14280
+ parent.insertBefore(child, o);
14281
+ replacementNodes.push(child);
14282
+ }
14277
14283
  }
14278
14284
  parent.removeChild(o);
14285
+ slotReplacements.set(o, replacementNodes);
14279
14286
  }
14287
+ this._updateSlotNodes(slotReplacements);
14280
14288
  }
14281
14289
  /**
14282
14290
  * @internal
@@ -14333,13 +14341,76 @@ Expected function or array of functions, received type ${typeof value}.`
14333
14341
  }
14334
14342
  }
14335
14343
  }
14344
+ class VueElement extends VueElementBase {
14345
+ constructor(def, props = {}, createAppFn = createApp) {
14346
+ super(def, props, createAppFn);
14347
+ }
14348
+ _needsHydration() {
14349
+ if (this.shadowRoot && this._createApp !== createApp) {
14350
+ return true;
14351
+ } else {
14352
+ if (this.shadowRoot) {
14353
+ warn(
14354
+ `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
14355
+ );
14356
+ }
14357
+ }
14358
+ return false;
14359
+ }
14360
+ _mount(def) {
14361
+ if (!def.name) {
14362
+ def.name = "VueElement";
14363
+ }
14364
+ this._app = this._createApp(def);
14365
+ this._inheritParentContext();
14366
+ if (def.configureApp) {
14367
+ def.configureApp(this._app);
14368
+ }
14369
+ this._app._ceVNode = this._createVNode();
14370
+ this._app.mount(this._root);
14371
+ }
14372
+ _update() {
14373
+ if (!this._app) return;
14374
+ const vnode = this._createVNode();
14375
+ vnode.appContext = this._app._context;
14376
+ render(vnode, this._root);
14377
+ }
14378
+ _unmount() {
14379
+ if (this._app) {
14380
+ this._app.unmount();
14381
+ }
14382
+ if (this._instance && this._instance.ce) {
14383
+ this._instance.ce = void 0;
14384
+ }
14385
+ this._app = this._instance = null;
14386
+ }
14387
+ /**
14388
+ * Only called when shadowRoot is false
14389
+ */
14390
+ _updateSlotNodes(replacements) {
14391
+ }
14392
+ _createVNode() {
14393
+ const baseProps = {};
14394
+ if (!this.shadowRoot) {
14395
+ baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
14396
+ }
14397
+ const vnode = createVNode(this._def, extend(baseProps, this._props));
14398
+ if (!this._instance) {
14399
+ vnode.ce = (instance) => {
14400
+ this._instance = instance;
14401
+ this._processInstance();
14402
+ };
14403
+ }
14404
+ return vnode;
14405
+ }
14406
+ }
14336
14407
  function useHost(caller) {
14337
- const instance = getCurrentInstance();
14338
- const el = instance && instance.ce;
14408
+ const { hasInstance, value } = useInstanceOption("ce", true);
14409
+ const el = value;
14339
14410
  if (el) {
14340
14411
  return el;
14341
14412
  } else {
14342
- if (!instance) {
14413
+ if (!hasInstance) {
14343
14414
  warn(
14344
14415
  `${caller || "useHost"} called without an active component instance.`
14345
14416
  );
@@ -15045,6 +15116,7 @@ Expected function or array of functions, received type ${typeof value}.`
15045
15116
  TransitionGroup: TransitionGroup,
15046
15117
  TriggerOpTypes: TriggerOpTypes,
15047
15118
  VueElement: VueElement,
15119
+ VueElementBase: VueElementBase,
15048
15120
  assertNumber: assertNumber,
15049
15121
  callWithAsyncErrorHandling: callWithAsyncErrorHandling,
15050
15122
  callWithErrorHandling: callWithErrorHandling,
@@ -15109,6 +15181,7 @@ Expected function or array of functions, received type ${typeof value}.`
15109
15181
  mergeModels: mergeModels,
15110
15182
  mergeProps: mergeProps,
15111
15183
  nextTick: nextTick,
15184
+ nodeOps: nodeOps,
15112
15185
  normalizeClass: normalizeClass,
15113
15186
  normalizeProps: normalizeProps,
15114
15187
  normalizeStyle: normalizeStyle,
@@ -15127,6 +15200,7 @@ Expected function or array of functions, received type ${typeof value}.`
15127
15200
  onUpdated: onUpdated,
15128
15201
  onWatcherCleanup: onWatcherCleanup,
15129
15202
  openBlock: openBlock,
15203
+ patchProp: patchProp,
15130
15204
  popScopeId: popScopeId,
15131
15205
  provide: provide,
15132
15206
  proxyRefs: proxyRefs,
@@ -15168,6 +15242,7 @@ Expected function or array of functions, received type ${typeof value}.`
15168
15242
  useCssVars: useCssVars,
15169
15243
  useHost: useHost,
15170
15244
  useId: useId,
15245
+ useInstanceOption: useInstanceOption,
15171
15246
  useModel: useModel,
15172
15247
  useSSRContext: useSSRContext,
15173
15248
  useShadowRoot: useShadowRoot,
@@ -20242,7 +20317,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20242
20317
  ];
20243
20318
  if (dir.modifiers.length && node.tagType === 1) {
20244
20319
  const modifiers = dir.modifiers.map((m) => m.content).map((m) => (isSimpleIdentifier(m) ? m : JSON.stringify(m)) + `: true`).join(`, `);
20245
- const modifiersKey = arg ? isStaticExp(arg) ? `${arg.content}Modifiers` : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
20320
+ const modifiersKey = arg ? isStaticExp(arg) ? getModifierPropName(arg.content) : createCompoundExpression([arg, ' + "Modifiers"']) : `modelModifiers`;
20246
20321
  props.push(
20247
20322
  createObjectProperty(
20248
20323
  modifiersKey,
@@ -20595,7 +20670,7 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20595
20670
  let ns = parent ? parent.ns : rootNamespace;
20596
20671
  if (parent && ns === 2) {
20597
20672
  if (parent.tag === "annotation-xml") {
20598
- if (tag === "svg") {
20673
+ if (isSVGTag(tag)) {
20599
20674
  return 1;
20600
20675
  }
20601
20676
  if (parent.props.some(
@@ -20612,10 +20687,10 @@ Use a v-bind binding combined with a v-on listener that emits update:x event ins
20612
20687
  }
20613
20688
  }
20614
20689
  if (ns === 0) {
20615
- if (tag === "svg") {
20690
+ if (isSVGTag(tag)) {
20616
20691
  return 1;
20617
20692
  }
20618
- if (tag === "math") {
20693
+ if (isMathMLTag(tag)) {
20619
20694
  return 2;
20620
20695
  }
20621
20696
  }