@vue/runtime-core 3.4.0-rc.1 → 3.4.0-rc.3

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.
@@ -5,9 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var reactivity = require('@vue/reactivity');
6
6
  var shared = require('@vue/shared');
7
7
 
8
- function warn$1(msg, ...args) {
9
- return;
10
- }
11
8
  function assertNumber(val, type) {
12
9
  return;
13
10
  }
@@ -44,6 +41,37 @@ const ErrorCodes = {
44
41
  "SCHEDULER": 14,
45
42
  "14": "SCHEDULER"
46
43
  };
44
+ const ErrorTypeStrings$1 = {
45
+ ["sp"]: "serverPrefetch hook",
46
+ ["bc"]: "beforeCreate hook",
47
+ ["c"]: "created hook",
48
+ ["bm"]: "beforeMount hook",
49
+ ["m"]: "mounted hook",
50
+ ["bu"]: "beforeUpdate hook",
51
+ ["u"]: "updated",
52
+ ["bum"]: "beforeUnmount hook",
53
+ ["um"]: "unmounted hook",
54
+ ["a"]: "activated hook",
55
+ ["da"]: "deactivated hook",
56
+ ["ec"]: "errorCaptured hook",
57
+ ["rtc"]: "renderTracked hook",
58
+ ["rtg"]: "renderTriggered hook",
59
+ [0]: "setup function",
60
+ [1]: "render function",
61
+ [2]: "watcher getter",
62
+ [3]: "watcher callback",
63
+ [4]: "watcher cleanup function",
64
+ [5]: "native event handler",
65
+ [6]: "component event handler",
66
+ [7]: "vnode hook",
67
+ [8]: "directive hook",
68
+ [9]: "transition hook",
69
+ [10]: "app errorHandler",
70
+ [11]: "app warnHandler",
71
+ [12]: "ref function",
72
+ [13]: "async component loader",
73
+ [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
74
+ };
47
75
  function callWithErrorHandling(fn, instance, type, args) {
48
76
  let res;
49
77
  try {
@@ -236,38 +264,6 @@ function flushJobs(seen) {
236
264
  }
237
265
  }
238
266
 
239
- exports.devtools = void 0;
240
- let buffer = [];
241
- function setDevtoolsHook(hook, target) {
242
- var _a, _b;
243
- exports.devtools = hook;
244
- if (exports.devtools) {
245
- exports.devtools.enabled = true;
246
- buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
247
- buffer = [];
248
- } else if (
249
- // handle late devtools injection - only do this if we are in an actual
250
- // browser environment to avoid the timer handle stalling test runner exit
251
- // (#4815)
252
- typeof window !== "undefined" && // some envs mock window but not fully
253
- window.HTMLElement && // also exclude jsdom
254
- !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
255
- ) {
256
- const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
257
- replay.push((newHook) => {
258
- setDevtoolsHook(newHook, target);
259
- });
260
- setTimeout(() => {
261
- if (!exports.devtools) {
262
- target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
263
- buffer = [];
264
- }
265
- }, 3e3);
266
- } else {
267
- buffer = [];
268
- }
269
- }
270
-
271
267
  function emit(instance, event, ...rawArgs) {
272
268
  if (instance.isUnmounted)
273
269
  return;
@@ -647,7 +643,6 @@ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false
647
643
  const selfName = getComponentName(
648
644
  Component,
649
645
  false
650
- /* do not include inferred name to avoid breaking existing code */
651
646
  );
652
647
  if (selfName && (selfName === name || selfName === shared.camelize(name) || selfName === shared.capitalize(shared.camelize(name)))) {
653
648
  return Component;
@@ -1140,6 +1135,7 @@ function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace
1140
1135
  parentSuspense,
1141
1136
  parentComponent,
1142
1137
  node.parentNode,
1138
+ // eslint-disable-next-line no-restricted-globals
1143
1139
  document.createElement("div"),
1144
1140
  null,
1145
1141
  namespace,
@@ -1147,7 +1143,6 @@ function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace
1147
1143
  optimized,
1148
1144
  rendererInternals,
1149
1145
  true
1150
- /* hydrating */
1151
1146
  );
1152
1147
  const result = hydrateNode(
1153
1148
  node,
@@ -1241,7 +1236,14 @@ const INITIAL_WATCHER_VALUE = {};
1241
1236
  function watch(source, cb, options) {
1242
1237
  return doWatch(source, cb, options);
1243
1238
  }
1244
- function doWatch(source, cb, { immediate, deep, flush, once, onTrack, onTrigger } = shared.EMPTY_OBJ) {
1239
+ function doWatch(source, cb, {
1240
+ immediate,
1241
+ deep,
1242
+ flush,
1243
+ once,
1244
+ onTrack,
1245
+ onTrigger
1246
+ } = shared.EMPTY_OBJ) {
1245
1247
  var _a;
1246
1248
  if (cb && once) {
1247
1249
  const _cb = cb;
@@ -1892,7 +1894,6 @@ function defineAsyncComponent(source) {
1892
1894
  instance,
1893
1895
  13,
1894
1896
  !errorComponent
1895
- /* do not throw in dev if user provided error component */
1896
1897
  );
1897
1898
  };
1898
1899
  if (suspensible && instance.suspense || isInSSRComponentSetup) {
@@ -2511,9 +2512,9 @@ function useSlots() {
2511
2512
  function useAttrs() {
2512
2513
  return getContext().attrs;
2513
2514
  }
2514
- function useModel(props, name) {
2515
+ function useModel(props, name, options = shared.EMPTY_OBJ) {
2515
2516
  const i = getCurrentInstance();
2516
- return reactivity.customRef((track, trigger) => {
2517
+ const res = reactivity.customRef((track, trigger) => {
2517
2518
  let localValue;
2518
2519
  watchSyncEffect(() => {
2519
2520
  const propValue = props[name];
@@ -2525,7 +2526,7 @@ function useModel(props, name) {
2525
2526
  return {
2526
2527
  get() {
2527
2528
  track();
2528
- return localValue;
2529
+ return options.get ? options.get(localValue) : localValue;
2529
2530
  },
2530
2531
  set(value) {
2531
2532
  const rawProps = i.vnode.props;
@@ -2533,10 +2534,24 @@ function useModel(props, name) {
2533
2534
  localValue = value;
2534
2535
  trigger();
2535
2536
  }
2536
- i.emit(`update:${name}`, value);
2537
+ i.emit(`update:${name}`, options.set ? options.set(value) : value);
2537
2538
  }
2538
2539
  };
2539
2540
  });
2541
+ const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
2542
+ res[Symbol.iterator] = () => {
2543
+ let i2 = 0;
2544
+ return {
2545
+ next() {
2546
+ if (i2 < 2) {
2547
+ return { value: i2++ ? props[modifierKey] : res, done: false };
2548
+ } else {
2549
+ return { done: true };
2550
+ }
2551
+ }
2552
+ };
2553
+ };
2554
+ return res;
2540
2555
  }
2541
2556
  function getContext() {
2542
2557
  const i = getCurrentInstance();
@@ -2751,7 +2766,6 @@ function resolveInjections(injectOptions, ctx, checkDuplicateProperties = shared
2751
2766
  opt.from || key,
2752
2767
  opt.default,
2753
2768
  true
2754
- /* treat default function as factory */
2755
2769
  );
2756
2770
  } else {
2757
2771
  injected = inject(opt.from || key);
@@ -3143,7 +3157,6 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3143
3157
  value,
3144
3158
  instance,
3145
3159
  false
3146
- /* isAbsent */
3147
3160
  );
3148
3161
  }
3149
3162
  } else {
@@ -3175,7 +3188,6 @@ function updateProps(instance, rawProps, rawPrevProps, optimized) {
3175
3188
  void 0,
3176
3189
  instance,
3177
3190
  true
3178
- /* isAbsent */
3179
3191
  );
3180
3192
  }
3181
3193
  } else {
@@ -5586,7 +5598,6 @@ function createElementBlock(type, props, children, patchFlag, dynamicProps, shap
5586
5598
  dynamicProps,
5587
5599
  shapeFlag,
5588
5600
  true
5589
- /* isBlock */
5590
5601
  )
5591
5602
  );
5592
5603
  }
@@ -5599,7 +5610,6 @@ function createBlock(type, props, children, patchFlag, dynamicProps) {
5599
5610
  patchFlag,
5600
5611
  dynamicProps,
5601
5612
  true
5602
- /* isBlock: prevent a block from tracking itself */
5603
5613
  )
5604
5614
  );
5605
5615
  }
@@ -6037,7 +6047,10 @@ function setupStatefulComponent(instance, isSSR) {
6037
6047
  setup,
6038
6048
  instance,
6039
6049
  0,
6040
- [instance.props, setupContext]
6050
+ [
6051
+ instance.props,
6052
+ setupContext
6053
+ ]
6041
6054
  );
6042
6055
  reactivity.resetTracking();
6043
6056
  unsetCurrentInstance();
@@ -6232,8 +6245,11 @@ function isMemoSame(cached, memo) {
6232
6245
  return true;
6233
6246
  }
6234
6247
 
6235
- const version = "3.4.0-rc.1";
6236
- const ErrorTypeStrings = null;
6248
+ const version = "3.4.0-rc.3";
6249
+ const warn$1 = shared.NOOP;
6250
+ const ErrorTypeStrings = ErrorTypeStrings$1 ;
6251
+ const devtools = void 0;
6252
+ const setDevtoolsHook = shared.NOOP;
6237
6253
  const _ssrUtils = {
6238
6254
  createComponentInstance,
6239
6255
  setupComponent,
@@ -6320,6 +6336,7 @@ exports.defineModel = defineModel;
6320
6336
  exports.defineOptions = defineOptions;
6321
6337
  exports.defineProps = defineProps;
6322
6338
  exports.defineSlots = defineSlots;
6339
+ exports.devtools = devtools;
6323
6340
  exports.getCurrentInstance = getCurrentInstance;
6324
6341
  exports.getTransitionRawChildren = getTransitionRawChildren;
6325
6342
  exports.guardReactiveProps = guardReactiveProps;
@@ -845,7 +845,7 @@ declare enum TeleportMoveTypes {
845
845
  REORDER = 2
846
846
  }
847
847
  declare function moveTeleport(vnode: VNode, container: RendererElement, parentAnchor: RendererNode | null, { o: { insert }, m: move }: RendererInternals, moveType?: TeleportMoveTypes): void;
848
- declare function hydrateTeleport(node: Node, vnode: TeleportVNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, slotScopeIds: string[] | null, optimized: boolean, { o: { nextSibling, parentNode, querySelector } }: RendererInternals<Node, Element>, hydrateChildren: (node: Node | null, vnode: VNode, container: Element, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, slotScopeIds: string[] | null, optimized: boolean) => Node | null): Node | null;
848
+ declare function hydrateTeleport(node: Node, vnode: TeleportVNode, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, slotScopeIds: string[] | null, optimized: boolean, { o: { nextSibling, parentNode, querySelector }, }: RendererInternals<Node, Element>, hydrateChildren: (node: Node | null, vnode: VNode, container: Element, parentComponent: ComponentInternalInstance | null, parentSuspense: SuspenseBoundary | null, slotScopeIds: string[] | null, optimized: boolean) => Node | null): Node | null;
849
849
  export declare const Teleport: {
850
850
  new (): {
851
851
  $props: VNodeProps & TeleportProps;
@@ -1278,6 +1278,10 @@ export declare function defineOptions<RawBindings = {}, D = {}, C extends Comput
1278
1278
  slots?: undefined;
1279
1279
  }): void;
1280
1280
  export declare function defineSlots<S extends Record<string, any> = Record<string, any>>(): StrictUnwrapSlotsType<SlotsType<S>>;
1281
+ export type ModelRef<T, M extends string | number | symbol = string> = Ref<T> & [
1282
+ ModelRef<T, M>,
1283
+ Record<M, true | undefined>
1284
+ ];
1281
1285
  /**
1282
1286
  * Vue `<script setup>` compiler macro for declaring a
1283
1287
  * two-way binding prop that can be consumed via `v-model` from the parent
@@ -1311,20 +1315,20 @@ export declare function defineSlots<S extends Record<string, any> = Record<strin
1311
1315
  * const count = defineModel<number>('count', { default: 0 })
1312
1316
  * ```
1313
1317
  */
1314
- export declare function defineModel<T>(options: {
1318
+ export declare function defineModel<T, M extends string | number | symbol = string>(options: {
1315
1319
  required: true;
1316
- } & PropOptions<T>): Ref<T>;
1317
- export declare function defineModel<T>(options: {
1320
+ } & PropOptions<T> & UseModelOptions<T>): ModelRef<T, M>;
1321
+ export declare function defineModel<T, M extends string | number | symbol = string>(options: {
1318
1322
  default: any;
1319
- } & PropOptions<T>): Ref<T>;
1320
- export declare function defineModel<T>(options?: PropOptions<T>): Ref<T | undefined>;
1321
- export declare function defineModel<T>(name: string, options: {
1323
+ } & PropOptions<T> & UseModelOptions<T>): ModelRef<T, M>;
1324
+ export declare function defineModel<T, M extends string | number | symbol = string>(options?: PropOptions<T> & UseModelOptions<T>): ModelRef<T | undefined, M>;
1325
+ export declare function defineModel<T, M extends string | number | symbol = string>(name: string, options: {
1322
1326
  required: true;
1323
- } & PropOptions<T>): Ref<T>;
1324
- export declare function defineModel<T>(name: string, options: {
1327
+ } & PropOptions<T> & UseModelOptions<T>): ModelRef<T, M>;
1328
+ export declare function defineModel<T, M extends string | number | symbol = string>(name: string, options: {
1325
1329
  default: any;
1326
- } & PropOptions<T>): Ref<T>;
1327
- export declare function defineModel<T>(name: string, options?: PropOptions<T>): Ref<T | undefined>;
1330
+ } & PropOptions<T> & UseModelOptions<T>): ModelRef<T, M>;
1331
+ export declare function defineModel<T, M extends string | number | symbol = string>(name: string, options?: PropOptions<T> & UseModelOptions<T>): ModelRef<T | undefined, M>;
1328
1332
  type NotUndefined<T> = T extends undefined ? never : T;
1329
1333
  type InferDefaults<T> = {
1330
1334
  [K in keyof T]?: InferDefault<T, T[K]>;
@@ -1359,7 +1363,11 @@ type PropsWithDefaults<T, Defaults extends InferDefaults<T>, BKeys extends keyof
1359
1363
  export declare function withDefaults<T, BKeys extends keyof T, Defaults extends InferDefaults<T>>(props: DefineProps<T, BKeys>, defaults: Defaults): PropsWithDefaults<T, Defaults, BKeys>;
1360
1364
  export declare function useSlots(): SetupContext['slots'];
1361
1365
  export declare function useAttrs(): SetupContext['attrs'];
1362
- export declare function useModel<T extends Record<string, any>, K extends keyof T>(props: T, name: K): Ref<T[K]>;
1366
+ type UseModelOptions<T = any> = {
1367
+ get?: (v: T) => any;
1368
+ set?: (v: T) => any;
1369
+ };
1370
+ export declare function useModel<M extends string | number | symbol, T extends Record<string, any>, K extends keyof T>(props: T, name: K, options?: UseModelOptions<T[K]>): ModelRef<T[K], M>;
1363
1371
 
1364
1372
  type RawProps = VNodeProps & {
1365
1373
  __v_isVNode?: never;
@@ -1404,7 +1412,7 @@ export declare function h<P>(type: string | Component<P>, props?: (RawProps & P)
1404
1412
  export declare const ssrContextKey: unique symbol;
1405
1413
  export declare const useSSRContext: <T = Record<string, any>>() => T | undefined;
1406
1414
 
1407
- export declare function warn(msg: string, ...args: any[]): void;
1415
+ declare function warn$1(msg: string, ...args: any[]): void;
1408
1416
 
1409
1417
  export declare enum ErrorCodes {
1410
1418
  SETUP_FUNCTION = 0,
@@ -1449,8 +1457,7 @@ interface DevtoolsHook {
1449
1457
  */
1450
1458
  cleanupBuffer?: (matchArg: unknown) => boolean;
1451
1459
  }
1452
- export declare let devtools: DevtoolsHook;
1453
- export declare function setDevtoolsHook(hook: DevtoolsHook, target: any): void;
1460
+ declare function setDevtoolsHook$1(hook: DevtoolsHook, target: any): void;
1454
1461
 
1455
1462
  type HMRComponent = ComponentOptions | ClassComponent;
1456
1463
  export interface HMRRuntime {
@@ -1618,6 +1625,11 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
1618
1625
 
1619
1626
  export declare const version: string;
1620
1627
 
1628
+ export declare const warn: typeof warn$1;
1629
+
1630
+ export declare const devtools: DevtoolsHook;
1631
+ export declare const setDevtoolsHook: typeof setDevtoolsHook$1;
1632
+
1621
1633
  declare module '@vue/reactivity' {
1622
1634
  interface RefUnwrapBailTypes {
1623
1635
  runtimeCoreBailTypes: VNode | {