@vue/runtime-dom 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/runtime-dom v3.6.0-alpha.3
2
+ * @vue/runtime-dom 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 VueRuntimeDOM = (function (exports) {
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++) {
@@ -2841,7 +2844,12 @@ var VueRuntimeDOM = (function (exports) {
2841
2844
  newComp = normalizeClassComponent(newComp);
2842
2845
  updateComponentDef(record.initialDef, newComp);
2843
2846
  const instances = [...record.instances];
2844
- if (newComp.__vapor) {
2847
+ if (newComp.__vapor && !instances.some((i) => i.ceReload)) {
2848
+ for (const instance of instances) {
2849
+ if (instance.root && instance.root.ce && instance !== instance.root) {
2850
+ instance.root.ce._removeChildStyle(instance.type);
2851
+ }
2852
+ }
2845
2853
  for (const instance of instances) {
2846
2854
  instance.hmrReload(newComp);
2847
2855
  }
@@ -9069,7 +9077,7 @@ app.use(vaporInteropPlugin)
9069
9077
  return res;
9070
9078
  }
9071
9079
  const getModelModifiers = (props, modelName, getter) => {
9072
- return modelName === "modelValue" || modelName === "model-value" ? getter(props, "modelModifiers") : getter(props, `${modelName}Modifiers`) || getter(props, `${camelize(modelName)}Modifiers`) || getter(props, `${hyphenate(modelName)}Modifiers`);
9080
+ return getter(props, getModifierPropName(modelName)) || getter(props, `${camelize(modelName)}Modifiers`) || getter(props, `${hyphenate(modelName)}Modifiers`);
9073
9081
  };
9074
9082
 
9075
9083
  function emit(instance, event, ...rawArgs) {
@@ -10511,6 +10519,25 @@ Component that was made reactive: `,
10511
10519
  simpleSetCurrentInstance(instance);
10512
10520
  }
10513
10521
  };
10522
+ const internalOptions = ["ce", "type"];
10523
+ const useInstanceOption = (key, silent = false) => {
10524
+ const instance = getCurrentGenericInstance();
10525
+ if (!instance) {
10526
+ if (!silent) {
10527
+ warn$1(`useInstanceOption called without an active component instance.`);
10528
+ }
10529
+ return { hasInstance: false, value: void 0 };
10530
+ }
10531
+ if (!internalOptions.includes(key)) {
10532
+ {
10533
+ warn$1(
10534
+ `useInstanceOption only accepts ${internalOptions.map((k) => `'${k}'`).join(", ")} as key, got '${key}'.`
10535
+ );
10536
+ }
10537
+ return { hasInstance: true, value: void 0 };
10538
+ }
10539
+ return { hasInstance: true, value: instance[key] };
10540
+ };
10514
10541
 
10515
10542
  const emptyAppContext = createAppContext();
10516
10543
  let uid = 0;
@@ -11143,7 +11170,7 @@ Component that was made reactive: `,
11143
11170
  return true;
11144
11171
  }
11145
11172
 
11146
- const version = "3.6.0-alpha.3";
11173
+ const version = "3.6.0-alpha.4";
11147
11174
  const warn = warn$1 ;
11148
11175
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11149
11176
  const devtools = devtools$1 ;
@@ -11967,12 +11994,9 @@ Expected function or array of functions, received type ${typeof value}.`
11967
11994
  });
11968
11995
  const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
11969
11996
  };
11970
- class VueElement extends BaseClass {
11971
- constructor(_def, _props = {}, _createApp = createApp) {
11997
+ class VueElementBase extends BaseClass {
11998
+ constructor(def, props = {}, createAppFn) {
11972
11999
  super();
11973
- this._def = _def;
11974
- this._props = _props;
11975
- this._createApp = _createApp;
11976
12000
  this._isVueCE = true;
11977
12001
  /**
11978
12002
  * @internal
@@ -11982,28 +12006,23 @@ Expected function or array of functions, received type ${typeof value}.`
11982
12006
  * @internal
11983
12007
  */
11984
12008
  this._app = null;
11985
- /**
11986
- * @internal
11987
- */
11988
- this._nonce = this._def.nonce;
11989
12009
  this._connected = false;
11990
12010
  this._resolved = false;
11991
- this._patching = false;
11992
- this._dirty = false;
11993
12011
  this._numberProps = null;
11994
12012
  this._styleChildren = /* @__PURE__ */ new WeakSet();
12013
+ this._patching = false;
12014
+ this._dirty = false;
11995
12015
  this._ob = null;
11996
- if (this.shadowRoot && _createApp !== createApp) {
12016
+ this._def = def;
12017
+ this._props = props;
12018
+ this._createApp = createAppFn;
12019
+ this._nonce = def.nonce;
12020
+ if (this._needsHydration()) {
11997
12021
  this._root = this.shadowRoot;
11998
12022
  } else {
11999
- if (this.shadowRoot) {
12000
- warn(
12001
- `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
12002
- );
12003
- }
12004
- if (_def.shadowRoot !== false) {
12023
+ if (def.shadowRoot !== false) {
12005
12024
  this.attachShadow(
12006
- extend({}, _def.shadowRootOptions, {
12025
+ extend({}, def.shadowRootOptions, {
12007
12026
  mode: "open"
12008
12027
  })
12009
12028
  );
@@ -12021,14 +12040,14 @@ Expected function or array of functions, received type ${typeof value}.`
12021
12040
  this._connected = true;
12022
12041
  let parent = this;
12023
12042
  while (parent = parent && (parent.parentNode || parent.host)) {
12024
- if (parent instanceof VueElement) {
12043
+ if (parent instanceof VueElementBase) {
12025
12044
  this._parent = parent;
12026
12045
  break;
12027
12046
  }
12028
12047
  }
12029
12048
  if (!this._instance) {
12030
12049
  if (this._resolved) {
12031
- this._mount(this._def);
12050
+ this._mountComponent(this._def);
12032
12051
  } else {
12033
12052
  if (parent && parent._pendingResolve) {
12034
12053
  this._pendingResolve = parent._pendingResolve.then(() => {
@@ -12041,20 +12060,6 @@ Expected function or array of functions, received type ${typeof value}.`
12041
12060
  }
12042
12061
  }
12043
12062
  }
12044
- _setParent(parent = this._parent) {
12045
- if (parent) {
12046
- this._instance.parent = parent._instance;
12047
- this._inheritParentContext(parent);
12048
- }
12049
- }
12050
- _inheritParentContext(parent = this._parent) {
12051
- if (parent && this._app) {
12052
- Object.setPrototypeOf(
12053
- this._app._context.provides,
12054
- parent._instance.provides
12055
- );
12056
- }
12057
- }
12058
12063
  disconnectedCallback() {
12059
12064
  this._connected = false;
12060
12065
  nextTick(() => {
@@ -12063,9 +12068,7 @@ Expected function or array of functions, received type ${typeof value}.`
12063
12068
  this._ob.disconnect();
12064
12069
  this._ob = null;
12065
12070
  }
12066
- this._app && this._app.unmount();
12067
- if (this._instance) this._instance.ce = void 0;
12068
- this._app = this._instance = null;
12071
+ this._unmount();
12069
12072
  if (this._teleportTargets) {
12070
12073
  this._teleportTargets.clear();
12071
12074
  this._teleportTargets = void 0;
@@ -12073,6 +12076,20 @@ Expected function or array of functions, received type ${typeof value}.`
12073
12076
  }
12074
12077
  });
12075
12078
  }
12079
+ _setParent(parent = this._parent) {
12080
+ if (parent && this._instance) {
12081
+ this._instance.parent = parent._instance;
12082
+ this._inheritParentContext(parent);
12083
+ }
12084
+ }
12085
+ _inheritParentContext(parent = this._parent) {
12086
+ if (parent && this._app) {
12087
+ Object.setPrototypeOf(
12088
+ this._app._context.provides,
12089
+ parent._instance.provides
12090
+ );
12091
+ }
12092
+ }
12076
12093
  _processMutations(mutations) {
12077
12094
  for (const m of mutations) {
12078
12095
  this._setAttr(m.attributeName);
@@ -12090,7 +12107,7 @@ Expected function or array of functions, received type ${typeof value}.`
12090
12107
  }
12091
12108
  this._ob = new MutationObserver(this._processMutations.bind(this));
12092
12109
  this._ob.observe(this, { attributes: true });
12093
- const resolve = (def, isAsync = false) => {
12110
+ const resolve = (def) => {
12094
12111
  this._resolved = true;
12095
12112
  this._pendingResolve = void 0;
12096
12113
  const { props, styles } = def;
@@ -12115,29 +12132,25 @@ Expected function or array of functions, received type ${typeof value}.`
12115
12132
  "Custom element style injection is not supported when using shadowRoot: false"
12116
12133
  );
12117
12134
  }
12118
- this._mount(def);
12135
+ this._mountComponent(def);
12119
12136
  };
12120
12137
  const asyncDef = this._def.__asyncLoader;
12121
12138
  if (asyncDef) {
12139
+ const { configureApp } = this._def;
12122
12140
  this._pendingResolve = asyncDef().then((def) => {
12123
- def.configureApp = this._def.configureApp;
12124
- resolve(this._def = def, true);
12141
+ def.configureApp = configureApp;
12142
+ this._def = def;
12143
+ resolve(def);
12125
12144
  });
12126
12145
  } else {
12127
12146
  resolve(this._def);
12128
12147
  }
12129
12148
  }
12130
- _mount(def) {
12131
- if (!def.name) {
12132
- def.name = "VueElement";
12133
- }
12134
- this._app = this._createApp(def);
12135
- this._inheritParentContext();
12136
- if (def.configureApp) {
12137
- def.configureApp(this._app);
12138
- }
12139
- this._app._ceVNode = this._createVNode();
12140
- this._app.mount(this._root);
12149
+ _mountComponent(def) {
12150
+ this._mount(def);
12151
+ this._processExposed();
12152
+ }
12153
+ _processExposed() {
12141
12154
  const exposed = this._instance && this._instance.exposed;
12142
12155
  if (!exposed) return;
12143
12156
  for (const key in exposed) {
@@ -12151,6 +12164,38 @@ Expected function or array of functions, received type ${typeof value}.`
12151
12164
  }
12152
12165
  }
12153
12166
  }
12167
+ _processInstance() {
12168
+ this._instance.ce = this;
12169
+ this._instance.isCE = true;
12170
+ {
12171
+ this._instance.ceReload = (newStyles) => {
12172
+ if (this._styles) {
12173
+ this._styles.forEach((s) => this._root.removeChild(s));
12174
+ this._styles.length = 0;
12175
+ }
12176
+ this._applyStyles(newStyles);
12177
+ if (!this._instance.vapor) {
12178
+ this._instance = null;
12179
+ }
12180
+ this._update();
12181
+ };
12182
+ }
12183
+ const dispatch = (event, args) => {
12184
+ this.dispatchEvent(
12185
+ new CustomEvent(
12186
+ event,
12187
+ isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
12188
+ )
12189
+ );
12190
+ };
12191
+ this._instance.emit = (event, ...args) => {
12192
+ dispatch(event, args);
12193
+ if (hyphenate(event) !== event) {
12194
+ dispatch(hyphenate(event), args);
12195
+ }
12196
+ };
12197
+ this._setParent();
12198
+ }
12154
12199
  _resolveProps(def) {
12155
12200
  const { props } = def;
12156
12201
  const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
@@ -12196,7 +12241,7 @@ Expected function or array of functions, received type ${typeof value}.`
12196
12241
  delete this._props[key];
12197
12242
  } else {
12198
12243
  this._props[key] = val;
12199
- if (key === "key" && this._app) {
12244
+ if (key === "key" && this._app && this._app._ceVNode) {
12200
12245
  this._app._ceVNode.key = val;
12201
12246
  }
12202
12247
  }
@@ -12220,52 +12265,6 @@ Expected function or array of functions, received type ${typeof value}.`
12220
12265
  }
12221
12266
  }
12222
12267
  }
12223
- _update() {
12224
- const vnode = this._createVNode();
12225
- if (this._app) vnode.appContext = this._app._context;
12226
- render(vnode, this._root);
12227
- }
12228
- _createVNode() {
12229
- const baseProps = {};
12230
- if (!this.shadowRoot) {
12231
- baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
12232
- }
12233
- const vnode = createVNode(this._def, extend(baseProps, this._props));
12234
- if (!this._instance) {
12235
- vnode.ce = (instance) => {
12236
- this._instance = instance;
12237
- instance.ce = this;
12238
- instance.isCE = true;
12239
- {
12240
- instance.ceReload = (newStyles) => {
12241
- if (this._styles) {
12242
- this._styles.forEach((s) => this._root.removeChild(s));
12243
- this._styles.length = 0;
12244
- }
12245
- this._applyStyles(newStyles);
12246
- this._instance = null;
12247
- this._update();
12248
- };
12249
- }
12250
- const dispatch = (event, args) => {
12251
- this.dispatchEvent(
12252
- new CustomEvent(
12253
- event,
12254
- isPlainObject(args[0]) ? extend({ detail: args }, args[0]) : { detail: args }
12255
- )
12256
- );
12257
- };
12258
- instance.emit = (event, ...args) => {
12259
- dispatch(event, args);
12260
- if (hyphenate(event) !== event) {
12261
- dispatch(hyphenate(event), args);
12262
- }
12263
- };
12264
- this._setParent();
12265
- };
12266
- }
12267
- return vnode;
12268
- }
12269
12268
  _applyStyles(styles, owner) {
12270
12269
  if (!styles) return;
12271
12270
  if (owner) {
@@ -12314,11 +12313,13 @@ Expected function or array of functions, received type ${typeof value}.`
12314
12313
  _renderSlots() {
12315
12314
  const outlets = this._getSlots();
12316
12315
  const scopeId = this._instance.type.__scopeId;
12316
+ const slotReplacements = /* @__PURE__ */ new Map();
12317
12317
  for (let i = 0; i < outlets.length; i++) {
12318
12318
  const o = outlets[i];
12319
12319
  const slotName = o.getAttribute("name") || "default";
12320
12320
  const content = this._slots[slotName];
12321
12321
  const parent = o.parentNode;
12322
+ const replacementNodes = [];
12322
12323
  if (content) {
12323
12324
  for (const n of content) {
12324
12325
  if (scopeId && n.nodeType === 1) {
@@ -12331,12 +12332,19 @@ Expected function or array of functions, received type ${typeof value}.`
12331
12332
  }
12332
12333
  }
12333
12334
  parent.insertBefore(n, o);
12335
+ replacementNodes.push(n);
12334
12336
  }
12335
12337
  } else {
12336
- while (o.firstChild) parent.insertBefore(o.firstChild, o);
12338
+ while (o.firstChild) {
12339
+ const child = o.firstChild;
12340
+ parent.insertBefore(child, o);
12341
+ replacementNodes.push(child);
12342
+ }
12337
12343
  }
12338
12344
  parent.removeChild(o);
12345
+ slotReplacements.set(o, replacementNodes);
12339
12346
  }
12347
+ this._updateSlotNodes(slotReplacements);
12340
12348
  }
12341
12349
  /**
12342
12350
  * @internal
@@ -12393,13 +12401,76 @@ Expected function or array of functions, received type ${typeof value}.`
12393
12401
  }
12394
12402
  }
12395
12403
  }
12404
+ class VueElement extends VueElementBase {
12405
+ constructor(def, props = {}, createAppFn = createApp) {
12406
+ super(def, props, createAppFn);
12407
+ }
12408
+ _needsHydration() {
12409
+ if (this.shadowRoot && this._createApp !== createApp) {
12410
+ return true;
12411
+ } else {
12412
+ if (this.shadowRoot) {
12413
+ warn(
12414
+ `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
12415
+ );
12416
+ }
12417
+ }
12418
+ return false;
12419
+ }
12420
+ _mount(def) {
12421
+ if (!def.name) {
12422
+ def.name = "VueElement";
12423
+ }
12424
+ this._app = this._createApp(def);
12425
+ this._inheritParentContext();
12426
+ if (def.configureApp) {
12427
+ def.configureApp(this._app);
12428
+ }
12429
+ this._app._ceVNode = this._createVNode();
12430
+ this._app.mount(this._root);
12431
+ }
12432
+ _update() {
12433
+ if (!this._app) return;
12434
+ const vnode = this._createVNode();
12435
+ vnode.appContext = this._app._context;
12436
+ render(vnode, this._root);
12437
+ }
12438
+ _unmount() {
12439
+ if (this._app) {
12440
+ this._app.unmount();
12441
+ }
12442
+ if (this._instance && this._instance.ce) {
12443
+ this._instance.ce = void 0;
12444
+ }
12445
+ this._app = this._instance = null;
12446
+ }
12447
+ /**
12448
+ * Only called when shadowRoot is false
12449
+ */
12450
+ _updateSlotNodes(replacements) {
12451
+ }
12452
+ _createVNode() {
12453
+ const baseProps = {};
12454
+ if (!this.shadowRoot) {
12455
+ baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
12456
+ }
12457
+ const vnode = createVNode(this._def, extend(baseProps, this._props));
12458
+ if (!this._instance) {
12459
+ vnode.ce = (instance) => {
12460
+ this._instance = instance;
12461
+ this._processInstance();
12462
+ };
12463
+ }
12464
+ return vnode;
12465
+ }
12466
+ }
12396
12467
  function useHost(caller) {
12397
- const instance = getCurrentInstance();
12398
- const el = instance && instance.ce;
12468
+ const { hasInstance, value } = useInstanceOption("ce", true);
12469
+ const el = value;
12399
12470
  if (el) {
12400
12471
  return el;
12401
12472
  } else {
12402
- if (!instance) {
12473
+ if (!hasInstance) {
12403
12474
  warn(
12404
12475
  `${caller || "useHost"} called without an active component instance.`
12405
12476
  );
@@ -13046,6 +13117,7 @@ Expected function or array of functions, received type ${typeof value}.`
13046
13117
  exports.TransitionGroup = TransitionGroup;
13047
13118
  exports.TriggerOpTypes = TriggerOpTypes;
13048
13119
  exports.VueElement = VueElement;
13120
+ exports.VueElementBase = VueElementBase;
13049
13121
  exports.assertNumber = assertNumber;
13050
13122
  exports.callWithAsyncErrorHandling = callWithAsyncErrorHandling;
13051
13123
  exports.callWithErrorHandling = callWithErrorHandling;
@@ -13110,6 +13182,7 @@ Expected function or array of functions, received type ${typeof value}.`
13110
13182
  exports.mergeModels = mergeModels;
13111
13183
  exports.mergeProps = mergeProps;
13112
13184
  exports.nextTick = nextTick;
13185
+ exports.nodeOps = nodeOps;
13113
13186
  exports.normalizeClass = normalizeClass;
13114
13187
  exports.normalizeProps = normalizeProps;
13115
13188
  exports.normalizeStyle = normalizeStyle;
@@ -13128,6 +13201,7 @@ Expected function or array of functions, received type ${typeof value}.`
13128
13201
  exports.onUpdated = onUpdated;
13129
13202
  exports.onWatcherCleanup = onWatcherCleanup;
13130
13203
  exports.openBlock = openBlock;
13204
+ exports.patchProp = patchProp;
13131
13205
  exports.popScopeId = popScopeId;
13132
13206
  exports.provide = provide;
13133
13207
  exports.proxyRefs = proxyRefs;
@@ -13169,6 +13243,7 @@ Expected function or array of functions, received type ${typeof value}.`
13169
13243
  exports.useCssVars = useCssVars;
13170
13244
  exports.useHost = useHost;
13171
13245
  exports.useId = useId;
13246
+ exports.useInstanceOption = useInstanceOption;
13172
13247
  exports.useModel = useModel;
13173
13248
  exports.useSSRContext = useSSRContext;
13174
13249
  exports.useShadowRoot = useShadowRoot;