@builder.io/dev-tools 1.0.19 → 1.1.0-rc0
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/README.md +2 -0
- package/cli/index.cjs +877 -1
- package/core/index.cjs +1 -1
- package/core/index.mjs +1 -1
- package/package.json +36 -5
- package/server/index.cjs +3 -5
- package/server/index.mjs +3 -5
- package/types/cli/add.d.ts +53 -0
- package/types/cli/credentials.d.ts +31 -0
- package/types/cli/download.d.ts +10 -0
- package/types/cli/figma-publish.d.ts +39 -0
- package/types/cli/figma.d.ts +9 -0
- package/types/cli/help.d.ts +1 -0
- package/types/cli/prettier.d.ts +1 -0
- package/types/figma/index.d.ts +70 -0
- package/types/figma/jsx-runtime/index.d.cts +2 -0
- package/types/figma/jsx-runtime/index.d.ts +2 -0
package/core/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@ ${r}=${n}
|
|
|
19
19
|
name: "${t.name}",
|
|
20
20
|
}
|
|
21
21
|
`,r+=");";let n=nt(e,r);return Dt(e,n,t)}function Dt(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;r.acceptsChildren?e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"||(o[0]=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[o[0]])):e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"&&(o[0]=o[0].arguments[0]);let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=U(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function V(e,t){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let r=await rn(e,t[0]),n=e.join(r,"typescript","lib"),o=new Map,i={fileExists:a=>{if(a=e.normalize(a),a.includes("node_modules")){let s=Ke.get(a);if(!s){try{e.statSync(a).isFile()?s={exists:!0,content:e.readFileSync(a)}:s={exists:!1}}catch{s={exists:!1}}Ke.set(a,s)}return s.exists}return o.has(a)||o.set(a,e.existsSync(a)),o.get(a)},getCanonicalFileName:a=>e.normalize(a),getCurrentDirectory:()=>e.cwd(),getDefaultLibFileName:()=>e.join(n,"lib.d.ts"),getDefaultLibLocation:()=>n,getNewLine:()=>`
|
|
22
|
-
`,getSourceFile:a=>{if(a=e.normalize(a),a.includes("node_modules")){let l=Ke.get(a);if(l)return D(e,l.content)}let s=e.readFileSync(a);if(s==null){let l=e.basename(a),c=e.extname(l).toLowerCase();if(a.startsWith(n)&&c===".ts"&&(s=gn.get(l),s==null&&typeof self<"u"&&typeof fetch=="function"))throw new ot(l)}return a.includes("node_modules")&&(s?Ke.set(a,{exists:!0,content:s}):Ke.set(a,{exists:!1})),D(e,s)},readFile:a=>{let s=e.readFileSync(a);return typeof s=="string"?s:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return ko(e,i,t)}catch(a){if(a instanceof ot){await jo(e,a.libName);continue}throw console.error("createTsProgram",a),new Error(`createTsProgram() Could not create program for: ${t[0]}`)}}function ko(e,t,r){let n={rootNames:[...r],options:{},host:t},o=e.ts.findConfigFile(e.dirname(r[0]),i=>e.existsSync(i));if(o){let i=dn.get(o);if(!i){let a=e.ts.readConfigFile(o,s=>{let l=e.readFileSync(s);return typeof l=="string"?l:void 0});a.error?console.error("error reading tsconfig for createTsProgram"):(i=e.ts.parseJsonConfigFileContent(a.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(l,c)=>e.readdirSync(l),fileExists:l=>e.existsSync(l),readFile:l=>e.readFileSync(l)||void 0},e.dirname(o),void 0,o).options,dn.set(o,i))}i&&(n.options=K(i))}return n.options.moduleResolution=e.ts.ModuleResolutionKind.Node16,n.options.noEmit=!0,n.options.isolatedModules=!1,n.options.strict=!1,n.options.jsx=e.ts.JsxEmit.Preserve,n.options.allowJs=!0,e.ts.createProgram(n)}async function be(e,t,r){r||(r=await V(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var ot=class{constructor(t){this.libName=t}};async function jo(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;rt.has(t)||rt.set(t,fetch(r).then(n=>n.text()).then(n=>{gn.set(t,n)})),await rt.get(t),rt.delete(t)}var gn=new Map,rt=new Map,Ke=new Map,dn=new Map;function E(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=_o(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=Bo(e,t,r.defaultImport,r.importPath,n)),t}function _o(e,t,r,n,o,i){return i==="cjs"?hn(e,t,null,r,n):xn(e,t,null,r,n,o)}function Bo(e,t,r,n,o){return o==="cjs"?hn(e,t,r,null,n):xn(e,t,r,null,n,!1)}function xn(e,t,r,n,o,i){let a=[...t.statements],s=0,l=!1,c=!1;for(let p=0;p<a.length;p++){let x=a[p];if(!e.ts.isImportDeclaration(x)||(s=p,!x.moduleSpecifier||!e.ts.isStringLiteral(x.moduleSpecifier))||x.moduleSpecifier.text!==o||!!x.importClause?.isTypeOnly!==i)continue;let f=[],g=x.importClause?.namedBindings;if(g&&e.ts.isNamedImports(g)&&g.elements&&f.push(...g.elements),typeof n=="string"){if(f.some(C=>C.name.text===n))return t;f.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),f.sort((C,T)=>C.name.text.localeCompare(T.name.text)),l=!0}let h=x.importClause?x.importClause.name:void 0;if(typeof r=="string"){if(h&&h.text===r)return t;h=e.ts.factory.createIdentifier(r),c=!0}if(l||c)return a[p]=e.ts.factory.updateImportDeclaration(x,void 0,e.ts.factory.createImportClause(i,h,e.ts.factory.createNamedImports(f)),x.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let d,m;typeof r=="string"&&(d=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let u=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,d,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,u),e.ts.factory.updateSourceFile(t,a)}function hn(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let l=i[s];if(e.ts.isVariableStatement(l))for(let c=0;c<l.declarationList.declarations.length;c++){let d=[...l.declarationList.declarations],m=d[c],u=m.initializer;if(!u||!e.ts.isCallExpression(u))continue;let p=u.expression;if(!e.ts.isIdentifier(p)||p.text!=="require"||u.arguments.length!==1)continue;let x=u.arguments[0];if(e.ts.isStringLiteral(x)&&(a=s,x.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let f=[...m.name.elements];return f.some(h=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)?!1:h.name.text===n)?t:(f.push(e.ts.factory.createBindingElement(void 0,void 0,n)),f.sort((h,C)=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:h.name.text.localeCompare(C.name.text)),d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(f),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function Q(e,t,r="esm"){return r==="cjs"?$o(e,t):Vo(e,t)}function Vo(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function $o(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function zo(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function Ie(e,t,r,n){let o=zo(e,r,n);if(o){let i=await Ue(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getRootDir(),i);return{displayFilePath:R(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function Ne(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function q(e,t,r){let n=Ne(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function it(e,t){if(t){if(Ko(e,t))return!0;let r=!1;if(t.forEachChild(n=>{it(e,n)&&(r=!0)}),r)return!0}return!1}function Ko(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function Ue(e,t){let r=e.extname(t).toLowerCase();if(r===""||!Et.includes(r)){for(let n of Et){let o=t+n;if(await e.exists(o))return o}for(let n of Et){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var Et=[".tsx",".jsx",".ts",".js"];function Me(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=Uo(e,i);return a?[{name:a}]:void 0}function Uo(e,t){if(typeof t=="string"){t=e.normalize(W(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function te(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}async function Re(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await V(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{if(!a.isRegistered){let s=n.getSourceFile(a.filePath);if(s){let c=(await xe(e,o,a.filePath,s)).find(d=>d.cmpInfo.id===a.id);c&&(a.inputs=Te(e,o,c.node.fnNode))}}return a}))}async function Ae(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await be(e,t.cmpInfo.filePath,r),a=(await xe(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Te(e,o,a.node.fnNode)}return[]}async function Cn(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Mo(e,t,n)}return null}function Mo(e,t,r){let n=D(e,r);return xe(e,null,t,n)}async function xe(e,t,r,n){let o=[];for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isStringLiteral(a.expression)&&a.expression.text==="use server")return o;let i=Q(e,n);return r=e.normalize(r),await Promise.all(i.map(async a=>{let s=await Qo(e,t,r,a);o.push(...s)})),o}async function Qo(e,t,r,n){let o=[],i=e.relative(e.getRootDir(),r),a=_(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!Be(s.name.text))continue;let l=Qe(e,t,s.initializer);if(l){let c=l.name||s.name.text,d=n.isDefaultExport?"default":c,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:j(c),inputs:[],exportName:d,exportType:m,importName:c,filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}}return o}if(e.ts.isArrowFunction(n.node)){let s=Qe(e,t,n.node);if(s){let l=Y(e,r),c=n.isDefaultExport?"default":l,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!Be(s))return o;let l=Qe(e,t,n.node);if(l){let c=l.name||Y(e,r),d=n.isDefaultExport||!l.name?"default":l.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:c,inputs:[],exportName:d,exportType:m,importName:l.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}return o}if(e.ts.isExportSpecifier(n.node)&&Be(n.node.getText())){let s=Qe(e,t,n.node);if(s){let l=s.name||Y(e,r),c=n.isDefaultExport||!s.name?"default":s.name,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:s.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}return o}function Qe(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return it(e,r.body)?{name:"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return it(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(!e.ts.isPropertyAccessExpression(n))return null;let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:Qe(e,t,o[0])}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!Be(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:Me(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:Me(e,t,n)}}return null}async function Sn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(Jo(e,i.fileName)||a===e.reactConfigPath||a===e.registryPath||a===e.builderComponentPath)return;let s=await xe(e,o,a,i);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var qo=new Set(["node_modules","dist"]);function Jo(e,t){for(let r of qo)if(e.dirname(t).includes(r))return!0;return!1}async function Tn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&Wo.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.registryPath||s===e.builderComponentPath)return;let l=await xe(e,o,s,i);r.push(...l)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Wo=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ne(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let l=a.moduleSpecifier.text;if(!l.startsWith(".")&&!l.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...Pt(e,r),...Pt(e,n),...Pt(e,o),...i])}function J(e){let t=e.split(`
|
|
22
|
+
`,getSourceFile:a=>{if(a=e.normalize(a),a.includes("node_modules")){let l=Ke.get(a);if(l)return D(e,l.content)}let s=e.readFileSync(a);if(s==null){let l=e.basename(a),c=e.extname(l).toLowerCase();if(a.startsWith(n)&&c===".ts"&&(s=gn.get(l),s==null&&typeof self<"u"&&typeof fetch=="function"))throw new ot(l)}return a.includes("node_modules")&&(s?Ke.set(a,{exists:!0,content:s}):Ke.set(a,{exists:!1})),D(e,s)},readFile:a=>{let s=e.readFileSync(a);return typeof s=="string"?s:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return ko(e,i,t)}catch(a){if(a instanceof ot){await jo(e,a.libName);continue}throw console.error("createTsProgram",a),new Error(`createTsProgram() Could not create program for: ${t[0]}`)}}function ko(e,t,r){let n={rootNames:[...r],options:{},host:t},o=e.ts.findConfigFile(e.dirname(r[0]),i=>e.existsSync(i));if(o){let i=dn.get(o);if(!i){let a=e.ts.readConfigFile(o,s=>{let l=e.readFileSync(s);return typeof l=="string"?l:void 0});a.error?console.error("error reading tsconfig for createTsProgram"):(i=e.ts.parseJsonConfigFileContent(a.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(l,c)=>e.readdirSync(l),fileExists:l=>e.existsSync(l),readFile:l=>e.readFileSync(l)||void 0},e.dirname(o),void 0,o).options,dn.set(o,i))}i&&(n.options=K(i))}return n.options.moduleResolution=e.ts.ModuleResolutionKind.Node16,n.options.noEmit=!0,n.options.isolatedModules=!1,n.options.strict=!1,n.options.jsx=e.ts.JsxEmit.Preserve,n.options.allowJs=!0,e.ts.createProgram(n)}async function be(e,t,r){r||(r=await V(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var ot=class{constructor(t){this.libName=t}};async function jo(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;rt.has(t)||rt.set(t,fetch(r).then(n=>n.text()).then(n=>{gn.set(t,n)})),await rt.get(t),rt.delete(t)}var gn=new Map,rt=new Map,Ke=new Map,dn=new Map;function E(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=_o(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=Bo(e,t,r.defaultImport,r.importPath,n)),t}function _o(e,t,r,n,o,i){return i==="cjs"?hn(e,t,null,r,n):xn(e,t,null,r,n,o)}function Bo(e,t,r,n,o){return o==="cjs"?hn(e,t,r,null,n):xn(e,t,r,null,n,!1)}function xn(e,t,r,n,o,i){let a=[...t.statements],s=0,l=!1,c=!1;for(let p=0;p<a.length;p++){let x=a[p];if(!e.ts.isImportDeclaration(x)||(s=p,!x.moduleSpecifier||!e.ts.isStringLiteral(x.moduleSpecifier))||x.moduleSpecifier.text!==o||!!x.importClause?.isTypeOnly!==i)continue;let f=[],g=x.importClause?.namedBindings;if(g&&e.ts.isNamedImports(g)&&g.elements&&f.push(...g.elements),typeof n=="string"){if(f.some(C=>C.name.text===n))return t;f.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),f.sort((C,T)=>C.name.text.localeCompare(T.name.text)),l=!0}let h=x.importClause?x.importClause.name:void 0;if(typeof r=="string"){if(h&&h.text===r)return t;h=e.ts.factory.createIdentifier(r),c=!0}if(l||c)return a[p]=e.ts.factory.updateImportDeclaration(x,void 0,e.ts.factory.createImportClause(i,h,e.ts.factory.createNamedImports(f)),x.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let d,m;typeof r=="string"&&(d=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let u=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,d,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,u),e.ts.factory.updateSourceFile(t,a)}function hn(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let l=i[s];if(e.ts.isVariableStatement(l))for(let c=0;c<l.declarationList.declarations.length;c++){let d=[...l.declarationList.declarations],m=d[c],u=m.initializer;if(!u||!e.ts.isCallExpression(u))continue;let p=u.expression;if(!e.ts.isIdentifier(p)||p.text!=="require"||u.arguments.length!==1)continue;let x=u.arguments[0];if(e.ts.isStringLiteral(x)&&(a=s,x.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let f=[...m.name.elements];return f.some(h=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)?!1:h.name.text===n)?t:(f.push(e.ts.factory.createBindingElement(void 0,void 0,n)),f.sort((h,C)=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:h.name.text.localeCompare(C.name.text)),d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(f),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function Q(e,t,r="esm"){return r==="cjs"?$o(e,t):Vo(e,t)}function Vo(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function $o(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function zo(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function Ie(e,t,r,n){let o=zo(e,r,n);if(o){let i=await Ue(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getRootDir(),i);return{displayFilePath:R(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function Ne(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function q(e,t,r){let n=Ne(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function it(e,t){if(t){if(Ko(e,t))return!0;let r=!1;if(t.forEachChild(n=>{it(e,n)&&(r=!0)}),r)return!0}return!1}function Ko(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function Ue(e,t){let r=e.extname(t).toLowerCase();if(r===""||!Et.includes(r)){for(let n of Et){let o=t+n;if(await e.exists(o))return o}for(let n of Et){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var Et=[".tsx",".jsx",".ts",".js"];function Me(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=Uo(e,i);return a?[{name:a}]:void 0}function Uo(e,t){if(typeof t=="string"){t=e.normalize(W(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function te(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}async function Re(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await V(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let c=(await xe(e,o,a.filePath,s)).find(d=>d.cmpInfo.id===a.id);c&&(a.inputs=Te(e,o,c.node.fnNode))}return a}))}async function Ae(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await be(e,t.cmpInfo.filePath,r),a=(await xe(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Te(e,o,a.node.fnNode)}return[]}async function Cn(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Mo(e,t,n)}return null}function Mo(e,t,r){let n=D(e,r);return xe(e,null,t,n)}async function xe(e,t,r,n){let o=[];for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isStringLiteral(a.expression)&&a.expression.text==="use server")return o;let i=Q(e,n);return r=e.normalize(r),await Promise.all(i.map(async a=>{let s=await Qo(e,t,r,a);o.push(...s)})),o}async function Qo(e,t,r,n){let o=[],i=e.relative(e.getRootDir(),r),a=_(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!Be(s.name.text))continue;let l=Qe(e,t,s.initializer);if(l){let c=l.name||s.name.text,d=n.isDefaultExport?"default":c,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:j(c),inputs:[],exportName:d,exportType:m,importName:c,filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}}return o}if(e.ts.isArrowFunction(n.node)){let s=Qe(e,t,n.node);if(s){let l=Y(e,r),c=n.isDefaultExport?"default":l,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!Be(s))return o;let l=Qe(e,t,n.node);if(l){let c=l.name||Y(e,r),d=n.isDefaultExport||!l.name?"default":l.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:c,inputs:[],exportName:d,exportType:m,importName:l.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}return o}if(e.ts.isExportSpecifier(n.node)&&Be(n.node.getText())){let s=Qe(e,t,n.node);if(s){let l=s.name||Y(e,r),c=n.isDefaultExport||!s.name?"default":s.name,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:s.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}return o}function Qe(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return it(e,r.body)?{name:"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return it(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(!e.ts.isPropertyAccessExpression(n))return null;let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:Qe(e,t,o[0])}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!Be(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:Me(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:Me(e,t,n)}}return null}async function Sn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(Jo(e,i.fileName)||a===e.reactConfigPath||a===e.registryPath||a===e.builderComponentPath)return;let s=await xe(e,o,a,i);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var qo=new Set(["node_modules","dist"]);function Jo(e,t){for(let r of qo)if(e.dirname(t).includes(r))return!0;return!1}async function Tn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&Wo.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.registryPath||s===e.builderComponentPath)return;let l=await xe(e,o,s,i);r.push(...l)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Wo=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ne(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let l=a.moduleSpecifier.text;if(!l.startsWith(".")&&!l.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...Pt(e,r),...Pt(e,n),...Pt(e,o),...i])}function J(e){let t=e.split(`
|
|
23
23
|
`).map(n=>n.trimEnd());e="";let r=!1;for(let n=t.length-1;n>=0;n--){let o=t[n];!r&&o.startsWith("import ")&&(r=!0,o=o+`
|
|
24
24
|
`),/^builder.init(.*)$/.test(o)&&(o=o+`
|
|
25
25
|
`),t[n-1]&&!t[n-1].includes("*/")&&(o.trim().startsWith("Builder.registerComponent")&&(o=`
|
package/core/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ ${r}=${n}
|
|
|
19
19
|
name: "${t.name}",
|
|
20
20
|
}
|
|
21
21
|
`,r+=");";let n=et(e,r);return Tt(e,n,t)}function Tt(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;r.acceptsChildren?e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"||(o[0]=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[o[0]])):e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"&&(o[0]=o[0].arguments[0]);let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=U(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function V(e,t){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let r=await Zt(e,t[0]),n=e.join(r,"typescript","lib"),o=new Map,i={fileExists:a=>{if(a=e.normalize(a),a.includes("node_modules")){let s=Ke.get(a);if(!s){try{e.statSync(a).isFile()?s={exists:!0,content:e.readFileSync(a)}:s={exists:!1}}catch{s={exists:!1}}Ke.set(a,s)}return s.exists}return o.has(a)||o.set(a,e.existsSync(a)),o.get(a)},getCanonicalFileName:a=>e.normalize(a),getCurrentDirectory:()=>e.cwd(),getDefaultLibFileName:()=>e.join(n,"lib.d.ts"),getDefaultLibLocation:()=>n,getNewLine:()=>`
|
|
22
|
-
`,getSourceFile:a=>{if(a=e.normalize(a),a.includes("node_modules")){let l=Ke.get(a);if(l)return D(e,l.content)}let s=e.readFileSync(a);if(s==null){let l=e.basename(a),c=e.extname(l).toLowerCase();if(a.startsWith(n)&&c===".ts"&&(s=fn.get(l),s==null&&typeof self<"u"&&typeof fetch=="function"))throw new nt(l)}return a.includes("node_modules")&&(s?Ke.set(a,{exists:!0,content:s}):Ke.set(a,{exists:!1})),D(e,s)},readFile:a=>{let s=e.readFileSync(a);return typeof s=="string"?s:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return No(e,i,t)}catch(a){if(a instanceof nt){await Ro(e,a.libName);continue}throw console.error("createTsProgram",a),new Error(`createTsProgram() Could not create program for: ${t[0]}`)}}function No(e,t,r){let n={rootNames:[...r],options:{},host:t},o=e.ts.findConfigFile(e.dirname(r[0]),i=>e.existsSync(i));if(o){let i=mn.get(o);if(!i){let a=e.ts.readConfigFile(o,s=>{let l=e.readFileSync(s);return typeof l=="string"?l:void 0});a.error?console.error("error reading tsconfig for createTsProgram"):(i=e.ts.parseJsonConfigFileContent(a.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(l,c)=>e.readdirSync(l),fileExists:l=>e.existsSync(l),readFile:l=>e.readFileSync(l)||void 0},e.dirname(o),void 0,o).options,mn.set(o,i))}i&&(n.options=K(i))}return n.options.moduleResolution=e.ts.ModuleResolutionKind.Node16,n.options.noEmit=!0,n.options.isolatedModules=!1,n.options.strict=!1,n.options.jsx=e.ts.JsxEmit.Preserve,n.options.allowJs=!0,e.ts.createProgram(n)}async function be(e,t,r){r||(r=await V(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var nt=class{constructor(t){this.libName=t}};async function Ro(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;tt.has(t)||tt.set(t,fetch(r).then(n=>n.text()).then(n=>{fn.set(t,n)})),await tt.get(t),tt.delete(t)}var fn=new Map,tt=new Map,Ke=new Map,mn=new Map;function E(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=Ao(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=Fo(e,t,r.defaultImport,r.importPath,n)),t}function Ao(e,t,r,n,o,i){return i==="cjs"?gn(e,t,null,r,n):dn(e,t,null,r,n,o)}function Fo(e,t,r,n,o){return o==="cjs"?gn(e,t,r,null,n):dn(e,t,r,null,n,!1)}function dn(e,t,r,n,o,i){let a=[...t.statements],s=0,l=!1,c=!1;for(let p=0;p<a.length;p++){let x=a[p];if(!e.ts.isImportDeclaration(x)||(s=p,!x.moduleSpecifier||!e.ts.isStringLiteral(x.moduleSpecifier))||x.moduleSpecifier.text!==o||!!x.importClause?.isTypeOnly!==i)continue;let f=[],g=x.importClause?.namedBindings;if(g&&e.ts.isNamedImports(g)&&g.elements&&f.push(...g.elements),typeof n=="string"){if(f.some(C=>C.name.text===n))return t;f.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),f.sort((C,T)=>C.name.text.localeCompare(T.name.text)),l=!0}let h=x.importClause?x.importClause.name:void 0;if(typeof r=="string"){if(h&&h.text===r)return t;h=e.ts.factory.createIdentifier(r),c=!0}if(l||c)return a[p]=e.ts.factory.updateImportDeclaration(x,void 0,e.ts.factory.createImportClause(i,h,e.ts.factory.createNamedImports(f)),x.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let d,m;typeof r=="string"&&(d=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let u=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,d,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,u),e.ts.factory.updateSourceFile(t,a)}function gn(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let l=i[s];if(e.ts.isVariableStatement(l))for(let c=0;c<l.declarationList.declarations.length;c++){let d=[...l.declarationList.declarations],m=d[c],u=m.initializer;if(!u||!e.ts.isCallExpression(u))continue;let p=u.expression;if(!e.ts.isIdentifier(p)||p.text!=="require"||u.arguments.length!==1)continue;let x=u.arguments[0];if(e.ts.isStringLiteral(x)&&(a=s,x.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let f=[...m.name.elements];return f.some(h=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)?!1:h.name.text===n)?t:(f.push(e.ts.factory.createBindingElement(void 0,void 0,n)),f.sort((h,C)=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:h.name.text.localeCompare(C.name.text)),d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(f),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function Q(e,t,r="esm"){return r==="cjs"?Oo(e,t):Lo(e,t)}function Lo(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function Oo(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function ko(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function Ie(e,t,r,n){let o=ko(e,r,n);if(o){let i=await Ue(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getRootDir(),i);return{displayFilePath:R(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function Ne(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function q(e,t,r){let n=Ne(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function rt(e,t){if(t){if(jo(e,t))return!0;let r=!1;if(t.forEachChild(n=>{rt(e,n)&&(r=!0)}),r)return!0}return!1}function jo(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function Ue(e,t){let r=e.extname(t).toLowerCase();if(r===""||!yt.includes(r)){for(let n of yt){let o=t+n;if(await e.exists(o))return o}for(let n of yt){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var yt=[".tsx",".jsx",".ts",".js"];function Me(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=_o(e,i);return a?[{name:a}]:void 0}function _o(e,t){if(typeof t=="string"){t=e.normalize(W(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function te(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}async function Re(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await V(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{if(!a.isRegistered){let s=n.getSourceFile(a.filePath);if(s){let c=(await ge(e,o,a.filePath,s)).find(d=>d.cmpInfo.id===a.id);c&&(a.inputs=Te(e,o,c.node.fnNode))}}return a}))}async function Ae(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await be(e,t.cmpInfo.filePath,r),a=(await ge(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Te(e,o,a.node.fnNode)}return[]}async function xn(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Bo(e,t,n)}return null}function Bo(e,t,r){let n=D(e,r);return ge(e,null,t,n)}async function ge(e,t,r,n){let o=[];for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isStringLiteral(a.expression)&&a.expression.text==="use server")return o;let i=Q(e,n);return r=e.normalize(r),await Promise.all(i.map(async a=>{let s=await Vo(e,t,r,a);o.push(...s)})),o}async function Vo(e,t,r,n){let o=[],i=e.relative(e.getRootDir(),r),a=_(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!Be(s.name.text))continue;let l=Qe(e,t,s.initializer);if(l){let c=l.name||s.name.text,d=n.isDefaultExport?"default":c,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:j(c),inputs:[],exportName:d,exportType:m,importName:c,filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}}return o}if(e.ts.isArrowFunction(n.node)){let s=Qe(e,t,n.node);if(s){let l=Y(e,r),c=n.isDefaultExport?"default":l,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!Be(s))return o;let l=Qe(e,t,n.node);if(l){let c=l.name||Y(e,r),d=n.isDefaultExport||!l.name?"default":l.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:c,inputs:[],exportName:d,exportType:m,importName:l.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}return o}if(e.ts.isExportSpecifier(n.node)&&Be(n.node.getText())){let s=Qe(e,t,n.node);if(s){let l=s.name||Y(e,r),c=n.isDefaultExport||!s.name?"default":s.name,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:s.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}return o}function Qe(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return rt(e,r.body)?{name:"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return rt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(!e.ts.isPropertyAccessExpression(n))return null;let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:Qe(e,t,o[0])}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!Be(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:Me(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:Me(e,t,n)}}return null}async function hn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(zo(e,i.fileName)||a===e.reactConfigPath||a===e.registryPath||a===e.builderComponentPath)return;let s=await ge(e,o,a,i);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var $o=new Set(["node_modules","dist"]);function zo(e,t){for(let r of $o)if(e.dirname(t).includes(r))return!0;return!1}async function Cn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&Ko.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.registryPath||s===e.builderComponentPath)return;let l=await ge(e,o,s,i);r.push(...l)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Ko=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ne(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let l=a.moduleSpecifier.text;if(!l.startsWith(".")&&!l.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...wt(e,r),...wt(e,n),...wt(e,o),...i])}function J(e){let t=e.split(`
|
|
22
|
+
`,getSourceFile:a=>{if(a=e.normalize(a),a.includes("node_modules")){let l=Ke.get(a);if(l)return D(e,l.content)}let s=e.readFileSync(a);if(s==null){let l=e.basename(a),c=e.extname(l).toLowerCase();if(a.startsWith(n)&&c===".ts"&&(s=fn.get(l),s==null&&typeof self<"u"&&typeof fetch=="function"))throw new nt(l)}return a.includes("node_modules")&&(s?Ke.set(a,{exists:!0,content:s}):Ke.set(a,{exists:!1})),D(e,s)},readFile:a=>{let s=e.readFileSync(a);return typeof s=="string"?s:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return No(e,i,t)}catch(a){if(a instanceof nt){await Ro(e,a.libName);continue}throw console.error("createTsProgram",a),new Error(`createTsProgram() Could not create program for: ${t[0]}`)}}function No(e,t,r){let n={rootNames:[...r],options:{},host:t},o=e.ts.findConfigFile(e.dirname(r[0]),i=>e.existsSync(i));if(o){let i=mn.get(o);if(!i){let a=e.ts.readConfigFile(o,s=>{let l=e.readFileSync(s);return typeof l=="string"?l:void 0});a.error?console.error("error reading tsconfig for createTsProgram"):(i=e.ts.parseJsonConfigFileContent(a.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(l,c)=>e.readdirSync(l),fileExists:l=>e.existsSync(l),readFile:l=>e.readFileSync(l)||void 0},e.dirname(o),void 0,o).options,mn.set(o,i))}i&&(n.options=K(i))}return n.options.moduleResolution=e.ts.ModuleResolutionKind.Node16,n.options.noEmit=!0,n.options.isolatedModules=!1,n.options.strict=!1,n.options.jsx=e.ts.JsxEmit.Preserve,n.options.allowJs=!0,e.ts.createProgram(n)}async function be(e,t,r){r||(r=await V(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var nt=class{constructor(t){this.libName=t}};async function Ro(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;tt.has(t)||tt.set(t,fetch(r).then(n=>n.text()).then(n=>{fn.set(t,n)})),await tt.get(t),tt.delete(t)}var fn=new Map,tt=new Map,Ke=new Map,mn=new Map;function E(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=Ao(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=Fo(e,t,r.defaultImport,r.importPath,n)),t}function Ao(e,t,r,n,o,i){return i==="cjs"?gn(e,t,null,r,n):dn(e,t,null,r,n,o)}function Fo(e,t,r,n,o){return o==="cjs"?gn(e,t,r,null,n):dn(e,t,r,null,n,!1)}function dn(e,t,r,n,o,i){let a=[...t.statements],s=0,l=!1,c=!1;for(let p=0;p<a.length;p++){let x=a[p];if(!e.ts.isImportDeclaration(x)||(s=p,!x.moduleSpecifier||!e.ts.isStringLiteral(x.moduleSpecifier))||x.moduleSpecifier.text!==o||!!x.importClause?.isTypeOnly!==i)continue;let f=[],g=x.importClause?.namedBindings;if(g&&e.ts.isNamedImports(g)&&g.elements&&f.push(...g.elements),typeof n=="string"){if(f.some(C=>C.name.text===n))return t;f.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),f.sort((C,T)=>C.name.text.localeCompare(T.name.text)),l=!0}let h=x.importClause?x.importClause.name:void 0;if(typeof r=="string"){if(h&&h.text===r)return t;h=e.ts.factory.createIdentifier(r),c=!0}if(l||c)return a[p]=e.ts.factory.updateImportDeclaration(x,void 0,e.ts.factory.createImportClause(i,h,e.ts.factory.createNamedImports(f)),x.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let d,m;typeof r=="string"&&(d=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let u=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,d,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,u),e.ts.factory.updateSourceFile(t,a)}function gn(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let l=i[s];if(e.ts.isVariableStatement(l))for(let c=0;c<l.declarationList.declarations.length;c++){let d=[...l.declarationList.declarations],m=d[c],u=m.initializer;if(!u||!e.ts.isCallExpression(u))continue;let p=u.expression;if(!e.ts.isIdentifier(p)||p.text!=="require"||u.arguments.length!==1)continue;let x=u.arguments[0];if(e.ts.isStringLiteral(x)&&(a=s,x.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let f=[...m.name.elements];return f.some(h=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)?!1:h.name.text===n)?t:(f.push(e.ts.factory.createBindingElement(void 0,void 0,n)),f.sort((h,C)=>!e.ts.isBindingElement(h)||!e.ts.isIdentifier(h.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:h.name.text.localeCompare(C.name.text)),d[c]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(f),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,d)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function Q(e,t,r="esm"){return r==="cjs"?Oo(e,t):Lo(e,t)}function Lo(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function Oo(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let l of s.declarationList.declarations)e.ts.isIdentifier(l.name)&&l.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function ko(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function Ie(e,t,r,n){let o=ko(e,r,n);if(o){let i=await Ue(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getRootDir(),i);return{displayFilePath:R(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function Ne(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function q(e,t,r){let n=Ne(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function rt(e,t){if(t){if(jo(e,t))return!0;let r=!1;if(t.forEachChild(n=>{rt(e,n)&&(r=!0)}),r)return!0}return!1}function jo(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function Ue(e,t){let r=e.extname(t).toLowerCase();if(r===""||!yt.includes(r)){for(let n of yt){let o=t+n;if(await e.exists(o))return o}for(let n of yt){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var yt=[".tsx",".jsx",".ts",".js"];function Me(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=_o(e,i);return a?[{name:a}]:void 0}function _o(e,t){if(typeof t=="string"){t=e.normalize(W(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function te(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}async function Re(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await V(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let c=(await ge(e,o,a.filePath,s)).find(d=>d.cmpInfo.id===a.id);c&&(a.inputs=Te(e,o,c.node.fnNode))}return a}))}async function Ae(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await be(e,t.cmpInfo.filePath,r),a=(await ge(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Te(e,o,a.node.fnNode)}return[]}async function xn(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Bo(e,t,n)}return null}function Bo(e,t,r){let n=D(e,r);return ge(e,null,t,n)}async function ge(e,t,r,n){let o=[];for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isStringLiteral(a.expression)&&a.expression.text==="use server")return o;let i=Q(e,n);return r=e.normalize(r),await Promise.all(i.map(async a=>{let s=await Vo(e,t,r,a);o.push(...s)})),o}async function Vo(e,t,r,n){let o=[],i=e.relative(e.getRootDir(),r),a=_(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!Be(s.name.text))continue;let l=Qe(e,t,s.initializer);if(l){let c=l.name||s.name.text,d=n.isDefaultExport?"default":c,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:j(c),inputs:[],exportName:d,exportType:m,importName:c,filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}}return o}if(e.ts.isArrowFunction(n.node)){let s=Qe(e,t,n.node);if(s){let l=Y(e,r),c=n.isDefaultExport?"default":l,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!Be(s))return o;let l=Qe(e,t,n.node);if(l){let c=l.name||Y(e,r),d=n.isDefaultExport||!l.name?"default":l.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,d),displayFilePath:R(e,r),name:c,inputs:[],exportName:d,exportType:m,importName:l.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:l.deps},node:l})}return o}if(e.ts.isExportSpecifier(n.node)&&Be(n.node.getText())){let s=Qe(e,t,n.node);if(s){let l=s.name||Y(e,r),c=n.isDefaultExport||!s.name?"default":s.name,d=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await k(e,r,c),displayFilePath:R(e,r),name:l,inputs:[],exportName:c,exportType:d,importName:s.name||Pe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps},node:s})}return o}return o}function Qe(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return rt(e,r.body)?{name:"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return rt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:Me(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(!e.ts.isPropertyAccessExpression(n))return null;let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:Qe(e,t,o[0])}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!Be(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:Me(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:Me(e,t,n)}}return null}async function hn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(zo(e,i.fileName)||a===e.reactConfigPath||a===e.registryPath||a===e.builderComponentPath)return;let s=await ge(e,o,a,i);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var $o=new Set(["node_modules","dist"]);function zo(e,t){for(let r of $o)if(e.dirname(t).includes(r))return!0;return!1}async function Cn(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&Ko.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.registryPath||s===e.builderComponentPath)return;let l=await ge(e,o,s,i);r.push(...l)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Ko=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ne(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let l=a.moduleSpecifier.text;if(!l.startsWith(".")&&!l.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...wt(e,r),...wt(e,n),...wt(e,o),...i])}function J(e){let t=e.split(`
|
|
23
23
|
`).map(n=>n.trimEnd());e="";let r=!1;for(let n=t.length-1;n>=0;n--){let o=t[n];!r&&o.startsWith("import ")&&(r=!0,o=o+`
|
|
24
24
|
`),/^builder.init(.*)$/.test(o)&&(o=o+`
|
|
25
25
|
`),t[n-1]&&!t[n-1].includes("*/")&&(o.trim().startsWith("Builder.registerComponent")&&(o=`
|
package/package.json
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/dev-tools",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0-rc0",
|
|
4
4
|
"description": "Builder.io Visual CMS Devtools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./core/index.cjs",
|
|
7
7
|
"module": "./core/index.mjs",
|
|
8
8
|
"types": "./core/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./core/index.mjs",
|
|
12
|
+
"require": "./core/index.cjs",
|
|
13
|
+
"types": "./core/index.d.ts"
|
|
14
|
+
},
|
|
10
15
|
"./core": {
|
|
11
16
|
"import": "./core/index.mjs",
|
|
12
17
|
"require": "./core/index.cjs",
|
|
13
18
|
"types": "./core/index.d.ts"
|
|
14
19
|
},
|
|
20
|
+
"./figma": {
|
|
21
|
+
"import": "./figma/index.mjs",
|
|
22
|
+
"require": "./figma/index.cjs",
|
|
23
|
+
"types": "./figma/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./figma/jsx-runtime": {
|
|
26
|
+
"import": "./figma/jsx-runtime/index.mjs",
|
|
27
|
+
"require": "./figma/jsx-runtime/index.cjs",
|
|
28
|
+
"types": "./figma/jsx-runtime/index.d.ts"
|
|
29
|
+
},
|
|
15
30
|
"./next": {
|
|
16
31
|
"import": "./next/index.mjs",
|
|
17
32
|
"require": "./next/index.cjs",
|
|
@@ -54,7 +69,9 @@
|
|
|
54
69
|
}
|
|
55
70
|
},
|
|
56
71
|
"bin": {
|
|
57
|
-
"builder-dev-tools": "./cli/index.cjs"
|
|
72
|
+
"builder-dev-tools": "./cli/index.cjs",
|
|
73
|
+
"builder.io": "./cli/index.cjs",
|
|
74
|
+
"bio": "./cli/index.cjs"
|
|
58
75
|
},
|
|
59
76
|
"files": [
|
|
60
77
|
"core",
|
|
@@ -70,7 +87,8 @@
|
|
|
70
87
|
"dependencies": {
|
|
71
88
|
"launch-editor": "^2.6.0",
|
|
72
89
|
"prettier": "^2.8.8",
|
|
73
|
-
"typescript": "^5.1.6"
|
|
90
|
+
"typescript": "^5.1.6",
|
|
91
|
+
"open": "^10.1.0"
|
|
74
92
|
},
|
|
75
93
|
"homepage": "https://builder.io/",
|
|
76
94
|
"keywords": [
|
|
@@ -84,7 +102,20 @@
|
|
|
84
102
|
"react",
|
|
85
103
|
"remix",
|
|
86
104
|
"next",
|
|
87
|
-
"qwik"
|
|
105
|
+
"qwik",
|
|
106
|
+
"vcp",
|
|
107
|
+
"visual copilot",
|
|
108
|
+
"figma to code",
|
|
109
|
+
"design to code",
|
|
110
|
+
"figma to react",
|
|
111
|
+
"figma"
|
|
88
112
|
],
|
|
89
|
-
"license": "MIT"
|
|
113
|
+
"license": "MIT",
|
|
114
|
+
"devDependencies": {
|
|
115
|
+
"@types/prompts": "^2.4.9",
|
|
116
|
+
"@clack/prompts": "^0.7.0",
|
|
117
|
+
"emphasize": "^7.0.0",
|
|
118
|
+
"enquirer": "^2.4.1",
|
|
119
|
+
"prompts": "^2.4.2"
|
|
120
|
+
}
|
|
90
121
|
}
|
package/server/index.cjs
CHANGED
|
@@ -159,8 +159,8 @@ Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-de
|
|
|
159
159
|
|
|
160
160
|
<div id="react-router-message" hidden>
|
|
161
161
|
<span
|
|
162
|
-
>Next, add the following path and component in your React app
|
|
163
|
-
setup</span
|
|
162
|
+
>Next, add the following path and component in your React app
|
|
163
|
+
routing setup</span
|
|
164
164
|
>
|
|
165
165
|
<ol id="react-router-steps">
|
|
166
166
|
<li>
|
|
@@ -176,9 +176,7 @@ Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-de
|
|
|
176
176
|
<span id="help-text">Need help?</span>
|
|
177
177
|
<span id="help-icon"></span>
|
|
178
178
|
</a>
|
|
179
|
-
<div id="react-checkbox-div">
|
|
180
|
-
</div>
|
|
181
|
-
|
|
179
|
+
<div id="react-checkbox-div"></div>
|
|
182
180
|
</div>
|
|
183
181
|
<div id="react-finish-button" hidden>
|
|
184
182
|
<a class="button next-step" href="#">
|
package/server/index.mjs
CHANGED
|
@@ -159,8 +159,8 @@ Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-de
|
|
|
159
159
|
|
|
160
160
|
<div id="react-router-message" hidden>
|
|
161
161
|
<span
|
|
162
|
-
>Next, add the following path and component in your React app
|
|
163
|
-
setup</span
|
|
162
|
+
>Next, add the following path and component in your React app
|
|
163
|
+
routing setup</span
|
|
164
164
|
>
|
|
165
165
|
<ol id="react-router-steps">
|
|
166
166
|
<li>
|
|
@@ -176,9 +176,7 @@ Visit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-de
|
|
|
176
176
|
<span id="help-text">Need help?</span>
|
|
177
177
|
<span id="help-icon"></span>
|
|
178
178
|
</a>
|
|
179
|
-
<div id="react-checkbox-div">
|
|
180
|
-
</div>
|
|
181
|
-
|
|
179
|
+
<div id="react-checkbox-div"></div>
|
|
182
180
|
</div>
|
|
183
181
|
<div id="react-finish-button" hidden>
|
|
184
182
|
<a class="button next-step" href="#">
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/// <reference types="@figma/plugin-typings" />
|
|
2
|
+
import type { ComponentInfo, ComponentInput, ComponentRegistry, DevToolsSys } from "../types";
|
|
3
|
+
import type { FigmaArgs } from "./figma";
|
|
4
|
+
export declare const runFigmaAdd: (sys: DevToolsSys, args: FigmaArgs) => Promise<void>;
|
|
5
|
+
export interface FigmaComponentInput {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
type: string;
|
|
10
|
+
baseType: "text" | "variant" | "boolean" | "slot";
|
|
11
|
+
variantOptions?: string[];
|
|
12
|
+
isDefault: boolean;
|
|
13
|
+
ref?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FigmaComponentInfo {
|
|
16
|
+
documentName: string;
|
|
17
|
+
key: string;
|
|
18
|
+
tree: string;
|
|
19
|
+
jsx: string;
|
|
20
|
+
name: string;
|
|
21
|
+
inputs: FigmaComponentInput[];
|
|
22
|
+
description: string;
|
|
23
|
+
documentationLinks: string[];
|
|
24
|
+
instanceId: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const parseFigmaURL: (str: string) => {
|
|
27
|
+
fileID: string;
|
|
28
|
+
nodeId: string;
|
|
29
|
+
} | null;
|
|
30
|
+
export declare const getFigmaNodeData: (auth: {
|
|
31
|
+
access_token: string;
|
|
32
|
+
oauth: boolean;
|
|
33
|
+
}, fileId: string, nodeId: string) => Promise<any>;
|
|
34
|
+
export declare function getInputsSlotsFromComponentPropertyDefinitions(mainComponent: ComponentSetNode | ComponentNode): {
|
|
35
|
+
inputs: FigmaComponentInput[];
|
|
36
|
+
nameMap: (key: string) => string;
|
|
37
|
+
};
|
|
38
|
+
export declare const REMOVE_EMOJI: RegExp;
|
|
39
|
+
export declare function getFigmaComponentName(name: string): string;
|
|
40
|
+
export interface MappingCodeV2 {
|
|
41
|
+
figmaInterface: string;
|
|
42
|
+
reactInterface: string;
|
|
43
|
+
componentRegistry: string;
|
|
44
|
+
figmaComponentName: string;
|
|
45
|
+
figmaTree: string;
|
|
46
|
+
meta?: Record<string, any>;
|
|
47
|
+
previousCode?: string;
|
|
48
|
+
prompt?: string;
|
|
49
|
+
}
|
|
50
|
+
export declare function getMappingData(figmaNode: FigmaComponentInfo, registeredCmp: ComponentInfo, cmpRegistry: ComponentRegistry, useJSX: boolean): MappingCodeV2;
|
|
51
|
+
export declare const getTypeFromComponentInput: (input: ComponentInput) => string;
|
|
52
|
+
export declare const getPropertyAccessor: (name: string) => string;
|
|
53
|
+
export declare function getMappingPrompt(figmaNode: FigmaComponentInfo, registeredCmp: ComponentInfo, cmpRegistry: ComponentRegistry, useJSX?: boolean): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DevToolsSys } from "../types";
|
|
2
|
+
import type { FigmaArgs } from "./figma";
|
|
3
|
+
export interface CredentialsOptions {
|
|
4
|
+
builderPublicKey?: boolean;
|
|
5
|
+
builderPrivateKey?: boolean;
|
|
6
|
+
figmaAuth?: boolean;
|
|
7
|
+
force?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FigmaAuth {
|
|
10
|
+
access_token: string;
|
|
11
|
+
oauth: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface BuilderAuth {
|
|
14
|
+
privateKey: string;
|
|
15
|
+
spaceId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
userId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Credentials {
|
|
20
|
+
figmaAuth?: FigmaAuth;
|
|
21
|
+
builderPublicKey?: string;
|
|
22
|
+
builderPrivateKey?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const isCI: (args: FigmaArgs) => boolean;
|
|
25
|
+
export declare const getCredentials: (sys: DevToolsSys, args: FigmaArgs, opts: CredentialsOptions) => Promise<{
|
|
26
|
+
figmaAuth: FigmaAuth | undefined;
|
|
27
|
+
builderPublicKey: string | undefined;
|
|
28
|
+
builderPrivateKey: string | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export declare function getFigmaAuth(): Promise<FigmaAuth>;
|
|
31
|
+
export declare function getBuilderAuth(sys: DevToolsSys): Promise<BuilderAuth>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FigmaArgs } from "./figma";
|
|
2
|
+
import type { DevToolsSys } from "../types";
|
|
3
|
+
import { type FigmaBuilderLink } from "./figma-publish";
|
|
4
|
+
interface KVGetRequest {
|
|
5
|
+
privateKey: string;
|
|
6
|
+
spaceId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const runFigmaMigrate: (sys: DevToolsSys, args: FigmaArgs) => Promise<void>;
|
|
9
|
+
export declare function getBuilderSpaceFigmaLinks(kvReq: KVGetRequest): Promise<FigmaBuilderLink[]>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { DevToolsSys, ExportType } from "../types";
|
|
2
|
+
import type { FigmaArgs } from "./figma";
|
|
3
|
+
export interface FigmaBuilderLink {
|
|
4
|
+
builderName: string;
|
|
5
|
+
figmaName: string;
|
|
6
|
+
figmaKey: string;
|
|
7
|
+
inputMapper?: string;
|
|
8
|
+
originalInputMapper?: string;
|
|
9
|
+
exportType?: ExportType;
|
|
10
|
+
importName?: string;
|
|
11
|
+
importPath?: string;
|
|
12
|
+
source: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const runFigmaPublish: (sys: DevToolsSys, args: FigmaArgs) => Promise<void>;
|
|
15
|
+
export declare const FIGMA_CONNECT_CALL = "figmaMapping";
|
|
16
|
+
export declare function findAllMappingFiles(sys: DevToolsSys): Promise<string[]>;
|
|
17
|
+
export interface BuilderSpace {
|
|
18
|
+
privateKey: string;
|
|
19
|
+
spaceId: string;
|
|
20
|
+
userId: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}
|
|
23
|
+
interface KVGetRequest extends BuilderSpace {
|
|
24
|
+
docId: string;
|
|
25
|
+
}
|
|
26
|
+
interface KVPutRequest extends KVGetRequest {
|
|
27
|
+
/**
|
|
28
|
+
* Must be an object but not an array. TS is a fool sometimes.
|
|
29
|
+
* https://stackoverflow.com/a/70448528/1520787
|
|
30
|
+
*/
|
|
31
|
+
data: Record<string, any> & {
|
|
32
|
+
length?: never;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export interface FigmaBuilderData {
|
|
36
|
+
figmaBuilderLinks: FigmaBuilderLink[];
|
|
37
|
+
}
|
|
38
|
+
export declare function putBuilderSpaceKv(kvReq: KVPutRequest): Promise<void>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DevToolsSys } from "../types";
|
|
2
|
+
export interface FigmaArgs {
|
|
3
|
+
privateKey?: string;
|
|
4
|
+
figmaToken?: string;
|
|
5
|
+
ci?: boolean;
|
|
6
|
+
help?: boolean;
|
|
7
|
+
_: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const runFigmaCommand: (sys: DevToolsSys, subCommand: string, args: FigmaArgs) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function printHelp(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatCode(code: string): Promise<string>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="@figma/plugin-typings" />
|
|
2
|
+
export type FigmaNodeType = "COMPONENT" | "ELLIPSE" | "FRAME" | "GROUP" | "INSTANCE" | "LINE" | "POLYGON" | "RECTANGLE" | "STAR" | "TEXT" | "VECTOR";
|
|
3
|
+
export interface FigmaComponentInput {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
value?: any;
|
|
7
|
+
type: string;
|
|
8
|
+
baseType: "text" | "variant" | "boolean" | "slot";
|
|
9
|
+
variantOptions?: string[];
|
|
10
|
+
isDefault: boolean;
|
|
11
|
+
ref?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface FigmaNode {
|
|
14
|
+
"@type": "passedNode";
|
|
15
|
+
$id: string;
|
|
16
|
+
$name: string;
|
|
17
|
+
$type: FigmaNodeType;
|
|
18
|
+
$inputs: readonly FigmaComponentInput[];
|
|
19
|
+
$componentName?: string;
|
|
20
|
+
$rawNode: SceneNode;
|
|
21
|
+
/** Represents the text content of the node and its descendants */
|
|
22
|
+
$textContent: string;
|
|
23
|
+
/** URL to the rasterized image of this node */
|
|
24
|
+
$imageUrl: string;
|
|
25
|
+
$children: readonly FigmaNode[];
|
|
26
|
+
/** Recursively finds the first node that matches the callback */
|
|
27
|
+
$findOne(callback: (node: SceneNode) => boolean): FigmaNode | undefined;
|
|
28
|
+
/** Recursively finds the first figma child with the given name */
|
|
29
|
+
$findOneByName(name: string | RegExp): FigmaNode | undefined;
|
|
30
|
+
/** @deprecated Use $type instead */
|
|
31
|
+
type: FigmaNodeType;
|
|
32
|
+
/** @deprecated - */
|
|
33
|
+
props: {};
|
|
34
|
+
/** @deprecated - */
|
|
35
|
+
key: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface BaseFigmaProps {
|
|
38
|
+
$id: string;
|
|
39
|
+
$name: string;
|
|
40
|
+
$type: FigmaNodeType;
|
|
41
|
+
$inputs: readonly FigmaComponentInput[];
|
|
42
|
+
$componentName?: string;
|
|
43
|
+
/** Represents the text content of the node and its descendants */
|
|
44
|
+
$textContent: string;
|
|
45
|
+
$css: Readonly<Record<string, string>>;
|
|
46
|
+
/** URL to the rasterized image of this node */
|
|
47
|
+
$imageUrl: string;
|
|
48
|
+
/** Direct children of the root component node or instance */
|
|
49
|
+
$children: readonly FigmaNode[];
|
|
50
|
+
/** Recursively finds the first figma child with the given name */
|
|
51
|
+
$findOneByName(name: string | RegExp): FigmaNode | undefined;
|
|
52
|
+
/** Recursively finds the first node that matches the callback */
|
|
53
|
+
$findOne(callback: (node: SceneNode) => boolean): FigmaNode | undefined;
|
|
54
|
+
}
|
|
55
|
+
interface FigmaProps extends BaseFigmaProps {
|
|
56
|
+
[key: string]: any;
|
|
57
|
+
}
|
|
58
|
+
export interface FigmaMappingWithKeyMapper<T extends BaseFigmaProps> {
|
|
59
|
+
url?: string;
|
|
60
|
+
componentKey: string;
|
|
61
|
+
mapper?: (figma: T) => any;
|
|
62
|
+
}
|
|
63
|
+
export interface FigmaGenericMapper {
|
|
64
|
+
genericMapper: (figma: FigmaProps) => any;
|
|
65
|
+
}
|
|
66
|
+
export interface FigmaTokenMapper {
|
|
67
|
+
designTokenMapper: (token: string) => string | undefined | boolean;
|
|
68
|
+
}
|
|
69
|
+
export declare function figmaMapping<T extends BaseFigmaProps = FigmaProps>(_config: FigmaMappingWithKeyMapper<T> | FigmaGenericMapper | FigmaTokenMapper): void;
|
|
70
|
+
export {};
|