@weapp-vite/web 1.3.37 → 1.4.1
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 +16 -12
- package/dist/compiler/wxml/renderer.mjs.map +1 -1
- package/dist/compiler/wxml/specialNodes.mjs +8 -2
- 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 +24 -6
- package/dist/index.mjs +21 -4
- 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 +55 -6
- 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 +244 -73
- 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 +6 -2
- package/dist/plugin/path.mjs.map +1 -1
- package/dist/plugin/register.mjs +45 -33
- package/dist/plugin/register.mjs.map +1 -1
- package/dist/plugin/scan.mjs +211 -92
- 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 +37 -1
- package/dist/plugin/vueSfc.mjs +150 -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 +36 -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/deviceApi.mjs +6 -3
- package/dist/runtime/polyfill/deviceApi.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 +33 -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 +9 -5
- 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 +11 -6
- 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 +3 -2
- package/dist/runtime/polyfill/mediaApi/file.mjs.map +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/mediaApi/picker.mjs +16 -8
- package/dist/runtime/polyfill/mediaApi/picker.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/preview.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/preview.mjs.map +1 -1
- package/dist/runtime/polyfill/mediaApi/process.mjs +4 -2
- package/dist/runtime/polyfill/mediaApi/process.mjs.map +1 -1
- package/dist/runtime/polyfill/menuApi.mjs +39 -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 +3 -2
- package/dist/runtime/polyfill/platformApi.mjs.map +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/storageAsync.mjs +4 -2
- package/dist/runtime/polyfill/storageAsync.mjs.map +1 -1
- package/dist/runtime/polyfill/system.mjs +31 -4
- package/dist/runtime/polyfill/system.mjs.map +1 -1
- package/dist/runtime/polyfill/systemApi.mjs +2 -1
- package/dist/runtime/polyfill/systemApi.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 +14 -6
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//#region src/runtime/seo/index.ts
|
|
2
|
+
const HEAD_MARKER = "data-weapp-web-head";
|
|
3
|
+
const HEAD_OWNER = "weapp-web-runtime";
|
|
4
|
+
let seoConfig = { enabled: false };
|
|
5
|
+
function getDocument() {
|
|
6
|
+
return typeof document === "undefined" ? void 0 : document;
|
|
7
|
+
}
|
|
8
|
+
function findOrCreateMeta(documentRef, name) {
|
|
9
|
+
const selector = `meta[${HEAD_MARKER}="${HEAD_OWNER}"][name="${name}"]`;
|
|
10
|
+
const existing = documentRef.head?.querySelector(selector);
|
|
11
|
+
if (existing) return existing;
|
|
12
|
+
const meta = documentRef.createElement("meta");
|
|
13
|
+
meta.setAttribute("name", name);
|
|
14
|
+
meta.setAttribute(HEAD_MARKER, HEAD_OWNER);
|
|
15
|
+
documentRef.head?.append(meta);
|
|
16
|
+
return meta;
|
|
17
|
+
}
|
|
18
|
+
function resolveTitle(title, route) {
|
|
19
|
+
const raw = title || seoConfig.defaultTitle || route || "";
|
|
20
|
+
if (!seoConfig.titleTemplate || !raw) return raw;
|
|
21
|
+
return seoConfig.titleTemplate.includes("%s") ? seoConfig.titleTemplate.replaceAll("%s", raw) : `${raw}${seoConfig.titleTemplate}`;
|
|
22
|
+
}
|
|
23
|
+
function resolveCanonicalUrl() {
|
|
24
|
+
if (typeof window === "undefined" || !window.location) return;
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(window.location.href);
|
|
27
|
+
url.search = "";
|
|
28
|
+
url.hash = "";
|
|
29
|
+
return url.href;
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function configureWebSeo(next) {
|
|
35
|
+
seoConfig = next ? {
|
|
36
|
+
enabled: next.enabled !== false,
|
|
37
|
+
...next
|
|
38
|
+
} : { enabled: false };
|
|
39
|
+
const documentRef = getDocument();
|
|
40
|
+
if (!documentRef || seoConfig.enabled === false) return;
|
|
41
|
+
if (seoConfig.description !== void 0) findOrCreateMeta(documentRef, "description").content = seoConfig.description;
|
|
42
|
+
}
|
|
43
|
+
function syncWebDocumentHead(head) {
|
|
44
|
+
const documentRef = getDocument();
|
|
45
|
+
if (!documentRef || seoConfig.enabled === false) return;
|
|
46
|
+
const title = resolveTitle(head.title, head.route);
|
|
47
|
+
if (title) documentRef.title = title;
|
|
48
|
+
if (seoConfig.description !== void 0) findOrCreateMeta(documentRef, "description").content = seoConfig.description;
|
|
49
|
+
if (seoConfig.canonical !== false) {
|
|
50
|
+
const canonical = resolveCanonicalUrl();
|
|
51
|
+
if (canonical && documentRef.head) {
|
|
52
|
+
let link = documentRef.head.querySelector(`link[${HEAD_MARKER}="${HEAD_OWNER}"][rel="canonical"]`);
|
|
53
|
+
if (!link) {
|
|
54
|
+
link = documentRef.createElement("link");
|
|
55
|
+
link.rel = "canonical";
|
|
56
|
+
link.setAttribute(HEAD_MARKER, HEAD_OWNER);
|
|
57
|
+
documentRef.head.append(link);
|
|
58
|
+
}
|
|
59
|
+
link.href = canonical;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function updateWebDocumentTitle(title) {
|
|
64
|
+
syncWebDocumentHead({ title });
|
|
65
|
+
}
|
|
66
|
+
function setupWebResourceHints(config) {
|
|
67
|
+
const documentRef = getDocument();
|
|
68
|
+
if (!documentRef?.head || !config?.links?.length) return;
|
|
69
|
+
for (const hint of config.links) {
|
|
70
|
+
if (!hint || typeof hint.href !== "string" || !hint.href || typeof hint.rel !== "string") continue;
|
|
71
|
+
const selector = `link[${HEAD_MARKER}="${HEAD_OWNER}"][rel="${hint.rel}"][href="${hint.href}"]`;
|
|
72
|
+
let link = documentRef.head.querySelector(selector);
|
|
73
|
+
if (!link) {
|
|
74
|
+
link = documentRef.createElement("link");
|
|
75
|
+
link.rel = hint.rel;
|
|
76
|
+
link.href = hint.href;
|
|
77
|
+
link.setAttribute(HEAD_MARKER, HEAD_OWNER);
|
|
78
|
+
documentRef.head.append(link);
|
|
79
|
+
}
|
|
80
|
+
if (hint.as) link.as = hint.as;
|
|
81
|
+
if (hint.type) link.type = hint.type;
|
|
82
|
+
if (hint.crossOrigin) link.crossOrigin = hint.crossOrigin;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function resetWebDocumentHead() {
|
|
86
|
+
const documentRef = getDocument();
|
|
87
|
+
if (!documentRef?.head) return;
|
|
88
|
+
documentRef.head.querySelectorAll(`[${HEAD_MARKER}="${HEAD_OWNER}"]`).forEach((node) => node.remove());
|
|
89
|
+
seoConfig = { enabled: false };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
export { configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle };
|
|
94
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/runtime/seo/index.ts"],"sourcesContent":["export type WebResourceHintRelation = 'preconnect' | 'dns-prefetch' | 'prefetch' | 'preload'\n\nexport interface WebResourceHint {\n href: string\n rel: WebResourceHintRelation\n as?: string\n type?: string\n crossOrigin?: 'anonymous' | 'use-credentials'\n}\n\nexport interface WebResourceHintsConfig {\n links?: WebResourceHint[]\n}\n\nexport interface WebSeoConfig {\n enabled?: boolean\n defaultTitle?: string\n titleTemplate?: string\n description?: string\n canonical?: boolean\n}\n\nexport interface WebPageHead {\n route?: string\n title?: string\n}\n\nconst HEAD_MARKER = 'data-weapp-web-head'\nconst HEAD_OWNER = 'weapp-web-runtime'\nlet seoConfig: WebSeoConfig = { enabled: false }\n\nfunction getDocument(): Document | undefined {\n return typeof document === 'undefined' ? undefined : document\n}\n\nfunction findOrCreateMeta(documentRef: Document, name: string) {\n const selector = `meta[${HEAD_MARKER}=\"${HEAD_OWNER}\"][name=\"${name}\"]`\n const existing = documentRef.head?.querySelector(selector) as HTMLMetaElement | null\n if (existing) {\n return existing\n }\n const meta = documentRef.createElement('meta')\n meta.setAttribute('name', name)\n meta.setAttribute(HEAD_MARKER, HEAD_OWNER)\n documentRef.head?.append(meta)\n return meta\n}\n\nfunction resolveTitle(title: string | undefined, route: string | undefined) {\n const raw = title || seoConfig.defaultTitle || route || ''\n if (!seoConfig.titleTemplate || !raw) {\n return raw\n }\n return seoConfig.titleTemplate.includes('%s')\n ? seoConfig.titleTemplate.replaceAll('%s', raw)\n : `${raw}${seoConfig.titleTemplate}`\n}\n\nfunction resolveCanonicalUrl() {\n if (typeof window === 'undefined' || !window.location) {\n return undefined\n }\n try {\n const url = new URL(window.location.href)\n url.search = ''\n url.hash = ''\n return url.href\n }\n catch {\n return undefined\n }\n}\n\nexport function configureWebSeo(next?: WebSeoConfig) {\n seoConfig = next\n ? { enabled: next.enabled !== false, ...next }\n : { enabled: false }\n const documentRef = getDocument()\n if (!documentRef || seoConfig.enabled === false) {\n return\n }\n if (seoConfig.description !== undefined) {\n findOrCreateMeta(documentRef, 'description').content = seoConfig.description\n }\n}\n\nexport function syncWebDocumentHead(head: WebPageHead) {\n const documentRef = getDocument()\n if (!documentRef || seoConfig.enabled === false) {\n return\n }\n const title = resolveTitle(head.title, head.route)\n if (title) {\n documentRef.title = title\n }\n if (seoConfig.description !== undefined) {\n findOrCreateMeta(documentRef, 'description').content = seoConfig.description\n }\n if (seoConfig.canonical !== false) {\n const canonical = resolveCanonicalUrl()\n if (canonical && documentRef.head) {\n let link = documentRef.head.querySelector(`link[${HEAD_MARKER}=\"${HEAD_OWNER}\"][rel=\"canonical\"]`) as HTMLLinkElement | null\n if (!link) {\n link = documentRef.createElement('link')\n link.rel = 'canonical'\n link.setAttribute(HEAD_MARKER, HEAD_OWNER)\n documentRef.head.append(link)\n }\n link.href = canonical\n }\n }\n}\n\nexport function updateWebDocumentTitle(title: string) {\n syncWebDocumentHead({ title })\n}\n\nexport function setupWebResourceHints(config?: WebResourceHintsConfig) {\n const documentRef = getDocument()\n if (!documentRef?.head || !config?.links?.length) {\n return\n }\n for (const hint of config.links) {\n if (!hint || typeof hint.href !== 'string' || !hint.href || typeof hint.rel !== 'string') {\n continue\n }\n const selector = `link[${HEAD_MARKER}=\"${HEAD_OWNER}\"][rel=\"${hint.rel}\"][href=\"${hint.href}\"]`\n let link = documentRef.head.querySelector(selector) as HTMLLinkElement | null\n if (!link) {\n link = documentRef.createElement('link')\n link.rel = hint.rel\n link.href = hint.href\n link.setAttribute(HEAD_MARKER, HEAD_OWNER)\n documentRef.head.append(link)\n }\n if (hint.as) {\n link.as = hint.as\n }\n if (hint.type) {\n link.type = hint.type\n }\n if (hint.crossOrigin) {\n link.crossOrigin = hint.crossOrigin\n }\n }\n}\n\nexport function resetWebDocumentHead() {\n const documentRef = getDocument()\n if (!documentRef?.head) {\n return\n }\n documentRef.head.querySelectorAll(`[${HEAD_MARKER}=\"${HEAD_OWNER}\"]`).forEach(node => node.remove())\n seoConfig = { enabled: false }\n}\n\nexport type { WebSeoConfig as WebRuntimeSeoConfig }\n"],"mappings":";AA2BA,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,IAAI,YAA0B,EAAE,SAAS,MAAM;AAE/C,SAAS,cAAoC;CAC3C,OAAO,OAAO,aAAa,cAAc,SAAY;AACvD;AAEA,SAAS,iBAAiB,aAAuB,MAAc;CAC7D,MAAM,WAAW,QAAQ,YAAY,IAAI,WAAW,WAAW,KAAK;CACpE,MAAM,WAAW,YAAY,MAAM,cAAc,QAAQ;CACzD,IAAI,UACF,OAAO;CAET,MAAM,OAAO,YAAY,cAAc,MAAM;CAC7C,KAAK,aAAa,QAAQ,IAAI;CAC9B,KAAK,aAAa,aAAa,UAAU;CACzC,YAAY,MAAM,OAAO,IAAI;CAC7B,OAAO;AACT;AAEA,SAAS,aAAa,OAA2B,OAA2B;CAC1E,MAAM,MAAM,SAAS,UAAU,gBAAgB,SAAS;CACxD,IAAI,CAAC,UAAU,iBAAiB,CAAC,KAC/B,OAAO;CAET,OAAO,UAAU,cAAc,SAAS,IAAI,IACxC,UAAU,cAAc,WAAW,MAAM,GAAG,IAC5C,GAAG,MAAM,UAAU;AACzB;AAEA,SAAS,sBAAsB;CAC7B,IAAI,OAAO,WAAW,eAAe,CAAC,OAAO,UAC3C;CAEF,IAAI;EACF,MAAM,MAAM,IAAI,IAAI,OAAO,SAAS,IAAI;EACxC,IAAI,SAAS;EACb,IAAI,OAAO;EACX,OAAO,IAAI;CACb,QACM;EACJ;CACF;AACF;AAEA,SAAgB,gBAAgB,MAAqB;CACnD,YAAY,OACR;EAAE,SAAS,KAAK,YAAY;EAAO,GAAG;CAAK,IAC3C,EAAE,SAAS,MAAM;CACrB,MAAM,cAAc,YAAY;CAChC,IAAI,CAAC,eAAe,UAAU,YAAY,OACxC;CAEF,IAAI,UAAU,gBAAgB,QAC5B,iBAAiB,aAAa,aAAa,CAAC,CAAC,UAAU,UAAU;AAErE;AAEA,SAAgB,oBAAoB,MAAmB;CACrD,MAAM,cAAc,YAAY;CAChC,IAAI,CAAC,eAAe,UAAU,YAAY,OACxC;CAEF,MAAM,QAAQ,aAAa,KAAK,OAAO,KAAK,KAAK;CACjD,IAAI,OACF,YAAY,QAAQ;CAEtB,IAAI,UAAU,gBAAgB,QAC5B,iBAAiB,aAAa,aAAa,CAAC,CAAC,UAAU,UAAU;CAEnE,IAAI,UAAU,cAAc,OAAO;EACjC,MAAM,YAAY,oBAAoB;EACtC,IAAI,aAAa,YAAY,MAAM;GACjC,IAAI,OAAO,YAAY,KAAK,cAAc,QAAQ,YAAY,IAAI,WAAW,oBAAoB;GACjG,IAAI,CAAC,MAAM;IACT,OAAO,YAAY,cAAc,MAAM;IACvC,KAAK,MAAM;IACX,KAAK,aAAa,aAAa,UAAU;IACzC,YAAY,KAAK,OAAO,IAAI;GAC9B;GACA,KAAK,OAAO;EACd;CACF;AACF;AAEA,SAAgB,uBAAuB,OAAe;CACpD,oBAAoB,EAAE,MAAM,CAAC;AAC/B;AAEA,SAAgB,sBAAsB,QAAiC;CACrE,MAAM,cAAc,YAAY;CAChC,IAAI,CAAC,aAAa,QAAQ,CAAC,QAAQ,OAAO,QACxC;CAEF,KAAK,MAAM,QAAQ,OAAO,OAAO;EAC/B,IAAI,CAAC,QAAQ,OAAO,KAAK,SAAS,YAAY,CAAC,KAAK,QAAQ,OAAO,KAAK,QAAQ,UAC9E;EAEF,MAAM,WAAW,QAAQ,YAAY,IAAI,WAAW,UAAU,KAAK,IAAI,WAAW,KAAK,KAAK;EAC5F,IAAI,OAAO,YAAY,KAAK,cAAc,QAAQ;EAClD,IAAI,CAAC,MAAM;GACT,OAAO,YAAY,cAAc,MAAM;GACvC,KAAK,MAAM,KAAK;GAChB,KAAK,OAAO,KAAK;GACjB,KAAK,aAAa,aAAa,UAAU;GACzC,YAAY,KAAK,OAAO,IAAI;EAC9B;EACA,IAAI,KAAK,IACP,KAAK,KAAK,KAAK;EAEjB,IAAI,KAAK,MACP,KAAK,OAAO,KAAK;EAEnB,IAAI,KAAK,aACP,KAAK,cAAc,KAAK;CAE5B;AACF;AAEA,SAAgB,uBAAuB;CACrC,MAAM,cAAc,YAAY;CAChC,IAAI,CAAC,aAAa,MAChB;CAEF,YAAY,KAAK,iBAAiB,IAAI,YAAY,IAAI,WAAW,GAAG,CAAC,CAAC,SAAQ,SAAQ,KAAK,OAAO,CAAC;CACnG,YAAY,EAAE,SAAS,MAAM;AAC/B"}
|
|
@@ -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"}
|