weapp-tailwindcss 5.0.10 → 5.0.12

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 (57) hide show
  1. package/dist/{bundle-state-CXzPknlT.mjs → bundle-state-BxMNKjBV.mjs} +2 -34
  2. package/dist/{bundle-state-BwtEqxvU.js → bundle-state-DU2ATDhw.js} +1 -39
  3. package/dist/bundlers/gulp/vinyl-transform.d.ts +1 -1
  4. package/dist/bundlers/shared/hmr-timing.d.ts +1 -0
  5. package/dist/bundlers/vite/generate-bundle/css-output.d.ts +2 -1
  6. package/dist/bundlers/vite/generate-bundle/remembered-css.d.ts +1 -1
  7. package/dist/bundlers/vite/generate-bundle/types.d.ts +5 -0
  8. package/dist/bundlers/vite/generate-bundle.d.ts +1 -1
  9. package/dist/bundlers/vite/source-candidates.d.ts +6 -0
  10. package/dist/bundlers/vite/weapp-vite-config.d.ts +1 -0
  11. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/helpers.d.ts +10 -8
  12. package/dist/cache/index.d.ts +4 -0
  13. package/dist/cli.js +7 -0
  14. package/dist/cli.mjs +7 -0
  15. package/dist/core.d.ts +7 -0
  16. package/dist/core.js +8 -5
  17. package/dist/core.mjs +8 -5
  18. package/dist/{generator-ChgOWNOj.js → generator-Cb1Zp3Al.js} +1 -1
  19. package/dist/{generator-h2XRiJ9-.mjs → generator-mvNFUvns.mjs} +1 -1
  20. package/dist/generator.js +2 -2
  21. package/dist/generator.mjs +2 -2
  22. package/dist/{gulp-Be88jhoY.mjs → gulp-BfZpaYSQ.mjs} +97 -11
  23. package/dist/{gulp-CHtZF-oT.js → gulp-CxGZU0-v.js} +97 -11
  24. package/dist/gulp.js +1 -1
  25. package/dist/gulp.mjs +1 -1
  26. package/dist/{hmr-timing-BkivBZvN.js → hmr-timing-DFR51wgo.js} +61 -9
  27. package/dist/{hmr-timing-Ct5w4hdM.mjs → hmr-timing-DNjF8bWA.mjs} +49 -10
  28. package/dist/index.js +4 -4
  29. package/dist/index.mjs +4 -4
  30. package/dist/postcss.js +9 -10
  31. package/dist/postcss.mjs +7 -5
  32. package/dist/{precheck-CY9oaH49.js → precheck-30zNPRlI.js} +13 -3
  33. package/dist/{precheck-BpHxsWRd.mjs → precheck-CsFr1q2l.mjs} +14 -4
  34. package/dist/presets.js +2 -2
  35. package/dist/presets.mjs +2 -2
  36. package/dist/tailwindcss/source-scan.d.ts +1 -0
  37. package/dist/tailwindcss/v3-engine/generator.d.ts +17 -0
  38. package/dist/tailwindcss/v3-engine/index.d.ts +1 -1
  39. package/dist/tailwindcss/v3-engine/types.d.ts +1 -0
  40. package/dist/tailwindcss/v4-engine/generator.d.ts +19 -0
  41. package/dist/tailwindcss/v4-engine/index.d.ts +1 -1
  42. package/dist/{tailwindcss-Bfy2egdX.mjs → tailwindcss-CK84uGBp.mjs} +1 -1
  43. package/dist/{tailwindcss-DbbAKAZP.js → tailwindcss-Clpkz1oR.js} +1 -1
  44. package/dist/{transform-Cd634UZV.js → transform-CaVEBOuR.js} +1 -1
  45. package/dist/{transform-r5evL6Hn.mjs → transform-Cju08-aJ.mjs} +1 -1
  46. package/dist/{v3-engine-D0yA9ZkF.js → v3-engine-CQE5JJNZ.js} +142 -29
  47. package/dist/{v3-engine-CFkP6dWF.mjs → v3-engine-DKBaKWGL.mjs} +131 -30
  48. package/dist/{vite-Bh-BNp5g.js → vite-BBGOjh9e.js} +301 -56
  49. package/dist/{vite-BM_iIFmS.mjs → vite-CS5DE-HD.mjs} +300 -55
  50. package/dist/vite.js +1 -1
  51. package/dist/vite.mjs +1 -1
  52. package/dist/weapp-tw-css-import-rewrite-loader.js +130 -31
  53. package/dist/{webpack-CJAOcYEO.js → webpack-DIWrcpRo.js} +93 -12
  54. package/dist/{webpack-DPdrcC2X.mjs → webpack-SPcri_D8.mjs} +92 -11
  55. package/dist/webpack.js +1 -1
  56. package/dist/webpack.mjs +1 -1
  57. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { h as traverse, m as babelParse, o as Parser } from "./precheck-BpHxsWRd.mjs";
1
+ import { h as traverse, m as babelParse, o as Parser } from "./precheck-CsFr1q2l.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
@@ -147,38 +147,6 @@ function parseBundlerGeneratedCssMarkerBlocks(source) {
147
147
  return blocks;
148
148
  }
149
149
  //#endregion
150
- //#region src/bundlers/shared/run-tasks.ts
151
- async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
152
- if (factories.length === 0) return [];
153
- const results = Array.from({ length: factories.length });
154
- const executing = /* @__PURE__ */ new Set();
155
- let cursor = 0;
156
- const effectiveLimit = Math.max(1, limit);
157
- const scheduleNext = () => {
158
- if (cursor >= factories.length) return;
159
- const currentIndex = cursor++;
160
- const factory = factories[currentIndex];
161
- if (!factory) return;
162
- const wrapped = Promise.resolve(factory()).then((value) => {
163
- results[currentIndex] = value;
164
- }).finally(() => {
165
- executing.delete(wrapped);
166
- });
167
- executing.add(wrapped);
168
- };
169
- while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
170
- while (cursor < factories.length) {
171
- await Promise.race(executing);
172
- scheduleNext();
173
- }
174
- await Promise.all(executing);
175
- return results;
176
- }
177
- function pushConcurrentTaskFactories(queue, factories, limit) {
178
- if (factories.length === 0) return;
179
- queue.push(runWithConcurrency(factories, limit).then(() => void 0));
180
- }
181
- //#endregion
182
150
  //#region src/bundlers/vite/bundle-entries.ts
183
151
  function readOutputEntry(entry) {
184
152
  if (entry.output.type === "chunk") return entry.output.code;
@@ -431,4 +399,4 @@ function updateBundleBuildState(state, snapshot, linkedByEntry, options = {}) {
431
399
  state.dependentsByLinkedFile = invertLinkedByEntry(state.linkedByEntry);
432
400
  }
433
401
  //#endregion
434
- export { toAbsoluteOutputPath as C, resolveOutputSpecifier as S, normalizePath as _, applyLinkedResults as a, stripRequestQuery as b, createBundlerGeneratedCssMarker as c, stripBundlerGeneratedCssMarkers as d, resolvePackageDir as f, isCSSRequest as g, formatPostcssSourceMap as h, createRuntimeAffectingSourceSignature as i, hasBundlerGeneratedCssMarker as l, cleanUrl as m, createBundleBuildState as n, createBundleModuleGraphOptions as o, resolvePluginDisabledState as p, updateBundleBuildState as r, pushConcurrentTaskFactories as s, buildBundleSnapshot as t, parseBundlerGeneratedCssMarkerBlocks as u, slash as v, normalizeOutputPathKey as x, isSourceStyleRequest as y };
402
+ export { toAbsoluteOutputPath as S, slash as _, applyLinkedResults as a, normalizeOutputPathKey as b, hasBundlerGeneratedCssMarker as c, resolvePackageDir as d, resolvePluginDisabledState as f, normalizePath as g, isCSSRequest as h, createRuntimeAffectingSourceSignature as i, parseBundlerGeneratedCssMarkerBlocks as l, formatPostcssSourceMap as m, createBundleBuildState as n, createBundleModuleGraphOptions as o, cleanUrl as p, updateBundleBuildState as r, createBundlerGeneratedCssMarker as s, buildBundleSnapshot as t, stripBundlerGeneratedCssMarkers as u, isSourceStyleRequest as v, resolveOutputSpecifier as x, stripRequestQuery as y };
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-emK7D4bc.js");
2
- const require_precheck = require("./precheck-CY9oaH49.js");
2
+ const require_precheck = require("./precheck-30zNPRlI.js");
3
3
  let node_module = require("node:module");
4
4
  let node_path = require("node:path");
5
5
  node_path = require_chunk.__toESM(node_path);
@@ -150,38 +150,6 @@ function parseBundlerGeneratedCssMarkerBlocks(source) {
150
150
  return blocks;
151
151
  }
152
152
  //#endregion
153
- //#region src/bundlers/shared/run-tasks.ts
154
- async function runWithConcurrency(factories, limit = Math.min(4, Math.max(1, factories.length))) {
155
- if (factories.length === 0) return [];
156
- const results = Array.from({ length: factories.length });
157
- const executing = /* @__PURE__ */ new Set();
158
- let cursor = 0;
159
- const effectiveLimit = Math.max(1, limit);
160
- const scheduleNext = () => {
161
- if (cursor >= factories.length) return;
162
- const currentIndex = cursor++;
163
- const factory = factories[currentIndex];
164
- if (!factory) return;
165
- const wrapped = Promise.resolve(factory()).then((value) => {
166
- results[currentIndex] = value;
167
- }).finally(() => {
168
- executing.delete(wrapped);
169
- });
170
- executing.add(wrapped);
171
- };
172
- while (cursor < factories.length && executing.size < effectiveLimit) scheduleNext();
173
- while (cursor < factories.length) {
174
- await Promise.race(executing);
175
- scheduleNext();
176
- }
177
- await Promise.all(executing);
178
- return results;
179
- }
180
- function pushConcurrentTaskFactories(queue, factories, limit) {
181
- if (factories.length === 0) return;
182
- queue.push(runWithConcurrency(factories, limit).then(() => void 0));
183
- }
184
- //#endregion
185
153
  //#region src/bundlers/vite/bundle-entries.ts
186
154
  function readOutputEntry(entry) {
187
155
  if (entry.output.type === "chunk") return entry.output.code;
@@ -512,12 +480,6 @@ Object.defineProperty(exports, "parseBundlerGeneratedCssMarkerBlocks", {
512
480
  return parseBundlerGeneratedCssMarkerBlocks;
513
481
  }
514
482
  });
515
- Object.defineProperty(exports, "pushConcurrentTaskFactories", {
516
- enumerable: true,
517
- get: function() {
518
- return pushConcurrentTaskFactories;
519
- }
520
- });
521
483
  Object.defineProperty(exports, "resolveOutputSpecifier", {
522
484
  enumerable: true,
523
485
  get: function() {
@@ -1,3 +1,3 @@
1
1
  import type File from 'vinyl';
2
2
  import stream from 'node:stream';
3
- export declare function createVinylTransform(phase: string, handler: (file: File) => Promise<void>): stream.Transform;
3
+ export declare function createVinylTransform(phase: string, handler: (file: File) => Promise<void>, getTimingDetails?: ((file: File) => Record<string, unknown> | undefined) | undefined): stream.Transform;
@@ -3,6 +3,7 @@ export interface HmrTimingDetails {
3
3
  file?: string;
4
4
  hooks?: Record<string, HmrTimingHookSummary>;
5
5
  metric?: 'hook' | 'total';
6
+ memoryDebug?: Record<string, unknown> | undefined;
6
7
  wallMs?: number;
7
8
  }
8
9
  export interface HmrTimingHookSummary {
@@ -3,8 +3,9 @@ export declare const SOURCE_STYLE_OUTPUT_EXT_RE: RegExp;
3
3
  export declare const CSS_SOURCE_OUTPUT_EXT_RE: RegExp;
4
4
  export declare const MINI_PROGRAM_STYLE_OUTPUT_EXT_RE: RegExp;
5
5
  export declare function resolveReplayCssOutputFile(rootDir: string, file: string): string;
6
+ export declare function resolveReplayCssOutputFileFromSourceRoot(rootDir: string, file: string, sourceRoot: string | undefined): string;
6
7
  export declare function resolveViteCssOutputFile(file: string, opts: InternalUserDefinedOptions, isWebGeneratorTarget: boolean, preserveCssExtension?: boolean): string;
7
- export declare function resolveViteCssPipelineOutputFile(file: string, _opts: Pick<InternalUserDefinedOptions, 'cssMatcher'>, rootDir: string, isWebGeneratorTarget?: boolean, preserveCssExtension?: boolean): string;
8
+ export declare function resolveViteCssPipelineOutputFile(file: string, _opts: Pick<InternalUserDefinedOptions, 'cssMatcher'>, rootDir: string, isWebGeneratorTarget?: boolean, preserveCssExtension?: boolean, sourceRoot?: string | undefined): string;
8
9
  export declare function canProcessViteSourceStyleAsCss(source: string, file: string): boolean;
9
10
  export declare function normalizeCssSourceForCompare(css: string): string;
10
11
  export declare function stripStyleFileExtension(file: string): string;
@@ -5,7 +5,7 @@ export declare function createRememberedCssRuntimeSignature(cssRuntimeSignature:
5
5
  export declare function resolveRememberedCssSourceForTest(sources: Iterable<[string, RememberedCssSource]> | undefined, outputFile: string, file: string, originalSource: OutputAsset, outputRoot: string, sourceRoot: string | undefined): RememberedCssSource | undefined;
6
6
  export declare function findRememberedCssSources(sources: Iterable<[string, RememberedCssSource]> | undefined, outputFile: string, file: string, originalSource: OutputAsset, outputRoot: string, sourceRoot: string | undefined): RememberedCssSource[];
7
7
  export declare function mergeRememberedCssSources(sources: RememberedCssSource[], outputFile: string): RememberedCssSource | undefined;
8
- export declare function collectRememberedCssReplayGroups(sources: Iterable<[string, RememberedCssSource]> | undefined, opts: Pick<InternalUserDefinedOptions, 'cssMatcher'>, rootDir: string, isWebGeneratorTarget: boolean, preserveCssExtension: boolean): Map<string, {
8
+ export declare function collectRememberedCssReplayGroups(sources: Iterable<[string, RememberedCssSource]> | undefined, opts: Pick<InternalUserDefinedOptions, 'cssMatcher'>, rootDir: string, isWebGeneratorTarget: boolean, preserveCssExtension: boolean, sourceRoot?: string | undefined): Map<string, {
9
9
  key: string;
10
10
  remembered: RememberedCssSource;
11
11
  }[]>;
@@ -48,6 +48,11 @@ export interface GenerateBundleContext {
48
48
  setRememberedCssSignature?: (file: string, cssRuntimeSignature: string) => void;
49
49
  getKnownSfcSource?: (file: string) => string | undefined;
50
50
  recordGeneratorCandidates?: (candidates: Set<string>) => void;
51
+ pruneViteCssCaches?: (options: {
52
+ activeFiles: Set<string>;
53
+ activeKnownSfcFiles?: Set<string> | undefined;
54
+ }) => void;
55
+ getViteCssCacheStats?: () => Record<string, unknown>;
51
56
  hmrTimingRecorder?: HmrTimingRecorder;
52
57
  }
53
58
  export interface RememberedCssSource {
@@ -1,6 +1,6 @@
1
1
  import type { OutputAsset, OutputChunk } from 'rollup';
2
2
  import type { GenerateBundleContext, GenerateBundleThis } from './generate-bundle/types';
3
- export { resolveReplayCssOutputFile, resolveViteCssPipelineOutputFile } from './generate-bundle/css-output';
3
+ export { resolveReplayCssOutputFile, resolveReplayCssOutputFileFromSourceRoot, resolveViteCssPipelineOutputFile } from './generate-bundle/css-output';
4
4
  export { resolveRememberedCssSourceForTest } from './generate-bundle/remembered-css';
5
5
  export type { GenerateBundleContext, GenerateBundleThis, RememberedCssSource } from './generate-bundle/types';
6
6
  export declare function createGenerateBundleHook(context: GenerateBundleContext): (this: GenerateBundleThis, _opt: unknown, bundle: Record<string, OutputAsset | OutputChunk>) => Promise<void>;
@@ -42,3 +42,9 @@ export interface SourceCandidateCollectorOptions {
42
42
  }
43
43
  export declare function isSourceCandidateRequest(id: string): boolean;
44
44
  export declare function createSourceCandidateCollector(options?: SourceCandidateCollectorOptions): SourceCandidateCollector;
45
+ export declare function getSourceCandidateContentCacheStatsForTest(): {
46
+ max: number;
47
+ size: number;
48
+ keys: string[];
49
+ };
50
+ export declare function clearSourceCandidateContentCacheForTest(): void;
@@ -0,0 +1 @@
1
+ export declare function resolveWeappViteSourceRoot(config: unknown): string | undefined;
@@ -18,6 +18,14 @@ export interface SetupWebpackV5ProcessAssetsHookOptions {
18
18
  debug: (format: string, ...args: unknown[]) => void;
19
19
  }
20
20
  export type WebpackSourceLike = string | WebpackSources.Source;
21
+ interface WebpackAssetCompilationLike {
22
+ getAsset: (file: string) => {
23
+ source: {
24
+ source: () => unknown;
25
+ };
26
+ } | undefined;
27
+ updateAsset: Compiler['webpack']['Compilation']['prototype']['updateAsset'];
28
+ }
21
29
  export declare function createWebpackSnapshotAssets(assets: Record<string, {
22
30
  source: () => unknown;
23
31
  }>): {
@@ -29,14 +37,7 @@ export declare function createWebpackSnapshotAssets(assets: Record<string, {
29
37
  };
30
38
  export declare function stringifyWebpackSource(source: unknown): string;
31
39
  export declare function createWebpackAssetUpdater(options: {
32
- compilation: {
33
- getAsset: (file: string) => {
34
- source: {
35
- source: () => unknown;
36
- };
37
- } | undefined;
38
- updateAsset: (file: string, source: WebpackSourceLike) => void;
39
- };
40
+ compilation: WebpackAssetCompilationLike;
40
41
  ConcatSource: new (source: string) => WebpackSources.Source;
41
42
  onUpdate: (file: string, previousSource: string, nextSource: string) => void;
42
43
  debug: (format: string, ...args: unknown[]) => void;
@@ -46,3 +47,4 @@ export declare function createWebpackAssetUpdater(options: {
46
47
  notifyUpdate?: boolean;
47
48
  }) => boolean;
48
49
  };
50
+ export {};
@@ -31,6 +31,10 @@ export interface ICreateCacheReturnType {
31
31
  set: <V extends CacheValue = sources.Source>(key: string, value: V) => LRUCache<string, CacheValue>;
32
32
  has: (key: string) => boolean;
33
33
  calcHashValueChanged: (key: HashMapKey, hash: string) => ICreateCacheReturnType;
34
+ prune?: (options: {
35
+ cacheKeys?: Iterable<string> | undefined;
36
+ hashKeys?: Iterable<HashMapKey> | undefined;
37
+ }) => void;
34
38
  process: <T extends CacheValue>(options: CacheProcessOptions<T>) => Promise<T>;
35
39
  }
36
40
  declare function createCache(options?: boolean): ICreateCacheReturnType;
package/dist/cli.js CHANGED
@@ -507,6 +507,12 @@ new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.rep
507
507
  isMainChunk: true,
508
508
  majorVersion: 4
509
509
  });
510
+ //#endregion
511
+ //#region src/tailwindcss/v4-engine/generator.ts
512
+ const INCREMENTAL_GENERATE_CACHE_MAX$1 = 8;
513
+ const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
514
+ new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX$1 });
515
+ new lru_cache.LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
510
516
  (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
511
517
  (0, _weapp_tailwindcss_postcss.createStyleHandler)({
512
518
  cssChildCombinatorReplaceValue: ["view", "text"],
@@ -514,6 +520,7 @@ new RegExp(`\\.(?:${FULL_SOURCE_SCAN_EXTENSIONS.map((extension) => extension.rep
514
520
  isMainChunk: true,
515
521
  majorVersion: 3
516
522
  });
523
+ new lru_cache.LRUCache({ max: 8 });
517
524
  typeof tailwindcss_patch.generateTailwindV3RawStyle === "function" && tailwindcss_patch.generateTailwindV3RawStyle;
518
525
  [
519
526
  "@tailwind base;",
package/dist/cli.mjs CHANGED
@@ -478,6 +478,12 @@ createStyleHandler({
478
478
  isMainChunk: true,
479
479
  majorVersion: 4
480
480
  });
481
+ //#endregion
482
+ //#region src/tailwindcss/v4-engine/generator.ts
483
+ const INCREMENTAL_GENERATE_CACHE_MAX$1 = 8;
484
+ const INCREMENTAL_GENERATE_TASK_CACHE_MAX = 32;
485
+ new LRUCache({ max: INCREMENTAL_GENERATE_CACHE_MAX$1 });
486
+ new LRUCache({ max: INCREMENTAL_GENERATE_TASK_CACHE_MAX });
481
487
  createRequire(import.meta.url);
482
488
  createStyleHandler({
483
489
  cssChildCombinatorReplaceValue: ["view", "text"],
@@ -485,6 +491,7 @@ createStyleHandler({
485
491
  isMainChunk: true,
486
492
  majorVersion: 3
487
493
  });
494
+ new LRUCache({ max: 8 });
488
495
  typeof tailwindcssPatch.generateTailwindV3RawStyle === "function" && tailwindcssPatch.generateTailwindV3RawStyle;
489
496
  [
490
497
  "@tailwind base;",
package/dist/core.d.ts CHANGED
@@ -2,7 +2,14 @@ import type { CreateJsHandlerOptions, IStyleHandlerOptions, ITemplateHandlerOpti
2
2
  type RuntimeJsTransformOptions = {
3
3
  runtimeSet?: Set<string>;
4
4
  } & CreateJsHandlerOptions;
5
+ export interface GetRuntimeSetOptions {
6
+ forceRefresh?: boolean | undefined;
7
+ forceCollect?: boolean | undefined;
8
+ clearCache?: boolean | undefined;
9
+ allowEmpty?: boolean | undefined;
10
+ }
5
11
  export declare function createContext(options?: UserDefinedOptions): {
12
+ getRuntimeSet: (options?: GetRuntimeSetOptions) => Promise<Set<string>>;
6
13
  transformWxss: (rawCss: string, options?: Partial<IStyleHandlerOptions>) => Promise<import("postcss").Result<import("postcss").Document | import("postcss").Root>>;
7
14
  transformWxml: (rawWxml: string, options?: ITemplateHandlerOptions) => Promise<string>;
8
15
  transformJs: (rawJs: string, options?: RuntimeJsTransformOptions) => Promise<import("./types").JsHandlerResult>;
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_precheck = require("./precheck-CY9oaH49.js");
2
+ const require_precheck = require("./precheck-30zNPRlI.js");
3
3
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
4
4
  //#region src/core.ts
5
5
  const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
@@ -106,12 +106,14 @@ function createContext(options = {}) {
106
106
  async function transformWxss(rawCss, options) {
107
107
  await runtimeState.readyPromise;
108
108
  const result = await styleHandler(rawCss, resolveTransformWxssOptions(options));
109
- runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState, {
110
- forceRefresh: true,
111
- forceCollect: true
112
- });
109
+ runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState);
113
110
  return result;
114
111
  }
112
+ async function getRuntimeSet(options) {
113
+ await runtimeState.readyPromise;
114
+ runtimeSet = await require_precheck.ensureRuntimeClassSet(runtimeState, options);
115
+ return runtimeSet;
116
+ }
115
117
  async function transformJs(rawJs, options) {
116
118
  await runtimeState.readyPromise;
117
119
  if (options?.runtimeSet) runtimeSet = options.runtimeSet;
@@ -126,6 +128,7 @@ function createContext(options = {}) {
126
128
  return templateHandler(rawWxml, resolveTransformWxmlOptions(options));
127
129
  }
128
130
  return {
131
+ getRuntimeSet,
129
132
  transformWxss,
130
133
  transformWxml,
131
134
  transformJs
package/dist/core.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-BpHxsWRd.mjs";
1
+ import { n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-CsFr1q2l.mjs";
2
2
  import { defuOverrideArray } from "@weapp-tailwindcss/shared";
3
3
  //#region src/core.ts
4
4
  const DEFAULT_MAIN_CHUNK_STYLE_OPTIONS = Object.freeze({ isMainChunk: true });
@@ -105,12 +105,14 @@ function createContext(options = {}) {
105
105
  async function transformWxss(rawCss, options) {
106
106
  await runtimeState.readyPromise;
107
107
  const result = await styleHandler(rawCss, resolveTransformWxssOptions(options));
108
- runtimeSet = await ensureRuntimeClassSet(runtimeState, {
109
- forceRefresh: true,
110
- forceCollect: true
111
- });
108
+ runtimeSet = await ensureRuntimeClassSet(runtimeState);
112
109
  return result;
113
110
  }
111
+ async function getRuntimeSet(options) {
112
+ await runtimeState.readyPromise;
113
+ runtimeSet = await ensureRuntimeClassSet(runtimeState, options);
114
+ return runtimeSet;
115
+ }
114
116
  async function transformJs(rawJs, options) {
115
117
  await runtimeState.readyPromise;
116
118
  if (options?.runtimeSet) runtimeSet = options.runtimeSet;
@@ -125,6 +127,7 @@ function createContext(options = {}) {
125
127
  return templateHandler(rawWxml, resolveTransformWxmlOptions(options));
126
128
  }
127
129
  return {
130
+ getRuntimeSet,
128
131
  transformWxss,
129
132
  transformWxml,
130
133
  transformJs
@@ -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-CQE5JJNZ.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 { S as resolveTailwindV4SourceFromPatcher, i as createTailwindV3Engine, n as resolveTailwindV3SourceFromPatcher, q as createTailwindV4Engine } from "./v3-engine-DKBaKWGL.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-CQE5JJNZ.js");
3
+ const require_generator = require("./generator-Cb1Zp3Al.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 resolveTailwindV4SourceOptionsFromPatcher, S as resolveTailwindV4SourceFromPatcher, X as transformTailwindV4CssToWeapp, Y as transformTailwindV4CssByTarget, b as resolveTailwindV4Source, n as resolveTailwindV3SourceFromPatcher, o as transformTailwindV3CssByTarget, r as resolveTailwindV3SourceOptionsFromPatcher, s as transformTailwindV3CssToWeapp, t as resolveTailwindV3Source, x as resolveTailwindV4SourceFromPatchOptions } from "./v3-engine-DKBaKWGL.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromPatcher, r as resolveTailwindSourceFromPatcher, t as createWeappTailwindcssGenerator } from "./generator-mvNFUvns.mjs";
3
3
  export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromPatcher, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromPatcher, resolveTailwindV3Source, resolveTailwindV3SourceFromPatcher, resolveTailwindV3SourceOptionsFromPatcher, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveTailwindV4SourceFromPatcher, resolveTailwindV4SourceOptionsFromPatcher, transformTailwindV3CssByTarget, transformTailwindV3CssToWeapp, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
@@ -1,7 +1,7 @@
1
- import { D as normalizeTailwindConfigDirectives, T as hasTailwindRootDirectives, k as normalizeTailwindSourceForGenerator, l as getRuntimeClassSetSignature, m as resolveViteSourceScanEntries, rt as createDebug } from "./v3-engine-CFkP6dWF.mjs";
2
- import { n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-BpHxsWRd.mjs";
3
- import { c as hasConfiguredTailwindV4CssRoots, l as upsertTailwindV4CssSource } from "./tailwindcss-Bfy2egdX.mjs";
4
- import { a as createTailwindV3DefaultExtractor, g as createCssTokenSourceMap, h as createCssSourceTraceCacheSignature, m as annotateCssSourceTrace, n as emitHmrTiming, o as createBundleRuntimeClassSetManager, r as createSourceCandidateCollector, s as generateCssByGenerator, v as processCachedTask } from "./hmr-timing-Ct5w4hdM.mjs";
1
+ import { A as normalizeTailwindSourceForGenerator, E as hasTailwindRootDirectives, J as getTailwindV4IncrementalGenerateCacheStats, O as normalizeTailwindConfigDirectives, a as getTailwindV3IncrementalGenerateCacheStats, at as createDebug, h as resolveViteSourceScanEntries, u as getRuntimeClassSetSignature } from "./v3-engine-DKBaKWGL.mjs";
2
+ import { n as getCompilerContext, t as shouldSkipJsTransform, v as createTailwindRuntimeReadyPromise, y as ensureRuntimeClassSet } from "./precheck-CsFr1q2l.mjs";
3
+ import { c as hasConfiguredTailwindV4CssRoots, l as upsertTailwindV4CssSource } from "./tailwindcss-CK84uGBp.mjs";
4
+ import { _ as createCssSourceTraceCacheSignature, a as createTailwindV3DefaultExtractor, b as processCachedTask, g as annotateCssSourceTrace, n as emitHmrTiming, o as createBundleRuntimeClassSetManager, r as createSourceCandidateCollector, s as generateCssByGenerator, v as createCssTokenSourceMap } from "./hmr-timing-DNjF8bWA.mjs";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
@@ -53,7 +53,7 @@ function createGulpModuleGraphOptions(opts) {
53
53
  },
54
54
  filter(id) {
55
55
  const relative = path.relative(process.cwd(), id);
56
- return opts.jsMatcher(relative) || opts.wxsMatcher(relative);
56
+ return opts.jsMatcher?.(relative) === true || opts.wxsMatcher?.(relative) === true;
57
57
  }
58
58
  };
59
59
  }
@@ -104,14 +104,17 @@ function createGulpRuntimeSnapshot(runtimeSourcesByFile, changedFiles) {
104
104
  //#endregion
105
105
  //#region src/bundlers/gulp/vinyl-transform.ts
106
106
  const Transform = stream.Transform;
107
- function createVinylTransform(phase, handler) {
107
+ function createVinylTransform(phase, handler, getTimingDetails) {
108
108
  return new Transform({
109
109
  objectMode: true,
110
110
  async transform(file, _encoding, callback) {
111
111
  const hmrTimingStartedAt = performance.now();
112
112
  try {
113
113
  await handler(file);
114
- emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, { file: file.relative || path.basename(file.path) });
114
+ emitHmrTiming("gulp", phase, performance.now() - hmrTimingStartedAt, {
115
+ file: file.relative || path.basename(file.path),
116
+ ...getTimingDetails?.(file)
117
+ });
115
118
  callback(null, file);
116
119
  } catch (error) {
117
120
  callback(error, file);
@@ -122,6 +125,69 @@ function createVinylTransform(phase, handler) {
122
125
  //#endregion
123
126
  //#region src/bundlers/gulp/index.ts
124
127
  const debug = createDebug();
128
+ const GULP_RUNTIME_SOURCE_CACHE_MAX = 256;
129
+ const GULP_PROCESS_CACHE_MAX = 512;
130
+ function toMb(bytes) {
131
+ return Math.round(bytes / 1024 / 1024);
132
+ }
133
+ function touchMapEntry(map, key, value) {
134
+ map.delete(key);
135
+ map.set(key, value);
136
+ }
137
+ function pruneGulpRuntimeSourceCaches(sourceHashByFile, sourcesByFile) {
138
+ while (sourcesByFile.size > GULP_RUNTIME_SOURCE_CACHE_MAX) {
139
+ const oldestKey = sourcesByFile.keys().next().value;
140
+ if (typeof oldestKey !== "string") break;
141
+ sourcesByFile.delete(oldestKey);
142
+ sourceHashByFile.delete(oldestKey);
143
+ }
144
+ }
145
+ function rememberGulpProcessCacheKey(cacheKeys, key) {
146
+ cacheKeys.delete(key);
147
+ cacheKeys.add(key);
148
+ while (cacheKeys.size > GULP_PROCESS_CACHE_MAX) {
149
+ const oldestKey = cacheKeys.keys().next().value;
150
+ if (typeof oldestKey !== "string") break;
151
+ cacheKeys.delete(oldestKey);
152
+ }
153
+ }
154
+ function pruneGulpProcessCache(cache, cacheKeys) {
155
+ cache.prune?.({
156
+ cacheKeys,
157
+ hashKeys: cacheKeys
158
+ });
159
+ }
160
+ function resolveGulpMemoryDebugStats(context) {
161
+ if (process.env["WEAPP_TW_HMR_MEMORY_DEBUG"] !== "1") return;
162
+ const memory = process.memoryUsage();
163
+ return {
164
+ phase: context.phase,
165
+ process: {
166
+ rssMb: toMb(memory.rss),
167
+ heapTotalMb: toMb(memory.heapTotal),
168
+ heapUsedMb: toMb(memory.heapUsed),
169
+ externalMb: toMb(memory.external),
170
+ arrayBuffersMb: toMb(memory.arrayBuffers)
171
+ },
172
+ runtime: {
173
+ runtimeSet: context.runtimeSet.size,
174
+ runtimeSourceHashByFile: context.runtimeSourceHashByFile.size,
175
+ runtimeSourcesByFile: context.runtimeSourcesByFile.size,
176
+ maxRuntimeSources: GULP_RUNTIME_SOURCE_CACHE_MAX
177
+ },
178
+ processCache: {
179
+ instance: context.cache.instance.size,
180
+ hashMap: context.cache.hashMap.size,
181
+ activeCacheKeys: context.gulpProcessCacheKeys.size,
182
+ maxCacheKeys: GULP_PROCESS_CACHE_MAX
183
+ },
184
+ gulpOptions: { defaultStyleHandlerOptions: context.defaultStyleHandlerOptionsCache.size },
185
+ tailwind: {
186
+ v3: getTailwindV3IncrementalGenerateCacheStats(),
187
+ v4: getTailwindV4IncrementalGenerateCacheStats()
188
+ }
189
+ };
190
+ }
125
191
  /**
126
192
  * @name weapp-tw-gulp
127
193
  * @description gulp版本weapp-tw插件
@@ -153,6 +219,7 @@ function createPlugins(options = {}) {
153
219
  const runtimeSourcesByFile = /* @__PURE__ */ new Map();
154
220
  let cachedGulpSourceCandidates;
155
221
  let cachedGulpSourceCandidateSignature;
222
+ const gulpProcessCacheKeys = /* @__PURE__ */ new Set();
156
223
  const sourceCandidateExtractor = initialTwPatcher.majorVersion === 3 ? createTailwindV3DefaultExtractor() : void 0;
157
224
  const bundleRuntimeClassSetManager = options.__internalGulpRuntimeClassSetManager ?? createBundleRuntimeClassSetManager();
158
225
  function invalidateGulpSourceCandidates() {
@@ -185,11 +252,13 @@ function createPlugins(options = {}) {
185
252
  const filename = path.resolve(file.path);
186
253
  const hash = cache.computeHash(rawSource);
187
254
  const changed = runtimeSourceHashByFile.get(filename) !== hash;
255
+ runtimeSourceHashByFile.delete(filename);
188
256
  runtimeSourceHashByFile.set(filename, hash);
189
- runtimeSourcesByFile.set(filename, {
257
+ touchMapEntry(runtimeSourcesByFile, filename, {
190
258
  source: rawSource,
191
259
  type
192
260
  });
261
+ pruneGulpRuntimeSourceCaches(runtimeSourceHashByFile, runtimeSourcesByFile);
193
262
  if (changed && runtimeState.twPatcher.majorVersion === 4) invalidateGulpSourceCandidates();
194
263
  if (!changed && runtimeSetInitialized) return runtimeSet;
195
264
  if (runtimeState.twPatcher.majorVersion === 4 && !runtimeSetDirty) try {
@@ -336,6 +405,17 @@ function createPlugins(options = {}) {
336
405
  ...options
337
406
  };
338
407
  }
408
+ function resolveGulpTransformTimingDetails(phase) {
409
+ return { memoryDebug: resolveGulpMemoryDebugStats({
410
+ cache,
411
+ defaultStyleHandlerOptionsCache,
412
+ gulpProcessCacheKeys,
413
+ phase,
414
+ runtimeSet,
415
+ runtimeSourceHashByFile,
416
+ runtimeSourcesByFile
417
+ }) };
418
+ }
339
419
  const transformWxss = (options = {}) => createVinylTransform("css", async (file) => {
340
420
  if (!file.contents) return;
341
421
  const rawSource = file.contents.toString();
@@ -389,7 +469,9 @@ function createPlugins(options = {}) {
389
469
  return { result: css };
390
470
  }
391
471
  });
392
- });
472
+ rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
473
+ pruneGulpProcessCache(cache, gulpProcessCacheKeys);
474
+ }, () => resolveGulpTransformTimingDetails("css"));
393
475
  const transformJs = (options = {}) => createVinylTransform("js", async (file) => {
394
476
  if (!file.contents) return;
395
477
  const filename = path.resolve(file.path);
@@ -429,7 +511,9 @@ function createPlugins(options = {}) {
429
511
  return { result: code };
430
512
  }
431
513
  });
432
- });
514
+ rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
515
+ pruneGulpProcessCache(cache, gulpProcessCacheKeys);
516
+ }, () => resolveGulpTransformTimingDetails("js"));
433
517
  const transformWxml = (options = {}) => createVinylTransform("html", async (file) => {
434
518
  if (!file.contents) return;
435
519
  const rawSource = file.contents.toString();
@@ -452,7 +536,9 @@ function createPlugins(options = {}) {
452
536
  return { result: code };
453
537
  }
454
538
  });
455
- });
539
+ rememberGulpProcessCacheKey(gulpProcessCacheKeys, file.path);
540
+ pruneGulpProcessCache(cache, gulpProcessCacheKeys);
541
+ }, () => resolveGulpTransformTimingDetails("html"));
456
542
  return {
457
543
  transformWxss,
458
544
  transformWxml,