@knapsack/renderer-react 4.71.19--canary.5314.3a527ea.0 → 4.71.19--canary.5222.4814b96.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/analyze/index.d.mts +2 -0
- package/dist/analyze/index.d.mts.map +1 -0
- package/dist/analyze/index.mjs +2 -0
- package/dist/analyze/index.mjs.map +1 -0
- package/dist/analyze/infer-spec-fixtures/components.d.ts +99 -0
- package/dist/analyze/infer-spec-fixtures/components.d.ts.map +1 -0
- package/dist/analyze/infer-spec-fixtures/components.js +59 -0
- package/dist/analyze/infer-spec-fixtures/components.js.map +1 -0
- package/dist/analyze/infer-spec-fixtures/index.d.mts +2 -0
- package/dist/analyze/infer-spec-fixtures/index.d.mts.map +1 -0
- package/dist/analyze/infer-spec-fixtures/index.mjs +2 -0
- package/dist/analyze/infer-spec-fixtures/index.mjs.map +1 -0
- package/dist/analyze/infer-spec.d.mts +27 -0
- package/dist/analyze/infer-spec.d.mts.map +1 -0
- package/dist/analyze/infer-spec.mjs +98 -0
- package/dist/analyze/infer-spec.mjs.map +1 -0
- package/dist/analyze/infer-spec.test.d.mts +2 -0
- package/dist/analyze/infer-spec.test.d.mts.map +1 -0
- package/dist/analyze/infer-spec.test.mjs +210 -0
- package/dist/analyze/infer-spec.test.mjs.map +1 -0
- package/dist/analyze/mui.test.d.mts +2 -0
- package/dist/analyze/mui.test.d.mts.map +1 -0
- package/dist/analyze/mui.test.mjs +88 -0
- package/dist/analyze/mui.test.mjs.map +1 -0
- package/dist/analyze/pkg-basic.test.d.mts +2 -0
- package/dist/analyze/pkg-basic.test.d.mts.map +1 -0
- package/dist/analyze/pkg-basic.test.mjs +28 -0
- package/dist/analyze/pkg-basic.test.mjs.map +1 -0
- package/dist/analyze/pkg-diff-types.test.d.mts +2 -0
- package/dist/analyze/pkg-diff-types.test.d.mts.map +1 -0
- package/dist/analyze/pkg-diff-types.test.mjs +29 -0
- package/dist/analyze/pkg-diff-types.test.mjs.map +1 -0
- package/dist/analyze/utils/importer.d.mts +17 -0
- package/dist/analyze/utils/importer.d.mts.map +1 -0
- package/dist/analyze/utils/importer.mjs +80 -0
- package/dist/analyze/utils/importer.mjs.map +1 -0
- package/dist/analyze/utils/react-component-analyzer.d.mts +24 -0
- package/dist/analyze/utils/react-component-analyzer.d.mts.map +1 -0
- package/dist/analyze/utils/react-component-analyzer.mjs +139 -0
- package/dist/analyze/utils/react-component-analyzer.mjs.map +1 -0
- package/dist/renderer-react.d.ts.map +1 -1
- package/dist/renderer-react.js +9 -8
- package/dist/renderer-react.js.map +1 -1
- package/package.json +16 -14
- package/turbo.json +9 -0
- package/dist/analyze/infer-spec.test.d.ts +0 -2
- package/dist/analyze/infer-spec.test.d.ts.map +0 -1
- package/dist/analyze/infer-spec.test.js +0 -112
- package/dist/analyze/infer-spec.test.js.map +0 -1
- package/dist/analyze/mui.test.d.ts +0 -2
- package/dist/analyze/mui.test.d.ts.map +0 -1
- package/dist/analyze/mui.test.js +0 -60
- package/dist/analyze/mui.test.js.map +0 -1
- package/dist/analyze/pkg-basic.test.d.ts +0 -2
- package/dist/analyze/pkg-basic.test.d.ts.map +0 -1
- package/dist/analyze/pkg-basic.test.js +0 -33
- package/dist/analyze/pkg-basic.test.js.map +0 -1
- package/dist/analyze/pkg-diff-types.test.d.ts +0 -2
- package/dist/analyze/pkg-diff-types.test.d.ts.map +0 -1
- package/dist/analyze/pkg-diff-types.test.js +0 -43
- package/dist/analyze/pkg-diff-types.test.js.map +0 -1
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/analyze/index.mts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/analyze/index.mts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import React, { ReactNode } from 'react';
|
2
|
+
type ButtonVariant = 'primary' | 'secondary' | 'tertiary';
|
3
|
+
type ButtonSize = 'small' | 'medium' | 'large';
|
4
|
+
type Status = 1 | 2 | 3;
|
5
|
+
interface ButtonProps {
|
6
|
+
/** The button's main variant */
|
7
|
+
variant: ButtonVariant;
|
8
|
+
/** The size of the button */
|
9
|
+
size?: ButtonSize;
|
10
|
+
/** Whether the button is disabled */
|
11
|
+
disabled?: boolean;
|
12
|
+
/** Click handler */
|
13
|
+
onClick?: () => void;
|
14
|
+
/** Status code */
|
15
|
+
status?: Status;
|
16
|
+
/** Specific literal string */
|
17
|
+
type?: 'button' | 'submit' | 'reset';
|
18
|
+
/** Specific literal number */
|
19
|
+
tabIndex?: -1 | 0 | 1;
|
20
|
+
/** Required literal */
|
21
|
+
role: 'button' | 'link';
|
22
|
+
children?: ReactNode;
|
23
|
+
}
|
24
|
+
export declare const Button: ({ variant, size, disabled, onClick, status, type, tabIndex, role, children, }: ButtonProps) => JSX.Element;
|
25
|
+
interface ComplexProps {
|
26
|
+
/** Array of user objects */
|
27
|
+
users: Array<{
|
28
|
+
id: number;
|
29
|
+
name: string;
|
30
|
+
role: 'admin' | 'user';
|
31
|
+
}>;
|
32
|
+
/** Configuration object */
|
33
|
+
config: {
|
34
|
+
theme: 'light' | 'dark';
|
35
|
+
showHeader: boolean;
|
36
|
+
};
|
37
|
+
}
|
38
|
+
export declare const ComplexComponent: ({ users, config, }: ComplexProps) => JSX.Element;
|
39
|
+
interface RenderPropsComponentProps {
|
40
|
+
/** Header render function */
|
41
|
+
renderHeader: () => ReactNode;
|
42
|
+
/** Content render function */
|
43
|
+
renderContent: (data: {
|
44
|
+
count: number;
|
45
|
+
}) => ReactNode;
|
46
|
+
/** Optional footer */
|
47
|
+
footer?: ReactNode;
|
48
|
+
}
|
49
|
+
export declare const RenderPropsComponent: ({ renderHeader, renderContent, footer, }: RenderPropsComponentProps) => JSX.Element;
|
50
|
+
interface TitleProps {
|
51
|
+
/** Main title text */
|
52
|
+
title: string;
|
53
|
+
/** Optional subtitle */
|
54
|
+
subtitle?: string;
|
55
|
+
}
|
56
|
+
export declare const TitleComponent: {
|
57
|
+
({ title, subtitle, }: TitleProps): JSX.Element;
|
58
|
+
propTypes: {
|
59
|
+
title: any;
|
60
|
+
subtitle: any;
|
61
|
+
};
|
62
|
+
};
|
63
|
+
export declare const OnlyPropTypesComponent: {
|
64
|
+
({ title }: TitleProps): JSX.Element;
|
65
|
+
propTypes: {
|
66
|
+
title: any;
|
67
|
+
};
|
68
|
+
};
|
69
|
+
interface ListProps<T> {
|
70
|
+
/** List of items */
|
71
|
+
items: T[];
|
72
|
+
/** Render function for each item */
|
73
|
+
renderItem: (item: T) => ReactNode;
|
74
|
+
}
|
75
|
+
export declare const ListComponent: <T>({ items, renderItem, }: ListProps<T>) => JSX.Element;
|
76
|
+
interface CounterProps {
|
77
|
+
/** Initial count value */
|
78
|
+
initialCount: number;
|
79
|
+
/** Step value for increment/decrement */
|
80
|
+
step?: number;
|
81
|
+
/** Optional label */
|
82
|
+
label?: string;
|
83
|
+
/** Counter variant */
|
84
|
+
variant: 'default' | 'compact';
|
85
|
+
}
|
86
|
+
interface CounterState {
|
87
|
+
count: number;
|
88
|
+
}
|
89
|
+
export declare class CounterComponent extends React.Component<CounterProps, CounterState> {
|
90
|
+
static defaultProps: {
|
91
|
+
step: number;
|
92
|
+
};
|
93
|
+
constructor({ initialCount, variant }: CounterProps);
|
94
|
+
handleIncrement: () => void;
|
95
|
+
handleDecrement: () => void;
|
96
|
+
render(): JSX.Element;
|
97
|
+
}
|
98
|
+
export {};
|
99
|
+
//# sourceMappingURL=components.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../../src/analyze/infer-spec-fixtures/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIzC,KAAK,aAAa,GAAG,SAAS,GAAG,WAAW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EO,MAAM,IAAI,GAAG,CAAC,OAAO;CAiB/B"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.CounterComponent = exports.ListComponent = exports.OnlyPropTypesComponent = exports.TitleComponent = exports.RenderPropsComponent = exports.ComplexComponent = exports.Button = void 0;
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
8
|
+
const react_1 = __importDefault(require("react"));
|
9
|
+
const prop_types_1 = __importDefault(require("prop-types"));
|
10
|
+
const Button = ({ variant, size, disabled, onClick, status, type, tabIndex, role, children, }) => ((0, jsx_runtime_1.jsx)("button", { onClick: onClick, disabled: disabled, type: "button", tabIndex: tabIndex, role: role, children: children || 'Click me' }));
|
11
|
+
exports.Button = Button;
|
12
|
+
const ComplexComponent = ({ users, config, }) => ((0, jsx_runtime_1.jsx)("div", { children: users.map((user) => ((0, jsx_runtime_1.jsx)("div", { children: user.name }, user.id))) }));
|
13
|
+
exports.ComplexComponent = ComplexComponent;
|
14
|
+
const RenderPropsComponent = ({ renderHeader, renderContent, footer, }) => ((0, jsx_runtime_1.jsxs)("div", { children: [renderHeader(), renderContent({ count: 0 }), footer] }));
|
15
|
+
exports.RenderPropsComponent = RenderPropsComponent;
|
16
|
+
const TitleComponent = ({ title, subtitle, }) => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h1", { children: title }), subtitle && (0, jsx_runtime_1.jsx)("h2", { children: subtitle })] }));
|
17
|
+
exports.TitleComponent = TitleComponent;
|
18
|
+
exports.TitleComponent.propTypes = {
|
19
|
+
title: prop_types_1.default.string.isRequired,
|
20
|
+
subtitle: prop_types_1.default.string,
|
21
|
+
};
|
22
|
+
// Example with only PropTypes
|
23
|
+
const OnlyPropTypesComponent = ({ title }) => ((0, jsx_runtime_1.jsx)("div", { children: title }));
|
24
|
+
exports.OnlyPropTypesComponent = OnlyPropTypesComponent;
|
25
|
+
exports.OnlyPropTypesComponent.propTypes = {
|
26
|
+
title: prop_types_1.default.string.isRequired,
|
27
|
+
};
|
28
|
+
const ListComponent = ({ items, renderItem, }) => ((0, jsx_runtime_1.jsx)("ul", { children: items.map((item, index) => ((0, jsx_runtime_1.jsx)("li", { children: renderItem(item) }, JSON.stringify(item)))) }));
|
29
|
+
exports.ListComponent = ListComponent;
|
30
|
+
class CounterComponent extends react_1.default.Component {
|
31
|
+
constructor({ initialCount, variant }) {
|
32
|
+
super({ initialCount, variant });
|
33
|
+
this.handleIncrement = () => {
|
34
|
+
const { step = 1 } = this.props;
|
35
|
+
this.setState((prevState) => ({
|
36
|
+
count: prevState.count + step,
|
37
|
+
}));
|
38
|
+
};
|
39
|
+
this.handleDecrement = () => {
|
40
|
+
const { step = 1 } = this.props;
|
41
|
+
this.setState((prevState) => ({
|
42
|
+
count: prevState.count - step,
|
43
|
+
}));
|
44
|
+
};
|
45
|
+
this.state = {
|
46
|
+
count: initialCount,
|
47
|
+
};
|
48
|
+
}
|
49
|
+
render() {
|
50
|
+
const { label, variant } = this.props;
|
51
|
+
const { count } = this.state;
|
52
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [label && (0, jsx_runtime_1.jsx)("span", { children: label }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: this.handleDecrement, children: "-" }), (0, jsx_runtime_1.jsx)("span", { children: count }), (0, jsx_runtime_1.jsx)("button", { type: "button", onClick: this.handleIncrement, children: "+" })] }));
|
53
|
+
}
|
54
|
+
}
|
55
|
+
exports.CounterComponent = CounterComponent;
|
56
|
+
CounterComponent.defaultProps = {
|
57
|
+
step: 1,
|
58
|
+
};
|
59
|
+
//# sourceMappingURL=components.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/analyze/infer-spec-fixtures/components.t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A,IAAI,CAAC,KAAK,GAAG;YACX,KAAK,EAAE,YAAY;SACpB,CAAC;IACJ,CAAC;IAgBQ,MAAM;QACb,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAE7B,OAAO,CACL,4CACG,KAAK,IAAI,2CAAO,KAAK,GAAQ,EAC9B,mCAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,IAAI,CAAC,eAAe,kBAE1C,EACT,2CAAO,KAAK,GAAQ,EACpB,mCAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,IAAI,CAAC,eAAe,kBAE1C,IACL,CACP,CAAC;IACJ,CAAC;;AA7CH,4CA8CC;AA1CQ,6BAAY,GAAG;IACpB,IAAI,EAAE,CAAC;CACR,AAFkB,CAEjB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/analyze/infer-spec-fixtures/index.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,aAAa,EACb,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/analyze/infer-spec-fixtures/index.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,sBAAsB,EACtB,aAAa,EACb,gBAAgB,GACjB,MAAM,iBAAiB,CAAC"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
export declare function inferSpec({ path, namedExport, resolveFrom, pkgPathAliases, }: {
|
2
|
+
path: string;
|
3
|
+
namedExport?: string;
|
4
|
+
resolveFrom?: string;
|
5
|
+
pkgPathAliases?: Record<string, string>;
|
6
|
+
}): Promise<{
|
7
|
+
ksTemplateSpec: {
|
8
|
+
isInferred: true;
|
9
|
+
hidePropsTable: true;
|
10
|
+
hideSlotsTable: true;
|
11
|
+
extraDocs: {
|
12
|
+
id: string;
|
13
|
+
title: string;
|
14
|
+
description?: string;
|
15
|
+
tableRows?: {
|
16
|
+
[columnTitle: string]: string;
|
17
|
+
}[];
|
18
|
+
}[];
|
19
|
+
props: import("@knapsack/types").JsonSchemaObject;
|
20
|
+
slots: {
|
21
|
+
[name: string]: import("@knapsack/types").KsSlotInfo;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
props: import("./utils/react-component-analyzer.mjs").ComponentProps;
|
25
|
+
slots: import("./utils/react-component-analyzer.mjs").SlotInfo[];
|
26
|
+
}>;
|
27
|
+
//# sourceMappingURL=infer-spec.d.mts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"infer-spec.d.mts","sourceRoot":"","sources":["../../src/analyze/infer-spec.mts"],"names":[],"mappings":"AAIA,wBAAsB,SAAS,CAAC,EAC9B,IAAI,EACJ,WAAW,EACX,WAA2B,EAC3B,cAAc,GACf,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;;;;;;;;;;;;;;;;;;;;GAwGA"}
|
@@ -0,0 +1,98 @@
|
|
1
|
+
import { convertToSpec } from '@knapsack/spec-utils';
|
2
|
+
import { analyzeComponent } from './utils/react-component-analyzer.mjs';
|
3
|
+
export async function inferSpec({ path, namedExport, resolveFrom = process.cwd(), pkgPathAliases, }) {
|
4
|
+
const { props: componentProps, slots: componentSlots } = await analyzeComponent({
|
5
|
+
fileName: path,
|
6
|
+
exportName: namedExport,
|
7
|
+
pkgPathAliases,
|
8
|
+
resolveFromDir: resolveFrom,
|
9
|
+
});
|
10
|
+
const props = {
|
11
|
+
$schema: 'http://json-schema.org/draft-07/schema',
|
12
|
+
type: 'object',
|
13
|
+
required: [],
|
14
|
+
properties: {},
|
15
|
+
};
|
16
|
+
const slots = componentSlots.reduce((acc, slot) => {
|
17
|
+
acc[slot.title] = slot;
|
18
|
+
return acc;
|
19
|
+
}, {});
|
20
|
+
const extraDocs = [];
|
21
|
+
// @TODO: Add overview table for react renderer
|
22
|
+
// https://linear.app/knapsack/issue/KSP-5870/update-react-renderer-api-docs-to-include-overview
|
23
|
+
// Path is currently the full path to the file, we need to get the package name from the path
|
24
|
+
// // Add component overview
|
25
|
+
// extraDocs.push({
|
26
|
+
// id: 'overview',
|
27
|
+
// title: 'Overview',
|
28
|
+
// description: '',
|
29
|
+
// tableRows: [
|
30
|
+
// {
|
31
|
+
// Title: 'Package',
|
32
|
+
// Description: `\`${path}\``,
|
33
|
+
// },
|
34
|
+
// {
|
35
|
+
// Title: 'Named Export',
|
36
|
+
// Description: `\`${namedExport}\``,
|
37
|
+
// },
|
38
|
+
// ],
|
39
|
+
// });
|
40
|
+
// Process props
|
41
|
+
const propsTableRows = [];
|
42
|
+
Object.entries(componentProps).forEach(([propName, propDetails]) => {
|
43
|
+
const { required, typeInfo: propTypeInfo } = propDetails;
|
44
|
+
if (propTypeInfo) {
|
45
|
+
const { prop } = convertToSpec({
|
46
|
+
typeInfo: propTypeInfo,
|
47
|
+
trustRequiredProps: false,
|
48
|
+
});
|
49
|
+
if (prop) {
|
50
|
+
props.properties[propName] = prop;
|
51
|
+
if (propDetails.description) {
|
52
|
+
props.properties[propName].description = propDetails.description;
|
53
|
+
}
|
54
|
+
if (required) {
|
55
|
+
props.required.push(propName);
|
56
|
+
}
|
57
|
+
}
|
58
|
+
propsTableRows.push({
|
59
|
+
'Prop Name': `\`${propName}\``,
|
60
|
+
Type: `\`${propTypeInfo.tsRawType || propTypeInfo.type || 'unknown'}\``,
|
61
|
+
Required: required ? 'Yes' : 'No',
|
62
|
+
Description: propDetails.description || '',
|
63
|
+
});
|
64
|
+
}
|
65
|
+
});
|
66
|
+
if (propsTableRows.length) {
|
67
|
+
extraDocs.push({
|
68
|
+
id: 'props',
|
69
|
+
title: 'Props',
|
70
|
+
description: '',
|
71
|
+
tableRows: propsTableRows,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
if (Object.keys(slots).length) {
|
75
|
+
extraDocs.push({
|
76
|
+
id: 'slots',
|
77
|
+
title: 'Slots',
|
78
|
+
description: '',
|
79
|
+
tableRows: Object.entries(slots).map(([slotName, slot]) => ({
|
80
|
+
'Slot Name': `\`${slotName}\``,
|
81
|
+
'Slot Title': slot.title,
|
82
|
+
})),
|
83
|
+
});
|
84
|
+
}
|
85
|
+
return {
|
86
|
+
ksTemplateSpec: {
|
87
|
+
isInferred: true,
|
88
|
+
hidePropsTable: true,
|
89
|
+
hideSlotsTable: true,
|
90
|
+
extraDocs,
|
91
|
+
props,
|
92
|
+
slots,
|
93
|
+
},
|
94
|
+
props: componentProps,
|
95
|
+
slots: componentSlots,
|
96
|
+
};
|
97
|
+
}
|
98
|
+
//# sourceMappingURL=infer-spec.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"infer-spec.mjs","sourceRoot":"","sources":["../../src/analyze/infer-spec.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC9B,IAAI,EACJ,WAAW,EACX,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,cAAc,GAMf;IACC,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE,GACpD,MAAM,gBAAgB,CAAC;QACrB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,WAAW;QACvB,cAAc;QACd,cAAc,EAAE,WAAW;KAC5B,CAAC,CAAC;IAEL,MAAM,KA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AC1B,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE,cAAc;KACtB,CAAC;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"infer-spec.test.d.mts","sourceRoot":"","sources":["../../src/analyze/infer-spec.test.mts"],"names":[],"mappings":""}
|
@@ -0,0 +1,210 @@
|
|
1
|
+
import test from 'ava';
|
2
|
+
import { isOptionsProp, isFunctionProp, isBooleanProp, isStringProp, } from '@knapsack/types';
|
3
|
+
import { validateSpec } from '@knapsack/app/renderers';
|
4
|
+
import { inferSpec } from './infer-spec.mjs';
|
5
|
+
test('infer types in packages with different files name for types', async (t) => {
|
6
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
7
|
+
path: '@knapsack/sandbox-components/react',
|
8
|
+
namedExport: 'Button',
|
9
|
+
resolveFrom: import.meta.dirname,
|
10
|
+
});
|
11
|
+
if (!spec) {
|
12
|
+
t.fail(`Spec could not be inferred`);
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
t.truthy(spec);
|
16
|
+
t.deepEqual(Object.keys(spec.props.properties).sort(), ['label', 'mode', 'size', 'type'].sort());
|
17
|
+
if (isOptionsProp(spec.props.properties.size)) {
|
18
|
+
t.deepEqual(spec.props.properties.size.enum, ['small', 'medium', 'large']);
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
t.fail(`size prop should be an options prop`);
|
22
|
+
}
|
23
|
+
if (isOptionsProp(spec.props.properties.type)) {
|
24
|
+
t.deepEqual(spec.props.properties.type.enum, ['filled', 'outlined']);
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
t.fail(`type prop should be an options prop`);
|
28
|
+
}
|
29
|
+
if (isOptionsProp(spec.props.properties.mode)) {
|
30
|
+
t.deepEqual(spec.props.properties.mode.enum, [
|
31
|
+
'default',
|
32
|
+
'success',
|
33
|
+
'error',
|
34
|
+
'warning',
|
35
|
+
]);
|
36
|
+
}
|
37
|
+
else {
|
38
|
+
t.fail(`mode prop should be an options prop`);
|
39
|
+
}
|
40
|
+
});
|
41
|
+
test('infer types in packages from tsx files', async (t) => {
|
42
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
43
|
+
path: '@knapsack/renderer-react-components/src/test-fixtures/button.tsx',
|
44
|
+
namedExport: 'Button',
|
45
|
+
resolveFrom: import.meta.dirname,
|
46
|
+
});
|
47
|
+
t.truthy(spec);
|
48
|
+
const { ok, message } = validateSpec(spec);
|
49
|
+
t.log(message);
|
50
|
+
t.is(ok, true, message);
|
51
|
+
});
|
52
|
+
test('inferDocs card.tsx with types', async (t) => {
|
53
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
54
|
+
path: '@knapsack/renderer-react-components/test-fixtures',
|
55
|
+
namedExport: 'Card',
|
56
|
+
resolveFrom: process.cwd(),
|
57
|
+
});
|
58
|
+
const expectedSpec = {
|
59
|
+
props: {
|
60
|
+
$schema: 'http://json-schema.org/draft-07/schema',
|
61
|
+
type: 'object',
|
62
|
+
required: ['cardBody', 'items'],
|
63
|
+
properties: {
|
64
|
+
textAlign: {
|
65
|
+
type: 'string',
|
66
|
+
enum: ['left', 'center', 'right'],
|
67
|
+
},
|
68
|
+
imgSrc: {
|
69
|
+
type: 'string',
|
70
|
+
},
|
71
|
+
isDark: {
|
72
|
+
type: 'boolean',
|
73
|
+
// @todo We lost proper default value when the source switched from `.tsx` to being from a package, which results in analyzing a `.d.ts` files... which doesn't have default values.
|
74
|
+
// default: true,
|
75
|
+
},
|
76
|
+
cardTitle: {
|
77
|
+
type: 'string',
|
78
|
+
},
|
79
|
+
cardSubTitle: {
|
80
|
+
type: 'string',
|
81
|
+
},
|
82
|
+
cardBody: {
|
83
|
+
type: 'string',
|
84
|
+
},
|
85
|
+
handleIt: {
|
86
|
+
typeof: 'function',
|
87
|
+
tsType: '(x: string) => boolean',
|
88
|
+
},
|
89
|
+
items: {
|
90
|
+
tsType: '{ id: string; title: string; description?: string;}[]',
|
91
|
+
},
|
92
|
+
},
|
93
|
+
},
|
94
|
+
slots: {
|
95
|
+
children: {
|
96
|
+
description: 'Goes in footer',
|
97
|
+
title: 'children',
|
98
|
+
},
|
99
|
+
header: {
|
100
|
+
title: 'header',
|
101
|
+
},
|
102
|
+
},
|
103
|
+
};
|
104
|
+
if (!spec) {
|
105
|
+
t.fail('Spec could not be inferred');
|
106
|
+
return;
|
107
|
+
}
|
108
|
+
const { ok, message } = validateSpec(spec);
|
109
|
+
t.log(message);
|
110
|
+
t.is(ok, true, message);
|
111
|
+
const { handleIt } = spec.props.properties;
|
112
|
+
t.truthy(handleIt);
|
113
|
+
if (isFunctionProp(handleIt)) {
|
114
|
+
t.is(handleIt.tsType, '(x: string) => boolean');
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
t.fail('handleIt should be a function prop');
|
118
|
+
}
|
119
|
+
t.like(spec, expectedSpec);
|
120
|
+
});
|
121
|
+
test('infer types for Knapsack Avatar', async (t) => {
|
122
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
123
|
+
path: '@knapsack/toby',
|
124
|
+
namedExport: 'Avatar',
|
125
|
+
resolveFrom: process.cwd(),
|
126
|
+
});
|
127
|
+
const { label } = spec.props.properties;
|
128
|
+
t.truthy(label);
|
129
|
+
if (isStringProp(label)) {
|
130
|
+
t.is(label.type, 'string', 'label should be a string');
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
t.fail('label should be a string');
|
134
|
+
}
|
135
|
+
const { ok, message } = validateSpec(spec);
|
136
|
+
t.log(message);
|
137
|
+
t.is(ok, true, message);
|
138
|
+
});
|
139
|
+
test('infer types for Knapsack SchemaForm', async (t) => {
|
140
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
141
|
+
path: '@knapsack/toby/schema-form',
|
142
|
+
namedExport: 'SchemaForm',
|
143
|
+
resolveFrom: process.cwd(),
|
144
|
+
});
|
145
|
+
const { submitLabel } = spec.props.properties;
|
146
|
+
t.truthy(submitLabel);
|
147
|
+
if (isStringProp(submitLabel)) {
|
148
|
+
t.is(submitLabel.type, 'string', 'submitLabel should be a string');
|
149
|
+
}
|
150
|
+
else {
|
151
|
+
t.fail('submitLabel should be a string');
|
152
|
+
}
|
153
|
+
const { ok, message } = validateSpec(spec);
|
154
|
+
t.log(message);
|
155
|
+
t.is(ok, true, message);
|
156
|
+
});
|
157
|
+
test('infer types for Modal', async (t) => {
|
158
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
159
|
+
path: '@knapsack/toby',
|
160
|
+
namedExport: 'Modal',
|
161
|
+
resolveFrom: process.cwd(),
|
162
|
+
});
|
163
|
+
const { instantOpen } = spec.props.properties;
|
164
|
+
t.truthy(instantOpen);
|
165
|
+
if (isBooleanProp(instantOpen)) {
|
166
|
+
t.is(instantOpen.type, 'boolean', 'instantOpen should be a boolean');
|
167
|
+
}
|
168
|
+
else {
|
169
|
+
t.fail('instantOpen should be a boolean');
|
170
|
+
}
|
171
|
+
const { ok, message } = validateSpec(spec);
|
172
|
+
t.is(ok, true, message);
|
173
|
+
t.truthy(spec);
|
174
|
+
});
|
175
|
+
test('infer types for Collapse', async (t) => {
|
176
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
177
|
+
path: '@knapsack/toby',
|
178
|
+
namedExport: 'Collapse',
|
179
|
+
resolveFrom: process.cwd(),
|
180
|
+
});
|
181
|
+
const { depth } = spec.props.properties;
|
182
|
+
t.truthy(depth);
|
183
|
+
if (isOptionsProp(depth)) {
|
184
|
+
t.deepEqual(depth.enum, [1, 2, 3, 4]);
|
185
|
+
}
|
186
|
+
else {
|
187
|
+
t.fail('depth should be an options prop');
|
188
|
+
}
|
189
|
+
const { ok, message } = validateSpec(spec);
|
190
|
+
t.is(ok, true, message);
|
191
|
+
t.truthy(spec);
|
192
|
+
});
|
193
|
+
test('infer types for Panel', async (t) => {
|
194
|
+
const { ksTemplateSpec: spec } = await inferSpec({
|
195
|
+
path: '@knapsack/toby',
|
196
|
+
namedExport: 'Panel',
|
197
|
+
resolveFrom: process.cwd(),
|
198
|
+
});
|
199
|
+
const { size } = spec.props.properties;
|
200
|
+
if (isOptionsProp(size)) {
|
201
|
+
t.deepEqual(size.enum, ['default', 'narrow', 'wide']);
|
202
|
+
}
|
203
|
+
else {
|
204
|
+
t.fail('size should be an options prop');
|
205
|
+
}
|
206
|
+
const { ok, message } = validateSpec(spec);
|
207
|
+
t.is(ok, true, message);
|
208
|
+
t.truthy(spec);
|
209
|
+
});
|
210
|
+
//# sourceMappingURL=infer-spec.test.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"infer-spec.test.mjs","sourceRoot":"","sources":["../../src/analyze/infer-spec.test.mts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EACL,aAAa,EACb,cAAc,EAEd,aAAa,EACb,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,IAAI,CAAC,6DAA6D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9E,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,MAAM,SAAS,CAAC;QAC/C,IAAI,EAAE,oCAAoC;QAC1C,WAAW,EAAE,QAAQ;QACrB,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO;KACjC,CAAC,CAAC;IACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACrC,OAAO;IACT,CAAC;IAED,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACf,CAAC,CAAC,SAAS,CACT,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,EACzC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CACzC,CAAC;IACF,IAAI,aAAa,CAAC,IAAI,C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