weapp-tailwindcss 5.1.4 → 5.1.6

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 (69) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/dist/bundlers/shared/generator-css/generation-helpers.d.ts +8 -2
  4. package/dist/bundlers/shared/generator-css/source-resolver/metadata.d.ts +5 -1
  5. package/dist/bundlers/shared/generator-css/types.d.ts +1 -0
  6. package/dist/bundlers/shared/generator-css/user-css.d.ts +4 -1
  7. package/dist/bundlers/vite/generate-bundle/finalize.d.ts +1 -0
  8. package/dist/bundlers/vite/generate-bundle/remembered-css-replay.d.ts +1 -0
  9. package/dist/bundlers/vite/generate-bundle/tailwind-v4-css-source.d.ts +6 -3
  10. package/dist/bundlers/vite/hot-css-modules.d.ts +1 -0
  11. package/dist/bundlers/vite/processed-css-assets.d.ts +7 -0
  12. package/dist/bundlers/vite/source-scan/css-entries.d.ts +1 -0
  13. package/dist/bundlers/webpack/BaseUnifiedPlugin/v5-assets/pipeline-helpers.d.ts +2 -1
  14. package/dist/cli.js +18 -3
  15. package/dist/cli.mjs +16 -1
  16. package/dist/{context-Bkpmt3ja.mjs → context-3GGqW9vw.mjs} +20 -5
  17. package/dist/{context-DCVMkTRj.js → context-BCSk_YnL.js} +23 -8
  18. package/dist/core.js +1 -1
  19. package/dist/core.mjs +1 -1
  20. package/dist/css-macro/index.d.ts +2 -1
  21. package/dist/{defaults-BhE26nSw.mjs → defaults-9B6aMyZb.mjs} +2 -2
  22. package/dist/{defaults-DQhgnnn-.js → defaults-nsf4VNMX.js} +2 -2
  23. package/dist/defaults.d.ts +1 -1
  24. package/dist/defaults.js +1 -1
  25. package/dist/defaults.mjs +1 -1
  26. package/dist/{generator-24-HgU9F.mjs → generator-CoT5vu9w.mjs} +2 -2
  27. package/dist/{generator-CilgHtxb.js → generator-CqWzj2Z1.js} +2 -2
  28. package/dist/generator.js +2 -2
  29. package/dist/generator.mjs +2 -2
  30. package/dist/{gulp-0RsqkF_d.mjs → gulp-Bss4wJ8t.mjs} +4 -4
  31. package/dist/{gulp-Bogfnoki.js → gulp-hXE1U4Cu.js} +4 -4
  32. package/dist/gulp.js +1 -1
  33. package/dist/gulp.mjs +1 -1
  34. package/dist/{hmr-timing-BRNaz8Od.mjs → hmr-timing-Cfu-4Bnf.mjs} +229 -576
  35. package/dist/{hmr-timing-BV6nFPoT.js → hmr-timing-Df4203aI.js} +253 -630
  36. package/dist/index.js +4 -4
  37. package/dist/index.mjs +4 -4
  38. package/dist/js/js-string-escape.d.ts +1 -0
  39. package/dist/postcss.js +2 -2
  40. package/dist/postcss.mjs +2 -2
  41. package/dist/presets.js +6 -3
  42. package/dist/presets.mjs +6 -3
  43. package/dist/rspack.js +1 -1
  44. package/dist/rspack.mjs +1 -1
  45. package/dist/runtime-branch/generator-target-env.d.ts +1 -0
  46. package/dist/{source-candidate-scan-signature-CaDT0gkj.js → source-candidate-scan-signature-5Uk6U72B.js} +168 -5
  47. package/dist/{source-candidate-scan-signature-BB1hvW68.mjs → source-candidate-scan-signature-BbCmW975.mjs} +157 -6
  48. package/dist/style-injector/internal.d.ts +7 -0
  49. package/dist/style-injector/options.d.ts +25 -0
  50. package/dist/tailwindcss/v4/preflight.d.ts +4 -0
  51. package/dist/{tailwindcss-D0JF0fuZ.mjs → tailwindcss-Bjr3aphG.mjs} +62 -15
  52. package/dist/{tailwindcss-D2xs4OEu.js → tailwindcss-DYJ3HZD2.js} +67 -14
  53. package/dist/{transform-BP86eSZp.mjs → transform--155BmeJ.mjs} +1 -1
  54. package/dist/{transform-CXCQ28Tc.js → transform-B6_y_yCB.js} +1 -1
  55. package/dist/typedoc.export.d.ts +1 -0
  56. package/dist/types/index.d.ts +2 -1
  57. package/dist/types/user-defined-options/general.d.ts +2 -0
  58. package/dist/{v4-engine-CKtsdKxK.js → v4-engine-C9cmNlP8.js} +610 -3
  59. package/dist/{v4-engine-BuuYDXt1.mjs → v4-engine-DRQaCFMm.mjs} +529 -6
  60. package/dist/{vite-BYgT1ir9.js → vite-Baw9qNrc.js} +652 -140
  61. package/dist/{vite-B1SlBmqO.mjs → vite-PdxjaqhO.mjs} +653 -141
  62. package/dist/vite.js +1 -1
  63. package/dist/vite.mjs +1 -1
  64. package/dist/weapp-tw-css-import-rewrite-loader.js +2981 -2752
  65. package/dist/{webpack-Bg6pefpb.mjs → webpack-BffTDmod.mjs} +69 -26
  66. package/dist/{webpack-khSwkXP5.js → webpack-C9u7mfGE.js} +74 -31
  67. package/dist/webpack.js +1 -1
  68. package/dist/webpack.mjs +1 -1
  69. package/package.json +16 -5
package/README.en.md CHANGED
@@ -8,4 +8,4 @@ This is the core package that brings Tailwind CSS to mini program ecosystems, ha
8
8
 
9
9
  For setup guides, configuration references, and framework examples, see the [official weapp-tailwindcss documentation](https://tw.icebreaker.top).
10
10
 
11
- For Tailwind CSS 4 projects, the entry CSS must still be imported by the application. Configure `cssEntries` when the plugin needs an explicit hint, but do not treat it as a replacement for importing the CSS entry into the build graph.
11
+ For Tailwind CSS 4 projects, the entry CSS must still be imported by the application. Configure `cssEntries` explicitly with absolute paths resolved from the project root, but do not treat it as a replacement for importing the CSS entry into the build graph.
package/README.md CHANGED
@@ -8,4 +8,4 @@
8
8
 
9
9
  更多接入方式、配置说明和框架示例见 [weapp-tailwindcss 官方文档](https://tw.icebreaker.top)。
10
10
 
11
- Tailwind CSS 4 项目中,入口 CSS 需要同时满足两点:在项目里被实际引入,并通过 `cssEntries` 显式传给插件用于稳定识别。`cssEntries` 不是替代 import 的开关。
11
+ Tailwind CSS 4 项目中,入口 CSS 需要同时满足两点:在项目里被实际引入,并通过 `cssEntries` 显式传给插件用于稳定识别。`cssEntries` 应使用项目根目录解析出的绝对路径;它不是替代 import 的开关。
@@ -6,13 +6,19 @@ import type { InternalUserDefinedOptions } from '../../../types';
6
6
  export declare function hasMiniProgramTailwindV4PreflightReset(css: string): boolean;
7
7
  export declare function finalizeMiniProgramGeneratorCss(css: string, target: string, _majorVersion: number | undefined, cssPreflight: InternalUserDefinedOptions['cssPreflight'], options?: {
8
8
  injectPreflight?: boolean;
9
+ preservePreflight?: boolean;
9
10
  styleOptions?: Partial<IStyleHandlerOptions> | undefined;
10
11
  }): string;
11
- export declare function shouldInjectMiniProgramPreflightForGeneratorCss(opts: InternalUserDefinedOptions, options: {
12
+ export declare function resolveMiniProgramPreflightModeForGeneratorCss(opts: InternalUserDefinedOptions, options: {
12
13
  cssHandlerOptions: IStyleHandlerOptions;
13
14
  isolateCurrentCssCandidates: boolean;
14
15
  localImports?: string | undefined;
15
- }): boolean;
16
+ primaryCssSource?: boolean | undefined;
17
+ explicitCssSource?: boolean | undefined;
18
+ }): {
19
+ inject: boolean;
20
+ preserve: boolean;
21
+ };
16
22
  export declare function mergeScopedRuntimeWithCurrentRuntime(scopedRuntime: Set<string>, runtime: Set<string>, options: {
17
23
  currentCssCandidates?: string[] | undefined;
18
24
  cssHandlerOptions: IStyleHandlerOptions;
@@ -2,8 +2,12 @@ import type { SourceSideCssEntrySource } from '../source-files';
2
2
  import type { TailwindResolvedSource } from '../../../../generator';
3
3
  import type { TailwindSourceEntry } from '../../../../tailwindcss/source-scan';
4
4
  export interface GeneratorSourceMetadata {
5
+ cssEntryIndex?: number | undefined;
6
+ cssSourceIndex?: number | undefined;
7
+ includesPreflight?: boolean | undefined;
5
8
  isolateCssSource?: boolean | undefined;
6
9
  matchedCssSourceFile?: string | undefined;
10
+ primaryCssSource?: boolean | undefined;
7
11
  sourceEntries?: TailwindSourceEntry[] | undefined;
8
12
  sourceBase?: string | undefined;
9
13
  sourceCss?: string | undefined;
@@ -12,4 +16,4 @@ export type GeneratorResolvedSource = TailwindResolvedSource & {
12
16
  __weappTailwindcssMeta?: GeneratorSourceMetadata | undefined;
13
17
  };
14
18
  export declare function withGeneratorSourceMetadata(source: TailwindResolvedSource, metadata: GeneratorSourceMetadata): GeneratorResolvedSource;
15
- export declare function withMatchedSourceSideMetadata(source: TailwindResolvedSource, resolvedEntrySource: SourceSideCssEntrySource): import("@/generator").TailwindV4ResolvedSource;
19
+ export declare function withMatchedSourceSideMetadata(source: TailwindResolvedSource, resolvedEntrySource: SourceSideCssEntrySource, metadata?: GeneratorSourceMetadata): import("@/generator").TailwindV4ResolvedSource;
@@ -18,6 +18,7 @@ export interface GenerateCssByGeneratorOptions {
18
18
  sourceCandidates?: Set<string> | undefined;
19
19
  styleHandler: InternalUserDefinedOptions['styleHandler'];
20
20
  debug: (format: string, ...args: unknown[]) => void;
21
+ generatorPlatform?: string | undefined;
21
22
  userRawSource?: string | undefined;
22
23
  userRawSourceProcessed?: boolean | undefined;
23
24
  forceGenerator?: boolean | undefined;
@@ -15,7 +15,10 @@ export declare function extractGeneratedCssForUserLayerSelectors(css: string, us
15
15
  layer: string;
16
16
  rest: string;
17
17
  };
18
- export declare function filterApplyOnlyGeneratedCss(css: string, source: string): string;
18
+ export declare function normalizeEmptyTailwindCustomVariants(css: string): string;
19
+ export declare function filterApplyOnlyGeneratedCss(css: string, source: string, options?: {
20
+ preserveVariables?: boolean | undefined;
21
+ }): string;
19
22
  export declare function shouldFilterApplyOnlyGeneratedCss(_majorVersion: number | undefined, target: string, source: string, options: {
20
23
  hasGeneratedCss: boolean;
21
24
  hasGeneratedMarkers: boolean;
@@ -54,6 +54,7 @@ interface FinalizeGenerateBundleOptions {
54
54
  tasks: Promise<void>[];
55
55
  timingDetails: Record<string, number>;
56
56
  transformRuntime: Set<string>;
57
+ transformWebTargetCss?: ((css: string, file: string) => string) | undefined;
57
58
  useIncrementalMode: boolean;
58
59
  }
59
60
  export declare function normalizeTaroRootImportShellAssets(bundle: Record<string, OutputAsset | OutputChunk>, options: Pick<GenerateBundleContext['opts'], 'appType' | 'cssMatcher'> & {
@@ -20,6 +20,7 @@ interface ProcessRememberedCssReplayOptions {
20
20
  defaultStyleOutputExtension: string;
21
21
  emitOrReplayCssAsset: (fileName: string, source: string) => OutputAsset | undefined;
22
22
  generatorRuntime: Set<string>;
23
+ generatorPlatform?: string | undefined;
23
24
  getCssHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('./css-handler-options').createCssHandlerOptionsCache>['getCssHandlerOptions']>;
24
25
  getCssUserHandlerOptions: (file: string) => ReturnType<ReturnType<typeof import('./css-handler-options').createCssHandlerOptionsCache>['getCssUserHandlerOptions']>;
25
26
  getRememberedCssSignature?: ((file: string) => string | undefined) | undefined;
@@ -2,8 +2,11 @@ export interface TailwindV4GenerationCssSourceEntry {
2
2
  file: string;
3
3
  source: string;
4
4
  }
5
+ export interface TailwindV4GenerationCssSourceSelectionOptions {
6
+ cwd?: string | undefined;
7
+ outputRoot?: string | undefined;
8
+ projectRoot?: string | undefined;
9
+ }
5
10
  export declare function collectTailwindV4SourceFingerprint(source: string): Set<string>;
6
11
  export declare function scoreConfiguredTailwindV4SourceForRawSource(rawSource: string | undefined, entrySource: string): number;
7
- export declare function resolveSubpackageRootForFile(file: string | undefined, subpackageRoots: Set<string> | undefined): string | undefined;
8
- export declare function isSameSubpackageScope(outputFile: string, sourceFile: string | undefined, subpackageRoots: Set<string> | undefined): boolean;
9
- export declare function selectTailwindV4GenerationCssSourceForOutput<T extends TailwindV4GenerationCssSourceEntry>(outputFile: string, entries: T[], rawSource?: string, subpackageRoots?: Set<string> | undefined): T | undefined;
12
+ export declare function selectTailwindV4GenerationCssSourceForOutput<T extends TailwindV4GenerationCssSourceEntry>(outputFile: string, entries: T[], rawSource?: string, options?: TailwindV4GenerationCssSourceSelectionOptions): T | undefined;
@@ -1,5 +1,6 @@
1
1
  import type { HmrContext, ModuleNode } from 'vite';
2
2
  export declare function resolveHotTailwindCssModules(ctx: HmrContext, tailwindRootCssModuleIds: Set<string>): ModuleNode[];
3
+ export declare function resolveHotSourceModules(ctx: HmrContext): ModuleNode[];
3
4
  export declare function hasSelfAcceptingNonStyleHotModule(modules: ModuleNode[]): boolean;
4
5
  export declare function sendSupplementalCssHotUpdates(ctx: HmrContext, cssModules: ModuleNode[]): void;
5
6
  export declare function sendFullReloadForUnresolvedHotUpdate(ctx: HmrContext): void;
@@ -42,12 +42,19 @@ interface InjectViteProcessedCssAssetOptions {
42
42
  injectIntoMain?: boolean | undefined;
43
43
  outputFile?: string | undefined;
44
44
  }) => boolean) | undefined;
45
+ transformCss?: ((css: string, file: string) => string) | undefined;
45
46
  debug?: ((format: string, ...args: unknown[]) => void) | undefined;
46
47
  onUpdate?: ((file: string, original: string, generated: string) => void) | undefined;
47
48
  }
49
+ export declare function removeDuplicateUnlinkedRootCssAssetsReferencedByHtml(bundle: OutputBundle, options?: {
50
+ debug?: ((format: string, ...args: unknown[]) => void) | undefined;
51
+ }): number;
52
+ export declare function removeScopedTailwindPreflightCss(css: string): string;
53
+ export declare function removeCssCoveredByRootStyleBundleSources(bundle: OutputBundle, file: string, css: string): string;
48
54
  export declare function removeCssCoveredByRootStyleAssets(bundle: OutputBundle, options: {
49
55
  cssMatcher: (file: string) => boolean;
50
56
  debug?: ((format: string, ...args: unknown[]) => void) | undefined;
57
+ includeTailwindGeneratedCssAssets?: boolean | undefined;
51
58
  isViteProcessedCssAsset?: CssAssetMarkerMatcher | undefined;
52
59
  onUpdate?: ((file: string, original: string, generated: string) => void) | undefined;
53
60
  recordCssAssetResult?: CssAssetResultRecorder | undefined;
@@ -4,6 +4,7 @@ import type { UserDefinedOptions } from '../../../types';
4
4
  export interface ResolvedTailwindV4CssEntries {
5
5
  entries: TailwindSourceEntry[];
6
6
  explicit: boolean;
7
+ includesPreflight: boolean;
7
8
  inlineCandidates: TailwindInlineSourceCandidates;
8
9
  dependencies: string[];
9
10
  }
@@ -140,7 +140,7 @@ export declare function resolveWebpackMemoryDebugStats(context: {
140
140
  };
141
141
  };
142
142
  } | undefined;
143
- export declare function shouldInjectWebpackCssTracePreflight(appType: SetupWebpackV5ProcessAssetsHookOptions['appType'], cssHandlerOptions: Pick<WebpackCssHandlerOptions, 'isMainChunk'>): boolean;
143
+ export declare function shouldInjectWebpackCssTracePreflight(_appType: SetupWebpackV5ProcessAssetsHookOptions['appType'], cssHandlerOptions: Pick<WebpackCssHandlerOptions, 'isMainChunk' | 'sourceOptions'>): boolean;
144
144
  export declare function finalizeMiniProgramUserCssAssetSource(source: string, compilerOptions: SetupWebpackV5ProcessAssetsHookOptions['options'], isWebGeneratorTarget: boolean, options?: {
145
145
  cssPreflight?: boolean | undefined;
146
146
  }): string;
@@ -183,6 +183,7 @@ export declare function finalizeTracedWebpackCssAsset(css: string, cssHandlerOpt
183
183
  isWebGeneratorTarget: boolean;
184
184
  }): string;
185
185
  export declare function finalizeWebpackCssAssetSource(source: string, compilerOptions: SetupWebpackV5ProcessAssetsHookOptions['options'], isWebGeneratorTarget: boolean, options?: {
186
+ cssPreflight?: boolean | undefined;
186
187
  generatedCss?: boolean;
187
188
  }): string;
188
189
  export declare function collectWebpackJsRuntimeCandidatesFromAssets(options: {
package/dist/cli.js CHANGED
@@ -47,7 +47,6 @@ _babel_traverse = __toESM(_babel_traverse);
47
47
  let _babel_parser = require("@babel/parser");
48
48
  let magic_string = require("magic-string");
49
49
  magic_string = __toESM(magic_string);
50
- let _ast_core_escape = require("@ast-core/escape");
51
50
  require("@babel/types");
52
51
  //#region src/js/babel/cache-options.ts
53
52
  const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
@@ -485,6 +484,22 @@ function isClassContextLiteralPath(path) {
485
484
  return false;
486
485
  }
487
486
  //#endregion
487
+ //#region src/js/js-string-escape.ts
488
+ function jsStringEscape(value) {
489
+ return String(value).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
490
+ switch (character) {
491
+ case "\"":
492
+ case "'":
493
+ case "\\": return `\\${character}`;
494
+ case "\n": return "\\n";
495
+ case "\r": return "\\r";
496
+ case "\u2028": return "\\u2028";
497
+ case "\u2029": return "\\u2029";
498
+ default: return character;
499
+ }
500
+ });
501
+ }
502
+ //#endregion
488
503
  //#region src/js/replacement-cache.ts
489
504
  const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
490
505
  const defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -644,7 +659,7 @@ function replaceHandleValue(path, options) {
644
659
  return {
645
660
  start,
646
661
  end,
647
- value: needEscaped ? (0, _ast_core_escape.jsStringEscape)(transformed) : transformed,
662
+ value: needEscaped ? jsStringEscape(transformed) : transformed,
648
663
  path
649
664
  };
650
665
  }
@@ -756,7 +771,7 @@ function createEvalReplacementToken(path, updated) {
756
771
  return {
757
772
  start,
758
773
  end,
759
- value: path.isStringLiteral() ? (0, _ast_core_escape.jsStringEscape)(updated) : updated,
774
+ value: path.isStringLiteral() ? jsStringEscape(updated) : updated,
760
775
  path
761
776
  };
762
777
  }
package/dist/cli.mjs CHANGED
@@ -18,7 +18,6 @@ import "tailwindcss-config";
18
18
  import _babelTraverse from "@babel/traverse";
19
19
  import { parse } from "@babel/parser";
20
20
  import MagicString from "magic-string";
21
- import { jsStringEscape } from "@ast-core/escape";
22
21
  import "@babel/types";
23
22
  //#region src/js/babel/cache-options.ts
24
23
  const DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH = 5e4;
@@ -456,6 +455,22 @@ function isClassContextLiteralPath(path) {
456
455
  return false;
457
456
  }
458
457
  //#endregion
458
+ //#region src/js/js-string-escape.ts
459
+ function jsStringEscape(value) {
460
+ return String(value).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
461
+ switch (character) {
462
+ case "\"":
463
+ case "'":
464
+ case "\\": return `\\${character}`;
465
+ case "\n": return "\\n";
466
+ case "\r": return "\\r";
467
+ case "\u2028": return "\\u2028";
468
+ case "\u2029": return "\\u2029";
469
+ default: return character;
470
+ }
471
+ });
472
+ }
473
+ //#endregion
459
474
  //#region src/js/replacement-cache.ts
460
475
  const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
461
476
  const defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -1,9 +1,9 @@
1
1
  import { resolveMpxPlatform } from "./framework.mjs";
2
- import { W as createTailwindV4Engine$1, ct as omitUndefined, dt as resolveValidTailwindV4Candidates$1, n as resolveTailwindV4SourceFromRuntime, ot as resolveCssMacroTailwindV4Source, ut as loadTailwindV4DesignSystem, y as resolveBooleanObjectOption } from "./v4-engine-BuuYDXt1.mjs";
3
- import { a as resolveGeneratorRuntimeBranch, i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-24-HgU9F.mjs";
2
+ import { At as resolveValidTailwindV4Candidates$1, Et as omitUndefined, ct as createTailwindV4Engine$1, kt as loadTailwindV4DesignSystem, n as resolveTailwindV4SourceFromRuntime, wt as resolveCssMacroTailwindV4Source, y as resolveBooleanObjectOption } from "./v4-engine-DRQaCFMm.mjs";
3
+ import { a as resolveGeneratorRuntimeBranch, i as normalizeWeappTailwindcssGeneratorOptions } from "./generator-CoT5vu9w.mjs";
4
4
  import { i as isMap, n as defuOverrideArray } from "./utils-DodxWHGz.mjs";
5
- import { a as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, i as resolveDefaultCssPreflight, o as HARD_PARSE_CACHE_MAX_ENTRIES, r as getDefaultOptions } from "./defaults-BhE26nSw.mjs";
6
- import { c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, i as resolveUniAppXOptions, o as applyV4CssCalcDefaults, s as warnMissingCssEntries, t as createTailwindcssRuntimeFromContext, u as getRuntimeClassSetSignatureWithSources } from "./tailwindcss-D0JF0fuZ.mjs";
5
+ import { a as DEFAULT_PARSE_CACHE_MAX_SOURCE_LENGTH, i as resolveDefaultCssPreflight, o as HARD_PARSE_CACHE_MAX_ENTRIES, r as getDefaultOptions } from "./defaults-9B6aMyZb.mjs";
6
+ import { c as getRuntimeClassSetCacheEntry, d as invalidateRuntimeClassSet, i as resolveUniAppXOptions, o as applyV4CssCalcDefaults, s as warnMissingCssEntries, t as createTailwindcssRuntimeFromContext, u as getRuntimeClassSetSignatureWithSources } from "./tailwindcss-Bjr3aphG.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import path from "node:path";
9
9
  import process from "node:process";
@@ -19,7 +19,6 @@ import _createDebug from "debug";
19
19
  import _babelTraverse from "@babel/traverse";
20
20
  import { parse, parseExpression } from "@babel/parser";
21
21
  import MagicString from "magic-string";
22
- import { jsStringEscape } from "@ast-core/escape";
23
22
  import * as t from "@babel/types";
24
23
  //#region src/cache/index.ts
25
24
  function isProcessResult(value) {
@@ -951,6 +950,22 @@ function isClassContextLiteralPath(path) {
951
950
  return false;
952
951
  }
953
952
  //#endregion
953
+ //#region src/js/js-string-escape.ts
954
+ function jsStringEscape(value) {
955
+ return String(value).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
956
+ switch (character) {
957
+ case "\"":
958
+ case "'":
959
+ case "\\": return `\\${character}`;
960
+ case "\n": return "\\n";
961
+ case "\r": return "\\r";
962
+ case "\u2028": return "\\u2028";
963
+ case "\u2029": return "\\u2029";
964
+ default: return character;
965
+ }
966
+ });
967
+ }
968
+ //#endregion
954
969
  //#region src/js/replacement-cache.ts
955
970
  const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
956
971
  const defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -1,10 +1,10 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
2
2
  const require_framework = require("./framework.js");
3
- const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
4
- const require_generator = require("./generator-CilgHtxb.js");
3
+ const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
4
+ const require_generator = require("./generator-CqWzj2Z1.js");
5
5
  require("./utils-D3h8j7Mk.js");
6
- const require_defaults = require("./defaults-DQhgnnn-.js");
7
- const require_tailwindcss = require("./tailwindcss-D2xs4OEu.js");
6
+ const require_defaults = require("./defaults-nsf4VNMX.js");
7
+ const require_tailwindcss = require("./tailwindcss-DYJ3HZD2.js");
8
8
  let node_path = require("node:path");
9
9
  node_path = require_rolldown_runtime.__toESM(node_path);
10
10
  let node_process = require("node:process");
@@ -25,7 +25,6 @@ _babel_traverse = require_rolldown_runtime.__toESM(_babel_traverse);
25
25
  let _babel_parser = require("@babel/parser");
26
26
  let magic_string = require("magic-string");
27
27
  magic_string = require_rolldown_runtime.__toESM(magic_string);
28
- let _ast_core_escape = require("@ast-core/escape");
29
28
  let _babel_types = require("@babel/types");
30
29
  _babel_types = require_rolldown_runtime.__toESM(_babel_types);
31
30
  let _weapp_tailwindcss_shared = require("@weapp-tailwindcss/shared");
@@ -959,6 +958,22 @@ function isClassContextLiteralPath(path) {
959
958
  return false;
960
959
  }
961
960
  //#endregion
961
+ //#region src/js/js-string-escape.ts
962
+ function jsStringEscape(value) {
963
+ return String(value).replaceAll(/[\n\r"'\\\u2028\u2029]/g, (character) => {
964
+ switch (character) {
965
+ case "\"":
966
+ case "'":
967
+ case "\\": return `\\${character}`;
968
+ case "\n": return "\\n";
969
+ case "\r": return "\\r";
970
+ case "\u2028": return "\\u2028";
971
+ case "\u2029": return "\\u2029";
972
+ default: return character;
973
+ }
974
+ });
975
+ }
976
+ //#endregion
962
977
  //#region src/js/replacement-cache.ts
963
978
  const replacementCacheByEscapeMap = /* @__PURE__ */ new WeakMap();
964
979
  const defaultReplacementCache = /* @__PURE__ */ new Map();
@@ -1118,7 +1133,7 @@ function replaceHandleValue(path, options) {
1118
1133
  return {
1119
1134
  start,
1120
1135
  end,
1121
- value: needEscaped ? (0, _ast_core_escape.jsStringEscape)(transformed) : transformed,
1136
+ value: needEscaped ? jsStringEscape(transformed) : transformed,
1122
1137
  path
1123
1138
  };
1124
1139
  }
@@ -1230,7 +1245,7 @@ function createEvalReplacementToken(path, updated) {
1230
1245
  return {
1231
1246
  start,
1232
1247
  end,
1233
- value: path.isStringLiteral() ? (0, _ast_core_escape.jsStringEscape)(updated) : updated,
1248
+ value: path.isStringLiteral() ? jsStringEscape(updated) : updated,
1234
1249
  path
1235
1250
  };
1236
1251
  }
@@ -2188,7 +2203,7 @@ function addStringLiteralReplacement(rawSource, node, transformOptions, context)
2188
2203
  const start = node.start + 1;
2189
2204
  const end = node.end - 1;
2190
2205
  if (start >= end || transformed === rawSource.slice(start, end)) return false;
2191
- getMagicString(rawSource, context).update(start, end, (0, _ast_core_escape.jsStringEscape)(transformed));
2206
+ getMagicString(rawSource, context).update(start, end, jsStringEscape(transformed));
2192
2207
  return true;
2193
2208
  }
2194
2209
  function addTemplateElementReplacement(rawSource, node, transformOptions, context) {
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_context = require("./context-DCVMkTRj.js");
2
+ const require_context = require("./context-BCSk_YnL.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 });
package/dist/core.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as ensureRuntimeClassSet, l as shouldSkipJsTransform, t as getCompilerContext, y as createTailwindRuntimeReadyPromise } from "./context-Bkpmt3ja.mjs";
1
+ import { b as ensureRuntimeClassSet, l as shouldSkipJsTransform, t as getCompilerContext, y as createTailwindRuntimeReadyPromise } from "./context-3GGqW9vw.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 });
@@ -1,4 +1,5 @@
1
- import type { PluginWithConfig } from 'tailwindcss/plugin';
1
+ import plugin from 'tailwindcss/plugin';
2
+ type PluginWithConfig = ReturnType<typeof plugin>;
2
3
  export interface Options {
3
4
  variantsMap?: Record<string, string | {
4
5
  value: string;
@@ -10,10 +10,10 @@ const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
10
10
  const JS_FILE_PATTERN = /.+\.[cm]?js?$/;
11
11
  const alwaysFalse = () => false;
12
12
  const TAILWIND_V4_CSS_PREFLIGHT = {
13
+ "border": "0 solid",
13
14
  "box-sizing": "border-box",
14
15
  "margin": "0",
15
- "padding": "0",
16
- "border": "0 solid"
16
+ "padding": "0"
17
17
  };
18
18
  function getDefaultCssPreflight() {
19
19
  return { ...TAILWIND_V4_CSS_PREFLIGHT };
@@ -11,10 +11,10 @@ const HTML_FILE_PATTERN = /.+\.(?:(?:wx|ax|jx|ks|tt|q|ty|xhs)ml|swan)$/;
11
11
  const JS_FILE_PATTERN = /.+\.[cm]?js?$/;
12
12
  const alwaysFalse = () => false;
13
13
  const TAILWIND_V4_CSS_PREFLIGHT = {
14
+ "border": "0 solid",
14
15
  "box-sizing": "border-box",
15
16
  "margin": "0",
16
- "padding": "0",
17
- "border": "0 solid"
17
+ "padding": "0"
18
18
  };
19
19
  function getDefaultCssPreflight() {
20
20
  return { ...TAILWIND_V4_CSS_PREFLIGHT };
@@ -1,9 +1,9 @@
1
1
  import type { CssPreflightOptions, UserDefinedOptions } from './types';
2
2
  export declare const TAILWIND_V4_CSS_PREFLIGHT: {
3
+ border: string;
3
4
  'box-sizing': string;
4
5
  margin: string;
5
6
  padding: string;
6
- border: string;
7
7
  };
8
8
  export declare function getDefaultCssPreflight(): Exclude<CssPreflightOptions, false>;
9
9
  export declare function resolveDefaultCssPreflight(cssPreflight: CssPreflightOptions | undefined, _tailwindcssMajorVersion?: number): CssPreflightOptions;
package/dist/defaults.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_defaults = require("./defaults-DQhgnnn-.js");
2
+ const require_defaults = require("./defaults-nsf4VNMX.js");
3
3
  exports.TAILWIND_V4_CSS_PREFLIGHT = require_defaults.TAILWIND_V4_CSS_PREFLIGHT;
4
4
  exports.getDefaultCssPreflight = require_defaults.getDefaultCssPreflight;
5
5
  exports.getDefaultOptions = require_defaults.getDefaultOptions;
package/dist/defaults.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { i as resolveDefaultCssPreflight, n as getDefaultCssPreflight, r as getDefaultOptions, t as TAILWIND_V4_CSS_PREFLIGHT } from "./defaults-BhE26nSw.mjs";
1
+ import { i as resolveDefaultCssPreflight, n as getDefaultCssPreflight, r as getDefaultOptions, t as TAILWIND_V4_CSS_PREFLIGHT } from "./defaults-9B6aMyZb.mjs";
2
2
  export { TAILWIND_V4_CSS_PREFLIGHT, getDefaultCssPreflight, getDefaultOptions, resolveDefaultCssPreflight };
@@ -1,4 +1,4 @@
1
- import { W as createTailwindV4Engine, lt as inferGeneratorTargetFromEnv, n as resolveTailwindV4SourceFromRuntime } from "./v4-engine-BuuYDXt1.mjs";
1
+ import { Dt as inferGeneratorTargetFromEnv, Ot as shouldUseUniAppViteWebViewGeneratorTarget, ct as createTailwindV4Engine, n as resolveTailwindV4SourceFromRuntime } from "./v4-engine-DRQaCFMm.mjs";
2
2
  import { o as resolveUniUtsPlatform } from "./utils-DodxWHGz.mjs";
3
3
  //#region src/runtime-branch/create-branch.ts
4
4
  function createRuntimeBranch(base, platformFamily, options) {
@@ -88,7 +88,7 @@ function shouldUseNativeAppCssBranch(branch) {
88
88
  //#endregion
89
89
  //#region src/generator/options.ts
90
90
  function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
91
- const target = options?.target ?? inferGeneratorTargetFromEnv();
91
+ const target = options?.target ?? (shouldUseUniAppViteWebViewGeneratorTarget(context.appType, context.platform) ? "web" : inferGeneratorTargetFromEnv());
92
92
  const branch = resolveRuntimeBranch({
93
93
  ...context,
94
94
  generatorTarget: target
@@ -1,4 +1,4 @@
1
- const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
1
+ const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
2
2
  const require_utils = require("./utils-D3h8j7Mk.js");
3
3
  //#region src/runtime-branch/create-branch.ts
4
4
  function createRuntimeBranch(base, platformFamily, options) {
@@ -88,7 +88,7 @@ function shouldUseNativeAppCssBranch(branch) {
88
88
  //#endregion
89
89
  //#region src/generator/options.ts
90
90
  function normalizeWeappTailwindcssGeneratorOptions(options, context = {}) {
91
- const target = options?.target ?? require_v4_engine.inferGeneratorTargetFromEnv();
91
+ const target = options?.target ?? (require_v4_engine.shouldUseUniAppViteWebViewGeneratorTarget(context.appType, context.platform) ? "web" : require_v4_engine.inferGeneratorTargetFromEnv());
92
92
  const branch = resolveRuntimeBranch({
93
93
  ...context,
94
94
  generatorTarget: target
package/dist/generator.js CHANGED
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
3
- const require_generator = require("./generator-CilgHtxb.js");
2
+ const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
3
+ const require_generator = require("./generator-CqWzj2Z1.js");
4
4
  exports.createWeappTailwindcssGenerator = require_generator.createWeappTailwindcssGenerator;
5
5
  exports.createWeappTailwindcssGeneratorFromRuntime = require_generator.createWeappTailwindcssGeneratorFromRuntime;
6
6
  exports.normalizeWeappTailwindcssGeneratorOptions = require_generator.normalizeWeappTailwindcssGeneratorOptions;
@@ -1,3 +1,3 @@
1
- import { K as transformTailwindV4CssByTarget, i as resolveTailwindV4SourceOptionsFromRuntime, n as resolveTailwindV4SourceFromRuntime, q as transformTailwindV4CssToWeapp, r as resolveTailwindV4SourceFromRuntimeOptions, t as resolveTailwindV4Source } from "./v4-engine-BuuYDXt1.mjs";
2
- import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator } from "./generator-24-HgU9F.mjs";
1
+ import { dt as transformTailwindV4CssToWeapp, i as resolveTailwindV4SourceOptionsFromRuntime, n as resolveTailwindV4SourceFromRuntime, r as resolveTailwindV4SourceFromRuntimeOptions, t as resolveTailwindV4Source, ut as transformTailwindV4CssByTarget } from "./v4-engine-DRQaCFMm.mjs";
2
+ import { i as normalizeWeappTailwindcssGeneratorOptions, n as createWeappTailwindcssGeneratorFromRuntime, r as resolveTailwindSourceFromRuntime, t as createWeappTailwindcssGenerator } from "./generator-CoT5vu9w.mjs";
3
3
  export { createWeappTailwindcssGenerator, createWeappTailwindcssGeneratorFromRuntime, normalizeWeappTailwindcssGeneratorOptions, resolveTailwindSourceFromRuntime, resolveTailwindV4Source, resolveTailwindV4SourceFromRuntime, resolveTailwindV4SourceFromRuntimeOptions, resolveTailwindV4SourceOptionsFromRuntime, transformTailwindV4CssByTarget, transformTailwindV4CssToWeapp };
@@ -1,7 +1,7 @@
1
- import { C as hasTailwindRootDirectives, D as normalizeTailwindSourceForGenerator, G as getTailwindV4IncrementalGenerateCacheStats, T as normalizeTailwindConfigDirectives, U as prependConfigDirective, o as hasConfiguredTailwindV4CssRoots, s as upsertTailwindV4CssSource } from "./v4-engine-BuuYDXt1.mjs";
2
- import { S as createDebug, b as ensureRuntimeClassSet, l as shouldSkipJsTransform, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, y as createTailwindRuntimeReadyPromise } from "./context-Bkpmt3ja.mjs";
3
- import { l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-D0JF0fuZ.mjs";
4
- import { F as createCssTokenSourceMap, L as processCachedTask, N as annotateCssSourceTrace, P as createCssSourceTraceCacheSignature, n as emitHmrTiming, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, u as generateCssByGenerator, v as rewriteLocalCssImportRequestsForOutput, y as splitLocalCssImports } from "./hmr-timing-BRNaz8Od.mjs";
1
+ import { G as normalizeTailwindSourceForGenerator, U as normalizeTailwindConfigDirectives, V as hasTailwindRootDirectives, lt as getTailwindV4IncrementalGenerateCacheStats, o as hasConfiguredTailwindV4CssRoots, s as upsertTailwindV4CssSource, st as prependConfigDirective } from "./v4-engine-DRQaCFMm.mjs";
2
+ import { S as createDebug, b as ensureRuntimeClassSet, l as shouldSkipJsTransform, n as normalizeStyleHandlerMajorVersion, t as getCompilerContext, y as createTailwindRuntimeReadyPromise } from "./context-3GGqW9vw.mjs";
3
+ import { l as getRuntimeClassSetSignature, p as resolveViteSourceScanEntries } from "./tailwindcss-Bjr3aphG.mjs";
4
+ import { E as createCssTokenSourceMap, O as processCachedTask, T as createCssSourceTraceCacheSignature, n as emitHmrTiming, r as createSourceCandidateCollector, s as createBundleRuntimeClassSetManager, u as generateCssByGenerator, v as rewriteLocalCssImportRequestsForOutput, w as annotateCssSourceTrace, y as splitLocalCssImports } from "./hmr-timing-Cfu-4Bnf.mjs";
5
5
  import fs from "node:fs";
6
6
  import path from "node:path";
7
7
  import process from "node:process";
@@ -1,8 +1,8 @@
1
1
  const require_rolldown_runtime = require("./rolldown-runtime-emK7D4bc.js");
2
- const require_v4_engine = require("./v4-engine-CKtsdKxK.js");
3
- const require_context = require("./context-DCVMkTRj.js");
4
- const require_tailwindcss = require("./tailwindcss-D2xs4OEu.js");
5
- const require_hmr_timing = require("./hmr-timing-BV6nFPoT.js");
2
+ const require_v4_engine = require("./v4-engine-C9cmNlP8.js");
3
+ const require_context = require("./context-BCSk_YnL.js");
4
+ const require_tailwindcss = require("./tailwindcss-DYJ3HZD2.js");
5
+ const require_hmr_timing = require("./hmr-timing-Df4203aI.js");
6
6
  let node_fs = require("node:fs");
7
7
  node_fs = require_rolldown_runtime.__toESM(node_fs);
8
8
  let node_path = require("node:path");
package/dist/gulp.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_gulp = require("./gulp-Bogfnoki.js");
2
+ const require_gulp = require("./gulp-hXE1U4Cu.js");
3
3
  exports.WeappTailwindcss = require_gulp.createPlugins;
4
4
  exports.createPlugins = require_gulp.createPlugins;
5
5
  exports.weappTailwindcss = require_gulp.createPlugins;
package/dist/gulp.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPlugins } from "./gulp-0RsqkF_d.mjs";
1
+ import { t as createPlugins } from "./gulp-Bss4wJ8t.mjs";
2
2
  export { createPlugins as WeappTailwindcss, createPlugins, createPlugins as weappTailwindcss };