builder.io 1.1.41 → 1.1.42

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/figma/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var s=(e,n)=>{for(var a in n)t(e,a,{get:n[a],enumerable:!0})},m=(e,n,a,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of o(n))!g.call(e,i)&&i!==a&&t(e,i,{get:()=>n[i],enumerable:!(r=p(n,i))||r.enumerable});return e};var d=e=>m(t({},"__esModule",{value:!0}),e);var y={};s(y,{explicitFalse:()=>c,figmaMapping:()=>F});module.exports=d(y);function F(e){}function c(e){return e===!1?!1:e}
1
+ "use strict";var t=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var s=(e,n)=>{for(var a in n)t(e,a,{get:n[a],enumerable:!0})},m=(e,n,a,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of o(n))!g.call(e,i)&&i!==a&&t(e,i,{get:()=>n[i],enumerable:!(r=p(n,i))||r.enumerable});return e};var d=e=>m(t({},"__esModule",{value:!0}),e);var F={};s(F,{explicitFalse:()=>y,figmaMapping:()=>l});module.exports=d(F);function l(e){}function y(e){return e===!1?!1:e}
package/node/index.cjs CHANGED
@@ -101,6 +101,6 @@ ${" ".repeat(6+r)}^`),c));s+=`
101
101
  ${l.join(`
102
102
  `)}
103
103
  `}this.message=s}},vc=new Set(["Literal","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","RegExpLiteral","BigIntLiteral"]),Yn=new Set(["string","number","boolean","bigint","symbol","undefined"]),ee=yt;function Cc(i){return/^[$A-Z_a-z][\w$]*$/.test(i)}var qr="__magicast_proxy";function ce(i,s=new Set){if(i===void 0)return ee.identifier("undefined");if(i===null)return ee.literal(null);if(Yn.has(typeof i))return ee.literal(i);if(s.has(i))throw new re("Can not serialize circular reference");if(s.add(i),i[qr])return i.$ast;if(i instanceof RegExp){let e=ee.regExpLiteral(i.source,i.flags);return delete e.extra.raw,e}return i instanceof Set?ee.newExpression(ee.identifier("Set"),[ee.arrayExpression([...i].map(e=>ce(e,s)))]):i instanceof Date?ee.newExpression(ee.identifier("Date"),[ee.literal(i.toISOString())]):i instanceof Map?ee.newExpression(ee.identifier("Map"),[ee.arrayExpression([...i].map(([e,t])=>ee.arrayExpression([ce(e,s),ce(t,s)])))]):Array.isArray(i)?ee.arrayExpression(i.map(e=>ce(e,s))):typeof i=="object"?ee.objectExpression(Object.entries(i).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(i)}function Ic(i,s={}){let e=s;return e[qr]=!0,e.$ast=i,e.$type||(e.$type="object"),e}var Nc={enumerable:!0,configurable:!0};function xe(i,s,e){let t=Ic(i,s);return new Proxy({},{ownKeys(){return Object.keys(t).filter(r=>r!==qr&&!r.startsWith("$"))},getOwnPropertyDescriptor(){return Nc},has(r,n){return n in t},...e,get(r,n,a){if(n in t)return t[n];if(e.get)return e.get(r,n,a)},set(r,n,a,o){return n in t?(t[n]=a,!0):e.set?e.set(r,n,a,o):!1}})}var fe=yt,Ir=new WeakMap;function kc(i,s,e){if(Ir.has(s))return Ir.get(s);let t=xe(s,{get $declaration(){return i},get imported(){return s.type==="ImportDefaultSpecifier"?"default":s.type==="ImportNamespaceSpecifier"?"*":s.imported.type==="Identifier"?s.imported.name:s.imported.value},set imported(r){if(s.type!=="ImportSpecifier")throw new re("Changing import name is not yet implemented");s.imported.type==="Identifier"?s.imported.name=r:s.imported.value=r},get local(){return s.local.name},set local(r){s.local.name=r},get from(){return i.source.value},set from(r){if(r===i.source.value)return;i.specifiers=i.specifiers.filter(a=>a!==s),i.specifiers.length===0&&(e.body=e.body.filter(a=>a!==i));let n=e.body.find(a=>a.type==="ImportDeclaration"&&a.source.value===r);n?n.specifiers.push(s):e.body.unshift(fe.importDeclaration([s],fe.stringLiteral(r)))},toJSON(){return{imported:this.imported,local:this.local,from:this.from}}},{ownKeys(){return["imported","local","from","toJSON"]}});return Ir.set(s,t),t}function Lc(i,s){let e=()=>{let a=[];for(let o of i.body)if(o.type==="ImportDeclaration")for(let l of o.specifiers)a.push(kc(o,l,i));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"?fe.importDefaultSpecifier(fe.identifier(h)):o.imported==="*"?fe.importNamespaceSpecifier(fe.identifier(h)):fe.importSpecifier(fe.identifier(o.imported),fe.identifier(h)),d=c.find(p=>p.from===o.from)?.$declaration;if(d)d.specifiers.push(f);else if(l==="prepend"||c.length===0)i.body.unshift(fe.importDeclaration([f],fe.stringLiteral(o.from)));else{let p=c.at(-1).$declaration,g=i.body.indexOf(p);i.body.splice(g+1,0,fe.importDeclaration([f],fe.stringLiteral(o.from)))}return!0},r=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&&(i.body=i.body.filter(u=>u!==l)),!0};return xe(i,{$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 r(o)},ownKeys(){return e().map(a=>a.local)},has(a,o){return e().some(l=>l.local===o)}})}function Cs(i,s,e){let t=n=>s[n],r=(n,a)=>{s[n]=a};return xe(i,{$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:(r(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 Dc(i,s){if("elements"in i)return Cs(i,i.elements,s)}function Zn(i,s){if(i.type!=="CallExpression")throw new re("Not a function call");function e(r){if(r.type==="Identifier")return r.name;if(r.type==="MemberExpression")return`${e(r.object)}.${e(r.property)}`;throw new re("Not implemented")}let t=Cs(i,i.arguments,s);return xe(i,{$type:"function-call",$callee:e(i.callee),$args:t},{})}function Oc(i,s){if(i.type!=="ArrowFunctionExpression")throw new re("Not an arrow function expression");let e=Cs(i,i.params,s);return xe(i,{$type:"arrow-function-expression",$params:e,$body:le(i.body,s)},{})}var Mc=yt;function Fc(i,s){if(!("properties"in i))return;let e=n=>{for(let a of i.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 re(`Casting "${n.type}" is not supported`,{ast:n,code:s?.$code})},r=(n,a)=>{let o=i.properties.find(l=>t(l)===n);o?o.value=a:Cc(n)?i.properties.push({type:"Property",key:{type:"Identifier",name:n},value:a}):i.properties.push({type:"ObjectProperty",key:Mc.stringLiteral(n),value:a})};return xe(i,{$type:"object",toJSON(){return i.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)),r(a,ce(o)),!0},deleteProperty(n,a){typeof a!="string"&&(a=String(a));let o=i.properties.findIndex(l=>"key"in l&&"name"in l.key&&l.key.name===a);return o!==-1&&i.properties.splice(o,1),!0},ownKeys(){return i.properties.map(n=>t(n,!0)).filter(Boolean)}})}function ea(i,s){if(i.type!=="NewExpression")throw new re("Not a new expression");function e(r){if(r.type==="Identifier")return r.name;if(r.type==="MemberExpression")return`${e(r.object)}.${e(r.property)}`;throw new re("Not implemented")}let t=Cs(i,i.arguments,s);return xe(i,{$type:"new-expression",$callee:e(i.callee),$args:t},{})}function Bc(i){if(i.type!=="Identifier")throw new re("Not an identifier");return xe(i,{$type:"identifier",$name:i.name},{})}function _c(i){if(i.type!=="LogicalExpression")throw new re("Not a logical expression");return xe(i,{$type:"logicalExpression"},{})}function jc(i){if(i.type!=="MemberExpression")throw new re("Not a member expression");return xe(i,{$type:"memberExpression"},{})}var Nr=new WeakMap;function le(i,s){if(Yn.has(typeof i))return i;if(vc.has(i.type))return i.value;if(Nr.has(i))return Nr.get(i);let e;switch(i.type){case"ObjectExpression":{e=Fc(i,s);break}case"ArrayExpression":{e=Dc(i,s);break}case"CallExpression":{e=Zn(i,s);break}case"ArrowFunctionExpression":{e=Oc(i,s);break}case"NewExpression":{e=ea(i,s);break}case"Identifier":{e=Bc(i);break}case"LogicalExpression":{e=_c(i);break}case"MemberExpression":{e=jc(i);break}case"TSAsExpression":case"TSSatisfiesExpression":{e=le(i.expression,s);break}default:throw new re(`Casting "${i.type}" is not supported`,{ast:i,code:s?.$code})}return Nr.set(i,e),e}var _t=yt;function Rc(i,s){let e=r=>{let n=r==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let a of i.body)if(a.type===n){if(r==="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===r)return o.init}}},t=(r,n)=>{let a=r==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration",o=ce(n);for(let l of i.body)if(l.type===a){if(r==="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===r){c.init=o;return}}}i.body.push(r==="default"?_t.exportDefaultDeclaration(o):_t.exportNamedDeclaration(_t.variableDeclaration("const",[_t.variableDeclarator(_t.identifier(r),o)])))};return xe(i,{$type:"exports"},{get(r,n){let a=e(n);if(a)return le(a,s)},set(r,n,a){return t(n,a),!0},ownKeys(){return i.body.flatMap(r=>r.type==="ExportDefaultDeclaration"?["default"]:r.type==="ExportNamedDeclaration"&&r.declaration&&"declarations"in r.declaration?r.declaration.declarations.map(n=>"name"in n.id?n.id.name:""):[]).filter(Boolean)},deleteProperty(r,n){let a=n==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let o=0;o<i.body.length;o++){let l=i.body[o];if(l.type===a){if(n==="default")return i.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 i.body.splice(o,1),!0}}}return!1}})}function Uc(i,s){let e=i.program;if(e.type!=="Program")throw new re(`Cannot proxify ${i.type} as module`);let t={$code:s,$type:"module"},r=xe(e,t,{ownKeys(){return["imports","exports","generate"]}});return t.exports=Rc(e,r),t.imports=Lc(e),t.generate=n=>zr(r,n),r}function ta(i,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,r=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=(i||"").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]===" "?r++:p.length>0&&r--)}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:r>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 sa(i,s){let e=Un(i,{parser:s?.parser||Qn(),...s});return Uc(e,i)}function ra(i,s){let e=Un("("+i+")",{parser:s?.parser||Qn(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let r={$ast:e,$code:" "+i+" ",$type:"module"};return le(t,r)}function zr(i,s={}){let e=i.$ast||i,t=s.format===!1||!("$code"in i)?{}:ta(i.$code,s.format),{code:r,map:n}=Sc(e,{...s,...t});return{code:r,map:n}}async function Vc(i,s={}){let e=await ys.promises.readFile(i,"utf8");return s.sourceFileName=s.sourceFileName??i,sa(e,s)}async function $c(i,s,e){let t="$ast"in i?i.$ast:i,{code:r,map:n}=zr(t,e);await ys.promises.writeFile(s,r),n&&await ys.promises.writeFile(s+".map",n)}var fs=yt,qc={functionCall(i,...s){let e=fs.callExpression(fs.identifier(i),s.map(t=>ce(t)));return Zn(e)},newExpression(i,...s){let e=fs.newExpression(fs.identifier(i),s.map(t=>ce(t)));return ea(e)},literal(i){return ce(i)},raw(i){return ra(i)}};async function oa(i){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,ia.createHash)("md5");return u.update(c),u.digest("hex")},r=$.default.normalize(i.cwd),n=Hc($.default.normalize(i.cwd))??r,a=Xc($.default.normalize(i.cwd))??n,o={...$.default,getCwdDir:()=>r,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await(0,be.access)(c),!0}catch{return!1}},magicast:Wr,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}},spawnSync:gt.spawnSync,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 Jr.default.resolveConfig(c)}catch{}try{return Jr.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,aa.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(i.cwd);return{remoteUrl:zc(c),defaultBranch:Wc(c),commit:Jc(c),currentBranch:Kc(c)}},getFrameworks:()=>[],ts:na.default,version:"1.1.41",sdkVersion:null,ignoreMissingConfig:i.ignoreMissingConfig,kind:null},l=await si(o);return o.getFrameworks=()=>l,o}function zc(i){try{return((0,gt.spawnSync)("git",["config","--get","remote.origin.url"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function Wc(i){let s="master";try{let e=(0,gt.spawnSync)("git",["branch","-r"],{cwd:i});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]===" "?r++:p.length>0&&r--)}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:r>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 sa(i,s){let e=Un(i,{parser:s?.parser||Qn(),...s});return Uc(e,i)}function ra(i,s){let e=Un("("+i+")",{parser:s?.parser||Qn(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let r={$ast:e,$code:" "+i+" ",$type:"module"};return le(t,r)}function zr(i,s={}){let e=i.$ast||i,t=s.format===!1||!("$code"in i)?{}:ta(i.$code,s.format),{code:r,map:n}=Sc(e,{...s,...t});return{code:r,map:n}}async function Vc(i,s={}){let e=await ys.promises.readFile(i,"utf8");return s.sourceFileName=s.sourceFileName??i,sa(e,s)}async function $c(i,s,e){let t="$ast"in i?i.$ast:i,{code:r,map:n}=zr(t,e);await ys.promises.writeFile(s,r),n&&await ys.promises.writeFile(s+".map",n)}var fs=yt,qc={functionCall(i,...s){let e=fs.callExpression(fs.identifier(i),s.map(t=>ce(t)));return Zn(e)},newExpression(i,...s){let e=fs.newExpression(fs.identifier(i),s.map(t=>ce(t)));return ea(e)},literal(i){return ce(i)},raw(i){return ra(i)}};async function oa(i){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,ia.createHash)("md5");return u.update(c),u.digest("hex")},r=$.default.normalize(i.cwd),n=Hc($.default.normalize(i.cwd))??r,a=Xc($.default.normalize(i.cwd))??n,o={...$.default,getCwdDir:()=>r,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await(0,be.access)(c),!0}catch{return!1}},magicast:Wr,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}},spawnSync:gt.spawnSync,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 Jr.default.resolveConfig(c)}catch{}try{return Jr.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,aa.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(i.cwd);return{remoteUrl:zc(c),defaultBranch:Wc(c),commit:Jc(c),currentBranch:Kc(c)}},getFrameworks:()=>[],ts:na.default,version:"1.1.42",sdkVersion:null,ignoreMissingConfig:i.ignoreMissingConfig,kind:null},l=await si(o);return o.getFrameworks=()=>l,o}function zc(i){try{return((0,gt.spawnSync)("git",["config","--get","remote.origin.url"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function Wc(i){let s="master";try{let e=(0,gt.spawnSync)("git",["branch","-r"],{cwd:i});return e.stdout&&e.stdout.toString().trim().split(`
105
105
  `).map(r=>r.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 Jc(i){try{return((0,gt.spawnSync)("git",["rev-parse","HEAD"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git commit:",s),""}}function Kc(i){try{return((0,gt.spawnSync)("git",["branch","--show-current"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting current branch name:",s),""}}function Hc(i){let s=$.default.resolve("/");for(let e=0;e<20;e++){let t=$.default.join(i,"package.json");if((0,Z.existsSync)(t))return i;if(i===s)break;i=$.default.dirname(i)}return null}function Xc(i){let s=$.default.resolve("/");for(let e=0;e<20;e++){if((0,Z.existsSync)($.default.join(i,"package.json"))||(0,Z.existsSync)($.default.join(i,"remix.config.js"))||(0,Z.existsSync)($.default.join(i,"remix.config.mjs"))||(0,Z.existsSync)($.default.join(i,"remix.config.ts"))||(0,Z.existsSync)($.default.join(i,"vite.config.js"))||(0,Z.existsSync)($.default.join(i,"vite.config.ts"))||(0,Z.existsSync)($.default.join(i,"vite.config.mjs"))||(0,Z.existsSync)($.default.join(i,"next.config.js"))||(0,Z.existsSync)($.default.join(i,"next.config.ts"))||(0,Z.existsSync)($.default.join(i,"angular.json"))||(0,Z.existsSync)($.default.join(i,"project.json"))||(0,Z.existsSync)($.default.join(i,"tsconfig.json")))return i;if(i===s)break;i=$.default.dirname(i)}return null}0&&(module.exports={createDevToolsNodeSys});
package/node/index.mjs CHANGED
@@ -101,6 +101,6 @@ ${" ".repeat(6+r)}^`),c));s+=`
101
101
  ${l.join(`
102
102
  `)}
103
103
  `}this.message=s}},bc=new Set(["Literal","StringLiteral","NumericLiteral","BooleanLiteral","NullLiteral","RegExpLiteral","BigIntLiteral"]),Kn=new Set(["string","number","boolean","bigint","symbol","undefined"]),Z=dt;function Tc(i){return/^[$A-Z_a-z][\w$]*$/.test(i)}var Vr="__magicast_proxy";function le(i,s=new Set){if(i===void 0)return Z.identifier("undefined");if(i===null)return Z.literal(null);if(Kn.has(typeof i))return Z.literal(i);if(s.has(i))throw new se("Can not serialize circular reference");if(s.add(i),i[Vr])return i.$ast;if(i instanceof RegExp){let e=Z.regExpLiteral(i.source,i.flags);return delete e.extra.raw,e}return i instanceof Set?Z.newExpression(Z.identifier("Set"),[Z.arrayExpression([...i].map(e=>le(e,s)))]):i instanceof Date?Z.newExpression(Z.identifier("Date"),[Z.literal(i.toISOString())]):i instanceof Map?Z.newExpression(Z.identifier("Map"),[Z.arrayExpression([...i].map(([e,t])=>Z.arrayExpression([le(e,s),le(t,s)])))]):Array.isArray(i)?Z.arrayExpression(i.map(e=>le(e,s))):typeof i=="object"?Z.objectExpression(Object.entries(i).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(i)}function Pc(i,s={}){let e=s;return e[Vr]=!0,e.$ast=i,e.$type||(e.$type="object"),e}var Sc={enumerable:!0,configurable:!0};function xe(i,s,e){let t=Pc(i,s);return new Proxy({},{ownKeys(){return Object.keys(t).filter(r=>r!==Vr&&!r.startsWith("$"))},getOwnPropertyDescriptor(){return Sc},has(r,n){return n in t},...e,get(r,n,a){if(n in t)return t[n];if(e.get)return e.get(r,n,a)},set(r,n,a,o){return n in t?(t[n]=a,!0):e.set?e.set(r,n,a,o):!1}})}var fe=dt,wr=new WeakMap;function Ac(i,s,e){if(wr.has(s))return wr.get(s);let t=xe(s,{get $declaration(){return i},get imported(){return s.type==="ImportDefaultSpecifier"?"default":s.type==="ImportNamespaceSpecifier"?"*":s.imported.type==="Identifier"?s.imported.name:s.imported.value},set imported(r){if(s.type!=="ImportSpecifier")throw new se("Changing import name is not yet implemented");s.imported.type==="Identifier"?s.imported.name=r:s.imported.value=r},get local(){return s.local.name},set local(r){s.local.name=r},get from(){return i.source.value},set from(r){if(r===i.source.value)return;i.specifiers=i.specifiers.filter(a=>a!==s),i.specifiers.length===0&&(e.body=e.body.filter(a=>a!==i));let n=e.body.find(a=>a.type==="ImportDeclaration"&&a.source.value===r);n?n.specifiers.push(s):e.body.unshift(fe.importDeclaration([s],fe.stringLiteral(r)))},toJSON(){return{imported:this.imported,local:this.local,from:this.from}}},{ownKeys(){return["imported","local","from","toJSON"]}});return wr.set(s,t),t}function Ec(i,s){let e=()=>{let a=[];for(let o of i.body)if(o.type==="ImportDeclaration")for(let l of o.specifiers)a.push(Ac(o,l,i));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"?fe.importDefaultSpecifier(fe.identifier(h)):o.imported==="*"?fe.importNamespaceSpecifier(fe.identifier(h)):fe.importSpecifier(fe.identifier(o.imported),fe.identifier(h)),d=c.find(p=>p.from===o.from)?.$declaration;if(d)d.specifiers.push(f);else if(l==="prepend"||c.length===0)i.body.unshift(fe.importDeclaration([f],fe.stringLiteral(o.from)));else{let p=c.at(-1).$declaration,g=i.body.indexOf(p);i.body.splice(g+1,0,fe.importDeclaration([f],fe.stringLiteral(o.from)))}return!0},r=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&&(i.body=i.body.filter(u=>u!==l)),!0};return xe(i,{$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 r(o)},ownKeys(){return e().map(a=>a.local)},has(a,o){return e().some(l=>l.local===o)}})}function As(i,s,e){let t=n=>s[n],r=(n,a)=>{s[n]=a};return xe(i,{$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:(r(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 wc(i,s){if("elements"in i)return As(i,i.elements,s)}function Hn(i,s){if(i.type!=="CallExpression")throw new se("Not a function call");function e(r){if(r.type==="Identifier")return r.name;if(r.type==="MemberExpression")return`${e(r.object)}.${e(r.property)}`;throw new se("Not implemented")}let t=As(i,i.arguments,s);return xe(i,{$type:"function-call",$callee:e(i.callee),$args:t},{})}function vc(i,s){if(i.type!=="ArrowFunctionExpression")throw new se("Not an arrow function expression");let e=As(i,i.params,s);return xe(i,{$type:"arrow-function-expression",$params:e,$body:oe(i.body,s)},{})}var Cc=dt;function Ic(i,s){if(!("properties"in i))return;let e=n=>{for(let a of i.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})},r=(n,a)=>{let o=i.properties.find(l=>t(l)===n);o?o.value=a:Tc(n)?i.properties.push({type:"Property",key:{type:"Identifier",name:n},value:a}):i.properties.push({type:"ObjectProperty",key:Cc.stringLiteral(n),value:a})};return xe(i,{$type:"object",toJSON(){return i.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)),r(a,le(o)),!0},deleteProperty(n,a){typeof a!="string"&&(a=String(a));let o=i.properties.findIndex(l=>"key"in l&&"name"in l.key&&l.key.name===a);return o!==-1&&i.properties.splice(o,1),!0},ownKeys(){return i.properties.map(n=>t(n,!0)).filter(Boolean)}})}function Xn(i,s){if(i.type!=="NewExpression")throw new se("Not a new expression");function e(r){if(r.type==="Identifier")return r.name;if(r.type==="MemberExpression")return`${e(r.object)}.${e(r.property)}`;throw new se("Not implemented")}let t=As(i,i.arguments,s);return xe(i,{$type:"new-expression",$callee:e(i.callee),$args:t},{})}function Nc(i){if(i.type!=="Identifier")throw new se("Not an identifier");return xe(i,{$type:"identifier",$name:i.name},{})}function kc(i){if(i.type!=="LogicalExpression")throw new se("Not a logical expression");return xe(i,{$type:"logicalExpression"},{})}function Lc(i){if(i.type!=="MemberExpression")throw new se("Not a member expression");return xe(i,{$type:"memberExpression"},{})}var vr=new WeakMap;function oe(i,s){if(Kn.has(typeof i))return i;if(bc.has(i.type))return i.value;if(vr.has(i))return vr.get(i);let e;switch(i.type){case"ObjectExpression":{e=Ic(i,s);break}case"ArrayExpression":{e=wc(i,s);break}case"CallExpression":{e=Hn(i,s);break}case"ArrowFunctionExpression":{e=vc(i,s);break}case"NewExpression":{e=Xn(i,s);break}case"Identifier":{e=Nc(i);break}case"LogicalExpression":{e=kc(i);break}case"MemberExpression":{e=Lc(i);break}case"TSAsExpression":case"TSSatisfiesExpression":{e=oe(i.expression,s);break}default:throw new se(`Casting "${i.type}" is not supported`,{ast:i,code:s?.$code})}return vr.set(i,e),e}var Mt=dt;function Dc(i,s){let e=r=>{let n=r==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let a of i.body)if(a.type===n){if(r==="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===r)return o.init}}},t=(r,n)=>{let a=r==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration",o=le(n);for(let l of i.body)if(l.type===a){if(r==="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===r){c.init=o;return}}}i.body.push(r==="default"?Mt.exportDefaultDeclaration(o):Mt.exportNamedDeclaration(Mt.variableDeclaration("const",[Mt.variableDeclarator(Mt.identifier(r),o)])))};return xe(i,{$type:"exports"},{get(r,n){let a=e(n);if(a)return oe(a,s)},set(r,n,a){return t(n,a),!0},ownKeys(){return i.body.flatMap(r=>r.type==="ExportDefaultDeclaration"?["default"]:r.type==="ExportNamedDeclaration"&&r.declaration&&"declarations"in r.declaration?r.declaration.declarations.map(n=>"name"in n.id?n.id.name:""):[]).filter(Boolean)},deleteProperty(r,n){let a=n==="default"?"ExportDefaultDeclaration":"ExportNamedDeclaration";for(let o=0;o<i.body.length;o++){let l=i.body[o];if(l.type===a){if(n==="default")return i.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 i.body.splice(o,1),!0}}}return!1}})}function Oc(i,s){let e=i.program;if(e.type!=="Program")throw new se(`Cannot proxify ${i.type} as module`);let t={$code:s,$type:"module"},r=xe(e,t,{ownKeys(){return["imports","exports","generate"]}});return t.exports=Dc(e,r),t.imports=Ec(e),t.generate=n=>$r(r,n),r}function Gn(i,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,r=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=(i||"").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]===" "?r++:p.length>0&&r--)}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:r>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 Qn(i,s){let e=Fn(i,{parser:s?.parser||Jn(),...s});return Oc(e,i)}function Yn(i,s){let e=Fn("("+i+")",{parser:s?.parser||Jn(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let r={$ast:e,$code:" "+i+" ",$type:"module"};return oe(t,r)}function $r(i,s={}){let e=i.$ast||i,t=s.format===!1||!("$code"in i)?{}:Gn(i.$code,s.format),{code:r,map:n}=mc(e,{...s,...t});return{code:r,map:n}}async function Mc(i,s={}){let e=await Cr.readFile(i,"utf8");return s.sourceFileName=s.sourceFileName??i,Qn(e,s)}async function Fc(i,s,e){let t="$ast"in i?i.$ast:i,{code:r,map:n}=$r(t,e);await Cr.writeFile(s,r),n&&await Cr.writeFile(s+".map",n)}var us=dt,Bc={functionCall(i,...s){let e=us.callExpression(us.identifier(i),s.map(t=>le(t)));return Hn(e)},newExpression(i,...s){let e=us.newExpression(us.identifier(i),s.map(t=>le(t)));return Xn(e)},literal(i){return le(i)},raw(i){return Yn(i)}};async function Qc(i){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=qc("md5");return u.update(c),u.digest("hex")},r=q.normalize(i.cwd),n=su(q.normalize(i.cwd))??r,a=ru(q.normalize(i.cwd))??n,o={...q,getCwdDir:()=>r,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await _c(c),!0}catch{return!1}},magicast:qr,existsSync:c=>ce(c),readdir:async(c,u)=>{let h=await Rc(c);return u?h.map(f=>q.join(c,f)):h},readdirSync:c=>zc(c),readFile:async c=>{try{return await Uc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},readFileSync(c){try{return Wc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},spawnSync:$t,stat:async c=>await Vc(c),statSync:c=>Jc(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 jc(q.dirname(c),{recursive:!0}),await $c(c,u);for(let f of s)await f(h)},hash:t,getDeviceId:()=>t(`${Hc()}:${Kc()}`),formatCode:async(c,u)=>{let h=null;try{h=await Zn.resolveConfig(c)}catch{}try{return Zn.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}`)),Gc(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(i.cwd);return{remoteUrl:Yc(c),defaultBranch:Zc(c),commit:eu(c),currentBranch:tu(c)}},getFrameworks:()=>[],ts:Xc,version:"1.1.41",sdkVersion:null,ignoreMissingConfig:i.ignoreMissingConfig,kind:null},l=await Qr(o);return o.getFrameworks=()=>l,o}function Yc(i){try{return($t("git",["config","--get","remote.origin.url"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function Zc(i){let s="master";try{let e=$t("git",["branch","-r"],{cwd:i});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]===" "?r++:p.length>0&&r--)}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:r>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 Qn(i,s){let e=Fn(i,{parser:s?.parser||Jn(),...s});return Oc(e,i)}function Yn(i,s){let e=Fn("("+i+")",{parser:s?.parser||Jn(),...s}),t=e.program.body[0];t.type==="ExpressionStatement"&&(t=t.expression),t.extra?.parenthesized&&(t.extra.parenthesized=!1);let r={$ast:e,$code:" "+i+" ",$type:"module"};return oe(t,r)}function $r(i,s={}){let e=i.$ast||i,t=s.format===!1||!("$code"in i)?{}:Gn(i.$code,s.format),{code:r,map:n}=mc(e,{...s,...t});return{code:r,map:n}}async function Mc(i,s={}){let e=await Cr.readFile(i,"utf8");return s.sourceFileName=s.sourceFileName??i,Qn(e,s)}async function Fc(i,s,e){let t="$ast"in i?i.$ast:i,{code:r,map:n}=$r(t,e);await Cr.writeFile(s,r),n&&await Cr.writeFile(s+".map",n)}var us=dt,Bc={functionCall(i,...s){let e=us.callExpression(us.identifier(i),s.map(t=>le(t)));return Hn(e)},newExpression(i,...s){let e=us.newExpression(us.identifier(i),s.map(t=>le(t)));return Xn(e)},literal(i){return le(i)},raw(i){return Yn(i)}};async function Qc(i){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=qc("md5");return u.update(c),u.digest("hex")},r=q.normalize(i.cwd),n=su(q.normalize(i.cwd))??r,a=ru(q.normalize(i.cwd))??n,o={...q,getCwdDir:()=>r,getRepoRootDir:()=>n,getAppRootDir:()=>a,cwd:()=>process.cwd(),exists:async c=>{try{return await _c(c),!0}catch{return!1}},magicast:qr,existsSync:c=>ce(c),readdir:async(c,u)=>{let h=await Rc(c);return u?h.map(f=>q.join(c,f)):h},readdirSync:c=>zc(c),readFile:async c=>{try{return await Uc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},readFileSync(c){try{return Wc(c,"utf-8")}catch(u){if(u.code==="ENOENT")return null;throw e(u,c),u}},spawnSync:$t,stat:async c=>await Vc(c),statSync:c=>Jc(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 jc(q.dirname(c),{recursive:!0}),await $c(c,u);for(let f of s)await f(h)},hash:t,getDeviceId:()=>t(`${Hc()}:${Kc()}`),formatCode:async(c,u)=>{let h=null;try{h=await Zn.resolveConfig(c)}catch{}try{return Zn.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}`)),Gc(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(i.cwd);return{remoteUrl:Yc(c),defaultBranch:Zc(c),commit:eu(c),currentBranch:tu(c)}},getFrameworks:()=>[],ts:Xc,version:"1.1.42",sdkVersion:null,ignoreMissingConfig:i.ignoreMissingConfig,kind:null},l=await Qr(o);return o.getFrameworks=()=>l,o}function Yc(i){try{return($t("git",["config","--get","remote.origin.url"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git remote URL:",s),""}}function Zc(i){let s="master";try{let e=$t("git",["branch","-r"],{cwd:i});return e.stdout&&e.stdout.toString().trim().split(`
105
105
  `).map(r=>r.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 eu(i){try{return($t("git",["rev-parse","HEAD"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting git commit:",s),""}}function tu(i){try{return($t("git",["branch","--show-current"],{cwd:i}).stdout||"").toString().trim()}catch(s){return console.error("Error getting current branch name:",s),""}}function su(i){let s=q.resolve("/");for(let e=0;e<20;e++){let t=q.join(i,"package.json");if(ce(t))return i;if(i===s)break;i=q.dirname(i)}return null}function ru(i){let s=q.resolve("/");for(let e=0;e<20;e++){if(ce(q.join(i,"package.json"))||ce(q.join(i,"remix.config.js"))||ce(q.join(i,"remix.config.mjs"))||ce(q.join(i,"remix.config.ts"))||ce(q.join(i,"vite.config.js"))||ce(q.join(i,"vite.config.ts"))||ce(q.join(i,"vite.config.mjs"))||ce(q.join(i,"next.config.js"))||ce(q.join(i,"next.config.ts"))||ce(q.join(i,"angular.json"))||ce(q.join(i,"project.json"))||ce(q.join(i,"tsconfig.json")))return i;if(i===s)break;i=q.dirname(i)}return null}export{Qc as createDevToolsNodeSys};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "builder.io",
3
- "version": "1.1.41",
3
+ "version": "1.1.42",
4
4
  "description": "Add and Sync Builder.io code snippets to an application",
5
5
  "type": "module",
6
6
  "bin": {