@builder.io/dev-tools 1.1.4 → 1.1.5

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/core/index.cjs CHANGED
@@ -782,7 +782,7 @@ export class Counter {
782
782
  }
783
783
  }
784
784
 
785
- `.trimStart()}async function Dr(e){await zt(e);let t=await e.readFile(e.registryPath);return t?Fa(e,t):{components:[],sourceFile:E(e,"")}}async function Fa(e,t){let r=E(e,t);return Oa(e,r)}async function Oa(e,t){let r=[],n=M(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await qt(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:Q(r)}}async function qt(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[]};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(b(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let d=s.arguments[0];e.ts.isIdentifier(d)&&(a=d.text)}if(!a)continue;n.name===""&&(n.name=j(a)),n.importName=a;let p=await ye(e,e.registryPath,t,a);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,n.importPath=k(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let l=await xr(e,p.filePath);if(l&&l.length>0)if(l.length===1)n.exportName=l[0].cmpInfo.exportName;else{let d=l.find(f=>f.cmpInfo.exportName===a);d&&(n.exportName=d.cmpInfo.exportName)}continue}}return n=W(e,n,r),n.filePath&&n.exportName&&(n.id=await _(e,n.filePath,n.exportName)),n}async function me(e,t,r,n,o,i,a,s){let p=await Ee(e),[l,d,f]=await Promise.all([gr(e,p),Dr(e),nt(e)]),c=l.map(C=>C.cmpInfo),u=d.components,h={components:ee(c,u),registryPath:e.registryPath,registryDisplayPath:A(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ie(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return h.components=await Cr(e,h.components),h;let m=!1,g=d.sourceFile,x=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(x.length>0){let C=x.map(T=>{let S=l.find(R=>R.cmpInfo.id===T);if(!S)throw new Error(`Component ${T} not found`);return S}),P=Array.from(new Set(C.map(T=>T.cmpInfo.filePath))),I=await K(e,P);for(let T of C){let S=h.components.find(L=>L.id===T.cmpInfo.id),R=await hr(e,T,I);Z(S,R);let B=c.findIndex(L=>L.id===T.cmpInfo.id);c[B].inputs=R;let F=pe(T.cmpInfo.id,c,u,r,n,o,i),{elements:y,elmIndex:w,statementIndex:V,statement:z,variableDeclaration:q}=await ka(e,g,T);if(F.addCmpToRegistry)y.push(La(e,F.addCmpToRegistry)),m=!0;else if(F.removeCmpFromRegistry)y.splice(w,1),m=!0;else if(F.updateRegisteredCmp){let L=$(e,y[w],F.updateRegisteredCmp);y[w]=e.ts.factory.updateObjectLiteralExpression(L,[Er(e,F.updateRegisteredCmp),...L.properties.slice(1)]),m=!0}if(m&&a){let L=[...g.statements];L[V]=e.ts.factory.updateVariableStatement(z,z.modifiers,e.ts.factory.updateVariableDeclarationList(z.declarationList,[e.ts.factory.updateVariableDeclaration(q,q.name,q.exclamationToken,q.type,e.ts.factory.createArrayLiteralExpression(De(e,y)))])),g=e.ts.factory.updateSourceFile(g,L),S.exportType==="named"?g=D(e,g,{namedImports:[S.importName],importPath:v(e,e.registryPath,S.filePath)}):g=D(e,g,{defaultImport:S.importName,importPath:v(e,e.registryPath,S.filePath)}),g=D(e,g,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),g=we(e,g,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),h.components=F.components,u=F.components.filter(fe=>fe.isRegistered)}}}if(m&&a){g=se(e,g),g=ae(e,g);let C=N(e,g);C=H(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return h}function Er(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function La(e,t){return $(e,e.ts.factory.createObjectLiteralExpression([Er(e,t)],!0),t)}async function ka(e,t,r){let n=M(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await qt(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function wr(e){let t=await _a(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>yr(t),ensureFigmaImportPage:()=>Tr(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>me(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),loadComponent:async n=>{let o=await me(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>me(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>me(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>me(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>me(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>nt(t),setPublicApiKey:n=>dr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ne(t),setCache:n=>re(t,n)}}async function _a(e){let t=await Ba(e),r=e.getRootDir(),n=e.join(r,"src"),o=await ja(e),i=`builder-registry.${o?"ts":"js"}`,a={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:"",angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:""};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);return a.srcDir=n,a.appDir=e.join(n,"app"),a.componentsDir=e.join(a.appDir,"components"),a.registryPath=e.join(a.appDir,i),a.builderPageComponentPath=e.join(a.componentsDir,`builder-page.component.${o?"ts":"js"}`),a}function ja(e){let t=e.join(e.getRootDir(),"tsconfig.json");return e.exists(t)}async function Ba(e){let t=e.join(e.getRootDir(),"angular.json");if(await e.exists(t))return t;throw new Error(`Could not find Angular config file. Searched for angular.json in "${e.getRootDir()}".`)}var yt=fo(Br(),1);async function Vr(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:X(e.relative(e.getRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:J(i.inputs)};return J(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,yt.compress)(n);return btoa(JSON.stringify(o))}async function Kr(e,t,r){if(typeof r!="string")throw new Error("Invalid registry to import");let n=await t.getRegistry(),o=JSON.parse(atob(r)),i=(0,yt.decompress)(o),a=J(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let p=X(e.normalize(s.filePath)),l=n.components.find(f=>X(f.filePath).endsWith(p)&&f.exportName===s.exportName);if(!l){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${l.id})`,l.filePath),await t.registerComponent({cmpId:l.id});for(let f of s.inputs)e.debug(`set input (${l.id})`),await t.setRegisteredComponentInput({cmpId:l.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${l.id}) info`);let d=await t.setRegisteredComponentInfo({cmpId:l.id,name:s.name,image:s.image,description:s.description});a=J(d)}return a}var te={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},Nm={[te.react]:[{version:O.gen1,recommended:!0}],[te.remix]:[{version:O.gen1,recommended:!1}],[te.angular]:[{version:O.gen2,recommended:!0}],[te.next]:[{version:O.gen1,recommended:!0},{version:O.gen2,recommended:!1}],[te.qwik]:[{version:O.gen2,recommended:!0}]};var ps={"@builder.io/qwik-city":Xn,next:$n,"@remix-run/react":ar,react:fr,"@angular/core":wr},ls={"@builder.io/qwik-city":te.qwik,next:te.next,"@remix-run/react":te.remix,react:te.react,"@angular/core":te.angular};async function $r(e){if(!e.ts)throw new Error("createDevTools() requires a TypeScript instance passed to the 'ts' option");if((!e.frameworks||e.frameworks.length===0)&&(e.frameworks=await Ce(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getRootDir()}`);for(let t of e.frameworks){let r=ps[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>Vr(e,n),importRegistry:i=>Kr(e,n,i),framework:ls[t.name]}}}throw new Error(`Devtools framework not found for ${e.getRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function Mr(e){function t(f){if(typeof f!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(f))}function r(f,c){let u="",h=0,m=-1,g=0,x;for(let C=0;C<=f.length;++C){if(C<f.length)x=f.charCodeAt(C);else{if(x===47)break;x=47}if(x===47){if(!(m===C-1||g===1))if(m!==C-1&&g===2){if(u.length<2||h!==2||u.charCodeAt(u.length-1)!==46||u.charCodeAt(u.length-2)!==46){if(u.length>2){let P=u.lastIndexOf("/");if(P!==u.length-1){P===-1?(u="",h=0):(u=u.slice(0,P),h=u.length-1-u.lastIndexOf("/")),m=C,g=0;continue}}else if(u.length===2||u.length===1){u="",h=0,m=C,g=0;continue}}c&&(u.length>0?u+="/..":u="..",h=2)}else u.length>0?u+="/"+f.slice(m+1,C):u=f.slice(m+1,C),h=C-m-1;m=C,g=0}else x===46&&g!==-1?++g:g=-1}return u}let n=function(...c){let u="",h=!1;for(let m=c.length-1;m>=-1&&!h;m--){let g;m>=0?g=c[m]:e.cwd?g=e.cwd():g="/",t(g),g.length!==0&&(u=g+"/"+u,h=g.charCodeAt(0)===47)}return u=r(u,!h),h?u.length>0?"/"+u:"/":u.length>0?u:"."},o=function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0)===47,h=c.charCodeAt(c.length-1)===47;return c=r(c,!u),c.length===0&&!u&&(c="."),c.length>0&&h&&(c+="/"),u?"/"+c:c};return{relative:function(c,u){if(t(c),t(u),c===u||(c=n(c),u=n(u),c===u))return"";let h=1;for(;h<c.length&&c.charCodeAt(h)===47;++h);let m=c.length,g=m-h,x=1;for(;x<u.length&&u.charCodeAt(x)===47;++x);let P=u.length-x,I=g<P?g:P,T=-1,S=0;for(;S<=I;++S){if(S===I){if(P>I){if(u.charCodeAt(x+S)===47)return u.slice(x+S+1);if(S===0)return u.slice(x+S)}else g>I&&(c.charCodeAt(h+S)===47?T=S:S===0&&(T=0));break}let B=c.charCodeAt(h+S),F=u.charCodeAt(x+S);if(B!==F)break;B===47&&(T=S)}let R="";for(S=h+T+1;S<=m;++S)(S===m||c.charCodeAt(S)===47)&&(R.length===0?R+="..":R+="/..");return R.length>0?R+u.slice(x+T):(x+=T,u.charCodeAt(x)===47&&++x,u.slice(x))},resolve:n,join:function(...c){if(c.length===0)return".";let u;for(let h=0;h<c.length;++h){let m=c[h];t(m),m.length>0&&(u===void 0?u=m:u+="/"+m)}return u===void 0?".":o(u)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,u){if(u!==void 0&&typeof u!="string")throw new TypeError('"ext" argument must be a string');t(c);let h=0,m=-1,g=!0,x;if(u!==void 0&&u.length>0&&u.length<=c.length){if(u.length===c.length&&u===c)return"";let C=u.length-1,P=-1;for(x=c.length-1;x>=0;--x){let I=c.charCodeAt(x);if(I===47){if(!g){h=x+1;break}}else P===-1&&(g=!1,P=x+1),C>=0&&(I===u.charCodeAt(C)?--C===-1&&(m=x):(C=-1,m=P))}return h===m?m=P:m===-1&&(m=c.length),c.slice(h,m)}else{for(x=c.length-1;x>=0;--x)if(c.charCodeAt(x)===47){if(!g){h=x+1;break}}else m===-1&&(g=!1,m=x+1);return m===-1?"":c.slice(h,m)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0),h=u===47,m=-1,g=!0;for(let x=c.length-1;x>=1;--x)if(u=c.charCodeAt(x),u===47){if(!g){m=x;break}}else g=!1;return m===-1?h?"/":".":h&&m===1?"//":c.slice(0,m)},extname:function(c){t(c);let u=-1,h=0,m=-1,g=!0,x=0;for(let C=c.length-1;C>=0;--C){let P=c.charCodeAt(C);if(P===47){if(!g){h=C+1;break}continue}m===-1&&(g=!1,m=C+1),P===46?u===-1?u=C:x!==1&&(x=1):u!==-1&&(x=-1)}return u===-1||m===-1||x===0||x===1&&u===m-1&&u===h+1?"":c.slice(u,m)}}}async function Ur(e){let t=e.getRootDir?e.getRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=Mr({cwd:r,...e}),o=new Map,i=m=>n.normalize(n.resolve(r(),m)),a=m=>{for(let[g]of o)if((g+"/").startsWith(m))return!0;return m===t()},s=m=>(m=i(m),o.has(m)?!0:a(m)),p=m=>{m=i(m);let g=m===t()?m:m+"/",x=g.split("/").length-1,C=[];for(let[P]of o)if(P.split("/").slice(0,x).join("/")+"/"===g){let S=P.split("/")[x];S&&!C.includes(S)&&C.push(S)}return C.sort()},l=m=>{m=i(m);let g=o.get(m);return typeof g=="string"?g:null},d=m=>(m=i(m),{isFile:()=>o.has(m),isDirectory:()=>!o.has(m)&&a(m)}),f=async m=>{if(typeof crypto<"u"){let C=new TextEncoder().encode(m),P=await crypto.subtle.digest("SHA-256",C);return Array.from(new Uint8Array(P)).map(I=>I.toString(16).padStart(2,"0")).join("")}let g=0;for(let x=0;x<m.length;x++){let C=m.charCodeAt(x);g=(g<<5)-g+C,g|=0}return Number(Math.abs(g)).toString(36)},c=new Set,u={getRootDir:t,cwd:r,exists:async m=>s(m),existsSync:s,readdir:async m=>p(m),readdirSync:p,readFile:async m=>l(m),readFileSync:l,stat:async m=>d(m),statSync:d,writeFile:async(m,g)=>{m=i(m),o.set(m,g);let x={path:m,basename:n.basename(m),dirname:n.dirname(m),extname:n.extname(m)};for(let C of c)await C(x)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",formatCode:async(m,g)=>g,on:(m,g)=>{m==="change"&&c.add(g)},off:(m,g)=>{m==="change"&&c.delete(g)},debug:(...m)=>{console.debug("[builder-dev-tools]",...m)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,ignoreMissingConfig:!1},h=await Ce(u);return u.getFrameworks=e.getFrameworks?e.getFrameworks:()=>h,u}async function zr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(qr(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Expected an export assignment from ${t}`);let c=d.statement;if(e.ts.isVariableStatement(c)){let u=[...c.declarationList.declarations];if(u.length!==1)throw new Error("Expected a single variable declaration");let h=u[0];if(!h.initializer)throw new Error("Expected an initializer on the declaration");let m=h.initializer;if(e.ts.isObjectLiteralExpression(m)||e.ts.isCallExpression(m)){let g="BuilderDevTools()",x=[...n.statements],C=x.indexOf(c);return x[C]=e.ts.factory.updateVariableStatement(c,c.modifiers,e.ts.factory.updateVariableDeclarationList(c.declarationList,[e.ts.factory.updateVariableDeclaration(h,h.name,h.exclamationToken,h.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(g),void 0,[m]))])),n=e.ts.factory.updateSourceFile(n,x),n=D(e,n,{defaultImport:"BuilderDevTools",importPath:"@builder.io/dev-tools/next"}),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}}let p=a[0];if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=an(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=an(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}if(e.ts.isArrowFunction(p.node)){let d=p.node,f=p.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let c=f.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let h=p.node.body;if(!e.ts.isBlock(h))throw new Error("Expected a block body on the next config function");let m=[...h.statements],g=m.findIndex(T=>e.ts.isReturnStatement(T));if(g===-1)throw new Error("Expected a return statement on the next config function");let x=m[g],C=an(e,n);n=C.sourceFile,m[g]=e.ts.factory.updateReturnStatement(x,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(C.withFnVariableName),void 0,[x.expression]));let P=[...n.statements],I=P.indexOf(f);return P[I]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.updateArrowFunction(d,d.modifiers,d.typeParameters,d.parameters,d.type,d.equalsGreaterThanToken,e.ts.factory.updateBlock(h,m)))),n=e.ts.factory.updateSourceFile(n,P),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected export type")}function qr(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function an(e,t){let r=qr(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function Wr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(Yr(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let p=a[0];if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isExportAssignment(f))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(f.expression)){let c="builderDevTools()",u=cs(e,f.expression);if(!u)return o;let h=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[u]),m=[...n.statements],g=m.indexOf(f);return m[g]=e.ts.factory.updateExportAssignment(f,f.modifiers,h),n=e.ts.factory.updateSourceFile(n,m),n=D(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=N(e,n),o.hasContentUpdates=!0,o}}if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=Qr(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=Qr(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}function Yr(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Qr(e,t){let r=Yr(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function cs(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Jr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Jr(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function Jr(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Hr(e,t,r){let n=E(e,r),o=G(e,n);if(o.length!==1)throw new Error(`Expected an export from ${t}`);let i=o[0];if(!i.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let a=i.statement;if(!e.ts.isExportAssignment(a))throw new Error(`Expected an export assignment from ${t}`);let s={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(e.ts.isCallExpression(i.node)&&e.ts.isIdentifier(i.node.expression)&&i.node.expression.text==="defineConfig"){let p=[...i.node.arguments];if(p.length===0)throw new Error("Expected an argument in defineConfig()");let l=p[0];if(e.ts.isArrowFunction(l)){let d=us(e,l);if(!d)return s;p[0]=e.ts.factory.updateArrowFunction(l,l.modifiers,l.typeParameters,l.parameters,l.type,l.equalsGreaterThanToken,d);let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,p)),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}if(e.ts.isObjectLiteralExpression(l)){let d=sn(e,l);if(!d)return s;let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,[d])),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(a.expression)){let p=sn(e,a.expression);if(!p)return s;let l=[...n.statements],d=l.indexOf(a);return l[d]=e.ts.factory.updateExportAssignment(a,a.modifiers,p),n=e.ts.factory.updateSourceFile(n,l),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error(`Unable to parse ${t}`)}function us(e,t){let r=t.body;if(!e.ts.isBlock(r))return null;let n=[...r.statements],o=n.findIndex(s=>e.ts.isReturnStatement(s));if(o===-1){let s=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());n.push(s),o=n.length-1}let i=n[o];if(!i.expression||!e.ts.isObjectLiteralExpression(i.expression))return null;let a=sn(e,i.expression);return a?(n[o]=e.ts.factory.updateReturnStatement(i,a),e.ts.factory.updateBlock(r,n)):null}function sn(e,t){if(ds(e)){let i=ms(e,t);i&&(t=i)}let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="plugins");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Gr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Gr(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("plugins",o)]):null}function Gr(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="builderDevTools":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("builderDevTools"),void 0,[])])}function ms(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=fs(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=pn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]);return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("ssr",i)])}return null}function fs(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=pn(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=pn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function pn(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function ds(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Xr(e,t,r){return e.debug("Webpack config updates are currently in progress..."),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function eo(e,t,r){e.debug("Angular config updates are currently in progress...");try{await hs(e)}catch{console.error("Unable to update package.json.")}return await gs(e),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function gs(e){let t=e.getRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await xs(e,o);await e.writeFile(n,i)}async function xs(e,t){let r=t,n=E(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
785
+ `.trimStart()}async function Dr(e){await zt(e);let t=await e.readFile(e.registryPath);return t?Fa(e,t):{components:[],sourceFile:E(e,"")}}async function Fa(e,t){let r=E(e,t);return Oa(e,r)}async function Oa(e,t){let r=[],n=M(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await qt(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:Q(r)}}async function qt(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[]};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(b(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let d=s.arguments[0];e.ts.isIdentifier(d)&&(a=d.text)}if(!a)continue;n.name===""&&(n.name=j(a)),n.importName=a;let p=await ye(e,e.registryPath,t,a);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,n.importPath=k(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let l=await xr(e,p.filePath);if(l&&l.length>0)if(l.length===1)n.exportName=l[0].cmpInfo.exportName;else{let d=l.find(f=>f.cmpInfo.exportName===a);d&&(n.exportName=d.cmpInfo.exportName)}continue}}return n=W(e,n,r),n.filePath&&n.exportName&&(n.id=await _(e,n.filePath,n.exportName)),n}async function me(e,t,r,n,o,i,a,s){let p=await Ee(e),[l,d,f]=await Promise.all([gr(e,p),Dr(e),nt(e)]),c=l.map(C=>C.cmpInfo),u=d.components,h={components:ee(c,u),registryPath:e.registryPath,registryDisplayPath:A(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ie(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return h.components=await Cr(e,h.components),h;let m=!1,g=d.sourceFile,x=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(x.length>0){let C=x.map(T=>{let S=l.find(R=>R.cmpInfo.id===T);if(!S)throw new Error(`Component ${T} not found`);return S}),P=Array.from(new Set(C.map(T=>T.cmpInfo.filePath))),I=await K(e,P);for(let T of C){let S=h.components.find(L=>L.id===T.cmpInfo.id),R=await hr(e,T,I);Z(S,R);let B=c.findIndex(L=>L.id===T.cmpInfo.id);c[B].inputs=R;let F=pe(T.cmpInfo.id,c,u,r,n,o,i),{elements:y,elmIndex:w,statementIndex:V,statement:z,variableDeclaration:q}=await ka(e,g,T);if(F.addCmpToRegistry)y.push(La(e,F.addCmpToRegistry)),m=!0;else if(F.removeCmpFromRegistry)y.splice(w,1),m=!0;else if(F.updateRegisteredCmp){let L=$(e,y[w],F.updateRegisteredCmp);y[w]=e.ts.factory.updateObjectLiteralExpression(L,[Er(e,F.updateRegisteredCmp),...L.properties.slice(1)]),m=!0}if(m&&a){let L=[...g.statements];L[V]=e.ts.factory.updateVariableStatement(z,z.modifiers,e.ts.factory.updateVariableDeclarationList(z.declarationList,[e.ts.factory.updateVariableDeclaration(q,q.name,q.exclamationToken,q.type,e.ts.factory.createArrayLiteralExpression(De(e,y)))])),g=e.ts.factory.updateSourceFile(g,L),S.exportType==="named"?g=D(e,g,{namedImports:[S.importName],importPath:v(e,e.registryPath,S.filePath)}):g=D(e,g,{defaultImport:S.importName,importPath:v(e,e.registryPath,S.filePath)}),g=D(e,g,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),g=we(e,g,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),h.components=F.components,u=F.components.filter(fe=>fe.isRegistered)}}}if(m&&a){g=se(e,g),g=ae(e,g);let C=N(e,g);C=H(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return h}function Er(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function La(e,t){return $(e,e.ts.factory.createObjectLiteralExpression([Er(e,t)],!0),t)}async function ka(e,t,r){let n=M(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await qt(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function wr(e){let t=await _a(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>yr(t),ensureFigmaImportPage:()=>Tr(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>me(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),loadComponent:async n=>{let o=await me(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>me(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>me(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>me(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>me(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>nt(t),setPublicApiKey:n=>dr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ne(t),setCache:n=>re(t,n)}}async function _a(e){let t=await Ba(e),r=e.getRootDir(),n=e.join(r,"src"),o=await ja(e),i=`builder-registry.${o?"ts":"js"}`,a={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:"",angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:""};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);return a.srcDir=n,a.appDir=e.join(n,"app"),a.componentsDir=e.join(a.appDir,"components"),a.registryPath=e.join(a.appDir,i),a.builderPageComponentPath=e.join(a.componentsDir,`builder-page.component.${o?"ts":"js"}`),a}function ja(e){let t=e.join(e.getRootDir(),"tsconfig.json");return e.exists(t)}async function Ba(e){let t=e.join(e.getRootDir(),"angular.json");if(await e.exists(t))return t;throw new Error(`Could not find Angular config file. Searched for angular.json in "${e.getRootDir()}".`)}var yt=fo(Br(),1);async function Vr(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:X(e.relative(e.getRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:J(i.inputs)};return J(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,yt.compress)(n);return btoa(JSON.stringify(o))}async function Kr(e,t,r){if(typeof r!="string")throw new Error("Invalid registry to import");let n=await t.getRegistry(),o=JSON.parse(atob(r)),i=(0,yt.decompress)(o),a=J(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let p=X(e.normalize(s.filePath)),l=n.components.find(f=>X(f.filePath).endsWith(p)&&f.exportName===s.exportName);if(!l){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${l.id})`,l.filePath),await t.registerComponent({cmpId:l.id});for(let f of s.inputs)e.debug(`set input (${l.id})`),await t.setRegisteredComponentInput({cmpId:l.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${l.id}) info`);let d=await t.setRegisteredComponentInfo({cmpId:l.id,name:s.name,image:s.image,description:s.description});a=J(d)}return a}var te={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},Nm={[te.react]:[{version:O.gen1,recommended:!0}],[te.remix]:[{version:O.gen1,recommended:!1}],[te.angular]:[{version:O.gen2,recommended:!0}],[te.next]:[{version:O.gen1,recommended:!0},{version:O.gen2,recommended:!1}],[te.qwik]:[{version:O.gen2,recommended:!0}]};var ps={"@builder.io/qwik-city":Xn,next:$n,"@remix-run/react":ar,react:fr,"@angular/core":wr},ls={"@builder.io/qwik-city":te.qwik,next:te.next,"@remix-run/react":te.remix,react:te.react,"@angular/core":te.angular};async function $r(e){if(!e.ts)throw new Error("createDevTools() requires a TypeScript instance passed to the 'ts' option");if((!e.frameworks||e.frameworks.length===0)&&(e.frameworks=await Ce(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getRootDir()}`);for(let t of e.frameworks){let r=ps[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>Vr(e,n),importRegistry:i=>Kr(e,n,i),framework:ls[t.name]}}}throw new Error(`Devtools framework not found for ${e.getRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function Mr(e){function t(f){if(typeof f!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(f))}function r(f,c){let u="",h=0,m=-1,g=0,x;for(let C=0;C<=f.length;++C){if(C<f.length)x=f.charCodeAt(C);else{if(x===47)break;x=47}if(x===47){if(!(m===C-1||g===1))if(m!==C-1&&g===2){if(u.length<2||h!==2||u.charCodeAt(u.length-1)!==46||u.charCodeAt(u.length-2)!==46){if(u.length>2){let P=u.lastIndexOf("/");if(P!==u.length-1){P===-1?(u="",h=0):(u=u.slice(0,P),h=u.length-1-u.lastIndexOf("/")),m=C,g=0;continue}}else if(u.length===2||u.length===1){u="",h=0,m=C,g=0;continue}}c&&(u.length>0?u+="/..":u="..",h=2)}else u.length>0?u+="/"+f.slice(m+1,C):u=f.slice(m+1,C),h=C-m-1;m=C,g=0}else x===46&&g!==-1?++g:g=-1}return u}let n=function(...c){let u="",h=!1;for(let m=c.length-1;m>=-1&&!h;m--){let g;m>=0?g=c[m]:e.cwd?g=e.cwd():g="/",t(g),g.length!==0&&(u=g+"/"+u,h=g.charCodeAt(0)===47)}return u=r(u,!h),h?u.length>0?"/"+u:"/":u.length>0?u:"."},o=function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0)===47,h=c.charCodeAt(c.length-1)===47;return c=r(c,!u),c.length===0&&!u&&(c="."),c.length>0&&h&&(c+="/"),u?"/"+c:c};return{relative:function(c,u){if(t(c),t(u),c===u||(c=n(c),u=n(u),c===u))return"";let h=1;for(;h<c.length&&c.charCodeAt(h)===47;++h);let m=c.length,g=m-h,x=1;for(;x<u.length&&u.charCodeAt(x)===47;++x);let P=u.length-x,I=g<P?g:P,T=-1,S=0;for(;S<=I;++S){if(S===I){if(P>I){if(u.charCodeAt(x+S)===47)return u.slice(x+S+1);if(S===0)return u.slice(x+S)}else g>I&&(c.charCodeAt(h+S)===47?T=S:S===0&&(T=0));break}let B=c.charCodeAt(h+S),F=u.charCodeAt(x+S);if(B!==F)break;B===47&&(T=S)}let R="";for(S=h+T+1;S<=m;++S)(S===m||c.charCodeAt(S)===47)&&(R.length===0?R+="..":R+="/..");return R.length>0?R+u.slice(x+T):(x+=T,u.charCodeAt(x)===47&&++x,u.slice(x))},resolve:n,join:function(...c){if(c.length===0)return".";let u;for(let h=0;h<c.length;++h){let m=c[h];t(m),m.length>0&&(u===void 0?u=m:u+="/"+m)}return u===void 0?".":o(u)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,u){if(u!==void 0&&typeof u!="string")throw new TypeError('"ext" argument must be a string');t(c);let h=0,m=-1,g=!0,x;if(u!==void 0&&u.length>0&&u.length<=c.length){if(u.length===c.length&&u===c)return"";let C=u.length-1,P=-1;for(x=c.length-1;x>=0;--x){let I=c.charCodeAt(x);if(I===47){if(!g){h=x+1;break}}else P===-1&&(g=!1,P=x+1),C>=0&&(I===u.charCodeAt(C)?--C===-1&&(m=x):(C=-1,m=P))}return h===m?m=P:m===-1&&(m=c.length),c.slice(h,m)}else{for(x=c.length-1;x>=0;--x)if(c.charCodeAt(x)===47){if(!g){h=x+1;break}}else m===-1&&(g=!1,m=x+1);return m===-1?"":c.slice(h,m)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0),h=u===47,m=-1,g=!0;for(let x=c.length-1;x>=1;--x)if(u=c.charCodeAt(x),u===47){if(!g){m=x;break}}else g=!1;return m===-1?h?"/":".":h&&m===1?"//":c.slice(0,m)},extname:function(c){t(c);let u=-1,h=0,m=-1,g=!0,x=0;for(let C=c.length-1;C>=0;--C){let P=c.charCodeAt(C);if(P===47){if(!g){h=C+1;break}continue}m===-1&&(g=!1,m=C+1),P===46?u===-1?u=C:x!==1&&(x=1):u!==-1&&(x=-1)}return u===-1||m===-1||x===0||x===1&&u===m-1&&u===h+1?"":c.slice(u,m)}}}async function Ur(e){let t=e.getRootDir?e.getRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=Mr({cwd:r,...e}),o=new Map,i=m=>n.normalize(n.resolve(r(),m)),a=m=>{for(let[g]of o)if((g+"/").startsWith(m))return!0;return m===t()},s=m=>(m=i(m),o.has(m)?!0:a(m)),p=m=>{m=i(m);let g=m===t()?m:m+"/",x=g.split("/").length-1,C=[];for(let[P]of o)if(P.split("/").slice(0,x).join("/")+"/"===g){let S=P.split("/")[x];S&&!C.includes(S)&&C.push(S)}return C.sort()},l=m=>{m=i(m);let g=o.get(m);return typeof g=="string"?g:null},d=m=>(m=i(m),{isFile:()=>o.has(m),isDirectory:()=>!o.has(m)&&a(m)}),f=async m=>{if(typeof crypto<"u"){let C=new TextEncoder().encode(m),P=await crypto.subtle.digest("SHA-256",C);return Array.from(new Uint8Array(P)).map(I=>I.toString(16).padStart(2,"0")).join("")}let g=0;for(let x=0;x<m.length;x++){let C=m.charCodeAt(x);g=(g<<5)-g+C,g|=0}return Number(Math.abs(g)).toString(36)},c=new Set,u={getRootDir:t,cwd:r,exists:async m=>s(m),existsSync:s,readdir:async m=>p(m),readdirSync:p,readFile:async m=>l(m),readFileSync:l,stat:async m=>d(m),statSync:d,writeFile:async(m,g)=>{m=i(m),o.set(m,g);let x={path:m,basename:n.basename(m),dirname:n.dirname(m),extname:n.extname(m)};for(let C of c)await C(x)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",formatCode:async(m,g)=>g,on:(m,g)=>{m==="change"&&c.add(g)},off:(m,g)=>{m==="change"&&c.delete(g)},debug:(...m)=>{console.debug("[builder-dev-tools]",...m)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null},h=await Ce(u);return u.getFrameworks=e.getFrameworks?e.getFrameworks:()=>h,u}async function zr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(qr(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Expected an export assignment from ${t}`);let c=d.statement;if(e.ts.isVariableStatement(c)){let u=[...c.declarationList.declarations];if(u.length!==1)throw new Error("Expected a single variable declaration");let h=u[0];if(!h.initializer)throw new Error("Expected an initializer on the declaration");let m=h.initializer;if(e.ts.isObjectLiteralExpression(m)||e.ts.isCallExpression(m)){let g="BuilderDevTools()",x=[...n.statements],C=x.indexOf(c);return x[C]=e.ts.factory.updateVariableStatement(c,c.modifiers,e.ts.factory.updateVariableDeclarationList(c.declarationList,[e.ts.factory.updateVariableDeclaration(h,h.name,h.exclamationToken,h.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(g),void 0,[m]))])),n=e.ts.factory.updateSourceFile(n,x),n=D(e,n,{defaultImport:"BuilderDevTools",importPath:"@builder.io/dev-tools/next"}),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}}let p=a[0];if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=an(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=an(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}if(e.ts.isArrowFunction(p.node)){let d=p.node,f=p.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let c=f.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let h=p.node.body;if(!e.ts.isBlock(h))throw new Error("Expected a block body on the next config function");let m=[...h.statements],g=m.findIndex(T=>e.ts.isReturnStatement(T));if(g===-1)throw new Error("Expected a return statement on the next config function");let x=m[g],C=an(e,n);n=C.sourceFile,m[g]=e.ts.factory.updateReturnStatement(x,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(C.withFnVariableName),void 0,[x.expression]));let P=[...n.statements],I=P.indexOf(f);return P[I]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.updateArrowFunction(d,d.modifiers,d.typeParameters,d.parameters,d.type,d.equalsGreaterThanToken,e.ts.factory.updateBlock(h,m)))),n=e.ts.factory.updateSourceFile(n,P),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected export type")}function qr(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function an(e,t){let r=qr(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function Wr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(Yr(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let p=a[0];if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isExportAssignment(f))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(f.expression)){let c="builderDevTools()",u=cs(e,f.expression);if(!u)return o;let h=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[u]),m=[...n.statements],g=m.indexOf(f);return m[g]=e.ts.factory.updateExportAssignment(f,f.modifiers,h),n=e.ts.factory.updateSourceFile(n,m),n=D(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=N(e,n),o.hasContentUpdates=!0,o}}if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=Qr(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=Qr(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}function Yr(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Qr(e,t){let r=Yr(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function cs(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Jr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Jr(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function Jr(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Hr(e,t,r){let n=E(e,r),o=G(e,n);if(o.length!==1)throw new Error(`Expected an export from ${t}`);let i=o[0];if(!i.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let a=i.statement;if(!e.ts.isExportAssignment(a))throw new Error(`Expected an export assignment from ${t}`);let s={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(e.ts.isCallExpression(i.node)&&e.ts.isIdentifier(i.node.expression)&&i.node.expression.text==="defineConfig"){let p=[...i.node.arguments];if(p.length===0)throw new Error("Expected an argument in defineConfig()");let l=p[0];if(e.ts.isArrowFunction(l)){let d=us(e,l);if(!d)return s;p[0]=e.ts.factory.updateArrowFunction(l,l.modifiers,l.typeParameters,l.parameters,l.type,l.equalsGreaterThanToken,d);let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,p)),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}if(e.ts.isObjectLiteralExpression(l)){let d=sn(e,l);if(!d)return s;let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,[d])),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(a.expression)){let p=sn(e,a.expression);if(!p)return s;let l=[...n.statements],d=l.indexOf(a);return l[d]=e.ts.factory.updateExportAssignment(a,a.modifiers,p),n=e.ts.factory.updateSourceFile(n,l),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error(`Unable to parse ${t}`)}function us(e,t){let r=t.body;if(!e.ts.isBlock(r))return null;let n=[...r.statements],o=n.findIndex(s=>e.ts.isReturnStatement(s));if(o===-1){let s=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());n.push(s),o=n.length-1}let i=n[o];if(!i.expression||!e.ts.isObjectLiteralExpression(i.expression))return null;let a=sn(e,i.expression);return a?(n[o]=e.ts.factory.updateReturnStatement(i,a),e.ts.factory.updateBlock(r,n)):null}function sn(e,t){if(ds(e)){let i=ms(e,t);i&&(t=i)}let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="plugins");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Gr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Gr(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("plugins",o)]):null}function Gr(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="builderDevTools":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("builderDevTools"),void 0,[])])}function ms(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=fs(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=pn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]);return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("ssr",i)])}return null}function fs(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=pn(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=pn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function pn(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function ds(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Xr(e,t,r){return e.debug("Webpack config updates are currently in progress..."),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function eo(e,t,r){e.debug("Angular config updates are currently in progress...");try{await hs(e)}catch{console.error("Unable to update package.json.")}return await gs(e),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function gs(e){let t=e.getRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await xs(e,o);await e.writeFile(n,i)}async function xs(e,t){let r=t,n=E(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
786
786
  builderDevTools().catch((err: Error) =>
787
787
  console.error("Error starting dev tools:", err)
788
788
  );`;return r=N(e,n),o||(r+=i),r}async function hs(e){let t=e.getRootDir(),r=e.join(t,"package.json"),n=await e.readFile(r);if(!n)throw new Error(`Unable to read package.json at ${r}`);let o=Cs(n);o&&await e.writeFile(r,o)}function Cs(e){let t=JSON.parse(e);if(t.scripts=t.scripts||{},t.scripts[Zr])return;let r=t.scripts.start||t.scripts.dev||"ng serve";return t.scripts[Zr]=`concurrently "${r}" "${Ss}"`,JSON.stringify(t,null,2)+`
@@ -805,4 +805,4 @@ module.exports = nextConfig
805
805
  `,n+=` }
806
806
  `,n+=` }
807
807
  `,n+=`})();
808
- `,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var at="1.1.4";
808
+ `,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var at="1.1.5";
package/core/index.mjs CHANGED
@@ -782,7 +782,7 @@ export class Counter {
782
782
  }
783
783
  }
784
784
 
785
- `.trimStart()}async function yr(e){await $t(e);let t=await e.readFile(e.registryPath);return t?va(e,t):{components:[],sourceFile:E(e,"")}}async function va(e,t){let r=E(e,t);return ba(e,r)}async function ba(e,t){let r=[],n=M(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Mt(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:Q(r)}}async function Mt(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[]};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(b(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let d=s.arguments[0];e.ts.isIdentifier(d)&&(a=d.text)}if(!a)continue;n.name===""&&(n.name=j(a)),n.importName=a;let p=await Pe(e,e.registryPath,t,a);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,n.importPath=k(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let l=await dr(e,p.filePath);if(l&&l.length>0)if(l.length===1)n.exportName=l[0].cmpInfo.exportName;else{let d=l.find(f=>f.cmpInfo.exportName===a);d&&(n.exportName=d.cmpInfo.exportName)}continue}}return n=W(e,n,r),n.filePath&&n.exportName&&(n.id=await _(e,n.filePath,n.exportName)),n}async function me(e,t,r,n,o,i,a,s){let p=await De(e),[l,d,f]=await Promise.all([fr(e,p),yr(e),nt(e)]),c=l.map(C=>C.cmpInfo),u=d.components,h={components:ee(c,u),registryPath:e.registryPath,registryDisplayPath:A(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ie(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return h.components=await xr(e,h.components),h;let m=!1,g=d.sourceFile,x=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(x.length>0){let C=x.map(T=>{let S=l.find(R=>R.cmpInfo.id===T);if(!S)throw new Error(`Component ${T} not found`);return S}),P=Array.from(new Set(C.map(T=>T.cmpInfo.filePath))),I=await K(e,P);for(let T of C){let S=h.components.find(L=>L.id===T.cmpInfo.id),R=await gr(e,T,I);Z(S,R);let B=c.findIndex(L=>L.id===T.cmpInfo.id);c[B].inputs=R;let F=pe(T.cmpInfo.id,c,u,r,n,o,i),{elements:y,elmIndex:w,statementIndex:V,statement:z,variableDeclaration:q}=await Ra(e,g,T);if(F.addCmpToRegistry)y.push(Ia(e,F.addCmpToRegistry)),m=!0;else if(F.removeCmpFromRegistry)y.splice(w,1),m=!0;else if(F.updateRegisteredCmp){let L=$(e,y[w],F.updateRegisteredCmp);y[w]=e.ts.factory.updateObjectLiteralExpression(L,[Tr(e,F.updateRegisteredCmp),...L.properties.slice(1)]),m=!0}if(m&&a){let L=[...g.statements];L[V]=e.ts.factory.updateVariableStatement(z,z.modifiers,e.ts.factory.updateVariableDeclarationList(z.declarationList,[e.ts.factory.updateVariableDeclaration(q,q.name,q.exclamationToken,q.type,e.ts.factory.createArrayLiteralExpression(Te(e,y)))])),g=e.ts.factory.updateSourceFile(g,L),S.exportType==="named"?g=D(e,g,{namedImports:[S.importName],importPath:v(e,e.registryPath,S.filePath)}):g=D(e,g,{defaultImport:S.importName,importPath:v(e,e.registryPath,S.filePath)}),g=D(e,g,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),g=Ee(e,g,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),h.components=F.components,u=F.components.filter(fe=>fe.isRegistered)}}}if(m&&a){g=se(e,g),g=ae(e,g);let C=N(e,g);C=H(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return h}function Tr(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function Ia(e,t){return $(e,e.ts.factory.createObjectLiteralExpression([Tr(e,t)],!0),t)}async function Ra(e,t,r){let n=M(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await Mt(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function Dr(e){let t=await Na(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Sr(t),ensureFigmaImportPage:()=>Pr(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>me(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),loadComponent:async n=>{let o=await me(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>me(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>me(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>me(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>me(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>nt(t),setPublicApiKey:n=>mr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ne(t),setCache:n=>re(t,n)}}async function Na(e){let t=await Fa(e),r=e.getRootDir(),n=e.join(r,"src"),o=await Aa(e),i=`builder-registry.${o?"ts":"js"}`,a={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:"",angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:""};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);return a.srcDir=n,a.appDir=e.join(n,"app"),a.componentsDir=e.join(a.appDir,"components"),a.registryPath=e.join(a.appDir,i),a.builderPageComponentPath=e.join(a.componentsDir,`builder-page.component.${o?"ts":"js"}`),a}function Aa(e){let t=e.join(e.getRootDir(),"tsconfig.json");return e.exists(t)}async function Fa(e){let t=e.join(e.getRootDir(),"angular.json");if(await e.exists(t))return t;throw new Error(`Could not find Angular config file. Searched for angular.json in "${e.getRootDir()}".`)}var St=po(_r(),1);async function jr(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:X(e.relative(e.getRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:J(i.inputs)};return J(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,St.compress)(n);return btoa(JSON.stringify(o))}async function Br(e,t,r){if(typeof r!="string")throw new Error("Invalid registry to import");let n=await t.getRegistry(),o=JSON.parse(atob(r)),i=(0,St.decompress)(o),a=J(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let p=X(e.normalize(s.filePath)),l=n.components.find(f=>X(f.filePath).endsWith(p)&&f.exportName===s.exportName);if(!l){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${l.id})`,l.filePath),await t.registerComponent({cmpId:l.id});for(let f of s.inputs)e.debug(`set input (${l.id})`),await t.setRegisteredComponentInput({cmpId:l.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${l.id}) info`);let d=await t.setRegisteredComponentInfo({cmpId:l.id,name:s.name,image:s.image,description:s.description});a=J(d)}return a}var te={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},bm={[te.react]:[{version:O.gen1,recommended:!0}],[te.remix]:[{version:O.gen1,recommended:!1}],[te.angular]:[{version:O.gen2,recommended:!0}],[te.next]:[{version:O.gen1,recommended:!0},{version:O.gen2,recommended:!1}],[te.qwik]:[{version:O.gen2,recommended:!0}]};var ns={"@builder.io/qwik-city":Gn,next:Vn,"@remix-run/react":or,react:ur,"@angular/core":Dr},rs={"@builder.io/qwik-city":te.qwik,next:te.next,"@remix-run/react":te.remix,react:te.react,"@angular/core":te.angular};async function os(e){if(!e.ts)throw new Error("createDevTools() requires a TypeScript instance passed to the 'ts' option");if((!e.frameworks||e.frameworks.length===0)&&(e.frameworks=await ve(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getRootDir()}`);for(let t of e.frameworks){let r=ns[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>jr(e,n),importRegistry:i=>Br(e,n,i),framework:rs[t.name]}}}throw new Error(`Devtools framework not found for ${e.getRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function Vr(e){function t(f){if(typeof f!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(f))}function r(f,c){let u="",h=0,m=-1,g=0,x;for(let C=0;C<=f.length;++C){if(C<f.length)x=f.charCodeAt(C);else{if(x===47)break;x=47}if(x===47){if(!(m===C-1||g===1))if(m!==C-1&&g===2){if(u.length<2||h!==2||u.charCodeAt(u.length-1)!==46||u.charCodeAt(u.length-2)!==46){if(u.length>2){let P=u.lastIndexOf("/");if(P!==u.length-1){P===-1?(u="",h=0):(u=u.slice(0,P),h=u.length-1-u.lastIndexOf("/")),m=C,g=0;continue}}else if(u.length===2||u.length===1){u="",h=0,m=C,g=0;continue}}c&&(u.length>0?u+="/..":u="..",h=2)}else u.length>0?u+="/"+f.slice(m+1,C):u=f.slice(m+1,C),h=C-m-1;m=C,g=0}else x===46&&g!==-1?++g:g=-1}return u}let n=function(...c){let u="",h=!1;for(let m=c.length-1;m>=-1&&!h;m--){let g;m>=0?g=c[m]:e.cwd?g=e.cwd():g="/",t(g),g.length!==0&&(u=g+"/"+u,h=g.charCodeAt(0)===47)}return u=r(u,!h),h?u.length>0?"/"+u:"/":u.length>0?u:"."},o=function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0)===47,h=c.charCodeAt(c.length-1)===47;return c=r(c,!u),c.length===0&&!u&&(c="."),c.length>0&&h&&(c+="/"),u?"/"+c:c};return{relative:function(c,u){if(t(c),t(u),c===u||(c=n(c),u=n(u),c===u))return"";let h=1;for(;h<c.length&&c.charCodeAt(h)===47;++h);let m=c.length,g=m-h,x=1;for(;x<u.length&&u.charCodeAt(x)===47;++x);let P=u.length-x,I=g<P?g:P,T=-1,S=0;for(;S<=I;++S){if(S===I){if(P>I){if(u.charCodeAt(x+S)===47)return u.slice(x+S+1);if(S===0)return u.slice(x+S)}else g>I&&(c.charCodeAt(h+S)===47?T=S:S===0&&(T=0));break}let B=c.charCodeAt(h+S),F=u.charCodeAt(x+S);if(B!==F)break;B===47&&(T=S)}let R="";for(S=h+T+1;S<=m;++S)(S===m||c.charCodeAt(S)===47)&&(R.length===0?R+="..":R+="/..");return R.length>0?R+u.slice(x+T):(x+=T,u.charCodeAt(x)===47&&++x,u.slice(x))},resolve:n,join:function(...c){if(c.length===0)return".";let u;for(let h=0;h<c.length;++h){let m=c[h];t(m),m.length>0&&(u===void 0?u=m:u+="/"+m)}return u===void 0?".":o(u)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,u){if(u!==void 0&&typeof u!="string")throw new TypeError('"ext" argument must be a string');t(c);let h=0,m=-1,g=!0,x;if(u!==void 0&&u.length>0&&u.length<=c.length){if(u.length===c.length&&u===c)return"";let C=u.length-1,P=-1;for(x=c.length-1;x>=0;--x){let I=c.charCodeAt(x);if(I===47){if(!g){h=x+1;break}}else P===-1&&(g=!1,P=x+1),C>=0&&(I===u.charCodeAt(C)?--C===-1&&(m=x):(C=-1,m=P))}return h===m?m=P:m===-1&&(m=c.length),c.slice(h,m)}else{for(x=c.length-1;x>=0;--x)if(c.charCodeAt(x)===47){if(!g){h=x+1;break}}else m===-1&&(g=!1,m=x+1);return m===-1?"":c.slice(h,m)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0),h=u===47,m=-1,g=!0;for(let x=c.length-1;x>=1;--x)if(u=c.charCodeAt(x),u===47){if(!g){m=x;break}}else g=!1;return m===-1?h?"/":".":h&&m===1?"//":c.slice(0,m)},extname:function(c){t(c);let u=-1,h=0,m=-1,g=!0,x=0;for(let C=c.length-1;C>=0;--C){let P=c.charCodeAt(C);if(P===47){if(!g){h=C+1;break}continue}m===-1&&(g=!1,m=C+1),P===46?u===-1?u=C:x!==1&&(x=1):u!==-1&&(x=-1)}return u===-1||m===-1||x===0||x===1&&u===m-1&&u===h+1?"":c.slice(u,m)}}}async function is(e){let t=e.getRootDir?e.getRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=Vr({cwd:r,...e}),o=new Map,i=m=>n.normalize(n.resolve(r(),m)),a=m=>{for(let[g]of o)if((g+"/").startsWith(m))return!0;return m===t()},s=m=>(m=i(m),o.has(m)?!0:a(m)),p=m=>{m=i(m);let g=m===t()?m:m+"/",x=g.split("/").length-1,C=[];for(let[P]of o)if(P.split("/").slice(0,x).join("/")+"/"===g){let S=P.split("/")[x];S&&!C.includes(S)&&C.push(S)}return C.sort()},l=m=>{m=i(m);let g=o.get(m);return typeof g=="string"?g:null},d=m=>(m=i(m),{isFile:()=>o.has(m),isDirectory:()=>!o.has(m)&&a(m)}),f=async m=>{if(typeof crypto<"u"){let C=new TextEncoder().encode(m),P=await crypto.subtle.digest("SHA-256",C);return Array.from(new Uint8Array(P)).map(I=>I.toString(16).padStart(2,"0")).join("")}let g=0;for(let x=0;x<m.length;x++){let C=m.charCodeAt(x);g=(g<<5)-g+C,g|=0}return Number(Math.abs(g)).toString(36)},c=new Set,u={getRootDir:t,cwd:r,exists:async m=>s(m),existsSync:s,readdir:async m=>p(m),readdirSync:p,readFile:async m=>l(m),readFileSync:l,stat:async m=>d(m),statSync:d,writeFile:async(m,g)=>{m=i(m),o.set(m,g);let x={path:m,basename:n.basename(m),dirname:n.dirname(m),extname:n.extname(m)};for(let C of c)await C(x)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",formatCode:async(m,g)=>g,on:(m,g)=>{m==="change"&&c.add(g)},off:(m,g)=>{m==="change"&&c.delete(g)},debug:(...m)=>{console.debug("[builder-dev-tools]",...m)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,ignoreMissingConfig:!1},h=await ve(u);return u.getFrameworks=e.getFrameworks?e.getFrameworks:()=>h,u}async function Kr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if($r(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Expected an export assignment from ${t}`);let c=d.statement;if(e.ts.isVariableStatement(c)){let u=[...c.declarationList.declarations];if(u.length!==1)throw new Error("Expected a single variable declaration");let h=u[0];if(!h.initializer)throw new Error("Expected an initializer on the declaration");let m=h.initializer;if(e.ts.isObjectLiteralExpression(m)||e.ts.isCallExpression(m)){let g="BuilderDevTools()",x=[...n.statements],C=x.indexOf(c);return x[C]=e.ts.factory.updateVariableStatement(c,c.modifiers,e.ts.factory.updateVariableDeclarationList(c.declarationList,[e.ts.factory.updateVariableDeclaration(h,h.name,h.exclamationToken,h.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(g),void 0,[m]))])),n=e.ts.factory.updateSourceFile(n,x),n=D(e,n,{defaultImport:"BuilderDevTools",importPath:"@builder.io/dev-tools/next"}),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}}let p=a[0];if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=nn(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=nn(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}if(e.ts.isArrowFunction(p.node)){let d=p.node,f=p.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let c=f.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let h=p.node.body;if(!e.ts.isBlock(h))throw new Error("Expected a block body on the next config function");let m=[...h.statements],g=m.findIndex(T=>e.ts.isReturnStatement(T));if(g===-1)throw new Error("Expected a return statement on the next config function");let x=m[g],C=nn(e,n);n=C.sourceFile,m[g]=e.ts.factory.updateReturnStatement(x,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(C.withFnVariableName),void 0,[x.expression]));let P=[...n.statements],I=P.indexOf(f);return P[I]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.updateArrowFunction(d,d.modifiers,d.typeParameters,d.parameters,d.type,d.equalsGreaterThanToken,e.ts.factory.updateBlock(h,m)))),n=e.ts.factory.updateSourceFile(n,P),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected export type")}function $r(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function nn(e,t){let r=$r(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function zr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(qr(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let p=a[0];if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isExportAssignment(f))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(f.expression)){let c="builderDevTools()",u=as(e,f.expression);if(!u)return o;let h=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[u]),m=[...n.statements],g=m.indexOf(f);return m[g]=e.ts.factory.updateExportAssignment(f,f.modifiers,h),n=e.ts.factory.updateSourceFile(n,m),n=D(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=N(e,n),o.hasContentUpdates=!0,o}}if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=Mr(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=Mr(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}function qr(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Mr(e,t){let r=qr(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function as(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Ur(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Ur(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function Ur(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Jr(e,t,r){let n=E(e,r),o=G(e,n);if(o.length!==1)throw new Error(`Expected an export from ${t}`);let i=o[0];if(!i.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let a=i.statement;if(!e.ts.isExportAssignment(a))throw new Error(`Expected an export assignment from ${t}`);let s={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(e.ts.isCallExpression(i.node)&&e.ts.isIdentifier(i.node.expression)&&i.node.expression.text==="defineConfig"){let p=[...i.node.arguments];if(p.length===0)throw new Error("Expected an argument in defineConfig()");let l=p[0];if(e.ts.isArrowFunction(l)){let d=ss(e,l);if(!d)return s;p[0]=e.ts.factory.updateArrowFunction(l,l.modifiers,l.typeParameters,l.parameters,l.type,l.equalsGreaterThanToken,d);let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,p)),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}if(e.ts.isObjectLiteralExpression(l)){let d=rn(e,l);if(!d)return s;let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,[d])),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(a.expression)){let p=rn(e,a.expression);if(!p)return s;let l=[...n.statements],d=l.indexOf(a);return l[d]=e.ts.factory.updateExportAssignment(a,a.modifiers,p),n=e.ts.factory.updateSourceFile(n,l),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error(`Unable to parse ${t}`)}function ss(e,t){let r=t.body;if(!e.ts.isBlock(r))return null;let n=[...r.statements],o=n.findIndex(s=>e.ts.isReturnStatement(s));if(o===-1){let s=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());n.push(s),o=n.length-1}let i=n[o];if(!i.expression||!e.ts.isObjectLiteralExpression(i.expression))return null;let a=rn(e,i.expression);return a?(n[o]=e.ts.factory.updateReturnStatement(i,a),e.ts.factory.updateBlock(r,n)):null}function rn(e,t){if(cs(e)){let i=ps(e,t);i&&(t=i)}let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="plugins");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Qr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Qr(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("plugins",o)]):null}function Qr(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="builderDevTools":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("builderDevTools"),void 0,[])])}function ps(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=ls(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=on(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]);return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("ssr",i)])}return null}function ls(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=on(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=on(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function on(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function cs(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Wr(e,t,r){return e.debug("Webpack config updates are currently in progress..."),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function Gr(e,t,r){e.debug("Angular config updates are currently in progress...");try{await fs(e)}catch{console.error("Unable to update package.json.")}return await us(e),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function us(e){let t=e.getRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await ms(e,o);await e.writeFile(n,i)}async function ms(e,t){let r=t,n=E(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
785
+ `.trimStart()}async function yr(e){await $t(e);let t=await e.readFile(e.registryPath);return t?va(e,t):{components:[],sourceFile:E(e,"")}}async function va(e,t){let r=E(e,t);return ba(e,r)}async function ba(e,t){let r=[],n=M(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Mt(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:Q(r)}}async function Mt(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[]};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(b(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let d=s.arguments[0];e.ts.isIdentifier(d)&&(a=d.text)}if(!a)continue;n.name===""&&(n.name=j(a)),n.importName=a;let p=await Pe(e,e.registryPath,t,a);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,n.importPath=k(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let l=await dr(e,p.filePath);if(l&&l.length>0)if(l.length===1)n.exportName=l[0].cmpInfo.exportName;else{let d=l.find(f=>f.cmpInfo.exportName===a);d&&(n.exportName=d.cmpInfo.exportName)}continue}}return n=W(e,n,r),n.filePath&&n.exportName&&(n.id=await _(e,n.filePath,n.exportName)),n}async function me(e,t,r,n,o,i,a,s){let p=await De(e),[l,d,f]=await Promise.all([fr(e,p),yr(e),nt(e)]),c=l.map(C=>C.cmpInfo),u=d.components,h={components:ee(c,u),registryPath:e.registryPath,registryDisplayPath:A(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ie(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return h.components=await xr(e,h.components),h;let m=!1,g=d.sourceFile,x=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(x.length>0){let C=x.map(T=>{let S=l.find(R=>R.cmpInfo.id===T);if(!S)throw new Error(`Component ${T} not found`);return S}),P=Array.from(new Set(C.map(T=>T.cmpInfo.filePath))),I=await K(e,P);for(let T of C){let S=h.components.find(L=>L.id===T.cmpInfo.id),R=await gr(e,T,I);Z(S,R);let B=c.findIndex(L=>L.id===T.cmpInfo.id);c[B].inputs=R;let F=pe(T.cmpInfo.id,c,u,r,n,o,i),{elements:y,elmIndex:w,statementIndex:V,statement:z,variableDeclaration:q}=await Ra(e,g,T);if(F.addCmpToRegistry)y.push(Ia(e,F.addCmpToRegistry)),m=!0;else if(F.removeCmpFromRegistry)y.splice(w,1),m=!0;else if(F.updateRegisteredCmp){let L=$(e,y[w],F.updateRegisteredCmp);y[w]=e.ts.factory.updateObjectLiteralExpression(L,[Tr(e,F.updateRegisteredCmp),...L.properties.slice(1)]),m=!0}if(m&&a){let L=[...g.statements];L[V]=e.ts.factory.updateVariableStatement(z,z.modifiers,e.ts.factory.updateVariableDeclarationList(z.declarationList,[e.ts.factory.updateVariableDeclaration(q,q.name,q.exclamationToken,q.type,e.ts.factory.createArrayLiteralExpression(Te(e,y)))])),g=e.ts.factory.updateSourceFile(g,L),S.exportType==="named"?g=D(e,g,{namedImports:[S.importName],importPath:v(e,e.registryPath,S.filePath)}):g=D(e,g,{defaultImport:S.importName,importPath:v(e,e.registryPath,S.filePath)}),g=D(e,g,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),g=Ee(e,g,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),h.components=F.components,u=F.components.filter(fe=>fe.isRegistered)}}}if(m&&a){g=se(e,g),g=ae(e,g);let C=N(e,g);C=H(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return h}function Tr(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function Ia(e,t){return $(e,e.ts.factory.createObjectLiteralExpression([Tr(e,t)],!0),t)}async function Ra(e,t,r){let n=M(e,t,"CUSTOM_COMPONENTS");if(!n)throw new Error(`Exported name of the Builder registry must be "CUSTOM_COMPONENTS". Please update your Builder registry file: ${e.registryPath}`);let o=n.arrayLiteralExp.elements.filter(a=>e.ts.isObjectLiteralExpression(a)),i=-1;for(let a=0;a<o.length;a++)if((await Mt(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function Dr(e){let t=await Na(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Sr(t),ensureFigmaImportPage:()=>Pr(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>me(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),loadComponent:async n=>{let o=await me(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>me(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>me(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>me(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>me(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>nt(t),setPublicApiKey:n=>mr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ne(t),setCache:n=>re(t,n)}}async function Na(e){let t=await Fa(e),r=e.getRootDir(),n=e.join(r,"src"),o=await Aa(e),i=`builder-registry.${o?"ts":"js"}`,a={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:"",angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:""};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);return a.srcDir=n,a.appDir=e.join(n,"app"),a.componentsDir=e.join(a.appDir,"components"),a.registryPath=e.join(a.appDir,i),a.builderPageComponentPath=e.join(a.componentsDir,`builder-page.component.${o?"ts":"js"}`),a}function Aa(e){let t=e.join(e.getRootDir(),"tsconfig.json");return e.exists(t)}async function Fa(e){let t=e.join(e.getRootDir(),"angular.json");if(await e.exists(t))return t;throw new Error(`Could not find Angular config file. Searched for angular.json in "${e.getRootDir()}".`)}var St=po(_r(),1);async function jr(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:X(e.relative(e.getRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:J(i.inputs)};return J(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,St.compress)(n);return btoa(JSON.stringify(o))}async function Br(e,t,r){if(typeof r!="string")throw new Error("Invalid registry to import");let n=await t.getRegistry(),o=JSON.parse(atob(r)),i=(0,St.decompress)(o),a=J(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let p=X(e.normalize(s.filePath)),l=n.components.find(f=>X(f.filePath).endsWith(p)&&f.exportName===s.exportName);if(!l){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${l.id})`,l.filePath),await t.registerComponent({cmpId:l.id});for(let f of s.inputs)e.debug(`set input (${l.id})`),await t.setRegisteredComponentInput({cmpId:l.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${l.id}) info`);let d=await t.setRegisteredComponentInfo({cmpId:l.id,name:s.name,image:s.image,description:s.description});a=J(d)}return a}var te={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},bm={[te.react]:[{version:O.gen1,recommended:!0}],[te.remix]:[{version:O.gen1,recommended:!1}],[te.angular]:[{version:O.gen2,recommended:!0}],[te.next]:[{version:O.gen1,recommended:!0},{version:O.gen2,recommended:!1}],[te.qwik]:[{version:O.gen2,recommended:!0}]};var ns={"@builder.io/qwik-city":Gn,next:Vn,"@remix-run/react":or,react:ur,"@angular/core":Dr},rs={"@builder.io/qwik-city":te.qwik,next:te.next,"@remix-run/react":te.remix,react:te.react,"@angular/core":te.angular};async function os(e){if(!e.ts)throw new Error("createDevTools() requires a TypeScript instance passed to the 'ts' option");if((!e.frameworks||e.frameworks.length===0)&&(e.frameworks=await ve(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getRootDir()}`);for(let t of e.frameworks){let r=ns[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>jr(e,n),importRegistry:i=>Br(e,n,i),framework:rs[t.name]}}}throw new Error(`Devtools framework not found for ${e.getRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function Vr(e){function t(f){if(typeof f!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(f))}function r(f,c){let u="",h=0,m=-1,g=0,x;for(let C=0;C<=f.length;++C){if(C<f.length)x=f.charCodeAt(C);else{if(x===47)break;x=47}if(x===47){if(!(m===C-1||g===1))if(m!==C-1&&g===2){if(u.length<2||h!==2||u.charCodeAt(u.length-1)!==46||u.charCodeAt(u.length-2)!==46){if(u.length>2){let P=u.lastIndexOf("/");if(P!==u.length-1){P===-1?(u="",h=0):(u=u.slice(0,P),h=u.length-1-u.lastIndexOf("/")),m=C,g=0;continue}}else if(u.length===2||u.length===1){u="",h=0,m=C,g=0;continue}}c&&(u.length>0?u+="/..":u="..",h=2)}else u.length>0?u+="/"+f.slice(m+1,C):u=f.slice(m+1,C),h=C-m-1;m=C,g=0}else x===46&&g!==-1?++g:g=-1}return u}let n=function(...c){let u="",h=!1;for(let m=c.length-1;m>=-1&&!h;m--){let g;m>=0?g=c[m]:e.cwd?g=e.cwd():g="/",t(g),g.length!==0&&(u=g+"/"+u,h=g.charCodeAt(0)===47)}return u=r(u,!h),h?u.length>0?"/"+u:"/":u.length>0?u:"."},o=function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0)===47,h=c.charCodeAt(c.length-1)===47;return c=r(c,!u),c.length===0&&!u&&(c="."),c.length>0&&h&&(c+="/"),u?"/"+c:c};return{relative:function(c,u){if(t(c),t(u),c===u||(c=n(c),u=n(u),c===u))return"";let h=1;for(;h<c.length&&c.charCodeAt(h)===47;++h);let m=c.length,g=m-h,x=1;for(;x<u.length&&u.charCodeAt(x)===47;++x);let P=u.length-x,I=g<P?g:P,T=-1,S=0;for(;S<=I;++S){if(S===I){if(P>I){if(u.charCodeAt(x+S)===47)return u.slice(x+S+1);if(S===0)return u.slice(x+S)}else g>I&&(c.charCodeAt(h+S)===47?T=S:S===0&&(T=0));break}let B=c.charCodeAt(h+S),F=u.charCodeAt(x+S);if(B!==F)break;B===47&&(T=S)}let R="";for(S=h+T+1;S<=m;++S)(S===m||c.charCodeAt(S)===47)&&(R.length===0?R+="..":R+="/..");return R.length>0?R+u.slice(x+T):(x+=T,u.charCodeAt(x)===47&&++x,u.slice(x))},resolve:n,join:function(...c){if(c.length===0)return".";let u;for(let h=0;h<c.length;++h){let m=c[h];t(m),m.length>0&&(u===void 0?u=m:u+="/"+m)}return u===void 0?".":o(u)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,u){if(u!==void 0&&typeof u!="string")throw new TypeError('"ext" argument must be a string');t(c);let h=0,m=-1,g=!0,x;if(u!==void 0&&u.length>0&&u.length<=c.length){if(u.length===c.length&&u===c)return"";let C=u.length-1,P=-1;for(x=c.length-1;x>=0;--x){let I=c.charCodeAt(x);if(I===47){if(!g){h=x+1;break}}else P===-1&&(g=!1,P=x+1),C>=0&&(I===u.charCodeAt(C)?--C===-1&&(m=x):(C=-1,m=P))}return h===m?m=P:m===-1&&(m=c.length),c.slice(h,m)}else{for(x=c.length-1;x>=0;--x)if(c.charCodeAt(x)===47){if(!g){h=x+1;break}}else m===-1&&(g=!1,m=x+1);return m===-1?"":c.slice(h,m)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let u=c.charCodeAt(0),h=u===47,m=-1,g=!0;for(let x=c.length-1;x>=1;--x)if(u=c.charCodeAt(x),u===47){if(!g){m=x;break}}else g=!1;return m===-1?h?"/":".":h&&m===1?"//":c.slice(0,m)},extname:function(c){t(c);let u=-1,h=0,m=-1,g=!0,x=0;for(let C=c.length-1;C>=0;--C){let P=c.charCodeAt(C);if(P===47){if(!g){h=C+1;break}continue}m===-1&&(g=!1,m=C+1),P===46?u===-1?u=C:x!==1&&(x=1):u!==-1&&(x=-1)}return u===-1||m===-1||x===0||x===1&&u===m-1&&u===h+1?"":c.slice(u,m)}}}async function is(e){let t=e.getRootDir?e.getRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=Vr({cwd:r,...e}),o=new Map,i=m=>n.normalize(n.resolve(r(),m)),a=m=>{for(let[g]of o)if((g+"/").startsWith(m))return!0;return m===t()},s=m=>(m=i(m),o.has(m)?!0:a(m)),p=m=>{m=i(m);let g=m===t()?m:m+"/",x=g.split("/").length-1,C=[];for(let[P]of o)if(P.split("/").slice(0,x).join("/")+"/"===g){let S=P.split("/")[x];S&&!C.includes(S)&&C.push(S)}return C.sort()},l=m=>{m=i(m);let g=o.get(m);return typeof g=="string"?g:null},d=m=>(m=i(m),{isFile:()=>o.has(m),isDirectory:()=>!o.has(m)&&a(m)}),f=async m=>{if(typeof crypto<"u"){let C=new TextEncoder().encode(m),P=await crypto.subtle.digest("SHA-256",C);return Array.from(new Uint8Array(P)).map(I=>I.toString(16).padStart(2,"0")).join("")}let g=0;for(let x=0;x<m.length;x++){let C=m.charCodeAt(x);g=(g<<5)-g+C,g|=0}return Number(Math.abs(g)).toString(36)},c=new Set,u={getRootDir:t,cwd:r,exists:async m=>s(m),existsSync:s,readdir:async m=>p(m),readdirSync:p,readFile:async m=>l(m),readFileSync:l,stat:async m=>d(m),statSync:d,writeFile:async(m,g)=>{m=i(m),o.set(m,g);let x={path:m,basename:n.basename(m),dirname:n.dirname(m),extname:n.extname(m)};for(let C of c)await C(x)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",formatCode:async(m,g)=>g,on:(m,g)=>{m==="change"&&c.add(g)},off:(m,g)=>{m==="change"&&c.delete(g)},debug:(...m)=>{console.debug("[builder-dev-tools]",...m)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null},h=await ve(u);return u.getFrameworks=e.getFrameworks?e.getFrameworks:()=>h,u}async function Kr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if($r(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Expected an export assignment from ${t}`);let c=d.statement;if(e.ts.isVariableStatement(c)){let u=[...c.declarationList.declarations];if(u.length!==1)throw new Error("Expected a single variable declaration");let h=u[0];if(!h.initializer)throw new Error("Expected an initializer on the declaration");let m=h.initializer;if(e.ts.isObjectLiteralExpression(m)||e.ts.isCallExpression(m)){let g="BuilderDevTools()",x=[...n.statements],C=x.indexOf(c);return x[C]=e.ts.factory.updateVariableStatement(c,c.modifiers,e.ts.factory.updateVariableDeclarationList(c.declarationList,[e.ts.factory.updateVariableDeclaration(h,h.name,h.exclamationToken,h.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(g),void 0,[m]))])),n=e.ts.factory.updateSourceFile(n,x),n=D(e,n,{defaultImport:"BuilderDevTools",importPath:"@builder.io/dev-tools/next"}),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}}let p=a[0];if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=nn(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=nn(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}if(e.ts.isArrowFunction(p.node)){let d=p.node,f=p.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let c=f.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let h=p.node.body;if(!e.ts.isBlock(h))throw new Error("Expected a block body on the next config function");let m=[...h.statements],g=m.findIndex(T=>e.ts.isReturnStatement(T));if(g===-1)throw new Error("Expected a return statement on the next config function");let x=m[g],C=nn(e,n);n=C.sourceFile,m[g]=e.ts.factory.updateReturnStatement(x,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(C.withFnVariableName),void 0,[x.expression]));let P=[...n.statements],I=P.indexOf(f);return P[I]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.updateArrowFunction(d,d.modifiers,d.typeParameters,d.parameters,d.type,d.equalsGreaterThanToken,e.ts.factory.updateBlock(h,m)))),n=e.ts.factory.updateSourceFile(n,P),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected export type")}function $r(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function nn(e,t){let r=$r(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function zr(e,t,r){let n=E(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(qr(e,n))return o;let a=G(e,n,"cjs"),s=G(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let p=a[0];if(s.length===1){let d=s[0];if(!d.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=d.statement;if(!e.ts.isExportAssignment(f))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(f.expression)){let c="builderDevTools()",u=as(e,f.expression);if(!u)return o;let h=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[u]),m=[...n.statements],g=m.indexOf(f);return m[g]=e.ts.factory.updateExportAssignment(f,f.modifiers,h),n=e.ts.factory.updateSourceFile(n,m),n=D(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=N(e,n),o.hasContentUpdates=!0,o}}if(!p.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let d=p.statement;if(!e.ts.isExpressionStatement(d))throw new Error("Expected an expression statement for the default export");let f=d.expression;if(!e.ts.isBinaryExpression(f))throw new Error("Expected a binary expression for the default export");let c=Mr(e,n);n=c.sourceFile;let u=[...n.statements],h=u.indexOf(d);return u[h]=e.ts.factory.updateExpressionStatement(d,e.ts.factory.updateBinaryExpression(f,f.left,f.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[f.right]))),n=e.ts.factory.updateSourceFile(n,u),o.content=N(e,n),o.hasContentUpdates=!0,o}let l=p.statement;if(e.ts.isVariableStatement(l)){let d=[...l.declarationList.declarations];if(d.length!==1)throw new Error("Expected a single variable declaration");let f=d[0];if(!f.initializer)throw new Error("Expected an initializer on the declaration");let c=f.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let u=Mr(e,n);n=u.sourceFile;let h=[...n.statements],m=h.indexOf(l);return h[m]=e.ts.factory.updateVariableStatement(l,l.modifiers,e.ts.factory.updateVariableDeclarationList(l.declarationList,[e.ts.factory.updateVariableDeclaration(f,f.name,f.exclamationToken,f.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(u.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,h),o.content=N(e,n),o.hasContentUpdates=!0,o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}function qr(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Mr(e,t){let r=qr(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[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.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function as(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Ur(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Ur(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function Ur(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Jr(e,t,r){let n=E(e,r),o=G(e,n);if(o.length!==1)throw new Error(`Expected an export from ${t}`);let i=o[0];if(!i.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let a=i.statement;if(!e.ts.isExportAssignment(a))throw new Error(`Expected an export assignment from ${t}`);let s={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(e.ts.isCallExpression(i.node)&&e.ts.isIdentifier(i.node.expression)&&i.node.expression.text==="defineConfig"){let p=[...i.node.arguments];if(p.length===0)throw new Error("Expected an argument in defineConfig()");let l=p[0];if(e.ts.isArrowFunction(l)){let d=ss(e,l);if(!d)return s;p[0]=e.ts.factory.updateArrowFunction(l,l.modifiers,l.typeParameters,l.parameters,l.type,l.equalsGreaterThanToken,d);let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,p)),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}if(e.ts.isObjectLiteralExpression(l)){let d=rn(e,l);if(!d)return s;let f=[...n.statements],c=f.indexOf(a);return f[c]=e.ts.factory.updateExportAssignment(a,void 0,e.ts.factory.updateCallExpression(i.node,i.node.expression,i.node.typeArguments,[d])),n=e.ts.factory.updateSourceFile(n,f),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(a.expression)){let p=rn(e,a.expression);if(!p)return s;let l=[...n.statements],d=l.indexOf(a);return l[d]=e.ts.factory.updateExportAssignment(a,a.modifiers,p),n=e.ts.factory.updateSourceFile(n,l),n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/vite"}),s.content=N(e,n),s.hasContentUpdates=!0,s}throw new Error(`Unable to parse ${t}`)}function ss(e,t){let r=t.body;if(!e.ts.isBlock(r))return null;let n=[...r.statements],o=n.findIndex(s=>e.ts.isReturnStatement(s));if(o===-1){let s=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());n.push(s),o=n.length-1}let i=n[o];if(!i.expression||!e.ts.isObjectLiteralExpression(i.expression))return null;let a=rn(e,i.expression);return a?(n[o]=e.ts.factory.updateReturnStatement(i,a),e.ts.factory.updateBlock(r,n)):null}function rn(e,t){if(cs(e)){let i=ps(e,t);i&&(t=i)}let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="plugins");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Qr(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Qr(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("plugins",o)]):null}function Qr(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="builderDevTools":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("builderDevTools"),void 0,[])])}function ps(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=ls(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=on(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]);return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("ssr",i)])}return null}function ls(e,t){let r=[...t.properties],n=r.findIndex(i=>b(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=on(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=on(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function on(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function cs(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Wr(e,t,r){return e.debug("Webpack config updates are currently in progress..."),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function Gr(e,t,r){e.debug("Angular config updates are currently in progress...");try{await fs(e)}catch{console.error("Unable to update package.json.")}return await us(e),{content:r,fileName:e.basename(t),filePath:t,hasContentUpdates:!0}}async function us(e){let t=e.getRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await ms(e,o);await e.writeFile(n,i)}async function ms(e,t){let r=t,n=E(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=D(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
786
786
  builderDevTools().catch((err: Error) =>
787
787
  console.error("Error starting dev tools:", err)
788
788
  );`;return r=N(e,n),o||(r+=i),r}async function fs(e){let t=e.getRootDir(),r=e.join(t,"package.json"),n=await e.readFile(r);if(!n)throw new Error(`Unable to read package.json at ${r}`);let o=ds(n);o&&await e.writeFile(r,o)}function ds(e){let t=JSON.parse(e);if(t.scripts=t.scripts||{},t.scripts[Yr])return;let r=t.scripts.start||t.scripts.dev||"ng serve";return t.scripts[Yr]=`concurrently "${r}" "${gs}"`,JSON.stringify(t,null,2)+`
@@ -805,4 +805,4 @@ module.exports = nextConfig
805
805
  `,n+=` }
806
806
  `,n+=` }
807
807
  `,n+=`})();
808
- `,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var Pt="1.1.4";export{os as createDevTools,is as createDevToolsSys,ve as detectFrameworks,pn as detectFrameworksFromPackageJson,xs as ensureConfigPlugin,Zr as findBuildToolConfig,hs as getClientScript,cn as parseDotEnvContent,Pt as version};
808
+ `,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var Pt="1.1.5";export{os as createDevTools,is as createDevToolsSys,ve as detectFrameworks,pn as detectFrameworksFromPackageJson,xs as ensureConfigPlugin,Zr as findBuildToolConfig,hs as getClientScript,cn as parseDotEnvContent,Pt as version};
package/node/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.create;var m=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var E=(t,o)=>{for(var n in o)m(t,n,{get:o[n],enumerable:!0})},S=(t,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of C(o))!T.call(t,a)&&a!==n&&m(t,a,{get:()=>o[a],enumerable:!(i=x(o,a))||i.enumerable});return t};var g=(t,o,n)=>(n=t!=null?b(N(t)):{},S(o||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),j=t=>S(m({},"__esModule",{value:!0}),t);var J={};E(J,{createDevToolsNodeSys:()=>O});module.exports=j(J);var s=require("fs/promises"),v=require("crypto"),d=require("fs"),y=require("os"),l=g(require("path"),1),h=g(require("prettier"),1),D=g(require("typescript"),1),F=g(require("launch-editor"),1);async function w(t,o){let n=t.resolve("/");for(let i=0;i<20;i++){let a=t.join(o,"package.json"),u=await t.readFile(a);if(u)return JSON.parse(u);if(o===n)break;o=t.dirname(o)}return null}async function k(t){let o=[],n=await w(t,t.getRootDir());if(n){let i=P(n);o.push(...i)}return o}function P(t){let o=[];if(t&&typeof t=="object"){let n=new Set(Object.keys({...t.dependencies,...t.devDependencies}));for(let i of R)n.has(i)&&(o.some(a=>a.name===i)||o.push({name:i}))}return o}var R=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"];async function O(t){let o=new Set,n=(...e)=>{if(process.env.DEBUG){let r=new Date,c=`${String(r.getMinutes()).padStart(2,"0")}:${String(r.getSeconds()).padStart(2,"0")}.${String(r.getMilliseconds()).padStart(3,"0")}`;console.debug(c,"[builder-dev-tools]",...e)}},i=async e=>{let r=(0,v.createHash)("md5");return r.update(e),r.digest("hex")},a={...l.default,getRootDir:()=>l.default.normalize(t.getRootDir()),cwd:()=>process.cwd(),exists:async e=>{try{return await(0,s.access)(e),!0}catch{return!1}},existsSync:e=>(0,d.existsSync)(e),readdir:async(e,r)=>{let c=await(0,s.readdir)(e);return r?c.map(f=>l.default.join(e,f)):c},readdirSync:e=>(0,d.readdirSync)(e),readFile:async e=>{p(t,e);try{return await(0,s.readFile)(e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw n(r,e),r}},readFileSync(e){p(t,e);try{return(0,d.readFileSync)(e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw n(r,e),r}},stat:async e=>await(0,s.stat)(e),statSync:e=>(0,d.statSync)(e),writeFile:async(e,r)=>{p(t,e),e=l.default.normalize(e);let c={path:e,basename:l.default.basename(e),dirname:l.default.dirname(e),extname:l.default.extname(e)};await(0,s.mkdir)(l.default.dirname(e),{recursive:!0}),await(0,s.writeFile)(e,r);for(let f of o)await f(c)},hash:i,getDeviceId:()=>i(`${(0,y.hostname)()}:${(0,y.homedir)()}`),formatCode:async(e,r)=>{let c=null;try{c=await h.default.resolveConfig(e)}catch{}try{return h.default.format(r,{...c,filepath:e})}catch{}return r},on:(e,r)=>{e==="change"&&o.add(r)},off:(e,r)=>{e==="change"&&o.delete(r)},debug:n,launchEditor:async e=>{try{let r=e.filePath;typeof e.line=="number"&&(r+=`:${e.line}`,typeof e.column=="number"&&(r+=`:${e.column}`)),(0,F.default)(r,"code",(c,f)=>{console.error(`Failed to launch editor for ${c}`),f&&console.error(f)})}catch(r){console.error(`Failed to launch editor for ${String(r.message||r)}`)}},platform:()=>({runtime:"node",os:process.platform}),getFrameworks:()=>[],ts:D.default,version:"1.1.4",sdkVersion:null,ignoreMissingConfig:t.ignoreMissingConfig??!1},u=await k(a);return a.getFrameworks=()=>u,a}function p(t,o){if(t.skipValidate)return;if(!o)throw new Error(`Invalid path: ${o} (7340)`);o=l.default.normalize(l.default.resolve(o));let n=t.getRootDir();if(!o.startsWith(n)&&!o.includes("node_modules"))throw new Error(`Invalid path: ${o} (7341)`)}0&&(module.exports={createDevToolsNodeSys});
1
+ "use strict";var b=Object.create;var m=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var E=(t,o)=>{for(var n in o)m(t,n,{get:o[n],enumerable:!0})},S=(t,o,n,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of C(o))!T.call(t,a)&&a!==n&&m(t,a,{get:()=>o[a],enumerable:!(i=x(o,a))||i.enumerable});return t};var g=(t,o,n)=>(n=t!=null?b(N(t)):{},S(o||!t||!t.__esModule?m(n,"default",{value:t,enumerable:!0}):n,t)),j=t=>S(m({},"__esModule",{value:!0}),t);var J={};E(J,{createDevToolsNodeSys:()=>O});module.exports=j(J);var s=require("fs/promises"),v=require("crypto"),d=require("fs"),y=require("os"),l=g(require("path"),1),h=g(require("prettier"),1),D=g(require("typescript"),1),F=g(require("launch-editor"),1);async function w(t,o){let n=t.resolve("/");for(let i=0;i<20;i++){let a=t.join(o,"package.json"),u=await t.readFile(a);if(u)return JSON.parse(u);if(o===n)break;o=t.dirname(o)}return null}async function k(t){let o=[],n=await w(t,t.getRootDir());if(n){let i=P(n);o.push(...i)}return o}function P(t){let o=[];if(t&&typeof t=="object"){let n=new Set(Object.keys({...t.dependencies,...t.devDependencies}));for(let i of R)n.has(i)&&(o.some(a=>a.name===i)||o.push({name:i}))}return o}var R=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"];async function O(t){let o=new Set,n=(...e)=>{if(process.env.DEBUG){let r=new Date,c=`${String(r.getMinutes()).padStart(2,"0")}:${String(r.getSeconds()).padStart(2,"0")}.${String(r.getMilliseconds()).padStart(3,"0")}`;console.debug(c,"[builder-dev-tools]",...e)}},i=async e=>{let r=(0,v.createHash)("md5");return r.update(e),r.digest("hex")},a={...l.default,getRootDir:()=>l.default.normalize(t.getRootDir()),cwd:()=>process.cwd(),exists:async e=>{try{return await(0,s.access)(e),!0}catch{return!1}},existsSync:e=>(0,d.existsSync)(e),readdir:async(e,r)=>{let c=await(0,s.readdir)(e);return r?c.map(f=>l.default.join(e,f)):c},readdirSync:e=>(0,d.readdirSync)(e),readFile:async e=>{p(t,e);try{return await(0,s.readFile)(e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw n(r,e),r}},readFileSync(e){p(t,e);try{return(0,d.readFileSync)(e,"utf-8")}catch(r){if(r.code==="ENOENT")return null;throw n(r,e),r}},stat:async e=>await(0,s.stat)(e),statSync:e=>(0,d.statSync)(e),writeFile:async(e,r)=>{p(t,e),e=l.default.normalize(e);let c={path:e,basename:l.default.basename(e),dirname:l.default.dirname(e),extname:l.default.extname(e)};await(0,s.mkdir)(l.default.dirname(e),{recursive:!0}),await(0,s.writeFile)(e,r);for(let f of o)await f(c)},hash:i,getDeviceId:()=>i(`${(0,y.hostname)()}:${(0,y.homedir)()}`),formatCode:async(e,r)=>{let c=null;try{c=await h.default.resolveConfig(e)}catch{}try{return h.default.format(r,{...c,filepath:e})}catch{}return r},on:(e,r)=>{e==="change"&&o.add(r)},off:(e,r)=>{e==="change"&&o.delete(r)},debug:n,launchEditor:async e=>{try{let r=e.filePath;typeof e.line=="number"&&(r+=`:${e.line}`,typeof e.column=="number"&&(r+=`:${e.column}`)),(0,F.default)(r,"code",(c,f)=>{console.error(`Failed to launch editor for ${c}`),f&&console.error(f)})}catch(r){console.error(`Failed to launch editor for ${String(r.message||r)}`)}},platform:()=>({runtime:"node",os:process.platform}),getFrameworks:()=>[],ts:D.default,version:"1.1.5",sdkVersion:null,ignoreMissingConfig:t.ignoreMissingConfig},u=await k(a);return a.getFrameworks=()=>u,a}function p(t,o){if(t.skipValidate)return;if(!o)throw new Error(`Invalid path: ${o} (7340)`);o=l.default.normalize(l.default.resolve(o));let n=t.getRootDir();if(!o.startsWith(n)&&!o.includes("node_modules"))throw new Error(`Invalid path: ${o} (7341)`)}0&&(module.exports={createDevToolsNodeSys});
package/node/index.mjs CHANGED
@@ -1 +1 @@
1
- import{access as h,mkdir as S,readdir as w,readFile as k,stat as v,writeFile as D}from"fs/promises";import{createHash as F}from"crypto";import{existsSync as O,readdirSync as b,readFileSync as x,statSync as C}from"fs";import{homedir as N,hostname as T}from"os";import s from"path";import g from"prettier";import E from"typescript";import j from"launch-editor";async function u(r,o){let n=r.resolve("/");for(let i=0;i<20;i++){let l=r.join(o,"package.json"),f=await r.readFile(l);if(f)return JSON.parse(f);if(o===n)break;o=r.dirname(o)}return null}async function m(r){let o=[],n=await u(r,r.getRootDir());if(n){let i=y(n);o.push(...i)}return o}function y(r){let o=[];if(r&&typeof r=="object"){let n=new Set(Object.keys({...r.dependencies,...r.devDependencies}));for(let i of p)n.has(i)&&(o.some(l=>l.name===i)||o.push({name:i}))}return o}var p=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"];async function P(r){let o=new Set,n=(...e)=>{if(process.env.DEBUG){let t=new Date,a=`${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`;console.debug(a,"[builder-dev-tools]",...e)}},i=async e=>{let t=F("md5");return t.update(e),t.digest("hex")},l={...s,getRootDir:()=>s.normalize(r.getRootDir()),cwd:()=>process.cwd(),exists:async e=>{try{return await h(e),!0}catch{return!1}},existsSync:e=>O(e),readdir:async(e,t)=>{let a=await w(e);return t?a.map(c=>s.join(e,c)):a},readdirSync:e=>b(e),readFile:async e=>{d(r,e);try{return await k(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw n(t,e),t}},readFileSync(e){d(r,e);try{return x(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw n(t,e),t}},stat:async e=>await v(e),statSync:e=>C(e),writeFile:async(e,t)=>{d(r,e),e=s.normalize(e);let a={path:e,basename:s.basename(e),dirname:s.dirname(e),extname:s.extname(e)};await S(s.dirname(e),{recursive:!0}),await D(e,t);for(let c of o)await c(a)},hash:i,getDeviceId:()=>i(`${T()}:${N()}`),formatCode:async(e,t)=>{let a=null;try{a=await g.resolveConfig(e)}catch{}try{return g.format(t,{...a,filepath:e})}catch{}return t},on:(e,t)=>{e==="change"&&o.add(t)},off:(e,t)=>{e==="change"&&o.delete(t)},debug:n,launchEditor:async e=>{try{let t=e.filePath;typeof e.line=="number"&&(t+=`:${e.line}`,typeof e.column=="number"&&(t+=`:${e.column}`)),j(t,"code",(a,c)=>{console.error(`Failed to launch editor for ${a}`),c&&console.error(c)})}catch(t){console.error(`Failed to launch editor for ${String(t.message||t)}`)}},platform:()=>({runtime:"node",os:process.platform}),getFrameworks:()=>[],ts:E,version:"1.1.4",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig??!1},f=await m(l);return l.getFrameworks=()=>f,l}function d(r,o){if(r.skipValidate)return;if(!o)throw new Error(`Invalid path: ${o} (7340)`);o=s.normalize(s.resolve(o));let n=r.getRootDir();if(!o.startsWith(n)&&!o.includes("node_modules"))throw new Error(`Invalid path: ${o} (7341)`)}export{P as createDevToolsNodeSys};
1
+ import{access as h,mkdir as S,readdir as w,readFile as k,stat as v,writeFile as D}from"fs/promises";import{createHash as F}from"crypto";import{existsSync as O,readdirSync as b,readFileSync as x,statSync as C}from"fs";import{homedir as N,hostname as T}from"os";import s from"path";import g from"prettier";import E from"typescript";import j from"launch-editor";async function u(r,o){let n=r.resolve("/");for(let i=0;i<20;i++){let l=r.join(o,"package.json"),f=await r.readFile(l);if(f)return JSON.parse(f);if(o===n)break;o=r.dirname(o)}return null}async function m(r){let o=[],n=await u(r,r.getRootDir());if(n){let i=y(n);o.push(...i)}return o}function y(r){let o=[];if(r&&typeof r=="object"){let n=new Set(Object.keys({...r.dependencies,...r.devDependencies}));for(let i of p)n.has(i)&&(o.some(l=>l.name===i)||o.push({name:i}))}return o}var p=["@shopify/remix-oxygen","@shopify/hydrogen","@builder.io/qwik-city","@remix-run/react","@sveltejs/kit","astro","gatsby","next","nuxt","@builder.io/qwik","@angular/core","react","solid-js","svelte","vue"];async function P(r){let o=new Set,n=(...e)=>{if(process.env.DEBUG){let t=new Date,a=`${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}.${String(t.getMilliseconds()).padStart(3,"0")}`;console.debug(a,"[builder-dev-tools]",...e)}},i=async e=>{let t=F("md5");return t.update(e),t.digest("hex")},l={...s,getRootDir:()=>s.normalize(r.getRootDir()),cwd:()=>process.cwd(),exists:async e=>{try{return await h(e),!0}catch{return!1}},existsSync:e=>O(e),readdir:async(e,t)=>{let a=await w(e);return t?a.map(c=>s.join(e,c)):a},readdirSync:e=>b(e),readFile:async e=>{d(r,e);try{return await k(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw n(t,e),t}},readFileSync(e){d(r,e);try{return x(e,"utf-8")}catch(t){if(t.code==="ENOENT")return null;throw n(t,e),t}},stat:async e=>await v(e),statSync:e=>C(e),writeFile:async(e,t)=>{d(r,e),e=s.normalize(e);let a={path:e,basename:s.basename(e),dirname:s.dirname(e),extname:s.extname(e)};await S(s.dirname(e),{recursive:!0}),await D(e,t);for(let c of o)await c(a)},hash:i,getDeviceId:()=>i(`${T()}:${N()}`),formatCode:async(e,t)=>{let a=null;try{a=await g.resolveConfig(e)}catch{}try{return g.format(t,{...a,filepath:e})}catch{}return t},on:(e,t)=>{e==="change"&&o.add(t)},off:(e,t)=>{e==="change"&&o.delete(t)},debug:n,launchEditor:async e=>{try{let t=e.filePath;typeof e.line=="number"&&(t+=`:${e.line}`,typeof e.column=="number"&&(t+=`:${e.column}`)),j(t,"code",(a,c)=>{console.error(`Failed to launch editor for ${a}`),c&&console.error(c)})}catch(t){console.error(`Failed to launch editor for ${String(t.message||t)}`)}},platform:()=>({runtime:"node",os:process.platform}),getFrameworks:()=>[],ts:E,version:"1.1.5",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig},f=await m(l);return l.getFrameworks=()=>f,l}function d(r,o){if(r.skipValidate)return;if(!o)throw new Error(`Invalid path: ${o} (7340)`);o=s.normalize(s.resolve(o));let n=r.getRootDir();if(!o.startsWith(n)&&!o.includes("node_modules"))throw new Error(`Invalid path: ${o} (7341)`)}export{P as createDevToolsNodeSys};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/dev-tools",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Builder.io Visual CMS Devtools",
5
5
  "type": "module",
6
6
  "main": "./core/index.cjs",