@astryxdesign/cli 0.7.8-canary.ffd29c5 → 0.7.9-canary.048476f
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 +62 -0
- package/README.md +1 -1
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/docs/_adapter.d.mts +8 -2
- package/api/docs/_adapter.mjs +10 -4
- package/api/docs/detail/section/section.d.mts +5 -2
- package/api/docs/detail/section/section.mjs +6 -2
- package/api/docs/docs.mjs +7 -1
- package/api/doctor/_adapter.d.mts +6 -2
- package/api/doctor/_adapter.mjs +5 -3
- package/api/doctor/built-checks.d.mts +9 -4
- package/api/doctor/built-checks.mjs +15 -10
- package/api/search/_adapter.d.mts +3 -1
- package/api/search/_adapter.mjs +12 -2
- package/api/search/_candidate-score.d.mts +4 -1
- package/api/search/_candidate-score.mjs +27 -11
- package/api/search/_gather-components.mjs +5 -0
- package/api/search/_gather-templates.mjs +31 -6
- package/api/search/_lexical.d.mts +14 -0
- package/api/search/_lexical.mjs +4 -0
- package/api/search/_result.d.mts +1 -0
- package/api/search/_result.mjs +1 -0
- package/api/search/search.d.mts +3 -1
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +9 -8
- package/api/search/search.type.d.mts +4 -0
- package/api/search/search.type.mjs +1 -0
- package/api/theme/build/build.d.mts +26 -1
- package/api/theme/build/build.mjs +50 -19
- package/api/theme/build/core-interception.d.mts +2 -1
- package/api/theme/build/core-interception.mjs +23 -5
- package/assets/codemods/registry.mjs +1 -0
- package/assets/codemods/transforms/next/index.mjs +1 -11
- package/assets/codemods/transforms/v0.7.8/index.mjs +20 -0
- package/assets/docs/browser-support.doc.mjs +27 -1
- package/assets/docs/tree/tokens-color.doc.mjs +1 -1
- package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useClickableContainerHookUsage.tsx +67 -0
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useClipboardHookUsage.tsx +35 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.tsx +55 -0
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.doc.mjs +15 -0
- package/assets/templates/blocks/components/Hooks/useTreeFocusHookUsage.tsx +98 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.doc.mjs +14 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipMetricDefinitions.tsx +46 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.doc.mjs +14 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipPermissionNotes.tsx +41 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.doc.mjs +13 -0
- package/assets/templates/blocks/components/InfoTip/InfoTipShowcase.tsx +24 -0
- package/assets/theme.template.ts +1 -1
- package/authoring/doctypes/_schema.d.mts +16 -0
- package/authoring/doctypes/_schema.mjs +15 -0
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +16 -0
- package/authoring/index.d.ts +1 -0
- package/clients/cli/commands/build.mjs +9 -3
- package/clients/cli/commands/search.mjs +8 -2
- package/clients/cli/formatters/index.mjs +11 -0
- package/foundation/discovery/template-adapter.d.mts +10 -0
- package/foundation/discovery/template-adapter.mjs +94 -4
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
- /package/assets/codemods/transforms/{next → v0.7.8}/promote-tokenizer-presentation.mjs +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# @xds/cli
|
|
2
2
|
|
|
3
|
+
# 0.7.8
|
|
4
|
+
|
|
5
|
+
#### Experimental APIs
|
|
6
|
+
|
|
7
|
+
- `astryx` discovery lists the lab's new `SelectableCardGroup`.
|
|
8
|
+
|
|
9
|
+
#### New Features
|
|
10
|
+
|
|
11
|
+
- In Chrome on Android, on a touch screen, a Tall BottomSheet places the focused field just above the on-screen keyboard when Chrome reports it, then rides the rest of Gboard's slide; through the hide the sheet's scroll room stays while its content rides down, so nothing jumps while the keyboard is still on screen. Under Reduce Motion it cross-fades instead of moving. The browser-support guide says so.
|
|
12
|
+
- A component doc can mark its component deprecated with `deprecated: {replacement, description}`: the `name` of the component to use instead and the modernization route. `astryx search` results and `astryx build` kit entries for that component carry the field as `deprecated` (a `deprecated:` line in their text output), and the docsite shows a Deprecated badge in the component's page header (beside any stability badge) and a notice at the top of its page that names and links the replacement, and labels it Deprecated on its components index tile and in site search. `BottomSheetSwitcher` sets it, naming `BottomSheet`; the component keeps working unchanged.
|
|
13
|
+
- `createAnimator(element)` and its hook `useAnimator(ref)` animate one element with the motion Astryx's components use; the hook takes the element's ref, so a gesture hook can share the element. `animate` springs `x`, `y`, `scale`, `rotate` and `opacity` to a target on the state-change motion, `decay` coasts any of them from a release velocity, `set` jumps, `get` and `getVelocity` read, and `stop` halts; `animate` and `decay` return a promise. Reduce Motion is planned for every call. `createAnimator` is exported from the package root and `useAnimator` from `@astryxdesign/core/hooks`; the CLI's templates gain a playing-cards example of each.
|
|
14
|
+
- `astryx upgrade` gains the `promote-tokenizer-presentation` codemod. It rewrites a static `experimental={{presentation: x}}` on Tokenizer, the 0.7.7 spelling that Tokenizer no longer reads, to `presentation={x}`. Where it cannot prove the rewrite, including any Tokenizer that spreads props (a spread may also set `presentation`), it leaves the call unchanged with a TODO.
|
|
15
|
+
|
|
16
|
+
#### Fixes
|
|
17
|
+
|
|
18
|
+
- `astryx component` takes a component's exact name in another case as that component's, never a module's that only shares the spelling. `tokenizer` opens Tokenizer's doc instead of CodeBlock's, which it reached through `CodeBlock/tokenizer.ts`. `--source` with `tokenizer`, `slider`, `switch` or `progressBar` no longer prints `CodeBlock/tokenizer.ts` or the motion tables in `motion/uikit/`, and answers `ERR_NO_SOURCE`, as `--source badge` does.
|
|
19
|
+
- The theme token `--duration-exit`, the standard dismissal duration, now exists. It defaults to `var(--duration-fast)`, so it follows a theme's `tempo` through that token, and a theme can set it like any duration token. Before, a theme or component that read `var(--duration-exit)` found no value. The motion and token docs, and the theme template's token list, name it.
|
|
20
|
+
|
|
21
|
+
#### Performance
|
|
22
|
+
|
|
23
|
+
- `integrationComponentConflicts()`, `integrationDocConflicts()` and `integrationCheck()` from `@astryxdesign/cli/api`, and `doctor integration components`, `doctor integration docs` and `integration check`, find Core's components from the folder listings they already read, with far fewer file system calls. Their results are unchanged.
|
|
24
|
+
- A run of `astryx` loads only the command it names, so it starts with less work: `astryx --version` uses about 0.31 s less CPU, and `astryx docs --json`, `astryx component --list` and `astryx theme build` about 0.25–0.3 s less. Help, the manifest and an unknown command still load every command. Output and exit codes are unchanged.
|
|
25
|
+
- `astryx search` and `astryx build` parse a page template's source for the components it renders only when the query could match one of them. A query no page renders parses only the few pages whose source holds an escape, and a first search for it uses about 20% less CPU. A query whose words name components on most pages still parses most of them and can take up to about 4% more. Results are unchanged.
|
|
26
|
+
|
|
27
|
+
#### Documentation
|
|
28
|
+
|
|
29
|
+
- The browser-support guide has a section on the on-screen keyboard: a fully expanded Tall BottomSheet measures it as the layout viewport's height minus the visual viewport's, and keeps the focused field above it in Safari on iOS, Firefox for Android and Chrome on Android. In Chrome, by default (`interactive-widget=resizes-visual`), the sheet adds its scroll room once Chrome reports the keyboard; with `interactive-widget=resizes-content` Chrome shrinks the page for the keyboard itself and the sheet changes nothing. Your app owns its viewport `<meta>` element; Astryx never sets it.
|
|
30
|
+
- Hook docs for `useLightbox`, so `astryx hook useLightbox` and `astryx search` return it, and a `useLightbox — Gallery Grid` example block: a grid of photo thumbnails that opens a fullscreen gallery at the clicked item.
|
|
31
|
+
- A new `useAnnounce — Filter Result Count` example block shows the hook on a product filter: once typing pauses for 500 ms, a screen reader hears the result count ("3 results", or "No results"). The count has its own `hasReplace` instance, as the hook's docs advise for a changing value. Copy it with `astryx template useAnnounceHookUsage <path>`.
|
|
32
|
+
- A new `useClipboard — Share Link` example block shows the hook on a share card: Copy writes the invite link, the button reads "Copied" while `isCopied` is true and resets on the hook's timer, and a screen reader hears "Link copied". Copy it with `astryx template useClipboardHookUsage <path>`.
|
|
33
|
+
- A new `useFocusTrap — Quick Edit Panel` example block traps focus in a custom quick-edit panel that is not built on Dialog: `focusFirst` moves focus to its field on open, Tab and Shift+Tab stay inside it, Escape closes it through `onEscape`, and closing returns focus to the Quick edit button. Copy it with `astryx template useFocusTrapHookUsage <path>`.
|
|
34
|
+
- A new `useHotkeys — Search and Help Shortcuts` example block shows the hook on a page header: "/" focuses the search field and "?" opens the shortcut help, typing either character in the field does not trigger them, and a switch turns the single-key shortcuts off through `isDisabled`. Copy it with `astryx template useHotkeysHookUsage <path>`.
|
|
35
|
+
- A new `useInputStatusIcon — Coupon Code Status` example block shows a custom bordered input that takes its status affordance from `useInputStatusIcon`: a wrong code shows the error status and the valid code shows success, and the variant switch moves between a glyph with a message below (attached), no icon on the field (detached), and a focusable button with a tooltip that keyboard and screen-reader users can reach (tooltip). Copy it with `astryx template useInputStatusIconHookUsage <path>`.
|
|
36
|
+
- The `useKeyboardHint — Arrow-key Hint` example block now calls `useKeyboardHint` itself instead of relying on Toolbar, which calls the hook internally. It is a five-star rating with one Tab stop, where Left and Right change the rating: tabbing into it shows the "← → to navigate" hint, the first arrow press dismisses it, and tabbing back in does not show it again. Copy it with `astryx template useKeyboardHintHookUsage <path>`.
|
|
37
|
+
- A new `useLocale — Invoice Summary` example block formats an invoice date and amount with `Intl` using the locale from `useLocale`, so switching the provider from English to German changes "Nov 2, 2026 · $1,234.50" to "2. Nov. 2026 · 1.234,50 $" with no second locale source. Copy it with `astryx template useLocaleHookUsage <path>`.
|
|
38
|
+
- A new `useScrollableArea — Activity Log Panel` example block shows a fixed-height Activity log whose entries scroll. `useScrollableArea` makes the panel a keyboard tab stop only when its entries overflow, shows a top or bottom edge shadow only where entries are hidden, and stops a scroll at the end from scrolling the page. Add entry flips it from not scrollable to scrollable. Copy it with `astryx template useScrollableAreaHookUsage <path>`.
|
|
39
|
+
- A new `useTreeFocus — Keyboard File Tree` example block builds a small file tree from plain rows with tree roles and gives it the WAI-ARIA tree keyboard model with `useTreeFocus`: arrow keys move over the visible rows and open, enter, leave or close folders, Home and End jump to the ends, a typed letter jumps to a matching name, Enter opens a file, and one row is the tab stop. Copy it with `astryx template useTreeFocusHookUsage <path>`.
|
|
40
|
+
- A new `useTypeahead — Type to Focus a Country` example block adds type-to-focus to a country list of buttons. Typing "can" focuses Canada, pressing "b" again and again cycles through Belgium, Brazil and Bulgaria, and "e" finds Éire with the accent ignored. `useTypeahead` reports each match through `onMatch`, and `useListFocus` moves focus. Copy it with `astryx template useTypeaheadHookUsage <path>`.
|
|
41
|
+
|
|
42
|
+
#### Other Changes
|
|
43
|
+
|
|
44
|
+
- Internal: the file read behind `astryx doctor --built` takes its file limit as an option, 20,000 unless a caller passes one, and the checks' messages name the limit the read used. The command's checks and output are unchanged. Not exported from the package entry point.
|
|
45
|
+
- `astryx discover` no longer lists the Lab components `MobileTokenizer` and `MobilePowerSearch`, which are removed from `@astryxdesign/lab`; their touch flows are Core's Tokenizer and PowerSearch `presentation` sheets.
|
|
46
|
+
- Internal: the public-import check's `declaredTargets` and `missingNames` are exported from their foundation module, so the docsite's production registry judges a copied example's imports by the same rule. The CLI's checks and their output are unchanged. Not exported from the package entry point.
|
|
47
|
+
- Internal: a gap-report handler's time budget starts once its module has loaded. Starting its worker and loading the module have the default deadline, so a short budget in a contract test no longer covers a slow start on a busy machine. The 30-second handler budget is unchanged.
|
|
48
|
+
- Internal: generating the CLI's type declarations no longer fails when builds in two checkouts run at once on one machine, and it no longer needs pnpm on PATH.
|
|
49
|
+
- The Tokenizer blocks and page templates that show a prop the bottom sheet does not render (`hasClear`, `endContent`, `tokenOverflowBehavior`, `hasEntriesOnFocus`, `renderToken`) pass `presentation="popover"`, so they keep the inline field on phones under Tokenizer's new `'adaptive'` default.
|
|
50
|
+
|
|
51
|
+
#### Contributors
|
|
52
|
+
|
|
53
|
+
Thanks to everyone who contributed to this release:
|
|
54
|
+
|
|
55
|
+
- @10k11
|
|
56
|
+
- @cixzhang
|
|
57
|
+
- @Geervan
|
|
58
|
+
- @imdreamrunner
|
|
59
|
+
- @kyu-rong
|
|
60
|
+
- @MannXo
|
|
61
|
+
- @vjeux
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
3
65
|
# 0.7.7
|
|
4
66
|
|
|
5
67
|
#### New Components
|
package/README.md
CHANGED
|
@@ -495,7 +495,7 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
495
495
|
| `discover.detail.doc` | The validated ComponentDoc for one installed component, for an @scope/name/Component query, plus package, the npm package that owns the component. |
|
|
496
496
|
| `discover.item` | One item that is not an installed component, for an @scope/name/<item> query: its kind, name, package, version, and whether the project has the package. The envelope's package names the same package. |
|
|
497
497
|
| `discover.search` | The echoed query plus every matching item and package across all packages, each with its kind and whether the project has it, even when only one matches; total is set when --limit cut the list. |
|
|
498
|
-
| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, package, score, reason, description, command} (package is the npm package that owns the result), plus import (components, hooks), title, parent (the command that opens the level above), and, for a hit on one section, section (docs), or displayName and kind (templates). When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is {skipped, reason}: the domains it skipped (component, hook, template) and why.
|
|
498
|
+
| `search` | The echoed query, `matchCount` (total matches, before `limit`), and results, a ranked SearchResultEntry[] bounded by `limit`: each {domain, name, package, score, reason, description, command} (package is the npm package that owns the result), plus import (components, hooks), title, parent (the command that opens the level above), and, for a hit on one section, section (docs), or displayName and kind (templates). The result for a deprecated component also carries deprecated {replacement, description}: the name of the component to use instead and the modernization route, from its doc. When a search with no `type` could not obtain @astryxdesign/core, `meta.partial` is {skipped, reason}: the domains it skipped (component, hook, template) and why. |
|
|
499
499
|
| `build.help` | The how-to-build-a-page playbook, emitted when no query is given: `playbook: true`, a title, the ordered steps (title, commands, optional returns), the on-system rules, and related lookups. Commands are bare subcommands for the caller to render with its own invocation. |
|
|
500
500
|
| `build.kit` | The template to start from and its kit: query, hasResults, matchCount (never a cap), directMatch, start {name, package, command, basis, reason, alternatives, ...} (the start and each alternative name the package that owns the template), pages (search's closest templates), blocks and domain as SearchResultEntry[] (each naming its package), frame and foundation (Core component names), and hint {reason, commands} when thin. |
|
|
501
501
|
| `swizzle.list` | The names of swizzlable components discoverable from cwd's @astryxdesign/core. The envelope's package is @astryxdesign/core. |
|
|
@@ -277,7 +277,7 @@ useListFormatter useListFormatter i18n/InternationalizationProvider.doc.mjs i18n
|
|
|
277
277
|
useMenuDrillIn useMenuDrillIn DropdownMenu/DropdownMenu.doc.mjs DropdownMenu/useMenuDrillIn.tsx
|
|
278
278
|
useMenuHover useMenuHover hooks/useAnimatedLayout.doc.mjs hooks/useMenuHover.ts
|
|
279
279
|
useMenuOverflow useMenuOverflow DropdownMenu/DropdownMenu.doc.mjs DropdownMenu/useMenuOverflow.ts
|
|
280
|
-
useMobileKeyboard
|
|
280
|
+
useMobileKeyboard ERR_UNKNOWN_COMPONENT - keyboard/useMobileKeyboard.ts
|
|
281
281
|
useOutlineFromDOM useOutlineFromDOM Outline/Outline.doc.mjs Outline/useOutlineFromDOM.ts
|
|
282
282
|
useOverlay useOverlay Overlay/Overlay.doc.mjs Overlay/useOverlay.tsx
|
|
283
283
|
useOwnScrollGesture useOwnScrollGesture DateInput/DateInput.doc.mjs DateInput/useOwnScrollGesture.ts
|
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -274,6 +274,11 @@ export function topicLinks(catalog: DocsCatalog, entry: import("../../foundation
|
|
|
274
274
|
* decides.
|
|
275
275
|
* @param {unknown} topic
|
|
276
276
|
* @param {{cwd?: string}} [options]
|
|
277
|
+
* @param {DocsCatalog} [loaded] internal: a catalog the read already loaded,
|
|
278
|
+
* so the read and every part of it share one snapshot of the project's docs
|
|
279
|
+
* (and its memoized lowering) instead of loading the project again for each
|
|
280
|
+
* part. It is a separate argument, never an option, so no caller of the
|
|
281
|
+
* public `docs()` can set it
|
|
277
282
|
* @returns {Promise<
|
|
278
283
|
* | {kind: 'topic', catalog: DocsCatalog, entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
|
|
279
284
|
* | {kind: 'node', catalog: DocsCatalog, tree: import('../../foundation/doc-compiler/tree.mjs').DocsTree, node: import('../../foundation/doc-compiler/tree.mjs').TreeNode}
|
|
@@ -282,7 +287,7 @@ export function topicLinks(catalog: DocsCatalog, entry: import("../../foundation
|
|
|
282
287
|
*/
|
|
283
288
|
export function resolveDocsArgument(topic: unknown, { cwd }?: {
|
|
284
289
|
cwd?: string;
|
|
285
|
-
}): Promise<{
|
|
290
|
+
}, loaded?: DocsCatalog): Promise<{
|
|
286
291
|
kind: "topic";
|
|
287
292
|
catalog: DocsCatalog;
|
|
288
293
|
entry: import("../../foundation/discovery/docs-discovery.mjs").DocsTopicEntry;
|
|
@@ -358,13 +363,14 @@ export function notLoaded(catalog: DocsCatalog): string;
|
|
|
358
363
|
* and lower it for the topic readers.
|
|
359
364
|
* @param {unknown} topic
|
|
360
365
|
* @param {{lang?: string | null, zh?: boolean, dense?: boolean, cwd?: string}} [options]
|
|
366
|
+
* @param {DocsCatalog} [loaded] internal, as {@link resolveDocsArgument}
|
|
361
367
|
*/
|
|
362
368
|
export function resolveTopicDocs(topic: unknown, options?: {
|
|
363
369
|
lang?: string | null;
|
|
364
370
|
zh?: boolean;
|
|
365
371
|
dense?: boolean;
|
|
366
372
|
cwd?: string;
|
|
367
|
-
}): Promise<{
|
|
373
|
+
}, loaded?: DocsCatalog): Promise<{
|
|
368
374
|
catalog: DocsCatalog;
|
|
369
375
|
node: import("../../foundation/doc-compiler/compile.mjs").CompiledReferenceNode;
|
|
370
376
|
lang: string | null;
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -1721,14 +1721,19 @@ export async function topicLinks(catalog, entry) {
|
|
|
1721
1721
|
* decides.
|
|
1722
1722
|
* @param {unknown} topic
|
|
1723
1723
|
* @param {{cwd?: string}} [options]
|
|
1724
|
+
* @param {DocsCatalog} [loaded] internal: a catalog the read already loaded,
|
|
1725
|
+
* so the read and every part of it share one snapshot of the project's docs
|
|
1726
|
+
* (and its memoized lowering) instead of loading the project again for each
|
|
1727
|
+
* part. It is a separate argument, never an option, so no caller of the
|
|
1728
|
+
* public `docs()` can set it
|
|
1724
1729
|
* @returns {Promise<
|
|
1725
1730
|
* | {kind: 'topic', catalog: DocsCatalog, entry: import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry}
|
|
1726
1731
|
* | {kind: 'node', catalog: DocsCatalog, tree: import('../../foundation/doc-compiler/tree.mjs').DocsTree, node: import('../../foundation/doc-compiler/tree.mjs').TreeNode}
|
|
1727
1732
|
* | {kind: 'unknown', catalog: DocsCatalog}
|
|
1728
1733
|
* >}
|
|
1729
1734
|
*/
|
|
1730
|
-
export async function resolveDocsArgument(topic, {cwd} = {}) {
|
|
1731
|
-
const catalog = await loadDocsCatalog(cwd);
|
|
1735
|
+
export async function resolveDocsArgument(topic, {cwd} = {}, loaded) {
|
|
1736
|
+
const catalog = loaded ?? (await loadDocsCatalog(cwd));
|
|
1732
1737
|
if (typeof topic !== 'string' || topic === '')
|
|
1733
1738
|
return {kind: 'unknown', catalog};
|
|
1734
1739
|
const tree = await projectTree(catalog);
|
|
@@ -1942,13 +1947,14 @@ export function notLoaded(catalog) {
|
|
|
1942
1947
|
* and lower it for the topic readers.
|
|
1943
1948
|
* @param {unknown} topic
|
|
1944
1949
|
* @param {{lang?: string | null, zh?: boolean, dense?: boolean, cwd?: string}} [options]
|
|
1950
|
+
* @param {DocsCatalog} [loaded] internal, as {@link resolveDocsArgument}
|
|
1945
1951
|
*/
|
|
1946
|
-
export async function resolveTopicDocs(topic, options = {}) {
|
|
1952
|
+
export async function resolveTopicDocs(topic, options = {}, loaded) {
|
|
1947
1953
|
const {lang = null, zh = false, dense = false, cwd} = options;
|
|
1948
1954
|
const effectiveLang = lang || (dense ? 'dense' : zh ? 'zh' : null);
|
|
1949
1955
|
// A public API caller could pass a non-string topic; it lands on the same
|
|
1950
1956
|
// stable code as an unknown name rather than a raw TypeError.
|
|
1951
|
-
const found = await resolveDocsArgument(topic, {cwd});
|
|
1957
|
+
const found = await resolveDocsArgument(topic, {cwd}, loaded);
|
|
1952
1958
|
if (found.kind !== 'topic') {
|
|
1953
1959
|
throw found.kind === 'node'
|
|
1954
1960
|
? new AstryxError(
|
|
@@ -30,14 +30,17 @@ export function section(topic: string, sectionName: string, options?: {
|
|
|
30
30
|
* with the section its own section read returns for the query; when that
|
|
31
31
|
* section's key (its `id`, else the key its title derives) is the query in
|
|
32
32
|
* some guides, those guides answer first. No guide, or several, fail with ERR_UNKNOWN_SECTION, naming
|
|
33
|
-
* the guides to read instead.
|
|
33
|
+
* the guides to read instead. Every guide is read from `catalog`, the one the
|
|
34
|
+
* namespace read loaded, so the read loads the project once, not once per
|
|
35
|
+
* guide below the namespace.
|
|
36
|
+
* @param {import('../../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
|
|
34
37
|
* @param {import('../../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
|
|
35
38
|
* @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} namespace
|
|
36
39
|
* @param {string} sectionName
|
|
37
40
|
* @param {object} [options] as {@link section}
|
|
38
41
|
* @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
|
|
39
42
|
*/
|
|
40
|
-
export function namespaceSection(tree: import("../../../../foundation/doc-compiler/tree.mjs").DocsTree, namespace: import("../../../../foundation/doc-compiler/tree.mjs").TreeNode, sectionName: string, options?: object): Promise<import("../../docs.type.mjs").DocsDetailSectionResponse>;
|
|
43
|
+
export function namespaceSection(catalog: import("../../../../foundation/discovery/docs-discovery.mjs").DocsCatalog, tree: import("../../../../foundation/doc-compiler/tree.mjs").DocsTree, namespace: import("../../../../foundation/doc-compiler/tree.mjs").TreeNode, sectionName: string, options?: object): Promise<import("../../docs.type.mjs").DocsDetailSectionResponse>;
|
|
41
44
|
/**
|
|
42
45
|
* The guide a namespace section read answers from, or null to ask. When the
|
|
43
46
|
* query matches sections in several guides, the read asks the reader which
|
|
@@ -130,7 +130,10 @@ async function sectionResponse({catalog, node, lang, entry}, sections, match) {
|
|
|
130
130
|
* with the section its own section read returns for the query; when that
|
|
131
131
|
* section's key (its `id`, else the key its title derives) is the query in
|
|
132
132
|
* some guides, those guides answer first. No guide, or several, fail with ERR_UNKNOWN_SECTION, naming
|
|
133
|
-
* the guides to read instead.
|
|
133
|
+
* the guides to read instead. Every guide is read from `catalog`, the one the
|
|
134
|
+
* namespace read loaded, so the read loads the project once, not once per
|
|
135
|
+
* guide below the namespace.
|
|
136
|
+
* @param {import('../../../../foundation/discovery/docs-discovery.mjs').DocsCatalog} catalog
|
|
134
137
|
* @param {import('../../../../foundation/doc-compiler/tree.mjs').DocsTree} tree
|
|
135
138
|
* @param {import('../../../../foundation/doc-compiler/tree.mjs').TreeNode} namespace
|
|
136
139
|
* @param {string} sectionName
|
|
@@ -138,6 +141,7 @@ async function sectionResponse({catalog, node, lang, entry}, sections, match) {
|
|
|
138
141
|
* @returns {Promise<import('../../docs.type.mjs').DocsDetailSectionResponse>}
|
|
139
142
|
*/
|
|
140
143
|
export async function namespaceSection(
|
|
144
|
+
catalog,
|
|
141
145
|
tree,
|
|
142
146
|
namespace,
|
|
143
147
|
sectionName,
|
|
@@ -148,7 +152,7 @@ export async function namespaceSection(
|
|
|
148
152
|
/** @type {Omit<GuideMatch, 'match'>[]} */
|
|
149
153
|
const reads = [];
|
|
150
154
|
for (const guide of guides) {
|
|
151
|
-
const resolved = await resolveTopicDocs(guide.route, options);
|
|
155
|
+
const resolved = await resolveTopicDocs(guide.route, options, catalog);
|
|
152
156
|
reads.push({guide, resolved, sections: readerSections(resolved.node)});
|
|
153
157
|
}
|
|
154
158
|
|
package/api/docs/docs.mjs
CHANGED
|
@@ -155,7 +155,13 @@ async function docsRead(topic, section, options = {}) {
|
|
|
155
155
|
// A namespace answers a section read from the one guide below it that
|
|
156
156
|
// has the section (spec:AST-046 FR6). A typed doc is one read.
|
|
157
157
|
if (found.node.kind === 'namespace') {
|
|
158
|
-
return namespaceSection(
|
|
158
|
+
return namespaceSection(
|
|
159
|
+
found.catalog,
|
|
160
|
+
found.tree,
|
|
161
|
+
found.node,
|
|
162
|
+
section,
|
|
163
|
+
options,
|
|
164
|
+
);
|
|
159
165
|
}
|
|
160
166
|
throw new AstryxError(
|
|
161
167
|
`"${found.node.route}" has no sections. Read it whole: ${formatCliCommand(`docs ${found.node.route}`)}.`,
|
|
@@ -176,11 +176,15 @@ export function resolveBuiltPath(cwd: string, target: string): string | null;
|
|
|
176
176
|
* path relative to the folder (a file's own name when the path is one file),
|
|
177
177
|
* whether it sits in build output, and a reader that returns its text, or
|
|
178
178
|
* null when it cannot be read or is over 5 MB. Installs and version control
|
|
179
|
-
* are skipped; at most
|
|
179
|
+
* are skipped; at most `fileLimit` files are listed.
|
|
180
180
|
* @param {string} target an existing absolute path
|
|
181
|
+
* @param {{fileLimit?: number}} [options] `fileLimit`: BUILT_FILE_LIMIT
|
|
182
|
+
* unless the caller reads fewer
|
|
181
183
|
* @returns {{files: {rel: string, built: boolean, read: () => string | null}[], truncated: boolean, missing?: number}}
|
|
182
184
|
*/
|
|
183
|
-
export function readBuiltPath(target: string
|
|
185
|
+
export function readBuiltPath(target: string, { fileLimit }?: {
|
|
186
|
+
fileLimit?: number;
|
|
187
|
+
}): {
|
|
184
188
|
files: {
|
|
185
189
|
rel: string;
|
|
186
190
|
built: boolean;
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -468,11 +468,13 @@ export function resolveBuiltPath(cwd, target) {
|
|
|
468
468
|
* path relative to the folder (a file's own name when the path is one file),
|
|
469
469
|
* whether it sits in build output, and a reader that returns its text, or
|
|
470
470
|
* null when it cannot be read or is over 5 MB. Installs and version control
|
|
471
|
-
* are skipped; at most
|
|
471
|
+
* are skipped; at most `fileLimit` files are listed.
|
|
472
472
|
* @param {string} target an existing absolute path
|
|
473
|
+
* @param {{fileLimit?: number}} [options] `fileLimit`: BUILT_FILE_LIMIT
|
|
474
|
+
* unless the caller reads fewer
|
|
473
475
|
* @returns {{files: {rel: string, built: boolean, read: () => string | null}[], truncated: boolean, missing?: number}}
|
|
474
476
|
*/
|
|
475
|
-
export function readBuiltPath(target) {
|
|
477
|
+
export function readBuiltPath(target, {fileLimit = BUILT_FILE_LIMIT} = {}) {
|
|
476
478
|
/** @param {string} file */
|
|
477
479
|
const reader = file => () => {
|
|
478
480
|
try {
|
|
@@ -568,7 +570,7 @@ export function readBuiltPath(target) {
|
|
|
568
570
|
built: built || BUILD_OUTPUT_DIRS.has(entry.name),
|
|
569
571
|
});
|
|
570
572
|
} else if (entry.isFile()) {
|
|
571
|
-
if (files.length >=
|
|
573
|
+
if (files.length >= fileLimit) return {files, truncated: true};
|
|
572
574
|
files.push({
|
|
573
575
|
rel: path.relative(target, full).split(path.sep).join('/'),
|
|
574
576
|
built,
|
|
@@ -6,19 +6,24 @@
|
|
|
6
6
|
* @param {string} target an existing file or folder
|
|
7
7
|
* @param {readonly string[]} packages package names whose components count as
|
|
8
8
|
* Astryx, beside every `@astryxdesign/*` package
|
|
9
|
+
* @param {{fileLimit?: number}} [options] how many files to read at most
|
|
9
10
|
* @returns {BuiltScan}
|
|
10
11
|
*/
|
|
11
|
-
export function scanBuilt(target: string, packages: readonly string[]
|
|
12
|
+
export function scanBuilt(target: string, packages: readonly string[], { fileLimit }?: {
|
|
13
|
+
fileLimit?: number;
|
|
14
|
+
}): BuiltScan;
|
|
12
15
|
/**
|
|
13
16
|
* The two checks for a path.
|
|
14
17
|
* @param {string} target as the caller gave it
|
|
15
|
-
* @param {{cwd: string, packages: readonly string[]}} options
|
|
16
|
-
* integration packages whose components count as Astryx
|
|
18
|
+
* @param {{cwd: string, packages: readonly string[], fileLimit?: number}} options
|
|
19
|
+
* `packages`: the integration packages whose components count as Astryx.
|
|
20
|
+
* `fileLimit`: how many files to read at most (BUILT_FILE_LIMIT).
|
|
17
21
|
* @returns {import('./doctor.type.mjs').DoctorCheck[]}
|
|
18
22
|
*/
|
|
19
|
-
export function checkBuilt(target: string, { cwd, packages }: {
|
|
23
|
+
export function checkBuilt(target: string, { cwd, packages, fileLimit }: {
|
|
20
24
|
cwd: string;
|
|
21
25
|
packages: readonly string[];
|
|
26
|
+
fileLimit?: number;
|
|
22
27
|
}): import("./doctor.type.mjs").DoctorCheck[];
|
|
23
28
|
export type BuiltFinding = {
|
|
24
29
|
/**
|
|
@@ -560,10 +560,11 @@ function jsxFindings(text, rel, iconNames) {
|
|
|
560
560
|
* @param {string} target an existing file or folder
|
|
561
561
|
* @param {readonly string[]} packages package names whose components count as
|
|
562
562
|
* Astryx, beside every `@astryxdesign/*` package
|
|
563
|
+
* @param {{fileLimit?: number}} [options] how many files to read at most
|
|
563
564
|
* @returns {BuiltScan}
|
|
564
565
|
*/
|
|
565
|
-
export function scanBuilt(target, packages) {
|
|
566
|
-
const {files, truncated, missing = 0} = readBuiltPath(target);
|
|
566
|
+
export function scanBuilt(target, packages, {fileLimit} = {}) {
|
|
567
|
+
const {files, truncated, missing = 0} = readBuiltPath(target, {fileLimit});
|
|
567
568
|
/** @type {BuiltScan} */
|
|
568
569
|
const scan = {
|
|
569
570
|
sourceFiles: 0,
|
|
@@ -705,11 +706,15 @@ function plural(count, word) {
|
|
|
705
706
|
/**
|
|
706
707
|
* The two checks for a path.
|
|
707
708
|
* @param {string} target as the caller gave it
|
|
708
|
-
* @param {{cwd: string, packages: readonly string[]}} options
|
|
709
|
-
* integration packages whose components count as Astryx
|
|
709
|
+
* @param {{cwd: string, packages: readonly string[], fileLimit?: number}} options
|
|
710
|
+
* `packages`: the integration packages whose components count as Astryx.
|
|
711
|
+
* `fileLimit`: how many files to read at most (BUILT_FILE_LIMIT).
|
|
710
712
|
* @returns {import('./doctor.type.mjs').DoctorCheck[]}
|
|
711
713
|
*/
|
|
712
|
-
export function checkBuilt(
|
|
714
|
+
export function checkBuilt(
|
|
715
|
+
target,
|
|
716
|
+
{cwd, packages, fileLimit = BUILT_FILE_LIMIT},
|
|
717
|
+
) {
|
|
713
718
|
const resolved = resolveBuiltPath(cwd, target);
|
|
714
719
|
if (resolved == null) {
|
|
715
720
|
return [
|
|
@@ -722,10 +727,10 @@ export function checkBuilt(target, {cwd, packages}) {
|
|
|
722
727
|
},
|
|
723
728
|
];
|
|
724
729
|
}
|
|
725
|
-
const scan = scanBuilt(resolved, packages);
|
|
730
|
+
const scan = scanBuilt(resolved, packages, {fileLimit});
|
|
726
731
|
const used =
|
|
727
732
|
scan.imports > 0 || scan.componentUses > 0 || scan.stylesheets.length > 0;
|
|
728
|
-
const read = `${plural(scan.sourceFiles, 'source file')} and ${plural(scan.builtFiles, 'built file')}${scan.truncated ? ` (the first ${
|
|
733
|
+
const read = `${plural(scan.sourceFiles, 'source file')} and ${plural(scan.builtFiles, 'built file')}${scan.truncated ? ` (the first ${fileLimit} files)` : ''}`;
|
|
729
734
|
const evidence = [
|
|
730
735
|
scan.imports > 0
|
|
731
736
|
? `${plural(scan.imports, 'import')} from ${scan.packages.join(', ')} in ${plural(scan.importFiles, 'file')}`
|
|
@@ -761,7 +766,7 @@ export function checkBuilt(target, {cwd, packages}) {
|
|
|
761
766
|
id: 'built-astryx-usage',
|
|
762
767
|
label: 'Built output uses Astryx',
|
|
763
768
|
status: 'warn',
|
|
764
|
-
message: `Read ${read} and found no Astryx in them, but ${[scan.truncated ? `the rest past the first ${
|
|
769
|
+
message: `Read ${read} and found no Astryx in them, but ${[scan.truncated ? `the rest past the first ${fileLimit} files` : null, scan.unread > 0 ? `${plural(scan.unread, 'source file')} over ${BUILT_FILE_MAX_MB} MB, unreadable or unparsed` : null, scan.missingLinks > 0 ? `${plural(scan.missingLinks, 'file')} the page links but that are not there` : null].filter(Boolean).join(' and ')} went unread, so this does not show whether the output uses Astryx.`,
|
|
765
770
|
fix: `Run \`${formatCliCommand('doctor --built <folder>', cwd)}\` on the folder that holds the page itself, or on its build output.`,
|
|
766
771
|
}
|
|
767
772
|
: {
|
|
@@ -798,7 +803,7 @@ export function checkBuilt(target, {cwd, packages}) {
|
|
|
798
803
|
id: 'built-astryx-purity',
|
|
799
804
|
label: 'Source uses Astryx well',
|
|
800
805
|
status: 'info',
|
|
801
|
-
message: `Not fully inspected: ${plural(scan.jsxFiles, 'source file')} with JSX had no finding${scan.truncated ? `, but only the first ${
|
|
806
|
+
message: `Not fully inspected: ${plural(scan.jsxFiles, 'source file')} with JSX had no finding${scan.truncated ? `, but only the first ${fileLimit} files were read` : ''}.${unreadNote}`,
|
|
802
807
|
fix: `Run \`${formatCliCommand('doctor --built <folder>', cwd)}\` on the folder that holds the page's own source.`,
|
|
803
808
|
};
|
|
804
809
|
} else if (scan.findings.length === 0) {
|
|
@@ -829,7 +834,7 @@ export function checkBuilt(target, {cwd, packages}) {
|
|
|
829
834
|
id: 'built-astryx-purity',
|
|
830
835
|
label: 'Source uses Astryx well',
|
|
831
836
|
status: 'warn',
|
|
832
|
-
message: `${plural(scan.findings.length, 'finding')} (${counts}): ${shown}${more}.${unreadNote}${scan.truncated ? ` Only the first ${
|
|
837
|
+
message: `${plural(scan.findings.length, 'finding')} (${counts}): ${shown}${more}.${unreadNote}${scan.truncated ? ` Only the first ${fileLimit} files were read.` : ''}`,
|
|
833
838
|
fix: `Replace each with the Astryx component, icon surface, prop or token it names; \`${formatCliCommand('docs is-my-code-good', cwd)}\` has the full rubric. Keep a raw element only where its native meaning is needed.`,
|
|
834
839
|
};
|
|
835
840
|
}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export function requireSearchCoreDir(cwd: string): string;
|
|
13
13
|
/**
|
|
14
|
-
* Gathers every candidate the query's domains hold.
|
|
14
|
+
* Gathers every candidate the query's domains hold. The gather runs in one
|
|
15
|
+
* listing-cache operation, so its discovery helpers list each folder once, as
|
|
16
|
+
* in the CLI's searches. A caller that runs its own operation shares it.
|
|
15
17
|
*
|
|
16
18
|
* @param {{cwd?: string, type?: string}} options
|
|
17
19
|
* @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null}>}
|
package/api/search/_adapter.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import {readFileSync} from 'node:fs';
|
|
10
10
|
import * as path from 'node:path';
|
|
11
11
|
import {requireCoreDir} from '../../foundation/fs/paths.mjs';
|
|
12
|
+
import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
12
13
|
import {
|
|
13
14
|
reusedWhileUnchanged,
|
|
14
15
|
unchangedSince,
|
|
@@ -37,12 +38,21 @@ export function requireSearchCoreDir(cwd) {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
|
-
* Gathers every candidate the query's domains hold.
|
|
41
|
+
* Gathers every candidate the query's domains hold. The gather runs in one
|
|
42
|
+
* listing-cache operation, so its discovery helpers list each folder once, as
|
|
43
|
+
* in the CLI's searches. A caller that runs its own operation shares it.
|
|
41
44
|
*
|
|
42
45
|
* @param {{cwd?: string, type?: string}} options
|
|
43
46
|
* @returns {Promise<{all: Candidate[], components: Candidate[], searchedComponents: boolean, outside: boolean, coreSkipped: string | null}>}
|
|
44
47
|
*/
|
|
45
|
-
export
|
|
48
|
+
export function gatherCandidates(options) {
|
|
49
|
+
return withListingCache(() => gatherDomains(options));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {{cwd?: string, type?: string}} options
|
|
54
|
+
*/
|
|
55
|
+
async function gatherDomains(options) {
|
|
46
56
|
const {cwd = process.cwd(), type} = options;
|
|
47
57
|
// `astryx docs` reads docs without @astryxdesign/core, and `astryx theme
|
|
48
58
|
// list` reads themes without it (bundled themes need no project), so a
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* also matches typed as words: `command palette` is CommandPalette.
|
|
15
15
|
* @param {string[]} [candidate.keywords] - Authored intent (componentsUsed, category words).
|
|
16
16
|
* @param {string[]} [candidate.weakKeywords] - Derived signal (components a page renders).
|
|
17
|
+
* @param {string[]} [candidate.weakKeywordBound] - Every name `weakKeywords`
|
|
18
|
+
* can hold, when reading them is costly: they are read only if one matches.
|
|
17
19
|
* @param {string} [candidate.description]
|
|
18
20
|
* @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
|
|
19
21
|
* @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
|
|
@@ -23,12 +25,13 @@
|
|
|
23
25
|
* @returns {{score: number, reason: string, alias?: 'partial' | 'keyword'} | null}
|
|
24
26
|
* `alias` marks a hit that read the query's words joined.
|
|
25
27
|
*/
|
|
26
|
-
export function scoreCandidate(term: string,
|
|
28
|
+
export function scoreCandidate(term: string, candidate: {
|
|
27
29
|
name: string;
|
|
28
30
|
aliases?: string[] | undefined;
|
|
29
31
|
domain?: string | undefined;
|
|
30
32
|
keywords?: string[] | undefined;
|
|
31
33
|
weakKeywords?: string[] | undefined;
|
|
34
|
+
weakKeywordBound?: string[] | undefined;
|
|
32
35
|
description?: string | undefined;
|
|
33
36
|
prose?: string[] | undefined;
|
|
34
37
|
guidance?: string[] | undefined;
|
|
@@ -94,6 +94,19 @@ function headOfLetters(term, name) {
|
|
|
94
94
|
/** How many of a family's members a query naming the family lists. */
|
|
95
95
|
const FAMILY_MEMBERS = 3;
|
|
96
96
|
|
|
97
|
+
/**
|
|
98
|
+
* A derived name's score for a term: 60 for the same word, 40 for a word the
|
|
99
|
+
* term starts, else 0.
|
|
100
|
+
* @param {string} term - Lowercased search term.
|
|
101
|
+
* @param {string} kw - The derived name as authored.
|
|
102
|
+
* @returns {number}
|
|
103
|
+
*/
|
|
104
|
+
function weakKeywordScore(term, kw) {
|
|
105
|
+
const kwLower = String(kw).toLowerCase();
|
|
106
|
+
if (kwLower === term || sameWord(term, kwLower)) return 60;
|
|
107
|
+
return startsAWordOf(term, kw) ? 40 : 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
97
110
|
/**
|
|
98
111
|
* Score a single candidate against the search term across name, keywords,
|
|
99
112
|
* and prose signals. Returns the best (highest) score plus a human reason,
|
|
@@ -107,6 +120,8 @@ const FAMILY_MEMBERS = 3;
|
|
|
107
120
|
* also matches typed as words: `command palette` is CommandPalette.
|
|
108
121
|
* @param {string[]} [candidate.keywords] - Authored intent (componentsUsed, category words).
|
|
109
122
|
* @param {string[]} [candidate.weakKeywords] - Derived signal (components a page renders).
|
|
123
|
+
* @param {string[]} [candidate.weakKeywordBound] - Every name `weakKeywords`
|
|
124
|
+
* can hold, when reading them is costly: they are read only if one matches.
|
|
110
125
|
* @param {string} [candidate.description]
|
|
111
126
|
* @param {string[]} [candidate.prose] - Extra free-text blobs (doc section text, best practices).
|
|
112
127
|
* @param {string[]} [candidate.guidance] - Usage guidance (features, best practices) — scored a tier below description.
|
|
@@ -118,20 +133,20 @@ const FAMILY_MEMBERS = 3;
|
|
|
118
133
|
*/
|
|
119
134
|
export function scoreCandidate(
|
|
120
135
|
term,
|
|
121
|
-
|
|
136
|
+
candidate,
|
|
137
|
+
{fuzzy = true, joins = true, part = false, synonym = false} = {},
|
|
138
|
+
) {
|
|
139
|
+
const {
|
|
122
140
|
name,
|
|
123
141
|
aliases = [],
|
|
124
142
|
domain,
|
|
125
143
|
keywords = [],
|
|
126
|
-
weakKeywords = [],
|
|
127
144
|
description = '',
|
|
128
145
|
prose = [],
|
|
129
146
|
guidance = [],
|
|
130
147
|
_family,
|
|
131
148
|
_familyIndex,
|
|
132
|
-
}
|
|
133
|
-
{fuzzy = true, joins = true, part = false, synonym = false} = {},
|
|
134
|
-
) {
|
|
149
|
+
} = candidate;
|
|
135
150
|
let best = 0;
|
|
136
151
|
let reason = '';
|
|
137
152
|
/** @type {'partial' | 'keyword' | false} */
|
|
@@ -277,13 +292,14 @@ export function scoreCandidate(
|
|
|
277
292
|
// confident-match gate on its own; it still counts toward multi-term
|
|
278
293
|
// coverage, which is where "this page renders that" is real evidence.
|
|
279
294
|
// No Levenshtein tier — fuzzy matching a derived signal is pure noise.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
295
|
+
// A bound skips the read when no name the page can yield matches the term,
|
|
296
|
+
// and then no weak keyword can match it either.
|
|
297
|
+
const bound = candidate.weakKeywordBound;
|
|
298
|
+
if (!bound || bound.some(kw => weakKeywordScore(term, kw) > 0)) {
|
|
299
|
+
for (const kw of candidate.weakKeywords ?? []) {
|
|
300
|
+
const score = weakKeywordScore(term, kw);
|
|
301
|
+
if (score > 0) consider(score, `renders ${kw}`);
|
|
285
302
|
}
|
|
286
|
-
if (startsAWordOf(term, kw)) consider(40, `renders ${kw}`);
|
|
287
303
|
}
|
|
288
304
|
|
|
289
305
|
// ── Prose / description / guidance signals (stem-tolerant whole word) ──
|