@weapp-vite/web 2.0.0 → 2.1.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/dist/_virtual/_rolldown/runtime.mjs +1 -2
- package/dist/compiler/wxml/attributes.mjs +12 -4
- package/dist/compiler/wxml/attributes.mjs.map +1 -1
- package/dist/compiler/wxml/compile.mjs +33 -39
- package/dist/compiler/wxml/compile.mjs.map +1 -1
- package/dist/compiler/wxml/dependency.mjs +10 -3
- package/dist/compiler/wxml/dependency.mjs.map +1 -1
- package/dist/compiler/wxml/interpolation.mjs +13 -3
- package/dist/compiler/wxml/interpolation.mjs.map +1 -1
- package/dist/compiler/wxml/nativeTags.mjs +60 -0
- package/dist/compiler/wxml/nativeTags.mjs.map +1 -0
- package/dist/compiler/wxml/navigation.mjs +1 -2
- package/dist/compiler/wxml/parser.mjs +1 -2
- package/dist/compiler/wxml/prepare.mjs +42 -0
- package/dist/compiler/wxml/prepare.mjs.map +1 -0
- package/dist/compiler/wxml/renderer.mjs +1 -2
- package/dist/compiler/wxml/specialNodes.mjs +1 -2
- package/dist/compiler/wxml/types.d.mts +0 -2
- package/dist/compiler/wxml/unknownTags.mjs +33 -0
- package/dist/compiler/wxml/unknownTags.mjs.map +1 -0
- package/dist/compiler/wxs.mjs +1 -2
- package/dist/css/wxss.d.mts +2 -19
- package/dist/css/wxss.mjs +5 -12
- package/dist/css/wxss.mjs.map +1 -1
- package/dist/index.d.mts +8 -3
- package/dist/index.mjs +8 -5
- package/dist/plugin/assets.d.mts +1 -2
- package/dist/plugin/assets.mjs +1 -2
- package/dist/plugin/constants.mjs +5 -4
- package/dist/plugin/constants.mjs.map +1 -1
- package/dist/plugin/dependencyScan.mjs +1 -2
- package/dist/plugin/entry.mjs +6 -4
- package/dist/plugin/entry.mjs.map +1 -1
- package/dist/plugin/files.mjs +1 -2
- package/dist/plugin/hostTypes.d.mts +1 -2
- package/dist/plugin/index.d.mts +0 -2
- package/dist/plugin/index.mjs +29 -24
- package/dist/plugin/index.mjs.map +1 -1
- package/dist/plugin/layout.mjs +1 -2
- package/dist/plugin/navigation.mjs +1 -2
- package/dist/plugin/packageResolution.mjs +1 -2
- package/dist/plugin/path.mjs +1 -2
- package/dist/plugin/register.mjs +1 -2
- package/dist/plugin/scan.mjs +1 -2
- package/dist/plugin/scanConfig.mjs +1 -2
- package/dist/plugin/scanSfc.mjs +1 -2
- package/dist/plugin/sfcHmr.mjs +28 -10
- package/dist/plugin/sfcHmr.mjs.map +1 -1
- package/dist/plugin/state.mjs +1 -2
- package/dist/plugin/styleModule.mjs +1 -2
- package/dist/plugin/types.d.mts +2 -3
- package/dist/plugin/vueSfc.mjs +1 -2
- package/dist/runtime/appShell/container.mjs +1 -2
- package/dist/runtime/appShell/tabBar/index.mjs +1 -2
- package/dist/runtime/appShell/tabBar/style.mjs +1 -2
- package/dist/runtime/appStyle.mjs +1 -2
- package/dist/runtime/button/helpers.mjs +1 -2
- package/dist/runtime/button/index.d.mts +0 -2
- package/dist/runtime/button/index.mjs +1 -2
- package/dist/runtime/button/style.mjs +1 -2
- package/dist/runtime/component/behavior.mjs +1 -2
- package/dist/runtime/component/constants.mjs +1 -2
- package/dist/runtime/component/dom.mjs +1 -2
- package/dist/runtime/component/element.mjs +9 -2
- package/dist/runtime/component/element.mjs.map +1 -1
- package/dist/runtime/component/events.mjs +4 -4
- package/dist/runtime/component/events.mjs.map +1 -1
- package/dist/runtime/component/index.d.mts +0 -2
- package/dist/runtime/component/index.mjs +1 -2
- package/dist/runtime/component/observers.mjs +1 -2
- package/dist/runtime/component/publicInstance.mjs +1 -2
- package/dist/runtime/component/relations.mjs +1 -2
- package/dist/runtime/component/slots.mjs +1 -2
- package/dist/runtime/component/state.mjs +1 -2
- package/dist/runtime/component/types.d.mts +0 -2
- package/dist/runtime/component/utils.mjs +1 -2
- package/dist/runtime/component/virtualHost.mjs +1 -2
- package/dist/runtime/componentEvents.mjs +1 -2
- package/dist/runtime/dataset.mjs +49 -0
- package/dist/runtime/dataset.mjs.map +1 -0
- package/dist/runtime/datasetBinding.d.mts +13 -0
- package/dist/runtime/datasetBinding.mjs +40 -0
- package/dist/runtime/datasetBinding.mjs.map +1 -0
- package/dist/runtime/eventBinding.d.mts +1 -2
- package/dist/runtime/eventBinding.mjs +1 -2
- package/dist/runtime/execution.d.mts +0 -2
- package/dist/runtime/execution.mjs +1 -2
- package/dist/runtime/host/index.d.mts +0 -2
- package/dist/runtime/host/index.mjs +1 -2
- package/dist/runtime/host/types.d.mts +0 -2
- package/dist/runtime/hostGlobals.d.mts +1 -2
- package/dist/runtime/hostGlobals.mjs +1 -2
- package/dist/runtime/index.d.mts +8 -3
- package/dist/runtime/index.mjs +9 -7
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/inlineStyle.d.mts +5 -0
- package/dist/runtime/inlineStyle.mjs +21 -0
- package/dist/runtime/inlineStyle.mjs.map +1 -0
- package/dist/runtime/inputHandlerResult.mjs +1 -2
- package/dist/runtime/legacyTemplate/dataset.mjs +53 -0
- package/dist/runtime/legacyTemplate/dataset.mjs.map +1 -0
- package/dist/runtime/legacyTemplate/dom.mjs +20 -5
- package/dist/runtime/legacyTemplate/dom.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/expression.mjs +1 -2
- package/dist/runtime/legacyTemplate/index.d.mts +0 -2
- package/dist/runtime/legacyTemplate/index.mjs +23 -16
- package/dist/runtime/legacyTemplate/index.mjs.map +1 -1
- package/dist/runtime/legacyTemplate/types.d.mts +0 -2
- package/dist/runtime/nativeComponents/canvas/index.mjs +1 -2
- package/dist/runtime/nativeComponents/checkbox.mjs +1 -2
- package/dist/runtime/nativeComponents/cover/index.mjs +1 -2
- package/dist/runtime/nativeComponents/form.d.mts +0 -2
- package/dist/runtime/nativeComponents/form.mjs +1 -2
- package/dist/runtime/nativeComponents/formControl.mjs +1 -2
- package/dist/runtime/nativeComponents/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/icon/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/icon/index.mjs +1 -2
- package/dist/runtime/nativeComponents/icon/style.mjs +1 -2
- package/dist/runtime/nativeComponents/image.d.mts +0 -2
- package/dist/runtime/nativeComponents/image.mjs +1 -2
- package/dist/runtime/nativeComponents/index.d.mts +1 -3
- package/dist/runtime/nativeComponents/index.mjs +3 -4
- package/dist/runtime/nativeComponents/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/input.d.mts +0 -2
- package/dist/runtime/nativeComponents/input.mjs +1 -2
- package/dist/runtime/nativeComponents/label.mjs +1 -2
- package/dist/runtime/nativeComponents/mediaRegistry.mjs +1 -2
- package/dist/runtime/nativeComponents/movable/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/movable/index.mjs +1 -2
- package/dist/runtime/nativeComponents/navigator.mjs +1 -2
- package/dist/runtime/nativeComponents/picker/editors.mjs +1 -2
- package/dist/runtime/nativeComponents/picker/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/picker/index.mjs +1 -2
- package/dist/runtime/nativeComponents/picker/style.mjs +1 -2
- package/dist/runtime/nativeComponents/pickerView/column.mjs +1 -2
- package/dist/runtime/nativeComponents/pickerView/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/pickerView/index.mjs +1 -2
- package/dist/runtime/nativeComponents/pickerView/style.mjs +1 -2
- package/dist/runtime/nativeComponents/primitives.mjs +1 -2
- package/dist/runtime/nativeComponents/progress/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/progress/index.mjs +1 -2
- package/dist/runtime/nativeComponents/progress/style.mjs +1 -2
- package/dist/runtime/nativeComponents/radio.mjs +1 -2
- package/dist/runtime/nativeComponents/richText/index.mjs +3 -4
- package/dist/runtime/nativeComponents/richText/index.mjs.map +1 -1
- package/dist/runtime/nativeComponents/scrollView/boundaries.mjs +62 -0
- package/dist/runtime/nativeComponents/scrollView/boundaries.mjs.map +1 -0
- package/dist/runtime/nativeComponents/{scrollView.d.mts → scrollView/helpers.d.mts} +4 -5
- package/dist/runtime/nativeComponents/scrollView/helpers.mjs +14 -0
- package/dist/runtime/nativeComponents/scrollView/helpers.mjs.map +1 -0
- package/dist/runtime/nativeComponents/scrollView/index.mjs +193 -0
- package/dist/runtime/nativeComponents/scrollView/index.mjs.map +1 -0
- package/dist/runtime/nativeComponents/scrollView/position.mjs +43 -0
- package/dist/runtime/nativeComponents/scrollView/position.mjs.map +1 -0
- package/dist/runtime/nativeComponents/slider/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/slider/index.mjs +1 -2
- package/dist/runtime/nativeComponents/slider/style.mjs +1 -2
- package/dist/runtime/nativeComponents/style.mjs +1 -2
- package/dist/runtime/nativeComponents/swiper/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/swiper/index.mjs +1 -2
- package/dist/runtime/nativeComponents/swiper/item.mjs +1 -2
- package/dist/runtime/nativeComponents/swiper/style.mjs +1 -2
- package/dist/runtime/nativeComponents/switch.d.mts +0 -2
- package/dist/runtime/nativeComponents/switch.mjs +1 -2
- package/dist/runtime/nativeComponents/textarea.d.mts +0 -2
- package/dist/runtime/nativeComponents/textarea.mjs +1 -2
- package/dist/runtime/nativeComponents/video/helpers.d.mts +0 -2
- package/dist/runtime/nativeComponents/video/helpers.mjs +1 -2
- package/dist/runtime/nativeComponents/video/index.mjs +1 -2
- package/dist/runtime/nativeComponents/video/style.mjs +1 -2
- package/dist/runtime/navigationBar/index.d.mts +0 -2
- package/dist/runtime/navigationBar/index.mjs +1 -2
- package/dist/runtime/navigationBar/style.mjs +1 -2
- package/dist/runtime/pageLayout.d.mts +1 -2
- package/dist/runtime/pageLayout.mjs +1 -2
- package/dist/runtime/polyfill/ad.mjs +1 -2
- package/dist/runtime/polyfill/animation.mjs +1 -2
- package/dist/runtime/polyfill/appState.mjs +1 -2
- package/dist/runtime/polyfill/async.d.mts +0 -2
- package/dist/runtime/polyfill/async.mjs +1 -2
- package/dist/runtime/polyfill/auth.mjs +1 -2
- package/dist/runtime/polyfill/authApi.mjs +1 -2
- package/dist/runtime/polyfill/background.mjs +1 -2
- package/dist/runtime/polyfill/canvasContext.mjs +1 -2
- package/dist/runtime/polyfill/capability.mjs +1 -2
- package/dist/runtime/polyfill/cloud.mjs +1 -2
- package/dist/runtime/polyfill/device.mjs +1 -2
- package/dist/runtime/polyfill/deviceApi.mjs +1 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.d.mts +0 -2
- package/dist/runtime/polyfill/deviceAuthSystemApi.mjs +1 -2
- package/dist/runtime/polyfill/eventBus.mjs +1 -2
- package/dist/runtime/polyfill/filePicker.mjs +1 -2
- package/dist/runtime/polyfill/fileSystemManager.mjs +1 -2
- package/dist/runtime/polyfill/files.mjs +1 -2
- package/dist/runtime/polyfill/font.mjs +1 -2
- package/dist/runtime/polyfill/index.d.mts +4 -4
- package/dist/runtime/polyfill/index.mjs +12 -5
- package/dist/runtime/polyfill/index.mjs.map +1 -1
- package/dist/runtime/polyfill/interaction.mjs +1 -2
- package/dist/runtime/polyfill/interactionApi.mjs +1 -2
- package/dist/runtime/polyfill/intersectionObserver.mjs +4 -4
- package/dist/runtime/polyfill/intersectionObserver.mjs.map +1 -1
- package/dist/runtime/polyfill/lifecycleEvents.d.mts +12 -0
- package/dist/runtime/polyfill/lifecycleEvents.mjs +67 -0
- package/dist/runtime/polyfill/lifecycleEvents.mjs.map +1 -0
- package/dist/runtime/polyfill/locale.mjs +1 -2
- package/dist/runtime/polyfill/location.mjs +1 -2
- package/dist/runtime/polyfill/locationApi.mjs +1 -2
- package/dist/runtime/polyfill/mediaActions.mjs +1 -2
- package/dist/runtime/polyfill/mediaApi/file.mjs +1 -2
- package/dist/runtime/polyfill/mediaApi/info.mjs +1 -2
- package/dist/runtime/polyfill/mediaApi/picker.mjs +1 -2
- package/dist/runtime/polyfill/mediaApi/preview.mjs +1 -2
- package/dist/runtime/polyfill/mediaApi/process.mjs +1 -2
- package/dist/runtime/polyfill/mediaInfo.mjs +1 -2
- package/dist/runtime/polyfill/mediaPicker.mjs +1 -2
- package/dist/runtime/polyfill/mediaProcess.mjs +1 -2
- package/dist/runtime/polyfill/menuApi.mjs +5 -3
- package/dist/runtime/polyfill/menuApi.mjs.map +1 -1
- package/dist/runtime/polyfill/navigationBarRuntime.mjs +1 -2
- package/dist/runtime/polyfill/network/request.mjs +1 -2
- package/dist/runtime/polyfill/network/requestBridge.mjs +1 -2
- package/dist/runtime/polyfill/network/status.mjs +1 -2
- package/dist/runtime/polyfill/platformApi.mjs +1 -2
- package/dist/runtime/polyfill/platformRuntime.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/appLifecycle.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/dom.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/events.d.mts +0 -2
- package/dist/runtime/polyfill/routeRuntime/events.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/history.d.mts +0 -2
- package/dist/runtime/polyfill/routeRuntime/history.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/lifecycle.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/options.d.mts +1 -2
- package/dist/runtime/polyfill/routeRuntime/options.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/result.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs +37 -6
- package/dist/runtime/polyfill/routeRuntime/scroll.mjs.map +1 -1
- package/dist/runtime/polyfill/routeRuntime/stack.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime/url.mjs +1 -2
- package/dist/runtime/polyfill/routeRuntime.d.mts +2 -2
- package/dist/runtime/polyfill/routeRuntime.mjs +14 -5
- package/dist/runtime/polyfill/routeRuntime.mjs.map +1 -1
- package/dist/runtime/polyfill/runtimeCapabilityApi.mjs +1 -2
- package/dist/runtime/polyfill/runtimeDataApi.d.mts +0 -2
- package/dist/runtime/polyfill/runtimeDataApi.mjs +1 -2
- package/dist/runtime/polyfill/runtimeInfra.mjs +1 -2
- package/dist/runtime/polyfill/runtimeOps.mjs +1 -2
- package/dist/runtime/polyfill/selectorQuery.mjs +3 -3
- package/dist/runtime/polyfill/selectorQuery.mjs.map +1 -1
- package/dist/runtime/polyfill/storage.mjs +1 -2
- package/dist/runtime/polyfill/storageAsync.mjs +1 -2
- package/dist/runtime/polyfill/subscribe.mjs +1 -2
- package/dist/runtime/polyfill/system.mjs +1 -2
- package/dist/runtime/polyfill/systemApi.mjs +1 -2
- package/dist/runtime/polyfill/types/base.d.mts +0 -2
- package/dist/runtime/polyfill/types/common.d.mts +0 -2
- package/dist/runtime/polyfill/types/lifecycle.d.mts +12 -0
- package/dist/runtime/polyfill/types/locationRuntime.d.mts +0 -2
- package/dist/runtime/polyfill/types/mediaAuth.d.mts +0 -2
- package/dist/runtime/polyfill/types/platformRuntime.d.mts +0 -2
- package/dist/runtime/polyfill/types/systemAuth.d.mts +0 -2
- package/dist/runtime/polyfill/types/tabBarRuntime.d.mts +0 -2
- package/dist/runtime/polyfill/ui.mjs +1 -2
- package/dist/runtime/polyfill/uiFeedback.mjs +19 -5
- package/dist/runtime/polyfill/uiFeedback.mjs.map +1 -1
- package/dist/runtime/polyfill/uiMediaApi.d.mts +8 -2
- package/dist/runtime/polyfill/uiMediaApi.mjs +20 -5
- package/dist/runtime/polyfill/uiMediaApi.mjs.map +1 -1
- package/dist/runtime/polyfill/videoContext.mjs +1 -2
- package/dist/runtime/polyfill/vkSession.mjs +1 -2
- package/dist/runtime/polyfill/windowResize.mjs +1 -2
- package/dist/runtime/polyfill/worker.mjs +1 -2
- package/dist/runtime/polyfill.d.mts +4 -2
- package/dist/runtime/renderContext.d.mts +0 -2
- package/dist/runtime/renderContext.mjs +5 -4
- package/dist/runtime/renderContext.mjs.map +1 -1
- package/dist/runtime/rpx.d.mts +0 -2
- package/dist/runtime/rpx.mjs +6 -6
- package/dist/runtime/rpx.mjs.map +1 -1
- package/dist/runtime/seo/index.d.mts +0 -2
- package/dist/runtime/seo/index.mjs +1 -2
- package/dist/runtime/style.d.mts +0 -2
- package/dist/runtime/style.mjs +1 -2
- package/dist/runtime/template.d.mts +0 -2
- package/dist/runtime/utils/object.mjs +1 -2
- package/dist/runtime/viewport/index.d.mts +0 -2
- package/dist/runtime/viewport/index.mjs +1 -2
- package/dist/runtime/viewport/style.mjs +2 -2
- package/dist/runtime/viewport/style.mjs.map +1 -1
- package/dist/runtime/viewport/types.d.mts +0 -2
- package/dist/runtime/warning.d.mts +0 -2
- package/dist/runtime/warning.mjs +1 -2
- package/dist/runtime/wevu.d.mts +1 -2
- package/dist/runtime/wevu.mjs +1 -2
- package/dist/shared/nativeComponents.mjs +10 -3
- package/dist/shared/nativeComponents.mjs.map +1 -1
- package/dist/shared/slugify.mjs +1 -2
- package/dist/shared/styleUnits/options.d.mts +24 -0
- package/dist/shared/styleUnits/options.mjs +13 -0
- package/dist/shared/styleUnits/options.mjs.map +1 -0
- package/dist/shared/styleUnits/value.mjs +63 -0
- package/dist/shared/styleUnits/value.mjs.map +1 -0
- package/dist/shared/tabBar.d.mts +0 -2
- package/dist/shared/tabBar.mjs +1 -2
- package/dist/shared/wxml.mjs +1 -2
- package/package.json +15 -13
- package/dist/runtime/nativeComponents/richText/helpers.mjs +0 -230
- package/dist/runtime/nativeComponents/richText/helpers.mjs.map +0 -1
- package/dist/runtime/nativeComponents/scrollView.mjs +0 -88
- package/dist/runtime/nativeComponents/scrollView.mjs.map +0 -1
package/dist/css/wxss.d.mts
CHANGED
|
@@ -1,25 +1,8 @@
|
|
|
1
|
+
import { WxssTransformOptions } from "../shared/styleUnits/options.mjs";
|
|
1
2
|
import postcss from "postcss";
|
|
2
|
-
//#region src/css/wxss.d.ts
|
|
3
|
-
export interface WxssTransformOptions {
|
|
4
|
-
/**
|
|
5
|
-
* 1rpx 对应的 CSS 像素数。
|
|
6
|
-
* 默认值近似于 750rpx 设计稿在 375px 屏幕上的换算。
|
|
7
|
-
*/
|
|
8
|
-
pxPerRpx?: number;
|
|
9
|
-
/**
|
|
10
|
-
* rpx 换算的设计宽度。传入后会把 rpx 转为
|
|
11
|
-
* `calc(var(--rpx) * N)` 以实现响应式缩放。
|
|
12
|
-
*/
|
|
13
|
-
designWidth?: number;
|
|
14
|
-
/**
|
|
15
|
-
* 用于存储运行时 rpx 大小的 CSS 变量名。
|
|
16
|
-
* @default "--rpx"
|
|
17
|
-
*/
|
|
18
|
-
rpxVar?: string;
|
|
19
|
-
}
|
|
20
3
|
export interface WxssTransformResult {
|
|
21
4
|
css: string;
|
|
22
5
|
}
|
|
23
6
|
export declare function transformWxssToCss(source: string, options?: WxssTransformOptions): WxssTransformResult;
|
|
24
|
-
|
|
7
|
+
export type { WxssTransformOptions };
|
|
25
8
|
//# sourceMappingURL=wxss.d.mts.map
|
package/dist/css/wxss.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { resolveNativeComponentWebTag } from "../shared/nativeComponents.mjs";
|
|
2
|
+
import { resolveStyleUnitOptions } from "../shared/styleUnits/options.mjs";
|
|
3
|
+
import { transformStyleValue } from "../shared/styleUnits/value.mjs";
|
|
2
4
|
import postcss from "postcss";
|
|
3
5
|
import selectorParser from "postcss-selector-parser";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
const RPX_RE = /(-?(?:\d+(?:\.\d+)?|\.\d+))rpx/gi;
|
|
7
|
-
const SAFE_AREA_ENV_RE = /env\(\s*safe-area-inset-(top|right|bottom|left)(?:\s*,[^)]*)?\)/gi;
|
|
7
|
+
// src/css/wxss.ts
|
|
8
8
|
const PAGE_HOST_SELECTOR = selectorParser().astSync(":host(:where([data-weapp-page-active]))").nodes[0].nodes[0];
|
|
9
9
|
function isDeepPseudo(pseudo) {
|
|
10
10
|
return pseudo.value === ":deep" || pseudo.value === "::v-deep";
|
|
@@ -86,18 +86,12 @@ function transformWxssSelector(selector) {
|
|
|
86
86
|
return output.join(",\n");
|
|
87
87
|
}
|
|
88
88
|
function transformWxssRoot(root, options) {
|
|
89
|
-
const
|
|
90
|
-
const useVariable = options?.pxPerRpx === void 0 || typeof options.designWidth === "number" && Number.isFinite(options.designWidth);
|
|
91
|
-
const ratio = options?.pxPerRpx ?? .5;
|
|
89
|
+
const unitOptions = resolveStyleUnitOptions(options);
|
|
92
90
|
root.walkRules((rule) => {
|
|
93
91
|
if (rule.selector) rule.selector = transformWxssSelector(rule.selector);
|
|
94
92
|
});
|
|
95
93
|
root.walkDecls((declaration) => {
|
|
96
|
-
declaration.value = declaration.value
|
|
97
|
-
const numeric = Number.parseFloat(value);
|
|
98
|
-
if (useVariable) return `calc(var(${rpxVar}) * ${numeric})`;
|
|
99
|
-
return `${Math.round(numeric * ratio * 1e3) / 1e3}px`;
|
|
100
|
-
});
|
|
94
|
+
declaration.value = transformStyleValue(declaration.value, unitOptions);
|
|
101
95
|
});
|
|
102
96
|
}
|
|
103
97
|
function createWxssPostcssPlugin(options) {
|
|
@@ -114,6 +108,5 @@ function transformWxssToCss(source, options) {
|
|
|
114
108
|
return { css: root.toString() };
|
|
115
109
|
}
|
|
116
110
|
|
|
117
|
-
//#endregion
|
|
118
111
|
export { createWxssPostcssPlugin, transformWxssToCss };
|
|
119
112
|
//# sourceMappingURL=wxss.mjs.map
|
package/dist/css/wxss.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wxss.mjs","names":[],"sources":["../../src/css/wxss.ts"],"sourcesContent":["import postcss from 'postcss'\nimport selectorParser from 'postcss-selector-parser'\nimport { resolveNativeComponentWebTag } from '../shared/nativeComponents'\
|
|
1
|
+
{"version":3,"file":"wxss.mjs","names":[],"sources":["../../src/css/wxss.ts"],"sourcesContent":["import type { WxssTransformOptions } from '../shared/styleUnits/options'\nimport postcss from 'postcss'\nimport selectorParser from 'postcss-selector-parser'\nimport { resolveNativeComponentWebTag } from '../shared/nativeComponents'\nimport { resolveStyleUnitOptions } from '../shared/styleUnits/options'\nimport { transformStyleValue } from '../shared/styleUnits/value'\n\nexport type { WxssTransformOptions } from '../shared/styleUnits/options'\n\nexport interface WxssTransformResult {\n css: string\n}\n\nconst PAGE_HOST_SELECTOR = selectorParser().astSync(':host(:where([data-weapp-page-active]))').nodes[0]!.nodes[0]!\n\nfunction isDeepPseudo(pseudo: selectorParser.Pseudo) {\n return pseudo.value === ':deep' || pseudo.value === '::v-deep'\n}\n\nfunction flattenDeepPseudos(selector: selectorParser.Selector) {\n selector.walkPseudos((pseudo) => {\n if (!isDeepPseudo(pseudo)) {\n return\n }\n const nestedSelector = pseudo.nodes?.[0]\n if (nestedSelector && nestedSelector.nodes.length > 0) {\n pseudo.replaceWith(...nestedSelector.nodes.map(node => node.clone()))\n return\n }\n pseudo.remove()\n })\n}\n\nfunction transformNativeTags(selector: selectorParser.Selector) {\n selector.walkTags((tag) => {\n if (tag.parent?.type === 'selector' && tag.parent.parent?.type === 'pseudo' && tag.parent.parent.value === '::part') {\n return\n }\n if (tag.value === 'page') {\n tag.replaceWith(PAGE_HOST_SELECTOR.clone())\n return\n }\n const webTag = resolveNativeComponentWebTag(tag.value)\n if (webTag) {\n tag.value = webTag\n }\n })\n}\n\nfunction createPartPseudo(className: string) {\n return selectorParser.pseudo({\n value: '::part',\n nodes: [selectorParser.selector({\n value: '',\n nodes: [selectorParser.tag({ value: className })],\n })],\n })\n}\n\nfunction createVirtualHostPartSelector(source: selectorParser.Selector) {\n const selector = source.clone()\n let deepPseudo: selectorParser.Pseudo | undefined\n selector.walkPseudos((pseudo) => {\n if (!deepPseudo && isDeepPseudo(pseudo)) {\n deepPseudo = pseudo\n }\n })\n if (!deepPseudo || deepPseudo.parent?.type !== 'selector') {\n return undefined\n }\n\n const parent = deepPseudo.parent\n const pseudoIndex = parent.nodes.indexOf(deepPseudo)\n const nestedNodes = deepPseudo.nodes?.[0]?.nodes ?? []\n const nestedTargetClass = nestedNodes.find(node => node.type === 'class')?.value\n let targetStart = pseudoIndex\n if (nestedNodes.length > 0) {\n deepPseudo.replaceWith(...nestedNodes.map(node => node.clone()))\n }\n else {\n deepPseudo.remove()\n while (parent.nodes[targetStart]?.type === 'combinator') {\n targetStart += 1\n }\n }\n\n let targetEnd = targetStart\n while (targetEnd + 1 < parent.nodes.length && parent.nodes[targetEnd + 1]?.type !== 'combinator') {\n targetEnd += 1\n }\n if (targetStart >= parent.nodes.length || targetEnd < parent.nodes.length - 1) {\n return undefined\n }\n\n const targetNodes = parent.nodes.slice(targetStart, targetEnd + 1)\n const targetClass = nestedTargetClass\n ?? targetNodes.find(node => node.type === 'class')?.value\n const targetNode = parent.nodes[targetEnd]!\n if (!targetClass) {\n return undefined\n }\n\n const firstTargetPseudo = targetNodes.find(node => node.type === 'pseudo')\n if (firstTargetPseudo?.value.startsWith(':') && !firstTargetPseudo.value.startsWith('::')) {\n return undefined\n }\n if (firstTargetPseudo) {\n parent.insertBefore(firstTargetPseudo, createPartPseudo(targetClass))\n }\n else {\n parent.insertAfter(targetNode, createPartPseudo(targetClass))\n }\n flattenDeepPseudos(selector)\n transformNativeTags(selector)\n return selector\n}\n\nfunction transformWxssSelector(selector: string) {\n const root = selectorParser().astSync(selector)\n const output: string[] = []\n for (const sourceSelector of root.nodes) {\n const partSelector = createVirtualHostPartSelector(sourceSelector)\n const flatSelector = sourceSelector.clone()\n flattenDeepPseudos(flatSelector)\n transformNativeTags(flatSelector)\n output.push(flatSelector.toString())\n if (partSelector) {\n output.push(partSelector.toString())\n }\n }\n return output.join(',\\n')\n}\n\nfunction transformWxssRoot(root: postcss.Root, options?: WxssTransformOptions) {\n const unitOptions = resolveStyleUnitOptions(options)\n root.walkRules((rule) => {\n if (rule.selector) {\n rule.selector = transformWxssSelector(rule.selector)\n }\n })\n root.walkDecls((declaration) => {\n declaration.value = transformStyleValue(declaration.value, unitOptions)\n })\n}\n\nexport function createWxssPostcssPlugin(options?: WxssTransformOptions) {\n return {\n postcssPlugin: 'weapp-vite-web-wxss',\n Once(root: postcss.Root) {\n transformWxssRoot(root, options)\n },\n }\n}\n\nexport function transformWxssToCss(source: string, options?: WxssTransformOptions): WxssTransformResult {\n const root = postcss.parse(source)\n transformWxssRoot(root, options)\n return {\n css: root.toString(),\n }\n}\n"],"mappings":"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"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ResolvedStyleUnitOptions } from "./shared/styleUnits/options.mjs";
|
|
1
2
|
import { transformWxssToCss } from "./css/wxss.mjs";
|
|
2
3
|
import { RenderContext, createRenderContext } from "./runtime/renderContext.mjs";
|
|
3
4
|
import { createTemplate, renderTemplate } from "./runtime/legacyTemplate/index.mjs";
|
|
@@ -11,14 +12,16 @@ import { WeappWebPluginOptions } from "./plugin/types.mjs";
|
|
|
11
12
|
import { weappWebPlugin } from "./plugin/index.mjs";
|
|
12
13
|
import "./plugin.mjs";
|
|
13
14
|
import { ButtonFormConfig, ensureButtonDefined, setButtonFormConfig } from "./runtime/button/index.mjs";
|
|
15
|
+
import { bindRuntimeDataset } from "./runtime/datasetBinding.mjs";
|
|
14
16
|
import { bindRuntimeEvent } from "./runtime/eventBinding.mjs";
|
|
15
17
|
import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./runtime/execution.mjs";
|
|
16
18
|
import { WebRuntimeClipboard, WebRuntimeDialogs, WebRuntimeHost, WebRuntimeStorage } from "./runtime/host/types.mjs";
|
|
17
19
|
import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./runtime/host/index.mjs";
|
|
18
20
|
import { installWebHostGlobals } from "./runtime/hostGlobals.mjs";
|
|
21
|
+
import { transformInlineStyleValue } from "./runtime/inlineStyle.mjs";
|
|
19
22
|
import { resolveImageModeStyle } from "./runtime/nativeComponents/image.mjs";
|
|
20
23
|
import { createInputEventDetail } from "./runtime/nativeComponents/input.mjs";
|
|
21
|
-
import { createScrollEventDetail } from "./runtime/nativeComponents/scrollView.mjs";
|
|
24
|
+
import { createScrollEventDetail } from "./runtime/nativeComponents/scrollView/helpers.mjs";
|
|
22
25
|
import { createSwitchEventDetail } from "./runtime/nativeComponents/switch.mjs";
|
|
23
26
|
import { createTextareaLineChangeDetail } from "./runtime/nativeComponents/textarea.mjs";
|
|
24
27
|
import { createVideoProgressDetail, createVideoTimeUpdateDetail, resolveVideoObjectFit } from "./runtime/nativeComponents/video/helpers.mjs";
|
|
@@ -26,12 +29,14 @@ import { ensureNativeComponentsDefined } from "./runtime/nativeComponents/index.
|
|
|
26
29
|
import { NavigationBarMetrics, setNavigationBarMetrics } from "./runtime/navigationBar/index.mjs";
|
|
27
30
|
import { setPageLayout } from "./runtime/pageLayout.mjs";
|
|
28
31
|
import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./runtime/polyfill/deviceAuthSystemApi.mjs";
|
|
32
|
+
import { MiniProgramErrorCallback, ThemeChangeCallback, ThemeChangeEvent, UnhandledRejectionCallback, UnhandledRejectionEvent } from "./runtime/polyfill/types/lifecycle.mjs";
|
|
33
|
+
import { offError, offThemeChange, offUnhandledRejection, onError, onThemeChange, onUnhandledRejection, reportEvent } from "./runtime/polyfill/lifecycleEvents.mjs";
|
|
29
34
|
import { ResolvedWebViewportConfig, WebViewportConfig } from "./runtime/viewport/types.mjs";
|
|
30
35
|
import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./runtime/viewport/index.mjs";
|
|
31
36
|
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./runtime/polyfill/routeRuntime.mjs";
|
|
32
37
|
import { AppRouteCallback, AppRouteEvent, AppRouteOpenType, BeforePageUnloadCallback, BeforePageUnloadEvent, offAppRoute, offAppRouteDone, offBeforeAppRoute, offBeforePageUnload, onAppRoute, onAppRouteDone, onBeforeAppRoute, onBeforePageUnload } from "./runtime/polyfill/routeRuntime/events.mjs";
|
|
33
38
|
import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtime/polyfill/runtimeDataApi.mjs";
|
|
34
|
-
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./runtime/polyfill/uiMediaApi.mjs";
|
|
39
|
+
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideHomeButton, hideLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./runtime/polyfill/uiMediaApi.mjs";
|
|
35
40
|
import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./runtime/polyfill/index.mjs";
|
|
36
41
|
import { RpxConfig, setupRpx } from "./runtime/rpx.mjs";
|
|
37
42
|
import { injectStyle, removeStyle } from "./runtime/style.mjs";
|
|
@@ -39,4 +44,4 @@ import { RuntimeWarningLevel, RuntimeWarningOptions, setRuntimeWarningOptions }
|
|
|
39
44
|
import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory } from "./runtime/wevu.mjs";
|
|
40
45
|
import "./runtime/index.mjs";
|
|
41
46
|
export * from "wevu/internal-runtime";
|
|
42
|
-
export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppRouteCallback, type AppRouteEvent, type AppRouteOpenType, type AppShowCallback, type BeforePageUnloadCallback, type BeforePageUnloadEvent, type ButtonFormConfig, type NavigationBarMetrics, type RenderContext, type ResolvedWebRoutingConfig, type ResolvedWebViewportConfig, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, type WeappWebPluginOptions, type WebPageHead, type WebResourceHint, type WebResourceHintRelation, type WebResourceHintsConfig, type WebRouteHistoryState, type WebRouteTarget, type WebRoutingConfig, type WebRoutingMode, type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, type WebSeoConfig, type WebTabBarConfig, type WebTabBarItem, type WebViewportConfig, authorize, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offNetworkStatusChange, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, transformWxssToCss, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort, weappWebPlugin };
|
|
47
|
+
export { type AppHideCallback, type AppHideOptions, type AppLaunchOptions, type AppRouteCallback, type AppRouteEvent, type AppRouteOpenType, type AppShowCallback, type BeforePageUnloadCallback, type BeforePageUnloadEvent, type ButtonFormConfig, type MiniProgramErrorCallback, type NavigationBarMetrics, type RenderContext, type ResolvedStyleUnitOptions, type ResolvedWebRoutingConfig, type ResolvedWebViewportConfig, type RpxConfig, type RuntimeWarningLevel, type RuntimeWarningOptions, type TemplateRenderer, type TemplateScope, type ThemeChangeCallback, type ThemeChangeEvent, type UnhandledRejectionCallback, type UnhandledRejectionEvent, type WeappWebPluginOptions, type WebPageHead, type WebResourceHint, type WebResourceHintRelation, type WebResourceHintsConfig, type WebRouteHistoryState, type WebRouteTarget, type WebRoutingConfig, type WebRoutingMode, type WebRuntimeClipboard, type WebRuntimeDialogs, type WebRuntimeHost, type WebRuntimeStorage, type WebSeoConfig, type WebTabBarConfig, type WebTabBarItem, type WebViewportConfig, authorize, bindRuntimeDataset, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offError, offNetworkStatusChange, offThemeChange, offUnhandledRejection, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onError, onNetworkStatusChange, onThemeChange, onUnhandledRejection, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, reportEvent, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, transformInlineStyleValue, transformWxssToCss, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort, weappWebPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -5,28 +5,31 @@ import { setRuntimeWarningOptions } from "./runtime/warning.mjs";
|
|
|
5
5
|
import { installWebHostGlobals } from "./runtime/hostGlobals.mjs";
|
|
6
6
|
import { getRuntimeClipboard, getRuntimeDialogs, getRuntimeFetch, getRuntimeStorage, getWebRuntimeHost, openRuntimeUrl, resetWebRuntimeHost, setWebRuntimeHost } from "./runtime/host/index.mjs";
|
|
7
7
|
import { authorize, checkSession, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getDeviceInfo, getFuzzyLocation, getLocation, getMenuButtonBoundingClientRect, getNetworkType, getSetting, getSystemInfo, getSystemInfoSync, getSystemSetting, getUserInfo, getUserProfile, getWindowInfo, login, offNetworkStatusChange, offWindowResize, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openSetting, vibrateShort } from "./runtime/polyfill/deviceAuthSystemApi.mjs";
|
|
8
|
+
import { offError, offThemeChange, offUnhandledRejection, onError, onThemeChange, onUnhandledRejection, reportEvent } from "./runtime/polyfill/lifecycleEvents.mjs";
|
|
8
9
|
import { configureWebSeo, resetWebDocumentHead, setupWebResourceHints, syncWebDocumentHead, updateWebDocumentTitle } from "./runtime/seo/index.mjs";
|
|
9
10
|
import { injectStyle, removeStyle } from "./runtime/style.mjs";
|
|
10
11
|
import { ensureButtonDefined, setButtonFormConfig } from "./runtime/button/index.mjs";
|
|
11
12
|
import { getRuntimeExecutionMode, setRuntimeExecutionMode } from "./runtime/execution.mjs";
|
|
12
13
|
import { createRenderContext } from "./runtime/renderContext.mjs";
|
|
13
14
|
import { defineComponent } from "./runtime/component/index.mjs";
|
|
15
|
+
import { transformInlineStyleValue } from "./runtime/inlineStyle.mjs";
|
|
14
16
|
import { resolveImageModeStyle } from "./runtime/nativeComponents/image.mjs";
|
|
15
17
|
import { createInputEventDetail } from "./runtime/nativeComponents/input.mjs";
|
|
16
18
|
import { clearStorage, clearStorageSync, createCanvasContext, createSelectorQuery, createVKSession, createVideoContext, createWorker, downloadFile, exitMiniProgram, getFileSystemManager, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, hideKeyboard, loadSubPackage, navigateToMiniProgram, nextTick, pageScrollTo, preloadSubpackage, removeStorage, removeStorageSync, request, setStorage, setStorageSync, startPullDownRefresh, stopPullDownRefresh, uploadFile } from "./runtime/polyfill/runtimeDataApi.mjs";
|
|
17
|
-
import {
|
|
19
|
+
import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./runtime/viewport/index.mjs";
|
|
20
|
+
import { setupRpx } from "./runtime/rpx.mjs";
|
|
21
|
+
import { createScrollEventDetail } from "./runtime/nativeComponents/scrollView/helpers.mjs";
|
|
18
22
|
import { createSwitchEventDetail } from "./runtime/nativeComponents/switch.mjs";
|
|
19
23
|
import { createTextareaLineChangeDetail } from "./runtime/nativeComponents/textarea.mjs";
|
|
20
24
|
import { createVideoProgressDetail, createVideoTimeUpdateDetail, resolveVideoObjectFit } from "./runtime/nativeComponents/video/helpers.mjs";
|
|
21
25
|
import { ensureNativeComponentsDefined } from "./runtime/nativeComponents/index.mjs";
|
|
22
26
|
import { setNavigationBarMetrics } from "./runtime/navigationBar/index.mjs";
|
|
23
|
-
import { getWebViewportWidth, resolveWebViewportConfig, setupWebViewport } from "./runtime/viewport/index.mjs";
|
|
24
|
-
import { setupRpx } from "./runtime/rpx.mjs";
|
|
25
27
|
import { offAppRoute, offAppRouteDone, offBeforeAppRoute, offBeforePageUnload, onAppRoute, onAppRouteDone, onBeforeAppRoute, onBeforePageUnload } from "./runtime/polyfill/routeRuntime/events.mjs";
|
|
26
28
|
import { disposeWebRouting, getWebRoutingConfig, resolveWebRoutingConfig } from "./runtime/polyfill/routeRuntime/history.mjs";
|
|
27
29
|
import { getEnterOptionsSync, getLaunchOptionsSync, initializePageRoutes, navigateBack, navigateTo, offAppHide, offAppShow, onAppHide, onAppShow, reLaunch, redirectTo, registerApp, registerComponent, registerPage, switchTab } from "./runtime/polyfill/routeRuntime.mjs";
|
|
28
|
-
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./runtime/polyfill/uiMediaApi.mjs";
|
|
30
|
+
import { chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, compressImage, compressVideo, getClipboardData, getImageInfo, getVideoInfo, hideHomeButton, hideLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, makePhoneCall, openCustomerServiceChat, openDocument, openLocation, openVideoEditor, previewImage, previewMedia, removeTabBarBadge, requestPayment, requestSubscribeMessage, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setClipboardData, setTabBarBadge, setTabBarItem, setTabBarStyle, showActionSheet, showLoading, showModal, showShareMenu, showTabBar, showTabBarRedDot, showToast, updateShareMenu } from "./runtime/polyfill/uiMediaApi.mjs";
|
|
29
31
|
import { canIUse, createInterstitialAd, createRewardedVideoAd, getExtConfig, getExtConfigSync, getLogManager, getUpdateManager, hideNavigationBarLoading, reportAnalytics, setBackgroundColor, setBackgroundTextStyle, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading } from "./runtime/polyfill/index.mjs";
|
|
32
|
+
import { bindRuntimeDataset } from "./runtime/datasetBinding.mjs";
|
|
30
33
|
import { bindRuntimeEvent } from "./runtime/eventBinding.mjs";
|
|
31
34
|
import { setPageLayout } from "./runtime/pageLayout.mjs";
|
|
32
35
|
import { createTemplate, renderTemplate } from "./runtime/legacyTemplate/index.mjs";
|
|
@@ -34,4 +37,4 @@ import { installWebModuleRegistration, registerWebWevuApp, registerWebWevuCompon
|
|
|
34
37
|
|
|
35
38
|
export * from "wevu/internal-runtime"
|
|
36
39
|
|
|
37
|
-
export { authorize, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideKeyboard, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offNetworkStatusChange, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onNetworkStatusChange, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, transformWxssToCss, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort, weappWebPlugin };
|
|
40
|
+
export { authorize, bindRuntimeDataset, bindRuntimeEvent, canIUse, checkSession, chooseAddress, chooseFile, chooseImage, chooseLocation, chooseMedia, chooseMessageFile, chooseVideo, clearStorage, clearStorageSync, compressImage, compressVideo, configureWebSeo, createCanvasContext, createInputEventDetail, createInterstitialAd, createRenderContext, createRewardedVideoAd, createScrollEventDetail, createSelectorQuery, createSwitchEventDetail, createTemplate, createTextareaLineChangeDetail, createVKSession, createVideoContext, createVideoProgressDetail, createVideoTimeUpdateDetail, createWorker, defineComponent, disposeWebRouting, downloadFile, ensureButtonDefined, ensureNativeComponentsDefined, exitMiniProgram, getAccountInfoSync, getAppAuthorizeSetting, getAppBaseInfo, getBatteryInfo, getBatteryInfoSync, getClipboardData, getDeviceInfo, getEnterOptionsSync, getExtConfig, getExtConfigSync, getFileSystemManager, getFuzzyLocation, getImageInfo, getLaunchOptionsSync, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNetworkType, getRuntimeClipboard, getRuntimeDialogs, getRuntimeExecutionMode, getRuntimeFetch, getRuntimeStorage, getSetting, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSystemInfo, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserInfo, getUserProfile, getVideoInfo, getWebRoutingConfig, getWebRuntimeHost, getWebViewportWidth, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, initializePageRoutes, injectStyle, installWebHostGlobals, installWebModuleRegistration, loadSubPackage, login, makePhoneCall, navigateBack, navigateTo, navigateToMiniProgram, nextTick, offAppHide, offAppRoute, offAppRouteDone, offAppShow, offBeforeAppRoute, offBeforePageUnload, offError, offNetworkStatusChange, offThemeChange, offUnhandledRejection, offWindowResize, onAppHide, onAppRoute, onAppRouteDone, onAppShow, onBeforeAppRoute, onBeforePageUnload, onError, onNetworkStatusChange, onThemeChange, onUnhandledRejection, onWindowResize, openAppAuthorizeSetting, openCustomerServiceChat, openDocument, openLocation, openRuntimeUrl, openSetting, openVideoEditor, pageScrollTo, preloadSubpackage, previewImage, previewMedia, reLaunch, redirectTo, registerApp, registerComponent, registerPage, registerWebWevuApp, registerWebWevuComponent, registerWebWevuComponentFactory, removeStorage, removeStorageSync, removeStyle, removeTabBarBadge, renderTemplate, reportAnalytics, reportEvent, request, requestPayment, requestSubscribeMessage, resetWebDocumentHead, resetWebRuntimeHost, resolveImageModeStyle, resolveVideoObjectFit, resolveWebRoutingConfig, resolveWebViewportConfig, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, setBackgroundColor, setBackgroundTextStyle, setButtonFormConfig, setClipboardData, setNavigationBarColor, setNavigationBarMetrics, setNavigationBarTitle, setPageLayout, setRuntimeExecutionMode, setRuntimeWarningOptions, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setWebRuntimeHost, setupRpx, setupWebResourceHints, setupWebViewport, showActionSheet, showLoading, showModal, showNavigationBarLoading, showShareMenu, showTabBar, showTabBarRedDot, showToast, startPullDownRefresh, stopPullDownRefresh, switchTab, syncWebDocumentHead, transformInlineStyleValue, transformWxssToCss, updateShareMenu, updateWebDocumentTitle, uploadFile, vibrateShort, weappWebPlugin };
|
package/dist/plugin/assets.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
-
//#region src/plugin/assets.d.ts
|
|
3
2
|
type WebAssetNext = (error?: unknown) => void;
|
|
4
3
|
export declare function createWebAssetMiddleware(srcRoot: string): (request: IncomingMessage, response: ServerResponse, next: WebAssetNext) => void;
|
|
5
|
-
|
|
4
|
+
export {};
|
|
6
5
|
//# sourceMappingURL=assets.d.mts.map
|
package/dist/plugin/assets.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, readdir, stat } from "node:fs/promises";
|
|
|
3
3
|
import { extname, relative, resolve } from "pathe";
|
|
4
4
|
import { createReadStream } from "node:fs";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/plugin/assets.ts
|
|
7
7
|
const WEB_ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
8
8
|
".aac",
|
|
9
9
|
".avif",
|
|
@@ -117,6 +117,5 @@ function createWebAssetMiddleware(srcRoot) {
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
//#endregion
|
|
121
120
|
export { createWebAssetMiddleware, emitWebAssets, resolveWebAssetRequest };
|
|
122
121
|
//# sourceMappingURL=assets.mjs.map
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { WEAPP_VITE_WEB_AUTO_ROUTES_RESOLVED_MODULE_ID, WEAPP_VITE_WEB_ENTRY_RESOLVED_MODULE_ID } from "@weapp-core/constants";
|
|
2
|
+
|
|
3
|
+
// src/plugin/constants.ts
|
|
2
4
|
const SCRIPT_EXTS = [
|
|
3
5
|
".vue",
|
|
4
6
|
".ts",
|
|
@@ -37,10 +39,10 @@ const WXS_RESOLVE_EXTS = [
|
|
|
37
39
|
".ts",
|
|
38
40
|
".js"
|
|
39
41
|
];
|
|
40
|
-
const ENTRY_ID =
|
|
42
|
+
const ENTRY_ID = WEAPP_VITE_WEB_ENTRY_RESOLVED_MODULE_ID;
|
|
41
43
|
const RUNTIME_ID = "/@weapp-vite/web/runtime";
|
|
42
44
|
const AUTO_ROUTES_ID = "weapp-vite/auto-routes";
|
|
43
|
-
const RESOLVED_AUTO_ROUTES_ID =
|
|
45
|
+
const RESOLVED_AUTO_ROUTES_ID = WEAPP_VITE_WEB_AUTO_ROUTES_RESOLVED_MODULE_ID;
|
|
44
46
|
const TEMPLATE_QUERY = "weapp-web-template";
|
|
45
47
|
const STYLE_QUERY = "weapp-web-style";
|
|
46
48
|
const SFC_TEMPLATE_QUERY = "weapp-web-sfc-template";
|
|
@@ -48,6 +50,5 @@ const SFC_STYLE_QUERY = "weapp-web-sfc-style";
|
|
|
48
50
|
const WEB_COMPONENT_PREFIX = "/@weapp-vite/web/component/";
|
|
49
51
|
const WEB_COMPONENT_QUERY = "weapp-web-component";
|
|
50
52
|
|
|
51
|
-
//#endregion
|
|
52
53
|
export { AUTO_ROUTES_ID, ENTRY_ID, RESOLVED_AUTO_ROUTES_ID, RUNTIME_ID, SCRIPT_EXTS, SFC_STYLE_QUERY, SFC_TEMPLATE_QUERY, STYLE_EXTS, STYLE_QUERY, TEMPLATE_EXTS, TEMPLATE_QUERY, TRANSFORM_STYLE_EXTS, WEB_COMPONENT_PREFIX, WEB_COMPONENT_QUERY, WXS_EXTS, WXS_RESOLVE_EXTS };
|
|
53
54
|
//# sourceMappingURL=constants.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/plugin/constants.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.mjs","names":[],"sources":["../../src/plugin/constants.ts"],"sourcesContent":["import {\n WEAPP_VITE_WEB_AUTO_ROUTES_RESOLVED_MODULE_ID,\n WEAPP_VITE_WEB_ENTRY_RESOLVED_MODULE_ID,\n} from '@weapp-core/constants'\n\nexport const SCRIPT_EXTS = ['.vue', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs']\nexport const STYLE_EXTS = ['.wxss', '.scss', '.less', '.css']\nexport const TRANSFORM_STYLE_EXTS = ['.wxss']\nexport const TEMPLATE_EXTS = ['.wxml', '.axml', '.swan', '.ttml', '.qml', '.ksml', '.xhsml', '.html']\nexport const WXS_EXTS = ['.wxs', '.wxs.ts', '.wxs.js']\nexport const WXS_RESOLVE_EXTS = ['.wxs', '.wxs.ts', '.wxs.js', '.ts', '.js']\n\nexport const ENTRY_ID = WEAPP_VITE_WEB_ENTRY_RESOLVED_MODULE_ID\nexport const RUNTIME_ID = '/@weapp-vite/web/runtime'\nexport const AUTO_ROUTES_ID = 'weapp-vite/auto-routes'\nexport const RESOLVED_AUTO_ROUTES_ID = WEAPP_VITE_WEB_AUTO_ROUTES_RESOLVED_MODULE_ID\nexport const TEMPLATE_QUERY = 'weapp-web-template'\nexport const STYLE_QUERY = 'weapp-web-style'\nexport const SFC_TEMPLATE_QUERY = 'weapp-web-sfc-template'\nexport const SFC_STYLE_QUERY = 'weapp-web-sfc-style'\nexport const WEB_COMPONENT_PREFIX = '/@weapp-vite/web/component/'\nexport const WEB_COMPONENT_QUERY = 'weapp-web-component'\n"],"mappings":";;;AAKA,MAAa,cAAc;CAAC;CAAQ;CAAO;CAAQ;CAAO;CAAQ;CAAQ;AAAM;AAChF,MAAa,aAAa;CAAC;CAAS;CAAS;CAAS;AAAM;AAC5D,MAAa,uBAAuB,CAAC,OAAO;AAC5C,MAAa,gBAAgB;CAAC;CAAS;CAAS;CAAS;CAAS;CAAQ;CAAS;CAAU;AAAO;AACpG,MAAa,WAAW;CAAC;CAAQ;CAAW;AAAS;AACrD,MAAa,mBAAmB;CAAC;CAAQ;CAAW;CAAW;CAAO;AAAK;AAE3E,MAAa,WAAW;AACxB,MAAa,aAAa;AAC1B,MAAa,iBAAiB;AAC9B,MAAa,0BAA0B;AACvC,MAAa,iBAAiB;AAC9B,MAAa,cAAc;AAC3B,MAAa,qBAAqB;AAClC,MAAa,kBAAkB;AAC/B,MAAa,uBAAuB;AACpC,MAAa,sBAAsB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extname } from "pathe";
|
|
2
2
|
import { build } from "esbuild";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/plugin/dependencyScan.ts
|
|
5
5
|
const SCRIPT_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
6
6
|
".cjs",
|
|
7
7
|
".js",
|
|
@@ -36,6 +36,5 @@ async function collectExternalComponentOptimizeDeps(components) {
|
|
|
36
36
|
return Array.from(dependencies).sort();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
export { collectExternalComponentOptimizeDeps };
|
|
41
40
|
//# sourceMappingURL=dependencyScan.mjs.map
|
package/dist/plugin/entry.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { resolveStyleUnitOptions } from "../shared/styleUnits/options.mjs";
|
|
1
2
|
import { WEB_COMPONENT_PREFIX } from "./constants.mjs";
|
|
2
3
|
import { relativeModuleId, resolveRuntimePolyfillPath, toViteFsImport } from "./path.mjs";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
// src/plugin/entry.ts
|
|
5
6
|
function generateAutoRoutesModule(result) {
|
|
6
7
|
const pages = result.pages.map((page) => page.id);
|
|
7
8
|
const subPackageMap = /* @__PURE__ */ new Map();
|
|
@@ -52,11 +53,13 @@ function generateEntryModule(result, root, wxssOptions, pluginOptions) {
|
|
|
52
53
|
}
|
|
53
54
|
for (const layout of result.layouts) importLines.push(`import '${relativeModuleId(root, layout.script)}'`);
|
|
54
55
|
const pageOrder = result.pages.map((page) => page.id);
|
|
55
|
-
const
|
|
56
|
-
|
|
56
|
+
const unitOptions = resolveStyleUnitOptions(wxssOptions);
|
|
57
|
+
const rpxConfig = unitOptions.useVariable ? {
|
|
58
|
+
designWidth: unitOptions.designWidth,
|
|
57
59
|
varName: wxssOptions?.rpxVar
|
|
58
60
|
} : void 0;
|
|
59
61
|
const initOptions = {};
|
|
62
|
+
initOptions.styleUnits = unitOptions;
|
|
60
63
|
if (result.tabBar) initOptions.tabBar = result.tabBar;
|
|
61
64
|
if (rpxConfig) initOptions.rpx = rpxConfig;
|
|
62
65
|
if (pluginOptions?.form?.preventDefault !== void 0) initOptions.form = { preventDefault: pluginOptions.form.preventDefault };
|
|
@@ -73,6 +76,5 @@ function generateEntryModule(result, root, wxssOptions, pluginOptions) {
|
|
|
73
76
|
return [...importLines, ...bodyLines].join("\n");
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
//#endregion
|
|
77
79
|
export { generateAutoRoutesModule, generateEntryModule };
|
|
78
80
|
//# sourceMappingURL=entry.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry.mjs","names":[],"sources":["../../src/plugin/entry.ts"],"sourcesContent":["import type { WxssTransformOptions } from '../css/wxss'\
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":[],"sources":["../../src/plugin/entry.ts"],"sourcesContent":["import type { WxssTransformOptions } from '../css/wxss'\nimport type { ScanResult, WeappWebPluginOptions } from './types'\n\nimport { resolveStyleUnitOptions } from '../shared/styleUnits/options'\nimport { WEB_COMPONENT_PREFIX } from './constants'\nimport { relativeModuleId, resolveRuntimePolyfillPath, toViteFsImport } from './path'\n\nexport function generateAutoRoutesModule(result: ScanResult) {\n const pages = result.pages.map(page => page.id)\n const subPackageMap = new Map<string, string[]>()\n for (const id of pages) {\n const pagesSegment = id.indexOf('/pages/')\n if (pagesSegment <= 0) {\n continue\n }\n const root = id.slice(0, pagesSegment)\n const route = id.slice(pagesSegment + 1)\n const routes = subPackageMap.get(root) ?? []\n routes.push(route)\n subPackageMap.set(root, routes)\n }\n const mainPages = pages.filter(id => !id.includes('/pages/'))\n const subPackages = [...subPackageMap].map(([root, routes]) => ({ root, pages: routes }))\n const snapshot = JSON.stringify({ pages: mainPages, entries: pages, subPackages })\n return [\n `const routes = ${snapshot}`,\n `const call = (name, options) => globalThis.wx?.[name]?.(options)`,\n `export const pages = routes.pages`,\n `export const entries = routes.entries`,\n `export const subPackages = routes.subPackages`,\n `export const miniProgramRouter = {`,\n ` switchTab: options => call('switchTab', options),`,\n ` reLaunch: options => call('reLaunch', options),`,\n ` redirectTo: options => call('redirectTo', options),`,\n ` navigateTo: options => call('navigateTo', options),`,\n ` navigateBack: options => call('navigateBack', options),`,\n `}`,\n `export const wxRouter = miniProgramRouter`,\n `export { routes }`,\n `export default routes`,\n ].join('\\n')\n}\n\nexport function generateEntryModule(\n result: ScanResult,\n root: string,\n wxssOptions?: WxssTransformOptions,\n pluginOptions?: WeappWebPluginOptions,\n) {\n const runtimePolyfillId = pluginOptions?.__runtimeProvider?.moduleId\n ?? toViteFsImport(resolveRuntimePolyfillPath())\n const importLines: string[] = [`import { initializePageRoutes } from '${runtimePolyfillId}'`]\n const bodyLines: string[] = []\n\n if (result.app) {\n importLines.push(`import '${relativeModuleId(root, result.app)}'`)\n }\n for (const page of result.pages) {\n importLines.push(`import '${relativeModuleId(root, page.script)}'`)\n }\n for (const component of result.components) {\n const componentImportId = component.importId\n ? `${WEB_COMPONENT_PREFIX}${encodeURIComponent(component.importId)}`\n : relativeModuleId(root, component.script)\n importLines.push(`import '${componentImportId}'`)\n }\n for (const layout of result.layouts) {\n importLines.push(`import '${relativeModuleId(root, layout.script)}'`)\n }\n\n const pageOrder = result.pages.map(page => page.id)\n const unitOptions = resolveStyleUnitOptions(wxssOptions)\n const rpxConfig = unitOptions.useVariable\n ? { designWidth: unitOptions.designWidth, varName: wxssOptions?.rpxVar }\n : undefined\n\n const initOptions: Record<string, any> = {}\n initOptions.styleUnits = unitOptions\n if (result.tabBar) {\n initOptions.tabBar = result.tabBar\n }\n if (rpxConfig) {\n initOptions.rpx = rpxConfig\n }\n if (pluginOptions?.form?.preventDefault !== undefined) {\n initOptions.form = { preventDefault: pluginOptions.form.preventDefault }\n }\n\n const runtimeOptions: Record<string, any> = {}\n if (pluginOptions?.runtime?.executionMode) {\n runtimeOptions.executionMode = pluginOptions.runtime.executionMode\n }\n if (pluginOptions?.runtime?.warnings) {\n runtimeOptions.warnings = pluginOptions.runtime.warnings\n }\n if (pluginOptions?.runtime?.viewport) {\n runtimeOptions.viewport = pluginOptions.runtime.viewport\n }\n if (pluginOptions?.runtime?.routing) {\n runtimeOptions.routing = pluginOptions.runtime.routing\n }\n if (pluginOptions?.runtime?.seo) {\n runtimeOptions.seo = pluginOptions.runtime.seo\n }\n if (pluginOptions?.runtime?.resourceHints) {\n runtimeOptions.resourceHints = pluginOptions.runtime.resourceHints\n }\n if (Object.keys(runtimeOptions).length > 0) {\n initOptions.runtime = runtimeOptions\n }\n\n const initOptionsCode = Object.keys(initOptions).length > 0 ? `, ${JSON.stringify(initOptions)}` : ''\n bodyLines.push(`initializePageRoutes(${JSON.stringify(pageOrder)}${initOptionsCode})`)\n return [...importLines, ...bodyLines].join('\\n')\n}\n"],"mappings":"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"}
|
package/dist/plugin/files.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { extname } from "pathe";
|
|
|
3
3
|
import { fs } from "@weapp-core/shared/fs";
|
|
4
4
|
import { bundleRequire } from "rolldown-require";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/plugin/files.ts
|
|
7
7
|
function isRecord(value) {
|
|
8
8
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
9
|
}
|
|
@@ -53,6 +53,5 @@ async function resolveTemplateFile(scriptPath) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
//#endregion
|
|
57
56
|
export { isRecord, readJsonFile, resolveJsonPath, resolveScriptFile, resolveStyleFile, resolveTemplateFile };
|
|
58
57
|
//# sourceMappingURL=files.mjs.map
|
|
@@ -3,7 +3,6 @@ import { ResolveWebModuleId, WebStylePreprocessOptions } from "./types.mjs";
|
|
|
3
3
|
import { AcceptedPlugin, ProcessOptions } from "postcss";
|
|
4
4
|
import { SourceMap } from "magic-string";
|
|
5
5
|
import { ViteDevServer } from "vite";
|
|
6
|
-
//#region src/plugin/hostTypes.d.ts
|
|
7
6
|
export interface WebPluginContext {
|
|
8
7
|
warn?: (message: string) => void;
|
|
9
8
|
addWatchFile?: (id: string) => void;
|
|
@@ -70,5 +69,5 @@ export interface WeappWebVitePlugin {
|
|
|
70
69
|
handleHotUpdate?: <Module extends object>(this: WebPluginContext, ctx: WebHmrContext<Module>) => Module[] | void | Promise<Module[] | void>;
|
|
71
70
|
transform?: (this: WebPluginContext, code: string, id: string) => WebTransformResult | Promise<WebTransformResult>;
|
|
72
71
|
}
|
|
73
|
-
|
|
72
|
+
export {};
|
|
74
73
|
//# sourceMappingURL=hostTypes.d.mts.map
|
package/dist/plugin/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { WeappWebPluginOptions } from "./types.mjs";
|
|
2
2
|
import { WeappWebVitePlugin } from "./hostTypes.mjs";
|
|
3
|
-
//#region src/plugin/index.d.ts
|
|
4
3
|
export declare function weappWebPlugin(options?: WeappWebPluginOptions): WeappWebVitePlugin;
|
|
5
|
-
//#endregion
|
|
6
4
|
export type { WeappWebPluginOptions };
|
|
7
5
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/plugin/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createWxssPostcssPlugin, transformWxssToCss } from "../css/wxss.mjs";
|
|
2
2
|
import { AUTO_ROUTES_ID, ENTRY_ID, RESOLVED_AUTO_ROUTES_ID, RUNTIME_ID, SCRIPT_EXTS, SFC_STYLE_QUERY, SFC_TEMPLATE_QUERY, STYLE_EXTS, STYLE_QUERY, TEMPLATE_EXTS, TEMPLATE_QUERY, TRANSFORM_STYLE_EXTS, WEB_COMPONENT_PREFIX, WEB_COMPONENT_QUERY, WXS_EXTS } from "./constants.mjs";
|
|
3
|
-
import { compileWxml } from "../compiler/wxml/compile.mjs";
|
|
3
|
+
import { compileWxml, compileWxmlDependency } from "../compiler/wxml/compile.mjs";
|
|
4
4
|
import { transformWxsToEsm } from "../compiler/wxs.mjs";
|
|
5
5
|
import { cleanUrl, isHtmlEntry, isInsideDir, normalizePath, resolveFileWithExtensionsSync, resolveRuntimePolyfillPath, resolveTemplatePathSync, resolveWxsPathSync, toRelativeImport, toViteFsImport } from "./path.mjs";
|
|
6
6
|
import { createWebAssetMiddleware, emitWebAssets } from "./assets.mjs";
|
|
@@ -11,7 +11,7 @@ import { createMiniProgramPackageResolver, getAncestorNodeModulesPaths } from ".
|
|
|
11
11
|
import { transformScriptModule } from "./register.mjs";
|
|
12
12
|
import { ensureWebVueSfcResult, generateWebVueSfcStyle, generateWebVueSfcTemplate, resolveWebVueSfcStyleLanguage, transformWebVueSfcScript } from "./vueSfc.mjs";
|
|
13
13
|
import { getStableWebComponentId, scanProject } from "./scan.mjs";
|
|
14
|
-
import {
|
|
14
|
+
import { collectSfcHmrModules } from "./sfcHmr.mjs";
|
|
15
15
|
import { createEmptyScanState } from "./state.mjs";
|
|
16
16
|
import { createInlineStyleModule } from "./styleModule.mjs";
|
|
17
17
|
import { readFile } from "node:fs/promises";
|
|
@@ -19,7 +19,7 @@ import process from "node:process";
|
|
|
19
19
|
import { dirname, extname, resolve } from "pathe";
|
|
20
20
|
import { isUniAppCompatibilityFile, transformUniAppSource } from "wevu/compiler";
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
// src/plugin/index.ts
|
|
23
23
|
const WEB_RUNTIME_MODULE_IDS = [
|
|
24
24
|
"lit",
|
|
25
25
|
"lit/async-directive.js",
|
|
@@ -125,7 +125,13 @@ function weappWebPlugin(options = {}) {
|
|
|
125
125
|
};
|
|
126
126
|
};
|
|
127
127
|
const scan = (context) => {
|
|
128
|
+
const graph = devServer?.moduleGraph;
|
|
129
|
+
for (const id of SCAN_VIRTUAL_MODULE_IDS) {
|
|
130
|
+
const module = graph?.getModuleById(id);
|
|
131
|
+
if (module) graph?.invalidateModule(module);
|
|
132
|
+
}
|
|
128
133
|
const result = scanQueue.then(async () => {
|
|
134
|
+
const previousState = state;
|
|
129
135
|
const nextState = createEmptyScanState();
|
|
130
136
|
await scanProject({
|
|
131
137
|
srcRoot,
|
|
@@ -139,7 +145,6 @@ function weappWebPlugin(options = {}) {
|
|
|
139
145
|
});
|
|
140
146
|
const nextComponentImportIdMap = /* @__PURE__ */ new Map();
|
|
141
147
|
for (const component of nextState.scanResult.components) if (component.importId) nextComponentImportIdMap.set(component.importId, component.script);
|
|
142
|
-
const graph = devServer?.moduleGraph;
|
|
143
148
|
const files = graph ? /* @__PURE__ */ new Set() : void 0;
|
|
144
149
|
if (files) for (const snapshot of [state, nextState]) {
|
|
145
150
|
for (const file of snapshot.moduleMeta.keys()) files.add(file);
|
|
@@ -148,25 +153,20 @@ function weappWebPlugin(options = {}) {
|
|
|
148
153
|
}
|
|
149
154
|
state = nextState;
|
|
150
155
|
componentImportIdMap = nextComponentImportIdMap;
|
|
151
|
-
if (graph && files) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (module) graph.invalidateModule(module);
|
|
155
|
-
}
|
|
156
|
-
for (const file of files) {
|
|
157
|
-
const modules = graph.getModulesByFile(file);
|
|
158
|
-
if (modules) for (const module of modules) graph.invalidateModule(module);
|
|
159
|
-
}
|
|
156
|
+
if (graph && files) for (const file of files) {
|
|
157
|
+
const modules = graph.getModulesByFile(file);
|
|
158
|
+
if (modules) for (const module of modules) graph.invalidateModule(module);
|
|
160
159
|
}
|
|
160
|
+
return [previousState, nextState];
|
|
161
161
|
});
|
|
162
|
-
scanQueue = result.
|
|
162
|
+
scanQueue = result.then(() => {}, () => {});
|
|
163
163
|
return result;
|
|
164
164
|
};
|
|
165
165
|
const scanChangedFile = async (context, file) => {
|
|
166
166
|
const clean = cleanUrl(file);
|
|
167
167
|
const normalized = normalizePath(clean);
|
|
168
168
|
if (!isInsideDir(clean, srcRoot) && !state.moduleMeta.has(normalized) && !state.templatePathSet.has(normalized)) return;
|
|
169
|
-
if (state.templatePathSet.has(normalized) || clean.endsWith(".json") || isTemplateFile(clean) || isWxsFile(clean) || clean.endsWith(".wxss") || SCRIPT_EXTS.includes(extname(clean)))
|
|
169
|
+
if (state.templatePathSet.has(normalized) || clean.endsWith(".json") || isTemplateFile(clean) || isWxsFile(clean) || clean.endsWith(".wxss") || SCRIPT_EXTS.includes(extname(clean))) return scan(context);
|
|
170
170
|
};
|
|
171
171
|
return {
|
|
172
172
|
name: "@weapp-vite/web",
|
|
@@ -236,15 +236,22 @@ function weappWebPlugin(options = {}) {
|
|
|
236
236
|
return resolveMiniProgramModuleId?.(id, importer).then((resolved) => resolved ?? null) ?? null;
|
|
237
237
|
},
|
|
238
238
|
async load(id) {
|
|
239
|
-
if (id ===
|
|
240
|
-
|
|
239
|
+
if (id === ENTRY_ID) {
|
|
240
|
+
await scanQueue;
|
|
241
|
+
return generateEntryModule(state.scanResult, root, wxssOptions, options);
|
|
242
|
+
}
|
|
243
|
+
if (id === RESOLVED_AUTO_ROUTES_ID) {
|
|
244
|
+
await scanQueue;
|
|
245
|
+
return generateAutoRoutesModule(state.scanResult);
|
|
246
|
+
}
|
|
241
247
|
if (hasQuery(id, "weapp-web-template")) {
|
|
242
248
|
const filename = cleanUrl(id);
|
|
243
249
|
let source = await readFile(filename, "utf8");
|
|
244
|
-
|
|
250
|
+
const pageMeta = resolveMetaByTemplate(filename);
|
|
251
|
+
if (pageMeta?.kind === "page" && state.scanResult.layouts.length) source = wrapPageTemplate(source, state.scanResult.layouts);
|
|
245
252
|
const navigationConfig = state.pageNavigationMap.get(normalizePath(filename));
|
|
246
253
|
const componentTags = state.templateComponentMap.get(normalizePath(filename));
|
|
247
|
-
const compiled = compileWxml({
|
|
254
|
+
const compiled = (pageMeta ? compileWxml : compileWxmlDependency)({
|
|
248
255
|
id: filename,
|
|
249
256
|
source,
|
|
250
257
|
resolveTemplatePath,
|
|
@@ -320,10 +327,9 @@ function weappWebPlugin(options = {}) {
|
|
|
320
327
|
},
|
|
321
328
|
async handleHotUpdate(ctx) {
|
|
322
329
|
const graph = devServer?.moduleGraph;
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
return ctx.modules || affected.size ? [...affected] : void 0;
|
|
330
|
+
const snapshots = await scanChangedFile(this, ctx.file);
|
|
331
|
+
const affected = graph ? collectSfcHmrModules(snapshots ?? [state], cleanUrl(ctx.file), graph, ctx.modules) : ctx.modules;
|
|
332
|
+
return ctx.modules || affected?.length ? affected : void 0;
|
|
327
333
|
},
|
|
328
334
|
async transform(code, id) {
|
|
329
335
|
const clean = cleanUrl(id);
|
|
@@ -447,6 +453,5 @@ function weappWebPlugin(options = {}) {
|
|
|
447
453
|
};
|
|
448
454
|
}
|
|
449
455
|
|
|
450
|
-
//#endregion
|
|
451
456
|
export { weappWebPlugin };
|
|
452
457
|
//# sourceMappingURL=index.mjs.map
|