@astryxdesign/cli 0.7.15 → 0.7.16-canary.g22213fd
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 +6 -4
- package/api/build/_adapter.d.mts +10 -0
- package/api/build/_adapter.mjs +24 -0
- package/api/build/blocks/blocks.d.mts +1 -0
- package/api/build/blocks/blocks.mjs +18 -1
- package/api/build/kit/shell.weights.json +1 -0
- package/api/build/kit/shellcall.d.mts +26 -0
- package/api/build/kit/shellcall.mjs +87 -0
- package/api/build/kit/start.mjs +67 -4
- package/api/build/kit/weights.d.mts +15 -0
- package/api/build/kit/weights.mjs +27 -0
- package/api/component/__fixtures__/resolutions/modules.txt +1 -1
- package/api/component/_adapter.d.mts +1 -1
- package/api/component/_adapter.mjs +28 -1
- package/api/doctor/_adapter.d.mts +38 -2
- package/api/doctor/_adapter.mjs +76 -1
- package/api/doctor/built-checks.mjs +1 -1
- package/api/doctor/doctor.d.mts +26 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.mjs +156 -11
- package/api/doctor/theme-checks.mjs +163 -18
- package/api/icon/_adapter.d.mts +7 -3
- package/api/icon/_adapter.mjs +12 -3
- package/api/icon/icon.type.d.mts +15 -0
- package/api/icon/icon.type.mjs +10 -3
- package/api/icon/iconUse.doc.mjs +19 -5
- package/api/icon/list/list.mjs +7 -1
- package/api/icon/use/use.d.mts +8 -5
- package/api/icon/use/use.mjs +95 -13
- package/api/init/run/run.mjs +1 -0
- package/api/integration/add-contribution.mjs +3 -3
- package/api/integration/pack-check.mjs +14 -8
- package/api/integration/validate-integration.mjs +1 -1
- package/api/search/_adapter.mjs +15 -16
- package/api/search/_entries.d.mts +2 -1
- package/api/search/_entries.mjs +28 -1
- package/api/swizzle/_moduleGraph.mjs +1 -1
- package/api/template/template.type.d.mts +6 -2
- package/api/template/template.type.mjs +2 -1
- package/api/theme/_adapter.d.mts +5 -2
- package/api/theme/_adapter.mjs +59 -14
- package/api/theme/_fork.mjs +1 -1
- package/api/theme/build/build.d.mts +120 -32
- package/api/theme/build/build.mjs +471 -111
- package/api/theme/eject/eject.mjs +22 -1
- package/api/theme/generateTonalPalette.doc.mjs +2 -2
- package/api/theme/palette/generate/generator.mjs +141 -2
- package/api/theme/template/template.d.mts +19 -0
- package/api/theme/template/template.mjs +102 -25
- package/api/theme/theme.type.d.mts +44 -1
- package/api/theme/theme.type.mjs +23 -1
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/theme/themeEject.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTemplate.doc.mjs +9 -3
- package/api/theme-edit/_adapter.d.mts +33 -2
- package/api/theme-edit/_adapter.mjs +276 -41
- package/api/theme-edit/_check.d.mts +93 -4
- package/api/theme-edit/_check.mjs +1712 -223
- package/api/theme-edit/_color.d.mts +2 -8
- package/api/theme-edit/_color.mjs +292 -219
- package/api/theme-edit/_compiler.d.mts +1 -0
- package/api/theme-edit/_compiler.mjs +20 -1
- package/api/theme-edit/_context.d.mts +31 -1
- package/api/theme-edit/_context.mjs +445 -41
- package/api/theme-edit/_css.d.mts +60 -1
- package/api/theme-edit/_css.mjs +404 -28
- package/api/theme-edit/_edit.d.mts +25 -0
- package/api/theme-edit/_edit.mjs +1620 -154
- package/api/theme-edit/_how-commands.d.mts +11 -26
- package/api/theme-edit/_how-commands.mjs +30 -2
- package/api/theme-edit/_how-question.d.mts +15 -0
- package/api/theme-edit/_how-question.mjs +1469 -194
- package/api/theme-edit/_how.mjs +144 -30
- package/api/theme-edit/_marks.d.mts +13 -0
- package/api/theme-edit/_marks.mjs +15 -0
- package/api/theme-edit/_overview.mjs +2 -0
- package/api/theme-edit/_palette.d.mts +38 -0
- package/api/theme-edit/_palette.mjs +306 -73
- package/api/theme-edit/_parts.d.mts +33 -0
- package/api/theme-edit/_parts.mjs +138 -9
- package/api/theme-edit/_png.d.mts +18 -0
- package/api/theme-edit/_png.mjs +95 -14
- package/api/theme-edit/_preview-app.d.mts +55 -1
- package/api/theme-edit/_preview-app.mjs +1552 -101
- package/api/theme-edit/_preview.d.mts +71 -3
- package/api/theme-edit/_preview.mjs +565 -35
- package/api/theme-edit/_project.d.mts +15 -0
- package/api/theme-edit/_project.mjs +68 -13
- package/api/theme-edit/_settings.d.mts +299 -5
- package/api/theme-edit/_settings.mjs +2806 -158
- package/api/theme-edit/_tables.d.mts +24 -0
- package/api/theme-edit/_tables.mjs +212 -150
- package/api/theme-edit/_vet.d.mts +42 -0
- package/api/theme-edit/_vet.mjs +144 -0
- package/api/theme-edit/theme-edit.type.d.mts +31 -2
- package/api/theme-edit/theme-edit.type.mjs +10 -2
- package/api/theme-edit/themeEditNew.doc.mjs +1 -1
- package/api/theme-edit/themeEditPreviewApp.doc.mjs +1 -1
- package/api/theme-edit/themeEditShow.doc.mjs +11 -3
- package/api/upgrade/registry/registry.mjs +6 -1
- package/assets/codemods/parse.mjs +2 -2
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +4 -3
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/icon-sets.doc.mjs +63 -8
- package/assets/docs/tree/single-component.doc.mjs +11 -2
- package/assets/docs/tree/tokens-and-setup.doc.mjs +39 -3
- package/assets/docs.generated.json +2 -2
- package/assets/preview-app/next.config.mjs +7 -1
- package/assets/preview-app/package.json +1 -0
- package/assets/preview-app/src/app/globals.css +1 -0
- package/assets/self-audit.generated.json +1 -1
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.doc.mjs +21 -0
- package/assets/templates/blocks/components/Outline/useOutlineFromDOMHookUsage.tsx +62 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/ColumnsVirtualizationHookUsage.tsx +53 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/InfiniteScrollHookUsage.tsx +33 -0
- package/assets/templates/components.generated.json +1 -1
- package/assets/templates/pages/ai-chat/page.tsx +20 -2
- package/assets/templates/pages/dashboard/page.tsx +1 -1
- package/assets/templates/themes/neutral/neutralPalettes.generated.receipt.json +2 -0
- package/authoring/config/config.doc.mjs +8 -0
- package/authoring/config/parse.d.mts +1 -0
- package/authoring/config/parse.mjs +12 -0
- package/authoring/config/type.ts +8 -0
- package/authoring/doctypes/_schema.d.mts +52 -5
- package/authoring/doctypes/_schema.mjs +62 -7
- package/authoring/doctypes/base/type.ts +10 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/function/function.doc.mjs +6 -0
- package/authoring/doctypes/function/type.ts +3 -0
- package/authoring/doctypes/icon-set/icon-set-data.doc.mjs +3 -3
- package/authoring/doctypes/legacy.mjs +5 -1
- package/authoring/index.d.ts +1 -0
- package/authoring/shadcn/source-variants.d.mts +1 -1
- package/authoring/shadcn/source-variants.mjs +32 -10
- package/clients/cli/build-id.generated.json +1 -1
- package/clients/cli/commands/doctor.doc.mjs +2 -2
- package/clients/cli/commands/experimental/icon.mjs +61 -6
- package/clients/cli/commands/experimental/theme.mjs +244 -45
- package/clients/cli/commands/experimental-icon-use.doc.mjs +12 -5
- package/clients/cli/commands/experimental-theme-compile.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-new.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-set.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor-show.doc.mjs +3 -3
- package/clients/cli/commands/experimental-theme-editor-undo.doc.mjs +2 -2
- package/clients/cli/commands/experimental-theme-editor.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-add.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-preview-app.doc.mjs +1 -1
- package/clients/cli/commands/experimental-theme-template.doc.mjs +2 -2
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/theme-eject.doc.mjs +1 -1
- package/clients/cli/commands/theme-template.doc.mjs +3 -1
- package/clients/cli/commands/theme.doc.mjs +7 -2
- package/clients/cli/commands/theme.mjs +222 -55
- package/clients/cli/commands.generated.json +1 -1
- package/clients/cli/formatters/index.mjs +7 -4
- package/clients/cli/index.mjs +25 -5
- package/clients/cli/lib/cli-error.mjs +9 -3
- package/clients/cli/lib/component-format.mjs +27 -9
- package/clients/cli/lib/json-shim.mjs +72 -2
- package/clients/cli/manifest.generated.json +1 -1
- package/clients/cli/run.mjs +49 -0
- package/foundation/agent-docs/agent-docs-target.d.mts +2 -6
- package/foundation/agent-docs/agent-docs-target.mjs +9 -17
- package/foundation/agent-docs/agent-docs.mjs +4 -3
- package/foundation/config/config-writer.d.mts +23 -0
- package/foundation/config/config-writer.mjs +152 -58
- package/foundation/config/project.mjs +103 -16
- package/foundation/discovery/component-discovery.mjs +11 -22
- package/foundation/discovery/icon-set-checks.mjs +164 -48
- package/foundation/discovery/icon-set-discovery.d.mts +38 -5
- package/foundation/discovery/icon-set-discovery.mjs +50 -6
- package/foundation/discovery/icon-set-theme-maps.d.mts +59 -0
- package/foundation/discovery/icon-set-theme-maps.mjs +95 -0
- package/foundation/discovery/icon-set-writer.d.mts +2 -3
- package/foundation/discovery/icon-set-writer.mjs +58 -17
- package/foundation/discovery/module-exports.mjs +1 -15
- package/foundation/discovery/template-adapter.mjs +44 -19
- package/foundation/discovery/template-icons.d.mts +27 -10
- package/foundation/discovery/template-icons.mjs +142 -26
- package/foundation/discovery/template-source-tree.mjs +3 -16
- package/foundation/discovery/theme-discovery.d.mts +30 -1
- package/foundation/discovery/theme-discovery.mjs +109 -50
- package/foundation/fs/exact-codec.d.mts +35 -0
- package/foundation/fs/exact-codec.mjs +148 -0
- package/foundation/fs/gather-cache.d.mts +15 -5
- package/foundation/fs/gather-cache.mjs +129 -31
- package/foundation/fs/paths.d.mts +39 -0
- package/foundation/fs/paths.mjs +44 -11
- package/foundation/fs/read-record.mjs +11 -1
- package/foundation/integrations/autolink.d.mts +4 -2
- package/foundation/integrations/autolink.mjs +4 -2
- package/foundation/integrations/cli-requirement.d.mts +16 -5
- package/foundation/integrations/cli-requirement.mjs +27 -6
- package/foundation/integrations/contribution-fixes.mjs +1 -16
- package/foundation/integrations/may-have-integrations.mjs +7 -3
- package/foundation/integrations/missing-dependency.d.mts +9 -0
- package/foundation/integrations/missing-dependency.mjs +100 -0
- package/foundation/integrations/public-imports.mjs +1 -1
- package/foundation/render/embedded-imports.mjs +1 -1
- package/foundation/render/host-exit.d.mts +8 -0
- package/foundation/render/host-exit.mjs +11 -0
- package/foundation/render/page-host.mjs +56 -10
- package/foundation/render/page-worker.mjs +14 -0
- package/foundation/render/render-page.mjs +37 -2
- package/foundation/response/error-codes.d.mts +2 -1
- package/foundation/response/error-codes.d.ts +1 -0
- package/foundation/response/error-codes.doc.mjs +5 -0
- package/foundation/response/error-codes.mjs +3 -0
- package/foundation/response/json.d.mts +15 -0
- package/foundation/response/json.mjs +52 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/runtime/lazy-dependencies.d.mts +14 -0
- package/foundation/runtime/lazy-dependencies.mjs +82 -0
- package/foundation/xle/browser.d.mts +2 -2
- package/package.json +7 -6
|
@@ -25,7 +25,7 @@ import * as fs from 'node:fs';
|
|
|
25
25
|
import * as path from 'node:path';
|
|
26
26
|
import {randomUUID} from 'node:crypto';
|
|
27
27
|
import {AsyncLocalStorage} from 'node:async_hooks';
|
|
28
|
-
import {parse} from '
|
|
28
|
+
import {babelParse as parse} from '../runtime/lazy-dependencies.mjs';
|
|
29
29
|
import {parseIconSetData} from '../../authoring/doctypes/icon-set/parse.mjs';
|
|
30
30
|
import {ICON_NAMES} from '../../authoring/doctypes/icon-set/icon-names.mjs';
|
|
31
31
|
import {assertWithin} from '../fs/path-safety.mjs';
|
|
@@ -34,6 +34,12 @@ import {loadManifestObject} from '../integrations/integrations.mjs';
|
|
|
34
34
|
import {levenshteinDistance} from '../text/string-utils.mjs';
|
|
35
35
|
import {astryxDefinitionsByName} from './icon-definition-discovery.mjs';
|
|
36
36
|
import {generatedTypesPath} from './icon-set-paths.mjs';
|
|
37
|
+
import {
|
|
38
|
+
lookExport,
|
|
39
|
+
THEME_MAP_NAME,
|
|
40
|
+
variantThemeMapName,
|
|
41
|
+
variantThemeMaps,
|
|
42
|
+
} from './icon-set-theme-maps.mjs';
|
|
37
43
|
|
|
38
44
|
export {generatedTypesPath};
|
|
39
45
|
import {
|
|
@@ -1373,6 +1379,7 @@ const GENERATED_HEADER = [
|
|
|
1373
1379
|
'// Edit with those commands; a statement added by hand is kept.',
|
|
1374
1380
|
'// themeIcons has one entry per built-in icon definition in map (the names Core renders), not one per icon;',
|
|
1375
1381
|
'// the import lines above it give it local names for the re-exported icons.',
|
|
1382
|
+
'// themeIcons<Variant> draws the same names in that variant, for each variant an icon draws.',
|
|
1376
1383
|
];
|
|
1377
1384
|
|
|
1378
1385
|
/**
|
|
@@ -1542,8 +1549,7 @@ export function generatedTypesMatch(actual, expected, label) {
|
|
|
1542
1549
|
/** The local name the generated module gives the set's adapter. */
|
|
1543
1550
|
const ADAPTER_LOCAL = 'adaptIcon';
|
|
1544
1551
|
|
|
1545
|
-
|
|
1546
|
-
export const THEME_MAP_NAME = 'themeIcons';
|
|
1552
|
+
export {THEME_MAP_NAME};
|
|
1547
1553
|
|
|
1548
1554
|
/** How the generated module imports React for its theme map. */
|
|
1549
1555
|
const REACT_IMPORT = "import {createElement} from 'react'";
|
|
@@ -1620,7 +1626,8 @@ export function generatedTypesText(statements) {
|
|
|
1620
1626
|
const theme = /^export const (\w+) = \{(.*)\}$/u.exec(statement);
|
|
1621
1627
|
if (
|
|
1622
1628
|
theme &&
|
|
1623
|
-
(theme[1]
|
|
1629
|
+
(theme[1].startsWith(THEME_MAP_NAME) ||
|
|
1630
|
+
statement.includes('createElement('))
|
|
1624
1631
|
) {
|
|
1625
1632
|
react.add('ReactElement');
|
|
1626
1633
|
const keys = [...theme[2].matchAll(/(\w+): createElement\(/gu)].map(
|
|
@@ -1687,6 +1694,14 @@ export function generatedModuleText(
|
|
|
1687
1694
|
return relative.startsWith('.') ? relative : `./${relative}`;
|
|
1688
1695
|
};
|
|
1689
1696
|
const themeName = data.themeMap === THEME_MAP_NAME ? THEME_MAP_NAME : null;
|
|
1697
|
+
// Every theme map the module may hold, one per declared look, so a look's
|
|
1698
|
+
// map no icon draws any more is dropped as well.
|
|
1699
|
+
const themeNames = [
|
|
1700
|
+
THEME_MAP_NAME,
|
|
1701
|
+
...(data.variants ?? [])
|
|
1702
|
+
.filter(variant => variant !== data.default?.variant)
|
|
1703
|
+
.map(variantThemeMapName),
|
|
1704
|
+
];
|
|
1690
1705
|
const lines = before == null ? [] : generatedStatements(before, generated);
|
|
1691
1706
|
const lineSet = new Set(lines);
|
|
1692
1707
|
// Written once, below: the adapter's import, React's createElement, and
|
|
@@ -1712,7 +1727,8 @@ export function generatedModuleText(
|
|
|
1712
1727
|
return (
|
|
1713
1728
|
line === REACT_IMPORT ||
|
|
1714
1729
|
themeImport(line) ||
|
|
1715
|
-
(themeName != null &&
|
|
1730
|
+
(themeName != null &&
|
|
1731
|
+
themeNames.some(name => line.startsWith(`export const ${name} = `)))
|
|
1716
1732
|
);
|
|
1717
1733
|
};
|
|
1718
1734
|
const imports = new Set(
|
|
@@ -1777,22 +1793,42 @@ export function generatedModuleText(
|
|
|
1777
1793
|
}
|
|
1778
1794
|
/** @type {string[]} */
|
|
1779
1795
|
const theme = [];
|
|
1796
|
+
/** @type {Array<{name: string, entries: string[]}>} */
|
|
1797
|
+
const looks = themeName
|
|
1798
|
+
? variantThemeMaps({...data, generated}).map(({name}) => ({
|
|
1799
|
+
name,
|
|
1800
|
+
entries: [],
|
|
1801
|
+
}))
|
|
1802
|
+
: [];
|
|
1780
1803
|
/** @type {Set<string>} */
|
|
1781
1804
|
const themeImports = new Set();
|
|
1805
|
+
/**
|
|
1806
|
+
* A theme-map entry for one built-in definition, and the import that
|
|
1807
|
+
* gives a re-exported icon its local name.
|
|
1808
|
+
* @param {string} name
|
|
1809
|
+
* @param {string} exportName
|
|
1810
|
+
*/
|
|
1811
|
+
const themeEntry = (name, exportName) => {
|
|
1812
|
+
const line = exported.get(exportName);
|
|
1813
|
+
const reexport =
|
|
1814
|
+
line != null && line.startsWith('export {') ? line : undefined;
|
|
1815
|
+
if (reexport) {
|
|
1816
|
+
themeImports.add(`import${reexport.slice('export'.length)}`);
|
|
1817
|
+
}
|
|
1818
|
+
return ` ${name}: createElement(${exportName}, ${THEME_ELEMENT_PROPS}),`;
|
|
1819
|
+
};
|
|
1782
1820
|
if (themeName) {
|
|
1783
|
-
const byId = new Map(data.icons.map(icon => [icon.id, icon
|
|
1821
|
+
const byId = new Map(data.icons.map(icon => [icon.id, icon]));
|
|
1822
|
+
const lookVariants = variantThemeMaps({...data, generated});
|
|
1784
1823
|
for (const name of Object.keys(data.map ?? {}).sort()) {
|
|
1785
|
-
const
|
|
1786
|
-
if (BUILT_IN.has(name) &&
|
|
1787
|
-
theme.push(
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
if (reexport) {
|
|
1794
|
-
themeImports.add(`import${reexport.slice('export'.length)}`);
|
|
1795
|
-
}
|
|
1824
|
+
const icon = byId.get(/** @type {string} */ (data.map?.[name]));
|
|
1825
|
+
if (BUILT_IN.has(name) && icon) {
|
|
1826
|
+
theme.push(themeEntry(name, icon.export));
|
|
1827
|
+
lookVariants.forEach(({variant}, index) => {
|
|
1828
|
+
looks[index].entries.push(
|
|
1829
|
+
themeEntry(name, lookExport(icon, variant)),
|
|
1830
|
+
);
|
|
1831
|
+
});
|
|
1796
1832
|
}
|
|
1797
1833
|
}
|
|
1798
1834
|
}
|
|
@@ -1815,6 +1851,11 @@ export function generatedModuleText(
|
|
|
1815
1851
|
? [`export const ${themeName} = {`, ...theme, '};']
|
|
1816
1852
|
: [`export const ${themeName} = {};`]
|
|
1817
1853
|
: []),
|
|
1854
|
+
...looks.flatMap(({name, entries}) =>
|
|
1855
|
+
entries.length > 0
|
|
1856
|
+
? [`export const ${name} = {`, ...entries, '};']
|
|
1857
|
+
: [`export const ${name} = {};`],
|
|
1858
|
+
),
|
|
1818
1859
|
'',
|
|
1819
1860
|
].join('\n');
|
|
1820
1861
|
const typesPath = generatedTypesPath(generated);
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
|
|
20
20
|
import * as fs from 'node:fs';
|
|
21
21
|
import * as path from 'node:path';
|
|
22
|
-
import {createRequire} from 'node:module';
|
|
23
22
|
import {findInstalledPackage} from '../fs/paths.mjs';
|
|
24
23
|
import {inspectPackageExport} from './package-exports.mjs';
|
|
24
|
+
import {babelParser} from '../runtime/lazy-dependencies.mjs';
|
|
25
25
|
|
|
26
26
|
const MODULE_EXTENSIONS = [
|
|
27
27
|
'.mjs',
|
|
@@ -103,20 +103,6 @@ function moduleText(file) {
|
|
|
103
103
|
return text;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
const requireFromHere = createRequire(import.meta.url);
|
|
107
|
-
/** @type {typeof import('@babel/parser') | undefined} */
|
|
108
|
-
let parser;
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @babel/parser, loaded on first use: a run that reads no module's exports
|
|
112
|
-
* never loads it.
|
|
113
|
-
* @returns {typeof import('@babel/parser')}
|
|
114
|
-
*/
|
|
115
|
-
function babelParser() {
|
|
116
|
-
parser ??= requireFromHere('@babel/parser');
|
|
117
|
-
return /** @type {typeof import('@babel/parser')} */ (parser);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
106
|
/** @param {string} file */
|
|
121
107
|
function parseModule(file) {
|
|
122
108
|
const stamp = fileStamp(file);
|
|
@@ -24,11 +24,10 @@
|
|
|
24
24
|
|
|
25
25
|
import * as fs from 'node:fs';
|
|
26
26
|
import * as path from 'node:path';
|
|
27
|
-
import {createRequire} from 'node:module';
|
|
28
27
|
import {readDocView} from '../doc-compiler/read.mjs';
|
|
29
28
|
import {importDocModule} from '../doc-compiler/import.mjs';
|
|
30
29
|
import {readStore, storedKey} from '../doc-compiler/stored-docs.mjs';
|
|
31
|
-
import {CLI_ROOT, discoverExternalPackages} from '../fs/paths.mjs';
|
|
30
|
+
import {CLI_ROOT, discoverExternalPackages, realDir} from '../fs/paths.mjs';
|
|
32
31
|
import {listDirEntries} from '../fs/listing-cache.mjs';
|
|
33
32
|
import {CORE_PROVIDER_ID} from '../identity/providers.mjs';
|
|
34
33
|
import {Project} from '../config/project.mjs';
|
|
@@ -40,8 +39,10 @@ import {
|
|
|
40
39
|
writtenNames,
|
|
41
40
|
TEMPLATE_COMPONENTS_FILE,
|
|
42
41
|
} from './template-source-tree.mjs';
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
import {persistedGather} from '../fs/gather-cache.mjs';
|
|
43
|
+
import {EXACT_CODEC} from '../fs/exact-codec.mjs';
|
|
44
|
+
import {hostedRun} from '../runtime/package-root.mjs';
|
|
45
|
+
import {babelParser} from '../runtime/lazy-dependencies.mjs';
|
|
45
46
|
|
|
46
47
|
/** Identity used for core (built-in) templates in package-scoped listings. */
|
|
47
48
|
const CORE_PACKAGE = CORE_PROVIDER_ID;
|
|
@@ -1070,19 +1071,6 @@ function expressionUse(source, open, close) {
|
|
|
1070
1071
|
return null;
|
|
1071
1072
|
}
|
|
1072
1073
|
|
|
1073
|
-
/** @type {typeof import('@babel/parser') | undefined} */
|
|
1074
|
-
let babelParser;
|
|
1075
|
-
|
|
1076
|
-
/**
|
|
1077
|
-
* The template source parser, loaded on first use so listing templates
|
|
1078
|
-
* never pays for it.
|
|
1079
|
-
* @returns {typeof import('@babel/parser')}
|
|
1080
|
-
*/
|
|
1081
|
-
function templateSourceParser() {
|
|
1082
|
-
babelParser ??= require('@babel/parser');
|
|
1083
|
-
return /** @type {typeof import('@babel/parser')} */ (babelParser);
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
1074
|
/**
|
|
1087
1075
|
* The [start, end) range of every comment in `source`, or none when it does
|
|
1088
1076
|
* not parse as TSX.
|
|
@@ -1091,7 +1079,7 @@ function templateSourceParser() {
|
|
|
1091
1079
|
*/
|
|
1092
1080
|
function commentRanges(source) {
|
|
1093
1081
|
try {
|
|
1094
|
-
const {comments} =
|
|
1082
|
+
const {comments} = babelParser().parse(source, {
|
|
1095
1083
|
sourceType: 'module',
|
|
1096
1084
|
plugins: ['jsx', 'typescript'],
|
|
1097
1085
|
});
|
|
@@ -1569,6 +1557,18 @@ export async function discoverAllUnresolved(cwd = process.cwd()) {
|
|
|
1569
1557
|
);
|
|
1570
1558
|
}
|
|
1571
1559
|
|
|
1560
|
+
/** Template discovery's records, kept exactly, with the shape they need. */
|
|
1561
|
+
const TEMPLATE_SOURCES_CODEC = {
|
|
1562
|
+
...EXACT_CODEC,
|
|
1563
|
+
valid: (/** @type {any} */ value) =>
|
|
1564
|
+
value != null &&
|
|
1565
|
+
Array.isArray(value.templates) &&
|
|
1566
|
+
Array.isArray(value.errors) &&
|
|
1567
|
+
value.templates.every(
|
|
1568
|
+
(/** @type {any} */ t) => t != null && typeof t.name === 'string',
|
|
1569
|
+
),
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1572
1572
|
/**
|
|
1573
1573
|
* Resolve replacement declarations while retaining package-addressable entries
|
|
1574
1574
|
* that are shadowed or rejected in the default discovery view.
|
|
@@ -1576,6 +1576,31 @@ export async function discoverAllUnresolved(cwd = process.cwd()) {
|
|
|
1576
1576
|
* @returns {Promise<{templates: DiscoveredTemplate[], errors: Array<TemplateDiscoveryError | TemplateReplacementError>}>}
|
|
1577
1577
|
*/
|
|
1578
1578
|
async function resolveAllSources(cwd = process.cwd()) {
|
|
1579
|
+
// A function of the files discovery reads, which the kept gather stamps:
|
|
1580
|
+
// a later run with every one unchanged reads the records back.
|
|
1581
|
+
return /** @type {Awaited<ReturnType<typeof resolveAllSourcesNow>>} */ (
|
|
1582
|
+
await persistedGather(
|
|
1583
|
+
// The folder, and the copy of the CLI that answers with the
|
|
1584
|
+
// integrations a host approves: outside a project the integrations
|
|
1585
|
+
// beside the answering copy load too.
|
|
1586
|
+
[
|
|
1587
|
+
'template-sources',
|
|
1588
|
+
realDir(cwd),
|
|
1589
|
+
CLI_ROOT,
|
|
1590
|
+
hostedRun()?.integrations ?? [],
|
|
1591
|
+
],
|
|
1592
|
+
() => resolveAllSourcesNow(cwd),
|
|
1593
|
+
TEMPLATE_SOURCES_CODEC,
|
|
1594
|
+
)
|
|
1595
|
+
);
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
/**
|
|
1599
|
+
* resolveAllSources, worked out now.
|
|
1600
|
+
* @param {string} cwd
|
|
1601
|
+
* @returns {Promise<{templates: DiscoveredTemplate[], errors: Array<TemplateDiscoveryError | TemplateReplacementError>}>}
|
|
1602
|
+
*/
|
|
1603
|
+
async function resolveAllSourcesNow(cwd) {
|
|
1579
1604
|
const discovered = await discoverAllSources(cwd);
|
|
1580
1605
|
const replacementErrors = discovered.errors.filter(
|
|
1581
1606
|
error => error.replacementTarget != null,
|
|
@@ -2079,7 +2104,7 @@ function topLevelBindings(src) {
|
|
|
2079
2104
|
const astryxImports = new Map();
|
|
2080
2105
|
let program;
|
|
2081
2106
|
try {
|
|
2082
|
-
program =
|
|
2107
|
+
program = babelParser().parse(src, {
|
|
2083
2108
|
sourceType: 'module',
|
|
2084
2109
|
plugins: ['jsx', 'typescript'],
|
|
2085
2110
|
errorRecovery: true,
|
|
@@ -35,12 +35,16 @@ export function placeholderUses(source: string): Array<{
|
|
|
35
35
|
meanings: string[] | null;
|
|
36
36
|
}> | null;
|
|
37
37
|
/**
|
|
38
|
-
* The commands that give a placeholder icon a real one.
|
|
38
|
+
* The commands that give a placeholder icon a real one. The `use` command
|
|
39
|
+
* keeps the list's backups and the project's look, and adds a backup after
|
|
40
|
+
* them.
|
|
39
41
|
* @param {string[]} definitions
|
|
40
42
|
* @param {string} main the main set's name as the list writes it
|
|
43
|
+
* @param {readonly string[]} [backups] the list's backups as it writes them
|
|
44
|
+
* @param {string | null} [variant] the project's look
|
|
41
45
|
* @returns {string[]}
|
|
42
46
|
*/
|
|
43
|
-
export function placeholderFixes(definitions: string[], main: string): string[];
|
|
47
|
+
export function placeholderFixes(definitions: string[], main: string, backups?: readonly string[], variant?: string | null): string[];
|
|
44
48
|
/**
|
|
45
49
|
* The target-set icon whose reviewed `matches` name the source icon with one
|
|
46
50
|
* of `confidences`, ties broken by the order the confidences are given and
|
|
@@ -177,13 +181,16 @@ export function mapTemplateIcons(source: string, { sets, choice }: {
|
|
|
177
181
|
* @property {string[]} [dropped] the library's sizing props (`size`,
|
|
178
182
|
* `strokeWidth`, `absoluteStrokeWidth`) removed from its elements: an icon
|
|
179
183
|
* set's icons take their size from CSS
|
|
180
|
-
* @property {'match' | 'definition'} by `match`: a reviewed
|
|
184
|
+
* @property {'match' | 'definition' | 'variant'} by `match`: a reviewed
|
|
181
185
|
* `exact` or `strong` match in the project set's data names the source
|
|
182
186
|
* icon; `definition`: the target's `map` names it for the Astryx icon
|
|
183
|
-
* definition the source draws
|
|
187
|
+
* definition the source draws; `variant`: the source is already this icon
|
|
188
|
+
* of a set in the project's list, in another look, and moves to the look
|
|
189
|
+
* the project names
|
|
184
190
|
* @property {{asked: string, used: string | null}} [variant] present when the
|
|
185
|
-
*
|
|
186
|
-
*
|
|
191
|
+
* look asked for, the project's variant or else the look the source draws,
|
|
192
|
+
* is one the target set's icon does not have: that look, and the look used
|
|
193
|
+
* (the set's default look)
|
|
187
194
|
*/
|
|
188
195
|
/**
|
|
189
196
|
* One icon no set in the project's list has: each of its uses in the copied
|
|
@@ -227,6 +234,8 @@ export function mapTemplateIcons(source: string, { sets, choice }: {
|
|
|
227
234
|
* @property {string[]} [order] the main set and each backup, as
|
|
228
235
|
* `<package>/<set>`, in the order icons are looked up; present when the
|
|
229
236
|
* project lists backups
|
|
237
|
+
* @property {string} [variant] the look the project's icons draw, as
|
|
238
|
+
* `experimental.iconVariant` names it; present when it is set
|
|
230
239
|
* @property {string} reason
|
|
231
240
|
* @property {MappedIcon[]} mapped
|
|
232
241
|
* @property {PlaceholderIcon[]} placeholder
|
|
@@ -297,13 +306,16 @@ export type MappedIcon = {
|
|
|
297
306
|
* `match`: a reviewed
|
|
298
307
|
* `exact` or `strong` match in the project set's data names the source
|
|
299
308
|
* icon; `definition`: the target's `map` names it for the Astryx icon
|
|
300
|
-
* definition the source draws
|
|
309
|
+
* definition the source draws; `variant`: the source is already this icon
|
|
310
|
+
* of a set in the project's list, in another look, and moves to the look
|
|
311
|
+
* the project names
|
|
301
312
|
*/
|
|
302
|
-
by: "match" | "definition";
|
|
313
|
+
by: "match" | "definition" | "variant";
|
|
303
314
|
/**
|
|
304
315
|
* present when the
|
|
305
|
-
*
|
|
306
|
-
*
|
|
316
|
+
* look asked for, the project's variant or else the look the source draws,
|
|
317
|
+
* is one the target set's icon does not have: that look, and the look used
|
|
318
|
+
* (the set's default look)
|
|
307
319
|
*/
|
|
308
320
|
variant?: {
|
|
309
321
|
asked: string;
|
|
@@ -410,6 +422,11 @@ export type TemplateIconsReport = {
|
|
|
410
422
|
* project lists backups
|
|
411
423
|
*/
|
|
412
424
|
order?: string[] | undefined;
|
|
425
|
+
/**
|
|
426
|
+
* the look the project's icons draw, as
|
|
427
|
+
* `experimental.iconVariant` names it; present when it is set
|
|
428
|
+
*/
|
|
429
|
+
variant?: string | undefined;
|
|
413
430
|
reason: string;
|
|
414
431
|
mapped: MappedIcon[];
|
|
415
432
|
placeholder: PlaceholderIcon[];
|