@weapp-vite/web 1.3.36 → 1.4.0
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/README.md +144 -5
- package/dist/_virtual/_rolldown/runtime.mjs +19 -1
- package/dist/compiler/wxml/attributes.mjs +1 -1
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/compile.mjs +6 -3
- package/dist/compiler/wxml/compile.mjs.map +1 -1
- package/dist/compiler/wxml/interpolation.mjs +1 -2
- package/dist/compiler/wxml/interpolation.mjs.map +1 -1
- package/dist/compiler/wxml/navigation.mjs +5 -7
- package/dist/compiler/wxml/navigation.mjs.map +1 -1
- package/dist/compiler/wxml/parser.mjs +5 -5
- package/dist/compiler/wxml/parser.mjs.map +1 -1
- package/dist/compiler/wxml/renderer.mjs +13 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +6 -1
- package/dist/compiler/wxml/specialNodes.mjs.map +1 -1
- package/dist/compiler/wxml/types.d.mts +12 -0
- package/dist/compiler/wxs.mjs +5 -5
- package/dist/compiler/wxs.mjs.map +1 -1
- package/dist/css/wxss.d.mts +1 -0
- package/dist/css/wxss.mjs +110 -9
- package/dist/css/wxss.mjs.map +1 -1
- package/dist/index.d.mts +29 -6
- package/dist/index.mjs +197 -4
- package/dist/index.mjs.map +1 -0
- package/dist/plugin/assets.d.mts +7 -0
- package/dist/plugin/assets.mjs +122 -0
- package/dist/plugin/assets.mjs.map +1 -0
- package/dist/plugin/constants.mjs +10 -1
- package/dist/plugin/constants.mjs.map +1 -1
- package/dist/plugin/dependencyScan.mjs +41 -0
- package/dist/plugin/dependencyScan.mjs.map +1 -0
- package/dist/plugin/entry.mjs +56 -7
- package/dist/plugin/entry.mjs.map +1 -1
- package/dist/plugin/files.mjs +1 -1
- package/dist/plugin/files.mjs.map +1 -1
- package/dist/plugin/index.d.mts +37 -3
- package/dist/plugin/index.mjs +245 -74
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/layout.mjs +24 -0
- package/dist/plugin/layout.mjs.map +1 -0
- package/dist/plugin/path.mjs +4 -1
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +48 -36
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +206 -94
- package/dist/plugin/scan.mjs.map +1 -1
- package/dist/plugin/scanSfc.mjs +65 -0
- package/dist/plugin/scanSfc.mjs.map +1 -0
- package/dist/plugin/state.mjs +3 -2
- package/dist/plugin/state.mjs.map +1 -1
- package/dist/plugin/styleModule.mjs +52 -0
- package/dist/plugin/styleModule.mjs.map +1 -0
- package/dist/plugin/types.d.mts +46 -1
- package/dist/plugin/vueSfc.mjs +149 -0
- package/dist/plugin/vueSfc.mjs.map +1 -0
- package/dist/runtime/appShell/container.mjs +25 -0
- package/dist/runtime/appShell/container.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/index.mjs +192 -0
- package/dist/runtime/appShell/tabBar/index.mjs.map +1 -0
- package/dist/runtime/appShell/tabBar/style.mjs +127 -0
- package/dist/runtime/appShell/tabBar/style.mjs.map +1 -0
- package/dist/runtime/button/helpers.mjs +1 -58
- package/dist/runtime/button/helpers.mjs.map +1 -1
- package/dist/runtime/button/index.d.mts +4 -5
- package/dist/runtime/button/index.mjs +6 -28
- package/dist/runtime/button/index.mjs.map +1 -1
- package/dist/runtime/button/style.mjs +53 -28
- package/dist/runtime/button/style.mjs.map +1 -1
- package/dist/runtime/component/behavior.mjs +26 -2
- package/dist/runtime/component/behavior.mjs.map +1 -1
- package/dist/runtime/component/element.mjs +107 -31
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/component/observers.mjs +36 -0
- package/dist/runtime/component/observers.mjs.map +1 -0
- package/dist/runtime/component/publicInstance.mjs +48 -0
- package/dist/runtime/component/publicInstance.mjs.map +1 -0
- package/dist/runtime/component/relations.mjs +35 -0
- package/dist/runtime/component/relations.mjs.map +1 -0
- package/dist/runtime/component/slots.mjs +24 -0
- package/dist/runtime/component/slots.mjs.map +1 -0
- package/dist/runtime/component/state.mjs +13 -3
- package/dist/runtime/component/state.mjs.map +1 -1
- package/dist/runtime/component/types.d.mts +29 -4
- package/dist/runtime/component/virtualHost.mjs +83 -0
- package/dist/runtime/component/virtualHost.mjs.map +1 -0
- package/dist/runtime/host/index.d.mts +13 -0
- package/dist/runtime/host/index.mjs +47 -0
- package/dist/runtime/host/index.mjs.map +1 -0
- package/dist/runtime/host/types.d.mts +28 -0
- package/dist/runtime/hostGlobals.d.mts +9 -0
- package/dist/runtime/hostGlobals.mjs +39 -0
- package/dist/runtime/hostGlobals.mjs.map +1 -0
- package/dist/runtime/index.d.mts +21 -3
- package/dist/runtime/index.mjs +26 -4
- package/dist/runtime/index.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/dom.mjs +3 -3
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/expression.mjs +9 -9
- package/dist/runtime/legacyTemplate/expression.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/index.mjs +6 -6
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/canvas/index.mjs +53 -0
- package/dist/runtime/nativeComponents/canvas/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/checkbox.mjs +137 -0
- package/dist/runtime/nativeComponents/checkbox.mjs.map +1 -0
- package/dist/runtime/nativeComponents/cover/index.mjs +23 -0
- package/dist/runtime/nativeComponents/cover/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/form.d.mts +7 -0
- package/dist/runtime/nativeComponents/form.mjs +50 -0
- package/dist/runtime/nativeComponents/form.mjs.map +1 -0
- package/dist/runtime/nativeComponents/formControl.mjs +61 -0
- package/dist/runtime/nativeComponents/formControl.mjs.map +1 -0
- package/dist/runtime/nativeComponents/helpers.mjs +25 -0
- package/dist/runtime/nativeComponents/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs +42 -0
- package/dist/runtime/nativeComponents/icon/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/index.mjs +45 -0
- package/dist/runtime/nativeComponents/icon/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/icon/style.mjs +176 -0
- package/dist/runtime/nativeComponents/icon/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/image.d.mts +8 -0
- package/dist/runtime/nativeComponents/image.mjs +121 -0
- package/dist/runtime/nativeComponents/image.mjs.map +1 -0
- package/dist/runtime/nativeComponents/index.d.mts +11 -0
- package/dist/runtime/nativeComponents/index.mjs +83 -0
- package/dist/runtime/nativeComponents/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/input.d.mts +8 -0
- package/dist/runtime/nativeComponents/input.mjs +131 -0
- package/dist/runtime/nativeComponents/input.mjs.map +1 -0
- package/dist/runtime/nativeComponents/label.mjs +36 -0
- package/dist/runtime/nativeComponents/label.mjs.map +1 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs +47 -0
- package/dist/runtime/nativeComponents/mediaRegistry.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs +23 -0
- package/dist/runtime/nativeComponents/movable/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/movable/index.mjs +117 -0
- package/dist/runtime/nativeComponents/movable/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/navigator.mjs +200 -0
- package/dist/runtime/nativeComponents/navigator.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs +74 -0
- package/dist/runtime/nativeComponents/picker/editors.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs +57 -0
- package/dist/runtime/nativeComponents/picker/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/index.mjs +210 -0
- package/dist/runtime/nativeComponents/picker/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/picker/style.mjs +71 -0
- package/dist/runtime/nativeComponents/picker/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs +134 -0
- package/dist/runtime/nativeComponents/pickerView/column.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs +17 -0
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs +128 -0
- package/dist/runtime/nativeComponents/pickerView/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs +58 -0
- package/dist/runtime/nativeComponents/pickerView/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/primitives.mjs +16 -0
- package/dist/runtime/nativeComponents/primitives.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs +29 -0
- package/dist/runtime/nativeComponents/progress/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/index.mjs +130 -0
- package/dist/runtime/nativeComponents/progress/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/progress/style.mjs +40 -0
- package/dist/runtime/nativeComponents/progress/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/radio.mjs +147 -0
- package/dist/runtime/nativeComponents/radio.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs +230 -0
- package/dist/runtime/nativeComponents/richText/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/richText/index.mjs +74 -0
- package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/scrollView.d.mts +15 -0
- package/dist/runtime/nativeComponents/scrollView.mjs +79 -0
- package/dist/runtime/nativeComponents/scrollView.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs +28 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/index.mjs +120 -0
- package/dist/runtime/nativeComponents/slider/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/style.mjs +60 -0
- package/dist/runtime/nativeComponents/slider/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/style.mjs +41 -0
- package/dist/runtime/nativeComponents/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs +52 -0
- package/dist/runtime/nativeComponents/swiper/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs +235 -0
- package/dist/runtime/nativeComponents/swiper/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs +14 -0
- package/dist/runtime/nativeComponents/swiper/item.mjs.map +1 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs +20 -0
- package/dist/runtime/nativeComponents/swiper/style.mjs.map +1 -0
- package/dist/runtime/nativeComponents/switch.d.mts +7 -0
- package/dist/runtime/nativeComponents/switch.mjs +132 -0
- package/dist/runtime/nativeComponents/switch.mjs.map +1 -0
- package/dist/runtime/nativeComponents/textarea.d.mts +9 -0
- package/dist/runtime/nativeComponents/textarea.mjs +144 -0
- package/dist/runtime/nativeComponents/textarea.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/helpers.d.mts +12 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs +21 -0
- package/dist/runtime/nativeComponents/video/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/index.mjs +124 -0
- package/dist/runtime/nativeComponents/video/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/video/style.mjs +14 -0
- package/dist/runtime/nativeComponents/video/style.mjs.map +1 -0
- package/dist/runtime/navigationBar/index.mjs +1 -3
- package/dist/runtime/navigationBar/index.mjs.map +1 -1
- package/dist/runtime/pageLayout.d.mts +9 -0
- package/dist/runtime/pageLayout.mjs +16 -0
- package/dist/runtime/pageLayout.mjs.map +1 -0
- package/dist/runtime/polyfill/animation.mjs +120 -0
- package/dist/runtime/polyfill/animation.mjs.map +1 -0
- package/dist/runtime/polyfill/appState.mjs +1 -1
- package/dist/runtime/polyfill/appState.mjs.map +1 -1
- package/dist/runtime/polyfill/async.d.mts +7 -0
- package/dist/runtime/polyfill/async.mjs.map +1 -1
- package/dist/runtime/polyfill/canvasContext.mjs +41 -0
- package/dist/runtime/polyfill/canvasContext.mjs.map +1 -1
- package/dist/runtime/polyfill/device.mjs +1 -1
- package/dist/runtime/polyfill/device.mjs.map +1 -1
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +8 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs.map +1 -1
- package/dist/runtime/polyfill/eventBus.mjs +56 -0
- package/dist/runtime/polyfill/eventBus.mjs.map +1 -0
- package/dist/runtime/polyfill/fileSystemManager.mjs +5 -2
- package/dist/runtime/polyfill/fileSystemManager.mjs.map +1 -1
- package/dist/runtime/polyfill/files.mjs +10 -10
- package/dist/runtime/polyfill/files.mjs.map +1 -1
- package/dist/runtime/polyfill/font.mjs +32 -0
- package/dist/runtime/polyfill/font.mjs.map +1 -0
- package/dist/runtime/polyfill/index.d.mts +2 -2
- package/dist/runtime/polyfill/index.mjs +49 -45
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/interaction.mjs +7 -6
- package/dist/runtime/polyfill/interaction.mjs.map +1 -1
- package/dist/runtime/polyfill/interactionApi.mjs +3 -2
- package/dist/runtime/polyfill/interactionApi.mjs.map +1 -1
- package/dist/runtime/polyfill/intersectionObserver.mjs +106 -0
- package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -0
- package/dist/runtime/polyfill/locale.mjs +14 -0
- package/dist/runtime/polyfill/locale.mjs.map +1 -0
- package/dist/runtime/polyfill/locationApi.mjs +7 -4
- package/dist/runtime/polyfill/locationApi.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaActions.mjs +2 -2
- package/dist/runtime/polyfill/mediaActions.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/file.mjs +1 -1
- package/dist/runtime/polyfill/mediaApi/info.mjs +6 -4
- package/dist/runtime/polyfill/mediaApi/info.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +38 -4
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +6 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/network/request.mjs +2 -2
- package/dist/runtime/polyfill/network/request.mjs.map +1 -1
- package/dist/runtime/polyfill/platformApi.mjs +1 -1
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +88 -0
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/dom.mjs +44 -15
- package/dist/runtime/polyfill/routeRuntime/dom.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/history.d.mts +30 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs +148 -0
- package/dist/runtime/polyfill/routeRuntime/history.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +39 -8
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +11 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs +0 -1
- package/dist/runtime/polyfill/routeRuntime/options.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/result.mjs +12 -0
- package/dist/runtime/polyfill/routeRuntime/result.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs +39 -0
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs +122 -0
- package/dist/runtime/polyfill/routeRuntime/stack.mjs.map +1 -0
- package/dist/runtime/polyfill/routeRuntime.d.mts +26 -17
- package/dist/runtime/polyfill/routeRuntime.mjs +121 -96
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeDataApi.mjs +8 -3
- package/dist/runtime/polyfill/runtimeDataApi.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeOps.mjs +10 -6
- package/dist/runtime/polyfill/runtimeOps.mjs.map +1 -1
- package/dist/runtime/polyfill/selectorQuery.mjs +70 -14
- package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
- package/dist/runtime/polyfill/storage.mjs +5 -2
- package/dist/runtime/polyfill/storage.mjs.map +1 -1
- package/dist/runtime/polyfill/system.mjs +30 -3
- package/dist/runtime/polyfill/system.mjs.map +1 -1
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +1 -4
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +9 -0
- package/dist/runtime/polyfill/types/systemAuth.d.mts +20 -9
- package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +25 -0
- package/dist/runtime/polyfill/ui.mjs +2 -6
- package/dist/runtime/polyfill/ui.mjs.map +1 -1
- package/dist/runtime/polyfill/uiMediaApi.d.mts +11 -10
- package/dist/runtime/polyfill/uiMediaApi.mjs +26 -2
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
- package/dist/runtime/polyfill/videoContext.mjs +4 -0
- package/dist/runtime/polyfill/videoContext.mjs.map +1 -1
- package/dist/runtime/polyfill/vkSession.mjs +4 -14
- package/dist/runtime/polyfill/vkSession.mjs.map +1 -1
- package/dist/runtime/polyfill.d.mts +2 -2
- package/dist/runtime/renderContext.mjs +1 -1
- package/dist/runtime/renderContext.mjs.map +1 -1
- package/dist/runtime/rpx.mjs +17 -8
- package/dist/runtime/rpx.mjs.map +1 -1
- package/dist/runtime/seo/index.d.mts +31 -0
- package/dist/runtime/seo/index.mjs +94 -0
- package/dist/runtime/seo/index.mjs.map +1 -0
- package/dist/runtime/viewport/index.d.mts +12 -0
- package/dist/runtime/viewport/index.mjs +44 -0
- package/dist/runtime/viewport/index.mjs.map +1 -0
- package/dist/runtime/viewport/style.mjs +62 -0
- package/dist/runtime/viewport/style.mjs.map +1 -0
- package/dist/runtime/viewport/types.d.mts +14 -0
- package/dist/runtime/wevu.d.mts +20 -0
- package/dist/runtime/wevu.mjs +73 -0
- package/dist/runtime/wevu.mjs.map +1 -0
- package/dist/shared/nativeComponents.mjs +401 -0
- package/dist/shared/nativeComponents.mjs.map +1 -0
- package/dist/shared/tabBar.d.mts +19 -0
- package/dist/shared/tabBar.mjs +37 -0
- package/dist/shared/tabBar.mjs.map +1 -0
- package/dist/shared/wxml.mjs +3 -20
- package/dist/shared/wxml.mjs.map +1 -1
- package/package.json +13 -5
package/dist/runtime/index.d.mts
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
|
|
2
1
|
import { RenderContext, createRenderContext } from "./renderContext.mjs";
|
|
3
2
|
import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
|
|
4
3
|
import { TemplateRenderer, TemplateScope } from "./template.mjs";
|
|
5
4
|
import { defineComponent } from "./component/index.mjs";
|
|
5
|
+
import { ResolvedWebRoutingConfig, WebRouteHistoryState, WebRouteTarget, WebRoutingConfig, WebRoutingMode, disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
|
|
6
|
+
import { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebRuntimeSeoConfig as WebSeoConfig, configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./seo/index.mjs";
|
|
7
|
+
import { WebTabBarConfig, WebTabBarItem } from "../shared/tabBar.mjs";
|
|
8
|
+
import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
|
|
6
9
|
import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./execution.mjs";
|
|
10
|
+
import { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from "./host/types.mjs";
|
|
11
|
+
import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./host/index.mjs";
|
|
12
|
+
import { installWebHostGlobals } from "./hostGlobals.mjs";
|
|
13
|
+
import { resolveImageModeStyle } from "./nativeComponents/image.mjs";
|
|
14
|
+
import { createInputEventDetail } from "./nativeComponents/input.mjs";
|
|
15
|
+
import { createScrollEventDetail } from "./nativeComponents/scrollView.mjs";
|
|
16
|
+
import { createSwitchEventDetail } from "./nativeComponents/switch.mjs";
|
|
17
|
+
import { createTextareaLineChangeDetail } from "./nativeComponents/textarea.mjs";
|
|
18
|
+
import { createVideoProgressDetail, createVideoTimeUpdateDetail, resolveVideoObjectFit } from "./nativeComponents/video/helpers.mjs";
|
|
19
|
+
import { ensureNativeComponentsDefined } from "./nativeComponents/index.mjs";
|
|
7
20
|
import { NavigationBarMetrics, setNavigationBarMetrics } from "./navigationBar/index.mjs";
|
|
21
|
+
import { setPageLayout } from "./pageLayout.mjs";
|
|
8
22
|
import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./polyfill/deviceAuthSystemApi.mjs";
|
|
23
|
+
import { ResolvedWebViewportConfig, WebViewportConfig } from "./viewport/types.mjs";
|
|
24
|
+
import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
|
|
9
25
|
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
|
|
10
26
|
import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./polyfill/runtimeDataApi.mjs";
|
|
11
|
-
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
|
|
27
|
+
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
|
|
12
28
|
import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
|
|
13
29
|
import "./polyfill.mjs";
|
|
14
30
|
import { RpxConfig, setupRpx } from "./rpx.mjs";
|
|
15
31
|
import { injectStyle, removeStyle } from "./style.mjs";
|
|
16
32
|
import { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions } from "./warning.mjs";
|
|
17
|
-
|
|
33
|
+
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from "./wevu.mjs";
|
|
34
|
+
export * from "wevu/internal-runtime";
|
|
35
|
+
export { type ButtonFormConfig, type NavigationBarMetrics, type RenderContext, type ResolvedWebRoutingConfig, type ResolvedWebViewportConfig, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, type WebPageHead, type WebResourceHint, type WebResourceHintRelation, type WebResourceHintsConfig, type WebRouteHistoryState, type WebRouteTarget, type WebRoutingConfig, type WebRoutingMode, type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, type WebSeoConfig, type WebTabBarConfig, type WebTabBarItem, type WebViewportConfig, authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
|
+
import { __exportAll, __reExport } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { setRuntimeWarningOptions } from "./warning.mjs";
|
|
3
|
+
import { installWebHostGlobals } from "./hostGlobals.mjs";
|
|
1
4
|
import { injectStyle, removeStyle } from "./style.mjs";
|
|
2
5
|
import { ensureButtonDefined, setButtonFormConfig } from "./button/index.mjs";
|
|
3
|
-
import { setRuntimeWarningOptions } from "./warning.mjs";
|
|
4
6
|
import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./execution.mjs";
|
|
5
7
|
import { createRenderContext } from "./renderContext.mjs";
|
|
6
8
|
import { defineComponent } from "./component/index.mjs";
|
|
9
|
+
import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./host/index.mjs";
|
|
10
|
+
import { resolveImageModeStyle } from "./nativeComponents/image.mjs";
|
|
11
|
+
import { createInputEventDetail } from "./nativeComponents/input.mjs";
|
|
7
12
|
import { setNavigationBarMetrics } from "./navigationBar/index.mjs";
|
|
8
|
-
import {
|
|
13
|
+
import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./viewport/index.mjs";
|
|
9
14
|
import { setupRpx } from "./rpx.mjs";
|
|
15
|
+
import { configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./seo/index.mjs";
|
|
16
|
+
import { disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./polyfill/routeRuntime/history.mjs";
|
|
10
17
|
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./polyfill/routeRuntime.mjs";
|
|
11
18
|
import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./polyfill/runtimeDataApi.mjs";
|
|
12
|
-
import {
|
|
19
|
+
import { createScrollEventDetail } from "./nativeComponents/scrollView.mjs";
|
|
20
|
+
import { createSwitchEventDetail } from "./nativeComponents/switch.mjs";
|
|
21
|
+
import { createTextareaLineChangeDetail } from "./nativeComponents/textarea.mjs";
|
|
22
|
+
import { createVideoProgressDetail, createVideoTimeUpdateDetail, resolveVideoObjectFit } from "./nativeComponents/video/helpers.mjs";
|
|
23
|
+
import { ensureNativeComponentsDefined } from "./nativeComponents/index.mjs";
|
|
24
|
+
import { setPageLayout } from "./pageLayout.mjs";
|
|
25
|
+
import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./polyfill/deviceAuthSystemApi.mjs";
|
|
26
|
+
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./polyfill/uiMediaApi.mjs";
|
|
13
27
|
import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./polyfill/index.mjs";
|
|
14
28
|
import { createTemplate, renderTemplate } from "./legacyTemplate/index.mjs";
|
|
29
|
+
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from "./wevu.mjs";
|
|
30
|
+
|
|
31
|
+
export * from "wevu/internal-runtime"
|
|
32
|
+
|
|
33
|
+
//#region src/runtime/index.ts
|
|
34
|
+
installWebHostGlobals();
|
|
15
35
|
|
|
16
|
-
|
|
36
|
+
//#endregion
|
|
37
|
+
export { authorize, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort };
|
|
38
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/runtime/index.ts"],"sourcesContent":["import { installWebHostGlobals } from './hostGlobals'\n\ninstallWebHostGlobals()\n\nexport type { WebTabBarConfig, WebTabBarItem } from './appShell/tabBar'\nexport { ensureButtonDefined, setButtonFormConfig } from './button'\nexport type { ButtonFormConfig } from './button'\nexport { defineComponent } from './component'\nexport { getRuntimeExecutionMode, setRuntimeExecutionMode } from './execution'\nexport {\n getRuntimeClipboard,\n getRuntimeDialogs,\n getRuntimeFetch,\n getRuntimeStorage,\n getWebRuntimeHost,\n openRuntimeUrl,\n resetWebRuntimeHost,\n setWebRuntimeHost,\n} from './host'\nexport type { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from './host'\nexport { installWebHostGlobals } from './hostGlobals'\nexport {\n createInputEventDetail,\n createScrollEventDetail,\n createSwitchEventDetail,\n createTextareaLineChangeDetail,\n createVideoProgressDetail,\n createVideoTimeUpdateDetail,\n ensureNativeComponentsDefined,\n resolveImageModeStyle,\n resolveVideoObjectFit,\n} from './nativeComponents'\nexport { setNavigationBarMetrics } from './navigationBar'\nexport type { NavigationBarMetrics } from './navigationBar'\nexport { setPageLayout } from './pageLayout'\nexport {\n authorize,\n canIUse,\n checkSession,\n chooseAddress,\n chooseFile,\n chooseImage,\n chooseLocation,\n chooseMedia,\n chooseMessageFile,\n chooseVideo,\n clearStorage,\n clearStorageSync,\n compressImage,\n compressVideo,\n createCanvasContext,\n createInterstitialAd,\n createRewardedVideoAd,\n createSelectorQuery,\n createVideoContext,\n createVKSession,\n createWorker,\n downloadFile,\n exitMiniProgram,\n getAccountInfoSync,\n getAppAuthorizeSetting,\n getAppBaseInfo,\n getBatteryInfo,\n getBatteryInfoSync,\n getClipboardData,\n getDeviceInfo,\n getEnterOptionsSync,\n getExtConfig,\n getExtConfigSync,\n getFileSystemManager,\n getFuzzyLocation,\n getImageInfo,\n getLaunchOptionsSync,\n getLocation,\n getLogManager,\n getMenuButtonBoundingClientRect,\n getNetworkType,\n getSetting,\n getStorage,\n getStorageInfo,\n getStorageInfoSync,\n getStorageSync,\n getSystemInfo,\n getSystemInfoSync,\n getSystemSetting,\n getUpdateManager,\n getUserInfo,\n getUserProfile,\n getVideoInfo,\n getWindowInfo,\n hideKeyboard,\n hideLoading,\n hideNavigationBarLoading,\n hideTabBar,\n hideTabBarRedDot,\n initializePageRoutes,\n loadSubPackage,\n login,\n makePhoneCall,\n navigateBack,\n navigateTo,\n navigateToMiniProgram,\n nextTick,\n offNetworkStatusChange,\n offWindowResize,\n onNetworkStatusChange,\n onWindowResize,\n openAppAuthorizeSetting,\n openCustomerServiceChat,\n openDocument,\n openLocation,\n openSetting,\n openVideoEditor,\n pageScrollTo,\n preloadSubpackage,\n previewImage,\n previewMedia,\n redirectTo,\n registerApp,\n registerComponent,\n registerPage,\n reLaunch,\n removeStorage,\n removeStorageSync,\n removeTabBarBadge,\n reportAnalytics,\n request,\n requestPayment,\n requestSubscribeMessage,\n saveFile,\n saveFileToDisk,\n saveImageToPhotosAlbum,\n saveVideoToPhotosAlbum,\n scanCode,\n setBackgroundColor,\n setBackgroundTextStyle,\n setClipboardData,\n setNavigationBarColor,\n setNavigationBarTitle,\n setStorage,\n setStorageSync,\n setTabBarBadge,\n setTabBarItem,\n setTabBarStyle,\n showActionSheet,\n showLoading,\n showModal,\n showNavigationBarLoading,\n showShareMenu,\n showTabBar,\n showTabBarRedDot,\n showToast,\n startPullDownRefresh,\n stopPullDownRefresh,\n switchTab,\n updateShareMenu,\n uploadFile,\n vibrateShort,\n} from './polyfill'\nexport {\n disposeWebRouting,\n getWebRoutingConfig,\n resolveWebRoutingConfig,\n} from './polyfill/routeRuntime/history'\nexport type {\n ResolvedWebRoutingConfig,\n WebRouteHistoryState,\n WebRouteTarget,\n WebRoutingConfig,\n WebRoutingMode,\n} from './polyfill/routeRuntime/history'\nexport { createRenderContext } from './renderContext'\nexport type { RenderContext } from './renderContext'\nexport { setupRpx } from './rpx'\nexport type { RpxConfig } from './rpx'\nexport {\n configureWebSeo,\n resetWebDocumentHead,\n setupWebResourceHints,\n syncWebDocumentHead,\n updateWebDocumentTitle,\n} from './seo'\nexport type { WebPageHead, WebResourceHint, WebResourceHintRelation, WebResourceHintsConfig, WebSeoConfig } from './seo'\nexport { injectStyle, removeStyle } from './style'\nexport { createTemplate, renderTemplate } from './template'\nexport type { TemplateRenderer, TemplateScope } from './template'\nexport { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from './viewport'\nexport type { ResolvedWebViewportConfig, WebViewportConfig } from './viewport'\nexport { setRuntimeWarningOptions } from './warning'\nexport type { RuntimeWarningLevel, RuntimeWarningOptions } from './warning'\nexport { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent } from './wevu'\nexport * from 'wevu/internal-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,sBAAsB"}
|
|
@@ -46,8 +46,8 @@ function buildAttributeString(attribs, scope) {
|
|
|
46
46
|
const event = rawEvent.toLowerCase();
|
|
47
47
|
const handlerName = resolveAttributeValue(rawValue, scope).trim();
|
|
48
48
|
if (!handlerName) continue;
|
|
49
|
-
const runtimeEvent = EVENT_KIND_ALIAS[event]
|
|
50
|
-
const flags = EVENT_PREFIX_FLAGS[prefix]
|
|
49
|
+
const runtimeEvent = EVENT_KIND_ALIAS[event] || event;
|
|
50
|
+
const flags = EVENT_PREFIX_FLAGS[prefix];
|
|
51
51
|
result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${runtimeEvent}="${escapeAttribute(handlerName)}"`;
|
|
52
52
|
const flagTokens = [flags.capture ? "capture" : "", flags.catch ? "catch" : ""].filter(Boolean);
|
|
53
53
|
if (flagTokens.length) result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${runtimeEvent}="${flagTokens.join(",")}"`;
|
|
@@ -67,7 +67,7 @@ function stripControlAttributes(attribs) {
|
|
|
67
67
|
}
|
|
68
68
|
function isConditionalElement(node) {
|
|
69
69
|
if (node.type !== "tag") return false;
|
|
70
|
-
const attribs = node.attribs
|
|
70
|
+
const attribs = node.attribs;
|
|
71
71
|
return hasControlAttribute(attribs, "if") || hasControlAttribute(attribs, "elif") || hasControlAttribute(attribs, "else");
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/dom.ts"],"sourcesContent":["import type { Element, Node } from 'domhandler'\nimport type { ExtractForResult, LegacyTemplateScope } from './types'\nimport {\n CONTROL_ATTRS,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport {\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n} from '../component/constants'\nimport { escapeAttribute, resolveAttributeValue } from './expression'\n\nconst EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\\w-]+)$/\nconst EVENT_KIND_ALIAS: Record<string, string> = {\n tap: 'click',\n longtap: 'contextmenu',\n longpress: 'contextmenu',\n}\n\nconst EVENT_PREFIX_FLAGS: Record<string, { catch?: boolean, capture?: boolean }> = {\n 'bind': {},\n 'catch': { catch: true },\n 'mut-bind': {},\n 'capture-bind': { capture: true },\n 'capture-catch': { capture: true, catch: true },\n}\n\nexport function extractFor(attribs: Record<string, string>): ExtractForResult {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const restAttribs: Record<string, string> = {}\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n\n for (const [key, val] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(key)) {\n continue\n }\n restAttribs[key] = val\n }\n\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n\n return {\n expr,\n itemName,\n indexName,\n restAttribs,\n }\n}\n\nexport function buildAttributeString(\n attribs: Record<string, string>,\n scope: LegacyTemplateScope,\n) {\n let result = ''\n for (const [name, rawValue] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n\n const eventMatch = EVENT_PREFIX_RE.exec(name)\n if (eventMatch) {\n const [, prefix, rawEvent] = eventMatch\n const event = rawEvent.toLowerCase()\n const handlerName = resolveAttributeValue(rawValue, scope).trim()\n if (!handlerName) {\n continue\n }\n const runtimeEvent = EVENT_KIND_ALIAS[event]
|
|
1
|
+
{"version":3,"file":"dom.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/dom.ts"],"sourcesContent":["import type { Element, Node } from 'domhandler'\nimport type { ExtractForResult, LegacyTemplateScope } from './types'\nimport {\n CONTROL_ATTRS,\n hasControlAttribute,\n normalizeAttributeName,\n resolveControlAttributeValue,\n} from '../../shared/wxml'\nimport {\n MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX,\n MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX,\n} from '../component/constants'\nimport { escapeAttribute, resolveAttributeValue } from './expression'\n\nconst EVENT_PREFIX_RE = /^(bind|catch|mut-bind|capture-bind|capture-catch)([\\w-]+)$/\nconst EVENT_KIND_ALIAS: Record<string, string> = {\n tap: 'click',\n longtap: 'contextmenu',\n longpress: 'contextmenu',\n}\n\nconst EVENT_PREFIX_FLAGS: Record<string, { catch?: boolean, capture?: boolean }> = {\n 'bind': {},\n 'catch': { catch: true },\n 'mut-bind': {},\n 'capture-bind': { capture: true },\n 'capture-catch': { capture: true, catch: true },\n}\n\nexport function extractFor(attribs: Record<string, string>): ExtractForResult {\n const expr = resolveControlAttributeValue(attribs, 'for')\n const restAttribs: Record<string, string> = {}\n const itemName = resolveControlAttributeValue(attribs, 'for-item')?.trim() || 'item'\n let indexName = resolveControlAttributeValue(attribs, 'for-index')?.trim() || 'index'\n\n for (const [key, val] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(key)) {\n continue\n }\n restAttribs[key] = val\n }\n\n if (itemName === indexName) {\n indexName = `${indexName}Index`\n }\n\n return {\n expr,\n itemName,\n indexName,\n restAttribs,\n }\n}\n\nexport function buildAttributeString(\n attribs: Record<string, string>,\n scope: LegacyTemplateScope,\n) {\n let result = ''\n for (const [name, rawValue] of Object.entries(attribs)) {\n if (CONTROL_ATTRS.has(name)) {\n continue\n }\n\n const eventMatch = EVENT_PREFIX_RE.exec(name)\n if (eventMatch) {\n const [, prefix, rawEvent] = eventMatch\n const event = rawEvent.toLowerCase()\n const handlerName = resolveAttributeValue(rawValue, scope).trim()\n if (!handlerName) {\n continue\n }\n const runtimeEvent = EVENT_KIND_ALIAS[event] || event\n const flags = EVENT_PREFIX_FLAGS[prefix]!\n result += ` ${MINI_PROGRAM_EVENT_ATTRIBUTE_PREFIX}${runtimeEvent}=\"${escapeAttribute(handlerName)}\"`\n const flagTokens = [\n flags.capture ? 'capture' : '',\n flags.catch ? 'catch' : '',\n ].filter(Boolean)\n if (flagTokens.length) {\n result += ` ${MINI_PROGRAM_EVENT_FLAG_ATTRIBUTE_PREFIX}${runtimeEvent}=\"${flagTokens.join(',')}\"`\n }\n continue\n }\n\n const value = resolveAttributeValue(rawValue, scope)\n if (value === '') {\n continue\n }\n const normalizedName = normalizeAttributeName(name)\n result += ` ${normalizedName}=\"${escapeAttribute(value)}\"`\n }\n return result\n}\n\nexport function stripControlAttributes(attribs: Record<string, string>) {\n const result: Record<string, string> = {}\n for (const [name, value] of Object.entries(attribs)) {\n if (!CONTROL_ATTRS.has(name)) {\n result[name] = value\n }\n }\n return result\n}\n\nexport function isConditionalElement(node: Node): node is Element {\n if (node.type !== 'tag') {\n return false\n }\n const attribs = (node as Element).attribs\n return hasControlAttribute(attribs, 'if')\n || hasControlAttribute(attribs, 'elif')\n || hasControlAttribute(attribs, 'else')\n}\n"],"mappings":";;;;;AAcA,MAAM,kBAAkB;AACxB,MAAM,mBAA2C;CAC/C,KAAK;CACL,SAAS;CACT,WAAW;AACb;AAEA,MAAM,qBAA6E;CACjF,QAAQ,CAAC;CACT,SAAS,EAAE,OAAO,KAAK;CACvB,YAAY,CAAC;CACb,gBAAgB,EAAE,SAAS,KAAK;CAChC,iBAAiB;EAAE,SAAS;EAAM,OAAO;CAAK;AAChD;AAEA,SAAgB,WAAW,SAAmD;CAC5E,MAAM,OAAO,6BAA6B,SAAS,KAAK;CACxD,MAAM,cAAsC,CAAC;CAC7C,MAAM,WAAW,6BAA6B,SAAS,UAAU,CAAC,EAAE,KAAK,KAAK;CAC9E,IAAI,YAAY,6BAA6B,SAAS,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,OAAO;AACT;AAEA,SAAgB,qBAAqB,MAA6B;CAChE,IAAI,KAAK,SAAS,OAChB,OAAO;CAET,MAAM,UAAW,KAAiB;CAClC,OAAO,oBAAoB,SAAS,IAAI,KACnC,oBAAoB,SAAS,MAAM,KACnC,oBAAoB,SAAS,MAAM;AAC1C"}
|
|
@@ -19,15 +19,15 @@ function normalizeList(value) {
|
|
|
19
19
|
return [];
|
|
20
20
|
}
|
|
21
21
|
function escapeHtml(value) {
|
|
22
|
+
const entities = {
|
|
23
|
+
"&": "&",
|
|
24
|
+
"<": "<",
|
|
25
|
+
">": ">",
|
|
26
|
+
"\"": """,
|
|
27
|
+
"'": "'"
|
|
28
|
+
};
|
|
22
29
|
return value.replace(/[&<>"']/g, (match) => {
|
|
23
|
-
|
|
24
|
-
case "&": return "&";
|
|
25
|
-
case "<": return "<";
|
|
26
|
-
case ">": return ">";
|
|
27
|
-
case "\"": return """;
|
|
28
|
-
case "'": return "'";
|
|
29
|
-
default: return match;
|
|
30
|
-
}
|
|
30
|
+
return entities[match];
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
function escapeAttribute(value) {
|
|
@@ -65,7 +65,7 @@ function evaluateExpression(expression, scope) {
|
|
|
65
65
|
evaluator = () => void 0;
|
|
66
66
|
} else throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 "${trimmed}": ${reason}`);
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
expressionCache.set(trimmed, evaluator);
|
|
69
69
|
}
|
|
70
70
|
try {
|
|
71
71
|
return evaluator?.(scope);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expression.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/expression.ts"],"sourcesContent":["import type { LegacyTemplateScope } from './types'\nimport { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from '../execution'\n\nconst expressionCache = new Map<string, (scope: LegacyTemplateScope) => any>()\n\nexport function createScope(initial?: LegacyTemplateScope) {\n return Object.assign(Object.create(null), initial ?? {})\n}\n\nexport function createChildScope(parent: LegacyTemplateScope) {\n return Object.assign(Object.create(parent), {})\n}\n\nexport function normalizeList(value: any): any[] {\n if (Array.isArray(value)) {\n return value\n }\n if (value == null) {\n return []\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n const length = Math.max(0, Math.floor(value))\n return Array.from({ length }, (_, index) => index)\n }\n if (typeof value === 'object') {\n return Object.values(value)\n }\n return []\n}\n\nexport function escapeHtml(value: string) {\n
|
|
1
|
+
{"version":3,"file":"expression.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/expression.ts"],"sourcesContent":["import type { LegacyTemplateScope } from './types'\nimport { getRuntimeExecutionMode, warnRuntimeExecutionOnce } from '../execution'\n\nconst expressionCache = new Map<string, (scope: LegacyTemplateScope) => any>()\n\nexport function createScope(initial?: LegacyTemplateScope) {\n return Object.assign(Object.create(null), initial ?? {})\n}\n\nexport function createChildScope(parent: LegacyTemplateScope) {\n return Object.assign(Object.create(parent), {})\n}\n\nexport function normalizeList(value: any): any[] {\n if (Array.isArray(value)) {\n return value\n }\n if (value == null) {\n return []\n }\n if (typeof value === 'number' && Number.isFinite(value)) {\n const length = Math.max(0, Math.floor(value))\n return Array.from({ length }, (_, index) => index)\n }\n if (typeof value === 'object') {\n return Object.values(value)\n }\n return []\n}\n\nexport function escapeHtml(value: string) {\n const entities: Record<string, string> = {\n '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n '\\'': ''',\n }\n return value.replace(/[&<>\"']/g, (match) => {\n return entities[match]\n })\n}\n\nexport function escapeAttribute(value: string) {\n return escapeHtml(value)\n}\n\nfunction toDisplayString(value: any) {\n if (value == null) {\n return ''\n }\n if (typeof value === 'object') {\n if (value instanceof Date) {\n return value.toISOString()\n }\n try {\n return JSON.stringify(value)\n }\n catch {\n return String(value)\n }\n }\n return String(value)\n}\n\nfunction unwrapExpression(expression: string) {\n const trimmed = expression.trim()\n if (trimmed.startsWith('{{') && trimmed.endsWith('}}')) {\n return trimmed.slice(2, -2).trim()\n }\n return trimmed\n}\n\nexport function evaluateExpression(expression: string, scope: LegacyTemplateScope) {\n if (!expression) {\n return undefined\n }\n const trimmed = unwrapExpression(expression)\n if (!trimmed) {\n return undefined\n }\n let evaluator = expressionCache.get(trimmed)\n if (!evaluator) {\n try {\n // eslint-disable-next-line no-new-func -- dynamic expressions are required for template evaluation\n evaluator = new Function('scope', `with(scope){ return (${trimmed}); }`) as (scope: LegacyTemplateScope) => any\n }\n catch (error) {\n const reason = error instanceof Error ? error.message : String(error)\n const mode = getRuntimeExecutionMode()\n if (mode === 'safe') {\n warnRuntimeExecutionOnce(\n `safe-legacy-expression-parse:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式解析错误 \"${trimmed}\": ${reason}`,\n )\n evaluator = () => undefined\n }\n else {\n throw new SyntaxError(`[@weapp-vite/web] 无法解析表达式 \"${trimmed}\": ${reason}`)\n }\n }\n expressionCache.set(trimmed, evaluator)\n }\n try {\n return evaluator?.(scope)\n }\n catch (error) {\n const mode = getRuntimeExecutionMode()\n if (mode === 'strict') {\n const reason = error instanceof Error ? error.message : String(error)\n throw new Error(`[@weapp-vite/web] strict 模式下表达式执行失败 \"${trimmed}\": ${reason}`)\n }\n if (mode === 'safe') {\n const reason = error instanceof Error ? error.message : String(error)\n warnRuntimeExecutionOnce(\n `safe-legacy-expression-runtime:${trimmed}`,\n `[@weapp-vite/web] safe 模式下忽略表达式执行错误 \"${trimmed}\": ${reason}`,\n )\n }\n return undefined\n }\n}\n\nexport function interpolateText(source: string, scope: LegacyTemplateScope, escapeResult: boolean) {\n if (!source.includes('{{')) {\n return escapeResult ? escapeHtml(source) : source\n }\n\n let cursor = 0\n let buffer = ''\n\n while (cursor < source.length) {\n const start = source.indexOf('{{', cursor)\n if (start === -1) {\n buffer += source.slice(cursor)\n break\n }\n\n buffer += source.slice(cursor, start)\n\n const end = source.indexOf('}}', start + 2)\n if (end === -1) {\n buffer += source.slice(start)\n break\n }\n\n const expression = source.slice(start + 2, end).trim()\n const evaluated = toDisplayString(evaluateExpression(expression, scope))\n buffer += evaluated\n cursor = end + 2\n }\n\n return escapeResult ? escapeHtml(buffer) : buffer\n}\n\nexport function resolveAttributeValue(value: string, scope: LegacyTemplateScope) {\n return interpolateText(value ?? '', scope, false)\n}\n"],"mappings":";;;AAGA,MAAM,kCAAkB,IAAI,IAAiD;AAE7E,SAAgB,YAAY,SAA+B;CACzD,OAAO,OAAO,OAAO,OAAO,OAAO,IAAI,GAAG,WAAW,CAAC,CAAC;AACzD;AAEA,SAAgB,iBAAiB,QAA6B;CAC5D,OAAO,OAAO,OAAO,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;AAChD;AAEA,SAAgB,cAAc,OAAmB;CAC/C,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO;CAET,IAAI,SAAS,MACX,OAAO,CAAC;CAEV,IAAI,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG;EACvD,MAAM,SAAS,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;EAC5C,OAAO,MAAM,KAAK,EAAE,OAAO,IAAI,GAAG,UAAU,KAAK;CACnD;CACA,IAAI,OAAO,UAAU,UACnB,OAAO,OAAO,OAAO,KAAK;CAE5B,OAAO,CAAC;AACV;AAEA,SAAgB,WAAW,OAAe;CACxC,MAAM,WAAmC;EACvC,KAAK;EACL,KAAK;EACL,KAAK;EACL,MAAK;EACL,KAAM;CACR;CACA,OAAO,MAAM,QAAQ,aAAa,UAAU;EAC1C,OAAO,SAAS;CAClB,CAAC;AACH;AAEA,SAAgB,gBAAgB,OAAe;CAC7C,OAAO,WAAW,KAAK;AACzB;AAEA,SAAS,gBAAgB,OAAY;CACnC,IAAI,SAAS,MACX,OAAO;CAET,IAAI,OAAO,UAAU,UAAU;EAC7B,IAAI,iBAAiB,MACnB,OAAO,MAAM,YAAY;EAE3B,IAAI;GACF,OAAO,KAAK,UAAU,KAAK;EAC7B,QACM;GACJ,OAAO,OAAO,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MAAM,IAAI;CAG7C,IAAI,SAAS;CACb,IAAI,SAAS;CAEb,OAAO,SAAS,OAAO,QAAQ;EAC7B,MAAM,QAAQ,OAAO,QAAQ,MAAM,MAAM;EACzC,IAAI,UAAU,IAAI;GAChB,UAAU,OAAO,MAAM,MAAM;GAC7B;EACF;EAEA,UAAU,OAAO,MAAM,QAAQ,KAAK;EAEpC,MAAM,MAAM,OAAO,QAAQ,MAAM,QAAQ,CAAC;EAC1C,IAAI,QAAQ,IAAI;GACd,UAAU,OAAO,MAAM,KAAK;GAC5B;EACF;EAGA,MAAM,YAAY,gBAAgB,mBADf,OAAO,MAAM,QAAQ,GAAG,GAAG,CAAC,CAAC,KACc,GAAG,KAAK,CAAC;EACvE,UAAU;EACV,SAAS,MAAM;CACjB;CAEA,OAAO,eAAe,WAAW,MAAM,IAAI;AAC7C;AAEA,SAAgB,sBAAsB,OAAe,OAA4B;CAC/E,OAAO,gBAAgB,SAAS,IAAI,OAAO,KAAK;AAClD"}
|
|
@@ -7,17 +7,17 @@ import { parseDocument } from "htmlparser2";
|
|
|
7
7
|
const templateCache = /* @__PURE__ */ new Map();
|
|
8
8
|
function filterRenderableNode(node) {
|
|
9
9
|
if (node.type === "directive" || node.type === "comment") return false;
|
|
10
|
-
if (node.type === "text") return
|
|
10
|
+
if (node.type === "text") return node.data.trim().length > 0;
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
function getOrParseTemplate(source) {
|
|
14
14
|
let cached = templateCache.get(source);
|
|
15
15
|
if (!cached) {
|
|
16
|
-
cached =
|
|
16
|
+
cached = parseDocument(source, {
|
|
17
17
|
xmlMode: true,
|
|
18
18
|
decodeEntities: true,
|
|
19
19
|
recognizeSelfClosing: true
|
|
20
|
-
}).children
|
|
20
|
+
}).children.filter(filterRenderableNode);
|
|
21
21
|
templateCache.set(source, cached);
|
|
22
22
|
}
|
|
23
23
|
return cached;
|
|
@@ -29,7 +29,7 @@ function renderConditionalSequence(nodes, startIndex, scope, renderChildren) {
|
|
|
29
29
|
const candidate = nodes[cursor];
|
|
30
30
|
if (!isConditionalElement(candidate)) break;
|
|
31
31
|
const element = candidate;
|
|
32
|
-
const attribs = element.attribs
|
|
32
|
+
const attribs = element.attribs;
|
|
33
33
|
if (branches.length === 0 && !hasControlAttribute(attribs, "if")) break;
|
|
34
34
|
if (branches.length > 0 && !hasControlAttribute(attribs, "elif") && !hasControlAttribute(attribs, "else")) break;
|
|
35
35
|
branches.push({
|
|
@@ -64,7 +64,7 @@ function renderConditionalSequence(nodes, startIndex, scope, renderChildren) {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
function renderElement(node, scope, renderChildren, options = {}) {
|
|
67
|
-
const attribs = node.attribs
|
|
67
|
+
const attribs = node.attribs;
|
|
68
68
|
if (!options.skipFor) {
|
|
69
69
|
const forExtract = extractFor(attribs);
|
|
70
70
|
if (forExtract.expr) {
|
|
@@ -93,7 +93,7 @@ function renderElement(node, scope, renderChildren, options = {}) {
|
|
|
93
93
|
return `<${normalizedTag}${attrs}>${children}</${normalizedTag}>`;
|
|
94
94
|
}
|
|
95
95
|
function renderTextNode(node, scope) {
|
|
96
|
-
const value = node.data
|
|
96
|
+
const value = node.data;
|
|
97
97
|
if (!value.trim()) return "";
|
|
98
98
|
return interpolateText(value, scope, true);
|
|
99
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/index.ts"],"sourcesContent":["import type { ChildNode, DataNode, Element, Node } from 'domhandler'\nimport type {\n LegacyTemplateRenderer,\n LegacyTemplateScope,\n RenderOptions,\n} from './types'\nimport { parseDocument } from 'htmlparser2'\nimport {\n hasControlAttribute,\n normalizeTagName,\n resolveControlAttributeValue,\n SELF_CLOSING_TAGS,\n} from '../../shared/wxml'\nimport {\n buildAttributeString,\n extractFor,\n isConditionalElement,\n stripControlAttributes,\n} from './dom'\nimport {\n createChildScope,\n createScope,\n evaluateExpression,\n interpolateText,\n normalizeList,\n} from './expression'\n\nconst templateCache = new Map<string, ChildNode[]>()\n\nfunction filterRenderableNode(node: Node) {\n if (node.type === 'directive' || node.type === 'comment') {\n return false\n }\n if (node.type === 'text') {\n const data = (node as DataNode).data
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/runtime/legacyTemplate/index.ts"],"sourcesContent":["import type { ChildNode, DataNode, Element, Node } from 'domhandler'\nimport type {\n LegacyTemplateRenderer,\n LegacyTemplateScope,\n RenderOptions,\n} from './types'\nimport { parseDocument } from 'htmlparser2'\nimport {\n hasControlAttribute,\n normalizeTagName,\n resolveControlAttributeValue,\n SELF_CLOSING_TAGS,\n} from '../../shared/wxml'\nimport {\n buildAttributeString,\n extractFor,\n isConditionalElement,\n stripControlAttributes,\n} from './dom'\nimport {\n createChildScope,\n createScope,\n evaluateExpression,\n interpolateText,\n normalizeList,\n} from './expression'\n\nconst templateCache = new Map<string, ChildNode[]>()\n\nfunction filterRenderableNode(node: Node) {\n if (node.type === 'directive' || node.type === 'comment') {\n return false\n }\n if (node.type === 'text') {\n const data = (node as DataNode).data\n return data.trim().length > 0\n }\n return true\n}\n\nfunction getOrParseTemplate(source: string) {\n let cached = templateCache.get(source)\n if (!cached) {\n const document = parseDocument(source, {\n xmlMode: true,\n decodeEntities: true,\n recognizeSelfClosing: true,\n })\n cached = document.children.filter(filterRenderableNode)\n templateCache.set(source, cached)\n }\n return cached\n}\n\nfunction renderConditionalSequence(\n nodes: ChildNode[],\n startIndex: number,\n scope: LegacyTemplateScope,\n renderChildren: (input: ChildNode[] | ChildNode | undefined, scope: LegacyTemplateScope) => string,\n) {\n const branches: Array<{ node: Element, attribs: Record<string, string> }> = []\n let cursor = startIndex\n\n while (cursor < nodes.length) {\n const candidate = nodes[cursor]\n if (!isConditionalElement(candidate)) {\n break\n }\n const element = candidate as Element\n const attribs = element.attribs\n if (branches.length === 0 && !hasControlAttribute(attribs, 'if')) {\n break\n }\n if (branches.length > 0 && !hasControlAttribute(attribs, 'elif') && !hasControlAttribute(attribs, 'else')) {\n break\n }\n branches.push({ node: element, attribs })\n cursor += 1\n if (hasControlAttribute(attribs, 'else')) {\n break\n }\n }\n\n if (!branches.length) {\n const node = nodes[startIndex]\n return {\n rendered: renderChildren(node, scope),\n endIndex: startIndex,\n }\n }\n\n for (const { node, attribs } of branches) {\n if (hasControlAttribute(attribs, 'else')) {\n return {\n // eslint-disable-next-line ts/no-use-before-define -- 条件分支与普通节点复用同一元素渲染逻辑。\n rendered: renderElement(\n node,\n scope,\n renderChildren,\n { overrideAttribs: stripControlAttributes(attribs) },\n ),\n endIndex: startIndex + branches.length - 1,\n }\n }\n const conditionExpr = resolveControlAttributeValue(attribs, 'if')\n ?? resolveControlAttributeValue(attribs, 'elif')\n if (!conditionExpr) {\n continue\n }\n const condition = evaluateExpression(conditionExpr, scope)\n if (condition) {\n return {\n // eslint-disable-next-line ts/no-use-before-define -- 条件分支与普通节点复用同一元素渲染逻辑。\n rendered: renderElement(\n node,\n scope,\n renderChildren,\n { overrideAttribs: stripControlAttributes(attribs) },\n ),\n endIndex: startIndex + branches.length - 1,\n }\n }\n }\n\n return {\n rendered: '',\n endIndex: startIndex + branches.length - 1,\n }\n}\n\nfunction renderElement(\n node: Element,\n scope: LegacyTemplateScope,\n renderChildren: (nodes: ChildNode[] | undefined, scope: LegacyTemplateScope) => string,\n options: RenderOptions = {},\n) {\n const attribs = node.attribs\n if (!options.skipFor) {\n const forExtract = extractFor(attribs)\n if (forExtract.expr) {\n const list = normalizeList(evaluateExpression(forExtract.expr, scope))\n if (!list.length) {\n return ''\n }\n let buffer = ''\n for (let idx = 0; idx < list.length; idx++) {\n const item = list[idx]\n const childScope = createChildScope(scope)\n childScope[forExtract.itemName] = item\n childScope[forExtract.indexName] = idx\n buffer += renderElement(node, childScope, renderChildren, {\n skipFor: true,\n overrideAttribs: forExtract.restAttribs,\n })\n }\n return buffer\n }\n }\n\n const effectiveAttribs = options.overrideAttribs ?? attribs\n const normalizedTag = normalizeTagName(node.name)\n if (normalizedTag === '#fragment') {\n return renderChildren(node.children, scope)\n }\n\n const attrs = buildAttributeString(effectiveAttribs, scope)\n const children = renderChildren(node.children, scope)\n\n if (SELF_CLOSING_TAGS.has(normalizedTag) && !children) {\n return `<${normalizedTag}${attrs} />`\n }\n\n return `<${normalizedTag}${attrs}>${children}</${normalizedTag}>`\n}\n\nfunction renderTextNode(node: DataNode, scope: LegacyTemplateScope) {\n const value = node.data\n if (!value.trim()) {\n return ''\n }\n return interpolateText(value, scope, true)\n}\n\nfunction renderTree(\n input: ChildNode[] | ChildNode | undefined,\n scope: LegacyTemplateScope,\n): string {\n if (!input) {\n return ''\n }\n\n if (Array.isArray(input)) {\n let buffer = ''\n for (let index = 0; index < input.length; index++) {\n const node = input[index]\n if (isConditionalElement(node)) {\n const { rendered, endIndex } = renderConditionalSequence(input, index, scope, renderTree)\n buffer += rendered\n index = endIndex\n continue\n }\n buffer += renderTree(node, scope)\n }\n return buffer\n }\n\n const node = input\n if (node.type === 'text') {\n return renderTextNode(node as DataNode, scope)\n }\n if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {\n return renderElement(node as Element, scope, renderTree)\n }\n if ('children' in node && node.children?.length) {\n return renderTree(node.children, scope)\n }\n return ''\n}\n\nexport function renderTemplate(nodes: ChildNode[], scope?: LegacyTemplateScope) {\n const renderScope = createScope(scope)\n return renderTree(nodes, renderScope)\n}\n\nexport function createTemplate(source: string): LegacyTemplateRenderer {\n const nodes = getOrParseTemplate(source)\n return (scope?: LegacyTemplateScope) => renderTemplate(nodes, scope)\n}\n\nexport type { LegacyTemplateRenderer, LegacyTemplateScope } from './types'\n"],"mappings":";;;;;;AA2BA,MAAM,gCAAgB,IAAI,IAAyB;AAEnD,SAAS,qBAAqB,MAAY;CACxC,IAAI,KAAK,SAAS,eAAe,KAAK,SAAS,WAC7C,OAAO;CAET,IAAI,KAAK,SAAS,QAEhB,OADc,KAAkB,KACpB,KAAK,CAAC,CAAC,SAAS;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AAI,CAAC,OACH,OAAO;CAGT,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,IAAI,SAAS;EACb,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;GACjD,MAAM,OAAO,MAAM;GACnB,IAAI,qBAAqB,IAAI,GAAG;IAC9B,MAAM,EAAE,UAAU,aAAa,0BAA0B,OAAO,OAAO,OAAO,UAAU;IACxF,UAAU;IACV,QAAQ;IACR;GACF;GACA,UAAU,WAAW,MAAM,KAAK;EAClC;EACA,OAAO;CACT;CAEA,MAAM,OAAO;CACb,IAAI,KAAK,SAAS,QAChB,OAAO,eAAe,MAAkB,KAAK;CAE/C,IAAI,KAAK,SAAS,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS,SACjE,OAAO,cAAc,MAAiB,OAAO,UAAU;CAEzD,IAAI,cAAc,QAAQ,KAAK,UAAU,QACvC,OAAO,WAAW,KAAK,UAAU,KAAK;CAExC,OAAO;AACT;AAEA,SAAgB,eAAe,OAAoB,OAA6B;CAE9E,OAAO,WAAW,OADE,YAAY,KACG,CAAC;AACtC;AAEA,SAAgB,eAAe,QAAwC;CACrE,MAAM,QAAQ,mBAAmB,MAAM;CACvC,QAAQ,UAAgC,eAAe,OAAO,KAAK;AACrE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../../shared/nativeComponents.mjs";
|
|
2
|
+
import { readBooleanAttribute, resolveContainingShadowRoot } from "../helpers.mjs";
|
|
3
|
+
import { ensureNativeComponentStyle } from "../style.mjs";
|
|
4
|
+
import { registerNativeMediaElement, unregisterNativeMediaElement } from "../mediaRegistry.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/runtime/nativeComponents/canvas/index.ts
|
|
7
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
8
|
+
function resolveCanvasSize(value, fallback) {
|
|
9
|
+
const size = Number(value);
|
|
10
|
+
return Number.isInteger(size) && size > 0 ? size : fallback;
|
|
11
|
+
}
|
|
12
|
+
var WeappCanvas = class extends BaseElement {
|
|
13
|
+
static observedAttributes = [...getNativeComponentDescriptor("canvas").attributes];
|
|
14
|
+
#canvas;
|
|
15
|
+
get canvasElement() {
|
|
16
|
+
return this.#canvas;
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
20
|
+
this.#ensureStructure();
|
|
21
|
+
this.#syncAttributes();
|
|
22
|
+
}
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
if (this.#canvas) unregisterNativeMediaElement(this.#canvas);
|
|
25
|
+
}
|
|
26
|
+
attributeChangedCallback() {
|
|
27
|
+
this.#syncAttributes();
|
|
28
|
+
}
|
|
29
|
+
#ensureStructure() {
|
|
30
|
+
if (this.#canvas || typeof document === "undefined") return;
|
|
31
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
32
|
+
const style = document.createElement("style");
|
|
33
|
+
style.textContent = `
|
|
34
|
+
:host { position: relative; }
|
|
35
|
+
canvas { display: block; }
|
|
36
|
+
`;
|
|
37
|
+
const canvas = document.createElement("canvas");
|
|
38
|
+
root.append(style, canvas);
|
|
39
|
+
this.#canvas = canvas;
|
|
40
|
+
}
|
|
41
|
+
#syncAttributes() {
|
|
42
|
+
const canvas = this.#canvas;
|
|
43
|
+
if (!canvas) return;
|
|
44
|
+
canvas.width = resolveCanvasSize(this.getAttribute("width"), 300);
|
|
45
|
+
canvas.height = resolveCanvasSize(this.getAttribute("height"), 150);
|
|
46
|
+
canvas.style.touchAction = readBooleanAttribute(this, "disable-scroll") ? "none" : "";
|
|
47
|
+
registerNativeMediaElement("canvas", [this.getAttribute("canvas-id"), this.getAttribute("id")], canvas);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { WeappCanvas };
|
|
53
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["#canvas","#ensureStructure","#syncAttributes"],"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,KAAKA;CACd;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,KAAKC,iBAAiB;EACtB,KAAKC,gBAAgB;CACvB;CAEA,uBAAuB;EACrB,IAAI,KAAKF,SACP,6BAA6B,KAAKA,OAAO;CAE7C;CAEA,2BAA2B;EACzB,KAAKE,gBAAgB;CACvB;CAEA,mBAAmB;EACjB,IAAI,KAAKF,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,KAAKA,UAAU;CACjB;CAEA,kBAAkB;EAChB,MAAM,SAAS,KAAKA;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"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../shared/nativeComponents.mjs";
|
|
2
|
+
import { connectFormControl, disconnectFormControl, findClosestComposedElement } from "./formControl.mjs";
|
|
3
|
+
import { dispatchMiniProgramEvent, readBooleanAttribute, resolveContainingShadowRoot } from "./helpers.mjs";
|
|
4
|
+
import { ensureNativeComponentStyle } from "./style.mjs";
|
|
5
|
+
|
|
6
|
+
//#region src/runtime/nativeComponents/checkbox.ts
|
|
7
|
+
const BaseElement = globalThis.HTMLElement ?? class {};
|
|
8
|
+
function collectCheckboxGroupValue(checkboxes) {
|
|
9
|
+
return Array.from(checkboxes).filter((checkbox) => checkbox.checked && !checkbox.disabled).map((checkbox) => checkbox.value);
|
|
10
|
+
}
|
|
11
|
+
var WeappCheckboxGroup = class extends BaseElement {
|
|
12
|
+
static observedAttributes = [...getNativeComponentDescriptor("checkbox-group").attributes];
|
|
13
|
+
get formControlName() {
|
|
14
|
+
return this.getAttribute("name") ?? "";
|
|
15
|
+
}
|
|
16
|
+
get formControlValue() {
|
|
17
|
+
return collectCheckboxGroupValue(this.querySelectorAll("weapp-checkbox"));
|
|
18
|
+
}
|
|
19
|
+
get formControlDisabled() {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
24
|
+
connectFormControl(this);
|
|
25
|
+
}
|
|
26
|
+
disconnectedCallback() {
|
|
27
|
+
disconnectFormControl(this);
|
|
28
|
+
}
|
|
29
|
+
formReset() {
|
|
30
|
+
for (const checkbox of this.querySelectorAll("weapp-checkbox")) checkbox.formReset();
|
|
31
|
+
}
|
|
32
|
+
notifyCheckboxChange() {
|
|
33
|
+
dispatchMiniProgramEvent(this, "change", { value: this.formControlValue });
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var WeappCheckbox = class extends BaseElement {
|
|
37
|
+
static observedAttributes = [...getNativeComponentDescriptor("checkbox").attributes];
|
|
38
|
+
#input;
|
|
39
|
+
#initialChecked = false;
|
|
40
|
+
#initialCheckedCaptured = false;
|
|
41
|
+
get value() {
|
|
42
|
+
return this.getAttribute("value") ?? "";
|
|
43
|
+
}
|
|
44
|
+
set value(value) {
|
|
45
|
+
this.setAttribute("value", value ?? "");
|
|
46
|
+
}
|
|
47
|
+
get checked() {
|
|
48
|
+
return this.#input?.checked ?? readBooleanAttribute(this, "checked");
|
|
49
|
+
}
|
|
50
|
+
set checked(value) {
|
|
51
|
+
this.toggleAttribute("checked", Boolean(value));
|
|
52
|
+
}
|
|
53
|
+
get disabled() {
|
|
54
|
+
return readBooleanAttribute(this, "disabled");
|
|
55
|
+
}
|
|
56
|
+
connectedCallback() {
|
|
57
|
+
ensureNativeComponentStyle(resolveContainingShadowRoot(this));
|
|
58
|
+
if (!this.#initialCheckedCaptured) {
|
|
59
|
+
this.#initialChecked = readBooleanAttribute(this, "checked");
|
|
60
|
+
this.#initialCheckedCaptured = true;
|
|
61
|
+
}
|
|
62
|
+
this.#ensureStructure();
|
|
63
|
+
this.#syncAttributes();
|
|
64
|
+
}
|
|
65
|
+
attributeChangedCallback() {
|
|
66
|
+
this.#syncAttributes();
|
|
67
|
+
}
|
|
68
|
+
formReset() {
|
|
69
|
+
this.setCheckedFromGroup(this.#initialChecked);
|
|
70
|
+
}
|
|
71
|
+
formActivate() {
|
|
72
|
+
if (!this.disabled) this.#input?.click();
|
|
73
|
+
}
|
|
74
|
+
setCheckedFromGroup(checked) {
|
|
75
|
+
if (this.#input) this.#input.checked = checked;
|
|
76
|
+
}
|
|
77
|
+
#ensureStructure() {
|
|
78
|
+
if (this.#input || typeof document === "undefined") return;
|
|
79
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
80
|
+
const style = document.createElement("style");
|
|
81
|
+
style.textContent = `
|
|
82
|
+
:host { --weapp-control-color: #07c160; }
|
|
83
|
+
label { display: inline-flex; align-items: center; cursor: pointer; }
|
|
84
|
+
input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
|
|
85
|
+
.control {
|
|
86
|
+
position: relative;
|
|
87
|
+
box-sizing: border-box;
|
|
88
|
+
width: 23px;
|
|
89
|
+
height: 23px;
|
|
90
|
+
flex: 0 0 23px;
|
|
91
|
+
border: 1px solid #d1d1d1;
|
|
92
|
+
border-radius: 3px;
|
|
93
|
+
background: #ffffff;
|
|
94
|
+
}
|
|
95
|
+
input:checked + .control { border-color: var(--weapp-control-color); background: var(--weapp-control-color); }
|
|
96
|
+
input:checked + .control::after {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 3px;
|
|
99
|
+
left: 7px;
|
|
100
|
+
width: 6px;
|
|
101
|
+
height: 11px;
|
|
102
|
+
border: solid #ffffff;
|
|
103
|
+
border-width: 0 2px 2px 0;
|
|
104
|
+
content: '';
|
|
105
|
+
transform: rotate(45deg);
|
|
106
|
+
}
|
|
107
|
+
input:disabled + .control { border-color: #d8d8d8; background: #eeeeee; opacity: 0.7; }
|
|
108
|
+
.content { margin-left: 8px; }
|
|
109
|
+
`;
|
|
110
|
+
const label = document.createElement("label");
|
|
111
|
+
const input = document.createElement("input");
|
|
112
|
+
input.type = "checkbox";
|
|
113
|
+
const control = document.createElement("span");
|
|
114
|
+
control.className = "control";
|
|
115
|
+
const content = document.createElement("span");
|
|
116
|
+
content.className = "content";
|
|
117
|
+
content.append(document.createElement("slot"));
|
|
118
|
+
input.addEventListener("change", (event) => {
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
findClosestComposedElement(this, "weapp-checkbox-group")?.notifyCheckboxChange();
|
|
121
|
+
});
|
|
122
|
+
label.append(input, control, content);
|
|
123
|
+
root.append(style, label);
|
|
124
|
+
this.#input = input;
|
|
125
|
+
}
|
|
126
|
+
#syncAttributes() {
|
|
127
|
+
if (!this.#input) return;
|
|
128
|
+
this.#input.checked = readBooleanAttribute(this, "checked");
|
|
129
|
+
this.#input.disabled = this.disabled;
|
|
130
|
+
this.#input.value = this.value;
|
|
131
|
+
this.style.setProperty("--weapp-control-color", this.getAttribute("color") || "#07c160");
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
export { WeappCheckbox, WeappCheckboxGroup, collectCheckboxGroupValue };
|
|
137
|
+
//# sourceMappingURL=checkbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.mjs","names":["#input","#initialCheckedCaptured","#initialChecked","#ensureStructure","#syncAttributes"],"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,6BAA6B,gBAAgB,CAAC,CAAE,UAAU;CAE1F,IAAI,kBAAkB;EACpB,OAAO,KAAK,aAAa,MAAM,KAAK;CACtC;CAEA,IAAI,mBAAmB;EACrB,OAAO,0BAA0B,KAAK,iBAAgC,gBAAgB,CAAC;CACzF;CAEA,IAAI,sBAAsB;EACxB,OAAO;CACT;CAEA,oBAAoB;EAClB,2BAA2B,4BAA4B,IAAI,CAAC;EAC5D,mBAAmB,IAAI;CACzB;CAEA,uBAAuB;EACrB,sBAAsB,IAAI;CAC5B;CAEA,YAAY;EACV,KAAK,MAAM,YAAY,KAAK,iBAAgC,gBAAgB,GAC1E,SAAS,UAAU;CAEvB;CAEA,uBAAuB;EACrB,yBAAyB,MAAM,UAAU,EAAE,OAAO,KAAK,iBAAiB,CAAC;CAC3E;AACF;AAEA,IAAa,gBAAb,cAAmC,YAAY;CAC7C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,UAAU,CAAC,CAAE,UAAU;CAEpF;CACA,kBAAkB;CAClB,0BAA0B;CAE1B,IAAI,QAAQ;EACV,OAAO,KAAK,aAAa,OAAO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C1C,MAAM,gBAAgB;GAEtB,AADc,2BAA2B,MAAM,sBAC3C,CAAC,EAAE,qBAAqB;EAC9B,CAAC;EACD,MAAM,OAAO,OAAO,SAAS,OAAO;EACpC,KAAK,OAAO,OAAO,KAAK;EACxB,KAAKA,SAAS;CAChB;CAEA,kBAAkB;EAChB,IAAI,CAAC,KAAKA,QACR;EAEF,KAAKA,OAAO,UAAU,qBAAqB,MAAM,SAAS;EAC1D,KAAKA,OAAO,WAAW,KAAK;EAC5B,KAAKA,OAAO,QAAQ,KAAK;EACzB,KAAK,MAAM,YAAY,yBAAyB,KAAK,aAAa,OAAO,KAAK,SAAS;CACzF;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getNativeComponentDescriptor } from "../../../shared/nativeComponents.mjs";
|
|
2
|
+
import { WeappImage } from "../image.mjs";
|
|
3
|
+
import { WeappView } from "../primitives.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/runtime/nativeComponents/cover/index.ts
|
|
6
|
+
var WeappCoverView = class extends WeappView {
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
super.connectedCallback();
|
|
9
|
+
this.style.zIndex = "2";
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
var WeappCoverImage = class extends WeappImage {
|
|
13
|
+
static observedAttributes = [...getNativeComponentDescriptor("cover-image").attributes];
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
super.connectedCallback();
|
|
16
|
+
this.style.position = "absolute";
|
|
17
|
+
this.style.zIndex = "2";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { WeappCoverImage, WeappCoverView };
|
|
23
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/runtime/nativeComponents/cover/index.ts"],"sourcesContent":["import { getNativeComponentDescriptor } from '../../../shared/nativeComponents'\nimport { WeappImage } from '../image'\nimport { WeappView } from '../primitives'\n\nexport class WeappCoverView extends WeappView {\n connectedCallback() {\n super.connectedCallback()\n this.style.zIndex = '2'\n }\n}\n\nexport class WeappCoverImage extends WeappImage {\n static observedAttributes = [...getNativeComponentDescriptor('cover-image')!.attributes]\n\n connectedCallback() {\n super.connectedCallback()\n this.style.position = 'absolute'\n this.style.zIndex = '2'\n }\n}\n"],"mappings":";;;;;AAIA,IAAa,iBAAb,cAAoC,UAAU;CAC5C,oBAAoB;EAClB,MAAM,kBAAkB;EACxB,KAAK,MAAM,SAAS;CACtB;AACF;AAEA,IAAa,kBAAb,cAAqC,WAAW;CAC9C,OAAO,qBAAqB,CAAC,GAAG,6BAA6B,aAAa,CAAC,CAAE,UAAU;CAEvF,oBAAoB;EAClB,MAAM,kBAAkB;EACxB,KAAK,MAAM,WAAW;EACtB,KAAK,MAAM,SAAS;CACtB;AACF"}
|