@astryxdesign/cli 0.7.12-canary.f543ec7 → 0.7.12
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 +107 -0
- package/api/build/blocks/blocks.d.mts +41 -0
- package/api/build/blocks/blocks.mjs +118 -68
- package/api/component/__fixtures__/resolutions/modules.txt +3 -3
- package/api/docs/_adapter.d.mts +22 -0
- package/api/docs/_adapter.mjs +81 -3
- package/api/docs/docs.doc.mjs +5 -5
- package/api/docs/docs.type.d.mts +21 -0
- package/api/docs/docs.type.mjs +11 -0
- package/api/docs/list/list.d.mts +5 -1
- package/api/docs/list/list.mjs +72 -6
- package/api/docs/node/node.mjs +2 -40
- package/api/doctor/doctor.d.mts +4 -4
- package/api/doctor/doctor.mjs +248 -78
- package/api/icon/_authoring.mjs +8 -1
- package/api/icon/add/add.mjs +45 -5
- package/api/icon/icon.type.d.mts +24 -0
- package/api/icon/icon.type.mjs +6 -0
- package/api/icon/iconAdd.doc.mjs +1 -1
- package/api/icon/map/map.mjs +11 -4
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/integration/add-helpers.d.mts +5 -1
- package/api/integration/add-helpers.mjs +1 -1
- package/api/render/_adapter.mjs +9 -0
- package/api/render/render.doc.mjs +3 -3
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +3 -0
- package/api/search/_adapter.d.mts +32 -3
- package/api/search/_adapter.mjs +50 -22
- package/api/search/_fit-order.d.mts +47 -0
- package/api/search/_fit-order.mjs +257 -0
- package/api/search/_main-searcher.mjs +15 -5
- package/api/search/exportSearchIndex.doc.d.mts +10 -0
- package/api/search/exportSearchIndex.doc.mjs +58 -0
- package/api/search/rankSearchIndex.doc.d.mts +10 -0
- package/api/search/rankSearchIndex.doc.mjs +79 -0
- package/api/search/search-index.d.mts +44 -0
- package/api/search/search-index.mjs +270 -0
- package/api/search/search.type.d.mts +28 -0
- package/api/search/search.type.mjs +17 -0
- package/api/swizzle/_moduleGraph.d.mts +7 -0
- package/api/swizzle/_moduleGraph.mjs +191 -83
- package/api/swizzle/copy/copy.mjs +28 -6
- package/api/template/skeleton/skeleton.mjs +1 -1
- package/api/template/template.mjs +1 -0
- package/assets/codemods/transforms/v0.1.0/drop-xds-prefix-imports.mjs +1 -1
- package/assets/codemods/transforms/v0.1.0/index.mjs +1 -1
- package/assets/discover/official-packages.json +16 -0
- package/assets/docs/styling-overview.doc.mjs +3 -3
- package/assets/docs/tree/icon-sets.doc.mjs +4 -4
- package/assets/docs/tree/render-pages.doc.mjs +3 -3
- package/assets/docs/tree/tailwind.doc.mjs +41 -1
- package/assets/docs/tree/type-scale.doc.mjs +19 -2
- package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +1 -0
- package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.tsx +56 -0
- package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.doc.mjs +2 -2
- package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.tsx +66 -10
- package/assets/templates/blocks/components/Link/useLinkifyHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Link/useLinkifyHookUsage.tsx +39 -0
- package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.tsx +83 -0
- package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.tsx +41 -0
- package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.tsx +97 -0
- package/assets/templates/pages/table-filter/page.tsx +15 -23
- package/assets/templates/pages/table-grouped/page.tsx +30 -30
- package/assets/templates/pages/table-inbox/page.tsx +3 -6
- package/assets/templates/themes/butter/butterTheme.ts +1 -1
- package/assets/templates/themes/gothic/gothicTheme.ts +16 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +1 -1
- package/assets/templates/themes/neutral/neutralTheme.ts +6 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/clients/cli/commands/docs.doc.mjs +5 -1
- package/clients/cli/commands/docs.mjs +30 -2
- package/clients/cli/commands/experimental/icon.mjs +25 -4
- package/clients/cli/commands/experimental-render.doc.mjs +1 -1
- package/clients/cli/commands/template.mjs +204 -181
- package/clients/cli/lib/resolve-theme.mjs +16 -7
- package/foundation/discovery/component-discovery.mjs +1 -1
- package/foundation/discovery/hook-discovery.mjs +31 -8
- package/foundation/discovery/icon-set-writer.d.mts +21 -5
- package/foundation/discovery/icon-set-writer.mjs +114 -13
- package/foundation/discovery/template-adapter.mjs +2 -2
- package/foundation/doc-compiler/import.d.mts +5 -1
- package/foundation/doc-compiler/import.mjs +40 -6
- package/foundation/fs/import-url.d.mts +20 -0
- package/foundation/fs/import-url.mjs +22 -0
- package/foundation/fs/module-loader.d.mts +24 -3
- package/foundation/fs/module-loader.mjs +69 -47
- package/foundation/render/charts.d.mts +59 -0
- package/foundation/render/charts.mjs +216 -0
- package/foundation/render/embedded-imports.d.mts +7 -7
- package/foundation/render/embedded-imports.mjs +63 -54
- package/foundation/render/page-host.d.mts +4 -0
- package/foundation/render/page-host.mjs +45 -0
- package/foundation/render/page-worker.mjs +350 -57
- package/foundation/render/render-page.d.mts +11 -6
- package/foundation/render/render-page.mjs +164 -54
- package/foundation/render/ts-paths.d.mts +63 -0
- package/foundation/render/ts-paths.mjs +138 -0
- package/foundation/response/error-codes.doc.mjs +3 -3
- package/foundation/response/error-codes.mjs +3 -2
- package/foundation/text/levenshtein.d.mts +6 -1
- package/foundation/text/levenshtein.mjs +25 -9
- package/foundation/text/suggest-order.d.mts +8 -1
- package/foundation/text/suggest-order.mjs +72 -6
- package/foundation/xle/registry-core.mjs +1 -1
- package/package.json +7 -6
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
|
|
20
20
|
import {levenshteinDistance} from './levenshtein.mjs';
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The score of a near name (nearNameSlips), less a little per slip: above any
|
|
24
|
+
* name that carries only some of the typed words, below one that carries all
|
|
25
|
+
* of them.
|
|
26
|
+
*/
|
|
27
|
+
const NEAR_NAME_SCORE = 19.6;
|
|
22
28
|
/** The score a synonym match gets: an exact keyword's. */
|
|
23
29
|
const SYNONYM_SCORE = 90;
|
|
24
30
|
/** The score a name with exactly the typed words gets: an exact name's. */
|
|
@@ -59,17 +65,22 @@ export function nameWords(text) {
|
|
|
59
65
|
* closer. Tiers, best first: the same words; every typed word present; some
|
|
60
66
|
* typed word present; none. Within a tier, more of the typed words and more of
|
|
61
67
|
* the candidate's own words matched rank higher, and a name that starts with
|
|
62
|
-
* the typed name (or the reverse) gets a small lift.
|
|
68
|
+
* the typed name (or the reverse) gets a small lift. With `typos`, a near name
|
|
69
|
+
* (one or two slips from the typed name) ranks just below the names that
|
|
70
|
+
* carry every typed word.
|
|
63
71
|
* @param {string[]} typed - {@link nameWords} of the typed name
|
|
64
72
|
* @param {string} name
|
|
73
|
+
* @param {{typos?: boolean}} [options]
|
|
65
74
|
* @returns {number}
|
|
66
75
|
*/
|
|
67
|
-
function affinityOf(typed, name) {
|
|
76
|
+
function affinityOf(typed, name, {typos = false} = {}) {
|
|
68
77
|
const words = nameWords(name);
|
|
69
78
|
if (typed.length === 0 || words.length === 0) return 0;
|
|
70
79
|
const typedJoined = typed.join('');
|
|
71
80
|
const joined = words.join('');
|
|
72
81
|
if (joined === typedJoined) return 40;
|
|
82
|
+
const slips = typos ? nearNameSlips(typedJoined, joined) : 0;
|
|
83
|
+
const near = slips > 0 ? NEAR_NAME_SCORE - slips * 0.2 : 0;
|
|
73
84
|
const have = new Set(words);
|
|
74
85
|
const want = new Set(typed);
|
|
75
86
|
const covered = typed.filter(w => have.has(w)).length / typed.length;
|
|
@@ -77,7 +88,29 @@ function affinityOf(typed, name) {
|
|
|
77
88
|
const prefix =
|
|
78
89
|
joined.startsWith(typedJoined) || typedJoined.startsWith(joined) ? 1 : 0;
|
|
79
90
|
const tier = covered === 1 ? 2 : covered > 0 ? 1 : 0;
|
|
80
|
-
|
|
91
|
+
// A near name keeps its word score when that is higher: a name that also
|
|
92
|
+
// carries every typed word ranks among the other full matches.
|
|
93
|
+
return Math.max(
|
|
94
|
+
near,
|
|
95
|
+
tier * 10 + covered * 4 + precise * 2 + prefix + precise * 0.01,
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* How many slips separate a typed name from a candidate, both with their
|
|
101
|
+
* words joined, when it is a near name: an edit or two adjacent letters
|
|
102
|
+
* swapped count as one slip, one slip is allowed from five letters and two from
|
|
103
|
+
* eight. Zero when it is not a near name.
|
|
104
|
+
* @param {string} typed
|
|
105
|
+
* @param {string} name
|
|
106
|
+
* @returns {number}
|
|
107
|
+
*/
|
|
108
|
+
function nearNameSlips(typed, name) {
|
|
109
|
+
const shorter = Math.min(typed.length, name.length);
|
|
110
|
+
const cap = shorter >= 8 ? 2 : shorter >= 5 ? 1 : 0;
|
|
111
|
+
if (cap === 0 || Math.abs(typed.length - name.length) > cap) return 0;
|
|
112
|
+
const slips = levenshteinDistance(typed, name, cap, {swaps: true});
|
|
113
|
+
return slips <= cap ? slips : 0;
|
|
81
114
|
}
|
|
82
115
|
|
|
83
116
|
/**
|
|
@@ -87,14 +120,15 @@ function affinityOf(typed, name) {
|
|
|
87
120
|
* @param {string} typedName
|
|
88
121
|
* @param {T[]} items
|
|
89
122
|
* @param {(item: T) => Array<string | undefined>} namesOf
|
|
123
|
+
* @param {{typos?: boolean}} [options]
|
|
90
124
|
* @returns {Array<{item: T, best: number}>}
|
|
91
125
|
*/
|
|
92
|
-
function scoreByAffinity(typedName, items, namesOf) {
|
|
126
|
+
function scoreByAffinity(typedName, items, namesOf, options = {}) {
|
|
93
127
|
const typed = nameWords(typedName);
|
|
94
128
|
const scored = items.map((item, index) => {
|
|
95
129
|
let best = 0;
|
|
96
130
|
for (const name of namesOf(item)) {
|
|
97
|
-
if (name) best = Math.max(best, affinityOf(typed, name));
|
|
131
|
+
if (name) best = Math.max(best, affinityOf(typed, name, options));
|
|
98
132
|
}
|
|
99
133
|
return {item, index, best};
|
|
100
134
|
});
|
|
@@ -112,14 +146,46 @@ function scoreByAffinity(typedName, items, namesOf) {
|
|
|
112
146
|
* when it carries some of them, the items that carry none are left out. When
|
|
113
147
|
* no item carries one, nothing is left out. The list only ever gets shorter,
|
|
114
148
|
* and its order does not change.
|
|
149
|
+
*
|
|
150
|
+
* With `typos`, a near name (one or two slips from the typed name, as
|
|
151
|
+
* `ButonGroup` or `ButtonGorup` for ButtonGroup) ranks just below the names
|
|
152
|
+
* that carry every typed word and above the rest. With `closest` too, near
|
|
153
|
+
* names stay in the list whatever the cut leaves out, and the list is never
|
|
154
|
+
* longer than it is without `typos`.
|
|
115
155
|
* @template T
|
|
116
156
|
* @param {string} typedName
|
|
117
157
|
* @param {T[]} items
|
|
118
158
|
* @param {(item: T) => Array<string | undefined>} namesOf
|
|
119
|
-
* @param {{closest?: boolean}} [options]
|
|
159
|
+
* @param {{closest?: boolean, typos?: boolean}} [options]
|
|
120
160
|
* @returns {T[]}
|
|
121
161
|
*/
|
|
122
162
|
export function orderByAffinity(typedName, items, namesOf, options = {}) {
|
|
163
|
+
if (!options.typos) return orderByWords(typedName, items, namesOf, options);
|
|
164
|
+
const scored = scoreByAffinity(typedName, items, namesOf, {typos: true});
|
|
165
|
+
if (!options.closest) return scored.map(s => s.item);
|
|
166
|
+
const kept = new Set(orderByWords(typedName, items, namesOf, options));
|
|
167
|
+
return scored
|
|
168
|
+
.filter(s => kept.has(s.item) || isNearScore(s.best))
|
|
169
|
+
.slice(0, kept.size)
|
|
170
|
+
.map(s => s.item);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Whether a score is a near name's.
|
|
175
|
+
* @param {number} score
|
|
176
|
+
*/
|
|
177
|
+
const isNearScore = score => score < 20 && score > NEAR_NAME_SCORE - 1;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* {@link orderByAffinity} without `typos`.
|
|
181
|
+
* @template T
|
|
182
|
+
* @param {string} typedName
|
|
183
|
+
* @param {T[]} items
|
|
184
|
+
* @param {(item: T) => Array<string | undefined>} namesOf
|
|
185
|
+
* @param {{closest?: boolean}} options
|
|
186
|
+
* @returns {T[]}
|
|
187
|
+
*/
|
|
188
|
+
function orderByWords(typedName, items, namesOf, options) {
|
|
123
189
|
const scored = scoreByAffinity(typedName, items, namesOf);
|
|
124
190
|
if (!options.closest) return scored.map(s => s.item);
|
|
125
191
|
// One-letter words (`a` in `a11y`, `use-a-theme`) say nothing about which
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
|
-
* Curated alias table (from the XLE research,
|
|
19
|
+
* Curated alias table (from the XLE alias research, section 2).
|
|
20
20
|
* Single letters reserved for the highest-frequency structural set.
|
|
21
21
|
* Collision policy: case-only pairs forbidden; HTML mnemonics win the
|
|
22
22
|
* Table family; form-frequency wins contested pairs (CB, NI).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.12
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
"ignore": "^7.0.5",
|
|
118
118
|
"jiti": "^2.7.0",
|
|
119
119
|
"jscodeshift": "^17.3.0",
|
|
120
|
+
"linkedom": "^0.18.14",
|
|
120
121
|
"node-diff3": "3.2.1",
|
|
121
122
|
"postcss": "^8.5.23",
|
|
122
123
|
"postcss-selector-parser": "^7.1.6",
|
|
@@ -124,7 +125,7 @@
|
|
|
124
125
|
"zod": "^4.4.3"
|
|
125
126
|
},
|
|
126
127
|
"peerDependencies": {
|
|
127
|
-
"@astryxdesign/core": "
|
|
128
|
+
"@astryxdesign/core": "*"
|
|
128
129
|
},
|
|
129
130
|
"peerDependenciesMeta": {
|
|
130
131
|
"@astryxdesign/core": {
|
|
@@ -132,10 +133,10 @@
|
|
|
132
133
|
}
|
|
133
134
|
},
|
|
134
135
|
"devDependencies": {
|
|
135
|
-
"@astryxdesign/charts": "
|
|
136
|
-
"@astryxdesign/core": "
|
|
137
|
-
"@astryxdesign/lab": "
|
|
138
|
-
"@astryxdesign/theme-neutral": "
|
|
136
|
+
"@astryxdesign/charts": "*",
|
|
137
|
+
"@astryxdesign/core": "*",
|
|
138
|
+
"@astryxdesign/lab": "*",
|
|
139
|
+
"@astryxdesign/theme-neutral": "*",
|
|
139
140
|
"@heroicons/react": "^2.2.0",
|
|
140
141
|
"@stylexjs/stylex": "^0.19.0",
|
|
141
142
|
"@types/babel__core": "^7.20.5",
|