@codefast/cli 0.9.0 → 0.11.0
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.
- package/CHANGELOG.md +61 -0
- package/README.md +345 -151
- package/dist/arrange/command.d.ts +7 -0
- package/dist/arrange/command.js +96 -132
- package/dist/arrange/domain/ast/ast-node.d.ts +394 -0
- package/dist/arrange/domain/ast/collectors-cn.d.ts +26 -0
- package/dist/arrange/domain/ast/collectors-jsx.d.ts +8 -0
- package/dist/arrange/domain/ast/collectors-tv.d.ts +34 -0
- package/dist/arrange/domain/ast/helpers.d.ts +36 -0
- package/dist/arrange/domain/ast/helpers.js +1 -0
- package/dist/arrange/domain/ast/simplify-targets.d.ts +22 -0
- package/dist/arrange/domain/ast/simplify-targets.js +18 -23
- package/dist/arrange/domain/ast/targets.d.ts +20 -0
- package/dist/arrange/domain/ast/translator.d.ts +32 -0
- package/dist/arrange/{typescript-ast-translator.js → domain/ast/translator.js} +19 -22
- package/dist/arrange/domain/constants.d.ts +111 -0
- package/dist/arrange/domain/grouping-service.d.ts +100 -0
- package/dist/arrange/domain/grouping.d.ts +21 -0
- package/dist/arrange/domain/imports.d.ts +14 -0
- package/dist/arrange/domain/source-text-formatters.d.ts +33 -0
- package/dist/arrange/domain/tailwind-token.d.ts +24 -0
- package/dist/arrange/domain/token-classifier.d.ts +47 -0
- package/dist/arrange/domain/types.d.ts +208 -0
- package/dist/arrange/group/cli-result.d.ts +7 -0
- package/dist/arrange/group/cli-result.js +12 -0
- package/dist/arrange/group/cli-schema.d.ts +17 -0
- package/dist/arrange/group/cli-schema.js +13 -0
- package/dist/arrange/group/output.d.ts +7 -0
- package/dist/arrange/group/output.js +10 -0
- package/dist/arrange/group/suggest.d.ts +8 -0
- package/dist/arrange/inspect/cli-result.d.ts +7 -0
- package/dist/arrange/inspect/cli-result.js +8 -0
- package/dist/arrange/inspect/cli-schema.d.ts +15 -0
- package/dist/arrange/inspect/cli-schema.js +9 -0
- package/dist/arrange/inspect/domain/analyze-service.d.ts +18 -0
- package/dist/arrange/inspect/output.d.ts +7 -0
- package/dist/arrange/inspect/output.js +42 -0
- package/dist/arrange/inspect/run.d.ts +10 -0
- package/dist/arrange/{analyze.js → inspect/run.js} +2 -2
- package/dist/arrange/prepare.d.ts +13 -0
- package/dist/arrange/{workspace.js → prepare.js} +5 -8
- package/dist/arrange/regroup/cli-result.d.ts +13 -0
- package/dist/arrange/regroup/cli-result.js +23 -0
- package/dist/arrange/regroup/cli-schema.d.ts +20 -0
- package/dist/arrange/regroup/cli-schema.js +14 -0
- package/dist/arrange/regroup/output.d.ts +14 -0
- package/dist/arrange/regroup/output.js +72 -0
- package/dist/arrange/regroup/process-file.d.ts +11 -0
- package/dist/arrange/regroup/run.d.ts +11 -0
- package/dist/arrange/{sync.js → regroup/run.js} +2 -2
- package/dist/arrange/resolve-target.d.ts +10 -0
- package/dist/arrange/resolve-target.js +3 -16
- package/dist/arrange/scan-target.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.d.ts +7 -0
- package/dist/arrange/simplify/cli-result.js +8 -0
- package/dist/arrange/simplify/cli-schema.d.ts +17 -0
- package/dist/arrange/simplify/cli-schema.js +11 -0
- package/dist/arrange/simplify/fold-targets.d.ts +13 -0
- package/dist/arrange/simplify/fold-targets.js +139 -0
- package/dist/arrange/simplify/output.d.ts +7 -0
- package/dist/arrange/simplify/output.js +15 -0
- package/dist/arrange/simplify/process-file.d.ts +13 -0
- package/dist/arrange/simplify/process-file.js +49 -0
- package/dist/arrange/simplify/run.d.ts +14 -0
- package/dist/arrange/simplify/run.js +38 -0
- package/dist/arrange/simplify/variant-classname-probe.d.ts +35 -0
- package/dist/arrange/simplify/variant-classname-probe.js +95 -0
- package/dist/arrange/source-parse.d.ts +7 -0
- package/dist/arrange/source-parse.js +1 -1
- package/dist/audit/command.d.ts +8 -0
- package/dist/audit/command.js +134 -211
- package/dist/audit/comments/cli-result.d.ts +13 -0
- package/dist/audit/comments/cli-result.js +22 -0
- package/dist/audit/comments/cli-schema.d.ts +19 -0
- package/dist/audit/comments/cli-schema.js +13 -0
- package/dist/audit/comments/domain/comment-content.d.ts +26 -0
- package/dist/audit/comments/domain/comment-dividers.d.ts +62 -0
- package/dist/audit/comments/domain/link-references.d.ts +40 -0
- package/dist/audit/comments/domain/since-versions.d.ts +26 -0
- package/dist/audit/comments/domain/tsdoc-syntax.d.ts +20 -0
- package/dist/audit/comments/output.d.ts +7 -0
- package/dist/audit/comments/output.js +27 -0
- package/dist/audit/comments/prepare.d.ts +16 -0
- package/dist/audit/comments/prepare.js +12 -0
- package/dist/audit/comments/run.d.ts +17 -0
- package/dist/audit/{run-comments.js → comments/run.js} +5 -5
- package/dist/audit/display-names/cli-result.d.ts +13 -0
- package/dist/audit/display-names/cli-result.js +22 -0
- package/dist/audit/display-names/cli-schema.d.ts +18 -0
- package/dist/audit/display-names/cli-schema.js +12 -0
- package/dist/audit/display-names/domain/display-names.d.ts +11 -0
- package/dist/audit/display-names/output.d.ts +7 -0
- package/dist/audit/display-names/output.js +21 -0
- package/dist/audit/display-names/prepare.d.ts +16 -0
- package/dist/audit/display-names/prepare.js +12 -0
- package/dist/audit/display-names/run.d.ts +14 -0
- package/dist/audit/{run-display-names.js → display-names/run.js} +1 -1
- package/dist/audit/domain/types.d.ts +171 -0
- package/dist/audit/imports/cli-result.d.ts +13 -0
- package/dist/audit/imports/cli-result.js +22 -0
- package/dist/audit/imports/cli-schema.d.ts +18 -0
- package/dist/audit/imports/cli-schema.js +12 -0
- package/dist/audit/imports/domain/import-policy.d.ts +34 -0
- package/dist/audit/imports/domain/import-policy.js +140 -0
- package/dist/audit/imports/output.d.ts +7 -0
- package/dist/audit/imports/output.js +21 -0
- package/dist/audit/imports/prepare.d.ts +16 -0
- package/dist/audit/imports/prepare.js +12 -0
- package/dist/audit/imports/run.d.ts +14 -0
- package/dist/audit/{run-react.js → imports/run.js} +15 -5
- package/dist/audit/links/cli-result.d.ts +13 -0
- package/dist/audit/links/cli-result.js +22 -0
- package/dist/audit/links/cli-schema.d.ts +18 -0
- package/dist/audit/links/cli-schema.js +12 -0
- package/dist/audit/links/domain/markdown-links.d.ts +44 -0
- package/dist/audit/links/output.d.ts +7 -0
- package/dist/audit/links/output.js +21 -0
- package/dist/audit/links/prepare.d.ts +16 -0
- package/dist/audit/links/prepare.js +12 -0
- package/dist/audit/links/run.d.ts +14 -0
- package/dist/audit/{run-links.js → links/run.js} +1 -1
- package/dist/audit/prepare.d.ts +31 -0
- package/dist/audit/prepare.js +11 -134
- package/dist/audit/rtl/cli-result.d.ts +13 -0
- package/dist/audit/rtl/cli-result.js +22 -0
- package/dist/audit/rtl/cli-schema.d.ts +18 -0
- package/dist/audit/rtl/cli-schema.js +12 -0
- package/dist/audit/rtl/domain/audit-file.d.ts +7 -0
- package/dist/audit/{domain → rtl/domain}/audit-file.js +2 -2
- package/dist/audit/rtl/domain/mappings.d.ts +45 -0
- package/dist/audit/rtl/domain/tokenize.d.ts +14 -0
- package/dist/audit/rtl/output.d.ts +7 -0
- package/dist/audit/rtl/output.js +21 -0
- package/dist/audit/rtl/prepare.d.ts +13 -0
- package/dist/audit/rtl/prepare.js +41 -0
- package/dist/audit/rtl/run.d.ts +14 -0
- package/dist/audit/{run.js → rtl/run.js} +1 -1
- package/dist/bin.d.ts +2 -0
- package/dist/cli.d.ts +6 -0
- package/dist/core/cli/command-pipeline.d.ts +91 -0
- package/dist/core/cli/command-pipeline.js +83 -0
- package/dist/core/cli/format-error.d.ts +7 -0
- package/dist/core/cli/global-options.d.ts +15 -0
- package/dist/core/cli/global-options.js +1 -1
- package/dist/core/cli/positional.d.ts +6 -0
- package/dist/core/cli/resolve-root.d.ts +9 -0
- package/dist/core/cli/resolve-root.js +16 -0
- package/dist/core/cli/result-handle.d.ts +13 -0
- package/dist/core/cli/result-handle.js +0 -13
- package/dist/core/config/define-config.d.ts +7 -0
- package/dist/core/config/define-config.js +8 -0
- package/dist/core/config/loader.d.ts +18 -0
- package/dist/core/config/loader.js +2 -7
- package/dist/core/config/schema.d.ts +99 -0
- package/dist/core/config/schema.js +8 -86
- package/dist/core/config/warnings.d.ts +6 -0
- package/dist/core/config.d.ts +12 -0
- package/dist/core/errors.d.ts +25 -0
- package/dist/core/exit-codes.d.ts +18 -0
- package/dist/core/filesystem/filesystem.d.ts +44 -0
- package/dist/core/filesystem/node.d.ts +7 -0
- package/dist/core/filesystem/node.js +2 -1
- package/dist/core/glob.d.ts +19 -0
- package/dist/core/logger.d.ts +9 -0
- package/dist/core/result.d.ts +30 -0
- package/dist/core/schema-parse.d.ts +9 -0
- package/dist/core/source-text-edit.d.ts +47 -0
- package/dist/core/source-text-edit.js +22 -0
- package/dist/core/verbose-diagnostics.d.ts +6 -0
- package/dist/core/workspace/ancestor-directories.d.ts +12 -0
- package/dist/core/workspace/ancestor-directories.js +30 -0
- package/dist/core/workspace/markdown-walk.d.ts +7 -0
- package/dist/core/workspace/markdown-walk.js +2 -20
- package/dist/core/workspace/package-version.d.ts +9 -0
- package/dist/core/workspace/package-version.js +8 -12
- package/dist/core/workspace/resolver.d.ts +39 -0
- package/dist/core/workspace/resolver.js +58 -75
- package/dist/core/workspace/skip-directories.d.ts +6 -0
- package/dist/core/workspace/source-walk.d.ts +16 -0
- package/dist/core/workspace/source-walk.js +2 -19
- package/dist/core/workspace/typescript-walk.d.ts +7 -0
- package/dist/core/workspace/typescript-walk.js +2 -23
- package/dist/core/workspace/walk-files.d.ts +7 -0
- package/dist/core/workspace/walk-files.js +27 -0
- package/dist/core/workspace/well-known-files.d.ts +18 -0
- package/dist/core/workspace/well-known-files.js +18 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/mirror/cli-result.d.ts +13 -0
- package/dist/mirror/cli-schema.d.ts +8 -0
- package/dist/mirror/cli-schema.js +1 -1
- package/dist/mirror/command.d.ts +7 -0
- package/dist/mirror/command.js +31 -60
- package/dist/mirror/dist-filesystem-node.d.ts +8 -0
- package/dist/mirror/{dist-filesystem-impl.js → dist-filesystem-node.js} +1 -1
- package/dist/mirror/domain/constants.d.ts +18 -0
- package/dist/mirror/domain/constants.js +0 -12
- package/dist/mirror/domain/dirent-guard.d.ts +10 -0
- package/dist/mirror/domain/dist-filesystem.d.ts +9 -0
- package/dist/mirror/domain/errors.d.ts +24 -0
- package/dist/mirror/domain/exports.d.ts +36 -0
- package/dist/mirror/domain/package-display-name.d.ts +8 -0
- package/dist/mirror/domain/path-normalizer.d.ts +6 -0
- package/dist/mirror/domain/types.d.ts +188 -0
- package/dist/mirror/output.d.ts +21 -0
- package/dist/mirror/output.js +126 -1
- package/dist/mirror/package-path.d.ts +19 -0
- package/dist/mirror/prepare.d.ts +15 -0
- package/dist/mirror/prepare.js +6 -10
- package/dist/mirror/run.d.ts +12 -0
- package/dist/mirror/{sync.js → run.js} +5 -3
- package/dist/mirror/supplement-exports.d.ts +27 -0
- package/dist/mirror/supplement-exports.js +2 -2
- package/dist/mirror/sync-workspace-package.d.ts +9 -0
- package/dist/mirror/sync-workspace-package.js +4 -4
- package/dist/mirror/write-exports.d.ts +15 -0
- package/dist/pack-slim/cli-result.d.ts +13 -0
- package/dist/pack-slim/cli-schema.d.ts +17 -0
- package/dist/pack-slim/cli-schema.js +1 -1
- package/dist/pack-slim/command.d.ts +7 -0
- package/dist/pack-slim/command.js +31 -66
- package/dist/pack-slim/domain/transform.d.ts +69 -0
- package/dist/pack-slim/domain/types.d.ts +46 -0
- package/dist/pack-slim/output.d.ts +15 -0
- package/dist/pack-slim/prepare.d.ts +21 -0
- package/dist/pack-slim/prepare.js +14 -0
- package/dist/pack-slim/run.d.ts +23 -0
- package/dist/pack-slim/{sync.js → run.js} +4 -4
- package/dist/pack-slim/working-tree.d.ts +20 -0
- package/dist/tag/cli-result.d.ts +13 -0
- package/dist/tag/cli-result.js +14 -1
- package/dist/tag/cli-schema.d.ts +8 -0
- package/dist/tag/cli-schema.js +3 -4
- package/dist/tag/command.d.ts +7 -0
- package/dist/tag/command.js +33 -60
- package/dist/tag/domain/skip-filter.d.ts +13 -0
- package/dist/tag/domain/skip-filter.js +29 -0
- package/dist/tag/domain/types.d.ts +131 -0
- package/dist/tag/domain/version-summary.d.ts +13 -0
- package/dist/tag/domain/version-summary.js +24 -0
- package/dist/tag/output.d.ts +17 -0
- package/dist/tag/output.js +6 -9
- package/dist/tag/prepare.d.ts +13 -0
- package/dist/tag/prepare.js +4 -4
- package/dist/tag/run.d.ts +10 -0
- package/dist/tag/{sync.js → run.js} +20 -50
- package/dist/tag/target/candidates.d.ts +8 -0
- package/dist/tag/{target-candidates.js → target/candidates.js} +2 -2
- package/dist/tag/target/resolve-path.d.ts +10 -0
- package/dist/tag/target/runner.d.ts +8 -0
- package/dist/tag/{target-runner.js → target/runner.js} +2 -2
- package/dist/tag/writer/since-writer.d.ts +32 -0
- package/dist/tag/writer/version-resolver.d.ts +7 -0
- package/package.json +21 -2
- package/dist/arrange/cli-schema.js +0 -34
- package/dist/arrange/output.js +0 -127
- package/dist/arrange/simplify-process-file.js +0 -30
- package/dist/arrange/simplify-sync.js +0 -30
- package/dist/audit/cli-schema.js +0 -66
- package/dist/audit/domain/react-imports.js +0 -91
- package/dist/audit/output.js +0 -213
- package/dist/mirror/sync-reporter.js +0 -124
- package/dist/mirror/sync-types.js +0 -1
- /package/dist/arrange/{suggest.js → group/suggest.js} +0 -0
- /package/dist/arrange/{domain → inspect/domain}/analyze-service.js +0 -0
- /package/dist/arrange/{process-file.js → regroup/process-file.js} +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-content.js +0 -0
- /package/dist/audit/{domain → comments/domain}/comment-dividers.js +0 -0
- /package/dist/audit/{domain → comments/domain}/link-references.js +0 -0
- /package/dist/audit/{domain → comments/domain}/since-versions.js +0 -0
- /package/dist/audit/{domain → comments/domain}/tsdoc-syntax.js +0 -0
- /package/dist/audit/{domain → display-names/domain}/display-names.js +0 -0
- /package/dist/audit/{domain → links/domain}/markdown-links.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/mappings.js +0 -0
- /package/dist/audit/{domain → rtl/domain}/tokenize.js +0 -0
- /package/dist/core/filesystem/{port.js → filesystem.js} +0 -0
- /package/dist/tag/{resolve-target-path.js → target/resolve-path.js} +0 -0
- /package/dist/tag/{since-writer.js → writer/since-writer.js} +0 -0
- /package/dist/tag/{version-resolver.js → writer/version-resolver.js} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DomainCallExpression, DomainObjectLiteralExpression, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
import type { StringNode, TailwindClassLiteral } from "#/arrange/domain/types";
|
|
3
|
+
type StringNodeVisitor = (classLiteral: TailwindClassLiteral, sourceFile: DomainSourceFile, cnCall?: DomainCallExpression) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Visits every class literal reachable inside a `tv({ ... })` object, including `cn()` arguments.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.3.16-canary.0
|
|
8
|
+
*/
|
|
9
|
+
export declare function traverseTvObject(sourceFile: DomainSourceFile, obj: DomainObjectLiteralExpression, visitor: StringNodeVisitor, depth?: number, knownBindings?: Set<string>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Collects the `cn()` calls nested inside a `tv({ ... })` object.
|
|
12
|
+
*
|
|
13
|
+
* @since 0.3.16-canary.0
|
|
14
|
+
*/
|
|
15
|
+
export declare function collectCnCallsInsideTv(sourceFile: DomainSourceFile, obj: DomainObjectLiteralExpression, knownBindings: Set<string>, depth?: number): Array<DomainCallExpression>;
|
|
16
|
+
/**
|
|
17
|
+
* Collects every `cn()` call nested inside any `tv()` call in a source file.
|
|
18
|
+
*
|
|
19
|
+
* @since 0.3.16-canary.0
|
|
20
|
+
*/
|
|
21
|
+
export declare function listAllCnCallsInsideTvInSourceFile(sourceFile: DomainSourceFile, knownBindings: Set<string>): Array<DomainCallExpression>;
|
|
22
|
+
/**
|
|
23
|
+
* Joins a slot's literals into one space-separated class string.
|
|
24
|
+
*
|
|
25
|
+
* @since 0.3.16-canary.0
|
|
26
|
+
*/
|
|
27
|
+
export declare function slotClassString(stringNode: StringNode): string;
|
|
28
|
+
/**
|
|
29
|
+
* Collects every groupable `cn()` / `tv()` string slot in a source file.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.3.16-canary.0
|
|
32
|
+
*/
|
|
33
|
+
export declare function collectGroupableStringNodes(sourceFile: DomainSourceFile): Array<StringNode>;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { DomainAstNode, DomainCallExpression, DomainPropertyAssignment, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
import { applyEditsDescending } from "#/core/source-text-edit";
|
|
3
|
+
/**
|
|
4
|
+
* Builds a set of local binding names that are imported from a known cn/tv
|
|
5
|
+
* module in `sourceFile`.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.3.16-canary.0
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildKnownCnTvBindings(sourceFile: DomainSourceFile): Set<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns true when `expr` is an identifier whose name matches `name` AND
|
|
12
|
+
* that name is listed in `knownBindings` from a recognized import.
|
|
13
|
+
*
|
|
14
|
+
* @since 0.3.16-canary.0
|
|
15
|
+
*/
|
|
16
|
+
export declare function isCnOrTvIdentifier(expr: DomainAstNode, name: "cn" | "tv", knownBindings?: Set<string>): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a property assignment's name text, or `undefined` for computed names.
|
|
19
|
+
*
|
|
20
|
+
* @since 0.3.16-canary.0
|
|
21
|
+
*/
|
|
22
|
+
export declare function propertyAssignmentNameText(prop: DomainPropertyAssignment): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves the one-based line number a node starts on.
|
|
25
|
+
*
|
|
26
|
+
* @since 0.3.16-canary.0
|
|
27
|
+
*/
|
|
28
|
+
export declare function lineOf(sourceFile: DomainSourceFile, node: DomainAstNode): number;
|
|
29
|
+
export { applyEditsDescending };
|
|
30
|
+
/**
|
|
31
|
+
* Replace `cn(...)` nested in `tv({...})` with a plain string (one arg) or a string
|
|
32
|
+
* array (multiple args). Returns undefined when there are zero arguments.
|
|
33
|
+
*
|
|
34
|
+
* @since 0.3.16-canary.0
|
|
35
|
+
*/
|
|
36
|
+
export declare function unwrapCnInsideTvCallReplacement(call: DomainCallExpression, sourceText: string): string | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
/**
|
|
3
|
+
* A planned text replacement produced by the simplify pass.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.3.16-canary.0
|
|
6
|
+
*/
|
|
7
|
+
export type PlannedSimplifyEdit = {
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
replacement: string;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Collects all simplify edits for a source file:
|
|
15
|
+
* - Arrays of pure string literals inside tv() slots → flat string
|
|
16
|
+
* - cn() calls whose every argument is a static string literal → flat string (unwrap cn)
|
|
17
|
+
* - cn() calls with mixed static + dynamic args → merge adjacent statics into one string
|
|
18
|
+
* - JSX `className={cn(...all-static...)}` → `className="flat string"`
|
|
19
|
+
*
|
|
20
|
+
* @since 0.3.16-canary.0
|
|
21
|
+
*/
|
|
22
|
+
export declare function collectSimplifyTargets(sourceFile: DomainSourceFile): Array<PlannedSimplifyEdit>;
|
|
@@ -15,47 +15,42 @@ function joinLiterals(args) {
|
|
|
15
15
|
function isAllStaticLiterals(args) {
|
|
16
16
|
return args.length > 0 && args.every(isDomainTailwindClassLiteral);
|
|
17
17
|
}
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
// Mixed cn() merge: ALL static args → one string first, dynamic args follow
|
|
20
|
-
// ---------------------------------------------------------------------------
|
|
21
18
|
/**
|
|
22
|
-
*
|
|
23
|
-
* - Merge ALL static string literals (regardless of position) into one string.
|
|
24
|
-
* - Place the merged string first.
|
|
25
|
-
* - Append all dynamic args in their original relative order.
|
|
19
|
+
* Builds a mixed cn() replacement that coalesces each run of adjacent static literals into one string.
|
|
26
20
|
*
|
|
27
|
-
*
|
|
21
|
+
* @remarks Argument order is preserved so tailwind-merge precedence is unchanged — a later cn()
|
|
22
|
+
* argument still overrides an earlier one. Returns `null` when no run of two-or-more adjacent statics
|
|
23
|
+
* exists, since reordering a lone static across a dynamic argument would change what renders.
|
|
28
24
|
*/
|
|
29
25
|
function buildMixedCnReplacement(call, sourceText) {
|
|
30
26
|
const args = [...call.arguments];
|
|
31
27
|
if (args.length === 0) {
|
|
32
28
|
return null;
|
|
33
29
|
}
|
|
34
|
-
const
|
|
35
|
-
const dynamicSrcs = [];
|
|
30
|
+
const pieces = [];
|
|
36
31
|
for (const arg of args) {
|
|
37
32
|
if (isDomainTailwindClassLiteral(arg)) {
|
|
38
|
-
|
|
33
|
+
const last = pieces.at(-1);
|
|
34
|
+
if (last?.kind === "static") {
|
|
35
|
+
last.texts.push(arg.text);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
pieces.push({ kind: "static", texts: [arg.text] });
|
|
39
|
+
}
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
|
-
|
|
42
|
+
pieces.push({ kind: "dynamic", src: sourceText.slice(arg.pos, arg.end) });
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
// Already simplest form: 1 static arg already at the front.
|
|
48
|
-
const firstArg = args[0];
|
|
49
|
-
if (staticTexts.length === 1 && firstArg !== undefined && isDomainTailwindClassLiteral(firstArg)) {
|
|
45
|
+
const merged = pieces.some((piece) => piece.kind === "static" && piece.texts.length > 1);
|
|
46
|
+
if (!merged) {
|
|
50
47
|
return null;
|
|
51
48
|
}
|
|
52
|
-
const flatStatic = staticTexts.join(" ").trim();
|
|
53
49
|
const baseIndent = indentOfLineContaining(sourceText, call.pos);
|
|
54
50
|
const argIndent = `${baseIndent} `;
|
|
55
|
-
const lines =
|
|
56
|
-
`${argIndent}"${escapeTsStringLiteralContent(
|
|
57
|
-
|
|
58
|
-
];
|
|
51
|
+
const lines = pieces.map((piece) => piece.kind === "static"
|
|
52
|
+
? `${argIndent}"${escapeTsStringLiteralContent(piece.texts.join(" ").trim())}",`
|
|
53
|
+
: `${argIndent}${piece.src},`);
|
|
59
54
|
return `cn(\n${lines.join("\n")}\n${baseIndent})`;
|
|
60
55
|
}
|
|
61
56
|
// ── tv() array collector ─────────────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
import type { GroupTarget, PlannedGroupEdit } from "#/arrange/domain/types";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves the source position where a group target's replacement begins.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function targetReplaceStart(target: GroupTarget): number;
|
|
9
|
+
/**
|
|
10
|
+
* Collects a file's group targets — `cn()` / `tv()` slots, plus long JSX `className` literals in `.tsx`.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.16-canary.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function collectGroupTargets(sourceFile: DomainSourceFile, filePath: string): Array<GroupTarget>;
|
|
15
|
+
/**
|
|
16
|
+
* Plans the grouped replacement for one target, or `undefined` when regrouping would change nothing.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.3.16-canary.0
|
|
19
|
+
*/
|
|
20
|
+
export declare function planGroupEditForTarget(target: GroupTarget, textAfterUnwrap: string, withClassName: boolean): PlannedGroupEdit | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anti-corruption layer: maps the oxc-parser ESTree AST to the arrange domain AST.
|
|
3
|
+
* This is the only place that parses TypeScript source for arrange AST translation.
|
|
4
|
+
*/
|
|
5
|
+
import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
6
|
+
/**
|
|
7
|
+
* The translator mapping the `oxc-parser` ESTree AST to the arrange domain AST.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.3.16-canary.0
|
|
10
|
+
*/
|
|
11
|
+
export declare class TypeScriptAstTranslator {
|
|
12
|
+
translateSourceFile(filePath: string, sourceText: string): DomainSourceFile;
|
|
13
|
+
/**
|
|
14
|
+
* Translates any node the typed cases do not cover, recursing into own child nodes and arrays of
|
|
15
|
+
* nodes in source-declaration order and skipping primitives and records that carry no `type`.
|
|
16
|
+
*
|
|
17
|
+
* @remarks Children are walked inline rather than through a generator — the `yield` per child is
|
|
18
|
+
* several times slower than a plain loop on this hot path, and this fallback runs for most nodes.
|
|
19
|
+
*/
|
|
20
|
+
private translateUnknown;
|
|
21
|
+
private stringLiteralText;
|
|
22
|
+
private noSubstitutionTemplateText;
|
|
23
|
+
private mapBinaryOperator;
|
|
24
|
+
private translateImportDeclaration;
|
|
25
|
+
private buildImportClause;
|
|
26
|
+
private buildNamespaceImport;
|
|
27
|
+
private buildNamedImports;
|
|
28
|
+
private buildImportSpecifier;
|
|
29
|
+
private translateIdentifier;
|
|
30
|
+
private translateNode;
|
|
31
|
+
private parseDomainSourceFile;
|
|
32
|
+
}
|
|
@@ -20,11 +20,21 @@ export class TypeScriptAstTranslator {
|
|
|
20
20
|
return this.parseDomainSourceFile(filePath, sourceText);
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* Translates any node the typed cases do not cover, recursing into own child nodes and arrays of
|
|
24
|
+
* nodes in source-declaration order and skipping primitives and records that carry no `type`.
|
|
25
|
+
*
|
|
26
|
+
* @remarks Children are walked inline rather than through a generator — the `yield` per child is
|
|
27
|
+
* several times slower than a plain loop on this hot path, and this fallback runs for most nodes.
|
|
26
28
|
*/
|
|
27
|
-
|
|
29
|
+
translateUnknown(node, parent) {
|
|
30
|
+
const self = {
|
|
31
|
+
kind: DomainSyntaxKind.Unknown,
|
|
32
|
+
pos: node.start,
|
|
33
|
+
end: node.end,
|
|
34
|
+
parent,
|
|
35
|
+
children: [],
|
|
36
|
+
};
|
|
37
|
+
const childList = [];
|
|
28
38
|
for (const key in node) {
|
|
29
39
|
if (key === "type" || key === "start" || key === "end" || key === "range") {
|
|
30
40
|
continue;
|
|
@@ -33,29 +43,16 @@ export class TypeScriptAstTranslator {
|
|
|
33
43
|
if (Array.isArray(value)) {
|
|
34
44
|
for (const element of value) {
|
|
35
45
|
if (isOxcNode(element)) {
|
|
36
|
-
|
|
46
|
+
childList.push(this.translateNode(element, self));
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
|
-
continue;
|
|
40
49
|
}
|
|
41
|
-
if (isOxcNode(value)) {
|
|
42
|
-
|
|
50
|
+
else if (isOxcNode(value)) {
|
|
51
|
+
childList.push(this.translateNode(value, self));
|
|
43
52
|
}
|
|
44
53
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const self = {
|
|
48
|
-
kind: DomainSyntaxKind.Unknown,
|
|
49
|
-
pos: node.start,
|
|
50
|
-
end: node.end,
|
|
51
|
-
parent,
|
|
52
|
-
children: [],
|
|
53
|
-
};
|
|
54
|
-
const childList = [];
|
|
55
|
-
for (const child of this.childNodesOf(node)) {
|
|
56
|
-
childList.push(this.translateNode(child, self));
|
|
57
|
-
}
|
|
58
|
-
return { ...self, children: childList };
|
|
54
|
+
self.children = childList;
|
|
55
|
+
return self;
|
|
59
56
|
}
|
|
60
57
|
stringLiteralText(node) {
|
|
61
58
|
if (node.type === "Literal" && typeof node.value === "string") {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Bucket } from "#/arrange/domain/types";
|
|
2
|
+
/**
|
|
3
|
+
* Analyze report: long literal threshold (token count).
|
|
4
|
+
*
|
|
5
|
+
* @since 0.3.16-canary.0
|
|
6
|
+
*/
|
|
7
|
+
export declare const LONG_STRING_TOKEN_THRESHOLD = 18;
|
|
8
|
+
/**
|
|
9
|
+
* Minimum token count for a string to be considered a candidate for grouping
|
|
10
|
+
* in the apply/preview pipeline. Intentionally much lower than
|
|
11
|
+
* {@link LONG_STRING_TOKEN_THRESHOLD} (analyze only).
|
|
12
|
+
*
|
|
13
|
+
* @since 0.3.16-canary.0
|
|
14
|
+
*/
|
|
15
|
+
export declare const APPLY_MIN_TOKENS = 2;
|
|
16
|
+
/**
|
|
17
|
+
* Minimum tokens a group must have to stand alone before singleton-merging.
|
|
18
|
+
* Set to 2 so single-token groups are not collapsed into unrelated buckets by the merger.
|
|
19
|
+
*
|
|
20
|
+
* @since 0.3.16-canary.0
|
|
21
|
+
*/
|
|
22
|
+
export declare const MIN_GROUP_TOKENS = 2;
|
|
23
|
+
/**
|
|
24
|
+
* Dynamic max groups clamp: base bound.
|
|
25
|
+
*
|
|
26
|
+
* @since 0.3.16-canary.0
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_GROUPS_BASE = 4;
|
|
29
|
+
/**
|
|
30
|
+
* Dynamic max groups clamp: upper cap.
|
|
31
|
+
*
|
|
32
|
+
* @since 0.3.16-canary.0
|
|
33
|
+
*/
|
|
34
|
+
export declare const MAX_GROUPS_CAP = 24;
|
|
35
|
+
/**
|
|
36
|
+
* Extra slots so a few state / aria groups do not force `capGroups` to merge
|
|
37
|
+
* unrelated buckets (e.g. `bg-border` + `outline-hidden`).
|
|
38
|
+
*
|
|
39
|
+
* @since 0.3.16-canary.0
|
|
40
|
+
*/
|
|
41
|
+
export declare const MAX_GROUPS_HEADROOM = 2;
|
|
42
|
+
/**
|
|
43
|
+
* Maximum findings printed per category in the analyze report.
|
|
44
|
+
*
|
|
45
|
+
* @since 0.3.16-canary.0
|
|
46
|
+
*/
|
|
47
|
+
export declare const MAX_REPORT_LINES = 40;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum recursion depth when traversing `tv()` object literals.
|
|
50
|
+
*
|
|
51
|
+
* @since 0.3.16-canary.0
|
|
52
|
+
*/
|
|
53
|
+
export declare const MAX_OBJECT_DEPTH = 12;
|
|
54
|
+
/**
|
|
55
|
+
* Maximum depth when peeling conditional / parens / arrays inside `cn(...)` args.
|
|
56
|
+
*
|
|
57
|
+
* @since 0.3.16-canary.0
|
|
58
|
+
*/
|
|
59
|
+
export declare const MAX_CLASS_EXPR_DEPTH = 12;
|
|
60
|
+
/**
|
|
61
|
+
* Maximum variant-stripping passes in {@link stripVariants}.
|
|
62
|
+
* Real-world Tailwind stacks rarely exceed 4–5 segments (e.g. `@md/sidebar:group-hover:dark:focus-visible:`);
|
|
63
|
+
* 12 is a conservative safety cap that prevents runaway loops on malformed input.
|
|
64
|
+
*
|
|
65
|
+
* @since 0.3.16-canary.0
|
|
66
|
+
*/
|
|
67
|
+
export declare const MAX_STRIP_VARIANT_PASSES = 12;
|
|
68
|
+
/**
|
|
69
|
+
* Passed when optional `knownBindings` is missing — size 0 disables matching
|
|
70
|
+
* for `cn` / `tv` identifier resolution.
|
|
71
|
+
*
|
|
72
|
+
* @since 0.3.16-canary.0
|
|
73
|
+
*/
|
|
74
|
+
export declare const EMPTY_CN_TV_BINDINGS: Set<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Bucket sort order — **render pipeline** (lower → earlier in `cn()` output).
|
|
77
|
+
*
|
|
78
|
+
* Matches README: Existence → Position → Layout → Sizing → Spacing → Shape → Background
|
|
79
|
+
* → Shadow → Typography → Composite → Motion → Starting → Behavior → State → Selector,
|
|
80
|
+
* then `other` and `arbitrary` as sort tails for unknown utilities and arbitrary properties.
|
|
81
|
+
*
|
|
82
|
+
* @since 0.3.16-canary.0
|
|
83
|
+
*/
|
|
84
|
+
export declare const BUCKET_ORDER: Record<Bucket, number>;
|
|
85
|
+
/**
|
|
86
|
+
* Compatible bucket **pairs** — two adjacent tokens whose buckets appear in the same
|
|
87
|
+
* `Set` may stay in one `cn()` string chunk. Compatibility is **not transitive**: there is
|
|
88
|
+
* no `{position, sizing}` pair, so `fixed inset-0` and `overflow-auto` become **separate**
|
|
89
|
+
* literals unless **layout** tokens sit between them in sorted order; then
|
|
90
|
+
* `position↔layout` and `layout↔sizing` each justify one hop and the whole “box in flow”
|
|
91
|
+
* (place + tracks + scrollport) stays in one chunk — co-located because they jointly define
|
|
92
|
+
* stacking and scroll behavior for the same surface.
|
|
93
|
+
*
|
|
94
|
+
* @since 0.3.16-canary.0
|
|
95
|
+
*/
|
|
96
|
+
export declare const COMPATIBLE_BUCKET_SETS: ReadonlyArray<ReadonlySet<Bucket>>;
|
|
97
|
+
/**
|
|
98
|
+
* Responsive / variant prefix — Tailwind v4 aware.
|
|
99
|
+
*
|
|
100
|
+
* v3: sm: md: … — v4: `@sm:`, `@min-[600px]:`, `@[480px]:`, named `@md/sidebar:`,
|
|
101
|
+
* viewport md/sidebar:, min-[100px]: / max-[100px]:, …
|
|
102
|
+
*
|
|
103
|
+
* @since 0.3.16-canary.0
|
|
104
|
+
*/
|
|
105
|
+
export declare const RESPONSIVE_PREFIX: RegExp;
|
|
106
|
+
/**
|
|
107
|
+
* State variant stems — hoisted to module scope (not recreated per call).
|
|
108
|
+
*
|
|
109
|
+
* @since 0.3.16-canary.0
|
|
110
|
+
*/
|
|
111
|
+
export declare const STATE_PREFIXES: ReadonlySet<string>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich domain: plan Tailwind class grouping / cn-in-tv unwrap for a single file.
|
|
3
|
+
* Pure: only DomainSourceFile, source strings, and options — no I/O.
|
|
4
|
+
*/
|
|
5
|
+
import type { DomainCallExpression, DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
6
|
+
import type { GroupFileResult, PlannedGroupEdit } from "#/arrange/domain/types";
|
|
7
|
+
/**
|
|
8
|
+
* A planned replacement unwrapping one `cn()` call nested in `tv({ ... })`.
|
|
9
|
+
*
|
|
10
|
+
* @since 0.3.16-canary.0
|
|
11
|
+
*/
|
|
12
|
+
export type GroupFileUnwrapPlan = {
|
|
13
|
+
readonly start: number;
|
|
14
|
+
readonly end: number;
|
|
15
|
+
readonly replacement: string;
|
|
16
|
+
readonly call: DomainCallExpression;
|
|
17
|
+
};
|
|
18
|
+
type GroupFileUnwrapState = {
|
|
19
|
+
readonly cnInTvCalls: ReadonlyArray<DomainCallExpression>;
|
|
20
|
+
readonly unwrapReplacementByCall: ReadonlyMap<DomainCallExpression, string>;
|
|
21
|
+
readonly unwrapEdits: ReadonlyArray<GroupFileUnwrapPlan>;
|
|
22
|
+
readonly textAfterUnwrap: string;
|
|
23
|
+
readonly cnInTvNoReplacement: number;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The complete per-file plan of unwrap and grouping edits, plus the totals reported for them.
|
|
27
|
+
*
|
|
28
|
+
* @since 0.3.16-canary.0
|
|
29
|
+
*/
|
|
30
|
+
export type GroupFileWorkPlan = {
|
|
31
|
+
readonly filePath: string;
|
|
32
|
+
readonly sourceText: string;
|
|
33
|
+
readonly textAfterUnwrap: string;
|
|
34
|
+
readonly domainSfForLineNumbers: DomainSourceFile;
|
|
35
|
+
readonly domainSfGrouped: DomainSourceFile;
|
|
36
|
+
readonly cnInTvCalls: ReadonlyArray<DomainCallExpression>;
|
|
37
|
+
readonly unwrapReplacementByCall: ReadonlyMap<DomainCallExpression, string>;
|
|
38
|
+
readonly unwrapEdits: ReadonlyArray<GroupFileUnwrapPlan>;
|
|
39
|
+
readonly plannedGroupEdits: ReadonlyArray<PlannedGroupEdit>;
|
|
40
|
+
readonly cnInTvNoReplacement: number;
|
|
41
|
+
readonly reportTotal: number;
|
|
42
|
+
readonly editSitesCount: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Builds the unwrap phase's state — cn-in-tv calls, their replacements, and the text after unwrapping.
|
|
46
|
+
*
|
|
47
|
+
* @since 0.3.16-canary.0
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildGroupFileUnwrapState(domainSfInitial: DomainSourceFile, sourceText: string): GroupFileUnwrapState;
|
|
50
|
+
/**
|
|
51
|
+
* `domainSfGrouped` must be a parse of `unwrap.textAfterUnwrap` (same `text` as source).
|
|
52
|
+
* Returns `null` when there is no cn-in-tv and no grouping targets.
|
|
53
|
+
*
|
|
54
|
+
* @since 0.3.16-canary.0
|
|
55
|
+
*/
|
|
56
|
+
export declare function tryBuildGroupFileWorkPlan(input: {
|
|
57
|
+
readonly filePath: string;
|
|
58
|
+
readonly sourceText: string;
|
|
59
|
+
readonly domainSfInitial: DomainSourceFile;
|
|
60
|
+
readonly domainSfGrouped: DomainSourceFile;
|
|
61
|
+
readonly withClassName: boolean;
|
|
62
|
+
readonly unwrap: GroupFileUnwrapState;
|
|
63
|
+
}): GroupFileWorkPlan | null;
|
|
64
|
+
/**
|
|
65
|
+
* Creates the empty per-file result for a dry run with nothing to edit.
|
|
66
|
+
*
|
|
67
|
+
* @since 0.3.16-canary.0
|
|
68
|
+
*/
|
|
69
|
+
export declare function groupFileDryRunNoEdits(filePath: string): GroupFileResult;
|
|
70
|
+
/**
|
|
71
|
+
* Derives the preview-mode per-file result from a work plan's report total.
|
|
72
|
+
*
|
|
73
|
+
* @since 0.3.16-canary.0
|
|
74
|
+
*/
|
|
75
|
+
export declare function groupFilePreviewTotals(work: GroupFileWorkPlan): GroupFileResult;
|
|
76
|
+
/**
|
|
77
|
+
* Applies a work plan's grouping edits to the unwrapped text and returns the merged file body.
|
|
78
|
+
*
|
|
79
|
+
* @since 0.3.16-canary.0
|
|
80
|
+
*/
|
|
81
|
+
export declare function mergeGroupFileBodyText(work: GroupFileWorkPlan): string;
|
|
82
|
+
/**
|
|
83
|
+
* Checks whether any planned edit rewrites a JSX `className` into a `cn()` call.
|
|
84
|
+
*
|
|
85
|
+
* @since 0.3.16-canary.0
|
|
86
|
+
*/
|
|
87
|
+
export declare function groupFileEditsTouchJsxCn(work: GroupFileWorkPlan): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Counts the edits a work plan writes in apply mode — unwraps plus grouping replacements.
|
|
90
|
+
*
|
|
91
|
+
* @since 0.3.16-canary.0
|
|
92
|
+
*/
|
|
93
|
+
export declare function countPersistedGroupFileEdits(work: GroupFileWorkPlan): number;
|
|
94
|
+
/**
|
|
95
|
+
* Checks whether a work plan has no edit sites and no skipped cn-in-tv calls to report.
|
|
96
|
+
*
|
|
97
|
+
* @since 0.3.16-canary.0
|
|
98
|
+
*/
|
|
99
|
+
export declare function groupFileWorkHasNothingToReport(work: GroupFileWorkPlan): boolean;
|
|
100
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when `staticLiteralTexts` carries the **same partition** of Tailwind tokens as
|
|
3
|
+
* `suggestedGroups` from {@link suggestCnGroups}, ignoring order of arguments and
|
|
4
|
+
* order of tokens within each chunk.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function areCnTailwindPartitionsEquivalent(staticLiteralTexts: Array<string>, suggestedGroups: Array<string>): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Partitions a class string into render-pipeline-ordered groups, one per suggested `cn()` argument.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.16-canary.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function suggestCnGroups(classString: string): Array<string>;
|
|
15
|
+
/**
|
|
16
|
+
* One label per suggested group: a single bucket name, or `mixed:a+b` when that chunk
|
|
17
|
+
* spans multiple Tailwind buckets (matches `codefast arrange group` stdout).
|
|
18
|
+
*
|
|
19
|
+
* @since 0.3.16-canary.0
|
|
20
|
+
*/
|
|
21
|
+
export declare function summarizeGroupBucketLabels(groups: Array<string>): Array<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DomainSourceFile } from "#/arrange/domain/ast/ast-node";
|
|
2
|
+
/**
|
|
3
|
+
* After simplify rewrites, drop the `cn` import specifier when `cn` is no
|
|
4
|
+
* longer referenced anywhere outside the import declarations.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function dropCnImportIfUnused(sourceFile: DomainSourceFile): string;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the source text with a `cn` import present, adding one when the file lacks it.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.16-canary.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function ensureCnImport(sourceFile: DomainSourceFile, cnImportOverride?: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Escapes backslashes and double quotes for embedding in a double-quoted TypeScript string literal.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.3.16-canary.0
|
|
5
|
+
*/
|
|
6
|
+
export declare function escapeTsStringLiteralContent(group: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* Formats grouped class strings as a multiline `cn(...)` call.
|
|
9
|
+
*
|
|
10
|
+
* @since 0.3.16-canary.0
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatCnCall(groups: Array<string>, options?: {
|
|
13
|
+
trailingClassName?: boolean;
|
|
14
|
+
}): string;
|
|
15
|
+
/**
|
|
16
|
+
* Formats grouped class strings as a multiline array literal.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.3.16-canary.0
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatArray(groups: Array<string>): string;
|
|
21
|
+
/**
|
|
22
|
+
* Multiple string literals as sequential lines for insertion **inside** an existing array
|
|
23
|
+
* (e.g. `tv({ base: [ … ] })` — avoids `[[ "a", "b" ]]` when replacing one long string).
|
|
24
|
+
*
|
|
25
|
+
* @since 0.3.16-canary.0
|
|
26
|
+
*/
|
|
27
|
+
export declare function formatArrayElementsAsSiblingLines(groups: Array<string>, continuationPrefix: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Formats grouped class strings as a JSX attribute value wrapping a multiline `cn(...)` call.
|
|
30
|
+
*
|
|
31
|
+
* @since 0.3.16-canary.0
|
|
32
|
+
*/
|
|
33
|
+
export declare function formatJsxCnAttributeValue(groups: Array<string>, source: string, valueNodeStart: number): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits a class string into its whitespace-separated tokens.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.3.16-canary.0
|
|
5
|
+
*/
|
|
6
|
+
export declare function tokenizeClassString(classString: string): Array<string>;
|
|
7
|
+
/**
|
|
8
|
+
* Index of the first `:` that separates a Tailwind variant segment from the rest.
|
|
9
|
+
* Colons inside `[...]` (at positive bracket depth) are ignored so selectors like
|
|
10
|
+
* `[&_a:hover]:text-red-500` split as `[&_a:hover]:` + `text-red-500`.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.16-canary.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function indexOfFirstVariantColon(text: string): number;
|
|
15
|
+
/**
|
|
16
|
+
* Strips every variant prefix off a token, leaving the bare utility name.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* `"hover:dark:md:text-sm"` → `"text-sm"`, `"@min-[600px]:flex"` → `"flex"`,
|
|
20
|
+
* `"[&_a:hover]:text-red-500"` → `"text-red-500"`.
|
|
21
|
+
*
|
|
22
|
+
* @since 0.3.16-canary.0
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripVariants(token: string): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Bucket } from "#/arrange/domain/types";
|
|
2
|
+
/**
|
|
3
|
+
* Secondary sort inside the **composite** bucket: opacity / blend / isolation →
|
|
4
|
+
* 3D context → 3D transforms → 2D transforms → filters → will-change.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.3.16-canary.0
|
|
7
|
+
*/
|
|
8
|
+
export declare function compositeSecondaryOrder(bareUtility: string): number;
|
|
9
|
+
/**
|
|
10
|
+
* Classifies a Tailwind token into its render-pipeline bucket.
|
|
11
|
+
*
|
|
12
|
+
* @since 0.3.16-canary.0
|
|
13
|
+
*/
|
|
14
|
+
export declare function classifyToken(token: string): Bucket;
|
|
15
|
+
/**
|
|
16
|
+
* Stable key for splitting adjacent `state` / `starting` tokens in {@link suggestCnGroups}
|
|
17
|
+
* (`selector` uses {@link selectorKey}).
|
|
18
|
+
* Uses the **full variant stack** (every `:` segment outside `[…]`), not only the
|
|
19
|
+
* outermost prefix, so `@md/foo:[&>*]:w-auto` and `@md/foo:has-[…]:mt-px` stay in
|
|
20
|
+
* separate groups while `hover:opacity` still keys as `hover` + `opacity`…
|
|
21
|
+
*
|
|
22
|
+
* `data-[…]` / `aria-[…]` normalize the first segment via {@link dataAttributeStem} /
|
|
23
|
+
* {@link ariaAttributeStem} (full token required for bracket capture).
|
|
24
|
+
*
|
|
25
|
+
* @since 0.3.16-canary.0
|
|
26
|
+
*/
|
|
27
|
+
export declare function stateKey(token: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Variant key for {@link Bucket} `"selector"` tokens in {@link suggestCnGroups}.
|
|
30
|
+
* Reuses {@link stateKey} layer splitting, then normalizes common Radix SVG patterns so
|
|
31
|
+
* `[&_svg]:…` and `[&_svg:not([class*='size-'])]:…` stay in one chunk.
|
|
32
|
+
*
|
|
33
|
+
* @since 0.3.16-canary.0
|
|
34
|
+
*/
|
|
35
|
+
export declare function selectorKey(token: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Checks whether two buckets may share one group in a suggested partition.
|
|
38
|
+
*
|
|
39
|
+
* @since 0.3.16-canary.0
|
|
40
|
+
*/
|
|
41
|
+
export declare function bucketsCompatible(a: Bucket, b: Bucket): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Like {@link bucketsCompatible}, but never merge two distinct state / starting / selector variant blobs.
|
|
44
|
+
*
|
|
45
|
+
* @since 0.3.16-canary.0
|
|
46
|
+
*/
|
|
47
|
+
export declare function bucketsMergeCompatible(a: Bucket, b: Bucket): boolean;
|