@forgebook/react 0.0.0-stage → 0.1.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 +21 -0
- package/README.md +40 -2
- package/dist/src/StoryErrorBoundary.d.ts +59 -0
- package/dist/src/StoryErrorBoundary.d.ts.map +1 -0
- package/dist/src/StoryErrorBoundary.js +59 -0
- package/dist/src/StoryErrorBoundary.js.map +1 -0
- package/dist/src/clock.d.ts +26 -0
- package/dist/src/clock.d.ts.map +1 -0
- package/dist/src/clock.js +30 -0
- package/dist/src/clock.js.map +1 -0
- package/dist/src/mountFrame.d.ts +15 -0
- package/dist/src/mountFrame.d.ts.map +1 -0
- package/dist/src/mountFrame.js +16 -0
- package/dist/src/mountFrame.js.map +1 -0
- package/dist/src/reactRenderer.d.ts +15 -0
- package/dist/src/reactRenderer.d.ts.map +1 -0
- package/dist/src/reactRenderer.js +79 -0
- package/dist/src/reactRenderer.js.map +1 -0
- package/dist/src/stories.d.ts +49 -0
- package/dist/src/stories.d.ts.map +1 -0
- package/dist/src/stories.js +1 -0
- package/dist/src/stories.js.map +1 -0
- package/dist/src/storyElement.d.ts +19 -0
- package/dist/src/storyElement.d.ts.map +1 -0
- package/dist/src/storyElement.js +39 -0
- package/dist/src/storyElement.js.map +1 -0
- package/dist/src/storyJsx.d.ts +24 -0
- package/dist/src/storyJsx.d.ts.map +1 -0
- package/dist/src/storyJsx.js +48 -0
- package/dist/src/storyJsx.js.map +1 -0
- package/dist/src/texts.d.ts +21 -0
- package/dist/src/texts.d.ts.map +1 -0
- package/dist/src/texts.js +22 -0
- package/dist/src/texts.js.map +1 -0
- package/dist/src/vite/extractDocs.d.ts +19 -0
- package/dist/src/vite/extractDocs.d.ts.map +1 -0
- package/dist/src/vite/extractDocs.js +439 -0
- package/dist/src/vite/extractDocs.js.map +1 -0
- package/dist/src/vite/react.d.ts +10 -0
- package/dist/src/vite/react.d.ts.map +1 -0
- package/dist/src/vite/react.js +33 -0
- package/dist/src/vite/react.js.map +1 -0
- package/package.json +82 -3
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The texts inside the stories for React components inside a story: the shown language's table, as the frame provides
|
|
3
|
+
* it, read with `useStoryText()`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The table and the text function are the format's (`@forgebook/story-format/texts`); this module is how a React
|
|
7
|
+
* component reads them. The frame's renderer provides the table (`reactRenderer.tsx`); outside a catalogue there is
|
|
8
|
+
* none, and a text is its key in brackets.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { type StoryTextFunction } from "@forgebook/story-format/texts";
|
|
13
|
+
/** The texts of the shown language, as the catalogue's frame provides them; none outside a catalogue. */
|
|
14
|
+
export declare const StoryTextsContext: import("react").Context<Readonly<Record<string, string>>>;
|
|
15
|
+
/**
|
|
16
|
+
* The text function of the shown language, for a component inside a story.
|
|
17
|
+
*
|
|
18
|
+
* @returns `text(key, values?)`.
|
|
19
|
+
*/
|
|
20
|
+
export declare const useStoryText: () => StoryTextFunction;
|
|
21
|
+
//# sourceMappingURL=texts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texts.d.ts","sourceRoot":"","sources":["../../src/texts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,iBAAiB,EAAoC,MAAM,+BAA+B,CAAC;AAGzG,yGAAyG;AACzG,eAAO,MAAM,iBAAiB,2DAAoC,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,iBAA+D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The texts inside the stories for React components inside a story: the shown language's table, as the frame provides
|
|
3
|
+
* it, read with `useStoryText()`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* The table and the text function are the format's (`@forgebook/story-format/texts`); this module is how a React
|
|
7
|
+
* component reads them. The frame's renderer provides the table (`reactRenderer.tsx`); outside a catalogue there is
|
|
8
|
+
* none, and a text is its key in brackets.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { storyTextOf } from "@forgebook/story-format/texts";
|
|
13
|
+
import { createContext, useContext } from "react";
|
|
14
|
+
/** The texts of the shown language, as the catalogue's frame provides them; none outside a catalogue. */
|
|
15
|
+
export const StoryTextsContext = createContext({});
|
|
16
|
+
/**
|
|
17
|
+
* The text function of the shown language, for a component inside a story.
|
|
18
|
+
*
|
|
19
|
+
* @returns `text(key, values?)`.
|
|
20
|
+
*/
|
|
21
|
+
export const useStoryText = () => storyTextOf(useContext(StoryTextsContext));
|
|
22
|
+
//# sourceMappingURL=texts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"texts.js","sourceRoot":"","sources":["../../src/texts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAA+C,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACzG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,yGAAyG;AACzG,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAiB,EAAE,CAAC,CAAC;AAEnE;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAsB,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentDocs, NoComponentDocs } from "forgebook/component-docs";
|
|
2
|
+
import type { StoryComponentResult } from "forgebook/vite/adapter";
|
|
3
|
+
/**
|
|
4
|
+
* The docs of a story file's component.
|
|
5
|
+
*
|
|
6
|
+
* @param storyFile - the story file's absolute path.
|
|
7
|
+
* @returns the component's docs, `{ name: null }` when the meta names no component, or a message saying why the file
|
|
8
|
+
* cannot be read.
|
|
9
|
+
*/
|
|
10
|
+
export declare const extractComponentDocs: (storyFile: string) => ComponentDocs | NoComponentDocs | string;
|
|
11
|
+
/**
|
|
12
|
+
* A story file's component with the file that declares it.
|
|
13
|
+
*
|
|
14
|
+
* @param storyFile - the story file's absolute path.
|
|
15
|
+
* @returns the component, `{ docs: { name: null } }` when the meta names none, or a message saying why the file
|
|
16
|
+
* cannot be read.
|
|
17
|
+
*/
|
|
18
|
+
export declare const extractStoryComponent: (storyFile: string) => StoryComponentResult;
|
|
19
|
+
//# sourceMappingURL=extractDocs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDocs.d.ts","sourceRoot":"","sources":["../../../src/vite/extractDocs.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,aAAa,EAEb,eAAe,EAIhB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAgXnE;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAAI,WAAW,MAAM,KAAG,aAAa,GAAG,eAAe,GAAG,MAG1F,CAAC;AA8EF;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,GAAI,WAAW,MAAM,KAAG,oBAsCzD,CAAC"}
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The component of a React story file, read from its types and TSDoc: its props with their kind (the panel's group
|
|
3
|
+
* and control), its events' signatures and its parts. The docs module of `@forgebook/react`: the plugin's worker and
|
|
4
|
+
* `forgebook-docs` load it through the adapter (`forgebook/vite/adapter`).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The component is the meta's `component`. Its props are the first parameter's properties declared in the package:
|
|
8
|
+
* what it passes on to the DOM (`ComponentProps<"button">`) comes from `node_modules` and is left out. Parts are the
|
|
9
|
+
* keys of the `classNames`, `styles` and `refs` maps (the reach-every-part rule).
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { dirname } from "node:path";
|
|
14
|
+
import { moduleSummaryOf, programFor, summaryOf, tagOf } from "forgebook/vite/docs-program";
|
|
15
|
+
import { metaComponent, metaField } from "forgebook/vite/story-meta";
|
|
16
|
+
import ts from "typescript-6";
|
|
17
|
+
/** The props whose keys are the component's parts. */
|
|
18
|
+
const PART_MAPS = ["classNames", "styles", "refs"];
|
|
19
|
+
/** An event: a function prop named `on` and a capital. */
|
|
20
|
+
const EVENT_NAME = /^on[A-Z]/;
|
|
21
|
+
/**
|
|
22
|
+
* The subcomponents the meta names, in the order it writes them: `subcomponents: { ChipList, Items: MenuItem }`.
|
|
23
|
+
*
|
|
24
|
+
* @param source - the story file, parsed.
|
|
25
|
+
* @param checker - the program's checker.
|
|
26
|
+
*/
|
|
27
|
+
const metaSubcomponents = (source, checker) => {
|
|
28
|
+
const field = metaField(source, "subcomponents");
|
|
29
|
+
const object = field === undefined ? undefined : unwrapped(field);
|
|
30
|
+
if (object === undefined || !ts.isObjectLiteralExpression(object))
|
|
31
|
+
return [];
|
|
32
|
+
return object.properties.flatMap((property) => {
|
|
33
|
+
if (ts.isShorthandPropertyAssignment(property)) {
|
|
34
|
+
const symbol = checker.getShorthandAssignmentValueSymbol(property);
|
|
35
|
+
return [{ name: property.name.text, expression: property.name, symbol }];
|
|
36
|
+
}
|
|
37
|
+
if (!ts.isPropertyAssignment(property))
|
|
38
|
+
return [];
|
|
39
|
+
const name = ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)
|
|
40
|
+
? property.name.text
|
|
41
|
+
: property.name.getText(source);
|
|
42
|
+
const symbol = checker.getSymbolAtLocation(property.initializer);
|
|
43
|
+
return [{ name, expression: property.initializer, symbol }];
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
/** Whether a type is a union of string or number literals (a choice). */
|
|
47
|
+
const literalValues = (type) => {
|
|
48
|
+
if (!type.isUnion())
|
|
49
|
+
return undefined;
|
|
50
|
+
const values = type.types.map((member) => member.isStringLiteral() || member.isNumberLiteral() ? member.value : undefined);
|
|
51
|
+
return values.every((value) => value !== undefined)
|
|
52
|
+
? values.filter((value) => value !== undefined)
|
|
53
|
+
: undefined;
|
|
54
|
+
};
|
|
55
|
+
/** A literal value an expression writes (`"md"`, `3`, `-1`), or none for anything else. */
|
|
56
|
+
const literalOfExpression = (expression) => {
|
|
57
|
+
if (ts.isStringLiteral(expression) || ts.isNoSubstitutionTemplateLiteral(expression))
|
|
58
|
+
return expression.text;
|
|
59
|
+
if (ts.isNumericLiteral(expression))
|
|
60
|
+
return Number(expression.text);
|
|
61
|
+
if (ts.isPrefixUnaryExpression(expression) &&
|
|
62
|
+
expression.operator === ts.SyntaxKind.MinusToken &&
|
|
63
|
+
ts.isNumericLiteral(expression.operand)) {
|
|
64
|
+
return -Number(expression.operand.text);
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
};
|
|
68
|
+
/** An expression without the wrappers around a literal list (`as const`, `satisfies`, parentheses). */
|
|
69
|
+
const unwrapped = (expression) => {
|
|
70
|
+
let inner = expression;
|
|
71
|
+
while (ts.isAsExpression(inner) || ts.isSatisfiesExpression(inner) || ts.isParenthesizedExpression(inner)) {
|
|
72
|
+
inner = inner.expression;
|
|
73
|
+
}
|
|
74
|
+
return inner;
|
|
75
|
+
};
|
|
76
|
+
/** A symbol, through an import to what it names. */
|
|
77
|
+
const declaredSymbol = (symbol, checker) => symbol !== undefined && symbol.flags & ts.SymbolFlags.Alias ? checker.getAliasedSymbol(symbol) : symbol;
|
|
78
|
+
/** The value a literal type node writes (`"md"`, `3`, `-1`), or none for another literal (`true`, `null`). */
|
|
79
|
+
const literalTypeValue = (node) => {
|
|
80
|
+
const literal = node.literal;
|
|
81
|
+
const value = ts.isLiteralExpression(literal) || ts.isPrefixUnaryExpression(literal)
|
|
82
|
+
? literalOfExpression(literal)
|
|
83
|
+
: undefined;
|
|
84
|
+
return value === undefined ? [] : [value];
|
|
85
|
+
};
|
|
86
|
+
/** The values a tuple query writes (`(typeof SIZES)[number]` with `SIZES = ["md", "sm"] as const`), in its order. */
|
|
87
|
+
const tupleValues = (node, checker) => {
|
|
88
|
+
let object = node.objectType;
|
|
89
|
+
while (ts.isParenthesizedTypeNode(object))
|
|
90
|
+
object = object.type;
|
|
91
|
+
if (!ts.isTypeQueryNode(object))
|
|
92
|
+
return [];
|
|
93
|
+
const variable = declaredSymbol(checker.getSymbolAtLocation(object.exprName), checker)?.valueDeclaration;
|
|
94
|
+
if (variable === undefined || !ts.isVariableDeclaration(variable) || variable.initializer === undefined)
|
|
95
|
+
return [];
|
|
96
|
+
const list = unwrapped(variable.initializer);
|
|
97
|
+
if (!ts.isArrayLiteralExpression(list))
|
|
98
|
+
return [];
|
|
99
|
+
return list.elements.flatMap((element) => {
|
|
100
|
+
const value = literalOfExpression(element);
|
|
101
|
+
return value === undefined ? [] : [value];
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
/** The keys an object query writes (`keyof typeof TEXT_STYLES`), in the order the object writes them. */
|
|
105
|
+
const keyValues = (node, checker) => {
|
|
106
|
+
if (node.operator !== ts.SyntaxKind.KeyOfKeyword || !ts.isTypeQueryNode(node.type))
|
|
107
|
+
return [];
|
|
108
|
+
const variable = declaredSymbol(checker.getSymbolAtLocation(node.type.exprName), checker)?.valueDeclaration;
|
|
109
|
+
if (variable === undefined || !ts.isVariableDeclaration(variable) || variable.initializer === undefined)
|
|
110
|
+
return [];
|
|
111
|
+
const object = unwrapped(variable.initializer);
|
|
112
|
+
if (!ts.isObjectLiteralExpression(object))
|
|
113
|
+
return [];
|
|
114
|
+
return object.properties.flatMap((property) => {
|
|
115
|
+
const name = property.name;
|
|
116
|
+
return name !== undefined && (ts.isIdentifier(name) || ts.isStringLiteral(name)) ? [name.text] : [];
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* The values an indexed type writes: a tuple's members (`(typeof SIZES)[number]`), or another type's prop as that
|
|
121
|
+
* type declares it (`PopoverProps["side"]`).
|
|
122
|
+
*
|
|
123
|
+
* @param node - the indexed type.
|
|
124
|
+
* @param checker - the type checker.
|
|
125
|
+
* @param seen - the nodes already walked.
|
|
126
|
+
*/
|
|
127
|
+
const accessedValues = (node, checker, seen) => {
|
|
128
|
+
const index = node.indexType;
|
|
129
|
+
if (!ts.isLiteralTypeNode(index) || !ts.isStringLiteral(index.literal))
|
|
130
|
+
return tupleValues(node, checker);
|
|
131
|
+
const prop = checker.getPropertyOfType(checker.getTypeFromTypeNode(node.objectType), index.literal.text);
|
|
132
|
+
return (prop?.declarations ?? []).flatMap((declaration) => ts.isPropertySignature(declaration) && declaration.type !== undefined
|
|
133
|
+
? writtenLiterals(declaration.type, checker, seen)
|
|
134
|
+
: []);
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* The literal values a type node writes, in the order it writes them: through unions, aliases and a tuple's members.
|
|
138
|
+
*
|
|
139
|
+
* @param node - the type node.
|
|
140
|
+
* @param checker - the type checker, to follow a name to its declaration.
|
|
141
|
+
* @param seen - the nodes already walked, so a recursive alias ends.
|
|
142
|
+
*/
|
|
143
|
+
const writtenLiterals = (node, checker, seen) => {
|
|
144
|
+
if (seen.has(node))
|
|
145
|
+
return [];
|
|
146
|
+
seen.add(node);
|
|
147
|
+
if (ts.isParenthesizedTypeNode(node))
|
|
148
|
+
return writtenLiterals(node.type, checker, seen);
|
|
149
|
+
if (ts.isUnionTypeNode(node))
|
|
150
|
+
return node.types.flatMap((member) => writtenLiterals(member, checker, seen));
|
|
151
|
+
if (ts.isLiteralTypeNode(node))
|
|
152
|
+
return literalTypeValue(node);
|
|
153
|
+
if (ts.isIndexedAccessTypeNode(node))
|
|
154
|
+
return accessedValues(node, checker, seen);
|
|
155
|
+
if (ts.isTypeOperatorNode(node))
|
|
156
|
+
return keyValues(node, checker);
|
|
157
|
+
if (!ts.isTypeReferenceNode(node))
|
|
158
|
+
return [];
|
|
159
|
+
// a generic's arguments first (`Exclude<TableVariant, "changes">`): the values it keeps come from them
|
|
160
|
+
const fromArguments = (node.typeArguments ?? []).flatMap((argument) => writtenLiterals(argument, checker, seen));
|
|
161
|
+
const alias = declaredSymbol(checker.getSymbolAtLocation(node.typeName), checker)?.declarations?.find(ts.isTypeAliasDeclaration);
|
|
162
|
+
return [...fromArguments, ...(alias === undefined ? [] : writtenLiterals(alias.type, checker, seen))];
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* A choice's values in the order the source writes them: the checker's order follows the order it happened to meet
|
|
166
|
+
* the types in, which a program kept between reads changes from one read to the next.
|
|
167
|
+
*
|
|
168
|
+
* @param values - the values, in the checker's order.
|
|
169
|
+
* @param symbol - the prop.
|
|
170
|
+
* @param checker - the type checker.
|
|
171
|
+
* @returns the values, those the source writes in its order first, any other after them in the checker's order.
|
|
172
|
+
*/
|
|
173
|
+
const writtenOrder = (values, symbol, checker) => {
|
|
174
|
+
const seen = new Set();
|
|
175
|
+
const written = declaredTypesOf(symbol).flatMap((node) => ts.isMethodSignature(node) ? [] : writtenLiterals(node, checker, seen));
|
|
176
|
+
const rank = (value) => {
|
|
177
|
+
const index = written.indexOf(value);
|
|
178
|
+
return index === -1 ? written.length : index;
|
|
179
|
+
};
|
|
180
|
+
return [...values].sort((left, right) => rank(left) - rank(right));
|
|
181
|
+
};
|
|
182
|
+
/** A choice's type as TypeScript writes it, its members in the given order (`"md" | "sm"`). */
|
|
183
|
+
const choiceTypeText = (values) => values.map((value) => (typeof value === "string" ? JSON.stringify(value) : String(value))).join(" | ");
|
|
184
|
+
/**
|
|
185
|
+
* The props in the order the source declares them: those declared in the component's own folder first, then the
|
|
186
|
+
* ones it takes from elsewhere, each by file and position. The checker's order follows the types it met first (an
|
|
187
|
+
* `Omit`'s keys are a union), so a program kept between reads changed it from one read to the next.
|
|
188
|
+
*
|
|
189
|
+
* @param props - the props.
|
|
190
|
+
* @param componentFolder - the folder of the file that declares the component.
|
|
191
|
+
*/
|
|
192
|
+
const declarationOrder = (props, componentFolder) => {
|
|
193
|
+
const keyOf = (prop) => {
|
|
194
|
+
const [declaration] = prop.declarations ?? [];
|
|
195
|
+
if (declaration === undefined)
|
|
196
|
+
return [2, "", 0];
|
|
197
|
+
const file = declaration.getSourceFile().fileName;
|
|
198
|
+
return [dirname(file) === componentFolder ? 0 : 1, file, declaration.getStart()];
|
|
199
|
+
};
|
|
200
|
+
return [...props].sort((left, right) => {
|
|
201
|
+
const [leftOwn, leftFile, leftAt] = keyOf(left);
|
|
202
|
+
const [rightOwn, rightFile, rightAt] = keyOf(right);
|
|
203
|
+
return leftOwn - rightOwn || leftFile.localeCompare(rightFile) || leftAt - rightAt;
|
|
204
|
+
});
|
|
205
|
+
};
|
|
206
|
+
/** A type node's text as the source writes it, on one line. */
|
|
207
|
+
const nodeText = (node) => node.getText().replace(/\s+/g, " ").trim();
|
|
208
|
+
/**
|
|
209
|
+
* Whether a type node adds nothing a prop can take: `undefined` and `null` (left out as the checker's `NonNullable`
|
|
210
|
+
* did) and `never` (a branch of the props where the prop is not allowed).
|
|
211
|
+
*/
|
|
212
|
+
const isNothing = (node) => node.kind === ts.SyntaxKind.UndefinedKeyword ||
|
|
213
|
+
node.kind === ts.SyntaxKind.NeverKeyword ||
|
|
214
|
+
(ts.isLiteralTypeNode(node) && node.literal.kind === ts.SyntaxKind.NullKeyword);
|
|
215
|
+
/** A type node without its parentheses. */
|
|
216
|
+
const bareType = (node) => ts.isParenthesizedTypeNode(node) ? bareType(node.type) : node;
|
|
217
|
+
/**
|
|
218
|
+
* A prop's declared type without what adds nothing (`undefined`, `null`, `never`): the members of a written union, or
|
|
219
|
+
* the node itself.
|
|
220
|
+
*
|
|
221
|
+
* @param node - the prop's declared type.
|
|
222
|
+
*/
|
|
223
|
+
const declaredMembers = (node) => {
|
|
224
|
+
const bare = bareType(node);
|
|
225
|
+
return (ts.isUnionTypeNode(bare) ? bare.types : [bare]).filter((member) => !isNothing(member));
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* A prop's declared type nodes: a property's type or a method's whole signature, once per declaration. A prop of
|
|
229
|
+
* props written as alternatives (`{ indicator?: never } | { indicator?: "dot" | "spinner" }`) has one per branch.
|
|
230
|
+
*
|
|
231
|
+
* @param symbol - the prop.
|
|
232
|
+
*/
|
|
233
|
+
const declaredTypesOf = (symbol) => (symbol.declarations ?? []).flatMap((declaration) => {
|
|
234
|
+
if (ts.isMethodSignature(declaration))
|
|
235
|
+
return [declaration];
|
|
236
|
+
return ts.isPropertySignature(declaration) && declaration.type !== undefined ? [declaration.type] : [];
|
|
237
|
+
});
|
|
238
|
+
/**
|
|
239
|
+
* A prop's type as the source writes it (`ReactNode`, `Ref<HTMLElement>`), without `undefined` and `null`: the
|
|
240
|
+
* checker's own text expands it and orders a union's members by the order it met the types in, which a program kept
|
|
241
|
+
* between reads changes from one read to the next.
|
|
242
|
+
*
|
|
243
|
+
* @param symbol - the prop.
|
|
244
|
+
* @returns the text, or none when the prop writes no type (the caller falls back to the checker's).
|
|
245
|
+
*/
|
|
246
|
+
const writtenTypeText = (symbol) => {
|
|
247
|
+
const texts = declaredTypesOf(symbol).flatMap((declared) => {
|
|
248
|
+
if (!ts.isMethodSignature(declared))
|
|
249
|
+
return declaredMembers(declared).map(nodeText);
|
|
250
|
+
const parameters = declared.parameters.map(nodeText).join(", ");
|
|
251
|
+
return [`(${parameters}) => ${declared.type === undefined ? "void" : nodeText(declared.type)}`];
|
|
252
|
+
});
|
|
253
|
+
// each branch's members once, in the order the branches write them
|
|
254
|
+
const unique = [...new Set(texts)];
|
|
255
|
+
return unique.length === 0 ? undefined : unique.join(" | ");
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* An event's signature as the source writes it: a function type among the prop's declared members, or a method.
|
|
259
|
+
*
|
|
260
|
+
* @param symbol - the event prop.
|
|
261
|
+
* @returns the signature, or none when the source writes none in place (a named handler type).
|
|
262
|
+
*/
|
|
263
|
+
const writtenSignature = (symbol) => {
|
|
264
|
+
const nodes = declaredTypesOf(symbol).flatMap((declared) => ts.isMethodSignature(declared) ? [declared] : declaredMembers(declared));
|
|
265
|
+
const fn = nodes.find((node) => ts.isMethodSignature(node) || ts.isFunctionTypeNode(node));
|
|
266
|
+
if (fn === undefined)
|
|
267
|
+
return undefined;
|
|
268
|
+
return {
|
|
269
|
+
parameters: fn.parameters.map((parameter) => ({
|
|
270
|
+
name: nodeText(parameter.name),
|
|
271
|
+
type: parameter.type === undefined ? "unknown" : nodeText(parameter.type)
|
|
272
|
+
})),
|
|
273
|
+
returns: fn.type === undefined ? "void" : nodeText(fn.type)
|
|
274
|
+
};
|
|
275
|
+
};
|
|
276
|
+
/** An event's signature. */
|
|
277
|
+
const signatureOf = (type, checker, node) => {
|
|
278
|
+
const [signature] = type.getCallSignatures();
|
|
279
|
+
if (signature === undefined)
|
|
280
|
+
return undefined;
|
|
281
|
+
return {
|
|
282
|
+
parameters: signature.parameters.map((parameter) => ({
|
|
283
|
+
name: parameter.getName(),
|
|
284
|
+
type: checker.typeToString(checker.getTypeOfSymbolAtLocation(parameter, node))
|
|
285
|
+
})),
|
|
286
|
+
returns: checker.typeToString(signature.getReturnType())
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
/** A prop's kind, from its name and its type without `undefined`. */
|
|
290
|
+
const kindOf = (name, type) => {
|
|
291
|
+
if (EVENT_NAME.test(name) && type.getCallSignatures().length > 0)
|
|
292
|
+
return "event";
|
|
293
|
+
if (type.flags & ts.TypeFlags.Boolean || type.flags & ts.TypeFlags.BooleanLiteral)
|
|
294
|
+
return "toggle";
|
|
295
|
+
if (literalValues(type) !== undefined)
|
|
296
|
+
return "choice";
|
|
297
|
+
if (type.flags & ts.TypeFlags.String)
|
|
298
|
+
return "text";
|
|
299
|
+
if (type.flags & ts.TypeFlags.Number)
|
|
300
|
+
return "number";
|
|
301
|
+
return "other";
|
|
302
|
+
};
|
|
303
|
+
/** Whether a symbol is declared outside the package (a DOM attribute from React's types). */
|
|
304
|
+
const isForeign = (symbol) => (symbol.declarations ?? []).every((declaration) => declaration.getSourceFile().fileName.includes("/node_modules/"));
|
|
305
|
+
/** One prop's docs. */
|
|
306
|
+
const propDocs = (symbol, checker, node) => {
|
|
307
|
+
const type = checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(symbol, node));
|
|
308
|
+
const name = symbol.getName();
|
|
309
|
+
const kind = kindOf(name, type);
|
|
310
|
+
const defaultValue = tagOf(symbol, checker, "defaultValue");
|
|
311
|
+
const checkerChoices = kind === "choice" ? literalValues(type) : undefined;
|
|
312
|
+
const choices = checkerChoices === undefined ? undefined : writtenOrder(checkerChoices, symbol, checker);
|
|
313
|
+
const signature = kind === "event" ? (writtenSignature(symbol) ?? signatureOf(type, checker, node)) : undefined;
|
|
314
|
+
// a node takes a text: the panel can set it as one, which covers labels, titles and children
|
|
315
|
+
const canTakeText = kind === "other" && checker.isTypeAssignableTo(checker.getStringType(), type);
|
|
316
|
+
return {
|
|
317
|
+
name,
|
|
318
|
+
kind,
|
|
319
|
+
type: choices === undefined
|
|
320
|
+
? (writtenTypeText(symbol) ?? checker.typeToString(type))
|
|
321
|
+
: choiceTypeText(choices),
|
|
322
|
+
description: summaryOf(symbol, checker),
|
|
323
|
+
isRequired: (symbol.flags & ts.SymbolFlags.Optional) === 0,
|
|
324
|
+
...(defaultValue === undefined ? {} : { defaultValue }),
|
|
325
|
+
...(choices === undefined ? {} : { choices }),
|
|
326
|
+
...(signature === undefined ? {} : { signature }),
|
|
327
|
+
...(canTakeText ? { canTakeText } : {})
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* The docs of a story file's component.
|
|
332
|
+
*
|
|
333
|
+
* @param storyFile - the story file's absolute path.
|
|
334
|
+
* @returns the component's docs, `{ name: null }` when the meta names no component, or a message saying why the file
|
|
335
|
+
* cannot be read.
|
|
336
|
+
*/
|
|
337
|
+
export const extractComponentDocs = (storyFile) => {
|
|
338
|
+
const component = extractStoryComponent(storyFile);
|
|
339
|
+
return typeof component === "string" ? component : component.docs;
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* A component's props, read at the expression that names it.
|
|
343
|
+
*
|
|
344
|
+
* @param symbol - the component's symbol, through its import.
|
|
345
|
+
* @param expression - where the code names it.
|
|
346
|
+
* @param checker - the program's checker.
|
|
347
|
+
* @param storyFile - the story file, the folder when the component has no declaration.
|
|
348
|
+
*/
|
|
349
|
+
const componentProps = (symbol, expression, checker, storyFile) => {
|
|
350
|
+
const [signature] = checker.getTypeOfSymbolAtLocation(symbol, expression).getCallSignatures();
|
|
351
|
+
const propsSymbol = signature?.parameters[0];
|
|
352
|
+
const propsType = propsSymbol === undefined ? undefined : checker.getTypeOfSymbolAtLocation(propsSymbol, expression);
|
|
353
|
+
const ownProps = declarationOrder((propsType?.getProperties() ?? []).filter((prop) => !isForeign(prop)), dirname(symbol.declarations?.[0]?.getSourceFile().fileName ?? storyFile));
|
|
354
|
+
return { propsType, ownProps };
|
|
355
|
+
};
|
|
356
|
+
/**
|
|
357
|
+
* The files a component's docs come from: the one declaring it and those declaring its own props.
|
|
358
|
+
*
|
|
359
|
+
* @param symbol - the component's symbol.
|
|
360
|
+
* @param ownProps - its own props.
|
|
361
|
+
* @param storyFile - the story file, when the component has no declaration.
|
|
362
|
+
*/
|
|
363
|
+
const docsSources = (symbol, ownProps, storyFile) => [
|
|
364
|
+
symbol.declarations?.[0]?.getSourceFile().fileName ?? storyFile,
|
|
365
|
+
...ownProps.flatMap((prop) => (prop.declarations ?? []).map((declaration) => declaration.getSourceFile().fileName))
|
|
366
|
+
];
|
|
367
|
+
/**
|
|
368
|
+
* The docs of the subcomponents a story file's meta names, with the files they come from.
|
|
369
|
+
*
|
|
370
|
+
* @param source - the story file, parsed.
|
|
371
|
+
* @param checker - the program's checker.
|
|
372
|
+
* @returns the docs and their files, or a message naming the subcomponent that cannot be resolved.
|
|
373
|
+
*/
|
|
374
|
+
const subcomponentsOf = (source, checker) => {
|
|
375
|
+
const docs = [];
|
|
376
|
+
const sources = [];
|
|
377
|
+
for (const subcomponent of metaSubcomponents(source, checker)) {
|
|
378
|
+
const symbol = declaredSymbol(subcomponent.symbol, checker);
|
|
379
|
+
if (symbol === undefined) {
|
|
380
|
+
return `${source.fileName}: the meta's subcomponent ${subcomponent.name} cannot be resolved`;
|
|
381
|
+
}
|
|
382
|
+
const { ownProps } = componentProps(symbol, subcomponent.expression, checker, source.fileName);
|
|
383
|
+
docs.push({
|
|
384
|
+
name: subcomponent.name,
|
|
385
|
+
description: summaryOf(symbol, checker),
|
|
386
|
+
props: ownProps.map((prop) => propDocs(prop, checker, subcomponent.expression))
|
|
387
|
+
});
|
|
388
|
+
sources.push(...docsSources(symbol, ownProps, source.fileName));
|
|
389
|
+
}
|
|
390
|
+
return { docs, sources };
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* A story file's component with the file that declares it.
|
|
394
|
+
*
|
|
395
|
+
* @param storyFile - the story file's absolute path.
|
|
396
|
+
* @returns the component, `{ docs: { name: null } }` when the meta names none, or a message saying why the file
|
|
397
|
+
* cannot be read.
|
|
398
|
+
*/
|
|
399
|
+
export const extractStoryComponent = (storyFile) => {
|
|
400
|
+
const program = programFor(storyFile);
|
|
401
|
+
if (typeof program === "string")
|
|
402
|
+
return program;
|
|
403
|
+
const { checker } = program;
|
|
404
|
+
const source = program.program.getSourceFile(storyFile);
|
|
405
|
+
if (source === undefined)
|
|
406
|
+
return `${storyFile} is not in its program`;
|
|
407
|
+
const expression = metaComponent(source);
|
|
408
|
+
if (expression === undefined)
|
|
409
|
+
return { docs: { name: null } };
|
|
410
|
+
const symbol = declaredSymbol(checker.getSymbolAtLocation(expression), checker);
|
|
411
|
+
if (symbol === undefined)
|
|
412
|
+
return `${storyFile}: the meta's component cannot be resolved`;
|
|
413
|
+
const subcomponents = subcomponentsOf(source, checker);
|
|
414
|
+
if (typeof subcomponents === "string")
|
|
415
|
+
return subcomponents;
|
|
416
|
+
const { propsType, ownProps } = componentProps(symbol, expression, checker, storyFile);
|
|
417
|
+
const props = ownProps.map((prop) => propDocs(prop, checker, expression));
|
|
418
|
+
const parts = [
|
|
419
|
+
...new Set((propsType?.getProperties() ?? [])
|
|
420
|
+
.filter((prop) => PART_MAPS.includes(prop.getName()))
|
|
421
|
+
.flatMap((prop) => checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(prop, expression)).getProperties())
|
|
422
|
+
.map((part) => part.getName()))
|
|
423
|
+
];
|
|
424
|
+
const declarationFile = symbol.declarations?.[0]?.getSourceFile();
|
|
425
|
+
const sources = docsSources(symbol, ownProps, storyFile);
|
|
426
|
+
return {
|
|
427
|
+
docs: {
|
|
428
|
+
name: symbol.getName(),
|
|
429
|
+
description: summaryOf(symbol, checker),
|
|
430
|
+
summary: declarationFile === undefined ? "" : moduleSummaryOf(declarationFile),
|
|
431
|
+
props,
|
|
432
|
+
parts,
|
|
433
|
+
subcomponents: subcomponents.docs
|
|
434
|
+
},
|
|
435
|
+
file: sources[0] ?? storyFile,
|
|
436
|
+
sources: [...new Set([...sources, ...subcomponents.sources])]
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
//# sourceMappingURL=extractDocs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extractDocs.js","sourceRoot":"","sources":["../../../src/vite/extractDocs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE9B,sDAAsD;AACtD,MAAM,SAAS,GAAG,CAAC,YAAY,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;AAEnD,0DAA0D;AAC1D,MAAM,UAAU,GAAG,UAAU,CAAC;AAY9B;;;;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S;QAC7B,OAAO,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;KAC9D,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FrameworkAdapter } from "forgebook/vite/adapter";
|
|
2
|
+
/**
|
|
3
|
+
* React, as the plugin reads its components: the docs module the docs' worker loads is this package's
|
|
4
|
+
* `extractDocs.ts` (the props from the first parameter's type, events as `on*` props); the generated pages draw with
|
|
5
|
+
* its renderer and write code with its JSX writer; Vite gets React's plugin.
|
|
6
|
+
*
|
|
7
|
+
* @returns the adapter.
|
|
8
|
+
*/
|
|
9
|
+
export declare const react: () => FrameworkAdapter;
|
|
10
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/vite/react.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,QAAO,gBAkBvB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forgebook's adapter for React, for the Vite plugin: `forgebookPlugin({ framework: react() })`.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { extname } from "node:path";
|
|
7
|
+
/**
|
|
8
|
+
* React, as the plugin reads its components: the docs module the docs' worker loads is this package's
|
|
9
|
+
* `extractDocs.ts` (the props from the first parameter's type, events as `on*` props); the generated pages draw with
|
|
10
|
+
* its renderer and write code with its JSX writer; Vite gets React's plugin.
|
|
11
|
+
*
|
|
12
|
+
* @returns the adapter.
|
|
13
|
+
*/
|
|
14
|
+
export const react = () => ({
|
|
15
|
+
name: "react",
|
|
16
|
+
// beside this module, with its extension: `.ts` in the sources, `.js` once built for npm
|
|
17
|
+
docsModule: new URL(`./extractDocs${extname(import.meta.url)}`, import.meta.url).href,
|
|
18
|
+
pages: { frame: "@forgebook/react/frame", code: "@forgebook/react/code" },
|
|
19
|
+
// what the renderer and the JSX of the stories import in the frame (the server render for the generated tests)
|
|
20
|
+
browserDependencies: [
|
|
21
|
+
"react",
|
|
22
|
+
"react/jsx-runtime",
|
|
23
|
+
"react/jsx-dev-runtime",
|
|
24
|
+
"react-dom/client",
|
|
25
|
+
"react-dom/server"
|
|
26
|
+
],
|
|
27
|
+
// Fast Refresh: an edited component updates in its frame and the story keeps its state
|
|
28
|
+
vitePlugins: async () => {
|
|
29
|
+
const { default: plugin } = await import("@vitejs/plugin-react");
|
|
30
|
+
return [plugin()];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/vite/react.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,GAAqB,EAAE,CAAC,CAAC;IAC5C,IAAI,EAAE,OAAO;IACb,yFAAyF;IACzF,UAAU,EAAE,IAAI,GAAG,CAAC,gBAAgB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI;IACrF,KAAK,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,IAAI,EAAE,uBAAuB,EAAE;IACzE,+GAA+G;IAC/G,mBAAmB,EAAE;QACnB,OAAO;QACP,mBAAmB;QACnB,uBAAuB;QACvB,kBAAkB;QAClB,kBAAkB;KACnB;IACD,uFAAuF;IACvF,WAAW,EAAE,KAAK,IAAsC,EAAE;QACxD,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC;QACjE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACpB,CAAC;CACF,CAAC,CAAC"}
|