vue 3.3.0-alpha.5 → 3.3.0-alpha.7

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.d.ts CHANGED
@@ -2,6 +2,10 @@ import { CompilerOptions } from '@vue/compiler-dom';
2
2
  import { RenderFunction } from '@vue/runtime-dom';
3
3
  export * from '@vue/runtime-dom';
4
4
 
5
- declare function compileToFunction(template: string | HTMLElement, options?: CompilerOptions): RenderFunction;
5
+ export declare function compileToFunction(template: string | HTMLElement, options?: CompilerOptions): RenderFunction;
6
6
 
7
7
  export { compileToFunction as compile };
8
+ // this is appended to the end of ../dist/vue.d.ts during build.
9
+ // imports the global JSX namespace registration for compat.
10
+ // TODO: remove in 3.4
11
+ import '../jsx'
@@ -1329,6 +1329,9 @@ function triggerRef(ref2) {
1329
1329
  function unref(ref2) {
1330
1330
  return isRef(ref2) ? ref2.value : ref2;
1331
1331
  }
1332
+ function toValue(source) {
1333
+ return isFunction(source) ? source() : unref(source);
1334
+ }
1332
1335
  const shallowUnwrapHandlers = {
1333
1336
  get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
1334
1337
  set: (target, key, value, receiver) => {
@@ -1371,7 +1374,7 @@ function toRefs(object) {
1371
1374
  }
1372
1375
  const ret = isArray(object) ? new Array(object.length) : {};
1373
1376
  for (const key in object) {
1374
- ret[key] = toRef(object, key);
1377
+ ret[key] = propertyToRef(object, key);
1375
1378
  }
1376
1379
  return ret;
1377
1380
  }
@@ -1393,9 +1396,34 @@ class ObjectRefImpl {
1393
1396
  return getDepFromReactive(toRaw(this._object), this._key);
1394
1397
  }
1395
1398
  }
1396
- function toRef(object, key, defaultValue) {
1397
- const val = object[key];
1398
- return isRef(val) ? val : new ObjectRefImpl(object, key, defaultValue);
1399
+ class GetterRefImpl {
1400
+ constructor(_getter) {
1401
+ this._getter = _getter;
1402
+ this.__v_isRef = true;
1403
+ this.__v_isReadonly = true;
1404
+ }
1405
+ get value() {
1406
+ return this._getter();
1407
+ }
1408
+ }
1409
+ function toRef(source, key, defaultValue) {
1410
+ if (isRef(source)) {
1411
+ return source;
1412
+ } else if (isFunction(source)) {
1413
+ return new GetterRefImpl(source);
1414
+ } else if (isObject(source) && arguments.length > 1) {
1415
+ return propertyToRef(source, key, defaultValue);
1416
+ } else {
1417
+ return ref(source);
1418
+ }
1419
+ }
1420
+ function propertyToRef(source, key, defaultValue) {
1421
+ const val = source[key];
1422
+ return isRef(val) ? val : new ObjectRefImpl(
1423
+ source,
1424
+ key,
1425
+ defaultValue
1426
+ );
1399
1427
  }
1400
1428
 
1401
1429
  class ComputedRefImpl {
@@ -3614,8 +3642,8 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3614
3642
  return ret;
3615
3643
  }
3616
3644
 
3617
- function defineComponent(options) {
3618
- return isFunction(options) ? { setup: options, name: options.name } : options;
3645
+ function defineComponent(options, extraOptions) {
3646
+ return isFunction(options) ? extend({}, extraOptions, { setup: options, name: options.name }) : options;
3619
3647
  }
3620
3648
 
3621
3649
  const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
@@ -5112,7 +5140,7 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5112
5140
  const hasDefault = hasOwn(opt, "default");
5113
5141
  if (hasDefault && value === void 0) {
5114
5142
  const defaultValue = opt.default;
5115
- if (opt.type !== Function && isFunction(defaultValue)) {
5143
+ if (opt.type !== Function && !opt.skipFactory && isFunction(defaultValue)) {
5116
5144
  const { propsDefaults } = instance;
5117
5145
  if (key in propsDefaults) {
5118
5146
  value = propsDefaults[key];
@@ -5248,7 +5276,7 @@ function validateProps(rawProps, props, instance) {
5248
5276
  }
5249
5277
  }
5250
5278
  function validateProp(name, value, prop, isAbsent) {
5251
- const { type, required, validator } = prop;
5279
+ const { type, required, validator, skipCheck } = prop;
5252
5280
  if (required && isAbsent) {
5253
5281
  warn('Missing required prop: "' + name + '"');
5254
5282
  return;
@@ -5256,7 +5284,7 @@ function validateProp(name, value, prop, isAbsent) {
5256
5284
  if (value == null && !prop.required) {
5257
5285
  return;
5258
5286
  }
5259
- if (type != null && type !== true) {
5287
+ if (type != null && type !== true && !skipCheck) {
5260
5288
  let isValid = false;
5261
5289
  const types = isArray(type) ? type : [type];
5262
5290
  const expectedTypes = [];
@@ -8645,6 +8673,16 @@ function defineExpose(exposed) {
8645
8673
  warnRuntimeUsage(`defineExpose`);
8646
8674
  }
8647
8675
  }
8676
+ function defineOptions(options) {
8677
+ {
8678
+ warnRuntimeUsage(`defineOptions`);
8679
+ }
8680
+ }
8681
+ function defineSlots() {
8682
+ {
8683
+ warnRuntimeUsage(`defineSlots`);
8684
+ }
8685
+ }
8648
8686
  function withDefaults(props, defaults) {
8649
8687
  {
8650
8688
  warnRuntimeUsage(`withDefaults`);
@@ -8670,18 +8708,23 @@ function mergeDefaults(raw, defaults) {
8670
8708
  {}
8671
8709
  ) : raw;
8672
8710
  for (const key in defaults) {
8673
- const opt = props[key];
8711
+ if (key.startsWith("__skip"))
8712
+ continue;
8713
+ let opt = props[key];
8674
8714
  if (opt) {
8675
8715
  if (isArray(opt) || isFunction(opt)) {
8676
- props[key] = { type: opt, default: defaults[key] };
8716
+ opt = props[key] = { type: opt, default: defaults[key] };
8677
8717
  } else {
8678
8718
  opt.default = defaults[key];
8679
8719
  }
8680
8720
  } else if (opt === null) {
8681
- props[key] = { default: defaults[key] };
8721
+ opt = props[key] = { default: defaults[key] };
8682
8722
  } else {
8683
8723
  warn(`props default key "${key}" has no corresponding declaration.`);
8684
8724
  }
8725
+ if (opt && defaults[`__skip_${key}`]) {
8726
+ opt.skipFactory = true;
8727
+ }
8685
8728
  }
8686
8729
  return props;
8687
8730
  }
@@ -8950,7 +8993,7 @@ function isMemoSame(cached, memo) {
8950
8993
  return true;
8951
8994
  }
8952
8995
 
8953
- const version = "3.3.0-alpha.5";
8996
+ const version = "3.3.0-alpha.7";
8954
8997
  const ssrUtils = null;
8955
8998
  const resolveFilter = null;
8956
8999
  const compatUtils = null;
@@ -10462,8 +10505,10 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10462
10505
  defineCustomElement: defineCustomElement,
10463
10506
  defineEmits: defineEmits,
10464
10507
  defineExpose: defineExpose,
10508
+ defineOptions: defineOptions,
10465
10509
  defineProps: defineProps,
10466
10510
  defineSSRCustomElement: defineSSRCustomElement,
10511
+ defineSlots: defineSlots,
10467
10512
  get devtools () { return devtools; },
10468
10513
  effect: effect,
10469
10514
  effectScope: effectScope,
@@ -10538,6 +10583,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10538
10583
  toRaw: toRaw,
10539
10584
  toRef: toRef,
10540
10585
  toRefs: toRefs,
10586
+ toValue: toValue,
10541
10587
  transformVNodeArgs: transformVNodeArgs,
10542
10588
  triggerRef: triggerRef,
10543
10589
  unref: unref,
@@ -15205,4 +15251,4 @@ ${codeFrame}` : message);
15205
15251
  }
15206
15252
  registerRuntimeCompiler(compileToFunction);
15207
15253
 
15208
- export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineProps, defineSSRCustomElement, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };
15254
+ export { BaseTransition, BaseTransitionPropsValidators, Comment, EffectScope, Fragment, KeepAlive, ReactiveEffect, Static, Suspense, Teleport, Text, Transition, TransitionGroup, VueElement, assertNumber, callWithAsyncErrorHandling, callWithErrorHandling, camelize, capitalize, cloneVNode, compatUtils, compileToFunction as compile, computed, createApp, createBlock, createCommentVNode, createElementBlock, createBaseVNode as createElementVNode, createHydrationRenderer, createPropsRestProxy, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, customRef, defineAsyncComponent, defineComponent, defineCustomElement, defineEmits, defineExpose, defineOptions, defineProps, defineSSRCustomElement, defineSlots, devtools, effect, effectScope, getCurrentInstance, getCurrentScope, getTransitionRawChildren, guardReactiveProps, h, handleError, hydrate, initCustomFormatter, initDirectivesForSSR, inject, isMemoSame, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isShallow, isVNode, markRaw, mergeDefaults, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveFilter, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, stop, toDisplayString, toHandlerKey, toHandlers, toRaw, toRef, toRefs, toValue, transformVNodeArgs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSSRContext, useSlots, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect, withAsyncContext, withCtx, withDefaults, withDirectives, withKeys, withMemo, withModifiers, withScopeId };