@md-code/follow-architecture 0.1.1 → 0.3.2
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 +37 -0
- package/LICENSE +202 -0
- package/README.md +1420 -139
- package/dist/aliases.d.ts +3 -0
- package/dist/aliases.js +12 -0
- package/dist/args.d.ts +18 -0
- package/dist/args.js +94 -0
- package/dist/bin/follow-architecture.d.ts +2 -0
- package/dist/bin/follow-architecture.js +23 -0
- package/dist/closure-project.d.ts +4 -0
- package/dist/closure-project.js +132 -0
- package/dist/code-entities/classify.d.ts +11 -0
- package/dist/code-entities/classify.js +45 -0
- package/dist/code-entities/connector.d.ts +8 -0
- package/dist/code-entities/connector.js +119 -0
- package/dist/code-entities/entities.d.ts +9 -0
- package/dist/code-entities/entities.js +227 -0
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +259 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +105 -0
- package/dist/config-options.d.ts +76 -0
- package/dist/config-options.js +52 -0
- package/dist/config-project.d.ts +4 -0
- package/dist/config-project.js +92 -0
- package/dist/config-report.d.ts +19 -0
- package/dist/config-report.js +161 -0
- package/dist/config-rule.d.ts +95 -0
- package/dist/config-rule.js +211 -0
- package/dist/config-state.d.ts +25 -0
- package/dist/config-state.js +269 -0
- package/dist/config.d.ts +107 -0
- package/dist/config.js +38 -0
- package/dist/css/index.d.ts +31 -0
- package/dist/css/index.js +251 -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 +51 -0
- package/dist/css/syntax/css/reference.d.ts +3 -0
- package/dist/css/syntax/css/reference.js +36 -0
- package/dist/css/syntax/language.d.ts +25 -0
- package/dist/css/syntax/language.js +81 -0
- package/dist/css/syntax/scss/index.d.ts +25 -0
- package/dist/css/syntax/scss/index.js +95 -0
- package/dist/css/syntax/scss/reference.d.ts +3 -0
- package/dist/css/syntax/scss/reference.js +17 -0
- package/dist/css/syntax/styled/document.d.ts +68 -0
- package/dist/css/syntax/styled/document.js +261 -0
- package/dist/css/syntax/styled/markup.d.ts +6 -0
- package/dist/css/syntax/styled/markup.js +84 -0
- package/dist/css/syntax/styled/tags.d.ts +2 -0
- package/dist/css/syntax/styled/tags.js +22 -0
- package/dist/css/syntax/styled/template.d.ts +23 -0
- package/dist/css/syntax/styled/template.js +67 -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 +73 -0
- package/dist/css/value/expression/block.d.ts +9 -0
- package/dist/css/value/expression/block.js +92 -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 +73 -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 +113 -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 +134 -0
- package/dist/css/value/object/path.d.ts +10 -0
- package/dist/css/value/object/path.js +152 -0
- package/dist/css/value/pieces.d.ts +61 -0
- package/dist/css/value/pieces.js +65 -0
- package/dist/css/value/resolve.d.ts +33 -0
- package/dist/css/value/resolve.js +104 -0
- package/dist/css/value/scope.d.ts +28 -0
- package/dist/css/value/scope.js +205 -0
- package/dist/css/value/substitute.d.ts +10 -0
- package/dist/css/value/substitute.js +145 -0
- package/dist/css/value/values.d.ts +23 -0
- package/dist/css/value/values.js +131 -0
- package/dist/entities/architecture.d.ts +165 -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 +139 -0
- package/dist/entities/ast/assignments-tagged.d.ts +5 -0
- package/dist/entities/ast/assignments-tagged.js +195 -0
- package/dist/entities/ast/assignments.d.ts +9 -0
- package/dist/entities/ast/assignments.js +80 -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 +150 -0
- package/dist/entities/ast/classes.d.ts +5 -0
- package/dist/entities/ast/classes.js +61 -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 +5 -0
- package/dist/entities/ast/comments.js +130 -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 +166 -0
- package/dist/entities/ast/enums.d.ts +6 -0
- package/dist/entities/ast/enums.js +17 -0
- package/dist/entities/ast/export-chain.d.ts +15 -0
- package/dist/entities/ast/export-chain.js +171 -0
- package/dist/entities/ast/file-exports.d.ts +7 -0
- package/dist/entities/ast/file-exports.js +101 -0
- package/dist/entities/ast/file-facts.d.ts +16 -0
- package/dist/entities/ast/file-facts.js +64 -0
- package/dist/entities/ast/file-imports.d.ts +5 -0
- package/dist/entities/ast/file-imports.js +100 -0
- package/dist/entities/ast/file.d.ts +5 -0
- package/dist/entities/ast/file.js +23 -0
- package/dist/entities/ast/functions.d.ts +8 -0
- package/dist/entities/ast/functions.js +111 -0
- package/dist/entities/ast/heritage.d.ts +4 -0
- package/dist/entities/ast/heritage.js +44 -0
- package/dist/entities/ast/index.d.ts +9 -0
- package/dist/entities/ast/index.js +181 -0
- package/dist/entities/ast/kind.d.ts +5 -0
- package/dist/entities/ast/kind.js +34 -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 +106 -0
- package/dist/entities/ast/properties.d.ts +11 -0
- package/dist/entities/ast/properties.js +176 -0
- package/dist/entities/ast/resolve.d.ts +16 -0
- package/dist/entities/ast/resolve.js +317 -0
- package/dist/entities/ast/tree.d.ts +31 -0
- package/dist/entities/ast/tree.js +518 -0
- package/dist/entities/ast/types.d.ts +6 -0
- package/dist/entities/ast/types.js +46 -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 +284 -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 +332 -0
- package/dist/entities/location/homes.d.ts +28 -0
- package/dist/entities/location/homes.js +195 -0
- package/dist/entities/location/place.d.ts +10 -0
- package/dist/entities/location/place.js +63 -0
- package/dist/entities/location/where.d.ts +19 -0
- package/dist/entities/location/where.js +277 -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 +82 -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 +81 -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 +375 -0
- package/dist/entities/repair.d.ts +16 -0
- package/dist/entities/repair.js +29 -0
- package/dist/entities/schema.d.ts +22 -0
- package/dist/entities/schema.js +81 -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 +6 -0
- package/dist/entities/tree/build.js +313 -0
- package/dist/entities/tree/entries.d.ts +7 -0
- package/dist/entities/tree/entries.js +145 -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 +190 -0
- package/dist/fa-index.d.ts +16 -0
- package/dist/fa-index.js +165 -0
- package/dist/fa-open.d.ts +51 -0
- package/dist/fa-open.js +242 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +232 -0
- package/dist/fa-values.d.ts +37 -0
- package/dist/fa-values.js +104 -0
- package/dist/facts-record.d.ts +45 -0
- package/dist/facts-record.js +297 -0
- package/dist/frameworks/angular/index.d.ts +7 -0
- package/dist/frameworks/angular/index.js +18 -0
- package/dist/frameworks/facet.d.ts +18 -0
- package/dist/frameworks/facet.js +15 -0
- package/dist/frameworks/index.d.ts +9 -0
- package/dist/frameworks/index.js +134 -0
- package/dist/frameworks/react/index.d.ts +7 -0
- package/dist/frameworks/react/index.js +237 -0
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +7 -0
- package/dist/frameworks/vue/index.js +18 -0
- package/dist/ignore.d.ts +3 -0
- package/dist/ignore.js +62 -0
- package/dist/index-file.d.ts +43 -0
- package/dist/index-file.js +218 -0
- package/dist/index-run.d.ts +39 -0
- package/dist/index-run.js +217 -0
- package/dist/index-zone.d.ts +25 -0
- package/dist/index-zone.js +219 -0
- package/dist/main.d.ts +10 -0
- package/dist/main.js +411 -0
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +25 -0
- package/dist/nodes/children.js +165 -0
- package/dist/nodes/finally/emit.d.ts +6 -0
- package/dist/nodes/finally/emit.js +71 -0
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -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 +25 -0
- package/dist/nodes/finally/relations-access.d.ts +5 -0
- package/dist/nodes/finally/relations-access.js +50 -0
- package/dist/nodes/finally/relations-edge.d.ts +29 -0
- package/dist/nodes/finally/relations-edge.js +148 -0
- package/dist/nodes/finally/relations-group.d.ts +31 -0
- package/dist/nodes/finally/relations-group.js +106 -0
- package/dist/nodes/finally/relations.d.ts +5 -0
- package/dist/nodes/finally/relations.js +85 -0
- package/dist/nodes/finally/required.d.ts +5 -0
- package/dist/nodes/finally/required.js +92 -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 +178 -0
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/pipeline-entities.d.ts +6 -0
- package/dist/pipeline-entities.js +79 -0
- package/dist/pipeline-facts.d.ts +12 -0
- package/dist/pipeline-facts.js +114 -0
- package/dist/pipeline-unclassified.d.ts +14 -0
- package/dist/pipeline-unclassified.js +188 -0
- package/dist/pipeline.d.ts +7 -0
- package/dist/pipeline.js +28 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +3 -0
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +55 -0
- package/dist/report/asks.js +60 -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 +126 -0
- package/dist/report/configErrors.js +121 -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 +109 -0
- package/dist/report/errorTypes/destinations.d.ts +38 -0
- package/dist/report/errorTypes/destinations.js +165 -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 +55 -0
- package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
- package/dist/report/errorTypes/types/fileContents.js +40 -0
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/unknownEntity.js +27 -0
- package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
- package/dist/report/errorTypes/types/wrongAction.js +140 -0
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
- package/dist/report/errorTypes/types/wrongPlacement.js +67 -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 +187 -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 +108 -0
- package/dist/report/notices.d.ts +9 -0
- package/dist/report/notices.js +57 -0
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +12 -0
- package/dist/report/render-report.js +145 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +188 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +1262 -0
- package/dist/report/user-report/data/collect.d.ts +4 -0
- package/dist/report/user-report/data/collect.js +93 -0
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/entities.js +88 -0
- package/dist/report/user-report/data/entity-examples.d.ts +16 -0
- package/dist/report/user-report/data/entity-examples.js +136 -0
- package/dist/report/user-report/data/entity-filters.d.ts +15 -0
- package/dist/report/user-report/data/entity-filters.js +79 -0
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/entity-marks.js +79 -0
- package/dist/report/user-report/data/file-tree.d.ts +9 -0
- package/dist/report/user-report/data/file-tree.js +80 -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 +181 -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-entities.d.ts +6 -0
- package/dist/report/user-report/data/graph-entities.js +158 -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.d.ts +12 -0
- package/dist/report/user-report/data/graph.js +97 -0
- package/dist/report/user-report/data/nodes.d.ts +11 -0
- package/dist/report/user-report/data/nodes.js +116 -0
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/rules.js +62 -0
- package/dist/report/user-report/data/scan.d.ts +8 -0
- package/dist/report/user-report/data/scan.js +69 -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 +58 -0
- package/dist/report/user-report/shared/describe.d.ts +7 -0
- package/dist/report/user-report/shared/describe.js +86 -0
- package/dist/rules/index.d.ts +7 -0
- package/dist/rules/index.js +327 -0
- package/dist/rules/list-vars.d.ts +5 -0
- package/dist/rules/list-vars.js +149 -0
- package/dist/rules/name.d.ts +16 -0
- package/dist/rules/name.js +18 -0
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/rules/normalize.js +108 -0
- package/dist/rules/vars.d.ts +22 -0
- package/dist/rules/vars.js +117 -0
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.d.ts +2 -0
- package/dist/scripts/audit-report.js +157 -0
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +282 -0
- package/dist/usage-mode.d.ts +7 -0
- package/dist/usage-mode.js +16 -0
- package/dist/usage-pass.d.ts +19 -0
- package/dist/usage-pass.js +136 -0
- package/dist/usage-prepare.d.ts +2 -0
- package/dist/usage-prepare.js +22 -0
- package/dist/usage-sweep.d.ts +10 -0
- package/dist/usage-sweep.js +264 -0
- package/dist/utils/accumulate.d.ts +6 -0
- package/dist/utils/accumulate.js +18 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +173 -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 +97 -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 +14 -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 +77 -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 +16 -0
- package/dist/utils/imports.d.ts +12 -0
- package/dist/utils/imports.js +185 -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/packages.d.ts +15 -0
- package/dist/utils/packages.js +207 -0
- package/dist/utils/path-label.d.ts +6 -0
- package/dist/utils/path-label.js +37 -0
- package/dist/utils/pattern.d.ts +19 -0
- package/dist/utils/pattern.js +231 -0
- package/dist/utils/permission.d.ts +16 -0
- package/dist/utils/permission.js +18 -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 +21 -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 +21 -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 +18 -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 +101 -47
- package/report/errorTypes/vocabulary/ids.ts +17 -0
- package/report/errorTypes/vocabulary/phrases.ts +181 -0
- package/report/errorTypes/vocabulary/places.ts +51 -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 -101
- package/entities/aliases.js +0 -10
- package/entities/invariants.js +0 -134
- package/entities/nodes.js +0 -112
- package/main.js +0 -96
- package/plugin.js +0 -5
- package/report.js +0 -73
- package/utils.js +0 -104
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type Project, type SourceFile, type TaggedTemplateExpression } from "ts-morph";
|
|
2
|
+
import type { Candidate } from "@md-code/follow-architecture/entities/facts";
|
|
3
|
+
import { tokenize } from "@md-code/follow-architecture/utils/tokenize";
|
|
4
|
+
import { hostOf } from "@md-code/follow-architecture/utils/host";
|
|
5
|
+
import { type LeadingComment } from "./syntax/styled/template";
|
|
6
|
+
import type { DocumentFacts } from "./syntax/styled/document";
|
|
7
|
+
import { type ObjectLiteral } from "./value/scope";
|
|
8
|
+
import { type FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
9
|
+
import * as syntax from "./syntax/language";
|
|
10
|
+
declare const materialiseResolution: (template: {
|
|
11
|
+
declarations?: FieldValue;
|
|
12
|
+
}, objects: readonly ObjectLiteral[]) => void;
|
|
13
|
+
declare const restoreResolution: (fact: object, rel: string, project: Project) => void;
|
|
14
|
+
declare const templateFacts: (node: TaggedTemplateExpression, options?: {
|
|
15
|
+
objects?: readonly ObjectLiteral[];
|
|
16
|
+
record?: boolean;
|
|
17
|
+
}) => DocumentFacts & {
|
|
18
|
+
tag: string;
|
|
19
|
+
line: number | null;
|
|
20
|
+
startLine: number | null;
|
|
21
|
+
comment: LeadingComment;
|
|
22
|
+
};
|
|
23
|
+
type TemplateFact = ReturnType<typeof templateFacts>;
|
|
24
|
+
declare const stylesheetFacts: (rel: string, text: string) => DocumentFacts | null;
|
|
25
|
+
declare const attachToCandidates: (candidates: Candidate[], { sf, record }: {
|
|
26
|
+
sf: SourceFile;
|
|
27
|
+
record?: boolean;
|
|
28
|
+
}) => Candidate[];
|
|
29
|
+
declare const forgetResolutions: (candidates: readonly Candidate[]) => void;
|
|
30
|
+
export { attachToCandidates, stylesheetFacts, templateFacts, materialiseResolution, restoreResolution, forgetResolutions, hostOf, tokenize, syntax, };
|
|
31
|
+
export type { TemplateFact };
|
|
@@ -0,0 +1,251 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.syntax = exports.tokenize = exports.hostOf = exports.forgetResolutions = exports.restoreResolution = exports.materialiseResolution = exports.templateFacts = exports.stylesheetFacts = exports.attachToCandidates = void 0;
|
|
37
|
+
// CSS as a FACT SOURCE, next to `ast` (which is the language). The engine has no
|
|
38
|
+
// opinion about styles: it says what is written — which declarations, which
|
|
39
|
+
// values were typed by hand, which `var(--x)` and which object paths were read —
|
|
40
|
+
// and the rules decide what that means.
|
|
41
|
+
//
|
|
42
|
+
// The facet is FUNCTIONS over a SYNTAX, never a closed implementation:
|
|
43
|
+
//
|
|
44
|
+
// syntax/language.ts the StyleLanguage contract + the registry
|
|
45
|
+
// syntax/css/ `.css`: postcss parser, variables, `var()` references,
|
|
46
|
+
// and the content gate
|
|
47
|
+
// syntax/<other>/ another stylesheet language with its own variable
|
|
48
|
+
// notation (`$x`), registered beside the first
|
|
49
|
+
// syntax/styled/ one tagged template's text + expression map, the style
|
|
50
|
+
// tags, the document reader, and the class attribute
|
|
51
|
+
// syntax/tailwind/ class names, read through Tailwind itself
|
|
52
|
+
// value/ what a value resolves to (pieces, fold, path, scope)
|
|
53
|
+
// index.ts this file: the entry points the pipeline calls
|
|
54
|
+
//
|
|
55
|
+
// Adding a language is a `syntax.register()`, not a change here; a rule written
|
|
56
|
+
// against `css.declarations` keeps working because the SHAPE is the contract.
|
|
57
|
+
//
|
|
58
|
+
// CSS-in-JS is the same pipeline over a substituted template: `${expr}` becomes
|
|
59
|
+
// blanks of its own length, the position map keeps the link back to TypeScript,
|
|
60
|
+
// so a declaration value can be reported as "read from an object" or "typed by
|
|
61
|
+
// hand".
|
|
62
|
+
const path = __importStar(require("node:path"));
|
|
63
|
+
const tree_1 = require("@md-code/follow-architecture/entities/ast/tree");
|
|
64
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
65
|
+
const markup_1 = require("./syntax/styled/markup");
|
|
66
|
+
const tags_1 = require("./syntax/styled/tags");
|
|
67
|
+
const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
|
|
68
|
+
const tokenize_1 = require("@md-code/follow-architecture/utils/tokenize");
|
|
69
|
+
Object.defineProperty(exports, "tokenize", { enumerable: true, get: function () { return tokenize_1.tokenize; } });
|
|
70
|
+
const host_1 = require("@md-code/follow-architecture/utils/host");
|
|
71
|
+
Object.defineProperty(exports, "hostOf", { enumerable: true, get: function () { return host_1.hostOf; } });
|
|
72
|
+
const template_1 = require("./syntax/styled/template");
|
|
73
|
+
const resolve_1 = require("./value/resolve");
|
|
74
|
+
const scope_1 = require("./value/scope");
|
|
75
|
+
const field_1 = require("@md-code/follow-architecture/utils/field");
|
|
76
|
+
const gate_1 = require("./syntax/css/gate");
|
|
77
|
+
const syntax = __importStar(require("./syntax/language"));
|
|
78
|
+
exports.syntax = syntax;
|
|
79
|
+
// The language that reads a substituted template: whatever is registered under
|
|
80
|
+
// `css`, so a consumer that replaces the language replaces the reading too.
|
|
81
|
+
const cssLanguage = () => {
|
|
82
|
+
const language = syntax.byId("css");
|
|
83
|
+
if (!language)
|
|
84
|
+
throw configError.styleLanguageIncomplete();
|
|
85
|
+
return language;
|
|
86
|
+
};
|
|
87
|
+
// Every declaration of a document gets its RESOLUTION: the concrete value(s) it
|
|
88
|
+
// reaches with `var()`, `$var` and `${expression}` walked to the bottom, the
|
|
89
|
+
// object literal and media variant each reading belongs to, the grammar's verdict,
|
|
90
|
+
// and what could not be read. Nothing is dropped silently.
|
|
91
|
+
const withResolutions = (facts, context) => ({
|
|
92
|
+
...facts,
|
|
93
|
+
declarations: facts.declarations.map((declaration) => ({
|
|
94
|
+
...declaration,
|
|
95
|
+
resolution: (0, resolve_1.resolveDeclaration)(declaration, context),
|
|
96
|
+
})),
|
|
97
|
+
});
|
|
98
|
+
const RESOLUTIONS = new WeakMap();
|
|
99
|
+
const objectSignature = (objects) => objects
|
|
100
|
+
.map((object) => `${object.name}|${object.node.getSourceFile().getFilePath()}|${object.node.getStart()}`)
|
|
101
|
+
.join(",");
|
|
102
|
+
// Resolve one template fact against an explicit object set (cached by that set)
|
|
103
|
+
// and write the readings onto the fact's declarations — the fact a rule's
|
|
104
|
+
// filter reads. Idempotent: asking twice reuses the cached readings.
|
|
105
|
+
const materialiseResolution = (template, objects) => {
|
|
106
|
+
const entry = RESOLUTIONS.get(template);
|
|
107
|
+
if (!entry)
|
|
108
|
+
return;
|
|
109
|
+
const key = objectSignature(objects);
|
|
110
|
+
let resolved = entry.cache.get(key);
|
|
111
|
+
if (!resolved) {
|
|
112
|
+
resolved = entry.resolve(objects);
|
|
113
|
+
entry.cache.set(key, resolved);
|
|
114
|
+
}
|
|
115
|
+
const declarations = template.declarations;
|
|
116
|
+
if (!(0, field_1.isList)(declarations))
|
|
117
|
+
return;
|
|
118
|
+
// Facts are plain, freshly built data; the declarations carry an open index
|
|
119
|
+
// the filter engine reads, so the resolution is written onto them in place.
|
|
120
|
+
declarations.forEach((declaration, index) => {
|
|
121
|
+
if ((0, field_1.isObj)(declaration))
|
|
122
|
+
Object.assign(declaration, { resolution: resolved?.declarations[index]?.resolution });
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
exports.materialiseResolution = materialiseResolution;
|
|
126
|
+
// Facts for one styled/CSS template held by a candidate. The substituted template
|
|
127
|
+
// is plain CSS, so it is read by the `css` language whatever file it sits in.
|
|
128
|
+
// RESOLUTION is NOT computed here: classification and the raw readings never need
|
|
129
|
+
// it, so it is attached only when a rule asks (`materialiseResolution`). A
|
|
130
|
+
// caller that already knows its objects (a unit test) may pass them to resolve
|
|
131
|
+
// eagerly.
|
|
132
|
+
// The resolution capability, registered for a template FACT: recompute the
|
|
133
|
+
// declarations against an explicit object set, caching each set. Kept beside the
|
|
134
|
+
// fact (a WeakMap), so the fact itself stays plain data.
|
|
135
|
+
const registerResolution = (fact, sourceFile, expressions) => {
|
|
136
|
+
const resolve = (objects) => withResolutions(fact, {
|
|
137
|
+
scope: (0, scope_1.withObjects)((0, scope_1.scopeFromProject)(sourceFile), objects),
|
|
138
|
+
expression: (index) => expressions[index] ?? null,
|
|
139
|
+
});
|
|
140
|
+
RESOLUTIONS.set(fact, { resolve, cache: new Map() });
|
|
141
|
+
};
|
|
142
|
+
// A template fact that came back from a RECORD carries no capability (a record
|
|
143
|
+
// is data). The node is the one thing a record cannot hold, so it is found by
|
|
144
|
+
// the position the fact kept: the same template, the same expressions.
|
|
145
|
+
// The fact arrives as an opaque object (a record is JSON, not a class): the two
|
|
146
|
+
// things this needs — its position and proof that it is a document fact — are
|
|
147
|
+
// read with checks, so nothing is asserted into existence.
|
|
148
|
+
const startOf = (fact) => {
|
|
149
|
+
const start = "start" in fact ? fact.start : undefined;
|
|
150
|
+
return typeof start === "number" ? start : undefined;
|
|
151
|
+
};
|
|
152
|
+
const isDocumentFacts = (fact) => "syntax" in fact && "parsed" in fact && "declarations" in fact;
|
|
153
|
+
const restoreResolution = (fact, rel, project) => {
|
|
154
|
+
const start = startOf(fact);
|
|
155
|
+
if (start === undefined || RESOLUTIONS.has(fact) || !isDocumentFacts(fact))
|
|
156
|
+
return;
|
|
157
|
+
const sourceFile = project.getSourceFile(path.resolve(project.getCompilerOptions().baseUrl ?? ".", rel));
|
|
158
|
+
// `start` is the template's first character, which sits on its tag — walking
|
|
159
|
+
// up from there lands on the template itself, the node `templateFacts` read.
|
|
160
|
+
const found = sourceFile?.getDescendantAtPos(start)?.getFirstAncestorByKind(tree_1.SK.TaggedTemplateExpression);
|
|
161
|
+
if (!sourceFile || !found || found.getStart() !== start)
|
|
162
|
+
return;
|
|
163
|
+
registerResolution(fact, sourceFile, (0, template_1.expressionNodesOf)(found.getTemplate()));
|
|
164
|
+
};
|
|
165
|
+
exports.restoreResolution = restoreResolution;
|
|
166
|
+
const templateFacts = (node, options) => {
|
|
167
|
+
const { text, exprs } = (0, template_1.templateSource)(node);
|
|
168
|
+
const facts = cssLanguage().facts(text, { exprs });
|
|
169
|
+
// The expressions the template quoted, by index — the way a blank in the
|
|
170
|
+
// substituted text gets back to its TypeScript question.
|
|
171
|
+
const expressions = (0, template_1.expressionNodesOf)(node.getTemplate());
|
|
172
|
+
const sourceFile = node.getSourceFile();
|
|
173
|
+
// Declaration lines are numbered INSIDE the template text (postcss counts
|
|
174
|
+
// from 1 at the first character after the backtick). `startLine` is the
|
|
175
|
+
// template's own line in the FILE, so a consumer can place any declaration
|
|
176
|
+
// on the file's line grid: startLine + decl.line - 1.
|
|
177
|
+
const startLine = node.getStartLineNumber();
|
|
178
|
+
const fact = {
|
|
179
|
+
tag: node.getTag().getText(),
|
|
180
|
+
line: startLine,
|
|
181
|
+
startLine,
|
|
182
|
+
// The template's own position: the ONE thing a record needs to get the
|
|
183
|
+
// node back, and the reason `restoreResolution` can exist at all.
|
|
184
|
+
start: node.getStart(),
|
|
185
|
+
comment: (0, template_1.leadingCommentOf)(node),
|
|
186
|
+
...facts,
|
|
187
|
+
};
|
|
188
|
+
// A fact read FOR A RECORD is plain data and outlives the project that read it:
|
|
189
|
+
// the capability holds the `SourceFile`, so registering it would keep a whole
|
|
190
|
+
// project alive through one string of JSON. The check restores it by position,
|
|
191
|
+
// and only when a rule actually asks (`restoreResolution`).
|
|
192
|
+
if (!options?.record)
|
|
193
|
+
registerResolution(fact, sourceFile, expressions);
|
|
194
|
+
if (options?.objects)
|
|
195
|
+
materialiseResolution(fact, options.objects);
|
|
196
|
+
return fact;
|
|
197
|
+
};
|
|
198
|
+
exports.templateFacts = templateFacts;
|
|
199
|
+
// Facts for a whole stylesheet file — the same shape, so one rule reads both. The
|
|
200
|
+
// language is chosen by extension; a syntax nobody registered produces nothing
|
|
201
|
+
// instead of being read as CSS. A stylesheet has no TypeScript expressions and
|
|
202
|
+
// reads no object literals, so it resolves eagerly against its own variables.
|
|
203
|
+
const stylesheetFacts = (rel, text) => {
|
|
204
|
+
const language = syntax.forFile(rel);
|
|
205
|
+
if (!language)
|
|
206
|
+
return null;
|
|
207
|
+
const facts = language.facts(text);
|
|
208
|
+
return withResolutions(facts, { scope: (0, scope_1.scopeFromFacts)(facts), expression: () => null });
|
|
209
|
+
};
|
|
210
|
+
exports.stylesheetFacts = stylesheetFacts;
|
|
211
|
+
// Every CSS template in the file, as its own fact set. ANY tagged template is
|
|
212
|
+
// offered to the grammar: the ones whose substituted text reads as CSS become
|
|
213
|
+
// facts, the rest (SQL, GraphQL, prose, …) do not. The tag's name is recorded as a
|
|
214
|
+
// fact and never decides for a body that has text — with ONE exception: a template
|
|
215
|
+
// whose tag is a styled-components style word AND whose substituted text is
|
|
216
|
+
// nothing but blanks is a stylesheet all the same, because a body made only of
|
|
217
|
+
// `${…}` IS the style block (`css`${…}``), its declarations living inside the
|
|
218
|
+
// interpolation. See `syntax/styled/tags`.
|
|
219
|
+
const styledTemplates = (sf) => sf.getDescendantsOfKind(tree_1.SK.TaggedTemplateExpression).filter((node) => {
|
|
220
|
+
const { text } = (0, template_1.templateSource)(node);
|
|
221
|
+
return (0, gate_1.isStylesheet)(text) || (text.trim() === "" && (0, tags_1.isStyleTag)(node.getTag().getText()));
|
|
222
|
+
});
|
|
223
|
+
// The one entry point the pipeline calls: attach `framework.css.*` to the
|
|
224
|
+
// candidates — templates first, then the class lists (`framework.tailwind.*`, CSS
|
|
225
|
+
// written in an attribute rather than in a template). Same facet, same call: a
|
|
226
|
+
// caller attaches the style facts once. The namespace is written through
|
|
227
|
+
// `frameworks/facet#attach`, so a component or test reading already on the
|
|
228
|
+
// candidate is kept and the style facts sit beside it.
|
|
229
|
+
const attachToCandidates = (candidates, { sf, record = false }) => {
|
|
230
|
+
for (const template of styledTemplates(sf).map((node) => templateFacts(node, { record }))) {
|
|
231
|
+
const host = (0, host_1.hostOf)(candidates, template.line);
|
|
232
|
+
if (!host)
|
|
233
|
+
continue;
|
|
234
|
+
const css = host.framework?.css ?? {};
|
|
235
|
+
const templates = Array.isArray(css.templates) ? css.templates : [];
|
|
236
|
+
(0, facet_1.attach)(host, { css: { ...css, templates: [...templates, template] } });
|
|
237
|
+
}
|
|
238
|
+
(0, markup_1.attachClasses)(candidates, { sf });
|
|
239
|
+
return candidates;
|
|
240
|
+
};
|
|
241
|
+
exports.attachToCandidates = attachToCandidates;
|
|
242
|
+
// A checked file's templates need their capability no longer: the check has
|
|
243
|
+
// already written every reading onto the fact. The capability is a closure over
|
|
244
|
+
// the live source (a record cannot hold a node), so keeping it after the check is
|
|
245
|
+
// what pins the file's whole project in memory for the rest of the run.
|
|
246
|
+
const forgetResolutions = (candidates) => {
|
|
247
|
+
for (const candidate of candidates)
|
|
248
|
+
for (const template of candidate.framework?.css?.templates ?? [])
|
|
249
|
+
RESOLUTIONS.delete(template);
|
|
250
|
+
};
|
|
251
|
+
exports.forgetResolutions = forgetResolutions;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStylesheet = void 0;
|
|
4
|
+
const check_1 = require("@md-code/follow-architecture/css/value/check");
|
|
5
|
+
const gate_1 = require("@md-code/follow-architecture/utils/gate");
|
|
6
|
+
const try_read_1 = require("@md-code/follow-architecture/utils/try-read");
|
|
7
|
+
const read_when_1 = require("@md-code/follow-architecture/utils/read-when");
|
|
8
|
+
const language_1 = require("@md-code/follow-architecture/css/syntax/language");
|
|
9
|
+
// A property is CSS when the grammar knows it: a custom property (`--x`), or a
|
|
10
|
+
// name (vendor prefix and hack stripped by the parser) in css-tree's dictionary.
|
|
11
|
+
const knownProperty = (raw) => {
|
|
12
|
+
if (/^--[\w-]+$/.test(raw))
|
|
13
|
+
return true;
|
|
14
|
+
if (raw.startsWith("$"))
|
|
15
|
+
return false;
|
|
16
|
+
try {
|
|
17
|
+
const parsed = check_1.cssTree.property(raw);
|
|
18
|
+
if (parsed.custom)
|
|
19
|
+
return true;
|
|
20
|
+
const properties = check_1.cssTree.lexer.properties ?? {};
|
|
21
|
+
return Object.hasOwn(properties, parsed.basename);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
// What one document walk counts: the structure, and how much of it the grammar
|
|
28
|
+
// recognises. An empty selector, or one opening with a brace/quote/bracket, is a
|
|
29
|
+
// data format's block (JSON, an INI section) — not a CSS selector.
|
|
30
|
+
const shapeOf = (root) => {
|
|
31
|
+
const shape = { declarations: 0, known: 0, rules: 0, badSelector: 0 };
|
|
32
|
+
root.walkDecls((decl) => {
|
|
33
|
+
shape.declarations += 1;
|
|
34
|
+
if (knownProperty(decl.prop))
|
|
35
|
+
shape.known += 1;
|
|
36
|
+
});
|
|
37
|
+
root.walkRules((rule) => {
|
|
38
|
+
shape.rules += 1;
|
|
39
|
+
const selector = String(rule.selector ?? "").trim();
|
|
40
|
+
if (!selector || /^[[{"']/.test(selector))
|
|
41
|
+
shape.badSelector += 1;
|
|
42
|
+
});
|
|
43
|
+
return shape;
|
|
44
|
+
};
|
|
45
|
+
// The verdicts over the counted shape: nothing structured is not a stylesheet
|
|
46
|
+
// (an empty template, a comment); a data-format selector is another language;
|
|
47
|
+
// declarations the grammar does not know at all (YAML, a variable-only fragment)
|
|
48
|
+
// are a different syntax's business, not this facet's. The decision ("admit when
|
|
49
|
+
// none rejects") is the shared gate; the verdicts are CSS's own.
|
|
50
|
+
const noStructure = ({ declarations, rules }) => !declarations && !rules;
|
|
51
|
+
const hasBadSelector = ({ badSelector }) => badSelector > 0;
|
|
52
|
+
const noKnownProperty = ({ declarations, known }) => declarations > 0 && known === 0;
|
|
53
|
+
const isStylesheetShape = (shape) => (0, gate_1.admitsWhenNoneReject)(shape, [noStructure, hasBadSelector, noKnownProperty]);
|
|
54
|
+
// One document's parse: the shared guarded read (a text the parser rejects is
|
|
55
|
+
// simply not CSS — silence, because a SQL template reaching here is normal).
|
|
56
|
+
const parseOrNull = (text) => {
|
|
57
|
+
const language = (0, language_1.byId)("css");
|
|
58
|
+
if (!language)
|
|
59
|
+
return null;
|
|
60
|
+
return (0, try_read_1.readOrFallback)(text, language.parse, null);
|
|
61
|
+
};
|
|
62
|
+
// A document is read only when it parsed — the shared qualified read; the shape
|
|
63
|
+
// verdicts are CSS's own. The registered `css` language does the parsing, so a
|
|
64
|
+
// consumer that replaces the language replaces the gate's reading too.
|
|
65
|
+
const isStylesheet = (text) => {
|
|
66
|
+
const root = parseOrNull(text);
|
|
67
|
+
return (0, read_when_1.readWhen)(root, (parsed) => parsed !== null, (parsed) => isStylesheetShape(shapeOf(parsed)), false);
|
|
68
|
+
};
|
|
69
|
+
exports.isStylesheet = isStylesheet;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Root } from "postcss";
|
|
2
|
+
import { type DocumentFacts, type DocumentOptions } from "@md-code/follow-architecture/css/syntax/styled/document";
|
|
3
|
+
declare const id = "css";
|
|
4
|
+
declare const exts: string[];
|
|
5
|
+
declare const parse: (text: string) => Root;
|
|
6
|
+
declare const facts: (text: string, options?: DocumentOptions) => DocumentFacts;
|
|
7
|
+
export { id, exts, parse, facts };
|
|
@@ -0,0 +1,51 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.facts = exports.parse = exports.exts = exports.id = void 0;
|
|
37
|
+
// Plain CSS. The reference language: it is only a parser plus the shared
|
|
38
|
+
// document reading, so everything it reports is available to every other syntax.
|
|
39
|
+
const postcss = __importStar(require("postcss"));
|
|
40
|
+
const document_1 = require("@md-code/follow-architecture/css/syntax/styled/document");
|
|
41
|
+
const id = "css";
|
|
42
|
+
exports.id = id;
|
|
43
|
+
const exts = [".css"];
|
|
44
|
+
exports.exts = exts;
|
|
45
|
+
const parse = (text) => postcss.parse(text, { from: undefined });
|
|
46
|
+
exports.parse = parse;
|
|
47
|
+
// A CSS custom property (`--x`) is this syntax's variable declaration; a plain
|
|
48
|
+
// `color` is not. The name kept is exactly what a `var(--x)` reference names.
|
|
49
|
+
const variableName = (prop) => (prop.startsWith("--") ? prop : null);
|
|
50
|
+
const facts = (text, options = {}) => (0, document_1.documentFacts)(text, { ...options, parse, syntax: id, variableNameOf: variableName });
|
|
51
|
+
exports.facts = facts;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.references = void 0;
|
|
4
|
+
// How a CSS value REFERS to a variable: `var(--x)`. The reader is the language's
|
|
5
|
+
// own — the substitution walk only asks every registered language for its next
|
|
6
|
+
// reference and takes the earliest. A reference may carry a fallback
|
|
7
|
+
// (`var(--x, 4px)`), which is used only when the name is undeclared.
|
|
8
|
+
const text_1 = require("@md-code/follow-architecture/utils/text");
|
|
9
|
+
const CSS_VARIABLE_RE = /\bvar\(\s*(--[\w-]+)/;
|
|
10
|
+
const cssToken = (text, match) => {
|
|
11
|
+
const open = text.indexOf("(", match.index);
|
|
12
|
+
const close = (0, text_1.closingParen)(text, open);
|
|
13
|
+
if (close < 0)
|
|
14
|
+
return {
|
|
15
|
+
name: match[1],
|
|
16
|
+
start: match.index,
|
|
17
|
+
end: text.length,
|
|
18
|
+
fallback: null,
|
|
19
|
+
broken: { kind: "unterminated-var" },
|
|
20
|
+
};
|
|
21
|
+
const inner = text.slice(open + 1, close);
|
|
22
|
+
const comma = (0, text_1.topLevelComma)(inner);
|
|
23
|
+
return {
|
|
24
|
+
name: match[1],
|
|
25
|
+
start: match.index,
|
|
26
|
+
end: close + 1,
|
|
27
|
+
fallback: comma < 0 ? null : inner.slice(comma + 1).trim(),
|
|
28
|
+
broken: null,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
// The next `var(--x)` in the text, or null.
|
|
32
|
+
const references = (text) => {
|
|
33
|
+
const match = CSS_VARIABLE_RE.exec(text);
|
|
34
|
+
return match ? cssToken(text, match) : null;
|
|
35
|
+
};
|
|
36
|
+
exports.references = references;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Root } from "postcss";
|
|
2
|
+
import type { DocumentFacts, DocumentOptions } from "./styled/document";
|
|
3
|
+
import type { BranchProblem, Span } from "@md-code/follow-architecture/css/value/pieces";
|
|
4
|
+
type VariableToken = Span & {
|
|
5
|
+
name: string;
|
|
6
|
+
fallback: string | null;
|
|
7
|
+
broken: BranchProblem | null;
|
|
8
|
+
};
|
|
9
|
+
type ReferenceTokenizer = (text: string) => VariableToken | null;
|
|
10
|
+
interface StyleLanguage {
|
|
11
|
+
id: string;
|
|
12
|
+
exts: string[];
|
|
13
|
+
parse: (text: string) => Root;
|
|
14
|
+
facts: (text: string, options?: DocumentOptions) => DocumentFacts;
|
|
15
|
+
referenceTokens?: ReferenceTokenizer[];
|
|
16
|
+
}
|
|
17
|
+
declare const register: (language: StyleLanguage) => StyleLanguage;
|
|
18
|
+
declare const list: () => StyleLanguage[];
|
|
19
|
+
declare const byId: (id: string) => StyleLanguage | null;
|
|
20
|
+
declare const forExt: (ext: string | null | undefined) => StyleLanguage | null;
|
|
21
|
+
declare const forFile: (rel: string | null | undefined) => StyleLanguage | null;
|
|
22
|
+
declare const referenceTokenizers: () => ReferenceTokenizer[];
|
|
23
|
+
declare const reset: () => void;
|
|
24
|
+
export { register, list, byId, forExt, forFile, referenceTokenizers, reset };
|
|
25
|
+
export type { StyleLanguage, ReferenceTokenizer, VariableToken };
|
|
@@ -0,0 +1,81 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.reset = exports.referenceTokenizers = exports.forFile = exports.forExt = exports.byId = exports.list = exports.register = void 0;
|
|
37
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
38
|
+
const cssLanguage = __importStar(require("./css"));
|
|
39
|
+
const sassLanguage = __importStar(require("./scss"));
|
|
40
|
+
const reference_1 = require("./css/reference");
|
|
41
|
+
const reference_2 = require("./scss/reference");
|
|
42
|
+
const languages = new Map();
|
|
43
|
+
const register = (language) => {
|
|
44
|
+
if (!language?.id || typeof language.facts !== "function")
|
|
45
|
+
throw configError.styleLanguageIncomplete();
|
|
46
|
+
languages.set(language.id, { exts: [], ...language });
|
|
47
|
+
return language;
|
|
48
|
+
};
|
|
49
|
+
exports.register = register;
|
|
50
|
+
const list = () => [...languages.values()];
|
|
51
|
+
exports.list = list;
|
|
52
|
+
const byId = (id) => languages.get(id) ?? null;
|
|
53
|
+
exports.byId = byId;
|
|
54
|
+
// Which language claims a file: by extension. No language, no facts — a syntax
|
|
55
|
+
// nobody registered is not silently read as CSS.
|
|
56
|
+
const forExt = (ext) => {
|
|
57
|
+
const wanted = String(ext ?? "").toLowerCase();
|
|
58
|
+
return list().find((language) => language.exts.includes(wanted)) ?? null;
|
|
59
|
+
};
|
|
60
|
+
exports.forExt = forExt;
|
|
61
|
+
const forFile = (rel) => {
|
|
62
|
+
const ext = String(rel ?? "")
|
|
63
|
+
.toLowerCase()
|
|
64
|
+
.match(/\.[a-z0-9]+$/)?.[0] ?? "";
|
|
65
|
+
return forExt(ext);
|
|
66
|
+
};
|
|
67
|
+
exports.forFile = forFile;
|
|
68
|
+
// Every registered language's reference tokenizers, flattened — what the
|
|
69
|
+
// substitution walk asks for, so it takes the earliest match of all notations.
|
|
70
|
+
const referenceTokenizers = () => list().flatMap((language) => language.referenceTokens ?? []);
|
|
71
|
+
exports.referenceTokenizers = referenceTokenizers;
|
|
72
|
+
// Test hook and extension point: the built-ins are registered on load, and a
|
|
73
|
+
// consumer may register its own or replace one.
|
|
74
|
+
const reset = () => {
|
|
75
|
+
languages.clear();
|
|
76
|
+
register({ ...cssLanguage, referenceTokens: [reference_1.references] });
|
|
77
|
+
register({ ...sassLanguage, referenceTokens: [reference_2.references] });
|
|
78
|
+
};
|
|
79
|
+
exports.reset = reset;
|
|
80
|
+
register({ ...cssLanguage, referenceTokens: [reference_1.references] });
|
|
81
|
+
register({ ...sassLanguage, referenceTokens: [reference_2.references] });
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Root } from "postcss";
|
|
2
|
+
import { type DocumentFacts, type DocumentOptions } from "@md-code/follow-architecture/css/syntax/styled/document";
|
|
3
|
+
import type { Located } from "@md-code/follow-architecture/entities/facts";
|
|
4
|
+
declare const id = "scss";
|
|
5
|
+
declare const exts: string[];
|
|
6
|
+
declare const parse: (text: string) => Root;
|
|
7
|
+
declare const variablesOf: (root: Root) => (Located & {
|
|
8
|
+
name: string;
|
|
9
|
+
line: number | null;
|
|
10
|
+
value: string;
|
|
11
|
+
})[];
|
|
12
|
+
type ScssVariable = ReturnType<typeof variablesOf>[number];
|
|
13
|
+
declare const mixinsOf: (root: Root) => (Located & {
|
|
14
|
+
name: string;
|
|
15
|
+
line: number | null;
|
|
16
|
+
kind: string;
|
|
17
|
+
})[];
|
|
18
|
+
type ScssMixin = ReturnType<typeof mixinsOf>[number];
|
|
19
|
+
declare const facts: (text: string, options?: DocumentOptions) => DocumentFacts & {
|
|
20
|
+
variables: ScssVariable[];
|
|
21
|
+
mixins: ScssMixin[];
|
|
22
|
+
};
|
|
23
|
+
type ScssFacts = ReturnType<typeof facts>;
|
|
24
|
+
export { id, exts, parse, facts };
|
|
25
|
+
export type { ScssFacts, ScssVariable, ScssMixin };
|