@astryxdesign/cli 0.7.17 → 0.7.18-canary.g32556bb
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/README.md +1 -1
- package/api/discover/_adapter.d.mts +7 -5
- package/api/discover/_adapter.mjs +12 -11
- package/api/docs/_adapter.d.mts +19 -2
- package/api/docs/_adapter.mjs +66 -5
- package/api/doctor/_adapter.d.mts +11 -62
- package/api/doctor/_adapter.mjs +242 -472
- package/api/doctor/doctor.d.mts +1 -1
- package/api/doctor/doctor.mjs +3 -3
- package/api/doctor/theme-checks.mjs +37 -45
- package/api/error.d.mts +21 -0
- package/api/error.mjs +89 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/icon/_adapter.d.mts +8 -0
- package/api/icon/_adapter.mjs +17 -0
- package/api/icon/_authoring.mjs +6 -6
- package/api/icon/_default-look.mjs +16 -16
- package/api/icon/add/add.mjs +3 -3
- package/api/icon/exportIconIndex.doc.mjs +2 -2
- package/api/icon/icon.doc.mjs +2 -2
- package/api/icon/icon.type.d.mts +4 -0
- package/api/icon/icon.type.mjs +2 -1
- package/api/icon/search/icon-index.mjs +16 -3
- package/api/icon/search/search.d.mts +15 -5
- package/api/icon/search/search.mjs +74 -16
- package/api/icon/use/use.mjs +4 -4
- package/api/render/_adapter.mjs +233 -40
- package/api/render/render.type.d.mts +1 -1
- package/api/render/render.type.mjs +1 -1
- package/api/search/ORDERING.md +2 -2
- package/api/search/_adapter.mjs +4 -0
- package/api/search/_candidate-score.mjs +32 -8
- package/api/search/_cards.json +1 -1
- package/api/search/_compound.d.mts +0 -1
- package/api/search/_compound.mjs +93 -2
- package/api/search/_icons.d.mts +4 -2
- package/api/search/_icons.mjs +4 -2
- package/api/search/_lexical.mjs +177 -17
- package/api/search/_order.d.mts +3 -1
- package/api/search/_order.mjs +16 -5
- package/api/search/_result.d.mts +9 -0
- package/api/search/_result.mjs +10 -0
- package/api/search/_score.mjs +21 -3
- package/api/swizzle/_moduleGraph.d.mts +8 -0
- package/api/swizzle/_moduleGraph.mjs +61 -3
- package/api/template/copy/copy.mjs +5 -3
- package/api/template/template.type.d.mts +3 -3
- package/api/template/template.type.mjs +3 -3
- package/api/theme/_adapter.mjs +48 -12
- package/api/theme/build/build.d.mts +4 -0
- package/api/theme/build/build.mjs +69 -18
- package/api/theme/build/style-keys.mjs +4 -5
- package/api/theme/build/theme-object.mjs +5 -0
- package/api/theme/palette/generate/color.d.mts +47 -0
- package/api/theme/palette/generate/color.mjs +58 -1
- package/api/theme/palette/generate/derive-look.d.mts +293 -0
- package/api/theme/palette/generate/derive-look.mjs +1362 -0
- package/api/theme/palette/generate/editor-look.d.mts +62 -0
- package/api/theme/palette/generate/editor-look.mjs +550 -0
- package/api/theme/palette/generate/mapping.d.mts +94 -9
- package/api/theme/palette/generate/mapping.mjs +94 -22
- package/api/theme-edit/_adapter.mjs +13 -2
- package/api/theme-edit/_catalog.d.mts +13 -13
- package/api/theme-edit/_catalog.mjs +66 -28
- package/api/theme-edit/_check.d.mts +82 -6
- package/api/theme-edit/_check.mjs +1270 -238
- package/api/theme-edit/_color.d.mts +74 -0
- package/api/theme-edit/_color.mjs +168 -3
- package/api/theme-edit/_compiler.d.mts +3 -5
- package/api/theme-edit/_compiler.mjs +122 -23
- package/api/theme-edit/_context.d.mts +55 -12
- package/api/theme-edit/_context.mjs +114 -60
- package/api/theme-edit/_css.d.mts +11 -0
- package/api/theme-edit/_css.mjs +40 -0
- package/api/theme-edit/_edit.d.mts +15 -2
- package/api/theme-edit/_edit.mjs +1469 -133
- package/api/theme-edit/_how-commands.d.mts +116 -0
- package/api/theme-edit/_how-commands.mjs +227 -115
- package/api/theme-edit/_how-question.d.mts +74 -29
- package/api/theme-edit/_how-question.mjs +8514 -1256
- package/api/theme-edit/_how-sides.d.mts +22 -0
- package/api/theme-edit/_how-sides.mjs +173 -0
- package/api/theme-edit/_how-steps.d.mts +42 -0
- package/api/theme-edit/_how-steps.mjs +208 -0
- package/api/theme-edit/_how-values.d.mts +29 -0
- package/api/theme-edit/_how-values.mjs +111 -0
- package/api/theme-edit/_how-words.d.mts +15 -0
- package/api/theme-edit/_how-words.mjs +239 -0
- package/api/theme-edit/_how.d.mts +1 -1
- package/api/theme-edit/_how.mjs +422 -37
- package/api/theme-edit/_missed.d.mts +2 -1
- package/api/theme-edit/_missed.mjs +125 -13
- package/api/theme-edit/_normal.d.mts +5 -3
- package/api/theme-edit/_normal.mjs +54 -14
- package/api/theme-edit/_palette.d.mts +204 -4
- package/api/theme-edit/_palette.mjs +901 -25
- package/api/theme-edit/_part-pieces.d.mts +54 -0
- package/api/theme-edit/_part-pieces.mjs +179 -0
- package/api/theme-edit/_part-words.mjs +33 -5
- package/api/theme-edit/_parts.d.mts +133 -0
- package/api/theme-edit/_parts.mjs +599 -10
- package/api/theme-edit/_picture-traits.d.mts +259 -0
- package/api/theme-edit/_picture-traits.mjs +1030 -0
- package/api/theme-edit/_preview.d.mts +95 -4
- package/api/theme-edit/_preview.mjs +284 -31
- package/api/theme-edit/_project.d.mts +14 -4
- package/api/theme-edit/_project.mjs +95 -26
- package/api/theme-edit/_resolved.d.mts +46 -0
- package/api/theme-edit/_resolved.mjs +800 -0
- package/api/theme-edit/_set-line.d.mts +29 -0
- package/api/theme-edit/_set-line.mjs +100 -0
- package/api/theme-edit/_settings.d.mts +625 -28
- package/api/theme-edit/_settings.mjs +4867 -888
- package/api/theme-edit/_tables.d.mts +25 -1
- package/api/theme-edit/_tables.mjs +115 -11
- package/api/theme-edit/_text-looks.d.mts +78 -0
- package/api/theme-edit/_text-looks.mjs +376 -0
- package/api/theme-edit/_vet.d.mts +3 -26
- package/api/theme-edit/_vet.mjs +5 -89
- package/api/theme-edit/how/how.d.mts +1 -1
- package/api/theme-edit/how/how.mjs +1 -1
- package/api/theme-edit/show/show.d.mts +4 -3
- package/api/theme-edit/show/show.mjs +3 -2
- package/api/theme-edit/theme-edit.type.d.mts +117 -1
- package/api/theme-edit/theme-edit.type.mjs +46 -3
- package/api/theme-edit/themeEditHow.doc.mjs +3 -3
- package/api/theme-edit/themeEditNew.doc.mjs +4 -0
- package/api/theme-edit/themeEditSet.doc.mjs +6 -2
- package/api/theme-edit/themeEditShow.doc.mjs +22 -3
- package/api/theme-edit/themeEditUndo.doc.mjs +4 -0
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/author-a-theme.doc.mjs +7 -4
- package/assets/docs/icons.doc.mjs +7 -6
- package/assets/docs/theme.doc.dense.mjs +10 -0
- package/assets/docs/theme.doc.mjs +10 -0
- package/assets/docs/theme.doc.zh.mjs +10 -0
- package/assets/docs/tree/export-pages.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +89 -17
- package/assets/docs-routes.generated.json +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/icons/definitions/article.doc.mjs +9 -0
- package/assets/icons/template-icons.json +5 -0
- package/assets/search-catalog.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationInlineText.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationShowcase.tsx +3 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.doc.mjs +1 -1
- package/assets/templates/blocks/components/Citation/CitationSourceList.tsx +7 -3
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.doc.mjs +1 -1
- package/assets/templates/blocks/components/Markdown/MarkdownCitedContent.tsx +5 -2
- package/assets/templates/blocks/components/SideNav/SideNavShowcase.tsx +9 -1
- package/assets/templates/blocks/components/SideNavCollapseButton/SideNavCollapseButtonShowcase.doc.mjs +9 -2
- package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.doc.mjs +3 -2
- package/assets/templates/blocks/components/SideNavHeading/SideNavHeadingShowcase.tsx +2 -1
- package/assets/templates/blocks/components/SideNavItem/SideNavItemShowcase.doc.mjs +3 -2
- package/assets/templates/blocks/components/SideNavSection/SideNavSectionShowcase.doc.mjs +2 -1
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ide/page.tsx +5 -10
- package/assets/templates/pages/payment-form/page.tsx +16 -60
- package/assets/templates/themes/neutral/neutralTheme.ts +4 -3
- package/authoring/config/parse.mjs +1 -1
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/doctypes/_schema.d.mts +13 -13
- package/authoring/doctypes/icon-definition/parse.mjs +2 -2
- package/authoring/doctypes/icon-set/parse.mjs +1 -1
- package/authoring/doctypes/template/parse.mjs +1 -4
- package/authoring/gap-report/parse.d.mts +1 -1
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/ensure-core-built.mjs +17 -10
- package/clients/cli/commands/experimental/icon.mjs +7 -7
- package/clients/cli/commands/experimental/theme.mjs +175 -13
- package/clients/cli/commands/experimental-icon.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +11 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +15 -5
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/hook.mjs +7 -0
- package/clients/cli/commands/template.mjs +1 -1
- package/clients/cli/commands/theme-build.doc.mjs +1 -1
- package/clients/cli/index.mjs +6 -2
- package/clients/cli/lib/hook-format.mjs +41 -1
- package/clients/cli/lib/json-shim.mjs +34 -14
- package/clients/cli/lib/other-cli-words.mjs +7 -0
- package/clients/cli/lib/unknown-command.mjs +345 -46
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +11 -2
- package/foundation/agent-docs/agent-docs.mjs +51 -8
- package/foundation/config/project.d.mts +11 -1
- package/foundation/config/project.mjs +11 -2
- package/foundation/discovery/component-replacement.d.mts +5 -8
- package/foundation/discovery/component-replacement.mjs +12 -14
- package/foundation/discovery/core-augmentation-points.d.mts +35 -0
- package/foundation/discovery/core-augmentation-points.mjs +410 -9
- package/foundation/discovery/core-elements.d.mts +6 -0
- package/foundation/discovery/core-elements.mjs +10 -2
- package/foundation/discovery/core-prop-types.d.mts +5 -0
- package/foundation/discovery/core-prop-types.mjs +10 -3
- package/foundation/discovery/core-props.d.mts +8 -0
- package/foundation/discovery/core-props.mjs +29 -13
- package/foundation/discovery/icon-ranking.d.mts +5 -2
- package/foundation/discovery/icon-ranking.mjs +101 -18
- package/foundation/discovery/icon-set-checks.mjs +1 -1
- package/foundation/discovery/icon-set-writer.mjs +1 -1
- package/foundation/discovery/official-list.d.mts +17 -0
- package/foundation/discovery/official-list.mjs +77 -0
- package/foundation/discovery/template-icon-notes.mjs +3 -3
- package/foundation/discovery/template-icons.mjs +2 -2
- package/foundation/discovery/template-placeholders.mjs +1 -1
- package/foundation/discovery/unknown-core-props.d.mts +130 -0
- package/foundation/discovery/unknown-core-props.mjs +601 -0
- package/foundation/discovery/written-prop-values.d.mts +35 -0
- package/foundation/discovery/written-prop-values.mjs +258 -0
- package/foundation/fonts/fontsource-families.generated.d.mts +5 -0
- package/foundation/fonts/fontsource-families.generated.mjs +2110 -0
- package/foundation/fs/package-name.d.mts +10 -0
- package/foundation/fs/package-name.mjs +37 -0
- package/foundation/fs/project-source-files.d.mts +27 -0
- package/foundation/fs/project-source-files.mjs +115 -0
- package/foundation/fs/project-sources.d.mts +25 -0
- package/foundation/fs/project-sources.mjs +83 -0
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +36 -2
- package/foundation/integrations/integration-warnings.d.mts +39 -7
- package/foundation/integrations/integration-warnings.mjs +141 -19
- package/foundation/integrations/missing-dependency.d.mts +11 -0
- package/foundation/integrations/missing-dependency.mjs +20 -5
- package/foundation/release/folder-lock.d.mts +5 -2
- package/foundation/release/folder-lock.mjs +9 -3
- package/foundation/release/notices.mjs +2 -8
- package/foundation/render/cut-short.d.mts +8 -2
- package/foundation/render/cut-short.mjs +50 -5
- package/foundation/render/drawn-contrast.d.mts +40 -0
- package/foundation/render/drawn-contrast.mjs +355 -0
- package/foundation/render/file-header.mjs +4 -0
- package/foundation/render/layers.d.mts +2 -1
- package/foundation/render/layers.mjs +22 -1
- package/foundation/render/package-resolve-hooks.d.mts +38 -9
- package/foundation/render/package-resolve-hooks.mjs +124 -32
- package/foundation/render/page-worker.mjs +95 -23
- package/foundation/render/part-boxes.d.mts +27 -0
- package/foundation/render/part-boxes.mjs +45 -0
- package/foundation/render/picture-chrome.mjs +36 -4
- package/foundation/render/picture-playwright.mjs +26 -2
- package/foundation/render/picture-window.d.mts +29 -2
- package/foundation/render/picture-window.mjs +99 -1
- package/foundation/render/render-page.d.mts +39 -6
- package/foundation/render/render-page.mjs +26 -10
- package/foundation/render/ts-paths.mjs +2 -1
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +9 -5
- package/foundation/suggest/other-command.mjs +25 -1
- package/foundation/text/icon-set-next.d.mts +1 -1
- package/foundation/text/icon-set-next.mjs +2 -2
- package/foundation/text/written-string.d.mts +4 -1
- package/foundation/text/written-string.mjs +4 -1
- package/package.json +8 -7
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
* set's own statement of what the icon means. Word matches share one
|
|
44
44
|
* score, so they keep set order first, as every equal score does; within a
|
|
45
45
|
* set they rank by the weight of the words they carry, then the icon whose
|
|
46
|
-
* id holds fewer parts that no query word names, then id order.
|
|
46
|
+
* id holds fewer parts that no query word names, then id order. The words
|
|
47
|
+
* after the query's last icon word that spell out a component's name say
|
|
48
|
+
* where the icon goes (`information icon popover links`), so they count only
|
|
49
|
+
* to break a tie.
|
|
47
50
|
*
|
|
48
51
|
* An exact match is a NAME match when the query is the icon's id, or one of
|
|
49
52
|
* its words that is also a part of its id (`trash` for `trash-2`); it is a
|
|
@@ -397,6 +400,66 @@ function featureIconWord(words, at) {
|
|
|
397
400
|
return words[before] === 'with' && !GLYPH_WORDS.has(words[at + 1]);
|
|
398
401
|
}
|
|
399
402
|
|
|
403
|
+
/**
|
|
404
|
+
* The words of a query that say where its icon goes, not what it shows: the
|
|
405
|
+
* words after its last icon word that spell out a component's name, its last
|
|
406
|
+
* word plural or not (`information icon popover links`: `popover`, `links`;
|
|
407
|
+
* `settings icon code block`: `code`, `block`), and a component's name
|
|
408
|
+
* written as one word with the words its export name reads as
|
|
409
|
+
* (`settings icon CodeBlock`: `codeblock`, `code`, `block`). There are none
|
|
410
|
+
* unless a word that names something stands before that icon word and no
|
|
411
|
+
* `of` or `for` follows it (`an icon of a table` asks for a table), and a
|
|
412
|
+
* word also written before the icon word is never one.
|
|
413
|
+
* @param {string} query
|
|
414
|
+
* @param {() => Iterable<string>} componentNames read only when the query
|
|
415
|
+
* has words after its icon word to check
|
|
416
|
+
* @returns {Set<string>}
|
|
417
|
+
*/
|
|
418
|
+
function placeWords(query, componentNames) {
|
|
419
|
+
const typed = query.trim().split(/\s+/u).filter(Boolean);
|
|
420
|
+
const words = typed.map(word => word.toLowerCase());
|
|
421
|
+
let at = words.length - 1;
|
|
422
|
+
while (at >= 0 && !ICON_WORDS.has(words[at])) at--;
|
|
423
|
+
const before = words.slice(0, Math.max(at, 0));
|
|
424
|
+
const after = words.slice(at + 1).filter(word => !before.includes(word));
|
|
425
|
+
if (
|
|
426
|
+
at < 1 ||
|
|
427
|
+
after.length === 0 ||
|
|
428
|
+
GLYPH_WORDS.has(words[at + 1]) ||
|
|
429
|
+
before.every(word => FILLER_WORDS.has(word))
|
|
430
|
+
) {
|
|
431
|
+
return new Set();
|
|
432
|
+
}
|
|
433
|
+
const names = [...componentNames()].map(name => spokenName(name).split(' '));
|
|
434
|
+
/** @type {Set<string>} */
|
|
435
|
+
const places = new Set();
|
|
436
|
+
/** @param {string} word */
|
|
437
|
+
const place = word => {
|
|
438
|
+
if (!before.includes(word) && !FILLER_WORDS.has(word)) places.add(word);
|
|
439
|
+
};
|
|
440
|
+
for (let start = at + 1; start < words.length; start++) {
|
|
441
|
+
for (const parts of names) {
|
|
442
|
+
const spelled = parts.every((part, k) => {
|
|
443
|
+
const word = words[start + k];
|
|
444
|
+
return (
|
|
445
|
+
word !== undefined &&
|
|
446
|
+
(word === part || (k === parts.length - 1 && sameWord(part, word)))
|
|
447
|
+
);
|
|
448
|
+
});
|
|
449
|
+
if (spelled) {
|
|
450
|
+
words.slice(start, start + parts.length).forEach(place);
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
const joined = parts.join('');
|
|
454
|
+
if (words[start] === joined || sameWord(joined, words[start])) {
|
|
455
|
+
place(words[start]);
|
|
456
|
+
exportNameWords(typed[start]).split(' ').forEach(place);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return places;
|
|
461
|
+
}
|
|
462
|
+
|
|
400
463
|
/**
|
|
401
464
|
* Whether a query asks for an icon: one word as typed is `icon` or `icons` in
|
|
402
465
|
* any case, names a set in `setNames`, or is written as an icon export name
|
|
@@ -568,12 +631,18 @@ export function withDefinitionWords(icon, definitions, lookup) {
|
|
|
568
631
|
* icon carries ({@link rankWords}), the words of both readings together:
|
|
569
632
|
* the finder's own search answers and search's icons block ask for that,
|
|
570
633
|
* while callers that look for a near spelling or a fitting definition do not.
|
|
634
|
+
* `componentNames` gives the names of the components the query's words may
|
|
635
|
+
* name to say where the icon goes ({@link placeWords}); without it, none do.
|
|
571
636
|
* @param {DiscoveredIconSet[]} sets in tie order
|
|
572
637
|
* @param {string} query
|
|
573
|
-
* @param {{words?: boolean}} [options]
|
|
638
|
+
* @param {{words?: boolean, componentNames?: () => Iterable<string>}} [options]
|
|
574
639
|
* @returns {IconMatchEntry[]}
|
|
575
640
|
*/
|
|
576
|
-
export function rankIcons(
|
|
641
|
+
export function rankIcons(
|
|
642
|
+
sets,
|
|
643
|
+
query,
|
|
644
|
+
{words = false, componentNames = () => []} = {},
|
|
645
|
+
) {
|
|
577
646
|
/** @type {SearchableIcons} */
|
|
578
647
|
const searchable = new Map();
|
|
579
648
|
const typed = typedQuery(query);
|
|
@@ -591,7 +660,14 @@ export function rankIcons(sets, query, {words = false} = {}) {
|
|
|
591
660
|
if (best.length > 0) return best;
|
|
592
661
|
if (!words) return [];
|
|
593
662
|
const asked = [...new Set([...named.split(' '), ...spelled.split(' ')])];
|
|
594
|
-
return asked.length > 1
|
|
663
|
+
return asked.length > 1
|
|
664
|
+
? rankWords(
|
|
665
|
+
sets,
|
|
666
|
+
asked.join(' '),
|
|
667
|
+
searchable,
|
|
668
|
+
placeWords(query, componentNames),
|
|
669
|
+
)
|
|
670
|
+
: [];
|
|
595
671
|
}
|
|
596
672
|
|
|
597
673
|
/**
|
|
@@ -611,13 +687,16 @@ const WORD_MATCH_SCORE = 20;
|
|
|
611
687
|
* many carry it, so a rare word counts more than a common one. An icon's
|
|
612
688
|
* weight is the sum of the weights of the words it carries, with the words
|
|
613
689
|
* that name a definition the set maps it for counted twice
|
|
614
|
-
* ({@link mappedNameWords}).
|
|
690
|
+
* ({@link mappedNameWords}). The words that say where the icon goes
|
|
691
|
+
* (`places`) count only to break a tie.
|
|
615
692
|
* @param {DiscoveredIconSet[]} sets in tie order
|
|
616
693
|
* @param {string} term lower-case words, filler words left out
|
|
617
694
|
* @param {SearchableIcons} searchable this search's worked-out sets
|
|
695
|
+
* @param {Set<string>} [places] the query's words that say where the icon
|
|
696
|
+
* goes ({@link placeWords})
|
|
618
697
|
* @returns {IconMatchEntry[]}
|
|
619
698
|
*/
|
|
620
|
-
function rankWords(sets, term, searchable) {
|
|
699
|
+
function rankWords(sets, term, searchable, places = new Set()) {
|
|
621
700
|
const words = [...new Set(term.split(' '))];
|
|
622
701
|
let total = 0;
|
|
623
702
|
/** @type {Array<{set: DiscoveredIconSet, icon: IconSetIcon, definitions: string[], carried: string[], named: string[], setIndex: number}>} */
|
|
@@ -646,22 +725,26 @@ function rankWords(sets, term, searchable) {
|
|
|
646
725
|
/** @param {string} word */
|
|
647
726
|
const weight = word =>
|
|
648
727
|
Math.log((total + 1) / ((carriers.get(word) ?? 0) + 1));
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
.
|
|
657
|
-
.
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
728
|
+
/** @param {string[]} counted */
|
|
729
|
+
const weigh = counted => counted.reduce((sum, word) => sum + weight(word), 0);
|
|
730
|
+
const ranked = hits.map(hit => {
|
|
731
|
+
const counted = [...hit.carried, ...hit.named];
|
|
732
|
+
return {
|
|
733
|
+
hit,
|
|
734
|
+
value: weigh(counted.filter(word => !places.has(word))),
|
|
735
|
+
placeValue: weigh(counted.filter(word => places.has(word))),
|
|
736
|
+
unasked: hit.icon.id
|
|
737
|
+
.split('-')
|
|
738
|
+
.filter(
|
|
739
|
+
part => !words.some(word => word === part || sameWord(word, part)),
|
|
740
|
+
).length,
|
|
741
|
+
};
|
|
742
|
+
});
|
|
661
743
|
ranked.sort(
|
|
662
744
|
(a, b) =>
|
|
663
745
|
a.hit.setIndex - b.hit.setIndex ||
|
|
664
746
|
b.value - a.value ||
|
|
747
|
+
b.placeValue - a.placeValue ||
|
|
665
748
|
a.unasked - b.unasked ||
|
|
666
749
|
(a.hit.icon.id < b.hit.icon.id
|
|
667
750
|
? -1
|
|
@@ -1062,7 +1062,7 @@ function checkExports(set, packageDir, packageName, unchecked) {
|
|
|
1062
1062
|
issues.push(
|
|
1063
1063
|
issueError(
|
|
1064
1064
|
ICON_THEME_MAP_MISMATCH,
|
|
1065
|
-
`${label}: its generated module ${generated} has no theme map "${name}", which draws the built-in icons in the ${variant}
|
|
1065
|
+
`${label}: its generated module ${generated} has no theme map "${name}", which draws the built-in icons in the ${variant} variant an icon draws. Rewrite the module: \`${lookRewriteCommand(set, variant, sources)}\`.`,
|
|
1066
1066
|
),
|
|
1067
1067
|
);
|
|
1068
1068
|
continue;
|
|
@@ -1051,7 +1051,7 @@ export function libraryIcons(file, options = {}) {
|
|
|
1051
1051
|
icons =>
|
|
1052
1052
|
icons.length === all.length
|
|
1053
1053
|
? `Found ${icons.length} icons in ${label}.`
|
|
1054
|
-
: `Found ${icons.length} icons in ${label}, drawn by ${all.length} exports
|
|
1054
|
+
: `Found ${icons.length} icons in ${label}, drawn by ${all.length} exports across its look words.`,
|
|
1055
1055
|
);
|
|
1056
1056
|
}
|
|
1057
1057
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The official list, parsed. A `file` other than the CLI's own is read as it
|
|
6
|
+
* is. For the CLI's own list, a checkout derives it from the repository
|
|
7
|
+
* (`root`, else the checkout), and a published CLI reads the file it was
|
|
8
|
+
* packed with. Throws when the list cannot be read or derived.
|
|
9
|
+
* @param {{file?: string, root?: string}} [options]
|
|
10
|
+
* @returns {any}
|
|
11
|
+
*/
|
|
12
|
+
export function readOfficialList({ file, root }?: {
|
|
13
|
+
file?: string;
|
|
14
|
+
root?: string;
|
|
15
|
+
}): any;
|
|
16
|
+
/** The list `prepack` writes into the published CLI. */
|
|
17
|
+
export const OFFICIAL_LIST_FILE: string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The official package list as the CLI reads it (spec:AST-051 FR11).
|
|
5
|
+
* @input The list file `prepack` writes, or the repository the CLI sits in
|
|
6
|
+
* @output `readOfficialList`: the parsed list
|
|
7
|
+
* @position The one reader of the list for `discover` and the release notices.
|
|
8
|
+
* A published CLI reads the file it was packed with. A checkout has no such
|
|
9
|
+
* file, so it asks the generator (scripts/generate-official-packages.mjs)
|
|
10
|
+
* for the list, once per process: a new package needs no edit here.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {execFileSync} from 'node:child_process';
|
|
14
|
+
import * as fs from 'node:fs';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import {fileURLToPath} from 'node:url';
|
|
17
|
+
|
|
18
|
+
// Found from this file, not from fs/paths.mjs: the release notices read the
|
|
19
|
+
// list, and paths.mjs and the notices load each other.
|
|
20
|
+
const CLI_DIR = path.resolve(
|
|
21
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
22
|
+
'..',
|
|
23
|
+
'..',
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
/** The list `prepack` writes into the published CLI. */
|
|
27
|
+
export const OFFICIAL_LIST_FILE = path.join(
|
|
28
|
+
CLI_DIR,
|
|
29
|
+
'assets',
|
|
30
|
+
'discover',
|
|
31
|
+
'official-packages.json',
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/** The generator. A checkout has it; a published CLI does not. */
|
|
35
|
+
const GENERATOR = path.join(
|
|
36
|
+
CLI_DIR,
|
|
37
|
+
'scripts',
|
|
38
|
+
'generate-official-packages.mjs',
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
/** @type {Map<string, unknown>} */
|
|
42
|
+
const derived = new Map();
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The official list, parsed. A `file` other than the CLI's own is read as it
|
|
46
|
+
* is. For the CLI's own list, a checkout derives it from the repository
|
|
47
|
+
* (`root`, else the checkout), and a published CLI reads the file it was
|
|
48
|
+
* packed with. Throws when the list cannot be read or derived.
|
|
49
|
+
* @param {{file?: string, root?: string}} [options]
|
|
50
|
+
* @returns {any}
|
|
51
|
+
*/
|
|
52
|
+
export function readOfficialList({file = OFFICIAL_LIST_FILE, root} = {}) {
|
|
53
|
+
if (file !== OFFICIAL_LIST_FILE || !fs.existsSync(GENERATOR)) {
|
|
54
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
55
|
+
}
|
|
56
|
+
const key = root ?? '';
|
|
57
|
+
if (!derived.has(key)) {
|
|
58
|
+
let text;
|
|
59
|
+
try {
|
|
60
|
+
text = execFileSync(
|
|
61
|
+
process.execPath,
|
|
62
|
+
[GENERATOR, '--print', ...(root == null ? [] : ['--root', root])],
|
|
63
|
+
{encoding: 'utf8', maxBuffer: 64 * 1024 * 1024, stdio: 'pipe'},
|
|
64
|
+
);
|
|
65
|
+
} catch (error) {
|
|
66
|
+
const why = String(
|
|
67
|
+
/** @type {{stderr?: unknown}} */ (error).stderr ?? error,
|
|
68
|
+
).trim();
|
|
69
|
+
throw new Error(
|
|
70
|
+
`the official list could not be derived from the repository${why ? `: ${why}` : ''}`,
|
|
71
|
+
{cause: error},
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
derived.set(key, JSON.parse(text));
|
|
75
|
+
}
|
|
76
|
+
return derived.get(key);
|
|
77
|
+
}
|
|
@@ -127,7 +127,7 @@ export async function templateIconUndeclaredNotes(loaded, packageDir) {
|
|
|
127
127
|
return {
|
|
128
128
|
notes: undeclared.map(({id, key, module}) => ({
|
|
129
129
|
code: TEMPLATE_ICON_UNDECLARED,
|
|
130
|
-
message: `${id} imports icon "${key}" from ${module}, but ${docOf.get(id)} does not declare it in \`icons\`, so it never follows a project's icon set. Add \`${key}: '<definition>'\` to \`icons\` (\`astryx experimental icon --definitions\` lists the
|
|
130
|
+
message: `${id} imports icon "${key}" from ${module}, but ${docOf.get(id)} does not declare it in \`icons\`, so it never follows a project's icon set. Add \`${key}: '<definition>'\` to \`icons\` (\`astryx experimental icon --definitions\` lists the meanings).`,
|
|
131
131
|
})),
|
|
132
132
|
unchecked: unchecked.map(({id, key, module, why}) => ({
|
|
133
133
|
file: id,
|
|
@@ -135,10 +135,10 @@ export async function templateIconUndeclaredNotes(loaded, packageDir) {
|
|
|
135
135
|
module,
|
|
136
136
|
reason:
|
|
137
137
|
why === 'renderer'
|
|
138
|
-
? `"${key}" is a generic renderer: it is a bare \`Icon\`, or every use gives it an icon prop, so it draws no one icon
|
|
138
|
+
? `"${key}" is a generic renderer: it is a bare \`Icon\`, or every use gives it an icon prop, so it draws no one icon meaning and needs no \`icons\` key.`
|
|
139
139
|
: why === 'use'
|
|
140
140
|
? `"${key}" is not rendered as an icon: the template never renders it as an element without children or passes it as a value, so it needs no \`icons\` key. Declaring it would make \`astryx template\` swap it for an icon.`
|
|
141
|
-
: `"${key}" matches an icon by its name only: no template in the package declares an icon from ${module}, so the check cannot tell whether it draws one icon
|
|
141
|
+
: `"${key}" matches an icon by its name only: no template in the package declares an icon from ${module}, so the check cannot tell whether it draws one icon meaning. Declare an icon from ${module} in a template's \`icons\` to have its imports checked.`,
|
|
142
142
|
})),
|
|
143
143
|
};
|
|
144
144
|
}
|
|
@@ -1147,7 +1147,7 @@ export function mapTemplateIcons(source, {sets, choice}, declared = {}) {
|
|
|
1147
1147
|
export: imported,
|
|
1148
1148
|
reason:
|
|
1149
1149
|
record.definitions.length > 0
|
|
1150
|
-
? `${icons.set} maps no icon to the icon
|
|
1150
|
+
? `${icons.set} maps no icon to the icon meaning "${record.definitions.join('", "')}"${record.setName ? ', and none is a reviewed match for it' : ''}`
|
|
1151
1151
|
: `no icon in ${targets.length > 1 ? 'any set in your list' : icons.set} is a reviewed match for it`,
|
|
1152
1152
|
...(likely
|
|
1153
1153
|
? {
|
|
@@ -1247,7 +1247,7 @@ export function mapTemplateIcons(source, {sets, choice}, declared = {}) {
|
|
|
1247
1247
|
reason:
|
|
1248
1248
|
wrapper === target
|
|
1249
1249
|
? `it already comes from ${from}, which ${icons.set} wraps`
|
|
1250
|
-
: `no set in your list maps its icon
|
|
1250
|
+
: `no set in your list maps its icon meaning, and it already comes from ${from}, which ${wrapper.package}/${wrapper.name} wraps`,
|
|
1251
1251
|
});
|
|
1252
1252
|
}
|
|
1253
1253
|
}
|
|
@@ -442,7 +442,7 @@ export function templatePlaceholderProblems(templates, definitions) {
|
|
|
442
442
|
: null;
|
|
443
443
|
if (!meaning || !definitions.has(meaning)) {
|
|
444
444
|
problems.push(
|
|
445
|
-
`${id}: ${name} names no icon meaning. Fix: import <Meaning>Icon for an icon
|
|
445
|
+
`${id}: ${name} names no icon meaning. Fix: import <Meaning>Icon for an icon meaning (astryx experimental icon <words> finds it), or add the meaning in the same change.`,
|
|
446
446
|
);
|
|
447
447
|
continue;
|
|
448
448
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The project's own TypeScript, found from the first of `dirs` that has one,
|
|
6
|
+
* or why the props cannot be checked without it and what to install. Doctor
|
|
7
|
+
* and the export say the same thing.
|
|
8
|
+
* @param {string[]} dirs
|
|
9
|
+
* @returns {{ts: any} | {skipped: string, reason: string}} `reason` is the
|
|
10
|
+
* same reason worded for a folder outside a project, with no install step
|
|
11
|
+
*/
|
|
12
|
+
export function projectTypeScript(dirs: string[]): {
|
|
13
|
+
ts: any;
|
|
14
|
+
} | {
|
|
15
|
+
skipped: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* For each component that Core's docs describe, its documented props as
|
|
20
|
+
* `astryx component <Name> --props` prints them, read in batches from the
|
|
21
|
+
* Core of the folder `cwd`. Doctor and the export read the docs through this
|
|
22
|
+
* one reader.
|
|
23
|
+
* @param {(names: string[], options: {cwd: string, package: string, props: boolean}) => Promise<unknown>} answer
|
|
24
|
+
* the component read (`component` of api/component), which this layer
|
|
25
|
+
* cannot import
|
|
26
|
+
* @param {string[]} names
|
|
27
|
+
* @param {string} cwd
|
|
28
|
+
* @param {number} batchLimit the most components one read takes
|
|
29
|
+
* @returns {Promise<Map<string, any[]>>}
|
|
30
|
+
*/
|
|
31
|
+
export function readCoreDocs(answer: (names: string[], options: {
|
|
32
|
+
cwd: string;
|
|
33
|
+
package: string;
|
|
34
|
+
props: boolean;
|
|
35
|
+
}) => Promise<unknown>, names: string[], cwd: string, batchLimit: number): Promise<Map<string, any[]>>;
|
|
36
|
+
/**
|
|
37
|
+
* The names of a component's documented props, as `readCoreDocs` gives them.
|
|
38
|
+
* @param {any[]} props
|
|
39
|
+
* @returns {string[]}
|
|
40
|
+
*/
|
|
41
|
+
export function propNamesOf(props: any[]): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Whether a TypeScript module may widen what JSX gives every component (see
|
|
44
|
+
* `JSX_DECLARATION`). Doctor, which reads each file once, asks it of every
|
|
45
|
+
* file it reads.
|
|
46
|
+
* @param {string} file
|
|
47
|
+
* @param {string} text
|
|
48
|
+
*/
|
|
49
|
+
export function widensJsx(file: string, text: string): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The props pages give Core components that the component does not take. A
|
|
52
|
+
* prop is a candidate when Core's docs for the component (the props
|
|
53
|
+
* `astryx component <Name> --package @astryxdesign/core` lists) leave it out,
|
|
54
|
+
* and it is reported only when TypeScript, reading Core's own published types
|
|
55
|
+
* as the pages see them, says the component's props do not take it either;
|
|
56
|
+
* the project's own modules that widen React's JSX are read with Core's
|
|
57
|
+
* types. A prop name React's types give an HTML or SVG element is never
|
|
58
|
+
* reported, since a component may pass it on to the element it renders, and
|
|
59
|
+
* neither is a prop JSX gives every component. A component with no docs, one
|
|
60
|
+
* TypeScript cannot read, a generic one, and a page whose config or build
|
|
61
|
+
* compiles JSX with another runtime or a `css` prop are not judged. Each page
|
|
62
|
+
* is judged with the config TypeScript reads for it. Only the docs are read
|
|
63
|
+
* while every prop is documented: TypeScript, configs and the project's
|
|
64
|
+
* files are read for candidates alone. `skipped` says why the candidates
|
|
65
|
+
* were not judged.
|
|
66
|
+
* @param {object} input
|
|
67
|
+
* @param {string} input.projectDir the folder of the pages' project
|
|
68
|
+
* @param {PageCorePropUse[]} input.uses
|
|
69
|
+
* @param {string[]} input.pages every page that imports Core, the pages of
|
|
70
|
+
* `uses` among them
|
|
71
|
+
* @param {(names: string[], cwd: string) => Promise<Map<string, any[]>>} input.readDocs
|
|
72
|
+
* for each component the docs describe, its documented props (`readCoreDocs`),
|
|
73
|
+
* read from the Core of the folder `cwd`
|
|
74
|
+
* @param {() => {ts: any} | {skipped: string, reason?: string}} input.typescript
|
|
75
|
+
* the compiler to read Core's types with, or why there is none (`reason`
|
|
76
|
+
* worded for a folder outside a project)
|
|
77
|
+
* @param {() => string[] | null} [input.jsxDeclarations] the files that may
|
|
78
|
+
* widen what JSX gives every component (`jsxDeclarationFiles` by default)
|
|
79
|
+
* @param {boolean} [input.runtimeFirst] doctor's order: report pages that
|
|
80
|
+
* find no installed Core, and a project on another JSX runtime
|
|
81
|
+
* (`jsxRuntimeCheck`), before the docs, whatever the props are. By default
|
|
82
|
+
* both are reported for candidates alone, and a page that finds no
|
|
83
|
+
* installed Core still reads the docs of the Core it renders with
|
|
84
|
+
* @returns {Promise<{found: UnknownCoreProp[], skipped: string | null, reason?: string}>}
|
|
85
|
+
* `skipped` ends with what to install when an install fixes it; `reason`,
|
|
86
|
+
* when given, is the same reason without that step, for a folder outside
|
|
87
|
+
* a project, where a project install step does not apply
|
|
88
|
+
*/
|
|
89
|
+
export function judgeCoreProps({ projectDir, uses, pages, readDocs, typescript, jsxDeclarations, runtimeFirst, }: {
|
|
90
|
+
projectDir: string;
|
|
91
|
+
uses: PageCorePropUse[];
|
|
92
|
+
pages: string[];
|
|
93
|
+
readDocs: (names: string[], cwd: string) => Promise<Map<string, any[]>>;
|
|
94
|
+
typescript: () => {
|
|
95
|
+
ts: any;
|
|
96
|
+
} | {
|
|
97
|
+
skipped: string;
|
|
98
|
+
reason?: string;
|
|
99
|
+
};
|
|
100
|
+
jsxDeclarations?: (() => string[] | null) | undefined;
|
|
101
|
+
runtimeFirst?: boolean | undefined;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
found: UnknownCoreProp[];
|
|
104
|
+
skipped: string | null;
|
|
105
|
+
reason?: string;
|
|
106
|
+
}>;
|
|
107
|
+
export { OTHER_JSX_RUNTIME } from "./core-elements.mjs";
|
|
108
|
+
/**
|
|
109
|
+
* a prop a page gives a Core component, with the page as the caller shows
|
|
110
|
+
* it (`file`) and its absolute path
|
|
111
|
+
*/
|
|
112
|
+
export type PageCorePropUse = import("./core-props.mjs").CorePropUse & {
|
|
113
|
+
file: string;
|
|
114
|
+
path: string;
|
|
115
|
+
};
|
|
116
|
+
export type UnknownCoreProp = {
|
|
117
|
+
/**
|
|
118
|
+
* as the caller shows it
|
|
119
|
+
*/
|
|
120
|
+
file: string;
|
|
121
|
+
line: number;
|
|
122
|
+
column: number;
|
|
123
|
+
component: string;
|
|
124
|
+
prop: string;
|
|
125
|
+
/**
|
|
126
|
+
* a documented prop with the same
|
|
127
|
+
* words, when there is one
|
|
128
|
+
*/
|
|
129
|
+
suggestion: string | null;
|
|
130
|
+
};
|