@astryxdesign/cli 0.7.11 → 0.7.12-canary.07e325e
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/api/build/kit/rank.mjs +21 -4
- package/api/build/kit/words.d.mts +1 -0
- package/api/build/kit/words.mjs +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +5 -5
- 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/icon/_adapter.d.mts +3 -2
- package/api/icon/_adapter.mjs +8 -2
- package/api/icon/_authoring.d.mts +1 -0
- package/api/icon/_authoring.mjs +586 -66
- package/api/icon/_default-look.d.mts +155 -0
- package/api/icon/_default-look.mjs +474 -0
- package/api/icon/_records.d.mts +1 -1
- package/api/icon/_records.mjs +1 -0
- package/api/icon/add/add.mjs +224 -38
- package/api/icon/icon.type.d.mts +22 -2
- package/api/icon/icon.type.mjs +6 -2
- package/api/icon/iconAdd.doc.mjs +2 -2
- package/api/icon/iconNewDefinition.doc.mjs +3 -2
- package/api/icon/iconNewSet.doc.mjs +4 -4
- package/api/icon/search/search.mjs +10 -9
- package/api/index.d.mts +1 -0
- package/api/index.mjs +1 -0
- package/api/integration/add-helpers.d.mts +11 -1
- package/api/integration/add-helpers.mjs +5 -2
- package/api/integration/authoring-checks.d.mts +0 -2
- package/api/integration/authoring-checks.mjs +1 -6
- package/api/logger.mjs +2 -1
- package/api/render/_adapter.mjs +9 -0
- package/api/render/render.doc.mjs +2 -2
- package/api/search/_adapter.d.mts +22 -1
- package/api/search/_adapter.mjs +37 -20
- 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/_adapter.d.mts +1 -0
- package/api/swizzle/_adapter.mjs +4 -1
- package/api/swizzle/_moduleGraph.d.mts +178 -0
- package/api/swizzle/_moduleGraph.mjs +903 -0
- package/api/swizzle/copy/copy.d.mts +2 -43
- package/api/swizzle/copy/copy.mjs +287 -315
- package/api/swizzle/swizzle.d.mts +0 -2
- package/api/swizzle/swizzle.doc.mjs +13 -4
- package/api/swizzle/swizzle.mjs +3 -7
- package/api/swizzle/swizzle.type.d.mts +7 -1
- package/api/swizzle/swizzle.type.mjs +4 -2
- package/api/template/template.mjs +1 -0
- package/assets/discover/official-packages.json +36 -0
- package/assets/docs/browser-support.doc.mjs +2 -2
- package/assets/docs/styling-overview.doc.mjs +6 -2
- package/assets/docs/tree/icon-sets.doc.mjs +11 -5
- package/assets/docs/tree/render-pages.doc.mjs +2 -2
- package/assets/docs/tree/tailwind.doc.mjs +41 -1
- package/assets/docs/tree/type-scale.doc.mjs +19 -2
- package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarConstraintsHookUsage.tsx +146 -0
- package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Calendar/useCalendarNavigationHookUsage.tsx +173 -0
- 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 +35 -0
- package/assets/templates/blocks/components/Table/TableRowIndexTable.doc.mjs +1 -1
- package/assets/templates/blocks/components/Table/TableRowIndexTable.tsx +2 -2
- 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/course-detail/page.tsx +699 -0
- package/assets/templates/pages/course-detail/template.doc.mjs +37 -0
- package/assets/templates/pages/file-explorer/page.tsx +103 -79
- package/assets/templates/pages/table-filter/page.tsx +15 -23
- package/assets/templates/pages/table-grouped/page.tsx +160 -232
- package/assets/templates/pages/table-grouped/template.doc.mjs +0 -2
- package/assets/templates/pages/table-inbox/page.tsx +3 -6
- package/assets/templates/pages/theme-showcase/page.tsx +724 -792
- package/assets/templates/pages/theme-showcase/template.doc.mjs +4 -5
- package/assets/templates/themes/butter/butterTheme.ts +2 -2
- package/assets/templates/themes/stone/stoneTheme.ts +1 -1
- package/assets/templates/themes/y2k/y2kTheme.ts +1 -1
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/docs.doc.mjs +5 -1
- package/clients/cli/commands/docs.mjs +30 -2
- package/clients/cli/commands/experimental/icon.mjs +31 -10
- package/clients/cli/commands/experimental-icon-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-icon-new-definition.doc.mjs +2 -1
- package/clients/cli/commands/experimental-icon-new-set.doc.mjs +2 -2
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +33 -9
- package/clients/cli/lib/resolve-theme.mjs +16 -7
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/doc-types.mjs +9 -2
- package/foundation/discovery/hook-discovery.mjs +31 -8
- package/foundation/discovery/icon-ranking.d.mts +27 -3
- package/foundation/discovery/icon-ranking.mjs +125 -8
- package/foundation/discovery/icon-set-checks.mjs +44 -35
- package/foundation/discovery/icon-set-discovery.d.mts +13 -0
- package/foundation/discovery/icon-set-discovery.mjs +25 -0
- package/foundation/discovery/icon-set-writer.d.mts +238 -16
- package/foundation/discovery/icon-set-writer.mjs +676 -79
- package/foundation/discovery/module-exports.d.mts +3 -2
- package/foundation/discovery/module-exports.mjs +167 -37
- 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/fs/paths.d.mts +2 -1
- package/foundation/fs/paths.mjs +3 -4
- 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-worker.mjs +339 -52
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.d.mts +63 -0
- package/foundation/render/ts-paths.mjs +138 -0
- package/foundation/response/error-codes.doc.mjs +2 -2
- 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/shell-arg.d.mts +14 -0
- package/foundation/text/shell-arg.mjs +17 -0
- package/foundation/text/suggest-order.d.mts +8 -1
- package/foundation/text/suggest-order.mjs +72 -6
- package/package.json +7 -6
|
@@ -6,7 +6,8 @@ export const doc = {
|
|
|
6
6
|
name: 'Theme Showcase',
|
|
7
7
|
displayName: 'Theme Showcase',
|
|
8
8
|
description:
|
|
9
|
-
'
|
|
9
|
+
'Multi-surface comparison shell: preview palettes, typography, icons and control states across a storefront, checkout, chat and inventory on one responsive canvas. A theme preview and design-system showcase, with an embeddable content view for an existing app shell.',
|
|
10
|
+
category: 'Shell - Top Nav',
|
|
10
11
|
keywords: [
|
|
11
12
|
'theme',
|
|
12
13
|
'tokens',
|
|
@@ -16,10 +17,8 @@ export const doc = {
|
|
|
16
17
|
'design system preview',
|
|
17
18
|
],
|
|
18
19
|
isReady: true,
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// No `category` — it's hidden from the overview gallery (the only consumer
|
|
22
|
-
// of `category`), and 'Showcase' isn't part of the TemplateCategory taxonomy.
|
|
20
|
+
// The standalone entry demonstrates an application shell; the named preview
|
|
21
|
+
// composes into its host without nesting AppShell. Keep it out of the gallery.
|
|
23
22
|
isHiddenFromOverview: true,
|
|
24
23
|
icons: {
|
|
25
24
|
Banknote: 'money',
|
|
@@ -260,7 +260,7 @@ export const butterTheme = defineTheme({
|
|
|
260
260
|
'--color-tint-hover': [neutral.light[0], neutral.dark[100]],
|
|
261
261
|
|
|
262
262
|
// Typography override
|
|
263
|
-
'--text-supporting-size': '
|
|
263
|
+
'--text-supporting-size': '0.75rem', // 12px at the default root size
|
|
264
264
|
|
|
265
265
|
// Element sizes — slightly taller defaults so the new input padding
|
|
266
266
|
// (--spacing-2 block) has room to breathe.
|
|
@@ -394,8 +394,8 @@ export const butterTheme = defineTheme({
|
|
|
394
394
|
// Radius intentionally not pinned, so buttons keep core's
|
|
395
395
|
// `var(--_button-radius, --radius-element)`: standalone buttons stay 8px,
|
|
396
396
|
// while the chat composer (which sets --_button-radius) rounds them fully.
|
|
397
|
+
// Inline padding only. Button sets its own block padding and height.
|
|
397
398
|
base: {
|
|
398
|
-
paddingBlock: 'var(--spacing-3)',
|
|
399
399
|
paddingInline: 'var(--spacing-4)',
|
|
400
400
|
},
|
|
401
401
|
'variant:secondary': SECONDARY_BUTTON,
|
|
@@ -240,7 +240,7 @@ export const stoneTheme = defineTheme({
|
|
|
240
240
|
'--color-tint-hover': [neutral.light[0], neutral.dark[100]],
|
|
241
241
|
|
|
242
242
|
// Typography override
|
|
243
|
-
'--text-supporting-size': '
|
|
243
|
+
'--text-supporting-size': '0.75rem', // 12px at the default root size
|
|
244
244
|
|
|
245
245
|
// Categorical
|
|
246
246
|
// Light mode pairs pastel stop 90 surfaces with stop 30 foregrounds.
|
|
@@ -236,7 +236,7 @@ export const y2kTheme = defineTheme({
|
|
|
236
236
|
'--color-tint-hover': [neutral.light[15], neutral.dark[95]],
|
|
237
237
|
|
|
238
238
|
// Typography override
|
|
239
|
-
'--text-supporting-size': '
|
|
239
|
+
'--text-supporting-size': '0.75rem', // 12px at the default root size
|
|
240
240
|
|
|
241
241
|
// Categorical colors
|
|
242
242
|
'--color-background-green': [green.light[80], green.dark[80]],
|
|
@@ -186,6 +186,7 @@ export type TemplateCategory =
|
|
|
186
186
|
| 'Content - Order Detail'
|
|
187
187
|
| 'Content - Product Detail'
|
|
188
188
|
| 'Content - Work Item Detail'
|
|
189
|
+
| 'Content - Course Detail'
|
|
189
190
|
| 'Content - Product List'
|
|
190
191
|
| 'Content - Documentation Catalog'
|
|
191
192
|
| 'Content - Documentation Design'
|
|
@@ -46,7 +46,7 @@ export const doc = {
|
|
|
46
46
|
flag: '--depth <levels>',
|
|
47
47
|
param: 'options.depth',
|
|
48
48
|
description:
|
|
49
|
-
'How many levels of the docs tree to read below a namespace: 0 for the namespace alone, 1 for its children (what a read without --depth shows), all for everything below it. With it, --detail sets how much of each doc below shows: brief (one line each, the default), compact (with its sections), or full',
|
|
49
|
+
'How many levels of the docs tree to read below a namespace: 0 for the namespace alone, 1 for its children (what a read without --depth shows), all for everything below it. On the topic list, where a namespace otherwise lists alone, it names the docs below each one by the route that opens them, one line each. With it on a namespace read, --detail sets how much of each doc below shows: brief (one line each, the default), compact (with its sections), or full; the topic list is one line per doc whatever the detail',
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
examples: [
|
|
@@ -56,6 +56,10 @@ export const doc = {
|
|
|
56
56
|
{label: 'One section', cli: 'astryx docs theme quick-start'},
|
|
57
57
|
{label: 'The CLI docs tree', cli: 'astryx docs cli'},
|
|
58
58
|
{label: 'Every CLI doc, one line each', cli: 'astryx docs cli --depth all'},
|
|
59
|
+
{
|
|
60
|
+
label: 'Every route in the docs tree, one line each',
|
|
61
|
+
cli: 'astryx docs --depth all',
|
|
62
|
+
},
|
|
59
63
|
{
|
|
60
64
|
label: 'The integration guides as one read',
|
|
61
65
|
cli: 'astryx docs authoring --depth all --detail full',
|
|
@@ -615,6 +615,32 @@ function summarize(result) {
|
|
|
615
615
|
|
|
616
616
|
// ─── Command ─────────────────────────────────────────────────────────────────
|
|
617
617
|
|
|
618
|
+
/**
|
|
619
|
+
* Every namespace of the list and, where a `--depth` read carried them, the
|
|
620
|
+
* docs below it, in reading order and in one flat list: each row's `topic` is
|
|
621
|
+
* the route that opens it, so the depth of a row never changes how a reader
|
|
622
|
+
* uses it, and each names the package that owns it.
|
|
623
|
+
* @param {Array<import('../../../api/docs/docs.type.mjs').DocsListNamespace | import('../../../api/docs/docs.type.mjs').DocsListChild>} rows
|
|
624
|
+
* @returns {Array<{topic: string, description: string, package: string}>}
|
|
625
|
+
*/
|
|
626
|
+
function flattenNamespaces(rows) {
|
|
627
|
+
return rows.flatMap(row => [
|
|
628
|
+
{
|
|
629
|
+
topic: row.topic,
|
|
630
|
+
// An experimental doc is marked here as it is wherever else it is
|
|
631
|
+
// listed, so a reader cannot take a row of this list for a stable doc.
|
|
632
|
+
description:
|
|
633
|
+
'stability' in row &&
|
|
634
|
+
row.stability === 'experimental' &&
|
|
635
|
+
!/^experimental\b/iu.test(row.description)
|
|
636
|
+
? `[experimental] ${row.description}`
|
|
637
|
+
: row.description,
|
|
638
|
+
package: row.package,
|
|
639
|
+
},
|
|
640
|
+
...flattenNamespaces(row.children ?? []),
|
|
641
|
+
]);
|
|
642
|
+
}
|
|
643
|
+
|
|
618
644
|
/**
|
|
619
645
|
* @param {import('commander').Command} program
|
|
620
646
|
*/
|
|
@@ -703,8 +729,10 @@ export function registerDocs(program) {
|
|
|
703
729
|
// The text view mirrors the JSON list, with the docs tree's
|
|
704
730
|
// namespaces (`meta.namespaces`) first under their own heading: that
|
|
705
731
|
// is where the CLI's own docs start, and a namespace reads
|
|
706
|
-
// differently from a topic.
|
|
707
|
-
|
|
732
|
+
// differently from a topic. With --depth each branch is flattened
|
|
733
|
+
// into the same list, so every line is a route a reader can pass
|
|
734
|
+
// straight back to `docs`.
|
|
735
|
+
const namespaces = flattenNamespaces(result.meta?.namespaces ?? []);
|
|
708
736
|
const topics = result.data;
|
|
709
737
|
emit(
|
|
710
738
|
...(namespaces.length > 0
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
getCliInvocation,
|
|
21
21
|
} from '../../../../foundation/env/package-manager.mjs';
|
|
22
22
|
import {jsonOut} from '../../../../foundation/response/json.mjs';
|
|
23
|
+
import {logger} from '../../../../api/logger.mjs';
|
|
23
24
|
import {resultSet} from '../../../../foundation/debug/index.mjs';
|
|
24
25
|
import {
|
|
25
26
|
emit,
|
|
@@ -140,7 +141,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
140
141
|
),
|
|
141
142
|
),
|
|
142
143
|
text(
|
|
143
|
-
`Built-in definitions are the ones every set maps. Map one: ${run} experimental icon map <definition> <icon id>`,
|
|
144
|
+
`Built-in definitions are the ones every set maps. Map one: ${run} experimental icon map <definition> <icon id> --set <set>`,
|
|
144
145
|
),
|
|
145
146
|
);
|
|
146
147
|
return answered;
|
|
@@ -157,7 +158,9 @@ export function registerExperimentalIcon(group, program) {
|
|
|
157
158
|
`${each.id}: ${each.words.join(', ')}${each.definitions.length > 0 ? ` = ${each.definitions.join(', ')}` : ''}`,
|
|
158
159
|
),
|
|
159
160
|
),
|
|
160
|
-
text(
|
|
161
|
+
text(
|
|
162
|
+
`Map one: ${run} experimental icon map <definition> <id> --set ${set}`,
|
|
163
|
+
),
|
|
161
164
|
);
|
|
162
165
|
return answered;
|
|
163
166
|
}
|
|
@@ -308,6 +311,9 @@ export function registerExperimentalIcon(group, program) {
|
|
|
308
311
|
* @param {(result: any) => void} print
|
|
309
312
|
*/
|
|
310
313
|
const run = async (call, print) => {
|
|
314
|
+
// Reading a large library reports its progress through the shared
|
|
315
|
+
// logger: on stderr in text mode, never under --json.
|
|
316
|
+
logger.setSilent(Boolean(program.opts().json));
|
|
311
317
|
let result;
|
|
312
318
|
try {
|
|
313
319
|
result = await call();
|
|
@@ -436,7 +442,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
436
442
|
return;
|
|
437
443
|
}
|
|
438
444
|
if (result.type === 'icon.definitionMatches') {
|
|
439
|
-
const {matches, newDefinition} = result.data;
|
|
445
|
+
const {matches, newDefinition, variant} = result.data;
|
|
440
446
|
emit(
|
|
441
447
|
section(
|
|
442
448
|
`Icon definitions for ${result.data.export} (${matches.length})`,
|
|
@@ -466,6 +472,13 @@ export function registerExperimentalIcon(group, program) {
|
|
|
466
472
|
),
|
|
467
473
|
]
|
|
468
474
|
: []),
|
|
475
|
+
...(variant
|
|
476
|
+
? [
|
|
477
|
+
text(
|
|
478
|
+
`The set already has this glyph in another look. Add this one as its variant: ${formatCliCommand(variant)}`,
|
|
479
|
+
),
|
|
480
|
+
]
|
|
481
|
+
: []),
|
|
469
482
|
text(
|
|
470
483
|
`All icon definitions: ${cli} docs cli/experimental/icon-definitions`,
|
|
471
484
|
),
|
|
@@ -500,17 +513,25 @@ export function registerExperimentalIcon(group, program) {
|
|
|
500
513
|
const {root, manifest, files, written, dryRun} = data;
|
|
501
514
|
const state = dryRun ? 'plan' : written ? 'ok' : 'unchanged';
|
|
502
515
|
const refreshed = data.refreshed === true;
|
|
516
|
+
const updated = data.updated === true;
|
|
517
|
+
const What = `${what[0].toUpperCase()}${what.slice(1)}`;
|
|
503
518
|
emit(
|
|
504
519
|
section(
|
|
505
520
|
refreshed
|
|
506
521
|
? dryRun
|
|
507
522
|
? `Refresh ${what} plan`
|
|
508
|
-
: `${
|
|
509
|
-
:
|
|
510
|
-
?
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
523
|
+
: `${What} refreshed`
|
|
524
|
+
: updated
|
|
525
|
+
? dryRun
|
|
526
|
+
? `${What} update plan`
|
|
527
|
+
: written && files.length > 0
|
|
528
|
+
? `${What} updated`
|
|
529
|
+
: `${What} unchanged`
|
|
530
|
+
: dryRun
|
|
531
|
+
? `New ${what} plan`
|
|
532
|
+
: written
|
|
533
|
+
? `New ${what} added`
|
|
534
|
+
: `New ${what} unchanged`,
|
|
514
535
|
),
|
|
515
536
|
text(`[${state}] ${data.name}`),
|
|
516
537
|
// What the command did (or, in a dry run, would do): never a step
|
|
@@ -542,7 +563,7 @@ export function registerExperimentalIcon(group, program) {
|
|
|
542
563
|
list(
|
|
543
564
|
data.suggestions.map(
|
|
544
565
|
each =>
|
|
545
|
-
`${each.definition} -> ${each.icon} (${each.word}): ${formatCliCommand(`astryx experimental icon map ${each.definition} ${each.icon}`)}`,
|
|
566
|
+
`${each.definition} -> ${each.icon} (${each.word}): ${formatCliCommand(`astryx experimental icon map ${each.definition} ${each.icon} --set ${data.name}`)}`,
|
|
546
567
|
),
|
|
547
568
|
),
|
|
548
569
|
]
|
|
@@ -30,7 +30,7 @@ export const doc = {
|
|
|
30
30
|
flag: '--new-definition <name>',
|
|
31
31
|
param: 'options.newDefinition',
|
|
32
32
|
description:
|
|
33
|
-
"Add your set's own definition, then map the icon to it; needs --description and --words",
|
|
33
|
+
"Add your set's own definition, named in camelCase (aiHelper) or kebab-case (ai-helper), then map the icon to it; needs --description and --words",
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
flag: '--description <text>',
|
|
@@ -18,7 +18,8 @@ export const doc = {
|
|
|
18
18
|
name: 'name',
|
|
19
19
|
param: 'name',
|
|
20
20
|
required: true,
|
|
21
|
-
description:
|
|
21
|
+
description:
|
|
22
|
+
'The definition name, in camelCase (rocketLaunch) or kebab-case (rocket-launch)',
|
|
22
23
|
},
|
|
23
24
|
],
|
|
24
25
|
options: [
|
|
@@ -11,7 +11,7 @@ export const doc = {
|
|
|
11
11
|
stability: 'experimental',
|
|
12
12
|
summary: 'Start an icon set in your integration package',
|
|
13
13
|
description:
|
|
14
|
-
"Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library, records the library and its version as the set's source, copies its license notice, and maps each Astryx icon definition whose name is an icon's id; definitions an icon only shares a word with are listed as suggestions, never written. Run it again to refresh. --variants and --default-variant declare the set's variants. Experimental: it may change or be removed in a patch release.",
|
|
14
|
+
"Run inside an integration package. Writes the set's folder with its descriptor, its data file, and its generated module, and declares the manifest's `experimental.iconSets` root on first use. With --from it wraps every icon component of a library, records the library and its version as the set's source, copies its license notice, and maps each Astryx icon definition whose name is an icon's id; definitions an icon only shares a word with are listed as suggestions, never written. A library whose export names end in looks (XOutline24WGHT500Icon) gives one icon per glyph, by its glyph id (x), in the look the default variant names, else the library's usual default. Run it again with --from to refresh. --variants and --default-variant declare the set's variants; over an existing set without --from, they, --display-name and --description update the set in place and leave its icons as they are; a set with icons changes its default variant only with --from, and only in a library whose export names encode looks. Experimental: it may change or be removed in a patch release.",
|
|
15
15
|
fn: 'iconNewSet',
|
|
16
16
|
args: [
|
|
17
17
|
{
|
|
@@ -49,7 +49,7 @@ export const doc = {
|
|
|
49
49
|
flag: '--default-variant <variant>',
|
|
50
50
|
param: 'options.defaultVariant',
|
|
51
51
|
description:
|
|
52
|
-
"With --variants: the variant each icon's own export draws (the first variant
|
|
52
|
+
"With --variants: the variant each icon's own export draws. When omitted: in a library whose export names encode looks, the look the icons draw (the library's usual default for a new set), which --variants must list; otherwise the set's current default, which --variants must list when the set has icons, else, on a set without icons, the first variant. A set with icons changes it only with --from, and only in a library whose export names encode looks",
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
flag: '--display-name <text>',
|
|
@@ -16,8 +16,17 @@ export const doc = {
|
|
|
16
16
|
summary: 'Copy component source for customization',
|
|
17
17
|
description:
|
|
18
18
|
"Ejects a component's source from the resolved @astryxdesign/core (or its owning " +
|
|
19
|
-
'integration) into your project for deep customization
|
|
20
|
-
'
|
|
19
|
+
'integration) into your project for deep customization. Every import in the copy ' +
|
|
20
|
+
'names a file the copy holds or a path the package exports: names the package ' +
|
|
21
|
+
'exports come from the package, and every internal module the component needs ' +
|
|
22
|
+
"is copied beside it in the package's folder layout. " +
|
|
23
|
+
'Tests, stories and docs are not copied. It lists the npm packages the copy imports, ' +
|
|
24
|
+
'with the ranges the owner package declares, to install if your project lacks them. ' +
|
|
25
|
+
'An output folder swizzle owns (one the copy ' +
|
|
26
|
+
'creates, an empty one, or one it marked before) gets an astryx-swizzle.json marker naming ' +
|
|
27
|
+
"each package its copies came from, so @astryxdesign/build's Babel, PostCSS and Vite " +
|
|
28
|
+
'integrations, and withAstryx() under webpack, compile the copy below your theme. ' +
|
|
29
|
+
'With no name it lists the swizzlable components. ' +
|
|
21
30
|
'An integration component that replaces a Core component is what that Core name ' +
|
|
22
31
|
'copies; --package @astryxdesign/core copies the original. --list lists Core ' +
|
|
23
32
|
'components, including one an integration replaces.',
|
|
@@ -46,7 +55,7 @@ export const doc = {
|
|
|
46
55
|
flag: '-f, --overwrite',
|
|
47
56
|
param: 'options.overwrite',
|
|
48
57
|
description:
|
|
49
|
-
|
|
58
|
+
"Replace the component's existing files. Without it, existing files fail the command with ERR_FILE_EXISTS and nothing is written. A helper an earlier swizzle wrote is reused when it is the same and is never replaced by a copy that carries it: a different one stays, and this copy writes its own under a version-suffixed name. Swizzling the component whose folder holds that helper counts it as one of that component's own files. A changed private attribute owner module, or a style module it imports, fails the command without --overwrite and is replaced with it",
|
|
50
59
|
},
|
|
51
60
|
],
|
|
52
61
|
examples: [
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file swizzle command — thin wrapper around api/swizzle.
|
|
5
5
|
*
|
|
6
|
-
* Copies a component's source into the consumer project for customization
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* commands for the caller's package manager.
|
|
6
|
+
* Copies a component's source into the consumer project for customization,
|
|
7
|
+
* with the internal modules it needs. All logic — owner resolution, the copy,
|
|
8
|
+
* StyleX detection, maintainer feedback — lives in api/swizzle; this file only
|
|
9
|
+
* parses flags, prints, and prefixes commands for the caller's package manager.
|
|
11
10
|
*/
|
|
12
11
|
|
|
13
12
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
@@ -85,18 +84,43 @@ export function registerSwizzle(program) {
|
|
|
85
84
|
text(`[ok] Copied ${filesCopied} files to ${outputDir}/`),
|
|
86
85
|
text(
|
|
87
86
|
[
|
|
88
|
-
`
|
|
87
|
+
`What ${ownerPackage} exports is imported from ${ownerPackage}; the internal modules the component needs are copied beside it.`,
|
|
89
88
|
'You can now customize the component source freely.',
|
|
90
89
|
].join('\n'),
|
|
91
90
|
),
|
|
92
91
|
];
|
|
93
|
-
// Files the copy wrote outside the component folder: the
|
|
94
|
-
//
|
|
92
|
+
// Files the copy wrote outside the component folder: the internal
|
|
93
|
+
// modules it needs, in the package's folder layout.
|
|
95
94
|
const shared = (result.data.files ?? []).filter(f => f.startsWith('../'));
|
|
96
95
|
if (shared.length > 0) {
|
|
97
96
|
out.push(
|
|
98
97
|
text(
|
|
99
|
-
`
|
|
98
|
+
`Copied beside it: ${shared.join(', ')} (in the package's folder layout; imported by relative path)`,
|
|
99
|
+
),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// npm packages the copy imports, each range quoted so the list pastes
|
|
104
|
+
// safely after an install command.
|
|
105
|
+
const dependencies = Object.entries(result.data.dependencies ?? {});
|
|
106
|
+
if (dependencies.length > 0) {
|
|
107
|
+
out.push(
|
|
108
|
+
text(
|
|
109
|
+
`It imports these npm packages; install any your project lacks: ${dependencies
|
|
110
|
+
.map(([name, range]) => (range === '*' ? name : `${name}@"${range}"`))
|
|
111
|
+
.join(' ')}`,
|
|
112
|
+
),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const {marker} = result.data;
|
|
117
|
+
if (marker) {
|
|
118
|
+
const folder = marker.path.replace(/\/?astryx-swizzle\.json$/, '') || '.';
|
|
119
|
+
out.push(
|
|
120
|
+
text(
|
|
121
|
+
marker.written
|
|
122
|
+
? `Marked ${folder}/ with astryx-swizzle.json: with @astryxdesign/build's Babel, PostCSS and Vite integrations, or withAstryx() under webpack, every module under it compiles below your theme, so theme overrides reach the copy. Keep only swizzled copies there. Turbopack does not read the marker yet.`
|
|
123
|
+
: `Did not mark ${folder}/ with astryx-swizzle.json: it already holds ${(marker.found ?? []).join(', ')} and no astryx-swizzle.json. If it holds only swizzled copies, add ${marker.path} to mark it, so theme overrides reach them; keep the product's own components out of a marked folder.`,
|
|
100
124
|
),
|
|
101
125
|
);
|
|
102
126
|
}
|
|
@@ -73,11 +73,22 @@ function extractTheme(mod) {
|
|
|
73
73
|
return null;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Print a theme warning as one inert line. The configured theme value and the
|
|
78
|
+
* generated record come from the checkout, so a newline, an escape sequence or
|
|
79
|
+
* a bidi override in them must not rewrite the terminal. Control and format
|
|
80
|
+
* characters print as U+FFFD.
|
|
81
|
+
* @param {string} message
|
|
82
|
+
*/
|
|
83
|
+
function warnTheme(message) {
|
|
84
|
+
console.warn(message.replace(/[\p{Cc}\p{Cf}]/gu, '\uFFFD'));
|
|
85
|
+
}
|
|
86
|
+
|
|
76
87
|
/** @param {unknown} mod @param {string} specifier */
|
|
77
88
|
function resolvedThemeData(mod, specifier) {
|
|
78
89
|
const theme = extractTheme(mod);
|
|
79
90
|
if (!theme) {
|
|
80
|
-
|
|
91
|
+
warnTheme(
|
|
81
92
|
`⚠ theme: loaded "${specifier}" but could not find a theme object`,
|
|
82
93
|
);
|
|
83
94
|
return null;
|
|
@@ -100,7 +111,7 @@ export async function resolveTheme(cwd = process.cwd()) {
|
|
|
100
111
|
const loaded = await resolveRecordedTheme(cwd);
|
|
101
112
|
if (loaded.configured) {
|
|
102
113
|
if (!loaded.module) {
|
|
103
|
-
|
|
114
|
+
warnTheme(
|
|
104
115
|
`⚠ theme: ${loaded.problem ?? `could not resolve the generated default theme (${loaded.specifier})`}`,
|
|
105
116
|
);
|
|
106
117
|
return null;
|
|
@@ -130,15 +141,13 @@ export async function resolveTheme(cwd = process.cwd()) {
|
|
|
130
141
|
if (specifier.startsWith('.') || specifier.startsWith('/')) {
|
|
131
142
|
mod = tryLoadLegacyModule(specifier, cwd);
|
|
132
143
|
if (!mod) {
|
|
133
|
-
|
|
134
|
-
`⚠ theme: could not resolve file "${specifier}" from ${cwd}`,
|
|
135
|
-
);
|
|
144
|
+
warnTheme(`⚠ theme: could not resolve file "${specifier}" from ${cwd}`);
|
|
136
145
|
return null;
|
|
137
146
|
}
|
|
138
147
|
} else if (specifier.startsWith('@')) {
|
|
139
148
|
mod = tryLoadLegacyModule(specifier, cwd);
|
|
140
149
|
if (!mod) {
|
|
141
|
-
|
|
150
|
+
warnTheme(`⚠ theme: could not resolve package "${specifier}"`);
|
|
142
151
|
return null;
|
|
143
152
|
}
|
|
144
153
|
} else {
|
|
@@ -147,7 +156,7 @@ export async function resolveTheme(cwd = process.cwd()) {
|
|
|
147
156
|
tryLoadLegacyModule(conventional, cwd) ??
|
|
148
157
|
tryLoadLegacyModule(specifier, cwd);
|
|
149
158
|
if (!mod) {
|
|
150
|
-
|
|
159
|
+
warnTheme(
|
|
151
160
|
`⚠ theme: could not resolve "${specifier}" (tried ${conventional} and ${specifier})`,
|
|
152
161
|
);
|
|
153
162
|
return null;
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* none), and a `<topic>.doc.<lang>.mjs` overlay against
|
|
28
28
|
* `ReferenceTranslationDoc`;
|
|
29
29
|
* - themes root: `ThemeDoc`;
|
|
30
|
-
* - iconSets root: `IconSetDoc
|
|
30
|
+
* - iconSets root: `IconSetDoc`, and a set's own definition (stamped
|
|
31
|
+
* `type: 'icon-definition'`) `IconDefinitionDoc`.
|
|
31
32
|
* Every finding is a warning, names the field, and says how to fix it.
|
|
32
33
|
*
|
|
33
34
|
* @input Doc files with the root each was found in, the package root, and the
|
|
@@ -312,7 +313,13 @@ function expectedType(ts, root, exportName, node, core = false) {
|
|
|
312
313
|
return {typeExpr: authoring('ThemeDoc'), typeName: 'ThemeDoc'};
|
|
313
314
|
}
|
|
314
315
|
if (root === 'icon-sets') {
|
|
315
|
-
|
|
316
|
+
// A set's own definitions live in its folder too.
|
|
317
|
+
return shape?.stamp === 'icon-definition'
|
|
318
|
+
? {
|
|
319
|
+
typeExpr: authoring('IconDefinitionDoc'),
|
|
320
|
+
typeName: 'IconDefinitionDoc',
|
|
321
|
+
}
|
|
322
|
+
: {typeExpr: authoring('IconSetDoc'), typeName: 'IconSetDoc'};
|
|
316
323
|
}
|
|
317
324
|
if (translation) {
|
|
318
325
|
return {
|
|
@@ -12,6 +12,13 @@ import {levenshteinDistance} from '../text/string-utils.mjs';
|
|
|
12
12
|
|
|
13
13
|
const SKIP_DIRS = new Set(['utils', '__tests__', 'node_modules']);
|
|
14
14
|
|
|
15
|
+
// A hook's doc outside src/hooks/: a `use…` hook, or a `create…` factory
|
|
16
|
+
// documented as one (its doc typed `HookDoc`, such as createReorderable).
|
|
17
|
+
const HOOK_DOC_FILE_RE = /^(?:use|create)[A-Z]\w*\.doc\.mjs$/;
|
|
18
|
+
|
|
19
|
+
// Matches the top-level `relatedHooks: [...]` field in a hook .doc.mjs file.
|
|
20
|
+
const RELATED_HOOKS_RE = /(?:^|\n) {0,4}relatedHooks:\s*\[([^\]]*)\]/;
|
|
21
|
+
|
|
15
22
|
// Matches the top-level `category: 'categoryName'` field in a hook .doc.mjs file.
|
|
16
23
|
const CATEGORY_RE = /(?:^|\n) {0,4}category:\s*['"]([^'"]+)['"]/;
|
|
17
24
|
|
|
@@ -32,6 +39,25 @@ function readHookMeta(docPath) {
|
|
|
32
39
|
}
|
|
33
40
|
}
|
|
34
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Whether a `create…` factory's doc names its own `use…` hook in
|
|
44
|
+
* `relatedHooks`, as createAnimator's names useAnimator. Such a factory is
|
|
45
|
+
* listed beside that hook, not on its own.
|
|
46
|
+
* @param {string} docPath
|
|
47
|
+
* @param {string} hookName
|
|
48
|
+
* @returns {boolean}
|
|
49
|
+
*/
|
|
50
|
+
function isBesideOwnHook(docPath, hookName) {
|
|
51
|
+
if (!hookName.startsWith('create')) return false;
|
|
52
|
+
const ownHook = `use${hookName.slice('create'.length)}`;
|
|
53
|
+
try {
|
|
54
|
+
const related = RELATED_HOOKS_RE.exec(fs.readFileSync(docPath, 'utf-8'));
|
|
55
|
+
return related != null && related[1].includes(`'${ownHook}'`);
|
|
56
|
+
} catch {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
35
61
|
/**
|
|
36
62
|
* Extract the hook name from a doc filename.
|
|
37
63
|
* e.g. 'useFocusTrap.doc.mjs' → 'useFocusTrap'
|
|
@@ -70,7 +96,8 @@ export function discoverHooks(coreDir) {
|
|
|
70
96
|
}
|
|
71
97
|
}
|
|
72
98
|
|
|
73
|
-
// 2. Scan ALL component directories for
|
|
99
|
+
// 2. Scan ALL component directories for hook docs: use*.doc.mjs, and
|
|
100
|
+
// create*.doc.mjs for a factory documented as a hook (createReorderable)
|
|
74
101
|
if (pathExists(srcDir)) {
|
|
75
102
|
const topEntries = listDirEntries(srcDir);
|
|
76
103
|
for (const entry of topEntries) {
|
|
@@ -120,14 +147,10 @@ function scanDirForHookDocs(dirPath, hookCategories) {
|
|
|
120
147
|
for (const entry of entries) {
|
|
121
148
|
if (entry.isDirectory() && !SKIP_DIRS.has(entry.name)) {
|
|
122
149
|
scanDirForHookDocs(path.join(dirPath, entry.name), hookCategories);
|
|
123
|
-
} else if (
|
|
124
|
-
entry.isFile() &&
|
|
125
|
-
entry.name.startsWith('use') &&
|
|
126
|
-
entry.name.endsWith('.doc.mjs')
|
|
127
|
-
) {
|
|
150
|
+
} else if (entry.isFile() && HOOK_DOC_FILE_RE.test(entry.name)) {
|
|
128
151
|
const hookName = hookNameFromFile(entry.name);
|
|
129
|
-
|
|
130
|
-
|
|
152
|
+
const docPath = path.join(dirPath, entry.name);
|
|
153
|
+
if (!hookCategories.has(hookName) && !isBesideOwnHook(docPath, hookName)) {
|
|
131
154
|
const {category} = readHookMeta(docPath);
|
|
132
155
|
hookCategories.set(hookName, category || 'Other');
|
|
133
156
|
}
|
|
@@ -30,7 +30,9 @@ export function iconRecord(set: DiscoveredIconSet, icon: IconSetIcon, definition
|
|
|
30
30
|
* @property {boolean} meaning the query is one of the icon's tags (never
|
|
31
31
|
* both: a tag is a word that is not the id or one of its parts)
|
|
32
32
|
* @property {number} rank within-tier key, lower first: for a name match 0
|
|
33
|
-
* (whole id)
|
|
33
|
+
* (whole id), 1 (the whole id's plural or singular), 2 (an id part), or 3
|
|
34
|
+
* (an id part's plural or singular); for a meaning match the tag's
|
|
35
|
+
* position
|
|
34
36
|
* @property {string} reason
|
|
35
37
|
*/
|
|
36
38
|
/**
|
|
@@ -41,6 +43,24 @@ export function iconRecord(set: DiscoveredIconSet, icon: IconSetIcon, definition
|
|
|
41
43
|
* @returns {IconMatch | null}
|
|
42
44
|
*/
|
|
43
45
|
export function matchIcon(query: string, icon: IconSetIcon, definitions?: string[]): IconMatch | null;
|
|
46
|
+
/**
|
|
47
|
+
* The query without the words that only phrase it, when it has several
|
|
48
|
+
* words and some word names something; else the query as typed.
|
|
49
|
+
* @param {string} query
|
|
50
|
+
*/
|
|
51
|
+
export function iconQuery(query: string): string;
|
|
52
|
+
/**
|
|
53
|
+
* The matches that answer a query: the whole-word ones (a definition or an
|
|
54
|
+
* exact match, 80 and up) when there are any, else word starts (60) when
|
|
55
|
+
* there are any, else partial matches. A longer word that only starts with
|
|
56
|
+
* the query (`start` for `star`) never stands beside a whole-word answer.
|
|
57
|
+
* @template {{score: number}} T
|
|
58
|
+
* @param {T[]} ranked best first
|
|
59
|
+
* @returns {T[]}
|
|
60
|
+
*/
|
|
61
|
+
export function answeringMatches<T extends {
|
|
62
|
+
score: number;
|
|
63
|
+
}>(ranked: T[]): T[];
|
|
44
64
|
/**
|
|
45
65
|
* Which exact reading leads for a set of matches: meaning, unless more icons
|
|
46
66
|
* carry the query as a name than as a tag.
|
|
@@ -78,7 +98,9 @@ export function withDefinitionWords(icon: IconSetIcon, definitions: string[], lo
|
|
|
78
98
|
words: string[];
|
|
79
99
|
} | undefined): IconSetIcon;
|
|
80
100
|
/**
|
|
81
|
-
* Every icon in `sets` that answers the query, ranked
|
|
101
|
+
* Every icon in `sets` that answers the query, ranked. The query is
|
|
102
|
+
* scored as typed; when nothing answers it with a whole word (80 and up),
|
|
103
|
+
* it is scored again without its filler words ({@link iconQuery}).
|
|
82
104
|
* @param {DiscoveredIconSet[]} sets in tie order
|
|
83
105
|
* @param {string} query
|
|
84
106
|
* @returns {IconMatchEntry[]}
|
|
@@ -106,7 +128,9 @@ export type IconMatch = {
|
|
|
106
128
|
meaning: boolean;
|
|
107
129
|
/**
|
|
108
130
|
* within-tier key, lower first: for a name match 0
|
|
109
|
-
* (whole id)
|
|
131
|
+
* (whole id), 1 (the whole id's plural or singular), 2 (an id part), or 3
|
|
132
|
+
* (an id part's plural or singular); for a meaning match the tag's
|
|
133
|
+
* position
|
|
110
134
|
*/
|
|
111
135
|
rank: number;
|
|
112
136
|
reason: string;
|