diff --git a/components/cardVideo.vue b/components/cardVideo.vue new file mode 100644 index 0000000..a2a94b7 --- /dev/null +++ b/components/cardVideo.vue @@ -0,0 +1,128 @@ + + + + + \ No newline at end of file diff --git a/components/photosInfo.vue b/components/photosInfo.vue new file mode 100644 index 0000000..dacb225 --- /dev/null +++ b/components/photosInfo.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/pages/discuss/CommentItem.vue b/pages/discuss/CommentItem.vue new file mode 100644 index 0000000..def7795 --- /dev/null +++ b/pages/discuss/CommentItem.vue @@ -0,0 +1,175 @@ + + + + + \ No newline at end of file diff --git a/pages/discuss/discuss.vue b/pages/discuss/discuss.vue index f4a5af9..f552c29 100644 --- a/pages/discuss/discuss.vue +++ b/pages/discuss/discuss.vue @@ -1,67 +1,111 @@ diff --git a/pages/intergral/intergral.vue b/pages/intergral/intergral.vue index 7991c89..8994949 100644 --- a/pages/intergral/intergral.vue +++ b/pages/intergral/intergral.vue @@ -1,56 +1,390 @@ + - + - - \ No newline at end of file diff --git a/pages/video/video.vue b/pages/video/video.vue index 7a2878e..0d418a3 100644 --- a/pages/video/video.vue +++ b/pages/video/video.vue @@ -1,187 +1,156 @@ - \ No newline at end of file diff --git a/unpackage/dist/dev/mp-weixin/app.js b/unpackage/dist/dev/mp-weixin/app.js index 65f6b27..1b7bb3b 100644 --- a/unpackage/dist/dev/mp-weixin/app.js +++ b/unpackage/dist/dev/mp-weixin/app.js @@ -21,7 +21,7 @@ const _sfc_main = { console.log("App Hide"); } }; -const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/DAN/wexinxiaochengxude/NewCode2/gree_leran/App.vue"]]); +const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "C:/Users/33043/Desktop/文件/work/newStud学习/greenStu/App.vue"]]); function createApp() { const app = common_vendor.createSSRApp(App); return { diff --git a/unpackage/dist/dev/mp-weixin/common/vendor.js b/unpackage/dist/dev/mp-weixin/common/vendor.js index ef674cd..8658b21 100644 --- a/unpackage/dist/dev/mp-weixin/common/vendor.js +++ b/unpackage/dist/dev/mp-weixin/common/vendor.js @@ -6,14 +6,13 @@ const _export_sfc = (sfc, props2) => { } return target; }; -/** -* @vue/shared v3.4.21 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/ function makeMap(str, expectsLowerCase) { - const set2 = new Set(str.split(",")); - return expectsLowerCase ? (val) => set2.has(val.toLowerCase()) : (val) => set2.has(val); + const map = /* @__PURE__ */ 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 EMPTY_OBJ = Object.freeze({}); const EMPTY_ARR = Object.freeze([]); @@ -95,10 +94,6 @@ const looseToNumber = (val) => { const n2 = parseFloat(val); return isNaN(n2) ? val : n2; }; -let _globalThis; -const getGlobalThis = () => { - return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {}); -}; function normalizeStyle(value2) { if (isArray(value2)) { const res = {}; @@ -177,8 +172,8 @@ const replacer = (_key, val) => { return val; }; const stringifySymbol = (v, i = "") => { - var _a; - return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v; + var _a2; + return isSymbol(v) ? `Symbol(${(_a2 = v.description) != null ? _a2 : i})` : v; }; const LINEFEED = "\n"; const SLOT_DEFAULT_NAME = "d"; @@ -374,9 +369,9 @@ E.prototype = { return this; }, once: function(name, callback, ctx) { - var self2 = this; + var self = this; function listener() { - self2.off(name, listener); + self.off(name, listener); callback.apply(ctx, arguments); } listener._ = callback; @@ -660,7 +655,7 @@ function wrapperHook(hook, params) { return hook(data, params) || data; }; } -function queue$2(hooks, data, params) { +function queue$1(hooks, data, params) { let promise2 = false; for (let i = 0; i < hooks.length; i++) { const hook = hooks[i]; @@ -697,7 +692,7 @@ function wrapperOptions(interceptors2, options = {}) { } const oldCallback = options[name]; options[name] = function callbackInterceptor(res) { - queue$2(hooks, res, options).then((res2) => { + queue$1(hooks, res, options).then((res2) => { return isFunction(oldCallback) && oldCallback(res2) || res2; }); }; @@ -739,7 +734,7 @@ function invokeApi(method, api, options, params) { const interceptor = getApiInterceptorHooks(method); if (interceptor && Object.keys(interceptor).length) { if (isArray(interceptor.invoke)) { - const res = queue$2(interceptor.invoke, options); + const res = queue$1(interceptor.invoke, options); return res.then((options2) => { return api(wrapperOptions(getApiInterceptorHooks(method), options2), ...params); }); @@ -799,8 +794,7 @@ function invokeSuccess(id, name, res) { function invokeFail(id, name, errMsg, errRes = {}) { const apiErrMsg = name + ":fail" + (errMsg ? " " + errMsg : ""); delete errRes.errCode; - let res = extend({ errMsg: apiErrMsg }, errRes); - return invokeCallback(id, res); + return invokeCallback(id, typeof UniError !== "undefined" ? typeof errRes.errCode !== "undefined" ? new UniError(name, errRes.errCode, apiErrMsg) : new UniError(apiErrMsg, errRes) : extend({ errMsg: apiErrMsg }, errRes)); } function beforeInvokeApi(name, args, protocol, options) { { @@ -1298,8 +1292,8 @@ function populateParameters(fromRes, toRes) { appVersion: "1.0.0", appVersionCode: "100", appLanguage: getAppLanguage(hostLanguage), - uniCompileVersion: "4.15", - uniRuntimeVersion: "4.15", + uniCompileVersion: "4.07", + uniRuntimeVersion: "4.07", uniPlatform: "mp-weixin", deviceBrand, deviceModel: model, @@ -1613,509 +1607,7 @@ var protocols = /* @__PURE__ */ Object.freeze({ }); const wx$1 = initWx(); var index = initUni(shims, protocols, wx$1); -new Set( - /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol) -); -function toRaw$1(observed) { - const raw = observed && observed["__v_raw"]; - return raw ? toRaw$1(raw) : observed; -} -function isRef$1(r2) { - return !!(r2 && r2.__v_isRef === true); -} -/** -* @vue/runtime-core v3.4.21 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/ -const stack$1 = []; -function pushWarningContext$1(vnode) { - stack$1.push(vnode); -} -function popWarningContext$1() { - stack$1.pop(); -} -function warn$1$1(msg, ...args) { - const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null; - const appWarnHandler = instance && instance.appContext.config.warnHandler; - const trace = getComponentTrace$1(); - if (appWarnHandler) { - callWithErrorHandling$1( - appWarnHandler, - instance, - 11, - [ - msg + args.map((a) => { - var _a, _b; - return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a); - }).join(""), - instance && instance.proxy, - trace.map( - ({ vnode }) => `at <${formatComponentName$1(instance, vnode.type)}>` - ).join("\n"), - trace - ] - ); - } else { - const warnArgs = [`[Vue warn]: ${msg}`, ...args]; - if (trace.length && // avoid spamming console during tests - true) { - warnArgs.push(` -`, ...formatTrace$1(trace)); - } - console.warn(...warnArgs); - } -} -function getComponentTrace$1() { - let currentVNode = stack$1[stack$1.length - 1]; - if (!currentVNode) { - return []; - } - 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; -} -function formatTrace$1(trace) { - const logs = []; - trace.forEach((entry, i) => { - logs.push(...i === 0 ? [] : [` -`], ...formatTraceEntry$1(entry)); - }); - return logs; -} -function formatTraceEntry$1({ vnode, recurseCount }) { - const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``; - const isRoot = vnode.component ? vnode.component.parent == null : false; - const open = ` at <${formatComponentName$1( - vnode.component, - vnode.type, - isRoot - )}`; - const close = `>` + postfix; - return vnode.props ? [open, ...formatProps$1(vnode.props), close] : [open + close]; -} -function formatProps$1(props2) { - const res = []; - const keys = Object.keys(props2); - keys.slice(0, 3).forEach((key) => { - res.push(...formatProp$1(key, props2[key])); - }); - if (keys.length > 3) { - res.push(` ...`); - } - return res; -} -function formatProp$1(key, value2, raw) { - if (isString(value2)) { - value2 = JSON.stringify(value2); - return raw ? value2 : [`${key}=${value2}`]; - } else if (typeof value2 === "number" || typeof value2 === "boolean" || value2 == null) { - return raw ? value2 : [`${key}=${value2}`]; - } else if (isRef$1(value2)) { - value2 = formatProp$1(key, toRaw$1(value2.value), true); - return raw ? value2 : [`${key}=Ref<`, value2, `>`]; - } else if (isFunction(value2)) { - return [`${key}=fn${value2.name ? `<${value2.name}>` : ``}`]; - } else { - value2 = toRaw$1(value2); - return raw ? value2 : [`${key}=`, value2]; - } -} -const ErrorTypeStrings$1 = { - ["sp"]: "serverPrefetch hook", - ["bc"]: "beforeCreate hook", - ["c"]: "created hook", - ["bm"]: "beforeMount hook", - ["m"]: "mounted hook", - ["bu"]: "beforeUpdate hook", - ["u"]: "updated", - ["bum"]: "beforeUnmount hook", - ["um"]: "unmounted hook", - ["a"]: "activated hook", - ["da"]: "deactivated hook", - ["ec"]: "errorCaptured hook", - ["rtc"]: "renderTracked hook", - ["rtg"]: "renderTriggered hook", - [0]: "setup function", - [1]: "render function", - [2]: "watcher getter", - [3]: "watcher callback", - [4]: "watcher cleanup function", - [5]: "native event handler", - [6]: "component event handler", - [7]: "vnode hook", - [8]: "directive hook", - [9]: "transition hook", - [10]: "app errorHandler", - [11]: "app warnHandler", - [12]: "ref function", - [13]: "async component loader", - [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ." -}; -function callWithErrorHandling$1(fn, instance, type, args) { - try { - return args ? fn(...args) : fn(); - } catch (err) { - handleError$1(err, instance, type); - } -} -function handleError$1(err, instance, type, throwInDev = true) { - const contextVNode = instance ? instance.vnode : null; - if (instance) { - let cur = instance.parent; - const exposedInstance = instance.proxy; - const errorInfo = ErrorTypeStrings$1[type]; - while (cur) { - const errorCapturedHooks = cur.ec; - if (errorCapturedHooks) { - for (let i = 0; i < errorCapturedHooks.length; i++) { - if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) { - return; - } - } - } - cur = cur.parent; - } - const appErrorHandler = instance.appContext.config.errorHandler; - if (appErrorHandler) { - callWithErrorHandling$1( - appErrorHandler, - null, - 10, - [err, exposedInstance, errorInfo] - ); - return; - } - } - logError$1(err, type, contextVNode, throwInDev); -} -function logError$1(err, type, contextVNode, throwInDev = true) { - { - const info = ErrorTypeStrings$1[type]; - if (contextVNode) { - pushWarningContext$1(contextVNode); - } - warn$1$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`); - if (contextVNode) { - popWarningContext$1(); - } - if (throwInDev) { - throw err; - } else { - console.error(err); - } - } -} -let isFlushing$1 = false; -let isFlushPending$1 = false; -const queue$1 = []; -let flushIndex$1 = 0; -const pendingPostFlushCbs$1 = []; -let activePostFlushCbs$1 = null; -let postFlushIndex$1 = 0; -const resolvedPromise$1 = /* @__PURE__ */ Promise.resolve(); -const RECURSION_LIMIT$1 = 100; -function findInsertionIndex$1(id) { - let start = flushIndex$1 + 1; - let end = queue$1.length; - while (start < end) { - const middle = start + end >>> 1; - const middleJob = queue$1[middle]; - const middleJobId = getId$1(middleJob); - if (middleJobId < id || middleJobId === id && middleJob.pre) { - start = middle + 1; - } else { - end = middle; - } - } - return start; -} -function queueJob$1(job) { - if (!queue$1.length || !queue$1.includes( - job, - isFlushing$1 && job.allowRecurse ? flushIndex$1 + 1 : flushIndex$1 - )) { - if (job.id == null) { - queue$1.push(job); - } else { - queue$1.splice(findInsertionIndex$1(job.id), 0, job); - } - queueFlush$1(); - } -} -function queueFlush$1() { - if (!isFlushing$1 && !isFlushPending$1) { - isFlushPending$1 = true; - resolvedPromise$1.then(flushJobs$1); - } -} -function queuePostFlushCb$1(cb) { - if (!isArray(cb)) { - if (!activePostFlushCbs$1 || !activePostFlushCbs$1.includes( - cb, - cb.allowRecurse ? postFlushIndex$1 + 1 : postFlushIndex$1 - )) { - pendingPostFlushCbs$1.push(cb); - } - } else { - pendingPostFlushCbs$1.push(...cb); - } - queueFlush$1(); -} -function flushPostFlushCbs$1(seen) { - if (pendingPostFlushCbs$1.length) { - const deduped = [...new Set(pendingPostFlushCbs$1)].sort( - (a, b) => getId$1(a) - getId$1(b) - ); - pendingPostFlushCbs$1.length = 0; - if (activePostFlushCbs$1) { - activePostFlushCbs$1.push(...deduped); - return; - } - activePostFlushCbs$1 = deduped; - { - seen = seen || /* @__PURE__ */ new Map(); - } - for (postFlushIndex$1 = 0; postFlushIndex$1 < activePostFlushCbs$1.length; postFlushIndex$1++) { - if (checkRecursiveUpdates$1(seen, activePostFlushCbs$1[postFlushIndex$1])) { - continue; - } - activePostFlushCbs$1[postFlushIndex$1](); - } - activePostFlushCbs$1 = null; - postFlushIndex$1 = 0; - } -} -const getId$1 = (job) => job.id == null ? Infinity : job.id; -const comparator$1 = (a, b) => { - const diff2 = getId$1(a) - getId$1(b); - if (diff2 === 0) { - if (a.pre && !b.pre) - return -1; - if (b.pre && !a.pre) - return 1; - } - return diff2; -}; -function flushJobs$1(seen) { - isFlushPending$1 = false; - isFlushing$1 = true; - { - seen = seen || /* @__PURE__ */ new Map(); - } - queue$1.sort(comparator$1); - const check = (job) => checkRecursiveUpdates$1(seen, job); - try { - for (flushIndex$1 = 0; flushIndex$1 < queue$1.length; flushIndex$1++) { - const job = queue$1[flushIndex$1]; - if (job && job.active !== false) { - if (check(job)) { - continue; - } - callWithErrorHandling$1(job, null, 14); - } - } - } finally { - flushIndex$1 = 0; - queue$1.length = 0; - flushPostFlushCbs$1(seen); - isFlushing$1 = false; - if (queue$1.length || pendingPostFlushCbs$1.length) { - flushJobs$1(seen); - } - } -} -function checkRecursiveUpdates$1(seen, fn) { - if (!seen.has(fn)) { - seen.set(fn, 1); - } else { - const count = seen.get(fn); - if (count > RECURSION_LIMIT$1) { - const instance = fn.ownerInstance; - const componentName = instance && getComponentName$1(instance.type); - handleError$1( - `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. 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.`, - null, - 10 - ); - return true; - } else { - seen.set(fn, count + 1); - } - } -} -const hmrDirtyComponents = /* @__PURE__ */ new Set(); -{ - getGlobalThis().__VUE_HMR_RUNTIME__ = { - createRecord: tryWrap(createRecord), - rerender: tryWrap(rerender), - reload: tryWrap(reload) - }; -} -const map = /* @__PURE__ */ new Map(); -function createRecord(id, initialDef) { - if (map.has(id)) { - return false; - } - map.set(id, { - initialDef: normalizeClassComponent(initialDef), - instances: /* @__PURE__ */ new Set() - }); - return true; -} -function normalizeClassComponent(component) { - return isClassComponent$1(component) ? component.__vccOpts : component; -} -function rerender(id, newRender) { - const record = map.get(id); - if (!record) { - return; - } - record.initialDef.render = newRender; - [...record.instances].forEach((instance) => { - if (newRender) { - instance.render = newRender; - normalizeClassComponent(instance.type).render = newRender; - } - instance.renderCache = []; - instance.effect.dirty = true; - instance.update(); - }); -} -function reload(id, newComp) { - const record = map.get(id); - if (!record) - return; - newComp = normalizeClassComponent(newComp); - updateComponentDef(record.initialDef, newComp); - const instances = [...record.instances]; - for (const instance of instances) { - const oldComp = normalizeClassComponent(instance.type); - if (!hmrDirtyComponents.has(oldComp)) { - if (oldComp !== record.initialDef) { - updateComponentDef(oldComp, newComp); - } - hmrDirtyComponents.add(oldComp); - } - instance.appContext.propsCache.delete(instance.type); - instance.appContext.emitsCache.delete(instance.type); - instance.appContext.optionsCache.delete(instance.type); - if (instance.ceReload) { - hmrDirtyComponents.add(oldComp); - instance.ceReload(newComp.styles); - hmrDirtyComponents.delete(oldComp); - } else if (instance.parent) { - instance.parent.effect.dirty = true; - queueJob$1(instance.parent.update); - } else if (instance.appContext.reload) { - instance.appContext.reload(); - } else if (typeof window !== "undefined") { - window.location.reload(); - } else { - console.warn( - "[HMR] Root or manually mounted instance modified. Full reload required." - ); - } - } - queuePostFlushCb$1(() => { - for (const instance of instances) { - hmrDirtyComponents.delete( - normalizeClassComponent(instance.type) - ); - } - }); -} -function updateComponentDef(oldComp, newComp) { - extend(oldComp, newComp); - for (const key in oldComp) { - if (key !== "__file" && !(key in newComp)) { - delete oldComp[key]; - } - } -} -function tryWrap(fn) { - return (id, arg) => { - try { - return fn(id, arg); - } catch (e2) { - console.error(e2); - console.warn( - `[HMR] Something went wrong during Vue component hot-reload. Full reload required.` - ); - } - }; -} -{ - const g = getGlobalThis(); - const registerGlobalSetter = (key, setter) => { - let setters; - if (!(setters = g[key])) - setters = g[key] = []; - setters.push(setter); - return (v) => { - if (setters.length > 1) - setters.forEach((set2) => set2(v)); - else - setters[0](v); - }; - }; - registerGlobalSetter( - `__VUE_INSTANCE_SETTERS__`, - (v) => v - ); - registerGlobalSetter( - `__VUE_SSR_SETTERS__`, - (v) => v - ); -} -const classifyRE$1 = /(?:^|[-_])(\w)/g; -const classify$1 = (str) => str.replace(classifyRE$1, (c2) => c2.toUpperCase()).replace(/[-_]/g, ""); -function getComponentName$1(Component2, includeInferred = true) { - return isFunction(Component2) ? Component2.displayName || Component2.name : Component2.name || includeInferred && Component2.__name; -} -function formatComponentName$1(instance, Component2, isRoot = false) { - let name = getComponentName$1(Component2); - if (!name && Component2.__file) { - const match = Component2.__file.match(/([^/\\]+)\.\w+$/); - if (match) { - name = match[1]; - } - } - if (!name && instance && instance.parent) { - const inferFromRegistry = (registry) => { - for (const key in registry) { - if (registry[key] === Component2) { - return key; - } - } - }; - name = inferFromRegistry( - instance.components || instance.parent.type.components - ) || inferFromRegistry(instance.appContext.components); - } - return name ? classify$1(name) : isRoot ? `App` : `Anonymous`; -} -function isClassComponent$1(value2) { - return isFunction(value2) && "__vccOpts" in value2; -} -/** -* @dcloudio/uni-mp-vue v3.4.21 -* (c) 2018-present Yuxi (Evan) You and Vue contributors -* @license MIT -**/ -function warn$2(msg, ...args) { +function warn$1(msg, ...args) { console.warn(`[Vue warn] ${msg}`, ...args); } let activeEffectScope; @@ -2127,9 +1619,7 @@ class EffectScope { this.cleanups = []; this.parent = activeEffectScope; if (!detached && activeEffectScope) { - this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push( - this - ) - 1; + this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1; } } get active() { @@ -2145,7 +1635,7 @@ class EffectScope { activeEffectScope = currentEffectScope; } } else { - warn$2(`cannot run an inactive effect scope.`); + warn$1(`cannot run an inactive effect scope.`); } } /** @@ -2188,108 +1678,120 @@ class EffectScope { } } } -function recordEffectScope(effect2, scope = activeEffectScope) { +function recordEffectScope(effect, scope = activeEffectScope) { if (scope && scope.active) { - scope.effects.push(effect2); + scope.effects.push(effect); } } function getCurrentScope() { return activeEffectScope; } +const createDep = (effects) => { + const dep = new Set(effects); + dep.w = 0; + dep.n = 0; + return dep; +}; +const wasTracked = (dep) => (dep.w & trackOpBit) > 0; +const newTracked = (dep) => (dep.n & trackOpBit) > 0; +const initDepMarkers = ({ deps }) => { + if (deps.length) { + for (let i = 0; i < deps.length; i++) { + deps[i].w |= trackOpBit; + } + } +}; +const finalizeDepMarkers = (effect) => { + const { deps } = effect; + if (deps.length) { + let ptr = 0; + for (let i = 0; i < deps.length; i++) { + const dep = deps[i]; + if (wasTracked(dep) && !newTracked(dep)) { + dep.delete(effect); + } else { + deps[ptr++] = dep; + } + dep.w &= ~trackOpBit; + dep.n &= ~trackOpBit; + } + deps.length = ptr; + } +}; +const targetMap = /* @__PURE__ */ new WeakMap(); +let effectTrackDepth = 0; +let trackOpBit = 1; +const maxMarkerBits = 30; let activeEffect; -class ReactiveEffect2 { - constructor(fn, trigger2, scheduler, scope) { +const ITERATE_KEY = Symbol("iterate"); +const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); +class ReactiveEffect { + constructor(fn, scheduler = null, scope) { this.fn = fn; - this.trigger = trigger2; this.scheduler = scheduler; this.active = true; this.deps = []; - this._dirtyLevel = 4; - this._trackId = 0; - this._runnings = 0; - this._shouldSchedule = false; - this._depsLength = 0; + this.parent = void 0; recordEffectScope(this, scope); } - get dirty() { - if (this._dirtyLevel === 2 || this._dirtyLevel === 3) { - this._dirtyLevel = 1; - pauseTracking(); - for (let i = 0; i < this._depsLength; i++) { - const dep = this.deps[i]; - if (dep.computed) { - triggerComputed(dep.computed); - if (this._dirtyLevel >= 4) { - break; - } - } - } - if (this._dirtyLevel === 1) { - this._dirtyLevel = 0; - } - resetTracking(); - } - return this._dirtyLevel >= 4; - } - set dirty(v) { - this._dirtyLevel = v ? 4 : 0; - } run() { - this._dirtyLevel = 0; if (!this.active) { return this.fn(); } + let parent = activeEffect; let lastShouldTrack = shouldTrack; - let lastEffect = activeEffect; + while (parent) { + if (parent === this) { + return; + } + parent = parent.parent; + } try { - shouldTrack = true; + this.parent = activeEffect; activeEffect = this; - this._runnings++; - preCleanupEffect(this); + shouldTrack = true; + trackOpBit = 1 << ++effectTrackDepth; + if (effectTrackDepth <= maxMarkerBits) { + initDepMarkers(this); + } else { + cleanupEffect(this); + } return this.fn(); } finally { - postCleanupEffect(this); - this._runnings--; - activeEffect = lastEffect; + if (effectTrackDepth <= maxMarkerBits) { + finalizeDepMarkers(this); + } + trackOpBit = 1 << --effectTrackDepth; + activeEffect = this.parent; shouldTrack = lastShouldTrack; + this.parent = void 0; + if (this.deferStop) { + this.stop(); + } } } stop() { - var _a; - if (this.active) { - preCleanupEffect(this); - postCleanupEffect(this); - (_a = this.onStop) == null ? void 0 : _a.call(this); + if (activeEffect === this) { + this.deferStop = true; + } else if (this.active) { + cleanupEffect(this); + if (this.onStop) { + this.onStop(); + } this.active = false; } } } -function triggerComputed(computed2) { - return computed2.value; -} -function preCleanupEffect(effect2) { - effect2._trackId++; - effect2._depsLength = 0; -} -function postCleanupEffect(effect2) { - if (effect2.deps.length > effect2._depsLength) { - for (let i = effect2._depsLength; i < effect2.deps.length; i++) { - cleanupDepEffect(effect2.deps[i], effect2); - } - effect2.deps.length = effect2._depsLength; - } -} -function cleanupDepEffect(dep, effect2) { - const trackId = dep.get(effect2); - if (trackId !== void 0 && effect2._trackId !== trackId) { - dep.delete(effect2); - if (dep.size === 0) { - dep.cleanup(); +function cleanupEffect(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; -let pauseScheduleStack = 0; const trackStack = []; function pauseTracking() { trackStack.push(shouldTrack); @@ -2299,67 +1801,6 @@ function resetTracking() { const last = trackStack.pop(); shouldTrack = last === void 0 ? true : last; } -function pauseScheduling() { - pauseScheduleStack++; -} -function resetScheduling() { - pauseScheduleStack--; - while (!pauseScheduleStack && queueEffectSchedulers.length) { - queueEffectSchedulers.shift()(); - } -} -function trackEffect(effect2, dep, debuggerEventExtraInfo) { - var _a; - if (dep.get(effect2) !== effect2._trackId) { - dep.set(effect2, effect2._trackId); - const oldDep = effect2.deps[effect2._depsLength]; - if (oldDep !== dep) { - if (oldDep) { - cleanupDepEffect(oldDep, effect2); - } - effect2.deps[effect2._depsLength++] = dep; - } else { - effect2._depsLength++; - } - { - (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); - } - } -} -const queueEffectSchedulers = []; -function triggerEffects(dep, dirtyLevel, debuggerEventExtraInfo) { - var _a; - pauseScheduling(); - for (const effect2 of dep.keys()) { - let tracking; - if (effect2._dirtyLevel < dirtyLevel && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { - effect2._shouldSchedule || (effect2._shouldSchedule = effect2._dirtyLevel === 0); - effect2._dirtyLevel = dirtyLevel; - } - if (effect2._shouldSchedule && (tracking != null ? tracking : tracking = dep.get(effect2) === effect2._trackId)) { - { - (_a = effect2.onTrigger) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo)); - } - effect2.trigger(); - if ((!effect2._runnings || effect2.allowRecurse) && effect2._dirtyLevel !== 2) { - effect2._shouldSchedule = false; - if (effect2.scheduler) { - queueEffectSchedulers.push(effect2.scheduler); - } - } - } - } - resetScheduling(); -} -const createDep = (cleanup, computed2) => { - const dep = /* @__PURE__ */ new Map(); - dep.cleanup = cleanup; - dep.computed = computed2; - return dep; -}; -const targetMap = /* @__PURE__ */ new WeakMap(); -const ITERATE_KEY = Symbol("iterate"); -const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); function track(target, type, key) { if (shouldTrack && activeEffect) { let depsMap = targetMap.get(target); @@ -2368,17 +1809,28 @@ function track(target, type, key) { } let dep = depsMap.get(key); if (!dep) { - depsMap.set(key, dep = createDep(() => depsMap.delete(key))); + depsMap.set(key, dep = createDep()); + } + const eventInfo = { effect: activeEffect, target, type, key }; + trackEffects(dep, eventInfo); + } +} +function trackEffects(dep, debuggerEventExtraInfo) { + let shouldTrack2 = false; + if (effectTrackDepth <= maxMarkerBits) { + if (!newTracked(dep)) { + dep.n |= trackOpBit; + shouldTrack2 = !wasTracked(dep); + } + } else { + shouldTrack2 = !dep.has(activeEffect); + } + if (shouldTrack2) { + dep.add(activeEffect); + activeEffect.deps.push(dep); + if (activeEffect.onTrack) { + activeEffect.onTrack(Object.assign({ effect: activeEffect }, debuggerEventExtraInfo)); } - trackEffect( - activeEffect, - dep, - { - target, - type, - key - } - ); } } function trigger(target, type, key, newValue, oldValue, oldTarget) { @@ -2392,7 +1844,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) { } else if (key === "length" && isArray(target)) { const newLength = Number(newValue); depsMap.forEach((dep, key2) => { - if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { + if (key2 === "length" || key2 >= newLength) { deps.push(dep); } }); @@ -2426,29 +1878,58 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) { break; } } - pauseScheduling(); - for (const dep of deps) { - if (dep) { - triggerEffects( - dep, - 4, - { - target, - type, - key, - newValue, - oldValue, - oldTarget - } - ); + const eventInfo = { target, type, key, newValue, oldValue, oldTarget }; + if (deps.length === 1) { + if (deps[0]) { + { + triggerEffects(deps[0], eventInfo); + } + } + } else { + const effects = []; + for (const dep of deps) { + if (dep) { + effects.push(...dep); + } + } + { + triggerEffects(createDep(effects), eventInfo); + } + } +} +function triggerEffects(dep, debuggerEventExtraInfo) { + const effects = 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(extend({ effect }, debuggerEventExtraInfo)); + } + if (effect.scheduler) { + effect.scheduler(); + } else { + effect.run(); } } - resetScheduling(); } const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); const builtInSymbols = new Set( /* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol) ); +const get$1 = /* @__PURE__ */ createGetter(); +const shallowGet = /* @__PURE__ */ createGetter(false, true); +const readonlyGet = /* @__PURE__ */ createGetter(true); +const shallowReadonlyGet = /* @__PURE__ */ createGetter(true, true); const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); function createArrayInstrumentations() { const instrumentations = {}; @@ -2469,9 +1950,7 @@ function createArrayInstrumentations() { ["push", "pop", "shift", "unshift", "splice"].forEach((key) => { instrumentations[key] = function(...args) { pauseTracking(); - pauseScheduling(); const res = toRaw(this)[key].apply(this, args); - resetScheduling(); resetTracking(); return res; }; @@ -2483,26 +1962,16 @@ function hasOwnProperty(key) { track(obj, "has", key); return obj.hasOwnProperty(key); } -class BaseReactiveHandler2 { - constructor(_isReadonly = false, _isShallow = false) { - this._isReadonly = _isReadonly; - this._isShallow = _isShallow; - } - get(target, key, receiver) { - const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow; +function createGetter(isReadonly2 = false, shallow = false) { + return function get2(target, key, receiver) { if (key === "__v_isReactive") { return !isReadonly2; } else if (key === "__v_isReadonly") { return isReadonly2; } else if (key === "__v_isShallow") { - return isShallow2; - } else if (key === "__v_raw") { - if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype - // this means the reciever is a user proxy of the reactive proxy - Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) { - return target; - } - return; + return shallow; + } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { + return target; } const targetIsArray = isArray(target); if (!isReadonly2) { @@ -2520,7 +1989,7 @@ class BaseReactiveHandler2 { if (!isReadonly2) { track(target, "get", key); } - if (isShallow2) { + if (shallow) { return res; } if (isRef(res)) { @@ -2530,27 +1999,24 @@ class BaseReactiveHandler2 { return isReadonly2 ? readonly(res) : reactive(res); } return res; - } + }; } -class MutableReactiveHandler2 extends BaseReactiveHandler2 { - constructor(isShallow2 = false) { - super(false, isShallow2); - } - set(target, key, value2, receiver) { +const set$1 = /* @__PURE__ */ createSetter(); +const shallowSet = /* @__PURE__ */ createSetter(true); +function createSetter(shallow = false) { + return function set2(target, key, value2, receiver) { let oldValue = target[key]; - if (!this._isShallow) { - const isOldValueReadonly = isReadonly(oldValue); + if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value2)) { + return false; + } + if (!shallow) { if (!isShallow(value2) && !isReadonly(value2)) { oldValue = toRaw(oldValue); value2 = toRaw(value2); } if (!isArray(target) && isRef(oldValue) && !isRef(value2)) { - if (isOldValueReadonly) { - return false; - } else { - oldValue.value = value2; - return true; - } + oldValue.value = value2; + return true; } } const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); @@ -2563,69 +2029,68 @@ class MutableReactiveHandler2 extends BaseReactiveHandler2 { } } return result; - } - deleteProperty(target, key) { - const hadKey = hasOwn(target, key); - const oldValue = target[key]; - const result = Reflect.deleteProperty(target, key); - if (result && hadKey) { - trigger(target, "delete", key, void 0, oldValue); - } - return result; - } - has(target, key) { - const result = Reflect.has(target, key); - if (!isSymbol(key) || !builtInSymbols.has(key)) { - track(target, "has", key); - } - return result; - } - ownKeys(target) { - track( - target, - "iterate", - isArray(target) ? "length" : ITERATE_KEY - ); - return Reflect.ownKeys(target); - } + }; } -class ReadonlyReactiveHandler2 extends BaseReactiveHandler2 { - constructor(isShallow2 = false) { - super(true, isShallow2); +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", key, void 0, oldValue); } + return result; +} +function has$1(target, key) { + const result = Reflect.has(target, key); + if (!isSymbol(key) || !builtInSymbols.has(key)) { + track(target, "has", key); + } + return result; +} +function ownKeys(target) { + track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); + return Reflect.ownKeys(target); +} +const mutableHandlers = { + get: get$1, + set: set$1, + deleteProperty, + has: has$1, + ownKeys +}; +const readonlyHandlers = { + get: readonlyGet, set(target, key) { { - warn$2( - `Set operation on key "${String(key)}" failed: target is readonly.`, - target - ); + warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target); } return true; - } + }, deleteProperty(target, key) { { - warn$2( - `Delete operation on key "${String(key)}" failed: target is readonly.`, - target - ); + warn$1(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); } return true; } -} -const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler2(); -const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler2(); -const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler2( - true -); -const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler2(true); +}; +const shallowReactiveHandlers = /* @__PURE__ */ extend({}, mutableHandlers, { + get: shallowGet, + set: shallowSet +}); +const shallowReadonlyHandlers = /* @__PURE__ */ extend({}, readonlyHandlers, { + get: shallowReadonlyGet +}); const toShallow = (value2) => value2; const getProto = (v) => Reflect.getPrototypeOf(v); function get(target, key, isReadonly2 = false, isShallow2 = false) { - target = target["__v_raw"]; + target = target[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]; const rawTarget = toRaw(target); const rawKey = toRaw(key); if (!isReadonly2) { - if (hasChanged(key, rawKey)) { + if (key !== rawKey) { track(rawTarget, "get", key); } track(rawTarget, "get", rawKey); @@ -2641,11 +2106,14 @@ function get(target, key, isReadonly2 = false, isShallow2 = false) { } } function has(key, isReadonly2 = false) { - const target = this["__v_raw"]; + const target = this[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]; const rawTarget = toRaw(target); const rawKey = toRaw(key); if (!isReadonly2) { - if (hasChanged(key, rawKey)) { + if (key !== rawKey) { track(rawTarget, "has", key); } track(rawTarget, "has", rawKey); @@ -2653,7 +2121,10 @@ function has(key, isReadonly2 = false) { return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); } function size(target, isReadonly2 = false) { - target = target["__v_raw"]; + target = target[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]; !isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY); return Reflect.get(target, "size", target); } @@ -2668,7 +2139,7 @@ function add(value2) { } return this; } -function set$1(key, value2) { +function set$2(key, value2) { value2 = toRaw(value2); const target = toRaw(this); const { has: has2, get: get2 } = getProto(target); @@ -2718,7 +2189,10 @@ function clear() { function createForEach(isReadonly2, isShallow2) { return function forEach(callback, thisArg) { const observed = this; - const target = observed["__v_raw"]; + const target = observed[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]; const rawTarget = toRaw(target); const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive; !isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY); @@ -2729,18 +2203,17 @@ function createForEach(isReadonly2, isShallow2) { } function createIterableMethod(method, isReadonly2, isShallow2) { return function(...args) { - const target = this["__v_raw"]; + const target = this[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]; const rawTarget = toRaw(target); const targetIsMap = isMap(rawTarget); const isPair = method === "entries" || method === Symbol.iterator && targetIsMap; const isKeyOnly = method === "keys" && targetIsMap; const innerIterator = target[method](...args); const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive; - !isReadonly2 && track( - rawTarget, - "iterate", - isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY - ); + !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); return { // iterator protocol next() { @@ -2761,12 +2234,9 @@ function createReadonlyMethod(type) { return function(...args) { { const key = args[0] ? `on key "${args[0]}" ` : ``; - warn$2( - `${capitalize(type)} operation ${key}failed: target is readonly.`, - toRaw(this) - ); + console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); } - return type === "delete" ? false : type === "clear" ? void 0 : this; + return type === "delete" ? false : this; }; } function createInstrumentations() { @@ -2779,7 +2249,7 @@ function createInstrumentations() { }, has, add, - set: set$1, + set: set$2, delete: deleteEntry, clear, forEach: createForEach(false, false) @@ -2793,7 +2263,7 @@ function createInstrumentations() { }, has, add, - set: set$1, + set: set$2, delete: deleteEntry, clear, forEach: createForEach(false, true) @@ -2808,10 +2278,22 @@ function createInstrumentations() { has(key) { return has.call(this, key, true); }, - add: createReadonlyMethod("add"), - set: createReadonlyMethod("set"), - delete: createReadonlyMethod("delete"), - clear: createReadonlyMethod("clear"), + add: createReadonlyMethod( + "add" + /* TriggerOpTypes.ADD */ + ), + set: createReadonlyMethod( + "set" + /* TriggerOpTypes.SET */ + ), + delete: createReadonlyMethod( + "delete" + /* TriggerOpTypes.DELETE */ + ), + clear: createReadonlyMethod( + "clear" + /* TriggerOpTypes.CLEAR */ + ), forEach: createForEach(true, false) }; const shallowReadonlyInstrumentations2 = { @@ -2824,27 +2306,30 @@ function createInstrumentations() { has(key) { return has.call(this, key, true); }, - add: createReadonlyMethod("add"), - set: createReadonlyMethod("set"), - delete: createReadonlyMethod("delete"), - clear: createReadonlyMethod("clear"), + add: createReadonlyMethod( + "add" + /* TriggerOpTypes.ADD */ + ), + set: createReadonlyMethod( + "set" + /* TriggerOpTypes.SET */ + ), + delete: createReadonlyMethod( + "delete" + /* TriggerOpTypes.DELETE */ + ), + clear: createReadonlyMethod( + "clear" + /* TriggerOpTypes.CLEAR */ + ), forEach: createForEach(true, true) }; - const iteratorMethods = [ - "keys", - "values", - "entries", - Symbol.iterator - ]; + const iteratorMethods = ["keys", "values", "entries", Symbol.iterator]; iteratorMethods.forEach((method) => { mutableInstrumentations2[method] = createIterableMethod(method, false, false); readonlyInstrumentations2[method] = createIterableMethod(method, true, false); shallowInstrumentations2[method] = createIterableMethod(method, false, true); - shallowReadonlyInstrumentations2[method] = createIterableMethod( - method, - true, - true - ); + shallowReadonlyInstrumentations2[method] = createIterableMethod(method, true, true); }); return [ mutableInstrumentations2, @@ -2853,12 +2338,7 @@ function createInstrumentations() { shallowReadonlyInstrumentations2 ]; } -const [ - mutableInstrumentations, - readonlyInstrumentations, - shallowInstrumentations, - shallowReadonlyInstrumentations -] = /* @__PURE__ */ createInstrumentations(); +const [mutableInstrumentations, readonlyInstrumentations, shallowInstrumentations, shallowReadonlyInstrumentations] = /* @__PURE__ */ createInstrumentations(); function createInstrumentationGetter(isReadonly2, shallow) { const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations; return (target, key, receiver) => { @@ -2869,11 +2349,7 @@ function createInstrumentationGetter(isReadonly2, shallow) { } else if (key === "__v_raw") { return target; } - return Reflect.get( - hasOwn(instrumentations, key) && key in target ? instrumentations : target, - key, - receiver - ); + return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver); }; } const mutableCollectionHandlers = { @@ -2892,9 +2368,7 @@ function checkIdentityKeys(target, has2, key) { const rawKey = toRaw(key); if (rawKey !== key && has2.call(target, rawKey)) { const type = toRawType(target); - warn$2( - `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.` - ); + 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.`); } } const reactiveMap = /* @__PURE__ */ new WeakMap(); @@ -2916,55 +2390,40 @@ function targetTypeMap(rawType) { } } function getTargetType(value2) { - return value2["__v_skip"] || !Object.isExtensible(value2) ? 0 : targetTypeMap(toRawType(value2)); + return value2[ + "__v_skip" + /* ReactiveFlags.SKIP */ + ] || !Object.isExtensible(value2) ? 0 : targetTypeMap(toRawType(value2)); } function reactive(target) { if (isReadonly(target)) { return target; } - return createReactiveObject( - target, - false, - mutableHandlers, - mutableCollectionHandlers, - reactiveMap - ); + return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); } function shallowReactive(target) { - return createReactiveObject( - target, - false, - shallowReactiveHandlers, - shallowCollectionHandlers, - shallowReactiveMap - ); + return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); } function readonly(target) { - return createReactiveObject( - target, - true, - readonlyHandlers, - readonlyCollectionHandlers, - readonlyMap - ); + return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); } function shallowReadonly(target) { - return createReactiveObject( - target, - true, - shallowReadonlyHandlers, - shallowReadonlyCollectionHandlers, - shallowReadonlyMap - ); + return createReactiveObject(target, true, shallowReadonlyHandlers, shallowReadonlyCollectionHandlers, shallowReadonlyMap); } function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) { if (!isObject(target)) { { - warn$2(`value cannot be made reactive: ${String(target)}`); + console.warn(`value cannot be made reactive: ${String(target)}`); } return target; } - if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) { + if (target[ + "__v_raw" + /* ReactiveFlags.RAW */ + ] && !(isReadonly2 && target[ + "__v_isReactive" + /* ReactiveFlags.IS_REACTIVE */ + ])) { return target; } const existingProxy = proxyMap.get(target); @@ -2975,143 +2434,78 @@ function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandl if (targetType === 0) { return target; } - const proxy = new Proxy( - target, - targetType === 2 ? collectionHandlers : baseHandlers - ); + const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); proxyMap.set(target, proxy); return proxy; } function isReactive(value2) { if (isReadonly(value2)) { - return isReactive(value2["__v_raw"]); + return isReactive(value2[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]); } - return !!(value2 && value2["__v_isReactive"]); + return !!(value2 && value2[ + "__v_isReactive" + /* ReactiveFlags.IS_REACTIVE */ + ]); } function isReadonly(value2) { - return !!(value2 && value2["__v_isReadonly"]); + return !!(value2 && value2[ + "__v_isReadonly" + /* ReactiveFlags.IS_READONLY */ + ]); } function isShallow(value2) { - return !!(value2 && value2["__v_isShallow"]); + return !!(value2 && value2[ + "__v_isShallow" + /* ReactiveFlags.IS_SHALLOW */ + ]); } function isProxy(value2) { return isReactive(value2) || isReadonly(value2); } function toRaw(observed) { - const raw = observed && observed["__v_raw"]; + const raw = observed && observed[ + "__v_raw" + /* ReactiveFlags.RAW */ + ]; return raw ? toRaw(raw) : observed; } function markRaw(value2) { - if (Object.isExtensible(value2)) { - def(value2, "__v_skip", true); - } + def(value2, "__v_skip", true); return value2; } const toReactive = (value2) => isObject(value2) ? reactive(value2) : value2; const toReadonly = (value2) => isObject(value2) ? readonly(value2) : value2; -const COMPUTED_SIDE_EFFECT_WARN = `Computed is still dirty after getter evaluation, likely because a computed is mutating its own dependency in its getter. State mutations in computed getters should be avoided. Check the docs for more details: https://vuejs.org/guide/essentials/computed.html#getters-should-be-side-effect-free`; -class ComputedRefImpl { - constructor(getter, _setter, isReadonly2, isSSR) { - this.getter = getter; - this._setter = _setter; - this.dep = void 0; - this.__v_isRef = true; - this["__v_isReadonly"] = false; - this.effect = new ReactiveEffect2( - () => getter(this._value), - () => triggerRefValue( - this, - this.effect._dirtyLevel === 2 ? 2 : 3 - ) - ); - this.effect.computed = this; - this.effect.active = this._cacheable = !isSSR; - this["__v_isReadonly"] = isReadonly2; - } - get value() { - const self2 = toRaw(this); - if ((!self2._cacheable || self2.effect.dirty) && hasChanged(self2._value, self2._value = self2.effect.run())) { - triggerRefValue(self2, 4); - } - trackRefValue(self2); - if (self2.effect._dirtyLevel >= 2) { - if (this._warnRecursive) { - warn$2(COMPUTED_SIDE_EFFECT_WARN, ` - -getter: `, this.getter); - } - triggerRefValue(self2, 2); - } - return self2._value; - } - set value(newValue) { - this._setter(newValue); - } - // #region polyfill _dirty for backward compatibility third party code for Vue <= 3.3.x - get _dirty() { - return this.effect.dirty; - } - set _dirty(v) { - this.effect.dirty = v; - } - // #endregion -} -function computed$1(getterOrOptions, debugOptions, isSSR = false) { - let getter; - let setter; - const onlyGetter = isFunction(getterOrOptions); - if (onlyGetter) { - getter = getterOrOptions; - setter = () => { - warn$2("Write operation failed: computed value is readonly"); - }; - } else { - getter = getterOrOptions.get; - setter = getterOrOptions.set; - } - const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); - if (debugOptions && !isSSR) { - cRef.effect.onTrack = debugOptions.onTrack; - cRef.effect.onTrigger = debugOptions.onTrigger; - } - return cRef; -} function trackRefValue(ref2) { - var _a; if (shouldTrack && activeEffect) { ref2 = toRaw(ref2); - trackEffect( - activeEffect, - (_a = ref2.dep) != null ? _a : ref2.dep = createDep( - () => ref2.dep = void 0, - ref2 instanceof ComputedRefImpl ? ref2 : void 0 - ), - { + { + trackEffects(ref2.dep || (ref2.dep = createDep()), { target: ref2, type: "get", key: "value" - } - ); + }); + } } } -function triggerRefValue(ref2, dirtyLevel = 4, newVal) { +function triggerRefValue(ref2, newVal) { ref2 = toRaw(ref2); const dep = ref2.dep; if (dep) { - triggerEffects( - dep, - dirtyLevel, - { + { + triggerEffects(dep, { target: ref2, type: "set", key: "value", newValue: newVal - } - ); + }); + } } } -function isRef(r2) { - return !!(r2 && r2.__v_isRef === true); +function isRef(r) { + return !!(r && r.__v_isRef === true); } function ref(value2) { return createRef(value2, false); @@ -3140,7 +2534,7 @@ class RefImpl { if (hasChanged(newVal, this._rawValue)) { this._rawValue = newVal; this._value = useDirectValue ? newVal : toReactive(newVal); - triggerRefValue(this, 4, newVal); + triggerRefValue(this, newVal); } } } @@ -3162,6 +2556,61 @@ const shallowUnwrapHandlers = { function proxyRefs(objectWithRefs) { return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers); } +var _a; +class ComputedRefImpl { + constructor(getter, _setter, isReadonly2, isSSR) { + this._setter = _setter; + this.dep = void 0; + this.__v_isRef = true; + this[_a] = false; + this._dirty = true; + this.effect = new ReactiveEffect(getter, () => { + if (!this._dirty) { + this._dirty = true; + triggerRefValue(this); + } + }); + this.effect.computed = this; + this.effect.active = this._cacheable = !isSSR; + this[ + "__v_isReadonly" + /* ReactiveFlags.IS_READONLY */ + ] = isReadonly2; + } + get value() { + const self = toRaw(this); + trackRefValue(self); + if (self._dirty || !self._cacheable) { + self._dirty = false; + self._value = self.effect.run(); + } + return self._value; + } + set value(newValue) { + this._setter(newValue); + } +} +_a = "__v_isReadonly"; +function computed$1(getterOrOptions, debugOptions, isSSR = false) { + let getter; + let setter; + const onlyGetter = isFunction(getterOrOptions); + if (onlyGetter) { + getter = getterOrOptions; + setter = () => { + console.warn("Write operation failed: computed value is readonly"); + }; + } else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR); + if (debugOptions && !isSSR) { + cRef.effect.onTrack = debugOptions.onTrack; + cRef.effect.onTrigger = debugOptions.onTrigger; + } + return cRef; +} const stack = []; function pushWarningContext(vnode) { stack.push(vnode); @@ -3169,28 +2618,18 @@ function pushWarningContext(vnode) { function popWarningContext() { stack.pop(); } -function warn$1(msg, ...args) { +function warn(msg, ...args) { 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, - [ - msg + args.map((a) => { - var _a, _b; - return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a); - }).join(""), - instance && instance.proxy, - trace.map( - ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>` - ).join("\n"), - trace - ] - ); + callWithErrorHandling(appWarnHandler, instance, 11, [ + msg + args.join(""), + instance && instance.proxy, + trace.map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`).join("\n"), + trace + ]); } else { const warnArgs = [`[Vue warn]: ${msg}`, ...args]; if (trace.length && // avoid spamming console during tests @@ -3234,11 +2673,7 @@ function formatTrace(trace) { 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 open = ` at <${formatComponentName(vnode.component, vnode.type, isRoot)}`; const close = `>` + postfix; return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close]; } @@ -3270,42 +2705,131 @@ function formatProp(key, value2, raw) { } } const ErrorTypeStrings = { - ["sp"]: "serverPrefetch hook", - ["bc"]: "beforeCreate hook", - ["c"]: "created hook", - ["bm"]: "beforeMount hook", - ["m"]: "mounted hook", - ["bu"]: "beforeUpdate hook", - ["u"]: "updated", - ["bum"]: "beforeUnmount hook", - ["um"]: "unmounted hook", - ["a"]: "activated hook", - ["da"]: "deactivated hook", - ["ec"]: "errorCaptured hook", - ["rtc"]: "renderTracked hook", - ["rtg"]: "renderTriggered hook", - [0]: "setup function", - [1]: "render function", - [2]: "watcher getter", - [3]: "watcher callback", - [4]: "watcher cleanup function", - [5]: "native event handler", - [6]: "component event handler", - [7]: "vnode hook", - [8]: "directive hook", - [9]: "transition hook", - [10]: "app errorHandler", - [11]: "app warnHandler", - [12]: "ref function", - [13]: "async component loader", - [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ." + [ + "sp" + /* LifecycleHooks.SERVER_PREFETCH */ + ]: "serverPrefetch hook", + [ + "bc" + /* LifecycleHooks.BEFORE_CREATE */ + ]: "beforeCreate hook", + [ + "c" + /* LifecycleHooks.CREATED */ + ]: "created hook", + [ + "bm" + /* LifecycleHooks.BEFORE_MOUNT */ + ]: "beforeMount hook", + [ + "m" + /* LifecycleHooks.MOUNTED */ + ]: "mounted hook", + [ + "bu" + /* LifecycleHooks.BEFORE_UPDATE */ + ]: "beforeUpdate hook", + [ + "u" + /* LifecycleHooks.UPDATED */ + ]: "updated", + [ + "bum" + /* LifecycleHooks.BEFORE_UNMOUNT */ + ]: "beforeUnmount hook", + [ + "um" + /* LifecycleHooks.UNMOUNTED */ + ]: "unmounted hook", + [ + "a" + /* LifecycleHooks.ACTIVATED */ + ]: "activated hook", + [ + "da" + /* LifecycleHooks.DEACTIVATED */ + ]: "deactivated hook", + [ + "ec" + /* LifecycleHooks.ERROR_CAPTURED */ + ]: "errorCaptured hook", + [ + "rtc" + /* LifecycleHooks.RENDER_TRACKED */ + ]: "renderTracked hook", + [ + "rtg" + /* LifecycleHooks.RENDER_TRIGGERED */ + ]: "renderTriggered hook", + [ + 0 + /* ErrorCodes.SETUP_FUNCTION */ + ]: "setup function", + [ + 1 + /* ErrorCodes.RENDER_FUNCTION */ + ]: "render function", + [ + 2 + /* ErrorCodes.WATCH_GETTER */ + ]: "watcher getter", + [ + 3 + /* ErrorCodes.WATCH_CALLBACK */ + ]: "watcher callback", + [ + 4 + /* ErrorCodes.WATCH_CLEANUP */ + ]: "watcher cleanup function", + [ + 5 + /* ErrorCodes.NATIVE_EVENT_HANDLER */ + ]: "native event handler", + [ + 6 + /* ErrorCodes.COMPONENT_EVENT_HANDLER */ + ]: "component event handler", + [ + 7 + /* ErrorCodes.VNODE_HOOK */ + ]: "vnode hook", + [ + 8 + /* ErrorCodes.DIRECTIVE_HOOK */ + ]: "directive hook", + [ + 9 + /* ErrorCodes.TRANSITION_HOOK */ + ]: "transition hook", + [ + 10 + /* ErrorCodes.APP_ERROR_HANDLER */ + ]: "app errorHandler", + [ + 11 + /* ErrorCodes.APP_WARN_HANDLER */ + ]: "app warnHandler", + [ + 12 + /* ErrorCodes.FUNCTION_REF */ + ]: "ref function", + [ + 13 + /* ErrorCodes.ASYNC_COMPONENT_LOADER */ + ]: "async component loader", + [ + 14 + /* ErrorCodes.SCHEDULER */ + ]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core" }; function callWithErrorHandling(fn, instance, type, args) { + let res; try { - return args ? fn(...args) : fn(); + res = args ? fn(...args) : fn(); } catch (err) { handleError(err, instance, type); } + return res; } function callWithAsyncErrorHandling(fn, instance, type, args) { if (isFunction(fn)) { @@ -3342,12 +2866,7 @@ function handleError(err, instance, type, throwInDev = true) { } const appErrorHandler = instance.appContext.config.errorHandler; if (appErrorHandler) { - callWithErrorHandling( - appErrorHandler, - null, - 10, - [err, exposedInstance, errorInfo] - ); + callWithErrorHandling(appErrorHandler, null, 10, [err, exposedInstance, errorInfo]); return; } } @@ -3359,7 +2878,7 @@ function logError(err, type, contextVNode, throwInDev = true) { if (contextVNode) { pushWarningContext(contextVNode); } - warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`); + warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`); if (contextVNode) { popWarningContext(); } @@ -3389,21 +2908,13 @@ function findInsertionIndex(id) { let end = queue.length; while (start < end) { const middle = start + end >>> 1; - const middleJob = queue[middle]; - const middleJobId = getId(middleJob); - if (middleJobId < id || middleJobId === id && middleJob.pre) { - start = middle + 1; - } else { - end = middle; - } + const middleJobId = getId(queue[middle]); + middleJobId < id ? start = middle + 1 : end = middle; } return start; } function queueJob(job) { - if (!queue.length || !queue.includes( - job, - isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex - )) { + if (!queue.length || !queue.includes(job, isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex)) { if (job.id == null) { queue.push(job); } else { @@ -3429,10 +2940,7 @@ function invalidateJob(job) { } function queuePostFlushCb(cb) { if (!isArray(cb)) { - if (!activePostFlushCbs || !activePostFlushCbs.includes( - cb, - cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex - )) { + if (!activePostFlushCbs || !activePostFlushCbs.includes(cb, cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex)) { pendingPostFlushCbs.push(cb); } } else { @@ -3440,16 +2948,13 @@ function queuePostFlushCb(cb) { } queueFlush(); } -function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) { +function flushPreFlushCbs(seen, i = isFlushing ? flushIndex + 1 : 0) { { seen = seen || /* @__PURE__ */ new Map(); } for (; i < queue.length; i++) { const cb = queue[i]; if (cb && cb.pre) { - if (instance && cb.id !== instance.uid) { - continue; - } if (checkRecursiveUpdates(seen, cb)) { continue; } @@ -3461,9 +2966,7 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) { } function flushPostFlushCbs(seen) { if (pendingPostFlushCbs.length) { - const deduped = [...new Set(pendingPostFlushCbs)].sort( - (a, b) => getId(a) - getId(b) - ); + const deduped = [...new Set(pendingPostFlushCbs)]; pendingPostFlushCbs.length = 0; if (activePostFlushCbs) { activePostFlushCbs.push(...deduped); @@ -3473,6 +2976,7 @@ function flushPostFlushCbs(seen) { { seen = seen || /* @__PURE__ */ new Map(); } + activePostFlushCbs.sort((a, b) => getId(a) - getId(b)); for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) { if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) { continue; @@ -3509,7 +3013,12 @@ function flushJobs(seen) { if (check(job)) { continue; } - callWithErrorHandling(job, null, 14); + callWithErrorHandling( + job, + null, + 14 + /* ErrorCodes.SCHEDULER */ + ); } } } finally { @@ -3531,11 +3040,7 @@ function checkRecursiveUpdates(seen, fn) { if (count > RECURSION_LIMIT) { const instance = fn.ownerInstance; const componentName = instance && getComponentName(instance.type); - handleError( - `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. 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.`, - null, - 10 - ); + warn(`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. 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.`); return true; } else { seen.set(fn, count + 1); @@ -3553,7 +3058,7 @@ function emit$1(event, ...args) { } } function setDevtoolsHook(hook, target) { - var _a, _b; + var _a2, _b; devtools = hook; if (devtools) { devtools.enabled = true; @@ -3564,8 +3069,10 @@ function setDevtoolsHook(hook, target) { // browser environment to avoid the timer handle stalling test runner exit // (#4815) typeof window !== "undefined" && // some envs mock window but not fully + // eslint-disable-next-line no-restricted-globals window.HTMLElement && // also exclude jsdom - !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom")) + // eslint-disable-next-line no-restricted-globals + !((_b = (_a2 = window.navigator) === null || _a2 === void 0 ? void 0 : _a2.userAgent) === null || _b === void 0 ? void 0 : _b.includes("jsdom")) ) { const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []; replay.push((newHook) => { @@ -3593,15 +3100,15 @@ function devtoolsInitApp(app, version2) { } const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook( "component:added" - /* COMPONENT_ADDED */ + /* DevtoolsHooks.COMPONENT_ADDED */ ); const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook( "component:updated" - /* COMPONENT_UPDATED */ + /* DevtoolsHooks.COMPONENT_UPDATED */ ); const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook( "component:removed" - /* COMPONENT_REMOVED */ + /* DevtoolsHooks.COMPONENT_REMOVED */ ); const devtoolsComponentRemoved = (component) => { if (devtools && typeof devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered @@ -3609,8 +3116,6 @@ const devtoolsComponentRemoved = (component) => { _devtoolsComponentRemoved(component); } }; -/*! #__NO_SIDE_EFFECTS__ */ -// @__NO_SIDE_EFFECTS__ function createDevtoolsComponentHook(hook) { return (component) => { emit$1( @@ -3626,11 +3131,11 @@ function createDevtoolsComponentHook(hook) { } const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook( "perf:start" - /* PERFORMANCE_START */ + /* DevtoolsHooks.PERFORMANCE_START */ ); const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook( "perf:end" - /* PERFORMANCE_END */ + /* DevtoolsHooks.PERFORMANCE_END */ ); function createDevtoolsPerformanceHook(hook) { return (component, type, time) => { @@ -3638,38 +3143,25 @@ function createDevtoolsPerformanceHook(hook) { }; } function devtoolsComponentEmit(component, event, params) { - emit$1( - "component:emit", - component.appContext.app, - component, - event, - params - ); + emit$1("component:emit", component.appContext.app, component, event, params); } function emit(instance, event, ...rawArgs) { if (instance.isUnmounted) return; const props2 = instance.vnode.props || EMPTY_OBJ; { - const { - emitsOptions, - propsOptions: [propsOptions] - } = instance; + const { emitsOptions, propsOptions: [propsOptions] } = instance; if (emitsOptions) { if (!(event in emitsOptions) && true) { if (!propsOptions || !(toHandlerKey(event) in propsOptions)) { - warn$1( - `Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.` - ); + warn(`Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`); } } else { const validator = emitsOptions[event]; if (isFunction(validator)) { const isValid = validator(...rawArgs); if (!isValid) { - warn$1( - `Invalid event arguments: event validation failed for event "${event}".` - ); + warn(`Invalid event arguments: event validation failed for event "${event}".`); } } } @@ -3694,14 +3186,7 @@ function emit(instance, event, ...rawArgs) { { const lowerCaseEvent = event.toLowerCase(); if (lowerCaseEvent !== event && props2[toHandlerKey(lowerCaseEvent)]) { - warn$1( - `Event "${lowerCaseEvent}" is emitted in component ${formatComponentName( - instance, - instance.type - )} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate( - event - )}" instead of "${event}".` - ); + warn(`Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(instance, instance.type)} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`); } } let handlerName; @@ -3711,12 +3196,7 @@ function emit(instance, event, ...rawArgs) { handler = props2[handlerName = toHandlerKey(hyphenate(event))]; } if (handler) { - callWithAsyncErrorHandling( - handler, - instance, - 6, - args - ); + callWithAsyncErrorHandling(handler, instance, 6, args); } const onceHandler = props2[handlerName + `Once`]; if (onceHandler) { @@ -3726,12 +3206,7 @@ function emit(instance, event, ...rawArgs) { return; } instance.emitted[handlerName] = true; - callWithAsyncErrorHandling( - onceHandler, - instance, - 6, - args - ); + callWithAsyncErrorHandling(onceHandler, instance, 6, args); } } function normalizeEmitsOptions(comp, appContext, asMixin = false) { @@ -3791,422 +3266,10 @@ function setCurrentRenderingInstance(instance) { instance && instance.type.__scopeId || null; return prev; } -const COMPONENTS = "components"; -function resolveComponent(name, maybeSelfReference) { - return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name; -} -function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) { - const instance = currentRenderingInstance || currentInstance; - if (instance) { - const Component2 = instance.type; - if (type === COMPONENTS) { - const selfName = getComponentName( - Component2, - false - ); - if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) { - return Component2; - } - } - const res = ( - // local registration - // check instance[type] first which is resolved for options API - resolve(instance[type] || Component2[type], name) || // global registration - resolve(instance.appContext[type], name) - ); - if (!res && maybeSelfReference) { - return Component2; - } - if (warnMissing && !res) { - const extra = type === COMPONENTS ? ` -If 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${capitalize(type.slice(0, -1))} can only be used in render() or setup().` - ); - } -} -function resolve(registry, name) { - return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]); -} -const INITIAL_WATCHER_VALUE = {}; -function watch(source, cb, options) { - if (!isFunction(cb)) { - warn$1( - `\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.` - ); - } - return doWatch(source, cb, options); -} -function doWatch(source, cb, { - immediate, - deep, - flush, - once: once2, - onTrack, - onTrigger -} = EMPTY_OBJ) { - if (cb && once2) { - const _cb = cb; - cb = (...args) => { - _cb(...args); - unwatch(); - }; - } - if (deep !== void 0 && typeof deep === "number") { - warn$1( - `watch() "deep" option with number value will be used as watch depth in future versions. Please use a boolean instead to avoid potential breakage.` - ); - } - if (!cb) { - if (immediate !== void 0) { - warn$1( - `watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.` - ); - } - if (deep !== void 0) { - warn$1( - `watch() "deep" option is only respected when using the watch(source, callback, options?) signature.` - ); - } - if (once2 !== void 0) { - warn$1( - `watch() "once" option is only respected when using the watch(source, callback, options?) signature.` - ); - } - } - const warnInvalidSource = (s2) => { - warn$1( - `Invalid watch source: `, - s2, - `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.` - ); - }; - const instance = currentInstance; - const reactiveGetter = (source2) => deep === true ? source2 : ( - // for deep: false, only traverse root-level properties - traverse(source2, deep === false ? 1 : void 0) - ); - let getter; - let forceTrigger = false; - let isMultiSource = false; - if (isRef(source)) { - getter = () => source.value; - forceTrigger = isShallow(source); - } else if (isReactive(source)) { - getter = () => reactiveGetter(source); - forceTrigger = true; - } else if (isArray(source)) { - isMultiSource = true; - forceTrigger = source.some((s2) => isReactive(s2) || isShallow(s2)); - getter = () => source.map((s2) => { - if (isRef(s2)) { - return s2.value; - } else if (isReactive(s2)) { - return reactiveGetter(s2); - } else if (isFunction(s2)) { - return callWithErrorHandling(s2, instance, 2); - } else { - warnInvalidSource(s2); - } - }); - } else if (isFunction(source)) { - if (cb) { - getter = () => callWithErrorHandling(source, instance, 2); - } else { - getter = () => { - if (cleanup) { - cleanup(); - } - return callWithAsyncErrorHandling( - source, - instance, - 3, - [onCleanup] - ); - }; - } - } else { - getter = NOOP; - warnInvalidSource(source); - } - if (cb && deep) { - const baseGetter = getter; - getter = () => traverse(baseGetter()); - } - let cleanup; - let onCleanup = (fn) => { - cleanup = effect2.onStop = () => { - callWithErrorHandling(fn, instance, 4); - cleanup = effect2.onStop = void 0; - }; - }; - let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE; - const job = () => { - if (!effect2.active || !effect2.dirty) { - return; - } - if (cb) { - const newValue = effect2.run(); - if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) { - if (cleanup) { - cleanup(); - } - callWithAsyncErrorHandling(cb, instance, 3, [ - newValue, - // pass undefined as the old value when it's changed for the first time - oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue, - onCleanup - ]); - oldValue = newValue; - } - } else { - effect2.run(); - } - }; - job.allowRecurse = !!cb; - let scheduler; - if (flush === "sync") { - scheduler = job; - } else if (flush === "post") { - scheduler = () => queuePostRenderEffect$1(job, instance && instance.suspense); - } else { - job.pre = true; - if (instance) - job.id = instance.uid; - scheduler = () => queueJob(job); - } - const effect2 = new ReactiveEffect2(getter, NOOP, scheduler); - const scope = getCurrentScope(); - const unwatch = () => { - effect2.stop(); - if (scope) { - remove(scope.effects, effect2); - } - }; - { - effect2.onTrack = onTrack; - effect2.onTrigger = onTrigger; - } - if (cb) { - if (immediate) { - job(); - } else { - oldValue = effect2.run(); - } - } else if (flush === "post") { - queuePostRenderEffect$1( - effect2.run.bind(effect2), - instance && instance.suspense - ); - } else { - effect2.run(); - } - return unwatch; -} -function instanceWatch(source, value2, options) { - const publicThis = this.proxy; - const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis); - let cb; - if (isFunction(value2)) { - cb = value2; - } else { - cb = value2.handler; - options = value2; - } - const reset = setCurrentInstance(this); - const res = doWatch(getter, cb.bind(publicThis), options); - reset(); - return res; -} -function createPathGetter(ctx, path) { - const segments = path.split("."); - return () => { - let cur = ctx; - for (let i = 0; i < segments.length && cur; i++) { - cur = cur[segments[i]]; - } - return cur; - }; -} -function traverse(value2, depth, currentDepth = 0, seen) { - if (!isObject(value2) || value2["__v_skip"]) { - return value2; - } - if (depth && depth > 0) { - if (currentDepth >= depth) { - return value2; - } - currentDepth++; - } - seen = seen || /* @__PURE__ */ new Set(); - if (seen.has(value2)) { - return value2; - } - seen.add(value2); - if (isRef(value2)) { - traverse(value2.value, depth, currentDepth, seen); - } else if (isArray(value2)) { - for (let i = 0; i < value2.length; i++) { - traverse(value2[i], depth, currentDepth, seen); - } - } else if (isSet(value2) || isMap(value2)) { - value2.forEach((v) => { - traverse(v, depth, currentDepth, seen); - }); - } else if (isPlainObject(value2)) { - for (const key in value2) { - traverse(value2[key], depth, currentDepth, seen); - } - } - return value2; -} -function validateDirectiveName(name) { - if (isBuiltInDirective(name)) { - warn$1("Do not use built-in directive ids as custom directive id: " + name); - } -} -function createAppContext() { - return { - app: null, - config: { - isNativeTag: NO, - performance: false, - globalProperties: {}, - optionMergeStrategies: {}, - errorHandler: void 0, - warnHandler: void 0, - compilerOptions: {} - }, - mixins: [], - components: {}, - directives: {}, - provides: /* @__PURE__ */ Object.create(null), - optionsCache: /* @__PURE__ */ new WeakMap(), - propsCache: /* @__PURE__ */ new WeakMap(), - emitsCache: /* @__PURE__ */ new WeakMap() - }; -} -let uid$1 = 0; -function createAppAPI(render, hydrate) { - return function createApp2(rootComponent, rootProps = null) { - if (!isFunction(rootComponent)) { - rootComponent = extend({}, rootComponent); - } - if (rootProps != null && !isObject(rootProps)) { - warn$1(`root props passed to app.mount() must be an object.`); - rootProps = null; - } - const context = createAppContext(); - const installedPlugins = /* @__PURE__ */ new WeakSet(); - const app = context.app = { - _uid: uid$1++, - _component: rootComponent, - _props: rootProps, - _container: null, - _context: context, - _instance: null, - version: version$1, - get config() { - return context.config; - }, - set config(v) { - { - warn$1( - `app.config cannot be replaced. Modify individual options instead.` - ); - } - }, - use(plugin2, ...options) { - if (installedPlugins.has(plugin2)) { - warn$1(`Plugin has already been applied to target app.`); - } else if (plugin2 && isFunction(plugin2.install)) { - installedPlugins.add(plugin2); - plugin2.install(app, ...options); - } else if (isFunction(plugin2)) { - installedPlugins.add(plugin2); - plugin2(app, ...options); - } else { - warn$1( - `A plugin must either be a function or an object with an "install" function.` - ); - } - return app; - }, - mixin(mixin2) { - { - if (!context.mixins.includes(mixin2)) { - context.mixins.push(mixin2); - } else { - warn$1( - "Mixin has already been applied to target app" + (mixin2.name ? `: ${mixin2.name}` : "") - ); - } - } - return app; - }, - component(name, component) { - { - validateComponentName(name, context.config); - } - if (!component) { - return context.components[name]; - } - if (context.components[name]) { - warn$1(`Component "${name}" has already been registered in target app.`); - } - context.components[name] = component; - return app; - }, - directive(name, directive) { - { - validateDirectiveName(name); - } - if (!directive) { - return context.directives[name]; - } - if (context.directives[name]) { - warn$1(`Directive "${name}" has already been registered in target app.`); - } - context.directives[name] = directive; - return app; - }, - // fixed by xxxxxx - mount() { - }, - // fixed by xxxxxx - unmount() { - }, - provide(key, value2) { - if (key in context.provides) { - warn$1( - `App already provides property with key "${String(key)}". It will be overwritten with the new value.` - ); - } - context.provides[key] = value2; - return app; - }, - runWithContext(fn) { - const lastApp = currentApp; - currentApp = app; - try { - return fn(); - } finally { - currentApp = lastApp; - } - } - }; - return app; - }; -} -let currentApp = null; function provide(key, value2) { if (!currentInstance) { { - warn$1(`provide() can only be used inside setup().`); + warn(`provide() can only be used inside setup().`); } } else { let provides = currentInstance.provides; @@ -4222,19 +3285,223 @@ function provide(key, value2) { } function inject(key, defaultValue, treatDefaultAsFactory = false) { const instance = currentInstance || currentRenderingInstance; - if (instance || currentApp) { - const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides; + if (instance) { + const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides; if (provides && key in provides) { return provides[key]; } else if (arguments.length > 1) { - return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue; + return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue; } else { - warn$1(`injection "${String(key)}" not found.`); + warn(`injection "${String(key)}" not found.`); } } else { - warn$1(`inject() can only be used inside setup() or functional components.`); + warn(`inject() can only be used inside setup() or functional components.`); } } +const INITIAL_WATCHER_VALUE = {}; +function watch(source, cb, options) { + if (!isFunction(cb)) { + warn(`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`); + } + return doWatch(source, cb, options); +} +function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ) { + if (!cb) { + if (immediate !== void 0) { + warn(`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`); + } + if (deep !== void 0) { + warn(`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`); + } + } + const warnInvalidSource = (s2) => { + warn(`Invalid watch source: `, s2, `A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`); + }; + const instance = getCurrentScope() === (currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope) ? currentInstance : null; + let getter; + let forceTrigger = false; + let isMultiSource = false; + if (isRef(source)) { + getter = () => source.value; + forceTrigger = isShallow(source); + } else if (isReactive(source)) { + getter = () => source; + deep = true; + } else if (isArray(source)) { + isMultiSource = true; + forceTrigger = source.some((s2) => isReactive(s2) || isShallow(s2)); + getter = () => source.map((s2) => { + if (isRef(s2)) { + return s2.value; + } else if (isReactive(s2)) { + return traverse(s2); + } else if (isFunction(s2)) { + return callWithErrorHandling( + s2, + instance, + 2 + /* ErrorCodes.WATCH_GETTER */ + ); + } else { + warnInvalidSource(s2); + } + }); + } else if (isFunction(source)) { + if (cb) { + getter = () => callWithErrorHandling( + source, + instance, + 2 + /* ErrorCodes.WATCH_GETTER */ + ); + } else { + getter = () => { + if (instance && instance.isUnmounted) { + return; + } + if (cleanup) { + cleanup(); + } + return callWithAsyncErrorHandling(source, instance, 3, [onCleanup]); + }; + } + } else { + getter = NOOP; + warnInvalidSource(source); + } + if (cb && deep) { + const baseGetter = getter; + getter = () => traverse(baseGetter()); + } + let cleanup; + let onCleanup = (fn) => { + cleanup = effect.onStop = () => { + callWithErrorHandling( + fn, + instance, + 4 + /* ErrorCodes.WATCH_CLEANUP */ + ); + }; + }; + let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE; + const job = () => { + if (!effect.active) { + return; + } + if (cb) { + const newValue = effect.run(); + if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) { + if (cleanup) { + cleanup(); + } + callWithAsyncErrorHandling(cb, instance, 3, [ + newValue, + // pass undefined as the old value when it's changed for the first time + oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue, + onCleanup + ]); + oldValue = newValue; + } + } else { + effect.run(); + } + }; + job.allowRecurse = !!cb; + let scheduler; + if (flush === "sync") { + scheduler = job; + } else if (flush === "post") { + scheduler = () => queuePostRenderEffect$1(job, instance && instance.suspense); + } else { + job.pre = true; + if (instance) + job.id = instance.uid; + scheduler = () => queueJob(job); + } + const effect = new ReactiveEffect(getter, scheduler); + { + effect.onTrack = onTrack; + effect.onTrigger = onTrigger; + } + if (cb) { + if (immediate) { + job(); + } else { + oldValue = effect.run(); + } + } else if (flush === "post") { + queuePostRenderEffect$1(effect.run.bind(effect), instance && instance.suspense); + } else { + effect.run(); + } + const unwatch = () => { + effect.stop(); + if (instance && instance.scope) { + remove(instance.scope.effects, effect); + } + }; + return unwatch; +} +function instanceWatch(source, value2, options) { + const publicThis = this.proxy; + const getter = isString(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis); + let cb; + if (isFunction(value2)) { + cb = value2; + } else { + cb = value2.handler; + options = value2; + } + const cur = currentInstance; + setCurrentInstance(this); + const res = doWatch(getter, cb.bind(publicThis), options); + if (cur) { + setCurrentInstance(cur); + } else { + unsetCurrentInstance(); + } + return res; +} +function createPathGetter(ctx, path) { + const segments = path.split("."); + return () => { + let cur = ctx; + for (let i = 0; i < segments.length && cur; i++) { + cur = cur[segments[i]]; + } + return cur; + }; +} +function traverse(value2, seen) { + if (!isObject(value2) || value2[ + "__v_skip" + /* ReactiveFlags.SKIP */ + ]) { + return value2; + } + seen = seen || /* @__PURE__ */ new Set(); + if (seen.has(value2)) { + return value2; + } + seen.add(value2); + if (isRef(value2)) { + traverse(value2.value, seen); + } else if (isArray(value2)) { + for (let i = 0; i < value2.length; i++) { + traverse(value2[i], seen); + } + } else if (isSet(value2) || isMap(value2)) { + value2.forEach((v) => { + traverse(v, seen); + }); + } else if (isPlainObject(value2)) { + for (const key in value2) { + traverse(value2[key], seen); + } + } + return value2; +} const isKeepAlive = (vnode) => vnode.type.__isKeepAlive; function onActivated(hook, target) { registerKeepAliveHook(hook, "a", target); @@ -4287,9 +3554,9 @@ function injectHook(type, hook, target = currentInstance, prepend = false) { return; } pauseTracking(); - const reset = setCurrentInstance(target); + setCurrentInstance(target); const res = callWithAsyncErrorHandling(hook, target, type, args); - reset(); + unsetCurrentInstance(); resetTracking(); return res; }); @@ -4300,34 +3567,98 @@ function injectHook(type, hook, target = currentInstance, prepend = false) { } return wrappedHook; } else { - const apiName = toHandlerKey( - (ErrorTypeStrings[type] || type.replace(/^on/, "")).replace(/ hook$/, "") - ); - warn$1( - `${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().` - ); + const apiName = toHandlerKey((ErrorTypeStrings[type] || type.replace(/^on/, "")).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().`); } } const createHook$1 = (lifecycle) => (hook, target = currentInstance) => ( // post-create lifecycle registrations are noops during SSR (except for serverPrefetch) (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target) ); -const onBeforeMount = createHook$1("bm"); -const onMounted = createHook$1("m"); -const onBeforeUpdate = createHook$1("bu"); -const onUpdated = createHook$1("u"); -const onBeforeUnmount = createHook$1("bum"); -const onUnmounted = createHook$1("um"); -const onServerPrefetch = createHook$1("sp"); +const onBeforeMount = createHook$1( + "bm" + /* LifecycleHooks.BEFORE_MOUNT */ +); +const onMounted = createHook$1( + "m" + /* LifecycleHooks.MOUNTED */ +); +const onBeforeUpdate = createHook$1( + "bu" + /* LifecycleHooks.BEFORE_UPDATE */ +); +const onUpdated = createHook$1( + "u" + /* LifecycleHooks.UPDATED */ +); +const onBeforeUnmount = createHook$1( + "bum" + /* LifecycleHooks.BEFORE_UNMOUNT */ +); +const onUnmounted = createHook$1( + "um" + /* LifecycleHooks.UNMOUNTED */ +); +const onServerPrefetch = createHook$1( + "sp" + /* LifecycleHooks.SERVER_PREFETCH */ +); const onRenderTriggered = createHook$1( "rtg" + /* LifecycleHooks.RENDER_TRIGGERED */ ); const onRenderTracked = createHook$1( "rtc" + /* LifecycleHooks.RENDER_TRACKED */ ); function onErrorCaptured(hook, target = currentInstance) { injectHook("ec", hook, target); } +function validateDirectiveName(name) { + if (isBuiltInDirective(name)) { + warn("Do not use built-in directive ids as custom directive id: " + name); + } +} +const COMPONENTS = "components"; +function resolveComponent(name, maybeSelfReference) { + return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name; +} +function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) { + const instance = currentRenderingInstance || currentInstance; + if (instance) { + const Component2 = instance.type; + if (type === COMPONENTS) { + const selfName = getComponentName( + Component2, + false + /* do not include inferred name to avoid breaking existing code */ + ); + if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) { + return Component2; + } + } + const res = ( + // local registration + // check instance[type] first which is resolved for options API + resolve(instance[type] || Component2[type], name) || // global registration + resolve(instance.appContext[type], name) + ); + if (!res && maybeSelfReference) { + return Component2; + } + if (warnMissing && !res) { + const extra = type === COMPONENTS ? ` +If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``; + warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`); + } + return res; + } else { + warn(`resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`); + } +} +function resolve(registry, name) { + return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]); +} const getPublicInstance = (i) => { if (!i) return null; @@ -4352,10 +3683,7 @@ const publicPropertiesMap = ( $root: (i) => getPublicInstance(i.root), $emit: (i) => i.emit, $options: (i) => resolveMergedOptions(i), - $forceUpdate: (i) => i.f || (i.f = () => { - i.effect.dirty = true; - queueJob(i.update); - }), + $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)), // $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy!)),// fixed by xxxxxx $watch: (i) => instanceWatch.bind(i) }) @@ -4407,8 +3735,6 @@ const PublicInstanceProxyHandlers = { if (publicGetter) { if (key === "$attrs") { track(instance, "get", key); - } else if (key === "$slots") { - track(instance, "get", key); } return publicGetter(instance); } else if ( @@ -4430,15 +3756,9 @@ const PublicInstanceProxyHandlers = { // to infinite warning loop key.indexOf("__v") !== 0)) { if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) { - warn$1( - `Property ${JSON.stringify( - key - )} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.` - ); + warn(`Property ${JSON.stringify(key)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`); } else if (instance === currentRenderingInstance) { - warn$1( - `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.` - ); + warn(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`); } } }, @@ -4448,19 +3768,17 @@ const PublicInstanceProxyHandlers = { setupState[key] = value2; return true; } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) { - warn$1(`Cannot mutate