weapp-tailwindcss 5.0.5 → 5.0.7

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 (103) hide show
  1. package/dist/{bundle-state-Cso_ceUo.js → bundle-state-BzwPS-UI.js} +2 -1
  2. package/dist/{bundle-state-DEyxCR4f.mjs → bundle-state-ChcOKb9w.mjs} +2 -1
  3. package/dist/bundlers/gulp/index.d.ts +3 -4
  4. package/dist/bundlers/gulp/module-graph.d.ts +2 -0
  5. package/dist/bundlers/gulp/runtime-snapshot.d.ts +5 -0
  6. package/dist/bundlers/gulp/vinyl-transform.d.ts +3 -0
  7. package/dist/bundlers/shared/css-cleanup.d.ts +1 -1
  8. package/dist/bundlers/shared/css-source-trace.d.ts +20 -0
  9. package/dist/bundlers/shared/generator-css/directives/fallback.d.ts +11 -0
  10. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +56 -0
  11. package/dist/bundlers/shared/generator-css/local-imports.d.ts +7 -0
  12. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +1 -1
  13. package/dist/bundlers/shared/generator-css/types.d.ts +27 -0
  14. package/dist/bundlers/shared/generator-css/user-css.d.ts +26 -0
  15. package/dist/bundlers/shared/generator-css/validate.d.ts +5 -0
  16. package/dist/bundlers/shared/generator-css.d.ts +4 -32
  17. package/dist/bundlers/vite/css-finalizer.d.ts +3 -0
  18. package/dist/bundlers/vite/generate-bundle/css-config-directives.d.ts +2 -0
  19. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +14 -0
  20. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +11 -0
  21. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +9 -0
  22. package/dist/bundlers/vite/generate-bundle/style-matching.d.ts +5 -0
  23. package/dist/bundlers/vite/generate-bundle/subpackages.d.ts +7 -0
  24. package/dist/bundlers/vite/generate-bundle/types.d.ts +68 -0
  25. package/dist/bundlers/vite/generate-bundle.d.ts +4 -62
  26. package/dist/bundlers/vite/incremental-runtime-class-set/entries.d.ts +4 -0
  27. package/dist/bundlers/vite/incremental-runtime-class-set/escaped-candidates.d.ts +2 -0
  28. package/dist/bundlers/vite/incremental-runtime-class-set/v3-candidates.d.ts +13 -0
  29. package/dist/bundlers/vite/incremental-runtime-class-set.d.ts +1 -0
  30. package/dist/bundlers/vite/processed-css-assets/css-rules.d.ts +17 -0
  31. package/dist/bundlers/vite/processed-css-assets.d.ts +2 -0
  32. package/dist/bundlers/vite/source-candidates/scan-root.d.ts +10 -0
  33. package/dist/bundlers/vite/source-candidates/script.d.ts +7 -0
  34. package/dist/bundlers/vite/source-candidates/tailwind-v3-default-extractor.d.ts +1 -0
  35. package/dist/bundlers/vite/source-candidates.d.ts +8 -3
  36. package/dist/bundlers/vite/source-scan/css-entries.d.ts +20 -0
  37. package/dist/bundlers/vite/source-scan/dependencies.d.ts +2 -0
  38. package/dist/bundlers/vite/source-scan.d.ts +2 -12
  39. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +48 -0
  40. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets.d.ts +1 -20
  41. package/dist/cli.js +69 -69
  42. package/dist/cli.mjs +69 -69
  43. package/dist/core.js +1 -1
  44. package/dist/core.mjs +1 -1
  45. package/dist/{defaults-BPUuNYcD.js → defaults-Boc26eel.js} +1 -0
  46. package/dist/{defaults-8xrgzxFY.mjs → defaults-DH0ZQRhy.mjs} +1 -0
  47. package/dist/defaults.js +1 -1
  48. package/dist/defaults.mjs +1 -1
  49. package/dist/{generator-AD-eX8Tr.js → generator-6yF8wjxR.js} +1 -1
  50. package/dist/{generator-DVWLNO0n.mjs → generator-BON6M1bL.mjs} +1 -1
  51. package/dist/generator.js +2 -2
  52. package/dist/generator.mjs +2 -2
  53. package/dist/gulp-_7p1Z2vc.js +473 -0
  54. package/dist/gulp-oE-Byqk6.mjs +463 -0
  55. package/dist/gulp.js +4 -414
  56. package/dist/gulp.mjs +1 -406
  57. package/dist/{incremental-runtime-class-set-vOetpdWs.js → hmr-timing-BKQNRxHr.js} +1257 -459
  58. package/dist/{incremental-runtime-class-set-xf49kky6.mjs → hmr-timing-BVTGf5ch.mjs} +1221 -477
  59. package/dist/index.js +5 -5
  60. package/dist/index.mjs +5 -5
  61. package/dist/{postcss-Cbi6RFpf.js → postcss-BTIunhWl.js} +7 -7
  62. package/dist/{postcss-hSUxK7oR.mjs → postcss-BtmrrZ31.mjs} +4 -4
  63. package/dist/postcss.js +1 -1
  64. package/dist/postcss.mjs +1 -1
  65. package/dist/{precheck-Bsn_LMmo.mjs → precheck-CZjr87m_.mjs} +19 -5
  66. package/dist/{precheck-b8Y8qZg0.js → precheck-fhIkzCSU.js} +19 -5
  67. package/dist/presets.js +2 -2
  68. package/dist/presets.mjs +2 -2
  69. package/dist/tailwindcss/source-scan/inline-source.d.ts +7 -0
  70. package/dist/tailwindcss/source-scan.d.ts +2 -7
  71. package/dist/tailwindcss/v3-engine/generator/cache-key.d.ts +3 -0
  72. package/dist/tailwindcss/v3-engine/generator/content.d.ts +10 -0
  73. package/dist/tailwindcss/v3-engine/generator/runtime-ready.d.ts +2 -0
  74. package/dist/tailwindcss/v4-engine/generator/css-compat.d.ts +2 -0
  75. package/dist/tailwindcss/v4-engine/generator/rpx-candidates.d.ts +6 -0
  76. package/dist/tailwindcss/v4-engine/generator/scan-sources.d.ts +2 -0
  77. package/dist/tailwindcss/v4-engine/types.d.ts +1 -1
  78. package/dist/{tailwindcss-AWaPVF2B.mjs → tailwindcss-bbQUg25J.mjs} +2 -2
  79. package/dist/{tailwindcss-CpQ6X4l6.js → tailwindcss-vswd1gc3.js} +2 -2
  80. package/dist/{transform-BkGtbxb1.js → transform-CReJxxh_.js} +11 -2
  81. package/dist/{transform-DumSZmTh.mjs → transform-DEsFlG9k.mjs} +11 -2
  82. package/dist/types/typedoc-tailwindcss-patch.d.ts +4 -2
  83. package/dist/types/user-defined-options/general.d.ts +5 -0
  84. package/dist/uni-app-x/component-local-style.d.ts +1 -0
  85. package/dist/uni-app-x/harmony.d.ts +1 -0
  86. package/dist/uni-app-x/style-asset/style-value.d.ts +16 -0
  87. package/dist/uni-app-x/style-asset.d.ts +20 -0
  88. package/dist/uni-app-x/transform.d.ts +1 -0
  89. package/dist/uni-app-x/vite.d.ts +1 -0
  90. package/dist/{v3-engine-CM0TRa8V.js → v3-engine-CEMXFegG.js} +714 -663
  91. package/dist/{v3-engine-Cczrkzqt.mjs → v3-engine-CdIwmHuc.mjs} +758 -707
  92. package/dist/{vite-CTuHPC91.js → vite-0jFbh9hx.js} +1797 -386
  93. package/dist/{vite-DLXDMHON.mjs → vite-C7BGAlCE.mjs} +1779 -369
  94. package/dist/vite.js +1 -1
  95. package/dist/vite.mjs +1 -1
  96. package/dist/weapp-tw-css-import-rewrite-loader.js +1169 -1002
  97. package/dist/{webpack-DJFw08SK.mjs → webpack-Dx6_eg5k.mjs} +96 -36
  98. package/dist/{webpack-BBHJYKqB.js → webpack-aEuDoYfQ.js} +105 -44
  99. package/dist/webpack.js +1 -1
  100. package/dist/webpack.mjs +1 -1
  101. package/package.json +6 -5
  102. package/dist/source-candidates-BsWYoIPN.mjs +0 -355
  103. package/dist/source-candidates-o2ZrKWzu.js +0 -374
@@ -0,0 +1,473 @@
1
+ const require_chunk = require("./chunk-emK7D4bc.js");
2
+ const require_v3_engine = require("./v3-engine-CEMXFegG.js");
3
+ const require_precheck = require("./precheck-fhIkzCSU.js");
4
+ const require_tailwindcss = require("./tailwindcss-vswd1gc3.js");
5
+ const require_hmr_timing = require("./hmr-timing-BKQNRxHr.js");
6
+ let node_process = require("node:process");
7
+ node_process = require_chunk.__toESM(node_process);
8
+ let node_fs = require("node:fs");
9
+ node_fs = require_chunk.__toESM(node_fs);
10
+ let node_path = require("node:path");
11
+ node_path = require_chunk.__toESM(node_path);
12
+ let node_buffer = require("node:buffer");
13
+ let node_stream = require("node:stream");
14
+ node_stream = require_chunk.__toESM(node_stream);
15
+ //#region src/bundlers/gulp/module-graph.ts
16
+ const MODULE_EXTENSIONS = [
17
+ ".js",
18
+ ".mjs",
19
+ ".cjs",
20
+ ".ts",
21
+ ".tsx",
22
+ ".jsx"
23
+ ];
24
+ function resolveWithExtensions(base) {
25
+ for (const ext of MODULE_EXTENSIONS) {
26
+ const candidate = `${base}${ext}`;
27
+ try {
28
+ if (node_fs.default.statSync(candidate).isFile()) return candidate;
29
+ } catch {
30
+ continue;
31
+ }
32
+ }
33
+ }
34
+ function resolveLocalModuleCandidate(base) {
35
+ try {
36
+ const stat = node_fs.default.statSync(base);
37
+ if (stat.isFile()) return base;
38
+ if (stat.isDirectory()) {
39
+ const resolvedIndex = resolveWithExtensions(node_path.default.join(base, "index"));
40
+ if (resolvedIndex) return resolvedIndex;
41
+ }
42
+ } catch {}
43
+ if (!node_path.default.extname(base)) return resolveWithExtensions(base);
44
+ }
45
+ function createGulpModuleGraphOptions(opts) {
46
+ return {
47
+ resolve(specifier, importer) {
48
+ if (!specifier) return;
49
+ if (!specifier.startsWith(".") && !node_path.default.isAbsolute(specifier)) return;
50
+ return resolveLocalModuleCandidate(node_path.default.resolve(node_path.default.dirname(importer), specifier));
51
+ },
52
+ load(id) {
53
+ try {
54
+ return node_fs.default.readFileSync(id, "utf8");
55
+ } catch {
56
+ return;
57
+ }
58
+ },
59
+ filter(id) {
60
+ const relative = node_path.default.relative(node_process.default.cwd(), id);
61
+ return opts.jsMatcher(relative) || opts.wxsMatcher(relative);
62
+ }
63
+ };
64
+ }
65
+ //#endregion
66
+ //#region src/bundlers/gulp/runtime-snapshot.ts
67
+ function createGulpRuntimeSnapshot(runtimeSourcesByFile, changedFiles) {
68
+ const runtimeAffectingChangedByType = {
69
+ html: /* @__PURE__ */ new Set(),
70
+ js: /* @__PURE__ */ new Set(),
71
+ css: /* @__PURE__ */ new Set(),
72
+ other: /* @__PURE__ */ new Set()
73
+ };
74
+ for (const file of changedFiles) {
75
+ const entry = runtimeSourcesByFile.get(file);
76
+ if (entry) runtimeAffectingChangedByType[entry.type].add(file);
77
+ }
78
+ return {
79
+ entries: [...runtimeSourcesByFile.entries()].map(([file, entry]) => ({
80
+ file,
81
+ output: {
82
+ fileName: file,
83
+ source: entry.source,
84
+ type: "asset"
85
+ },
86
+ source: entry.source,
87
+ type: entry.type
88
+ })),
89
+ jsEntries: /* @__PURE__ */ new Map(),
90
+ sourceHashByFile: /* @__PURE__ */ new Map(),
91
+ runtimeAffectingSignatureByFile: /* @__PURE__ */ new Map(),
92
+ runtimeAffectingHashByFile: /* @__PURE__ */ new Map(),
93
+ hasOmittedKnownFiles: false,
94
+ changedByType: {
95
+ html: /* @__PURE__ */ new Set(),
96
+ js: /* @__PURE__ */ new Set(),
97
+ css: /* @__PURE__ */ new Set(),
98
+ other: /* @__PURE__ */ new Set()
99
+ },
100
+ runtimeAffectingChangedByType,
101
+ processFiles: {
102
+ html: /* @__PURE__ */ new Set(),
103
+ js: /* @__PURE__ */ new Set(),
104
+ css: /* @__PURE__ */ new Set()
105
+ },
106
+ linkedImpactsByEntry: /* @__PURE__ */ new Map()
107
+ };
108
+ }
109
+ //#endregion
110
+ //#region src/bundlers/gulp/vinyl-transform.ts
111
+ const Transform = node_stream.default.Transform;
112
+ function createVinylTransform(phase, handler) {
113
+ return new Transform({
114
+ objectMode: true,
115
+ async transform(file, _encoding, callback) {
116
+ const hmrTimingStartedAt = performance.now();
117
+ try {
118
+ await handler(file);
119
+ require_hmr_timing.emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, { file: file.relative || node_path.default.basename(file.path) });
120
+ callback(null, file);
121
+ } catch (error) {
122
+ callback(error, file);
123
+ }
124
+ }
125
+ });
126
+ }
127
+ //#endregion
128
+ //#region src/bundlers/gulp/index.ts
129
+ const debug = require_v3_engine.createDebug();
130
+ /**
131
+ * @name weapp-tw-gulp
132
+ * @description gulp版本weapp-tw插件
133
+ * @link https://tw.icebreaker.top/docs/quick-start/frameworks/native
134
+ */
135
+ function createPlugins(options = {}) {
136
+ const hasInitialTailwindCssRoots = require_tailwindcss.hasConfiguredTailwindV4CssRoots(options);
137
+ const opts = require_precheck.getCompilerContext({
138
+ ...options,
139
+ __internalDeferMissingCssEntriesWarning: true
140
+ });
141
+ const { templateHandler, styleHandler, jsHandler, cache, twPatcher: initialTwPatcher, refreshTailwindcssPatcher } = opts;
142
+ const readyPromise = require_precheck.createTailwindRuntimeReadyPromise(initialTwPatcher);
143
+ let runtimeSet = /* @__PURE__ */ new Set();
144
+ const runtimeState = {
145
+ twPatcher: initialTwPatcher,
146
+ readyPromise,
147
+ refreshTailwindcssPatcher
148
+ };
149
+ const defaultStyleHandlerOptionsCache = /* @__PURE__ */ new Map();
150
+ let cachedDefaultTemplateHandlerOptions;
151
+ let cachedDefaultTemplateRuntimeSet;
152
+ let cachedDefaultModuleGraphOptions;
153
+ let cachedGulpSourceCandidateGetter;
154
+ let cachedGulpSourceCandidateSourceGetter;
155
+ let runtimeSetInitialized = false;
156
+ let runtimeSetDirty = false;
157
+ const runtimeSourceHashByFile = /* @__PURE__ */ new Map();
158
+ const runtimeSourcesByFile = /* @__PURE__ */ new Map();
159
+ let cachedGulpSourceCandidates;
160
+ let cachedGulpSourceCandidateSignature;
161
+ const sourceCandidateExtractor = initialTwPatcher.majorVersion === 3 ? require_hmr_timing.createTailwindV3DefaultExtractor() : void 0;
162
+ const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? require_hmr_timing.createBundleRuntimeClassSetManager();
163
+ function invalidateGulpSourceCandidates() {
164
+ cachedGulpSourceCandidates = void 0;
165
+ cachedGulpSourceCandidateSignature = void 0;
166
+ cachedGulpSourceCandidateGetter = void 0;
167
+ cachedGulpSourceCandidateSourceGetter = void 0;
168
+ }
169
+ async function refreshRuntimeSet(options = false) {
170
+ const normalizedOptions = typeof options === "boolean" ? {
171
+ forceRefresh: options,
172
+ forceCollect: options,
173
+ clearCache: options
174
+ } : options;
175
+ const forceRefresh = normalizedOptions.forceRefresh === true;
176
+ const shouldForceCollect = normalizedOptions.forceCollect === true || runtimeSetDirty;
177
+ const clearCache = normalizedOptions.clearCache === true || runtimeSetDirty;
178
+ if (!forceRefresh && !shouldForceCollect && runtimeSetInitialized) return runtimeSet;
179
+ runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState, {
180
+ forceRefresh,
181
+ forceCollect: shouldForceCollect,
182
+ clearCache,
183
+ allowEmpty: false
184
+ });
185
+ runtimeSetInitialized = true;
186
+ runtimeSetDirty = false;
187
+ return runtimeSet;
188
+ }
189
+ async function refreshRuntimeSetForSource(file, rawSource, type) {
190
+ const filename = node_path.default.resolve(file.path);
191
+ const hash = cache.computeHash(rawSource);
192
+ const changed = runtimeSourceHashByFile.get(filename) !== hash;
193
+ runtimeSourceHashByFile.set(filename, hash);
194
+ runtimeSourcesByFile.set(filename, {
195
+ source: rawSource,
196
+ type
197
+ });
198
+ if (changed && runtimeState.twPatcher.majorVersion === 4) invalidateGulpSourceCandidates();
199
+ if (!changed && runtimeSetInitialized) return runtimeSet;
200
+ if (runtimeState.twPatcher.majorVersion === 4 && !runtimeSetDirty) try {
201
+ runtimeSet = await bundleRuntimeClassSetManager.sync(runtimeState.twPatcher, createGulpRuntimeSnapshot(runtimeSourcesByFile, [filename]));
202
+ runtimeSetInitialized = true;
203
+ return runtimeSet;
204
+ } catch (error) {
205
+ debug("gulp incremental runtime set sync failed, fallback to collect: %O", error);
206
+ await bundleRuntimeClassSetManager.reset();
207
+ }
208
+ return refreshRuntimeSet({ forceCollect: true });
209
+ }
210
+ async function refreshGulpSourceCandidates(forceRefresh = false) {
211
+ if (runtimeState.twPatcher.majorVersion !== 3) return /* @__PURE__ */ new Set();
212
+ const root = opts.tailwindcssBasedir ?? node_process.default.cwd();
213
+ const sourceScan = await require_v3_engine.resolveViteSourceScanEntries(opts, runtimeState.twPatcher, { root });
214
+ const nextSignature = cache.computeHash(JSON.stringify({
215
+ root,
216
+ entries: sourceScan?.entries,
217
+ inlineCandidates: sourceScan?.inlineCandidates ? {
218
+ included: [...sourceScan.inlineCandidates.included].sort(),
219
+ excluded: [...sourceScan.inlineCandidates.excluded].sort()
220
+ } : void 0,
221
+ explicit: sourceScan?.explicit ?? false,
222
+ dependencies: [...sourceScan?.dependencies ?? []].sort()
223
+ }));
224
+ if (!forceRefresh && cachedGulpSourceCandidateSignature === nextSignature && cachedGulpSourceCandidates) return cachedGulpSourceCandidates;
225
+ const collector = require_hmr_timing.createSourceCandidateCollector({
226
+ bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues,
227
+ extractor: sourceCandidateExtractor
228
+ });
229
+ await collector.scanRoot({
230
+ entries: sourceScan?.entries,
231
+ root
232
+ });
233
+ collector.syncInline(sourceScan?.inlineCandidates);
234
+ cachedGulpSourceCandidateSignature = nextSignature;
235
+ cachedGulpSourceCandidateGetter = (entries) => collector.valuesForEntries(entries);
236
+ cachedGulpSourceCandidateSourceGetter = (entries) => collector.sourcesForEntries(entries);
237
+ cachedGulpSourceCandidates = sourceScan?.entries ? collector.valuesForEntries(sourceScan.entries) : collector.values();
238
+ return cachedGulpSourceCandidates;
239
+ }
240
+ async function refreshGulpV4SourceCandidates(forceRefresh = false) {
241
+ if (runtimeState.twPatcher.majorVersion !== 4) {
242
+ cachedGulpSourceCandidateGetter = void 0;
243
+ cachedGulpSourceCandidateSourceGetter = void 0;
244
+ return;
245
+ }
246
+ const root = opts.tailwindcssBasedir ?? node_process.default.cwd();
247
+ const sourceScan = await require_v3_engine.resolveViteSourceScanEntries(opts, runtimeState.twPatcher, { root });
248
+ const nextSignature = cache.computeHash(JSON.stringify({
249
+ root,
250
+ entries: sourceScan?.entries,
251
+ inlineCandidates: sourceScan?.inlineCandidates ? {
252
+ included: [...sourceScan.inlineCandidates.included].sort(),
253
+ excluded: [...sourceScan.inlineCandidates.excluded].sort()
254
+ } : void 0,
255
+ explicit: sourceScan?.explicit ?? false,
256
+ dependencies: [...sourceScan?.dependencies ?? []].sort()
257
+ }));
258
+ if (!forceRefresh && cachedGulpSourceCandidateSignature === nextSignature && cachedGulpSourceCandidateGetter) return cachedGulpSourceCandidateGetter;
259
+ const collector = require_hmr_timing.createSourceCandidateCollector({ bareArbitraryValues: opts.arbitraryValues?.bareArbitraryValues });
260
+ await collector.scanRoot({
261
+ entries: sourceScan?.entries,
262
+ explicit: sourceScan?.explicit,
263
+ root
264
+ });
265
+ collector.syncInline(sourceScan?.inlineCandidates);
266
+ cachedGulpSourceCandidateSignature = nextSignature;
267
+ cachedGulpSourceCandidateGetter = (entries) => collector.valuesForEntries(entries);
268
+ cachedGulpSourceCandidateSourceGetter = (entries) => collector.sourcesForEntries(entries);
269
+ return cachedGulpSourceCandidateGetter;
270
+ }
271
+ function createRuntimeSetHash(rawSource, nextRuntimeSet, sourceTraceSignature) {
272
+ return cache.computeHash([
273
+ rawSource,
274
+ require_v3_engine.getRuntimeClassSetSignature(runtimeState.twPatcher),
275
+ [...nextRuntimeSet].sort().join("\n"),
276
+ sourceTraceSignature ?? "css-source-trace:0"
277
+ ].join("\n\n"));
278
+ }
279
+ async function registerAutoCssSource(file, rawSource) {
280
+ if (hasInitialTailwindCssRoots || (runtimeState.twPatcher.majorVersion ?? 0) < 4 || !file.path || !require_v3_engine.hasTailwindRootDirectives(rawSource)) return false;
281
+ const sourceFile = node_path.default.resolve(file.path);
282
+ const sourceCss = require_v3_engine.normalizeTailwindSourceForGenerator(require_v3_engine.normalizeTailwindConfigDirectives(rawSource, node_path.default.dirname(sourceFile)), { importFallback: true });
283
+ if (!require_tailwindcss.upsertTailwindV4CssSource(opts, {
284
+ file: sourceFile,
285
+ base: node_path.default.dirname(sourceFile),
286
+ css: sourceCss
287
+ })) return false;
288
+ runtimeSetInitialized = false;
289
+ runtimeSetDirty = true;
290
+ await bundleRuntimeClassSetManager.reset();
291
+ debug("detected tailwindcss v4 css source from gulp css file: %s", file.path);
292
+ return true;
293
+ }
294
+ function resolveModuleGraphOptions(moduleGraph) {
295
+ if (moduleGraph) return moduleGraph;
296
+ if (!cachedDefaultModuleGraphOptions) cachedDefaultModuleGraphOptions = createGulpModuleGraphOptions(opts);
297
+ return cachedDefaultModuleGraphOptions;
298
+ }
299
+ function resolveWxssHandlerOptions(options) {
300
+ const majorVersion = runtimeState.twPatcher.majorVersion ?? "unknown";
301
+ if (!options || Object.keys(options).length === 0) {
302
+ let cached = defaultStyleHandlerOptionsCache.get(majorVersion);
303
+ if (!cached) {
304
+ cached = runtimeState.twPatcher.majorVersion === void 0 ? {} : { majorVersion: runtimeState.twPatcher.majorVersion };
305
+ defaultStyleHandlerOptionsCache.set(majorVersion, cached);
306
+ }
307
+ return cached;
308
+ }
309
+ return runtimeState.twPatcher.majorVersion === void 0 ? { ...options } : {
310
+ majorVersion: runtimeState.twPatcher.majorVersion,
311
+ ...options
312
+ };
313
+ }
314
+ function resolveGulpMatcherName(file) {
315
+ return (file.relative || node_path.default.basename(file.path)).replaceAll(node_path.default.sep, "/");
316
+ }
317
+ function resolveWxssFileHandlerOptions(file, options) {
318
+ const resolved = resolveWxssHandlerOptions(options);
319
+ if (resolved.isMainChunk !== void 0) return resolved;
320
+ return {
321
+ ...resolved,
322
+ isMainChunk: opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType)
323
+ };
324
+ }
325
+ function resolveWxssUserHandlerOptions(options) {
326
+ return {
327
+ ...resolveWxssHandlerOptions(options),
328
+ isMainChunk: false
329
+ };
330
+ }
331
+ function resolveWxmlHandlerOptions(options) {
332
+ if (!options || Object.keys(options).length === 0) {
333
+ if (cachedDefaultTemplateRuntimeSet !== runtimeSet || !cachedDefaultTemplateHandlerOptions) {
334
+ cachedDefaultTemplateRuntimeSet = runtimeSet;
335
+ cachedDefaultTemplateHandlerOptions = { runtimeSet };
336
+ }
337
+ return cachedDefaultTemplateHandlerOptions;
338
+ }
339
+ return {
340
+ runtimeSet,
341
+ ...options
342
+ };
343
+ }
344
+ const transformWxss = (options = {}) => createVinylTransform("css", async (file) => {
345
+ if (!file.contents) return;
346
+ const rawSource = file.contents.toString();
347
+ const cssSourceChanged = await registerAutoCssSource(file, rawSource);
348
+ const isMainChunk = opts.mainCssChunkMatcher(resolveGulpMatcherName(file), opts.appType);
349
+ const shouldUseGenerator = runtimeState.twPatcher.majorVersion !== 3 || require_v3_engine.hasTailwindRootDirectives(rawSource);
350
+ const gulpV4SourceCandidates = shouldUseGenerator && runtimeState.twPatcher.majorVersion === 4 ? await refreshGulpV4SourceCandidates(cssSourceChanged) : void 0;
351
+ let nextRuntimeSet = await refreshRuntimeSet({
352
+ forceRefresh: cssSourceChanged,
353
+ forceCollect: cssSourceChanged || runtimeState.twPatcher.majorVersion !== 4 && isMainChunk,
354
+ clearCache: cssSourceChanged
355
+ });
356
+ if (runtimeState.twPatcher.majorVersion === 3 && isMainChunk && shouldUseGenerator) {
357
+ const sourceCandidates = await refreshGulpSourceCandidates(cssSourceChanged);
358
+ if (sourceCandidates.size > 0) {
359
+ nextRuntimeSet = new Set([...nextRuntimeSet, ...sourceCandidates]);
360
+ runtimeSet = nextRuntimeSet;
361
+ }
362
+ }
363
+ const sourceTraceTokenSources = cachedGulpSourceCandidateSourceGetter ? require_hmr_timing.createCssTokenSourceMap(cachedGulpSourceCandidateSourceGetter(void 0), opts) : void 0;
364
+ const sourceTraceSignature = require_hmr_timing.createCssSourceTraceCacheSignature(sourceTraceTokenSources, opts);
365
+ await require_hmr_timing.processCachedTask({
366
+ cache,
367
+ cacheKey: file.path,
368
+ hash: createRuntimeSetHash(rawSource, nextRuntimeSet, sourceTraceSignature),
369
+ applyResult(source) {
370
+ file.contents = node_buffer.Buffer.from(source);
371
+ },
372
+ onCacheHit() {
373
+ debug("css cache hit: %s", file.path);
374
+ },
375
+ async transform() {
376
+ await runtimeState.readyPromise;
377
+ const cssHandlerOptions = resolveWxssFileHandlerOptions(file, options);
378
+ const css = require_hmr_timing.annotateCssSourceTrace((shouldUseGenerator ? await require_hmr_timing.generateCssByGenerator({
379
+ opts,
380
+ runtimeState,
381
+ runtime: nextRuntimeSet,
382
+ rawSource,
383
+ file: file.path,
384
+ cssHandlerOptions,
385
+ cssUserHandlerOptions: resolveWxssUserHandlerOptions(options),
386
+ getSourceCandidatesForEntries: gulpV4SourceCandidates,
387
+ styleHandler,
388
+ debug
389
+ }) : void 0)?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css, {
390
+ opts,
391
+ tokenSources: sourceTraceTokenSources
392
+ });
393
+ debug("css handle: %s", file.path);
394
+ return { result: css };
395
+ }
396
+ });
397
+ });
398
+ const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
399
+ if (!file.contents) return;
400
+ const filename = node_path.default.resolve(file.path);
401
+ const rawSource = file.contents.toString();
402
+ await refreshRuntimeSetForSource(file, rawSource, "js");
403
+ await runtimeState.readyPromise;
404
+ const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
405
+ const handlerOptions = {
406
+ ...options,
407
+ filename,
408
+ moduleGraph,
409
+ babelParserOptions: {
410
+ ...options?.babelParserOptions ?? {},
411
+ sourceFilename: filename
412
+ }
413
+ };
414
+ if (runtimeState.twPatcher.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.twPatcher.majorVersion;
415
+ await require_hmr_timing.processCachedTask({
416
+ cache,
417
+ cacheKey: file.path,
418
+ rawSource,
419
+ applyResult(source) {
420
+ file.contents = node_buffer.Buffer.from(source);
421
+ },
422
+ onCacheHit() {
423
+ debug("js cache hit: %s", file.path);
424
+ },
425
+ async transform() {
426
+ await runtimeState.readyPromise;
427
+ const currentSource = file.contents?.toString() ?? rawSource;
428
+ if (require_precheck.shouldSkipJsTransform(currentSource, {
429
+ ...handlerOptions,
430
+ classNameSet: runtimeSet
431
+ })) return { result: currentSource };
432
+ const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
433
+ debug("js handle: %s", file.path);
434
+ return { result: code };
435
+ }
436
+ });
437
+ });
438
+ const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
439
+ if (!file.contents) return;
440
+ const rawSource = file.contents.toString();
441
+ await refreshRuntimeSetForSource(file, rawSource, "html");
442
+ await runtimeState.readyPromise;
443
+ await require_hmr_timing.processCachedTask({
444
+ cache,
445
+ cacheKey: file.path,
446
+ rawSource,
447
+ applyResult(source) {
448
+ file.contents = node_buffer.Buffer.from(source);
449
+ },
450
+ onCacheHit() {
451
+ debug("html cache hit: %s", file.path);
452
+ },
453
+ async transform() {
454
+ await runtimeState.readyPromise;
455
+ const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
456
+ debug("html handle: %s", file.path);
457
+ return { result: code };
458
+ }
459
+ });
460
+ });
461
+ return {
462
+ transformWxss,
463
+ transformWxml,
464
+ transformJs
465
+ };
466
+ }
467
+ //#endregion
468
+ Object.defineProperty(exports, "createPlugins", {
469
+ enumerable: true,
470
+ get: function() {
471
+ return createPlugins;
472
+ }
473
+ });