weapp-tailwindcss 5.1.14 → 5.1.16

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 (149) hide show
  1. package/dist/auto-2dg_uhEJ.mjs +13 -0
  2. package/dist/bundlers/gulp/frameworks/native/index.d.ts +2 -0
  3. package/dist/bundlers/gulp/index.d.ts +2 -0
  4. package/dist/bundlers/gulp/shared/create-native-framework-plugins/cache-state.d.ts +71 -0
  5. package/dist/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.d.ts +43 -0
  6. package/dist/bundlers/gulp/shared/create-native-framework-plugins.d.ts +4 -2
  7. package/dist/bundlers/shared/framework-postcss.d.ts +14 -0
  8. package/dist/bundlers/shared/generated-css-marker.d.ts +2 -2
  9. package/dist/bundlers/shared/generator-css/generation-helpers/preflight.d.ts +18 -0
  10. package/dist/bundlers/shared/generator-css/generation-helpers/results.d.ts +25 -0
  11. package/dist/bundlers/shared/generator-css/generation-helpers/runtime-isolation.d.ts +30 -0
  12. package/dist/bundlers/shared/generator-css/generation-helpers/source-order.d.ts +2 -0
  13. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +4 -72
  14. package/dist/bundlers/shared/generator-css/legacy-compat.d.ts +3 -1
  15. package/dist/bundlers/shared/generator-css/local-imports.d.ts +1 -1
  16. package/dist/bundlers/shared/generator-css/pipeline/deferred-output.d.ts +14 -0
  17. package/dist/bundlers/shared/generator-css/pipeline/execution.d.ts +12 -0
  18. package/dist/bundlers/shared/generator-css/pipeline/fallback-output.d.ts +12 -0
  19. package/dist/bundlers/shared/generator-css/pipeline/ordered-output.d.ts +25 -0
  20. package/dist/bundlers/shared/generator-css/pipeline.d.ts +2 -0
  21. package/dist/bundlers/shared/generator-css/result-helpers.d.ts +6 -0
  22. package/dist/bundlers/shared/generator-css/scoped-rules.d.ts +1 -0
  23. package/dist/bundlers/shared/generator-css/source-resolver/configuration.d.ts +33 -0
  24. package/dist/bundlers/shared/generator-css/source-resolver/postcss-source.d.ts +2 -0
  25. package/dist/bundlers/shared/generator-css/source-resolver/resolve-source.d.ts +4 -0
  26. package/dist/bundlers/shared/generator-css/source-resolver/resolve-sources.d.ts +4 -0
  27. package/dist/bundlers/shared/generator-css/source-resolver/single-source.d.ts +16 -0
  28. package/dist/bundlers/shared/generator-css/source-resolver/source-entries.d.ts +3 -0
  29. package/dist/bundlers/shared/generator-css/source-resolver/source-matching.d.ts +5 -0
  30. package/dist/bundlers/shared/generator-css/source-resolver.d.ts +3 -6
  31. package/dist/bundlers/shared/generator-css/types.d.ts +5 -0
  32. package/dist/bundlers/shared/generator-css/user-css/apply-only.d.ts +9 -0
  33. package/dist/bundlers/shared/generator-css/user-css/at-rules.d.ts +3 -0
  34. package/dist/bundlers/shared/generator-css/user-css/generated-cleanup.d.ts +4 -0
  35. package/dist/bundlers/shared/generator-css/user-css/source-fragments.d.ts +9 -0
  36. package/dist/bundlers/shared/generator-css/user-css/transform.d.ts +10 -0
  37. package/dist/bundlers/shared/generator-css/user-css/user-layers.d.ts +15 -0
  38. package/dist/bundlers/shared/generator-css/user-css.d.ts +5 -33
  39. package/dist/bundlers/shared/generator-css.d.ts +1 -2
  40. package/dist/bundlers/shared/style-requests.d.ts +1 -0
  41. package/dist/bundlers/shared/v4-generation-core.d.ts +3 -0
  42. package/dist/bundlers/vite/bundle-state.d.ts +1 -0
  43. package/dist/bundlers/vite/css-finalizer/options.d.ts +54 -0
  44. package/dist/bundlers/vite/css-finalizer/plugin.d.ts +3 -0
  45. package/dist/bundlers/vite/css-finalizer.d.ts +1 -43
  46. package/dist/bundlers/vite/generate-bundle/bundle-markup-candidates.d.ts +20 -0
  47. package/dist/bundlers/vite/generate-bundle/css-handler-options.d.ts +1 -0
  48. package/dist/bundlers/vite/generate-bundle/finalize/bundle.d.ts +2 -0
  49. package/dist/bundlers/vite/generate-bundle/finalize/root-import-shell.d.ts +69 -0
  50. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +2 -70
  51. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
  52. package/dist/bundlers/vite/generate-bundle/sfc-style-source.d.ts +2 -1
  53. package/dist/bundlers/vite/generate-bundle/source-candidate-source.d.ts +1 -0
  54. package/dist/bundlers/vite/generate-bundle/types.d.ts +5 -0
  55. package/dist/bundlers/vite/generate-bundle-runtime.d.ts +6 -0
  56. package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
  57. package/dist/bundlers/vite/processed-css-assets/cleanup.d.ts +12 -0
  58. package/dist/bundlers/vite/processed-css-assets/collector.d.ts +4 -0
  59. package/dist/bundlers/vite/processed-css-assets/coverage.d.ts +34 -0
  60. package/dist/bundlers/vite/processed-css-assets/injection-plan.d.ts +42 -0
  61. package/dist/bundlers/vite/processed-css-assets/markers-imports.d.ts +89 -0
  62. package/dist/bundlers/vite/processed-css-assets/style-files.d.ts +3 -0
  63. package/dist/bundlers/vite/processed-css-assets.d.ts +4 -71
  64. package/dist/bundlers/vite/rewrite-css-imports.d.ts +1 -0
  65. package/dist/bundlers/vite/serve-css-generation.d.ts +4 -2
  66. package/dist/bundlers/vite/shared/create-framework-plugins-runtime.d.ts +2 -0
  67. package/dist/bundlers/vite/shared/create-framework-plugins.d.ts +5 -4
  68. package/dist/bundlers/vite/source-candidates/collector.d.ts +8 -0
  69. package/dist/bundlers/vite/source-candidates/store.d.ts +2 -0
  70. package/dist/bundlers/vite/source-candidates/types-and-cache.d.ts +69 -0
  71. package/dist/bundlers/vite/source-candidates.d.ts +4 -68
  72. package/dist/bundlers/vite/watch-css-post.d.ts +10 -0
  73. package/dist/bundlers/webpack/BaseUnifiedPlugin/shared.d.ts +6 -0
  74. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/css-source-resolvers.d.ts +1 -0
  75. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/finalize-assets.d.ts +2 -0
  76. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-result.d.ts +3 -0
  77. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/generated-css-task.d.ts +2 -0
  78. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/html-js-tasks.d.ts +5 -0
  79. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/finalize.d.ts +30 -0
  80. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/generated-css.d.ts +8 -0
  81. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/memory-trace.d.ts +78 -0
  82. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/preflight-runtime.d.ts +43 -0
  83. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/resources.d.ts +30 -0
  84. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/runtime-candidates.d.ts +1 -0
  85. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/sources.d.ts +28 -0
  86. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css-markers.d.ts +1 -0
  87. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers/user-css.d.ts +21 -0
  88. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +9 -217
  89. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/processed-css-task.d.ts +4 -0
  90. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-loaders.d.ts +4 -0
  91. package/dist/bundlers/webpack/loaders/runtime-registry.d.ts +6 -0
  92. package/dist/bundlers/webpack/loaders/weapp-tw-css-generation-loader.d.ts +4 -0
  93. package/dist/bundlers/webpack/loaders/weapp-tw-css-import-rewrite-loader.d.ts +3 -0
  94. package/dist/bundlers/webpack/shared/create-framework-plugin/plugin.d.ts +20 -0
  95. package/dist/bundlers/webpack/shared/create-framework-plugin/watch-output.d.ts +13 -0
  96. package/dist/bundlers/webpack/shared/create-framework-plugin.d.ts +3 -21
  97. package/dist/cli.js +14 -18
  98. package/dist/cli.mjs +14 -18
  99. package/dist/{context-VeFq_8vW.js → context-BtLIID4m.js} +3 -3
  100. package/dist/{context-BL8Gy71H.mjs → context-JzwzSX36.mjs} +3 -3
  101. package/dist/core.js +1 -1
  102. package/dist/core.mjs +1 -1
  103. package/dist/css-macro.mjs +1 -1
  104. package/dist/{generator-CEnUsjed.js → generator-B91GhUJQ.js} +636 -505
  105. package/dist/{generator-B59OA64h.mjs → generator-Bv7myuhY.mjs} +557 -432
  106. package/dist/generator.js +1 -1
  107. package/dist/generator.mjs +1 -1
  108. package/dist/{gulp-DUYWxmZC.mjs → gulp-CKSklPlH.mjs} +218 -153
  109. package/dist/{gulp-C1Q3LRzg.js → gulp-Q1wITegn.js} +218 -153
  110. package/dist/gulp.js +1 -1
  111. package/dist/gulp.mjs +1 -1
  112. package/dist/{hmr-timing-C3ed5vCx.mjs → hmr-timing-BXg7nI8N.mjs} +3406 -3145
  113. package/dist/{hmr-timing-BZ5sWIqO.js → hmr-timing-CMPaWn9P.js} +3474 -3147
  114. package/dist/index.js +4 -4
  115. package/dist/index.mjs +4 -4
  116. package/dist/postcss.js +1 -1
  117. package/dist/postcss.mjs +1 -1
  118. package/dist/presets.js +1 -1
  119. package/dist/presets.mjs +1 -1
  120. package/dist/rspack.js +1 -1
  121. package/dist/rspack.mjs +1 -1
  122. package/dist/shared/mpx-plugin-owner.d.ts +2 -0
  123. package/dist/shared/mpx.d.ts +4 -1
  124. package/dist/{source-candidate-scan-signature-R3dzamcm.js → source-candidate-scan-signature-BKZZk_e6.js} +144 -96
  125. package/dist/{source-candidate-scan-signature-D7RWjWsY.mjs → source-candidate-scan-signature-CtK-mB_C.mjs} +127 -60
  126. package/dist/tailwindcss/v4-engine/generator/cache-stats.d.ts +26 -0
  127. package/dist/tailwindcss/v4-engine/generator/engine.d.ts +2 -0
  128. package/dist/tailwindcss/v4-engine/generator/incremental-cache.d.ts +52 -0
  129. package/dist/tailwindcss/v4-engine/generator.d.ts +2 -28
  130. package/dist/{tailwindcss-KBYPJ2DW.js → tailwindcss-B4phC0kB.js} +2 -2
  131. package/dist/{tailwindcss-DPcKMLxL.mjs → tailwindcss-BTcXX8Ka.mjs} +2 -2
  132. package/dist/{transform-D5JUgMpE.mjs → transform-B_KM9sLX.mjs} +47 -5
  133. package/dist/{transform-COFRlmDF.js → transform-CcYptivi.js} +47 -5
  134. package/dist/uni-app-x/component-local-style.d.ts +1 -0
  135. package/dist/uni-app-x/style-asset/style-value.d.ts +1 -1
  136. package/dist/{vite-CBU5NXTX.mjs → vite-BwQWl9ft.mjs} +1269 -878
  137. package/dist/{vite-BNlPdsGM.js → vite-DhVnXvAQ.js} +1314 -923
  138. package/dist/vite.js +1 -1
  139. package/dist/vite.mjs +1 -1
  140. package/dist/weapp-tw-css-generation-loader.js +12 -0
  141. package/dist/weapp-tw-css-import-rewrite-loader-B0tVkJLH.js +10524 -0
  142. package/dist/weapp-tw-css-import-rewrite-loader.js +6 -10255
  143. package/dist/weapp-tw-runtime-classset-loader.js +10 -4
  144. package/dist/{webpack-CZ38fMGC.mjs → webpack-Bo1QrFPf.mjs} +1518 -1079
  145. package/dist/{webpack-Jpe048pQ.js → webpack-kh78iMSS.js} +1519 -1080
  146. package/dist/webpack.js +1 -1
  147. package/dist/webpack.mjs +1 -1
  148. package/package.json +17 -7
  149. package/dist/auto-CrJJc5rK.mjs +0 -13
package/dist/generator.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_generator = require("./generator-CEnUsjed.js");
2
+ const require_generator = require("./generator-B91GhUJQ.js");
3
3
  exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
4
4
  exports.createWeappTailwindcssGeneratorFromRuntime = require_generator.createWeappTailwindcssGeneratorFromRuntime;
5
5
  exports.normalizeWeappTailwindcssGeneratorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions;
@@ -1,2 +1,2 @@
1
- import { bt as transformTailwindV4CssToWeapp, d as resolveTailwindV4SourceFromRuntime, f as resolveTailwindV4SourceFromRuntimeOptions, i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromRuntime, p as resolveTailwindV4SourceOptionsFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source, yt as transformTailwindV4CssByTarget } from "./generator-B59OA64h.mjs";
1
+ import { At as transformTailwindV4CssByTarget, d as resolveTailwindV4SourceFromRuntime, f as resolveTailwindV4SourceFromRuntimeOptions, i as normalizeWeappTailwindcssGeneratorOptions, jt as transformTailwindV4CssToWeapp, n as createWeappTailwindcssGeneratorFromRuntime, p as resolveTailwindV4SourceOptionsFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator, u as resolveTailwindV4Source } from "./generator-Bv7myuhY.mjs";
2
2
  export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromRuntime, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromRuntime, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
@@ -1,8 +1,8 @@
1
- import { Q as normalizeTailwindConfigDirectives, X as hasTailwindRootDirectives, et as normalizeTailwindSourceForGenerator, g as upsertTailwindV4CssSource, gt as prependConfigDirective, h as hasConfiguredTailwindV4CssRoots, vt as getTailwindV4IncrementalGenerateCacheStats } from "./generator-B59OA64h.mjs";
2
- import { l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-DPcKMLxL.mjs";
1
+ import { $ as normalizeTailwindConfigDirectives, Nt as getTailwindV4IncrementalGenerateCacheStats, Z as hasTailwindRootDirectives, _t as prependConfigDirective, g as upsertTailwindV4CssSource, h as hasConfiguredTailwindV4CssRoots, tt as normalizeTailwindSourceForGenerator } from "./generator-Bv7myuhY.mjs";
2
+ import { l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-BTcXX8Ka.mjs";
3
3
  import { y as createDebug } from "./wxml-DdGdeqaH.mjs";
4
- import { l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-BL8Gy71H.mjs";
5
- import { A as processCachedTask, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, O as createCssTokenSourceMap, b as rewriteLocalCssImportRequestsForOutput, n as emitHmrTiming, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, u as generateCssByGenerator, x as splitLocalCssImports } from "./hmr-timing-C3ed5vCx.mjs";
4
+ import { l as createTailwindRuntimeReadyPromise, n as normalizeStyleHandlerMajorVersion, o as shouldSkipJsTransform, t as getCompilerContext, u as ensureRuntimeClassSet } from "./context-JzwzSX36.mjs";
5
+ import { A as processCachedTask, B as rewriteLocalCssImportRequestsForOutput, C as hasBundlerGeneratedCssMarker, D as createCssSourceTraceCacheSignature, E as annotateCssSourceTrace, I as createBundleRuntimeClassSetManager, O as createCssTokenSourceMap, S as createBundlerGeneratedCssMarker, T as stripBundlerGeneratedCssMarkers, V as splitLocalCssImports, i as generateCssByGenerator, j as createSourceCandidateCollector, m as finalizeMiniProgramGeneratorCss, n as emitHmrTiming } from "./hmr-timing-BXg7nI8N.mjs";
6
6
  import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import process from "node:process";
@@ -103,29 +103,7 @@ function createGulpRuntimeSnapshot(runtimeSourcesByFile, changedFiles) {
103
103
  };
104
104
  }
105
105
  //#endregion
106
- //#region src/bundlers/gulp/vinyl-transform.ts
107
- const Transform = stream.Transform;
108
- function createVinylTransform(phase, handler, getTimingDetails) {
109
- return new Transform({
110
- objectMode: true,
111
- async transform(file, _encoding, callback) {
112
- const hmrTimingStartedAt = performance.now();
113
- try {
114
- await handler(file);
115
- emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, {
116
- file: file.relative || path.basename(file.path),
117
- ...getTimingDetails?.(file)
118
- });
119
- callback(null, file);
120
- } catch (error) {
121
- callback(error, file);
122
- }
123
- }
124
- });
125
- }
126
- //#endregion
127
- //#region src/bundlers/gulp/shared/create-native-framework-plugins.ts
128
- const debug = createDebug();
106
+ //#region src/bundlers/gulp/shared/create-native-framework-plugins/cache-state.ts
129
107
  const GULP_RUNTIME_SOURCE_CACHE_MAX = 256;
130
108
  const GULP_PROCESS_CACHE_MAX = 512;
131
109
  function toMb(bytes) {
@@ -186,6 +164,195 @@ function resolveGulpMemoryDebugStats(context) {
186
164
  tailwind: { v4: getTailwindV4IncrementalGenerateCacheStats() }
187
165
  };
188
166
  }
167
+ //#endregion
168
+ //#region src/bundlers/gulp/vinyl-transform.ts
169
+ const Transform = stream.Transform;
170
+ function createVinylTransform(phase, handler, getTimingDetails) {
171
+ return new Transform({
172
+ objectMode: true,
173
+ async transform(file, _encoding, callback) {
174
+ const hmrTimingStartedAt = performance.now();
175
+ try {
176
+ await handler(file);
177
+ emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, {
178
+ file: file.relative || path.basename(file.path),
179
+ ...getTimingDetails?.(file)
180
+ });
181
+ callback(null, file);
182
+ } catch (error) {
183
+ callback(error, file);
184
+ }
185
+ }
186
+ });
187
+ }
188
+ //#endregion
189
+ //#region src/bundlers/gulp/shared/create-native-framework-plugins/file-transforms.ts
190
+ function createGulpFileTransforms(context) {
191
+ const { cache, createRuntimeSetHash, debug, generatedCssPreflightModeByFile, getSourceCandidateGetter, getSourceCandidateSourceGetter, getRuntimeSet, gulpProcessCacheKeys, opts, refreshGulpV4SourceCandidates, refreshRuntimeSet, refreshRuntimeSetForSource, registerAutoCssSource, resolveGulpStyleOutputExtension, resolveGulpTransformTimingDetails, resolveModuleGraphOptions, resolveWxmlHandlerOptions, resolveWxssFileHandlerOptions, resolveWxssUserHandlerOptions, runtimeState } = context;
192
+ const { templateHandler, styleHandler, jsHandler } = opts;
193
+ function createWxssTransform(options, stage) {
194
+ return createVinylTransform(`css:${stage}`, async (file) => {
195
+ if (!file.contents) return;
196
+ const rawSource = file.contents.toString();
197
+ const cssSourceChanged = await registerAutoCssSource(file, rawSource);
198
+ const shouldUseGenerator = runtimeState.tailwindRuntime.majorVersion === 4;
199
+ let gulpSourceCandidateGetter = getSourceCandidateGetter();
200
+ if (shouldUseGenerator) gulpSourceCandidateGetter = await refreshGulpV4SourceCandidates(cssSourceChanged);
201
+ const nextRuntimeSet = await refreshRuntimeSet({
202
+ forceRefresh: cssSourceChanged,
203
+ forceCollect: cssSourceChanged,
204
+ clearCache: cssSourceChanged
205
+ });
206
+ const sourceCandidateSourceGetter = getSourceCandidateSourceGetter();
207
+ const sourceTraceTokenSources = sourceCandidateSourceGetter ? createCssTokenSourceMap(sourceCandidateSourceGetter(void 0), opts) : void 0;
208
+ const sourceTraceSignature = createCssSourceTraceCacheSignature(sourceTraceTokenSources, opts);
209
+ const sourceCandidateSignature = gulpSourceCandidateGetter ? `gulp-source-candidates:1:${[...gulpSourceCandidateGetter(void 0)].sort().join("\n")}` : void 0;
210
+ const styleOutputExtension = resolveGulpStyleOutputExtension(file);
211
+ const outputSignature = styleOutputExtension ? `gulp-output:1:${stage}:${styleOutputExtension}` : `gulp-output:0:${stage}`;
212
+ await processCachedTask({
213
+ cache,
214
+ cacheKey: file.path,
215
+ hash: createRuntimeSetHash(rawSource, nextRuntimeSet, sourceTraceSignature, sourceCandidateSignature, outputSignature),
216
+ applyResult(source) {
217
+ file.contents = Buffer.from(source);
218
+ },
219
+ onCacheHit() {
220
+ debug("css cache hit: %s", file.path);
221
+ },
222
+ async transform() {
223
+ await runtimeState.readyPromise;
224
+ const cssHandlerOptions = resolveWxssFileHandlerOptions(file, rawSource, options);
225
+ const generated = shouldUseGenerator ? await generateCssByGenerator({
226
+ opts,
227
+ runtimeState,
228
+ runtime: nextRuntimeSet,
229
+ rawSource,
230
+ file: file.path,
231
+ cssHandlerOptions,
232
+ cssUserHandlerOptions: resolveWxssUserHandlerOptions(options),
233
+ getSourceCandidatesForEntries: gulpSourceCandidateGetter,
234
+ styleHandler,
235
+ debug,
236
+ deferCssAdaptation: stage === "generate"
237
+ }) : void 0;
238
+ const transformedCss = generated?.css ?? (stage === "generate" ? rawSource : (await styleHandler(rawSource, cssHandlerOptions)).css);
239
+ if (stage === "generate") {
240
+ const preflightMode = generated?.metadata?.preflightMode;
241
+ if (preflightMode) generatedCssPreflightModeByFile.set(file.path, preflightMode);
242
+ else generatedCssPreflightModeByFile.delete(file.path);
243
+ }
244
+ const css = annotateCssSourceTrace(transformedCss, {
245
+ opts,
246
+ tokenSources: sourceTraceTokenSources
247
+ });
248
+ const generatedCss = stage === "generate" && generated ? `${createBundlerGeneratedCssMarker("gulp", file.path)}\n${css}` : css;
249
+ const outputCss = stage === "generate" ? generatedCss : rewriteLocalCssImportRequestsForOutput(generatedCss, { styleOutputExtension });
250
+ debug("css handle: %s", file.path);
251
+ return { result: outputCss };
252
+ }
253
+ });
254
+ rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
255
+ pruneGulpProcessCache(cache, gulpProcessCacheKeys);
256
+ }, () => resolveGulpTransformTimingDetails(`css:${stage}`));
257
+ }
258
+ const generateWxss = (options = {}) => createWxssTransform(options, "generate");
259
+ const transformWxss = (options = {}) => createWxssTransform(options, "transform");
260
+ const adaptWxss = (options = {}) => createVinylTransform("css:adapt", async (file) => {
261
+ if (!file.contents) return;
262
+ const rawSource = file.contents.toString();
263
+ const generatedCss = hasBundlerGeneratedCssMarker(rawSource);
264
+ const source = generatedCss ? stripBundlerGeneratedCssMarkers(rawSource) : rawSource;
265
+ const styleOutputExtension = resolveGulpStyleOutputExtension(file);
266
+ const cssHandlerOptions = resolveWxssFileHandlerOptions(file, source, options);
267
+ const handled = await styleHandler(source, cssHandlerOptions);
268
+ const preflightMode = generatedCssPreflightModeByFile.get(file.path);
269
+ const finalized = generatedCss ? finalizeMiniProgramGeneratorCss(handled.css, "weapp", runtimeState.tailwindRuntime.majorVersion, opts.cssPreflight, {
270
+ injectPreflight: preflightMode?.inject ?? cssHandlerOptions.isMainChunk,
271
+ preservePreflight: preflightMode?.preserve ?? cssHandlerOptions.isMainChunk,
272
+ styleOptions: cssHandlerOptions
273
+ }) : handled.css;
274
+ file.contents = Buffer.from(rewriteLocalCssImportRequestsForOutput(finalized, { styleOutputExtension }));
275
+ debug("css adapt: %s", file.path);
276
+ }, () => resolveGulpTransformTimingDetails("css:adapt"));
277
+ const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
278
+ if (!file.contents) return;
279
+ const filename = path.resolve(file.path);
280
+ const rawSource = file.contents.toString();
281
+ await refreshRuntimeSetForSource(file, rawSource, "js");
282
+ await runtimeState.readyPromise;
283
+ const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
284
+ const handlerOptions = {
285
+ ...options,
286
+ generateMap: false,
287
+ filename,
288
+ moduleGraph,
289
+ babelParserOptions: {
290
+ ...options?.babelParserOptions ?? {},
291
+ sourceFilename: filename
292
+ }
293
+ };
294
+ if (runtimeState.tailwindRuntime.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.tailwindRuntime.majorVersion;
295
+ await processCachedTask({
296
+ cache,
297
+ cacheKey: file.path,
298
+ rawSource,
299
+ applyResult(source) {
300
+ file.contents = Buffer.from(source);
301
+ },
302
+ onCacheHit() {
303
+ debug("js cache hit: %s", file.path);
304
+ },
305
+ async transform() {
306
+ await runtimeState.readyPromise;
307
+ const currentSource = file.contents?.toString() ?? rawSource;
308
+ if (shouldSkipJsTransform(currentSource, {
309
+ ...handlerOptions,
310
+ classNameSet: getRuntimeSet()
311
+ })) return { result: currentSource };
312
+ const { code } = await jsHandler(currentSource, getRuntimeSet(), handlerOptions);
313
+ debug("js handle: %s", file.path);
314
+ return { result: code };
315
+ }
316
+ });
317
+ rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
318
+ pruneGulpProcessCache(cache, gulpProcessCacheKeys);
319
+ }, () => resolveGulpTransformTimingDetails("js"));
320
+ const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
321
+ if (!file.contents) return;
322
+ const rawSource = file.contents.toString();
323
+ await refreshRuntimeSetForSource(file, rawSource, "html");
324
+ await runtimeState.readyPromise;
325
+ await processCachedTask({
326
+ cache,
327
+ cacheKey: file.path,
328
+ rawSource,
329
+ applyResult(source) {
330
+ file.contents = Buffer.from(source);
331
+ },
332
+ onCacheHit() {
333
+ debug("html cache hit: %s", file.path);
334
+ },
335
+ async transform() {
336
+ await runtimeState.readyPromise;
337
+ const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
338
+ debug("html handle: %s", file.path);
339
+ return { result: code };
340
+ }
341
+ });
342
+ rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
343
+ pruneGulpProcessCache(cache, gulpProcessCacheKeys);
344
+ }, () => resolveGulpTransformTimingDetails("html"));
345
+ return {
346
+ adaptWxss,
347
+ generateWxss,
348
+ transformWxss,
349
+ transformWxml,
350
+ transformJs
351
+ };
352
+ }
353
+ //#endregion
354
+ //#region src/bundlers/gulp/shared/create-native-framework-plugins.ts
355
+ const debug = createDebug();
189
356
  /**
190
357
  * @name weapp-tw-gulp
191
358
  * @description native framework 的插件组合实现
@@ -197,7 +364,7 @@ function createNativeGulpPlugins(options = {}) {
197
364
  ...options,
198
365
  __internalDeferMissingCssEntriesWarning: true
199
366
  });
200
- const { templateHandler, styleHandler, jsHandler, cache } = opts;
367
+ const { cache } = opts;
201
368
  const initialTailwindRuntime = opts.tailwindRuntime;
202
369
  const refreshTailwindcssRuntime = opts.refreshTailwindcssRuntime;
203
370
  const readyPromise = createTailwindRuntimeReadyPromise(initialTailwindRuntime);
@@ -217,6 +384,7 @@ function createNativeGulpPlugins(options = {}) {
217
384
  let runtimeSetDirty = false;
218
385
  const runtimeSourceHashByFile = /* @__PURE__ */ new Map();
219
386
  const runtimeSourcesByFile = /* @__PURE__ */ new Map();
387
+ const generatedCssPreflightModeByFile = /* @__PURE__ */ new Map();
220
388
  let cachedGulpSourceCandidateSignature;
221
389
  const gulpProcessCacheKeys = /* @__PURE__ */ new Set();
222
390
  const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? createBundleRuntimeClassSetManager();
@@ -414,131 +582,28 @@ function createNativeGulpPlugins(options = {}) {
414
582
  runtimeSourcesByFile
415
583
  }) };
416
584
  }
417
- const transformWxss = (options = {}) => createVinylTransform("css", async (file) => {
418
- if (!file.contents) return;
419
- const rawSource = file.contents.toString();
420
- const cssSourceChanged = await registerAutoCssSource(file, rawSource);
421
- const shouldUseGenerator = runtimeState.tailwindRuntime.majorVersion === 4;
422
- let gulpSourceCandidateGetter;
423
- if (shouldUseGenerator) gulpSourceCandidateGetter = await refreshGulpV4SourceCandidates(cssSourceChanged);
424
- const nextRuntimeSet = await refreshRuntimeSet({
425
- forceRefresh: cssSourceChanged,
426
- forceCollect: cssSourceChanged,
427
- clearCache: cssSourceChanged
428
- });
429
- const sourceTraceTokenSources = cachedGulpSourceCandidateSourceGetter ? createCssTokenSourceMap(cachedGulpSourceCandidateSourceGetter(void 0), opts) : void 0;
430
- const sourceTraceSignature = createCssSourceTraceCacheSignature(sourceTraceTokenSources, opts);
431
- const sourceCandidateSignature = cachedGulpSourceCandidateGetter ? `gulp-source-candidates:1:${[...cachedGulpSourceCandidateGetter(void 0)].sort().join("\n")}` : void 0;
432
- const styleOutputExtension = resolveGulpStyleOutputExtension(file);
433
- const outputSignature = styleOutputExtension ? `gulp-output:1:${styleOutputExtension}` : "gulp-output:0";
434
- await processCachedTask({
435
- cache,
436
- cacheKey: file.path,
437
- hash: createRuntimeSetHash(rawSource, nextRuntimeSet, sourceTraceSignature, sourceCandidateSignature, outputSignature),
438
- applyResult(source) {
439
- file.contents = Buffer.from(source);
440
- },
441
- onCacheHit() {
442
- debug("css cache hit: %s", file.path);
443
- },
444
- async transform() {
445
- await runtimeState.readyPromise;
446
- const cssHandlerOptions = resolveWxssFileHandlerOptions(file, rawSource, options);
447
- const outputCss = rewriteLocalCssImportRequestsForOutput(annotateCssSourceTrace((shouldUseGenerator ? await generateCssByGenerator({
448
- opts,
449
- runtimeState,
450
- runtime: nextRuntimeSet,
451
- rawSource,
452
- file: file.path,
453
- cssHandlerOptions,
454
- cssUserHandlerOptions: resolveWxssUserHandlerOptions(options),
455
- getSourceCandidatesForEntries: gulpSourceCandidateGetter,
456
- styleHandler,
457
- debug
458
- }) : void 0)?.css ?? (await styleHandler(rawSource, cssHandlerOptions)).css, {
459
- opts,
460
- tokenSources: sourceTraceTokenSources
461
- }), { styleOutputExtension });
462
- debug("css handle: %s", file.path);
463
- return { result: outputCss };
464
- }
465
- });
466
- rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
467
- pruneGulpProcessCache(cache, gulpProcessCacheKeys);
468
- }, () => resolveGulpTransformTimingDetails("css"));
469
- const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
470
- if (!file.contents) return;
471
- const filename = path.resolve(file.path);
472
- const rawSource = file.contents.toString();
473
- await refreshRuntimeSetForSource(file, rawSource, "js");
474
- await runtimeState.readyPromise;
475
- const moduleGraph = resolveModuleGraphOptions(options.moduleGraph);
476
- const handlerOptions = {
477
- ...options,
478
- generateMap: false,
479
- filename,
480
- moduleGraph,
481
- babelParserOptions: {
482
- ...options?.babelParserOptions ?? {},
483
- sourceFilename: filename
484
- }
485
- };
486
- if (runtimeState.tailwindRuntime.majorVersion !== void 0) handlerOptions.tailwindcssMajorVersion = runtimeState.tailwindRuntime.majorVersion;
487
- await processCachedTask({
488
- cache,
489
- cacheKey: file.path,
490
- rawSource,
491
- applyResult(source) {
492
- file.contents = Buffer.from(source);
493
- },
494
- onCacheHit() {
495
- debug("js cache hit: %s", file.path);
496
- },
497
- async transform() {
498
- await runtimeState.readyPromise;
499
- const currentSource = file.contents?.toString() ?? rawSource;
500
- if (shouldSkipJsTransform(currentSource, {
501
- ...handlerOptions,
502
- classNameSet: runtimeSet
503
- })) return { result: currentSource };
504
- const { code } = await jsHandler(currentSource, runtimeSet, handlerOptions);
505
- debug("js handle: %s", file.path);
506
- return { result: code };
507
- }
508
- });
509
- rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
510
- pruneGulpProcessCache(cache, gulpProcessCacheKeys);
511
- }, () => resolveGulpTransformTimingDetails("js"));
512
- const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
513
- if (!file.contents) return;
514
- const rawSource = file.contents.toString();
515
- await refreshRuntimeSetForSource(file, rawSource, "html");
516
- await runtimeState.readyPromise;
517
- await processCachedTask({
518
- cache,
519
- cacheKey: file.path,
520
- rawSource,
521
- applyResult(source) {
522
- file.contents = Buffer.from(source);
523
- },
524
- onCacheHit() {
525
- debug("html cache hit: %s", file.path);
526
- },
527
- async transform() {
528
- await runtimeState.readyPromise;
529
- const code = await templateHandler(rawSource, resolveWxmlHandlerOptions(options));
530
- debug("html handle: %s", file.path);
531
- return { result: code };
532
- }
533
- });
534
- rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
535
- pruneGulpProcessCache(cache, gulpProcessCacheKeys);
536
- }, () => resolveGulpTransformTimingDetails("html"));
537
- return {
538
- transformWxss,
539
- transformWxml,
540
- transformJs
541
- };
585
+ return createGulpFileTransforms({
586
+ cache,
587
+ createRuntimeSetHash,
588
+ debug,
589
+ generatedCssPreflightModeByFile,
590
+ getSourceCandidateGetter: () => cachedGulpSourceCandidateGetter,
591
+ getSourceCandidateSourceGetter: () => cachedGulpSourceCandidateSourceGetter,
592
+ getRuntimeSet: () => runtimeSet,
593
+ gulpProcessCacheKeys,
594
+ opts,
595
+ refreshGulpV4SourceCandidates,
596
+ refreshRuntimeSet,
597
+ refreshRuntimeSetForSource,
598
+ registerAutoCssSource,
599
+ resolveGulpStyleOutputExtension,
600
+ resolveGulpTransformTimingDetails,
601
+ resolveModuleGraphOptions,
602
+ resolveWxmlHandlerOptions,
603
+ resolveWxssFileHandlerOptions,
604
+ resolveWxssUserHandlerOptions,
605
+ runtimeState
606
+ });
542
607
  }
543
608
  //#endregion
544
609
  //#region src/bundlers/gulp/frameworks/native/index.ts