designlane 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +239 -2
- package/dist/catalog/components.d.ts +35 -0
- package/dist/catalog/components.js +118 -0
- package/dist/catalog/js-reader.d.ts +4 -0
- package/dist/catalog/js-reader.js +102 -0
- package/dist/catalog/kotlin-reader.d.ts +4 -0
- package/dist/catalog/kotlin-reader.js +78 -0
- package/dist/catalog/reader.d.ts +47 -0
- package/dist/catalog/reader.js +78 -0
- package/dist/catalog/sources.d.ts +26 -0
- package/dist/catalog/sources.js +29 -0
- package/dist/catalog/swift-reader.d.ts +4 -0
- package/dist/catalog/swift-reader.js +72 -0
- package/dist/catalog/token-uses.d.ts +11 -0
- package/dist/catalog/token-uses.js +84 -0
- package/dist/cli/agent-prompt.d.ts +4 -0
- package/dist/cli/agent-prompt.js +14 -0
- package/dist/cli/command.d.ts +10 -0
- package/dist/cli/command.js +9 -0
- package/dist/cli/edit.d.ts +5 -0
- package/dist/cli/edit.js +102 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +11 -0
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.js +186 -0
- package/dist/drift/drift.d.ts +57 -0
- package/dist/drift/drift.js +138 -0
- package/dist/drift/duplicates.d.ts +15 -0
- package/dist/drift/duplicates.js +67 -0
- package/dist/drift/literals.d.ts +14 -0
- package/dist/drift/literals.js +66 -0
- package/dist/edit/alias-copy.d.ts +13 -0
- package/dist/edit/alias-copy.js +48 -0
- package/dist/edit/code-scan.d.ts +25 -0
- package/dist/edit/code-scan.js +105 -0
- package/dist/edit/color-channels.d.ts +8 -0
- package/dist/edit/color-channels.js +157 -0
- package/dist/edit/color-hex.d.ts +6 -0
- package/dist/edit/color-hex.js +73 -0
- package/dist/edit/color-value.d.ts +23 -0
- package/dist/edit/color-value.js +51 -0
- package/dist/edit/diff.d.ts +4 -0
- package/dist/edit/diff.js +41 -0
- package/dist/edit/edit-tokens.d.ts +48 -0
- package/dist/edit/edit-tokens.js +70 -0
- package/dist/edit/editors.d.ts +16 -0
- package/dist/edit/editors.js +43 -0
- package/dist/edit/notation.d.ts +41 -0
- package/dist/edit/notation.js +87 -0
- package/dist/edit/plan.d.ts +35 -0
- package/dist/edit/plan.js +167 -0
- package/dist/edit/read-source.d.ts +21 -0
- package/dist/edit/read-source.js +28 -0
- package/dist/edit/sharers.d.ts +13 -0
- package/dist/edit/sharers.js +61 -0
- package/dist/edit/type-values.d.ts +10 -0
- package/dist/edit/type-values.js +72 -0
- package/dist/frameworks/android-resources.d.ts +34 -0
- package/dist/frameworks/android-resources.js +91 -0
- package/dist/frameworks/android-text-appearances.d.ts +9 -0
- package/dist/frameworks/android-text-appearances.js +197 -0
- package/dist/frameworks/compose-circuit.d.ts +10 -0
- package/dist/frameworks/compose-circuit.js +135 -0
- package/dist/frameworks/compose-color-values.d.ts +24 -0
- package/dist/frameworks/compose-color-values.js +160 -0
- package/dist/frameworks/compose-colors.d.ts +9 -0
- package/dist/frameworks/compose-colors.js +137 -0
- package/dist/frameworks/compose-external-theme.d.ts +3 -0
- package/dist/frameworks/compose-external-theme.js +25 -0
- package/dist/frameworks/compose-fonts.d.ts +9 -0
- package/dist/frameworks/compose-fonts.js +57 -0
- package/dist/frameworks/compose-functions.d.ts +39 -0
- package/dist/frameworks/compose-functions.js +120 -0
- package/dist/frameworks/compose-links.d.ts +32 -0
- package/dist/frameworks/compose-links.js +367 -0
- package/dist/frameworks/compose-navigation.d.ts +49 -0
- package/dist/frameworks/compose-navigation.js +217 -0
- package/dist/frameworks/compose-routes.d.ts +36 -0
- package/dist/frameworks/compose-routes.js +191 -0
- package/dist/frameworks/compose-themes.d.ts +18 -0
- package/dist/frameworks/compose-themes.js +180 -0
- package/dist/frameworks/compose-tokens.d.ts +5 -0
- package/dist/frameworks/compose-tokens.js +63 -0
- package/dist/frameworks/compose-type.d.ts +13 -0
- package/dist/frameworks/compose-type.js +202 -0
- package/dist/frameworks/compose-views.d.ts +14 -0
- package/dist/frameworks/compose-views.js +136 -0
- package/dist/frameworks/compose.d.ts +3 -0
- package/dist/frameworks/compose.js +26 -0
- package/dist/frameworks/css-color.d.ts +6 -0
- package/dist/frameworks/css-color.js +73 -0
- package/dist/frameworks/js-code.d.ts +6 -0
- package/dist/frameworks/js-code.js +39 -0
- package/dist/frameworks/js-sources.d.ts +58 -0
- package/dist/frameworks/js-sources.js +259 -0
- package/dist/frameworks/kotlin-calls.d.ts +45 -0
- package/dist/frameworks/kotlin-calls.js +131 -0
- package/dist/frameworks/kotlin-source.d.ts +5 -0
- package/dist/frameworks/kotlin-source.js +116 -0
- package/dist/frameworks/kotlin-sources.d.ts +24 -0
- package/dist/frameworks/kotlin-sources.js +51 -0
- package/dist/frameworks/material-type.d.ts +19 -0
- package/dist/frameworks/material-type.js +69 -0
- package/dist/frameworks/plugin.d.ts +59 -0
- package/dist/frameworks/plugin.js +1 -0
- package/dist/frameworks/react-native.d.ts +7 -0
- package/dist/frameworks/react-native.js +130 -0
- package/dist/frameworks/rn-color-entries.d.ts +42 -0
- package/dist/frameworks/rn-color-entries.js +208 -0
- package/dist/frameworks/rn-color-modules.d.ts +27 -0
- package/dist/frameworks/rn-color-modules.js +90 -0
- package/dist/frameworks/rn-color-uses.d.ts +18 -0
- package/dist/frameworks/rn-color-uses.js +104 -0
- package/dist/frameworks/rn-colors.d.ts +8 -0
- package/dist/frameworks/rn-colors.js +108 -0
- package/dist/frameworks/rn-font-sizes.d.ts +5 -0
- package/dist/frameworks/rn-font-sizes.js +120 -0
- package/dist/frameworks/rn-fonts.d.ts +10 -0
- package/dist/frameworks/rn-fonts.js +63 -0
- package/dist/frameworks/rn-modules.d.ts +57 -0
- package/dist/frameworks/rn-modules.js +152 -0
- package/dist/frameworks/rn-named.d.ts +50 -0
- package/dist/frameworks/rn-named.js +98 -0
- package/dist/frameworks/rn-style.d.ts +25 -0
- package/dist/frameworks/rn-style.js +147 -0
- package/dist/frameworks/rn-themes.d.ts +37 -0
- package/dist/frameworks/rn-themes.js +178 -0
- package/dist/frameworks/rn-type.d.ts +18 -0
- package/dist/frameworks/rn-type.js +161 -0
- package/dist/frameworks/rn-values.d.ts +29 -0
- package/dist/frameworks/rn-values.js +181 -0
- package/dist/frameworks/rn-views.d.ts +20 -0
- package/dist/frameworks/rn-views.js +462 -0
- package/dist/frameworks/source-text.d.ts +32 -0
- package/dist/frameworks/source-text.js +105 -0
- package/dist/frameworks/swift-directives.d.ts +22 -0
- package/dist/frameworks/swift-directives.js +33 -0
- package/dist/frameworks/swift-expression-reader.d.ts +35 -0
- package/dist/frameworks/swift-expression-reader.js +276 -0
- package/dist/frameworks/swift-expression-types.d.ts +64 -0
- package/dist/frameworks/swift-expression-types.js +2 -0
- package/dist/frameworks/swift-expressions.d.ts +30 -0
- package/dist/frameworks/swift-expressions.js +142 -0
- package/dist/frameworks/swift-font-changes.d.ts +17 -0
- package/dist/frameworks/swift-font-changes.js +70 -0
- package/dist/frameworks/swift-font-helpers.d.ts +29 -0
- package/dist/frameworks/swift-font-helpers.js +170 -0
- package/dist/frameworks/swift-font-names.d.ts +31 -0
- package/dist/frameworks/swift-font-names.js +84 -0
- package/dist/frameworks/swift-font-reading.d.ts +15 -0
- package/dist/frameworks/swift-font-reading.js +182 -0
- package/dist/frameworks/swift-font-sites.d.ts +18 -0
- package/dist/frameworks/swift-font-sites.js +88 -0
- package/dist/frameworks/swift-font-values.d.ts +58 -0
- package/dist/frameworks/swift-font-values.js +31 -0
- package/dist/frameworks/swift-operators.d.ts +22 -0
- package/dist/frameworks/swift-operators.js +52 -0
- package/dist/frameworks/swift-owners.d.ts +10 -0
- package/dist/frameworks/swift-owners.js +76 -0
- package/dist/frameworks/swift-source.d.ts +56 -0
- package/dist/frameworks/swift-source.js +228 -0
- package/dist/frameworks/swift-token-cursor.d.ts +46 -0
- package/dist/frameworks/swift-token-cursor.js +93 -0
- package/dist/frameworks/swift-tokens.d.ts +40 -0
- package/dist/frameworks/swift-tokens.js +145 -0
- package/dist/frameworks/swift-type-spans.d.ts +13 -0
- package/dist/frameworks/swift-type-spans.js +106 -0
- package/dist/frameworks/swiftui-colors.d.ts +4 -0
- package/dist/frameworks/swiftui-colors.js +235 -0
- package/dist/frameworks/swiftui-hosting.d.ts +19 -0
- package/dist/frameworks/swiftui-hosting.js +279 -0
- package/dist/frameworks/swiftui-links.d.ts +29 -0
- package/dist/frameworks/swiftui-links.js +195 -0
- package/dist/frameworks/swiftui-presenters.d.ts +26 -0
- package/dist/frameworks/swiftui-presenters.js +220 -0
- package/dist/frameworks/swiftui-routes.d.ts +22 -0
- package/dist/frameworks/swiftui-routes.js +91 -0
- package/dist/frameworks/swiftui-sources.d.ts +23 -0
- package/dist/frameworks/swiftui-sources.js +51 -0
- package/dist/frameworks/swiftui-themes.d.ts +22 -0
- package/dist/frameworks/swiftui-themes.js +209 -0
- package/dist/frameworks/swiftui-tokens.d.ts +5 -0
- package/dist/frameworks/swiftui-tokens.js +27 -0
- package/dist/frameworks/swiftui-type.d.ts +8 -0
- package/dist/frameworks/swiftui-type.js +146 -0
- package/dist/frameworks/swiftui-usage.d.ts +40 -0
- package/dist/frameworks/swiftui-usage.js +139 -0
- package/dist/frameworks/swiftui.d.ts +2 -0
- package/dist/frameworks/swiftui.js +88 -0
- package/dist/frameworks/tailwind-classes.d.ts +10 -0
- package/dist/frameworks/tailwind-classes.js +80 -0
- package/dist/frameworks/tailwind-colors.d.ts +17 -0
- package/dist/frameworks/tailwind-colors.js +80 -0
- package/dist/frameworks/tailwind-config.d.ts +36 -0
- package/dist/frameworks/tailwind-config.js +99 -0
- package/dist/frameworks/tailwind-css.d.ts +12 -0
- package/dist/frameworks/tailwind-css.js +94 -0
- package/dist/frameworks/tailwind-type.d.ts +14 -0
- package/dist/frameworks/tailwind-type.js +177 -0
- package/dist/frameworks/value-locations.d.ts +20 -0
- package/dist/frameworks/value-locations.js +25 -0
- package/dist/frameworks/view-links.d.ts +12 -0
- package/dist/frameworks/view-links.js +18 -0
- package/dist/frameworks/xcode-colors.d.ts +4 -0
- package/dist/frameworks/xcode-colors.js +136 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/mcp/app.d.ts +20 -0
- package/dist/mcp/app.js +31 -0
- package/dist/mcp/component-tools.d.ts +6 -0
- package/dist/mcp/component-tools.js +111 -0
- package/dist/mcp/drift-tool.d.ts +4 -0
- package/dist/mcp/drift-tool.js +59 -0
- package/dist/mcp/server.d.ts +4 -0
- package/dist/mcp/server.js +77 -0
- package/dist/output/catalog-html.d.ts +9 -0
- package/dist/output/catalog-html.js +205 -0
- package/dist/output/catalog-style.d.ts +4 -0
- package/dist/output/catalog-style.js +64 -0
- package/dist/output/css-values.d.ts +4 -0
- package/dist/output/css-values.js +7 -0
- package/dist/output/design-md.d.ts +7 -0
- package/dist/output/design-md.js +218 -0
- package/dist/output/drift-md.d.ts +5 -0
- package/dist/output/drift-md.js +112 -0
- package/dist/output/old-names.d.ts +7 -0
- package/dist/output/old-names.js +31 -0
- package/dist/output/output-files.d.ts +9 -0
- package/dist/output/output-files.js +12 -0
- package/dist/output/reports.d.ts +9 -0
- package/dist/output/reports.js +25 -0
- package/dist/output/screen-links.d.ts +12 -0
- package/dist/output/screen-links.js +41 -0
- package/dist/output/token-names.d.ts +39 -0
- package/dist/output/token-names.js +104 -0
- package/dist/output/tokens-json.d.ts +15 -0
- package/dist/output/tokens-json.js +141 -0
- package/dist/output/tokens-schema.d.ts +729 -0
- package/dist/output/tokens-schema.js +114 -0
- package/dist/output/write.d.ts +21 -0
- package/dist/output/write.js +84 -0
- package/dist/previews/previews.d.ts +27 -0
- package/dist/previews/previews.js +103 -0
- package/dist/scan/agent-tokens.d.ts +13 -0
- package/dist/scan/agent-tokens.js +147 -0
- package/dist/scan/classify.d.ts +24 -0
- package/dist/scan/classify.js +89 -0
- package/dist/scan/counting.d.ts +13 -0
- package/dist/scan/counting.js +28 -0
- package/dist/scan/file-limits.d.ts +2 -0
- package/dist/scan/file-limits.js +2 -0
- package/dist/scan/files.d.ts +21 -0
- package/dist/scan/files.js +87 -0
- package/dist/scan/index.d.ts +5 -0
- package/dist/scan/index.js +71 -0
- package/dist/scan/notes.d.ts +5 -0
- package/dist/scan/notes.js +29 -0
- package/dist/scan/palette.d.ts +54 -0
- package/dist/scan/palette.js +139 -0
- package/dist/scan/screen-links.d.ts +8 -0
- package/dist/scan/screen-links.js +63 -0
- package/dist/scan/sorted.d.ts +3 -0
- package/dist/scan/sorted.js +14 -0
- package/dist/scan/targets.d.ts +8 -0
- package/dist/scan/targets.js +42 -0
- package/dist/scan/test-paths.d.ts +2 -0
- package/dist/scan/test-paths.js +4 -0
- package/dist/scan/tokens.d.ts +6 -0
- package/dist/scan/tokens.js +28 -0
- package/dist/scan/type-scale.d.ts +33 -0
- package/dist/scan/type-scale.js +65 -0
- package/dist/scan/types.d.ts +173 -0
- package/dist/scan/types.js +40 -0
- package/dist/sync/plan.d.ts +81 -0
- package/dist/sync/plan.js +190 -0
- package/dist/sync/tokens-file.d.ts +57 -0
- package/dist/sync/tokens-file.js +123 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,240 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Designlane
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/designlane)
|
|
4
|
+
[](https://github.com/codual-ai/designlane/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
**Your design tools stay in step with your app's code.** Run `designlane` in your iOS, Android or React Native repo
|
|
8
|
+
and it reads the colours and text styles your code names, so your design tool's variables and text styles update with
|
|
9
|
+
every push.
|
|
10
|
+
|
|
11
|
+
https://github.com/user-attachments/assets/e6324208-a820-4d70-b27a-24a0337e082c
|
|
12
|
+
|
|
13
|
+
*An app's design system in Figma, synced from its code: each colour with its light and dark value and how the code
|
|
14
|
+
names it (`Theme.accent`).*
|
|
15
|
+
|
|
16
|
+
- **Always matches the app.** Your design file shows exactly what the code uses, nothing guessed.
|
|
17
|
+
- **You stay in control.** See every change before you apply it. Renamed tokens keep their variables, so designs
|
|
18
|
+
never break.
|
|
19
|
+
- **Free and private by default.** No AI and no account needed: it runs in your GitHub Actions, and your code stays
|
|
20
|
+
with you. Bring your own coding agent only if you want to.
|
|
21
|
+
|
|
22
|
+
> [!NOTE]
|
|
23
|
+
> Designlane works with **Figma** today, with **Penpot** and **Sketch** next. It writes standard W3C design tokens,
|
|
24
|
+
> which Tokens Studio and Style Dictionary already import.
|
|
25
|
+
|
|
26
|
+
Designlane was called Designmap until 0.3.0: what it set up then keeps working (see the [changelog](CHANGELOG.md)).
|
|
27
|
+
|
|
28
|
+
## Get started (30 seconds)
|
|
29
|
+
|
|
30
|
+
Needs Node 22 or later. In your app's repo:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx designlane .
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's it. You get four files:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
designlane/
|
|
40
|
+
├── tokens.json the design system the code names, as W3C design tokens: what your design tool syncs
|
|
41
|
+
├── DESIGN.md the full report: every colour, text style, spacing and corner radius, with where each is used
|
|
42
|
+
├── catalog.html one page with the colours, text styles and every component, to open or send to a designer
|
|
43
|
+
└── drift.md where the UI code writes values the design system already has
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then keep your design file in step:
|
|
47
|
+
|
|
48
|
+
1. **Add the GitHub Action.** On every push it updates `designlane/tokens.json` and commits it when it changed
|
|
49
|
+
([workflow](figma-plugin/README.md#keeping-tokensjson-up-to-date)).
|
|
50
|
+
2. **Install the Figma plugin** and connect your repo, with a token that can only read it
|
|
51
|
+
([plugin](figma-plugin/README.md)).
|
|
52
|
+
3. **Apply.** After each push the plugin shows what changed in the code. Read the plan and press Apply.
|
|
53
|
+
4. **Changed something in Figma?** The plugin lists it, and opens a pull request with the exact code edit
|
|
54
|
+
([how](figma-plugin/README.md#changes-made-in-figma)).
|
|
55
|
+
|
|
56
|
+
**One tool, three platforms.** SwiftUI, Jetpack Compose and React Native, on macOS, Linux and Windows.
|
|
57
|
+
|
|
58
|
+
## See it in action
|
|
59
|
+
|
|
60
|
+
Real output, run on a small SwiftUI shop app:
|
|
61
|
+
|
|
62
|
+

|
|
63
|
+
|
|
64
|
+
Each colour in `tokens.json` records how the code refers to it and where it's declared, so the plugin can show it
|
|
65
|
+
and find it again after any rename, and exactly where each of its values is written: the file, line and characters
|
|
66
|
+
of its light and dark values (offsets in UTF-16 code units, each span exactly the text to replace, never a string's
|
|
67
|
+
quotes), what the span holds (`kind`: a `literal`, an `expression`, a `family-name` holding the weight too, a family's
|
|
68
|
+
`identifier`, or an asset's `components`), and each name on the way when the code reaches the value through another
|
|
69
|
+
(`via`). Each text style records the same for its family, size and weight:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
"Brand": {
|
|
73
|
+
"$type": "color",
|
|
74
|
+
"$value": { "colorSpace": "srgb", "components": [1, 0.102, 0.18], "hex": "#ff1a2e" },
|
|
75
|
+
"$extensions": {
|
|
76
|
+
"designlane": {
|
|
77
|
+
"reference": "Color(\"Brand\")",
|
|
78
|
+
"source": "Shop/Assets.xcassets/Brand.colorset/Contents.json",
|
|
79
|
+
"modes": { "dark": { "colorSpace": "srgb", "components": [1, 0.333, 0.4], "hex": "#ff5566" } },
|
|
80
|
+
"locations": {
|
|
81
|
+
"light": { "file": "Shop/Assets.xcassets/Brand.colorset/Contents.json", "line": 6, "start": 92, "end": 160, "kind": "components" },
|
|
82
|
+
"dark": { "file": "Shop/Assets.xcassets/Brand.colorset/Contents.json", "line": 14, "start": 352, "end": 420, "kind": "components" }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
In Figma, the plugin lists what's new, what changed and what the code no longer uses. Nothing changes in your file
|
|
90
|
+
until you press Apply; then your variables and text styles update in place, and a page in the file shows the design
|
|
91
|
+
system as swatches and type samples.
|
|
92
|
+
|
|
93
|
+
## What it does
|
|
94
|
+
|
|
95
|
+
| Capability | What you get |
|
|
96
|
+
|---|---|
|
|
97
|
+
| Colours | Every colour the code names, from asset catalogs, theme objects, colour resources and Tailwind, as Figma variables |
|
|
98
|
+
| Light and dark | A colour's light and dark values as one variable with two modes |
|
|
99
|
+
| Text styles | The app's type scale and named styles: family, size and weight, as Figma text styles |
|
|
100
|
+
| A plan you apply | What's new, what changed and what the code no longer uses, each with how the code refers to it |
|
|
101
|
+
| Safe renames | A token renamed in the code, or a whole theme renamed, keeps its variable and every design using it |
|
|
102
|
+
| Several themes | An app whose users pick a theme gets a Figma collection for each, with Light and Dark modes |
|
|
103
|
+
| Your coding agent, for unusual setups | Your agent reads the app; Designlane checks every value against the code before syncing it |
|
|
104
|
+
| Two apps, one repo | An iPhone and an Android app in one repo each get their own design system |
|
|
105
|
+
| The full picture | `DESIGN.md` lists every value the code uses and the app's screens (for SwiftUI and Compose, how they open each other too) |
|
|
106
|
+
| Design context for agents | An agent can ask for the design system while it codes: `claude mcp add designlane -- npx designlane mcp .` |
|
|
107
|
+
| A component catalog | `catalog.html`: the colours light and dark, text styles, spacing, corner radii and every component, with its file, uses, parameters and the tokens it uses |
|
|
108
|
+
| Drift | `drift.md`: colours written as values (with the named colour to use), spacing and corners off the scale the code uses, text styles written in place, near-duplicate components |
|
|
109
|
+
|
|
110
|
+
## Component catalog
|
|
111
|
+
|
|
112
|
+
`designlane/catalog.html` is one page that opens offline in any browser, in light or dark: the app's colours (light
|
|
113
|
+
and dark, and each theme), text styles, the spacing and corner radii the code uses, and every component and screen.
|
|
114
|
+
Each component shows its kind (a button, a row, a card…), where it's declared, how often other code uses it, its
|
|
115
|
+
parameters as the code writes them (`title: String`), and the colours and text styles it uses. When two components
|
|
116
|
+
share a name, each use counts for the one declared nearest (the same file, else the same folder), and a use as near
|
|
117
|
+
both is shown as possibly either. Search and filter by kind at the top.
|
|
118
|
+
|
|
119
|
+
Your coding agent can add a picture of each component. With the MCP server connected, ask it to *"draw my components
|
|
120
|
+
for the Designlane catalog"*: it finds them with `find_components`, reads each with `get_component`, draws it in HTML
|
|
121
|
+
with the app's own colours, and saves it with `save_preview`, which updates the catalog. Pictures are plain HTML and
|
|
122
|
+
styles only, no scripts or links, and show in a sandbox; when a component's code changes, its card says the picture is
|
|
123
|
+
out of date. Use `--no-write` to see what Designlane finds without writing any file.
|
|
124
|
+
|
|
125
|
+
`designlane/drift.md` lists where the UI code skips the design system, each with its file and line, and the agent can
|
|
126
|
+
check its own changes with `check_drift`. Designlane names a colour or text style to use when one matches; for spacing
|
|
127
|
+
and corners it says which value the code uses often nearby, since it doesn't read named spacing tokens. Theme and
|
|
128
|
+
token files (`Theme.kt`, `AppColors.swift`, `theme/`) and previews are left out, as values belong there.
|
|
129
|
+
|
|
130
|
+
## Unusual setup? Let your coding agent read it
|
|
131
|
+
|
|
132
|
+
Designlane's own reading covers the common ways apps define colours and text styles. If your app builds its theme
|
|
133
|
+
some other way, have your coding agent do the reading, and Designlane checks it before anything reaches Figma:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
claude -p "$(npx designlane prompt)" --allowedTools Read Glob Grep Write # writes designlane/agent.json
|
|
137
|
+
npx designlane --from-agent designlane/agent.json # checks it, writes tokens.json
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
A colour is kept only when the code writes its exact value and uses its name; whatever isn't is listed and left out.
|
|
141
|
+
Any agent works: `designlane prompt` prints plain instructions.
|
|
142
|
+
|
|
143
|
+
## Change a token in the code
|
|
144
|
+
|
|
145
|
+
`designlane edit` makes a design change in the code, in the one place tokens.json says the value is written, and
|
|
146
|
+
writes it the way the code already does:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
npx designlane edit Theme.brand light '#de2413' --dry-run
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```diff
|
|
153
|
+
--- a/Shop/Theme.swift
|
|
154
|
+
+++ b/Shop/Theme.swift
|
|
155
|
+
@@ -2,1 +2,1 @@
|
|
156
|
+
- static let brand = Color(red: 0.2, green: 0.4, blue: 0.9)
|
|
157
|
+
+ static let brand = Color(red: 0.87, green: 0.14, blue: 0.075)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Name the token by its key in tokens.json or how the code refers to it, and the property as `light`, `dark`,
|
|
161
|
+
`family`, `size` or `weight`. Without `--dry-run` it writes the file. The new value keeps the code's notation: hex
|
|
162
|
+
case and length, Compose's `0xFF…`, Swift's `/ 255` or its decimals, `rgb()`, an asset catalog's components (with more decimals only when the code's can't hold the new value), `22.sp`,
|
|
163
|
+
`.semibold` or `FontWeight.SemiBold`. A colour the code gives as another name (`link: colors.blue0`) gets its own value
|
|
164
|
+
in place of that name, so everything else using `colors.blue0` keeps it, when the value is written in the same file and
|
|
165
|
+
can stand on its own there.
|
|
166
|
+
|
|
167
|
+
When it can't be sure, it changes nothing and says why: the code changed since designlane last ran (run it again), the
|
|
168
|
+
colour is a named or computed one (`.white`, `Brand.copy(alpha = 0.5f)`), the weight is part of a font's name
|
|
169
|
+
(`Inter-Bold`), the change would also change another token (one written in the same place, or one whose name leads
|
|
170
|
+
there), a value can't be copied in place of a name safely (it's in another file, or Swift's `.init(…)`), or a text
|
|
171
|
+
style's value comes from a style it builds on. `--tokens` is read relative to `--dir`.
|
|
172
|
+
|
|
173
|
+
## Supported
|
|
174
|
+
|
|
175
|
+
| | Today | Next |
|
|
176
|
+
|---|---|---|
|
|
177
|
+
| **Code** | SwiftUI, Jetpack Compose, React Native | more to come |
|
|
178
|
+
| **Design tools** | Figma | Penpot, Sketch |
|
|
179
|
+
| **Direction** | code to design; design to code, from Figma as a pull request ([plugin](figma-plugin/README.md#changes-made-in-figma)) or with `designlane edit` | |
|
|
180
|
+
| **Token formats** | W3C design tokens (Tokens Studio, Style Dictionary) | |
|
|
181
|
+
|
|
182
|
+
## What it reads
|
|
183
|
+
|
|
184
|
+
The design system is what the code names: a colour declared with a name (`Theme.surface`, an asset, a colour
|
|
185
|
+
resource) and a text style the code defines (a typography style, the app's own font helper). Values written in place
|
|
186
|
+
in a screen's layout, and spacing and corner radii, are listed in `DESIGN.md`, so editing a screen doesn't change your
|
|
187
|
+
design system.
|
|
188
|
+
|
|
189
|
+
- **SwiftUI:** asset catalog colours, colours declared in code, the app's own font helpers and text styles.
|
|
190
|
+
- **Jetpack Compose:** the Material colour scheme (each role with its Light and Dark value), the type scale and named
|
|
191
|
+
text styles, an app's own colour class and colour resources.
|
|
192
|
+
- **React Native:** theme objects (a light and a dark theme paired into one colour, a theme chosen per platform read as
|
|
193
|
+
iOS's), Tailwind's colours and text classes (a `tailwind.config.js`, or a CSS `@theme`, as NativeWind and Uniwind
|
|
194
|
+
use), and typography objects (a font file's name like `Inter-SemiBold` read as its family and weight).
|
|
195
|
+
|
|
196
|
+
`DESIGN.md` also lists the app's screens and, for SwiftUI and Compose, how they open each other: pushed, a sheet, a
|
|
197
|
+
dialog, full screen, a popover, a tab, a pane beside, or starting over.
|
|
198
|
+
|
|
199
|
+
### Apps with several themes
|
|
200
|
+
|
|
201
|
+
Some apps let people pick a theme, each with a light and a dark version: SwiftUI types conforming to one protocol of
|
|
202
|
+
colours (`OceanLight` and `OceanDark`, `DesertLight` and `DesertDark`), or React Native theme objects beyond one light
|
|
203
|
+
and dark pair (`themes.black`, a list of presets). The first theme the code declares, or the one named `light` and
|
|
204
|
+
`dark`, is the app's own colours, so reordering the themes in the code changes which one that is. Every other theme
|
|
205
|
+
gets its own colours in tokens.json, under `theme`, and its own Figma collection with Light and Dark modes, such as
|
|
206
|
+
**Shop · Desert (Designlane)**, with the same variable names, so designers can see every theme and design with any of
|
|
207
|
+
them. DESIGN.md lists each theme's colours.
|
|
208
|
+
|
|
209
|
+
### Two apps in one repo
|
|
210
|
+
|
|
211
|
+
A repo with both an iPhone and an Android app gets a design system for each, since the two often differ (a different
|
|
212
|
+
blue, the platform's own fonts): `designlane/tokens.ios.json` and `designlane/tokens.android.json`, with one `DESIGN.md`
|
|
213
|
+
covering both. Connect each design file to its app's path.
|
|
214
|
+
|
|
215
|
+
### A design system in its own repo
|
|
216
|
+
|
|
217
|
+
Some teams keep their theme in a separate library that the app imports. Designlane then tells you the theme is defined
|
|
218
|
+
outside the app. Add Designlane to the library's repo instead, and connect your design tool there.
|
|
219
|
+
|
|
220
|
+
## Prerequisites
|
|
221
|
+
|
|
222
|
+
| Requirement | Minimum | Check |
|
|
223
|
+
|---|---|---|
|
|
224
|
+
| Node.js | 22 | `node --version` |
|
|
225
|
+
| A GitHub token for the plugin | read-only access to the app's repo contents; to open pull requests from Figma, a second one with Contents and Pull requests set to Read and write | GitHub → Settings → Developer settings → Fine-grained tokens |
|
|
226
|
+
|
|
227
|
+
## Documentation
|
|
228
|
+
|
|
229
|
+
- [Figma plugin](figma-plugin/README.md): install, connect a repo, and what a sync does
|
|
230
|
+
- [Keeping tokens.json up to date](figma-plugin/README.md#keeping-tokensjson-up-to-date): the GitHub Action
|
|
231
|
+
- [Changelog](CHANGELOG.md)
|
|
232
|
+
|
|
233
|
+
## Status
|
|
234
|
+
|
|
235
|
+
Version 0.2. Designlane reads SwiftUI, Jetpack Compose and React Native apps, syncs to Figma, and turns changes made
|
|
236
|
+
in Figma into pull requests. Feedback and issues are welcome.
|
|
237
|
+
|
|
238
|
+
## License
|
|
239
|
+
|
|
240
|
+
[Apache 2.0](LICENSE)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** The app's components and screens as the catalog shows them: what each is, where it's declared and used, what it
|
|
2
|
+
* takes, and which of the app's colours and text styles it uses. */
|
|
3
|
+
import type { FrameworkId, ScanResult, ScreenRef } from "../scan/types.js";
|
|
4
|
+
import type { ComponentReader } from "./reader.js";
|
|
5
|
+
import { type AppSources, type FrameworkSources } from "./sources.js";
|
|
6
|
+
export declare const CATEGORIES: readonly ["button", "list", "card", "header", "input", "label", "media", "screen", "other"];
|
|
7
|
+
export type Category = (typeof CATEGORIES)[number];
|
|
8
|
+
export interface ComponentInfo {
|
|
9
|
+
/** The scan's id for the view. */
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
framework: FrameworkId;
|
|
13
|
+
file: string;
|
|
14
|
+
line: number;
|
|
15
|
+
kind: ScreenRef["kind"];
|
|
16
|
+
category: Category;
|
|
17
|
+
/** How many places in other code place it, and the files they're in, most first. */
|
|
18
|
+
uses: number;
|
|
19
|
+
usedIn: string[];
|
|
20
|
+
/** Places of its name as near another component of that name as this one, so either could be meant. */
|
|
21
|
+
sharedUses: number;
|
|
22
|
+
/** As the code writes them: `title: String`, `onClick: () -> Unit`. */
|
|
23
|
+
params: string[];
|
|
24
|
+
/** The keys of the colours and text styles its code refers to. */
|
|
25
|
+
colors: string[];
|
|
26
|
+
typeStyles: string[];
|
|
27
|
+
/** Its declaration's code; empty when it couldn't be found. */
|
|
28
|
+
source: string;
|
|
29
|
+
}
|
|
30
|
+
export declare const categoryOf: (name: string, kind: ScreenRef["kind"]) => Category;
|
|
31
|
+
export declare function readerOf(sources: FrameworkSources): ComponentReader;
|
|
32
|
+
/** `source` cut to its first `maxLines` lines, ending in `…` when cut. */
|
|
33
|
+
export declare function firstLines(source: string, maxLines: number): string;
|
|
34
|
+
/** Every view the scan found, components first, then by how often they're used. */
|
|
35
|
+
export declare function inventory(scan: ScanResult, sources: AppSources): ComponentInfo[];
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** The app's components and screens as the catalog shows them: what each is, where it's declared and used, what it
|
|
2
|
+
* takes, and which of the app's colours and text styles it uses. */
|
|
3
|
+
import { byCode, groupBy } from "../scan/counting.js";
|
|
4
|
+
import { jsReader } from "./js-reader.js";
|
|
5
|
+
import { kotlinReader } from "./kotlin-reader.js";
|
|
6
|
+
import { codeFiles } from "./sources.js";
|
|
7
|
+
import { swiftReader } from "./swift-reader.js";
|
|
8
|
+
import { tokenUsesReader } from "./token-uses.js";
|
|
9
|
+
export const CATEGORIES = [
|
|
10
|
+
"button",
|
|
11
|
+
"list",
|
|
12
|
+
"card",
|
|
13
|
+
"header",
|
|
14
|
+
"input",
|
|
15
|
+
"label",
|
|
16
|
+
"media",
|
|
17
|
+
"screen",
|
|
18
|
+
"other",
|
|
19
|
+
];
|
|
20
|
+
/** Each category by the end of a view's name: whole name parts, so `Tabletop` isn't a `Tab` nor `Labelled` a label. */
|
|
21
|
+
const CATEGORY_SUFFIXES = [
|
|
22
|
+
[/(?:Screen|Page|Scene|Route)$/, "screen"],
|
|
23
|
+
[/(?:Button|CTA|Fab|FAB|Action)$/, "button"],
|
|
24
|
+
[/(?:Row|Cell|Item|Tile)$/, "list"],
|
|
25
|
+
[/(?:Card|Panel|Sheet|Banner)$/, "card"],
|
|
26
|
+
[/(?:Header|Footer|Bar|Toolbar)$/, "header"],
|
|
27
|
+
[/(?:Field|Input|Toggle|Switch|Picker|Checkbox|Slider|Stepper|Search)$/, "input"],
|
|
28
|
+
[/(?:Label|Badge|Chip|Tag|Pill|Text|Title)$/, "label"],
|
|
29
|
+
[/(?:Image|Avatar|Icon|Thumbnail|Logo|Photo)$/, "media"],
|
|
30
|
+
];
|
|
31
|
+
export const categoryOf = (name, kind) => CATEGORY_SUFFIXES.find(([suffix]) => suffix.test(name))?.[1] ?? (kind === "screen" ? "screen" : "other");
|
|
32
|
+
export function readerOf(sources) {
|
|
33
|
+
if (sources.framework === "swiftui")
|
|
34
|
+
return swiftReader(sources.files);
|
|
35
|
+
if (sources.framework === "compose")
|
|
36
|
+
return kotlinReader(sources.files);
|
|
37
|
+
return jsReader(sources.files);
|
|
38
|
+
}
|
|
39
|
+
/** `source` cut to its first `maxLines` lines, ending in `…` when cut. */
|
|
40
|
+
export function firstLines(source, maxLines) {
|
|
41
|
+
const lines = source.split("\n");
|
|
42
|
+
return lines.length > maxLines ? `${lines.slice(0, maxLines).join("\n")}\n…` : source;
|
|
43
|
+
}
|
|
44
|
+
/** How near a placement in `rel` is to a view declared in `file`: the same file, else the folders they share. */
|
|
45
|
+
function nearness(file, rel) {
|
|
46
|
+
if (file === rel)
|
|
47
|
+
return Number.POSITIVE_INFINITY;
|
|
48
|
+
const declared = file.split("/");
|
|
49
|
+
const placed = rel.split("/");
|
|
50
|
+
let shared = 0;
|
|
51
|
+
while (shared < declared.length - 1 && declared[shared] === placed[shared])
|
|
52
|
+
shared++;
|
|
53
|
+
return shared;
|
|
54
|
+
}
|
|
55
|
+
/** Each view's placements, by id. A name shared by several views is credited to the one declared nearest; a
|
|
56
|
+
* placement as near two of them is shared by both, since the code alone doesn't say which it means. */
|
|
57
|
+
function placementsByView(views, placements) {
|
|
58
|
+
const byName = groupBy(views, (v) => v.name);
|
|
59
|
+
const out = new Map(views.map((v) => [v.id, { own: [], shared: [] }]));
|
|
60
|
+
for (const placement of placements) {
|
|
61
|
+
const named = byName.get(placement.name) ?? [];
|
|
62
|
+
const near = named.map((v) => nearness(v.file, placement.rel));
|
|
63
|
+
const most = Math.max(...near);
|
|
64
|
+
const nearest = named.filter((_, i) => near[i] === most);
|
|
65
|
+
for (const view of nearest)
|
|
66
|
+
out.get(view.id)?.[nearest.length === 1 ? "own" : "shared"].push(placement);
|
|
67
|
+
}
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
/** The places using a view: its placements outside its own declaration. */
|
|
71
|
+
function usesOf(view, declaration, placements) {
|
|
72
|
+
const outside = (list = []) => list.filter((p) => !(declaration && p.rel === view.file && p.at >= declaration.start && p.at < declaration.end));
|
|
73
|
+
const own = outside(placements?.own);
|
|
74
|
+
const byFile = [...groupBy(own, (p) => p.rel)].sort((a, b) => b[1].length - a[1].length || byCode(a[0], b[0]));
|
|
75
|
+
return {
|
|
76
|
+
uses: own.length,
|
|
77
|
+
usedIn: byFile.map(([rel]) => rel),
|
|
78
|
+
sharedUses: outside(placements?.shared).length,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function frameworkComponents(scan, sources) {
|
|
82
|
+
const reader = readerOf(sources);
|
|
83
|
+
const texts = new Map(codeFiles(sources).map((f) => [f.rel, f]));
|
|
84
|
+
const placements = placementsByView(scan.screens, reader.placements(new Set(scan.screens.map((s) => s.name))));
|
|
85
|
+
const tokenUses = tokenUsesReader(scan.tokens, scan.framework, scan.platforms[0]);
|
|
86
|
+
return scan.screens.map((view) => {
|
|
87
|
+
const declaration = reader.declaration(view);
|
|
88
|
+
const file = texts.get(view.file);
|
|
89
|
+
const source = declaration && file ? file.text.slice(declaration.start, declaration.end) : "";
|
|
90
|
+
const code = declaration && file ? file.code.slice(declaration.start, declaration.end) : "";
|
|
91
|
+
return {
|
|
92
|
+
id: view.id,
|
|
93
|
+
name: view.name,
|
|
94
|
+
framework: view.framework,
|
|
95
|
+
file: view.file,
|
|
96
|
+
line: view.line,
|
|
97
|
+
kind: view.kind,
|
|
98
|
+
category: categoryOf(view.name, view.kind),
|
|
99
|
+
...usesOf(view, declaration, placements.get(view.id)),
|
|
100
|
+
params: declaration?.params ?? [],
|
|
101
|
+
...tokenUses(source, code),
|
|
102
|
+
source,
|
|
103
|
+
};
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Every view the scan found, components first, then by how often they're used. */
|
|
107
|
+
export function inventory(scan, sources) {
|
|
108
|
+
const out = [];
|
|
109
|
+
for (const framework of scan.frameworks) {
|
|
110
|
+
const own = sources.get(framework.framework);
|
|
111
|
+
if (own)
|
|
112
|
+
out.push(...frameworkComponents(framework, own));
|
|
113
|
+
}
|
|
114
|
+
return out.sort((a, b) => Number(a.kind === "screen") - Number(b.kind === "screen") ||
|
|
115
|
+
b.uses - a.uses ||
|
|
116
|
+
byCode(a.name, b.name) ||
|
|
117
|
+
byCode(a.id, b.id));
|
|
118
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The catalog's reading of React Native components: their props, and the JSX placing them. */
|
|
2
|
+
import { type JsSource } from "../frameworks/js-sources.js";
|
|
3
|
+
import { type ComponentReader } from "./reader.js";
|
|
4
|
+
export declare function jsReader(files: JsSource[]): ComponentReader;
|