diff --git a/packages/uni-mp-vue/dist/vue.runtime.esm.js b/packages/uni-mp-vue/dist/vue.runtime.esm.js index 4895be922fbc848f0dc67504e50c2b55e6e3f3b2..01f7bc25c6350e916efdf883b61fc7c2544f2820 100644 --- a/packages/uni-mp-vue/dist/vue.runtime.esm.js +++ b/packages/uni-mp-vue/dist/vue.runtime.esm.js @@ -1,5 +1,5 @@ -import { isSymbol, isObject, toRawType, def, hasChanged, isArray, isFunction, NOOP, remove, toHandlerKey, camelize, capitalize, isString, normalizeClass, extend, normalizeStyle, isOn, isPromise, EMPTY_OBJ, isSet, isMap, isPlainObject, invokeArrayFns, hasOwn, NO, isIntegerKey, toNumber, hyphenate, isReservedProp, EMPTY_ARR, makeMap, toTypeString } from '@vue/shared'; -export { camelize } from '@vue/shared'; +import { extend, isSymbol, isObject, toRawType, def, hasChanged, isArray, isFunction, NOOP, remove, toHandlerKey, camelize, capitalize, isString, normalizeClass, normalizeStyle, isOn, isPromise, EMPTY_OBJ, isSet, isMap, isPlainObject, invokeArrayFns, hasOwn, NO, isIntegerKey, toNumber, hyphenate, isReservedProp, EMPTY_ARR, makeMap, toTypeString } from '@vue/shared'; +export { camelize, normalizeClass, normalizeProps, normalizeStyle, toDisplayString, toHandlerKey } from '@vue/shared'; // lifecycle // App and Page @@ -30,6 +30,19 @@ const ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED = 'onNavigationBarSearchInputClicke const ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED = 'onNavigationBarSearchInputChanged'; const ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED = 'onNavigationBarSearchInputConfirmed'; const ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = 'onNavigationBarSearchInputFocusChanged'; + +const PAGE_HOOKS = [ + ON_SHOW, + ON_HIDE, + ON_BACK_PRESS, + ON_PAGE_SCROLL, + ON_TAB_ITEM_TAP, + ON_REACH_BOTTOM, + ON_PULL_DOWN_REFRESH, +]; +function isRootHook(name) { + return PAGE_HOOKS.indexOf(name) > -1; +} const UniLifecycleHooks = [ ON_SHOW, ON_HIDE, @@ -120,11 +133,26 @@ class EffectScope { } } } +function effectScope(detached) { + return new EffectScope(detached); +} function recordEffectScope(effect, scope) { scope = scope || activeEffectScope; if (scope && scope.active) { scope.effects.push(effect); } +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else if ((process.env.NODE_ENV !== 'production')) { + warn(`onScopeDispose() is called when there is no active effect scope` + + ` to be associated with.`); + } } const createDep = (effects) => { @@ -232,6 +260,26 @@ function cleanupEffect(effect) { deps.length = 0; } } +function effect(fn, options) { + if (fn.effect) { + fn = fn.effect.fn; + } + const _effect = new ReactiveEffect(fn); + if (options) { + extend(_effect, options); + if (options.scope) + recordEffectScope(_effect, options.scope); + } + if (!options || !options.lazy) { + _effect.run(); + } + const runner = _effect.run.bind(_effect); + runner.effect = _effect; + return runner; +} +function stop(runner) { + runner.effect.stop(); +} let shouldTrack = true; const trackStack = []; function pauseTracking() { @@ -1139,6 +1187,13 @@ function computed(getterOrOptions, debugOptions) { function emit(event, ...args) { } +const devtoolsComponentUpdated = +/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* COMPONENT_UPDATED */); +function createDevtoolsComponentHook(hook) { + return (component) => { + emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component); + }; +} function devtoolsComponentEmit(component, event, params) { emit("component:emit" /* COMPONENT_EMIT */, component.appContext.app, component, event, params); } @@ -1276,7 +1331,70 @@ function isEmitListener(options, key) { * resolveComponent, resolveDirective) during render */ let currentRenderingInstance = null; -let currentScopeId = null; +let currentScopeId = null; +/** + * Note: rendering calls maybe nested. The function returns the parent rendering + * instance if present, which should be restored after the render is done: + * + * ```js + * const prev = setCurrentRenderingInstance(i) + * // ...render + * setCurrentRenderingInstance(prev) + * ``` + */ +function setCurrentRenderingInstance(instance) { + const prev = currentRenderingInstance; + currentRenderingInstance = instance; + currentScopeId = (instance && instance.type.__scopeId) || null; + return prev; +} +/** + * Only for backwards compat + * @private + */ +const withScopeId = (_id) => withCtx; +/** + * Wrap a slot function to memoize current rendering instance + * @private compiler helper + */ +function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false only +) { + if (!ctx) + return fn; + // already normalized + if (fn._n) { + return fn; + } + const renderFnWithContext = (...args) => { + // If a user calls a compiled slot inside a template expression (#1745), it + // can mess up block tracking, so by default we disable block tracking and + // force bail out when invoking a compiled slot (indicated by the ._d flag). + // This isn't necessary if rendering a compiled ``, so we flip the + // ._d flag off when invoking the wrapped fn inside `renderSlot`. + if (renderFnWithContext._d) { + setBlockTracking(-1); + } + const prevInstance = setCurrentRenderingInstance(ctx); + const res = fn(...args); + setCurrentRenderingInstance(prevInstance); + if (renderFnWithContext._d) { + setBlockTracking(1); + } + if ((process.env.NODE_ENV !== 'production') || false) { + devtoolsComponentUpdated(ctx); + } + return res; + }; + // mark normalized to avoid duplicated wrapping + renderFnWithContext._n = true; + // mark this as compiled by default + // this is used in vnode.ts -> normalizeChildren() to set the slot + // rendering flag. + renderFnWithContext._c = true; + // disable block tracking by default + renderFnWithContext._d = true; + return renderFnWithContext; +} function markAttrsAccessed() { } @@ -1386,6 +1504,10 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) { function injectHook(type, hook, target = currentInstance, prepend = false) { if (target) { + // fixed by xxxxxx + if (isRootHook(type)) { + target = target.root; + } 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 @@ -1401,7 +1523,7 @@ function injectHook(type, hook, target = currentInstance, prepend = false) { // 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); + setCurrentInstance(target); // fixed by xxxxxx const res = callWithAsyncErrorHandling(hook, target, type, args); unsetCurrentInstance(); resetTracking(); @@ -2240,10 +2362,34 @@ function validateDirectiveName(name) { * Adds directives to a VNode. */ function withDirectives(vnode, directives) { - { + const internalInstance = currentRenderingInstance; + if (internalInstance === null) { (process.env.NODE_ENV !== 'production') && warn$1(`withDirectives can only be used inside render functions.`); return vnode; } + const instance = internalInstance.proxy; + const bindings = vnode.dirs || (vnode.dirs = []); + for (let i = 0; i < directives.length; i++) { + let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i]; + if (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 createAppContext() { @@ -2383,6 +2529,12 @@ const isTeleport = (type) => type.__isTeleport; const COMPONENTS = 'components'; const DIRECTIVES = 'directives'; +/** + * @private + */ +function resolveComponent(name, maybeSelfReference) { + return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name; +} const NULL_DYNAMIC_COMPONENT = Symbol(); /** * @private @@ -2392,7 +2544,7 @@ function resolveDirective(name) { } // implementation function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) { - const instance = currentInstance; + const instance = currentRenderingInstance || currentInstance; if (instance) { const Component = instance.type; // explicit self name has highest priority @@ -2441,6 +2593,30 @@ const Text = Symbol((process.env.NODE_ENV !== 'production') ? 'Text' : undefined const Comment = Symbol((process.env.NODE_ENV !== 'production') ? 'Comment' : undefined); 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 isBlockTreeEnabled = 1; +/** + * Block tracking sometimes needs to be disabled, for example during the + * creation of a tree that needs to be cached by v-once. The compiler generates + * code like this: + * + * ``` js + * _cache[1] || ( + * setBlockTracking(-1), + * _cache[1] = createVNode(...), + * setBlockTracking(1), + * _cache[1] + * ) + * ``` + * + * @private + */ +function setBlockTracking(value) { + isBlockTreeEnabled += value; +} function isVNode(value) { return value ? value.__v_isVNode === true : false; } @@ -2499,7 +2675,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn warn$1(`VNode created with invalid key (NaN). VNode type:`, vnode.type); } // track vnode for block tree - if (// avoid a block node from tracking itself + if (isBlockTreeEnabled > 0 && + // avoid a block node from tracking itself !isBlockNode && // has current parent block currentBlock && @@ -2742,6 +2919,22 @@ function mergeProps(...args) { return ret; } +/** + * For prefixing keys in v-on="obj" with "on" + * @private + */ +function toHandlers(obj) { + const ret = {}; + if ((process.env.NODE_ENV !== 'production') && !isObject(obj)) { + warn$1(`v-on with no argument expects an object value.`); + return ret; + } + for (const key in obj) { + ret[toHandlerKey(key)] = obj[key]; + } + return ret; +} + /** * #2437 In Vue 3, functional components do not have a public instance proxy but * they exist in the internal parent chain. For code that relies on traversing @@ -3153,17 +3346,8 @@ function setupStatefulComponent(instance, isSSR) { unsetCurrentInstance(); if (isPromise(setupResult)) { setupResult.then(unsetCurrentInstance, unsetCurrentInstance); - if (isSSR) { - // return the promise so server-renderer can wait on it - return setupResult - .then((resolvedResult) => { - handleSetupResult(instance, resolvedResult, isSSR); - }) - .catch(e => { - handleError(e, instance, 0 /* SETUP_FUNCTION */); - }); - } - else if ((process.env.NODE_ENV !== 'production')) { + // fixed by xxxxxx + if ((process.env.NODE_ENV !== 'production')) { warn$1(`setup() returned a Promise, but the version of Vue you are using ` + `does not support it yet.`); } @@ -3208,10 +3392,6 @@ let compile; const isRuntimeOnly = () => !compile; function finishComponentSetup(instance, isSSR, skipOptions) { const Component = instance.type; - // template / render function normalization - if (!instance.render) { - instance.render = (Component.render || NOOP); - } // support for 2.x options if (__VUE_OPTIONS_API__ && !(false )) { setCurrentInstance(instance); @@ -3772,6 +3952,16 @@ function checkRecursiveUpdates(seen, fn) { function watchEffect(effect, options) { return doWatch(effect, null, options); } +function watchPostEffect(effect, options) { + return doWatch(effect, null, ((process.env.NODE_ENV !== 'production') + ? Object.assign(options || {}, { flush: 'post' }) + : { flush: 'post' })); +} +function watchSyncEffect(effect, options) { + return doWatch(effect, null, ((process.env.NODE_ENV !== 'production') + ? Object.assign(options || {}, { flush: 'sync' }) + : { flush: 'sync' })); +} // initial value for watchers to trigger on undefined initial values const INITIAL_WATCHER_VALUE = {}; // implementation @@ -4026,10 +4216,136 @@ function defineEmits() { warnRuntimeUsage(`defineEmits`); } return null; +} +/** + * Vue `