builder.io 1.1.39 → 1.1.41
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/cli/index.cjs +218 -218
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +3 -3
- package/core/index.mjs +3 -3
- package/node/index.cjs +48 -48
- package/node/index.mjs +53 -53
- package/package.json +1 -1
- package/server/index.cjs +7 -7
- package/server/index.mjs +7 -7
- package/types/types.d.ts +3 -1
package/core/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var si=Object.create;var vt=Object.defineProperty;var ui=Object.getOwnPropertyDescriptor;var pi=Object.getOwnPropertyNames;var li=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty;var ve=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mi=(e,t)=>{for(var r in t)vt(e,r,{get:t[r],enumerable:!0})},qn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pi(t))!ci.call(e,o)&&o!==r&&vt(e,o,{get:()=>t[o],enumerable:!(n=ui(t,o))||n.enumerable});return e};var Jn=(e,t,r)=>(r=e!=null?si(li(e)):{},qn(t||!e||!e.__esModule?vt(r,"default",{value:e,enumerable:!0}):r,e)),fi=e=>qn(vt({},"__esModule",{value:!0}),e);var Yn=ve((Nu,Wn)=>{"use strict";Wn.exports=function(){if(process.env.npm_config_user_agent)return gi(process.env.npm_config_user_agent)};function gi(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var bn=ve(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});function wo(e){return Object.prototype.toString.call(e)}Jt.getType=wo;function Ws(e){throw new TypeError("unsupported data type: "+wo(e))}Jt.throwUnknownDataType=Ws});var Bn=ve(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});var Be="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Be+=t}var st=Be.length,In={};for(let e=0;e<st;e++){let t=Be[e];In[t]=e}function Rn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=In[o];i*=r,t+=i,r*=st}return t}Oe.s_to_int=Rn;function To(e){let t=BigInt(0),r=BigInt(1),n=BigInt(st);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(In[i]);a*=r,t+=a,r*=n}return t}Oe.s_to_big_int=To;function Nn(e){if(e===0)return Be[0];let t=[];for(;e!==0;){let r=e%st,n=Be[r];t.push(n),e-=r,e/=st}return t.reverse().join("")}Oe.int_to_s=Nn;function bo(e){let t=BigInt(0),r=BigInt(st);if(e===t)return Be[0];let n=[];for(;e!==t;){let o=e%r,i=Be[Number(o)];n.push(i),e-=o,e/=r}return n.reverse().join("")}Oe.big_int_to_s=bo;function Wt(e){return e.split("").reverse().join("")}function vo(e){if(e<0)return"-"+vo(-e);let[t,r]=e.toString().split(".");if(!r)return Nn(e);let n;r&&([r,n]=r.split("e")),t=Qt(t),r=Wt(r),r=Qt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Wt(n),n=Qt(n),o+=n}return o}Oe.num_to_s=vo;function Qt(e){let t=+e;return t.toString()===e?Nn(t):":"+bo(BigInt(e))}Oe.int_str_to_s=Qt;function vn(e){return e[0]===":"?To(e.substring(1)).toString():Rn(e).toString()}function Io(e){if(e[0]==="-")return-Io(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Rn(t);t=vn(t),r=vn(r),r=Wt(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=vn(n),n=Wt(n),o+=i?-n:+n}return+o}Oe.s_to_num=Io});var kn=ve(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var On=Bn();function Ys(e){return"n|"+On.num_to_s(e)}ke.encodeNum=Ys;function Gs(e){return e=e.replace("n|",""),On.s_to_num(e)}ke.decodeNum=Gs;function Hs(e){return typeof e=="number"?e:On.s_to_int(e)}ke.decodeKey=Hs;function Xs(e){return e?"b|T":"b|F"}ke.encodeBool=Xs;function Zs(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}ke.decodeBool=Zs;function eu(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}ke.encodeStr=eu;function tu(e){return e[0]+e[1]==="s|"?e.substr(2):e}ke.decodeStr=tu});var Ro=ve(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.config={sort_key:!1}});var jn=ve(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});var nu=Ro(),ru=bn(),_n=kn(),ou=Bn();function iu(e){return e.store.toArray()}He.memToValues=iu;function No(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}He.makeInMemoryStore=No;function Bo(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}He.makeInMemoryCache=Bo;function au(){return{store:No(),cache:Bo(),keyCount:0}}He.makeInMemoryMemory=au;function Ge(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=ou.num_to_s(r);return e.store.add(t),e.cache.setValue(t,n),n}function su(e,t){nu.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=yt(e,t,void 0);return e.cache.setSchema(r,n),n}function yt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return yt(e,null,r);break;case"object":if(t===null)return Ge(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":yt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),Ge(e,n)}else{let n=Object.keys(t);if(n.length===0)return Ge(e,"o|");let o="o",i=su(e,n);o+="|"+i;for(let a of n){let s=t[a],u=yt(e,s,t);o+="|"+u}return Ge(e,o)}case"boolean":return Ge(e,_n.encodeBool(t));case"number":return Ge(e,_n.encodeNum(t));case"string":return Ge(e,_n.encodeStr(t))}return ru.throwUnknownDataType(t)}He.addValue=yt});var $n=ve(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});var uu=bn(),Yt=kn(),Vn=jn();function pu(e){let t=Vn.makeInMemoryMemory(),r=Vn.addValue(t,e,void 0);return[Vn.memToValues(t),r]}Tt.compress=pu;function lu(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=wt(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=wt(e,p),r[u]=p}return r}function cu(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=wt(e,a),o[i]=a}return o}function wt(e,t){if(t===""||t==="_")return null;let r=Yt.decodeKey(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return Yt.decodeBool(n);case"o|":return lu(e,n);case"n|":return Yt.decodeNum(n);case"a|":return cu(e,n);default:return Yt.decodeStr(n)}}return uu.throwUnknownDataType(n)}Tt.decode=wt;function mu(e){let[t,r]=e;return wt(t,r)}Tt.decompress=mu});var ko=ve(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});function fu(e){for(let t in e)e[t]===void 0&&delete e[t]}Gt.trimUndefined=fu;function du(e){Oo(e,new Set)}Gt.trimUndefinedRecursively=du;function Oo(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&Oo(n,t)}}});var jo=ve(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var Lo=$n();Ue.compress=Lo.compress;Ue.decompress=Lo.decompress;var gu=$n();Ue.decode=gu.decode;var Du=jn();Ue.addValue=Du.addValue;var _o=ko();Ue.trimUndefined=_o.trimUndefined;Ue.trimUndefinedRecursively=_o.trimUndefinedRecursively});var vu={};mi(vu,{createDevTools:()=>Mo,createDevToolsSys:()=>zo,detectFrameworks:()=>Le,detectFrameworksFromPackageJson:()=>Zt,ensureConfigPlugin:()=>oi,findBuildToolConfig:()=>zn,getClientScript:()=>ai,parseDotEnvContent:()=>en,version:()=>bt});module.exports=fi(vu);function re(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var di=["node_modules","dist","build","public"];async function ae(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(di.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("builder-registry."))return u;if(p.isDirectory()){let m=await r(u,i+1);if(m)return m}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await re(e)?"ts":"js"}`;return e.join(t,i)}return n}async function It(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function Qn(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function ut(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await ut(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var Hn=Jn(Yn(),1);function B(e,t,r){t=ce(t),r=ce(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=ce(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function ce(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function qe(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return Gn(o==="index"?e.basename(e.dirname(t)):o)}function Gn(e){return K(e).replace(/ /g,"")}function se(e,t){let r=e.extname(t),n=ce(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function V(e,t){let r=ce(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function k(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function te(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function $(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function pt(e){return typeof e=="number"}function Xe(e){return typeof e=="boolean"}function Z(e){return typeof e=="string"}function Ze(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function oe(e){return JSON.parse(JSON.stringify(e))}function Rt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function Xn(){try{let e=(0,Hn.default)();if(e?.name)return e.name}catch{}return"npm"}async function Le(e){let t=[],r=await It(e,e.getRepoRootDir());if(r){let n=await Zt(r,e);t.push(...n)}return t}async function Zt(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Di)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};Zn.has(o)&&(i.version=await Zn.get(o)(t)),r.push(i)}}return r}function Xt(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var Zn=new Map([["next",async e=>{if(!e.spawn)return;let t=Xn(),r=t==="npm"?"npx":t,{stdout:n}=e.spawn.sync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:Xt(a),minor:Xt(s),patch:Xt(u)}}]]),Di=["@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 ge(e){let t=er(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function De(e,t){t=typeof t=="object"&&t!=null?t:{};let r=er(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function er(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function _e(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await Ci(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function Ci(e,t){let r=await e.readFile(t);return typeof r=="string"?en(r):null}function en(e){let t={},r=e.replace(/\r\n?/gm,`
|
|
1
|
+
"use strict";var si=Object.create;var vt=Object.defineProperty;var ui=Object.getOwnPropertyDescriptor;var pi=Object.getOwnPropertyNames;var li=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty;var ve=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),mi=(e,t)=>{for(var r in t)vt(e,r,{get:t[r],enumerable:!0})},qn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pi(t))!ci.call(e,o)&&o!==r&&vt(e,o,{get:()=>t[o],enumerable:!(n=ui(t,o))||n.enumerable});return e};var Jn=(e,t,r)=>(r=e!=null?si(li(e)):{},qn(t||!e||!e.__esModule?vt(r,"default",{value:e,enumerable:!0}):r,e)),fi=e=>qn(vt({},"__esModule",{value:!0}),e);var Yn=ve((Nu,Wn)=>{"use strict";Wn.exports=function(){if(process.env.npm_config_user_agent)return gi(process.env.npm_config_user_agent)};function gi(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var bn=ve(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});function wo(e){return Object.prototype.toString.call(e)}Jt.getType=wo;function Ws(e){throw new TypeError("unsupported data type: "+wo(e))}Jt.throwUnknownDataType=Ws});var Bn=ve(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});var Be="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Be+=t}var st=Be.length,In={};for(let e=0;e<st;e++){let t=Be[e];In[t]=e}function Rn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=In[o];i*=r,t+=i,r*=st}return t}Oe.s_to_int=Rn;function To(e){let t=BigInt(0),r=BigInt(1),n=BigInt(st);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(In[i]);a*=r,t+=a,r*=n}return t}Oe.s_to_big_int=To;function Nn(e){if(e===0)return Be[0];let t=[];for(;e!==0;){let r=e%st,n=Be[r];t.push(n),e-=r,e/=st}return t.reverse().join("")}Oe.int_to_s=Nn;function bo(e){let t=BigInt(0),r=BigInt(st);if(e===t)return Be[0];let n=[];for(;e!==t;){let o=e%r,i=Be[Number(o)];n.push(i),e-=o,e/=r}return n.reverse().join("")}Oe.big_int_to_s=bo;function Wt(e){return e.split("").reverse().join("")}function vo(e){if(e<0)return"-"+vo(-e);let[t,r]=e.toString().split(".");if(!r)return Nn(e);let n;r&&([r,n]=r.split("e")),t=Qt(t),r=Wt(r),r=Qt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Wt(n),n=Qt(n),o+=n}return o}Oe.num_to_s=vo;function Qt(e){let t=+e;return t.toString()===e?Nn(t):":"+bo(BigInt(e))}Oe.int_str_to_s=Qt;function vn(e){return e[0]===":"?To(e.substring(1)).toString():Rn(e).toString()}function Io(e){if(e[0]==="-")return-Io(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Rn(t);t=vn(t),r=vn(r),r=Wt(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=vn(n),n=Wt(n),o+=i?-n:+n}return+o}Oe.s_to_num=Io});var kn=ve(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var On=Bn();function Ys(e){return"n|"+On.num_to_s(e)}ke.encodeNum=Ys;function Gs(e){return e=e.replace("n|",""),On.s_to_num(e)}ke.decodeNum=Gs;function Hs(e){return typeof e=="number"?e:On.s_to_int(e)}ke.decodeKey=Hs;function Xs(e){return e?"b|T":"b|F"}ke.encodeBool=Xs;function Zs(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}ke.decodeBool=Zs;function eu(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}ke.encodeStr=eu;function tu(e){return e[0]+e[1]==="s|"?e.substr(2):e}ke.decodeStr=tu});var Ro=ve(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.config={sort_key:!1}});var jn=ve(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});var nu=Ro(),ru=bn(),_n=kn(),ou=Bn();function iu(e){return e.store.toArray()}He.memToValues=iu;function No(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}He.makeInMemoryStore=No;function Bo(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}He.makeInMemoryCache=Bo;function au(){return{store:No(),cache:Bo(),keyCount:0}}He.makeInMemoryMemory=au;function Ge(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=ou.num_to_s(r);return e.store.add(t),e.cache.setValue(t,n),n}function su(e,t){nu.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=yt(e,t,void 0);return e.cache.setSchema(r,n),n}function yt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return yt(e,null,r);break;case"object":if(t===null)return Ge(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":yt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),Ge(e,n)}else{let n=Object.keys(t);if(n.length===0)return Ge(e,"o|");let o="o",i=su(e,n);o+="|"+i;for(let a of n){let s=t[a],u=yt(e,s,t);o+="|"+u}return Ge(e,o)}case"boolean":return Ge(e,_n.encodeBool(t));case"number":return Ge(e,_n.encodeNum(t));case"string":return Ge(e,_n.encodeStr(t))}return ru.throwUnknownDataType(t)}He.addValue=yt});var $n=ve(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});var uu=bn(),Yt=kn(),Vn=jn();function pu(e){let t=Vn.makeInMemoryMemory(),r=Vn.addValue(t,e,void 0);return[Vn.memToValues(t),r]}Tt.compress=pu;function lu(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=wt(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=wt(e,p),r[u]=p}return r}function cu(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=wt(e,a),o[i]=a}return o}function wt(e,t){if(t===""||t==="_")return null;let r=Yt.decodeKey(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return Yt.decodeBool(n);case"o|":return lu(e,n);case"n|":return Yt.decodeNum(n);case"a|":return cu(e,n);default:return Yt.decodeStr(n)}}return uu.throwUnknownDataType(n)}Tt.decode=wt;function mu(e){let[t,r]=e;return wt(t,r)}Tt.decompress=mu});var ko=ve(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});function fu(e){for(let t in e)e[t]===void 0&&delete e[t]}Gt.trimUndefined=fu;function du(e){Oo(e,new Set)}Gt.trimUndefinedRecursively=du;function Oo(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&Oo(n,t)}}});var jo=ve(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var Lo=$n();Ue.compress=Lo.compress;Ue.decompress=Lo.decompress;var gu=$n();Ue.decode=gu.decode;var Du=jn();Ue.addValue=Du.addValue;var _o=ko();Ue.trimUndefined=_o.trimUndefined;Ue.trimUndefinedRecursively=_o.trimUndefinedRecursively});var vu={};mi(vu,{createDevTools:()=>Mo,createDevToolsSys:()=>zo,detectFrameworks:()=>Le,detectFrameworksFromPackageJson:()=>Zt,ensureConfigPlugin:()=>oi,findBuildToolConfig:()=>zn,getClientScript:()=>ai,parseDotEnvContent:()=>en,version:()=>bt});module.exports=fi(vu);function re(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var di=["node_modules","dist","build","public"];async function ae(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(di.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("builder-registry."))return u;if(p.isDirectory()){let m=await r(u,i+1);if(m)return m}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await re(e)?"ts":"js"}`;return e.join(t,i)}return n}async function It(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function Qn(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function ut(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await ut(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var Hn=Jn(Yn(),1);function B(e,t,r){t=ce(t),r=ce(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=ce(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function ce(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function qe(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return Gn(o==="index"?e.basename(e.dirname(t)):o)}function Gn(e){return K(e).replace(/ /g,"")}function se(e,t){let r=e.extname(t),n=ce(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function V(e,t){let r=ce(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function k(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function te(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function $(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function pt(e){return typeof e=="number"}function Xe(e){return typeof e=="boolean"}function Z(e){return typeof e=="string"}function Ze(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function oe(e){return JSON.parse(JSON.stringify(e))}function Rt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function Xn(){try{let e=(0,Hn.default)();if(e?.name)return e.name}catch{}return"npm"}async function Le(e){let t=[],r=await It(e,e.getRepoRootDir());if(r){let n=await Zt(r,e);t.push(...n)}return t}async function Zt(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Di)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};Zn.has(o)&&(i.version=await Zn.get(o)(t)),r.push(i)}}return r}function Xt(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var Zn=new Map([["next",async e=>{if(!e.spawnSync)return;let t=Xn(),r=t==="npm"?"npx":t,{stdout:n}=e.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:Xt(a),minor:Xt(s),patch:Xt(u)}}]]),Di=["@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 ge(e){let t=er(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function De(e,t){t=typeof t=="object"&&t!=null?t:{};let r=er(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function er(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function _e(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await Ci(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function Ci(e,t){let r=await e.readFile(t);return typeof r=="string"?en(r):null}function en(e){let t={},r=e.replace(/\r\n?/gm,`
|
|
2
2
|
`),n;for(;(n=xi.exec(r))!=null;){let o=n[1],i=n[2]||"";i=i.trim();let a=i[0];i=i.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),a==='"'&&(i=i.replace(/\\n/g,`
|
|
3
3
|
`),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var xi=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;async function je(e,t,r,n){let o="# https://www.builder.io/c/docs/using-your-api-key",i=await e.readFile(t);if(i)if(i.includes(r))if(i.includes(n))e.debug(`"${r}" with "${n}" already set in ${t}`);else return e.debug(`Replace "${r}" in ${t}`),i=i.replace(new RegExp(`${r}=.*`),`${r}=${n}`),await e.writeFile(t,i),"update";else return e.debug(`Append "${r}" to ${t}`),i+=`
|
|
4
4
|
|
|
@@ -913,7 +913,7 @@ export class Counter {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
-
`.trimStart()}async function Fo(e){await qt(e);let t=await e.readFile(e.registryPath);return t?Ms(e,t):{components:[],sourceFile:I(e,"")}}async function Ms(e,t){let r=I(e,t);return Us(e,r)}async function Us(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Tn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:te(r)}}async function Tn(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(N(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let p=s.arguments[0];e.ts.isIdentifier(p)&&(a=p.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await xe(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=V(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await lo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let m=p.find(f=>f.cmpInfo.exportName===a);m&&(n.exportName=m.cmpInfo.exportName)}}continue}}return n=ne(e,n,r),n.filePath&&n.exportName&&(n.id=await $(e,n.filePath,n.exportName,n.externalImportPath)),n}async function be(e,t,r,n,o,i,a,s){let u=await Ke(e),[p,m,f]=await Promise.all([po(e,u),Fo(e),At(e)]),c=p.map(x=>x.cmpInfo),d=m.components,C={components:me(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:he(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return C.components=await co(e,p,C.components),C;let l=!1,D=m.sourceFile,g=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(g.length>0){let x=g.map(A=>{let E=p.find(O=>O.cmpInfo.id===A);if(!E)throw new Error(`Component ${A} not found`);return E}),S=Array.from(new Set(x.map(A=>A.cmpInfo.filePath))),P=await G(e,S);for(let A of x){let E=C.components.find(L=>L.id===A.cmpInfo.id),O=await hn(e,A,P);ie(E,O);let z=c.findIndex(L=>L.id===A.cmpInfo.id);c[z].inputs=O;let j=Fe(A.cmpInfo.id,c,d,r,n,o,i),{elements:F,elmIndex:y,statementIndex:H,statement:le,variableDeclaration:Y}=await qs(e,D,A);if(j.addCmpToRegistry)F.push(zs(e,j.addCmpToRegistry)),l=!0;else if(j.removeCmpFromRegistry)F.splice(y,1),l=!0;else if(j.updateRegisteredCmp){let L=Q(e,F[y],j.updateRegisteredCmp);F[y]=e.ts.factory.updateObjectLiteralExpression(L,[Po(e,j.updateRegisteredCmp),...L.properties.slice(1)]),l=!0}if(l&&a){let L=[...D.statements];L[H]=e.ts.factory.updateVariableStatement(le,le.modifiers,e.ts.factory.updateVariableDeclarationList(le.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Se(e,F)))])),D=e.ts.factory.updateSourceFile(D,L),E.exportType==="named"?D=v(e,D,{namedImports:[E.importName],importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}):D=v(e,D,{defaultImport:E.importName,importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}),D=v(e,D,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),D=Pe(e,D,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),C.components=j.components,d=j.components.filter(X=>X.isRegistered)}}}if(l&&a){D=Ae(e,D),D=Ee(e,D);let x=_(e,D);x=pe(x),x=await e.formatCode(e.registryPath,x),await e.writeFile(e.registryPath,x)}return C}function Po(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function zs(e,t){return Q(e,e.ts.factory.createObjectLiteralExpression([Po(e,t)],!0),t)}async function qs(e,t,r){let n=J(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 Tn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function yo(e){let t=await Js(e),r={};return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Eo(t),ensureFigmaImportPage:()=>So(t),getRegistryPath:()=>t.registryPath,getRegistry:o=>be(t,null,!1,!1,null,null,!1,!!o?.readAllInputTypes),addExternalPackage:async o=>{r[o]||(r[o]=`export * from "${o}";`)},loadComponent:async o=>{let i=await be(t,o.cmpId,!1,!1,null,null,!1,!1);return{...i,component:i.components.find(a=>a.id===o.cmpId)}},registerComponent:o=>be(t,o.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:o=>be(t,o.cmpId,!1,!1,o,null,!0,!1),setRegisteredComponentInput:o=>be(t,o.cmpId,!1,!1,null,o,!0,!1),unregisterComponent:o=>be(t,o.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>At(t),setPublicApiKey:o=>uo(t,o.publicApiKey),getDependencies:o=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ge(t),setCache:o=>De(t,o)}}async function Js(e){let t=await Qs(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await re(e),i=e.join(n,"app"),a=await ae(e,i),s={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);s.srcDir=n,s.appDir=i,s.componentsDir=e.join(s.appDir,"components"),s.builderPageComponentPath=e.join(s.componentsDir,`builder-page.component.${o?"ts":"js"}`);let u=`app.module.${o?"ts":"js"}`,p=e.join(s.appDir,u);return await e.exists(p)&&(s.hasAppModule=!0),s}async function Qs(e){let t=e.join(e.getAppRootDir(),"angular.json");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"project.json");if(await e.exists(r))return r;throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}var Ht=Jn(jo(),1);async function Vo(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:ce(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:oe(i.inputs)};return oe(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,Ht.compress)(n);return btoa(JSON.stringify(o))}async function $o(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,Ht.decompress)(o),a=oe(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=ce(e.normalize(s.filePath)),p=n.components.find(f=>ce(f.filePath).endsWith(u)&&f.exportName===s.exportName);if(!p){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${p.id})`,p.filePath),await t.registerComponent({cmpId:p.id});for(let f of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${p.id}) info`);let m=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=oe(m)}return a}var de={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},ud={[de.react]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.remix]:[{version:w.gen1,recommended:!1},{version:w.gen2,recommended:!0}],[de.angular]:[{version:w.gen2,recommended:!0}],[de.next]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.qwik]:[{version:w.gen2,recommended:!0}]};async function Ko(e,t){let r=[],n=new Set;async function o(s){let u=e.join(s,"package.json");try{let p=await e.readFile(u);if(p===null)throw new Error(`Failed to read package.json at ${u}`);let m=JSON.parse(p);if(n.has(m.name))return null;n.add(m.name);let f={name:m.name,subPackages:[]},c=await e.readdir(s);for(let d of c)d!=="node_modules"&&(await e.stat(e.join(s,d))).isDirectory()&&f.subPackages.push(d);return r.push(f),f}catch(p){return console.error(`Error reading package.json at ${s}:`,p),null}}let i=e.join(t,"package.json"),a=await e.readFile(i);if(a!==null){let s=JSON.parse(a),u={...s.dependencies,...s.devDependencies};for(let p of Object.keys(u)){let m=e.join(t,"node_modules",p);await o(m)}if(s.workspaces)for(let p of s.workspaces){let m=await e.readdir(e.join(t,p));for(let f of m){let c=e.join(t,p,f);await o(c)}}}return r}var Cu={"@builder.io/qwik-city":zr,next:Br,"@remix-run/react":Xr,react:so,"@angular/core":yo},xu={"@builder.io/qwik-city":de.qwik,next:de.next,"@remix-run/react":de.remix,react:de.react,"@angular/core":de.angular};async function Mo(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 Le(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getAppRootDir()}`);for(let t of e.frameworks){let r=Cu[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>Vo(e,n),importRegistry:i=>$o(e,n,i),framework:xu[t.name],findAllDependencies:async()=>await Ko(e,e.getRepoRootDir())}}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function Uo(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 d="",C=0,l=-1,D=0,g;for(let x=0;x<=f.length;++x){if(x<f.length)g=f.charCodeAt(x);else{if(g===47)break;g=47}if(g===47){if(!(l===x-1||D===1))if(l!==x-1&&D===2){if(d.length<2||C!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let S=d.lastIndexOf("/");if(S!==d.length-1){S===-1?(d="",C=0):(d=d.slice(0,S),C=d.length-1-d.lastIndexOf("/")),l=x,D=0;continue}}else if(d.length===2||d.length===1){d="",C=0,l=x,D=0;continue}}c&&(d.length>0?d+="/..":d="..",C=2)}else d.length>0?d+="/"+f.slice(l+1,x):d=f.slice(l+1,x),C=x-l-1;l=x,D=0}else g===46&&D!==-1?++D:D=-1}return d}let n=function(...c){let d="",C=!1;for(let l=c.length-1;l>=-1&&!C;l--){let D;l>=0?D=c[l]:e.cwd?D=e.cwd():D="/",t(D),D.length!==0&&(d=D+"/"+d,C=D.charCodeAt(0)===47)}return d=r(d,!C),C?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,C=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&C&&(c+="/"),d?"/"+c:c};return{relative:function(c,d){if(t(c),t(d),c===d||(c=n(c),d=n(d),c===d))return"";let C=1;for(;C<c.length&&c.charCodeAt(C)===47;++C);let l=c.length,D=l-C,g=1;for(;g<d.length&&d.charCodeAt(g)===47;++g);let S=d.length-g,P=D<S?D:S,A=-1,E=0;for(;E<=P;++E){if(E===P){if(S>P){if(d.charCodeAt(g+E)===47)return d.slice(g+E+1);if(E===0)return d.slice(g+E)}else D>P&&(c.charCodeAt(C+E)===47?A=E:E===0&&(A=0));break}let z=c.charCodeAt(C+E),j=d.charCodeAt(g+E);if(z!==j)break;z===47&&(A=E)}let O="";for(E=C+A+1;E<=l;++E)(E===l||c.charCodeAt(E)===47)&&(O.length===0?O+="..":O+="/..");return O.length>0?O+d.slice(g+A):(g+=A,d.charCodeAt(g)===47&&++g,d.slice(g))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let C=0;C<c.length;++C){let l=c[C];t(l),l.length>0&&(d===void 0?d=l:d+="/"+l)}return d===void 0?".":o(d)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,d){if(d!==void 0&&typeof d!="string")throw new TypeError('"ext" argument must be a string');t(c);let C=0,l=-1,D=!0,g;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let x=d.length-1,S=-1;for(g=c.length-1;g>=0;--g){let P=c.charCodeAt(g);if(P===47){if(!D){C=g+1;break}}else S===-1&&(D=!1,S=g+1),x>=0&&(P===d.charCodeAt(x)?--x===-1&&(l=g):(x=-1,l=S))}return C===l?l=S:l===-1&&(l=c.length),c.slice(C,l)}else{for(g=c.length-1;g>=0;--g)if(c.charCodeAt(g)===47){if(!D){C=g+1;break}}else l===-1&&(D=!1,l=g+1);return l===-1?"":c.slice(C,l)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),C=d===47,l=-1,D=!0;for(let g=c.length-1;g>=1;--g)if(d=c.charCodeAt(g),d===47){if(!D){l=g;break}}else D=!1;return l===-1?C?"/":".":C&&l===1?"//":c.slice(0,l)},extname:function(c){t(c);let d=-1,C=0,l=-1,D=!0,g=0;for(let x=c.length-1;x>=0;--x){let S=c.charCodeAt(x);if(S===47){if(!D){C=x+1;break}continue}l===-1&&(D=!1,l=x+1),S===46?d===-1?d=x:g!==1&&(g=1):d!==-1&&(g=-1)}return d===-1||l===-1||g===0||g===1&&d===l-1&&d===C+1?"":c.slice(d,l)}}}async function zo(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=Uo({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[D]of o)if((D+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let D=l===t()?l:l+"/",g=D.split("/").length-1,x=[];for(let[S]of o)if(S.split("/").slice(0,g).join("/")+"/"===D){let E=S.split("/")[g];E&&!x.includes(E)&&x.push(E)}return x.sort()},p=l=>{l=i(l);let D=o.get(l);return typeof D=="string"?D:null},m=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l)}),f=async l=>{if(typeof crypto<"u"){let x=new TextEncoder().encode(l),S=await crypto.subtle.digest("SHA-256",x);return Array.from(new Uint8Array(S)).map(P=>P.toString(16).padStart(2,"0")).join("")}let D=0;for(let g=0;g<l.length;g++){let x=l.charCodeAt(g);D=(D<<5)-D+x,D|=0}return Number(Math.abs(D)).toString(36)},c=new Set,d={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readFile:async l=>p(l),readFileSync:p,stat:async l=>m(l),statSync:m,writeFile:async(l,D)=>{l=i(l),o.set(l,D);let g={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let x of c)await x(g)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",getRepoInfo:async()=>({remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,D)=>D,on:(l,D)=>{l==="change"&&c.add(D)},off:(l,D)=>{l==="change"&&c.delete(D)},debug:(...l)=>{console.debug("[builder-dev-tools]",...l)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,kind:null,magicast:void 0,spawn:void 0},C=await Le(d);return d.getFrameworks=e.getFrameworks?e.getFrameworks:()=>C,d}async function qo(e,t,r){let n=I(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(Jo(e,n))return o;let a=ue(e,n,"cjs"),s=ue(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let m=s[0];if(!m.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=m.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Unexpected export type in ${t}
|
|
916
|
+
`.trimStart()}async function Fo(e){await qt(e);let t=await e.readFile(e.registryPath);return t?Ms(e,t):{components:[],sourceFile:I(e,"")}}async function Ms(e,t){let r=I(e,t);return Us(e,r)}async function Us(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Tn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:te(r)}}async function Tn(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(N(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let p=s.arguments[0];e.ts.isIdentifier(p)&&(a=p.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await xe(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=V(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await lo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let m=p.find(f=>f.cmpInfo.exportName===a);m&&(n.exportName=m.cmpInfo.exportName)}}continue}}return n=ne(e,n,r),n.filePath&&n.exportName&&(n.id=await $(e,n.filePath,n.exportName,n.externalImportPath)),n}async function be(e,t,r,n,o,i,a,s){let u=await Ke(e),[p,m,f]=await Promise.all([po(e,u),Fo(e),At(e)]),c=p.map(x=>x.cmpInfo),d=m.components,C={components:me(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:he(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return C.components=await co(e,p,C.components),C;let l=!1,D=m.sourceFile,g=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(g.length>0){let x=g.map(A=>{let E=p.find(O=>O.cmpInfo.id===A);if(!E)throw new Error(`Component ${A} not found`);return E}),S=Array.from(new Set(x.map(A=>A.cmpInfo.filePath))),P=await G(e,S);for(let A of x){let E=C.components.find(L=>L.id===A.cmpInfo.id),O=await hn(e,A,P);ie(E,O);let z=c.findIndex(L=>L.id===A.cmpInfo.id);c[z].inputs=O;let j=Fe(A.cmpInfo.id,c,d,r,n,o,i),{elements:F,elmIndex:y,statementIndex:H,statement:le,variableDeclaration:Y}=await qs(e,D,A);if(j.addCmpToRegistry)F.push(zs(e,j.addCmpToRegistry)),l=!0;else if(j.removeCmpFromRegistry)F.splice(y,1),l=!0;else if(j.updateRegisteredCmp){let L=Q(e,F[y],j.updateRegisteredCmp);F[y]=e.ts.factory.updateObjectLiteralExpression(L,[Po(e,j.updateRegisteredCmp),...L.properties.slice(1)]),l=!0}if(l&&a){let L=[...D.statements];L[H]=e.ts.factory.updateVariableStatement(le,le.modifiers,e.ts.factory.updateVariableDeclarationList(le.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Se(e,F)))])),D=e.ts.factory.updateSourceFile(D,L),E.exportType==="named"?D=v(e,D,{namedImports:[E.importName],importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}):D=v(e,D,{defaultImport:E.importName,importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}),D=v(e,D,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),D=Pe(e,D,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),C.components=j.components,d=j.components.filter(X=>X.isRegistered)}}}if(l&&a){D=Ae(e,D),D=Ee(e,D);let x=_(e,D);x=pe(x),x=await e.formatCode(e.registryPath,x),await e.writeFile(e.registryPath,x)}return C}function Po(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function zs(e,t){return Q(e,e.ts.factory.createObjectLiteralExpression([Po(e,t)],!0),t)}async function qs(e,t,r){let n=J(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 Tn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function yo(e){let t=await Js(e),r={};return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Eo(t),ensureFigmaImportPage:()=>So(t),getRegistryPath:()=>t.registryPath,getRegistry:o=>be(t,null,!1,!1,null,null,!1,!!o?.readAllInputTypes),addExternalPackage:async o=>{r[o]||(r[o]=`export * from "${o}";`)},loadComponent:async o=>{let i=await be(t,o.cmpId,!1,!1,null,null,!1,!1);return{...i,component:i.components.find(a=>a.id===o.cmpId)}},registerComponent:o=>be(t,o.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:o=>be(t,o.cmpId,!1,!1,o,null,!0,!1),setRegisteredComponentInput:o=>be(t,o.cmpId,!1,!1,null,o,!0,!1),unregisterComponent:o=>be(t,o.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>At(t),setPublicApiKey:o=>uo(t,o.publicApiKey),getDependencies:o=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ge(t),setCache:o=>De(t,o)}}async function Js(e){let t=await Qs(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await re(e),i=e.join(n,"app"),a=await ae(e,i),s={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);s.srcDir=n,s.appDir=i,s.componentsDir=e.join(s.appDir,"components"),s.builderPageComponentPath=e.join(s.componentsDir,`builder-page.component.${o?"ts":"js"}`);let u=`app.module.${o?"ts":"js"}`,p=e.join(s.appDir,u);return await e.exists(p)&&(s.hasAppModule=!0),s}async function Qs(e){let t=e.join(e.getAppRootDir(),"angular.json");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"project.json");if(await e.exists(r))return r;throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}var Ht=Jn(jo(),1);async function Vo(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:ce(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:oe(i.inputs)};return oe(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,Ht.compress)(n);return btoa(JSON.stringify(o))}async function $o(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,Ht.decompress)(o),a=oe(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=ce(e.normalize(s.filePath)),p=n.components.find(f=>ce(f.filePath).endsWith(u)&&f.exportName===s.exportName);if(!p){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${p.id})`,p.filePath),await t.registerComponent({cmpId:p.id});for(let f of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${p.id}) info`);let m=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=oe(m)}return a}var de={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},ud={[de.react]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.remix]:[{version:w.gen1,recommended:!1},{version:w.gen2,recommended:!0}],[de.angular]:[{version:w.gen2,recommended:!0}],[de.next]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.qwik]:[{version:w.gen2,recommended:!0}]};async function Ko(e,t){let r=[],n=new Set;async function o(s){let u=e.join(s,"package.json");try{let p=await e.readFile(u);if(p===null)throw new Error(`Failed to read package.json at ${u}`);let m=JSON.parse(p);if(n.has(m.name))return null;n.add(m.name);let f={name:m.name,subPackages:[]},c=await e.readdir(s);for(let d of c)d!=="node_modules"&&(await e.stat(e.join(s,d))).isDirectory()&&f.subPackages.push(d);return r.push(f),f}catch(p){return console.error(`Error reading package.json at ${s}:`,p),null}}let i=e.join(t,"package.json"),a=await e.readFile(i);if(a!==null){let s=JSON.parse(a),u={...s.dependencies,...s.devDependencies};for(let p of Object.keys(u)){let m=e.join(t,"node_modules",p);await o(m)}if(s.workspaces)for(let p of s.workspaces){let m=await e.readdir(e.join(t,p));for(let f of m){let c=e.join(t,p,f);await o(c)}}}return r}var Cu={"@builder.io/qwik-city":zr,next:Br,"@remix-run/react":Xr,react:so,"@angular/core":yo},xu={"@builder.io/qwik-city":de.qwik,next:de.next,"@remix-run/react":de.remix,react:de.react,"@angular/core":de.angular};async function Mo(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 Le(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getAppRootDir()}`);for(let t of e.frameworks){let r=Cu[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>Vo(e,n),importRegistry:i=>$o(e,n,i),framework:xu[t.name],findAllDependencies:async()=>await Ko(e,e.getRepoRootDir())}}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function Uo(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 d="",C=0,l=-1,D=0,g;for(let x=0;x<=f.length;++x){if(x<f.length)g=f.charCodeAt(x);else{if(g===47)break;g=47}if(g===47){if(!(l===x-1||D===1))if(l!==x-1&&D===2){if(d.length<2||C!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let S=d.lastIndexOf("/");if(S!==d.length-1){S===-1?(d="",C=0):(d=d.slice(0,S),C=d.length-1-d.lastIndexOf("/")),l=x,D=0;continue}}else if(d.length===2||d.length===1){d="",C=0,l=x,D=0;continue}}c&&(d.length>0?d+="/..":d="..",C=2)}else d.length>0?d+="/"+f.slice(l+1,x):d=f.slice(l+1,x),C=x-l-1;l=x,D=0}else g===46&&D!==-1?++D:D=-1}return d}let n=function(...c){let d="",C=!1;for(let l=c.length-1;l>=-1&&!C;l--){let D;l>=0?D=c[l]:e.cwd?D=e.cwd():D="/",t(D),D.length!==0&&(d=D+"/"+d,C=D.charCodeAt(0)===47)}return d=r(d,!C),C?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,C=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&C&&(c+="/"),d?"/"+c:c};return{relative:function(c,d){if(t(c),t(d),c===d||(c=n(c),d=n(d),c===d))return"";let C=1;for(;C<c.length&&c.charCodeAt(C)===47;++C);let l=c.length,D=l-C,g=1;for(;g<d.length&&d.charCodeAt(g)===47;++g);let S=d.length-g,P=D<S?D:S,A=-1,E=0;for(;E<=P;++E){if(E===P){if(S>P){if(d.charCodeAt(g+E)===47)return d.slice(g+E+1);if(E===0)return d.slice(g+E)}else D>P&&(c.charCodeAt(C+E)===47?A=E:E===0&&(A=0));break}let z=c.charCodeAt(C+E),j=d.charCodeAt(g+E);if(z!==j)break;z===47&&(A=E)}let O="";for(E=C+A+1;E<=l;++E)(E===l||c.charCodeAt(E)===47)&&(O.length===0?O+="..":O+="/..");return O.length>0?O+d.slice(g+A):(g+=A,d.charCodeAt(g)===47&&++g,d.slice(g))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let C=0;C<c.length;++C){let l=c[C];t(l),l.length>0&&(d===void 0?d=l:d+="/"+l)}return d===void 0?".":o(d)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,d){if(d!==void 0&&typeof d!="string")throw new TypeError('"ext" argument must be a string');t(c);let C=0,l=-1,D=!0,g;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let x=d.length-1,S=-1;for(g=c.length-1;g>=0;--g){let P=c.charCodeAt(g);if(P===47){if(!D){C=g+1;break}}else S===-1&&(D=!1,S=g+1),x>=0&&(P===d.charCodeAt(x)?--x===-1&&(l=g):(x=-1,l=S))}return C===l?l=S:l===-1&&(l=c.length),c.slice(C,l)}else{for(g=c.length-1;g>=0;--g)if(c.charCodeAt(g)===47){if(!D){C=g+1;break}}else l===-1&&(D=!1,l=g+1);return l===-1?"":c.slice(C,l)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),C=d===47,l=-1,D=!0;for(let g=c.length-1;g>=1;--g)if(d=c.charCodeAt(g),d===47){if(!D){l=g;break}}else D=!1;return l===-1?C?"/":".":C&&l===1?"//":c.slice(0,l)},extname:function(c){t(c);let d=-1,C=0,l=-1,D=!0,g=0;for(let x=c.length-1;x>=0;--x){let S=c.charCodeAt(x);if(S===47){if(!D){C=x+1;break}continue}l===-1&&(D=!1,l=x+1),S===46?d===-1?d=x:g!==1&&(g=1):d!==-1&&(g=-1)}return d===-1||l===-1||g===0||g===1&&d===l-1&&d===C+1?"":c.slice(d,l)}}}async function zo(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=Uo({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[D]of o)if((D+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let D=l===t()?l:l+"/",g=D.split("/").length-1,x=[];for(let[S]of o)if(S.split("/").slice(0,g).join("/")+"/"===D){let E=S.split("/")[g];E&&!x.includes(E)&&x.push(E)}return x.sort()},p=l=>{l=i(l);let D=o.get(l);return typeof D=="string"?D:null},m=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l)}),f=async l=>{if(typeof crypto<"u"){let x=new TextEncoder().encode(l),S=await crypto.subtle.digest("SHA-256",x);return Array.from(new Uint8Array(S)).map(P=>P.toString(16).padStart(2,"0")).join("")}let D=0;for(let g=0;g<l.length;g++){let x=l.charCodeAt(g);D=(D<<5)-D+x,D|=0}return Number(Math.abs(D)).toString(36)},c=new Set,d={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readFile:async l=>p(l),readFileSync:p,stat:async l=>m(l),statSync:m,writeFile:async(l,D)=>{l=i(l),o.set(l,D);let g={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let x of c)await x(g)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",getRepoInfo:async()=>({remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,D)=>D,on:(l,D)=>{l==="change"&&c.add(D)},off:(l,D)=>{l==="change"&&c.delete(D)},debug:(...l)=>{console.debug("[builder-dev-tools]",...l)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,kind:null,magicast:void 0,spawnSync:void 0},C=await Le(d);return d.getFrameworks=e.getFrameworks?e.getFrameworks:()=>C,d}async function qo(e,t,r){let n=I(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(Jo(e,n))return o;let a=ue(e,n,"cjs"),s=ue(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let m=s[0];if(!m.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=m.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Unexpected export type in ${t}
|
|
917
917
|
Found config content:
|
|
918
918
|
${r}
|
|
919
919
|
|
|
@@ -974,4 +974,4 @@ module.exports = nextConfig
|
|
|
974
974
|
`,n+=` }
|
|
975
975
|
`,n+=` }
|
|
976
976
|
`,n+=`})();
|
|
977
|
-
`,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var bt="1.1.
|
|
977
|
+
`,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var bt="1.1.41";
|
package/core/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ni=Object.create;var Kn=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ii=Object.getPrototypeOf,ai=Object.prototype.hasOwnProperty;var ve=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var si=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oi(t))!ai.call(e,o)&&o!==r&&Kn(e,o,{get:()=>t[o],enumerable:!(n=ri(t,o))||n.enumerable});return e};var Mn=(e,t,r)=>(r=e!=null?ni(ii(e)):{},si(t||!e||!e.__esModule?Kn(r,"default",{value:e,enumerable:!0}):r,e));var qn=ve((vu,zn)=>{"use strict";zn.exports=function(){if(process.env.npm_config_user_agent)return pi(process.env.npm_config_user_agent)};function pi(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var yn=ve(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});function Po(e){return Object.prototype.toString.call(e)}zt.getType=Po;function Ms(e){throw new TypeError("unsupported data type: "+Po(e))}zt.throwUnknownDataType=Ms});var In=ve(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});var Be="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Be+=t}var st=Be.length,Tn={};for(let e=0;e<st;e++){let t=Be[e];Tn[t]=e}function bn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=Tn[o];i*=r,t+=i,r*=st}return t}Oe.s_to_int=bn;function yo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(st);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(Tn[i]);a*=r,t+=a,r*=n}return t}Oe.s_to_big_int=yo;function vn(e){if(e===0)return Be[0];let t=[];for(;e!==0;){let r=e%st,n=Be[r];t.push(n),e-=r,e/=st}return t.reverse().join("")}Oe.int_to_s=vn;function wo(e){let t=BigInt(0),r=BigInt(st);if(e===t)return Be[0];let n=[];for(;e!==t;){let o=e%r,i=Be[Number(o)];n.push(i),e-=o,e/=r}return n.reverse().join("")}Oe.big_int_to_s=wo;function Jt(e){return e.split("").reverse().join("")}function To(e){if(e<0)return"-"+To(-e);let[t,r]=e.toString().split(".");if(!r)return vn(e);let n;r&&([r,n]=r.split("e")),t=qt(t),r=Jt(r),r=qt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Jt(n),n=qt(n),o+=n}return o}Oe.num_to_s=To;function qt(e){let t=+e;return t.toString()===e?vn(t):":"+wo(BigInt(e))}Oe.int_str_to_s=qt;function wn(e){return e[0]===":"?yo(e.substring(1)).toString():bn(e).toString()}function bo(e){if(e[0]==="-")return-bo(e.substr(1));let[t,r,n]=e.split(".");if(!r)return bn(t);t=wn(t),r=wn(r),r=Jt(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=wn(n),n=Jt(n),o+=i?-n:+n}return+o}Oe.s_to_num=bo});var Nn=ve(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var Rn=In();function Us(e){return"n|"+Rn.num_to_s(e)}ke.encodeNum=Us;function zs(e){return e=e.replace("n|",""),Rn.s_to_num(e)}ke.decodeNum=zs;function qs(e){return typeof e=="number"?e:Rn.s_to_int(e)}ke.decodeKey=qs;function Js(e){return e?"b|T":"b|F"}ke.encodeBool=Js;function Qs(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}ke.decodeBool=Qs;function Ws(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}ke.encodeStr=Ws;function Ys(e){return e[0]+e[1]==="s|"?e.substr(2):e}ke.decodeStr=Ys});var vo=ve(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.config={sort_key:!1}});var kn=ve(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});var Gs=vo(),Hs=yn(),On=Nn(),Xs=In();function Zs(e){return e.store.toArray()}He.memToValues=Zs;function Io(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}He.makeInMemoryStore=Io;function Ro(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}He.makeInMemoryCache=Ro;function eu(){return{store:Io(),cache:Ro(),keyCount:0}}He.makeInMemoryMemory=eu;function Ge(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=Xs.num_to_s(r);return e.store.add(t),e.cache.setValue(t,n),n}function tu(e,t){Gs.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=yt(e,t,void 0);return e.cache.setSchema(r,n),n}function yt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return yt(e,null,r);break;case"object":if(t===null)return Ge(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":yt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),Ge(e,n)}else{let n=Object.keys(t);if(n.length===0)return Ge(e,"o|");let o="o",i=tu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=yt(e,s,t);o+="|"+u}return Ge(e,o)}case"boolean":return Ge(e,On.encodeBool(t));case"number":return Ge(e,On.encodeNum(t));case"string":return Ge(e,On.encodeStr(t))}return Hs.throwUnknownDataType(t)}He.addValue=yt});var _n=ve(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});var nu=yn(),Qt=Nn(),Ln=kn();function ru(e){let t=Ln.makeInMemoryMemory(),r=Ln.addValue(t,e,void 0);return[Ln.memToValues(t),r]}Tt.compress=ru;function ou(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=wt(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=wt(e,p),r[u]=p}return r}function iu(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=wt(e,a),o[i]=a}return o}function wt(e,t){if(t===""||t==="_")return null;let r=Qt.decodeKey(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return Qt.decodeBool(n);case"o|":return ou(e,n);case"n|":return Qt.decodeNum(n);case"a|":return iu(e,n);default:return Qt.decodeStr(n)}}return nu.throwUnknownDataType(n)}Tt.decode=wt;function au(e){let[t,r]=e;return wt(t,r)}Tt.decompress=au});var Bo=ve(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});function su(e){for(let t in e)e[t]===void 0&&delete e[t]}Wt.trimUndefined=su;function uu(e){No(e,new Set)}Wt.trimUndefinedRecursively=uu;function No(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&No(n,t)}}});var Lo=ve(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});var Oo=_n();Me.compress=Oo.compress;Me.decompress=Oo.decompress;var pu=_n();Me.decode=pu.decode;var lu=kn();Me.addValue=lu.addValue;var ko=Bo();Me.trimUndefined=ko.trimUndefined;Me.trimUndefinedRecursively=ko.trimUndefinedRecursively});function re(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var ui=["node_modules","dist","build","public"];async function ae(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(ui.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("builder-registry."))return u;if(p.isDirectory()){let m=await r(u,i+1);if(m)return m}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await re(e)?"ts":"js"}`;return e.join(t,i)}return n}async function bt(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function Un(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function ut(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await ut(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var Qn=Mn(qn(),1);function B(e,t,r){t=ce(t),r=ce(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=ce(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function ce(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function ze(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return Jn(o==="index"?e.basename(e.dirname(t)):o)}function Jn(e){return K(e).replace(/ /g,"")}function se(e,t){let r=e.extname(t),n=ce(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function V(e,t){let r=ce(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function k(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function te(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function $(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function pt(e){return typeof e=="number"}function Xe(e){return typeof e=="boolean"}function Z(e){return typeof e=="string"}function Ze(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function oe(e){return JSON.parse(JSON.stringify(e))}function vt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function Wn(){try{let e=(0,Qn.default)();if(e?.name)return e.name}catch{}return"npm"}async function qe(e){let t=[],r=await bt(e,e.getRepoRootDir());if(r){let n=await Gn(r,e);t.push(...n)}return t}async function Gn(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of li)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};Yn.has(o)&&(i.version=await Yn.get(o)(t)),r.push(i)}}return r}function Ht(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var Yn=new Map([["next",async e=>{if(!e.spawn)return;let t=Wn(),r=t==="npm"?"npx":t,{stdout:n}=e.spawn.sync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:Ht(a),minor:Ht(s),patch:Ht(u)}}]]),li=["@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 ge(e){let t=Hn(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function De(e,t){t=typeof t=="object"&&t!=null?t:{};let r=Hn(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function Hn(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function Le(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await ci(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function ci(e,t){let r=await e.readFile(t);return typeof r=="string"?Xn(r):null}function Xn(e){let t={},r=e.replace(/\r\n?/gm,`
|
|
1
|
+
var ni=Object.create;var Kn=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var oi=Object.getOwnPropertyNames;var ii=Object.getPrototypeOf,ai=Object.prototype.hasOwnProperty;var ve=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var si=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oi(t))!ai.call(e,o)&&o!==r&&Kn(e,o,{get:()=>t[o],enumerable:!(n=ri(t,o))||n.enumerable});return e};var Mn=(e,t,r)=>(r=e!=null?ni(ii(e)):{},si(t||!e||!e.__esModule?Kn(r,"default",{value:e,enumerable:!0}):r,e));var qn=ve((vu,zn)=>{"use strict";zn.exports=function(){if(process.env.npm_config_user_agent)return pi(process.env.npm_config_user_agent)};function pi(e){let t=e.split(" ")[0],r=t.lastIndexOf("/"),n=t.substring(0,r);return{name:n==="npminstall"?"cnpm":n,version:t.substring(r+1)}}});var yn=ve(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});function Po(e){return Object.prototype.toString.call(e)}zt.getType=Po;function Ms(e){throw new TypeError("unsupported data type: "+Po(e))}zt.throwUnknownDataType=Ms});var In=ve(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});var Be="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Be+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Be+=t}var st=Be.length,Tn={};for(let e=0;e<st;e++){let t=Be[e];Tn[t]=e}function bn(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=Tn[o];i*=r,t+=i,r*=st}return t}Oe.s_to_int=bn;function yo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(st);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(Tn[i]);a*=r,t+=a,r*=n}return t}Oe.s_to_big_int=yo;function vn(e){if(e===0)return Be[0];let t=[];for(;e!==0;){let r=e%st,n=Be[r];t.push(n),e-=r,e/=st}return t.reverse().join("")}Oe.int_to_s=vn;function wo(e){let t=BigInt(0),r=BigInt(st);if(e===t)return Be[0];let n=[];for(;e!==t;){let o=e%r,i=Be[Number(o)];n.push(i),e-=o,e/=r}return n.reverse().join("")}Oe.big_int_to_s=wo;function Jt(e){return e.split("").reverse().join("")}function To(e){if(e<0)return"-"+To(-e);let[t,r]=e.toString().split(".");if(!r)return vn(e);let n;r&&([r,n]=r.split("e")),t=qt(t),r=Jt(r),r=qt(r);let o=t+"."+r;if(n){switch(o+=".",n[0]){case"+":n=n.slice(1);break;case"-":o+="-",n=n.slice(1);break}n=Jt(n),n=qt(n),o+=n}return o}Oe.num_to_s=To;function qt(e){let t=+e;return t.toString()===e?vn(t):":"+wo(BigInt(e))}Oe.int_str_to_s=qt;function wn(e){return e[0]===":"?yo(e.substring(1)).toString():bn(e).toString()}function bo(e){if(e[0]==="-")return-bo(e.substr(1));let[t,r,n]=e.split(".");if(!r)return bn(t);t=wn(t),r=wn(r),r=Jt(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=wn(n),n=Jt(n),o+=i?-n:+n}return+o}Oe.s_to_num=bo});var Nn=ve(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});var Rn=In();function Us(e){return"n|"+Rn.num_to_s(e)}ke.encodeNum=Us;function zs(e){return e=e.replace("n|",""),Rn.s_to_num(e)}ke.decodeNum=zs;function qs(e){return typeof e=="number"?e:Rn.s_to_int(e)}ke.decodeKey=qs;function Js(e){return e?"b|T":"b|F"}ke.encodeBool=Js;function Qs(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}ke.decodeBool=Qs;function Ws(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}ke.encodeStr=Ws;function Ys(e){return e[0]+e[1]==="s|"?e.substr(2):e}ke.decodeStr=Ys});var vo=ve(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.config={sort_key:!1}});var kn=ve(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});var Gs=vo(),Hs=yn(),On=Nn(),Xs=In();function Zs(e){return e.store.toArray()}He.memToValues=Zs;function Io(){let e=[];return{forEach(t){for(let r=0;r<e.length;r++)if(t(e[r])==="break")return},add(t){e.push(t)},toArray(){return e}}}He.makeInMemoryStore=Io;function Ro(){let e=Object.create(null),t=Object.create(null);return{getValue(r){return e[r]},getSchema(r){return t[r]},forEachValue(r){for(let[n,o]of Object.entries(e))if(r(n,o)==="break")return},forEachSchema(r){for(let[n,o]of Object.entries(t))if(r(n,o)==="break")return},setValue(r,n){e[r]=n},setSchema(r,n){t[r]=n},hasValue(r){return r in e},hasSchema(r){return r in t}}}He.makeInMemoryCache=Ro;function eu(){return{store:Io(),cache:Ro(),keyCount:0}}He.makeInMemoryMemory=eu;function Ge(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=Xs.num_to_s(r);return e.store.add(t),e.cache.setValue(t,n),n}function tu(e,t){Gs.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=yt(e,t,void 0);return e.cache.setSchema(r,n),n}function yt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return yt(e,null,r);break;case"object":if(t===null)return Ge(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":yt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),Ge(e,n)}else{let n=Object.keys(t);if(n.length===0)return Ge(e,"o|");let o="o",i=tu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=yt(e,s,t);o+="|"+u}return Ge(e,o)}case"boolean":return Ge(e,On.encodeBool(t));case"number":return Ge(e,On.encodeNum(t));case"string":return Ge(e,On.encodeStr(t))}return Hs.throwUnknownDataType(t)}He.addValue=yt});var _n=ve(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});var nu=yn(),Qt=Nn(),Ln=kn();function ru(e){let t=Ln.makeInMemoryMemory(),r=Ln.addValue(t,e,void 0);return[Ln.memToValues(t),r]}Tt.compress=ru;function ou(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=wt(e,o),a=n.length;a-2===1&&!Array.isArray(i)&&(i=[i]);for(let s=2;s<a;s++){let u=i[s-2],p=n[s];p=wt(e,p),r[u]=p}return r}function iu(e,t){if(t==="a|")return[];let r=t.split("|"),n=r.length-1,o=new Array(n);for(let i=0;i<n;i++){let a=r[i+1];a=wt(e,a),o[i]=a}return o}function wt(e,t){if(t===""||t==="_")return null;let r=Qt.decodeKey(t),n=e[r];if(n===null)return n;switch(typeof n){case"undefined":return n;case"number":return n;case"string":switch(n[0]+n[1]){case"b|":return Qt.decodeBool(n);case"o|":return ou(e,n);case"n|":return Qt.decodeNum(n);case"a|":return iu(e,n);default:return Qt.decodeStr(n)}}return nu.throwUnknownDataType(n)}Tt.decode=wt;function au(e){let[t,r]=e;return wt(t,r)}Tt.decompress=au});var Bo=ve(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});function su(e){for(let t in e)e[t]===void 0&&delete e[t]}Wt.trimUndefined=su;function uu(e){No(e,new Set)}Wt.trimUndefinedRecursively=uu;function No(e,t){t.add(e);for(let r in e)if(e[r]===void 0)delete e[r];else{let n=e[r];n&&typeof n=="object"&&!t.has(n)&&No(n,t)}}});var Lo=ve(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});var Oo=_n();Me.compress=Oo.compress;Me.decompress=Oo.decompress;var pu=_n();Me.decode=pu.decode;var lu=kn();Me.addValue=lu.addValue;var ko=Bo();Me.trimUndefined=ko.trimUndefined;Me.trimUndefinedRecursively=ko.trimUndefinedRecursively});function re(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var ui=["node_modules","dist","build","public"];async function ae(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(ui.includes(s))continue;let u=e.join(o,s),p=await e.stat(u);if(p){if(p.isFile()&&s.startsWith("builder-registry."))return u;if(p.isDirectory()){let m=await r(u,i+1);if(m)return m}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await re(e)?"ts":"js"}`;return e.join(t,i)}return n}async function bt(e,t){let r=e.resolve("/");for(let n=0;n<20;n++){let o=e.join(t,"package.json"),i=await e.readFile(o);if(i)return JSON.parse(i);if(t===r)break;t=e.dirname(t)}return null}async function Un(e,t){for(let r=0;r<20;r++){let n=e.dirname(t),o=e.join(n,"node_modules");if(await e.exists(o))return o;if(t===e.getAppRootDir())break;t=e.dirname(t)}return e.join(e.getAppRootDir(),"node_modules")}async function ut(e,t,r){let n=await e.readdir(t);return n.includes(r)?e.join(t,r):(await Promise.all(n.map(async i=>{if(i.startsWith(".")||i==="node_modules")return;let a=e.join(t,i);if((await e.stat(a)).isDirectory()){let u=await ut(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var Qn=Mn(qn(),1);function B(e,t,r){t=ce(t),r=ce(r),t=e.dirname(t);let n=e.basename(r,e.extname(r));r=e.dirname(r);let o;return n==="index"?o=e.relative(t,r):o=e.relative(t,e.join(r,n)),o=ce(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function ce(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}function ze(e,t){let r=e.extname(t),n=e.basename(t,r).split(/[\/\\]/),o=n[n.length-1];return Jn(o==="index"?e.basename(e.dirname(t)):o)}function Jn(e){return K(e).replace(/ /g,"")}function se(e,t){let r=e.extname(t),n=ce(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function V(e,t){let r=ce(e.relative(e.getAppRootDir(),t));r=r.split("/").filter(o=>o!=="."&&o!==".."&&o!=="").join("/"),r.endsWith(".tsx")||r.endsWith(".jsx")?r=r.slice(0,-4):(r.endsWith(".ts")||r.endsWith(".js"))&&(r=r.slice(0,-3));let n=e.getFrameworks();return r.startsWith("src/")&&(r=r.slice(4)),n.some(o=>o.name.includes("next"))?"@/"+r:"~/"+r}function k(e,t){let r=t,n=[];for(let o=0;o<2;o++){let i=e.basename(r);if(!i||i==="components")break;n.unshift(i),r=e.dirname(r)}return n.join("/")}function K(e){for(e=e.replace(/([A-Z])/g," $1").replace(/\./g," ").replace(/_/g," ").replace(/-/g," ").replace(/\s/g," ").trim();e.includes(" ");)e=e.replace(/ /g," ");return e.split(" ").map(t=>t.length>2?t[0].toUpperCase()+t.slice(1):t).join("").trim()}function te(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function $(e,t,r,n){if(typeof r!="string"||r==="")throw new Error(`getComponentId(), exportName must be a non-empty string, received: ${r}, ${t}`);return n&&(t=n),t=e.normalize(t),(await e.hash(t+"#"+r)).substring(0,8)}function pt(e){return typeof e=="number"}function Xe(e){return typeof e=="boolean"}function Z(e){return typeof e=="string"}function Ze(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function oe(e){return JSON.parse(JSON.stringify(e))}function vt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function Wn(){try{let e=(0,Qn.default)();if(e?.name)return e.name}catch{}return"npm"}async function qe(e){let t=[],r=await bt(e,e.getRepoRootDir());if(r){let n=await Gn(r,e);t.push(...n)}return t}async function Gn(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of li)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};Yn.has(o)&&(i.version=await Yn.get(o)(t)),r.push(i)}}return r}function Ht(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var Yn=new Map([["next",async e=>{if(!e.spawnSync)return;let t=Wn(),r=t==="npm"?"npx":t,{stdout:n}=e.spawnSync(r,["next","-v"],{encoding:"utf8"});if(!n)return;let o=n.match(/(Next.js v)([\d.]+)/g);if(!o)return;let i=o[0].split("Next.js v")[1],[a,s,u]=i.split(".");return{major:Ht(a),minor:Ht(s),patch:Ht(u)}}]]),li=["@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 ge(e){let t=Hn(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function De(e,t){t=typeof t=="object"&&t!=null?t:{};let r=Hn(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function Hn(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function Le(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await ci(e,i);if(a){let s=a[r];if(typeof s=="string"&&s.length>0&&s!=="YOUR_API_KEY")return n.envValue=s,n.file=i,n}}return n.file=e.join(e.getAppRootDir(),t[t.length-1]),n}async function ci(e,t){let r=await e.readFile(t);return typeof r=="string"?Xn(r):null}function Xn(e){let t={},r=e.replace(/\r\n?/gm,`
|
|
2
2
|
`),n;for(;(n=mi.exec(r))!=null;){let o=n[1],i=n[2]||"";i=i.trim();let a=i[0];i=i.replace(/^(['"`])([\s\S]*)\1$/gm,"$2"),a==='"'&&(i=i.replace(/\\n/g,`
|
|
3
3
|
`),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var mi=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;async function _e(e,t,r,n){let o="# https://www.builder.io/c/docs/using-your-api-key",i=await e.readFile(t);if(i)if(i.includes(r))if(i.includes(n))e.debug(`"${r}" with "${n}" already set in ${t}`);else return e.debug(`Replace "${r}" in ${t}`),i=i.replace(new RegExp(`${r}=.*`),`${r}=${n}`),await e.writeFile(t,i),"update";else return e.debug(`Append "${r}" to ${t}`),i+=`
|
|
4
4
|
|
|
@@ -913,7 +913,7 @@ export class Counter {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
-
`.trimStart()}async function So(e){await Ut(e);let t=await e.readFile(e.registryPath);return t?Ls(e,t):{components:[],sourceFile:I(e,"")}}async function Ls(e,t){let r=I(e,t);return _s(e,r)}async function _s(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Pn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:te(r)}}async function Pn(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(N(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let p=s.arguments[0];e.ts.isIdentifier(p)&&(a=p.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await xe(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=V(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await uo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let m=p.find(f=>f.cmpInfo.exportName===a);m&&(n.exportName=m.cmpInfo.exportName)}}continue}}return n=ne(e,n,r),n.filePath&&n.exportName&&(n.id=await $(e,n.filePath,n.exportName,n.externalImportPath)),n}async function be(e,t,r,n,o,i,a,s){let u=await $e(e),[p,m,f]=await Promise.all([so(e,u),So(e),At(e)]),c=p.map(x=>x.cmpInfo),d=m.components,C={components:me(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:he(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return C.components=await po(e,p,C.components),C;let l=!1,D=m.sourceFile,g=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(g.length>0){let x=g.map(A=>{let E=p.find(O=>O.cmpInfo.id===A);if(!E)throw new Error(`Component ${A} not found`);return E}),S=Array.from(new Set(x.map(A=>A.cmpInfo.filePath))),P=await G(e,S);for(let A of x){let E=C.components.find(L=>L.id===A.cmpInfo.id),O=await Dn(e,A,P);ie(E,O);let z=c.findIndex(L=>L.id===A.cmpInfo.id);c[z].inputs=O;let j=Fe(A.cmpInfo.id,c,d,r,n,o,i),{elements:F,elmIndex:y,statementIndex:H,statement:le,variableDeclaration:Y}=await Vs(e,D,A);if(j.addCmpToRegistry)F.push(js(e,j.addCmpToRegistry)),l=!0;else if(j.removeCmpFromRegistry)F.splice(y,1),l=!0;else if(j.updateRegisteredCmp){let L=Q(e,F[y],j.updateRegisteredCmp);F[y]=e.ts.factory.updateObjectLiteralExpression(L,[Ao(e,j.updateRegisteredCmp),...L.properties.slice(1)]),l=!0}if(l&&a){let L=[...D.statements];L[H]=e.ts.factory.updateVariableStatement(le,le.modifiers,e.ts.factory.updateVariableDeclarationList(le.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Se(e,F)))])),D=e.ts.factory.updateSourceFile(D,L),E.exportType==="named"?D=v(e,D,{namedImports:[E.importName],importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}):D=v(e,D,{defaultImport:E.importName,importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}),D=v(e,D,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),D=Pe(e,D,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),C.components=j.components,d=j.components.filter(X=>X.isRegistered)}}}if(l&&a){D=Ae(e,D),D=Ee(e,D);let x=_(e,D);x=pe(x),x=await e.formatCode(e.registryPath,x),await e.writeFile(e.registryPath,x)}return C}function Ao(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function js(e,t){return Q(e,e.ts.factory.createObjectLiteralExpression([Ao(e,t)],!0),t)}async function Vs(e,t,r){let n=J(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 Pn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function Fo(e){let t=await $s(e),r={};return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>xo(t),ensureFigmaImportPage:()=>ho(t),getRegistryPath:()=>t.registryPath,getRegistry:o=>be(t,null,!1,!1,null,null,!1,!!o?.readAllInputTypes),addExternalPackage:async o=>{r[o]||(r[o]=`export * from "${o}";`)},loadComponent:async o=>{let i=await be(t,o.cmpId,!1,!1,null,null,!1,!1);return{...i,component:i.components.find(a=>a.id===o.cmpId)}},registerComponent:o=>be(t,o.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:o=>be(t,o.cmpId,!1,!1,o,null,!0,!1),setRegisteredComponentInput:o=>be(t,o.cmpId,!1,!1,null,o,!0,!1),unregisterComponent:o=>be(t,o.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>At(t),setPublicApiKey:o=>ao(t,o.publicApiKey),getDependencies:o=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ge(t),setCache:o=>De(t,o)}}async function $s(e){let t=await Ks(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await re(e),i=e.join(n,"app"),a=await ae(e,i),s={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);s.srcDir=n,s.appDir=i,s.componentsDir=e.join(s.appDir,"components"),s.builderPageComponentPath=e.join(s.componentsDir,`builder-page.component.${o?"ts":"js"}`);let u=`app.module.${o?"ts":"js"}`,p=e.join(s.appDir,u);return await e.exists(p)&&(s.hasAppModule=!0),s}async function Ks(e){let t=e.join(e.getAppRootDir(),"angular.json");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"project.json");if(await e.exists(r))return r;throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}var Yt=Mn(Lo(),1);async function _o(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:ce(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:oe(i.inputs)};return oe(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,Yt.compress)(n);return btoa(JSON.stringify(o))}async function jo(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=oe(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=ce(e.normalize(s.filePath)),p=n.components.find(f=>ce(f.filePath).endsWith(u)&&f.exportName===s.exportName);if(!p){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${p.id})`,p.filePath),await t.registerComponent({cmpId:p.id});for(let f of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${p.id}) info`);let m=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=oe(m)}return a}var de={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},id={[de.react]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.remix]:[{version:w.gen1,recommended:!1},{version:w.gen2,recommended:!0}],[de.angular]:[{version:w.gen2,recommended:!0}],[de.next]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.qwik]:[{version:w.gen2,recommended:!0}]};async function Vo(e,t){let r=[],n=new Set;async function o(s){let u=e.join(s,"package.json");try{let p=await e.readFile(u);if(p===null)throw new Error(`Failed to read package.json at ${u}`);let m=JSON.parse(p);if(n.has(m.name))return null;n.add(m.name);let f={name:m.name,subPackages:[]},c=await e.readdir(s);for(let d of c)d!=="node_modules"&&(await e.stat(e.join(s,d))).isDirectory()&&f.subPackages.push(d);return r.push(f),f}catch(p){return console.error(`Error reading package.json at ${s}:`,p),null}}let i=e.join(t,"package.json"),a=await e.readFile(i);if(a!==null){let s=JSON.parse(a),u={...s.dependencies,...s.devDependencies};for(let p of Object.keys(u)){let m=e.join(t,"node_modules",p);await o(m)}if(s.workspaces)for(let p of s.workspaces){let m=await e.readdir(e.join(t,p));for(let f of m){let c=e.join(t,p,f);await o(c)}}}return r}var cu={"@builder.io/qwik-city":Mr,next:Rr,"@remix-run/react":Gr,react:io,"@angular/core":Fo},mu={"@builder.io/qwik-city":de.qwik,next:de.next,"@remix-run/react":de.remix,react:de.react,"@angular/core":de.angular};async function fu(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 qe(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getAppRootDir()}`);for(let t of e.frameworks){let r=cu[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>_o(e,n),importRegistry:i=>jo(e,n,i),framework:mu[t.name],findAllDependencies:async()=>await Vo(e,e.getRepoRootDir())}}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function $o(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 d="",C=0,l=-1,D=0,g;for(let x=0;x<=f.length;++x){if(x<f.length)g=f.charCodeAt(x);else{if(g===47)break;g=47}if(g===47){if(!(l===x-1||D===1))if(l!==x-1&&D===2){if(d.length<2||C!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let S=d.lastIndexOf("/");if(S!==d.length-1){S===-1?(d="",C=0):(d=d.slice(0,S),C=d.length-1-d.lastIndexOf("/")),l=x,D=0;continue}}else if(d.length===2||d.length===1){d="",C=0,l=x,D=0;continue}}c&&(d.length>0?d+="/..":d="..",C=2)}else d.length>0?d+="/"+f.slice(l+1,x):d=f.slice(l+1,x),C=x-l-1;l=x,D=0}else g===46&&D!==-1?++D:D=-1}return d}let n=function(...c){let d="",C=!1;for(let l=c.length-1;l>=-1&&!C;l--){let D;l>=0?D=c[l]:e.cwd?D=e.cwd():D="/",t(D),D.length!==0&&(d=D+"/"+d,C=D.charCodeAt(0)===47)}return d=r(d,!C),C?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,C=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&C&&(c+="/"),d?"/"+c:c};return{relative:function(c,d){if(t(c),t(d),c===d||(c=n(c),d=n(d),c===d))return"";let C=1;for(;C<c.length&&c.charCodeAt(C)===47;++C);let l=c.length,D=l-C,g=1;for(;g<d.length&&d.charCodeAt(g)===47;++g);let S=d.length-g,P=D<S?D:S,A=-1,E=0;for(;E<=P;++E){if(E===P){if(S>P){if(d.charCodeAt(g+E)===47)return d.slice(g+E+1);if(E===0)return d.slice(g+E)}else D>P&&(c.charCodeAt(C+E)===47?A=E:E===0&&(A=0));break}let z=c.charCodeAt(C+E),j=d.charCodeAt(g+E);if(z!==j)break;z===47&&(A=E)}let O="";for(E=C+A+1;E<=l;++E)(E===l||c.charCodeAt(E)===47)&&(O.length===0?O+="..":O+="/..");return O.length>0?O+d.slice(g+A):(g+=A,d.charCodeAt(g)===47&&++g,d.slice(g))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let C=0;C<c.length;++C){let l=c[C];t(l),l.length>0&&(d===void 0?d=l:d+="/"+l)}return d===void 0?".":o(d)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,d){if(d!==void 0&&typeof d!="string")throw new TypeError('"ext" argument must be a string');t(c);let C=0,l=-1,D=!0,g;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let x=d.length-1,S=-1;for(g=c.length-1;g>=0;--g){let P=c.charCodeAt(g);if(P===47){if(!D){C=g+1;break}}else S===-1&&(D=!1,S=g+1),x>=0&&(P===d.charCodeAt(x)?--x===-1&&(l=g):(x=-1,l=S))}return C===l?l=S:l===-1&&(l=c.length),c.slice(C,l)}else{for(g=c.length-1;g>=0;--g)if(c.charCodeAt(g)===47){if(!D){C=g+1;break}}else l===-1&&(D=!1,l=g+1);return l===-1?"":c.slice(C,l)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),C=d===47,l=-1,D=!0;for(let g=c.length-1;g>=1;--g)if(d=c.charCodeAt(g),d===47){if(!D){l=g;break}}else D=!1;return l===-1?C?"/":".":C&&l===1?"//":c.slice(0,l)},extname:function(c){t(c);let d=-1,C=0,l=-1,D=!0,g=0;for(let x=c.length-1;x>=0;--x){let S=c.charCodeAt(x);if(S===47){if(!D){C=x+1;break}continue}l===-1&&(D=!1,l=x+1),S===46?d===-1?d=x:g!==1&&(g=1):d!==-1&&(g=-1)}return d===-1||l===-1||g===0||g===1&&d===l-1&&d===C+1?"":c.slice(d,l)}}}async function du(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=$o({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[D]of o)if((D+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let D=l===t()?l:l+"/",g=D.split("/").length-1,x=[];for(let[S]of o)if(S.split("/").slice(0,g).join("/")+"/"===D){let E=S.split("/")[g];E&&!x.includes(E)&&x.push(E)}return x.sort()},p=l=>{l=i(l);let D=o.get(l);return typeof D=="string"?D:null},m=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l)}),f=async l=>{if(typeof crypto<"u"){let x=new TextEncoder().encode(l),S=await crypto.subtle.digest("SHA-256",x);return Array.from(new Uint8Array(S)).map(P=>P.toString(16).padStart(2,"0")).join("")}let D=0;for(let g=0;g<l.length;g++){let x=l.charCodeAt(g);D=(D<<5)-D+x,D|=0}return Number(Math.abs(D)).toString(36)},c=new Set,d={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readFile:async l=>p(l),readFileSync:p,stat:async l=>m(l),statSync:m,writeFile:async(l,D)=>{l=i(l),o.set(l,D);let g={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let x of c)await x(g)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",getRepoInfo:async()=>({remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,D)=>D,on:(l,D)=>{l==="change"&&c.add(D)},off:(l,D)=>{l==="change"&&c.delete(D)},debug:(...l)=>{console.debug("[builder-dev-tools]",...l)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,kind:null,magicast:void 0,spawn:void 0},C=await qe(d);return d.getFrameworks=e.getFrameworks?e.getFrameworks:()=>C,d}async function Ko(e,t,r){let n=I(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(Mo(e,n))return o;let a=ue(e,n,"cjs"),s=ue(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let m=s[0];if(!m.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=m.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Unexpected export type in ${t}
|
|
916
|
+
`.trimStart()}async function So(e){await Ut(e);let t=await e.readFile(e.registryPath);return t?Ls(e,t):{components:[],sourceFile:I(e,"")}}async function Ls(e,t){let r=I(e,t);return _s(e,r)}async function _s(e,t){let r=[],n=J(e,t,"CUSTOM_COMPONENTS");return n&&await Promise.all(n.arrayLiteralExp.elements.map(async(o,i)=>{let a=await Pn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:te(r)}}async function Pn(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(N(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){let p=s.arguments[0];e.ts.isIdentifier(p)&&(a=p.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await xe(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=V(e,u.filePath):(n.externalImportPath=u.importPath,n.importPath=n.externalImportPath),n.displayFilePath=u.displayFilePath,n.exportType=u.exportType,n.externalImportPath)n.exportName=a;else{let p=await uo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let m=p.find(f=>f.cmpInfo.exportName===a);m&&(n.exportName=m.cmpInfo.exportName)}}continue}}return n=ne(e,n,r),n.filePath&&n.exportName&&(n.id=await $(e,n.filePath,n.exportName,n.externalImportPath)),n}async function be(e,t,r,n,o,i,a,s){let u=await $e(e),[p,m,f]=await Promise.all([so(e,u),So(e),At(e)]),c=p.map(x=>x.cmpInfo),d=m.components,C={components:me(c,d),registryPath:e.registryPath,registryDisplayPath:k(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:he(c),publicApiKey:f.envValue??void 0,devToolsVersion:e.version};if(s)return C.components=await po(e,p,C.components),C;let l=!1,D=m.sourceFile,g=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(g.length>0){let x=g.map(A=>{let E=p.find(O=>O.cmpInfo.id===A);if(!E)throw new Error(`Component ${A} not found`);return E}),S=Array.from(new Set(x.map(A=>A.cmpInfo.filePath))),P=await G(e,S);for(let A of x){let E=C.components.find(L=>L.id===A.cmpInfo.id),O=await Dn(e,A,P);ie(E,O);let z=c.findIndex(L=>L.id===A.cmpInfo.id);c[z].inputs=O;let j=Fe(A.cmpInfo.id,c,d,r,n,o,i),{elements:F,elmIndex:y,statementIndex:H,statement:le,variableDeclaration:Y}=await Vs(e,D,A);if(j.addCmpToRegistry)F.push(js(e,j.addCmpToRegistry)),l=!0;else if(j.removeCmpFromRegistry)F.splice(y,1),l=!0;else if(j.updateRegisteredCmp){let L=Q(e,F[y],j.updateRegisteredCmp);F[y]=e.ts.factory.updateObjectLiteralExpression(L,[Ao(e,j.updateRegisteredCmp),...L.properties.slice(1)]),l=!0}if(l&&a){let L=[...D.statements];L[H]=e.ts.factory.updateVariableStatement(le,le.modifiers,e.ts.factory.updateVariableDeclarationList(le.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Se(e,F)))])),D=e.ts.factory.updateSourceFile(D,L),E.exportType==="named"?D=v(e,D,{namedImports:[E.importName],importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}):D=v(e,D,{defaultImport:E.importName,importPath:E.externalImportPath?E.externalImportPath:B(e,e.registryPath,E.filePath)}),D=v(e,D,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),D=Pe(e,D,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),C.components=j.components,d=j.components.filter(X=>X.isRegistered)}}}if(l&&a){D=Ae(e,D),D=Ee(e,D);let x=_(e,D);x=pe(x),x=await e.formatCode(e.registryPath,x),await e.writeFile(e.registryPath,x)}return C}function Ao(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function js(e,t){return Q(e,e.ts.factory.createObjectLiteralExpression([Ao(e,t)],!0),t)}async function Vs(e,t,r){let n=J(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 Pn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function Fo(e){let t=await $s(e),r={};return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>xo(t),ensureFigmaImportPage:()=>ho(t),getRegistryPath:()=>t.registryPath,getRegistry:o=>be(t,null,!1,!1,null,null,!1,!!o?.readAllInputTypes),addExternalPackage:async o=>{r[o]||(r[o]=`export * from "${o}";`)},loadComponent:async o=>{let i=await be(t,o.cmpId,!1,!1,null,null,!1,!1);return{...i,component:i.components.find(a=>a.id===o.cmpId)}},registerComponent:o=>be(t,o.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:o=>be(t,o.cmpId,!1,!1,o,null,!0,!1),setRegisteredComponentInput:o=>be(t,o.cmpId,!1,!1,null,o,!0,!1),unregisterComponent:o=>be(t,o.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>At(t),setPublicApiKey:o=>ao(t,o.publicApiKey),getDependencies:o=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>ge(t),setCache:o=>De(t,o)}}async function $s(e){let t=await Ks(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await re(e),i=e.join(n,"app"),a=await ae(e,i),s={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);s.srcDir=n,s.appDir=i,s.componentsDir=e.join(s.appDir,"components"),s.builderPageComponentPath=e.join(s.componentsDir,`builder-page.component.${o?"ts":"js"}`);let u=`app.module.${o?"ts":"js"}`,p=e.join(s.appDir,u);return await e.exists(p)&&(s.hasAppModule=!0),s}async function Ks(e){let t=e.join(e.getAppRootDir(),"angular.json");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"project.json");if(await e.exists(r))return r;throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}var Yt=Mn(Lo(),1);async function _o(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:ce(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:oe(i.inputs)};return oe(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,Yt.compress)(n);return btoa(JSON.stringify(o))}async function jo(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=oe(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=ce(e.normalize(s.filePath)),p=n.components.find(f=>ce(f.filePath).endsWith(u)&&f.exportName===s.exportName);if(!p){console.error(`Could not find component to register: ${s.filePath}, ${s.exportName}`);continue}e.debug(`register (${p.id})`,p.filePath),await t.registerComponent({cmpId:p.id});for(let f of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:f.name,type:f.type,required:f.required,defaultValue:f.defaultValue,friendlyName:f.friendlyName,helperText:f.helperText});e.debug(`set input (${p.id}) info`);let m=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=oe(m)}return a}var de={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik"},id={[de.react]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.remix]:[{version:w.gen1,recommended:!1},{version:w.gen2,recommended:!0}],[de.angular]:[{version:w.gen2,recommended:!0}],[de.next]:[{version:w.gen1,recommended:!0},{version:w.gen2,recommended:!1}],[de.qwik]:[{version:w.gen2,recommended:!0}]};async function Vo(e,t){let r=[],n=new Set;async function o(s){let u=e.join(s,"package.json");try{let p=await e.readFile(u);if(p===null)throw new Error(`Failed to read package.json at ${u}`);let m=JSON.parse(p);if(n.has(m.name))return null;n.add(m.name);let f={name:m.name,subPackages:[]},c=await e.readdir(s);for(let d of c)d!=="node_modules"&&(await e.stat(e.join(s,d))).isDirectory()&&f.subPackages.push(d);return r.push(f),f}catch(p){return console.error(`Error reading package.json at ${s}:`,p),null}}let i=e.join(t,"package.json"),a=await e.readFile(i);if(a!==null){let s=JSON.parse(a),u={...s.dependencies,...s.devDependencies};for(let p of Object.keys(u)){let m=e.join(t,"node_modules",p);await o(m)}if(s.workspaces)for(let p of s.workspaces){let m=await e.readdir(e.join(t,p));for(let f of m){let c=e.join(t,p,f);await o(c)}}}return r}var cu={"@builder.io/qwik-city":Mr,next:Rr,"@remix-run/react":Gr,react:io,"@angular/core":Fo},mu={"@builder.io/qwik-city":de.qwik,next:de.next,"@remix-run/react":de.remix,react:de.react,"@angular/core":de.angular};async function fu(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 qe(e)),e.frameworks.length===0)throw new Error(`Supported Devtools framework for not found within ${e.getAppRootDir()}`);for(let t of e.frameworks){let r=cu[t.name];if(r){let n=await r(e);return{...n,exportRegistry:()=>_o(e,n),importRegistry:i=>jo(e,n,i),framework:mu[t.name],findAllDependencies:async()=>await Vo(e,e.getRepoRootDir())}}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function $o(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 d="",C=0,l=-1,D=0,g;for(let x=0;x<=f.length;++x){if(x<f.length)g=f.charCodeAt(x);else{if(g===47)break;g=47}if(g===47){if(!(l===x-1||D===1))if(l!==x-1&&D===2){if(d.length<2||C!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let S=d.lastIndexOf("/");if(S!==d.length-1){S===-1?(d="",C=0):(d=d.slice(0,S),C=d.length-1-d.lastIndexOf("/")),l=x,D=0;continue}}else if(d.length===2||d.length===1){d="",C=0,l=x,D=0;continue}}c&&(d.length>0?d+="/..":d="..",C=2)}else d.length>0?d+="/"+f.slice(l+1,x):d=f.slice(l+1,x),C=x-l-1;l=x,D=0}else g===46&&D!==-1?++D:D=-1}return d}let n=function(...c){let d="",C=!1;for(let l=c.length-1;l>=-1&&!C;l--){let D;l>=0?D=c[l]:e.cwd?D=e.cwd():D="/",t(D),D.length!==0&&(d=D+"/"+d,C=D.charCodeAt(0)===47)}return d=r(d,!C),C?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,C=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&C&&(c+="/"),d?"/"+c:c};return{relative:function(c,d){if(t(c),t(d),c===d||(c=n(c),d=n(d),c===d))return"";let C=1;for(;C<c.length&&c.charCodeAt(C)===47;++C);let l=c.length,D=l-C,g=1;for(;g<d.length&&d.charCodeAt(g)===47;++g);let S=d.length-g,P=D<S?D:S,A=-1,E=0;for(;E<=P;++E){if(E===P){if(S>P){if(d.charCodeAt(g+E)===47)return d.slice(g+E+1);if(E===0)return d.slice(g+E)}else D>P&&(c.charCodeAt(C+E)===47?A=E:E===0&&(A=0));break}let z=c.charCodeAt(C+E),j=d.charCodeAt(g+E);if(z!==j)break;z===47&&(A=E)}let O="";for(E=C+A+1;E<=l;++E)(E===l||c.charCodeAt(E)===47)&&(O.length===0?O+="..":O+="/..");return O.length>0?O+d.slice(g+A):(g+=A,d.charCodeAt(g)===47&&++g,d.slice(g))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let C=0;C<c.length;++C){let l=c[C];t(l),l.length>0&&(d===void 0?d=l:d+="/"+l)}return d===void 0?".":o(d)},isAbsolute:function(c){return t(c),c.length>0&&c.charCodeAt(0)===47},basename:function(c,d){if(d!==void 0&&typeof d!="string")throw new TypeError('"ext" argument must be a string');t(c);let C=0,l=-1,D=!0,g;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let x=d.length-1,S=-1;for(g=c.length-1;g>=0;--g){let P=c.charCodeAt(g);if(P===47){if(!D){C=g+1;break}}else S===-1&&(D=!1,S=g+1),x>=0&&(P===d.charCodeAt(x)?--x===-1&&(l=g):(x=-1,l=S))}return C===l?l=S:l===-1&&(l=c.length),c.slice(C,l)}else{for(g=c.length-1;g>=0;--g)if(c.charCodeAt(g)===47){if(!D){C=g+1;break}}else l===-1&&(D=!1,l=g+1);return l===-1?"":c.slice(C,l)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),C=d===47,l=-1,D=!0;for(let g=c.length-1;g>=1;--g)if(d=c.charCodeAt(g),d===47){if(!D){l=g;break}}else D=!1;return l===-1?C?"/":".":C&&l===1?"//":c.slice(0,l)},extname:function(c){t(c);let d=-1,C=0,l=-1,D=!0,g=0;for(let x=c.length-1;x>=0;--x){let S=c.charCodeAt(x);if(S===47){if(!D){C=x+1;break}continue}l===-1&&(D=!1,l=x+1),S===46?d===-1?d=x:g!==1&&(g=1):d!==-1&&(g=-1)}return d===-1||l===-1||g===0||g===1&&d===l-1&&d===C+1?"":c.slice(d,l)}}}async function du(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=$o({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[D]of o)if((D+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let D=l===t()?l:l+"/",g=D.split("/").length-1,x=[];for(let[S]of o)if(S.split("/").slice(0,g).join("/")+"/"===D){let E=S.split("/")[g];E&&!x.includes(E)&&x.push(E)}return x.sort()},p=l=>{l=i(l);let D=o.get(l);return typeof D=="string"?D:null},m=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l)}),f=async l=>{if(typeof crypto<"u"){let x=new TextEncoder().encode(l),S=await crypto.subtle.digest("SHA-256",x);return Array.from(new Uint8Array(S)).map(P=>P.toString(16).padStart(2,"0")).join("")}let D=0;for(let g=0;g<l.length;g++){let x=l.charCodeAt(g);D=(D<<5)-D+x,D|=0}return Number(Math.abs(D)).toString(36)},c=new Set,d={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readFile:async l=>p(l),readFileSync:p,stat:async l=>m(l),statSync:m,writeFile:async(l,D)=>{l=i(l),o.set(l,D);let g={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let x of c)await x(g)},hash:f,getDeviceId:async()=>typeof navigator<"u"?f(navigator.userAgent):"",getRepoInfo:async()=>({remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,D)=>D,on:(l,D)=>{l==="change"&&c.add(D)},off:(l,D)=>{l==="change"&&c.delete(D)},debug:(...l)=>{console.debug("[builder-dev-tools]",...l)},launchEditor:async()=>{},platform:()=>({runtime:"",os:""}),getFrameworks:()=>[],...n,...e,version:"0.0.0",sdkVersion:null,kind:null,magicast:void 0,spawnSync:void 0},C=await qe(d);return d.getFrameworks=e.getFrameworks?e.getFrameworks:()=>C,d}async function Ko(e,t,r){let n=I(e,r),o={content:r,filePath:t,fileName:e.basename(t),hasContentUpdates:!1};if(Mo(e,n))return o;let a=ue(e,n,"cjs"),s=ue(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);if(s.length===1){let m=s[0];if(!m.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let f=m.statement;if(!e.ts.isVariableStatement(f))throw new Error(`Unexpected export type in ${t}
|
|
917
917
|
Found config content:
|
|
918
918
|
${r}
|
|
919
919
|
|
|
@@ -974,4 +974,4 @@ module.exports = nextConfig
|
|
|
974
974
|
`,n+=` }
|
|
975
975
|
`,n+=` }
|
|
976
976
|
`,n+=`})();
|
|
977
|
-
`,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var Gt="1.1.
|
|
977
|
+
`,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var Gt="1.1.41";export{fu as createDevTools,du as createDevToolsSys,qe as detectFrameworks,Gn as detectFrameworksFromPackageJson,yu as ensureConfigPlugin,ei as findBuildToolConfig,wu as getClientScript,Xn as parseDotEnvContent,Gt as version};
|