From 7d972a7d99d0ac75af75b52f5b22889518dc9d03 Mon Sep 17 00:00:00 2001 From: xuxu <1438102025@qq.com> Date: Sun, 16 Jun 2024 23:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86=20=E8=A7=86?= =?UTF-8?q?=E9=A2=91=20=E8=AE=A8=E8=AE=BA=20=E7=A7=AF=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 2 +- pages.json | 78 +- pages/discuss/discuss.vue | 103 + pages/index/index.vue | 42 +- pages/intergral/intergral.vue | 56 + pages/user/login.vue | 30 +- pages/user/user.vue | 2 - pages/video/video.vue | 173 +- project.config.json | 28 + project.private.config.json | 7 + unpackage/dist/dev/mp-weixin/app.js | 5 +- unpackage/dist/dev/mp-weixin/app.json | 5 +- unpackage/dist/dev/mp-weixin/common/vendor.js | 3099 +++++++++++------ .../dist/dev/mp-weixin/components/newsCard.js | 2 +- .../components/u-avatar/u-avatar.js | 2 +- .../components/u-button/u-button.js | 2 +- .../uview-plus/components/u-cell/u-cell.js | 2 +- .../components/u-grid-item/u-grid-item.js | 2 +- .../uview-plus/components/u-grid/u-grid.js | 2 +- .../uview-plus/components/u-icon/u-icon.js | 2 +- .../uview-plus/components/u-line/u-line.js | 2 +- .../uview-plus/components/u-link/u-link.js | 2 +- .../components/u-list-item/u-list-item.js | 2 +- .../uview-plus/components/u-list/u-list.js | 2 +- .../u-loading-icon/u-loading-icon.js | 2 +- .../components/u-search/u-search.js | 2 +- .../u-swiper-indicator/u-swiper-indicator.js | 2 +- .../components/u-swiper/u-swiper.js | 2 +- .../uview-plus/components/u-text/u-text.js | 2 +- .../dev/mp-weixin/pages/discuss/discuss.js | 43 + .../dev/mp-weixin/pages/discuss/discuss.json | 5 + .../dev/mp-weixin/pages/discuss/discuss.wxml | 1 + .../dev/mp-weixin/pages/discuss/discuss.wxss | 46 + .../dist/dev/mp-weixin/pages/index/index.js | 21 +- .../dist/dev/mp-weixin/pages/index/index.wxml | 2 +- .../mp-weixin/pages/intergral/intergral.js | 15 + .../mp-weixin/pages/intergral/intergral.json | 5 + .../mp-weixin/pages/intergral/intergral.wxml | 1 + .../mp-weixin/pages/intergral/intergral.wxss | 24 + .../dist/dev/mp-weixin/pages/news/news.js | 4 +- .../dist/dev/mp-weixin/pages/user/login.js | 10 +- .../dist/dev/mp-weixin/pages/user/login.wxml | 2 +- .../dist/dev/mp-weixin/pages/user/user.js | 5 +- .../dist/dev/mp-weixin/pages/video/video.js | 119 + .../dist/dev/mp-weixin/pages/video/video.json | 5 + .../dist/dev/mp-weixin/pages/video/video.wxml | 1 + .../dist/dev/mp-weixin/pages/video/video.wxss | 25 + .../dist/dev/mp-weixin/project.config.json | 54 +- .../dev/mp-weixin/project.private.config.json | 11 +- unpackage/dist/dev/mp-weixin/utils/http.js | 7 +- utils/http.js | 40 +- 51 files changed, 2798 insertions(+), 1310 deletions(-) create mode 100644 pages/discuss/discuss.vue create mode 100644 pages/intergral/intergral.vue create mode 100644 project.config.json create mode 100644 project.private.config.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/discuss/discuss.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/discuss/discuss.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/discuss/discuss.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/discuss/discuss.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/intergral/intergral.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/intergral/intergral.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/intergral/intergral.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/intergral/intergral.wxss create mode 100644 unpackage/dist/dev/mp-weixin/pages/video/video.js create mode 100644 unpackage/dist/dev/mp-weixin/pages/video/video.json create mode 100644 unpackage/dist/dev/mp-weixin/pages/video/video.wxml create mode 100644 unpackage/dist/dev/mp-weixin/pages/video/video.wxss diff --git a/manifest.json b/manifest.json index 2f92ccf..aa52628 100644 --- a/manifest.json +++ b/manifest.json @@ -50,7 +50,7 @@ "quickapp" : {}, /* 小程序特有相关 */ "mp-weixin" : { - "appid" : "wx0beef2b22e05d3d1", + "appid" : "Ewx0beef2b22e05d3d1", "setting" : { "urlCheck" : false }, diff --git a/pages.json b/pages.json index 4719ebe..627999b 100644 --- a/pages.json +++ b/pages.json @@ -1,13 +1,13 @@ { "easycom": { - "autoscan": true, - // 注意一定要放在custom里,否则无效,https://ask.dcloud.net.cn/question/131175 - "custom": { - "^u--(.*)": "uview-plus/components/u-$1/u-$1.vue", - "^up-(.*)": "uview-plus/components/u-$1/u-$1.vue", - "^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue" - } - }, + "autoscan": true, + // 注意一定要放在custom里,否则无效,https://ask.dcloud.net.cn/question/131175 + "custom": { + "^u--(.*)": "uview-plus/components/u-$1/u-$1.vue", + "^up-(.*)": "uview-plus/components/u-$1/u-$1.vue", + "^u-([^-].*)": "uview-plus/components/u-$1/u-$1.vue" + } + }, "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", @@ -35,6 +35,29 @@ "navigationBarTitleText": "登录", "navigationStyle": "default" } + }, + { + + "path": "pages/video/video", + "style": { + "navigationBarTitleText": "视频", + "navigationStyle": "default" + } + }, + { + "path": "pages/intergral/intergral", + "style": { + "navigationBarTitleText": "积分", + "navigationStyle": "default" + } + }, + { + + "path": "pages/discuss/discuss", + "style": { + "navigationBarTitleText": "评论", + "navigationStyle": "default" + } } ], "globalStyle": { @@ -47,26 +70,25 @@ "tabBar": { "color": "#dcedc1", "selectedColor": "#ffd3b6", - "list": [ - { - "pagePath": "pages/index/index", - "text": "首页", - "iconPath": "static/icon/home.png", - "selectedIconPath": "static/icon/homeSelect.png" - }, - { - "pagePath": "pages/news/news", - "text": "资讯", - "iconPath": "static/icon/neq.png", - "selectedIconPath": "static/icon/newSelecgt.png" - }, - { - "pagePath": "pages/user/user", - "text": "我的", - "iconPath": "static/icon/user.png", - "selectedIconPath": "static/icon/user1.png" - } + "list": [{ + "pagePath": "pages/index/index", + "text": "首页", + "iconPath": "static/icon/home.png", + "selectedIconPath": "static/icon/homeSelect.png" + }, + { + "pagePath": "pages/news/news", + "text": "资讯", + "iconPath": "static/icon/neq.png", + "selectedIconPath": "static/icon/newSelecgt.png" + }, + { + "pagePath": "pages/user/user", + "text": "我的", + "iconPath": "static/icon/user.png", + "selectedIconPath": "static/icon/user1.png" + } ] } -} +} \ No newline at end of file diff --git a/pages/discuss/discuss.vue b/pages/discuss/discuss.vue new file mode 100644 index 0000000..f4a5af9 --- /dev/null +++ b/pages/discuss/discuss.vue @@ -0,0 +1,103 @@ + + + + + diff --git a/pages/index/index.vue b/pages/index/index.vue index 0ab13f6..3d16496 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -14,7 +14,7 @@ - + {{baseListItem.title}} @@ -47,23 +47,31 @@ const baseList = ref([ - { - src:'/static/icon/video.png', - title: '视频' - }, - { - src:'/static/icon/talk.png', - title: '讨论' - }, - { - src: '/static/icon/score.png', - title: '积分' - }, - { - src: '/static/icon/me.png', - title: '我的' - }, + { + src:'/static/icon/video.png', + title: '视频' , + url:"/pages/video/video" + }, + { + src:'/static/icon/talk.png', + title: '讨论', + url:'/pages/discuss/discuss' + }, + { + src: '/static/icon/score.png', + title: '积分', + url:'/pages/intergral/intergral' + }, + { + src: '/static/icon/me.png', + title: '我的', + }, ]); + function NavicatToBaseItems(item){ + uni.navigateTo({ + url:item.url + }) + } \ No newline at end of file diff --git a/pages/user/login.vue b/pages/user/login.vue index 665ff59..42c5f39 100644 --- a/pages/user/login.vue +++ b/pages/user/login.vue @@ -10,35 +10,43 @@ import { loginByCode } from "@/comm/api.js" - import {setToken} from "@/utils/Auth.js" + import { + setToken, + getToken + } from "@/utils/Auth.js" async function login() { const __this = this uni.login({ provider: "weixin", async success(e) { - + console.log(e.code) try { const resp = await loginByCode({ code: e.code }) - console.log(resp) + console.log(resp, "resp") uni.showToast({ - icon:"none", - title:"登录成功" + icon: "none", + title: "登录成功" }) setToken(resp.token) - setTimeout(()=>{ + setTimeout(() => { uni.switchTab({ - url:"/pages/user/user" + url: "/pages/user/user" }) - },800) - }catch(err){ + }, 800) + } catch (err) { + console.log(err,"errorCatch") uni.showToast({ - icon:"none", - title:"登录失败" + icon: "none", + title: "登录失败" }) } } + , + fail(err) { + console.log(err,"error") + } }) } diff --git a/pages/user/user.vue b/pages/user/user.vue index f2e4064..c8499fe 100644 --- a/pages/user/user.vue +++ b/pages/user/user.vue @@ -26,7 +26,6 @@ nickName: "点击登录" }) function gologin(){ - console.log(getToken()) if(isLogin()){ return } @@ -36,7 +35,6 @@ } async function getUserInfo(){ const resp = await userInfo() - console.log(resp) user.value = resp.data } onShow(()=>{ diff --git a/pages/video/video.vue b/pages/video/video.vue index 8183fd0..7a2878e 100644 --- a/pages/video/video.vue +++ b/pages/video/video.vue @@ -1,6 +1,23 @@ @@ -8,15 +25,163 @@ export default { data() { return { - + screenHeight: 0, + statusBarHeight: 0, + navBarHeight: 0, + originList: [], // 源数据 + displaySwiperList: [], // swiper需要的数据 + displayIndex: 0, // 用于显示swiper的真正的下标数值只有:0,1,2。 + originIndex: 0, // 记录源数据的下标 + changeIndex: 0, //控制video是否渲染 + page: 0, // 视频分页 + num: 0, + flag: true } }, + onLoad() { + /* 获取系统信息 */ + wx.getSystemInfo({ + success: (res) => { + // 获取屏幕高度 + this.screenHeight = res.screenHeight + // 获取状态栏高度 + this.statusBarHeight = res.statusBarHeight + // 通过操作系统 确定自定义导航栏高度 + if (res.system.substring(0, 3) == "iOS") { + this.navBarHeight = 42 + } else { + this.navBarHeight = 40 + } + } + }) + + // 调用函数 + this.getPageID() + + }, + methods: { - + /* 生成随机的 pageID */ + getPageID() { + let pageID = parseInt(Math.random() * (0 - 100 + 1) + 100) //生成 [min,max] 的随机数 + this.getVideoList(pageID) + }, + /* 获取视频数据 */ + getVideoList(pageID) { + uni.request({ + url: 'https://api.apiopen.top/api/getMiniVideo?page=' + pageID + + '&size=10&pageSize=10', // 请求数据接口 + data: {}, + success: (res) => { + if (res.data.code == 200) { + res.data.result.list.forEach(item => { + //取源数据的部分属性组合成新的数组 + let obj = {} + obj.src = item.playurl + obj.title = item.title + + this.originList.push(obj) + }) + } + //解决首次加载页面的时候没有画面的问题 + if (this.flag) { + this.flag = false + this.initSwiperData(0) + } + + } + }) + }, + changed(event) { + let { + current + } = event.detail; + let originListLength = this.originList.length; + this.changeIndex = current; + // console.log(this.displayIndex,current) + // 如果两者的差为2或者-1则是向后滑动 + if (this.displayIndex - current == 2 || this.displayIndex - current == -1) { + this.originIndex = this.originIndex + 1 == originListLength ? 0 : this.originIndex + 1; + this.displayIndex = this.displayIndex + 1 == 3 ? 0 : this.displayIndex + 1; + + this.initSwiperData(this.originIndex); + //如果滑到最后一条,请求新数据 + this.num++ + console.log('num', this.num, this.originList.length) + if (this.num + 5 >= this.originList.length) { + + this.getPageID() + } + } + // 如果两者的差为-2或者1则是向前滑动 + else if (this.displayIndex - current == -2 || this.displayIndex - current == 1) { + this.originIndex = this.originIndex - 1 == -1 ? originListLength - 1 : this.originIndex - 1; + this.displayIndex = this.displayIndex - 1 == -1 ? 2 : this.displayIndex - 1; + this.initSwiperData(this.originIndex); + + if (this.num > 0) { + this.num-- + } + } + }, + + initSwiperData(originIndex = this.originIndex) { + // console.log(this.displayIndex,originIndex) + // 0 0 + // 1 1 + // 2 2 + // 0 3 + // 1 4 + //源数据长度 + let originListLength = this.originList.length; + let displayList = []; + displayList[this.displayIndex] = this.originList[originIndex]; + displayList[this.displayIndex - 1 == -1 ? 2 : this.displayIndex - 1] = this.originList[originIndex - 1 == - + 1 ? originListLength - 1 : originIndex - 1]; + displayList[this.displayIndex + 1 == 3 ? 0 : this.displayIndex + 1] = this.originList[originIndex + 1 == + originListLength ? 0 : originIndex + 1]; + // console.log(originIndex, (originIndex - 1 == -1 ? originListLength - 1 : originIndex - 1), (originIndex + + // 1 == originListLength ? 0 : originIndex + 1)) + // 0 9 1 + // 1 0 2 + // 2 1 3 + // 3 2 4 + // 4 3 5 + //刷新数据 + this.displaySwiperList = displayList; + // console.log(this.displaySwiperList,this.originList) + }, } } + swiper-item { + height: 100%; + width: 100% + } + + video { + height: 96%; + width: 100% + } + + .video-text { + position: absolute; + margin-left: 32rpx; + width: 580rpx; + bottom: 200rpx; + z-index: 9999; + } + + .tips { + width: 560rpx; + font-size: 26rpx; + color: #ffffff; + } + \ No newline at end of file diff --git a/project.config.json b/project.config.json new file mode 100644 index 0000000..8f121ec --- /dev/null +++ b/project.config.json @@ -0,0 +1,28 @@ +{ + "appid": "wx0b2e6f02015ee7c1", + "compileType": "miniprogram", + "libVersion": "3.4.7", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "coverView": true, + "es6": true, + "postcss": true, + "minified": true, + "enhance": true, + "showShadowRootInWxmlPanel": true, + "packNpmRelationList": [], + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/project.private.config.json b/project.private.config.json new file mode 100644 index 0000000..94d6f2f --- /dev/null +++ b/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "gree_leran", + "setting": { + "compileHotReLoad": true + } +} \ 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 d137b92..65f6b27 100644 --- a/unpackage/dist/dev/mp-weixin/app.js +++ b/unpackage/dist/dev/mp-weixin/app.js @@ -6,6 +6,9 @@ if (!Math) { "./pages/news/news.js"; "./pages/user/user.js"; "./pages/user/login.js"; + "./pages/video/video.js"; + "./pages/intergral/intergral.js"; + "./pages/discuss/discuss.js"; } const _sfc_main = { onLaunch: function() { @@ -18,7 +21,7 @@ const _sfc_main = { console.log("App Hide"); } }; -const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "C:/Users/33043/Desktop/文件/work/newStud学习/greenStu/App.vue"]]); +const App = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "E:/DAN/wexinxiaochengxude/NewCode2/gree_leran/App.vue"]]); function createApp() { const app = common_vendor.createSSRApp(App); return { diff --git a/unpackage/dist/dev/mp-weixin/app.json b/unpackage/dist/dev/mp-weixin/app.json index 2bba785..c42693b 100644 --- a/unpackage/dist/dev/mp-weixin/app.json +++ b/unpackage/dist/dev/mp-weixin/app.json @@ -3,7 +3,10 @@ "pages/index/index", "pages/news/news", "pages/user/user", - "pages/user/login" + "pages/user/login", + "pages/video/video", + "pages/intergral/intergral", + "pages/discuss/discuss" ], "window": { "navigationBarTextStyle": "black", diff --git a/unpackage/dist/dev/mp-weixin/common/vendor.js b/unpackage/dist/dev/mp-weixin/common/vendor.js index 32af752..ef674cd 100644 --- a/unpackage/dist/dev/mp-weixin/common/vendor.js +++ b/unpackage/dist/dev/mp-weixin/common/vendor.js @@ -6,13 +6,14 @@ 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 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 set2 = new Set(str.split(",")); + return expectsLowerCase ? (val) => set2.has(val.toLowerCase()) : (val) => set2.has(val); } const EMPTY_OBJ = Object.freeze({}); const EMPTY_ARR = Object.freeze([]); @@ -94,6 +95,10 @@ 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 = {}; @@ -172,8 +177,8 @@ const replacer = (_key, val) => { return val; }; const stringifySymbol = (v, i = "") => { - var _a2; - return isSymbol(v) ? `Symbol(${(_a2 = v.description) != null ? _a2 : i})` : v; + var _a; + return isSymbol(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v; }; const LINEFEED = "\n"; const SLOT_DEFAULT_NAME = "d"; @@ -369,9 +374,9 @@ E.prototype = { return this; }, once: function(name, callback, ctx) { - var self = this; + var self2 = this; function listener() { - self.off(name, listener); + self2.off(name, listener); callback.apply(ctx, arguments); } listener._ = callback; @@ -655,7 +660,7 @@ function wrapperHook(hook, params) { return hook(data, params) || data; }; } -function queue$1(hooks, data, params) { +function queue$2(hooks, data, params) { let promise2 = false; for (let i = 0; i < hooks.length; i++) { const hook = hooks[i]; @@ -692,7 +697,7 @@ function wrapperOptions(interceptors2, options = {}) { } const oldCallback = options[name]; options[name] = function callbackInterceptor(res) { - queue$1(hooks, res, options).then((res2) => { + queue$2(hooks, res, options).then((res2) => { return isFunction(oldCallback) && oldCallback(res2) || res2; }); }; @@ -734,7 +739,7 @@ function invokeApi(method, api, options, params) { const interceptor = getApiInterceptorHooks(method); if (interceptor && Object.keys(interceptor).length) { if (isArray(interceptor.invoke)) { - const res = queue$1(interceptor.invoke, options); + const res = queue$2(interceptor.invoke, options); return res.then((options2) => { return api(wrapperOptions(getApiInterceptorHooks(method), options2), ...params); }); @@ -794,7 +799,8 @@ function invokeSuccess(id, name, res) { function invokeFail(id, name, errMsg, errRes = {}) { const apiErrMsg = name + ":fail" + (errMsg ? " " + errMsg : ""); delete errRes.errCode; - return invokeCallback(id, typeof UniError !== "undefined" ? typeof errRes.errCode !== "undefined" ? new UniError(name, errRes.errCode, apiErrMsg) : new UniError(apiErrMsg, errRes) : extend({ errMsg: apiErrMsg }, errRes)); + let res = extend({ errMsg: apiErrMsg }, errRes); + return invokeCallback(id, res); } function beforeInvokeApi(name, args, protocol, options) { { @@ -1292,8 +1298,8 @@ function populateParameters(fromRes, toRes) { appVersion: "1.0.0", appVersionCode: "100", appLanguage: getAppLanguage(hostLanguage), - uniCompileVersion: "4.07", - uniRuntimeVersion: "4.07", + uniCompileVersion: "4.15", + uniRuntimeVersion: "4.15", uniPlatform: "mp-weixin", deviceBrand, deviceModel: model, @@ -1607,7 +1613,509 @@ var protocols = /* @__PURE__ */ Object.freeze({ }); const wx$1 = initWx(); var index = initUni(shims, protocols, wx$1); -function warn$1(msg, ...args) { +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) { console.warn(`[Vue warn] ${msg}`, ...args); } let activeEffectScope; @@ -1619,7 +2127,9 @@ 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() { @@ -1635,7 +2145,7 @@ class EffectScope { activeEffectScope = currentEffectScope; } } else { - warn$1(`cannot run an inactive effect scope.`); + warn$2(`cannot run an inactive effect scope.`); } } /** @@ -1678,120 +2188,108 @@ class EffectScope { } } } -function recordEffectScope(effect, scope = activeEffectScope) { +function recordEffectScope(effect2, scope = activeEffectScope) { if (scope && scope.active) { - scope.effects.push(effect); + scope.effects.push(effect2); } } 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; -const ITERATE_KEY = Symbol("iterate"); -const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate"); -class ReactiveEffect { - constructor(fn, scheduler = null, scope) { +class ReactiveEffect2 { + constructor(fn, trigger2, scheduler, scope) { this.fn = fn; + this.trigger = trigger2; this.scheduler = scheduler; this.active = true; this.deps = []; - this.parent = void 0; + this._dirtyLevel = 4; + this._trackId = 0; + this._runnings = 0; + this._shouldSchedule = false; + this._depsLength = 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; - while (parent) { - if (parent === this) { - return; - } - parent = parent.parent; - } + let lastEffect = activeEffect; try { - this.parent = activeEffect; - activeEffect = this; shouldTrack = true; - trackOpBit = 1 << ++effectTrackDepth; - if (effectTrackDepth <= maxMarkerBits) { - initDepMarkers(this); - } else { - cleanupEffect(this); - } + activeEffect = this; + this._runnings++; + preCleanupEffect(this); return this.fn(); } finally { - if (effectTrackDepth <= maxMarkerBits) { - finalizeDepMarkers(this); - } - trackOpBit = 1 << --effectTrackDepth; - activeEffect = this.parent; + postCleanupEffect(this); + this._runnings--; + activeEffect = lastEffect; shouldTrack = lastShouldTrack; - this.parent = void 0; - if (this.deferStop) { - this.stop(); - } } } stop() { - if (activeEffect === this) { - this.deferStop = true; - } else if (this.active) { - cleanupEffect(this); - if (this.onStop) { - this.onStop(); - } + var _a; + if (this.active) { + preCleanupEffect(this); + postCleanupEffect(this); + (_a = this.onStop) == null ? void 0 : _a.call(this); this.active = false; } } } -function cleanupEffect(effect) { - const { deps } = effect; - if (deps.length) { - for (let i = 0; i < deps.length; i++) { - deps[i].delete(effect); +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(); } - deps.length = 0; } } let shouldTrack = true; +let pauseScheduleStack = 0; const trackStack = []; function pauseTracking() { trackStack.push(shouldTrack); @@ -1801,6 +2299,67 @@ 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); @@ -1809,28 +2368,17 @@ function track(target, type, key) { } let dep = depsMap.get(key); if (!dep) { - 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)); + depsMap.set(key, dep = createDep(() => depsMap.delete(key))); } + trackEffect( + activeEffect, + dep, + { + target, + type, + key + } + ); } } function trigger(target, type, key, newValue, oldValue, oldTarget) { @@ -1844,7 +2392,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" || key2 >= newLength) { + if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) { deps.push(dep); } }); @@ -1878,58 +2426,29 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) { break; } } - 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(); + pauseScheduling(); + for (const dep of deps) { + if (dep) { + triggerEffects( + dep, + 4, + { + target, + type, + key, + newValue, + oldValue, + oldTarget + } + ); } } + 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 = {}; @@ -1950,7 +2469,9 @@ 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; }; @@ -1962,16 +2483,26 @@ function hasOwnProperty(key) { track(obj, "has", key); return obj.hasOwnProperty(key); } -function createGetter(isReadonly2 = false, shallow = false) { - return function get2(target, key, receiver) { +class BaseReactiveHandler2 { + constructor(_isReadonly = false, _isShallow = false) { + this._isReadonly = _isReadonly; + this._isShallow = _isShallow; + } + get(target, key, receiver) { + const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow; if (key === "__v_isReactive") { return !isReadonly2; } else if (key === "__v_isReadonly") { return isReadonly2; } else if (key === "__v_isShallow") { - return shallow; - } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { - return target; + 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; } const targetIsArray = isArray(target); if (!isReadonly2) { @@ -1989,7 +2520,7 @@ function createGetter(isReadonly2 = false, shallow = false) { if (!isReadonly2) { track(target, "get", key); } - if (shallow) { + if (isShallow2) { return res; } if (isRef(res)) { @@ -1999,24 +2530,27 @@ function createGetter(isReadonly2 = false, shallow = false) { return isReadonly2 ? readonly(res) : reactive(res); } return res; - }; + } } -const set$1 = /* @__PURE__ */ createSetter(); -const shallowSet = /* @__PURE__ */ createSetter(true); -function createSetter(shallow = false) { - return function set2(target, key, value2, receiver) { +class MutableReactiveHandler2 extends BaseReactiveHandler2 { + constructor(isShallow2 = false) { + super(false, isShallow2); + } + set(target, key, value2, receiver) { let oldValue = target[key]; - if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value2)) { - return false; - } - if (!shallow) { + if (!this._isShallow) { + const isOldValueReadonly = isReadonly(oldValue); if (!isShallow(value2) && !isReadonly(value2)) { oldValue = toRaw(oldValue); value2 = toRaw(value2); } if (!isArray(target) && isRef(oldValue) && !isRef(value2)) { - oldValue.value = value2; - return true; + if (isOldValueReadonly) { + return false; + } else { + oldValue.value = value2; + return true; + } } } const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key); @@ -2029,68 +2563,69 @@ function createSetter(shallow = false) { } } return result; - }; -} -function deleteProperty(target, key) { - const hadKey = hasOwn(target, key); - const oldValue = target[key]; - const result = Reflect.deleteProperty(target, key); - if (result && hadKey) { - trigger(target, "delete", 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); + 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); } - 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, +class ReadonlyReactiveHandler2 extends BaseReactiveHandler2 { + constructor(isShallow2 = false) { + super(true, isShallow2); + } set(target, key) { { - warn$1(`Set operation on key "${String(key)}" failed: target is readonly.`, target); - } - return true; - }, - deleteProperty(target, key) { - { - warn$1(`Delete operation on key "${String(key)}" failed: target is readonly.`, target); + warn$2( + `Set operation on key "${String(key)}" failed: target is readonly.`, + target + ); } return true; } -}; -const shallowReactiveHandlers = /* @__PURE__ */ extend({}, mutableHandlers, { - get: shallowGet, - set: shallowSet -}); -const shallowReadonlyHandlers = /* @__PURE__ */ extend({}, readonlyHandlers, { - get: shallowReadonlyGet -}); + deleteProperty(target, key) { + { + warn$2( + `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 toShallow = (value2) => value2; const getProto = (v) => Reflect.getPrototypeOf(v); function get(target, key, isReadonly2 = false, isShallow2 = false) { - target = target[ - "__v_raw" - /* ReactiveFlags.RAW */ - ]; + target = target["__v_raw"]; const rawTarget = toRaw(target); const rawKey = toRaw(key); if (!isReadonly2) { - if (key !== rawKey) { + if (hasChanged(key, rawKey)) { track(rawTarget, "get", key); } track(rawTarget, "get", rawKey); @@ -2106,14 +2641,11 @@ function get(target, key, isReadonly2 = false, isShallow2 = false) { } } function has(key, isReadonly2 = false) { - const target = this[ - "__v_raw" - /* ReactiveFlags.RAW */ - ]; + const target = this["__v_raw"]; const rawTarget = toRaw(target); const rawKey = toRaw(key); if (!isReadonly2) { - if (key !== rawKey) { + if (hasChanged(key, rawKey)) { track(rawTarget, "has", key); } track(rawTarget, "has", rawKey); @@ -2121,10 +2653,7 @@ 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" - /* ReactiveFlags.RAW */ - ]; + target = target["__v_raw"]; !isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY); return Reflect.get(target, "size", target); } @@ -2139,7 +2668,7 @@ function add(value2) { } return this; } -function set$2(key, value2) { +function set$1(key, value2) { value2 = toRaw(value2); const target = toRaw(this); const { has: has2, get: get2 } = getProto(target); @@ -2189,10 +2718,7 @@ function clear() { function createForEach(isReadonly2, isShallow2) { return function forEach(callback, thisArg) { const observed = this; - const target = observed[ - "__v_raw" - /* ReactiveFlags.RAW */ - ]; + const target = observed["__v_raw"]; const rawTarget = toRaw(target); const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive; !isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY); @@ -2203,17 +2729,18 @@ function createForEach(isReadonly2, isShallow2) { } function createIterableMethod(method, isReadonly2, isShallow2) { return function(...args) { - const target = this[ - "__v_raw" - /* ReactiveFlags.RAW */ - ]; + const target = this["__v_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() { @@ -2234,9 +2761,12 @@ function createReadonlyMethod(type) { return function(...args) { { const key = args[0] ? `on key "${args[0]}" ` : ``; - console.warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this)); + warn$2( + `${capitalize(type)} operation ${key}failed: target is readonly.`, + toRaw(this) + ); } - return type === "delete" ? false : this; + return type === "delete" ? false : type === "clear" ? void 0 : this; }; } function createInstrumentations() { @@ -2249,7 +2779,7 @@ function createInstrumentations() { }, has, add, - set: set$2, + set: set$1, delete: deleteEntry, clear, forEach: createForEach(false, false) @@ -2263,7 +2793,7 @@ function createInstrumentations() { }, has, add, - set: set$2, + set: set$1, delete: deleteEntry, clear, forEach: createForEach(false, true) @@ -2278,22 +2808,10 @@ function createInstrumentations() { has(key) { return has.call(this, key, true); }, - add: createReadonlyMethod( - "add" - /* TriggerOpTypes.ADD */ - ), - set: createReadonlyMethod( - "set" - /* TriggerOpTypes.SET */ - ), - delete: createReadonlyMethod( - "delete" - /* TriggerOpTypes.DELETE */ - ), - clear: createReadonlyMethod( - "clear" - /* TriggerOpTypes.CLEAR */ - ), + add: createReadonlyMethod("add"), + set: createReadonlyMethod("set"), + delete: createReadonlyMethod("delete"), + clear: createReadonlyMethod("clear"), forEach: createForEach(true, false) }; const shallowReadonlyInstrumentations2 = { @@ -2306,30 +2824,27 @@ function createInstrumentations() { has(key) { return has.call(this, key, true); }, - add: createReadonlyMethod( - "add" - /* TriggerOpTypes.ADD */ - ), - set: createReadonlyMethod( - "set" - /* TriggerOpTypes.SET */ - ), - delete: createReadonlyMethod( - "delete" - /* TriggerOpTypes.DELETE */ - ), - clear: createReadonlyMethod( - "clear" - /* TriggerOpTypes.CLEAR */ - ), + add: createReadonlyMethod("add"), + set: createReadonlyMethod("set"), + delete: createReadonlyMethod("delete"), + clear: createReadonlyMethod("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, @@ -2338,7 +2853,12 @@ 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) => { @@ -2349,7 +2869,11 @@ 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 = { @@ -2368,7 +2892,9 @@ function checkIdentityKeys(target, has2, key) { const rawKey = toRaw(key); if (rawKey !== key && has2.call(target, rawKey)) { const type = toRawType(target); - console.warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`); + 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.` + ); } } const reactiveMap = /* @__PURE__ */ new WeakMap(); @@ -2390,40 +2916,55 @@ function targetTypeMap(rawType) { } } function getTargetType(value2) { - return value2[ - "__v_skip" - /* ReactiveFlags.SKIP */ - ] || !Object.isExtensible(value2) ? 0 : targetTypeMap(toRawType(value2)); + return value2["__v_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)) { { - console.warn(`value cannot be made reactive: ${String(target)}`); + warn$2(`value cannot be made reactive: ${String(target)}`); } return target; } - if (target[ - "__v_raw" - /* ReactiveFlags.RAW */ - ] && !(isReadonly2 && target[ - "__v_isReactive" - /* ReactiveFlags.IS_REACTIVE */ - ])) { + if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) { return target; } const existingProxy = proxyMap.get(target); @@ -2434,78 +2975,143 @@ 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" - /* ReactiveFlags.RAW */ - ]); + return isReactive(value2["__v_raw"]); } - return !!(value2 && value2[ - "__v_isReactive" - /* ReactiveFlags.IS_REACTIVE */ - ]); + return !!(value2 && value2["__v_isReactive"]); } function isReadonly(value2) { - return !!(value2 && value2[ - "__v_isReadonly" - /* ReactiveFlags.IS_READONLY */ - ]); + return !!(value2 && value2["__v_isReadonly"]); } function isShallow(value2) { - return !!(value2 && value2[ - "__v_isShallow" - /* ReactiveFlags.IS_SHALLOW */ - ]); + return !!(value2 && value2["__v_isShallow"]); } function isProxy(value2) { return isReactive(value2) || isReadonly(value2); } function toRaw(observed) { - const raw = observed && observed[ - "__v_raw" - /* ReactiveFlags.RAW */ - ]; + const raw = observed && observed["__v_raw"]; return raw ? toRaw(raw) : observed; } function markRaw(value2) { - def(value2, "__v_skip", true); + if (Object.isExtensible(value2)) { + 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); - { - trackEffects(ref2.dep || (ref2.dep = createDep()), { + trackEffect( + activeEffect, + (_a = ref2.dep) != null ? _a : ref2.dep = createDep( + () => ref2.dep = void 0, + ref2 instanceof ComputedRefImpl ? ref2 : void 0 + ), + { target: ref2, type: "get", key: "value" - }); - } + } + ); } } -function triggerRefValue(ref2, newVal) { +function triggerRefValue(ref2, dirtyLevel = 4, newVal) { ref2 = toRaw(ref2); const dep = ref2.dep; if (dep) { - { - triggerEffects(dep, { + triggerEffects( + dep, + dirtyLevel, + { target: ref2, type: "set", key: "value", newValue: newVal - }); - } + } + ); } } -function isRef(r) { - return !!(r && r.__v_isRef === true); +function isRef(r2) { + return !!(r2 && r2.__v_isRef === true); } function ref(value2) { return createRef(value2, false); @@ -2534,7 +3140,7 @@ class RefImpl { if (hasChanged(newVal, this._rawValue)) { this._rawValue = newVal; this._value = useDirectValue ? newVal : toReactive(newVal); - triggerRefValue(this, newVal); + triggerRefValue(this, 4, newVal); } } } @@ -2556,61 +3162,6 @@ 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); @@ -2618,18 +3169,28 @@ function pushWarningContext(vnode) { function popWarningContext() { stack.pop(); } -function warn(msg, ...args) { +function warn$1(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.join(""), - instance && instance.proxy, - trace.map(({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`).join("\n"), - trace - ]); + 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 + ] + ); } else { const warnArgs = [`[Vue warn]: ${msg}`, ...args]; if (trace.length && // avoid spamming console during tests @@ -2673,7 +3234,11 @@ 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]; } @@ -2705,131 +3270,42 @@ function formatProp(key, value2, raw) { } } const ErrorTypeStrings = { - [ - "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" + ["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(fn, instance, type, args) { - let res; try { - res = args ? fn(...args) : fn(); + return args ? fn(...args) : fn(); } catch (err) { handleError(err, instance, type); } - return res; } function callWithAsyncErrorHandling(fn, instance, type, args) { if (isFunction(fn)) { @@ -2866,7 +3342,12 @@ 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; } } @@ -2878,7 +3359,7 @@ function logError(err, type, contextVNode, throwInDev = true) { if (contextVNode) { pushWarningContext(contextVNode); } - warn(`Unhandled error${info ? ` during execution of ${info}` : ``}`); + warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`); if (contextVNode) { popWarningContext(); } @@ -2908,13 +3389,21 @@ function findInsertionIndex(id) { let end = queue.length; while (start < end) { const middle = start + end >>> 1; - const middleJobId = getId(queue[middle]); - middleJobId < id ? start = middle + 1 : end = middle; + const middleJob = queue[middle]; + const middleJobId = getId(middleJob); + if (middleJobId < id || middleJobId === id && middleJob.pre) { + start = middle + 1; + } else { + 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 { @@ -2940,7 +3429,10 @@ 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 { @@ -2948,13 +3440,16 @@ function queuePostFlushCb(cb) { } queueFlush(); } -function flushPreFlushCbs(seen, i = isFlushing ? flushIndex + 1 : 0) { +function flushPreFlushCbs(instance, 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; } @@ -2966,7 +3461,9 @@ function flushPreFlushCbs(seen, i = isFlushing ? flushIndex + 1 : 0) { } function flushPostFlushCbs(seen) { if (pendingPostFlushCbs.length) { - const deduped = [...new Set(pendingPostFlushCbs)]; + const deduped = [...new Set(pendingPostFlushCbs)].sort( + (a, b) => getId(a) - getId(b) + ); pendingPostFlushCbs.length = 0; if (activePostFlushCbs) { activePostFlushCbs.push(...deduped); @@ -2976,7 +3473,6 @@ 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; @@ -3013,12 +3509,7 @@ function flushJobs(seen) { if (check(job)) { continue; } - callWithErrorHandling( - job, - null, - 14 - /* ErrorCodes.SCHEDULER */ - ); + callWithErrorHandling(job, null, 14); } } } finally { @@ -3040,7 +3531,11 @@ function checkRecursiveUpdates(seen, fn) { if (count > RECURSION_LIMIT) { const instance = fn.ownerInstance; const componentName = instance && getComponentName(instance.type); - 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.`); + 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 + ); return true; } else { seen.set(fn, count + 1); @@ -3058,7 +3553,7 @@ function emit$1(event, ...args) { } } function setDevtoolsHook(hook, target) { - var _a2, _b; + var _a, _b; devtools = hook; if (devtools) { devtools.enabled = true; @@ -3069,10 +3564,8 @@ 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 - // 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")) + !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom")) ) { const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []; replay.push((newHook) => { @@ -3100,15 +3593,15 @@ function devtoolsInitApp(app, version2) { } const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook( "component:added" - /* DevtoolsHooks.COMPONENT_ADDED */ + /* COMPONENT_ADDED */ ); const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook( "component:updated" - /* DevtoolsHooks.COMPONENT_UPDATED */ + /* COMPONENT_UPDATED */ ); const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook( "component:removed" - /* DevtoolsHooks.COMPONENT_REMOVED */ + /* COMPONENT_REMOVED */ ); const devtoolsComponentRemoved = (component) => { if (devtools && typeof devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered @@ -3116,6 +3609,8 @@ const devtoolsComponentRemoved = (component) => { _devtoolsComponentRemoved(component); } }; +/*! #__NO_SIDE_EFFECTS__ */ +// @__NO_SIDE_EFFECTS__ function createDevtoolsComponentHook(hook) { return (component) => { emit$1( @@ -3131,11 +3626,11 @@ function createDevtoolsComponentHook(hook) { } const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook( "perf:start" - /* DevtoolsHooks.PERFORMANCE_START */ + /* PERFORMANCE_START */ ); const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook( "perf:end" - /* DevtoolsHooks.PERFORMANCE_END */ + /* PERFORMANCE_END */ ); function createDevtoolsPerformanceHook(hook) { return (component, type, time) => { @@ -3143,25 +3638,38 @@ 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(`Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`); + warn$1( + `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(`Invalid event arguments: event validation failed for event "${event}".`); + warn$1( + `Invalid event arguments: event validation failed for event "${event}".` + ); } } } @@ -3186,7 +3694,14 @@ function emit(instance, event, ...rawArgs) { { const lowerCaseEvent = event.toLowerCase(); if (lowerCaseEvent !== event && props2[toHandlerKey(lowerCaseEvent)]) { - 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}".`); + 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}".` + ); } } let handlerName; @@ -3196,7 +3711,12 @@ 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) { @@ -3206,7 +3726,12 @@ 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) { @@ -3266,10 +3791,422 @@ 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(`provide() can only be used inside setup().`); + warn$1(`provide() can only be used inside setup().`); } } else { let provides = currentInstance.provides; @@ -3285,223 +4222,19 @@ function provide(key, value2) { } function inject(key, defaultValue, treatDefaultAsFactory = false) { const instance = currentInstance || currentRenderingInstance; - if (instance) { - const provides = instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides; + if (instance || currentApp) { + const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides; if (provides && key in provides) { return provides[key]; } else if (arguments.length > 1) { - return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue; + return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue; } else { - warn(`injection "${String(key)}" not found.`); + warn$1(`injection "${String(key)}" not found.`); } } else { - warn(`inject() can only be used inside setup() or functional components.`); + warn$1(`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); @@ -3554,9 +4287,9 @@ function injectHook(type, hook, target = currentInstance, prepend = false) { return; } pauseTracking(); - setCurrentInstance(target); + const reset = setCurrentInstance(target); const res = callWithAsyncErrorHandling(hook, target, type, args); - unsetCurrentInstance(); + reset(); resetTracking(); return res; }); @@ -3567,98 +4300,34 @@ function injectHook(type, hook, target = currentInstance, prepend = false) { } return wrappedHook; } else { - 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 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 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" - /* 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 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 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; @@ -3683,7 +4352,10 @@ const publicPropertiesMap = ( $root: (i) => getPublicInstance(i.root), $emit: (i) => i.emit, $options: (i) => resolveMergedOptions(i), - $forceUpdate: (i) => i.f || (i.f = () => queueJob(i.update)), + $forceUpdate: (i) => i.f || (i.f = () => { + i.effect.dirty = true; + queueJob(i.update); + }), // $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy!)),// fixed by xxxxxx $watch: (i) => instanceWatch.bind(i) }) @@ -3735,6 +4407,8 @@ const PublicInstanceProxyHandlers = { if (publicGetter) { if (key === "$attrs") { track(instance, "get", key); + } else if (key === "$slots") { + track(instance, "get", key); } return publicGetter(instance); } else if ( @@ -3756,9 +4430,15 @@ const PublicInstanceProxyHandlers = { // to infinite warning loop key.indexOf("__v") !== 0)) { if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) { - 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.`); + 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.` + ); } else if (instance === currentRenderingInstance) { - warn(`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`); + warn$1( + `Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.` + ); } } }, @@ -3768,17 +4448,19 @@ const PublicInstanceProxyHandlers = { setupState[key] = value2; return true; } else if (setupState.__isScriptSetup && hasOwn(setupState, key)) { - warn(`Cannot mutate