@vue/composition-api
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -0,5 +1,37 @@ | ||
# 0.6.0 | ||
Great thanks to @pikax for #311, making most of the APIs better aligned with the latest vue-next. | ||
## BREAKING CHANGE | ||
- The `lazy` option of `watch` has been replaced by the opposite `immediate` option, which defaults to false. (It's ignored when using the effect signature). [more details](https://github.com/vuejs/vue-next/blob/master/CHANGELOG.md#breaking-changes-12) (#266) | ||
- Rename `nonReactive` to `markRaw` | ||
- `UnwrapRef` types from `vue-next` this can cause some incompatibilities. | ||
## Bug Fixes | ||
- Added missing reactivity API from vue-next, #311, @pikax | ||
- Fix return type of `toRefs`, #315 | ||
- Fix incorrect ref typing, #344, @antfu | ||
- Binding context vm when using function without parentheses, #148, @pikax | ||
- **computed**: destroy helper vm of computed to prevent memleak, #277, @LinusBorg | ||
- Remove the surplus Function type from PropType, #352, @pikax | ||
## Features | ||
- Added `unref`(#309), `isReactive` (#327), `toRef` (#313), `UnwrapRef` (#247) | ||
- Added `shallowReactive`, `shallowRef` | ||
- Added `toRaw` | ||
- `getCurrentInstance` available on the lifecycle hooks (`onMounted`, etc) | ||
- `getCurrentInstance` returns `undefined` when called outside setup instead of throwing exception | ||
## Types | ||
- Align reactivity types with `vue-next` | ||
# 0.5.0 | ||
- New: `watchEffect` function, lingin up with the latest version of the RFC ([RFC docs](https://vue-composition-api-rfc.netlify.com/api.html#watcheffect)) (#275) | ||
- Fix: `setup` from a mixin should called before the componen's own (#276) | ||
- Fix: `setup` from a mixin should called before the component's own (#276) | ||
- Fix(types): Fix corner case in `UnWrapRef` internal type (#261) | ||
@@ -6,0 +38,0 @@ - types: Add `Element` to bailout types for unwrapping (#278) |
@@ -6,4 +6,9 @@ import { Ref } from '../reactivity'; | ||
} | ||
export declare function computed<T>(getter: Option<T>['get']): Readonly<Ref<Readonly<T>>>; | ||
export declare function computed<T>(options: Option<T>): Ref<Readonly<T>>; | ||
export interface ComputedRef<T = any> extends WritableComputedRef<T> { | ||
readonly value: T; | ||
} | ||
export interface WritableComputedRef<T> extends Ref<T> { | ||
} | ||
export declare function computed<T>(getter: Option<T>['get']): ComputedRef<T>; | ||
export declare function computed<T>(options: Option<T>): WritableComputedRef<T>; | ||
export {}; |
export interface InjectionKey<T> extends Symbol { | ||
} | ||
export declare function provide<T>(key: InjectionKey<T> | string, value: T): void; | ||
export declare function inject<T>(key: InjectionKey<T> | string): T | void; | ||
export declare function inject<T>(key: InjectionKey<T> | string): T | undefined; | ||
export declare function inject<T>(key: InjectionKey<T> | string, defaultValue: T): T; |
@@ -1,1 +0,1 @@ | ||
export { reactive, ref, Ref, isRef, toRefs, set } from '../reactivity'; | ||
export { reactive, ref, Ref, isRef, toRefs, set, toRef, isReactive, UnwrapRef, markRaw, unref, shallowReactive, toRaw, shallowRef, triggerRef, } from '../reactivity'; |
import { Ref } from '../reactivity'; | ||
declare type CleanupRegistrator = (invalidate: () => void) => void; | ||
declare type SimpleEffect = (onCleanup: CleanupRegistrator) => void; | ||
declare type StopHandle = () => void; | ||
declare type WatcherCallBack<T> = (newVal: T, oldVal: T, onCleanup: CleanupRegistrator) => void; | ||
declare type WatcherSource<T> = Ref<T> | (() => T); | ||
import { ComputedRef } from './computed'; | ||
export declare type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void; | ||
export declare type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T); | ||
export declare type WatchCallback<V = any, OV = any> = (value: V, oldValue: OV, onInvalidate: InvalidateCbRegistrator) => any; | ||
declare type MapSources<T> = { | ||
[K in keyof T]: T[K] extends WatcherSource<infer V> ? V : never; | ||
[K in keyof T]: T[K] extends WatchSource<infer V> ? V : never; | ||
}; | ||
declare type FlushMode = 'pre' | 'post' | 'sync'; | ||
interface WatcherOption { | ||
lazy: boolean; | ||
deep: boolean; | ||
flush: FlushMode; | ||
declare type MapOldSources<T, Immediate> = { | ||
[K in keyof T]: T[K] extends WatchSource<infer V> ? Immediate extends true ? V | undefined : V : never; | ||
}; | ||
export interface WatchOptionsBase { | ||
flush?: FlushMode; | ||
} | ||
declare type InvalidateCbRegistrator = (cb: () => void) => void; | ||
export declare type FlushMode = 'pre' | 'post' | 'sync'; | ||
export interface WatchOptions<Immediate = boolean> extends WatchOptionsBase { | ||
immediate?: Immediate; | ||
deep?: boolean; | ||
} | ||
export interface VueWatcher { | ||
@@ -21,6 +26,7 @@ lazy: boolean; | ||
} | ||
export declare function watchEffect(effect: SimpleEffect, options?: Omit<Partial<WatcherOption>, 'lazy'>): StopHandle; | ||
export declare function watch<T = any>(source: SimpleEffect, options?: Omit<Partial<WatcherOption>, 'lazy'>): StopHandle; | ||
export declare function watch<T = any>(source: WatcherSource<T>, cb: WatcherCallBack<T>, options?: Partial<WatcherOption>): StopHandle; | ||
export declare function watch<T extends WatcherSource<unknown>[]>(sources: T, cb: (newValues: MapSources<T>, oldValues: MapSources<T>, onCleanup: CleanupRegistrator) => any, options?: Partial<WatcherOption>): StopHandle; | ||
export declare type WatchStopHandle = () => void; | ||
export declare function watchEffect(effect: WatchEffect, options?: WatchOptionsBase): WatchStopHandle; | ||
export declare function watch<T extends Readonly<WatchSource<unknown>[]>, Immediate extends Readonly<boolean> = false>(sources: T, cb: WatchCallback<MapSources<T>, MapOldSources<T, Immediate>>, options?: WatchOptions<Immediate>): WatchStopHandle; | ||
export declare function watch<T, Immediate extends Readonly<boolean> = false>(source: WatchSource<T>, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle; | ||
export declare function watch<T extends object, Immediate extends Readonly<boolean> = false>(source: T, cb: WatchCallback<T, Immediate extends true ? T | undefined : T>, options?: WatchOptions<Immediate>): WatchStopHandle; | ||
export {}; |
@@ -28,2 +28,4 @@ import { Data } from './component'; | ||
declare type OptionalKeys<T, MakeDefaultRequired> = Exclude<keyof T, RequiredKeys<T, MakeDefaultRequired>>; | ||
declare type ExtractFunctionPropType<T extends Function, TArgs extends Array<any> = any[], TResult = any> = T extends (...args: TArgs) => TResult ? T : never; | ||
declare type ExtractCorrectPropType<T> = T extends Function ? ExtractFunctionPropType<T> : Exclude<T, Function>; | ||
declare type InferPropType<T> = T extends null ? any : T extends { | ||
@@ -35,3 +37,3 @@ type: null; | ||
[key: string]: any; | ||
} : T extends Prop<infer V, true | false> ? V : T; | ||
} : T extends Prop<infer V, true | false> ? ExtractCorrectPropType<V> : T; | ||
export declare type ExtractPropTypes<O, MakeDefaultRequired extends boolean = true> = { | ||
@@ -38,0 +40,0 @@ readonly [K in RequiredKeys<O, MakeDefaultRequired>]: InferPropType<O[K]>; |
import Vue, { VNode, ComponentOptions, VueConstructor } from 'vue'; | ||
import { ComponentInstance } from './component'; | ||
export declare function ensureCurrentVMInFn(hook: string): ComponentInstance; | ||
export declare function currentVMInFn(hook: string): ComponentInstance | null; | ||
export declare function defineComponentInstance<V extends Vue = Vue>(Ctor: VueConstructor<V>, options?: ComponentOptions<V>): import("vue/types/vue").CombinedVueInstance<V, object, object, object, Record<never, any>>; | ||
@@ -5,0 +5,0 @@ export declare function isComponentInstance(obj: any): boolean | null; |
@@ -9,3 +9,3 @@ import Vue, { VueConstructor } from 'vue'; | ||
declare const plugin: { | ||
install: (Vue: VueConstructor<Vue>) => void; | ||
install: (Vue: VueConstructor) => void; | ||
}; | ||
@@ -12,0 +12,0 @@ export default plugin; |
@@ -1,3 +0,3 @@ | ||
export { reactive, isReactive, nonReactive } from './reactive'; | ||
export { ref, isRef, Ref, createRef, UnwrapRef, toRefs } from './ref'; | ||
export { reactive, isReactive, markRaw, shallowReactive, toRaw, isRaw } from './reactive'; | ||
export { ref, isRef, Ref, createRef, UnwrapRef, toRefs, toRef, unref, shallowRef, triggerRef, } from './ref'; | ||
export { set } from './set'; |
import { AnyObject } from '../types/basic'; | ||
import { UnwrapRef } from './ref'; | ||
export declare function isRaw(obj: any): boolean; | ||
export declare function isReactive(obj: any): boolean; | ||
@@ -8,9 +9,12 @@ /** | ||
export declare function defineAccessControl(target: AnyObject, key: any, val?: any): void; | ||
export declare function shallowReactive<T extends object = any>(obj: T): T; | ||
export declare function markReactive(target: any, shallow?: boolean): void; | ||
/** | ||
* Make obj reactivity | ||
*/ | ||
export declare function reactive<T = any>(obj: T): UnwrapRef<T>; | ||
export declare function reactive<T extends object>(obj: T): UnwrapRef<T>; | ||
/** | ||
* Make sure obj can't be a reactive | ||
*/ | ||
export declare function nonReactive<T = any>(obj: T): T; | ||
export declare function markRaw<T extends object>(obj: T): T; | ||
export declare function toRaw<T>(observed: T): T; |
import { Data } from '../component'; | ||
import { HasDefined } from '../types/basic'; | ||
declare type BailTypes = Function | Map<any, any> | Set<any> | WeakMap<any, any> | WeakSet<any> | Element; | ||
declare type BaseTypes = string | number | boolean; | ||
export interface Ref<T> { | ||
import { ComputedRef } from '../apis/computed'; | ||
declare const _refBrand: unique symbol; | ||
export interface Ref<T = any> { | ||
readonly [_refBrand]: true; | ||
value: T; | ||
} | ||
export declare type UnwrapRef<T> = T extends Ref<infer V> ? UnwrapRef2<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef2<T[K]>; | ||
} : T; | ||
declare type UnwrapRef2<T> = T extends Ref<infer V> ? UnwrapRef3<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef3<T[K]>; | ||
} : T; | ||
declare type UnwrapRef3<T> = T extends Ref<infer V> ? UnwrapRef4<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef4<T[K]>; | ||
} : T; | ||
declare type UnwrapRef4<T> = T extends Ref<infer V> ? UnwrapRef5<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef5<T[K]>; | ||
} : T; | ||
declare type UnwrapRef5<T> = T extends Ref<infer V> ? UnwrapRef6<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef6<T[K]>; | ||
} : T; | ||
declare type UnwrapRef6<T> = T extends Ref<infer V> ? UnwrapRef7<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef7<T[K]>; | ||
} : T; | ||
declare type UnwrapRef7<T> = T extends Ref<infer V> ? UnwrapRef8<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef8<T[K]>; | ||
} : T; | ||
declare type UnwrapRef8<T> = T extends Ref<infer V> ? UnwrapRef9<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef9<T[K]>; | ||
} : T; | ||
declare type UnwrapRef9<T> = T extends Ref<infer V> ? UnwrapRef10<V> : T extends BailTypes | BaseTypes ? T : T extends object ? { | ||
[K in keyof T]: UnwrapRef10<T[K]>; | ||
} : T; | ||
declare type UnwrapRef10<T> = T extends Ref<infer V> ? V : T; | ||
export declare type ToRefs<T = any> = { | ||
[K in keyof T]: Ref<T[K]>; | ||
}; | ||
export declare type CollectionTypes = IterableCollections | WeakCollections; | ||
declare type IterableCollections = Map<any, any> | Set<any>; | ||
declare type WeakCollections = WeakMap<any, any> | WeakSet<any>; | ||
declare type BaseTypes = string | number | boolean | Node | Window; | ||
export declare type UnwrapRef<T> = T extends ComputedRef<infer V> ? UnwrapRefSimple<V> : T extends Ref<infer V> ? UnwrapRefSimple<V> : UnwrapRefSimple<T>; | ||
declare type UnwrapRefSimple<T> = T extends Function | CollectionTypes | BaseTypes | Ref ? T : T extends Array<any> ? T : T extends object ? UnwrappedObject<T> : T; | ||
declare type SymbolExtract<T> = (T extends { | ||
[Symbol.asyncIterator]: infer V; | ||
} ? { | ||
[Symbol.asyncIterator]: V; | ||
} : {}) & (T extends { | ||
[Symbol.hasInstance]: infer V; | ||
} ? { | ||
[Symbol.hasInstance]: V; | ||
} : {}) & (T extends { | ||
[Symbol.isConcatSpreadable]: infer V; | ||
} ? { | ||
[Symbol.isConcatSpreadable]: V; | ||
} : {}) & (T extends { | ||
[Symbol.iterator]: infer V; | ||
} ? { | ||
[Symbol.iterator]: V; | ||
} : {}) & (T extends { | ||
[Symbol.match]: infer V; | ||
} ? { | ||
[Symbol.match]: V; | ||
} : {}) & (T extends { | ||
[Symbol.replace]: infer V; | ||
} ? { | ||
[Symbol.replace]: V; | ||
} : {}) & (T extends { | ||
[Symbol.search]: infer V; | ||
} ? { | ||
[Symbol.search]: V; | ||
} : {}) & (T extends { | ||
[Symbol.species]: infer V; | ||
} ? { | ||
[Symbol.species]: V; | ||
} : {}) & (T extends { | ||
[Symbol.split]: infer V; | ||
} ? { | ||
[Symbol.split]: V; | ||
} : {}) & (T extends { | ||
[Symbol.toPrimitive]: infer V; | ||
} ? { | ||
[Symbol.toPrimitive]: V; | ||
} : {}) & (T extends { | ||
[Symbol.toStringTag]: infer V; | ||
} ? { | ||
[Symbol.toStringTag]: V; | ||
} : {}) & (T extends { | ||
[Symbol.unscopables]: infer V; | ||
} ? { | ||
[Symbol.unscopables]: V; | ||
} : {}); | ||
declare type UnwrappedObject<T> = { | ||
[P in keyof T]: UnwrapRef<T[P]>; | ||
} & SymbolExtract<T>; | ||
interface RefOption<T> { | ||
@@ -41,2 +74,3 @@ get(): T; | ||
declare class RefImpl<T> implements Ref<T> { | ||
readonly [_refBrand]: true; | ||
value: T; | ||
@@ -46,11 +80,12 @@ constructor({ get, set }: RefOption<T>); | ||
export declare function createRef<T>(options: RefOption<T>): RefImpl<T>; | ||
declare type RefValue<T> = T extends Ref<infer V> ? V : UnwrapRef<T>; | ||
export declare function ref<T = undefined>(): Ref<T | undefined>; | ||
export declare function ref<T = null>(raw: null): Ref<T | null>; | ||
export declare function ref<S, T = unknown, R = HasDefined<S> extends true ? S : RefValue<T>>(raw: T): Ref<R>; | ||
export declare function ref<T extends object>(raw: T): T extends Ref ? T : Ref<UnwrapRef<T>>; | ||
export declare function ref<T>(raw: T): Ref<UnwrapRef<T>>; | ||
export declare function ref<T = any>(): Ref<T | undefined>; | ||
export declare function isRef<T>(value: any): value is Ref<T>; | ||
declare type Refs<Data> = { | ||
[K in keyof Data]: Data[K] extends Ref<infer V> ? Ref<V> : Ref<Data[K]>; | ||
}; | ||
export declare function toRefs<T extends Data = Data>(obj: T): Refs<T>; | ||
export declare function unref<T>(ref: T): T extends Ref<infer V> ? V : T; | ||
export declare function toRefs<T extends Data = Data>(obj: T): ToRefs<T>; | ||
export declare function toRef<T extends object, K extends keyof T>(object: T, key: K): Ref<T[K]>; | ||
export declare function shallowRef<T>(value: T): T extends Ref ? T : Ref<T>; | ||
export declare function shallowRef<T = any>(): Ref<T | undefined>; | ||
export declare function triggerRef(value: any): void; | ||
export {}; |
@@ -5,3 +5,3 @@ export declare const WatcherPreFlushQueueKey: string; | ||
export declare const ReactiveIdentifierKey: string; | ||
export declare const NonReactiveIdentifierKey: string; | ||
export declare const RawIdentifierKey: string; | ||
export declare const RefKey = "vfa.key.refKey"; |
@@ -13,4 +13,6 @@ 'use strict'; | ||
} | ||
var hasSymbol = typeof Symbol !== 'undefined' && isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); | ||
var hasSymbol = typeof Symbol !== 'undefined' && | ||
isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && | ||
isNative(Reflect.ownKeys); | ||
var noopFn = function (_) { return _; }; | ||
@@ -87,6 +89,69 @@ var sharedPropertyDefinition = { | ||
function ensureCurrentVMInFn(hook) { | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __values(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function currentVMInFn(hook) { | ||
var vm = getCurrentVM(); | ||
{ | ||
assert(vm, "\"" + hook + "\" get called outside of \"setup()\""); | ||
if ( !vm) { | ||
warn(hook + " is called when there is no active component instance to be " + | ||
"associated with. " + | ||
"Lifecycle injection APIs can only be used during execution of setup()."); | ||
} | ||
@@ -151,3 +216,3 @@ return vm; | ||
var ReactiveIdentifierKey = createSymbol('vfa.key.reactiveIdentifier'); | ||
var NonReactiveIdentifierKey = createSymbol('vfa.key.nonReactiveIdentifier'); | ||
var RawIdentifierKey = createSymbol('vfa.key.rawIdentifierKey'); | ||
// must be a string, symbol key is ignored in reactive | ||
@@ -168,12 +233,11 @@ var RefKey = 'vfa.key.refKey'; | ||
// seal the ref, this could prevent ref from being observed | ||
// It's safe to seal the ref, since we really shoulnd't extend it. | ||
// It's safe to seal the ref, since we really shouldn't extend it. | ||
// related issues: #79 | ||
return Object.seal(new RefImpl(options)); | ||
} | ||
// implementation | ||
function ref(raw) { | ||
// if (isRef(raw)) { | ||
// return {} as any; | ||
// } | ||
var _a; | ||
if (isRef(raw)) { | ||
return raw; | ||
} | ||
var value = reactive((_a = {}, _a[RefKey] = raw, _a)); | ||
@@ -188,29 +252,53 @@ return createRef({ | ||
} | ||
function unref(ref) { | ||
return isRef(ref) ? ref.value : ref; | ||
} | ||
function toRefs(obj) { | ||
if (!isPlainObject(obj)) | ||
return obj; | ||
var res = {}; | ||
Object.keys(obj).forEach(function (key) { | ||
var val = obj[key]; | ||
// use ref to proxy the property | ||
if (!isRef(val)) { | ||
val = createRef({ | ||
get: function () { return obj[key]; }, | ||
set: function (v) { return (obj[key] = v); }, | ||
}); | ||
} | ||
// todo | ||
res[key] = val; | ||
if ( !isReactive(obj)) { | ||
warn("toRefs() expects a reactive object but received a plain one."); | ||
} | ||
var ret = {}; | ||
for (var key in obj) { | ||
ret[key] = toRef(obj, key); | ||
} | ||
return ret; | ||
} | ||
function toRef(object, key) { | ||
var v = object[key]; | ||
if (isRef(v)) | ||
return v; | ||
return createRef({ | ||
get: function () { return object[key]; }, | ||
set: function (v) { return (object[key] = v); }, | ||
}); | ||
return res; | ||
} | ||
function shallowRef(raw) { | ||
var _a; | ||
if (isRef(raw)) { | ||
return raw; | ||
} | ||
var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); | ||
return createRef({ | ||
get: function () { return value[RefKey]; }, | ||
set: function (v) { return (value[RefKey] = v); }, | ||
}); | ||
} | ||
function triggerRef(value) { | ||
if (!isRef(value)) | ||
return; | ||
value.value = value.value; | ||
} | ||
var AccessControlIdentifier = {}; | ||
var ReactiveIdentifier = {}; | ||
var NonReactiveIdentifier = {}; | ||
function isNonReactive(obj) { | ||
return (hasOwn(obj, NonReactiveIdentifierKey) && obj[NonReactiveIdentifierKey] === NonReactiveIdentifier); | ||
var RawIdentifier = {}; | ||
function isRaw(obj) { | ||
return hasOwn(obj, RawIdentifierKey) && obj[RawIdentifierKey] === RawIdentifier; | ||
} | ||
function isReactive(obj) { | ||
return hasOwn(obj, ReactiveIdentifierKey) && obj[ReactiveIdentifierKey] === ReactiveIdentifier; | ||
return (Object.isExtensible(obj) && | ||
hasOwn(obj, ReactiveIdentifierKey) && | ||
obj[ReactiveIdentifierKey] === ReactiveIdentifier); | ||
} | ||
@@ -223,3 +311,3 @@ /** | ||
if (!isPlainObject(target) || | ||
isNonReactive(target) || | ||
isRaw(target) || | ||
Array.isArray(target) || | ||
@@ -311,2 +399,93 @@ isRef(target) || | ||
} | ||
function shallowReactive(obj) { | ||
var e_1, _a; | ||
if ( !obj) { | ||
warn('"shallowReactive()" is called without provide an "object".'); | ||
// @ts-ignore | ||
return; | ||
} | ||
if (!isPlainObject(obj) || isReactive(obj) || isRaw(obj) || !Object.isExtensible(obj)) { | ||
return obj; | ||
} | ||
var observed = observe({}); | ||
markReactive(observed, true); | ||
setupAccessControl(observed); | ||
var ob = observed.__ob__; | ||
var _loop_1 = function (key) { | ||
var val = obj[key]; | ||
var getter; | ||
var setter; | ||
var property = Object.getOwnPropertyDescriptor(obj, key); | ||
if (property) { | ||
if (property.configurable === false) { | ||
return "continue"; | ||
} | ||
getter = property.get; | ||
setter = property.set; | ||
if ((!getter || setter) /* not only have getter */ && arguments_1.length === 2) { | ||
val = obj[key]; | ||
} | ||
} | ||
// setupAccessControl(val); | ||
Object.defineProperty(observed, key, { | ||
enumerable: true, | ||
configurable: true, | ||
get: function getterHandler() { | ||
var value = getter ? getter.call(obj) : val; | ||
ob.dep.depend(); | ||
return value; | ||
}, | ||
set: function setterHandler(newVal) { | ||
if (getter && !setter) | ||
return; | ||
if (setter) { | ||
setter.call(obj, newVal); | ||
} | ||
else { | ||
val = newVal; | ||
} | ||
ob.dep.notify(); | ||
}, | ||
}); | ||
}; | ||
var arguments_1 = arguments; | ||
try { | ||
for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var key = _c.value; | ||
_loop_1(key); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return observed; | ||
} | ||
function markReactive(target, shallow) { | ||
if (shallow === void 0) { shallow = false; } | ||
if (!isPlainObject(target) || | ||
isRaw(target) || | ||
Array.isArray(target) || | ||
isRef(target) || | ||
isComponentInstance(target)) { | ||
return; | ||
} | ||
if (hasOwn(target, ReactiveIdentifierKey) && | ||
target[ReactiveIdentifierKey] === ReactiveIdentifier) { | ||
return; | ||
} | ||
if (Object.isExtensible(target)) { | ||
def(target, ReactiveIdentifierKey, ReactiveIdentifier); | ||
} | ||
if (shallow) { | ||
return; | ||
} | ||
var keys = Object.keys(target); | ||
for (var i = 0; i < keys.length; i++) { | ||
markReactive(target[keys[i]]); | ||
} | ||
} | ||
/** | ||
@@ -316,3 +495,3 @@ * Make obj reactivity | ||
function reactive(obj) { | ||
if (!obj) { | ||
if ( !obj) { | ||
warn('"reactive()" is called without provide an "object".'); | ||
@@ -322,7 +501,8 @@ // @ts-ignore | ||
} | ||
if (!isPlainObject(obj) || isReactive(obj) || isNonReactive(obj) || !Object.isExtensible(obj)) { | ||
if (!isPlainObject(obj) || isReactive(obj) || isRaw(obj) || !Object.isExtensible(obj)) { | ||
return obj; | ||
} | ||
var observed = observe(obj); | ||
def(observed, ReactiveIdentifierKey, ReactiveIdentifier); | ||
// def(obj, ReactiveIdentifierKey, ReactiveIdentifier); | ||
markReactive(obj); | ||
setupAccessControl(observed); | ||
@@ -334,3 +514,3 @@ return observed; | ||
*/ | ||
function nonReactive(obj) { | ||
function markRaw(obj) { | ||
if (!isPlainObject(obj)) { | ||
@@ -341,6 +521,12 @@ return obj; | ||
def(obj, '__ob__', observe({}).__ob__); | ||
// mark as nonReactive | ||
def(obj, NonReactiveIdentifierKey, NonReactiveIdentifier); | ||
// mark as Raw | ||
def(obj, RawIdentifierKey, RawIdentifier); | ||
return obj; | ||
} | ||
function toRaw(observed) { | ||
if (isRaw(observe) || !Object.isExtensible(observed)) { | ||
return observed; | ||
} | ||
return observed.__ob__.value || observed; | ||
} | ||
@@ -369,3 +555,3 @@ function isUndef(v) { | ||
var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; | ||
if (isUndef(target) || isPrimitive(target)) { | ||
if ( (isUndef(target) || isPrimitive(target))) { | ||
warn("Cannot set reactive property on undefined, null, or primitive value: " + target); | ||
@@ -384,3 +570,4 @@ } | ||
if (target._isVue || (ob && ob.vmCount)) { | ||
warn('Avoid adding reactive properties to a Vue instance or its root $data ' + | ||
warn('Avoid adding reactive properties to a Vue instance or its root $data ' + | ||
'at runtime - declare it upfront in the data option.'); | ||
@@ -396,2 +583,3 @@ return val; | ||
defineAccessControl(target, key, val); | ||
markReactive(ob.value[key]); | ||
ob.dep.notify(); | ||
@@ -422,4 +610,6 @@ return val; | ||
else if (toVal !== fromVal && | ||
(isPlainObject(toVal) && !isRef(toVal)) && | ||
(isPlainObject(fromVal) && !isRef(fromVal))) { | ||
isPlainObject(toVal) && | ||
!isRef(toVal) && | ||
isPlainObject(fromVal) && | ||
!isRef(fromVal)) { | ||
mergeData(fromVal, toVal); | ||
@@ -446,51 +636,2 @@ } | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function set$1(vm, key, value) { | ||
@@ -684,4 +825,8 @@ var state = (vm.__secret_vfa_state__ = vm.__secret_vfa_state__ || {}); | ||
else { | ||
// bind function to the vm, this will make `this` = vm | ||
if (isFunction(bindingValue)) { | ||
bindingValue = bindingValue.bind(vm); | ||
} | ||
// a non-reactive should not don't get reactivity | ||
bindingValue = ref(nonReactive(bindingValue)); | ||
bindingValue = ref(markRaw(bindingValue)); | ||
} | ||
@@ -781,4 +926,6 @@ } | ||
return function (callback) { | ||
var vm = ensureCurrentVMInFn(genName(lifeCyclehook)); | ||
injectHookOption(getCurrentVue(), vm, lifeCyclehook, callback); | ||
var vm = currentVMInFn(genName(lifeCyclehook)); | ||
if (vm) { | ||
injectHookOption(getCurrentVue(), vm, lifeCyclehook, callback); | ||
} | ||
}; | ||
@@ -789,4 +936,20 @@ } | ||
var mergeFn = Vue.config.optionMergeStrategies[hook]; | ||
options[hook] = mergeFn(options[hook], val); | ||
options[hook] = mergeFn(options[hook], wrapHookCall(vm, val)); | ||
} | ||
function wrapHookCall(vm, fn) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var preVm = getCurrentVM(); | ||
setCurrentVM(vm); | ||
try { | ||
return fn.apply(void 0, __spread(args)); | ||
} | ||
finally { | ||
setCurrentVM(preVm); | ||
} | ||
}; | ||
} | ||
// export const onCreated = createLifeCycle('created'); | ||
@@ -822,3 +985,3 @@ var onBeforeMount = createLifeCycle('beforeMount'); | ||
return __assign({ | ||
lazy: false, | ||
immediate: false, | ||
deep: false, | ||
@@ -828,2 +991,9 @@ flush: 'post', | ||
} | ||
function getWatchEffectOption(options) { | ||
return __assign({ | ||
immediate: true, | ||
deep: false, | ||
flush: 'post', | ||
}, options); | ||
} | ||
function getWatcherVM() { | ||
@@ -887,2 +1057,15 @@ var vm = getCurrentVM(); | ||
} | ||
// We have to monkeypatch the teardown function so Vue will run | ||
// runCleanup() when it tears down the watcher on unmmount. | ||
function patchWatcherTeardown(watcher, runCleanup) { | ||
var _teardown = watcher.teardown; | ||
watcher.teardown = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_teardown.apply(watcher, args); | ||
runCleanup(); | ||
}; | ||
} | ||
function createWatcher(vm, source, cb, options) { | ||
@@ -927,22 +1110,17 @@ var flushMode = options.flush; | ||
var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { | ||
noRun: true, | ||
deep: options.deep, | ||
deep: options.deep || false, | ||
sync: isSync, | ||
before: runCleanup, | ||
}); | ||
patchWatcherTeardown(watcher_1, runCleanup); | ||
// enable the watcher update | ||
watcher_1.lazy = false; | ||
var originGet = watcher_1.get.bind(watcher_1); | ||
if (isSync) { | ||
watcher_1.get(); | ||
} | ||
else { | ||
vm.$nextTick(originGet); | ||
} | ||
// always run watchEffect | ||
watcher_1.get = createScheduler(originGet); | ||
return function () { | ||
watcher_1.teardown(); | ||
runCleanup(); | ||
}; | ||
} | ||
var deep = options.deep; | ||
var getter; | ||
@@ -955,5 +1133,13 @@ if (Array.isArray(source)) { | ||
} | ||
else { | ||
else if (isReactive(source)) { | ||
getter = function () { return source; }; | ||
deep = true; | ||
} | ||
else if (isFunction(source)) { | ||
getter = source; | ||
} | ||
else { | ||
getter = noopFn; | ||
warn("Invalid watch source: " + JSON.stringify(source) + ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.", vm); | ||
} | ||
var applyCb = function (n, o) { | ||
@@ -965,3 +1151,3 @@ // cleanup before running cb again | ||
var callback = createScheduler(applyCb); | ||
if (!options.lazy) { | ||
if (options.immediate) { | ||
var originalCallbck_1 = callback; | ||
@@ -980,16 +1166,19 @@ // `shiftCallback` is used to handle the first sync effect run. | ||
var stop = vm.$watch(getter, callback, { | ||
immediate: !options.lazy, | ||
deep: options.deep, | ||
immediate: options.immediate, | ||
deep: deep, | ||
sync: isSync, | ||
}); | ||
// Once again, we have to hack the watcher for proper teardown | ||
var watcher = vm._watchers[vm._watchers.length - 1]; | ||
patchWatcherTeardown(watcher, runCleanup); | ||
return function () { | ||
stop(); | ||
runCleanup(); | ||
}; | ||
} | ||
function watchEffect(effect, options) { | ||
var opts = getWatcherOption(options); | ||
var opts = getWatchEffectOption(options); | ||
var vm = getWatcherVM(); | ||
return createWatcher(vm, effect, null, opts); | ||
} | ||
// implementation | ||
function watch(source, cb, options) { | ||
@@ -1035,6 +1224,7 @@ var callback = null; | ||
}); | ||
vm && vm.$on('hook:destroyed', function () { return computedHost.$destroy(); }); | ||
return createRef({ | ||
get: function () { return computedHost.$$state; }, | ||
set: function (v) { | ||
if (!set) { | ||
if ( !set) { | ||
warn('Computed property was assigned to but it has no setter.', vm); | ||
@@ -1062,3 +1252,5 @@ return; | ||
function provide(key, value) { | ||
var vm = ensureCurrentVMInFn('provide'); | ||
var vm = currentVMInFn('provide'); | ||
if (!vm) | ||
return; | ||
if (!vm._provided) { | ||
@@ -1077,12 +1269,17 @@ var provideCache_1 = {}; | ||
} | ||
var vm = ensureCurrentVMInFn('inject'); | ||
var val = resolveInject(key, vm); | ||
if (val !== NOT_FOUND) { | ||
return val; | ||
var vm = getCurrentVM(); | ||
if (vm) { | ||
var val = resolveInject(key, vm); | ||
if (val !== NOT_FOUND) { | ||
return val; | ||
} | ||
else { | ||
if (defaultValue === undefined && "development" !== 'production') { | ||
warn("Injection \"" + String(key) + "\" not found", vm); | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
else if (defaultValue !== undefined) { | ||
return defaultValue; | ||
} | ||
else { | ||
warn("Injection \"" + String(key) + "\" not found", vm); | ||
warn("inject() can only be used inside setup() or functional components."); | ||
} | ||
@@ -1108,3 +1305,5 @@ } | ||
exports.inject = inject; | ||
exports.isReactive = isReactive; | ||
exports.isRef = isRef; | ||
exports.markRaw = markRaw; | ||
exports.onActivated = onActivated; | ||
@@ -1124,4 +1323,10 @@ exports.onBeforeMount = onBeforeMount; | ||
exports.set = set; | ||
exports.shallowReactive = shallowReactive; | ||
exports.shallowRef = shallowRef; | ||
exports.toRaw = toRaw; | ||
exports.toRef = toRef; | ||
exports.toRefs = toRefs; | ||
exports.triggerRef = triggerRef; | ||
exports.unref = unref; | ||
exports.watch = watch; | ||
exports.watchEffect = watchEffect; |
@@ -1,1 +0,15 @@ | ||
"use strict";function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var Vue=_interopDefault(require("vue")),toString=function(e){return Object.prototype.toString.call(e)};function isNative(e){return"function"==typeof e&&/native code/.test(e.toString())}var hasSymbol="undefined"!=typeof Symbol&&isNative(Symbol)&&"undefined"!=typeof Reflect&&isNative(Reflect.ownKeys),noopFn=function(e){return e},sharedPropertyDefinition={enumerable:!0,configurable:!0,get:noopFn,set:noopFn};function proxy(e,t,n){var r=n.get,o=n.set;sharedPropertyDefinition.get=r||noopFn,sharedPropertyDefinition.set=o||noopFn,Object.defineProperty(e,t,sharedPropertyDefinition)}function def(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}var hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(e,t){return hasOwnProperty.call(e,t)}function assert(e,t){if(!e)throw new Error("[vue-composition-api] "+t)}function isArray(e){return Array.isArray(e)}function isPlainObject(e){return"[object Object]"===toString(e)}function isFunction(e){return"function"==typeof e}function warn(e,t){Vue.util.warn(e,t)}function logError(e,t,n){if("undefined"==typeof window||"undefined"==typeof console)throw e;console.error(e)}var currentVue=null,currentVM=null;function getCurrentVue(){return currentVue}function setCurrentVue(e){currentVue=e}function getCurrentVM(){return currentVM}function setCurrentVM(e){currentVM=e}function ensureCurrentVMInFn(e){return getCurrentVM()}function defineComponentInstance(e,t){void 0===t&&(t={});var n=e.config.silent;e.config.silent=!0;var r=new e(t);return e.config.silent=n,r}function isComponentInstance(e){return currentVue&&e instanceof currentVue}function createSlotProxy(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.$scopedSlots[t]?e.$scopedSlots[t].apply(e,n):warn("slots."+t+'() got called outside of the "render()" scope',e)}}function resolveSlots(e,t){var n;if(e){if(e._normalized)return e._normalized;for(var r in n={},e)e[r]&&"$"!==r[0]&&(n[r]=!0)}else n={};for(var r in t)r in n||(n[r]=!0);return n}function createSymbol(e){return hasSymbol?Symbol.for(e):e}var WatcherPreFlushQueueKey=createSymbol("vfa.key.preFlushQueue"),WatcherPostFlushQueueKey=createSymbol("vfa.key.postFlushQueue"),AccessControlIdentifierKey=createSymbol("vfa.key.accessControlIdentifier"),ReactiveIdentifierKey=createSymbol("vfa.key.reactiveIdentifier"),NonReactiveIdentifierKey=createSymbol("vfa.key.nonReactiveIdentifier"),RefKey="vfa.key.refKey",RefImpl=function(){return function(e){proxy(this,"value",{get:e.get,set:e.set})}}();function createRef(e){return Object.seal(new RefImpl(e))}function ref(e){var t,n=reactive(((t={})[RefKey]=e,t));return createRef({get:function(){return n[RefKey]},set:function(e){return n[RefKey]=e}})}function isRef(e){return e instanceof RefImpl}function toRefs(e){if(!isPlainObject(e))return e;var t={};return Object.keys(e).forEach(function(n){var r=e[n];isRef(r)||(r=createRef({get:function(){return e[n]},set:function(t){return e[n]=t}})),t[n]=r}),t}var AccessControlIdentifier={},ReactiveIdentifier={},NonReactiveIdentifier={};function isNonReactive(e){return hasOwn(e,NonReactiveIdentifierKey)&&e[NonReactiveIdentifierKey]===NonReactiveIdentifier}function isReactive(e){return hasOwn(e,ReactiveIdentifierKey)&&e[ReactiveIdentifierKey]===ReactiveIdentifier}function setupAccessControl(e){if(!(!isPlainObject(e)||isNonReactive(e)||Array.isArray(e)||isRef(e)||isComponentInstance(e)||hasOwn(e,AccessControlIdentifierKey)&&e[AccessControlIdentifierKey]===AccessControlIdentifier)){Object.isExtensible(e)&&def(e,AccessControlIdentifierKey,AccessControlIdentifier);for(var t=Object.keys(e),n=0;n<t.length;n++)defineAccessControl(e,t[n])}}function defineAccessControl(e,t,n){if("__ob__"!==t){var r,o,i=Object.getOwnPropertyDescriptor(e,t);if(i){if(!1===i.configurable)return;r=i.get,o=i.set,r&&!o||2!==arguments.length||(n=e[t])}setupAccessControl(n),Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){var o=r?r.call(e):n;return t!==RefKey&&isRef(o)?o.value:o},set:function(i){if(!r||o){var a=r?r.call(e):n;t!==RefKey&&isRef(a)&&!isRef(i)?a.value=i:o?o.call(e,i):n=i,setupAccessControl(i)}}})}}function observe(e){var t,n=getCurrentVue();n.observable?t=n.observable(e):t=defineComponentInstance(n,{data:{$$state:e}})._data.$$state;return t}function reactive(e){if(!isPlainObject(e)||isReactive(e)||isNonReactive(e)||!Object.isExtensible(e))return e;var t=observe(e);return def(t,ReactiveIdentifierKey,ReactiveIdentifier),setupAccessControl(t),t}function nonReactive(e){return isPlainObject(e)?(def(e,"__ob__",observe({}).__ob__),def(e,NonReactiveIdentifierKey,NonReactiveIdentifier),e):e}function isValidArrayIndex(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function set(e,t,n){var r=getCurrentVue().util,o=(r.warn,r.defineReactive);if(isArray(e)&&isValidArrayIndex(t))return e.length=Math.max(e.length,t),e.splice(t,1,n),n;if(t in e&&!(t in Object.prototype))return e[t]=n,n;var i=e.__ob__;return e._isVue||i&&i.vmCount?n:i?(o(i.value,t,n),defineAccessControl(e,t,n),i.dep.notify(),n):(e[t]=n,n)}function mergeData(e,t){if(!e)return t;for(var n,r,o,i=hasSymbol?Reflect.ownKeys(e):Object.keys(e),a=0;a<i.length;a++)"__ob__"!==(n=i[a])&&(r=t[n],o=e[n],hasOwn(t,n)?r!==o&&isPlainObject(r)&&!isRef(r)&&isPlainObject(o)&&!isRef(o)&&mergeData(o,r):t[n]=o);return t}function install(e,t){currentVue&¤tVue===e||(e.config.optionMergeStrategies.setup=function(e,t){return function(n,r){return mergeData("function"==typeof e&&e(n,r)||{},"function"==typeof t&&t(n,r)||{})}},setCurrentVue(e),t(e))}var __assign=function(){return(__assign=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function __spread(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(__read(arguments[t]));return e}function set$1(e,t,n){(e.__secret_vfa_state__=e.__secret_vfa_state__||{})[t]=n}function get(e,t){return(e.__secret_vfa_state__||{})[t]}var fallbackCreateElement,vmStateManager={set:set$1,get:get};function asVmProperty(e,t,n){var r=e.$options.props;t in e||r&&hasOwn(r,t)||proxy(e,t,{get:function(){return n.value},set:function(e){n.value=e}})}function updateTemplateRef(e){var t=vmStateManager.get(e,"rawBindings")||{};if(t&&Object.keys(t).length){for(var n=e.$refs,r=vmStateManager.get(e,"refs")||[],o=0;o<r.length;o++){var i=t[c=r[o]];!n[c]&&i&&isRef(i)&&(i.value=null)}var a=Object.keys(n),u=[];for(o=0;o<a.length;o++){var c;i=t[c=a[o]];n[c]&&i&&isRef(i)&&(i.value=n[c],u.push(c))}vmStateManager.set(e,"refs",u)}}function resolveScopedSlots(e,t){var n=e.$options._parentVnode;if(n){for(var r=vmStateManager.get(e,"slots")||[],o=resolveSlots(n.data.scopedSlots,e.$slots),i=0;i<r.length;i++){o[u=r[i]]||delete t[u]}var a=Object.keys(o);for(i=0;i<a.length;i++){var u;t[u=a[i]]||(t[u]=createSlotProxy(e,u))}vmStateManager.set(e,"slots",a)}}function activateCurrentInstance(e,t,n){var r=getCurrentVM();setCurrentVM(e);try{return t(e)}catch(e){if(!n)throw e;n(e)}finally{setCurrentVM(r)}}function mixin(e){e.mixin({beforeCreate:function(){var e=this,t=e.$options,n=t.setup,r=t.render;r&&(t.render=function(){for(var t=this,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return activateCurrentInstance(e,function(){return r.apply(t,n)})});if(!n)return;if("function"!=typeof n)return;var o=t.data;t.data=function(){return function(e,t){void 0===t&&(t={});var n,r=e.$options.setup,o=function(e){var t={slots:{}};return["root","parent","refs","attrs","listeners","isServer","ssrContext"].forEach(function(n){var r,o,i;Array.isArray(n)?(r=__read(n,2),o=r[0],i=r[1]):o=i=n,i="$"+i,proxy(t,o,{get:function(){return e[i]},set:function(){warn("Cannot assign to '"+o+"' because it is a read-only property",e)}})}),["emit"].forEach(function(n){var r="$"+n;proxy(t,n,{get:function(){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];e[r].apply(e,t)}}})}),t}(e);if(resolveScopedSlots(e,o.slots),activateCurrentInstance(e,function(){n=r(t,o)}),!n)return;if(isFunction(n)){var i=n;return void(e.$options.render=function(){return resolveScopedSlots(e,o.slots),activateCurrentInstance(e,function(){return i()})})}if(isPlainObject(n)){var a=n;vmStateManager.set(e,"rawBindings",n),Object.keys(n).forEach(function(t){var n=a[t];isRef(n)||(n=isReactive(n)?ref(n):ref(nonReactive(n))),asVmProperty(e,t,n)})}}(e,e.$props),"function"==typeof o?o.call(e,e):o||{}}},mounted:function(){updateTemplateRef(this)},updated:function(){updateTemplateRef(this)}})}var createElement=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return currentVM?currentVM.$createElement.apply(currentVM,e):(warn("`createElement()` has been called outside of render function."),fallbackCreateElement||(fallbackCreateElement=defineComponentInstance(getCurrentVue()).$createElement),fallbackCreateElement.apply(fallbackCreateElement,e))};function defineComponent(e){return e}function createComponent(e){return defineComponent(e)}var genName=function(e){return"on"+(e[0].toUpperCase()+e.slice(1))};function createLifeCycle(e){return function(t){var n=ensureCurrentVMInFn(genName(e));injectHookOption(getCurrentVue(),n,e,t)}}function injectHookOption(e,t,n,r){var o=t.$options,i=e.config.optionMergeStrategies[n];o[n]=i(o[n],r)}var fallbackVM,onBeforeMount=createLifeCycle("beforeMount"),onMounted=createLifeCycle("mounted"),onBeforeUpdate=createLifeCycle("beforeUpdate"),onUpdated=createLifeCycle("updated"),onBeforeUnmount=createLifeCycle("beforeDestroy"),onUnmounted=createLifeCycle("destroyed"),onErrorCaptured=createLifeCycle("errorCaptured"),onActivated=createLifeCycle("activated"),onDeactivated=createLifeCycle("deactivated"),onServerPrefetch=createLifeCycle("serverPrefetch");function flushPreQueue(){flushQueue(this,WatcherPreFlushQueueKey)}function flushPostQueue(){flushQueue(this,WatcherPostFlushQueueKey)}function hasWatchEnv(e){return void 0!==e[WatcherPreFlushQueueKey]}function installWatchEnv(e){e[WatcherPreFlushQueueKey]=[],e[WatcherPostFlushQueueKey]=[],e.$on("hook:beforeUpdate",flushPreQueue),e.$on("hook:updated",flushPostQueue)}function getWatcherOption(e){return __assign({lazy:!1,deep:!1,flush:"post"},e)}function getWatcherVM(){var e=getCurrentVM();return e?hasWatchEnv(e)||installWatchEnv(e):(fallbackVM||(fallbackVM=defineComponentInstance(getCurrentVue())),e=fallbackVM),e}function flushQueue(e,t){for(var n=e[t],r=0;r<n.length;r++)n[r]();n.length=0}function queueFlushJob(e,t,n){var r=function(){e.$nextTick(function(){e[WatcherPreFlushQueueKey].length&&flushQueue(e,WatcherPreFlushQueueKey),e[WatcherPostFlushQueueKey].length&&flushQueue(e,WatcherPostFlushQueueKey)})};switch(n){case"pre":r(),e[WatcherPreFlushQueueKey].push(t);break;case"post":r(),e[WatcherPostFlushQueueKey].push(t);break;default:assert(!1,'flush must be one of ["post", "pre", "sync"], but got '+n)}}function createVueWatcher(e,t,n,r){var o=e._watchers.length;return e.$watch(t,n,{immediate:r.immediateInvokeCallback,deep:r.deep,lazy:r.noRun,sync:r.sync,before:r.before}),e._watchers[o]}function createWatcher(e,t,n,r){var o,i,a=r.flush,u="sync"===a,c=function(t){o=function(){try{t()}catch(t){logError(t,e,"onCleanup()")}}},f=function(){o&&(o(),o=null)},s=function(t){return u||e===fallbackVM?t:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return queueFlushJob(e,function(){t.apply(void 0,__spread(n))},a)}};if(null===n){var l=createVueWatcher(e,function(){return t(c)},noopFn,{noRun:!0,deep:r.deep,sync:u,before:f});l.lazy=!1;var p=l.get.bind(l);return u?l.get():e.$nextTick(p),l.get=s(p),function(){l.teardown(),f()}}i=Array.isArray(t)?function(){return t.map(function(e){return isRef(e)?e.value:e()})}:isRef(t)?function(){return t.value}:t;var v=function(e,t){f(),n(e,t,c)},d=s(v);if(!r.lazy){var y=d,h=function(e,t){h=y,v(e,t)};d=function(e,t){h(e,t)}}var g=e.$watch(i,d,{immediate:!r.lazy,deep:r.deep,sync:u});return function(){g(),f()}}function watchEffect(e,t){var n=getWatcherOption(t);return createWatcher(getWatcherVM(),e,null,n)}function watch(e,t,n){var r=null;"function"==typeof t?r=t:(n=t,r=null);var o=getWatcherOption(n);return createWatcher(getWatcherVM(),e,r,o)}function computed(e){var t,n;"function"==typeof e?t=e:(t=e.get,n=e.set);var r=defineComponentInstance(getCurrentVue(),{computed:{$$state:{get:t,set:n}}});return createRef({get:function(){return r.$$state},set:function(e){r.$$state=e}})}var NOT_FOUND={};function resolveInject(e,t){for(var n=t;n;){if(n._provided&&hasOwn(n._provided,e))return n._provided[e];n=n.$parent}return NOT_FOUND}function provide(e,t){var n=ensureCurrentVMInFn("provide");if(!n._provided){var r={};Object.defineProperty(n,"_provided",{get:function(){return r},set:function(e){return Object.assign(r,e)}})}n._provided[e]=t}function inject(e,t){if(!e)return t;var n=resolveInject(e,ensureCurrentVMInFn("inject"));return n!==NOT_FOUND?n:void 0!==t?t:void 0}var _install=function(e){return install(e,mixin)},plugin={install:_install};currentVue&&"undefined"!=typeof window&&window.Vue&&_install(window.Vue),exports.computed=computed,exports.createComponent=createComponent,exports.createElement=createElement,exports.default=plugin,exports.defineComponent=defineComponent,exports.getCurrentInstance=getCurrentVM,exports.inject=inject,exports.isRef=isRef,exports.onActivated=onActivated,exports.onBeforeMount=onBeforeMount,exports.onBeforeUnmount=onBeforeUnmount,exports.onBeforeUpdate=onBeforeUpdate,exports.onDeactivated=onDeactivated,exports.onErrorCaptured=onErrorCaptured,exports.onMounted=onMounted,exports.onServerPrefetch=onServerPrefetch,exports.onUnmounted=onUnmounted,exports.onUpdated=onUpdated,exports.provide=provide,exports.reactive=reactive,exports.ref=ref,exports.set=set,exports.toRefs=toRefs,exports.watch=watch,exports.watchEffect=watchEffect; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("vue"))&&"object"==typeof e&&"default"in e?e.default:e;function n(e){return"function"==typeof e&&/native code/.test(e.toString())}var r="undefined"!=typeof Symbol&&n(Symbol)&&"undefined"!=typeof Reflect&&n(Reflect.ownKeys),o=function(e){return e},i={enumerable:!0,configurable:!0,get:o,set:o};function u(e,t,n){var r=n.get,u=n.set;i.get=r||o,i.set=u||o,Object.defineProperty(e,t,i)}function f(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}var a=Object.prototype.hasOwnProperty;function c(e,t){return a.call(e,t)}function s(e){return"[object Object]"===function(e){return Object.prototype.toString.call(e)}(e)}function l(e){return"function"==typeof e}function p(e,n){t.util.warn(e,n)}var v=null,d=null;function y(){return v}function b(){return d}function g(e){d=e} | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var h=function(){return(h=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function _(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function w(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}function x(e){return b()}function j(e,t){void 0===t&&(t={});var n=e.config.silent;e.config.silent=!0;var r=new e(t);return e.config.silent=n,r}function O(e){return v&&e instanceof v}function $(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.$scopedSlots[t]?e.$scopedSlots[t].apply(e,n):p("slots."+t+'() got called outside of the "render()" scope',e)}}function k(e){return r?Symbol.for(e):e}var S=k("vfa.key.preFlushQueue"),E=k("vfa.key.postFlushQueue"),R=k("vfa.key.accessControlIdentifier"),A=k("vfa.key.reactiveIdentifier"),C=k("vfa.key.rawIdentifierKey"),P="vfa.key.refKey",M=function(e){u(this,"value",{get:e.get,set:e.set})};function U(e){return Object.seal(new M(e))}function I(e){var t;if(B(e))return e;var n=H(((t={})[P]=e,t));return U({get:function(){return n[P]},set:function(e){return n[P]=e}})}function B(e){return e instanceof M}function z(e,t){var n=e[t];return B(n)?n:U({get:function(){return e[t]},set:function(n){return e[t]=n}})}var D={},F={},K={};function V(e){return c(e,C)&&e[C]===K}function Q(e){return Object.isExtensible(e)&&c(e,A)&&e[A]===F}function T(e){if(!(!s(e)||V(e)||Array.isArray(e)||B(e)||O(e)||c(e,R)&&e[R]===D)){Object.isExtensible(e)&&f(e,R,D);for(var t=Object.keys(e),n=0;n<t.length;n++)q(e,t[n])}}function q(e,t,n){if("__ob__"!==t){var r,o,i=Object.getOwnPropertyDescriptor(e,t);if(i){if(!1===i.configurable)return;r=i.get,o=i.set,r&&!o||2!==arguments.length||(n=e[t])}T(n),Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){var o=r?r.call(e):n;return t!==P&&B(o)?o.value:o},set:function(i){if(!r||o){var u=r?r.call(e):n;t!==P&&B(u)&&!B(i)?u.value=i:o?o.call(e,i):n=i,T(i)}}})}}function J(e){var t,n=y();n.observable?t=n.observable(e):t=j(n,{data:{$$state:e}})._data.$$state;return t}function N(e){var t,n;if(!s(e)||Q(e)||V(e)||!Object.isExtensible(e))return e;var r=J({});G(r,!0),T(r);var o=r.__ob__,i=function(t){var n,i,f=e[t],a=Object.getOwnPropertyDescriptor(e,t);if(a){if(!1===a.configurable)return"continue";n=a.get,i=a.set,n&&!i||2!==u.length||(f=e[t])}Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){var t=n?n.call(e):f;return o.dep.depend(),t},set:function(t){n&&!i||(i?i.call(e,t):f=t,o.dep.notify())}})},u=arguments;try{for(var f=_(Object.keys(e)),a=f.next();!a.done;a=f.next()){var c=a.value;i(c)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}return r}function G(e,t){if(void 0===t&&(t=!1),!(!s(e)||V(e)||Array.isArray(e)||B(e)||O(e)||c(e,A)&&e[A]===F||(Object.isExtensible(e)&&f(e,A,F),t)))for(var n=Object.keys(e),r=0;r<n.length;r++)G(e[n[r]])}function H(e){if(!s(e)||Q(e)||V(e)||!Object.isExtensible(e))return e;var t=J(e);return G(e),T(t),t}function L(e){return s(e)?(f(e,"__ob__",J({}).__ob__),f(e,C,K),e):e}function W(e,t){v&&v===e||(e.config.optionMergeStrategies.setup=function(e,t){return function(n,o){return function e(t,n){if(!t)return n;for(var o,i,u,f=r?Reflect.ownKeys(t):Object.keys(t),a=0;a<f.length;a++)"__ob__"!==(o=f[a])&&(i=n[o],u=t[o],c(n,o)?i!==u&&s(i)&&!B(i)&&s(u)&&!B(u)&&e(u,i):n[o]=u);return n}("function"==typeof e&&e(n,o)||{},"function"==typeof t&&t(n,o)||{})}},v=e,t(e))}var X,Y={set:function(e,t,n){(e.__secret_vfa_state__=e.__secret_vfa_state__||{})[t]=n},get:function(e,t){return(e.__secret_vfa_state__||{})[t]}};function Z(e){var t=Y.get(e,"rawBindings")||{};if(t&&Object.keys(t).length){for(var n=e.$refs,r=Y.get(e,"refs")||[],o=0;o<r.length;o++){var i=t[a=r[o]];!n[a]&&i&&B(i)&&(i.value=null)}var u=Object.keys(n),f=[];for(o=0;o<u.length;o++){var a;i=t[a=u[o]];n[a]&&i&&B(i)&&(i.value=n[a],f.push(a))}Y.set(e,"refs",f)}}function ee(e,t){var n=e.$options._parentVnode;if(n){for(var r=Y.get(e,"slots")||[],o=function(e,t){var n;if(e){if(e._normalized)return e._normalized;for(var r in n={},e)e[r]&&"$"!==r[0]&&(n[r]=!0)}else n={};for(var r in t)r in n||(n[r]=!0);return n}(n.data.scopedSlots,e.$slots),i=0;i<r.length;i++){o[f=r[i]]||delete t[f]}var u=Object.keys(o);for(i=0;i<u.length;i++){var f;t[f=u[i]]||(t[f]=$(e,f))}Y.set(e,"slots",u)}}function te(e,t,n){var r=b();g(e);try{return t(e)}catch(e){if(!n)throw e;n(e)}finally{g(r)}}function ne(e){e.mixin({beforeCreate:function(){var e=this,t=e.$options,n=t.setup,r=t.render;r&&(t.render=function(){for(var t=this,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return te(e,(function(){return r.apply(t,n)}))});if(!n)return;if("function"!=typeof n)return;var o=t.data;t.data=function(){return function(e,t){void 0===t&&(t={});var n,r=e.$options.setup,o=function(e){var t={slots:{}};return["root","parent","refs","attrs","listeners","isServer","ssrContext"].forEach((function(n){var r,o,i;Array.isArray(n)?(r=m(n,2),o=r[0],i=r[1]):o=i=n,i="$"+i,u(t,o,{get:function(){return e[i]},set:function(){p("Cannot assign to '"+o+"' because it is a read-only property",e)}})})),["emit"].forEach((function(n){var r="$"+n;u(t,n,{get:function(){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var o=e[r];o.apply(e,t)}}})})),t}(e);if(ee(e,o.slots),te(e,(function(){n=r(t,o)})),!n)return;if(l(n)){var i=n;return void(e.$options.render=function(){return ee(e,o.slots),te(e,(function(){return i()}))})}if(s(n)){var f=n;Y.set(e,"rawBindings",n),Object.keys(n).forEach((function(t){var n=f[t];B(n)||(Q(n)?n=I(n):(l(n)&&(n=n.bind(e)),n=I(L(n)))),function(e,t,n){var r=e.$options.props;t in e||r&&c(r,t)||u(e,t,{get:function(){return n.value},set:function(e){n.value=e}})}(e,t,n)}))}}(e,e.$props),"function"==typeof o?o.call(e,e):o||{}}},mounted:function(){Z(this)},updated:function(){Z(this)}})}function re(e){return e}function oe(e){return function(t){var n,r=x(((n=e)[0].toUpperCase(),n.slice(1)));r&&function(e,t,n,r){var o=t.$options,i=e.config.optionMergeStrategies[n];o[n]=i(o[n],function(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=b();g(e);try{return t.apply(void 0,w(n))}finally{g(o)}}}(t,r))}(y(),r,e,t)}}var ie,ue=oe("beforeMount"),fe=oe("mounted"),ae=oe("beforeUpdate"),ce=oe("updated"),se=oe("beforeDestroy"),le=oe("destroyed"),pe=oe("errorCaptured"),ve=oe("activated"),de=oe("deactivated"),ye=oe("serverPrefetch");function be(){_e(this,S)}function ge(){_e(this,E)}function he(){var e=b();return e?function(e){return void 0!==e[S]}(e)||function(e){e[S]=[],e[E]=[],e.$on("hook:beforeUpdate",be),e.$on("hook:updated",ge)}(e):(ie||(ie=j(y())),e=ie),e}function _e(e,t){for(var n=e[t],r=0;r<n.length;r++)n[r]();n.length=0}function me(e,t,n){var r=function(){e.$nextTick((function(){e[S].length&&_e(e,S),e[E].length&&_e(e,E)}))};switch(n){case"pre":r(),e[S].push(t);break;case"post":r(),e[E].push(t);break;default:!function(e,t){if(!e)throw new Error("[vue-composition-api] "+t)}(!1,'flush must be one of ["post", "pre", "sync"], but got '+n)}}function we(e,t){var n=e.teardown;e.teardown=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n.apply(e,r),t()}}function xe(e,t,n,r){var i,u=r.flush,f="sync"===u,a=function(e){i=function(){try{e()}catch(e){!function(e,t,n){if("undefined"==typeof window||"undefined"==typeof console)throw e;console.error(e)}(e)}}},c=function(){i&&(i(),i=null)},s=function(t){return f||e===ie?t:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return me(e,(function(){t.apply(void 0,w(n))}),u)}};if(null===n){var v=function(e,t,n,r){var o=e._watchers.length;return e.$watch(t,n,{immediate:r.immediateInvokeCallback,deep:r.deep,lazy:r.noRun,sync:r.sync,before:r.before}),e._watchers[o]}(e,(function(){return t(a)}),o,{deep:r.deep||!1,sync:f,before:c});we(v,c),v.lazy=!1;var d=v.get.bind(v);return v.get=s(d),function(){v.teardown()}}var y,b=r.deep;Array.isArray(t)?y=function(){return t.map((function(e){return B(e)?e.value:e()}))}:B(t)?y=function(){return t.value}:Q(t)?(y=function(){return t},b=!0):l(t)?y=t:(y=o,p("Invalid watch source: "+JSON.stringify(t)+".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.",e));var g=function(e,t){c(),n(e,t,a)},h=s(g);if(r.immediate){var _=h,m=function(e,t){m=_,g(e,t)};h=function(e,t){m(e,t)}}var x=e.$watch(y,h,{immediate:r.immediate,deep:b,sync:f});return we(e._watchers[e._watchers.length-1],c),function(){x()}}var je={};var Oe=function(e){return W(e,ne)},$e={install:Oe};v&&"undefined"!=typeof window&&window.Vue&&Oe(window.Vue),exports.computed=function(e){var t,n,r=b();"function"==typeof e?t=e:(t=e.get,n=e.set);var o=j(y(),{computed:{$$state:{get:t,set:n}}});return r&&r.$on("hook:destroyed",(function(){return o.$destroy()})),U({get:function(){return o.$$state},set:function(e){o.$$state=e}})},exports.createComponent=function(e){return e},exports.createElement=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d?d.$createElement.apply(d,e):(p("`createElement()` has been called outside of render function."),X||(X=j(y()).$createElement),X.apply(X,e))},exports.default=$e,exports.defineComponent=re,exports.getCurrentInstance=b,exports.inject=function(e,t){if(!e)return t;var n=b();if(n){var r=function(e,t){for(var n=t;n;){if(n._provided&&c(n._provided,e))return n._provided[e];n=n.$parent}return je}(e,n);return r!==je?r:t}p("inject() can only be used inside setup() or functional components.")},exports.isReactive=Q,exports.isRef=B,exports.markRaw=L,exports.onActivated=ve,exports.onBeforeMount=ue,exports.onBeforeUnmount=se,exports.onBeforeUpdate=ae,exports.onDeactivated=de,exports.onErrorCaptured=pe,exports.onMounted=fe,exports.onServerPrefetch=ye,exports.onUnmounted=le,exports.onUpdated=ce,exports.provide=function(e,t){var n=x();if(n){if(!n._provided){var r={};Object.defineProperty(n,"_provided",{get:function(){return r},set:function(e){return Object.assign(r,e)}})}n._provided[e]=t}},exports.reactive=H,exports.ref=I,exports.set=function(e,t,n){var r,o=y().util,i=(o.warn,o.defineReactive);if(r=e,Array.isArray(r)&&function(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}(t))return e.length=Math.max(e.length,t),e.splice(t,1,n),n;if(t in e&&!(t in Object.prototype))return e[t]=n,n;var u=e.__ob__;return e._isVue||u&&u.vmCount?n:u?(i(u.value,t,n),q(e,t,n),G(u.value[t]),u.dep.notify(),n):(e[t]=n,n)},exports.shallowReactive=N,exports.shallowRef=function(e){var t;if(B(e))return e;var n=N(((t={})[P]=e,t));return U({get:function(){return n[P]},set:function(e){return n[P]=e}})},exports.toRaw=function(e){return V(J)||!Object.isExtensible(e)?e:e.__ob__.value||e},exports.toRef=z,exports.toRefs=function(e){if(!s(e))return e;var t={};for(var n in e)t[n]=z(e,n);return t},exports.triggerRef=function(e){B(e)&&(e.value=e.value)},exports.unref=function(e){return B(e)?e.value:e},exports.watch=function(e,t,n){var r=null;"function"==typeof t?r=t:(n=t,r=null);var o=function(e){return h({immediate:!1,deep:!1,flush:"post"},e)}(n);return xe(he(),e,r,o)},exports.watchEffect=function(e,t){var n=function(e){return h({immediate:!0,deep:!1,flush:"post"},e)}(t);return xe(he(),e,null,n)}; |
@@ -7,4 +7,6 @@ import Vue from 'vue'; | ||
} | ||
var hasSymbol = typeof Symbol !== 'undefined' && isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); | ||
var hasSymbol = typeof Symbol !== 'undefined' && | ||
isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && | ||
isNative(Reflect.ownKeys); | ||
var noopFn = function (_) { return _; }; | ||
@@ -52,3 +54,3 @@ var sharedPropertyDefinition = { | ||
function logError(err, vm, info) { | ||
{ | ||
if (((__DEV__))) { | ||
warn("Error in " + info + ": \"" + err.toString() + "\"", vm); | ||
@@ -67,3 +69,3 @@ } | ||
function getCurrentVue() { | ||
{ | ||
if (((__DEV__))) { | ||
assert(currentVue, "must call Vue.use(plugin) before using any function."); | ||
@@ -83,6 +85,69 @@ } | ||
function ensureCurrentVMInFn(hook) { | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __values(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function currentVMInFn(hook) { | ||
var vm = getCurrentVM(); | ||
{ | ||
assert(vm, "\"" + hook + "\" get called outside of \"setup()\""); | ||
if (((__DEV__)) && !vm) { | ||
warn(hook + " is called when there is no active component instance to be " + | ||
"associated with. " + | ||
"Lifecycle injection APIs can only be used during execution of setup()."); | ||
} | ||
@@ -147,3 +212,3 @@ return vm; | ||
var ReactiveIdentifierKey = createSymbol('vfa.key.reactiveIdentifier'); | ||
var NonReactiveIdentifierKey = createSymbol('vfa.key.nonReactiveIdentifier'); | ||
var RawIdentifierKey = createSymbol('vfa.key.rawIdentifierKey'); | ||
// must be a string, symbol key is ignored in reactive | ||
@@ -164,12 +229,11 @@ var RefKey = 'vfa.key.refKey'; | ||
// seal the ref, this could prevent ref from being observed | ||
// It's safe to seal the ref, since we really shoulnd't extend it. | ||
// It's safe to seal the ref, since we really shouldn't extend it. | ||
// related issues: #79 | ||
return Object.seal(new RefImpl(options)); | ||
} | ||
// implementation | ||
function ref(raw) { | ||
// if (isRef(raw)) { | ||
// return {} as any; | ||
// } | ||
var _a; | ||
if (isRef(raw)) { | ||
return raw; | ||
} | ||
var value = reactive((_a = {}, _a[RefKey] = raw, _a)); | ||
@@ -184,29 +248,53 @@ return createRef({ | ||
} | ||
function unref(ref) { | ||
return isRef(ref) ? ref.value : ref; | ||
} | ||
function toRefs(obj) { | ||
if (!isPlainObject(obj)) | ||
return obj; | ||
var res = {}; | ||
Object.keys(obj).forEach(function (key) { | ||
var val = obj[key]; | ||
// use ref to proxy the property | ||
if (!isRef(val)) { | ||
val = createRef({ | ||
get: function () { return obj[key]; }, | ||
set: function (v) { return (obj[key] = v); }, | ||
}); | ||
} | ||
// todo | ||
res[key] = val; | ||
if (((__DEV__)) && !isReactive(obj)) { | ||
warn("toRefs() expects a reactive object but received a plain one."); | ||
} | ||
var ret = {}; | ||
for (var key in obj) { | ||
ret[key] = toRef(obj, key); | ||
} | ||
return ret; | ||
} | ||
function toRef(object, key) { | ||
var v = object[key]; | ||
if (isRef(v)) | ||
return v; | ||
return createRef({ | ||
get: function () { return object[key]; }, | ||
set: function (v) { return (object[key] = v); }, | ||
}); | ||
return res; | ||
} | ||
function shallowRef(raw) { | ||
var _a; | ||
if (isRef(raw)) { | ||
return raw; | ||
} | ||
var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); | ||
return createRef({ | ||
get: function () { return value[RefKey]; }, | ||
set: function (v) { return (value[RefKey] = v); }, | ||
}); | ||
} | ||
function triggerRef(value) { | ||
if (!isRef(value)) | ||
return; | ||
value.value = value.value; | ||
} | ||
var AccessControlIdentifier = {}; | ||
var ReactiveIdentifier = {}; | ||
var NonReactiveIdentifier = {}; | ||
function isNonReactive(obj) { | ||
return (hasOwn(obj, NonReactiveIdentifierKey) && obj[NonReactiveIdentifierKey] === NonReactiveIdentifier); | ||
var RawIdentifier = {}; | ||
function isRaw(obj) { | ||
return hasOwn(obj, RawIdentifierKey) && obj[RawIdentifierKey] === RawIdentifier; | ||
} | ||
function isReactive(obj) { | ||
return hasOwn(obj, ReactiveIdentifierKey) && obj[ReactiveIdentifierKey] === ReactiveIdentifier; | ||
return (Object.isExtensible(obj) && | ||
hasOwn(obj, ReactiveIdentifierKey) && | ||
obj[ReactiveIdentifierKey] === ReactiveIdentifier); | ||
} | ||
@@ -219,3 +307,3 @@ /** | ||
if (!isPlainObject(target) || | ||
isNonReactive(target) || | ||
isRaw(target) || | ||
Array.isArray(target) || | ||
@@ -307,2 +395,93 @@ isRef(target) || | ||
} | ||
function shallowReactive(obj) { | ||
var e_1, _a; | ||
if (((__DEV__)) && !obj) { | ||
warn('"shallowReactive()" is called without provide an "object".'); | ||
// @ts-ignore | ||
return; | ||
} | ||
if (!isPlainObject(obj) || isReactive(obj) || isRaw(obj) || !Object.isExtensible(obj)) { | ||
return obj; | ||
} | ||
var observed = observe({}); | ||
markReactive(observed, true); | ||
setupAccessControl(observed); | ||
var ob = observed.__ob__; | ||
var _loop_1 = function (key) { | ||
var val = obj[key]; | ||
var getter; | ||
var setter; | ||
var property = Object.getOwnPropertyDescriptor(obj, key); | ||
if (property) { | ||
if (property.configurable === false) { | ||
return "continue"; | ||
} | ||
getter = property.get; | ||
setter = property.set; | ||
if ((!getter || setter) /* not only have getter */ && arguments_1.length === 2) { | ||
val = obj[key]; | ||
} | ||
} | ||
// setupAccessControl(val); | ||
Object.defineProperty(observed, key, { | ||
enumerable: true, | ||
configurable: true, | ||
get: function getterHandler() { | ||
var value = getter ? getter.call(obj) : val; | ||
ob.dep.depend(); | ||
return value; | ||
}, | ||
set: function setterHandler(newVal) { | ||
if (getter && !setter) | ||
return; | ||
if (setter) { | ||
setter.call(obj, newVal); | ||
} | ||
else { | ||
val = newVal; | ||
} | ||
ob.dep.notify(); | ||
}, | ||
}); | ||
}; | ||
var arguments_1 = arguments; | ||
try { | ||
for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var key = _c.value; | ||
_loop_1(key); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return observed; | ||
} | ||
function markReactive(target, shallow) { | ||
if (shallow === void 0) { shallow = false; } | ||
if (!isPlainObject(target) || | ||
isRaw(target) || | ||
Array.isArray(target) || | ||
isRef(target) || | ||
isComponentInstance(target)) { | ||
return; | ||
} | ||
if (hasOwn(target, ReactiveIdentifierKey) && | ||
target[ReactiveIdentifierKey] === ReactiveIdentifier) { | ||
return; | ||
} | ||
if (Object.isExtensible(target)) { | ||
def(target, ReactiveIdentifierKey, ReactiveIdentifier); | ||
} | ||
if (shallow) { | ||
return; | ||
} | ||
var keys = Object.keys(target); | ||
for (var i = 0; i < keys.length; i++) { | ||
markReactive(target[keys[i]]); | ||
} | ||
} | ||
/** | ||
@@ -312,3 +491,3 @@ * Make obj reactivity | ||
function reactive(obj) { | ||
if (!obj) { | ||
if (((__DEV__)) && !obj) { | ||
warn('"reactive()" is called without provide an "object".'); | ||
@@ -318,7 +497,8 @@ // @ts-ignore | ||
} | ||
if (!isPlainObject(obj) || isReactive(obj) || isNonReactive(obj) || !Object.isExtensible(obj)) { | ||
if (!isPlainObject(obj) || isReactive(obj) || isRaw(obj) || !Object.isExtensible(obj)) { | ||
return obj; | ||
} | ||
var observed = observe(obj); | ||
def(observed, ReactiveIdentifierKey, ReactiveIdentifier); | ||
// def(obj, ReactiveIdentifierKey, ReactiveIdentifier); | ||
markReactive(obj); | ||
setupAccessControl(observed); | ||
@@ -330,3 +510,3 @@ return observed; | ||
*/ | ||
function nonReactive(obj) { | ||
function markRaw(obj) { | ||
if (!isPlainObject(obj)) { | ||
@@ -337,6 +517,12 @@ return obj; | ||
def(obj, '__ob__', observe({}).__ob__); | ||
// mark as nonReactive | ||
def(obj, NonReactiveIdentifierKey, NonReactiveIdentifier); | ||
// mark as Raw | ||
def(obj, RawIdentifierKey, RawIdentifier); | ||
return obj; | ||
} | ||
function toRaw(observed) { | ||
if (isRaw(observe) || !Object.isExtensible(observed)) { | ||
return observed; | ||
} | ||
return observed.__ob__.value || observed; | ||
} | ||
@@ -365,3 +551,3 @@ function isUndef(v) { | ||
var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; | ||
if (isUndef(target) || isPrimitive(target)) { | ||
if (((__DEV__)) && (isUndef(target) || isPrimitive(target))) { | ||
warn("Cannot set reactive property on undefined, null, or primitive value: " + target); | ||
@@ -380,3 +566,4 @@ } | ||
if (target._isVue || (ob && ob.vmCount)) { | ||
warn('Avoid adding reactive properties to a Vue instance or its root $data ' + | ||
((__DEV__)) && | ||
warn('Avoid adding reactive properties to a Vue instance or its root $data ' + | ||
'at runtime - declare it upfront in the data option.'); | ||
@@ -392,2 +579,3 @@ return val; | ||
defineAccessControl(target, key, val); | ||
markReactive(ob.value[key]); | ||
ob.dep.notify(); | ||
@@ -418,4 +606,6 @@ return val; | ||
else if (toVal !== fromVal && | ||
(isPlainObject(toVal) && !isRef(toVal)) && | ||
(isPlainObject(fromVal) && !isRef(fromVal))) { | ||
isPlainObject(toVal) && | ||
!isRef(toVal) && | ||
isPlainObject(fromVal) && | ||
!isRef(fromVal)) { | ||
mergeData(fromVal, toVal); | ||
@@ -428,3 +618,3 @@ } | ||
if (currentVue && currentVue === Vue) { | ||
{ | ||
if (((__DEV__))) { | ||
assert(false, 'already installed. Vue.use(plugin) should be called only once'); | ||
@@ -443,51 +633,2 @@ } | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function set$1(vm, key, value) { | ||
@@ -514,3 +655,3 @@ var state = (vm.__secret_vfa_state__ = vm.__secret_vfa_state__ || {}); | ||
}); | ||
{ | ||
if (((__DEV__))) { | ||
// expose binding to Vue Devtool as a data property | ||
@@ -528,3 +669,3 @@ // delay this until state has been resolved to prevent repeated works | ||
} | ||
else { | ||
else if (((__DEV__))) { | ||
if (props && hasOwn(props, propName)) { | ||
@@ -636,3 +777,3 @@ warn("The setup binding property \"" + propName + "\" is already declared as a prop.", vm); | ||
if (typeof setup !== 'function') { | ||
{ | ||
if (((__DEV__))) { | ||
warn('The "setup" option should be a function that returns a object in component definitions.', vm); | ||
@@ -684,4 +825,8 @@ } | ||
else { | ||
// bind function to the vm, this will make `this` = vm | ||
if (isFunction(bindingValue)) { | ||
bindingValue = bindingValue.bind(vm); | ||
} | ||
// a non-reactive should not don't get reactivity | ||
bindingValue = ref(nonReactive(bindingValue)); | ||
bindingValue = ref(markRaw(bindingValue)); | ||
} | ||
@@ -693,3 +838,3 @@ } | ||
} | ||
{ | ||
if (((__DEV__))) { | ||
assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"" + Object.prototype.toString | ||
@@ -773,3 +918,3 @@ .call(binding) | ||
function createComponent(options) { | ||
{ | ||
if (((__DEV__))) { | ||
Vue.util.warn('`createComponent` has been renamed to `defineComponent`.'); | ||
@@ -783,4 +928,6 @@ } | ||
return function (callback) { | ||
var vm = ensureCurrentVMInFn(genName(lifeCyclehook)); | ||
injectHookOption(getCurrentVue(), vm, lifeCyclehook, callback); | ||
var vm = currentVMInFn(genName(lifeCyclehook)); | ||
if (vm) { | ||
injectHookOption(getCurrentVue(), vm, lifeCyclehook, callback); | ||
} | ||
}; | ||
@@ -791,4 +938,20 @@ } | ||
var mergeFn = Vue.config.optionMergeStrategies[hook]; | ||
options[hook] = mergeFn(options[hook], val); | ||
options[hook] = mergeFn(options[hook], wrapHookCall(vm, val)); | ||
} | ||
function wrapHookCall(vm, fn) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var preVm = getCurrentVM(); | ||
setCurrentVM(vm); | ||
try { | ||
return fn.apply(void 0, __spread(args)); | ||
} | ||
finally { | ||
setCurrentVM(preVm); | ||
} | ||
}; | ||
} | ||
// export const onCreated = createLifeCycle('created'); | ||
@@ -824,3 +987,3 @@ var onBeforeMount = createLifeCycle('beforeMount'); | ||
return __assign({ | ||
lazy: false, | ||
immediate: false, | ||
deep: false, | ||
@@ -830,2 +993,9 @@ flush: 'post', | ||
} | ||
function getWatchEffectOption(options) { | ||
return __assign({ | ||
immediate: true, | ||
deep: false, | ||
flush: 'post', | ||
}, options); | ||
} | ||
function getWatcherVM() { | ||
@@ -889,2 +1059,15 @@ var vm = getCurrentVM(); | ||
} | ||
// We have to monkeypatch the teardown function so Vue will run | ||
// runCleanup() when it tears down the watcher on unmmount. | ||
function patchWatcherTeardown(watcher, runCleanup) { | ||
var _teardown = watcher.teardown; | ||
watcher.teardown = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_teardown.apply(watcher, args); | ||
runCleanup(); | ||
}; | ||
} | ||
function createWatcher(vm, source, cb, options) { | ||
@@ -929,22 +1112,17 @@ var flushMode = options.flush; | ||
var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { | ||
noRun: true, | ||
deep: options.deep, | ||
deep: options.deep || false, | ||
sync: isSync, | ||
before: runCleanup, | ||
}); | ||
patchWatcherTeardown(watcher_1, runCleanup); | ||
// enable the watcher update | ||
watcher_1.lazy = false; | ||
var originGet = watcher_1.get.bind(watcher_1); | ||
if (isSync) { | ||
watcher_1.get(); | ||
} | ||
else { | ||
vm.$nextTick(originGet); | ||
} | ||
// always run watchEffect | ||
watcher_1.get = createScheduler(originGet); | ||
return function () { | ||
watcher_1.teardown(); | ||
runCleanup(); | ||
}; | ||
} | ||
var deep = options.deep; | ||
var getter; | ||
@@ -957,5 +1135,13 @@ if (Array.isArray(source)) { | ||
} | ||
else { | ||
else if (isReactive(source)) { | ||
getter = function () { return source; }; | ||
deep = true; | ||
} | ||
else if (isFunction(source)) { | ||
getter = source; | ||
} | ||
else { | ||
getter = noopFn; | ||
warn("Invalid watch source: " + JSON.stringify(source) + ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.", vm); | ||
} | ||
var applyCb = function (n, o) { | ||
@@ -967,3 +1153,3 @@ // cleanup before running cb again | ||
var callback = createScheduler(applyCb); | ||
if (!options.lazy) { | ||
if (options.immediate) { | ||
var originalCallbck_1 = callback; | ||
@@ -982,16 +1168,19 @@ // `shiftCallback` is used to handle the first sync effect run. | ||
var stop = vm.$watch(getter, callback, { | ||
immediate: !options.lazy, | ||
deep: options.deep, | ||
immediate: options.immediate, | ||
deep: deep, | ||
sync: isSync, | ||
}); | ||
// Once again, we have to hack the watcher for proper teardown | ||
var watcher = vm._watchers[vm._watchers.length - 1]; | ||
patchWatcherTeardown(watcher, runCleanup); | ||
return function () { | ||
stop(); | ||
runCleanup(); | ||
}; | ||
} | ||
function watchEffect(effect, options) { | ||
var opts = getWatcherOption(options); | ||
var opts = getWatchEffectOption(options); | ||
var vm = getWatcherVM(); | ||
return createWatcher(vm, effect, null, opts); | ||
} | ||
// implementation | ||
function watch(source, cb, options) { | ||
@@ -1005,3 +1194,3 @@ var callback = null; | ||
// effect watch | ||
{ | ||
if (((__DEV__))) { | ||
warn("`watch(fn, options?)` signature has been moved to a separate API. " + | ||
@@ -1038,6 +1227,7 @@ "Use `watchEffect(fn, options?)` instead. `watch` now only " + | ||
}); | ||
vm && vm.$on('hook:destroyed', function () { return computedHost.$destroy(); }); | ||
return createRef({ | ||
get: function () { return computedHost.$$state; }, | ||
set: function (v) { | ||
if (!set) { | ||
if (((__DEV__)) && !set) { | ||
warn('Computed property was assigned to but it has no setter.', vm); | ||
@@ -1065,3 +1255,5 @@ return; | ||
function provide(key, value) { | ||
var vm = ensureCurrentVMInFn('provide'); | ||
var vm = currentVMInFn('provide'); | ||
if (!vm) | ||
return; | ||
if (!vm._provided) { | ||
@@ -1080,12 +1272,17 @@ var provideCache_1 = {}; | ||
} | ||
var vm = ensureCurrentVMInFn('inject'); | ||
var val = resolveInject(key, vm); | ||
if (val !== NOT_FOUND) { | ||
return val; | ||
var vm = getCurrentVM(); | ||
if (vm) { | ||
var val = resolveInject(key, vm); | ||
if (val !== NOT_FOUND) { | ||
return val; | ||
} | ||
else { | ||
if (defaultValue === undefined && "development" !== 'production') { | ||
warn("Injection \"" + String(key) + "\" not found", vm); | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
else if (defaultValue !== undefined) { | ||
return defaultValue; | ||
} | ||
else { | ||
warn("Injection \"" + String(key) + "\" not found", vm); | ||
warn("inject() can only be used inside setup() or functional components."); | ||
} | ||
@@ -1105,2 +1302,2 @@ } | ||
export default plugin; | ||
export { computed, createComponent, createElement, defineComponent, getCurrentVM as getCurrentInstance, inject, isRef, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onServerPrefetch, onUnmounted, onUpdated, provide, reactive, ref, set, toRefs, watch, watchEffect }; | ||
export { computed, createComponent, createElement, defineComponent, getCurrentVM as getCurrentInstance, inject, isReactive, isRef, markRaw, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onServerPrefetch, onUnmounted, onUpdated, provide, reactive, ref, set, shallowReactive, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, watch, watchEffect }; |
@@ -5,5 +5,5 @@ (function (global, factory) { | ||
(global = global || self, factory(global.vueCompositionApi = {}, global.Vue)); | ||
}(this, function (exports, Vue) { 'use strict'; | ||
}(this, (function (exports, Vue) { 'use strict'; | ||
Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue; | ||
Vue = Vue && Object.prototype.hasOwnProperty.call(Vue, 'default') ? Vue['default'] : Vue; | ||
@@ -14,4 +14,6 @@ var toString = function (x) { return Object.prototype.toString.call(x); }; | ||
} | ||
var hasSymbol = typeof Symbol !== 'undefined' && isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); | ||
var hasSymbol = typeof Symbol !== 'undefined' && | ||
isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && | ||
isNative(Reflect.ownKeys); | ||
var noopFn = function (_) { return _; }; | ||
@@ -88,6 +90,69 @@ var sharedPropertyDefinition = { | ||
function ensureCurrentVMInFn(hook) { | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __values(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function currentVMInFn(hook) { | ||
var vm = getCurrentVM(); | ||
{ | ||
assert(vm, "\"" + hook + "\" get called outside of \"setup()\""); | ||
if ( !vm) { | ||
warn(hook + " is called when there is no active component instance to be " + | ||
"associated with. " + | ||
"Lifecycle injection APIs can only be used during execution of setup()."); | ||
} | ||
@@ -152,3 +217,3 @@ return vm; | ||
var ReactiveIdentifierKey = createSymbol('vfa.key.reactiveIdentifier'); | ||
var NonReactiveIdentifierKey = createSymbol('vfa.key.nonReactiveIdentifier'); | ||
var RawIdentifierKey = createSymbol('vfa.key.rawIdentifierKey'); | ||
// must be a string, symbol key is ignored in reactive | ||
@@ -169,12 +234,11 @@ var RefKey = 'vfa.key.refKey'; | ||
// seal the ref, this could prevent ref from being observed | ||
// It's safe to seal the ref, since we really shoulnd't extend it. | ||
// It's safe to seal the ref, since we really shouldn't extend it. | ||
// related issues: #79 | ||
return Object.seal(new RefImpl(options)); | ||
} | ||
// implementation | ||
function ref(raw) { | ||
// if (isRef(raw)) { | ||
// return {} as any; | ||
// } | ||
var _a; | ||
if (isRef(raw)) { | ||
return raw; | ||
} | ||
var value = reactive((_a = {}, _a[RefKey] = raw, _a)); | ||
@@ -189,29 +253,53 @@ return createRef({ | ||
} | ||
function unref(ref) { | ||
return isRef(ref) ? ref.value : ref; | ||
} | ||
function toRefs(obj) { | ||
if (!isPlainObject(obj)) | ||
return obj; | ||
var res = {}; | ||
Object.keys(obj).forEach(function (key) { | ||
var val = obj[key]; | ||
// use ref to proxy the property | ||
if (!isRef(val)) { | ||
val = createRef({ | ||
get: function () { return obj[key]; }, | ||
set: function (v) { return (obj[key] = v); }, | ||
}); | ||
} | ||
// todo | ||
res[key] = val; | ||
if ( !isReactive(obj)) { | ||
warn("toRefs() expects a reactive object but received a plain one."); | ||
} | ||
var ret = {}; | ||
for (var key in obj) { | ||
ret[key] = toRef(obj, key); | ||
} | ||
return ret; | ||
} | ||
function toRef(object, key) { | ||
var v = object[key]; | ||
if (isRef(v)) | ||
return v; | ||
return createRef({ | ||
get: function () { return object[key]; }, | ||
set: function (v) { return (object[key] = v); }, | ||
}); | ||
return res; | ||
} | ||
function shallowRef(raw) { | ||
var _a; | ||
if (isRef(raw)) { | ||
return raw; | ||
} | ||
var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); | ||
return createRef({ | ||
get: function () { return value[RefKey]; }, | ||
set: function (v) { return (value[RefKey] = v); }, | ||
}); | ||
} | ||
function triggerRef(value) { | ||
if (!isRef(value)) | ||
return; | ||
value.value = value.value; | ||
} | ||
var AccessControlIdentifier = {}; | ||
var ReactiveIdentifier = {}; | ||
var NonReactiveIdentifier = {}; | ||
function isNonReactive(obj) { | ||
return (hasOwn(obj, NonReactiveIdentifierKey) && obj[NonReactiveIdentifierKey] === NonReactiveIdentifier); | ||
var RawIdentifier = {}; | ||
function isRaw(obj) { | ||
return hasOwn(obj, RawIdentifierKey) && obj[RawIdentifierKey] === RawIdentifier; | ||
} | ||
function isReactive(obj) { | ||
return hasOwn(obj, ReactiveIdentifierKey) && obj[ReactiveIdentifierKey] === ReactiveIdentifier; | ||
return (Object.isExtensible(obj) && | ||
hasOwn(obj, ReactiveIdentifierKey) && | ||
obj[ReactiveIdentifierKey] === ReactiveIdentifier); | ||
} | ||
@@ -224,3 +312,3 @@ /** | ||
if (!isPlainObject(target) || | ||
isNonReactive(target) || | ||
isRaw(target) || | ||
Array.isArray(target) || | ||
@@ -312,2 +400,93 @@ isRef(target) || | ||
} | ||
function shallowReactive(obj) { | ||
var e_1, _a; | ||
if ( !obj) { | ||
warn('"shallowReactive()" is called without provide an "object".'); | ||
// @ts-ignore | ||
return; | ||
} | ||
if (!isPlainObject(obj) || isReactive(obj) || isRaw(obj) || !Object.isExtensible(obj)) { | ||
return obj; | ||
} | ||
var observed = observe({}); | ||
markReactive(observed, true); | ||
setupAccessControl(observed); | ||
var ob = observed.__ob__; | ||
var _loop_1 = function (key) { | ||
var val = obj[key]; | ||
var getter; | ||
var setter; | ||
var property = Object.getOwnPropertyDescriptor(obj, key); | ||
if (property) { | ||
if (property.configurable === false) { | ||
return "continue"; | ||
} | ||
getter = property.get; | ||
setter = property.set; | ||
if ((!getter || setter) /* not only have getter */ && arguments_1.length === 2) { | ||
val = obj[key]; | ||
} | ||
} | ||
// setupAccessControl(val); | ||
Object.defineProperty(observed, key, { | ||
enumerable: true, | ||
configurable: true, | ||
get: function getterHandler() { | ||
var value = getter ? getter.call(obj) : val; | ||
ob.dep.depend(); | ||
return value; | ||
}, | ||
set: function setterHandler(newVal) { | ||
if (getter && !setter) | ||
return; | ||
if (setter) { | ||
setter.call(obj, newVal); | ||
} | ||
else { | ||
val = newVal; | ||
} | ||
ob.dep.notify(); | ||
}, | ||
}); | ||
}; | ||
var arguments_1 = arguments; | ||
try { | ||
for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
var key = _c.value; | ||
_loop_1(key); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
return observed; | ||
} | ||
function markReactive(target, shallow) { | ||
if (shallow === void 0) { shallow = false; } | ||
if (!isPlainObject(target) || | ||
isRaw(target) || | ||
Array.isArray(target) || | ||
isRef(target) || | ||
isComponentInstance(target)) { | ||
return; | ||
} | ||
if (hasOwn(target, ReactiveIdentifierKey) && | ||
target[ReactiveIdentifierKey] === ReactiveIdentifier) { | ||
return; | ||
} | ||
if (Object.isExtensible(target)) { | ||
def(target, ReactiveIdentifierKey, ReactiveIdentifier); | ||
} | ||
if (shallow) { | ||
return; | ||
} | ||
var keys = Object.keys(target); | ||
for (var i = 0; i < keys.length; i++) { | ||
markReactive(target[keys[i]]); | ||
} | ||
} | ||
/** | ||
@@ -317,3 +496,3 @@ * Make obj reactivity | ||
function reactive(obj) { | ||
if (!obj) { | ||
if ( !obj) { | ||
warn('"reactive()" is called without provide an "object".'); | ||
@@ -323,7 +502,8 @@ // @ts-ignore | ||
} | ||
if (!isPlainObject(obj) || isReactive(obj) || isNonReactive(obj) || !Object.isExtensible(obj)) { | ||
if (!isPlainObject(obj) || isReactive(obj) || isRaw(obj) || !Object.isExtensible(obj)) { | ||
return obj; | ||
} | ||
var observed = observe(obj); | ||
def(observed, ReactiveIdentifierKey, ReactiveIdentifier); | ||
// def(obj, ReactiveIdentifierKey, ReactiveIdentifier); | ||
markReactive(obj); | ||
setupAccessControl(observed); | ||
@@ -335,3 +515,3 @@ return observed; | ||
*/ | ||
function nonReactive(obj) { | ||
function markRaw(obj) { | ||
if (!isPlainObject(obj)) { | ||
@@ -342,6 +522,12 @@ return obj; | ||
def(obj, '__ob__', observe({}).__ob__); | ||
// mark as nonReactive | ||
def(obj, NonReactiveIdentifierKey, NonReactiveIdentifier); | ||
// mark as Raw | ||
def(obj, RawIdentifierKey, RawIdentifier); | ||
return obj; | ||
} | ||
function toRaw(observed) { | ||
if (isRaw(observe) || !Object.isExtensible(observed)) { | ||
return observed; | ||
} | ||
return observed.__ob__.value || observed; | ||
} | ||
@@ -370,3 +556,3 @@ function isUndef(v) { | ||
var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; | ||
if (isUndef(target) || isPrimitive(target)) { | ||
if ( (isUndef(target) || isPrimitive(target))) { | ||
warn("Cannot set reactive property on undefined, null, or primitive value: " + target); | ||
@@ -385,3 +571,4 @@ } | ||
if (target._isVue || (ob && ob.vmCount)) { | ||
warn('Avoid adding reactive properties to a Vue instance or its root $data ' + | ||
warn('Avoid adding reactive properties to a Vue instance or its root $data ' + | ||
'at runtime - declare it upfront in the data option.'); | ||
@@ -397,2 +584,3 @@ return val; | ||
defineAccessControl(target, key, val); | ||
markReactive(ob.value[key]); | ||
ob.dep.notify(); | ||
@@ -423,4 +611,6 @@ return val; | ||
else if (toVal !== fromVal && | ||
(isPlainObject(toVal) && !isRef(toVal)) && | ||
(isPlainObject(fromVal) && !isRef(fromVal))) { | ||
isPlainObject(toVal) && | ||
!isRef(toVal) && | ||
isPlainObject(fromVal) && | ||
!isRef(fromVal)) { | ||
mergeData(fromVal, toVal); | ||
@@ -447,51 +637,2 @@ } | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var __assign = function() { | ||
__assign = Object.assign || function __assign(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
function __spread() { | ||
for (var ar = [], i = 0; i < arguments.length; i++) | ||
ar = ar.concat(__read(arguments[i])); | ||
return ar; | ||
} | ||
function set$1(vm, key, value) { | ||
@@ -685,4 +826,8 @@ var state = (vm.__secret_vfa_state__ = vm.__secret_vfa_state__ || {}); | ||
else { | ||
// bind function to the vm, this will make `this` = vm | ||
if (isFunction(bindingValue)) { | ||
bindingValue = bindingValue.bind(vm); | ||
} | ||
// a non-reactive should not don't get reactivity | ||
bindingValue = ref(nonReactive(bindingValue)); | ||
bindingValue = ref(markRaw(bindingValue)); | ||
} | ||
@@ -782,4 +927,6 @@ } | ||
return function (callback) { | ||
var vm = ensureCurrentVMInFn(genName(lifeCyclehook)); | ||
injectHookOption(getCurrentVue(), vm, lifeCyclehook, callback); | ||
var vm = currentVMInFn(genName(lifeCyclehook)); | ||
if (vm) { | ||
injectHookOption(getCurrentVue(), vm, lifeCyclehook, callback); | ||
} | ||
}; | ||
@@ -790,4 +937,20 @@ } | ||
var mergeFn = Vue.config.optionMergeStrategies[hook]; | ||
options[hook] = mergeFn(options[hook], val); | ||
options[hook] = mergeFn(options[hook], wrapHookCall(vm, val)); | ||
} | ||
function wrapHookCall(vm, fn) { | ||
return function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var preVm = getCurrentVM(); | ||
setCurrentVM(vm); | ||
try { | ||
return fn.apply(void 0, __spread(args)); | ||
} | ||
finally { | ||
setCurrentVM(preVm); | ||
} | ||
}; | ||
} | ||
// export const onCreated = createLifeCycle('created'); | ||
@@ -823,3 +986,3 @@ var onBeforeMount = createLifeCycle('beforeMount'); | ||
return __assign({ | ||
lazy: false, | ||
immediate: false, | ||
deep: false, | ||
@@ -829,2 +992,9 @@ flush: 'post', | ||
} | ||
function getWatchEffectOption(options) { | ||
return __assign({ | ||
immediate: true, | ||
deep: false, | ||
flush: 'post', | ||
}, options); | ||
} | ||
function getWatcherVM() { | ||
@@ -888,2 +1058,15 @@ var vm = getCurrentVM(); | ||
} | ||
// We have to monkeypatch the teardown function so Vue will run | ||
// runCleanup() when it tears down the watcher on unmmount. | ||
function patchWatcherTeardown(watcher, runCleanup) { | ||
var _teardown = watcher.teardown; | ||
watcher.teardown = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
_teardown.apply(watcher, args); | ||
runCleanup(); | ||
}; | ||
} | ||
function createWatcher(vm, source, cb, options) { | ||
@@ -928,22 +1111,17 @@ var flushMode = options.flush; | ||
var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { | ||
noRun: true, | ||
deep: options.deep, | ||
deep: options.deep || false, | ||
sync: isSync, | ||
before: runCleanup, | ||
}); | ||
patchWatcherTeardown(watcher_1, runCleanup); | ||
// enable the watcher update | ||
watcher_1.lazy = false; | ||
var originGet = watcher_1.get.bind(watcher_1); | ||
if (isSync) { | ||
watcher_1.get(); | ||
} | ||
else { | ||
vm.$nextTick(originGet); | ||
} | ||
// always run watchEffect | ||
watcher_1.get = createScheduler(originGet); | ||
return function () { | ||
watcher_1.teardown(); | ||
runCleanup(); | ||
}; | ||
} | ||
var deep = options.deep; | ||
var getter; | ||
@@ -956,5 +1134,13 @@ if (Array.isArray(source)) { | ||
} | ||
else { | ||
else if (isReactive(source)) { | ||
getter = function () { return source; }; | ||
deep = true; | ||
} | ||
else if (isFunction(source)) { | ||
getter = source; | ||
} | ||
else { | ||
getter = noopFn; | ||
warn("Invalid watch source: " + JSON.stringify(source) + ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.", vm); | ||
} | ||
var applyCb = function (n, o) { | ||
@@ -966,3 +1152,3 @@ // cleanup before running cb again | ||
var callback = createScheduler(applyCb); | ||
if (!options.lazy) { | ||
if (options.immediate) { | ||
var originalCallbck_1 = callback; | ||
@@ -981,16 +1167,19 @@ // `shiftCallback` is used to handle the first sync effect run. | ||
var stop = vm.$watch(getter, callback, { | ||
immediate: !options.lazy, | ||
deep: options.deep, | ||
immediate: options.immediate, | ||
deep: deep, | ||
sync: isSync, | ||
}); | ||
// Once again, we have to hack the watcher for proper teardown | ||
var watcher = vm._watchers[vm._watchers.length - 1]; | ||
patchWatcherTeardown(watcher, runCleanup); | ||
return function () { | ||
stop(); | ||
runCleanup(); | ||
}; | ||
} | ||
function watchEffect(effect, options) { | ||
var opts = getWatcherOption(options); | ||
var opts = getWatchEffectOption(options); | ||
var vm = getWatcherVM(); | ||
return createWatcher(vm, effect, null, opts); | ||
} | ||
// implementation | ||
function watch(source, cb, options) { | ||
@@ -1036,6 +1225,7 @@ var callback = null; | ||
}); | ||
vm && vm.$on('hook:destroyed', function () { return computedHost.$destroy(); }); | ||
return createRef({ | ||
get: function () { return computedHost.$$state; }, | ||
set: function (v) { | ||
if (!set) { | ||
if ( !set) { | ||
warn('Computed property was assigned to but it has no setter.', vm); | ||
@@ -1063,3 +1253,5 @@ return; | ||
function provide(key, value) { | ||
var vm = ensureCurrentVMInFn('provide'); | ||
var vm = currentVMInFn('provide'); | ||
if (!vm) | ||
return; | ||
if (!vm._provided) { | ||
@@ -1078,12 +1270,17 @@ var provideCache_1 = {}; | ||
} | ||
var vm = ensureCurrentVMInFn('inject'); | ||
var val = resolveInject(key, vm); | ||
if (val !== NOT_FOUND) { | ||
return val; | ||
var vm = getCurrentVM(); | ||
if (vm) { | ||
var val = resolveInject(key, vm); | ||
if (val !== NOT_FOUND) { | ||
return val; | ||
} | ||
else { | ||
if (defaultValue === undefined && "development" !== 'production') { | ||
warn("Injection \"" + String(key) + "\" not found", vm); | ||
} | ||
return defaultValue; | ||
} | ||
} | ||
else if (defaultValue !== undefined) { | ||
return defaultValue; | ||
} | ||
else { | ||
warn("Injection \"" + String(key) + "\" not found", vm); | ||
warn("inject() can only be used inside setup() or functional components."); | ||
} | ||
@@ -1109,3 +1306,5 @@ } | ||
exports.inject = inject; | ||
exports.isReactive = isReactive; | ||
exports.isRef = isRef; | ||
exports.markRaw = markRaw; | ||
exports.onActivated = onActivated; | ||
@@ -1125,3 +1324,9 @@ exports.onBeforeMount = onBeforeMount; | ||
exports.set = set; | ||
exports.shallowReactive = shallowReactive; | ||
exports.shallowRef = shallowRef; | ||
exports.toRaw = toRaw; | ||
exports.toRef = toRef; | ||
exports.toRefs = toRefs; | ||
exports.triggerRef = triggerRef; | ||
exports.unref = unref; | ||
exports.watch = watch; | ||
@@ -1132,2 +1337,2 @@ exports.watchEffect = watchEffect; | ||
})); | ||
}))); |
@@ -1,1 +0,15 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],n):n((e=e||self).vueCompositionApi={},e.Vue)}(this,function(e,n){"use strict";n=n&&n.hasOwnProperty("default")?n.default:n;var t=function(e){return Object.prototype.toString.call(e)};function r(e){return"function"==typeof e&&/native code/.test(e.toString())}var o="undefined"!=typeof Symbol&&r(Symbol)&&"undefined"!=typeof Reflect&&r(Reflect.ownKeys),i=function(e){return e},u={enumerable:!0,configurable:!0,get:i,set:i};function f(e,n,t){var r=t.get,o=t.set;u.get=r||i,u.set=o||i,Object.defineProperty(e,n,u)}function a(e,n,t,r){Object.defineProperty(e,n,{value:t,enumerable:!!r,writable:!0,configurable:!0})}var c=Object.prototype.hasOwnProperty;function s(e,n){return c.call(e,n)}function l(e){return"[object Object]"===t(e)}function v(e,t){n.util.warn(e,t)}var p=null,d=null;function y(){return p}function g(){return d}function h(e){d=e}function b(e){return g()}function _(e,n){void 0===n&&(n={});var t=e.config.silent;e.config.silent=!0;var r=new e(n);return e.config.silent=t,r}function m(e,n){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.$scopedSlots[n]?e.$scopedSlots[n].apply(e,t):v("slots."+n+'() got called outside of the "render()" scope',e)}}function w(e){return o?Symbol.for(e):e}var $=w("vfa.key.preFlushQueue"),O=w("vfa.key.postFlushQueue"),j=w("vfa.key.accessControlIdentifier"),k=w("vfa.key.reactiveIdentifier"),S=w("vfa.key.nonReactiveIdentifier"),C="vfa.key.refKey",E=function(){return function(e){f(this,"value",{get:e.get,set:e.set})}}();function x(e){return Object.seal(new E(e))}function P(e){var n,t=D(((n={})[C]=e,n));return x({get:function(){return t[C]},set:function(e){return t[C]=e}})}function A(e){return e instanceof E}var R={},M={},z={};function U(e){return s(e,S)&&e[S]===z}function B(e){return s(e,k)&&e[k]===M}function I(e){var n;if(!(!l(e)||U(e)||Array.isArray(e)||A(e)||(n=e,p&&n instanceof p))&&(!s(e,j)||e[j]!==R)){Object.isExtensible(e)&&a(e,j,R);for(var t=Object.keys(e),r=0;r<t.length;r++)V(e,t[r])}}function V(e,n,t){if("__ob__"!==n){var r,o,i=Object.getOwnPropertyDescriptor(e,n);if(i){if(!1===i.configurable)return;r=i.get,o=i.set,r&&!o||2!==arguments.length||(t=e[n])}I(t),Object.defineProperty(e,n,{enumerable:!0,configurable:!0,get:function(){var o=r?r.call(e):t;return n!==C&&A(o)?o.value:o},set:function(i){if(!r||o){var u=r?r.call(e):t;n!==C&&A(u)&&!A(i)?u.value=i:o?o.call(e,i):t=i,I(i)}}})}}function F(e){var n,t=y();t.observable?n=t.observable(e):n=_(t,{data:{$$state:e}})._data.$$state;return n}function D(e){if(!l(e)||B(e)||U(e)||!Object.isExtensible(e))return e;var n=F(e);return a(n,k,M),I(n),n}function K(e,n){p&&p===e||(e.config.optionMergeStrategies.setup=function(e,n){return function(t,r){return function e(n,t){if(!n)return t;for(var r,i,u,f=o?Reflect.ownKeys(n):Object.keys(n),a=0;a<f.length;a++)"__ob__"!==(r=f[a])&&(i=t[r],u=n[r],s(t,r)?i!==u&&l(i)&&!A(i)&&l(u)&&!A(u)&&e(u,i):t[r]=u);return t}("function"==typeof e&&e(t,r)||{},"function"==typeof n&&n(t,r)||{})}},p=e,n(e))}var Q=function(){return(Q=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};function T(e,n){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var r,o,i=t.call(e),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return u}var q,G={set:function(e,n,t){(e.__secret_vfa_state__=e.__secret_vfa_state__||{})[n]=t},get:function(e,n){return(e.__secret_vfa_state__||{})[n]}};function H(e){var n=G.get(e,"rawBindings")||{};if(n&&Object.keys(n).length){for(var t=e.$refs,r=G.get(e,"refs")||[],o=0;o<r.length;o++){var i=n[a=r[o]];!t[a]&&i&&A(i)&&(i.value=null)}var u=Object.keys(t),f=[];for(o=0;o<u.length;o++){var a;i=n[a=u[o]];t[a]&&i&&A(i)&&(i.value=t[a],f.push(a))}G.set(e,"refs",f)}}function J(e,n){var t=e.$options._parentVnode;if(t){for(var r=G.get(e,"slots")||[],o=function(e,n){var t;if(e){if(e._normalized)return e._normalized;for(var r in t={},e)e[r]&&"$"!==r[0]&&(t[r]=!0)}else t={};for(var r in n)r in t||(t[r]=!0);return t}(t.data.scopedSlots,e.$slots),i=0;i<r.length;i++){o[f=r[i]]||delete n[f]}var u=Object.keys(o);for(i=0;i<u.length;i++){var f;n[f=u[i]]||(n[f]=m(e,f))}G.set(e,"slots",u)}}function L(e,n,t){var r=g();h(e);try{return n(e)}catch(e){if(!t)throw e;t(e)}finally{h(r)}}function N(e){e.mixin({beforeCreate:function(){var e=this,n=e.$options,t=n.setup,r=n.render;r&&(n.render=function(){for(var n=this,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return L(e,function(){return r.apply(n,t)})});if(!t)return;if("function"!=typeof t)return;var o=n.data;n.data=function(){return function(e,n){void 0===n&&(n={});var t,r=e.$options.setup,o=function(e){var n={slots:{}};return["root","parent","refs","attrs","listeners","isServer","ssrContext"].forEach(function(t){var r,o,i;Array.isArray(t)?(r=T(t,2),o=r[0],i=r[1]):o=i=t,i="$"+i,f(n,o,{get:function(){return e[i]},set:function(){v("Cannot assign to '"+o+"' because it is a read-only property",e)}})}),["emit"].forEach(function(t){var r="$"+t;f(n,t,{get:function(){return function(){for(var n=[],t=0;t<arguments.length;t++)n[t]=arguments[t];e[r].apply(e,n)}}})}),n}(e);if(J(e,o.slots),L(e,function(){t=r(n,o)}),!t)return;if(u=t,"function"==typeof u){var i=t;return void(e.$options.render=function(){return J(e,o.slots),L(e,function(){return i()})})}var u;if(l(t)){var c=t;G.set(e,"rawBindings",t),Object.keys(t).forEach(function(n){var t,r=c[n];A(r)||(r=B(r)?P(r):P(l(t=r)?(a(t,"__ob__",F({}).__ob__),a(t,S,z),t):t)),function(e,n,t){var r=e.$options.props;n in e||r&&s(r,n)||f(e,n,{get:function(){return t.value},set:function(e){t.value=e}})}(e,n,r)})}}(e,e.$props),"function"==typeof o?o.call(e,e):o||{}}},mounted:function(){H(this)},updated:function(){H(this)}})}function W(e){return e}var X=function(e){return"on"+(e[0].toUpperCase()+e.slice(1))};function Y(e){return function(n){var t=b(X(e));!function(e,n,t,r){var o=n.$options,i=e.config.optionMergeStrategies[t];o[t]=i(o[t],r)}(y(),t,e,n)}}var Z,ee=Y("beforeMount"),ne=Y("mounted"),te=Y("beforeUpdate"),re=Y("updated"),oe=Y("beforeDestroy"),ie=Y("destroyed"),ue=Y("errorCaptured"),fe=Y("activated"),ae=Y("deactivated"),ce=Y("serverPrefetch");function se(){de(this,$)}function le(){de(this,O)}function ve(e){return Q({lazy:!1,deep:!1,flush:"post"},e)}function pe(){var e=g();return e?function(e){return void 0!==e[$]}(e)||function(e){e[$]=[],e[O]=[],e.$on("hook:beforeUpdate",se),e.$on("hook:updated",le)}(e):(Z||(Z=_(y())),e=Z),e}function de(e,n){for(var t=e[n],r=0;r<t.length;r++)t[r]();t.length=0}function ye(e,n,t){var r=function(){e.$nextTick(function(){e[$].length&&de(e,$),e[O].length&&de(e,O)})};switch(t){case"pre":r(),e[$].push(n);break;case"post":r(),e[O].push(n);break;default:!function(e,n){if(!e)throw new Error("[vue-composition-api] "+n)}(!1,'flush must be one of ["post", "pre", "sync"], but got '+t)}}function ge(e,n,t,r){var o,u,f=r.flush,a="sync"===f,c=function(e){o=function(){try{e()}catch(e){!function(e,n,t){if("undefined"==typeof window||"undefined"==typeof console)throw e;console.error(e)}(e)}}},s=function(){o&&(o(),o=null)},l=function(n){return a||e===Z?n:function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return ye(e,function(){n.apply(void 0,function(){for(var e=[],n=0;n<arguments.length;n++)e=e.concat(T(arguments[n]));return e}(t))},f)}};if(null===t){var v=function(e,n,t,r){var o=e._watchers.length;return e.$watch(n,t,{immediate:r.immediateInvokeCallback,deep:r.deep,lazy:r.noRun,sync:r.sync,before:r.before}),e._watchers[o]}(e,function(){return n(c)},i,{noRun:!0,deep:r.deep,sync:a,before:s});v.lazy=!1;var p=v.get.bind(v);return a?v.get():e.$nextTick(p),v.get=l(p),function(){v.teardown(),s()}}u=Array.isArray(n)?function(){return n.map(function(e){return A(e)?e.value:e()})}:A(n)?function(){return n.value}:n;var d=function(e,n){s(),t(e,n,c)},y=l(d);if(!r.lazy){var g=y,h=function(e,n){h=g,d(e,n)};y=function(e,n){h(e,n)}}var b=e.$watch(u,y,{immediate:!r.lazy,deep:r.deep,sync:a});return function(){b(),s()}}var he={};var be=function(e){return K(e,N)},_e={install:be};p&&"undefined"!=typeof window&&window.Vue&&be(window.Vue),e.computed=function(e){var n,t;"function"==typeof e?n=e:(n=e.get,t=e.set);var r=_(y(),{computed:{$$state:{get:n,set:t}}});return x({get:function(){return r.$$state},set:function(e){r.$$state=e}})},e.createComponent=function(e){return W(e)},e.createElement=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return d?d.$createElement.apply(d,e):(v("`createElement()` has been called outside of render function."),q||(q=_(y()).$createElement),q.apply(q,e))},e.default=_e,e.defineComponent=W,e.getCurrentInstance=g,e.inject=function(e,n){if(!e)return n;var t=function(e,n){for(var t=n;t;){if(t._provided&&s(t._provided,e))return t._provided[e];t=t.$parent}return he}(e,b());return t!==he?t:void 0!==n?n:void 0},e.isRef=A,e.onActivated=fe,e.onBeforeMount=ee,e.onBeforeUnmount=oe,e.onBeforeUpdate=te,e.onDeactivated=ae,e.onErrorCaptured=ue,e.onMounted=ne,e.onServerPrefetch=ce,e.onUnmounted=ie,e.onUpdated=re,e.provide=function(e,n){var t=b();if(!t._provided){var r={};Object.defineProperty(t,"_provided",{get:function(){return r},set:function(e){return Object.assign(r,e)}})}t._provided[e]=n},e.reactive=D,e.ref=P,e.set=function(e,n,t){var r,o=y().util,i=(o.warn,o.defineReactive);if(r=e,Array.isArray(r)&&function(e){var n=parseFloat(String(e));return n>=0&&Math.floor(n)===n&&isFinite(e)}(n))return e.length=Math.max(e.length,n),e.splice(n,1,t),t;if(n in e&&!(n in Object.prototype))return e[n]=t,t;var u=e.__ob__;return e._isVue||u&&u.vmCount?t:u?(i(u.value,n,t),V(e,n,t),u.dep.notify(),t):(e[n]=t,t)},e.toRefs=function(e){if(!l(e))return e;var n={};return Object.keys(e).forEach(function(t){var r=e[t];A(r)||(r=x({get:function(){return e[t]},set:function(n){return e[t]=n}})),n[t]=r}),n},e.watch=function(e,n,t){var r=null;"function"==typeof n?r=n:(t=n,r=null);var o=ve(t);return ge(pe(),e,r,o)},e.watchEffect=function(e,n){var t=ve(n);return ge(pe(),e,null,t)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e=e||self).vueCompositionApi={},e.Vue)}(this,(function(e,t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;function n(e){return"function"==typeof e&&/native code/.test(e.toString())}var r="undefined"!=typeof Symbol&&n(Symbol)&&"undefined"!=typeof Reflect&&n(Reflect.ownKeys),o=function(e){return e},i={enumerable:!0,configurable:!0,get:o,set:o};function u(e,t,n){var r=n.get,u=n.set;i.get=r||o,i.set=u||o,Object.defineProperty(e,t,i)}function f(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}var a=Object.prototype.hasOwnProperty;function c(e,t){return a.call(e,t)}function s(e){return"[object Object]"===function(e){return Object.prototype.toString.call(e)}(e)}function l(e){return"function"==typeof e}function v(e,n){t.util.warn(e,n)}var d=null,p=null;function y(){return d}function b(){return p}function h(e){p=e} | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var g=function(){return(g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function _(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function m(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}function w(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(m(arguments[t]));return e}function O(e){return b()}function j(e,t){void 0===t&&(t={});var n=e.config.silent;e.config.silent=!0;var r=new e(t);return e.config.silent=n,r}function $(e){return d&&e instanceof d}function k(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return e.$scopedSlots[t]?e.$scopedSlots[t].apply(e,n):v("slots."+t+'() got called outside of the "render()" scope',e)}}function S(e){return r?Symbol.for(e):e}var x=S("vfa.key.preFlushQueue"),E=S("vfa.key.postFlushQueue"),R=S("vfa.key.accessControlIdentifier"),A=S("vfa.key.reactiveIdentifier"),C=S("vfa.key.rawIdentifierKey"),P="vfa.key.refKey",M=function(e){u(this,"value",{get:e.get,set:e.set})};function U(e){return Object.seal(new M(e))}function I(e){var t;if(B(e))return e;var n=H(((t={})[P]=e,t));return U({get:function(){return n[P]},set:function(e){return n[P]=e}})}function B(e){return e instanceof M}function V(e,t){var n=e[t];return B(n)?n:U({get:function(){return e[t]},set:function(n){return e[t]=n}})}var z={},D={},F={};function K(e){return c(e,C)&&e[C]===F}function Q(e){return Object.isExtensible(e)&&c(e,A)&&e[A]===D}function T(e){if(!(!s(e)||K(e)||Array.isArray(e)||B(e)||$(e)||c(e,R)&&e[R]===z)){Object.isExtensible(e)&&f(e,R,z);for(var t=Object.keys(e),n=0;n<t.length;n++)q(e,t[n])}}function q(e,t,n){if("__ob__"!==t){var r,o,i=Object.getOwnPropertyDescriptor(e,t);if(i){if(!1===i.configurable)return;r=i.get,o=i.set,r&&!o||2!==arguments.length||(n=e[t])}T(n),Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){var o=r?r.call(e):n;return t!==P&&B(o)?o.value:o},set:function(i){if(!r||o){var u=r?r.call(e):n;t!==P&&B(u)&&!B(i)?u.value=i:o?o.call(e,i):n=i,T(i)}}})}}function J(e){var t,n=y();n.observable?t=n.observable(e):t=j(n,{data:{$$state:e}})._data.$$state;return t}function N(e){var t,n;if(!s(e)||Q(e)||K(e)||!Object.isExtensible(e))return e;var r=J({});G(r,!0),T(r);var o=r.__ob__,i=function(t){var n,i,f=e[t],a=Object.getOwnPropertyDescriptor(e,t);if(a){if(!1===a.configurable)return"continue";n=a.get,i=a.set,n&&!i||2!==u.length||(f=e[t])}Object.defineProperty(r,t,{enumerable:!0,configurable:!0,get:function(){var t=n?n.call(e):f;return o.dep.depend(),t},set:function(t){n&&!i||(i?i.call(e,t):f=t,o.dep.notify())}})},u=arguments;try{for(var f=_(Object.keys(e)),a=f.next();!a.done;a=f.next()){var c=a.value;i(c)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}return r}function G(e,t){if(void 0===t&&(t=!1),!(!s(e)||K(e)||Array.isArray(e)||B(e)||$(e)||c(e,A)&&e[A]===D||(Object.isExtensible(e)&&f(e,A,D),t)))for(var n=Object.keys(e),r=0;r<n.length;r++)G(e[n[r]])}function H(e){if(!s(e)||Q(e)||K(e)||!Object.isExtensible(e))return e;var t=J(e);return G(e),T(t),t}function L(e){return s(e)?(f(e,"__ob__",J({}).__ob__),f(e,C,F),e):e}function W(e,t){d&&d===e||(e.config.optionMergeStrategies.setup=function(e,t){return function(n,o){return function e(t,n){if(!t)return n;for(var o,i,u,f=r?Reflect.ownKeys(t):Object.keys(t),a=0;a<f.length;a++)"__ob__"!==(o=f[a])&&(i=n[o],u=t[o],c(n,o)?i!==u&&s(i)&&!B(i)&&s(u)&&!B(u)&&e(u,i):n[o]=u);return n}("function"==typeof e&&e(n,o)||{},"function"==typeof t&&t(n,o)||{})}},d=e,t(e))}var X,Y={set:function(e,t,n){(e.__secret_vfa_state__=e.__secret_vfa_state__||{})[t]=n},get:function(e,t){return(e.__secret_vfa_state__||{})[t]}};function Z(e){var t=Y.get(e,"rawBindings")||{};if(t&&Object.keys(t).length){for(var n=e.$refs,r=Y.get(e,"refs")||[],o=0;o<r.length;o++){var i=t[a=r[o]];!n[a]&&i&&B(i)&&(i.value=null)}var u=Object.keys(n),f=[];for(o=0;o<u.length;o++){var a;i=t[a=u[o]];n[a]&&i&&B(i)&&(i.value=n[a],f.push(a))}Y.set(e,"refs",f)}}function ee(e,t){var n=e.$options._parentVnode;if(n){for(var r=Y.get(e,"slots")||[],o=function(e,t){var n;if(e){if(e._normalized)return e._normalized;for(var r in n={},e)e[r]&&"$"!==r[0]&&(n[r]=!0)}else n={};for(var r in t)r in n||(n[r]=!0);return n}(n.data.scopedSlots,e.$slots),i=0;i<r.length;i++){o[f=r[i]]||delete t[f]}var u=Object.keys(o);for(i=0;i<u.length;i++){var f;t[f=u[i]]||(t[f]=k(e,f))}Y.set(e,"slots",u)}}function te(e,t,n){var r=b();h(e);try{return t(e)}catch(e){if(!n)throw e;n(e)}finally{h(r)}}function ne(e){e.mixin({beforeCreate:function(){var e=this,t=e.$options,n=t.setup,r=t.render;r&&(t.render=function(){for(var t=this,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return te(e,(function(){return r.apply(t,n)}))});if(!n)return;if("function"!=typeof n)return;var o=t.data;t.data=function(){return function(e,t){void 0===t&&(t={});var n,r=e.$options.setup,o=function(e){var t={slots:{}};return["root","parent","refs","attrs","listeners","isServer","ssrContext"].forEach((function(n){var r,o,i;Array.isArray(n)?(r=m(n,2),o=r[0],i=r[1]):o=i=n,i="$"+i,u(t,o,{get:function(){return e[i]},set:function(){v("Cannot assign to '"+o+"' because it is a read-only property",e)}})})),["emit"].forEach((function(n){var r="$"+n;u(t,n,{get:function(){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var o=e[r];o.apply(e,t)}}})})),t}(e);if(ee(e,o.slots),te(e,(function(){n=r(t,o)})),!n)return;if(l(n)){var i=n;return void(e.$options.render=function(){return ee(e,o.slots),te(e,(function(){return i()}))})}if(s(n)){var f=n;Y.set(e,"rawBindings",n),Object.keys(n).forEach((function(t){var n=f[t];B(n)||(Q(n)?n=I(n):(l(n)&&(n=n.bind(e)),n=I(L(n)))),function(e,t,n){var r=e.$options.props;t in e||r&&c(r,t)||u(e,t,{get:function(){return n.value},set:function(e){n.value=e}})}(e,t,n)}))}}(e,e.$props),"function"==typeof o?o.call(e,e):o||{}}},mounted:function(){Z(this)},updated:function(){Z(this)}})}function re(e){return e}function oe(e){return function(t){var n,r=O(((n=e)[0].toUpperCase(),n.slice(1)));r&&function(e,t,n,r){var o=t.$options,i=e.config.optionMergeStrategies[n];o[n]=i(o[n],function(e,t){return function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=b();h(e);try{return t.apply(void 0,w(n))}finally{h(o)}}}(t,r))}(y(),r,e,t)}}var ie,ue=oe("beforeMount"),fe=oe("mounted"),ae=oe("beforeUpdate"),ce=oe("updated"),se=oe("beforeDestroy"),le=oe("destroyed"),ve=oe("errorCaptured"),de=oe("activated"),pe=oe("deactivated"),ye=oe("serverPrefetch");function be(){_e(this,x)}function he(){_e(this,E)}function ge(){var e=b();return e?function(e){return void 0!==e[x]}(e)||function(e){e[x]=[],e[E]=[],e.$on("hook:beforeUpdate",be),e.$on("hook:updated",he)}(e):(ie||(ie=j(y())),e=ie),e}function _e(e,t){for(var n=e[t],r=0;r<n.length;r++)n[r]();n.length=0}function me(e,t,n){var r=function(){e.$nextTick((function(){e[x].length&&_e(e,x),e[E].length&&_e(e,E)}))};switch(n){case"pre":r(),e[x].push(t);break;case"post":r(),e[E].push(t);break;default:!function(e,t){if(!e)throw new Error("[vue-composition-api] "+t)}(!1,'flush must be one of ["post", "pre", "sync"], but got '+n)}}function we(e,t){var n=e.teardown;e.teardown=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n.apply(e,r),t()}}function Oe(e,t,n,r){var i,u=r.flush,f="sync"===u,a=function(e){i=function(){try{e()}catch(e){!function(e,t,n){if("undefined"==typeof window||"undefined"==typeof console)throw e;console.error(e)}(e)}}},c=function(){i&&(i(),i=null)},s=function(t){return f||e===ie?t:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return me(e,(function(){t.apply(void 0,w(n))}),u)}};if(null===n){var d=function(e,t,n,r){var o=e._watchers.length;return e.$watch(t,n,{immediate:r.immediateInvokeCallback,deep:r.deep,lazy:r.noRun,sync:r.sync,before:r.before}),e._watchers[o]}(e,(function(){return t(a)}),o,{deep:r.deep||!1,sync:f,before:c});we(d,c),d.lazy=!1;var p=d.get.bind(d);return d.get=s(p),function(){d.teardown()}}var y,b=r.deep;Array.isArray(t)?y=function(){return t.map((function(e){return B(e)?e.value:e()}))}:B(t)?y=function(){return t.value}:Q(t)?(y=function(){return t},b=!0):l(t)?y=t:(y=o,v("Invalid watch source: "+JSON.stringify(t)+".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.",e));var h=function(e,t){c(),n(e,t,a)},g=s(h);if(r.immediate){var _=g,m=function(e,t){m=_,h(e,t)};g=function(e,t){m(e,t)}}var O=e.$watch(y,g,{immediate:r.immediate,deep:b,sync:f});return we(e._watchers[e._watchers.length-1],c),function(){O()}}var je={};var $e=function(e){return W(e,ne)},ke={install:$e};d&&"undefined"!=typeof window&&window.Vue&&$e(window.Vue),e.computed=function(e){var t,n,r=b();"function"==typeof e?t=e:(t=e.get,n=e.set);var o=j(y(),{computed:{$$state:{get:t,set:n}}});return r&&r.$on("hook:destroyed",(function(){return o.$destroy()})),U({get:function(){return o.$$state},set:function(e){o.$$state=e}})},e.createComponent=function(e){return e},e.createElement=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return p?p.$createElement.apply(p,e):(v("`createElement()` has been called outside of render function."),X||(X=j(y()).$createElement),X.apply(X,e))},e.default=ke,e.defineComponent=re,e.getCurrentInstance=b,e.inject=function(e,t){if(!e)return t;var n=b();if(n){var r=function(e,t){for(var n=t;n;){if(n._provided&&c(n._provided,e))return n._provided[e];n=n.$parent}return je}(e,n);return r!==je?r:t}v("inject() can only be used inside setup() or functional components.")},e.isReactive=Q,e.isRef=B,e.markRaw=L,e.onActivated=de,e.onBeforeMount=ue,e.onBeforeUnmount=se,e.onBeforeUpdate=ae,e.onDeactivated=pe,e.onErrorCaptured=ve,e.onMounted=fe,e.onServerPrefetch=ye,e.onUnmounted=le,e.onUpdated=ce,e.provide=function(e,t){var n=O();if(n){if(!n._provided){var r={};Object.defineProperty(n,"_provided",{get:function(){return r},set:function(e){return Object.assign(r,e)}})}n._provided[e]=t}},e.reactive=H,e.ref=I,e.set=function(e,t,n){var r,o=y().util,i=(o.warn,o.defineReactive);if(r=e,Array.isArray(r)&&function(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}(t))return e.length=Math.max(e.length,t),e.splice(t,1,n),n;if(t in e&&!(t in Object.prototype))return e[t]=n,n;var u=e.__ob__;return e._isVue||u&&u.vmCount?n:u?(i(u.value,t,n),q(e,t,n),G(u.value[t]),u.dep.notify(),n):(e[t]=n,n)},e.shallowReactive=N,e.shallowRef=function(e){var t;if(B(e))return e;var n=N(((t={})[P]=e,t));return U({get:function(){return n[P]},set:function(e){return n[P]=e}})},e.toRaw=function(e){return K(J)||!Object.isExtensible(e)?e:e.__ob__.value||e},e.toRef=V,e.toRefs=function(e){if(!s(e))return e;var t={};for(var n in e)t[n]=V(e,n);return t},e.triggerRef=function(e){B(e)&&(e.value=e.value)},e.unref=function(e){return B(e)?e.value:e},e.watch=function(e,t,n){var r=null;"function"==typeof t?r=t:(n=t,r=null);var o=function(e){return g({immediate:!1,deep:!1,flush:"post"},e)}(n);return Oe(ge(),e,r,o)},e.watchEffect=function(e,t){var n=function(e){return g({immediate:!0,deep:!1,flush:"post"},e)}(t);return Oe(ge(),e,null,n)},Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@vue/composition-api", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Provide logic composition capabilities for Vue.", | ||
@@ -38,19 +38,19 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^24.0.13", | ||
"@types/node": "^12.0.2", | ||
"cross-env": "^5.2.0", | ||
"husky": "^2.7.0", | ||
"jest": "^24.8.0", | ||
"lint-staged": "^8.2.1", | ||
"prettier": "^1.18.2", | ||
"rollup": "^1.12.0", | ||
"rollup-plugin-node-resolve": "^5.0.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^4.0.4", | ||
"rollup-plugin-typescript2": "^0.21.0", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.6.2", | ||
"vue": "^2.5.22", | ||
"vue-router": "^3.1.3", | ||
"vue-server-renderer": "^2.6.10" | ||
"@rollup/plugin-node-resolve": "8.0.0", | ||
"@rollup/plugin-replace": "^2.3.2", | ||
"@types/jest": "^25.2.3", | ||
"@types/node": "^14.0.6", | ||
"cross-env": "^7.0.2", | ||
"husky": "^4.2.5", | ||
"jest": "^26.0.1", | ||
"lint-staged": "^10.2.7", | ||
"prettier": "^2.0.5", | ||
"rollup": "^2.12.0", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"ts-jest": "^26.1.0", | ||
"typescript": "^3.9.3", | ||
"vue": "^2.6.11", | ||
"vue-router": "^3.3.2", | ||
"vue-server-renderer": "^2.6.11" | ||
}, | ||
@@ -61,3 +61,3 @@ "peerDependencies": { | ||
"dependencies": { | ||
"tslib": "^1.9.3" | ||
"tslib": "^2.0.0" | ||
}, | ||
@@ -81,2 +81,5 @@ "husky": { | ||
"verbose": true, | ||
"globals": { | ||
"__DEV__": true | ||
}, | ||
"setupFiles": [ | ||
@@ -83,0 +86,0 @@ "<rootDir>/test/setupTest.js" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
192969
4271
0
+ Addedtslib@2.8.1(transitive)
- Removedtslib@1.14.1(transitive)
Updatedtslib@^2.0.0