weapp-vite 7.2.2 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,85 @@
1
+ import { t as MINI_PROGRAM_PLATFORM_ADAPTERS } from "./adapters-BwnMMIZR.mjs";
2
+ //#region src/platforms/sourceAssets.ts
3
+ const PORTABLE_TEMPLATE_EXTENSIONS = ["wxml", "html"];
4
+ const PORTABLE_STYLE_EXTENSIONS = [
5
+ "wxss",
6
+ "css",
7
+ "scss",
8
+ "less",
9
+ "sass",
10
+ "styl"
11
+ ];
12
+ function uniqueExtensions(extensions) {
13
+ return Array.from(new Set(extensions.filter((extension) => Boolean(extension))));
14
+ }
15
+ const ALL_NATIVE_TEMPLATE_EXTENSIONS = uniqueExtensions(MINI_PROGRAM_PLATFORM_ADAPTERS.map((adapter) => adapter.outputExtensions.wxml));
16
+ const ALL_NATIVE_STYLE_EXTENSIONS = uniqueExtensions(MINI_PROGRAM_PLATFORM_ADAPTERS.map((adapter) => adapter.outputExtensions.wxss));
17
+ const ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS = ALL_NATIVE_STYLE_EXTENSIONS.filter((extension) => extension !== "css");
18
+ const ALL_SOURCE_TEMPLATE_EXTENSIONS = uniqueExtensions([...PORTABLE_TEMPLATE_EXTENSIONS, ...ALL_NATIVE_TEMPLATE_EXTENSIONS]);
19
+ const ALL_SOURCE_STYLE_EXTENSIONS = uniqueExtensions([...PORTABLE_STYLE_EXTENSIONS, ...ALL_NATIVE_STYLE_EXTENSIONS]);
20
+ function getAdapter(platform) {
21
+ return platform ? MINI_PROGRAM_PLATFORM_ADAPTERS.find((adapter) => adapter.id === platform) : void 0;
22
+ }
23
+ /**
24
+ * 返回当前平台的模板源码选择顺序。
25
+ * 原生平台后缀优先,便携源码后缀作为兼容回退。
26
+ */
27
+ function getSourceTemplateExtensions(platform) {
28
+ const nativeExtension = getAdapter(platform)?.outputExtensions.wxml;
29
+ return platform ? uniqueExtensions([nativeExtension, ...PORTABLE_TEMPLATE_EXTENSIONS]) : ALL_SOURCE_TEMPLATE_EXTENSIONS;
30
+ }
31
+ /**
32
+ * 返回当前平台的样式源码选择顺序。
33
+ * 原生平台后缀优先,预处理器和便携样式后缀继续可用。
34
+ */
35
+ function getSourceStyleExtensions(platform) {
36
+ const nativeExtension = getAdapter(platform)?.outputExtensions.wxss;
37
+ return platform ? uniqueExtensions([nativeExtension, ...PORTABLE_STYLE_EXTENSIONS]) : ALL_SOURCE_STYLE_EXTENSIONS;
38
+ }
39
+ function isSourceTemplateExtension(extension) {
40
+ const normalized = extension.startsWith(".") ? extension.slice(1) : extension;
41
+ return getSourceTemplateExtensions().includes(normalized);
42
+ }
43
+ function isSourceStyleExtension(extension) {
44
+ const normalized = extension.startsWith(".") ? extension.slice(1) : extension;
45
+ return getSourceStyleExtensions().includes(normalized);
46
+ }
47
+ function isNativeTemplateSource(filePath, platform) {
48
+ const nativeExtension = getAdapter(platform)?.outputExtensions.wxml;
49
+ return Boolean(nativeExtension && filePath.endsWith(`.${nativeExtension}`));
50
+ }
51
+ //#endregion
52
+ //#region src/constants.ts
53
+ const VERSION = "__VERSION__";
54
+ /**
55
+ * 源代码支持的 js 文件格式
56
+ */
57
+ const jsExtensions = ["ts", "js"];
58
+ const scriptExtensions = [
59
+ "ts",
60
+ "js",
61
+ "tsx",
62
+ "jsx"
63
+ ];
64
+ /**
65
+ * 源代码支持的 vue 文件格式
66
+ */
67
+ const vueExtensions = ["vue"];
68
+ /**
69
+ * 源代码支持的 json 文件格式
70
+ */
71
+ const configExtensions = [
72
+ "jsonc",
73
+ "json",
74
+ ...jsExtensions.map((x) => `json.${x}`)
75
+ ];
76
+ /**
77
+ * 源代码支持的 css 文件格式
78
+ */
79
+ const supportedCssLangs = ALL_SOURCE_STYLE_EXTENSIONS;
80
+ /**
81
+ * 源代码支持的 wxml 文件格式
82
+ */
83
+ const templateExtensions = ALL_SOURCE_TEMPLATE_EXTENSIONS;
84
+ //#endregion
85
+ export { supportedCssLangs as a, ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS as c, isNativeTemplateSource as d, isSourceStyleExtension as f, scriptExtensions as i, getSourceStyleExtensions as l, configExtensions as n, templateExtensions as o, isSourceTemplateExtension as p, jsExtensions as r, vueExtensions as s, VERSION as t, getSourceTemplateExtensions as u };