blockparty 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.
Files changed (51) hide show
  1. package/README.md +102 -0
  2. package/dist/cli.d.ts +3 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +54 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/build.d.ts +2 -0
  7. package/dist/commands/build.d.ts.map +1 -0
  8. package/dist/commands/build.js +66 -0
  9. package/dist/commands/build.js.map +1 -0
  10. package/dist/commands/storybook.d.ts +2 -0
  11. package/dist/commands/storybook.d.ts.map +1 -0
  12. package/dist/commands/storybook.js +95 -0
  13. package/dist/commands/storybook.js.map +1 -0
  14. package/dist/discoverBlocks.d.ts +9 -0
  15. package/dist/discoverBlocks.d.ts.map +1 -0
  16. package/dist/discoverBlocks.js +63 -0
  17. package/dist/discoverBlocks.js.map +1 -0
  18. package/dist/extractProps.d.ts +10 -0
  19. package/dist/extractProps.d.ts.map +1 -0
  20. package/dist/extractProps.js +251 -0
  21. package/dist/extractProps.js.map +1 -0
  22. package/dist/extractProps.test.d.ts +2 -0
  23. package/dist/extractProps.test.d.ts.map +1 -0
  24. package/dist/extractProps.test.js +305 -0
  25. package/dist/extractProps.test.js.map +1 -0
  26. package/dist/generateBlocksModule.d.ts +3 -0
  27. package/dist/generateBlocksModule.d.ts.map +1 -0
  28. package/dist/generateBlocksModule.js +21 -0
  29. package/dist/generateBlocksModule.js.map +1 -0
  30. package/dist/index.d.ts +4 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +5 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/parseReadme.d.ts +15 -0
  35. package/dist/parseReadme.d.ts.map +1 -0
  36. package/dist/parseReadme.js +84 -0
  37. package/dist/parseReadme.js.map +1 -0
  38. package/dist/parseReadme.test.d.ts +2 -0
  39. package/dist/parseReadme.test.d.ts.map +1 -0
  40. package/dist/parseReadme.test.js +142 -0
  41. package/dist/parseReadme.test.js.map +1 -0
  42. package/dist/templates/App.tsx +236 -0
  43. package/dist/templates/ErrorBoundary.tsx +53 -0
  44. package/dist/templates/PropsEditor.tsx +707 -0
  45. package/dist/templates/index.html +27 -0
  46. package/dist/templates/index.tsx +10 -0
  47. package/dist/viteConfig.d.ts +12 -0
  48. package/dist/viteConfig.d.ts.map +1 -0
  49. package/dist/viteConfig.js +22 -0
  50. package/dist/viteConfig.js.map +1 -0
  51. package/package.json +60 -0
@@ -0,0 +1,251 @@
1
+ import { readFile } from 'fs/promises';
2
+ import * as ts from 'typescript';
3
+ function isFunctionType(typeNode) {
4
+ if (!typeNode)
5
+ return false;
6
+ if (ts.isFunctionTypeNode(typeNode))
7
+ return true;
8
+ // Check if it's a parenthesized function type like: (x: number) => void
9
+ if (ts.isParenthesizedTypeNode(typeNode)) {
10
+ return isFunctionType(typeNode.type);
11
+ }
12
+ return false;
13
+ }
14
+ function extractJSDocComment(node, sourceFile) {
15
+ const fullText = sourceFile.getFullText();
16
+ const commentRanges = ts.getLeadingCommentRanges(fullText, node.pos);
17
+ if (!commentRanges || commentRanges.length === 0) {
18
+ return undefined;
19
+ }
20
+ // Loop backwards to find the last comment starting with "/**"
21
+ for (let i = commentRanges.length - 1; i >= 0; i--) {
22
+ const range = commentRanges[i];
23
+ const commentText = fullText.substring(range.pos, range.end);
24
+ if (commentText.startsWith('/**')) {
25
+ // Parse JSDoc comment
26
+ return commentText
27
+ .replace(/^\/\*\*/, '') // Remove opening /**
28
+ .replace(/\*\/$/, '') // Remove closing */
29
+ .split('\n')
30
+ .map(line => line.trim().replace(/^\* ?/, '')) // Remove leading * from each line
31
+ .filter(line => line.length > 0) // Remove empty lines
32
+ .join(' ')
33
+ .trim();
34
+ }
35
+ }
36
+ return undefined;
37
+ }
38
+ function extractPropertiesFromType(typeNode, sourceFile) {
39
+ const props = [];
40
+ if (ts.isTypeLiteralNode(typeNode)) {
41
+ for (const member of typeNode.members) {
42
+ if (ts.isPropertySignature(member) && member.name) {
43
+ // Skip function-typed properties
44
+ if (isFunctionType(member.type)) {
45
+ continue;
46
+ }
47
+ const name = member.name.getText(sourceFile);
48
+ const optional = !!member.questionToken;
49
+ const type = member.type ? member.type.getText(sourceFile) : 'any';
50
+ const propDef = { name, type, optional };
51
+ // Extract JSDoc comment if available
52
+ const description = extractJSDocComment(member, sourceFile);
53
+ if (description) {
54
+ propDef.description = description;
55
+ }
56
+ // If this property has a type, try to extract nested properties
57
+ if (member.type) {
58
+ const nestedProps = extractNestedProperties(member.type, sourceFile);
59
+ if (nestedProps.length > 0) {
60
+ propDef.properties = nestedProps;
61
+ }
62
+ }
63
+ props.push(propDef);
64
+ }
65
+ }
66
+ }
67
+ else if (ts.isTypeReferenceNode(typeNode)) {
68
+ // Type reference like "Props" or "ComponentProps"
69
+ const typeName = typeNode.typeName.getText(sourceFile);
70
+ // Find the type declaration
71
+ const typeDecl = findTypeDeclaration(sourceFile, typeName);
72
+ if (typeDecl) {
73
+ return extractPropertiesFromDeclaration(typeDecl, sourceFile);
74
+ }
75
+ }
76
+ return props;
77
+ }
78
+ function extractNestedProperties(typeNode, sourceFile) {
79
+ // Handle array types - extract element type
80
+ if (ts.isArrayTypeNode(typeNode)) {
81
+ return extractNestedProperties(typeNode.elementType, sourceFile);
82
+ }
83
+ // Handle inline object types
84
+ if (ts.isTypeLiteralNode(typeNode)) {
85
+ return extractPropertiesFromType(typeNode, sourceFile);
86
+ }
87
+ // Handle type references
88
+ if (ts.isTypeReferenceNode(typeNode)) {
89
+ const typeName = typeNode.typeName.getText(sourceFile);
90
+ const typeDecl = findTypeDeclaration(sourceFile, typeName);
91
+ if (typeDecl) {
92
+ return extractPropertiesFromDeclaration(typeDecl, sourceFile);
93
+ }
94
+ }
95
+ return [];
96
+ }
97
+ function extractPropertiesFromDeclaration(decl, sourceFile) {
98
+ const props = [];
99
+ if (ts.isInterfaceDeclaration(decl)) {
100
+ for (const member of decl.members) {
101
+ if (ts.isPropertySignature(member) && member.name) {
102
+ // Skip function-typed properties
103
+ if (isFunctionType(member.type)) {
104
+ continue;
105
+ }
106
+ const name = member.name.getText(sourceFile);
107
+ const optional = !!member.questionToken;
108
+ const type = member.type ? member.type.getText(sourceFile) : 'any';
109
+ const propDef = { name, type, optional };
110
+ // Extract JSDoc comment if available
111
+ const description = extractJSDocComment(member, sourceFile);
112
+ if (description) {
113
+ propDef.description = description;
114
+ }
115
+ // Try to extract nested properties
116
+ if (member.type) {
117
+ const nestedProps = extractNestedProperties(member.type, sourceFile);
118
+ if (nestedProps.length > 0) {
119
+ propDef.properties = nestedProps;
120
+ }
121
+ }
122
+ props.push(propDef);
123
+ }
124
+ }
125
+ }
126
+ else if (ts.isTypeAliasDeclaration(decl) && decl.type) {
127
+ if (ts.isTypeLiteralNode(decl.type)) {
128
+ for (const member of decl.type.members) {
129
+ if (ts.isPropertySignature(member) && member.name) {
130
+ // Skip function-typed properties
131
+ if (isFunctionType(member.type)) {
132
+ continue;
133
+ }
134
+ const name = member.name.getText(sourceFile);
135
+ const optional = !!member.questionToken;
136
+ const type = member.type ? member.type.getText(sourceFile) : 'any';
137
+ const propDef = { name, type, optional };
138
+ // Extract JSDoc comment if available
139
+ const description = extractJSDocComment(member, sourceFile);
140
+ if (description) {
141
+ propDef.description = description;
142
+ }
143
+ // Try to extract nested properties
144
+ if (member.type) {
145
+ const nestedProps = extractNestedProperties(member.type, sourceFile);
146
+ if (nestedProps.length > 0) {
147
+ propDef.properties = nestedProps;
148
+ }
149
+ }
150
+ props.push(propDef);
151
+ }
152
+ }
153
+ }
154
+ }
155
+ return props;
156
+ }
157
+ function findTypeDeclaration(sourceFile, typeName) {
158
+ let result = null;
159
+ function visit(node) {
160
+ if ((ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) && node.name.text === typeName) {
161
+ result = node;
162
+ }
163
+ ts.forEachChild(node, visit);
164
+ }
165
+ visit(sourceFile);
166
+ return result;
167
+ }
168
+ export function extractPropsFromSource(content, fileName = 'source.tsx') {
169
+ const sourceFile = ts.createSourceFile(fileName, content, ts.ScriptTarget.Latest, true);
170
+ // Find the default export
171
+ let defaultExport = null;
172
+ function visit(node) {
173
+ // export default ...
174
+ if (ts.isExportAssignment(node) && !node.isExportEquals) {
175
+ defaultExport = node;
176
+ }
177
+ // export default function Component(props: Props) { ... }
178
+ else if (ts.isFunctionDeclaration(node)) {
179
+ const hasExport = node.modifiers?.some(m => m.kind === ts.SyntaxKind.ExportKeyword);
180
+ const hasDefault = node.modifiers?.some(m => m.kind === ts.SyntaxKind.DefaultKeyword);
181
+ if (hasExport && hasDefault) {
182
+ defaultExport = node;
183
+ }
184
+ }
185
+ ts.forEachChild(node, visit);
186
+ }
187
+ visit(sourceFile);
188
+ if (!defaultExport) {
189
+ return [];
190
+ }
191
+ // Get the function from the default export
192
+ let func = null;
193
+ if (ts.isFunctionDeclaration(defaultExport)) {
194
+ func = defaultExport;
195
+ }
196
+ else {
197
+ // Must be ExportAssignment
198
+ const exportAssignment = defaultExport;
199
+ const expr = exportAssignment.expression;
200
+ if (ts.isArrowFunction(expr) || ts.isFunctionExpression(expr)) {
201
+ func = expr;
202
+ }
203
+ else if (ts.isIdentifier(expr)) {
204
+ // export default ComponentName - need to find the declaration
205
+ const funcDecl = findFunctionDeclaration(sourceFile, expr.text);
206
+ if (funcDecl) {
207
+ func = funcDecl;
208
+ }
209
+ }
210
+ }
211
+ if (!func || !func.parameters || func.parameters.length === 0) {
212
+ return [];
213
+ }
214
+ // Get the first parameter's type
215
+ const firstParam = func.parameters[0];
216
+ if (!firstParam.type) {
217
+ return [];
218
+ }
219
+ return extractPropertiesFromType(firstParam.type, sourceFile);
220
+ }
221
+ function findFunctionDeclaration(sourceFile, name) {
222
+ let result = null;
223
+ function visit(node) {
224
+ if (ts.isFunctionDeclaration(node) && node.name?.text === name) {
225
+ result = node;
226
+ }
227
+ else if (ts.isVariableStatement(node)) {
228
+ for (const decl of node.declarationList.declarations) {
229
+ if (ts.isIdentifier(decl.name) && decl.name.text === name && decl.initializer) {
230
+ if (ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer)) {
231
+ result = decl.initializer;
232
+ }
233
+ }
234
+ }
235
+ }
236
+ ts.forEachChild(node, visit);
237
+ }
238
+ visit(sourceFile);
239
+ return result;
240
+ }
241
+ export async function extractPropsFromFile(filePath) {
242
+ try {
243
+ const content = await readFile(filePath, 'utf-8');
244
+ return extractPropsFromSource(content, filePath);
245
+ }
246
+ catch (error) {
247
+ console.error(`Error extracting props from ${filePath}:`, error);
248
+ return [];
249
+ }
250
+ }
251
+ //# sourceMappingURL=extractProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractProps.js","sourceRoot":"","sources":["../src/extractProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAUhC,SAAS,cAAc,CAAC,QAAiC;IACvD,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC3B,IAAI,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAA;IAEhD,wEAAwE;IACxE,IAAI,EAAE,CAAC,uBAAuB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAa,EAAE,UAAyB;IACnE,MAAM,QAAQ,GAAG,UAAU,CAAC,WAAW,EAAE,CAAA;IACzC,MAAM,aAAa,GAAG,EAAE,CAAC,uBAAuB,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAA;IAEpE,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,8DAA8D;IAC9D,KAAK,IAAI,CA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oot":"","sources":["../src/extractProps.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,305 @@
1
+ import { test, describe } from 'node:test';
2
+ import assert from 'node:assert';
3
+ import { extractPropsFromSource } from './extractProps.js';
4
+ describe('extractPropsFromSource', () => {
5
+ test('extracts props from interface named Props', () => {
6
+ const source = `
7
+ export interface Props {
8
+ name: string
9
+ age: number
10
+ optional?: boolean
11
+ }
12
+
13
+ export default ({ name, age }: Props) => <div>{name}</div>
14
+ `;
15
+ const props = extractPropsFromSource(source);
16
+ assert.strictEqual(props.length, 3);
17
+ assert.deepStrictEqual(props[0], { name: 'name', type: 'string', optional: false });
18
+ assert.deepStrictEqual(props[1], { name: 'age', type: 'number', optional: false });
19
+ assert.deepStrictEqual(props[2], { name: 'optional', type: 'boolean', optional: true });
20
+ });
21
+ test('extracts props from only exported type', () => {
22
+ const source = `
23
+ export type MyProps = {
24
+ title: string
25
+ count?: number
26
+ }
27
+
28
+ export default ({ title }: MyProps) => <div>{title}</div>
29
+ `;
30
+ const props = extractPropsFromSource(source);
31
+ assert.strictEqual(props.length, 2);
32
+ assert.deepStrictEqual(props[0], { name: 'title', type: 'string', optional: false });
33
+ assert.deepStrictEqual(props[1], { name: 'count', type: 'number', optional: true });
34
+ });
35
+ test('extracts props from default export', () => {
36
+ const source = `
37
+ export type MyProps = {
38
+ title: string
39
+ }
40
+
41
+ export type NotProps = {
42
+ foo: string
43
+ }
44
+
45
+ export default ({ title }: MyProps) => <div>{title}</div>
46
+ export const Foo = ({ foo }: NotProps) => <div>{foo}</div>
47
+ `;
48
+ const props = extractPropsFromSource(source);
49
+ assert.strictEqual(props.length, 1);
50
+ assert.deepStrictEqual(props[0], { name: 'title', type: 'string', optional: false });
51
+ });
52
+ test('returns empty array when no Props interface found', () => {
53
+ const source = `
54
+ export default () => <div>No props</div>
55
+ `;
56
+ const props = extractPropsFromSource(source);
57
+ assert.strictEqual(props.length, 0);
58
+ });
59
+ test('returns empty array when multiple types exported but no Props', () => {
60
+ const source = `
61
+ export interface Foo {
62
+ x: string
63
+ }
64
+
65
+ export interface Bar {
66
+ y: number
67
+ }
68
+
69
+ export default () => <div>Multiple types</div>
70
+ `;
71
+ const props = extractPropsFromSource(source);
72
+ assert.strictEqual(props.length, 0);
73
+ });
74
+ test('prefers Props interface over other exported types', () => {
75
+ const source = `
76
+ export interface OtherType {
77
+ wrong: string
78
+ }
79
+
80
+ export interface Props {
81
+ correct: number
82
+ }
83
+
84
+ export default ({ correct }: Props) => <div>{correct}</div>
85
+ `;
86
+ const props = extractPropsFromSource(source);
87
+ assert.strictEqual(props.length, 1);
88
+ assert.deepStrictEqual(props[0], { name: 'correct', type: 'number', optional: false });
89
+ });
90
+ test('handles complex types', () => {
91
+ const source = `
92
+ export interface Props {
93
+ items: string[]
94
+ callback: (x: number) => void
95
+ config: { key: string }
96
+ }
97
+
98
+ export default (props: Props) => <div>Complex</div>
99
+ `;
100
+ const props = extractPropsFromSource(source);
101
+ // callback is filtered out because it's a function type
102
+ assert.strictEqual(props.length, 2);
103
+ assert.strictEqual(props[0].name, 'items');
104
+ assert.strictEqual(props[0].type, 'string[]');
105
+ assert.strictEqual(props[1].name, 'config');
106
+ assert.strictEqual(props[1].type, '{ key: string }');
107
+ });
108
+ test('extracts props from default export parameter type (multiple types exported)', () => {
109
+ const source = `
110
+ export interface UserData {
111
+ id: number
112
+ name: string
113
+ }
114
+
115
+ export interface ComponentProps {
116
+ title: string
117
+ enabled?: boolean
118
+ }
119
+
120
+ export default ({ title, enabled }: ComponentProps) => <div>{title}</div>
121
+ `;
122
+ const props = extractPropsFromSource(source);
123
+ assert.strictEqual(props.length, 2);
124
+ assert.deepStrictEqual(props[0], { name: 'title', type: 'string', optional: false });
125
+ assert.deepStrictEqual(props[1], { name: 'enabled', type: 'boolean', optional: true });
126
+ });
127
+ test('extracts props from export default function syntax', () => {
128
+ const source = `
129
+ export interface ButtonProps {
130
+ label: string
131
+ onClick: () => void
132
+ disabled?: boolean
133
+ }
134
+
135
+ export default function Button({ label, onClick, disabled }: ButtonProps) {
136
+ return <button onClick={onClick} disabled={disabled}>{label}</button>
137
+ }
138
+ `;
139
+ const props = extractPropsFromSource(source);
140
+ // onClick is filtered out because it's a function type
141
+ assert.strictEqual(props.length, 2);
142
+ assert.deepStrictEqual(props[0], { name: 'label', type: 'string', optional: false });
143
+ assert.deepStrictEqual(props[1], { name: 'disabled', type: 'boolean', optional: true });
144
+ });
145
+ test('extracts JSDoc comments from interface props', () => {
146
+ const source = `
147
+ export interface Props {
148
+ /**
149
+ * The user's name
150
+ */
151
+ name: string
152
+ /**
153
+ * The user's age in years
154
+ */
155
+ age: number
156
+ /** Optional flag */
157
+ optional?: boolean
158
+ }
159
+
160
+ export default ({ name, age }: Props) => <div>{name}</div>
161
+ `;
162
+ const props = extractPropsFromSource(source);
163
+ assert.strictEqual(props.length, 3);
164
+ assert.strictEqual(props[0].name, 'name');
165
+ assert.strictEqual(props[0].description, "The user's name");
166
+ assert.strictEqual(props[1].name, 'age');
167
+ assert.strictEqual(props[1].description, "The user's age in years");
168
+ assert.strictEqual(props[2].name, 'optional');
169
+ assert.strictEqual(props[2].description, 'Optional flag');
170
+ });
171
+ test('extracts JSDoc comments from type alias props', () => {
172
+ const source = `
173
+ export type Props = {
174
+ /**
175
+ * The title to display
176
+ */
177
+ title: string
178
+ /** Number of items */
179
+ count?: number
180
+ }
181
+
182
+ export default ({ title }: Props) => <div>{title}</div>
183
+ `;
184
+ const props = extractPropsFromSource(source);
185
+ assert.strictEqual(props.length, 2);
186
+ assert.strictEqual(props[0].name, 'title');
187
+ assert.strictEqual(props[0].description, 'The title to display');
188
+ assert.strictEqual(props[1].name, 'count');
189
+ assert.strictEqual(props[1].description, 'Number of items');
190
+ });
191
+ test('ignores non-JSDoc comments', () => {
192
+ const source = `
193
+ export interface Props {
194
+ // This is a regular comment
195
+ name: string
196
+ /* This is a block comment */
197
+ age: number
198
+ /**
199
+ * This is a JSDoc comment
200
+ */
201
+ optional?: boolean
202
+ }
203
+
204
+ export default ({ name, age }: Props) => <div>{name}</div>
205
+ `;
206
+ const props = extractPropsFromSource(source);
207
+ assert.strictEqual(props.length, 3);
208
+ assert.strictEqual(props[0].description, undefined);
209
+ assert.strictEqual(props[1].description, undefined);
210
+ assert.strictEqual(props[2].description, 'This is a JSDoc comment');
211
+ });
212
+ test('extracts last JSDoc comment when multiple exist', () => {
213
+ const source = `
214
+ export interface Props {
215
+ /**
216
+ * First comment
217
+ */
218
+ /* Regular block comment */
219
+ /**
220
+ * Second comment (should be used)
221
+ */
222
+ name: string
223
+ }
224
+
225
+ export default ({ name }: Props) => <div>{name}</div>
226
+ `;
227
+ const props = extractPropsFromSource(source);
228
+ assert.strictEqual(props.length, 1);
229
+ assert.strictEqual(props[0].description, 'Second comment (should be used)');
230
+ });
231
+ test('handles props without JSDoc comments', () => {
232
+ const source = `
233
+ export interface Props {
234
+ /**
235
+ * Has a comment
236
+ */
237
+ commented: string
238
+ notCommented: number
239
+ }
240
+
241
+ export default ({ commented }: Props) => <div>{commented}</div>
242
+ `;
243
+ const props = extractPropsFromSource(source);
244
+ assert.strictEqual(props.length, 2);
245
+ assert.strictEqual(props[0].description, 'Has a comment');
246
+ assert.strictEqual(props[1].description, undefined);
247
+ });
248
+ test('filters out function-typed props', () => {
249
+ const source = `
250
+ export interface Props {
251
+ /**
252
+ * A regular string prop
253
+ */
254
+ name: string
255
+ /**
256
+ * A function prop (should be filtered)
257
+ */
258
+ onClick: () => void
259
+ /**
260
+ * Another function (should be filtered)
261
+ */
262
+ onHover: (x: number) => void
263
+ }
264
+
265
+ export default ({ name }: Props) => <div>{name}</div>
266
+ `;
267
+ const props = extractPropsFromSource(source);
268
+ assert.strictEqual(props.length, 1);
269
+ assert.strictEqual(props[0].name, 'name');
270
+ assert.strictEqual(props[0].description, 'A regular string prop');
271
+ });
272
+ test('extracts nested properties with descriptions', () => {
273
+ const source = `
274
+ export interface Config {
275
+ /**
276
+ * API key
277
+ */
278
+ apiKey: string
279
+ /**
280
+ * Timeout in milliseconds
281
+ */
282
+ timeout: number
283
+ }
284
+
285
+ export interface Props {
286
+ /**
287
+ * Configuration object
288
+ */
289
+ config: Config
290
+ }
291
+
292
+ export default ({ config }: Props) => <div>{config.apiKey}</div>
293
+ `;
294
+ const props = extractPropsFromSource(source);
295
+ assert.strictEqual(props.length, 1);
296
+ assert.strictEqual(props[0].name, 'config');
297
+ assert.strictEqual(props[0].description, 'Configuration object');
298
+ assert.strictEqual(props[0].properties?.length, 2);
299
+ assert.strictEqual(props[0].properties?.[0].name, 'apiKey');
300
+ assert.strictEqual(props[0].properties?.[0].description, 'API key');
301
+ assert.strictEqual(props[0].properties?.[1].name, 'timeout');
302
+ assert.strictEqual(props[0].properties?.[1].description, 'Timeout in milliseconds');
303
+ });
304
+ });
305
+ //# sourceMappingURL=extractProps.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractProps.test.js","sourceRoot":"","sources":["../src/extractProps.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAE1D,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAI,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACrD,MAAM,MAAM,GAAG;;;;;;;;CAQlB,CAAA;QAEG,MAAM,KAAK,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAA;QAE5C,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;QACnC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;QACnF,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,E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AC,WAAW,EAAE,sBAAsB,CAAC,CAAA;QAChE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;QAClD,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;QAC3D,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;QACnE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAC5D,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAA;IACrF,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { BlockInfo } from './discoverBlocks.js';
2
+ export declare function generateBlocksModule(blocks: BlockInfo[]): Promise<string>;
3
+ //# sourceMappingURL=generateBlocksModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateBlocksModule.d.ts","sourceRoot":"","sources":["../src/generateBlocksModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGpD,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB/E"}
@@ -0,0 +1,21 @@
1
+ export async function generateBlocksModule(blocks) {
2
+ // Generate block imports
3
+ const imports = blocks.map((block, idx) => `import Block${idx} from '${block.path.replace(/\\/g, '/')}'`).join('\n');
4
+ // Generate block configs
5
+ const blockConfigs = blocks.map((block, idx) => {
6
+ const blockInfo = {
7
+ name: block.name,
8
+ description: block.description,
9
+ propDefinitions: block.propDefinitions,
10
+ Component: null // Placeholder
11
+ };
12
+ return JSON.stringify(blockInfo).replace('null', `Block${idx}`);
13
+ }).join(',\n');
14
+ return `${imports}
15
+
16
+ export const blocks = [
17
+ ${blockConfigs}
18
+ ]
19
+ `;
20
+ }
21
+ //# sourceMappingURL=generateBlocksModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateBlocksModule.js","sourceRoot":"","sources":["../src/generateBlocksModule.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAmB;IAC5D,yBAAyB;IACzB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CACxC,eAAe,GAAG,UAAU,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,CAC9D,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,yBAAyB;IACzB,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC7C,MAAM,SAAS,GAAqB;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,SAAS,EAAE,IAAW,CAAE,cAAc;SACvC,CAAA;QACD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,GAAG,EAAE,CAAC,CAAA;IACjE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAEd,OAAO,GAAG,OAAO;;;EAGjB,YAAY;;CAEb,CAAA;AACD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { discoverBlocks, type BlockInfo } from './discoverBlocks.js';
2
+ export { startStorybookServer } from './commands/storybook.js';
3
+ export { buildStorybook } from './commands/build.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ // Public API exports for BlockParty library
2
+ export { discoverBlocks } from './discoverBlocks.js';
3
+ export { startStorybookServer } from './commands/storybook.js';
4
+ export { buildStorybook } from './commands/build.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAE5C,OAAO,EAAE,cAAc,EAAkB,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
@@ -0,0 +1,15 @@
1
+ export interface BlockMetadata {
2
+ name?: string;
3
+ description?: string;
4
+ /** The markdown content of the readme (not including frontmatter) */
5
+ readme?: string;
6
+ /** The metadata from the readme frontmatter */
7
+ frontmatter?: Record<string, string>;
8
+ }
9
+ export declare function parseFrontmatter(content: string): {
10
+ frontmatter: Record<string, string>;
11
+ content: string;
12
+ };
13
+ export declare function extractMarkdownMetadata(content: string): BlockMetadata;
14
+ export declare function parseReadmeMetadata(dirPath: string): Promise<BlockMetadata>;
15
+ //# sourceMappingURL=parseReadme.d.ts.map