weapp-tailwindcss 5.0.11 → 5.0.13

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.
Files changed (109) hide show
  1. package/dist/{bundle-state-BwtEqxvU.js → bundle-state-CKWeTEhv.js} +2 -40
  2. package/dist/{bundle-state-CXzPknlT.mjs → bundle-state-zQ2MrDdi.mjs} +2 -34
  3. package/dist/bundlers/gulp/vinyl-transform.d.ts +1 -1
  4. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +7 -2
  5. package/dist/bundlers/shared/generator-css/source-files.d.ts +1 -0
  6. package/dist/bundlers/shared/generator-css/source-resolver/apply-reference.d.ts +3 -0
  7. package/dist/bundlers/shared/generator-css/source-resolver/config.d.ts +7 -0
  8. package/dist/bundlers/shared/generator-css/source-resolver/matching.d.ts +4 -0
  9. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +15 -0
  10. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +12 -0
  11. package/dist/bundlers/shared/generator-css/source-resolver/types.d.ts +22 -0
  12. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +5 -22
  13. package/dist/bundlers/shared/generator-css/types.d.ts +2 -0
  14. package/dist/bundlers/shared/generator-css/validate.d.ts +1 -0
  15. package/dist/bundlers/shared/hmr-timing.d.ts +1 -0
  16. package/dist/bundlers/vite/css-memory.d.ts +27 -0
  17. package/dist/bundlers/vite/generate-bundle/bundle-file-names.d.ts +2 -0
  18. package/dist/bundlers/vite/generate-bundle/configured-css-sources.d.ts +8 -0
  19. package/dist/bundlers/vite/generate-bundle/css-assets.d.ts +4 -0
  20. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +5 -0
  21. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +9 -7
  22. package/dist/bundlers/vite/generate-bundle/env-flags.d.ts +7 -0
  23. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +58 -0
  24. package/dist/bundlers/vite/generate-bundle/js-processing.d.ts +31 -0
  25. package/dist/bundlers/vite/generate-bundle/memory-debug.d.ts +77 -0
  26. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +53 -0
  27. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
  28. package/dist/bundlers/vite/generate-bundle/runtime-linked-css.d.ts +4 -0
  29. package/dist/bundlers/vite/generate-bundle/scoped-generator.d.ts +21 -0
  30. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
  31. package/dist/bundlers/vite/generate-bundle/source-candidate-scope.d.ts +29 -0
  32. package/dist/bundlers/vite/generate-bundle/timing.d.ts +1 -0
  33. package/dist/bundlers/vite/generate-bundle/types.d.ts +7 -0
  34. package/dist/bundlers/vite/generate-bundle/uni-app-x-postprocess.d.ts +20 -0
  35. package/dist/bundlers/vite/generate-bundle/vite-css-cache.d.ts +6 -0
  36. package/dist/bundlers/vite/generate-bundle.d.ts +2 -1
  37. package/dist/bundlers/vite/hot-css-modules.d.ts +5 -0
  38. package/dist/bundlers/vite/map-cache.d.ts +2 -0
  39. package/dist/bundlers/vite/processed-css-assets.d.ts +16 -0
  40. package/dist/bundlers/vite/resolve-app-type.d.ts +1 -2
  41. package/dist/bundlers/vite/source-candidate-scan-signature.d.ts +13 -0
  42. package/dist/bundlers/vite/source-candidates.d.ts +9 -0
  43. package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
  44. package/dist/bundlers/vite/source-scan.d.ts +1 -1
  45. package/dist/bundlers/vite/weapp-vite-config.d.ts +3 -0
  46. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +11 -8
  47. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +2 -0
  48. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +5 -0
  49. package/dist/cache/index.d.ts +4 -0
  50. package/dist/cli.js +9 -2
  51. package/dist/cli.mjs +8 -1
  52. package/dist/core.d.ts +7 -0
  53. package/dist/core.js +8 -5
  54. package/dist/core.mjs +8 -5
  55. package/dist/css-macro.js +1 -1
  56. package/dist/css-macro.mjs +1 -1
  57. package/dist/{defaults-DH0ZQRhy.mjs → defaults-Bqx18S1f.mjs} +2 -35
  58. package/dist/{defaults-Boc26eel.js → defaults-C_J_kBpw.js} +2 -35
  59. package/dist/defaults.js +1 -1
  60. package/dist/defaults.mjs +1 -1
  61. package/dist/framework/index.d.ts +59 -0
  62. package/dist/framework.d.ts +1 -0
  63. package/dist/framework.js +198 -0
  64. package/dist/framework.mjs +180 -0
  65. package/dist/{generator-ChgOWNOj.js → generator-CzpArpCL.js} +1 -1
  66. package/dist/{generator-h2XRiJ9-.mjs → generator-ITLd7PTl.mjs} +1 -1
  67. package/dist/generator.js +2 -2
  68. package/dist/generator.mjs +2 -2
  69. package/dist/{gulp-Be88jhoY.mjs → gulp-DfOQERcV.mjs} +137 -23
  70. package/dist/{gulp-CHtZF-oT.js → gulp-XT8Jc7lH.js} +137 -23
  71. package/dist/gulp.js +1 -1
  72. package/dist/gulp.mjs +1 -1
  73. package/dist/{hmr-timing-BkivBZvN.js → hmr-timing-BMftW7Us.js} +354 -225
  74. package/dist/{hmr-timing-Ct5w4hdM.mjs → hmr-timing-DQIP_8qP.mjs} +341 -225
  75. package/dist/index.d.ts +1 -0
  76. package/dist/index.js +20 -4
  77. package/dist/index.mjs +6 -5
  78. package/dist/postcss.js +9 -10
  79. package/dist/postcss.mjs +7 -5
  80. package/dist/{precheck-CY9oaH49.js → precheck-B0Z8yW7E.js} +108 -27
  81. package/dist/{precheck-BpHxsWRd.mjs → precheck-CRI90iL1.mjs} +109 -28
  82. package/dist/presets.js +3 -3
  83. package/dist/presets.mjs +3 -3
  84. package/dist/tailwindcss/source-scan.d.ts +1 -0
  85. package/dist/tailwindcss/v3-engine/generator.d.ts +17 -0
  86. package/dist/tailwindcss/v3-engine/index.d.ts +1 -1
  87. package/dist/tailwindcss/v3-engine/types.d.ts +1 -0
  88. package/dist/tailwindcss/v4-engine/generator.d.ts +19 -0
  89. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  90. package/dist/{tailwindcss-Bfy2egdX.mjs → tailwindcss-DTq3uYBK.mjs} +2 -2
  91. package/dist/{tailwindcss-DbbAKAZP.js → tailwindcss-DZEwT3C_.js} +3 -3
  92. package/dist/{transform-r5evL6Hn.mjs → transform-DfcEjsZF.mjs} +29 -21
  93. package/dist/{transform-Cd634UZV.js → transform-YmrmxuF3.js} +29 -21
  94. package/dist/types/user-defined-options/general.d.ts +3 -1
  95. package/dist/{utils-Dolmt8EO.js → utils-BCa37Wqj.js} +2 -17
  96. package/dist/{utils-DsaS975I.mjs → utils-DodxWHGz.mjs} +2 -17
  97. package/dist/{v3-engine-D0yA9ZkF.js → v3-engine-2rrgylhn.js} +194 -34
  98. package/dist/{v3-engine-CFkP6dWF.mjs → v3-engine-C6eJ0YzK.mjs} +176 -34
  99. package/dist/{vite-j9cB2Ff1.js → vite-CXHVsHmX.js} +2071 -1160
  100. package/dist/{vite-Bd8qf9dK.mjs → vite-DjI09vVN.mjs} +2071 -1160
  101. package/dist/vite.js +1 -1
  102. package/dist/vite.mjs +1 -1
  103. package/dist/weapp-tw-css-import-rewrite-loader.js +476 -217
  104. package/dist/weapp-tw-runtime-classset-loader.js +25 -0
  105. package/dist/{webpack-DPdrcC2X.mjs → webpack-BcPpnT90.mjs} +251 -40
  106. package/dist/{webpack-CJAOcYEO.js → webpack-CfkUkMXG.js} +254 -43
  107. package/dist/webpack.js +1 -1
  108. package/dist/webpack.mjs +1 -1
  109. package/package.json +10 -5
@@ -0,0 +1,59 @@
1
+ export type DetectableAppType = 'mpx' | 'taro' | 'uni-app' | 'uni-app-vite' | 'uni-app-x' | 'weapp-vite';
2
+ export type FrameworkEnv = Partial<Record<'MPX_CLI_MODE' | 'MPX_CURRENT_TARGET_MODE' | 'NODE_PATH' | 'TARO_ENV' | 'UNI_PLATFORM' | 'UNI_UTS_PLATFORM' | 'WEAPP_TAILWINDCSS_TARGET' | 'WEAPP_TW_TARGET', string | undefined>>;
3
+ export interface UniPlatformInfo {
4
+ raw: string | undefined;
5
+ normalized: string | undefined;
6
+ isApp: boolean;
7
+ isAppAndroid: boolean;
8
+ isAppHarmony: boolean;
9
+ isAppIos: boolean;
10
+ isMp: boolean;
11
+ isWeb: boolean;
12
+ }
13
+ export interface HBuilderXRuntimeHints {
14
+ cwd?: string | undefined;
15
+ env?: FrameworkEnv | undefined;
16
+ nodePath?: string | null | undefined;
17
+ }
18
+ export interface PackageJsonLike {
19
+ 'dependencies'?: Record<string, string> | undefined;
20
+ 'devDependencies'?: Record<string, string> | undefined;
21
+ 'peerDependencies'?: Record<string, string> | undefined;
22
+ 'optionalDependencies'?: Record<string, string> | undefined;
23
+ 'scripts'?: Record<string, string> | undefined;
24
+ 'uni-app'?: unknown;
25
+ }
26
+ export interface UniAppManifestLike {
27
+ 'uni-app-x'?: unknown;
28
+ }
29
+ export interface DetectAppTypeOptions {
30
+ root?: string | undefined;
31
+ packageJson?: PackageJsonLike | undefined;
32
+ manifest?: UniAppManifestLike | undefined;
33
+ searchUp?: boolean | undefined;
34
+ env?: FrameworkEnv | undefined;
35
+ detectEnv?: boolean | undefined;
36
+ cwd?: string | undefined;
37
+ hbuilderxVite?: boolean | undefined;
38
+ }
39
+ export declare function isRunningInHBuilderX(options?: HBuilderXRuntimeHints): boolean;
40
+ export declare function resolveUniPlatform(value: string | undefined): UniPlatformInfo;
41
+ export declare function resolveUniUtsPlatform(value: string | undefined): UniPlatformInfo;
42
+ export declare function resolveUniPlatformsFromEnv(env?: FrameworkEnv): {
43
+ uniPlatform: UniPlatformInfo;
44
+ uniUtsPlatform: UniPlatformInfo;
45
+ };
46
+ export declare function detectAppTypeFromEnv(env?: FrameworkEnv, options?: {
47
+ cwd?: string | undefined;
48
+ hbuilderxVite?: boolean | undefined;
49
+ }): DetectableAppType | undefined;
50
+ export declare function isWeappVitePackage(pkg: PackageJsonLike): boolean;
51
+ export declare function isMpxPackage(pkg: PackageJsonLike): boolean;
52
+ export declare function isTaroPackage(pkg: PackageJsonLike): boolean;
53
+ export declare function isUniAppVitePackage(pkg: PackageJsonLike): boolean;
54
+ export declare function isUniAppXPackage(pkg: PackageJsonLike): boolean;
55
+ export declare function isUniAppPackage(pkg: PackageJsonLike): boolean;
56
+ export declare function isUniAppXManifest(manifest: UniAppManifestLike | undefined): boolean;
57
+ export declare function detectAppTypeFromPackageJson(pkg: PackageJsonLike): DetectableAppType | undefined;
58
+ export declare function detectAppType(options?: DetectAppTypeOptions): DetectableAppType | undefined;
59
+ export declare const resolveImplicitAppTypeFromViteRoot: (root: string) => DetectableAppType | undefined;
@@ -0,0 +1 @@
1
+ export * from './framework/index'
@@ -0,0 +1,198 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_chunk = require("./chunk-emK7D4bc.js");
3
+ let node_fs = require("node:fs");
4
+ let node_path = require("node:path");
5
+ node_path = require_chunk.__toESM(node_path);
6
+ let node_process = require("node:process");
7
+ node_process = require_chunk.__toESM(node_process);
8
+ //#region src/framework/index.ts
9
+ const KNOWN_MAC_HBUILDERX_PLUGIN_DIRS = ["/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli-vite", "/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli"];
10
+ const HBUILDERX_PLUGIN_CWD_RE = /[\\/]HBuilderX(?:\.[^\\/]*)?(?:[\\/]Contents[\\/]HBuilderX)?[\\/]plugins[\\/]uniapp-cli(?:-vite)?(?:[\\/]|$)/i;
11
+ const PACKAGE_JSON_FILE = "package.json";
12
+ const MANIFEST_JSON_FILE = "manifest.json";
13
+ const MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;
14
+ const TARO_SCRIPT_RE = /\btaro\b/u;
15
+ const WEAPP_VITE_SCRIPT_RE = /\bweapp-vite\b/u;
16
+ const UNI_APP_SCRIPT_RE = /\buni(?:\s|$)/u;
17
+ const UNI_APP_VITE_SCRIPT_RE = /\buni(?:\s|$)/u;
18
+ const MPX_MARKERS = [["src/app.mpx", "mpx"], ["app.mpx", "mpx"]];
19
+ function getProcessEnv() {
20
+ return {
21
+ MPX_CLI_MODE: node_process.default.env["MPX_CLI_MODE"],
22
+ MPX_CURRENT_TARGET_MODE: node_process.default.env["MPX_CURRENT_TARGET_MODE"],
23
+ NODE_PATH: node_process.default.env["NODE_PATH"],
24
+ TARO_ENV: node_process.default.env["TARO_ENV"],
25
+ UNI_PLATFORM: node_process.default.env["UNI_PLATFORM"],
26
+ UNI_UTS_PLATFORM: node_process.default.env["UNI_UTS_PLATFORM"],
27
+ WEAPP_TAILWINDCSS_TARGET: node_process.default.env["WEAPP_TAILWINDCSS_TARGET"],
28
+ WEAPP_TW_TARGET: node_process.default.env["WEAPP_TW_TARGET"]
29
+ };
30
+ }
31
+ function resolveDependencyNames(pkg) {
32
+ return new Set([
33
+ ...Object.keys(pkg.dependencies ?? {}),
34
+ ...Object.keys(pkg.devDependencies ?? {}),
35
+ ...Object.keys(pkg.peerDependencies ?? {}),
36
+ ...Object.keys(pkg.optionalDependencies ?? {})
37
+ ]);
38
+ }
39
+ function hasDependencyPrefix(dependencyNames, prefix) {
40
+ return [...dependencyNames].some((name) => name.startsWith(prefix));
41
+ }
42
+ function hasScriptMatch(pkg, pattern) {
43
+ return Object.values(pkg.scripts ?? {}).some((script) => pattern.test(script));
44
+ }
45
+ function normalizePlatform(value) {
46
+ return value?.trim().toLowerCase() || void 0;
47
+ }
48
+ function resolvePlatformInfo(value) {
49
+ const normalized = normalizePlatform(value);
50
+ const isAppAndroid = normalized === "app-android";
51
+ const isAppIos = normalized === "app-ios";
52
+ const isAppHarmony = normalized === "app-harmony";
53
+ return {
54
+ raw: value,
55
+ normalized,
56
+ isApp: normalized?.startsWith("app-") === true || normalized === "app" || normalized === "app-plus",
57
+ isAppAndroid,
58
+ isAppHarmony,
59
+ isAppIos,
60
+ isMp: normalized?.startsWith("mp-") === true,
61
+ isWeb: normalized?.startsWith("web") === true || normalized === "h5"
62
+ };
63
+ }
64
+ function hasKnownHBuilderXPluginPrefix(normalizedCwd) {
65
+ for (const dir of KNOWN_MAC_HBUILDERX_PLUGIN_DIRS) {
66
+ const normalizedDir = node_path.default.normalize(dir);
67
+ if (normalizedCwd === normalizedDir || normalizedCwd.startsWith(`${normalizedDir}${node_path.default.sep}`)) return true;
68
+ }
69
+ return false;
70
+ }
71
+ function matchesHBuilderXPluginCwd(cwd) {
72
+ const normalized = node_path.default.normalize(cwd);
73
+ if (hasKnownHBuilderXPluginPrefix(normalized)) return true;
74
+ return HBUILDERX_PLUGIN_CWD_RE.test(normalized);
75
+ }
76
+ function isRunningInHBuilderX(options = {}) {
77
+ const env = options.env ?? getProcessEnv();
78
+ const nodePath = "nodePath" in options ? options.nodePath : env.NODE_PATH;
79
+ if (!(nodePath == null || nodePath.trim().length === 0)) return false;
80
+ return matchesHBuilderXPluginCwd(options.cwd ?? node_process.default.cwd());
81
+ }
82
+ function resolveUniPlatform(value) {
83
+ return resolvePlatformInfo(value);
84
+ }
85
+ function resolveUniUtsPlatform(value) {
86
+ return resolvePlatformInfo(value);
87
+ }
88
+ function resolveUniPlatformsFromEnv(env = getProcessEnv()) {
89
+ return {
90
+ uniPlatform: resolveUniPlatform(env.UNI_PLATFORM),
91
+ uniUtsPlatform: resolveUniUtsPlatform(env.UNI_UTS_PLATFORM)
92
+ };
93
+ }
94
+ function detectAppTypeFromEnv(env = getProcessEnv(), options = {}) {
95
+ if (env.WEAPP_TW_TARGET === "weapp-vite" || env.WEAPP_TAILWINDCSS_TARGET === "weapp-vite") return "weapp-vite";
96
+ if (env.TARO_ENV) return "taro";
97
+ if (env.MPX_CLI_MODE || env.MPX_CURRENT_TARGET_MODE) return "mpx";
98
+ const { uniPlatform, uniUtsPlatform } = resolveUniPlatformsFromEnv(env);
99
+ if (uniUtsPlatform.normalized) return "uni-app-x";
100
+ if (uniPlatform.normalized) return "uni-app-vite";
101
+ if (isRunningInHBuilderX({
102
+ cwd: options.cwd,
103
+ env
104
+ })) return options.hbuilderxVite === false ? "uni-app" : "uni-app-vite";
105
+ }
106
+ function isWeappVitePackage(pkg) {
107
+ const dependencyNames = resolveDependencyNames(pkg);
108
+ return dependencyNames.has("weapp-vite") || hasDependencyPrefix(dependencyNames, "@weapp-vite/") || hasScriptMatch(pkg, WEAPP_VITE_SCRIPT_RE);
109
+ }
110
+ function isMpxPackage(pkg) {
111
+ return hasDependencyPrefix(resolveDependencyNames(pkg), "@mpxjs/") || hasScriptMatch(pkg, MPX_SCRIPT_RE);
112
+ }
113
+ function isTaroPackage(pkg) {
114
+ return hasDependencyPrefix(resolveDependencyNames(pkg), "@tarojs/") || hasScriptMatch(pkg, TARO_SCRIPT_RE);
115
+ }
116
+ function isUniAppVitePackage(pkg) {
117
+ return resolveDependencyNames(pkg).has("@dcloudio/vite-plugin-uni") || hasScriptMatch(pkg, UNI_APP_VITE_SCRIPT_RE);
118
+ }
119
+ function isUniAppXPackage(pkg) {
120
+ const dependencyNames = resolveDependencyNames(pkg);
121
+ return dependencyNames.has("@dcloudio/uni-uts-v1") || dependencyNames.has("@weapp-tailwindcss/debug-uni-app-x");
122
+ }
123
+ function isUniAppPackage(pkg) {
124
+ const dependencyNames = resolveDependencyNames(pkg);
125
+ return dependencyNames.has("@dcloudio/vue-cli-plugin-uni") || dependencyNames.has("@dcloudio/uni-app") || Object.hasOwn(pkg, "uni-app") || hasScriptMatch(pkg, UNI_APP_SCRIPT_RE);
126
+ }
127
+ function isUniAppXManifest(manifest) {
128
+ return Boolean(manifest && Object.hasOwn(manifest, "uni-app-x"));
129
+ }
130
+ function detectAppTypeFromPackageJson(pkg) {
131
+ if (isWeappVitePackage(pkg)) return "weapp-vite";
132
+ if (isMpxPackage(pkg)) return "mpx";
133
+ if (isTaroPackage(pkg)) return "taro";
134
+ if (isUniAppXPackage(pkg)) return "uni-app-x";
135
+ if (isUniAppVitePackage(pkg)) return "uni-app-vite";
136
+ if (isUniAppPackage(pkg)) return "uni-app";
137
+ }
138
+ function tryReadJson(file) {
139
+ if (!(0, node_fs.existsSync)(file)) return;
140
+ try {
141
+ return JSON.parse((0, node_fs.readFileSync)(file, "utf8"));
142
+ } catch {}
143
+ }
144
+ function detectAppTypeFromMarkers(root) {
145
+ for (const [relativePath, appType] of MPX_MARKERS) if ((0, node_fs.existsSync)(node_path.default.join(root, relativePath))) return appType;
146
+ }
147
+ function detectAppTypeFromRoot(root, searchUp = true) {
148
+ const resolvedRoot = node_path.default.resolve(root);
149
+ if (!(0, node_fs.existsSync)(resolvedRoot)) return;
150
+ const markerDetected = detectAppTypeFromMarkers(resolvedRoot);
151
+ if (markerDetected) return markerDetected;
152
+ let current = resolvedRoot;
153
+ while (true) {
154
+ if (isUniAppXManifest(tryReadJson(node_path.default.join(current, MANIFEST_JSON_FILE)))) return "uni-app-x";
155
+ const pkg = tryReadJson(node_path.default.join(current, PACKAGE_JSON_FILE));
156
+ if (pkg) {
157
+ const detected = detectAppTypeFromPackageJson(pkg);
158
+ if (detected) return detected;
159
+ }
160
+ if (!searchUp) break;
161
+ const parent = node_path.default.dirname(current);
162
+ if (parent === current) break;
163
+ current = parent;
164
+ }
165
+ }
166
+ function detectAppType(options = {}) {
167
+ if (isUniAppXManifest(options.manifest)) return "uni-app-x";
168
+ if (options.packageJson) {
169
+ const detected = detectAppTypeFromPackageJson(options.packageJson);
170
+ if (detected) return detected;
171
+ }
172
+ if (options.root) {
173
+ const detected = detectAppTypeFromRoot(options.root, options.searchUp ?? true);
174
+ if (detected) return detected;
175
+ }
176
+ const env = options.env ?? (options.detectEnv ? getProcessEnv() : void 0);
177
+ if (env) return detectAppTypeFromEnv(env, {
178
+ cwd: options.cwd ?? options.root ?? (options.detectEnv ? node_process.default.cwd() : void 0),
179
+ hbuilderxVite: options.hbuilderxVite
180
+ });
181
+ }
182
+ const resolveImplicitAppTypeFromViteRoot = (root) => detectAppType({ root });
183
+ //#endregion
184
+ exports.detectAppType = detectAppType;
185
+ exports.detectAppTypeFromEnv = detectAppTypeFromEnv;
186
+ exports.detectAppTypeFromPackageJson = detectAppTypeFromPackageJson;
187
+ exports.isMpxPackage = isMpxPackage;
188
+ exports.isRunningInHBuilderX = isRunningInHBuilderX;
189
+ exports.isTaroPackage = isTaroPackage;
190
+ exports.isUniAppPackage = isUniAppPackage;
191
+ exports.isUniAppVitePackage = isUniAppVitePackage;
192
+ exports.isUniAppXManifest = isUniAppXManifest;
193
+ exports.isUniAppXPackage = isUniAppXPackage;
194
+ exports.isWeappVitePackage = isWeappVitePackage;
195
+ exports.resolveImplicitAppTypeFromViteRoot = resolveImplicitAppTypeFromViteRoot;
196
+ exports.resolveUniPlatform = resolveUniPlatform;
197
+ exports.resolveUniPlatformsFromEnv = resolveUniPlatformsFromEnv;
198
+ exports.resolveUniUtsPlatform = resolveUniUtsPlatform;
@@ -0,0 +1,180 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+ //#region src/framework/index.ts
5
+ const KNOWN_MAC_HBUILDERX_PLUGIN_DIRS = ["/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli-vite", "/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli"];
6
+ const HBUILDERX_PLUGIN_CWD_RE = /[\\/]HBuilderX(?:\.[^\\/]*)?(?:[\\/]Contents[\\/]HBuilderX)?[\\/]plugins[\\/]uniapp-cli(?:-vite)?(?:[\\/]|$)/i;
7
+ const PACKAGE_JSON_FILE = "package.json";
8
+ const MANIFEST_JSON_FILE = "manifest.json";
9
+ const MPX_SCRIPT_RE = /\bmpx(?:-cli-service)?\b/u;
10
+ const TARO_SCRIPT_RE = /\btaro\b/u;
11
+ const WEAPP_VITE_SCRIPT_RE = /\bweapp-vite\b/u;
12
+ const UNI_APP_SCRIPT_RE = /\buni(?:\s|$)/u;
13
+ const UNI_APP_VITE_SCRIPT_RE = /\buni(?:\s|$)/u;
14
+ const MPX_MARKERS = [["src/app.mpx", "mpx"], ["app.mpx", "mpx"]];
15
+ function getProcessEnv() {
16
+ return {
17
+ MPX_CLI_MODE: process.env["MPX_CLI_MODE"],
18
+ MPX_CURRENT_TARGET_MODE: process.env["MPX_CURRENT_TARGET_MODE"],
19
+ NODE_PATH: process.env["NODE_PATH"],
20
+ TARO_ENV: process.env["TARO_ENV"],
21
+ UNI_PLATFORM: process.env["UNI_PLATFORM"],
22
+ UNI_UTS_PLATFORM: process.env["UNI_UTS_PLATFORM"],
23
+ WEAPP_TAILWINDCSS_TARGET: process.env["WEAPP_TAILWINDCSS_TARGET"],
24
+ WEAPP_TW_TARGET: process.env["WEAPP_TW_TARGET"]
25
+ };
26
+ }
27
+ function resolveDependencyNames(pkg) {
28
+ return new Set([
29
+ ...Object.keys(pkg.dependencies ?? {}),
30
+ ...Object.keys(pkg.devDependencies ?? {}),
31
+ ...Object.keys(pkg.peerDependencies ?? {}),
32
+ ...Object.keys(pkg.optionalDependencies ?? {})
33
+ ]);
34
+ }
35
+ function hasDependencyPrefix(dependencyNames, prefix) {
36
+ return [...dependencyNames].some((name) => name.startsWith(prefix));
37
+ }
38
+ function hasScriptMatch(pkg, pattern) {
39
+ return Object.values(pkg.scripts ?? {}).some((script) => pattern.test(script));
40
+ }
41
+ function normalizePlatform(value) {
42
+ return value?.trim().toLowerCase() || void 0;
43
+ }
44
+ function resolvePlatformInfo(value) {
45
+ const normalized = normalizePlatform(value);
46
+ const isAppAndroid = normalized === "app-android";
47
+ const isAppIos = normalized === "app-ios";
48
+ const isAppHarmony = normalized === "app-harmony";
49
+ return {
50
+ raw: value,
51
+ normalized,
52
+ isApp: normalized?.startsWith("app-") === true || normalized === "app" || normalized === "app-plus",
53
+ isAppAndroid,
54
+ isAppHarmony,
55
+ isAppIos,
56
+ isMp: normalized?.startsWith("mp-") === true,
57
+ isWeb: normalized?.startsWith("web") === true || normalized === "h5"
58
+ };
59
+ }
60
+ function hasKnownHBuilderXPluginPrefix(normalizedCwd) {
61
+ for (const dir of KNOWN_MAC_HBUILDERX_PLUGIN_DIRS) {
62
+ const normalizedDir = path.normalize(dir);
63
+ if (normalizedCwd === normalizedDir || normalizedCwd.startsWith(`${normalizedDir}${path.sep}`)) return true;
64
+ }
65
+ return false;
66
+ }
67
+ function matchesHBuilderXPluginCwd(cwd) {
68
+ const normalized = path.normalize(cwd);
69
+ if (hasKnownHBuilderXPluginPrefix(normalized)) return true;
70
+ return HBUILDERX_PLUGIN_CWD_RE.test(normalized);
71
+ }
72
+ function isRunningInHBuilderX(options = {}) {
73
+ const env = options.env ?? getProcessEnv();
74
+ const nodePath = "nodePath" in options ? options.nodePath : env.NODE_PATH;
75
+ if (!(nodePath == null || nodePath.trim().length === 0)) return false;
76
+ return matchesHBuilderXPluginCwd(options.cwd ?? process.cwd());
77
+ }
78
+ function resolveUniPlatform(value) {
79
+ return resolvePlatformInfo(value);
80
+ }
81
+ function resolveUniUtsPlatform(value) {
82
+ return resolvePlatformInfo(value);
83
+ }
84
+ function resolveUniPlatformsFromEnv(env = getProcessEnv()) {
85
+ return {
86
+ uniPlatform: resolveUniPlatform(env.UNI_PLATFORM),
87
+ uniUtsPlatform: resolveUniUtsPlatform(env.UNI_UTS_PLATFORM)
88
+ };
89
+ }
90
+ function detectAppTypeFromEnv(env = getProcessEnv(), options = {}) {
91
+ if (env.WEAPP_TW_TARGET === "weapp-vite" || env.WEAPP_TAILWINDCSS_TARGET === "weapp-vite") return "weapp-vite";
92
+ if (env.TARO_ENV) return "taro";
93
+ if (env.MPX_CLI_MODE || env.MPX_CURRENT_TARGET_MODE) return "mpx";
94
+ const { uniPlatform, uniUtsPlatform } = resolveUniPlatformsFromEnv(env);
95
+ if (uniUtsPlatform.normalized) return "uni-app-x";
96
+ if (uniPlatform.normalized) return "uni-app-vite";
97
+ if (isRunningInHBuilderX({
98
+ cwd: options.cwd,
99
+ env
100
+ })) return options.hbuilderxVite === false ? "uni-app" : "uni-app-vite";
101
+ }
102
+ function isWeappVitePackage(pkg) {
103
+ const dependencyNames = resolveDependencyNames(pkg);
104
+ return dependencyNames.has("weapp-vite") || hasDependencyPrefix(dependencyNames, "@weapp-vite/") || hasScriptMatch(pkg, WEAPP_VITE_SCRIPT_RE);
105
+ }
106
+ function isMpxPackage(pkg) {
107
+ return hasDependencyPrefix(resolveDependencyNames(pkg), "@mpxjs/") || hasScriptMatch(pkg, MPX_SCRIPT_RE);
108
+ }
109
+ function isTaroPackage(pkg) {
110
+ return hasDependencyPrefix(resolveDependencyNames(pkg), "@tarojs/") || hasScriptMatch(pkg, TARO_SCRIPT_RE);
111
+ }
112
+ function isUniAppVitePackage(pkg) {
113
+ return resolveDependencyNames(pkg).has("@dcloudio/vite-plugin-uni") || hasScriptMatch(pkg, UNI_APP_VITE_SCRIPT_RE);
114
+ }
115
+ function isUniAppXPackage(pkg) {
116
+ const dependencyNames = resolveDependencyNames(pkg);
117
+ return dependencyNames.has("@dcloudio/uni-uts-v1") || dependencyNames.has("@weapp-tailwindcss/debug-uni-app-x");
118
+ }
119
+ function isUniAppPackage(pkg) {
120
+ const dependencyNames = resolveDependencyNames(pkg);
121
+ return dependencyNames.has("@dcloudio/vue-cli-plugin-uni") || dependencyNames.has("@dcloudio/uni-app") || Object.hasOwn(pkg, "uni-app") || hasScriptMatch(pkg, UNI_APP_SCRIPT_RE);
122
+ }
123
+ function isUniAppXManifest(manifest) {
124
+ return Boolean(manifest && Object.hasOwn(manifest, "uni-app-x"));
125
+ }
126
+ function detectAppTypeFromPackageJson(pkg) {
127
+ if (isWeappVitePackage(pkg)) return "weapp-vite";
128
+ if (isMpxPackage(pkg)) return "mpx";
129
+ if (isTaroPackage(pkg)) return "taro";
130
+ if (isUniAppXPackage(pkg)) return "uni-app-x";
131
+ if (isUniAppVitePackage(pkg)) return "uni-app-vite";
132
+ if (isUniAppPackage(pkg)) return "uni-app";
133
+ }
134
+ function tryReadJson(file) {
135
+ if (!existsSync(file)) return;
136
+ try {
137
+ return JSON.parse(readFileSync(file, "utf8"));
138
+ } catch {}
139
+ }
140
+ function detectAppTypeFromMarkers(root) {
141
+ for (const [relativePath, appType] of MPX_MARKERS) if (existsSync(path.join(root, relativePath))) return appType;
142
+ }
143
+ function detectAppTypeFromRoot(root, searchUp = true) {
144
+ const resolvedRoot = path.resolve(root);
145
+ if (!existsSync(resolvedRoot)) return;
146
+ const markerDetected = detectAppTypeFromMarkers(resolvedRoot);
147
+ if (markerDetected) return markerDetected;
148
+ let current = resolvedRoot;
149
+ while (true) {
150
+ if (isUniAppXManifest(tryReadJson(path.join(current, MANIFEST_JSON_FILE)))) return "uni-app-x";
151
+ const pkg = tryReadJson(path.join(current, PACKAGE_JSON_FILE));
152
+ if (pkg) {
153
+ const detected = detectAppTypeFromPackageJson(pkg);
154
+ if (detected) return detected;
155
+ }
156
+ if (!searchUp) break;
157
+ const parent = path.dirname(current);
158
+ if (parent === current) break;
159
+ current = parent;
160
+ }
161
+ }
162
+ function detectAppType(options = {}) {
163
+ if (isUniAppXManifest(options.manifest)) return "uni-app-x";
164
+ if (options.packageJson) {
165
+ const detected = detectAppTypeFromPackageJson(options.packageJson);
166
+ if (detected) return detected;
167
+ }
168
+ if (options.root) {
169
+ const detected = detectAppTypeFromRoot(options.root, options.searchUp ?? true);
170
+ if (detected) return detected;
171
+ }
172
+ const env = options.env ?? (options.detectEnv ? getProcessEnv() : void 0);
173
+ if (env) return detectAppTypeFromEnv(env, {
174
+ cwd: options.cwd ?? options.root ?? (options.detectEnv ? process.cwd() : void 0),
175
+ hbuilderxVite: options.hbuilderxVite
176
+ });
177
+ }
178
+ const resolveImplicitAppTypeFromViteRoot = (root) => detectAppType({ root });
179
+ //#endregion
180
+ export { detectAppType, detectAppTypeFromEnv, detectAppTypeFromPackageJson, isMpxPackage, isRunningInHBuilderX, isTaroPackage, isUniAppPackage, isUniAppVitePackage, isUniAppXManifest, isUniAppXPackage, isWeappVitePackage, resolveImplicitAppTypeFromViteRoot, resolveUniPlatform, resolveUniPlatformsFromEnv, resolveUniUtsPlatform };
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_v3_engine = require("./v3-engine-D0yA9ZkF.js");
2
+ const require_v3_engine = require("./v3-engine-2rrgylhn.js");
3
3
  let node_process = require("node:process");
4
4
  node_process = require_chunk.__toESM(node_process);
5
5
  //#region src/generator/options.ts
@@ -1,4 +1,4 @@
1
- import { K as createTailwindV4Engine, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher, x as resolveTailwindV4SourceFromPatcher } from "./v3-engine-CFkP6dWF.mjs";
1
+ import { C as resolveTailwindV4SourceFromPatcher, J as createTailwindV4Engine, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher } from "./v3-engine-C6eJ0YzK.mjs";
2
2
  import process from "node:process";
3
3
  //#region src/generator/options.ts
4
4
  const explicitGeneratorTargetEnvKeys = ["WEAPP_TW_TARGET", "WEAPP_TAILWINDCSS_TARGET"];
package/dist/generator.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_v3_engine = require("./v3-engine-D0yA9ZkF.js");
3
- const require_generator = require("./generator-ChgOWNOj.js");
2
+ const require_v3_engine = require("./v3-engine-2rrgylhn.js");
3
+ const require_generator = require("./generator-CzpArpCL.js");
4
4
  let tailwindcss_patch = require("tailwindcss-patch");
5
5
  exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
6
6
  exports.createWeappTailwindcssGeneratorFromPatcher = require_generator.createWeappTailwindcssGeneratorFromPatcher;
@@ -1,3 +1,3 @@
1
- import { J as transformTailwindV4CssToWeapp, S as resolveTailwindV4SourceOptionsFromPatcher, a as transformTailwindV3CssByTarget, b as resolveTailwindV4SourceFromPatchOptions, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssToWeapp, q as transformTailwindV4CssByTarget, r as resolveTailwindV3SourceOptionsFromPatcher, t as resolveTailwindV3Source, x as resolveTailwindV4SourceFromPatcher, y as resolveTailwindV4Source } from "./v3-engine-CFkP6dWF.mjs";
2
- import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-h2XRiJ9-.mjs";
1
+ import { C as resolveTailwindV4SourceFromPatcher, S as resolveTailwindV4SourceFromPatchOptions, X as transformTailwindV4CssByTarget, Z as transformTailwindV4CssToWeapp, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssByTarget, r as resolveTailwindV3SourceOptionsFromPatcher, s as transformTailwindV3CssToWeapp, t as resolveTailwindV3Source, w as resolveTailwindV4SourceOptionsFromPatcher, x as resolveTailwindV4Source } from "./v3-engine-C6eJ0YzK.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-ITLd7PTl.mjs";
3
3
  export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromPatcher, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromPatcher, resolveTailwindV3Source, resolveTailwindV3SourceFromPatcher, resolveTailwindV3SourceOptionsFromPatcher, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveTailwindV4SourceFromPatcher, resolveTailwindV4SourceOptionsFromPatcher, transformTailwindV3CssByTarget, transformTailwindV3CssToWeapp, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };