@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.
Files changed (113) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/api/build/blocks/blocks.d.mts +41 -0
  3. package/api/build/blocks/blocks.mjs +118 -68
  4. package/api/component/__fixtures__/resolutions/modules.txt +3 -3
  5. package/api/docs/_adapter.d.mts +22 -0
  6. package/api/docs/_adapter.mjs +81 -3
  7. package/api/docs/docs.doc.mjs +5 -5
  8. package/api/docs/docs.type.d.mts +21 -0
  9. package/api/docs/docs.type.mjs +11 -0
  10. package/api/docs/list/list.d.mts +5 -1
  11. package/api/docs/list/list.mjs +72 -6
  12. package/api/docs/node/node.mjs +2 -40
  13. package/api/doctor/doctor.d.mts +4 -4
  14. package/api/doctor/doctor.mjs +248 -78
  15. package/api/icon/_authoring.mjs +8 -1
  16. package/api/icon/add/add.mjs +45 -5
  17. package/api/icon/icon.type.d.mts +24 -0
  18. package/api/icon/icon.type.mjs +6 -0
  19. package/api/icon/iconAdd.doc.mjs +1 -1
  20. package/api/icon/map/map.mjs +11 -4
  21. package/api/index.d.mts +1 -0
  22. package/api/index.mjs +1 -0
  23. package/api/integration/add-helpers.d.mts +5 -1
  24. package/api/integration/add-helpers.mjs +1 -1
  25. package/api/render/_adapter.mjs +9 -0
  26. package/api/render/render.doc.mjs +3 -3
  27. package/api/render/render.type.d.mts +1 -1
  28. package/api/render/render.type.mjs +1 -1
  29. package/api/search/ORDERING.md +3 -0
  30. package/api/search/_adapter.d.mts +32 -3
  31. package/api/search/_adapter.mjs +50 -22
  32. package/api/search/_fit-order.d.mts +47 -0
  33. package/api/search/_fit-order.mjs +257 -0
  34. package/api/search/_main-searcher.mjs +15 -5
  35. package/api/search/exportSearchIndex.doc.d.mts +10 -0
  36. package/api/search/exportSearchIndex.doc.mjs +58 -0
  37. package/api/search/rankSearchIndex.doc.d.mts +10 -0
  38. package/api/search/rankSearchIndex.doc.mjs +79 -0
  39. package/api/search/search-index.d.mts +44 -0
  40. package/api/search/search-index.mjs +270 -0
  41. package/api/search/search.type.d.mts +28 -0
  42. package/api/search/search.type.mjs +17 -0
  43. package/api/swizzle/_moduleGraph.d.mts +7 -0
  44. package/api/swizzle/_moduleGraph.mjs +191 -83
  45. package/api/swizzle/copy/copy.mjs +28 -6
  46. package/api/template/skeleton/skeleton.mjs +1 -1
  47. package/api/template/template.mjs +1 -0
  48. package/assets/codemods/transforms/v0.1.0/drop-xds-prefix-imports.mjs +1 -1
  49. package/assets/codemods/transforms/v0.1.0/index.mjs +1 -1
  50. package/assets/discover/official-packages.json +16 -0
  51. package/assets/docs/styling-overview.doc.mjs +3 -3
  52. package/assets/docs/tree/icon-sets.doc.mjs +4 -4
  53. package/assets/docs/tree/render-pages.doc.mjs +3 -3
  54. package/assets/docs/tree/tailwind.doc.mjs +41 -1
  55. package/assets/docs/tree/type-scale.doc.mjs +19 -2
  56. package/assets/templates/blocks/components/Hooks/useInputStatusIconHookUsage.tsx +1 -0
  57. package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.doc.mjs +14 -0
  58. package/assets/templates/blocks/components/Hooks/useInteractiveRoleHookUsage.tsx +56 -0
  59. package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.doc.mjs +2 -2
  60. package/assets/templates/blocks/components/Hooks/useStreamingTextHookUsage.tsx +66 -10
  61. package/assets/templates/blocks/components/Link/useLinkifyHookUsage.doc.mjs +14 -0
  62. package/assets/templates/blocks/components/Link/useLinkifyHookUsage.tsx +39 -0
  63. package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.doc.mjs +14 -0
  64. package/assets/templates/blocks/components/PowerSearch/usePowerSearchConfigHookUsage.tsx +83 -0
  65. package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.doc.mjs +14 -0
  66. package/assets/templates/blocks/components/Table/RowsVirtualizationHookUsage.tsx +41 -0
  67. package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.doc.mjs +14 -0
  68. package/assets/templates/blocks/components/Table/useTableColumnSettingsStateHookUsage.tsx +97 -0
  69. package/assets/templates/pages/table-filter/page.tsx +15 -23
  70. package/assets/templates/pages/table-grouped/page.tsx +30 -30
  71. package/assets/templates/pages/table-inbox/page.tsx +3 -6
  72. package/assets/templates/themes/butter/butterTheme.ts +1 -1
  73. package/assets/templates/themes/gothic/gothicTheme.ts +16 -0
  74. package/assets/templates/themes/matcha/matchaTheme.ts +1 -1
  75. package/assets/templates/themes/neutral/neutralTheme.ts +6 -0
  76. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +1 -1
  77. package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
  78. package/clients/cli/commands/docs.doc.mjs +5 -1
  79. package/clients/cli/commands/docs.mjs +30 -2
  80. package/clients/cli/commands/experimental/icon.mjs +25 -4
  81. package/clients/cli/commands/experimental-render.doc.mjs +1 -1
  82. package/clients/cli/commands/template.mjs +204 -181
  83. package/clients/cli/lib/resolve-theme.mjs +16 -7
  84. package/foundation/discovery/component-discovery.mjs +1 -1
  85. package/foundation/discovery/hook-discovery.mjs +31 -8
  86. package/foundation/discovery/icon-set-writer.d.mts +21 -5
  87. package/foundation/discovery/icon-set-writer.mjs +114 -13
  88. package/foundation/discovery/template-adapter.mjs +2 -2
  89. package/foundation/doc-compiler/import.d.mts +5 -1
  90. package/foundation/doc-compiler/import.mjs +40 -6
  91. package/foundation/fs/import-url.d.mts +20 -0
  92. package/foundation/fs/import-url.mjs +22 -0
  93. package/foundation/fs/module-loader.d.mts +24 -3
  94. package/foundation/fs/module-loader.mjs +69 -47
  95. package/foundation/render/charts.d.mts +59 -0
  96. package/foundation/render/charts.mjs +216 -0
  97. package/foundation/render/embedded-imports.d.mts +7 -7
  98. package/foundation/render/embedded-imports.mjs +63 -54
  99. package/foundation/render/page-host.d.mts +4 -0
  100. package/foundation/render/page-host.mjs +45 -0
  101. package/foundation/render/page-worker.mjs +350 -57
  102. package/foundation/render/render-page.d.mts +11 -6
  103. package/foundation/render/render-page.mjs +164 -54
  104. package/foundation/render/ts-paths.d.mts +63 -0
  105. package/foundation/render/ts-paths.mjs +138 -0
  106. package/foundation/response/error-codes.doc.mjs +3 -3
  107. package/foundation/response/error-codes.mjs +3 -2
  108. package/foundation/text/levenshtein.d.mts +6 -1
  109. package/foundation/text/levenshtein.mjs +25 -9
  110. package/foundation/text/suggest-order.d.mts +8 -1
  111. package/foundation/text/suggest-order.mjs +72 -6
  112. package/foundation/xle/registry-core.mjs +1 -1
  113. 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
- return tier * 10 + covered * 4 + precise * 2 + prefix + precise * 0.01;
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, paste P2376666892 §2).
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-canary.f543ec7",
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": "0.7.12-canary.f543ec7"
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": "0.7.12-canary.f543ec7",
136
- "@astryxdesign/core": "0.7.12-canary.f543ec7",
137
- "@astryxdesign/lab": "0.7.12-canary.f543ec7",
138
- "@astryxdesign/theme-neutral": "0.7.12-canary.f543ec7",
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",