@astryxdesign/cli 0.7.17-canary.gcfcba64 → 0.7.17-canary.gd15407f
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/_adapter.d.mts +7 -0
- package/api/build/_adapter.mjs +2 -0
- package/api/build/build.doc.mjs +2 -2
- package/api/build/build.type.d.mts +2 -2
- package/api/build/build.type.mjs +3 -3
- package/api/build/kit/kind.d.mts +2 -1
- package/api/build/kit/kind.mjs +116 -9
- package/api/build/kit/kit.mjs +6 -4
- package/api/build/kit/rank.d.mts +4 -2
- package/api/build/kit/rank.mjs +66 -12
- package/api/build/kit/start.d.mts +5 -4
- package/api/build/kit/start.mjs +12 -8
- package/api/build/kit/weights.d.mts +23 -0
- package/api/build/kit/weights.mjs +130 -49
- package/api/component/list/list.mjs +2 -1
- package/api/discover/search/search.mjs +3 -2
- package/api/docs/_adapter.d.mts +2 -0
- package/api/docs/_adapter.mjs +32 -5
- package/api/doctor/_adapter.mjs +6 -4
- package/api/doctor/built-checks.mjs +2 -1
- package/api/doctor/doctor.mjs +1 -1
- package/api/icon/_records.mjs +2 -1
- package/api/integration/authoring-checks.mjs +6 -6
- package/api/integration/validate-integration.mjs +2 -1
- package/api/render/_adapter.mjs +90 -17
- package/api/render/render.doc.mjs +1 -1
- package/api/render/render.type.d.mts +23 -1
- package/api/render/render.type.mjs +12 -1
- package/api/search/_adapter.d.mts +9 -0
- package/api/search/_adapter.mjs +85 -0
- package/api/search/_gather-components.d.mts +3 -2
- package/api/search/_gather-components.mjs +12 -3
- package/api/search/_lexical.d.mts +5 -0
- package/api/search/_lexical.mjs +8 -2
- package/api/search/_result.d.mts +6 -4
- package/api/search/_result.mjs +4 -4
- package/api/search/search-index.mjs +7 -1
- package/api/theme/_adapter.mjs +2 -1
- package/api/theme/build/build.d.mts +85 -1
- package/api/theme/build/build.mjs +337 -134
- package/api/theme/build/core-interception.d.mts +10 -0
- package/api/theme/build/core-interception.mjs +10 -0
- package/api/theme/build/font-warning.d.mts +44 -5
- package/api/theme/build/font-warning.mjs +118 -10
- package/api/theme/build/icon-imports.mjs +51 -9
- package/api/theme-edit/_adapter.d.mts +71 -8
- package/api/theme-edit/_adapter.mjs +463 -182
- package/api/theme-edit/_catalog.d.mts +20 -2
- package/api/theme-edit/_catalog.mjs +50 -10
- package/api/theme-edit/_check.d.mts +47 -2
- package/api/theme-edit/_check.mjs +1328 -307
- package/api/theme-edit/_color.d.mts +1 -0
- package/api/theme-edit/_color.mjs +13 -0
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +124 -15
- package/api/theme-edit/_context.d.mts +14 -3
- package/api/theme-edit/_context.mjs +167 -64
- package/api/theme-edit/_css.d.mts +14 -0
- package/api/theme-edit/_css.mjs +25 -0
- package/api/theme-edit/_edit.d.mts +38 -10
- package/api/theme-edit/_edit.mjs +2024 -452
- package/api/theme-edit/_how-commands.d.mts +15 -1
- package/api/theme-edit/_how-commands.mjs +260 -34
- package/api/theme-edit/_how-question.d.mts +19 -7
- package/api/theme-edit/_how-question.mjs +2675 -569
- package/api/theme-edit/_how.d.mts +2 -1
- package/api/theme-edit/_how.mjs +134 -38
- package/api/theme-edit/_importers.d.mts +38 -0
- package/api/theme-edit/_importers.mjs +188 -0
- package/api/theme-edit/_name-rule.d.mts +11 -0
- package/api/theme-edit/_name-rule.mjs +12 -0
- package/api/theme-edit/_normal.d.mts +163 -13
- package/api/theme-edit/_normal.mjs +917 -61
- package/api/theme-edit/_palette.d.mts +12 -0
- package/api/theme-edit/_palette.mjs +27 -0
- package/api/theme-edit/_part-words.d.mts +31 -0
- package/api/theme-edit/_part-words.mjs +126 -0
- package/api/theme-edit/_parts.d.mts +21 -3
- package/api/theme-edit/_parts.mjs +167 -32
- package/api/theme-edit/_preview-app.d.mts +0 -12
- package/api/theme-edit/_preview-app.mjs +615 -395
- package/api/theme-edit/_preview.d.mts +60 -16
- package/api/theme-edit/_preview.mjs +337 -198
- package/api/theme-edit/_project.d.mts +22 -1
- package/api/theme-edit/_project.mjs +83 -3
- package/api/theme-edit/_settings.d.mts +325 -71
- package/api/theme-edit/_settings.mjs +1850 -599
- package/api/theme-edit/_tables.d.mts +18 -3
- package/api/theme-edit/_tables.mjs +74 -11
- package/api/theme-edit/_vet.d.mts +31 -0
- package/api/theme-edit/_vet.mjs +114 -8
- package/api/theme-edit/theme-edit.type.d.mts +6 -1
- package/api/theme-edit/theme-edit.type.mjs +2 -2
- package/api/theme-edit/themeEditHow.doc.mjs +1 -1
- package/api/theme-edit/themeEditNew.doc.d.mts +0 -1
- package/api/theme-edit/themeEditNew.doc.mjs +7 -4
- package/api/theme-edit/themeEditPreviewRemove.doc.mjs +2 -2
- package/api/upgrade/run/run.mjs +4 -3
- package/assets/codemods/integration-discovery.mjs +2 -1
- package/assets/component-list.generated.json +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/render-pages.doc.mjs +2 -2
- package/assets/docs/tree/share-a-page.doc.mjs +157 -0
- package/assets/docs.generated.json +2 -2
- package/assets/search-catalog.generated.json +2 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Hooks/useContainerRevealHookUsage.tsx +2 -2
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +3 -0
- package/assets/theme.template.ts +6 -0
- package/authoring/doctypes/component/categories.d.mts +37 -0
- package/authoring/doctypes/component/categories.mjs +54 -0
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.mjs +2 -1
- package/clients/cli/commands/experimental/render.mjs +10 -0
- package/clients/cli/commands/experimental/theme.mjs +508 -105
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-how.doc.mjs +87 -1
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +10 -3
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-remove.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-preview.doc.mjs +2 -1
- package/clients/cli/commands/experimental-theme.doc.mjs +5 -1
- package/clients/cli/commands/theme.mjs +687 -555
- package/clients/cli/lib/cli-error.mjs +2 -1
- package/clients/cli/lib/json-shim.mjs +132 -24
- package/clients/cli/lib/manifest.mjs +3 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/discovery/component-discovery.mjs +5 -4
- package/foundation/discovery/copied-passages.mjs +2 -1
- package/foundation/discovery/core-component-docs.d.mts +29 -0
- package/foundation/discovery/core-component-docs.mjs +83 -0
- package/foundation/discovery/doc-types.mjs +4 -3
- package/foundation/discovery/hook-discovery.mjs +2 -1
- package/foundation/discovery/icon-definition-discovery.mjs +2 -1
- package/foundation/discovery/icon-set-checks.mjs +2 -1
- package/foundation/discovery/icon-set-discovery.mjs +2 -1
- package/foundation/discovery/integration-doc-files.mjs +2 -1
- package/foundation/discovery/prop-drift.mjs +9 -9
- package/foundation/discovery/stored-search-catalog.d.mts +115 -0
- package/foundation/discovery/stored-search-catalog.mjs +297 -0
- package/foundation/discovery/template-adapter.d.mts +1 -1
- package/foundation/discovery/template-adapter.mjs +3 -2
- package/foundation/discovery/template-icons.mjs +2 -1
- package/foundation/discovery/theme-discovery.mjs +31 -4
- package/foundation/discovery/theming-targets.d.mts +6 -5
- package/foundation/discovery/theming-targets.mjs +31 -47
- package/foundation/doc-compiler/inputs.mjs +3 -2
- package/foundation/env/semver.mjs +3 -1
- package/foundation/fonts/font-stylesheet.d.mts +38 -0
- package/foundation/fonts/font-stylesheet.mjs +141 -0
- package/foundation/fs/exact-codec.d.mts +12 -2
- package/foundation/fs/exact-codec.mjs +23 -6
- package/foundation/fs/file-protection.mjs +4 -3
- package/foundation/fs/gather-cache.d.mts +37 -0
- package/foundation/fs/gather-cache.mjs +357 -41
- package/foundation/fs/module-loader.d.mts +6 -0
- package/foundation/fs/module-loader.mjs +2 -1
- package/foundation/fs/paths.d.mts +18 -0
- package/foundation/fs/paths.mjs +15 -2
- package/foundation/fs/read-record.d.mts +9 -0
- package/foundation/fs/read-record.mjs +19 -11
- package/foundation/fs/stop-cleanup.d.mts +12 -0
- package/foundation/fs/stop-cleanup.mjs +66 -0
- package/foundation/integrations/contribution-inventory.mjs +4 -3
- package/foundation/integrations/public-imports.mjs +2 -1
- package/foundation/render/embedded-files.mjs +17 -4
- package/foundation/render/embedded-imports.d.mts +25 -3
- package/foundation/render/embedded-imports.mjs +42 -6
- package/foundation/render/file-header.d.mts +2 -2
- package/foundation/render/file-header.mjs +1 -1
- package/foundation/render/markup-edits.d.mts +1 -1
- package/foundation/render/markup-edits.mjs +1 -1
- package/foundation/render/page-worker.mjs +38 -0
- package/foundation/render/picture-chrome.d.mts +4 -0
- package/foundation/render/picture-chrome.mjs +185 -0
- package/foundation/render/picture-playwright.d.mts +4 -0
- package/foundation/render/picture-playwright.mjs +34 -0
- package/foundation/render/rebuild.mjs +2 -1
- package/foundation/render/render-page.mjs +383 -91
- package/foundation/render/source-block.d.mts +6 -2
- package/foundation/render/source-block.mjs +31 -9
- package/foundation/render/ts-paths.d.mts +21 -5
- package/foundation/render/ts-paths.mjs +56 -15
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/compare-text.d.mts +14 -0
- package/foundation/text/compare-text.mjs +68 -0
- package/foundation/text/css-escape.d.mts +18 -0
- package/foundation/text/css-escape.mjs +35 -0
- package/foundation/text/string-utils.mjs +2 -1
- package/foundation/text/suggest-order.mjs +2 -1
- package/foundation/xle/expand.mjs +2 -1
- package/package.json +6 -6
package/api/build/_adapter.d.mts
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* @typedef {object} ComponentWords
|
|
20
20
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
21
21
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
22
|
+
* @property {string} [category] The category its own doc files it under,
|
|
23
|
+
* e.g. `Table & List`.
|
|
22
24
|
*/
|
|
23
25
|
/**
|
|
24
26
|
* Every ready page template the project can scaffold, in discovery order. This
|
|
@@ -176,6 +178,11 @@ export type ComponentWords = {
|
|
|
176
178
|
* The keywords its own doc declares.
|
|
177
179
|
*/
|
|
178
180
|
keywords: string[];
|
|
181
|
+
/**
|
|
182
|
+
* The category its own doc files it under,
|
|
183
|
+
* e.g. `Table & List`.
|
|
184
|
+
*/
|
|
185
|
+
category?: string | undefined;
|
|
179
186
|
};
|
|
180
187
|
/**
|
|
181
188
|
* A block the kit can name, as search names a block result.
|
package/api/build/_adapter.mjs
CHANGED
|
@@ -57,6 +57,8 @@ export {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
|
57
57
|
* @typedef {object} ComponentWords
|
|
58
58
|
* @property {string} name The component's name, e.g. `DateRangeInput`.
|
|
59
59
|
* @property {string[]} keywords The keywords its own doc declares.
|
|
60
|
+
* @property {string} [category] The category its own doc files it under,
|
|
61
|
+
* e.g. `Table & List`.
|
|
60
62
|
*/
|
|
61
63
|
|
|
62
64
|
/**
|
package/api/build/build.doc.mjs
CHANGED
|
@@ -19,7 +19,7 @@ export const doc = {
|
|
|
19
19
|
'The "build a page" entry point. Called with no query it returns the ' +
|
|
20
20
|
'how-to-build-a-page playbook as data: the workflow steps with their ' +
|
|
21
21
|
'commands, the on-system rules, and related lookups. Called with a query it names the page template to ' +
|
|
22
|
-
|
|
22
|
+
"START from (always one: for a whole page, the template its page-pick model chooses from the page ranker's list and its own word tables, or the app shell when its word weights call the shell; for a part " +
|
|
23
23
|
'of a page, the page it names; else the app shell, unless the idea reads as a whole page, which starts ' +
|
|
24
24
|
'from the closest page template) and the next two templates, ' +
|
|
25
25
|
'and the unified search grouped around it: the other close page templates, drop-in blocks, and ' +
|
|
@@ -65,7 +65,7 @@ export const doc = {
|
|
|
65
65
|
{
|
|
66
66
|
type: 'build.kit',
|
|
67
67
|
description:
|
|
68
|
-
|
|
68
|
+
'The page template to start from and the kit around it: the echoed query, hasResults/matchCount/directMatch fields, `start` (the template to scaffold, the `template <id> --type page <path>` command that selects it, whether the start is also search\'s direct match, the closest page, or the fallback app shell, the next two `alternatives` in the order the start is chosen from, and optional `notes` — setup notes naming what the template needs that the project lacks, such as missing packages or a missing StyleX compiler), search\'s closest page templates (≤3), drop-in block patterns (≤5), idea-specific components/hooks (≤6), and the always-on frame + foundation component-name arrays. Carries `hint` only when the kit came back thin — what to try instead, so a caller does not read a near-empty kit as "the package has nothing".',
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
71
|
throws: [
|
|
@@ -69,7 +69,7 @@ export type BuildStart = {
|
|
|
69
69
|
*/
|
|
70
70
|
command: string;
|
|
71
71
|
/**
|
|
72
|
-
* Why this template. The page ranker
|
|
72
|
+
* Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
|
|
73
73
|
*/
|
|
74
74
|
basis: "direct" | "closest" | "fallback";
|
|
75
75
|
/**
|
|
@@ -77,7 +77,7 @@ export type BuildStart = {
|
|
|
77
77
|
*/
|
|
78
78
|
reason: string;
|
|
79
79
|
/**
|
|
80
|
-
* The
|
|
80
|
+
* The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
|
|
81
81
|
*/
|
|
82
82
|
alternatives: BuildAlternative[];
|
|
83
83
|
/**
|
package/api/build/build.type.mjs
CHANGED
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
* @property {string} description What the page is: its layout and the ideas it serves.
|
|
45
45
|
* @property {string} package The npm package that owns this template.
|
|
46
46
|
* @property {string} command The scaffold command that selects exactly this template, `astryx template <id> --type page <path>`: `<id>` is the Core id an integration replacement stands in for, else the template's own id, `<path>` is a placeholder for the file or folder to write the template to, and the `astryx` prefix is for the caller to replace with its own invocation.
|
|
47
|
-
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker
|
|
47
|
+
* @property {'direct' | 'closest' | 'fallback'} basis Why this template. The page ranker orders the page templates: it weighs each matched word by how rare it is among page templates, favors the family the idea's head names and the container it names ("in a modal"), and discounts words that only modify another. For a part or an edit, the start is where the ranker's placement rules put it; for a whole page, checked-in word weights decide page or app shell and a page-pick model chooses the page from the ranker's list and its own word tables, so the start can differ from the ranker's first template. `direct` when the start is also search's direct match (`directMatch`); `closest` when it is not; `fallback` when the page starts from the app shell.
|
|
48
48
|
* @property {string} reason One sentence saying the same as `basis`, for a reader.
|
|
49
|
-
* @property {BuildAlternative[]} alternatives The
|
|
49
|
+
* @property {BuildAlternative[]} alternatives The next closest page templates (≤2), for when the start's layout is wrong: for a whole page in the page-pick model's order, else in the ranker's.
|
|
50
50
|
* @property {string[]} [notes] Setup notes: what the template needs that the project lacks (missing packages, missing StyleX compiler). Present only when the start template imports packages the project does not have or needs a StyleX compiler the project has not configured.
|
|
51
51
|
*/
|
|
52
52
|
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
* @property {boolean} data.hasResults False when search returned nothing. The kit still names a template in `start`.
|
|
76
76
|
* @property {number} data.matchCount Total ranked search matches for the query — counted before the search `limit`, the kit's score floors, and its per-group caps, so it is never a cap read back.
|
|
77
77
|
* @property {boolean} data.directMatch True when the top page template is a confident direct match.
|
|
78
|
-
* @property {BuildStart | null} data.start The page template to start from
|
|
78
|
+
* @property {BuildStart | null} data.start The page template to start from (see `BuildStart.basis`), else the app shell. Null only when the kit is narrowed to components or hooks (`type`), or when the project has no page template to offer.
|
|
79
79
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.pages Closest page templates by search (≤3). Each entry's `command` carries `--skeleton` when `directMatch` is false, so it previews the layout; `start.command` is the scaffold.
|
|
80
80
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.blocks Drop-in block patterns covering parts of the idea (≤5), best first. A block search returned keeps search's score and reason; any other block carries the block picker's relative score (100 for its best candidate, never below 1) and reason, so the two kinds of score are not comparable.
|
|
81
81
|
* @property {import('../search/search.type.mjs').SearchResultEntry[]} data.domain Idea-specific components/hooks (≤6), excluding frame/foundation.
|
package/api/build/kit/kind.d.mts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
/**
|
|
5
5
|
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
6
6
|
* when its head noun names one of the system's components and it lists fewer
|
|
7
|
-
* than PAGE_PIECES pieces; or an `edit` of a
|
|
7
|
+
* than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
|
|
8
|
+
* page the builder already has.
|
|
8
9
|
*
|
|
9
10
|
* @param {string} query
|
|
10
11
|
* @param {PageTemplate[]} pages
|
package/api/build/kit/kind.mjs
CHANGED
|
@@ -8,7 +8,10 @@
|
|
|
8
8
|
* not a page, and the system's own components say what a part is: an idea
|
|
9
9
|
* whose head noun is a word of a component's name or keywords, Core's or an
|
|
10
10
|
* integration's, asks for that part, unless the noun is a family word ("a data
|
|
11
|
-
* table") or the idea lists a page's worth of pieces.
|
|
11
|
+
* table") or the idea lists a page's worth of pieces. A component named with
|
|
12
|
+
* its listed contents ("a side panel with an owner, a status, and a history")
|
|
13
|
+
* is still one part, unless the component holds records: its category declares
|
|
14
|
+
* a page family (a list, a table). Words search drops as
|
|
12
15
|
* stopwords ("page", "screen", "app", "view") name no component, so "a calendar
|
|
13
16
|
* page" asks for a page and "a calendar" for a part. A part starts from the
|
|
14
17
|
* base template of the family the idea names ("an empty state for a settings
|
|
@@ -26,6 +29,7 @@
|
|
|
26
29
|
* new dashboard").
|
|
27
30
|
*/
|
|
28
31
|
|
|
32
|
+
import {COMPONENT_CATEGORIES} from '../../../authoring/doctypes/component/categories.mjs';
|
|
29
33
|
import {stem} from '../../search/search.mjs';
|
|
30
34
|
import {
|
|
31
35
|
HEAD_END,
|
|
@@ -46,7 +50,7 @@ import {
|
|
|
46
50
|
/**
|
|
47
51
|
* How many listed pieces make an idea a page: a part is one thing with a detail
|
|
48
52
|
* or two ("a status pill with a tooltip"), while three pieces, two commas
|
|
49
|
-
* apart, describe a page.
|
|
53
|
+
* apart, describe a page, unless they are one component's contents.
|
|
50
54
|
*/
|
|
51
55
|
const PAGE_PIECES = 3;
|
|
52
56
|
|
|
@@ -71,7 +75,8 @@ const NEW = /\bnew\b/;
|
|
|
71
75
|
/**
|
|
72
76
|
* What an idea asks for (spec:AST-048/FR3): a whole `page`; a `part` of one,
|
|
73
77
|
* when its head noun names one of the system's components and it lists fewer
|
|
74
|
-
* than PAGE_PIECES pieces; or an `edit` of a
|
|
78
|
+
* than PAGE_PIECES pieces or only that component's contents; or an `edit` of a
|
|
79
|
+
* page the builder already has.
|
|
75
80
|
*
|
|
76
81
|
* @param {string} query
|
|
77
82
|
* @param {PageTemplate[]} pages
|
|
@@ -87,21 +92,123 @@ export function ideaKind(query, pages, components) {
|
|
|
87
92
|
// calendar", "page" the noun of "a calendar page". An overlay frame names
|
|
88
93
|
// where the thing lives, not the thing: "drafts" is the noun of "drafts in
|
|
89
94
|
// a modal".
|
|
90
|
-
const
|
|
95
|
+
const rawHead = text.split(HEAD_END)[0] ?? '';
|
|
96
|
+
const head = rawHead.replace(CONTAINER_PHRASE, m =>
|
|
91
97
|
containersOf(m).size > 0 ? ' ' : m,
|
|
92
98
|
);
|
|
93
|
-
const
|
|
94
|
-
w => w.length >= 2,
|
|
95
|
-
);
|
|
96
|
-
const noun = stem(words[words.length - 1] ?? '');
|
|
99
|
+
const noun = lastNoun(head);
|
|
97
100
|
if (familyWords.has(noun)) return 'page';
|
|
101
|
+
const holdsRecords = (/** @type {string} */ word) =>
|
|
102
|
+
namedComponents(word, components).some(c => namesFamily(c, familyWords));
|
|
103
|
+
if (
|
|
104
|
+
describesOnePart(text, rawHead, noun, familyWords, components) &&
|
|
105
|
+
!holdsRecords(noun)
|
|
106
|
+
)
|
|
107
|
+
return 'part';
|
|
98
108
|
const pieces = (text.match(/,/g) ?? []).length + 1;
|
|
99
109
|
if (pieces >= PAGE_PIECES) return 'page';
|
|
100
|
-
|
|
110
|
+
const namesPart = (/** @type {string} */ word) =>
|
|
111
|
+
components.some(c => componentTerms(c).includes(word));
|
|
112
|
+
if (!namesPart(noun)) return 'page';
|
|
113
|
+
// A component that holds records, followed by "of", is a page of those
|
|
114
|
+
// records ("a list of jobs"), unless what follows names a component ("a list
|
|
115
|
+
// of buttons") or a page family ("a list of settings toggles").
|
|
116
|
+
if (!holdsRecords(noun) || !endsOnOf(text)) return 'part';
|
|
117
|
+
const phrase = madeOf(text);
|
|
118
|
+
return terms(phrase).some(t => familyWords.has(t)) ||
|
|
119
|
+
namesPart(lastNoun(phrase))
|
|
101
120
|
? 'part'
|
|
102
121
|
: 'page';
|
|
103
122
|
}
|
|
104
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Whether an idea describes one part and its contents: its head names a
|
|
126
|
+
* component by name and ends on a word ("a side panel with a, b and c"), not
|
|
127
|
+
* on a comma or a colon that starts a list of peers, and no word of the idea
|
|
128
|
+
* names a page family. Such an idea is a part however many pieces it lists.
|
|
129
|
+
* @param {string} text
|
|
130
|
+
* @param {string} head the idea's head, before any frame is removed
|
|
131
|
+
* @param {string} noun
|
|
132
|
+
* @param {Map<string, string>} familyWords
|
|
133
|
+
* @param {ComponentWords[]} components
|
|
134
|
+
* @returns {boolean}
|
|
135
|
+
*/
|
|
136
|
+
function describesOnePart(text, head, noun, familyWords, components) {
|
|
137
|
+
const end = text.slice(head.length).match(/^\s*([a-z]+)/i);
|
|
138
|
+
return (
|
|
139
|
+
end !== null &&
|
|
140
|
+
components.some(c => nameTerms(c).includes(noun)) &&
|
|
141
|
+
!terms(text).some(t => familyWords.has(t))
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The components a word names: the one whose whole name is the word
|
|
147
|
+
* ("button" names Button), else every component whose name holds it.
|
|
148
|
+
* @param {string} word
|
|
149
|
+
* @param {ComponentWords[]} components
|
|
150
|
+
* @returns {ComponentWords[]}
|
|
151
|
+
*/
|
|
152
|
+
function namedComponents(word, components) {
|
|
153
|
+
const whole = components.filter(c => {
|
|
154
|
+
const name = nameTerms(c);
|
|
155
|
+
return name.length === 1 && name[0] === word;
|
|
156
|
+
});
|
|
157
|
+
return whole.length > 0
|
|
158
|
+
? whole
|
|
159
|
+
: components.filter(c => nameTerms(c).includes(word));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Whether a component's doc files it under a category that declares a page
|
|
164
|
+
* family the project has ("Table & List" declares the table family): such a
|
|
165
|
+
* component holds the records a page of that family shows.
|
|
166
|
+
* @param {ComponentWords} component
|
|
167
|
+
* @param {Map<string, string>} familyWords
|
|
168
|
+
* @returns {boolean}
|
|
169
|
+
*/
|
|
170
|
+
function namesFamily(component, familyWords) {
|
|
171
|
+
const family = Object.hasOwn(COMPONENT_CATEGORIES, component.category ?? '')
|
|
172
|
+
? COMPONENT_CATEGORIES[component.category ?? ''].pageFamily
|
|
173
|
+
: undefined;
|
|
174
|
+
return family !== undefined && [...familyWords.values()].includes(family);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The stem of a phrase's last word.
|
|
179
|
+
* @param {string} phrase
|
|
180
|
+
* @returns {string}
|
|
181
|
+
*/
|
|
182
|
+
function lastNoun(phrase) {
|
|
183
|
+
const words = (phrase.toLowerCase().match(/[a-z0-9]+/g) ?? []).filter(
|
|
184
|
+
w => w.length >= 2,
|
|
185
|
+
);
|
|
186
|
+
return stem(words[words.length - 1] ?? '');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Whether an idea's head ends on "of" ("a list of jobs").
|
|
191
|
+
* @param {string} text
|
|
192
|
+
* @returns {boolean}
|
|
193
|
+
*/
|
|
194
|
+
function endsOnOf(text) {
|
|
195
|
+
return text.match(HEAD_END)?.[0].toLowerCase() === 'of';
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* What a head that ends on "of" is made of: the phrase after "of", up to the
|
|
200
|
+
* next head end, without an overlay frame.
|
|
201
|
+
* @param {string} text
|
|
202
|
+
* @returns {string}
|
|
203
|
+
*/
|
|
204
|
+
function madeOf(text) {
|
|
205
|
+
const end = text.match(HEAD_END);
|
|
206
|
+
const rest = text.slice((end?.index ?? 0) + (end?.[0].length ?? 0));
|
|
207
|
+
return (rest.split(HEAD_END)[0] ?? '').replace(CONTAINER_PHRASE, m =>
|
|
208
|
+
containersOf(m).size > 0 ? ' ' : m,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
105
212
|
/**
|
|
106
213
|
* Whether an idea adds a piece to a page the builder already has: it opens
|
|
107
214
|
* with "add", says where the piece goes with a place phrase that names
|
package/api/build/kit/kit.mjs
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file build.kit leaf — the page template to start from, and the kit around it.
|
|
5
5
|
*
|
|
6
|
-
* Every kit names a page template to START from
|
|
7
|
-
* (rank.mjs)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Every kit names a page template to START from, else the app shell. The page
|
|
7
|
+
* ranker (rank.mjs) orders the page templates; for a whole page the word
|
|
8
|
+
* weights (weights.mjs) decide page or shell and the page-pick model chooses
|
|
9
|
+
* the page from that list (start.mjs). Search's own matches never choose the
|
|
10
|
+
* start, so one noisy signal — search matching "site" to a gallery's "side" —
|
|
11
|
+
* cannot choose the page. A
|
|
10
12
|
* template carries the page frame, the spacing, and the section rhythm; a page
|
|
11
13
|
* composed from components carries none of that, so the kit never recommends
|
|
12
14
|
* composing from scratch while a template exists. Next to the start it names
|
package/api/build/kit/rank.d.mts
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Rank page templates against an idea, best first.
|
|
6
|
-
*
|
|
5
|
+
* Rank page templates against an idea, best first. An exact tie goes to a
|
|
6
|
+
* family's base template ahead of a variant; templates still tied are ordered
|
|
7
|
+
* by how strongly each one's own descriptor answers the idea, then by how
|
|
8
|
+
* typical of its family it is, then by name (`settleTies`).
|
|
7
9
|
*
|
|
8
10
|
* @param {string} query
|
|
9
11
|
* @param {PageTemplate[]} pages
|
package/api/build/kit/rank.mjs
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
* "board" picks the kanban board for a game board. Here every matched term
|
|
24
24
|
* counts, weighted by how rare it is among page templates (inverse document
|
|
25
25
|
* frequency), so the page that answers more of the idea — and its rarer words —
|
|
26
|
-
* wins. Structural signals sit on top
|
|
26
|
+
* wins. Structural signals sit on top. They order the ranker's list; for a
|
|
27
|
+
* whole page, the page-pick model in weights.mjs reads that list beside its
|
|
28
|
+
* own word tables and picks the start, so the start can differ from the
|
|
29
|
+
* ranker's first template:
|
|
27
30
|
*
|
|
28
31
|
* - The head noun. The words before the first "with", ":" or "," name what
|
|
29
32
|
* the page is ("audit dashboard: dense table with …"); a family word there
|
|
@@ -62,6 +65,8 @@ import {
|
|
|
62
65
|
keywordWordsFor,
|
|
63
66
|
framesOf,
|
|
64
67
|
} from './words.mjs';
|
|
68
|
+
import {namedOutright, tieReading} from './weights.mjs';
|
|
69
|
+
import {compareText} from '../../../foundation/text/compare-text.mjs';
|
|
65
70
|
|
|
66
71
|
/**
|
|
67
72
|
* @typedef {import('./words.mjs').PageTemplate} PageTemplate
|
|
@@ -131,8 +136,10 @@ const START_SCORE = 10;
|
|
|
131
136
|
const START_TERMS = 2;
|
|
132
137
|
|
|
133
138
|
/**
|
|
134
|
-
* Rank page templates against an idea, best first.
|
|
135
|
-
*
|
|
139
|
+
* Rank page templates against an idea, best first. An exact tie goes to a
|
|
140
|
+
* family's base template ahead of a variant; templates still tied are ordered
|
|
141
|
+
* by how strongly each one's own descriptor answers the idea, then by how
|
|
142
|
+
* typical of its family it is, then by name (`settleTies`).
|
|
136
143
|
*
|
|
137
144
|
* @param {string} query
|
|
138
145
|
* @param {PageTemplate[]} pages
|
|
@@ -285,18 +292,64 @@ export function rankPages(query, pages) {
|
|
|
285
292
|
matched,
|
|
286
293
|
};
|
|
287
294
|
})
|
|
288
|
-
.sort(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
+
.sort((a, b) => b.score - a.score || Number(b.base) - Number(a.base));
|
|
296
|
+
return baseFirst(settleTies(ranked, query, pages));
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Order each run of templates the ranker scores exactly the same (and that
|
|
301
|
+
* are all bases or all variants), whatever their families: first the one the
|
|
302
|
+
* idea names by its whole name (`namedOutright`), then by how strongly each
|
|
303
|
+
* one's own descriptor answers the idea (`tieReading`), then by how typical of
|
|
304
|
+
* its family it is, then by name. The catalog's order never decides, and
|
|
305
|
+
* neither does the host's locale.
|
|
306
|
+
* @param {RankedPage[]} ranked sorted by score, then base first
|
|
307
|
+
* @param {string} query
|
|
308
|
+
* @param {PageTemplate[]} pages
|
|
309
|
+
* @returns {RankedPage[]}
|
|
310
|
+
*/
|
|
311
|
+
function settleTies(ranked, query, pages) {
|
|
312
|
+
const out = [];
|
|
313
|
+
for (let i = 0; i < ranked.length;) {
|
|
314
|
+
let j = i + 1;
|
|
315
|
+
while (
|
|
316
|
+
j < ranked.length &&
|
|
317
|
+
ranked[j].score === ranked[i].score &&
|
|
318
|
+
ranked[j].base === ranked[i].base
|
|
319
|
+
)
|
|
320
|
+
j++;
|
|
321
|
+
const run = ranked.slice(i, j);
|
|
322
|
+
if (run.length > 1) {
|
|
323
|
+
const reading = tieReading(
|
|
324
|
+
run.map(r => r.name),
|
|
325
|
+
query,
|
|
326
|
+
pages,
|
|
327
|
+
);
|
|
328
|
+
const named = namedOutright(
|
|
329
|
+
run.map(r => r.name),
|
|
330
|
+
query,
|
|
331
|
+
pages,
|
|
332
|
+
);
|
|
333
|
+
const at = new Map(run.map((r, k) => [r, reading[k]]));
|
|
334
|
+
const outright = new Map(run.map((r, k) => [r, named[k]]));
|
|
335
|
+
run.sort(
|
|
336
|
+
(a, b) =>
|
|
337
|
+
Number(outright.get(b)) - Number(outright.get(a)) ||
|
|
338
|
+
Number(at.get(b)) - Number(at.get(a)) ||
|
|
339
|
+
b.typical - a.typical ||
|
|
340
|
+
compareText(a.name, b.name),
|
|
341
|
+
);
|
|
342
|
+
} else run.sort((a, b) => compareText(a.name, b.name));
|
|
343
|
+
out.push(...run);
|
|
344
|
+
i = j;
|
|
345
|
+
}
|
|
346
|
+
return out;
|
|
295
347
|
}
|
|
296
348
|
|
|
297
349
|
/**
|
|
298
350
|
* Put a named family's base template ahead of the variant that outranks it,
|
|
299
|
-
* unless the variant matched START_TERMS terms the base did not,
|
|
351
|
+
* unless the variant matched START_TERMS terms the base did not, the idea
|
|
352
|
+
* places the page in the variant's frame and not the base's, or the base
|
|
300
353
|
* cannot start on its own: too little score, or too few matched terms. The
|
|
301
354
|
* head names the exception: a family word in the idea's head is start
|
|
302
355
|
* evidence on its own — the same evidence pickStart accepts in place of a
|
|
@@ -319,8 +372,9 @@ function baseFirst(ranked) {
|
|
|
319
372
|
) {
|
|
320
373
|
return ranked;
|
|
321
374
|
}
|
|
375
|
+
// The frame is what a template is, and pickStart takes it as evidence.
|
|
322
376
|
const own = [...top.matched].filter(t => !base.matched.has(t)).length;
|
|
323
|
-
return own >= START_TERMS
|
|
377
|
+
return own >= START_TERMS || (top.containerMatched && !base.containerMatched)
|
|
324
378
|
? ranked
|
|
325
379
|
: [base, ...ranked.filter(r => r !== base)];
|
|
326
380
|
}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* The template to start from:
|
|
6
|
-
*
|
|
5
|
+
* The template to start from: for a whole page, the ready page the word
|
|
6
|
+
* weights and the page-pick model choose (weighStart); for a part or an edit,
|
|
7
|
+
* the ranker's placement; else the first fallback shell the project can
|
|
7
8
|
* scaffold. Null only when the project has no page template to offer at all.
|
|
8
9
|
*
|
|
9
|
-
* `direct` means two independent signals agree: the
|
|
10
|
-
*
|
|
10
|
+
* `direct` means two independent signals agree: the start is also search's
|
|
11
|
+
* direct match. The ranker sees only ready templates, so a template
|
|
11
12
|
* still marked not ready is never the start; when search matched one directly
|
|
12
13
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
13
14
|
*
|
package/api/build/kit/start.mjs
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file The page template a kit starts from:
|
|
5
|
-
*
|
|
4
|
+
* @file The page template a kit starts from: for a whole page, the page the
|
|
5
|
+
* word weights and the page-pick model choose from the ranker's list; for a
|
|
6
|
+
* part or an edit, where the ranker's placement rules put it; else the app
|
|
7
|
+
* shell.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import {loadWeights} from '../_adapter.mjs';
|
|
@@ -113,12 +115,13 @@ function liftFromShell(ranked, kind, catalog, idea) {
|
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
/**
|
|
116
|
-
* The template to start from:
|
|
117
|
-
*
|
|
118
|
+
* The template to start from: for a whole page, the ready page the word
|
|
119
|
+
* weights and the page-pick model choose (weighStart); for a part or an edit,
|
|
120
|
+
* the ranker's placement; else the first fallback shell the project can
|
|
118
121
|
* scaffold. Null only when the project has no page template to offer at all.
|
|
119
122
|
*
|
|
120
|
-
* `direct` means two independent signals agree: the
|
|
121
|
-
*
|
|
123
|
+
* `direct` means two independent signals agree: the start is also search's
|
|
124
|
+
* direct match. The ranker sees only ready templates, so a template
|
|
122
125
|
* still marked not ready is never the start; when search matched one directly
|
|
123
126
|
* the reason names it, so the reader knows why the kit starts elsewhere.
|
|
124
127
|
*
|
|
@@ -149,8 +152,9 @@ export function chooseStart(ranked, kind, pages, directMatch, catalog, idea) {
|
|
|
149
152
|
: place[0].toUpperCase() + place.slice(1);
|
|
150
153
|
const proposed = pickStart(ranked, kind);
|
|
151
154
|
// The checked-in word weights (weights.mjs), blended with the ranker's
|
|
152
|
-
// scores, decide the start of a whole page
|
|
153
|
-
//
|
|
155
|
+
// scores, decide the start of a whole page, so it can differ from the
|
|
156
|
+
// ranker's own pick, its head-noun family included. A part or an edit starts
|
|
157
|
+
// where the ranker's placement rules put it (spec:AST-048/FR3).
|
|
154
158
|
const weighed =
|
|
155
159
|
kind === 'page'
|
|
156
160
|
? weighStart(idea, ranked, proposed, catalog, {
|
|
@@ -13,6 +13,29 @@ export function stem(word: string): string;
|
|
|
13
13
|
* @returns {string[]}
|
|
14
14
|
*/
|
|
15
15
|
export function weightWords(idea: string): string[];
|
|
16
|
+
/**
|
|
17
|
+
* Which of a set of tied templates the idea names by its whole name: its
|
|
18
|
+
* display name or its id, as consecutive words of the idea ("a form wizard
|
|
19
|
+
* page" names `form-wizard`, "Form Wizard"). A whole name is stronger evidence
|
|
20
|
+
* than any descriptor word, so it settles an exact tie first.
|
|
21
|
+
* @param {string[]} names the tied templates' ids
|
|
22
|
+
* @param {string} idea
|
|
23
|
+
* @param {DescribedTemplate[]} catalog
|
|
24
|
+
* @returns {boolean[]} one flag per name, in order
|
|
25
|
+
*/
|
|
26
|
+
export function namedOutright(names: string[], idea: string, catalog: DescribedTemplate[]): boolean[];
|
|
27
|
+
/**
|
|
28
|
+
* How strongly each of a set of tied templates' own descriptors answers the
|
|
29
|
+
* idea. Words every tied template names cannot choose between them, so they
|
|
30
|
+
* are left out; each other word of the idea that a template's descriptor
|
|
31
|
+
* names adds its rarity among the templates of the tied templates' families.
|
|
32
|
+
* Reads only the templates' descriptors.
|
|
33
|
+
* @param {string[]} names the tied templates' ids
|
|
34
|
+
* @param {string} idea
|
|
35
|
+
* @param {DescribedTemplate[]} catalog
|
|
36
|
+
* @returns {number[]} one reading per name, in order
|
|
37
|
+
*/
|
|
38
|
+
export function tieReading(names: string[], idea: string, catalog: DescribedTemplate[]): number[];
|
|
16
39
|
/**
|
|
17
40
|
* Every ready, non-shell template in the blend's own order, best first: the
|
|
18
41
|
* order the page start is chosen from, so the alternatives build names beside
|