@astryxdesign/cli 0.7.11-canary.ec945c9 → 0.7.11
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 +51 -0
- package/api/build/kit/rank.mjs +4 -21
- package/api/build/kit/words.d.mts +0 -1
- package/api/build/kit/words.mjs +1 -1
- package/api/icon/_adapter.d.mts +2 -3
- package/api/icon/_adapter.mjs +2 -8
- package/api/icon/_authoring.d.mts +0 -1
- package/api/icon/_authoring.mjs +66 -586
- package/api/icon/_records.d.mts +1 -1
- package/api/icon/_records.mjs +0 -1
- package/api/icon/add/add.mjs +38 -224
- package/api/icon/icon.type.d.mts +2 -22
- package/api/icon/icon.type.mjs +2 -6
- package/api/icon/iconAdd.doc.mjs +2 -2
- package/api/icon/iconNewDefinition.doc.mjs +2 -3
- package/api/icon/iconNewSet.doc.mjs +4 -4
- package/api/icon/search/search.mjs +9 -10
- package/api/integration/add-helpers.d.mts +1 -11
- package/api/integration/add-helpers.mjs +2 -5
- package/api/integration/authoring-checks.d.mts +2 -0
- package/api/integration/authoring-checks.mjs +6 -1
- package/api/logger.mjs +1 -2
- package/api/swizzle/_adapter.d.mts +0 -1
- package/api/swizzle/_adapter.mjs +1 -4
- package/api/swizzle/copy/copy.d.mts +43 -2
- package/api/swizzle/copy/copy.mjs +314 -194
- package/api/swizzle/swizzle.d.mts +2 -0
- package/api/swizzle/swizzle.doc.mjs +4 -8
- package/api/swizzle/swizzle.mjs +7 -3
- package/api/swizzle/swizzle.type.d.mts +1 -1
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/assets/discover/official-packages.json +0 -12
- package/assets/docs/tree/icon-sets.doc.mjs +5 -11
- package/assets/templates/pages/file-explorer/page.tsx +79 -103
- package/assets/templates/pages/table-grouped/page.tsx +232 -160
- package/assets/templates/pages/table-grouped/template.doc.mjs +2 -0
- package/assets/templates/pages/theme-showcase/page.tsx +792 -724
- package/assets/templates/pages/theme-showcase/template.doc.mjs +5 -4
- package/clients/cli/commands/experimental/icon.mjs +10 -31
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +1 -2
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/commands/swizzle.doc.mjs +3 -6
- package/clients/cli/commands/swizzle.mjs +9 -8
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/doc-types.mjs +2 -9
- package/foundation/discovery/icon-ranking.d.mts +3 -27
- package/foundation/discovery/icon-ranking.mjs +8 -125
- package/foundation/discovery/icon-set-checks.mjs +35 -44
- package/foundation/discovery/icon-set-discovery.d.mts +0 -13
- package/foundation/discovery/icon-set-discovery.mjs +0 -25
- package/foundation/discovery/icon-set-writer.d.mts +16 -238
- package/foundation/discovery/icon-set-writer.mjs +79 -676
- package/foundation/discovery/module-exports.d.mts +2 -3
- package/foundation/discovery/module-exports.mjs +37 -167
- package/foundation/fs/paths.d.mts +1 -2
- package/foundation/fs/paths.mjs +4 -3
- package/package.json +6 -6
- package/api/icon/_default-look.d.mts +0 -155
- package/api/icon/_default-look.mjs +0 -474
- package/api/swizzle/_moduleGraph.d.mts +0 -162
- package/api/swizzle/_moduleGraph.mjs +0 -754
- package/foundation/text/shell-arg.d.mts +0 -14
- package/foundation/text/shell-arg.mjs +0 -17
|
@@ -53,12 +53,11 @@ export function moduleExportSource(file: string, exportName: string, seen?: Set<
|
|
|
53
53
|
export function moduleExportNames(file: string): string[] | null;
|
|
54
54
|
/**
|
|
55
55
|
* Every export of a module with where it is declared, in one pass: the same
|
|
56
|
-
* answers as
|
|
57
|
-
* module.
|
|
56
|
+
* answers as {@link moduleExportOrigin} for each name, read once per module.
|
|
58
57
|
* Pass one `memo` to calls that read the same package, so a module behind
|
|
59
58
|
* many barrels is read once; a memo keeps value and type reads apart, and
|
|
60
59
|
* nothing is kept between memos. One difference follows ESM where
|
|
61
|
-
* {@link
|
|
60
|
+
* {@link moduleExportOrigin} does not: a name re-exported by name from a
|
|
62
61
|
* module that cannot be followed is absent, never filled from `export *`.
|
|
63
62
|
* @param {string} file
|
|
64
63
|
* @param {{types?: boolean, memo?: Map<string, Map<string, {file: string, name: string}>>}} [options]
|
|
@@ -161,46 +161,17 @@ const nodesByTree = new WeakMap();
|
|
|
161
161
|
* @returns {readonly any[]}
|
|
162
162
|
*/
|
|
163
163
|
function nodesOfType(node, type) {
|
|
164
|
-
return cachedNodes(node, `all\0${type}`, () =>
|
|
165
|
-
collectNodesOfType(node, type, []),
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* The module declarations of `type` at a program's top level, in source
|
|
171
|
-
* order: a library file is read without a walk of every function in it. A
|
|
172
|
-
* declaration nested in a namespace is not one of them. Only the readers of
|
|
173
|
-
* icon-set libraries use this: the parse-failure and re-export checks,
|
|
174
|
-
* {@link moduleExportOrigin} and the readers built on it, and
|
|
175
|
-
* {@link followedExportNames}. {@link bindingOrigin}, and so
|
|
176
|
-
* {@link aliasedOrigin}, {@link elementPropOrigins} and
|
|
177
|
-
* {@link moduleExportOrigins}, read with {@link nodesOfType}, as do the
|
|
178
|
-
* other readers.
|
|
179
|
-
* @param {any} program
|
|
180
|
-
* @param {string} type
|
|
181
|
-
* @returns {readonly any[]}
|
|
182
|
-
*/
|
|
183
|
-
function moduleDeclarations(program, type) {
|
|
184
|
-
return cachedNodes(program, `top\0${type}`, () => topLevel(program, type));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @param {any} node
|
|
189
|
-
* @param {string} key
|
|
190
|
-
* @param {() => readonly any[]} find
|
|
191
|
-
* @returns {readonly any[]}
|
|
192
|
-
*/
|
|
193
|
-
function cachedNodes(node, key, find) {
|
|
194
164
|
if (node == null || typeof node !== 'object') return [];
|
|
195
165
|
let byType = nodesByTree.get(node);
|
|
196
166
|
if (!byType) {
|
|
197
167
|
byType = new Map();
|
|
198
168
|
nodesByTree.set(node, byType);
|
|
199
169
|
}
|
|
200
|
-
|
|
201
|
-
if (
|
|
202
|
-
|
|
203
|
-
|
|
170
|
+
let found = byType.get(type);
|
|
171
|
+
if (!found) {
|
|
172
|
+
found = collectNodesOfType(node, type, []);
|
|
173
|
+
byType.set(type, found);
|
|
174
|
+
}
|
|
204
175
|
return found;
|
|
205
176
|
}
|
|
206
177
|
|
|
@@ -344,7 +315,7 @@ export function moduleParseFailure(file) {
|
|
|
344
315
|
};
|
|
345
316
|
}
|
|
346
317
|
for (const type of ['ExportNamedDeclaration', 'ExportAllDeclaration']) {
|
|
347
|
-
for (const node of
|
|
318
|
+
for (const node of nodesOfType(ast.program, type)) {
|
|
348
319
|
const specifier = node.source?.value;
|
|
349
320
|
if (typeof specifier !== 'string' || !specifier.startsWith('.')) {
|
|
350
321
|
continue;
|
|
@@ -373,7 +344,7 @@ export function unfollowedReexports(file) {
|
|
|
373
344
|
/** @type {Set<string>} */
|
|
374
345
|
const missing = new Set();
|
|
375
346
|
for (const type of ['ExportNamedDeclaration', 'ExportAllDeclaration']) {
|
|
376
|
-
for (const node of
|
|
347
|
+
for (const node of nodesOfType(ast.program, type)) {
|
|
377
348
|
const specifier = node.source?.value;
|
|
378
349
|
if (typeof specifier !== 'string' || node.exportKind === 'type') continue;
|
|
379
350
|
if (!resolveModuleOrPackage(specifier, file)) missing.add(specifier);
|
|
@@ -637,12 +608,11 @@ export function moduleExportNames(file) {
|
|
|
637
608
|
|
|
638
609
|
/**
|
|
639
610
|
* Every export of a module with where it is declared, in one pass: the same
|
|
640
|
-
* answers as
|
|
641
|
-
* module.
|
|
611
|
+
* answers as {@link moduleExportOrigin} for each name, read once per module.
|
|
642
612
|
* Pass one `memo` to calls that read the same package, so a module behind
|
|
643
613
|
* many barrels is read once; a memo keeps value and type reads apart, and
|
|
644
614
|
* nothing is kept between memos. One difference follows ESM where
|
|
645
|
-
* {@link
|
|
615
|
+
* {@link moduleExportOrigin} does not: a name re-exported by name from a
|
|
646
616
|
* module that cannot be followed is absent, never filled from `export *`.
|
|
647
617
|
* @param {string} file
|
|
648
618
|
* @param {{types?: boolean, memo?: Map<string, Map<string, {file: string, name: string}>>}} [options]
|
|
@@ -707,12 +677,7 @@ function exportOriginsOf(file, read) {
|
|
|
707
677
|
for (const node of declarations) {
|
|
708
678
|
for (const name of declaredNames(node.declaration, types)) {
|
|
709
679
|
named.add(name);
|
|
710
|
-
if (!origins.has(name)) {
|
|
711
|
-
origins.set(
|
|
712
|
-
name,
|
|
713
|
-
declaredOrigin(ast, file, node.declaration, name, types),
|
|
714
|
-
);
|
|
715
|
-
}
|
|
680
|
+
if (!origins.has(name)) origins.set(name, {file, name});
|
|
716
681
|
}
|
|
717
682
|
}
|
|
718
683
|
for (const [exportName, entries] of specifiers) {
|
|
@@ -732,7 +697,7 @@ function exportOriginsOf(file, read) {
|
|
|
732
697
|
origin =
|
|
733
698
|
result.origins.get(local) ??
|
|
734
699
|
(result.low < Infinity
|
|
735
|
-
?
|
|
700
|
+
? moduleExportOrigin(target, local, new Set(), {types})
|
|
736
701
|
: null);
|
|
737
702
|
}
|
|
738
703
|
} else {
|
|
@@ -1122,34 +1087,23 @@ export function staticExportObject(file, exportNames) {
|
|
|
1122
1087
|
/**
|
|
1123
1088
|
* A module's runtime named exports, indexed once per parsed tree: the
|
|
1124
1089
|
* export declarations that declare something, and each export specifier by
|
|
1125
|
-
* the name it exports, in source order.
|
|
1126
|
-
*
|
|
1127
|
-
* @type {WeakMap<object, Map<Function, {declarations: any[], specifiers: Map<string, Array<{node: any, specifier: any}>>}>>}
|
|
1090
|
+
* the name it exports, in source order.
|
|
1091
|
+
* @type {WeakMap<object, {declarations: any[], specifiers: Map<string, Array<{node: any, specifier: any}>>}>}
|
|
1128
1092
|
*/
|
|
1129
1093
|
const namedExportIndexes = new WeakMap();
|
|
1130
1094
|
/** The same index with type-only exports included. */
|
|
1131
1095
|
const typedExportIndexes = new WeakMap();
|
|
1132
1096
|
|
|
1133
|
-
/**
|
|
1134
|
-
|
|
1135
|
-
* @param {boolean} [types] include type-only exports
|
|
1136
|
-
* @param {(node: any, type: string) => readonly any[]} [read] how the
|
|
1137
|
-
* module's export declarations are read
|
|
1138
|
-
*/
|
|
1139
|
-
function namedExportIndex(program, types = false, read = nodesOfType) {
|
|
1097
|
+
/** @param {any} program @param {boolean} [types] include type-only exports */
|
|
1098
|
+
function namedExportIndex(program, types = false) {
|
|
1140
1099
|
const indexes = types ? typedExportIndexes : namedExportIndexes;
|
|
1141
|
-
|
|
1142
|
-
if (!byReader) {
|
|
1143
|
-
byReader = new Map();
|
|
1144
|
-
indexes.set(program, byReader);
|
|
1145
|
-
}
|
|
1146
|
-
const cached = byReader.get(read);
|
|
1100
|
+
const cached = indexes.get(program);
|
|
1147
1101
|
if (cached) return cached;
|
|
1148
1102
|
/** @type {any[]} */
|
|
1149
1103
|
const declarations = [];
|
|
1150
1104
|
/** @type {Map<string, Array<{node: any, specifier: any}>>} */
|
|
1151
1105
|
const specifiers = new Map();
|
|
1152
|
-
for (const node of
|
|
1106
|
+
for (const node of nodesOfType(program, 'ExportNamedDeclaration')) {
|
|
1153
1107
|
if (node.exportKind === 'type' && !types) continue;
|
|
1154
1108
|
if (node.declaration) declarations.push(node);
|
|
1155
1109
|
for (const specifier of node.specifiers ?? []) {
|
|
@@ -1166,7 +1120,7 @@ function namedExportIndex(program, types = false, read = nodesOfType) {
|
|
|
1166
1120
|
}
|
|
1167
1121
|
}
|
|
1168
1122
|
const index = {declarations, specifiers};
|
|
1169
|
-
|
|
1123
|
+
indexes.set(program, index);
|
|
1170
1124
|
return index;
|
|
1171
1125
|
}
|
|
1172
1126
|
|
|
@@ -1188,21 +1142,6 @@ export function moduleExportOrigin(
|
|
|
1188
1142
|
seen = new Set(),
|
|
1189
1143
|
{types = false} = {},
|
|
1190
1144
|
) {
|
|
1191
|
-
return exportOrigin(file, exportName, seen, moduleDeclarations, types);
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
/**
|
|
1195
|
-
* {@link moduleExportOrigin} with the reader of a module's export
|
|
1196
|
-
* declarations: {@link moduleDeclarations} for icon-set libraries, or
|
|
1197
|
-
* {@link nodesOfType} for every other caller.
|
|
1198
|
-
* @param {string} file
|
|
1199
|
-
* @param {string} exportName
|
|
1200
|
-
* @param {Set<string>} seen
|
|
1201
|
-
* @param {(node: any, type: string) => readonly any[]} read
|
|
1202
|
-
* @param {boolean} [types] also follow type-only exports and declarations
|
|
1203
|
-
* @returns {{file: string, name: string} | null}
|
|
1204
|
-
*/
|
|
1205
|
-
function exportOrigin(file, exportName, seen, read, types = false) {
|
|
1206
1145
|
const identity = `${file}\0${exportName}`;
|
|
1207
1146
|
if (seen.has(identity)) return null;
|
|
1208
1147
|
seen.add(identity);
|
|
@@ -1213,18 +1152,10 @@ function exportOrigin(file, exportName, seen, read, types = false) {
|
|
|
1213
1152
|
} catch {
|
|
1214
1153
|
return null;
|
|
1215
1154
|
}
|
|
1216
|
-
const {declarations, specifiers} = namedExportIndex(ast.program, types
|
|
1155
|
+
const {declarations, specifiers} = namedExportIndex(ast.program, types);
|
|
1217
1156
|
for (const node of declarations) {
|
|
1218
1157
|
if (declarationExports(node.declaration, exportName, types)) {
|
|
1219
|
-
return
|
|
1220
|
-
ast,
|
|
1221
|
-
file,
|
|
1222
|
-
node.declaration,
|
|
1223
|
-
exportName,
|
|
1224
|
-
types,
|
|
1225
|
-
seen,
|
|
1226
|
-
read,
|
|
1227
|
-
);
|
|
1158
|
+
return {file, name: exportName};
|
|
1228
1159
|
}
|
|
1229
1160
|
}
|
|
1230
1161
|
for (const {node, specifier} of specifiers.get(exportName) ?? []) {
|
|
@@ -1232,28 +1163,28 @@ function exportOrigin(file, exportName, seen, read, types = false) {
|
|
|
1232
1163
|
if (node.source) {
|
|
1233
1164
|
const target = resolveModuleOrPackage(node.source.value, file);
|
|
1234
1165
|
const origin = target
|
|
1235
|
-
?
|
|
1166
|
+
? moduleExportOrigin(target, local, seen, {types})
|
|
1236
1167
|
: null;
|
|
1237
1168
|
if (origin) return origin;
|
|
1238
1169
|
continue;
|
|
1239
1170
|
}
|
|
1240
|
-
return bindingOrigin(ast, file, local, seen, types
|
|
1171
|
+
return bindingOrigin(ast, file, local, seen, types);
|
|
1241
1172
|
}
|
|
1242
1173
|
if (exportName === 'default') {
|
|
1243
|
-
for (const node of
|
|
1174
|
+
for (const node of nodesOfType(ast.program, 'ExportDefaultDeclaration')) {
|
|
1244
1175
|
const declaration = node.declaration;
|
|
1245
1176
|
if (!types && !runtimeDefault(declaration)) continue;
|
|
1246
1177
|
if (declaration.type === 'Identifier') {
|
|
1247
|
-
return bindingOrigin(ast, file, declaration.name, seen, types
|
|
1178
|
+
return bindingOrigin(ast, file, declaration.name, seen, types);
|
|
1248
1179
|
}
|
|
1249
1180
|
return {file, name: 'default'};
|
|
1250
1181
|
}
|
|
1251
1182
|
}
|
|
1252
|
-
for (const node of
|
|
1183
|
+
for (const node of nodesOfType(ast.program, 'ExportAllDeclaration')) {
|
|
1253
1184
|
if ((node.exportKind === 'type' && !types) || node.exported) continue;
|
|
1254
1185
|
const target = resolveModuleOrPackage(node.source?.value, file);
|
|
1255
1186
|
const origin = target
|
|
1256
|
-
?
|
|
1187
|
+
? moduleExportOrigin(target, exportName, seen, {types})
|
|
1257
1188
|
: null;
|
|
1258
1189
|
if (origin) return origin;
|
|
1259
1190
|
}
|
|
@@ -1309,10 +1240,7 @@ function originGapReason(file, exportName, seen = new Set()) {
|
|
|
1309
1240
|
}
|
|
1310
1241
|
/** @type {string | null} */
|
|
1311
1242
|
let local = null;
|
|
1312
|
-
for (const node of
|
|
1313
|
-
ast.program,
|
|
1314
|
-
'ExportNamedDeclaration',
|
|
1315
|
-
)) {
|
|
1243
|
+
for (const node of nodesOfType(ast.program, 'ExportNamedDeclaration')) {
|
|
1316
1244
|
for (const specifier of node.specifiers ?? []) {
|
|
1317
1245
|
const exported = specifier.exported?.name ?? specifier.exported?.value;
|
|
1318
1246
|
if (exported !== exportName) continue;
|
|
@@ -1333,10 +1261,7 @@ function originGapReason(file, exportName, seen = new Set()) {
|
|
|
1333
1261
|
}
|
|
1334
1262
|
}
|
|
1335
1263
|
if (exportName === 'default') {
|
|
1336
|
-
for (const node of
|
|
1337
|
-
ast.program,
|
|
1338
|
-
'ExportDefaultDeclaration',
|
|
1339
|
-
)) {
|
|
1264
|
+
for (const node of nodesOfType(ast.program, 'ExportDefaultDeclaration')) {
|
|
1340
1265
|
if (node.declaration?.type === 'Identifier') {
|
|
1341
1266
|
local = node.declaration.name;
|
|
1342
1267
|
}
|
|
@@ -1344,10 +1269,7 @@ function originGapReason(file, exportName, seen = new Set()) {
|
|
|
1344
1269
|
}
|
|
1345
1270
|
if (!local) {
|
|
1346
1271
|
// Bound behind `export *`: the module it comes from says why.
|
|
1347
|
-
for (const node of
|
|
1348
|
-
ast.program,
|
|
1349
|
-
'ExportAllDeclaration',
|
|
1350
|
-
)) {
|
|
1272
|
+
for (const node of nodesOfType(ast.program, 'ExportAllDeclaration')) {
|
|
1351
1273
|
if (node.exportKind === 'type' || node.exported) continue;
|
|
1352
1274
|
const target = resolveModuleOrPackage(node.source?.value, file);
|
|
1353
1275
|
if (
|
|
@@ -1408,10 +1330,7 @@ export function followedExportNames(
|
|
|
1408
1330
|
}
|
|
1409
1331
|
/** @type {Set<string>} */
|
|
1410
1332
|
const names = new Set();
|
|
1411
|
-
for (const node of
|
|
1412
|
-
ast.program,
|
|
1413
|
-
'ExportNamedDeclaration',
|
|
1414
|
-
)) {
|
|
1333
|
+
for (const node of nodesOfType(ast.program, 'ExportNamedDeclaration')) {
|
|
1415
1334
|
if (node.exportKind === 'type' && !types) continue;
|
|
1416
1335
|
const declaration = node.declaration;
|
|
1417
1336
|
if (declaration && (declaration.declare !== true || types)) {
|
|
@@ -1441,7 +1360,7 @@ export function followedExportNames(
|
|
|
1441
1360
|
}
|
|
1442
1361
|
}
|
|
1443
1362
|
}
|
|
1444
|
-
for (const node of
|
|
1363
|
+
for (const node of nodesOfType(ast.program, 'ExportAllDeclaration')) {
|
|
1445
1364
|
if ((node.exportKind === 'type' && !types) || node.exported) continue;
|
|
1446
1365
|
const target = resolveModuleOrPackage(node.source?.value, file);
|
|
1447
1366
|
if (target) {
|
|
@@ -1503,7 +1422,7 @@ export function exportValueKind(file, exportName) {
|
|
|
1503
1422
|
return 'unknown';
|
|
1504
1423
|
};
|
|
1505
1424
|
if (origin.name === 'default') {
|
|
1506
|
-
const [node] =
|
|
1425
|
+
const [node] = nodesOfType(ast.program, 'ExportDefaultDeclaration');
|
|
1507
1426
|
return node ? kindOf(node.declaration) : 'unknown';
|
|
1508
1427
|
}
|
|
1509
1428
|
for (const statement of ast.program.body) {
|
|
@@ -1560,7 +1479,7 @@ export function exportScalarType(file, exportName) {
|
|
|
1560
1479
|
return null;
|
|
1561
1480
|
};
|
|
1562
1481
|
if (origin.name === 'default') {
|
|
1563
|
-
const [node] =
|
|
1482
|
+
const [node] = nodesOfType(ast.program, 'ExportDefaultDeclaration');
|
|
1564
1483
|
return node ? typeOf(node.declaration) : null;
|
|
1565
1484
|
}
|
|
1566
1485
|
for (const statement of ast.program.body) {
|
|
@@ -1703,48 +1622,6 @@ export function elementPropOrigins(file, {sources, name, prop, unwrap}) {
|
|
|
1703
1622
|
return origins;
|
|
1704
1623
|
}
|
|
1705
1624
|
|
|
1706
|
-
/**
|
|
1707
|
-
* Where a declared export is defined. An `export const X = Y` whose value is
|
|
1708
|
-
* another binding is that binding, so an alias of an imported value has the
|
|
1709
|
-
* imported value's origin.
|
|
1710
|
-
* @param {any} ast
|
|
1711
|
-
* @param {string} file
|
|
1712
|
-
* @param {any} declaration
|
|
1713
|
-
* @param {string} name
|
|
1714
|
-
* @param {boolean} types
|
|
1715
|
-
* @param {Set<string>} [seen]
|
|
1716
|
-
* @param {(node: any, type: string) => readonly any[]} [read]
|
|
1717
|
-
* @returns {{file: string, name: string}}
|
|
1718
|
-
*/
|
|
1719
|
-
function declaredOrigin(
|
|
1720
|
-
ast,
|
|
1721
|
-
file,
|
|
1722
|
-
declaration,
|
|
1723
|
-
name,
|
|
1724
|
-
types,
|
|
1725
|
-
seen = new Set(),
|
|
1726
|
-
read = nodesOfType,
|
|
1727
|
-
) {
|
|
1728
|
-
if (
|
|
1729
|
-
declaration?.type === 'VariableDeclaration' &&
|
|
1730
|
-
declaration.kind === 'const'
|
|
1731
|
-
) {
|
|
1732
|
-
for (const declarator of declaration.declarations) {
|
|
1733
|
-
if (
|
|
1734
|
-
declarator.id?.type === 'Identifier' &&
|
|
1735
|
-
declarator.id.name === name &&
|
|
1736
|
-
declarator.init?.type === 'Identifier'
|
|
1737
|
-
) {
|
|
1738
|
-
const init = declarator.init.name;
|
|
1739
|
-
return (
|
|
1740
|
-
bindingOrigin(ast, file, init, seen, types, read) ?? {file, name}
|
|
1741
|
-
);
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
return {file, name};
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
1625
|
/**
|
|
1749
1626
|
* Where a top-level binding of a parsed module comes from: an import from a
|
|
1750
1627
|
* local module is followed to its origin; anything else is declared here.
|
|
@@ -1753,18 +1630,9 @@ function declaredOrigin(
|
|
|
1753
1630
|
* @param {string} local
|
|
1754
1631
|
* @param {Set<string>} seen
|
|
1755
1632
|
* @param {boolean} [types] also follow `import type`
|
|
1756
|
-
* @param {(node: any, type: string) => readonly any[]} [read] how an
|
|
1757
|
-
* imported module's export declarations are read
|
|
1758
1633
|
* @returns {{file: string, name: string} | null}
|
|
1759
1634
|
*/
|
|
1760
|
-
function bindingOrigin(
|
|
1761
|
-
ast,
|
|
1762
|
-
file,
|
|
1763
|
-
local,
|
|
1764
|
-
seen,
|
|
1765
|
-
types = false,
|
|
1766
|
-
read = nodesOfType,
|
|
1767
|
-
) {
|
|
1635
|
+
function bindingOrigin(ast, file, local, seen, types = false) {
|
|
1768
1636
|
for (const node of ast.program.body) {
|
|
1769
1637
|
if (
|
|
1770
1638
|
node.type !== 'ImportDeclaration' ||
|
|
@@ -1778,7 +1646,9 @@ function bindingOrigin(
|
|
|
1778
1646
|
const imported =
|
|
1779
1647
|
specifier.imported?.name ?? specifier.imported?.value ?? local;
|
|
1780
1648
|
const target = resolveModuleOrPackage(node.source.value, file);
|
|
1781
|
-
return target
|
|
1649
|
+
return target
|
|
1650
|
+
? moduleExportOrigin(target, imported, seen, {types})
|
|
1651
|
+
: null;
|
|
1782
1652
|
}
|
|
1783
1653
|
}
|
|
1784
1654
|
return {file, name: local};
|
|
@@ -166,8 +166,7 @@ export function discoverExternalPackages(startDir?: string): {
|
|
|
166
166
|
}[];
|
|
167
167
|
/**
|
|
168
168
|
* List available component directories in packages/core/src.
|
|
169
|
-
*
|
|
170
|
-
* directories hold shared infrastructure and are never listed.
|
|
169
|
+
* Returns directory names that contain Astryx*.tsx files.
|
|
171
170
|
* @param {string} coreDir
|
|
172
171
|
*/
|
|
173
172
|
export function listComponents(coreDir: string): string[];
|
package/foundation/fs/paths.mjs
CHANGED
|
@@ -854,8 +854,7 @@ export function discoverExternalPackages(startDir = process.cwd()) {
|
|
|
854
854
|
|
|
855
855
|
/**
|
|
856
856
|
* List available component directories in packages/core/src.
|
|
857
|
-
*
|
|
858
|
-
* directories hold shared infrastructure and are never listed.
|
|
857
|
+
* Returns directory names that contain Astryx*.tsx files.
|
|
859
858
|
* @param {string} coreDir
|
|
860
859
|
*/
|
|
861
860
|
export function listComponents(coreDir) {
|
|
@@ -866,7 +865,9 @@ export function listComponents(coreDir) {
|
|
|
866
865
|
return entries
|
|
867
866
|
.filter(e => {
|
|
868
867
|
if (!e.isDirectory()) return false;
|
|
869
|
-
|
|
868
|
+
// Skip non-component dirs
|
|
869
|
+
if (['hooks', 'theme', 'utils'].includes(e.name)) return false;
|
|
870
|
+
return true;
|
|
870
871
|
})
|
|
871
872
|
.map(e => e.name)
|
|
872
873
|
.sort();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.7.11
|
|
3
|
+
"version": "0.7.11",
|
|
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",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"zod": "^4.4.3"
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
|
-
"@astryxdesign/core": "
|
|
127
|
+
"@astryxdesign/core": "*"
|
|
128
128
|
},
|
|
129
129
|
"peerDependenciesMeta": {
|
|
130
130
|
"@astryxdesign/core": {
|
|
@@ -132,10 +132,10 @@
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
"devDependencies": {
|
|
135
|
-
"@astryxdesign/charts": "
|
|
136
|
-
"@astryxdesign/core": "
|
|
137
|
-
"@astryxdesign/lab": "
|
|
138
|
-
"@astryxdesign/theme-neutral": "
|
|
135
|
+
"@astryxdesign/charts": "*",
|
|
136
|
+
"@astryxdesign/core": "*",
|
|
137
|
+
"@astryxdesign/lab": "*",
|
|
138
|
+
"@astryxdesign/theme-neutral": "*",
|
|
139
139
|
"@heroicons/react": "^2.2.0",
|
|
140
140
|
"@stylexjs/stylex": "^0.19.0",
|
|
141
141
|
"@types/babel__core": "^7.20.5",
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
-
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* The variants and default variant a command declares.
|
|
6
|
-
* @typedef {object} Looks
|
|
7
|
-
* @property {string[]} variants
|
|
8
|
-
* @property {string} default
|
|
9
|
-
* @property {boolean} [named] whether `--default-variant` named the default
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* What a set's icons draw now, read from the look words of the library
|
|
13
|
-
* exports its generated module re-exports.
|
|
14
|
-
* @typedef {object} DrawnLooks
|
|
15
|
-
* @property {string} module the library most of the set's icons come from
|
|
16
|
-
* @property {Array<Set<string>>} positions that library's look positions,
|
|
17
|
-
* the last word of a name first; empty when its names encode no looks
|
|
18
|
-
* @property {Array<string | null>} words the word most icons' exports have
|
|
19
|
-
* at each position
|
|
20
|
-
* @property {number} icons how many of the set's icons come from it
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* @typedef {import('../../foundation/discovery/icon-set-discovery.mjs').DiscoveredIconSet} LookSet
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* A library's look words in the order its names write them, one position
|
|
27
|
-
* after another: `filled or outline; 24; wght300, wght400, wght500`.
|
|
28
|
-
* @param {string[][]} positions each position's words, sorted, the last
|
|
29
|
-
* word of a name first
|
|
30
|
-
*/
|
|
31
|
-
export function describedLooks(positions: string[][]): string;
|
|
32
|
-
/**
|
|
33
|
-
* What the set's icons draw now ({@link DrawnLooks}), or null when no icon
|
|
34
|
-
* re-exports a named library export.
|
|
35
|
-
* @param {LookSet} set
|
|
36
|
-
* @param {string} packageDir
|
|
37
|
-
* @param {(module: string) => Array<Set<string>> | null} positionsOf the
|
|
38
|
-
* look positions of a library the set's generated module names
|
|
39
|
-
* @param {{module?: string}} [options] `module`: read only the icons that
|
|
40
|
-
* come from this library
|
|
41
|
-
* @returns {DrawnLooks | null}
|
|
42
|
-
*/
|
|
43
|
-
export function drawnLooks(set: LookSet, packageDir: string, positionsOf: (module: string) => Array<Set<string>> | null, options?: {
|
|
44
|
-
module?: string;
|
|
45
|
-
}): DrawnLooks | null;
|
|
46
|
-
/**
|
|
47
|
-
* The variants and default variant to write for a command that declares
|
|
48
|
-
* looks, and whether the set's icons must move to a new look. Every path
|
|
49
|
-
* that writes `default.variant` uses it:
|
|
50
|
-
*
|
|
51
|
-
* - The drawn look is read from every look word of the exports the set
|
|
52
|
-
* wraps (`drawn`), or, with no icons from the library yet, is the look
|
|
53
|
-
* the library is wrapped in by default.
|
|
54
|
-
* - A named default must be a look word the library has.
|
|
55
|
-
* - A named default other than the drawn look moves the icons only on a
|
|
56
|
-
* refresh (`library` given), where each glyph that has the look takes it;
|
|
57
|
-
* in place it is refused with the refresh command.
|
|
58
|
-
* - With none named, the default is the drawn look, which `--variants` must
|
|
59
|
-
* list.
|
|
60
|
-
*
|
|
61
|
-
* A library whose names encode no looks has no look words: there the named
|
|
62
|
-
* variant, the set's current default, or the first variant is the default.
|
|
63
|
-
* Its icons keep their exports on every path, so a set with icons keeps a
|
|
64
|
-
* declared default, `--variants` must list it, and with none declared the
|
|
65
|
-
* command names it.
|
|
66
|
-
* @param {object} args
|
|
67
|
-
* @param {string} args.name the set
|
|
68
|
-
* @param {Looks | null} args.given the variants and default the command names
|
|
69
|
-
* @param {string | undefined} args.current the set's `default.variant`
|
|
70
|
-
* @param {number} args.icons how many icons the set has
|
|
71
|
-
* @param {DrawnLooks | null} args.drawn what the set's icons draw now
|
|
72
|
-
* @param {{module: string, positions: Array<Set<string>>} | null} args.library
|
|
73
|
-
* the library `--from` wraps; null in place
|
|
74
|
-
* @returns {{looks: Looks | null, moved: boolean}}
|
|
75
|
-
*/
|
|
76
|
-
export function resolveDefaultLook({ name, given, current, icons, drawn, library, }: {
|
|
77
|
-
name: string;
|
|
78
|
-
given: Looks | null;
|
|
79
|
-
current: string | undefined;
|
|
80
|
-
icons: number;
|
|
81
|
-
drawn: DrawnLooks | null;
|
|
82
|
-
library: {
|
|
83
|
-
module: string;
|
|
84
|
-
positions: Array<Set<string>>;
|
|
85
|
-
} | null;
|
|
86
|
-
}): {
|
|
87
|
-
looks: Looks | null;
|
|
88
|
-
moved: boolean;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* The command that declares `variant` beside the set's variants. It names
|
|
92
|
-
* the default variant the set keeps, so it runs as printed.
|
|
93
|
-
* @param {LookSet} set
|
|
94
|
-
* @param {string} variant
|
|
95
|
-
* @param {DrawnLooks | null} drawn
|
|
96
|
-
* @returns {{name: string, reason: string}}
|
|
97
|
-
*/
|
|
98
|
-
export function declareVariantSuggestion(set: LookSet, variant: string, drawn: DrawnLooks | null): {
|
|
99
|
-
name: string;
|
|
100
|
-
reason: string;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Check that `add --variant` may add `variant` to the set's icons: a look
|
|
104
|
-
* word the library has, not the look each icon's own export draws (the
|
|
105
|
-
* default, declared or drawn), and declared by the set.
|
|
106
|
-
* @param {object} args
|
|
107
|
-
* @param {LookSet} args.set
|
|
108
|
-
* @param {string} args.variant
|
|
109
|
-
* @param {string} args.module the module the variant comes from
|
|
110
|
-
* @param {Array<Set<string>>} args.positions that module's look positions
|
|
111
|
-
* @param {DrawnLooks | null} args.drawn what the set's icons draw now
|
|
112
|
-
*/
|
|
113
|
-
export function checkVariantLook({ set, variant, module, positions, drawn }: {
|
|
114
|
-
set: LookSet;
|
|
115
|
-
variant: string;
|
|
116
|
-
module: string;
|
|
117
|
-
positions: Array<Set<string>>;
|
|
118
|
-
drawn: DrawnLooks | null;
|
|
119
|
-
}): void;
|
|
120
|
-
/**
|
|
121
|
-
* The variants and default variant a command declares.
|
|
122
|
-
*/
|
|
123
|
-
export type Looks = {
|
|
124
|
-
variants: string[];
|
|
125
|
-
default: string;
|
|
126
|
-
/**
|
|
127
|
-
* whether `--default-variant` named the default
|
|
128
|
-
*/
|
|
129
|
-
named?: boolean | undefined;
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* What a set's icons draw now, read from the look words of the library
|
|
133
|
-
* exports its generated module re-exports.
|
|
134
|
-
*/
|
|
135
|
-
export type DrawnLooks = {
|
|
136
|
-
/**
|
|
137
|
-
* the library most of the set's icons come from
|
|
138
|
-
*/
|
|
139
|
-
module: string;
|
|
140
|
-
/**
|
|
141
|
-
* that library's look positions,
|
|
142
|
-
* the last word of a name first; empty when its names encode no looks
|
|
143
|
-
*/
|
|
144
|
-
positions: Array<Set<string>>;
|
|
145
|
-
/**
|
|
146
|
-
* the word most icons' exports have
|
|
147
|
-
* at each position
|
|
148
|
-
*/
|
|
149
|
-
words: Array<string | null>;
|
|
150
|
-
/**
|
|
151
|
-
* how many of the set's icons come from it
|
|
152
|
-
*/
|
|
153
|
-
icons: number;
|
|
154
|
-
};
|
|
155
|
-
export type LookSet = import("../../foundation/discovery/icon-set-discovery.mjs").DiscoveredIconSet;
|