@vue/composition-api
Advanced tools
Comparing version 0.3.4 to 0.4.0
@@ -19,4 +19,4 @@ import Vue, { VueConstructor, VNode, ComponentOptions as Vue2ComponentOptions } from 'vue'; | ||
} & P & S; | ||
declare type VueConstructorProxy<PropsOptions, RawBindings> = { | ||
new (): ComponentRenderProxy<ExtractPropTypes<PropsOptions>, UnwrapRef<RawBindings>, ExtractPropTypes<PropsOptions, false>>; | ||
declare type VueConstructorProxy<PropsOptions, RawBindings> = VueConstructor & { | ||
new (...args: any[]): ComponentRenderProxy<ExtractPropTypes<PropsOptions>, UnwrapRef<RawBindings>, ExtractPropTypes<PropsOptions, false>>; | ||
}; | ||
@@ -41,8 +41,10 @@ declare type VueProxy<PropsOptions, RawBindings> = Vue2ComponentOptions<Vue, UnwrapRef<RawBindings>, never, never, PropsOptions, ExtractPropTypes<PropsOptions, false>> & VueConstructorProxy<PropsOptions, RawBindings>; | ||
} | ||
interface ComponentOptionsWithoutProps<Props = never, RawBindings = Data> { | ||
interface ComponentOptionsWithoutProps<Props = unknown, RawBindings = Data> { | ||
props?: undefined; | ||
setup?: SetupFunction<Props, RawBindings>; | ||
} | ||
export declare function createComponent<RawBindings>(options: ComponentOptionsWithoutProps<never, RawBindings>): VueProxy<never, RawBindings>; | ||
export declare function defineComponent<RawBindings>(options: ComponentOptionsWithoutProps<unknown, RawBindings>): VueProxy<unknown, RawBindings>; | ||
export declare function defineComponent<Props, RawBindings = Data, PropsOptions extends ComponentPropsOptions = ComponentPropsOptions>(options: (HasDefined<Props> extends true ? ComponentOptionsWithProps<PropsOptions, RawBindings, Props> : ComponentOptionsWithProps<PropsOptions, RawBindings>) & Omit<Vue2ComponentOptions<Vue>, keyof ComponentOptionsWithProps<never, never>>): VueProxy<PropsOptions, RawBindings>; | ||
export declare function createComponent<RawBindings>(options: ComponentOptionsWithoutProps<unknown, RawBindings>): VueProxy<unknown, RawBindings>; | ||
export declare function createComponent<Props, RawBindings = Data, PropsOptions extends ComponentPropsOptions = ComponentPropsOptions>(options: (HasDefined<Props> extends true ? ComponentOptionsWithProps<PropsOptions, RawBindings, Props> : ComponentOptionsWithProps<PropsOptions, RawBindings>) & Omit<Vue2ComponentOptions<Vue>, keyof ComponentOptionsWithProps<never, never>>): VueProxy<PropsOptions, RawBindings>; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
export { Data, createComponent, SetupFunction, SetupContext, ComponentInstance, ComponentRenderProxy, } from './component'; | ||
export { Data, createComponent, defineComponent, SetupFunction, SetupContext, ComponentInstance, ComponentRenderProxy, } from './component'; | ||
export { PropType, PropOptions } from './componentProps'; |
import Vue, { VNode, ComponentOptions, VueConstructor } from 'vue'; | ||
import { ComponentInstance } from './component'; | ||
export declare function ensureCurrentVMInFn(hook: string): ComponentInstance; | ||
export declare function createComponentInstance<V extends Vue = Vue>(Ctor: VueConstructor<V>, options?: ComponentOptions<V>): import("vue/types/vue").CombinedVueInstance<V, object, object, object, Record<never, any>>; | ||
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>>; | ||
export declare function isComponentInstance(obj: any): boolean | null; | ||
@@ -6,0 +6,0 @@ export declare function createSlotProxy(vm: ComponentInstance, slotName: string): (...args: any) => void | VNode[]; |
@@ -14,3 +14,3 @@ import Vue, { VueConstructor } from 'vue'; | ||
export { SetupContext }; | ||
export { createComponent, ComponentRenderProxy, PropType, PropOptions } from './component'; | ||
export { createComponent, defineComponent, ComponentRenderProxy, PropType, PropOptions, } from './component'; | ||
export { getCurrentVM as getCurrentInstance } from './runtimeContext'; | ||
@@ -17,0 +17,0 @@ export * from './apis/state'; |
import Vue from 'vue'; | ||
export declare const hasSymbol: false | ((key: string) => symbol); | ||
export declare function isNative(Ctor: any): boolean; | ||
export declare const hasSymbol: boolean; | ||
export declare const noopFn: any; | ||
@@ -4,0 +5,0 @@ export declare function proxy(target: any, key: string, { get, set }: { |
@@ -10,3 +10,7 @@ 'use strict'; | ||
var toString = function (x) { return Object.prototype.toString.call(x); }; | ||
var hasSymbol = typeof Symbol === 'function' && Symbol.for; | ||
function isNative(Ctor) { | ||
return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); | ||
} | ||
var hasSymbol = typeof Symbol !== 'undefined' && isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); | ||
var noopFn = function (_) { return _; }; | ||
@@ -90,3 +94,3 @@ var sharedPropertyDefinition = { | ||
} | ||
function createComponentInstance(Ctor, options) { | ||
function defineComponentInstance(Ctor, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -294,3 +298,3 @@ var silent = Ctor.config.silent; | ||
else { | ||
var vm = createComponentInstance(Vue, { | ||
var vm = defineComponentInstance(Vue, { | ||
data: { | ||
@@ -741,3 +745,3 @@ $$state: obj, | ||
if (!fallbackCreateElement) { | ||
fallbackCreateElement = createComponentInstance(getCurrentVue()).$createElement; | ||
fallbackCreateElement = defineComponentInstance(getCurrentVue()).$createElement; | ||
} | ||
@@ -750,5 +754,12 @@ return fallbackCreateElement.apply(fallbackCreateElement, args); | ||
// implementation, close to no-op | ||
function createComponent(options) { | ||
function defineComponent(options) { | ||
return options; | ||
} | ||
// implementation, deferring to defineComponent, but logging a warning in dev mode | ||
function createComponent(options) { | ||
{ | ||
Vue.util.warn('`createComponent` has been renamed to `defineComponent`.'); | ||
} | ||
return defineComponent(options); | ||
} | ||
@@ -762,11 +773,2 @@ var genName = function (name) { return "on" + (name[0].toUpperCase() + name.slice(1)); }; | ||
} | ||
function createLifeCycles(lifeCyclehooks, name) { | ||
return function (callback) { | ||
var currentVue = getCurrentVue(); | ||
var vm = ensureCurrentVMInFn(name); | ||
lifeCyclehooks.forEach(function (lifeCyclehook) { | ||
return injectHookOption(currentVue, vm, lifeCyclehook, callback); | ||
}); | ||
}; | ||
} | ||
function injectHookOption(Vue, vm, hook, val) { | ||
@@ -783,4 +785,3 @@ var options = vm.$options; | ||
var onBeforeUnmount = createLifeCycle('beforeDestroy'); | ||
// only one event will be fired between destroyed and deactivated when an unmount occurs | ||
var onUnmounted = createLifeCycles(['destroyed', 'deactivated'], genName('unmounted')); | ||
var onUnmounted = createLifeCycle('destroyed'); | ||
var onErrorCaptured = createLifeCycle('errorCaptured'); | ||
@@ -969,3 +970,3 @@ var onActivated = createLifeCycle('activated'); | ||
if (!fallbackVM) { | ||
fallbackVM = createComponentInstance(getCurrentVue()); | ||
fallbackVM = defineComponentInstance(getCurrentVue()); | ||
} | ||
@@ -991,3 +992,3 @@ vm = fallbackVM; | ||
} | ||
var computedHost = createComponentInstance(getCurrentVue(), { | ||
var computedHost = defineComponentInstance(getCurrentVue(), { | ||
computed: { | ||
@@ -1067,2 +1068,3 @@ $$state: { | ||
exports.default = plugin; | ||
exports.defineComponent = defineComponent; | ||
exports.getCurrentInstance = getCurrentVM; | ||
@@ -1069,0 +1071,0 @@ exports.inject = inject; |
@@ -1,1 +0,1 @@ | ||
"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)},hasSymbol="function"==typeof Symbol&&Symbol.for,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 createComponentInstance(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,a=Object.getOwnPropertyDescriptor(e,t);if(a){if(!1===a.configurable)return;r=a.get,o=a.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(a){if(!r||o){var i=r?r.call(e):n;t!==RefKey&&isRef(i)&&!isRef(a)?i.value=a:o?o.call(e,a):n=a,setupAccessControl(a)}}})}}function observe(e){var t,n=getCurrentVue();n.observable?t=n.observable(e):t=createComponentInstance(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 a=e.__ob__;return e._isVue||a&&a.vmCount?n:a?(o(a.value,t,n),defineAccessControl(e,t,n),a.dep.notify(),n):(e[t]=n,n)}function mergeData(e,t){if(!t)return e;for(var n,r,o,a=hasSymbol?Reflect.ownKeys(t):Object.keys(t),i=0;i<a.length;i++)"__ob__"!==(n=a[i])&&(r=e[n],o=t[n],hasOwn(e,n)?r!==o&&isPlainObject(r)&&!isRef(r)&&isPlainObject(o)&&!isRef(o)&&mergeData(r,o):e[n]=o);return e}function install(e,t){currentVue&¤tVue===e||(e.config.optionMergeStrategies.setup=function(e,t){return function(n,r){return mergeData("function"==typeof t&&t(n,r)||{},"function"==typeof e&&e(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,a=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=a.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return i}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 a=t[c=r[o]];!n[c]&&a&&isRef(a)&&(a.value=null)}var i=Object.keys(n),u=[];for(o=0;o<i.length;o++){var c;a=t[c=i[o]];n[c]&&a&&isRef(a)&&(a.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),a=0;a<r.length;a++){o[u=r[a]]||delete t[u]}var i=Object.keys(o);for(a=0;a<i.length;a++){var u;t[u=i[a]]||(t[u]=createSlotProxy(e,u))}vmStateManager.set(e,"slots",i)}}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,a;Array.isArray(n)?(r=__read(n,2),o=r[0],a=r[1]):o=a=n,a="$"+a,proxy(t,o,{get:function(){return e[a]},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 a=n;return void(e.$options.render=function(){return resolveScopedSlots(e,o.slots),activateCurrentInstance(e,function(){return a()})})}if(isPlainObject(n)){var i=n;vmStateManager.set(e,"rawBindings",n),Object.keys(n).forEach(function(t){var n=i[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=createComponentInstance(getCurrentVue()).$createElement),fallbackCreateElement.apply(fallbackCreateElement,e))};function createComponent(e){return 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 createLifeCycles(e,t){return function(n){var r=getCurrentVue(),o=ensureCurrentVMInFn(t);e.forEach(function(e){return injectHookOption(r,o,e,n)})}}function injectHookOption(e,t,n,r){var o=t.$options,a=e.config.optionMergeStrategies[n];o[n]=a(o[n],r)}var fallbackVM,onBeforeMount=createLifeCycle("beforeMount"),onMounted=createLifeCycle("mounted"),onBeforeUpdate=createLifeCycle("beforeUpdate"),onUpdated=createLifeCycle("updated"),onBeforeUnmount=createLifeCycle("beforeDestroy"),onUnmounted=createLifeCycles(["destroyed","deactivated"],genName("unmounted")),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 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,a,i=r.flush,u="sync"===i,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))},i)}};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()}}a=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(a,d,{immediate:!r.lazy,deep:r.deep,sync:u});return function(){g(),f()}}function watch(e,t,n){var r=null;"function"==typeof t?r=t:(n=t,r=null);var o=__assign({lazy:!1,deep:!1,flush:"post"},n),a=getCurrentVM();return a?hasWatchEnv(a)||installWatchEnv(a):(fallbackVM||(fallbackVM=createComponentInstance(getCurrentVue())),a=fallbackVM),createWatcher(a,e,r,o)}function computed(e){var t,n;"function"==typeof e?t=e:(t=e.get,n=e.set);var r=createComponentInstance(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.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; | ||
"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(!t)return e;for(var n,r,o,i=hasSymbol?Reflect.ownKeys(t):Object.keys(t),a=0;a<i.length;a++)"__ob__"!==(n=i[a])&&(r=e[n],o=t[n],hasOwn(e,n)?r!==o&&isPlainObject(r)&&!isRef(r)&&isPlainObject(o)&&!isRef(o)&&mergeData(r,o):e[n]=o);return e}function install(e,t){currentVue&¤tVue===e||(e.config.optionMergeStrategies.setup=function(e,t){return function(n,r){return mergeData("function"==typeof t&&t(n,r)||{},"function"==typeof e&&e(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 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 watch(e,t,n){var r=null;"function"==typeof t?r=t:(n=t,r=null);var o=__assign({lazy:!1,deep:!1,flush:"post"},n),i=getCurrentVM();return i?hasWatchEnv(i)||installWatchEnv(i):(fallbackVM||(fallbackVM=defineComponentInstance(getCurrentVue())),i=fallbackVM),createWatcher(i,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; |
import Vue from 'vue'; | ||
var toString = function (x) { return Object.prototype.toString.call(x); }; | ||
var hasSymbol = typeof Symbol === 'function' && Symbol.for; | ||
function isNative(Ctor) { | ||
return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); | ||
} | ||
var hasSymbol = typeof Symbol !== 'undefined' && isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); | ||
var noopFn = function (_) { return _; }; | ||
@@ -83,3 +87,3 @@ var sharedPropertyDefinition = { | ||
} | ||
function createComponentInstance(Ctor, options) { | ||
function defineComponentInstance(Ctor, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -287,3 +291,3 @@ var silent = Ctor.config.silent; | ||
else { | ||
var vm = createComponentInstance(Vue, { | ||
var vm = defineComponentInstance(Vue, { | ||
data: { | ||
@@ -734,3 +738,3 @@ $$state: obj, | ||
if (!fallbackCreateElement) { | ||
fallbackCreateElement = createComponentInstance(getCurrentVue()).$createElement; | ||
fallbackCreateElement = defineComponentInstance(getCurrentVue()).$createElement; | ||
} | ||
@@ -743,5 +747,12 @@ return fallbackCreateElement.apply(fallbackCreateElement, args); | ||
// implementation, close to no-op | ||
function createComponent(options) { | ||
function defineComponent(options) { | ||
return options; | ||
} | ||
// implementation, deferring to defineComponent, but logging a warning in dev mode | ||
function createComponent(options) { | ||
{ | ||
Vue.util.warn('`createComponent` has been renamed to `defineComponent`.'); | ||
} | ||
return defineComponent(options); | ||
} | ||
@@ -755,11 +766,2 @@ var genName = function (name) { return "on" + (name[0].toUpperCase() + name.slice(1)); }; | ||
} | ||
function createLifeCycles(lifeCyclehooks, name) { | ||
return function (callback) { | ||
var currentVue = getCurrentVue(); | ||
var vm = ensureCurrentVMInFn(name); | ||
lifeCyclehooks.forEach(function (lifeCyclehook) { | ||
return injectHookOption(currentVue, vm, lifeCyclehook, callback); | ||
}); | ||
}; | ||
} | ||
function injectHookOption(Vue, vm, hook, val) { | ||
@@ -776,4 +778,3 @@ var options = vm.$options; | ||
var onBeforeUnmount = createLifeCycle('beforeDestroy'); | ||
// only one event will be fired between destroyed and deactivated when an unmount occurs | ||
var onUnmounted = createLifeCycles(['destroyed', 'deactivated'], genName('unmounted')); | ||
var onUnmounted = createLifeCycle('destroyed'); | ||
var onErrorCaptured = createLifeCycle('errorCaptured'); | ||
@@ -962,3 +963,3 @@ var onActivated = createLifeCycle('activated'); | ||
if (!fallbackVM) { | ||
fallbackVM = createComponentInstance(getCurrentVue()); | ||
fallbackVM = defineComponentInstance(getCurrentVue()); | ||
} | ||
@@ -984,3 +985,3 @@ vm = fallbackVM; | ||
} | ||
var computedHost = createComponentInstance(getCurrentVue(), { | ||
var computedHost = defineComponentInstance(getCurrentVue(), { | ||
computed: { | ||
@@ -1057,2 +1058,2 @@ $$state: { | ||
export default plugin; | ||
export { computed, createComponent, createElement, getCurrentVM as getCurrentInstance, inject, isRef, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onServerPrefetch, onUnmounted, onUpdated, provide, reactive, ref, set, toRefs, watch }; | ||
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 }; |
@@ -10,3 +10,7 @@ (function (global, factory) { | ||
var toString = function (x) { return Object.prototype.toString.call(x); }; | ||
var hasSymbol = typeof Symbol === 'function' && Symbol.for; | ||
function isNative(Ctor) { | ||
return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); | ||
} | ||
var hasSymbol = typeof Symbol !== 'undefined' && isNative(Symbol) && | ||
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); | ||
var noopFn = function (_) { return _; }; | ||
@@ -90,3 +94,3 @@ var sharedPropertyDefinition = { | ||
} | ||
function createComponentInstance(Ctor, options) { | ||
function defineComponentInstance(Ctor, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -294,3 +298,3 @@ var silent = Ctor.config.silent; | ||
else { | ||
var vm = createComponentInstance(Vue, { | ||
var vm = defineComponentInstance(Vue, { | ||
data: { | ||
@@ -741,3 +745,3 @@ $$state: obj, | ||
if (!fallbackCreateElement) { | ||
fallbackCreateElement = createComponentInstance(getCurrentVue()).$createElement; | ||
fallbackCreateElement = defineComponentInstance(getCurrentVue()).$createElement; | ||
} | ||
@@ -750,5 +754,12 @@ return fallbackCreateElement.apply(fallbackCreateElement, args); | ||
// implementation, close to no-op | ||
function createComponent(options) { | ||
function defineComponent(options) { | ||
return options; | ||
} | ||
// implementation, deferring to defineComponent, but logging a warning in dev mode | ||
function createComponent(options) { | ||
{ | ||
Vue.util.warn('`createComponent` has been renamed to `defineComponent`.'); | ||
} | ||
return defineComponent(options); | ||
} | ||
@@ -762,11 +773,2 @@ var genName = function (name) { return "on" + (name[0].toUpperCase() + name.slice(1)); }; | ||
} | ||
function createLifeCycles(lifeCyclehooks, name) { | ||
return function (callback) { | ||
var currentVue = getCurrentVue(); | ||
var vm = ensureCurrentVMInFn(name); | ||
lifeCyclehooks.forEach(function (lifeCyclehook) { | ||
return injectHookOption(currentVue, vm, lifeCyclehook, callback); | ||
}); | ||
}; | ||
} | ||
function injectHookOption(Vue, vm, hook, val) { | ||
@@ -783,4 +785,3 @@ var options = vm.$options; | ||
var onBeforeUnmount = createLifeCycle('beforeDestroy'); | ||
// only one event will be fired between destroyed and deactivated when an unmount occurs | ||
var onUnmounted = createLifeCycles(['destroyed', 'deactivated'], genName('unmounted')); | ||
var onUnmounted = createLifeCycle('destroyed'); | ||
var onErrorCaptured = createLifeCycle('errorCaptured'); | ||
@@ -969,3 +970,3 @@ var onActivated = createLifeCycle('activated'); | ||
if (!fallbackVM) { | ||
fallbackVM = createComponentInstance(getCurrentVue()); | ||
fallbackVM = defineComponentInstance(getCurrentVue()); | ||
} | ||
@@ -991,3 +992,3 @@ vm = fallbackVM; | ||
} | ||
var computedHost = createComponentInstance(getCurrentVue(), { | ||
var computedHost = defineComponentInstance(getCurrentVue(), { | ||
computed: { | ||
@@ -1067,2 +1068,3 @@ $$state: { | ||
exports.default = plugin; | ||
exports.defineComponent = defineComponent; | ||
exports.getCurrentInstance = getCurrentVM; | ||
@@ -1069,0 +1071,0 @@ exports.inject = inject; |
@@ -1,1 +0,1 @@ | ||
!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&&t.hasOwnProperty("default")?t.default:t;var n=function(e){return Object.prototype.toString.call(e)},r="function"==typeof Symbol&&Symbol.for,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]"===n(e)}function l(e,n){t.util.warn(e,n)}var v=null,p=null;function d(){return v}function y(){return p}function g(e){p=e}function h(e){return y()}function b(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,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):l("slots."+t+'() got called outside of the "render()" scope',e)}}function m(e){return r?Symbol.for(e):e}var $=m("vfa.key.preFlushQueue"),w=m("vfa.key.postFlushQueue"),O=m("vfa.key.accessControlIdentifier"),j=m("vfa.key.reactiveIdentifier"),k=m("vfa.key.nonReactiveIdentifier"),S="vfa.key.refKey",E=function(){return function(e){u(this,"value",{get:e.get,set:e.set})}}();function C(e){return Object.seal(new E(e))}function x(e){var t,n=F(((t={})[S]=e,t));return C({get:function(){return n[S]},set:function(e){return n[S]=e}})}function P(e){return e instanceof E}var A={},M={},z={};function R(e){return c(e,k)&&e[k]===z}function U(e){return c(e,j)&&e[j]===M}function B(e){var t;if(!(!s(e)||R(e)||Array.isArray(e)||P(e)||(t=e,v&&t instanceof v))&&(!c(e,O)||e[O]!==A)){Object.isExtensible(e)&&f(e,O,A);for(var n=Object.keys(e),r=0;r<n.length;r++)I(e,n[r])}}function I(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])}B(n),Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){var o=r?r.call(e):n;return t!==S&&P(o)?o.value:o},set:function(i){if(!r||o){var u=r?r.call(e):n;t!==S&&P(u)&&!P(i)?u.value=i:o?o.call(e,i):n=i,B(i)}}})}}function V(e){var t,n=d();n.observable?t=n.observable(e):t=b(n,{data:{$$state:e}})._data.$$state;return t}function F(e){if(!s(e)||U(e)||R(e)||!Object.isExtensible(e))return e;var t=V(e);return f(t,j,M),B(t),t}function D(e,t){v&&v===e||(e.config.optionMergeStrategies.setup=function(e,t){return function(n,o){return function e(t,n){if(!n)return t;for(var o,i,u,f=r?Reflect.ownKeys(n):Object.keys(n),a=0;a<f.length;a++)"__ob__"!==(o=f[a])&&(i=t[o],u=n[o],c(t,o)?i!==u&&s(i)&&!P(i)&&s(u)&&!P(u)&&e(i,u):t[o]=u);return t}("function"==typeof t&&t(n,o)||{},"function"==typeof e&&e(n,o)||{})}},v=e,t(e))}var K=function(){return(K=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 Q(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}var T,q={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 G(e){var t=q.get(e,"rawBindings")||{};if(t&&Object.keys(t).length){for(var n=e.$refs,r=q.get(e,"refs")||[],o=0;o<r.length;o++){var i=t[a=r[o]];!n[a]&&i&&P(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&&P(i)&&(i.value=n[a],f.push(a))}q.set(e,"refs",f)}}function H(e,t){var n=e.$options._parentVnode;if(n){for(var r=q.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))}q.set(e,"slots",u)}}function J(e,t,n){var r=y();g(e);try{return t(e)}catch(e){if(!n)throw e;n(e)}finally{g(r)}}function L(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 J(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=Q(n,2),o=r[0],i=r[1]):o=i=n,i="$"+i,u(t,o,{get:function(){return e[i]},set:function(){l("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];e[r].apply(e,t)}}})}),t}(e);if(H(e,o.slots),J(e,function(){n=r(t,o)}),!n)return;if(a=n,"function"==typeof a){var i=n;return void(e.$options.render=function(){return H(e,o.slots),J(e,function(){return i()})})}var a;if(s(n)){var v=n;q.set(e,"rawBindings",n),Object.keys(n).forEach(function(t){var n,r=v[t];P(r)||(r=U(r)?x(r):x(s(n=r)?(f(n,"__ob__",V({}).__ob__),f(n,k,z),n):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,r)})}}(e,e.$props),"function"==typeof o?o.call(e,e):o||{}}},mounted:function(){G(this)},updated:function(){G(this)}})}var N=function(e){return"on"+(e[0].toUpperCase()+e.slice(1))};function W(e){return function(t){var n=h(N(e));X(d(),n,e,t)}}function X(e,t,n,r){var o=t.$options,i=e.config.optionMergeStrategies[n];o[n]=i(o[n],r)}var Y,Z,ee=W("beforeMount"),te=W("mounted"),ne=W("beforeUpdate"),re=W("updated"),oe=W("beforeDestroy"),ie=(Y=["destroyed","deactivated"],N("unmounted"),function(e){var t=d(),n=h();Y.forEach(function(r){return X(t,n,r,e)})}),ue=W("errorCaptured"),fe=W("activated"),ae=W("deactivated"),ce=W("serverPrefetch");function se(){ve(this,$)}function le(){ve(this,w)}function ve(e,t){for(var n=e[t],r=0;r<n.length;r++)n[r]();n.length=0}function pe(e,t,n){var r=function(){e.$nextTick(function(){e[$].length&&ve(e,$),e[w].length&&ve(e,w)})};switch(n){case"pre":r(),e[$].push(t);break;case"post":r(),e[w].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 de(e,t,n,r){var i,u,f=r.flush,a="sync"===f,c=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)}}},s=function(){i&&(i(),i=null)},l=function(t){return a||e===Z?t:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return pe(e,function(){t.apply(void 0,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Q(arguments[t]));return e}(n))},f)}};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(c)},o,{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(t)?function(){return t.map(function(e){return P(e)?e.value:e()})}:P(t)?function(){return t.value}:t;var d=function(e,t){s(),n(e,t,c)},y=l(d);if(!r.lazy){var g=y,h=function(e,t){h=g,d(e,t)};y=function(e,t){h(e,t)}}var b=e.$watch(u,y,{immediate:!r.lazy,deep:r.deep,sync:a});return function(){b(),s()}}var ye={};var ge=function(e){return D(e,L)},he={install:ge};v&&"undefined"!=typeof window&&window.Vue&&ge(window.Vue),e.computed=function(e){var t,n;"function"==typeof e?t=e:(t=e.get,n=e.set);var r=b(d(),{computed:{$$state:{get:t,set:n}}});return C({get:function(){return r.$$state},set:function(e){r.$$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):(l("`createElement()` has been called outside of render function."),T||(T=b(d()).$createElement),T.apply(T,e))},e.default=he,e.getCurrentInstance=y,e.inject=function(e,t){if(!e)return t;var n=function(e,t){for(var n=t;n;){if(n._provided&&c(n._provided,e))return n._provided[e];n=n.$parent}return ye}(e,h());return n!==ye?n:void 0!==t?t:void 0},e.isRef=P,e.onActivated=fe,e.onBeforeMount=ee,e.onBeforeUnmount=oe,e.onBeforeUpdate=ne,e.onDeactivated=ae,e.onErrorCaptured=ue,e.onMounted=te,e.onServerPrefetch=ce,e.onUnmounted=ie,e.onUpdated=re,e.provide=function(e,t){var n=h();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=F,e.ref=x,e.set=function(e,t,n){var r,o=d().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),I(e,t,n),u.dep.notify(),n):(e[t]=n,n)},e.toRefs=function(e){if(!s(e))return e;var t={};return Object.keys(e).forEach(function(n){var r=e[n];P(r)||(r=C({get:function(){return e[n]},set:function(t){return e[n]=t}})),t[n]=r}),t},e.watch=function(e,t,n){var r=null;"function"==typeof t?r=t:(n=t,r=null);var o=K({lazy:!1,deep:!1,flush:"post"},n),i=y();return i?function(e){return void 0!==e[$]}(i)||function(e){e[$]=[],e[w]=[],e.$on("hook:beforeUpdate",se),e.$on("hook:updated",le)}(i):(Z||(Z=b(d())),i=Z),de(i,e,r,o)},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!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(!t)return n;for(var r,i,u,f=o?Reflect.ownKeys(t):Object.keys(t),a=0;a<f.length;a++)"__ob__"!==(r=f[a])&&(i=n[r],u=t[r],s(n,r)?i!==u&&l(i)&&!A(i)&&l(u)&&!A(u)&&e(i,u):n[r]=u);return n}("function"==typeof n&&n(t,r)||{},"function"==typeof e&&e(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(){ve(this,$)}function le(){ve(this,O)}function ve(e,n){for(var t=e[n],r=0;r<t.length;r++)t[r]();t.length=0}function pe(e,n,t){var r=function(){e.$nextTick(function(){e[$].length&&ve(e,$),e[O].length&&ve(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 de(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 pe(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 ye={};var ge=function(e){return K(e,N)},he={install:ge};p&&"undefined"!=typeof window&&window.Vue&&ge(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=he,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 ye}(e,b());return t!==ye?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=Q({lazy:!1,deep:!1,flush:"post"},t),i=g();return i?function(e){return void 0!==e[$]}(i)||function(e){e[$]=[],e[O]=[],e.$on("hook:beforeUpdate",se),e.$on("hook:updated",le)}(i):(Z||(Z=_(y())),i=Z),de(i,e,r,o)},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@vue/composition-api", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "Provide logic composition capabilities for Vue.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -60,8 +60,8 @@ # Vue Composition API | ||
To let TypeScript properly infer types inside Vue component options, you need to define components with `createComponent`: | ||
To let TypeScript properly infer types inside Vue component options, you need to define components with `defineComponent`: | ||
```ts | ||
import { createComponent } from '@vue/composition-api'; | ||
import { defineComponent } from '@vue/composition-api'; | ||
const Component = createComponent({ | ||
const Component = defineComponent({ | ||
// type inference enabled | ||
@@ -68,0 +68,0 @@ }); |
@@ -60,8 +60,8 @@ # Vue Composition API | ||
为了让 TypeScript 正确的推导类型,我们必须使用 `createComponent` 来定义组件: | ||
为了让 TypeScript 正确的推导类型,我们必须使用 `defineComponent` 来定义组件: | ||
```ts | ||
import { createComponent } from '@vue/composition-api'; | ||
import { defineComponent } from '@vue/composition-api'; | ||
const Component = createComponent({ | ||
const Component = defineComponent({ | ||
// 启用类型推断 | ||
@@ -68,0 +68,0 @@ }); |
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
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
163316
3531
1