@vue/runtime-core 3.3.0-alpha.12 → 3.3.0-alpha.13

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > This package is published only for typing and building custom renderers. It is NOT meant to be used in applications.
4
4
 
5
- For full exposed APIs, see `src/index.ts`. You can also run `pnpm build runtime-core --types` from repo root, which will generate an API report at `temp/runtime-core.api.md`.
5
+ For full exposed APIs, see `src/index.ts`.
6
6
 
7
7
  ## Building a Custom Renderer
8
8
 
@@ -2909,6 +2909,8 @@ const PublicInstanceProxyHandlers = {
2909
2909
  if (key === "$attrs") {
2910
2910
  reactivity.track(instance, "get", key);
2911
2911
  markAttrsAccessed();
2912
+ } else if (key === "$slots") {
2913
+ reactivity.track(instance, "get", key);
2912
2914
  }
2913
2915
  return publicGetter(instance);
2914
2916
  } else if (
@@ -3868,6 +3870,9 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
3868
3870
  warn(`inject() can only be used inside setup() or functional components.`);
3869
3871
  }
3870
3872
  }
3873
+ function hasInjectionContext() {
3874
+ return !!(currentInstance || currentRenderingInstance || currentApp);
3875
+ }
3871
3876
 
3872
3877
  function initProps(instance, rawProps, isStateful, isSSR = false) {
3873
3878
  const props = {};
@@ -4336,6 +4341,7 @@ const updateSlots = (instance, children, optimized) => {
4336
4341
  if (type) {
4337
4342
  if (isHmrUpdating) {
4338
4343
  shared.extend(slots, children);
4344
+ reactivity.trigger(instance, "set", "$slots");
4339
4345
  } else if (optimized && type === 1) {
4340
4346
  needDeletionCheck = false;
4341
4347
  } else {
@@ -5264,7 +5270,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5264
5270
  areChildrenSVG,
5265
5271
  slotScopeIds
5266
5272
  );
5267
- if (parentComponent && parentComponent.type.__hmrId) {
5273
+ {
5268
5274
  traverseStaticChildren(n1, n2);
5269
5275
  }
5270
5276
  } else if (!optimized) {
@@ -5460,21 +5466,8 @@ function baseCreateRenderer(options, createHydrationFns) {
5460
5466
  isSVG,
5461
5467
  slotScopeIds
5462
5468
  );
5463
- if (parentComponent && parentComponent.type.__hmrId) {
5469
+ {
5464
5470
  traverseStaticChildren(n1, n2);
5465
- } else if (
5466
- // #2080 if the stable fragment has a key, it's a <template v-for> that may
5467
- // get moved around. Make sure all root level vnodes inherit el.
5468
- // #2134 or if it's a component root, it may also get moved around
5469
- // as the component is being moved.
5470
- n2.key != null || parentComponent && n2 === parentComponent.subTree
5471
- ) {
5472
- traverseStaticChildren(
5473
- n1,
5474
- n2,
5475
- true
5476
- /* shallow */
5477
- );
5478
5471
  }
5479
5472
  } else {
5480
5473
  patchChildren(
@@ -7048,6 +7041,8 @@ function createComponentInstance(vnode, parent, suspense) {
7048
7041
  refs: shared.EMPTY_OBJ,
7049
7042
  setupState: shared.EMPTY_OBJ,
7050
7043
  setupContext: null,
7044
+ attrsProxy: null,
7045
+ slotsProxy: null,
7051
7046
  // suspense related
7052
7047
  suspense,
7053
7048
  suspenseId: suspense ? suspense.pendingId : 0,
@@ -7287,8 +7282,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7287
7282
  }
7288
7283
  }
7289
7284
  }
7290
- function createAttrsProxy(instance) {
7291
- return new Proxy(
7285
+ function getAttrsProxy(instance) {
7286
+ return instance.attrsProxy || (instance.attrsProxy = new Proxy(
7292
7287
  instance.attrs,
7293
7288
  {
7294
7289
  get(target, key) {
@@ -7305,7 +7300,23 @@ function createAttrsProxy(instance) {
7305
7300
  return false;
7306
7301
  }
7307
7302
  }
7308
- );
7303
+ ));
7304
+ }
7305
+ function getSlotsProxy(instance) {
7306
+ return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
7307
+ get(target, key) {
7308
+ reactivity.track(instance, "get", "$slots");
7309
+ return target[key];
7310
+ },
7311
+ set() {
7312
+ warn(`setupContext.slots is readonly.`);
7313
+ return false;
7314
+ },
7315
+ deleteProperty() {
7316
+ warn(`setupContext.slots is readonly.`);
7317
+ return false;
7318
+ }
7319
+ }));
7309
7320
  }
7310
7321
  function createSetupContext(instance) {
7311
7322
  const expose = (exposed) => {
@@ -7331,14 +7342,13 @@ function createSetupContext(instance) {
7331
7342
  }
7332
7343
  instance.exposed = exposed || {};
7333
7344
  };
7334
- let attrs;
7335
7345
  {
7336
7346
  return Object.freeze({
7337
7347
  get attrs() {
7338
- return attrs || (attrs = createAttrsProxy(instance));
7348
+ return getAttrsProxy(instance);
7339
7349
  },
7340
7350
  get slots() {
7341
- return reactivity.shallowReadonly(instance.slots);
7351
+ return getSlotsProxy(instance);
7342
7352
  },
7343
7353
  get emit() {
7344
7354
  return (event, ...args) => instance.emit(event, ...args);
@@ -7637,7 +7647,7 @@ function isMemoSame(cached, memo) {
7637
7647
  return true;
7638
7648
  }
7639
7649
 
7640
- const version = "3.3.0-alpha.12";
7650
+ const version = "3.3.0-alpha.13";
7641
7651
  const _ssrUtils = {
7642
7652
  createComponentInstance,
7643
7653
  setupComponent,
@@ -7723,6 +7733,7 @@ exports.getTransitionRawChildren = getTransitionRawChildren;
7723
7733
  exports.guardReactiveProps = guardReactiveProps;
7724
7734
  exports.h = h;
7725
7735
  exports.handleError = handleError;
7736
+ exports.hasInjectionContext = hasInjectionContext;
7726
7737
  exports.initCustomFormatter = initCustomFormatter;
7727
7738
  exports.inject = inject;
7728
7739
  exports.isMemoSame = isMemoSame;
@@ -2966,6 +2966,9 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
2966
2966
  } else ;
2967
2967
  }
2968
2968
  }
2969
+ function hasInjectionContext() {
2970
+ return !!(currentInstance || currentRenderingInstance || currentApp);
2971
+ }
2969
2972
 
2970
2973
  function initProps(instance, rawProps, isStateful, isSSR = false) {
2971
2974
  const props = {};
@@ -5712,6 +5715,8 @@ function createComponentInstance(vnode, parent, suspense) {
5712
5715
  refs: shared.EMPTY_OBJ,
5713
5716
  setupState: shared.EMPTY_OBJ,
5714
5717
  setupContext: null,
5718
+ attrsProxy: null,
5719
+ slotsProxy: null,
5715
5720
  // suspense related
5716
5721
  suspense,
5717
5722
  suspenseId: suspense ? suspense.pendingId : 0,
@@ -5879,8 +5884,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
5879
5884
  unsetCurrentInstance();
5880
5885
  }
5881
5886
  }
5882
- function createAttrsProxy(instance) {
5883
- return new Proxy(
5887
+ function getAttrsProxy(instance) {
5888
+ return instance.attrsProxy || (instance.attrsProxy = new Proxy(
5884
5889
  instance.attrs,
5885
5890
  {
5886
5891
  get(target, key) {
@@ -5888,17 +5893,16 @@ function createAttrsProxy(instance) {
5888
5893
  return target[key];
5889
5894
  }
5890
5895
  }
5891
- );
5896
+ ));
5892
5897
  }
5893
5898
  function createSetupContext(instance) {
5894
5899
  const expose = (exposed) => {
5895
5900
  instance.exposed = exposed || {};
5896
5901
  };
5897
- let attrs;
5898
5902
  {
5899
5903
  return {
5900
5904
  get attrs() {
5901
- return attrs || (attrs = createAttrsProxy(instance));
5905
+ return getAttrsProxy(instance);
5902
5906
  },
5903
5907
  slots: instance.slots,
5904
5908
  emit: instance.emit,
@@ -5993,7 +5997,7 @@ function isMemoSame(cached, memo) {
5993
5997
  return true;
5994
5998
  }
5995
5999
 
5996
- const version = "3.3.0-alpha.12";
6000
+ const version = "3.3.0-alpha.13";
5997
6001
  const _ssrUtils = {
5998
6002
  createComponentInstance,
5999
6003
  setupComponent,
@@ -6079,6 +6083,7 @@ exports.getTransitionRawChildren = getTransitionRawChildren;
6079
6083
  exports.guardReactiveProps = guardReactiveProps;
6080
6084
  exports.h = h;
6081
6085
  exports.handleError = handleError;
6086
+ exports.hasInjectionContext = hasInjectionContext;
6082
6087
  exports.initCustomFormatter = initCustomFormatter;
6083
6088
  exports.inject = inject;
6084
6089
  exports.isMemoSame = isMemoSame;
@@ -660,6 +660,12 @@ export declare function provide<T>(key: InjectionKey<T> | string | number, value
660
660
  export declare function inject<T>(key: InjectionKey<T> | string): T | undefined;
661
661
  export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T, treatDefaultAsFactory?: false): T;
662
662
  export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T | (() => T), treatDefaultAsFactory: true): T;
663
+ /**
664
+ * Returns true if `inject()` can be used without warning about being called in the wrong place (e.g. outside of
665
+ * setup()). This is used by libraries that want to use `inject()` internally without triggering a warning to the end
666
+ * user. One example is `useRoute()` in `vue-router`.
667
+ */
668
+ export declare function hasInjectionContext(): boolean;
663
669
 
664
670
  export interface App<HostElement = any> {
665
671
  version: string;
@@ -1108,6 +1114,8 @@ export interface ComponentInternalInstance {
1108
1114
  slots: InternalSlots;
1109
1115
  refs: Data;
1110
1116
  emit: EmitFn;
1117
+ attrsProxy: Data | null;
1118
+ slotsProxy: Slots | null;
1111
1119
  /* removed internal: emitted */
1112
1120
  /* removed internal: propsDefaults */
1113
1121
  /* removed internal: setupState */
@@ -2915,6 +2915,8 @@ const PublicInstanceProxyHandlers = {
2915
2915
  if (key === "$attrs") {
2916
2916
  track(instance, "get", key);
2917
2917
  process.env.NODE_ENV !== "production" && markAttrsAccessed();
2918
+ } else if (process.env.NODE_ENV !== "production" && key === "$slots") {
2919
+ track(instance, "get", key);
2918
2920
  }
2919
2921
  return publicGetter(instance);
2920
2922
  } else if (
@@ -3878,6 +3880,9 @@ function inject(key, defaultValue, treatDefaultAsFactory = false) {
3878
3880
  warn(`inject() can only be used inside setup() or functional components.`);
3879
3881
  }
3880
3882
  }
3883
+ function hasInjectionContext() {
3884
+ return !!(currentInstance || currentRenderingInstance || currentApp);
3885
+ }
3881
3886
 
3882
3887
  function initProps(instance, rawProps, isStateful, isSSR = false) {
3883
3888
  const props = {};
@@ -4346,6 +4351,7 @@ const updateSlots = (instance, children, optimized) => {
4346
4351
  if (type) {
4347
4352
  if (process.env.NODE_ENV !== "production" && isHmrUpdating) {
4348
4353
  extend(slots, children);
4354
+ trigger(instance, "set", "$slots");
4349
4355
  } else if (optimized && type === 1) {
4350
4356
  needDeletionCheck = false;
4351
4357
  } else {
@@ -5297,7 +5303,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5297
5303
  areChildrenSVG,
5298
5304
  slotScopeIds
5299
5305
  );
5300
- if (process.env.NODE_ENV !== "production" && parentComponent && parentComponent.type.__hmrId) {
5306
+ if (process.env.NODE_ENV !== "production") {
5301
5307
  traverseStaticChildren(n1, n2);
5302
5308
  }
5303
5309
  } else if (!optimized) {
@@ -5491,7 +5497,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5491
5497
  isSVG,
5492
5498
  slotScopeIds
5493
5499
  );
5494
- if (process.env.NODE_ENV !== "production" && parentComponent && parentComponent.type.__hmrId) {
5500
+ if (process.env.NODE_ENV !== "production") {
5495
5501
  traverseStaticChildren(n1, n2);
5496
5502
  } else if (
5497
5503
  // #2080 if the stable fragment has a key, it's a <template v-for> that may
@@ -7079,6 +7085,8 @@ function createComponentInstance(vnode, parent, suspense) {
7079
7085
  refs: EMPTY_OBJ,
7080
7086
  setupState: EMPTY_OBJ,
7081
7087
  setupContext: null,
7088
+ attrsProxy: null,
7089
+ slotsProxy: null,
7082
7090
  // suspense related
7083
7091
  suspense,
7084
7092
  suspenseId: suspense ? suspense.pendingId : 0,
@@ -7320,8 +7328,8 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
7320
7328
  }
7321
7329
  }
7322
7330
  }
7323
- function createAttrsProxy(instance) {
7324
- return new Proxy(
7331
+ function getAttrsProxy(instance) {
7332
+ return instance.attrsProxy || (instance.attrsProxy = new Proxy(
7325
7333
  instance.attrs,
7326
7334
  process.env.NODE_ENV !== "production" ? {
7327
7335
  get(target, key) {
@@ -7343,7 +7351,23 @@ function createAttrsProxy(instance) {
7343
7351
  return target[key];
7344
7352
  }
7345
7353
  }
7346
- );
7354
+ ));
7355
+ }
7356
+ function getSlotsProxy(instance) {
7357
+ return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
7358
+ get(target, key) {
7359
+ track(instance, "get", "$slots");
7360
+ return target[key];
7361
+ },
7362
+ set() {
7363
+ warn(`setupContext.slots is readonly.`);
7364
+ return false;
7365
+ },
7366
+ deleteProperty() {
7367
+ warn(`setupContext.slots is readonly.`);
7368
+ return false;
7369
+ }
7370
+ }));
7347
7371
  }
7348
7372
  function createSetupContext(instance) {
7349
7373
  const expose = (exposed) => {
@@ -7369,14 +7393,13 @@ function createSetupContext(instance) {
7369
7393
  }
7370
7394
  instance.exposed = exposed || {};
7371
7395
  };
7372
- let attrs;
7373
7396
  if (process.env.NODE_ENV !== "production") {
7374
7397
  return Object.freeze({
7375
7398
  get attrs() {
7376
- return attrs || (attrs = createAttrsProxy(instance));
7399
+ return getAttrsProxy(instance);
7377
7400
  },
7378
7401
  get slots() {
7379
- return shallowReadonly(instance.slots);
7402
+ return getSlotsProxy(instance);
7380
7403
  },
7381
7404
  get emit() {
7382
7405
  return (event, ...args) => instance.emit(event, ...args);
@@ -7386,7 +7409,7 @@ function createSetupContext(instance) {
7386
7409
  } else {
7387
7410
  return {
7388
7411
  get attrs() {
7389
- return attrs || (attrs = createAttrsProxy(instance));
7412
+ return getAttrsProxy(instance);
7390
7413
  },
7391
7414
  slots: instance.slots,
7392
7415
  emit: instance.emit,
@@ -7684,7 +7707,7 @@ function isMemoSame(cached, memo) {
7684
7707
  return true;
7685
7708
  }
7686
7709
 
7687
- const version = "3.3.0-alpha.12";
7710
+ const version = "3.3.0-alpha.13";
7688
7711
  const _ssrUtils = {
7689
7712
  createComponentInstance,
7690
7713
  setupComponent,
@@ -7697,4 +7720,4 @@ const ssrUtils = _ssrUtils ;
7697
7720
  const resolveFilter = null;
7698
7721
  const compatUtils = null;
7699
7722
 
7700
- export { BaseTransition, BaseTransitionPropsValidators, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, initCustomFormatter, inject, isMemoSame, isRuntimeOnly, isVNode, mergeDefaults, mergeModels, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useAttrs, useModel, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withMemo, withScopeId };
7723
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compatUtils, computed, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, defineEmits, defineExpose, defineModel, defineOptions, defineProps, defineSlots, devtools, getCurrentInstance, getTransitionRawChildren, guardReactiveProps, h, handleError, hasInjectionContext, initCustomFormatter, inject, isMemoSame, isRuntimeOnly, isVNode, mergeDefaults, mergeModels, mergeProps, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, pushScopeId, queuePostFlushCb, registerRuntimeCompiler, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, ssrContextKey, ssrUtils, toHandlers, transformVNodeArgs, useAttrs, useModel, useSSRContext, useSlots, useTransitionState, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withMemo, withScopeId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/runtime-core",
3
- "version": "3.3.0-alpha.12",
3
+ "version": "3.3.0-alpha.13",
4
4
  "description": "@vue/runtime-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/runtime-core.esm-bundler.js",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "homepage": "https://github.com/vuejs/core/tree/main/packages/runtime-core#readme",
34
34
  "dependencies": {
35
- "@vue/shared": "3.3.0-alpha.12",
36
- "@vue/reactivity": "3.3.0-alpha.12"
35
+ "@vue/shared": "3.3.0-alpha.13",
36
+ "@vue/reactivity": "3.3.0-alpha.13"
37
37
  }
38
38
  }