@lynx-js/genui 0.0.1-rc.0
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/LICENSE +202 -0
- package/README.md +170 -0
- package/a2ui/README.md +140 -0
- package/a2ui/dist/catalog/Button/catalog.json +156 -0
- package/a2ui/dist/catalog/Button/index.d.ts +35 -0
- package/a2ui/dist/catalog/Button/index.js +35 -0
- package/a2ui/dist/catalog/Button/index.js.map +1 -0
- package/a2ui/dist/catalog/Card/catalog.json +24 -0
- package/a2ui/dist/catalog/Card/index.d.ts +11 -0
- package/a2ui/dist/catalog/Card/index.js +19 -0
- package/a2ui/dist/catalog/Card/index.js.map +1 -0
- package/a2ui/dist/catalog/CheckBox/catalog.json +170 -0
- package/a2ui/dist/catalog/CheckBox/index.d.ts +32 -0
- package/a2ui/dist/catalog/CheckBox/index.js +24 -0
- package/a2ui/dist/catalog/CheckBox/index.js.map +1 -0
- package/a2ui/dist/catalog/Column/catalog.json +57 -0
- package/a2ui/dist/catalog/Column/index.d.ts +15 -0
- package/a2ui/dist/catalog/Column/index.js +55 -0
- package/a2ui/dist/catalog/Column/index.js.map +1 -0
- package/a2ui/dist/catalog/Divider/catalog.json +14 -0
- package/a2ui/dist/catalog/Divider/index.d.ts +9 -0
- package/a2ui/dist/catalog/Divider/index.js +8 -0
- package/a2ui/dist/catalog/Divider/index.js.map +1 -0
- package/a2ui/dist/catalog/Icon/catalog.json +45 -0
- package/a2ui/dist/catalog/Icon/index.d.ts +14 -0
- package/a2ui/dist/catalog/Icon/index.js +11 -0
- package/a2ui/dist/catalog/Icon/index.js.map +1 -0
- package/a2ui/dist/catalog/Image/catalog.json +62 -0
- package/a2ui/dist/catalog/Image/index.d.ts +16 -0
- package/a2ui/dist/catalog/Image/index.js +30 -0
- package/a2ui/dist/catalog/Image/index.js.map +1 -0
- package/a2ui/dist/catalog/LineChart/catalog.json +98 -0
- package/a2ui/dist/catalog/LineChart/index.d.ts +31 -0
- package/a2ui/dist/catalog/LineChart/index.js +195 -0
- package/a2ui/dist/catalog/LineChart/index.js.map +1 -0
- package/a2ui/dist/catalog/List/catalog.json +52 -0
- package/a2ui/dist/catalog/List/index.d.ts +15 -0
- package/a2ui/dist/catalog/List/index.js +53 -0
- package/a2ui/dist/catalog/List/index.js.map +1 -0
- package/a2ui/dist/catalog/Modal/catalog.json +18 -0
- package/a2ui/dist/catalog/Modal/index.d.ts +12 -0
- package/a2ui/dist/catalog/Modal/index.js +33 -0
- package/a2ui/dist/catalog/Modal/index.js.map +1 -0
- package/a2ui/dist/catalog/PieChart/catalog.json +87 -0
- package/a2ui/dist/catalog/PieChart/index.d.ts +37 -0
- package/a2ui/dist/catalog/PieChart/index.js +131 -0
- package/a2ui/dist/catalog/PieChart/index.js.map +1 -0
- package/a2ui/dist/catalog/RadioGroup/catalog.json +184 -0
- package/a2ui/dist/catalog/RadioGroup/index.d.ts +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js +36 -0
- package/a2ui/dist/catalog/RadioGroup/index.js.map +1 -0
- package/a2ui/dist/catalog/Row/catalog.json +57 -0
- package/a2ui/dist/catalog/Row/index.d.ts +15 -0
- package/a2ui/dist/catalog/Row/index.js +28 -0
- package/a2ui/dist/catalog/Row/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/catalog.json +183 -0
- package/a2ui/dist/catalog/Slider/index.d.ts +41 -0
- package/a2ui/dist/catalog/Slider/index.js +39 -0
- package/a2ui/dist/catalog/Slider/index.js.map +1 -0
- package/a2ui/dist/catalog/Slider/utils.d.ts +11 -0
- package/a2ui/dist/catalog/Slider/utils.js +58 -0
- package/a2ui/dist/catalog/Slider/utils.js.map +1 -0
- package/a2ui/dist/catalog/Tabs/catalog.json +28 -0
- package/a2ui/dist/catalog/Tabs/index.d.ts +12 -0
- package/a2ui/dist/catalog/Tabs/index.js +32 -0
- package/a2ui/dist/catalog/Tabs/index.js.map +1 -0
- package/a2ui/dist/catalog/Text/catalog.json +74 -0
- package/a2ui/dist/catalog/Text/index.d.ts +18 -0
- package/a2ui/dist/catalog/Text/index.js +27 -0
- package/a2ui/dist/catalog/Text/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/catalog.json +147 -0
- package/a2ui/dist/catalog/TextField/index.d.ts +35 -0
- package/a2ui/dist/catalog/TextField/index.js +43 -0
- package/a2ui/dist/catalog/TextField/index.js.map +1 -0
- package/a2ui/dist/catalog/TextField/utils.d.ts +7 -0
- package/a2ui/dist/catalog/TextField/utils.js +51 -0
- package/a2ui/dist/catalog/TextField/utils.js.map +1 -0
- package/a2ui/dist/catalog/defineCatalog.d.ts +119 -0
- package/a2ui/dist/catalog/defineCatalog.js +196 -0
- package/a2ui/dist/catalog/defineCatalog.js.map +1 -0
- package/a2ui/dist/catalog/index.d.ts +20 -0
- package/a2ui/dist/catalog/index.js +26 -0
- package/a2ui/dist/catalog/index.js.map +1 -0
- package/a2ui/dist/catalog/utils/chart.d.ts +3 -0
- package/a2ui/dist/catalog/utils/chart.js +28 -0
- package/a2ui/dist/catalog/utils/chart.js.map +1 -0
- package/a2ui/dist/functions/index.d.ts +19 -0
- package/a2ui/dist/functions/index.js +87 -0
- package/a2ui/dist/functions/index.js.map +1 -0
- package/a2ui/dist/index.d.ts +11 -0
- package/a2ui/dist/index.js +35 -0
- package/a2ui/dist/index.js.map +1 -0
- package/a2ui/dist/react/A2UI.d.ts +77 -0
- package/a2ui/dist/react/A2UI.js +159 -0
- package/a2ui/dist/react/A2UI.js.map +1 -0
- package/a2ui/dist/react/A2UIProvider.d.ts +25 -0
- package/a2ui/dist/react/A2UIProvider.js +20 -0
- package/a2ui/dist/react/A2UIProvider.js.map +1 -0
- package/a2ui/dist/react/A2UIRenderer.d.ts +34 -0
- package/a2ui/dist/react/A2UIRenderer.js +161 -0
- package/a2ui/dist/react/A2UIRenderer.js.map +1 -0
- package/a2ui/dist/react/FormContext.d.ts +10 -0
- package/a2ui/dist/react/FormContext.js +12 -0
- package/a2ui/dist/react/FormContext.js.map +1 -0
- package/a2ui/dist/react/index.d.ts +8 -0
- package/a2ui/dist/react/index.js +23 -0
- package/a2ui/dist/react/index.js.map +1 -0
- package/a2ui/dist/react/useA2UIContext.d.ts +7 -0
- package/a2ui/dist/react/useA2UIContext.js +19 -0
- package/a2ui/dist/react/useA2UIContext.js.map +1 -0
- package/a2ui/dist/react/useAction.d.ts +9 -0
- package/a2ui/dist/react/useAction.js +38 -0
- package/a2ui/dist/react/useAction.js.map +1 -0
- package/a2ui/dist/react/useCatalog.d.ts +7 -0
- package/a2ui/dist/react/useCatalog.js +13 -0
- package/a2ui/dist/react/useCatalog.js.map +1 -0
- package/a2ui/dist/react/useChecks.d.ts +27 -0
- package/a2ui/dist/react/useChecks.js +76 -0
- package/a2ui/dist/react/useChecks.js.map +1 -0
- package/a2ui/dist/react/useDataBinding.d.ts +10 -0
- package/a2ui/dist/react/useDataBinding.js +175 -0
- package/a2ui/dist/react/useDataBinding.js.map +1 -0
- package/a2ui/dist/store/FormController.d.ts +23 -0
- package/a2ui/dist/store/FormController.js +40 -0
- package/a2ui/dist/store/FormController.js.map +1 -0
- package/a2ui/dist/store/FunctionRegistry.d.ts +47 -0
- package/a2ui/dist/store/FunctionRegistry.js +23 -0
- package/a2ui/dist/store/FunctionRegistry.js.map +1 -0
- package/a2ui/dist/store/MessageProcessor.d.ts +28 -0
- package/a2ui/dist/store/MessageProcessor.js +408 -0
- package/a2ui/dist/store/MessageProcessor.js.map +1 -0
- package/a2ui/dist/store/MessageStore.d.ts +38 -0
- package/a2ui/dist/store/MessageStore.js +37 -0
- package/a2ui/dist/store/MessageStore.js.map +1 -0
- package/a2ui/dist/store/Resource.d.ts +45 -0
- package/a2ui/dist/store/Resource.js +80 -0
- package/a2ui/dist/store/Resource.js.map +1 -0
- package/a2ui/dist/store/SignalStore.d.ts +10 -0
- package/a2ui/dist/store/SignalStore.js +29 -0
- package/a2ui/dist/store/SignalStore.js.map +1 -0
- package/a2ui/dist/store/index.d.ts +14 -0
- package/a2ui/dist/store/index.js +15 -0
- package/a2ui/dist/store/index.js.map +1 -0
- package/a2ui/dist/store/payloadNormalizer.d.ts +27 -0
- package/a2ui/dist/store/payloadNormalizer.js +179 -0
- package/a2ui/dist/store/payloadNormalizer.js.map +1 -0
- package/a2ui/dist/store/resolveFunctionCall.d.ts +18 -0
- package/a2ui/dist/store/resolveFunctionCall.js +131 -0
- package/a2ui/dist/store/resolveFunctionCall.js.map +1 -0
- package/a2ui/dist/store/types.d.ts +68 -0
- package/a2ui/dist/store/types.js +2 -0
- package/a2ui/dist/store/types.js.map +1 -0
- package/a2ui/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui/styles/catalog/Button.css +83 -0
- package/a2ui/styles/catalog/Card.css +49 -0
- package/a2ui/styles/catalog/CheckBox.css +46 -0
- package/a2ui/styles/catalog/Column.css +89 -0
- package/a2ui/styles/catalog/Divider.css +20 -0
- package/a2ui/styles/catalog/Icon.css +39 -0
- package/a2ui/styles/catalog/Image.css +54 -0
- package/a2ui/styles/catalog/LineChart.css +116 -0
- package/a2ui/styles/catalog/List.css +38 -0
- package/a2ui/styles/catalog/Modal.css +60 -0
- package/a2ui/styles/catalog/PieChart.css +109 -0
- package/a2ui/styles/catalog/RadioGroup.css +123 -0
- package/a2ui/styles/catalog/Row.css +83 -0
- package/a2ui/styles/catalog/Slider.css +96 -0
- package/a2ui/styles/catalog/Tabs.css +46 -0
- package/a2ui/styles/catalog/Text.css +121 -0
- package/a2ui/styles/catalog/TextField.css +48 -0
- package/a2ui/styles/theme.css +62 -0
- package/a2ui-catalog-extractor/README.md +605 -0
- package/a2ui-catalog-extractor/bin/a2ui-catalog-extractor.js +6 -0
- package/a2ui-catalog-extractor/dist/cli.d.ts +12 -0
- package/a2ui-catalog-extractor/dist/cli.js +171 -0
- package/a2ui-catalog-extractor/dist/cli.js.map +1 -0
- package/a2ui-catalog-extractor/dist/index.d.ts +140 -0
- package/a2ui-catalog-extractor/dist/index.js +755 -0
- package/a2ui-catalog-extractor/dist/index.js.map +1 -0
- package/a2ui-catalog-extractor/dist/tsconfig.build.tsbuildinfo +1 -0
- package/a2ui-catalog-extractor/skills/a2ui-catalog-extractor/SKILL.md +30 -0
- package/a2ui-prompt/README.md +65 -0
- package/a2ui-prompt/dist/index.d.ts +91 -0
- package/a2ui-prompt/dist/index.js +767 -0
- package/cli/README.md +88 -0
- package/cli/bin/cli.js +271 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/index.ts +114 -0
- package/openui/README.md +211 -0
- package/openui/dist/catalog/Action/index.d.ts +20 -0
- package/openui/dist/catalog/Action/index.js +23 -0
- package/openui/dist/catalog/Action/index.js.map +1 -0
- package/openui/dist/catalog/Button/index.d.ts +64 -0
- package/openui/dist/catalog/Button/index.js +75 -0
- package/openui/dist/catalog/Button/index.js.map +1 -0
- package/openui/dist/catalog/Card/index.d.ts +34 -0
- package/openui/dist/catalog/Card/index.js +69 -0
- package/openui/dist/catalog/Card/index.js.map +1 -0
- package/openui/dist/catalog/CardHeader/index.d.ts +5 -0
- package/openui/dist/catalog/CardHeader/index.js +18 -0
- package/openui/dist/catalog/CardHeader/index.js.map +1 -0
- package/openui/dist/catalog/Separator/index.d.ts +2 -0
- package/openui/dist/catalog/Separator/index.js +13 -0
- package/openui/dist/catalog/Separator/index.js.map +1 -0
- package/openui/dist/catalog/Stack/index.d.ts +29 -0
- package/openui/dist/catalog/Stack/index.js +61 -0
- package/openui/dist/catalog/Stack/index.js.map +1 -0
- package/openui/dist/catalog/Tag/index.d.ts +4 -0
- package/openui/dist/catalog/Tag/index.js +15 -0
- package/openui/dist/catalog/Tag/index.js.map +1 -0
- package/openui/dist/catalog/TextContent/index.d.ts +11 -0
- package/openui/dist/catalog/TextContent/index.js +33 -0
- package/openui/dist/catalog/TextContent/index.js.map +1 -0
- package/openui/dist/catalog/index.d.ts +7 -0
- package/openui/dist/catalog/index.js +11 -0
- package/openui/dist/catalog/index.js.map +1 -0
- package/openui/dist/catalog/utils.d.ts +2 -0
- package/openui/dist/catalog/utils.js +17 -0
- package/openui/dist/catalog/utils.js.map +1 -0
- package/openui/dist/core/context.d.ts +112 -0
- package/openui/dist/core/context.js +99 -0
- package/openui/dist/core/context.js.map +1 -0
- package/openui/dist/core/createLibrary.d.ts +10 -0
- package/openui/dist/core/createLibrary.js +36 -0
- package/openui/dist/core/createLibrary.js.map +1 -0
- package/openui/dist/core/hooks/index.d.ts +4 -0
- package/openui/dist/core/hooks/index.js +6 -0
- package/openui/dist/core/hooks/index.js.map +1 -0
- package/openui/dist/core/hooks/useFormValidation.d.ts +13 -0
- package/openui/dist/core/hooks/useFormValidation.js +76 -0
- package/openui/dist/core/hooks/useFormValidation.js.map +1 -0
- package/openui/dist/core/hooks/useOpenUIState.d.ts +33 -0
- package/openui/dist/core/hooks/useOpenUIState.js +413 -0
- package/openui/dist/core/hooks/useOpenUIState.js.map +1 -0
- package/openui/dist/core/hooks/useStateField.d.ts +2 -0
- package/openui/dist/core/hooks/useStateField.js +11 -0
- package/openui/dist/core/hooks/useStateField.js.map +1 -0
- package/openui/dist/core/index.d.ts +7 -0
- package/openui/dist/core/index.js +8 -0
- package/openui/dist/core/index.js.map +1 -0
- package/openui/dist/core/library.d.ts +20 -0
- package/openui/dist/core/library.js +13 -0
- package/openui/dist/core/library.js.map +1 -0
- package/openui/dist/core/renderer.css +271 -0
- package/openui/dist/core/renderer.d.ts +9 -0
- package/openui/dist/core/renderer.js +139 -0
- package/openui/dist/core/renderer.js.map +1 -0
- package/openui/dist/core/utils.d.ts +1 -0
- package/openui/dist/core/utils.js +76 -0
- package/openui/dist/core/utils.js.map +1 -0
- package/package.json +120 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
3
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
4
|
+
// LICENSE file in the root directory of this source tree.
|
|
5
|
+
import * as fs from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
import { extractCatalogComponentsFromTypeDocJson, extractCatalogFunctionsFromTypeDocJson, findCatalogSourceFiles, writeCatalogArtifacts, writeCatalogComponents, writeCatalogFunctions, } from './index.js';
|
|
10
|
+
const usage = `Usage: a2ui-catalog-extractor [options]
|
|
11
|
+
|
|
12
|
+
Options:
|
|
13
|
+
--catalog-dir <dir> Directory to scan for TypeScript catalog interfaces.
|
|
14
|
+
--source <path> Source file or directory to scan. Repeatable.
|
|
15
|
+
--typedoc-json <file>
|
|
16
|
+
Read an existing TypeDoc JSON project instead of
|
|
17
|
+
running TypeDoc conversion.
|
|
18
|
+
--out-dir <dir> Output directory for component catalog.json files.
|
|
19
|
+
--version Print the package version.
|
|
20
|
+
--help Print this help message.
|
|
21
|
+
|
|
22
|
+
Defaults:
|
|
23
|
+
--catalog-dir src/catalog
|
|
24
|
+
--out-dir dist/catalog
|
|
25
|
+
`;
|
|
26
|
+
export function parseCliArgs(args) {
|
|
27
|
+
const options = {
|
|
28
|
+
catalogDirs: [],
|
|
29
|
+
help: false,
|
|
30
|
+
outDir: 'dist/catalog',
|
|
31
|
+
sourceInputs: [],
|
|
32
|
+
version: false,
|
|
33
|
+
};
|
|
34
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
35
|
+
const arg = args[index];
|
|
36
|
+
switch (arg) {
|
|
37
|
+
case 'catalog-extractor':
|
|
38
|
+
break;
|
|
39
|
+
case '--catalog-dir':
|
|
40
|
+
options.catalogDirs.push(readValue(args, ++index, arg));
|
|
41
|
+
break;
|
|
42
|
+
case '--source':
|
|
43
|
+
options.sourceInputs.push(readValue(args, ++index, arg));
|
|
44
|
+
break;
|
|
45
|
+
case '--typedoc-json':
|
|
46
|
+
options.typedocJson = readValue(args, ++index, arg);
|
|
47
|
+
break;
|
|
48
|
+
case '--out-dir':
|
|
49
|
+
options.outDir = readValue(args, ++index, arg);
|
|
50
|
+
break;
|
|
51
|
+
case '--help':
|
|
52
|
+
case '-h':
|
|
53
|
+
options.help = true;
|
|
54
|
+
break;
|
|
55
|
+
case '--version':
|
|
56
|
+
case '-v':
|
|
57
|
+
options.version = true;
|
|
58
|
+
break;
|
|
59
|
+
default:
|
|
60
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return options;
|
|
64
|
+
}
|
|
65
|
+
export async function runCli(args, cwd = process.cwd()) {
|
|
66
|
+
const options = parseCliArgs(args);
|
|
67
|
+
if (options.help) {
|
|
68
|
+
console.info(usage);
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
if (options.version) {
|
|
72
|
+
const require = createRequire(import.meta.url);
|
|
73
|
+
const packageJson = require('../package.json');
|
|
74
|
+
console.info(packageJson.version);
|
|
75
|
+
return 0;
|
|
76
|
+
}
|
|
77
|
+
if (options.typedocJson) {
|
|
78
|
+
const typedocJsonPath = path.resolve(cwd, options.typedocJson);
|
|
79
|
+
const project = JSON.parse(fs.readFileSync(typedocJsonPath, 'utf8'));
|
|
80
|
+
const components = extractCatalogComponentsFromTypeDocJson(project, {
|
|
81
|
+
cwd,
|
|
82
|
+
});
|
|
83
|
+
const functions = extractCatalogFunctionsFromTypeDocJson(project, {
|
|
84
|
+
cwd,
|
|
85
|
+
});
|
|
86
|
+
writeCatalogComponents(components, {
|
|
87
|
+
cwd,
|
|
88
|
+
outDir: options.outDir,
|
|
89
|
+
});
|
|
90
|
+
writeCatalogFunctions(functions, {
|
|
91
|
+
cwd,
|
|
92
|
+
outDir: options.outDir,
|
|
93
|
+
});
|
|
94
|
+
printGeneratedComponents(components);
|
|
95
|
+
printGeneratedFunctions(functions);
|
|
96
|
+
return 0;
|
|
97
|
+
}
|
|
98
|
+
const configuredInputs = [
|
|
99
|
+
...options.sourceInputs,
|
|
100
|
+
...options.catalogDirs,
|
|
101
|
+
];
|
|
102
|
+
const inputs = configuredInputs.length > 0
|
|
103
|
+
? configuredInputs
|
|
104
|
+
: ['src/catalog'];
|
|
105
|
+
const sourceFiles = inputs.flatMap(input => findCatalogSourceFiles(path.resolve(cwd, input)));
|
|
106
|
+
const uniqueSourceFiles = [...new Set(sourceFiles)].sort((left, right) => left.localeCompare(right));
|
|
107
|
+
if (uniqueSourceFiles.length === 0) {
|
|
108
|
+
throw new Error(`No TypeScript source files found in ${inputs.join(', ')}.`);
|
|
109
|
+
}
|
|
110
|
+
const { components, functions } = await writeCatalogArtifacts({
|
|
111
|
+
cwd,
|
|
112
|
+
outDir: options.outDir,
|
|
113
|
+
sourceFiles: uniqueSourceFiles,
|
|
114
|
+
});
|
|
115
|
+
printGeneratedComponents(components);
|
|
116
|
+
printGeneratedFunctions(functions);
|
|
117
|
+
// Fail loudly if we matched source files but emitted no artifacts —
|
|
118
|
+
// this used to silently succeed on Windows when TypeDoc rejected
|
|
119
|
+
// backslash entry-point paths, and downstream packages then failed
|
|
120
|
+
// to import the missing `catalog.json` files.
|
|
121
|
+
if (components.length === 0 && functions.length === 0) {
|
|
122
|
+
console.error(`[a2ui-catalog-extractor] Found ${uniqueSourceFiles.length} `
|
|
123
|
+
+ `source file(s) but emitted 0 component catalogs and 0 `
|
|
124
|
+
+ `function definitions. Make sure each catalog props interface `
|
|
125
|
+
+ `is annotated with \`@a2uiCatalog <Name>\` and each function `
|
|
126
|
+
+ `is annotated with \`@a2uiFunction <name>\`.`);
|
|
127
|
+
return 1;
|
|
128
|
+
}
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
function printGeneratedComponents(components) {
|
|
132
|
+
console.info(`Generated ${components.length} A2UI component catalog files.`);
|
|
133
|
+
for (const component of components) {
|
|
134
|
+
console.info(`Generated strict schema for ${component.name}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function printGeneratedFunctions(functions) {
|
|
138
|
+
if (functions.length === 0)
|
|
139
|
+
return;
|
|
140
|
+
console.info(`Generated ${functions.length} A2UI function definition files.`);
|
|
141
|
+
for (const fn of functions) {
|
|
142
|
+
console.info(`Generated function definition for ${fn.name}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function readValue(args, index, option) {
|
|
146
|
+
const value = args[index];
|
|
147
|
+
if (!value || value.startsWith('-')) {
|
|
148
|
+
throw new Error(`Missing value for ${option}.`);
|
|
149
|
+
}
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
function isEntryScript() {
|
|
153
|
+
if (!process.argv[1])
|
|
154
|
+
return false;
|
|
155
|
+
const entryUrl = pathToFileURL(process.argv[1]).href;
|
|
156
|
+
if (import.meta.url === entryUrl)
|
|
157
|
+
return true;
|
|
158
|
+
// The published bin shim does `import '../dist/cli.js'`. In that case the
|
|
159
|
+
// entry script is the bin shim, not this module — but we should still run.
|
|
160
|
+
return /[/\\]bin[/\\]a2ui-catalog-extractor\.[mc]?js$/.test(process.argv[1]);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
if (isEntryScript()) {
|
|
164
|
+
process.exitCode = await runCli(process.argv.slice(2));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
169
|
+
process.exitCode = 1;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,wDAAwD;AACxD,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,uCAAu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nC,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC9C,0EAA0E;IAC1E,2EAA2E;IAC3E,OAAO,+CAA+C,CAAC,IAAI,CACzD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAChB,CAAC;AACJ,CAAC;AAED,IAAI,CAAC;IACH,IAAI,aAAa,EAAE,EAAE,CAAC;QACpB,OAAO,CAAC,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { ProjectReflection } from 'typedoc';
|
|
2
|
+
export interface JsonSchema {
|
|
3
|
+
$ref?: string;
|
|
4
|
+
additionalProperties?: boolean | JsonSchema;
|
|
5
|
+
default?: unknown;
|
|
6
|
+
deprecated?: boolean;
|
|
7
|
+
description?: string;
|
|
8
|
+
enum?: Array<boolean | number | string>;
|
|
9
|
+
items?: JsonSchema;
|
|
10
|
+
oneOf?: JsonSchema[];
|
|
11
|
+
properties?: Record<string, JsonSchema>;
|
|
12
|
+
required?: string[];
|
|
13
|
+
type?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface CatalogComponent {
|
|
16
|
+
filePath: string;
|
|
17
|
+
interfaceName: string;
|
|
18
|
+
name: string;
|
|
19
|
+
schema: JsonSchema;
|
|
20
|
+
}
|
|
21
|
+
export interface ExtractCatalogOptions {
|
|
22
|
+
cwd?: string;
|
|
23
|
+
sourceFiles: string[];
|
|
24
|
+
tsconfig?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ExtractCatalogFromTypeDocOptions {
|
|
27
|
+
cwd?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WriteComponentCatalogOptions extends ExtractCatalogOptions {
|
|
30
|
+
outDir: string;
|
|
31
|
+
}
|
|
32
|
+
export interface A2UICatalog {
|
|
33
|
+
catalogId: string;
|
|
34
|
+
components?: Record<string, JsonSchema>;
|
|
35
|
+
functions?: FunctionDefinition[];
|
|
36
|
+
theme?: Record<string, JsonSchema>;
|
|
37
|
+
}
|
|
38
|
+
export interface FunctionDefinition {
|
|
39
|
+
description?: string;
|
|
40
|
+
name: string;
|
|
41
|
+
parameters: JsonSchema;
|
|
42
|
+
returnType: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'any' | 'void';
|
|
43
|
+
}
|
|
44
|
+
/** A function discovered in source via `@a2uiFunction`, with its origin path. */
|
|
45
|
+
export interface CatalogFunction extends FunctionDefinition {
|
|
46
|
+
filePath: string;
|
|
47
|
+
}
|
|
48
|
+
export interface TypeDocProject {
|
|
49
|
+
children?: TypeDocReflection[];
|
|
50
|
+
}
|
|
51
|
+
export interface TypeDocReflection {
|
|
52
|
+
children?: TypeDocReflection[];
|
|
53
|
+
comment?: TypeDocComment;
|
|
54
|
+
flags?: {
|
|
55
|
+
isOptional?: boolean;
|
|
56
|
+
};
|
|
57
|
+
inheritedFrom?: unknown;
|
|
58
|
+
kind?: number;
|
|
59
|
+
kindString?: string;
|
|
60
|
+
name: string;
|
|
61
|
+
parameters?: TypeDocReflection[];
|
|
62
|
+
signatures?: TypeDocSignature[];
|
|
63
|
+
sources?: TypeDocSource[];
|
|
64
|
+
type?: TypeDocType;
|
|
65
|
+
}
|
|
66
|
+
export interface TypeDocSignature {
|
|
67
|
+
comment?: TypeDocComment;
|
|
68
|
+
kind?: number;
|
|
69
|
+
kindString?: string;
|
|
70
|
+
name?: string;
|
|
71
|
+
parameters?: TypeDocReflection[];
|
|
72
|
+
type?: TypeDocType;
|
|
73
|
+
}
|
|
74
|
+
export interface TypeDocSource {
|
|
75
|
+
character?: number;
|
|
76
|
+
fileName?: string;
|
|
77
|
+
fullFileName?: string;
|
|
78
|
+
line?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface TypeDocComment {
|
|
81
|
+
blockTags?: TypeDocCommentTag[];
|
|
82
|
+
modifierTags?: Iterable<string> | Record<string, boolean>;
|
|
83
|
+
summary?: TypeDocCommentDisplayPart[];
|
|
84
|
+
}
|
|
85
|
+
export interface TypeDocCommentTag {
|
|
86
|
+
content?: TypeDocCommentDisplayPart[];
|
|
87
|
+
tag: string;
|
|
88
|
+
}
|
|
89
|
+
export interface TypeDocCommentDisplayPart {
|
|
90
|
+
code?: string;
|
|
91
|
+
content?: TypeDocCommentDisplayPart[];
|
|
92
|
+
kind?: string;
|
|
93
|
+
tag?: string;
|
|
94
|
+
target?: unknown;
|
|
95
|
+
text?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface TypeDocType {
|
|
98
|
+
declaration?: TypeDocReflection;
|
|
99
|
+
elementType?: TypeDocType;
|
|
100
|
+
name?: string;
|
|
101
|
+
qualifiedName?: string;
|
|
102
|
+
target?: TypeDocType;
|
|
103
|
+
type: string;
|
|
104
|
+
typeArguments?: TypeDocType[];
|
|
105
|
+
types?: TypeDocType[];
|
|
106
|
+
value?: bigint | boolean | number | string | null;
|
|
107
|
+
}
|
|
108
|
+
export declare function findCatalogSourceFiles(inputPath: string): string[];
|
|
109
|
+
export declare function extractCatalogComponents(options: ExtractCatalogOptions): Promise<CatalogComponent[]>;
|
|
110
|
+
export declare function extractCatalogComponentsFromTypeDocProject(project: ProjectReflection | TypeDocProject, options?: ExtractCatalogFromTypeDocOptions): CatalogComponent[];
|
|
111
|
+
export declare function extractCatalogComponentsFromTypeDocJson(project: TypeDocProject, options?: ExtractCatalogFromTypeDocOptions): CatalogComponent[];
|
|
112
|
+
export declare function extractCatalogFunctions(options: ExtractCatalogOptions): Promise<CatalogFunction[]>;
|
|
113
|
+
export declare function extractCatalogFunctionsFromTypeDocProject(project: ProjectReflection | TypeDocProject, options?: ExtractCatalogFromTypeDocOptions): CatalogFunction[];
|
|
114
|
+
export declare function extractCatalogFunctionsFromTypeDocJson(project: TypeDocProject, options?: ExtractCatalogFromTypeDocOptions): CatalogFunction[];
|
|
115
|
+
export declare function writeComponentCatalogs(options: WriteComponentCatalogOptions): Promise<CatalogComponent[]>;
|
|
116
|
+
export declare function writeCatalogComponents(components: CatalogComponent[], options: {
|
|
117
|
+
cwd?: string;
|
|
118
|
+
outDir: string;
|
|
119
|
+
}): void;
|
|
120
|
+
export declare function writeCatalogFunctionDefinitions(options: WriteComponentCatalogOptions): Promise<CatalogFunction[]>;
|
|
121
|
+
export interface CatalogArtifacts {
|
|
122
|
+
components: CatalogComponent[];
|
|
123
|
+
functions: CatalogFunction[];
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Bootstrap TypeDoc once and emit both component and function catalog files.
|
|
127
|
+
* Preferred entry point for the CLI — running the conversion twice doubles
|
|
128
|
+
* cold-start latency on large catalogs.
|
|
129
|
+
*/
|
|
130
|
+
export declare function writeCatalogArtifacts(options: WriteComponentCatalogOptions): Promise<CatalogArtifacts>;
|
|
131
|
+
export declare function writeCatalogFunctions(functions: CatalogFunction[], options: {
|
|
132
|
+
cwd?: string;
|
|
133
|
+
outDir: string;
|
|
134
|
+
}): void;
|
|
135
|
+
export declare function createA2UICatalog(options: {
|
|
136
|
+
catalogId: string;
|
|
137
|
+
components: CatalogComponent[] | Record<string, JsonSchema>;
|
|
138
|
+
functions?: FunctionDefinition[];
|
|
139
|
+
theme?: Record<string, JsonSchema>;
|
|
140
|
+
}): A2UICatalog;
|