@codefast/cli 0.3.13-canary.0 → 0.3.13-canary.1

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 (112) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/commands/arrange.mjs +106 -1
  3. package/dist/commands/mirror.mjs +65 -1
  4. package/dist/commands/tag.mjs +57 -1
  5. package/dist/lib/arrange/application/analyze.mjs +91 -1
  6. package/dist/lib/arrange/application/group-file.mjs +112 -1
  7. package/dist/lib/arrange/application/run-target.mjs +64 -1
  8. package/dist/lib/arrange/domain/ast/ast-helpers.mjs +114 -1
  9. package/dist/lib/arrange/domain/ast/collectors-cn.mjs +60 -1
  10. package/dist/lib/arrange/domain/ast/collectors-jsx.mjs +19 -1
  11. package/dist/lib/arrange/domain/ast/collectors-tv.mjs +169 -1
  12. package/dist/lib/arrange/domain/ast/targets.mjs +105 -1
  13. package/dist/lib/arrange/domain/constants.mjs +168 -1
  14. package/dist/lib/arrange/domain/errors.mjs +18 -1
  15. package/dist/lib/arrange/domain/grouping.mjs +234 -1
  16. package/dist/lib/arrange/domain/imports.mjs +53 -1
  17. package/dist/lib/arrange/domain/tokenizer.mjs +215 -1
  18. package/dist/lib/arrange/index.mjs +14 -15
  19. package/dist/lib/arrange/infra/walk.mjs +32 -1
  20. package/dist/lib/arrange/presentation/formatters.mjs +51 -1
  21. package/dist/lib/arrange/presentation/report.mjs +23 -1
  22. package/dist/lib/config/domain/schema.mjs +24 -1
  23. package/dist/lib/config/index.mjs +2 -3
  24. package/dist/lib/config/infra/loader.mjs +77 -1
  25. package/dist/lib/infra/caught-unknown-message.mjs +19 -1
  26. package/dist/lib/infra/config-reporter.mjs +9 -1
  27. package/dist/lib/infra/node-io.mjs +29 -1
  28. package/dist/lib/infra/workspace/repo-root.mjs +21 -1
  29. package/dist/lib/mirror/application/engine.mjs +247 -1
  30. package/dist/lib/mirror/application/sync.mjs +161 -1
  31. package/dist/lib/mirror/domain/constants.mjs +11 -1
  32. package/dist/lib/mirror/domain/errors.mjs +14 -1
  33. package/dist/lib/mirror/index.mjs +1 -2
  34. package/dist/lib/mirror/infra/dirent-list.mjs +13 -1
  35. package/dist/lib/mirror/infra/package-filter.mjs +25 -1
  36. package/dist/lib/mirror/infra/path-normalizer.mjs +6 -1
  37. package/dist/lib/mirror/infra/update-pkg.mjs +104 -1
  38. package/dist/lib/mirror/infra/workspace-packages.mjs +158 -1
  39. package/dist/lib/mirror/presentation/reporter.mjs +111 -2
  40. package/dist/lib/tag/application/engine.mjs +286 -1
  41. package/dist/lib/tag/index.mjs +3 -4
  42. package/dist/lib/tag/infra/target-resolver.mjs +169 -1
  43. package/dist/lib/tag/presentation/colors.mjs +11 -1
  44. package/dist/lib/tag/presentation/tag-presenter.mjs +62 -1
  45. package/dist/program.mjs +33 -1
  46. package/package.json +2 -2
  47. package/dist/analyze-DvtJ3j9m.mjs +0 -92
  48. package/dist/arrange-Bbh62DrU.mjs +0 -107
  49. package/dist/arrange-BqP2DI3w.mjs +0 -8
  50. package/dist/ast-helpers-MDRYuIAk.mjs +0 -115
  51. package/dist/caught-unknown-message-CRhkDWO7.mjs +0 -20
  52. package/dist/collectors-cn-BS8TTQ8O.mjs +0 -61
  53. package/dist/collectors-jsx-D9tL2ZPM.mjs +0 -20
  54. package/dist/collectors-tv-D2PXZaRt.mjs +0 -170
  55. package/dist/colors-BjdkCfGK.mjs +0 -12
  56. package/dist/commands/mirror.test.mjs +0 -48
  57. package/dist/config-DVia_f9a.mjs +0 -3
  58. package/dist/config-reporter-SCcWDZc1.mjs +0 -10
  59. package/dist/constants-AtPhF-Ct.mjs +0 -169
  60. package/dist/constants-Bq5wdyLC.mjs +0 -8
  61. package/dist/dirent-list-BSDeRG5i.mjs +0 -14
  62. package/dist/engine-CcWEHSCq.mjs +0 -287
  63. package/dist/engine-DRTdkc5u.mjs +0 -236
  64. package/dist/errors-CFH4w6ic.mjs +0 -15
  65. package/dist/errors-CpU1ogfA.mjs +0 -19
  66. package/dist/formatters-DGE8jJ53.mjs +0 -52
  67. package/dist/group-file-ClW7XdD6.mjs +0 -113
  68. package/dist/grouping-c1grpCQT.mjs +0 -235
  69. package/dist/imports-DSVq1xhB.mjs +0 -54
  70. package/dist/lib/arrange/application/analyze.test.mjs +0 -171
  71. package/dist/lib/arrange/application/group-file.test.mjs +0 -273
  72. package/dist/lib/arrange/application/run-target.test.mjs +0 -97
  73. package/dist/lib/arrange/domain/ast/ast-helpers.test.mjs +0 -148
  74. package/dist/lib/arrange/domain/ast/collectors-cn.test.mjs +0 -58
  75. package/dist/lib/arrange/domain/ast/collectors-jsx.test.mjs +0 -20
  76. package/dist/lib/arrange/domain/ast/collectors-tv.test.mjs +0 -145
  77. package/dist/lib/arrange/domain/ast/targets.test.mjs +0 -50
  78. package/dist/lib/arrange/domain/grouping.test.mjs +0 -186
  79. package/dist/lib/arrange/domain/imports.test.mjs +0 -48
  80. package/dist/lib/arrange/domain/tokenizer.test.mjs +0 -165
  81. package/dist/lib/arrange/infra/walk.test.mjs +0 -50
  82. package/dist/lib/arrange/presentation/formatters.test.mjs +0 -73
  83. package/dist/lib/config/infra/loader.test.mjs +0 -116
  84. package/dist/lib/infra/workspace/repo-root.test.mjs +0 -45
  85. package/dist/lib/mirror/application/sync.test.mjs +0 -482
  86. package/dist/lib/mirror/infra/dirent-list.test.mjs +0 -18
  87. package/dist/lib/mirror/infra/package-filter.test.mjs +0 -32
  88. package/dist/lib/mirror/infra/workspace-packages.test.mjs +0 -167
  89. package/dist/lib/tag/application/engine.test.mjs +0 -159
  90. package/dist/lib/tag/presentation/tag-presenter.test.mjs +0 -29
  91. package/dist/loader-DpN-zl5g.mjs +0 -78
  92. package/dist/mirror-CbGiLXKT.mjs +0 -2
  93. package/dist/mirror-DqJE3ejL.mjs +0 -66
  94. package/dist/node-io-DFRbHO6m.mjs +0 -30
  95. package/dist/package-filter-C_8ryqvz.mjs +0 -26
  96. package/dist/path-normalizer-D4ceBO3l.mjs +0 -7
  97. package/dist/program-DR-H4tH3.mjs +0 -34
  98. package/dist/repo-root-HmtIEm6J.mjs +0 -22
  99. package/dist/report-DYxvw34T.mjs +0 -24
  100. package/dist/reporter-CwIe_tAM.mjs +0 -108
  101. package/dist/run-target-CJWrqNT4.mjs +0 -65
  102. package/dist/schema-Or8RAARd.mjs +0 -25
  103. package/dist/sync-e1Sp-shi.mjs +0 -157
  104. package/dist/tag-Cd9JujU5.mjs +0 -2
  105. package/dist/tag-hEKVZ_-7.mjs +0 -58
  106. package/dist/tag-presenter-Cs66UBsH.mjs +0 -63
  107. package/dist/target-resolver-CR3FXMTy.mjs +0 -170
  108. package/dist/targets-pCTslnFh.mjs +0 -106
  109. package/dist/tokenizer-CeZx73Zu.mjs +0 -216
  110. package/dist/update-pkg-CnGfjWBy.mjs +0 -37
  111. package/dist/walk-DjgQn66n.mjs +0 -33
  112. package/dist/workspace-packages-K2NYTHJq.mjs +0 -159
@@ -1,2 +1,235 @@
1
- import { a as suggestCnGroups, i as mergeSingletons, n as capGroups, o as summarizeGroupBucketLabels, r as mergeEaseTimingIntoFollowingAnimatedState, t as areCnTailwindPartitionsEquivalent } from "../../../grouping-c1grpCQT.mjs";
1
+ import { BUCKET_ORDER } from "./constants.mjs";
2
+ import { bucketsCompatible, bucketsMergeCompatible, classifyToken, compositeSecondaryOrder, selectorKey, stateKey, stripVariants, tokenizeClassString } from "./tokenizer.mjs";
3
+ //#region src/lib/arrange/domain/grouping.ts
4
+ function isVariantKeyedBucket(bucket) {
5
+ return bucket === "selector" || bucket === "state" || bucket === "starting";
6
+ }
7
+ function variantGroupKey(bucket, classToken) {
8
+ return bucket === "selector" ? selectorKey(classToken) : stateKey(classToken);
9
+ }
10
+ /**
11
+ * True when `staticLiteralTexts` carries the **same partition** of Tailwind tokens as
12
+ * `suggestedGroups` from {@link suggestCnGroups}, ignoring order of arguments and
13
+ * order of tokens within each chunk.
14
+ */
15
+ function areCnTailwindPartitionsEquivalent(staticLiteralTexts, suggestedGroups) {
16
+ const partitionSignatures = (chunks) => chunks.map((chunk) => {
17
+ const classTokens = tokenizeClassString(chunk);
18
+ return classTokens.length === 0 ? "" : [...classTokens].sort().join(" ");
19
+ }).filter((s) => s.length > 0).sort((a, b) => a.localeCompare(b));
20
+ const staticPartitionSigs = partitionSignatures(staticLiteralTexts);
21
+ const suggestedPartitionSigs = partitionSignatures(suggestedGroups);
22
+ if (staticPartitionSigs.length !== suggestedPartitionSigs.length) return false;
23
+ for (let i = 0; i < staticPartitionSigs.length; i++) if (staticPartitionSigs[i] !== suggestedPartitionSigs[i]) return false;
24
+ return true;
25
+ }
26
+ /** Dominant bucket of a whitespace-delimited class group (for merge heuristics). */
27
+ function dominantBucketOfGroup(groupStr) {
28
+ const counts = /* @__PURE__ */ new Map();
29
+ for (const classToken of tokenizeClassString(groupStr)) {
30
+ const tokenBucket = classifyToken(classToken);
31
+ counts.set(tokenBucket, (counts.get(tokenBucket) ?? 0) + 1);
32
+ }
33
+ let best = "other";
34
+ let bestN = 0;
35
+ for (const [bucket, count] of counts) {
36
+ if (count > bestN) {
37
+ best = bucket;
38
+ bestN = count;
39
+ continue;
40
+ }
41
+ if (count === bestN && BUCKET_ORDER[bucket] < BUCKET_ORDER[best]) best = bucket;
42
+ }
43
+ return best;
44
+ }
45
+ /** Dynamic cap: more tokens → allow more groups, within [BASE, CAP]. */
46
+ function dynamicMaxGroups(tokenCount) {
47
+ const byTokens = Math.ceil(tokenCount / 2) + 2;
48
+ return Math.max(4, Math.min(24, byTokens));
49
+ }
50
+ /**
51
+ * Merge singleton groups (< MIN_GROUP_TOKENS tokens) into their nearest
52
+ * neighbour. Prefers merging toward a bucket-compatible neighbor.
53
+ *
54
+ * Loop termination: each iteration either splices one element (shrinking the
55
+ * array, guaranteeing progress) or finds no singleton that can merge and exits
56
+ * via `changed = false`. Two mutually-incompatible singletons both hit
57
+ * `continue` and `changed` stays false, so the loop exits without spinning.
58
+ */
59
+ function mergeSingletons(groups) {
60
+ if (groups.length <= 1) return groups;
61
+ const result = [...groups];
62
+ let changed = true;
63
+ while (changed) {
64
+ changed = false;
65
+ for (let i = 0; i < result.length; i++) if (tokenizeClassString(result[i]).length < 2) {
66
+ if (result.length === 1) break;
67
+ const myBucket = dominantBucketOfGroup(result[i]);
68
+ const prevCompat = i > 0 && bucketsMergeCompatible(myBucket, dominantBucketOfGroup(result[i - 1]));
69
+ const nextCompat = i < result.length - 1 && bucketsMergeCompatible(myBucket, dominantBucketOfGroup(result[i + 1]));
70
+ let mergeDir;
71
+ if (nextCompat && !prevCompat) mergeDir = "forward";
72
+ else if (prevCompat && !nextCompat) mergeDir = "backward";
73
+ else if (prevCompat && nextCompat) mergeDir = i < result.length - 1 ? "forward" : "backward";
74
+ else continue;
75
+ if (mergeDir === "forward") result[i + 1] = result[i] + " " + result[i + 1];
76
+ else result[i - 1] = result[i - 1] + " " + result[i];
77
+ result.splice(i, 1);
78
+ changed = true;
79
+ break;
80
+ }
81
+ }
82
+ return result;
83
+ }
84
+ /** Tie-break when two merge candidates are both {@link bucketsMergeCompatible} (same bucket or COMPATIBLE_BUCKET_SETS). */
85
+ function capMergePenalty(leftBucket, rightBucket) {
86
+ if (leftBucket === rightBucket) return 0;
87
+ if (bucketsCompatible(leftBucket, rightBucket)) return 0;
88
+ return 500;
89
+ }
90
+ /**
91
+ * Merge adjacent groups until total count ≤ maxGroups.
92
+ * Only merges pairs allowed by {@link bucketsMergeCompatible} — never glues incompatible
93
+ * buckets (which previously defaulted to penalty 0 and merged layout+state when over cap).
94
+ *
95
+ * Complexity: O(n²) in the number of groups — each merge pass scans all remaining adjacent
96
+ * pairs. In practice `n` is bounded by {@link MAX_GROUPS_CAP} (24) and typical class strings
97
+ * are well below that, so this is not a concern for the current usage pattern. If this ever
98
+ * runs in a high-throughput batch mode, consider a priority-queue approach.
99
+ */
100
+ function capGroups(groups, maxGroups) {
101
+ const result = [...groups];
102
+ const lengths = result.map((groupStr) => tokenizeClassString(groupStr).length);
103
+ while (result.length > maxGroups) {
104
+ const mergePairCandidates = [];
105
+ for (let i = 0; i < result.length - 1; i++) {
106
+ const dominantLeft = dominantBucketOfGroup(result[i]);
107
+ const dominantRight = dominantBucketOfGroup(result[i + 1]);
108
+ if (!bucketsMergeCompatible(dominantLeft, dominantRight)) continue;
109
+ mergePairCandidates.push({
110
+ i,
111
+ size: lengths[i] + lengths[i + 1],
112
+ penalty: capMergePenalty(dominantLeft, dominantRight)
113
+ });
114
+ }
115
+ if (mergePairCandidates.length === 0) break;
116
+ let best = mergePairCandidates[0];
117
+ for (const candidate of mergePairCandidates) if (candidate.penalty < best.penalty || candidate.penalty === best.penalty && candidate.size < best.size) best = candidate;
118
+ const bestIdx = best.i;
119
+ result[bestIdx] = result[bestIdx] + " " + result[bestIdx + 1];
120
+ lengths[bestIdx] = lengths[bestIdx] + lengths[bestIdx + 1];
121
+ result.splice(bestIdx + 1, 1);
122
+ lengths.splice(bestIdx + 1, 1);
123
+ }
124
+ return result;
125
+ }
126
+ /**
127
+ * If a chunk is **only** bare `ease-*` timing (Motion), buffer it and prepend to the **first**
128
+ * **later** chunk that is predominantly `state` **and** contains some `animate-*` utility —
129
+ * skipping intermediate `state` chunks (`sm:…`, `group-data-[…]:…`, etc.) that sit between
130
+ * `ease-ui` and `data-open:animate-*`. If no such chunk exists, the ease chunk is left as-is.
131
+ */
132
+ function mergeEaseTimingIntoFollowingAnimatedState(groups) {
133
+ const result = [...groups];
134
+ let changed = true;
135
+ while (changed) {
136
+ changed = false;
137
+ for (let i = 0; i < result.length; i++) {
138
+ if (!chunkIsOnlyEaseTimingMotion(result[i])) continue;
139
+ const easeStr = result[i];
140
+ let target = -1;
141
+ for (let j = i + 1; j < result.length; j++) {
142
+ if (dominantBucketOfGroup(result[j]) !== "state") continue;
143
+ if (!tokenizeClassString(result[j]).some((classToken) => /^animate/.test(stripVariants(classToken)))) continue;
144
+ target = j;
145
+ break;
146
+ }
147
+ if (target === -1) continue;
148
+ result[target] = `${easeStr} ${result[target]}`.trim();
149
+ result.splice(i, 1);
150
+ changed = true;
151
+ break;
152
+ }
153
+ }
154
+ return result;
155
+ }
156
+ function chunkIsOnlyEaseTimingMotion(groupStr) {
157
+ const classTokens = tokenizeClassString(groupStr);
158
+ if (classTokens.length === 0) return false;
159
+ return classTokens.every((classToken) => classifyToken(classToken) === "motion" && /^ease-/.test(stripVariants(classToken)));
160
+ }
161
+ function suggestCnGroups(classString) {
162
+ const tokens = tokenizeClassString(classString);
163
+ if (tokens.length === 0) return [];
164
+ const classified = tokens.map((classToken, index) => ({
165
+ classToken,
166
+ bucket: classifyToken(classToken),
167
+ index
168
+ }));
169
+ classified.sort((left, right) => {
170
+ const bucketOrderDiff = BUCKET_ORDER[left.bucket] - BUCKET_ORDER[right.bucket];
171
+ if (bucketOrderDiff !== 0) return bucketOrderDiff;
172
+ if (left.bucket === "composite" && right.bucket === "composite") {
173
+ const compositeOrderDiff = compositeSecondaryOrder(stripVariants(left.classToken)) - compositeSecondaryOrder(stripVariants(right.classToken));
174
+ if (compositeOrderDiff !== 0) return compositeOrderDiff;
175
+ }
176
+ return left.index - right.index;
177
+ });
178
+ const rawGroups = [];
179
+ /** Bucket of the last token already placed in the current run (pairwise compat with `COMPATIBLE_BUCKET_SETS`). */
180
+ let lastBucketInRun = null;
181
+ let currentStateKey = null;
182
+ let currentTokens = [];
183
+ const flush = () => {
184
+ if (currentTokens.length > 0) {
185
+ rawGroups.push(currentTokens.join(" "));
186
+ currentTokens = [];
187
+ }
188
+ lastBucketInRun = null;
189
+ currentStateKey = null;
190
+ };
191
+ for (const { classToken, bucket: tokenBucket } of classified) {
192
+ if (lastBucketInRun === null) {
193
+ lastBucketInRun = tokenBucket;
194
+ currentStateKey = isVariantKeyedBucket(tokenBucket) ? variantGroupKey(tokenBucket, classToken) : null;
195
+ currentTokens.push(classToken);
196
+ continue;
197
+ }
198
+ if (isVariantKeyedBucket(tokenBucket)) {
199
+ const key = variantGroupKey(tokenBucket, classToken);
200
+ if (currentStateKey !== null && key !== currentStateKey) {
201
+ flush();
202
+ lastBucketInRun = tokenBucket;
203
+ currentStateKey = key;
204
+ currentTokens.push(classToken);
205
+ continue;
206
+ }
207
+ }
208
+ if (!bucketsCompatible(tokenBucket, lastBucketInRun)) {
209
+ flush();
210
+ lastBucketInRun = tokenBucket;
211
+ currentStateKey = isVariantKeyedBucket(tokenBucket) ? variantGroupKey(tokenBucket, classToken) : null;
212
+ currentTokens.push(classToken);
213
+ continue;
214
+ }
215
+ if (isVariantKeyedBucket(tokenBucket)) currentStateKey = variantGroupKey(tokenBucket, classToken);
216
+ else if (currentStateKey !== null) currentStateKey = null;
217
+ lastBucketInRun = tokenBucket;
218
+ currentTokens.push(classToken);
219
+ }
220
+ flush();
221
+ const withEaseMerged = mergeEaseTimingIntoFollowingAnimatedState(mergeSingletons(rawGroups));
222
+ return capGroups(withEaseMerged, Math.max(dynamicMaxGroups(tokens.length), withEaseMerged.length));
223
+ }
224
+ /**
225
+ * One label per suggested group: a single bucket name, or `mixed:a+b` when that chunk
226
+ * spans multiple Tailwind buckets (matches `codefast arrange group` stdout).
227
+ */
228
+ function summarizeGroupBucketLabels(groups) {
229
+ return groups.map((g) => {
230
+ const uniq = new Set(tokenizeClassString(g).map(classifyToken));
231
+ return uniq.size === 1 ? [...uniq][0] : `mixed:${[...uniq].sort().join("+")}`;
232
+ });
233
+ }
234
+ //#endregion
2
235
  export { areCnTailwindPartitionsEquivalent, capGroups, mergeEaseTimingIntoFollowingAnimatedState, mergeSingletons, suggestCnGroups, summarizeGroupBucketLabels };
@@ -1,2 +1,54 @@
1
- import { n as ensureCnImport, t as cnModuleSpecifierForFile } from "../../../imports-DSVq1xhB.mjs";
1
+ import ts from "typescript";
2
+ //#region src/lib/arrange/domain/imports.ts
3
+ function sourceFileImportsCn(sf) {
4
+ for (const statement of sf.statements) {
5
+ if (!ts.isImportDeclaration(statement) || !statement.importClause) continue;
6
+ const clause = statement.importClause;
7
+ if (clause.name?.text === "cn") return true;
8
+ if (clause.namedBindings && ts.isNamedImports(clause.namedBindings)) {
9
+ for (const importedBinding of clause.namedBindings.elements) if (importedBinding.name.text === "cn") return true;
10
+ }
11
+ }
12
+ return false;
13
+ }
14
+ /**
15
+ * Resolve the module specifier used when injecting a `cn` import into a file.
16
+ */
17
+ function cnModuleSpecifierForFile(filePath, override) {
18
+ if (override) return override;
19
+ return "@codefast/tailwind-variants";
20
+ }
21
+ function findImportDeclarationFromModule(sf, moduleSpecifier) {
22
+ for (const statement of sf.statements) {
23
+ if (!ts.isImportDeclaration(statement)) continue;
24
+ const spec = statement.moduleSpecifier;
25
+ if (ts.isStringLiteral(spec) && spec.text === moduleSpecifier) return statement;
26
+ }
27
+ }
28
+ function ensureCnImport(sourceText, filePath, cnImportOverride) {
29
+ const sf = ts.createSourceFile(filePath, sourceText, ts.ScriptTarget.Latest, true, filePath.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS);
30
+ if (sourceFileImportsCn(sf)) return sourceText;
31
+ const moduleSpecifier = cnModuleSpecifierForFile(filePath, cnImportOverride);
32
+ const decl = findImportDeclarationFromModule(sf, moduleSpecifier);
33
+ if (decl?.importClause && !decl.importClause.isTypeOnly && decl.importClause.namedBindings && ts.isNamedImports(decl.importClause.namedBindings)) {
34
+ const elements = decl.importClause.namedBindings.elements;
35
+ if (elements.length > 0) {
36
+ const pos = elements[0].getStart(sf);
37
+ return `${sourceText.slice(0, pos)}cn, ${sourceText.slice(pos)}`;
38
+ }
39
+ }
40
+ const importLine = `import { cn } from "${moduleSpecifier}";`;
41
+ let firstImport = -1;
42
+ for (const statement of sf.statements) if (ts.isImportDeclaration(statement)) {
43
+ firstImport = statement.getStart(sf);
44
+ break;
45
+ }
46
+ const useClient = /^["']use client["'];?\s*\r?\n/.exec(sourceText);
47
+ let insertAt;
48
+ if (useClient) insertAt = useClient[0].length;
49
+ else if (firstImport !== -1) insertAt = firstImport;
50
+ else insertAt = 0;
51
+ return `${sourceText.slice(0, insertAt)}${importLine}\n${sourceText.slice(insertAt)}`;
52
+ }
53
+ //#endregion
2
54
  export { cnModuleSpecifierForFile, ensureCnImport };
@@ -1,2 +1,216 @@
1
- import { a as compositeSecondaryOrder, c as selectorKey, d as tokenizeClassString, i as classifyToken, l as stateKey, n as bucketsMergeCompatible, o as indexOfFirstVariantColon, r as classifyBareUtility, s as isArbitraryParentSelectorStateToken, t as bucketsCompatible, u as stripVariants } from "../../../tokenizer-CeZx73Zu.mjs";
1
+ import { COMPATIBLE_BUCKET_SETS, RESPONSIVE_PREFIX, STATE_PREFIXES } from "./constants.mjs";
2
+ //#region src/lib/arrange/domain/tokenizer.ts
3
+ /**
4
+ * Variant stems not covered by a single entry in STATE_PREFIXES (compound `has-*`,
5
+ * numbered `nth-*`, media features, v4 `in-[…]`, child selectors `*` / `**`, …).
6
+ * When these are missed, `isStateToken` is false and the variant is stripped — the
7
+ * utility is then bucketed as if it were unconditional, which breaks preview grouping.
8
+ */
9
+ function isCompoundOrMediaVariantPrefix(prefix) {
10
+ if (prefix === "*" || prefix === "**") return true;
11
+ if (prefix === "inert") return true;
12
+ if (prefix.startsWith("has-")) return true;
13
+ if (prefix.startsWith("in-[")) return true;
14
+ if (/^nth(?:-last)?(?:-of-type)?(?:-\d+|-\[)/.test(prefix) || /^nth-of-type-\d+$/.test(prefix) || /^nth-last-of-type-\d+$/.test(prefix)) return true;
15
+ if (/^(?:user-valid|user-invalid|contrast-more|contrast-less|forced-colors|inverted-colors)$/.test(prefix)) return true;
16
+ if (/^(?:any-)?pointer-(?:fine|coarse|none)$/.test(prefix)) return true;
17
+ if (/^(?:portrait|landscape|noscript)$/.test(prefix)) return true;
18
+ return false;
19
+ }
20
+ function tokenizeClassString(classString) {
21
+ return classString.trim().split(/\s+/).filter(Boolean);
22
+ }
23
+ /**
24
+ * Index of the first `:` that separates a Tailwind variant segment from the rest.
25
+ * Colons inside `[...]` (at positive bracket depth) are ignored so selectors like
26
+ * `[&_a:hover]:text-red-500` split as `[&_a:hover]:` + `text-red-500`.
27
+ */
28
+ function indexOfFirstVariantColon(text) {
29
+ let depth = 0;
30
+ for (let i = 0; i < text.length; i++) {
31
+ const ch = text[i];
32
+ if (ch === "[") depth++;
33
+ else if (ch === "]") depth = Math.max(0, depth - 1);
34
+ else if (ch === ":" && depth === 0) return i;
35
+ }
36
+ return -1;
37
+ }
38
+ function stripVariants(token) {
39
+ let withoutVariants = token;
40
+ const MAX_PASSES = 12;
41
+ for (let i = 0; i < MAX_PASSES; i++) {
42
+ const colonIdx = indexOfFirstVariantColon(withoutVariants);
43
+ if (colonIdx === -1) break;
44
+ withoutVariants = withoutVariants.slice(colonIdx + 1);
45
+ }
46
+ return withoutVariants;
47
+ }
48
+ /** Outermost variant segment: first `:` at bracket depth 0 → text before it. */
49
+ function firstLeadingVariantPrefix(token) {
50
+ const colonIdx = indexOfFirstVariantColon(token);
51
+ if (colonIdx === -1) return;
52
+ return token.slice(0, colonIdx);
53
+ }
54
+ function isSelectorVariantToken(token) {
55
+ const prefix = firstLeadingVariantPrefix(token);
56
+ if (prefix === void 0) return false;
57
+ if (prefix === "*" || prefix === "**") return true;
58
+ if (prefix.startsWith("has-")) return true;
59
+ if (prefix.startsWith("in-[")) return true;
60
+ if (prefix.startsWith("group-[")) return true;
61
+ if (prefix.startsWith("peer-[")) return true;
62
+ if (prefix.startsWith("not-[")) return true;
63
+ return false;
64
+ }
65
+ function isStateToken(token) {
66
+ const prefix = firstLeadingVariantPrefix(token);
67
+ if (prefix === void 0) return false;
68
+ if (RESPONSIVE_PREFIX.test(token)) return true;
69
+ if (STATE_PREFIXES.has(prefix)) return true;
70
+ if (prefix.startsWith("data-[")) return true;
71
+ if (prefix.startsWith("aria-[")) return true;
72
+ if (prefix.startsWith("supports-[")) return true;
73
+ if (prefix.startsWith("in-data-")) return true;
74
+ if (/^data-(?!\[)/.test(prefix)) return true;
75
+ if (/^aria-/.test(prefix)) return true;
76
+ if (/^(group|peer)-/.test(prefix)) return true;
77
+ if (/^not-/.test(prefix)) return true;
78
+ if (isCompoundOrMediaVariantPrefix(prefix)) return true;
79
+ if (prefix.startsWith("[") && prefix.endsWith("]")) return true;
80
+ return false;
81
+ }
82
+ /**
83
+ * Secondary sort inside the **composite** bucket: opacity / blend / isolation →
84
+ * 3D context → 3D transforms → 2D transforms → filters → will-change.
85
+ */
86
+ function compositeSecondaryOrder(bareUtility) {
87
+ const b = bareUtility;
88
+ if (/^opacity(?:-|$)/.test(b) || /^mix-blend-/.test(b) || /^isolation(?:-|$)/.test(b) || b === "isolate") return 0;
89
+ if (b === "transform-3d" || /^perspective(?:-|$)/.test(b)) return 10;
90
+ if (/^rotate-[xyz](?:-|$)/.test(b) || /^translate-z(?:-|$)/.test(b) || /^scale-z(?:-|$)/.test(b)) return 20;
91
+ if (/^translate(?:-|$)/.test(b) || /^scale(?:-|$)/.test(b) || /^rotate(?:-|$)/.test(b) || /^skew(?:-|$)/.test(b)) return 30;
92
+ if (/^transform(?:-(?:gpu|cpu|none))?$/.test(b)) return 35;
93
+ if (/^blur(?:-|$)/.test(b) || /^backdrop-/.test(b) || /^filter(?:-|$)/.test(b) || /^brightness-/.test(b) || /^contrast-/.test(b) || /^grayscale(?:-|$)/.test(b) || /^hue-rotate-/.test(b) || /^invert(?:-|$)/.test(b) || /^saturate-/.test(b) || /^sepia(?:-|$)/.test(b)) return 40;
94
+ if (/^will-change/.test(b)) return 50;
95
+ return 99;
96
+ }
97
+ /** Classify a **bare** utility (no `hover:` / `md:` / … prefixes). */
98
+ function classifyBareUtility(bareUtility) {
99
+ const b = bareUtility;
100
+ if (/^@container(?:\/[a-z][a-z0-9-]*)?$/i.test(b)) return "existence";
101
+ if (/^(?:hidden|contents|sr-only|not-sr-only|list-item|flow-root)$/.test(b) || /^(?:block|inline-block|inline)$/.test(b)) return "existence";
102
+ if (/^table(?:$|-)/.test(b)) return "existence";
103
+ if (/^contain-/.test(b)) return "existence";
104
+ if (/^(?:group|peer)(?:\/[a-z][a-z0-9-]*)?$/.test(b)) return "existence";
105
+ if (/^(?:static|relative|absolute|fixed|sticky)$/.test(b)) return "position";
106
+ if (/^-?(?:inset|top|right|bottom|left|start|end)(?:-|\/|$)/.test(b) || /^-?(?:inset-x|inset-y|inset-s|inset-e)-/.test(b)) return "position";
107
+ if (/^-?z-/.test(b) || b === "z-auto") return "position";
108
+ if (/^(?:flex|inline-flex|grid|inline-grid|subgrid|masonry)(?:$|-)/.test(b) || /^(?:items|justify|justify-items|justify-self|content|self|place|place-content|place-items|place-self)-/.test(b) || /^-?(?:gap|space-[xy]|col-|row-|grid-|auto-cols|auto-rows|order-|order$)/.test(b) || /^-?(?:auto-flow|grid-flow)-/.test(b) || /^(?:columns-|break-after|break-before|break-inside)-/.test(b) || /^(?:float|clear)-/.test(b) || /^(?:wrap-|flex-wrap|flex-nowrap|flex-row|flex-col|flex-auto|flex-initial|flex-none|flex-1|flex-\[)/.test(b) || /^container$/.test(b)) return "layout";
109
+ if (/^-?(?:w|h|min-w|max-w|min-h|max-h|size|aspect|shrink|grow|basis)-/.test(b) || /^(?:shrink|grow)(?:$|-)/.test(b) || /^-?overflow-/.test(b) || /^-?object-/.test(b)) return "sizing";
110
+ if (/^-?(?:p|px|py|pt|pb|pl|pr|ps|pe|m|mx|my|mt|mb|ml|mr|ms|me)-/.test(b)) return "spacing";
111
+ if (/^-?(?:rounded|border|ring|divide|inset-ring)(?:-|\/|$)/.test(b) || /^(?:rounded|border|ring|divide|inset-ring)$/.test(b) || /^ring-offset-/.test(b)) return "shape";
112
+ if (/^-?bg-/.test(b) || /^(?:from|via|to)(?:-|\/|$)/.test(b) || /^bg-(?:linear|radial|conic)-/.test(b) || /^-?mask-/.test(b) || /^-?(?:fill|stroke)-/.test(b)) return "background";
113
+ if (/^-?(?:shadow|inset-shadow|drop-shadow|text-shadow)(?:-|\/|$)/.test(b) || /^(?:shadow|inset-shadow)$/.test(b) || /^-?outline(?:-|\/|$)/.test(b) || /^outline$/.test(b)) return "shadow";
114
+ if (/^-?(?:font|leading|tracking|list|indent|align|decoration|underline-offset|text-wrap|text-balance|text-pretty)-/.test(b) || /^-?(?:text-(?!shadow))/.test(b) || /^-?(?:whitespace|break|line-clamp|hyphens)-/.test(b) || /^(?:antialiased|subpixel-antialiased|italic|not-italic|overline|line-through|underline|no-underline|uppercase|lowercase|capitalize|normal-case|truncate|text-wrap|text-balance|text-pretty)$/.test(b) || /^text-wrap-/.test(b) || /^tabular-nums$|^slashed-zero$|^lining-nums$|^oldstyle-nums$|^proportional-nums$/.test(b)) return "typography";
115
+ if (/^opacity(?:-|$)/.test(b) || /^mix-blend-/.test(b) || /^isolation(?:-|$)/.test(b) || b === "isolate" || /^transform(?:-(?:gpu|cpu|none))?$/.test(b) || /^-?(?:translate|scale|rotate|skew)-/.test(b) || /^perspective(?:-|$)/.test(b) || b === "transform-3d" || /^blur(?:-|$)/.test(b) || /^backdrop-/.test(b) || /^filter(?:-|$)/.test(b) || /^brightness-/.test(b) || /^contrast-/.test(b) || /^grayscale(?:-|$)/.test(b) || /^hue-rotate-/.test(b) || /^invert(?:-|$)/.test(b) || /^saturate-/.test(b) || /^sepia(?:-|$)/.test(b) || /^will-change/.test(b)) return "composite";
116
+ if (/^(?:transition|duration|ease|delay|animate)(?:-|$)/.test(b) || /^ease-/.test(b)) return "motion";
117
+ if (/^(?:cursor|pointer-events|select|touch|scroll|scroll-m|scroll-p|overscroll|snap|resize|field-sizing|appearance|scheme|color-scheme|accent|caret)(?:-|$)/.test(b) || /^(?:cursor|select|resize)$/.test(b) || /^scroll-behavior/.test(b) || /^scroll-snap/.test(b) || /^touch-action/.test(b) || b === "inert") return "behavior";
118
+ return "other";
119
+ }
120
+ /**
121
+ * Arbitrary **parent** selectors (`[&…]`, `[&>a]:…`, slot forms with `&` inside the bracket)
122
+ * scope utilities to descendants — bucket as `selector` so they chunk apart from base layout/typography
123
+ * and are labeled distinctly from interactive `state` variants (`hover:`, `data-[…]:`, …).
124
+ * Pure arbitrary **properties** (`[--x]:`, `[color:red]`) have no `&` in the leading `[…]` segment.
125
+ */
126
+ function isArbitraryParentSelectorStateToken(token) {
127
+ if (/^\[&/.test(token)) return true;
128
+ if (!token.startsWith("[")) return false;
129
+ const colonIdx = indexOfFirstVariantColon(token);
130
+ if (colonIdx === -1 || colonIdx === 0 || token[colonIdx - 1] !== "]") return false;
131
+ return token.slice(0, colonIdx).includes("&");
132
+ }
133
+ function classifyToken(token) {
134
+ if (isArbitraryParentSelectorStateToken(token)) return "selector";
135
+ if (isSelectorVariantToken(token)) return "selector";
136
+ if (/^@container(?:\/[a-z][a-z0-9-]*)?$/i.test(token)) return "existence";
137
+ if (token.startsWith("[")) {
138
+ const splitIdx = indexOfFirstVariantColon(token);
139
+ if (splitIdx === -1) return "arbitrary";
140
+ if (splitIdx === 0 || token[splitIdx - 1] !== "]") return "arbitrary";
141
+ }
142
+ if (firstLeadingVariantPrefix(token) === "starting") return "starting";
143
+ if (isStateToken(token)) return "state";
144
+ return classifyBareUtility(stripVariants(token));
145
+ }
146
+ /**
147
+ * Stable key for `data-[…]` variants so unrelated selectors stay split, while
148
+ * **branching on the full bracket** (e.g. `data-[vaul-drawer-direction=bottom]`
149
+ * vs `=left`) keeps direction-specific utilities in separate state groups.
150
+ */
151
+ function dataAttributeStem(token) {
152
+ const match = token.match(/^data-\[([^\]]*)\]/);
153
+ return match ? `data-[${match[1]}]` : "data";
154
+ }
155
+ /** Same idea as {@link dataAttributeStem} for `aria-[…]:` variants. */
156
+ function ariaAttributeStem(token) {
157
+ const match = token.match(/^aria-\[([^\]]*)\]/);
158
+ return match ? `aria-[${match[1]}]` : "aria";
159
+ }
160
+ /** `in-data-[…]:` — normalize on the full bracket expression like {@link dataAttributeStem}. */
161
+ function inDataAttributeStem(token) {
162
+ const match = token.match(/^in-data-\[([^\]]*)\]/);
163
+ return match ? `in-data-[${match[1]}]` : "in-data";
164
+ }
165
+ /**
166
+ * Stable key for splitting adjacent `state` / `starting` tokens in {@link suggestCnGroups}
167
+ * (`selector` uses {@link selectorKey}).
168
+ * Uses the **full variant stack** (every `:` segment outside `[…]`), not only the
169
+ * outermost prefix, so `@md/foo:[&>*]:w-auto` and `@md/foo:has-[…]:mt-px` stay in
170
+ * separate groups while `hover:opacity` still keys as `hover` + `opacity`…
171
+ *
172
+ * `data-[…]` / `aria-[…]` normalize the first segment via {@link dataAttributeStem} /
173
+ * {@link ariaAttributeStem} (full token required for bracket capture).
174
+ */
175
+ function stateKey(token) {
176
+ const layers = [];
177
+ let rest = token;
178
+ while (rest.length > 0) {
179
+ const colonIdx = indexOfFirstVariantColon(rest);
180
+ if (colonIdx === -1) break;
181
+ layers.push(rest.slice(0, colonIdx));
182
+ rest = rest.slice(colonIdx + 1);
183
+ }
184
+ if (layers.length === 0) return token;
185
+ if (layers[0].startsWith("data-[")) layers[0] = dataAttributeStem(token);
186
+ else if (layers[0].startsWith("aria-[")) layers[0] = ariaAttributeStem(token);
187
+ else if (layers[0].startsWith("in-data-[")) layers[0] = inDataAttributeStem(token);
188
+ return layers.join("");
189
+ }
190
+ const SELECTOR_KEY_SEP = "";
191
+ /**
192
+ * Variant key for {@link Bucket} `"selector"` tokens in {@link suggestCnGroups}.
193
+ * Reuses {@link stateKey} layer splitting, then normalizes common shadcn/Radix SVG patterns so
194
+ * `[&_svg]:…` and `[&_svg:not([class*='size-'])]:…` stay in one chunk.
195
+ */
196
+ function selectorKey(token) {
197
+ return stateKey(token).split(SELECTOR_KEY_SEP).map(normalizeSelectorVariantLayer).join(SELECTOR_KEY_SEP);
198
+ }
199
+ function normalizeSelectorVariantLayer(layer) {
200
+ if (layer === "[&_svg:not([class*='size-'])]") return "[&_svg]";
201
+ return layer;
202
+ }
203
+ function bucketsCompatible(a, b) {
204
+ if (a === b) return true;
205
+ return COMPATIBLE_BUCKET_SETS.some((bucketSet) => bucketSet.has(a) && bucketSet.has(b));
206
+ }
207
+ /** Like {@link bucketsCompatible}, but never merge two distinct state / starting / selector variant blobs. */
208
+ function bucketsMergeCompatible(a, b) {
209
+ if (a === "state" && b === "state") return false;
210
+ if (a === "starting" && b === "starting") return false;
211
+ if (a === "selector" && b === "selector") return false;
212
+ if (a === "arbitrary" || b === "arbitrary") return false;
213
+ return bucketsCompatible(a, b);
214
+ }
215
+ //#endregion
2
216
  export { bucketsCompatible, bucketsMergeCompatible, classifyBareUtility, classifyToken, compositeSecondaryOrder, indexOfFirstVariantColon, isArbitraryParentSelectorStateToken, selectorKey, stateKey, stripVariants, tokenizeClassString };
@@ -1,16 +1,15 @@
1
- import { i as DEFAULT_ARRANGE_TARGET, o as LONG_STRING_TOKEN_THRESHOLD, p as MAX_STRIP_VARIANT_PASSES } from "../../constants-AtPhF-Ct.mjs";
2
- import { c as selectorKey, d as tokenizeClassString, i as classifyToken, l as stateKey, n as bucketsMergeCompatible, o as indexOfFirstVariantColon, t as bucketsCompatible, u as stripVariants } from "../../tokenizer-CeZx73Zu.mjs";
3
- import { a as mergeCnUnconditionalLiteralPoolForTest, r as forEachStringLiteralInClassExpression } from "../../collectors-cn-BS8TTQ8O.mjs";
4
- import { a as isCnOrTvIdentifier, i as indentOfLineContaining, l as unwrapCnInsideTvCallReplacement, n as applyEditsDescending, o as lineOf, r as buildKnownCnTvBindings, s as moduleLooksLikeCnTvReexport, t as KNOWN_CN_TV_MODULES } from "../../ast-helpers-MDRYuIAk.mjs";
5
- import { n as walkTsxFiles, t as DEFAULT_SKIP_DIRS } from "../../walk-DjgQn66n.mjs";
6
- import { t as analyzeDirectory } from "../../analyze-DvtJ3j9m.mjs";
7
- import { t as printAnalyzeReport } from "../../report-DYxvw34T.mjs";
8
- import { a as suggestCnGroups, i as mergeSingletons, n as capGroups, o as summarizeGroupBucketLabels, r as mergeEaseTimingIntoFollowingAnimatedState, t as areCnTailwindPartitionsEquivalent } from "../../grouping-c1grpCQT.mjs";
9
- import { a as formatJsxCnAttributeValue, i as formatCnCall, n as formatArray, r as formatCnArguments, t as escapeTsStringLiteralContent } from "../../formatters-DGE8jJ53.mjs";
10
- import { n as ensureCnImport, t as cnModuleSpecifierForFile } from "../../imports-DSVq1xhB.mjs";
11
- import { t as groupFile } from "../../group-file-ClW7XdD6.mjs";
12
- import { n as ArrangeErrorCode, t as ArrangeError } from "../../errors-CpU1ogfA.mjs";
13
- import { n as runOnTarget, t as runArrangeSync } from "../../run-target-CJWrqNT4.mjs";
14
- import { n as createNodeCliLogger, t as createNodeCliFs } from "../../node-io-DFRbHO6m.mjs";
15
- import "../../arrange-BqP2DI3w.mjs";
1
+ import { DEFAULT_ARRANGE_TARGET, LONG_STRING_TOKEN_THRESHOLD, MAX_STRIP_VARIANT_PASSES } from "./domain/constants.mjs";
2
+ import { bucketsCompatible, bucketsMergeCompatible, classifyToken, indexOfFirstVariantColon, selectorKey, stateKey, stripVariants, tokenizeClassString } from "./domain/tokenizer.mjs";
3
+ import { forEachStringLiteralInClassExpression, mergeCnUnconditionalLiteralPoolForTest } from "./domain/ast/collectors-cn.mjs";
4
+ import { KNOWN_CN_TV_MODULES, applyEditsDescending, buildKnownCnTvBindings, indentOfLineContaining, isCnOrTvIdentifier, lineOf, moduleLooksLikeCnTvReexport, unwrapCnInsideTvCallReplacement } from "./domain/ast/ast-helpers.mjs";
5
+ import { DEFAULT_SKIP_DIRS, walkTsxFiles } from "./infra/walk.mjs";
6
+ import { analyzeDirectory } from "./application/analyze.mjs";
7
+ import { printAnalyzeReport } from "./presentation/report.mjs";
8
+ import { areCnTailwindPartitionsEquivalent, capGroups, mergeEaseTimingIntoFollowingAnimatedState, mergeSingletons, suggestCnGroups, summarizeGroupBucketLabels } from "./domain/grouping.mjs";
9
+ import { escapeTsStringLiteralContent, formatArray, formatCnArguments, formatCnCall, formatJsxCnAttributeValue } from "./presentation/formatters.mjs";
10
+ import { cnModuleSpecifierForFile, ensureCnImport } from "./domain/imports.mjs";
11
+ import { groupFile } from "./application/group-file.mjs";
12
+ import { ArrangeError, ArrangeErrorCode } from "./domain/errors.mjs";
13
+ import { runArrangeSync, runOnTarget } from "./application/run-target.mjs";
14
+ import { createNodeCliFs, createNodeCliLogger } from "../infra/node-io.mjs";
16
15
  export { ArrangeError, ArrangeErrorCode, DEFAULT_ARRANGE_TARGET, DEFAULT_SKIP_DIRS, KNOWN_CN_TV_MODULES, LONG_STRING_TOKEN_THRESHOLD, MAX_STRIP_VARIANT_PASSES, analyzeDirectory, applyEditsDescending, areCnTailwindPartitionsEquivalent, bucketsCompatible, bucketsMergeCompatible, buildKnownCnTvBindings, capGroups, classifyToken, cnModuleSpecifierForFile, createNodeCliFs, createNodeCliLogger, ensureCnImport, escapeTsStringLiteralContent, forEachStringLiteralInClassExpression, formatArray, formatCnArguments, formatCnCall, formatJsxCnAttributeValue, groupFile, indentOfLineContaining, indexOfFirstVariantColon, isCnOrTvIdentifier, lineOf, mergeCnUnconditionalLiteralPoolForTest, mergeEaseTimingIntoFollowingAnimatedState, mergeSingletons, moduleLooksLikeCnTvReexport, printAnalyzeReport, runArrangeSync, runOnTarget, selectorKey, stateKey, stripVariants, suggestCnGroups, summarizeGroupBucketLabels, tokenizeClassString, unwrapCnInsideTvCallReplacement, walkTsxFiles };
@@ -1,2 +1,33 @@
1
- import { n as walkTsxFiles, t as DEFAULT_SKIP_DIRS } from "../../../walk-DjgQn66n.mjs";
1
+ import path from "node:path";
2
+ //#region src/lib/arrange/infra/walk.ts
3
+ const DEFAULT_SKIP_DIRS = new Set([
4
+ "node_modules",
5
+ "dist",
6
+ ".git",
7
+ ".turbo",
8
+ ".next",
9
+ ".cache",
10
+ "out",
11
+ "build",
12
+ "coverage",
13
+ ".vercel",
14
+ ".output"
15
+ ]);
16
+ function walkTsxFiles(rootDirectoryPath, fs) {
17
+ const result = [];
18
+ const visit = (entryPath) => {
19
+ if (fs.statSync(entryPath).isDirectory()) {
20
+ for (const childName of fs.readdirSync(entryPath)) {
21
+ if (DEFAULT_SKIP_DIRS.has(childName)) continue;
22
+ visit(path.join(entryPath, childName));
23
+ }
24
+ return;
25
+ }
26
+ if (entryPath.endsWith(".d.ts")) return;
27
+ if (entryPath.endsWith(".tsx") || entryPath.endsWith(".ts")) result.push(entryPath);
28
+ };
29
+ visit(rootDirectoryPath);
30
+ return result;
31
+ }
32
+ //#endregion
2
33
  export { DEFAULT_SKIP_DIRS, walkTsxFiles };
@@ -1,2 +1,52 @@
1
- import { a as formatJsxCnAttributeValue, i as formatCnCall, n as formatArray, r as formatCnArguments, t as escapeTsStringLiteralContent } from "../../../formatters-DGE8jJ53.mjs";
1
+ import { indentOfLineContaining } from "../domain/ast/ast-helpers.mjs";
2
+ //#region src/lib/arrange/presentation/formatters.ts
3
+ function escapeTsStringLiteralContent(group) {
4
+ return group.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
5
+ }
6
+ /**
7
+ * Multiline fragment for use *inside* an existing `cn(...)` — replaces one
8
+ * string argument with several, without producing `cn(cn(...))`.
9
+ */
10
+ function formatCnArguments(groups, options) {
11
+ const indent = options?.indent ?? " ";
12
+ const commaAfterLast = options?.commaAfterLastGroup ?? options?.trailingClassName ?? false;
13
+ const lines = [];
14
+ for (let i = 0; i < groups.length; i++) {
15
+ const group = groups[i];
16
+ const comma = i < groups.length - 1 || commaAfterLast ? "," : "";
17
+ lines.push(`${indent}"${escapeTsStringLiteralContent(group)}"${comma}`);
18
+ }
19
+ if (options?.trailingClassName) lines.push(`${indent}className,`);
20
+ return lines.join("\n");
21
+ }
22
+ function formatCnCall(groups, options) {
23
+ const lines = ["cn("];
24
+ const commaOnEachStringLine = groups.length > 1 || Boolean(options?.trailingClassName);
25
+ for (let i = 0; i < groups.length; i++) {
26
+ const group = groups[i];
27
+ const comma = commaOnEachStringLine ? "," : "";
28
+ lines.push(` "${escapeTsStringLiteralContent(group)}"${comma}`);
29
+ }
30
+ if (options?.trailingClassName) lines.push(" className,");
31
+ lines.push(")");
32
+ return lines.join("\n");
33
+ }
34
+ function formatArray(groups) {
35
+ const lines = ["["];
36
+ for (let i = 0; i < groups.length; i++) {
37
+ const group = groups[i];
38
+ const comma = i < groups.length - 1 || groups.length > 1 ? "," : "";
39
+ lines.push(` "${escapeTsStringLiteralContent(group)}"${comma}`);
40
+ }
41
+ lines.push("]");
42
+ return lines.join("\n");
43
+ }
44
+ function formatJsxCnAttributeValue(groups, source, valueNodeStart) {
45
+ const baseIndent = indentOfLineContaining(source, valueNodeStart);
46
+ return `{cn(\n${formatCnArguments(groups, {
47
+ indent: `${baseIndent} `,
48
+ commaAfterLastGroup: groups.length > 1
49
+ })}\n${baseIndent})}`;
50
+ }
51
+ //#endregion
2
52
  export { escapeTsStringLiteralContent, formatArray, formatCnArguments, formatCnCall, formatJsxCnAttributeValue };