@knapsack/renderer-react 4.72.0--canary.4920.be98a9b.0 → 4.72.0--canary.5313.51b7b5f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +217 -0
  2. package/ava.config.cjs +7 -1
  3. package/dist/analyze/infer-spec.test.d.ts +2 -0
  4. package/dist/analyze/infer-spec.test.d.ts.map +1 -0
  5. package/dist/analyze/infer-spec.test.js +112 -0
  6. package/dist/analyze/infer-spec.test.js.map +1 -0
  7. package/dist/analyze/mui.test.d.ts +2 -0
  8. package/dist/analyze/mui.test.d.ts.map +1 -0
  9. package/dist/analyze/mui.test.js +60 -0
  10. package/dist/analyze/mui.test.js.map +1 -0
  11. package/dist/analyze/pkg-basic.test.d.ts +2 -0
  12. package/dist/analyze/pkg-basic.test.d.ts.map +1 -0
  13. package/dist/analyze/pkg-basic.test.js +33 -0
  14. package/dist/analyze/pkg-basic.test.js.map +1 -0
  15. package/dist/analyze/pkg-diff-types.test.d.ts +2 -0
  16. package/dist/analyze/pkg-diff-types.test.d.ts.map +1 -0
  17. package/dist/analyze/pkg-diff-types.test.js +43 -0
  18. package/dist/analyze/pkg-diff-types.test.js.map +1 -0
  19. package/dist/client/init.d.mts +2 -2
  20. package/dist/client/init.d.mts.map +1 -0
  21. package/dist/client/init.mjs +38 -10
  22. package/dist/client/init.mjs.map +1 -1
  23. package/dist/index.d.ts +3 -45
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +16 -52
  26. package/dist/index.js.map +1 -1
  27. package/dist/react-creators.d.ts +20 -0
  28. package/dist/react-creators.d.ts.map +1 -0
  29. package/dist/react-creators.js +170 -0
  30. package/dist/react-creators.js.map +1 -0
  31. package/dist/{index.d.mts → renderer-react.d.ts} +2 -5
  32. package/dist/renderer-react.d.ts.map +1 -0
  33. package/dist/renderer-react.js +569 -0
  34. package/dist/renderer-react.js.map +1 -0
  35. package/dist/types.d.ts +19 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +5 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/utils.d.ts +28 -0
  40. package/dist/utils.d.ts.map +1 -0
  41. package/dist/utils.js +500 -0
  42. package/dist/utils.js.map +1 -0
  43. package/dist/utils.test.d.ts +2 -0
  44. package/dist/utils.test.d.ts.map +1 -0
  45. package/dist/utils.test.js +59 -0
  46. package/dist/utils.test.js.map +1 -0
  47. package/package.json +27 -31
  48. package/prototype-template.d.mts +3 -0
  49. package/prototype-template.mjs +3 -0
  50. package/test-fixtures/pkg-diff-types/button.js +10 -0
  51. package/test-fixtures/pkg-diff-types/package.json +4 -0
  52. package/test-fixtures/pkg-diff-types/readme.md +1 -0
  53. package/test-fixtures/pkg-diff-types/types/button.d.ts +5 -0
  54. package/tsconfig.json +3 -2
  55. package/dist/client/init.d.ts +0 -2
  56. package/dist/client/init.js +0 -20
  57. package/dist/client/init.js.map +0 -1
  58. package/dist/demo-wrapper.d.mts +0 -7
  59. package/dist/demo-wrapper.d.ts +0 -7
  60. package/dist/demo-wrapper.js +0 -9
  61. package/dist/demo-wrapper.js.map +0 -1
  62. package/dist/demo-wrapper.mjs +0 -7
  63. package/dist/demo-wrapper.mjs.map +0 -1
  64. package/dist/error-catcher.d.mts +0 -20
  65. package/dist/error-catcher.d.ts +0 -20
  66. package/dist/error-catcher.js +0 -30
  67. package/dist/error-catcher.js.map +0 -1
  68. package/dist/error-catcher.mjs +0 -8
  69. package/dist/error-catcher.mjs.map +0 -1
  70. package/dist/index.mjs +0 -47
  71. package/dist/index.mjs.map +0 -1
  72. package/dist/prototype-template.d.mts +0 -7
  73. package/dist/prototype-template.d.ts +0 -7
  74. package/dist/prototype-template.js +0 -7
  75. package/dist/prototype-template.js.map +0 -1
  76. package/dist/prototype-template.mjs +0 -5
  77. package/dist/prototype-template.mjs.map +0 -1
  78. package/dist/types-CivTHEEo.d.mts +0 -10
  79. package/dist/types-CivTHEEo.d.ts +0 -10
  80. package/tsup.config.cjs +0 -5
package/dist/index.d.ts CHANGED
@@ -1,45 +1,3 @@
1
- import { RendererWebpackBase, Renderer, KsJsImportMap } from '@knapsack/renderer-webpack-base';
2
- import { Renderable } from '@knapsack/app/renderers';
3
- import { RendererId } from '@knapsack/types';
4
- export { D as DemoWrapperProps } from './types-CivTHEEo.js';
5
-
6
- declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
7
- #private;
8
- /**
9
- * `react.js` & `react-dom.js` root relative paths
10
- */
11
- assets: string[];
12
- babelConfig: Record<string, unknown>;
13
- constructor({ webpackConfig, demoWrapperPath, id, disableReactStrictMode, }?: {
14
- webpackConfig?: ConstructorParameters<typeof RendererWebpackBase>[0]['webpackConfig'];
15
- demoWrapperPath?: string;
16
- /** 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).
17
- *
18
- * See https://reactjs.org/docs/strict-mode.html for more info
19
- * */
20
- disableReactStrictMode?: boolean;
21
- /** Don't set if calling from `knapsack.config.js`, only use if creating a new Renderer based on the React Renderer */
22
- id?: RendererId;
23
- });
24
- setConfig: Renderer['setConfig'];
25
- init: Renderer['init'];
26
- hydrate: Renderer['hydrate'];
27
- getMeta: Renderer['getMeta'];
28
- changeCase: Renderer['changeCase'];
29
- createWebpackConfig: RendererWebpackBase['createWebpackConfig'];
30
- prepClientRenderResults({ usage, demoApp, importMap, renderOptions: { demo, state, patternId, templateId }, }: {
31
- usage: string;
32
- demoApp: string;
33
- importMap: KsJsImportMap;
34
- renderOptions: Parameters<Renderer['render']>[0];
35
- }): ReturnType<Renderer['render']>;
36
- render: Renderer['render'];
37
- getUsageAndImports: RendererWebpackBase['getUsageAndImports'];
38
- inferSpec: Renderer['inferSpec'];
39
- watch: Renderer['watch'];
40
- getTemplateMeta: Renderer['getTemplateMeta'];
41
- alterTemplateMetaFiles: Renderer['alterTemplateMetaFiles'];
42
- getTemplateSuggestions: Renderer['getTemplateSuggestions'];
43
- }
44
-
45
- export { KnapsackReactRenderer };
1
+ export * from './renderer-react';
2
+ export type { DemoWrapperProps, } from '@knapsack/renderer-react-components/demo-wrapper';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,YAAY,EACV,gBAAgB,GAEjB,MAAM,kDAAkD,CAAC"}
package/dist/index.js CHANGED
@@ -1,54 +1,18 @@
1
- 'use strict';
2
-
3
- var ke = require('sleep-promise');
4
- var rendererWebpackBase = require('@knapsack/renderer-webpack-base');
5
- var utils = require('@knapsack/utils');
6
- var app = require('@knapsack/app');
7
- var renderers = require('@knapsack/app/renderers');
8
- var types = require('@knapsack/types');
9
- var fileUtils = require('@knapsack/file-utils');
10
- var g = require('path');
11
- var creatorUtils = require('@knapsack/creator-utils');
12
- var ksFileUtils = require('@knapsack/ks-file-utils');
13
-
14
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
-
16
- var ke__default = /*#__PURE__*/_interopDefault(ke);
17
- var g__default = /*#__PURE__*/_interopDefault(g);
18
-
19
- var Y=Object.defineProperty;var l=(s,t)=>Y(s,"name",{value:t,configurable:!0}),D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});function se({templateName:s,attributes:t,children:e}){return `
20
- <${s}
21
- ${t}
22
- ${e?`>
23
- ${e}
24
- </${s}>`:"/>"}
25
- `}l(se,"renderUsageTemplate");var E="DemoApp";function ae({imports:s="",children:t}){return `${s}
26
-
27
- function ${E}() {
28
- return (
29
- ${t}
30
- )
31
- }
32
- `}l(ae,"renderDemoAppTemplate");async function O(s){let t=Object.keys(s.props||{}).map(a=>{let o=s.props[a];return {key:a,value:o}}),{templateName:e,children:r,extraProps:n=[]}=s;if(!e)throw new Error('Cannot getUsage of a React Component when no "templateName" is provided.');let i=t.map(({key:a,value:o})=>{switch(typeof o){case"string":return o.startsWith("(")&&o.includes("=>")?`${a}={${o}}`:`${a}="${o}"`;case"boolean":return o?`${a}`:`${a}={${o}}`;default:return `${a}={${JSON.stringify(o)}}`}}),p=[],u={};n.forEach(({key:a,value:o})=>{u[a]=u[a]??[],u[a].push(o);}),Object.entries(u).forEach(([a,o])=>{let d=o.length===1?o[0]:`<>${o.join(`
33
- `)}</>`;p.push(`${a}={${d}}`);});let c=se({templateName:e,attributes:[...i,...p].join(" "),children:r});return s.format?fileUtils.formatCode({contents:c,path:"x.tsx"}).then(a=>a.trim()).catch(()=>c.trim()):c.trim()}l(O,"getUsage");async function v({children:s,imports:t,format:e}){let r=ae({children:s,imports:t});return e?fileUtils.formatCode({contents:r,path:"x.tsx"}):r}l(v,"getDemoAppUsage");async function J({src:s}){let t=await fileUtils.findUp("tsconfig.json",{cwd:g__default.default.dirname(s)}),e=await import('react-docgen-typescript'),r={shouldExtractLiteralValuesFromEnum:!0,savePropValueAsString:!0,skipChildrenPropWithoutDoc:!1,customComponentTypes:["VoidFunctionComponent","VFC"]};return {info:(t?e.withCustomConfig(t,r).parse:e.withDefaultConfig(r).parse)(s)}}l(J,"getTypeScriptInfoFromFile");function ne({info:s,exportName:t}){try{if(!s)return !1;let e={props:{$schema:"http://json-schema.org/draft-07/schema",type:"object",required:[],properties:{}},slots:{}},n=!t||t==="default"?s.pop():s.find(p=>p.displayName===t);if(!n)return !1;return Object.entries(n?.props||{}).forEach(([p,u])=>{let{name:c,description:a,defaultValue:o,required:d,type:f,parent:y}=u;switch(f?.name?.replace("| undefined","").replace(/<.*/g,"").trim()){case"string":e.props.properties[p]={type:"string"};break;case"number":e.props.properties[p]={type:"number"};break;case"boolean":case"bool":o&&"value"in o&&(o.value=o.value==="true"),e.props.properties[p]={type:"boolean"};break;case"enum":e.props.properties[p]={type:"string",enum:[...new Set(f.value.map(({value:h})=>utils.removeWrappingDoubleQuotes(h?.trim())).filter(Boolean))]};break;case"ReactNode":case"React.ReactNode":case"React.ReactElement":case"ReactElement":e.slots[p]={title:p},a&&(e.slots[p]={...e.slots[p],description:a});break;case"VFC":case"FC":e.slots[p]={title:p,description:a||"A reference to a component",isTemplateReference:!0,allowOnlyOne:!0,disallowText:!0};break;default:if(f?.name?.startsWith("("))e.props.properties[p]={typeof:"function",tsType:u?.type?.name};else if(f?.name?.includes("|")){let h=f.name.split("|").map(R=>utils.removeWrappingDoubleQuotes(R.trim())).filter(Boolean);h?.length&&(e.props.properties[p]={type:"string",enum:[...new Set(h)]});}else e.props.properties[p]={tsType:u?.type?.name};}e.props.properties[p]&&(d&&e.props.required.push(p),a&&!e.props.properties[p].description&&(e.props.properties[p].description=a),o&&"value"in o&&(types.isNumberProp(e.props.properties[p])?e.props.properties[p].default=parseFloat(o.value):e.props.properties[p].default=utils.removeWrappingDoubleQuotes(o.value)));}),e}catch(e){return app.log.verbose("Could not infer spec from React TypeScript file",{exportName:t,error:e},"react renderer"),!1}}l(ne,"extractSpecFromTypeScriptInfo");async function oe({src:s}){let t=await import('react-docgen'),{builtinResolvers:e}=t,r=await fileUtils.readFile(s),{FindExportedDefinitionsResolver:n}=e;return {info:t.parse(r,{resolver:new n,handlers:null,filename:s})}}l(oe,"getPropTypesInfoFromFile");function ie({info:s,exportName:t}){try{let r=!t||t==="default"?s.pop():s.find(i=>i.displayName===t),n={isInferred:!0,props:{$schema:"http://json-schema.org/draft-07/schema",type:"object",required:[],properties:{}},slots:{}};return Object.entries(r?.props||{}).forEach(([i,p])=>{let{required:u,description:c,defaultValue:a}=p;switch(p?.type?.name){case"string":n.props.properties[i]={type:"string"};break;case"func":n.props.properties[i]={type:"string"};break;case"bool":n.props.properties[i]={type:"boolean"};break;case"node":n.slots[i]={title:i,description:c};}n.props.properties[i]&&(u&&n.props.required.push(i),c&&!n.props.properties[i].description&&(n.props.properties[i].description=c),a&&"value"in a&&(n.props.properties[i].default=typeof a.value=="string"?utils.removeWrappingDoubleQuotes(a.value):a.value));}),n}catch(e){return app.log.verbose("Could not infer spec from React PropTypes",{exportName:t,error:e},"react renderer"),!1}}l(ie,"extractSpecFromPropTypesInfo");function pe({spec:s}){return s===!1||Object.entries(s?.props?.properties||{}).forEach(([t,e])=>{types.isOptionsProp(e)&&(e.enum.includes(e.default)||(e.default=void 0));}),s}l(pe,"cleanUpSpec");async function ce({src:s,resolveFromDir:t}){let e=await fileUtils.resolvePath({path:s,resolveFromDir:t,resolveType:"types"});if(e.exists){let i=await J({src:e.absolutePath});if(i)return {type:"typescript",info:i.info}}let r=await fileUtils.resolvePath({path:s,resolveFromDir:t});if(!r.exists)return {type:"unknown"};let{ext:n}=g__default.default.parse(r.absolutePath);switch(n){case".jsx":return {type:"propTypes",info:(await oe({src:r.absolutePath})).info};case".ts":case".tsx":return {type:"typescript",info:(await J({src:r.absolutePath})).info};default:return {type:"unknown"}}}l(ce,"getReactModuleInfoUncached");var S=new Map,q=l(()=>{app.log.info("Clearing React TypeScript inferSpec cache..."),S.clear();},"clearInferSpecCache");async function le(s){let t=JSON.stringify(s);return S.has(t)||S.set(t,ce(s)),S.get(t)}l(le,"getReactModuleInfo");async function de({src:s,exportName:t,resolveFromDir:e}){let r=await le({src:s,resolveFromDir:e});switch(r.type){case"typescript":return ne({info:r.info,exportName:t});case"propTypes":return ie({info:r.info,exportName:t});case"unknown":default:return !1}}l(de,"getReactSpec");async function B(s){return pe({spec:await de(s)})}l(B,"getReactDocs");async function _(s,t){try{let{version:e}=fileUtils.getModulePkgJson("react"),{version:r}=fileUtils.getModulePkgJson("react-dom"),n=g__default.default.dirname(D.resolve("react",{paths:[process.cwd()]})),i=g__default.default.dirname(D.resolve("react-dom",{paths:[process.cwd()]}));await Promise.all([fileUtils.copy(g__default.default.join(n,"umd/react.development.js"),g__default.default.join(s,`react.development.${e}.js`)),fileUtils.copy(g__default.default.join(n,"umd/react.production.min.js"),g__default.default.join(s,`react.production.min.${e}.js`)),fileUtils.copy(g__default.default.join(i,"umd/react-dom.production.min.js"),g__default.default.join(s,`react-dom.production.min.${r}.js`)),fileUtils.copy(g__default.default.join(i,"umd/react-dom.development.js"),g__default.default.join(s,`react-dom.development.${r}.js`))]);let p=process.env.NODE_ENV==="production"?"production.min":"development";return [g__default.default.join(t,`react.${p}.${e}.js`),g__default.default.join(t,`react-dom.${p}.${r}.js`)]}catch(e){app.log.warn('Error trying to copy "react" and "react-dom" JS files, are they installed? We want to use your exact versions.',e,"templateRenderer:react"),process.exit(1);}}l(_,"copyReactAssets");function Re(s){return s.toUpperCase()===s}l(Re,"isCapitalLetter");function be(s){return Re(s[0])}l(be,"startsWithCapitalLetter");function Te({importName:s,id:t,title:e=s,pkgPath:r,initialDemoId:n}){return {id:t,title:e,description:"",statuses:{main:"ready"},templates:[{id:"react",title:"react",path:r,alias:s,templateLanguageId:"react",spec:{isInferred:!0},demoIds:[n],blockIds:[]}],tabs:[{type:"template",id:"react"}],subPages:[]}}l(Te,"createPatternData");var N=creatorUtils.createCreator({id:"react-patterns",title:"React Ks Patterns",description:"Adds React templates as Knapsack Patterns",getQuestions:l(async()=>({pkgPath:{type:"text",title:"Package path"},importPrefix:{type:"text",title:"Import Prefix to Remove"}}),"getQuestions"),getTasks:l(async({answers:{pkgPath:s,importPrefix:t=""},config:e})=>{let r=e.dest,i=(await ksFileUtils.readKsPatternConfigs({dataDir:r})).reduce((u,c)=>{let a=c.templates?.filter(o=>o.templateLanguageId==="react")??[];return u.push(...a.map(o=>o.alias)),u},[]),{exports:p}=await fileUtils.getJsExportNames({path:s});return [{title:"Pick Imports to add",task:l((u,c)=>creatorUtils.tasks.runSubCreator({task:c,config:e,creator:creatorUtils.createCreator({id:"react-pattern-import-names",getQuestions:l(async()=>({importNames:{type:"choices",choices:p.filter(a=>be(a)&&!i.includes(a)).map(a=>({value:a}))}}),"getQuestions"),getTasks:l(async({answers:{importNames:a}})=>{let o=a.map(d=>({importName:d,patternId:d.startsWith(t)?d.slice(t.length).toLowerCase():d.toLowerCase()}));return [...o.map(({importName:d,patternId:f})=>({title:`Add ${d} React Template`,task:l(async(y,b)=>{let h={type:"data",id:utils.makeShortId(),title:"Main",patternId:f,templateId:"react",data:{props:{},slots:{}}},R=Te({id:f,importName:d,pkgPath:s,initialDemoId:h.id});await Promise.all([ksFileUtils.writeDemo({dataDir:r,demo:h}),ksFileUtils.writeKsPatternConfig({dataDir:r,patternId:f,data:R})]);},"task")})),{title:"Updating Nav",task:l(async(d,f)=>{let{byId:y}=await ksFileUtils.readKsNavConfig({dataDir:r}),b=Object.values(y).find(({path:h,name:R,id:X})=>h?!1:R.toLowerCase()==="patterns"||R.toLowerCase()==="components");await ksFileUtils.addKsNavItems({dataDir:r,navItems:o.map(({patternId:h})=>({navId:h,navPath:`/pattern/${h}`,navParent:b?.id||"root"}))});},"task")}]},"getTasks")})}),"task")}]},"getTasks")});var G="ks-react-meta";var{pkg:I}=fileUtils.findUpPkgJson(__dirname);app.log.setupUpdateNotifier({...I,name:I.name,version:I.version});var A=g.join(__dirname,"./error-catcher.mjs");if(!fileUtils.exists(A))throw new Error(`Could not find error catcher at: ${A}`);var H=class s extends rendererWebpackBase.RendererWebpackBase{static{l(this,"KnapsackReactRenderer");}assets;babelConfig;#e;#t;constructor({webpackConfig:t,demoWrapperPath:e=g.join(__dirname,"./demo-wrapper.mjs"),id:r=types.rendererIds.react,disableReactStrictMode:n}={}){super({id:r,language:"jsx",webpackConfig:t,extraScripts:["@knapsack/renderer-react/client"]}),this.language="jsx",this.assets=[],this.#e=e,this.#t=n,this.creators=[N];}setConfig=l(t=>{super.setConfig(t);let{absolutePath:e,exists:r,type:n}=this.resolvePathSync({path:this.#e,resolveFromDir:this.userConfigDir});if(!r)throw new Error(`Could not find demo wrapper at: "${this.#e}"
34
- Please adjust setting in "knapsack.config.js" or pass a different path when creating the React Renderer.`);this.registerExtraJsImports({DemoWrapper:{exportName:"DemoWrapper",isDefaultExport:!0,path:n==="package"?this.#e:e},ErrorCatcher:{exportName:"ErrorCatcher",isDefaultExport:!0,path:A}});},"setConfig");init=l(async()=>{this.assets=await _(this.outputDir,this.publicPath);},"init");hydrate=l(async t=>{await super.hydrate(t),await this.init({missingFileVerbosity:"silent"});},"hydrate");getMeta=l(()=>({id:this.id,title:"React",aliasUse:"optional",aliasTitle:"Named Export",aliasIsJsNamedExport:!0,aliasDescription:"If `export X` was used instead of `export default`, then provide X.",enableDataDemos:!0,enableTemplateDemos:!0,hasSlotsSupport:!0,hasSlotOptionsSupport:!0,version:I.version,hasInferSpecSupport:!0,syntaxHighlightingLanguage:"jsx",hasTemplateSuggestionsSupport:!0,prototypingTemplate:{path:"@knapsack/renderer-react/prototype-template",spec:{isInferred:!1,props:{type:"object",properties:{}},slots:{children:{title:"Children"}}}}}),"getMeta");changeCase=l(t=>utils.pascalCase(t),"changeCase");createWebpackConfig=l(()=>{let t=super.createWebpackConfig();return t.externals={react:"React","react-dom":"ReactDOM"},t},"createWebpackConfig");async prepClientRenderResults({usage:t,demoApp:e,importMap:r,renderOptions:{demo:n,state:i,patternId:p,templateId:u}}){let c={demo:n,disableReactStrictMode:this.#t,neededImportsByCodeSrcId:rendererWebpackBase.convertImportMapToNeededImportsByCodeSrcId(r),demoWrapperProps:{patternId:p,templateId:u,demo:n}},a=`
35
- window.knapsack = window.knapsack || {};
36
- window.knapsack.getDemoApp = ({ ${[...r.keys()].join(", ")} }) => {
37
- ${e}
38
- return ${E}
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
39
7
  }
40
- `,o="";try{a=await renderers.babelCodeForBrowser({code:a});}catch(f){console.log(a),console.log("---original code before babel error ^---"),console.trace(f.message),a=`console.error(${JSON.stringify(f.message)});`,o=`<pre><code>${f.message}</code></pre>`;}let d=`
41
- <script type="application/json" id="${G}">${JSON.stringify(c)}</script>
42
- <script type="application/javascript">${a}</script>
43
- <div id="render-root" class="knapsack-pattern-direct-parent" data-dev-note="Knapsack React Template Wrapper"></div>
44
- ${this.assets.map(f=>`<script src="${f}"></script>`).join(`
45
- `)}
46
- ${rendererWebpackBase.RendererWebpackBase.createHtmlTagsForAssetPaths({assets:this.getWebpackAssetPaths(),scriptTagsAreAsync:!1})}
47
- ${o}
48
- `;return {ok:!o,html:await fileUtils.formatCode({contents:d,path:"x.html"}),usage:t,templateLanguage:this.language}}render=l(async t=>{if(t.demo?.type==="template"){let e=[5,10,20,50,100,1e3,1e3],r,n=0;for(;;)try{let{absolutePath:o,exists:d}=await this.resolvePath(t.demo.templateInfo.path);if(!d)throw new Error(`Template demo file does not exist: ${o}`);r=o;break}catch(o){let d=e[n];if(!d)throw new Error(o);n+=1,await ke__default.default(d);}let[i,{usage:p,importMap:u}]=await Promise.all([fileUtils.readFile(r),this.getUsageAndImports({...t,importMap:new Map})]),c=await v({children:p});return await this.prepClientRenderResults({usage:i,demoApp:c,renderOptions:t,importMap:u})}if(t.demo?.type==="data"){let{usage:e,importMap:r}=await this.getUsageAndImports({...t,importMap:new Map}),n=rendererWebpackBase.RendererWebpackBase.createJsImportCodeBlock({importMap:r}),[i,p]=await Promise.all([v({children:e,imports:n,format:!0}),v({children:e})]);return this.prepClientRenderResults({demoApp:p,usage:i,renderOptions:t,importMap:r})}},"render");getUsageAndImports=l(async({patternId:t,templateId:e,demo:r,state:n,importMap:i})=>{if(!r)throw new Error(`No demo provided while rendering ${t} ${e}`);let p=n.patterns[t];if(!p)throw new Error(`Could not find pattern: ${t}`);if(r.type==="data"){let c=p.templates.find(R=>R.id===e);if(!c)throw new Error(`Could not find template: ${e}`);let{data:{props:a,slots:o,slotsOptionsComputed:d}}=r,{name:f}=await this.addUniqueValueToImportMap({importMap:i,path:c.path,alias:c.alias||"default"}),y=[],b=[];if(o){let R=Object.keys(o);(await Promise.all(R.map(async w=>{let T=o[w],j=await Promise.all(T.filter(m=>!(!m||m.type!=="text"&&(!m.patternId||!m.templateId||m.type==="template-demo"&&!m.demoId))).map(async m=>{if(m.type==="text")return T.length===1&&w!=="children"?`\`${m.text}\``:m.text;if(m.type==="template-reference"){let P=n.patterns[m.patternId]?.templates.find(z=>z.id===m.templateId);if(!P)throw new Error(`Could not find slotted template: ${m.patternId} ${m.templateId}`);return (await this.addUniqueValueToImportMap({importMap:i,path:P.path,alias:P.alias||"default"})).name}if(m.type==="template-demo"){let P=m.demo;if(!P)throw new Error(`Could not find slotted template demo ${JSON.stringify(m)}`);let{usage:K}=await this.getUsageAndImports({patternId:P.patternId,templateId:P.templateId,demo:P,state:n,importMap:i});return K}throw new Error(`Unknown slot item: ${JSON.stringify(m)}`)}));return {slotName:w,slotItemsUsages:j}}))).forEach(({slotName:w,slotItemsUsages:T})=>{let j=d?.[w],{openTag:m,closeTag:k}=renderers.createSlotOptionsHtmlTags({slotOptionsComputed:j,classAttributeName:"className",stylesValueType:"object"});m&&(w==="children"?y.push(m):b.push({key:w,value:m})),T.forEach(P=>{w==="children"?y.push(P):b.push({key:w,value:P});}),k&&(w==="children"?y.push(k):b.push({key:w,value:k}));});}return {usage:await O({templateName:f,props:a,children:y.join(`
49
- `),extraProps:b}),importMap:i}}if(r.type==="template"){let{templateInfo:c}=r,{name:a}=await this.addUniqueValueToImportMap({importMap:i,path:c.path,alias:c.alias||"default"});return {usage:await O({templateName:a}),importMap:i}}throw new Error(`Unhandled demo type for ${t}-${e}: ${JSON.stringify(r)}`)},"getUsageAndImports");inferSpec=l(async({template:t,templatePath:e})=>{let r=await B({src:t.path,exportName:t.alias||"default",resolveFromDir:this.config.data});if(r!==!1){let n=Object.keys(r?.props?.properties||{}).length,i=Object.keys(r?.slots||{}).length;if(n===0&&i===0)return !1}return r},"inferSpec");watch=l(async()=>{super.watch(),app.knapsackEvents.onPatternTemplateChanged(()=>{q();});},"watch");getTemplateMeta=l(async({pattern:t,template:e})=>{let r=[];if(e?.spec?.props){let n=JSON.parse(JSON.stringify(e.spec.props));e?.spec?.slots&&Object.entries(e.spec.slots).forEach(([p,u])=>{n.properties[p]={typeof:"function",tsType:"React.ReactNode",description:u.allowedPatternIds?`${u.description}. Only use: ${u.allowedPatternIds.join(", ")}`:u.description},n.required=n.required??[],u.isRequired&&n.required.push(p);});let i=await s.convertSchemaToTypeScriptDefs({schema:n,title:`${this.changeCase(t.id)}Props`,description:`[Knapsack Docs](http://localhost:3999/pattern/${t.id}/${e.id})`,patternId:t.id,templateId:e.id,postBanner:"import * as React from 'react';"});r.push({contents:i,encoding:"utf8",path:`${t.id}.${e.id}.spec.d.ts`}),r.push({contents:JSON.stringify(n,null," "),encoding:"utf8",path:`${t.id}.${e.id}.spec.json`});}return r},"getTemplateMeta");alterTemplateMetaFiles=l(async({files:t,metaDir:e})=>{let r=[],n=".spec.d.ts";return t.forEach(i=>{if(i.path.endsWith(n)){let{base:p}=g.parse(i.path),[u,c]=p.split("."),a=c===this.id,o=this.changeCase(`${u}Props`),d=this.changeCase(`${u}-${c}Props`);r.push(`export { ${a?o:`${o} as ${d}`} } from './${g.relative(e,i.path).replace(".d.ts","")}';`);}}),r.push(""),[...t,{contents:r.join(`
50
- `),encoding:"utf8",path:g.join(e,"react.d.ts")}]},"alterTemplateMetaFiles");getTemplateSuggestions=l(async({newPath:t,state:e})=>{let r=Object.values(e.patterns).reduce((c,{templateDemos:a,templates:o})=>(o.forEach(({path:d,alias:f,templateLanguageId:y})=>{y===this.id&&c.push({path:d,alias:f});}),a.forEach(({templateInfo:{path:d,alias:f},templateLanguageId:y})=>{y===this.id&&c.push({path:d,alias:f});}),c),[]),n=new Set(this.getCodeSrcs().map(({path:c})=>c)),i=[...new Set([t,...Object.keys(this.pkgPathAliases||{}),...n])];return {suggestions:(await Promise.all(i.map(async c=>{if(!c)return [];try{let{exports:a,errorMsg:o}=await fileUtils.getJsExportNames({path:c,resolveFromDir:this.dataDir,pkgPathAliases:this.pkgPathAliases});if(o)throw new Error(o);return a.filter(d=>d==="default"||utils.isFirstLetterCapital(d)).map(d=>({alias:d,path:c}))}catch(a){return app.log.verbose(`Error getting import names for ${c}: ${a.message}`,null,this.logPrefix),[]}})).then(c=>c.flat())).filter(c=>!r.find(a=>a.alias===c.alias&&a.path===c.path))}},"getTemplateSuggestions")};
51
-
52
- exports.KnapsackReactRenderer = H;
53
- //# sourceMappingURL=index.js.map
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./renderer-react"), exports);
54
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/react-creators.ts","../src/types.ts","../src/renderer-react.ts"],"names":["renderUsageTemplate","templateName","attributes","children","__name","demoAppName","renderDemoAppTemplate","imports","getUsage","data","props","key","value","extraProps","extraAttributes","slotProps","values","result","formatCode","code","getDemoAppUsage","format","getTypeScriptInfoFromFile","src","tsConfigPath","findUp","path","rdTs","config","extractSpecFromTypeScriptInfo","results","exportName","spec","r","propName","propDef","name","description","defaultValue","required","type","parent","removeWrappingDoubleQuotes","options","enumItem","isNumberProp","error","log","getPropTypesInfoFromFile","reactDocs","builtinResolvers","fileSrc","readFile","FindExportedDefinitionsResolver","extractSpecFromPropTypesInfo","cleanUpSpec","prop","isOptionsProp","getReactModuleInfoUncached","unknownSrc","resolveFromDir","typesInfo","resolvePath","typeScriptInfo","jsInfo","ext","getReactModuleInfoCache","clearInferSpecCache","getReactModuleInfo","args","cacheKey","getReactSpec","reactModuleInfo","getReactDocs","opt","copyReactAssets","distDirAbsolute","publicPath","reactVersion","getModulePkgJson","reactDomVersion","reactRoot","__require","reactDomRoot","copy","reactFileSuffix","isCapitalLetter","char","startsWithCapitalLetter","str","createPatternData","importName","id","title","pkgPath","initialDemoId","createReactPattern","createCreator","importPrefix","dataDir","currentReactPatternsImportNames","readKsPatternConfigs","cur","pattern","reactTemplates","t","allImports","getJsExportNames","_","task","tasks","importNames","patterns","patternId","__","subTask","initialDemo","makeShortId","writeDemo","writeKsPatternConfig","byId","readKsNavConfig","componentsGroup","addKsNavItems","rendererMetaScriptTagId","pkg","findUpPkgJson","errorCatcherAbsolutePath","join","fileExists","KnapsackReactRenderer","_KnapsackReactRenderer","RendererWebpackBase","#demoWrapperPath","#disableReactStrictMode","webpackConfig","demoWrapperPath","rendererIds","disableReactStrictMode","absolutePath","demoWrapperPathExists","pascalCase","usage","demoApp","importMap","demo","state","templateId","meta","convertImportMapToNeededImportsByCodeSrcId","errorHtmlMsg","babelCodeForBrowser","e","html","asset","waits","templateDemoPath","attempt","exists","waitTime","sleep","templateFileContents","importCode","demoAppUsage","template","slots","slotsOptionsComputed","slotNames","slotName","slotItems","slotItemsUsages","slotItem","slottedTemplate","thisDemo","slotOptionsComputed","openTag","closeTag","createSlotOptionsHtmlTags","templateInfo","templatePath","totalProps","totalSlots","knapsackEvents","files","schema","info","typeDefs","metaDir","file","base","parse","isFirst","exportNameWithTemplateId","relative","newPath","usedSuggestions","acc","templateDemos","templates","alias","templateLanguageId","codeSrcs","allPaths","exports","errorMsg","isFirstLetterCapital","s","us"],"mappings":";;;;;;;;;;;;;;;;;;oUAgEA,SAASA,GAAoB,CAC3B,YAAA,CAAAC,EACA,UAAAC,CAAAA,CAAAA,CACA,SAAAC,CACF,CAAA,CAIG,CACD,OAAO,CAAA;AAAA,KAAA,EACFF,CAAY,CAAA;AAAA,MAAA,EACXC,CAAU,CAAA;AAAA,MAAA,EAEVC,CACI,CAAA,CAAA;AAAA,QAAA,EACFA,CAAQ,CAAA;AA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A,CAAI,OACF,CAAA,CAAA,+BAAA,EAAkCrB,CAAI,CAAA,EAAA,EAAK8H,CAAE,CAAA,OAAO,CACpD,CAAA,CAAA,IAAA,CACA,IAAK,CAAA,SACP,CACO,CAAA,EACT,CACF,CAAC,CACH,CAAA,CAAE,IAAM1H,CAAAA,CAAAA,EAECA,CAAQ,CAAA,IAAA,EAChB,CAAA,EAEkC,MAAQgL,CAAAA,CAAAA,EAClC,CAACX,CAAAA,CAAgB,IACrBY,CAAAA,CAAAA,EAAOA,CAAG,CAAA,KAAA,GAAUD,CAAE,CAAA,KAAA,EAASC,CAAG,CAAA,IAAA,GAASD,CAAE,CAAA,IAChD,CACD,CAID,CACF,CAAA,CA5E6D,wBA6E/D,CAAA","file":"index.js","sourcesContent":["import { log } from '@knapsack/app';\nimport {\n getModulePkgJson,\n readFile,\n copy,\n formatCode,\n resolvePath,\n findUp,\n} from '@knapsack/file-utils';\nimport { removeWrappingDoubleQuotes } from '@knapsack/utils';\nimport path from 'path';\nimport type { Documentation } from 'react-docgen';\nimport type { ComponentDoc, ParserOptions } from 'react-docgen-typescript';\nimport { KsTemplateSpec, isNumberProp, isOptionsProp } from '@knapsack/types';\n\ntype GetSpecParams = {\n src: string;\n exportName?: string;\n};\n\n/**\n * The name of the type, which is usually corresponds to the function name in `React.PropTypes`. However, for types define with `oneOf`, we use `\"enum\"` and for `oneOfType` we use `\"union\"`. If a custom function is provided or the type cannot be resolved to anything of `React.PropTypes`, we use `\"custom\"`.\n */\ntype RdTypeName =\n | 'number'\n | 'string'\n | 'custom'\n | 'union'\n | 'bool'\n | 'node'\n | 'func';\n\n/**\n * Some types accept parameters which define the type in more detail (such as `arrayOf`, `instanceOf`, `oneOf`, etc). Those are stored in `<typeValue>`. The data type of `<typeValue>` depends on the type definition.\n */\ntype RdTypeValue = string;\n\ntype RdProps = {\n [prop: string]: {\n defaultValue?: {\n value: string;\n computed: boolean;\n };\n type: {\n name: RdTypeName;\n value?: RdTypeValue;\n raw?: string;\n };\n flowType?: string;\n tsType?: string;\n description?: string;\n required: boolean;\n };\n};\n\ntype RdResults = {\n /**\n * Name of function, class, or const\n */\n displayName: string;\n description?: string;\n props: RdProps;\n};\n\nfunction renderUsageTemplate({\n templateName,\n attributes,\n children,\n}: {\n templateName: string;\n attributes: string;\n children: string;\n}) {\n return `\n <${templateName}\n ${attributes}\n ${\n children\n ? `>\n ${children}\n </${templateName}>`\n : '/>'\n }\n `;\n}\nexport const demoAppName = 'DemoApp';\n\nfunction renderDemoAppTemplate({\n imports = '',\n children,\n}: {\n imports: string;\n children: string;\n}) {\n return `${imports}\n\nfunction ${demoAppName}() {\n return (\n ${children}\n )\n}\n`;\n}\n\nexport async function getUsage(data: {\n templateName: string;\n props?: Record<string, unknown>;\n children?: string;\n extraProps?: {\n key: string;\n value: string;\n }[];\n format?: boolean;\n}): Promise<string> {\n const props = Object.keys(data.props || {}).map((key) => {\n const value = data.props[key];\n return {\n key,\n value,\n };\n });\n\n const { templateName, children, extraProps = [] } = data;\n if (!templateName) {\n throw new Error(\n `Cannot getUsage of a React Component when no \"templateName\" is provided.`,\n );\n }\n\n const attributes: string[] = props.map(({ key, value }) => {\n switch (typeof value) {\n case 'string':\n // Is this a function like `() => {}` but not a \"sizes\" attribute for an image like `(min-width: 400px) 50vw, 100vw`?\n if (value.startsWith('(') && value.includes('=>')) {\n return `${key}={${value}}`;\n }\n return `${key}=\"${value}\"`;\n case 'boolean':\n return value ? `${key}` : `${key}={${value}}`;\n default:\n return `${key}={${JSON.stringify(value)}}`;\n }\n });\n\n const extraAttributes: string[] = [];\n const slotProps: { [key: string]: string[] } = {};\n\n extraProps.forEach(({ key, value }) => {\n slotProps[key] = slotProps[key] ?? [];\n slotProps[key].push(value);\n });\n\n Object.entries(slotProps).forEach(([key, values]) => {\n const value = values.length === 1 ? values[0] : `<>${values.join('\\n')}</>`;\n extraAttributes.push(`${key}={${value}}`);\n });\n\n const result = renderUsageTemplate({\n templateName,\n attributes: [...attributes, ...extraAttributes].join(' '),\n children,\n });\n return data.format\n ? formatCode({\n contents: result,\n path: 'x.tsx', // doing this to set format language\n })\n .then((code) => code.trim())\n .catch(() => result.trim()) // if format fails, just return the unformatted code\n : result.trim();\n}\n\nexport async function getDemoAppUsage({\n children,\n imports,\n format,\n}: {\n children: string;\n imports?: string;\n format?: boolean;\n}): Promise<string> {\n const code = renderDemoAppTemplate({\n children,\n imports,\n });\n if (!format) return code;\n return formatCode({\n contents: code,\n path: 'x.tsx', // doing this to set format language\n });\n}\n\nasync function getTypeScriptInfoFromFile({ src }: { src: string }): Promise<{\n info: ComponentDoc[];\n}> {\n const tsConfigPath = await findUp('tsconfig.json', {\n cwd: path.dirname(src),\n });\n const rdTs = await import('react-docgen-typescript');\n const config: ParserOptions = {\n shouldExtractLiteralValuesFromEnum: true,\n savePropValueAsString: true,\n skipChildrenPropWithoutDoc: false,\n // In addition to the ones listed here, which had not strangely included these below ~ https://github.com/styleguidist/react-docgen-typescript/blob/287e7012843cb26fed8f4bd8ee24e462c25a1414/src/parser.ts#L308\n customComponentTypes: ['VoidFunctionComponent', 'VFC'],\n };\n const parse = tsConfigPath\n ? rdTs.withCustomConfig(tsConfigPath, config).parse\n : rdTs.withDefaultConfig(config).parse;\n return {\n info: parse(src),\n };\n}\n\nfunction extractSpecFromTypeScriptInfo({\n info: results,\n exportName,\n}: {\n info: ComponentDoc[];\n exportName: string;\n}): KsTemplateSpec | false {\n try {\n if (!results) return false;\n const spec: KsTemplateSpec = {\n props: {\n $schema: 'http://json-schema.org/draft-07/schema',\n type: 'object',\n required: [],\n properties: {},\n },\n slots: {\n // children: {\n // title: 'children',\n // },\n },\n };\n\n const isDefaultExport = !exportName || exportName === 'default';\n\n // if `isDefaultExport` then we just grab last result since `export default` TENDS to be last. that'll we can do really...\n const result = isDefaultExport\n ? results.pop()\n : results.find((r) => r.displayName === exportName);\n\n // log.inspect({ result, isDefaultExport, exportName }, 'ts result');\n if (!result) return false;\n\n const { displayName } = result;\n // log.inspect({ result }, 'result');\n Object.entries(result?.props || {}).forEach(([propName, propDef]) => {\n const { name, description, defaultValue, required, type, parent } =\n propDef;\n\n // `type.name` can include `| undefined` if tsConfig has `strict: true`. So we need to handle these scenarios:\n // `string` or `string | undefined`\n // `'left' | 'right'` or `'left' | 'right' | undefined`\n const propType = type?.name\n ?.replace('| undefined', '')\n // remove generics. things like `FC<{}>` and `FC<Props>` should become `FC`\n .replace(/<.*/g, '')\n .trim();\n\n switch (propType) {\n case 'string':\n spec.props.properties[propName] = {\n type: 'string',\n };\n break;\n case 'number':\n spec.props.properties[propName] = {\n type: 'number',\n };\n break;\n case 'boolean':\n case 'bool':\n if (defaultValue && 'value' in defaultValue) {\n // comes in as `'true'` - this turns it to `true`\n defaultValue.value = defaultValue.value === 'true';\n }\n spec.props.properties[propName] = {\n type: 'boolean',\n };\n break;\n case 'enum':\n type EnumType = {\n name: string;\n raw: string;\n value: {\n /** Looks like `'\"option1\"'` - beware of string that contains `\"` */\n value: string;\n }[];\n };\n spec.props.properties[propName] = {\n type: 'string',\n // yes there is a double \"value\" & yes it is confusing\n enum: [\n // ensure list is unique\n ...new Set<string>(\n (type as EnumType).value\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","import type { Demo, Except } from '@knapsack/types';\nimport type { ComponentType } from 'react';\nimport type { RendererMetaBase } from '@knapsack/renderer-webpack-base/client';\n\nexport type Component = ComponentType<Record<string, unknown>>;\n\nexport type DemoWrapperProps = {\n children: React.ReactNode;\n demo: Demo;\n patternId: string;\n templateId: string;\n};\n\nexport type ExtraJsImportNames = 'DemoWrapper' | 'ErrorCatcher';\n/**\n * Found as JSON in HTML `#ks-react-meta`\n */\nexport type KsReactMeta = {\n disableReactStrictMode: boolean;\n demo: Demo;\n demoWrapperProps: Except<DemoWrapperProps, 'children'>;\n} & RendererMetaBase;\n\nexport const rendererMetaScriptTagId = 'ks-react-meta';\n\nexport type RendererMethods = {\n getDemoApp: (components: Record<string, Component>) => Component;\n};\n","import sleep from 'sleep-promise';\nimport {\n RendererWebpackBase,\n Renderer,\n KsJsImportMap,\n convertImportMapToNeededImportsByCodeSrcId,\n} from '@knapsack/renderer-webpack-base';\nimport { pascalCase, isFirstLetterCapital } from '@knapsack/utils';\nimport { knapsackEvents, log } from '@knapsack/app';\nimport {\n Renderable,\n babelCodeForBrowser,\n createSlotOptionsHtmlTags,\n} from '@knapsack/app/renderers';\nimport {\n KnapsackFile,\n KnapsackPatternTemplate,\n KsTemplateSpec,\n TemplateSuggestion,\n rendererIds,\n RendererId,\n} from '@knapsack/types';\nimport {\n exists as fileExists,\n findUpPkgJson,\n getJsExportNames,\n readFile,\n formatCode,\n} from '@knapsack/file-utils';\nimport { join, relative, parse } from 'path';\nimport {\n clearInferSpecCache,\n copyReactAssets,\n demoAppName,\n getDemoAppUsage,\n getReactDocs,\n getUsage,\n} from './utils';\nimport { createReactPattern } from './react-creators';\nimport {\n ExtraJsImportNames,\n KsReactMeta,\n rendererMetaScriptTagId,\n} from './types';\n\nconst { pkg } = findUpPkgJson(__dirname);\n// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\nlog.setupUpdateNotifier({ ...pkg, name: pkg.name!, version: pkg.version! });\n\nconst errorCatcherAbsolutePath = join(__dirname, './error-catcher.mjs');\nif (!fileExists(errorCatcherAbsolutePath)) {\n throw new Error(\n `Could not find error catcher at: ${errorCatcherAbsolutePath}`,\n );\n}\n\nexport class KnapsackReactRenderer\n extends RendererWebpackBase\n implements Renderable\n{\n /**\n * `react.js` & `react-dom.js` root relative paths\n */\n assets: string[];\n babelConfig: Record<string, unknown>;\n #demoWrapperPath: string;\n #disableReactStrictMode?: boolean;\n\n constructor({\n webpackConfig,\n demoWrapperPath = join(__dirname, './demo-wrapper.mjs'),\n id = rendererIds.react,\n disableReactStrictMode,\n }: {\n webpackConfig?: ConstructorParameters<\n typeof RendererWebpackBase\n >[0]['webpackConfig'];\n demoWrapperPath?: string;\n /** When using React v18+, this option allows a workspace to _disable_ React's Strict Mode from running in Knapsack's React Renderer (StrictMode is enabled by default).\n *\n * See https://reactjs.org/docs/strict-mode.html for more info\n * */\n disableReactStrictMode?: boolean;\n /** Don't set if calling from `knapsack.config.js`, only use if creating a new Renderer based on the React Renderer */\n id?: RendererId;\n } = {}) {\n super({\n id,\n language: 'jsx',\n webpackConfig,\n extraScripts: [\n // this is the code in `./client/init.mts`\n '@knapsack/renderer-react/client',\n ],\n });\n this.language = 'jsx';\n this.assets = [];\n this.#demoWrapperPath = demoWrapperPath;\n this.#disableReactStrictMode = disableReactStrictMode;\n this.creators = [createReactPattern];\n }\n\n override setConfig: Renderer['setConfig'] = (opt) => {\n super.setConfig(opt);\n const {\n absolutePath,\n exists: demoWrapperPathExists,\n type,\n } = this.resolvePathSync({\n path: this.#demoWrapperPath,\n resolveFromDir: this.userConfigDir,\n });\n if (!demoWrapperPathExists) {\n throw new Error(\n `Could not find demo wrapper at: \"${\n this.#demoWrapperPath\n }\"\\nPlease adjust setting in \"knapsack.config.js\" or pass a different path when creating the React Renderer.`,\n );\n }\n this.registerExtraJsImports<ExtraJsImportNames>({\n DemoWrapper: {\n exportName: 'DemoWrapper',\n isDefaultExport: true,\n path: type === 'package' ? this.#demoWrapperPath : absolutePath,\n },\n ErrorCatcher: {\n exportName: 'ErrorCatcher',\n isDefaultExport: true,\n path: errorCatcherAbsolutePath,\n },\n });\n };\n\n init: Renderer['init'] = async () => {\n this.assets = await copyReactAssets(this.outputDir, this.publicPath);\n };\n\n override hydrate: Renderer['hydrate'] = async (opt) => {\n await super.hydrate(opt);\n await this.init({ missingFileVerbosity: 'silent' });\n };\n\n getMeta: Renderer['getMeta'] = () => ({\n id: this.id,\n title: 'React',\n aliasUse: 'optional',\n aliasTitle: 'Named Export',\n aliasIsJsNamedExport: true,\n aliasDescription:\n 'If `export X` was used instead of `export default`, then provide X.',\n enableDataDemos: true,\n enableTemplateDemos: true,\n hasSlotsSupport: true,\n hasSlotOptionsSupport: true,\n version: pkg.version,\n hasInferSpecSupport: true,\n syntaxHighlightingLanguage: 'jsx',\n hasTemplateSuggestionsSupport: true,\n prototypingTemplate: {\n path: '@knapsack/renderer-react/prototype-template',\n spec: {\n isInferred: false,\n props: {\n type: 'object',\n properties: {},\n },\n slots: {\n children: { title: 'Children' },\n },\n },\n },\n });\n\n override changeCase: Renderer['changeCase'] = (str) => pascalCase(str);\n\n override createWebpackConfig: RendererWebpackBase['createWebpackConfig'] =\n () => {\n const config = super.createWebpackConfig();\n\n config.externals = {\n react: 'React',\n 'react-dom': 'ReactDOM',\n };\n\n return config;\n };\n\n async prepClientRenderResults({\n usage,\n demoApp,\n importMap,\n renderOptions: { demo, state, patternId, templateId },\n }: {\n usage: string;\n demoApp: string;\n importMap: KsJsImportMap;\n renderOptions: Parameters<Renderer['render']>[0];\n }): ReturnType<Renderer['render']> {\n const meta = {\n demo,\n disableReactStrictMode: this.#disableReactStrictMode,\n neededImportsByCodeSrcId:\n convertImportMapToNeededImportsByCodeSrcId(importMap),\n demoWrapperProps: {\n patternId,\n templateId,\n demo,\n },\n } as const satisfies KsReactMeta;\n\n let code = `\n window.knapsack = window.knapsack || {};\n window.knapsack.getDemoApp = ({ ${[...importMap.keys()].join(', ')} }) => {\n ${demoApp}\n return ${demoAppName}\n }\n `;\n\n let errorHtmlMsg = '';\n try {\n code = await babelCodeForBrowser({ code });\n } catch (e) {\n console.log(code);\n console.log('---original code before babel error ^---');\n console.trace(e.message);\n code = `console.error(${JSON.stringify(e.message)});`;\n errorHtmlMsg = `<pre><code>${e.message}</code></pre>`;\n }\n\n const html = `\n <script type=\"application/json\" id=\"${rendererMetaScriptTagId}\">${JSON.stringify(\n meta,\n )}</script>\n <script type=\"application/javascript\">${code}</script>\n <div id=\"render-root\" class=\"knapsack-pattern-direct-parent\" data-dev-note=\"Knapsack React Template Wrapper\"></div>\n ${this.assets.map((asset) => `<script src=\"${asset}\"></script>`).join('\\n')}\n ${RendererWebpackBase.createHtmlTagsForAssetPaths({\n assets: this.getWebpackAssetPaths(),\n // we need the scripts to finish adding methods to the global knapsack object synchronously before the client-side code runs that is in the <script> tag below\n scriptTagsAreAsync: false,\n })}\n ${errorHtmlMsg}\n `;\n\n return {\n ok: !errorHtmlMsg,\n html: await formatCode({\n contents: html,\n path: 'x.html', // doing this to set format language\n }),\n usage,\n templateLanguage: this.language,\n };\n }\n\n render: Renderer['render'] = async (opt) => {\n if (opt.demo?.type === 'template') {\n // when getting a template demos path sometimes we have a race condition where the client asks for it before the server knows about it.\n // so we try several times in a row to get it\n /** The amount of time in ms to wait between attempts; when we run out of array items, we give up and throw the error */\n const waits = [5, 10, 20, 50, 100, 1000, 1000];\n let templateDemoPath: string;\n let attempt = 0;\n\n while (true) {\n try {\n const { absolutePath, exists } = await this.resolvePath(\n opt.demo.templateInfo.path,\n );\n if (!exists) {\n throw new Error(\n `Template demo file does not exist: ${absolutePath}`,\n );\n }\n templateDemoPath = absolutePath;\n // got it!\n break;\n } catch (e) {\n const waitTime = waits[attempt];\n if (!waitTime) {\n throw new Error(e);\n }\n attempt += 1;\n // eslint-disable-next-line no-await-in-loop\n await sleep(waitTime);\n }\n }\n const [templateFileContents, { usage, importMap }] = await Promise.all([\n readFile(templateDemoPath),\n this.getUsageAndImports({\n ...opt,\n importMap: new Map(),\n }),\n ]);\n const demoApp = await getDemoAppUsage({\n children: usage,\n });\n const results = await this.prepClientRenderResults({\n usage: templateFileContents,\n demoApp,\n renderOptions: opt,\n importMap,\n });\n\n return results;\n }\n\n if (opt.demo?.type === 'data') {\n const { usage, importMap } = await this.getUsageAndImports({\n ...opt,\n importMap: new Map(),\n });\n const importCode = RendererWebpackBase.createJsImportCodeBlock({\n importMap,\n });\n const [demoAppUsage, demoApp] = await Promise.all([\n getDemoAppUsage({\n children: usage,\n imports: importCode,\n format: true,\n }),\n getDemoAppUsage({\n children: usage,\n }),\n ]);\n\n return this.prepClientRenderResults({\n demoApp,\n usage: demoAppUsage,\n renderOptions: opt,\n importMap,\n });\n }\n };\n\n getUsageAndImports: RendererWebpackBase['getUsageAndImports'] = async ({\n patternId,\n templateId,\n demo,\n state,\n importMap,\n }) => {\n if (!demo) {\n throw new Error(\n `No demo provided while rendering ${patternId} ${templateId}`,\n );\n }\n const pattern = state.patterns[patternId];\n if (!pattern) {\n throw new Error(`Could not find pattern: ${patternId}`);\n }\n if (demo.type === 'data') {\n const template = pattern.templates.find((t) => t.id === templateId);\n if (!template) {\n throw new Error(`Could not find template: ${templateId}`);\n }\n const {\n data: { props, slots, slotsOptionsComputed },\n } = demo;\n const { name: templateName } = await this.addUniqueValueToImportMap({\n importMap,\n path: template.path,\n alias: template.alias || 'default',\n });\n\n const children: string[] = [];\n const extraProps: { key: string; value: string }[] = [];\n\n if (slots) {\n const slotNames = Object.keys(slots);\n const slotUsages = await Promise.all(\n slotNames.map(async (slotName) => {\n const slotItems = slots[slotName];\n const slotItemsUsages = await Promise.all(\n slotItems\n // remove any incomplete item - happens when users are filling out form\n .filter((slotItem) => {\n if (!slotItem) return false;\n if (slotItem.type !== 'text') {\n if (!slotItem.patternId) return false;\n if (!slotItem.templateId) return false;\n if (slotItem.type === 'template-demo' && !slotItem.demoId) {\n return false;\n }\n }\n return true;\n })\n .map(async (slotItem) => {\n if (slotItem.type === 'text') {\n if (slotItems.length === 1 && slotName !== 'children') {\n // The ` prevents multi-line strings from causing error (even though they don't show a line break)\n return `\\`${slotItem.text}\\``;\n }\n return slotItem.text;\n }\n if (slotItem.type === 'template-reference') {\n const slottedTemplate = state.patterns[\n slotItem.patternId\n ]?.templates.find((t) => t.id === slotItem.templateId);\n if (!slottedTemplate) {\n throw new Error(\n `Could not find slotted template: ${slotItem.patternId} ${slotItem.templateId}`,\n );\n }\n const templateRefImport =\n await this.addUniqueValueToImportMap({\n importMap,\n path: slottedTemplate.path,\n alias: slottedTemplate.alias || 'default',\n });\n /**\n * i.e. Given a React Component, `Button`, normally this would be `<Button>` with a demo, but since there is none this will just be a reference to it: `Button`\n * @see {KsSlotInfo['isTemplateReference']}\n * @see {SlottedTemplate}\n */\n return templateRefImport.name;\n }\n if (slotItem.type === 'template-demo') {\n const thisDemo = slotItem.demo;\n if (!thisDemo) {\n throw new Error(\n `Could not find slotted template demo ${JSON.stringify(\n slotItem,\n )}`,\n );\n }\n const { usage } = await this.getUsageAndImports({\n patternId: thisDemo.patternId,\n templateId: thisDemo.templateId,\n demo: thisDemo,\n state,\n importMap,\n });\n return usage;\n }\n const _exhaustiveCheck: never = slotItem;\n throw new Error(\n `Unknown slot item: ${JSON.stringify(slotItem)}`,\n );\n }),\n );\n return {\n slotName,\n slotItemsUsages,\n };\n }),\n );\n\n slotUsages.forEach(({ slotName, slotItemsUsages }) => {\n const slotOptionsComputed = slotsOptionsComputed?.[slotName];\n const { openTag, closeTag } = createSlotOptionsHtmlTags({\n slotOptionsComputed,\n classAttributeName: 'className',\n stylesValueType: 'object',\n });\n if (openTag) {\n if (slotName === 'children') {\n children.push(openTag);\n } else {\n extraProps.push({\n key: slotName,\n value: openTag,\n });\n }\n }\n\n slotItemsUsages.forEach((usage) => {\n if (slotName === 'children') {\n children.push(usage);\n } else {\n extraProps.push({\n key: slotName,\n value: usage,\n });\n }\n });\n\n if (closeTag) {\n if (slotName === 'children') {\n children.push(closeTag);\n } else {\n extraProps.push({\n key: slotName,\n value: closeTag,\n });\n }\n }\n });\n }\n\n const usage = await getUsage({\n templateName,\n props,\n children: children.join('\\n'),\n extraProps,\n });\n\n return {\n usage,\n importMap,\n };\n }\n\n if (demo.type === 'template') {\n const { templateInfo } = demo;\n const { name: templateName } = await this.addUniqueValueToImportMap({\n importMap,\n path: templateInfo.path,\n alias: templateInfo.alias || 'default',\n });\n const usage = await getUsage({ templateName });\n\n return {\n usage,\n importMap,\n };\n }\n\n const _exhaustiveCheck: never = demo;\n throw new Error(\n `Unhandled demo type for ${patternId}-${templateId}: ${JSON.stringify(\n demo,\n )}`,\n );\n };\n\n inferSpec: Renderer['inferSpec'] = async ({\n template,\n templatePath,\n }: {\n template: KnapsackPatternTemplate;\n templatePath: string;\n }): Promise<KsTemplateSpec | false> => {\n const spec = await getReactDocs({\n src: template.path,\n exportName: template.alias || 'default',\n resolveFromDir: this.config.data,\n });\n if (spec !== false) {\n const totalProps = Object.keys(spec?.props?.properties || {}).length;\n const totalSlots = Object.keys(spec?.slots || {}).length;\n if (totalProps === 0 && totalSlots === 0) {\n return false;\n }\n }\n return spec;\n };\n\n override watch: Renderer['watch'] = async () => {\n super.watch();\n knapsackEvents.onPatternTemplateChanged(() => {\n clearInferSpecCache();\n });\n };\n\n getTemplateMeta: Renderer['getTemplateMeta'] = async ({\n pattern,\n template,\n }) => {\n const files: KnapsackFile[] = [];\n if (template?.spec?.props) {\n const schema = JSON.parse(JSON.stringify(template.spec.props));\n if (template?.spec?.slots) {\n Object.entries(template.spec.slots).forEach(([id, info]) => {\n schema.properties[id] = {\n typeof: 'function',\n tsType: 'React.ReactNode',\n\n description: info.allowedPatternIds\n ? `${info.description}. Only use: ${info.allowedPatternIds.join(\n ', ',\n )}`\n : info.description,\n };\n schema.required = schema.required ?? [];\n if (info.isRequired) schema.required.push(id);\n });\n }\n const typeDefs =\n await KnapsackReactRenderer.convertSchemaToTypeScriptDefs({\n schema,\n title: `${this.changeCase(pattern.id)}Props`,\n // @todo pull in base url\n description: `[Knapsack Docs](http://localhost:3999/pattern/${pattern.id}/${template.id})`,\n patternId: pattern.id,\n templateId: template.id,\n postBanner: `import * as React from 'react';`,\n });\n\n files.push({\n contents: typeDefs,\n encoding: 'utf8',\n path: `${pattern.id}.${template.id}.spec.d.ts`,\n });\n files.push({\n contents: JSON.stringify(schema, null, ' '),\n encoding: 'utf8',\n path: `${pattern.id}.${template.id}.spec.json`,\n });\n }\n return files;\n };\n\n alterTemplateMetaFiles: Renderer['alterTemplateMetaFiles'] = async ({\n files,\n metaDir,\n }) => {\n const imports: string[] = [];\n\n const ext = '.spec.d.ts';\n files.forEach((file) => {\n if (file.path.endsWith(ext)) {\n const { base } = parse(file.path);\n const [patternId, templateId] = base.split('.');\n const isFirst = templateId === this.id;\n const exportName = this.changeCase(`${patternId}Props`);\n const exportNameWithTemplateId = this.changeCase(\n `${patternId}-${templateId}Props`,\n );\n imports.push(\n `export { ${\n isFirst\n ? exportName\n : `${exportName} as ${exportNameWithTemplateId}`\n } } from './${relative(metaDir, file.path).replace('.d.ts', '')}';`,\n );\n }\n });\n\n // extra line at end of file\n imports.push('');\n\n return [\n ...files,\n {\n contents: imports.join('\\n'),\n encoding: 'utf8',\n path: join(metaDir, 'react.d.ts'),\n },\n ];\n };\n\n getTemplateSuggestions: Renderer['getTemplateSuggestions'] = async ({\n newPath,\n state,\n }) => {\n const usedSuggestions = Object.values(state.patterns).reduce(\n (acc, { templateDemos, templates }) => {\n templates.forEach(({ path, alias, templateLanguageId }) => {\n if (templateLanguageId !== this.id) return;\n acc.push({ path, alias });\n });\n templateDemos.forEach(\n ({ templateInfo: { path, alias }, templateLanguageId }) => {\n if (templateLanguageId !== this.id) return;\n acc.push({ path, alias });\n },\n );\n return acc;\n },\n [] as TemplateSuggestion[],\n );\n\n const codeSrcs = new Set(this.getCodeSrcs().map(({ path }) => path));\n\n const allPaths = [\n ...new Set([\n newPath,\n ...Object.keys(this.pkgPathAliases || {}),\n ...codeSrcs,\n ]),\n ];\n const allSuggestions: TemplateSuggestion[] = await Promise.all(\n allPaths.map(async (path): Promise<TemplateSuggestion[]> => {\n if (!path) return [];\n try {\n const { exports, errorMsg } = await getJsExportNames({\n path,\n resolveFromDir: this.dataDir,\n pkgPathAliases: this.pkgPathAliases,\n });\n if (errorMsg) {\n throw new Error(errorMsg);\n }\n return (\n exports\n // only allow names that start with a capital letter (i.e. React Component names)\n // will exclude helper functions and custom hooks\n .filter((e) => e === 'default' || isFirstLetterCapital(e))\n .map((name) => ({\n alias: name,\n path,\n }))\n );\n } catch (e) {\n // only want this showing with verbose since template suggestions are not critical\n log.verbose(\n `Error getting import names for ${path}: ${e.message}`,\n null,\n this.logPrefix,\n );\n return [];\n }\n }),\n ).then((results) => {\n // sadly `Promise.all` & `.flatMap` just don't work, so this:\n return results.flat();\n });\n\n const suggestions = allSuggestions.filter((s) => {\n return !usedSuggestions.find(\n (us) => us.alias === s.alias && us.path === s.path,\n );\n });\n\n return {\n suggestions,\n };\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
@@ -0,0 +1,20 @@
1
+ export declare const createReactPattern: import("@knapsack/creator-utils").Creator<{
2
+ pkgPath: {
3
+ type: "text";
4
+ title: string;
5
+ };
6
+ importPrefix: {
7
+ type: "text";
8
+ title: string;
9
+ };
10
+ }, import("@knapsack/creator-utils").KsAnswers<{
11
+ pkgPath: {
12
+ type: "text";
13
+ title: string;
14
+ };
15
+ importPrefix: {
16
+ type: "text";
17
+ title: string;
18
+ };
19
+ }>>;
20
+ //# sourceMappingURL=react-creators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-creators.d.ts","sourceRoot":"","sources":["../src/react-creators.ts"],"names":[],"mappings":"AAgEA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;GAsI7B,CAAC"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createReactPattern = void 0;
4
+ const file_utils_1 = require("@knapsack/file-utils");
5
+ const creator_utils_1 = require("@knapsack/creator-utils");
6
+ const ks_file_utils_1 = require("@knapsack/ks-file-utils");
7
+ const utils_1 = require("@knapsack/utils");
8
+ function isCapitalLetter(char) {
9
+ return char.toUpperCase() === char;
10
+ }
11
+ function startsWithCapitalLetter(str) {
12
+ return isCapitalLetter(str[0]);
13
+ }
14
+ function createPatternData({ importName, id, title = importName, pkgPath, initialDemoId, }) {
15
+ return {
16
+ id,
17
+ title,
18
+ description: '',
19
+ statuses: {
20
+ main: 'ready',
21
+ },
22
+ templates: [
23
+ {
24
+ id: 'react',
25
+ title: 'react',
26
+ path: pkgPath,
27
+ alias: importName,
28
+ templateLanguageId: 'react',
29
+ spec: {
30
+ isInferred: true,
31
+ },
32
+ demoIds: [initialDemoId],
33
+ blockIds: [],
34
+ },
35
+ ],
36
+ tabs: [
37
+ {
38
+ type: 'template',
39
+ id: 'react',
40
+ },
41
+ ],
42
+ subPages: [],
43
+ };
44
+ }
45
+ exports.createReactPattern = (0, creator_utils_1.createCreator)({
46
+ id: 'react-patterns',
47
+ title: 'React Ks Patterns',
48
+ description: 'Adds React templates as Knapsack Patterns',
49
+ getQuestions: async () => ({
50
+ pkgPath: {
51
+ type: 'text',
52
+ title: 'Package path',
53
+ },
54
+ importPrefix: {
55
+ type: 'text',
56
+ title: 'Import Prefix to Remove',
57
+ },
58
+ }),
59
+ getTasks: async ({ answers: { pkgPath, importPrefix = '' }, config }) => {
60
+ const dataDir = config.dest;
61
+ const currentPatterns = await (0, ks_file_utils_1.readKsPatternConfigs)({
62
+ dataDir,
63
+ });
64
+ const currentReactPatternsImportNames = currentPatterns.reduce((cur, pattern) => {
65
+ var _a, _b;
66
+ const reactTemplates = (_b = (_a = pattern.templates) === null || _a === void 0 ? void 0 : _a.filter((t) => t.templateLanguageId === 'react')) !== null && _b !== void 0 ? _b : [];
67
+ cur.push(...reactTemplates.map((t) => t.alias));
68
+ return cur;
69
+ }, []);
70
+ const { exports: allImports } = await (0, file_utils_1.getJsExportNames)({
71
+ path: pkgPath,
72
+ });
73
+ return [
74
+ {
75
+ title: 'Pick Imports to add',
76
+ task: (_, task) => creator_utils_1.tasks.runSubCreator({
77
+ task,
78
+ config,
79
+ creator: (0, creator_utils_1.createCreator)({
80
+ id: 'react-pattern-import-names',
81
+ getQuestions: async () => ({
82
+ importNames: {
83
+ type: 'choices',
84
+ choices: allImports
85
+ .filter((importName) => startsWithCapitalLetter(importName) &&
86
+ !currentReactPatternsImportNames.includes(importName))
87
+ .map((importName) => ({
88
+ value: importName,
89
+ })),
90
+ },
91
+ }),
92
+ getTasks: async ({ answers }) => {
93
+ // not sure why TS failed to infer this. happened during turning on strictNullChecks
94
+ const { importNames } = answers;
95
+ const patterns = importNames.map((importName) => ({
96
+ importName,
97
+ patternId: importName.startsWith(importPrefix)
98
+ ? importName.slice(importPrefix.length).toLowerCase()
99
+ : importName.toLowerCase(),
100
+ }));
101
+ return [
102
+ ...patterns.map(({ importName, patternId }) => ({
103
+ title: `Add ${importName} React Template`,
104
+ task: async (__, subTask) => {
105
+ const initialDemo = {
106
+ type: 'data',
107
+ id: (0, utils_1.makeShortId)(),
108
+ title: 'Main',
109
+ patternId,
110
+ templateId: 'react',
111
+ data: {
112
+ props: {},
113
+ slots: {},
114
+ },
115
+ };
116
+ const pattern = createPatternData({
117
+ id: patternId,
118
+ importName,
119
+ pkgPath,
120
+ initialDemoId: initialDemo.id,
121
+ });
122
+ await Promise.all([
123
+ (0, ks_file_utils_1.writeDemo)({
124
+ dataDir,
125
+ demo: initialDemo,
126
+ }),
127
+ (0, ks_file_utils_1.writeKsPatternConfig)({
128
+ dataDir,
129
+ patternId,
130
+ data: pattern,
131
+ }),
132
+ ]);
133
+ },
134
+ })),
135
+ {
136
+ title: `Updating Nav`,
137
+ task: async (__, subTask) => {
138
+ const { byId } = await (0, ks_file_utils_1.readKsNavConfig)({
139
+ dataDir,
140
+ });
141
+ // attempt to find a nav group to put patterns under
142
+ const componentsGroup = Object.values(byId).find(({ path, name, id }) => {
143
+ // we only want groups (i.e. not pages or patterns)
144
+ if (path)
145
+ return false;
146
+ if (name.toLowerCase() === 'patterns')
147
+ return true;
148
+ if (name.toLowerCase() === 'components')
149
+ return true;
150
+ return false;
151
+ });
152
+ await (0, ks_file_utils_1.addKsNavItems)({
153
+ dataDir,
154
+ navItems: patterns.map(({ patternId }) => ({
155
+ navId: patternId,
156
+ navPath: `/pattern/${patternId}`,
157
+ navParent: (componentsGroup === null || componentsGroup === void 0 ? void 0 : componentsGroup.id) || 'root',
158
+ })),
159
+ });
160
+ },
161
+ },
162
+ ];
163
+ },
164
+ }),
165
+ }),
166
+ },
167
+ ];
168
+ },
169
+ });
170
+ //# sourceMappingURL=react-creators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-creators.js","sourceRoot":"","sources":["../src/react-creators.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AACxD,2DAAqE;AACrE,2DAMiC;AAEjC,2CAA8C;AAE9C,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC;AACrC,CAAC;AAED,SAAS,uBAAuB,CAAC,GAAW;IAC1C,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,iBAAiB,CAAC,EACzB,UAAU,EACV,EAAE,EACF,KAAK,GAAG,UAAU,EAClB,OAAO,EACP,aAAa,GAOd;IACC,OAAO;QACL,EAAE;QACF,KAAK;QACL,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,IAAI,EAAE,OAAO;SACd;QACD,SAAS,EAAE;YACT;gBACE,EAAE,EAAE,OAAO;gBACX,KAAK,EAAE,OAAO;gBACd,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,UAAU;gBACjB,kBAAkB,EAAE,OAAO;gBAC3B,IAAI,EAAE;oBACJ,UAAU,EAAE,IAAI;iBACjB;gBACD,OAAO,EAAE,CAAC,aAAa,CAAC;gBACxB,QAAQ,EAAE,EAAE;aACb;SACF;QACD,IAAI,EAAE;YACJ;gBACE,IAAI,EAAE,UAAU;gBAChB,EAAE,EAAE,OAAO;aACZ;SACF;QACD,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAEY,QAAA,kBAAkB,GAAG,IAAA,6BAAa,EAAC;IAC9C,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,2CAA2C;IACxD,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;QACzB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YAC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CACL,CAAC;iCACF;6BACF,CAAC;wBACJ,CAAC;qBACF,CAAC;iBACH,CAAC;aACL;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -1,9 +1,7 @@
1
1
  import { RendererWebpackBase, Renderer, KsJsImportMap } from '@knapsack/renderer-webpack-base';
2
2
  import { Renderable } from '@knapsack/app/renderers';
3
3
  import { RendererId } from '@knapsack/types';
4
- export { D as DemoWrapperProps } from './types-CivTHEEo.mjs';
5
-
6
- declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
4
+ export declare class KnapsackReactRenderer extends RendererWebpackBase implements Renderable {
7
5
  #private;
8
6
  /**
9
7
  * `react.js` & `react-dom.js` root relative paths
@@ -41,5 +39,4 @@ declare class KnapsackReactRenderer extends RendererWebpackBase implements Rende
41
39
  alterTemplateMetaFiles: Renderer['alterTemplateMetaFiles'];
42
40
  getTemplateSuggestions: Renderer['getTemplateSuggestions'];
43
41
  }
44
-
45
- export { KnapsackReactRenderer };
42
+ //# sourceMappingURL=renderer-react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer-react.d.ts","sourceRoot":"","sources":["../src/renderer-react.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,aAAa,EAEd,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,UAAU,EAGX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAML,UAAU,EACX,MAAM,iBAAiB,CAAC;AA2BzB,qBAAa,qBACX,SAAQ,mBACR,YAAW,UAAU;;IAErB;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAIzB,EACV,aAAa,EACb,eAAe,EACf,EAAsB,EACtB,sBAAsB,GACvB,GAAE;QACD,aAAa,CAAC,EAAE,qBAAqB,CACnC,OAAO,mBAAmB,CAC3B,CAAC,CAAC,CAAC,CAAC,eAAe,CA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