@md-code/follow-architecture 0.1.0 → 0.3.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 +16 -0
- package/LICENSE +202 -0
- package/README.md +597 -126
- package/dist/aliases.d.ts +3 -0
- package/dist/aliases.js +12 -0
- package/dist/args.d.ts +14 -0
- package/dist/args.js +77 -0
- package/dist/bin/follow-architecture.d.ts +2 -0
- package/dist/bin/follow-architecture.js +23 -0
- package/dist/code-roles/classify.d.ts +11 -0
- package/dist/code-roles/classify.js +43 -0
- package/dist/code-roles/connector.d.ts +5 -0
- package/dist/code-roles/connector.js +114 -0
- package/dist/code-roles/project.d.ts +12 -0
- package/dist/code-roles/project.js +122 -0
- package/dist/code-roles/roles.d.ts +8 -0
- package/dist/code-roles/roles.js +190 -0
- package/dist/config-options.d.ts +53 -0
- package/dist/config-options.js +35 -0
- package/dist/config-project.d.ts +4 -0
- package/dist/config-project.js +74 -0
- package/dist/config-report.d.ts +19 -0
- package/dist/config-report.js +134 -0
- package/dist/config-rule.d.ts +70 -0
- package/dist/config-rule.js +118 -0
- package/dist/config-state.d.ts +14 -0
- package/dist/config-state.js +96 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.js +38 -0
- package/dist/css/index.d.ts +27 -0
- package/dist/css/index.js +140 -0
- package/dist/css/syntax/css/gate.d.ts +2 -0
- package/dist/css/syntax/css/gate.js +69 -0
- package/dist/css/syntax/css/index.d.ts +7 -0
- package/dist/css/syntax/css/index.js +41 -0
- package/dist/css/syntax/css/reference.d.ts +3 -0
- package/dist/css/syntax/css/reference.js +24 -0
- package/dist/css/syntax/language.d.ts +25 -0
- package/dist/css/syntax/language.js +69 -0
- package/dist/css/syntax/scss/index.d.ts +25 -0
- package/dist/css/syntax/scss/index.js +85 -0
- package/dist/css/syntax/scss/reference.d.ts +3 -0
- package/dist/css/syntax/scss/reference.js +11 -0
- package/dist/css/syntax/styled/document.d.ts +68 -0
- package/dist/css/syntax/styled/document.js +241 -0
- package/dist/css/syntax/styled/markup.d.ts +6 -0
- package/dist/css/syntax/styled/markup.js +76 -0
- package/dist/css/syntax/styled/template.d.ts +23 -0
- package/dist/css/syntax/styled/template.js +61 -0
- package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
- package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
- package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
- package/dist/css/syntax/tailwind/tailwind.js +118 -0
- package/dist/css/value/check.d.ts +86 -0
- package/dist/css/value/check.js +122 -0
- package/dist/css/value/expression/arithmetic.d.ts +7 -0
- package/dist/css/value/expression/arithmetic.js +69 -0
- package/dist/css/value/expression/block.d.ts +9 -0
- package/dist/css/value/expression/block.js +91 -0
- package/dist/css/value/expression/conditional.d.ts +8 -0
- package/dist/css/value/expression/conditional.js +53 -0
- package/dist/css/value/expression/index.d.ts +5 -0
- package/dist/css/value/expression/index.js +69 -0
- package/dist/css/value/expression/map.d.ts +7 -0
- package/dist/css/value/expression/map.js +113 -0
- package/dist/css/value/object/index.d.ts +5 -0
- package/dist/css/value/object/index.js +103 -0
- package/dist/css/value/object/members.d.ts +7 -0
- package/dist/css/value/object/members.js +103 -0
- package/dist/css/value/object/node.d.ts +8 -0
- package/dist/css/value/object/node.js +129 -0
- package/dist/css/value/object/path.d.ts +10 -0
- package/dist/css/value/object/path.js +146 -0
- package/dist/css/value/pieces.d.ts +61 -0
- package/dist/css/value/pieces.js +55 -0
- package/dist/css/value/resolve.d.ts +33 -0
- package/dist/css/value/resolve.js +94 -0
- package/dist/css/value/scope.d.ts +27 -0
- package/dist/css/value/scope.js +187 -0
- package/dist/css/value/substitute.d.ts +10 -0
- package/dist/css/value/substitute.js +113 -0
- package/dist/css/value/values.d.ts +23 -0
- package/dist/css/value/values.js +131 -0
- package/dist/entities/architecture.d.ts +162 -0
- package/dist/entities/architecture.js +2 -0
- package/dist/entities/ast/assignments-nodes.d.ts +10 -0
- package/dist/entities/ast/assignments-nodes.js +64 -0
- package/dist/entities/ast/assignments-raw.d.ts +6 -0
- package/dist/entities/ast/assignments-raw.js +86 -0
- package/dist/entities/ast/assignments-tagged.d.ts +5 -0
- package/dist/entities/ast/assignments-tagged.js +180 -0
- package/dist/entities/ast/assignments.d.ts +9 -0
- package/dist/entities/ast/assignments.js +78 -0
- package/dist/entities/ast/branches.d.ts +4 -0
- package/dist/entities/ast/branches.js +32 -0
- package/dist/entities/ast/calls.d.ts +6 -0
- package/dist/entities/ast/calls.js +134 -0
- package/dist/entities/ast/classes.d.ts +5 -0
- package/dist/entities/ast/classes.js +57 -0
- package/dist/entities/ast/climb.d.ts +12 -0
- package/dist/entities/ast/climb.js +17 -0
- package/dist/entities/ast/comments.d.ts +4 -0
- package/dist/entities/ast/comments.js +100 -0
- package/dist/entities/ast/declaration.d.ts +4 -0
- package/dist/entities/ast/declaration.js +26 -0
- package/dist/entities/ast/depth.d.ts +17 -0
- package/dist/entities/ast/depth.js +149 -0
- package/dist/entities/ast/enums.d.ts +6 -0
- package/dist/entities/ast/enums.js +17 -0
- package/dist/entities/ast/file-exports.d.ts +7 -0
- package/dist/entities/ast/file-exports.js +78 -0
- package/dist/entities/ast/file-facts.d.ts +13 -0
- package/dist/entities/ast/file-facts.js +35 -0
- package/dist/entities/ast/file-imports.d.ts +5 -0
- package/dist/entities/ast/file-imports.js +77 -0
- package/dist/entities/ast/file.d.ts +5 -0
- package/dist/entities/ast/file.js +22 -0
- package/dist/entities/ast/functions.d.ts +8 -0
- package/dist/entities/ast/functions.js +102 -0
- package/dist/entities/ast/heritage.d.ts +4 -0
- package/dist/entities/ast/heritage.js +36 -0
- package/dist/entities/ast/index.d.ts +6 -0
- package/dist/entities/ast/index.js +125 -0
- package/dist/entities/ast/kind.d.ts +5 -0
- package/dist/entities/ast/kind.js +28 -0
- package/dist/entities/ast/loose.d.ts +37 -0
- package/dist/entities/ast/loose.js +2 -0
- package/dist/entities/ast/modifiers.d.ts +5 -0
- package/dist/entities/ast/modifiers.js +32 -0
- package/dist/entities/ast/project.d.ts +9 -0
- package/dist/entities/ast/project.js +75 -0
- package/dist/entities/ast/properties.d.ts +11 -0
- package/dist/entities/ast/properties.js +171 -0
- package/dist/entities/ast/resolve.d.ts +16 -0
- package/dist/entities/ast/resolve.js +307 -0
- package/dist/entities/ast/tree.d.ts +29 -0
- package/dist/entities/ast/tree.js +351 -0
- package/dist/entities/ast/types.d.ts +6 -0
- package/dist/entities/ast/types.js +45 -0
- package/dist/entities/ast/usage.d.ts +11 -0
- package/dist/entities/ast/usage.js +81 -0
- package/dist/entities/ast/variables.d.ts +8 -0
- package/dist/entities/ast/variables.js +91 -0
- package/dist/entities/context.d.ts +29 -0
- package/dist/entities/context.js +2 -0
- package/dist/entities/facts.d.ts +261 -0
- package/dist/entities/facts.js +2 -0
- package/dist/entities/findings.d.ts +19 -0
- package/dist/entities/findings.js +2 -0
- package/dist/entities/kinds.d.ts +40 -0
- package/dist/entities/kinds.js +221 -0
- package/dist/entities/location/homes.d.ts +28 -0
- package/dist/entities/location/homes.js +169 -0
- package/dist/entities/location/place.d.ts +10 -0
- package/dist/entities/location/place.js +56 -0
- package/dist/entities/location/where.d.ts +17 -0
- package/dist/entities/location/where.js +218 -0
- package/dist/entities/location.d.ts +16 -0
- package/dist/entities/location.js +140 -0
- package/dist/entities/operators.d.ts +14 -0
- package/dist/entities/operators.js +30 -0
- package/dist/entities/overview/data.d.ts +43 -0
- package/dist/entities/overview/data.js +2 -0
- package/dist/entities/overview/decision.d.ts +60 -0
- package/dist/entities/overview/decision.js +2 -0
- package/dist/entities/overview/file-tree.d.ts +10 -0
- package/dist/entities/overview/file-tree.js +2 -0
- package/dist/entities/overview/finding.d.ts +58 -0
- package/dist/entities/overview/finding.js +2 -0
- package/dist/entities/overview/graph.d.ts +65 -0
- package/dist/entities/overview/graph.js +2 -0
- package/dist/entities/overview/input.d.ts +15 -0
- package/dist/entities/overview/input.js +2 -0
- package/dist/entities/overview/summaries.d.ts +79 -0
- package/dist/entities/overview/summaries.js +2 -0
- package/dist/entities/place.d.ts +5 -0
- package/dist/entities/place.js +2 -0
- package/dist/entities/queries.d.ts +9 -0
- package/dist/entities/queries.js +305 -0
- package/dist/entities/repair.d.ts +16 -0
- package/dist/entities/repair.js +23 -0
- package/dist/entities/schema.d.ts +8 -0
- package/dist/entities/schema.js +23 -0
- package/dist/entities/story.d.ts +47 -0
- package/dist/entities/story.js +2 -0
- package/dist/entities/structure-facts.d.ts +11 -0
- package/dist/entities/structure-facts.js +2 -0
- package/dist/entities/token.d.ts +23 -0
- package/dist/entities/token.js +2 -0
- package/dist/entities/tree/build.d.ts +5 -0
- package/dist/entities/tree/build.js +252 -0
- package/dist/entities/tree/entries.d.ts +7 -0
- package/dist/entities/tree/entries.js +120 -0
- package/dist/entities/tree/index.d.ts +6 -0
- package/dist/entities/tree/index.js +21 -0
- package/dist/entities/tree/match.d.ts +17 -0
- package/dist/entities/tree/match.js +176 -0
- package/dist/frameworks/angular/index.d.ts +7 -0
- package/dist/frameworks/angular/index.js +17 -0
- package/dist/frameworks/facet.d.ts +16 -0
- package/dist/frameworks/facet.js +2 -0
- package/dist/frameworks/index.d.ts +9 -0
- package/dist/frameworks/index.js +120 -0
- package/dist/frameworks/react/index.d.ts +7 -0
- package/dist/frameworks/react/index.js +214 -0
- package/dist/frameworks/vue/index.d.ts +7 -0
- package/dist/frameworks/vue/index.js +17 -0
- package/dist/invariants/index.d.ts +6 -0
- package/dist/invariants/index.js +299 -0
- package/dist/invariants/list-vars.d.ts +5 -0
- package/dist/invariants/list-vars.js +143 -0
- package/dist/invariants/name.d.ts +16 -0
- package/dist/invariants/name.js +18 -0
- package/dist/invariants/normalize.d.ts +4 -0
- package/dist/invariants/normalize.js +95 -0
- package/dist/invariants/vars.d.ts +20 -0
- package/dist/invariants/vars.js +117 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +229 -0
- package/dist/nodes/child-roles.d.ts +3 -0
- package/dist/nodes/child-roles.js +12 -0
- package/dist/nodes/children.d.ts +25 -0
- package/dist/nodes/children.js +112 -0
- package/dist/nodes/finally/emit.d.ts +6 -0
- package/dist/nodes/finally/emit.js +55 -0
- package/dist/nodes/finally/index.d.ts +8 -0
- package/dist/nodes/finally/index.js +35 -0
- package/dist/nodes/finally/queries.d.ts +5 -0
- package/dist/nodes/finally/queries.js +22 -0
- package/dist/nodes/finally/relations-access.d.ts +5 -0
- package/dist/nodes/finally/relations-access.js +46 -0
- package/dist/nodes/finally/relations-edge.d.ts +29 -0
- package/dist/nodes/finally/relations-edge.js +125 -0
- package/dist/nodes/finally/relations-group.d.ts +31 -0
- package/dist/nodes/finally/relations-group.js +103 -0
- package/dist/nodes/finally/relations.d.ts +5 -0
- package/dist/nodes/finally/relations.js +81 -0
- package/dist/nodes/finally/required.d.ts +5 -0
- package/dist/nodes/finally/required.js +90 -0
- package/dist/nodes/finally/roles.d.ts +13 -0
- package/dist/nodes/finally/roles.js +41 -0
- package/dist/nodes/finally/violation.d.ts +17 -0
- package/dist/nodes/finally/violation.js +2 -0
- package/dist/nodes/similar.d.ts +21 -0
- package/dist/nodes/similar.js +156 -0
- package/dist/pipeline-facts.d.ts +11 -0
- package/dist/pipeline-facts.js +112 -0
- package/dist/pipeline-roles.d.ts +6 -0
- package/dist/pipeline-roles.js +75 -0
- package/dist/pipeline-unroled.d.ts +14 -0
- package/dist/pipeline-unroled.js +193 -0
- package/dist/pipeline.d.ts +7 -0
- package/dist/pipeline.js +73 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +3 -0
- package/dist/report/asks.d.ts +55 -0
- package/dist/report/asks.js +50 -0
- package/dist/report/cli-report.d.ts +2 -0
- package/dist/report/cli-report.js +13 -0
- package/dist/report/config-error-guard.d.ts +8 -0
- package/dist/report/config-error-guard.js +5 -0
- package/dist/report/configErrors.d.ts +98 -0
- package/dist/report/configErrors.js +75 -0
- package/dist/report/errorTypes/codes/structure.d.ts +15 -0
- package/dist/report/errorTypes/codes/structure.js +76 -0
- package/dist/report/errorTypes/decision-maker.d.ts +23 -0
- package/dist/report/errorTypes/decision-maker.js +99 -0
- package/dist/report/errorTypes/destinations.d.ts +38 -0
- package/dist/report/errorTypes/destinations.js +147 -0
- package/dist/report/errorTypes/finding-type.d.ts +11 -0
- package/dist/report/errorTypes/finding-type.js +2 -0
- package/dist/report/errorTypes/index.d.ts +15 -0
- package/dist/report/errorTypes/index.js +45 -0
- package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
- package/dist/report/errorTypes/types/fileContents.js +34 -0
- package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
- package/dist/report/errorTypes/types/unknownRole.js +22 -0
- package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
- package/dist/report/errorTypes/types/wrongAction.js +135 -0
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
- package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
- package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
- package/dist/report/errorTypes/vocabulary/ids.js +16 -0
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
- package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
- package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
- package/dist/report/errorTypes/vocabulary/places.js +36 -0
- package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
- package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
- package/dist/report/finding-from.d.ts +9 -0
- package/dist/report/finding-from.js +103 -0
- package/dist/report/notices.d.ts +4 -0
- package/dist/report/notices.js +31 -0
- package/dist/report/render-report.d.ts +12 -0
- package/dist/report/render-report.js +142 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +169 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
- package/dist/report/user-report/data/collect.d.ts +4 -0
- package/dist/report/user-report/data/collect.js +80 -0
- package/dist/report/user-report/data/file-tree.d.ts +9 -0
- package/dist/report/user-report/data/file-tree.js +72 -0
- package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
- package/dist/report/user-report/data/finding-boundary.js +21 -0
- package/dist/report/user-report/data/finding-plan.d.ts +16 -0
- package/dist/report/user-report/data/finding-plan.js +45 -0
- package/dist/report/user-report/data/finding-title.d.ts +12 -0
- package/dist/report/user-report/data/finding-title.js +36 -0
- package/dist/report/user-report/data/findings.d.ts +10 -0
- package/dist/report/user-report/data/findings.js +171 -0
- package/dist/report/user-report/data/graph-edges.d.ts +19 -0
- package/dist/report/user-report/data/graph-edges.js +109 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
- package/dist/report/user-report/data/graph-helpers.js +67 -0
- package/dist/report/user-report/data/graph-roles.d.ts +5 -0
- package/dist/report/user-report/data/graph-roles.js +71 -0
- package/dist/report/user-report/data/graph.d.ts +11 -0
- package/dist/report/user-report/data/graph.js +90 -0
- package/dist/report/user-report/data/invariants.d.ts +7 -0
- package/dist/report/user-report/data/invariants.js +62 -0
- package/dist/report/user-report/data/nodes.d.ts +11 -0
- package/dist/report/user-report/data/nodes.js +106 -0
- package/dist/report/user-report/data/role-examples.d.ts +16 -0
- package/dist/report/user-report/data/role-examples.js +94 -0
- package/dist/report/user-report/data/role-filters.d.ts +15 -0
- package/dist/report/user-report/data/role-filters.js +79 -0
- package/dist/report/user-report/data/role-marks.d.ts +5 -0
- package/dist/report/user-report/data/role-marks.js +79 -0
- package/dist/report/user-report/data/roles.d.ts +7 -0
- package/dist/report/user-report/data/roles.js +83 -0
- package/dist/report/user-report/data/scan.d.ts +8 -0
- package/dist/report/user-report/data/scan.js +59 -0
- package/dist/report/user-report/html/shell.d.ts +3 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +8 -0
- package/dist/report/user-report/index.js +48 -0
- package/dist/report/user-report/shared/describe.d.ts +7 -0
- package/dist/report/user-report/shared/describe.js +86 -0
- package/dist/scripts/audit-report.d.ts +2 -0
- package/dist/scripts/audit-report.js +147 -0
- package/dist/utils/accumulate.d.ts +6 -0
- package/dist/utils/accumulate.js +18 -0
- package/dist/utils/article.d.ts +2 -0
- package/dist/utils/article.js +12 -0
- package/dist/utils/classify.d.ts +12 -0
- package/dist/utils/classify.js +25 -0
- package/dist/utils/configs.d.ts +25 -0
- package/dist/utils/configs.js +87 -0
- package/dist/utils/count.d.ts +7 -0
- package/dist/utils/count.js +13 -0
- package/dist/utils/dispatch.d.ts +2 -0
- package/dist/utils/dispatch.js +27 -0
- package/dist/utils/distinct.d.ts +2 -0
- package/dist/utils/distinct.js +12 -0
- package/dist/utils/field.d.ts +14 -0
- package/dist/utils/field.js +60 -0
- package/dist/utils/file-name.d.ts +2 -0
- package/dist/utils/file-name.js +11 -0
- package/dist/utils/files.d.ts +7 -0
- package/dist/utils/files.js +73 -0
- package/dist/utils/fixpoint.d.ts +2 -0
- package/dist/utils/fixpoint.js +19 -0
- package/dist/utils/gate.d.ts +2 -0
- package/dist/utils/gate.js +12 -0
- package/dist/utils/group.d.ts +3 -0
- package/dist/utils/group.js +33 -0
- package/dist/utils/host.d.ts +3 -0
- package/dist/utils/host.js +13 -0
- package/dist/utils/imports.d.ts +12 -0
- package/dist/utils/imports.js +121 -0
- package/dist/utils/judged.d.ts +5 -0
- package/dist/utils/judged.js +19 -0
- package/dist/utils/keyed.d.ts +2 -0
- package/dist/utils/keyed.js +23 -0
- package/dist/utils/map-record.d.ts +2 -0
- package/dist/utils/map-record.js +11 -0
- package/dist/utils/path-label.d.ts +6 -0
- package/dist/utils/path-label.js +35 -0
- package/dist/utils/pattern.d.ts +18 -0
- package/dist/utils/pattern.js +191 -0
- package/dist/utils/permission.d.ts +16 -0
- package/dist/utils/permission.js +16 -0
- package/dist/utils/plural.d.ts +2 -0
- package/dist/utils/plural.js +9 -0
- package/dist/utils/qualified.d.ts +2 -0
- package/dist/utils/qualified.js +21 -0
- package/dist/utils/rank.d.ts +2 -0
- package/dist/utils/rank.js +24 -0
- package/dist/utils/read-field.d.ts +12 -0
- package/dist/utils/read-field.js +50 -0
- package/dist/utils/read-when.d.ts +2 -0
- package/dist/utils/read-when.js +17 -0
- package/dist/utils/reason.d.ts +4 -0
- package/dist/utils/reason.js +9 -0
- package/dist/utils/record.d.ts +3 -0
- package/dist/utils/record.js +21 -0
- package/dist/utils/resolve.d.ts +2 -0
- package/dist/utils/resolve.js +24 -0
- package/dist/utils/search.d.ts +2 -0
- package/dist/utils/search.js +16 -0
- package/dist/utils/seen.d.ts +6 -0
- package/dist/utils/seen.js +27 -0
- package/dist/utils/span.d.ts +5 -0
- package/dist/utils/span.js +2 -0
- package/dist/utils/speak.d.ts +2 -0
- package/dist/utils/speak.js +18 -0
- package/dist/utils/split.d.ts +8 -0
- package/dist/utils/split.js +8 -0
- package/dist/utils/template.d.ts +5 -0
- package/dist/utils/template.js +5 -0
- package/dist/utils/text.d.ts +4 -0
- package/dist/utils/text.js +42 -0
- package/dist/utils/tokenize.d.ts +2 -0
- package/dist/utils/tokenize.js +13 -0
- package/dist/utils/try-read.d.ts +4 -0
- package/dist/utils/try-read.js +24 -0
- package/dist/utils/typed-field.d.ts +3 -0
- package/dist/utils/typed-field.js +16 -0
- package/dist/utils/verdicts.d.ts +4 -0
- package/dist/utils/verdicts.js +20 -0
- package/entities/operators.ts +31 -0
- package/package.json +62 -19
- package/report/errorTypes/vocabulary/ids.ts +12 -0
- package/report/errorTypes/vocabulary/phrases.ts +161 -0
- package/report/errorTypes/vocabulary/places.ts +46 -0
- package/report/errorTypes/vocabulary/verbs.ts +31 -0
- package/report/user-report/shared/describe.ts +107 -0
- package/ast.js +0 -107
- package/bin/follow-architecture.js +0 -6
- package/config.js +0 -82
- package/entities/aliases.js +0 -10
- package/entities/invariants.js +0 -134
- package/entities/nodes.js +0 -112
- package/main.js +0 -95
- package/report.js +0 -73
- package/utils.js +0 -104
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.references = void 0;
|
|
4
|
+
const SCSS_VARIABLE_RE = /#\{\s*\$([\w-]+)\s*\}|\$([\w-]+)/;
|
|
5
|
+
const scssToken = (match) => ({ name: `$${match[1] ?? match[2]}`, start: match.index, end: match.index + match[0].length, fallback: null, broken: null });
|
|
6
|
+
// The next `$x` / `#{$x}` reference in the text, or null.
|
|
7
|
+
const references = (text) => {
|
|
8
|
+
const match = SCSS_VARIABLE_RE.exec(text);
|
|
9
|
+
return match ? scssToken(match) : null;
|
|
10
|
+
};
|
|
11
|
+
exports.references = references;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Root, Node } from "postcss";
|
|
2
|
+
import { type ValueParts } from "../../value/values";
|
|
3
|
+
import { type Piece } from "../../value/pieces";
|
|
4
|
+
import type { ValueResolution } from "../../value/resolve";
|
|
5
|
+
import type { TemplateExpr, CommentFact } from "./template";
|
|
6
|
+
type ParseFn = (text: string) => Root;
|
|
7
|
+
declare const defaultParse: ParseFn;
|
|
8
|
+
declare const commentAbove: (node: Node) => CommentFact | null;
|
|
9
|
+
type Ordered = {
|
|
10
|
+
key: string | null;
|
|
11
|
+
index?: number;
|
|
12
|
+
prev?: string | null;
|
|
13
|
+
next?: string | null;
|
|
14
|
+
};
|
|
15
|
+
declare const addOrder: <T extends Ordered>(list: T[]) => T[];
|
|
16
|
+
type SelectorFact = {
|
|
17
|
+
text: string;
|
|
18
|
+
nodes: number;
|
|
19
|
+
};
|
|
20
|
+
declare const selectorFacts: (selector: string) => SelectorFact[];
|
|
21
|
+
type RuleFact = Ordered & {
|
|
22
|
+
selector: string;
|
|
23
|
+
selectors: SelectorFact[];
|
|
24
|
+
line: number | null;
|
|
25
|
+
comment: CommentFact | null;
|
|
26
|
+
parent: {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string | null;
|
|
29
|
+
} | null;
|
|
30
|
+
};
|
|
31
|
+
type DeclarationFact = Ordered & ValueParts & {
|
|
32
|
+
prop: string;
|
|
33
|
+
value: string;
|
|
34
|
+
line: number | null;
|
|
35
|
+
important: boolean;
|
|
36
|
+
rule: string | null;
|
|
37
|
+
comment: CommentFact | null;
|
|
38
|
+
reads: TemplateExpr[];
|
|
39
|
+
parsed: boolean;
|
|
40
|
+
valueFrom: number;
|
|
41
|
+
valueTo: number;
|
|
42
|
+
media: string | null;
|
|
43
|
+
pieces: Piece[];
|
|
44
|
+
variableName: string | null;
|
|
45
|
+
resolution?: ValueResolution;
|
|
46
|
+
};
|
|
47
|
+
type DocumentOptions = {
|
|
48
|
+
exprs?: TemplateExpr[];
|
|
49
|
+
parse?: ParseFn;
|
|
50
|
+
syntax?: string;
|
|
51
|
+
variableNameOf?: (prop: string) => string | null;
|
|
52
|
+
};
|
|
53
|
+
type DocumentFacts = {
|
|
54
|
+
syntax: string;
|
|
55
|
+
parsed: boolean;
|
|
56
|
+
rules: RuleFact[];
|
|
57
|
+
declarations: DeclarationFact[];
|
|
58
|
+
comments: CommentFact[];
|
|
59
|
+
leading: CommentFact | null;
|
|
60
|
+
literals: (ValueParts["literals"][number] & {
|
|
61
|
+
prop: string;
|
|
62
|
+
})[];
|
|
63
|
+
vars: string[];
|
|
64
|
+
exprs: TemplateExpr[];
|
|
65
|
+
};
|
|
66
|
+
declare const documentFacts: (text: string, { exprs, parse, syntax, variableNameOf }?: DocumentOptions) => DocumentFacts;
|
|
67
|
+
export { documentFacts, defaultParse, commentAbove, addOrder, selectorFacts };
|
|
68
|
+
export type { DocumentFacts, DocumentOptions, ParseFn, RuleFact, DeclarationFact, SelectorFact };
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.selectorFacts = exports.addOrder = exports.commentAbove = exports.defaultParse = exports.documentFacts = void 0;
|
|
30
|
+
// The DOCUMENT reader: one postcss walk shared by every syntax. It is a FUNCTION
|
|
31
|
+
// of a `parse`, not a class — `.css`, another stylesheet syntax, a
|
|
32
|
+
// styled-components template after substitution, and anything added later differ
|
|
33
|
+
// only in the parser handed in.
|
|
34
|
+
//
|
|
35
|
+
// What it produces is the fact set a rule queries:
|
|
36
|
+
// rules selector (text + parsed AST), line, parent at-rule, the comment
|
|
37
|
+
// above it, and the ORDER (`index`, `prev`, `next`) — order is a
|
|
38
|
+
// fact, "must be sorted" is a policy written in the config
|
|
39
|
+
// declarations prop, value, line, !important, the rule it belongs to, the
|
|
40
|
+
// comment above it, the value's literals/vars/exprs, and the order
|
|
41
|
+
// comments every comment in the document, with its line
|
|
42
|
+
// leading the comment block immediately above the first node — the `@file`
|
|
43
|
+
// style doc a stylesheet is expected to carry
|
|
44
|
+
//
|
|
45
|
+
// Nothing here knows about Tailwind or the architecture.
|
|
46
|
+
const postcss = __importStar(require("postcss"));
|
|
47
|
+
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
48
|
+
const values_1 = require("../../value/values");
|
|
49
|
+
const pieces_1 = require("../../value/pieces");
|
|
50
|
+
const notices_1 = require("../../../report/notices");
|
|
51
|
+
const reason_1 = require("../../../utils/reason");
|
|
52
|
+
const try_read_1 = require("../../../utils/try-read");
|
|
53
|
+
const defaultParse = (text) => postcss.parse(text, { from: undefined });
|
|
54
|
+
exports.defaultParse = defaultParse;
|
|
55
|
+
// The comment immediately above a node, or null. `prev()` answers the node's own
|
|
56
|
+
// sibling; only a comment is a doc, anything else is code.
|
|
57
|
+
const commentAbove = (node) => {
|
|
58
|
+
const prev = node.prev();
|
|
59
|
+
if (!prev || prev.type !== "comment")
|
|
60
|
+
return null;
|
|
61
|
+
const comment = prev;
|
|
62
|
+
return { text: comment.text, line: comment.source?.start?.line ?? null };
|
|
63
|
+
};
|
|
64
|
+
exports.commentAbove = commentAbove;
|
|
65
|
+
const keyOf = (item) => item.key;
|
|
66
|
+
// Stamp the order facts onto a list, in place: each item learns its index and the
|
|
67
|
+
// keys of its neighbours. The list is the producer's own, freshly built.
|
|
68
|
+
const addOrder = (list) => {
|
|
69
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
70
|
+
const item = list[index];
|
|
71
|
+
item.index = index;
|
|
72
|
+
item.prev = index > 0 ? keyOf(list[index - 1]) : null;
|
|
73
|
+
item.next = index < list.length - 1 ? keyOf(list[index + 1]) : null;
|
|
74
|
+
}
|
|
75
|
+
return list;
|
|
76
|
+
};
|
|
77
|
+
exports.addOrder = addOrder;
|
|
78
|
+
// A document the parser rejects is not read at all — and the reader is told
|
|
79
|
+
// which one, so "no declarations found" never passes for a clean file. The
|
|
80
|
+
// guarded read is the shared one; the notice is this reader's own voice.
|
|
81
|
+
const parseOf = (text, parse) => (0, try_read_1.readOrFallback)(text, parse ?? defaultParse, null, (e) => {
|
|
82
|
+
(0, notices_1.notice)("a CSS document could not be parsed", (0, reason_1.reasonOf)(e));
|
|
83
|
+
});
|
|
84
|
+
const selectorFacts = (selector) => {
|
|
85
|
+
const parsed = [];
|
|
86
|
+
try {
|
|
87
|
+
(0, postcss_selector_parser_1.default)((selectors) => {
|
|
88
|
+
selectors.each((one) => {
|
|
89
|
+
parsed.push({ text: String(one), nodes: one.nodes.length });
|
|
90
|
+
});
|
|
91
|
+
}).processSync(selector);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
// A selector we cannot READ is still a selector: text only, and the reason
|
|
95
|
+
// is reported.
|
|
96
|
+
const e = error;
|
|
97
|
+
(0, notices_1.notice)(`the selector \`${selector}\` could not be read`, (0, reason_1.reasonOf)(e));
|
|
98
|
+
}
|
|
99
|
+
return parsed;
|
|
100
|
+
};
|
|
101
|
+
exports.selectorFacts = selectorFacts;
|
|
102
|
+
// A declaration value can quote TypeScript: `${({ spec }) => spec.colors.section}`.
|
|
103
|
+
// It is not part of the CSS text, so the link is made by POSITION: the
|
|
104
|
+
// substitution leaves the SAME NUMBER OF CHARACTERS where the expression was
|
|
105
|
+
// (blanks), so a declaration's own source offsets still point at the place the
|
|
106
|
+
// expression occupies. No marker is written into the value, and no line is
|
|
107
|
+
// guessed.
|
|
108
|
+
const readsIn = (exprs, from, to) => exprs.filter((expr) => expr.offset >= from && expr.offset < to);
|
|
109
|
+
// The container a rule sits in, as a fact: an at-rule reports its name (`media`,
|
|
110
|
+
// `supports`), anything else its own type. No word compared.
|
|
111
|
+
const parentOf = (rule) => {
|
|
112
|
+
const parent = rule.parent;
|
|
113
|
+
if (!parent)
|
|
114
|
+
return null;
|
|
115
|
+
const name = "name" in parent ? parent.name : null;
|
|
116
|
+
return { type: parent.type, name };
|
|
117
|
+
};
|
|
118
|
+
const ruleFact = (rule) => ({
|
|
119
|
+
key: rule.selector,
|
|
120
|
+
selector: rule.selector,
|
|
121
|
+
selectors: selectorFacts(rule.selector),
|
|
122
|
+
line: rule.source?.start?.line ?? null,
|
|
123
|
+
comment: commentAbove(rule),
|
|
124
|
+
parent: parentOf(rule),
|
|
125
|
+
});
|
|
126
|
+
// The rule a declaration belongs to, or null when it sits at the document root.
|
|
127
|
+
const ruleOf = (decl) => (decl.parent?.type === "rule" ? decl.parent.selector : null);
|
|
128
|
+
// The declaration's own span in the (elided) text — the same offsets the
|
|
129
|
+
// expressions were recorded at.
|
|
130
|
+
const spanOf = (decl) => {
|
|
131
|
+
const from = decl.source?.start?.offset ?? 0;
|
|
132
|
+
const to = decl.source?.end?.offset ?? from;
|
|
133
|
+
return { from, to };
|
|
134
|
+
};
|
|
135
|
+
// Where the VALUE starts in the source text: the declaration starts at the
|
|
136
|
+
// property, so the `raws.between` postcss kept (`: `, `:\n `) is the distance
|
|
137
|
+
// from the property's end to the value's first character. Any other reading
|
|
138
|
+
// (`indexOf(":")`) would mistake a `:` inside a value for the separator.
|
|
139
|
+
const valueFromOf = (decl, exprs) => {
|
|
140
|
+
const start = decl.source?.start?.offset ?? 0;
|
|
141
|
+
const between = decl.raws?.between ?? ":";
|
|
142
|
+
const afterProp = start + decl.prop.length + between.length;
|
|
143
|
+
// A value that STARTS with an expression keeps its leading blanks in
|
|
144
|
+
// `raws.between` (they look like whitespace to postcss), so the expression
|
|
145
|
+
// would fall outside the value range and be silently dropped. The recorded
|
|
146
|
+
// expression offset is the true start then.
|
|
147
|
+
const firstExpression = exprs
|
|
148
|
+
.filter((expr) => expr.offset >= start + decl.prop.length && expr.offset < (decl.source?.end?.offset ?? expr.offset + 1))
|
|
149
|
+
.sort((a, b) => a.offset - b.offset)[0];
|
|
150
|
+
return firstExpression && firstExpression.offset < afterProp ? firstExpression.offset : afterProp;
|
|
151
|
+
};
|
|
152
|
+
const endOffsetOf = (decl) => decl.source?.end?.offset ?? decl.source?.start?.offset ?? 0;
|
|
153
|
+
const semicolonLength = (decl, text) => (text[endOffsetOf(decl) - 1] === ";" ? 1 : 0);
|
|
154
|
+
const importantLength = (decl) => (decl.important ? (decl.raws?.important ?? "!important").length : 0);
|
|
155
|
+
// Where the value ENDS: postcss's declaration end includes the `;` and (when
|
|
156
|
+
// present) `!important`, neither of which is part of the value. Only those two
|
|
157
|
+
// are trimmed — the blank placeholders an expression left are part of the value.
|
|
158
|
+
const valueToOf = (decl, text) => endOffsetOf(decl) - semicolonLength(decl, text) - importantLength(decl);
|
|
159
|
+
// The media query a declaration is scoped to, as a fact: the nearest enclosing
|
|
160
|
+
// `@media` block, its params verbatim. A variable declared once inside a media
|
|
161
|
+
// query is a VARIANT of the same variable, so the query is what keeps the two
|
|
162
|
+
// apart — the reader does not decide which one wins.
|
|
163
|
+
const MEDIA_AT_RULES = new Set(["media"]);
|
|
164
|
+
const mediaOf = (decl) => {
|
|
165
|
+
let parent = decl.parent;
|
|
166
|
+
while (parent) {
|
|
167
|
+
// A declaration's parent chain is postcss's own nodes; the structural
|
|
168
|
+
// properties of an at-rule are checked with `in`, so no cast is needed.
|
|
169
|
+
if (parent.type === "atrule" && "params" in parent && "name" in parent) {
|
|
170
|
+
const name = String(parent.name);
|
|
171
|
+
if (MEDIA_AT_RULES.has(name))
|
|
172
|
+
return `@${name} ${String(parent.params).trim()}`;
|
|
173
|
+
}
|
|
174
|
+
parent = parent.parent;
|
|
175
|
+
}
|
|
176
|
+
return null;
|
|
177
|
+
};
|
|
178
|
+
const declarationFact = (decl, exprs, text, variableNameOf) => {
|
|
179
|
+
const value = String(decl.value);
|
|
180
|
+
const classification = (0, values_1.classifyValue)(value, decl.source?.start?.line ?? null);
|
|
181
|
+
const { from, to } = spanOf(decl);
|
|
182
|
+
const valueFrom = valueFromOf(decl, exprs);
|
|
183
|
+
const valueTo = valueToOf(decl, text);
|
|
184
|
+
return {
|
|
185
|
+
key: decl.prop,
|
|
186
|
+
prop: decl.prop,
|
|
187
|
+
value,
|
|
188
|
+
line: decl.source?.start?.line ?? null,
|
|
189
|
+
important: Boolean(decl.important),
|
|
190
|
+
rule: ruleOf(decl),
|
|
191
|
+
comment: commentAbove(decl),
|
|
192
|
+
...classification,
|
|
193
|
+
reads: readsIn(exprs, from, to),
|
|
194
|
+
valueFrom,
|
|
195
|
+
valueTo,
|
|
196
|
+
media: mediaOf(decl),
|
|
197
|
+
// The value as PIECES, read from the document text — not from
|
|
198
|
+
// `decl.value`, which postcss trims: a value that is only an expression
|
|
199
|
+
// (`box-shadow: ${x};`) would arrive empty and lose its question.
|
|
200
|
+
pieces: (0, pieces_1.piecesOfRange)(text, exprs, { from: valueFrom, to: valueTo, base: 0 }),
|
|
201
|
+
variableName: variableNameOf(decl.prop),
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
const documentFacts = (text, { exprs = [], parse, syntax = "css", variableNameOf = () => null } = {}) => {
|
|
205
|
+
const root = parseOf(text, parse);
|
|
206
|
+
const quoted = exprs ?? [];
|
|
207
|
+
// A document the parser REJECTS is not CSS: the facts are empty, and `parsed`
|
|
208
|
+
// says so. Reading it anyway would report declarations nobody wrote.
|
|
209
|
+
if (!root) {
|
|
210
|
+
return { syntax, parsed: false, rules: [], declarations: [], comments: [], leading: null, literals: [], vars: [], exprs: quoted };
|
|
211
|
+
}
|
|
212
|
+
const comments = [];
|
|
213
|
+
root.walkComments((comment) => {
|
|
214
|
+
comments.push({ text: comment.text, line: comment.source?.start?.line ?? null });
|
|
215
|
+
});
|
|
216
|
+
const rules = [];
|
|
217
|
+
root.walkRules((rule) => {
|
|
218
|
+
rules.push(ruleFact(rule));
|
|
219
|
+
});
|
|
220
|
+
const declarations = [];
|
|
221
|
+
const literals = [];
|
|
222
|
+
const vars = [];
|
|
223
|
+
root.walkDecls((decl) => {
|
|
224
|
+
const fact = declarationFact(decl, quoted, text, variableNameOf);
|
|
225
|
+
declarations.push(fact);
|
|
226
|
+
literals.push(...fact.literals.map((literal) => ({ ...literal, prop: decl.prop })));
|
|
227
|
+
vars.push(...fact.vars);
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
syntax,
|
|
231
|
+
parsed: true,
|
|
232
|
+
rules: addOrder(rules),
|
|
233
|
+
declarations: addOrder(declarations),
|
|
234
|
+
comments,
|
|
235
|
+
leading: comments[0] ?? null,
|
|
236
|
+
literals,
|
|
237
|
+
vars: [...new Set(vars)],
|
|
238
|
+
exprs: quoted,
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
exports.documentFacts = documentFacts;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.attachClasses = void 0;
|
|
4
|
+
// The class ATTRIBUTE of an element, whatever the framework calls it:
|
|
5
|
+
// `className` in React, `class` in Vue/Angular/HTML. The reading belongs to CSS —
|
|
6
|
+
// a class list is a declaration list written in a string — so the whole facet
|
|
7
|
+
// shares it: `frameworks/*` says which element is which, this says what it is
|
|
8
|
+
// styled with.
|
|
9
|
+
//
|
|
10
|
+
// Only a STATIC string is a declaration list. `{cn(...)}` is code, and guessing at
|
|
11
|
+
// it would invent facts.
|
|
12
|
+
const ts_morph_1 = require("ts-morph");
|
|
13
|
+
const tree_1 = require("../../../entities/ast/tree");
|
|
14
|
+
const variables_1 = require("../../../entities/ast/variables");
|
|
15
|
+
const frameworks_1 = require("../../../frameworks");
|
|
16
|
+
const resolve_1 = require("../../../utils/resolve");
|
|
17
|
+
const dispatch_1 = require("../../../utils/dispatch");
|
|
18
|
+
const host_1 = require("../../../utils/host");
|
|
19
|
+
const tailwind_1 = require("../tailwind/tailwind");
|
|
20
|
+
// A class list may be WRITTEN ONCE and named: `const cls = "flex p-4"` then
|
|
21
|
+
// `className={cls}`. That is still a static declaration list — the binding's
|
|
22
|
+
// initializer is a string literal the AST already recorded, so the reading
|
|
23
|
+
// follows the NAME to the text instead of guessing at code. The walk is the
|
|
24
|
+
// shared `resolveReference`; the table (this file's candidates) and the verdicts
|
|
25
|
+
// (a module-scope, never-reassigned string binding) are this reader's own.
|
|
26
|
+
const staticStringOf = (candidates, expr) => {
|
|
27
|
+
if (!expr || !ts_morph_1.Node.isIdentifier(expr))
|
|
28
|
+
return null;
|
|
29
|
+
return (0, resolve_1.resolveReference)(expr.getText(), (name) => candidates.find((c) => c.name === name && c.kind?.own?.is === "VariableDeclaration" && !c.location?.nested), (binding) => {
|
|
30
|
+
if (binding.mutable)
|
|
31
|
+
return null;
|
|
32
|
+
const value = binding.kind?.initializer?.value;
|
|
33
|
+
return typeof value === "string" ? value : null;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
// The attribute's value as a declaration list, dispatched on the parser's kind
|
|
37
|
+
// (the shared dispatch): a literal initializer is read by the AST's ONE
|
|
38
|
+
// literal-text reading (`literalTextOf` — a quoted string and a backtick string
|
|
39
|
+
// without substitutions are both static); a `{name}` expression is read only
|
|
40
|
+
// when it resolves to a static string binding of this file. `{cn(...)}`, a
|
|
41
|
+
// ternary, a reassigned `let` stay unread — guessing at code would invent facts.
|
|
42
|
+
const classLiteralOf = (candidates, attribute) => {
|
|
43
|
+
const readers = new Map([
|
|
44
|
+
[tree_1.SK.StringLiteral, variables_1.literalTextOf],
|
|
45
|
+
[tree_1.SK.NoSubstitutionTemplateLiteral, variables_1.literalTextOf],
|
|
46
|
+
[tree_1.SK.JsxExpression, (node) => (ts_morph_1.Node.isJsxExpression(node) ? staticStringOf(candidates, node.getExpression()) : null)],
|
|
47
|
+
]);
|
|
48
|
+
return (0, dispatch_1.dispatchOn)(attribute.getInitializer(), (node) => node.getKind(), readers, () => null);
|
|
49
|
+
};
|
|
50
|
+
// Attach one class list to the piece that declares it. The attribute's own line
|
|
51
|
+
// travels with every class it carries: a report can point at the exact line the
|
|
52
|
+
// class list is written on.
|
|
53
|
+
const attachClassList = (candidates, attribute, literal) => {
|
|
54
|
+
const line = attribute.getStartLineNumber();
|
|
55
|
+
const host = (0, host_1.hostOf)(candidates, line);
|
|
56
|
+
if (!host)
|
|
57
|
+
return;
|
|
58
|
+
host.css = host.css ?? {};
|
|
59
|
+
host.css.classes = [...(host.css.classes ?? []), ...(0, tailwind_1.classFacts)(literal).map((fact) => ({ ...fact, line }))];
|
|
60
|
+
};
|
|
61
|
+
// Every opening element, whichever spelling it uses. WHICH attribute holds the
|
|
62
|
+
// class list is the framework's own answer (`frameworks.*`); nothing here spells
|
|
63
|
+
// a framework's attribute name.
|
|
64
|
+
const attachClasses = (candidates, { sf }) => {
|
|
65
|
+
const names = (0, frameworks_1.classAttributes)();
|
|
66
|
+
for (const attribute of sf.getDescendantsOfKind(tree_1.SK.JsxAttribute)) {
|
|
67
|
+
if (!names.has(attribute.getNameNode().getText()))
|
|
68
|
+
continue;
|
|
69
|
+
const literal = classLiteralOf(candidates, attribute);
|
|
70
|
+
if (!literal)
|
|
71
|
+
continue;
|
|
72
|
+
attachClassList(candidates, attribute, literal);
|
|
73
|
+
}
|
|
74
|
+
return candidates;
|
|
75
|
+
};
|
|
76
|
+
exports.attachClasses = attachClasses;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Expression, type TaggedTemplateExpression } from "ts-morph";
|
|
2
|
+
type TemplateExpr = {
|
|
3
|
+
index: number;
|
|
4
|
+
text: string;
|
|
5
|
+
line: number;
|
|
6
|
+
offset: number;
|
|
7
|
+
};
|
|
8
|
+
type TemplateSource = {
|
|
9
|
+
text: string;
|
|
10
|
+
exprs: TemplateExpr[];
|
|
11
|
+
};
|
|
12
|
+
type TemplateLiteralNode = ReturnType<TaggedTemplateExpression["getTemplate"]>;
|
|
13
|
+
declare const templateLiteralSource: (template: TemplateLiteralNode) => TemplateSource;
|
|
14
|
+
declare const templateSource: (node: TaggedTemplateExpression) => TemplateSource;
|
|
15
|
+
declare const expressionNodesOf: (template: TemplateLiteralNode) => Expression[];
|
|
16
|
+
declare const leadingCommentOf: (node: TaggedTemplateExpression) => {
|
|
17
|
+
text: string;
|
|
18
|
+
line: number | null;
|
|
19
|
+
} | null;
|
|
20
|
+
type LeadingComment = ReturnType<typeof leadingCommentOf>;
|
|
21
|
+
type CommentFact = NonNullable<LeadingComment>;
|
|
22
|
+
export { templateSource, templateLiteralSource, expressionNodesOf, leadingCommentOf };
|
|
23
|
+
export type { TemplateExpr, TemplateSource, TemplateLiteralNode, LeadingComment, CommentFact };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.leadingCommentOf = exports.expressionNodesOf = exports.templateLiteralSource = exports.templateSource = void 0;
|
|
4
|
+
// The TEMPLATE reader: a tagged template's CSS text, plus the map back to the
|
|
5
|
+
// TypeScript expressions it quotes. This is syntax-agnostic — it reads the
|
|
6
|
+
// template's literal parts and spans, whatever the tag is called. The CONTENT
|
|
7
|
+
// gate (is this CSS at all?) lives with the `css` language (`syntax/css/gate`);
|
|
8
|
+
// this only reads what is there.
|
|
9
|
+
const ts_morph_1 = require("ts-morph");
|
|
10
|
+
const tree_1 = require("../../../entities/ast/tree");
|
|
11
|
+
const climb_1 = require("../../../entities/ast/climb");
|
|
12
|
+
// The template as parseable CSS plus the map back to the expressions it quotes.
|
|
13
|
+
// An expression contributes NOTHING to the CSS text: it is not a value, it is a
|
|
14
|
+
// question for TypeScript. It is REPLACED by blanks of its own length, so the
|
|
15
|
+
// text stays parseable and every declaration's source offsets still point at the
|
|
16
|
+
// place the expression occupies — the link is a position, not a marker and not a
|
|
17
|
+
// guess.
|
|
18
|
+
const templateLiteralSource = (template) => {
|
|
19
|
+
if (ts_morph_1.Node.isNoSubstitutionTemplateLiteral(template))
|
|
20
|
+
return { text: template.getLiteralText(), exprs: [] };
|
|
21
|
+
const head = template.getHead();
|
|
22
|
+
const spans = template.getTemplateSpans();
|
|
23
|
+
let text = head.getLiteralText();
|
|
24
|
+
const exprs = [];
|
|
25
|
+
for (const [index, span] of spans.entries()) {
|
|
26
|
+
const expression = span.getExpression();
|
|
27
|
+
const source = expression.getText();
|
|
28
|
+
const literal = span.getLiteral().getLiteralText();
|
|
29
|
+
exprs.push({ index, text: source, line: expression.getStartLineNumber(), offset: text.length });
|
|
30
|
+
text += " ".repeat(source.length) + literal;
|
|
31
|
+
}
|
|
32
|
+
return { text, exprs };
|
|
33
|
+
};
|
|
34
|
+
exports.templateLiteralSource = templateLiteralSource;
|
|
35
|
+
const templateSource = (node) => templateLiteralSource(node.getTemplate());
|
|
36
|
+
exports.templateSource = templateSource;
|
|
37
|
+
// The TypeScript expressions a template quotes, in the SAME order as
|
|
38
|
+
// `TemplateExpr.index` — the resolver's way from a blank back to its question.
|
|
39
|
+
const expressionNodesOf = (template) => (ts_morph_1.Node.isNoSubstitutionTemplateLiteral(template) ? [] : template.getTemplateSpans().map((span) => span.getExpression()));
|
|
40
|
+
exports.expressionNodesOf = expressionNodesOf;
|
|
41
|
+
// The comment a declaration is documented by, read from the TypeScript source
|
|
42
|
+
// (above the template, above the `const`) — because a styled template's own
|
|
43
|
+
// comment lives outside the CSS text.
|
|
44
|
+
// A template literal carries no comment of its own: the doc of `const Title =
|
|
45
|
+
// styled.h2`…`` hangs on the STATEMENT, so the climb goes through the binding —
|
|
46
|
+
// the shared climb (`entities/ast/climb`), with this reader's own wrappers.
|
|
47
|
+
const TEMPLATE_HOLDERS = new Set([tree_1.SK.TaggedTemplateExpression, tree_1.SK.VariableDeclaration, tree_1.SK.VariableDeclarationList]);
|
|
48
|
+
const commentHolder = (node) => (0, climb_1.climbFrom)(node, {
|
|
49
|
+
isHolder: (holder) => holder.getKind() === tree_1.SK.VariableStatement,
|
|
50
|
+
passesThrough: (holder) => TEMPLATE_HOLDERS.has(holder.getKind()),
|
|
51
|
+
}).node;
|
|
52
|
+
const leadingCommentOf = (node) => {
|
|
53
|
+
const holder = commentHolder(node);
|
|
54
|
+
const ranges = holder.getLeadingCommentRanges();
|
|
55
|
+
if (!ranges.length)
|
|
56
|
+
return null;
|
|
57
|
+
const last = ranges[ranges.length - 1];
|
|
58
|
+
const line = last.getPos() >= 0 ? node.getSourceFile().getLineAndColumnAtPos(last.getPos()).line : null;
|
|
59
|
+
return { text: last.getText().replace(/^\/\*\*?|\*\/$/g, "").trim(), line };
|
|
60
|
+
};
|
|
61
|
+
exports.leadingCommentOf = leadingCommentOf;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Config } from "tailwindcss/types/config";
|
|
2
|
+
import type { Rule, AtRule } from "postcss";
|
|
3
|
+
interface TailwindContext {
|
|
4
|
+
readonly candidateRuleCache: Map<string, object>;
|
|
5
|
+
}
|
|
6
|
+
type GeneratedRule = [meta: {
|
|
7
|
+
layer: string;
|
|
8
|
+
}, rule: Rule | AtRule];
|
|
9
|
+
interface SetupContextUtils {
|
|
10
|
+
createContext: (config: Config, changedContent?: {
|
|
11
|
+
file: string | null;
|
|
12
|
+
content: string;
|
|
13
|
+
}[]) => TailwindContext;
|
|
14
|
+
}
|
|
15
|
+
interface GenerateRulesModule {
|
|
16
|
+
generateRules: (candidates: Iterable<string>, context: TailwindContext) => GeneratedRule[];
|
|
17
|
+
}
|
|
18
|
+
declare const baseConfig: () => Config;
|
|
19
|
+
declare const loadSetup: () => SetupContextUtils;
|
|
20
|
+
declare const loadGenerate: () => GenerateRulesModule;
|
|
21
|
+
declare const loadVersion: () => string;
|
|
22
|
+
export { baseConfig, loadSetup, loadGenerate, loadVersion };
|
|
23
|
+
export type { TailwindContext, GeneratedRule };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadVersion = exports.loadGenerate = exports.loadSetup = exports.baseConfig = void 0;
|
|
7
|
+
// Tailwind itself, loaded through a TYPED view. The public config types ship with
|
|
8
|
+
// the package; the two internal generators the facet reads (`createContext`,
|
|
9
|
+
// `generateRules`) do not, so their surface is modelled here once. Nothing here
|
|
10
|
+
// enumerates Tailwind's vocabulary — the generator is asked, so new classes appear
|
|
11
|
+
// by themselves on `pnpm update`.
|
|
12
|
+
//
|
|
13
|
+
// `createRequire` (not a bare `require`) keeps the load at run time, the same way
|
|
14
|
+
// the config loader reads a JS module.
|
|
15
|
+
const node_module_1 = require("node:module");
|
|
16
|
+
const resolveConfig_1 = __importDefault(require("tailwindcss/resolveConfig"));
|
|
17
|
+
const defaultConfig_1 = __importDefault(require("tailwindcss/defaultConfig"));
|
|
18
|
+
const requireModule = (0, node_module_1.createRequire)(__filename);
|
|
19
|
+
// The default config, resolved with no content files and no plugins: the facet
|
|
20
|
+
// asks what a class SETS, not what a particular project's build produces.
|
|
21
|
+
const baseConfig = () => (0, resolveConfig_1.default)({ ...defaultConfig_1.default, content: { files: [] }, plugins: [] });
|
|
22
|
+
exports.baseConfig = baseConfig;
|
|
23
|
+
const loadSetup = () => {
|
|
24
|
+
const module = requireModule("tailwindcss/lib/lib/setupContextUtils");
|
|
25
|
+
return module;
|
|
26
|
+
};
|
|
27
|
+
exports.loadSetup = loadSetup;
|
|
28
|
+
const loadGenerate = () => {
|
|
29
|
+
const module = requireModule("tailwindcss/lib/lib/generateRules");
|
|
30
|
+
return module;
|
|
31
|
+
};
|
|
32
|
+
exports.loadGenerate = loadGenerate;
|
|
33
|
+
const loadVersion = () => {
|
|
34
|
+
const manifest = requireModule("tailwindcss/package.json");
|
|
35
|
+
return manifest.version;
|
|
36
|
+
};
|
|
37
|
+
exports.loadVersion = loadVersion;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type TailwindContext } from "./tailwind-engine";
|
|
2
|
+
type Engine = {
|
|
3
|
+
version: string;
|
|
4
|
+
propertiesOf: ReturnType<typeof propertiesReader>;
|
|
5
|
+
};
|
|
6
|
+
declare const propertiesReader: (context: TailwindContext) => ((candidate: string) => string[]);
|
|
7
|
+
declare const engine: () => Engine | false | null;
|
|
8
|
+
declare const structureOf: (raw: string) => {
|
|
9
|
+
raw: string;
|
|
10
|
+
variants: string[];
|
|
11
|
+
utility: string;
|
|
12
|
+
base: string;
|
|
13
|
+
value: string | null;
|
|
14
|
+
arbitrary: boolean;
|
|
15
|
+
negative: boolean;
|
|
16
|
+
};
|
|
17
|
+
type ClassStructure = ReturnType<typeof structureOf>;
|
|
18
|
+
declare const utilityFacts: (raw: string) => ClassStructure & {
|
|
19
|
+
known: boolean | null;
|
|
20
|
+
properties: string[];
|
|
21
|
+
};
|
|
22
|
+
type ClassFact = ReturnType<typeof utilityFacts>;
|
|
23
|
+
declare const classFacts: (text: string | null | undefined) => ClassFact[];
|
|
24
|
+
declare const resetEngine: () => void;
|
|
25
|
+
export { classFacts, utilityFacts, structureOf, engine, resetEngine };
|
|
26
|
+
export type { ClassFact, ClassStructure };
|