@knapsack/renderer-react 4.71.16--canary.5239.d839174.0 → 4.71.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/ava.config.cjs +7 -1
  3. package/dist/analyze/infer-spec.test.d.ts +2 -0
  4. package/dist/analyze/infer-spec.test.d.ts.map +1 -0
  5. package/dist/analyze/infer-spec.test.js +112 -0
  6. package/dist/analyze/infer-spec.test.js.map +1 -0
  7. package/dist/analyze/mui.test.d.ts +2 -0
  8. package/dist/analyze/mui.test.d.ts.map +1 -0
  9. package/dist/analyze/mui.test.js +60 -0
  10. package/dist/analyze/mui.test.js.map +1 -0
  11. package/dist/analyze/pkg-basic.test.d.ts +2 -0
  12. package/dist/analyze/pkg-basic.test.d.ts.map +1 -0
  13. package/dist/analyze/pkg-basic.test.js +33 -0
  14. package/dist/analyze/pkg-basic.test.js.map +1 -0
  15. package/dist/analyze/pkg-diff-types.test.d.ts +2 -0
  16. package/dist/analyze/pkg-diff-types.test.d.ts.map +1 -0
  17. package/dist/analyze/pkg-diff-types.test.js +43 -0
  18. package/dist/analyze/pkg-diff-types.test.js.map +1 -0
  19. package/dist/client/init.d.mts +2 -2
  20. package/dist/client/init.d.mts.map +1 -0
  21. package/dist/client/init.mjs +39 -3
  22. package/dist/client/init.mjs.map +1 -1
  23. package/dist/index.d.ts +3 -45
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +16 -31
  26. package/dist/index.js.map +1 -1
  27. package/dist/react-creators.d.ts +20 -0
  28. package/dist/react-creators.d.ts.map +1 -0
  29. package/dist/react-creators.js +170 -0
  30. package/dist/react-creators.js.map +1 -0
  31. package/dist/{index.d.mts → renderer-react.d.ts} +2 -5
  32. package/dist/renderer-react.d.ts.map +1 -0
  33. package/dist/renderer-react.js +569 -0
  34. package/dist/renderer-react.js.map +1 -0
  35. package/dist/types.d.ts +19 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +5 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/utils.d.ts +28 -0
  40. package/dist/utils.d.ts.map +1 -0
  41. package/dist/utils.js +500 -0
  42. package/dist/utils.js.map +1 -0
  43. package/dist/utils.test.d.ts +2 -0
  44. package/dist/utils.test.d.ts.map +1 -0
  45. package/dist/utils.test.js +59 -0
  46. package/dist/utils.test.js.map +1 -0
  47. package/package.json +23 -27
  48. package/prototype-template.d.mts +3 -0
  49. package/prototype-template.mjs +3 -0
  50. package/test-fixtures/pkg-diff-types/button.js +10 -0
  51. package/test-fixtures/pkg-diff-types/package.json +4 -0
  52. package/test-fixtures/pkg-diff-types/readme.md +1 -0
  53. package/test-fixtures/pkg-diff-types/types/button.d.ts +5 -0
  54. package/tsconfig.json +2 -2
  55. package/dist/client/init.d.ts +0 -2
  56. package/dist/client/init.js +0 -5
  57. package/dist/client/init.js.map +0 -1
  58. package/dist/demo-wrapper.d.mts +0 -7
  59. package/dist/demo-wrapper.d.ts +0 -7
  60. package/dist/demo-wrapper.js +0 -2
  61. package/dist/demo-wrapper.js.map +0 -1
  62. package/dist/demo-wrapper.mjs +0 -2
  63. package/dist/demo-wrapper.mjs.map +0 -1
  64. package/dist/error-catcher.d.mts +0 -20
  65. package/dist/error-catcher.d.ts +0 -20
  66. package/dist/error-catcher.js +0 -2
  67. package/dist/error-catcher.js.map +0 -1
  68. package/dist/error-catcher.mjs +0 -2
  69. package/dist/error-catcher.mjs.map +0 -1
  70. package/dist/index.mjs +0 -33
  71. package/dist/index.mjs.map +0 -1
  72. package/dist/prototype-template.d.mts +0 -7
  73. package/dist/prototype-template.d.ts +0 -7
  74. package/dist/prototype-template.js +0 -2
  75. package/dist/prototype-template.js.map +0 -1
  76. package/dist/prototype-template.mjs +0 -2
  77. package/dist/prototype-template.mjs.map +0 -1
  78. package/dist/types-CivTHEEo.d.mts +0 -10
  79. package/dist/types-CivTHEEo.d.ts +0 -10
  80. package/tsup.config.cjs +0 -5
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
2
  "name": "@knapsack/renderer-react",
3
3
  "description": "Render React",
4
- "version": "4.71.16--canary.5239.d839174.0",
4
+ "version": "4.71.16",
5
5
  "type": "commonjs",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
6
  "exports": {
9
7
  ".": {
10
8
  "types": "./dist/index.d.ts",
@@ -17,31 +15,30 @@
17
15
  "./package": "./package.json",
18
16
  "./package.json": "./package.json",
19
17
  "./prototype-template": {
20
- "types": "./dist/prototype-template.d.ts",
21
- "import": "./dist/prototype-template.mjs",
22
- "require": "./dist/prototype-template.js",
23
- "default": "./dist/prototype-template.mjs"
18
+ "types": "./prototype-template.d.mts",
19
+ "default": "./prototype-template.mjs"
24
20
  }
25
21
  },
26
- "sideEffects": false,
22
+ "sideEffects": [
23
+ "./dist/client/init.mjs"
24
+ ],
27
25
  "scripts": {
28
- "build": "tsup src/index.ts src/error-catcher.tsx src/demo-wrapper.tsx src/prototype-template.tsx src/client/init.tsx",
26
+ "build": "tsc",
29
27
  "clean": "rm -rf dist",
30
- "lint": "eslint ./src ./tests --quiet",
31
- "test": "npm run test:types && npm run test:unit",
32
- "test:types": "tsc",
33
- "test:unit": "ava"
28
+ "lint": "eslint ./src --quiet",
29
+ "test": "ava"
34
30
  },
35
31
  "author": "Knapsack",
36
32
  "dependencies": {
37
33
  "@babel/preset-react": "^7.25.9",
38
- "@knapsack/app": "4.71.16--canary.5239.d839174.0",
39
- "@knapsack/creator-utils": "4.71.16--canary.5239.d839174.0",
40
- "@knapsack/file-utils": "4.71.16--canary.5239.d839174.0",
41
- "@knapsack/ks-file-utils": "4.71.16--canary.5239.d839174.0",
42
- "@knapsack/renderer-webpack-base": "4.71.16--canary.5239.d839174.0",
43
- "@knapsack/types": "4.71.16--canary.5239.d839174.0",
44
- "@knapsack/utils": "4.71.16--canary.5239.d839174.0",
34
+ "@knapsack/app": "4.71.16",
35
+ "@knapsack/creator-utils": "4.71.16",
36
+ "@knapsack/file-utils": "4.71.16",
37
+ "@knapsack/ks-file-utils": "4.71.16",
38
+ "@knapsack/renderer-react-components": "4.71.16",
39
+ "@knapsack/renderer-webpack-base": "4.71.16",
40
+ "@knapsack/types": "4.71.16",
41
+ "@knapsack/utils": "4.71.16",
45
42
  "react": "^18.3.1",
46
43
  "react-docgen": "^6.0.4",
47
44
  "react-docgen-typescript": "^2.2.2",
@@ -50,10 +47,10 @@
50
47
  "typescript": "^5.6.3"
51
48
  },
52
49
  "devDependencies": {
53
- "@knapsack/eslint-config-starter": "4.71.16--canary.5239.d839174.0",
54
- "@knapsack/sandbox-components": "4.71.16--canary.5239.d839174.0",
55
- "@knapsack/test-ava": "4.71.16--canary.5239.d839174.0",
56
- "@knapsack/typescript-config-starter": "4.71.16--canary.5239.d839174.0",
50
+ "@knapsack/eslint-config-starter": "4.71.16",
51
+ "@knapsack/sandbox-components": "4.71.16",
52
+ "@knapsack/test-ava": "4.71.16",
53
+ "@knapsack/typescript-config-starter": "4.71.16",
57
54
  "@mui/material": "^5.16.7",
58
55
  "@mui/x-data-grid": "^6.20.4",
59
56
  "@types/node": "^20.17.8",
@@ -61,8 +58,7 @@
61
58
  "@types/react-dom": "^18.3.1",
62
59
  "ava": "^6.2.0",
63
60
  "eslint": "^8.57.0",
64
- "prop-types": "^15.8.1",
65
- "tsup": "^8.3.5"
61
+ "prop-types": "^15.8.1"
66
62
  },
67
63
  "publishConfig": {
68
64
  "access": "public"
@@ -72,5 +68,5 @@
72
68
  "directory": "apps/client/renderers/renderer-react",
73
69
  "type": "git"
74
70
  },
75
- "gitHead": "d839174feb8a20eccecdb49293d10ca269a417de"
71
+ "gitHead": "9807af7e7efc7b6190b4184dc508e37b17bcf359"
76
72
  }
@@ -0,0 +1,3 @@
1
+ import PrototypeTemplate from '@knapsack/renderer-react-components/prototype-template';
2
+
3
+ export default PrototypeTemplate;
@@ -0,0 +1,3 @@
1
+ import PrototypeTemplate from '@knapsack/renderer-react-components/prototype-template';
2
+
3
+ export default PrototypeTemplate;
@@ -0,0 +1,10 @@
1
+ const jsx_runtime_1 = require('react/jsx-runtime');
2
+
3
+ const Button = (props) => {
4
+ return (0, jsx_runtime_1.jsx)('button', {
5
+ type: 'button',
6
+ children: props.text,
7
+ });
8
+ };
9
+
10
+ module.exports = { Button };
@@ -0,0 +1,4 @@
1
+ {
2
+ "module": "./button.js",
3
+ "types": "./types/button.d.ts"
4
+ }
@@ -0,0 +1 @@
1
+ note that the dist does not have `x.js` & `x.d.ts` - instead the `types` key in `package.json` points to a different location - this is because of the `declarationDir` config in `tsconfig.json`
@@ -0,0 +1,5 @@
1
+ export declare const Button: (props: {
2
+ text: string;
3
+ size?: 'small' | 'medium' | 'large';
4
+ children: React.ReactNode;
5
+ }) => import('react/jsx-runtime').JSX.Element;
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "extends": "@knapsack/typescript-config-starter/tsconfig.test-only.json",
3
- "include": ["src/**/*", "*.*", "tests/**/*"],
2
+ "extends": "@knapsack/typescript-config-starter/tsconfig.build.json",
3
+ "include": ["src/**/*"],
4
4
  "exclude": ["**/dist"],
5
5
  "compilerOptions": {
6
6
  "strictNullChecks": false,
@@ -1,2 +0,0 @@
1
-
2
- export { }
@@ -1,5 +0,0 @@
1
- 'use strict';var E=require('react'),g=require('react-dom/client'),client=require('@knapsack/renderer-webpack-base/client'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var E__default=/*#__PURE__*/_interopDefault(E);var g__default=/*#__PURE__*/_interopDefault(g);var l=Object.defineProperty;var n=(r,e)=>l(r,"name",{value:e,configurable:!0});var h=(r,e)=>()=>(r&&(e=r(r=0)),e);var C=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var a,m=h(()=>{a="ks-react-meta";});var I=C(()=>{m();async function x(){try{let{getNeededImports:r,getExtraImports:e,rendererMeta:{disableReactStrictMode:d,demoWrapperProps:s},rendererMethods:{getDemoApp:c}}=client.getKsRendererClientUtils({rendererMetaScriptTagId:a}),[i,{DemoWrapper:R,ErrorCatcher:y}]=await Promise.all([r(),e()]),o=document.getElementById("render-root");if(!o)throw new Error("No root element found");let M=c(i),p=jsxRuntime.jsx(y,{children:jsxRuntime.jsx(R,{...s,children:jsxRuntime.jsx(M,{})})});g__default.default.createRoot(o).render(d?p:jsxRuntime.jsx(E__default.default.StrictMode,{children:p}));}catch(r){console.error(r);let e=document.createElement("div");e.innerHTML=`
2
- <h1>Error</h1>
3
- <p>${r.message}</p>
4
- `,document.body.appendChild(e);}}n(x,"init");x();});var init = I();module.exports=init;//# sourceMappingURL=init.js.map
5
- //# sourceMappingURL=init.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/types.ts","../../src/client/init.tsx"],"names":["rendererMetaScriptTagId","init_types","__esmMin","require_init","__commonJSMin","init","getNeededImports","getExtraImports","disableReactStrictMode","demoWrapperProps","getDemoApp","getKsRendererClientUtils","neededImports","DemoWrapper","ErrorCatcher","root","DemoApp","app","jsx","ReactDOM","React","e","errorElement","__name"],"mappings":"kUAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,KAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,KAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,EAAA,CAAA,EAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,OAAA,CAAA,CAAA,IAuBaA,CAvBbC,CAAAA,CAAAA,CAAAC,CAAA,CAAA,IAAA,CAuB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ACjDA,EAAa,SAAY,CAAA;AAAA;AAAA,OAAA,EAEpBD,EAAE,OAAO,CAAA;AAAA,EAEd,CAAA,CAAA,QAAA,CAAS,IAAK,CAAA,WAAA,CAAYC,CAAY,EACxC,CACF,CA9CeC,CAAAA,CAAAlB,CAAA,CAAA,MAAA,CAAA,CAgDfA,CAAK,GAAA,CAAA,CAAA,CAAA,WAAA,CAAA,EAAA","file":"init.js","sourcesContent":["import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type { RendererMetaBase } from '@knapsack/renderer-webpack-base/client';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n demo: Demo;\n patternId: string;\n templateId: string;\n};\n\nexport type ExtraJsImportNames = 'DemoWrapper' | 'ErrorCatcher';\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase;\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n","/// <reference lib=\"dom\" />\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { getKsRendererClientUtils } from '@knapsack/renderer-webpack-base/client';\nimport {\n rendererMetaScriptTagId,\n type KsReactMeta,\n type Component,\n type RendererMethods,\n ExtraJsImportNames,\n} from '../types';\n\nasync function init() {\n try {\n const {\n getNeededImports,\n getExtraImports,\n rendererMeta: { disableReactStrictMode, demoWrapperProps },\n rendererMethods: { getDemoApp },\n } = getKsRendererClientUtils<\n Component,\n KsReactMeta,\n RendererMethods,\n ExtraJsImportNames\n >({\n rendererMetaScriptTagId,\n });\n const [neededImports, { DemoWrapper, ErrorCatcher }] = await Promise.all([\n getNeededImports(),\n getExtraImports(),\n ]);\n const root = document.getElementById('render-root');\n if (!root) {\n throw new Error('No root element found');\n }\n const demoComponents = neededImports;\n const DemoApp = getDemoApp(demoComponents);\n const app = (\n <ErrorCatcher>\n <DemoWrapper {...demoWrapperProps}>\n <DemoApp />\n </DemoWrapper>\n </ErrorCatcher>\n );\n\n ReactDOM.createRoot(root).render(\n disableReactStrictMode ? app : <React.StrictMode>{app}</React.StrictMode>,\n );\n } catch (e) {\n console.error(e);\n // create html element with error message\n const errorElement = document.createElement('div');\n errorElement.innerHTML = `\n <h1>Error</h1>\n <p>${e.message}</p>\n `;\n document.body.appendChild(errorElement);\n }\n}\n\ninit();\n"]}
@@ -1,7 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { D as DemoWrapperProps } from './types-CivTHEEo.mjs';
3
- import '@knapsack/types';
4
-
5
- declare const DemoWrapper: ({ children }: DemoWrapperProps) => react_jsx_runtime.JSX.Element;
6
-
7
- export { DemoWrapper as default };
@@ -1,7 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { D as DemoWrapperProps } from './types-CivTHEEo.js';
3
- import '@knapsack/types';
4
-
5
- declare const DemoWrapper: ({ children }: DemoWrapperProps) => react_jsx_runtime.JSX.Element;
6
-
7
- export { DemoWrapper as default };
@@ -1,2 +0,0 @@
1
- 'use strict';var jsxRuntime=require('react/jsx-runtime');var o=Object.defineProperty;var e=(p,r)=>o(p,"name",{value:r,configurable:!0});var a=e(({children:p})=>jsxRuntime.jsx("div",{className:"demo-wrapper",children:p}),"DemoWrapper"),d=a;module.exports=d;//# sourceMappingURL=demo-wrapper.js.map
2
- //# sourceMappingURL=demo-wrapper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/demo-wrapper.tsx"],"names":["DemoWrapper","__name","children","jsx","demo_wrapper_default"],"mappings":"yDAGE,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CADF,IAAMA,EAAcC,CAAA,CAAA,CAAC,CAAE,QAAAC,CAAAA,CAAS,CAC9BC,GAAAA,cAAAA,CAAC,OAAI,SAAU,CAAA,cAAA,CAAgB,SAAAD,CAAS,CAAA,CAAA,CADtB,eAIbE,CAAQJ,CAAAA","file":"demo-wrapper.js","sourcesContent":["import type { DemoWrapperProps } from './types';\n\nconst DemoWrapper = ({ children }: DemoWrapperProps) => (\n <div className=\"demo-wrapper\">{children}</div>\n);\n\nexport default DemoWrapper;\n"]}
@@ -1,2 +0,0 @@
1
- import {jsx}from'react/jsx-runtime';var o=Object.defineProperty;var e=(p,r)=>o(p,"name",{value:r,configurable:!0});var a=e(({children:p})=>jsx("div",{className:"demo-wrapper",children:p}),"DemoWrapper"),d=a;export{d as default};//# sourceMappingURL=demo-wrapper.mjs.map
2
- //# sourceMappingURL=demo-wrapper.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/demo-wrapper.tsx"],"names":["DemoWrapper","__name","children","jsx","demo_wrapper_default"],"mappings":"oCAGE,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CADF,IAAMA,EAAcC,CAAA,CAAA,CAAC,CAAE,QAAAC,CAAAA,CAAS,CAC9BC,GAAAA,GAAAA,CAAC,OAAI,SAAU,CAAA,cAAA,CAAgB,SAAAD,CAAS,CAAA,CAAA,CADtB,eAIbE,CAAQJ,CAAAA","file":"demo-wrapper.mjs","sourcesContent":["import type { DemoWrapperProps } from './types';\n\nconst DemoWrapper = ({ children }: DemoWrapperProps) => (\n <div className=\"demo-wrapper\">{children}</div>\n);\n\nexport default DemoWrapper;\n"]}
@@ -1,20 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
-
4
- type State = {
5
- hasError: boolean;
6
- componentStack?: string;
7
- error?: Error;
8
- };
9
- declare class ErrorCatcher extends React.Component<{
10
- children: React.ReactNode;
11
- }, State> {
12
- constructor(props: any);
13
- static getDerivedStateFromError(error: Error): {
14
- hasError: boolean;
15
- };
16
- componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
17
- render(): string | number | boolean | Iterable<React.ReactNode> | react_jsx_runtime.JSX.Element;
18
- }
19
-
20
- export { ErrorCatcher as default };
@@ -1,20 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
-
4
- type State = {
5
- hasError: boolean;
6
- componentStack?: string;
7
- error?: Error;
8
- };
9
- declare class ErrorCatcher extends React.Component<{
10
- children: React.ReactNode;
11
- }, State> {
12
- constructor(props: any);
13
- static getDerivedStateFromError(error: Error): {
14
- hasError: boolean;
15
- };
16
- componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
17
- render(): string | number | boolean | Iterable<React.ReactNode> | react_jsx_runtime.JSX.Element;
18
- }
19
-
20
- export { ErrorCatcher as default };
@@ -1,2 +0,0 @@
1
- 'use strict';var n=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var n__namespace=/*#__PURE__*/_interopNamespace(n);var d=Object.defineProperty;var a=(s,t)=>d(s,"name",{value:t,configurable:!0});var o=class extends n__namespace.Component{static{a(this,"ErrorCatcher");}constructor(t){super(t),this.state={hasError:!1,componentStack:"",error:null};}static getDerivedStateFromError(t){return {hasError:!0}}componentDidCatch(t,h){let{componentStack:i}=h;this.setState({error:t,componentStack:i});}render(){return this.state.hasError?jsxRuntime.jsxs("div",{style:{padding:"5px"},children:[jsxRuntime.jsx("h5",{children:"Error caught in React Components"}),this.state.error?.name&&jsxRuntime.jsxs("h5",{children:["Error Name: ",jsxRuntime.jsx("code",{children:this.state.error?.name})]}),this.state.error?.message&&jsxRuntime.jsxs("h5",{children:["Message:",this.state.error?.message]}),this.state.componentStack&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h6",{children:"Component Stack:"}),jsxRuntime.jsx("pre",{children:jsxRuntime.jsx("code",{children:this.state.componentStack})}),jsxRuntime.jsx("br",{})]}),this.state.error?.stack&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("h6",{children:"Error Stack:"}),jsxRuntime.jsx("pre",{children:jsxRuntime.jsx("code",{children:this.state.error?.stack})})]})]}):this.props.children}};module.exports=o;//# sourceMappingURL=error-catcher.js.map
2
- //# sourceMappingURL=error-catcher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error-catcher.tsx"],"names":["ErrorCatcher","n","__name","props","error","errorInfo","componentStack","jsxs","jsx","Fragment"],"mappings":"kbAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAQqBA,CAArB,CAAA,cAAgDC,sBAG9C,CAXF,OAWEC,CAAA,CAAA,IAAA,CAAA,cAAA,EAAA,CACA,WAAYC,CAAAA,CAAAA,CAAO,CACjB,KAAMA,CAAAA,CAAK,CACX,CAAA,IAAA,CAAK,MAAQ,CACX,QAAA,CAAU,CACV,CAAA,CAAA,cAAA,CAAgB,GAChB,KAAO,CAAA,IACT,EACF,CAEA,OAAO,yBAAyBC,CAAc,CAAA,CAE5C,OAAO,CACL,SAAU,CACZ,CAAA,CACF,CAES,iBAAA,CAAkBA,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CAAC,QAAM,QAAK,CAAA,IAAA,CAAA,KAAA,CAAM,KAAO,EAAA,KAAA,CAAM,EACjC,CACF,CAAA,CAAA,CAAA,CAAA,CAEJ,EAIG,IAAK,CAAA,KAAA,CAAM,QACpB,CACF","file":"error-catcher.js","sourcesContent":["import * as React from 'react';\n\ntype State = {\n hasError: boolean;\n componentStack?: string;\n error?: Error;\n};\n\nexport default class ErrorCatcher extends React.Component<\n { children: React.ReactNode },\n State\n> {\n constructor(props) {\n super(props);\n this.state = {\n hasError: false,\n componentStack: '',\n error: null,\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n // Update state so the next render will show the fallback UI.\n return {\n hasError: true,\n };\n }\n\n override componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n const { componentStack } = errorInfo;\n this.setState({\n error,\n componentStack,\n });\n }\n\n override render() {\n if (this.state.hasError) {\n return (\n <div\n style={{\n padding: '5px',\n }}\n >\n <h5>Error caught in React Components</h5>\n {this.state.error?.name && (\n <h5>\n Error Name: <code>{this.state.error?.name}</code>\n </h5>\n )}\n {this.state.error?.message && (\n <h5>\n Message:\n {this.state.error?.message}\n </h5>\n )}\n {this.state.componentStack && (\n <>\n <h6>Component Stack:</h6>\n <pre>\n <code>{this.state.componentStack}</code>\n </pre>\n <br />\n </>\n )}\n {this.state.error?.stack && (\n <>\n <h6>Error Stack:</h6>\n <pre>\n <code>{this.state.error?.stack}</code>\n </pre>\n </>\n )}\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- import*as n from'react';import {jsxs,jsx,Fragment}from'react/jsx-runtime';var d=Object.defineProperty;var a=(s,t)=>d(s,"name",{value:t,configurable:!0});var o=class extends n.Component{static{a(this,"ErrorCatcher");}constructor(t){super(t),this.state={hasError:!1,componentStack:"",error:null};}static getDerivedStateFromError(t){return {hasError:!0}}componentDidCatch(t,h){let{componentStack:i}=h;this.setState({error:t,componentStack:i});}render(){return this.state.hasError?jsxs("div",{style:{padding:"5px"},children:[jsx("h5",{children:"Error caught in React Components"}),this.state.error?.name&&jsxs("h5",{children:["Error Name: ",jsx("code",{children:this.state.error?.name})]}),this.state.error?.message&&jsxs("h5",{children:["Message:",this.state.error?.message]}),this.state.componentStack&&jsxs(Fragment,{children:[jsx("h6",{children:"Component Stack:"}),jsx("pre",{children:jsx("code",{children:this.state.componentStack})}),jsx("br",{})]}),this.state.error?.stack&&jsxs(Fragment,{children:[jsx("h6",{children:"Error Stack:"}),jsx("pre",{children:jsx("code",{children:this.state.error?.stack})})]})]}):this.props.children}};export{o as default};//# sourceMappingURL=error-catcher.mjs.map
2
- //# sourceMappingURL=error-catcher.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/error-catcher.tsx"],"names":["ErrorCatcher","__name","props","error","errorInfo","componentStack","jsxs","jsx","Fragment"],"mappings":"0EAAA,IAAA,CAAA,CAAA,MAAA,CAAA,cAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,MAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,YAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAQqBA,CAArB,CAAA,cAAgD,WAG9C,CAXF,OAWEC,CAAA,CAAA,IAAA,CAAA,cAAA,EAAA,CACA,WAAYC,CAAAA,CAAAA,CAAO,CACjB,KAAMA,CAAAA,CAAK,CACX,CAAA,IAAA,CAAK,MAAQ,CACX,QAAA,CAAU,CACV,CAAA,CAAA,cAAA,CAAgB,GAChB,KAAO,CAAA,IACT,EACF,CAEA,OAAO,yBAAyBC,CAAc,CAAA,CAE5C,OAAO,CACL,SAAU,CACZ,CAAA,CACF,CAES,iBAAA,CAAkBA,EAAcC,CAAkC,CAAA,CACzE,GAAM,CAAE,eAAAC,CAAe,CAAA,CAAID,EAC3B,IAAK,CAAA,QAAA,CAAS,CACZ,KAAAD,CAAAA,CAAAA,CACA,cAAAE,CAAAA,CACF,CAAC,EACH,CAES,M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mjs","sourcesContent":["import * as React from 'react';\n\ntype State = {\n hasError: boolean;\n componentStack?: string;\n error?: Error;\n};\n\nexport default class ErrorCatcher extends React.Component<\n { children: React.ReactNode },\n State\n> {\n constructor(props) {\n super(props);\n this.state = {\n hasError: false,\n componentStack: '',\n error: null,\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n // Update state so the next render will show the fallback UI.\n return {\n hasError: true,\n };\n }\n\n override componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {\n const { componentStack } = errorInfo;\n this.setState({\n error,\n componentStack,\n });\n }\n\n override render() {\n if (this.state.hasError) {\n return (\n <div\n style={{\n padding: '5px',\n }}\n >\n <h5>Error caught in React Components</h5>\n {this.state.error?.name && (\n <h5>\n Error Name: <code>{this.state.error?.name}</code>\n </h5>\n )}\n {this.state.error?.message && (\n <h5>\n Message:\n {this.state.error?.message}\n </h5>\n )}\n {this.state.componentStack && (\n <>\n <h6>Component Stack:</h6>\n <pre>\n <code>{this.state.componentStack}</code>\n </pre>\n <br />\n </>\n )}\n {this.state.error?.stack && (\n <>\n <h6>Error Stack:</h6>\n <pre>\n <code>{this.state.error?.stack}</code>\n </pre>\n </>\n )}\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n"]}
package/dist/index.mjs DELETED
@@ -1,33 +0,0 @@
1
- import ke from'sleep-promise';import {RendererWebpackBase,convertImportMapToNeededImportsByCodeSrcId}from'@knapsack/renderer-webpack-base';import {makeShortId,pascalCase,isFirstLetterCapital,removeWrappingDoubleQuotes}from'@knapsack/utils';import {log,knapsackEvents}from'@knapsack/app';import {babelCodeForBrowser,createSlotOptionsHtmlTags}from'@knapsack/app/renderers';import {rendererIds,isNumberProp,isOptionsProp}from'@knapsack/types';import {findUpPkgJson,exists,formatCode,getJsExportNames,readFile,findUp,resolvePath,getModulePkgJson,copy}from'@knapsack/file-utils';import y,{join,parse,relative}from'path';import {createCreator,tasks}from'@knapsack/creator-utils';import {readKsPatternConfigs,writeDemo,writeKsPatternConfig,readKsNavConfig,addKsNavItems}from'@knapsack/ks-file-utils';var Y=Object.defineProperty;var c=(a,t)=>Y(a,"name",{value:t,configurable:!0}),E=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});function se({templateName:a,attributes:t,children:e}){return `
2
- <${a}
3
- ${t}
4
- ${e?`>
5
- ${e}
6
- </${a}>`:"/>"}
7
- `}c(se,"renderUsageTemplate");var M="DemoApp";function ae({imports:a="",children:t}){return `${a}
8
-
9
- function ${M}() {
10
- return (
11
- ${t}
12
- )
13
- }
14
- `}c(ae,"renderDemoAppTemplate");async function O(a){let t=Object.keys(a.props||{}).map(s=>{let n=a.props[s];return {key:s,value:n}}),{templateName:e,children:r,extraProps:o=[]}=a;if(!e)throw new Error('Cannot getUsage of a React Component when no "templateName" is provided.');let i=t.map(({key:s,value:n})=>{switch(typeof n){case"string":return n.startsWith("(")&&n.includes("=>")?`${s}={${n}}`:`${s}="${n}"`;case"boolean":return n?`${s}`:`${s}={${n}}`;default:return `${s}={${JSON.stringify(n)}}`}}),p=[],d={};o.forEach(({key:s,value:n})=>{d[s]=d[s]??[],d[s].push(n);}),Object.entries(d).forEach(([s,n])=>{let f=n.length===1?n[0]:`<>${n.join(`
15
- `)}</>`;p.push(`${s}={${f}}`);});let u=se({templateName:e,attributes:[...i,...p].join(" "),children:r});return a.format?formatCode({contents:u,path:"x.tsx"}).then(s=>s.trim()).catch(()=>u.trim()):u.trim()}c(O,"getUsage");async function I({children:a,imports:t,format:e}){let r=ae({children:a,imports:t});return e?formatCode({contents:r,path:"x.tsx"}):r}c(I,"getDemoAppUsage");async function V({src:a}){let t=await findUp("tsconfig.json",{cwd:y.dirname(a)}),e=await import('react-docgen-typescript'),r={shouldExtractLiteralValuesFromEnum:!0,savePropValueAsString:!0,skipChildrenPropWithoutDoc:!1,customComponentTypes:["VoidFunctionComponent","VFC"]};return {info:(t?e.withCustomConfig(t,r).parse:e.withDefaultConfig(r).parse)(a)}}c(V,"getTypeScriptInfoFromFile");function ne({info:a,exportName:t}){try{if(!a)return !1;let e={props:{$schema:"http://json-schema.org/draft-07/schema",type:"object",required:[],properties:{}},slots:{}},o=!t||t==="default"?a.pop():a.find(p=>p.displayName===t);if(!o)return !1;return Object.entries(o?.props||{}).forEach(([p,d])=>{let{name:u,description:s,defaultValue:n,required:f,type:l,parent:h}=d;switch(l?.name?.replace("| undefined","").replace(/<.*/g,"").trim()){case"string":e.props.properties[p]={type:"string"};break;case"number":e.props.properties[p]={type:"number"};break;case"boolean":case"bool":n&&"value"in n&&(n.value=n.value==="true"),e.props.properties[p]={type:"boolean"};break;case"enum":e.props.properties[p]={type:"string",enum:[...new Set(l.value.flatMap(({value:b})=>{if(!b)return [];let g=removeWrappingDoubleQuotes(b.trim());return g==="undefined"?[]:[g]}))]};break;case"ReactNode":case"React.ReactNode":case"React.ReactElement":case"ReactElement":e.slots[p]={title:p},s&&(e.slots[p]={...e.slots[p],description:s});break;case"VFC":case"FC":e.slots[p]={title:p,description:s||"A reference to a component",isTemplateReference:!0,allowOnlyOne:!0,disallowText:!0};break;default:if(l?.name?.startsWith("("))e.props.properties[p]={typeof:"function",tsType:d?.type?.name};else if(l?.name?.includes("|")){let b=l.name.split("|").flatMap(g=>{if(!g)return [];let T=removeWrappingDoubleQuotes(g.trim());return T==="undefined"?[]:[T]});b?.length&&(e.props.properties[p]={type:"string",enum:[...new Set(b)]});}else e.props.properties[p]={tsType:d?.type?.name};}e.props.properties[p]&&(f&&e.props.required.push(p),s&&!e.props.properties[p].description&&(e.props.properties[p].description=s),n&&"value"in n&&(isNumberProp(e.props.properties[p])?e.props.properties[p].default=parseFloat(n.value):e.props.properties[p].default=removeWrappingDoubleQuotes(n.value)));}),e}catch(e){return log.verbose("Could not infer spec from React TypeScript file",{exportName:t,error:e},"react renderer"),!1}}c(ne,"extractSpecFromTypeScriptInfo");async function oe({src:a}){let t=await import('react-docgen'),{builtinResolvers:e}=t,r=await readFile(a),{FindExportedDefinitionsResolver:o}=e;return {info:t.parse(r,{resolver:new o,handlers:null,filename:a})}}c(oe,"getPropTypesInfoFromFile");function ie({info:a,exportName:t}){try{let r=!t||t==="default"?a.pop():a.find(i=>i.displayName===t),o={isInferred:!0,props:{$schema:"http://json-schema.org/draft-07/schema",type:"object",required:[],properties:{}},slots:{}};return Object.entries(r?.props||{}).forEach(([i,p])=>{let{required:d,description:u,defaultValue:s}=p;switch(p?.type?.name){case"string":o.props.properties[i]={type:"string"};break;case"func":o.props.properties[i]={type:"string"};break;case"bool":o.props.properties[i]={type:"boolean"};break;case"node":o.slots[i]={title:i,description:u};}o.props.properties[i]&&(d&&o.props.required.push(i),u&&!o.props.properties[i].description&&(o.props.properties[i].description=u),s&&"value"in s&&(o.props.properties[i].default=typeof s.value=="string"?removeWrappingDoubleQuotes(s.value):s.value));}),o}catch(e){return log.verbose("Could not infer spec from React PropTypes",{exportName:t,error:e},"react renderer"),!1}}c(ie,"extractSpecFromPropTypesInfo");function pe({spec:a}){return a===!1||Object.entries(a?.props?.properties||{}).forEach(([t,e])=>{isOptionsProp(e)&&(e.enum.includes(e.default)||(e.default=void 0));}),a}c(pe,"cleanUpSpec");async function ce({src:a,resolveFromDir:t}){let e=await resolvePath({path:a,resolveFromDir:t,resolveType:"types"});if(e.exists){let i=await V({src:e.absolutePath});if(i)return {type:"typescript",info:i.info}}let r=await resolvePath({path:a,resolveFromDir:t});if(!r.exists)return {type:"unknown"};let{ext:o}=y.parse(r.absolutePath);switch(o){case".jsx":return {type:"propTypes",info:(await oe({src:r.absolutePath})).info};case".ts":case".tsx":return {type:"typescript",info:(await V({src:r.absolutePath})).info};default:return {type:"unknown"}}}c(ce,"getReactModuleInfoUncached");var $=new Map,N=c(()=>{log.info("Clearing React TypeScript inferSpec cache..."),$.clear();},"clearInferSpecCache");async function le(a){let t=JSON.stringify(a);return $.has(t)||$.set(t,ce(a)),$.get(t)}c(le,"getReactModuleInfo");async function de({src:a,exportName:t,resolveFromDir:e}){let r=await le({src:a,resolveFromDir:e});switch(r.type){case"typescript":return ne({info:r.info,exportName:t});case"propTypes":return ie({info:r.info,exportName:t});case"unknown":default:return !1}}c(de,"getReactSpec");async function _(a){return pe({spec:await de(a)})}c(_,"getReactDocs");async function L(a,t){try{let{version:e}=getModulePkgJson("react"),{version:r}=getModulePkgJson("react-dom"),o=y.dirname(E.resolve("react",{paths:[process.cwd()]})),i=y.dirname(E.resolve("react-dom",{paths:[process.cwd()]}));await Promise.all([copy(y.join(o,"umd/react.development.js"),y.join(a,`react.development.${e}.js`)),copy(y.join(o,"umd/react.production.min.js"),y.join(a,`react.production.min.${e}.js`)),copy(y.join(i,"umd/react-dom.production.min.js"),y.join(a,`react-dom.production.min.${r}.js`)),copy(y.join(i,"umd/react-dom.development.js"),y.join(a,`react-dom.development.${r}.js`))]);let p=process.env.NODE_ENV==="production"?"production.min":"development";return [y.join(t,`react.${p}.${e}.js`),y.join(t,`react-dom.${p}.${r}.js`)]}catch(e){log.warn('Error trying to copy "react" and "react-dom" JS files, are they installed? We want to use your exact versions.',e,"templateRenderer:react"),process.exit(1);}}c(L,"copyReactAssets");function Re(a){return a.toUpperCase()===a}c(Re,"isCapitalLetter");function be(a){return Re(a[0])}c(be,"startsWithCapitalLetter");function Te({importName:a,id:t,title:e=a,pkgPath:r,initialDemoId:o}){return {id:t,title:e,description:"",statuses:{main:"ready"},templates:[{id:"react",title:"react",path:r,alias:a,templateLanguageId:"react",spec:{isInferred:!0},demoIds:[o],blockIds:[]}],tabs:[{type:"template",id:"react"}],subPages:[]}}c(Te,"createPatternData");var G=createCreator({id:"react-patterns",title:"React Ks Patterns",description:"Adds React templates as Knapsack Patterns",getQuestions:c(async()=>({pkgPath:{type:"text",title:"Package path"},importPrefix:{type:"text",title:"Import Prefix to Remove"}}),"getQuestions"),getTasks:c(async({answers:{pkgPath:a,importPrefix:t=""},config:e})=>{let r=e.dest,i=(await readKsPatternConfigs({dataDir:r})).reduce((d,u)=>{let s=u.templates?.filter(n=>n.templateLanguageId==="react")??[];return d.push(...s.map(n=>n.alias)),d},[]),{exports:p}=await getJsExportNames({path:a});return [{title:"Pick Imports to add",task:c((d,u)=>tasks.runSubCreator({task:u,config:e,creator:createCreator({id:"react-pattern-import-names",getQuestions:c(async()=>({importNames:{type:"choices",choices:p.filter(s=>be(s)&&!i.includes(s)).map(s=>({value:s}))}}),"getQuestions"),getTasks:c(async({answers:s})=>{let{importNames:n}=s,f=n.map(l=>({importName:l,patternId:l.startsWith(t)?l.slice(t.length).toLowerCase():l.toLowerCase()}));return [...f.map(({importName:l,patternId:h})=>({title:`Add ${l} React Template`,task:c(async(w,b)=>{let g={type:"data",id:makeShortId(),title:"Main",patternId:h,templateId:"react",data:{props:{},slots:{}}},T=Te({id:h,importName:l,pkgPath:a,initialDemoId:g.id});await Promise.all([writeDemo({dataDir:r,demo:g}),writeKsPatternConfig({dataDir:r,patternId:h,data:T})]);},"task")})),{title:"Updating Nav",task:c(async(l,h)=>{let{byId:w}=await readKsNavConfig({dataDir:r}),b=Object.values(w).find(({path:g,name:T,id:P})=>g?!1:T.toLowerCase()==="patterns"||T.toLowerCase()==="components");await addKsNavItems({dataDir:r,navItems:f.map(({patternId:g})=>({navId:g,navPath:`/pattern/${g}`,navParent:b?.id||"root"}))});},"task")}]},"getTasks")})}),"task")}]},"getTasks")});var H="ks-react-meta";var{pkg:j}=findUpPkgJson(__dirname);log.setupUpdateNotifier({...j,name:j.name,version:j.version});var K=join(__dirname,"./error-catcher.mjs");if(!exists(K))throw new Error(`Could not find error catcher at: ${K}`);var Q=class a extends RendererWebpackBase{static{c(this,"KnapsackReactRenderer");}assets;babelConfig;#e;#t;constructor({webpackConfig:t,demoWrapperPath:e=join(__dirname,"./demo-wrapper.mjs"),id:r=rendererIds.react,disableReactStrictMode:o}={}){super({id:r,language:"jsx",webpackConfig:t,extraScripts:["@knapsack/renderer-react/client"]}),this.language="jsx",this.assets=[],this.#e=e,this.#t=o,this.creators=[G];}setConfig=c(t=>{super.setConfig(t);let{absolutePath:e,exists:r,type:o}=this.resolvePathSync({path:this.#e,resolveFromDir:this.userConfigDir});if(!r)throw new Error(`Could not find demo wrapper at: "${this.#e}"
16
- Please adjust setting in "knapsack.config.js" or pass a different path when creating the React Renderer.`);this.registerExtraJsImports({DemoWrapper:{exportName:"DemoWrapper",isDefaultExport:!0,path:o==="package"?this.#e:e},ErrorCatcher:{exportName:"ErrorCatcher",isDefaultExport:!0,path:K}});},"setConfig");init=c(async()=>{this.assets=await L(this.outputDir,this.publicPath);},"init");hydrate=c(async t=>{await super.hydrate(t),await this.init({missingFileVerbosity:"silent"});},"hydrate");getMeta=c(()=>({id:this.id,title:"React",aliasUse:"optional",aliasTitle:"Named Export",aliasIsJsNamedExport:!0,aliasDescription:"If `export X` was used instead of `export default`, then provide X.",enableDataDemos:!0,enableTemplateDemos:!0,hasSlotsSupport:!0,hasSlotOptionsSupport:!0,version:j.version,hasInferSpecSupport:!0,syntaxHighlightingLanguage:"jsx",hasTemplateSuggestionsSupport:!0,prototypingTemplate:{path:"@knapsack/renderer-react/prototype-template",spec:{isInferred:!1,props:{type:"object",properties:{}},slots:{children:{title:"Children"}}}}}),"getMeta");changeCase=c(t=>pascalCase(t),"changeCase");createWebpackConfig=c(()=>{let t=super.createWebpackConfig();return t.externals={react:"React","react-dom":"ReactDOM"},t},"createWebpackConfig");async prepClientRenderResults({usage:t,demoApp:e,importMap:r,renderOptions:{demo:o,state:i,patternId:p,templateId:d}}){let u={demo:o,disableReactStrictMode:this.#t,neededImportsByCodeSrcId:convertImportMapToNeededImportsByCodeSrcId(r),demoWrapperProps:{patternId:p,templateId:d,demo:o}},s=`
17
- window.knapsack = window.knapsack || {};
18
- window.knapsack.getDemoApp = ({ ${[...r.keys()].join(", ")} }) => {
19
- ${e}
20
- return ${M}
21
- }
22
- `,n="";try{s=await babelCodeForBrowser({code:s});}catch(l){console.log(s),console.log("---original code before babel error ^---"),console.trace(l.message),s=`console.error(${JSON.stringify(l.message)});`,n=`<pre><code>${l.message}</code></pre>`;}let f=`
23
- <script type="application/json" id="${H}">${JSON.stringify(u)}</script>
24
- <script type="application/javascript">${s}</script>
25
- <div id="render-root" class="knapsack-pattern-direct-parent" data-dev-note="Knapsack React Template Wrapper"></div>
26
- ${this.assets.map(l=>`<script src="${l}"></script>`).join(`
27
- `)}
28
- ${RendererWebpackBase.createHtmlTagsForAssetPaths({assets:this.getWebpackAssetPaths(),scriptTagsAreAsync:!1})}
29
- ${n}
30
- `;return {ok:!n,html:await formatCode({contents:f,path:"x.html"}),usage:t,templateLanguage:this.language}}render=c(async t=>{if(t.demo?.type==="template"){let e=[5,10,20,50,100,1e3,1e3],r,o=0;for(;;)try{let{absolutePath:n,exists:f}=await this.resolvePath(t.demo.templateInfo.path);if(!f)throw new Error(`Template demo file does not exist: ${n}`);r=n;break}catch(n){let f=e[o];if(!f)throw new Error(n);o+=1,await ke(f);}let[i,{usage:p,importMap:d}]=await Promise.all([readFile(r),this.getUsageAndImports({...t,importMap:new Map})]),u=await I({children:p});return await this.prepClientRenderResults({usage:i,demoApp:u,renderOptions:t,importMap:d})}if(t.demo?.type==="data"){let{usage:e,importMap:r}=await this.getUsageAndImports({...t,importMap:new Map}),o=RendererWebpackBase.createJsImportCodeBlock({importMap:r}),[i,p]=await Promise.all([I({children:e,imports:o,format:!0}),I({children:e})]);return this.prepClientRenderResults({demoApp:p,usage:i,renderOptions:t,importMap:r})}},"render");getUsageAndImports=c(async({patternId:t,templateId:e,demo:r,state:o,importMap:i})=>{if(!r)throw new Error(`No demo provided while rendering ${t} ${e}`);let p=o.patterns[t];if(!p)throw new Error(`Could not find pattern: ${t}`);if(r.type==="data"){let u=p.templates.find(g=>g.id===e);if(!u)throw new Error(`Could not find template: ${e}`);let{data:{props:s,slots:n,slotsOptionsComputed:f}}=r,{name:l}=await this.addUniqueValueToImportMap({importMap:i,path:u.path,alias:u.alias||"default"}),h=[],w=[];if(n){let g=Object.keys(n);(await Promise.all(g.map(async P=>{let k=n[P],D=await Promise.all(k.filter(m=>!(!m||m.type!=="text"&&(!m.patternId||!m.templateId||m.type==="template-demo"&&!m.demoId))).map(async m=>{if(m.type==="text")return k.length===1&&P!=="children"?`\`${m.text}\``:m.text;if(m.type==="template-reference"){let R=o.patterns[m.patternId]?.templates.find(z=>z.id===m.templateId);if(!R)throw new Error(`Could not find slotted template: ${m.patternId} ${m.templateId}`);return (await this.addUniqueValueToImportMap({importMap:i,path:R.path,alias:R.alias||"default"})).name}if(m.type==="template-demo"){let R=m.demo;if(!R)throw new Error(`Could not find slotted template demo ${JSON.stringify(m)}`);let{usage:U}=await this.getUsageAndImports({patternId:R.patternId,templateId:R.templateId,demo:R,state:o,importMap:i});return U}throw new Error(`Unknown slot item: ${JSON.stringify(m)}`)}));return {slotName:P,slotItemsUsages:D}}))).forEach(({slotName:P,slotItemsUsages:k})=>{let D=f?.[P],{openTag:m,closeTag:C}=createSlotOptionsHtmlTags({slotOptionsComputed:D,classAttributeName:"className",stylesValueType:"object"});m&&(P==="children"?h.push(m):w.push({key:P,value:m})),k.forEach(R=>{P==="children"?h.push(R):w.push({key:P,value:R});}),C&&(P==="children"?h.push(C):w.push({key:P,value:C}));});}return {usage:await O({templateName:l,props:s,children:h.join(`
31
- `),extraProps:w}),importMap:i}}if(r.type==="template"){let{templateInfo:u}=r,{name:s}=await this.addUniqueValueToImportMap({importMap:i,path:u.path,alias:u.alias||"default"});return {usage:await O({templateName:s}),importMap:i}}throw new Error(`Unhandled demo type for ${t}-${e}: ${JSON.stringify(r)}`)},"getUsageAndImports");inferSpec=c(async({template:t,templatePath:e})=>{let r=await _({src:t.path,exportName:t.alias||"default",resolveFromDir:this.config.data});if(r!==!1){let o=Object.keys(r?.props?.properties||{}).length,i=Object.keys(r?.slots||{}).length;if(o===0&&i===0)return !1}return r},"inferSpec");watch=c(async()=>{super.watch(),knapsackEvents.onPatternTemplateChanged(()=>{N();});},"watch");getTemplateMeta=c(async({pattern:t,template:e})=>{let r=[];if(e?.spec?.props){let o=JSON.parse(JSON.stringify(e.spec.props));e?.spec?.slots&&Object.entries(e.spec.slots).forEach(([p,d])=>{o.properties[p]={typeof:"function",tsType:"React.ReactNode",description:d.allowedPatternIds?`${d.description}. Only use: ${d.allowedPatternIds.join(", ")}`:d.description},o.required=o.required??[],d.isRequired&&o.required.push(p);});let i=await a.convertSchemaToTypeScriptDefs({schema:o,title:`${this.changeCase(t.id)}Props`,description:`[Knapsack Docs](http://localhost:3999/pattern/${t.id}/${e.id})`,patternId:t.id,templateId:e.id,postBanner:"import * as React from 'react';"});r.push({contents:i,encoding:"utf8",path:`${t.id}.${e.id}.spec.d.ts`}),r.push({contents:JSON.stringify(o,null," "),encoding:"utf8",path:`${t.id}.${e.id}.spec.json`});}return r},"getTemplateMeta");alterTemplateMetaFiles=c(async({files:t,metaDir:e})=>{let r=[],o=".spec.d.ts";return t.forEach(i=>{if(i.path.endsWith(o)){let{base:p}=parse(i.path),[d,u]=p.split("."),s=u===this.id,n=this.changeCase(`${d}Props`),f=this.changeCase(`${d}-${u}Props`);r.push(`export { ${s?n:`${n} as ${f}`} } from './${relative(e,i.path).replace(".d.ts","")}';`);}}),r.push(""),[...t,{contents:r.join(`
32
- `),encoding:"utf8",path:join(e,"react.d.ts")}]},"alterTemplateMetaFiles");getTemplateSuggestions=c(async({newPath:t,state:e})=>{let r=Array.from(new Map(Object.values(e.patterns).reduce((s,{templateDemos:n,templates:f})=>(f.forEach(({path:l,alias:h,templateLanguageId:w})=>{w===this.id&&s.push([JSON.stringify({path:l,alias:h}),{path:l,alias:h}]);}),n.forEach(({templateInfo:{path:l,alias:h},templateLanguageId:w})=>{w===this.id&&s.push([JSON.stringify({path:l,alias:h}),{path:l,alias:h}]);}),s),[])).values()),o=new Set(this.getCodeSrcs().map(({path:s})=>s)),i=[...new Set([t,...Object.keys(this.pkgPathAliases||{}),...o])],d=(await Promise.all(i.map(async s=>{if(!s)return [];try{let{exports:n,errorMsg:f}=await getJsExportNames({path:s,resolveFromDir:this.dataDir,pkgPathAliases:this.pkgPathAliases});if(f)throw new Error(f);return n.filter(l=>l==="default"||isFirstLetterCapital(l)).map(l=>({alias:l,path:s}))}catch(n){return log.verbose(`Error getting import names for ${s}: ${n.message}`,null,this.logPrefix),[]}})).then(s=>s.flat())).filter(s=>!r.find(n=>n.alias===s.alias&&n.path===s.path)),u=r.map(s=>({...s,connected:!0}));return {suggestions:[...d,...u]}},"getTemplateSuggestions")};export{Q as KnapsackReactRenderer};//# sourceMappingURL=index.mjs.map
33
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/react-creators.ts","../src/types.ts","../src/renderer-react.ts"],"names":["renderUsageTemplate","templateName","attributes","children","__name","demoAppName","renderDemoAppTemplate","imports","getUsage","data","props","key","value","extraProps","extraAttributes","slotProps","values","result","formatCode","code","getDemoAppUsage","format","getTypeScriptInfoFromFile","src","tsConfigPath","findUp","path","rdTs","config","extractSpecFromTypeScriptInfo","results","exportName","spec","r","propName","propDef","name","description","defaultValue","required","type","parent","item","removeWrappingDoubleQuotes","options","enumItem","isNumberProp","error","log","getPropTypesInfoFromFile","reactDocs","builtinResolvers","fileSrc","readFile","FindExportedDefinitionsResolver","extractSpecFromPropTypesInfo","cleanUpSpec","prop","isOptionsProp","getReactModuleInfoUncached","unknownSrc","resolveFromDir","typesInfo","resolvePath","typeScriptInfo","jsInfo","ext","getReactModuleInfoCache","clearInferSpecCache","getReactModuleInfo","args","cacheKey","getReactSpec","reactModuleInfo","getReactDocs","opt","copyReactAssets","distDirAbsolute","publicPath","reactVersion","getModulePkgJson","reactDomVersion","reactRoot","__require","reactDomRoot","copy","reactFileSuffix","isCapitalLetter","char","startsWithCapitalLetter","str","createPatternData","importName","id","title","pkgPath","initialDemoId","createReactPattern","createCreator","importPrefix","dataDir","currentReactPatternsImportNames","readKsPatternConfigs","cur","pattern","reactTemplates","t","allImports","getJsExportNames","_","task","tasks","answers","importNames","patterns","patternId","__","subTask","initialDemo","makeShortId","writeDemo","writeKsPatternConfig","byId","readKsNavConfig","componentsGroup","addKsNavItems","rendererMetaScriptTagId","pkg","findUpPkgJson","errorCatcherAbsolutePath","join","fileExists","KnapsackReactRenderer","_KnapsackReactRenderer","RendererWebpackBase","#demoWrapperPath","#disableReactStrictMode","webpackConfig","demoWrapperPath","rendererIds","disableReactStrictMode","absolutePath","demoWrapperPathExists","pascalCase","usage","demoApp","importMap","demo","state","templateId","meta","convertImportMapToNeededImportsByCodeSrcId","errorHtmlMsg","babelCodeForBrowser","e","html","asset","waits","templateDemoPath","attempt","exists","waitTime","sleep","templateFileContents","importCode","demoAppUsage","template","slots","slotsOptionsComputed","slotNames","slotName","slotItems","slotItemsUsages","slotItem","slottedTemplate","thisDemo","slotOptionsComputed","openTag","closeTag","createSlotOptionsHtmlTags","templateInfo","templatePath","totalProps","totalSlots","knapsackEvents","files","schema","info","typeDefs","metaDir","file","base","parse","isFirst","exportNameWithTemplateId","relative","newPath","usedSuggestions","acc","templateDemos","templates","alias","templateLanguageId","codeSrcs","allPaths","suggestions","exports","errorMsg","isFirstLetterCapital","us","connectedSuggestions"],"mappings":"6lCAgEA,SAASA,GAAoB,CAC3B,YAAA,CAAAC,EACA,UAAAC,CAAAA,CAAAA,CACA,SAAAC,CACF,CAAA,CAIG,CACD,OAAO;AAAA,KAAA,EACFF,CAAY;AAAA,MAAA,EACXC,CAAU;AAAA,MAAA,EAEVC,CACI,CAAA,CAAA;AAAA,QAAA,EACFA,CAAQ;AAAA,QACRF,EAAAA,CAAY,IACV,IACN;AAAA,EAAA,CAEN,CApBSG,CAAAJ,CAAAA,EAAAA,CAAA,uBAqBF,IAAMK,CAAAA,CAAc,UAE3B,SAASC,EAAAA,CAAsB,CAC7B,OAAAC,CAAAA,CAAAA,CAAU,GACV,QAAAJ,CAAAA,CACF,EAGG,CACD,OAAO,GAAGI,CAAO;;AAAA,SAAA,EA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MA,CAAQ,CAAA,CAE1B,OACED,CAGG,CAAA,MAAA,CAAQpD,CAAMA,EAAAA,CAAAA,GAAM,WAAasD,oBAAqBtD,CAAAA,CAAC,CAAC,CAAA,CACxD,IAAKtH,CAAU,GAAA,CACd,KAAOA,CAAAA,CAAAA,CACP,IAAAV,CAAAA,CACF,CAAE,CAAA,CAER,OAASgI,CAAG,CAAA,CAEV,OAAA1G,GAAAA,CAAI,OACF,CAAA,CAAA,+BAAA,EAAkCtB,CAAI,CAAA,EAAA,EAAKgI,EAAE,OAAO,CAAA,CAAA,CACpD,IACA,CAAA,IAAA,CAAK,SACP,CAAA,CACO,EACT,CACF,CAAC,CACH,CAAE,CAAA,IAAA,CAAM5H,GAECA,CAAQ,CAAA,IAAA,EAChB,CAAA,EAEkC,OAAQ,CAClC,EAAA,CAACuK,CAAgB,CAAA,IAAA,CACrBY,CAAOA,EAAAA,CAAAA,CAAG,KAAU,GAAA,CAAA,CAAE,OAASA,CAAG,CAAA,IAAA,GAAS,CAAE,CAAA,IAChD,CACD,CAAA,CACKC,CAAuBb,CAAAA,CAAAA,CAAgB,IAAK,CAAO,GAAA,CACvD,GAAG,CAAA,CACH,SAAW,CAAA,CAAA,CACb,CAAE,CAAA,CAAA,CAEF,OAAO,CACL,WAAA,CAAa,CAAC,GAAGQ,EAAa,GAAGK,CAAoB,CACvD,CACF,EAtF6D,wBAuF/D,CAAA","file":"index.mjs","sourcesContent":["import { log } from '@knapsack/app';\nimport {\n getModulePkgJson,\n readFile,\n copy,\n formatCode,\n resolvePath,\n findUp,\n} from '@knapsack/file-utils';\nimport { removeWrappingDoubleQuotes } from '@knapsack/utils';\nimport path from 'path';\nimport type { Documentation } from 'react-docgen';\nimport type { ComponentDoc, ParserOptions } from 'react-docgen-typescript';\nimport { KsTemplateSpec, isNumberProp, isOptionsProp } from '@knapsack/types';\n\ntype GetSpecParams = {\n src: string;\n exportName?: string;\n};\n\n/**\n * The name of the type, which is usually corresponds to the function name in `React.PropTypes`. However, for types define with `oneOf`, we use `\"enum\"` and for `oneOfType` we use `\"union\"`. If a custom function is provided or the type cannot be resolved to anything of `React.PropTypes`, we use `\"custom\"`.\n */\ntype RdTypeName =\n | 'number'\n | 'string'\n | 'custom'\n | 'union'\n | 'bool'\n | 'node'\n | 'func';\n\n/**\n * Some types accept parameters which define the type in more detail (such as `arrayOf`, `instanceOf`, `oneOf`, etc). Those are stored in `<typeValue>`. The data type of `<typeValue>` depends on the type definition.\n */\ntype RdTypeValue = string;\n\ntype RdProps = {\n [prop: string]: {\n defaultValue?: {\n value: string;\n computed: boolean;\n };\n type: {\n name: RdTypeName;\n value?: RdTypeValue;\n raw?: string;\n };\n flowType?: string;\n tsType?: string;\n description?: string;\n required: boolean;\n };\n};\n\ntype RdResults = {\n /**\n * Name of function, class, or const\n */\n displayName: string;\n description?: string;\n props: RdProps;\n};\n\nfunction renderUsageTemplate({\n templateName,\n attributes,\n children,\n}: {\n templateName: string;\n attributes: string;\n children: string;\n}) {\n return `\n <${templateName}\n ${attributes}\n ${\n children\n ? `>\n ${children}\n </${templateName}>`\n : '/>'\n }\n `;\n}\nexport const demoAppName = 'DemoApp';\n\nfunction renderDemoAppTemplate({\n imports = '',\n children,\n}: {\n imports: string;\n children: string;\n}) {\n return `${imports}\n\nfunction ${demoAppName}() {\n return (\n ${children}\n )\n}\n`;\n}\n\nexport async function getUsage(data: {\n templateName: string;\n props?: Record<string, unknown>;\n children?: string;\n extraProps?: {\n key: string;\n value: string;\n }[];\n format?: boolean;\n}): Promise<string> {\n const props = Object.keys(data.props || {}).map((key) => {\n const value = data.props[key];\n return {\n key,\n value,\n };\n });\n\n const { templateName, children, extraProps = [] } = data;\n if (!templateName) {\n throw new Error(\n `Cannot getUsage of a React Component when no \"templateName\" is provided.`,\n );\n }\n\n const attributes: string[] = props.map(({ key, value }) => {\n switch (typeof value) {\n case 'string':\n // Is this a function like `() => {}` but not a \"sizes\" attribute for an image like `(min-width: 400px) 50vw, 100vw`?\n if (value.startsWith('(') && value.includes('=>')) {\n return `${key}={${value}}`;\n }\n return `${key}=\"${value}\"`;\n case 'boolean':\n return value ? `${key}` : `${key}={${value}}`;\n default:\n return `${key}={${JSON.stringify(value)}}`;\n }\n });\n\n const extraAttributes: string[] = [];\n const slotProps: { [key: string]: string[] } = {};\n\n extraProps.forEach(({ key, value }) => {\n slotProps[key] = slotProps[key] ?? [];\n slotProps[key].push(value);\n });\n\n Object.entries(slotProps).forEach(([key, values]) => {\n const value = values.length === 1 ? values[0] : `<>${values.join('\\n')}</>`;\n extraAttributes.push(`${key}={${value}}`);\n });\n\n const result = renderUsageTemplate({\n templateName,\n attributes: [...attributes, ...extraAttributes].join(' '),\n children,\n });\n return data.format\n ? formatCode({\n contents: result,\n path: 'x.tsx', // doing this to set format language\n })\n .then((code) => code.trim())\n .catch(() => result.trim()) // if format fails, just return the unformatted code\n : result.trim();\n}\n\nexport async function getDemoAppUsage({\n children,\n imports,\n format,\n}: {\n children: string;\n imports?: string;\n format?: boolean;\n}): Promise<string> {\n const code = renderDemoAppTemplate({\n children,\n imports,\n });\n if (!format) return code;\n return formatCode({\n contents: code,\n path: 'x.tsx', // doing this to set format language\n });\n}\n\nasync function getTypeScriptInfoFromFile({ src }: { src: string }): Promise<{\n info: ComponentDoc[];\n}> {\n const tsConfigPath = await findUp('tsconfig.json', {\n cwd: path.dirname(src),\n });\n const rdTs = await import('react-docgen-typescript');\n const config: ParserOptions = {\n shouldExtractLiteralValuesFromEnum: true,\n savePropValueAsString: true,\n skipChildrenPropWithoutDoc: false,\n // In addition to the ones listed here, which had not strangely included these below ~ https://github.com/styleguidist/react-docgen-typescript/blob/287e7012843cb26fed8f4bd8ee24e462c25a1414/src/parser.ts#L308\n customComponentTypes: ['VoidFunctionComponent', 'VFC'],\n };\n const parse = tsConfigPath\n ? rdTs.withCustomConfig(tsConfigPath, config).parse\n : rdTs.withDefaultConfig(config).parse;\n return {\n info: parse(src),\n };\n}\n\nfunction extractSpecFromTypeScriptInfo({\n info: results,\n exportName,\n}: {\n info: ComponentDoc[];\n exportName: string;\n}): KsTemplateSpec | false {\n try {\n if (!results) return false;\n const spec: KsTemplateSpec = {\n props: {\n $schema: 'http://json-schema.org/draft-07/schema',\n type: 'object',\n required: [],\n properties: {},\n },\n slots: {\n // children: {\n // title: 'children',\n // },\n },\n };\n\n const isDefaultExport = !exportName || exportName === 'default';\n\n // if `isDefaultExport` then we just grab last result since `export default` TENDS to be last. that'll we can do really...\n const result = isDefaultExport\n ? results.pop()\n : results.find((r) => r.displayName === exportName);\n\n // log.inspect({ result, isDefaultExport, exportName }, 'ts result');\n if (!result) return false;\n\n const { displayName } = result;\n // log.inspect({ result }, 'result');\n Object.entries(result?.props || {}).forEach(([propName, propDef]) => {\n const { name, description, defaultValue, required, type, parent } =\n propDef;\n\n // `type.name` can include `| undefined` if tsConfig has `strict: true`. So we need to handle these scenarios:\n // `string` or `string | undefined`\n // `'left' | 'right'` or `'left' | 'right' | undefined`\n const propType = type?.name\n ?.replace('| undefined', '')\n // remove generics. things like `FC<{}>` and `FC<Props>` should become `FC`\n .replace(/<.*/g, '')\n .trim();\n\n switch (propType) {\n case 'string':\n spec.props.properties[propName] = {\n type: 'string',\n };\n break;\n case 'number':\n spec.props.properties[propName] = {\n type: 'number',\n };\n break;\n case 'boolean':\n case 'bool':\n if (defaultValue && 'value' in defaultValue) {\n // comes in as `'true'` - this turns it to `true`\n defaultValue.value = defaultValue.value === 'true';\n }\n spec.props.properties[propName] = {\n type: 'boolean',\n };\n break;\n case 'enum':\n type EnumType = {\n name: string;\n raw: string;\n value: {\n /** Looks like `'\"option1\"'` - beware of string that contains `\"` */\n value: string;\n }[];\n };\n spec.props.properties[propName] = {\n type: 'string',\n // yes there is a double \"value\" & yes it is confusing\n enum: [\n // ensure list is unique\n ...new Set<string>(\n (type as EnumType).value.flatMap(({ value }) => {\n if (!value) return [];\n const item = removeWrappingDoubleQuotes(value.trim());\n if (item === 'undefined') {\n return [];\n }\n return [item];\n }),\n ),\n ],\n };\n break;\n case 'ReactNode':\n case 'React.ReactNode':\n case 'React.ReactElement':\n case 'ReactElement':\n spec.slots[propName] = {\n title: propName,\n };\n if (description) {\n spec.slots[propName] = {\n ...spec.slots[propName],\n description,\n };\n }\n break;\n case 'VFC':\n case 'FC':\n spec.slots[propName] = {\n title: propName,\n description: description || 'A reference to a component',\n isTemplateReference: true,\n allowOnlyOne: true,\n disallowText: true,\n };\n break;\n default: {\n if (type?.name?.startsWith('(')) {\n // functions\n spec.props.properties[propName] = {\n // description: `\\`${type.name}\\` ${description}`,\n typeof: 'function',\n tsType: propDef?.type?.name,\n };\n } else if (type?.name?.includes('|')) {\n // enums / unions (multi-choice strings)\n // comes in like this: `{ name: '\"option1\" | \"option2\" | \"option3\"' }`\n const options = type.name.split('|').flatMap((enumItem) => {\n if (!enumItem) return [];\n const item = removeWrappingDoubleQuotes(enumItem.trim());\n if (item === 'undefined') {\n return [];\n }\n return [item];\n });\n\n if (options?.length) {\n spec.props.properties[propName] = {\n type: 'string',\n // ensuring list is unique\n enum: [...new Set(options)],\n };\n }\n } else {\n spec.props.properties[propName] = {\n tsType: propDef?.type?.name,\n };\n }\n }\n }\n\n // assigning info that all would have\n if (spec.props.properties[propName]) {\n if (required) spec.props.required.push(propName);\n if (description && !spec.props.properties[propName].description) {\n spec.props.properties[propName].description = description;\n }\n if (defaultValue && 'value' in defaultValue) {\n if (isNumberProp(spec.props.properties[propName])) {\n spec.props.properties[propName].default = parseFloat(\n defaultValue.value,\n );\n } else {\n spec.props.properties[propName].default =\n removeWrappingDoubleQuotes(defaultValue.value);\n }\n }\n }\n\n // console.log('type', type);\n });\n\n return spec;\n } catch (error) {\n log.verbose(\n 'Could not infer spec from React TypeScript file',\n {\n exportName,\n error,\n },\n 'react renderer',\n );\n return false;\n }\n}\n\nasync function getPropTypesInfoFromFile({ src }: { src: string }): Promise<{\n info: Documentation[];\n}> {\n const reactDocs = await import('react-docgen');\n const { builtinResolvers } = reactDocs;\n const fileSrc = await readFile(src);\n const { FindExportedDefinitionsResolver } = builtinResolvers;\n const results: Documentation[] = reactDocs.parse(fileSrc, {\n resolver: new FindExportedDefinitionsResolver(),\n handlers: null,\n filename: src,\n // babelrc: false,\n });\n return {\n info: results,\n };\n}\n\nfunction extractSpecFromPropTypesInfo({\n info: results,\n exportName,\n}: {\n info: Documentation[];\n exportName: string;\n}): KsTemplateSpec | false {\n try {\n const isDefaultExport = !exportName || exportName === 'default';\n\n // if `isDefaultExport` then we just grab last result since `export default` TENDS to be last. that'll we can do really...\n const result = isDefaultExport\n ? results.pop()\n : results.find((r) => r.displayName === exportName);\n\n // log.inspect(results, 'JSX PropTypes Results');\n // console.log(JSON.stringify(result, null, ' '));\n\n const spec: KsTemplateSpec = {\n isInferred: true,\n props: {\n $schema: 'http://json-schema.org/draft-07/schema',\n type: 'object',\n required: [],\n properties: {},\n },\n slots: {},\n };\n\n Object.entries(result?.props || {}).forEach(([propName, propDef]) => {\n const { required, description, defaultValue } = propDef;\n switch (propDef?.type?.name) {\n case 'string':\n spec.props.properties[propName] = {\n type: 'string',\n };\n break;\n case 'func':\n spec.props.properties[propName] = {\n type: 'string',\n };\n break;\n case 'bool':\n spec.props.properties[propName] = {\n type: 'boolean',\n };\n break;\n case 'node':\n spec.slots[propName] = {\n title: propName,\n description,\n };\n }\n\n // assigning info that all would have\n if (spec.props.properties[propName]) {\n if (required) spec.props.required.push(propName);\n if (description && !spec.props.properties[propName].description) {\n spec.props.properties[propName].description = description;\n }\n if (defaultValue && 'value' in defaultValue) {\n spec.props.properties[propName].default =\n typeof defaultValue.value === 'string'\n ? removeWrappingDoubleQuotes(defaultValue.value)\n : defaultValue.value;\n }\n }\n });\n\n return spec;\n } catch (error) {\n log.verbose(\n 'Could not infer spec from React PropTypes',\n {\n exportName,\n error,\n },\n 'react renderer',\n );\n return false;\n }\n}\n\nfunction cleanUpSpec({\n spec,\n}: {\n spec: KsTemplateSpec | false;\n}): KsTemplateSpec | false {\n if (spec === false) return spec;\n // ok to mutate b/c spec was just created before passing in here\n Object.entries(spec?.props?.properties || {}).forEach(([propName, prop]) => {\n if (isOptionsProp(prop)) {\n // If the default is not in the enum, it should not be there\n // OR the enum is wrong\n if (!prop.enum.includes(prop.default)) {\n prop.default = undefined;\n }\n }\n });\n\n return spec;\n}\n\nasync function getReactModuleInfoUncached({\n src: unknownSrc,\n resolveFromDir,\n}: {\n src: string;\n resolveFromDir: string;\n}): Promise<\n | {\n type: 'typescript';\n info: ComponentDoc[];\n }\n | {\n type: 'propTypes';\n info: Documentation[];\n }\n | {\n type: 'unknown';\n }\n> {\n const typesInfo = await resolvePath({\n path: unknownSrc,\n resolveFromDir,\n resolveType: 'types',\n });\n if (typesInfo.exists) {\n const typeScriptInfo = await getTypeScriptInfoFromFile({\n src: typesInfo.absolutePath,\n });\n if (typeScriptInfo) {\n return {\n type: 'typescript',\n info: typeScriptInfo.info,\n };\n }\n }\n const jsInfo = await resolvePath({\n path: unknownSrc,\n resolveFromDir,\n });\n if (!jsInfo.exists) return { type: 'unknown' };\n const { ext } = path.parse(jsInfo.absolutePath);\n switch (ext) {\n case '.jsx': {\n const propTypesInfo = await getPropTypesInfoFromFile({\n src: jsInfo.absolutePath,\n });\n return {\n type: 'propTypes',\n info: propTypesInfo.info,\n };\n }\n case '.ts':\n case '.tsx': {\n const typeScriptInfo = await getTypeScriptInfoFromFile({\n src: jsInfo.absolutePath,\n });\n return {\n type: 'typescript',\n info: typeScriptInfo.info,\n };\n }\n default:\n return {\n type: 'unknown',\n };\n }\n}\n\nconst getReactModuleInfoCache = new Map<\n string,\n ReturnType<typeof getReactModuleInfoUncached>\n>();\nexport const clearInferSpecCache = () => {\n log.info(`Clearing React TypeScript inferSpec cache...`);\n getReactModuleInfoCache.clear();\n};\nasync function getReactModuleInfo(\n args: Parameters<typeof getReactModuleInfoUncached>[0],\n) {\n const cacheKey = JSON.stringify(args);\n if (!getReactModuleInfoCache.has(cacheKey)) {\n getReactModuleInfoCache.set(cacheKey, getReactModuleInfoUncached(args));\n }\n return getReactModuleInfoCache.get(cacheKey);\n}\n\nasync function getReactSpec({\n src,\n exportName,\n resolveFromDir,\n}: GetSpecParams & {\n resolveFromDir: string;\n}): Promise<KsTemplateSpec | false> {\n const reactModuleInfo = await getReactModuleInfo({\n src,\n resolveFromDir,\n });\n switch (reactModuleInfo.type) {\n case 'typescript':\n return extractSpecFromTypeScriptInfo({\n info: reactModuleInfo.info,\n exportName,\n });\n case 'propTypes':\n return extractSpecFromPropTypesInfo({\n info: reactModuleInfo.info,\n exportName,\n });\n case 'unknown':\n default:\n return false;\n }\n}\n\nexport async function getReactDocs(\n opt: GetSpecParams & {\n resolveFromDir: string;\n },\n): Promise<KsTemplateSpec | false> {\n return cleanUpSpec({\n spec: await getReactSpec(opt),\n });\n}\n\nexport async function copyReactAssets(\n distDirAbsolute: string,\n publicPath: string,\n): Promise<string[]> {\n try {\n const { version: reactVersion } = getModulePkgJson('react');\n const { version: reactDomVersion } = getModulePkgJson('react-dom');\n\n // switch to resolving the root NPM package dir vs the entire file via require.resolve\n // workaround due to NPM packages using the exports field; prevents these from being auto-resolved\n const reactRoot = path.dirname(\n require.resolve('react', {\n paths: [process.cwd()],\n }),\n );\n const reactDomRoot = path.dirname(\n require.resolve('react-dom', {\n paths: [process.cwd()],\n }),\n );\n await Promise.all([\n copy(\n path.join(reactRoot, 'umd/react.development.js'),\n path.join(distDirAbsolute, `react.development.${reactVersion}.js`),\n ),\n copy(\n path.join(reactRoot, 'umd/react.production.min.js'),\n path.join(distDirAbsolute, `react.production.min.${reactVersion}.js`),\n ),\n copy(\n path.join(reactDomRoot, 'umd/react-dom.production.min.js'),\n path.join(\n distDirAbsolute,\n `react-dom.production.min.${reactDomVersion}.js`,\n ),\n ),\n copy(\n path.join(reactDomRoot, 'umd/react-dom.development.js'),\n path.join(\n distDirAbsolute,\n `react-dom.development.${reactDomVersion}.js`,\n ),\n ),\n ]);\n const reactFileSuffix =\n process.env.NODE_ENV === 'production' ? 'production.min' : 'development';\n\n return [\n path.join(publicPath, `react.${reactFileSuffix}.${reactVersion}.js`),\n path.join(\n publicPath,\n `react-dom.${reactFileSuffix}.${reactDomVersion}.js`,\n ),\n ];\n } catch (error) {\n log.warn(\n 'Error trying to copy \"react\" and \"react-dom\" JS files, are they installed? We want to use your exact versions.',\n error,\n 'templateRenderer:react',\n );\n process.exit(1);\n }\n}\n","import { getJsExportNames } from '@knapsack/file-utils';\nimport { createCreator, tasks, Task } from '@knapsack/creator-utils';\nimport {\n readKsPatternConfigs,\n writeKsPatternConfig,\n readKsNavConfig,\n addKsNavItems,\n writeDemo,\n} from '@knapsack/ks-file-utils';\nimport { Demo, KnapsackPattern } from '@knapsack/types';\nimport { makeShortId } from '@knapsack/utils';\n\nfunction isCapitalLetter(char: string): boolean {\n return char.toUpperCase() === char;\n}\n\nfunction startsWithCapitalLetter(str: string): boolean {\n return isCapitalLetter(str[0]);\n}\n\nfunction createPatternData({\n importName,\n id,\n title = importName,\n pkgPath,\n initialDemoId,\n}: {\n importName: string;\n id: string;\n title?: string;\n pkgPath: string;\n initialDemoId: string;\n}): KnapsackPattern {\n return {\n id,\n title,\n description: '',\n statuses: {\n main: 'ready',\n },\n templates: [\n {\n id: 'react',\n title: 'react',\n path: pkgPath,\n alias: importName,\n templateLanguageId: 'react',\n spec: {\n isInferred: true,\n },\n demoIds: [initialDemoId],\n blockIds: [],\n },\n ],\n tabs: [\n {\n type: 'template',\n id: 'react',\n },\n ],\n subPages: [],\n };\n}\n\nexport const createReactPattern = createCreator({\n id: 'react-patterns',\n title: 'React Ks Patterns',\n description: 'Adds React templates as Knapsack Patterns',\n getQuestions: async () => ({\n pkgPath: {\n type: 'text',\n title: 'Package path',\n },\n importPrefix: {\n type: 'text',\n title: 'Import Prefix to Remove',\n },\n }),\n getTasks: async ({ answers: { pkgPath, importPrefix = '' }, config }) => {\n const dataDir = config.dest;\n const currentPatterns = await readKsPatternConfigs({\n dataDir,\n });\n const currentReactPatternsImportNames = currentPatterns.reduce(\n (cur, pattern) => {\n const reactTemplates =\n pattern.templates?.filter((t) => t.templateLanguageId === 'react') ??\n [];\n cur.push(...reactTemplates.map((t) => t.alias));\n return cur;\n },\n [] as string[],\n );\n const { exports: allImports } = await getJsExportNames({\n path: pkgPath,\n });\n return [\n {\n title: 'Pick Imports to add',\n task: (_, task) =>\n tasks.runSubCreator({\n task,\n config,\n creator: createCreator({\n id: 'react-pattern-import-names',\n getQuestions: async () => ({\n importNames: {\n type: 'choices' as const,\n choices: allImports\n .filter(\n (importName) =>\n startsWithCapitalLetter(importName) &&\n !currentReactPatternsImportNames.includes(importName),\n )\n .map((importName) => ({\n value: importName,\n })),\n },\n }),\n getTasks: async ({ answers }) => {\n // not sure why TS failed to infer this. happened during turning on strictNullChecks\n const { importNames } = answers as { importNames: string[] };\n const patterns = importNames.map((importName) => ({\n importName,\n patternId: importName.startsWith(importPrefix)\n ? importName.slice(importPrefix.length).toLowerCase()\n : importName.toLowerCase(),\n }));\n return [\n ...patterns.map(\n ({ importName, patternId }): Task => ({\n title: `Add ${importName} React Template`,\n task: async (__, subTask) => {\n const initialDemo: Demo = {\n type: 'data',\n id: makeShortId(),\n title: 'Main',\n patternId,\n templateId: 'react',\n data: {\n props: {},\n slots: {},\n },\n };\n const pattern = createPatternData({\n id: patternId,\n importName,\n pkgPath,\n initialDemoId: initialDemo.id,\n });\n\n await Promise.all([\n writeDemo({\n dataDir,\n demo: initialDemo,\n }),\n writeKsPatternConfig({\n dataDir,\n patternId,\n data: pattern,\n }),\n ]);\n },\n }),\n ),\n {\n title: `Updating Nav`,\n task: async (__, subTask) => {\n const { byId } = await readKsNavConfig({\n dataDir,\n });\n // attempt to find a nav group to put patterns under\n const componentsGroup = Object.values(byId).find(\n ({ path, name, id }) => {\n // we only want groups (i.e. not pages or patterns)\n if (path) return false;\n if (name.toLowerCase() === 'patterns') return true;\n if (name.toLowerCase() === 'components') return true;\n return false;\n },\n );\n await addKsNavItems({\n dataDir,\n navItems: patterns.map(({ patternId }) => ({\n navId: patternId,\n navPath: `/pattern/${patternId}`,\n navParent: componentsGroup?.id || 'root',\n })),\n });\n },\n },\n ];\n },\n }),\n }),\n },\n ];\n },\n});\n","import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type { RendererMetaBase } from '@knapsack/renderer-webpack-base/client';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n demo: Demo;\n patternId: string;\n templateId: string;\n};\n\nexport type ExtraJsImportNames = 'DemoWrapper' | 'ErrorCatcher';\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase;\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n","import sleep from 'sleep-promise';\nimport {\n RendererWebpackBase,\n Renderer,\n KsJsImportMap,\n convertImportMapToNeededImportsByCodeSrcId,\n} from '@knapsack/renderer-webpack-base';\nimport { pascalCase, isFirstLetterCapital } from '@knapsack/utils';\nimport { knapsackEvents, log } from '@knapsack/app';\nimport {\n Renderable,\n babelCodeForBrowser,\n createSlotOptionsHtmlTags,\n} from '@knapsack/app/renderers';\nimport {\n KnapsackFile,\n KnapsackPatternTemplate,\n KsTemplateSpec,\n TemplateSuggestion,\n rendererIds,\n RendererId,\n} from '@knapsack/types';\nimport {\n exists as fileExists,\n findUpPkgJson,\n getJsExportNames,\n readFile,\n formatCode,\n} from '@knapsack/file-utils';\nimport { join, relative, parse } from 'path';\nimport {\n clearInferSpecCache,\n copyReactAssets,\n demoAppName,\n getDemoAppUsage,\n getReactDocs,\n getUsage,\n} from './utils';\nimport { createReactPattern } from './react-creators';\nimport {\n ExtraJsImportNames,\n KsReactMeta,\n rendererMetaScriptTagId,\n} from './types';\n\nconst { pkg } = findUpPkgJson(__dirname);\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nlog.setupUpdateNotifier({ ...pkg, name: pkg.name!, version: pkg.version! });\n\nconst errorCatcherAbsolutePath = join(__dirname, './error-catcher.mjs');\nif (!fileExists(errorCatcherAbsolutePath)) {\n throw new Error(\n `Could not find error catcher at: ${errorCatcherAbsolutePath}`,\n );\n}\n\nexport class KnapsackReactRenderer\n extends RendererWebpackBase\n implements Renderable\n{\n /**\n * `react.js` & `react-dom.js` root relative paths\n */\n assets: string[];\n babelConfig: Record<string, unknown>;\n #demoWrapperPath: string;\n #disableReactStrictMode?: boolean;\n\n constructor({\n webpackConfig,\n demoWrapperPath = join(__dirname, './demo-wrapper.mjs'),\n id = rendererIds.react,\n disableReactStrictMode,\n }: {\n webpackConfig?: ConstructorParameters<\n typeof RendererWebpackBase\n >[0]['webpackConfig'];\n demoWrapperPath?: string;\n /** When using React v18+, this option allows a workspace to _disable_ React's Strict Mode from running in Knapsack's React Renderer (StrictMode is enabled by default).\n *\n * See https://reactjs.org/docs/strict-mode.html for more info\n * */\n disableReactStrictMode?: boolean;\n /** Don't set if calling from `knapsack.config.js`, only use if creating a new Renderer based on the React Renderer */\n id?: RendererId;\n } = {}) {\n super({\n id,\n language: 'jsx',\n webpackConfig,\n extraScripts: [\n // this is the code in `./client/init.mts`\n '@knapsack/renderer-react/client',\n ],\n });\n this.language = 'jsx';\n this.assets = [];\n this.#demoWrapperPath = demoWrapperPath;\n this.#disableReactStrictMode = disableReactStrictMode;\n this.creators = [createReactPattern];\n }\n\n override setConfig: Renderer['setConfig'] = (opt) => {\n super.setConfig(opt);\n const {\n absolutePath,\n exists: demoWrapperPathExists,\n type,\n } = this.resolvePathSync({\n path: this.#demoWrapperPath,\n resolveFromDir: this.userConfigDir,\n });\n if (!demoWrapperPathExists) {\n throw new Error(\n `Could not find demo wrapper at: \"${\n this.#demoWrapperPath\n }\"\\nPlease adjust setting in \"knapsack.config.js\" or pass a different path when creating the React Renderer.`,\n );\n }\n this.registerExtraJsImports<ExtraJsImportNames>({\n DemoWrapper: {\n exportName: 'DemoWrapper',\n isDefaultExport: true,\n path: type === 'package' ? this.#demoWrapperPath : absolutePath,\n },\n ErrorCatcher: {\n exportName: 'ErrorCatcher',\n isDefaultExport: true,\n path: errorCatcherAbsolutePath,\n },\n });\n };\n\n init: Renderer['init'] = async () => {\n this.assets = await copyReactAssets(this.outputDir, this.publicPath);\n };\n\n override hydrate: Renderer['hydrate'] = async (opt) => {\n await super.hydrate(opt);\n await this.init({ missingFileVerbosity: 'silent' });\n };\n\n getMeta: Renderer['getMeta'] = () => ({\n id: this.id,\n title: 'React',\n aliasUse: 'optional',\n aliasTitle: 'Named Export',\n aliasIsJsNamedExport: true,\n aliasDescription:\n 'If `export X` was used instead of `export default`, then provide X.',\n enableDataDemos: true,\n enableTemplateDemos: true,\n hasSlotsSupport: true,\n hasSlotOptionsSupport: true,\n version: pkg.version,\n hasInferSpecSupport: true,\n syntaxHighlightingLanguage: 'jsx',\n hasTemplateSuggestionsSupport: true,\n prototypingTemplate: {\n path: '@knapsack/renderer-react/prototype-template',\n spec: {\n isInferred: false,\n props: {\n type: 'object',\n properties: {},\n },\n slots: {\n children: { title: 'Children' },\n },\n },\n },\n });\n\n override changeCase: Renderer['changeCase'] = (str) => pascalCase(str);\n\n override createWebpackConfig: RendererWebpackBase['createWebpackConfig'] =\n () => {\n const config = super.createWebpackConfig();\n\n config.externals = {\n react: 'React',\n 'react-dom': 'ReactDOM',\n };\n\n return config;\n };\n\n async prepClientRenderResults({\n usage,\n demoApp,\n importMap,\n renderOptions: { demo, state, patternId, templateId },\n }: {\n usage: string;\n demoApp: string;\n importMap: KsJsImportMap;\n renderOptions: Parameters<Renderer['render']>[0];\n }): ReturnType<Renderer['render']> {\n const meta = {\n demo,\n disableReactStrictMode: this.#disableReactStrictMode,\n neededImportsByCodeSrcId:\n convertImportMapToNeededImportsByCodeSrcId(importMap),\n demoWrapperProps: {\n patternId,\n templateId,\n demo,\n },\n } as const satisfies KsReactMeta;\n\n let code = `\n window.knapsack = window.knapsack || {};\n window.knapsack.getDemoApp = ({ ${[...importMap.keys()].join(', ')} }) => {\n ${demoApp}\n return ${demoAppName}\n }\n `;\n\n let errorHtmlMsg = '';\n try {\n code = await babelCodeForBrowser({ code });\n } catch (e) {\n console.log(code);\n console.log('---original code before babel error ^---');\n console.trace(e.message);\n code = `console.error(${JSON.stringify(e.message)});`;\n errorHtmlMsg = `<pre><code>${e.message}</code></pre>`;\n }\n\n const html = `\n <script type=\"application/json\" id=\"${rendererMetaScriptTagId}\">${JSON.stringify(\n meta,\n )}</script>\n <script type=\"application/javascript\">${code}</script>\n <div id=\"render-root\" class=\"knapsack-pattern-direct-parent\" data-dev-note=\"Knapsack React Template Wrapper\"></div>\n ${this.assets.map((asset) => `<script src=\"${asset}\"></script>`).join('\\n')}\n ${RendererWebpackBase.createHtmlTagsForAssetPaths({\n assets: this.getWebpackAssetPaths(),\n // we need the scripts to finish adding methods to the global knapsack object synchronously before the client-side code runs that is in the <script> tag below\n scriptTagsAreAsync: false,\n })}\n ${errorHtmlMsg}\n `;\n\n return {\n ok: !errorHtmlMsg,\n html: await formatCode({\n contents: html,\n path: 'x.html', // doing this to set format language\n }),\n usage,\n templateLanguage: this.language,\n };\n }\n\n render: Renderer['render'] = async (opt) => {\n if (opt.demo?.type === 'template') {\n // when getting a template demos path sometimes we have a race condition where the client asks for it before the server knows about it.\n // so we try several times in a row to get it\n /** The amount of time in ms to wait between attempts; when we run out of array items, we give up and throw the error */\n const waits = [5, 10, 20, 50, 100, 1000, 1000];\n let templateDemoPath: string;\n let attempt = 0;\n\n while (true) {\n try {\n const { absolutePath, exists } = await this.resolvePath(\n opt.demo.templateInfo.path,\n );\n if (!exists) {\n throw new Error(\n `Template demo file does not exist: ${absolutePath}`,\n );\n }\n templateDemoPath = absolutePath;\n // got it!\n break;\n } catch (e) {\n const waitTime = waits[attempt];\n if (!waitTime) {\n throw new Error(e);\n }\n attempt += 1;\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTime);\n }\n }\n const [templateFileContents, { usage, importMap }] = await Promise.all([\n readFile(templateDemoPath),\n this.getUsageAndImports({\n ...opt,\n importMap: new Map(),\n }),\n ]);\n const demoApp = await getDemoAppUsage({\n children: usage,\n });\n const results = await this.prepClientRenderResults({\n usage: templateFileContents,\n demoApp,\n renderOptions: opt,\n importMap,\n });\n\n return results;\n }\n\n if (opt.demo?.type === 'data') {\n const { usage, importMap } = await this.getUsageAndImports({\n ...opt,\n importMap: new Map(),\n });\n const importCode = RendererWebpackBase.createJsImportCodeBlock({\n importMap,\n });\n const [demoAppUsage, demoApp] = await Promise.all([\n getDemoAppUsage({\n children: usage,\n imports: importCode,\n format: true,\n }),\n getDemoAppUsage({\n children: usage,\n }),\n ]);\n\n return this.prepClientRenderResults({\n demoApp,\n usage: demoAppUsage,\n renderOptions: opt,\n importMap,\n });\n }\n };\n\n getUsageAndImports: RendererWebpackBase['getUsageAndImports'] = async ({\n patternId,\n templateId,\n demo,\n state,\n importMap,\n }) => {\n if (!demo) {\n throw new Error(\n `No demo provided while rendering ${patternId} ${templateId}`,\n );\n }\n const pattern = state.patterns[patternId];\n if (!pattern) {\n throw new Error(`Could not find pattern: ${patternId}`);\n }\n if (demo.type === 'data') {\n const template = pattern.templates.find((t) => t.id === templateId);\n if (!template) {\n throw new Error(`Could not find template: ${templateId}`);\n }\n const {\n data: { props, slots, slotsOptionsComputed },\n } = demo;\n const { name: templateName } = await this.addUniqueValueToImportMap({\n importMap,\n path: template.path,\n alias: template.alias || 'default',\n });\n\n const children: string[] = [];\n const extraProps: { key: string; value: string }[] = [];\n\n if (slots) {\n const slotNames = Object.keys(slots);\n const slotUsages = await Promise.all(\n slotNames.map(async (slotName) => {\n const slotItems = slots[slotName];\n const slotItemsUsages = await Promise.all(\n slotItems\n // remove any incomplete item - happens when users are filling out form\n .filter((slotItem) => {\n if (!slotItem) return false;\n if (slotItem.type !== 'text') {\n if (!slotItem.patternId) return false;\n if (!slotItem.templateId) return false;\n if (slotItem.type === 'template-demo' && !slotItem.demoId) {\n return false;\n }\n }\n return true;\n })\n .map(async (slotItem) => {\n if (slotItem.type === 'text') {\n if (slotItems.length === 1 && slotName !== 'children') {\n // The ` prevents multi-line strings from causing error (even though they don't show a line break)\n return `\\`${slotItem.text}\\``;\n }\n return slotItem.text;\n }\n if (slotItem.type === 'template-reference') {\n const slottedTemplate = state.patterns[\n slotItem.patternId\n ]?.templates.find((t) => t.id === slotItem.templateId);\n if (!slottedTemplate) {\n throw new Error(\n `Could not find slotted template: ${slotItem.patternId} ${slotItem.templateId}`,\n );\n }\n const templateRefImport =\n await this.addUniqueValueToImportMap({\n importMap,\n path: slottedTemplate.path,\n alias: slottedTemplate.alias || 'default',\n });\n /**\n * i.e. Given a React Component, `Button`, normally this would be `<Button>` with a demo, but since there is none this will just be a reference to it: `Button`\n * @see {KsSlotInfo['isTemplateReference']}\n * @see {SlottedTemplate}\n */\n return templateRefImport.name;\n }\n if (slotItem.type === 'template-demo') {\n const thisDemo = slotItem.demo;\n if (!thisDemo) {\n throw new Error(\n `Could not find slotted template demo ${JSON.stringify(\n slotItem,\n )}`,\n );\n }\n const { usage } = await this.getUsageAndImports({\n patternId: thisDemo.patternId,\n templateId: thisDemo.templateId,\n demo: thisDemo,\n state,\n importMap,\n });\n return usage;\n }\n const _exhaustiveCheck: never = slotItem;\n throw new Error(\n `Unknown slot item: ${JSON.stringify(slotItem)}`,\n );\n }),\n );\n return {\n slotName,\n slotItemsUsages,\n };\n }),\n );\n\n slotUsages.forEach(({ slotName, slotItemsUsages }) => {\n const slotOptionsComputed = slotsOptionsComputed?.[slotName];\n const { openTag, closeTag } = createSlotOptionsHtmlTags({\n slotOptionsComputed,\n classAttributeName: 'className',\n stylesValueType: 'object',\n });\n if (openTag) {\n if (slotName === 'children') {\n children.push(openTag);\n } else {\n extraProps.push({\n key: slotName,\n value: openTag,\n });\n }\n }\n\n slotItemsUsages.forEach((usage) => {\n if (slotName === 'children') {\n children.push(usage);\n } else {\n extraProps.push({\n key: slotName,\n value: usage,\n });\n }\n });\n\n if (closeTag) {\n if (slotName === 'children') {\n children.push(closeTag);\n } else {\n extraProps.push({\n key: slotName,\n value: closeTag,\n });\n }\n }\n });\n }\n\n const usage = await getUsage({\n templateName,\n props,\n children: children.join('\\n'),\n extraProps,\n });\n\n return {\n usage,\n importMap,\n };\n }\n\n if (demo.type === 'template') {\n const { templateInfo } = demo;\n const { name: templateName } = await this.addUniqueValueToImportMap({\n importMap,\n path: templateInfo.path,\n alias: templateInfo.alias || 'default',\n });\n const usage = await getUsage({ templateName });\n\n return {\n usage,\n importMap,\n };\n }\n\n const _exhaustiveCheck: never = demo;\n throw new Error(\n `Unhandled demo type for ${patternId}-${templateId}: ${JSON.stringify(\n demo,\n )}`,\n );\n };\n\n inferSpec: Renderer['inferSpec'] = async ({\n template,\n templatePath,\n }: {\n template: KnapsackPatternTemplate;\n templatePath: string;\n }): Promise<KsTemplateSpec | false> => {\n const spec = await getReactDocs({\n src: template.path,\n exportName: template.alias || 'default',\n resolveFromDir: this.config.data,\n });\n if (spec !== false) {\n const totalProps = Object.keys(spec?.props?.properties || {}).length;\n const totalSlots = Object.keys(spec?.slots || {}).length;\n if (totalProps === 0 && totalSlots === 0) {\n return false;\n }\n }\n return spec;\n };\n\n override watch: Renderer['watch'] = async () => {\n super.watch();\n knapsackEvents.onPatternTemplateChanged(() => {\n clearInferSpecCache();\n });\n };\n\n getTemplateMeta: Renderer['getTemplateMeta'] = async ({\n pattern,\n template,\n }) => {\n const files: KnapsackFile[] = [];\n if (template?.spec?.props) {\n const schema = JSON.parse(JSON.stringify(template.spec.props));\n if (template?.spec?.slots) {\n Object.entries(template.spec.slots).forEach(([id, info]) => {\n schema.properties[id] = {\n typeof: 'function',\n tsType: 'React.ReactNode',\n\n description: info.allowedPatternIds\n ? `${info.description}. Only use: ${info.allowedPatternIds.join(\n ', ',\n )}`\n : info.description,\n };\n schema.required = schema.required ?? [];\n if (info.isRequired) schema.required.push(id);\n });\n }\n const typeDefs =\n await KnapsackReactRenderer.convertSchemaToTypeScriptDefs({\n schema,\n title: `${this.changeCase(pattern.id)}Props`,\n // @todo pull in base url\n description: `[Knapsack Docs](http://localhost:3999/pattern/${pattern.id}/${template.id})`,\n patternId: pattern.id,\n templateId: template.id,\n postBanner: `import * as React from 'react';`,\n });\n\n files.push({\n contents: typeDefs,\n encoding: 'utf8',\n path: `${pattern.id}.${template.id}.spec.d.ts`,\n });\n files.push({\n contents: JSON.stringify(schema, null, ' '),\n encoding: 'utf8',\n path: `${pattern.id}.${template.id}.spec.json`,\n });\n }\n return files;\n };\n\n alterTemplateMetaFiles: Renderer['alterTemplateMetaFiles'] = async ({\n files,\n metaDir,\n }) => {\n const imports: string[] = [];\n\n const ext = '.spec.d.ts';\n files.forEach((file) => {\n if (file.path.endsWith(ext)) {\n const { base } = parse(file.path);\n const [patternId, templateId] = base.split('.');\n const isFirst = templateId === this.id;\n const exportName = this.changeCase(`${patternId}Props`);\n const exportNameWithTemplateId = this.changeCase(\n `${patternId}-${templateId}Props`,\n );\n imports.push(\n `export { ${\n isFirst\n ? exportName\n : `${exportName} as ${exportNameWithTemplateId}`\n } } from './${relative(metaDir, file.path).replace('.d.ts', '')}';`,\n );\n }\n });\n\n // extra line at end of file\n imports.push('');\n\n return [\n ...files,\n {\n contents: imports.join('\\n'),\n encoding: 'utf8',\n path: join(metaDir, 'react.d.ts'),\n },\n ];\n };\n\n getTemplateSuggestions: Renderer['getTemplateSuggestions'] = async ({\n newPath,\n state,\n }) => {\n // Deduplicate suggestions using Map with stringified path/alias as keys.\n // Map values are suggestion objects, Array.from(map.values()) returns deduplicated array.\n const usedSuggestions = Array.from(\n new Map(\n Object.values(state.patterns).reduce(\n (acc, { templateDemos, templates }) => {\n templates.forEach(({ path, alias, templateLanguageId }) => {\n if (templateLanguageId !== this.id) return;\n acc.push([JSON.stringify({ path, alias }), { path, alias }]);\n });\n templateDemos.forEach(\n ({ templateInfo: { path, alias }, templateLanguageId }) => {\n if (templateLanguageId !== this.id) return;\n acc.push([JSON.stringify({ path, alias }), { path, alias }]);\n },\n );\n return acc;\n },\n [] as [string, TemplateSuggestion][],\n ),\n ).values(),\n );\n\n const codeSrcs = new Set(this.getCodeSrcs().map(({ path }) => path));\n\n const allPaths = [\n ...new Set([\n newPath,\n ...Object.keys(this.pkgPathAliases || {}),\n ...codeSrcs,\n ]),\n ];\n const allSuggestions: TemplateSuggestion[] = await Promise.all(\n allPaths.map(async (path): Promise<TemplateSuggestion[]> => {\n if (!path) return [];\n try {\n const { exports, errorMsg } = await getJsExportNames({\n path,\n resolveFromDir: this.dataDir,\n pkgPathAliases: this.pkgPathAliases,\n });\n if (errorMsg) {\n throw new Error(errorMsg);\n }\n return (\n exports\n // only allow names that start with a capital letter (i.e. React Component names)\n // will exclude helper functions and custom hooks\n .filter((e) => e === 'default' || isFirstLetterCapital(e))\n .map((name) => ({\n alias: name,\n path,\n }))\n );\n } catch (e) {\n // only want this showing with verbose since template suggestions are not critical\n log.verbose(\n `Error getting import names for ${path}: ${e.message}`,\n null,\n this.logPrefix,\n );\n return [];\n }\n }),\n ).then((results) => {\n // sadly `Promise.all` & `.flatMap` just don't work, so this:\n return results.flat();\n });\n\n const suggestions = allSuggestions.filter((s) => {\n return !usedSuggestions.find(\n (us) => us.alias === s.alias && us.path === s.path,\n );\n });\n const connectedSuggestions = usedSuggestions.map((s) => ({\n ...s,\n connected: true,\n }));\n\n return {\n suggestions: [...suggestions, ...connectedSuggestions],\n };\n };\n}\n"]}
@@ -1,7 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- declare const PrototypeWrapper: ({ children }: {
4
- children: ReactNode;
5
- }) => ReactNode;
6
-
7
- export { PrototypeWrapper as default };
@@ -1,7 +0,0 @@
1
- import { ReactNode } from 'react';
2
-
3
- declare const PrototypeWrapper: ({ children }: {
4
- children: ReactNode;
5
- }) => ReactNode;
6
-
7
- export { PrototypeWrapper as default };
@@ -1,2 +0,0 @@
1
- 'use strict';var r=Object.defineProperty;var t=(e,o)=>r(e,"name",{value:o,configurable:!0});var p=t(({children:e})=>e,"PrototypeWrapper"),c=p;module.exports=c;//# sourceMappingURL=prototype-template.js.map
2
- //# sourceMappingURL=prototype-template.js.map