@knapsack/renderer-react 4.67.0--canary.5f03d3b.0 → 4.67.0--canary.4438.d153c90.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,86 @@
1
+ # v4.66.11 (Tue Jul 30 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - additional angular renderer improvements [#4395](https://github.com/knapsack-labs/app-monorepo/pull/4395) ([@mabry1985](https://github.com/mabry1985))
6
+ - Merge branch 'latest' into feature/ksp-5310-angular-improvements-redux ([@mabry1985](https://github.com/mabry1985))
7
+
8
+ #### 🏠 Internal
9
+
10
+ - KSP-5320: arbitrary classes field for slot options [#4402](https://github.com/knapsack-labs/app-monorepo/pull/4402) ([@illepic](https://github.com/illepic) [@EvanLovely](https://github.com/EvanLovely))
11
+
12
+ #### Authors: 3
13
+
14
+ - Christopher Bloom ([@illepic](https://github.com/illepic))
15
+ - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
16
+ - Josh Mabry ([@mabry1985](https://github.com/mabry1985))
17
+
18
+ ---
19
+
20
+ # v4.66.8 (Fri Jul 26 2024)
21
+
22
+ #### 🐛 Bug Fix
23
+
24
+ - fix bug where code usage block creates invalid HTML [#4390](https://github.com/knapsack-labs/app-monorepo/pull/4390) ([@EvanLovely](https://github.com/EvanLovely))
25
+
26
+ #### 🏠 Internal
27
+
28
+ - make types for `slotsOptions` and add Renderer support [#4389](https://github.com/knapsack-labs/app-monorepo/pull/4389) ([@EvanLovely](https://github.com/EvanLovely))
29
+
30
+ #### Authors: 1
31
+
32
+ - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
33
+
34
+ ---
35
+
36
+ # v4.66.7 (Tue Jul 23 2024)
37
+
38
+ #### 🐛 Bug Fix
39
+
40
+ - fix page content not saving when there are duplicate IDs [#4381](https://github.com/knapsack-labs/app-monorepo/pull/4381) ([@EvanLovely](https://github.com/EvanLovely))
41
+
42
+ #### Authors: 1
43
+
44
+ - Evan Lovely ([@EvanLovely](https://github.com/EvanLovely))
45
+
46
+ ---
47
+
48
+ # v4.66.6 (Mon Jul 22 2024)
49
+
50
+ #### 🐛 Bug Fix
51
+
52
+ - Merge branch 'latest' into feature/async-loading-buttons ([@GormanDesign](https://github.com/GormanDesign))
53
+
54
+ #### Authors: 1
55
+
56
+ - Matt Gorman ([@GormanDesign](https://github.com/GormanDesign))
57
+
58
+ ---
59
+
60
+ # v4.66.5 (Fri Jul 19 2024)
61
+
62
+ #### 🏠 Internal
63
+
64
+ - update token import replace existing language [#4375](https://github.com/knapsack-labs/app-monorepo/pull/4375) ([@GormanDesign](https://github.com/GormanDesign))
65
+
66
+ #### Authors: 1
67
+
68
+ - Matt Gorman ([@GormanDesign](https://github.com/GormanDesign))
69
+
70
+ ---
71
+
72
+ # v4.66.4 (Fri Jul 19 2024)
73
+
74
+ #### 🏠 Internal
75
+
76
+ - update ReactMarkdown to latest version [#4369](https://github.com/knapsack-labs/app-monorepo/pull/4369) ([@GormanDesign](https://github.com/GormanDesign))
77
+
78
+ #### Authors: 1
79
+
80
+ - Matt Gorman ([@GormanDesign](https://github.com/GormanDesign))
81
+
82
+ ---
83
+
1
84
  # v4.66.3 (Fri Jul 19 2024)
2
85
 
3
86
  #### 🐛 Bug Fix
package/dist/index.js CHANGED
@@ -71,9 +71,7 @@ function renderDemoAppTemplate({
71
71
 
72
72
  function DemoApp() {
73
73
  return (
74
- <div className="demo-app knapsack-pattern-direct-parent">
75
- ${children}
76
- </div>
74
+ ${children}
77
75
  )
78
76
  }
79
77
  `;
@@ -731,6 +729,7 @@ var createReactPattern = (0, import_creator_utils.createCreator)({
731
729
  // src/renderer-react.ts
732
730
  var { pkg } = (0, import_file_utils3.findUpPkgJson)(__dirname);
733
731
  import_app2.log.setupUpdateNotifier({ ...pkg, name: pkg.name, version: pkg.version });
732
+ var { createSlotOptionsHtmlTags } = import_app2.KnapsackRendererBase;
734
733
  var KnapsackReactRenderer = class _KnapsackReactRenderer extends import_renderer_webpack_base.KnapsackRendererWebpackBase {
735
734
  static {
736
735
  __name(this, "KnapsackReactRenderer");
@@ -780,6 +779,7 @@ var KnapsackReactRenderer = class _KnapsackReactRenderer extends import_renderer
780
779
  enableDataDemos: true,
781
780
  enableTemplateDemos: true,
782
781
  hasSlotsSupport: true,
782
+ hasSlotOptionsSupport: true,
783
783
  version: pkg.version,
784
784
  hasInferSpecSupport: true,
785
785
  syntaxHighlightingLanguage: "jsx",
@@ -1070,7 +1070,7 @@ ${errorHtmlMsg}
1070
1070
  const { pattern, template, patternManifest, demo } = opt;
1071
1071
  if (demo?.type && _KnapsackReactRenderer.isDataDemo(demo)) {
1072
1072
  const {
1073
- data: { props, slots }
1073
+ data: { props, slots, slotsOptionsComputed }
1074
1074
  } = demo;
1075
1075
  const importInfo = this.getJsImport({
1076
1076
  patternId: pattern.id,
@@ -1090,7 +1090,7 @@ ${errorHtmlMsg}
1090
1090
  const slotUsages = await Promise.all(
1091
1091
  slotNames.map(async (slotName) => {
1092
1092
  const slotItems = slots[slotName];
1093
- const usages = await Promise.all(
1093
+ const slotItemsUsages = await Promise.all(
1094
1094
  slotItems.filter((slotItem) => {
1095
1095
  if (!(0, import_types2.isSlottedText)(slotItem)) {
1096
1096
  if (!slotItem.patternId)
@@ -1141,12 +1141,28 @@ ${errorHtmlMsg}
1141
1141
  );
1142
1142
  return {
1143
1143
  slotName,
1144
- usages
1144
+ slotItemsUsages
1145
1145
  };
1146
1146
  })
1147
1147
  );
1148
- slotUsages.forEach(({ slotName, usages }) => {
1149
- usages.forEach((usage2) => {
1148
+ slotUsages.forEach(({ slotName, slotItemsUsages }) => {
1149
+ const slotOptionsComputed = slotsOptionsComputed?.[slotName];
1150
+ const { openTag, closeTag } = createSlotOptionsHtmlTags({
1151
+ slotOptionsComputed,
1152
+ classAttributeName: "className",
1153
+ stylesValueType: "object"
1154
+ });
1155
+ if (openTag) {
1156
+ if (slotName === "children") {
1157
+ children.push(openTag);
1158
+ } else {
1159
+ extraProps.push({
1160
+ key: slotName,
1161
+ value: openTag
1162
+ });
1163
+ }
1164
+ }
1165
+ slotItemsUsages.forEach((usage2) => {
1150
1166
  if (slotName === "children") {
1151
1167
  children.push(usage2);
1152
1168
  } else {
@@ -1156,6 +1172,16 @@ ${errorHtmlMsg}
1156
1172
  });
1157
1173
  }
1158
1174
  });
1175
+ if (closeTag) {
1176
+ if (slotName === "children") {
1177
+ children.push(closeTag);
1178
+ } else {
1179
+ extraProps.push({
1180
+ key: slotName,
1181
+ value: closeTag
1182
+ });
1183
+ }
1184
+ }
1159
1185
  });
1160
1186
  }
1161
1187
  const usage = await getUsage({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/renderer-react.ts","../src/utils.ts","../src/react-creators.ts"],"sourcesContent":["export * from './renderer-react';\n","import sleep from 'sleep-promise';\nimport { KnapsackRendererWebpackBase } from '@knapsack/renderer-webpack-base';\nimport {\n pascalCase,\n Except,\n isFirstLetterCapital,\n isObject,\n} from '@knapsack/utils';\nimport { knapsackEvents, log } from '@knapsack/app';\nimport {\n KsRendererClientGlobal,\n KnapsackFile,\n KsJsImport,\n isSlottedText,\n isSlottedTemplateReference,\n isSlottedTemplateDemo,\n KnapsackPatternTemplate,\n KsTemplateSpec,\n TemplateSuggestion,\n rendererIds,\n RendererId,\n} from '@knapsack/types';\nimport type {\n KnapsackRenderParams,\n KnapsackTemplateRenderer,\n KnapsackTemplateRendererBase,\n KnapsackTemplateRendererResults,\n Patterns,\n} from '@knapsack/app/types';\nimport {\n exists,\n findUpPkgJson,\n getJsExportNames,\n readFile,\n formatCode,\n} from '@knapsack/file-utils';\nimport type { ReactNode } from 'react';\nimport { join, relative, parse } from 'path';\nimport {\n clearInferSpecCache,\n copyReactAssets,\n getDemoAppUsage,\n getReactDocs,\n getUsage,\n} from './utils';\nimport { createReactPattern } from './react-creators';\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\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[];\n} & Except<KnapsackRenderParams, 'patternManifest'>;\n\nexport class KnapsackReactRenderer\n extends KnapsackRendererWebpackBase\n implements KnapsackTemplateRenderer\n{\n /**\n * `react.js` & `react-dom.js` root relative paths\n */\n assets: string[];\n babelConfig: Record<string, unknown>;\n creators: KnapsackTemplateRenderer['creators'];\n private demoWrapperPath: string;\n\n private 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 KnapsackRendererWebpackBase\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 extension: '.jsx',\n language: 'jsx',\n webpackConfig,\n });\n this.language = 'jsx';\n this.assets = [];\n this.demoWrapperPath = demoWrapperPath;\n\n // Half-borrowing the API Synax for this from the latest version of Next.js\n this.disableReactStrictMode = disableReactStrictMode;\n this.creators = [createReactPattern];\n }\n\n async init(opt: { patterns: Patterns; cacheDir: string }): Promise<void> {\n await super.init(opt);\n this.assets = await copyReactAssets(this.outputDir, this.publicPath);\n if (!(await exists(this.demoWrapperPath))) {\n throw new Error(\n `Could not find demo wrapper at: \"${this.demoWrapperPath}\"`,\n );\n }\n }\n\n getMeta: KnapsackTemplateRenderer['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 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 changeCase(str: string): string {\n return pascalCase(str);\n }\n\n createWebpackConfig(): ReturnType<\n KnapsackRendererWebpackBase['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 getJsImports(): ReturnType<KnapsackRendererWebpackBase['getJsImports']> {\n const imports = super.getJsImports();\n imports.push(\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: this.demoWrapperPath,\n name: 'DemoWrapper',\n },\n },\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: join(__dirname, './error-catcher.mjs'),\n name: 'ErrorCatcher',\n },\n },\n );\n return imports;\n }\n\n async prepClientRenderResults({\n usage,\n demoApp,\n imports: xImports,\n renderOptions: { pattern, template, demo },\n }: {\n usage: string;\n demoApp: string;\n imports: KsJsImport[];\n renderOptions: KnapsackRenderParams;\n }): Promise<KnapsackTemplateRendererResults> {\n const extraImportNames = this.getJsImports().flatMap((imp) =>\n imp.type === 'extra' ? [imp.importInfo.name] : [],\n );\n const { imports, isDeclaredVarsUnique, nameCollisions } =\n this.makeKsJsImportsUnique({ imports: xImports });\n\n if (!isDeclaredVarsUnique) {\n log.error(`${nameCollisions.join(', ')} are declared multiple times`, {\n imports,\n });\n }\n\n // import names; i.e. `KsButton`\n const importNames = [\n ...imports.map(({ importInfo: { name } }) => name),\n ...extraImportNames,\n ];\n\n const patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[] = imports.flatMap((imp) => {\n if (imp.type === 'pattern-template') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n },\n ];\n }\n if (imp.type === 'pattern-template-demo') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n demoId: imp.demoId,\n },\n ];\n }\n return [];\n });\n\n const demoWrapperProps: Omit<DemoWrapperProps, 'children'> = {\n patternsUsed,\n pattern,\n template,\n demo,\n };\n const demoWrapperCode = await getUsage({\n templateName: 'DemoWrapper',\n props: demoWrapperProps,\n children: `<DemoApp />`,\n // extraProps,\n });\n\n /**\n * IMPORTANT: this function is stringified and then executed in the browser - it cannot use anything in scope (other functions, vars, etc)\n */\n async function renderReact({\n patterns,\n theExtraImportNames,\n ksGlobal,\n }: {\n patterns: typeof patternsUsed;\n theExtraImportNames: typeof extraImportNames;\n ksGlobal: KsRendererClientGlobal<ReactNode>;\n }): Promise<Record<string, ReactNode>> {\n if (!ksGlobal) {\n throw new Error('\"window.knapsack\" is null');\n }\n const components = await ksGlobal.getAllImports({\n patterns,\n extras: theExtraImportNames.map((name) => ({ name })),\n });\n return components;\n }\n\n let code = `\n\n${renderReact.toString()}\n${renderReact.name}({\n ksGlobal: window.knapsack,\n patterns: ${JSON.stringify(patternsUsed)},\n theExtraImportNames: ${JSON.stringify(extraImportNames)},\n}).then((components) => {\n const { ${importNames.join(', ')} } = components;\n const root = document.getElementById('render-root');\n\n ${demoApp}\n\n const reactDomVersion = parseInt(ReactDOM.version.split('.')[0], 10);\n\n const ReactRendererResult = () => {\n if (reactDomVersion < 17 || ${this.disableReactStrictMode}){\n return (\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n )\n }\n\n return (\n <React.StrictMode>\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n </React.StrictMode>\n )\n };\n\n\n if (reactDomVersion > 17){\n ReactDOM.createRoot(root).render(\n <ReactRendererResult />\n )\n } else {\n ReactDOM.render(\n <ReactRendererResult />,\n root\n );\n }\n}).catch((err) => {\n console.error(err);\n const root = document.getElementById('render-root');\n // Create a new <div> element to contain the error message\n const errorMsgDiv = document.createElement('div');\n // Insert the new <div> element before the existing element\n root.parentNode.insertBefore(errorMsgDiv, root);\n // add error message so users can see it\n errorMsgDiv.innerHTML = '<h1>Component Error</h1><p>' + err.message + '</p>';\n});\n `;\n\n let codeHadError = false;\n let errorHtmlMsg = '';\n\n try {\n code = await this.babelCodeForBrowser({\n code,\n });\n } catch (e) {\n codeHadError = true;\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 if (!codeHadError) {\n try {\n code = await formatCode({\n contents: code,\n path: 'x.tsx', // doing this to set format language\n });\n } catch (e) {\n codeHadError = true;\n console.log(code);\n console.log('---original code before prettier 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\n const html = `\n ${this.assets.map((asset) => `<script src=\"${asset}\"></script>`).join('\\n')}\n\n ${this.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\n <div id=\"render-root\" class=\"knapsack-pattern-direct-parent\" data-dev-note=\"Knapsack React Template Wrapper\"></div>\n <script type=\"application/javascript\">${code}</script>\n${errorHtmlMsg}\n\n `;\n\n return {\n ok: !codeHadError,\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 async render(\n opt: KnapsackRenderParams,\n ): Promise<KnapsackTemplateRendererResults> {\n if (KnapsackReactRenderer.isTemplateDemo(opt.demo)) {\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 templateDemoPath = opt.patternManifest.getTemplateDemoAbsolutePath({\n patternId: opt.pattern.id,\n templateId: opt.template.id,\n demoId: opt.demo.id,\n });\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\n const [templateFileContents, { usage, imports }] = await Promise.all([\n readFile(templateDemoPath),\n this.getUsageAndImports(opt),\n ]);\n const demoApp = await getDemoAppUsage({\n children: usage,\n });\n const results = await this.prepClientRenderResults({\n usage: templateFileContents,\n demoApp,\n imports,\n renderOptions: opt,\n });\n\n return results;\n }\n\n if (KnapsackReactRenderer.isDataDemo(opt.demo)) {\n const { usage, imports } = await this.getUsageAndImports(opt);\n const { code: importCode } = this.createJsImportCodeBlock({\n imports,\n });\n\n const [demoAppUsage, demoApp] = await Promise.all([\n getDemoAppUsage({\n children: usage,\n imports: importCode,\n }),\n getDemoAppUsage({\n children: usage,\n }),\n ]);\n\n return this.prepClientRenderResults({\n demoApp,\n usage: demoAppUsage,\n imports,\n renderOptions: opt,\n });\n }\n }\n\n async getUsageAndImports(opt: KnapsackRenderParams): Promise<{\n usage: string;\n imports: KsJsImport[];\n }> {\n const { pattern, template, patternManifest, demo } = opt;\n if (demo?.type && KnapsackReactRenderer.isDataDemo(demo)) {\n const {\n data: { props, slots },\n } = demo;\n\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const importInfos: KsJsImport[] = [importInfo];\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 usages = await Promise.all(\n slotItems\n // remove any incomplete item - happens when users are filling out form\n .filter((slotItem) => {\n if (!isSlottedText(slotItem)) {\n if (!slotItem.patternId) return false;\n if (!slotItem.templateId) return false;\n if (isSlottedTemplateDemo(slotItem) && !slotItem.demoId) {\n return false;\n }\n }\n return true;\n })\n .map(async (slotItem) => {\n if (isSlottedText(slotItem)) {\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\n const slotPattern = patternManifest.getPattern(\n slotItem.patternId,\n );\n\n const slotTemplate = slotPattern.templates.find(\n (t) => t.id === slotItem.templateId,\n );\n if (isSlottedTemplateReference(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n if (isSlottedTemplateDemo(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n demo:\n slotItem.demo ||\n this.patterns.demosById[slotItem.demoId],\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n\n throw new Error(\n `Unknown slot item: ${JSON.stringify(slotItem)}`,\n );\n }),\n );\n return {\n slotName,\n usages,\n };\n }),\n );\n\n slotUsages.forEach(({ slotName, usages }) => {\n usages.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 }\n\n const usage = await getUsage({\n templateName,\n props,\n children: children.join('\\n'),\n extraProps,\n });\n\n return {\n usage,\n imports: importInfos,\n };\n }\n\n if (demo?.type && KnapsackReactRenderer.isTemplateDemo(demo)) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n demoId: demo.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template-demo: ${pattern.id}-${template.id}-${demo.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const usage = await getUsage({ templateName });\n\n return {\n usage,\n imports: [importInfo],\n };\n }\n\n if (!demo) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n return {\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 usage: templateName,\n imports: [importInfo],\n };\n }\n\n throw new Error(\n `Unhandled demo type for ${pattern.id}-${template.id}: ${JSON.stringify(\n demo,\n )}`,\n );\n }\n\n async getUsage(opt: KnapsackRenderParams): Promise<string> {\n const { usage } = await this.getUsageAndImports(opt);\n return usage;\n }\n\n inferSpec: KnapsackTemplateRendererBase['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 async watch(opt: Parameters<KnapsackTemplateRendererBase['watch']>[0]) {\n await super.watch(opt);\n knapsackEvents.onPatternTemplateChanged(() => {\n clearInferSpecCache();\n });\n }\n\n getTemplateMeta: KnapsackTemplateRendererBase['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: KnapsackTemplateRendererBase['alterTemplateMetaFiles'] =\n async ({ files, metaDir }) => {\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 async getTemplateSuggestions({\n newPath,\n }: Parameters<\n KnapsackTemplateRendererBase['getTemplateSuggestions']\n >[0]): ReturnType<KnapsackTemplateRendererBase['getTemplateSuggestions']> {\n const { data: dataDir } = this.patterns.userConfig;\n const { allTemplateDemos, allTemplates } = this.getMyTemplates();\n const usedSuggestions: TemplateSuggestion[] = [\n ...allTemplateDemos,\n ...allTemplates,\n ].map(({ path, alias }) => {\n return {\n path,\n alias: alias || 'default',\n };\n });\n\n const allPaths = [\n ...new Set([newPath, ...usedSuggestions.map(({ path }) => path)]),\n ];\n const {\n resolve: { alias },\n } = this.createWebpackConfig();\n const aliasConfig: Record<string, string> = {};\n if (isObject(alias)) {\n Object.entries(alias).forEach(([key, value]) => {\n if (typeof value === 'string') {\n aliasConfig[key] = value;\n }\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: dataDir,\n alias: aliasConfig,\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\n return {\n suggestions,\n };\n }\n}\n","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}\n\nfunction renderDemoAppTemplate({\n imports,\n children,\n}: {\n imports: string;\n children: string;\n}) {\n return `${imports}\n\nfunction DemoApp() {\n return (\n <div className=\"demo-app knapsack-pattern-direct-parent\">\n ${children}\n </div>\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}: {\n children: string;\n imports?: string;\n}): Promise<string> {\n const code = renderDemoAppTemplate({\n children,\n imports,\n });\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\n .map(({ value }) => removeWrappingDoubleQuotes(value?.trim()))\n .filter(Boolean),\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\n .split('|')\n .map((enumItem) => removeWrappingDoubleQuotes(enumItem.trim()))\n .filter(Boolean);\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',\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: { importNames } }) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;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AM,iBAAuC,MAAM,QAAQ;AAAA,MACzD,SAAS,IAAI,OAAOA,UAAwC;AAC1D,YAAI,CAACA;AAAM,iBAAO,CAAC;AACnB,YAAI;AACF,gBAAM,EAAE,SAAAE,UAAS,SAAS,IAAI,UAAM,qCAAiB;AAAA,YACnD,MAAAF;AAAA,YACA,gBAAgB;AAAA,YAChB,OAAO;AAAA,UACT,CAAC;AACD,cAAI,UAAU;AACZ,kBAAM,IAAI,MAAM,QAAQ;AAAA,UAC1B;AACA,iBACEE,SAGG,OAAO,CAAC,MAAM,MAAM,iBAAa,oCAAqB,CAAC,CAAC,EACxD,IAAI,CAAC,UAAU;AAAA,YACd,OAAO;AAAA,YACP,MAAAF;AAAA,UACF,EAAE;AAAA,QAER,SAAS,GAAG;AAEV,0BAAI;AAAA,YACF,kCAAkCA,KAAI,KAAK,EAAE,OAAO;AAAA,YACpD;AAAA,YACA,KAAK;AAAA,UACP;AACA,iBAAO,CAAC;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,EAAE,KAAK,CAAC,YAAY;AAElB,aAAO,QAAQ,KAAK;AAAA,IACtB,CAAC;AAED,UAAM,cAAc,eAAe,OAAO,CAAC,MAAM;AAC/C,aAAO,CAAC,gBAAgB;AAAA,QACtB,CAAC,OAAO,GAAG,UAAU,EAAE,SAAS,GAAG,SAAS,EAAE;AAAA,MAChD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":["import_utils","import_app","import_types","import_file_utils","import_path","path","parse","import_file_utils","import_utils","path","sleep","usage","path","alias","exports"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/renderer-react.ts","../src/utils.ts","../src/react-creators.ts"],"sourcesContent":["export * from './renderer-react';\n","import sleep from 'sleep-promise';\nimport { KnapsackRendererWebpackBase } from '@knapsack/renderer-webpack-base';\nimport {\n pascalCase,\n Except,\n isFirstLetterCapital,\n isObject,\n} from '@knapsack/utils';\nimport { knapsackEvents, log, KnapsackRendererBase } from '@knapsack/app';\nimport {\n KsRendererClientGlobal,\n KnapsackFile,\n KsJsImport,\n isSlottedText,\n isSlottedTemplateReference,\n isSlottedTemplateDemo,\n KnapsackPatternTemplate,\n KsTemplateSpec,\n TemplateSuggestion,\n rendererIds,\n RendererId,\n} from '@knapsack/types';\nimport type {\n KnapsackRenderParams,\n KnapsackTemplateRenderer,\n KnapsackTemplateRendererBase,\n KnapsackTemplateRendererResults,\n Patterns,\n} from '@knapsack/app/types';\nimport {\n exists,\n findUpPkgJson,\n getJsExportNames,\n readFile,\n formatCode,\n} from '@knapsack/file-utils';\nimport type { ReactNode } from 'react';\nimport { join, relative, parse } from 'path';\nimport {\n clearInferSpecCache,\n copyReactAssets,\n getDemoAppUsage,\n getReactDocs,\n getUsage,\n} from './utils';\nimport { createReactPattern } from './react-creators';\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\n// static methods only\nconst { createSlotOptionsHtmlTags } = KnapsackRendererBase;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[];\n} & Except<KnapsackRenderParams, 'patternManifest'>;\n\nexport class KnapsackReactRenderer\n extends KnapsackRendererWebpackBase\n implements KnapsackTemplateRenderer\n{\n /**\n * `react.js` & `react-dom.js` root relative paths\n */\n assets: string[];\n babelConfig: Record<string, unknown>;\n creators: KnapsackTemplateRenderer['creators'];\n private demoWrapperPath: string;\n\n private 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 KnapsackRendererWebpackBase\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 extension: '.jsx',\n language: 'jsx',\n webpackConfig,\n });\n this.language = 'jsx';\n this.assets = [];\n this.demoWrapperPath = demoWrapperPath;\n\n // Half-borrowing the API Synax for this from the latest version of Next.js\n this.disableReactStrictMode = disableReactStrictMode;\n this.creators = [createReactPattern];\n }\n\n async init(opt: { patterns: Patterns; cacheDir: string }): Promise<void> {\n await super.init(opt);\n this.assets = await copyReactAssets(this.outputDir, this.publicPath);\n if (!(await exists(this.demoWrapperPath))) {\n throw new Error(\n `Could not find demo wrapper at: \"${this.demoWrapperPath}\"`,\n );\n }\n }\n\n getMeta: KnapsackTemplateRenderer['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 changeCase(str: string): string {\n return pascalCase(str);\n }\n\n createWebpackConfig(): ReturnType<\n KnapsackRendererWebpackBase['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 getJsImports(): ReturnType<KnapsackRendererWebpackBase['getJsImports']> {\n const imports = super.getJsImports();\n imports.push(\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: this.demoWrapperPath,\n name: 'DemoWrapper',\n },\n },\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: join(__dirname, './error-catcher.mjs'),\n name: 'ErrorCatcher',\n },\n },\n );\n return imports;\n }\n\n async prepClientRenderResults({\n usage,\n demoApp,\n imports: xImports,\n renderOptions: { pattern, template, demo },\n }: {\n usage: string;\n demoApp: string;\n imports: KsJsImport[];\n renderOptions: KnapsackRenderParams;\n }): Promise<KnapsackTemplateRendererResults> {\n const extraImportNames = this.getJsImports().flatMap((imp) =>\n imp.type === 'extra' ? [imp.importInfo.name] : [],\n );\n const { imports, isDeclaredVarsUnique, nameCollisions } =\n this.makeKsJsImportsUnique({ imports: xImports });\n\n if (!isDeclaredVarsUnique) {\n log.error(`${nameCollisions.join(', ')} are declared multiple times`, {\n imports,\n });\n }\n\n // import names; i.e. `KsButton`\n const importNames = [\n ...imports.map(({ importInfo: { name } }) => name),\n ...extraImportNames,\n ];\n\n const patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[] = imports.flatMap((imp) => {\n if (imp.type === 'pattern-template') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n },\n ];\n }\n if (imp.type === 'pattern-template-demo') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n demoId: imp.demoId,\n },\n ];\n }\n return [];\n });\n\n const demoWrapperProps: Omit<DemoWrapperProps, 'children'> = {\n patternsUsed,\n pattern,\n template,\n demo,\n };\n const demoWrapperCode = await getUsage({\n templateName: 'DemoWrapper',\n props: demoWrapperProps,\n children: `<DemoApp />`,\n // extraProps,\n });\n\n /**\n * IMPORTANT: this function is stringified and then executed in the browser - it cannot use anything in scope (other functions, vars, etc)\n */\n async function renderReact({\n patterns,\n theExtraImportNames,\n ksGlobal,\n }: {\n patterns: typeof patternsUsed;\n theExtraImportNames: typeof extraImportNames;\n ksGlobal: KsRendererClientGlobal<ReactNode>;\n }): Promise<Record<string, ReactNode>> {\n if (!ksGlobal) {\n throw new Error('\"window.knapsack\" is null');\n }\n const components = await ksGlobal.getAllImports({\n patterns,\n extras: theExtraImportNames.map((name) => ({ name })),\n });\n return components;\n }\n\n let code = `\n\n${renderReact.toString()}\n${renderReact.name}({\n ksGlobal: window.knapsack,\n patterns: ${JSON.stringify(patternsUsed)},\n theExtraImportNames: ${JSON.stringify(extraImportNames)},\n}).then((components) => {\n const { ${importNames.join(', ')} } = components;\n const root = document.getElementById('render-root');\n\n ${demoApp}\n\n const reactDomVersion = parseInt(ReactDOM.version.split('.')[0], 10);\n\n const ReactRendererResult = () => {\n if (reactDomVersion < 17 || ${this.disableReactStrictMode}){\n return (\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n )\n }\n\n return (\n <React.StrictMode>\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n </React.StrictMode>\n )\n };\n\n\n if (reactDomVersion > 17){\n ReactDOM.createRoot(root).render(\n <ReactRendererResult />\n )\n } else {\n ReactDOM.render(\n <ReactRendererResult />,\n root\n );\n }\n}).catch((err) => {\n console.error(err);\n const root = document.getElementById('render-root');\n // Create a new <div> element to contain the error message\n const errorMsgDiv = document.createElement('div');\n // Insert the new <div> element before the existing element\n root.parentNode.insertBefore(errorMsgDiv, root);\n // add error message so users can see it\n errorMsgDiv.innerHTML = '<h1>Component Error</h1><p>' + err.message + '</p>';\n});\n `;\n\n let codeHadError = false;\n let errorHtmlMsg = '';\n\n try {\n code = await this.babelCodeForBrowser({\n code,\n });\n } catch (e) {\n codeHadError = true;\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 if (!codeHadError) {\n try {\n code = await formatCode({\n contents: code,\n path: 'x.tsx', // doing this to set format language\n });\n } catch (e) {\n codeHadError = true;\n console.log(code);\n console.log('---original code before prettier 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\n const html = `\n ${this.assets.map((asset) => `<script src=\"${asset}\"></script>`).join('\\n')}\n\n ${this.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\n <div id=\"render-root\" class=\"knapsack-pattern-direct-parent\" data-dev-note=\"Knapsack React Template Wrapper\"></div>\n <script type=\"application/javascript\">${code}</script>\n${errorHtmlMsg}\n\n `;\n\n return {\n ok: !codeHadError,\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 async render(\n opt: KnapsackRenderParams,\n ): Promise<KnapsackTemplateRendererResults> {\n if (KnapsackReactRenderer.isTemplateDemo(opt.demo)) {\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 templateDemoPath = opt.patternManifest.getTemplateDemoAbsolutePath({\n patternId: opt.pattern.id,\n templateId: opt.template.id,\n demoId: opt.demo.id,\n });\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\n const [templateFileContents, { usage, imports }] = await Promise.all([\n readFile(templateDemoPath),\n this.getUsageAndImports(opt),\n ]);\n const demoApp = await getDemoAppUsage({\n children: usage,\n });\n const results = await this.prepClientRenderResults({\n usage: templateFileContents,\n demoApp,\n imports,\n renderOptions: opt,\n });\n\n return results;\n }\n\n if (KnapsackReactRenderer.isDataDemo(opt.demo)) {\n const { usage, imports } = await this.getUsageAndImports(opt);\n const { code: importCode } = this.createJsImportCodeBlock({\n imports,\n });\n\n const [demoAppUsage, demoApp] = await Promise.all([\n getDemoAppUsage({\n children: usage,\n imports: importCode,\n }),\n getDemoAppUsage({\n children: usage,\n }),\n ]);\n\n return this.prepClientRenderResults({\n demoApp,\n usage: demoAppUsage,\n imports,\n renderOptions: opt,\n });\n }\n }\n\n async getUsageAndImports(opt: KnapsackRenderParams): Promise<{\n usage: string;\n imports: KsJsImport[];\n }> {\n const { pattern, template, patternManifest, demo } = opt;\n if (demo?.type && KnapsackReactRenderer.isDataDemo(demo)) {\n const {\n data: { props, slots, slotsOptionsComputed },\n } = demo;\n\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const importInfos: KsJsImport[] = [importInfo];\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 (!isSlottedText(slotItem)) {\n if (!slotItem.patternId) return false;\n if (!slotItem.templateId) return false;\n if (isSlottedTemplateDemo(slotItem) && !slotItem.demoId) {\n return false;\n }\n }\n return true;\n })\n .map(async (slotItem) => {\n if (isSlottedText(slotItem)) {\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\n const slotPattern = patternManifest.getPattern(\n slotItem.patternId,\n );\n\n const slotTemplate = slotPattern.templates.find(\n (t) => t.id === slotItem.templateId,\n );\n if (isSlottedTemplateReference(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n if (isSlottedTemplateDemo(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n demo:\n slotItem.demo ||\n this.patterns.demosById[slotItem.demoId],\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n\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 imports: importInfos,\n };\n }\n\n if (demo?.type && KnapsackReactRenderer.isTemplateDemo(demo)) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n demoId: demo.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template-demo: ${pattern.id}-${template.id}-${demo.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const usage = await getUsage({ templateName });\n\n return {\n usage,\n imports: [importInfo],\n };\n }\n\n if (!demo) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n return {\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 usage: templateName,\n imports: [importInfo],\n };\n }\n\n throw new Error(\n `Unhandled demo type for ${pattern.id}-${template.id}: ${JSON.stringify(\n demo,\n )}`,\n );\n }\n\n async getUsage(opt: KnapsackRenderParams): Promise<string> {\n const { usage } = await this.getUsageAndImports(opt);\n return usage;\n }\n\n inferSpec: KnapsackTemplateRendererBase['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 async watch(opt: Parameters<KnapsackTemplateRendererBase['watch']>[0]) {\n await super.watch(opt);\n knapsackEvents.onPatternTemplateChanged(() => {\n clearInferSpecCache();\n });\n }\n\n getTemplateMeta: KnapsackTemplateRendererBase['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: KnapsackTemplateRendererBase['alterTemplateMetaFiles'] =\n async ({ files, metaDir }) => {\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 async getTemplateSuggestions({\n newPath,\n }: Parameters<\n KnapsackTemplateRendererBase['getTemplateSuggestions']\n >[0]): ReturnType<KnapsackTemplateRendererBase['getTemplateSuggestions']> {\n const { data: dataDir } = this.patterns.userConfig;\n const { allTemplateDemos, allTemplates } = this.getMyTemplates();\n const usedSuggestions: TemplateSuggestion[] = [\n ...allTemplateDemos,\n ...allTemplates,\n ].map(({ path, alias }) => {\n return {\n path,\n alias: alias || 'default',\n };\n });\n\n const allPaths = [\n ...new Set([newPath, ...usedSuggestions.map(({ path }) => path)]),\n ];\n const {\n resolve: { alias },\n } = this.createWebpackConfig();\n const aliasConfig: Record<string, string> = {};\n if (isObject(alias)) {\n Object.entries(alias).forEach(([key, value]) => {\n if (typeof value === 'string') {\n aliasConfig[key] = value;\n }\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: dataDir,\n alias: aliasConfig,\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\n return {\n suggestions,\n };\n }\n}\n","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}\n\nfunction renderDemoAppTemplate({\n imports,\n children,\n}: {\n imports: string;\n children: string;\n}) {\n return `${imports}\n\nfunction DemoApp() {\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}: {\n children: string;\n imports?: string;\n}): Promise<string> {\n const code = renderDemoAppTemplate({\n children,\n imports,\n });\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\n .map(({ value }) => removeWrappingDoubleQuotes(value?.trim()))\n .filter(Boolean),\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\n .split('|')\n .map((enumItem) => removeWrappingDoubleQuotes(enumItem.trim()))\n .filter(Boolean);\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',\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: { importNames } }) => {\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAAkB;AAClB,mCAA4C;AAC5C,IAAAA,gBAKO;AACP,IAAAC,cAA0D;AAC1D,IAAAC,gBAYO;AAQP,IAAAC,qBAMO;AAEP,IAAAC,eAAsC;;;ACrCtC,iBAAoB;AACpB,wBAOO;AACP,mBAA2C;AAC3C,kBAAiB;AAGjB,mBAA4D;AAmD5D,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA;AAAA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ACnB,IAAI,KAAK,oBAAoB;AAC7B,UAAM,cAAsC,CAAC;AAC7C,YAAI,wBAAS,KAAK,GAAG;AACnB,aAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC9C,YAAI,OAAO,UAAU,UAAU;AAC7B,sBAAY,GAAG,IAAI;AAAA,QACrB;AAAA,MACF,CAAC;AAAA,IACH;AACA,UAAM,iBAAuC,MAAM,QAAQ;AAAA,MACzD,SAAS,IAAI,OAAOA,UAAwC;AAC1D,YAAI,CAACA;AAAM,iBAAO,CAAC;AACnB,YAAI;AACF,gBAAM,EAAE,SAAAE,UAAS,SAAS,IAAI,UAAM,qCAAiB;AAAA,YACnD,MAAAF;AAAA,YACA,gBAAgB;AAAA,YAChB,OAAO;AAAA,UACT,CAAC;AACD,cAAI,UAAU;AACZ,kBAAM,IAAI,MAAM,QAAQ;AAAA,UAC1B;AACA,iBACEE,SAGG,OAAO,CAAC,MAAM,MAAM,iBAAa,oCAAqB,CAAC,CAAC,EACxD,IAAI,CAAC,UAAU;AAAA,YACd,OAAO;AAAA,YACP,MAAAF;AAAA,UACF,EAAE;AAAA,QAER,SAAS,GAAG;AAEV,0BAAI;AAAA,YACF,kCAAkCA,KAAI,KAAK,EAAE,OAAO;AAAA,YACpD;AAAA,YACA,KAAK;AAAA,UACP;AACA,iBAAO,CAAC;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,EAAE,KAAK,CAAC,YAAY;AAElB,aAAO,QAAQ,KAAK;AAAA,IACtB,CAAC;AAED,UAAM,cAAc,eAAe,OAAO,CAAC,MAAM;AAC/C,aAAO,CAAC,gBAAgB;AAAA,QACtB,CAAC,OAAO,GAAG,UAAU,EAAE,SAAS,GAAG,SAAS,EAAE;AAAA,MAChD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":["import_utils","import_app","import_types","import_file_utils","import_path","path","parse","import_file_utils","import_utils","path","sleep","usage","path","alias","exports"]}
package/dist/index.mjs CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  isFirstLetterCapital,
24
24
  isObject
25
25
  } from "@knapsack/utils";
26
- import { knapsackEvents, log as log2 } from "@knapsack/app";
26
+ import { knapsackEvents, log as log2, KnapsackRendererBase } from "@knapsack/app";
27
27
  import {
28
28
  isSlottedText,
29
29
  isSlottedTemplateReference,
@@ -74,9 +74,7 @@ function renderDemoAppTemplate({
74
74
 
75
75
  function DemoApp() {
76
76
  return (
77
- <div className="demo-app knapsack-pattern-direct-parent">
78
- ${children}
79
- </div>
77
+ ${children}
80
78
  )
81
79
  }
82
80
  `;
@@ -740,6 +738,7 @@ var createReactPattern = createCreator({
740
738
  // src/renderer-react.ts
741
739
  var { pkg } = findUpPkgJson(__dirname);
742
740
  log2.setupUpdateNotifier({ ...pkg, name: pkg.name, version: pkg.version });
741
+ var { createSlotOptionsHtmlTags } = KnapsackRendererBase;
743
742
  var KnapsackReactRenderer = class _KnapsackReactRenderer extends KnapsackRendererWebpackBase {
744
743
  static {
745
744
  __name(this, "KnapsackReactRenderer");
@@ -789,6 +788,7 @@ var KnapsackReactRenderer = class _KnapsackReactRenderer extends KnapsackRendere
789
788
  enableDataDemos: true,
790
789
  enableTemplateDemos: true,
791
790
  hasSlotsSupport: true,
791
+ hasSlotOptionsSupport: true,
792
792
  version: pkg.version,
793
793
  hasInferSpecSupport: true,
794
794
  syntaxHighlightingLanguage: "jsx",
@@ -1079,7 +1079,7 @@ ${errorHtmlMsg}
1079
1079
  const { pattern, template, patternManifest, demo } = opt;
1080
1080
  if (demo?.type && _KnapsackReactRenderer.isDataDemo(demo)) {
1081
1081
  const {
1082
- data: { props, slots }
1082
+ data: { props, slots, slotsOptionsComputed }
1083
1083
  } = demo;
1084
1084
  const importInfo = this.getJsImport({
1085
1085
  patternId: pattern.id,
@@ -1099,7 +1099,7 @@ ${errorHtmlMsg}
1099
1099
  const slotUsages = await Promise.all(
1100
1100
  slotNames.map(async (slotName) => {
1101
1101
  const slotItems = slots[slotName];
1102
- const usages = await Promise.all(
1102
+ const slotItemsUsages = await Promise.all(
1103
1103
  slotItems.filter((slotItem) => {
1104
1104
  if (!isSlottedText(slotItem)) {
1105
1105
  if (!slotItem.patternId)
@@ -1150,12 +1150,28 @@ ${errorHtmlMsg}
1150
1150
  );
1151
1151
  return {
1152
1152
  slotName,
1153
- usages
1153
+ slotItemsUsages
1154
1154
  };
1155
1155
  })
1156
1156
  );
1157
- slotUsages.forEach(({ slotName, usages }) => {
1158
- usages.forEach((usage2) => {
1157
+ slotUsages.forEach(({ slotName, slotItemsUsages }) => {
1158
+ const slotOptionsComputed = slotsOptionsComputed?.[slotName];
1159
+ const { openTag, closeTag } = createSlotOptionsHtmlTags({
1160
+ slotOptionsComputed,
1161
+ classAttributeName: "className",
1162
+ stylesValueType: "object"
1163
+ });
1164
+ if (openTag) {
1165
+ if (slotName === "children") {
1166
+ children.push(openTag);
1167
+ } else {
1168
+ extraProps.push({
1169
+ key: slotName,
1170
+ value: openTag
1171
+ });
1172
+ }
1173
+ }
1174
+ slotItemsUsages.forEach((usage2) => {
1159
1175
  if (slotName === "children") {
1160
1176
  children.push(usage2);
1161
1177
  } else {
@@ -1165,6 +1181,16 @@ ${errorHtmlMsg}
1165
1181
  });
1166
1182
  }
1167
1183
  });
1184
+ if (closeTag) {
1185
+ if (slotName === "children") {
1186
+ children.push(closeTag);
1187
+ } else {
1188
+ extraProps.push({
1189
+ key: slotName,
1190
+ value: closeTag
1191
+ });
1192
+ }
1193
+ }
1168
1194
  });
1169
1195
  }
1170
1196
  const usage = await getUsage({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../node_modules/.pnpm/tsup@8.0.2_@microsoft+api-extractor@7.43.8_@types+node@20.14.9__@swc+core@1.3.57_postcss@8.4._c7ofiv7d7od3vtkxwbcxujiyae/node_modules/tsup/assets/esm_shims.js","../src/renderer-react.ts","../src/utils.ts","../src/react-creators.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import sleep from 'sleep-promise';\nimport { KnapsackRendererWebpackBase } from '@knapsack/renderer-webpack-base';\nimport {\n pascalCase,\n Except,\n isFirstLetterCapital,\n isObject,\n} from '@knapsack/utils';\nimport { knapsackEvents, log } from '@knapsack/app';\nimport {\n KsRendererClientGlobal,\n KnapsackFile,\n KsJsImport,\n isSlottedText,\n isSlottedTemplateReference,\n isSlottedTemplateDemo,\n KnapsackPatternTemplate,\n KsTemplateSpec,\n TemplateSuggestion,\n rendererIds,\n RendererId,\n} from '@knapsack/types';\nimport type {\n KnapsackRenderParams,\n KnapsackTemplateRenderer,\n KnapsackTemplateRendererBase,\n KnapsackTemplateRendererResults,\n Patterns,\n} from '@knapsack/app/types';\nimport {\n exists,\n findUpPkgJson,\n getJsExportNames,\n readFile,\n formatCode,\n} from '@knapsack/file-utils';\nimport type { ReactNode } from 'react';\nimport { join, relative, parse } from 'path';\nimport {\n clearInferSpecCache,\n copyReactAssets,\n getDemoAppUsage,\n getReactDocs,\n getUsage,\n} from './utils';\nimport { createReactPattern } from './react-creators';\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\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[];\n} & Except<KnapsackRenderParams, 'patternManifest'>;\n\nexport class KnapsackReactRenderer\n extends KnapsackRendererWebpackBase\n implements KnapsackTemplateRenderer\n{\n /**\n * `react.js` & `react-dom.js` root relative paths\n */\n assets: string[];\n babelConfig: Record<string, unknown>;\n creators: KnapsackTemplateRenderer['creators'];\n private demoWrapperPath: string;\n\n private 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 KnapsackRendererWebpackBase\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 extension: '.jsx',\n language: 'jsx',\n webpackConfig,\n });\n this.language = 'jsx';\n this.assets = [];\n this.demoWrapperPath = demoWrapperPath;\n\n // Half-borrowing the API Synax for this from the latest version of Next.js\n this.disableReactStrictMode = disableReactStrictMode;\n this.creators = [createReactPattern];\n }\n\n async init(opt: { patterns: Patterns; cacheDir: string }): Promise<void> {\n await super.init(opt);\n this.assets = await copyReactAssets(this.outputDir, this.publicPath);\n if (!(await exists(this.demoWrapperPath))) {\n throw new Error(\n `Could not find demo wrapper at: \"${this.demoWrapperPath}\"`,\n );\n }\n }\n\n getMeta: KnapsackTemplateRenderer['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 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 changeCase(str: string): string {\n return pascalCase(str);\n }\n\n createWebpackConfig(): ReturnType<\n KnapsackRendererWebpackBase['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 getJsImports(): ReturnType<KnapsackRendererWebpackBase['getJsImports']> {\n const imports = super.getJsImports();\n imports.push(\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: this.demoWrapperPath,\n name: 'DemoWrapper',\n },\n },\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: join(__dirname, './error-catcher.mjs'),\n name: 'ErrorCatcher',\n },\n },\n );\n return imports;\n }\n\n async prepClientRenderResults({\n usage,\n demoApp,\n imports: xImports,\n renderOptions: { pattern, template, demo },\n }: {\n usage: string;\n demoApp: string;\n imports: KsJsImport[];\n renderOptions: KnapsackRenderParams;\n }): Promise<KnapsackTemplateRendererResults> {\n const extraImportNames = this.getJsImports().flatMap((imp) =>\n imp.type === 'extra' ? [imp.importInfo.name] : [],\n );\n const { imports, isDeclaredVarsUnique, nameCollisions } =\n this.makeKsJsImportsUnique({ imports: xImports });\n\n if (!isDeclaredVarsUnique) {\n log.error(`${nameCollisions.join(', ')} are declared multiple times`, {\n imports,\n });\n }\n\n // import names; i.e. `KsButton`\n const importNames = [\n ...imports.map(({ importInfo: { name } }) => name),\n ...extraImportNames,\n ];\n\n const patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[] = imports.flatMap((imp) => {\n if (imp.type === 'pattern-template') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n },\n ];\n }\n if (imp.type === 'pattern-template-demo') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n demoId: imp.demoId,\n },\n ];\n }\n return [];\n });\n\n const demoWrapperProps: Omit<DemoWrapperProps, 'children'> = {\n patternsUsed,\n pattern,\n template,\n demo,\n };\n const demoWrapperCode = await getUsage({\n templateName: 'DemoWrapper',\n props: demoWrapperProps,\n children: `<DemoApp />`,\n // extraProps,\n });\n\n /**\n * IMPORTANT: this function is stringified and then executed in the browser - it cannot use anything in scope (other functions, vars, etc)\n */\n async function renderReact({\n patterns,\n theExtraImportNames,\n ksGlobal,\n }: {\n patterns: typeof patternsUsed;\n theExtraImportNames: typeof extraImportNames;\n ksGlobal: KsRendererClientGlobal<ReactNode>;\n }): Promise<Record<string, ReactNode>> {\n if (!ksGlobal) {\n throw new Error('\"window.knapsack\" is null');\n }\n const components = await ksGlobal.getAllImports({\n patterns,\n extras: theExtraImportNames.map((name) => ({ name })),\n });\n return components;\n }\n\n let code = `\n\n${renderReact.toString()}\n${renderReact.name}({\n ksGlobal: window.knapsack,\n patterns: ${JSON.stringify(patternsUsed)},\n theExtraImportNames: ${JSON.stringify(extraImportNames)},\n}).then((components) => {\n const { ${importNames.join(', ')} } = components;\n const root = document.getElementById('render-root');\n\n ${demoApp}\n\n const reactDomVersion = parseInt(ReactDOM.version.split('.')[0], 10);\n\n const ReactRendererResult = () => {\n if (reactDomVersion < 17 || ${this.disableReactStrictMode}){\n return (\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n )\n }\n\n return (\n <React.StrictMode>\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n </React.StrictMode>\n )\n };\n\n\n if (reactDomVersion > 17){\n ReactDOM.createRoot(root).render(\n <ReactRendererResult />\n )\n } else {\n ReactDOM.render(\n <ReactRendererResult />,\n root\n );\n }\n}).catch((err) => {\n console.error(err);\n const root = document.getElementById('render-root');\n // Create a new <div> element to contain the error message\n const errorMsgDiv = document.createElement('div');\n // Insert the new <div> element before the existing element\n root.parentNode.insertBefore(errorMsgDiv, root);\n // add error message so users can see it\n errorMsgDiv.innerHTML = '<h1>Component Error</h1><p>' + err.message + '</p>';\n});\n `;\n\n let codeHadError = false;\n let errorHtmlMsg = '';\n\n try {\n code = await this.babelCodeForBrowser({\n code,\n });\n } catch (e) {\n codeHadError = true;\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 if (!codeHadError) {\n try {\n code = await formatCode({\n contents: code,\n path: 'x.tsx', // doing this to set format language\n });\n } catch (e) {\n codeHadError = true;\n console.log(code);\n console.log('---original code before prettier 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\n const html = `\n ${this.assets.map((asset) => `<script src=\"${asset}\"></script>`).join('\\n')}\n\n ${this.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\n <div id=\"render-root\" class=\"knapsack-pattern-direct-parent\" data-dev-note=\"Knapsack React Template Wrapper\"></div>\n <script type=\"application/javascript\">${code}</script>\n${errorHtmlMsg}\n\n `;\n\n return {\n ok: !codeHadError,\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 async render(\n opt: KnapsackRenderParams,\n ): Promise<KnapsackTemplateRendererResults> {\n if (KnapsackReactRenderer.isTemplateDemo(opt.demo)) {\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 templateDemoPath = opt.patternManifest.getTemplateDemoAbsolutePath({\n patternId: opt.pattern.id,\n templateId: opt.template.id,\n demoId: opt.demo.id,\n });\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\n const [templateFileContents, { usage, imports }] = await Promise.all([\n readFile(templateDemoPath),\n this.getUsageAndImports(opt),\n ]);\n const demoApp = await getDemoAppUsage({\n children: usage,\n });\n const results = await this.prepClientRenderResults({\n usage: templateFileContents,\n demoApp,\n imports,\n renderOptions: opt,\n });\n\n return results;\n }\n\n if (KnapsackReactRenderer.isDataDemo(opt.demo)) {\n const { usage, imports } = await this.getUsageAndImports(opt);\n const { code: importCode } = this.createJsImportCodeBlock({\n imports,\n });\n\n const [demoAppUsage, demoApp] = await Promise.all([\n getDemoAppUsage({\n children: usage,\n imports: importCode,\n }),\n getDemoAppUsage({\n children: usage,\n }),\n ]);\n\n return this.prepClientRenderResults({\n demoApp,\n usage: demoAppUsage,\n imports,\n renderOptions: opt,\n });\n }\n }\n\n async getUsageAndImports(opt: KnapsackRenderParams): Promise<{\n usage: string;\n imports: KsJsImport[];\n }> {\n const { pattern, template, patternManifest, demo } = opt;\n if (demo?.type && KnapsackReactRenderer.isDataDemo(demo)) {\n const {\n data: { props, slots },\n } = demo;\n\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const importInfos: KsJsImport[] = [importInfo];\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 usages = await Promise.all(\n slotItems\n // remove any incomplete item - happens when users are filling out form\n .filter((slotItem) => {\n if (!isSlottedText(slotItem)) {\n if (!slotItem.patternId) return false;\n if (!slotItem.templateId) return false;\n if (isSlottedTemplateDemo(slotItem) && !slotItem.demoId) {\n return false;\n }\n }\n return true;\n })\n .map(async (slotItem) => {\n if (isSlottedText(slotItem)) {\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\n const slotPattern = patternManifest.getPattern(\n slotItem.patternId,\n );\n\n const slotTemplate = slotPattern.templates.find(\n (t) => t.id === slotItem.templateId,\n );\n if (isSlottedTemplateReference(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n if (isSlottedTemplateDemo(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n demo:\n slotItem.demo ||\n this.patterns.demosById[slotItem.demoId],\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n\n throw new Error(\n `Unknown slot item: ${JSON.stringify(slotItem)}`,\n );\n }),\n );\n return {\n slotName,\n usages,\n };\n }),\n );\n\n slotUsages.forEach(({ slotName, usages }) => {\n usages.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 }\n\n const usage = await getUsage({\n templateName,\n props,\n children: children.join('\\n'),\n extraProps,\n });\n\n return {\n usage,\n imports: importInfos,\n };\n }\n\n if (demo?.type && KnapsackReactRenderer.isTemplateDemo(demo)) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n demoId: demo.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template-demo: ${pattern.id}-${template.id}-${demo.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const usage = await getUsage({ templateName });\n\n return {\n usage,\n imports: [importInfo],\n };\n }\n\n if (!demo) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n return {\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 usage: templateName,\n imports: [importInfo],\n };\n }\n\n throw new Error(\n `Unhandled demo type for ${pattern.id}-${template.id}: ${JSON.stringify(\n demo,\n )}`,\n );\n }\n\n async getUsage(opt: KnapsackRenderParams): Promise<string> {\n const { usage } = await this.getUsageAndImports(opt);\n return usage;\n }\n\n inferSpec: KnapsackTemplateRendererBase['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 async watch(opt: Parameters<KnapsackTemplateRendererBase['watch']>[0]) {\n await super.watch(opt);\n knapsackEvents.onPatternTemplateChanged(() => {\n clearInferSpecCache();\n });\n }\n\n getTemplateMeta: KnapsackTemplateRendererBase['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: KnapsackTemplateRendererBase['alterTemplateMetaFiles'] =\n async ({ files, metaDir }) => {\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 async getTemplateSuggestions({\n newPath,\n }: Parameters<\n KnapsackTemplateRendererBase['getTemplateSuggestions']\n >[0]): ReturnType<KnapsackTemplateRendererBase['getTemplateSuggestions']> {\n const { data: dataDir } = this.patterns.userConfig;\n const { allTemplateDemos, allTemplates } = this.getMyTemplates();\n const usedSuggestions: TemplateSuggestion[] = [\n ...allTemplateDemos,\n ...allTemplates,\n ].map(({ path, alias }) => {\n return {\n path,\n alias: alias || 'default',\n };\n });\n\n const allPaths = [\n ...new Set([newPath, ...usedSuggestions.map(({ path }) => path)]),\n ];\n const {\n resolve: { alias },\n } = this.createWebpackConfig();\n const aliasConfig: Record<string, string> = {};\n if (isObject(alias)) {\n Object.entries(alias).forEach(([key, value]) => {\n if (typeof value === 'string') {\n aliasConfig[key] = value;\n }\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: dataDir,\n alias: aliasConfig,\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\n return {\n suggestions,\n };\n }\n}\n","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}\n\nfunction renderDemoAppTemplate({\n imports,\n children,\n}: {\n imports: string;\n children: string;\n}) {\n return `${imports}\n\nfunction DemoApp() {\n return (\n <div className=\"demo-app knapsack-pattern-direct-parent\">\n ${children}\n </div>\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}: {\n children: string;\n imports?: string;\n}): Promise<string> {\n const code = renderDemoAppTemplate({\n children,\n imports,\n });\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\n .map(({ value }) => removeWrappingDoubleQuotes(value?.trim()))\n .filter(Boolean),\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\n .split('|')\n .map((enumItem) => removeWrappingDoubleQuotes(enumItem.trim()))\n .filter(Boolean);\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',\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: { importNames } }) => {\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"],"mappings":";;;;;;;;;;;AACA,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAEjB,IAAM,cAAc,6BAAM,cAAc,YAAY,GAAG,GAAnC;AACpB,IAAM,aAAa,6BAAM,KAAK,QAAQ,YAAY,CAAC,GAAhC;AAEZ,IAAM,YAA4B,2BAAW;;;ACPpD,OAAO,WAAW;AAClB,SAAS,mCAAmC;AAC5C;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,OAAAA,YAAW;AACpC;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,OAEK;AAQP;AAAA,EACE;AAAA,EAC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AAI,OAAOA,UAAwC;AAC1D,YAAI,CAACA;AAAM,iBAAO,CAAC;AACnB,YAAI;AACF,gBAAM,EAAE,SAAS,SAAS,IAAI,MAAME,kBAAiB;AAAA,YACnD,MAAAF;AAAA,YACA,gBAAgB;AAAA,YAChB,OAAO;AAAA,UACT,CAAC;AACD,cAAI,UAAU;AACZ,kBAAM,IAAI,MAAM,QAAQ;AAAA,UAC1B;AACA,iBACE,QAGG,OAAO,CAAC,MAAM,MAAM,aAAa,qBAAqB,CAAC,CAAC,EACxD,IAAI,CAAC,UAAU;AAAA,YACd,OAAO;AAAA,YACP,MAAAA;AAAA,UACF,EAAE;AAAA,QAER,SAAS,GAAG;AAEV,UAAAJ,KAAI;AAAA,YACF,kCAAkCI,KAAI,KAAK,EAAE,OAAO;AAAA,YACpD;AAAA,YACA,KAAK;AAAA,UACP;AACA,iBAAO,CAAC;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,EAAE,KAAK,CAAC,YAAY;AAElB,aAAO,QAAQ,KAAK;AAAA,IACtB,CAAC;AAED,UAAM,cAAc,eAAe,OAAO,CAAC,MAAM;AAC/C,aAAO,CAAC,gBAAgB;AAAA,QACtB,CAAC,OAAO,GAAG,UAAU,EAAE,SAAS,GAAG,SAAS,EAAE;AAAA,MAChD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":["log","getJsExportNames","readFile","formatCode","path","path","parse","path","log","formatCode","readFile","usage","path","alias","getJsExportNames"]}
1
+ {"version":3,"sources":["../../../../../node_modules/.pnpm/tsup@8.0.2_@microsoft+api-extractor@7.43.8_@types+node@20.14.9__@swc+core@1.3.57_postcss@8.4._c7ofiv7d7od3vtkxwbcxujiyae/node_modules/tsup/assets/esm_shims.js","../src/renderer-react.ts","../src/utils.ts","../src/react-creators.ts"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import sleep from 'sleep-promise';\nimport { KnapsackRendererWebpackBase } from '@knapsack/renderer-webpack-base';\nimport {\n pascalCase,\n Except,\n isFirstLetterCapital,\n isObject,\n} from '@knapsack/utils';\nimport { knapsackEvents, log, KnapsackRendererBase } from '@knapsack/app';\nimport {\n KsRendererClientGlobal,\n KnapsackFile,\n KsJsImport,\n isSlottedText,\n isSlottedTemplateReference,\n isSlottedTemplateDemo,\n KnapsackPatternTemplate,\n KsTemplateSpec,\n TemplateSuggestion,\n rendererIds,\n RendererId,\n} from '@knapsack/types';\nimport type {\n KnapsackRenderParams,\n KnapsackTemplateRenderer,\n KnapsackTemplateRendererBase,\n KnapsackTemplateRendererResults,\n Patterns,\n} from '@knapsack/app/types';\nimport {\n exists,\n findUpPkgJson,\n getJsExportNames,\n readFile,\n formatCode,\n} from '@knapsack/file-utils';\nimport type { ReactNode } from 'react';\nimport { join, relative, parse } from 'path';\nimport {\n clearInferSpecCache,\n copyReactAssets,\n getDemoAppUsage,\n getReactDocs,\n getUsage,\n} from './utils';\nimport { createReactPattern } from './react-creators';\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\n// static methods only\nconst { createSlotOptionsHtmlTags } = KnapsackRendererBase;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[];\n} & Except<KnapsackRenderParams, 'patternManifest'>;\n\nexport class KnapsackReactRenderer\n extends KnapsackRendererWebpackBase\n implements KnapsackTemplateRenderer\n{\n /**\n * `react.js` & `react-dom.js` root relative paths\n */\n assets: string[];\n babelConfig: Record<string, unknown>;\n creators: KnapsackTemplateRenderer['creators'];\n private demoWrapperPath: string;\n\n private 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 KnapsackRendererWebpackBase\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 extension: '.jsx',\n language: 'jsx',\n webpackConfig,\n });\n this.language = 'jsx';\n this.assets = [];\n this.demoWrapperPath = demoWrapperPath;\n\n // Half-borrowing the API Synax for this from the latest version of Next.js\n this.disableReactStrictMode = disableReactStrictMode;\n this.creators = [createReactPattern];\n }\n\n async init(opt: { patterns: Patterns; cacheDir: string }): Promise<void> {\n await super.init(opt);\n this.assets = await copyReactAssets(this.outputDir, this.publicPath);\n if (!(await exists(this.demoWrapperPath))) {\n throw new Error(\n `Could not find demo wrapper at: \"${this.demoWrapperPath}\"`,\n );\n }\n }\n\n getMeta: KnapsackTemplateRenderer['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 changeCase(str: string): string {\n return pascalCase(str);\n }\n\n createWebpackConfig(): ReturnType<\n KnapsackRendererWebpackBase['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 getJsImports(): ReturnType<KnapsackRendererWebpackBase['getJsImports']> {\n const imports = super.getJsImports();\n imports.push(\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: this.demoWrapperPath,\n name: 'DemoWrapper',\n },\n },\n {\n type: 'extra',\n importInfo: {\n type: 'default',\n path: join(__dirname, './error-catcher.mjs'),\n name: 'ErrorCatcher',\n },\n },\n );\n return imports;\n }\n\n async prepClientRenderResults({\n usage,\n demoApp,\n imports: xImports,\n renderOptions: { pattern, template, demo },\n }: {\n usage: string;\n demoApp: string;\n imports: KsJsImport[];\n renderOptions: KnapsackRenderParams;\n }): Promise<KnapsackTemplateRendererResults> {\n const extraImportNames = this.getJsImports().flatMap((imp) =>\n imp.type === 'extra' ? [imp.importInfo.name] : [],\n );\n const { imports, isDeclaredVarsUnique, nameCollisions } =\n this.makeKsJsImportsUnique({ imports: xImports });\n\n if (!isDeclaredVarsUnique) {\n log.error(`${nameCollisions.join(', ')} are declared multiple times`, {\n imports,\n });\n }\n\n // import names; i.e. `KsButton`\n const importNames = [\n ...imports.map(({ importInfo: { name } }) => name),\n ...extraImportNames,\n ];\n\n const patternsUsed: {\n patternId: string;\n templateId: string;\n demoId?: string;\n }[] = imports.flatMap((imp) => {\n if (imp.type === 'pattern-template') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n },\n ];\n }\n if (imp.type === 'pattern-template-demo') {\n return [\n {\n patternId: imp.patternId,\n templateId: imp.templateId,\n demoId: imp.demoId,\n },\n ];\n }\n return [];\n });\n\n const demoWrapperProps: Omit<DemoWrapperProps, 'children'> = {\n patternsUsed,\n pattern,\n template,\n demo,\n };\n const demoWrapperCode = await getUsage({\n templateName: 'DemoWrapper',\n props: demoWrapperProps,\n children: `<DemoApp />`,\n // extraProps,\n });\n\n /**\n * IMPORTANT: this function is stringified and then executed in the browser - it cannot use anything in scope (other functions, vars, etc)\n */\n async function renderReact({\n patterns,\n theExtraImportNames,\n ksGlobal,\n }: {\n patterns: typeof patternsUsed;\n theExtraImportNames: typeof extraImportNames;\n ksGlobal: KsRendererClientGlobal<ReactNode>;\n }): Promise<Record<string, ReactNode>> {\n if (!ksGlobal) {\n throw new Error('\"window.knapsack\" is null');\n }\n const components = await ksGlobal.getAllImports({\n patterns,\n extras: theExtraImportNames.map((name) => ({ name })),\n });\n return components;\n }\n\n let code = `\n\n${renderReact.toString()}\n${renderReact.name}({\n ksGlobal: window.knapsack,\n patterns: ${JSON.stringify(patternsUsed)},\n theExtraImportNames: ${JSON.stringify(extraImportNames)},\n}).then((components) => {\n const { ${importNames.join(', ')} } = components;\n const root = document.getElementById('render-root');\n\n ${demoApp}\n\n const reactDomVersion = parseInt(ReactDOM.version.split('.')[0], 10);\n\n const ReactRendererResult = () => {\n if (reactDomVersion < 17 || ${this.disableReactStrictMode}){\n return (\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n )\n }\n\n return (\n <React.StrictMode>\n <ErrorCatcher>\n ${demoWrapperCode}\n </ErrorCatcher>\n </React.StrictMode>\n )\n };\n\n\n if (reactDomVersion > 17){\n ReactDOM.createRoot(root).render(\n <ReactRendererResult />\n )\n } else {\n ReactDOM.render(\n <ReactRendererResult />,\n root\n );\n }\n}).catch((err) => {\n console.error(err);\n const root = document.getElementById('render-root');\n // Create a new <div> element to contain the error message\n const errorMsgDiv = document.createElement('div');\n // Insert the new <div> element before the existing element\n root.parentNode.insertBefore(errorMsgDiv, root);\n // add error message so users can see it\n errorMsgDiv.innerHTML = '<h1>Component Error</h1><p>' + err.message + '</p>';\n});\n `;\n\n let codeHadError = false;\n let errorHtmlMsg = '';\n\n try {\n code = await this.babelCodeForBrowser({\n code,\n });\n } catch (e) {\n codeHadError = true;\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 if (!codeHadError) {\n try {\n code = await formatCode({\n contents: code,\n path: 'x.tsx', // doing this to set format language\n });\n } catch (e) {\n codeHadError = true;\n console.log(code);\n console.log('---original code before prettier 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\n const html = `\n ${this.assets.map((asset) => `<script src=\"${asset}\"></script>`).join('\\n')}\n\n ${this.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\n <div id=\"render-root\" class=\"knapsack-pattern-direct-parent\" data-dev-note=\"Knapsack React Template Wrapper\"></div>\n <script type=\"application/javascript\">${code}</script>\n${errorHtmlMsg}\n\n `;\n\n return {\n ok: !codeHadError,\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 async render(\n opt: KnapsackRenderParams,\n ): Promise<KnapsackTemplateRendererResults> {\n if (KnapsackReactRenderer.isTemplateDemo(opt.demo)) {\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 templateDemoPath = opt.patternManifest.getTemplateDemoAbsolutePath({\n patternId: opt.pattern.id,\n templateId: opt.template.id,\n demoId: opt.demo.id,\n });\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\n const [templateFileContents, { usage, imports }] = await Promise.all([\n readFile(templateDemoPath),\n this.getUsageAndImports(opt),\n ]);\n const demoApp = await getDemoAppUsage({\n children: usage,\n });\n const results = await this.prepClientRenderResults({\n usage: templateFileContents,\n demoApp,\n imports,\n renderOptions: opt,\n });\n\n return results;\n }\n\n if (KnapsackReactRenderer.isDataDemo(opt.demo)) {\n const { usage, imports } = await this.getUsageAndImports(opt);\n const { code: importCode } = this.createJsImportCodeBlock({\n imports,\n });\n\n const [demoAppUsage, demoApp] = await Promise.all([\n getDemoAppUsage({\n children: usage,\n imports: importCode,\n }),\n getDemoAppUsage({\n children: usage,\n }),\n ]);\n\n return this.prepClientRenderResults({\n demoApp,\n usage: demoAppUsage,\n imports,\n renderOptions: opt,\n });\n }\n }\n\n async getUsageAndImports(opt: KnapsackRenderParams): Promise<{\n usage: string;\n imports: KsJsImport[];\n }> {\n const { pattern, template, patternManifest, demo } = opt;\n if (demo?.type && KnapsackReactRenderer.isDataDemo(demo)) {\n const {\n data: { props, slots, slotsOptionsComputed },\n } = demo;\n\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const importInfos: KsJsImport[] = [importInfo];\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 (!isSlottedText(slotItem)) {\n if (!slotItem.patternId) return false;\n if (!slotItem.templateId) return false;\n if (isSlottedTemplateDemo(slotItem) && !slotItem.demoId) {\n return false;\n }\n }\n return true;\n })\n .map(async (slotItem) => {\n if (isSlottedText(slotItem)) {\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\n const slotPattern = patternManifest.getPattern(\n slotItem.patternId,\n );\n\n const slotTemplate = slotPattern.templates.find(\n (t) => t.id === slotItem.templateId,\n );\n if (isSlottedTemplateReference(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n if (isSlottedTemplateDemo(slotItem)) {\n const { usage, imports } = await this.getUsageAndImports({\n pattern: slotPattern,\n template: slotTemplate,\n demo:\n slotItem.demo ||\n this.patterns.demosById[slotItem.demoId],\n patternManifest,\n });\n importInfos.push(...imports);\n return usage;\n }\n\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 imports: importInfos,\n };\n }\n\n if (demo?.type && KnapsackReactRenderer.isTemplateDemo(demo)) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n demoId: demo.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template-demo: ${pattern.id}-${template.id}-${demo.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n const usage = await getUsage({ templateName });\n\n return {\n usage,\n imports: [importInfo],\n };\n }\n\n if (!demo) {\n const importInfo = this.getJsImport({\n patternId: pattern.id,\n templateId: template.id,\n });\n if (!importInfo) {\n throw new Error(\n `Could not find import for pattern-template: ${pattern.id}-${template.id}`,\n );\n }\n const { type, name: templateName } = importInfo.importInfo;\n\n return {\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 usage: templateName,\n imports: [importInfo],\n };\n }\n\n throw new Error(\n `Unhandled demo type for ${pattern.id}-${template.id}: ${JSON.stringify(\n demo,\n )}`,\n );\n }\n\n async getUsage(opt: KnapsackRenderParams): Promise<string> {\n const { usage } = await this.getUsageAndImports(opt);\n return usage;\n }\n\n inferSpec: KnapsackTemplateRendererBase['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 async watch(opt: Parameters<KnapsackTemplateRendererBase['watch']>[0]) {\n await super.watch(opt);\n knapsackEvents.onPatternTemplateChanged(() => {\n clearInferSpecCache();\n });\n }\n\n getTemplateMeta: KnapsackTemplateRendererBase['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: KnapsackTemplateRendererBase['alterTemplateMetaFiles'] =\n async ({ files, metaDir }) => {\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 async getTemplateSuggestions({\n newPath,\n }: Parameters<\n KnapsackTemplateRendererBase['getTemplateSuggestions']\n >[0]): ReturnType<KnapsackTemplateRendererBase['getTemplateSuggestions']> {\n const { data: dataDir } = this.patterns.userConfig;\n const { allTemplateDemos, allTemplates } = this.getMyTemplates();\n const usedSuggestions: TemplateSuggestion[] = [\n ...allTemplateDemos,\n ...allTemplates,\n ].map(({ path, alias }) => {\n return {\n path,\n alias: alias || 'default',\n };\n });\n\n const allPaths = [\n ...new Set([newPath, ...usedSuggestions.map(({ path }) => path)]),\n ];\n const {\n resolve: { alias },\n } = this.createWebpackConfig();\n const aliasConfig: Record<string, string> = {};\n if (isObject(alias)) {\n Object.entries(alias).forEach(([key, value]) => {\n if (typeof value === 'string') {\n aliasConfig[key] = value;\n }\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: dataDir,\n alias: aliasConfig,\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\n return {\n suggestions,\n };\n }\n}\n","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}\n\nfunction renderDemoAppTemplate({\n imports,\n children,\n}: {\n imports: string;\n children: string;\n}) {\n return `${imports}\n\nfunction DemoApp() {\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}: {\n children: string;\n imports?: string;\n}): Promise<string> {\n const code = renderDemoAppTemplate({\n children,\n imports,\n });\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\n .map(({ value }) => removeWrappingDoubleQuotes(value?.trim()))\n .filter(Boolean),\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\n .split('|')\n .map((enumItem) => removeWrappingDoubleQuotes(enumItem.trim()))\n .filter(Boolean);\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',\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: { importNames } }) => {\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"],"mappings":";;;;;;;;;;;AACA,SAAS,qBAAqB;AAC9B,OAAO,UAAU;AAEjB,IAAM,cAAc,6BAAM,cAAc,YA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,UAAU;AAAA,YACd,OAAO;AAAA,YACP,MAAAA;AAAA,UACF,EAAE;AAAA,QAER,SAAS,GAAG;AAEV,UAAAJ,KAAI;AAAA,YACF,kCAAkCI,KAAI,KAAK,EAAE,OAAO;AAAA,YACpD;AAAA,YACA,KAAK;AAAA,UACP;AACA,iBAAO,CAAC;AAAA,QACV;AAAA,MACF,CAAC;AAAA,IACH,EAAE,KAAK,CAAC,YAAY;AAElB,aAAO,QAAQ,KAAK;AAAA,IACtB,CAAC;AAED,UAAM,cAAc,eAAe,OAAO,CAAC,MAAM;AAC/C,aAAO,CAAC,gBAAgB;AAAA,QACtB,CAAC,OAAO,GAAG,UAAU,EAAE,SAAS,GAAG,SAAS,EAAE;AAAA,MAChD;AAAA,IACF,CAAC;AAED,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":["log","getJsExportNames","readFile","formatCode","path","path","parse","path","log","formatCode","readFile","usage","path","alias","getJsExportNames"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knapsack/renderer-react",
3
3
  "description": "Render React",
4
- "version": "4.67.0--canary.5f03d3b.0",
4
+ "version": "4.67.0--canary.4438.d153c90.0",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -31,13 +31,13 @@
31
31
  "author": "Knapsack",
32
32
  "dependencies": {
33
33
  "@babel/preset-react": "^7.24.7",
34
- "@knapsack/app": "4.67.0--canary.5f03d3b.0",
35
- "@knapsack/creator-utils": "4.67.0--canary.5f03d3b.0",
36
- "@knapsack/file-utils": "4.67.0--canary.5f03d3b.0",
37
- "@knapsack/ks-file-utils": "4.67.0--canary.5f03d3b.0",
38
- "@knapsack/renderer-webpack-base": "4.67.0--canary.5f03d3b.0",
39
- "@knapsack/types": "4.67.0--canary.5f03d3b.0",
40
- "@knapsack/utils": "4.67.0--canary.5f03d3b.0",
34
+ "@knapsack/app": "4.67.0--canary.4438.d153c90.0",
35
+ "@knapsack/creator-utils": "4.67.0--canary.4438.d153c90.0",
36
+ "@knapsack/file-utils": "4.67.0--canary.4438.d153c90.0",
37
+ "@knapsack/ks-file-utils": "4.67.0--canary.4438.d153c90.0",
38
+ "@knapsack/renderer-webpack-base": "4.67.0--canary.4438.d153c90.0",
39
+ "@knapsack/types": "4.67.0--canary.4438.d153c90.0",
40
+ "@knapsack/utils": "4.67.0--canary.4438.d153c90.0",
41
41
  "react": "^18.3.1",
42
42
  "react-docgen": "^6.0.4",
43
43
  "react-docgen-typescript": "^2.2.2",
@@ -46,10 +46,10 @@
46
46
  "typescript": "^5.5.3"
47
47
  },
48
48
  "devDependencies": {
49
- "@knapsack/eslint-config-starter": "4.67.0--canary.5f03d3b.0",
50
- "@knapsack/sandbox-components": "4.67.0--canary.5f03d3b.0",
51
- "@knapsack/test-ava": "4.67.0--canary.5f03d3b.0",
52
- "@knapsack/typescript-config-starter": "4.67.0--canary.5f03d3b.0",
49
+ "@knapsack/eslint-config-starter": "4.67.0--canary.4438.d153c90.0",
50
+ "@knapsack/sandbox-components": "4.67.0--canary.4438.d153c90.0",
51
+ "@knapsack/test-ava": "4.67.0--canary.4438.d153c90.0",
52
+ "@knapsack/typescript-config-starter": "4.67.0--canary.4438.d153c90.0",
53
53
  "@mui/material": "^5.15.18",
54
54
  "@mui/x-data-grid": "^6.19.11",
55
55
  "@types/node": "^20.12.12",
@@ -68,5 +68,5 @@
68
68
  "directory": "apps/client/renderers/renderer-react",
69
69
  "type": "git"
70
70
  },
71
- "gitHead": "5f03d3be42dc1ed7a2eab43f5a66a5c4a18a38ab"
71
+ "gitHead": "d153c903440ddf8b00c90ee9b38c2313c80dfb8f"
72
72
  }