From a8a51d3d00688cddba997782c97e24824fb355a6 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 9 Jul 2021 16:18:33 +0800 Subject: [PATCH] wip(app): uni-app-plus --- packages/uni-app-plus/build.json | 64 +- packages/uni-app-plus/dist/style.css | 375 ++ packages/uni-app-plus/dist/tools.umd.js | 124 + .../uni-app-plus/dist/uni-app-service.es.js | 390 +- .../uni-app-plus/dist/uni-app-view.umd.js | 5041 +++++++++++++---- packages/uni-app-plus/package.json | 4 +- .../uni-app-plus/src/view/components/index.ts | 1 - .../uni-app-plus/src/view/components/view.ts | 4 - .../view/framework/dom/elements/UniElement.ts | 8 +- .../view/framework/dom/elements/UniNode.ts | 2 +- .../framework/dom/elements/UniViewElement.ts | 3 +- .../elements/components/UniButtonElement.ts | 58 + .../dom/elements/components/index.ts | 40 + .../src/view/framework/dom/elements/index.ts | 23 +- .../framework/dom/elements/modules/events.ts | 4 +- .../src/view/framework/dom/elements/utils.ts | 32 - packages/uni-app-plus/src/view/index.ts | 20 +- packages/uni-app-plus/src/view/ready.ts | 14 - .../uni-app-plus/style/framework/base.css | 54 + packages/uni-app-plus/vite.config.ts | 16 +- .../uni-app-vue/dist/service.runtime.esm.js | 21 +- packages/uni-app/dist/uni-app.cjs.js | 42 - packages/uni-app/dist/uni-app.es.js | 44 +- packages/uni-core/src/helpers/page.ts | 4 + packages/uni-mp-alipay/dist/uni.mp.esm.js | 44 +- packages/uni-mp-baidu/dist/uni.mp.esm.js | 44 +- packages/uni-mp-qq/dist/uni.mp.esm.js | 44 +- packages/uni-mp-toutiao/dist/uni.mp.esm.js | 44 +- packages/uni-mp-vue/dist/vue.runtime.esm.js | 44 +- packages/uni-mp-weixin/dist/uni.mp.esm.js | 44 +- .../uni-quickapp-webview/dist/uni.mp.esm.js | 44 +- packages/uni-shared/dist/uni-shared.cjs.js | 19 +- packages/uni-shared/dist/uni-shared.es.js | 19 +- packages/uni-shared/src/vdom/encode.ts | 27 +- packages/vite-plugin-uni/src/vue/options.ts | 2 + 35 files changed, 5233 insertions(+), 1530 deletions(-) create mode 100644 packages/uni-app-plus/dist/tools.umd.js delete mode 100644 packages/uni-app-plus/src/view/components/index.ts delete mode 100644 packages/uni-app-plus/src/view/components/view.ts create mode 100644 packages/uni-app-plus/src/view/framework/dom/elements/components/UniButtonElement.ts create mode 100644 packages/uni-app-plus/src/view/framework/dom/elements/components/index.ts delete mode 100644 packages/uni-app-plus/src/view/framework/dom/elements/utils.ts delete mode 100644 packages/uni-app-plus/src/view/ready.ts create mode 100644 packages/uni-app-plus/style/framework/base.css diff --git a/packages/uni-app-plus/build.json b/packages/uni-app-plus/build.json index fd1a9c9a8..2a218b871 100644 --- a/packages/uni-app-plus/build.json +++ b/packages/uni-app-plus/build.json @@ -1,27 +1,39 @@ -{ - "input": { - "src/service/index.ts": "dist/uni-app-service.es.js" +[ + { + "input": { + "src/service/index.ts": "dist/uni-app-service.es.js" + }, + "output": { + "name": "serviceContext", + "format": "iife", + "banner": "export function createServiceContext(Vue,weex, plus,instanceContext){\nconst setTimeout = instanceContext.setTimeout;\nconst clearTimeout = instanceContext.clearTimeout;\nconst setInterval = instanceContext.setInterval;\nconst clearInterval = instanceContext.clearInterval;\nconst __uniConfig = instanceContext.__uniConfig;\nconst __uniRoutes = instanceContext.__uniRoutes;\n", + "footer": "const uni = serviceContext.uni;\nconst getApp = serviceContext.getApp;\nconst getCurrentPages = serviceContext.getCurrentPages;\nconst UniServiceJSBridge = serviceContext.UniServiceJSBridge;\nreturn serviceContext;\n}", + "globals": { + "vue": "Vue" + } + }, + "replacements": { + "__PLATFORM__": "'app'", + "__VUE_OPTIONS_API__": "true", + "__VUE_PROD_DEVTOOLS__": "false", + "__UNI_FEATURE_WX__": "true", + "__UNI_FEATURE_PROMISE__": "false", + "__UNI_FEATURE_I18N_EN__": "true", + "__UNI_FEATURE_I18N_ES__": "true", + "__UNI_FEATURE_I18N_FR__": "true", + "__UNI_FEATURE_I18N_ZH_HANS__": "true", + "__UNI_FEATURE_I18N_ZH_HANT__": "true" + }, + "external": ["vue"] }, - "output": { - "name": "serviceContext", - "format": "iife", - "banner": "export function createServiceContext(Vue,weex, plus,instanceContext){\nconst setTimeout = instanceContext.setTimeout;\nconst clearTimeout = instanceContext.clearTimeout;\nconst setInterval = instanceContext.setInterval;\nconst clearInterval = instanceContext.clearInterval;\nconst __uniConfig = instanceContext.__uniConfig;\nconst __uniRoutes = instanceContext.__uniRoutes;\n", - "footer": "const uni = serviceContext.uni;\nconst getApp = serviceContext.getApp;\nconst getCurrentPages = serviceContext.getCurrentPages;\nconst UniServiceJSBridge = serviceContext.UniServiceJSBridge;\nreturn serviceContext;\n}", - "globals": { - "vue": "Vue" - } - }, - "replacements": { - "__PLATFORM__": "'app'", - "__VUE_OPTIONS_API__": "true", - "__VUE_PROD_DEVTOOLS__": "false", - "__UNI_FEATURE_WX__": "true", - "__UNI_FEATURE_PROMISE__": "false", - "__UNI_FEATURE_I18N_EN__": "true", - "__UNI_FEATURE_I18N_ES__": "true", - "__UNI_FEATURE_I18N_FR__": "true", - "__UNI_FEATURE_I18N_ZH_HANS__": "true", - "__UNI_FEATURE_I18N_ZH_HANT__": "true" - }, - "external": ["vue"] -} + { + "input": { + "src/service/framework/dom/decodeActions.ts": "dist/tools.umd.js" + }, + "output": { + "name": "Tools", + "format": "umd" + }, + "external": false + } +] diff --git a/packages/uni-app-plus/dist/style.css b/packages/uni-app-plus/dist/style.css index dde338974..f0b3f0e53 100644 --- a/packages/uni-app-plus/dist/style.css +++ b/packages/uni-app-plus/dist/style.css @@ -1,6 +1,381 @@ +* { + margin: 0; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + -webkit-tap-highlight-color: transparent; +} + +html, +body { + -webkit-user-select: none; + user-select: none; + width: 100%; +} + +html { + height: 100%; + height: 100vh; + width: 100%; + width: 100vw; +} + +body { + overflow-x: hidden; + background-color: white; +} + +input[type='search']::-webkit-search-cancel-button { + display: none; +} + +.uni-loading, +uni-button[loading]:before { + background: transparent + url('data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=') + no-repeat; +} + +.uni-loading { + width: 20px; + height: 20px; + display: inline-block; + vertical-align: middle; + animation: uni-loading 1s steps(12, end) infinite; + background-size: 100%; +} + +@keyframes uni-loading { + 0% { + transform: rotate3d(0, 0, 1, 0deg); + } + + 100% { + transform: rotate3d(0, 0, 1, 360deg); + } +} +[nvue] uni-view, +[nvue] uni-label, +[nvue] uni-swiper-item, +[nvue] uni-scroll-view { + display: flex; + flex-shrink: 0; + flex-grow: 0; + flex-basis: auto; + align-items: stretch; + align-content: flex-start; +} + +[nvue] uni-button { + margin: 0; +} + +[nvue-dir-row] uni-view, +[nvue-dir-row] uni-label, +[nvue-dir-row] uni-swiper-item { + flex-direction: row; +} + +[nvue-dir-column] uni-view, +[nvue-dir-column] uni-label, +[nvue-dir-column] uni-swiper-item { + flex-direction: column; +} + +[nvue-dir-row-reverse] uni-view, +[nvue-dir-row-reverse] uni-label, +[nvue-dir-row-reverse] uni-swiper-item { + flex-direction: row-reverse; +} + +[nvue-dir-column-reverse] uni-view, +[nvue-dir-column-reverse] uni-label, +[nvue-dir-column-reverse] uni-swiper-item { + flex-direction: column-reverse; +} + +[nvue] uni-view, +[nvue] uni-image, +[nvue] uni-input, +[nvue] uni-scroll-view, +[nvue] uni-swiper, +[nvue] uni-swiper-item, +[nvue] uni-text, +[nvue] uni-textarea, +[nvue] uni-video { + position: relative; + border: 0px solid #000000; + box-sizing: border-box; +} + +[nvue] uni-swiper-item { + position: absolute; +} uni-view { display: block; } uni-view[hidden] { display: none; } +uni-button { + position: relative; + display: block; + margin-left: auto; + margin-right: auto; + padding-left: 14px; + padding-right: 14px; + box-sizing: border-box; + font-size: 18px; + text-align: center; + text-decoration: none; + line-height: 2.55555556; + border-radius: 5px; + -webkit-tap-highlight-color: transparent; + overflow: hidden; + color: #000000; + background-color: #f8f8f8; + cursor: pointer; +} + +uni-button[hidden] { + display: none !important; +} + +uni-button:after { + content: ' '; + width: 200%; + height: 200%; + position: absolute; + top: 0; + left: 0; + border: 1px solid rgba(0, 0, 0, 0.2); + transform: scale(0.5); + transform-origin: 0 0; + box-sizing: border-box; + border-radius: 10px; +} + +uni-button[native] { + padding-left: 0; + padding-right: 0; +} + +uni-button[native] .uni-button-cover-view-wrapper { + border: inherit; + border-color: inherit; + border-radius: inherit; + background-color: inherit; +} + +uni-button[native] .uni-button-cover-view-inner { + padding-left: 14px; + padding-right: 14px; +} + +uni-button uni-cover-view { + line-height: inherit; + white-space: inherit; +} + +uni-button[type='default'] { + color: #000000; + background-color: #f8f8f8; +} + +uni-button[type='primary'] { + color: #ffffff; + background-color: #007aff; +} + +uni-button[type='warn'] { + color: #ffffff; + background-color: #e64340; +} + +uni-button[disabled] { + color: rgba(255, 255, 255, 0.6); + cursor: not-allowed; +} + +uni-button[disabled][type='default'], +uni-button[disabled]:not([type]) { + color: rgba(0, 0, 0, 0.3); + background-color: #f7f7f7; +} + +uni-button[disabled][type='primary'] { + background-color: rgba(0, 122, 255, 0.6); +} + +uni-button[disabled][type='warn'] { + background-color: #ec8b89; +} + +uni-button[type='primary'][plain] { + color: #007aff; + border: 1px solid #007aff; + background-color: transparent; +} + +uni-button[type='primary'][plain][disabled] { + color: rgba(0, 0, 0, 0.2); + border-color: rgba(0, 0, 0, 0.2); +} + +uni-button[type='primary'][plain]:after { + border-width: 0; +} + +uni-button[type='default'][plain] { + color: #353535; + border: 1px solid #353535; + background-color: transparent; +} + +uni-button[type='default'][plain][disabled] { + color: rgba(0, 0, 0, 0.2); + border-color: rgba(0, 0, 0, 0.2); +} + +uni-button[type='default'][plain]:after { + border-width: 0; +} + +uni-button[plain] { + color: #353535; + border: 1px solid #353535; + background-color: transparent; +} + +uni-button[plain][disabled] { + color: rgba(0, 0, 0, 0.2); + border-color: rgba(0, 0, 0, 0.2); +} + +uni-button[plain]:after { + border-width: 0; +} + +uni-button[plain][native] .uni-button-cover-view-inner { + padding: 0; +} + +uni-button[type='warn'][plain] { + color: #e64340; + border: 1px solid #e64340; + background-color: transparent; +} + +uni-button[type='warn'][plain][disabled] { + color: rgba(0, 0, 0, 0.2); + border-color: rgba(0, 0, 0, 0.2); +} + +uni-button[type='warn'][plain]:after { + border-width: 0; +} + +uni-button[size='mini'] { + display: inline-block; + line-height: 2.3; + font-size: 13px; + padding: 0 1.34em; +} + +uni-button[size='mini'][native] { + padding: 0; +} + +uni-button[size='mini'][native] .uni-button-cover-view-inner { + padding: 0 1.34em; +} + +uni-button[loading]:not([disabled]) { + cursor: progress; +} + +uni-button[loading]:before { + content: ' '; + display: inline-block; + width: 18px; + height: 18px; + vertical-align: middle; + animation: uni-loading 1s steps(12, end) infinite; + background-size: 100%; +} + +uni-button[loading][type='primary'] { + color: rgba(255, 255, 255, 0.6); + background-color: #0062cc; +} + +uni-button[loading][type='primary'][plain] { + color: #007aff; + background-color: transparent; +} + +uni-button[loading][type='default'] { + color: rgba(0, 0, 0, 0.6); + background-color: #dedede; +} + +uni-button[loading][type='default'][plain] { + color: #353535; + background-color: transparent; +} + +uni-button[loading][type='warn'] { + color: rgba(255, 255, 255, 0.6); + background-color: #ce3c39; +} + +uni-button[loading][type='warn'][plain] { + color: #e64340; + background-color: transparent; +} + +uni-button[loading][native]:before { + content: none; +} + +.button-hover { + color: rgba(0, 0, 0, 0.6); + background-color: #dedede; +} + +.button-hover[plain] { + color: rgba(53, 53, 53, 0.6); + border-color: rgba(53, 53, 53, 0.6); + background-color: transparent; +} + +.button-hover[type='primary'] { + color: rgba(255, 255, 255, 0.6); + background-color: #0062cc; +} + +.button-hover[type='primary'][plain] { + color: rgba(26, 173, 25, 0.6); + border-color: rgba(26, 173, 25, 0.6); + background-color: transparent; +} + +.button-hover[type='default'] { + color: rgba(0, 0, 0, 0.6); + background-color: #dedede; +} + +.button-hover[type='default'][plain] { + color: rgba(53, 53, 53, 0.6); + border-color: rgba(53, 53, 53, 0.6); + background-color: transparent; +} + +.button-hover[type='warn'] { + color: rgba(255, 255, 255, 0.6); + background-color: #ce3c39; +} + +.button-hover[type='warn'][plain] { + color: rgba(230, 67, 64, 0.6); + border-color: rgba(230, 67, 64, 0.6); + background-color: transparent; +} diff --git a/packages/uni-app-plus/dist/tools.umd.js b/packages/uni-app-plus/dist/tools.umd.js new file mode 100644 index 000000000..1053ad25a --- /dev/null +++ b/packages/uni-app-plus/dist/tools.umd.js @@ -0,0 +1,124 @@ +(function (window, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : window || self, factory(window.Tools = {})); +}(this, (function (exports) { 'use strict'; + + const COMPONENT_MAP = { + VIEW: 1, + IMAGE: 2, + TEXT: 3, + '#text': 4, + '#comment': 5, + NAVIGATOR: 6, + FORM: 7, + BUTTON: 8, + INPUT: 9, + LABEL: 10, + RADIO: 11, + CHECKBOX: 12, + 'CHECKBOX-GROUP': 13, + AD: 14, + AUDIO: 15, + CAMERA: 16, + CANVAS: 17, + 'COVER-IMAGE': 18, + 'COVER-VIEW': 19, + EDITOR: 20, + 'FUNCTIONAL-PAGE-NAVIGATOR': 21, + ICON: 22, + 'RADIO-GROUP': 23, + 'LIVE-PLAYER': 24, + 'LIVE-PUSHER': 25, + MAP: 26, + 'MOVABLE-AREA': 27, + 'MOVABLE-VIEW': 28, + 'OFFICIAL-ACCOUNT': 29, + 'OPEN-DATA': 30, + PICKER: 31, + 'PICKER-VIEW': 32, + 'PICKER-VIEW-COLUMN': 33, + PROGRESS: 34, + 'RICH-TEXT': 35, + 'SCROLL-VIEW': 36, + SLIDER: 37, + SWIPER: 38, + 'SWIPER-ITEM': 39, + SWITCH: 40, + TEXTAREA: 41, + VIDEO: 42, + 'WEB-VIEW': 43, + }; + function decodeArrMap(objMap) { + return Object.keys(objMap).reduce((arr, name) => { + arr.push(name.toLowerCase()); + return arr; + }, ['']); + } + const DECODED_COMPONENT_ARR = /*#__PURE__*/ decodeArrMap(COMPONENT_MAP); + function decodeTag(tag) { + return (DECODED_COMPONENT_ARR[tag] || tag); + } + + const ACTION_TYPE_PAGE_CREATE = 1; + const ACTION_TYPE_PAGE_CREATED = 2; + const ACTION_TYPE_CREATE = 3; + const ACTION_TYPE_INSERT = 4; + const ACTION_TYPE_REMOVE = 5; + const ACTION_TYPE_SET_ATTRIBUTE = 6; + const ACTION_TYPE_REMOVE_ATTRIBUTE = 7; + const ACTION_TYPE_SET_TEXT = 8; + + function decodePageCreateAction([, pageCreateData]) { + return ['pageCreate', pageCreateData]; + } + function decodePageCreatedAction([]) { + return ['pageCreated']; + } + function decodeCreateAction([, nodeId, nodeName]) { + return ['create', nodeId, decodeTag(nodeName)]; + } + function decodeInsertAction([, ...action]) { + return ['insert', ...action]; + } + function decodeRemoveAction([, ...action]) { + return ['remove', ...action]; + } + function decodeSetAttributeAction([, ...action]) { + return ['setAttr', ...action]; + } + function decodeRemoveAttributeAction([, ...action]) { + return ['removeAttr', ...action]; + } + function decodeSetTextAction([, ...action]) { + return ['setText', action]; + } + function decodeActions(actions) { + return actions.map((action) => { + switch (action[0]) { + case ACTION_TYPE_PAGE_CREATE: + return decodePageCreateAction(action); + case ACTION_TYPE_PAGE_CREATED: + return decodePageCreatedAction(action); + case ACTION_TYPE_CREATE: + return decodeCreateAction(action); + case ACTION_TYPE_INSERT: + return decodeInsertAction(action); + case ACTION_TYPE_REMOVE: + return decodeRemoveAction(action); + case ACTION_TYPE_SET_ATTRIBUTE: + return decodeSetAttributeAction(action); + case ACTION_TYPE_REMOVE_ATTRIBUTE: + return decodeRemoveAttributeAction(action); + case ACTION_TYPE_SET_TEXT: + return decodeSetTextAction(action); + } + return action; + }); + } + + exports.decodeActions = decodeActions; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/packages/uni-app-plus/dist/uni-app-service.es.js b/packages/uni-app-plus/dist/uni-app-service.es.js index 34bd51bbf..95608aa1c 100644 --- a/packages/uni-app-plus/dist/uni-app-service.es.js +++ b/packages/uni-app-plus/dist/uni-app-service.es.js @@ -141,6 +141,8 @@ var serviceContext = (function (vue) { */ const capitalize = cacheStringFunction$1((str) => str.charAt(0).toUpperCase() + str.slice(1)); + const CHOOSE_SIZE_TYPES = ['original', 'compressed']; + const CHOOSE_SOURCE_TYPES = ['album', 'camera']; const HTTP_METHODS = [ 'GET', 'OPTIONS', @@ -157,6 +159,14 @@ var serviceContext = (function (vue) { } return str; } + function elemsInArray(strArr, optionalVal) { + if (!isArray(strArr) || + strArr.length === 0 || + strArr.find((val) => optionalVal.indexOf(val) === -1)) { + return optionalVal; + } + return strArr; + } function validateProtocolFail(name, msg) { console.warn(`${name}: ${msg}`); } @@ -774,48 +784,6 @@ var serviceContext = (function (vue) { } return [hyphenate(name.slice(2)), options]; } - const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', - }; - const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', - ]; - const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', - }; - /*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; - }, Object.create(null))); const COMPONENT_MAP = { VIEW: 1, IMAGE: 2, @@ -1444,6 +1412,44 @@ var serviceContext = (function (vue) { })); } }); + const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => { + const name = 'uni.chooseVideo.'; + { + useI18n().add(LOCALE_EN, normalizeMessages(name, { + cancel: 'Cancel', + 'sourceType.album': 'Album', + 'sourceType.camera': 'Camera', + })); + } + { + useI18n().add(LOCALE_ES, normalizeMessages(name, { + cancel: 'Cancelar', + 'sourceType.album': 'Álbum', + 'sourceType.camera': 'Cámara', + })); + } + { + useI18n().add(LOCALE_FR, normalizeMessages(name, { + cancel: 'Annuler', + 'sourceType.album': 'Album', + 'sourceType.camera': 'Caméra', + })); + } + { + useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { + cancel: '取消', + 'sourceType.album': '从相册选择', + 'sourceType.camera': '拍摄', + })); + } + { + useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { + cancel: '取消', + 'sourceType.album': '從相冊選擇', + 'sourceType.camera': '拍攝', + })); + } + }); const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(() => { const name = 'uni.startSoterAuthentication.'; { @@ -2168,6 +2174,62 @@ var serviceContext = (function (vue) { altitude: Boolean, }; + const API_CHOOSE_IMAGE = 'chooseImage'; + const ChooseImageOptions = { + formatArgs: { + count(value, params) { + if (!value || value <= 0) { + params.count = 9; + } + }, + sizeType(sizeType, params) { + params.sizeType = elemsInArray(sizeType, CHOOSE_SIZE_TYPES); + }, + sourceType(sourceType, params) { + params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES); + }, + extension(extension, params) { + if (extension instanceof Array && extension.length === 0) { + return 'param extension should not be empty.'; + } + if (!extension) + params.extension = ['']; + }, + }, + }; + const ChooseImageProtocol = { + count: Number, + sizeType: [Array, String], + sourceType: Array, + extension: Array, + }; + + const API_CHOOSE_VIDEO = 'chooseVideo'; + const ChooseVideoOptions = { + formatArgs: { + sourceType(sourceType, params) { + params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES); + }, + compressed: true, + maxDuration: 60, + camera: 'back', + extension(extension, params) { + if (extension instanceof Array && extension.length === 0) { + return 'param extension should not be empty.'; + } + if (!extension) + params.extension = ['']; + }, + }, + }; + const ChooseVideoProtocol = { + sourceType: Array, + compressed: Boolean, + maxDuration: Number, + camera: String, + extension: Array, + }; + const API_GET_IMAGE_INFO = 'getImageInfo'; const GetImageInfoOptions = { formatArgs: { @@ -3119,7 +3181,7 @@ var serviceContext = (function (vue) { resolve(getStorageInfoSync()); })); - const getFileInfo = defineAsyncApi(API_GET_FILE_INFO, (options, { resolve, reject }) => { + const getFileInfo$1 = defineAsyncApi(API_GET_FILE_INFO, (options, { resolve, reject }) => { plus.io.getFileInfo(extend(options, { success: warpPlusSuccessCallback(resolve), fail: warpPlusErrorCallback(reject), @@ -3899,7 +3961,7 @@ var serviceContext = (function (vue) { return array[array.length - 1]; } - const compressImage = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => { + const compressImage$1 = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => { const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; plus.zip.compressImage(extend({}, options, { dst, @@ -3921,6 +3983,236 @@ var serviceContext = (function (vue) { }, reject); }, CompressVideoProtocol, CompressVideoOptions); + /** + * 获取文件信息 + * @param {string} filePath 文件路径 + * @returns {Promise} 文件信息Promise + */ + function getFileInfo(filePath) { + return new Promise((resolve, reject) => { + plus.io.resolveLocalFileSystemURL(filePath, function (entry) { + entry.getMetadata(resolve, reject, false); + }, reject); + }); + } + function compressImage(tempFilePath) { + const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`; + return new Promise((resolve) => { + plus.nativeUI.showWaiting(); + plus.zip.compressImage({ + src: tempFilePath, + dst, + overwrite: true, + }, () => { + plus.nativeUI.closeWaiting(); + resolve(dst); + }, () => { + plus.nativeUI.closeWaiting(); + resolve(tempFilePath); + }); + }); + } + const chooseImage = defineAsyncApi(API_CHOOSE_IMAGE, + // @ts-ignore crop 属性App特有 + ({ count, sizeType, sourceType, crop } = {}, { resolve, reject }) => { + initI18nChooseImageMsgsOnce(); + const { t } = useI18n(); + const errorCallback = warpPlusErrorCallback(reject); + function successCallback(paths) { + const tempFiles = []; + const tempFilePaths = []; + // plus.zip.compressImage 压缩文件并发调用在iOS端容易出现问题(图像错误、闪退),改为队列执行 + paths + .reduce((promise, path) => { + return promise + .then(() => { + return getFileInfo(path); + }) + .then((fileInfo) => { + const size = fileInfo.size; + // 压缩阈值 0.5 兆 + const THRESHOLD = 1024 * 1024 * 0.5; + // 判断是否需要压缩 + if (!crop && + sizeType.includes('compressed') && + size > THRESHOLD) { + return compressImage(path).then((dstPath) => { + path = dstPath; + return getFileInfo(path); + }); + } + return fileInfo; + }) + .then(({ size }) => { + tempFilePaths.push(path); + tempFiles.push({ + path, + size: size, + }); + }); + }, Promise.resolve()) + .then(() => { + resolve({ + tempFilePaths, + tempFiles, + }); + }) + .catch(errorCallback); + } + function openCamera() { + const camera = plus.camera.getCamera(); + camera.captureImage((path) => successCallback([path]), errorCallback, { + filename: TEMP_PATH + '/camera/', + resolution: 'high', + crop, + }); + } + function openAlbum() { + // NOTE 5+此API分单选和多选,多选返回files:string[] + // @ts-ignore + plus.gallery.pick(({ files }) => successCallback(files), errorCallback, { + maximum: count, + multiple: true, + system: false, + filename: TEMP_PATH + '/gallery/', + permissionAlert: true, + crop, + }); + } + if (sourceType.length === 1) { + if (sourceType.includes('album')) { + openAlbum(); + return; + } + else if (sourceType.includes('camera')) { + openCamera(); + return; + } + } + plus.nativeUI.actionSheet({ + cancel: t('uni.chooseImage.cancel'), + buttons: [ + { + title: t('uni.chooseImage.sourceType.camera'), + }, + { + title: t('uni.chooseImage.sourceType.album'), + }, + ], + }, (e) => { + switch (e.index) { + case 1: + openCamera(); + break; + case 2: + openAlbum(); + break; + default: + errorCallback(); + break; + } + }); + }, ChooseImageProtocol, ChooseImageOptions); + + const chooseVideo = defineAsyncApi(API_CHOOSE_VIDEO, ({ sourceType, compressed, maxDuration, camera }, { resolve, reject }) => { + initI18nChooseVideoMsgsOnce(); + const { t } = useI18n(); + const errorCallback = warpPlusErrorCallback(reject); + function successCallback(tempFilePath = '') { + const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`; + const compressVideo = compressed + ? new Promise((resolve) => { + plus.zip.compressVideo({ + src: tempFilePath, + filename, + }, ({ tempFilePath }) => { + resolve(tempFilePath); + }, () => { + resolve(tempFilePath); + }); + }) + : Promise.resolve(tempFilePath); + if (compressed) { + plus.nativeUI.showWaiting(); + } + compressVideo.then((tempFilePath) => { + if (compressed) { + plus.nativeUI.closeWaiting(); + } + plus.io.getVideoInfo({ + filePath: tempFilePath, + success(videoInfo) { + const result = { + errMsg: 'chooseVideo:ok', + tempFilePath: tempFilePath, + size: videoInfo.size, + duration: videoInfo.duration, + width: videoInfo.width, + height: videoInfo.height, + }; + resolve(result); + }, + fail: errorCallback, + }); + }); + } + function openAlbum() { + plus.gallery.pick( + // NOTE 5+此API分单选和多选,多选返回files:string[] + // @ts-ignore + ({ files }) => successCallback(files[0]), errorCallback, { + filter: 'video', + system: false, + // 不启用 multiple 时 system 无效 + multiple: true, + maximum: 1, + filename: TEMP_PATH + '/gallery/', + permissionAlert: true, + }); + } + function openCamera() { + const plusCamera = plus.camera.getCamera(); + plusCamera.startVideoCapture(successCallback, errorCallback, { + index: camera === 'front' ? '2' : '1', + videoMaximumDuration: maxDuration, + filename: TEMP_PATH + '/camera/', + }); + } + if (sourceType.length === 1) { + if (sourceType.includes('album')) { + openAlbum(); + return; + } + else if (sourceType.includes('camera')) { + openCamera(); + return; + } + } + plus.nativeUI.actionSheet({ + cancel: t('uni.chooseVideo.cancel'), + buttons: [ + { + title: t('uni.chooseVideo.sourceType.camera'), + }, + { + title: t('uni.chooseVideo.sourceType.album'), + }, + ], + }, (e) => { + switch (e.index) { + case 1: + openCamera(); + break; + case 2: + openAlbum(); + break; + default: + errorCallback(); + break; + } + }); + }, ChooseVideoProtocol, ChooseVideoOptions); + const showKeyboard = defineAsyncApi(API_SHOW_KEYBOARD, (_, { resolve }) => { plus.key.showSoftKeybord(); resolve(); @@ -4483,7 +4775,7 @@ var serviceContext = (function (vue) { audio.__timing = setInterval(() => { const currentTime = audio.currentTime; if (currentTime !== oldCurrentTime) { - emit(audio, 'timeupdate'); + emit(audio, 'timeUpdate'); } }, 200); } @@ -4623,7 +4915,7 @@ var serviceContext = (function (vue) { }); }); function emit(audio, state, errMsg, errCode) { - const name = `on${state[0].toUpperCase() + state.substr(1)}`; + const name = `on${capitalize(state)}`; audio._callbacks[name].forEach((callback) => { if (typeof callback === 'function') { callback(state === 'error' @@ -7338,7 +7630,7 @@ var serviceContext = (function (vue) { clearStorage: clearStorage, getStorageInfoSync: getStorageInfoSync, getStorageInfo: getStorageInfo, - getFileInfo: getFileInfo, + getFileInfo: getFileInfo$1, openDocument: openDocument, onCompassChange: onCompassChange, offCompassChange: offCompassChange, @@ -7391,8 +7683,10 @@ var serviceContext = (function (vue) { getRecorderManager: getRecorderManager, saveVideoToPhotosAlbum: saveVideoToPhotosAlbum, saveImageToPhotosAlbum: saveImageToPhotosAlbum, - compressImage: compressImage, + compressImage: compressImage$1, compressVideo: compressVideo, + chooseImage: chooseImage, + chooseVideo: chooseVideo, showKeyboard: showKeyboard, hideKeyboard: hideKeyboard, downloadFile: downloadFile, diff --git a/packages/uni-app-plus/dist/uni-app-view.umd.js b/packages/uni-app-plus/dist/uni-app-view.umd.js index b0d17d038..00b97c9b9 100644 --- a/packages/uni-app-plus/dist/uni-app-view.umd.js +++ b/packages/uni-app-plus/dist/uni-app-view.umd.js @@ -2,758 +2,8 @@ typeof define === "function" && define.amd ? define(factory) : factory(); })(function() { "use strict"; - (function() { - var n = window.Document.prototype.createElement, p2 = window.Document.prototype.createElementNS, aa = window.Document.prototype.importNode, ba = window.Document.prototype.prepend, ca = window.Document.prototype.append, da = window.DocumentFragment.prototype.prepend, ea = window.DocumentFragment.prototype.append, q = window.Node.prototype.cloneNode, r = window.Node.prototype.appendChild, t = window.Node.prototype.insertBefore, u = window.Node.prototype.removeChild, v = window.Node.prototype.replaceChild, w = Object.getOwnPropertyDescriptor(window.Node.prototype, "textContent"), y = window.Element.prototype.attachShadow, z = Object.getOwnPropertyDescriptor(window.Element.prototype, "innerHTML"), A = window.Element.prototype.getAttribute, B = window.Element.prototype.setAttribute, C = window.Element.prototype.removeAttribute, D = window.Element.prototype.getAttributeNS, E2 = window.Element.prototype.setAttributeNS, F = window.Element.prototype.removeAttributeNS, G = window.Element.prototype.insertAdjacentElement, H = window.Element.prototype.insertAdjacentHTML, fa = window.Element.prototype.prepend, ha = window.Element.prototype.append, ia = window.Element.prototype.before, ja = window.Element.prototype.after, ka = window.Element.prototype.replaceWith, la = window.Element.prototype.remove, ma = window.HTMLElement, I = Object.getOwnPropertyDescriptor(window.HTMLElement.prototype, "innerHTML"), na = window.HTMLElement.prototype.insertAdjacentElement, oa = window.HTMLElement.prototype.insertAdjacentHTML; - var pa = new Set(); - "annotation-xml color-profile font-face font-face-src font-face-uri font-face-format font-face-name missing-glyph".split(" ").forEach(function(a) { - return pa.add(a); - }); - function qa(a) { - var b = pa.has(a); - a = /^[a-z][.0-9_a-z]*-[-.0-9_a-z]*$/.test(a); - return !b && a; - } - var ra = document.contains ? document.contains.bind(document) : document.documentElement.contains.bind(document.documentElement); - function J(a) { - var b = a.isConnected; - if (b !== void 0) - return b; - if (ra(a)) - return true; - for (; a && !(a.__CE_isImportDocument || a instanceof Document); ) - a = a.parentNode || (window.ShadowRoot && a instanceof ShadowRoot ? a.host : void 0); - return !(!a || !(a.__CE_isImportDocument || a instanceof Document)); - } - function K(a) { - var b = a.children; - if (b) - return Array.prototype.slice.call(b); - b = []; - for (a = a.firstChild; a; a = a.nextSibling) - a.nodeType === Node.ELEMENT_NODE && b.push(a); - return b; - } - function L(a, b) { - for (; b && b !== a && !b.nextSibling; ) - b = b.parentNode; - return b && b !== a ? b.nextSibling : null; - } - function M(a, b, c) { - for (var f = a; f; ) { - if (f.nodeType === Node.ELEMENT_NODE) { - var d = f; - b(d); - var e = d.localName; - if (e === "link" && d.getAttribute("rel") === "import") { - f = d.import; - c === void 0 && (c = new Set()); - if (f instanceof Node && !c.has(f)) - for (c.add(f), f = f.firstChild; f; f = f.nextSibling) - M(f, b, c); - f = L(a, d); - continue; - } else if (e === "template") { - f = L(a, d); - continue; - } - if (d = d.__CE_shadowRoot) - for (d = d.firstChild; d; d = d.nextSibling) - M(d, b, c); - } - f = f.firstChild ? f.firstChild : L(a, f); - } - } - function N() { - var a = !(O === null || O === void 0 || !O.noDocumentConstructionObserver), b = !(O === null || O === void 0 || !O.shadyDomFastWalk); - this.h = []; - this.a = []; - this.f = false; - this.shadyDomFastWalk = b; - this.C = !a; - } - function P(a, b, c, f) { - var d = window.ShadyDom; - if (a.shadyDomFastWalk && d && d.inUse) { - if (b.nodeType === Node.ELEMENT_NODE && c(b), b.querySelectorAll) - for (a = d.nativeMethods.querySelectorAll.call(b, "*"), b = 0; b < a.length; b++) - c(a[b]); - } else - M(b, c, f); - } - function sa(a, b) { - a.f = true; - a.h.push(b); - } - function ta(a, b) { - a.f = true; - a.a.push(b); - } - function Q(a, b) { - a.f && P(a, b, function(c) { - return R(a, c); - }); - } - function R(a, b) { - if (a.f && !b.__CE_patched) { - b.__CE_patched = true; - for (var c = 0; c < a.h.length; c++) - a.h[c](b); - for (c = 0; c < a.a.length; c++) - a.a[c](b); - } - } - function S(a, b) { - var c = []; - P(a, b, function(d) { - return c.push(d); - }); - for (b = 0; b < c.length; b++) { - var f = c[b]; - f.__CE_state === 1 ? a.connectedCallback(f) : T(a, f); - } - } - function U(a, b) { - var c = []; - P(a, b, function(d) { - return c.push(d); - }); - for (b = 0; b < c.length; b++) { - var f = c[b]; - f.__CE_state === 1 && a.disconnectedCallback(f); - } - } - function V(a, b, c) { - c = c === void 0 ? {} : c; - var f = c.D, d = c.upgrade || function(g) { - return T(a, g); - }, e = []; - P(a, b, function(g) { - a.f && R(a, g); - if (g.localName === "link" && g.getAttribute("rel") === "import") { - var h = g.import; - h instanceof Node && (h.__CE_isImportDocument = true, h.__CE_registry = document.__CE_registry); - h && h.readyState === "complete" ? h.__CE_documentLoadHandled = true : g.addEventListener("load", function() { - var k = g.import; - if (!k.__CE_documentLoadHandled) { - k.__CE_documentLoadHandled = true; - var l = new Set(); - f && (f.forEach(function(m) { - return l.add(m); - }), l.delete(k)); - V(a, k, { D: l, upgrade: d }); - } - }); - } else - e.push(g); - }, f); - for (b = 0; b < e.length; b++) - d(e[b]); - } - function T(a, b) { - try { - var c = b.ownerDocument, f = c.__CE_registry; - var d = f && (c.defaultView || c.__CE_isImportDocument) ? W(f, b.localName) : void 0; - if (d && b.__CE_state === void 0) { - d.constructionStack.push(b); - try { - try { - if (new d.constructorFunction() !== b) - throw Error("The custom element constructor did not produce the element being upgraded."); - } finally { - d.constructionStack.pop(); - } - } catch (k) { - throw b.__CE_state = 2, k; - } - b.__CE_state = 1; - b.__CE_definition = d; - if (d.attributeChangedCallback && b.hasAttributes()) { - var e = d.observedAttributes; - for (d = 0; d < e.length; d++) { - var g = e[d], h = b.getAttribute(g); - h !== null && a.attributeChangedCallback(b, g, null, h, null); - } - } - J(b) && a.connectedCallback(b); - } - } catch (k) { - X(k); - } - } - N.prototype.connectedCallback = function(a) { - var b = a.__CE_definition; - if (b.connectedCallback) - try { - b.connectedCallback.call(a); - } catch (c) { - X(c); - } - }; - N.prototype.disconnectedCallback = function(a) { - var b = a.__CE_definition; - if (b.disconnectedCallback) - try { - b.disconnectedCallback.call(a); - } catch (c) { - X(c); - } - }; - N.prototype.attributeChangedCallback = function(a, b, c, f, d) { - var e = a.__CE_definition; - if (e.attributeChangedCallback && -1 < e.observedAttributes.indexOf(b)) - try { - e.attributeChangedCallback.call(a, b, c, f, d); - } catch (g) { - X(g); - } - }; - function ua(a, b, c, f) { - var d = b.__CE_registry; - if (d && (f === null || f === "http://www.w3.org/1999/xhtml") && (d = W(d, c))) - try { - var e = new d.constructorFunction(); - if (e.__CE_state === void 0 || e.__CE_definition === void 0) - throw Error("Failed to construct '" + c + "': The returned value was not constructed with the HTMLElement constructor."); - if (e.namespaceURI !== "http://www.w3.org/1999/xhtml") - throw Error("Failed to construct '" + c + "': The constructed element's namespace must be the HTML namespace."); - if (e.hasAttributes()) - throw Error("Failed to construct '" + c + "': The constructed element must not have any attributes."); - if (e.firstChild !== null) - throw Error("Failed to construct '" + c + "': The constructed element must not have any children."); - if (e.parentNode !== null) - throw Error("Failed to construct '" + c + "': The constructed element must not have a parent node."); - if (e.ownerDocument !== b) - throw Error("Failed to construct '" + c + "': The constructed element's owner document is incorrect."); - if (e.localName !== c) - throw Error("Failed to construct '" + c + "': The constructed element's local name is incorrect."); - return e; - } catch (g) { - return X(g), b = f === null ? n.call(b, c) : p2.call(b, f, c), Object.setPrototypeOf(b, HTMLUnknownElement.prototype), b.__CE_state = 2, b.__CE_definition = void 0, R(a, b), b; - } - b = f === null ? n.call(b, c) : p2.call(b, f, c); - R(a, b); - return b; - } - function X(a) { - var b = a.message, c = a.sourceURL || a.fileName || "", f = a.line || a.lineNumber || 0, d = a.column || a.columnNumber || 0, e = void 0; - ErrorEvent.prototype.initErrorEvent === void 0 ? e = new ErrorEvent("error", { cancelable: true, message: b, filename: c, lineno: f, colno: d, error: a }) : (e = document.createEvent("ErrorEvent"), e.initErrorEvent("error", false, true, b, c, f), e.preventDefault = function() { - Object.defineProperty(this, "defaultPrevented", { configurable: true, get: function() { - return true; - } }); - }); - e.error === void 0 && Object.defineProperty(e, "error", { configurable: true, enumerable: true, get: function() { - return a; - } }); - window.dispatchEvent(e); - e.defaultPrevented || console.error(a); - } - function va() { - var a = this; - this.a = void 0; - this.w = new Promise(function(b) { - a.g = b; - }); - } - va.prototype.resolve = function(a) { - if (this.a) - throw Error("Already resolved."); - this.a = a; - this.g(a); - }; - function wa(a) { - var b = document; - this.g = void 0; - this.b = a; - this.a = b; - V(this.b, this.a); - this.a.readyState === "loading" && (this.g = new MutationObserver(this.A.bind(this)), this.g.observe(this.a, { childList: true, subtree: true })); - } - function xa(a) { - a.g && a.g.disconnect(); - } - wa.prototype.A = function(a) { - var b = this.a.readyState; - b !== "interactive" && b !== "complete" || xa(this); - for (b = 0; b < a.length; b++) - for (var c = a[b].addedNodes, f = 0; f < c.length; f++) - V(this.b, c[f]); - }; - function Y(a) { - this.j = new Map(); - this.l = new Map(); - this.u = new Map(); - this.o = false; - this.s = new Map(); - this.i = function(b) { - return b(); - }; - this.c = false; - this.m = []; - this.b = a; - this.v = a.C ? new wa(a) : void 0; - } - Y.prototype.B = function(a, b) { - var c = this; - if (!(b instanceof Function)) - throw new TypeError("Custom element constructor getters must be functions."); - ya(this, a); - this.j.set(a, b); - this.m.push(a); - this.c || (this.c = true, this.i(function() { - return za(c); - })); - }; - Y.prototype.define = function(a, b) { - var c = this; - if (!(b instanceof Function)) - throw new TypeError("Custom element constructors must be functions."); - ya(this, a); - Aa(this, a, b); - this.m.push(a); - this.c || (this.c = true, this.i(function() { - return za(c); - })); - }; - function ya(a, b) { - if (!qa(b)) - throw new SyntaxError("The element name '" + b + "' is not valid."); - if (W(a, b)) - throw Error("A custom element with name '" + (b + "' has already been defined.")); - if (a.o) - throw Error("A custom element is already being defined."); - } - function Aa(a, b, c) { - a.o = true; - var f; - try { - var d = c.prototype; - if (!(d instanceof Object)) - throw new TypeError("The custom element constructor's prototype is not an object."); - var e = function(m) { - var x = d[m]; - if (x !== void 0 && !(x instanceof Function)) - throw Error("The '" + m + "' callback must be a function."); - return x; - }; - var g = e("connectedCallback"); - var h = e("disconnectedCallback"); - var k = e("adoptedCallback"); - var l = (f = e("attributeChangedCallback")) && c.observedAttributes || []; - } catch (m) { - throw m; - } finally { - a.o = false; - } - c = { - localName: b, - constructorFunction: c, - connectedCallback: g, - disconnectedCallback: h, - adoptedCallback: k, - attributeChangedCallback: f, - observedAttributes: l, - constructionStack: [] - }; - a.l.set(b, c); - a.u.set(c.constructorFunction, c); - return c; - } - Y.prototype.upgrade = function(a) { - V(this.b, a); - }; - function za(a) { - if (a.c !== false) { - a.c = false; - for (var b = [], c = a.m, f = new Map(), d = 0; d < c.length; d++) - f.set(c[d], []); - V(a.b, document, { upgrade: function(k) { - if (k.__CE_state === void 0) { - var l = k.localName, m = f.get(l); - m ? m.push(k) : a.l.has(l) && b.push(k); - } - } }); - for (d = 0; d < b.length; d++) - T(a.b, b[d]); - for (d = 0; d < c.length; d++) { - for (var e = c[d], g = f.get(e), h = 0; h < g.length; h++) - T(a.b, g[h]); - (e = a.s.get(e)) && e.resolve(void 0); - } - c.length = 0; - } - } - Y.prototype.get = function(a) { - if (a = W(this, a)) - return a.constructorFunction; - }; - Y.prototype.whenDefined = function(a) { - if (!qa(a)) - return Promise.reject(new SyntaxError("'" + a + "' is not a valid custom element name.")); - var b = this.s.get(a); - if (b) - return b.w; - b = new va(); - this.s.set(a, b); - var c = this.l.has(a) || this.j.has(a); - a = this.m.indexOf(a) === -1; - c && a && b.resolve(void 0); - return b.w; - }; - Y.prototype.polyfillWrapFlushCallback = function(a) { - this.v && xa(this.v); - var b = this.i; - this.i = function(c) { - return a(function() { - return b(c); - }); - }; - }; - function W(a, b) { - var c = a.l.get(b); - if (c) - return c; - if (c = a.j.get(b)) { - a.j.delete(b); - try { - return Aa(a, b, c()); - } catch (f) { - X(f); - } - } - } - window.CustomElementRegistry = Y; - Y.prototype.define = Y.prototype.define; - Y.prototype.upgrade = Y.prototype.upgrade; - Y.prototype.get = Y.prototype.get; - Y.prototype.whenDefined = Y.prototype.whenDefined; - Y.prototype.polyfillDefineLazy = Y.prototype.B; - Y.prototype.polyfillWrapFlushCallback = Y.prototype.polyfillWrapFlushCallback; - function Z(a, b, c) { - function f(d) { - return function(e) { - for (var g = [], h = 0; h < arguments.length; ++h) - g[h] = arguments[h]; - h = []; - for (var k = [], l = 0; l < g.length; l++) { - var m = g[l]; - m instanceof Element && J(m) && k.push(m); - if (m instanceof DocumentFragment) - for (m = m.firstChild; m; m = m.nextSibling) - h.push(m); - else - h.push(m); - } - d.apply(this, g); - for (g = 0; g < k.length; g++) - U(a, k[g]); - if (J(this)) - for (g = 0; g < h.length; g++) - k = h[g], k instanceof Element && S(a, k); - }; - } - c.prepend !== void 0 && (b.prepend = f(c.prepend)); - c.append !== void 0 && (b.append = f(c.append)); - } - function Ba(a) { - Document.prototype.createElement = function(b) { - return ua(a, this, b, null); - }; - Document.prototype.importNode = function(b, c) { - b = aa.call(this, b, !!c); - this.__CE_registry ? V(a, b) : Q(a, b); - return b; - }; - Document.prototype.createElementNS = function(b, c) { - return ua(a, this, c, b); - }; - Z(a, Document.prototype, { prepend: ba, append: ca }); - } - function Ca(a) { - function b(f) { - return function(d) { - for (var e = [], g = 0; g < arguments.length; ++g) - e[g] = arguments[g]; - g = []; - for (var h = [], k = 0; k < e.length; k++) { - var l = e[k]; - l instanceof Element && J(l) && h.push(l); - if (l instanceof DocumentFragment) - for (l = l.firstChild; l; l = l.nextSibling) - g.push(l); - else - g.push(l); - } - f.apply(this, e); - for (e = 0; e < h.length; e++) - U(a, h[e]); - if (J(this)) - for (e = 0; e < g.length; e++) - h = g[e], h instanceof Element && S(a, h); - }; - } - var c = Element.prototype; - ia !== void 0 && (c.before = b(ia)); - ja !== void 0 && (c.after = b(ja)); - ka !== void 0 && (c.replaceWith = function(f) { - for (var d = [], e = 0; e < arguments.length; ++e) - d[e] = arguments[e]; - e = []; - for (var g = [], h = 0; h < d.length; h++) { - var k = d[h]; - k instanceof Element && J(k) && g.push(k); - if (k instanceof DocumentFragment) - for (k = k.firstChild; k; k = k.nextSibling) - e.push(k); - else - e.push(k); - } - h = J(this); - ka.apply(this, d); - for (d = 0; d < g.length; d++) - U(a, g[d]); - if (h) - for (U(a, this), d = 0; d < e.length; d++) - g = e[d], g instanceof Element && S(a, g); - }); - la !== void 0 && (c.remove = function() { - var f = J(this); - la.call(this); - f && U(a, this); - }); - } - function Da(a) { - function b(d, e) { - Object.defineProperty(d, "innerHTML", { enumerable: e.enumerable, configurable: true, get: e.get, set: function(g) { - var h = this, k = void 0; - J(this) && (k = [], P(a, this, function(x) { - x !== h && k.push(x); - })); - e.set.call(this, g); - if (k) - for (var l = 0; l < k.length; l++) { - var m = k[l]; - m.__CE_state === 1 && a.disconnectedCallback(m); - } - this.ownerDocument.__CE_registry ? V(a, this) : Q(a, this); - return g; - } }); - } - function c(d, e) { - d.insertAdjacentElement = function(g, h) { - var k = J(h); - g = e.call(this, g, h); - k && U(a, h); - J(g) && S(a, h); - return g; - }; - } - function f(d, e) { - function g(h, k) { - for (var l = []; h !== k; h = h.nextSibling) - l.push(h); - for (k = 0; k < l.length; k++) - V(a, l[k]); - } - d.insertAdjacentHTML = function(h, k) { - h = h.toLowerCase(); - if (h === "beforebegin") { - var l = this.previousSibling; - e.call(this, h, k); - g(l || this.parentNode.firstChild, this); - } else if (h === "afterbegin") - l = this.firstChild, e.call(this, h, k), g(this.firstChild, l); - else if (h === "beforeend") - l = this.lastChild, e.call(this, h, k), g(l || this.firstChild, null); - else if (h === "afterend") - l = this.nextSibling, e.call(this, h, k), g(this.nextSibling, l); - else - throw new SyntaxError("The value provided (" + String(h) + ") is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'."); - }; - } - y && (Element.prototype.attachShadow = function(d) { - d = y.call(this, d); - if (a.f && !d.__CE_patched) { - d.__CE_patched = true; - for (var e = 0; e < a.h.length; e++) - a.h[e](d); - } - return this.__CE_shadowRoot = d; - }); - z && z.get ? b(Element.prototype, z) : I && I.get ? b(HTMLElement.prototype, I) : ta(a, function(d) { - b(d, { enumerable: true, configurable: true, get: function() { - return q.call(this, true).innerHTML; - }, set: function(e) { - var g = this.localName === "template", h = g ? this.content : this, k = p2.call(document, this.namespaceURI, this.localName); - for (k.innerHTML = e; 0 < h.childNodes.length; ) - u.call(h, h.childNodes[0]); - for (e = g ? k.content : k; 0 < e.childNodes.length; ) - r.call(h, e.childNodes[0]); - } }); - }); - Element.prototype.setAttribute = function(d, e) { - if (this.__CE_state !== 1) - return B.call(this, d, e); - var g = A.call(this, d); - B.call(this, d, e); - e = A.call(this, d); - a.attributeChangedCallback(this, d, g, e, null); - }; - Element.prototype.setAttributeNS = function(d, e, g) { - if (this.__CE_state !== 1) - return E2.call(this, d, e, g); - var h = D.call(this, d, e); - E2.call(this, d, e, g); - g = D.call(this, d, e); - a.attributeChangedCallback(this, e, h, g, d); - }; - Element.prototype.removeAttribute = function(d) { - if (this.__CE_state !== 1) - return C.call(this, d); - var e = A.call(this, d); - C.call(this, d); - e !== null && a.attributeChangedCallback(this, d, e, null, null); - }; - Element.prototype.removeAttributeNS = function(d, e) { - if (this.__CE_state !== 1) - return F.call(this, d, e); - var g = D.call(this, d, e); - F.call(this, d, e); - var h = D.call(this, d, e); - g !== h && a.attributeChangedCallback(this, e, g, h, d); - }; - na ? c(HTMLElement.prototype, na) : G && c(Element.prototype, G); - oa ? f(HTMLElement.prototype, oa) : H && f(Element.prototype, H); - Z(a, Element.prototype, { prepend: fa, append: ha }); - Ca(a); - } - var Ea = {}; - function Fa(a) { - function b() { - var c = this.constructor; - var f = document.__CE_registry.u.get(c); - if (!f) - throw Error("Failed to construct a custom element: The constructor was not registered with `customElements`."); - var d = f.constructionStack; - if (d.length === 0) - return d = n.call(document, f.localName), Object.setPrototypeOf(d, c.prototype), d.__CE_state = 1, d.__CE_definition = f, R(a, d), d; - var e = d.length - 1, g = d[e]; - if (g === Ea) - throw Error("Failed to construct '" + f.localName + "': This element was already constructed."); - d[e] = Ea; - Object.setPrototypeOf(g, c.prototype); - R(a, g); - return g; - } - b.prototype = ma.prototype; - Object.defineProperty(HTMLElement.prototype, "constructor", { writable: true, configurable: true, enumerable: false, value: b }); - window.HTMLElement = b; - } - function Ga(a) { - function b(c, f) { - Object.defineProperty(c, "textContent", { enumerable: f.enumerable, configurable: true, get: f.get, set: function(d) { - if (this.nodeType === Node.TEXT_NODE) - f.set.call(this, d); - else { - var e = void 0; - if (this.firstChild) { - var g = this.childNodes, h = g.length; - if (0 < h && J(this)) { - e = Array(h); - for (var k = 0; k < h; k++) - e[k] = g[k]; - } - } - f.set.call(this, d); - if (e) - for (d = 0; d < e.length; d++) - U(a, e[d]); - } - } }); - } - Node.prototype.insertBefore = function(c, f) { - if (c instanceof DocumentFragment) { - var d = K(c); - c = t.call(this, c, f); - if (J(this)) - for (f = 0; f < d.length; f++) - S(a, d[f]); - return c; - } - d = c instanceof Element && J(c); - f = t.call(this, c, f); - d && U(a, c); - J(this) && S(a, c); - return f; - }; - Node.prototype.appendChild = function(c) { - if (c instanceof DocumentFragment) { - var f = K(c); - c = r.call(this, c); - if (J(this)) - for (var d = 0; d < f.length; d++) - S(a, f[d]); - return c; - } - f = c instanceof Element && J(c); - d = r.call(this, c); - f && U(a, c); - J(this) && S(a, c); - return d; - }; - Node.prototype.cloneNode = function(c) { - c = q.call(this, !!c); - this.ownerDocument.__CE_registry ? V(a, c) : Q(a, c); - return c; - }; - Node.prototype.removeChild = function(c) { - var f = c instanceof Element && J(c), d = u.call(this, c); - f && U(a, c); - return d; - }; - Node.prototype.replaceChild = function(c, f) { - if (c instanceof DocumentFragment) { - var d = K(c); - c = v.call(this, c, f); - if (J(this)) - for (U(a, f), f = 0; f < d.length; f++) - S(a, d[f]); - return c; - } - d = c instanceof Element && J(c); - var e = v.call(this, c, f), g = J(this); - g && U(a, f); - d && U(a, c); - g && S(a, c); - return e; - }; - w && w.get ? b(Node.prototype, w) : sa(a, function(c) { - b(c, { enumerable: true, configurable: true, get: function() { - for (var f = [], d = this.firstChild; d; d = d.nextSibling) - d.nodeType !== Node.COMMENT_NODE && f.push(d.textContent); - return f.join(""); - }, set: function(f) { - for (; this.firstChild; ) - u.call(this, this.firstChild); - f != null && f !== "" && r.call(this, document.createTextNode(f)); - } }); - }); - } - var O = window.customElements; - function Ha() { - var a = new N(); - Fa(a); - Ba(a); - Z(a, DocumentFragment.prototype, { prepend: da, append: ea }); - Ga(a); - Da(a); - a = new Y(a); - document.__CE_registry = a; - Object.defineProperty(window, "customElements", { configurable: true, enumerable: true, value: a }); - } - O && !O.forcePolyfill && typeof O.define == "function" && typeof O.get == "function" || Ha(); - window.__CE_installPolyfill = Ha; - }).call(self); - var view = "uni-view {\n display: block;\n}\nuni-view[hidden] {\n display: none;\n}\n"; + var base = "* {\n margin: 0;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n -webkit-tap-highlight-color: transparent;\n}\n\nhtml,\nbody {\n -webkit-user-select: none;\n user-select: none;\n width: 100%;\n}\n\nhtml {\n height: 100%;\n height: 100vh;\n width: 100%;\n width: 100vw;\n}\n\nbody {\n overflow-x: hidden;\n background-color: white;\n}\n\ninput[type='search']::-webkit-search-cancel-button {\n display: none;\n}\n\n.uni-loading,\nuni-button[loading]:before {\n background: transparent\n url('data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=')\n no-repeat;\n}\n\n.uni-loading {\n width: 20px;\n height: 20px;\n display: inline-block;\n vertical-align: middle;\n animation: uni-loading 1s steps(12, end) infinite;\n background-size: 100%;\n}\n\n@keyframes uni-loading {\n 0% {\n transform: rotate3d(0, 0, 1, 0deg);\n }\n\n 100% {\n transform: rotate3d(0, 0, 1, 360deg);\n }\n}\n"; + var nvue = "[nvue] uni-view,\n[nvue] uni-label,\n[nvue] uni-swiper-item,\n[nvue] uni-scroll-view {\n display: flex;\n flex-shrink: 0;\n flex-grow: 0;\n flex-basis: auto;\n align-items: stretch;\n align-content: flex-start;\n}\n\n[nvue] uni-button {\n margin: 0;\n}\n\n[nvue-dir-row] uni-view,\n[nvue-dir-row] uni-label,\n[nvue-dir-row] uni-swiper-item {\n flex-direction: row;\n}\n\n[nvue-dir-column] uni-view,\n[nvue-dir-column] uni-label,\n[nvue-dir-column] uni-swiper-item {\n flex-direction: column;\n}\n\n[nvue-dir-row-reverse] uni-view,\n[nvue-dir-row-reverse] uni-label,\n[nvue-dir-row-reverse] uni-swiper-item {\n flex-direction: row-reverse;\n}\n\n[nvue-dir-column-reverse] uni-view,\n[nvue-dir-column-reverse] uni-label,\n[nvue-dir-column-reverse] uni-swiper-item {\n flex-direction: column-reverse;\n}\n\n[nvue] uni-view,\n[nvue] uni-image,\n[nvue] uni-input,\n[nvue] uni-scroll-view,\n[nvue] uni-swiper,\n[nvue] uni-swiper-item,\n[nvue] uni-text,\n[nvue] uni-textarea,\n[nvue] uni-video {\n position: relative;\n border: 0px solid #000000;\n box-sizing: border-box;\n}\n\n[nvue] uni-swiper-item {\n position: absolute;\n}\n"; const VD_SYNC = "vdSync"; const ON_WEBVIEW_READY = "onWebviewReady"; function makeMap(str, expectsLowerCase) { @@ -768,9 +18,60 @@ const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED); const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs); + function normalizeStyle(value) { + if (isArray(value)) { + const res = {}; + for (let i = 0; i < value.length; i++) { + const item = value[i]; + const normalized = normalizeStyle(isString(item) ? parseStringStyle(item) : item); + if (normalized) { + for (const key in normalized) { + res[key] = normalized[key]; + } + } + } + return res; + } else if (isObject$1(value)) { + return value; + } + } + const listDelimiterRE = /;(?![^(]*\))/g; + const propertyDelimiterRE = /:(.+)/; + function parseStringStyle(cssText) { + const ret = {}; + cssText.split(listDelimiterRE).forEach((item) => { + if (item) { + const tmp = item.split(propertyDelimiterRE); + tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim()); + } + }); + return ret; + } + function normalizeClass(value) { + let res = ""; + if (isString(value)) { + res = value; + } else if (isArray(value)) { + for (let i = 0; i < value.length; i++) { + const normalized = normalizeClass(value[i]); + if (normalized) { + res += normalized + " "; + } + } + } else if (isObject$1(value)) { + for (const name in value) { + if (value[name]) { + res += name + " "; + } + } + } + return res.trim(); + } const EMPTY_OBJ = {}; + const EMPTY_ARR = []; const NOOP = () => { }; + const NO = () => false; const onRE = /^on[^a-z]/; const isOn = (key) => onRE.test(key); const isModelListener = (key) => key.startsWith("onUpdate:"); @@ -781,21 +82,26 @@ arr.splice(i, 1); } }; - const hasOwnProperty = Object.prototype.hasOwnProperty; - const hasOwn = (val, key) => hasOwnProperty.call(val, key); + const hasOwnProperty$1 = Object.prototype.hasOwnProperty; + const hasOwn$1 = (val, key) => hasOwnProperty$1.call(val, key); const isArray = Array.isArray; const isMap = (val) => toTypeString(val) === "[object Map]"; const isSet = (val) => toTypeString(val) === "[object Set]"; const isFunction = (val) => typeof val === "function"; const isString = (val) => typeof val === "string"; const isSymbol = (val) => typeof val === "symbol"; - const isObject = (val) => val !== null && typeof val === "object"; + const isObject$1 = (val) => val !== null && typeof val === "object"; const isPromise = (val) => { - return isObject(val) && isFunction(val.then) && isFunction(val.catch); + return isObject$1(val) && isFunction(val.then) && isFunction(val.catch); }; const objectToString = Object.prototype.toString; const toTypeString = (value) => objectToString.call(value); + const toRawType = (value) => { + return toTypeString(value).slice(8, -1); + }; const isPlainObject = (val) => toTypeString(val) === "[object Object]"; + const isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key; + const isReservedProp = /* @__PURE__ */ makeMap(",key,ref,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"); const cacheStringFunction = (fn) => { const cache = Object.create(null); return (str) => { @@ -810,7 +116,13 @@ const hyphenateRE = /\B([A-Z])/g; const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase()); const capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1)); + const toHandlerKey = cacheStringFunction((str) => str ? `on${capitalize(str)}` : ``); const hasChanged = (value, oldValue) => value !== oldValue && (value === value || oldValue === oldValue); + const invokeArrayFns = (fns, arg) => { + for (let i = 0; i < fns.length; i++) { + fns[i](arg); + } + }; const def = (obj, key, value) => { Object.defineProperty(obj, key, { configurable: true, @@ -818,6 +130,10 @@ value }); }; + const toNumber = (val) => { + const n = parseFloat(val); + return isNaN(n) ? val : n; + }; function formatLog(module, ...args) { return `[${Date.now()}][${module}]\uFF1A${args.map((arg) => JSON.stringify(arg)).join(" ")}`; } @@ -833,6 +149,15 @@ offsetLeft }; } + function plusReady(callback) { + if (typeof callback !== "function") { + return; + } + if (window.plus) { + return callback(); + } + document.addEventListener("plusready", callback); + } function normalizeEventType(type, options) { if (options) { if (options.capture) { @@ -899,14 +224,16 @@ "hover-start-time": ".h2", "hover-stay-time": ".h3" }; - const ATTR_MAP = /* @__PURE__ */ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; - }, Object.create(null))); + const ATTR_MAP = /* @__PURE__ */ (() => { + return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { + const value = EVENT_MAP[name]; + res[name] = value; + OPTIONS.forEach((v, i) => { + res[name + v] = value + i; + }); + return res; + }, Object.create(null))); + })(); function decodeObjMap(objMap) { return Object.keys(objMap).reduce((map, name) => { map[objMap[name]] = name; @@ -917,6 +244,305 @@ function decodeAttr(name) { return DECODED_ATTR_MAP[name] || name; } + function once(fn, ctx = null) { + let res; + return (...args) => { + if (fn) { + res = fn.apply(ctx, args); + fn = null; + } + return res; + }; + } + const PRIMARY_COLOR = "#007aff"; + const isObject = (val) => val !== null && typeof val === "object"; + class BaseFormatter { + constructor() { + this._caches = Object.create(null); + } + interpolate(message, values) { + if (!values) { + return [message]; + } + let tokens = this._caches[message]; + if (!tokens) { + tokens = parse(message); + this._caches[message] = tokens; + } + return compile(tokens, values); + } + } + const RE_TOKEN_LIST_VALUE = /^(?:\d)+/; + const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/; + function parse(format) { + const tokens = []; + let position = 0; + let text = ""; + while (position < format.length) { + let char = format[position++]; + if (char === "{") { + if (text) { + tokens.push({ type: "text", value: text }); + } + text = ""; + let sub = ""; + char = format[position++]; + while (char !== void 0 && char !== "}") { + sub += char; + char = format[position++]; + } + const isClosed = char === "}"; + const type = RE_TOKEN_LIST_VALUE.test(sub) ? "list" : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? "named" : "unknown"; + tokens.push({ value: sub, type }); + } else if (char === "%") { + if (format[position] !== "{") { + text += char; + } + } else { + text += char; + } + } + text && tokens.push({ type: "text", value: text }); + return tokens; + } + function compile(tokens, values) { + const compiled = []; + let index = 0; + const mode = Array.isArray(values) ? "list" : isObject(values) ? "named" : "unknown"; + if (mode === "unknown") { + return compiled; + } + while (index < tokens.length) { + const token = tokens[index]; + switch (token.type) { + case "text": + compiled.push(token.value); + break; + case "list": + compiled.push(values[parseInt(token.value, 10)]); + break; + case "named": + if (mode === "named") { + compiled.push(values[token.value]); + } + break; + } + index++; + } + return compiled; + } + const LOCALE_ZH_HANS = "zh-Hans"; + const LOCALE_ZH_HANT = "zh-Hant"; + const LOCALE_EN = "en"; + const LOCALE_FR = "fr"; + const LOCALE_ES = "es"; + const hasOwnProperty = Object.prototype.hasOwnProperty; + const hasOwn = (val, key) => hasOwnProperty.call(val, key); + const defaultFormatter = new BaseFormatter(); + function include(str, parts) { + return !!parts.find((part) => str.indexOf(part) !== -1); + } + function startsWith(str, parts) { + return parts.find((part) => str.indexOf(part) === 0); + } + function normalizeLocale(locale, messages) { + if (!locale) { + return; + } + locale = locale.trim().replace(/_/g, "-"); + if (messages[locale]) { + return locale; + } + locale = locale.toLowerCase(); + if (locale.indexOf("zh") === 0) { + if (locale.indexOf("-hans") !== -1) { + return LOCALE_ZH_HANS; + } + if (locale.indexOf("-hant") !== -1) { + return LOCALE_ZH_HANT; + } + if (include(locale, ["-tw", "-hk", "-mo", "-cht"])) { + return LOCALE_ZH_HANT; + } + return LOCALE_ZH_HANS; + } + const lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]); + if (lang) { + return lang; + } + } + class I18n { + constructor({ locale, fallbackLocale, messages, watcher, formater }) { + this.locale = LOCALE_EN; + this.fallbackLocale = LOCALE_EN; + this.message = {}; + this.messages = {}; + this.watchers = []; + if (fallbackLocale) { + this.fallbackLocale = fallbackLocale; + } + this.formater = formater || defaultFormatter; + this.messages = messages || {}; + this.setLocale(locale); + if (watcher) { + this.watchLocale(watcher); + } + } + setLocale(locale) { + const oldLocale = this.locale; + this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale; + if (!this.messages[this.locale]) { + this.messages[this.locale] = {}; + } + this.message = this.messages[this.locale]; + this.watchers.forEach((watcher) => { + watcher(this.locale, oldLocale); + }); + } + getLocale() { + return this.locale; + } + watchLocale(fn) { + const index = this.watchers.push(fn) - 1; + return () => { + this.watchers.splice(index, 1); + }; + } + add(locale, message) { + if (this.messages[locale]) { + Object.assign(this.messages[locale], message); + } else { + this.messages[locale] = message; + } + } + t(key, locale, values) { + let message = this.message; + if (typeof locale === "string") { + locale = normalizeLocale(locale, this.messages); + locale && (message = this.messages[locale]); + } else { + values = locale; + } + if (!hasOwn(message, key)) { + console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`); + return key; + } + return this.formater.interpolate(message[key], values).join(""); + } + } + function initLocaleWatcher(appVm, i18n2) { + appVm.$i18n && appVm.$i18n.vm.$watch("locale", (newLocale) => { + i18n2.setLocale(newLocale); + }, { + immediate: true + }); + } + function initVueI18n(locale = LOCALE_EN, messages = {}, fallbackLocale = LOCALE_EN) { + if (typeof locale !== "string") { + [locale, messages] = [messages, locale]; + } + if (typeof locale !== "string") { + locale = fallbackLocale; + } + const i18n2 = new I18n({ + locale: locale || fallbackLocale, + fallbackLocale, + messages + }); + let t = (key, values) => { + if (typeof getApp !== "function") { + t = function(key2, values2) { + return i18n2.t(key2, values2); + }; + } else { + const appVm = getApp().$vm; + if (!appVm.$t || !appVm.$i18n) { + t = function(key2, values2) { + return i18n2.t(key2, values2); + }; + } else { + initLocaleWatcher(appVm, i18n2); + t = function(key2, values2) { + const $i18n = appVm.$i18n; + const silentTranslationWarn = $i18n.silentTranslationWarn; + $i18n.silentTranslationWarn = true; + const msg = appVm.$t(key2, values2); + $i18n.silentTranslationWarn = silentTranslationWarn; + if (msg !== key2) { + return msg; + } + return i18n2.t(key2, $i18n.locale, values2); + }; + } + } + return t(key, values); + }; + return { + i18n: i18n2, + t(key, values) { + return t(key, values); + }, + add(locale2, message) { + return i18n2.add(locale2, message); + }, + getLocale() { + return i18n2.getLocale(); + }, + setLocale(newLocale) { + return i18n2.setLocale(newLocale); + } + }; + } + let i18n; + function useI18n() { + if (!i18n) { + let language; + { + language = plus.os.language; + } + i18n = initVueI18n(language); + } + return i18n; + } + function normalizeMessages(namespace, messages) { + return Object.keys(messages).reduce((res, name) => { + res[namespace + name] = messages[name]; + return res; + }, {}); + } + const initI18nButtonMsgsOnce = /* @__PURE__ */ once(() => { + const name = "uni.button."; + { + useI18n().add(LOCALE_EN, normalizeMessages(name, { + "feedback.title": "feedback", + "feedback.send": "send" + })); + } + { + useI18n().add(LOCALE_ES, normalizeMessages(name, { + "feedback.title": "realimentaci\xF3n", + "feedback.send": "enviar" + })); + } + { + useI18n().add(LOCALE_FR, normalizeMessages(name, { + "feedback.title": "retour d'information", + "feedback.send": "envoyer" + })); + } + { + useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { + "feedback.title": "\u95EE\u9898\u53CD\u9988", + "feedback.send": "\u53D1\u9001" + })); + } + { + useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { + "feedback.title": "\u554F\u984C\u53CD\u994B", + "feedback.send": "\u767C\u9001" + })); + } + }); const E = function() { }; E.prototype = { @@ -929,9 +555,9 @@ return this; }, once: function(name, callback, ctx) { - var self2 = this; + var self = this; function listener() { - self2.off(name, listener); + self.off(name, listener); callback.apply(ctx, arguments); } listener._ = callback; @@ -976,8 +602,8 @@ emit(event, ...args) { return emitter.emit(event, ...args); }, - subscribe(event, callback, once = false) { - emitter[once ? "once" : "on"](`${subscribeNamespace}.${event}`, callback); + subscribe(event, callback, once2 = false) { + emitter[once2 ? "once" : "on"](`${subscribeNamespace}.${event}`, callback); }, unsubscribe(event, callback) { emitter.off(`${subscribeNamespace}.${event}`, callback); @@ -994,6 +620,8 @@ const targetMap = new WeakMap(); const effectStack = []; let activeEffect; + const ITERATE_KEY = Symbol(""); + const MAP_KEY_ITERATE_KEY = Symbol(""); function isEffect(fn) { return fn && fn._isEffect === true; } @@ -1085,44 +713,596 @@ activeEffect.deps.push(dep); } } - new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol)); - function isReactive(value) { - if (isReadonly(value)) { - return isReactive(value["__v_raw"]); + function trigger(target, type, key, newValue, oldValue, oldTarget) { + const depsMap = targetMap.get(target); + if (!depsMap) { + return; } - return !!(value && value["__v_isReactive"]); - } - function isReadonly(value) { - return !!(value && value["__v_isReadonly"]); - } - function toRaw(observed) { - return observed && toRaw(observed["__v_raw"]) || observed; - } - function markRaw(value) { - def(value, "__v_skip", true); - return value; - } - function isRef(r) { - return Boolean(r && r.__v_isRef === true); - } - function unref(ref) { - return isRef(ref) ? ref.value : ref; - } - const shallowUnwrapHandlers = { - get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)), - set: (target, key, value, receiver) => { - const oldValue = target[key]; - if (isRef(oldValue) && !isRef(value)) { - oldValue.value = value; - return true; - } else { - return Reflect.set(target, key, value, receiver); + const effects = new Set(); + const add2 = (effectsToAdd) => { + if (effectsToAdd) { + effectsToAdd.forEach((effect2) => { + if (effect2 !== activeEffect || effect2.allowRecurse) { + effects.add(effect2); + } + }); } - } - }; - function proxyRefs(objectWithRefs) { + }; + if (type === "clear") { + depsMap.forEach(add2); + } else if (key === "length" && isArray(target)) { + depsMap.forEach((dep, key2) => { + if (key2 === "length" || key2 >= newValue) { + add2(dep); + } + }); + } else { + if (key !== void 0) { + add2(depsMap.get(key)); + } + switch (type) { + case "add": + if (!isArray(target)) { + add2(depsMap.get(ITERATE_KEY)); + if (isMap(target)) { + add2(depsMap.get(MAP_KEY_ITERATE_KEY)); + } + } else if (isIntegerKey(key)) { + add2(depsMap.get("length")); + } + break; + case "delete": + if (!isArray(target)) { + add2(depsMap.get(ITERATE_KEY)); + if (isMap(target)) { + add2(depsMap.get(MAP_KEY_ITERATE_KEY)); + } + } + break; + case "set": + if (isMap(target)) { + add2(depsMap.get(ITERATE_KEY)); + } + break; + } + } + const run = (effect2) => { + if (effect2.options.scheduler) { + effect2.options.scheduler(effect2); + } else { + effect2(); + } + }; + effects.forEach(run); + } + const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`); + const builtInSymbols = new Set(Object.getOwnPropertyNames(Symbol).map((key) => Symbol[key]).filter(isSymbol)); + const get = /* @__PURE__ */ createGetter(); + const shallowGet = /* @__PURE__ */ createGetter(false, true); + const readonlyGet = /* @__PURE__ */ createGetter(true); + const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations(); + function createArrayInstrumentations() { + const instrumentations = {}; + ["includes", "indexOf", "lastIndexOf"].forEach((key) => { + const method = Array.prototype[key]; + instrumentations[key] = function(...args) { + const arr = toRaw(this); + for (let i = 0, l = this.length; i < l; i++) { + track(arr, "get", i + ""); + } + const res = method.apply(arr, args); + if (res === -1 || res === false) { + return method.apply(arr, args.map(toRaw)); + } else { + return res; + } + }; + }); + ["push", "pop", "shift", "unshift", "splice"].forEach((key) => { + const method = Array.prototype[key]; + instrumentations[key] = function(...args) { + pauseTracking(); + const res = method.apply(this, args); + resetTracking(); + return res; + }; + }); + return instrumentations; + } + function createGetter(isReadonly2 = false, shallow = false) { + return function get2(target, key, receiver) { + if (key === "__v_isReactive") { + return !isReadonly2; + } else if (key === "__v_isReadonly") { + return isReadonly2; + } else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) { + return target; + } + const targetIsArray = isArray(target); + if (!isReadonly2 && targetIsArray && hasOwn$1(arrayInstrumentations, key)) { + return Reflect.get(arrayInstrumentations, key, receiver); + } + const res = Reflect.get(target, key, receiver); + if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) { + return res; + } + if (!isReadonly2) { + track(target, "get", key); + } + if (shallow) { + return res; + } + if (isRef(res)) { + const shouldUnwrap = !targetIsArray || !isIntegerKey(key); + return shouldUnwrap ? res.value : res; + } + if (isObject$1(res)) { + return isReadonly2 ? readonly(res) : reactive(res); + } + return res; + }; + } + const set = /* @__PURE__ */ createSetter(); + const shallowSet = /* @__PURE__ */ createSetter(true); + function createSetter(shallow = false) { + return function set2(target, key, value, receiver) { + let oldValue = target[key]; + if (!shallow) { + value = toRaw(value); + oldValue = toRaw(oldValue); + if (!isArray(target) && isRef(oldValue) && !isRef(value)) { + oldValue.value = value; + return true; + } + } + const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn$1(target, key); + const result = Reflect.set(target, key, value, receiver); + if (target === toRaw(receiver)) { + if (!hadKey) { + trigger(target, "add", key, value); + } else if (hasChanged(value, oldValue)) { + trigger(target, "set", key, value); + } + } + return result; + }; + } + function deleteProperty(target, key) { + const hadKey = hasOwn$1(target, key); + target[key]; + const result = Reflect.deleteProperty(target, key); + if (result && hadKey) { + trigger(target, "delete", key, void 0); + } + return result; + } + function has(target, key) { + const result = Reflect.has(target, key); + if (!isSymbol(key) || !builtInSymbols.has(key)) { + track(target, "has", key); + } + return result; + } + function ownKeys(target) { + track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY); + return Reflect.ownKeys(target); + } + const mutableHandlers = { + get, + set, + deleteProperty, + has, + ownKeys + }; + const readonlyHandlers = { + get: readonlyGet, + set(target, key) { + return true; + }, + deleteProperty(target, key) { + return true; + } + }; + const shallowReactiveHandlers = /* @__PURE__ */ extend({}, mutableHandlers, { + get: shallowGet, + set: shallowSet + }); + const toReactive = (value) => isObject$1(value) ? reactive(value) : value; + const toReadonly = (value) => isObject$1(value) ? readonly(value) : value; + const toShallow = (value) => value; + const getProto = (v) => Reflect.getPrototypeOf(v); + function get$1(target, key, isReadonly2 = false, isShallow = false) { + target = target["__v_raw"]; + const rawTarget = toRaw(target); + const rawKey = toRaw(key); + if (key !== rawKey) { + !isReadonly2 && track(rawTarget, "get", key); + } + !isReadonly2 && track(rawTarget, "get", rawKey); + const { has: has2 } = getProto(rawTarget); + const wrap = isShallow ? toShallow : isReadonly2 ? toReadonly : toReactive; + if (has2.call(rawTarget, key)) { + return wrap(target.get(key)); + } else if (has2.call(rawTarget, rawKey)) { + return wrap(target.get(rawKey)); + } else if (target !== rawTarget) { + target.get(key); + } + } + function has$1(key, isReadonly2 = false) { + const target = this["__v_raw"]; + const rawTarget = toRaw(target); + const rawKey = toRaw(key); + if (key !== rawKey) { + !isReadonly2 && track(rawTarget, "has", key); + } + !isReadonly2 && track(rawTarget, "has", rawKey); + return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey); + } + function size(target, isReadonly2 = false) { + target = target["__v_raw"]; + !isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY); + return Reflect.get(target, "size", target); + } + function add(value) { + value = toRaw(value); + const target = toRaw(this); + const proto = getProto(target); + const hadKey = proto.has.call(target, value); + if (!hadKey) { + target.add(value); + trigger(target, "add", value, value); + } + return this; + } + function set$1(key, value) { + value = toRaw(value); + const target = toRaw(this); + const { has: has2, get: get2 } = getProto(target); + let hadKey = has2.call(target, key); + if (!hadKey) { + key = toRaw(key); + hadKey = has2.call(target, key); + } + const oldValue = get2.call(target, key); + target.set(key, value); + if (!hadKey) { + trigger(target, "add", key, value); + } else if (hasChanged(value, oldValue)) { + trigger(target, "set", key, value); + } + return this; + } + function deleteEntry(key) { + const target = toRaw(this); + const { has: has2, get: get2 } = getProto(target); + let hadKey = has2.call(target, key); + if (!hadKey) { + key = toRaw(key); + hadKey = has2.call(target, key); + } + get2 ? get2.call(target, key) : void 0; + const result = target.delete(key); + if (hadKey) { + trigger(target, "delete", key, void 0); + } + return result; + } + function clear() { + const target = toRaw(this); + const hadItems = target.size !== 0; + const result = target.clear(); + if (hadItems) { + trigger(target, "clear", void 0, void 0); + } + return result; + } + function createForEach(isReadonly2, isShallow) { + return function forEach(callback, thisArg) { + const observed = this; + const target = observed["__v_raw"]; + const rawTarget = toRaw(target); + const wrap = isShallow ? toShallow : isReadonly2 ? toReadonly : toReactive; + !isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY); + return target.forEach((value, key) => { + return callback.call(thisArg, wrap(value), wrap(key), observed); + }); + }; + } + function createIterableMethod(method, isReadonly2, isShallow) { + return function(...args) { + 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 = isShallow ? toShallow : isReadonly2 ? toReadonly : toReactive; + !isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY); + return { + next() { + const { value, done } = innerIterator.next(); + return done ? { value, done } : { + value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), + done + }; + }, + [Symbol.iterator]() { + return this; + } + }; + }; + } + function createReadonlyMethod(type) { + return function(...args) { + return type === "delete" ? false : this; + }; + } + function createInstrumentations() { + const mutableInstrumentations2 = { + get(key) { + return get$1(this, key); + }, + get size() { + return size(this); + }, + has: has$1, + add, + set: set$1, + delete: deleteEntry, + clear, + forEach: createForEach(false, false) + }; + const shallowInstrumentations2 = { + get(key) { + return get$1(this, key, false, true); + }, + get size() { + return size(this); + }, + has: has$1, + add, + set: set$1, + delete: deleteEntry, + clear, + forEach: createForEach(false, true) + }; + const readonlyInstrumentations2 = { + get(key) { + return get$1(this, key, true); + }, + get size() { + return size(this, true); + }, + has(key) { + return has$1.call(this, key, true); + }, + add: createReadonlyMethod("add"), + set: createReadonlyMethod("set"), + delete: createReadonlyMethod("delete"), + clear: createReadonlyMethod("clear"), + forEach: createForEach(true, false) + }; + const shallowReadonlyInstrumentations2 = { + get(key) { + return get$1(this, key, true, true); + }, + get size() { + return size(this, true); + }, + has(key) { + return has$1.call(this, key, true); + }, + add: createReadonlyMethod("add"), + set: createReadonlyMethod("set"), + delete: createReadonlyMethod("delete"), + clear: createReadonlyMethod("clear"), + forEach: createForEach(true, true) + }; + 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); + }); + return [ + mutableInstrumentations2, + readonlyInstrumentations2, + shallowInstrumentations2, + shallowReadonlyInstrumentations2 + ]; + } + const [ + mutableInstrumentations, + readonlyInstrumentations, + shallowInstrumentations, + shallowReadonlyInstrumentations + ] = /* @__PURE__ */ createInstrumentations(); + function createInstrumentationGetter(isReadonly2, shallow) { + const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations; + return (target, key, receiver) => { + if (key === "__v_isReactive") { + return !isReadonly2; + } else if (key === "__v_isReadonly") { + return isReadonly2; + } else if (key === "__v_raw") { + return target; + } + return Reflect.get(hasOwn$1(instrumentations, key) && key in target ? instrumentations : target, key, receiver); + }; + } + const mutableCollectionHandlers = { + get: /* @__PURE__ */ createInstrumentationGetter(false, false) + }; + const shallowCollectionHandlers = { + get: /* @__PURE__ */ createInstrumentationGetter(false, true) + }; + const readonlyCollectionHandlers = { + get: /* @__PURE__ */ createInstrumentationGetter(true, false) + }; + const reactiveMap = new WeakMap(); + const shallowReactiveMap = new WeakMap(); + const readonlyMap = new WeakMap(); + const shallowReadonlyMap = new WeakMap(); + function targetTypeMap(rawType) { + switch (rawType) { + case "Object": + case "Array": + return 1; + case "Map": + case "Set": + case "WeakMap": + case "WeakSet": + return 2; + default: + return 0; + } + } + function getTargetType(value) { + return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value)); + } + function reactive(target) { + if (target && target["__v_isReadonly"]) { + return target; + } + return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap); + } + function shallowReactive(target) { + return createReactiveObject(target, false, shallowReactiveHandlers, shallowCollectionHandlers, shallowReactiveMap); + } + function readonly(target) { + return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap); + } + function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) { + if (!isObject$1(target)) { + return target; + } + if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) { + return target; + } + const existingProxy = proxyMap.get(target); + if (existingProxy) { + return existingProxy; + } + const targetType = getTargetType(target); + if (targetType === 0) { + return target; + } + const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers); + proxyMap.set(target, proxy); + return proxy; + } + function isReactive(value) { + if (isReadonly(value)) { + return isReactive(value["__v_raw"]); + } + return !!(value && value["__v_isReactive"]); + } + function isReadonly(value) { + return !!(value && value["__v_isReadonly"]); + } + function isProxy(value) { + return isReactive(value) || isReadonly(value); + } + function toRaw(observed) { + return observed && toRaw(observed["__v_raw"]) || observed; + } + function markRaw(value) { + def(value, "__v_skip", true); + return value; + } + const convert = (val) => isObject$1(val) ? reactive(val) : val; + function isRef(r) { + return Boolean(r && r.__v_isRef === true); + } + function ref(value) { + return createRef(value); + } + class RefImpl { + constructor(_rawValue, _shallow) { + this._rawValue = _rawValue; + this._shallow = _shallow; + this.__v_isRef = true; + this._value = _shallow ? _rawValue : convert(_rawValue); + } + get value() { + track(toRaw(this), "get", "value"); + return this._value; + } + set value(newVal) { + if (hasChanged(toRaw(newVal), this._rawValue)) { + this._rawValue = newVal; + this._value = this._shallow ? newVal : convert(newVal); + trigger(toRaw(this), "set", "value", newVal); + } + } + } + function createRef(rawValue, shallow = false) { + if (isRef(rawValue)) { + return rawValue; + } + return new RefImpl(rawValue, shallow); + } + function unref(ref2) { + return isRef(ref2) ? ref2.value : ref2; + } + const shallowUnwrapHandlers = { + get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)), + set: (target, key, value, receiver) => { + const oldValue = target[key]; + if (isRef(oldValue) && !isRef(value)) { + oldValue.value = value; + return true; + } else { + return Reflect.set(target, key, value, receiver); + } + } + }; + function proxyRefs(objectWithRefs) { return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers); } + class ComputedRefImpl { + constructor(getter, _setter, isReadonly2) { + this._setter = _setter; + this._dirty = true; + this.__v_isRef = true; + this.effect = effect(getter, { + lazy: true, + scheduler: () => { + if (!this._dirty) { + this._dirty = true; + trigger(toRaw(this), "set", "value"); + } + } + }); + this["__v_isReadonly"] = isReadonly2; + } + get value() { + const self = toRaw(this); + if (self._dirty) { + self._value = this.effect(); + self._dirty = false; + } + track(self, "get", "value"); + return self._value; + } + set value(newValue) { + this._setter(newValue); + } + } + function computed(getterOrOptions) { + let getter; + let setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + setter = NOOP; + } else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + return new ComputedRefImpl(getter, setter, isFunction(getterOrOptions) || !getterOrOptions.set); + } const stack = []; function warn(msg, ...args) { pauseTracking(); @@ -1314,6 +1494,12 @@ currentFlushPromise = resolvedPromise.then(flushJobs); } } + function invalidateJob(job) { + const i = queue.indexOf(job); + if (i > flushIndex) { + queue.splice(i, 1); + } + } function queueCb(cb, activeQueue, pendingQueue, index) { if (!isArray(cb)) { if (!activeQueue || !activeQueue.includes(cb, cb.allowRecurse ? index + 1 : index)) { @@ -1402,99 +1588,468 @@ } } } - function queueEffectWithSuspense(fn, suspense) { - if (suspense && suspense.pendingBranch) { - if (isArray(fn)) { - suspense.effects.push(...fn); - } else { - suspense.effects.push(fn); - } + const globalCompatConfig = { + MODE: 2 + }; + function getCompatConfigForKey(key, instance) { + const instanceConfig = instance && instance.type.compatConfig; + if (instanceConfig && key in instanceConfig) { + return instanceConfig[key]; + } + return globalCompatConfig[key]; + } + function isCompatEnabled(key, instance, enableForBuiltIn = false) { + if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) { + return false; + } + const rawMode = getCompatConfigForKey("MODE", instance) || 2; + const val = getCompatConfigForKey(key, instance); + const mode = isFunction(rawMode) ? rawMode(instance && instance.type) : rawMode; + if (mode === 2) { + return val !== false; } else { - queuePostFlushCb(fn); + return val === true || val === "suppress-warning"; } } - const INITIAL_WATCHER_VALUE = {}; - function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ, instance = currentInstance) { - let getter; - let forceTrigger = false; - let isMultiSource = false; - if (isRef(source)) { - getter = () => source.value; - forceTrigger = !!source._shallow; - } else if (isReactive(source)) { - getter = () => source; - deep = true; - } else if (isArray(source)) { - isMultiSource = true; - forceTrigger = source.some(isReactive); - getter = () => source.map((s) => { - if (isRef(s)) { - return s.value; - } else if (isReactive(s)) { - return traverse(s); - } else if (isFunction(s)) { - return callWithErrorHandling(s, instance, 2); - } else - ; - }); - } else if (isFunction(source)) { - if (cb) { - getter = () => callWithErrorHandling(source, instance, 2); - } else { - getter = () => { - if (instance && instance.isUnmounted) { - return; - } - if (cleanup2) { - cleanup2(); - } - return callWithAsyncErrorHandling(source, instance, 3, [onInvalidate]); - }; + function emit(instance, event, ...rawArgs) { + const props = instance.vnode.props || EMPTY_OBJ; + let args = rawArgs; + const isModelListener2 = event.startsWith("update:"); + const modelArg = isModelListener2 && event.slice(7); + if (modelArg && modelArg in props) { + const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`; + const { number, trim } = props[modifiersKey] || EMPTY_OBJ; + if (trim) { + args = rawArgs.map((a) => a.trim()); + } else if (number) { + args = rawArgs.map(toNumber); } - } else { - getter = NOOP; } - if (cb && deep) { - const baseGetter = getter; - getter = () => traverse(baseGetter()); + let handlerName; + let handler = props[handlerName = toHandlerKey(event)] || props[handlerName = toHandlerKey(camelize(event))]; + if (!handler && isModelListener2) { + handler = props[handlerName = toHandlerKey(hyphenate(event))]; } - let cleanup2; - let onInvalidate = (fn) => { - cleanup2 = runner.options.onStop = () => { - callWithErrorHandling(fn, instance, 4); - }; - }; - let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE; - const job = () => { - if (!runner.active) { + if (handler) { + callWithAsyncErrorHandling(handler, instance, 6, args); + } + const onceHandler = props[handlerName + `Once`]; + if (onceHandler) { + if (!instance.emitted) { + instance.emitted = {}; + } else if (instance.emitted[handlerName]) { return; } - if (cb) { - const newValue = runner(); - if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) { - if (cleanup2) { - cleanup2(); - } - callWithAsyncErrorHandling(cb, instance, 3, [ - newValue, - oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue, - onInvalidate - ]); - oldValue = newValue; + instance.emitted[handlerName] = true; + callWithAsyncErrorHandling(onceHandler, instance, 6, args); + } + } + function normalizeEmitsOptions(comp, appContext, asMixin = false) { + const cache = appContext.emitsCache; + const cached = cache.get(comp); + if (cached !== void 0) { + return cached; + } + const raw = comp.emits; + let normalized = {}; + let hasExtends = false; + if (!isFunction(comp)) { + const extendEmits = (raw2) => { + const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true); + if (normalizedFromExtend) { + hasExtends = true; + extend(normalized, normalizedFromExtend); } - } else { - runner(); + }; + if (!asMixin && appContext.mixins.length) { + appContext.mixins.forEach(extendEmits); } - }; - job.allowRecurse = !!cb; - let scheduler; - if (flush === "sync") { - scheduler = job; - } else if (flush === "post") { - scheduler = () => queuePostRenderEffect(job, instance && instance.suspense); - } else { - scheduler = () => { - if (!instance || instance.isMounted) { + if (comp.extends) { + extendEmits(comp.extends); + } + if (comp.mixins) { + comp.mixins.forEach(extendEmits); + } + } + if (!raw && !hasExtends) { + cache.set(comp, null); + return null; + } + if (isArray(raw)) { + raw.forEach((key) => normalized[key] = null); + } else { + extend(normalized, raw); + } + cache.set(comp, normalized); + return normalized; + } + function isEmitListener(options, key) { + if (!options || !isOn(key)) { + return false; + } + key = key.slice(2).replace(/Once$/, ""); + return hasOwn$1(options, key[0].toLowerCase() + key.slice(1)) || hasOwn$1(options, hyphenate(key)) || hasOwn$1(options, key); + } + let currentRenderingInstance = null; + let currentScopeId = null; + function setCurrentRenderingInstance(instance) { + const prev = currentRenderingInstance; + currentRenderingInstance = instance; + currentScopeId = instance && instance.type.__scopeId || null; + return prev; + } + function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot) { + if (!ctx) + return fn; + if (fn._n) { + return fn; + } + const renderFnWithContext = (...args) => { + if (renderFnWithContext._d) { + setBlockTracking(-1); + } + const prevInstance = setCurrentRenderingInstance(ctx); + const res = fn(...args); + setCurrentRenderingInstance(prevInstance); + if (renderFnWithContext._d) { + setBlockTracking(1); + } + return res; + }; + renderFnWithContext._n = true; + renderFnWithContext._c = true; + renderFnWithContext._d = true; + return renderFnWithContext; + } + let accessedAttrs = false; + function markAttrsAccessed() { + accessedAttrs = true; + } + function renderComponentRoot(instance) { + const { + type: Component, + vnode, + proxy, + withProxy, + props, + propsOptions: [propsOptions], + slots, + attrs: attrs2, + emit: emit2, + render, + renderCache, + data, + setupState, + ctx, + inheritAttrs + } = instance; + let result; + const prev = setCurrentRenderingInstance(instance); + try { + let fallthroughAttrs; + if (vnode.shapeFlag & 4) { + const proxyToUse = withProxy || proxy; + result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx)); + fallthroughAttrs = attrs2; + } else { + const render2 = Component; + if (false) + ; + result = normalizeVNode(render2.length > 1 ? render2(props, false ? { + get attrs() { + markAttrsAccessed(); + return attrs2; + }, + slots, + emit: emit2 + } : { attrs: attrs2, slots, emit: emit2 }) : render2(props, null)); + fallthroughAttrs = Component.props ? attrs2 : getFunctionalFallthrough(attrs2); + } + let root = result; + let setRoot = void 0; + if (false) + ; + if (fallthroughAttrs && inheritAttrs !== false) { + const keys = Object.keys(fallthroughAttrs); + const { shapeFlag } = root; + if (keys.length) { + if (shapeFlag & 1 || shapeFlag & 6) { + if (propsOptions && keys.some(isModelListener)) { + fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions); + } + root = cloneVNode(root, fallthroughAttrs); + } else if (false) + ; + } + } + if (false) + ; + if (vnode.dirs) { + if (false) + ; + root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs; + } + if (vnode.transition) { + if (false) + ; + root.transition = vnode.transition; + } + if (false) + ; + else { + result = root; + } + } catch (err) { + handleError(err, instance, 1); + result = createVNode(Comment$1); + } + setCurrentRenderingInstance(prev); + return result; + } + const getChildRoot = (vnode) => { + const rawChildren = vnode.children; + const dynamicChildren = vnode.dynamicChildren; + const childRoot = filterSingleRoot(rawChildren); + if (!childRoot) { + return [vnode, void 0]; + } + const index = rawChildren.indexOf(childRoot); + const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1; + const setRoot = (updatedRoot) => { + rawChildren[index] = updatedRoot; + if (dynamicChildren) { + if (dynamicIndex > -1) { + dynamicChildren[dynamicIndex] = updatedRoot; + } else if (updatedRoot.patchFlag > 0) { + vnode.dynamicChildren = [...dynamicChildren, updatedRoot]; + } + } + }; + return [normalizeVNode(childRoot), setRoot]; + }; + function filterSingleRoot(children) { + let singleRoot; + for (let i = 0; i < children.length; i++) { + const child = children[i]; + if (isVNode(child)) { + if (child.type !== Comment$1 || child.children === "v-if") { + if (singleRoot) { + return; + } else { + singleRoot = child; + } + } + } else { + return; + } + } + return singleRoot; + } + const getFunctionalFallthrough = (attrs2) => { + let res; + for (const key in attrs2) { + if (key === "class" || key === "style" || isOn(key)) { + (res || (res = {}))[key] = attrs2[key]; + } + } + return res; + }; + const filterModelListeners = (attrs2, props) => { + const res = {}; + for (const key in attrs2) { + if (!isModelListener(key) || !(key.slice(9) in props)) { + res[key] = attrs2[key]; + } + } + return res; + }; + const isElementRoot = (vnode) => { + return vnode.shapeFlag & 6 || vnode.shapeFlag & 1 || vnode.type === Comment$1; + }; + function shouldUpdateComponent(prevVNode, nextVNode, optimized) { + const { props: prevProps, children: prevChildren, component } = prevVNode; + const { props: nextProps, children: nextChildren, patchFlag } = nextVNode; + const emits = component.emitsOptions; + if (nextVNode.dirs || nextVNode.transition) { + return true; + } + if (optimized && patchFlag >= 0) { + if (patchFlag & 1024) { + return true; + } + if (patchFlag & 16) { + if (!prevProps) { + return !!nextProps; + } + return hasPropsChanged(prevProps, nextProps, emits); + } else if (patchFlag & 8) { + const dynamicProps = nextVNode.dynamicProps; + for (let i = 0; i < dynamicProps.length; i++) { + const key = dynamicProps[i]; + if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) { + return true; + } + } + } + } else { + if (prevChildren || nextChildren) { + if (!nextChildren || !nextChildren.$stable) { + return true; + } + } + if (prevProps === nextProps) { + return false; + } + if (!prevProps) { + return !!nextProps; + } + if (!nextProps) { + return true; + } + return hasPropsChanged(prevProps, nextProps, emits); + } + return false; + } + function hasPropsChanged(prevProps, nextProps, emitsOptions) { + const nextKeys = Object.keys(nextProps); + if (nextKeys.length !== Object.keys(prevProps).length) { + return true; + } + for (let i = 0; i < nextKeys.length; i++) { + const key = nextKeys[i]; + if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) { + return true; + } + } + return false; + } + function updateHOCHostEl({ vnode, parent }, el) { + while (parent && parent.subTree === vnode) { + (vnode = parent.vnode).el = el; + parent = parent.parent; + } + } + const isSuspense = (type) => type.__isSuspense; + function queueEffectWithSuspense(fn, suspense) { + if (suspense && suspense.pendingBranch) { + if (isArray(fn)) { + suspense.effects.push(...fn); + } else { + suspense.effects.push(fn); + } + } else { + queuePostFlushCb(fn); + } + } + function provide(key, value) { + if (!currentInstance) + ; + else { + let provides = currentInstance.provides; + const parentProvides = currentInstance.parent && currentInstance.parent.provides; + if (parentProvides === provides) { + provides = currentInstance.provides = Object.create(parentProvides); + } + provides[key] = value; + } + } + 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 (provides && key in provides) { + return provides[key]; + } else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) ? defaultValue.call(instance.proxy) : defaultValue; + } else + ; + } + } + const INITIAL_WATCHER_VALUE = {}; + function watch(source, cb, options) { + return doWatch(source, cb, options); + } + function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EMPTY_OBJ, instance = currentInstance) { + let getter; + let forceTrigger = false; + let isMultiSource = false; + if (isRef(source)) { + getter = () => source.value; + forceTrigger = !!source._shallow; + } else if (isReactive(source)) { + getter = () => source; + deep = true; + } else if (isArray(source)) { + isMultiSource = true; + forceTrigger = source.some(isReactive); + getter = () => source.map((s) => { + if (isRef(s)) { + return s.value; + } else if (isReactive(s)) { + return traverse(s); + } else if (isFunction(s)) { + return callWithErrorHandling(s, instance, 2); + } else + ; + }); + } else if (isFunction(source)) { + if (cb) { + getter = () => callWithErrorHandling(source, instance, 2); + } else { + getter = () => { + if (instance && instance.isUnmounted) { + return; + } + if (cleanup2) { + cleanup2(); + } + return callWithAsyncErrorHandling(source, instance, 3, [onInvalidate]); + }; + } + } else { + getter = NOOP; + } + if (cb && deep) { + const baseGetter = getter; + getter = () => traverse(baseGetter()); + } + let cleanup2; + let onInvalidate = (fn) => { + cleanup2 = runner.options.onStop = () => { + callWithErrorHandling(fn, instance, 4); + }; + }; + let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE; + const job = () => { + if (!runner.active) { + return; + } + if (cb) { + const newValue = runner(); + if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue)) || false) { + if (cleanup2) { + cleanup2(); + } + callWithAsyncErrorHandling(cb, instance, 3, [ + newValue, + oldValue === INITIAL_WATCHER_VALUE ? void 0 : oldValue, + onInvalidate + ]); + oldValue = newValue; + } + } else { + runner(); + } + }; + job.allowRecurse = !!cb; + let scheduler; + if (flush === "sync") { + scheduler = job; + } else if (flush === "post") { + scheduler = () => queuePostRenderEffect(job, instance && instance.suspense); + } else { + scheduler = () => { + if (!instance || instance.isMounted) { queuePreFlushCb(job); } else { job(); @@ -1549,7 +2104,7 @@ }; } function traverse(value, seen = new Set()) { - if (!isObject(value) || seen.has(value) || value["__v_skip"]) { + if (!isObject$1(value) || seen.has(value) || value["__v_skip"]) { return value; } seen.add(value); @@ -1570,30 +2125,280 @@ } return value; } + function defineComponent(options) { + return isFunction(options) ? { setup: options, name: options.name } : options; + } + const isAsyncWrapper = (i) => !!i.type.__asyncLoader; + const isKeepAlive = (vnode) => vnode.type.__isKeepAlive; + function onActivated(hook, target) { + registerKeepAliveHook(hook, "a", target); + } + function onDeactivated(hook, target) { + registerKeepAliveHook(hook, "da", target); + } + function registerKeepAliveHook(hook, type, target = currentInstance) { + const wrappedHook = hook.__wdc || (hook.__wdc = () => { + let current = target; + while (current) { + if (current.isDeactivated) { + return; + } + current = current.parent; + } + hook(); + }); + injectHook(type, wrappedHook, target); + if (target) { + let current = target.parent; + while (current && current.parent) { + if (isKeepAlive(current.parent.vnode)) { + injectToKeepAliveRoot(wrappedHook, type, target, current); + } + current = current.parent; + } + } + } + function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) { + const injected = injectHook(type, hook, keepAliveRoot, true); + onUnmounted(() => { + remove(keepAliveRoot[type], injected); + }, target); + } + function injectHook(type, hook, target = currentInstance, prepend = false) { + if (target) { + const hooks = target[type] || (target[type] = []); + const wrappedHook = hook.__weh || (hook.__weh = (...args) => { + if (target.isUnmounted) { + return; + } + pauseTracking(); + setCurrentInstance(target); + const res = callWithAsyncErrorHandling(hook, target, type, args); + setCurrentInstance(null); + resetTracking(); + return res; + }); + if (prepend) { + hooks.unshift(wrappedHook); + } else { + hooks.push(wrappedHook); + } + return wrappedHook; + } + } + const createHook = (lifecycle) => (hook, target = currentInstance) => (!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, hook, target); + const onBeforeMount = createHook("bm"); + const onMounted = createHook("m"); + const onBeforeUpdate = createHook("bu"); + const onUpdated = createHook("u"); + const onBeforeUnmount = createHook("bum"); + const onUnmounted = createHook("um"); + const onServerPrefetch = createHook("sp"); + const onRenderTriggered = createHook("rtg"); + const onRenderTracked = createHook("rtc"); + function onErrorCaptured(hook, target = currentInstance) { + injectHook("ec", hook, target); + } + let shouldCacheAccess = true; + function applyOptions(instance) { + const options = resolveMergedOptions(instance); + const publicThis = instance.proxy; + const ctx = instance.ctx; + shouldCacheAccess = false; + if (options.beforeCreate) { + callHook(options.beforeCreate, instance, "bc"); + } + const { + data: dataOptions, + computed: computedOptions, + methods, + watch: watchOptions, + provide: provideOptions, + inject: injectOptions, + created, + beforeMount, + mounted, + beforeUpdate, + updated, + activated, + deactivated, + beforeDestroy, + beforeUnmount, + destroyed, + unmounted, + render, + renderTracked, + renderTriggered, + errorCaptured, + serverPrefetch, + expose, + inheritAttrs, + components, + directives, + filters + } = options; + const checkDuplicateProperties = null; + if (injectOptions) { + resolveInjections(injectOptions, ctx, checkDuplicateProperties); + } + if (methods) { + for (const key in methods) { + const methodHandler = methods[key]; + if (isFunction(methodHandler)) { + { + ctx[key] = methodHandler.bind(publicThis); + } + } + } + } + if (dataOptions) { + const data = dataOptions.call(publicThis, publicThis); + if (!isObject$1(data)) + ; + else { + instance.data = reactive(data); + } + } + shouldCacheAccess = true; + if (computedOptions) { + for (const key in computedOptions) { + const opt = computedOptions[key]; + const get2 = isFunction(opt) ? opt.bind(publicThis, publicThis) : isFunction(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP; + const set2 = !isFunction(opt) && isFunction(opt.set) ? opt.set.bind(publicThis) : NOOP; + const c = computed$1({ + get: get2, + set: set2 + }); + Object.defineProperty(ctx, key, { + enumerable: true, + configurable: true, + get: () => c.value, + set: (v) => c.value = v + }); + } + } + if (watchOptions) { + for (const key in watchOptions) { + createWatcher(watchOptions[key], ctx, publicThis, key); + } + } + if (provideOptions) { + const provides = isFunction(provideOptions) ? provideOptions.call(publicThis) : provideOptions; + Reflect.ownKeys(provides).forEach((key) => { + provide(key, provides[key]); + }); + } + if (created) { + callHook(created, instance, "c"); + } + function registerLifecycleHook(register, hook) { + if (isArray(hook)) { + hook.forEach((_hook) => register(_hook.bind(publicThis))); + } else if (hook) { + register(hook.bind(publicThis)); + } + } + registerLifecycleHook(onBeforeMount, beforeMount); + registerLifecycleHook(onMounted, mounted); + registerLifecycleHook(onBeforeUpdate, beforeUpdate); + registerLifecycleHook(onUpdated, updated); + registerLifecycleHook(onActivated, activated); + registerLifecycleHook(onDeactivated, deactivated); + registerLifecycleHook(onErrorCaptured, errorCaptured); + registerLifecycleHook(onRenderTracked, renderTracked); + registerLifecycleHook(onRenderTriggered, renderTriggered); + registerLifecycleHook(onBeforeUnmount, beforeUnmount); + registerLifecycleHook(onUnmounted, unmounted); + registerLifecycleHook(onServerPrefetch, serverPrefetch); + if (isArray(expose)) { + if (expose.length) { + const exposed = instance.exposed || (instance.exposed = {}); + expose.forEach((key) => { + Object.defineProperty(exposed, key, { + get: () => publicThis[key], + set: (val) => publicThis[key] = val + }); + }); + } else if (!instance.exposed) { + instance.exposed = {}; + } + } + if (render && instance.render === NOOP) { + instance.render = render; + } + if (inheritAttrs != null) { + instance.inheritAttrs = inheritAttrs; + } + if (components) + instance.components = components; + if (directives) + instance.directives = directives; + } + function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) { + if (isArray(injectOptions)) { + injectOptions = normalizeInject(injectOptions); + } + for (const key in injectOptions) { + const opt = injectOptions[key]; + if (isObject$1(opt)) { + if ("default" in opt) { + ctx[key] = inject(opt.from || key, opt.default, true); + } else { + ctx[key] = inject(opt.from || key); + } + } else { + ctx[key] = inject(opt); + } + } + } + function callHook(hook, instance, type) { + callWithAsyncErrorHandling(isArray(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy), instance, type); + } + function createWatcher(raw, ctx, publicThis, key) { + const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key]; + if (isString(raw)) { + const handler = ctx[raw]; + if (isFunction(handler)) { + watch(getter, handler); + } + } else if (isFunction(raw)) { + watch(getter, raw.bind(publicThis)); + } else if (isObject$1(raw)) { + if (isArray(raw)) { + raw.forEach((r) => createWatcher(r, ctx, publicThis, key)); + } else { + const handler = isFunction(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler]; + if (isFunction(handler)) { + watch(getter, handler, raw); + } + } + } else + ; + } function resolveMergedOptions(instance) { - const base = instance.type; - const { mixins, extends: extendsOptions } = base; + const base2 = instance.type; + const { mixins, extends: extendsOptions } = base2; const { mixins: globalMixins, optionsCache: cache, config: { optionMergeStrategies } } = instance.appContext; - const cached = cache.get(base); + const cached = cache.get(base2); let resolved; if (cached) { resolved = cached; } else if (!globalMixins.length && !mixins && !extendsOptions) { { - resolved = base; + resolved = base2; } } else { resolved = {}; if (globalMixins.length) { globalMixins.forEach((m) => mergeOptions(resolved, m, optionMergeStrategies, true)); } - mergeOptions(resolved, base, optionMergeStrategies); + mergeOptions(resolved, base2, optionMergeStrategies); } - cache.set(base, resolved); + cache.set(base2, resolved); return resolved; } function mergeOptions(to, from, strats, asMixin = false) { @@ -1658,28 +2463,1587 @@ for (let i = 0; i < raw.length; i++) { res[raw[i]] = raw[i]; } - return res; + return res; + } + return raw; + } + function mergeAsArray(to, from) { + return to ? [...new Set([].concat(to, from))] : from; + } + function mergeObjectOptions(to, from) { + return to ? extend(extend(Object.create(null), to), from) : from; + } + function mergeWatchOptions(to, from) { + if (!to) + return from; + if (!from) + return to; + const merged = extend(Object.create(null), to); + for (const key in from) { + merged[key] = mergeAsArray(to[key], from[key]); + } + return merged; + } + function initProps(instance, rawProps, isStateful, isSSR = false) { + const props = {}; + const attrs2 = {}; + def(attrs2, InternalObjectKey, 1); + instance.propsDefaults = Object.create(null); + setFullProps(instance, rawProps, props, attrs2); + for (const key in instance.propsOptions[0]) { + if (!(key in props)) { + props[key] = void 0; + } + } + if (isStateful) { + instance.props = isSSR ? props : shallowReactive(props); + } else { + if (!instance.type.props) { + instance.props = attrs2; + } else { + instance.props = props; + } + } + instance.attrs = attrs2; + } + function updateProps(instance, rawProps, rawPrevProps, optimized) { + const { + props, + attrs: attrs2, + vnode: { patchFlag } + } = instance; + const rawCurrentProps = toRaw(props); + const [options] = instance.propsOptions; + let hasAttrsChanged = false; + if ((optimized || patchFlag > 0) && !(patchFlag & 16)) { + if (patchFlag & 8) { + const propsToUpdate = instance.vnode.dynamicProps; + for (let i = 0; i < propsToUpdate.length; i++) { + let key = propsToUpdate[i]; + const value = rawProps[key]; + if (options) { + if (hasOwn$1(attrs2, key)) { + if (value !== attrs2[key]) { + attrs2[key] = value; + hasAttrsChanged = true; + } + } else { + const camelizedKey = camelize(key); + props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false); + } + } else { + if (value !== attrs2[key]) { + attrs2[key] = value; + hasAttrsChanged = true; + } + } + } + } + } else { + if (setFullProps(instance, rawProps, props, attrs2)) { + hasAttrsChanged = true; + } + let kebabKey; + for (const key in rawCurrentProps) { + if (!rawProps || !hasOwn$1(rawProps, key) && ((kebabKey = hyphenate(key)) === key || !hasOwn$1(rawProps, kebabKey))) { + if (options) { + if (rawPrevProps && (rawPrevProps[key] !== void 0 || rawPrevProps[kebabKey] !== void 0)) { + props[key] = resolvePropValue(options, rawCurrentProps, key, void 0, instance, true); + } + } else { + delete props[key]; + } + } + } + if (attrs2 !== rawCurrentProps) { + for (const key in attrs2) { + if (!rawProps || !hasOwn$1(rawProps, key)) { + delete attrs2[key]; + hasAttrsChanged = true; + } + } + } + } + if (hasAttrsChanged) { + trigger(instance, "set", "$attrs"); + } + } + function setFullProps(instance, rawProps, props, attrs2) { + const [options, needCastKeys] = instance.propsOptions; + let hasAttrsChanged = false; + let rawCastValues; + if (rawProps) { + for (let key in rawProps) { + if (isReservedProp(key)) { + continue; + } + const value = rawProps[key]; + let camelKey; + if (options && hasOwn$1(options, camelKey = camelize(key))) { + if (!needCastKeys || !needCastKeys.includes(camelKey)) { + props[camelKey] = value; + } else { + (rawCastValues || (rawCastValues = {}))[camelKey] = value; + } + } else if (!isEmitListener(instance.emitsOptions, key)) { + if (value !== attrs2[key]) { + attrs2[key] = value; + hasAttrsChanged = true; + } + } + } + } + if (needCastKeys) { + const rawCurrentProps = toRaw(props); + const castValues = rawCastValues || EMPTY_OBJ; + for (let i = 0; i < needCastKeys.length; i++) { + const key = needCastKeys[i]; + props[key] = resolvePropValue(options, rawCurrentProps, key, castValues[key], instance, !hasOwn$1(castValues, key)); + } + } + return hasAttrsChanged; + } + function resolvePropValue(options, props, key, value, instance, isAbsent) { + const opt = options[key]; + if (opt != null) { + const hasDefault = hasOwn$1(opt, "default"); + if (hasDefault && value === void 0) { + const defaultValue = opt.default; + if (opt.type !== Function && isFunction(defaultValue)) { + const { propsDefaults } = instance; + if (key in propsDefaults) { + value = propsDefaults[key]; + } else { + setCurrentInstance(instance); + value = propsDefaults[key] = defaultValue.call(null, props); + setCurrentInstance(null); + } + } else { + value = defaultValue; + } + } + if (opt[0]) { + if (isAbsent && !hasDefault) { + value = false; + } else if (opt[1] && (value === "" || value === hyphenate(key))) { + value = true; + } + } + } + return value; + } + function normalizePropsOptions(comp, appContext, asMixin = false) { + const cache = appContext.propsCache; + const cached = cache.get(comp); + if (cached) { + return cached; + } + const raw = comp.props; + const normalized = {}; + const needCastKeys = []; + let hasExtends = false; + if (!isFunction(comp)) { + const extendProps = (raw2) => { + hasExtends = true; + const [props, keys] = normalizePropsOptions(raw2, appContext, true); + extend(normalized, props); + if (keys) + needCastKeys.push(...keys); + }; + if (!asMixin && appContext.mixins.length) { + appContext.mixins.forEach(extendProps); + } + if (comp.extends) { + extendProps(comp.extends); + } + if (comp.mixins) { + comp.mixins.forEach(extendProps); + } + } + if (!raw && !hasExtends) { + cache.set(comp, EMPTY_ARR); + return EMPTY_ARR; + } + if (isArray(raw)) { + for (let i = 0; i < raw.length; i++) { + const normalizedKey = camelize(raw[i]); + if (validatePropName(normalizedKey)) { + normalized[normalizedKey] = EMPTY_OBJ; + } + } + } else if (raw) { + for (const key in raw) { + const normalizedKey = camelize(key); + if (validatePropName(normalizedKey)) { + const opt = raw[key]; + const prop = normalized[normalizedKey] = isArray(opt) || isFunction(opt) ? { type: opt } : opt; + if (prop) { + const booleanIndex = getTypeIndex(Boolean, prop.type); + const stringIndex = getTypeIndex(String, prop.type); + prop[0] = booleanIndex > -1; + prop[1] = stringIndex < 0 || booleanIndex < stringIndex; + if (booleanIndex > -1 || hasOwn$1(prop, "default")) { + needCastKeys.push(normalizedKey); + } + } + } + } + } + const res = [normalized, needCastKeys]; + cache.set(comp, res); + return res; + } + function validatePropName(key) { + if (key[0] !== "$") { + return true; + } + return false; + } + function getType(ctor) { + const match = ctor && ctor.toString().match(/^\s*function (\w+)/); + return match ? match[1] : ""; + } + function isSameType(a, b) { + return getType(a) === getType(b); + } + function getTypeIndex(type, expectedTypes) { + if (isArray(expectedTypes)) { + return expectedTypes.findIndex((t) => isSameType(t, type)); + } else if (isFunction(expectedTypes)) { + return isSameType(expectedTypes, type) ? 0 : -1; + } + return -1; + } + const isInternalKey = (key) => key[0] === "_" || key === "$stable"; + const normalizeSlotValue = (value) => isArray(value) ? value.map(normalizeVNode) : [normalizeVNode(value)]; + const normalizeSlot = (key, rawSlot, ctx) => { + const normalized = withCtx((props) => { + return normalizeSlotValue(rawSlot(props)); + }, ctx); + normalized._c = false; + return normalized; + }; + const normalizeObjectSlots = (rawSlots, slots, instance) => { + const ctx = rawSlots._ctx; + for (const key in rawSlots) { + if (isInternalKey(key)) + continue; + const value = rawSlots[key]; + if (isFunction(value)) { + slots[key] = normalizeSlot(key, value, ctx); + } else if (value != null) { + const normalized = normalizeSlotValue(value); + slots[key] = () => normalized; + } + } + }; + const normalizeVNodeSlots = (instance, children) => { + const normalized = normalizeSlotValue(children); + instance.slots.default = () => normalized; + }; + const initSlots = (instance, children) => { + if (instance.vnode.shapeFlag & 32) { + const type = children._; + if (type) { + instance.slots = toRaw(children); + def(children, "_", type); + } else { + normalizeObjectSlots(children, instance.slots = {}); + } + } else { + instance.slots = {}; + if (children) { + normalizeVNodeSlots(instance, children); + } + } + def(instance.slots, InternalObjectKey, 1); + }; + const updateSlots = (instance, children, optimized) => { + const { vnode, slots } = instance; + let needDeletionCheck = true; + let deletionComparisonTarget = EMPTY_OBJ; + if (vnode.shapeFlag & 32) { + const type = children._; + if (type) { + if (optimized && type === 1) { + needDeletionCheck = false; + } else { + extend(slots, children); + if (!optimized && type === 1) { + delete slots._; + } + } + } else { + needDeletionCheck = !children.$stable; + normalizeObjectSlots(children, slots); + } + deletionComparisonTarget = children; + } else if (children) { + normalizeVNodeSlots(instance, children); + deletionComparisonTarget = { default: 1 }; + } + if (needDeletionCheck) { + for (const key in slots) { + if (!isInternalKey(key) && !(key in deletionComparisonTarget)) { + delete slots[key]; + } + } + } + }; + function invokeDirectiveHook(vnode, prevVNode, instance, name) { + const bindings = vnode.dirs; + const oldBindings = prevVNode && prevVNode.dirs; + for (let i = 0; i < bindings.length; i++) { + const binding = bindings[i]; + if (oldBindings) { + binding.oldValue = oldBindings[i].value; + } + let hook = binding.dir[name]; + if (hook) { + pauseTracking(); + callWithAsyncErrorHandling(hook, instance, 8, [ + vnode.el, + binding, + vnode, + prevVNode + ]); + resetTracking(); + } + } + } + function createAppContext() { + return { + app: null, + config: { + isNativeTag: NO, + performance: false, + globalProperties: {}, + optionMergeStrategies: {}, + errorHandler: void 0, + warnHandler: void 0, + compilerOptions: {} + }, + mixins: [], + components: {}, + directives: {}, + provides: Object.create(null), + optionsCache: new WeakMap(), + propsCache: new WeakMap(), + emitsCache: new WeakMap() + }; + } + let uid$1 = 0; + function createAppAPI(render, hydrate) { + return function createApp2(rootComponent, rootProps = null) { + if (rootProps != null && !isObject$1(rootProps)) { + rootProps = null; + } + const context = createAppContext(); + const installedPlugins = new Set(); + let isMounted = false; + const app = context.app = { + _uid: uid$1++, + _component: rootComponent, + _props: rootProps, + _container: null, + _context: context, + _instance: null, + version, + get config() { + return context.config; + }, + set config(v) { + }, + use(plugin, ...options) { + if (installedPlugins.has(plugin)) + ; + else if (plugin && isFunction(plugin.install)) { + installedPlugins.add(plugin); + plugin.install(app, ...options); + } else if (isFunction(plugin)) { + installedPlugins.add(plugin); + plugin(app, ...options); + } else + ; + return app; + }, + mixin(mixin) { + { + if (!context.mixins.includes(mixin)) { + context.mixins.push(mixin); + } + } + return app; + }, + component(name, component) { + if (!component) { + return context.components[name]; + } + context.components[name] = component; + return app; + }, + directive(name, directive) { + if (!directive) { + return context.directives[name]; + } + context.directives[name] = directive; + return app; + }, + mount(rootContainer, isHydrate, isSVG) { + if (!isMounted) { + const vnode = createVNode(rootComponent, rootProps); + vnode.appContext = context; + if (isHydrate && hydrate) { + hydrate(vnode, rootContainer); + } else { + render(vnode, rootContainer, isSVG); + } + isMounted = true; + app._container = rootContainer; + rootContainer.__vue_app__ = app; + return vnode.component.proxy; + } + }, + unmount() { + if (isMounted) { + render(null, app._container); + delete app._container.__vue_app__; + } + }, + provide(key, value) { + context.provides[key] = value; + return app; + } + }; + return app; + }; + } + const prodEffectOptions = { + scheduler: queueJob, + allowRecurse: true + }; + const queuePostRenderEffect = queueEffectWithSuspense; + const setRef = (rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) => { + if (isArray(rawRef)) { + rawRef.forEach((r, i) => setRef(r, oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef), parentSuspense, vnode, isUnmount)); + return; + } + if (isAsyncWrapper(vnode) && !isUnmount) { + return; + } + const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el; + const value = isUnmount ? null : refValue; + const { i: owner, r: ref2 } = rawRef; + const oldRef = oldRawRef && oldRawRef.r; + const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs; + const setupState = owner.setupState; + if (oldRef != null && oldRef !== ref2) { + if (isString(oldRef)) { + refs[oldRef] = null; + if (hasOwn$1(setupState, oldRef)) { + setupState[oldRef] = null; + } + } else if (isRef(oldRef)) { + oldRef.value = null; + } + } + if (isString(ref2)) { + const doSet = () => { + { + refs[ref2] = value; + } + if (hasOwn$1(setupState, ref2)) { + setupState[ref2] = value; + } + }; + if (value) { + doSet.id = -1; + queuePostRenderEffect(doSet, parentSuspense); + } else { + doSet(); + } + } else if (isRef(ref2)) { + const doSet = () => { + ref2.value = value; + }; + if (value) { + doSet.id = -1; + queuePostRenderEffect(doSet, parentSuspense); + } else { + doSet(); + } + } else if (isFunction(ref2)) { + callWithErrorHandling(ref2, owner, 12, [value, refs]); + } else + ; + }; + function createRenderer(options) { + return baseCreateRenderer(options); + } + function baseCreateRenderer(options, createHydrationFns) { + const { + insert: hostInsert, + remove: hostRemove, + patchProp: hostPatchProp, + forcePatchProp: hostForcePatchProp, + createElement: hostCreateElement, + createText: hostCreateText, + createComment: hostCreateComment, + setText: hostSetText, + setElementText: hostSetElementText, + parentNode: hostParentNode, + nextSibling: hostNextSibling, + setScopeId: hostSetScopeId = NOOP, + cloneNode: hostCloneNode, + insertStaticContent: hostInsertStaticContent + } = options; + const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = false) => { + if (n1 && !isSameVNodeType(n1, n2)) { + anchor = getNextHostNode(n1); + unmount(n1, parentComponent, parentSuspense, true); + n1 = null; + } + if (n2.patchFlag === -2) { + optimized = false; + n2.dynamicChildren = null; + } + const { type, ref: ref2, shapeFlag } = n2; + switch (type) { + case Text: + processText(n1, n2, container, anchor); + break; + case Comment$1: + processCommentNode(n1, n2, container, anchor); + break; + case Static: + if (n1 == null) { + mountStaticNode(n2, container, anchor, isSVG); + } + break; + case Fragment: + processFragment(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + break; + default: + if (shapeFlag & 1) { + processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else if (shapeFlag & 6) { + processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else if (shapeFlag & 64) { + type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); + } else if (shapeFlag & 128) { + type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals); + } else + ; + } + if (ref2 != null && parentComponent) { + setRef(ref2, n1 && n1.ref, parentSuspense, n2 || n1, !n2); + } + }; + const processText = (n1, n2, container, anchor) => { + if (n1 == null) { + hostInsert(n2.el = hostCreateText(n2.children), container, anchor); + } else { + const el = n2.el = n1.el; + if (n2.children !== n1.children) { + hostSetText(el, n2.children); + } + } + }; + const processCommentNode = (n1, n2, container, anchor) => { + if (n1 == null) { + hostInsert(n2.el = hostCreateComment(n2.children || ""), container, anchor); + } else { + n2.el = n1.el; + } + }; + const mountStaticNode = (n2, container, anchor, isSVG) => { + const nodes = hostInsertStaticContent(n2.children, container, anchor, isSVG, n2.staticCache); + if (!n2.el) { + n2.staticCache = nodes; + } + n2.el = nodes[0]; + n2.anchor = nodes[nodes.length - 1]; + }; + const moveStaticNode = ({ el, anchor }, container, nextSibling) => { + let next; + while (el && el !== anchor) { + next = hostNextSibling(el); + hostInsert(el, container, nextSibling); + el = next; + } + hostInsert(anchor, container, nextSibling); + }; + const removeStaticNode = ({ el, anchor }) => { + let next; + while (el && el !== anchor) { + next = hostNextSibling(el); + hostRemove(el); + el = next; + } + hostRemove(anchor); + }; + const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + isSVG = isSVG || n2.type === "svg"; + if (n1 == null) { + mountElement(n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else { + patchElement(n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } + }; + const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + let el; + let vnodeHook; + const { type, props, shapeFlag, transition, patchFlag, dirs } = vnode; + if (vnode.el && hostCloneNode !== void 0 && patchFlag === -1) { + el = vnode.el = hostCloneNode(vnode.el); + } else { + el = vnode.el = hostCreateElement(vnode.type, isSVG, props && props.is, props); + if (shapeFlag & 8) { + hostSetElementText(el, vnode.children); + } else if (shapeFlag & 16) { + mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== "foreignObject", slotScopeIds, optimized || !!vnode.dynamicChildren); + } + if (dirs) { + invokeDirectiveHook(vnode, null, parentComponent, "created"); + } + if (props) { + for (const key in props) { + if (!isReservedProp(key)) { + hostPatchProp(el, key, null, props[key], isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren); + } + } + if (vnodeHook = props.onVnodeBeforeMount) { + invokeVNodeHook(vnodeHook, parentComponent, vnode); + } + } + setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent); + } + if (dirs) { + invokeDirectiveHook(vnode, null, parentComponent, "beforeMount"); + } + const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted; + if (needCallTransitionHooks) { + transition.beforeEnter(el); + } + hostInsert(el, container, anchor); + if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) { + queuePostRenderEffect(() => { + vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode); + needCallTransitionHooks && transition.enter(el); + dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted"); + }, parentSuspense); + } + }; + const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => { + if (scopeId) { + hostSetScopeId(el, scopeId); + } + if (slotScopeIds) { + for (let i = 0; i < slotScopeIds.length; i++) { + hostSetScopeId(el, slotScopeIds[i]); + } + } + if (parentComponent) { + let subTree = parentComponent.subTree; + if (vnode === subTree) { + const parentVNode = parentComponent.vnode; + setScopeId(el, parentVNode, parentVNode.scopeId, parentVNode.slotScopeIds, parentComponent.parent); + } + } + }; + const mountChildren = (children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => { + for (let i = start; i < children.length; i++) { + const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]); + patch(null, child, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } + }; + const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + const el = n2.el = n1.el; + let { patchFlag, dynamicChildren, dirs } = n2; + patchFlag |= n1.patchFlag & 16; + const oldProps = n1.props || EMPTY_OBJ; + const newProps = n2.props || EMPTY_OBJ; + let vnodeHook; + if (vnodeHook = newProps.onVnodeBeforeUpdate) { + invokeVNodeHook(vnodeHook, parentComponent, n2, n1); + } + if (dirs) { + invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate"); + } + if (patchFlag > 0) { + if (patchFlag & 16) { + patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG); + } else { + if (patchFlag & 2) { + if (oldProps.class !== newProps.class) { + hostPatchProp(el, "class", null, newProps.class, isSVG); + } + } + if (patchFlag & 4) { + hostPatchProp(el, "style", oldProps.style, newProps.style, isSVG); + } + if (patchFlag & 8) { + const propsToUpdate = n2.dynamicProps; + for (let i = 0; i < propsToUpdate.length; i++) { + const key = propsToUpdate[i]; + const prev = oldProps[key]; + const next = newProps[key]; + if (next !== prev || hostForcePatchProp && hostForcePatchProp(el, key)) { + hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren); + } + } + } + } + if (patchFlag & 1) { + if (n1.children !== n2.children) { + hostSetElementText(el, n2.children); + } + } + } else if (!optimized && dynamicChildren == null) { + patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG); + } + const areChildrenSVG = isSVG && n2.type !== "foreignObject"; + if (dynamicChildren) { + patchBlockChildren(n1.dynamicChildren, dynamicChildren, el, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds); + } else if (!optimized) { + patchChildren(n1, n2, el, null, parentComponent, parentSuspense, areChildrenSVG, slotScopeIds, false); + } + if ((vnodeHook = newProps.onVnodeUpdated) || dirs) { + queuePostRenderEffect(() => { + vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1); + dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated"); + }, parentSuspense); + } + }; + const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => { + for (let i = 0; i < newChildren.length; i++) { + const oldVNode = oldChildren[i]; + const newVNode = newChildren[i]; + const container = oldVNode.el && (oldVNode.type === Fragment || !isSameVNodeType(oldVNode, newVNode) || oldVNode.shapeFlag & 6 || oldVNode.shapeFlag & 64) ? hostParentNode(oldVNode.el) : fallbackContainer; + patch(oldVNode, newVNode, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, true); + } + }; + const patchProps = (el, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => { + if (oldProps !== newProps) { + for (const key in newProps) { + if (isReservedProp(key)) + continue; + const next = newProps[key]; + const prev = oldProps[key]; + if (next !== prev || hostForcePatchProp && hostForcePatchProp(el, key)) { + hostPatchProp(el, key, prev, next, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren); + } + } + if (oldProps !== EMPTY_OBJ) { + for (const key in oldProps) { + if (!isReservedProp(key) && !(key in newProps)) { + hostPatchProp(el, key, oldProps[key], null, isSVG, vnode.children, parentComponent, parentSuspense, unmountChildren); + } + } + } + } + }; + const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText(""); + const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText(""); + let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2; + if (dynamicChildren) { + optimized = true; + } + if (fragmentSlotScopeIds) { + slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds; + } + if (n1 == null) { + hostInsert(fragmentStartAnchor, container, anchor); + hostInsert(fragmentEndAnchor, container, anchor); + mountChildren(n2.children, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else { + if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && n1.dynamicChildren) { + patchBlockChildren(n1.dynamicChildren, dynamicChildren, container, parentComponent, parentSuspense, isSVG, slotScopeIds); + if (n2.key != null || parentComponent && n2 === parentComponent.subTree) { + traverseStaticChildren(n1, n2, true); + } + } else { + patchChildren(n1, n2, container, fragmentEndAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } + } + }; + const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + n2.slotScopeIds = slotScopeIds; + if (n1 == null) { + if (n2.shapeFlag & 512) { + parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized); + } else { + mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized); + } + } else { + updateComponent(n1, n2, optimized); + } + }; + const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => { + const instance = initialVNode.component = createComponentInstance(initialVNode, parentComponent, parentSuspense); + if (isKeepAlive(initialVNode)) { + instance.ctx.renderer = internals; + } + { + setupComponent(instance); + } + if (instance.asyncDep) { + parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect); + if (!initialVNode.el) { + const placeholder = instance.subTree = createVNode(Comment$1); + processCommentNode(null, placeholder, container, anchor); + } + return; + } + setupRenderEffect(instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized); + }; + const updateComponent = (n1, n2, optimized) => { + const instance = n2.component = n1.component; + if (shouldUpdateComponent(n1, n2, optimized)) { + if (instance.asyncDep && !instance.asyncResolved) { + updateComponentPreRender(instance, n2, optimized); + return; + } else { + instance.next = n2; + invalidateJob(instance.update); + instance.update(); + } + } else { + n2.component = n1.component; + n2.el = n1.el; + instance.vnode = n2; + } + }; + const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => { + instance.update = effect(function componentEffect() { + if (!instance.isMounted) { + let vnodeHook; + const { el, props } = initialVNode; + const { bm, m, parent } = instance; + if (bm) { + invokeArrayFns(bm); + } + if (vnodeHook = props && props.onVnodeBeforeMount) { + invokeVNodeHook(vnodeHook, parent, initialVNode); + } + if (el && hydrateNode) { + const hydrateSubTree = () => { + instance.subTree = renderComponentRoot(instance); + hydrateNode(el, instance.subTree, instance, parentSuspense, null); + }; + if (isAsyncWrapper(initialVNode)) { + initialVNode.type.__asyncLoader().then(() => !instance.isUnmounted && hydrateSubTree()); + } else { + hydrateSubTree(); + } + } else { + const subTree = instance.subTree = renderComponentRoot(instance); + patch(null, subTree, container, anchor, instance, parentSuspense, isSVG); + initialVNode.el = subTree.el; + } + if (m) { + queuePostRenderEffect(m, parentSuspense); + } + if (vnodeHook = props && props.onVnodeMounted) { + const scopedInitialVNode = initialVNode; + queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode), parentSuspense); + } + if (initialVNode.shapeFlag & 256) { + instance.a && queuePostRenderEffect(instance.a, parentSuspense); + } + instance.isMounted = true; + initialVNode = container = anchor = null; + } else { + let { next, bu, u, parent, vnode } = instance; + let originNext = next; + let vnodeHook; + if (next) { + next.el = vnode.el; + updateComponentPreRender(instance, next, optimized); + } else { + next = vnode; + } + if (bu) { + invokeArrayFns(bu); + } + if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) { + invokeVNodeHook(vnodeHook, parent, next, vnode); + } + const nextTree = renderComponentRoot(instance); + const prevTree = instance.subTree; + instance.subTree = nextTree; + patch(prevTree, nextTree, hostParentNode(prevTree.el), getNextHostNode(prevTree), instance, parentSuspense, isSVG); + next.el = nextTree.el; + if (originNext === null) { + updateHOCHostEl(instance, nextTree.el); + } + if (u) { + queuePostRenderEffect(u, parentSuspense); + } + if (vnodeHook = next.props && next.props.onVnodeUpdated) { + queuePostRenderEffect(() => invokeVNodeHook(vnodeHook, parent, next, vnode), parentSuspense); + } + } + }, prodEffectOptions); + }; + const updateComponentPreRender = (instance, nextVNode, optimized) => { + nextVNode.component = instance; + const prevProps = instance.vnode.props; + instance.vnode = nextVNode; + instance.next = null; + updateProps(instance, nextVNode.props, prevProps, optimized); + updateSlots(instance, nextVNode.children, optimized); + pauseTracking(); + flushPreFlushCbs(void 0, instance.update); + resetTracking(); + }; + const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => { + const c1 = n1 && n1.children; + const prevShapeFlag = n1 ? n1.shapeFlag : 0; + const c2 = n2.children; + const { patchFlag, shapeFlag } = n2; + if (patchFlag > 0) { + if (patchFlag & 128) { + patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + return; + } else if (patchFlag & 256) { + patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + return; + } + } + if (shapeFlag & 8) { + if (prevShapeFlag & 16) { + unmountChildren(c1, parentComponent, parentSuspense); + } + if (c2 !== c1) { + hostSetElementText(container, c2); + } + } else { + if (prevShapeFlag & 16) { + if (shapeFlag & 16) { + patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else { + unmountChildren(c1, parentComponent, parentSuspense, true); + } + } else { + if (prevShapeFlag & 8) { + hostSetElementText(container, ""); + } + if (shapeFlag & 16) { + mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } + } + } + }; + const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + c1 = c1 || EMPTY_ARR; + c2 = c2 || EMPTY_ARR; + const oldLength = c1.length; + const newLength = c2.length; + const commonLength = Math.min(oldLength, newLength); + let i; + for (i = 0; i < commonLength; i++) { + const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); + patch(c1[i], nextChild, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } + if (oldLength > newLength) { + unmountChildren(c1, parentComponent, parentSuspense, true, false, commonLength); + } else { + mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, commonLength); + } + }; + const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => { + let i = 0; + const l2 = c2.length; + let e1 = c1.length - 1; + let e2 = l2 - 1; + while (i <= e1 && i <= e2) { + const n1 = c1[i]; + const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); + if (isSameVNodeType(n1, n2)) { + patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else { + break; + } + i++; + } + while (i <= e1 && i <= e2) { + const n1 = c1[e1]; + const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]); + if (isSameVNodeType(n1, n2)) { + patch(n1, n2, container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else { + break; + } + e1--; + e2--; + } + if (i > e1) { + if (i <= e2) { + const nextPos = e2 + 1; + const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor; + while (i <= e2) { + patch(null, c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]), container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + i++; + } + } + } else if (i > e2) { + while (i <= e1) { + unmount(c1[i], parentComponent, parentSuspense, true); + i++; + } + } else { + const s1 = i; + const s2 = i; + const keyToNewIndexMap = new Map(); + for (i = s2; i <= e2; i++) { + const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]); + if (nextChild.key != null) { + keyToNewIndexMap.set(nextChild.key, i); + } + } + let j; + let patched = 0; + const toBePatched = e2 - s2 + 1; + let moved = false; + let maxNewIndexSoFar = 0; + const newIndexToOldIndexMap = new Array(toBePatched); + for (i = 0; i < toBePatched; i++) + newIndexToOldIndexMap[i] = 0; + for (i = s1; i <= e1; i++) { + const prevChild = c1[i]; + if (patched >= toBePatched) { + unmount(prevChild, parentComponent, parentSuspense, true); + continue; + } + let newIndex; + if (prevChild.key != null) { + newIndex = keyToNewIndexMap.get(prevChild.key); + } else { + for (j = s2; j <= e2; j++) { + if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) { + newIndex = j; + break; + } + } + } + if (newIndex === void 0) { + unmount(prevChild, parentComponent, parentSuspense, true); + } else { + newIndexToOldIndexMap[newIndex - s2] = i + 1; + if (newIndex >= maxNewIndexSoFar) { + maxNewIndexSoFar = newIndex; + } else { + moved = true; + } + patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + patched++; + } + } + const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR; + j = increasingNewIndexSequence.length - 1; + for (i = toBePatched - 1; i >= 0; i--) { + const nextIndex = s2 + i; + const nextChild = c2[nextIndex]; + const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor; + if (newIndexToOldIndexMap[i] === 0) { + patch(null, nextChild, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized); + } else if (moved) { + if (j < 0 || i !== increasingNewIndexSequence[j]) { + move(nextChild, container, anchor, 2); + } else { + j--; + } + } + } + } + }; + const move = (vnode, container, anchor, moveType, parentSuspense = null) => { + const { el, type, transition, children, shapeFlag } = vnode; + if (shapeFlag & 6) { + move(vnode.component.subTree, container, anchor, moveType); + return; + } + if (shapeFlag & 128) { + vnode.suspense.move(container, anchor, moveType); + return; + } + if (shapeFlag & 64) { + type.move(vnode, container, anchor, internals); + return; + } + if (type === Fragment) { + hostInsert(el, container, anchor); + for (let i = 0; i < children.length; i++) { + move(children[i], container, anchor, moveType); + } + hostInsert(vnode.anchor, container, anchor); + return; + } + if (type === Static) { + moveStaticNode(vnode, container, anchor); + return; + } + const needTransition = moveType !== 2 && shapeFlag & 1 && transition; + if (needTransition) { + if (moveType === 0) { + transition.beforeEnter(el); + hostInsert(el, container, anchor); + queuePostRenderEffect(() => transition.enter(el), parentSuspense); + } else { + const { leave, delayLeave, afterLeave } = transition; + const remove3 = () => hostInsert(el, container, anchor); + const performLeave = () => { + leave(el, () => { + remove3(); + afterLeave && afterLeave(); + }); + }; + if (delayLeave) { + delayLeave(el, remove3, performLeave); + } else { + performLeave(); + } + } + } else { + hostInsert(el, container, anchor); + } + }; + const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => { + const { + type, + props, + ref: ref2, + children, + dynamicChildren, + shapeFlag, + patchFlag, + dirs + } = vnode; + if (ref2 != null) { + setRef(ref2, null, parentSuspense, vnode, true); + } + if (shapeFlag & 256) { + parentComponent.ctx.deactivate(vnode); + return; + } + const shouldInvokeDirs = shapeFlag & 1 && dirs; + let vnodeHook; + if (vnodeHook = props && props.onVnodeBeforeUnmount) { + invokeVNodeHook(vnodeHook, parentComponent, vnode); + } + if (shapeFlag & 6) { + unmountComponent(vnode.component, parentSuspense, doRemove); + } else { + if (shapeFlag & 128) { + vnode.suspense.unmount(parentSuspense, doRemove); + return; + } + if (shouldInvokeDirs) { + invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount"); + } + if (shapeFlag & 64) { + vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove); + } else if (dynamicChildren && (type !== Fragment || patchFlag > 0 && patchFlag & 64)) { + unmountChildren(dynamicChildren, parentComponent, parentSuspense, false, true); + } else if (type === Fragment && (patchFlag & 128 || patchFlag & 256) || !optimized && shapeFlag & 16) { + unmountChildren(children, parentComponent, parentSuspense); + } + if (doRemove) { + remove2(vnode); + } + } + if ((vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) { + queuePostRenderEffect(() => { + vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode); + shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted"); + }, parentSuspense); + } + }; + const remove2 = (vnode) => { + const { type, el, anchor, transition } = vnode; + if (type === Fragment) { + removeFragment(el, anchor); + return; + } + if (type === Static) { + removeStaticNode(vnode); + return; + } + const performRemove = () => { + hostRemove(el); + if (transition && !transition.persisted && transition.afterLeave) { + transition.afterLeave(); + } + }; + if (vnode.shapeFlag & 1 && transition && !transition.persisted) { + const { leave, delayLeave } = transition; + const performLeave = () => leave(el, performRemove); + if (delayLeave) { + delayLeave(vnode.el, performRemove, performLeave); + } else { + performLeave(); + } + } else { + performRemove(); + } + }; + const removeFragment = (cur, end) => { + let next; + while (cur !== end) { + next = hostNextSibling(cur); + hostRemove(cur); + cur = next; + } + hostRemove(end); + }; + const unmountComponent = (instance, parentSuspense, doRemove) => { + const { bum, effects, update, subTree, um } = instance; + if (bum) { + invokeArrayFns(bum); + } + if (effects) { + for (let i = 0; i < effects.length; i++) { + stop(effects[i]); + } + } + if (update) { + stop(update); + unmount(subTree, instance, parentSuspense, doRemove); + } + if (um) { + queuePostRenderEffect(um, parentSuspense); + } + queuePostRenderEffect(() => { + instance.isUnmounted = true; + }, parentSuspense); + if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) { + parentSuspense.deps--; + if (parentSuspense.deps === 0) { + parentSuspense.resolve(); + } + } + }; + const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => { + for (let i = start; i < children.length; i++) { + unmount(children[i], parentComponent, parentSuspense, doRemove, optimized); + } + }; + const getNextHostNode = (vnode) => { + if (vnode.shapeFlag & 6) { + return getNextHostNode(vnode.component.subTree); + } + if (vnode.shapeFlag & 128) { + return vnode.suspense.next(); + } + return hostNextSibling(vnode.anchor || vnode.el); + }; + const render = (vnode, container, isSVG) => { + if (vnode == null) { + if (container._vnode) { + unmount(container._vnode, null, null, true); + } + } else { + patch(container._vnode || null, vnode, container, null, null, null, isSVG); + } + flushPostFlushCbs(); + container._vnode = vnode; + }; + const internals = { + p: patch, + um: unmount, + m: move, + r: remove2, + mt: mountComponent, + mc: mountChildren, + pc: patchChildren, + pbc: patchBlockChildren, + n: getNextHostNode, + o: options + }; + let hydrate; + let hydrateNode; + if (createHydrationFns) { + [hydrate, hydrateNode] = createHydrationFns(internals); + } + return { + render, + hydrate, + createApp: createAppAPI(render, hydrate) + }; + } + function invokeVNodeHook(hook, instance, vnode, prevVNode = null) { + callWithAsyncErrorHandling(hook, instance, 7, [ + vnode, + prevVNode + ]); + } + function traverseStaticChildren(n1, n2, shallow = false) { + const ch1 = n1.children; + const ch2 = n2.children; + if (isArray(ch1) && isArray(ch2)) { + for (let i = 0; i < ch1.length; i++) { + const c1 = ch1[i]; + let c2 = ch2[i]; + if (c2.shapeFlag & 1 && !c2.dynamicChildren) { + if (c2.patchFlag <= 0 || c2.patchFlag === 32) { + c2 = ch2[i] = cloneIfMounted(ch2[i]); + c2.el = c1.el; + } + if (!shallow) + traverseStaticChildren(c1, c2); + } + } + } + } + function getSequence(arr) { + const p2 = arr.slice(); + const result = [0]; + let i, j, u, v, c; + const len = arr.length; + for (i = 0; i < len; i++) { + const arrI = arr[i]; + if (arrI !== 0) { + j = result[result.length - 1]; + if (arr[j] < arrI) { + p2[i] = j; + result.push(i); + continue; + } + u = 0; + v = result.length - 1; + while (u < v) { + c = (u + v) / 2 | 0; + if (arr[result[c]] < arrI) { + u = c + 1; + } else { + v = c; + } + } + if (arrI < arr[result[u]]) { + if (u > 0) { + p2[i] = result[u - 1]; + } + result[u] = i; + } + } + } + u = result.length; + v = result[u - 1]; + while (u-- > 0) { + result[u] = v; + v = p2[v]; + } + return result; + } + const isTeleport = (type) => type.__isTeleport; + const NULL_DYNAMIC_COMPONENT = Symbol(); + const Fragment = Symbol(void 0); + const Text = Symbol(void 0); + const Comment$1 = Symbol(void 0); + const Static = Symbol(void 0); + let currentBlock = null; + let isBlockTreeEnabled = 1; + function setBlockTracking(value) { + isBlockTreeEnabled += value; + } + function isVNode(value) { + return value ? value.__v_isVNode === true : false; + } + function isSameVNodeType(n1, n2) { + return n1.type === n2.type && n1.key === n2.key; + } + const InternalObjectKey = `__vInternal`; + const normalizeKey = ({ key }) => key != null ? key : null; + const normalizeRef = ({ ref: ref2 }) => { + return ref2 != null ? isString(ref2) || isRef(ref2) || isFunction(ref2) ? { i: currentRenderingInstance, r: ref2 } : ref2 : null; + }; + const createVNode = _createVNode; + function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) { + if (!type || type === NULL_DYNAMIC_COMPONENT) { + type = Comment$1; + } + if (isVNode(type)) { + const cloned = cloneVNode(type, props, true); + if (children) { + normalizeChildren(cloned, children); + } + return cloned; + } + if (isClassComponent(type)) { + type = type.__vccOpts; + } + if (props) { + if (isProxy(props) || InternalObjectKey in props) { + props = extend({}, props); + } + let { class: klass, style } = props; + if (klass && !isString(klass)) { + props.class = normalizeClass(klass); + } + if (isObject$1(style)) { + if (isProxy(style) && !isArray(style)) { + style = extend({}, style); + } + props.style = normalizeStyle(style); + } + } + const shapeFlag = isString(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject$1(type) ? 4 : isFunction(type) ? 2 : 0; + const vnode = { + __v_isVNode: true, + __v_skip: true, + type, + props, + key: props && normalizeKey(props), + ref: props && normalizeRef(props), + scopeId: currentScopeId, + slotScopeIds: null, + children: null, + component: null, + suspense: null, + ssContent: null, + ssFallback: null, + dirs: null, + transition: null, + el: null, + anchor: null, + target: null, + targetAnchor: null, + shapeFlag, + patchFlag, + dynamicProps, + dynamicChildren: null, + appContext: null + }; + normalizeChildren(vnode, children); + if (shapeFlag & 128) { + type.normalize(vnode); + } + if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock && (patchFlag > 0 || shapeFlag & 6) && patchFlag !== 32) { + currentBlock.push(vnode); + } + return vnode; + } + function cloneVNode(vnode, extraProps, mergeRef = false) { + const { props, ref: ref2, patchFlag, children } = vnode; + const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props; + const cloned = { + __v_isVNode: true, + __v_skip: true, + type: vnode.type, + props: mergedProps, + key: mergedProps && normalizeKey(mergedProps), + ref: extraProps && extraProps.ref ? mergeRef && ref2 ? isArray(ref2) ? ref2.concat(normalizeRef(extraProps)) : [ref2, normalizeRef(extraProps)] : normalizeRef(extraProps) : ref2, + scopeId: vnode.scopeId, + slotScopeIds: vnode.slotScopeIds, + children, + target: vnode.target, + targetAnchor: vnode.targetAnchor, + staticCount: vnode.staticCount, + staticCache: vnode.staticCache, + shapeFlag: vnode.shapeFlag, + patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag, + dynamicProps: vnode.dynamicProps, + dynamicChildren: vnode.dynamicChildren, + appContext: vnode.appContext, + dirs: vnode.dirs, + transition: vnode.transition, + component: vnode.component, + suspense: vnode.suspense, + ssContent: vnode.ssContent && cloneVNode(vnode.ssContent), + ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback), + el: vnode.el, + anchor: vnode.anchor + }; + return cloned; + } + function createTextVNode(text = " ", flag = 0) { + return createVNode(Text, null, text, flag); + } + function normalizeVNode(child) { + if (child == null || typeof child === "boolean") { + return createVNode(Comment$1); + } else if (isArray(child)) { + return createVNode(Fragment, null, child.slice()); + } else if (typeof child === "object") { + return cloneIfMounted(child); + } else { + return createVNode(Text, null, String(child)); + } + } + function cloneIfMounted(child) { + return child.el === null ? child : cloneVNode(child); + } + function normalizeChildren(vnode, children) { + let type = 0; + const { shapeFlag } = vnode; + if (children == null) { + children = null; + } else if (isArray(children)) { + type = 16; + } else if (typeof children === "object") { + if (shapeFlag & 1 || shapeFlag & 64) { + const slot = children.default; + if (slot) { + slot._c && (slot._d = false); + normalizeChildren(vnode, slot()); + slot._c && (slot._d = true); + } + return; + } else { + type = 32; + const slotFlag = children._; + if (!slotFlag && !(InternalObjectKey in children)) { + children._ctx = currentRenderingInstance; + } else if (slotFlag === 3 && currentRenderingInstance) { + if (currentRenderingInstance.slots._ === 1) { + children._ = 1; + } else { + children._ = 2; + vnode.patchFlag |= 1024; + } + } + } + } else if (isFunction(children)) { + children = { default: children, _ctx: currentRenderingInstance }; + type = 32; + } else { + children = String(children); + if (shapeFlag & 64) { + type = 16; + children = [createTextVNode(children)]; + } else { + type = 8; + } } - return raw; - } - function mergeAsArray(to, from) { - return to ? [...new Set([].concat(to, from))] : from; - } - function mergeObjectOptions(to, from) { - return to ? extend(extend(Object.create(null), to), from) : from; + vnode.children = children; + vnode.shapeFlag |= type; } - function mergeWatchOptions(to, from) { - if (!to) - return from; - if (!from) - return to; - const merged = extend(Object.create(null), to); - for (const key in from) { - merged[key] = mergeAsArray(to[key], from[key]); + function mergeProps(...args) { + const ret = extend({}, args[0]); + for (let i = 1; i < args.length; i++) { + const toMerge = args[i]; + for (const key in toMerge) { + if (key === "class") { + if (ret.class !== toMerge.class) { + ret.class = normalizeClass([ret.class, toMerge.class]); + } + } else if (key === "style") { + ret.style = normalizeStyle([ret.style, toMerge.style]); + } else if (isOn(key)) { + const existing = ret[key]; + const incoming = toMerge[key]; + if (existing !== incoming) { + ret[key] = existing ? [].concat(existing, incoming) : incoming; + } + } else if (key !== "") { + ret[key] = toMerge[key]; + } + } } - return merged; + return ret; } - const queuePostRenderEffect = queueEffectWithSuspense; const getPublicInstance = (i) => { if (!i) return null; @@ -1720,19 +4084,19 @@ case 2: return props[key]; } - } else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { + } else if (setupState !== EMPTY_OBJ && hasOwn$1(setupState, key)) { accessCache[key] = 0; return setupState[key]; - } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { + } else if (data !== EMPTY_OBJ && hasOwn$1(data, key)) { accessCache[key] = 1; return data[key]; - } else if ((normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)) { + } else if ((normalizedProps = instance.propsOptions[0]) && hasOwn$1(normalizedProps, key)) { accessCache[key] = 2; return props[key]; - } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { + } else if (ctx !== EMPTY_OBJ && hasOwn$1(ctx, key)) { accessCache[key] = 3; return ctx[key]; - } else { + } else if (shouldCacheAccess) { accessCache[key] = 4; } } @@ -1745,10 +4109,10 @@ return publicGetter(instance); } else if ((cssModule = type.__cssModules) && (cssModule = cssModule[key])) { return cssModule; - } else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) { + } else if (ctx !== EMPTY_OBJ && hasOwn$1(ctx, key)) { accessCache[key] = 3; return ctx[key]; - } else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) { + } else if (globalProperties = appContext.config.globalProperties, hasOwn$1(globalProperties, key)) { { return globalProperties[key]; } @@ -1757,11 +4121,11 @@ }, set({ _: instance }, key, value) { const { data, setupState, ctx } = instance; - if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) { + if (setupState !== EMPTY_OBJ && hasOwn$1(setupState, key)) { setupState[key] = value; - } else if (data !== EMPTY_OBJ && hasOwn(data, key)) { + } else if (data !== EMPTY_OBJ && hasOwn$1(data, key)) { data[key] = value; - } else if (hasOwn(instance.props, key)) { + } else if (hasOwn$1(instance.props, key)) { return false; } if (key[0] === "$" && key.slice(1) in instance) { @@ -1775,10 +4139,10 @@ }, has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) { let normalizedProps; - return accessCache[key] !== void 0 || data !== EMPTY_OBJ && hasOwn(data, key) || setupState !== EMPTY_OBJ && hasOwn(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key); + return accessCache[key] !== void 0 || data !== EMPTY_OBJ && hasOwn$1(data, key) || setupState !== EMPTY_OBJ && hasOwn$1(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn$1(normalizedProps, key) || hasOwn$1(ctx, key) || hasOwn$1(publicPropertiesMap, key) || hasOwn$1(appContext.config.globalProperties, key); } }; - extend({}, PublicInstanceProxyHandlers, { + const RuntimeCompiledPublicInstanceProxyHandlers = extend({}, PublicInstanceProxyHandlers, { get(target, key) { if (key === Symbol.unscopables) { return; @@ -1786,14 +4150,173 @@ return PublicInstanceProxyHandlers.get(target, key, target); }, has(_, key) { - const has = key[0] !== "_" && !isGloballyWhitelisted(key); - return has; + const has2 = key[0] !== "_" && !isGloballyWhitelisted(key); + return has2; } }); + const emptyAppContext = createAppContext(); + let uid$2 = 0; + function createComponentInstance(vnode, parent, suspense) { + const type = vnode.type; + const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext; + const instance = { + uid: uid$2++, + vnode, + type, + parent, + appContext, + root: null, + next: null, + subTree: null, + update: null, + render: null, + proxy: null, + exposed: null, + exposeProxy: null, + withProxy: null, + effects: null, + provides: parent ? parent.provides : Object.create(appContext.provides), + accessCache: null, + renderCache: [], + components: null, + directives: null, + propsOptions: normalizePropsOptions(type, appContext), + emitsOptions: normalizeEmitsOptions(type, appContext), + emit: null, + emitted: null, + propsDefaults: EMPTY_OBJ, + inheritAttrs: type.inheritAttrs, + ctx: EMPTY_OBJ, + data: EMPTY_OBJ, + props: EMPTY_OBJ, + attrs: EMPTY_OBJ, + slots: EMPTY_OBJ, + refs: EMPTY_OBJ, + setupState: EMPTY_OBJ, + setupContext: null, + suspense, + suspenseId: suspense ? suspense.pendingId : 0, + asyncDep: null, + asyncResolved: false, + isMounted: false, + isUnmounted: false, + isDeactivated: false, + bc: null, + c: null, + bm: null, + m: null, + bu: null, + u: null, + um: null, + bum: null, + da: null, + a: null, + rtg: null, + rtc: null, + ec: null, + sp: null + }; + { + instance.ctx = { _: instance }; + } + instance.root = parent ? parent.root : instance; + instance.emit = emit.bind(null, instance); + return instance; + } let currentInstance = null; + const setCurrentInstance = (instance) => { + currentInstance = instance; + }; function isStatefulComponent(instance) { return instance.vnode.shapeFlag & 4; } + let isInSSRComponentSetup = false; + function setupComponent(instance, isSSR = false) { + isInSSRComponentSetup = isSSR; + const { props, children } = instance.vnode; + const isStateful = isStatefulComponent(instance); + initProps(instance, props, isStateful, isSSR); + initSlots(instance, children); + const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0; + isInSSRComponentSetup = false; + return setupResult; + } + function setupStatefulComponent(instance, isSSR) { + const Component = instance.type; + instance.accessCache = Object.create(null); + instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers)); + const { setup } = Component; + if (setup) { + const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null; + currentInstance = instance; + pauseTracking(); + const setupResult = callWithErrorHandling(setup, instance, 0, [ + instance.props, + setupContext + ]); + resetTracking(); + currentInstance = null; + if (isPromise(setupResult)) { + const unsetInstance = () => { + currentInstance = null; + }; + setupResult.then(unsetInstance, unsetInstance); + if (isSSR) { + return setupResult.then((resolvedResult) => { + handleSetupResult(instance, resolvedResult); + }).catch((e) => { + handleError(e, instance, 0); + }); + } else { + instance.asyncDep = setupResult; + } + } else { + handleSetupResult(instance, setupResult); + } + } else { + finishComponentSetup(instance); + } + } + function handleSetupResult(instance, setupResult, isSSR) { + if (isFunction(setupResult)) { + { + instance.render = setupResult; + } + } else if (isObject$1(setupResult)) { + instance.setupState = proxyRefs(setupResult); + } else + ; + finishComponentSetup(instance); + } + function finishComponentSetup(instance, isSSR, skipOptions) { + const Component = instance.type; + if (!instance.render) { + instance.render = Component.render || NOOP; + if (instance.render._rc) { + instance.withProxy = new Proxy(instance.ctx, RuntimeCompiledPublicInstanceProxyHandlers); + } + } + { + currentInstance = instance; + pauseTracking(); + applyOptions(instance); + resetTracking(); + currentInstance = null; + } + } + function createSetupContext(instance) { + const expose = (exposed) => { + instance.exposed = exposed || {}; + }; + { + return { + attrs: instance.attrs, + slots: instance.slots, + emit: instance.emit, + expose + }; + } + } function getExposeProxy(instance) { if (instance.exposed) { return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), { @@ -1837,6 +4360,35 @@ } return name ? classify(name) : isRoot ? `App` : `Anonymous`; } + function isClassComponent(value) { + return isFunction(value) && "__vccOpts" in value; + } + function computed$1(getterOrOptions) { + const c = computed(getterOrOptions); + recordInstanceBoundEffect(c.effect); + return c; + } + function h(type, propsOrChildren, children) { + const l = arguments.length; + if (l === 2) { + if (isObject$1(propsOrChildren) && !isArray(propsOrChildren)) { + if (isVNode(propsOrChildren)) { + return createVNode(type, null, [propsOrChildren]); + } + return createVNode(type, propsOrChildren); + } else { + return createVNode(type, null, propsOrChildren); + } + } else { + if (l > 3) { + children = Array.prototype.slice.call(arguments, 2); + } else if (l === 3 && isVNode(children)) { + children = [children]; + } + return createVNode(type, propsOrChildren, children); + } + } + const version = "3.1.4"; const svgNS = "http://www.w3.org/2000/svg"; const doc = typeof document !== "undefined" ? document : null; const nodeOps = { @@ -2207,7 +4759,39 @@ return fn(event, ...args); }; }; - extend({ patchProp, forcePatchProp }, nodeOps); + const rendererOptions = extend({ patchProp, forcePatchProp }, nodeOps); + let renderer; + function ensureRenderer() { + return renderer || (renderer = createRenderer(rendererOptions)); + } + const createApp = (...args) => { + const app = ensureRenderer().createApp(...args); + const { mount } = app; + app.mount = (containerOrSelector) => { + const container = normalizeContainer(containerOrSelector); + if (!container) + return; + const component = app._component; + if (!isFunction(component) && !component.render && !component.template) { + component.template = container.innerHTML; + } + container.innerHTML = ""; + const proxy = mount(container, false, container instanceof SVGElement); + if (container instanceof Element) { + container.removeAttribute("v-cloak"); + container.setAttribute("data-v-app", ""); + } + return proxy; + }; + return app; + }; + function normalizeContainer(container) { + if (isString(container)) { + const res = document.querySelector(container); + return res; + } + return container; + } var attrs = ["top", "left", "right", "bottom"]; var inited; var elementComputedStyle = {}; @@ -2413,6 +4997,23 @@ style.setProperty(name, cssVars[name]); }); } + function PolySymbol(name) { + return Symbol("[uni-app]: " + name); + } + const ICON_PATH_CANCEL = "M20.928 10.176l-4.928 4.928-4.928-4.928-0.896 0.896 4.928 4.928-4.928 4.928 0.896 0.896 4.928-4.928 4.928 4.928 0.896-0.896-4.928-4.928 4.928-4.928-0.896-0.896zM16 2.080q-3.776 0-7.040 1.888-3.136 1.856-4.992 4.992-1.888 3.264-1.888 7.040t1.888 7.040q1.856 3.136 4.992 4.992 3.264 1.888 7.040 1.888t7.040-1.888q3.136-1.856 4.992-4.992 1.888-3.264 1.888-7.040t-1.888-7.040q-1.856-3.136-4.992-4.992-3.264-1.888-7.040-1.888zM16 28.64q-3.424 0-6.4-1.728-2.848-1.664-4.512-4.512-1.728-2.976-1.728-6.4t1.728-6.4q1.664-2.848 4.512-4.512 2.976-1.728 6.4-1.728t6.4 1.728q2.848 1.664 4.512 4.512 1.728 2.976 1.728 6.4t-1.728 6.4q-1.664 2.848-4.512 4.512-2.976 1.728-6.4 1.728z"; + const ICON_PATH_CLEAR = "M16 0q-4.352 0-8.064 2.176-3.616 2.144-5.76 5.76-2.176 3.712-2.176 8.064t2.176 8.064q2.144 3.616 5.76 5.76 3.712 2.176 8.064 2.176t8.064-2.176q3.616-2.144 5.76-5.76 2.176-3.712 2.176-8.064t-2.176-8.064q-2.144-3.616-5.76-5.76-3.712-2.176-8.064-2.176zM22.688 21.408q0.32 0.32 0.304 0.752t-0.336 0.736-0.752 0.304-0.752-0.32l-5.184-5.376-5.376 5.184q-0.32 0.32-0.752 0.304t-0.736-0.336-0.304-0.752 0.32-0.752l5.376-5.184-5.184-5.376q-0.32-0.32-0.304-0.752t0.336-0.752 0.752-0.304 0.752 0.336l5.184 5.376 5.376-5.184q0.32-0.32 0.752-0.304t0.752 0.336 0.304 0.752-0.336 0.752l-5.376 5.184 5.184 5.376z"; + const ICON_PATH_DOWNLOAD = "M15.808 1.696q-3.776 0-7.072 1.984-3.2 1.888-5.088 5.152-1.952 3.392-1.952 7.36 0 3.776 1.952 7.072 1.888 3.2 5.088 5.088 3.296 1.952 7.072 1.952 3.968 0 7.36-1.952 3.264-1.888 5.152-5.088 1.984-3.296 1.984-7.072 0-4-1.984-7.36-1.888-3.264-5.152-5.152-3.36-1.984-7.36-1.984zM20.864 18.592l-3.776 4.928q-0.448 0.576-1.088 0.576t-1.088-0.576l-3.776-4.928q-0.448-0.576-0.24-0.992t0.944-0.416h2.976v-8.928q0-0.256 0.176-0.432t0.4-0.176h1.216q0.224 0 0.4 0.176t0.176 0.432v8.928h2.976q0.736 0 0.944 0.416t-0.24 0.992z"; + const ICON_PATH_INFO = "M15.808 0.128q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.176 3.776-2.176 8.16 0 4.224 2.176 7.872 2.080 3.552 5.632 5.632 3.648 2.176 7.872 2.176 4.384 0 8.16-2.176 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.416-2.176-8.16-2.112-3.616-5.728-5.728-3.744-2.176-8.16-2.176zM16.864 23.776q0 0.064-0.064 0.064h-1.568q-0.096 0-0.096-0.064l-0.256-11.328q0-0.064 0.064-0.064h2.112q0.096 0 0.064 0.064l-0.256 11.328zM16 10.88q-0.576 0-0.976-0.4t-0.4-0.96 0.4-0.96 0.976-0.4 0.976 0.4 0.4 0.96-0.4 0.96-0.976 0.4z"; + const ICON_PATH_SEARCH = "M20.928 22.688q-1.696 1.376-3.744 2.112-2.112 0.768-4.384 0.768-3.488 0-6.464-1.728-2.88-1.696-4.576-4.608-1.76-2.976-1.76-6.464t1.76-6.464q1.696-2.88 4.576-4.576 2.976-1.76 6.464-1.76t6.464 1.76q2.912 1.696 4.608 4.576 1.728 2.976 1.728 6.464 0 2.272-0.768 4.384-0.736 2.048-2.112 3.744l9.312 9.28-1.824 1.824-9.28-9.312zM12.8 23.008q2.784 0 5.184-1.376 2.304-1.376 3.68-3.68 1.376-2.4 1.376-5.184t-1.376-5.152q-1.376-2.336-3.68-3.68-2.4-1.408-5.184-1.408t-5.152 1.408q-2.336 1.344-3.68 3.68-1.408 2.368-1.408 5.152t1.408 5.184q1.344 2.304 3.68 3.68 2.368 1.376 5.152 1.376zM12.8 23.008v0z"; + const ICON_PATH_SUCCESS_NO_CIRCLE = "M1.952 18.080q-0.32-0.352-0.416-0.88t0.128-0.976l0.16-0.352q0.224-0.416 0.64-0.528t0.8 0.176l6.496 4.704q0.384 0.288 0.912 0.272t0.88-0.336l17.312-14.272q0.352-0.288 0.848-0.256t0.848 0.352l-0.416-0.416q0.32 0.352 0.32 0.816t-0.32 0.816l-18.656 18.912q-0.32 0.352-0.8 0.352t-0.8-0.32l-7.936-8.064z"; + const ICON_PATH_SUCCESS = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM24.832 11.328l-11.264 11.104q-0.032 0.032-0.112 0.032t-0.112-0.032l-5.216-5.376q-0.096-0.128 0-0.288l0.704-0.96q0.032-0.064 0.112-0.064t0.112 0.032l4.256 3.264q0.064 0.032 0.144 0.032t0.112-0.032l10.336-8.608q0.064-0.064 0.144-0.064t0.112 0.064l0.672 0.672q0.128 0.128 0 0.224z"; + const ICON_PATH_WAITING = "M15.84 0.096q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM23.008 21.92l-0.512 0.896q-0.096 0.128-0.224 0.064l-8-3.808q-0.096-0.064-0.16-0.128-0.128-0.096-0.128-0.288l0.512-12.096q0-0.064 0.048-0.112t0.112-0.048h1.376q0.064 0 0.112 0.048t0.048 0.112l0.448 10.848 6.304 4.256q0.064 0.064 0.080 0.128t-0.016 0.128z"; + const ICON_PATH_WARN = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM15.136 8.672h1.728q0.128 0 0.224 0.096t0.096 0.256l-0.384 10.24q0 0.064-0.048 0.112t-0.112 0.048h-1.248q-0.096 0-0.144-0.048t-0.048-0.112l-0.384-10.24q0-0.16 0.096-0.256t0.224-0.096zM16 23.328q-0.48 0-0.832-0.352t-0.352-0.848 0.352-0.848 0.832-0.352 0.832 0.352 0.352 0.848-0.352 0.848-0.832 0.352z"; + function useCurrentPageId() { + { + return parseInt(window.__id__); + } + } function disableScrollListener(evt) { evt.preventDefault(); } @@ -2442,7 +5043,7 @@ } return false; }; - const trigger = () => { + const trigger2 = () => { onPageScroll && onPageScroll(window.pageYOffset); function testReachBottom() { if (isReachBottom()) { @@ -2466,13 +5067,12 @@ return function onScroll() { clearTimeout(testReachBottomTimer); if (!ticking) { - requestAnimationFrame(trigger); + requestAnimationFrame(trigger2); } ticking = true; }; } const isClickEvent = (val) => val.type === "click"; - const isMouseEvent = (val) => val.type.indexOf("mouse") === 0; function $nne(evt) { const { currentTarget } = evt; if (!(evt instanceof Event) || !(currentTarget instanceof HTMLElement)) { @@ -2484,8 +5084,6 @@ const res = createNativeEvent(evt); if (isClickEvent(evt)) { normalizeClickEvent(res, evt); - } else if (isMouseEvent(evt)) { - normalizeMouseEvent(res, evt); } else if (evt instanceof TouchEvent) { const { top } = getWindowOffset(); res.touches = normalizeTouchEvent(evt.touches, top); @@ -2515,16 +5113,6 @@ event.touches = evt.touches; event.changedTouches = evt.changedTouches; } - { - extend(event, { - preventDefault() { - return evt.preventDefault(); - }, - stopPropagation() { - return evt.stopPropagation(); - } - }); - } return event; } function normalizeClickEvent(evt, mouseEvt) { @@ -2533,13 +5121,6 @@ evt.detail = { x, y: y - top }; evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt)]; } - function normalizeMouseEvent(evt, mouseEvt) { - const { top } = getWindowOffset(); - evt.pageX = mouseEvt.pageX; - evt.pageY = mouseEvt.pageY - top; - evt.clientX = mouseEvt.clientX; - evt.clientY = mouseEvt.clientY - top; - } function createTouchEvent(evt) { return { force: 1, @@ -2601,7 +5182,7 @@ this.tag = tag; } init(nodeJson) { - if (hasOwn(nodeJson, "t")) { + if (hasOwn$1(nodeJson, "t")) { this.$.textContent = nodeJson.t || ""; } } @@ -2629,6 +5210,13 @@ this.$ = document.createComment(""); } } + class UniText extends UniNode { + constructor(id) { + super(id, "#text"); + this.$ = document.createTextNode(""); + } + } + var view = "uni-view {\n display: block;\n}\nuni-view[hidden] {\n display: none;\n}\n"; function patchClass(el, clazz) { el.className = clazz; } @@ -2728,15 +5316,15 @@ return modifiers; } class UniElement extends UniNode { - constructor(id, tag) { - super(id, tag); - this.$ = document.createElement(tag); + constructor(id, element) { + super(id, element.tagName); + this.$ = element; this.$.__id = id; this.$.__listeners = Object.create(null); } init(nodeJson) { super.init(nodeJson); - if (hasOwn(nodeJson, "a")) { + if (hasOwn$1(nodeJson, "a")) { this.setAttrs(nodeJson.a); } } @@ -2768,12 +5356,6 @@ } } } - class UniText extends UniNode { - constructor(id) { - super(id, "#text"); - this.$ = document.createTextNode(""); - } - } function isHoverAttr(name) { return name.indexOf(".h") === 0; } @@ -2897,23 +5479,552 @@ } class UniViewElement extends UniHoverElement { constructor(id) { - super(id, "uni-view"); + super(id, document.createElement("uni-view")); } } - const elements = new Map(); - const UniBuiltInComponents = [, UniViewElement, , , UniText, UniComment]; - function createUniComponent(type, id) { - return new UniBuiltInComponents[type](id); + var button = "uni-button {\n position: relative;\n display: block;\n margin-left: auto;\n margin-right: auto;\n padding-left: 14px;\n padding-right: 14px;\n box-sizing: border-box;\n font-size: 18px;\n text-align: center;\n text-decoration: none;\n line-height: 2.55555556;\n border-radius: 5px;\n -webkit-tap-highlight-color: transparent;\n overflow: hidden;\n color: #000000;\n background-color: #f8f8f8;\n cursor: pointer;\n}\n\nuni-button[hidden] {\n display: none !important;\n}\n\nuni-button:after {\n content: ' ';\n width: 200%;\n height: 200%;\n position: absolute;\n top: 0;\n left: 0;\n border: 1px solid rgba(0, 0, 0, 0.2);\n transform: scale(0.5);\n transform-origin: 0 0;\n box-sizing: border-box;\n border-radius: 10px;\n}\n\nuni-button[native] {\n padding-left: 0;\n padding-right: 0;\n}\n\nuni-button[native] .uni-button-cover-view-wrapper {\n border: inherit;\n border-color: inherit;\n border-radius: inherit;\n background-color: inherit;\n}\n\nuni-button[native] .uni-button-cover-view-inner {\n padding-left: 14px;\n padding-right: 14px;\n}\n\nuni-button uni-cover-view {\n line-height: inherit;\n white-space: inherit;\n}\n\nuni-button[type='default'] {\n color: #000000;\n background-color: #f8f8f8;\n}\n\nuni-button[type='primary'] {\n color: #ffffff;\n background-color: #007aff;\n}\n\nuni-button[type='warn'] {\n color: #ffffff;\n background-color: #e64340;\n}\n\nuni-button[disabled] {\n color: rgba(255, 255, 255, 0.6);\n cursor: not-allowed;\n}\n\nuni-button[disabled][type='default'],\nuni-button[disabled]:not([type]) {\n color: rgba(0, 0, 0, 0.3);\n background-color: #f7f7f7;\n}\n\nuni-button[disabled][type='primary'] {\n background-color: rgba(0, 122, 255, 0.6);\n}\n\nuni-button[disabled][type='warn'] {\n background-color: #ec8b89;\n}\n\nuni-button[type='primary'][plain] {\n color: #007aff;\n border: 1px solid #007aff;\n background-color: transparent;\n}\n\nuni-button[type='primary'][plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[type='primary'][plain]:after {\n border-width: 0;\n}\n\nuni-button[type='default'][plain] {\n color: #353535;\n border: 1px solid #353535;\n background-color: transparent;\n}\n\nuni-button[type='default'][plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[type='default'][plain]:after {\n border-width: 0;\n}\n\nuni-button[plain] {\n color: #353535;\n border: 1px solid #353535;\n background-color: transparent;\n}\n\nuni-button[plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[plain]:after {\n border-width: 0;\n}\n\nuni-button[plain][native] .uni-button-cover-view-inner {\n padding: 0;\n}\n\nuni-button[type='warn'][plain] {\n color: #e64340;\n border: 1px solid #e64340;\n background-color: transparent;\n}\n\nuni-button[type='warn'][plain][disabled] {\n color: rgba(0, 0, 0, 0.2);\n border-color: rgba(0, 0, 0, 0.2);\n}\n\nuni-button[type='warn'][plain]:after {\n border-width: 0;\n}\n\nuni-button[size='mini'] {\n display: inline-block;\n line-height: 2.3;\n font-size: 13px;\n padding: 0 1.34em;\n}\n\nuni-button[size='mini'][native] {\n padding: 0;\n}\n\nuni-button[size='mini'][native] .uni-button-cover-view-inner {\n padding: 0 1.34em;\n}\n\nuni-button[loading]:not([disabled]) {\n cursor: progress;\n}\n\nuni-button[loading]:before {\n content: ' ';\n display: inline-block;\n width: 18px;\n height: 18px;\n vertical-align: middle;\n animation: uni-loading 1s steps(12, end) infinite;\n background-size: 100%;\n}\n\nuni-button[loading][type='primary'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #0062cc;\n}\n\nuni-button[loading][type='primary'][plain] {\n color: #007aff;\n background-color: transparent;\n}\n\nuni-button[loading][type='default'] {\n color: rgba(0, 0, 0, 0.6);\n background-color: #dedede;\n}\n\nuni-button[loading][type='default'][plain] {\n color: #353535;\n background-color: transparent;\n}\n\nuni-button[loading][type='warn'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #ce3c39;\n}\n\nuni-button[loading][type='warn'][plain] {\n color: #e64340;\n background-color: transparent;\n}\n\nuni-button[loading][native]:before {\n content: none;\n}\n\n.button-hover {\n color: rgba(0, 0, 0, 0.6);\n background-color: #dedede;\n}\n\n.button-hover[plain] {\n color: rgba(53, 53, 53, 0.6);\n border-color: rgba(53, 53, 53, 0.6);\n background-color: transparent;\n}\n\n.button-hover[type='primary'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #0062cc;\n}\n\n.button-hover[type='primary'][plain] {\n color: rgba(26, 173, 25, 0.6);\n border-color: rgba(26, 173, 25, 0.6);\n background-color: transparent;\n}\n\n.button-hover[type='default'] {\n color: rgba(0, 0, 0, 0.6);\n background-color: #dedede;\n}\n\n.button-hover[type='default'][plain] {\n color: rgba(53, 53, 53, 0.6);\n border-color: rgba(53, 53, 53, 0.6);\n background-color: transparent;\n}\n\n.button-hover[type='warn'] {\n color: rgba(255, 255, 255, 0.6);\n background-color: #ce3c39;\n}\n\n.button-hover[type='warn'][plain] {\n color: rgba(230, 67, 64, 0.6);\n border-color: rgba(230, 67, 64, 0.6);\n background-color: transparent;\n}\n"; + function converPx(value) { + if (/^-?\d+[ur]px$/i.test(value)) { + return value.replace(/(^-?\d+)[ur]px$/i, (text, num) => { + return `${uni.upx2px(parseFloat(num))}px`; + }); + } else if (/^-?[\d\.]+$/.test(value)) { + return `${value}px`; + } + return value || ""; + } + function converType(type) { + return type.replace(/[A-Z]/g, (text) => { + return `-${text.toLowerCase()}`; + }).replace("webkit", "-webkit"); + } + function getStyle(action) { + const animateTypes1 = [ + "matrix", + "matrix3d", + "scale", + "scale3d", + "rotate3d", + "skew", + "translate", + "translate3d" + ]; + const animateTypes2 = [ + "scaleX", + "scaleY", + "scaleZ", + "rotate", + "rotateX", + "rotateY", + "rotateZ", + "skewX", + "skewY", + "translateX", + "translateY", + "translateZ" + ]; + const animateTypes3 = ["opacity", "background-color"]; + const animateTypes4 = ["width", "height", "left", "right", "top", "bottom"]; + const animates = action.animates; + const option = action.option; + const transition = option.transition; + const style = {}; + const transform = []; + animates.forEach((animate) => { + let type = animate.type; + let args = [...animate.args]; + if (animateTypes1.concat(animateTypes2).includes(type)) { + if (type.startsWith("rotate") || type.startsWith("skew")) { + args = args.map((value) => parseFloat(value) + "deg"); + } else if (type.startsWith("translate")) { + args = args.map(converPx); + } + if (animateTypes2.indexOf(type) >= 0) { + args.length = 1; + } + transform.push(`${type}(${args.join(",")})`); + } else if (animateTypes3.concat(animateTypes4).includes(args[0])) { + type = args[0]; + const value = args[1]; + style[type] = animateTypes4.includes(type) ? converPx(value) : value; + } + }); + style.transform = style.webkitTransform = transform.join(" "); + style.transition = style.webkitTransition = Object.keys(style).map((type) => `${converType(type)} ${transition.duration}ms ${transition.timingFunction} ${transition.delay}ms`).join(","); + style.transformOrigin = style.webkitTransformOrigin = option.transformOrigin; + return style; + } + function startAnimation(context) { + const animation2 = context.animation; + if (!animation2 || !animation2.actions || !animation2.actions.length) { + return; + } + let index = 0; + const actions = animation2.actions; + const length = animation2.actions.length; + function animate() { + const action = actions[index]; + const transition = action.option.transition; + const style = getStyle(action); + Object.keys(style).forEach((key) => { + context.$el.style[key] = style[key]; + }); + index += 1; + if (index < length) { + setTimeout(animate, transition.duration + transition.delay); + } + } + setTimeout(() => { + animate(); + }, 0); + } + var animation = { + props: ["animation"], + watch: { + animation: { + deep: true, + handler() { + startAnimation(this); + } + } + }, + mounted() { + startAnimation(this); + } + }; + const defineBuiltInComponent = (options) => { + const { props, mixins } = options; + if (!props || !props.animation) { + (mixins || (options.mixins = [])).push(animation); + } + return defineSystemComponent(options); + }; + const defineSystemComponent = (options) => { + options.compatConfig = { + MODE: 3 + }; + return defineComponent(options); + }; + const hoverProps = { + hoverClass: { + type: String, + default: "none" + }, + hoverStopPropagation: { + type: Boolean, + default: false + }, + hoverStartTime: { + type: [Number, String], + default: 50 + }, + hoverStayTime: { + type: [Number, String], + default: 400 + } + }; + function useHover(props) { + const hovering = ref(false); + let hoverTouch = false; + let hoverStartTimer; + let hoverStayTimer; + function hoverReset() { + requestAnimationFrame(() => { + clearTimeout(hoverStayTimer); + hoverStayTimer = setTimeout(() => { + hovering.value = false; + }, parseInt(props.hoverStayTime)); + }); + } + function onTouchstartPassive(evt) { + if (evt._hoverPropagationStopped) { + return; + } + if (!props.hoverClass || props.hoverClass === "none" || props.disabled) { + return; + } + if (evt.touches.length > 1) { + return; + } + if (props.hoverStopPropagation) { + evt._hoverPropagationStopped = true; + } + hoverTouch = true; + hoverStartTimer = setTimeout(() => { + hovering.value = true; + if (!hoverTouch) { + hoverReset(); + } + }, parseInt(props.hoverStartTime)); + } + function onTouchend() { + hoverTouch = false; + if (hovering.value) { + hoverReset(); + } + } + function onTouchcancel() { + hoverTouch = false; + hovering.value = false; + clearTimeout(hoverStartTimer); + } + return { + hovering, + binding: { + onTouchstartPassive, + onTouchend, + onTouchcancel + } + }; + } + function useBooleanAttr(props, keys) { + if (isString(keys)) { + keys = [keys]; + } + return keys.reduce((res, key) => { + if (props[key]) { + res[key] = true; + } + return res; + }, Object.create(null)); + } + function withWebEvent(fn) { + return fn.__wwe = true, fn; + } + const uniFormKey = PolySymbol("uniForm"); + const uniLabelKey = PolySymbol("uniLabel"); + function useListeners(props, listeners) { + _addListeners(props.id, listeners); + watch(() => props.id, (newId, oldId) => { + _removeListeners(oldId, listeners, true); + _addListeners(newId, listeners, true); + }); + onUnmounted(() => { + _removeListeners(props.id, listeners); + }); + } + function _addListeners(id, listeners, watch2) { + const pageId2 = useCurrentPageId(); + if (watch2 && !id) { + return; + } + if (!isPlainObject(listeners)) { + return; + } + Object.keys(listeners).forEach((name) => { + if (watch2) { + if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) { + UniViewJSBridge.on(`uni-${name}-${pageId2}-${id}`, listeners[name]); + } + } else { + if (name.indexOf("uni-") === 0) { + UniViewJSBridge.on(name, listeners[name]); + } else if (id) { + UniViewJSBridge.on(`uni-${name}-${pageId2}-${id}`, listeners[name]); + } + } + }); + } + function _removeListeners(id, listeners, watch2) { + const pageId2 = useCurrentPageId(); + if (watch2 && !id) { + return; + } + if (!isPlainObject(listeners)) { + return; + } + Object.keys(listeners).forEach((name) => { + if (watch2) { + if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) { + UniViewJSBridge.off(`uni-${name}-${pageId2}-${id}`, listeners[name]); + } + } else { + if (name.indexOf("uni-") === 0) { + UniViewJSBridge.off(name, listeners[name]); + } else if (id) { + UniViewJSBridge.off(`uni-${name}-${pageId2}-${id}`, listeners[name]); + } + } + }); + } + var Button = /* @__PURE__ */ defineBuiltInComponent({ + name: "Button", + props: { + id: { + type: String, + default: "" + }, + hoverClass: { + type: String, + default: "button-hover" + }, + hoverStartTime: { + type: [Number, String], + default: 20 + }, + hoverStayTime: { + type: [Number, String], + default: 70 + }, + hoverStopPropagation: { + type: Boolean, + default: false + }, + disabled: { + type: [Boolean, String], + default: false + }, + formType: { + type: String, + default: "" + }, + openType: { + type: String, + default: "" + }, + loading: { + type: [Boolean, String], + default: false + } + }, + setup(props, { + slots + }) { + const rootRef = ref(null); + { + initI18nButtonMsgsOnce(); + } + const uniForm = inject(uniFormKey, false); + const { + hovering, + binding + } = useHover(props); + const { + t + } = useI18n(); + const onClick = withWebEvent((e, isLabelClick) => { + if (props.disabled) { + return e.stopImmediatePropagation(); + } + if (isLabelClick) { + rootRef.value.click(); + } + const formType = props.formType; + if (formType) { + if (!uniForm) { + return; + } + if (formType === "submit") { + uniForm.submit(); + } else if (formType === "reset") { + uniForm.reset(); + } + return; + } + if (props.openType === "feedback") { + openFeedback(t("uni.button.feedback.title"), t("uni.button.feedback.send")); + } + }); + const uniLabel = inject(uniLabelKey, false); + if (uniLabel) { + uniLabel.addHandler(onClick); + onBeforeUnmount(() => { + uniLabel.removeHandler(onClick); + }); + } + useListeners(props, { + "label-click": onClick + }); + return () => { + const hoverClass = props.hoverClass; + const booleanAttrs = useBooleanAttr(props, "disabled"); + const loadingAttrs = useBooleanAttr(props, "loading"); + const hasHoverClass = hoverClass && hoverClass !== "none"; + return createVNode("uni-button", mergeProps({ + "ref": rootRef, + "onClick": onClick, + "class": hasHoverClass && hovering.value ? hoverClass : "" + }, hasHoverClass && binding, booleanAttrs, loadingAttrs), { + default: () => [slots.default && slots.default()] + }, 16, ["onClick", "class"]); + }; + } + }); + function openFeedback(titleText, sendText) { + const feedback = plus.webview.create("https://service.dcloud.net.cn/uniapp/feedback.html", "feedback", { + titleNView: { + titleText, + autoBackButton: true, + backgroundColor: "#F7F7F7", + titleColor: "#007aff", + buttons: [{ + text: sendText, + color: "#007aff", + fontSize: "16px", + fontWeight: "bold", + onclick: function() { + feedback.evalJS('typeof mui !== "undefined" && mui.trigger(document.getElementById("submit"),"tap")'); + } + }] + } + }); + feedback.show("slide-in-right"); + } + { + plusReady(() => { + plus.os.name === "Android"; + plus.os.version || ""; + }); + document.addEventListener("keyboardchange", function(event) { + }, false); + } + const INFO_COLOR = "#10aeff"; + const WARN_COLOR = "#f76260"; + const GREY_COLOR = "#b2b2b2"; + const CANCEL_COLOR = "#f43530"; + ({ + success: { + d: ICON_PATH_SUCCESS, + c: PRIMARY_COLOR + }, + success_no_circle: { + d: ICON_PATH_SUCCESS_NO_CIRCLE, + c: PRIMARY_COLOR + }, + info: { + d: ICON_PATH_INFO, + c: INFO_COLOR + }, + warn: { + d: ICON_PATH_WARN, + c: WARN_COLOR + }, + waiting: { + d: ICON_PATH_WAITING, + c: INFO_COLOR + }, + cancel: { + d: ICON_PATH_CANCEL, + c: CANCEL_COLOR + }, + download: { + d: ICON_PATH_DOWNLOAD, + c: PRIMARY_COLOR + }, + search: { + d: ICON_PATH_SEARCH, + c: GREY_COLOR + }, + clear: { + d: ICON_PATH_CLEAR, + c: GREY_COLOR + } + }); + ({ + activeColor: PRIMARY_COLOR, + backgroundColor: "#EBEBEB", + activeMode: "backwards" + }); + /* @__PURE__ */ defineBuiltInComponent({ + name: "View", + props: extend({}, hoverProps), + setup(props, { + slots + }) { + const { + hovering, + binding + } = useHover(props); + return () => { + const hoverClass = props.hoverClass; + if (hoverClass && hoverClass !== "none") { + return createVNode("uni-view", mergeProps({ + "class": hovering.value ? hoverClass : "" + }, binding), { + default: () => [slots.default && slots.default()] + }, 16, ["class"]); + } + return createVNode("uni-view", null, { + default: () => [slots.default && slots.default()] + }); + }; + } + }); + const UniButton = createWrapper(Button); + class UniButtonElement extends UniNode { + constructor(id) { + super(id, "uni-button"); + } + init(nodeJson) { + const container = document.createElement("div"); + this.$props = reactive({}); + const { a } = nodeJson; + if (a) { + Object.keys(a).forEach((n) => { + this.setAttr(n, a[n]); + }); + } + const vm = createApp(UniButton, { attrs: this.$props }).mount(container); + this.$ = container.firstElementChild; + if (hasOwn$1(nodeJson, "t")) { + this.$.textContent = nodeJson.t || ""; + } + watch(this.$props, () => { + { + console.log(formatLog(this.tag, "props", "forceUpdate")); + } + vm.$forceUpdate(); + }); + } + setAttr(name, value) { + const decoded = decodeAttr(name); + if (name.indexOf(".e") === 0) { + this.$props[decoded] = createInvoker(this.id, value, parseEventName(decoded)[1]); + } else { + this.$props[decoded] = value; + } + } + removeAttr(name) { + this.$props[decodeAttr(name)] = null; + } } + const BuiltInComponents = [ + , + UniViewElement, + , + , + UniText, + UniComment, + , + , + UniButtonElement + ]; + function createBuiltInComponent(type, id) { + return new BuiltInComponents[type](id); + } + function createWrapper(component) { + return defineComponent({ + props: ["attrs"], + data() { + return { + props: this.attrs + }; + }, + render() { + return h(component, this.props); + } + }); + } + const elements = new Map(); function $(id) { return elements.get(id); } function createElement(id, tag) { let element; if (isString(tag)) { - element = new UniElement(id, tag); + element = new UniElement(id, document.createElement(tag)); } else { - element = createUniComponent(tag, id); + element = createBuiltInComponent(tag, id); } elements.set(id, element); return element; diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index 5e41ff102..94ed3d617 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -17,9 +17,7 @@ "url": "https://github.com/dcloudio/uni-app/issues" }, "dependencies": { - "@webcomponents/custom-elements": "^1.4.3", - "vue": "^3.1.4", - "vue3-webcomponent-wrapper": "^0.1.4" + "vue": "^3.1.4" }, "gitHead": "56deaeb47d42e924d10282d7af418ccee6b139bf" } diff --git a/packages/uni-app-plus/src/view/components/index.ts b/packages/uni-app-plus/src/view/components/index.ts deleted file mode 100644 index 5bef70215..000000000 --- a/packages/uni-app-plus/src/view/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './view' diff --git a/packages/uni-app-plus/src/view/components/view.ts b/packages/uni-app-plus/src/view/components/view.ts deleted file mode 100644 index 2a2d7a6a3..000000000 --- a/packages/uni-app-plus/src/view/components/view.ts +++ /dev/null @@ -1,4 +0,0 @@ -import '@dcloudio/uni-components/style/view.css' -export function View() { - return document.createElement('uni-view') -} diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts index 8c0507a46..3910d8d70 100644 --- a/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts +++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts @@ -2,16 +2,16 @@ import { hasOwn } from '@vue/shared' import { decodeAttr, UniNodeJSON } from '@dcloudio/uni-shared' import { UniNode } from './UniNode' -import { UniCustomElement } from './utils' import { patchClass } from './modules/class' import { patchStyle } from './modules/style' import { patchEvent } from './modules/events' +import { UniCustomElement } from './components' export class UniElement extends UniNode { $: UniCustomElement - constructor(id: number, tag: string) { - super(id, tag) - this.$ = document.createElement(tag) as unknown as UniCustomElement + constructor(id: number, element: Element) { + super(id, element.tagName) + this.$ = element as UniCustomElement this.$.__id = id this.$.__listeners = Object.create(null) } diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts index 3ac622f81..e31ad36e3 100644 --- a/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts +++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts @@ -1,7 +1,7 @@ import { hasOwn } from '@vue/shared' import { UniNodeJSON } from '@dcloudio/uni-shared' -import { $ } from './utils' +import { $ } from '.' export class UniNode { id: number diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniViewElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniViewElement.ts index f8190b303..90cbfbf06 100644 --- a/packages/uni-app-plus/src/view/framework/dom/elements/UniViewElement.ts +++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniViewElement.ts @@ -1,6 +1,7 @@ +import '@dcloudio/uni-components/style/view.css' import { UniHoverElement } from './UniHoverElement' export class UniViewElement extends UniHoverElement { constructor(id: number) { - super(id, 'uni-view') + super(id, document.createElement('uni-view')) } } diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/components/UniButtonElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/components/UniButtonElement.ts new file mode 100644 index 000000000..2624e2ff6 --- /dev/null +++ b/packages/uni-app-plus/src/view/framework/dom/elements/components/UniButtonElement.ts @@ -0,0 +1,58 @@ +import '@dcloudio/uni-components/style/button.css' +import { hasOwn } from '@vue/shared' +import { Button } from '@dcloudio/uni-components' +import { createApp, reactive, watch } from 'vue' +import { createWrapper } from '.' +import { + decodeAttr, + formatLog, + parseEventName, + UniNodeJSON, +} from '@dcloudio/uni-shared' +import { UniNode } from '../UniNode' +import { createInvoker } from '../modules/events' + +const UniButton = createWrapper(Button) + +export class UniButtonElement extends UniNode { + private $props!: Record + constructor(id: number) { + super(id, 'uni-button') + } + init(nodeJson: Partial) { + const container = document.createElement('div') + this.$props = reactive({}) + const { a } = nodeJson + if (a) { + Object.keys(a).forEach((n) => { + this.setAttr(n, a[n]) + }) + } + const vm = createApp(UniButton, { attrs: this.$props }).mount(container) + this.$ = container.firstElementChild! + if (hasOwn(nodeJson, 't')) { + this.$.textContent = nodeJson.t || '' + } + watch(this.$props, () => { + if (__DEV__) { + console.log(formatLog(this.tag, 'props', 'forceUpdate')) + } + vm.$forceUpdate() + }) + } + setAttr(name: string, value: unknown) { + const decoded = decodeAttr(name) + if (name.indexOf('.e') === 0) { + this.$props[decoded] = createInvoker( + this.id, + value as number, + parseEventName(decoded)[1] + ) + } else { + this.$props[decoded] = value + } + } + removeAttr(name: string) { + this.$props[decodeAttr(name)] = null + } +} diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/components/index.ts b/packages/uni-app-plus/src/view/framework/dom/elements/components/index.ts new file mode 100644 index 000000000..b075f4ccf --- /dev/null +++ b/packages/uni-app-plus/src/view/framework/dom/elements/components/index.ts @@ -0,0 +1,40 @@ +import { defineComponent, h, reactive } from 'vue' +import { UniComment } from '../UniComment' +import { UniText } from '../UniText' +import { UniViewElement } from '../UniViewElement' +import { UniButtonElement } from './UniButtonElement' + +export interface UniCustomElement extends Element { + __id: number + __listeners: Record void> +} + +const BuiltInComponents = [ + , + UniViewElement, + , + , + UniText, + UniComment, + , + , + UniButtonElement, +] + +export function createBuiltInComponent(type: number, id: number) { + return new BuiltInComponents[type]!(id) +} + +export function createWrapper(component: ReturnType) { + return defineComponent({ + props: ['attrs'], + data() { + return { + props: this.attrs, + } + }, + render() { + return h(component, this.props) + }, + }) +} diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/index.ts b/packages/uni-app-plus/src/view/framework/dom/elements/index.ts index 9c56149ef..8789a8d17 100644 --- a/packages/uni-app-plus/src/view/framework/dom/elements/index.ts +++ b/packages/uni-app-plus/src/view/framework/dom/elements/index.ts @@ -1 +1,22 @@ -export * from './utils' +import { isString } from '@vue/shared' +import { createBuiltInComponent } from './components' + +import { UniElement } from './UniElement' +import { UniText } from './UniText' + +const elements = new Map() + +export function $(id: number) { + return elements.get(id) as UniElement +} + +export function createElement(id: number, tag: string | number) { + let element: UniElement | UniText + if (isString(tag)) { + element = new UniElement(id, document.createElement(tag)) + } else { + element = createBuiltInComponent(tag, id) + } + elements.set(id, element) + return element +} diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/modules/events.ts b/packages/uni-app-plus/src/view/framework/dom/elements/modules/events.ts index b62217a07..c9653f109 100644 --- a/packages/uni-app-plus/src/view/framework/dom/elements/modules/events.ts +++ b/packages/uni-app-plus/src/view/framework/dom/elements/modules/events.ts @@ -9,7 +9,7 @@ import { } from '@dcloudio/uni-shared' import { VD_SYNC } from '../../../../../constants' import { ACTION_TYPE_EVENT } from '../../../../../PageAction' -import { UniCustomElement } from '../utils' +import { UniCustomElement } from '../components' export function patchEvent(el: UniCustomElement, name: string, flag: number) { const [type, options] = parseEventName(decodeAttr(name)) @@ -43,7 +43,7 @@ export function patchEvent(el: UniCustomElement, name: string, flag: number) { } } -function createInvoker( +export function createInvoker( id: number, flag: number, options?: AddEventListenerOptions diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/utils.ts b/packages/uni-app-plus/src/view/framework/dom/elements/utils.ts deleted file mode 100644 index b57038519..000000000 --- a/packages/uni-app-plus/src/view/framework/dom/elements/utils.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { isString } from '@vue/shared' -import { UniComment } from './UniComment' -import { UniElement } from './UniElement' -import { UniText } from './UniText' -import { UniViewElement } from './UniViewElement' - -export interface UniCustomElement extends Element { - __id: number - __listeners: Record void> -} -const elements = new Map() - -const UniBuiltInComponents = [, UniViewElement, , , UniText, UniComment] - -function createUniComponent(type: number, id: number) { - return new UniBuiltInComponents[type]!(id) -} - -export function $(id: number) { - return elements.get(id) as UniElement -} - -export function createElement(id: number, tag: string | number) { - let element: UniElement | UniText - if (isString(tag)) { - element = new UniElement(id, tag) - } else { - element = createUniComponent(tag, id) - } - elements.set(id, element) - return element -} diff --git a/packages/uni-app-plus/src/view/index.ts b/packages/uni-app-plus/src/view/index.ts index 30c430e9b..033c3f131 100644 --- a/packages/uni-app-plus/src/view/index.ts +++ b/packages/uni-app-plus/src/view/index.ts @@ -1,3 +1,17 @@ -import '@webcomponents/custom-elements' -import './components' -import './ready' +import '../../style/framework/base.css' +import '@dcloudio/uni-h5/style/framework/nvue.css' + +import { ON_WEBVIEW_READY } from '../constants' +import { UniViewJSBridge } from './bridge' +import { initView } from './framework' +;(window as any).UniViewJSBridge = UniViewJSBridge + +function onWebviewReady() { + initView() + UniViewJSBridge.publishHandler(ON_WEBVIEW_READY) +} +if (typeof plus !== 'undefined') { + onWebviewReady() +} else { + document.addEventListener('plusready', onWebviewReady) +} diff --git a/packages/uni-app-plus/src/view/ready.ts b/packages/uni-app-plus/src/view/ready.ts deleted file mode 100644 index 9de9fc395..000000000 --- a/packages/uni-app-plus/src/view/ready.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ON_WEBVIEW_READY } from '../constants' -import { UniViewJSBridge } from './bridge' -import { initView } from './framework' -;(window as any).UniViewJSBridge = UniViewJSBridge - -function onWebviewReady() { - initView() - UniViewJSBridge.publishHandler(ON_WEBVIEW_READY) -} -if (typeof plus !== 'undefined') { - onWebviewReady() -} else { - document.addEventListener('plusready', onWebviewReady) -} diff --git a/packages/uni-app-plus/style/framework/base.css b/packages/uni-app-plus/style/framework/base.css new file mode 100644 index 000000000..c7855532f --- /dev/null +++ b/packages/uni-app-plus/style/framework/base.css @@ -0,0 +1,54 @@ +* { + margin: 0; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); + -webkit-tap-highlight-color: transparent; +} + +html, +body { + -webkit-user-select: none; + user-select: none; + width: 100%; +} + +html { + height: 100%; + height: 100vh; + width: 100%; + width: 100vw; +} + +body { + overflow-x: hidden; + background-color: white; +} + +input[type='search']::-webkit-search-cancel-button { + display: none; +} + +.uni-loading, +uni-button[loading]:before { + background: transparent + url('data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=') + no-repeat; +} + +.uni-loading { + width: 20px; + height: 20px; + display: inline-block; + vertical-align: middle; + animation: uni-loading 1s steps(12, end) infinite; + background-size: 100%; +} + +@keyframes uni-loading { + 0% { + transform: rotate3d(0, 0, 1, 0deg); + } + + 100% { + transform: rotate3d(0, 0, 1, 360deg); + } +} diff --git a/packages/uni-app-plus/vite.config.ts b/packages/uni-app-plus/vite.config.ts index 2d4df01cf..3888caa2c 100644 --- a/packages/uni-app-plus/vite.config.ts +++ b/packages/uni-app-plus/vite.config.ts @@ -42,8 +42,13 @@ export default defineConfig({ global: 'window', __DEV__: true, __TEST__: false, - __PLATFORM__: JSON.stringify('h5'), + __PLATFORM__: JSON.stringify('app'), __NODE_JS__: false, + __UNI_FEATURE_I18N_EN__: true, + __UNI_FEATURE_I18N_ES__: true, + __UNI_FEATURE_I18N_FR__: true, + __UNI_FEATURE_I18N_ZH_HANS__: true, + __UNI_FEATURE_I18N_ZH_HANT__: true, }, resolve: { alias: [ @@ -77,6 +82,15 @@ export default defineConfig({ }, ], }, + css: { + postcss: { + plugins: [ + require('autoprefixer')({ + overrideBrowserslist: ['Android > 4.4', 'iOS >= 10'], + }), + ], + }, + }, plugins: [ vue({ template: { diff --git a/packages/uni-app-vue/dist/service.runtime.esm.js b/packages/uni-app-vue/dist/service.runtime.esm.js index 6ebf5d80a..e5e9efdac 100644 --- a/packages/uni-app-vue/dist/service.runtime.esm.js +++ b/packages/uni-app-vue/dist/service.runtime.esm.js @@ -416,15 +416,18 @@ export default function vueFactory(exports) { 'hover-stop-propagation': '.h1', 'hover-start-time': '.h2', 'hover-stay-time': '.h3' - }; - var ATTR_MAP = /*#__PURE__*/extend$1(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce(function (res, name) { - var value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach(function (v, i) { - res[name + v] = value + i; - }); - return res; - }, Object.create(null))); + }; // 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend + + var ATTR_MAP = /*#__PURE__*/function () { + return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce(function (res, name) { + var value = EVENT_MAP[name]; + res[name] = value; + OPTIONS.forEach(function (v, i) { + res[name + v] = value + i; + }); + return res; + }, Object.create(null))); + }(); function encodeAttr(name) { return ATTR_MAP[name] || name; diff --git a/packages/uni-app/dist/uni-app.cjs.js b/packages/uni-app/dist/uni-app.cjs.js index 7a13a26a1..ccde10325 100644 --- a/packages/uni-app/dist/uni-app.cjs.js +++ b/packages/uni-app/dist/uni-app.cjs.js @@ -5,48 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); var shared = require('@vue/shared'); -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ shared.extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val; const UNI_SSR = '__uniSSR'; const UNI_SSR_DATA = 'data'; diff --git a/packages/uni-app/dist/uni-app.es.js b/packages/uni-app/dist/uni-app.es.js index 3f4b821b8..6fa0c73a2 100644 --- a/packages/uni-app/dist/uni-app.es.js +++ b/packages/uni-app/dist/uni-app.es.js @@ -1,48 +1,6 @@ import { shallowRef, ref, getCurrentInstance, isInSSRComponentSetup, injectHook } from 'vue'; -import { extend, hasOwn, isString } from '@vue/shared'; +import { hasOwn, isString } from '@vue/shared'; -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val; const UNI_SSR = '__uniSSR'; const UNI_SSR_DATA = 'data'; diff --git a/packages/uni-core/src/helpers/page.ts b/packages/uni-core/src/helpers/page.ts index 4947bd8e9..7d51d1267 100644 --- a/packages/uni-core/src/helpers/page.ts +++ b/packages/uni-core/src/helpers/page.ts @@ -3,6 +3,10 @@ import { ComponentPublicInstance, getCurrentInstance } from 'vue' import { rpx2px } from './util' export function useCurrentPageId() { + if (__PLATFORM__ === 'app') { + // view 层 + return parseInt((window as any).__id__) + } return getCurrentInstance()!.root.proxy!.$page.id } diff --git a/packages/uni-mp-alipay/dist/uni.mp.esm.js b/packages/uni-mp-alipay/dist/uni.mp.esm.js index 3f6153c0f..c578e8dcc 100644 --- a/packages/uni-mp-alipay/dist/uni.mp.esm.js +++ b/packages/uni-mp-alipay/dist/uni.mp.esm.js @@ -234,49 +234,7 @@ function stringifyQuery(obj, encodeStr = encode) { .join('&') : null; return res ? `?${res}` : ''; -} -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +} function initVueIds(vueIds, mpInstance) { if (!vueIds) { diff --git a/packages/uni-mp-baidu/dist/uni.mp.esm.js b/packages/uni-mp-baidu/dist/uni.mp.esm.js index 43eb593d6..a8fae7a46 100644 --- a/packages/uni-mp-baidu/dist/uni.mp.esm.js +++ b/packages/uni-mp-baidu/dist/uni.mp.esm.js @@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) { .join('&') : null; return res ? `?${res}` : ''; -} -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +} function initBehavior(options) { return Behavior(options); diff --git a/packages/uni-mp-qq/dist/uni.mp.esm.js b/packages/uni-mp-qq/dist/uni.mp.esm.js index 3bd442641..d80257163 100644 --- a/packages/uni-mp-qq/dist/uni.mp.esm.js +++ b/packages/uni-mp-qq/dist/uni.mp.esm.js @@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) { .join('&') : null; return res ? `?${res}` : ''; -} -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +} function initBehavior(options) { return Behavior(options); diff --git a/packages/uni-mp-toutiao/dist/uni.mp.esm.js b/packages/uni-mp-toutiao/dist/uni.mp.esm.js index 4b87bfe66..05522d926 100644 --- a/packages/uni-mp-toutiao/dist/uni.mp.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.mp.esm.js @@ -228,49 +228,7 @@ function stringifyQuery(obj, encodeStr = encode) { .join('&') : null; return res ? `?${res}` : ''; -} -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +} function initBehavior(options) { return Behavior(options); diff --git a/packages/uni-mp-vue/dist/vue.runtime.esm.js b/packages/uni-mp-vue/dist/vue.runtime.esm.js index 6c1d2c33b..776cd613c 100644 --- a/packages/uni-mp-vue/dist/vue.runtime.esm.js +++ b/packages/uni-mp-vue/dist/vue.runtime.esm.js @@ -1,4 +1,4 @@ -import { isFunction, extend, isSymbol, isMap, isObject, toRawType, def, isArray, isString, isPromise, toHandlerKey, remove, EMPTY_OBJ, camelize, capitalize, normalizeClass, normalizeStyle, isOn, NOOP, isGloballyWhitelisted, isIntegerKey, hasOwn, hasChanged, invokeArrayFns as invokeArrayFns$1, makeMap, isSet, NO, toNumber, hyphenate, isReservedProp, EMPTY_ARR, toTypeString } from '@vue/shared'; +import { isFunction, isSymbol, extend, isMap, isObject, toRawType, def, isArray, isString, isPromise, toHandlerKey, remove, EMPTY_OBJ, camelize, capitalize, normalizeClass, normalizeStyle, isOn, NOOP, isGloballyWhitelisted, isIntegerKey, hasOwn, hasChanged, invokeArrayFns as invokeArrayFns$1, makeMap, isSet, NO, toNumber, hyphenate, isReservedProp, EMPTY_ARR, toTypeString } from '@vue/shared'; export { camelize } from '@vue/shared'; import { injectHook as injectHook$1 } from 'vue'; @@ -13,48 +13,6 @@ function applyOptions$1(options, instance, publicThis) { }); } -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); const invokeArrayFns = (fns, arg) => { let ret; for (let i = 0; i < fns.length; i++) { diff --git a/packages/uni-mp-weixin/dist/uni.mp.esm.js b/packages/uni-mp-weixin/dist/uni.mp.esm.js index 3bd442641..d80257163 100644 --- a/packages/uni-mp-weixin/dist/uni.mp.esm.js +++ b/packages/uni-mp-weixin/dist/uni.mp.esm.js @@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) { .join('&') : null; return res ? `?${res}` : ''; -} -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +} function initBehavior(options) { return Behavior(options); diff --git a/packages/uni-quickapp-webview/dist/uni.mp.esm.js b/packages/uni-quickapp-webview/dist/uni.mp.esm.js index 0dc11d832..279da0573 100644 --- a/packages/uni-quickapp-webview/dist/uni.mp.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.mp.esm.js @@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) { .join('&') : null; return res ? `?${res}` : ''; -} -const EVENT_MAP = { - onClick: '.e0', - onChange: '.e1', - onInput: '.e2', - onLoad: '.e3', - onError: '.e4', - onTouchstart: '.e5', - onTouchmove: '.e6', - onTouchcancel: '.e7', - onTouchend: '.e8', - onLongpress: '.e9', - onTransitionend: '.ea', - onAnimationstart: '.eb', - onAnimationiteration: '.ec', - onAnimationend: '.ed', - onTouchforcechange: '.ee', -}; -const OPTIONS = [ - 'Capture', - 'CaptureOnce', - 'CapturePassive', - 'CaptureOncePassive', - 'Once', - 'OncePassive', - 'Passive', -]; -const BASE_ATTR_MAP = { - class: '.c', - style: '.s', - 'hover-class': '.h0', - 'hover-stop-propagation': '.h1', - 'hover-start-time': '.h2', - 'hover-stay-time': '.h3', -}; -/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +} function initBehavior(options) { return Behavior(options); diff --git a/packages/uni-shared/dist/uni-shared.cjs.js b/packages/uni-shared/dist/uni-shared.cjs.js index 4f06a8a51..bfcff4eb5 100644 --- a/packages/uni-shared/dist/uni-shared.cjs.js +++ b/packages/uni-shared/dist/uni-shared.cjs.js @@ -554,14 +554,17 @@ const BASE_ATTR_MAP = { 'hover-start-time': '.h2', 'hover-stay-time': '.h3', }; -const ATTR_MAP = /*#__PURE__*/ shared.extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +// 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend +const ATTR_MAP = /*#__PURE__*/ (() => { + return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { + const value = EVENT_MAP[name]; + res[name] = value; + OPTIONS.forEach((v, i) => { + res[name + v] = value + i; + }); + return res; + }, Object.create(null))); +})(); function encodeAttr(name) { return ATTR_MAP[name] || name; } diff --git a/packages/uni-shared/dist/uni-shared.es.js b/packages/uni-shared/dist/uni-shared.es.js index c8c88fa7c..75d35c036 100644 --- a/packages/uni-shared/dist/uni-shared.es.js +++ b/packages/uni-shared/dist/uni-shared.es.js @@ -550,14 +550,17 @@ const BASE_ATTR_MAP = { 'hover-start-time': '.h2', 'hover-stay-time': '.h3', }; -const ATTR_MAP = /*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name]; - res[name] = value; - OPTIONS.forEach((v, i) => { - res[name + v] = value + i; - }); - return res; -}, Object.create(null))); +// 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend +const ATTR_MAP = /*#__PURE__*/ (() => { + return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => { + const value = EVENT_MAP[name]; + res[name] = value; + OPTIONS.forEach((v, i) => { + res[name + v] = value + i; + }); + return res; + }, Object.create(null))); +})(); function encodeAttr(name) { return ATTR_MAP[name] || name; } diff --git a/packages/uni-shared/src/vdom/encode.ts b/packages/uni-shared/src/vdom/encode.ts index add1ec1a8..00b67bfa0 100644 --- a/packages/uni-shared/src/vdom/encode.ts +++ b/packages/uni-shared/src/vdom/encode.ts @@ -1,5 +1,3 @@ -import { extend } from '@vue/shared' - export const EventOptionFlags = { capture: 1, once: 1 << 1, @@ -79,17 +77,20 @@ const BASE_ATTR_MAP = { 'hover-stay-time': '.h3', } -export const ATTR_MAP = /*#__PURE__*/ extend( - BASE_ATTR_MAP, - Object.keys(EVENT_MAP).reduce((res, name) => { - const value = EVENT_MAP[name as keyof typeof EVENT_MAP] - res[name] = value - OPTIONS.forEach((v, i) => { - res[name + v] = value + i - }) - return res - }, Object.create(null)) -) +// 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend +export const ATTR_MAP = /*#__PURE__*/ (() => { + return Object.assign( + BASE_ATTR_MAP, + Object.keys(EVENT_MAP).reduce((res, name) => { + const value = EVENT_MAP[name as keyof typeof EVENT_MAP] + res[name] = value + OPTIONS.forEach((v, i) => { + res[name + v] = value + i + }) + return res + }, Object.create(null)) + ) +})() export function encodeAttr(name: string) { return ATTR_MAP[name as keyof typeof ATTR_MAP] || name diff --git a/packages/vite-plugin-uni/src/vue/options.ts b/packages/vite-plugin-uni/src/vue/options.ts index eebe2c429..31ed55d1e 100644 --- a/packages/vite-plugin-uni/src/vue/options.ts +++ b/packages/vite-plugin-uni/src/vue/options.ts @@ -110,6 +110,8 @@ export function initPluginVueOptions( directiveTransforms ) } + // App,MP 平台不支持使用静态节点 + compilerOptions.hoistStatic = false return vueOptions } -- GitLab