@astryxdesign/cli 0.7.16 → 0.7.17-canary.g9a957aa
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 +12 -23
- package/api/build/_adapter.d.mts +5 -0
- package/api/build/_adapter.mjs +49 -34
- package/api/build/blocks/blocks.d.mts +7 -5
- package/api/build/blocks/blocks.mjs +113 -26
- package/api/build/build.doc.mjs +2 -1
- package/api/build/kit/rank.mjs +47 -9
- package/api/build/kit/weights.d.mts +16 -3
- package/api/build/kit/weights.json +1 -1
- package/api/build/kit/weights.mjs +238 -31
- package/api/build/kit/word-model.d.mts +23 -0
- package/api/build/kit/word-model.mjs +46 -0
- package/api/build/kit/words.d.mts +32 -0
- package/api/build/kit/words.mjs +49 -1
- package/api/component/__fixtures__/resolutions/modules.txt +4 -5
- package/api/component/list/list.d.mts +1 -1
- package/api/component/list/list.mjs +48 -5
- package/api/discover/_adapter.d.mts +1 -1
- package/api/docs/_adapter.d.mts +26 -2
- package/api/docs/_adapter.mjs +217 -5
- package/api/docs/docs.d.mts +3 -0
- package/api/docs/docs.doc.mjs +7 -1
- package/api/docs/docs.mjs +12 -0
- package/api/docs/docs.type.d.mts +5 -0
- package/api/docs/docs.type.mjs +2 -0
- package/api/docs/node/node.mjs +1 -1
- package/api/doctor/_adapter.d.mts +27 -5
- package/api/doctor/_adapter.mjs +77 -6
- package/api/doctor/built-checks.mjs +38 -13
- package/api/doctor/doctor.d.mts +4 -3
- package/api/doctor/doctor.mjs +14 -7
- package/api/doctor/theme-checks.mjs +121 -17
- package/api/render/_adapter.mjs +491 -186
- package/api/render/render.doc.mjs +10 -3
- package/api/render/render.type.d.mts +30 -0
- package/api/render/render.type.mjs +19 -0
- package/api/search/ORDERING.md +1 -1
- package/api/search/_candidate-score.mjs +51 -32
- package/api/search/_fit-order.mjs +3 -3
- package/api/search/_result.d.mts +5 -5
- package/api/search/_score.d.mts +6 -1
- package/api/search/_score.mjs +15 -3
- package/api/search/search.d.mts +1 -1
- package/api/theme/_adapter.mjs +10 -0
- package/api/theme/build/build.d.mts +38 -0
- package/api/theme/build/build.mjs +144 -24
- package/api/theme/theme.type.d.mts +10 -0
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme-edit/_adapter.d.mts +35 -0
- package/api/theme-edit/_adapter.mjs +477 -41
- package/api/theme-edit/_check.d.mts +28 -22
- package/api/theme-edit/_check.mjs +1077 -200
- package/api/theme-edit/_compiler.mjs +9 -0
- package/api/theme-edit/_context.mjs +60 -3
- package/api/theme-edit/_css.mjs +21 -1
- package/api/theme-edit/_edit.d.mts +22 -0
- package/api/theme-edit/_edit.mjs +932 -82
- package/api/theme-edit/_how-commands.d.mts +49 -0
- package/api/theme-edit/_how-commands.mjs +386 -1
- package/api/theme-edit/_how-question.d.mts +56 -0
- package/api/theme-edit/_how-question.mjs +3509 -168
- package/api/theme-edit/_how.mjs +104 -4
- package/api/theme-edit/_marks.d.mts +31 -5
- package/api/theme-edit/_marks.mjs +57 -5
- package/api/theme-edit/_normal.d.mts +137 -0
- package/api/theme-edit/_normal.mjs +612 -0
- package/api/theme-edit/_palette.mjs +10 -4
- package/api/theme-edit/_parts.d.mts +4 -0
- package/api/theme-edit/_parts.mjs +28 -2
- package/api/theme-edit/_preview-app.d.mts +7 -1
- package/api/theme-edit/_preview-app.mjs +191 -15
- package/api/theme-edit/_preview.d.mts +64 -8
- package/api/theme-edit/_preview.mjs +401 -83
- package/api/theme-edit/_settings.d.mts +139 -5
- package/api/theme-edit/_settings.mjs +1659 -112
- package/api/theme-edit/_tables.mjs +17 -1
- package/api/theme-edit/theme-edit.type.d.mts +10 -1
- package/api/theme-edit/theme-edit.type.mjs +4 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +2 -2
- package/assets/codemods/run-codemod.mjs +73 -6
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-item-swipe-actions-to-swipe.mjs +394 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -0
- package/assets/docs/theme.doc.dense.mjs +2 -2
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +2 -3
- package/assets/docs/tree/render-pages.doc.mjs +43 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/use-a-theme.doc.mjs +1 -1
- package/assets/docs.generated.json +2 -2
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/ChatComposerInput/useChatDictationHookUsage.tsx +38 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/SyntaxTheme/useSyntaxThemeHookUsage.tsx +36 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/template.doc.mjs +8 -4
- package/assets/templates/pages/ai-chat-landing/template.doc.mjs +2 -1
- package/assets/templates/pages/blank/template.doc.mjs +1 -1
- package/assets/templates/pages/canvas-editor/template.doc.mjs +4 -2
- package/assets/templates/pages/centered-hero/template.doc.mjs +9 -1
- package/assets/templates/pages/classic-gallery/template.doc.mjs +1 -1
- package/assets/templates/pages/contact-form/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard/template.doc.mjs +3 -2
- package/assets/templates/pages/dashboard-alert-rail/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-cohort-funnel/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-composition/template.doc.mjs +2 -1
- package/assets/templates/pages/dashboard-progress/template.doc.mjs +6 -3
- package/assets/templates/pages/detail-page/template.doc.mjs +10 -3
- package/assets/templates/pages/documentation/template.doc.mjs +4 -1
- package/assets/templates/pages/documentation-design/template.doc.mjs +7 -1
- package/assets/templates/pages/documentation-technical/template.doc.mjs +7 -1
- package/assets/templates/pages/editor/template.doc.mjs +1 -7
- package/assets/templates/pages/file-explorer/template.doc.mjs +1 -1
- package/assets/templates/pages/form-two-column/template.doc.mjs +4 -3
- package/assets/templates/pages/form-wizard/template.doc.mjs +5 -3
- package/assets/templates/pages/gallery-hero/template.doc.mjs +4 -2
- package/assets/templates/pages/ide/page.tsx +24 -2
- package/assets/templates/pages/library/template.doc.mjs +4 -1
- package/assets/templates/pages/login/template.doc.mjs +2 -1
- package/assets/templates/pages/login-card/template.doc.mjs +2 -1
- package/assets/templates/pages/login-split/template.doc.mjs +2 -1
- package/assets/templates/pages/login-sso/template.doc.mjs +4 -2
- package/assets/templates/pages/mixed-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/product-detail/template.doc.mjs +4 -2
- package/assets/templates/pages/product-gallery/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-dialog/template.doc.mjs +2 -1
- package/assets/templates/pages/settings-sidebar/template.doc.mjs +2 -1
- package/assets/templates/pages/shell-nav/template.doc.mjs +4 -2
- package/assets/templates/pages/shell-side-nav/template.doc.mjs +5 -3
- package/assets/templates/pages/shell-top-nav/template.doc.mjs +2 -1
- package/assets/templates/pages/side-gallery/template.doc.mjs +9 -1
- package/assets/templates/pages/table-filter/template.doc.mjs +9 -8
- package/assets/templates/pages/table-grouped/template.doc.mjs +4 -2
- package/assets/templates/pages/table-page/template.doc.mjs +5 -4
- package/assets/templates/pages/table-tree/template.doc.mjs +6 -3
- package/assets/templates/pages/theme-showcase/template.doc.mjs +2 -1
- package/assets/templates/pages/work-item-detail/template.doc.mjs +1 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +3 -3
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +9 -0
- package/clients/cli/bin/astryx.mjs +6 -9
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/component.doc.mjs +1 -1
- package/clients/cli/commands/component.mjs +20 -2
- package/clients/cli/commands/docs.doc.mjs +7 -1
- package/clients/cli/commands/docs.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +22 -14
- package/clients/cli/commands/experimental/render.mjs +32 -1
- package/clients/cli/commands/experimental/theme.mjs +27 -2
- package/clients/cli/commands/experimental-render.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +2 -1
- package/clients/cli/commands/search.mjs +6 -1
- package/clients/cli/commands/template.mjs +4 -2
- package/clients/cli/commands/theme-build.doc.mjs +5 -1
- package/clients/cli/commands/theme.doc.mjs +1 -1
- package/clients/cli/commands/theme.mjs +138 -3
- package/clients/cli/commands/upgrade.mjs +42 -7
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +205 -98
- package/clients/cli/lib/hook-format.mjs +9 -19
- package/clients/cli/manifest.generated.json +1 -1
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/config/theme-state.d.mts +13 -1
- package/foundation/config/theme-state.mjs +47 -7
- package/foundation/discovery/component-discovery.d.mts +11 -0
- package/foundation/discovery/component-discovery.mjs +27 -2
- package/foundation/discovery/component-replacement.mjs +130 -1
- package/foundation/discovery/entry-name-files.d.mts +43 -0
- package/foundation/discovery/entry-name-files.mjs +264 -0
- package/foundation/discovery/hook-discovery.d.mts +8 -2
- package/foundation/discovery/hook-discovery.mjs +20 -7
- package/foundation/discovery/runner-allowlist.d.mts +1 -0
- package/foundation/discovery/runner-allowlist.mjs +2 -0
- package/foundation/discovery/template-adapter.d.mts +52 -0
- package/foundation/discovery/template-adapter.mjs +169 -0
- package/foundation/discovery/theme-imports.d.mts +14 -0
- package/foundation/discovery/theme-imports.mjs +43 -1
- package/foundation/doc-compiler/import.mjs +7 -1
- package/foundation/doc-compiler/parse-readable.mjs +4 -1
- package/foundation/doc-compiler/stored-docs.d.mts +22 -0
- package/foundation/doc-compiler/stored-docs.mjs +49 -0
- package/foundation/fs/cache-eviction.d.mts +21 -0
- package/foundation/fs/cache-eviction.mjs +73 -0
- package/foundation/fs/gather-cache.d.mts +25 -4
- package/foundation/fs/gather-cache.mjs +138 -52
- package/foundation/fs/jiti-cache.d.mts +19 -1
- package/foundation/fs/jiti-cache.mjs +130 -6
- package/foundation/fs/kept-tree.d.mts +60 -0
- package/foundation/fs/kept-tree.mjs +154 -0
- package/foundation/fs/module-loader.d.mts +18 -2
- package/foundation/fs/module-loader.mjs +92 -20
- package/foundation/identity/provider-identity.d.mts +6 -0
- package/foundation/identity/provider-identity.mjs +10 -1
- package/foundation/render/file-header.d.mts +66 -0
- package/foundation/render/file-header.mjs +118 -0
- package/foundation/render/host-answer.d.mts +18 -0
- package/foundation/render/host-answer.mjs +46 -0
- package/foundation/render/host-exit.d.mts +1 -0
- package/foundation/render/host-exit.mjs +6 -1
- package/foundation/render/html-reader.d.mts +55 -2
- package/foundation/render/html-reader.mjs +145 -26
- package/foundation/render/markup-edits.d.mts +57 -0
- package/foundation/render/markup-edits.mjs +182 -0
- package/foundation/render/page-host.mjs +29 -12
- package/foundation/render/page-worker.mjs +79 -10
- package/foundation/render/render-page.d.mts +34 -2
- package/foundation/render/render-page.mjs +210 -29
- package/foundation/render/source-block.d.mts +73 -6
- package/foundation/render/source-block.mjs +170 -19
- package/foundation/render/ts-paths.d.mts +4 -1
- package/foundation/render/ts-paths.mjs +7 -3
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.doc.mjs +7 -1
- package/foundation/response/error-codes.mjs +7 -0
- package/foundation/text/string-utils.d.mts +3 -2
- package/foundation/text/string-utils.mjs +16 -3
- package/foundation/text/suggest-order.d.mts +9 -0
- package/foundation/text/suggest-order.mjs +13 -0
- package/package.json +6 -6
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Word weights for `build`'s START (spec:AST-048):
|
|
5
|
-
* per-template word weights, blended with the page ranker's own scores,
|
|
6
|
-
* the template an idea starts from.
|
|
4
|
+
* @file Word weights for `build`'s START (spec:AST-048): checked-in tables of
|
|
5
|
+
* per-template word weights, blended with the page ranker's own scores, pick
|
|
6
|
+
* the template an idea starts from. The call model (the file's top-level
|
|
7
|
+
* tables and blend) decides page or app shell; an optional pick model
|
|
8
|
+
* (`pick`) chooses which page once the call model calls a page.
|
|
7
9
|
*
|
|
8
10
|
* @input An idea, the ranker's output for it (`rankPages`, `pickStart`), the
|
|
9
11
|
* project's ready page templates, and the weights (`weights.json` beside this
|
|
@@ -20,6 +22,8 @@
|
|
|
20
22
|
*/
|
|
21
23
|
|
|
22
24
|
import {STOPWORDS} from '../../search/search.mjs';
|
|
25
|
+
import {keywordUnits, keywordWordsFor} from './words.mjs';
|
|
26
|
+
import {isWordModel} from './word-model.mjs';
|
|
23
27
|
|
|
24
28
|
/** The app shell, as one candidate. */
|
|
25
29
|
export const SHELL = 'SHELL';
|
|
@@ -160,8 +164,34 @@ export function weightWords(idea) {
|
|
|
160
164
|
* @property {WeightTable[]} tables
|
|
161
165
|
* @property {number[]} blend three numbers per member (the tables, in order,
|
|
162
166
|
* with the ranker second), then one for `SHELL`
|
|
167
|
+
* @property {{tables: WeightTable[], blend: number[]}} [pick] the pick
|
|
168
|
+
* model: its own tables and blend numbers, used only to choose which page
|
|
169
|
+
* starts once the call model (the top-level tables and blend) has called a
|
|
170
|
+
* page. Without it, one model does both.
|
|
163
171
|
*/
|
|
164
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Whether the weights file carries a well-formed pick model. A malformed
|
|
175
|
+
* `pick` block is ignored, so one model then does both decisions.
|
|
176
|
+
* @param {WeightsFile} weights
|
|
177
|
+
* @returns {boolean}
|
|
178
|
+
*/
|
|
179
|
+
const hasPickModel = weights =>
|
|
180
|
+
isWordModel(weights.pick, weights.candidates.length);
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The pick model of a weights file: its `pick` tables and blend when present,
|
|
184
|
+
* else the file's own.
|
|
185
|
+
* @param {WeightsFile} weights
|
|
186
|
+
* @returns {WeightsFile}
|
|
187
|
+
*/
|
|
188
|
+
const pickModel = weights => {
|
|
189
|
+
const pick = weights.pick;
|
|
190
|
+
return pick && hasPickModel(weights)
|
|
191
|
+
? {...weights, tables: pick.tables, blend: pick.blend}
|
|
192
|
+
: weights;
|
|
193
|
+
};
|
|
194
|
+
|
|
165
195
|
/**
|
|
166
196
|
* A table's score for every candidate.
|
|
167
197
|
* @param {WeightTable} table
|
|
@@ -233,32 +263,68 @@ function memberFeatures(v) {
|
|
|
233
263
|
* @property {string} [displayName]
|
|
234
264
|
* @property {string} [category]
|
|
235
265
|
* @property {string[]} [keywords]
|
|
266
|
+
* @property {string} [description]
|
|
267
|
+
* @property {string[]} [components]
|
|
236
268
|
*/
|
|
237
269
|
|
|
238
270
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
271
|
+
* The words of a descriptor text as this file reads an idea: stemmed, less
|
|
272
|
+
* search's stopwords. Search's stopwords are no evidence: "to" in a "to-do
|
|
273
|
+
* list" keyword must not answer the "to" of "rows to track orders".
|
|
274
|
+
* @param {string} text
|
|
275
|
+
* @returns {string[]}
|
|
276
|
+
*/
|
|
277
|
+
const contentWords = text =>
|
|
278
|
+
weightWords(text)
|
|
279
|
+
.filter(w => !STOPWORDS.has(w))
|
|
280
|
+
.map(stem);
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The words a template's descriptor gives an idea: every word of `texts`, and
|
|
284
|
+
* the words its keywords give the idea (`keywordWordsFor`): a phrase keyword
|
|
285
|
+
* counts all of its words when the idea names the whole phrase, and none of
|
|
286
|
+
* them otherwise.
|
|
287
|
+
* @param {string[]} texts
|
|
288
|
+
* @param {readonly string[]} keywords
|
|
289
|
+
* @param {string[]} order the idea's words, in order (`contentWords`)
|
|
290
|
+
* @returns {Set<string>}
|
|
291
|
+
*/
|
|
292
|
+
const descriptorWordsFor = (texts, keywords, order) =>
|
|
293
|
+
new Set([
|
|
294
|
+
...contentWords(texts.join(' ')),
|
|
295
|
+
...keywordWordsFor(keywordUnits(keywords, contentWords), order),
|
|
296
|
+
]);
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* How many of the idea's words a template's own descriptor names: its display
|
|
300
|
+
* name, its category, and its keywords.
|
|
241
301
|
* @param {string} name
|
|
242
302
|
* @param {DescribedTemplate[]} catalog
|
|
243
|
-
* @param {
|
|
303
|
+
* @param {string[]} order the idea's words, in order (`contentWords`)
|
|
244
304
|
*/
|
|
245
|
-
function ownWords(name, catalog,
|
|
305
|
+
function ownWords(name, catalog, order) {
|
|
246
306
|
const t = catalog.find(c => c.name === name);
|
|
247
307
|
if (!t) return 0;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
[t.displayName ?? '', t.category ?? '', ...(t.keywords ?? [])].join(' '),
|
|
253
|
-
)
|
|
254
|
-
.filter(w => !STOPWORDS.has(w))
|
|
255
|
-
.map(stem),
|
|
308
|
+
const own = descriptorWordsFor(
|
|
309
|
+
[t.displayName ?? '', t.category ?? ''],
|
|
310
|
+
t.keywords ?? [],
|
|
311
|
+
order,
|
|
256
312
|
);
|
|
257
313
|
let n = 0;
|
|
258
|
-
for (const w of
|
|
314
|
+
for (const w of new Set(order)) if (own.has(w)) n++;
|
|
259
315
|
return n;
|
|
260
316
|
}
|
|
261
317
|
|
|
318
|
+
/**
|
|
319
|
+
* A template's family: the part of its category before ` - `.
|
|
320
|
+
* @param {string} name
|
|
321
|
+
* @param {DescribedTemplate[]} catalog
|
|
322
|
+
*/
|
|
323
|
+
const familyOf = (name, catalog) =>
|
|
324
|
+
String(catalog.find(c => c.name === name)?.category ?? '')
|
|
325
|
+
.split(' - ')[0]
|
|
326
|
+
.trim();
|
|
327
|
+
|
|
262
328
|
/** How many fewer own words a template whose family the idea names first may
|
|
263
329
|
* name than the listed template it competes with, and still start. */
|
|
264
330
|
const FAMILY_SLACK = 2;
|
|
@@ -330,6 +396,132 @@ function blend(idea, ranked, pick, catalog, weights) {
|
|
|
330
396
|
return {cands, scores, position};
|
|
331
397
|
}
|
|
332
398
|
|
|
399
|
+
/**
|
|
400
|
+
* The most typical of the ready templates the ranker ties with `name` in its
|
|
401
|
+
* family (same score, same id length): the one whose descriptor's words are
|
|
402
|
+
* shared by the most of its family's templates, on average. `name` keeps its
|
|
403
|
+
* place on an equal value. Reads only the templates' descriptors.
|
|
404
|
+
* @param {string} name
|
|
405
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
406
|
+
* @param {string[]} cands
|
|
407
|
+
* @returns {string}
|
|
408
|
+
*/
|
|
409
|
+
function typicalOfTie(name, ranked, cands) {
|
|
410
|
+
const self = ranked.find(r => r.name === name);
|
|
411
|
+
if (!self || self.family === SHELL_FAMILY || !self.family) return name;
|
|
412
|
+
const length = (/** @type {string} */ n) => n.split('-').length;
|
|
413
|
+
let chosen = self;
|
|
414
|
+
for (const r of ranked) {
|
|
415
|
+
if (
|
|
416
|
+
r.score === self.score &&
|
|
417
|
+
r.family === self.family &&
|
|
418
|
+
length(r.name) === length(self.name) &&
|
|
419
|
+
cands.includes(r.name) &&
|
|
420
|
+
r.typical > chosen.typical
|
|
421
|
+
)
|
|
422
|
+
chosen = r;
|
|
423
|
+
}
|
|
424
|
+
return chosen.name;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* The words a template's whole descriptor gives an idea
|
|
429
|
+
* (`descriptorWordsFor`): its display name, category, keywords, description,
|
|
430
|
+
* and the names of the components its page composes.
|
|
431
|
+
* @param {DescribedTemplate} t
|
|
432
|
+
* @param {string[]} order the idea's words, in order (`contentWords`)
|
|
433
|
+
* @returns {Set<string>}
|
|
434
|
+
*/
|
|
435
|
+
function descriptorWords(t, order) {
|
|
436
|
+
const components = (t.components ?? []).map(c =>
|
|
437
|
+
c.replace(/([a-z0-9])([A-Z])/g, '$1 $2'),
|
|
438
|
+
);
|
|
439
|
+
return descriptorWordsFor(
|
|
440
|
+
[t.displayName ?? '', t.category ?? '', t.description ?? '', ...components],
|
|
441
|
+
t.keywords ?? [],
|
|
442
|
+
order,
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Settles an exact tie in the ranker by a fuller reading of each tied
|
|
448
|
+
* template's own descriptor. Words every tied template names cannot choose
|
|
449
|
+
* between them, so they are left out; each other word of the idea that a
|
|
450
|
+
* template's descriptor names adds its rarity within the family. The highest
|
|
451
|
+
* total starts. An equal total goes to the most typical of the family
|
|
452
|
+
* (`typicalOfTie`), then to `name`. Reads only the templates' descriptors.
|
|
453
|
+
* @param {string} name
|
|
454
|
+
* @param {string} idea
|
|
455
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
456
|
+
* @param {string[]} cands
|
|
457
|
+
* @param {DescribedTemplate[]} catalog
|
|
458
|
+
* @returns {string}
|
|
459
|
+
*/
|
|
460
|
+
function fullerOfTie(name, idea, ranked, cands, catalog) {
|
|
461
|
+
const self = ranked.find(r => r.name === name);
|
|
462
|
+
if (!self || self.family === SHELL_FAMILY || !self.family) return name;
|
|
463
|
+
const length = (/** @type {string} */ n) => n.split('-').length;
|
|
464
|
+
const tied = ranked.filter(
|
|
465
|
+
r =>
|
|
466
|
+
r.score === self.score &&
|
|
467
|
+
r.family === self.family &&
|
|
468
|
+
length(r.name) === length(self.name) &&
|
|
469
|
+
cands.includes(r.name),
|
|
470
|
+
);
|
|
471
|
+
if (tied.length < 2) return name;
|
|
472
|
+
const family = catalog.filter(t => familyOf(t.name, catalog) === self.family);
|
|
473
|
+
const order = contentWords(idea);
|
|
474
|
+
const words = new Map(family.map(t => [t.name, descriptorWords(t, order)]));
|
|
475
|
+
const df = (/** @type {string} */ w) =>
|
|
476
|
+
family.filter(t => words.get(t.name)?.has(w)).length;
|
|
477
|
+
const said = new Set(order);
|
|
478
|
+
const own = tied.map(r => words.get(r.name) ?? new Set());
|
|
479
|
+
const n = family.length;
|
|
480
|
+
const score = tied.map((_, i) => {
|
|
481
|
+
let s = 0;
|
|
482
|
+
for (const w of said) {
|
|
483
|
+
if (!own[i].has(w) || own.every(o => o.has(w))) continue;
|
|
484
|
+
const d = df(w);
|
|
485
|
+
s += Math.log(1 + (n - d + 0.5) / (d + 0.5));
|
|
486
|
+
}
|
|
487
|
+
return s;
|
|
488
|
+
});
|
|
489
|
+
const top = Math.max(...score);
|
|
490
|
+
if (top === 0) return typicalOfTie(name, ranked, cands);
|
|
491
|
+
const leaders = tied.filter((_, i) => score[i] >= top - 1e-9);
|
|
492
|
+
if (leaders.length === 1) return leaders[0].name;
|
|
493
|
+
const lead = leaders.some(r => r.name === name) ? self : leaders[0];
|
|
494
|
+
return typicalOfTie(
|
|
495
|
+
lead.name,
|
|
496
|
+
ranked,
|
|
497
|
+
leaders.map(r => r.name),
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* The pick model's best ready, non-shell template, or null when it has none.
|
|
503
|
+
* @param {string} idea
|
|
504
|
+
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
505
|
+
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
506
|
+
* @param {DescribedTemplate[]} catalog
|
|
507
|
+
* @param {WeightsFile} weights
|
|
508
|
+
* @returns {string | null}
|
|
509
|
+
*/
|
|
510
|
+
function bestPage(idea, ranked, pick, catalog, weights) {
|
|
511
|
+
const {cands, scores} = blend(
|
|
512
|
+
idea,
|
|
513
|
+
ranked,
|
|
514
|
+
pick,
|
|
515
|
+
catalog,
|
|
516
|
+
pickModel(weights),
|
|
517
|
+
);
|
|
518
|
+
let at = -1;
|
|
519
|
+
for (let c = 0; c < cands.length; c++) {
|
|
520
|
+
if (cands[c] !== SHELL && (at < 0 || scores[c] > scores[at])) at = c;
|
|
521
|
+
}
|
|
522
|
+
return at < 0 ? null : cands[at];
|
|
523
|
+
}
|
|
524
|
+
|
|
333
525
|
/**
|
|
334
526
|
* Every ready, non-shell template in the blend's own order, best first: the
|
|
335
527
|
* order the page start is chosen from, so the alternatives build names beside
|
|
@@ -343,7 +535,13 @@ function blend(idea, ranked, pick, catalog, weights) {
|
|
|
343
535
|
*/
|
|
344
536
|
export function blendOrder(idea, ranked, pick, catalog, weights) {
|
|
345
537
|
if (!weights) return null;
|
|
346
|
-
const {cands, scores} = blend(
|
|
538
|
+
const {cands, scores} = blend(
|
|
539
|
+
idea,
|
|
540
|
+
ranked,
|
|
541
|
+
pick,
|
|
542
|
+
catalog,
|
|
543
|
+
pickModel(weights),
|
|
544
|
+
);
|
|
347
545
|
return cands
|
|
348
546
|
.map((c, i) => ({c, s: scores[i], i}))
|
|
349
547
|
.filter(x => x.c !== SHELL)
|
|
@@ -397,22 +595,28 @@ export function weighStart(
|
|
|
397
595
|
if (!listed) return kept;
|
|
398
596
|
// The idea's own words, less search's stopwords: "basically" must not
|
|
399
597
|
// answer the "Basic" of a category.
|
|
400
|
-
const
|
|
401
|
-
const
|
|
402
|
-
const
|
|
403
|
-
const theirs = ownWords(listed, catalog, said);
|
|
404
|
-
if (mine >= theirs) return kept;
|
|
598
|
+
const order = contentWords(idea);
|
|
599
|
+
const mine = ownWords(kept, catalog, order);
|
|
600
|
+
const theirs = ownWords(listed, catalog, order);
|
|
405
601
|
// An idea that names the template's family before the listed one's
|
|
406
602
|
// ("a dashboard with a data table") is that family's page, unless it
|
|
407
603
|
// names far more of the listed template's words.
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
604
|
+
const stays =
|
|
605
|
+
mine >= theirs ||
|
|
606
|
+
(familyAt(kept, catalog, order) < familyAt(listed, catalog, order) &&
|
|
607
|
+
mine >= theirs - FAMILY_SLACK);
|
|
608
|
+
if (!stays) return listed;
|
|
609
|
+
// A tie in the ranker is no preference: every table that names "table"
|
|
610
|
+
// scores the same, and the alphabet must not choose the page. Among the
|
|
611
|
+
// family's templates the ranker ties with this unlisted one, the template
|
|
612
|
+
// whose own descriptor best matches the idea starts (`fullerOfTie`), then
|
|
613
|
+
// the one most typical of the family. Only the templates' descriptors
|
|
614
|
+
// decide this tie, never the tables.
|
|
615
|
+
return fullerOfTie(kept, idea, ranked, cands, catalog);
|
|
413
616
|
}
|
|
414
617
|
const top = best(() => true);
|
|
415
|
-
if (top !== SHELL)
|
|
618
|
+
if (top !== SHELL)
|
|
619
|
+
return bestPage(idea, ranked, pick, catalog, weights) ?? top;
|
|
416
620
|
// An idea that asks for a new page keeps the ranker's template rather than
|
|
417
621
|
// the shell.
|
|
418
622
|
if (newPage && kept) return kept;
|
|
@@ -420,8 +624,9 @@ export function weighStart(
|
|
|
420
624
|
}
|
|
421
625
|
|
|
422
626
|
/**
|
|
423
|
-
* The
|
|
424
|
-
*
|
|
627
|
+
* The call model's scores: the app shell's, the best non-shell template's and
|
|
628
|
+
* the runner-up's, with the page to start from (the pick model's choice when
|
|
629
|
+
* the file has one, else the call model's best page). Null without weights.
|
|
425
630
|
* @param {string} idea
|
|
426
631
|
* @param {import('./rank.mjs').RankedPage[]} ranked
|
|
427
632
|
* @param {import('./rank.mjs').RankedPage | null} pick
|
|
@@ -440,7 +645,9 @@ export function blendSummary(idea, ranked, pick, catalog, weights) {
|
|
|
440
645
|
rest.sort((x, y) => y.score - x.score || x.i - y.i);
|
|
441
646
|
return {
|
|
442
647
|
shell,
|
|
443
|
-
best:
|
|
648
|
+
best: hasPickModel(weights)
|
|
649
|
+
? bestPage(idea, ranked, pick, catalog, weights)
|
|
650
|
+
: (rest[0]?.name ?? null),
|
|
444
651
|
bestScore: rest[0]?.score ?? 0,
|
|
445
652
|
secondScore: rest[1]?.score ?? 0,
|
|
446
653
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file The shape check for `build`'s checked-in word models (spec:AST-048).
|
|
6
|
+
*
|
|
7
|
+
* @input A parsed word model (tables and blend numbers) and the candidate
|
|
8
|
+
* count of its weights file.
|
|
9
|
+
* @output `isWordModel(model, n)`: whether the kit can read it.
|
|
10
|
+
* @position Beside weights.mjs (api/build/kit/). The adapter checks the
|
|
11
|
+
* weights file's call model with it, and weights.mjs checks the optional
|
|
12
|
+
* pick model with it. It imports nothing, so both can use it.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Whether a word model has the shape the kit reads, over `n` candidates: every
|
|
16
|
+
* table row has a weight per candidate, every bias a number per candidate, and
|
|
17
|
+
* the blend has three numbers per member (the tables plus the ranker) and one
|
|
18
|
+
* for the shell. The weights file's call model and its `pick` model share it.
|
|
19
|
+
* @param {any} model
|
|
20
|
+
* @param {number} n the candidate count
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
export function isWordModel(model: any, n: number): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The shape check for `build`'s checked-in word models (spec:AST-048).
|
|
5
|
+
*
|
|
6
|
+
* @input A parsed word model (tables and blend numbers) and the candidate
|
|
7
|
+
* count of its weights file.
|
|
8
|
+
* @output `isWordModel(model, n)`: whether the kit can read it.
|
|
9
|
+
* @position Beside weights.mjs (api/build/kit/). The adapter checks the
|
|
10
|
+
* weights file's call model with it, and weights.mjs checks the optional
|
|
11
|
+
* pick model with it. It imports nothing, so both can use it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether a word model has the shape the kit reads, over `n` candidates: every
|
|
16
|
+
* table row has a weight per candidate, every bias a number per candidate, and
|
|
17
|
+
* the blend has three numbers per member (the tables plus the ranker) and one
|
|
18
|
+
* for the shell. The weights file's call model and its `pick` model share it.
|
|
19
|
+
* @param {any} model
|
|
20
|
+
* @param {number} n the candidate count
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
export function isWordModel(model, n) {
|
|
24
|
+
return (
|
|
25
|
+
n > 0 &&
|
|
26
|
+
Array.isArray(model?.tables) &&
|
|
27
|
+
model.tables.length > 0 &&
|
|
28
|
+
model.tables.every(
|
|
29
|
+
(/** @type {any} */ t) =>
|
|
30
|
+
Array.isArray(t?.words) &&
|
|
31
|
+
Array.isArray(t.rows) &&
|
|
32
|
+
t.rows.length === t.words.length &&
|
|
33
|
+
t.rows.every(
|
|
34
|
+
(/** @type {any} */ r) => typeof r === 'string' && r.length === n,
|
|
35
|
+
) &&
|
|
36
|
+
Array.isArray(t.bias) &&
|
|
37
|
+
t.bias.length === n &&
|
|
38
|
+
t.bias.every((/** @type {any} */ b) => Number.isFinite(b)) &&
|
|
39
|
+
Number.isFinite(t.clip) &&
|
|
40
|
+
Number.isFinite(t.step),
|
|
41
|
+
) &&
|
|
42
|
+
Array.isArray(model.blend) &&
|
|
43
|
+
model.blend.length === 3 * (model.tables.length + 1) + 1 &&
|
|
44
|
+
model.blend.every((/** @type {any} */ x) => Number.isFinite(x))
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -30,6 +30,37 @@ export function pairsOf(texts: string[]): Set<string>;
|
|
|
30
30
|
* @returns {Set<string>}
|
|
31
31
|
*/
|
|
32
32
|
export function containersOf(query: string): Set<string>;
|
|
33
|
+
/**
|
|
34
|
+
* A template's keywords as the units a request can match, each read with the
|
|
35
|
+
* caller's own word reader. A one-word keyword is that word. A longer keyword
|
|
36
|
+
* is one phrase unit, its words joined by single spaces: a request matches it
|
|
37
|
+
* only when it names those words in that order (`phrasesIn`), and its words
|
|
38
|
+
* never count alone. So "table of contents" on a docs page adds no "table" to
|
|
39
|
+
* that page, and a table request still reads as a table.
|
|
40
|
+
* @param {readonly string[]} keywords
|
|
41
|
+
* @param {(text: string) => string[]} read the caller's word reader
|
|
42
|
+
* @returns {string[]}
|
|
43
|
+
*/
|
|
44
|
+
export function keywordUnits(keywords: readonly string[], read: (text: string) => string[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* The phrase units (two or more words) a request names: the unit's words
|
|
47
|
+
* appear next to each other, in order, in the request's words as the same
|
|
48
|
+
* reader reads them.
|
|
49
|
+
* @param {readonly string[]} words the request's words, in order
|
|
50
|
+
* @param {Iterable<string>} units
|
|
51
|
+
* @returns {Set<string>}
|
|
52
|
+
*/
|
|
53
|
+
export function phrasesIn(words: readonly string[], units: Iterable<string>): Set<string>;
|
|
54
|
+
/**
|
|
55
|
+
* The words a template's keyword units give an idea: each one-word keyword,
|
|
56
|
+
* and every word of each phrase keyword the idea names (`phrasesIn`). A named
|
|
57
|
+
* phrase carries all of its words, as the same words listed one by one would;
|
|
58
|
+
* a phrase the idea does not name gives none of them.
|
|
59
|
+
* @param {readonly string[]} units the template's keyword units (`keywordUnits`)
|
|
60
|
+
* @param {readonly string[]} words the idea's words, in order, read the same way
|
|
61
|
+
* @returns {string[]}
|
|
62
|
+
*/
|
|
63
|
+
export function keywordWordsFor(units: readonly string[], words: readonly string[]): string[];
|
|
33
64
|
/**
|
|
34
65
|
* Family words, from the templates' own ids: a word in the ids of two or more
|
|
35
66
|
* templates of one family, plus the family's name when a template carries it.
|
|
@@ -69,5 +100,6 @@ export type RankedPage = {
|
|
|
69
100
|
family: string;
|
|
70
101
|
base: boolean;
|
|
71
102
|
matched: Set<string>;
|
|
103
|
+
typical: number;
|
|
72
104
|
};
|
|
73
105
|
export type IdeaKind = "page" | "part" | "edit";
|
package/api/build/kit/words.mjs
CHANGED
|
@@ -130,6 +130,54 @@ export function containersOf(query) {
|
|
|
130
130
|
return found;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
/**
|
|
134
|
+
* A template's keywords as the units a request can match, each read with the
|
|
135
|
+
* caller's own word reader. A one-word keyword is that word. A longer keyword
|
|
136
|
+
* is one phrase unit, its words joined by single spaces: a request matches it
|
|
137
|
+
* only when it names those words in that order (`phrasesIn`), and its words
|
|
138
|
+
* never count alone. So "table of contents" on a docs page adds no "table" to
|
|
139
|
+
* that page, and a table request still reads as a table.
|
|
140
|
+
* @param {readonly string[]} keywords
|
|
141
|
+
* @param {(text: string) => string[]} read the caller's word reader
|
|
142
|
+
* @returns {string[]}
|
|
143
|
+
*/
|
|
144
|
+
export function keywordUnits(keywords, read) {
|
|
145
|
+
return keywords.map(keyword => read(keyword).join(' ')).filter(Boolean);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The phrase units (two or more words) a request names: the unit's words
|
|
150
|
+
* appear next to each other, in order, in the request's words as the same
|
|
151
|
+
* reader reads them.
|
|
152
|
+
* @param {readonly string[]} words the request's words, in order
|
|
153
|
+
* @param {Iterable<string>} units
|
|
154
|
+
* @returns {Set<string>}
|
|
155
|
+
*/
|
|
156
|
+
export function phrasesIn(words, units) {
|
|
157
|
+
const text = ` ${words.join(' ')} `;
|
|
158
|
+
const found = new Set();
|
|
159
|
+
for (const unit of units) {
|
|
160
|
+
if (unit.includes(' ') && text.includes(` ${unit} `)) found.add(unit);
|
|
161
|
+
}
|
|
162
|
+
return found;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The words a template's keyword units give an idea: each one-word keyword,
|
|
167
|
+
* and every word of each phrase keyword the idea names (`phrasesIn`). A named
|
|
168
|
+
* phrase carries all of its words, as the same words listed one by one would;
|
|
169
|
+
* a phrase the idea does not name gives none of them.
|
|
170
|
+
* @param {readonly string[]} units the template's keyword units (`keywordUnits`)
|
|
171
|
+
* @param {readonly string[]} words the idea's words, in order, read the same way
|
|
172
|
+
* @returns {string[]}
|
|
173
|
+
*/
|
|
174
|
+
export function keywordWordsFor(units, words) {
|
|
175
|
+
const named = phrasesIn(words, units);
|
|
176
|
+
return units.flatMap(unit =>
|
|
177
|
+
!unit.includes(' ') ? [unit] : named.has(unit) ? unit.split(' ') : [],
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
133
181
|
/** @param {string} text */
|
|
134
182
|
export const normalized = text =>
|
|
135
183
|
(
|
|
@@ -163,7 +211,7 @@ export const SYNONYMS_OF = (() => {
|
|
|
163
211
|
/**
|
|
164
212
|
* @typedef {import('../_adapter.mjs').PageTemplate} PageTemplate
|
|
165
213
|
* @typedef {import('../_adapter.mjs').ComponentWords} ComponentWords
|
|
166
|
-
* @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string
|
|
214
|
+
* @typedef {{name: string, score: number, hits: number, familyNamed: boolean, headNamed: boolean, containerMatched: boolean, family: string, base: boolean, matched: Set<string>, typical: number}} RankedPage
|
|
167
215
|
* @typedef {'page' | 'part' | 'edit'} IdeaKind
|
|
168
216
|
*/
|
|
169
217
|
|
|
@@ -27,7 +27,6 @@ InputGroupInternalContext InputGroupInternalContext InputGroup/InputGroup.doc.mj
|
|
|
27
27
|
InternationalizationContext InternationalizationContext i18n/InternationalizationProvider.doc.mjs i18n/InternationalizationContext.ts
|
|
28
28
|
ItemDescriptionContext ItemDescriptionContext Item/Item.doc.mjs Item/ItemDescriptionContext.tsx
|
|
29
29
|
ItemMarkerColumnsContext ItemMarkerColumnsContext Item/Item.doc.mjs Item/ItemMarkerColumnsContext.tsx
|
|
30
|
-
ItemSwipeLayer ItemSwipeLayer Item/Item.doc.mjs Item/ItemSwipeLayer.tsx
|
|
31
30
|
LayerContext LayerContext Layer/Layer.doc.mjs Layer/LayerContext.ts
|
|
32
31
|
LayerDepthContext LayerDepthContext Layer/Layer.doc.mjs Layer/LayerDepthContext.tsx
|
|
33
32
|
LayerProvider LayerProvider Layer/Layer.doc.mjs Layer/LayerProvider.tsx
|
|
@@ -111,7 +110,7 @@ dataTokens dataTokens theme/MediaTheme.doc.mjs theme/domainTokens/dataTokens.ts
|
|
|
111
110
|
dayCellUtils dayCellUtils Calendar/Calendar.doc.mjs Calendar/dayCellUtils.ts
|
|
112
111
|
declarationBoundary declarationBoundary theme/MediaTheme.doc.mjs theme/declarationBoundary.ts
|
|
113
112
|
defaultIcons defaultIcons Icon/Icon.doc.mjs Icon/defaultIcons.tsx
|
|
114
|
-
defineSyntaxTheme defineSyntaxTheme theme/
|
|
113
|
+
defineSyntaxTheme defineSyntaxTheme theme/syntax/useSyntaxTheme.doc.mjs theme/syntax/defineSyntaxTheme.ts
|
|
115
114
|
defineTheme defineTheme theme/MediaTheme.doc.mjs theme/defineTheme.ts
|
|
116
115
|
derivedVarRegistry derivedVarRegistry theme/MediaTheme.doc.mjs theme/derivedVarRegistry.ts
|
|
117
116
|
dockerfile dockerfile CodeBlock/CodeBlock.doc.mjs CodeBlock/languages/dockerfile.ts
|
|
@@ -191,7 +190,7 @@ popoverOperations popoverOperations Layer/Layer.doc.mjs Layer/popoverOperations.
|
|
|
191
190
|
powerSearchSheetUtils powerSearchSheetUtils PowerSearch/PowerSearch.doc.mjs PowerSearch/powerSearchSheetUtils.ts
|
|
192
191
|
powershell powershell CodeBlock/CodeBlock.doc.mjs CodeBlock/languages/powershell.ts
|
|
193
192
|
preserveAnimations preserveAnimations Layer/Layer.doc.mjs Layer/preserveAnimations.ts
|
|
194
|
-
presets presets theme/
|
|
193
|
+
presets presets theme/syntax/useSyntaxTheme.doc.mjs theme/syntax/presets.ts
|
|
195
194
|
pressGroupContext pressGroupContext hooks/useAnimatedLayout.doc.mjs hooks/pressGroupContext.ts
|
|
196
195
|
protocol protocol Markdown/Markdown.doc.mjs Markdown/plugins/protocol.ts
|
|
197
196
|
publicContext publicContext i18n/InternationalizationProvider.doc.mjs i18n/publicContext.ts
|
|
@@ -251,7 +250,7 @@ useCalendarConstraints useCalendarConstraints Calendar/useCalendarConstraints.do
|
|
|
251
250
|
useCalendarDays useCalendarDays Calendar/useCalendarDays.doc.mjs Calendar/hooks/useCalendarDays.ts
|
|
252
251
|
useCalendarNavigation useCalendarNavigation Calendar/useCalendarNavigation.doc.mjs Calendar/hooks/useCalendarNavigation.ts
|
|
253
252
|
useChatComposerTokens useChatComposerTokens Chat/Chat.doc.mjs Chat/useChatComposerTokens.ts
|
|
254
|
-
useChatDictation useChatDictation Chat/
|
|
253
|
+
useChatDictation useChatDictation Chat/useChatDictation.doc.mjs Chat/useChatDictation.ts
|
|
255
254
|
useChatNewMessages useChatNewMessages Chat/Chat.doc.mjs Chat/useChatNewMessages.ts
|
|
256
255
|
useChatPasteAsToken useChatPasteAsToken Chat/Chat.doc.mjs Chat/useChatPasteAsToken.ts
|
|
257
256
|
useChatStreamScroll useChatStreamScroll Chat/Chat.doc.mjs Chat/useChatStreamScroll.ts
|
|
@@ -295,7 +294,7 @@ useSettledOpen useSettledOpen hooks/useAnimatedLayout.doc.mjs hooks/useSettledOp
|
|
|
295
294
|
useSheetGestures useSheetGestures BottomSheet/BottomSheet.doc.mjs BottomSheet/useSheetGestures.ts
|
|
296
295
|
useSliderTouch useSliderTouch Slider/Slider.doc.mjs Slider/useSliderTouch.ts
|
|
297
296
|
useSpeechRecognition useSpeechRecognition Chat/Chat.doc.mjs Chat/useSpeechRecognition.ts
|
|
298
|
-
useSwipeAction useSwipeAction
|
|
297
|
+
useSwipeAction useSwipeAction Swipe/createSwipe.doc.mjs Swipe/useSwipeAction.ts
|
|
299
298
|
useSwitchTouch useSwitchTouch Switch/Switch.doc.mjs Switch/useSwitchTouch.ts
|
|
300
299
|
useTableCellStyles useTableCellStyles Table/Table.doc.mjs Table/useTableCellStyles.ts
|
|
301
300
|
useTableColumnSettingsState useTableColumnSettingsState Table/plugins/columnSettings/useTableColumnSettingsState.doc.mjs Table/plugins/columnSettings/useTableColumnSettingsState.tsx
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* @param {string|null} opts.lang
|
|
16
16
|
* @returns {Promise<ComponentListResponse>}
|
|
17
17
|
*/
|
|
18
|
-
export function componentList(coreDir: string,
|
|
18
|
+
export function componentList(coreDir: string, opts: {
|
|
19
19
|
cwd: string;
|
|
20
20
|
category?: string | undefined;
|
|
21
21
|
detail: "full" | "compact" | "brief";
|
|
@@ -22,7 +22,10 @@ import {
|
|
|
22
22
|
resolveImportPath,
|
|
23
23
|
resolveIntegrationImportPath,
|
|
24
24
|
} from '../../../foundation/discovery/component-discovery.mjs';
|
|
25
|
-
import {
|
|
25
|
+
import {EXACT_CODEC} from '../../../foundation/fs/exact-codec.mjs';
|
|
26
|
+
import {persistedGather} from '../../../foundation/fs/gather-cache.mjs';
|
|
27
|
+
import {CLI_ROOT, discoverExternalPackages, realDir} from '../../../foundation/fs/paths.mjs';
|
|
28
|
+
import {hostedRun} from '../../../foundation/runtime/package-root.mjs';
|
|
26
29
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
27
30
|
import {AstryxError} from '../../error.mjs';
|
|
28
31
|
import {
|
|
@@ -162,10 +165,50 @@ async function replacementEntry(replacement, detail, {zh, dense, lang}) {
|
|
|
162
165
|
* @param {string|null} opts.lang
|
|
163
166
|
* @returns {Promise<ComponentListResponse>}
|
|
164
167
|
*/
|
|
165
|
-
export async function componentList(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
)
|
|
168
|
+
export async function componentList(coreDir, opts) {
|
|
169
|
+
const {cwd, category, detail, zh, dense, lang} = opts;
|
|
170
|
+
// A function of the files it reads (Core's component folders and docs, the
|
|
171
|
+
// integrations and their docs), which the kept gather stamps: a later run
|
|
172
|
+
// with every one unchanged reads the list back.
|
|
173
|
+
return /** @type {ComponentListResponse} */ (
|
|
174
|
+
await persistedGather(
|
|
175
|
+
[
|
|
176
|
+
'component-list',
|
|
177
|
+
realDir(cwd),
|
|
178
|
+
coreDir,
|
|
179
|
+
CLI_ROOT,
|
|
180
|
+
hostedRun()?.integrations ?? [],
|
|
181
|
+
category ?? null,
|
|
182
|
+
detail,
|
|
183
|
+
zh,
|
|
184
|
+
dense,
|
|
185
|
+
lang,
|
|
186
|
+
],
|
|
187
|
+
() => componentListNow(coreDir, opts),
|
|
188
|
+
COMPONENT_LIST_CODEC,
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** The component list, kept exactly, with the envelope's shape. */
|
|
194
|
+
const COMPONENT_LIST_CODEC = {
|
|
195
|
+
...EXACT_CODEC,
|
|
196
|
+
valid: (/** @type {any} */ value) =>
|
|
197
|
+
value != null &&
|
|
198
|
+
value.type === 'component.list' &&
|
|
199
|
+
value.data != null &&
|
|
200
|
+
typeof value.data.detail === 'string' &&
|
|
201
|
+
value.data.components != null &&
|
|
202
|
+
typeof value.data.components === 'object',
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* componentList, worked out now.
|
|
207
|
+
* @param {string} coreDir
|
|
208
|
+
* @param {Parameters<typeof componentList>[1]} options
|
|
209
|
+
* @returns {Promise<ComponentListResponse>}
|
|
210
|
+
*/
|
|
211
|
+
async function componentListNow(coreDir, {cwd, category, detail, zh, dense, lang}) {
|
|
169
212
|
const components = discoverComponents(coreDir);
|
|
170
213
|
// An active integration replacement takes its Core component's slot in
|
|
171
214
|
// every list view (spec:AST-035 FR11); the Core original stays reachable
|
|
@@ -216,7 +216,7 @@ export const OFFICIAL_LIST_FILE: string;
|
|
|
216
216
|
*/
|
|
217
217
|
export const EXPERIMENTAL_KINDS: readonly ["icon-set"];
|
|
218
218
|
/** The item kinds every project reads: the catalog kinds, less experimental ones. */
|
|
219
|
-
export const STABLE_KINDS: ("
|
|
219
|
+
export const STABLE_KINDS: ("component" | "template" | "doc" | "theme" | "codemod" | "agent-doc" | "icon-set")[];
|
|
220
220
|
/** The list and detail entry fields for each item kind, in display order. */
|
|
221
221
|
export const KIND_FIELDS: readonly [readonly ["component", "components"], readonly ["template", "templates"], readonly ["doc", "docs"], readonly ["theme", "themes"], readonly ["codemod", "codemods"], readonly ["agent-doc", "agentDocs"], readonly ["icon-set", "iconSets"]];
|
|
222
222
|
export type ScannedPackage = import("./_package-scanner.mjs").ScannedPackage;
|