From 5c09e85ed04da917983d499ef7eadf4c6eb43418 Mon Sep 17 00:00:00 2001 From: qiang Date: Fri, 27 May 2022 21:35:29 +0800 Subject: [PATCH] chore: reset files to 97e8900de81df1213ad885fb4b6e9cae1ea5dd7e --- packages/uni-h5-vue/dist/vue.runtime.cjs.js | 2100 +++++++++--------- packages/uni-h5-vue/dist/vue.runtime.esm.js | 2106 +++++++++---------- 2 files changed, 2023 insertions(+), 2183 deletions(-) diff --git a/packages/uni-h5-vue/dist/vue.runtime.cjs.js b/packages/uni-h5-vue/dist/vue.runtime.cjs.js index 85324ce2e..64f012310 100644 --- a/packages/uni-h5-vue/dist/vue.runtime.cjs.js +++ b/packages/uni-h5-vue/dist/vue.runtime.cjs.js @@ -286,10 +286,7 @@ function trackEffects(dep, debuggerEventExtraInfo) { dep.add(activeEffect); activeEffect.deps.push(dep); if (activeEffect.onTrack) { - activeEffect.onTrack({ - effect: activeEffect, - ...debuggerEventExtraInfo - }); + activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo)); } } } @@ -369,28 +366,17 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) { } function triggerEffects(dep, debuggerEventExtraInfo) { // spread into array for stabilization - const effects = shared.isArray(dep) ? dep : [...dep]; - for (const effect of effects) { - if (effect.computed) { - triggerEffect(effect, debuggerEventExtraInfo); - } - } - for (const effect of effects) { - if (!effect.computed) { - triggerEffect(effect, debuggerEventExtraInfo); - } - } -} -function triggerEffect(effect, debuggerEventExtraInfo) { - if (effect !== activeEffect || effect.allowRecurse) { - if (effect.onTrigger) { - effect.onTrigger(shared.extend({ effect }, debuggerEventExtraInfo)); - } - if (effect.scheduler) { - effect.scheduler(); - } - else { - effect.run(); + for (const effect of shared.isArray(dep) ? dep : [...dep]) { + if (effect !== activeEffect || effect.allowRecurse) { + if (effect.onTrigger) { + effect.onTrigger(shared.extend({ effect }, debuggerEventExtraInfo)); + } + if (effect.scheduler) { + effect.scheduler(); + } + else { + effect.run(); + } } } } @@ -399,10 +385,6 @@ const isNonTrackableKeys = /*#__PURE__*/ shared.makeMap(`__proto__,__v_isRef,__i const builtInSymbols = new Set( /*#__PURE__*/ Object.getOwnPropertyNames(Symbol) - // ios10.x Object.getOwnPropertyNames(Symbol) can enumerate 'arguments' and 'caller' - // but accessing them on Symbol leads to TypeError because Symbol is a strict mode - // function - .filter(key => key !== 'arguments' && key !== 'caller') .map(key => Symbol[key]) .filter(shared.isSymbol)); const get = /*#__PURE__*/ createGetter(); @@ -476,8 +458,9 @@ function createGetter(isReadonly = false, shallow = false) { return res; } if (isRef(res)) { - // ref unwrapping - skip unwrap for Array + integer key. - return targetIsArray && shared.isIntegerKey(key) ? res : res.value; + // ref unwrapping - does not apply for Array + integer key. + const shouldUnwrap = !targetIsArray || !shared.isIntegerKey(key); + return shouldUnwrap ? res.value : res; } if (shared.isObject(res)) { // Convert returned value into a proxy as well. we do the isObject check @@ -583,12 +566,10 @@ function get$1(target, key, isReadonly = false, isShallow = false) { target = target["__v_raw" /* RAW */]; const rawTarget = toRaw(target); const rawKey = toRaw(key); - if (!isReadonly) { - if (key !== rawKey) { - track(rawTarget, "get" /* GET */, key); - } - track(rawTarget, "get" /* GET */, rawKey); + if (key !== rawKey) { + !isReadonly && track(rawTarget, "get" /* GET */, key); } + !isReadonly && track(rawTarget, "get" /* GET */, rawKey); const { has } = getProto(rawTarget); const wrap = isShallow ? toShallow : isReadonly ? toReadonly : toReactive; if (has.call(rawTarget, key)) { @@ -607,12 +588,10 @@ function has$1(key, isReadonly = false) { const target = this["__v_raw" /* RAW */]; const rawTarget = toRaw(target); const rawKey = toRaw(key); - if (!isReadonly) { - if (key !== rawKey) { - track(rawTarget, "has" /* HAS */, key); - } - track(rawTarget, "has" /* HAS */, rawKey); + if (key !== rawKey) { + !isReadonly && track(rawTarget, "has" /* HAS */, key); } + !isReadonly && track(rawTarget, "has" /* HAS */, rawKey); return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); @@ -938,7 +917,7 @@ function createReactiveObject(target, isReadonly, baseHandlers, collectionHandle if (existingProxy) { return existingProxy; } - // only specific value types can be observed. + // only a whitelist of value types can be observed. const targetType = getTargetType(target); if (targetType === 0 /* INVALID */) { return target; @@ -1493,8 +1472,6 @@ function flushPreFlushCbs(seen, parentJob = null) { } } function flushPostFlushCbs(seen) { - // flush any pre cbs queued during the flush (e.g. pre watchers) - flushPreFlushCbs(); if (pendingPostFlushCbs.length) { const deduped = [...new Set(pendingPostFlushCbs)]; pendingPostFlushCbs.length = 0; @@ -1759,6 +1736,7 @@ function setDevtoolsHook(hook, target) { // handle late devtools injection - only do this if we are in an actual // browser environment to avoid the timer handle stalling test runner exit // (#4815) + // eslint-disable-next-line no-restricted-globals typeof window !== 'undefined' && // some envs mock window but not fully // eslint-disable-next-line no-restricted-globals @@ -1854,7 +1832,7 @@ function emit$1(instance, event, ...rawArgs) { if (trim) { args = rawArgs.map(a => a.trim()); } - if (number) { + else if (number) { args = rawArgs.map(shared.toNumber); } } @@ -2197,8 +2175,6 @@ function renderComponentRoot(instance) { warn$1(`Runtime directive used on component with non-element root node. ` + `The directives will not function as intended.`); } - // clone before mutating since the root may be a hoisted vnode - root = cloneVNode(root); root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs; } // inherit transition data @@ -2860,12 +2836,10 @@ function watchEffect(effect, options) { return doWatch(effect, null, options); } function watchPostEffect(effect, options) { - return doWatch(effect, null, ({ ...options, flush: 'post' } - )); + return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'post' }) )); } function watchSyncEffect(effect, options) { - return doWatch(effect, null, ({ ...options, flush: 'sync' } - )); + return doWatch(effect, null, (Object.assign(Object.assign({}, options), { flush: 'sync' }) )); } // initial value for watchers to trigger on undefined initial values const INITIAL_WATCHER_VALUE = {}; @@ -2907,7 +2881,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh } else if (shared.isArray(source)) { isMultiSource = true; - forceTrigger = source.some(s => isReactive(s) || isShallow(s)); + forceTrigger = source.some(isReactive); getter = () => source.map(s => { if (isRef(s)) { return s.value; @@ -3016,7 +2990,16 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = sh } else { // default: 'pre' - scheduler = () => queuePreFlushCb(job); + 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(); + } + }; } const effect = new ReactiveEffect(getter, scheduler); { @@ -3269,17 +3252,6 @@ function resolveTransitionHooks(vnode, props, state, instance) { hook && callWithAsyncErrorHandling(hook, instance, 9 /* TRANSITION_HOOK */, args); }; - const callAsyncHook = (hook, args) => { - const done = args[1]; - callHook(hook, args); - if (shared.isArray(hook)) { - if (hook.every(hook => hook.length <= 1)) - done(); - } - else if (hook.length <= 1) { - done(); - } - }; const hooks = { mode, persisted, @@ -3338,7 +3310,10 @@ function resolveTransitionHooks(vnode, props, state, instance) { el._enterCb = undefined; }); if (hook) { - callAsyncHook(hook, [el, done]); + hook(el, done); + if (hook.length <= 1) { + done(); + } } else { done(); @@ -3372,7 +3347,10 @@ function resolveTransitionHooks(vnode, props, state, instance) { }); leavingVNodesCache[key] = vnode; if (onLeave) { - callAsyncHook(onLeave, [el, done]); + onLeave(el, done); + if (onLeave.length <= 1) { + done(); + } } else { done(); @@ -3582,7 +3560,7 @@ function defineAsyncComponent(source) { } }); } -function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) { +function createInnerComp(comp, { vnode: { ref, props, children } }) { const vnode = createVNode(comp, props, children); // ensure inner component inherits the async wrapper's ref owner vnode.ref = ref; @@ -3654,10 +3632,7 @@ const KeepAliveImpl = { // if the internal renderer is not registered, it indicates that this is server-side rendering, // for KeepAlive, we just need to render its children if (!sharedContext.renderer) { - return () => { - const children = slots.default && slots.default(); - return children && children.length === 1 ? children[0] : children; - }; + return () => slots.default && slots.default()[0]; // fixed by xxxxxx } if (props.cache && props.max) { // fixed by xxxxxx @@ -3952,13 +3927,13 @@ function resetHookState(hooks) { function injectHook(type, hook, target = currentInstance, prepend = false) { if (target) { // fixed by xxxxxx - if (uniShared.isRootHook(type)) { + if (uniShared.isRootHook(type) && target.$pageInstance) { // 系统保留组件,如 view,app 等 if (target.type.__reserved) { return; } - if (target !== target.root) { - target = target.root; + if (target !== target.$pageInstance) { + target = target.$pageInstance; if (uniShared.isRootImmediateHook(type)) { // 作用域应该是组件还是页面?目前绑定的是页面 const proxy = target.proxy; @@ -4023,821 +3998,263 @@ function onErrorCaptured(hook, target = currentInstance) { injectHook("ec" /* ERROR_CAPTURED */, hook, target); } -/** -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] -]) -*/ -function validateDirectiveName(name) { - if (shared.isBuiltInDirective(name)) { - warn$1('Do not use built-in directive ids as custom directive id: ' + name); - } -} -/** - * Adds directives to a VNode. - */ -function withDirectives(vnode, directives) { - const internalInstance = currentRenderingInstance; - if (internalInstance === null) { - warn$1(`withDirectives can only be used inside render functions.`); - return vnode; - } - const instance = getExposeProxy(internalInstance) || - internalInstance.proxy; - const bindings = vnode.dirs || (vnode.dirs = []); - for (let i = 0; i < directives.length; i++) { - let [dir, value, arg, modifiers = shared.EMPTY_OBJ] = directives[i]; - if (shared.isFunction(dir)) { - dir = { - mounted: dir, - updated: dir - }; - } - if (dir.deep) { - traverse(value); - } - bindings.push({ - dir, - instance, - value, - oldValue: void 0, - arg, - modifiers - }); - } - return vnode; -} -function invokeDirectiveHook(vnode, prevVNode, instance, name) { - const bindings = vnode.dirs; - const oldBindings = prevVNode && prevVNode.dirs; - for (let i = 0; i < bindings.length; i++) { - const binding = bindings[i]; - if (oldBindings) { - binding.oldValue = oldBindings[i].value; +function createDuplicateChecker() { + const cache = Object.create(null); + return (type, key) => { + if (cache[key]) { + warn$1(`${type} property "${key}" is already defined in ${cache[key]}.`); } - let hook = binding.dir[name]; - if (hook) { - // disable tracking inside all lifecycle hooks - // since they can potentially be called inside effects. - pauseTracking(); - callWithAsyncErrorHandling(hook, instance, 8 /* DIRECTIVE_HOOK */, [ - vnode.el, - binding, - vnode, - prevVNode - ]); - resetTracking(); + else { + cache[key] = type; } - } -} - -const COMPONENTS = 'components'; -const DIRECTIVES = 'directives'; -/** - * @private - */ -function resolveComponent(name, maybeSelfReference) { - return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name; + }; } -const NULL_DYNAMIC_COMPONENT = Symbol(); -/** - * @private - */ -function resolveDynamicComponent(component) { - if (shared.isString(component)) { - return resolveAsset(COMPONENTS, component, false) || component; - } - else { - // invalid types will fallthrough to createVNode and raise warning - return (component || NULL_DYNAMIC_COMPONENT); +let shouldCacheAccess = true; +function applyOptions(instance) { + const options = resolveMergedOptions(instance); + const publicThis = instance.proxy; + const ctx = instance.ctx; + // do not cache property access on public proxy during state initialization + shouldCacheAccess = false; + // call beforeCreate first before accessing other options since + // the hook may mutate resolved options (#2791) + if (options.beforeCreate) { + callHook(options.beforeCreate, instance, "bc" /* BEFORE_CREATE */); } -} -/** - * @private - */ -function resolveDirective(name) { - return resolveAsset(DIRECTIVES, name); -} -// implementation -function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) { - const instance = currentRenderingInstance || currentInstance; - if (instance) { - const Component = instance.type; - // explicit self name has highest priority - if (type === COMPONENTS) { - const selfName = getComponentName(Component); - if (selfName && - (selfName === name || - selfName === shared.camelize(name) || - selfName === shared.capitalize(shared.camelize(name)))) { - return Component; + const { + // state + data: dataOptions, computed: computedOptions, methods, watch: watchOptions, provide: provideOptions, inject: injectOptions, + // lifecycle + created, beforeMount, mounted, beforeUpdate, updated, activated, deactivated, beforeDestroy, beforeUnmount, destroyed, unmounted, render, renderTracked, renderTriggered, errorCaptured, serverPrefetch, + // public API + expose, inheritAttrs, + // assets + components, directives, filters } = options; + const checkDuplicateProperties = createDuplicateChecker() ; + { + const [propsOptions] = instance.propsOptions; + if (propsOptions) { + for (const key in propsOptions) { + checkDuplicateProperties("Props" /* PROPS */, key); } } - const res = - // local registration - // check instance[type] first which is resolved for options API - resolve(instance[type] || Component[type], name) || - // global registration - resolve(instance.appContext[type], name); - if (!res && maybeSelfReference) { - // fallback to implicit self-reference - return Component; - } - if (warnMissing && !res) { - const extra = type === COMPONENTS - ? `\nIf this is a native custom element, make sure to exclude it from ` + - `component resolution via compilerOptions.isCustomElement.` - : ``; - warn$1(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`); - } - return res; } - else { - warn$1(`resolve${shared.capitalize(type.slice(0, -1))} ` + - `can only be used in render() or setup().`); + // options initialization order (to be consistent with Vue 2): + // - props (already done outside of this function) + // - inject + // - methods + // - data (deferred since it relies on `this` access) + // - computed + // - watch (deferred since it relies on `this` access) + if (injectOptions) { + resolveInjections(injectOptions, ctx, checkDuplicateProperties, instance.appContext.config.unwrapInjectedRef); } -} -function resolve(registry, name) { - return (registry && - (registry[name] || - registry[shared.camelize(name)] || - registry[shared.capitalize(shared.camelize(name))])); -} - -/** - * Actual implementation - */ -function renderList(source, renderItem, cache, index) { - let ret; - const cached = (cache && cache[index]); - if (shared.isArray(source) || shared.isString(source)) { - ret = new Array(source.length); - for (let i = 0, l = source.length; i < l; i++) { - ret[i] = renderItem(source[i], i, undefined, cached && cached[i]); + if (methods) { + for (const key in methods) { + const methodHandler = methods[key]; + if (shared.isFunction(methodHandler)) { + // In dev mode, we use the `createRenderContext` function to define + // methods to the proxy target, and those are read-only but + // reconfigurable, so it needs to be redefined here + { + Object.defineProperty(ctx, key, { + value: methodHandler.bind(publicThis), + configurable: true, + enumerable: true, + writable: true + }); + } + { + checkDuplicateProperties("Methods" /* METHODS */, key); + } + } + else { + warn$1(`Method "${key}" has type "${typeof methodHandler}" in the component definition. ` + + `Did you reference the function correctly?`); + } } } - else if (typeof source === 'number') { - if (!Number.isInteger(source)) { - warn$1(`The v-for range expect an integer value but got ${source}.`); + if (dataOptions) { + if (!shared.isFunction(dataOptions)) { + warn$1(`The data option must be a function. ` + + `Plain object usage is no longer supported.`); } - ret = new Array(source); - for (let i = 0; i < source; i++) { - ret[i] = renderItem(i + 1, i, undefined, cached && cached[i]); + const data = dataOptions.call(publicThis, publicThis); + if (shared.isPromise(data)) { + warn$1(`data() returned a Promise - note data() cannot be async; If you ` + + `intend to perform data fetching before component renders, use ` + + `async setup() + .`); } - } - else if (shared.isObject(source)) { - if (source[Symbol.iterator]) { - ret = Array.from(source, (item, i) => renderItem(item, i, undefined, cached && cached[i])); + if (!shared.isObject(data)) { + warn$1(`data() should return an object.`); } else { - const keys = Object.keys(source); - ret = new Array(keys.length); - for (let i = 0, l = keys.length; i < l; i++) { - const key = keys[i]; - ret[i] = renderItem(source[key], key, i, cached && cached[i]); + instance.data = reactive(data); + { + for (const key in data) { + checkDuplicateProperties("Data" /* DATA */, key); + // expose data on ctx during dev + if (key[0] !== '$' && key[0] !== '_') { + Object.defineProperty(ctx, key, { + configurable: true, + enumerable: true, + get: () => data[key], + set: shared.NOOP + }); + } + } } } } - else { - ret = []; - } - if (cache) { - cache[index] = ret; - } - return ret; -} - -/** - * Compiler runtime helper for creating dynamic slots object - * @private - */ -function createSlots(slots, dynamicSlots) { - for (let i = 0; i < dynamicSlots.length; i++) { - const slot = dynamicSlots[i]; - // array of dynamic slot generated by