@weapp-vite/web 1.4.13 → 1.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/runtime/appShell/tabBar/index.mjs.map +1 -1
- package/dist/runtime/button/index.mjs.map +1 -1
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -1
- package/dist/runtime/nativeComponents/form.mjs.map +1 -1
- package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/image.mjs.map +1 -1
- package/dist/runtime/nativeComponents/input.mjs.map +1 -1
- package/dist/runtime/nativeComponents/label.mjs.map +1 -1
- package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/navigator.mjs.map +1 -1
- package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -1
- package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/radio.mjs.map +1 -1
- package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -1
- package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/switch.mjs.map +1 -1
- package/dist/runtime/nativeComponents/textarea.mjs.map +1 -1
- package/dist/runtime/nativeComponents/video/index.mjs.map +1 -1
- package/dist/runtime/navigationBar/index.mjs.map +1 -1
- package/dist/runtime/polyfill/animation.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["#createStyle","#createBar","#createItem"],"sources":["../../../../src/runtime/appShell/tabBar/index.ts"],"sourcesContent":["import type { WebTabBarConfig, WebTabBarItem } from '../../../shared/tabBar'\nimport { ensureAppContainer, getAppContainer, onDocumentReady } from '../container'\nimport { TAB_BAR_STYLE } from './style'\n\ninterface TabBarItemState {\n badge?: string\n redDot?: boolean\n}\n\ntype SwitchTabHandler = (url: string) => Promise<unknown>\n\nconst TAB_BAR_TAG = 'weapp-tab-bar'\nconst TAB_BAR_HEIGHT = '50px'\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nlet tabBarConfig: WebTabBarConfig | undefined\nlet activeRoute = ''\nlet requestedVisible = true\nlet animationEnabled = false\nlet switchTabHandler: SwitchTabHandler | undefined\nlet itemStates: TabBarItemState[] = []\nconst instances = new Set<WeappTabBar>()\n\nfunction resolveAssetUrl(value: string | undefined) {\n if (!value || /^(?:data:|blob:|https?:\\/\\/|\\/)/.test(value)) {\n return value\n }\n return `/${value.replace(/^\\.\\//, '')}`\n}\n\nfunction isNativeTabBarVisible() {\n return Boolean(\n tabBarConfig\n && !tabBarConfig.custom\n && requestedVisible\n && tabBarConfig.list.some(item => item.pagePath === activeRoute),\n )\n}\n\nfunction syncContainerInsets() {\n const container = getAppContainer()\n if (!container) {\n return\n }\n const bottomVisible = isNativeTabBarVisible() && tabBarConfig?.position !== 'top'\n const topVisible = isNativeTabBarVisible() && tabBarConfig?.position === 'top'\n container.style?.setProperty(\n '--weapp-tab-bar-inset',\n bottomVisible ? `calc(${TAB_BAR_HEIGHT} + var(--weapp-safe-area-inset-bottom, 0px))` : '0px',\n )\n container.style?.setProperty('--weapp-tab-bar-top-inset', topVisible ? TAB_BAR_HEIGHT : '0px')\n}\n\nfunction updateInstances() {\n syncContainerInsets()\n for (const instance of instances) {\n instance.renderTabBar()\n }\n}\n\nfunction ensureTabBarMounted() {\n onDocumentReady(() => {\n const container = ensureAppContainer()\n if (!container || tabBarConfig?.custom || !tabBarConfig) {\n container?.querySelector(TAB_BAR_TAG)?.remove()\n syncContainerInsets()\n return\n }\n let element = container.querySelector(TAB_BAR_TAG) as WeappTabBar | null\n if (!element) {\n element = document.createElement(TAB_BAR_TAG) as WeappTabBar\n container.append(element)\n }\n element.renderTabBar()\n })\n}\n\nfunction resolveItem(index: number) {\n if (!Number.isInteger(index) || index < 0 || !tabBarConfig?.list[index]) {\n return undefined\n }\n return tabBarConfig.list[index]\n}\n\nclass WeappTabBar extends BaseElement {\n connectedCallback() {\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' })\n }\n instances.add(this)\n this.renderTabBar()\n }\n\n disconnectedCallback() {\n instances.delete(this)\n }\n\n renderTabBar() {\n const root = this.shadowRoot\n const config = tabBarConfig\n if (!root || !config || config.custom) {\n return\n }\n this.toggleAttribute('hidden', !isNativeTabBarVisible())\n this.setAttribute('position', config.position)\n this.toggleAttribute('data-animation', animationEnabled)\n this.style.setProperty('--weapp-tab-bar-color', config.color)\n this.style.setProperty('--weapp-tab-bar-selected-color', config.selectedColor)\n this.style.setProperty('--weapp-tab-bar-background', config.backgroundColor)\n this.style.setProperty(\n '--weapp-tab-bar-border-color',\n config.borderStyle === 'white' ? 'rgba(255, 255, 255, 0.33)' : 'rgba(0, 0, 0, 0.33)',\n )\n root.replaceChildren(this.#createStyle(), this.#createBar(config))\n }\n\n #createStyle() {\n const style = document.createElement('style')\n style.textContent = TAB_BAR_STYLE\n return style\n }\n\n #createBar(config: WebTabBarConfig) {\n const bar = document.createElement('nav')\n bar.className = 'weapp-tab-bar'\n bar.setAttribute('aria-label', 'Tab bar')\n for (const [index, item] of config.list.entries()) {\n bar.append(this.#createItem(item, index))\n }\n return bar\n }\n\n #createItem(item: WebTabBarItem, index: number) {\n const selected = item.pagePath === activeRoute\n const button = document.createElement('button')\n button.type = 'button'\n button.className = 'weapp-tab-bar__item'\n button.dataset.index = String(index)\n button.dataset.pagePath = item.pagePath\n if (selected) {\n button.setAttribute('aria-current', 'page')\n }\n const iconPath = resolveAssetUrl(selected ? (item.selectedIconPath ?? item.iconPath) : item.iconPath)\n const state = itemStates[index]\n if (iconPath || state?.badge || state?.redDot) {\n const iconWrap = document.createElement('span')\n iconWrap.className = 'weapp-tab-bar__icon-wrap'\n if (iconPath) {\n const icon = document.createElement('img')\n icon.className = 'weapp-tab-bar__icon'\n icon.src = iconPath\n icon.alt = ''\n iconWrap.append(icon)\n }\n if (state?.badge || state?.redDot) {\n const badge = document.createElement('span')\n badge.className = state.redDot\n ? 'weapp-tab-bar__badge weapp-tab-bar__badge--dot'\n : 'weapp-tab-bar__badge'\n badge.textContent = state.redDot ? '' : state.badge!\n iconWrap.append(badge)\n }\n button.append(iconWrap)\n }\n const label = document.createElement('span')\n label.className = 'weapp-tab-bar__label'\n label.textContent = item.text\n button.append(label)\n button.addEventListener('click', () => {\n if (selected || !switchTabHandler) {\n return\n }\n void switchTabHandler(`/${item.pagePath}`).catch(() => {})\n })\n return button\n }\n}\n\nexport function ensureTabBarDefined() {\n if (typeof customElements === 'undefined' || customElements.get(TAB_BAR_TAG)) {\n return\n }\n customElements.define(TAB_BAR_TAG, WeappTabBar)\n}\n\nexport function configureTabBar(config: WebTabBarConfig | undefined, onSwitchTab: SwitchTabHandler) {\n ensureTabBarDefined()\n tabBarConfig = config\n ? {\n ...config,\n list: config.list.map(item => ({ ...item })),\n }\n : undefined\n switchTabHandler = onSwitchTab\n itemStates = config?.list.map(() => ({})) ?? []\n requestedVisible = true\n animationEnabled = false\n ensureTabBarMounted()\n updateInstances()\n}\n\nexport function getTabBarPagePaths() {\n return new Set(tabBarConfig?.list.map(item => item.pagePath) ?? [])\n}\n\nexport function syncTabBarRoute(route: string) {\n activeRoute = route\n ensureTabBarMounted()\n updateInstances()\n}\n\nexport function setTabBarVisible(visible: boolean, animation = false) {\n requestedVisible = visible\n animationEnabled = animation\n updateInstances()\n return true\n}\n\nexport function updateTabBarItem(index: number, patch: Partial<Omit<WebTabBarItem, 'pagePath'>>) {\n const item = resolveItem(index)\n if (!item) {\n return false\n }\n Object.assign(item, patch)\n updateInstances()\n return true\n}\n\nexport function updateTabBarStyle(patch: Partial<Pick<WebTabBarConfig, 'color' | 'selectedColor' | 'backgroundColor' | 'borderStyle'>>) {\n if (!tabBarConfig) {\n return false\n }\n Object.assign(tabBarConfig, patch)\n updateInstances()\n return true\n}\n\nexport function setTabBarBadgeState(index: number, badge: string | undefined) {\n if (!resolveItem(index)) {\n return false\n }\n itemStates[index] = { badge, redDot: false }\n updateInstances()\n return true\n}\n\nexport function setTabBarRedDotState(index: number, redDot: boolean) {\n if (!resolveItem(index)) {\n return false\n }\n itemStates[index] = { redDot, badge: undefined }\n updateInstances()\n return true\n}\n\nexport type { WebTabBarConfig, WebTabBarItem } from '../../../shared/tabBar'\n"],"mappings":";;;;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAI;AACJ,IAAI,cAAc;AAClB,IAAI,mBAAmB;AACvB,IAAI,mBAAmB;AACvB,IAAI;AACJ,IAAI,aAAgC,CAAC;AACrC,MAAM,4BAAY,IAAI,IAAiB;AAEvC,SAAS,gBAAgB,OAA2B;CAClD,IAAI,CAAC,SAAS,kCAAkC,KAAK,KAAK,GACxD,OAAO;CAET,OAAO,IAAI,MAAM,QAAQ,SAAS,EAAE;AACtC;AAEA,SAAS,wBAAwB;CAC/B,OAAO,QACL,gBACG,CAAC,aAAa,UACd,oBACA,aAAa,KAAK,MAAK,SAAQ,KAAK,aAAa,WAAW,CACjE;AACF;AAEA,SAAS,sBAAsB;CAC7B,MAAM,YAAY,gBAAgB;CAClC,IAAI,CAAC,WACH;CAEF,MAAM,gBAAgB,sBAAsB,KAAK,cAAc,aAAa;CAC5E,MAAM,aAAa,sBAAsB,KAAK,cAAc,aAAa;CACzE,UAAU,OAAO,YACf,yBACA,gBAAgB,QAAQ,eAAe,gDAAgD,KACzF;CACA,UAAU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GACpB,OAAO;CAET,WAAW,SAAS;EAAE;EAAO,QAAQ;CAAM;CAC3C,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,qBAAqB,OAAe,QAAiB;CACnE,IAAI,CAAC,YAAY,KAAK,GACpB,OAAO;CAET,WAAW,SAAS;EAAE;EAAQ,OAAO;CAAU;CAC/C,gBAAgB;CAChB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/appShell/tabBar/index.ts"],"sourcesContent":["import type { WebTabBarConfig, WebTabBarItem } from '../../../shared/tabBar'\nimport { ensureAppContainer, getAppContainer, onDocumentReady } from '../container'\nimport { TAB_BAR_STYLE } from './style'\n\ninterface TabBarItemState {\n badge?: string\n redDot?: boolean\n}\n\ntype SwitchTabHandler = (url: string) => Promise<unknown>\n\nconst TAB_BAR_TAG = 'weapp-tab-bar'\nconst TAB_BAR_HEIGHT = '50px'\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nlet tabBarConfig: WebTabBarConfig | undefined\nlet activeRoute = ''\nlet requestedVisible = true\nlet animationEnabled = false\nlet switchTabHandler: SwitchTabHandler | undefined\nlet itemStates: TabBarItemState[] = []\nconst instances = new Set<WeappTabBar>()\n\nfunction resolveAssetUrl(value: string | undefined) {\n if (!value || /^(?:data:|blob:|https?:\\/\\/|\\/)/.test(value)) {\n return value\n }\n return `/${value.replace(/^\\.\\//, '')}`\n}\n\nfunction isNativeTabBarVisible() {\n return Boolean(\n tabBarConfig\n && !tabBarConfig.custom\n && requestedVisible\n && tabBarConfig.list.some(item => item.pagePath === activeRoute),\n )\n}\n\nfunction syncContainerInsets() {\n const container = getAppContainer()\n if (!container) {\n return\n }\n const bottomVisible = isNativeTabBarVisible() && tabBarConfig?.position !== 'top'\n const topVisible = isNativeTabBarVisible() && tabBarConfig?.position === 'top'\n container.style?.setProperty(\n '--weapp-tab-bar-inset',\n bottomVisible ? `calc(${TAB_BAR_HEIGHT} + var(--weapp-safe-area-inset-bottom, 0px))` : '0px',\n )\n container.style?.setProperty('--weapp-tab-bar-top-inset', topVisible ? TAB_BAR_HEIGHT : '0px')\n}\n\nfunction updateInstances() {\n syncContainerInsets()\n for (const instance of instances) {\n instance.renderTabBar()\n }\n}\n\nfunction ensureTabBarMounted() {\n onDocumentReady(() => {\n const container = ensureAppContainer()\n if (!container || tabBarConfig?.custom || !tabBarConfig) {\n container?.querySelector(TAB_BAR_TAG)?.remove()\n syncContainerInsets()\n return\n }\n let element = container.querySelector(TAB_BAR_TAG) as WeappTabBar | null\n if (!element) {\n element = document.createElement(TAB_BAR_TAG) as WeappTabBar\n container.append(element)\n }\n element.renderTabBar()\n })\n}\n\nfunction resolveItem(index: number) {\n if (!Number.isInteger(index) || index < 0 || !tabBarConfig?.list[index]) {\n return undefined\n }\n return tabBarConfig.list[index]\n}\n\nclass WeappTabBar extends BaseElement {\n connectedCallback() {\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' })\n }\n instances.add(this)\n this.renderTabBar()\n }\n\n disconnectedCallback() {\n instances.delete(this)\n }\n\n renderTabBar() {\n const root = this.shadowRoot\n const config = tabBarConfig\n if (!root || !config || config.custom) {\n return\n }\n this.toggleAttribute('hidden', !isNativeTabBarVisible())\n this.setAttribute('position', config.position)\n this.toggleAttribute('data-animation', animationEnabled)\n this.style.setProperty('--weapp-tab-bar-color', config.color)\n this.style.setProperty('--weapp-tab-bar-selected-color', config.selectedColor)\n this.style.setProperty('--weapp-tab-bar-background', config.backgroundColor)\n this.style.setProperty(\n '--weapp-tab-bar-border-color',\n config.borderStyle === 'white' ? 'rgba(255, 255, 255, 0.33)' : 'rgba(0, 0, 0, 0.33)',\n )\n root.replaceChildren(this.#createStyle(), this.#createBar(config))\n }\n\n #createStyle() {\n const style = document.createElement('style')\n style.textContent = TAB_BAR_STYLE\n return style\n }\n\n #createBar(config: WebTabBarConfig) {\n const bar = document.createElement('nav')\n bar.className = 'weapp-tab-bar'\n bar.setAttribute('aria-label', 'Tab bar')\n for (const [index, item] of config.list.entries()) {\n bar.append(this.#createItem(item, index))\n }\n return bar\n }\n\n #createItem(item: WebTabBarItem, index: number) {\n const selected = item.pagePath === activeRoute\n const button = document.createElement('button')\n button.type = 'button'\n button.className = 'weapp-tab-bar__item'\n button.dataset.index = String(index)\n button.dataset.pagePath = item.pagePath\n if (selected) {\n button.setAttribute('aria-current', 'page')\n }\n const iconPath = resolveAssetUrl(selected ? (item.selectedIconPath ?? item.iconPath) : item.iconPath)\n const state = itemStates[index]\n if (iconPath || state?.badge || state?.redDot) {\n const iconWrap = document.createElement('span')\n iconWrap.className = 'weapp-tab-bar__icon-wrap'\n if (iconPath) {\n const icon = document.createElement('img')\n icon.className = 'weapp-tab-bar__icon'\n icon.src = iconPath\n icon.alt = ''\n iconWrap.append(icon)\n }\n if (state?.badge || state?.redDot) {\n const badge = document.createElement('span')\n badge.className = state.redDot\n ? 'weapp-tab-bar__badge weapp-tab-bar__badge--dot'\n : 'weapp-tab-bar__badge'\n badge.textContent = state.redDot ? '' : state.badge!\n iconWrap.append(badge)\n }\n button.append(iconWrap)\n }\n const label = document.createElement('span')\n label.className = 'weapp-tab-bar__label'\n label.textContent = item.text\n button.append(label)\n button.addEventListener('click', () => {\n if (selected || !switchTabHandler) {\n return\n }\n void switchTabHandler(`/${item.pagePath}`).catch(() => {})\n })\n return button\n }\n}\n\nexport function ensureTabBarDefined() {\n if (typeof customElements === 'undefined' || customElements.get(TAB_BAR_TAG)) {\n return\n }\n customElements.define(TAB_BAR_TAG, WeappTabBar)\n}\n\nexport function configureTabBar(config: WebTabBarConfig | undefined, onSwitchTab: SwitchTabHandler) {\n ensureTabBarDefined()\n tabBarConfig = config\n ? {\n ...config,\n list: config.list.map(item => ({ ...item })),\n }\n : undefined\n switchTabHandler = onSwitchTab\n itemStates = config?.list.map(() => ({})) ?? []\n requestedVisible = true\n animationEnabled = false\n ensureTabBarMounted()\n updateInstances()\n}\n\nexport function getTabBarPagePaths() {\n return new Set(tabBarConfig?.list.map(item => item.pagePath) ?? [])\n}\n\nexport function syncTabBarRoute(route: string) {\n activeRoute = route\n ensureTabBarMounted()\n updateInstances()\n}\n\nexport function setTabBarVisible(visible: boolean, animation = false) {\n requestedVisible = visible\n animationEnabled = animation\n updateInstances()\n return true\n}\n\nexport function updateTabBarItem(index: number, patch: Partial<Omit<WebTabBarItem, 'pagePath'>>) {\n const item = resolveItem(index)\n if (!item) {\n return false\n }\n Object.assign(item, patch)\n updateInstances()\n return true\n}\n\nexport function updateTabBarStyle(patch: Partial<Pick<WebTabBarConfig, 'color' | 'selectedColor' | 'backgroundColor' | 'borderStyle'>>) {\n if (!tabBarConfig) {\n return false\n }\n Object.assign(tabBarConfig, patch)\n updateInstances()\n return true\n}\n\nexport function setTabBarBadgeState(index: number, badge: string | undefined) {\n if (!resolveItem(index)) {\n return false\n }\n itemStates[index] = { badge, redDot: false }\n updateInstances()\n return true\n}\n\nexport function setTabBarRedDotState(index: number, redDot: boolean) {\n if (!resolveItem(index)) {\n return false\n }\n itemStates[index] = { redDot, badge: undefined }\n updateInstances()\n return true\n}\n\nexport type { WebTabBarConfig, WebTabBarItem } from '../../../shared/tabBar'\n"],"mappings":";;;;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAI;AACJ,IAAI,cAAc;AAClB,IAAI,mBAAmB;AACvB,IAAI,mBAAmB;AACvB,IAAI;AACJ,IAAI,aAAgC,CAAC;AACrC,MAAM,4BAAY,IAAI,IAAiB;AAEvC,SAAS,gBAAgB,OAA2B;CAClD,IAAI,CAAC,SAAS,kCAAkC,KAAK,KAAK,GACxD,OAAO;CAET,OAAO,IAAI,MAAM,QAAQ,SAAS,EAAE;AACtC;AAEA,SAAS,wBAAwB;CAC/B,OAAO,QACL,gBACG,CAAC,aAAa,UACd,oBACA,aAAa,KAAK,MAAK,SAAQ,KAAK,aAAa,WAAW,CACjE;AACF;AAEA,SA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AAM,KAAK;CACzB,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,kBAAkB,OAAsG;CACtI,IAAI,CAAC,cACH,OAAO;CAET,OAAO,OAAO,cAAc,KAAK;CACjC,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAAe,OAA2B;CAC5E,IAAI,CAAC,YAAY,KAAK,GACpB,OAAO;CAET,WAAW,SAAS;EAAE;EAAO,QAAQ;CAAM;CAC3C,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,qBAAqB,OAAe,QAAiB;CACnE,IAAI,CAAC,YAAY,KAAK,GACpB,OAAO;CAET,WAAW,SAAS;EAAE;EAAQ,OAAO;CAAU;CAC/C,gBAAgB;CAChB,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["#ensureStructure","#applyState","#bindEvents","#clearHoverTimers","#observer","#button","#content","#text","#loading","#handleClickCapture","#handleClick","#handlePressStart","#handlePressEnd","#lastTouchTime","#hoverTimer","#hoverRemoveTimer"],"sources":["../../../src/runtime/button/index.ts"],"sourcesContent":["import type { FormConfig } from '../nativeComponents/form'\nimport { setFormConfig } from '../nativeComponents/form'\nimport { requestContainingFormAction } from '../nativeComponents/formControl'\nimport {\n DEFAULT_HOVER_START,\n DEFAULT_HOVER_STAY,\n getHoverClass,\n isDisabled,\n isInternalNode,\n normalizeType,\n parseNumber,\n toBoolean,\n} from './helpers'\nimport { ensureButtonStyle } from './style'\n\nconst NAV_BUTTON_TAG = 'weapp-button'\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappButton extends BaseElement {\n static observedAttributes = [\n 'type',\n 'plain',\n 'size',\n 'loading',\n 'disabled',\n 'hover-class',\n 'hover-start-time',\n 'hover-stay-time',\n 'form-type',\n 'open-type',\n ]\n\n #button?: HTMLButtonElement\n #content?: HTMLSpanElement\n #text?: HTMLSpanElement\n #loading?: HTMLSpanElement\n #hoverTimer?: ReturnType<typeof globalThis.setTimeout>\n #hoverRemoveTimer?: ReturnType<typeof globalThis.setTimeout>\n #lastTouchTime = 0\n #observer?: MutationObserver\n\n connectedCallback() {\n const root = this.getRootNode()\n if (root instanceof ShadowRoot) {\n ensureButtonStyle(root)\n }\n else {\n ensureButtonStyle()\n }\n this.#ensureStructure()\n this.#applyState()\n this.#bindEvents()\n }\n\n disconnectedCallback() {\n this.#clearHoverTimers()\n this.#observer?.disconnect()\n this.#observer = undefined\n }\n\n attributeChangedCallback() {\n this.#applyState()\n }\n\n #ensureStructure() {\n if (this.#button) {\n return\n }\n const button = document.createElement('button')\n button.type = 'button'\n button.className = 'weapp-btn'\n button.dataset.weappInternal = 'true'\n const content = document.createElement('span')\n content.className = 'weapp-btn__content'\n content.dataset.weappInternal = 'true'\n const loading = document.createElement('span')\n loading.className = 'weapp-btn__loading'\n loading.dataset.weappInternal = 'true'\n loading.setAttribute('hidden', '')\n const text = document.createElement('span')\n text.className = 'weapp-btn__text'\n text.dataset.weappInternal = 'true'\n content.append(loading, text)\n button.append(content)\n\n const existing = [...this.childNodes].filter(node => !isInternalNode(node))\n for (const node of existing) {\n text.appendChild(node)\n }\n this.appendChild(button)\n\n this.#button = button\n this.#content = content\n this.#text = text\n this.#loading = loading\n\n if (typeof MutationObserver !== 'undefined') {\n this.#observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of [...record.addedNodes]) {\n if (isInternalNode(node)) {\n continue\n }\n this.#text!.appendChild(node)\n }\n }\n })\n this.#observer.observe(this, { childList: true })\n }\n }\n\n #applyState() {\n if (!this.#button || !this.#loading) {\n return\n }\n const type = normalizeType(this.getAttribute('type'))\n const plain = toBoolean(this.getAttribute('plain'))\n const size = (this.getAttribute('size') ?? 'default').toLowerCase()\n const loading = toBoolean(this.getAttribute('loading'))\n const disabled = toBoolean(this.getAttribute('disabled'))\n const openType = this.getAttribute('open-type')\n\n this.classList.toggle('weapp-btn--primary', type === 'primary')\n this.classList.toggle('weapp-btn--warn', type === 'warn')\n this.classList.toggle('weapp-btn--default', type === 'default')\n this.classList.toggle('weapp-btn--plain', plain)\n this.classList.toggle('weapp-btn--mini', size === 'mini')\n this.classList.toggle('weapp-btn--loading', loading)\n this.classList.toggle('weapp-btn--disabled', disabled)\n\n if (openType) {\n const openTypeClass = `weapp-btn--open-type-${openType}`\n for (const className of [...this.classList]) {\n if (className.startsWith('weapp-btn--open-type-') && className !== openTypeClass) {\n this.classList.remove(className)\n }\n }\n this.classList.add(openTypeClass)\n }\n else {\n for (const className of [...this.classList]) {\n if (className.startsWith('weapp-btn--open-type-')) {\n this.classList.remove(className)\n }\n }\n }\n\n const locked = disabled || loading\n this.#button.disabled = locked\n if (locked) {\n this.#button.setAttribute('aria-disabled', 'true')\n }\n else {\n this.#button.removeAttribute('aria-disabled')\n }\n this.#loading.toggleAttribute('hidden', !loading)\n }\n\n #bindEvents() {\n if ((this as any).__weappButtonBound) {\n return\n }\n ;(this as any).__weappButtonBound = true\n this.addEventListener('click', this.#handleClickCapture, true)\n this.addEventListener('click', this.#handleClick)\n this.addEventListener('touchstart', this.#handlePressStart, { passive: true })\n this.addEventListener('mousedown', this.#handlePressStart)\n this.addEventListener('touchend', this.#handlePressEnd)\n this.addEventListener('touchcancel', this.#handlePressEnd)\n this.addEventListener('mouseup', this.#handlePressEnd)\n this.addEventListener('mouseleave', this.#handlePressEnd)\n }\n\n #handleClickCapture = (event: Event) => {\n if (isDisabled(this)) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n }\n\n #handleClick = (event: Event) => {\n const formType = this.getAttribute('form-type')\n if (!formType) {\n return\n }\n if ((formType === 'submit' || formType === 'reset') && requestContainingFormAction(this, formType)) {\n event.preventDefault()\n }\n }\n\n #handlePressStart = (event: Event) => {\n if (isDisabled(this)) {\n return\n }\n const hoverClass = getHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (event.type === 'touchstart') {\n this.#lastTouchTime = Date.now()\n }\n if (event.type === 'mousedown' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n const startTime = parseNumber(this.getAttribute('hover-start-time'), DEFAULT_HOVER_START)\n this.#clearHoverTimers()\n this.#hoverTimer = globalThis.setTimeout(() => {\n this.classList.add(hoverClass)\n }, startTime)\n }\n\n #handlePressEnd = (event: Event) => {\n const hoverClass = getHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (event.type === 'mouseup' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n const stayTime = parseNumber(this.getAttribute('hover-stay-time'), DEFAULT_HOVER_STAY)\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.classList.contains(hoverClass)) {\n this.#hoverRemoveTimer = globalThis.setTimeout(() => {\n this.classList.remove(hoverClass)\n }, stayTime)\n }\n }\n\n #clearHoverTimers() {\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.#hoverRemoveTimer) {\n clearTimeout(this.#hoverRemoveTimer)\n this.#hoverRemoveTimer = undefined\n }\n }\n}\n\nexport function ensureButtonDefined(): void {\n if (typeof customElements === 'undefined') {\n return\n }\n if (!customElements.get(NAV_BUTTON_TAG)) {\n customElements.define(NAV_BUTTON_TAG, WeappButton)\n }\n}\n\nexport function setButtonFormConfig(next: FormConfig): void {\n setFormConfig(next)\n}\n\nexport type ButtonFormConfig = FormConfig\n"],"mappings":";;;;;;AAeA,MAAM,iBAAiB;AACvB,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA;CACA;CACA;CACA;CACA;CACA;CACA,iBAAiB;CACjB;CAEA,oBAAoB;EAClB,MAAM,OAAO,KAAK,YAAY;EAC9B,IAAI,gBAAgB,YAClB,kBAAkB,IAAI;OAGtB,kBAAkB;EAEpB,KAAKA,iBAAiB;EACtB,KAAKC,YAA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B,KAAKA,cAAc;EACrB;EACA,IAAI,KAAK,UAAU,SAAS,UAAU,GACpC,KAAKC,oBAAoB,WAAW,iBAAiB;GACnD,KAAK,UAAU,OAAO,UAAU;EAClC,GAAG,QAAQ;CAEf;CAEA,oBAAoB;EAClB,IAAI,KAAKD,aAAa;GACpB,aAAa,KAAKA,WAAW;GAC7B,KAAKA,cAAc;EACrB;EACA,IAAI,KAAKC,mBAAmB;GAC1B,aAAa,KAAKA,iBAAiB;GACnC,KAAKA,oBAAoB;EAC3B;CACF;AACF;AAEA,SAAgB,sBAA4B;CAC1C,IAAI,OAAO,mBAAmB,aAC5B;CAEF,IAAI,CAAC,eAAe,IAAI,cAAc,GACpC,eAAe,OAAO,gBAAgB,WAAW;AAErD;AAEA,SAAgB,oBAAoB,MAAwB;CAC1D,cAAc,IAAI;AACpB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/runtime/button/index.ts"],"sourcesContent":["import type { FormConfig } from '../nativeComponents/form'\nimport { setFormConfig } from '../nativeComponents/form'\nimport { requestContainingFormAction } from '../nativeComponents/formControl'\nimport {\n DEFAULT_HOVER_START,\n DEFAULT_HOVER_STAY,\n getHoverClass,\n isDisabled,\n isInternalNode,\n normalizeType,\n parseNumber,\n toBoolean,\n} from './helpers'\nimport { ensureButtonStyle } from './style'\n\nconst NAV_BUTTON_TAG = 'weapp-button'\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappButton extends BaseElement {\n static observedAttributes = [\n 'type',\n 'plain',\n 'size',\n 'loading',\n 'disabled',\n 'hover-class',\n 'hover-start-time',\n 'hover-stay-time',\n 'form-type',\n 'open-type',\n ]\n\n #button?: HTMLButtonElement\n #content?: HTMLSpanElement\n #text?: HTMLSpanElement\n #loading?: HTMLSpanElement\n #hoverTimer?: ReturnType<typeof globalThis.setTimeout>\n #hoverRemoveTimer?: ReturnType<typeof globalThis.setTimeout>\n #lastTouchTime = 0\n #observer?: MutationObserver\n\n connectedCallback() {\n const root = this.getRootNode()\n if (root instanceof ShadowRoot) {\n ensureButtonStyle(root)\n }\n else {\n ensureButtonStyle()\n }\n this.#ensureStructure()\n this.#applyState()\n this.#bindEvents()\n }\n\n disconnectedCallback() {\n this.#clearHoverTimers()\n this.#observer?.disconnect()\n this.#observer = undefined\n }\n\n attributeChangedCallback() {\n this.#applyState()\n }\n\n #ensureStructure() {\n if (this.#button) {\n return\n }\n const button = document.createElement('button')\n button.type = 'button'\n button.className = 'weapp-btn'\n button.dataset.weappInternal = 'true'\n const content = document.createElement('span')\n content.className = 'weapp-btn__content'\n content.dataset.weappInternal = 'true'\n const loading = document.createElement('span')\n loading.className = 'weapp-btn__loading'\n loading.dataset.weappInternal = 'true'\n loading.setAttribute('hidden', '')\n const text = document.createElement('span')\n text.className = 'weapp-btn__text'\n text.dataset.weappInternal = 'true'\n content.append(loading, text)\n button.append(content)\n\n const existing = [...this.childNodes].filter(node => !isInternalNode(node))\n for (const node of existing) {\n text.appendChild(node)\n }\n this.appendChild(button)\n\n this.#button = button\n this.#content = content\n this.#text = text\n this.#loading = loading\n\n if (typeof MutationObserver !== 'undefined') {\n this.#observer = new MutationObserver((records) => {\n for (const record of records) {\n for (const node of [...record.addedNodes]) {\n if (isInternalNode(node)) {\n continue\n }\n this.#text!.appendChild(node)\n }\n }\n })\n this.#observer.observe(this, { childList: true })\n }\n }\n\n #applyState() {\n if (!this.#button || !this.#loading) {\n return\n }\n const type = normalizeType(this.getAttribute('type'))\n const plain = toBoolean(this.getAttribute('plain'))\n const size = (this.getAttribute('size') ?? 'default').toLowerCase()\n const loading = toBoolean(this.getAttribute('loading'))\n const disabled = toBoolean(this.getAttribute('disabled'))\n const openType = this.getAttribute('open-type')\n\n this.classList.toggle('weapp-btn--primary', type === 'primary')\n this.classList.toggle('weapp-btn--warn', type === 'warn')\n this.classList.toggle('weapp-btn--default', type === 'default')\n this.classList.toggle('weapp-btn--plain', plain)\n this.classList.toggle('weapp-btn--mini', size === 'mini')\n this.classList.toggle('weapp-btn--loading', loading)\n this.classList.toggle('weapp-btn--disabled', disabled)\n\n if (openType) {\n const openTypeClass = `weapp-btn--open-type-${openType}`\n for (const className of [...this.classList]) {\n if (className.startsWith('weapp-btn--open-type-') && className !== openTypeClass) {\n this.classList.remove(className)\n }\n }\n this.classList.add(openTypeClass)\n }\n else {\n for (const className of [...this.classList]) {\n if (className.startsWith('weapp-btn--open-type-')) {\n this.classList.remove(className)\n }\n }\n }\n\n const locked = disabled || loading\n this.#button.disabled = locked\n if (locked) {\n this.#button.setAttribute('aria-disabled', 'true')\n }\n else {\n this.#button.removeAttribute('aria-disabled')\n }\n this.#loading.toggleAttribute('hidden', !loading)\n }\n\n #bindEvents() {\n if ((this as any).__weappButtonBound) {\n return\n }\n ;(this as any).__weappButtonBound = true\n this.addEventListener('click', this.#handleClickCapture, true)\n this.addEventListener('click', this.#handleClick)\n this.addEventListener('touchstart', this.#handlePressStart, { passive: true })\n this.addEventListener('mousedown', this.#handlePressStart)\n this.addEventListener('touchend', this.#handlePressEnd)\n this.addEventListener('touchcancel', this.#handlePressEnd)\n this.addEventListener('mouseup', this.#handlePressEnd)\n this.addEventListener('mouseleave', this.#handlePressEnd)\n }\n\n #handleClickCapture = (event: Event) => {\n if (isDisabled(this)) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n }\n\n #handleClick = (event: Event) => {\n const formType = this.getAttribute('form-type')\n if (!formType) {\n return\n }\n if ((formType === 'submit' || formType === 'reset') && requestContainingFormAction(this, formType)) {\n event.preventDefault()\n }\n }\n\n #handlePressStart = (event: Event) => {\n if (isDisabled(this)) {\n return\n }\n const hoverClass = getHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (event.type === 'touchstart') {\n this.#lastTouchTime = Date.now()\n }\n if (event.type === 'mousedown' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n const startTime = parseNumber(this.getAttribute('hover-start-time'), DEFAULT_HOVER_START)\n this.#clearHoverTimers()\n this.#hoverTimer = globalThis.setTimeout(() => {\n this.classList.add(hoverClass)\n }, startTime)\n }\n\n #handlePressEnd = (event: Event) => {\n const hoverClass = getHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (event.type === 'mouseup' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n const stayTime = parseNumber(this.getAttribute('hover-stay-time'), DEFAULT_HOVER_STAY)\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.classList.contains(hoverClass)) {\n this.#hoverRemoveTimer = globalThis.setTimeout(() => {\n this.classList.remove(hoverClass)\n }, stayTime)\n }\n }\n\n #clearHoverTimers() {\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.#hoverRemoveTimer) {\n clearTimeout(this.#hoverRemoveTimer)\n this.#hoverRemoveTimer = undefined\n }\n }\n}\n\nexport function ensureButtonDefined(): void {\n if (typeof customElements === 'undefined') {\n return\n }\n if (!customElements.get(NAV_BUTTON_TAG)) {\n customElements.define(NAV_BUTTON_TAG, WeappButton)\n }\n}\n\nexport function setButtonFormConfig(next: FormConfig): void {\n setFormConfig(next)\n}\n\nexport type ButtonFormConfig = FormConfig\n"],"mappings":";;;;;;AAeA,MAAM,iBAAiB;AACvB,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB;EAC1B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA;CACA;CACA;CACA;CACA;CACA;CACA,iBAAiB;CACjB;CAEA,oBAAoB;EAClB,MAAM,OAAO,KAAK,YAAY;EAC9B,IAAI,gBAAgB,YAClB,kBAAkB,IAAI;OAGtB,kBAAkB;EAEpB,KAAK,iBAAiB;EACtB,KAAK,YAAY;EACjB,KAAK,YAAY;CACnB;CAEA,uBAAuB;EACrB,KAAK,kBAAkB;EACvB,KAAK,WAAW,WAAW;EAC3B,KAAK,Y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Ef;CAEA,oBAAoB;EAClB,IAAI,KAAK,aAAa;GACpB,aAAa,KAAK,WAAW;GAC7B,KAAK,cAAc;EACrB;EACA,IAAI,KAAK,mBAAmB;GAC1B,aAAa,KAAK,iBAAiB;GACnC,KAAK,oBAAoB;EAC3B;CACF;AACF;AAEA,SAAgB,sBAA4B;CAC1C,IAAI,OAAO,mBAAmB,aAC5B;CAEF,IAAI,CAAC,eAAe,IAAI,cAAc,GACpC,eAAe,OAAO,gBAAgB,WAAW;AAErD;AAEA,SAAgB,oBAAoB,MAAwB;CAC1D,cAAc,IAAI;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.mjs","names":["#properties","#state","#publicInstance","#methods","#setProperty","#syncMethods","#applyDataPatch","#applyAttributes","#runInitialObservers","#isMounted","#renderLegacy","#readyFired","#syncVirtualHostClasses","#usesLegacyTemplate","#renderContext","#observedKeys","#observerInitDone","#exposedMethodNames","#virtualHostClassTokens","#virtualHostRootElement","#virtualHostPartTokens"],"sources":["../../../src/runtime/component/element.ts"],"sourcesContent":["import type {\n CreateComponentElementClassOptions,\n WeappComponentInstance,\n} from './elementTypes'\nimport type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n PageLifeTimeHooks,\n TriggerEventOptions,\n} from './types'\nimport type { ClassAttributeElement } from './virtualHost'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { createIntersectionObserverBridge } from '../polyfill/intersectionObserver'\nimport { createRenderContext } from '../renderContext'\nimport { hasOwn } from '../utils/object'\nimport { supportsLit } from './constants'\nimport {\n createScopedSelectorQuery,\n resolveRenderRoot,\n selectRuntimeComponent,\n selectRuntimeComponents,\n} from './dom'\nimport { bindRuntimeEvents } from './events'\nimport { runComponentObservers } from './observers'\nimport { createComponentPublicInstance } from './publicInstance'\nimport { resolveRelationNodes } from './relations'\nimport { createWebSlotsProxy } from './slots'\nimport { assignDataPath, cloneValue, coerceValue, parseDataPath, resolveDataPath, toCamelCase } from './utils'\nimport {\n clearVirtualHostClasses,\n clearVirtualHostParts,\n syncVirtualHostClasses,\n syncVirtualHostParts,\n} from './virtualHost'\n\nexport type { WeappComponentInstance } from './elementTypes'\nexport type WeappComponentElementClass = typeof HTMLElement & {\n new (): WeappComponentInstance\n}\n\nfunction resolveComposedParent(node: Node): Node | undefined {\n const assignedSlot = (node as Element).assignedSlot\n if (assignedSlot) {\n return assignedSlot\n }\n if (node.parentNode) {\n return node.parentNode\n }\n const root = node.getRootNode?.()\n return root instanceof ShadowRoot ? root.host : undefined\n}\n\nfunction isWeappComponentInstance(value: unknown): value is WeappComponentInstance {\n return Boolean(\n value\n && typeof value === 'object'\n && typeof (value as WeappComponentInstance).__weappSync === 'function',\n )\n}\n\nexport function createComponentElementClass({\n BaseElement,\n runtimeState,\n instances,\n}: CreateComponentElementClassOptions): WeappComponentElementClass {\n const RuntimeBaseElement = BaseElement as typeof HTMLElement & {\n readonly observedAttributes?: string[]\n }\n class WeappWebComponent extends RuntimeBaseElement implements WeappComponentInstance {\n static get observedAttributes() {\n const inherited = super.observedAttributes ?? []\n return Array.from(new Set([...inherited, ...runtimeState.observedAttributes]))\n }\n\n #state: DataRecord\n #properties: DataRecord\n #methods: Record<string, (event: any) => any> = {}\n #publicInstance: ComponentPublicInstance\n #exposedMethodNames = new Set<string>()\n #isMounted = false\n #renderContext = createRenderContext(this, {})\n #usesLegacyTemplate = false\n #readyFired = false\n #observerInitDone = false\n #observedKeys = new Set<string>()\n #virtualHostClassTokens = new Set<string>()\n #virtualHostPartTokens = new Set<string>()\n #virtualHostRootElement: ClassAttributeElement | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n const dataOption = runtimeState.componentRef.data ?? {}\n this.#properties = { ...runtimeState.defaultPropertyValues }\n this.#state = { ...cloneValue(this.#properties), ...cloneValue(dataOption) }\n Object.defineProperty(this.#state, '$slots', {\n configurable: true,\n enumerable: true,\n value: createWebSlotsProxy(() => this.#state.vueSlots),\n })\n Object.defineProperties(this, {\n data: {\n configurable: true,\n enumerable: true,\n get: () => this.#state,\n },\n properties: {\n configurable: true,\n enumerable: true,\n get: () => this.#properties,\n },\n })\n this.#publicInstance = createComponentPublicInstance(\n this,\n WeappWebComponent.prototype,\n key => typeof key === 'string' ? this.#methods[key] : undefined,\n )\n for (const [propName] of runtimeState.propertyEntries) {\n Object.defineProperty(this, propName, {\n configurable: true,\n enumerable: true,\n get: () => this.#state[propName],\n set: value => this.#setProperty(propName, value),\n })\n }\n this.#syncMethods(runtimeState.componentRef.methods ?? {})\n if (!supportsLit) {\n const host = this as unknown as HTMLElement\n if (!host.shadowRoot && typeof host.attachShadow === 'function') {\n host.attachShadow({ mode: 'open' })\n }\n ;(this as any).renderRoot = host.shadowRoot ?? host\n }\n instances.add(this)\n runtimeState.lifetimes.created?.call(this.#publicInstance)\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && changed) {\n const updateComplete = (this as unknown as { updateComplete: Promise<boolean> }).updateComplete\n return updateComplete.then(() => {\n callback?.()\n })\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n }))\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n createIntersectionObserver(options?: {\n initialRatio?: number\n observeAll?: boolean\n thresholds?: number[]\n }) {\n return createIntersectionObserverBridge(this, options)\n }\n\n selectComponent(selector: string) {\n return selectRuntimeComponent(this, selector)\n }\n\n selectAllComponents(selector: string) {\n return selectRuntimeComponents(this, selector)\n }\n\n getRelationNodes(relationPath: string) {\n const relation = runtimeState.componentRef.relations?.[relationPath]\n return relation\n ? resolveRelationNodes(this, runtimeState.id, relationPath, relation.type)\n : []\n }\n\n selectOwnerComponent() {\n let current = resolveComposedParent(this)\n while (current) {\n if (isWeappComponentInstance(current)) {\n return current\n }\n current = resolveComposedParent(current)\n }\n return undefined\n }\n\n connectedCallback() {\n const superConnected = (BaseElement.prototype as { connectedCallback?: () => void }).connectedCallback\n if (supportsLit && typeof superConnected === 'function') {\n superConnected.call(this)\n }\n this.#applyAttributes()\n if (runtimeState.observerInitEnabled) {\n this.#runInitialObservers()\n }\n runtimeState.lifetimes.attached?.call(this.#publicInstance)\n this.#isMounted = true\n if (!supportsLit) {\n this.#renderLegacy()\n }\n }\n\n disconnectedCallback() {\n const superDisconnected = (BaseElement.prototype as { disconnectedCallback?: () => void }).disconnectedCallback\n if (supportsLit && typeof superDisconnected === 'function') {\n superDisconnected.call(this)\n }\n this.#isMounted = false\n instances.delete(this)\n runtimeState.lifetimes.detached?.call(this.#publicInstance)\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n const superAttributeChanged = (BaseElement.prototype as {\n attributeChangedCallback?: (name: string, oldValue: string | null, newValue: string | null) => void\n }).attributeChangedCallback\n if (supportsLit && typeof superAttributeChanged === 'function') {\n superAttributeChanged.call(this, attrName, oldValue, newValue)\n }\n const propName = toCamelCase(attrName)\n if (!hasOwn(this.#properties, propName)) {\n return\n }\n const propOption = runtimeState.componentRef.properties?.[propName]\n this.#setProperty(propName, coerceValue(newValue, propOption?.type))\n }\n\n firstUpdated() {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n\n updated() {\n this.#syncVirtualHostClasses()\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const styleMarkup = runtimeState.styleRef\n ? html`<style>${runtimeState.styleRef}</style>`\n : null\n if (typeof result === 'string') {\n this.#usesLegacyTemplate = true\n return html`${styleMarkup}${unsafeHTML(result)}`\n }\n this.#usesLegacyTemplate = false\n if (styleMarkup) {\n return html`${styleMarkup}${result as any}`\n }\n return result\n }\n\n requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: unknown) {\n const superRequestUpdate = (BaseElement.prototype as any).requestUpdate\n if (supportsLit && typeof superRequestUpdate === 'function') {\n return superRequestUpdate.call(this, name, oldValue, options)\n }\n if (this.#isMounted) {\n this.#renderLegacy()\n }\n return undefined\n }\n\n #applyAttributes() {\n if (!this.attributes || typeof this.attributes[Symbol.iterator] !== 'function') {\n return\n }\n for (const attr of this.attributes) {\n this.attributeChangedCallback(attr.name, null, attr.value)\n }\n }\n\n #applyDataPatch(patch: DataRecord) {\n if (!patch || typeof patch !== 'object') {\n return false\n }\n let changed = false\n const changedKeys: string[] = []\n const previousProperties: DataRecord = {}\n for (const [path, value] of Object.entries(patch)) {\n const segments = parseDataPath(path)\n const topKey = segments[0]\n if (!topKey || Object.is(resolveDataPath(this.#state, segments), value)) {\n continue\n }\n if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) {\n previousProperties[topKey] = this.#properties[topKey]\n }\n assignDataPath(this.#state, segments, value)\n if (hasOwn(this.#properties, topKey)) {\n this.#properties[topKey] = this.#state[topKey]\n }\n changedKeys.push(path)\n changed = true\n }\n if (changed) {\n this.requestUpdate()\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, changedKeys, previousProperties)\n for (const key of changedKeys) {\n if (runtimeState.componentRef.properties?.[key]?.observer) {\n this.#observedKeys.add(key)\n }\n }\n }\n return changed\n }\n\n #setProperty(name: string, value: any) {\n const propOption = runtimeState.componentRef.properties?.[name]\n const coerced = coerceValue(value, propOption?.type)\n const oldValue = this.#properties[name]\n if (oldValue === coerced) {\n return\n }\n this.#properties[name] = coerced\n this.#state[name] = coerced\n if (this.#isMounted) {\n this.requestUpdate()\n }\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, [name], { [name]: oldValue })\n if (propOption?.observer) {\n this.#observedKeys.add(name)\n }\n }\n\n #runInitialObservers() {\n if (this.#observerInitDone) {\n return\n }\n this.#observerInitDone = true\n for (const [propName, propOption] of runtimeState.propertyEntries) {\n if (!propOption.observer || this.#observedKeys.has(propName)) {\n continue\n }\n const value = this.#state[propName]\n propOption.observer.call(this.#publicInstance, value, undefined)\n this.#observedKeys.add(propName)\n }\n }\n\n #syncMethods(nextMethods: ComponentOptions['methods']) {\n const resolved = nextMethods ?? {}\n const bound: Record<string, (event: any) => any> = {}\n for (const [name, fn] of Object.entries(resolved)) {\n if (typeof fn === 'function') {\n bound[name] = fn.bind(this.#publicInstance)\n }\n }\n for (const name of this.#exposedMethodNames) {\n if (name in bound) {\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(this, name)\n if (descriptor?.configurable && descriptor.value === this.#methods[name]) {\n delete (this as unknown as Record<string, unknown>)[name]\n }\n this.#exposedMethodNames.delete(name)\n }\n for (const key of Object.keys(this.#methods)) {\n if (!(key in bound)) {\n delete this.#methods[key]\n }\n }\n for (const [key, fn] of Object.entries(bound)) {\n this.#methods[key] = fn\n if (!this.#exposedMethodNames.has(key) && key in this) {\n continue\n }\n Object.defineProperty(this, key, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: fn,\n })\n this.#exposedMethodNames.add(key)\n }\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n this.requestUpdate()\n }\n\n __weappInvokePageLifetime(type: keyof PageLifeTimeHooks) {\n const hook = runtimeState.pageLifetimes[type]\n if (typeof hook === 'function') {\n hook.call(this.#publicInstance)\n }\n }\n\n #renderLegacy() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const styleMarkup = runtimeState.styleRef ? `<style>${runtimeState.styleRef}</style>` : ''\n if (typeof result === 'string') {\n root.innerHTML = `${styleMarkup}${result}`\n bindRuntimeEvents(root as ShadowRoot, this.#methods, this)\n }\n else if (result == null) {\n root.innerHTML = styleMarkup\n }\n else {\n root.innerHTML = `${styleMarkup}${String(result)}`\n }\n this.#syncVirtualHostClasses()\n if (!this.#readyFired) {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n }\n\n #syncVirtualHostClasses() {\n const host = this as unknown as ClassAttributeElement\n if (!runtimeState.componentRef.options?.virtualHost) {\n clearVirtualHostClasses(host, this.#virtualHostClassTokens)\n clearVirtualHostParts(this.#virtualHostRootElement, this.#virtualHostPartTokens)\n this.#virtualHostRootElement = undefined\n return\n }\n const root = resolveRenderRoot(this)\n syncVirtualHostClasses(host, root, this.#virtualHostClassTokens)\n this.#virtualHostRootElement = syncVirtualHostParts(\n root,\n this.#virtualHostRootElement,\n this.#virtualHostPartTokens,\n )\n }\n }\n\n return WeappWebComponent as WeappComponentElementClass\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,SAAS,sBAAsB,MAA8B;CAC3D,MAAM,eAAgB,KAAiB;CACvC,IAAI,cACF,OAAO;CAET,IAAI,KAAK,YACP,OAAO,KAAK;CAEd,MAAM,OAAO,KAAK,cAAc;CAChC,OAAO,gBAAgB,aAAa,KAAK,OAAO;AAClD;AAEA,SAAS,yBAAyB,OAAiD;CACjF,OAAO,QACL,SACG,OAAO,UAAU,YACjB,OAAQ,MAAiC,gBAAgB,UAC9D;AACF;AAEA,SAAgB,4BAA4B,EAC1C,aACA,cACA,aACiE;CACjE,MAAM,qBAAqB;CAG3B,MAAM,0BAA0B,mBAAqD;EACnF,WAAW,qBAAqB;GAC9B,MAAM,YAAY,MAAM,sBAAsB,CAAC;GAC/C,OAAO,MAAM,qBAAK,IAAI,IAAI,CAAC,GAAG,WAAW,GAAG,aAAa,kBAAkB,CAAC,CAAC;EAC/E;EAEA;EACA;EACA,WAAgD,CAAC;EACjD;EACA,sCAAsB,IAAI,IAAY;EACtC,aAAa;EACb,iBAAiB,oBAAoB,MAAM,CAAC,CAAC;EAC7C,sBAAsB;EACtB,cAAc;EACd,oBAAoB;EACpB,gCAAgB,IAAI,IAAY;EAChC,0CAA0B,IAAI,IAAY;EAC1C,yCAAyB,IAAI,IAAY;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,YAAY,KAAKD,QAAQ,KAAKa,cAAc;GACxE,MAAM,OAAO,kBAAkB,IAAI;GACnC,MAAM,cAAc,aAAa,WAAW,UAAU,aAAa,SAAS,YAAY;GACxF,IAAI,OAAO,WAAW,UAAU;IAC9B,KAAK,YAAY,GAAG,cAAc;IAClC,kBAAkB,MAAoB,KAAKX,UAAU,IAAI;GAC3D,OACK,IAAI,UAAU,MACjB,KAAK,YAAY;QAGjB,KAAK,YAAY,GAAG,cAAc,OAAO,MAAM;GAEjD,KAAKS,wBAAwB;GAC7B,IAAI,CAAC,KAAKD,aAAa;IACrB,aAAa,UAAU,OAAO,KAAK,KAAKT,eAAe;IACvD,KAAKS,cAAc;GACrB;EACF;EAEA,0BAA0B;GACxB,MAAM,OAAO;GACb,IAAI,CAAC,aAAa,aAAa,SAAS,aAAa;IACnD,wBAAwB,MAAM,KAAKO,uBAAuB;IAC1D,sBAAsB,KAAKC,yBAAyB,KAAKC,sBAAsB;IAC/E,KAAKD,0BAA0B;IAC/B;GACF;GACA,MAAM,OAAO,kBAAkB,IAAI;GACnC,uBAAuB,MAAM,MAAM,KAAKD,uBAAuB;GAC/D,KAAKC,0BAA0B,qBAC7B,MACA,KAAKA,yBACL,KAAKC,sBACP;EACF;CACF;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"element.mjs","names":[],"sources":["../../../src/runtime/component/element.ts"],"sourcesContent":["import type {\n CreateComponentElementClassOptions,\n WeappComponentInstance,\n} from './elementTypes'\nimport type {\n ComponentOptions,\n ComponentPublicInstance,\n DataRecord,\n PageLifeTimeHooks,\n TriggerEventOptions,\n} from './types'\nimport type { ClassAttributeElement } from './virtualHost'\nimport { html } from 'lit'\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js'\nimport { createIntersectionObserverBridge } from '../polyfill/intersectionObserver'\nimport { createRenderContext } from '../renderContext'\nimport { hasOwn } from '../utils/object'\nimport { supportsLit } from './constants'\nimport {\n createScopedSelectorQuery,\n resolveRenderRoot,\n selectRuntimeComponent,\n selectRuntimeComponents,\n} from './dom'\nimport { bindRuntimeEvents } from './events'\nimport { runComponentObservers } from './observers'\nimport { createComponentPublicInstance } from './publicInstance'\nimport { resolveRelationNodes } from './relations'\nimport { createWebSlotsProxy } from './slots'\nimport { assignDataPath, cloneValue, coerceValue, parseDataPath, resolveDataPath, toCamelCase } from './utils'\nimport {\n clearVirtualHostClasses,\n clearVirtualHostParts,\n syncVirtualHostClasses,\n syncVirtualHostParts,\n} from './virtualHost'\n\nexport type { WeappComponentInstance } from './elementTypes'\nexport type WeappComponentElementClass = typeof HTMLElement & {\n new (): WeappComponentInstance\n}\n\nfunction resolveComposedParent(node: Node): Node | undefined {\n const assignedSlot = (node as Element).assignedSlot\n if (assignedSlot) {\n return assignedSlot\n }\n if (node.parentNode) {\n return node.parentNode\n }\n const root = node.getRootNode?.()\n return root instanceof ShadowRoot ? root.host : undefined\n}\n\nfunction isWeappComponentInstance(value: unknown): value is WeappComponentInstance {\n return Boolean(\n value\n && typeof value === 'object'\n && typeof (value as WeappComponentInstance).__weappSync === 'function',\n )\n}\n\nexport function createComponentElementClass({\n BaseElement,\n runtimeState,\n instances,\n}: CreateComponentElementClassOptions): WeappComponentElementClass {\n const RuntimeBaseElement = BaseElement as typeof HTMLElement & {\n readonly observedAttributes?: string[]\n }\n class WeappWebComponent extends RuntimeBaseElement implements WeappComponentInstance {\n static get observedAttributes() {\n const inherited = super.observedAttributes ?? []\n return Array.from(new Set([...inherited, ...runtimeState.observedAttributes]))\n }\n\n #state: DataRecord\n #properties: DataRecord\n #methods: Record<string, (event: any) => any> = {}\n #publicInstance: ComponentPublicInstance\n #exposedMethodNames = new Set<string>()\n #isMounted = false\n #renderContext = createRenderContext(this, {})\n #usesLegacyTemplate = false\n #readyFired = false\n #observerInitDone = false\n #observedKeys = new Set<string>()\n #virtualHostClassTokens = new Set<string>()\n #virtualHostPartTokens = new Set<string>()\n #virtualHostRootElement: ClassAttributeElement | undefined\n readonly data!: DataRecord\n readonly properties!: DataRecord\n\n constructor() {\n super()\n const dataOption = runtimeState.componentRef.data ?? {}\n this.#properties = { ...runtimeState.defaultPropertyValues }\n this.#state = { ...cloneValue(this.#properties), ...cloneValue(dataOption) }\n Object.defineProperty(this.#state, '$slots', {\n configurable: true,\n enumerable: true,\n value: createWebSlotsProxy(() => this.#state.vueSlots),\n })\n Object.defineProperties(this, {\n data: {\n configurable: true,\n enumerable: true,\n get: () => this.#state,\n },\n properties: {\n configurable: true,\n enumerable: true,\n get: () => this.#properties,\n },\n })\n this.#publicInstance = createComponentPublicInstance(\n this,\n WeappWebComponent.prototype,\n key => typeof key === 'string' ? this.#methods[key] : undefined,\n )\n for (const [propName] of runtimeState.propertyEntries) {\n Object.defineProperty(this, propName, {\n configurable: true,\n enumerable: true,\n get: () => this.#state[propName],\n set: value => this.#setProperty(propName, value),\n })\n }\n this.#syncMethods(runtimeState.componentRef.methods ?? {})\n if (!supportsLit) {\n const host = this as unknown as HTMLElement\n if (!host.shadowRoot && typeof host.attachShadow === 'function') {\n host.attachShadow({ mode: 'open' })\n }\n ;(this as any).renderRoot = host.shadowRoot ?? host\n }\n instances.add(this)\n runtimeState.lifetimes.created?.call(this.#publicInstance)\n }\n\n setData(patch: DataRecord, callback?: () => void) {\n const changed = this.#applyDataPatch(patch)\n if (supportsLit && changed) {\n const updateComplete = (this as unknown as { updateComplete: Promise<boolean> }).updateComplete\n return updateComplete.then(() => {\n callback?.()\n })\n }\n callback?.()\n }\n\n triggerEvent(name: string, detail?: any, options: TriggerEventOptions = {}) {\n this.dispatchEvent(new CustomEvent(name, {\n detail,\n bubbles: options.bubbles ?? false,\n composed: options.composed ?? false,\n }))\n }\n\n createSelectorQuery() {\n return createScopedSelectorQuery(this)\n }\n\n createIntersectionObserver(options?: {\n initialRatio?: number\n observeAll?: boolean\n thresholds?: number[]\n }) {\n return createIntersectionObserverBridge(this, options)\n }\n\n selectComponent(selector: string) {\n return selectRuntimeComponent(this, selector)\n }\n\n selectAllComponents(selector: string) {\n return selectRuntimeComponents(this, selector)\n }\n\n getRelationNodes(relationPath: string) {\n const relation = runtimeState.componentRef.relations?.[relationPath]\n return relation\n ? resolveRelationNodes(this, runtimeState.id, relationPath, relation.type)\n : []\n }\n\n selectOwnerComponent() {\n let current = resolveComposedParent(this)\n while (current) {\n if (isWeappComponentInstance(current)) {\n return current\n }\n current = resolveComposedParent(current)\n }\n return undefined\n }\n\n connectedCallback() {\n const superConnected = (BaseElement.prototype as { connectedCallback?: () => void }).connectedCallback\n if (supportsLit && typeof superConnected === 'function') {\n superConnected.call(this)\n }\n this.#applyAttributes()\n if (runtimeState.observerInitEnabled) {\n this.#runInitialObservers()\n }\n runtimeState.lifetimes.attached?.call(this.#publicInstance)\n this.#isMounted = true\n if (!supportsLit) {\n this.#renderLegacy()\n }\n }\n\n disconnectedCallback() {\n const superDisconnected = (BaseElement.prototype as { disconnectedCallback?: () => void }).disconnectedCallback\n if (supportsLit && typeof superDisconnected === 'function') {\n superDisconnected.call(this)\n }\n this.#isMounted = false\n instances.delete(this)\n runtimeState.lifetimes.detached?.call(this.#publicInstance)\n }\n\n attributeChangedCallback(attrName: string, oldValue: string | null, newValue: string | null) {\n const superAttributeChanged = (BaseElement.prototype as {\n attributeChangedCallback?: (name: string, oldValue: string | null, newValue: string | null) => void\n }).attributeChangedCallback\n if (supportsLit && typeof superAttributeChanged === 'function') {\n superAttributeChanged.call(this, attrName, oldValue, newValue)\n }\n const propName = toCamelCase(attrName)\n if (!hasOwn(this.#properties, propName)) {\n return\n }\n const propOption = runtimeState.componentRef.properties?.[propName]\n this.#setProperty(propName, coerceValue(newValue, propOption?.type))\n }\n\n firstUpdated() {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n\n updated() {\n this.#syncVirtualHostClasses()\n if (this.#usesLegacyTemplate) {\n bindRuntimeEvents(resolveRenderRoot(this), this.#methods, this)\n }\n }\n\n render() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const styleMarkup = runtimeState.styleRef\n ? html`<style>${runtimeState.styleRef}</style>`\n : null\n if (typeof result === 'string') {\n this.#usesLegacyTemplate = true\n return html`${styleMarkup}${unsafeHTML(result)}`\n }\n this.#usesLegacyTemplate = false\n if (styleMarkup) {\n return html`${styleMarkup}${result as any}`\n }\n return result\n }\n\n requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: unknown) {\n const superRequestUpdate = (BaseElement.prototype as any).requestUpdate\n if (supportsLit && typeof superRequestUpdate === 'function') {\n return superRequestUpdate.call(this, name, oldValue, options)\n }\n if (this.#isMounted) {\n this.#renderLegacy()\n }\n return undefined\n }\n\n #applyAttributes() {\n if (!this.attributes || typeof this.attributes[Symbol.iterator] !== 'function') {\n return\n }\n for (const attr of this.attributes) {\n this.attributeChangedCallback(attr.name, null, attr.value)\n }\n }\n\n #applyDataPatch(patch: DataRecord) {\n if (!patch || typeof patch !== 'object') {\n return false\n }\n let changed = false\n const changedKeys: string[] = []\n const previousProperties: DataRecord = {}\n for (const [path, value] of Object.entries(patch)) {\n const segments = parseDataPath(path)\n const topKey = segments[0]\n if (!topKey || Object.is(resolveDataPath(this.#state, segments), value)) {\n continue\n }\n if (hasOwn(this.#properties, topKey) && !hasOwn(previousProperties, topKey)) {\n previousProperties[topKey] = this.#properties[topKey]\n }\n assignDataPath(this.#state, segments, value)\n if (hasOwn(this.#properties, topKey)) {\n this.#properties[topKey] = this.#state[topKey]\n }\n changedKeys.push(path)\n changed = true\n }\n if (changed) {\n this.requestUpdate()\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, changedKeys, previousProperties)\n for (const key of changedKeys) {\n if (runtimeState.componentRef.properties?.[key]?.observer) {\n this.#observedKeys.add(key)\n }\n }\n }\n return changed\n }\n\n #setProperty(name: string, value: any) {\n const propOption = runtimeState.componentRef.properties?.[name]\n const coerced = coerceValue(value, propOption?.type)\n const oldValue = this.#properties[name]\n if (oldValue === coerced) {\n return\n }\n this.#properties[name] = coerced\n this.#state[name] = coerced\n if (this.#isMounted) {\n this.requestUpdate()\n }\n runComponentObservers(runtimeState.componentRef, this.#publicInstance, [name], { [name]: oldValue })\n if (propOption?.observer) {\n this.#observedKeys.add(name)\n }\n }\n\n #runInitialObservers() {\n if (this.#observerInitDone) {\n return\n }\n this.#observerInitDone = true\n for (const [propName, propOption] of runtimeState.propertyEntries) {\n if (!propOption.observer || this.#observedKeys.has(propName)) {\n continue\n }\n const value = this.#state[propName]\n propOption.observer.call(this.#publicInstance, value, undefined)\n this.#observedKeys.add(propName)\n }\n }\n\n #syncMethods(nextMethods: ComponentOptions['methods']) {\n const resolved = nextMethods ?? {}\n const bound: Record<string, (event: any) => any> = {}\n for (const [name, fn] of Object.entries(resolved)) {\n if (typeof fn === 'function') {\n bound[name] = fn.bind(this.#publicInstance)\n }\n }\n for (const name of this.#exposedMethodNames) {\n if (name in bound) {\n continue\n }\n const descriptor = Object.getOwnPropertyDescriptor(this, name)\n if (descriptor?.configurable && descriptor.value === this.#methods[name]) {\n delete (this as unknown as Record<string, unknown>)[name]\n }\n this.#exposedMethodNames.delete(name)\n }\n for (const key of Object.keys(this.#methods)) {\n if (!(key in bound)) {\n delete this.#methods[key]\n }\n }\n for (const [key, fn] of Object.entries(bound)) {\n this.#methods[key] = fn\n if (!this.#exposedMethodNames.has(key) && key in this) {\n continue\n }\n Object.defineProperty(this, key, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: fn,\n })\n this.#exposedMethodNames.add(key)\n }\n this.#renderContext = createRenderContext(this, this.#methods)\n }\n\n __weappSync(nextMethods: ComponentOptions['methods']) {\n this.#syncMethods(nextMethods)\n this.requestUpdate()\n }\n\n __weappInvokePageLifetime(type: keyof PageLifeTimeHooks) {\n const hook = runtimeState.pageLifetimes[type]\n if (typeof hook === 'function') {\n hook.call(this.#publicInstance)\n }\n }\n\n #renderLegacy() {\n const result = runtimeState.templateRef(this.#state, this.#renderContext)\n const root = resolveRenderRoot(this)\n const styleMarkup = runtimeState.styleRef ? `<style>${runtimeState.styleRef}</style>` : ''\n if (typeof result === 'string') {\n root.innerHTML = `${styleMarkup}${result}`\n bindRuntimeEvents(root as ShadowRoot, this.#methods, this)\n }\n else if (result == null) {\n root.innerHTML = styleMarkup\n }\n else {\n root.innerHTML = `${styleMarkup}${String(result)}`\n }\n this.#syncVirtualHostClasses()\n if (!this.#readyFired) {\n runtimeState.lifetimes.ready?.call(this.#publicInstance)\n this.#readyFired = true\n }\n }\n\n #syncVirtualHostClasses() {\n const host = this as unknown as ClassAttributeElement\n if (!runtimeState.componentRef.options?.virtualHost) {\n clearVirtualHostClasses(host, this.#virtualHostClassTokens)\n clearVirtualHostParts(this.#virtualHostRootElement, this.#virtualHostPartTokens)\n this.#virtualHostRootElement = undefined\n return\n }\n const root = resolveRenderRoot(this)\n syncVirtualHostClasses(host, root, this.#virtualHostClassTokens)\n this.#virtualHostRootElement = syncVirtualHostParts(\n root,\n this.#virtualHostRootElement,\n this.#virtualHostPartTokens,\n )\n }\n }\n\n return WeappWebComponent as WeappComponentElementClass\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0CA,SAAS,sBAAsB,MAA8B;CAC3D,MAAM,eAAgB,KAAiB;CACvC,IAAI,cACF,OAAO;CAET,IAAI,KAAK,YACP,OAAO,KAAK;CAEd,MAAM,OAAO,KAAK,cAAc;CAChC,OAAO,gBAAgB,aAAa,KAAK,OAAO;AAClD;AAEA,SAAS,yBAAyB,OAAiD;CACjF,OAAO,QACL,SACG,OAAO,UAAU,YACjB,OAAQ,MAAiC,gBAAgB,UAC9D;AACF;AAEA,SAAgB,4BAA4B,EAC1C,aACA,cACA,aACiE;CACjE,MAAM,qBAAqB;CAG3B,MAAM,0BAA0B,mBAAqD;EACnF,WAAW,qBAAqB;GAC9B,MAAM,YAAY,MAAM,sBAAsB,CAAC;GAC/C,OAAO,MAAM,qBAAK,IAAI,IAAI,CAAC,GAAG,WAAW,GAAG,aAAa,kBAAkB,CAAC,CAAC;EAC/E;EAEA;EACA;EACA,WAAgD,CAAC;EACj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M,OAAO,aAAa,cAAc;GACxC,IAAI,OAAO,SAAS,YAClB,KAAK,KAAK,KAAK,eAAe;EAElC;EAEA,gBAAgB;GACd,MAAM,SAAS,aAAa,YAAY,KAAK,QAAQ,KAAK,cAAc;GACxE,MAAM,OAAO,kBAAkB,IAAI;GACnC,MAAM,cAAc,aAAa,WAAW,UAAU,aAAa,SAAS,YAAY;GACxF,IAAI,OAAO,WAAW,UAAU;IAC9B,KAAK,YAAY,GAAG,cAAc;IAClC,kBAAkB,MAAoB,KAAK,UAAU,IAAI;GAC3D,OACK,IAAI,UAAU,MACjB,KAAK,YAAY;QAGjB,KAAK,YAAY,GAAG,cAAc,OAAO,MAAM;GAEjD,KAAK,wBAAwB;GAC7B,IAAI,CAAC,KAAK,aAAa;IACrB,aAAa,UAAU,OAAO,KAAK,KAAK,eAAe;IACvD,KAAK,cAAc;GACrB;EACF;EAEA,0BAA0B;GACxB,MAAM,OAAO;GACb,IAAI,CAAC,aAAa,aAAa,SAAS,aAAa;IACnD,wBAAwB,MAAM,KAAK,uBAAuB;IAC1D,sBAAsB,KAAK,yBAAyB,KAAK,sBAAsB;IAC/E,KAAK,0BAA0B;IAC/B;GACF;GACA,MAAM,OAAO,kBAAkB,IAAI;GACnC,uBAAuB,MAAM,MAAM,KAAK,uBAAuB;GAC/D,KAAK,0BAA0B,qBAC7B,MACA,KAAK,yBACL,KAAK,sBACP;EACF;CACF;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/canvas/index.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { registerNativeMediaElement, unregisterNativeMediaElement } from '../mediaRegistry'\nimport { ensureNativeComponentStyle } from '../style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nfunction resolveCanvasSize(value: string | null, fallback: number) {\n const size = Number(value)\n return Number.isInteger(size) && size > 0 ? size : fallback\n}\n\nexport class WeappCanvas extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('canvas')!.attributes]\n\n #canvas?: HTMLCanvasElement\n\n get canvasElement() {\n return this.#canvas\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n }\n\n disconnectedCallback() {\n if (this.#canvas) {\n unregisterNativeMediaElement(this.#canvas)\n }\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#canvas || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { position: relative; }\n canvas { display: block; }\n `\n const canvas = document.createElement('canvas')\n root.append(style, canvas)\n this.#canvas = canvas\n }\n\n #syncAttributes() {\n const canvas = this.#canvas\n if (!canvas) {\n return\n }\n canvas.width = resolveCanvasSize(this.getAttribute('width'), 300)\n canvas.height = resolveCanvasSize(this.getAttribute('height'), 150)\n canvas.style.touchAction = readBooleanAttribute(this, 'disable-scroll') ? 'none' : ''\n registerNativeMediaElement('canvas', [\n this.getAttribute('canvas-id'),\n this.getAttribute('id'),\n ], canvas)\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAS,kBAAkB,OAAsB,UAAkB;CACjE,MAAM,OAAO,OAAO,KAAK;CACzB,OAAO,OAAO,UAAU,IAAI,KAAK,OAAO,IAAI,OAAO;AACrD;AAEA,IAAa,cAAb,cAAiC,YAAY;CAC3C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,QAAQ,CAAC,CAAE,UAAU;CAElF;CAEA,IAAI,gBAAgB;EAClB,OAAO,KAAK;CACd;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAK,iBAAiB;EACtB,KAAK,gBAAgB;CACvB;CAEA,uBAAuB;EACrB,IAAI,KAAK,SACP,6BAA6B,KAAK,OAAO;CAE7C;CAEA,2BAA2B;EACzB,KAAK,gBAAgB;CACvB;CAEA,mBAAmB;EACjB,IAAI,KAAK,WAAW,OAAO,aAAa,aACtC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,cAAc;;;;EAIpB,MAAM,SAAS,SAAS,cAAc,QAAQ;EAC9C,KAAK,OAAO,OAAO,MAAM;EACzB,KAAK,UAAU;CACjB;CAEA,kBAAkB;EAChB,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QACH;EAEF,OAAO,QAAQ,kBAAkB,KAAK,aAAa,OAAO,GAAG,GAAG;EAChE,OAAO,SAAS,kBAAkB,KAAK,aAAa,QAAQ,GAAG,GAAG;EAClE,OAAO,MAAM,cAAc,qBAAqB,MAAM,gBAAgB,IAAI,SAAS;EACnF,2BAA2B,UAAU,CACnC,KAAK,aAAa,WAAW,GAC7B,KAAK,aAAa,IAAI,CACxB,GAAG,MAAM;CACX;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.mjs","names":[
|
|
1
|
+
{"version":3,"file":"checkbox.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/checkbox.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { connectFormControl, disconnectFormControl, findClosestComposedElement } from './formControl'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport function collectCheckboxGroupValue(checkboxes: ArrayLike<WeappCheckbox>) {\n return Array.from(checkboxes)\n .filter(checkbox => checkbox.checked && !checkbox.disabled)\n .map(checkbox => checkbox.value)\n}\n\nexport class WeappCheckboxGroup extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('checkbox-group')!.attributes]\n\n get formControlName() {\n return this.getAttribute('name') ?? ''\n }\n\n get formControlValue() {\n return collectCheckboxGroupValue(this.querySelectorAll<WeappCheckbox>('weapp-checkbox'))\n }\n\n get formControlDisabled() {\n return false\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n connectFormControl(this)\n }\n\n disconnectedCallback() {\n disconnectFormControl(this)\n }\n\n formReset() {\n for (const checkbox of this.querySelectorAll<WeappCheckbox>('weapp-checkbox')) {\n checkbox.formReset()\n }\n }\n\n notifyCheckboxChange() {\n dispatchMiniProgramEvent(this, 'change', { value: this.formControlValue })\n }\n}\n\nexport class WeappCheckbox extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('checkbox')!.attributes]\n\n #input?: HTMLInputElement\n #initialChecked = false\n #initialCheckedCaptured = false\n\n get value() {\n return this.getAttribute('value') ?? ''\n }\n\n set value(value: string) {\n this.setAttribute('value', value ?? '')\n }\n\n get checked() {\n return this.#input?.checked ?? readBooleanAttribute(this, 'checked')\n }\n\n set checked(value: boolean) {\n this.toggleAttribute('checked', Boolean(value))\n }\n\n get disabled() {\n return readBooleanAttribute(this, 'disabled')\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n if (!this.#initialCheckedCaptured) {\n this.#initialChecked = readBooleanAttribute(this, 'checked')\n this.#initialCheckedCaptured = true\n }\n this.#ensureStructure()\n this.#syncAttributes()\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n formReset() {\n this.setCheckedFromGroup(this.#initialChecked)\n }\n\n formActivate() {\n if (!this.disabled) {\n this.#input?.click()\n }\n }\n\n setCheckedFromGroup(checked: boolean) {\n if (this.#input) {\n this.#input.checked = checked\n }\n }\n\n #ensureStructure() {\n if (this.#input || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { --weapp-control-color: #07c160; }\n label { display: inline-flex; align-items: center; cursor: pointer; }\n input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }\n .control {\n position: relative;\n box-sizing: border-box;\n width: 23px;\n height: 23px;\n flex: 0 0 23px;\n border: 1px solid #d1d1d1;\n border-radius: 3px;\n background: #ffffff;\n }\n input:checked + .control { border-color: var(--weapp-control-color); background: var(--weapp-control-color); }\n input:checked + .control::after {\n position: absolute;\n top: 3px;\n left: 7px;\n width: 6px;\n height: 11px;\n border: solid #ffffff;\n border-width: 0 2px 2px 0;\n content: '';\n transform: rotate(45deg);\n }\n input:disabled + .control { border-color: #d8d8d8; background: #eeeeee; opacity: 0.7; }\n .content { margin-left: 8px; }\n `\n const label = document.createElement('label')\n const input = document.createElement('input')\n input.type = 'checkbox'\n const control = document.createElement('span')\n control.className = 'control'\n const content = document.createElement('span')\n content.className = 'content'\n content.append(document.createElement('slot'))\n input.addEventListener('change', (event) => {\n event.stopPropagation()\n const group = findClosestComposedElement(this, 'weapp-checkbox-group') as WeappCheckboxGroup | null\n group?.notifyCheckboxChange()\n })\n label.append(input, control, content)\n root.append(style, label)\n this.#input = input\n }\n\n #syncAttributes() {\n if (!this.#input) {\n return\n }\n this.#input.checked = readBooleanAttribute(this, 'checked')\n this.#input.disabled = this.disabled\n this.#input.value = this.value\n this.style.setProperty('--weapp-control-color', this.getAttribute('color') || '#07c160')\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAgB,0BAA0B,YAAsC;CAC9E,OAAO,MAAM,KAAK,UAAU,CAAC,CAC1B,QAAO,aAAY,SAAS,WAAW,CAAC,SAAS,QAAQ,CAAC,CAC1D,KAAI,aAAY,SAAS,KAAK;AACnC;AAEA,IAAa,qBAAb,cAAwC,YAAY;CAClD,OAAO,qBAAqB,CAAC,GAAG,6BA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BAAoB,KAAK,eAAe;CAC/C;CAEA,eAAe;EACb,IAAI,CAAC,KAAK,UACR,KAAK,QAAQ,MAAM;CAEvB;CAEA,oBAAoB,SAAkB;EACpC,IAAI,KAAK,QACP,KAAK,OAAO,UAAU;CAE1B;CAEA,mBAAmB;EACjB,IAAI,KAAK,UAAU,OAAO,aAAa,aACrC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BpB,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,OAAO;EACb,MAAM,UAAU,SAAS,cAAc,MAAM;EAC7C,QAAQ,YAAY;EACpB,MAAM,UAAU,SAAS,cAAc,MAAM;EAC7C,QAAQ,YAAY;EACpB,QAAQ,OAAO,SAAS,cAAc,MAAM,CAAC;EAC7C,MAAM,iBAAiB,WAAW,UAAU;GAC1C,MAAM,gBAAgB;GAEtB,AADc,2BAA2B,MAAM,sBAC3C,CAAC,EAAE,qBAAqB;EAC9B,CAAC;EACD,MAAM,OAAO,OAAO,SAAS,OAAO;EACpC,KAAK,OAAO,OAAO,KAAK;EACxB,KAAK,SAAS;CAChB;CAEA,kBAAkB;EAChB,IAAI,CAAC,KAAK,QACR;EAEF,KAAK,OAAO,UAAU,qBAAqB,MAAM,SAAS;EAC1D,KAAK,OAAO,WAAW,KAAK;EAC5B,KAAK,OAAO,QAAQ,KAAK;EACzB,KAAK,MAAM,YAAY,yBAAyB,KAAK,aAAa,OAAO,KAAK,SAAS;CACzF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.mjs","names":[
|
|
1
|
+
{"version":3,"file":"form.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/form.ts"],"sourcesContent":["import { collectFormControlValues, resetFormControls } from './formControl'\nimport { dispatchMiniProgramEvent, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nexport interface FormConfig {\n preventDefault?: boolean\n}\n\nconst DEFAULT_FORM_CONFIG: Required<FormConfig> = {\n preventDefault: true,\n}\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\nlet formConfig: Required<FormConfig> = { ...DEFAULT_FORM_CONFIG }\n\nexport class WeappForm extends BaseElement {\n #form?: HTMLFormElement\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n }\n\n requestSubmit() {\n const submitEvent = new CustomEvent('submit', {\n detail: { value: collectFormControlValues(this) },\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n const shouldSubmit = this.dispatchEvent(submitEvent)\n if (shouldSubmit && !formConfig.preventDefault) {\n this.#form?.submit()\n }\n }\n\n reset() {\n resetFormControls(this)\n dispatchMiniProgramEvent(this, 'reset', {})\n }\n\n #ensureStructure() {\n if (this.#form || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = ':host { display: inline; box-sizing: border-box; } form { display: block; margin: 3px 0 0; }'\n const form = document.createElement('form')\n form.addEventListener('submit', event => event.preventDefault())\n const slot = document.createElement('slot')\n form.append(slot)\n root.append(style, form)\n this.#form = form\n }\n}\n\nexport function setFormConfig(next: FormConfig) {\n formConfig = {\n ...formConfig,\n ...next,\n }\n}\n"],"mappings":";;;;;AAQA,MAAM,sBAA4C,EAChD,gBAAgB,KAClB;AAEA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AACtD,IAAI,aAAmC,EAAE,GAAG,oBAAoB;AAEhE,IAAa,YAAb,cAA+B,YAAY;CACzC;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAK,iBAAiB;CACxB;CAEA,gBAAgB;EACd,MAAM,cAAc,IAAI,YAAY,UAAU;GAC5C,QAAQ,EAAE,OAAO,yBAAyB,IAAI,EAAE;GAChD,SAAS;GACT,UAAU;GACV,YAAY;EACd,CAAC;EAED,IADqB,KAAK,cAAc,WACzB,KAAK,CAAC,WAAW,gBAC9B,KAAK,OAAO,OAAO;CAEvB;CAEA,QAAQ;EACN,kBAAkB,IAAI;EACtB,yBAAyB,MAAM,SAAS,CAAC,CAAC;CAC5C;CAEA,mBAAmB;EACjB,IAAI,KAAK,SAAS,OAAO,aAAa,aACpC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,cAAc;EACpB,MAAM,OAAO,SAAS,cAAc,MAAM;EAC1C,KAAK,iBAAiB,WAAU,UAAS,MAAM,eAAe,CAAC;EAC/D,MAAM,OAAO,SAAS,cAAc,MAAM;EAC1C,KAAK,OAAO,IAAI;EAChB,KAAK,OAAO,OAAO,IAAI;EACvB,KAAK,QAAQ;CACf;AACF;AAEA,SAAgB,cAAc,MAAkB;CAC9C,aAAa;EACX,GAAG;EACH,GAAG;CACL;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/icon/index.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\nimport { resolveIconColor, resolveIconSize, resolveIconType } from './helpers'\nimport { ICON_SHADOW_STYLE } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappIcon extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('icon')!.attributes]\n\n #icon?: HTMLSpanElement\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#icon || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = ICON_SHADOW_STYLE\n const icon = document.createElement('span')\n icon.className = 'icon'\n icon.setAttribute('role', 'img')\n root.append(style, icon)\n this.#icon = icon\n }\n\n #syncAttributes() {\n if (!this.#icon) {\n return\n }\n const type = resolveIconType(this.getAttribute('type'))\n const size = resolveIconSize(this.getAttribute('size'))\n const color = resolveIconColor(type, this.getAttribute('color'))\n this.style.setProperty('--weapp-icon-size', `${size}px`)\n this.style.setProperty('--weapp-icon-color', color)\n this.#icon.className = `icon ${type}`\n this.#icon.setAttribute('aria-label', type)\n }\n}\n\nexport * from './helpers'\n"],"mappings":";;;;;;;AAMA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,YAAb,cAA+B,YAAY;CACzC,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,MAAM,CAAC,CAAE,UAAU;CAEhF;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAK,iBAAiB;EACtB,KAAK,gBAAgB;CACvB;CAEA,2BAA2B;EACzB,KAAK,gBAAgB;CACvB;CAEA,mBAAmB;EACjB,IAAI,KAAK,SAAS,OAAO,aAAa,aACpC;EAEF,MAAM,OAAO,KAAK,cAAc,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;EAClE,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,cAAc;EACpB,MAAM,OAAO,SAAS,cAAc,MAAM;EAC1C,KAAK,YAAY;EACjB,KAAK,aAAa,QAAQ,KAAK;EAC/B,KAAK,OAAO,OAAO,IAAI;EACvB,KAAK,QAAQ;CACf;CAEA,kBAAkB;EAChB,IAAI,CAAC,KAAK,OACR;EAEF,MAAM,OAAO,gBAAgB,KAAK,aAAa,MAAM,CAAC;EACtD,MAAM,OAAO,gBAAgB,KAAK,aAAa,MAAM,CAAC;EACtD,MAAM,QAAQ,iBAAiB,MAAM,KAAK,aAAa,OAAO,CAAC;EAC/D,KAAK,MAAM,YAAY,qBAAqB,GAAG,KAAK,GAAG;EACvD,KAAK,MAAM,YAAY,sBAAsB,KAAK;EAClD,KAAK,MAAM,YAAY,QAAQ;EAC/B,KAAK,MAAM,aAAa,cAAc,IAAI;CAC5C;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.mjs","names":[
|
|
1
|
+
{"version":3,"file":"image.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/image.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nconst IMAGE_MODE_STYLES: Record<string, { fit: string, position: string }> = {\n 'scaleToFill': { fit: 'fill', position: 'center' },\n 'aspectFit': { fit: 'contain', position: 'center' },\n 'aspectFill': { fit: 'cover', position: 'center' },\n 'top': { fit: 'none', position: 'top' },\n 'bottom': { fit: 'none', position: 'bottom' },\n 'center': { fit: 'none', position: 'center' },\n 'left': { fit: 'none', position: 'left' },\n 'right': { fit: 'none', position: 'right' },\n 'top left': { fit: 'none', position: 'left top' },\n 'top right': { fit: 'none', position: 'right top' },\n 'bottom left': { fit: 'none', position: 'left bottom' },\n 'bottom right': { fit: 'none', position: 'right bottom' },\n}\n\nexport function resolveImageModeStyle(mode: string | null) {\n return IMAGE_MODE_STYLES[mode ?? 'scaleToFill'] ?? IMAGE_MODE_STYLES.scaleToFill!\n}\n\nexport class WeappImage extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('image')!.attributes]\n\n #image?: HTMLImageElement\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#image || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { position: relative; }\n img { display: block; width: 100%; height: 100%; }\n `\n const image = document.createElement('img')\n image.addEventListener('load', () => {\n dispatchMiniProgramEvent(this, 'load', {\n width: image.naturalWidth,\n height: image.naturalHeight,\n })\n })\n image.addEventListener('error', () => {\n dispatchMiniProgramEvent(this, 'error', { errMsg: 'image load failed' }, {\n bubbles: false,\n composed: false,\n })\n })\n root.append(style, image)\n this.#image = image\n }\n\n #syncAttributes() {\n if (!this.#image) {\n return\n }\n this.#image.src = this.getAttribute('src') ?? ''\n this.#image.alt = this.getAttribute('alt') ?? ''\n this.#image.loading = readBooleanAttribute(this, 'lazy-load') ? 'lazy' : 'eager'\n const mode = this.getAttribute('mode') ?? 'scaleToFill'\n const modeStyle = resolveImageModeStyle(mode)\n this.#image.style.objectFit = modeStyle.fit\n this.#image.style.objectPosition = modeStyle.position\n this.toggleAttribute('data-width-fix', mode === 'widthFix')\n this.toggleAttribute('data-height-fix', mode === 'heightFix')\n if (mode === 'widthFix') {\n this.#image.style.height = 'auto'\n this.style.height = 'auto'\n }\n else if (mode === 'heightFix') {\n this.#image.style.width = 'auto'\n this.style.width = 'auto'\n }\n else {\n this.#image.style.width = '100%'\n this.#image.style.height = '100%'\n }\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,MAAM,oBAAuE;CAC3E,eAAe;EAAE,KAAK;EAAQ,UAAU;CAAS;CACjD,aAAa;EAAE,KAAK;EAAW,UAAU;CAAS;CAClD,cAAc;EAAE,KAAK;EAAS,UAAU;CAAS;CACjD,OAAO;EAAE,KAAK;EAAQ,UAAU;CAAM;CACtC,UAAU;EAAE,KAAK;EAAQ,UAAU;CAAS;CA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KAAK,KAAK;EAC9C,KAAK,OAAO,MAAM,KAAK,aAAa,KAAK,KAAK;EAC9C,KAAK,OAAO,UAAU,qBAAqB,MAAM,WAAW,IAAI,SAAS;EACzE,MAAM,OAAO,KAAK,aAAa,MAAM,KAAK;EAC1C,MAAM,YAAY,sBAAsB,IAAI;EAC5C,KAAK,OAAO,MAAM,YAAY,UAAU;EACxC,KAAK,OAAO,MAAM,iBAAiB,UAAU;EAC7C,KAAK,gBAAgB,kBAAkB,SAAS,UAAU;EAC1D,KAAK,gBAAgB,mBAAmB,SAAS,WAAW;EAC5D,IAAI,SAAS,YAAY;GACvB,KAAK,OAAO,MAAM,SAAS;GAC3B,KAAK,MAAM,SAAS;EACtB,OACK,IAAI,SAAS,aAAa;GAC7B,KAAK,OAAO,MAAM,QAAQ;GAC1B,KAAK,MAAM,QAAQ;EACrB,OACK;GACH,KAAK,OAAO,MAAM,QAAQ;GAC1B,KAAK,OAAO,MAAM,SAAS;EAC7B;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.mjs","names":[
|
|
1
|
+
{"version":3,"file":"input.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/input.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { connectFormControl, disconnectFormControl } from './formControl'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot, resolveMaxLength } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nfunction resolveInputType(element: Element) {\n if (readBooleanAttribute(element, 'password')) {\n return 'password'\n }\n const type = element.getAttribute('type')\n return type === 'number' || type === 'digit' || type === 'idcard' ? 'text' : (type ?? 'text')\n}\n\nexport function createInputEventDetail(input: Pick<HTMLInputElement, 'selectionStart' | 'value'>) {\n return {\n value: input.value,\n cursor: input.selectionStart ?? input.value.length,\n }\n}\n\nexport class WeappInput extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('input')!.attributes]\n\n #input?: HTMLInputElement\n #initialValue = ''\n #initialValueCaptured = false\n\n get formControlName() {\n return this.getAttribute('name') ?? ''\n }\n\n get formControlValue() {\n return this.value\n }\n\n get formControlDisabled() {\n return readBooleanAttribute(this, 'disabled')\n }\n\n get value() {\n return this.#input?.value ?? this.getAttribute('value') ?? ''\n }\n\n set value(value: string) {\n this.setAttribute('value', value ?? '')\n }\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n if (!this.#initialValueCaptured) {\n this.#initialValue = this.getAttribute('value') ?? ''\n this.#initialValueCaptured = true\n }\n this.#ensureStructure()\n this.#syncAttributes()\n connectFormControl(this)\n this.#syncFocus()\n }\n\n disconnectedCallback() {\n disconnectFormControl(this)\n }\n\n attributeChangedCallback(name: string) {\n this.#syncAttributes()\n if (name === 'focus') {\n this.#syncFocus()\n }\n }\n\n focus(options?: FocusOptions) {\n this.#input?.focus(options)\n }\n\n blur() {\n this.#input?.blur()\n }\n\n formReset() {\n if (this.#input) {\n this.#input.value = this.#initialValue\n }\n }\n\n formActivate() {\n this.focus()\n }\n\n #ensureStructure() {\n if (this.#input || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { cursor: text; }\n input {\n display: block;\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 100%;\n padding: 0;\n border: 0;\n outline: 0;\n color: inherit;\n background: transparent;\n font: inherit;\n line-height: inherit;\n }\n `\n const input = document.createElement('input')\n input.addEventListener('input', (event) => {\n event.stopPropagation()\n dispatchMiniProgramEvent(this, 'input', createInputEventDetail(input))\n })\n input.addEventListener('focus', () => {\n dispatchMiniProgramEvent(this, 'focus', { value: input.value, height: 0 })\n })\n input.addEventListener('blur', () => {\n dispatchMiniProgramEvent(this, 'blur', createInputEventDetail(input))\n })\n input.addEventListener('keydown', (event) => {\n if (event.key === 'Enter') {\n dispatchMiniProgramEvent(this, 'confirm', { value: input.value })\n }\n })\n root.append(style, input)\n this.#input = input\n }\n\n #syncAttributes() {\n if (!this.#input) {\n return\n }\n const value = this.getAttribute('value') ?? ''\n if (this.#input.value !== value) {\n this.#input.value = value\n }\n this.#input.type = resolveInputType(this)\n this.#input.placeholder = this.getAttribute('placeholder') ?? ''\n this.#input.disabled = readBooleanAttribute(this, 'disabled')\n const maxlength = resolveMaxLength(this.getAttribute('maxlength'))\n if (maxlength === undefined) {\n this.#input.removeAttribute('maxlength')\n }\n else {\n this.#input.maxLength = maxlength\n }\n const confirmType = this.getAttribute('confirm-type')\n if (confirmType) {\n this.#input.enterKeyHint = confirmType === 'send' ? 'send' : confirmType as HTMLInputElement['enterKeyHint']\n }\n }\n\n #syncFocus() {\n if (!readBooleanAttribute(this, 'focus')) {\n return\n }\n queueMicrotask(() => this.focus())\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,SAAS,iBAAiB,SAAkB;CAC1C,IAAI,qBAAqB,SAAS,UAAU,GAC1C,OAAO;CAET,MAAM,OAAO,QAAQ,aAAa,MAAM;CACxC,OAAO,SAAS,YAAY,SAAS,WAAW,SAAS,WAAW,SAAU,QAAQ;AACxF;AAEA,SAAgB,uBAAuB,OAA2D;CAChG,OAAO;EACL,OAAO,MAAM;EACb,QAAQ,MAAM,kBAAkB,MAAM,MAAM;CAC9C;AACF;AAEA,IAAa,aAAb,cAAgC,YAAY;CAC1C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,OAAO,CAAC,CAAE,UAAU;CAEjF;CACA,gBAAgB;CAChB,wBAAwB;CAExB,IAAI,kBAAkB;EACpB,OAAO,KAAK,aAAa,MAAM,KAAK;CACtC;CAEA,IAAI,mBAAmB;EACrB,OAAO,KAAK;CACd;CAEA,IAAI,sBAAsB;EACxB,OAAO,qBAAqB,MAAM,UAAU;CAC9C;CAEA,IAAI,QAAQ;EACV,OAAO,K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MAAM,iBAAiB,YAAY,UAAU;GAC3C,IAAI,MAAM,QAAQ,SAChB,yBAAyB,MAAM,WAAW,EAAE,OAAO,MAAM,MAAM,CAAC;EAEpE,CAAC;EACD,KAAK,OAAO,OAAO,KAAK;EACxB,KAAK,SAAS;CAChB;CAEA,kBAAkB;EAChB,IAAI,CAAC,KAAK,QACR;EAEF,MAAM,QAAQ,KAAK,aAAa,OAAO,KAAK;EAC5C,IAAI,KAAK,OAAO,UAAU,OACxB,KAAK,OAAO,QAAQ;EAEtB,KAAK,OAAO,OAAO,iBAAiB,IAAI;EACxC,KAAK,OAAO,cAAc,KAAK,aAAa,aAAa,KAAK;EAC9D,KAAK,OAAO,WAAW,qBAAqB,MAAM,UAAU;EAC5D,MAAM,YAAY,iBAAiB,KAAK,aAAa,WAAW,CAAC;EACjE,IAAI,cAAc,QAChB,KAAK,OAAO,gBAAgB,WAAW;OAGvC,KAAK,OAAO,YAAY;EAE1B,MAAM,cAAc,KAAK,aAAa,cAAc;EACpD,IAAI,aACF,KAAK,OAAO,eAAe,gBAAgB,SAAS,SAAS;CAEjE;CAEA,aAAa;EACX,IAAI,CAAC,qBAAqB,MAAM,OAAO,GACrC;EAEF,qBAAqB,KAAK,MAAM,CAAC;CACnC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.mjs","names":[
|
|
1
|
+
{"version":3,"file":"label.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/label.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { isFormActivatable } from './formControl'\nimport { resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\nconst FORM_CONTROL_SELECTOR = 'weapp-input, weapp-textarea, weapp-checkbox, weapp-radio, weapp-switch'\n\nfunction findElementById(root: Node, id: string) {\n if (!('querySelectorAll' in root)) {\n return null\n }\n return Array.from((root as ParentNode).querySelectorAll<HTMLElement>('[id]'))\n .find(element => element.id === id) ?? null\n}\n\nexport class WeappLabel extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('label')!.attributes]\n\n #bound = false\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n if (!this.#bound) {\n this.#bound = true\n this.addEventListener('click', this.#handleClick)\n }\n }\n\n #handleClick = (event: Event) => {\n if (event.defaultPrevented) {\n return\n }\n const path = event.composedPath()\n const selfIndex = path.indexOf(this)\n if (path.slice(0, selfIndex).some(node => node instanceof Element && isFormActivatable(node))) {\n return\n }\n const forId = this.getAttribute('for')?.trim()\n const target = forId\n ? findElementById(this.getRootNode(), forId)\n : this.querySelector<HTMLElement>(FORM_CONTROL_SELECTOR)\n if (target && isFormActivatable(target)) {\n target.formActivate?.()\n }\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AACtD,MAAM,wBAAwB;AAE9B,SAAS,gBAAgB,MAAY,IAAY;CAC/C,IAAI,EAAE,sBAAsB,OAC1B,OAAO;CAET,OAAO,MAAM,KAAM,KAAoB,iBAA8B,MAAM,CAAC,CAAC,CAC1E,MAAK,YAAW,QAAQ,OAAO,EAAE,KAAK;AAC3C;AAEA,IAAa,aAAb,cAAgC,YAAY;CAC1C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,OAAO,CAAC,CAAE,UAAU;CAEjF,SAAS;CAET,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,IAAI,CAAC,KAAK,QAAQ;GAChB,KAAK,SAAS;GACd,KAAK,iBAAiB,SAAS,KAAK,YAAY;EAClD;CACF;CAEA,gBAAgB,UAAiB;EAC/B,IAAI,MAAM,kBACR;EAEF,MAAM,OAAO,MAAM,aAAa;EAChC,MAAM,YAAY,KAAK,QAAQ,IAAI;EACnC,IAAI,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC,MAAK,SAAQ,gBAAgB,WAAW,kBAAkB,IAAI,CAAC,GAC1F;EAEF,MAAM,QAAQ,KAAK,aAAa,KAAK,CAAC,EAAE,KAAK;EAC7C,MAAM,SAAS,QACX,gBAAgB,KAAK,YAAY,GAAG,KAAK,IACzC,KAAK,cAA2B,qBAAqB;EACzD,IAAI,UAAU,kBAAkB,MAAM,GACpC,OAAO,eAAe;CAE1B;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/movable/index.ts"],"sourcesContent":["import type { MovablePosition } from './helpers'\nimport { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from '../helpers'\nimport { ensureNativeComponentStyle } from '../style'\nimport {\n clampMovablePosition,\n\n resolveMovableDirection,\n resolveMovableNumber,\n} from './helpers'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\nexport class WeappMovableArea extends BaseElement {\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n }\n}\n\nexport class WeappMovableView extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('movable-view')!.attributes]\n\n #position: MovablePosition = { x: 0, y: 0 }\n #drag?: { pointerId: number, startX: number, startY: number, position: MovablePosition }\n #bound = false\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#syncAttributes()\n if (!this.#bound) {\n this.addEventListener('pointerdown', this.#handlePointerDown)\n this.addEventListener('pointermove', this.#handlePointerMove)\n this.addEventListener('pointerup', this.#handlePointerUp)\n this.addEventListener('pointercancel', this.#handlePointerUp)\n this.#bound = true\n }\n }\n\n disconnectedCallback() {\n this.#drag = undefined\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #syncAttributes() {\n const direction = resolveMovableDirection(this.getAttribute('direction'))\n this.#position = clampMovablePosition({\n x: resolveMovableNumber(this.getAttribute('x')),\n y: resolveMovableNumber(this.getAttribute('y')),\n }, this.#readBounds(), direction, readBooleanAttribute(this, 'out-of-bounds'))\n this.style.transition = readBooleanAttribute(this, 'animation') ? 'transform 300ms ease' : 'none'\n this.#applyPosition()\n }\n\n #readBounds() {\n const area = this.closest('weapp-movable-area')\n const areaRect = area?.getBoundingClientRect()\n const viewRect = this.getBoundingClientRect()\n return {\n width: areaRect?.width ?? 0,\n height: areaRect?.height ?? 0,\n viewWidth: viewRect.width || 10,\n viewHeight: viewRect.height || 10,\n }\n }\n\n #applyPosition() {\n this.style.transform = `translate3d(${this.#position.x}px, ${this.#position.y}px, 0)`\n }\n\n #handlePointerDown = (event: Event) => {\n if (readBooleanAttribute(this, 'disabled')) {\n return\n }\n const pointer = event as PointerEvent\n const pointerId = Number.isFinite(pointer.pointerId) ? pointer.pointerId : 0\n this.#drag = {\n pointerId,\n startX: pointer.clientX,\n startY: pointer.clientY,\n position: { ...this.#position },\n }\n this.setPointerCapture?.(pointerId)\n event.preventDefault()\n }\n\n #handlePointerMove = (event: Event) => {\n const drag = this.#drag\n if (!drag) {\n return\n }\n const pointer = event as PointerEvent\n if (Number.isFinite(pointer.pointerId) && pointer.pointerId !== drag.pointerId) {\n return\n }\n const direction = resolveMovableDirection(this.getAttribute('direction'))\n const next = clampMovablePosition({\n x: drag.position.x + pointer.clientX - drag.startX,\n y: drag.position.y + pointer.clientY - drag.startY,\n }, this.#readBounds(), direction, readBooleanAttribute(this, 'out-of-bounds'))\n if (direction === 'horizontal' || direction === 'none') {\n next.y = drag.position.y\n }\n if (direction === 'vertical' || direction === 'none') {\n next.x = drag.position.x\n }\n const changedX = next.x !== this.#position.x\n const changedY = next.y !== this.#position.y\n if (!changedX && !changedY) {\n return\n }\n this.#position = next\n this.#applyPosition()\n const detail = { x: next.x, y: next.y, source: 'touch' }\n dispatchMiniProgramEvent(this, 'change', detail)\n if (changedX) {\n dispatchMiniProgramEvent(this, 'htouchmove', detail)\n }\n if (changedY) {\n dispatchMiniProgramEvent(this, 'vtouchmove', detail)\n }\n event.preventDefault()\n }\n\n #handlePointerUp = (event: Event) => {\n const drag = this.#drag\n if (!drag) {\n return\n }\n const pointer = event as PointerEvent\n if (Number.isFinite(pointer.pointerId) && pointer.pointerId !== drag.pointerId) {\n return\n }\n this.releasePointerCapture?.(drag.pointerId)\n this.#drag = undefined\n dispatchMiniProgramEvent(this, 'change', {\n x: this.#position.x,\n y: this.#position.y,\n source: 'touch',\n })\n }\n}\n\nexport { clampMovablePosition, resolveMovableDirection } from './helpers'\n"],"mappings":";;;;;;AAWA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AAEtD,IAAa,mBAAb,cAAsC,YAAY;CAChD,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;CAC9D;AACF;AAEA,IAAa,mBAAb,cAAsC,YAAY;CAChD,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,cAAc,CAAC,CAAE,UAAU;CAExF,YAA6B;EAAE,GAAG;EAAG,GAAG;CAAE;CAC1C;CACA,SAAS;CAET,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAK,gBAAgB;EACrB,IAAI,CAAC,KAAK,QAAQ;GAChB,KAAK,iBAAiB,eAAe,KAAK,kBAAkB;GAC5D,KAAK,iBAAiB,eAAe,KAAK,kBAAkB;GAC5D,KAAK,iBAAiB,aAAa,KAAK,gBAAgB;GACxD,KAAK,iBAAiB,iBAAiB,KAAK,gBAAgB;GAC5D,KAAK,SAAS;EAChB;CACF;CAEA,uBAAuB;EACrB,KAAK,QAAQ;CACf;CAEA,2BAA2B;EACzB,KAAK,gBAAgB;CACvB;CAEA,kBAAkB;EAChB,MAAM,YAAY,wBAAwB,KAAK,aAAa,WAAW,CAAC;EACxE,KAAK,YAAY,qBAAqB;GACpC,GAAG,qBAAqB,KAAK,aAAa,GAAG,CAAC;GAC9C,GAAG,qBAAqB,KAAK,aAAa,GAAG,CAAC;EAChD,G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AAc,cAAc,cAAc,QAC5C,KAAK,IAAI,KAAK,SAAS;EAEzB,MAAM,WAAW,KAAK,MAAM,KAAK,UAAU;EAC3C,MAAM,WAAW,KAAK,MAAM,KAAK,UAAU;EAC3C,IAAI,CAAC,YAAY,CAAC,UAChB;EAEF,KAAK,YAAY;EACjB,KAAK,eAAe;EACpB,MAAM,SAAS;GAAE,GAAG,KAAK;GAAG,GAAG,KAAK;GAAG,QAAQ;EAAQ;EACvD,yBAAyB,MAAM,UAAU,MAAM;EAC/C,IAAI,UACF,yBAAyB,MAAM,cAAc,MAAM;EAErD,IAAI,UACF,yBAAyB,MAAM,cAAc,MAAM;EAErD,MAAM,eAAe;CACvB;CAEA,oBAAoB,UAAiB;EACnC,MAAM,OAAO,KAAK;EAClB,IAAI,CAAC,MACH;EAEF,MAAM,UAAU;EAChB,IAAI,OAAO,SAAS,QAAQ,SAAS,KAAK,QAAQ,cAAc,KAAK,WACnE;EAEF,KAAK,wBAAwB,KAAK,SAAS;EAC3C,KAAK,QAAQ;EACb,yBAAyB,MAAM,UAAU;GACvC,GAAG,KAAK,UAAU;GAClB,GAAG,KAAK,UAAU;GAClB,QAAQ;EACV,CAAC;CACH;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigator.mjs","names":["#ensureStructure","#syncAttributes","#bindEvents","#clearHoverTimers","#anchor","#bound","#handleClick","#handlePressStart","#handlePressEnd","#lastTouchTime","#hoverTimer","#hoverRemoveTimer"],"sources":["../../../src/runtime/nativeComponents/navigator.ts"],"sourcesContent":["import type { MiniProgramBaseResult, NavigateToMiniProgramOptions } from '../polyfill/types'\nimport { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { navigateBack, navigateTo, redirectTo, reLaunch, switchTab } from '../polyfill/routeRuntime'\nimport { exitMiniProgram, navigateToMiniProgram } from '../polyfill/runtimeDataApi'\nimport { emitRuntimeWarning } from '../warning'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\ntype NavigatorOpenType = 'navigate' | 'redirect' | 'switchtab' | 'relaunch' | 'navigateback' | 'exit'\n\ninterface NavigatorRuntimeBridge {\n navigateTo: typeof navigateTo\n redirectTo: typeof redirectTo\n switchTab: typeof switchTab\n reLaunch: typeof reLaunch\n navigateBack: typeof navigateBack\n navigateToMiniProgram: typeof navigateToMiniProgram\n exitMiniProgram: typeof exitMiniProgram\n}\n\nexport interface NavigatorRequest {\n url: string\n openType: string\n delta: number\n target: string\n appId?: string\n path?: string\n extraData?: Record<string, unknown>\n envVersion?: 'develop' | 'trial' | 'release'\n success?: (result: MiniProgramBaseResult) => void\n fail?: (result: MiniProgramBaseResult) => void\n complete?: (result: MiniProgramBaseResult) => void\n}\n\nconst defaultBridge: NavigatorRuntimeBridge = {\n navigateTo,\n redirectTo,\n switchTab,\n reLaunch,\n navigateBack,\n navigateToMiniProgram,\n exitMiniProgram,\n}\n\nfunction normalizeOpenType(value: string): NavigatorOpenType {\n const normalized = value.trim().toLowerCase()\n switch (normalized) {\n case 'redirect':\n case 'switchtab':\n case 'relaunch':\n case 'navigateback':\n case 'exit':\n return normalized\n default:\n return 'navigate'\n }\n}\n\nfunction withNavigatorCallbacks<T extends Record<string, unknown>>(options: T, request: NavigatorRequest) {\n if (request.success) {\n Object.assign(options, { success: request.success })\n }\n if (request.fail) {\n Object.assign(options, { fail: request.fail })\n }\n if (request.complete) {\n Object.assign(options, { complete: request.complete })\n }\n return options\n}\n\nexport function executeNavigatorRequest(\n request: NavigatorRequest,\n bridge: NavigatorRuntimeBridge = defaultBridge,\n) {\n const openType = normalizeOpenType(request.openType)\n if (request.target.trim().toLowerCase() === 'miniprogram') {\n if (openType === 'exit') {\n return bridge.exitMiniProgram({\n success: request.success,\n fail: request.fail,\n complete: request.complete,\n })\n }\n const options: NavigateToMiniProgramOptions = {\n appId: request.appId,\n path: request.path,\n extraData: request.extraData,\n envVersion: request.envVersion,\n success: request.success,\n fail: request.fail,\n complete: request.complete,\n }\n return bridge.navigateToMiniProgram(options)\n }\n\n switch (openType) {\n case 'redirect':\n return bridge.redirectTo(withNavigatorCallbacks({ url: request.url }, request))\n case 'switchtab':\n return bridge.switchTab(withNavigatorCallbacks({ url: request.url }, request))\n case 'relaunch':\n return bridge.reLaunch(withNavigatorCallbacks({ url: request.url }, request))\n case 'navigateback':\n return bridge.navigateBack(withNavigatorCallbacks({ delta: request.delta }, request))\n case 'exit':\n emitRuntimeWarning('[@weapp-vite/web] navigator open-type=\"exit\" 仅在 target=\"miniProgram\" 时生效', {\n key: 'navigator:self:exit',\n context: 'native-component:navigator',\n })\n return Promise.resolve()\n default:\n return bridge.navigateTo(withNavigatorCallbacks({ url: request.url }, request))\n }\n}\n\nexport function resolveNavigatorExtraData(value: unknown, attributeValue?: string | null) {\n if (value && typeof value === 'object') {\n return value as Record<string, unknown>\n }\n const serialized = typeof value === 'string' ? value : attributeValue\n if (!serialized) {\n return undefined\n }\n try {\n const parsed = JSON.parse(serialized) as unknown\n return parsed && typeof parsed === 'object' ? parsed as Record<string, unknown> : undefined\n }\n catch {\n return undefined\n }\n}\n\nfunction parseNumber(value: string | null, fallback: number) {\n const number = Number(value)\n return value !== null && Number.isFinite(number) ? number : fallback\n}\n\nfunction resolveHoverClass(element: HTMLElement) {\n const value = element.getAttribute('hover-class') ?? element.getAttribute('data-hover-class')\n if (value === 'none') {\n return ''\n }\n return value || 'navigator-hover'\n}\n\nexport class WeappNavigator extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('navigator')!.attributes]\n\n extraData?: Record<string, unknown> | string\n\n #anchor?: HTMLAnchorElement\n #hoverTimer?: ReturnType<typeof globalThis.setTimeout>\n #hoverRemoveTimer?: ReturnType<typeof globalThis.setTimeout>\n #lastTouchTime = 0\n #bound = false\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n this.#bindEvents()\n }\n\n disconnectedCallback() {\n this.#clearHoverTimers()\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#anchor || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { -webkit-tap-highlight-color: transparent; }\n :host(.navigator-hover) { opacity: 0.7; }\n a { display: block; width: 100%; height: 100%; color: inherit; text-decoration: none; outline: none; }\n `\n const anchor = document.createElement('a')\n anchor.append(document.createElement('slot'))\n root.append(style, anchor)\n this.#anchor = anchor\n }\n\n #syncAttributes() {\n if (!this.#anchor) {\n return\n }\n const url = this.getAttribute('url') ?? ''\n this.#anchor.href = url || '#'\n this.#anchor.setAttribute('aria-label', this.getAttribute('aria-label') ?? this.textContent.trim())\n }\n\n #bindEvents() {\n if (this.#bound || !this.#anchor) {\n return\n }\n this.#bound = true\n this.#anchor.addEventListener('click', this.#handleClick)\n this.addEventListener('touchstart', this.#handlePressStart, { passive: true })\n this.addEventListener('mousedown', this.#handlePressStart)\n this.addEventListener('touchend', this.#handlePressEnd)\n this.addEventListener('touchcancel', this.#handlePressEnd)\n this.addEventListener('mouseup', this.#handlePressEnd)\n this.addEventListener('mouseleave', this.#handlePressEnd)\n }\n\n #handleClick = (event: MouseEvent) => {\n event.preventDefault()\n const target = this.getAttribute('target') ?? 'self'\n const shortLink = this.getAttribute('short-link')\n if (target.toLowerCase() === 'miniprogram' && shortLink && !this.getAttribute('app-id')) {\n emitRuntimeWarning('[@weapp-vite/web] navigator short-link 暂无浏览器等价实现,请同时提供 app-id', {\n key: 'navigator:miniprogram:short-link',\n context: 'native-component:navigator',\n })\n }\n const version = this.getAttribute('version')\n const envVersion = version === 'develop' || version === 'trial' || version === 'release'\n ? version\n : undefined\n void executeNavigatorRequest({\n url: this.getAttribute('url') ?? '',\n openType: this.getAttribute('open-type') ?? 'navigate',\n delta: Math.max(1, parseNumber(this.getAttribute('delta'), 1)),\n target,\n appId: this.getAttribute('app-id') ?? undefined,\n path: this.getAttribute('path') ?? undefined,\n extraData: resolveNavigatorExtraData(this.extraData, this.getAttribute('extra-data')),\n envVersion,\n success: result => dispatchMiniProgramEvent(this, 'success', result),\n fail: result => dispatchMiniProgramEvent(this, 'fail', result),\n complete: result => dispatchMiniProgramEvent(this, 'complete', result),\n }).catch(() => {})\n }\n\n #handlePressStart = (event: Event) => {\n const hoverClass = resolveHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (readBooleanAttribute(this, 'hover-stop-propagation')) {\n event.stopPropagation()\n }\n if (event.type === 'touchstart') {\n this.#lastTouchTime = Date.now()\n }\n if (event.type === 'mousedown' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n this.#clearHoverTimers()\n const startTime = Math.max(0, parseNumber(this.getAttribute('hover-start-time'), 50))\n this.#hoverTimer = globalThis.setTimeout(() => this.classList.add(hoverClass), startTime)\n }\n\n #handlePressEnd = (event: Event) => {\n const hoverClass = resolveHoverClass(this)\n if (!hoverClass || (event.type === 'mouseup' && Date.now() - this.#lastTouchTime < 400)) {\n return\n }\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.classList.contains(hoverClass)) {\n const stayTime = Math.max(0, parseNumber(this.getAttribute('hover-stay-time'), 600))\n this.#hoverRemoveTimer = globalThis.setTimeout(() => this.classList.remove(hoverClass), stayTime)\n }\n }\n\n #clearHoverTimers() {\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.#hoverRemoveTimer) {\n clearTimeout(this.#hoverRemoveTimer)\n this.#hoverRemoveTimer = undefined\n }\n }\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AA4BtD,MAAM,gBAAwC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,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AAG,QAAQ;EAClG;CACF;CAEA,oBAAoB;EAClB,IAAI,KAAKD,aAAa;GACpB,aAAa,KAAKA,WAAW;GAC7B,KAAKA,cAAc;EACrB;EACA,IAAI,KAAKC,mBAAmB;GAC1B,aAAa,KAAKA,iBAAiB;GACnC,KAAKA,oBAAoB;EAC3B;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"navigator.mjs","names":[],"sources":["../../../src/runtime/nativeComponents/navigator.ts"],"sourcesContent":["import type { MiniProgramBaseResult, NavigateToMiniProgramOptions } from '../polyfill/types'\nimport { getNativeComponentDescriptor } from '../../shared/nativeComponents'\nimport { navigateBack, navigateTo, redirectTo, reLaunch, switchTab } from '../polyfill/routeRuntime'\nimport { exitMiniProgram, navigateToMiniProgram } from '../polyfill/runtimeDataApi'\nimport { emitRuntimeWarning } from '../warning'\nimport { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from './helpers'\nimport { ensureNativeComponentStyle } from './style'\n\nconst BaseElement = (globalThis.HTMLElement ?? class {}) as typeof HTMLElement\n\ntype NavigatorOpenType = 'navigate' | 'redirect' | 'switchtab' | 'relaunch' | 'navigateback' | 'exit'\n\ninterface NavigatorRuntimeBridge {\n navigateTo: typeof navigateTo\n redirectTo: typeof redirectTo\n switchTab: typeof switchTab\n reLaunch: typeof reLaunch\n navigateBack: typeof navigateBack\n navigateToMiniProgram: typeof navigateToMiniProgram\n exitMiniProgram: typeof exitMiniProgram\n}\n\nexport interface NavigatorRequest {\n url: string\n openType: string\n delta: number\n target: string\n appId?: string\n path?: string\n extraData?: Record<string, unknown>\n envVersion?: 'develop' | 'trial' | 'release'\n success?: (result: MiniProgramBaseResult) => void\n fail?: (result: MiniProgramBaseResult) => void\n complete?: (result: MiniProgramBaseResult) => void\n}\n\nconst defaultBridge: NavigatorRuntimeBridge = {\n navigateTo,\n redirectTo,\n switchTab,\n reLaunch,\n navigateBack,\n navigateToMiniProgram,\n exitMiniProgram,\n}\n\nfunction normalizeOpenType(value: string): NavigatorOpenType {\n const normalized = value.trim().toLowerCase()\n switch (normalized) {\n case 'redirect':\n case 'switchtab':\n case 'relaunch':\n case 'navigateback':\n case 'exit':\n return normalized\n default:\n return 'navigate'\n }\n}\n\nfunction withNavigatorCallbacks<T extends Record<string, unknown>>(options: T, request: NavigatorRequest) {\n if (request.success) {\n Object.assign(options, { success: request.success })\n }\n if (request.fail) {\n Object.assign(options, { fail: request.fail })\n }\n if (request.complete) {\n Object.assign(options, { complete: request.complete })\n }\n return options\n}\n\nexport function executeNavigatorRequest(\n request: NavigatorRequest,\n bridge: NavigatorRuntimeBridge = defaultBridge,\n) {\n const openType = normalizeOpenType(request.openType)\n if (request.target.trim().toLowerCase() === 'miniprogram') {\n if (openType === 'exit') {\n return bridge.exitMiniProgram({\n success: request.success,\n fail: request.fail,\n complete: request.complete,\n })\n }\n const options: NavigateToMiniProgramOptions = {\n appId: request.appId,\n path: request.path,\n extraData: request.extraData,\n envVersion: request.envVersion,\n success: request.success,\n fail: request.fail,\n complete: request.complete,\n }\n return bridge.navigateToMiniProgram(options)\n }\n\n switch (openType) {\n case 'redirect':\n return bridge.redirectTo(withNavigatorCallbacks({ url: request.url }, request))\n case 'switchtab':\n return bridge.switchTab(withNavigatorCallbacks({ url: request.url }, request))\n case 'relaunch':\n return bridge.reLaunch(withNavigatorCallbacks({ url: request.url }, request))\n case 'navigateback':\n return bridge.navigateBack(withNavigatorCallbacks({ delta: request.delta }, request))\n case 'exit':\n emitRuntimeWarning('[@weapp-vite/web] navigator open-type=\"exit\" 仅在 target=\"miniProgram\" 时生效', {\n key: 'navigator:self:exit',\n context: 'native-component:navigator',\n })\n return Promise.resolve()\n default:\n return bridge.navigateTo(withNavigatorCallbacks({ url: request.url }, request))\n }\n}\n\nexport function resolveNavigatorExtraData(value: unknown, attributeValue?: string | null) {\n if (value && typeof value === 'object') {\n return value as Record<string, unknown>\n }\n const serialized = typeof value === 'string' ? value : attributeValue\n if (!serialized) {\n return undefined\n }\n try {\n const parsed = JSON.parse(serialized) as unknown\n return parsed && typeof parsed === 'object' ? parsed as Record<string, unknown> : undefined\n }\n catch {\n return undefined\n }\n}\n\nfunction parseNumber(value: string | null, fallback: number) {\n const number = Number(value)\n return value !== null && Number.isFinite(number) ? number : fallback\n}\n\nfunction resolveHoverClass(element: HTMLElement) {\n const value = element.getAttribute('hover-class') ?? element.getAttribute('data-hover-class')\n if (value === 'none') {\n return ''\n }\n return value || 'navigator-hover'\n}\n\nexport class WeappNavigator extends BaseElement {\n static observedAttributes = [...getNativeComponentDescriptor('navigator')!.attributes]\n\n extraData?: Record<string, unknown> | string\n\n #anchor?: HTMLAnchorElement\n #hoverTimer?: ReturnType<typeof globalThis.setTimeout>\n #hoverRemoveTimer?: ReturnType<typeof globalThis.setTimeout>\n #lastTouchTime = 0\n #bound = false\n\n connectedCallback() {\n ensureNativeComponentStyle(resolveContainingShadowRoot(this))\n this.#ensureStructure()\n this.#syncAttributes()\n this.#bindEvents()\n }\n\n disconnectedCallback() {\n this.#clearHoverTimers()\n }\n\n attributeChangedCallback() {\n this.#syncAttributes()\n }\n\n #ensureStructure() {\n if (this.#anchor || typeof document === 'undefined') {\n return\n }\n const root = this.shadowRoot ?? this.attachShadow({ mode: 'open' })\n const style = document.createElement('style')\n style.textContent = `\n :host { -webkit-tap-highlight-color: transparent; }\n :host(.navigator-hover) { opacity: 0.7; }\n a { display: block; width: 100%; height: 100%; color: inherit; text-decoration: none; outline: none; }\n `\n const anchor = document.createElement('a')\n anchor.append(document.createElement('slot'))\n root.append(style, anchor)\n this.#anchor = anchor\n }\n\n #syncAttributes() {\n if (!this.#anchor) {\n return\n }\n const url = this.getAttribute('url') ?? ''\n this.#anchor.href = url || '#'\n this.#anchor.setAttribute('aria-label', this.getAttribute('aria-label') ?? this.textContent.trim())\n }\n\n #bindEvents() {\n if (this.#bound || !this.#anchor) {\n return\n }\n this.#bound = true\n this.#anchor.addEventListener('click', this.#handleClick)\n this.addEventListener('touchstart', this.#handlePressStart, { passive: true })\n this.addEventListener('mousedown', this.#handlePressStart)\n this.addEventListener('touchend', this.#handlePressEnd)\n this.addEventListener('touchcancel', this.#handlePressEnd)\n this.addEventListener('mouseup', this.#handlePressEnd)\n this.addEventListener('mouseleave', this.#handlePressEnd)\n }\n\n #handleClick = (event: MouseEvent) => {\n event.preventDefault()\n const target = this.getAttribute('target') ?? 'self'\n const shortLink = this.getAttribute('short-link')\n if (target.toLowerCase() === 'miniprogram' && shortLink && !this.getAttribute('app-id')) {\n emitRuntimeWarning('[@weapp-vite/web] navigator short-link 暂无浏览器等价实现,请同时提供 app-id', {\n key: 'navigator:miniprogram:short-link',\n context: 'native-component:navigator',\n })\n }\n const version = this.getAttribute('version')\n const envVersion = version === 'develop' || version === 'trial' || version === 'release'\n ? version\n : undefined\n void executeNavigatorRequest({\n url: this.getAttribute('url') ?? '',\n openType: this.getAttribute('open-type') ?? 'navigate',\n delta: Math.max(1, parseNumber(this.getAttribute('delta'), 1)),\n target,\n appId: this.getAttribute('app-id') ?? undefined,\n path: this.getAttribute('path') ?? undefined,\n extraData: resolveNavigatorExtraData(this.extraData, this.getAttribute('extra-data')),\n envVersion,\n success: result => dispatchMiniProgramEvent(this, 'success', result),\n fail: result => dispatchMiniProgramEvent(this, 'fail', result),\n complete: result => dispatchMiniProgramEvent(this, 'complete', result),\n }).catch(() => {})\n }\n\n #handlePressStart = (event: Event) => {\n const hoverClass = resolveHoverClass(this)\n if (!hoverClass) {\n return\n }\n if (readBooleanAttribute(this, 'hover-stop-propagation')) {\n event.stopPropagation()\n }\n if (event.type === 'touchstart') {\n this.#lastTouchTime = Date.now()\n }\n if (event.type === 'mousedown' && Date.now() - this.#lastTouchTime < 400) {\n return\n }\n this.#clearHoverTimers()\n const startTime = Math.max(0, parseNumber(this.getAttribute('hover-start-time'), 50))\n this.#hoverTimer = globalThis.setTimeout(() => this.classList.add(hoverClass), startTime)\n }\n\n #handlePressEnd = (event: Event) => {\n const hoverClass = resolveHoverClass(this)\n if (!hoverClass || (event.type === 'mouseup' && Date.now() - this.#lastTouchTime < 400)) {\n return\n }\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.classList.contains(hoverClass)) {\n const stayTime = Math.max(0, parseNumber(this.getAttribute('hover-stay-time'), 600))\n this.#hoverRemoveTimer = globalThis.setTimeout(() => this.classList.remove(hoverClass), stayTime)\n }\n }\n\n #clearHoverTimers() {\n if (this.#hoverTimer) {\n clearTimeout(this.#hoverTimer)\n this.#hoverTimer = undefined\n }\n if (this.#hoverRemoveTimer) {\n clearTimeout(this.#hoverRemoveTimer)\n this.#hoverRemoveTimer = undefined\n }\n }\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,cAAe,WAAW,eAAe,MAAM,CAAC;AA4BtD,MAAM,gBAAwC;CAC5C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,OAAkC;CAC3D,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,YAAY;CAC5C,QAAQ,YAAR;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAEA,SAAS,uBAA0D,SAAY,SAA2B;CACxG,IAAI,QAAQ,SACV,OAAO,OAAO,SAAS,EAAE,SAAS,QAAQ,QAAQ,CAAC;CAErD,IAAI,QAAQ,MACV,OAAO,OAAO,SAAS,EAAE,MAAM,QAAQ,KAAK,CAAC;CAE/C,IAAI,QAAQ,UACV,OAAO,OAAO,SAAS,EAAE,UAAU,QAAQ,SAAS,CAAC;CAEvD,OAAO;AACT;AAEA,SAAgB,wBACd,SACA,SAAiC,eACjC;CACA,MAAM,WAAW,kBAAkB,QAAQ,QAAQ;CACnD,IAAI,QAAQ,OAAO,KAAK,CAAC,CAAC,YAAY,MAAM,eAAe;EACzD,IAAI,aAAa,QACf,OAAO,OAAO,gBAAgB;GAC5B,SAAS,QAAQ;GACjB,MAAM,QAAQ;GACd,U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