@astryxdesign/cli 0.1.6-canary.e8d4c3f → 0.1.6-canary.eb23da7
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/package.json +9 -9
- package/src/api/template.mjs +1 -1
- package/src/codemods/__tests__/registry.test.mjs +0 -1
- package/src/codemods/registry.mjs +0 -1
- package/src/config.mjs +14 -5
- package/src/doc.mjs +261 -17
- package/src/integration.mjs +15 -4
- package/src/lib/component-format.mjs +13 -45
- package/src/lib/component-format.test.mjs +1 -95
- package/src/lib/component-loader.mjs +3 -52
- package/src/lib/hook-format.mjs +3 -8
- package/src/template.mjs +67 -9
- package/src/types/config.d.ts +66 -11
- package/src/types/doc.d.ts +135 -19
- package/src/types/integration.d.ts +18 -7
- package/src/types/template-api.d.ts +50 -14
- package/templates/pages/ide/page.tsx +41 -35
- package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
- package/src/codemods/transforms/v0.1.7/index.mjs +0 -19
- package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +0 -188
- package/src/lib/componentDocOverlay.test.mjs +0 -111
- package/src/schemas/doc-schema.mjs +0 -226
- package/src/schemas/template-schema.mjs +0 -47
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import {pathToFileURL} from 'node:url';
|
|
8
8
|
import {importUserModule} from './module-loader.mjs';
|
|
9
9
|
import {formatZodError} from './config-schema.mjs';
|
|
10
|
-
import {ComponentDocSchema} from '../
|
|
10
|
+
import {ComponentDocSchema} from '../doc.mjs';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Load a component doc through the shared load/validation boundary.
|
|
@@ -144,64 +144,15 @@ export async function loadDocs(readmePath, {zh = false, dense = false, lang} = {
|
|
|
144
144
|
|
|
145
145
|
const translation = mod[translationKey];
|
|
146
146
|
|
|
147
|
-
//
|
|
148
|
-
// returned wholesale. That made it a REPLACEMENT, not an overlay: any prop
|
|
149
|
-
// the translation had not caught up with simply ceased to exist —
|
|
150
|
-
// `component Button --zh` silently omitted `isInterruptible` and
|
|
151
|
-
// `isIconOnly`. A reader of the translated docs cannot discover a prop that
|
|
152
|
-
// is not there. Overlay it instead, so an untranslated prop falls back to
|
|
153
|
-
// its English entry. (Same principle as the reference-doc overlays, #2182.)
|
|
147
|
+
// If the translation is a full ComponentDoc (legacy docsZh shape), return it directly
|
|
154
148
|
if (translation.props || translation.components?.some(c => c.props)) {
|
|
155
|
-
return
|
|
149
|
+
return translation;
|
|
156
150
|
}
|
|
157
151
|
|
|
158
152
|
// Otherwise it's a TranslationDoc — merge it onto docs
|
|
159
153
|
return mergeTranslation(docs, translation);
|
|
160
154
|
}
|
|
161
155
|
|
|
162
|
-
/**
|
|
163
|
-
* Overlay a full-ComponentDoc-shaped translation onto the English doc.
|
|
164
|
-
*
|
|
165
|
-
* Base order and completeness win; the translation supplies text for the
|
|
166
|
-
* entries it covers. Props are matched by name, never by position, so a
|
|
167
|
-
* translation that is missing entries (or lists them in another order) can no
|
|
168
|
-
* longer drop or misattribute one.
|
|
169
|
-
*
|
|
170
|
-
* @param {any} docs Base (English) component doc.
|
|
171
|
-
* @param {any} translation Translated doc, possibly covering only some props.
|
|
172
|
-
* @returns {any} Merged doc with every base prop present.
|
|
173
|
-
*/
|
|
174
|
-
function overlayComponentDoc(docs, translation) {
|
|
175
|
-
/** Merge one prop list: keep base entries and order, translate what's covered. */
|
|
176
|
-
const overlayProps = (baseProps, tProps) => {
|
|
177
|
-
if (!baseProps) return baseProps;
|
|
178
|
-
const byName = new Map((tProps ?? []).map(p => [p.name, p]));
|
|
179
|
-
return baseProps.map(prop => {
|
|
180
|
-
const t = byName.get(prop.name);
|
|
181
|
-
// Take the translated text, but never let it drop the prop's contract
|
|
182
|
-
// (type/default/required stay authoritative from the English doc).
|
|
183
|
-
return t ? {...prop, ...t, name: prop.name, type: prop.type} : prop;
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
const merged = {...docs, ...translation};
|
|
188
|
-
|
|
189
|
-
merged.props = overlayProps(docs.props, translation.props);
|
|
190
|
-
|
|
191
|
-
if (docs.components) {
|
|
192
|
-
const tByName = new Map(
|
|
193
|
-
(translation.components ?? []).map(c => [c.name, c]),
|
|
194
|
-
);
|
|
195
|
-
merged.components = docs.components.map(base => {
|
|
196
|
-
const t = tByName.get(base.name);
|
|
197
|
-
if (!t) return base;
|
|
198
|
-
return {...base, ...t, props: overlayProps(base.props, t.props)};
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return merged;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
156
|
/**
|
|
206
157
|
* Find the doc file for a component, checking both top-level
|
|
207
158
|
* and nested directories. Prefers {Name}.doc.mjs, then README.md
|
package/src/lib/hook-format.mjs
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
|
|
12
12
|
import {discoverHooks, findHookDoc} from './hook-discovery.mjs';
|
|
13
13
|
import {loadDocs} from './component-loader.mjs';
|
|
14
|
-
import {mdCell} from './component-format.mjs';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Build a signature string from hook docs.
|
|
@@ -52,11 +51,9 @@ function formatParamsTable(params) {
|
|
|
52
51
|
lines.push('| Param | Type | Default | Description |');
|
|
53
52
|
lines.push('|-------|------|---------|-------------|');
|
|
54
53
|
for (const p of params) {
|
|
55
|
-
const def = p.default ? `\`${
|
|
54
|
+
const def = p.default ? `\`${p.default}\`` : '\u2014';
|
|
56
55
|
const req = p.required ? ' **(required)**' : '';
|
|
57
|
-
lines.push(
|
|
58
|
-
`| \`${mdCell(p.name)}\` | \`${mdCell(p.type)}\` | ${def} | ${mdCell(p.description)}${req} |`,
|
|
59
|
-
);
|
|
56
|
+
lines.push(`| \`${p.name}\` | \`${p.type}\` | ${def} | ${p.description}${req} |`);
|
|
60
57
|
}
|
|
61
58
|
return lines.join('\n');
|
|
62
59
|
}
|
|
@@ -70,9 +67,7 @@ function formatReturnsTable(returns) {
|
|
|
70
67
|
lines.push('| Field | Type | Description |');
|
|
71
68
|
lines.push('|-------|------|-------------|');
|
|
72
69
|
for (const r of returns) {
|
|
73
|
-
lines.push(
|
|
74
|
-
`| \`${mdCell(r.name)}\` | \`${mdCell(r.type)}\` | ${mdCell(r.description)} |`,
|
|
75
|
-
);
|
|
70
|
+
lines.push(`| \`${r.name}\` | \`${r.type}\` | ${r.description} |`);
|
|
76
71
|
}
|
|
77
72
|
return lines.join('\n');
|
|
78
73
|
}
|
package/src/template.mjs
CHANGED
|
@@ -1,15 +1,73 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Static template authoring API
|
|
4
|
+
* @file Static template authoring API.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* Helpers for authoring Astryx page/block template docs. Like
|
|
7
|
+
* `createConfig`/`createIntegration`, these are tiny runtime identity helpers
|
|
8
|
+
* whose real value is the exported TypeScript surface from
|
|
9
|
+
* `@astryxdesign/cli/template`. They inject the discriminant `type` so a
|
|
10
|
+
* discovered doc always knows whether it is a page or a block. They do NOT
|
|
11
|
+
* validate — validation happens at the load boundary, where integration
|
|
12
|
+
* template discovery runs the module's default export through
|
|
13
|
+
* {@link TemplateEnvelopeSchema} (see `loadModuleWithSchema`).
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
import {z} from 'zod';
|
|
17
|
+
|
|
18
|
+
const PreviewSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
image: z.string().optional(),
|
|
21
|
+
aspectRatio: z.string().optional(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shared authored-template shape. `type` is injected by the create* helpers,
|
|
27
|
+
* so authors never write it. Inline source/sourceFile are intentionally NOT
|
|
28
|
+
* part of v1 — a template's source is the required same-stem sibling file.
|
|
29
|
+
* Exported so integration template discovery can validate the stamped result.
|
|
30
|
+
*/
|
|
31
|
+
export const BaseTemplateSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
name: z.string().min(1, 'name is required'),
|
|
34
|
+
description: z.string().min(1, 'description is required'),
|
|
35
|
+
category: z.string().optional(),
|
|
36
|
+
componentsUsed: z.array(z.string()).optional(),
|
|
37
|
+
preview: PreviewSchema.optional(),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The metadata envelope integration template discovery validates: a stamped
|
|
43
|
+
* template doc. This is the LOAD-boundary contract — a hand-written plain
|
|
44
|
+
* object that matches this shape is accepted (discovery does not check "was it
|
|
45
|
+
* made by the factory", only the shape).
|
|
46
|
+
*/
|
|
47
|
+
export const TemplateEnvelopeSchema = BaseTemplateSchema.extend({
|
|
48
|
+
type: z.enum(['page', 'block']),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Author an Astryx page template doc. Stamp-only: returns the def with
|
|
53
|
+
* `type: 'page'` injected. Validation happens at the load boundary.
|
|
54
|
+
*
|
|
55
|
+
* @template {import('./types/template-api').AstryxPageTemplateInput} T
|
|
56
|
+
* @param {T} def
|
|
57
|
+
* @returns {T & {type: 'page'}}
|
|
58
|
+
*/
|
|
59
|
+
export function createPageTemplate(def) {
|
|
60
|
+
return /** @type {T & {type: 'page'}} */ ({...def, type: 'page'});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Author an Astryx block template doc. Stamp-only: returns the def with
|
|
65
|
+
* `type: 'block'` injected. Validation happens at the load boundary.
|
|
66
|
+
*
|
|
67
|
+
* @template {import('./types/template-api').AstryxBlockTemplateInput} T
|
|
68
|
+
* @param {T} def
|
|
69
|
+
* @returns {T & {type: 'block'}}
|
|
70
|
+
*/
|
|
71
|
+
export function createBlockTemplate(def) {
|
|
72
|
+
return /** @type {T & {type: 'block'}} */ ({...def, type: 'block'});
|
|
73
|
+
}
|
package/src/types/config.d.ts
CHANGED
|
@@ -1,15 +1,70 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* so existing `@astryxdesign/cli/config` type imports keep resolving.
|
|
4
|
+
* A command to run as part of a post-codemod hook. Returned by a hook's
|
|
5
|
+
* `buildCommand` and executed via `execFile` after codemods write files.
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
export interface PostCodemodCommand {
|
|
8
|
+
command: string;
|
|
9
|
+
args?: string[];
|
|
10
|
+
options?: {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A post-codemod hook. `buildCommand` receives the package directory and the
|
|
19
|
+
* list of files changed by codemods, and returns the command to run (or a
|
|
20
|
+
* nullish value to skip).
|
|
21
|
+
*/
|
|
22
|
+
export type PostCodemodHook = {
|
|
23
|
+
name?: string;
|
|
24
|
+
buildCommand: (ctx: {
|
|
25
|
+
packageDir: string;
|
|
26
|
+
files: string[];
|
|
27
|
+
}) =>
|
|
28
|
+
| PostCodemodCommand
|
|
29
|
+
| null
|
|
30
|
+
| undefined
|
|
31
|
+
| Promise<PostCodemodCommand | null | undefined>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** A component XLE layout expressions can reference by name via `{hint}`. */
|
|
35
|
+
export interface XleComponent {
|
|
36
|
+
/** Import specifier the component is imported from, e.g. '@/components/KpiCard'. */
|
|
37
|
+
from: string;
|
|
38
|
+
/** Optional human description shown in tooling. */
|
|
39
|
+
description?: string;
|
|
40
|
+
/** Import as the module's default export instead of a named export. Defaults to false. */
|
|
41
|
+
default?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** User config exported from astryx.config.{ts,mjs,js}. */
|
|
45
|
+
export interface AstryxConfig {
|
|
46
|
+
/** Integration package names to load. */
|
|
47
|
+
integrations?: string[];
|
|
48
|
+
/** Where to file issues/feedback for this project. */
|
|
49
|
+
issuesUrl?: string;
|
|
50
|
+
/** Lifecycle hooks. */
|
|
51
|
+
hooks?: {
|
|
52
|
+
postCodemod?: PostCodemodHook[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* EXPERIMENTAL — shape may change and is not part of the stable config
|
|
56
|
+
* contract. Provisional home for features still being proven out.
|
|
57
|
+
*/
|
|
58
|
+
experimental?: {
|
|
59
|
+
/** Experimental XLE (layout expression) configuration. */
|
|
60
|
+
xle?: {
|
|
61
|
+
/**
|
|
62
|
+
* Register app-local components so XLE layout expressions can
|
|
63
|
+
* reference them by name via {hint}. Keyed by component name.
|
|
64
|
+
*/
|
|
65
|
+
components?: Record<string, XleComponent>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare function createConfig<T extends AstryxConfig>(config: T): T;
|
package/src/types/doc.d.ts
CHANGED
|
@@ -1,23 +1,139 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Authoring surface for Astryx docs, exported from `@astryxdesign/cli/doc`.
|
|
5
|
+
*
|
|
6
|
+
* A doc lives in a `{Name}.doc.{ts,mjs,js}` file. Authors default-export a
|
|
7
|
+
* factory result (`createComponentDoc`/`createFunctionDoc`/`createDoc`) —
|
|
8
|
+
* preferred — or, for the current loose docs, name-export `docs`. The doc's
|
|
9
|
+
* shape is validated at the load boundary against `ComponentDocSchema` (see
|
|
10
|
+
* `doc.mjs`), which accepts BOTH the new stamped formats and the legacy loose
|
|
11
|
+
* shape.
|
|
12
|
+
*
|
|
13
|
+
* The factories inject the `type` discriminant, so authors never write it. The
|
|
14
|
+
* inputs are kept as broad records so authoring never fails to typecheck when a
|
|
15
|
+
* richer core type surface is not resolvable; the precise per-field guidance
|
|
16
|
+
* lives on the doc types in `@astryxdesign/core/docs-types`.
|
|
7
17
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Fields shared by every doc kind (component + function + generic).
|
|
21
|
+
*
|
|
22
|
+
* `group` vs `parent` are distinct:
|
|
23
|
+
* - `group` is a FLAT sidebar bucket label; many docs can share it and it is
|
|
24
|
+
* NOT an inheritance key.
|
|
25
|
+
* - `parent` is a DIRECTED inheritance/composition pointer — a doc naming the
|
|
26
|
+
* doc it belongs to (e.g. a sub-component naming its parent component). The
|
|
27
|
+
* legacy `subComponentOf` field is a synonym.
|
|
28
|
+
*
|
|
29
|
+
* `relatedDocs` is a single flat curated cross-reference list; it replaces the
|
|
30
|
+
* legacy split `relatedComponents` + `relatedHooks`.
|
|
31
|
+
*/
|
|
32
|
+
export interface AstryxBaseDocInput {
|
|
33
|
+
/** Name of the documented unit, without any prefix, PascalCase. Required. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Human-readable display name for gallery/sidebar. */
|
|
36
|
+
displayName?: string;
|
|
37
|
+
/** Short description. */
|
|
38
|
+
description?: string;
|
|
39
|
+
/** Usage documentation (description, best practices, anatomy, slotElements). */
|
|
40
|
+
usage?: unknown;
|
|
41
|
+
/** Flat sidebar grouping label (not an inheritance key). */
|
|
42
|
+
group?: string;
|
|
43
|
+
/** Overview-page functional category. */
|
|
44
|
+
category?: string;
|
|
45
|
+
/** CLI fuzzy-search keywords. */
|
|
46
|
+
keywords?: string[];
|
|
47
|
+
/** Directed inheritance/composition pointer to the doc this belongs to. */
|
|
48
|
+
parent?: string;
|
|
49
|
+
/** Flat curated cross-reference list of related doc names. */
|
|
50
|
+
relatedDocs?: string[];
|
|
51
|
+
/** Hide the whole doc from human-facing UI (stays importable/discoverable). */
|
|
52
|
+
hidden?: boolean;
|
|
53
|
+
/** Exclude from the categorized overview page (kept in sidebar/CLI). */
|
|
54
|
+
isHiddenFromOverview?: boolean;
|
|
55
|
+
/** Any additional fields the rich doc surface carries. */
|
|
56
|
+
[key: string]: unknown;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A single documented prop (mirrors `PropDoc` from core docs-types). */
|
|
60
|
+
export interface AstryxPropInput {
|
|
61
|
+
name: string;
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
default?: string;
|
|
65
|
+
required?: boolean;
|
|
66
|
+
[key: string]: unknown;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A single documented param (mirrors `HookParamDoc`). */
|
|
70
|
+
export interface AstryxParamInput {
|
|
71
|
+
name: string;
|
|
72
|
+
type: string;
|
|
73
|
+
description: string;
|
|
74
|
+
default?: string;
|
|
75
|
+
required?: boolean;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A single documented return field (mirrors `HookReturnDoc`). */
|
|
80
|
+
export interface AstryxReturnInput {
|
|
81
|
+
name: string;
|
|
82
|
+
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Input accepted by {@link createComponentDoc}. A component (or a family). The
|
|
89
|
+
* `type` discriminant is injected by the factory. `anatomy`/`slotElements` live
|
|
90
|
+
* inside `usage`; `importPath` is DERIVED (never authored).
|
|
91
|
+
*/
|
|
92
|
+
export interface AstryxComponentDocInput extends AstryxBaseDocInput {
|
|
93
|
+
/** All public props for the component. */
|
|
94
|
+
props: AstryxPropInput[];
|
|
95
|
+
/** Theming/selector-surface metadata. */
|
|
96
|
+
theming?: unknown;
|
|
97
|
+
/** Interactive-preview playground configuration. */
|
|
98
|
+
playground?: unknown;
|
|
99
|
+
/** Short code examples rendered after the props table. */
|
|
100
|
+
examples?: unknown[];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Input accepted by {@link createFunctionDoc}. Covers any function, including
|
|
105
|
+
* hooks: an inputs (`params`) + outputs (`returns`) surface. The `type`
|
|
106
|
+
* discriminant is injected by the factory; `importPath` is DERIVED.
|
|
107
|
+
*/
|
|
108
|
+
export interface AstryxFunctionDocInput extends AstryxBaseDocInput {
|
|
109
|
+
/** Function/hook parameters or options-object fields. */
|
|
110
|
+
params: AstryxParamInput[];
|
|
111
|
+
/** Return value documentation. One entry per field (or a single primitive). */
|
|
112
|
+
returns: AstryxReturnInput[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Input accepted by {@link createDoc}. A generic reference/topic doc — just the
|
|
117
|
+
* shared base. The `type` discriminant is injected by the factory.
|
|
118
|
+
*/
|
|
119
|
+
export type AstryxGenericDocInput = AstryxBaseDocInput;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Back-compat alias. Previously `createDoc` accepted a broad component-doc
|
|
123
|
+
* record; the union of the three input kinds preserves that permissiveness for
|
|
124
|
+
* any code referring to the old name.
|
|
125
|
+
*/
|
|
126
|
+
export type AstryxComponentDoc =
|
|
127
|
+
AstryxComponentDocInput | AstryxFunctionDocInput | AstryxGenericDocInput;
|
|
128
|
+
|
|
129
|
+
export declare function createComponentDoc<T extends AstryxComponentDocInput>(
|
|
130
|
+
def: T,
|
|
131
|
+
): T & {type: 'component'};
|
|
132
|
+
|
|
133
|
+
export declare function createFunctionDoc<T extends AstryxFunctionDocInput>(
|
|
134
|
+
def: T,
|
|
135
|
+
): T & {type: 'function'};
|
|
136
|
+
|
|
137
|
+
export declare function createDoc<T extends AstryxGenericDocInput>(
|
|
138
|
+
def: T,
|
|
139
|
+
): T & {type: 'generic'};
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* validation type, not part of the authoring surface.
|
|
4
|
+
* Integration manifest exported from a conventional root manifest file
|
|
5
|
+
* (astryx.integration.{ts,mjs,js}) sibling to the integration package's
|
|
6
|
+
* package.json. Identity (name/version) comes from the package's
|
|
7
|
+
* package.json, not from the manifest.
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
9
|
+
export interface AstryxIntegration {
|
|
10
|
+
/** Relative path to the components/docs root (resolved to absolute). */
|
|
11
|
+
components?: string;
|
|
12
|
+
/** Relative path to the templates root (resolved to absolute). */
|
|
13
|
+
templates?: string;
|
|
14
|
+
/** Relative path to the codemods root (resolved to absolute). */
|
|
15
|
+
codemods?: string;
|
|
16
|
+
/** Where to file issues/feedback for this integration. */
|
|
17
|
+
issuesUrl?: string;
|
|
18
|
+
}
|
|
12
19
|
|
|
13
20
|
/** An issue surfaced by an integration. */
|
|
14
21
|
export interface AstryxIntegrationIssue {
|
|
@@ -16,3 +23,7 @@ export interface AstryxIntegrationIssue {
|
|
|
16
23
|
severity: 'warning' | 'error';
|
|
17
24
|
message: string;
|
|
18
25
|
}
|
|
26
|
+
|
|
27
|
+
export declare function createIntegration<T extends AstryxIntegration>(
|
|
28
|
+
integration: T,
|
|
29
|
+
): T;
|
|
@@ -1,18 +1,54 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Authoring surface for Astryx static templates, exported from
|
|
5
|
+
* `@astryxdesign/cli/template`.
|
|
6
|
+
*
|
|
7
|
+
* A template doc lives in a `<id>.doc.{ts,mjs,js}` file with a required
|
|
8
|
+
* same-stem sibling source file (`<id>.tsx`). The doc's `type` (page or
|
|
9
|
+
* block) — injected by the create* helpers — decides how the template is
|
|
10
|
+
* scaffolded; there is no `/pages` vs `/blocks` directory requirement.
|
|
7
11
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
12
|
+
|
|
13
|
+
/** Optional preview metadata for a template (used by docs surfaces). */
|
|
14
|
+
export interface AstryxTemplatePreview {
|
|
15
|
+
/** Path or URL to a preview image. */
|
|
16
|
+
image?: string;
|
|
17
|
+
/** CSS aspect-ratio hint for the preview, e.g. "16 / 9". */
|
|
18
|
+
aspectRatio?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Fields common to page and block template docs (without the `type` tag). */
|
|
22
|
+
export interface AstryxTemplateInput {
|
|
23
|
+
/** Human-readable template name. Required. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** One-line description of what the template provides. Required. */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Optional grouping/category label. */
|
|
28
|
+
category?: string;
|
|
29
|
+
/** Component display names the template composes. */
|
|
30
|
+
componentsUsed?: string[];
|
|
31
|
+
/** Optional preview metadata. */
|
|
32
|
+
preview?: AstryxTemplatePreview;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Input accepted by {@link createPageTemplate} (no `type` field). */
|
|
36
|
+
export type AstryxPageTemplateInput = AstryxTemplateInput;
|
|
37
|
+
/** Input accepted by {@link createBlockTemplate} (no `type` field). */
|
|
38
|
+
export type AstryxBlockTemplateInput = AstryxTemplateInput;
|
|
39
|
+
|
|
40
|
+
/** A validated page template doc. */
|
|
41
|
+
export type AstryxPageTemplate = AstryxTemplateInput & {type: 'page'};
|
|
42
|
+
/** A validated block template doc. */
|
|
43
|
+
export type AstryxBlockTemplate = AstryxTemplateInput & {type: 'block'};
|
|
44
|
+
|
|
45
|
+
/** A validated template doc (page or block). */
|
|
46
|
+
export type AstryxTemplate = AstryxPageTemplate | AstryxBlockTemplate;
|
|
47
|
+
|
|
48
|
+
export declare function createPageTemplate<T extends AstryxPageTemplateInput>(
|
|
49
|
+
def: T,
|
|
50
|
+
): T & {type: 'page'};
|
|
51
|
+
|
|
52
|
+
export declare function createBlockTemplate<T extends AstryxBlockTemplateInput>(
|
|
53
|
+
def: T,
|
|
54
|
+
): T & {type: 'block'};
|
|
@@ -69,8 +69,8 @@ const styles: Record<string, CSSProperties> = {
|
|
|
69
69
|
propertyActions: {
|
|
70
70
|
marginTop: 'auto',
|
|
71
71
|
},
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
terminalArea: {
|
|
73
|
+
height: '100%',
|
|
74
74
|
overflow: 'hidden',
|
|
75
75
|
},
|
|
76
76
|
};
|
|
@@ -301,40 +301,46 @@ export default function ResizableWorkspacePage() {
|
|
|
301
301
|
label="Resize terminal"
|
|
302
302
|
/>
|
|
303
303
|
{!bottomPanel.isCollapsed && (
|
|
304
|
-
<
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
<Tab label="Output" value="output" />
|
|
317
|
-
<Tab label="Debug" value="debug" />
|
|
318
|
-
</TabList>
|
|
319
|
-
<StackItem
|
|
320
|
-
size="fill"
|
|
321
|
-
style={styles.terminalWrapper}>
|
|
322
|
-
<CodeBlock
|
|
323
|
-
code={TERMINAL_OUTPUT}
|
|
324
|
-
language="bash"
|
|
325
|
-
container="section"
|
|
326
|
-
hasLanguageLabel={false}
|
|
327
|
-
hasCopyButton={false}
|
|
304
|
+
<div
|
|
305
|
+
style={{
|
|
306
|
+
height: bottomPanel.size,
|
|
307
|
+
flexShrink: 0,
|
|
308
|
+
overflow: 'hidden',
|
|
309
|
+
}}>
|
|
310
|
+
<Stack
|
|
311
|
+
direction="vertical"
|
|
312
|
+
style={styles.contentFill}>
|
|
313
|
+
<TabList
|
|
314
|
+
value={activeTermTab}
|
|
315
|
+
onChange={val => setActiveTermTab(val)}
|
|
328
316
|
size="sm"
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
317
|
+
hasDivider={false}
|
|
318
|
+
style={styles.tabListPadding}>
|
|
319
|
+
<Tab label="Terminal" value="terminal" />
|
|
320
|
+
<Tab label="Problems" value="problems" />
|
|
321
|
+
<Tab label="Output" value="output" />
|
|
322
|
+
<Tab label="Debug" value="debug" />
|
|
323
|
+
</TabList>
|
|
324
|
+
<StackItem
|
|
325
|
+
size="fill"
|
|
326
|
+
style={styles.terminalWrapper}>
|
|
327
|
+
<CodeBlock
|
|
328
|
+
code={TERMINAL_OUTPUT}
|
|
329
|
+
language="bash"
|
|
330
|
+
container="section"
|
|
331
|
+
hasLanguageLabel={false}
|
|
332
|
+
hasCopyButton={false}
|
|
333
|
+
size="sm"
|
|
334
|
+
style={{
|
|
335
|
+
width: '100%',
|
|
336
|
+
height: '100%',
|
|
337
|
+
borderWidth: 0,
|
|
338
|
+
borderRadius: 0,
|
|
339
|
+
}}
|
|
340
|
+
/>
|
|
341
|
+
</StackItem>
|
|
342
|
+
</Stack>
|
|
343
|
+
</div>
|
|
338
344
|
)}
|
|
339
345
|
</Stack>
|
|
340
346
|
</LayoutContent>
|