builder.io 1.1.36 → 1.1.38

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/node/index.cjs CHANGED
@@ -101,6 +101,6 @@ ${" ".repeat(6+i)}^`),c));s+=`
101
101
  ${l.join(`
102
102
  `)}
103
103
  `}this.message=s}},bc=new Set(["Literal","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","RegExpLiteral","BigIntLiteral"]),Jn=new Set(["string","number","boolean","bigint","symbol","undefined"]),ee=yt;function Pc(r){return/^[$A-Z_a-z][\w$]*$/.test(r)}var $i="__magicast_proxy";function ce(r,s=new Set){if(r===void 0)return ee.identifier("undefined");if(r===null)return ee.literal(null);if(Jn.has(typeof r))return ee.literal(r);if(s.has(r))throw new ie("Can not serialize circular reference");if(s.add(r),r[$i])return r.$ast;if(r instanceof RegExp){let e=ee.regExpLiteral(r.source,r.flags);return delete e.extra.raw,e}return r instanceof Set?ee.newExpression(ee.identifier("Set"),[ee.arrayExpression([...r].map(e=>ce(e,s)))]):r instanceof Date?ee.newExpression(ee.identifier("Date"),[ee.literal(r.toISOString())]):r instanceof Map?ee.newExpression(ee.identifier("Map"),[ee.arrayExpression([...r].map(([e,t])=>ee.arrayExpression([ce(e,s),ce(t,s)])))]):Array.isArray(r)?ee.arrayExpression(r.map(e=>ce(e,s))):typeof r=="object"?ee.objectExpression(Object.entries(r).map(([e,t])=>ee.property("init",/^[$A-Z_a-z][\w$]*$/g.test(e)?ee.identifier(e):ee.literal(e),ce(t,s)))):ee.literal(r)}function Tc(r,s={}){let e=s;return e[$i]=!0,e.$ast=r,e.$type||(e.$type="object"),e}var Sc={enumerable:!0,configurable:!0};function xe(r,s,e){let t=Tc(r,s);return new Proxy({},{ownKeys(){return Object.keys(t).filter(i=>i!==$i&&!i.startsWith("$"))},getOwnPropertyDescriptor(){return Sc},has(i,n){return n in t},...e,get(i,n,a){if(n in t)return t[n];if(e.get)return e.get(i,n,a)},set(i,n,a,o){return n in t?(t[n]=a,!0):e.set?e.set(i,n,a,o):!1}})}var pe=yt,Ci=new WeakMap;function Ac(r,s,e){if(Ci.has(s))return Ci.get(s);let t=xe(s,{get $declaration(){return r},get imported(){return s.type==="ImportDefaultSpecifier"?"default":s.type==="ImportNamespaceSpecifier"?"*":s.imported.type==="Identifier"?s.imported.name:s.imported.value},set imported(i){if(s.type!=="ImportSpecifier")throw new ie("Changing import name is not yet implemented");s.imported.type==="Identifier"?s.imported.name=i:s.imported.value=i},get local(){return s.local.name},set local(i){s.local.name=i},get from(){return r.source.value},set from(i){if(i===r.source.value)return;r.specifiers=r.specifiers.filter(a=>a!==s),r.specifiers.length===0&&(e.body=e.body.filter(a=>a!==r));let n=e.body.find(a=>a.type==="ImportDeclaration"&&a.source.value===i);n?n.specifiers.push(s):e.body.unshift(pe.importDeclaration([s],pe.stringLiteral(i)))},toJSON(){return{imported:this.imported,local:this.local,from:this.from}}},{ownKeys(){return["imported","local","from","toJSON"]}});return Ci.set(s,t),t}function Ec(r,s){let e=()=>{let a=[];for(let o of r.body)if(o.type==="ImportDeclaration")for(let l of o.specifiers)a.push(Ac(o,l,r));return a},t=(a,o,l)=>{let c=e(),u=c.find(p=>p.local===a),h=o.local||a;if(u)return u.imported=o.imported,u.local=h,u.from=o.from,!0;let f=o.imported==="default"?pe.importDefaultSpecifier(pe.identifier(h)):o.imported==="*"?pe.importNamespaceSpecifier(pe.identifier(h)):pe.importSpecifier(pe.identifier(o.imported),pe.identifier(h)),d=c.find(p=>p.from===o.from)?.$declaration;if(d)d.specifiers.push(f);else if(l==="prepend"||c.length===0)r.body.unshift(pe.importDeclaration([f],pe.stringLiteral(o.from)));else{let p=c.at(-1).$declaration,g=r.body.indexOf(p);r.body.splice(g+1,0,pe.importDeclaration([f],pe.stringLiteral(o.from)))}return!0},i=a=>{let o=e().find(u=>u.local===a);if(!o)return!1;let l=o.$declaration,c=o.$ast;return l.specifiers=l.specifiers.filter(u=>u!==c),l.specifiers.length===0&&(r.body=r.body.filter(u=>u!==l)),!0};return xe(r,{$type:"imports",$add(a){t(a.local||a.imported,a,"prepend")},$prepend(a){t(a.local||a.imported,a,"prepend")},$append(a){t(a.local||a.imported,a,"append")},get $items(){return e()},toJSON(){return e().reduce((a,o)=>(a[o.local]=o,a),{})}},{get(a,o){return e().find(l=>l.local===o)},set(a,o,l){return t(o,l,"prepend")},deleteProperty(a,o){return i(o)},ownKeys(){return e().map(a=>a.local)},has(a,o){return e().some(l=>l.local===o)}})}function Cs(r,s,e){let t=n=>s[n],i=(n,a)=>{s[n]=a};return xe(r,{$type:"array",push(n){s.push(ce(n))},pop(){return le(s.pop(),e)},unshift(n){s.unshift(ce(n))},shift(){return le(s.shift(),e)},splice(n,a,...o){return s.splice(n,a,...o.map(c=>ce(c))).map(c=>le(c,e))},find(n){return s.map(a=>le(a,e)).find(n)},findIndex(n){return s.map(a=>le(a,e)).findIndex(n)},includes(n){return s.map(a=>le(a,e)).includes(n)},toJSON(){return s.map(n=>le(n,e))}},{get(n,a){if(a==="length")return s.length;if(a===Symbol.iterator)return function*(){for(let c of s)yield le(c,e)};if(typeof a=="symbol")return;let o=+a;if(Number.isNaN(o))return;let l=t(o);if(l)return le(l,e)},set(n,a,o){if(typeof a=="symbol")return!1;let l=+a;return Number.isNaN(l)?!1:(i(l,ce(o)),!0)},deleteProperty(n,a){if(typeof a=="symbol")return!1;let o=+a;return Number.isNaN(o)?!1:(s[o]=ce(void 0),!0)},ownKeys(){return["length",...s.map((n,a)=>a.toString())]}})}function wc(r,s){if("elements"in r)return Cs(r,r.elements,s)}function Kn(r,s){if(r.type!=="CallExpression")throw new ie("Not a function call");function e(i){if(i.type==="Identifier")return i.name;if(i.type==="MemberExpression")return`${e(i.object)}.${e(i.property)}`;throw new ie("Not implemented")}let t=Cs(r,r.arguments,s);return xe(r,{$type:"function-call",$callee:e(r.callee),$args:t},{})}function vc(r,s){if(r.type!=="ArrowFunctionExpression")throw new ie("Not an arrow function expression");let e=Cs(r,r.params,s);return xe(r,{$type:"arrow-function-expression",$params:e,$body:le(r.body,s)},{})}var Cc=yt;function Ic(r,s){if(!("properties"in r))return;let e=n=>{for(let a of r.properties){if("key"in a&&"name"in a.key&&a.key.name===n)return a.value;if(a.type==="ObjectProperty"&&(a.key.type==="StringLiteral"||a.key.type==="NumericLiteral"||a.key.type==="BooleanLiteral")&&a.key.value.toString()===n)return a.value.value??a.value}},t=(n,a=!1)=>{if("key"in n&&"name"in n.key)return n.key.name;if(n.type==="ObjectProperty"&&(n.key.type==="StringLiteral"||n.key.type==="NumericLiteral"||n.key.type==="BooleanLiteral"))return n.key.value.toString();if(a)throw new ie(`Casting "${n.type}" is not supported`,{ast:n,code:s?.$code})},i=(n,a)=>{let o=r.properties.find(l=>t(l)===n);o?o.value=a:Pc(n)?r.properties.push({type:"Property",key:{type:"Identifier",name:n},value:a}):r.properties.push({type:"ObjectProperty",key:Cc.stringLiteral(n),value:a})};return xe(r,{$type:"object",toJSON(){return r.properties.reduce((n,a)=>("key"in a&&"name"in a.key&&(n[a.key.name]=le(a.value,s)),n),{})}},{get(n,a){let o=e(a);if(o)return le(o,s)},set(n,a,o){return typeof a!="string"&&(a=String(a)),i(a,ce(o)),!0},deleteProperty(n,a){typeof a!="string"&&(a=String(a));let o=r.properties.findIndex(l=>"key"in l&&"name"in l.key&&l.key.name===a);return o!==-1&&r.properties.splice(o,1),!0},ownKeys(){return r.properties.map(n=>t(n,!0)).filter(Boolean)}})}function Hn(r,s){if(r.type!=="NewExpression")throw new ie("Not a new expression");function e(i){if(i.type==="Identifier")return i.name;if(i.type==="MemberExpression")return`${e(i.object)}.${e(i.property)}`;throw new ie("Not implemented")}let t=Cs(r,r.arguments,s);return xe(r,{$type:"new-expression",$callee:e(r.callee),$args:t},{})}function Nc(r){if(r.type!=="Identifier")throw new ie("Not an identifier");return xe(r,{$type:"identifier",$name:r.name},{})}function kc(r){if(r.type!=="LogicalExpression")throw new ie("Not a logical expression");return xe(r,{$type:"logicalExpression"},{})}function Lc(r){if(r.type!=="MemberExpression")throw new ie("Not a member expression");return xe(r,{$type:"memberExpression"},{})}var Ii=new WeakMap;function le(r,s){if(Jn.has(typeof r))return r;if(bc.has(r.type))return r.value;if(Ii.has(r))return Ii.get(r);let e;switch(r.type){case"ObjectExpression":{e=Ic(r,s);break}case"ArrayExpression":{e=wc(r,s);break}case"CallExpression":{e=Kn(r,s);break}case"ArrowFunctionExpression":{e=vc(r,s);break}case"NewExpression":{e=Hn(r,s);break}case"Identifier":{e=Nc(r);break}case"LogicalExpression":{e=kc(r);break}case"MemberExpression":{e=Lc(r);break}case"TSAsExpression":case"TSSatisfiesExpression":{e=le(r.expression,s);break}default:throw new ie(`Casting "${r.type}" is not supported`,{ast:r,code:s?.$code})}return Ii.set(r,e),e}var Bt=yt;function Dc(r,s){let e=i=>{let n=i==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let a of r.body)if(a.type===n){if(i==="default")return a.declaration;if(a.declaration&&"declarations"in a.declaration){let o=a.declaration.declarations[0];if("name"in o.id&&o.id.name===i)return o.init}}},t=(i,n)=>{let a=i==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration",o=ce(n);for(let l of r.body)if(l.type===a){if(i==="default"){l.declaration=o;return}if(l.declaration&&"declarations"in l.declaration){let c=l.declaration.declarations[0];if("name"in c.id&&c.id.name===i){c.init=o;return}}}r.body.push(i==="default"?Bt.exportDefaultDeclaration(o):Bt.exportNamedDeclaration(Bt.variableDeclaration("const",[Bt.variableDeclarator(Bt.identifier(i),o)])))};return xe(r,{$type:"exports"},{get(i,n){let a=e(n);if(a)return le(a,s)},set(i,n,a){return t(n,a),!0},ownKeys(){return r.body.flatMap(i=>i.type==="ExportDefaultDeclaration"?["default"]:i.type==="ExportNamedDeclaration"&&i.declaration&&"declarations"in i.declaration?i.declaration.declarations.map(n=>"name"in n.id?n.id.name:""):[]).filter(Boolean)},deleteProperty(i,n){let a=n==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let o=0;o<r.body.length;o++){let l=r.body[o];if(l.type===a){if(n==="default")return r.body.splice(o,1),!0;if(l.declaration&&"declarations"in l.declaration){let c=l.declaration.declarations[0];if("name"in c.id&&c.id.name===n)return r.body.splice(o,1),!0}}}return!1}})}function Oc(r,s){let e=r.program;if(e.type!=="Program")throw new ie(`Cannot proxify ${r.type} as module`);let t={$code:s,$type:"module"},i=xe(e,t,{ownKeys(){return["imports","exports","generate"]}});return t.exports=Dc(e,i),t.imports=Ec(e),t.generate=n=>qi(i,n),i}function Xn(r,s={}){let e={wrapColumn:s.wrapColumn===void 0,indent:s.tabWidth===void 0||s.useTabs===void 0,quote:s.quote===void 0,arrowParens:s.arrowParensAlways===void 0,trailingComma:s.trailingComma===void 0},t=2,i=0,n=0,a=0,o=0,l=/(?<doubleQuote>"[^"]+")|(?<singleQuote>'[^']+')|(?<singleParam>\([^),]+\)\s*=>)|(?<trailingComma>,\s*[\]}])/g,c={doubleQuote:0,singleQuote:0,singleParam:0,trailingComma:0},u=(r||"").split(`
104
- `),h=!1;for(let f of u){let d=f.trim();if(d.length!==0){if(e.wrapColumn&&f.length>a&&(a=f.length),e.indent){let p=f.match(/^\s+/)?.[0]||"";p.length>0&&(p.length>0&&p.length<t&&(t=p.length),p[0]===" "?i++:p.length>0&&i--)}if(d.at(-1)===";"?n++:d.length>0&&n--,e.quote||e.arrowParens){let p=d.matchAll(l);for(let g of p)if(g.groups)for(let y in c)g.groups[y]&&c[y]++}e.trailingComma&&((f.startsWith("}")||f.startsWith("]"))&&(h?o++:o--),h=d.endsWith(","))}}return{wrapColumn:a,useTabs:i>0,tabWidth:t,quote:c.singleQuote>c.doubleQuote?"single":"double",arrowParensAlways:c.singleParam>0,trailingComma:o>0||c.trailingComma>0,useSemi:n>0,arrayBracketSpacing:void 0,objectCurlySpacing:void 0,...s}}function Gn(r,s){let e=Mn(r,{parser:s?.parser||Wn(),...s});return Oc(e,r)}function Qn(r,s){let e=Mn("("+r+")",{parser:s?.parser||Wn(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let i={$ast:e,$code:" "+r+" ",$type:"module"};return le(t,i)}function qi(r,s={}){let e=r.$ast||r,t=s.format===!1||!("$code"in r)?{}:Xn(r.$code,s.format),{code:i,map:n}=mc(e,{...s,...t});return{code:i,map:n}}async function Mc(r,s={}){let e=await ys.promises.readFile(r,"utf8");return s.sourceFileName=s.sourceFileName??r,Gn(e,s)}async function Fc(r,s,e){let t="$ast"in r?r.$ast:r,{code:i,map:n}=qi(t,e);await ys.promises.writeFile(s,i),n&&await ys.promises.writeFile(s+".map",n)}var fs=yt,Bc={functionCall(r,...s){let e=fs.callExpression(fs.identifier(r),s.map(t=>ce(t)));return Kn(e)},newExpression(r,...s){let e=fs.newExpression(fs.identifier(r),s.map(t=>ce(t)));return Hn(e)},literal(r){return ce(r)},raw(r){return Qn(r)}};async function ta(r){let s=new Set,e=(...c)=>{if(process.env.DEBUG){let u=new Date,h=`${String(u.getMinutes()).padStart(2,"0")}:${String(u.getSeconds()).padStart(2,"0")}.${String(u.getMilliseconds()).padStart(3,"0")}`;console.debug(h,"[builder-dev-tools]",...c)}},t=async c=>{let u=(0,Yn.createHash)("md5");return u.update(c),u.digest("hex")},i=$.default.normalize(r.cwd),n=Vc($.default.normalize(r.cwd))??i,a=$c($.default.normalize(r.cwd))??n,o={...$.default,getCwdDir:()=>i,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await(0,be.access)(c),!0}catch{return!1}},magicast:zi,existsSync:c=>(0,Z.existsSync)(c),readdir:async(c,u)=>{let h=await(0,be.readdir)(c);return u?h.map(f=>$.default.join(c,f)):h},readdirSync:c=>(0,Z.readdirSync)(c),readFile:async c=>{try{return await(0,be.readFile)(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},readFileSync(c){try{return(0,Z.readFileSync)(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},stat:async c=>await(0,be.stat)(c),statSync:c=>(0,Z.statSync)(c),writeFile:async(c,u)=>{c=$.default.normalize(c);let h={path:c,basename:$.default.basename(c),dirname:$.default.dirname(c),extname:$.default.extname(c)};await(0,be.mkdir)($.default.dirname(c),{recursive:!0}),await(0,be.writeFile)(c,u);for(let f of s)await f(h)},hash:t,getDeviceId:()=>t(`${(0,Is.hostname)()}:${(0,Is.homedir)()}`),formatCode:async(c,u)=>{let h=null;try{h=await Wi.default.resolveConfig(c)}catch{}try{return Wi.default.format(u,{...h,filepath:c})}catch{}return u},on:(c,u)=>{c==="change"&&s.add(u)},off:(c,u)=>{c==="change"&&s.delete(u)},debug:e,launchEditor:async c=>{try{let u=c.filePath;typeof c.line=="number"&&(u+=`:${c.line}`,typeof c.column=="number"&&(u+=`:${c.column}`)),(0,ea.default)(u,"code",(h,f)=>{console.error(`Failed to launch editor for ${h}`),f&&console.error(f)})}catch(u){console.error(`Failed to launch editor for ${String(u.message||u)}`)}},platform:()=>({runtime:"node",os:process.platform}),getRepoInfo:async()=>{let c=$.default.normalize(r.cwd);return{remoteUrl:_c(c),defaultBranch:jc(c),commit:Rc(c),currentBranch:Uc(c)}},getFrameworks:()=>[],ts:Zn.default,version:"1.1.36",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig,kind:null},l=await Gi(o);return o.getFrameworks=()=>l,o}function _c(r){try{return((0,zt.spawnSync)("git",["config","--get","remote.origin.url"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function jc(r){let s="master";try{let e=(0,zt.spawnSync)("git",["branch","-r"],{cwd:r});return e.stdout&&e.stdout.toString().trim().split(`
104
+ `),h=!1;for(let f of u){let d=f.trim();if(d.length!==0){if(e.wrapColumn&&f.length>a&&(a=f.length),e.indent){let p=f.match(/^\s+/)?.[0]||"";p.length>0&&(p.length>0&&p.length<t&&(t=p.length),p[0]===" "?i++:p.length>0&&i--)}if(d.at(-1)===";"?n++:d.length>0&&n--,e.quote||e.arrowParens){let p=d.matchAll(l);for(let g of p)if(g.groups)for(let y in c)g.groups[y]&&c[y]++}e.trailingComma&&((f.startsWith("}")||f.startsWith("]"))&&(h?o++:o--),h=d.endsWith(","))}}return{wrapColumn:a,useTabs:i>0,tabWidth:t,quote:c.singleQuote>c.doubleQuote?"single":"double",arrowParensAlways:c.singleParam>0,trailingComma:o>0||c.trailingComma>0,useSemi:n>0,arrayBracketSpacing:void 0,objectCurlySpacing:void 0,...s}}function Gn(r,s){let e=Mn(r,{parser:s?.parser||Wn(),...s});return Oc(e,r)}function Qn(r,s){let e=Mn("("+r+")",{parser:s?.parser||Wn(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let i={$ast:e,$code:" "+r+" ",$type:"module"};return le(t,i)}function qi(r,s={}){let e=r.$ast||r,t=s.format===!1||!("$code"in r)?{}:Xn(r.$code,s.format),{code:i,map:n}=mc(e,{...s,...t});return{code:i,map:n}}async function Mc(r,s={}){let e=await ys.promises.readFile(r,"utf8");return s.sourceFileName=s.sourceFileName??r,Gn(e,s)}async function Fc(r,s,e){let t="$ast"in r?r.$ast:r,{code:i,map:n}=qi(t,e);await ys.promises.writeFile(s,i),n&&await ys.promises.writeFile(s+".map",n)}var fs=yt,Bc={functionCall(r,...s){let e=fs.callExpression(fs.identifier(r),s.map(t=>ce(t)));return Kn(e)},newExpression(r,...s){let e=fs.newExpression(fs.identifier(r),s.map(t=>ce(t)));return Hn(e)},literal(r){return ce(r)},raw(r){return Qn(r)}};async function ta(r){let s=new Set,e=(...c)=>{if(process.env.DEBUG){let u=new Date,h=`${String(u.getMinutes()).padStart(2,"0")}:${String(u.getSeconds()).padStart(2,"0")}.${String(u.getMilliseconds()).padStart(3,"0")}`;console.debug(h,"[builder-dev-tools]",...c)}},t=async c=>{let u=(0,Yn.createHash)("md5");return u.update(c),u.digest("hex")},i=$.default.normalize(r.cwd),n=Vc($.default.normalize(r.cwd))??i,a=$c($.default.normalize(r.cwd))??n,o={...$.default,getCwdDir:()=>i,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await(0,be.access)(c),!0}catch{return!1}},magicast:zi,existsSync:c=>(0,Z.existsSync)(c),readdir:async(c,u)=>{let h=await(0,be.readdir)(c);return u?h.map(f=>$.default.join(c,f)):h},readdirSync:c=>(0,Z.readdirSync)(c),readFile:async c=>{try{return await(0,be.readFile)(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},readFileSync(c){try{return(0,Z.readFileSync)(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},stat:async c=>await(0,be.stat)(c),statSync:c=>(0,Z.statSync)(c),writeFile:async(c,u)=>{c=$.default.normalize(c);let h={path:c,basename:$.default.basename(c),dirname:$.default.dirname(c),extname:$.default.extname(c)};await(0,be.mkdir)($.default.dirname(c),{recursive:!0}),await(0,be.writeFile)(c,u);for(let f of s)await f(h)},hash:t,getDeviceId:()=>t(`${(0,Is.hostname)()}:${(0,Is.homedir)()}`),formatCode:async(c,u)=>{let h=null;try{h=await Wi.default.resolveConfig(c)}catch{}try{return Wi.default.format(u,{...h,filepath:c})}catch{}return u},on:(c,u)=>{c==="change"&&s.add(u)},off:(c,u)=>{c==="change"&&s.delete(u)},debug:e,launchEditor:async c=>{try{let u=c.filePath;typeof c.line=="number"&&(u+=`:${c.line}`,typeof c.column=="number"&&(u+=`:${c.column}`)),(0,ea.default)(u,"code",(h,f)=>{console.error(`Failed to launch editor for ${h}`),f&&console.error(f)})}catch(u){console.error(`Failed to launch editor for ${String(u.message||u)}`)}},platform:()=>({runtime:"node",os:process.platform}),getRepoInfo:async()=>{let c=$.default.normalize(r.cwd);return{remoteUrl:_c(c),defaultBranch:jc(c),commit:Rc(c),currentBranch:Uc(c)}},getFrameworks:()=>[],ts:Zn.default,version:"1.1.38",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig,kind:null},l=await Gi(o);return o.getFrameworks=()=>l,o}function _c(r){try{return((0,zt.spawnSync)("git",["config","--get","remote.origin.url"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function jc(r){let s="master";try{let e=(0,zt.spawnSync)("git",["branch","-r"],{cwd:r});return e.stdout&&e.stdout.toString().trim().split(`
105
105
  `).map(i=>i.trim()).includes("origin/main")?"main":s}catch(e){return console.error("Error getting git default branch name:",e.toString().split(`
106
106
  `)[0]),s}}function Rc(r){try{return((0,zt.spawnSync)("git",["rev-parse","HEAD"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git commit:",s),""}}function Uc(r){try{return((0,zt.spawnSync)("git",["branch","--show-current"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting current branch name:",s),""}}function Vc(r){let s=$.default.resolve("/");for(let e=0;e<20;e++){let t=$.default.join(r,"package.json");if((0,Z.existsSync)(t))return r;if(r===s)break;r=$.default.dirname(r)}return null}function $c(r){let s=$.default.resolve("/");for(let e=0;e<20;e++){if((0,Z.existsSync)($.default.join(r,"package.json"))||(0,Z.existsSync)($.default.join(r,"remix.config.js"))||(0,Z.existsSync)($.default.join(r,"remix.config.mjs"))||(0,Z.existsSync)($.default.join(r,"remix.config.ts"))||(0,Z.existsSync)($.default.join(r,"vite.config.js"))||(0,Z.existsSync)($.default.join(r,"vite.config.ts"))||(0,Z.existsSync)($.default.join(r,"vite.config.mjs"))||(0,Z.existsSync)($.default.join(r,"next.config.js"))||(0,Z.existsSync)($.default.join(r,"next.config.ts"))||(0,Z.existsSync)($.default.join(r,"angular.json"))||(0,Z.existsSync)($.default.join(r,"project.json"))||(0,Z.existsSync)($.default.join(r,"tsconfig.json")))return r;if(r===s)break;r=$.default.dirname(r)}return null}0&&(module.exports={createDevToolsNodeSys});
package/node/index.mjs CHANGED
@@ -101,6 +101,6 @@ ${" ".repeat(6+i)}^`),c));s+=`
101
101
  ${l.join(`
102
102
  `)}
103
103
  `}this.message=s}},pc=new Set(["Literal","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","RegExpLiteral","BigIntLiteral"]),Vn=new Set(["string","number","boolean","bigint","symbol","undefined"]),Z=dt;function fc(r){return/^[$A-Z_a-z][\w$]*$/.test(r)}var Ri="__magicast_proxy";function le(r,s=new Set){if(r===void 0)return Z.identifier("undefined");if(r===null)return Z.literal(null);if(Vn.has(typeof r))return Z.literal(r);if(s.has(r))throw new se("Can not serialize circular reference");if(s.add(r),r[Ri])return r.$ast;if(r instanceof RegExp){let e=Z.regExpLiteral(r.source,r.flags);return delete e.extra.raw,e}return r instanceof Set?Z.newExpression(Z.identifier("Set"),[Z.arrayExpression([...r].map(e=>le(e,s)))]):r instanceof Date?Z.newExpression(Z.identifier("Date"),[Z.literal(r.toISOString())]):r instanceof Map?Z.newExpression(Z.identifier("Map"),[Z.arrayExpression([...r].map(([e,t])=>Z.arrayExpression([le(e,s),le(t,s)])))]):Array.isArray(r)?Z.arrayExpression(r.map(e=>le(e,s))):typeof r=="object"?Z.objectExpression(Object.entries(r).map(([e,t])=>Z.property("init",/^[$A-Z_a-z][\w$]*$/g.test(e)?Z.identifier(e):Z.literal(e),le(t,s)))):Z.literal(r)}function dc(r,s={}){let e=s;return e[Ri]=!0,e.$ast=r,e.$type||(e.$type="object"),e}var mc={enumerable:!0,configurable:!0};function xe(r,s,e){let t=dc(r,s);return new Proxy({},{ownKeys(){return Object.keys(t).filter(i=>i!==Ri&&!i.startsWith("$"))},getOwnPropertyDescriptor(){return mc},has(i,n){return n in t},...e,get(i,n,a){if(n in t)return t[n];if(e.get)return e.get(i,n,a)},set(i,n,a,o){return n in t?(t[n]=a,!0):e.set?e.set(i,n,a,o):!1}})}var pe=dt,Ai=new WeakMap;function yc(r,s,e){if(Ai.has(s))return Ai.get(s);let t=xe(s,{get $declaration(){return r},get imported(){return s.type==="ImportDefaultSpecifier"?"default":s.type==="ImportNamespaceSpecifier"?"*":s.imported.type==="Identifier"?s.imported.name:s.imported.value},set imported(i){if(s.type!=="ImportSpecifier")throw new se("Changing import name is not yet implemented");s.imported.type==="Identifier"?s.imported.name=i:s.imported.value=i},get local(){return s.local.name},set local(i){s.local.name=i},get from(){return r.source.value},set from(i){if(i===r.source.value)return;r.specifiers=r.specifiers.filter(a=>a!==s),r.specifiers.length===0&&(e.body=e.body.filter(a=>a!==r));let n=e.body.find(a=>a.type==="ImportDeclaration"&&a.source.value===i);n?n.specifiers.push(s):e.body.unshift(pe.importDeclaration([s],pe.stringLiteral(i)))},toJSON(){return{imported:this.imported,local:this.local,from:this.from}}},{ownKeys(){return["imported","local","from","toJSON"]}});return Ai.set(s,t),t}function gc(r,s){let e=()=>{let a=[];for(let o of r.body)if(o.type==="ImportDeclaration")for(let l of o.specifiers)a.push(yc(o,l,r));return a},t=(a,o,l)=>{let c=e(),u=c.find(p=>p.local===a),h=o.local||a;if(u)return u.imported=o.imported,u.local=h,u.from=o.from,!0;let f=o.imported==="default"?pe.importDefaultSpecifier(pe.identifier(h)):o.imported==="*"?pe.importNamespaceSpecifier(pe.identifier(h)):pe.importSpecifier(pe.identifier(o.imported),pe.identifier(h)),d=c.find(p=>p.from===o.from)?.$declaration;if(d)d.specifiers.push(f);else if(l==="prepend"||c.length===0)r.body.unshift(pe.importDeclaration([f],pe.stringLiteral(o.from)));else{let p=c.at(-1).$declaration,g=r.body.indexOf(p);r.body.splice(g+1,0,pe.importDeclaration([f],pe.stringLiteral(o.from)))}return!0},i=a=>{let o=e().find(u=>u.local===a);if(!o)return!1;let l=o.$declaration,c=o.$ast;return l.specifiers=l.specifiers.filter(u=>u!==c),l.specifiers.length===0&&(r.body=r.body.filter(u=>u!==l)),!0};return xe(r,{$type:"imports",$add(a){t(a.local||a.imported,a,"prepend")},$prepend(a){t(a.local||a.imported,a,"prepend")},$append(a){t(a.local||a.imported,a,"append")},get $items(){return e()},toJSON(){return e().reduce((a,o)=>(a[o.local]=o,a),{})}},{get(a,o){return e().find(l=>l.local===o)},set(a,o,l){return t(o,l,"prepend")},deleteProperty(a,o){return i(o)},ownKeys(){return e().map(a=>a.local)},has(a,o){return e().some(l=>l.local===o)}})}function Ss(r,s,e){let t=n=>s[n],i=(n,a)=>{s[n]=a};return xe(r,{$type:"array",push(n){s.push(le(n))},pop(){return oe(s.pop(),e)},unshift(n){s.unshift(le(n))},shift(){return oe(s.shift(),e)},splice(n,a,...o){return s.splice(n,a,...o.map(c=>le(c))).map(c=>oe(c,e))},find(n){return s.map(a=>oe(a,e)).find(n)},findIndex(n){return s.map(a=>oe(a,e)).findIndex(n)},includes(n){return s.map(a=>oe(a,e)).includes(n)},toJSON(){return s.map(n=>oe(n,e))}},{get(n,a){if(a==="length")return s.length;if(a===Symbol.iterator)return function*(){for(let c of s)yield oe(c,e)};if(typeof a=="symbol")return;let o=+a;if(Number.isNaN(o))return;let l=t(o);if(l)return oe(l,e)},set(n,a,o){if(typeof a=="symbol")return!1;let l=+a;return Number.isNaN(l)?!1:(i(l,le(o)),!0)},deleteProperty(n,a){if(typeof a=="symbol")return!1;let o=+a;return Number.isNaN(o)?!1:(s[o]=le(void 0),!0)},ownKeys(){return["length",...s.map((n,a)=>a.toString())]}})}function xc(r,s){if("elements"in r)return Ss(r,r.elements,s)}function $n(r,s){if(r.type!=="CallExpression")throw new se("Not a function call");function e(i){if(i.type==="Identifier")return i.name;if(i.type==="MemberExpression")return`${e(i.object)}.${e(i.property)}`;throw new se("Not implemented")}let t=Ss(r,r.arguments,s);return xe(r,{$type:"function-call",$callee:e(r.callee),$args:t},{})}function bc(r,s){if(r.type!=="ArrowFunctionExpression")throw new se("Not an arrow function expression");let e=Ss(r,r.params,s);return xe(r,{$type:"arrow-function-expression",$params:e,$body:oe(r.body,s)},{})}var Pc=dt;function Tc(r,s){if(!("properties"in r))return;let e=n=>{for(let a of r.properties){if("key"in a&&"name"in a.key&&a.key.name===n)return a.value;if(a.type==="ObjectProperty"&&(a.key.type==="StringLiteral"||a.key.type==="NumericLiteral"||a.key.type==="BooleanLiteral")&&a.key.value.toString()===n)return a.value.value??a.value}},t=(n,a=!1)=>{if("key"in n&&"name"in n.key)return n.key.name;if(n.type==="ObjectProperty"&&(n.key.type==="StringLiteral"||n.key.type==="NumericLiteral"||n.key.type==="BooleanLiteral"))return n.key.value.toString();if(a)throw new se(`Casting "${n.type}" is not supported`,{ast:n,code:s?.$code})},i=(n,a)=>{let o=r.properties.find(l=>t(l)===n);o?o.value=a:fc(n)?r.properties.push({type:"Property",key:{type:"Identifier",name:n},value:a}):r.properties.push({type:"ObjectProperty",key:Pc.stringLiteral(n),value:a})};return xe(r,{$type:"object",toJSON(){return r.properties.reduce((n,a)=>("key"in a&&"name"in a.key&&(n[a.key.name]=oe(a.value,s)),n),{})}},{get(n,a){let o=e(a);if(o)return oe(o,s)},set(n,a,o){return typeof a!="string"&&(a=String(a)),i(a,le(o)),!0},deleteProperty(n,a){typeof a!="string"&&(a=String(a));let o=r.properties.findIndex(l=>"key"in l&&"name"in l.key&&l.key.name===a);return o!==-1&&r.properties.splice(o,1),!0},ownKeys(){return r.properties.map(n=>t(n,!0)).filter(Boolean)}})}function qn(r,s){if(r.type!=="NewExpression")throw new se("Not a new expression");function e(i){if(i.type==="Identifier")return i.name;if(i.type==="MemberExpression")return`${e(i.object)}.${e(i.property)}`;throw new se("Not implemented")}let t=Ss(r,r.arguments,s);return xe(r,{$type:"new-expression",$callee:e(r.callee),$args:t},{})}function Sc(r){if(r.type!=="Identifier")throw new se("Not an identifier");return xe(r,{$type:"identifier",$name:r.name},{})}function Ac(r){if(r.type!=="LogicalExpression")throw new se("Not a logical expression");return xe(r,{$type:"logicalExpression"},{})}function Ec(r){if(r.type!=="MemberExpression")throw new se("Not a member expression");return xe(r,{$type:"memberExpression"},{})}var Ei=new WeakMap;function oe(r,s){if(Vn.has(typeof r))return r;if(pc.has(r.type))return r.value;if(Ei.has(r))return Ei.get(r);let e;switch(r.type){case"ObjectExpression":{e=Tc(r,s);break}case"ArrayExpression":{e=xc(r,s);break}case"CallExpression":{e=$n(r,s);break}case"ArrowFunctionExpression":{e=bc(r,s);break}case"NewExpression":{e=qn(r,s);break}case"Identifier":{e=Sc(r);break}case"LogicalExpression":{e=Ac(r);break}case"MemberExpression":{e=Ec(r);break}case"TSAsExpression":case"TSSatisfiesExpression":{e=oe(r.expression,s);break}default:throw new se(`Casting "${r.type}" is not supported`,{ast:r,code:s?.$code})}return Ei.set(r,e),e}var Mt=dt;function wc(r,s){let e=i=>{let n=i==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let a of r.body)if(a.type===n){if(i==="default")return a.declaration;if(a.declaration&&"declarations"in a.declaration){let o=a.declaration.declarations[0];if("name"in o.id&&o.id.name===i)return o.init}}},t=(i,n)=>{let a=i==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration",o=le(n);for(let l of r.body)if(l.type===a){if(i==="default"){l.declaration=o;return}if(l.declaration&&"declarations"in l.declaration){let c=l.declaration.declarations[0];if("name"in c.id&&c.id.name===i){c.init=o;return}}}r.body.push(i==="default"?Mt.exportDefaultDeclaration(o):Mt.exportNamedDeclaration(Mt.variableDeclaration("const",[Mt.variableDeclarator(Mt.identifier(i),o)])))};return xe(r,{$type:"exports"},{get(i,n){let a=e(n);if(a)return oe(a,s)},set(i,n,a){return t(n,a),!0},ownKeys(){return r.body.flatMap(i=>i.type==="ExportDefaultDeclaration"?["default"]:i.type==="ExportNamedDeclaration"&&i.declaration&&"declarations"in i.declaration?i.declaration.declarations.map(n=>"name"in n.id?n.id.name:""):[]).filter(Boolean)},deleteProperty(i,n){let a=n==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let o=0;o<r.body.length;o++){let l=r.body[o];if(l.type===a){if(n==="default")return r.body.splice(o,1),!0;if(l.declaration&&"declarations"in l.declaration){let c=l.declaration.declarations[0];if("name"in c.id&&c.id.name===n)return r.body.splice(o,1),!0}}}return!1}})}function vc(r,s){let e=r.program;if(e.type!=="Program")throw new se(`Cannot proxify ${r.type} as module`);let t={$code:s,$type:"module"},i=xe(e,t,{ownKeys(){return["imports","exports","generate"]}});return t.exports=wc(e,i),t.imports=gc(e),t.generate=n=>Ui(i,n),i}function zn(r,s={}){let e={wrapColumn:s.wrapColumn===void 0,indent:s.tabWidth===void 0||s.useTabs===void 0,quote:s.quote===void 0,arrowParens:s.arrowParensAlways===void 0,trailingComma:s.trailingComma===void 0},t=2,i=0,n=0,a=0,o=0,l=/(?<doubleQuote>"[^"]+")|(?<singleQuote>'[^']+')|(?<singleParam>\([^),]+\)\s*=>)|(?<trailingComma>,\s*[\]}])/g,c={doubleQuote:0,singleQuote:0,singleParam:0,trailingComma:0},u=(r||"").split(`
104
- `),h=!1;for(let f of u){let d=f.trim();if(d.length!==0){if(e.wrapColumn&&f.length>a&&(a=f.length),e.indent){let p=f.match(/^\s+/)?.[0]||"";p.length>0&&(p.length>0&&p.length<t&&(t=p.length),p[0]===" "?i++:p.length>0&&i--)}if(d.at(-1)===";"?n++:d.length>0&&n--,e.quote||e.arrowParens){let p=d.matchAll(l);for(let g of p)if(g.groups)for(let y in c)g.groups[y]&&c[y]++}e.trailingComma&&((f.startsWith("}")||f.startsWith("]"))&&(h?o++:o--),h=d.endsWith(","))}}return{wrapColumn:a,useTabs:i>0,tabWidth:t,quote:c.singleQuote>c.doubleQuote?"single":"double",arrowParensAlways:c.singleParam>0,trailingComma:o>0||c.trailingComma>0,useSemi:n>0,arrayBracketSpacing:void 0,objectCurlySpacing:void 0,...s}}function Wn(r,s){let e=Nn(r,{parser:s?.parser||Un(),...s});return vc(e,r)}function Jn(r,s){let e=Nn("("+r+")",{parser:s?.parser||Un(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let i={$ast:e,$code:" "+r+" ",$type:"module"};return oe(t,i)}function Ui(r,s={}){let e=r.$ast||r,t=s.format===!1||!("$code"in r)?{}:zn(r.$code,s.format),{code:i,map:n}=lc(e,{...s,...t});return{code:i,map:n}}async function Cc(r,s={}){let e=await wi.readFile(r,"utf8");return s.sourceFileName=s.sourceFileName??r,Wn(e,s)}async function Ic(r,s,e){let t="$ast"in r?r.$ast:r,{code:i,map:n}=Ui(t,e);await wi.writeFile(s,i),n&&await wi.writeFile(s+".map",n)}var cs=dt,Nc={functionCall(r,...s){let e=cs.callExpression(cs.identifier(r),s.map(t=>le(t)));return $n(e)},newExpression(r,...s){let e=cs.newExpression(cs.identifier(r),s.map(t=>le(t)));return qn(e)},literal(r){return le(r)},raw(r){return Jn(r)}};async function zc(r){let s=new Set,e=(...c)=>{if(process.env.DEBUG){let u=new Date,h=`${String(u.getMinutes()).padStart(2,"0")}:${String(u.getSeconds()).padStart(2,"0")}.${String(u.getMilliseconds()).padStart(3,"0")}`;console.debug(h,"[builder-dev-tools]",...c)}},t=async c=>{let u=Bc("md5");return u.update(c),u.digest("hex")},i=q.normalize(r.cwd),n=Xc(q.normalize(r.cwd))??i,a=Gc(q.normalize(r.cwd))??n,o={...q,getCwdDir:()=>i,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await kc(c),!0}catch{return!1}},magicast:Vi,existsSync:c=>ce(c),readdir:async(c,u)=>{let h=await Dc(c);return u?h.map(f=>q.join(c,f)):h},readdirSync:c=>_c(c),readFile:async c=>{try{return await Oc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},readFileSync(c){try{return jc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},stat:async c=>await Mc(c),statSync:c=>Rc(c),writeFile:async(c,u)=>{c=q.normalize(c);let h={path:c,basename:q.basename(c),dirname:q.dirname(c),extname:q.extname(c)};await Lc(q.dirname(c),{recursive:!0}),await Fc(c,u);for(let f of s)await f(h)},hash:t,getDeviceId:()=>t(`${Vc()}:${Uc()}`),formatCode:async(c,u)=>{let h=null;try{h=await Kn.resolveConfig(c)}catch{}try{return Kn.format(u,{...h,filepath:c})}catch{}return u},on:(c,u)=>{c==="change"&&s.add(u)},off:(c,u)=>{c==="change"&&s.delete(u)},debug:e,launchEditor:async c=>{try{let u=c.filePath;typeof c.line=="number"&&(u+=`:${c.line}`,typeof c.column=="number"&&(u+=`:${c.column}`)),qc(u,"code",(h,f)=>{console.error(`Failed to launch editor for ${h}`),f&&console.error(f)})}catch(u){console.error(`Failed to launch editor for ${String(u.message||u)}`)}},platform:()=>({runtime:"node",os:process.platform}),getRepoInfo:async()=>{let c=q.normalize(r.cwd);return{remoteUrl:Wc(c),defaultBranch:Jc(c),commit:Kc(c),currentBranch:Hc(c)}},getFrameworks:()=>[],ts:$c,version:"1.1.36",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig,kind:null},l=await Wi(o);return o.getFrameworks=()=>l,o}function Wc(r){try{return(As("git",["config","--get","remote.origin.url"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function Jc(r){let s="master";try{let e=As("git",["branch","-r"],{cwd:r});return e.stdout&&e.stdout.toString().trim().split(`
104
+ `),h=!1;for(let f of u){let d=f.trim();if(d.length!==0){if(e.wrapColumn&&f.length>a&&(a=f.length),e.indent){let p=f.match(/^\s+/)?.[0]||"";p.length>0&&(p.length>0&&p.length<t&&(t=p.length),p[0]===" "?i++:p.length>0&&i--)}if(d.at(-1)===";"?n++:d.length>0&&n--,e.quote||e.arrowParens){let p=d.matchAll(l);for(let g of p)if(g.groups)for(let y in c)g.groups[y]&&c[y]++}e.trailingComma&&((f.startsWith("}")||f.startsWith("]"))&&(h?o++:o--),h=d.endsWith(","))}}return{wrapColumn:a,useTabs:i>0,tabWidth:t,quote:c.singleQuote>c.doubleQuote?"single":"double",arrowParensAlways:c.singleParam>0,trailingComma:o>0||c.trailingComma>0,useSemi:n>0,arrayBracketSpacing:void 0,objectCurlySpacing:void 0,...s}}function Wn(r,s){let e=Nn(r,{parser:s?.parser||Un(),...s});return vc(e,r)}function Jn(r,s){let e=Nn("("+r+")",{parser:s?.parser||Un(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let i={$ast:e,$code:" "+r+" ",$type:"module"};return oe(t,i)}function Ui(r,s={}){let e=r.$ast||r,t=s.format===!1||!("$code"in r)?{}:zn(r.$code,s.format),{code:i,map:n}=lc(e,{...s,...t});return{code:i,map:n}}async function Cc(r,s={}){let e=await wi.readFile(r,"utf8");return s.sourceFileName=s.sourceFileName??r,Wn(e,s)}async function Ic(r,s,e){let t="$ast"in r?r.$ast:r,{code:i,map:n}=Ui(t,e);await wi.writeFile(s,i),n&&await wi.writeFile(s+".map",n)}var cs=dt,Nc={functionCall(r,...s){let e=cs.callExpression(cs.identifier(r),s.map(t=>le(t)));return $n(e)},newExpression(r,...s){let e=cs.newExpression(cs.identifier(r),s.map(t=>le(t)));return qn(e)},literal(r){return le(r)},raw(r){return Jn(r)}};async function zc(r){let s=new Set,e=(...c)=>{if(process.env.DEBUG){let u=new Date,h=`${String(u.getMinutes()).padStart(2,"0")}:${String(u.getSeconds()).padStart(2,"0")}.${String(u.getMilliseconds()).padStart(3,"0")}`;console.debug(h,"[builder-dev-tools]",...c)}},t=async c=>{let u=Bc("md5");return u.update(c),u.digest("hex")},i=q.normalize(r.cwd),n=Xc(q.normalize(r.cwd))??i,a=Gc(q.normalize(r.cwd))??n,o={...q,getCwdDir:()=>i,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await kc(c),!0}catch{return!1}},magicast:Vi,existsSync:c=>ce(c),readdir:async(c,u)=>{let h=await Dc(c);return u?h.map(f=>q.join(c,f)):h},readdirSync:c=>_c(c),readFile:async c=>{try{return await Oc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},readFileSync(c){try{return jc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},stat:async c=>await Mc(c),statSync:c=>Rc(c),writeFile:async(c,u)=>{c=q.normalize(c);let h={path:c,basename:q.basename(c),dirname:q.dirname(c),extname:q.extname(c)};await Lc(q.dirname(c),{recursive:!0}),await Fc(c,u);for(let f of s)await f(h)},hash:t,getDeviceId:()=>t(`${Vc()}:${Uc()}`),formatCode:async(c,u)=>{let h=null;try{h=await Kn.resolveConfig(c)}catch{}try{return Kn.format(u,{...h,filepath:c})}catch{}return u},on:(c,u)=>{c==="change"&&s.add(u)},off:(c,u)=>{c==="change"&&s.delete(u)},debug:e,launchEditor:async c=>{try{let u=c.filePath;typeof c.line=="number"&&(u+=`:${c.line}`,typeof c.column=="number"&&(u+=`:${c.column}`)),qc(u,"code",(h,f)=>{console.error(`Failed to launch editor for ${h}`),f&&console.error(f)})}catch(u){console.error(`Failed to launch editor for ${String(u.message||u)}`)}},platform:()=>({runtime:"node",os:process.platform}),getRepoInfo:async()=>{let c=q.normalize(r.cwd);return{remoteUrl:Wc(c),defaultBranch:Jc(c),commit:Kc(c),currentBranch:Hc(c)}},getFrameworks:()=>[],ts:$c,version:"1.1.38",sdkVersion:null,ignoreMissingConfig:r.ignoreMissingConfig,kind:null},l=await Wi(o);return o.getFrameworks=()=>l,o}function Wc(r){try{return(As("git",["config","--get","remote.origin.url"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function Jc(r){let s="master";try{let e=As("git",["branch","-r"],{cwd:r});return e.stdout&&e.stdout.toString().trim().split(`
105
105
  `).map(i=>i.trim()).includes("origin/main")?"main":s}catch(e){return console.error("Error getting git default branch name:",e.toString().split(`
106
106
  `)[0]),s}}function Kc(r){try{return(As("git",["rev-parse","HEAD"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git commit:",s),""}}function Hc(r){try{return(As("git",["branch","--show-current"],{cwd:r}).stdout||"").toString().trim()}catch(s){return console.error("Error getting current branch name:",s),""}}function Xc(r){let s=q.resolve("/");for(let e=0;e<20;e++){let t=q.join(r,"package.json");if(ce(t))return r;if(r===s)break;r=q.dirname(r)}return null}function Gc(r){let s=q.resolve("/");for(let e=0;e<20;e++){if(ce(q.join(r,"package.json"))||ce(q.join(r,"remix.config.js"))||ce(q.join(r,"remix.config.mjs"))||ce(q.join(r,"remix.config.ts"))||ce(q.join(r,"vite.config.js"))||ce(q.join(r,"vite.config.ts"))||ce(q.join(r,"vite.config.mjs"))||ce(q.join(r,"next.config.js"))||ce(q.join(r,"next.config.ts"))||ce(q.join(r,"angular.json"))||ce(q.join(r,"project.json"))||ce(q.join(r,"tsconfig.json")))return r;if(r===s)break;r=q.dirname(r)}return null}export{zc as createDevToolsNodeSys};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "builder.io",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "description": "Add and Sync Builder.io code snippets to an application",
5
5
  "type": "module",
6
6
  "bin": {