@knapsack/renderer-react 5.0.0--canary.6593.d6350c3.0 β†’ 5.0.0--canary.7791.86072ba.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 (41) hide show
  1. package/.lintstagedrc.mjs +2 -2
  2. package/CHANGELOG.md +172 -0
  3. package/dist/analyze/filter-props.d.mts +24 -0
  4. package/dist/analyze/filter-props.d.mts.map +1 -0
  5. package/dist/analyze/filter-props.mjs +54 -0
  6. package/dist/analyze/filter-props.mjs.map +1 -0
  7. package/dist/analyze/infer-spec.bench.d.mts +2 -0
  8. package/dist/analyze/infer-spec.bench.d.mts.map +1 -0
  9. package/dist/analyze/infer-spec.bench.mjs +50 -0
  10. package/dist/analyze/infer-spec.bench.mjs.map +1 -0
  11. package/dist/analyze/infer-spec.d.mts +11 -1
  12. package/dist/analyze/infer-spec.d.mts.map +1 -1
  13. package/dist/analyze/infer-spec.mjs +81 -39
  14. package/dist/analyze/infer-spec.mjs.map +1 -1
  15. package/dist/analyze/utils/extract-default-props.d.mts +25 -0
  16. package/dist/analyze/utils/extract-default-props.d.mts.map +1 -0
  17. package/dist/analyze/utils/extract-default-props.mjs +202 -0
  18. package/dist/analyze/utils/extract-default-props.mjs.map +1 -0
  19. package/dist/analyze/utils/react-component-analyzer.d.mts +22 -2
  20. package/dist/analyze/utils/react-component-analyzer.d.mts.map +1 -1
  21. package/dist/analyze/utils/react-component-analyzer.mjs +81 -30
  22. package/dist/analyze/utils/react-component-analyzer.mjs.map +1 -1
  23. package/dist/client/init.d.mts +7 -1
  24. package/dist/client/init.d.mts.map +1 -1
  25. package/dist/client/init.mjs +34 -31
  26. package/dist/client/init.mjs.map +1 -1
  27. package/dist/react-creators.js +3 -3
  28. package/dist/react-creators.js.map +1 -1
  29. package/dist/renderer-react.d.ts +1 -2
  30. package/dist/renderer-react.d.ts.map +1 -1
  31. package/dist/renderer-react.js +468 -487
  32. package/dist/renderer-react.js.map +1 -1
  33. package/dist/utils.d.ts +1 -2
  34. package/dist/utils.d.ts.map +1 -1
  35. package/dist/utils.js +27 -61
  36. package/dist/utils.js.map +1 -1
  37. package/package.json +28 -26
  38. package/test-fixtures/default-props.tsx +60 -0
  39. package/test-fixtures/pkg-diff-types/types/button.d.ts +1 -0
  40. package/vitest.config.mts +1 -0
  41. package/.eslintrc.cjs +0 -7
package/.lintstagedrc.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { dirname } from 'path';
2
- import { fileURLToPath } from 'url';
1
+ import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
3
 
4
4
  import defaultConfig from '../../../../.lintstagedrc.mjs';
5
5
 
package/CHANGELOG.md CHANGED
@@ -1,3 +1,175 @@
1
+ # v4.89.8 (Fri Feb 20 2026)
2
+
3
+ ### Release Notes
4
+
5
+ #### KSP-7685: Synthetic Data for Conflict Enrichment/Resolution testing ([#7154](https://github.com/knapsack-labs/app-monorepo/pull/7154))
6
+
7
+ * **Documentation**
8
+ * Added synthetic multi-source test fixtures including component documentation, design tokens, and brand guidelines for comprehensive testing coverage.
9
+
10
+ <!-- end of auto-generated comment: release notes by coderabbit.ai -->
11
+
12
+ ---
13
+
14
+ #### πŸ› Bug Fix
15
+
16
+ - Merged latest in ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
17
+ - Extended timeout for tests ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
18
+ - Fixed indentation erros ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
19
+ - merge latest in ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
20
+ - Merge branch 'latest' into sxa/KSP-7037-tests-v2 ([@sxalexander](https://github.com/sxalexander))
21
+ - Use node: protocol prefix in all .lintstagedrc.mjs files ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
22
+ - Migrated ESLint config to flat config format (ESLint 9) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
23
+
24
+ #### 🏠 Internal
25
+
26
+ - KSP-5516 Upgraded prettier to v3.8.1 and fix async API usage [#7191](https://github.com/knapsack-labs/app-monorepo/pull/7191) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
27
+ - KSP-7685: Synthetic Data for Conflict Enrichment/Resolution testing [#7154](https://github.com/knapsack-labs/app-monorepo/pull/7154) ([@sxalexander](https://github.com/sxalexander))
28
+ - KSP-5524 Migrated ESLint config to flat config format (ESLint 9) [#7162](https://github.com/knapsack-labs/app-monorepo/pull/7162) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
29
+
30
+ #### Authors: 2
31
+
32
+ - [@EmmanuelVelez](https://github.com/EmmanuelVelez)
33
+ - Sam Alexander ([@sxalexander](https://github.com/sxalexander))
34
+
35
+ ---
36
+
37
+ # v4.89.7 (Fri Feb 06 2026)
38
+
39
+ #### πŸ› Bug Fix
40
+
41
+ - Merge branch 'latest' into feature/ksp-6555-remove-app-client-watchers-for-files-in-data-directory ([@EvanLovely](https://github.com/EvanLovely))
42
+ - Merge branch 'latest' into feature/ksp-6555-remove-app-client-watchers-for-files-in-data-directory ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
43
+
44
+ #### 🏠 Internal
45
+
46
+ - KSP-6106 Added consistent-type-imports rule with inline type syntax [#7128](https://github.com/knapsack-labs/app-monorepo/pull/7128) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
47
+ - KSP-7692: expand server actions body size limit [#7097](https://github.com/knapsack-labs/app-monorepo/pull/7097) ([@illepic](https://github.com/illepic))
48
+ - KSP-7623 resolved some of react-hooks/set-state-in-effect lint errors and enab… [#7077](https://github.com/knapsack-labs/app-monorepo/pull/7077) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
49
+
50
+ #### Authors: 3
51
+
52
+ - [@EmmanuelVelez](https://github.com/EmmanuelVelez)
53
+ - Christopher Bloom ([@illepic](https://github.com/illepic))
54
+ - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
55
+
56
+ ---
57
+
58
+ # v4.89.4 (Mon Jan 05 2026)
59
+
60
+ #### πŸ› Bug Fix
61
+
62
+ - fix React Error 525 by moving React to peerDependencies [#7063](https://github.com/knapsack-labs/app-monorepo/pull/7063) ([@brittanysmart](https://github.com/brittanysmart))
63
+
64
+ #### 🏠 Internal
65
+
66
+ - KSP-6086 normalize error and log metadata for api domains [#6997](https://github.com/knapsack-labs/app-monorepo/pull/6997) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
67
+
68
+ #### Authors: 2
69
+
70
+ - [@EmmanuelVelez](https://github.com/EmmanuelVelez)
71
+ - Brittany Smart ([@brittanysmart](https://github.com/brittanysmart))
72
+
73
+ ---
74
+
75
+ # v4.89.3 (Thu Dec 11 2025)
76
+
77
+ #### πŸ› Bug Fix
78
+
79
+ - KSP-6536 Fixed align token metrics counting with UI logic for variables and collections [#6778](https://github.com/knapsack-labs/app-monorepo/pull/6778) ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
80
+ - Merge branch 'latest' into feature/ksp-6536-metrics-not-computing-tokens-and-variables-correctly ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
81
+ - Merge remote-tracking branch 'origin/feature/ksp-6536-metrics-not-computing-tokens-and-variables-correctly' into feature/ksp-6536-metrics-not-computing-tokens-and-variables-correctly ([@EmmanuelVelez](https://github.com/EmmanuelVelez))
82
+
83
+ #### Authors: 1
84
+
85
+ - [@EmmanuelVelez](https://github.com/EmmanuelVelez)
86
+
87
+ ---
88
+
89
+ # v4.89.1 (Wed Dec 10 2025)
90
+
91
+ #### πŸ› Bug Fix
92
+
93
+ - Merge remote-tracking branch 'origin/latest' into KSP-6900_mcp_onboarding_pages ([@brittanysmart](https://github.com/brittanysmart))
94
+
95
+ #### Authors: 1
96
+
97
+ - Brittany Smart ([@brittanysmart](https://github.com/brittanysmart))
98
+
99
+ ---
100
+
101
+ # v4.88.0 (Mon Nov 24 2025)
102
+
103
+ #### πŸš€ Enhancement
104
+
105
+ - upgrade to react 19 [#6897](https://github.com/knapsack-labs/app-monorepo/pull/6897) ([@brittanysmart](https://github.com/brittanysmart) [@EvanLovely](https://github.com/EvanLovely))
106
+
107
+ #### Authors: 2
108
+
109
+ - Brittany Smart ([@brittanysmart](https://github.com/brittanysmart))
110
+ - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
111
+
112
+ ---
113
+
114
+ # v4.87.9 (Thu Nov 20 2025)
115
+
116
+ #### 🏠 Internal
117
+
118
+ - fix(deps): update dependency @types/node to ^20.19.25 [#6803](https://github.com/knapsack-labs/app-monorepo/pull/6803) ([@renovate[bot]](https://github.com/renovate[bot]))
119
+ - fix(deps): update dependency zod to ^4.1.12 [#6861](https://github.com/knapsack-labs/app-monorepo/pull/6861) ([@renovate[bot]](https://github.com/renovate[bot]))
120
+
121
+ #### Authors: 1
122
+
123
+ - [@renovate[bot]](https://github.com/renovate[bot])
124
+
125
+ ---
126
+
127
+ # v4.87.7 (Mon Nov 10 2025)
128
+
129
+ #### 🏠 Internal
130
+
131
+ - fix(deps): update typescript [#6863](https://github.com/knapsack-labs/app-monorepo/pull/6863) ([@renovate[bot]](https://github.com/renovate[bot]))
132
+
133
+ #### Authors: 1
134
+
135
+ - [@renovate[bot]](https://github.com/renovate[bot])
136
+
137
+ ---
138
+
139
+ # v4.87.6 (Wed Nov 05 2025)
140
+
141
+ #### πŸ› Bug Fix
142
+
143
+ - Add logging to infer spec ksp-7310 [#6882](https://github.com/knapsack-labs/app-monorepo/pull/6882) ([@rizchelwood](https://github.com/rizchelwood))
144
+ - adds skip to long running tests ([@mabry1985](https://github.com/mabry1985))
145
+ - Refactor MUI spec validation function to improve type handling and error messaging ([@mabry1985](https://github.com/mabry1985))
146
+ - Refactor property access in MUI spec validation to handle undefined properties gracefully ([@mabry1985](https://github.com/mabry1985))
147
+ - Refactor default value checks in MUI validation to ensure strict undefined checks ([@mabry1985](https://github.com/mabry1985))
148
+ - Add comprehensive testing for remaining frameworks and MUI lib ([@mabry1985](https://github.com/mabry1985))
149
+
150
+ #### 🏠 Internal
151
+
152
+ - Add comprehensive testing for remaining frameworks and MUI lib [#6876](https://github.com/knapsack-labs/app-monorepo/pull/6876) ([@mabry1985](https://github.com/mabry1985))
153
+
154
+ #### Authors: 2
155
+
156
+ - Josh Mabry ([@mabry1985](https://github.com/mabry1985))
157
+ - Rizchel Wood ([@rizchelwood](https://github.com/rizchelwood))
158
+
159
+ ---
160
+
161
+ # v4.87.4 (Fri Oct 31 2025)
162
+
163
+ #### 🏠 Internal
164
+
165
+ - adds wider testing to angular renderer [#6871](https://github.com/knapsack-labs/app-monorepo/pull/6871) ([@mabry1985](https://github.com/mabry1985))
166
+
167
+ #### Authors: 1
168
+
169
+ - Josh Mabry ([@mabry1985](https://github.com/mabry1985))
170
+
171
+ ---
172
+
1
173
  # v4.87.3 (Thu Oct 30 2025)
2
174
 
3
175
  #### πŸ› Bug Fix
@@ -0,0 +1,24 @@
1
+ import type { KnapsackInferSpecFilters } from '@knapsack/types';
2
+ import type { ComponentProps } from './utils/react-component-analyzer.mjs';
3
+ export declare function isAriaProp(name: string): boolean;
4
+ export declare function isEventHandlerProp(name: string): boolean;
5
+ export declare function shouldFilterProp({ name, declaredIn, filters, }: {
6
+ name: string;
7
+ declaredIn: ComponentProps[string]['declaredIn'];
8
+ filters: KnapsackInferSpecFilters | undefined;
9
+ }): boolean;
10
+ /**
11
+ * Apply workspace `inferSpec` filters to a component's inferred props, then
12
+ * re-add any names listed in `extras` (the per-template override).
13
+ *
14
+ * Names in `extras` that don't exist on the inferred component are silently
15
+ * absent from the output β€” the template-form is responsible for warning the
16
+ * author about typos. Slots are not filtered (they're a different surface
17
+ * than the prop deluge this targets).
18
+ */
19
+ export declare function filterInferredProps({ componentProps, filters, extras, }: {
20
+ componentProps: ComponentProps;
21
+ filters?: KnapsackInferSpecFilters;
22
+ extras?: readonly string[];
23
+ }): ComponentProps;
24
+ //# sourceMappingURL=filter-props.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-props.d.mts","sourceRoot":"","sources":["../../src/analyze/filter-props.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAE3E,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,UAAU,EACV,OAAO,GACR,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IACjD,OAAO,EAAE,wBAAwB,GAAG,SAAS,CAAC;CAC/C,GAAG,OAAO,CAeV;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,cAAc,EACd,OAAO,EACP,MAAM,GACP,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,GAAG,cAAc,CAejB"}
@@ -0,0 +1,54 @@
1
+ export function isAriaProp(name) {
2
+ return name.startsWith('aria-');
3
+ }
4
+ export function isEventHandlerProp(name) {
5
+ return /^on[A-Z]/.test(name);
6
+ }
7
+ export function shouldFilterProp({ name, declaredIn, filters, }) {
8
+ if (!filters)
9
+ return false;
10
+ if (filters.removeClassName && name === 'className')
11
+ return true;
12
+ if (filters.removeStyle && name === 'style')
13
+ return true;
14
+ if (filters.removeAria && isAriaProp(name))
15
+ return true;
16
+ if (filters.removeEventHandlers && isEventHandlerProp(name))
17
+ return true;
18
+ // Inheritance-based: only true when every declaration sits inside a React
19
+ // DOM interface (`HTMLAttributes`, `ButtonHTMLAttributes`, `AriaAttributes`,
20
+ // `DOMAttributes`, `SVGAttributes`, etc.). A prop the author redeclared on
21
+ // their own interface keeps `isReactDomInterface: false` and survives β€”
22
+ // even if its name (`size`, `color`, `disabled`) collides with a DOM attr.
23
+ if (filters.removeHtmlAttributes && declaredIn?.isReactDomInterface) {
24
+ return true;
25
+ }
26
+ return false;
27
+ }
28
+ /**
29
+ * Apply workspace `inferSpec` filters to a component's inferred props, then
30
+ * re-add any names listed in `extras` (the per-template override).
31
+ *
32
+ * Names in `extras` that don't exist on the inferred component are silently
33
+ * absent from the output β€” the template-form is responsible for warning the
34
+ * author about typos. Slots are not filtered (they're a different surface
35
+ * than the prop deluge this targets).
36
+ */
37
+ export function filterInferredProps({ componentProps, filters, extras, }) {
38
+ if (!filters)
39
+ return componentProps;
40
+ const extrasSet = new Set(extras ?? []);
41
+ const filtered = {};
42
+ for (const [name, prop] of Object.entries(componentProps)) {
43
+ const drop = shouldFilterProp({
44
+ name,
45
+ declaredIn: prop.declaredIn,
46
+ filters,
47
+ });
48
+ if (!drop || extrasSet.has(name)) {
49
+ filtered[name] = prop;
50
+ }
51
+ }
52
+ return filtered;
53
+ }
54
+ //# sourceMappingURL=filter-props.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-props.mjs","sourceRoot":"","sources":["../../src/analyze/filter-props.mts"],"names":[],"mappings":"AAGA,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAC/B,IAAI,EACJ,UAAU,EACV,OAAO,GAKR;IACC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACjE,IAAI,OAAO,CAAC,WAAW,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACxD,IAAI,OAAO,CAAC,mBAAmB,IAAI,kBAAkB,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACzE,0EAA0E;IAC1E,6EAA6E;IAC7E,2EAA2E;IAC3E,wEAAwE;IACxE,2EAA2E;IAC3E,IAAI,OAAO,CAAC,oBAAoB,IAAI,UAAU,EAAE,mBAAmB,EAAE,CAAC;QACpE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,cAAc,EACd,OAAO,EACP,MAAM,GAKP;IACC,IAAI,CAAC,OAAO;QAAE,OAAO,cAAc,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,gBAAgB,CAAC;YAC5B,IAAI;YACJ,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO;SACR,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACxB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=infer-spec.bench.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer-spec.bench.d.mts","sourceRoot":"","sources":["../../src/analyze/infer-spec.bench.mts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { bench, describe } from 'vitest';
2
+ import { join } from 'node:path';
3
+ import { inferSpec } from './infer-spec.mjs';
4
+ /**
5
+ * Measures the cost of source-level DEFAULT extraction on `inferSpec`. Per Evan's
6
+ * suggestion, the same codebase is benched with `extractDefaults` on vs off β€” the delta
7
+ * is the added cost of recovering defaults. Run: `pnpm bench` (vitest bench --run).
8
+ *
9
+ * - "fixture .tsx" resolves to real SOURCE β†’ exercises the full createSourceFile + AST
10
+ * walk (the worst case for our added work).
11
+ * - "sandbox Button" resolves through package exports (often a `.d.ts`) β†’ the realistic
12
+ * path, where extraction early-returns `{}` after a cheap resolve + extension check.
13
+ */
14
+ const resolveFrom = import.meta.dirname;
15
+ const fixture = join(import.meta.dirname, '../../test-fixtures/default-props.tsx');
16
+ // ~170ms/op, so give each bench a long window for many samples β†’ tighter rme.
17
+ const benchOpts = { time: 15_000, warmupTime: 2_000 };
18
+ const cases = [
19
+ {
20
+ label: 'inferSpec β€” fixture .tsx (source-resolved)',
21
+ path: fixture,
22
+ namedExport: 'ParamDefaults',
23
+ },
24
+ {
25
+ label: 'inferSpec β€” sandbox Button (package-resolved)',
26
+ path: '@knapsack/sandbox-components/react',
27
+ namedExport: 'Button',
28
+ },
29
+ ];
30
+ for (const { label, path, namedExport } of cases) {
31
+ describe(label, () => {
32
+ bench('extractDefaults: true (after PR)', async () => {
33
+ await inferSpec({
34
+ path,
35
+ namedExport,
36
+ resolveFrom,
37
+ extractDefaults: true,
38
+ });
39
+ }, benchOpts);
40
+ bench('extractDefaults: false (before PR)', async () => {
41
+ await inferSpec({
42
+ path,
43
+ namedExport,
44
+ resolveFrom,
45
+ extractDefaults: false,
46
+ });
47
+ }, benchOpts);
48
+ });
49
+ }
50
+ //# sourceMappingURL=infer-spec.bench.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer-spec.bench.mjs","sourceRoot":"","sources":["../../src/analyze/infer-spec.bench.mts"],"names":[],"mappings":"AAAA,OAAO,E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
1
+ import { type KnapsackInferSpecFilters } from '@knapsack/types';
2
+ export declare function inferSpec({ path, namedExport, resolveFrom, pkgPathAliases, inferSpecFilters, inferSpecExtras, extractDefaults, }: {
2
3
  path: string;
3
4
  namedExport?: string;
4
5
  resolveFrom?: string;
5
6
  pkgPathAliases?: Record<string, string>;
7
+ /** Workspace filters from `db.settings.renderers.react.inferSpec`. */
8
+ inferSpecFilters?: KnapsackInferSpecFilters;
9
+ /** Per-template overrides from `KsTemplateSpec.inferSpecExtras`. */
10
+ inferSpecExtras?: readonly string[];
11
+ /**
12
+ * Recover source-level default prop values (an extra syntactic source read). On by
13
+ * default; set false to skip it (perf-sensitive contexts / benchmarking).
14
+ */
15
+ extractDefaults?: boolean;
6
16
  }): Promise<{
7
17
  ksTemplateSpec: {
8
18
  isInferred: true;
@@ -1 +1 @@
1
- {"version":3,"file":"infer-spec.d.mts","sourceRoot":"","sources":["../../src/analyze/infer-spec.mts"],"names":[],"mappings":"AAOA,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;;;;;;;;;;;;;;;;;;;;GA8IA"}
1
+ {"version":3,"file":"infer-spec.d.mts","sourceRoot":"","sources":["../../src/analyze/infer-spec.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAI9B,MAAM,iBAAiB,CAAC;AASzB,wBAAsB,SAAS,CAAC,EAC9B,IAAI,EACJ,WAAW,EACX,WAA2B,EAC3B,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,eAAsB,GACvB,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;IACxC,sEAAsE;IACtE,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C,oEAAoE;IACpE,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;;;;;;;;;;;;;;;;;;;;GA+MA"}
@@ -1,11 +1,19 @@
1
+ import { log } from '@knapsack/app';
1
2
  import { convertToSpec } from '@knapsack/spec-utils';
2
3
  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, isPropTypes = false, } = await analyzeComponent({
4
+ import { filterInferredProps } from './filter-props.mjs';
5
+ export async function inferSpec({ path, namedExport, resolveFrom = process.cwd(), pkgPathAliases, inferSpecFilters, inferSpecExtras, extractDefaults = true, }) {
6
+ const { props: rawComponentProps, slots: componentSlots, isPropTypes = false, } = await analyzeComponent({
5
7
  fileName: path,
6
8
  exportName: namedExport,
7
9
  pkgPathAliases,
8
10
  resolveFromDir: resolveFrom,
11
+ extractDefaults,
12
+ });
13
+ const componentProps = filterInferredProps({
14
+ componentProps: rawComponentProps,
15
+ filters: inferSpecFilters,
16
+ extras: inferSpecExtras,
9
17
  });
10
18
  const props = {
11
19
  $schema: 'http://json-schema.org/draft-07/schema',
@@ -44,47 +52,81 @@ export async function inferSpec({ path, namedExport, resolveFrom = process.cwd()
44
52
  const propsTableRows = [];
45
53
  Object.entries(componentProps).forEach(([propName, propDetails]) => {
46
54
  const { required, typeInfo: propTypeInfo } = propDetails;
47
- if (propTypeInfo) {
48
- // Extract display type before processing (since we may destructure these fields)
49
- const displayType = propTypeInfo.tsRawType ||
50
- propTypeInfo.type ||
51
- (isPropTypes && propTypeInfo.tsType) ||
52
- 'unknown';
53
- // Both TypeScript and PropTypes now produce the same flat structure in typeInfo
54
- let prop = null;
55
- if (isPropTypes) {
56
- // PropTypes analysis produces flat structure in typeInfo
57
- // Remove tsRawType and tsType before assigning as PropertyTypes
58
- const propTypeInfoTyped = propTypeInfo;
59
- const { tsRawType: _tsRawType, tsType: _tsType, ...propData } = propTypeInfoTyped;
60
- prop = propData;
55
+ if (!propTypeInfo) {
56
+ log.verbose(`Property missing typeInfo: ${propName}`, { propName }, 'react-renderer');
57
+ return;
58
+ }
59
+ // Extract display type before processing (since we may destructure these fields)
60
+ const displayType = propTypeInfo.tsRawType ||
61
+ propTypeInfo.type ||
62
+ (isPropTypes && propTypeInfo.tsType) ||
63
+ 'unknown';
64
+ if (displayType === 'unknown') {
65
+ log.verbose(`Property type could not be determined: ${propName}`, {
66
+ propName,
67
+ propTypeInfo: {
68
+ type: propTypeInfo.type,
69
+ hasTsRawType: !!propTypeInfo.tsRawType,
70
+ },
71
+ }, 'react-renderer');
72
+ }
73
+ // Both TypeScript and PropTypes now produce the same flat structure in typeInfo
74
+ let prop = null;
75
+ if (isPropTypes) {
76
+ // PropTypes analysis produces flat structure in typeInfo
77
+ // Remove tsRawType and tsType before assigning as PropertyTypes
78
+ const propTypeInfoTyped = propTypeInfo;
79
+ const { tsRawType: _tsRawType, tsType: _tsType, ...propData } = propTypeInfoTyped;
80
+ prop = propData;
81
+ }
82
+ else {
83
+ const { prop: convertedProp } = convertToSpec({
84
+ typeInfo: propTypeInfo,
85
+ trustRequiredProps: false,
86
+ });
87
+ prop = convertedProp;
88
+ }
89
+ // Assign prop with all metadata
90
+ if (prop) {
91
+ props.properties[propName] = prop;
92
+ // Add description if present
93
+ if (propDetails.description) {
94
+ props.properties[propName].description = propDetails.description;
61
95
  }
62
- else {
63
- const { prop: convertedProp } = convertToSpec({
64
- typeInfo: propTypeInfo,
65
- trustRequiredProps: false,
66
- });
67
- prop = convertedProp;
96
+ // Add the source-level default value (destructuring / defaultProps) if recovered
97
+ // and not already provided by the conversion. Lets the props form pre-fill.
98
+ if (propDetails.defaultValue !== undefined &&
99
+ props.properties[propName].default ===
100
+ undefined) {
101
+ props.properties[propName].default =
102
+ propDetails.defaultValue;
68
103
  }
69
- // Assign prop with all metadata
70
- if (prop) {
71
- props.properties[propName] = prop;
72
- // Add description if present
73
- if (propDetails.description) {
74
- props.properties[propName].description = propDetails.description;
75
- }
76
- // Add to required array if needed
77
- if (required && props.required) {
78
- props.required.push(propName);
79
- }
104
+ // Add to required array if needed
105
+ if (required && props.required) {
106
+ props.required.push(propName);
80
107
  }
81
- propsTableRows.push({
82
- 'Prop Name': `\`${propName}\``,
83
- Type: `\`${displayType}\``,
84
- Required: required ? 'Yes' : 'No',
85
- Description: propDetails.description || '',
86
- });
108
+ log.verbose(`Property successfully converted for prop: ${propName}`, {
109
+ propName,
110
+ displayType,
111
+ propType: prop.type || prop.typeof || 'unknown',
112
+ }, 'react-renderer');
87
113
  }
114
+ else {
115
+ log.verbose(`Property could not be converted to spec: ${propName}`, {
116
+ propName,
117
+ displayType,
118
+ propTypeInfo: {
119
+ type: propTypeInfo.type,
120
+ tsRawType: propTypeInfo.tsRawType,
121
+ },
122
+ }, 'react-renderer');
123
+ }
124
+ propsTableRows.push({
125
+ 'Prop Name': `\`${propName}\``,
126
+ Type: `\`${displayType}\``,
127
+ Required: required ? 'Yes' : 'No',
128
+ Description: propDetails.description || '',
129
+ });
88
130
  });
89
131
  if (propsTableRows.length) {
90
132
  extraDocs.push({
@@ -1 +1 @@
1
- {"version":3,"file":"infer-spec.mjs","sourceRoot":"","sources":["../../src/analyze/infer-spec.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAiB,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,gBAAgB,GAEjB,MAAM,sCAAsC,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC9B,IAAI,EACJ,WAAW,EACX,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAC3B,cAAc,GAM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ACjB,CAAC;QACJ,CAAC;QAED,cAAc,CAAC,IAAI,CAAC;YAClB,WAAW,EAAE,KAAK,QAAQ,IAAI;YAC9B,IAAI,EAAE,KAAK,WAAW,IAAI;YAC1B,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACjC,WAAW,EAAE,WAAW,CAAC,WAAW,IAAI,EAAE;SAC3C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,IAAI,cAAc,CAAC,MAAM,EAAE,CAAC;QAC1B,SAAS,CAAC,IAAI,CAAC;YACb,EAAE,EAAE,OAAO;YACX,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,cAAc;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QACpC,SAAS,CAAC,IAAI,CAAC;YACb,EAAE,EAAE,OAAO;YACX,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;gBAChE,WAAW,EAAE,KAAK,QAAQ,IAAI;gBAC9B,YAAY,EAAE,IAAI,CAAC,KAAK;aACzB,CAAC,CAAC;SACJ,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,cAAc,EAAE;YACd,UAAU,EAAE,IAAI;YAChB,cAAc,EAAE,IAAI;YACpB,cAAc,EAAE,IAAI;YACpB,SAAS;YACT,KAAK;YACL,KAAK;SACmB;QAC1B,KAAK,EAAE,cAAc;QACrB,KAAK,EAAE,cAAc;KACtB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ /** Literal default values we can carry into the spec's `default`. */
2
+ export type DefaultValue = string | number | boolean | null;
3
+ /**
4
+ * Source-level default prop values for a React component. TypeScript TYPES don't carry
5
+ * defaults β€” they live in the implementation (destructuring defaults or `defaultProps`),
6
+ * which `analyzeExport` (type-based) and `react-docgen`'s default handler (param-only)
7
+ * miss. This does a lightweight, SYNTACTIC AST walk (no type-check, no program) of the
8
+ * source file to recover them for the three real-world shapes:
9
+ *
10
+ * 1. param destructuring `(props: P) => ({ size = 'md' }) ...` ← also `function`
11
+ * 2. body destructuring `(props: P) => { const { size = 'md' } = props; ... }`
12
+ * 3. static defaultProps `Comp.defaultProps = { size: 'md' }`
13
+ *
14
+ * Only string / number / boolean / null literal defaults are returned (a default of a
15
+ * function, identifier, or object isn't a meaningful form value, so it's skipped).
16
+ * Best-effort: any failure yields `{}` rather than throwing β€” defaults are an
17
+ * enhancement, never a reason to fail inference.
18
+ */
19
+ export declare function extractDefaultProps({ fileName, exportName, resolveFromDir, pkgPathAliases, }: {
20
+ fileName: string;
21
+ exportName?: string;
22
+ resolveFromDir: string;
23
+ pkgPathAliases?: Record<string, string>;
24
+ }): Promise<Record<string, DefaultValue>>;
25
+ //# sourceMappingURL=extract-default-props.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-default-props.d.mts","sourceRoot":"","sources":["../../../src/analyze/utils/extract-default-props.mts"],"names":[],"mappings":"AAKA,qEAAqE;AACrE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAsL5D;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,QAAQ,EACR,UAAsB,EACtB,cAAc,EACd,cAAmB,GACpB,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAiCxC"}