@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,106 +0,0 @@
1
- import "./constants-AtPhF-Ct.mjs";
2
- import { d as tokenizeClassString } from "./tokenizer-CeZx73Zu.mjs";
3
- import { i as isUnsafeLiteralForCnStyleApplySplit } from "./collectors-cn-BS8TTQ8O.mjs";
4
- import { t as jsxClassNameStaticLiteral } from "./collectors-jsx-D9tL2ZPM.mjs";
5
- import { i as indentOfLineContaining } from "./ast-helpers-MDRYuIAk.mjs";
6
- import { n as collectGroupableStringNodes, s as slotClassString } from "./collectors-tv-D2PXZaRt.mjs";
7
- import { a as suggestCnGroups, o as summarizeGroupBucketLabels, t as areCnTailwindPartitionsEquivalent } from "./grouping-c1grpCQT.mjs";
8
- import { a as formatJsxCnAttributeValue, n as formatArray, t as escapeTsStringLiteralContent } from "./formatters-DGE8jJ53.mjs";
9
- import ts from "typescript";
10
- //#region src/lib/arrange/domain/ast/targets.ts
11
- function targetReplaceStart(target) {
12
- if (target.kind === "cnArg") return target.item.cnCall ? target.item.cnCall.getStart(target.item.sf) : target.item.primaryClassLiteral.getStart(target.item.sf);
13
- return target.valueNode.getStart(target.sf);
14
- }
15
- function collectLongJsxClassNameTargets(sf) {
16
- const results = [];
17
- const visitTypeScriptSubtree = (tsNode) => {
18
- if (ts.isJsxAttribute(tsNode)) {
19
- const parsed = jsxClassNameStaticLiteral(tsNode);
20
- if (parsed && tokenizeClassString(parsed.lit.text).length >= 2) results.push({
21
- kind: "jsxClassName",
22
- sf,
23
- lit: parsed.lit,
24
- valueNode: parsed.valueNode
25
- });
26
- }
27
- ts.forEachChild(tsNode, visitTypeScriptSubtree);
28
- };
29
- visitTypeScriptSubtree(sf);
30
- return results;
31
- }
32
- function collectGroupTargets(sf, filePath) {
33
- const cnPart = collectGroupableStringNodes(sf).map((stringNode) => ({
34
- kind: "cnArg",
35
- item: stringNode
36
- }));
37
- if (!filePath.endsWith(".tsx")) return cnPart;
38
- return [...cnPart, ...collectLongJsxClassNameTargets(sf)];
39
- }
40
- function formatCnCallReplacement(stringNode, sourceText, withClassName) {
41
- const call = stringNode.cnCall;
42
- const sf = stringNode.sf;
43
- const baseIndent = indentOfLineContaining(sourceText, call.getStart(sf));
44
- const argIndent = `${baseIndent} `;
45
- const dynamicArgTexts = [];
46
- for (const arg of call.arguments) if (!((ts.isStringLiteral(arg) || ts.isNoSubstitutionTemplateLiteral(arg)) && !isUnsafeLiteralForCnStyleApplySplit(arg))) dynamicArgTexts.push(sourceText.slice(arg.getStart(sf), arg.getEnd()));
47
- const pool = slotClassString(stringNode);
48
- const groups = pool.trim() ? suggestCnGroups(pool) : [];
49
- const allArgs = [];
50
- if (groups.length > 1) for (const group of groups) allArgs.push(`${argIndent}"${escapeTsStringLiteralContent(group)}"`);
51
- else if (groups.length === 1) allArgs.push(`${argIndent}"${escapeTsStringLiteralContent(groups[0])}"`);
52
- for (const dynamicArgumentSource of dynamicArgTexts) allArgs.push(`${argIndent}${dynamicArgumentSource}`);
53
- if (withClassName) allArgs.push(`${argIndent}className`);
54
- const commaAfterLastArg = allArgs.length > 1;
55
- return `cn(\n${allArgs.map((argLine, lineIndex) => lineIndex < allArgs.length - 1 || commaAfterLastArg ? `${argLine},` : `${argLine}`).join("\n")}\n${baseIndent})`;
56
- }
57
- function planGroupEditForTarget(target, textAfterUnwrap, withClassName) {
58
- if (target.kind === "jsxClassName") {
59
- const groups = suggestCnGroups(target.lit.text);
60
- if (groups.length <= 1) return void 0;
61
- const start = target.valueNode.getStart(target.sf);
62
- return {
63
- start,
64
- end: target.valueNode.getEnd(),
65
- replacement: formatJsxCnAttributeValue(groups, textAfterUnwrap, start),
66
- bucketSummary: summarizeGroupBucketLabels(groups),
67
- jsxCn: true,
68
- lineSf: target.sf,
69
- reportNode: target.lit,
70
- label: "JSX className"
71
- };
72
- }
73
- const groups = suggestCnGroups(slotClassString(target.item));
74
- if (groups.length <= 1) return void 0;
75
- if (areCnTailwindPartitionsEquivalent(target.item.nodes.map((classLiteral) => classLiteral.text), groups)) return;
76
- if (!target.item.cnCall) {
77
- const anchorClassLiteral = target.item.primaryClassLiteral;
78
- const parentArray = target.item.nodes.length > 1 && ts.isArrayLiteralExpression(anchorClassLiteral.parent) ? anchorClassLiteral.parent : null;
79
- const start = parentArray ? parentArray.getStart(target.item.sf) : anchorClassLiteral.getStart(target.item.sf);
80
- const end = parentArray ? parentArray.getEnd() : anchorClassLiteral.getEnd();
81
- const baseIndent = indentOfLineContaining(textAfterUnwrap, start);
82
- return {
83
- start,
84
- end,
85
- replacement: formatArray(groups).split("\n").map((line, lineIndex) => lineIndex === 0 ? line : `${baseIndent}${line}`).join("\n"),
86
- bucketSummary: summarizeGroupBucketLabels(groups),
87
- jsxCn: false,
88
- lineSf: target.item.sf,
89
- reportNode: anchorClassLiteral,
90
- label: target.item.isTvContext ? "tv" : "cn"
91
- };
92
- }
93
- const call = target.item.cnCall;
94
- return {
95
- start: call.getStart(target.item.sf),
96
- end: call.getEnd(),
97
- replacement: formatCnCallReplacement(target.item, textAfterUnwrap, withClassName),
98
- bucketSummary: summarizeGroupBucketLabels(groups),
99
- jsxCn: false,
100
- lineSf: target.item.sf,
101
- reportNode: target.item.primaryClassLiteral,
102
- label: target.item.isTvContext ? "tv" : "cn"
103
- };
104
- }
105
- //#endregion
106
- export { targetReplaceStart as a, planGroupEditForTarget as i, collectLongJsxClassNameTargets as n, formatCnCallReplacement as r, collectGroupTargets as t };
@@ -1,216 +0,0 @@
1
- import { g as STATE_PREFIXES, h as RESPONSIVE_PREFIX, r as COMPATIBLE_BUCKET_SETS } from "./constants-AtPhF-Ct.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 void 0;
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
216
- export { compositeSecondaryOrder as a, selectorKey as c, tokenizeClassString as d, classifyToken as i, stateKey as l, bucketsMergeCompatible as n, indexOfFirstVariantColon as o, classifyBareUtility as r, isArbitraryParentSelectorStateToken as s, bucketsCompatible as t, stripVariants as u };
@@ -1,37 +0,0 @@
1
- import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
2
- import { n as MirrorErrorCode, t as MirrorError } from "./errors-CFH4w6ic.mjs";
3
- //#region src/lib/mirror/infra/update-pkg.ts
4
- /** Shared rule: show `package.json#name` when it is a non-empty string; else folder basename. */
5
- function resolvePackageDisplayName(packageJson, folderBasename) {
6
- const declaredName = packageJson.name;
7
- return typeof declaredName === "string" && declaredName.length > 0 ? declaredName : folderBasename;
8
- }
9
- async function readPackageJsonDisplayName(fs, packageJsonPath, folderBasename) {
10
- if (!fs.existsSync(packageJsonPath)) return folderBasename;
11
- try {
12
- const raw = await fs.readFile(packageJsonPath, "utf8");
13
- return resolvePackageDisplayName(JSON.parse(raw), folderBasename);
14
- } catch {
15
- return folderBasename;
16
- }
17
- }
18
- /**
19
- * Writes `exports` into `package.json` via a temp file + rename (atomic on same volume).
20
- * Preserves a trailing newline after JSON.
21
- */
22
- async function writePackageJsonExportsAtomic(fs, packageJsonPath, nextExports) {
23
- const raw = await fs.readFile(packageJsonPath, "utf8");
24
- const packageJson = JSON.parse(raw);
25
- packageJson.exports = nextExports;
26
- const serialized = JSON.stringify(packageJson, null, 2) + "\n";
27
- const tmpPath = `${packageJsonPath}.tmp`;
28
- await fs.writeFile(tmpPath, serialized, "utf8");
29
- try {
30
- await fs.rename(tmpPath, packageJsonPath);
31
- } catch (caughtRenameError) {
32
- await fs.unlink(tmpPath).catch(() => {});
33
- throw new MirrorError(MirrorErrorCode.PACKAGE_WRITE, `Failed to atomically update ${packageJsonPath}: ${messageFromCaughtUnknown(caughtRenameError)}`, caughtRenameError instanceof Error ? { cause: caughtRenameError } : void 0);
34
- }
35
- }
36
- //#endregion
37
- export { resolvePackageDisplayName as n, writePackageJsonExportsAtomic as r, readPackageJsonDisplayName as t };
@@ -1,33 +0,0 @@
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
33
- export { walkTsxFiles as n, DEFAULT_SKIP_DIRS as t };
@@ -1,159 +0,0 @@
1
- import { t as messageFromCaughtUnknown } from "./caught-unknown-message-CRhkDWO7.mjs";
2
- import { t as normalizePath } from "./path-normalizer-D4ceBO3l.mjs";
3
- import { s as mirrorGlobWarning } from "./reporter-CwIe_tAM.mjs";
4
- import { globSync } from "node:fs";
5
- import path from "node:path";
6
- import picomatch from "picomatch";
7
- import { parse } from "yaml";
8
- //#region src/lib/mirror/infra/workspace-packages.ts
9
- const PNPM_WORKSPACE = "pnpm-workspace.yaml";
10
- /** Default when the workspace file is missing or has no `packages` key. */
11
- const DEFAULT_INCLUDE = ["packages/*"];
12
- function toPosix(filePath) {
13
- return filePath.split(path.sep).join("/");
14
- }
15
- function isGlobPermissionError(caughtError) {
16
- if (typeof caughtError !== "object" || caughtError === null || !("code" in caughtError)) return false;
17
- const code = caughtError.code;
18
- return code === "EACCES" || code === "EPERM";
19
- }
20
- /** Turn a pnpm `packages` glob into a `globSync` pattern that finds `package.json` files. */
21
- function workspacePatternToPackageJsonGlob(pattern) {
22
- const normalizedPattern = toPosix(pattern.trim()).replace(/\/+$/, "");
23
- if (!normalizedPattern) return "**/package.json";
24
- return `${normalizedPattern}/package.json`;
25
- }
26
- function splitWorkspacePackageEntries(raw) {
27
- const include = [];
28
- const exclude = [];
29
- if (!Array.isArray(raw)) return {
30
- include,
31
- exclude
32
- };
33
- for (const entry of raw) {
34
- if (typeof entry !== "string") continue;
35
- const trimmed = entry.trim();
36
- if (!trimmed) continue;
37
- if (trimmed.startsWith("!")) exclude.push(trimmed.slice(1).trim());
38
- else include.push(trimmed);
39
- }
40
- return {
41
- include,
42
- exclude
43
- };
44
- }
45
- /**
46
- * Reads `packages` from a parsed pnpm workspace document.
47
- * @throws If the document is invalid or `packages` is present but not an array.
48
- */
49
- function parsePnpmWorkspaceDocument(doc) {
50
- if (doc === null || doc === void 0) throw new Error(`${PNPM_WORKSPACE} root document must be an object (got empty or null)`);
51
- if (typeof doc !== "object" || Array.isArray(doc)) throw new Error(`${PNPM_WORKSPACE} root must be a mapping, not an array or scalar`);
52
- const parsedDoc = doc;
53
- if (!Object.prototype.hasOwnProperty.call(parsedDoc, "packages")) return {
54
- include: [],
55
- exclude: [],
56
- hasPackagesKey: false,
57
- isEmptyPackagesArray: false
58
- };
59
- const pkgs = parsedDoc.packages;
60
- if (!Array.isArray(pkgs)) throw new Error(`${PNPM_WORKSPACE} field "packages" must be an array`);
61
- if (pkgs.length === 0) return {
62
- include: [],
63
- exclude: [],
64
- hasPackagesKey: true,
65
- isEmptyPackagesArray: true
66
- };
67
- return {
68
- ...splitWorkspacePackageEntries(pkgs),
69
- hasPackagesKey: true,
70
- isEmptyPackagesArray: false
71
- };
72
- }
73
- async function readWorkspaceYaml(rootDir, fs) {
74
- const workspaceYamlPath = path.join(rootDir, PNPM_WORKSPACE);
75
- if (!fs.existsSync(workspaceYamlPath)) return { exists: false };
76
- let raw;
77
- try {
78
- raw = await fs.readFile(workspaceYamlPath, "utf8");
79
- } catch (caughtReadError) {
80
- throw new Error(`Failed to read ${PNPM_WORKSPACE}: ${messageFromCaughtUnknown(caughtReadError)}`);
81
- }
82
- let doc;
83
- try {
84
- doc = parse(raw);
85
- } catch (caughtYamlParseError) {
86
- throw new Error(`Failed to parse ${PNPM_WORKSPACE}: ${messageFromCaughtUnknown(caughtYamlParseError)}`);
87
- }
88
- if (doc === null || doc === void 0) throw new Error(`${PNPM_WORKSPACE} must define a mapping at the document root`);
89
- return {
90
- exists: true,
91
- doc
92
- };
93
- }
94
- /**
95
- * Workspace package directories relative to `rootDir` (POSIX slashes), sorted.
96
- * Reads `pnpm-workspace.yaml` when present; otherwise uses `packages/*`.
97
- * Only paths with a `package.json` are returned (same practical rule as pnpm).
98
- */
99
- async function findWorkspacePackageRelPaths(rootDir, fs, logger) {
100
- const workspaceYaml = await readWorkspaceYaml(rootDir, fs);
101
- let include;
102
- let exclude;
103
- let multiSource;
104
- if (!workspaceYaml.exists) {
105
- include = [...DEFAULT_INCLUDE];
106
- exclude = [];
107
- multiSource = "default-patterns";
108
- } else {
109
- const parsed = parsePnpmWorkspaceDocument(workspaceYaml.doc);
110
- if (!parsed.hasPackagesKey) {
111
- include = [...DEFAULT_INCLUDE];
112
- exclude = [];
113
- multiSource = "default-patterns";
114
- } else if (parsed.isEmptyPackagesArray) return {
115
- relPaths: [],
116
- multiSource: "declared-empty"
117
- };
118
- else {
119
- include = parsed.include;
120
- exclude = parsed.exclude;
121
- multiSource = "pnpm-workspace-yaml";
122
- }
123
- }
124
- const found = /* @__PURE__ */ new Set();
125
- const globOpts = {
126
- cwd: rootDir,
127
- posix: true,
128
- ...path.sep === "\\" ? { windowsPathsNoEscape: true } : {}
129
- };
130
- for (const pattern of include) {
131
- const globPat = workspacePatternToPackageJsonGlob(pattern);
132
- let matches;
133
- try {
134
- matches = globSync(globPat, globOpts);
135
- } catch (caughtGlobError) {
136
- if (isGlobPermissionError(caughtGlobError)) {
137
- mirrorGlobWarning(logger, `Skipping workspace glob "${pattern}" (${messageFromCaughtUnknown(caughtGlobError)})`);
138
- continue;
139
- }
140
- throw new Error(`Invalid workspace glob "${pattern}": ${messageFromCaughtUnknown(caughtGlobError)}`);
141
- }
142
- for (const matchedPath of matches) {
143
- const posix = toPosix(matchedPath);
144
- if (!posix.endsWith("/package.json")) continue;
145
- const rel = posix.slice(0, -13);
146
- if (!rel) continue;
147
- found.add(normalizePath(rel));
148
- }
149
- }
150
- const excludeMatchers = exclude.map((pat) => picomatch(pat, { dot: true }));
151
- const relPaths = [...found].filter((rel) => !excludeMatchers.some((isMatch) => isMatch(rel)));
152
- relPaths.sort((a, b) => a.localeCompare(b));
153
- return {
154
- relPaths,
155
- multiSource
156
- };
157
- }
158
- //#endregion
159
- export { workspacePatternToPackageJsonGlob as i, parsePnpmWorkspaceDocument as n, splitWorkspacePackageEntries as r, findWorkspacePackageRelPaths as t };