diff --git a/packages/global.d.ts b/packages/global.d.ts index c2faac561809b5caf197cb941358c75be545b612..01d82e52290035b7eaa24d8707b6d09b77407318 100644 --- a/packages/global.d.ts +++ b/packages/global.d.ts @@ -22,6 +22,7 @@ declare var __UNI_FEATURE_ROUTER_MODE__: 'hash' | 'history' declare var __UNI_FEATURE_PAGES__: boolean declare var __UNI_FEATURE_TABBAR__: boolean +declare var __UNI_FEATURE_TABBAR_MIDBUTTON__: boolean declare var __UNI_FEATURE_TOPWINDOW__: boolean declare var __UNI_FEATURE_LEFTWINDOW__: boolean declare var __UNI_FEATURE_RIGHTWINDOW__: boolean diff --git a/packages/shims-uni-app.d.ts b/packages/shims-uni-app.d.ts index 38cbcb15ee77975f6ef92d03f036f547524108e8..36be880fcd7f3f0c4b18525434588f20969b26bc 100644 --- a/packages/shims-uni-app.d.ts +++ b/packages/shims-uni-app.d.ts @@ -40,6 +40,7 @@ declare namespace UniApp { request: number uploadFile: number } + tabBar?: TabBarOptions } interface UniRoute { @@ -162,14 +163,51 @@ declare namespace UniApp { subpackages?: PagesJsonSubpackagesOptions[] subPackages?: PagesJsonSubpackagesOptions[] globalStyle: PagesJsonPageStyle - tabBar?: { - list: [] - } + tabBar?: TabBarOptions topWindow?: PagesJsonWindowOptions leftWindow?: PagesJsonWindowOptions rightWindow?: PagesJsonWindowOptions } + interface TabBarItemBaseOptions { + pagePath: string + text: string + iconPath?: string + selectedIconPath?: string + redDot?: boolean + badge?: string + } + + interface TabBarNormalItemOptions extends TabBarItemBaseOptions { + type: 'normal' + } + interface TabBarMidButtonOptions extends TabBarItemBaseOptions { + type: 'midButton' + width?: string + height?: string + iconWidth?: string + backgroundImage?: string + } + + type TabBarItemOptions = TabBarNormalItemOptions | TabBarMidButtonOptions + + interface TabBarOptions { + position?: 'bottom' | 'top' + color: string + selectedColor: string + backgroundColor: string + borderStyle?: 'black' | 'white' + list: TabBarItemOptions[] + blurEffect?: 'none' | 'dark' | 'extralight' | 'light' + fontSize?: string + iconWidth?: string + spacing?: string + height?: string + midButton?: TabBarMidButtonOptions + selectedIndex?: number + shown: boolean + } + type OnApiLike = (callback: (result: unknown) => void) => void interface UniServiceJSBridge { /** @@ -206,7 +244,7 @@ declare namespace UniApp { */ invokeOnCallback( name: string, - res: Parameters[0]>[0] + res?: Parameters[0]>[0] ): void /** * 订阅 View 的自定义事件,回调函数会接收所有传入事件触发函数的额外参数。 diff --git a/packages/uni-api/src/helpers/api/index.ts b/packages/uni-api/src/helpers/api/index.ts index 2074eb1aa6132f70e1b9a8a8bee6a6992cfb3711..6fb01ad71424cff91b5e84c58d3f0227b9291bae 100644 --- a/packages/uni-api/src/helpers/api/index.ts +++ b/packages/uni-api/src/helpers/api/index.ts @@ -1,4 +1,4 @@ -import { extend, isPlainObject } from '@vue/shared' +import { extend, isString, isPlainObject } from '@vue/shared' import { ApiOptions, ApiProtocols } from '../../protocols/type' import { API_TYPE_ON_PROTOCOLS, validateProtocols } from '../protocol' import { @@ -130,7 +130,13 @@ function wrapperApi( return function (...args: any[]) { if (__DEV__) { const errMsg = validateProtocols(name!, args, protocol) - if (errMsg) { + if (isString(errMsg)) { + return errMsg + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args) + if (isString(errMsg)) { return errMsg } } diff --git a/packages/uni-api/src/helpers/protocol.ts b/packages/uni-api/src/helpers/protocol.ts index 6041e5cb8dc305e8dabdefa4043d7f7f9ae7a376..cbc9f3408130864cf75196055e5f75e1d12a0a16 100644 --- a/packages/uni-api/src/helpers/protocol.ts +++ b/packages/uni-api/src/helpers/protocol.ts @@ -2,6 +2,7 @@ import { hasOwn, makeMap, isArray, + isString, isObject, toRawType, capitalize, @@ -69,7 +70,7 @@ function validateProtocol( protocol[key], !hasOwn(data, key) ) - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg) } } @@ -133,10 +134,8 @@ function validateProp( } } // custom validator - if (validator && !validator(value)) { - return ( - 'Invalid args: custom validator check failed for args "' + name + '".' - ) + if (validator) { + return validator(value) } } diff --git a/packages/uni-api/src/helpers/utils.ts b/packages/uni-api/src/helpers/utils.ts deleted file mode 100644 index d5b995c348d6fe9b14bf40b12f89cf979d1aa2fe..0000000000000000000000000000000000000000 --- a/packages/uni-api/src/helpers/utils.ts +++ /dev/null @@ -1,6 +0,0 @@ -export function getCurrentPageVm() { - const pages = getCurrentPages() - const len = pages.length - const page = pages[len - 1] - return page && (page as any).$vm -} diff --git a/packages/uni-api/src/index.ts b/packages/uni-api/src/index.ts index 563aa167af2235ca609578707287a8c18c0f410f..11acb9af40c1abb86cf99359007f0cf04288951e 100644 --- a/packages/uni-api/src/index.ts +++ b/packages/uni-api/src/index.ts @@ -6,6 +6,7 @@ export * from './service/context/createVideoContext' export * from './service/ui/createIntersectionObserver' export * from './service/ui/createSelectorQuery' +export * from './service/ui/tabBar' // protocols export * from './protocols/base/canIUse' @@ -27,6 +28,7 @@ export * from './protocols/network/request' export * from './protocols/route/route' +export * from './protocols/ui/tabBar' // helpers export { defineOnApi, @@ -36,8 +38,6 @@ export { defineAsyncApi, } from './helpers/api' -export { getCurrentPageVm } from './helpers/utils' - export { handlePromise } from './helpers/api/promise' export { invokeApi, wrapperReturnValue } from './helpers/interceptor' export { requestComponentObserver } from './helpers/requestComponentObserver' diff --git a/packages/uni-api/src/protocols/type.ts b/packages/uni-api/src/protocols/type.ts index 57a8345d4d85f7e35f25982b3f90b2392d791ff9..fcd3adedb83293ed37c5989d85402b92ddd1b5ad 100644 --- a/packages/uni-api/src/protocols/type.ts +++ b/packages/uni-api/src/protocols/type.ts @@ -10,17 +10,18 @@ type ProtocolMethod = T extends (...args: any) => any : never type ProtocolType = ProtocolConstructor | ProtocolConstructor[] -type Validator = (value: any, params: Record) => void +type ApiArgsValidator = (value: any, params: Record) => void export interface ApiProtocol { [name: string]: ProtocolOptions } export type ApiProtocols = ApiProtocol | ProtocolOptions[] export interface ApiOptions { + beforeInvoke?: (args: unknown) => boolean | void | string beforeAll?: (res: unknown) => void beforeSuccess?: (res: unknown) => void formatArgs?: { - [name: string]: Validator + [name: string]: ApiArgsValidator } } diff --git a/packages/uni-api/src/protocols/ui/tab-bar.js b/packages/uni-api/src/protocols/ui/tab-bar.js deleted file mode 100644 index 998753c266ca42158ab42710d5d3f0944e50708b..0000000000000000000000000000000000000000 --- a/packages/uni-api/src/protocols/ui/tab-bar.js +++ /dev/null @@ -1,96 +0,0 @@ -import { getLen } from 'uni-shared' -import getRealPath from 'uni-platform/helpers/get-real-path' - -const indexValidator = { - type: Number, - required: true -} - -export const setTabBarItem = { - index: indexValidator, - text: { - type: String - }, - iconPath: { - type: String - }, - selectedIconPath: { - type: String - }, - pagePath: { - type: String - } -} - -export const setTabBarStyle = { - color: { - type: String - }, - selectedColor: { - type: String - }, - backgroundColor: { - type: String - }, - backgroundImage: { - type: String, - validator(backgroundImage, params) { - if ( - backgroundImage && - !/^(linear|radial)-gradient\(.+?\);?$/.test(backgroundImage) - ) { - params.backgroundImage = getRealPath(backgroundImage) - } - } - }, - backgroundRepeat: { - type: String - }, - borderStyle: { - type: String, - validator(borderStyle, params) { - if (borderStyle) { - params.borderStyle = borderStyle === 'black' ? 'black' : 'white' - } - } - } -} - -export const hideTabBar = { - animation: { - type: Boolean, - default: false - } -} - -export const showTabBar = { - animation: { - type: Boolean, - default: false - } -} - -export const hideTabBarRedDot = { - index: indexValidator -} - -export const showTabBarRedDot = { - index: indexValidator -} - -export const removeTabBarBadge = { - index: indexValidator -} - -export const setTabBarBadge = { - index: indexValidator, - text: { - type: String, - required: true, - validator(text, params) { - if (getLen(text) >= 4) { - params.text = '...' - } - } - } -} diff --git a/packages/uni-api/src/protocols/ui/tabBar.ts b/packages/uni-api/src/protocols/ui/tabBar.ts new file mode 100644 index 0000000000000000000000000000000000000000..845ecaebe5aa8a8b95d3e68b3b5b0a7bb15f5f66 --- /dev/null +++ b/packages/uni-api/src/protocols/ui/tabBar.ts @@ -0,0 +1,124 @@ +import { extend } from '@vue/shared' +import { getLen } from '@dcloudio/uni-shared' +import { getRealPath } from '@dcloudio/uni-platform' +import { getCurrentPageMeta } from '@dcloudio/uni-core' + +import { ApiOptions, ApiProtocol } from '../type' + +const IndexProtocol: ApiProtocol = { + index: { + type: Number, + required: true, + }, +} + +const IndexOptions: ApiOptions = { + beforeInvoke() { + const pageMeta = getCurrentPageMeta() + if (pageMeta && !pageMeta.isTabBar) { + return 'not TabBar page' + } + }, + formatArgs: { + index(value) { + if (!__uniConfig.tabBar!.list[value]) { + return 'tabbar item not found' + } + }, + }, +} + +export const SetTabBarItemProtocol: ApiProtocol = extend( + { + text: { + type: String, + }, + iconPath: { + type: String, + }, + selectedIconPath: { + type: String, + }, + pagePath: { + type: String, + }, + }, + IndexProtocol +) + +export const SetTabBarItemOptions: ApiOptions = IndexOptions + +export const SetTabBarStyleProtocol: ApiProtocol = { + color: { + type: String, + }, + selectedColor: { + type: String, + }, + backgroundColor: { + type: String, + }, + backgroundImage: { + type: String, + }, + backgroundRepeat: { + type: String, + }, + borderStyle: { + type: String, + }, +} +const GRADIENT_RE = /^(linear|radial)-gradient\(.+?\);?$/ +export const SetTabBarStyleOptions: ApiOptions = { + formatArgs: { + backgroundImage(value, params) { + if (value && !GRADIENT_RE.test(value)) { + params.backgroundImage = getRealPath(value) + } + }, + borderStyle(value, params) { + if (value) { + params.borderStyle = value === 'white' ? 'white' : 'black' + } + }, + }, +} +export const HideTabBarProtocol: ApiProtocol = { + animation: { + type: Boolean, + default: false, + }, +} +export const ShowTabBarProtocol: ApiProtocol = HideTabBarProtocol + +export const HideTabBarRedDotProtocol: ApiProtocol = IndexProtocol +export const HideTabBarRedDotOptions: ApiOptions = IndexOptions + +export const ShowTabBarRedDotProtocol: ApiProtocol = IndexProtocol +export const ShowTabBarRedDotOptions: ApiOptions = IndexOptions + +export const RemoveTabBarBadgeProtocol: ApiProtocol = IndexProtocol +export const RemoveTabBarBadgeOptions: ApiOptions = IndexOptions + +export const SetTabBarBadgeProtocol: ApiProtocol = extend( + { + text: { + type: String, + required: true, + }, + }, + IndexProtocol +) + +export const SetTabBarBadgeOptions: ApiOptions = { + formatArgs: extend( + { + text(value, params) { + if (getLen(value) >= 4) { + params.text = '...' + } + }, + } as ApiOptions['formatArgs'], + IndexOptions.formatArgs + ), +} diff --git a/packages/uni-api/src/service/context/createVideoContext.ts b/packages/uni-api/src/service/context/createVideoContext.ts index 15e6a874edc2b0de416f344a627c4f5828a3c370..0fdf0011ffa2c7c5dca5b8df7b4bca0cf191143f 100644 --- a/packages/uni-api/src/service/context/createVideoContext.ts +++ b/packages/uni-api/src/service/context/createVideoContext.ts @@ -1,6 +1,6 @@ import { ComponentPublicInstance } from 'vue' +import { getCurrentPageVm } from '@dcloudio/uni-core' import { operateVideoPlayer } from '@dcloudio/uni-platform' -import { getCurrentPageVm } from '../../helpers/utils' const RATES = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0] @@ -69,5 +69,5 @@ export function createVideoContext( if (context) { return new VideoContext(id, context) } - return new VideoContext(id, getCurrentPageVm()) + return new VideoContext(id, getCurrentPageVm()!) } diff --git a/packages/uni-api/src/service/ui/createIntersectionObserver.ts b/packages/uni-api/src/service/ui/createIntersectionObserver.ts index 560f03cb55e05d583f5fb7503722b1c0e3938612..1c87b86d9ffe0ac2041f500f223176d62f12598a 100644 --- a/packages/uni-api/src/service/ui/createIntersectionObserver.ts +++ b/packages/uni-api/src/service/ui/createIntersectionObserver.ts @@ -1,11 +1,11 @@ import { ComponentPublicInstance } from 'vue' import { extend, isFunction } from '@vue/shared' +import { getCurrentPageVm } from '@dcloudio/uni-core' import { addIntersectionObserver, removeIntersectionObserver, } from '@dcloudio/uni-platform' import { defineSyncApi } from '../../helpers/api' -import { getCurrentPageVm } from '../../helpers/utils' import { RequestComponentObserverOptions } from '../../helpers/requestComponentObserver' export interface AddIntersectionObserverArgs { @@ -103,5 +103,5 @@ export const createIntersectionObserver = defineSyncApi< if (context) { return new ServiceIntersectionObserver(context, options) } - return new ServiceIntersectionObserver(getCurrentPageVm(), options) + return new ServiceIntersectionObserver(getCurrentPageVm()!, options) }) diff --git a/packages/uni-api/src/service/ui/tabBar.ts b/packages/uni-api/src/service/ui/tabBar.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec33a38b663739c030cda1b9ba6525c5a8db50d3 --- /dev/null +++ b/packages/uni-api/src/service/ui/tabBar.ts @@ -0,0 +1,11 @@ +import { defineOnApi } from '../../helpers/api' +export type OnTabBarMidButtonTap = typeof uni.onTabBarMidButtonTap + +export const API_ON_TAB_BAR_MID_BUTTON_TAP = 'onTabBarMidButtonTap' + +export const onTabBarMidButtonTap = defineOnApi( + API_ON_TAB_BAR_MID_BUTTON_TAP, + () => { + // noop + } +) diff --git a/packages/uni-components/src/components/form/index.tsx b/packages/uni-components/src/components/form/index.tsx index 2da037823cb7995ef272c203c87e243f5ee39191..5f0a19212d0eef5787f73a0bd5f73e97c92b52a5 100644 --- a/packages/uni-components/src/components/form/index.tsx +++ b/packages/uni-components/src/components/form/index.tsx @@ -17,7 +17,7 @@ interface UniFormFieldCtx { export default defineComponent({ name: 'Form', - setup(props, { slots, emit }) { + setup(_props, { slots, emit }) { provideForm(emit) return () => ( diff --git a/packages/uni-core/src/service/plugin/index.ts b/packages/uni-core/src/service/plugin/index.ts index 83054a5883219933f0fe3dac4e2d60291c5b936f..b1b3a523d135fdce23ba735ad928ce16405f23fc 100644 --- a/packages/uni-core/src/service/plugin/index.ts +++ b/packages/uni-core/src/service/plugin/index.ts @@ -1,7 +1,34 @@ -import { App } from 'vue' +import { App, ComponentPublicInstance } from 'vue' import { initAppConfig } from './appConfig' export function initService(app: App) { initAppConfig(app._context.config) } + +export function getCurrentPage() { + const pages = getCurrentPages() + const len = pages.length + if (len) { + return pages[len - 1] + } +} + +export function getCurrentPageMeta() { + const page = getCurrentPage() + if (page) { + return page.$page.meta + } +} + +export function getCurrentPageVm() { + const page = getCurrentPage() + if (page) { + return (page as any).$vm as ComponentPublicInstance + } +} + +export function invokeHook(name: string, args?: T) { + const vm = getCurrentPageVm() + return vm && vm.$callHook(name, args) +} diff --git a/packages/uni-h5/dist/uni-h5.esm.js b/packages/uni-h5/dist/uni-h5.esm.js index bc89230e9df2b77a31481e1c718c1b410308ecf3..28f6c71a1f6965a002a50b8bf92ff7e26e93d6d0 100644 --- a/packages/uni-h5/dist/uni-h5.esm.js +++ b/packages/uni-h5/dist/uni-h5.esm.js @@ -1,6 +1,6 @@ -import {isFunction, extend, isPlainObject, isString, hasOwn as hasOwn$1, hyphenate, isArray, isObject as isObject$1, capitalize, toRawType, makeMap as makeMap$1, isPromise} from "@vue/shared"; -import {injectHook, createVNode, defineComponent, inject, provide, reactive, computed, nextTick, withDirectives, vShow, withCtx, openBlock, createBlock, KeepAlive, resolveDynamicComponent, resolveComponent, onMounted, ref, mergeProps, toDisplayString, toHandlers, renderSlot, createCommentVNode, getCurrentInstance, onBeforeUnmount, withModifiers, vModelDynamic, createTextVNode, Fragment, renderList, vModelText, watch, onBeforeMount} from "vue"; -import {passive, NAVBAR_HEIGHT, COMPONENT_NAME_PREFIX, plusReady, debounce, PRIMARY_COLOR} from "@dcloudio/uni-shared"; +import {isFunction, extend, isPlainObject, isArray, hasOwn as hasOwn$1, isString, isObject as isObject$1, capitalize, toRawType, makeMap as makeMap$1, isPromise, hyphenate} from "@vue/shared"; +import {injectHook, createVNode, reactive, inject, provide, computed, nextTick, defineComponent, onRenderTriggered, watch, withDirectives, vShow, withCtx, openBlock, createBlock, KeepAlive, resolveDynamicComponent, resolveComponent, onMounted, ref, mergeProps, toDisplayString, toHandlers, renderSlot, createCommentVNode, getCurrentInstance, onBeforeUnmount, withModifiers, vModelDynamic, createTextVNode, Fragment, renderList, vModelText, onBeforeMount} from "vue"; +import {passive, NAVBAR_HEIGHT, getLen, COMPONENT_NAME_PREFIX, plusReady, debounce, PRIMARY_COLOR} from "@dcloudio/uni-shared"; import {createRouter, createWebHistory, createWebHashHistory, useRoute, RouterView, isNavigationFailure} from "vue-router"; function applyOptions(options, instance2, publicThis) { Object.keys(options).forEach((name) => { @@ -715,6 +715,29 @@ function initAppConfig(appConfig) { function initService(app) { initAppConfig(app._context.config); } +function getCurrentPage() { + const pages = getCurrentPages(); + const len = pages.length; + if (len) { + return pages[len - 1]; + } +} +function getCurrentPageMeta() { + const page = getCurrentPage(); + if (page) { + return page.$page.meta; + } +} +function getCurrentPageVm() { + const page = getCurrentPage(); + if (page) { + return page.$vm; + } +} +function invokeHook(name, args) { + const vm = getCurrentPageVm(); + return vm && vm.$callHook(name, args); +} function PolySymbol(name) { return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name); } @@ -1223,10 +1246,14 @@ function initHistory() { const history2 = __UNI_FEATURE_ROUTER_MODE__ === "history" ? createWebHistory() : createWebHashHistory(); return history2; } -var TabBar = /* @__PURE__ */ defineComponent({ - name: "TabBar" -}); -const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "pageMeta" : "pm"); +let tabBar; +function useTabBar() { + if (!tabBar) { + tabBar = __uniConfig.tabBar && reactive(__uniConfig.tabBar); + } + return tabBar; +} +const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageMeta" : "upm"); function usePageMeta() { return inject(pageMetaKey); } @@ -1402,4217 +1429,4586 @@ function pruneRouteCache(key) { } }); } -var Layout = defineComponent({ - name: "Layout", - props: { - onChange: Function - }, - emits: ["change"], - setup() { - const route = __UNI_FEATURE_TABBAR__ && useRoute(); - const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute(); - __UNI_FEATURE_TOPWINDOW__ && useTopWindow(); - __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(); - __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(); - return () => { - const layoutTsx = createLayoutTsx(keepAliveRoute); - const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(route); - if (!tabBarTsx) { - return layoutTsx; - } - return [layoutTsx, tabBarTsx]; - }; +var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +var lookup = new Uint8Array(256); +for (var i$1 = 0; i$1 < chars.length; i$1++) { + lookup[chars.charCodeAt(i$1)] = i$1; +} +function encode$1(arraybuffer) { + var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = ""; + for (i2 = 0; i2 < len; i2 += 3) { + base64 += chars[bytes[i2] >> 2]; + base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4]; + base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6]; + base64 += chars[bytes[i2 + 2] & 63]; } -}); -function createLayoutTsx(keepAliveRoute, topWindow, leftWindow, rightWindow) { - const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode(); - if (!__UNI_FEATURE_RESPONSIVE__) { - return routerVNode; + if (len % 3 === 2) { + base64 = base64.substring(0, base64.length - 1) + "="; + } else if (len % 3 === 1) { + base64 = base64.substring(0, base64.length - 2) + "=="; } - const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx() : null; - const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx() : null; - const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx() : null; - return createVNode("uni-layout", null, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])]); -} -function createTabBarTsx(route) { - return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, route.meta.isTabBar]]); -} -function createPageVNode() { - return createVNode(__uniRoutes[0].component); -} -function createRouterViewVNode(keepAliveRoute) { - return createVNode(RouterView, null, { - default: withCtx(({ - Component - }) => [(openBlock(), createBlock(KeepAlive, { - matchBy: "key", - cache: keepAliveRoute.routeCache - }, [(openBlock(), createBlock(resolveDynamicComponent(Component), { - key: keepAliveRoute.routeKey.value - }))], 1032, ["cache"]))]), - _: 1 - }); -} -function useTopWindow() { - const component = resolveComponent("VUniTopWindow"); - return { - component, - style: component.style, - height: 0, - show: false - }; + return base64; } -function useLeftWindow() { - const component = resolveComponent("VUniLeftWindow"); - return { - component, - style: component.style, - height: 0 - }; +function decode(base64) { + var bufferLength = base64.length * 0.75, len = base64.length, i2, p2 = 0, encoded1, encoded2, encoded3, encoded4; + if (base64[base64.length - 1] === "=") { + bufferLength--; + if (base64[base64.length - 2] === "=") { + bufferLength--; + } + } + var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); + for (i2 = 0; i2 < len; i2 += 4) { + encoded1 = lookup[base64.charCodeAt(i2)]; + encoded2 = lookup[base64.charCodeAt(i2 + 1)]; + encoded3 = lookup[base64.charCodeAt(i2 + 2)]; + encoded4 = lookup[base64.charCodeAt(i2 + 3)]; + bytes[p2++] = encoded1 << 2 | encoded2 >> 4; + bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2; + bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63; + } + return arraybuffer; } -function useRightWindow() { - const component = resolveComponent("VUniRightWindow"); +const API_TYPE_ON_PROTOCOLS = [ + { + name: "callback", + type: Function, + required: true + } +]; +function validateProtocolFail(name, msg) { + const errMsg = `${name}:fail ${msg}`; + { + console.error(errMsg); + } return { - component, - style: component.style, - height: 0 + errMsg }; } -function createTopWindowTsx(topWindow) { -} -function createLeftWindowTsx(leftWindow) { -} -function createRightWindowTsx(leftWindow) { -} -const CSS_VARS = ["--status-bar-height", "--top-window-height", "--window-left", "--window-right", "--window-margin"]; -var AppComponent = defineComponent({ - name: "App", - setup() { - useCssVar(); - useAppLifecycle(); - const { - clazz, - onChange: onChange2 - } = useAppClass(); - return () => createVNode("uni-app", { - class: clazz.value - }, [createVNode(Layout, { - onChange: onChange2 - }, null, 8, ["onChange"])], 2); +function validateProtocol(name, data, protocol) { + for (const key in protocol) { + const errMsg = validateProp(key, data[key], protocol[key], !hasOwn$1(data, key)); + if (isString(errMsg)) { + return validateProtocolFail(name, errMsg); + } } -}); -function useCssVar() { - CSS_VARS.forEach((name) => updateCssVar(name, "0px")); } -function useAppLifecycle() { - onMounted(() => { - document.addEventListener("visibilitychange", function() { - if (document.visibilityState === "visible") { - UniServiceJSBridge.emit("onAppEnterForeground"); - } else { - UniServiceJSBridge.emit("onAppEnterBackground"); +function validateProtocols(name, args, protocol) { + if (!protocol) { + return; + } + if (isArray(protocol)) { + const len = protocol.length; + const argsLen = args.length; + for (let i2 = 0; i2 < len; i2++) { + const opts = protocol[i2]; + const data = Object.create(null); + if (argsLen > i2) { + data[opts.name] = args[i2]; } - }); - }); + const errMsg = validateProtocol(name, data, {[opts.name]: opts}); + if (errMsg) { + return errMsg; + } + } + return; + } + return validateProtocol(name, args[0] || Object.create(null), protocol); } -function useAppClass() { - const showTabBar = ref(false); - const showMaxWidth = ref(false); - function onChange2(type, value) { - if (type === "showTabBar") { - showTabBar.value = value; - } else if (type === "showMaxWidth") { - showMaxWidth.value = value; +function validateProp(name, value, prop, isAbsent) { + const {type, required, validator} = prop; + if (required && isAbsent) { + return 'Missing required args: "' + name + '"'; + } + if (value == null && !prop.required) { + return; + } + if (type != null && type !== true) { + let isValid = false; + const types = isArray(type) ? type : [type]; + const expectedTypes = []; + for (let i2 = 0; i2 < types.length && !isValid; i2++) { + const {valid, expectedType} = assertType(value, types[i2]); + expectedTypes.push(expectedType || ""); + isValid = valid; + } + if (!isValid) { + return getInvalidTypeMessage(name, value, expectedTypes); + } + } + if (validator) { + return validator(value); + } +} +const isSimpleType = /* @__PURE__ */ makeMap$1("String,Number,Boolean,Function,Symbol"); +function assertType(value, type) { + let valid; + const expectedType = getType(type); + if (isSimpleType(expectedType)) { + const t2 = typeof value; + valid = t2 === expectedType.toLowerCase(); + if (!valid && t2 === "object") { + valid = value instanceof type; + } + } else if (expectedType === "Object") { + valid = isObject$1(value); + } else if (expectedType === "Array") { + valid = isArray(value); + } else { + { + valid = value instanceof type; } } - const clazz = computed(() => { - return { - "uni-app--showtabbar": showTabBar.value, - "uni-app--maxwidth": showMaxWidth.value - }; - }); return { - clazz, - onChange: onChange2 + valid, + expectedType }; } -function initSystemComponents(app) { - AppComponent.name = COMPONENT_NAME_PREFIX + AppComponent.name; - app.component(AppComponent.name, AppComponent); -} -let appVm; -function getApp$1() { - return appVm; -} -function isApp(vm) { - return vm.$options.mpType === "app"; -} -function initApp(vm) { - appVm = vm; - appVm.$vm = vm; - appVm.globalData = appVm.$options.globalData || {}; +function getInvalidTypeMessage(name, value, expectedTypes) { + let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`; + const expectedType = expectedTypes[0]; + const receivedType = toRawType(value); + const expectedValue = styleValue(value, expectedType); + const receivedValue = styleValue(value, receivedType); + if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) { + message += ` with value ${expectedValue}`; + } + message += `, got ${receivedType} `; + if (isExplicable(receivedType)) { + message += `with value ${receivedValue}.`; + } + return message; } -function initMixin(app) { - app.mixin({ - created() { - this.__isApp = isApp(this); - this.__isPage = !this.__isApp && isPage(this); - if (this.__isApp) { - initApp(this); - } else if (this.__isPage) { - initPage(this); - this.$callHook("onLoad", {}); - this.__isVisible = true; - this.$callHook("onShow"); - } else { - if (this.$parent) { - this.$page = this.$parent.$page; - } - } - }, - mounted() { - if (this.__isPage) { - this.$callHook("onReady"); - } - }, - beforeActivate() { - if (this.__isPage && !this.__isVisible) { - this.$callHook("onShow"); - } - }, - beforeDeactivate() { - if (this.__isPage) { - this.__isVisible = false; - this.$callHook("onHide"); +function getType(ctor) { + const match = ctor && ctor.toString().match(/^\s*function (\w+)/); + return match ? match[1] : ""; +} +function styleValue(value, type) { + if (type === "String") { + return `"${value}"`; + } else if (type === "Number") { + return `${Number(value)}`; + } else { + return `${value}`; + } +} +function isExplicable(type) { + const explicitTypes = ["string", "number", "boolean"]; + return explicitTypes.some((elem) => type.toLowerCase() === elem); +} +function isBoolean(...args) { + return args.some((elem) => elem.toLowerCase() === "boolean"); +} +function tryCatch(fn) { + return function() { + try { + return fn.apply(fn, arguments); + } catch (e2) { + console.error(e2); + } + }; +} +let invokeCallbackId = 1; +const invokeCallbacks = {}; +function addInvokeCallback(id2, name, callback, keepAlive = false) { + invokeCallbacks[id2] = { + name, + keepAlive, + callback + }; + return id2; +} +function invokeCallback(id2, res, extras) { + if (typeof id2 === "number") { + const opts = invokeCallbacks[id2]; + if (opts) { + if (!opts.keepAlive) { + delete invokeCallbacks[id2]; } - }, - beforeUnmount() { - if (this.__isPage) { - this.$callHook("onUnload"); + return opts.callback(res, extras); + } + } + return res; +} +function findInvokeCallbackByName(name) { + for (const key in invokeCallbacks) { + if (invokeCallbacks[key].name === name) { + return true; + } + } + return false; +} +function removeKeepAliveApiCallback(name, callback) { + for (const key in invokeCallbacks) { + const item = invokeCallbacks[key]; + if (item.callback === callback && item.name === name) { + delete invokeCallbacks[key]; + } + } +} +function offKeepAliveApiCallback(name) { + UniServiceJSBridge.off("api." + name); +} +function onKeepAliveApiCallback(name) { + UniServiceJSBridge.on("api." + name, (res) => { + for (const key in invokeCallbacks) { + const opts = invokeCallbacks[key]; + if (opts.name === name) { + opts.callback(res); } } }); } -var index$6 = { - install(app) { - initApp$1(app); - initView(app); - initService(app); - initSystemComponents(app); - initMixin(app); - if (__UNI_FEATURE_PAGES__) { - initRouter(app); +function createKeepAliveApiCallback(name, callback) { + return addInvokeCallback(invokeCallbackId++, name, callback, true); +} +const API_SUCCESS = "success"; +const API_FAIL = "fail"; +const API_COMPLETE = "complete"; +function getApiCallbacks(args) { + const apiCallbacks = {}; + for (const name in args) { + const fn = args[name]; + if (isFunction(fn)) { + apiCallbacks[name] = tryCatch(fn); + delete args[name]; } } -}; -function broadcast(componentName, eventName, ...params) { - const children = this.$children; - const len = children.length; - for (let i2 = 0; i2 < len; i2++) { - const child = children[i2]; - const name = child.$options.name && child.$options.name.substr(4); - if (~componentName.indexOf(name)) { - child.$emit.apply(child, [eventName].concat(params)); - return false; + return apiCallbacks; +} +function normalizeErrMsg(errMsg, name) { + if (!errMsg || errMsg.indexOf(":fail") === -1) { + return name + ":ok"; + } + return name + errMsg.substring(errMsg.indexOf(":fail")); +} +function createAsyncApiCallback(name, args = {}, {beforeAll, beforeSuccess} = {}) { + if (!isPlainObject(args)) { + args = {}; + } + const {success, fail, complete} = getApiCallbacks(args); + const hasSuccess = isFunction(success); + const hasFail = isFunction(fail); + const hasComplete = isFunction(complete); + const callbackId = invokeCallbackId++; + addInvokeCallback(callbackId, name, (res) => { + res = res || {}; + res.errMsg = normalizeErrMsg(res.errMsg, name); + isFunction(beforeAll) && beforeAll(res); + if (res.errMsg === name + ":ok") { + isFunction(beforeSuccess) && beforeSuccess(res); + hasSuccess && success(res); } else { - if (broadcast.apply(child, [componentName, eventName].concat([params])) === false) { - return false; - } + hasFail && fail(res); } + hasComplete && complete(res); + }); + return callbackId; +} +const callbacks = [API_SUCCESS, API_FAIL, API_COMPLETE]; +function hasCallback(args) { + if (isPlainObject(args) && callbacks.find((cb) => isFunction(args[cb]))) { + return true; } + return false; } -var emitter = { - methods: { - $dispatch(componentName, eventName, ...params) { - console.log("$dispatch", componentName, eventName, params); - }, - $broadcast(componentName, eventName, ...params) { - if (typeof componentName === "string") { - componentName = [componentName]; - } - broadcast.apply(this, [componentName, eventName].concat(params)); +function handlePromise(promise) { + if (__UNI_FEATURE_PROMISE__) { + return promise.then((data) => { + return [null, data]; + }).catch((err) => [err]); + } + return promise; +} +function promisify(fn) { + return (args = {}) => { + if (hasCallback(args)) { + return fn(args); } + return handlePromise(new Promise((resolve, reject) => { + fn(Object.assign(args, {success: resolve, fail: reject})); + })); + }; +} +function formatApiArgs(args, options) { + const params = args[0]; + if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) { + return args; } -}; -var listeners = { - props: { - id: { - type: String, - default: "" + const formatArgs = options.formatArgs; + Object.keys(formatArgs).forEach((name) => { + formatArgs[name](args[0][name], params); + }); + return args; +} +function wrapperOnApi(name, fn) { + return (callback) => { + const isFirstInvokeOnApi = !findInvokeCallbackByName(name); + createKeepAliveApiCallback(name, callback); + if (isFirstInvokeOnApi) { + onKeepAliveApiCallback(name); + fn(); } - }, - created() { - this._addListeners(this.id); - this.$watch("id", (newId, oldId) => { - this._removeListeners(oldId, true); - this._addListeners(newId, true); - }); - }, - beforeDestroy() { - this._removeListeners(this.id); - }, - methods: { - _addListeners(id2, watch2) { - if (watch2 && !id2) { - return; - } - const {listeners: listeners2} = this.$options; - if (!isPlainObject(listeners2)) { - return; - } - Object.keys(listeners2).forEach((name) => { - if (watch2) { - if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) { - UniViewJSBridge.on(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); - } - } else { - if (name.indexOf("@") === 0) { - this.$on(`uni-${name.substr(1)}`, this[listeners2[name]]); - } else if (name.indexOf("uni-") === 0) { - UniViewJSBridge.on(name, this[listeners2[name]]); - } else if (id2) { - UniViewJSBridge.on(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); - } - } - }); - }, - _removeListeners(id2, watch2) { - if (watch2 && !id2) { - return; - } - const {listeners: listeners2} = this.$options; - if (!isPlainObject(listeners2)) { - return; - } - Object.keys(listeners2).forEach((name) => { - if (watch2) { - if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) { - UniViewJSBridge.off(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); - } - } else { - if (name.indexOf("@") === 0) { - this.$off(`uni-${name.substr(1)}`, this[listeners2[name]]); - } else if (name.indexOf("uni-") === 0) { - UniViewJSBridge.off(name, this[listeners2[name]]); - } else if (id2) { - UniViewJSBridge.off(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); - } - } - }); - } - } -}; -var hover = { - data() { - return { - hovering: false - }; - }, - props: { - hoverClass: { - type: String, - default: "none" - }, - hoverStopPropagation: { - type: Boolean, - default: false - }, - hoverStartTime: { - type: [Number, String], - default: 50 - }, - hoverStayTime: { - type: [Number, String], - default: 400 - } - }, - methods: { - _hoverTouchStart(evt) { - if (evt._hoverPropagationStopped) { - return; - } - if (!this.hoverClass || this.hoverClass === "none" || this.disabled) { - return; - } - if (evt.touches.length > 1) { - return; - } - if (this.hoverStopPropagation) { - evt._hoverPropagationStopped = true; - } - this._hoverTouch = true; - this._hoverStartTimer = setTimeout(() => { - this.hovering = true; - if (!this._hoverTouch) { - this._hoverReset(); - } - }, this.hoverStartTime); - }, - _hoverTouchEnd(evt) { - this._hoverTouch = false; - if (this.hovering) { - this._hoverReset(); - } - }, - _hoverReset() { - requestAnimationFrame(() => { - clearTimeout(this._hoverStayTimer); - this._hoverStayTimer = setTimeout(() => { - this.hovering = false; - }, this.hoverStayTime); - }); - }, - _hoverTouchCancel(evt) { - this._hoverTouch = false; - this.hovering = false; - clearTimeout(this._hoverStartTimer); + }; +} +function wrapperOffApi(name, fn) { + return (callback) => { + name = name.replace("off", "on"); + removeKeepAliveApiCallback(name, callback); + const hasInvokeOnApi = findInvokeCallbackByName(name); + if (!hasInvokeOnApi) { + offKeepAliveApiCallback(name); + fn(); } - } -}; -var subscriber = { - mounted() { - this._toggleListeners("subscribe", this.id); - this.$watch("id", (newId, oldId) => { - this._toggleListeners("unsubscribe", oldId, true); - this._toggleListeners("subscribe", newId, true); + }; +} +function invokeSuccess(id2, name, res) { + return invokeCallback(id2, extend(res || {}, {errMsg: name + ":ok"})); +} +function invokeFail(id2, name, err) { + return invokeCallback(id2, {errMsg: name + ":fail" + (err ? " " + err : "")}); +} +function wrapperTaskApi(name, fn, options) { + return (args) => { + const id2 = createAsyncApiCallback(name, args, options); + return fn(args, { + resolve: (res) => invokeSuccess(id2, name, res), + reject: (err) => invokeFail(id2, name, err) }); - }, - beforeDestroy() { - this._toggleListeners("unsubscribe", this.id); - if (this._contextId) { - this._toggleListeners("unsubscribe", this._contextId); - } - }, - methods: { - _toggleListeners(type, id2, watch2) { - if (watch2 && !id2) { - return; - } - if (!isFunction(this._handleSubscribe)) { - return; + }; +} +function wrapperSyncApi(fn) { + return (...args) => fn.apply(null, args); +} +function wrapperAsyncApi(name, fn, options) { + return wrapperTaskApi(name, fn, options); +} +function wrapperApi(fn, name, protocol, options) { + return function(...args) { + if (process.env.NODE_ENV !== "production") { + const errMsg = validateProtocols(name, args, protocol); + if (isString(errMsg)) { + return errMsg; } - UniViewJSBridge[type](this.$page.id + "-" + this.$options.name.replace(/VUni([A-Z])/, "$1").toLowerCase() + "-" + id2, this._handleSubscribe); - }, - _getContextInfo() { - const id2 = `context-${this._uid}`; - if (!this._contextId) { - this._toggleListeners("subscribe", id2); - this._contextId = id2; + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { + return errMsg; } - return { - name: this.$options.name.replace(/VUni([A-Z])/, "$1").toLowerCase(), - id: id2, - page: this.$page.id - }; } + return fn.apply(null, formatApiArgs(args, options)); + }; +} +function defineOnApi(name, fn, options) { + return wrapperApi(wrapperOnApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); +} +function defineOffApi(name, fn, options) { + return wrapperApi(wrapperOffApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); +} +function defineTaskApi(name, fn, protocol, options) { + return promisify(wrapperApi(wrapperTaskApi(name, fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); +} +function defineSyncApi(name, fn, protocol, options) { + return wrapperApi(wrapperSyncApi(fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options); +} +function defineAsyncApi(name, fn, protocol, options) { + return promisify(wrapperApi(wrapperAsyncApi(name, fn, options), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); +} +const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer"; +const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64"; +const Base64ToArrayBufferProtocol = [ + { + name: "base64", + type: String, + required: true } -}; -function hideKeyboard() { - document.activeElement.blur(); +]; +const ArrayBufferToBase64Protocol = [ + { + name: "arrayBuffer", + type: [ArrayBuffer, Uint8Array], + required: true + } +]; +const base64ToArrayBuffer = /* @__PURE__ */ defineSyncApi(API_BASE64_TO_ARRAY_BUFFER, (base64) => { + return decode(base64); +}, Base64ToArrayBufferProtocol); +const arrayBufferToBase64 = /* @__PURE__ */ defineSyncApi(API_ARRAY_BUFFER_TO_BASE64, (arrayBuffer) => { + return encode$1(arrayBuffer); +}, ArrayBufferToBase64Protocol); +function findElem(vm) { + return vm.$el; } -function iosHideKeyboard() { +const SCHEME_RE = /^([a-z-]+:)?\/\//i; +const DATA_RE = /^data:.*,.*/; +function addBase(filePath) { + const base = __uniConfig.router.base; + if (!base) { + return filePath; + } + if (base !== "/") { + if (("/" + filePath).indexOf(base) === 0) { + return "/" + filePath; + } + } + return base + filePath; } -var keyboard = { - name: "Keyboard", - props: { - cursorSpacing: { - type: [Number, String], - default: 0 - }, - showConfirmBar: { - type: [Boolean, String], - default: "auto" - }, - adjustPosition: { - type: Boolean, - default: true - } - }, - watch: { - focus(val) { - if (val && false) { - this.showSoftKeybord(); - } - } - }, - mounted() { - if (this.autoFocus || this.focus) { - this.showSoftKeybord(); - } - }, - beforeDestroy() { - this.onKeyboardHide(); - }, - methods: { - initKeyboard(el) { - el.addEventListener("focus", () => { - this.hideKeyboardTemp = function() { - hideKeyboard(); - }; - UniViewJSBridge.subscribe("hideKeyboard", this.hideKeyboardTemp); - document.addEventListener("click", iosHideKeyboard, false); - }); - el.addEventListener("blur", this.onKeyboardHide.bind(this)); - }, - showSoftKeybord() { - plusReady(() => { - plus.key.showSoftKeybord(); - }); - }, - setSoftinputTemporary() { - plusReady(() => { - const currentWebview = plus.webview.currentWebview(); - const style = currentWebview.getStyle() || {}; - const rect = this.$el.getBoundingClientRect(); - currentWebview.setSoftinputTemporary && currentWebview.setSoftinputTemporary({ - mode: style.softinputMode === "adjustResize" ? "adjustResize" : this.adjustPosition ? "adjustPan" : "nothing", - position: { - top: rect.top, - height: rect.height + (Number(this.cursorSpacing) || 0) - } - }); - }); - }, - setSoftinputNavBar() { - if (this.showConfirmBar === "auto") { - delete this.__softinputNavBar; - return; - } - plusReady(() => { - const currentWebview = plus.webview.currentWebview(); - const {softinputNavBar} = currentWebview.getStyle() || {}; - const showConfirmBar = softinputNavBar !== "none"; - if (showConfirmBar !== this.showConfirmBar) { - this.__softinputNavBar = softinputNavBar || "auto"; - currentWebview.setStyle({ - softinputNavBar: this.showConfirmBar ? "auto" : "none" - }); - } else { - delete this.__softinputNavBar; - } - }); - }, - resetSoftinputNavBar() { - const softinputNavBar = this.__softinputNavBar; - if (softinputNavBar) { - plusReady(() => { - const currentWebview = plus.webview.currentWebview(); - currentWebview.setStyle({ - softinputNavBar - }); - }); - } - }, - onKeyboardHide() { - UniViewJSBridge.unsubscribe("hideKeyboard", this.hideKeyboardTemp); - document.removeEventListener("click", iosHideKeyboard, false); - if (String(navigator.vendor).indexOf("Apple") === 0) { - document.documentElement.scrollTo(document.documentElement.scrollLeft, document.documentElement.scrollTop); - } - } +function getRealPath(filePath) { + if (__uniConfig.router.base === "./") { + filePath = filePath.replace(/^\.\/static\//, "/static/"); } -}; -function throttle(fn, wait) { - let last = 0; - let timeout; - const newFn = function(...arg) { - const now = Date.now(); - clearTimeout(timeout); - const waitCallback = () => { - last = now; - fn.apply(this, arg); - }; - if (now - last < wait) { - timeout = setTimeout(waitCallback, wait - (now - last)); - return; + if (filePath.indexOf("/") === 0) { + if (filePath.indexOf("//") === 0) { + filePath = "https:" + filePath; + } else { + return addBase(filePath.substr(1)); } - waitCallback(); - }; - newFn.cancel = function() { - clearTimeout(timeout); + } + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf("blob:") === 0) { + return filePath; + } + const pages = getCurrentPages(); + if (pages.length) { + return addBase(getRealRoute(pages[pages.length - 1].$page.route, filePath).substr(1)); + } + return filePath; +} +const ua = navigator.userAgent; +const isAndroid = /android/i.test(ua); +const isIOS$1 = /iphone|ipad|ipod/i.test(ua); +function getScreenFix() { + return /^Apple/.test(navigator.vendor) && typeof window.orientation === "number"; +} +function isLandscape(screenFix) { + return screenFix && Math.abs(window.orientation) === 90; +} +function getScreenWidth(screenFix, landscape) { + return screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width; +} +function getScreenHeight(screenFix, landscape) { + return screenFix ? Math[landscape ? "min" : "max"](screen.height, screen.width) : screen.height; +} +function getWindowWidth(screenWidth) { + return Math.min(window.innerWidth, document.documentElement.clientWidth, screenWidth) || screenWidth; +} +function getBaseSystemInfo() { + const screenFix = getScreenFix(); + const windowWidth = getWindowWidth(getScreenWidth(screenFix, isLandscape(screenFix))); + return { + platform: isIOS$1 ? "ios" : "other", + pixelRatio: window.devicePixelRatio, + windowWidth }; - return newFn; } -var baseInput = { - name: "BaseInput", - mixins: [emitter, keyboard], - model: { - prop: "value", - event: "update:value" - }, - props: { - value: { - type: [String, Number], - default: "" - } - }, - data() { - return { - valueSync: this._getValueString(this.value) - }; - }, - created() { - const valueChange = this.__valueChange = debounce((val) => { - this.valueSync = this._getValueString(val); - }, 100); - this.$watch("value", valueChange); - this.__triggerInput = throttle(($event, detail) => { - this.$emit("update:value", detail.value); - this.$trigger("input", $event, detail); - }, 100); - this.$triggerInput = ($event, detail) => { - this.__valueChange.cancel(); - this.__triggerInput($event, detail); - }; - }, - beforeDestroy() { - this.__valueChange.cancel(); - this.__triggerInput.cancel(); - }, - methods: { - _getValueString(value) { - return value === null ? "" : String(value); +function operateVideoPlayer(videoId, vm, type, data) { + const pageId = vm.$page.id; + UniServiceJSBridge.publishHandler(pageId + "-video-" + videoId, { + videoId, + type, + data + }, pageId); +} +function addIntersectionObserver({reqId, component, options, callback}, _pageId) { + const $el = findElem(component); + ($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver($el, options, callback); +} +function removeIntersectionObserver({reqId, component}, _pageId) { + const $el = findElem(component); + const intersectionObserver = $el.__io && $el.__io[reqId]; + if (intersectionObserver) { + intersectionObserver.disconnect(); + delete $el.__io[reqId]; + } +} +const API_UPX2PX = "upx2px"; +const Upx2pxProtocol = [ + { + name: "upx", + type: [Number, String], + required: true + } +]; +const EPS = 1e-4; +const BASE_DEVICE_WIDTH = 750; +let isIOS = false; +let deviceWidth = 0; +let deviceDPR = 0; +function checkDeviceWidth() { + const {platform, pixelRatio: pixelRatio2, windowWidth} = getBaseSystemInfo(); + deviceWidth = windowWidth; + deviceDPR = pixelRatio2; + isIOS = platform === "ios"; +} +const upx2px = /* @__PURE__ */ defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => { + if (deviceWidth === 0) { + checkDeviceWidth(); + } + number = Number(number); + if (number === 0) { + return 0; + } + let result = number / BASE_DEVICE_WIDTH * (newDeviceWidth || deviceWidth); + if (result < 0) { + result = -result; + } + result = Math.floor(result + EPS); + if (result === 0) { + if (deviceDPR === 1 || !isIOS) { + result = 1; + } else { + result = 0.5; } } -}; -const _sfc_main$n = { - name: "Audio", - mixins: [subscriber], - props: { - id: { - type: String, - default: "" - }, - src: { - type: String, - default: "" - }, - loop: { - type: [Boolean, String], - default: false - }, - controls: { - type: [Boolean, String], - default: false - }, - poster: { - type: String, - default: "" - }, - name: { - type: String, - default: "" - }, - author: { - type: String, - default: "" + return number < 0 ? -result : result; +}, Upx2pxProtocol); +var HOOKS; +(function(HOOKS2) { + HOOKS2["INVOKE"] = "invoke"; + HOOKS2["SUCCESS"] = "success"; + HOOKS2["FAIL"] = "fail"; + HOOKS2["COMPLETE"] = "complete"; + HOOKS2["RETURN_VALUE"] = "returnValue"; +})(HOOKS || (HOOKS = {})); +const globalInterceptors = {}; +const scopedInterceptors = {}; +const API_ADD_INTERCEPTOR = "addInterceptor"; +const API_REMOVE_INTERCEPTOR = "removeInterceptor"; +const AddInterceptorProtocol = [ + { + name: "method", + type: [String, Object], + required: true + } +]; +const RemoveInterceptorProtocol = AddInterceptorProtocol; +function mergeInterceptorHook(interceptors, interceptor) { + Object.keys(interceptor).forEach((hook) => { + if (isFunction(interceptor[hook])) { + interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]); } - }, - data() { - return { - playing: false, - currentTime: this.getTime(0) - }; - }, - watch: { - src(val) { - if (this.$refs.audio) { - this.$refs.audio.src = this.$getRealPath(val); - } + }); +} +function removeInterceptorHook(interceptors, interceptor) { + if (!interceptors || !interceptor) { + return; + } + Object.keys(interceptor).forEach((hook) => { + if (isFunction(interceptor[hook])) { + removeHook(interceptors[hook], interceptor[hook]); } - }, - mounted() { - const audio = this.$refs.audio; - audio.addEventListener("error", ($event) => { - this.playing = false; - this.$trigger("error", $event, {}); - }); - audio.addEventListener("play", ($event) => { - this.playing = true; - this.$trigger("play", $event, {}); - }); - audio.addEventListener("pause", ($event) => { - this.playing = false; - this.$trigger("pause", $event, {}); - }); - audio.addEventListener("ended", ($event) => { - this.playing = false; - this.$trigger("ended", $event, {}); - }); - audio.addEventListener("timeupdate", ($event) => { - var currentTime = audio.currentTime; - this.currentTime = this.getTime(currentTime); - var duration = audio.duration; - this.$trigger("timeupdate", $event, { - currentTime, - duration - }); - }); - audio.src = this.$getRealPath(this.src); - }, - methods: { - _handleSubscribe({ - type, - data = {} - }) { - var audio = this.$refs.audio; - switch (type) { - case "setSrc": - audio.src = this.$getRealPath(data.src); - this.$emit("update:src", data.src); - break; - case "play": - audio.play(); - break; - case "pause": - audio.pause(); - break; - case "seek": - audio.currentTime = data.position; - break; - } - }, - trigger() { - if (this.playing) { - this.$refs.audio.pause(); - } else { - this.$refs.audio.play(); - } - }, - getTime(time) { - var h = Math.floor(time / 3600); - var m = Math.floor(time % 3600 / 60); - var s = Math.floor(time % 3600 % 60); - h = (h < 10 ? "0" : "") + h; - m = (m < 10 ? "0" : "") + m; - s = (s < 10 ? "0" : "") + s; - var str = m + ":" + s; - if (h !== "00") { - str = h + ":" + str; - } - return str; + }); +} +function mergeHook(parentVal, childVal) { + const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal; + return res ? dedupeHooks(res) : res; +} +function dedupeHooks(hooks) { + const res = []; + for (let i2 = 0; i2 < hooks.length; i2++) { + if (res.indexOf(hooks[i2]) === -1) { + res.push(hooks[i2]); } } -}; -const _hoisted_1$d = {class: "uni-audio-default"}; -const _hoisted_2$7 = {class: "uni-audio-right"}; -const _hoisted_3$3 = {class: "uni-audio-time"}; -const _hoisted_4$3 = {class: "uni-audio-info"}; -const _hoisted_5$2 = {class: "uni-audio-name"}; -const _hoisted_6$2 = {class: "uni-audio-author"}; -function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-audio", mergeProps({ - id: $props.id, - controls: !!$props.controls - }, _ctx.$attrs), [ - createVNode("audio", { - ref: "audio", - loop: $props.loop, - style: {display: "none"} - }, null, 8, ["loop"]), - createVNode("div", _hoisted_1$d, [ - createVNode("div", { - style: "background-image: url(" + _ctx.$getRealPath($props.poster) + ");", - class: "uni-audio-left" - }, [ - createVNode("div", { - class: [{play: !$data.playing, pause: $data.playing}, "uni-audio-button"], - onClick: _cache[1] || (_cache[1] = (...args) => $options.trigger && $options.trigger(...args)) - }, null, 2) - ], 4), - createVNode("div", _hoisted_2$7, [ - createVNode("div", _hoisted_3$3, toDisplayString($data.currentTime), 1), - createVNode("div", _hoisted_4$3, [ - createVNode("div", _hoisted_5$2, toDisplayString($props.name), 1), - createVNode("div", _hoisted_6$2, toDisplayString($props.author), 1) - ]) - ]) - ]) - ], 16, ["id", "controls"]); + return res; } -_sfc_main$n.render = _sfc_render$m; -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 removeHook(hooks, hook) { + if (!hooks) { + return; } -}; -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)); - }); + const index2 = hooks.indexOf(hook); + if (index2 !== -1) { + hooks.splice(index2, 1); } - function onTouchstart(evt) { - if (evt._hoverPropagationStopped) { - return; - } - if (!props.hoverClass || props.hoverClass === "none" || props.disabled) { - return; +} +const addInterceptor = /* @__PURE__ */ defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => { + if (typeof method === "string" && isPlainObject(interceptor)) { + mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); + } else if (isPlainObject(method)) { + mergeInterceptorHook(globalInterceptors, method); + } +}, AddInterceptorProtocol); +const removeInterceptor = /* @__PURE__ */ defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => { + if (typeof method === "string") { + if (isPlainObject(interceptor)) { + removeInterceptorHook(scopedInterceptors[method], interceptor); + } else { + delete scopedInterceptors[method]; } - if (evt.touches.length > 1) { - return; + } else if (isPlainObject(method)) { + removeInterceptorHook(globalInterceptors, method); + } +}, RemoveInterceptorProtocol); +const promiseInterceptor = { + returnValue(res) { + if (!isPromise(res)) { + return res; } - if (props.hoverStopPropagation) { - evt._hoverPropagationStopped = true; - } - hoverTouch = true; - hoverStartTimer = setTimeout(() => { - hovering.value = true; - if (!hoverTouch) { - hoverReset(); - } - }, parseInt(props.hoverStartTime)); + return res.then((res2) => { + return res2[1]; + }).catch((res2) => { + return res2[0]; + }); } - function onTouchend() { - hoverTouch = false; - if (hovering.value) { - hoverReset(); - } +}; +const RATES = [0.5, 0.8, 1, 1.25, 1.5, 2]; +class VideoContext { + constructor(id2, vm) { + this.id = id2; + this.vm = vm; } - function onTouchcancel() { - hoverTouch = false; - hovering.value = false; - clearTimeout(hoverStartTimer); + play() { + operateVideoPlayer(this.id, this.vm, "play"); } - return { - hovering, - binding: { - onTouchstart, - onTouchend, - onTouchcancel + pause() { + operateVideoPlayer(this.id, this.vm, "pause"); + } + stop() { + operateVideoPlayer(this.id, this.vm, "stop"); + } + seek(position) { + operateVideoPlayer(this.id, this.vm, "seek", { + position + }); + } + sendDanmu(args) { + operateVideoPlayer(this.id, this.vm, "sendDanmu", args); + } + playbackRate(rate) { + if (!~RATES.indexOf(rate)) { + rate = 1; } - }; + operateVideoPlayer(this.id, this.vm, "playbackRate", { + rate + }); + } + requestFullScreen(args = {}) { + operateVideoPlayer(this.id, this.vm, "requestFullScreen", args); + } + exitFullScreen() { + operateVideoPlayer(this.id, this.vm, "exitFullScreen"); + } + showStatusBar() { + operateVideoPlayer(this.id, this.vm, "showStatusBar"); + } + hideStatusBar() { + operateVideoPlayer(this.id, this.vm, "hideStatusBar"); + } } -function useBooleanAttr(props, keys) { - if (isString(keys)) { - keys = [keys]; +function createVideoContext(id2, context) { + if (context) { + return new VideoContext(id2, context); } - return keys.reduce((res, key) => { - if (props[key]) { - res[key] = true; - } - return res; - }, Object.create(null)); + return new VideoContext(id2, getCurrentPageVm()); } -const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf"); -var index$5 = defineComponent({ - name: "Form", - setup(props, { - slots, - emit - }) { - provideForm(emit); - return () => createVNode("uni-form", null, [createVNode("span", null, [slots.default && slots.default()])]); +const defaultOptions = { + thresholds: [0], + initialRatio: 0, + observeAll: false +}; +const MARGINS = ["top", "right", "bottom", "left"]; +let reqComponentObserverId = 1; +function normalizeRootMargin(margins = {}) { + return MARGINS.map((name) => `${Number(margins[name]) || 0}px`).join(" "); +} +class ServiceIntersectionObserver { + constructor(component, options) { + this._pageId = component.$page && component.$page.id; + this._component = component; + this._options = extend({}, defaultOptions, options); } -}); -function provideForm(emit) { - const fields = []; - provide(uniFormKey, { - addField(field) { - fields.push(field); - }, - removeField(field) { - fields.splice(fields.indexOf(field), 1); - }, - submit() { - emit("submit", { - detail: { - value: fields.reduce((res, field) => { - const [name, value] = field.submit(); - name && (res[name] = value); - return res; - }, Object.create(null)) - } - }); - }, - reset() { - fields.forEach((field) => field.reset()); - emit("reset"); + relativeTo(selector, margins) { + this._options.relativeToSelector = selector; + this._options.rootMargin = normalizeRootMargin(margins); + return this; + } + relativeToViewport(margins) { + this._options.relativeToSelector = void 0; + this._options.rootMargin = normalizeRootMargin(margins); + return this; + } + observe(selector, callback) { + if (!isFunction(callback)) { + return; } - }); - return fields; + this._options.selector = selector; + this._reqId = reqComponentObserverId++; + addIntersectionObserver({ + reqId: this._reqId, + component: this._component, + options: this._options, + callback + }, this._pageId); + } + disconnect() { + this._reqId && removeIntersectionObserver({reqId: this._reqId, component: this._component}, this._pageId); + } } -var index$4 = defineComponent({ - 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: "" - } - }, - setup(props, { - slots - }) { - const uniForm = inject(uniFormKey); - const { - hovering, - binding - } = useHover(props); - function onClick() { - if (props.disabled) { - return; - } - const formType = props.formType; - if (formType) { - if (!uniForm) { - return; - } - if (formType === "submit") { - uniForm.submit(); - } else if (formType === "reset") { - uniForm.reset(); - } - return; - } - } - return () => { - const hoverClass = props.hoverClass; - const booleanAttrs = useBooleanAttr(props, "disabled"); - if (hoverClass && hoverClass !== "none") { - return createVNode("uni-button", mergeProps({ - onClick, - class: hovering.value ? hoverClass : "" - }, binding, booleanAttrs), [slots.default && slots.default()], 16, ["onClick"]); - } - return createVNode("uni-button", mergeProps({ - onClick - }, booleanAttrs), [slots.default && slots.default()], 16, ["onClick"]); - }; +const createIntersectionObserver = /* @__PURE__ */ defineSyncApi("createIntersectionObserver", (context, options) => { + if (context && !context.$page) { + options = context; + context = null; } -}); -const pixelRatio = function() { - const canvas = document.createElement("canvas"); - canvas.height = canvas.width = 0; - const context = canvas.getContext("2d"); - const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; - return (window.devicePixelRatio || 1) / backingStore; -}(); -const forEach = function(obj, func) { - for (const key in obj) { - if (hasOwn$1(obj, key)) { - func(obj[key], key); - } + if (context) { + return new ServiceIntersectionObserver(context, options); } + return new ServiceIntersectionObserver(getCurrentPageVm(), options); +}); +const createSelectorQuery = () => { }; -const ratioArgs = { - fillRect: "all", - clearRect: "all", - strokeRect: "all", - moveTo: "all", - lineTo: "all", - arc: [0, 1, 2], - arcTo: "all", - bezierCurveTo: "all", - isPointinPath: "all", - isPointinStroke: "all", - quadraticCurveTo: "all", - rect: "all", - translate: "all", - createRadialGradient: "all", - createLinearGradient: "all", - setTransform: [4, 5] +const API_ON_TAB_BAR_MID_BUTTON_TAP = "onTabBarMidButtonTap"; +const onTabBarMidButtonTap = /* @__PURE__ */ defineOnApi(API_ON_TAB_BAR_MID_BUTTON_TAP, () => { +}); +const API_CAN_I_USE = "canIUse"; +const CanIUseProtocol = [ + { + name: "schema", + type: String, + required: true + } +]; +const API_MAKE_PHONE_CALL = "makePhoneCall"; +const MakePhoneCallProtocol = { + phoneNumber: { + type: String, + required: true, + validator(phoneNumber) { + if (!phoneNumber) { + return "parameter error: parameter.phoneNumber should not be empty String;"; + } + } + } }; -const proto = CanvasRenderingContext2D.prototype; -proto.drawImageByCanvas = function(_super) { - return function(canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) { - if (!this.__hidpi__) { - return _super.apply(this, arguments); +const API_OPEN_DOCUMENT = "openDocument"; +const OpenDocumentProtocol = { + filePath: { + type: String, + required: true + }, + fileType: { + type: String + } +}; +const API_GET_IMAGE_INFO = "getImageInfo"; +const GetImageInfoOptions = { + formatArgs: { + src(src, params) { + params.src = getRealPath(src); } - srcx *= pixelRatio; - srcy *= pixelRatio; - srcw *= pixelRatio; - srch *= pixelRatio; - desx *= pixelRatio; - desy *= pixelRatio; - desw = isScale ? desw * pixelRatio : desw; - desh = isScale ? desh * pixelRatio : desh; - _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh); - }; -}(proto.drawImage); -if (pixelRatio !== 1) { - forEach(ratioArgs, function(value, key) { - proto[key] = function(_super) { - return function() { - if (!this.__hidpi__) { - return _super.apply(this, arguments); - } - let args = Array.prototype.slice.call(arguments); - if (value === "all") { - args = args.map(function(a2) { - return a2 * pixelRatio; - }); - } else if (Array.isArray(value)) { - for (let i2 = 0; i2 < value.length; i2++) { - args[value[i2]] *= pixelRatio; - } - } - return _super.apply(this, args); - }; - }(proto[key]); + } +}; +const GetImageInfoProtocol = { + src: { + type: String, + required: true + } +}; +const API_REQUEST = "request"; +const METHOD = [ + "GET", + "OPTIONS", + "HEAD", + "POST", + "PUT", + "DELETE", + "TRACE", + "CONNECT" +]; +const DEFAULT_METHOD = "GET"; +const dataType = { + JSON: "json" +}; +const RESPONSE_TYPE = ["text", "arraybuffer"]; +const DEFAULT_RESPONSE_TYPE = "text"; +const encode = encodeURIComponent; +function stringifyQuery(url, data) { + let str = url.split("#"); + const hash = str[1] || ""; + str = str[0].split("?"); + let query = str[1] || ""; + url = str[0]; + const search = query.split("&").filter((item) => item); + const params = {}; + search.forEach((item) => { + const part = item.split("="); + params[part[0]] = part[1]; }); - proto.stroke = function(_super) { - return function() { - if (!this.__hidpi__) { - return _super.apply(this, arguments); - } - this.lineWidth *= pixelRatio; - _super.apply(this, arguments); - this.lineWidth /= pixelRatio; - }; - }(proto.stroke); - proto.fillText = function(_super) { - return function() { - if (!this.__hidpi__) { - return _super.apply(this, arguments); - } - const args = Array.prototype.slice.call(arguments); - args[1] *= pixelRatio; - args[2] *= pixelRatio; - var font2 = this.font; - this.font = font2.replace(/(\d+\.?\d*)(px|em|rem|pt)/g, function(w, m, u) { - return m * pixelRatio + u; - }); - _super.apply(this, args); - this.font = font2; - }; - }(proto.fillText); - proto.strokeText = function(_super) { - return function() { - if (!this.__hidpi__) { - return _super.apply(this, arguments); - } - var args = Array.prototype.slice.call(arguments); - args[1] *= pixelRatio; - args[2] *= pixelRatio; - var font2 = this.font; - this.font = font2.replace(/(\d+\.?\d*)(px|em|rem|pt)/g, function(w, m, u) { - return m * pixelRatio + u; - }); - _super.apply(this, args); - this.font = font2; - }; - }(proto.strokeText); - proto.drawImage = function(_super) { - return function() { - if (!this.__hidpi__) { - return _super.apply(this, arguments); + for (const key in data) { + if (hasOwn$1(data, key)) { + let v2 = data[key]; + if (typeof v2 === "undefined" || v2 === null) { + v2 = ""; + } else if (isPlainObject(v2)) { + v2 = JSON.stringify(v2); } - this.scale(pixelRatio, pixelRatio); - _super.apply(this, arguments); - this.scale(1 / pixelRatio, 1 / pixelRatio); - }; - }(proto.drawImage); -} -function wrapper(canvas) { - canvas.width = canvas.offsetWidth * pixelRatio; - canvas.height = canvas.offsetHeight * pixelRatio; - canvas.getContext("2d").__hidpi__ = true; -} -var index_vue_vue_type_style_index_0_lang$b = "\nuni-canvas {\r\n width: 300px;\r\n height: 150px;\r\n display: block;\r\n position: relative;\n}\nuni-canvas > canvas {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\n}\r\n"; -function resolveColor(color) { - color = color.slice(0); - color[3] = color[3] / 255; - return "rgba(" + color.join(",") + ")"; -} -function processTouches(target, touches) { - return [].map.call(touches, (touch) => { - var boundingClientRect = target.getBoundingClientRect(); - return { - identifier: touch.identifier, - x: touch.clientX - boundingClientRect.left, - y: touch.clientY - boundingClientRect.top - }; - }); -} -var tempCanvas; -function getTempCanvas(width = 0, height = 0) { - if (!tempCanvas) { - tempCanvas = document.createElement("canvas"); + params[encode(key)] = encode(v2); + } } - tempCanvas.width = width; - tempCanvas.height = height; - return tempCanvas; + query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&"); + return url + (query ? "?" + query : "") + (hash ? "#" + hash : ""); } -const _sfc_main$m = { - name: "Canvas", - mixins: [subscriber], - props: { - canvasId: { - type: String, - default: "" - }, - disableScroll: { - type: [Boolean, String], - default: false - } +const RequestProtocol = { + method: { + type: String }, - data() { - return { - actionsWaiting: false - }; + data: { + type: [Object, String, Array, ArrayBuffer] }, - computed: { - id() { - return this.canvasId; - }, - _listeners() { - var $listeners = Object.assign({}, this.$listeners); - var events = ["touchstart", "touchmove", "touchend"]; - events.forEach((event2) => { - var existing = $listeners[event2]; - var eventHandler = []; - if (existing) { - eventHandler.push(($event) => { - this.$trigger(event2, Object.assign({}, $event, { - touches: processTouches($event.currentTarget, $event.touches), - changedTouches: processTouches($event.currentTarget, $event.changedTouches) - })); - }); - } - if (this.disableScroll && event2 === "touchmove") { - eventHandler.push(this._touchmove); - } - $listeners[event2] = eventHandler; - }); - return $listeners; - } + url: { + type: String, + required: true }, - created() { - this._actionsDefer = []; - this._images = {}; + header: { + type: Object }, - mounted() { - this._resize({ - width: this.$refs.sensor.$el.offsetWidth, - height: this.$refs.sensor.$el.offsetHeight - }); + dataType: { + type: String }, - beforeDestroy() { - const canvas = this.$refs.canvas; - canvas.height = canvas.width = 0; + responseType: { + type: String }, - methods: { - _handleSubscribe({ - type, - data = {} - }) { - var method = this[type]; - if (type.indexOf("_") !== 0 && typeof method === "function") { - method(data); + withCredentials: { + type: Boolean + } +}; +const RequestOptions = { + formatArgs: { + method(value, params) { + params.method = (value || "").toUpperCase(); + if (METHOD.indexOf(params.method) === -1) { + params.method = DEFAULT_METHOD; } }, - _resize() { - var canvas = this.$refs.canvas; - if (canvas.width > 0 && canvas.height > 0) { - var context = canvas.getContext("2d"); - var imageData = context.getImageData(0, 0, canvas.width, canvas.height); - wrapper(this.$refs.canvas); - context.putImageData(imageData, 0, 0); - } else { - wrapper(this.$refs.canvas); + data(value, params) { + params.data = value || ""; + }, + url(value, params) { + if (params.method === DEFAULT_METHOD && isPlainObject(params.data) && Object.keys(params.data).length) { + params.url = stringifyQuery(value, params.data); } }, - _touchmove(event2) { - event2.preventDefault(); + header(value, params) { + const header = params.header = value || {}; + if (params.method !== DEFAULT_METHOD) { + if (!Object.keys(header).find((key) => key.toLowerCase() === "content-type")) { + header["Content-Type"] = "application/json"; + } + } }, - actionsChanged({ - actions, - reserve, - callbackId - }) { - var self = this; - if (!actions) { - return; + dataType(value, params) { + params.dataType = (value || dataType.JSON).toLowerCase(); + }, + responseType(value, params) { + params.responseType = (value || "").toLowerCase(); + if (RESPONSE_TYPE.indexOf(params.responseType) === -1) { + params.responseType = DEFAULT_RESPONSE_TYPE; } - if (this.actionsWaiting) { - this._actionsDefer.push([actions, reserve, callbackId]); - return; + } + } +}; +function encodeQueryString(url) { + if (typeof url !== "string") { + return url; + } + const index2 = url.indexOf("?"); + if (index2 === -1) { + return url; + } + const query = url.substr(index2 + 1).trim().replace(/^(\?|#|&)/, ""); + if (!query) { + return url; + } + url = url.substr(0, index2); + const params = []; + query.split("&").forEach((param) => { + const parts = param.replace(/\+/g, " ").split("="); + const key = parts.shift(); + const val = parts.length > 0 ? parts.join("=") : ""; + params.push(key + "=" + encodeURIComponent(val)); + }); + return params.length ? url + "?" + params.join("&") : url; +} +const ANIMATION_IN = [ + "slide-in-right", + "slide-in-left", + "slide-in-top", + "slide-in-bottom", + "fade-in", + "zoom-out", + "zoom-fade-out", + "pop-in", + "none" +]; +const ANIMATION_OUT = [ + "slide-out-right", + "slide-out-left", + "slide-out-top", + "slide-out-bottom", + "fade-out", + "zoom-in", + "zoom-fade-in", + "pop-out", + "none" +]; +const BaseRouteProtocol = { + url: { + type: String, + required: true + } +}; +const API_NAVIGATE_TO = "navigateTo"; +const API_REDIRECT_TO = "redirectTo"; +const API_RE_LAUNCH = "reLaunch"; +const API_SWITCH_TAB = "switchTab"; +const API_NAVIGATE_BACK = "navigateBack"; +const API_PRELOAD_PAGE = "preloadPage"; +const API_UN_PRELOAD_PAGE = "unPreloadPage"; +const NavigateToProtocol = extend({}, BaseRouteProtocol, createAnimationProtocol(ANIMATION_IN)); +const NavigateBackProtocol = extend({ + delta: { + type: Number + } +}, createAnimationProtocol(ANIMATION_OUT)); +const RedirectToProtocol = BaseRouteProtocol; +const ReLaunchProtocol = BaseRouteProtocol; +const SwitchTabProtocol = BaseRouteProtocol; +const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO); +const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO); +const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH); +const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB); +const NavigateBackOptions = { + formatArgs: { + delta(delta, params) { + delta = parseInt(delta) || 1; + params.delta = Math.min(getCurrentPages().length - 1, delta); + } + } +}; +function createAnimationProtocol(animationTypes) { + return { + animationType: { + type: String, + validator(type) { + if (type && animationTypes.indexOf(type) === -1) { + return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)"; + } } - var canvas = this.$refs.canvas; - var c2d = canvas.getContext("2d"); - if (!reserve) { - c2d.fillStyle = "#000000"; - c2d.strokeStyle = "#000000"; - c2d.shadowColor = "#000000"; - c2d.shadowBlur = 0; - c2d.shadowOffsetX = 0; - c2d.shadowOffsetY = 0; - c2d.setTransform(1, 0, 0, 1, 0, 0); - c2d.clearRect(0, 0, canvas.width, canvas.height); + }, + animationDuration: { + type: Number + } + }; +} +let navigatorLock; +function beforeRoute() { + navigatorLock = ""; +} +function createRouteOptions(type) { + return { + formatArgs: { + url: createNormalizeUrl(type) + }, + beforeAll: beforeRoute + }; +} +function createNormalizeUrl(type) { + return function normalizeUrl(url, params) { + url = getRealRoute(url); + const pagePath = url.split("?")[0]; + if (url === "/") { + url = __uniRoutes[0].path; + } + const routeOptions = __uniRoutes.find(({path}) => path === pagePath); + if (!routeOptions) { + return "page `" + url + "` is not found"; + } + if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) { + if (routeOptions.meta.isTabBar) { + return `can not ${type} a tabbar page`; } - this.preloadImage(actions); - for (let index2 = 0; index2 < actions.length; index2++) { - const action = actions[index2]; - let method = action.method; - const data = action.data; - if (/^set/.test(method) && method !== "setTransform") { - const method1 = method[3].toLowerCase() + method.slice(4); - let color; - if (method1 === "fillStyle" || method1 === "strokeStyle") { - if (data[0] === "normal") { - color = resolveColor(data[1]); - } else if (data[0] === "linear") { - const LinearGradient = c2d.createLinearGradient(...data[1]); - data[2].forEach(function(data2) { - const offset = data2[0]; - const color2 = resolveColor(data2[1]); - LinearGradient.addColorStop(offset, color2); - }); - color = LinearGradient; - } else if (data[0] === "radial") { - const x = data[1][0]; - const y = data[1][1]; - const r = data[1][2]; - const LinearGradient = c2d.createRadialGradient(x, y, 0, x, y, r); - data[2].forEach(function(data2) { - const offset = data2[0]; - const color2 = resolveColor(data2[1]); - LinearGradient.addColorStop(offset, color2); - }); - color = LinearGradient; - } else if (data[0] === "pattern") { - const loaded = this.checkImageLoaded(data[1], actions.slice(index2 + 1), callbackId, function(image2) { - if (image2) { - c2d[method1] = c2d.createPattern(image2, data[2]); - } - }); - if (!loaded) { - break; - } - continue; - } - c2d[method1] = color; - } else if (method1 === "globalAlpha") { - c2d[method1] = data[0] / 255; - } else if (method1 === "shadow") { - var _ = ["shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor"]; - data.forEach(function(color_, method_) { - c2d[_[method_]] = _[method_] === "shadowColor" ? resolveColor(color_) : color_; - }); - } else { - if (method1 === "fontSize") { - c2d.font = c2d.font.replace(/\d+\.?\d*px/, data[0] + "px"); - } else { - if (method1 === "lineDash") { - c2d.setLineDash(data[0]); - c2d.lineDashOffset = data[1] || 0; - } else { - if (method1 === "textBaseline") { - if (data[0] === "normal") { - data[0] = "alphabetic"; - } - c2d[method1] = data[0]; - } else { - c2d[method1] = data[0]; - } - } - } - } - } else if (method === "fillPath" || method === "strokePath") { - method = method.replace(/Path/, ""); - c2d.beginPath(); - data.forEach(function(data_) { - c2d[data_.method].apply(c2d, data_.data); - }); - c2d[method](); - } else if (method === "fillText") { - c2d.fillText.apply(c2d, data); - } else if (method === "drawImage") { - var A = function() { - var dataArray = [...data]; - var url = dataArray[0]; - var otherData = dataArray.slice(1); - self._images = self._images || {}; - if (!self.checkImageLoaded(url, actions.slice(index2 + 1), callbackId, function(image2) { - if (image2) { - c2d.drawImage.apply(c2d, [image2].concat([...otherData.slice(4, 8)], [...otherData.slice(0, 4)])); - } - })) - return "break"; - }(); - if (A === "break") { - break; - } - } else { - if (method === "clip") { - data.forEach(function(data_) { - c2d[data_.method].apply(c2d, data_.data); - }); - c2d.clip(); - } else { - c2d[method].apply(c2d, data); - } + } else if (type === API_SWITCH_TAB) { + if (!routeOptions.meta.isTabBar) { + return "can not switch to no-tabBar page"; + } + } + if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") { + url = pagePath; + } + if (routeOptions.meta.isEntry) { + url = url.replace(routeOptions.path, "/"); + } + params.url = encodeQueryString(url); + if (type === API_UN_PRELOAD_PAGE) { + return; + } else if (type === API_PRELOAD_PAGE) { + if (routeOptions.meta.isTabBar) { + const pages = getCurrentPages(true); + const tabBarPagePath = routeOptions.path.substr(1); + if (pages.find((page) => page.route === tabBarPagePath)) { + return "tabBar page `" + tabBarPagePath + "` already exists"; } } - if (!this.actionsWaiting && callbackId) { - UniViewJSBridge.publishHandler("onDrawCanvas", { - callbackId, - data: { - errMsg: "drawCanvas:ok" - } - }, this.$page.id); + return; + } + if (navigatorLock === url && params.openType !== "appLaunch") { + return `${navigatorLock} locked`; + } + if (__uniConfig.ready) { + navigatorLock = url; + } + }; +} +const IndexProtocol = { + index: { + type: Number, + required: true + } +}; +const IndexOptions = { + beforeInvoke() { + const pageMeta = getCurrentPageMeta(); + if (pageMeta && !pageMeta.isTabBar) { + return "not TabBar page"; + } + }, + formatArgs: { + index(value) { + if (!__uniConfig.tabBar.list[value]) { + return "tabbar item not found"; } - }, - preloadImage: function(actions) { - var self = this; - actions.forEach(function(action) { - var method = action.method; - var data = action.data; - var src = ""; - if (method === "drawImage") { - src = data[0]; - src = self.$getRealPath(src); - data[0] = src; - } else if (method === "setFillStyle" && data[0] === "pattern") { - src = data[1]; - src = self.$getRealPath(src); - data[1] = src; - } - if (src && !self._images[src]) { - loadImage(); - } - function loadImage() { - self._images[src] = new Image(); - self._images[src].onload = function() { - self._images[src].ready = true; - }; - function loadBlob(blob) { - self._images[src].src = (window.URL || window.webkitURL).createObjectURL(blob); - } - function loadFile(path) { - var bitmap = new plus.nativeObj.Bitmap("bitmap" + Date.now()); - bitmap.load(path, function() { - self._images[src].src = bitmap.toBase64Data(); - bitmap.clear(); - }, function() { - bitmap.clear(); - console.error("preloadImage error"); - }); - } - function loadUrl(url) { - function plusDownload() { - plus.downloader.createDownload(url, { - filename: "_doc/uniapp_temp/download/" - }, function(d, status) { - if (status === 200) { - loadFile(d.filename); - } else { - self._images[src].src = src; - } - }).start(); - } - var xhr = new XMLHttpRequest(); - xhr.open("GET", url, true); - xhr.responseType = "blob"; - xhr.onload = function() { - if (this.status === 200) { - loadBlob(this.response); - } - }; - xhr.onerror = window.plus ? plusDownload : function() { - self._images[src].src = src; - }; - xhr.send(); - } - if (window.plus && (!window.webkit || !window.webkit.messageHandlers)) { - self._images[src].src = src; - } else { - if (window.plus && src.indexOf("http://") !== 0 && src.indexOf("https://") !== 0 && !/^data:.*,.*/.test(src)) { - loadFile(src); - } else if (/^data:.*,.*/.test(src)) { - self._images[src].src = src; - } else { - loadUrl(src); - } - } - } - }); - }, - checkImageLoaded: function(src, actions, callbackId, fn) { - var self = this; - var image2 = this._images[src]; - if (image2.ready) { - fn(image2); - return true; - } else { - this._actionsDefer.unshift([actions, true]); - this.actionsWaiting = true; - image2.onload = function() { - image2.ready = true; - fn(image2); - self.actionsWaiting = false; - var actions2 = self._actionsDefer.slice(0); - self._actionsDefer = []; - for (var action = actions2.shift(); action; ) { - self.actionsChanged({ - actions: action[0], - reserve: action[1], - callbackId - }); - action = actions2.shift(); - } - }; - return false; + } + } +}; +const SetTabBarItemProtocol = extend({ + text: { + type: String + }, + iconPath: { + type: String + }, + selectedIconPath: { + type: String + }, + pagePath: { + type: String + } +}, IndexProtocol); +const SetTabBarItemOptions = IndexOptions; +const SetTabBarStyleProtocol = { + color: { + type: String + }, + selectedColor: { + type: String + }, + backgroundColor: { + type: String + }, + backgroundImage: { + type: String + }, + backgroundRepeat: { + type: String + }, + borderStyle: { + type: String + } +}; +const GRADIENT_RE = /^(linear|radial)-gradient\(.+?\);?$/; +const SetTabBarStyleOptions = { + formatArgs: { + backgroundImage(value, params) { + if (value && !GRADIENT_RE.test(value)) { + params.backgroundImage = getRealPath(value); } }, - getImageData({ - x = 0, - y = 0, - width, - height, - destWidth, - destHeight, - hidpi = true, - callbackId - }) { - var imgData; - var canvas = this.$refs.canvas; - if (!width) { - width = canvas.offsetWidth - x; - } - if (!height) { - height = canvas.offsetHeight - y; + borderStyle(value, params) { + if (value) { + params.borderStyle = value === "white" ? "white" : "black"; } - try { - if (!hidpi) { - if (!destWidth && !destHeight) { - destWidth = Math.round(width * pixelRatio); - destHeight = Math.round(height * pixelRatio); - } else if (!destWidth) { - destWidth = Math.round(width / height * destHeight); - } else if (!destHeight) { - destHeight = Math.round(height / width * destWidth); - } - } else { - destWidth = width; - destHeight = height; - } - const newCanvas = getTempCanvas(destWidth, destHeight); - const context = newCanvas.getContext("2d"); - context.__hidpi__ = true; - context.drawImageByCanvas(canvas, x, y, width, height, 0, 0, destWidth, destHeight, false); - imgData = context.getImageData(0, 0, destWidth, destHeight); - newCanvas.height = newCanvas.width = 0; - context.__hidpi__ = false; - } catch (error) { - if (!callbackId) { - return; - } - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasGetImageData:fail" - } - }, this.$page.id); - return; - } - if (!callbackId) { - return { - data: Array.prototype.slice.call(imgData.data), - width: destWidth, - height: destHeight - }; - } else { - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasGetImageData:ok", - data: [...imgData.data], - width: destWidth, - height: destHeight - } - }, this.$page.id); - } - }, - putImageData({ - data, - x, - y, - width, - height, - callbackId - }) { - try { - if (!height) { - height = Math.round(data.length / 4 / width); - } - const canvas = getTempCanvas(width, height); - const context = canvas.getContext("2d"); - context.putImageData(new ImageData(new Uint8ClampedArray(data), width, height), 0, 0); - this.$refs.canvas.getContext("2d").drawImage(canvas, x, y, width, height); - canvas.height = canvas.width = 0; - } catch (error) { - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasPutImageData:fail" - } - }, this.$page.id); - return; - } - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasPutImageData:ok" - } - }, this.$page.id); - }, - getDataUrl({ - x = 0, - y = 0, - width, - height, - destWidth, - destHeight, - hidpi = true, - fileType, - qualit, - callbackId - }) { - const res = this.getImageData({ - x, - y, - width, - height, - destWidth, - destHeight, - hidpi - }); - if (!res.data || !res.data.length) { - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasGetDataUrl:fail" - } - }, this.$page.id); - return; - } - let imgData; - try { - imgData = new ImageData(new Uint8ClampedArray(res.data), res.width, res.height); - } catch (error) { - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasGetDataUrl:fail" - } - }, this.$page.id); - return; - } - destWidth = res.width; - destHeight = res.height; - const canvas = getTempCanvas(destWidth, destHeight); - const c2d = canvas.getContext("2d"); - c2d.putImageData(imgData, 0, 0); - let base64 = canvas.toDataURL("image/png"); - canvas.height = canvas.width = 0; - const img = new Image(); - img.onload = () => { - const canvas2 = getTempCanvas(destWidth, destHeight); - if (fileType === "jpeg" || fileType === "jpg") { - fileType = "jpeg"; - c2d.fillStyle = "#fff"; - c2d.fillRect(0, 0, destWidth, destHeight); - } - c2d.drawImage(img, 0, 0); - base64 = canvas2.toDataURL(`image/${fileType}`, qualit); - canvas2.height = canvas2.width = 0; - UniViewJSBridge.publishHandler("onCanvasMethodCallback", { - callbackId, - data: { - errMsg: "canvasGetDataUrl:ok", - base64 - } - }, this.$page.id); - }; - img.src = base64; } } }; -const _hoisted_1$c = { - ref: "canvas", - width: "300", - height: "150" +const HideTabBarProtocol = { + animation: { + type: Boolean, + default: false + } }; -const _hoisted_2$6 = {style: {position: "absolute", top: "0", left: "0", width: "100%", height: "100%", overflow: "hidden"}}; -function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) { - const _component_v_uni_resize_sensor = resolveComponent("v-uni-resize-sensor"); - return openBlock(), createBlock("uni-canvas", mergeProps({ - "canvas-id": $props.canvasId, - "disable-scroll": $props.disableScroll - }, toHandlers($options._listeners)), [ - createVNode("canvas", _hoisted_1$c, null, 512), - createVNode("div", _hoisted_2$6, [ - renderSlot(_ctx.$slots, "default") - ]), - createVNode(_component_v_uni_resize_sensor, { - ref: "sensor", - onResize: $options._resize - }, null, 8, ["onResize"]) - ], 16, ["canvas-id", "disable-scroll"]); -} -_sfc_main$m.render = _sfc_render$l; -const _sfc_main$l = { - name: "Checkbox", - mixins: [emitter, listeners], - props: { - checked: { - type: [Boolean, String], - default: false - }, - id: { - type: String, - default: "" - }, - disabled: { - type: [Boolean, String], - default: false - }, - color: { - type: String, - default: "#007aff" - }, - value: { - type: String, - default: "" - } - }, - data() { - return { - checkboxChecked: this.checked, - checkboxValue: this.value - }; - }, - watch: { - checked(val) { - this.checkboxChecked = val; - }, - value(val) { - this.checkboxValue = val; - } - }, - listeners: { - "label-click": "_onClick", - "@label-click": "_onClick" - }, - created() { - this.$dispatch("CheckboxGroup", "uni-checkbox-group-update", { - type: "add", - vm: this - }); - this.$dispatch("Form", "uni-form-group-update", { - type: "add", - vm: this - }); - }, - beforeDestroy() { - this.$dispatch("CheckboxGroup", "uni-checkbox-group-update", { - type: "remove", - vm: this - }); - this.$dispatch("Form", "uni-form-group-update", { - type: "remove", - vm: this - }); - }, - methods: { - _onClick($event) { - if (this.disabled) { - return; +const ShowTabBarProtocol = HideTabBarProtocol; +const HideTabBarRedDotProtocol = IndexProtocol; +const HideTabBarRedDotOptions = IndexOptions; +const ShowTabBarRedDotProtocol = IndexProtocol; +const ShowTabBarRedDotOptions = IndexOptions; +const RemoveTabBarBadgeProtocol = IndexProtocol; +const RemoveTabBarBadgeOptions = IndexOptions; +const SetTabBarBadgeProtocol = extend({ + text: { + type: String, + required: true + } +}, IndexProtocol); +const SetTabBarBadgeOptions = { + formatArgs: extend({ + text(value, params) { + if (getLen(value) >= 4) { + params.text = "..."; } - this.checkboxChecked = !this.checkboxChecked; - this.$dispatch("CheckboxGroup", "uni-checkbox-change", $event); - }, - _resetFormData() { - this.checkboxChecked = false; } - } + }, IndexOptions.formatArgs) }; -const _hoisted_1$b = {class: "uni-checkbox-wrapper"}; -function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-checkbox", mergeProps({disabled: $props.disabled}, _ctx.$attrs, { - onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) - }), [ - createVNode("div", _hoisted_1$b, [ - createVNode("div", { - class: [[$data.checkboxChecked ? "uni-checkbox-input-checked" : ""], "uni-checkbox-input"], - style: {color: $props.color} - }, null, 6), - renderSlot(_ctx.$slots, "default") - ]) - ], 16, ["disabled"]); -} -_sfc_main$l.render = _sfc_render$k; -var index_vue_vue_type_style_index_0_lang$a = "\nuni-checkbox-group[hidden] {\r\n display: none;\n}\r\n"; -const _sfc_main$k = { - name: "CheckboxGroup", - mixins: [emitter, listeners], - props: { - name: { - type: String, - default: "" - } - }, - data() { - return { - checkboxList: [] - }; - }, - listeners: { - "@checkbox-change": "_changeHandler", - "@checkbox-group-update": "_checkboxGroupUpdateHandler" - }, - created() { - this.$dispatch("Form", "uni-form-group-update", { - type: "add", - vm: this - }); - }, - beforeDestroy() { - this.$dispatch("Form", "uni-form-group-update", { - type: "remove", - vm: this - }); - }, - methods: { - _changeHandler($event) { - const value = []; - this.checkboxList.forEach((vm) => { - if (vm.checkboxChecked) { - value.push(vm.value); - } - }); - this.$trigger("change", $event, { - value - }); - }, - _checkboxGroupUpdateHandler($event) { - if ($event.type === "add") { - this.checkboxList.push($event.vm); - } else { - const index2 = this.checkboxList.indexOf($event.vm); - this.checkboxList.splice(index2, 1); - } - }, - _getFormData() { - const data = {}; - if (this.name !== "") { - const value = []; - this.checkboxList.forEach((vm) => { - if (vm.checkboxChecked) { - value.push(vm.value); - } - }); - data.value = value; - data.key = this.name; - } - return data; - } +const initIntersectionObserverPolyfill = function() { + if (typeof window !== "object") { + return; } -}; -function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-checkbox-group", _ctx.$attrs, [ - renderSlot(_ctx.$slots, "default") - ], 16); -} -_sfc_main$k.render = _sfc_render$j; -var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/; -var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/; -var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; -var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"); -var block = makeMap("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"); -var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"); -var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"); -var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"); -var special = makeMap("script,style"); -function HTMLParser(html, handler) { - var index2; - var chars2; - var match; - var stack = []; - var last = html; - stack.last = function() { - return this[this.length - 1]; - }; - while (html) { - chars2 = true; - if (!stack.last() || !special[stack.last()]) { - if (html.indexOf(""); - if (index2 >= 0) { - if (handler.comment) { - handler.comment(html.substring(4, index2)); - } - html = html.substring(index2 + 3); - chars2 = false; - } - } else if (html.indexOf("]*>"), function(all, text3) { - text3 = text3.replace(/|/g, "$1$2"); - if (handler.chars) { - handler.chars(text3); + if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) { + if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) { + Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", { + get: function() { + return this.intersectionRatio > 0; } - return ""; }); - parseEndTag("", stack.last()); } - if (html == last) { - throw "Parse Error: " + html; + return; + } + function getFrameElement(doc) { + try { + return doc.defaultView && doc.defaultView.frameElement || null; + } catch (e2) { + return null; } - last = html; } - parseEndTag(); - function parseStartTag(tag, tagName, rest, unary) { - tagName = tagName.toLowerCase(); - if (block[tagName]) { - while (stack.last() && inline[stack.last()]) { - parseEndTag("", stack.last()); - } + var document2 = function(startDoc) { + var doc = startDoc; + var frame = getFrameElement(doc); + while (frame) { + doc = frame.ownerDocument; + frame = getFrameElement(doc); } - if (closeSelf[tagName] && stack.last() == tagName) { - parseEndTag("", tagName); + return doc; + }(window.document); + var registry = []; + var crossOriginUpdater = null; + var crossOriginRect = null; + function IntersectionObserverEntry(entry) { + this.time = entry.time; + this.target = entry.target; + this.rootBounds = ensureDOMRect(entry.rootBounds); + this.boundingClientRect = ensureDOMRect(entry.boundingClientRect); + this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect()); + this.isIntersecting = !!entry.intersectionRect; + var targetRect = this.boundingClientRect; + var targetArea = targetRect.width * targetRect.height; + var intersectionRect = this.intersectionRect; + var intersectionArea = intersectionRect.width * intersectionRect.height; + if (targetArea) { + this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4)); + } else { + this.intersectionRatio = this.isIntersecting ? 1 : 0; } - unary = empty[tagName] || !!unary; - if (!unary) { - stack.push(tagName); + } + function IntersectionObserver2(callback, opt_options) { + var options = opt_options || {}; + if (typeof callback != "function") { + throw new Error("callback must be a function"); } - if (handler.start) { - var attrs2 = []; - rest.replace(attr, function(match2, name) { - var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : ""; - attrs2.push({ - name, - value, - escaped: value.replace(/(^|[^\\])"/g, '$1\\"') - }); - }); - if (handler.start) { - handler.start(tagName, attrs2, unary); - } + if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) { + throw new Error("root must be a Document or Element"); } + this._checkForIntersections = throttle2(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT); + this._callback = callback; + this._observationTargets = []; + this._queuedEntries = []; + this._rootMarginValues = this._parseRootMargin(options.rootMargin); + this.thresholds = this._initThresholds(options.threshold); + this.root = options.root || null; + this.rootMargin = this._rootMarginValues.map(function(margin) { + return margin.value + margin.unit; + }).join(" "); + this._monitoringDocuments = []; + this._monitoringUnsubscribes = []; } - function parseEndTag(tag, tagName) { - if (!tagName) { - var pos = 0; - } else { - for (var pos = stack.length - 1; pos >= 0; pos--) { - if (stack[pos] == tagName) { - break; - } - } - } - if (pos >= 0) { - for (var i2 = stack.length - 1; i2 >= pos; i2--) { - if (handler.end) { - handler.end(stack[i2]); + IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100; + IntersectionObserver2.prototype.POLL_INTERVAL = null; + IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true; + IntersectionObserver2._setupCrossOriginUpdater = function() { + if (!crossOriginUpdater) { + crossOriginUpdater = function(boundingClientRect, intersectionRect) { + if (!boundingClientRect || !intersectionRect) { + crossOriginRect = getEmptyRect(); + } else { + crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect); } - } - stack.length = pos; + registry.forEach(function(observer) { + observer._checkForIntersections(); + }); + }; } - } -} -function makeMap(str) { - var obj = {}; - var items = str.split(","); - for (var i2 = 0; i2 < items.length; i2++) { - obj[items[i2]] = true; - } - return obj; -} -function divider(Quill) { - const BlockEmbed = Quill.import("blots/block/embed"); - class Divider extends BlockEmbed { - } - Divider.blotName = "divider"; - Divider.tagName = "HR"; - return { - "formats/divider": Divider + return crossOriginUpdater; }; -} -function ins(Quill) { - const Inline = Quill.import("blots/inline"); - class Ins extends Inline { - } - Ins.blotName = "ins"; - Ins.tagName = "INS"; - return { - "formats/ins": Ins + IntersectionObserver2._resetCrossOriginUpdater = function() { + crossOriginUpdater = null; + crossOriginRect = null; }; -} -function align(Quill) { - const {Scope, Attributor} = Quill.import("parchment"); - const config = { - scope: Scope.BLOCK, - whitelist: ["left", "right", "center", "justify"] + IntersectionObserver2.prototype.observe = function(target) { + var isTargetAlreadyObserved = this._observationTargets.some(function(item) { + return item.element == target; + }); + if (isTargetAlreadyObserved) { + return; + } + if (!(target && target.nodeType == 1)) { + throw new Error("target must be an Element"); + } + this._registerInstance(); + this._observationTargets.push({element: target, entry: null}); + this._monitorIntersections(target.ownerDocument); + this._checkForIntersections(); }; - const AlignStyle = new Attributor.Style("align", "text-align", config); - return { - "formats/align": AlignStyle + IntersectionObserver2.prototype.unobserve = function(target) { + this._observationTargets = this._observationTargets.filter(function(item) { + return item.element != target; + }); + this._unmonitorIntersections(target.ownerDocument); + if (this._observationTargets.length == 0) { + this._unregisterInstance(); + } }; -} -function direction(Quill) { - const {Scope, Attributor} = Quill.import("parchment"); - const config = { - scope: Scope.BLOCK, - whitelist: ["rtl"] + IntersectionObserver2.prototype.disconnect = function() { + this._observationTargets = []; + this._unmonitorAllIntersections(); + this._unregisterInstance(); }; - const DirectionStyle = new Attributor.Style("direction", "direction", config); - return { - "formats/direction": DirectionStyle + IntersectionObserver2.prototype.takeRecords = function() { + var records = this._queuedEntries.slice(); + this._queuedEntries = []; + return records; }; -} -function list(Quill) { - const Parchment = Quill.import("parchment"); - const Container = Quill.import("blots/container"); - const ListItem = Quill.import("formats/list/item"); - class List extends Container { - static create(value) { - const tagName = value === "ordered" ? "OL" : "UL"; - const node = super.create(tagName); - if (value === "checked" || value === "unchecked") { - node.setAttribute("data-checked", value === "checked"); + IntersectionObserver2.prototype._initThresholds = function(opt_threshold) { + var threshold = opt_threshold || [0]; + if (!Array.isArray(threshold)) + threshold = [threshold]; + return threshold.sort().filter(function(t2, i2, a2) { + if (typeof t2 != "number" || isNaN(t2) || t2 < 0 || t2 > 1) { + throw new Error("threshold must be a number between 0 and 1 inclusively"); } - return node; + return t2 !== a2[i2 - 1]; + }); + }; + IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) { + var marginString = opt_rootMargin || "0px"; + var margins = marginString.split(/\s+/).map(function(margin) { + var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin); + if (!parts) { + throw new Error("rootMargin must be specified in pixels or percent"); + } + return {value: parseFloat(parts[1]), unit: parts[2]}; + }); + margins[1] = margins[1] || margins[0]; + margins[2] = margins[2] || margins[0]; + margins[3] = margins[3] || margins[1]; + return margins; + }; + IntersectionObserver2.prototype._monitorIntersections = function(doc) { + var win = doc.defaultView; + if (!win) { + return; } - static formats(domNode) { - if (domNode.tagName === "OL") - return "ordered"; - if (domNode.tagName === "UL") { - if (domNode.hasAttribute("data-checked")) { - return domNode.getAttribute("data-checked") === "true" ? "checked" : "unchecked"; - } else { - return "bullet"; - } + if (this._monitoringDocuments.indexOf(doc) != -1) { + return; + } + var callback = this._checkForIntersections; + var monitoringInterval = null; + var domObserver = null; + if (this.POLL_INTERVAL) { + monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL); + } else { + addEvent(win, "resize", callback, true); + addEvent(doc, "scroll", callback, true); + if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) { + domObserver = new win.MutationObserver(callback); + domObserver.observe(doc, { + attributes: true, + childList: true, + characterData: true, + subtree: true + }); } - return void 0; } - constructor(domNode) { - super(domNode); - const listEventHandler = (e2) => { - if (e2.target.parentNode !== domNode) - return; - const format = this.statics.formats(domNode); - const blot = Parchment.find(e2.target); - if (format === "checked") { - blot.format("list", "unchecked"); - } else if (format === "unchecked") { - blot.format("list", "checked"); + this._monitoringDocuments.push(doc); + this._monitoringUnsubscribes.push(function() { + var win2 = doc.defaultView; + if (win2) { + if (monitoringInterval) { + win2.clearInterval(monitoringInterval); } - }; - domNode.addEventListener("click", listEventHandler); - } - format(name, value) { - if (this.children.length > 0) { - this.children.tail.format(name, value); + removeEvent(win2, "resize", callback, true); + } + removeEvent(doc, "scroll", callback, true); + if (domObserver) { + domObserver.disconnect(); + } + }); + var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; + if (doc != rootDoc) { + var frame = getFrameElement(doc); + if (frame) { + this._monitorIntersections(frame.ownerDocument); } } - formats() { - return {[this.statics.blotName]: this.statics.formats(this.domNode)}; + }; + IntersectionObserver2.prototype._unmonitorIntersections = function(doc) { + var index2 = this._monitoringDocuments.indexOf(doc); + if (index2 == -1) { + return; } - insertBefore(blot, ref2) { - if (blot instanceof ListItem) { - super.insertBefore(blot, ref2); - } else { - const index2 = ref2 == null ? this.length() : ref2.offset(this); - const after = this.split(index2); - after.parent.insertBefore(blot, after); + var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; + var hasDependentTargets = this._observationTargets.some(function(item) { + var itemDoc = item.element.ownerDocument; + if (itemDoc == doc) { + return true; } - } - optimize(context) { - super.optimize(context); - const next = this.next; - if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute("data-checked") === this.domNode.getAttribute("data-checked")) { - next.moveChildren(this); - next.remove(); + while (itemDoc && itemDoc != rootDoc) { + var frame2 = getFrameElement(itemDoc); + itemDoc = frame2 && frame2.ownerDocument; + if (itemDoc == doc) { + return true; + } } + return false; + }); + if (hasDependentTargets) { + return; } - replace(target) { - if (target.statics.blotName !== this.statics.blotName) { - const item = Parchment.create(this.statics.defaultChild); - target.moveChildren(item); - this.appendChild(item); + var unsubscribe = this._monitoringUnsubscribes[index2]; + this._monitoringDocuments.splice(index2, 1); + this._monitoringUnsubscribes.splice(index2, 1); + unsubscribe(); + if (doc != rootDoc) { + var frame = getFrameElement(doc); + if (frame) { + this._unmonitorIntersections(frame.ownerDocument); } - super.replace(target); } - } - List.blotName = "list"; - List.scope = Parchment.Scope.BLOCK_BLOT; - List.tagName = ["OL", "UL"]; - List.defaultChild = "list-item"; - List.allowedChildren = [ListItem]; - return { - "formats/list": List - }; -} -function background(Quill) { - const {Scope} = Quill.import("parchment"); - const BackgroundStyle = Quill.import("formats/background"); - const BackgroundColorStyle = new BackgroundStyle.constructor("backgroundColor", "background-color", { - scope: Scope.INLINE - }); - return { - "formats/backgroundColor": BackgroundColorStyle }; -} -function box(Quill) { - const {Scope, Attributor} = Quill.import("parchment"); - const config = { - scope: Scope.BLOCK - }; - const margin = [ - "margin", - "marginTop", - "marginBottom", - "marginLeft", - "marginRight" - ]; - const padding = [ - "padding", - "paddingTop", - "paddingBottom", - "paddingLeft", - "paddingRight" - ]; - const result = {}; - margin.concat(padding).forEach((name) => { - result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), config); - }); - return result; -} -function font(Quill) { - const {Scope, Attributor} = Quill.import("parchment"); - const config = { - scope: Scope.INLINE + IntersectionObserver2.prototype._unmonitorAllIntersections = function() { + var unsubscribes = this._monitoringUnsubscribes.slice(0); + this._monitoringDocuments.length = 0; + this._monitoringUnsubscribes.length = 0; + for (var i2 = 0; i2 < unsubscribes.length; i2++) { + unsubscribes[i2](); + } }; - const font2 = [ - "font", - "fontSize", - "fontStyle", - "fontVariant", - "fontWeight", - "fontFamily" - ]; - const result = {}; - font2.forEach((name) => { - result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), config); - }); - return result; -} -function text(Quill) { - const {Scope, Attributor} = Quill.import("parchment"); - const text2 = [ - { - name: "lineHeight", - scope: Scope.BLOCK - }, - { - name: "letterSpacing", - scope: Scope.INLINE - }, - { - name: "textDecoration", - scope: Scope.INLINE - }, - { - name: "textIndent", - scope: Scope.BLOCK + IntersectionObserver2.prototype._checkForIntersections = function() { + if (!this.root && crossOriginUpdater && !crossOriginRect) { + return; } - ]; - const result = {}; - text2.forEach(({name, scope}) => { - result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), { - scope - }); - }); - return result; -} -function image(Quill) { - const Image2 = Quill.import("formats/image"); - const ATTRIBUTES = [ - "alt", - "height", - "width", - "data-custom", - "class", - "data-local" - ]; - Image2.sanitize = (url) => url; - Image2.formats = function formats(domNode) { - return ATTRIBUTES.reduce(function(formats2, attribute) { - if (domNode.hasAttribute(attribute)) { - formats2[attribute] = domNode.getAttribute(attribute); + var rootIsInDom = this._rootIsInDom(); + var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect(); + this._observationTargets.forEach(function(item) { + var target = item.element; + var targetRect = getBoundingClientRect(target); + var rootContainsTarget = this._rootContainsTarget(target); + var oldEntry = item.entry; + var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect); + var rootBounds = null; + if (!this._rootContainsTarget(target)) { + rootBounds = getEmptyRect(); + } else if (!crossOriginUpdater || this.root) { + rootBounds = rootRect; } - return formats2; - }, {}); - }; - const format = Image2.prototype.format; - Image2.prototype.format = function(name, value) { - if (ATTRIBUTES.indexOf(name) > -1) { - if (value) { - this.domNode.setAttribute(name, value); + var newEntry = item.entry = new IntersectionObserverEntry({ + time: now(), + target, + boundingClientRect: targetRect, + rootBounds, + intersectionRect + }); + if (!oldEntry) { + this._queuedEntries.push(newEntry); + } else if (rootIsInDom && rootContainsTarget) { + if (this._hasCrossedThreshold(oldEntry, newEntry)) { + this._queuedEntries.push(newEntry); + } } else { - this.domNode.removeAttribute(name); + if (oldEntry && oldEntry.isIntersecting) { + this._queuedEntries.push(newEntry); + } } - } else { - format.call(this, name, value); + }, this); + if (this._queuedEntries.length) { + this._callback(this.takeRecords(), this); } }; -} -function register(Quill) { - const formats = { - divider, - ins, - align, - direction, - list, - background, - box, - font, - text, - image - }; - const options = {}; - Object.values(formats).forEach((value) => Object.assign(options, value(Quill))); - Quill.register(options, true); -} -var editor_css_vue_type_style_index_0_src_lang = ".ql-container {\n display: block;\n position: relative;\n box-sizing: border-box;\n -webkit-user-select: text;\n user-select: text;\n outline: none;\n overflow: hidden;\n width: 100%;\n height: 200px;\n min-height: 200px;\n}\n.ql-container[hidden] {\n display: none;\n}\n.ql-container .ql-editor {\n position: relative;\n font-size: inherit;\n line-height: inherit;\n font-family: inherit;\n min-height: inherit;\n width: 100%;\n height: 100%;\n padding: 0;\n overflow-x: hidden;\n overflow-y: auto;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n -webkit-overflow-scrolling: touch;\n}\n.ql-container .ql-editor::-webkit-scrollbar {\n width: 0 !important;\n}\n.ql-container .ql-editor.scroll-disabled {\n overflow: hidden;\n}\n.ql-container .ql-image-overlay {\n display: flex;\n position: absolute;\n box-sizing: border-box;\n border: 1px dashed #ccc;\n justify-content: center;\n align-items: center;\n -webkit-user-select: none;\n user-select: none;\n}\n.ql-container .ql-image-overlay .ql-image-size {\n position: absolute;\n padding: 4px 8px;\n text-align: center;\n background-color: #fff;\n color: #888;\n border: 1px solid #ccc;\n box-sizing: border-box;\n opacity: 0.8;\n right: 4px;\n top: 4px;\n font-size: 12px;\n display: inline-block;\n width: auto;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar {\n position: relative;\n text-align: center;\n box-sizing: border-box;\n background: #000;\n border-radius: 5px;\n color: #fff;\n font-size: 0;\n min-height: 24px;\n z-index: 100;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar span {\n display: inline-block;\n cursor: pointer;\n padding: 5px;\n font-size: 12px;\n border-right: 1px solid #fff;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar span:last-child {\n border-right: 0;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar span.triangle-up {\n padding: 0;\n position: absolute;\n top: -12px;\n left: 50%;\n transform: translatex(-50%);\n width: 0;\n height: 0;\n border-width: 6px;\n border-style: solid;\n border-color: transparent transparent black transparent;\n}\n.ql-container .ql-image-overlay .ql-image-handle {\n position: absolute;\n height: 12px;\n width: 12px;\n border-radius: 50%;\n border: 1px solid #ccc;\n box-sizing: border-box;\n background: #fff;\n}\n.ql-container img {\n display: inline-block;\n max-width: 100%;\n}\n.ql-clipboard p {\n margin: 0;\n padding: 0;\n}\n.ql-editor {\n box-sizing: border-box;\n height: 100%;\n outline: none;\n overflow-y: auto;\n tab-size: 4;\n -moz-tab-size: 4;\n text-align: left;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n.ql-editor > * {\n cursor: text;\n}\n.ql-editor p,\n.ql-editor ol,\n.ql-editor ul,\n.ql-editor pre,\n.ql-editor blockquote,\n.ql-editor h1,\n.ql-editor h2,\n.ql-editor h3,\n.ql-editor h4,\n.ql-editor h5,\n.ql-editor h6 {\n margin: 0;\n padding: 0;\n counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol > li,\n.ql-editor ul > li {\n list-style-type: none;\n}\n.ql-editor ul > li::before {\n content: '\\2022';\n}\n.ql-editor ul[data-checked=true],\n.ql-editor ul[data-checked=false] {\n pointer-events: none;\n}\n.ql-editor ul[data-checked=true] > li *,\n.ql-editor ul[data-checked=false] > li * {\n pointer-events: all;\n}\n.ql-editor ul[data-checked=true] > li::before,\n.ql-editor ul[data-checked=false] > li::before {\n color: #777;\n cursor: pointer;\n pointer-events: all;\n}\n.ql-editor ul[data-checked=true] > li::before {\n content: '\\2611';\n}\n.ql-editor ul[data-checked=false] > li::before {\n content: '\\2610';\n}\n.ql-editor li::before {\n display: inline-block;\n white-space: nowrap;\n width: 2em;\n}\n.ql-editor ol li {\n counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n counter-increment: list-0;\n}\n.ql-editor ol li:before {\n content: counter(list-0, decimal) '. ';\n}\n.ql-editor ol li.ql-indent-1 {\n counter-increment: list-1;\n}\n.ql-editor ol li.ql-indent-1:before {\n content: counter(list-1, lower-alpha) '. ';\n}\n.ql-editor ol li.ql-indent-1 {\n counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-2 {\n counter-increment: list-2;\n}\n.ql-editor ol li.ql-indent-2:before {\n content: counter(list-2, lower-roman) '. ';\n}\n.ql-editor ol li.ql-indent-2 {\n counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-3 {\n counter-increment: list-3;\n}\n.ql-editor ol li.ql-indent-3:before {\n content: counter(list-3, decimal) '. ';\n}\n.ql-editor ol li.ql-indent-3 {\n counter-reset: list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-4 {\n counter-increment: list-4;\n}\n.ql-editor ol li.ql-indent-4:before {\n content: counter(list-4, lower-alpha) '. ';\n}\n.ql-editor ol li.ql-indent-4 {\n counter-reset: list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-5 {\n counter-increment: list-5;\n}\n.ql-editor ol li.ql-indent-5:before {\n content: counter(list-5, lower-roman) '. ';\n}\n.ql-editor ol li.ql-indent-5 {\n counter-reset: list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-6 {\n counter-increment: list-6;\n}\n.ql-editor ol li.ql-indent-6:before {\n content: counter(list-6, decimal) '. ';\n}\n.ql-editor ol li.ql-indent-6 {\n counter-reset: list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-7 {\n counter-increment: list-7;\n}\n.ql-editor ol li.ql-indent-7:before {\n content: counter(list-7, lower-alpha) '. ';\n}\n.ql-editor ol li.ql-indent-7 {\n counter-reset: list-8 list-9;\n}\n.ql-editor ol li.ql-indent-8 {\n counter-increment: list-8;\n}\n.ql-editor ol li.ql-indent-8:before {\n content: counter(list-8, lower-roman) '. ';\n}\n.ql-editor ol li.ql-indent-8 {\n counter-reset: list-9;\n}\n.ql-editor ol li.ql-indent-9 {\n counter-increment: list-9;\n}\n.ql-editor ol li.ql-indent-9:before {\n content: counter(list-9, decimal) '. ';\n}\n.ql-editor .ql-indent-1:not(.ql-direction-rtl) {\n padding-left: 2em;\n}\n.ql-editor li.ql-indent-1:not(.ql-direction-rtl) {\n padding-left: 2em;\n}\n.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right {\n padding-right: 2em;\n}\n.ql-editor li.ql-indent-1.ql-direction-rtl.ql-align-right {\n padding-right: 2em;\n}\n.ql-editor .ql-indent-2:not(.ql-direction-rtl) {\n padding-left: 4em;\n}\n.ql-editor li.ql-indent-2:not(.ql-direction-rtl) {\n padding-left: 4em;\n}\n.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right {\n padding-right: 4em;\n}\n.ql-editor li.ql-indent-2.ql-direction-rtl.ql-align-right {\n padding-right: 4em;\n}\n.ql-editor .ql-indent-3:not(.ql-direction-rtl) {\n padding-left: 6em;\n}\n.ql-editor li.ql-indent-3:not(.ql-direction-rtl) {\n padding-left: 6em;\n}\n.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right {\n padding-right: 6em;\n}\n.ql-editor li.ql-indent-3.ql-direction-rtl.ql-align-right {\n padding-right: 6em;\n}\n.ql-editor .ql-indent-4:not(.ql-direction-rtl) {\n padding-left: 8em;\n}\n.ql-editor li.ql-indent-4:not(.ql-direction-rtl) {\n padding-left: 8em;\n}\n.ql-editor .ql-indent-4.ql-direction-rtl.ql-align-right {\n padding-right: 8em;\n}\n.ql-editor li.ql-indent-4.ql-direction-rtl.ql-align-right {\n padding-right: 8em;\n}\n.ql-editor .ql-indent-5:not(.ql-direction-rtl) {\n padding-left: 10em;\n}\n.ql-editor li.ql-indent-5:not(.ql-direction-rtl) {\n padding-left: 10em;\n}\n.ql-editor .ql-indent-5.ql-direction-rtl.ql-align-right {\n padding-right: 10em;\n}\n.ql-editor li.ql-indent-5.ql-direction-rtl.ql-align-right {\n padding-right: 10em;\n}\n.ql-editor .ql-indent-6:not(.ql-direction-rtl) {\n padding-left: 12em;\n}\n.ql-editor li.ql-indent-6:not(.ql-direction-rtl) {\n padding-left: 12em;\n}\n.ql-editor .ql-indent-6.ql-direction-rtl.ql-align-right {\n padding-right: 12em;\n}\n.ql-editor li.ql-indent-6.ql-direction-rtl.ql-align-right {\n padding-right: 12em;\n}\n.ql-editor .ql-indent-7:not(.ql-direction-rtl) {\n padding-left: 14em;\n}\n.ql-editor li.ql-indent-7:not(.ql-direction-rtl) {\n padding-left: 14em;\n}\n.ql-editor .ql-indent-7.ql-direction-rtl.ql-align-right {\n padding-right: 14em;\n}\n.ql-editor li.ql-indent-7.ql-direction-rtl.ql-align-right {\n padding-right: 14em;\n}\n.ql-editor .ql-indent-8:not(.ql-direction-rtl) {\n padding-left: 16em;\n}\n.ql-editor li.ql-indent-8:not(.ql-direction-rtl) {\n padding-left: 16em;\n}\n.ql-editor .ql-indent-8.ql-direction-rtl.ql-align-right {\n padding-right: 16em;\n}\n.ql-editor li.ql-indent-8.ql-direction-rtl.ql-align-right {\n padding-right: 16em;\n}\n.ql-editor .ql-indent-9:not(.ql-direction-rtl) {\n padding-left: 18em;\n}\n.ql-editor li.ql-indent-9:not(.ql-direction-rtl) {\n padding-left: 18em;\n}\n.ql-editor .ql-indent-9.ql-direction-rtl.ql-align-right {\n padding-right: 18em;\n}\n.ql-editor li.ql-indent-9.ql-direction-rtl.ql-align-right {\n padding-right: 18em;\n}\n.ql-editor .ql-direction-rtl {\n direction: rtl;\n text-align: inherit;\n}\n.ql-editor .ql-align-center {\n text-align: center;\n}\n.ql-editor .ql-align-justify {\n text-align: justify;\n}\n.ql-editor .ql-align-right {\n text-align: right;\n}\n.ql-editor.ql-blank::before {\n color: rgba(0, 0, 0, 0.6);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n position: absolute;\n}\n.ql-container.ql-disabled .ql-editor ul[data-checked] > li::before {\n pointer-events: none;\n}\n.ql-clipboard {\n left: -100000px;\n height: 1px;\n overflow-y: hidden;\n position: absolute;\n top: 50%;\n}\n"; -var index_vue_vue_type_style_index_1_lang = "\n"; -const _sfc_main$j = { - name: "Editor", - mixins: [subscriber, emitter, keyboard], - props: { - id: { - type: String, - default: "" - }, - readOnly: { - type: [Boolean, String], - default: false - }, - placeholder: { - type: String, - default: "" - }, - showImgSize: { - type: [Boolean, String], - default: false - }, - showImgToolbar: { - type: [Boolean, String], - default: false - }, - showImgResize: { - type: [Boolean, String], - default: false - } - }, - data() { - return { - quillReady: false - }; - }, - computed: {}, - watch: { - readOnly(value) { - if (this.quillReady) { - const quill = this.quill; - quill.enable(!value); - if (!value) { - quill.blur(); + IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) { + if (window.getComputedStyle(target).display == "none") + return; + var intersectionRect = targetRect; + var parent = getParentNode(target); + var atRoot = false; + while (!atRoot && parent) { + var parentRect = null; + var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {}; + if (parentComputedStyle.display == "none") + return null; + if (parent == this.root || parent.nodeType == 9) { + atRoot = true; + if (parent == this.root || parent == document2) { + if (crossOriginUpdater && !this.root) { + if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) { + parent = null; + parentRect = null; + intersectionRect = null; + } else { + parentRect = crossOriginRect; + } + } else { + parentRect = rootRect; + } + } else { + var frame = getParentNode(parent); + var frameRect = frame && getBoundingClientRect(frame); + var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect); + if (frameRect && frameIntersect) { + parent = frame; + parentRect = convertFromParentRect(frameRect, frameIntersect); + } else { + parent = null; + intersectionRect = null; + } + } + } else { + var doc = parent.ownerDocument; + if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") { + parentRect = getBoundingClientRect(parent); } } - }, - placeholder(value) { - if (this.quillReady) { - this.quill.root.setAttribute("data-placeholder", value); + if (parentRect) { + intersectionRect = computeRectIntersection(parentRect, intersectionRect); } + if (!intersectionRect) + break; + parent = parent && getParentNode(parent); } - }, - mounted() { - const imageResizeModules = []; - if (this.showImgSize) { - imageResizeModules.push("DisplaySize"); - } - if (this.showImgToolbar) { - imageResizeModules.push("Toolbar"); - } - if (this.showImgResize) { - imageResizeModules.push("Resize"); + return intersectionRect; + }; + IntersectionObserver2.prototype._getRootRect = function() { + var rootRect; + if (this.root && !isDoc(this.root)) { + rootRect = getBoundingClientRect(this.root); + } else { + var doc = isDoc(this.root) ? this.root : document2; + var html = doc.documentElement; + var body = doc.body; + rootRect = { + top: 0, + left: 0, + right: html.clientWidth || body.clientWidth, + width: html.clientWidth || body.clientWidth, + bottom: html.clientHeight || body.clientHeight, + height: html.clientHeight || body.clientHeight + }; } - this.loadQuill(() => { - if (imageResizeModules.length) { - this.loadImageResizeModule(() => { - this.initQuill(imageResizeModules); - }); - } else { - this.initQuill(imageResizeModules); - } + return this._expandRectByRootMargin(rootRect); + }; + IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) { + var margins = this._rootMarginValues.map(function(margin, i2) { + return margin.unit == "px" ? margin.value : margin.value * (i2 % 2 ? rect.width : rect.height) / 100; }); - }, - methods: { - _handleSubscribe({ - type, - data - }) { - const {options, callbackId} = data; - const quill = this.quill; - const Quill = window.Quill; - let res; - let range; - let errMsg; - if (this.quillReady) { - switch (type) { - case "format": - { - let {name = "", value = false} = options; - range = quill.getSelection(true); - let format = quill.getFormat(range)[name] || false; - if (["bold", "italic", "underline", "strike", "ins"].includes(name)) { - value = !format; - } else if (name === "direction") { - value = value === "rtl" && format ? false : value; - const align2 = quill.getFormat(range).align; - if (value === "rtl" && !align2) { - quill.format("align", "right", Quill.sources.USER); - } else if (!value && align2 === "right") { - quill.format("align", false, Quill.sources.USER); - } - } else if (name === "indent") { - const rtl = quill.getFormat(range).direction === "rtl"; - value = value === "+1"; - if (rtl) { - value = !value; - } - value = value ? "+1" : "-1"; - } else { - if (name === "list") { - value = value === "check" ? "unchecked" : value; - format = format === "checked" ? "unchecked" : format; - } - value = format && format !== (value || false) || !format && value ? value : !format; - } - quill.format(name, value, Quill.sources.USER); - } - break; - case "insertDivider": - range = quill.getSelection(true); - quill.insertText(range.index, "\n", Quill.sources.USER); - quill.insertEmbed(range.index + 1, "divider", true, Quill.sources.USER); - quill.setSelection(range.index + 2, Quill.sources.SILENT); - break; - case "insertImage": - { - range = quill.getSelection(true); - const {src = "", alt = "", width = "", height = "", extClass = "", data: data2 = {}} = options; - const path = this.$getRealPath(src); - quill.insertEmbed(range.index, "image", path, Quill.sources.USER); - const local = /^(file|blob):/.test(path) ? path : false; - quill.formatText(range.index, 1, "data-local", local); - quill.formatText(range.index, 1, "alt", alt); - quill.formatText(range.index, 1, "width", width); - quill.formatText(range.index, 1, "height", height); - quill.formatText(range.index, 1, "class", extClass); - quill.formatText(range.index, 1, "data-custom", Object.keys(data2).map((key) => `${key}=${data2[key]}`).join("&")); - quill.setSelection(range.index + 1, Quill.sources.SILENT); - } - break; - case "insertText": - { - range = quill.getSelection(true); - const {text: text2 = ""} = options; - quill.insertText(range.index, text2, Quill.sources.USER); - quill.setSelection(range.index + text2.length, 0, Quill.sources.SILENT); - } - break; - case "setContents": - { - const {delta, html} = options; - if (typeof delta === "object") { - quill.setContents(delta, Quill.sources.SILENT); - } else if (typeof html === "string") { - quill.setContents(this.html2delta(html), Quill.sources.SILENT); - } else { - errMsg = "contents is missing"; - } - } - break; - case "getContents": - res = this.getContents(); - break; - case "clear": - quill.setContents([]); - break; - case "removeFormat": - { - range = quill.getSelection(true); - const parchment = Quill.import("parchment"); - if (range.length) { - quill.removeFormat(range, Quill.sources.USER); - } else { - Object.keys(quill.getFormat(range)).forEach((key) => { - if (parchment.query(key, parchment.Scope.INLINE)) { - quill.format(key, false); - } - }); - } - } - break; - case "undo": - quill.history.undo(); - break; - case "redo": - quill.history.redo(); - break; - } - this.updateStatus(range); - } else { - errMsg = "not ready"; - } - if (callbackId) { - UniViewJSBridge.publishHandler("onEditorMethodCallback", { - callbackId, - data: Object.assign({}, res, { - errMsg: `${type}:${errMsg ? "fail " + errMsg : "ok"}` - }) - }, this.$page.id); - } - }, - loadQuill(callback) { - if (typeof window.Quill === "function") { - if (typeof callback === "function") { - callback(); - } - return; - } - const script = document.createElement("script"); - script.src = window.plus ? "./__uniappquill.js" : "https://unpkg.com/quill@1.3.7/dist/quill.min.js"; - document.body.appendChild(script); - script.onload = callback; - }, - loadImageResizeModule(callback) { - if (typeof window.ImageResize === "function") { - if (typeof callback === "function") { - callback(); - } - return; + var newRect = { + top: rect.top - margins[0], + right: rect.right + margins[1], + bottom: rect.bottom + margins[2], + left: rect.left - margins[3] + }; + newRect.width = newRect.right - newRect.left; + newRect.height = newRect.bottom - newRect.top; + return newRect; + }; + IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) { + var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1; + var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1; + if (oldRatio === newRatio) + return; + for (var i2 = 0; i2 < this.thresholds.length; i2++) { + var threshold = this.thresholds[i2]; + if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) { + return true; } - const script = document.createElement("script"); - script.src = window.plus ? "./__uniappquillimageresize.js" : "https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js"; - document.body.appendChild(script); - script.onload = callback; - }, - initQuill(imageResizeModules) { - const Quill = window.Quill; - register(Quill); - const options = { - toolbar: false, - readOnly: this.readOnly, - placeholder: this.placeholder, - modules: {} - }; - if (imageResizeModules.length) { - Quill.register("modules/ImageResize", window.ImageResize.default); - options.modules.ImageResize = { - modules: imageResizeModules - }; + } + }; + IntersectionObserver2.prototype._rootIsInDom = function() { + return !this.root || containsDeep(document2, this.root); + }; + IntersectionObserver2.prototype._rootContainsTarget = function(target) { + var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; + return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument); + }; + IntersectionObserver2.prototype._registerInstance = function() { + if (registry.indexOf(this) < 0) { + registry.push(this); + } + }; + IntersectionObserver2.prototype._unregisterInstance = function() { + var index2 = registry.indexOf(this); + if (index2 != -1) + registry.splice(index2, 1); + }; + function now() { + return window.performance && performance.now && performance.now(); + } + function throttle2(fn, timeout) { + var timer = null; + return function() { + if (!timer) { + timer = setTimeout(function() { + fn(); + timer = null; + }, timeout); } - const quill = this.quill = new Quill(this.$el, options); - const $el = quill.root; - const events = ["focus", "blur", "input"]; - events.forEach((name) => { - $el.addEventListener(name, ($event) => { - if (name === "input") { - $event.stopPropagation(); - } else { - this.$trigger(name, $event, this.getContents()); - } - }); - }); - quill.on(Quill.events.TEXT_CHANGE, () => { - this.$trigger("input", {}, this.getContents()); - }); - quill.on(Quill.events.SELECTION_CHANGE, this.updateStatus.bind(this)); - quill.on(Quill.events.SCROLL_OPTIMIZE, () => { - const range = quill.selection.getRange()[0]; - this.updateStatus(range); - }); - quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => { - if (this.skipMatcher) { - return delta; - } - delta.ops = delta.ops.filter(({insert}) => typeof insert === "string").map(({insert}) => ({insert})); - return delta; - }); - this.initKeyboard($el); - this.quillReady = true; - this.$trigger("ready", event, {}); - }, - getContents() { - const quill = this.quill; - const html = quill.root.innerHTML; - const text2 = quill.getText(); - const delta = quill.getContents(); - return { - html, - text: text2, - delta - }; - }, - html2delta(html) { - const tags = ["span", "strong", "b", "ins", "em", "i", "u", "a", "del", "s", "sub", "sup", "img", "div", "p", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ol", "ul", "li", "br"]; - let content = ""; - let disable; - HTMLParser(html, { - start: function(tag, attrs2, unary) { - if (!tags.includes(tag)) { - disable = !unary; - return; - } - disable = false; - const arrts = attrs2.map(({name, value}) => `${name}="${value}"`).join(" "); - const start = `<${tag} ${arrts} ${unary ? "/" : ""}>`; - content += start; - }, - end: function(tag) { - if (!disable) { - content += ``; - } - }, - chars: function(text2) { - if (!disable) { - content += text2; - } - } - }); - this.skipMatcher = true; - const delta = this.quill.clipboard.convert(content); - this.skipMatcher = false; - return delta; - }, - updateStatus(range) { - const status = range ? this.quill.getFormat(range) : {}; - const keys = Object.keys(status); - if (keys.length !== Object.keys(this.__status || {}).length || keys.find((key) => status[key] !== this.__status[key])) { - this.__status = status; - this.$trigger("statuschange", {}, status); - } - } + }; } -}; -function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) { - return openBlock(), createBlock("uni-editor", mergeProps({ - id: $props.id, - class: "ql-container" - }, _ctx.$attrs), null, 16, ["id"]); -} -_sfc_main$j.render = _sfc_render$i; -const INFO_COLOR = "#10aeff"; -const WARN_COLOR = "#f76260"; -const GREY_COLOR = "#b2b2b2"; -const CANCEL_COLOR = "#f43530"; -const ICONS = { - 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 + function addEvent(node, event2, fn, opt_useCapture) { + if (typeof node.addEventListener == "function") { + node.addEventListener(event2, fn, opt_useCapture || false); + } else if (typeof node.attachEvent == "function") { + node.attachEvent("on" + event2, fn); + } } -}; -var index$3 = defineComponent({ - name: "Icon", - props: { - type: { - type: String, - required: true, - default: "" - }, - size: { - type: [String, Number], - default: 23 - }, - color: { - type: String, - default: "" + function removeEvent(node, event2, fn, opt_useCapture) { + if (typeof node.removeEventListener == "function") { + node.removeEventListener(event2, fn, opt_useCapture || false); + } else if (typeof node.detatchEvent == "function") { + node.detatchEvent("on" + event2, fn); } - }, - setup(props) { - const path = computed(() => ICONS[props.type]); - return () => createVNode("uni-icon", null, [path.value.d && createSvgIconVNode(path.value.d, props.color || path.value.c, rpx2px(props.size))]); } -}); -var index_vue_vue_type_style_index_0_lang$9 = "\n@keyframes once-show {\nfrom {\n top: 0;\n}\n}\nuni-resize-sensor,\nuni-resize-sensor > div {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n}\nuni-resize-sensor {\n display: block;\n z-index: -1;\n visibility: hidden;\n animation: once-show 1ms;\n}\nuni-resize-sensor > div > div {\n position: absolute;\n left: 0;\n top: 0;\n}\nuni-resize-sensor > div:first-child > div {\n width: 100000px;\n height: 100000px;\n}\nuni-resize-sensor > div:last-child > div {\n width: 200%;\n height: 200%;\n}\n"; -const _sfc_main$i = { - name: "ResizeSensor", - props: { - initial: { - type: [Boolean, String], - default: false + function computeRectIntersection(rect1, rect2) { + var top = Math.max(rect1.top, rect2.top); + var bottom = Math.min(rect1.bottom, rect2.bottom); + var left = Math.max(rect1.left, rect2.left); + var right = Math.min(rect1.right, rect2.right); + var width = right - left; + var height = bottom - top; + return width >= 0 && height >= 0 && { + top, + bottom, + left, + right, + width, + height + } || null; + } + function getBoundingClientRect(el) { + var rect; + try { + rect = el.getBoundingClientRect(); + } catch (err) { } - }, - data: function() { + if (!rect) + return getEmptyRect(); + if (!(rect.width && rect.height)) { + rect = { + top: rect.top, + right: rect.right, + bottom: rect.bottom, + left: rect.left, + width: rect.right - rect.left, + height: rect.bottom - rect.top + }; + } + return rect; + } + function getEmptyRect() { return { - size: { - width: -1, - height: -1 - } + top: 0, + bottom: 0, + left: 0, + right: 0, + width: 0, + height: 0 }; - }, - watch: { - size: { - deep: true, - handler: function(size) { - this.$emit("resize", Object.assign({}, size)); - } - } - }, - mounted: function() { - if (this.initial === true) { - this.$nextTick(this.update); + } + function ensureDOMRect(rect) { + if (!rect || "x" in rect) { + return rect; } - if (this.$el.offsetParent !== this.$el.parentNode) { - this.$el.parentNode.style.position = "relative"; + return { + top: rect.top, + y: rect.top, + bottom: rect.bottom, + left: rect.left, + x: rect.left, + right: rect.right, + width: rect.width, + height: rect.height + }; + } + function convertFromParentRect(parentBoundingRect, parentIntersectionRect) { + var top = parentIntersectionRect.top - parentBoundingRect.top; + var left = parentIntersectionRect.left - parentBoundingRect.left; + return { + top, + left, + height: parentIntersectionRect.height, + width: parentIntersectionRect.width, + bottom: top + parentIntersectionRect.height, + right: left + parentIntersectionRect.width + }; + } + function containsDeep(parent, child) { + var node = child; + while (node) { + if (node == parent) + return true; + node = getParentNode(node); } - if (!("AnimationEvent" in window)) { - this.reset(); + return false; + } + function getParentNode(node) { + var parent = node.parentNode; + if (node.nodeType == 9 && node != document2) { + return getFrameElement(node); } - }, - methods: { - reset: function() { - var expand = this.$el.firstChild; - var shrink = this.$el.lastChild; - expand.scrollLeft = 1e5; - expand.scrollTop = 1e5; - shrink.scrollLeft = 1e5; - shrink.scrollTop = 1e5; - }, - update: function() { - this.size.width = this.$el.offsetWidth; - this.size.height = this.$el.offsetHeight; - this.reset(); + if (parent && parent.assignedSlot) { + parent = parent.assignedSlot.parentNode; } - }, - render: function(create) { - return create("uni-resize-sensor", { - on: { - "~animationstart": this.update - } - }, [ - create("div", { - on: { - scroll: this.update - } - }, [ - create("div") - ]), - create("div", { - on: { - scroll: this.update - } - }, [ - create("div") - ]) - ]); + if (parent && parent.nodeType == 11 && parent.host) { + return parent.host; + } + return parent; + } + function isDoc(node) { + return node && node.nodeType === 9; } + window.IntersectionObserver = IntersectionObserver2; + window.IntersectionObserverEntry = IntersectionObserverEntry; }; -function findElem(vm) { - return vm.$el; +function normalizeRect(rect) { + const {bottom, height, left, right, top, width} = rect || {}; + return { + bottom, + height, + left, + right, + top, + width + }; } -const SCHEME_RE = /^([a-z-]+:)?\/\//i; -const DATA_RE = /^data:.*,.*/; -function addBase(filePath) { - const base = __uniConfig.router.base; - if (!base) { - return filePath; - } - if (base !== "/") { - if (("/" + filePath).indexOf(base) === 0) { - return "/" + filePath; +function requestComponentObserver($el, options, callback) { + initIntersectionObserverPolyfill(); + const root = options.relativeToSelector ? $el.querySelector(options.relativeToSelector) : null; + const intersectionObserver = new IntersectionObserver((entries) => { + entries.forEach((entrie) => { + callback({ + intersectionRatio: entrie.intersectionRatio, + intersectionRect: normalizeRect(entrie.intersectionRect), + boundingClientRect: normalizeRect(entrie.boundingClientRect), + relativeRect: normalizeRect(entrie.rootBounds), + time: Date.now() + }); + }); + }, { + root, + rootMargin: options.rootMargin, + threshold: options.thresholds + }); + if (options.observeAll) { + intersectionObserver.USE_MUTATION_OBSERVER = true; + const nodeList = $el.querySelectorAll(options.selector); + for (let i2 = 0; i2 < nodeList.length; i2++) { + intersectionObserver.observe(nodeList[i2]); } - } - return base + filePath; -} -function getRealPath(filePath) { - if (__uniConfig.router.base === "./") { - filePath = filePath.replace(/^\.\/static\//, "/static/"); - } - if (filePath.indexOf("/") === 0) { - if (filePath.indexOf("//") === 0) { - filePath = "https:" + filePath; + } else { + intersectionObserver.USE_MUTATION_OBSERVER = false; + const el = $el.querySelector(options.selector); + if (!el) { + console.warn(`Node ${options.selector} is not found. Intersection observer will not trigger.`); } else { - return addBase(filePath.substr(1)); + intersectionObserver.observe(el); } } - if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf("blob:") === 0) { - return filePath; + return intersectionObserver; +} +const supports = window.CSS && window.CSS.supports; +function cssSupports(css) { + return supports && (supports(css) || supports.apply(window.CSS, css.split(":"))); +} +const cssVar = /* @__PURE__ */ cssSupports("--a:0"); +const cssEnv = /* @__PURE__ */ cssSupports("top:env(a)"); +const cssConstant = /* @__PURE__ */ cssSupports("top:constant(a)"); +const cssBackdropFilter = /* @__PURE__ */ cssSupports("backdrop-filter:blur(10px)"); +const SCHEMA_CSS = { + "css.var": cssVar, + "css.env": cssEnv, + "css.constant": cssConstant, + "css.backdrop-filter": cssBackdropFilter +}; +const canIUse = /* @__PURE__ */ defineSyncApi(API_CAN_I_USE, (schema) => { + if (hasOwn$1(SCHEMA_CSS, schema)) { + return SCHEMA_CSS[schema]; } - const pages = getCurrentPages(); - if (pages.length) { - return addBase(getRealRoute(pages[pages.length - 1].$page.route, filePath).substr(1)); + return true; +}, CanIUseProtocol); +var TabBar = /* @__PURE__ */ defineComponent({ + name: "TabBar", + setup() { + const tabBar2 = useTabBar(); + const onSwitchTab = useSwitchTab(useRoute(), tabBar2); + const { + style, + borderStyle, + placeholderStyle + } = useTabBarStyle(tabBar2); + onRenderTriggered(() => { + debugger; + }); + return () => { + const tabBarItemsTsx = createTabBarItemsTsx(tabBar2, onSwitchTab); + return createVNode("uni-tabbar", { + class: "uni-tabbar-" + tabBar2.position + }, [createVNode("div", { + class: "uni-tabbar", + style: style.value + }, [createVNode("div", { + class: "uni-tabbar-border", + style: borderStyle.value + }, null, 4), tabBarItemsTsx], 4), createVNode("div", { + class: "uni-placeholder", + style: placeholderStyle.value + }, null, 4)], 2); + }; } - return filePath; +}); +function useSwitchTab(route, tabBar2) { + watch(route, () => { + const meta = route.meta; + if (meta.isTabBar) { + const pagePath = meta.route; + const index2 = tabBar2.list.findIndex((item) => item.pagePath === pagePath); + if (index2 === -1) { + return; + } + tabBar2.selectedIndex = index2; + } + }, { + immediate: true + }); + return (tabBarItem, index2) => { + const { + type + } = tabBarItem; + return () => { + if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === "midButton") { + return UniServiceJSBridge.invokeOnCallback(API_ON_TAB_BAR_MID_BUTTON_TAP); + } + const { + pagePath, + text: text2 + } = tabBarItem; + let url = "/" + pagePath; + if (url === __uniRoutes[0].alias) { + url = "/"; + } + if (route.path !== url) { + uni.switchTab({ + from: "tabBar", + url + }); + } else { + invokeHook("onTabItemTap", { + index: index2, + text: text2, + pagePath + }); + } + }; + }; } -const ua = navigator.userAgent; -const isAndroid = /android/i.test(ua); -const isIOS$1 = /iphone|ipad|ipod/i.test(ua); -function getScreenFix() { - return /^Apple/.test(navigator.vendor) && typeof window.orientation === "number"; +const DEFAULT_BG_COLOR = "#f7f7fa"; +const BLUR_EFFECT_COLOR_DARK = "rgb(0, 0, 0, 0.8)"; +const BLUR_EFFECT_COLOR_LIGHT = "rgb(250, 250, 250, 0.8)"; +const BLUR_EFFECT_COLORS = { + dark: BLUR_EFFECT_COLOR_DARK, + light: BLUR_EFFECT_COLOR_LIGHT, + extralight: BLUR_EFFECT_COLOR_LIGHT +}; +const BORDER_COLORS = { + white: "rgba(255, 255, 255, 0.33)", + black: "rgba(0, 0, 0, 0.33)" +}; +function useTabBarStyle(tabBar2) { + const style = computed(() => { + let backgroundColor = tabBar2.backgroundColor; + const blurEffect = tabBar2.blurEffect; + if (!backgroundColor) { + if (cssBackdropFilter && blurEffect && blurEffect !== "none") { + backgroundColor = BLUR_EFFECT_COLORS[blurEffect]; + } + } + return { + backgroundColor: backgroundColor || DEFAULT_BG_COLOR, + backdropFilter: blurEffect !== "none" ? "blur(10px)" : blurEffect + }; + }); + const borderStyle = computed(() => { + const { + borderStyle: borderStyle2 + } = tabBar2; + return { + backgroundColor: BORDER_COLORS[borderStyle2] || borderStyle2 + }; + }); + const placeholderStyle = computed(() => { + return { + height: tabBar2.height + }; + }); + return { + style, + borderStyle, + placeholderStyle + }; } -function isLandscape(screenFix) { - return screenFix && Math.abs(window.orientation) === 90; +function isMidButton(item) { + return item.type === "midButton"; } -function getScreenWidth(screenFix, landscape) { - return screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width; +function createTabBarItemsTsx(tabBar2, onSwitchTab) { + const { + list: list2, + selectedIndex, + selectedColor, + color + } = tabBar2; + return list2.map((item, index2) => { + const selected = selectedIndex === index2; + const textColor = selected ? selectedColor : color; + const iconPath = (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || ""; + if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) { + return createTabBarItemTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab); + } + return isMidButton(item) ? createTabBarMidButtonTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab) : createTabBarItemTsx(textColor, iconPath, item, tabBar2, index2, onSwitchTab); + }); } -function getScreenHeight(screenFix, landscape) { - return screenFix ? Math[landscape ? "min" : "max"](screen.height, screen.width) : screen.height; +function createTabBarItemTsx(color, iconPath, tabBarItem, tabBar2, index2, onSwitchTab) { + return createVNode("div", { + key: index2, + class: "uni-tabbar__item", + onClick: onSwitchTab(tabBarItem, index2) + }, [createTabBarItemBdTsx(color, iconPath || "", tabBarItem, tabBar2)], 8, ["onClick"]); } -function getWindowWidth(screenWidth) { - return Math.min(window.innerWidth, document.documentElement.clientWidth, screenWidth) || screenWidth; +function createTabBarItemBdTsx(color, iconPath, tabBarItem, tabBar2) { + const { + height + } = tabBar2; + return createVNode("div", { + class: "uni-tabbar__bd", + style: { + height + } + }, [iconPath && createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2), tabBarItem.text && createTabBarItemTextTsx(color, tabBarItem, tabBar2)], 4); } -function getBaseSystemInfo() { - const screenFix = getScreenFix(); - const windowWidth = getWindowWidth(getScreenWidth(screenFix, isLandscape(screenFix))); - return { - platform: isIOS$1 ? "ios" : "other", - pixelRatio: window.devicePixelRatio, - windowWidth +function createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2) { + const { + type, + text: text2, + redDot + } = tabBarItem; + const { + iconWidth + } = tabBar2; + const clazz = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : ""); + const style = { + width: iconWidth, + height: iconWidth }; + return createVNode("div", { + class: clazz, + style + }, [type !== "midButton" && createVNode("img", { + src: getRealPath(iconPath) + }, null, 8, ["src"]), redDot && createTabBarItemRedDotTsx(tabBarItem.badge)], 6); } -function operateVideoPlayer(videoId, vm, type, data) { - const pageId = vm.$page.id; - UniServiceJSBridge.publishHandler(pageId + "-video-" + videoId, { - videoId, - type, - data - }, pageId); +function createTabBarItemTextTsx(color, tabBarItem, tabBar2) { + const { + redDot, + iconPath, + text: text2 + } = tabBarItem; + const { + fontSize, + spacing + } = tabBar2; + const style = { + color, + fontSize, + lineHeight: !iconPath ? 1.8 : "normal", + marginTop: !iconPath ? "inherit" : spacing + }; + return createVNode("div", { + class: "uni-tabbar__label", + style + }, [text2, redDot && !iconPath && createTabBarItemRedDotTsx(tabBarItem.badge)], 4); } -var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -var lookup = new Uint8Array(256); -for (var i$1 = 0; i$1 < chars.length; i$1++) { - lookup[chars.charCodeAt(i$1)] = i$1; +function createTabBarItemRedDotTsx(badge) { + const clazz = "uni-tabbar__reddot" + (badge ? " uni-tabbar__badge" : ""); + return createVNode("div", { + class: clazz + }, [badge], 2); } -function encode$1(arraybuffer) { - var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = ""; - for (i2 = 0; i2 < len; i2 += 3) { - base64 += chars[bytes[i2] >> 2]; - base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4]; - base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6]; - base64 += chars[bytes[i2 + 2] & 63]; - } - if (len % 3 === 2) { - base64 = base64.substring(0, base64.length - 1) + "="; - } else if (len % 3 === 1) { - base64 = base64.substring(0, base64.length - 2) + "=="; - } - return base64; +function createTabBarMidButtonTsx(color, iconPath, midButton, tabBar2, index2, onSwitchTab) { + const { + width, + height, + backgroundImage, + iconWidth + } = midButton; + return createVNode("div", { + key: index2, + class: "uni-tabbar__item", + style: { + flex: "0 0 " + width, + position: "relative" + }, + onClick: onSwitchTab(midButton, index2) + }, [createVNode("div", { + class: "uni-tabbar__mid", + style: { + width, + height, + backgroundImage: backgroundImage ? "url('" + getRealPath(backgroundImage) + "')" : "none" + } + }, [iconPath && createVNode("img", { + style: { + width: iconWidth, + height: iconWidth + }, + src: getRealPath(iconPath) + }, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, midButton, tabBar2)], 12, ["onClick"]); } -function decode(base64) { - var bufferLength = base64.length * 0.75, len = base64.length, i2, p2 = 0, encoded1, encoded2, encoded3, encoded4; - if (base64[base64.length - 1] === "=") { - bufferLength--; - if (base64[base64.length - 2] === "=") { - bufferLength--; - } +var Layout = defineComponent({ + name: "Layout", + props: { + onChange: Function + }, + emits: ["change"], + setup(props, { + emit + }) { + const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute(); + __UNI_FEATURE_TOPWINDOW__ && useTopWindow(); + __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(); + __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(); + const showTabBar2 = __UNI_FEATURE_TABBAR__ && useShowTabBar(emit); + return () => { + const layoutTsx = createLayoutTsx(keepAliveRoute); + const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar2); + if (!tabBarTsx) { + return layoutTsx; + } + return [layoutTsx, tabBarTsx]; + }; } - var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer); - for (i2 = 0; i2 < len; i2 += 4) { - encoded1 = lookup[base64.charCodeAt(i2)]; - encoded2 = lookup[base64.charCodeAt(i2 + 1)]; - encoded3 = lookup[base64.charCodeAt(i2 + 2)]; - encoded4 = lookup[base64.charCodeAt(i2 + 3)]; - bytes[p2++] = encoded1 << 2 | encoded2 >> 4; - bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2; - bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63; +}); +function createLayoutTsx(keepAliveRoute, topWindow, leftWindow, rightWindow) { + const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode(); + if (!__UNI_FEATURE_RESPONSIVE__) { + return routerVNode; } - return arraybuffer; + const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx() : null; + const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx() : null; + const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx() : null; + return createVNode("uni-layout", null, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])]); } -const API_TYPE_ON_PROTOCOLS = [ - { - name: "callback", - type: Function, - required: true - } -]; -function validateProtocolFail(name, msg) { - const errMsg = `${name}:fail ${msg}`; - { - console.error(errMsg); - } +function useShowTabBar(emit) { + const route = useRoute(); + const tabBar2 = useTabBar(); + const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown); + watch(showTabBar2, (value) => { + emit("change", "showTabBar", value); + }); + return showTabBar2; +} +function createTabBarTsx(showTabBar2) { + return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, showTabBar2.value]]); +} +function createPageVNode() { + return createVNode(__uniRoutes[0].component); +} +function createRouterViewVNode(keepAliveRoute) { + return createVNode(RouterView, null, { + default: withCtx(({ + Component + }) => [(openBlock(), createBlock(KeepAlive, { + matchBy: "key", + cache: keepAliveRoute.routeCache + }, [(openBlock(), createBlock(resolveDynamicComponent(Component), { + key: keepAliveRoute.routeKey.value + }))], 1032, ["cache"]))]), + _: 1 + }); +} +function useTopWindow() { + const component = resolveComponent("VUniTopWindow"); return { - errMsg + component, + style: component.style, + height: 0, + show: false }; } -function validateProtocol(name, data, protocol) { - for (const key in protocol) { - const errMsg = validateProp(key, data[key], protocol[key], !hasOwn$1(data, key)); - if (errMsg) { - return validateProtocolFail(name, errMsg); - } - } +function useLeftWindow() { + const component = resolveComponent("VUniLeftWindow"); + return { + component, + style: component.style, + height: 0 + }; } -function validateProtocols(name, args, protocol) { - if (!protocol) { - return; - } - if (isArray(protocol)) { - const len = protocol.length; - const argsLen = args.length; - for (let i2 = 0; i2 < len; i2++) { - const opts = protocol[i2]; - const data = Object.create(null); - if (argsLen > i2) { - data[opts.name] = args[i2]; - } - const errMsg = validateProtocol(name, data, {[opts.name]: opts}); - if (errMsg) { - return errMsg; - } - } - return; - } - return validateProtocol(name, args[0] || Object.create(null), protocol); +function useRightWindow() { + const component = resolveComponent("VUniRightWindow"); + return { + component, + style: component.style, + height: 0 + }; } -function validateProp(name, value, prop, isAbsent) { - const {type, required, validator} = prop; - if (required && isAbsent) { - return 'Missing required args: "' + name + '"'; - } - if (value == null && !prop.required) { - return; - } - if (type != null && type !== true) { - let isValid = false; - const types = isArray(type) ? type : [type]; - const expectedTypes = []; - for (let i2 = 0; i2 < types.length && !isValid; i2++) { - const {valid, expectedType} = assertType(value, types[i2]); - expectedTypes.push(expectedType || ""); - isValid = valid; - } - if (!isValid) { - return getInvalidTypeMessage(name, value, expectedTypes); - } - } - if (validator && !validator(value)) { - return 'Invalid args: custom validator check failed for args "' + name + '".'; +function createTopWindowTsx(topWindow) { +} +function createLeftWindowTsx(leftWindow) { +} +function createRightWindowTsx(leftWindow) { +} +const CSS_VARS = ["--status-bar-height", "--top-window-height", "--window-left", "--window-right", "--window-margin"]; +var AppComponent = defineComponent({ + name: "App", + setup() { + useCssVar(); + useAppLifecycle(); + const { + clazz, + onChange: onChange2 + } = useAppClass(); + return () => createVNode("uni-app", { + class: clazz.value + }, [createVNode(Layout, { + onChange: onChange2 + }, null, 8, ["onChange"])], 2); } +}); +function useCssVar() { + CSS_VARS.forEach((name) => updateCssVar(name, "0px")); } -const isSimpleType = /* @__PURE__ */ makeMap$1("String,Number,Boolean,Function,Symbol"); -function assertType(value, type) { - let valid; - const expectedType = getType(type); - if (isSimpleType(expectedType)) { - const t2 = typeof value; - valid = t2 === expectedType.toLowerCase(); - if (!valid && t2 === "object") { - valid = value instanceof type; - } - } else if (expectedType === "Object") { - valid = isObject$1(value); - } else if (expectedType === "Array") { - valid = isArray(value); - } else { - { - valid = value instanceof type; +function useAppLifecycle() { + onMounted(() => { + document.addEventListener("visibilitychange", function() { + if (document.visibilityState === "visible") { + UniServiceJSBridge.emit("onAppEnterForeground"); + } else { + UniServiceJSBridge.emit("onAppEnterBackground"); + } + }); + }); +} +function useAppClass() { + const showTabBar2 = ref(false); + const showMaxWidth = ref(false); + function onChange2(type, value) { + if (type === "showTabBar") { + showTabBar2.value = value; + } else if (type === "showMaxWidth") { + showMaxWidth.value = value; } } + const clazz = computed(() => { + return { + "uni-app--showtabbar": showTabBar2.value, + "uni-app--maxwidth": showMaxWidth.value + }; + }); return { - valid, - expectedType + clazz, + onChange: onChange2 }; } -function getInvalidTypeMessage(name, value, expectedTypes) { - let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`; - const expectedType = expectedTypes[0]; - const receivedType = toRawType(value); - const expectedValue = styleValue(value, expectedType); - const receivedValue = styleValue(value, receivedType); - if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) { - message += ` with value ${expectedValue}`; - } - message += `, got ${receivedType} `; - if (isExplicable(receivedType)) { - message += `with value ${receivedValue}.`; - } - return message; -} -function getType(ctor) { - const match = ctor && ctor.toString().match(/^\s*function (\w+)/); - return match ? match[1] : ""; +function initSystemComponents(app) { + AppComponent.name = COMPONENT_NAME_PREFIX + AppComponent.name; + app.component(AppComponent.name, AppComponent); } -function styleValue(value, type) { - if (type === "String") { - return `"${value}"`; - } else if (type === "Number") { - return `${Number(value)}`; - } else { - return `${value}`; - } +let appVm; +function getApp$1() { + return appVm; } -function isExplicable(type) { - const explicitTypes = ["string", "number", "boolean"]; - return explicitTypes.some((elem) => type.toLowerCase() === elem); +function isApp(vm) { + return vm.$options.mpType === "app"; } -function isBoolean(...args) { - return args.some((elem) => elem.toLowerCase() === "boolean"); +function initApp(vm) { + appVm = vm; + appVm.$vm = vm; + appVm.globalData = appVm.$options.globalData || {}; } -function tryCatch(fn) { - return function() { - try { - return fn.apply(fn, arguments); - } catch (e2) { - console.error(e2); - } - }; -} -let invokeCallbackId = 1; -const invokeCallbacks = {}; -function addInvokeCallback(id2, name, callback, keepAlive = false) { - invokeCallbacks[id2] = { - name, - keepAlive, - callback - }; - return id2; -} -function invokeCallback(id2, res, extras) { - if (typeof id2 === "number") { - const opts = invokeCallbacks[id2]; - if (opts) { - if (!opts.keepAlive) { - delete invokeCallbacks[id2]; +function initMixin(app) { + app.mixin({ + created() { + this.__isApp = isApp(this); + this.__isPage = !this.__isApp && isPage(this); + if (this.__isApp) { + initApp(this); + } else if (this.__isPage) { + initPage(this); + this.$callHook("onLoad", {}); + this.__isVisible = true; + this.$callHook("onShow"); + } else { + if (this.$parent) { + this.$page = this.$parent.$page; + } } - return opts.callback(res, extras); - } - } - return res; -} -function findInvokeCallbackByName(name) { - for (const key in invokeCallbacks) { - if (invokeCallbacks[key].name === name) { - return true; - } - } - return false; -} -function removeKeepAliveApiCallback(name, callback) { - for (const key in invokeCallbacks) { - const item = invokeCallbacks[key]; - if (item.callback === callback && item.name === name) { - delete invokeCallbacks[key]; - } - } -} -function offKeepAliveApiCallback(name) { - UniServiceJSBridge.off("api." + name); -} -function onKeepAliveApiCallback(name) { - UniServiceJSBridge.on("api." + name, (res) => { - for (const key in invokeCallbacks) { - const opts = invokeCallbacks[key]; - if (opts.name === name) { - opts.callback(res); + }, + mounted() { + if (this.__isPage) { + this.$callHook("onReady"); + } + }, + beforeActivate() { + if (this.__isPage && !this.__isVisible) { + this.$callHook("onShow"); + } + }, + beforeDeactivate() { + if (this.__isPage) { + this.__isVisible = false; + this.$callHook("onHide"); + } + }, + beforeUnmount() { + if (this.__isPage) { + this.$callHook("onUnload"); } } }); } -function createKeepAliveApiCallback(name, callback) { - return addInvokeCallback(invokeCallbackId++, name, callback, true); -} -const API_SUCCESS = "success"; -const API_FAIL = "fail"; -const API_COMPLETE = "complete"; -function getApiCallbacks(args) { - const apiCallbacks = {}; - for (const name in args) { - const fn = args[name]; - if (isFunction(fn)) { - apiCallbacks[name] = tryCatch(fn); - delete args[name]; +var index$6 = { + install(app) { + initApp$1(app); + initView(app); + initService(app); + initSystemComponents(app); + initMixin(app); + if (__UNI_FEATURE_PAGES__) { + initRouter(app); } } - return apiCallbacks; -} -function normalizeErrMsg(errMsg, name) { - if (!errMsg || errMsg.indexOf(":fail") === -1) { - return name + ":ok"; - } - return name + errMsg.substring(errMsg.indexOf(":fail")); -} -function createAsyncApiCallback(name, args = {}, {beforeAll, beforeSuccess} = {}) { - if (!isPlainObject(args)) { - args = {}; - } - const {success, fail, complete} = getApiCallbacks(args); - const hasSuccess = isFunction(success); - const hasFail = isFunction(fail); - const hasComplete = isFunction(complete); - const callbackId = invokeCallbackId++; - addInvokeCallback(callbackId, name, (res) => { - res = res || {}; - res.errMsg = normalizeErrMsg(res.errMsg, name); - isFunction(beforeAll) && beforeAll(res); - if (res.errMsg === name + ":ok") { - isFunction(beforeSuccess) && beforeSuccess(res); - hasSuccess && success(res); +}; +function broadcast(componentName, eventName, ...params) { + const children = this.$children; + const len = children.length; + for (let i2 = 0; i2 < len; i2++) { + const child = children[i2]; + const name = child.$options.name && child.$options.name.substr(4); + if (~componentName.indexOf(name)) { + child.$emit.apply(child, [eventName].concat(params)); + return false; } else { - hasFail && fail(res); + if (broadcast.apply(child, [componentName, eventName].concat([params])) === false) { + return false; + } } - hasComplete && complete(res); - }); - return callbackId; -} -const callbacks = [API_SUCCESS, API_FAIL, API_COMPLETE]; -function hasCallback(args) { - if (isPlainObject(args) && callbacks.find((cb) => isFunction(args[cb]))) { - return true; - } - return false; -} -function handlePromise(promise) { - if (__UNI_FEATURE_PROMISE__) { - return promise.then((data) => { - return [null, data]; - }).catch((err) => [err]); } - return promise; } -function promisify(fn) { - return (args = {}) => { - if (hasCallback(args)) { - return fn(args); +var emitter = { + methods: { + $dispatch(componentName, eventName, ...params) { + console.log("$dispatch", componentName, eventName, params); + }, + $broadcast(componentName, eventName, ...params) { + if (typeof componentName === "string") { + componentName = [componentName]; + } + broadcast.apply(this, [componentName, eventName].concat(params)); } - return handlePromise(new Promise((resolve, reject) => { - fn(Object.assign(args, {success: resolve, fail: reject})); - })); - }; -} -function formatApiArgs(args, options) { - const params = args[0]; - if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) { - return args; } - const formatArgs = options.formatArgs; - Object.keys(formatArgs).forEach((name) => { - formatArgs[name](args[0][name], params); - }); - return args; -} -function wrapperOnApi(name, fn) { - return (callback) => { - const isFirstInvokeOnApi = !findInvokeCallbackByName(name); - createKeepAliveApiCallback(name, callback); - if (isFirstInvokeOnApi) { - onKeepAliveApiCallback(name); - fn(); - } - }; -} -function wrapperOffApi(name, fn) { - return (callback) => { - name = name.replace("off", "on"); - removeKeepAliveApiCallback(name, callback); - const hasInvokeOnApi = findInvokeCallbackByName(name); - if (!hasInvokeOnApi) { - offKeepAliveApiCallback(name); - fn(); +}; +var listeners = { + props: { + id: { + type: String, + default: "" } - }; -} -function invokeSuccess(id2, name, res) { - return invokeCallback(id2, extend(res || {}, {errMsg: name + ":ok"})); -} -function invokeFail(id2, name, err) { - return invokeCallback(id2, {errMsg: name + ":fail" + (err ? " " + err : "")}); -} -function wrapperTaskApi(name, fn, options) { - return (args) => { - const id2 = createAsyncApiCallback(name, args, options); - return fn(args, { - resolve: (res) => invokeSuccess(id2, name, res), - reject: (err) => invokeFail(id2, name, err) + }, + created() { + this._addListeners(this.id); + this.$watch("id", (newId, oldId) => { + this._removeListeners(oldId, true); + this._addListeners(newId, true); }); - }; -} -function wrapperSyncApi(fn) { - return (...args) => fn.apply(null, args); -} -function wrapperAsyncApi(name, fn, options) { - return wrapperTaskApi(name, fn, options); -} -function wrapperApi(fn, name, protocol, options) { - return function(...args) { - if (process.env.NODE_ENV !== "production") { - const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { - return errMsg; - } + }, + beforeDestroy() { + this._removeListeners(this.id); + }, + methods: { + _addListeners(id2, watch2) { + if (watch2 && !id2) { + return; + } + const {listeners: listeners2} = this.$options; + if (!isPlainObject(listeners2)) { + return; + } + Object.keys(listeners2).forEach((name) => { + if (watch2) { + if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) { + UniViewJSBridge.on(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); + } + } else { + if (name.indexOf("@") === 0) { + this.$on(`uni-${name.substr(1)}`, this[listeners2[name]]); + } else if (name.indexOf("uni-") === 0) { + UniViewJSBridge.on(name, this[listeners2[name]]); + } else if (id2) { + UniViewJSBridge.on(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); + } + } + }); + }, + _removeListeners(id2, watch2) { + if (watch2 && !id2) { + return; + } + const {listeners: listeners2} = this.$options; + if (!isPlainObject(listeners2)) { + return; + } + Object.keys(listeners2).forEach((name) => { + if (watch2) { + if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) { + UniViewJSBridge.off(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); + } + } else { + if (name.indexOf("@") === 0) { + this.$off(`uni-${name.substr(1)}`, this[listeners2[name]]); + } else if (name.indexOf("uni-") === 0) { + UniViewJSBridge.off(name, this[listeners2[name]]); + } else if (id2) { + UniViewJSBridge.off(`uni-${name}-${this.$page.id}-${id2}`, this[listeners2[name]]); + } + } + }); } - return fn.apply(null, formatApiArgs(args, options)); - }; -} -function defineOnApi(name, fn, options) { - return wrapperApi(wrapperOnApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); -} -function defineOffApi(name, fn, options) { - return wrapperApi(wrapperOffApi(name, fn), name, process.env.NODE_ENV !== "production" ? API_TYPE_ON_PROTOCOLS : void 0, options); -} -function defineTaskApi(name, fn, protocol, options) { - return promisify(wrapperApi(wrapperTaskApi(name, fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); -} -function defineSyncApi(name, fn, protocol, options) { - return wrapperApi(wrapperSyncApi(fn), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options); -} -function defineAsyncApi(name, fn, protocol, options) { - return promisify(wrapperApi(wrapperAsyncApi(name, fn, options), name, process.env.NODE_ENV !== "production" ? protocol : void 0, options)); -} -const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer"; -const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64"; -const Base64ToArrayBufferProtocol = [ - { - name: "base64", - type: String, - required: true - } -]; -const ArrayBufferToBase64Protocol = [ - { - name: "arrayBuffer", - type: [ArrayBuffer, Uint8Array], - required: true - } -]; -const base64ToArrayBuffer = /* @__PURE__ */ defineSyncApi(API_BASE64_TO_ARRAY_BUFFER, (base64) => { - return decode(base64); -}, Base64ToArrayBufferProtocol); -const arrayBufferToBase64 = /* @__PURE__ */ defineSyncApi(API_ARRAY_BUFFER_TO_BASE64, (arrayBuffer) => { - return encode$1(arrayBuffer); -}, ArrayBufferToBase64Protocol); -const API_UPX2PX = "upx2px"; -const Upx2pxProtocol = [ - { - name: "upx", - type: [Number, String], - required: true - } -]; -const EPS = 1e-4; -const BASE_DEVICE_WIDTH = 750; -let isIOS = false; -let deviceWidth = 0; -let deviceDPR = 0; -function checkDeviceWidth() { - const {platform, pixelRatio: pixelRatio2, windowWidth} = getBaseSystemInfo(); - deviceWidth = windowWidth; - deviceDPR = pixelRatio2; - isIOS = platform === "ios"; -} -const upx2px = /* @__PURE__ */ defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => { - if (deviceWidth === 0) { - checkDeviceWidth(); - } - number = Number(number); - if (number === 0) { - return 0; - } - let result = number / BASE_DEVICE_WIDTH * (newDeviceWidth || deviceWidth); - if (result < 0) { - result = -result; } - result = Math.floor(result + EPS); - if (result === 0) { - if (deviceDPR === 1 || !isIOS) { - result = 1; - } else { - result = 0.5; +}; +var hover = { + data() { + return { + hovering: false + }; + }, + props: { + hoverClass: { + type: String, + default: "none" + }, + hoverStopPropagation: { + type: Boolean, + default: false + }, + hoverStartTime: { + type: [Number, String], + default: 50 + }, + hoverStayTime: { + type: [Number, String], + default: 400 } - } - return number < 0 ? -result : result; -}, Upx2pxProtocol); -var HOOKS; -(function(HOOKS2) { - HOOKS2["INVOKE"] = "invoke"; - HOOKS2["SUCCESS"] = "success"; - HOOKS2["FAIL"] = "fail"; - HOOKS2["COMPLETE"] = "complete"; - HOOKS2["RETURN_VALUE"] = "returnValue"; -})(HOOKS || (HOOKS = {})); -const globalInterceptors = {}; -const scopedInterceptors = {}; -const API_ADD_INTERCEPTOR = "addInterceptor"; -const API_REMOVE_INTERCEPTOR = "removeInterceptor"; -const AddInterceptorProtocol = [ - { - name: "method", - type: [String, Object], - required: true - } -]; -const RemoveInterceptorProtocol = AddInterceptorProtocol; -function mergeInterceptorHook(interceptors, interceptor) { - Object.keys(interceptor).forEach((hook) => { - if (isFunction(interceptor[hook])) { - interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]); + }, + methods: { + _hoverTouchStart(evt) { + if (evt._hoverPropagationStopped) { + return; + } + if (!this.hoverClass || this.hoverClass === "none" || this.disabled) { + return; + } + if (evt.touches.length > 1) { + return; + } + if (this.hoverStopPropagation) { + evt._hoverPropagationStopped = true; + } + this._hoverTouch = true; + this._hoverStartTimer = setTimeout(() => { + this.hovering = true; + if (!this._hoverTouch) { + this._hoverReset(); + } + }, this.hoverStartTime); + }, + _hoverTouchEnd(evt) { + this._hoverTouch = false; + if (this.hovering) { + this._hoverReset(); + } + }, + _hoverReset() { + requestAnimationFrame(() => { + clearTimeout(this._hoverStayTimer); + this._hoverStayTimer = setTimeout(() => { + this.hovering = false; + }, this.hoverStayTime); + }); + }, + _hoverTouchCancel(evt) { + this._hoverTouch = false; + this.hovering = false; + clearTimeout(this._hoverStartTimer); } - }); -} -function removeInterceptorHook(interceptors, interceptor) { - if (!interceptors || !interceptor) { - return; } - Object.keys(interceptor).forEach((hook) => { - if (isFunction(interceptor[hook])) { - removeHook(interceptors[hook], interceptor[hook]); - } - }); -} -function mergeHook(parentVal, childVal) { - const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal; - return res ? dedupeHooks(res) : res; -} -function dedupeHooks(hooks) { - const res = []; - for (let i2 = 0; i2 < hooks.length; i2++) { - if (res.indexOf(hooks[i2]) === -1) { - res.push(hooks[i2]); +}; +var subscriber = { + mounted() { + this._toggleListeners("subscribe", this.id); + this.$watch("id", (newId, oldId) => { + this._toggleListeners("unsubscribe", oldId, true); + this._toggleListeners("subscribe", newId, true); + }); + }, + beforeDestroy() { + this._toggleListeners("unsubscribe", this.id); + if (this._contextId) { + this._toggleListeners("unsubscribe", this._contextId); } - } - return res; -} -function removeHook(hooks, hook) { - if (!hooks) { - return; - } - const index2 = hooks.indexOf(hook); - if (index2 !== -1) { - hooks.splice(index2, 1); - } -} -const addInterceptor = /* @__PURE__ */ defineSyncApi(API_ADD_INTERCEPTOR, (method, interceptor) => { - if (typeof method === "string" && isPlainObject(interceptor)) { - mergeInterceptorHook(scopedInterceptors[method] || (scopedInterceptors[method] = {}), interceptor); - } else if (isPlainObject(method)) { - mergeInterceptorHook(globalInterceptors, method); - } -}, AddInterceptorProtocol); -const removeInterceptor = /* @__PURE__ */ defineSyncApi(API_REMOVE_INTERCEPTOR, (method, interceptor) => { - if (typeof method === "string") { - if (isPlainObject(interceptor)) { - removeInterceptorHook(scopedInterceptors[method], interceptor); - } else { - delete scopedInterceptors[method]; - } - } else if (isPlainObject(method)) { - removeInterceptorHook(globalInterceptors, method); - } -}, RemoveInterceptorProtocol); -const promiseInterceptor = { - returnValue(res) { - if (!isPromise(res)) { - return res; + }, + methods: { + _toggleListeners(type, id2, watch2) { + if (watch2 && !id2) { + return; + } + if (!isFunction(this._handleSubscribe)) { + return; + } + UniViewJSBridge[type](this.$page.id + "-" + this.$options.name.replace(/VUni([A-Z])/, "$1").toLowerCase() + "-" + id2, this._handleSubscribe); + }, + _getContextInfo() { + const id2 = `context-${this._uid}`; + if (!this._contextId) { + this._toggleListeners("subscribe", id2); + this._contextId = id2; + } + return { + name: this.$options.name.replace(/VUni([A-Z])/, "$1").toLowerCase(), + id: id2, + page: this.$page.id + }; } - return res.then((res2) => { - return res2[1]; - }).catch((res2) => { - return res2[0]; - }); } }; -function getCurrentPageVm() { - const pages = getCurrentPages(); - const len = pages.length; - const page = pages[len - 1]; - return page && page.$vm; +function hideKeyboard() { + document.activeElement.blur(); } -const RATES = [0.5, 0.8, 1, 1.25, 1.5, 2]; -class VideoContext { - constructor(id2, vm) { - this.id = id2; - this.vm = vm; - } - play() { - operateVideoPlayer(this.id, this.vm, "play"); - } - pause() { - operateVideoPlayer(this.id, this.vm, "pause"); - } - stop() { - operateVideoPlayer(this.id, this.vm, "stop"); - } - seek(position) { - operateVideoPlayer(this.id, this.vm, "seek", { - position - }); - } - sendDanmu(args) { - operateVideoPlayer(this.id, this.vm, "sendDanmu", args); - } - playbackRate(rate) { - if (!~RATES.indexOf(rate)) { - rate = 1; - } - operateVideoPlayer(this.id, this.vm, "playbackRate", { - rate - }); - } - requestFullScreen(args = {}) { - operateVideoPlayer(this.id, this.vm, "requestFullScreen", args); - } - exitFullScreen() { - operateVideoPlayer(this.id, this.vm, "exitFullScreen"); - } - showStatusBar() { - operateVideoPlayer(this.id, this.vm, "showStatusBar"); - } - hideStatusBar() { - operateVideoPlayer(this.id, this.vm, "hideStatusBar"); - } +function iosHideKeyboard() { } -function createVideoContext(id2, context) { - if (context) { - return new VideoContext(id2, context); +var keyboard = { + name: "Keyboard", + props: { + cursorSpacing: { + type: [Number, String], + default: 0 + }, + showConfirmBar: { + type: [Boolean, String], + default: "auto" + }, + adjustPosition: { + type: Boolean, + default: true + } + }, + watch: { + focus(val) { + if (val && false) { + this.showSoftKeybord(); + } + } + }, + mounted() { + if (this.autoFocus || this.focus) { + this.showSoftKeybord(); + } + }, + beforeDestroy() { + this.onKeyboardHide(); + }, + methods: { + initKeyboard(el) { + el.addEventListener("focus", () => { + this.hideKeyboardTemp = function() { + hideKeyboard(); + }; + UniViewJSBridge.subscribe("hideKeyboard", this.hideKeyboardTemp); + document.addEventListener("click", iosHideKeyboard, false); + }); + el.addEventListener("blur", this.onKeyboardHide.bind(this)); + }, + showSoftKeybord() { + plusReady(() => { + plus.key.showSoftKeybord(); + }); + }, + setSoftinputTemporary() { + plusReady(() => { + const currentWebview = plus.webview.currentWebview(); + const style = currentWebview.getStyle() || {}; + const rect = this.$el.getBoundingClientRect(); + currentWebview.setSoftinputTemporary && currentWebview.setSoftinputTemporary({ + mode: style.softinputMode === "adjustResize" ? "adjustResize" : this.adjustPosition ? "adjustPan" : "nothing", + position: { + top: rect.top, + height: rect.height + (Number(this.cursorSpacing) || 0) + } + }); + }); + }, + setSoftinputNavBar() { + if (this.showConfirmBar === "auto") { + delete this.__softinputNavBar; + return; + } + plusReady(() => { + const currentWebview = plus.webview.currentWebview(); + const {softinputNavBar} = currentWebview.getStyle() || {}; + const showConfirmBar = softinputNavBar !== "none"; + if (showConfirmBar !== this.showConfirmBar) { + this.__softinputNavBar = softinputNavBar || "auto"; + currentWebview.setStyle({ + softinputNavBar: this.showConfirmBar ? "auto" : "none" + }); + } else { + delete this.__softinputNavBar; + } + }); + }, + resetSoftinputNavBar() { + const softinputNavBar = this.__softinputNavBar; + if (softinputNavBar) { + plusReady(() => { + const currentWebview = plus.webview.currentWebview(); + currentWebview.setStyle({ + softinputNavBar + }); + }); + } + }, + onKeyboardHide() { + UniViewJSBridge.unsubscribe("hideKeyboard", this.hideKeyboardTemp); + document.removeEventListener("click", iosHideKeyboard, false); + if (String(navigator.vendor).indexOf("Apple") === 0) { + document.documentElement.scrollTo(document.documentElement.scrollLeft, document.documentElement.scrollTop); + } + } } - return new VideoContext(id2, getCurrentPageVm()); -} -const defaultOptions = { - thresholds: [0], - initialRatio: 0, - observeAll: false }; -const MARGINS = ["top", "right", "bottom", "left"]; -let reqComponentObserverId = 1; -function normalizeRootMargin(margins = {}) { - return MARGINS.map((name) => `${Number(margins[name]) || 0}px`).join(" "); -} -class ServiceIntersectionObserver { - constructor(component, options) { - this._pageId = component.$page && component.$page.id; - this._component = component; - this._options = extend({}, defaultOptions, options); - } - relativeTo(selector, margins) { - this._options.relativeToSelector = selector; - this._options.rootMargin = normalizeRootMargin(margins); - return this; - } - relativeToViewport(margins) { - this._options.relativeToSelector = void 0; - this._options.rootMargin = normalizeRootMargin(margins); - return this; - } - observe(selector, callback) { - if (!isFunction(callback)) { +function throttle(fn, wait) { + let last = 0; + let timeout; + const newFn = function(...arg) { + const now = Date.now(); + clearTimeout(timeout); + const waitCallback = () => { + last = now; + fn.apply(this, arg); + }; + if (now - last < wait) { + timeout = setTimeout(waitCallback, wait - (now - last)); return; } - this._options.selector = selector; - this._reqId = reqComponentObserverId++; - addIntersectionObserver({ - reqId: this._reqId, - component: this._component, - options: this._options, - callback - }, this._pageId); - } - disconnect() { - this._reqId && removeIntersectionObserver({reqId: this._reqId, component: this._component}, this._pageId); - } + waitCallback(); + }; + newFn.cancel = function() { + clearTimeout(timeout); + }; + return newFn; } -const createIntersectionObserver = /* @__PURE__ */ defineSyncApi("createIntersectionObserver", (context, options) => { - if (context && !context.$page) { - options = context; - context = null; +var baseInput = { + name: "BaseInput", + mixins: [emitter, keyboard], + model: { + prop: "value", + event: "update:value" + }, + props: { + value: { + type: [String, Number], + default: "" + } + }, + data() { + return { + valueSync: this._getValueString(this.value) + }; + }, + created() { + const valueChange = this.__valueChange = debounce((val) => { + this.valueSync = this._getValueString(val); + }, 100); + this.$watch("value", valueChange); + this.__triggerInput = throttle(($event, detail) => { + this.$emit("update:value", detail.value); + this.$trigger("input", $event, detail); + }, 100); + this.$triggerInput = ($event, detail) => { + this.__valueChange.cancel(); + this.__triggerInput($event, detail); + }; + }, + beforeDestroy() { + this.__valueChange.cancel(); + this.__triggerInput.cancel(); + }, + methods: { + _getValueString(value) { + return value === null ? "" : String(value); + } } - if (context) { - return new ServiceIntersectionObserver(context, options); +}; +const _sfc_main$n = { + name: "Audio", + mixins: [subscriber], + props: { + id: { + type: String, + default: "" + }, + src: { + type: String, + default: "" + }, + loop: { + type: [Boolean, String], + default: false + }, + controls: { + type: [Boolean, String], + default: false + }, + poster: { + type: String, + default: "" + }, + name: { + type: String, + default: "" + }, + author: { + type: String, + default: "" + } + }, + data() { + return { + playing: false, + currentTime: this.getTime(0) + }; + }, + watch: { + src(val) { + if (this.$refs.audio) { + this.$refs.audio.src = this.$getRealPath(val); + } + } + }, + mounted() { + const audio = this.$refs.audio; + audio.addEventListener("error", ($event) => { + this.playing = false; + this.$trigger("error", $event, {}); + }); + audio.addEventListener("play", ($event) => { + this.playing = true; + this.$trigger("play", $event, {}); + }); + audio.addEventListener("pause", ($event) => { + this.playing = false; + this.$trigger("pause", $event, {}); + }); + audio.addEventListener("ended", ($event) => { + this.playing = false; + this.$trigger("ended", $event, {}); + }); + audio.addEventListener("timeupdate", ($event) => { + var currentTime = audio.currentTime; + this.currentTime = this.getTime(currentTime); + var duration = audio.duration; + this.$trigger("timeupdate", $event, { + currentTime, + duration + }); + }); + audio.src = this.$getRealPath(this.src); + }, + methods: { + _handleSubscribe({ + type, + data = {} + }) { + var audio = this.$refs.audio; + switch (type) { + case "setSrc": + audio.src = this.$getRealPath(data.src); + this.$emit("update:src", data.src); + break; + case "play": + audio.play(); + break; + case "pause": + audio.pause(); + break; + case "seek": + audio.currentTime = data.position; + break; + } + }, + trigger() { + if (this.playing) { + this.$refs.audio.pause(); + } else { + this.$refs.audio.play(); + } + }, + getTime(time) { + var h = Math.floor(time / 3600); + var m = Math.floor(time % 3600 / 60); + var s = Math.floor(time % 3600 % 60); + h = (h < 10 ? "0" : "") + h; + m = (m < 10 ? "0" : "") + m; + s = (s < 10 ? "0" : "") + s; + var str = m + ":" + s; + if (h !== "00") { + str = h + ":" + str; + } + return str; + } } - return new ServiceIntersectionObserver(getCurrentPageVm(), options); -}); -const createSelectorQuery = () => { }; -const API_CAN_I_USE = "canIUse"; -const CanIUseProtocol = [ - { - name: "schema", +const _hoisted_1$d = {class: "uni-audio-default"}; +const _hoisted_2$7 = {class: "uni-audio-right"}; +const _hoisted_3$3 = {class: "uni-audio-time"}; +const _hoisted_4$3 = {class: "uni-audio-info"}; +const _hoisted_5$2 = {class: "uni-audio-name"}; +const _hoisted_6$2 = {class: "uni-audio-author"}; +function _sfc_render$m(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-audio", mergeProps({ + id: $props.id, + controls: !!$props.controls + }, _ctx.$attrs), [ + createVNode("audio", { + ref: "audio", + loop: $props.loop, + style: {display: "none"} + }, null, 8, ["loop"]), + createVNode("div", _hoisted_1$d, [ + createVNode("div", { + style: "background-image: url(" + _ctx.$getRealPath($props.poster) + ");", + class: "uni-audio-left" + }, [ + createVNode("div", { + class: [{play: !$data.playing, pause: $data.playing}, "uni-audio-button"], + onClick: _cache[1] || (_cache[1] = (...args) => $options.trigger && $options.trigger(...args)) + }, null, 2) + ], 4), + createVNode("div", _hoisted_2$7, [ + createVNode("div", _hoisted_3$3, toDisplayString($data.currentTime), 1), + createVNode("div", _hoisted_4$3, [ + createVNode("div", _hoisted_5$2, toDisplayString($props.name), 1), + createVNode("div", _hoisted_6$2, toDisplayString($props.author), 1) + ]) + ]) + ]) + ], 16, ["id", "controls"]); +} +_sfc_main$n.render = _sfc_render$m; +const hoverProps = { + hoverClass: { type: String, - required: true + default: "none" + }, + hoverStopPropagation: { + type: Boolean, + default: false + }, + hoverStartTime: { + type: [Number, String], + default: 50 + }, + hoverStayTime: { + type: [Number, String], + default: 400 } -]; -const API_MAKE_PHONE_CALL = "makePhoneCall"; -const MakePhoneCallProtocol = { - phoneNumber: { - type: String, - required: true, - validator(phoneNumber) { - if (!phoneNumber) { - return "parameter error: parameter.phoneNumber should not be empty String;"; +}; +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 onTouchstart(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: { + onTouchstart, + 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)); +} +const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf"); +var index$5 = defineComponent({ + name: "Form", + setup(_props, { + slots, + emit + }) { + provideForm(emit); + return () => createVNode("uni-form", null, [createVNode("span", null, [slots.default && slots.default()])]); + } +}); +function provideForm(emit) { + const fields = []; + provide(uniFormKey, { + addField(field) { + fields.push(field); + }, + removeField(field) { + fields.splice(fields.indexOf(field), 1); + }, + submit() { + emit("submit", { + detail: { + value: fields.reduce((res, field) => { + const [name, value] = field.submit(); + name && (res[name] = value); + return res; + }, Object.create(null)) + } + }); + }, + reset() { + fields.forEach((field) => field.reset()); + emit("reset"); + } + }); + return fields; +} +var index$4 = defineComponent({ + 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: "" + } + }, + setup(props, { + slots + }) { + const uniForm = inject(uniFormKey); + const { + hovering, + binding + } = useHover(props); + function onClick() { + if (props.disabled) { + return; + } + const formType = props.formType; + if (formType) { + if (!uniForm) { + return; + } + if (formType === "submit") { + uniForm.submit(); + } else if (formType === "reset") { + uniForm.reset(); + } + return; + } + } + return () => { + const hoverClass = props.hoverClass; + const booleanAttrs = useBooleanAttr(props, "disabled"); + if (hoverClass && hoverClass !== "none") { + return createVNode("uni-button", mergeProps({ + onClick, + class: hovering.value ? hoverClass : "" + }, binding, booleanAttrs), [slots.default && slots.default()], 16, ["onClick"]); + } + return createVNode("uni-button", mergeProps({ + onClick + }, booleanAttrs), [slots.default && slots.default()], 16, ["onClick"]); + }; + } +}); +const pixelRatio = function() { + const canvas = document.createElement("canvas"); + canvas.height = canvas.width = 0; + const context = canvas.getContext("2d"); + const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1; + return (window.devicePixelRatio || 1) / backingStore; +}(); +const forEach = function(obj, func) { + for (const key in obj) { + if (hasOwn$1(obj, key)) { + func(obj[key], key); + } + } +}; +const ratioArgs = { + fillRect: "all", + clearRect: "all", + strokeRect: "all", + moveTo: "all", + lineTo: "all", + arc: [0, 1, 2], + arcTo: "all", + bezierCurveTo: "all", + isPointinPath: "all", + isPointinStroke: "all", + quadraticCurveTo: "all", + rect: "all", + translate: "all", + createRadialGradient: "all", + createLinearGradient: "all", + setTransform: [4, 5] +}; +const proto = CanvasRenderingContext2D.prototype; +proto.drawImageByCanvas = function(_super) { + return function(canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) { + if (!this.__hidpi__) { + return _super.apply(this, arguments); + } + srcx *= pixelRatio; + srcy *= pixelRatio; + srcw *= pixelRatio; + srch *= pixelRatio; + desx *= pixelRatio; + desy *= pixelRatio; + desw = isScale ? desw * pixelRatio : desw; + desh = isScale ? desh * pixelRatio : desh; + _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh); + }; +}(proto.drawImage); +if (pixelRatio !== 1) { + forEach(ratioArgs, function(value, key) { + proto[key] = function(_super) { + return function() { + if (!this.__hidpi__) { + return _super.apply(this, arguments); + } + let args = Array.prototype.slice.call(arguments); + if (value === "all") { + args = args.map(function(a2) { + return a2 * pixelRatio; + }); + } else if (Array.isArray(value)) { + for (let i2 = 0; i2 < value.length; i2++) { + args[value[i2]] *= pixelRatio; + } + } + return _super.apply(this, args); + }; + }(proto[key]); + }); + proto.stroke = function(_super) { + return function() { + if (!this.__hidpi__) { + return _super.apply(this, arguments); + } + this.lineWidth *= pixelRatio; + _super.apply(this, arguments); + this.lineWidth /= pixelRatio; + }; + }(proto.stroke); + proto.fillText = function(_super) { + return function() { + if (!this.__hidpi__) { + return _super.apply(this, arguments); + } + const args = Array.prototype.slice.call(arguments); + args[1] *= pixelRatio; + args[2] *= pixelRatio; + var font2 = this.font; + this.font = font2.replace(/(\d+\.?\d*)(px|em|rem|pt)/g, function(w, m, u) { + return m * pixelRatio + u; + }); + _super.apply(this, args); + this.font = font2; + }; + }(proto.fillText); + proto.strokeText = function(_super) { + return function() { + if (!this.__hidpi__) { + return _super.apply(this, arguments); + } + var args = Array.prototype.slice.call(arguments); + args[1] *= pixelRatio; + args[2] *= pixelRatio; + var font2 = this.font; + this.font = font2.replace(/(\d+\.?\d*)(px|em|rem|pt)/g, function(w, m, u) { + return m * pixelRatio + u; + }); + _super.apply(this, args); + this.font = font2; + }; + }(proto.strokeText); + proto.drawImage = function(_super) { + return function() { + if (!this.__hidpi__) { + return _super.apply(this, arguments); + } + this.scale(pixelRatio, pixelRatio); + _super.apply(this, arguments); + this.scale(1 / pixelRatio, 1 / pixelRatio); + }; + }(proto.drawImage); +} +function wrapper(canvas) { + canvas.width = canvas.offsetWidth * pixelRatio; + canvas.height = canvas.offsetHeight * pixelRatio; + canvas.getContext("2d").__hidpi__ = true; +} +var index_vue_vue_type_style_index_0_lang$b = "\nuni-canvas {\r\n width: 300px;\r\n height: 150px;\r\n display: block;\r\n position: relative;\n}\nuni-canvas > canvas {\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n width: 100%;\r\n height: 100%;\n}\r\n"; +function resolveColor(color) { + color = color.slice(0); + color[3] = color[3] / 255; + return "rgba(" + color.join(",") + ")"; +} +function processTouches(target, touches) { + return [].map.call(touches, (touch) => { + var boundingClientRect = target.getBoundingClientRect(); + return { + identifier: touch.identifier, + x: touch.clientX - boundingClientRect.left, + y: touch.clientY - boundingClientRect.top + }; + }); +} +var tempCanvas; +function getTempCanvas(width = 0, height = 0) { + if (!tempCanvas) { + tempCanvas = document.createElement("canvas"); + } + tempCanvas.width = width; + tempCanvas.height = height; + return tempCanvas; +} +const _sfc_main$m = { + name: "Canvas", + mixins: [subscriber], + props: { + canvasId: { + type: String, + default: "" + }, + disableScroll: { + type: [Boolean, String], + default: false + } + }, + data() { + return { + actionsWaiting: false + }; + }, + computed: { + id() { + return this.canvasId; + }, + _listeners() { + var $listeners = Object.assign({}, this.$listeners); + var events = ["touchstart", "touchmove", "touchend"]; + events.forEach((event2) => { + var existing = $listeners[event2]; + var eventHandler = []; + if (existing) { + eventHandler.push(($event) => { + this.$trigger(event2, Object.assign({}, $event, { + touches: processTouches($event.currentTarget, $event.touches), + changedTouches: processTouches($event.currentTarget, $event.changedTouches) + })); + }); + } + if (this.disableScroll && event2 === "touchmove") { + eventHandler.push(this._touchmove); + } + $listeners[event2] = eventHandler; + }); + return $listeners; + } + }, + created() { + this._actionsDefer = []; + this._images = {}; + }, + mounted() { + this._resize({ + width: this.$refs.sensor.$el.offsetWidth, + height: this.$refs.sensor.$el.offsetHeight + }); + }, + beforeDestroy() { + const canvas = this.$refs.canvas; + canvas.height = canvas.width = 0; + }, + methods: { + _handleSubscribe({ + type, + data = {} + }) { + var method = this[type]; + if (type.indexOf("_") !== 0 && typeof method === "function") { + method(data); + } + }, + _resize() { + var canvas = this.$refs.canvas; + if (canvas.width > 0 && canvas.height > 0) { + var context = canvas.getContext("2d"); + var imageData = context.getImageData(0, 0, canvas.width, canvas.height); + wrapper(this.$refs.canvas); + context.putImageData(imageData, 0, 0); + } else { + wrapper(this.$refs.canvas); + } + }, + _touchmove(event2) { + event2.preventDefault(); + }, + actionsChanged({ + actions, + reserve, + callbackId + }) { + var self = this; + if (!actions) { + return; + } + if (this.actionsWaiting) { + this._actionsDefer.push([actions, reserve, callbackId]); + return; + } + var canvas = this.$refs.canvas; + var c2d = canvas.getContext("2d"); + if (!reserve) { + c2d.fillStyle = "#000000"; + c2d.strokeStyle = "#000000"; + c2d.shadowColor = "#000000"; + c2d.shadowBlur = 0; + c2d.shadowOffsetX = 0; + c2d.shadowOffsetY = 0; + c2d.setTransform(1, 0, 0, 1, 0, 0); + c2d.clearRect(0, 0, canvas.width, canvas.height); + } + this.preloadImage(actions); + for (let index2 = 0; index2 < actions.length; index2++) { + const action = actions[index2]; + let method = action.method; + const data = action.data; + if (/^set/.test(method) && method !== "setTransform") { + const method1 = method[3].toLowerCase() + method.slice(4); + let color; + if (method1 === "fillStyle" || method1 === "strokeStyle") { + if (data[0] === "normal") { + color = resolveColor(data[1]); + } else if (data[0] === "linear") { + const LinearGradient = c2d.createLinearGradient(...data[1]); + data[2].forEach(function(data2) { + const offset = data2[0]; + const color2 = resolveColor(data2[1]); + LinearGradient.addColorStop(offset, color2); + }); + color = LinearGradient; + } else if (data[0] === "radial") { + const x = data[1][0]; + const y = data[1][1]; + const r = data[1][2]; + const LinearGradient = c2d.createRadialGradient(x, y, 0, x, y, r); + data[2].forEach(function(data2) { + const offset = data2[0]; + const color2 = resolveColor(data2[1]); + LinearGradient.addColorStop(offset, color2); + }); + color = LinearGradient; + } else if (data[0] === "pattern") { + const loaded = this.checkImageLoaded(data[1], actions.slice(index2 + 1), callbackId, function(image2) { + if (image2) { + c2d[method1] = c2d.createPattern(image2, data[2]); + } + }); + if (!loaded) { + break; + } + continue; + } + c2d[method1] = color; + } else if (method1 === "globalAlpha") { + c2d[method1] = data[0] / 255; + } else if (method1 === "shadow") { + var _ = ["shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor"]; + data.forEach(function(color_, method_) { + c2d[_[method_]] = _[method_] === "shadowColor" ? resolveColor(color_) : color_; + }); + } else { + if (method1 === "fontSize") { + c2d.font = c2d.font.replace(/\d+\.?\d*px/, data[0] + "px"); + } else { + if (method1 === "lineDash") { + c2d.setLineDash(data[0]); + c2d.lineDashOffset = data[1] || 0; + } else { + if (method1 === "textBaseline") { + if (data[0] === "normal") { + data[0] = "alphabetic"; + } + c2d[method1] = data[0]; + } else { + c2d[method1] = data[0]; + } + } + } + } + } else if (method === "fillPath" || method === "strokePath") { + method = method.replace(/Path/, ""); + c2d.beginPath(); + data.forEach(function(data_) { + c2d[data_.method].apply(c2d, data_.data); + }); + c2d[method](); + } else if (method === "fillText") { + c2d.fillText.apply(c2d, data); + } else if (method === "drawImage") { + var A = function() { + var dataArray = [...data]; + var url = dataArray[0]; + var otherData = dataArray.slice(1); + self._images = self._images || {}; + if (!self.checkImageLoaded(url, actions.slice(index2 + 1), callbackId, function(image2) { + if (image2) { + c2d.drawImage.apply(c2d, [image2].concat([...otherData.slice(4, 8)], [...otherData.slice(0, 4)])); + } + })) + return "break"; + }(); + if (A === "break") { + break; + } + } else { + if (method === "clip") { + data.forEach(function(data_) { + c2d[data_.method].apply(c2d, data_.data); + }); + c2d.clip(); + } else { + c2d[method].apply(c2d, data); + } + } + } + if (!this.actionsWaiting && callbackId) { + UniViewJSBridge.publishHandler("onDrawCanvas", { + callbackId, + data: { + errMsg: "drawCanvas:ok" + } + }, this.$page.id); + } + }, + preloadImage: function(actions) { + var self = this; + actions.forEach(function(action) { + var method = action.method; + var data = action.data; + var src = ""; + if (method === "drawImage") { + src = data[0]; + src = self.$getRealPath(src); + data[0] = src; + } else if (method === "setFillStyle" && data[0] === "pattern") { + src = data[1]; + src = self.$getRealPath(src); + data[1] = src; + } + if (src && !self._images[src]) { + loadImage(); + } + function loadImage() { + self._images[src] = new Image(); + self._images[src].onload = function() { + self._images[src].ready = true; + }; + function loadBlob(blob) { + self._images[src].src = (window.URL || window.webkitURL).createObjectURL(blob); + } + function loadFile(path) { + var bitmap = new plus.nativeObj.Bitmap("bitmap" + Date.now()); + bitmap.load(path, function() { + self._images[src].src = bitmap.toBase64Data(); + bitmap.clear(); + }, function() { + bitmap.clear(); + console.error("preloadImage error"); + }); + } + function loadUrl(url) { + function plusDownload() { + plus.downloader.createDownload(url, { + filename: "_doc/uniapp_temp/download/" + }, function(d, status) { + if (status === 200) { + loadFile(d.filename); + } else { + self._images[src].src = src; + } + }).start(); + } + var xhr = new XMLHttpRequest(); + xhr.open("GET", url, true); + xhr.responseType = "blob"; + xhr.onload = function() { + if (this.status === 200) { + loadBlob(this.response); + } + }; + xhr.onerror = window.plus ? plusDownload : function() { + self._images[src].src = src; + }; + xhr.send(); + } + if (window.plus && (!window.webkit || !window.webkit.messageHandlers)) { + self._images[src].src = src; + } else { + if (window.plus && src.indexOf("http://") !== 0 && src.indexOf("https://") !== 0 && !/^data:.*,.*/.test(src)) { + loadFile(src); + } else if (/^data:.*,.*/.test(src)) { + self._images[src].src = src; + } else { + loadUrl(src); + } + } + } + }); + }, + checkImageLoaded: function(src, actions, callbackId, fn) { + var self = this; + var image2 = this._images[src]; + if (image2.ready) { + fn(image2); + return true; + } else { + this._actionsDefer.unshift([actions, true]); + this.actionsWaiting = true; + image2.onload = function() { + image2.ready = true; + fn(image2); + self.actionsWaiting = false; + var actions2 = self._actionsDefer.slice(0); + self._actionsDefer = []; + for (var action = actions2.shift(); action; ) { + self.actionsChanged({ + actions: action[0], + reserve: action[1], + callbackId + }); + action = actions2.shift(); + } + }; + return false; + } + }, + getImageData({ + x = 0, + y = 0, + width, + height, + destWidth, + destHeight, + hidpi = true, + callbackId + }) { + var imgData; + var canvas = this.$refs.canvas; + if (!width) { + width = canvas.offsetWidth - x; + } + if (!height) { + height = canvas.offsetHeight - y; + } + try { + if (!hidpi) { + if (!destWidth && !destHeight) { + destWidth = Math.round(width * pixelRatio); + destHeight = Math.round(height * pixelRatio); + } else if (!destWidth) { + destWidth = Math.round(width / height * destHeight); + } else if (!destHeight) { + destHeight = Math.round(height / width * destWidth); + } + } else { + destWidth = width; + destHeight = height; + } + const newCanvas = getTempCanvas(destWidth, destHeight); + const context = newCanvas.getContext("2d"); + context.__hidpi__ = true; + context.drawImageByCanvas(canvas, x, y, width, height, 0, 0, destWidth, destHeight, false); + imgData = context.getImageData(0, 0, destWidth, destHeight); + newCanvas.height = newCanvas.width = 0; + context.__hidpi__ = false; + } catch (error) { + if (!callbackId) { + return; + } + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasGetImageData:fail" + } + }, this.$page.id); + return; + } + if (!callbackId) { + return { + data: Array.prototype.slice.call(imgData.data), + width: destWidth, + height: destHeight + }; + } else { + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasGetImageData:ok", + data: [...imgData.data], + width: destWidth, + height: destHeight + } + }, this.$page.id); + } + }, + putImageData({ + data, + x, + y, + width, + height, + callbackId + }) { + try { + if (!height) { + height = Math.round(data.length / 4 / width); + } + const canvas = getTempCanvas(width, height); + const context = canvas.getContext("2d"); + context.putImageData(new ImageData(new Uint8ClampedArray(data), width, height), 0, 0); + this.$refs.canvas.getContext("2d").drawImage(canvas, x, y, width, height); + canvas.height = canvas.width = 0; + } catch (error) { + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasPutImageData:fail" + } + }, this.$page.id); + return; + } + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasPutImageData:ok" + } + }, this.$page.id); + }, + getDataUrl({ + x = 0, + y = 0, + width, + height, + destWidth, + destHeight, + hidpi = true, + fileType, + qualit, + callbackId + }) { + const res = this.getImageData({ + x, + y, + width, + height, + destWidth, + destHeight, + hidpi + }); + if (!res.data || !res.data.length) { + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasGetDataUrl:fail" + } + }, this.$page.id); + return; + } + let imgData; + try { + imgData = new ImageData(new Uint8ClampedArray(res.data), res.width, res.height); + } catch (error) { + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasGetDataUrl:fail" + } + }, this.$page.id); + return; } + destWidth = res.width; + destHeight = res.height; + const canvas = getTempCanvas(destWidth, destHeight); + const c2d = canvas.getContext("2d"); + c2d.putImageData(imgData, 0, 0); + let base64 = canvas.toDataURL("image/png"); + canvas.height = canvas.width = 0; + const img = new Image(); + img.onload = () => { + const canvas2 = getTempCanvas(destWidth, destHeight); + if (fileType === "jpeg" || fileType === "jpg") { + fileType = "jpeg"; + c2d.fillStyle = "#fff"; + c2d.fillRect(0, 0, destWidth, destHeight); + } + c2d.drawImage(img, 0, 0); + base64 = canvas2.toDataURL(`image/${fileType}`, qualit); + canvas2.height = canvas2.width = 0; + UniViewJSBridge.publishHandler("onCanvasMethodCallback", { + callbackId, + data: { + errMsg: "canvasGetDataUrl:ok", + base64 + } + }, this.$page.id); + }; + img.src = base64; } } }; -const API_OPEN_DOCUMENT = "openDocument"; -const OpenDocumentProtocol = { - filePath: { - type: String, - required: true - }, - fileType: { - type: String - } +const _hoisted_1$c = { + ref: "canvas", + width: "300", + height: "150" }; -const API_GET_IMAGE_INFO = "getImageInfo"; -const GetImageInfoOptions = { - formatArgs: { - src(src, params) { - params.src = getRealPath(src); +const _hoisted_2$6 = {style: {position: "absolute", top: "0", left: "0", width: "100%", height: "100%", overflow: "hidden"}}; +function _sfc_render$l(_ctx, _cache, $props, $setup, $data, $options) { + const _component_v_uni_resize_sensor = resolveComponent("v-uni-resize-sensor"); + return openBlock(), createBlock("uni-canvas", mergeProps({ + "canvas-id": $props.canvasId, + "disable-scroll": $props.disableScroll + }, toHandlers($options._listeners)), [ + createVNode("canvas", _hoisted_1$c, null, 512), + createVNode("div", _hoisted_2$6, [ + renderSlot(_ctx.$slots, "default") + ]), + createVNode(_component_v_uni_resize_sensor, { + ref: "sensor", + onResize: $options._resize + }, null, 8, ["onResize"]) + ], 16, ["canvas-id", "disable-scroll"]); +} +_sfc_main$m.render = _sfc_render$l; +const _sfc_main$l = { + name: "Checkbox", + mixins: [emitter, listeners], + props: { + checked: { + type: [Boolean, String], + default: false + }, + id: { + type: String, + default: "" + }, + disabled: { + type: [Boolean, String], + default: false + }, + color: { + type: String, + default: "#007aff" + }, + value: { + type: String, + default: "" } - } -}; -const GetImageInfoProtocol = { - src: { - type: String, - required: true - } -}; -const API_REQUEST = "request"; -const METHOD = [ - "GET", - "OPTIONS", - "HEAD", - "POST", - "PUT", - "DELETE", - "TRACE", - "CONNECT" -]; -const DEFAULT_METHOD = "GET"; -const dataType = { - JSON: "json" -}; -const RESPONSE_TYPE = ["text", "arraybuffer"]; -const DEFAULT_RESPONSE_TYPE = "text"; -const encode = encodeURIComponent; -function stringifyQuery(url, data) { - let str = url.split("#"); - const hash = str[1] || ""; - str = str[0].split("?"); - let query = str[1] || ""; - url = str[0]; - const search = query.split("&").filter((item) => item); - const params = {}; - search.forEach((item) => { - const part = item.split("="); - params[part[0]] = part[1]; - }); - for (const key in data) { - if (hasOwn$1(data, key)) { - let v2 = data[key]; - if (typeof v2 === "undefined" || v2 === null) { - v2 = ""; - } else if (isPlainObject(v2)) { - v2 = JSON.stringify(v2); + }, + data() { + return { + checkboxChecked: this.checked, + checkboxValue: this.value + }; + }, + watch: { + checked(val) { + this.checkboxChecked = val; + }, + value(val) { + this.checkboxValue = val; + } + }, + listeners: { + "label-click": "_onClick", + "@label-click": "_onClick" + }, + created() { + this.$dispatch("CheckboxGroup", "uni-checkbox-group-update", { + type: "add", + vm: this + }); + this.$dispatch("Form", "uni-form-group-update", { + type: "add", + vm: this + }); + }, + beforeDestroy() { + this.$dispatch("CheckboxGroup", "uni-checkbox-group-update", { + type: "remove", + vm: this + }); + this.$dispatch("Form", "uni-form-group-update", { + type: "remove", + vm: this + }); + }, + methods: { + _onClick($event) { + if (this.disabled) { + return; } - params[encode(key)] = encode(v2); + this.checkboxChecked = !this.checkboxChecked; + this.$dispatch("CheckboxGroup", "uni-checkbox-change", $event); + }, + _resetFormData() { + this.checkboxChecked = false; } } - query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&"); - return url + (query ? "?" + query : "") + (hash ? "#" + hash : ""); +}; +const _hoisted_1$b = {class: "uni-checkbox-wrapper"}; +function _sfc_render$k(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-checkbox", mergeProps({disabled: $props.disabled}, _ctx.$attrs, { + onClick: _cache[1] || (_cache[1] = (...args) => $options._onClick && $options._onClick(...args)) + }), [ + createVNode("div", _hoisted_1$b, [ + createVNode("div", { + class: [[$data.checkboxChecked ? "uni-checkbox-input-checked" : ""], "uni-checkbox-input"], + style: {color: $props.color} + }, null, 6), + renderSlot(_ctx.$slots, "default") + ]) + ], 16, ["disabled"]); } -const RequestProtocol = { - method: { - type: String - }, - data: { - type: [Object, String, Array, ArrayBuffer] +_sfc_main$l.render = _sfc_render$k; +var index_vue_vue_type_style_index_0_lang$a = "\nuni-checkbox-group[hidden] {\r\n display: none;\n}\r\n"; +const _sfc_main$k = { + name: "CheckboxGroup", + mixins: [emitter, listeners], + props: { + name: { + type: String, + default: "" + } }, - url: { - type: String, - required: true + data() { + return { + checkboxList: [] + }; }, - header: { - type: Object + listeners: { + "@checkbox-change": "_changeHandler", + "@checkbox-group-update": "_checkboxGroupUpdateHandler" }, - dataType: { - type: String + created() { + this.$dispatch("Form", "uni-form-group-update", { + type: "add", + vm: this + }); }, - responseType: { - type: String + beforeDestroy() { + this.$dispatch("Form", "uni-form-group-update", { + type: "remove", + vm: this + }); }, - withCredentials: { - type: Boolean - } -}; -const RequestOptions = { - formatArgs: { - method(value, params) { - params.method = (value || "").toUpperCase(); - if (METHOD.indexOf(params.method) === -1) { - params.method = DEFAULT_METHOD; - } - }, - data(value, params) { - params.data = value || ""; - }, - url(value, params) { - if (params.method === DEFAULT_METHOD && isPlainObject(params.data) && Object.keys(params.data).length) { - params.url = stringifyQuery(value, params.data); - } - }, - header(value, params) { - const header = params.header = value || {}; - if (params.method !== DEFAULT_METHOD) { - if (!Object.keys(header).find((key) => key.toLowerCase() === "content-type")) { - header["Content-Type"] = "application/json"; + methods: { + _changeHandler($event) { + const value = []; + this.checkboxList.forEach((vm) => { + if (vm.checkboxChecked) { + value.push(vm.value); } - } + }); + this.$trigger("change", $event, { + value + }); }, - dataType(value, params) { - params.dataType = (value || dataType.JSON).toLowerCase(); + _checkboxGroupUpdateHandler($event) { + if ($event.type === "add") { + this.checkboxList.push($event.vm); + } else { + const index2 = this.checkboxList.indexOf($event.vm); + this.checkboxList.splice(index2, 1); + } }, - responseType(value, params) { - params.responseType = (value || "").toLowerCase(); - if (RESPONSE_TYPE.indexOf(params.responseType) === -1) { - params.responseType = DEFAULT_RESPONSE_TYPE; + _getFormData() { + const data = {}; + if (this.name !== "") { + const value = []; + this.checkboxList.forEach((vm) => { + if (vm.checkboxChecked) { + value.push(vm.value); + } + }); + data.value = value; + data.key = this.name; } + return data; } } }; -function encodeQueryString(url) { - if (typeof url !== "string") { - return url; - } - const index2 = url.indexOf("?"); - if (index2 === -1) { - return url; - } - const query = url.substr(index2 + 1).trim().replace(/^(\?|#|&)/, ""); - if (!query) { - return url; - } - url = url.substr(0, index2); - const params = []; - query.split("&").forEach((param) => { - const parts = param.replace(/\+/g, " ").split("="); - const key = parts.shift(); - const val = parts.length > 0 ? parts.join("=") : ""; - params.push(key + "=" + encodeURIComponent(val)); - }); - return params.length ? url + "?" + params.join("&") : url; +function _sfc_render$j(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-checkbox-group", _ctx.$attrs, [ + renderSlot(_ctx.$slots, "default") + ], 16); } -const ANIMATION_IN = [ - "slide-in-right", - "slide-in-left", - "slide-in-top", - "slide-in-bottom", - "fade-in", - "zoom-out", - "zoom-fade-out", - "pop-in", - "none" -]; -const ANIMATION_OUT = [ - "slide-out-right", - "slide-out-left", - "slide-out-top", - "slide-out-bottom", - "fade-out", - "zoom-in", - "zoom-fade-in", - "pop-out", - "none" -]; -const BaseRouteProtocol = { - url: { - type: String, - required: true - } -}; -const API_NAVIGATE_TO = "navigateTo"; -const API_REDIRECT_TO = "redirectTo"; -const API_RE_LAUNCH = "reLaunch"; -const API_SWITCH_TAB = "switchTab"; -const API_NAVIGATE_BACK = "navigateBack"; -const API_PRELOAD_PAGE = "preloadPage"; -const API_UN_PRELOAD_PAGE = "unPreloadPage"; -const NavigateToProtocol = extend({}, BaseRouteProtocol, createAnimationProtocol(ANIMATION_IN)); -const NavigateBackProtocol = extend({ - delta: { - type: Number - } -}, createAnimationProtocol(ANIMATION_OUT)); -const RedirectToProtocol = BaseRouteProtocol; -const ReLaunchProtocol = BaseRouteProtocol; -const SwitchTabProtocol = BaseRouteProtocol; -const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO); -const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO); -const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH); -const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB); -const NavigateBackOptions = { - formatArgs: { - delta(delta, params) { - delta = parseInt(delta) || 1; - params.delta = Math.min(getCurrentPages().length - 1, delta); - } - } -}; -function createAnimationProtocol(animationTypes) { - return { - animationType: { - type: String, - validator(type) { - if (type && animationTypes.indexOf(type) === -1) { - return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)"; +_sfc_main$k.render = _sfc_render$j; +var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/; +var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/; +var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g; +var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"); +var block = makeMap("a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"); +var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"); +var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"); +var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"); +var special = makeMap("script,style"); +function HTMLParser(html, handler) { + var index2; + var chars2; + var match; + var stack = []; + var last = html; + stack.last = function() { + return this[this.length - 1]; + }; + while (html) { + chars2 = true; + if (!stack.last() || !special[stack.last()]) { + if (html.indexOf(""); + if (index2 >= 0) { + if (handler.comment) { + handler.comment(html.substring(4, index2)); + } + html = html.substring(index2 + 3); + chars2 = false; + } + } else if (html.indexOf("]*>"), function(all, text3) { + text3 = text3.replace(/|/g, "$1$2"); + if (handler.chars) { + handler.chars(text3); + } + return ""; + }); + parseEndTag("", stack.last()); } - const routeOptions = __uniRoutes.find(({path}) => path === pagePath); - if (!routeOptions) { - return "page `" + url + "` is not found"; + if (html == last) { + throw "Parse Error: " + html; } - if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) { - if (routeOptions.meta.isTabBar) { - return `can not ${type} a tabbar page`; - } - } else if (type === API_SWITCH_TAB) { - if (!routeOptions.meta.isTabBar) { - return "can not switch to no-tabBar page"; + last = html; + } + parseEndTag(); + function parseStartTag(tag, tagName, rest, unary) { + tagName = tagName.toLowerCase(); + if (block[tagName]) { + while (stack.last() && inline[stack.last()]) { + parseEndTag("", stack.last()); } } - if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") { - url = pagePath; + if (closeSelf[tagName] && stack.last() == tagName) { + parseEndTag("", tagName); } - if (routeOptions.meta.isEntry) { - url = url.replace(routeOptions.path, "/"); + unary = empty[tagName] || !!unary; + if (!unary) { + stack.push(tagName); } - params.url = encodeQueryString(url); - if (type === API_UN_PRELOAD_PAGE) { - return; - } else if (type === API_PRELOAD_PAGE) { - if (routeOptions.meta.isTabBar) { - const pages = getCurrentPages(true); - const tabBarPagePath = routeOptions.path.substr(1); - if (pages.find((page) => page.route === tabBarPagePath)) { - return "tabBar page `" + tabBarPagePath + "` already exists"; - } + if (handler.start) { + var attrs2 = []; + rest.replace(attr, function(match2, name) { + var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : ""; + attrs2.push({ + name, + value, + escaped: value.replace(/(^|[^\\])"/g, '$1\\"') + }); + }); + if (handler.start) { + handler.start(tagName, attrs2, unary); } - return; } - if (navigatorLock === url && params.openType !== "appLaunch") { - return `${navigatorLock} locked`; - } - if (__uniConfig.ready) { - navigatorLock = url; - } - }; -} -const initIntersectionObserverPolyfill = function() { - if (typeof window !== "object") { - return; } - if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) { - if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) { - Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", { - get: function() { - return this.intersectionRatio > 0; + function parseEndTag(tag, tagName) { + if (!tagName) { + var pos = 0; + } else { + for (var pos = stack.length - 1; pos >= 0; pos--) { + if (stack[pos] == tagName) { + break; } - }); + } } - return; - } - function getFrameElement(doc) { - try { - return doc.defaultView && doc.defaultView.frameElement || null; - } catch (e2) { - return null; + if (pos >= 0) { + for (var i2 = stack.length - 1; i2 >= pos; i2--) { + if (handler.end) { + handler.end(stack[i2]); + } + } + stack.length = pos; } } - var document2 = function(startDoc) { - var doc = startDoc; - var frame = getFrameElement(doc); - while (frame) { - doc = frame.ownerDocument; - frame = getFrameElement(doc); - } - return doc; - }(window.document); - var registry = []; - var crossOriginUpdater = null; - var crossOriginRect = null; - function IntersectionObserverEntry(entry) { - this.time = entry.time; - this.target = entry.target; - this.rootBounds = ensureDOMRect(entry.rootBounds); - this.boundingClientRect = ensureDOMRect(entry.boundingClientRect); - this.intersectionRect = ensureDOMRect(entry.intersectionRect || getEmptyRect()); - this.isIntersecting = !!entry.intersectionRect; - var targetRect = this.boundingClientRect; - var targetArea = targetRect.width * targetRect.height; - var intersectionRect = this.intersectionRect; - var intersectionArea = intersectionRect.width * intersectionRect.height; - if (targetArea) { - this.intersectionRatio = Number((intersectionArea / targetArea).toFixed(4)); - } else { - this.intersectionRatio = this.isIntersecting ? 1 : 0; - } +} +function makeMap(str) { + var obj = {}; + var items = str.split(","); + for (var i2 = 0; i2 < items.length; i2++) { + obj[items[i2]] = true; } - function IntersectionObserver2(callback, opt_options) { - var options = opt_options || {}; - if (typeof callback != "function") { - throw new Error("callback must be a function"); - } - if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) { - throw new Error("root must be a Document or Element"); - } - this._checkForIntersections = throttle2(this._checkForIntersections.bind(this), this.THROTTLE_TIMEOUT); - this._callback = callback; - this._observationTargets = []; - this._queuedEntries = []; - this._rootMarginValues = this._parseRootMargin(options.rootMargin); - this.thresholds = this._initThresholds(options.threshold); - this.root = options.root || null; - this.rootMargin = this._rootMarginValues.map(function(margin) { - return margin.value + margin.unit; - }).join(" "); - this._monitoringDocuments = []; - this._monitoringUnsubscribes = []; + return obj; +} +function divider(Quill) { + const BlockEmbed = Quill.import("blots/block/embed"); + class Divider extends BlockEmbed { } - IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100; - IntersectionObserver2.prototype.POLL_INTERVAL = null; - IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true; - IntersectionObserver2._setupCrossOriginUpdater = function() { - if (!crossOriginUpdater) { - crossOriginUpdater = function(boundingClientRect, intersectionRect) { - if (!boundingClientRect || !intersectionRect) { - crossOriginRect = getEmptyRect(); - } else { - crossOriginRect = convertFromParentRect(boundingClientRect, intersectionRect); - } - registry.forEach(function(observer) { - observer._checkForIntersections(); - }); - }; - } - return crossOriginUpdater; - }; - IntersectionObserver2._resetCrossOriginUpdater = function() { - crossOriginUpdater = null; - crossOriginRect = null; + Divider.blotName = "divider"; + Divider.tagName = "HR"; + return { + "formats/divider": Divider }; - IntersectionObserver2.prototype.observe = function(target) { - var isTargetAlreadyObserved = this._observationTargets.some(function(item) { - return item.element == target; - }); - if (isTargetAlreadyObserved) { - return; - } - if (!(target && target.nodeType == 1)) { - throw new Error("target must be an Element"); - } - this._registerInstance(); - this._observationTargets.push({element: target, entry: null}); - this._monitorIntersections(target.ownerDocument); - this._checkForIntersections(); +} +function ins(Quill) { + const Inline = Quill.import("blots/inline"); + class Ins extends Inline { + } + Ins.blotName = "ins"; + Ins.tagName = "INS"; + return { + "formats/ins": Ins }; - IntersectionObserver2.prototype.unobserve = function(target) { - this._observationTargets = this._observationTargets.filter(function(item) { - return item.element != target; - }); - this._unmonitorIntersections(target.ownerDocument); - if (this._observationTargets.length == 0) { - this._unregisterInstance(); - } +} +function align(Quill) { + const {Scope, Attributor} = Quill.import("parchment"); + const config = { + scope: Scope.BLOCK, + whitelist: ["left", "right", "center", "justify"] }; - IntersectionObserver2.prototype.disconnect = function() { - this._observationTargets = []; - this._unmonitorAllIntersections(); - this._unregisterInstance(); + const AlignStyle = new Attributor.Style("align", "text-align", config); + return { + "formats/align": AlignStyle }; - IntersectionObserver2.prototype.takeRecords = function() { - var records = this._queuedEntries.slice(); - this._queuedEntries = []; - return records; +} +function direction(Quill) { + const {Scope, Attributor} = Quill.import("parchment"); + const config = { + scope: Scope.BLOCK, + whitelist: ["rtl"] }; - IntersectionObserver2.prototype._initThresholds = function(opt_threshold) { - var threshold = opt_threshold || [0]; - if (!Array.isArray(threshold)) - threshold = [threshold]; - return threshold.sort().filter(function(t2, i2, a2) { - if (typeof t2 != "number" || isNaN(t2) || t2 < 0 || t2 > 1) { - throw new Error("threshold must be a number between 0 and 1 inclusively"); - } - return t2 !== a2[i2 - 1]; - }); + const DirectionStyle = new Attributor.Style("direction", "direction", config); + return { + "formats/direction": DirectionStyle }; - IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) { - var marginString = opt_rootMargin || "0px"; - var margins = marginString.split(/\s+/).map(function(margin) { - var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin); - if (!parts) { - throw new Error("rootMargin must be specified in pixels or percent"); +} +function list(Quill) { + const Parchment = Quill.import("parchment"); + const Container = Quill.import("blots/container"); + const ListItem = Quill.import("formats/list/item"); + class List extends Container { + static create(value) { + const tagName = value === "ordered" ? "OL" : "UL"; + const node = super.create(tagName); + if (value === "checked" || value === "unchecked") { + node.setAttribute("data-checked", value === "checked"); } - return {value: parseFloat(parts[1]), unit: parts[2]}; - }); - margins[1] = margins[1] || margins[0]; - margins[2] = margins[2] || margins[0]; - margins[3] = margins[3] || margins[1]; - return margins; - }; - IntersectionObserver2.prototype._monitorIntersections = function(doc) { - var win = doc.defaultView; - if (!win) { - return; + return node; + } + static formats(domNode) { + if (domNode.tagName === "OL") + return "ordered"; + if (domNode.tagName === "UL") { + if (domNode.hasAttribute("data-checked")) { + return domNode.getAttribute("data-checked") === "true" ? "checked" : "unchecked"; + } else { + return "bullet"; + } + } + return void 0; } - if (this._monitoringDocuments.indexOf(doc) != -1) { - return; + constructor(domNode) { + super(domNode); + const listEventHandler = (e2) => { + if (e2.target.parentNode !== domNode) + return; + const format = this.statics.formats(domNode); + const blot = Parchment.find(e2.target); + if (format === "checked") { + blot.format("list", "unchecked"); + } else if (format === "unchecked") { + blot.format("list", "checked"); + } + }; + domNode.addEventListener("click", listEventHandler); } - var callback = this._checkForIntersections; - var monitoringInterval = null; - var domObserver = null; - if (this.POLL_INTERVAL) { - monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL); - } else { - addEvent(win, "resize", callback, true); - addEvent(doc, "scroll", callback, true); - if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) { - domObserver = new win.MutationObserver(callback); - domObserver.observe(doc, { - attributes: true, - childList: true, - characterData: true, - subtree: true - }); + format(name, value) { + if (this.children.length > 0) { + this.children.tail.format(name, value); } } - this._monitoringDocuments.push(doc); - this._monitoringUnsubscribes.push(function() { - var win2 = doc.defaultView; - if (win2) { - if (monitoringInterval) { - win2.clearInterval(monitoringInterval); - } - removeEvent(win2, "resize", callback, true); + formats() { + return {[this.statics.blotName]: this.statics.formats(this.domNode)}; + } + insertBefore(blot, ref2) { + if (blot instanceof ListItem) { + super.insertBefore(blot, ref2); + } else { + const index2 = ref2 == null ? this.length() : ref2.offset(this); + const after = this.split(index2); + after.parent.insertBefore(blot, after); } - removeEvent(doc, "scroll", callback, true); - if (domObserver) { - domObserver.disconnect(); + } + optimize(context) { + super.optimize(context); + const next = this.next; + if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute("data-checked") === this.domNode.getAttribute("data-checked")) { + next.moveChildren(this); + next.remove(); } - }); - var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; - if (doc != rootDoc) { - var frame = getFrameElement(doc); - if (frame) { - this._monitorIntersections(frame.ownerDocument); + } + replace(target) { + if (target.statics.blotName !== this.statics.blotName) { + const item = Parchment.create(this.statics.defaultChild); + target.moveChildren(item); + this.appendChild(item); } + super.replace(target); } + } + List.blotName = "list"; + List.scope = Parchment.Scope.BLOCK_BLOT; + List.tagName = ["OL", "UL"]; + List.defaultChild = "list-item"; + List.allowedChildren = [ListItem]; + return { + "formats/list": List }; - IntersectionObserver2.prototype._unmonitorIntersections = function(doc) { - var index2 = this._monitoringDocuments.indexOf(doc); - if (index2 == -1) { - return; +} +function background(Quill) { + const {Scope} = Quill.import("parchment"); + const BackgroundStyle = Quill.import("formats/background"); + const BackgroundColorStyle = new BackgroundStyle.constructor("backgroundColor", "background-color", { + scope: Scope.INLINE + }); + return { + "formats/backgroundColor": BackgroundColorStyle + }; +} +function box(Quill) { + const {Scope, Attributor} = Quill.import("parchment"); + const config = { + scope: Scope.BLOCK + }; + const margin = [ + "margin", + "marginTop", + "marginBottom", + "marginLeft", + "marginRight" + ]; + const padding = [ + "padding", + "paddingTop", + "paddingBottom", + "paddingLeft", + "paddingRight" + ]; + const result = {}; + margin.concat(padding).forEach((name) => { + result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), config); + }); + return result; +} +function font(Quill) { + const {Scope, Attributor} = Quill.import("parchment"); + const config = { + scope: Scope.INLINE + }; + const font2 = [ + "font", + "fontSize", + "fontStyle", + "fontVariant", + "fontWeight", + "fontFamily" + ]; + const result = {}; + font2.forEach((name) => { + result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), config); + }); + return result; +} +function text(Quill) { + const {Scope, Attributor} = Quill.import("parchment"); + const text2 = [ + { + name: "lineHeight", + scope: Scope.BLOCK + }, + { + name: "letterSpacing", + scope: Scope.INLINE + }, + { + name: "textDecoration", + scope: Scope.INLINE + }, + { + name: "textIndent", + scope: Scope.BLOCK } - var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; - var hasDependentTargets = this._observationTargets.some(function(item) { - var itemDoc = item.element.ownerDocument; - if (itemDoc == doc) { - return true; + ]; + const result = {}; + text2.forEach(({name, scope}) => { + result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), { + scope + }); + }); + return result; +} +function image(Quill) { + const Image2 = Quill.import("formats/image"); + const ATTRIBUTES = [ + "alt", + "height", + "width", + "data-custom", + "class", + "data-local" + ]; + Image2.sanitize = (url) => url; + Image2.formats = function formats(domNode) { + return ATTRIBUTES.reduce(function(formats2, attribute) { + if (domNode.hasAttribute(attribute)) { + formats2[attribute] = domNode.getAttribute(attribute); } - while (itemDoc && itemDoc != rootDoc) { - var frame2 = getFrameElement(itemDoc); - itemDoc = frame2 && frame2.ownerDocument; - if (itemDoc == doc) { - return true; + return formats2; + }, {}); + }; + const format = Image2.prototype.format; + Image2.prototype.format = function(name, value) { + if (ATTRIBUTES.indexOf(name) > -1) { + if (value) { + this.domNode.setAttribute(name, value); + } else { + this.domNode.removeAttribute(name); + } + } else { + format.call(this, name, value); + } + }; +} +function register(Quill) { + const formats = { + divider, + ins, + align, + direction, + list, + background, + box, + font, + text, + image + }; + const options = {}; + Object.values(formats).forEach((value) => Object.assign(options, value(Quill))); + Quill.register(options, true); +} +var editor_css_vue_type_style_index_0_src_lang = ".ql-container {\n display: block;\n position: relative;\n box-sizing: border-box;\n -webkit-user-select: text;\n user-select: text;\n outline: none;\n overflow: hidden;\n width: 100%;\n height: 200px;\n min-height: 200px;\n}\n.ql-container[hidden] {\n display: none;\n}\n.ql-container .ql-editor {\n position: relative;\n font-size: inherit;\n line-height: inherit;\n font-family: inherit;\n min-height: inherit;\n width: 100%;\n height: 100%;\n padding: 0;\n overflow-x: hidden;\n overflow-y: auto;\n -webkit-tap-highlight-color: transparent;\n -webkit-touch-callout: none;\n -webkit-overflow-scrolling: touch;\n}\n.ql-container .ql-editor::-webkit-scrollbar {\n width: 0 !important;\n}\n.ql-container .ql-editor.scroll-disabled {\n overflow: hidden;\n}\n.ql-container .ql-image-overlay {\n display: flex;\n position: absolute;\n box-sizing: border-box;\n border: 1px dashed #ccc;\n justify-content: center;\n align-items: center;\n -webkit-user-select: none;\n user-select: none;\n}\n.ql-container .ql-image-overlay .ql-image-size {\n position: absolute;\n padding: 4px 8px;\n text-align: center;\n background-color: #fff;\n color: #888;\n border: 1px solid #ccc;\n box-sizing: border-box;\n opacity: 0.8;\n right: 4px;\n top: 4px;\n font-size: 12px;\n display: inline-block;\n width: auto;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar {\n position: relative;\n text-align: center;\n box-sizing: border-box;\n background: #000;\n border-radius: 5px;\n color: #fff;\n font-size: 0;\n min-height: 24px;\n z-index: 100;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar span {\n display: inline-block;\n cursor: pointer;\n padding: 5px;\n font-size: 12px;\n border-right: 1px solid #fff;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar span:last-child {\n border-right: 0;\n}\n.ql-container .ql-image-overlay .ql-image-toolbar span.triangle-up {\n padding: 0;\n position: absolute;\n top: -12px;\n left: 50%;\n transform: translatex(-50%);\n width: 0;\n height: 0;\n border-width: 6px;\n border-style: solid;\n border-color: transparent transparent black transparent;\n}\n.ql-container .ql-image-overlay .ql-image-handle {\n position: absolute;\n height: 12px;\n width: 12px;\n border-radius: 50%;\n border: 1px solid #ccc;\n box-sizing: border-box;\n background: #fff;\n}\n.ql-container img {\n display: inline-block;\n max-width: 100%;\n}\n.ql-clipboard p {\n margin: 0;\n padding: 0;\n}\n.ql-editor {\n box-sizing: border-box;\n height: 100%;\n outline: none;\n overflow-y: auto;\n tab-size: 4;\n -moz-tab-size: 4;\n text-align: left;\n white-space: pre-wrap;\n word-wrap: break-word;\n}\n.ql-editor > * {\n cursor: text;\n}\n.ql-editor p,\n.ql-editor ol,\n.ql-editor ul,\n.ql-editor pre,\n.ql-editor blockquote,\n.ql-editor h1,\n.ql-editor h2,\n.ql-editor h3,\n.ql-editor h4,\n.ql-editor h5,\n.ql-editor h6 {\n margin: 0;\n padding: 0;\n counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol > li,\n.ql-editor ul > li {\n list-style-type: none;\n}\n.ql-editor ul > li::before {\n content: '\\2022';\n}\n.ql-editor ul[data-checked=true],\n.ql-editor ul[data-checked=false] {\n pointer-events: none;\n}\n.ql-editor ul[data-checked=true] > li *,\n.ql-editor ul[data-checked=false] > li * {\n pointer-events: all;\n}\n.ql-editor ul[data-checked=true] > li::before,\n.ql-editor ul[data-checked=false] > li::before {\n color: #777;\n cursor: pointer;\n pointer-events: all;\n}\n.ql-editor ul[data-checked=true] > li::before {\n content: '\\2611';\n}\n.ql-editor ul[data-checked=false] > li::before {\n content: '\\2610';\n}\n.ql-editor li::before {\n display: inline-block;\n white-space: nowrap;\n width: 2em;\n}\n.ql-editor ol li {\n counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n counter-increment: list-0;\n}\n.ql-editor ol li:before {\n content: counter(list-0, decimal) '. ';\n}\n.ql-editor ol li.ql-indent-1 {\n counter-increment: list-1;\n}\n.ql-editor ol li.ql-indent-1:before {\n content: counter(list-1, lower-alpha) '. ';\n}\n.ql-editor ol li.ql-indent-1 {\n counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-2 {\n counter-increment: list-2;\n}\n.ql-editor ol li.ql-indent-2:before {\n content: counter(list-2, lower-roman) '. ';\n}\n.ql-editor ol li.ql-indent-2 {\n counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-3 {\n counter-increment: list-3;\n}\n.ql-editor ol li.ql-indent-3:before {\n content: counter(list-3, decimal) '. ';\n}\n.ql-editor ol li.ql-indent-3 {\n counter-reset: list-4 list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-4 {\n counter-increment: list-4;\n}\n.ql-editor ol li.ql-indent-4:before {\n content: counter(list-4, lower-alpha) '. ';\n}\n.ql-editor ol li.ql-indent-4 {\n counter-reset: list-5 list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-5 {\n counter-increment: list-5;\n}\n.ql-editor ol li.ql-indent-5:before {\n content: counter(list-5, lower-roman) '. ';\n}\n.ql-editor ol li.ql-indent-5 {\n counter-reset: list-6 list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-6 {\n counter-increment: list-6;\n}\n.ql-editor ol li.ql-indent-6:before {\n content: counter(list-6, decimal) '. ';\n}\n.ql-editor ol li.ql-indent-6 {\n counter-reset: list-7 list-8 list-9;\n}\n.ql-editor ol li.ql-indent-7 {\n counter-increment: list-7;\n}\n.ql-editor ol li.ql-indent-7:before {\n content: counter(list-7, lower-alpha) '. ';\n}\n.ql-editor ol li.ql-indent-7 {\n counter-reset: list-8 list-9;\n}\n.ql-editor ol li.ql-indent-8 {\n counter-increment: list-8;\n}\n.ql-editor ol li.ql-indent-8:before {\n content: counter(list-8, lower-roman) '. ';\n}\n.ql-editor ol li.ql-indent-8 {\n counter-reset: list-9;\n}\n.ql-editor ol li.ql-indent-9 {\n counter-increment: list-9;\n}\n.ql-editor ol li.ql-indent-9:before {\n content: counter(list-9, decimal) '. ';\n}\n.ql-editor .ql-indent-1:not(.ql-direction-rtl) {\n padding-left: 2em;\n}\n.ql-editor li.ql-indent-1:not(.ql-direction-rtl) {\n padding-left: 2em;\n}\n.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right {\n padding-right: 2em;\n}\n.ql-editor li.ql-indent-1.ql-direction-rtl.ql-align-right {\n padding-right: 2em;\n}\n.ql-editor .ql-indent-2:not(.ql-direction-rtl) {\n padding-left: 4em;\n}\n.ql-editor li.ql-indent-2:not(.ql-direction-rtl) {\n padding-left: 4em;\n}\n.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right {\n padding-right: 4em;\n}\n.ql-editor li.ql-indent-2.ql-direction-rtl.ql-align-right {\n padding-right: 4em;\n}\n.ql-editor .ql-indent-3:not(.ql-direction-rtl) {\n padding-left: 6em;\n}\n.ql-editor li.ql-indent-3:not(.ql-direction-rtl) {\n padding-left: 6em;\n}\n.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right {\n padding-right: 6em;\n}\n.ql-editor li.ql-indent-3.ql-direction-rtl.ql-align-right {\n padding-right: 6em;\n}\n.ql-editor .ql-indent-4:not(.ql-direction-rtl) {\n padding-left: 8em;\n}\n.ql-editor li.ql-indent-4:not(.ql-direction-rtl) {\n padding-left: 8em;\n}\n.ql-editor .ql-indent-4.ql-direction-rtl.ql-align-right {\n padding-right: 8em;\n}\n.ql-editor li.ql-indent-4.ql-direction-rtl.ql-align-right {\n padding-right: 8em;\n}\n.ql-editor .ql-indent-5:not(.ql-direction-rtl) {\n padding-left: 10em;\n}\n.ql-editor li.ql-indent-5:not(.ql-direction-rtl) {\n padding-left: 10em;\n}\n.ql-editor .ql-indent-5.ql-direction-rtl.ql-align-right {\n padding-right: 10em;\n}\n.ql-editor li.ql-indent-5.ql-direction-rtl.ql-align-right {\n padding-right: 10em;\n}\n.ql-editor .ql-indent-6:not(.ql-direction-rtl) {\n padding-left: 12em;\n}\n.ql-editor li.ql-indent-6:not(.ql-direction-rtl) {\n padding-left: 12em;\n}\n.ql-editor .ql-indent-6.ql-direction-rtl.ql-align-right {\n padding-right: 12em;\n}\n.ql-editor li.ql-indent-6.ql-direction-rtl.ql-align-right {\n padding-right: 12em;\n}\n.ql-editor .ql-indent-7:not(.ql-direction-rtl) {\n padding-left: 14em;\n}\n.ql-editor li.ql-indent-7:not(.ql-direction-rtl) {\n padding-left: 14em;\n}\n.ql-editor .ql-indent-7.ql-direction-rtl.ql-align-right {\n padding-right: 14em;\n}\n.ql-editor li.ql-indent-7.ql-direction-rtl.ql-align-right {\n padding-right: 14em;\n}\n.ql-editor .ql-indent-8:not(.ql-direction-rtl) {\n padding-left: 16em;\n}\n.ql-editor li.ql-indent-8:not(.ql-direction-rtl) {\n padding-left: 16em;\n}\n.ql-editor .ql-indent-8.ql-direction-rtl.ql-align-right {\n padding-right: 16em;\n}\n.ql-editor li.ql-indent-8.ql-direction-rtl.ql-align-right {\n padding-right: 16em;\n}\n.ql-editor .ql-indent-9:not(.ql-direction-rtl) {\n padding-left: 18em;\n}\n.ql-editor li.ql-indent-9:not(.ql-direction-rtl) {\n padding-left: 18em;\n}\n.ql-editor .ql-indent-9.ql-direction-rtl.ql-align-right {\n padding-right: 18em;\n}\n.ql-editor li.ql-indent-9.ql-direction-rtl.ql-align-right {\n padding-right: 18em;\n}\n.ql-editor .ql-direction-rtl {\n direction: rtl;\n text-align: inherit;\n}\n.ql-editor .ql-align-center {\n text-align: center;\n}\n.ql-editor .ql-align-justify {\n text-align: justify;\n}\n.ql-editor .ql-align-right {\n text-align: right;\n}\n.ql-editor.ql-blank::before {\n color: rgba(0, 0, 0, 0.6);\n content: attr(data-placeholder);\n font-style: italic;\n pointer-events: none;\n position: absolute;\n}\n.ql-container.ql-disabled .ql-editor ul[data-checked] > li::before {\n pointer-events: none;\n}\n.ql-clipboard {\n left: -100000px;\n height: 1px;\n overflow-y: hidden;\n position: absolute;\n top: 50%;\n}\n"; +var index_vue_vue_type_style_index_1_lang = "\n"; +const _sfc_main$j = { + name: "Editor", + mixins: [subscriber, emitter, keyboard], + props: { + id: { + type: String, + default: "" + }, + readOnly: { + type: [Boolean, String], + default: false + }, + placeholder: { + type: String, + default: "" + }, + showImgSize: { + type: [Boolean, String], + default: false + }, + showImgToolbar: { + type: [Boolean, String], + default: false + }, + showImgResize: { + type: [Boolean, String], + default: false + } + }, + data() { + return { + quillReady: false + }; + }, + computed: {}, + watch: { + readOnly(value) { + if (this.quillReady) { + const quill = this.quill; + quill.enable(!value); + if (!value) { + quill.blur(); } } - return false; - }); - if (hasDependentTargets) { - return; - } - var unsubscribe = this._monitoringUnsubscribes[index2]; - this._monitoringDocuments.splice(index2, 1); - this._monitoringUnsubscribes.splice(index2, 1); - unsubscribe(); - if (doc != rootDoc) { - var frame = getFrameElement(doc); - if (frame) { - this._unmonitorIntersections(frame.ownerDocument); + }, + placeholder(value) { + if (this.quillReady) { + this.quill.root.setAttribute("data-placeholder", value); } } - }; - IntersectionObserver2.prototype._unmonitorAllIntersections = function() { - var unsubscribes = this._monitoringUnsubscribes.slice(0); - this._monitoringDocuments.length = 0; - this._monitoringUnsubscribes.length = 0; - for (var i2 = 0; i2 < unsubscribes.length; i2++) { - unsubscribes[i2](); + }, + mounted() { + const imageResizeModules = []; + if (this.showImgSize) { + imageResizeModules.push("DisplaySize"); } - }; - IntersectionObserver2.prototype._checkForIntersections = function() { - if (!this.root && crossOriginUpdater && !crossOriginRect) { - return; + if (this.showImgToolbar) { + imageResizeModules.push("Toolbar"); } - var rootIsInDom = this._rootIsInDom(); - var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect(); - this._observationTargets.forEach(function(item) { - var target = item.element; - var targetRect = getBoundingClientRect(target); - var rootContainsTarget = this._rootContainsTarget(target); - var oldEntry = item.entry; - var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect); - var rootBounds = null; - if (!this._rootContainsTarget(target)) { - rootBounds = getEmptyRect(); - } else if (!crossOriginUpdater || this.root) { - rootBounds = rootRect; - } - var newEntry = item.entry = new IntersectionObserverEntry({ - time: now(), - target, - boundingClientRect: targetRect, - rootBounds, - intersectionRect - }); - if (!oldEntry) { - this._queuedEntries.push(newEntry); - } else if (rootIsInDom && rootContainsTarget) { - if (this._hasCrossedThreshold(oldEntry, newEntry)) { - this._queuedEntries.push(newEntry); - } + if (this.showImgResize) { + imageResizeModules.push("Resize"); + } + this.loadQuill(() => { + if (imageResizeModules.length) { + this.loadImageResizeModule(() => { + this.initQuill(imageResizeModules); + }); } else { - if (oldEntry && oldEntry.isIntersecting) { - this._queuedEntries.push(newEntry); - } + this.initQuill(imageResizeModules); } - }, this); - if (this._queuedEntries.length) { - this._callback(this.takeRecords(), this); - } - }; - IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) { - if (window.getComputedStyle(target).display == "none") - return; - var intersectionRect = targetRect; - var parent = getParentNode(target); - var atRoot = false; - while (!atRoot && parent) { - var parentRect = null; - var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {}; - if (parentComputedStyle.display == "none") - return null; - if (parent == this.root || parent.nodeType == 9) { - atRoot = true; - if (parent == this.root || parent == document2) { - if (crossOriginUpdater && !this.root) { - if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) { - parent = null; - parentRect = null; - intersectionRect = null; - } else { - parentRect = crossOriginRect; + }); + }, + methods: { + _handleSubscribe({ + type, + data + }) { + const {options, callbackId} = data; + const quill = this.quill; + const Quill = window.Quill; + let res; + let range; + let errMsg; + if (this.quillReady) { + switch (type) { + case "format": + { + let {name = "", value = false} = options; + range = quill.getSelection(true); + let format = quill.getFormat(range)[name] || false; + if (["bold", "italic", "underline", "strike", "ins"].includes(name)) { + value = !format; + } else if (name === "direction") { + value = value === "rtl" && format ? false : value; + const align2 = quill.getFormat(range).align; + if (value === "rtl" && !align2) { + quill.format("align", "right", Quill.sources.USER); + } else if (!value && align2 === "right") { + quill.format("align", false, Quill.sources.USER); + } + } else if (name === "indent") { + const rtl = quill.getFormat(range).direction === "rtl"; + value = value === "+1"; + if (rtl) { + value = !value; + } + value = value ? "+1" : "-1"; + } else { + if (name === "list") { + value = value === "check" ? "unchecked" : value; + format = format === "checked" ? "unchecked" : format; + } + value = format && format !== (value || false) || !format && value ? value : !format; + } + quill.format(name, value, Quill.sources.USER); } - } else { - parentRect = rootRect; - } - } else { - var frame = getParentNode(parent); - var frameRect = frame && getBoundingClientRect(frame); - var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect); - if (frameRect && frameIntersect) { - parent = frame; - parentRect = convertFromParentRect(frameRect, frameIntersect); - } else { - parent = null; - intersectionRect = null; - } + break; + case "insertDivider": + range = quill.getSelection(true); + quill.insertText(range.index, "\n", Quill.sources.USER); + quill.insertEmbed(range.index + 1, "divider", true, Quill.sources.USER); + quill.setSelection(range.index + 2, Quill.sources.SILENT); + break; + case "insertImage": + { + range = quill.getSelection(true); + const {src = "", alt = "", width = "", height = "", extClass = "", data: data2 = {}} = options; + const path = this.$getRealPath(src); + quill.insertEmbed(range.index, "image", path, Quill.sources.USER); + const local = /^(file|blob):/.test(path) ? path : false; + quill.formatText(range.index, 1, "data-local", local); + quill.formatText(range.index, 1, "alt", alt); + quill.formatText(range.index, 1, "width", width); + quill.formatText(range.index, 1, "height", height); + quill.formatText(range.index, 1, "class", extClass); + quill.formatText(range.index, 1, "data-custom", Object.keys(data2).map((key) => `${key}=${data2[key]}`).join("&")); + quill.setSelection(range.index + 1, Quill.sources.SILENT); + } + break; + case "insertText": + { + range = quill.getSelection(true); + const {text: text2 = ""} = options; + quill.insertText(range.index, text2, Quill.sources.USER); + quill.setSelection(range.index + text2.length, 0, Quill.sources.SILENT); + } + break; + case "setContents": + { + const {delta, html} = options; + if (typeof delta === "object") { + quill.setContents(delta, Quill.sources.SILENT); + } else if (typeof html === "string") { + quill.setContents(this.html2delta(html), Quill.sources.SILENT); + } else { + errMsg = "contents is missing"; + } + } + break; + case "getContents": + res = this.getContents(); + break; + case "clear": + quill.setContents([]); + break; + case "removeFormat": + { + range = quill.getSelection(true); + const parchment = Quill.import("parchment"); + if (range.length) { + quill.removeFormat(range, Quill.sources.USER); + } else { + Object.keys(quill.getFormat(range)).forEach((key) => { + if (parchment.query(key, parchment.Scope.INLINE)) { + quill.format(key, false); + } + }); + } + } + break; + case "undo": + quill.history.undo(); + break; + case "redo": + quill.history.redo(); + break; + } + this.updateStatus(range); + } else { + errMsg = "not ready"; + } + if (callbackId) { + UniViewJSBridge.publishHandler("onEditorMethodCallback", { + callbackId, + data: Object.assign({}, res, { + errMsg: `${type}:${errMsg ? "fail " + errMsg : "ok"}` + }) + }, this.$page.id); + } + }, + loadQuill(callback) { + if (typeof window.Quill === "function") { + if (typeof callback === "function") { + callback(); } - } else { - var doc = parent.ownerDocument; - if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") { - parentRect = getBoundingClientRect(parent); + return; + } + const script = document.createElement("script"); + script.src = window.plus ? "./__uniappquill.js" : "https://unpkg.com/quill@1.3.7/dist/quill.min.js"; + document.body.appendChild(script); + script.onload = callback; + }, + loadImageResizeModule(callback) { + if (typeof window.ImageResize === "function") { + if (typeof callback === "function") { + callback(); } + return; } - if (parentRect) { - intersectionRect = computeRectIntersection(parentRect, intersectionRect); + const script = document.createElement("script"); + script.src = window.plus ? "./__uniappquillimageresize.js" : "https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js"; + document.body.appendChild(script); + script.onload = callback; + }, + initQuill(imageResizeModules) { + const Quill = window.Quill; + register(Quill); + const options = { + toolbar: false, + readOnly: this.readOnly, + placeholder: this.placeholder, + modules: {} + }; + if (imageResizeModules.length) { + Quill.register("modules/ImageResize", window.ImageResize.default); + options.modules.ImageResize = { + modules: imageResizeModules + }; } - if (!intersectionRect) - break; - parent = parent && getParentNode(parent); - } - return intersectionRect; - }; - IntersectionObserver2.prototype._getRootRect = function() { - var rootRect; - if (this.root && !isDoc(this.root)) { - rootRect = getBoundingClientRect(this.root); - } else { - var doc = isDoc(this.root) ? this.root : document2; - var html = doc.documentElement; - var body = doc.body; - rootRect = { - top: 0, - left: 0, - right: html.clientWidth || body.clientWidth, - width: html.clientWidth || body.clientWidth, - bottom: html.clientHeight || body.clientHeight, - height: html.clientHeight || body.clientHeight + const quill = this.quill = new Quill(this.$el, options); + const $el = quill.root; + const events = ["focus", "blur", "input"]; + events.forEach((name) => { + $el.addEventListener(name, ($event) => { + if (name === "input") { + $event.stopPropagation(); + } else { + this.$trigger(name, $event, this.getContents()); + } + }); + }); + quill.on(Quill.events.TEXT_CHANGE, () => { + this.$trigger("input", {}, this.getContents()); + }); + quill.on(Quill.events.SELECTION_CHANGE, this.updateStatus.bind(this)); + quill.on(Quill.events.SCROLL_OPTIMIZE, () => { + const range = quill.selection.getRange()[0]; + this.updateStatus(range); + }); + quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => { + if (this.skipMatcher) { + return delta; + } + delta.ops = delta.ops.filter(({insert}) => typeof insert === "string").map(({insert}) => ({insert})); + return delta; + }); + this.initKeyboard($el); + this.quillReady = true; + this.$trigger("ready", event, {}); + }, + getContents() { + const quill = this.quill; + const html = quill.root.innerHTML; + const text2 = quill.getText(); + const delta = quill.getContents(); + return { + html, + text: text2, + delta }; - } - return this._expandRectByRootMargin(rootRect); - }; - IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) { - var margins = this._rootMarginValues.map(function(margin, i2) { - return margin.unit == "px" ? margin.value : margin.value * (i2 % 2 ? rect.width : rect.height) / 100; - }); - var newRect = { - top: rect.top - margins[0], - right: rect.right + margins[1], - bottom: rect.bottom + margins[2], - left: rect.left - margins[3] - }; - newRect.width = newRect.right - newRect.left; - newRect.height = newRect.bottom - newRect.top; - return newRect; - }; - IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) { - var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1; - var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1; - if (oldRatio === newRatio) - return; - for (var i2 = 0; i2 < this.thresholds.length; i2++) { - var threshold = this.thresholds[i2]; - if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) { - return true; + }, + html2delta(html) { + const tags = ["span", "strong", "b", "ins", "em", "i", "u", "a", "del", "s", "sub", "sup", "img", "div", "p", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "ol", "ul", "li", "br"]; + let content = ""; + let disable; + HTMLParser(html, { + start: function(tag, attrs2, unary) { + if (!tags.includes(tag)) { + disable = !unary; + return; + } + disable = false; + const arrts = attrs2.map(({name, value}) => `${name}="${value}"`).join(" "); + const start = `<${tag} ${arrts} ${unary ? "/" : ""}>`; + content += start; + }, + end: function(tag) { + if (!disable) { + content += ``; + } + }, + chars: function(text2) { + if (!disable) { + content += text2; + } + } + }); + this.skipMatcher = true; + const delta = this.quill.clipboard.convert(content); + this.skipMatcher = false; + return delta; + }, + updateStatus(range) { + const status = range ? this.quill.getFormat(range) : {}; + const keys = Object.keys(status); + if (keys.length !== Object.keys(this.__status || {}).length || keys.find((key) => status[key] !== this.__status[key])) { + this.__status = status; + this.$trigger("statuschange", {}, status); } } - }; - IntersectionObserver2.prototype._rootIsInDom = function() { - return !this.root || containsDeep(document2, this.root); - }; - IntersectionObserver2.prototype._rootContainsTarget = function(target) { - var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2; - return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument); - }; - IntersectionObserver2.prototype._registerInstance = function() { - if (registry.indexOf(this) < 0) { - registry.push(this); - } - }; - IntersectionObserver2.prototype._unregisterInstance = function() { - var index2 = registry.indexOf(this); - if (index2 != -1) - registry.splice(index2, 1); - }; - function now() { - return window.performance && performance.now && performance.now(); - } - function throttle2(fn, timeout) { - var timer = null; - return function() { - if (!timer) { - timer = setTimeout(function() { - fn(); - timer = null; - }, timeout); - } - }; } - function addEvent(node, event2, fn, opt_useCapture) { - if (typeof node.addEventListener == "function") { - node.addEventListener(event2, fn, opt_useCapture || false); - } else if (typeof node.attachEvent == "function") { - node.attachEvent("on" + event2, fn); - } +}; +function _sfc_render$i(_ctx, _cache, $props, $setup, $data, $options) { + return openBlock(), createBlock("uni-editor", mergeProps({ + id: $props.id, + class: "ql-container" + }, _ctx.$attrs), null, 16, ["id"]); +} +_sfc_main$j.render = _sfc_render$i; +const INFO_COLOR = "#10aeff"; +const WARN_COLOR = "#f76260"; +const GREY_COLOR = "#b2b2b2"; +const CANCEL_COLOR = "#f43530"; +const ICONS = { + 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 } - function removeEvent(node, event2, fn, opt_useCapture) { - if (typeof node.removeEventListener == "function") { - node.removeEventListener(event2, fn, opt_useCapture || false); - } else if (typeof node.detatchEvent == "function") { - node.detatchEvent("on" + event2, fn); +}; +var index$3 = defineComponent({ + name: "Icon", + props: { + type: { + type: String, + required: true, + default: "" + }, + size: { + type: [String, Number], + default: 23 + }, + color: { + type: String, + default: "" } + }, + setup(props) { + const path = computed(() => ICONS[props.type]); + return () => createVNode("uni-icon", null, [path.value.d && createSvgIconVNode(path.value.d, props.color || path.value.c, rpx2px(props.size))]); } - function computeRectIntersection(rect1, rect2) { - var top = Math.max(rect1.top, rect2.top); - var bottom = Math.min(rect1.bottom, rect2.bottom); - var left = Math.max(rect1.left, rect2.left); - var right = Math.min(rect1.right, rect2.right); - var width = right - left; - var height = bottom - top; - return width >= 0 && height >= 0 && { - top, - bottom, - left, - right, - width, - height - } || null; - } - function getBoundingClientRect(el) { - var rect; - try { - rect = el.getBoundingClientRect(); - } catch (err) { - } - if (!rect) - return getEmptyRect(); - if (!(rect.width && rect.height)) { - rect = { - top: rect.top, - right: rect.right, - bottom: rect.bottom, - left: rect.left, - width: rect.right - rect.left, - height: rect.bottom - rect.top - }; +}); +var index_vue_vue_type_style_index_0_lang$9 = "\n@keyframes once-show {\nfrom {\n top: 0;\n}\n}\nuni-resize-sensor,\nuni-resize-sensor > div {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n}\nuni-resize-sensor {\n display: block;\n z-index: -1;\n visibility: hidden;\n animation: once-show 1ms;\n}\nuni-resize-sensor > div > div {\n position: absolute;\n left: 0;\n top: 0;\n}\nuni-resize-sensor > div:first-child > div {\n width: 100000px;\n height: 100000px;\n}\nuni-resize-sensor > div:last-child > div {\n width: 200%;\n height: 200%;\n}\n"; +const _sfc_main$i = { + name: "ResizeSensor", + props: { + initial: { + type: [Boolean, String], + default: false } - return rect; - } - function getEmptyRect() { + }, + data: function() { return { - top: 0, - bottom: 0, - left: 0, - right: 0, - width: 0, - height: 0 + size: { + width: -1, + height: -1 + } }; - } - function ensureDOMRect(rect) { - if (!rect || "x" in rect) { - return rect; + }, + watch: { + size: { + deep: true, + handler: function(size) { + this.$emit("resize", Object.assign({}, size)); + } } - return { - top: rect.top, - y: rect.top, - bottom: rect.bottom, - left: rect.left, - x: rect.left, - right: rect.right, - width: rect.width, - height: rect.height - }; - } - function convertFromParentRect(parentBoundingRect, parentIntersectionRect) { - var top = parentIntersectionRect.top - parentBoundingRect.top; - var left = parentIntersectionRect.left - parentBoundingRect.left; - return { - top, - left, - height: parentIntersectionRect.height, - width: parentIntersectionRect.width, - bottom: top + parentIntersectionRect.height, - right: left + parentIntersectionRect.width - }; - } - function containsDeep(parent, child) { - var node = child; - while (node) { - if (node == parent) - return true; - node = getParentNode(node); + }, + mounted: function() { + if (this.initial === true) { + this.$nextTick(this.update); } - return false; - } - function getParentNode(node) { - var parent = node.parentNode; - if (node.nodeType == 9 && node != document2) { - return getFrameElement(node); + if (this.$el.offsetParent !== this.$el.parentNode) { + this.$el.parentNode.style.position = "relative"; } - if (parent && parent.assignedSlot) { - parent = parent.assignedSlot.parentNode; + if (!("AnimationEvent" in window)) { + this.reset(); } - if (parent && parent.nodeType == 11 && parent.host) { - return parent.host; + }, + methods: { + reset: function() { + var expand = this.$el.firstChild; + var shrink = this.$el.lastChild; + expand.scrollLeft = 1e5; + expand.scrollTop = 1e5; + shrink.scrollLeft = 1e5; + shrink.scrollTop = 1e5; + }, + update: function() { + this.size.width = this.$el.offsetWidth; + this.size.height = this.$el.offsetHeight; + this.reset(); } - return parent; - } - function isDoc(node) { - return node && node.nodeType === 9; + }, + render: function(create) { + return create("uni-resize-sensor", { + on: { + "~animationstart": this.update + } + }, [ + create("div", { + on: { + scroll: this.update + } + }, [ + create("div") + ]), + create("div", { + on: { + scroll: this.update + } + }, [ + create("div") + ]) + ]); } - window.IntersectionObserver = IntersectionObserver2; - window.IntersectionObserverEntry = IntersectionObserverEntry; }; -function normalizeRect(rect) { - const {bottom, height, left, right, top, width} = rect || {}; - return { - bottom, - height, - left, - right, - top, - width - }; -} -function requestComponentObserver($el, options, callback) { - initIntersectionObserverPolyfill(); - const root = options.relativeToSelector ? $el.querySelector(options.relativeToSelector) : null; - const intersectionObserver = new IntersectionObserver((entries) => { - entries.forEach((entrie) => { - callback({ - intersectionRatio: entrie.intersectionRatio, - intersectionRect: normalizeRect(entrie.intersectionRect), - boundingClientRect: normalizeRect(entrie.boundingClientRect), - relativeRect: normalizeRect(entrie.rootBounds), - time: Date.now() - }); - }); - }, { - root, - rootMargin: options.rootMargin, - threshold: options.thresholds - }); - if (options.observeAll) { - intersectionObserver.USE_MUTATION_OBSERVER = true; - const nodeList = $el.querySelectorAll(options.selector); - for (let i2 = 0; i2 < nodeList.length; i2++) { - intersectionObserver.observe(nodeList[i2]); - } - } else { - intersectionObserver.USE_MUTATION_OBSERVER = false; - const el = $el.querySelector(options.selector); - if (!el) { - console.warn(`Node ${options.selector} is not found. Intersection observer will not trigger.`); - } else { - intersectionObserver.observe(el); - } - } - return intersectionObserver; -} -function addIntersectionObserver({reqId, component, options, callback}, _pageId) { - const $el = findElem(component); - ($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver($el, options, callback); -} -function removeIntersectionObserver({reqId, component}, _pageId) { - const $el = findElem(component); - const intersectionObserver = $el.__io && $el.__io[reqId]; - if (intersectionObserver) { - intersectionObserver.disconnect(); - delete $el.__io[reqId]; - } -} const _sfc_main$h = { name: "Image", props: { @@ -10356,20 +10752,6 @@ const UniViewJSBridge$1 = extend(ViewJSBridge, { window.UniServiceJSBridge.subscribeHandler(event2, args, pageId); } }); -function cssSupports(css) { - return window.CSS && window.CSS.supports && window.CSS.supports(css); -} -const SCHEMA_CSS = { - "css.var": cssSupports("--a:0"), - "css.env": cssSupports("top:env(a)"), - "css.constant": cssSupports("top:constant(a)") -}; -const canIUse = /* @__PURE__ */ defineSyncApi(API_CAN_I_USE, (schema) => { - if (hasOwn$1(SCHEMA_CSS, schema)) { - return SCHEMA_CSS[schema]; - } - return true; -}, CanIUseProtocol); const makePhoneCall = /* @__PURE__ */ defineAsyncApi(API_MAKE_PHONE_CALL, ({phoneNumber}, {resolve}) => { window.location.href = `tel:${phoneNumber}`; return resolve(); @@ -10664,8 +11046,7 @@ function parseHeaders(headers) { } const navigateBack = /* @__PURE__ */ defineAsyncApi(API_NAVIGATE_BACK, ({delta}, {resolve, reject}) => { let canBack = true; - const vm = getCurrentPageVm(); - if (vm && vm.$callHook("onBackPress") === true) { + if (invokeHook("onBackPress") === true) { canBack = false; } if (!canBack) { @@ -10693,6 +11074,36 @@ const navigateTo = /* @__PURE__ */ defineAsyncApi(API_NAVIGATE_TO, ({url}, {reso const redirectTo = /* @__PURE__ */ defineAsyncApi(API_REDIRECT_TO, ({url}, {resolve, reject}) => navigate(API_REDIRECT_TO, url).then(resolve).catch(reject), RedirectToProtocol, RedirectToOptions); const reLaunch = /* @__PURE__ */ defineAsyncApi(API_RE_LAUNCH, ({url}, {resolve, reject}) => navigate(API_RE_LAUNCH, url).then(resolve).catch(reject), ReLaunchProtocol, ReLaunchOptions); const switchTab = /* @__PURE__ */ defineAsyncApi(API_SWITCH_TAB, ({url}, {resolve, reject}) => navigate(API_SWITCH_TAB, url).then(resolve).catch(reject), SwitchTabProtocol, SwitchTabOptions); +function setTabBar(type, args, resolve) { + const tabBar2 = useTabBar(); + switch (type) { + case "showTabBar": + tabBar2.shown = true; + break; + case "hideTabBar": + tabBar2.shown = false; + } + resolve(); +} +const setTabBarItem = /* @__PURE__ */ defineAsyncApi("setTabBarItem", (args, {resolve}) => { + setTabBar("setTabBarItem", args, resolve); +}, SetTabBarItemProtocol, SetTabBarItemOptions); +const setTabBarStyle = /* @__PURE__ */ defineAsyncApi("setTabBarStyle", () => { +}, SetTabBarStyleProtocol, SetTabBarStyleOptions); +const hideTabBar = /* @__PURE__ */ defineAsyncApi("hideTabBar", (args, {resolve}) => { + setTabBar("hideTabBar", args, resolve); +}, HideTabBarProtocol); +const showTabBar = /* @__PURE__ */ defineAsyncApi("showTabBar", (args, {resolve}) => { + setTabBar("showTabBar", args, resolve); +}, ShowTabBarProtocol); +const hideTabBarRedDot = /* @__PURE__ */ defineAsyncApi("hideTabBarRedDot", () => { +}, HideTabBarRedDotProtocol, HideTabBarRedDotOptions); +const showTabBarRedDot = /* @__PURE__ */ defineAsyncApi("showTabBarRedDot", () => { +}, ShowTabBarRedDotProtocol, ShowTabBarRedDotOptions); +const removeTabBarBadge = /* @__PURE__ */ defineAsyncApi("removeTabBarBadge", () => { +}, RemoveTabBarBadgeProtocol, RemoveTabBarBadgeOptions); +const setTabBarBadge = /* @__PURE__ */ defineAsyncApi("setTabBarBadge", () => { +}, SetTabBarBadgeProtocol, SetTabBarBadgeOptions); var api = /* @__PURE__ */ Object.freeze({ __proto__: null, [Symbol.toStringTag]: "Module", @@ -10705,6 +11116,11 @@ var api = /* @__PURE__ */ Object.freeze({ createIntersectionObserver, createSelectorQuery, createVideoContext, + onTabBarMidButtonTap, + cssVar, + cssEnv, + cssConstant, + cssBackdropFilter, canIUse, makePhoneCall, getSystemInfo, @@ -10719,7 +11135,15 @@ var api = /* @__PURE__ */ Object.freeze({ navigateTo, redirectTo, reLaunch, - switchTab + switchTab, + setTabBarItem, + setTabBarStyle, + hideTabBar, + showTabBar, + hideTabBarRedDot, + showTabBarRedDot, + removeTabBarBadge, + setTabBarBadge }); const uni$1 = api; const UniServiceJSBridge$1 = extend(ServiceJSBridge, { @@ -11414,4 +11838,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { ]); } _sfc_main.render = _sfc_render; -export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$n as Audio, index$4 as Button, _sfc_main$m as Canvas, _sfc_main$l as Checkbox, _sfc_main$k as CheckboxGroup, _sfc_main$j as Editor, index$5 as Form, index$3 as Icon, _sfc_main$h as Image, _sfc_main$g as Input, _sfc_main$f as Label, _sfc_main$e as MovableView, _sfc_main$d as Navigator, index as PageComponent, _sfc_main$c as Progress, _sfc_main$b as Radio, _sfc_main$a as RadioGroup, _sfc_main$i as ResizeSensor, _sfc_main$9 as RichText, _sfc_main$8 as ScrollView, _sfc_main$7 as Slider, _sfc_main$6 as SwiperItem, _sfc_main$5 as Switch, index$2 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as Video, index$1 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, createVideoContext, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getNetworkType, getSystemInfo, getSystemInfoSync, makePhoneCall, navigateBack, navigateTo, offNetworkStatusChange, onNetworkStatusChange, openDocument, index$6 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, request, switchTab, uni$1 as uni, upx2px, useSubscribe}; +export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$n as Audio, index$4 as Button, _sfc_main$m as Canvas, _sfc_main$l as Checkbox, _sfc_main$k as CheckboxGroup, _sfc_main$j as Editor, index$5 as Form, index$3 as Icon, _sfc_main$h as Image, _sfc_main$g as Input, _sfc_main$f as Label, _sfc_main$e as MovableView, _sfc_main$d as Navigator, index as PageComponent, _sfc_main$c as Progress, _sfc_main$b as Radio, _sfc_main$a as RadioGroup, _sfc_main$i as ResizeSensor, _sfc_main$9 as RichText, _sfc_main$8 as ScrollView, _sfc_main$7 as Slider, _sfc_main$6 as SwiperItem, _sfc_main$5 as Switch, index$2 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as Video, index$1 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getNetworkType, getSystemInfo, getSystemInfoSync, hideTabBar, hideTabBarRedDot, makePhoneCall, navigateBack, navigateTo, offNetworkStatusChange, onNetworkStatusChange, onTabBarMidButtonTap, openDocument, index$6 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeTabBarBadge, request, setTabBarBadge, setTabBarItem, setTabBarStyle, showTabBar, showTabBarRedDot, switchTab, uni$1 as uni, upx2px, useSubscribe}; diff --git a/packages/uni-h5/src/framework/components/app/layout/index.tsx b/packages/uni-h5/src/framework/components/app/layout/index.tsx index 3206b8b6bd4cfe4fffd2ad5275d51e08b6b374ff..efef793c4f139e90eef41aefe4450811430ce8de 100644 --- a/packages/uni-h5/src/framework/components/app/layout/index.tsx +++ b/packages/uni-h5/src/framework/components/app/layout/index.tsx @@ -1,4 +1,7 @@ import { + watch, + computed, + ComputedRef, withCtx, KeepAlive, openBlock, @@ -8,14 +11,16 @@ import { resolveComponent, ConcreteComponent, resolveDynamicComponent, + SetupContext, } from 'vue' -import { RouteLocationNormalizedLoaded, RouterView, useRoute } from 'vue-router' - -import TabBar from '../tabBar' +import { RouterView, useRoute } from 'vue-router' +import { useTabBar } from '../../../plugin/state' import { useKeepAliveRoute } from '../../../plugin/page' +import TabBar from '../tabBar' + type KeepAliveRoute = ReturnType export default defineComponent({ @@ -24,14 +29,14 @@ export default defineComponent({ onChange: Function, }, emits: ['change'], - setup() { - const route = (__UNI_FEATURE_TABBAR__ && - useRoute()) as RouteLocationNormalizedLoaded + setup(props, { emit }) { const keepAliveRoute = (__UNI_FEATURE_PAGES__ && useKeepAliveRoute()) as KeepAliveRoute const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow() const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow() const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow() + const showTabBar = (__UNI_FEATURE_TABBAR__ && + useShowTabBar(emit)) as ComputedRef return () => { const layoutTsx = createLayoutTsx( keepAliveRoute, @@ -39,7 +44,7 @@ export default defineComponent({ leftWindow, rightWindow ) - const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(route) + const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar) if (!tabBarTsx) { return layoutTsx } @@ -82,8 +87,19 @@ function createLayoutTsx( ) } -function createTabBarTsx(route: RouteLocationNormalizedLoaded) { - return +function useShowTabBar(emit: SetupContext['emit']) { + const route = useRoute() + const tabBar = useTabBar()! + // TODO meida query + const showTabBar = computed(() => route.meta.isTabBar && tabBar.shown) + watch(showTabBar, (value) => { + emit('change', 'showTabBar', value) + }) + return showTabBar +} + +function createTabBarTsx(showTabBar: ComputedRef) { + return } function createPageVNode() { diff --git a/packages/uni-h5/src/framework/components/app/tabBar.ts b/packages/uni-h5/src/framework/components/app/tabBar.ts deleted file mode 100644 index 29df4e448ebd56a2549cb106f9ff90fe2352d03c..0000000000000000000000000000000000000000 --- a/packages/uni-h5/src/framework/components/app/tabBar.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { defineComponent } from 'vue' - -export default /*#__PURE__*/ defineComponent({ - name: 'TabBar', -}) diff --git a/packages/uni-h5/src/framework/components/app/tabBar.tsx b/packages/uni-h5/src/framework/components/app/tabBar.tsx new file mode 100644 index 0000000000000000000000000000000000000000..37625a8bc79201f7faff9e44a657d311edb3b059 --- /dev/null +++ b/packages/uni-h5/src/framework/components/app/tabBar.tsx @@ -0,0 +1,288 @@ +import { watch, computed, defineComponent, onRenderTriggered } from 'vue' +import { RouteLocationNormalizedLoaded, useRoute } from 'vue-router' +import { invokeHook } from '@dcloudio/uni-core' +import { + API_ON_TAB_BAR_MID_BUTTON_TAP, + OnTabBarMidButtonTap, +} from '@dcloudio/uni-api' +import { getRealPath } from '../../../platform' +import { useTabBar } from '../../plugin/state' +import { cssBackdropFilter } from '../../../service/api/base/canIUse' + +export default /*#__PURE__*/ defineComponent({ + name: 'TabBar', + setup() { + const tabBar = useTabBar()! + const onSwitchTab = useSwitchTab(useRoute(), tabBar) + const { style, borderStyle, placeholderStyle } = useTabBarStyle(tabBar) + onRenderTriggered(() => { + debugger + }) + return () => { + const tabBarItemsTsx = createTabBarItemsTsx(tabBar, onSwitchTab) + return ( + +
+
+ {tabBarItemsTsx} +
+
+
+ ) + } + }, +}) + +function useSwitchTab( + route: RouteLocationNormalizedLoaded, + tabBar: UniApp.TabBarOptions +) { + watch( + route, + () => { + const meta = route.meta + if (meta.isTabBar) { + const pagePath = meta.route + const index = tabBar.list.findIndex( + (item) => item.pagePath === pagePath + ) + if (index === -1) { + return + } + tabBar.selectedIndex = index + } + }, + { immediate: true } + ) + return (tabBarItem: UniApp.TabBarItemOptions, index: number) => { + const { type } = tabBarItem + return () => { + if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === 'midButton') { + return UniServiceJSBridge.invokeOnCallback( + API_ON_TAB_BAR_MID_BUTTON_TAP + ) + } + const { pagePath, text } = tabBarItem + let url = '/' + pagePath + if (url === __uniRoutes[0].alias) { + url = '/' + } + if (route.path !== url) { + uni.switchTab({ from: 'tabBar', url } as any) + } else { + invokeHook('onTabItemTap', { + index, + text, + pagePath, + }) + } + } + } +} + +type OnSwtichTab = ReturnType + +const DEFAULT_BG_COLOR = '#f7f7fa' + +const BLUR_EFFECT_COLOR_DARK = 'rgb(0, 0, 0, 0.8)' +const BLUR_EFFECT_COLOR_LIGHT = 'rgb(250, 250, 250, 0.8)' +const BLUR_EFFECT_COLORS = { + dark: BLUR_EFFECT_COLOR_DARK, + light: BLUR_EFFECT_COLOR_LIGHT, + extralight: BLUR_EFFECT_COLOR_LIGHT, +} + +const BORDER_COLORS = { + white: 'rgba(255, 255, 255, 0.33)', + black: 'rgba(0, 0, 0, 0.33)', +} +function useTabBarStyle(tabBar: UniApp.TabBarOptions) { + const style = computed(() => { + let backgroundColor = tabBar.backgroundColor + const blurEffect = tabBar.blurEffect + if (!backgroundColor) { + if (cssBackdropFilter && blurEffect && blurEffect !== 'none') { + backgroundColor = BLUR_EFFECT_COLORS[blurEffect] + } + } + return { + backgroundColor: backgroundColor || DEFAULT_BG_COLOR, + backdropFilter: blurEffect !== 'none' ? 'blur(10px)' : blurEffect, + } + }) + const borderStyle = computed(() => { + const { borderStyle } = tabBar + return { + backgroundColor: BORDER_COLORS[borderStyle!] || borderStyle, + } + }) + const placeholderStyle = computed(() => { + return { + height: tabBar.height!, + } + }) + return { + style, + borderStyle, + placeholderStyle, + } +} + +function isMidButton(item: unknown): item is UniApp.TabBarMidButtonOptions { + return (item as any).type === 'midButton' +} + +function createTabBarItemsTsx( + tabBar: UniApp.TabBarOptions, + onSwitchTab: OnSwtichTab +) { + const { list, selectedIndex, selectedColor, color } = tabBar + return list.map((item, index) => { + const selected = selectedIndex === index + const textColor = selected ? selectedColor : color + const iconPath = + (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || '' + if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) { + return createTabBarItemTsx( + textColor, + iconPath, + item, + tabBar, + index, + onSwitchTab + ) + } + return isMidButton(item) + ? createTabBarMidButtonTsx( + textColor, + iconPath, + item, + tabBar, + index, + onSwitchTab + ) + : createTabBarItemTsx( + textColor, + iconPath, + item, + tabBar, + index, + onSwitchTab + ) + }) +} + +function createTabBarItemTsx( + color: string, + iconPath: string, + tabBarItem: UniApp.TabBarItemOptions, + tabBar: UniApp.TabBarOptions, + index: number, + onSwitchTab: OnSwtichTab +) { + return ( +
+ {createTabBarItemBdTsx(color, iconPath || '', tabBarItem, tabBar)} +
+ ) +} + +function createTabBarItemBdTsx( + color: string, + iconPath: string, + tabBarItem: UniApp.TabBarItemOptions, + tabBar: UniApp.TabBarOptions +) { + const { height } = tabBar + return ( +
+ {iconPath && createTabBarItemIconTsx(iconPath, tabBarItem, tabBar)} + {tabBarItem.text && createTabBarItemTextTsx(color, tabBarItem, tabBar)} +
+ ) +} + +function createTabBarItemIconTsx( + iconPath: string, + tabBarItem: UniApp.TabBarItemOptions, + tabBar: UniApp.TabBarOptions +) { + const { type, text, redDot } = tabBarItem + const { iconWidth } = tabBar + const clazz = 'uni-tabbar__icon' + (text ? ' uni-tabbar__icon__diff' : '') + const style = { width: iconWidth, height: iconWidth } + return ( +
+ {type !== 'midButton' && } + {redDot && createTabBarItemRedDotTsx(tabBarItem.badge)} +
+ ) +} + +function createTabBarItemTextTsx( + color: string, + tabBarItem: UniApp.TabBarItemOptions, + tabBar: UniApp.TabBarOptions +) { + const { redDot, iconPath, text } = tabBarItem + const { fontSize, spacing } = tabBar + const style = { + color, + fontSize: fontSize, + lineHeight: !iconPath ? 1.8 : 'normal', + marginTop: !iconPath ? 'inherit' : spacing, + } + return ( +
+ {text} + {redDot && !iconPath && createTabBarItemRedDotTsx(tabBarItem.badge)} +
+ ) +} + +function createTabBarItemRedDotTsx(badge?: string) { + const clazz = 'uni-tabbar__reddot' + (badge ? ' uni-tabbar__badge' : '') + return
{badge}
+} + +function createTabBarMidButtonTsx( + color: string, + iconPath: string, + midButton: UniApp.TabBarMidButtonOptions, + tabBar: UniApp.TabBarOptions, + index: number, + onSwitchTab: OnSwtichTab +) { + const { width, height, backgroundImage, iconWidth } = midButton + return ( +
+
+ {iconPath && ( + + )} +
+ {createTabBarItemBdTsx(color, iconPath, midButton, tabBar)} +
+ ) +} diff --git a/packages/uni-h5/src/framework/components/app/tabBar.vue b/packages/uni-h5/src/framework/components/app/tabBar.vue deleted file mode 100644 index 9439fdd0a53fce37f8ce440dd46cf86de9339ad8..0000000000000000000000000000000000000000 --- a/packages/uni-h5/src/framework/components/app/tabBar.vue +++ /dev/null @@ -1,403 +0,0 @@ - - - - - diff --git a/packages/uni-h5/src/framework/plugin/provide/page.ts b/packages/uni-h5/src/framework/plugin/provide/page.ts index eed524025a0db04792dc6c77c2639537a5440f71..72fe0028646600b0ad0d98e5e0b8f13b60fb983c 100644 --- a/packages/uni-h5/src/framework/plugin/provide/page.ts +++ b/packages/uni-h5/src/framework/plugin/provide/page.ts @@ -6,7 +6,7 @@ import { PolySymbol, rpx2px } from '@dcloudio/uni-core' import safeAreaInsets from 'safe-area-insets' -const pageMetaKey = PolySymbol(__DEV__ ? 'pageMeta' : 'pm') +const pageMetaKey = PolySymbol(__DEV__ ? 'UniPageMeta' : 'upm') export function usePageMeta() { return inject(pageMetaKey)! diff --git a/packages/uni-h5/src/framework/plugin/state.ts b/packages/uni-h5/src/framework/plugin/state.ts new file mode 100644 index 0000000000000000000000000000000000000000..de52fa3ca769f8dcfef24a5d8de4e13a90c3d79e --- /dev/null +++ b/packages/uni-h5/src/framework/plugin/state.ts @@ -0,0 +1,11 @@ +import { reactive } from 'vue' + +let tabBar: UniApp.TabBarOptions | undefined + +export function useTabBar() { + if (!tabBar) { + tabBar = + __uniConfig.tabBar && reactive(__uniConfig.tabBar) + } + return tabBar +} diff --git a/packages/uni-h5/src/service/api/base/canIUse.ts b/packages/uni-h5/src/service/api/base/canIUse.ts index d9414053da3eeb36e328db0e53f6594dd3903a92..b1ecb9128eacbf2f503dd0e1faf67440d126d454 100644 --- a/packages/uni-h5/src/service/api/base/canIUse.ts +++ b/packages/uni-h5/src/service/api/base/canIUse.ts @@ -6,14 +6,27 @@ import { defineSyncApi, } from '@dcloudio/uni-api' +const supports = window.CSS && window.CSS.supports + function cssSupports(css: string) { - return window.CSS && window.CSS.supports && window.CSS.supports(css) + return ( + supports && + (supports(css) || supports.apply(window.CSS, css.split(':') as any)) + ) } +export const cssVar = /*#__PURE__*/ cssSupports('--a:0') +export const cssEnv = /*#__PURE__*/ cssSupports('top:env(a)') +export const cssConstant = /*#__PURE__*/ cssSupports('top:constant(a)') +export const cssBackdropFilter = /*#__PURE__*/ cssSupports( + 'backdrop-filter:blur(10px)' +) + const SCHEMA_CSS = { - 'css.var': cssSupports('--a:0'), - 'css.env': cssSupports('top:env(a)'), - 'css.constant': cssSupports('top:constant(a)'), + 'css.var': cssVar, + 'css.env': cssEnv, + 'css.constant': cssConstant, + 'css.backdrop-filter': cssBackdropFilter, } export const canIUse = defineSyncApi( diff --git a/packages/uni-h5/src/service/api/index.ts b/packages/uni-h5/src/service/api/index.ts index e224fa04e0d5933b5a8d3705a16a1eee250164f0..5801cb6a7e32725b2498a9923f9f7240f54362a8 100644 --- a/packages/uni-h5/src/service/api/index.ts +++ b/packages/uni-h5/src/service/api/index.ts @@ -17,6 +17,8 @@ export * from './route/redirectTo' export * from './route/reLaunch' export * from './route/switchTab' +export * from './ui/tabBar' + export { upx2px, addInterceptor, @@ -27,4 +29,5 @@ export { createIntersectionObserver, createSelectorQuery, createVideoContext, + onTabBarMidButtonTap, } from '@dcloudio/uni-api' diff --git a/packages/uni-h5/src/service/api/route/navigateBack.ts b/packages/uni-h5/src/service/api/route/navigateBack.ts index fea9622a0f26f807e2f9b5c946987f23259ec4d0..1993351ccfbd53731aef0e86b643690a0d079645 100644 --- a/packages/uni-h5/src/service/api/route/navigateBack.ts +++ b/packages/uni-h5/src/service/api/route/navigateBack.ts @@ -1,7 +1,7 @@ +import { invokeHook } from '@dcloudio/uni-core' import { API_NAVIGATE_BACK, defineAsyncApi, - getCurrentPageVm, NavigateBackOptions, NavigateBackProtocol, } from '@dcloudio/uni-api' @@ -10,8 +10,7 @@ export const navigateBack = defineAsyncApi( API_NAVIGATE_BACK, ({ delta }, { resolve, reject }) => { let canBack = true - const vm = getCurrentPageVm() - if (vm && vm.$callHook('onBackPress') === true) { + if (invokeHook('onBackPress') === true) { canBack = false } if (!canBack) { diff --git a/packages/uni-h5/src/service/api/ui/tabBar.ts b/packages/uni-h5/src/service/api/ui/tabBar.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a547086970dbccf16ac30d610abbd4510653e2e --- /dev/null +++ b/packages/uni-h5/src/service/api/ui/tabBar.ts @@ -0,0 +1,93 @@ +import { + defineAsyncApi, + HideTabBarProtocol, + HideTabBarRedDotOptions, + HideTabBarRedDotProtocol, + RemoveTabBarBadgeOptions, + RemoveTabBarBadgeProtocol, + SetTabBarBadgeOptions, + SetTabBarBadgeProtocol, + SetTabBarItemOptions, + SetTabBarItemProtocol, + SetTabBarStyleOptions, + SetTabBarStyleProtocol, + ShowTabBarProtocol, + ShowTabBarRedDotOptions, + ShowTabBarRedDotProtocol, +} from '@dcloudio/uni-api' +import { useTabBar } from '../../../framework/plugin/state' + +function setTabBar( + type: string, + args: Record, + resolve: () => void +) { + const tabBar = useTabBar()! + switch (type) { + case 'showTabBar': + tabBar.shown = true + break + case 'hideTabBar': + tabBar.shown = false + } + resolve() +} + +export const setTabBarItem = defineAsyncApi( + 'setTabBarItem', + (args, { resolve }) => { + setTabBar('setTabBarItem', args, resolve) + }, + SetTabBarItemProtocol, + SetTabBarItemOptions +) + +export const setTabBarStyle = defineAsyncApi( + 'setTabBarStyle', + () => {}, + SetTabBarStyleProtocol, + SetTabBarStyleOptions +) + +export const hideTabBar = defineAsyncApi( + 'hideTabBar', + (args, { resolve }) => { + setTabBar('hideTabBar', args, resolve) + }, + HideTabBarProtocol +) + +export const showTabBar = defineAsyncApi( + 'showTabBar', + (args, { resolve }) => { + setTabBar('showTabBar', args, resolve) + }, + ShowTabBarProtocol +) +export const hideTabBarRedDot = defineAsyncApi( + 'hideTabBarRedDot', + () => {}, + HideTabBarRedDotProtocol, + HideTabBarRedDotOptions +) + +export const showTabBarRedDot = defineAsyncApi( + 'showTabBarRedDot', + () => {}, + ShowTabBarRedDotProtocol, + ShowTabBarRedDotOptions +) + +export const removeTabBarBadge = defineAsyncApi( + 'removeTabBarBadge', + () => {}, + RemoveTabBarBadgeProtocol, + RemoveTabBarBadgeOptions +) + +export const setTabBarBadge = defineAsyncApi( + 'setTabBarBadge', + () => {}, + SetTabBarBadgeProtocol, + SetTabBarBadgeOptions +) diff --git a/packages/uni-h5/style/tabBar.css b/packages/uni-h5/style/tabBar.css new file mode 100644 index 0000000000000000000000000000000000000000..2392902ff14482504c8b42f55c50e5a2392d7fb1 --- /dev/null +++ b/packages/uni-h5/style/tabBar.css @@ -0,0 +1,131 @@ +uni-tabbar { + display: block; + box-sizing: border-box; + width: 100%; + z-index: 998; +} + +.uni-tabbar { + display: flex; + z-index: 998; + box-sizing: border-box; +} + +.uni-tabbar-top, +.uni-tabbar-bottom, +.uni-tabbar-top .uni-tabbar, +.uni-tabbar-bottom .uni-tabbar { + position: fixed; + left: var(--window-left); + right: var(--window-right); +} + +.uni-app--showlayout + .uni-tabbar-top, +.uni-app--showlayout + .uni-tabbar-bottom, +.uni-app--showlayout + .uni-tabbar-top .uni-tabbar, +.uni-app--showlayout + .uni-tabbar-bottom .uni-tabbar { + left: var(--window-margin); + right: var(--window-margin); +} + +.uni-tabbar-bottom .uni-tabbar { + bottom: 0; + padding-bottom: 0; + padding-bottom: constant(safe-area-inset-bottom); + padding-bottom: env(safe-area-inset-bottom); +} + +.uni-tabbar ~ .uni-placeholder { + width: 100%; + margin-bottom: 0; + margin-bottom: constant(safe-area-inset-bottom); + margin-bottom: env(safe-area-inset-bottom); +} + +.uni-tabbar * { + box-sizing: border-box; +} + +.uni-tabbar__item { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + flex: 1; + font-size: 0; + text-align: center; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} + +.uni-tabbar__bd { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + cursor: pointer; +} + +.uni-tabbar__icon { + position: relative; + display: inline-block; + margin-top: 5px; +} + +.uni-tabbar__icon.uni-tabbar__icon__diff { + margin-top: 0px; + width: 34px; + height: 34px; +} + +.uni-tabbar__icon img { + width: 100%; + height: 100%; +} + +.uni-tabbar__label { + position: relative; + text-align: center; + font-size: 10px; +} + +.uni-tabbar-border { + position: absolute; + left: 0; + top: 0; + width: 100%; + height: 1px; + transform: scaleY(0.5); +} + +.uni-tabbar__reddot { + position: absolute; + top: 0; + right: 0; + width: 12px; + height: 12px; + border-radius: 50%; + background-color: #f43530; + color: #ffffff; + transform: translate(40%, -20%); +} + +.uni-tabbar__badge { + width: auto; + height: 16px; + line-height: 16px; + border-radius: 16px; + min-width: 16px; + padding: 0 2px; + font-size: 12px; + text-align: center; + white-space: nowrap; +} + +.uni-tabbar__mid { + display: flex; + justify-content: center; + position: absolute; + bottom: 0; + background-size: 100% 100%; +} diff --git a/packages/uni-h5/types/shims-vue-router.d.ts b/packages/uni-h5/types/shims-vue-router.d.ts index c04dd28b19b2dc9a5724330abd223118d06c1220..b5655a6fab569b04e8cba38699a9ba70e5c0773b 100644 --- a/packages/uni-h5/types/shims-vue-router.d.ts +++ b/packages/uni-h5/types/shims-vue-router.d.ts @@ -1,6 +1,7 @@ import 'vue-router' declare module 'vue-router' { interface RouteMeta { + route: string isEntry: boolean isTabBar: boolean topWindow?: boolean diff --git a/packages/uni-mp-alipay/dist/uni.api.esm.js b/packages/uni-mp-alipay/dist/uni.api.esm.js index 11dc6352db18d8a4e5ab46b1b00fbb2377f5c043..d38348e9377fa9e6593b5b08b502a2ac2868a360 100644 --- a/packages/uni-mp-alipay/dist/uni.api.esm.js +++ b/packages/uni-mp-alipay/dist/uni.api.esm.js @@ -1,4 +1,4 @@ -import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction, isString } from '@vue/shared'; +import { isArray, hasOwn, isString, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction } from '@vue/shared'; function validateProtocolFail(name, msg) { const errMsg = `${name}:fail ${msg}`; @@ -12,7 +12,7 @@ function validateProtocolFail(name, msg) { function validateProtocol(name, data, protocol) { for (const key in protocol) { const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key)); - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg); } } @@ -65,8 +65,8 @@ function validateProp(name, value, prop, isAbsent) { } } // custom validator - if (validator && !validator(value)) { - return ('Invalid args: custom validator check failed for args "' + name + '".'); + if (validator) { + return validator(value); } } const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); @@ -170,7 +170,13 @@ function wrapperApi(fn, name, protocol, options) { return function (...args) { if ((process.env.NODE_ENV !== 'production')) { const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { + if (isString(errMsg)) { + return errMsg; + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { return errMsg; } } diff --git a/packages/uni-mp-baidu/dist/uni.api.esm.js b/packages/uni-mp-baidu/dist/uni.api.esm.js index 67b68706aba7af076273ede2716d4db076dfd408..d3616ab562de4b37d36e43251892d372b2414677 100644 --- a/packages/uni-mp-baidu/dist/uni.api.esm.js +++ b/packages/uni-mp-baidu/dist/uni.api.esm.js @@ -1,4 +1,4 @@ -import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction, isString } from '@vue/shared'; +import { isArray, hasOwn, isString, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction } from '@vue/shared'; function validateProtocolFail(name, msg) { const errMsg = `${name}:fail ${msg}`; @@ -12,7 +12,7 @@ function validateProtocolFail(name, msg) { function validateProtocol(name, data, protocol) { for (const key in protocol) { const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key)); - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg); } } @@ -65,8 +65,8 @@ function validateProp(name, value, prop, isAbsent) { } } // custom validator - if (validator && !validator(value)) { - return ('Invalid args: custom validator check failed for args "' + name + '".'); + if (validator) { + return validator(value); } } const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); @@ -170,7 +170,13 @@ function wrapperApi(fn, name, protocol, options) { return function (...args) { if ((process.env.NODE_ENV !== 'production')) { const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { + if (isString(errMsg)) { + return errMsg; + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { return errMsg; } } diff --git a/packages/uni-mp-qq/dist/uni.api.esm.js b/packages/uni-mp-qq/dist/uni.api.esm.js index 36f6b26ad1d83e3aefd3b0133a87c597595d4e88..1ea319e02bc104b6a734ff47d35e9fb414281912 100644 --- a/packages/uni-mp-qq/dist/uni.api.esm.js +++ b/packages/uni-mp-qq/dist/uni.api.esm.js @@ -1,4 +1,4 @@ -import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction, isString } from '@vue/shared'; +import { isArray, hasOwn, isString, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction } from '@vue/shared'; function validateProtocolFail(name, msg) { const errMsg = `${name}:fail ${msg}`; @@ -12,7 +12,7 @@ function validateProtocolFail(name, msg) { function validateProtocol(name, data, protocol) { for (const key in protocol) { const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key)); - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg); } } @@ -65,8 +65,8 @@ function validateProp(name, value, prop, isAbsent) { } } // custom validator - if (validator && !validator(value)) { - return ('Invalid args: custom validator check failed for args "' + name + '".'); + if (validator) { + return validator(value); } } const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); @@ -170,7 +170,13 @@ function wrapperApi(fn, name, protocol, options) { return function (...args) { if ((process.env.NODE_ENV !== 'production')) { const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { + if (isString(errMsg)) { + return errMsg; + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { return errMsg; } } diff --git a/packages/uni-mp-toutiao/dist/uni.api.esm.js b/packages/uni-mp-toutiao/dist/uni.api.esm.js index eaa50cdbb2c86739006d99c752753dc6199ea9de..949a331cf0b04d4b936f41baf249b74a6b28bafb 100644 --- a/packages/uni-mp-toutiao/dist/uni.api.esm.js +++ b/packages/uni-mp-toutiao/dist/uni.api.esm.js @@ -1,4 +1,4 @@ -import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction, isString } from '@vue/shared'; +import { isArray, hasOwn, isString, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction } from '@vue/shared'; function validateProtocolFail(name, msg) { const errMsg = `${name}:fail ${msg}`; @@ -12,7 +12,7 @@ function validateProtocolFail(name, msg) { function validateProtocol(name, data, protocol) { for (const key in protocol) { const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key)); - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg); } } @@ -65,8 +65,8 @@ function validateProp(name, value, prop, isAbsent) { } } // custom validator - if (validator && !validator(value)) { - return ('Invalid args: custom validator check failed for args "' + name + '".'); + if (validator) { + return validator(value); } } const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); @@ -170,7 +170,13 @@ function wrapperApi(fn, name, protocol, options) { return function (...args) { if ((process.env.NODE_ENV !== 'production')) { const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { + if (isString(errMsg)) { + return errMsg; + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { return errMsg; } } diff --git a/packages/uni-mp-weixin/dist/uni.api.esm.js b/packages/uni-mp-weixin/dist/uni.api.esm.js index c357360c506b8ddd1540de953ba5daec8d2a4a45..383034036cd430a541ce84ff389f625e83af2fdc 100644 --- a/packages/uni-mp-weixin/dist/uni.api.esm.js +++ b/packages/uni-mp-weixin/dist/uni.api.esm.js @@ -1,4 +1,4 @@ -import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction, isString } from '@vue/shared'; +import { isArray, hasOwn, isString, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction } from '@vue/shared'; function validateProtocolFail(name, msg) { const errMsg = `${name}:fail ${msg}`; @@ -12,7 +12,7 @@ function validateProtocolFail(name, msg) { function validateProtocol(name, data, protocol) { for (const key in protocol) { const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key)); - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg); } } @@ -65,8 +65,8 @@ function validateProp(name, value, prop, isAbsent) { } } // custom validator - if (validator && !validator(value)) { - return ('Invalid args: custom validator check failed for args "' + name + '".'); + if (validator) { + return validator(value); } } const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); @@ -170,7 +170,13 @@ function wrapperApi(fn, name, protocol, options) { return function (...args) { if ((process.env.NODE_ENV !== 'production')) { const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { + if (isString(errMsg)) { + return errMsg; + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { return errMsg; } } diff --git a/packages/uni-quickapp-webview/dist/uni.api.esm.js b/packages/uni-quickapp-webview/dist/uni.api.esm.js index 5be717be220708be865e154a9761e38d2d11696b..16450f24a75e1b21a5d4c513aeae8579a50f8513 100644 --- a/packages/uni-quickapp-webview/dist/uni.api.esm.js +++ b/packages/uni-quickapp-webview/dist/uni.api.esm.js @@ -1,4 +1,4 @@ -import { isArray, hasOwn, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction, isString } from '@vue/shared'; +import { isArray, hasOwn, isString, isObject, capitalize, toRawType, makeMap, isPlainObject, isPromise, isFunction } from '@vue/shared'; function validateProtocolFail(name, msg) { const errMsg = `${name}:fail ${msg}`; @@ -12,7 +12,7 @@ function validateProtocolFail(name, msg) { function validateProtocol(name, data, protocol) { for (const key in protocol) { const errMsg = validateProp(key, data[key], protocol[key], !hasOwn(data, key)); - if (errMsg) { + if (isString(errMsg)) { return validateProtocolFail(name, errMsg); } } @@ -65,8 +65,8 @@ function validateProp(name, value, prop, isAbsent) { } } // custom validator - if (validator && !validator(value)) { - return ('Invalid args: custom validator check failed for args "' + name + '".'); + if (validator) { + return validator(value); } } const isSimpleType = /*#__PURE__*/ makeMap('String,Number,Boolean,Function,Symbol'); @@ -170,7 +170,13 @@ function wrapperApi(fn, name, protocol, options) { return function (...args) { if ((process.env.NODE_ENV !== 'production')) { const errMsg = validateProtocols(name, args, protocol); - if (errMsg) { + if (isString(errMsg)) { + return errMsg; + } + } + if (options && options.beforeInvoke) { + const errMsg = options.beforeInvoke(args); + if (isString(errMsg)) { return errMsg; } } diff --git a/packages/uni-shared/dist/uni-shared.cjs.js b/packages/uni-shared/dist/uni-shared.cjs.js index 3b46f0d534bef748f7ba650f032815515a7822c7..c7fd1e65ffc14ae1140ba8fafb25839fbc870674 100644 --- a/packages/uni-shared/dist/uni-shared.cjs.js +++ b/packages/uni-shared/dist/uni-shared.cjs.js @@ -97,6 +97,10 @@ function isNativeTag(tag) { const COMPONENT_SELECTOR_PREFIX = 'uni-'; const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX; +function getLen(str = '') { + return ('' + str).replace(/[^\x00-\xff]/g, '**').length; +} + const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { const res = obj @@ -146,6 +150,7 @@ exports.RESPONSIVE_MIN_WIDTH = RESPONSIVE_MIN_WIDTH; exports.TABBAR_HEIGHT = TABBAR_HEIGHT; exports.TAGS = TAGS; exports.debounce = debounce; +exports.getLen = getLen; exports.isBuiltInComponent = isBuiltInComponent; exports.isCustomElement = isCustomElement; exports.isNativeTag = isNativeTag; diff --git a/packages/uni-shared/dist/uni-shared.d.ts b/packages/uni-shared/dist/uni-shared.d.ts index c6d48549b4610cabcca5a321c421f8ab896130cd..a429d48d986d34f98cef8c3dd0acab74ee6d7038 100644 --- a/packages/uni-shared/dist/uni-shared.d.ts +++ b/packages/uni-shared/dist/uni-shared.d.ts @@ -12,6 +12,8 @@ export declare function debounce(fn: Function, delay: number): { cancel(): void; }; +export declare function getLen(str?: string): number; + export declare function isBuiltInComponent(tag: string): boolean; export declare function isCustomElement(tag: string): boolean; diff --git a/packages/uni-shared/dist/uni-shared.esm.js b/packages/uni-shared/dist/uni-shared.esm.js index 47a526d12a907dbb21be19f15ed916c06c24b781..015930be322a39f247417d29e65034e9de2a1037 100644 --- a/packages/uni-shared/dist/uni-shared.esm.js +++ b/packages/uni-shared/dist/uni-shared.esm.js @@ -93,6 +93,10 @@ function isNativeTag(tag) { const COMPONENT_SELECTOR_PREFIX = 'uni-'; const COMPONENT_PREFIX = 'v-' + COMPONENT_SELECTOR_PREFIX; +function getLen(str = '') { + return ('' + str).replace(/[^\x00-\xff]/g, '**').length; +} + const encode = encodeURIComponent; function stringifyQuery(obj, encodeStr = encode) { const res = obj @@ -132,4 +136,4 @@ const RESPONSIVE_MIN_WIDTH = 768; const COMPONENT_NAME_PREFIX = 'VUni'; const PRIMARY_COLOR = '#007aff'; -export { BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, NAVBAR_HEIGHT, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, TABBAR_HEIGHT, TAGS, debounce, isBuiltInComponent, isCustomElement, isNativeTag, normalizeDataset, passive, plusReady, stringifyQuery }; +export { BUILT_IN_TAGS, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, NAVBAR_HEIGHT, PRIMARY_COLOR, RESPONSIVE_MIN_WIDTH, TABBAR_HEIGHT, TAGS, debounce, getLen, isBuiltInComponent, isCustomElement, isNativeTag, normalizeDataset, passive, plusReady, stringifyQuery }; diff --git a/packages/uni-shared/src/index.ts b/packages/uni-shared/src/index.ts index 8a534ead272e442f6546f70237c5f06e79c6bf32..fdbb40500ac4c136812a5df98703e2657f3d9ab7 100644 --- a/packages/uni-shared/src/index.ts +++ b/packages/uni-shared/src/index.ts @@ -1,6 +1,7 @@ export * from './dom' export * from './plus' export * from './tags' +export * from './utils' export * from './query' export * from './debounce' export * from './constants' diff --git a/packages/uni-shared/src/utils.ts b/packages/uni-shared/src/utils.ts new file mode 100644 index 0000000000000000000000000000000000000000..7cfb22dcbdb68e5301ee346763dea2ff03c0cac1 --- /dev/null +++ b/packages/uni-shared/src/utils.ts @@ -0,0 +1,3 @@ +export function getLen(str = '') { + return ('' + str).replace(/[^\x00-\xff]/g, '**').length +} diff --git a/packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts b/packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts index 9964004eaad50c04d960b7de58c8dcffa10a3c4c..0188288363ee479ec7c25feaa8e7f7fe65550f36 100644 --- a/packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts +++ b/packages/vite-plugin-uni/src/configResolved/plugins/pagesJson.ts @@ -105,6 +105,9 @@ function generateCssCode(config: ResolvedConfig) { if (define.__UNI_FEATURE_NAVIGATIONBAR__) { cssFiles.push('@dcloudio/uni-h5/style/pageHead.css') } + if (define.__UNI_FEATURE_TABBAR__) { + cssFiles.push('@dcloudio/uni-h5/style/tabBar.css') + } if (define.__UNI_FEATURE_NVUE__) { cssFiles.push('@dcloudio/uni-h5/style/nvue.css') } @@ -151,6 +154,7 @@ function normalizePagesRoute(pagesJson: UniApp.PagesJson): PageRouteOptions[] { let windowTop = 0 const meta = Object.assign( { + route: pageOptions.path, isQuit: isEntry || isTabBar ? true : undefined, isEntry, isTabBar, @@ -159,11 +163,6 @@ function normalizePagesRoute(pagesJson: UniApp.PagesJson): PageRouteOptions[] { }, pageOptions.style ) - - if (isEntry) { - ;(meta as any).route = pageOptions.path - } - return { name, path: pageOptions.path, diff --git a/packages/vite-plugin-uni/src/utils/define.ts b/packages/vite-plugin-uni/src/utils/define.ts index acbdaf5de12f3ac5504124ca87303e43fdd64395..3796dfbbc6210371fd430c6a26974ce06729c88f 100644 --- a/packages/vite-plugin-uni/src/utils/define.ts +++ b/packages/vite-plugin-uni/src/utils/define.ts @@ -11,6 +11,7 @@ interface PagesFeatures { nvue: boolean pages: boolean tabBar: boolean + tabBarMidButton: boolean topWindow: boolean leftWindow: boolean rightWindow: boolean @@ -46,6 +47,7 @@ function resolvePagesFeature( nvue: true, pages: true, tabBar: true, + tabBarMidButton: true, topWindow: false, leftWindow: false, rightWindow: false, @@ -72,6 +74,10 @@ function resolvePagesFeature( } if (!(tabBar && tabBar.list && tabBar.list.length)) { features.tabBar = false + features.tabBarMidButton = false + } + if (features.tabBar && !tabBar!.midButton) { + features.tabBarMidButton = false } if (topWindow && topWindow.path) { features.topWindow = true @@ -177,6 +183,7 @@ export function getFeatures( nvue, pages, tabBar, + tabBarMidButton, promise, longpress, routerMode, @@ -203,6 +210,7 @@ export function getFeatures( __UNI_FEATURE_ROUTER_MODE__: routerMode, // 路由模式 __UNI_FEATURE_PAGES__: pages, // 是否多页面 __UNI_FEATURE_TABBAR__: tabBar, // 是否包含tabBar + __UNI_FEATURE_TABBAR_MIDBUTTON__: tabBarMidButton, // 是否包含midButton __UNI_FEATURE_TOPWINDOW__: topWindow, // 是否包含topWindow __UNI_FEATURE_LEFTWINDOW__: leftWindow, // 是否包含leftWindow __UNI_FEATURE_RIGHTWINDOW__: rightWindow, // 是否包含rightWindow diff --git a/packages/vite-plugin-uni/src/utils/pagesJson.ts b/packages/vite-plugin-uni/src/utils/pagesJson.ts index 9abab5bae6db8daff839d5204cb3e0351f88d250..d2b495c523fbcaa6cc8e243f554bd8d7971ca776 100644 --- a/packages/vite-plugin-uni/src/utils/pagesJson.ts +++ b/packages/vite-plugin-uni/src/utils/pagesJson.ts @@ -1,7 +1,8 @@ import path from 'path' import slash from 'slash' -import { hasOwn, isArray, isPlainObject } from '@vue/shared' +import { extend, hasOwn, isArray, isPlainObject } from '@vue/shared' import { parseJson } from '@dcloudio/uni-cli-shared' +import { TABBAR_HEIGHT } from '@dcloudio/uni-shared' export function normalizePagesJson(jsonStr: string, platform: UniApp.PLATFORM) { let pagesJson: UniApp.PagesJson = { @@ -26,6 +27,15 @@ export function normalizePagesJson(jsonStr: string, platform: UniApp.PLATFORM) { normalizePages(pagesJson.pages, platform) // globalStyle pagesJson.globalStyle = normalizePageStyle(pagesJson.globalStyle!, platform) + // tabBar + if (pagesJson.tabBar) { + const tabBar = normalizeTabBar(pagesJson.tabBar!) + if (tabBar) { + pagesJson.tabBar = tabBar + } else { + delete pagesJson.tabBar + } + } return pagesJson } @@ -181,6 +191,69 @@ function normalizeNavigationBarSearchInput( ) } +const DEFAULT_TAB_BAR: Partial = { + position: 'bottom', + color: '#999', + selectedColor: '#007aff', + borderStyle: 'black', + blurEffect: 'none', + fontSize: '10px', + iconWidth: '24px', + spacing: '3px', + height: TABBAR_HEIGHT + 'px', +} + +function normalizeTabBar(tabBar: UniApp.TabBarOptions) { + const { list, midButton } = tabBar + if (!list || !list.length) { + return + } + tabBar = extend({}, DEFAULT_TAB_BAR, tabBar) + const len = list.length + if (len % 2 === 0 && isPlainObject(midButton)) { + list.splice( + Math.floor(len / 2), + 0, + extend( + { + type: 'midButton', + width: '50px', + height: '50px', + iconWidth: '24px', + }, + midButton + ) + ) + } else { + delete tabBar.midButton + } + list.forEach((item) => { + if (item.iconPath) { + item.iconPath = normalizeFilepath(item.iconPath) + } + if (item.selectedIconPath) { + item.selectedIconPath = normalizeFilepath(item.selectedIconPath) + } + if (item.type === 'midButton' && item.backgroundImage) { + item.backgroundImage = normalizeFilepath(item.backgroundImage) + } + }) + tabBar.selectedIndex = 0 + tabBar.shown = true + return tabBar +} +const SCHEME_RE = /^([a-z-]+:)?\/\//i +const DATA_RE = /^data:.*,.*/ +function normalizeFilepath(filepath: string) { + if ( + !(SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) && + filepath.indexOf('/') !== 0 + ) { + return '/' + filepath + } + return filepath +} + const platforms = ['h5', 'app-plus', 'mp-', 'quickapp'] function removePlatformStyle(pageStyle: UniApp.PagesJsonPageStyle) {