@weapp-vite/web 1.3.4 → 1.3.5

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.
@@ -0,0 +1,96 @@
1
+ import { SourceMap } from "magic-string";
2
+
3
+ //#region src/css/wxss.d.ts
4
+ interface WxssTransformOptions {
5
+ /**
6
+ * 1rpx 对应的 CSS 像素数。
7
+ * 默认值近似于 750rpx 设计稿在 375px 屏幕上的换算。
8
+ */
9
+ pxPerRpx?: number;
10
+ /**
11
+ * rpx 换算的设计宽度。传入后会把 rpx 转为
12
+ * `calc(var(--rpx) * N)` 以实现响应式缩放。
13
+ */
14
+ designWidth?: number;
15
+ /**
16
+ * 用于存储运行时 rpx 大小的 CSS 变量名。
17
+ * @default "--rpx"
18
+ */
19
+ rpxVar?: string;
20
+ }
21
+ interface WxssTransformResult {
22
+ css: string;
23
+ }
24
+ declare function transformWxssToCss(source: string, options?: WxssTransformOptions): WxssTransformResult;
25
+ //#endregion
26
+ //#region src/plugin/types.d.ts
27
+ interface WeappWebPluginOptions {
28
+ wxss?: WxssTransformOptions;
29
+ /**
30
+ * 小程序项目的源代码根目录,默认 `<root>/src`。
31
+ */
32
+ srcDir?: string;
33
+ /**
34
+ * Web 运行时的表单行为配置。
35
+ */
36
+ form?: {
37
+ /**
38
+ * 为 true 时阻止浏览器默认的表单提交,默认 true。
39
+ */
40
+ preventDefault?: boolean;
41
+ };
42
+ /**
43
+ * Web 运行时执行策略。
44
+ */
45
+ runtime?: {
46
+ /**
47
+ * 表达式与 WXS 执行模式:
48
+ * - compat: 保持当前行为(默认)
49
+ * - safe: 忽略解析/执行异常并告警
50
+ * - strict: 解析/执行异常直接抛错
51
+ */
52
+ executionMode?: 'compat' | 'safe' | 'strict';
53
+ /**
54
+ * 运行时告警策略:
55
+ * - warn: 使用 console.warn 输出(默认)
56
+ * - error: 使用 console.error 输出
57
+ * - off: 关闭告警输出
58
+ *
59
+ * dedupe 为 true 时同 key 告警仅输出一次(默认)。
60
+ */
61
+ warnings?: {
62
+ level?: 'off' | 'warn' | 'error';
63
+ dedupe?: boolean;
64
+ };
65
+ };
66
+ }
67
+ //#endregion
68
+ //#region src/plugin/index.d.ts
69
+ interface WebPluginContext {
70
+ warn?: (message: string) => void;
71
+ addWatchFile?: (id: string) => void;
72
+ }
73
+ type WebTransformResult = {
74
+ code: string;
75
+ map: SourceMap | null;
76
+ } | null;
77
+ interface WebResolvedConfig {
78
+ root: string;
79
+ command: string;
80
+ }
81
+ interface WebHmrContext {
82
+ file: string;
83
+ }
84
+ interface WeappWebVitePlugin {
85
+ name: string;
86
+ enforce?: 'pre' | 'post';
87
+ configResolved?: (this: WebPluginContext, config: WebResolvedConfig) => void | Promise<void>;
88
+ buildStart?: (this: WebPluginContext) => void | Promise<void>;
89
+ resolveId?: (id: string) => string | null | Promise<string | null>;
90
+ load?: (id: string) => string | null | Promise<string | null>;
91
+ handleHotUpdate?: (this: WebPluginContext, ctx: WebHmrContext) => void | Promise<void>;
92
+ transform?: (this: WebPluginContext, code: string, id: string) => WebTransformResult | Promise<WebTransformResult>;
93
+ }
94
+ declare function weappWebPlugin(options?: WeappWebPluginOptions): WeappWebVitePlugin;
95
+ //#endregion
96
+ export { WeappWebPluginOptions as n, transformWxssToCss as r, weappWebPlugin as t };