@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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResolvedWebViewportConfig, WebViewportConfig } from "./types.mjs";
|
|
2
|
+
//#region src/runtime/viewport/index.d.ts
|
|
3
|
+
declare function resolveWebViewportConfig(config?: WebViewportConfig): ResolvedWebViewportConfig;
|
|
4
|
+
declare function setupWebViewport(config?: WebViewportConfig): {
|
|
5
|
+
mode: "mini-program" | "responsive";
|
|
6
|
+
maxWidth: number;
|
|
7
|
+
desktopBreakpoint: number;
|
|
8
|
+
};
|
|
9
|
+
declare function getWebViewportWidth(): number;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type ResolvedWebViewportConfig, type WebViewportConfig, getWebViewportWidth, resolveWebViewportConfig, setupWebViewport };
|
|
12
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { WEB_VIEWPORT_STYLE_ID, createWebViewportStyle } from "./style.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/runtime/viewport/index.ts
|
|
4
|
+
const DEFAULT_VIEWPORT_CONFIG = {
|
|
5
|
+
mode: "mini-program",
|
|
6
|
+
maxWidth: 375,
|
|
7
|
+
desktopBreakpoint: 600
|
|
8
|
+
};
|
|
9
|
+
let resolvedConfig = { ...DEFAULT_VIEWPORT_CONFIG };
|
|
10
|
+
function resolvePositiveNumber(value, fallback) {
|
|
11
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : fallback;
|
|
12
|
+
}
|
|
13
|
+
function resolveWebViewportConfig(config) {
|
|
14
|
+
return {
|
|
15
|
+
mode: config?.mode === "responsive" ? "responsive" : "mini-program",
|
|
16
|
+
maxWidth: resolvePositiveNumber(config?.maxWidth, DEFAULT_VIEWPORT_CONFIG.maxWidth),
|
|
17
|
+
desktopBreakpoint: resolvePositiveNumber(config?.desktopBreakpoint, DEFAULT_VIEWPORT_CONFIG.desktopBreakpoint)
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function setupWebViewport(config) {
|
|
21
|
+
resolvedConfig = resolveWebViewportConfig(config);
|
|
22
|
+
if (typeof document === "undefined") return resolvedConfig;
|
|
23
|
+
document.documentElement?.setAttribute("data-weapp-viewport-mode", resolvedConfig.mode);
|
|
24
|
+
let style = document.querySelector(`#${WEB_VIEWPORT_STYLE_ID}`);
|
|
25
|
+
if (!style) {
|
|
26
|
+
style = document.createElement("style");
|
|
27
|
+
style.id = WEB_VIEWPORT_STYLE_ID;
|
|
28
|
+
document.head?.append(style);
|
|
29
|
+
}
|
|
30
|
+
style.textContent = createWebViewportStyle(resolvedConfig);
|
|
31
|
+
return resolvedConfig;
|
|
32
|
+
}
|
|
33
|
+
function getWebViewportWidth() {
|
|
34
|
+
if (typeof document === "undefined") return 0;
|
|
35
|
+
const containerWidth = document.querySelector("#app")?.clientWidth ?? 0;
|
|
36
|
+
if (containerWidth > 0) return containerWidth;
|
|
37
|
+
const documentWidth = document.documentElement?.clientWidth ?? 0;
|
|
38
|
+
if (resolvedConfig.mode === "mini-program" && documentWidth >= resolvedConfig.desktopBreakpoint) return Math.min(documentWidth, resolvedConfig.maxWidth);
|
|
39
|
+
return documentWidth || (typeof window !== "undefined" ? window.innerWidth : 0);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport };
|
|
44
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/runtime/viewport/index.ts"],"sourcesContent":["import type { ResolvedWebViewportConfig, WebViewportConfig } from './types'\nimport { createWebViewportStyle, WEB_VIEWPORT_STYLE_ID } from './style'\n\nconst DEFAULT_VIEWPORT_CONFIG: ResolvedWebViewportConfig = {\n mode: 'mini-program',\n maxWidth: 375,\n desktopBreakpoint: 600,\n}\n\nlet resolvedConfig = { ...DEFAULT_VIEWPORT_CONFIG }\n\nfunction resolvePositiveNumber(value: number | undefined, fallback: number) {\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : fallback\n}\n\nexport function resolveWebViewportConfig(config?: WebViewportConfig): ResolvedWebViewportConfig {\n return {\n mode: config?.mode === 'responsive' ? 'responsive' : 'mini-program',\n maxWidth: resolvePositiveNumber(config?.maxWidth, DEFAULT_VIEWPORT_CONFIG.maxWidth),\n desktopBreakpoint: resolvePositiveNumber(config?.desktopBreakpoint, DEFAULT_VIEWPORT_CONFIG.desktopBreakpoint),\n }\n}\n\nexport function setupWebViewport(config?: WebViewportConfig) {\n resolvedConfig = resolveWebViewportConfig(config)\n if (typeof document === 'undefined') {\n return resolvedConfig\n }\n document.documentElement?.setAttribute('data-weapp-viewport-mode', resolvedConfig.mode)\n let style = document.querySelector(`#${WEB_VIEWPORT_STYLE_ID}`) as HTMLStyleElement | null\n if (!style) {\n style = document.createElement('style')\n style.id = WEB_VIEWPORT_STYLE_ID\n document.head?.append(style)\n }\n style.textContent = createWebViewportStyle(resolvedConfig)\n return resolvedConfig\n}\n\nexport function getWebViewportWidth() {\n if (typeof document === 'undefined') {\n return 0\n }\n const container = document.querySelector('#app') as HTMLElement | null\n const containerWidth = container?.clientWidth ?? 0\n if (containerWidth > 0) {\n return containerWidth\n }\n const documentWidth = document.documentElement?.clientWidth ?? 0\n if (resolvedConfig.mode === 'mini-program' && documentWidth >= resolvedConfig.desktopBreakpoint) {\n return Math.min(documentWidth, resolvedConfig.maxWidth)\n }\n return documentWidth || (typeof window !== 'undefined' ? window.innerWidth : 0)\n}\n\nexport type { ResolvedWebViewportConfig, WebViewportConfig } from './types'\n"],"mappings":";;;AAGA,MAAM,0BAAqD;CACzD,MAAM;CACN,UAAU;CACV,mBAAmB;AACrB;AAEA,IAAI,iBAAiB,EAAE,GAAG,wBAAwB;AAElD,SAAS,sBAAsB,OAA2B,UAAkB;CAC1E,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,QAAQ,IAAI,QAAQ;AACpF;AAEA,SAAgB,yBAAyB,QAAuD;CAC9F,OAAO;EACL,MAAM,QAAQ,SAAS,eAAe,eAAe;EACrD,UAAU,sBAAsB,QAAQ,UAAU,wBAAwB,QAAQ;EAClF,mBAAmB,sBAAsB,QAAQ,mBAAmB,wBAAwB,iBAAiB;CAC/G;AACF;AAEA,SAAgB,iBAAiB,QAA4B;CAC3D,iBAAiB,yBAAyB,MAAM;CAChD,IAAI,OAAO,aAAa,aACtB,OAAO;CAET,SAAS,iBAAiB,aAAa,4BAA4B,eAAe,IAAI;CACtF,IAAI,QAAQ,SAAS,cAAc,IAAI,uBAAuB;CAC9D,IAAI,CAAC,OAAO;EACV,QAAQ,SAAS,cAAc,OAAO;EACtC,MAAM,KAAK;EACX,SAAS,MAAM,OAAO,KAAK;CAC7B;CACA,MAAM,cAAc,uBAAuB,cAAc;CACzD,OAAO;AACT;AAEA,SAAgB,sBAAsB;CACpC,IAAI,OAAO,aAAa,aACtB,OAAO;CAGT,MAAM,iBADY,SAAS,cAAc,MACV,CAAC,EAAE,eAAe;CACjD,IAAI,iBAAiB,GACnB,OAAO;CAET,MAAM,gBAAgB,SAAS,iBAAiB,eAAe;CAC/D,IAAI,eAAe,SAAS,kBAAkB,iBAAiB,eAAe,mBAC5E,OAAO,KAAK,IAAI,eAAe,eAAe,QAAQ;CAExD,OAAO,kBAAkB,OAAO,WAAW,cAAc,OAAO,aAAa;AAC/E"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//#region src/runtime/viewport/style.ts
|
|
2
|
+
const WEB_VIEWPORT_STYLE_ID = "weapp-web-viewport-style";
|
|
3
|
+
function createWebViewportStyle(config) {
|
|
4
|
+
const maxWidth = `${config.maxWidth}px`;
|
|
5
|
+
return `
|
|
6
|
+
:root {
|
|
7
|
+
--weapp-viewport-width: 100vw;
|
|
8
|
+
--weapp-viewport-max-width: ${maxWidth};
|
|
9
|
+
--weapp-viewport-left: 0px;
|
|
10
|
+
--weapp-viewport-right: 0px;
|
|
11
|
+
--weapp-safe-area-inset-top: env(safe-area-inset-top, 0px);
|
|
12
|
+
--weapp-safe-area-inset-right: env(safe-area-inset-right, 0px);
|
|
13
|
+
--weapp-safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
|
|
14
|
+
--weapp-safe-area-inset-left: env(safe-area-inset-left, 0px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
html,
|
|
18
|
+
body {
|
|
19
|
+
min-width: 0;
|
|
20
|
+
height: 100%;
|
|
21
|
+
margin: 0;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
background: #f2f2f2;
|
|
27
|
+
font-family: Helvetica, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
#app {
|
|
31
|
+
--weapp-tab-bar-inset: 0px;
|
|
32
|
+
--weapp-tab-bar-top-inset: 0px;
|
|
33
|
+
position: relative;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
width: 100%;
|
|
36
|
+
height: 100dvh;
|
|
37
|
+
min-height: 0;
|
|
38
|
+
margin: 0 auto;
|
|
39
|
+
overflow: auto;
|
|
40
|
+
overscroll-behavior: contain;
|
|
41
|
+
background: #ffffff;
|
|
42
|
+
contain: layout paint;
|
|
43
|
+
transform: translateZ(0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@media (min-width: ${`${config.desktopBreakpoint}px`}) {
|
|
47
|
+
html[data-weapp-viewport-mode="mini-program"] {
|
|
48
|
+
--weapp-viewport-width: ${maxWidth};
|
|
49
|
+
--weapp-viewport-left: calc((100vw - ${maxWidth}) / 2);
|
|
50
|
+
--weapp-viewport-right: calc((100vw - ${maxWidth}) / 2);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
html[data-weapp-viewport-mode="mini-program"] #app {
|
|
54
|
+
width: ${maxWidth};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { WEB_VIEWPORT_STYLE_ID, createWebViewportStyle };
|
|
62
|
+
//# sourceMappingURL=style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../../src/runtime/viewport/style.ts"],"sourcesContent":["import type { ResolvedWebViewportConfig } from './types'\n\nexport const WEB_VIEWPORT_STYLE_ID = 'weapp-web-viewport-style'\n\nexport function createWebViewportStyle(config: ResolvedWebViewportConfig) {\n const maxWidth = `${config.maxWidth}px`\n const breakpoint = `${config.desktopBreakpoint}px`\n return `\n:root {\n --weapp-viewport-width: 100vw;\n --weapp-viewport-max-width: ${maxWidth};\n --weapp-viewport-left: 0px;\n --weapp-viewport-right: 0px;\n --weapp-safe-area-inset-top: env(safe-area-inset-top, 0px);\n --weapp-safe-area-inset-right: env(safe-area-inset-right, 0px);\n --weapp-safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);\n --weapp-safe-area-inset-left: env(safe-area-inset-left, 0px);\n}\n\nhtml,\nbody {\n min-width: 0;\n height: 100%;\n margin: 0;\n overflow: hidden;\n}\n\nbody {\n background: #f2f2f2;\n font-family: Helvetica, -apple-system, BlinkMacSystemFont, \"Helvetica Neue\", Arial, sans-serif;\n}\n\n#app {\n --weapp-tab-bar-inset: 0px;\n --weapp-tab-bar-top-inset: 0px;\n position: relative;\n box-sizing: border-box;\n width: 100%;\n height: 100dvh;\n min-height: 0;\n margin: 0 auto;\n overflow: auto;\n overscroll-behavior: contain;\n background: #ffffff;\n contain: layout paint;\n transform: translateZ(0);\n}\n\n@media (min-width: ${breakpoint}) {\n html[data-weapp-viewport-mode=\"mini-program\"] {\n --weapp-viewport-width: ${maxWidth};\n --weapp-viewport-left: calc((100vw - ${maxWidth}) / 2);\n --weapp-viewport-right: calc((100vw - ${maxWidth}) / 2);\n }\n\n html[data-weapp-viewport-mode=\"mini-program\"] #app {\n width: ${maxWidth};\n }\n}\n`\n}\n"],"mappings":";AAEA,MAAa,wBAAwB;AAErC,SAAgB,uBAAuB,QAAmC;CACxE,MAAM,WAAW,GAAG,OAAO,SAAS;CAEpC,OAAO;;;gCAGuB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAsCpB,GA1CG,OAAO,kBAAkB,IA0CjB;;8BAEF,SAAS;2CACI,SAAS;4CACR,SAAS;;;;aAIxC,SAAS;;;;AAItB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//#region src/runtime/viewport/types.d.ts
|
|
2
|
+
interface WebViewportConfig {
|
|
3
|
+
mode?: 'mini-program' | 'responsive';
|
|
4
|
+
maxWidth?: number;
|
|
5
|
+
desktopBreakpoint?: number;
|
|
6
|
+
}
|
|
7
|
+
interface ResolvedWebViewportConfig {
|
|
8
|
+
mode: 'mini-program' | 'responsive';
|
|
9
|
+
maxWidth: number;
|
|
10
|
+
desktopBreakpoint: number;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ResolvedWebViewportConfig, WebViewportConfig };
|
|
14
|
+
//# sourceMappingURL=types.d.mts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RegisterMeta } from "./polyfill/routeRuntime/options.mjs";
|
|
2
|
+
//#region src/runtime/wevu.d.ts
|
|
3
|
+
interface WevuRegisterMeta extends RegisterMeta {
|
|
4
|
+
kind: 'app' | 'page' | 'component';
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 将 Wevu App 注册过程接入 Web 页面栈。
|
|
8
|
+
*/
|
|
9
|
+
declare function registerWebWevuApp(options: Record<string, any>, meta: WevuRegisterMeta): void;
|
|
10
|
+
/**
|
|
11
|
+
* 将 Wevu 页面或组件注册过程接入 Web 自定义元素。
|
|
12
|
+
*/
|
|
13
|
+
declare function registerWebWevuComponent(options: Record<string, any>, meta: WevuRegisterMeta): void;
|
|
14
|
+
/**
|
|
15
|
+
* 在原生模块同步求值期间安装带页面元数据的宿主注册函数。
|
|
16
|
+
*/
|
|
17
|
+
declare function installWebModuleRegistration(meta: WevuRegisterMeta, target?: Record<string, any>): () => void;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent };
|
|
20
|
+
//# sourceMappingURL=wevu.d.mts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { registerApp, registerComponent, registerPage } from "./polyfill/routeRuntime.mjs";
|
|
2
|
+
import { createApp, createWevuComponent, takePendingRuntimeAppRegistration } from "wevu/internal-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/runtime/wevu.ts
|
|
5
|
+
function createRuntimeConstructor(meta, name) {
|
|
6
|
+
return (definition) => {
|
|
7
|
+
if (name === "App") registerApp(definition, meta);
|
|
8
|
+
else if (name === "Page" || meta.kind === "page") registerPage(definition, meta);
|
|
9
|
+
else registerComponent(definition, meta);
|
|
10
|
+
return definition;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function withRuntimeConstructor(name, constructor, run) {
|
|
14
|
+
const target = globalThis;
|
|
15
|
+
const hadOwn = Object.prototype.hasOwnProperty.call(target, name);
|
|
16
|
+
const previous = target[name];
|
|
17
|
+
target[name] = constructor;
|
|
18
|
+
try {
|
|
19
|
+
return run();
|
|
20
|
+
} finally {
|
|
21
|
+
if (hadOwn) target[name] = previous;
|
|
22
|
+
else delete target[name];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 将 Wevu App 注册过程接入 Web 页面栈。
|
|
27
|
+
*/
|
|
28
|
+
function registerWebWevuApp(options, meta) {
|
|
29
|
+
const pendingRegistration = takePendingRuntimeAppRegistration();
|
|
30
|
+
withRuntimeConstructor("App", (definition) => registerApp(definition, meta), () => {
|
|
31
|
+
if (pendingRegistration) {
|
|
32
|
+
pendingRegistration.register();
|
|
33
|
+
return pendingRegistration.app;
|
|
34
|
+
}
|
|
35
|
+
return createApp(options);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 将 Wevu 页面或组件注册过程接入 Web 自定义元素。
|
|
40
|
+
*/
|
|
41
|
+
function registerWebWevuComponent(options, meta) {
|
|
42
|
+
withRuntimeConstructor("Component", (definition) => {
|
|
43
|
+
return meta.kind === "page" ? registerPage(definition, meta) : registerComponent(definition, meta);
|
|
44
|
+
}, () => createWevuComponent(options));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 在原生模块同步求值期间安装带页面元数据的宿主注册函数。
|
|
48
|
+
*/
|
|
49
|
+
function installWebModuleRegistration(meta, target = globalThis) {
|
|
50
|
+
const names = meta.kind === "app" ? ["App"] : meta.kind === "page" ? ["Page", "Component"] : ["Component"];
|
|
51
|
+
const previous = names.map((name) => ({
|
|
52
|
+
hadOwn: Object.prototype.hasOwnProperty.call(target, name),
|
|
53
|
+
name,
|
|
54
|
+
value: target[name]
|
|
55
|
+
}));
|
|
56
|
+
const installed = /* @__PURE__ */ new Map();
|
|
57
|
+
for (const name of names) {
|
|
58
|
+
const constructor = createRuntimeConstructor(meta, name);
|
|
59
|
+
installed.set(name, constructor);
|
|
60
|
+
target[name] = constructor;
|
|
61
|
+
}
|
|
62
|
+
return () => {
|
|
63
|
+
for (const entry of previous) {
|
|
64
|
+
if (target[entry.name] !== installed.get(entry.name)) continue;
|
|
65
|
+
if (entry.hadOwn) target[entry.name] = entry.value;
|
|
66
|
+
else delete target[entry.name];
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent };
|
|
73
|
+
//# sourceMappingURL=wevu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wevu.mjs","names":[],"sources":["../../src/runtime/wevu.ts"],"sourcesContent":["import type { RegisterMeta } from './polyfill/routeRuntime/options'\nimport { createApp, createWevuComponent, takePendingRuntimeAppRegistration } from 'wevu/internal-runtime'\nimport { registerApp, registerComponent, registerPage } from './polyfill/routeRuntime'\n\ninterface WevuRegisterMeta extends RegisterMeta {\n kind: 'app' | 'page' | 'component'\n}\n\ntype RuntimeConstructorName = 'App' | 'Page' | 'Component'\n\nfunction createRuntimeConstructor(meta: WevuRegisterMeta, name: RuntimeConstructorName) {\n return (definition: Record<string, any>) => {\n if (name === 'App') {\n registerApp(definition, meta)\n }\n else if (name === 'Page' || meta.kind === 'page') {\n registerPage(definition, meta)\n }\n else {\n registerComponent(definition, meta)\n }\n return definition\n }\n}\n\nfunction withRuntimeConstructor<T>(\n name: 'App' | 'Component',\n constructor: (options: Record<string, any>) => unknown,\n run: () => T,\n) {\n const target = globalThis as Record<string, any>\n const hadOwn = Object.prototype.hasOwnProperty.call(target, name)\n const previous = target[name]\n target[name] = constructor\n try {\n return run()\n }\n finally {\n if (hadOwn) {\n target[name] = previous\n }\n else {\n delete target[name]\n }\n }\n}\n\n/**\n * 将 Wevu App 注册过程接入 Web 页面栈。\n */\nexport function registerWebWevuApp(options: Record<string, any>, meta: WevuRegisterMeta): void {\n const pendingRegistration = takePendingRuntimeAppRegistration()\n withRuntimeConstructor('App', definition => registerApp(definition, meta), () => {\n if (pendingRegistration) {\n pendingRegistration.register()\n return pendingRegistration.app\n }\n return createApp(options)\n })\n}\n\n/**\n * 将 Wevu 页面或组件注册过程接入 Web 自定义元素。\n */\nexport function registerWebWevuComponent(options: Record<string, any>, meta: WevuRegisterMeta): void {\n withRuntimeConstructor('Component', (definition) => {\n return meta.kind === 'page'\n ? registerPage(definition, meta)\n : registerComponent(definition, meta)\n }, () => createWevuComponent(options))\n}\n\n/**\n * 在原生模块同步求值期间安装带页面元数据的宿主注册函数。\n */\nexport function installWebModuleRegistration(\n meta: WevuRegisterMeta,\n target: Record<string, any> = globalThis,\n): () => void {\n const names: RuntimeConstructorName[] = meta.kind === 'app'\n ? ['App']\n : meta.kind === 'page'\n ? ['Page', 'Component']\n : ['Component']\n const previous = names.map(name => ({\n hadOwn: Object.prototype.hasOwnProperty.call(target, name),\n name,\n value: target[name],\n }))\n const installed = new Map<RuntimeConstructorName, (definition: Record<string, any>) => Record<string, any>>()\n\n for (const name of names) {\n const constructor = createRuntimeConstructor(meta, name)\n installed.set(name, constructor)\n target[name] = constructor\n }\n\n return () => {\n for (const entry of previous) {\n if (target[entry.name] !== installed.get(entry.name)) {\n continue\n }\n if (entry.hadOwn) {\n target[entry.name] = entry.value\n }\n else {\n delete target[entry.name]\n }\n }\n }\n}\n"],"mappings":";;;;AAUA,SAAS,yBAAyB,MAAwB,MAA8B;CACtF,QAAQ,eAAoC;EAC1C,IAAI,SAAS,OACX,YAAY,YAAY,IAAI;OAEzB,IAAI,SAAS,UAAU,KAAK,SAAS,QACxC,aAAa,YAAY,IAAI;OAG7B,kBAAkB,YAAY,IAAI;EAEpC,OAAO;CACT;AACF;AAEA,SAAS,uBACP,MACA,aACA,KACA;CACA,MAAM,SAAS;CACf,MAAM,SAAS,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;CAChE,MAAM,WAAW,OAAO;CACxB,OAAO,QAAQ;CACf,IAAI;EACF,OAAO,IAAI;CACb,UACQ;EACN,IAAI,QACF,OAAO,QAAQ;OAGf,OAAO,OAAO;CAElB;AACF;;;;AAKA,SAAgB,mBAAmB,SAA8B,MAA8B;CAC7F,MAAM,sBAAsB,kCAAkC;CAC9D,uBAAuB,QAAO,eAAc,YAAY,YAAY,IAAI,SAAS;EAC/E,IAAI,qBAAqB;GACvB,oBAAoB,SAAS;GAC7B,OAAO,oBAAoB;EAC7B;EACA,OAAO,UAAU,OAAO;CAC1B,CAAC;AACH;;;;AAKA,SAAgB,yBAAyB,SAA8B,MAA8B;CACnG,uBAAuB,cAAc,eAAe;EAClD,OAAO,KAAK,SAAS,SACjB,aAAa,YAAY,IAAI,IAC7B,kBAAkB,YAAY,IAAI;CACxC,SAAS,oBAAoB,OAAO,CAAC;AACvC;;;;AAKA,SAAgB,6BACd,MACA,SAA8B,YAClB;CACZ,MAAM,QAAkC,KAAK,SAAS,QAClD,CAAC,KAAK,IACN,KAAK,SAAS,SACZ,CAAC,QAAQ,WAAW,IACpB,CAAC,WAAW;CAClB,MAAM,WAAW,MAAM,KAAI,UAAS;EAClC,QAAQ,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI;EACzD;EACA,OAAO,OAAO;CAChB,EAAE;CACF,MAAM,4BAAY,IAAI,IAAsF;CAE5G,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,cAAc,yBAAyB,MAAM,IAAI;EACvD,UAAU,IAAI,MAAM,WAAW;EAC/B,OAAO,QAAQ;CACjB;CAEA,aAAa;EACX,KAAK,MAAM,SAAS,UAAU;GAC5B,IAAI,OAAO,MAAM,UAAU,UAAU,IAAI,MAAM,IAAI,GACjD;GAEF,IAAI,MAAM,QACR,OAAO,MAAM,QAAQ,MAAM;QAG3B,OAAO,OAAO,MAAM;EAExB;CACF;AACF"}
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
//#region src/shared/nativeComponents.ts
|
|
2
|
+
const NATIVE_COMPONENT_DESCRIPTORS = Object.freeze([
|
|
3
|
+
{
|
|
4
|
+
name: "view",
|
|
5
|
+
webTag: "weapp-view",
|
|
6
|
+
attributes: [],
|
|
7
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: "text",
|
|
11
|
+
webTag: "weapp-text",
|
|
12
|
+
attributes: [
|
|
13
|
+
"selectable",
|
|
14
|
+
"user-select",
|
|
15
|
+
"space",
|
|
16
|
+
"decode"
|
|
17
|
+
],
|
|
18
|
+
defaultStyle: "display: inline; box-sizing: border-box; white-space: pre-wrap;"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "image",
|
|
22
|
+
webTag: "weapp-image",
|
|
23
|
+
attributes: [
|
|
24
|
+
"src",
|
|
25
|
+
"mode",
|
|
26
|
+
"lazy-load",
|
|
27
|
+
"alt"
|
|
28
|
+
],
|
|
29
|
+
defaultStyle: "display: inline-block; box-sizing: border-box; width: 320px; height: 240px; overflow: hidden; vertical-align: middle;"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "button",
|
|
33
|
+
webTag: "weapp-button",
|
|
34
|
+
attributes: [
|
|
35
|
+
"type",
|
|
36
|
+
"size",
|
|
37
|
+
"plain",
|
|
38
|
+
"disabled",
|
|
39
|
+
"loading",
|
|
40
|
+
"form-type",
|
|
41
|
+
"open-type"
|
|
42
|
+
],
|
|
43
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "input",
|
|
47
|
+
webTag: "weapp-input",
|
|
48
|
+
attributes: [
|
|
49
|
+
"name",
|
|
50
|
+
"value",
|
|
51
|
+
"type",
|
|
52
|
+
"password",
|
|
53
|
+
"placeholder",
|
|
54
|
+
"disabled",
|
|
55
|
+
"maxlength",
|
|
56
|
+
"confirm-type",
|
|
57
|
+
"focus"
|
|
58
|
+
],
|
|
59
|
+
defaultStyle: "display: block; box-sizing: border-box; min-height: 1.4em;"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "textarea",
|
|
63
|
+
webTag: "weapp-textarea",
|
|
64
|
+
attributes: [
|
|
65
|
+
"name",
|
|
66
|
+
"value",
|
|
67
|
+
"placeholder",
|
|
68
|
+
"disabled",
|
|
69
|
+
"maxlength",
|
|
70
|
+
"confirm-type",
|
|
71
|
+
"auto-focus",
|
|
72
|
+
"focus",
|
|
73
|
+
"auto-height"
|
|
74
|
+
],
|
|
75
|
+
defaultStyle: "display: block; box-sizing: border-box; width: 300px; height: 150px;"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "form",
|
|
79
|
+
webTag: "weapp-form",
|
|
80
|
+
attributes: [],
|
|
81
|
+
defaultStyle: "display: inline; box-sizing: border-box;"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "label",
|
|
85
|
+
webTag: "weapp-label",
|
|
86
|
+
attributes: ["for"],
|
|
87
|
+
defaultStyle: "display: inline; box-sizing: border-box; cursor: pointer;"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "checkbox-group",
|
|
91
|
+
webTag: "weapp-checkbox-group",
|
|
92
|
+
attributes: ["name"],
|
|
93
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "checkbox",
|
|
97
|
+
webTag: "weapp-checkbox",
|
|
98
|
+
attributes: [
|
|
99
|
+
"value",
|
|
100
|
+
"checked",
|
|
101
|
+
"disabled",
|
|
102
|
+
"color"
|
|
103
|
+
],
|
|
104
|
+
defaultStyle: "display: inline-flex; box-sizing: border-box; align-items: center; vertical-align: middle;"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "radio-group",
|
|
108
|
+
webTag: "weapp-radio-group",
|
|
109
|
+
attributes: ["name"],
|
|
110
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "radio",
|
|
114
|
+
webTag: "weapp-radio",
|
|
115
|
+
attributes: [
|
|
116
|
+
"value",
|
|
117
|
+
"checked",
|
|
118
|
+
"disabled",
|
|
119
|
+
"color"
|
|
120
|
+
],
|
|
121
|
+
defaultStyle: "display: inline-flex; box-sizing: border-box; align-items: center; vertical-align: middle;"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "switch",
|
|
125
|
+
webTag: "weapp-switch",
|
|
126
|
+
attributes: [
|
|
127
|
+
"name",
|
|
128
|
+
"checked",
|
|
129
|
+
"disabled",
|
|
130
|
+
"type",
|
|
131
|
+
"color"
|
|
132
|
+
],
|
|
133
|
+
defaultStyle: "display: inline-flex; box-sizing: border-box; align-items: center; vertical-align: middle;"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: "picker",
|
|
137
|
+
webTag: "weapp-picker",
|
|
138
|
+
attributes: [
|
|
139
|
+
"name",
|
|
140
|
+
"header-text",
|
|
141
|
+
"mode",
|
|
142
|
+
"range",
|
|
143
|
+
"range-key",
|
|
144
|
+
"value",
|
|
145
|
+
"start",
|
|
146
|
+
"end",
|
|
147
|
+
"fields",
|
|
148
|
+
"custom-item",
|
|
149
|
+
"level",
|
|
150
|
+
"disabled"
|
|
151
|
+
],
|
|
152
|
+
propertyAttributes: ["range", "value"],
|
|
153
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: "picker-view",
|
|
157
|
+
webTag: "weapp-picker-view",
|
|
158
|
+
attributes: [
|
|
159
|
+
"value",
|
|
160
|
+
"mask-class",
|
|
161
|
+
"indicator-style",
|
|
162
|
+
"indicator-class",
|
|
163
|
+
"mask-style",
|
|
164
|
+
"immediate-change"
|
|
165
|
+
],
|
|
166
|
+
propertyAttributes: ["value"],
|
|
167
|
+
defaultStyle: "position: relative; display: flex; box-sizing: border-box; height: 225px; overflow: hidden;"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "picker-view-column",
|
|
171
|
+
webTag: "weapp-picker-view-column",
|
|
172
|
+
attributes: ["indicator-style"],
|
|
173
|
+
defaultStyle: "display: block; box-sizing: border-box; min-width: 0; height: 100%; flex: 1;"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "slider",
|
|
177
|
+
webTag: "weapp-slider",
|
|
178
|
+
attributes: [
|
|
179
|
+
"name",
|
|
180
|
+
"min",
|
|
181
|
+
"max",
|
|
182
|
+
"step",
|
|
183
|
+
"disabled",
|
|
184
|
+
"value",
|
|
185
|
+
"color",
|
|
186
|
+
"selected-color",
|
|
187
|
+
"active-color",
|
|
188
|
+
"background-color",
|
|
189
|
+
"block-size",
|
|
190
|
+
"block-color",
|
|
191
|
+
"show-value"
|
|
192
|
+
],
|
|
193
|
+
defaultStyle: "display: block; box-sizing: border-box; margin: 10px 18px;"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
name: "icon",
|
|
197
|
+
webTag: "weapp-icon",
|
|
198
|
+
attributes: [
|
|
199
|
+
"type",
|
|
200
|
+
"size",
|
|
201
|
+
"color"
|
|
202
|
+
],
|
|
203
|
+
defaultStyle: "display: inline-flex; box-sizing: border-box; align-items: center; justify-content: center; vertical-align: middle;"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: "progress",
|
|
207
|
+
webTag: "weapp-progress",
|
|
208
|
+
attributes: [
|
|
209
|
+
"percent",
|
|
210
|
+
"show-info",
|
|
211
|
+
"stroke-width",
|
|
212
|
+
"color",
|
|
213
|
+
"active-color",
|
|
214
|
+
"background-color",
|
|
215
|
+
"active",
|
|
216
|
+
"active-mode",
|
|
217
|
+
"duration",
|
|
218
|
+
"border-radius",
|
|
219
|
+
"font-size"
|
|
220
|
+
],
|
|
221
|
+
defaultStyle: "display: flex; box-sizing: border-box; align-items: center;"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: "rich-text",
|
|
225
|
+
webTag: "weapp-rich-text",
|
|
226
|
+
attributes: [
|
|
227
|
+
"nodes",
|
|
228
|
+
"space",
|
|
229
|
+
"user-select"
|
|
230
|
+
],
|
|
231
|
+
propertyAttributes: ["nodes"],
|
|
232
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: "scroll-view",
|
|
236
|
+
webTag: "weapp-scroll-view",
|
|
237
|
+
attributes: [
|
|
238
|
+
"scroll-x",
|
|
239
|
+
"scroll-y",
|
|
240
|
+
"scroll-top",
|
|
241
|
+
"scroll-left"
|
|
242
|
+
],
|
|
243
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "navigator",
|
|
247
|
+
webTag: "weapp-navigator",
|
|
248
|
+
attributes: [
|
|
249
|
+
"url",
|
|
250
|
+
"open-type",
|
|
251
|
+
"delta",
|
|
252
|
+
"target",
|
|
253
|
+
"app-id",
|
|
254
|
+
"path",
|
|
255
|
+
"extra-data",
|
|
256
|
+
"version",
|
|
257
|
+
"short-link",
|
|
258
|
+
"aria-label",
|
|
259
|
+
"hover-class",
|
|
260
|
+
"hover-start-time",
|
|
261
|
+
"hover-stay-time",
|
|
262
|
+
"hover-stop-propagation"
|
|
263
|
+
],
|
|
264
|
+
propertyAttributes: ["extra-data"],
|
|
265
|
+
defaultStyle: "display: block; box-sizing: border-box;"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: "swiper",
|
|
269
|
+
webTag: "weapp-swiper",
|
|
270
|
+
attributes: [
|
|
271
|
+
"current",
|
|
272
|
+
"current-item-id",
|
|
273
|
+
"autoplay",
|
|
274
|
+
"interval",
|
|
275
|
+
"duration",
|
|
276
|
+
"circular",
|
|
277
|
+
"vertical",
|
|
278
|
+
"indicator-dots",
|
|
279
|
+
"indicator-color",
|
|
280
|
+
"indicator-active-color",
|
|
281
|
+
"display-multiple-items",
|
|
282
|
+
"previous-margin",
|
|
283
|
+
"next-margin",
|
|
284
|
+
"disable-touch",
|
|
285
|
+
"easing-function"
|
|
286
|
+
],
|
|
287
|
+
defaultStyle: "display: block; box-sizing: border-box; height: 150px; overflow: hidden;"
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: "swiper-item",
|
|
291
|
+
webTag: "weapp-swiper-item",
|
|
292
|
+
attributes: ["item-id"],
|
|
293
|
+
defaultStyle: "display: block; box-sizing: border-box; width: 100%; height: 100%; overflow: hidden;"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
name: "canvas",
|
|
297
|
+
webTag: "weapp-canvas",
|
|
298
|
+
attributes: [
|
|
299
|
+
"id",
|
|
300
|
+
"canvas-id",
|
|
301
|
+
"type",
|
|
302
|
+
"disable-scroll",
|
|
303
|
+
"width",
|
|
304
|
+
"height"
|
|
305
|
+
],
|
|
306
|
+
defaultStyle: "display: block; box-sizing: border-box; width: 300px; height: 150px; overflow: hidden;"
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: "video",
|
|
310
|
+
webTag: "weapp-video",
|
|
311
|
+
attributes: [
|
|
312
|
+
"id",
|
|
313
|
+
"src",
|
|
314
|
+
"poster",
|
|
315
|
+
"autoplay",
|
|
316
|
+
"loop",
|
|
317
|
+
"muted",
|
|
318
|
+
"controls",
|
|
319
|
+
"initial-time",
|
|
320
|
+
"object-fit"
|
|
321
|
+
],
|
|
322
|
+
defaultStyle: "display: block; box-sizing: border-box; width: 300px; height: 225px; overflow: hidden;"
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
name: "cover-view",
|
|
326
|
+
webTag: "weapp-cover-view",
|
|
327
|
+
attributes: [],
|
|
328
|
+
defaultStyle: "position: absolute; z-index: 2; display: block; box-sizing: border-box; pointer-events: auto;"
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
name: "cover-image",
|
|
332
|
+
webTag: "weapp-cover-image",
|
|
333
|
+
attributes: [
|
|
334
|
+
"src",
|
|
335
|
+
"mode",
|
|
336
|
+
"lazy-load",
|
|
337
|
+
"alt"
|
|
338
|
+
],
|
|
339
|
+
defaultStyle: "position: absolute; z-index: 2; display: block; box-sizing: border-box; width: 100%; height: 100%; overflow: hidden; pointer-events: auto;"
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
name: "movable-area",
|
|
343
|
+
webTag: "weapp-movable-area",
|
|
344
|
+
attributes: [],
|
|
345
|
+
defaultStyle: "position: relative; display: block; box-sizing: border-box; overflow: hidden;"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "movable-view",
|
|
349
|
+
webTag: "weapp-movable-view",
|
|
350
|
+
attributes: [
|
|
351
|
+
"direction",
|
|
352
|
+
"inertia",
|
|
353
|
+
"out-of-bounds",
|
|
354
|
+
"x",
|
|
355
|
+
"y",
|
|
356
|
+
"damping",
|
|
357
|
+
"friction",
|
|
358
|
+
"disabled",
|
|
359
|
+
"scale",
|
|
360
|
+
"scale-min",
|
|
361
|
+
"scale-max",
|
|
362
|
+
"scale-value",
|
|
363
|
+
"animation"
|
|
364
|
+
],
|
|
365
|
+
defaultStyle: "position: absolute; top: 0; left: 0; display: block; box-sizing: border-box; width: 10px; height: 10px; touch-action: none; user-select: none;"
|
|
366
|
+
}
|
|
367
|
+
]);
|
|
368
|
+
const descriptorMap = new Map(NATIVE_COMPONENT_DESCRIPTORS.map((descriptor) => [descriptor.name, descriptor]));
|
|
369
|
+
const KNOWN_UNSUPPORTED_NATIVE_COMPONENTS = /* @__PURE__ */ new Set([
|
|
370
|
+
"editor",
|
|
371
|
+
"keyboard-accessory",
|
|
372
|
+
"match-media",
|
|
373
|
+
"root-portal",
|
|
374
|
+
"page-container",
|
|
375
|
+
"share-element",
|
|
376
|
+
"audio",
|
|
377
|
+
"camera",
|
|
378
|
+
"live-player",
|
|
379
|
+
"live-pusher",
|
|
380
|
+
"map",
|
|
381
|
+
"web-view",
|
|
382
|
+
"ad",
|
|
383
|
+
"official-account",
|
|
384
|
+
"open-data"
|
|
385
|
+
]);
|
|
386
|
+
function getNativeComponentDescriptor(name) {
|
|
387
|
+
return descriptorMap.get(name.toLowerCase());
|
|
388
|
+
}
|
|
389
|
+
function resolveNativeComponentWebTag(name) {
|
|
390
|
+
return getNativeComponentDescriptor(name)?.webTag;
|
|
391
|
+
}
|
|
392
|
+
function resolveNativeComponentPropertyAttributes(name) {
|
|
393
|
+
return getNativeComponentDescriptor(name)?.propertyAttributes ?? [];
|
|
394
|
+
}
|
|
395
|
+
function isKnownUnsupportedNativeComponent(name) {
|
|
396
|
+
return KNOWN_UNSUPPORTED_NATIVE_COMPONENTS.has(name.toLowerCase());
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
//#endregion
|
|
400
|
+
export { NATIVE_COMPONENT_DESCRIPTORS, getNativeComponentDescriptor, isKnownUnsupportedNativeComponent, resolveNativeComponentPropertyAttributes, resolveNativeComponentWebTag };
|
|
401
|
+
//# sourceMappingURL=nativeComponents.mjs.map
|