From 344aa703b4b5bae9ee756d1091aebfa10c96d05e Mon Sep 17 00:00:00 2001 From: Vinicius Rangel Date: Tue, 6 Oct 2020 16:20:47 -0300 Subject: [PATCH] Added Vue as external dependency --- index.es.js | 3424 +---------------------------------- index.js | 4445 ++++++---------------------------------------- rollup.config.js | 3 +- 3 files changed, 552 insertions(+), 7320 deletions(-) diff --git a/index.es.js b/index.es.js index 18813c32..d3ba0b85 100644 --- a/index.es.js +++ b/index.es.js @@ -1,3391 +1,7 @@ +import { h, defineComponent } from 'vue'; import { parse, icon, config, text } from '@fortawesome/fontawesome-svg-core'; -/** - * Make a map and return a function for checking if a key - * is in that map. - * IMPORTANT: all calls of this function must be prefixed with - * \/\*#\_\_PURE\_\_\*\/ - * So that rollup can tree-shake them if necessary. - */ -function makeMap(str, expectsLowerCase) { - const map = Object.create(null); - const list = str.split(','); - for (let i = 0; i < list.length; i++) { - map[list[i]] = true; - } - return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; -} - -const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' + - 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' + - 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl'; -const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED); - -/** - * On the client we only need to offer special cases for boolean attributes that - * have different names from their corresponding dom properties: - * - itemscope -> N/A - * - allowfullscreen -> allowFullscreen - * - formnovalidate -> formNoValidate - * - ismap -> isMap - * - nomodule -> noModule - * - novalidate -> noValidate - * - readonly -> readOnly - */ -const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; -const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs); -/** - * The full list is needed during SSR to produce the correct initial markup. - */ -const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs + - `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` + - `loop,open,required,reversed,scoped,seamless,` + - `checked,muted,multiple,selected`); -/** - * CSS properties that accept plain numbers - */ -const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` + - `border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` + - `columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` + - `grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` + - `grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` + - `line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` + - // SVG - `fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` + - `stroke-miterlimit,stroke-opacity,stroke-width`); -/** - * Known attributes, this is used for stringification of runtime static nodes - * so that we don't stringify bindings that cannot be set from HTML. - * Don't also forget to allow `data-*` and `aria-*`! - * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes - */ -const isKnownAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` + - `autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` + - `border,buffered,capture,challenge,charset,checked,cite,class,code,` + - `codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` + - `coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` + - `disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` + - `formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` + - `height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` + - `ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` + - `manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` + - `open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` + - `referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` + - `selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` + - `start,step,style,summary,tabindex,target,title,translate,type,usemap,` + - `value,width,wrap`); - -function normalizeStyle(value) { - if (isArray(value)) { - const res = {}; - for (let i = 0; i < value.length; i++) { - const item = value[i]; - const normalized = normalizeStyle(isString(item) ? parseStringStyle(item) : item); - if (normalized) { - for (const key in normalized) { - res[key] = normalized[key]; - } - } - } - return res; - } - else if (isObject(value)) { - return value; - } -} -const listDelimiterRE = /;(?![^(]*\))/g; -const propertyDelimiterRE = /:(.+)/; -function parseStringStyle(cssText) { - const ret = {}; - cssText.split(listDelimiterRE).forEach(item => { - if (item) { - const tmp = item.split(propertyDelimiterRE); - tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); - } - }); - return ret; -} -function normalizeClass(value) { - let res = ''; - if (isString(value)) { - res = value; - } - else if (isArray(value)) { - for (let i = 0; i < value.length; i++) { - res += normalizeClass(value[i]) + ' '; - } - } - else if (isObject(value)) { - for (const name in value) { - if (value[name]) { - res += name + ' '; - } - } - } - return res.trim(); -} - -// These tag configs are shared between compiler-dom and runtime-dom, so they -// https://developer.mozilla.org/en-US/docs/Web/HTML/Element -const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' + - 'header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,' + - 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' + - 'data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,' + - 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' + - 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' + - 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' + - 'option,output,progress,select,textarea,details,dialog,menu,' + - 'summary,template,blockquote,iframe,tfoot'; -// https://developer.mozilla.org/en-US/docs/Web/SVG/Element -const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' + - 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' + - 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' + - 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' + - 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' + - 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' + - 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' + - 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' + - 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' + - 'text,textPath,title,tspan,unknown,use,view'; -const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'; -const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS); -const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS); -const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS); -const EMPTY_OBJ = (process.env.NODE_ENV !== 'production') - ? Object.freeze({}) - : {}; -const EMPTY_ARR = []; -const NOOP = () => { }; -const onRE = /^on[^a-z]/; -const isOn = (key) => onRE.test(key); -const isModelListener = (key) => key.startsWith('onUpdate:'); -const extend = Object.assign; -const remove = (arr, el) => { - const i = arr.indexOf(el); - if (i > -1) { - arr.splice(i, 1); - } -}; -const hasOwnProperty = Object.prototype.hasOwnProperty; -const hasOwn = (val, key) => hasOwnProperty.call(val, key); -const isArray = Array.isArray; -const isFunction = (val) => typeof val === 'function'; -const isString = (val) => typeof val === 'string'; -const isSymbol = (val) => typeof val === 'symbol'; -const isObject = (val) => val !== null && typeof val === 'object'; -const isPromise = (val) => { - return isObject(val) && isFunction(val.then) && isFunction(val.catch); -}; -const objectToString = Object.prototype.toString; -const toTypeString = (value) => objectToString.call(value); -const toRawType = (value) => { - return toTypeString(value).slice(8, -1); -}; -const isReservedProp = /*#__PURE__*/ makeMap('key,ref,' + - 'onVnodeBeforeMount,onVnodeMounted,' + - 'onVnodeBeforeUpdate,onVnodeUpdated,' + - 'onVnodeBeforeUnmount,onVnodeUnmounted'); -const cacheStringFunction = (fn) => { - const cache = Object.create(null); - return ((str) => { - const hit = cache[str]; - return hit || (cache[str] = fn(str)); - }); -}; -const camelizeRE = /-(\w)/g; -/** - * @private - */ -const camelize = cacheStringFunction((str) => { - return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); -}); -const hyphenateRE = /\B([A-Z])/g; -/** - * @private - */ -const hyphenate = cacheStringFunction((str) => { - return str.replace(hyphenateRE, '-$1').toLowerCase(); -}); -/** - * @private - */ -const capitalize = cacheStringFunction((str) => { - return str.charAt(0).toUpperCase() + str.slice(1); -}); -// compare whether a value has changed, accounting for NaN. -const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); -const def = (obj, key, value) => { - Object.defineProperty(obj, key, { - configurable: true, - enumerable: false, - value - }); -}; -const toNumber = (val) => { - const n = parseFloat(val); - return isNaN(n) ? val : n; -}; -let _globalThis; -const getGlobalThis = () => { - return (_globalThis || - (_globalThis = - typeof globalThis !== 'undefined' - ? globalThis - : typeof self !== 'undefined' - ? self - : typeof window !== 'undefined' - ? window - : typeof global !== 'undefined' - ? global - : {})); -}; - -const targetMap = new WeakMap(); -const effectStack = []; -let activeEffect; -const ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'iterate' : ''); -const MAP_KEY_ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'Map key iterate' : ''); -function isEffect(fn) { - return fn && fn._isEffect === true; -} -function effect(fn, options = EMPTY_OBJ) { - if (isEffect(fn)) { - fn = fn.raw; - } - const effect = createReactiveEffect(fn, options); - if (!options.lazy) { - effect(); - } - return effect; -} -function stop(effect) { - if (effect.active) { - cleanup(effect); - if (effect.options.onStop) { - effect.options.onStop(); - } - effect.active = false; - } -} -let uid = 0; -function createReactiveEffect(fn, options) { - const effect = function reactiveEffect() { - if (!effect.active) { - return options.scheduler ? undefined : fn(); - } - if (!effectStack.includes(effect)) { - cleanup(effect); - try { - enableTracking(); - effectStack.push(effect); - activeEffect = effect; - return fn(); - } - finally { - effectStack.pop(); - resetTracking(); - activeEffect = effectStack[effectStack.length - 1]; - } - } - }; - effect.id = uid++; - effect._isEffect = true; - effect.active = true; - effect.raw = fn; - effect.deps = []; - effect.options = options; - return effect; -} -function cleanup(effect) { - const { deps } = effect; - if (deps.length) { - for (let i = 0; i < deps.length; i++) { - deps[i].delete(effect); - } - deps.length = 0; - } -} -let shouldTrack = true; -const trackStack = []; -function pauseTracking() { - trackStack.push(shouldTrack); - shouldTrack = false; -} -function enableTracking() { - trackStack.push(shouldTrack); - shouldTrack = true; -} -function resetTracking() { - const last = trackStack.pop(); - shouldTrack = last === undefined ? true : last; -} -function track(target, type, key) { - if (!shouldTrack || activeEffect === undefined) { - return; - } - let depsMap = targetMap.get(target); - if (!depsMap) { - targetMap.set(target, (depsMap = new Map())); - } - let dep = depsMap.get(key); - if (!dep) { - depsMap.set(key, (dep = new Set())); - } - if (!dep.has(activeEffect)) { - dep.add(activeEffect); - activeEffect.deps.push(dep); - if ((process.env.NODE_ENV !== 'production') && activeEffect.options.onTrack) { - activeEffect.options.onTrack({ - effect: activeEffect, - target, - type, - key - }); - } - } -} -function trigger(target, type, key, newValue, oldValue, oldTarget) { - const depsMap = targetMap.get(target); - if (!depsMap) { - // never been tracked - return; - } - const effects = new Set(); - const add = (effectsToAdd) => { - if (effectsToAdd) { - effectsToAdd.forEach(effect => { - if (effect !== activeEffect) { - effects.add(effect); - } - }); - } - }; - if (type === "clear" /* CLEAR */) { - // collection being cleared - // trigger all effects for target - depsMap.forEach(add); - } - else if (key === 'length' && isArray(target)) { - depsMap.forEach((dep, key) => { - if (key === 'length' || key >= newValue) { - add(dep); - } - }); - } - else { - // schedule runs for SET | ADD | DELETE - if (key !== void 0) { - add(depsMap.get(key)); - } - // also run for iteration key on ADD | DELETE | Map.SET - const isAddOrDelete = type === "add" /* ADD */ || - (type === "delete" /* DELETE */ && !isArray(target)); - if (isAddOrDelete || - (type === "set" /* SET */ && target instanceof Map)) { - add(depsMap.get(isArray(target) ? 'length' : ITERATE_KEY)); - } - if (isAddOrDelete && target instanceof Map) { - add(depsMap.get(MAP_KEY_ITERATE_KEY)); - } - } - const run = (effect) => { - if ((process.env.NODE_ENV !== 'production') && effect.options.onTrigger) { - effect.options.onTrigger({ - effect, - target, - key, - type, - newValue, - oldValue, - oldTarget - }); - } - if (effect.options.scheduler) { - effect.options.scheduler(effect); - } - else { - effect(); - } - }; - effects.forEach(run); -} - -const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) - .map(key => Symbol[key]) - .filter(isSymbol)); -const get = /*#__PURE__*/ createGetter(); -const shallowGet = /*#__PURE__*/ createGetter(false, true); -const readonlyGet = /*#__PURE__*/ createGetter(true); -const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true); -const arrayInstrumentations = {}; -['includes', 'indexOf', 'lastIndexOf'].forEach(key => { - arrayInstrumentations[key] = function (...args) { - const arr = toRaw(this); - for (let i = 0, l = this.length; i < l; i++) { - track(arr, "get" /* GET */, i + ''); - } - // we run the method using the original args first (which may be reactive) - const res = arr[key](...args); - if (res === -1 || res === false) { - // if that didn't work, run it again using raw values. - return arr[key](...args.map(toRaw)); - } - else { - return res; - } - }; -}); -function createGetter(isReadonly = false, shallow = false) { - return function get(target, key, receiver) { - if (key === "__v_isReactive" /* IS_REACTIVE */) { - return !isReadonly; - } - else if (key === "__v_isReadonly" /* IS_READONLY */) { - return isReadonly; - } - else if (key === "__v_raw" /* RAW */ && - receiver === - (isReadonly - ? target["__v_readonly" /* READONLY */] - : target["__v_reactive" /* REACTIVE */])) { - return target; - } - const targetIsArray = isArray(target); - if (targetIsArray && hasOwn(arrayInstrumentations, key)) { - return Reflect.get(arrayInstrumentations, key, receiver); - } - const res = Reflect.get(target, key, receiver); - if (isSymbol(key) - ? builtInSymbols.has(key) - : key === `__proto__` || key === `__v_isRef`) { - return res; - } - if (!isReadonly) { - track(target, "get" /* GET */, key); - } - if (shallow) { - return res; - } - if (isRef(res)) { - // ref unwrapping, only for Objects, not for Arrays. - return targetIsArray ? res : res.value; - } - if (isObject(res)) { - // Convert returned value into a proxy as well. we do the isObject check - // here to avoid invalid value warning. Also need to lazy access readonly - // and reactive here to avoid circular dependency. - return isReadonly ? readonly(res) : reactive(res); - } - return res; - }; -} -const set = /*#__PURE__*/ createSetter(); -const shallowSet = /*#__PURE__*/ createSetter(true); -function createSetter(shallow = false) { - return function set(target, key, value, receiver) { - const oldValue = target[key]; - if (!shallow) { - value = toRaw(value); - if (!isArray(target) && isRef(oldValue) && !isRef(value)) { - oldValue.value = value; - return true; - } - } - const hadKey = hasOwn(target, key); - const result = Reflect.set(target, key, value, receiver); - // don't trigger if target is something up in the prototype chain of original - if (target === toRaw(receiver)) { - if (!hadKey) { - trigger(target, "add" /* ADD */, key, value); - } - else if (hasChanged(value, oldValue)) { - trigger(target, "set" /* SET */, key, value, oldValue); - } - } - return result; - }; -} -function deleteProperty(target, key) { - const hadKey = hasOwn(target, key); - const oldValue = target[key]; - const result = Reflect.deleteProperty(target, key); - if (result && hadKey) { - trigger(target, "delete" /* DELETE */, key, undefined, oldValue); - } - return result; -} -function has(target, key) { - const result = Reflect.has(target, key); - if (!isSymbol(key) || !builtInSymbols.has(key)) { - track(target, "has" /* HAS */, key); - } - return result; -} -function ownKeys(target) { - track(target, "iterate" /* ITERATE */, ITERATE_KEY); - return Reflect.ownKeys(target); -} -const mutableHandlers = { - get, - set, - deleteProperty, - has, - ownKeys -}; -const readonlyHandlers = { - get: readonlyGet, - has, - ownKeys, - set(target, key) { - if ((process.env.NODE_ENV !== 'production')) { - console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target); - } - return true; - }, - deleteProperty(target, key) { - if ((process.env.NODE_ENV !== 'production')) { - console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); - } - return true; - } -}; -const shallowReactiveHandlers = extend({}, mutableHandlers, { - get: shallowGet, - set: shallowSet -}); -// Props handlers are special in the sense that it should not unwrap top-level -// refs (in order to allow refs to be explicitly passed down), but should -// retain the reactivity of the normal readonly object. -const shallowReadonlyHandlers = extend({}, readonlyHandlers, { - get: shallowReadonlyGet -}); - -const toReactive = (value) => isObject(value) ? reactive(value) : value; -const toReadonly = (value) => isObject(value) ? readonly(value) : value; -const toShallow = (value) => value; -const getProto = (v) => Reflect.getPrototypeOf(v); -function get$1(target, key, isReadonly = false, isShallow = false) { - // #1772: readonly(reactive(Map)) should return readonly + reactive version - // of the value - target = target["__v_raw" /* RAW */]; - const rawTarget = toRaw(target); - const rawKey = toRaw(key); - if (key !== rawKey) { - !isReadonly && track(rawTarget, "get" /* GET */, key); - } - !isReadonly && track(rawTarget, "get" /* GET */, rawKey); - const { has } = getProto(rawTarget); - const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - if (has.call(rawTarget, key)) { - return wrap(target.get(key)); - } - else if (has.call(rawTarget, rawKey)) { - return wrap(target.get(rawKey)); - } -} -function has$1(key, isReadonly = false) { - const target = this["__v_raw" /* RAW */]; - const rawTarget = toRaw(target); - const rawKey = toRaw(key); - if (key !== rawKey) { - !isReadonly && track(rawTarget, "has" /* HAS */, key); - } - !isReadonly && track(rawTarget, "has" /* HAS */, rawKey); - return target.has(key) || target.has(rawKey); -} -function size(target, isReadonly = false) { - target = target["__v_raw" /* RAW */]; - !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); - return Reflect.get(target, 'size', target); -} -function add(value) { - value = toRaw(value); - const target = toRaw(this); - const proto = getProto(target); - const hadKey = proto.has.call(target, value); - const result = proto.add.call(target, value); - if (!hadKey) { - trigger(target, "add" /* ADD */, value, value); - } - return result; -} -function set$1(key, value) { - value = toRaw(value); - const target = toRaw(this); - const { has, get, set } = getProto(target); - let hadKey = has.call(target, key); - if (!hadKey) { - key = toRaw(key); - hadKey = has.call(target, key); - } - else if ((process.env.NODE_ENV !== 'production')) { - checkIdentityKeys(target, has, key); - } - const oldValue = get.call(target, key); - const result = set.call(target, key, value); - if (!hadKey) { - trigger(target, "add" /* ADD */, key, value); - } - else if (hasChanged(value, oldValue)) { - trigger(target, "set" /* SET */, key, value, oldValue); - } - return result; -} -function deleteEntry(key) { - const target = toRaw(this); - const { has, get, delete: del } = getProto(target); - let hadKey = has.call(target, key); - if (!hadKey) { - key = toRaw(key); - hadKey = has.call(target, key); - } - else if ((process.env.NODE_ENV !== 'production')) { - checkIdentityKeys(target, has, key); - } - const oldValue = get ? get.call(target, key) : undefined; - // forward the operation before queueing reactions - const result = del.call(target, key); - if (hadKey) { - trigger(target, "delete" /* DELETE */, key, undefined, oldValue); - } - return result; -} -function clear() { - const target = toRaw(this); - const hadItems = target.size !== 0; - const oldTarget = (process.env.NODE_ENV !== 'production') - ? target instanceof Map - ? new Map(target) - : new Set(target) - : undefined; - // forward the operation before queueing reactions - const result = getProto(target).clear.call(target); - if (hadItems) { - trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget); - } - return result; -} -function createForEach(isReadonly, isShallow) { - return function forEach(callback, thisArg) { - const observed = this; - const target = toRaw(observed); - const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - !isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); - // important: create sure the callback is - // 1. invoked with the reactive map as `this` and 3rd arg - // 2. the value received should be a corresponding reactive/readonly. - function wrappedCallback(value, key) { - return callback.call(thisArg, wrap(value), wrap(key), observed); - } - return getProto(target).forEach.call(target, wrappedCallback); - }; -} -function createIterableMethod(method, isReadonly, isShallow) { - return function (...args) { - const target = this["__v_raw" /* RAW */]; - const rawTarget = toRaw(target); - const isMap = rawTarget instanceof Map; - const isPair = method === 'entries' || (method === Symbol.iterator && isMap); - const isKeyOnly = method === 'keys' && isMap; - const innerIterator = target[method](...args); - const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - !isReadonly && - track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); - // return a wrapped iterator which returns observed versions of the - // values emitted from the real iterator - return { - // iterator protocol - next() { - const { value, done } = innerIterator.next(); - return done - ? { value, done } - : { - value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), - done - }; - }, - // iterable protocol - [Symbol.iterator]() { - return this; - } - }; - }; -} -function createReadonlyMethod(type) { - return function (...args) { - if ((process.env.NODE_ENV !== 'production')) { - const key = args[0] ? `on key "${args[0]}" ` : ``; - console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); - } - return type === "delete" /* DELETE */ ? false : this; - }; -} -const mutableInstrumentations = { - get(key) { - return get$1(this, key); - }, - get size() { - return size(this); - }, - has: has$1, - add, - set: set$1, - delete: deleteEntry, - clear, - forEach: createForEach(false, false) -}; -const shallowInstrumentations = { - get(key) { - return get$1(this, key, false, true); - }, - get size() { - return size(this); - }, - has: has$1, - add, - set: set$1, - delete: deleteEntry, - clear, - forEach: createForEach(false, true) -}; -const readonlyInstrumentations = { - get(key) { - return get$1(this, key, true); - }, - get size() { - return size(this, true); - }, - has(key) { - return has$1.call(this, key, true); - }, - add: createReadonlyMethod("add" /* ADD */), - set: createReadonlyMethod("set" /* SET */), - delete: createReadonlyMethod("delete" /* DELETE */), - clear: createReadonlyMethod("clear" /* CLEAR */), - forEach: createForEach(true, false) -}; -const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; -iteratorMethods.forEach(method => { - mutableInstrumentations[method] = createIterableMethod(method, false, false); - readonlyInstrumentations[method] = createIterableMethod(method, true, false); - shallowInstrumentations[method] = createIterableMethod(method, false, true); -}); -function createInstrumentationGetter(isReadonly, shallow) { - const instrumentations = shallow - ? shallowInstrumentations - : isReadonly - ? readonlyInstrumentations - : mutableInstrumentations; - return (target, key, receiver) => { - if (key === "__v_isReactive" /* IS_REACTIVE */) { - return !isReadonly; - } - else if (key === "__v_isReadonly" /* IS_READONLY */) { - return isReadonly; - } - else if (key === "__v_raw" /* RAW */) { - return target; - } - return Reflect.get(hasOwn(instrumentations, key) && key in target - ? instrumentations - : target, key, receiver); - }; -} -const mutableCollectionHandlers = { - get: createInstrumentationGetter(false, false) -}; -const readonlyCollectionHandlers = { - get: createInstrumentationGetter(true, false) -}; -function checkIdentityKeys(target, has, key) { - const rawKey = toRaw(key); - if (rawKey !== key && has.call(target, rawKey)) { - const type = toRawType(target); - console.warn(`Reactive ${type} contains both the raw and reactive ` + - `versions of the same object${type === `Map` ? `as keys` : ``}, ` + - `which can lead to inconsistencies. ` + - `Avoid differentiating between the raw and reactive versions ` + - `of an object and only use the reactive version if possible.`); - } -} - -function targetTypeMap(rawType) { - switch (rawType) { - case 'Object': - case 'Array': - return 1 /* COMMON */; - case 'Map': - case 'Set': - case 'WeakMap': - case 'WeakSet': - return 2 /* COLLECTION */; - default: - return 0 /* INVALID */; - } -} -function getTargetType(value) { - return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) - ? 0 /* INVALID */ - : targetTypeMap(toRawType(value)); -} -function reactive(target) { - // if trying to observe a readonly proxy, return the readonly version. - if (target && target["__v_isReadonly" /* IS_READONLY */]) { - return target; - } - return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); -} -function readonly(target) { - return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); -} -// Return a reactive-copy of the original object, where only the root level -// properties are readonly, and does NOT unwrap refs nor recursively convert -// returned properties. -// This is used for creating the props proxy object for stateful components. -function shallowReadonly(target) { - return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); -} -function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { - if (!isObject(target)) { - if ((process.env.NODE_ENV !== 'production')) { - console.warn(`value cannot be made reactive: ${String(target)}`); - } - return target; - } - // target is already a Proxy, return it. - // exception: calling readonly() on a reactive object - if (target["__v_raw" /* RAW */] && - !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) { - return target; - } - // target already has corresponding Proxy - const reactiveFlag = isReadonly - ? "__v_readonly" /* READONLY */ - : "__v_reactive" /* REACTIVE */; - if (hasOwn(target, reactiveFlag)) { - return target[reactiveFlag]; - } - // only a whitelist of value types can be observed. - const targetType = getTargetType(target); - if (targetType === 0 /* INVALID */) { - return target; - } - const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); - def(target, reactiveFlag, observed); - return observed; -} -function isReactive(value) { - if (isReadonly(value)) { - return isReactive(value["__v_raw" /* RAW */]); - } - return !!(value && value["__v_isReactive" /* IS_REACTIVE */]); -} -function isReadonly(value) { - return !!(value && value["__v_isReadonly" /* IS_READONLY */]); -} -function isProxy(value) { - return isReactive(value) || isReadonly(value); -} -function toRaw(observed) { - return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed); -} -function isRef(r) { - return r ? r.__v_isRef === true : false; -} - -const stack = []; -function pushWarningContext(vnode) { - stack.push(vnode); -} -function popWarningContext() { - stack.pop(); -} -function warn(msg, ...args) { - // avoid props formatting or warn handler tracking deps that might be mutated - // during patch, leading to infinite recursion. - pauseTracking(); - const instance = stack.length ? stack[stack.length - 1].component : null; - const appWarnHandler = instance && instance.appContext.config.warnHandler; - const trace = getComponentTrace(); - if (appWarnHandler) { - callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [ - msg + args.join(''), - instance && instance.proxy, - trace - .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`) - .join('\n'), - trace - ]); - } - else { - const warnArgs = [`[Vue warn]: ${msg}`, ...args]; - /* istanbul ignore if */ - if (trace.length && - // avoid spamming console during tests - !false) { - warnArgs.push(`\n`, ...formatTrace(trace)); - } - console.warn(...warnArgs); - } - resetTracking(); -} -function getComponentTrace() { - let currentVNode = stack[stack.length - 1]; - if (!currentVNode) { - return []; - } - // we can't just use the stack because it will be incomplete during updates - // that did not start from the root. Re-construct the parent chain using - // instance parent pointers. - const normalizedStack = []; - while (currentVNode) { - const last = normalizedStack[0]; - if (last && last.vnode === currentVNode) { - last.recurseCount++; - } - else { - normalizedStack.push({ - vnode: currentVNode, - recurseCount: 0 - }); - } - const parentInstance = currentVNode.component && currentVNode.component.parent; - currentVNode = parentInstance && parentInstance.vnode; - } - return normalizedStack; -} -/* istanbul ignore next */ -function formatTrace(trace) { - const logs = []; - trace.forEach((entry, i) => { - logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry)); - }); - return logs; -} -function formatTraceEntry({ vnode, recurseCount }) { - const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``; - const isRoot = vnode.component ? vnode.component.parent == null : false; - const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`; - const close = `>` + postfix; - return vnode.props - ? [open, ...formatProps(vnode.props), close] - : [open + close]; -} -/* istanbul ignore next */ -function formatProps(props) { - const res = []; - const keys = Object.keys(props); - keys.slice(0, 3).forEach(key => { - res.push(...formatProp(key, props[key])); - }); - if (keys.length > 3) { - res.push(` ...`); - } - return res; -} -/* istanbul ignore next */ -function formatProp(key, value, raw) { - if (isString(value)) { - value = JSON.stringify(value); - return raw ? value : [`${key}=${value}`]; - } - else if (typeof value === 'number' || - typeof value === 'boolean' || - value == null) { - return raw ? value : [`${key}=${value}`]; - } - else if (isRef(value)) { - value = formatProp(key, toRaw(value.value), true); - return raw ? value : [`${key}=Ref<`, value, `>`]; - } - else if (isFunction(value)) { - return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]; - } - else { - value = toRaw(value); - return raw ? value : [`${key}=`, value]; - } -} - -const ErrorTypeStrings = { - ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook', - ["c" /* CREATED */]: 'created hook', - ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook', - ["m" /* MOUNTED */]: 'mounted hook', - ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook', - ["u" /* UPDATED */]: 'updated', - ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook', - ["um" /* UNMOUNTED */]: 'unmounted hook', - ["a" /* ACTIVATED */]: 'activated hook', - ["da" /* DEACTIVATED */]: 'deactivated hook', - ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook', - ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook', - ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook', - [0 /* SETUP_FUNCTION */]: 'setup function', - [1 /* RENDER_FUNCTION */]: 'render function', - [2 /* WATCH_GETTER */]: 'watcher getter', - [3 /* WATCH_CALLBACK */]: 'watcher callback', - [4 /* WATCH_CLEANUP */]: 'watcher cleanup function', - [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler', - [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler', - [7 /* VNODE_HOOK */]: 'vnode hook', - [8 /* DIRECTIVE_HOOK */]: 'directive hook', - [9 /* TRANSITION_HOOK */]: 'transition hook', - [10 /* APP_ERROR_HANDLER */]: 'app errorHandler', - [11 /* APP_WARN_HANDLER */]: 'app warnHandler', - [12 /* FUNCTION_REF */]: 'ref function', - [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader', - [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' + - 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next' -}; -function callWithErrorHandling(fn, instance, type, args) { - let res; - try { - res = args ? fn(...args) : fn(); - } - catch (err) { - handleError(err, instance, type); - } - return res; -} -function callWithAsyncErrorHandling(fn, instance, type, args) { - if (isFunction(fn)) { - const res = callWithErrorHandling(fn, instance, type, args); - if (res && isPromise(res)) { - res.catch(err => { - handleError(err, instance, type); - }); - } - return res; - } - const values = []; - for (let i = 0; i < fn.length; i++) { - values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)); - } - return values; -} -function handleError(err, instance, type) { - const contextVNode = instance ? instance.vnode : null; - if (instance) { - let cur = instance.parent; - // the exposed instance is the render proxy to keep it consistent with 2.x - const exposedInstance = instance.proxy; - // in production the hook receives only the error code - const errorInfo = (process.env.NODE_ENV !== 'production') ? ErrorTypeStrings[type] : type; - while (cur) { - const errorCapturedHooks = cur.ec; - if (errorCapturedHooks) { - for (let i = 0; i < errorCapturedHooks.length; i++) { - if (errorCapturedHooks[i](err, exposedInstance, errorInfo)) { - return; - } - } - } - cur = cur.parent; - } - // app-level handling - const appErrorHandler = instance.appContext.config.errorHandler; - if (appErrorHandler) { - callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]); - return; - } - } - logError(err, type, contextVNode); -} -function logError(err, type, contextVNode) { - if ((process.env.NODE_ENV !== 'production')) { - const info = ErrorTypeStrings[type]; - if (contextVNode) { - pushWarningContext(contextVNode); - } - warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`); - if (contextVNode) { - popWarningContext(); - } - // crash in dev so it's more noticeable - throw err; - } - else { - // recover in prod to reduce the impact on end-user - console.error(err); - } -} - -let isFlushing = false; -let isFlushPending = false; -const queue = []; -let flushIndex = 0; -const pendingPreFlushCbs = []; -let activePreFlushCbs = null; -let preFlushIndex = 0; -const pendingPostFlushCbs = []; -let activePostFlushCbs = null; -let postFlushIndex = 0; -const resolvedPromise = Promise.resolve(); -let currentFlushPromise = null; -let currentPreFlushParentJob = null; -const RECURSION_LIMIT = 100; -function nextTick(fn) { - const p = currentFlushPromise || resolvedPromise; - return fn ? p.then(fn) : p; -} -function queueJob(job) { - // the dedupe search uses the startIndex argument of Array.includes() - // by default the search index includes the current job that is being run - // so it cannot recursively trigger itself again. - // if the job is a watch() callback, the search will start with a +1 index to - // allow it recursively trigger itself - it is the user's responsibility to - // ensure it doesn't end up in an infinite loop. - if ((!queue.length || - !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) && - job !== currentPreFlushParentJob) { - queue.push(job); - queueFlush(); - } -} -function queueFlush() { - if (!isFlushing && !isFlushPending) { - isFlushPending = true; - currentFlushPromise = resolvedPromise.then(flushJobs); - } -} -function queueCb(cb, activeQueue, pendingQueue, index) { - if (!isArray(cb)) { - if (!activeQueue || - !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) { - pendingQueue.push(cb); - } - } - else { - // if cb is an array, it is a component lifecycle hook which can only be - // triggered by a job, which is already deduped in the main queue, so - // we can skip duplicate check here to improve perf - pendingQueue.push(...cb); - } - queueFlush(); -} -function queuePreFlushCb(cb) { - queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex); -} -function queuePostFlushCb(cb) { - queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex); -} -function flushPreFlushCbs(seen, parentJob = null) { - if (pendingPreFlushCbs.length) { - currentPreFlushParentJob = parentJob; - activePreFlushCbs = [...new Set(pendingPreFlushCbs)]; - pendingPreFlushCbs.length = 0; - if ((process.env.NODE_ENV !== 'production')) { - seen = seen || new Map(); - } - for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) { - if ((process.env.NODE_ENV !== 'production')) { - checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex]); - } - activePreFlushCbs[preFlushIndex](); - } - activePreFlushCbs = null; - preFlushIndex = 0; - currentPreFlushParentJob = null; - // recursively flush until it drains - flushPreFlushCbs(seen, parentJob); - } -} -function flushPostFlushCbs(seen) { - if (pendingPostFlushCbs.length) { - activePostFlushCbs = [...new Set(pendingPostFlushCbs)]; - pendingPostFlushCbs.length = 0; - if ((process.env.NODE_ENV !== 'production')) { - seen = seen || new Map(); - } - activePostFlushCbs.sort((a, b) => getId(a) - getId(b)); - for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) { - if ((process.env.NODE_ENV !== 'production')) { - checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex]); - } - activePostFlushCbs[postFlushIndex](); - } - activePostFlushCbs = null; - postFlushIndex = 0; - } -} -const getId = (job) => job.id == null ? Infinity : job.id; -function flushJobs(seen) { - isFlushPending = false; - isFlushing = true; - if ((process.env.NODE_ENV !== 'production')) { - seen = seen || new Map(); - } - flushPreFlushCbs(seen); - // Sort queue before flush. - // This ensures that: - // 1. Components are updated from parent to child. (because parent is always - // created before the child so its render effect will have smaller - // priority number) - // 2. If a component is unmounted during a parent component's update, - // its update can be skipped. - // Jobs can never be null before flush starts, since they are only invalidated - // during execution of another flushed job. - queue.sort((a, b) => getId(a) - getId(b)); - try { - for (flushIndex = 0; flushIndex < queue.length; flushIndex++) { - const job = queue[flushIndex]; - if (job) { - if ((process.env.NODE_ENV !== 'production')) { - checkRecursiveUpdates(seen, job); - } - callWithErrorHandling(job, null, 14 /* SCHEDULER */); - } - } - } - finally { - flushIndex = 0; - queue.length = 0; - flushPostFlushCbs(seen); - isFlushing = false; - currentFlushPromise = null; - // some postFlushCb queued jobs! - // keep flushing until it drains. - if (queue.length || pendingPostFlushCbs.length) { - flushJobs(seen); - } - } -} -function checkRecursiveUpdates(seen, fn) { - if (!seen.has(fn)) { - seen.set(fn, 1); - } - else { - const count = seen.get(fn); - if (count > RECURSION_LIMIT) { - throw new Error(`Maximum recursive updates exceeded. ` + - `This means you have a reactive effect that is mutating its own ` + - `dependencies and thus recursively triggering itself. Possible sources ` + - `include component template, render function, updated hook or ` + - `watcher source function.`); - } - else { - seen.set(fn, count + 1); - } - } -} -const hmrDirtyComponents = new Set(); -// Expose the HMR runtime on the global object -// This makes it entirely tree-shakable without polluting the exports and makes -// it easier to be used in toolings like vue-loader -// Note: for a component to be eligible for HMR it also needs the __hmrId option -// to be set so that its instances can be registered / removed. -if ((process.env.NODE_ENV !== 'production')) { - const globalObject = typeof global !== 'undefined' - ? global - : typeof self !== 'undefined' - ? self - : typeof window !== 'undefined' - ? window - : {}; - globalObject.__VUE_HMR_RUNTIME__ = { - createRecord: tryWrap(createRecord), - rerender: tryWrap(rerender), - reload: tryWrap(reload) - }; -} -const map = new Map(); -function createRecord(id) { - if (map.has(id)) { - return false; - } - map.set(id, new Set()); - return true; -} -function rerender(id, newRender) { - const record = map.get(id); - if (!record) - return; - // Array.from creates a snapshot which avoids the set being mutated during - // updates - Array.from(record).forEach(instance => { - if (newRender) { - instance.render = newRender; - } - instance.renderCache = []; - instance.update(); - }); -} -function reload(id, newComp) { - const record = map.get(id); - if (!record) - return; - // Array.from creates a snapshot which avoids the set being mutated during - // updates - Array.from(record).forEach(instance => { - const comp = instance.type; - if (!hmrDirtyComponents.has(comp)) { - // 1. Update existing comp definition to match new one - extend(comp, newComp); - for (const key in comp) { - if (!(key in newComp)) { - delete comp[key]; - } - } - // 2. Mark component dirty. This forces the renderer to replace the component - // on patch. - hmrDirtyComponents.add(comp); - // 3. Make sure to unmark the component after the reload. - queuePostFlushCb(() => { - hmrDirtyComponents.delete(comp); - }); - } - if (instance.parent) { - // 4. Force the parent instance to re-render. This will cause all updated - // components to be unmounted and re-mounted. Queue the update so that we - // don't end up forcing the same parent to re-render multiple times. - queueJob(instance.parent.update); - } - else if (instance.appContext.reload) { - // root instance mounted via createApp() has a reload method - instance.appContext.reload(); - } - else if (typeof window !== 'undefined') { - // root instance inside tree created via raw render(). Force reload. - window.location.reload(); - } - else { - console.warn('[HMR] Root or manually mounted instance modified. Full reload required.'); - } - }); -} -function tryWrap(fn) { - return (id, arg) => { - try { - return fn(id, arg); - } - catch (e) { - console.error(e); - console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` + - `Full reload required.`); - } - }; -} - -// mark the current rendering instance for asset resolution (e.g. -// resolveComponent, resolveDirective) during render -let currentRenderingInstance = null; -function markAttrsAccessed() { -} - -const isSuspense = (type) => type.__isSuspense; -function queueEffectWithSuspense(fn, suspense) { - if (suspense && !suspense.isResolved) { - if (isArray(fn)) { - suspense.effects.push(...fn); - } - else { - suspense.effects.push(fn); - } - } - else { - queuePostFlushCb(fn); - } -} - -// SFC scoped style ID management. -let currentScopeId = null; - -const isTeleport = (type) => type.__isTeleport; -const NULL_DYNAMIC_COMPONENT = Symbol(); - -let isRenderingTemplateSlot = false; - -const Fragment = Symbol((process.env.NODE_ENV !== 'production') ? 'Fragment' : undefined); -const Text = Symbol((process.env.NODE_ENV !== 'production') ? 'Text' : undefined); -const Comment = Symbol((process.env.NODE_ENV !== 'production') ? 'Comment' : undefined); -const Static = Symbol((process.env.NODE_ENV !== 'production') ? 'Static' : undefined); -let currentBlock = null; -// Whether we should be tracking dynamic child nodes inside a block. -// Only tracks when this value is > 0 -// We are not using a simple boolean because this value may need to be -// incremented/decremented by nested usage of v-once (see below) -let shouldTrack$1 = 1; -function isVNode(value) { - return value ? value.__v_isVNode === true : false; -} -function isSameVNodeType(n1, n2) { - if ((process.env.NODE_ENV !== 'production') && - n2.shapeFlag & 6 /* COMPONENT */ && - hmrDirtyComponents.has(n2.type)) { - // HMR only: if the component has been hot-updated, force a reload. - return false; - } - return n1.type === n2.type && n1.key === n2.key; -} -let vnodeArgsTransformer; -const createVNodeWithArgsTransform = (...args) => { - return _createVNode(...(vnodeArgsTransformer - ? vnodeArgsTransformer(args, currentRenderingInstance) - : args)); -}; -const InternalObjectKey = `__vInternal`; -const normalizeKey = ({ key }) => key != null ? key : null; -const normalizeRef = ({ ref: ref$$1 }) => { - return (ref$$1 != null - ? isArray(ref$$1) - ? ref$$1 - : [currentRenderingInstance, ref$$1] - : null); -}; -const createVNode = ((process.env.NODE_ENV !== 'production') - ? createVNodeWithArgsTransform - : _createVNode); -function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) { - if (!type || type === NULL_DYNAMIC_COMPONENT) { - if ((process.env.NODE_ENV !== 'production') && !type) { - warn(`Invalid vnode type when creating vnode: ${type}.`); - } - type = Comment; - } - if (isVNode(type)) { - const cloned = cloneVNode(type, props); - if (children) { - normalizeChildren(cloned, children); - } - return cloned; - } - // class component normalization. - if (isFunction(type) && '__vccOpts' in type) { - type = type.__vccOpts; - } - // class & style normalization. - if (props) { - // for reactive or proxy objects, we need to clone it to enable mutation. - if (isProxy(props) || InternalObjectKey in props) { - props = extend({}, props); - } - let { class: klass, style } = props; - if (klass && !isString(klass)) { - props.class = normalizeClass(klass); - } - if (isObject(style)) { - // reactive state objects need to be cloned since they are likely to be - // mutated - if (isProxy(style) && !isArray(style)) { - style = extend({}, style); - } - props.style = normalizeStyle(style); - } - } - // encode the vnode type information into a bitmap - const shapeFlag = isString(type) - ? 1 /* ELEMENT */ - : isSuspense(type) - ? 128 /* SUSPENSE */ - : isTeleport(type) - ? 64 /* TELEPORT */ - : isObject(type) - ? 4 /* STATEFUL_COMPONENT */ - : isFunction(type) - ? 2 /* FUNCTIONAL_COMPONENT */ - : 0; - if ((process.env.NODE_ENV !== 'production') && shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) { - type = toRaw(type); - warn(`Vue received a Component which was made a reactive object. This can ` + - `lead to unnecessary performance overhead, and should be avoided by ` + - `marking the component with \`markRaw\` or using \`shallowRef\` ` + - `instead of \`ref\`.`, `\nComponent that was made reactive: `, type); - } - const vnode = { - __v_isVNode: true, - __v_skip: true, - type, - props, - key: props && normalizeKey(props), - ref: props && normalizeRef(props), - scopeId: currentScopeId, - children: null, - component: null, - suspense: null, - dirs: null, - transition: null, - el: null, - anchor: null, - target: null, - targetAnchor: null, - staticCount: 0, - shapeFlag, - patchFlag, - dynamicProps, - dynamicChildren: null, - appContext: null - }; - // validate key - if ((process.env.NODE_ENV !== 'production') && vnode.key !== vnode.key) { - warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type); - } - normalizeChildren(vnode, children); - if ((shouldTrack$1 > 0 || isRenderingTemplateSlot) && - // avoid a block node from tracking itself - !isBlockNode && - // has current parent block - currentBlock && - // presence of a patch flag indicates this node needs patching on updates. - // component nodes also should always be patched, because even if the - // component doesn't need to update, it needs to persist the instance on to - // the next vnode so that it can be properly unmounted later. - (patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) && - // the EVENTS flag is only for hydration and if it is the only flag, the - // vnode should not be considered dynamic due to handler caching. - patchFlag !== 32 /* HYDRATE_EVENTS */) { - currentBlock.push(vnode); - } - return vnode; -} -function cloneVNode(vnode, extraProps) { - // This is intentionally NOT using spread or extend to avoid the runtime - // key enumeration cost. - const { props, patchFlag } = vnode; - const mergedProps = extraProps - ? props - ? mergeProps(props, extraProps) - : extend({}, extraProps) - : props; - return { - __v_isVNode: true, - __v_skip: true, - type: vnode.type, - props: mergedProps, - key: mergedProps && normalizeKey(mergedProps), - ref: extraProps && extraProps.ref ? normalizeRef(extraProps) : vnode.ref, - scopeId: vnode.scopeId, - children: vnode.children, - target: vnode.target, - targetAnchor: vnode.targetAnchor, - staticCount: vnode.staticCount, - shapeFlag: vnode.shapeFlag, - // if the vnode is cloned with extra props, we can no longer assume its - // existing patch flag to be reliable and need to add the FULL_PROPS flag. - // note: perserve flag for fragments since they use the flag for children - // fast paths only. - patchFlag: extraProps && vnode.type !== Fragment - ? patchFlag === -1 // hoisted node - ? 16 /* FULL_PROPS */ - : patchFlag | 16 /* FULL_PROPS */ - : patchFlag, - dynamicProps: vnode.dynamicProps, - dynamicChildren: vnode.dynamicChildren, - appContext: vnode.appContext, - dirs: vnode.dirs, - transition: vnode.transition, - // These should technically only be non-null on mounted VNodes. However, - // they *should* be copied for kept-alive vnodes. So we just always copy - // them since them being non-null during a mount doesn't affect the logic as - // they will simply be overwritten. - component: vnode.component, - suspense: vnode.suspense, - el: vnode.el, - anchor: vnode.anchor - }; -} -/** - * @private - */ -function createTextVNode(text$$1 = ' ', flag = 0) { - return createVNode(Text, null, text$$1, flag); -} -function normalizeChildren(vnode, children) { - let type = 0; - const { shapeFlag } = vnode; - if (children == null) { - children = null; - } - else if (isArray(children)) { - type = 16 /* ARRAY_CHILDREN */; - } - else if (typeof children === 'object') { - // Normalize slot to plain children - if ((shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) && - children.default) { - normalizeChildren(vnode, children.default()); - return; - } - else { - type = 32 /* SLOTS_CHILDREN */; - const slotFlag = children._; - if (!slotFlag && !(InternalObjectKey in children)) { - children._ctx = currentRenderingInstance; - } - else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) { - // a child component receives forwarded slots from the parent. - // its slot type is determined by its parent's slot type. - if (currentRenderingInstance.vnode.patchFlag & 1024 /* DYNAMIC_SLOTS */) { - children._ = 2 /* DYNAMIC */; - vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */; - } - else { - children._ = 1 /* STABLE */; - } - } - } - } - else if (isFunction(children)) { - children = { default: children, _ctx: currentRenderingInstance }; - type = 32 /* SLOTS_CHILDREN */; - } - else { - children = String(children); - // force teleport children to array so it can be moved around - if (shapeFlag & 64 /* TELEPORT */) { - type = 16 /* ARRAY_CHILDREN */; - children = [createTextVNode(children)]; - } - else { - type = 8 /* TEXT_CHILDREN */; - } - } - vnode.children = children; - vnode.shapeFlag |= type; -} -function mergeProps(...args) { - const ret = extend({}, args[0]); - for (let i = 1; i < args.length; i++) { - const toMerge = args[i]; - for (const key in toMerge) { - if (key === 'class') { - if (ret.class !== toMerge.class) { - ret.class = normalizeClass([ret.class, toMerge.class]); - } - } - else if (key === 'style') { - ret.style = normalizeStyle([ret.style, toMerge.style]); - } - else if (isOn(key)) { - const existing = ret[key]; - const incoming = toMerge[key]; - if (existing !== incoming) { - ret[key] = existing - ? [].concat(existing, toMerge[key]) - : incoming; - } - } - else { - ret[key] = toMerge[key]; - } - } - } - return ret; -} -function normalizePropsOptions(comp) { - if (comp.__props) { - return comp.__props; - } - const raw = comp.props; - const normalized = {}; - const needCastKeys = []; - // apply mixin/extends props - let hasExtends = false; - if (__VUE_OPTIONS_API__ && !isFunction(comp)) { - const extendProps = (raw) => { - const [props, keys] = normalizePropsOptions(raw); - extend(normalized, props); - if (keys) - needCastKeys.push(...keys); - }; - if (comp.extends) { - hasExtends = true; - extendProps(comp.extends); - } - if (comp.mixins) { - hasExtends = true; - comp.mixins.forEach(extendProps); - } - } - if (!raw && !hasExtends) { - return (comp.__props = EMPTY_ARR); - } - if (isArray(raw)) { - for (let i = 0; i < raw.length; i++) { - if ((process.env.NODE_ENV !== 'production') && !isString(raw[i])) { - warn(`props must be strings when using array syntax.`, raw[i]); - } - const normalizedKey = camelize(raw[i]); - if (validatePropName(normalizedKey)) { - normalized[normalizedKey] = EMPTY_OBJ; - } - } - } - else if (raw) { - if ((process.env.NODE_ENV !== 'production') && !isObject(raw)) { - warn(`invalid props options`, raw); - } - for (const key in raw) { - const normalizedKey = camelize(key); - if (validatePropName(normalizedKey)) { - const opt = raw[key]; - const prop = (normalized[normalizedKey] = - isArray(opt) || isFunction(opt) ? { type: opt } : opt); - if (prop) { - const booleanIndex = getTypeIndex(Boolean, prop.type); - const stringIndex = getTypeIndex(String, prop.type); - prop[0 /* shouldCast */] = booleanIndex > -1; - prop[1 /* shouldCastTrue */] = - stringIndex < 0 || booleanIndex < stringIndex; - // if the prop needs boolean casting or default value - if (booleanIndex > -1 || hasOwn(prop, 'default')) { - needCastKeys.push(normalizedKey); - } - } - } - } - } - const normalizedEntry = [normalized, needCastKeys]; - comp.__props = normalizedEntry; - return normalizedEntry; -} -// use function string name to check type constructors -// so that it works across vms / iframes. -function getType(ctor) { - const match = ctor && ctor.toString().match(/^\s*function (\w+)/); - return match ? match[1] : ''; -} -function isSameType(a, b) { - return getType(a) === getType(b); -} -function getTypeIndex(type, expectedTypes) { - if (isArray(expectedTypes)) { - for (let i = 0, len = expectedTypes.length; i < len; i++) { - if (isSameType(expectedTypes[i], type)) { - return i; - } - } - } - else if (isFunction(expectedTypes)) { - return isSameType(expectedTypes, type) ? 0 : -1; - } - return -1; -} -/** - * dev only - */ -function validatePropName(key) { - if (key[0] !== '$') { - return true; - } - else if ((process.env.NODE_ENV !== 'production')) { - warn(`Invalid prop name: "${key}" is a reserved property.`); - } - return false; -} -const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); - -function injectHook(type, hook, target = currentInstance, prepend = false) { - if (target) { - const hooks = target[type] || (target[type] = []); - // cache the error handling wrapper for injected hooks so the same hook - // can be properly deduped by the scheduler. "__weh" stands for "with error - // handling". - const wrappedHook = hook.__weh || - (hook.__weh = (...args) => { - if (target.isUnmounted) { - return; - } - // disable tracking inside all lifecycle hooks - // since they can potentially be called inside effects. - pauseTracking(); - // Set currentInstance during hook invocation. - // This assumes the hook does not synchronously trigger other hooks, which - // can only be false when the user does something really funky. - setCurrentInstance(target); - const res = callWithAsyncErrorHandling(hook, target, type, args); - setCurrentInstance(null); - resetTracking(); - return res; - }); - if (prepend) { - hooks.unshift(wrappedHook); - } - else { - hooks.push(wrappedHook); - } - } - else if ((process.env.NODE_ENV !== 'production')) { - const apiName = `on${capitalize(ErrorTypeStrings[type].replace(/ hook$/, ''))}`; - warn(`${apiName} is called when there is no active component instance to be ` + - `associated with. ` + - `Lifecycle injection APIs can only be used during execution of setup().` + - ( ` If you are using async setup(), make sure to register lifecycle ` + - `hooks before the first await statement.` - )); - } -} -const createHook = (lifecycle) => (hook, target = currentInstance) => -// post-create lifecycle registrations are noops during SSR -!isInSSRComponentSetup && injectHook(lifecycle, hook, target); -const onMounted = createHook("m" /* MOUNTED */); -const onUpdated = createHook("u" /* UPDATED */); -const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */); - -function useTransitionState() { - const state = { - isMounted: false, - isLeaving: false, - isUnmounting: false, - leavingVNodes: new Map() - }; - onMounted(() => { - state.isMounted = true; - }); - onBeforeUnmount(() => { - state.isUnmounting = true; - }); - return state; -} -const TransitionHookValidator = [Function, Array]; -const BaseTransitionImpl = { - name: `BaseTransition`, - props: { - mode: String, - appear: Boolean, - persisted: Boolean, - // enter - onBeforeEnter: TransitionHookValidator, - onEnter: TransitionHookValidator, - onAfterEnter: TransitionHookValidator, - onEnterCancelled: TransitionHookValidator, - // leave - onBeforeLeave: TransitionHookValidator, - onLeave: TransitionHookValidator, - onAfterLeave: TransitionHookValidator, - onLeaveCancelled: TransitionHookValidator, - // appear - onBeforeAppear: TransitionHookValidator, - onAppear: TransitionHookValidator, - onAfterAppear: TransitionHookValidator, - onAppearCancelled: TransitionHookValidator - }, - setup(props, { slots }) { - const instance = getCurrentInstance(); - const state = useTransitionState(); - let prevTransitionKey; - return () => { - const children = slots.default && getTransitionRawChildren(slots.default(), true); - if (!children || !children.length) { - return; - } - // warn multiple elements - if ((process.env.NODE_ENV !== 'production') && children.length > 1) { - warn(' can only be used on a single element or component. Use ' + - ' for lists.'); - } - // there's no need to track reactivity for these props so use the raw - // props for a bit better perf - const rawProps = toRaw(props); - const { mode } = rawProps; - // check mode - if ((process.env.NODE_ENV !== 'production') && mode && !['in-out', 'out-in', 'default'].includes(mode)) { - warn(`invalid mode: ${mode}`); - } - // at this point children has a guaranteed length of 1. - const child = children[0]; - if (state.isLeaving) { - return emptyPlaceholder(child); - } - // in the case of , we need to - // compare the type of the kept-alive children. - const innerChild = getKeepAliveChild(child); - if (!innerChild) { - return emptyPlaceholder(child); - } - const enterHooks = (innerChild.transition = resolveTransitionHooks(innerChild, rawProps, state, instance)); - const oldChild = instance.subTree; - const oldInnerChild = oldChild && getKeepAliveChild(oldChild); - let transitionKeyChanged = false; - const { getTransitionKey } = innerChild.type; - if (getTransitionKey) { - const key = getTransitionKey(); - if (prevTransitionKey === undefined) { - prevTransitionKey = key; - } - else if (key !== prevTransitionKey) { - prevTransitionKey = key; - transitionKeyChanged = true; - } - } - // handle mode - if (oldInnerChild && - oldInnerChild.type !== Comment && - (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) { - const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance); - // update old tree's hooks in case of dynamic transition - setTransitionHooks(oldInnerChild, leavingHooks); - // switching between different views - if (mode === 'out-in') { - state.isLeaving = true; - // return placeholder node and queue update when leave finishes - leavingHooks.afterLeave = () => { - state.isLeaving = false; - instance.update(); - }; - return emptyPlaceholder(child); - } - else if (mode === 'in-out') { - leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => { - const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild); - leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild; - // early removal callback - el._leaveCb = () => { - earlyRemove(); - el._leaveCb = undefined; - delete enterHooks.delayedLeave; - }; - enterHooks.delayedLeave = delayedLeave; - }; - } - } - return child; - }; - } -}; -// export the public type for h/tsx inference -// also to avoid inline import() in generated d.ts files -const BaseTransition = BaseTransitionImpl; -function getLeavingNodesForType(state, vnode) { - const { leavingVNodes } = state; - let leavingVNodesCache = leavingVNodes.get(vnode.type); - if (!leavingVNodesCache) { - leavingVNodesCache = Object.create(null); - leavingVNodes.set(vnode.type, leavingVNodesCache); - } - return leavingVNodesCache; -} -// The transition hooks are attached to the vnode as vnode.transition -// and will be called at appropriate timing in the renderer. -function resolveTransitionHooks(vnode, { appear, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled }, state, instance) { - const key = String(vnode.key); - const leavingVNodesCache = getLeavingNodesForType(state, vnode); - const callHook = (hook, args) => { - hook && - callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args); - }; - const hooks = { - persisted, - beforeEnter(el) { - let hook = onBeforeEnter; - if (!state.isMounted) { - if (appear) { - hook = onBeforeAppear || onBeforeEnter; - } - else { - return; - } - } - // for same element (v-show) - if (el._leaveCb) { - el._leaveCb(true /* cancelled */); - } - // for toggled element with same key (v-if) - const leavingVNode = leavingVNodesCache[key]; - if (leavingVNode && - isSameVNodeType(vnode, leavingVNode) && - leavingVNode.el._leaveCb) { - // force early removal (not cancelled) - leavingVNode.el._leaveCb(); - } - callHook(hook, [el]); - }, - enter(el) { - let hook = onEnter; - let afterHook = onAfterEnter; - let cancelHook = onEnterCancelled; - if (!state.isMounted) { - if (appear) { - hook = onAppear || onEnter; - afterHook = onAfterAppear || onAfterEnter; - cancelHook = onAppearCancelled || onEnterCancelled; - } - else { - return; - } - } - let called = false; - const done = (el._enterCb = (cancelled) => { - if (called) - return; - called = true; - if (cancelled) { - callHook(cancelHook, [el]); - } - else { - callHook(afterHook, [el]); - } - if (hooks.delayedLeave) { - hooks.delayedLeave(); - } - el._enterCb = undefined; - }); - if (hook) { - hook(el, done); - if (hook.length <= 1) { - done(); - } - } - else { - done(); - } - }, - leave(el, remove$$1) { - const key = String(vnode.key); - if (el._enterCb) { - el._enterCb(true /* cancelled */); - } - if (state.isUnmounting) { - return remove$$1(); - } - callHook(onBeforeLeave, [el]); - let called = false; - const done = (el._leaveCb = (cancelled) => { - if (called) - return; - called = true; - remove$$1(); - if (cancelled) { - callHook(onLeaveCancelled, [el]); - } - else { - callHook(onAfterLeave, [el]); - } - el._leaveCb = undefined; - if (leavingVNodesCache[key] === vnode) { - delete leavingVNodesCache[key]; - } - }); - leavingVNodesCache[key] = vnode; - if (onLeave) { - onLeave(el, done); - if (onLeave.length <= 1) { - done(); - } - } - else { - done(); - } - } - }; - return hooks; -} -// the placeholder really only handles one special case: KeepAlive -// in the case of a KeepAlive in a leave phase we need to return a KeepAlive -// placeholder with empty content to avoid the KeepAlive instance from being -// unmounted. -function emptyPlaceholder(vnode) { - if (isKeepAlive(vnode)) { - vnode = cloneVNode(vnode); - vnode.children = null; - return vnode; - } -} -function getKeepAliveChild(vnode) { - return isKeepAlive(vnode) - ? vnode.children - ? vnode.children[0] - : undefined - : vnode; -} -function setTransitionHooks(vnode, hooks) { - if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) { - setTransitionHooks(vnode.component.subTree, hooks); - } - else { - vnode.transition = hooks; - } -} -function getTransitionRawChildren(children, keepComment = false) { - let ret = []; - let keyedFragmentCount = 0; - for (let i = 0; i < children.length; i++) { - const child = children[i]; - // handle fragment children case, e.g. v-for - if (child.type === Fragment) { - if (child.patchFlag & 128 /* KEYED_FRAGMENT */) - keyedFragmentCount++; - ret = ret.concat(getTransitionRawChildren(child.children, keepComment)); - } - // comment placeholders should be skipped, e.g. v-if - else if (keepComment || child.type !== Comment) { - ret.push(child); - } - } - // #1126 if a transition children list contains multiple sub fragments, these - // fragments will be merged into a flat children array. Since each v-for - // fragment may contain different static bindings inside, we need to de-top - // these children to force full diffs to ensure correct behavior. - if (keyedFragmentCount > 1) { - for (let i = 0; i < ret.length; i++) { - ret[i].patchFlag = -2 /* BAIL */; - } - } - return ret; -} - -const isKeepAlive = (vnode) => vnode.type.__isKeepAlive; - -/** -Runtime helper for applying directives to a vnode. Example usage: - -const comp = resolveComponent('comp') -const foo = resolveDirective('foo') -const bar = resolveDirective('bar') - -return withDirectives(h(comp), [ - [foo, this.x], - [bar, this.y] -]) -*/ -const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text'); -function setDevtoolsHook(hook) { -} -const queuePostRenderEffect = queueEffectWithSuspense - ; -// initial value for watchers to trigger on undefined initial values -const INITIAL_WATCHER_VALUE = {}; -function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ, instance = currentInstance) { - if ((process.env.NODE_ENV !== 'production') && !cb) { - if (immediate !== undefined) { - warn(`watch() "immediate" option is only respected when using the ` + - `watch(source, callback, options?) signature.`); - } - if (deep !== undefined) { - warn(`watch() "deep" option is only respected when using the ` + - `watch(source, callback, options?) signature.`); - } - } - const warnInvalidSource = (s) => { - warn(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` + - `a reactive object, or an array of these types.`); - }; - let getter; - const isRefSource = isRef(source); - if (isRefSource) { - getter = () => source.value; - } - else if (isReactive(source)) { - getter = () => source; - deep = true; - } - else if (isArray(source)) { - getter = () => source.map(s => { - if (isRef(s)) { - return s.value; - } - else if (isReactive(s)) { - return traverse(s); - } - else if (isFunction(s)) { - return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */); - } - else { - (process.env.NODE_ENV !== 'production') && warnInvalidSource(s); - } - }); - } - else if (isFunction(source)) { - if (cb) { - // getter with cb - getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */); - } - else { - // no cb -> simple effect - getter = () => { - if (instance && instance.isUnmounted) { - return; - } - if (cleanup) { - cleanup(); - } - return callWithErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onInvalidate]); - }; - } - } - else { - getter = NOOP; - (process.env.NODE_ENV !== 'production') && warnInvalidSource(source); - } - if (cb && deep) { - const baseGetter = getter; - getter = () => traverse(baseGetter()); - } - let cleanup; - const onInvalidate = (fn) => { - cleanup = runner.options.onStop = () => { - callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */); - }; - }; - let oldValue = isArray(source) ? [] : INITIAL_WATCHER_VALUE; - const job = () => { - if (!runner.active) { - return; - } - if (cb) { - // watch(source, cb) - const newValue = runner(); - if (deep || isRefSource || hasChanged(newValue, oldValue)) { - // cleanup before running cb again - if (cleanup) { - cleanup(); - } - callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [ - newValue, - // pass undefined as the old value when it's changed for the first time - oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, - onInvalidate - ]); - oldValue = newValue; - } - } - else { - // watchEffect - runner(); - } - }; - // important: mark the job as a watcher callback so that scheduler knows it - // it is allowed to self-trigger (#1727) - job.allowRecurse = !!cb; - let scheduler; - if (flush === 'sync') { - scheduler = job; - } - else if (flush === 'pre') { - // ensure it's queued before component updates (which have positive ids) - job.id = -1; - scheduler = () => { - if (!instance || instance.isMounted) { - queuePreFlushCb(job); - } - else { - // with 'pre' option, the first call must happen before - // the component is mounted so it is called synchronously. - job(); - } - }; - } - else { - scheduler = () => queuePostRenderEffect(job, instance && instance.suspense); - } - const runner = effect(getter, { - lazy: true, - onTrack, - onTrigger, - scheduler - }); - recordInstanceBoundEffect(runner); - // initial run - if (cb) { - if (immediate) { - job(); - } - else { - oldValue = runner(); - } - } - else { - runner(); - } - return () => { - stop(runner); - if (instance) { - remove(instance.effects, runner); - } - }; -} -// this.$watch -function instanceWatch(source, cb, options) { - const publicThis = this.proxy; - const getter = isString(source) - ? () => publicThis[source] - : source.bind(publicThis); - return doWatch(getter, cb.bind(publicThis), options, this); -} -function traverse(value, seen = new Set()) { - if (!isObject(value) || seen.has(value)) { - return value; - } - seen.add(value); - if (isArray(value)) { - for (let i = 0; i < value.length; i++) { - traverse(value[i], seen); - } - } - else if (value instanceof Map) { - value.forEach((v, key) => { - // to register mutation dep for existing keys - traverse(value.get(key), seen); - }); - } - else if (value instanceof Set) { - value.forEach(v => { - traverse(v, seen); - }); - } - else { - for (const key in value) { - traverse(value[key], seen); - } - } - return value; -} -let isInBeforeCreate = false; -function resolveMergedOptions(instance) { - const raw = instance.type; - const { __merged, mixins, extends: extendsOptions } = raw; - if (__merged) - return __merged; - const globalMixins = instance.appContext.mixins; - if (!globalMixins.length && !mixins && !extendsOptions) - return raw; - const options = {}; - globalMixins.forEach(m => mergeOptions(options, m, instance)); - extendsOptions && mergeOptions(options, extendsOptions, instance); - mixins && mixins.forEach(m => mergeOptions(options, m, instance)); - mergeOptions(options, raw, instance); - return (raw.__merged = options); -} -function mergeOptions(to, from, instance) { - const strats = instance.appContext.config.optionMergeStrategies; - for (const key in from) { - if (strats && hasOwn(strats, key)) { - to[key] = strats[key](to[key], from[key], instance.proxy, key); - } - else if (!hasOwn(to, key)) { - to[key] = from[key]; - } - } -} - -const publicPropertiesMap = extend(Object.create(null), { - $: i => i, - $el: i => i.vnode.el, - $data: i => i.data, - $props: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.props) : i.props), - $attrs: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.attrs) : i.attrs), - $slots: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.slots) : i.slots), - $refs: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.refs) : i.refs), - $parent: i => i.parent && i.parent.proxy, - $root: i => i.root && i.root.proxy, - $emit: i => i.emit, - $options: i => (__VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type), - $forceUpdate: i => () => queueJob(i.update), - $nextTick: () => nextTick, - $watch: i => (__VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP) -}); -const PublicInstanceProxyHandlers = { - get({ _: instance }, key) { - const { ctx, setupState, data, props, accessCache, type, appContext } = instance; - // let @vue/reactivity know it should never observe Vue public instances. - if (key === "__v_skip" /* SKIP */) { - return true; - } - // data / props / ctx - // This getter gets called for every property access on the render context - // during render and is a major hotspot. The most expensive part of this - // is the multiple hasOwn() calls. It's much faster to do a simple property - // access on a plain object, so we use an accessCache object (with null - // prototype) to memoize what access type a key corresponds to. - let normalizedProps; - if (key[0] !== '$') { - const n = accessCache[key]; - if (n !== undefined) { - switch (n) { - case 0 /* SETUP */: - return setupState[key]; - case 1 /* DATA */: - return data[key]; - case 3 /* CONTEXT */: - return ctx[key]; - case 2 /* PROPS */: - return props[key]; - // default: just fallthrough - } - } - else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { - accessCache[key] = 0 /* SETUP */; - return setupState[key]; - } - else if (data !== EMPTY_OBJ && hasOwn(data, key)) { - accessCache[key] = 1 /* DATA */; - return data[key]; - } - else if ( - // only cache other properties when instance has declared (thus stable) - // props - (normalizedProps = normalizePropsOptions(type)[0]) && - hasOwn(normalizedProps, key)) { - accessCache[key] = 2 /* PROPS */; - return props[key]; - } - else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { - accessCache[key] = 3 /* CONTEXT */; - return ctx[key]; - } - else if (!__VUE_OPTIONS_API__ || !isInBeforeCreate) { - accessCache[key] = 4 /* OTHER */; - } - } - const publicGetter = publicPropertiesMap[key]; - let cssModule, globalProperties; - // public $xxx properties - if (publicGetter) { - if (key === '$attrs') { - track(instance, "get" /* GET */, key); - (process.env.NODE_ENV !== 'production') && markAttrsAccessed(); - } - return publicGetter(instance); - } - else if ( - // css module (injected by vue-loader) - (cssModule = type.__cssModules) && - (cssModule = cssModule[key])) { - return cssModule; - } - else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { - // user may set custom properties to `this` that start with `$` - accessCache[key] = 3 /* CONTEXT */; - return ctx[key]; - } - else if ( - // global properties - (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key))) { - return globalProperties[key]; - } - else if ((process.env.NODE_ENV !== 'production') && - currentRenderingInstance && - (!isString(key) || - // #1091 avoid internal isRef/isVNode checks on component instance leading - // to infinite warning loop - key.indexOf('__v') !== 0)) { - if (data !== EMPTY_OBJ && key[0] === '$' && hasOwn(data, key)) { - warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` + - `character and is not proxied on the render context.`); - } - else { - warn(`Property ${JSON.stringify(key)} was accessed during render ` + - `but is not defined on instance.`); - } - } - }, - set({ _: instance }, key, value) { - const { data, setupState, ctx } = instance; - if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { - setupState[key] = value; - } - else if (data !== EMPTY_OBJ && hasOwn(data, key)) { - data[key] = value; - } - else if (key in instance.props) { - (process.env.NODE_ENV !== 'production') && - warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance); - return false; - } - if (key[0] === '$' && key.slice(1) in instance) { - (process.env.NODE_ENV !== 'production') && - warn(`Attempting to mutate public property "${key}". ` + - `Properties starting with $ are reserved and readonly.`, instance); - return false; - } - else { - if ((process.env.NODE_ENV !== 'production') && key in instance.appContext.config.globalProperties) { - Object.defineProperty(ctx, key, { - enumerable: true, - configurable: true, - value - }); - } - else { - ctx[key] = value; - } - } - return true; - }, - has({ _: { data, setupState, accessCache, ctx, type, appContext } }, key) { - let normalizedProps; - return (accessCache[key] !== undefined || - (data !== EMPTY_OBJ && hasOwn(data, key)) || - (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) || - ((normalizedProps = normalizePropsOptions(type)[0]) && - hasOwn(normalizedProps, key)) || - hasOwn(ctx, key) || - hasOwn(publicPropertiesMap, key) || - hasOwn(appContext.config.globalProperties, key)); - } -}; -if ((process.env.NODE_ENV !== 'production') && !false) { - PublicInstanceProxyHandlers.ownKeys = (target) => { - warn(`Avoid app logic that relies on enumerating keys on a component instance. ` + - `The keys will be empty in production mode to avoid performance overhead.`); - return Reflect.ownKeys(target); - }; -} -const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, { - get(target, key) { - // fast path for unscopables when using `with` block - if (key === Symbol.unscopables) { - return; - } - return PublicInstanceProxyHandlers.get(target, key, target); - }, - has(_, key) { - const has = key[0] !== '_' && !isGloballyWhitelisted(key); - if ((process.env.NODE_ENV !== 'production') && !has && PublicInstanceProxyHandlers.has(_, key)) { - warn(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`); - } - return has; - } -}); -let currentInstance = null; -const getCurrentInstance = () => currentInstance || currentRenderingInstance; -const setCurrentInstance = (instance) => { - currentInstance = instance; -}; -const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component'); -let isInSSRComponentSetup = false; -// record effects created during a component's setup() so that they can be -// stopped when the component unmounts -function recordInstanceBoundEffect(effect$$1) { - if (currentInstance) { - (currentInstance.effects || (currentInstance.effects = [])).push(effect$$1); - } -} -const classifyRE = /(?:^|[-_])(\w)/g; -const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, ''); -/* istanbul ignore next */ -function formatComponentName(instance, Component, isRoot = false) { - let name = isFunction(Component) - ? Component.displayName || Component.name - : Component.name; - if (!name && Component.__file) { - const match = Component.__file.match(/([^/\\]+)\.vue$/); - if (match) { - name = match[1]; - } - } - if (!name && instance && instance.parent) { - // try to infer the name based on reverse resolution - const inferFromRegistry = (registry) => { - for (const key in registry) { - if (registry[key] === Component) { - return key; - } - } - }; - name = - inferFromRegistry(instance.parent.type.components) || inferFromRegistry(instance.appContext.components); - } - return name ? classify(name) : isRoot ? `App` : `Anonymous`; -} - -// implementation, close to no-op -function defineComponent(options) { - return isFunction(options) ? { setup: options, name: options.name } : options; -} - -// Actual implementation -function h(type, propsOrChildren, children) { - if (arguments.length === 2) { - if (isObject(propsOrChildren) && !isArray(propsOrChildren)) { - // single vnode without props - if (isVNode(propsOrChildren)) { - return createVNode(type, null, [propsOrChildren]); - } - // props without children - return createVNode(type, propsOrChildren); - } - else { - // omit props - return createVNode(type, null, propsOrChildren); - } - } - else { - if (isVNode(children)) { - children = [children]; - } - return createVNode(type, propsOrChildren, children); - } -} - -const ssrContextKey = Symbol((process.env.NODE_ENV !== 'production') ? `ssrContext` : ``); - -const svgNS = 'http://www.w3.org/2000/svg'; -const doc = (typeof document !== 'undefined' ? document : null); -let tempContainer; -let tempSVGContainer; -const nodeOps = { - insert: (child, parent, anchor) => { - parent.insertBefore(child, anchor || null); - }, - remove: child => { - const parent = child.parentNode; - if (parent) { - parent.removeChild(child); - } - }, - createElement: (tag, isSVG, is) => isSVG - ? doc.createElementNS(svgNS, tag) - : doc.createElement(tag, is ? { is } : undefined), - createText: text$$1 => doc.createTextNode(text$$1), - createComment: text$$1 => doc.createComment(text$$1), - setText: (node, text$$1) => { - node.nodeValue = text$$1; - }, - setElementText: (el, text$$1) => { - el.textContent = text$$1; - }, - parentNode: node => node.parentNode, - nextSibling: node => node.nextSibling, - querySelector: selector => doc.querySelector(selector), - setScopeId(el, id) { - el.setAttribute(id, ''); - }, - cloneNode(el) { - return el.cloneNode(true); - }, - // __UNSAFE__ - // Reason: innerHTML. - // Static content here can only come from compiled templates. - // As long as the user only uses trusted templates, this is safe. - insertStaticContent(content, parent, anchor, isSVG) { - const temp = isSVG - ? tempSVGContainer || - (tempSVGContainer = doc.createElementNS(svgNS, 'svg')) - : tempContainer || (tempContainer = doc.createElement('div')); - temp.innerHTML = content; - const first = temp.firstChild; - let node = first; - let last = node; - while (node) { - last = node; - nodeOps.insert(node, parent, anchor); - node = temp.firstChild; - } - return [first, last]; - } -}; - -// compiler should normalize class + :class bindings on the same element -// into a single binding ['staticClass', dynamic] -function patchClass(el, value, isSVG) { - if (value == null) { - value = ''; - } - if (isSVG) { - el.setAttribute('class', value); - } - else { - // directly setting className should be faster than setAttribute in theory - // if this is an element during a transition, take the temporary transition - // classes into account. - const transitionClasses = el._vtc; - if (transitionClasses) { - value = (value - ? [value, ...transitionClasses] - : [...transitionClasses]).join(' '); - } - el.className = value; - } -} - -function patchStyle(el, prev, next) { - const style = el.style; - if (!next) { - el.removeAttribute('style'); - } - else if (isString(next)) { - if (prev !== next) { - style.cssText = next; - } - } - else { - for (const key in next) { - setStyle(style, key, next[key]); - } - if (prev && !isString(prev)) { - for (const key in prev) { - if (next[key] == null) { - setStyle(style, key, ''); - } - } - } - } -} -const importantRE = /\s*!important$/; -function setStyle(style, name, val) { - if (isArray(val)) { - val.forEach(v => setStyle(style, name, v)); - } - else { - if (name.startsWith('--')) { - // custom property definition - style.setProperty(name, val); - } - else { - const prefixed = autoPrefix(style, name); - if (importantRE.test(val)) { - // !important - style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important'); - } - else { - style[prefixed] = val; - } - } - } -} -const prefixes = ['Webkit', 'Moz', 'ms']; -const prefixCache = {}; -function autoPrefix(style, rawName) { - const cached = prefixCache[rawName]; - if (cached) { - return cached; - } - let name = camelize(rawName); - if (name !== 'filter' && name in style) { - return (prefixCache[rawName] = name); - } - name = capitalize(name); - for (let i = 0; i < prefixes.length; i++) { - const prefixed = prefixes[i] + name; - if (prefixed in style) { - return (prefixCache[rawName] = prefixed); - } - } - return rawName; -} - -const xlinkNS = 'http://www.w3.org/1999/xlink'; -function patchAttr(el, key, value, isSVG) { - if (isSVG && key.startsWith('xlink:')) { - if (value == null) { - el.removeAttributeNS(xlinkNS, key.slice(6, key.length)); - } - else { - el.setAttributeNS(xlinkNS, key, value); - } - } - else { - // note we are only checking boolean attributes that don't have a - // corresponding dom prop of the same name here. - const isBoolean = isSpecialBooleanAttr(key); - if (value == null || (isBoolean && value === false)) { - el.removeAttribute(key); - } - else { - el.setAttribute(key, isBoolean ? '' : value); - } - } -} - -// __UNSAFE__ -// functions. The user is responsible for using them with only trusted content. -function patchDOMProp(el, key, value, -// the following args are passed only due to potential innerHTML/textContent -// overriding existing VNodes, in which case the old tree must be properly -// unmounted. -prevChildren, parentComponent, parentSuspense, unmountChildren) { - if (key === 'innerHTML' || key === 'textContent') { - if (prevChildren) { - unmountChildren(prevChildren, parentComponent, parentSuspense); - } - el[key] = value == null ? '' : value; - return; - } - if (key === 'value' && el.tagName !== 'PROGRESS') { - // store value as _value as well since - // non-string values will be stringified. - el._value = value; - el.value = value == null ? '' : value; - return; - } - if (value === '' && typeof el[key] === 'boolean') { - // e.g. with - // :true-value & :false-value - // store value as dom properties since non-string values will be - // stringified. - if (key === 'true-value') { - el._trueValue = nextValue; - } - else if (key === 'false-value') { - el._falseValue = nextValue; - } - patchAttr(el, key, nextValue, isSVG); - } - break; - } -}; -function shouldSetAsProp(el, key, value, isSVG) { - if (isSVG) { - // most keys must be set as attribute on svg elements to work - // ...except innerHTML - if (key === 'innerHTML') { - return true; - } - // or native onclick with function values - if (key in el && nativeOnRE.test(key) && isFunction(value)) { - return true; - } - return false; - } - // spellcheck and draggable are numerated attrs, however their - // corresponding DOM properties are actually booleans - this leads to - // setting it with a string "false" value leading it to be coerced to - // `true`, so we need to always treat them as attributes. - // Note that `contentEditable` doesn't have this problem: its DOM - // property is also enumerated string values. - if (key === 'spellcheck' || key === 'draggable') { - return false; - } - // #1787 form as an attribute must be a string, while it accepts an Element as - // a prop - if (key === 'form' && typeof value === 'string') { - return false; - } - // #1526 must be set as attribute - if (key === 'list' && el.tagName === 'INPUT') { - return false; - } - // native onclick with string value, must be set as attribute - if (nativeOnRE.test(key) && isString(value)) { - return false; - } - return key in el; -} - -const TRANSITION = 'transition'; -const ANIMATION = 'animation'; -// DOM Transition is a higher-order-component based on the platform-agnostic -// base Transition component, with DOM-specific logic. -const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots); -Transition.displayName = 'Transition'; -const DOMTransitionPropsValidators = { - name: String, - type: String, - css: { - type: Boolean, - default: true - }, - duration: [String, Number, Object], - enterFromClass: String, - enterActiveClass: String, - enterToClass: String, - appearFromClass: String, - appearActiveClass: String, - appearToClass: String, - leaveFromClass: String, - leaveActiveClass: String, - leaveToClass: String -}; -const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators)); -function resolveTransitionProps(rawProps) { - let { name = 'v', type, css = true, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps; - const baseProps = {}; - for (const key in rawProps) { - if (!(key in DOMTransitionPropsValidators)) { - baseProps[key] = rawProps[key]; - } - } - if (!css) { - return baseProps; - } - const durations = normalizeDuration(duration); - const enterDuration = durations && durations[0]; - const leaveDuration = durations && durations[1]; - const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps; - const finishEnter = (el, isAppear, done) => { - removeTransitionClass(el, isAppear ? appearToClass : enterToClass); - removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass); - done && done(); - }; - const finishLeave = (el, done) => { - removeTransitionClass(el, leaveToClass); - removeTransitionClass(el, leaveActiveClass); - done && done(); - }; - const makeEnterHook = (isAppear) => { - return (el, done) => { - const hook = isAppear ? onAppear : onEnter; - const resolve = () => finishEnter(el, isAppear, done); - hook && hook(el, resolve); - nextFrame(() => { - removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass); - addTransitionClass(el, isAppear ? appearToClass : enterToClass); - if (!(hook && hook.length > 1)) { - if (enterDuration) { - setTimeout(resolve, enterDuration); - } - else { - whenTransitionEnds(el, type, resolve); - } - } - }); - }; - }; - return extend(baseProps, { - onBeforeEnter(el) { - onBeforeEnter && onBeforeEnter(el); - addTransitionClass(el, enterActiveClass); - addTransitionClass(el, enterFromClass); - }, - onBeforeAppear(el) { - onBeforeAppear && onBeforeAppear(el); - addTransitionClass(el, appearActiveClass); - addTransitionClass(el, appearFromClass); - }, - onEnter: makeEnterHook(false), - onAppear: makeEnterHook(true), - onLeave(el, done) { - const resolve = () => finishLeave(el, done); - addTransitionClass(el, leaveActiveClass); - addTransitionClass(el, leaveFromClass); - nextFrame(() => { - removeTransitionClass(el, leaveFromClass); - addTransitionClass(el, leaveToClass); - if (!(onLeave && onLeave.length > 1)) { - if (leaveDuration) { - setTimeout(resolve, leaveDuration); - } - else { - whenTransitionEnds(el, type, resolve); - } - } - }); - onLeave && onLeave(el, resolve); - }, - onEnterCancelled(el) { - finishEnter(el, false); - onEnterCancelled && onEnterCancelled(el); - }, - onAppearCancelled(el) { - finishEnter(el, true); - onAppearCancelled && onAppearCancelled(el); - }, - onLeaveCancelled(el) { - finishLeave(el); - onLeaveCancelled && onLeaveCancelled(el); - } - }); -} -function normalizeDuration(duration) { - if (duration == null) { - return null; - } - else if (isObject(duration)) { - return [NumberOf(duration.enter), NumberOf(duration.leave)]; - } - else { - const n = NumberOf(duration); - return [n, n]; - } -} -function NumberOf(val) { - const res = toNumber(val); - if ((process.env.NODE_ENV !== 'production')) - validateDuration(res); - return res; -} -function validateDuration(val) { - if (typeof val !== 'number') { - warn(` explicit duration is not a valid number - ` + - `got ${JSON.stringify(val)}.`); - } - else if (isNaN(val)) { - warn(` explicit duration is NaN - ` + - 'the duration expression might be incorrect.'); - } -} -function addTransitionClass(el, cls) { - cls.split(/\s+/).forEach(c => c && el.classList.add(c)); - (el._vtc || - (el._vtc = new Set())).add(cls); -} -function removeTransitionClass(el, cls) { - cls.split(/\s+/).forEach(c => c && el.classList.remove(c)); - const { _vtc } = el; - if (_vtc) { - _vtc.delete(cls); - if (!_vtc.size) { - el._vtc = undefined; - } - } -} -function nextFrame(cb) { - requestAnimationFrame(() => { - requestAnimationFrame(cb); - }); -} -function whenTransitionEnds(el, expectedType, cb) { - const { type, timeout, propCount } = getTransitionInfo(el, expectedType); - if (!type) { - return cb(); - } - const endEvent = type + 'end'; - let ended = 0; - const end = () => { - el.removeEventListener(endEvent, onEnd); - cb(); - }; - const onEnd = (e) => { - if (e.target === el) { - if (++ended >= propCount) { - end(); - } - } - }; - setTimeout(() => { - if (ended < propCount) { - end(); - } - }, timeout + 1); - el.addEventListener(endEvent, onEnd); -} -function getTransitionInfo(el, expectedType) { - const styles = window.getComputedStyle(el); - // JSDOM may return undefined for transition properties - const getStyleProperties = (key) => (styles[key] || '').split(', '); - const transitionDelays = getStyleProperties(TRANSITION + 'Delay'); - const transitionDurations = getStyleProperties(TRANSITION + 'Duration'); - const transitionTimeout = getTimeout(transitionDelays, transitionDurations); - const animationDelays = getStyleProperties(ANIMATION + 'Delay'); - const animationDurations = getStyleProperties(ANIMATION + 'Duration'); - const animationTimeout = getTimeout(animationDelays, animationDurations); - let type = null; - let timeout = 0; - let propCount = 0; - /* istanbul ignore if */ - if (expectedType === TRANSITION) { - if (transitionTimeout > 0) { - type = TRANSITION; - timeout = transitionTimeout; - propCount = transitionDurations.length; - } - } - else if (expectedType === ANIMATION) { - if (animationTimeout > 0) { - type = ANIMATION; - timeout = animationTimeout; - propCount = animationDurations.length; - } - } - else { - timeout = Math.max(transitionTimeout, animationTimeout); - type = - timeout > 0 - ? transitionTimeout > animationTimeout - ? TRANSITION - : ANIMATION - : null; - propCount = type - ? type === TRANSITION - ? transitionDurations.length - : animationDurations.length - : 0; - } - const hasTransform = type === TRANSITION && - /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']); - return { - type, - timeout, - propCount, - hasTransform - }; -} -function getTimeout(delays, durations) { - while (delays.length < durations.length) { - delays = delays.concat(delays); - } - return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))); -} -// Old versions of Chromium (below 61.0.3163.100) formats floating pointer -// numbers in a locale-dependent way, using a comma instead of a dot. -// If comma is not replaced with a dot, the input will be rounded down -// (i.e. acting as a floor function) causing unexpected behaviors -function toMs(s) { - return Number(s.slice(0, -1).replace(',', '.')) * 1000; -} - -function toRaw$1(observed) { - return ((observed && toRaw$1(observed["__v_raw" /* RAW */])) || observed); -} - -const positionMap = new WeakMap(); -const newPositionMap = new WeakMap(); -const TransitionGroupImpl = { - name: 'TransitionGroup', - props: /*#__PURE__*/ extend({}, TransitionPropsValidators, { - tag: String, - moveClass: String - }), - setup(props, { slots }) { - const instance = getCurrentInstance(); - const state = useTransitionState(); - let prevChildren; - let children; - onUpdated(() => { - // children is guaranteed to exist after initial render - if (!prevChildren.length) { - return; - } - const moveClass = props.moveClass || `${props.name || 'v'}-move`; - if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) { - return; - } - // we divide the work into three loops to avoid mixing DOM reads and writes - // in each iteration - which helps prevent layout thrashing. - prevChildren.forEach(callPendingCbs); - prevChildren.forEach(recordPosition); - const movedChildren = prevChildren.filter(applyTranslation); - // force reflow to put everything in position - forceReflow(); - movedChildren.forEach(c => { - const el = c.el; - const style = el.style; - addTransitionClass(el, moveClass); - style.transform = style.webkitTransform = style.transitionDuration = ''; - const cb = (el._moveCb = (e) => { - if (e && e.target !== el) { - return; - } - if (!e || /transform$/.test(e.propertyName)) { - el.removeEventListener('transitionend', cb); - el._moveCb = null; - removeTransitionClass(el, moveClass); - } - }); - el.addEventListener('transitionend', cb); - }); - }); - return () => { - const rawProps = toRaw$1(props); - const cssTransitionProps = resolveTransitionProps(rawProps); - const tag = rawProps.tag || Fragment; - prevChildren = children; - children = slots.default ? getTransitionRawChildren(slots.default()) : []; - for (let i = 0; i < children.length; i++) { - const child = children[i]; - if (child.key != null) { - setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance)); - } - else if ((process.env.NODE_ENV !== 'production')) { - warn(` children must be keyed.`); - } - } - if (prevChildren) { - for (let i = 0; i < prevChildren.length; i++) { - const child = prevChildren[i]; - setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance)); - positionMap.set(child, child.el.getBoundingClientRect()); - } - } - return createVNode(tag, null, children); - }; - } -}; -function callPendingCbs(c) { - const el = c.el; - if (el._moveCb) { - el._moveCb(); - } - if (el._enterCb) { - el._enterCb(); - } -} -function recordPosition(c) { - newPositionMap.set(c, c.el.getBoundingClientRect()); -} -function applyTranslation(c) { - const oldPos = positionMap.get(c); - const newPos = newPositionMap.get(c); - const dx = oldPos.left - newPos.left; - const dy = oldPos.top - newPos.top; - if (dx || dy) { - const s = c.el.style; - s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`; - s.transitionDuration = '0s'; - return c; - } -} -// this is put in a dedicated function to avoid the line from being treeshaken -function forceReflow() { - return document.body.offsetHeight; -} -function hasCSSTransform(el, root, moveClass) { - // Detect whether an element with the move class applied has - // CSS transitions. Since the element may be inside an entering - // transition at this very moment, we make a clone of it and remove - // all other transition classes applied to ensure only the move class - // is applied. - const clone = el.cloneNode(); - if (el._vtc) { - el._vtc.forEach(cls => { - cls.split(/\s+/).forEach(c => c && clone.classList.remove(c)); - }); - } - moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c)); - clone.style.display = 'none'; - const container = (root.nodeType === 1 - ? root - : root.parentNode); - container.appendChild(clone); - const { hasTransform } = getTransitionInfo(clone); - container.removeChild(clone); - return hasTransform; -} - -const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps); - -function initDev() { - const target = getGlobalThis(); - target.__VUE__ = true; - setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__); - { - console.info(`You are running a development build of Vue.\n` + - `Make sure to use the production build (*.prod.js) when deploying for production.`); - } -} - -// This entry exports the runtime only, and is built as -(process.env.NODE_ENV !== 'production') && initDev(); - -var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; +var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; @@ -3582,10 +198,10 @@ var toConsumableArray = function (arr) { } }; -/** - * Converts a CSS style into a plain Javascript object. - * @param {String} style The style to converts into a plain Javascript object. - * @returns {Object} +/** + * Converts a CSS style into a plain Javascript object. + * @param {String} style The style to converts into a plain Javascript object. + * @returns {Object} */ function styleToObject(style) { return style.split(';').map(function (s) { @@ -3602,10 +218,10 @@ function styleToObject(style) { }, {}); } -/** - * Converts a CSS class list into a plain Javascript object. - * @param {Array} classes The class list to convert. - * @returns {Object} +/** + * Converts a CSS class list into a plain Javascript object. + * @param {Array} classes The class list to convert. + * @returns {Object} */ function classToObject(classes) { return classes.split(/\s+/).reduce(function (output, className) { @@ -3614,14 +230,14 @@ function classToObject(classes) { }, {}); } -/** - * Converts a FontAwesome abstract element of an icon into a Vue render function. - * @param {AbstractElement | String} abstractElement The element to convert. - * @param {Object} props The user-defined props. - * @param {Object} attrs The user-defined native HTML attributes. - * @returns {Function | String} +/** + * Converts a FontAwesome abstract element of an icon into a Vue render function. + * @param {AbstractElement | String} abstractElement The element to convert. + * @param {Object} props The user-defined props. + * @param {Object} attrs The user-defined native HTML attributes. + * @returns {Function | String} */ -function convert$1(abstractElement) { +function convert(abstractElement) { var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var attrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; @@ -3633,7 +249,7 @@ function convert$1(abstractElement) { // Converting abstract element children into Vue render functions, then we'll execute // them to retrieve VDOM elements var children = (abstractElement.children || []).map(function (child) { - return convert$1(child); + return convert(child); }).map(function (renderFn) { return typeof renderFn === 'string' ? renderFn : renderFn(); }); @@ -3834,7 +450,7 @@ var FontAwesomeIcon = defineComponent({ } var abstractElement = renderedIcon.abstract[0]; - return convert$1(abstractElement, {}, attrs); + return convert(abstractElement, {}, attrs); } }); @@ -3901,7 +517,7 @@ var FontAwesomeLayersText = defineComponent({ abstract[0].attributes.class = abstract[0].attributes.class.replace('fa-layers-text', ''); } - return convert$1(abstract[0], {}, attrs); + return convert(abstract[0], {}, attrs); } }); diff --git a/index.js b/index.js index 1958a961..29dfd41e 100644 --- a/index.js +++ b/index.js @@ -1,3918 +1,533 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@fortawesome/fontawesome-svg-core')) : - typeof define === 'function' && define.amd ? define(['exports', '@fortawesome/fontawesome-svg-core'], factory) : - (factory((global['vue-fontawesome'] = {}),global.FontAwesome)); -}(this, (function (exports,fontawesomeSvgCore) { 'use strict'; - - /** - * Make a map and return a function for checking if a key - * is in that map. - * IMPORTANT: all calls of this function must be prefixed with - * \/\*#\_\_PURE\_\_\*\/ - * So that rollup can tree-shake them if necessary. - */ - function makeMap(str, expectsLowerCase) { - const map = Object.create(null); - const list = str.split(','); - for (let i = 0; i < list.length; i++) { - map[list[i]] = true; - } - return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; - } - - const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' + - 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' + - 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl'; - const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED); - - /** - * On the client we only need to offer special cases for boolean attributes that - * have different names from their corresponding dom properties: - * - itemscope -> N/A - * - allowfullscreen -> allowFullscreen - * - formnovalidate -> formNoValidate - * - ismap -> isMap - * - nomodule -> noModule - * - novalidate -> noValidate - * - readonly -> readOnly - */ - const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; - const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs); - /** - * The full list is needed during SSR to produce the correct initial markup. - */ - const isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs + - `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` + - `loop,open,required,reversed,scoped,seamless,` + - `checked,muted,multiple,selected`); - /** - * CSS properties that accept plain numbers - */ - const isNoUnitNumericStyleProp = /*#__PURE__*/ makeMap(`animation-iteration-count,border-image-outset,border-image-slice,` + - `border-image-width,box-flex,box-flex-group,box-ordinal-group,column-count,` + - `columns,flex,flex-grow,flex-positive,flex-shrink,flex-negative,flex-order,` + - `grid-row,grid-row-end,grid-row-span,grid-row-start,grid-column,` + - `grid-column-end,grid-column-span,grid-column-start,font-weight,line-clamp,` + - `line-height,opacity,order,orphans,tab-size,widows,z-index,zoom,` + - // SVG - `fill-opacity,flood-opacity,stop-opacity,stroke-dasharray,stroke-dashoffset,` + - `stroke-miterlimit,stroke-opacity,stroke-width`); - /** - * Known attributes, this is used for stringification of runtime static nodes - * so that we don't stringify bindings that cannot be set from HTML. - * Don't also forget to allow `data-*` and `aria-*`! - * Generated from https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes - */ - const isKnownAttr = /*#__PURE__*/ makeMap(`accept,accept-charset,accesskey,action,align,allow,alt,async,` + - `autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,` + - `border,buffered,capture,challenge,charset,checked,cite,class,code,` + - `codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,` + - `coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,` + - `disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,` + - `formaction,formenctype,formmethod,formnovalidate,formtarget,headers,` + - `height,hidden,high,href,hreflang,http-equiv,icon,id,importance,integrity,` + - `ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,` + - `manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,` + - `open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,` + - `referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` + - `selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` + - `start,step,style,summary,tabindex,target,title,translate,type,usemap,` + - `value,width,wrap`); - - function normalizeStyle(value) { - if (isArray(value)) { - const res = {}; - for (let i = 0; i < value.length; i++) { - const item = value[i]; - const normalized = normalizeStyle(isString(item) ? parseStringStyle(item) : item); - if (normalized) { - for (const key in normalized) { - res[key] = normalized[key]; - } - } - } - return res; - } - else if (isObject(value)) { - return value; - } - } - const listDelimiterRE = /;(?![^(]*\))/g; - const propertyDelimiterRE = /:(.+)/; - function parseStringStyle(cssText) { - const ret = {}; - cssText.split(listDelimiterRE).forEach(item => { - if (item) { - const tmp = item.split(propertyDelimiterRE); - tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); - } - }); - return ret; - } - function normalizeClass(value) { - let res = ''; - if (isString(value)) { - res = value; - } - else if (isArray(value)) { - for (let i = 0; i < value.length; i++) { - res += normalizeClass(value[i]) + ' '; - } - } - else if (isObject(value)) { - for (const name in value) { - if (value[name]) { - res += name + ' '; - } - } - } - return res.trim(); - } - - // These tag configs are shared between compiler-dom and runtime-dom, so they - // https://developer.mozilla.org/en-US/docs/Web/HTML/Element - const HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' + - 'header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,' + - 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' + - 'data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,' + - 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' + - 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' + - 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' + - 'option,output,progress,select,textarea,details,dialog,menu,' + - 'summary,template,blockquote,iframe,tfoot'; - // https://developer.mozilla.org/en-US/docs/Web/SVG/Element - const SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' + - 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' + - 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' + - 'feDistanceLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' + - 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' + - 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' + - 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' + - 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' + - 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' + - 'text,textPath,title,tspan,unknown,use,view'; - const VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr'; - const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS); - const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS); - const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS); - const EMPTY_OBJ = (process.env.NODE_ENV !== 'production') - ? Object.freeze({}) - : {}; - const EMPTY_ARR = []; - const NOOP = () => { }; - const onRE = /^on[^a-z]/; - const isOn = (key) => onRE.test(key); - const isModelListener = (key) => key.startsWith('onUpdate:'); - const extend = Object.assign; - const remove = (arr, el) => { - const i = arr.indexOf(el); - if (i > -1) { - arr.splice(i, 1); - } - }; - const hasOwnProperty = Object.prototype.hasOwnProperty; - const hasOwn = (val, key) => hasOwnProperty.call(val, key); - const isArray = Array.isArray; - const isFunction = (val) => typeof val === 'function'; - const isString = (val) => typeof val === 'string'; - const isSymbol = (val) => typeof val === 'symbol'; - const isObject = (val) => val !== null && typeof val === 'object'; - const isPromise = (val) => { - return isObject(val) && isFunction(val.then) && isFunction(val.catch); - }; - const objectToString = Object.prototype.toString; - const toTypeString = (value) => objectToString.call(value); - const toRawType = (value) => { - return toTypeString(value).slice(8, -1); - }; - const isReservedProp = /*#__PURE__*/ makeMap('key,ref,' + - 'onVnodeBeforeMount,onVnodeMounted,' + - 'onVnodeBeforeUpdate,onVnodeUpdated,' + - 'onVnodeBeforeUnmount,onVnodeUnmounted'); - const cacheStringFunction = (fn) => { - const cache = Object.create(null); - return ((str) => { - const hit = cache[str]; - return hit || (cache[str] = fn(str)); - }); - }; - const camelizeRE = /-(\w)/g; - /** - * @private - */ - const camelize = cacheStringFunction((str) => { - return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : '')); - }); - const hyphenateRE = /\B([A-Z])/g; - /** - * @private - */ - const hyphenate = cacheStringFunction((str) => { - return str.replace(hyphenateRE, '-$1').toLowerCase(); - }); - /** - * @private - */ - const capitalize = cacheStringFunction((str) => { - return str.charAt(0).toUpperCase() + str.slice(1); - }); - // compare whether a value has changed, accounting for NaN. - const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); - const def = (obj, key, value) => { - Object.defineProperty(obj, key, { - configurable: true, - enumerable: false, - value - }); - }; - const toNumber = (val) => { - const n = parseFloat(val); - return isNaN(n) ? val : n; - }; - let _globalThis; - const getGlobalThis = () => { - return (_globalThis || - (_globalThis = - typeof globalThis !== 'undefined' - ? globalThis - : typeof self !== 'undefined' - ? self - : typeof window !== 'undefined' - ? window - : typeof global !== 'undefined' - ? global - : {})); - }; - - const targetMap = new WeakMap(); - const effectStack = []; - let activeEffect; - const ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'iterate' : ''); - const MAP_KEY_ITERATE_KEY = Symbol((process.env.NODE_ENV !== 'production') ? 'Map key iterate' : ''); - function isEffect(fn) { - return fn && fn._isEffect === true; - } - function effect(fn, options = EMPTY_OBJ) { - if (isEffect(fn)) { - fn = fn.raw; - } - const effect = createReactiveEffect(fn, options); - if (!options.lazy) { - effect(); - } - return effect; - } - function stop(effect) { - if (effect.active) { - cleanup(effect); - if (effect.options.onStop) { - effect.options.onStop(); - } - effect.active = false; - } - } - let uid = 0; - function createReactiveEffect(fn, options) { - const effect = function reactiveEffect() { - if (!effect.active) { - return options.scheduler ? undefined : fn(); - } - if (!effectStack.includes(effect)) { - cleanup(effect); - try { - enableTracking(); - effectStack.push(effect); - activeEffect = effect; - return fn(); - } - finally { - effectStack.pop(); - resetTracking(); - activeEffect = effectStack[effectStack.length - 1]; - } - } - }; - effect.id = uid++; - effect._isEffect = true; - effect.active = true; - effect.raw = fn; - effect.deps = []; - effect.options = options; - return effect; - } - function cleanup(effect) { - const { deps } = effect; - if (deps.length) { - for (let i = 0; i < deps.length; i++) { - deps[i].delete(effect); - } - deps.length = 0; - } - } - let shouldTrack = true; - const trackStack = []; - function pauseTracking() { - trackStack.push(shouldTrack); - shouldTrack = false; - } - function enableTracking() { - trackStack.push(shouldTrack); - shouldTrack = true; - } - function resetTracking() { - const last = trackStack.pop(); - shouldTrack = last === undefined ? true : last; - } - function track(target, type, key) { - if (!shouldTrack || activeEffect === undefined) { - return; - } - let depsMap = targetMap.get(target); - if (!depsMap) { - targetMap.set(target, (depsMap = new Map())); - } - let dep = depsMap.get(key); - if (!dep) { - depsMap.set(key, (dep = new Set())); - } - if (!dep.has(activeEffect)) { - dep.add(activeEffect); - activeEffect.deps.push(dep); - if ((process.env.NODE_ENV !== 'production') && activeEffect.options.onTrack) { - activeEffect.options.onTrack({ - effect: activeEffect, - target, - type, - key - }); - } - } - } - function trigger(target, type, key, newValue, oldValue, oldTarget) { - const depsMap = targetMap.get(target); - if (!depsMap) { - // never been tracked - return; - } - const effects = new Set(); - const add = (effectsToAdd) => { - if (effectsToAdd) { - effectsToAdd.forEach(effect => { - if (effect !== activeEffect) { - effects.add(effect); - } - }); - } - }; - if (type === "clear" /* CLEAR */) { - // collection being cleared - // trigger all effects for target - depsMap.forEach(add); - } - else if (key === 'length' && isArray(target)) { - depsMap.forEach((dep, key) => { - if (key === 'length' || key >= newValue) { - add(dep); - } - }); - } - else { - // schedule runs for SET | ADD | DELETE - if (key !== void 0) { - add(depsMap.get(key)); - } - // also run for iteration key on ADD | DELETE | Map.SET - const isAddOrDelete = type === "add" /* ADD */ || - (type === "delete" /* DELETE */ && !isArray(target)); - if (isAddOrDelete || - (type === "set" /* SET */ && target instanceof Map)) { - add(depsMap.get(isArray(target) ? 'length' : ITERATE_KEY)); - } - if (isAddOrDelete && target instanceof Map) { - add(depsMap.get(MAP_KEY_ITERATE_KEY)); - } - } - const run = (effect) => { - if ((process.env.NODE_ENV !== 'production') && effect.options.onTrigger) { - effect.options.onTrigger({ - effect, - target, - key, - type, - newValue, - oldValue, - oldTarget - }); - } - if (effect.options.scheduler) { - effect.options.scheduler(effect); - } - else { - effect(); - } - }; - effects.forEach(run); - } - - const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol) - .map(key => Symbol[key]) - .filter(isSymbol)); - const get = /*#__PURE__*/ createGetter(); - const shallowGet = /*#__PURE__*/ createGetter(false, true); - const readonlyGet = /*#__PURE__*/ createGetter(true); - const shallowReadonlyGet = /*#__PURE__*/ createGetter(true, true); - const arrayInstrumentations = {}; - ['includes', 'indexOf', 'lastIndexOf'].forEach(key => { - arrayInstrumentations[key] = function (...args) { - const arr = toRaw(this); - for (let i = 0, l = this.length; i < l; i++) { - track(arr, "get" /* GET */, i + ''); - } - // we run the method using the original args first (which may be reactive) - const res = arr[key](...args); - if (res === -1 || res === false) { - // if that didn't work, run it again using raw values. - return arr[key](...args.map(toRaw)); - } - else { - return res; - } - }; - }); - function createGetter(isReadonly = false, shallow = false) { - return function get(target, key, receiver) { - if (key === "__v_isReactive" /* IS_REACTIVE */) { - return !isReadonly; - } - else if (key === "__v_isReadonly" /* IS_READONLY */) { - return isReadonly; - } - else if (key === "__v_raw" /* RAW */ && - receiver === - (isReadonly - ? target["__v_readonly" /* READONLY */] - : target["__v_reactive" /* REACTIVE */])) { - return target; - } - const targetIsArray = isArray(target); - if (targetIsArray && hasOwn(arrayInstrumentations, key)) { - return Reflect.get(arrayInstrumentations, key, receiver); - } - const res = Reflect.get(target, key, receiver); - if (isSymbol(key) - ? builtInSymbols.has(key) - : key === `__proto__` || key === `__v_isRef`) { - return res; - } - if (!isReadonly) { - track(target, "get" /* GET */, key); - } - if (shallow) { - return res; - } - if (isRef(res)) { - // ref unwrapping, only for Objects, not for Arrays. - return targetIsArray ? res : res.value; - } - if (isObject(res)) { - // Convert returned value into a proxy as well. we do the isObject check - // here to avoid invalid value warning. Also need to lazy access readonly - // and reactive here to avoid circular dependency. - return isReadonly ? readonly(res) : reactive(res); - } - return res; - }; - } - const set = /*#__PURE__*/ createSetter(); - const shallowSet = /*#__PURE__*/ createSetter(true); - function createSetter(shallow = false) { - return function set(target, key, value, receiver) { - const oldValue = target[key]; - if (!shallow) { - value = toRaw(value); - if (!isArray(target) && isRef(oldValue) && !isRef(value)) { - oldValue.value = value; - return true; - } - } - const hadKey = hasOwn(target, key); - const result = Reflect.set(target, key, value, receiver); - // don't trigger if target is something up in the prototype chain of original - if (target === toRaw(receiver)) { - if (!hadKey) { - trigger(target, "add" /* ADD */, key, value); - } - else if (hasChanged(value, oldValue)) { - trigger(target, "set" /* SET */, key, value, oldValue); - } - } - return result; - }; - } - function deleteProperty(target, key) { - const hadKey = hasOwn(target, key); - const oldValue = target[key]; - const result = Reflect.deleteProperty(target, key); - if (result && hadKey) { - trigger(target, "delete" /* DELETE */, key, undefined, oldValue); - } - return result; - } - function has(target, key) { - const result = Reflect.has(target, key); - if (!isSymbol(key) || !builtInSymbols.has(key)) { - track(target, "has" /* HAS */, key); - } - return result; - } - function ownKeys(target) { - track(target, "iterate" /* ITERATE */, ITERATE_KEY); - return Reflect.ownKeys(target); - } - const mutableHandlers = { - get, - set, - deleteProperty, - has, - ownKeys - }; - const readonlyHandlers = { - get: readonlyGet, - has, - ownKeys, - set(target, key) { - if ((process.env.NODE_ENV !== 'production')) { - console.warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target); - } - return true; - }, - deleteProperty(target, key) { - if ((process.env.NODE_ENV !== 'production')) { - console.warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); - } - return true; - } - }; - const shallowReactiveHandlers = extend({}, mutableHandlers, { - get: shallowGet, - set: shallowSet - }); - // Props handlers are special in the sense that it should not unwrap top-level - // refs (in order to allow refs to be explicitly passed down), but should - // retain the reactivity of the normal readonly object. - const shallowReadonlyHandlers = extend({}, readonlyHandlers, { - get: shallowReadonlyGet - }); - - const toReactive = (value) => isObject(value) ? reactive(value) : value; - const toReadonly = (value) => isObject(value) ? readonly(value) : value; - const toShallow = (value) => value; - const getProto = (v) => Reflect.getPrototypeOf(v); - function get$1(target, key, isReadonly = false, isShallow = false) { - // #1772: readonly(reactive(Map)) should return readonly + reactive version - // of the value - target = target["__v_raw" /* RAW */]; - const rawTarget = toRaw(target); - const rawKey = toRaw(key); - if (key !== rawKey) { - !isReadonly && track(rawTarget, "get" /* GET */, key); - } - !isReadonly && track(rawTarget, "get" /* GET */, rawKey); - const { has } = getProto(rawTarget); - const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - if (has.call(rawTarget, key)) { - return wrap(target.get(key)); - } - else if (has.call(rawTarget, rawKey)) { - return wrap(target.get(rawKey)); - } - } - function has$1(key, isReadonly = false) { - const target = this["__v_raw" /* RAW */]; - const rawTarget = toRaw(target); - const rawKey = toRaw(key); - if (key !== rawKey) { - !isReadonly && track(rawTarget, "has" /* HAS */, key); - } - !isReadonly && track(rawTarget, "has" /* HAS */, rawKey); - return target.has(key) || target.has(rawKey); - } - function size(target, isReadonly = false) { - target = target["__v_raw" /* RAW */]; - !isReadonly && track(toRaw(target), "iterate" /* ITERATE */, ITERATE_KEY); - return Reflect.get(target, 'size', target); - } - function add(value) { - value = toRaw(value); - const target = toRaw(this); - const proto = getProto(target); - const hadKey = proto.has.call(target, value); - const result = proto.add.call(target, value); - if (!hadKey) { - trigger(target, "add" /* ADD */, value, value); - } - return result; - } - function set$1(key, value) { - value = toRaw(value); - const target = toRaw(this); - const { has, get, set } = getProto(target); - let hadKey = has.call(target, key); - if (!hadKey) { - key = toRaw(key); - hadKey = has.call(target, key); - } - else if ((process.env.NODE_ENV !== 'production')) { - checkIdentityKeys(target, has, key); - } - const oldValue = get.call(target, key); - const result = set.call(target, key, value); - if (!hadKey) { - trigger(target, "add" /* ADD */, key, value); - } - else if (hasChanged(value, oldValue)) { - trigger(target, "set" /* SET */, key, value, oldValue); - } - return result; - } - function deleteEntry(key) { - const target = toRaw(this); - const { has, get, delete: del } = getProto(target); - let hadKey = has.call(target, key); - if (!hadKey) { - key = toRaw(key); - hadKey = has.call(target, key); - } - else if ((process.env.NODE_ENV !== 'production')) { - checkIdentityKeys(target, has, key); - } - const oldValue = get ? get.call(target, key) : undefined; - // forward the operation before queueing reactions - const result = del.call(target, key); - if (hadKey) { - trigger(target, "delete" /* DELETE */, key, undefined, oldValue); - } - return result; - } - function clear() { - const target = toRaw(this); - const hadItems = target.size !== 0; - const oldTarget = (process.env.NODE_ENV !== 'production') - ? target instanceof Map - ? new Map(target) - : new Set(target) - : undefined; - // forward the operation before queueing reactions - const result = getProto(target).clear.call(target); - if (hadItems) { - trigger(target, "clear" /* CLEAR */, undefined, undefined, oldTarget); - } - return result; - } - function createForEach(isReadonly, isShallow) { - return function forEach(callback, thisArg) { - const observed = this; - const target = toRaw(observed); - const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - !isReadonly && track(target, "iterate" /* ITERATE */, ITERATE_KEY); - // important: create sure the callback is - // 1. invoked with the reactive map as `this` and 3rd arg - // 2. the value received should be a corresponding reactive/readonly. - function wrappedCallback(value, key) { - return callback.call(thisArg, wrap(value), wrap(key), observed); - } - return getProto(target).forEach.call(target, wrappedCallback); - }; - } - function createIterableMethod(method, isReadonly, isShallow) { - return function (...args) { - const target = this["__v_raw" /* RAW */]; - const rawTarget = toRaw(target); - const isMap = rawTarget instanceof Map; - const isPair = method === 'entries' || (method === Symbol.iterator && isMap); - const isKeyOnly = method === 'keys' && isMap; - const innerIterator = target[method](...args); - const wrap = isReadonly ? toReadonly : isShallow ? toShallow : toReactive; - !isReadonly && - track(rawTarget, "iterate" /* ITERATE */, isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); - // return a wrapped iterator which returns observed versions of the - // values emitted from the real iterator - return { - // iterator protocol - next() { - const { value, done } = innerIterator.next(); - return done - ? { value, done } - : { - value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), - done - }; - }, - // iterable protocol - [Symbol.iterator]() { - return this; - } - }; - }; - } - function createReadonlyMethod(type) { - return function (...args) { - if ((process.env.NODE_ENV !== 'production')) { - const key = args[0] ? `on key "${args[0]}" ` : ``; - console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); - } - return type === "delete" /* DELETE */ ? false : this; - }; - } - const mutableInstrumentations = { - get(key) { - return get$1(this, key); - }, - get size() { - return size(this); - }, - has: has$1, - add, - set: set$1, - delete: deleteEntry, - clear, - forEach: createForEach(false, false) - }; - const shallowInstrumentations = { - get(key) { - return get$1(this, key, false, true); - }, - get size() { - return size(this); - }, - has: has$1, - add, - set: set$1, - delete: deleteEntry, - clear, - forEach: createForEach(false, true) - }; - const readonlyInstrumentations = { - get(key) { - return get$1(this, key, true); - }, - get size() { - return size(this, true); - }, - has(key) { - return has$1.call(this, key, true); - }, - add: createReadonlyMethod("add" /* ADD */), - set: createReadonlyMethod("set" /* SET */), - delete: createReadonlyMethod("delete" /* DELETE */), - clear: createReadonlyMethod("clear" /* CLEAR */), - forEach: createForEach(true, false) - }; - const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]; - iteratorMethods.forEach(method => { - mutableInstrumentations[method] = createIterableMethod(method, false, false); - readonlyInstrumentations[method] = createIterableMethod(method, true, false); - shallowInstrumentations[method] = createIterableMethod(method, false, true); - }); - function createInstrumentationGetter(isReadonly, shallow) { - const instrumentations = shallow - ? shallowInstrumentations - : isReadonly - ? readonlyInstrumentations - : mutableInstrumentations; - return (target, key, receiver) => { - if (key === "__v_isReactive" /* IS_REACTIVE */) { - return !isReadonly; - } - else if (key === "__v_isReadonly" /* IS_READONLY */) { - return isReadonly; - } - else if (key === "__v_raw" /* RAW */) { - return target; - } - return Reflect.get(hasOwn(instrumentations, key) && key in target - ? instrumentations - : target, key, receiver); - }; - } - const mutableCollectionHandlers = { - get: createInstrumentationGetter(false, false) - }; - const readonlyCollectionHandlers = { - get: createInstrumentationGetter(true, false) - }; - function checkIdentityKeys(target, has, key) { - const rawKey = toRaw(key); - if (rawKey !== key && has.call(target, rawKey)) { - const type = toRawType(target); - console.warn(`Reactive ${type} contains both the raw and reactive ` + - `versions of the same object${type === `Map` ? `as keys` : ``}, ` + - `which can lead to inconsistencies. ` + - `Avoid differentiating between the raw and reactive versions ` + - `of an object and only use the reactive version if possible.`); - } - } - - function targetTypeMap(rawType) { - switch (rawType) { - case 'Object': - case 'Array': - return 1 /* COMMON */; - case 'Map': - case 'Set': - case 'WeakMap': - case 'WeakSet': - return 2 /* COLLECTION */; - default: - return 0 /* INVALID */; - } - } - function getTargetType(value) { - return value["__v_skip" /* SKIP */] || !Object.isExtensible(value) - ? 0 /* INVALID */ - : targetTypeMap(toRawType(value)); - } - function reactive(target) { - // if trying to observe a readonly proxy, return the readonly version. - if (target && target["__v_isReadonly" /* IS_READONLY */]) { - return target; - } - return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers); - } - function readonly(target) { - return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers); - } - // Return a reactive-copy of the original object, where only the root level - // properties are readonly, and does NOT unwrap refs nor recursively convert - // returned properties. - // This is used for creating the props proxy object for stateful components. - function shallowReadonly(target) { - return createReactiveObject(target, true, shallowReadonlyHandlers, readonlyCollectionHandlers); - } - function createReactiveObject(target, isReadonly, baseHandlers, collectionHandlers) { - if (!isObject(target)) { - if ((process.env.NODE_ENV !== 'production')) { - console.warn(`value cannot be made reactive: ${String(target)}`); - } - return target; - } - // target is already a Proxy, return it. - // exception: calling readonly() on a reactive object - if (target["__v_raw" /* RAW */] && - !(isReadonly && target["__v_isReactive" /* IS_REACTIVE */])) { - return target; - } - // target already has corresponding Proxy - const reactiveFlag = isReadonly - ? "__v_readonly" /* READONLY */ - : "__v_reactive" /* REACTIVE */; - if (hasOwn(target, reactiveFlag)) { - return target[reactiveFlag]; - } - // only a whitelist of value types can be observed. - const targetType = getTargetType(target); - if (targetType === 0 /* INVALID */) { - return target; - } - const observed = new Proxy(target, targetType === 2 /* COLLECTION */ ? collectionHandlers : baseHandlers); - def(target, reactiveFlag, observed); - return observed; - } - function isReactive(value) { - if (isReadonly(value)) { - return isReactive(value["__v_raw" /* RAW */]); - } - return !!(value && value["__v_isReactive" /* IS_REACTIVE */]); - } - function isReadonly(value) { - return !!(value && value["__v_isReadonly" /* IS_READONLY */]); - } - function isProxy(value) { - return isReactive(value) || isReadonly(value); - } - function toRaw(observed) { - return ((observed && toRaw(observed["__v_raw" /* RAW */])) || observed); - } - function isRef(r) { - return r ? r.__v_isRef === true : false; - } - - const stack = []; - function pushWarningContext(vnode) { - stack.push(vnode); - } - function popWarningContext() { - stack.pop(); - } - function warn(msg, ...args) { - // avoid props formatting or warn handler tracking deps that might be mutated - // during patch, leading to infinite recursion. - pauseTracking(); - const instance = stack.length ? stack[stack.length - 1].component : null; - const appWarnHandler = instance && instance.appContext.config.warnHandler; - const trace = getComponentTrace(); - if (appWarnHandler) { - callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [ - msg + args.join(''), - instance && instance.proxy, - trace - .map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`) - .join('\n'), - trace - ]); - } - else { - const warnArgs = [`[Vue warn]: ${msg}`, ...args]; - /* istanbul ignore if */ - if (trace.length && - // avoid spamming console during tests - !false) { - warnArgs.push(`\n`, ...formatTrace(trace)); - } - console.warn(...warnArgs); - } - resetTracking(); - } - function getComponentTrace() { - let currentVNode = stack[stack.length - 1]; - if (!currentVNode) { - return []; - } - // we can't just use the stack because it will be incomplete during updates - // that did not start from the root. Re-construct the parent chain using - // instance parent pointers. - const normalizedStack = []; - while (currentVNode) { - const last = normalizedStack[0]; - if (last && last.vnode === currentVNode) { - last.recurseCount++; - } - else { - normalizedStack.push({ - vnode: currentVNode, - recurseCount: 0 - }); - } - const parentInstance = currentVNode.component && currentVNode.component.parent; - currentVNode = parentInstance && parentInstance.vnode; - } - return normalizedStack; - } - /* istanbul ignore next */ - function formatTrace(trace) { - const logs = []; - trace.forEach((entry, i) => { - logs.push(...(i === 0 ? [] : [`\n`]), ...formatTraceEntry(entry)); - }); - return logs; - } - function formatTraceEntry({ vnode, recurseCount }) { - const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``; - const isRoot = vnode.component ? vnode.component.parent == null : false; - const open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`; - const close = `>` + postfix; - return vnode.props - ? [open, ...formatProps(vnode.props), close] - : [open + close]; - } - /* istanbul ignore next */ - function formatProps(props) { - const res = []; - const keys = Object.keys(props); - keys.slice(0, 3).forEach(key => { - res.push(...formatProp(key, props[key])); - }); - if (keys.length > 3) { - res.push(` ...`); - } - return res; - } - /* istanbul ignore next */ - function formatProp(key, value, raw) { - if (isString(value)) { - value = JSON.stringify(value); - return raw ? value : [`${key}=${value}`]; - } - else if (typeof value === 'number' || - typeof value === 'boolean' || - value == null) { - return raw ? value : [`${key}=${value}`]; - } - else if (isRef(value)) { - value = formatProp(key, toRaw(value.value), true); - return raw ? value : [`${key}=Ref<`, value, `>`]; - } - else if (isFunction(value)) { - return [`${key}=fn${value.name ? `<${value.name}>` : ``}`]; - } - else { - value = toRaw(value); - return raw ? value : [`${key}=`, value]; - } - } - - const ErrorTypeStrings = { - ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook', - ["c" /* CREATED */]: 'created hook', - ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook', - ["m" /* MOUNTED */]: 'mounted hook', - ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook', - ["u" /* UPDATED */]: 'updated', - ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook', - ["um" /* UNMOUNTED */]: 'unmounted hook', - ["a" /* ACTIVATED */]: 'activated hook', - ["da" /* DEACTIVATED */]: 'deactivated hook', - ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook', - ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook', - ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook', - [0 /* SETUP_FUNCTION */]: 'setup function', - [1 /* RENDER_FUNCTION */]: 'render function', - [2 /* WATCH_GETTER */]: 'watcher getter', - [3 /* WATCH_CALLBACK */]: 'watcher callback', - [4 /* WATCH_CLEANUP */]: 'watcher cleanup function', - [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler', - [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler', - [7 /* VNODE_HOOK */]: 'vnode hook', - [8 /* DIRECTIVE_HOOK */]: 'directive hook', - [9 /* TRANSITION_HOOK */]: 'transition hook', - [10 /* APP_ERROR_HANDLER */]: 'app errorHandler', - [11 /* APP_WARN_HANDLER */]: 'app warnHandler', - [12 /* FUNCTION_REF */]: 'ref function', - [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader', - [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' + - 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/vue-next' - }; - function callWithErrorHandling(fn, instance, type, args) { - let res; - try { - res = args ? fn(...args) : fn(); - } - catch (err) { - handleError(err, instance, type); - } - return res; - } - function callWithAsyncErrorHandling(fn, instance, type, args) { - if (isFunction(fn)) { - const res = callWithErrorHandling(fn, instance, type, args); - if (res && isPromise(res)) { - res.catch(err => { - handleError(err, instance, type); - }); - } - return res; - } - const values = []; - for (let i = 0; i < fn.length; i++) { - values.push(callWithAsyncErrorHandling(fn[i], instance, type, args)); - } - return values; - } - function handleError(err, instance, type) { - const contextVNode = instance ? instance.vnode : null; - if (instance) { - let cur = instance.parent; - // the exposed instance is the render proxy to keep it consistent with 2.x - const exposedInstance = instance.proxy; - // in production the hook receives only the error code - const errorInfo = (process.env.NODE_ENV !== 'production') ? ErrorTypeStrings[type] : type; - while (cur) { - const errorCapturedHooks = cur.ec; - if (errorCapturedHooks) { - for (let i = 0; i < errorCapturedHooks.length; i++) { - if (errorCapturedHooks[i](err, exposedInstance, errorInfo)) { - return; - } - } - } - cur = cur.parent; - } - // app-level handling - const appErrorHandler = instance.appContext.config.errorHandler; - if (appErrorHandler) { - callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]); - return; - } - } - logError(err, type, contextVNode); - } - function logError(err, type, contextVNode) { - if ((process.env.NODE_ENV !== 'production')) { - const info = ErrorTypeStrings[type]; - if (contextVNode) { - pushWarningContext(contextVNode); - } - warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`); - if (contextVNode) { - popWarningContext(); - } - // crash in dev so it's more noticeable - throw err; - } - else { - // recover in prod to reduce the impact on end-user - console.error(err); - } - } - - let isFlushing = false; - let isFlushPending = false; - const queue = []; - let flushIndex = 0; - const pendingPreFlushCbs = []; - let activePreFlushCbs = null; - let preFlushIndex = 0; - const pendingPostFlushCbs = []; - let activePostFlushCbs = null; - let postFlushIndex = 0; - const resolvedPromise = Promise.resolve(); - let currentFlushPromise = null; - let currentPreFlushParentJob = null; - const RECURSION_LIMIT = 100; - function nextTick(fn) { - const p = currentFlushPromise || resolvedPromise; - return fn ? p.then(fn) : p; - } - function queueJob(job) { - // the dedupe search uses the startIndex argument of Array.includes() - // by default the search index includes the current job that is being run - // so it cannot recursively trigger itself again. - // if the job is a watch() callback, the search will start with a +1 index to - // allow it recursively trigger itself - it is the user's responsibility to - // ensure it doesn't end up in an infinite loop. - if ((!queue.length || - !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) && - job !== currentPreFlushParentJob) { - queue.push(job); - queueFlush(); - } - } - function queueFlush() { - if (!isFlushing && !isFlushPending) { - isFlushPending = true; - currentFlushPromise = resolvedPromise.then(flushJobs); - } - } - function queueCb(cb, activeQueue, pendingQueue, index) { - if (!isArray(cb)) { - if (!activeQueue || - !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) { - pendingQueue.push(cb); - } - } - else { - // if cb is an array, it is a component lifecycle hook which can only be - // triggered by a job, which is already deduped in the main queue, so - // we can skip duplicate check here to improve perf - pendingQueue.push(...cb); - } - queueFlush(); - } - function queuePreFlushCb(cb) { - queueCb(cb, activePreFlushCbs, pendingPreFlushCbs, preFlushIndex); - } - function queuePostFlushCb(cb) { - queueCb(cb, activePostFlushCbs, pendingPostFlushCbs, postFlushIndex); - } - function flushPreFlushCbs(seen, parentJob = null) { - if (pendingPreFlushCbs.length) { - currentPreFlushParentJob = parentJob; - activePreFlushCbs = [...new Set(pendingPreFlushCbs)]; - pendingPreFlushCbs.length = 0; - if ((process.env.NODE_ENV !== 'production')) { - seen = seen || new Map(); - } - for (preFlushIndex = 0; preFlushIndex < activePreFlushCbs.length; preFlushIndex++) { - if ((process.env.NODE_ENV !== 'production')) { - checkRecursiveUpdates(seen, activePreFlushCbs[preFlushIndex]); - } - activePreFlushCbs[preFlushIndex](); - } - activePreFlushCbs = null; - preFlushIndex = 0; - currentPreFlushParentJob = null; - // recursively flush until it drains - flushPreFlushCbs(seen, parentJob); - } - } - function flushPostFlushCbs(seen) { - if (pendingPostFlushCbs.length) { - activePostFlushCbs = [...new Set(pendingPostFlushCbs)]; - pendingPostFlushCbs.length = 0; - if ((process.env.NODE_ENV !== 'production')) { - seen = seen || new Map(); - } - activePostFlushCbs.sort((a, b) => getId(a) - getId(b)); - for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) { - if ((process.env.NODE_ENV !== 'production')) { - checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex]); - } - activePostFlushCbs[postFlushIndex](); - } - activePostFlushCbs = null; - postFlushIndex = 0; - } - } - const getId = (job) => job.id == null ? Infinity : job.id; - function flushJobs(seen) { - isFlushPending = false; - isFlushing = true; - if ((process.env.NODE_ENV !== 'production')) { - seen = seen || new Map(); - } - flushPreFlushCbs(seen); - // Sort queue before flush. - // This ensures that: - // 1. Components are updated from parent to child. (because parent is always - // created before the child so its render effect will have smaller - // priority number) - // 2. If a component is unmounted during a parent component's update, - // its update can be skipped. - // Jobs can never be null before flush starts, since they are only invalidated - // during execution of another flushed job. - queue.sort((a, b) => getId(a) - getId(b)); - try { - for (flushIndex = 0; flushIndex < queue.length; flushIndex++) { - const job = queue[flushIndex]; - if (job) { - if ((process.env.NODE_ENV !== 'production')) { - checkRecursiveUpdates(seen, job); - } - callWithErrorHandling(job, null, 14 /* SCHEDULER */); - } - } - } - finally { - flushIndex = 0; - queue.length = 0; - flushPostFlushCbs(seen); - isFlushing = false; - currentFlushPromise = null; - // some postFlushCb queued jobs! - // keep flushing until it drains. - if (queue.length || pendingPostFlushCbs.length) { - flushJobs(seen); - } - } - } - function checkRecursiveUpdates(seen, fn) { - if (!seen.has(fn)) { - seen.set(fn, 1); - } - else { - const count = seen.get(fn); - if (count > RECURSION_LIMIT) { - throw new Error(`Maximum recursive updates exceeded. ` + - `This means you have a reactive effect that is mutating its own ` + - `dependencies and thus recursively triggering itself. Possible sources ` + - `include component template, render function, updated hook or ` + - `watcher source function.`); - } - else { - seen.set(fn, count + 1); - } - } - } - const hmrDirtyComponents = new Set(); - // Expose the HMR runtime on the global object - // This makes it entirely tree-shakable without polluting the exports and makes - // it easier to be used in toolings like vue-loader - // Note: for a component to be eligible for HMR it also needs the __hmrId option - // to be set so that its instances can be registered / removed. - if ((process.env.NODE_ENV !== 'production')) { - const globalObject = typeof global !== 'undefined' - ? global - : typeof self !== 'undefined' - ? self - : typeof window !== 'undefined' - ? window - : {}; - globalObject.__VUE_HMR_RUNTIME__ = { - createRecord: tryWrap(createRecord), - rerender: tryWrap(rerender), - reload: tryWrap(reload) - }; - } - const map = new Map(); - function createRecord(id) { - if (map.has(id)) { - return false; - } - map.set(id, new Set()); - return true; - } - function rerender(id, newRender) { - const record = map.get(id); - if (!record) - return; - // Array.from creates a snapshot which avoids the set being mutated during - // updates - Array.from(record).forEach(instance => { - if (newRender) { - instance.render = newRender; - } - instance.renderCache = []; - instance.update(); - }); - } - function reload(id, newComp) { - const record = map.get(id); - if (!record) - return; - // Array.from creates a snapshot which avoids the set being mutated during - // updates - Array.from(record).forEach(instance => { - const comp = instance.type; - if (!hmrDirtyComponents.has(comp)) { - // 1. Update existing comp definition to match new one - extend(comp, newComp); - for (const key in comp) { - if (!(key in newComp)) { - delete comp[key]; - } - } - // 2. Mark component dirty. This forces the renderer to replace the component - // on patch. - hmrDirtyComponents.add(comp); - // 3. Make sure to unmark the component after the reload. - queuePostFlushCb(() => { - hmrDirtyComponents.delete(comp); - }); - } - if (instance.parent) { - // 4. Force the parent instance to re-render. This will cause all updated - // components to be unmounted and re-mounted. Queue the update so that we - // don't end up forcing the same parent to re-render multiple times. - queueJob(instance.parent.update); - } - else if (instance.appContext.reload) { - // root instance mounted via createApp() has a reload method - instance.appContext.reload(); - } - else if (typeof window !== 'undefined') { - // root instance inside tree created via raw render(). Force reload. - window.location.reload(); - } - else { - console.warn('[HMR] Root or manually mounted instance modified. Full reload required.'); - } - }); - } - function tryWrap(fn) { - return (id, arg) => { - try { - return fn(id, arg); - } - catch (e) { - console.error(e); - console.warn(`[HMR] Something went wrong during Vue component hot-reload. ` + - `Full reload required.`); - } - }; - } - - // mark the current rendering instance for asset resolution (e.g. - // resolveComponent, resolveDirective) during render - let currentRenderingInstance = null; - function markAttrsAccessed() { - } - - const isSuspense = (type) => type.__isSuspense; - function queueEffectWithSuspense(fn, suspense) { - if (suspense && !suspense.isResolved) { - if (isArray(fn)) { - suspense.effects.push(...fn); - } - else { - suspense.effects.push(fn); - } - } - else { - queuePostFlushCb(fn); - } - } - - // SFC scoped style ID management. - let currentScopeId = null; - - const isTeleport = (type) => type.__isTeleport; - const NULL_DYNAMIC_COMPONENT = Symbol(); - - let isRenderingTemplateSlot = false; - - const Fragment = Symbol((process.env.NODE_ENV !== 'production') ? 'Fragment' : undefined); - const Text = Symbol((process.env.NODE_ENV !== 'production') ? 'Text' : undefined); - const Comment = Symbol((process.env.NODE_ENV !== 'production') ? 'Comment' : undefined); - const Static = Symbol((process.env.NODE_ENV !== 'production') ? 'Static' : undefined); - let currentBlock = null; - // Whether we should be tracking dynamic child nodes inside a block. - // Only tracks when this value is > 0 - // We are not using a simple boolean because this value may need to be - // incremented/decremented by nested usage of v-once (see below) - let shouldTrack$1 = 1; - function isVNode(value) { - return value ? value.__v_isVNode === true : false; - } - function isSameVNodeType(n1, n2) { - if ((process.env.NODE_ENV !== 'production') && - n2.shapeFlag & 6 /* COMPONENT */ && - hmrDirtyComponents.has(n2.type)) { - // HMR only: if the component has been hot-updated, force a reload. - return false; - } - return n1.type === n2.type && n1.key === n2.key; - } - let vnodeArgsTransformer; - const createVNodeWithArgsTransform = (...args) => { - return _createVNode(...(vnodeArgsTransformer - ? vnodeArgsTransformer(args, currentRenderingInstance) - : args)); - }; - const InternalObjectKey = `__vInternal`; - const normalizeKey = ({ key }) => key != null ? key : null; - const normalizeRef = ({ ref: ref$$1 }) => { - return (ref$$1 != null - ? isArray(ref$$1) - ? ref$$1 - : [currentRenderingInstance, ref$$1] - : null); - }; - const createVNode = ((process.env.NODE_ENV !== 'production') - ? createVNodeWithArgsTransform - : _createVNode); - function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) { - if (!type || type === NULL_DYNAMIC_COMPONENT) { - if ((process.env.NODE_ENV !== 'production') && !type) { - warn(`Invalid vnode type when creating vnode: ${type}.`); - } - type = Comment; - } - if (isVNode(type)) { - const cloned = cloneVNode(type, props); - if (children) { - normalizeChildren(cloned, children); - } - return cloned; - } - // class component normalization. - if (isFunction(type) && '__vccOpts' in type) { - type = type.__vccOpts; - } - // class & style normalization. - if (props) { - // for reactive or proxy objects, we need to clone it to enable mutation. - if (isProxy(props) || InternalObjectKey in props) { - props = extend({}, props); - } - let { class: klass, style } = props; - if (klass && !isString(klass)) { - props.class = normalizeClass(klass); - } - if (isObject(style)) { - // reactive state objects need to be cloned since they are likely to be - // mutated - if (isProxy(style) && !isArray(style)) { - style = extend({}, style); - } - props.style = normalizeStyle(style); - } - } - // encode the vnode type information into a bitmap - const shapeFlag = isString(type) - ? 1 /* ELEMENT */ - : isSuspense(type) - ? 128 /* SUSPENSE */ - : isTeleport(type) - ? 64 /* TELEPORT */ - : isObject(type) - ? 4 /* STATEFUL_COMPONENT */ - : isFunction(type) - ? 2 /* FUNCTIONAL_COMPONENT */ - : 0; - if ((process.env.NODE_ENV !== 'production') && shapeFlag & 4 /* STATEFUL_COMPONENT */ && isProxy(type)) { - type = toRaw(type); - warn(`Vue received a Component which was made a reactive object. This can ` + - `lead to unnecessary performance overhead, and should be avoided by ` + - `marking the component with \`markRaw\` or using \`shallowRef\` ` + - `instead of \`ref\`.`, `\nComponent that was made reactive: `, type); - } - const vnode = { - __v_isVNode: true, - __v_skip: true, - type, - props, - key: props && normalizeKey(props), - ref: props && normalizeRef(props), - scopeId: currentScopeId, - children: null, - component: null, - suspense: null, - dirs: null, - transition: null, - el: null, - anchor: null, - target: null, - targetAnchor: null, - staticCount: 0, - shapeFlag, - patchFlag, - dynamicProps, - dynamicChildren: null, - appContext: null - }; - // validate key - if ((process.env.NODE_ENV !== 'production') && vnode.key !== vnode.key) { - warn(`VNode created with invalid key (NaN). VNode type:`, vnode.type); - } - normalizeChildren(vnode, children); - if ((shouldTrack$1 > 0 || isRenderingTemplateSlot) && - // avoid a block node from tracking itself - !isBlockNode && - // has current parent block - currentBlock && - // presence of a patch flag indicates this node needs patching on updates. - // component nodes also should always be patched, because even if the - // component doesn't need to update, it needs to persist the instance on to - // the next vnode so that it can be properly unmounted later. - (patchFlag > 0 || shapeFlag & 6 /* COMPONENT */) && - // the EVENTS flag is only for hydration and if it is the only flag, the - // vnode should not be considered dynamic due to handler caching. - patchFlag !== 32 /* HYDRATE_EVENTS */) { - currentBlock.push(vnode); - } - return vnode; - } - function cloneVNode(vnode, extraProps) { - // This is intentionally NOT using spread or extend to avoid the runtime - // key enumeration cost. - const { props, patchFlag } = vnode; - const mergedProps = extraProps - ? props - ? mergeProps(props, extraProps) - : extend({}, extraProps) - : props; - return { - __v_isVNode: true, - __v_skip: true, - type: vnode.type, - props: mergedProps, - key: mergedProps && normalizeKey(mergedProps), - ref: extraProps && extraProps.ref ? normalizeRef(extraProps) : vnode.ref, - scopeId: vnode.scopeId, - children: vnode.children, - target: vnode.target, - targetAnchor: vnode.targetAnchor, - staticCount: vnode.staticCount, - shapeFlag: vnode.shapeFlag, - // if the vnode is cloned with extra props, we can no longer assume its - // existing patch flag to be reliable and need to add the FULL_PROPS flag. - // note: perserve flag for fragments since they use the flag for children - // fast paths only. - patchFlag: extraProps && vnode.type !== Fragment - ? patchFlag === -1 // hoisted node - ? 16 /* FULL_PROPS */ - : patchFlag | 16 /* FULL_PROPS */ - : patchFlag, - dynamicProps: vnode.dynamicProps, - dynamicChildren: vnode.dynamicChildren, - appContext: vnode.appContext, - dirs: vnode.dirs, - transition: vnode.transition, - // These should technically only be non-null on mounted VNodes. However, - // they *should* be copied for kept-alive vnodes. So we just always copy - // them since them being non-null during a mount doesn't affect the logic as - // they will simply be overwritten. - component: vnode.component, - suspense: vnode.suspense, - el: vnode.el, - anchor: vnode.anchor - }; - } - /** - * @private - */ - function createTextVNode(text = ' ', flag = 0) { - return createVNode(Text, null, text, flag); - } - function normalizeChildren(vnode, children) { - let type = 0; - const { shapeFlag } = vnode; - if (children == null) { - children = null; - } - else if (isArray(children)) { - type = 16 /* ARRAY_CHILDREN */; - } - else if (typeof children === 'object') { - // Normalize slot to plain children - if ((shapeFlag & 1 /* ELEMENT */ || shapeFlag & 64 /* TELEPORT */) && - children.default) { - normalizeChildren(vnode, children.default()); - return; - } - else { - type = 32 /* SLOTS_CHILDREN */; - const slotFlag = children._; - if (!slotFlag && !(InternalObjectKey in children)) { - children._ctx = currentRenderingInstance; - } - else if (slotFlag === 3 /* FORWARDED */ && currentRenderingInstance) { - // a child component receives forwarded slots from the parent. - // its slot type is determined by its parent's slot type. - if (currentRenderingInstance.vnode.patchFlag & 1024 /* DYNAMIC_SLOTS */) { - children._ = 2 /* DYNAMIC */; - vnode.patchFlag |= 1024 /* DYNAMIC_SLOTS */; - } - else { - children._ = 1 /* STABLE */; - } - } - } - } - else if (isFunction(children)) { - children = { default: children, _ctx: currentRenderingInstance }; - type = 32 /* SLOTS_CHILDREN */; - } - else { - children = String(children); - // force teleport children to array so it can be moved around - if (shapeFlag & 64 /* TELEPORT */) { - type = 16 /* ARRAY_CHILDREN */; - children = [createTextVNode(children)]; - } - else { - type = 8 /* TEXT_CHILDREN */; - } - } - vnode.children = children; - vnode.shapeFlag |= type; - } - function mergeProps(...args) { - const ret = extend({}, args[0]); - for (let i = 1; i < args.length; i++) { - const toMerge = args[i]; - for (const key in toMerge) { - if (key === 'class') { - if (ret.class !== toMerge.class) { - ret.class = normalizeClass([ret.class, toMerge.class]); - } - } - else if (key === 'style') { - ret.style = normalizeStyle([ret.style, toMerge.style]); - } - else if (isOn(key)) { - const existing = ret[key]; - const incoming = toMerge[key]; - if (existing !== incoming) { - ret[key] = existing - ? [].concat(existing, toMerge[key]) - : incoming; - } - } - else { - ret[key] = toMerge[key]; - } - } - } - return ret; - } - function normalizePropsOptions(comp) { - if (comp.__props) { - return comp.__props; - } - const raw = comp.props; - const normalized = {}; - const needCastKeys = []; - // apply mixin/extends props - let hasExtends = false; - if (__VUE_OPTIONS_API__ && !isFunction(comp)) { - const extendProps = (raw) => { - const [props, keys] = normalizePropsOptions(raw); - extend(normalized, props); - if (keys) - needCastKeys.push(...keys); - }; - if (comp.extends) { - hasExtends = true; - extendProps(comp.extends); - } - if (comp.mixins) { - hasExtends = true; - comp.mixins.forEach(extendProps); - } - } - if (!raw && !hasExtends) { - return (comp.__props = EMPTY_ARR); - } - if (isArray(raw)) { - for (let i = 0; i < raw.length; i++) { - if ((process.env.NODE_ENV !== 'production') && !isString(raw[i])) { - warn(`props must be strings when using array syntax.`, raw[i]); - } - const normalizedKey = camelize(raw[i]); - if (validatePropName(normalizedKey)) { - normalized[normalizedKey] = EMPTY_OBJ; - } - } - } - else if (raw) { - if ((process.env.NODE_ENV !== 'production') && !isObject(raw)) { - warn(`invalid props options`, raw); - } - for (const key in raw) { - const normalizedKey = camelize(key); - if (validatePropName(normalizedKey)) { - const opt = raw[key]; - const prop = (normalized[normalizedKey] = - isArray(opt) || isFunction(opt) ? { type: opt } : opt); - if (prop) { - const booleanIndex = getTypeIndex(Boolean, prop.type); - const stringIndex = getTypeIndex(String, prop.type); - prop[0 /* shouldCast */] = booleanIndex > -1; - prop[1 /* shouldCastTrue */] = - stringIndex < 0 || booleanIndex < stringIndex; - // if the prop needs boolean casting or default value - if (booleanIndex > -1 || hasOwn(prop, 'default')) { - needCastKeys.push(normalizedKey); - } - } - } - } - } - const normalizedEntry = [normalized, needCastKeys]; - comp.__props = normalizedEntry; - return normalizedEntry; - } - // use function string name to check type constructors - // so that it works across vms / iframes. - function getType(ctor) { - const match = ctor && ctor.toString().match(/^\s*function (\w+)/); - return match ? match[1] : ''; - } - function isSameType(a, b) { - return getType(a) === getType(b); - } - function getTypeIndex(type, expectedTypes) { - if (isArray(expectedTypes)) { - for (let i = 0, len = expectedTypes.length; i < len; i++) { - if (isSameType(expectedTypes[i], type)) { - return i; - } - } - } - else if (isFunction(expectedTypes)) { - return isSameType(expectedTypes, type) ? 0 : -1; - } - return -1; - } - /** - * dev only - */ - function validatePropName(key) { - if (key[0] !== '$') { - return true; - } - else if ((process.env.NODE_ENV !== 'production')) { - warn(`Invalid prop name: "${key}" is a reserved property.`); - } - return false; - } - const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); - - function injectHook(type, hook, target = currentInstance, prepend = false) { - if (target) { - const hooks = target[type] || (target[type] = []); - // cache the error handling wrapper for injected hooks so the same hook - // can be properly deduped by the scheduler. "__weh" stands for "with error - // handling". - const wrappedHook = hook.__weh || - (hook.__weh = (...args) => { - if (target.isUnmounted) { - return; - } - // disable tracking inside all lifecycle hooks - // since they can potentially be called inside effects. - pauseTracking(); - // Set currentInstance during hook invocation. - // This assumes the hook does not synchronously trigger other hooks, which - // can only be false when the user does something really funky. - setCurrentInstance(target); - const res = callWithAsyncErrorHandling(hook, target, type, args); - setCurrentInstance(null); - resetTracking(); - return res; - }); - if (prepend) { - hooks.unshift(wrappedHook); - } - else { - hooks.push(wrappedHook); - } - } - else if ((process.env.NODE_ENV !== 'production')) { - const apiName = `on${capitalize(ErrorTypeStrings[type].replace(/ hook$/, ''))}`; - warn(`${apiName} is called when there is no active component instance to be ` + - `associated with. ` + - `Lifecycle injection APIs can only be used during execution of setup().` + - ( ` If you are using async setup(), make sure to register lifecycle ` + - `hooks before the first await statement.` - )); - } - } - const createHook = (lifecycle) => (hook, target = currentInstance) => - // post-create lifecycle registrations are noops during SSR - !isInSSRComponentSetup && injectHook(lifecycle, hook, target); - const onMounted = createHook("m" /* MOUNTED */); - const onUpdated = createHook("u" /* UPDATED */); - const onBeforeUnmount = createHook("bum" /* BEFORE_UNMOUNT */); - - function useTransitionState() { - const state = { - isMounted: false, - isLeaving: false, - isUnmounting: false, - leavingVNodes: new Map() - }; - onMounted(() => { - state.isMounted = true; - }); - onBeforeUnmount(() => { - state.isUnmounting = true; - }); - return state; - } - const TransitionHookValidator = [Function, Array]; - const BaseTransitionImpl = { - name: `BaseTransition`, - props: { - mode: String, - appear: Boolean, - persisted: Boolean, - // enter - onBeforeEnter: TransitionHookValidator, - onEnter: TransitionHookValidator, - onAfterEnter: TransitionHookValidator, - onEnterCancelled: TransitionHookValidator, - // leave - onBeforeLeave: TransitionHookValidator, - onLeave: TransitionHookValidator, - onAfterLeave: TransitionHookValidator, - onLeaveCancelled: TransitionHookValidator, - // appear - onBeforeAppear: TransitionHookValidator, - onAppear: TransitionHookValidator, - onAfterAppear: TransitionHookValidator, - onAppearCancelled: TransitionHookValidator - }, - setup(props, { slots }) { - const instance = getCurrentInstance(); - const state = useTransitionState(); - let prevTransitionKey; - return () => { - const children = slots.default && getTransitionRawChildren(slots.default(), true); - if (!children || !children.length) { - return; - } - // warn multiple elements - if ((process.env.NODE_ENV !== 'production') && children.length > 1) { - warn(' can only be used on a single element or component. Use ' + - ' for lists.'); - } - // there's no need to track reactivity for these props so use the raw - // props for a bit better perf - const rawProps = toRaw(props); - const { mode } = rawProps; - // check mode - if ((process.env.NODE_ENV !== 'production') && mode && !['in-out', 'out-in', 'default'].includes(mode)) { - warn(`invalid mode: ${mode}`); - } - // at this point children has a guaranteed length of 1. - const child = children[0]; - if (state.isLeaving) { - return emptyPlaceholder(child); - } - // in the case of , we need to - // compare the type of the kept-alive children. - const innerChild = getKeepAliveChild(child); - if (!innerChild) { - return emptyPlaceholder(child); - } - const enterHooks = (innerChild.transition = resolveTransitionHooks(innerChild, rawProps, state, instance)); - const oldChild = instance.subTree; - const oldInnerChild = oldChild && getKeepAliveChild(oldChild); - let transitionKeyChanged = false; - const { getTransitionKey } = innerChild.type; - if (getTransitionKey) { - const key = getTransitionKey(); - if (prevTransitionKey === undefined) { - prevTransitionKey = key; - } - else if (key !== prevTransitionKey) { - prevTransitionKey = key; - transitionKeyChanged = true; - } - } - // handle mode - if (oldInnerChild && - oldInnerChild.type !== Comment && - (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) { - const leavingHooks = resolveTransitionHooks(oldInnerChild, rawProps, state, instance); - // update old tree's hooks in case of dynamic transition - setTransitionHooks(oldInnerChild, leavingHooks); - // switching between different views - if (mode === 'out-in') { - state.isLeaving = true; - // return placeholder node and queue update when leave finishes - leavingHooks.afterLeave = () => { - state.isLeaving = false; - instance.update(); - }; - return emptyPlaceholder(child); - } - else if (mode === 'in-out') { - leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => { - const leavingVNodesCache = getLeavingNodesForType(state, oldInnerChild); - leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild; - // early removal callback - el._leaveCb = () => { - earlyRemove(); - el._leaveCb = undefined; - delete enterHooks.delayedLeave; - }; - enterHooks.delayedLeave = delayedLeave; - }; - } - } - return child; - }; - } - }; - // export the public type for h/tsx inference - // also to avoid inline import() in generated d.ts files - const BaseTransition = BaseTransitionImpl; - function getLeavingNodesForType(state, vnode) { - const { leavingVNodes } = state; - let leavingVNodesCache = leavingVNodes.get(vnode.type); - if (!leavingVNodesCache) { - leavingVNodesCache = Object.create(null); - leavingVNodes.set(vnode.type, leavingVNodesCache); - } - return leavingVNodesCache; - } - // The transition hooks are attached to the vnode as vnode.transition - // and will be called at appropriate timing in the renderer. - function resolveTransitionHooks(vnode, { appear, persisted = false, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, onBeforeAppear, onAppear, onAfterAppear, onAppearCancelled }, state, instance) { - const key = String(vnode.key); - const leavingVNodesCache = getLeavingNodesForType(state, vnode); - const callHook = (hook, args) => { - hook && - callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args); - }; - const hooks = { - persisted, - beforeEnter(el) { - let hook = onBeforeEnter; - if (!state.isMounted) { - if (appear) { - hook = onBeforeAppear || onBeforeEnter; - } - else { - return; - } - } - // for same element (v-show) - if (el._leaveCb) { - el._leaveCb(true /* cancelled */); - } - // for toggled element with same key (v-if) - const leavingVNode = leavingVNodesCache[key]; - if (leavingVNode && - isSameVNodeType(vnode, leavingVNode) && - leavingVNode.el._leaveCb) { - // force early removal (not cancelled) - leavingVNode.el._leaveCb(); - } - callHook(hook, [el]); - }, - enter(el) { - let hook = onEnter; - let afterHook = onAfterEnter; - let cancelHook = onEnterCancelled; - if (!state.isMounted) { - if (appear) { - hook = onAppear || onEnter; - afterHook = onAfterAppear || onAfterEnter; - cancelHook = onAppearCancelled || onEnterCancelled; - } - else { - return; - } - } - let called = false; - const done = (el._enterCb = (cancelled) => { - if (called) - return; - called = true; - if (cancelled) { - callHook(cancelHook, [el]); - } - else { - callHook(afterHook, [el]); - } - if (hooks.delayedLeave) { - hooks.delayedLeave(); - } - el._enterCb = undefined; - }); - if (hook) { - hook(el, done); - if (hook.length <= 1) { - done(); - } - } - else { - done(); - } - }, - leave(el, remove$$1) { - const key = String(vnode.key); - if (el._enterCb) { - el._enterCb(true /* cancelled */); - } - if (state.isUnmounting) { - return remove$$1(); - } - callHook(onBeforeLeave, [el]); - let called = false; - const done = (el._leaveCb = (cancelled) => { - if (called) - return; - called = true; - remove$$1(); - if (cancelled) { - callHook(onLeaveCancelled, [el]); - } - else { - callHook(onAfterLeave, [el]); - } - el._leaveCb = undefined; - if (leavingVNodesCache[key] === vnode) { - delete leavingVNodesCache[key]; - } - }); - leavingVNodesCache[key] = vnode; - if (onLeave) { - onLeave(el, done); - if (onLeave.length <= 1) { - done(); - } - } - else { - done(); - } - } - }; - return hooks; - } - // the placeholder really only handles one special case: KeepAlive - // in the case of a KeepAlive in a leave phase we need to return a KeepAlive - // placeholder with empty content to avoid the KeepAlive instance from being - // unmounted. - function emptyPlaceholder(vnode) { - if (isKeepAlive(vnode)) { - vnode = cloneVNode(vnode); - vnode.children = null; - return vnode; - } - } - function getKeepAliveChild(vnode) { - return isKeepAlive(vnode) - ? vnode.children - ? vnode.children[0] - : undefined - : vnode; - } - function setTransitionHooks(vnode, hooks) { - if (vnode.shapeFlag & 6 /* COMPONENT */ && vnode.component) { - setTransitionHooks(vnode.component.subTree, hooks); - } - else { - vnode.transition = hooks; - } - } - function getTransitionRawChildren(children, keepComment = false) { - let ret = []; - let keyedFragmentCount = 0; - for (let i = 0; i < children.length; i++) { - const child = children[i]; - // handle fragment children case, e.g. v-for - if (child.type === Fragment) { - if (child.patchFlag & 128 /* KEYED_FRAGMENT */) - keyedFragmentCount++; - ret = ret.concat(getTransitionRawChildren(child.children, keepComment)); - } - // comment placeholders should be skipped, e.g. v-if - else if (keepComment || child.type !== Comment) { - ret.push(child); - } - } - // #1126 if a transition children list contains multiple sub fragments, these - // fragments will be merged into a flat children array. Since each v-for - // fragment may contain different static bindings inside, we need to de-top - // these children to force full diffs to ensure correct behavior. - if (keyedFragmentCount > 1) { - for (let i = 0; i < ret.length; i++) { - ret[i].patchFlag = -2 /* BAIL */; - } - } - return ret; - } - - const isKeepAlive = (vnode) => vnode.type.__isKeepAlive; - - /** - Runtime helper for applying directives to a vnode. Example usage: - - const comp = resolveComponent('comp') - const foo = resolveDirective('foo') - const bar = resolveDirective('bar') - - return withDirectives(h(comp), [ - [foo, this.x], - [bar, this.y] - ]) - */ - const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text'); - function setDevtoolsHook(hook) { - } - const queuePostRenderEffect = queueEffectWithSuspense - ; - // initial value for watchers to trigger on undefined initial values - const INITIAL_WATCHER_VALUE = {}; - function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ, instance = currentInstance) { - if ((process.env.NODE_ENV !== 'production') && !cb) { - if (immediate !== undefined) { - warn(`watch() "immediate" option is only respected when using the ` + - `watch(source, callback, options?) signature.`); - } - if (deep !== undefined) { - warn(`watch() "deep" option is only respected when using the ` + - `watch(source, callback, options?) signature.`); - } - } - const warnInvalidSource = (s) => { - warn(`Invalid watch source: `, s, `A watch source can only be a getter/effect function, a ref, ` + - `a reactive object, or an array of these types.`); - }; - let getter; - const isRefSource = isRef(source); - if (isRefSource) { - getter = () => source.value; - } - else if (isReactive(source)) { - getter = () => source; - deep = true; - } - else if (isArray(source)) { - getter = () => source.map(s => { - if (isRef(s)) { - return s.value; - } - else if (isReactive(s)) { - return traverse(s); - } - else if (isFunction(s)) { - return callWithErrorHandling(s, instance, 2 /* WATCH_GETTER */); - } - else { - (process.env.NODE_ENV !== 'production') && warnInvalidSource(s); - } - }); - } - else if (isFunction(source)) { - if (cb) { - // getter with cb - getter = () => callWithErrorHandling(source, instance, 2 /* WATCH_GETTER */); - } - else { - // no cb -> simple effect - getter = () => { - if (instance && instance.isUnmounted) { - return; - } - if (cleanup) { - cleanup(); - } - return callWithErrorHandling(source, instance, 3 /* WATCH_CALLBACK */, [onInvalidate]); - }; - } - } - else { - getter = NOOP; - (process.env.NODE_ENV !== 'production') && warnInvalidSource(source); - } - if (cb && deep) { - const baseGetter = getter; - getter = () => traverse(baseGetter()); - } - let cleanup; - const onInvalidate = (fn) => { - cleanup = runner.options.onStop = () => { - callWithErrorHandling(fn, instance, 4 /* WATCH_CLEANUP */); - }; - }; - let oldValue = isArray(source) ? [] : INITIAL_WATCHER_VALUE; - const job = () => { - if (!runner.active) { - return; - } - if (cb) { - // watch(source, cb) - const newValue = runner(); - if (deep || isRefSource || hasChanged(newValue, oldValue)) { - // cleanup before running cb again - if (cleanup) { - cleanup(); - } - callWithAsyncErrorHandling(cb, instance, 3 /* WATCH_CALLBACK */, [ - newValue, - // pass undefined as the old value when it's changed for the first time - oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue, - onInvalidate - ]); - oldValue = newValue; - } - } - else { - // watchEffect - runner(); - } - }; - // important: mark the job as a watcher callback so that scheduler knows it - // it is allowed to self-trigger (#1727) - job.allowRecurse = !!cb; - let scheduler; - if (flush === 'sync') { - scheduler = job; - } - else if (flush === 'pre') { - // ensure it's queued before component updates (which have positive ids) - job.id = -1; - scheduler = () => { - if (!instance || instance.isMounted) { - queuePreFlushCb(job); - } - else { - // with 'pre' option, the first call must happen before - // the component is mounted so it is called synchronously. - job(); - } - }; - } - else { - scheduler = () => queuePostRenderEffect(job, instance && instance.suspense); - } - const runner = effect(getter, { - lazy: true, - onTrack, - onTrigger, - scheduler - }); - recordInstanceBoundEffect(runner); - // initial run - if (cb) { - if (immediate) { - job(); - } - else { - oldValue = runner(); - } - } - else { - runner(); - } - return () => { - stop(runner); - if (instance) { - remove(instance.effects, runner); - } - }; - } - // this.$watch - function instanceWatch(source, cb, options) { - const publicThis = this.proxy; - const getter = isString(source) - ? () => publicThis[source] - : source.bind(publicThis); - return doWatch(getter, cb.bind(publicThis), options, this); - } - function traverse(value, seen = new Set()) { - if (!isObject(value) || seen.has(value)) { - return value; - } - seen.add(value); - if (isArray(value)) { - for (let i = 0; i < value.length; i++) { - traverse(value[i], seen); - } - } - else if (value instanceof Map) { - value.forEach((v, key) => { - // to register mutation dep for existing keys - traverse(value.get(key), seen); - }); - } - else if (value instanceof Set) { - value.forEach(v => { - traverse(v, seen); - }); - } - else { - for (const key in value) { - traverse(value[key], seen); - } - } - return value; - } - let isInBeforeCreate = false; - function resolveMergedOptions(instance) { - const raw = instance.type; - const { __merged, mixins, extends: extendsOptions } = raw; - if (__merged) - return __merged; - const globalMixins = instance.appContext.mixins; - if (!globalMixins.length && !mixins && !extendsOptions) - return raw; - const options = {}; - globalMixins.forEach(m => mergeOptions(options, m, instance)); - extendsOptions && mergeOptions(options, extendsOptions, instance); - mixins && mixins.forEach(m => mergeOptions(options, m, instance)); - mergeOptions(options, raw, instance); - return (raw.__merged = options); - } - function mergeOptions(to, from, instance) { - const strats = instance.appContext.config.optionMergeStrategies; - for (const key in from) { - if (strats && hasOwn(strats, key)) { - to[key] = strats[key](to[key], from[key], instance.proxy, key); - } - else if (!hasOwn(to, key)) { - to[key] = from[key]; - } - } - } - - const publicPropertiesMap = extend(Object.create(null), { - $: i => i, - $el: i => i.vnode.el, - $data: i => i.data, - $props: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.props) : i.props), - $attrs: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.attrs) : i.attrs), - $slots: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.slots) : i.slots), - $refs: i => ((process.env.NODE_ENV !== 'production') ? shallowReadonly(i.refs) : i.refs), - $parent: i => i.parent && i.parent.proxy, - $root: i => i.root && i.root.proxy, - $emit: i => i.emit, - $options: i => (__VUE_OPTIONS_API__ ? resolveMergedOptions(i) : i.type), - $forceUpdate: i => () => queueJob(i.update), - $nextTick: () => nextTick, - $watch: i => (__VUE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP) - }); - const PublicInstanceProxyHandlers = { - get({ _: instance }, key) { - const { ctx, setupState, data, props, accessCache, type, appContext } = instance; - // let @vue/reactivity know it should never observe Vue public instances. - if (key === "__v_skip" /* SKIP */) { - return true; - } - // data / props / ctx - // This getter gets called for every property access on the render context - // during render and is a major hotspot. The most expensive part of this - // is the multiple hasOwn() calls. It's much faster to do a simple property - // access on a plain object, so we use an accessCache object (with null - // prototype) to memoize what access type a key corresponds to. - let normalizedProps; - if (key[0] !== '$') { - const n = accessCache[key]; - if (n !== undefined) { - switch (n) { - case 0 /* SETUP */: - return setupState[key]; - case 1 /* DATA */: - return data[key]; - case 3 /* CONTEXT */: - return ctx[key]; - case 2 /* PROPS */: - return props[key]; - // default: just fallthrough - } - } - else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { - accessCache[key] = 0 /* SETUP */; - return setupState[key]; - } - else if (data !== EMPTY_OBJ && hasOwn(data, key)) { - accessCache[key] = 1 /* DATA */; - return data[key]; - } - else if ( - // only cache other properties when instance has declared (thus stable) - // props - (normalizedProps = normalizePropsOptions(type)[0]) && - hasOwn(normalizedProps, key)) { - accessCache[key] = 2 /* PROPS */; - return props[key]; - } - else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { - accessCache[key] = 3 /* CONTEXT */; - return ctx[key]; - } - else if (!__VUE_OPTIONS_API__ || !isInBeforeCreate) { - accessCache[key] = 4 /* OTHER */; - } - } - const publicGetter = publicPropertiesMap[key]; - let cssModule, globalProperties; - // public $xxx properties - if (publicGetter) { - if (key === '$attrs') { - track(instance, "get" /* GET */, key); - (process.env.NODE_ENV !== 'production') && markAttrsAccessed(); - } - return publicGetter(instance); - } - else if ( - // css module (injected by vue-loader) - (cssModule = type.__cssModules) && - (cssModule = cssModule[key])) { - return cssModule; - } - else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { - // user may set custom properties to `this` that start with `$` - accessCache[key] = 3 /* CONTEXT */; - return ctx[key]; - } - else if ( - // global properties - (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key))) { - return globalProperties[key]; - } - else if ((process.env.NODE_ENV !== 'production') && - currentRenderingInstance && - (!isString(key) || - // #1091 avoid internal isRef/isVNode checks on component instance leading - // to infinite warning loop - key.indexOf('__v') !== 0)) { - if (data !== EMPTY_OBJ && key[0] === '$' && hasOwn(data, key)) { - warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved ` + - `character and is not proxied on the render context.`); - } - else { - warn(`Property ${JSON.stringify(key)} was accessed during render ` + - `but is not defined on instance.`); - } - } - }, - set({ _: instance }, key, value) { - const { data, setupState, ctx } = instance; - if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { - setupState[key] = value; - } - else if (data !== EMPTY_OBJ && hasOwn(data, key)) { - data[key] = value; - } - else if (key in instance.props) { - (process.env.NODE_ENV !== 'production') && - warn(`Attempting to mutate prop "${key}". Props are readonly.`, instance); - return false; - } - if (key[0] === '$' && key.slice(1) in instance) { - (process.env.NODE_ENV !== 'production') && - warn(`Attempting to mutate public property "${key}". ` + - `Properties starting with $ are reserved and readonly.`, instance); - return false; - } - else { - if ((process.env.NODE_ENV !== 'production') && key in instance.appContext.config.globalProperties) { - Object.defineProperty(ctx, key, { - enumerable: true, - configurable: true, - value - }); - } - else { - ctx[key] = value; - } - } - return true; - }, - has({ _: { data, setupState, accessCache, ctx, type, appContext } }, key) { - let normalizedProps; - return (accessCache[key] !== undefined || - (data !== EMPTY_OBJ && hasOwn(data, key)) || - (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) || - ((normalizedProps = normalizePropsOptions(type)[0]) && - hasOwn(normalizedProps, key)) || - hasOwn(ctx, key) || - hasOwn(publicPropertiesMap, key) || - hasOwn(appContext.config.globalProperties, key)); - } - }; - if ((process.env.NODE_ENV !== 'production') && !false) { - PublicInstanceProxyHandlers.ownKeys = (target) => { - warn(`Avoid app logic that relies on enumerating keys on a component instance. ` + - `The keys will be empty in production mode to avoid performance overhead.`); - return Reflect.ownKeys(target); - }; - } - const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, { - get(target, key) { - // fast path for unscopables when using `with` block - if (key === Symbol.unscopables) { - return; - } - return PublicInstanceProxyHandlers.get(target, key, target); - }, - has(_, key) { - const has = key[0] !== '_' && !isGloballyWhitelisted(key); - if ((process.env.NODE_ENV !== 'production') && !has && PublicInstanceProxyHandlers.has(_, key)) { - warn(`Property ${JSON.stringify(key)} should not start with _ which is a reserved prefix for Vue internals.`); - } - return has; - } - }); - let currentInstance = null; - const getCurrentInstance = () => currentInstance || currentRenderingInstance; - const setCurrentInstance = (instance) => { - currentInstance = instance; - }; - const isBuiltInTag = /*#__PURE__*/ makeMap('slot,component'); - let isInSSRComponentSetup = false; - // record effects created during a component's setup() so that they can be - // stopped when the component unmounts - function recordInstanceBoundEffect(effect$$1) { - if (currentInstance) { - (currentInstance.effects || (currentInstance.effects = [])).push(effect$$1); - } - } - const classifyRE = /(?:^|[-_])(\w)/g; - const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, ''); - /* istanbul ignore next */ - function formatComponentName(instance, Component, isRoot = false) { - let name = isFunction(Component) - ? Component.displayName || Component.name - : Component.name; - if (!name && Component.__file) { - const match = Component.__file.match(/([^/\\]+)\.vue$/); - if (match) { - name = match[1]; - } - } - if (!name && instance && instance.parent) { - // try to infer the name based on reverse resolution - const inferFromRegistry = (registry) => { - for (const key in registry) { - if (registry[key] === Component) { - return key; - } - } - }; - name = - inferFromRegistry(instance.parent.type.components) || inferFromRegistry(instance.appContext.components); - } - return name ? classify(name) : isRoot ? `App` : `Anonymous`; - } - - // implementation, close to no-op - function defineComponent(options) { - return isFunction(options) ? { setup: options, name: options.name } : options; - } - - // Actual implementation - function h(type, propsOrChildren, children) { - if (arguments.length === 2) { - if (isObject(propsOrChildren) && !isArray(propsOrChildren)) { - // single vnode without props - if (isVNode(propsOrChildren)) { - return createVNode(type, null, [propsOrChildren]); - } - // props without children - return createVNode(type, propsOrChildren); - } - else { - // omit props - return createVNode(type, null, propsOrChildren); - } - } - else { - if (isVNode(children)) { - children = [children]; - } - return createVNode(type, propsOrChildren, children); - } - } - - const ssrContextKey = Symbol((process.env.NODE_ENV !== 'production') ? `ssrContext` : ``); - - const svgNS = 'http://www.w3.org/2000/svg'; - const doc = (typeof document !== 'undefined' ? document : null); - let tempContainer; - let tempSVGContainer; - const nodeOps = { - insert: (child, parent, anchor) => { - parent.insertBefore(child, anchor || null); - }, - remove: child => { - const parent = child.parentNode; - if (parent) { - parent.removeChild(child); - } - }, - createElement: (tag, isSVG, is) => isSVG - ? doc.createElementNS(svgNS, tag) - : doc.createElement(tag, is ? { is } : undefined), - createText: text => doc.createTextNode(text), - createComment: text => doc.createComment(text), - setText: (node, text) => { - node.nodeValue = text; - }, - setElementText: (el, text) => { - el.textContent = text; - }, - parentNode: node => node.parentNode, - nextSibling: node => node.nextSibling, - querySelector: selector => doc.querySelector(selector), - setScopeId(el, id) { - el.setAttribute(id, ''); - }, - cloneNode(el) { - return el.cloneNode(true); - }, - // __UNSAFE__ - // Reason: innerHTML. - // Static content here can only come from compiled templates. - // As long as the user only uses trusted templates, this is safe. - insertStaticContent(content, parent, anchor, isSVG) { - const temp = isSVG - ? tempSVGContainer || - (tempSVGContainer = doc.createElementNS(svgNS, 'svg')) - : tempContainer || (tempContainer = doc.createElement('div')); - temp.innerHTML = content; - const first = temp.firstChild; - let node = first; - let last = node; - while (node) { - last = node; - nodeOps.insert(node, parent, anchor); - node = temp.firstChild; - } - return [first, last]; - } - }; - - // compiler should normalize class + :class bindings on the same element - // into a single binding ['staticClass', dynamic] - function patchClass(el, value, isSVG) { - if (value == null) { - value = ''; - } - if (isSVG) { - el.setAttribute('class', value); - } - else { - // directly setting className should be faster than setAttribute in theory - // if this is an element during a transition, take the temporary transition - // classes into account. - const transitionClasses = el._vtc; - if (transitionClasses) { - value = (value - ? [value, ...transitionClasses] - : [...transitionClasses]).join(' '); - } - el.className = value; - } - } - - function patchStyle(el, prev, next) { - const style = el.style; - if (!next) { - el.removeAttribute('style'); - } - else if (isString(next)) { - if (prev !== next) { - style.cssText = next; - } - } - else { - for (const key in next) { - setStyle(style, key, next[key]); - } - if (prev && !isString(prev)) { - for (const key in prev) { - if (next[key] == null) { - setStyle(style, key, ''); - } - } - } - } - } - const importantRE = /\s*!important$/; - function setStyle(style, name, val) { - if (isArray(val)) { - val.forEach(v => setStyle(style, name, v)); - } - else { - if (name.startsWith('--')) { - // custom property definition - style.setProperty(name, val); - } - else { - const prefixed = autoPrefix(style, name); - if (importantRE.test(val)) { - // !important - style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important'); - } - else { - style[prefixed] = val; - } - } - } - } - const prefixes = ['Webkit', 'Moz', 'ms']; - const prefixCache = {}; - function autoPrefix(style, rawName) { - const cached = prefixCache[rawName]; - if (cached) { - return cached; - } - let name = camelize(rawName); - if (name !== 'filter' && name in style) { - return (prefixCache[rawName] = name); - } - name = capitalize(name); - for (let i = 0; i < prefixes.length; i++) { - const prefixed = prefixes[i] + name; - if (prefixed in style) { - return (prefixCache[rawName] = prefixed); - } - } - return rawName; - } - - const xlinkNS = 'http://www.w3.org/1999/xlink'; - function patchAttr(el, key, value, isSVG) { - if (isSVG && key.startsWith('xlink:')) { - if (value == null) { - el.removeAttributeNS(xlinkNS, key.slice(6, key.length)); - } - else { - el.setAttributeNS(xlinkNS, key, value); - } - } - else { - // note we are only checking boolean attributes that don't have a - // corresponding dom prop of the same name here. - const isBoolean = isSpecialBooleanAttr(key); - if (value == null || (isBoolean && value === false)) { - el.removeAttribute(key); - } - else { - el.setAttribute(key, isBoolean ? '' : value); - } - } - } - - // __UNSAFE__ - // functions. The user is responsible for using them with only trusted content. - function patchDOMProp(el, key, value, - // the following args are passed only due to potential innerHTML/textContent - // overriding existing VNodes, in which case the old tree must be properly - // unmounted. - prevChildren, parentComponent, parentSuspense, unmountChildren) { - if (key === 'innerHTML' || key === 'textContent') { - if (prevChildren) { - unmountChildren(prevChildren, parentComponent, parentSuspense); - } - el[key] = value == null ? '' : value; - return; - } - if (key === 'value' && el.tagName !== 'PROGRESS') { - // store value as _value as well since - // non-string values will be stringified. - el._value = value; - el.value = value == null ? '' : value; - return; - } - if (value === '' && typeof el[key] === 'boolean') { - // e.g. with - // :true-value & :false-value - // store value as dom properties since non-string values will be - // stringified. - if (key === 'true-value') { - el._trueValue = nextValue; - } - else if (key === 'false-value') { - el._falseValue = nextValue; - } - patchAttr(el, key, nextValue, isSVG); - } - break; - } - }; - function shouldSetAsProp(el, key, value, isSVG) { - if (isSVG) { - // most keys must be set as attribute on svg elements to work - // ...except innerHTML - if (key === 'innerHTML') { - return true; - } - // or native onclick with function values - if (key in el && nativeOnRE.test(key) && isFunction(value)) { - return true; - } - return false; - } - // spellcheck and draggable are numerated attrs, however their - // corresponding DOM properties are actually booleans - this leads to - // setting it with a string "false" value leading it to be coerced to - // `true`, so we need to always treat them as attributes. - // Note that `contentEditable` doesn't have this problem: its DOM - // property is also enumerated string values. - if (key === 'spellcheck' || key === 'draggable') { - return false; - } - // #1787 form as an attribute must be a string, while it accepts an Element as - // a prop - if (key === 'form' && typeof value === 'string') { - return false; - } - // #1526 must be set as attribute - if (key === 'list' && el.tagName === 'INPUT') { - return false; - } - // native onclick with string value, must be set as attribute - if (nativeOnRE.test(key) && isString(value)) { - return false; - } - return key in el; - } - - const TRANSITION = 'transition'; - const ANIMATION = 'animation'; - // DOM Transition is a higher-order-component based on the platform-agnostic - // base Transition component, with DOM-specific logic. - const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots); - Transition.displayName = 'Transition'; - const DOMTransitionPropsValidators = { - name: String, - type: String, - css: { - type: Boolean, - default: true - }, - duration: [String, Number, Object], - enterFromClass: String, - enterActiveClass: String, - enterToClass: String, - appearFromClass: String, - appearActiveClass: String, - appearToClass: String, - leaveFromClass: String, - leaveActiveClass: String, - leaveToClass: String - }; - const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators)); - function resolveTransitionProps(rawProps) { - let { name = 'v', type, css = true, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps; - const baseProps = {}; - for (const key in rawProps) { - if (!(key in DOMTransitionPropsValidators)) { - baseProps[key] = rawProps[key]; - } - } - if (!css) { - return baseProps; - } - const durations = normalizeDuration(duration); - const enterDuration = durations && durations[0]; - const leaveDuration = durations && durations[1]; - const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps; - const finishEnter = (el, isAppear, done) => { - removeTransitionClass(el, isAppear ? appearToClass : enterToClass); - removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass); - done && done(); - }; - const finishLeave = (el, done) => { - removeTransitionClass(el, leaveToClass); - removeTransitionClass(el, leaveActiveClass); - done && done(); - }; - const makeEnterHook = (isAppear) => { - return (el, done) => { - const hook = isAppear ? onAppear : onEnter; - const resolve = () => finishEnter(el, isAppear, done); - hook && hook(el, resolve); - nextFrame(() => { - removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass); - addTransitionClass(el, isAppear ? appearToClass : enterToClass); - if (!(hook && hook.length > 1)) { - if (enterDuration) { - setTimeout(resolve, enterDuration); - } - else { - whenTransitionEnds(el, type, resolve); - } - } - }); - }; - }; - return extend(baseProps, { - onBeforeEnter(el) { - onBeforeEnter && onBeforeEnter(el); - addTransitionClass(el, enterActiveClass); - addTransitionClass(el, enterFromClass); - }, - onBeforeAppear(el) { - onBeforeAppear && onBeforeAppear(el); - addTransitionClass(el, appearActiveClass); - addTransitionClass(el, appearFromClass); - }, - onEnter: makeEnterHook(false), - onAppear: makeEnterHook(true), - onLeave(el, done) { - const resolve = () => finishLeave(el, done); - addTransitionClass(el, leaveActiveClass); - addTransitionClass(el, leaveFromClass); - nextFrame(() => { - removeTransitionClass(el, leaveFromClass); - addTransitionClass(el, leaveToClass); - if (!(onLeave && onLeave.length > 1)) { - if (leaveDuration) { - setTimeout(resolve, leaveDuration); - } - else { - whenTransitionEnds(el, type, resolve); - } - } - }); - onLeave && onLeave(el, resolve); - }, - onEnterCancelled(el) { - finishEnter(el, false); - onEnterCancelled && onEnterCancelled(el); - }, - onAppearCancelled(el) { - finishEnter(el, true); - onAppearCancelled && onAppearCancelled(el); - }, - onLeaveCancelled(el) { - finishLeave(el); - onLeaveCancelled && onLeaveCancelled(el); - } - }); - } - function normalizeDuration(duration) { - if (duration == null) { - return null; - } - else if (isObject(duration)) { - return [NumberOf(duration.enter), NumberOf(duration.leave)]; - } - else { - const n = NumberOf(duration); - return [n, n]; - } - } - function NumberOf(val) { - const res = toNumber(val); - if ((process.env.NODE_ENV !== 'production')) - validateDuration(res); - return res; - } - function validateDuration(val) { - if (typeof val !== 'number') { - warn(` explicit duration is not a valid number - ` + - `got ${JSON.stringify(val)}.`); - } - else if (isNaN(val)) { - warn(` explicit duration is NaN - ` + - 'the duration expression might be incorrect.'); - } - } - function addTransitionClass(el, cls) { - cls.split(/\s+/).forEach(c => c && el.classList.add(c)); - (el._vtc || - (el._vtc = new Set())).add(cls); - } - function removeTransitionClass(el, cls) { - cls.split(/\s+/).forEach(c => c && el.classList.remove(c)); - const { _vtc } = el; - if (_vtc) { - _vtc.delete(cls); - if (!_vtc.size) { - el._vtc = undefined; - } - } - } - function nextFrame(cb) { - requestAnimationFrame(() => { - requestAnimationFrame(cb); - }); - } - function whenTransitionEnds(el, expectedType, cb) { - const { type, timeout, propCount } = getTransitionInfo(el, expectedType); - if (!type) { - return cb(); - } - const endEvent = type + 'end'; - let ended = 0; - const end = () => { - el.removeEventListener(endEvent, onEnd); - cb(); - }; - const onEnd = (e) => { - if (e.target === el) { - if (++ended >= propCount) { - end(); - } - } - }; - setTimeout(() => { - if (ended < propCount) { - end(); - } - }, timeout + 1); - el.addEventListener(endEvent, onEnd); - } - function getTransitionInfo(el, expectedType) { - const styles = window.getComputedStyle(el); - // JSDOM may return undefined for transition properties - const getStyleProperties = (key) => (styles[key] || '').split(', '); - const transitionDelays = getStyleProperties(TRANSITION + 'Delay'); - const transitionDurations = getStyleProperties(TRANSITION + 'Duration'); - const transitionTimeout = getTimeout(transitionDelays, transitionDurations); - const animationDelays = getStyleProperties(ANIMATION + 'Delay'); - const animationDurations = getStyleProperties(ANIMATION + 'Duration'); - const animationTimeout = getTimeout(animationDelays, animationDurations); - let type = null; - let timeout = 0; - let propCount = 0; - /* istanbul ignore if */ - if (expectedType === TRANSITION) { - if (transitionTimeout > 0) { - type = TRANSITION; - timeout = transitionTimeout; - propCount = transitionDurations.length; - } - } - else if (expectedType === ANIMATION) { - if (animationTimeout > 0) { - type = ANIMATION; - timeout = animationTimeout; - propCount = animationDurations.length; - } - } - else { - timeout = Math.max(transitionTimeout, animationTimeout); - type = - timeout > 0 - ? transitionTimeout > animationTimeout - ? TRANSITION - : ANIMATION - : null; - propCount = type - ? type === TRANSITION - ? transitionDurations.length - : animationDurations.length - : 0; - } - const hasTransform = type === TRANSITION && - /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']); - return { - type, - timeout, - propCount, - hasTransform - }; - } - function getTimeout(delays, durations) { - while (delays.length < durations.length) { - delays = delays.concat(delays); - } - return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i]))); - } - // Old versions of Chromium (below 61.0.3163.100) formats floating pointer - // numbers in a locale-dependent way, using a comma instead of a dot. - // If comma is not replaced with a dot, the input will be rounded down - // (i.e. acting as a floor function) causing unexpected behaviors - function toMs(s) { - return Number(s.slice(0, -1).replace(',', '.')) * 1000; - } - - function toRaw$1(observed) { - return ((observed && toRaw$1(observed["__v_raw" /* RAW */])) || observed); - } - - const positionMap = new WeakMap(); - const newPositionMap = new WeakMap(); - const TransitionGroupImpl = { - name: 'TransitionGroup', - props: /*#__PURE__*/ extend({}, TransitionPropsValidators, { - tag: String, - moveClass: String - }), - setup(props, { slots }) { - const instance = getCurrentInstance(); - const state = useTransitionState(); - let prevChildren; - let children; - onUpdated(() => { - // children is guaranteed to exist after initial render - if (!prevChildren.length) { - return; - } - const moveClass = props.moveClass || `${props.name || 'v'}-move`; - if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) { - return; - } - // we divide the work into three loops to avoid mixing DOM reads and writes - // in each iteration - which helps prevent layout thrashing. - prevChildren.forEach(callPendingCbs); - prevChildren.forEach(recordPosition); - const movedChildren = prevChildren.filter(applyTranslation); - // force reflow to put everything in position - forceReflow(); - movedChildren.forEach(c => { - const el = c.el; - const style = el.style; - addTransitionClass(el, moveClass); - style.transform = style.webkitTransform = style.transitionDuration = ''; - const cb = (el._moveCb = (e) => { - if (e && e.target !== el) { - return; - } - if (!e || /transform$/.test(e.propertyName)) { - el.removeEventListener('transitionend', cb); - el._moveCb = null; - removeTransitionClass(el, moveClass); - } - }); - el.addEventListener('transitionend', cb); - }); - }); - return () => { - const rawProps = toRaw$1(props); - const cssTransitionProps = resolveTransitionProps(rawProps); - const tag = rawProps.tag || Fragment; - prevChildren = children; - children = slots.default ? getTransitionRawChildren(slots.default()) : []; - for (let i = 0; i < children.length; i++) { - const child = children[i]; - if (child.key != null) { - setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance)); - } - else if ((process.env.NODE_ENV !== 'production')) { - warn(` children must be keyed.`); - } - } - if (prevChildren) { - for (let i = 0; i < prevChildren.length; i++) { - const child = prevChildren[i]; - setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance)); - positionMap.set(child, child.el.getBoundingClientRect()); - } - } - return createVNode(tag, null, children); - }; - } - }; - function callPendingCbs(c) { - const el = c.el; - if (el._moveCb) { - el._moveCb(); - } - if (el._enterCb) { - el._enterCb(); - } - } - function recordPosition(c) { - newPositionMap.set(c, c.el.getBoundingClientRect()); - } - function applyTranslation(c) { - const oldPos = positionMap.get(c); - const newPos = newPositionMap.get(c); - const dx = oldPos.left - newPos.left; - const dy = oldPos.top - newPos.top; - if (dx || dy) { - const s = c.el.style; - s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`; - s.transitionDuration = '0s'; - return c; - } - } - // this is put in a dedicated function to avoid the line from being treeshaken - function forceReflow() { - return document.body.offsetHeight; - } - function hasCSSTransform(el, root, moveClass) { - // Detect whether an element with the move class applied has - // CSS transitions. Since the element may be inside an entering - // transition at this very moment, we make a clone of it and remove - // all other transition classes applied to ensure only the move class - // is applied. - const clone = el.cloneNode(); - if (el._vtc) { - el._vtc.forEach(cls => { - cls.split(/\s+/).forEach(c => c && clone.classList.remove(c)); - }); - } - moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c)); - clone.style.display = 'none'; - const container = (root.nodeType === 1 - ? root - : root.parentNode); - container.appendChild(clone); - const { hasTransform } = getTransitionInfo(clone); - container.removeChild(clone); - return hasTransform; - } - - const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps); - - function initDev() { - const target = getGlobalThis(); - target.__VUE__ = true; - setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__); - { - console.info(`You are running a development build of Vue.\n` + - `Make sure to use the production build (*.prod.js) when deploying for production.`); - } - } - - // This entry exports the runtime only, and is built as - (process.env.NODE_ENV !== 'production') && initDev(); - - var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - - function createCommonjsModule(fn, module) { - return module = { exports: {} }, fn(module, module.exports), module.exports; - } - - var humps = createCommonjsModule(function (module) { - (function(global) { - - var _processKeys = function(convert, obj, options) { - if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) { - return obj; - } - - var output, - i = 0, - l = 0; - - if(_isArray(obj)) { - output = []; - for(l=obj.length; i= 0) continue; - if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; - target[i] = obj[i]; - } - - return target; - }; - - var toConsumableArray = function (arr) { - if (Array.isArray(arr)) { - for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; - - return arr2; - } else { - return Array.from(arr); - } - }; - - /** - * Converts a CSS style into a plain Javascript object. - * @param {String} style The style to converts into a plain Javascript object. - * @returns {Object} - */ - function styleToObject(style) { - return style.split(';').map(function (s) { - return s.trim(); - }).filter(function (s) { - return s; - }).reduce(function (output, pair) { - var idx = pair.indexOf(':'); - var prop = humps.camelize(pair.slice(0, idx)); - var value = pair.slice(idx + 1).trim(); - - output[prop] = value; - return output; - }, {}); - } - - /** - * Converts a CSS class list into a plain Javascript object. - * @param {Array} classes The class list to convert. - * @returns {Object} - */ - function classToObject(classes) { - return classes.split(/\s+/).reduce(function (output, className) { - output[className] = true; - return output; - }, {}); - } - - /** - * Converts a FontAwesome abstract element of an icon into a Vue render function. - * @param {AbstractElement | String} abstractElement The element to convert. - * @param {Object} props The user-defined props. - * @param {Object} attrs The user-defined native HTML attributes. - * @returns {Function | String} - */ - function convert$1(abstractElement) { - var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - var attrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; - - // If the abstract element is a string, we'll just return a string render function - if (typeof abstractElement === 'string') { - return abstractElement; - } - - // Converting abstract element children into Vue render functions, then we'll execute - // them to retrieve VDOM elements - var children = (abstractElement.children || []).map(function (child) { - return convert$1(child); - }).map(function (renderFn) { - return typeof renderFn === 'string' ? renderFn : renderFn(); - }); - - // Converting abstract element attributes into valid Vue format - var mixins = Object.keys(abstractElement.attributes || {}).reduce(function (mixins, key) { - var value = abstractElement.attributes[key]; - - switch (key) { - case 'class': - mixins.class = classToObject(value); - break; - case 'style': - mixins.style = styleToObject(value); - break; - default: - mixins.attrs[key] = value; - } - - return mixins; - }, { - attrs: {}, - class: {}, - style: {} - }); - - // Now, we'll return the render function of the - - var _attrs$class = attrs.class, - _attrs$style = attrs.style, - aStyle = _attrs$style === undefined ? {} : _attrs$style, - otherAttrs = objectWithoutProperties(attrs, ['class', 'style']); - - return function () { - return h(abstractElement.tag, _extends({}, props, { - class: mixins.class, - style: _extends({}, mixins.style, aStyle) - }, mixins.attrs, otherAttrs), children); - }; - } - - var PRODUCTION = false; - - try { - PRODUCTION = process.env.NODE_ENV === 'production'; - } catch (e) {} - - function log () { - if (!PRODUCTION && console && typeof console.error === 'function') { - var _console; - - (_console = console).error.apply(_console, arguments); - } - } - - function objectWithKey(key, value) { - return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? defineProperty({}, key, value) : {}; - } - - function classList(props) { - var _classes; - - var classes = (_classes = { - 'fa-spin': props.spin, - 'fa-pulse': props.pulse, - 'fa-fw': props.fixedWidth, - 'fa-border': props.border, - 'fa-li': props.listItem, - 'fa-inverse': props.inverse, - 'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both', - 'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both' - }, defineProperty(_classes, 'fa-' + props.size, props.size !== null), defineProperty(_classes, 'fa-rotate-' + props.rotation, props.rotation !== null), defineProperty(_classes, 'fa-pull-' + props.pull, props.pull !== null), defineProperty(_classes, 'fa-swap-opacity', props.swapOpacity), _classes); - - return Object.keys(classes).map(function (key) { - return classes[key] ? key : null; - }).filter(function (key) { - return key; - }); - } - - function normalizeIconArgs(icon) { - if (icon === null) { - return null; - } - - if ((typeof icon === 'undefined' ? 'undefined' : _typeof(icon)) === 'object' && icon.prefix && icon.iconName) { - return icon; - } - - if (Array.isArray(icon) && icon.length === 2) { - return { prefix: icon[0], iconName: icon[1] }; - } - - if (typeof icon === 'string') { - return { prefix: 'fas', iconName: icon }; - } - } - - var FontAwesomeIcon = defineComponent({ - name: 'FontAwesomeIcon', - - props: { - border: { - type: Boolean, - default: false - }, - fixedWidth: { - type: Boolean, - default: false - }, - flip: { - type: String, - default: null, - validator: function validator(value) { - return ['horizontal', 'vertical', 'both'].indexOf(value) > -1; - } - }, - icon: { - type: [Object, Array, String], - required: true - }, - mask: { - type: [Object, Array, String], - default: null - }, - listItem: { - type: Boolean, - default: false - }, - pull: { - type: String, - default: null, - validator: function validator(value) { - return ['right', 'left'].indexOf(value) > -1; - } - }, - pulse: { - type: Boolean, - default: false - }, - rotation: { - type: [String, Number], - default: null, - validator: function validator(value) { - return [90, 180, 270].indexOf(Number.parseInt(value, 10)) > -1; - } - }, - swapOpacity: { - type: Boolean, - default: false - }, - size: { - type: String, - default: null, - validator: function validator(value) { - return ['lg', 'xs', 'sm', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x'].indexOf(value) > -1; - } - }, - spin: { - type: Boolean, - default: false - }, - transform: { - type: [String, Object], - default: null - }, - symbol: { - type: [Boolean, String], - default: false - }, - title: { - type: String, - default: null - }, - inverse: { - type: Boolean, - default: false - } - }, - - setup: function setup(props, _ref) { - var attrs = _ref.attrs; - var symbol = props.symbol, - title = props.title; - - var icon = normalizeIconArgs(props.icon); - var classes = objectWithKey('classes', classList(props)); - var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); - var mask = objectWithKey('mask', normalizeIconArgs(props.mask)); - - var renderedIcon = fontawesomeSvgCore.icon(icon, _extends({}, classes, transform, mask, { - symbol: symbol, - title: title - })); - - if (!renderedIcon) { - return log('Could not find one or more icon(s)', icon, mask); - } - - var abstractElement = renderedIcon.abstract[0]; - return convert$1(abstractElement, {}, attrs); - } - }); - - var FontAwesomeLayers = defineComponent({ - name: 'FontAwesomeLayers', - - props: { - fixedWidth: { - type: Boolean, - default: false - } - }, - - setup: function setup(props, _ref) { - var slots = _ref.slots; - var familyPrefix = fontawesomeSvgCore.config.familyPrefix; - - - var className = [familyPrefix + '-layers'].concat(toConsumableArray(props.fixedWidth ? [familyPrefix + '-fw'] : [])); - - return function () { - return h('div', { class: className }, slots.default ? slots.default() : []); - }; - } - }); - - var FontAwesomeLayersText = defineComponent({ - name: 'FontAwesomeLayersText', - - props: { - value: { - type: [String, Number], - default: '' - }, - transform: { - type: [String, Object], - default: null - }, - counter: { - type: Boolean, - default: false - }, - position: { - type: String, - default: null, - validator: function validator(value) { - return ['bottom-left', 'bottom-right', 'top-left', 'top-right'].indexOf(value) > -1; - } - } - }, - - setup: function setup(props, _ref) { - var attrs = _ref.attrs; - var familyPrefix = fontawesomeSvgCore.config.familyPrefix; - - - var classes = objectWithKey('classes', [].concat(toConsumableArray(props.counter ? [familyPrefix + '-layers-counter'] : []), toConsumableArray(props.position ? [familyPrefix + '-layers-' + props.position] : []))); - var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); - var renderedText = fontawesomeSvgCore.text(props.value.toString(), _extends({}, transform, classes)); - - var abstract = renderedText.abstract; - - if (props.counter) { - abstract[0].attributes.class = abstract[0].attributes.class.replace('fa-layers-text', ''); - } - - return convert$1(abstract[0], {}, attrs); - } - }); - - exports.FontAwesomeIcon = FontAwesomeIcon; - exports.FontAwesomeLayers = FontAwesomeLayers; - exports.FontAwesomeLayersText = FontAwesomeLayersText; - - Object.defineProperty(exports, '__esModule', { value: true }); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@fortawesome/fontawesome-svg-core')) : + typeof define === 'function' && define.amd ? define(['exports', 'vue', '@fortawesome/fontawesome-svg-core'], factory) : + (factory((global['vue-fontawesome'] = {}),global.vue,global.FontAwesome)); +}(this, (function (exports,vue,fontawesomeSvgCore) { 'use strict'; + + var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + var humps = createCommonjsModule(function (module) { + (function(global) { + + var _processKeys = function(convert, obj, options) { + if(!_isObject(obj) || _isDate(obj) || _isRegExp(obj) || _isBoolean(obj) || _isFunction(obj)) { + return obj; + } + + var output, + i = 0, + l = 0; + + if(_isArray(obj)) { + output = []; + for(l=obj.length; i= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } + + return target; + }; + + var toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + /** + * Converts a CSS style into a plain Javascript object. + * @param {String} style The style to converts into a plain Javascript object. + * @returns {Object} + */ + function styleToObject(style) { + return style.split(';').map(function (s) { + return s.trim(); + }).filter(function (s) { + return s; + }).reduce(function (output, pair) { + var idx = pair.indexOf(':'); + var prop = humps.camelize(pair.slice(0, idx)); + var value = pair.slice(idx + 1).trim(); + + output[prop] = value; + return output; + }, {}); + } + + /** + * Converts a CSS class list into a plain Javascript object. + * @param {Array} classes The class list to convert. + * @returns {Object} + */ + function classToObject(classes) { + return classes.split(/\s+/).reduce(function (output, className) { + output[className] = true; + return output; + }, {}); + } + + /** + * Converts a FontAwesome abstract element of an icon into a Vue render function. + * @param {AbstractElement | String} abstractElement The element to convert. + * @param {Object} props The user-defined props. + * @param {Object} attrs The user-defined native HTML attributes. + * @returns {Function | String} + */ + function convert(abstractElement) { + var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var attrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; + + // If the abstract element is a string, we'll just return a string render function + if (typeof abstractElement === 'string') { + return abstractElement; + } + + // Converting abstract element children into Vue render functions, then we'll execute + // them to retrieve VDOM elements + var children = (abstractElement.children || []).map(function (child) { + return convert(child); + }).map(function (renderFn) { + return typeof renderFn === 'string' ? renderFn : renderFn(); + }); + + // Converting abstract element attributes into valid Vue format + var mixins = Object.keys(abstractElement.attributes || {}).reduce(function (mixins, key) { + var value = abstractElement.attributes[key]; + + switch (key) { + case 'class': + mixins.class = classToObject(value); + break; + case 'style': + mixins.style = styleToObject(value); + break; + default: + mixins.attrs[key] = value; + } + + return mixins; + }, { + attrs: {}, + class: {}, + style: {} + }); + + // Now, we'll return the render function of the + + var _attrs$class = attrs.class, + _attrs$style = attrs.style, + aStyle = _attrs$style === undefined ? {} : _attrs$style, + otherAttrs = objectWithoutProperties(attrs, ['class', 'style']); + + return function () { + return vue.h(abstractElement.tag, _extends({}, props, { + class: mixins.class, + style: _extends({}, mixins.style, aStyle) + }, mixins.attrs, otherAttrs), children); + }; + } + + var PRODUCTION = false; + + try { + PRODUCTION = process.env.NODE_ENV === 'production'; + } catch (e) {} + + function log () { + if (!PRODUCTION && console && typeof console.error === 'function') { + var _console; + + (_console = console).error.apply(_console, arguments); + } + } + + function objectWithKey(key, value) { + return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? defineProperty({}, key, value) : {}; + } + + function classList(props) { + var _classes; + + var classes = (_classes = { + 'fa-spin': props.spin, + 'fa-pulse': props.pulse, + 'fa-fw': props.fixedWidth, + 'fa-border': props.border, + 'fa-li': props.listItem, + 'fa-inverse': props.inverse, + 'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both', + 'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both' + }, defineProperty(_classes, 'fa-' + props.size, props.size !== null), defineProperty(_classes, 'fa-rotate-' + props.rotation, props.rotation !== null), defineProperty(_classes, 'fa-pull-' + props.pull, props.pull !== null), defineProperty(_classes, 'fa-swap-opacity', props.swapOpacity), _classes); + + return Object.keys(classes).map(function (key) { + return classes[key] ? key : null; + }).filter(function (key) { + return key; + }); + } + + function normalizeIconArgs(icon) { + if (icon === null) { + return null; + } + + if ((typeof icon === 'undefined' ? 'undefined' : _typeof(icon)) === 'object' && icon.prefix && icon.iconName) { + return icon; + } + + if (Array.isArray(icon) && icon.length === 2) { + return { prefix: icon[0], iconName: icon[1] }; + } + + if (typeof icon === 'string') { + return { prefix: 'fas', iconName: icon }; + } + } + + var FontAwesomeIcon = vue.defineComponent({ + name: 'FontAwesomeIcon', + + props: { + border: { + type: Boolean, + default: false + }, + fixedWidth: { + type: Boolean, + default: false + }, + flip: { + type: String, + default: null, + validator: function validator(value) { + return ['horizontal', 'vertical', 'both'].indexOf(value) > -1; + } + }, + icon: { + type: [Object, Array, String], + required: true + }, + mask: { + type: [Object, Array, String], + default: null + }, + listItem: { + type: Boolean, + default: false + }, + pull: { + type: String, + default: null, + validator: function validator(value) { + return ['right', 'left'].indexOf(value) > -1; + } + }, + pulse: { + type: Boolean, + default: false + }, + rotation: { + type: [String, Number], + default: null, + validator: function validator(value) { + return [90, 180, 270].indexOf(Number.parseInt(value, 10)) > -1; + } + }, + swapOpacity: { + type: Boolean, + default: false + }, + size: { + type: String, + default: null, + validator: function validator(value) { + return ['lg', 'xs', 'sm', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x'].indexOf(value) > -1; + } + }, + spin: { + type: Boolean, + default: false + }, + transform: { + type: [String, Object], + default: null + }, + symbol: { + type: [Boolean, String], + default: false + }, + title: { + type: String, + default: null + }, + inverse: { + type: Boolean, + default: false + } + }, + + setup: function setup(props, _ref) { + var attrs = _ref.attrs; + var symbol = props.symbol, + title = props.title; + + var icon = normalizeIconArgs(props.icon); + var classes = objectWithKey('classes', classList(props)); + var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); + var mask = objectWithKey('mask', normalizeIconArgs(props.mask)); + + var renderedIcon = fontawesomeSvgCore.icon(icon, _extends({}, classes, transform, mask, { + symbol: symbol, + title: title + })); + + if (!renderedIcon) { + return log('Could not find one or more icon(s)', icon, mask); + } + + var abstractElement = renderedIcon.abstract[0]; + return convert(abstractElement, {}, attrs); + } + }); + + var FontAwesomeLayers = vue.defineComponent({ + name: 'FontAwesomeLayers', + + props: { + fixedWidth: { + type: Boolean, + default: false + } + }, + + setup: function setup(props, _ref) { + var slots = _ref.slots; + var familyPrefix = fontawesomeSvgCore.config.familyPrefix; + + + var className = [familyPrefix + '-layers'].concat(toConsumableArray(props.fixedWidth ? [familyPrefix + '-fw'] : [])); + + return function () { + return vue.h('div', { class: className }, slots.default ? slots.default() : []); + }; + } + }); + + var FontAwesomeLayersText = vue.defineComponent({ + name: 'FontAwesomeLayersText', + + props: { + value: { + type: [String, Number], + default: '' + }, + transform: { + type: [String, Object], + default: null + }, + counter: { + type: Boolean, + default: false + }, + position: { + type: String, + default: null, + validator: function validator(value) { + return ['bottom-left', 'bottom-right', 'top-left', 'top-right'].indexOf(value) > -1; + } + } + }, + + setup: function setup(props, _ref) { + var attrs = _ref.attrs; + var familyPrefix = fontawesomeSvgCore.config.familyPrefix; + + + var classes = objectWithKey('classes', [].concat(toConsumableArray(props.counter ? [familyPrefix + '-layers-counter'] : []), toConsumableArray(props.position ? [familyPrefix + '-layers-' + props.position] : []))); + var transform = objectWithKey('transform', typeof props.transform === 'string' ? fontawesomeSvgCore.parse.transform(props.transform) : props.transform); + var renderedText = fontawesomeSvgCore.text(props.value.toString(), _extends({}, transform, classes)); + + var abstract = renderedText.abstract; + + if (props.counter) { + abstract[0].attributes.class = abstract[0].attributes.class.replace('fa-layers-text', ''); + } + + return convert(abstract[0], {}, attrs); + } + }); + + exports.FontAwesomeIcon = FontAwesomeIcon; + exports.FontAwesomeLayers = FontAwesomeLayers; + exports.FontAwesomeLayersText = FontAwesomeLayersText; + + Object.defineProperty(exports, '__esModule', { value: true }); }))); diff --git a/rollup.config.js b/rollup.config.js index 3878f857..7e1f825f 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -9,7 +9,8 @@ const globals = { export default { external: [ - '@fortawesome/fontawesome-svg-core' + '@fortawesome/fontawesome-svg-core', + 'vue', ], input: 'src/index.js', output: [