@astryxdesign/cli 0.7.8 → 0.7.9-canary.07992bb
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/discover/_adapter.d.mts +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/search/_adapter.d.mts +3 -1
- package/api/search/_adapter.mjs +12 -2
- package/api/search/_main-searcher.mjs +1 -1
- package/api/search/_result.d.mts +5 -5
- package/api/search/search.d.mts +4 -2
- package/api/search/search.mjs +9 -8
- 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/docs/tree/calendar-systems.doc.mjs +146 -0
- package/assets/docs/tree/calendars.doc.mjs +46 -0
- package/assets/docs/tree/i18n-calendars.doc.mjs +51 -0
- package/assets/docs/tree/internationalization.doc.mjs +3 -3
- 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/useImageModeHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Hooks/useImageModeHookUsage.tsx +55 -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/templates/blocks/components/PowerSearch/PowerSearchContentSearch.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchFullFeatured.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchPresetFilters.tsx +8 -7
- package/assets/templates/blocks/components/PowerSearch/PowerSearchSearchWithTable.tsx +12 -10
- package/assets/templates/blocks/components/PowerSearch/PowerSearchShowcase.tsx +8 -7
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.doc.mjs +2 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +2 -2
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +0 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.doc.mjs +2 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +0 -2
- package/assets/templates/pages/table-inbox/page.tsx +11 -8
- package/assets/templates/pages/work-item-detail/page.tsx +6 -2
- package/assets/theme.template.ts +1 -1
- package/authoring/debug/parse.d.mts +2 -2
- package/clients/cli/index.mjs +11 -6
- package/foundation/agent-docs/agent-docs-target.d.mts +49 -0
- package/foundation/agent-docs/agent-docs-target.mjs +201 -0
- package/foundation/agent-docs/agent-docs.d.mts +1 -38
- package/foundation/agent-docs/agent-docs.mjs +16 -181
- package/foundation/config/config-path.d.mts +13 -0
- package/foundation/config/config-path.mjs +42 -0
- package/foundation/config/project.d.mts +1 -10
- package/foundation/config/project.mjs +4 -26
- package/foundation/discovery/component-discovery.mjs +39 -4
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/icon-set-paths.d.mts +18 -0
- package/foundation/discovery/icon-set-paths.mjs +23 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -7
- package/foundation/discovery/icon-set-writer.mjs +3 -12
- package/foundation/fs/module-loader.d.mts +2 -8
- package/foundation/fs/module-loader.mjs +3 -12
- package/foundation/fs/present-files.d.mts +11 -0
- package/foundation/fs/present-files.mjs +25 -0
- package/foundation/integrations/autolink.d.mts +2 -21
- package/foundation/integrations/autolink.mjs +6 -42
- package/foundation/integrations/contribution-fixes.mjs +26 -3
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/integrations/installed-package.d.mts +36 -0
- package/foundation/integrations/installed-package.mjs +57 -0
- package/foundation/integrations/integrations.d.mts +3 -75
- package/foundation/integrations/integrations.mjs +3 -16
- package/foundation/integrations/manifest-paths.d.mts +13 -0
- package/foundation/integrations/manifest-paths.mjs +31 -0
- package/foundation/release/cache.d.mts +11 -4
- package/foundation/release/cache.mjs +15 -7
- package/foundation/runtime/locked-versions.mjs +1 -1
- package/foundation/runtime/package-set.mjs +1 -1
- package/package.json +9 -9
|
@@ -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: ("template" | "component" | "
|
|
219
|
+
export const STABLE_KINDS: ("template" | "component" | "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;
|
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}`)}.`,
|
|
@@ -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
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* domain the query wants. Its weights are static numbers in
|
|
9
9
|
* _main-searcher.weights.json.
|
|
10
10
|
* @input {query, options} and the gathered catalog with its static data
|
|
11
|
-
* @output the search response, the lexical response's shape and
|
|
11
|
+
* @output the search response, the lexical response's shape and count
|
|
12
12
|
* @position api/search; a child of the root dispatcher in tree.mjs
|
|
13
13
|
*/
|
|
14
14
|
|
package/api/search/_result.d.mts
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* (spec AST-081 FR3).
|
|
18
18
|
*/
|
|
19
19
|
export function toResult(c: Candidate, score: number, reason: string, matchedTerms: number, queryTerms: number, outside?: boolean): {
|
|
20
|
-
domain: "template" | "component" | "
|
|
20
|
+
domain: "template" | "component" | "doc" | "theme" | "hook";
|
|
21
21
|
name: string;
|
|
22
22
|
package: string | undefined;
|
|
23
23
|
score: number;
|
|
@@ -27,7 +27,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
27
27
|
deprecated?: import("../../authoring/index.js").ComponentDeprecation | undefined;
|
|
28
28
|
import: string | undefined;
|
|
29
29
|
command: string;
|
|
30
|
-
domain: "template" | "component" | "
|
|
30
|
+
domain: "template" | "component" | "doc" | "theme" | "hook";
|
|
31
31
|
name: string;
|
|
32
32
|
package: string | undefined;
|
|
33
33
|
score: number;
|
|
@@ -39,7 +39,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
39
39
|
command: string;
|
|
40
40
|
section?: string | undefined;
|
|
41
41
|
name: string;
|
|
42
|
-
domain: "template" | "component" | "
|
|
42
|
+
domain: "template" | "component" | "doc" | "theme" | "hook";
|
|
43
43
|
package: string | undefined;
|
|
44
44
|
score: number;
|
|
45
45
|
reason: string;
|
|
@@ -48,7 +48,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
48
48
|
displayName: string | undefined;
|
|
49
49
|
kind: "page" | "block" | undefined;
|
|
50
50
|
command: string;
|
|
51
|
-
domain: "template" | "component" | "
|
|
51
|
+
domain: "template" | "component" | "doc" | "theme" | "hook";
|
|
52
52
|
name: string;
|
|
53
53
|
package: string | undefined;
|
|
54
54
|
score: number;
|
|
@@ -57,7 +57,7 @@ export function toResult(c: Candidate, score: number, reason: string, matchedTer
|
|
|
57
57
|
} | {
|
|
58
58
|
displayName: string | undefined;
|
|
59
59
|
command: string;
|
|
60
|
-
domain: "template" | "component" | "
|
|
60
|
+
domain: "template" | "component" | "doc" | "theme" | "hook";
|
|
61
61
|
name: string;
|
|
62
62
|
package: string | undefined;
|
|
63
63
|
score: number;
|
package/api/search/search.d.mts
CHANGED
|
@@ -13,12 +13,14 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export function search(query: string, options?: {
|
|
15
15
|
cwd?: string | undefined;
|
|
16
|
-
type?: "template" | "component" | "
|
|
16
|
+
type?: "template" | "component" | "doc" | "theme" | "hook" | undefined;
|
|
17
17
|
limit?: number | undefined;
|
|
18
18
|
}): Promise<import("./search.type.mjs").SearchResponse>;
|
|
19
19
|
/**
|
|
20
20
|
* The lexical ranker alone: keyword and fuzzy scoring of every candidate.
|
|
21
|
-
* `build` ranks from it.
|
|
21
|
+
* `build` ranks from it. It ranks the candidates search gathers, reused the
|
|
22
|
+
* same way. A later query in the same folder, for the same `type`, gathers
|
|
23
|
+
* again only when an input changed.
|
|
22
24
|
*
|
|
23
25
|
* @param {string} query
|
|
24
26
|
* @param {{cwd?: string, type?: 'component'|'hook'|'doc'|'template'|'theme', limit?: number}} [options]
|
package/api/search/search.mjs
CHANGED
|
@@ -19,11 +19,7 @@ import {
|
|
|
19
19
|
runWithDocPackageManager,
|
|
20
20
|
} from '../../foundation/env/package-manager.mjs';
|
|
21
21
|
import {withListingCache} from '../../foundation/fs/listing-cache.mjs';
|
|
22
|
-
import {
|
|
23
|
-
gatherCandidates,
|
|
24
|
-
gatherCandidatesReused,
|
|
25
|
-
loadSearchData,
|
|
26
|
-
} from './_adapter.mjs';
|
|
22
|
+
import {gatherCandidatesReused, loadSearchData} from './_adapter.mjs';
|
|
27
23
|
import {rankLexical} from './_lexical.mjs';
|
|
28
24
|
import {checkSearchArgs} from './_result.mjs';
|
|
29
25
|
import {runTree} from '../../foundation/route/route.mjs';
|
|
@@ -76,7 +72,10 @@ async function searchRead(query, options) {
|
|
|
76
72
|
await runTree(
|
|
77
73
|
SEARCH_TREE,
|
|
78
74
|
{query, options},
|
|
79
|
-
{
|
|
75
|
+
{
|
|
76
|
+
...(await gatherCandidatesReused(options)),
|
|
77
|
+
data: loadSearchData(),
|
|
78
|
+
},
|
|
80
79
|
)
|
|
81
80
|
),
|
|
82
81
|
options.cwd ?? process.cwd(),
|
|
@@ -87,7 +86,9 @@ async function searchRead(query, options) {
|
|
|
87
86
|
|
|
88
87
|
/**
|
|
89
88
|
* The lexical ranker alone: keyword and fuzzy scoring of every candidate.
|
|
90
|
-
* `build` ranks from it.
|
|
89
|
+
* `build` ranks from it. It ranks the candidates search gathers, reused the
|
|
90
|
+
* same way. A later query in the same folder, for the same `type`, gathers
|
|
91
|
+
* again only when an input changed.
|
|
91
92
|
*
|
|
92
93
|
* @param {string} query
|
|
93
94
|
* @param {{cwd?: string, type?: 'component'|'hook'|'doc'|'template'|'theme', limit?: number}} [options]
|
|
@@ -109,7 +110,7 @@ export async function searchCore(query, options = {}) {
|
|
|
109
110
|
async function searchCoreRead(query, options) {
|
|
110
111
|
return withListingCache(async () =>
|
|
111
112
|
linkSearchResponse(
|
|
112
|
-
rankLexical(query, options, await
|
|
113
|
+
rankLexical(query, options, await gatherCandidatesReused(options)),
|
|
113
114
|
options.cwd ?? process.cwd(),
|
|
114
115
|
),
|
|
115
116
|
);
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The bindings one Core provides: the namespaces interception spreads, the
|
|
6
|
+
* functions the build calls, and why the import failed, if it did.
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* themeModule: any,
|
|
9
|
+
* rootModule: (() => any) | null,
|
|
10
|
+
* importError: any,
|
|
11
|
+
* defineTheme: any,
|
|
12
|
+
* generateThemeRulesSplit: any,
|
|
13
|
+
* generateOnMediaCSS: any,
|
|
14
|
+
* generateAdaptationCSS: any,
|
|
15
|
+
* }} CoreBindings
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A Core's root namespace, loaded on first use. The root entry loads all of
|
|
19
|
+
* Core and React, and only a theme that imports the root specifier needs it.
|
|
20
|
+
* Requiring the file an import resolves to returns the namespace `import()`
|
|
21
|
+
* gives. A root that cannot be loaded gives null, and interception then hands
|
|
22
|
+
* the theme namespace in its place. A root that only `import()` can load
|
|
23
|
+
* throws instead: one that awaits at its top level, or any root when Node runs
|
|
24
|
+
* without require(esm).
|
|
25
|
+
* @param {() => string | null} resolveFile
|
|
26
|
+
* @returns {() => any}
|
|
27
|
+
*/
|
|
28
|
+
export function lazyRootModule(resolveFile: () => string | null): () => any;
|
|
4
29
|
/**
|
|
5
30
|
* Why `theme build` has no Core to generate with, and the fix for where it
|
|
6
31
|
* ran: the Astryx repository builds Core, an app installs it, and an installed
|
|
@@ -170,7 +195,7 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
170
195
|
*/
|
|
171
196
|
export type CoreBindings = {
|
|
172
197
|
themeModule: any;
|
|
173
|
-
rootModule: any;
|
|
198
|
+
rootModule: (() => any) | null;
|
|
174
199
|
importError: any;
|
|
175
200
|
defineTheme: any;
|
|
176
201
|
generateThemeRulesSplit: any;
|
|
@@ -132,12 +132,13 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
132
132
|
*/
|
|
133
133
|
/** @type {any} */ let _coreThemeModule = null;
|
|
134
134
|
/**
|
|
135
|
-
* The `@astryxdesign/core` ROOT namespace,
|
|
135
|
+
* The `@astryxdesign/core` ROOT namespace, loaded separately because it
|
|
136
136
|
* exports far more than the theme subpath. Interception must hand a theme file
|
|
137
137
|
* that imports a component from the root the root's own exports, not the theme
|
|
138
|
-
* namespace wearing its name.
|
|
138
|
+
* namespace wearing its name. It loads on first use: see lazyRootModule.
|
|
139
|
+
* @type {(() => any) | null}
|
|
139
140
|
*/
|
|
140
|
-
|
|
141
|
+
let _coreRootModule = null;
|
|
141
142
|
/** @type {any} */ let _coreImportError = null;
|
|
142
143
|
|
|
143
144
|
/**
|
|
@@ -145,7 +146,7 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
145
146
|
* functions the build calls, and why the import failed, if it did.
|
|
146
147
|
* @typedef {{
|
|
147
148
|
* themeModule: any,
|
|
148
|
-
* rootModule: any,
|
|
149
|
+
* rootModule: (() => any) | null,
|
|
149
150
|
* importError: any,
|
|
150
151
|
* defineTheme: any,
|
|
151
152
|
* generateThemeRulesSplit: any,
|
|
@@ -154,6 +155,47 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
154
155
|
* }} CoreBindings
|
|
155
156
|
*/
|
|
156
157
|
|
|
158
|
+
/**
|
|
159
|
+
* A Core's root namespace, loaded on first use. The root entry loads all of
|
|
160
|
+
* Core and React, and only a theme that imports the root specifier needs it.
|
|
161
|
+
* Requiring the file an import resolves to returns the namespace `import()`
|
|
162
|
+
* gives. A root that cannot be loaded gives null, and interception then hands
|
|
163
|
+
* the theme namespace in its place. A root that only `import()` can load
|
|
164
|
+
* throws instead: one that awaits at its top level, or any root when Node runs
|
|
165
|
+
* without require(esm).
|
|
166
|
+
* @param {() => string | null} resolveFile
|
|
167
|
+
* @returns {() => any}
|
|
168
|
+
*/
|
|
169
|
+
export function lazyRootModule(resolveFile) {
|
|
170
|
+
/** @type {{namespace: any} | null} */
|
|
171
|
+
let loaded = null;
|
|
172
|
+
return () => {
|
|
173
|
+
if (loaded) return loaded.namespace;
|
|
174
|
+
let namespace = null;
|
|
175
|
+
let file = null;
|
|
176
|
+
try {
|
|
177
|
+
file = resolveFile();
|
|
178
|
+
} catch {
|
|
179
|
+
// A Core whose root entry does not resolve falls back below.
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
if (file) namespace = createRequire(import.meta.url)(file);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
const code = /** @type {any} */ (error)?.code;
|
|
185
|
+
// The theme namespace would stand in for the root's own exports here.
|
|
186
|
+
if (code === 'ERR_REQUIRE_ASYNC_MODULE' || code === 'ERR_REQUIRE_ESM') {
|
|
187
|
+
throw new Error(
|
|
188
|
+
`The @astryxdesign/core root entry at ${file} cannot be loaded with require() (${code}), so a theme that imports it cannot be built.`,
|
|
189
|
+
{cause: error},
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
// A Core without a usable root entry still builds themes.
|
|
193
|
+
}
|
|
194
|
+
loaded = {namespace};
|
|
195
|
+
return namespace;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
157
199
|
/**
|
|
158
200
|
* Import the CLI's own Core: the `@astryxdesign/core` this module resolves.
|
|
159
201
|
* Never throws. A failed import is kept as `importError`, so the build can
|
|
@@ -178,12 +220,9 @@ async function importCliCore() {
|
|
|
178
220
|
core.generateThemeRulesSplit = coreTheme.generateThemeRulesSplit;
|
|
179
221
|
core.generateOnMediaCSS = coreTheme.generateOnMediaCSS;
|
|
180
222
|
core.generateAdaptationCSS = coreTheme.generateAdaptationCSS;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
// A core without a usable root entry still builds themes; interception
|
|
185
|
-
// falls back to the theme namespace for the root specifier.
|
|
186
|
-
}
|
|
223
|
+
core.rootModule = lazyRootModule(() =>
|
|
224
|
+
fileURLToPath(import.meta.resolve('@astryxdesign/core')),
|
|
225
|
+
);
|
|
187
226
|
} catch (e) {
|
|
188
227
|
// Capture the reason so the theme action can surface a precise, actionable
|
|
189
228
|
// error. The hard failure happens when `theme build` runs.
|
|
@@ -350,18 +389,10 @@ async function loadProjectCore(cwd, cliCore, {projectOnly = false} = {}) {
|
|
|
350
389
|
ERROR_CODES.ERR_CORE_INCOMPATIBLE,
|
|
351
390
|
);
|
|
352
391
|
}
|
|
353
|
-
let rootModule = null;
|
|
354
392
|
const rootFile = importTarget(dir, '.');
|
|
355
|
-
if (rootFile) {
|
|
356
|
-
try {
|
|
357
|
-
rootModule = await import(pathToFileURL(rootFile).href);
|
|
358
|
-
} catch {
|
|
359
|
-
// As with the CLI's own import, the theme namespace stands in for it.
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
393
|
return {
|
|
363
394
|
themeModule,
|
|
364
|
-
rootModule,
|
|
395
|
+
rootModule: lazyRootModule(() => rootFile),
|
|
365
396
|
importError: null,
|
|
366
397
|
defineTheme: themeModule.defineTheme,
|
|
367
398
|
generateThemeRulesSplit: themeModule.generateThemeRulesSplit,
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* standalone builds with current Core do not.
|
|
17
17
|
*
|
|
18
18
|
* @param {any} coreThemeModule - The installed `@astryxdesign/core/theme` namespace.
|
|
19
|
-
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace
|
|
19
|
+
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace,
|
|
20
|
+
* or a function that loads it. A function is called once, on first use.
|
|
20
21
|
* @returns {CoreInterception}
|
|
21
22
|
*/
|
|
22
23
|
export function interceptCore(coreThemeModule: any, coreRootModule?: any): CoreInterception;
|
|
@@ -236,7 +236,8 @@ function mergeGenerativeAxes(inherited, own) {
|
|
|
236
236
|
* standalone builds with current Core do not.
|
|
237
237
|
*
|
|
238
238
|
* @param {any} coreThemeModule - The installed `@astryxdesign/core/theme` namespace.
|
|
239
|
-
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace
|
|
239
|
+
* @param {any} [coreRootModule] - The installed `@astryxdesign/core` namespace,
|
|
240
|
+
* or a function that loads it. A function is called once, on first use.
|
|
240
241
|
* @returns {CoreInterception}
|
|
241
242
|
*/
|
|
242
243
|
export function interceptCore(coreThemeModule, coreRootModule) {
|
|
@@ -287,14 +288,31 @@ export function interceptCore(coreThemeModule, coreRootModule) {
|
|
|
287
288
|
};
|
|
288
289
|
};
|
|
289
290
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
291
|
+
const modules = {
|
|
292
|
+
'@astryxdesign/core/theme': wrapNamespace(coreThemeModule),
|
|
293
|
+
};
|
|
294
|
+
/** @type {any} */
|
|
295
|
+
let wrappedRoot;
|
|
296
|
+
// jiti reads a virtual module only when a theme imports its specifier. So
|
|
297
|
+
// the root, which loads all of Core, loads only for a theme that asks.
|
|
298
|
+
Object.defineProperty(modules, '@astryxdesign/core', {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
configurable: true,
|
|
301
|
+
get() {
|
|
302
|
+
const root =
|
|
303
|
+
typeof coreRootModule === 'function'
|
|
304
|
+
? coreRootModule()
|
|
305
|
+
: coreRootModule;
|
|
293
306
|
// Falls back to the theme namespace only when the root could not be
|
|
294
307
|
// imported at all; a partial root is better than none, and a core
|
|
295
308
|
// missing its own root entry is already broken.
|
|
296
|
-
|
|
309
|
+
wrappedRoot ??= wrapNamespace(root ?? coreThemeModule);
|
|
310
|
+
return wrappedRoot;
|
|
297
311
|
},
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
modules,
|
|
298
316
|
|
|
299
317
|
// prettier-ignore
|
|
300
318
|
observed(theme) { return wasObserved(theme, byReference); },
|