builder.io 1.9.19 → 1.9.21
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 +153 -153
- package/cli/index.cjs.map +4 -4
- package/core/index.cjs +48 -48
- package/core/index.mjs +46 -46
- package/node/index.cjs +1 -1
- package/node/index.mjs +1 -1
- package/package.json +1 -1
- package/server/index.cjs +91 -91
- package/server/index.mjs +90 -90
- package/types/cli/code-tools.d.ts +5 -3
- package/types/cli/codegen.d.ts +26 -9
- package/types/cli/credentials.d.ts +0 -7
- package/types/tsconfig.tsbuildinfo +1 -1
package/core/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var Fi=Object.create;var Gn=Object.defineProperty;var Pi=Object.getOwnPropertyDescriptor;var yi=Object.getOwnPropertyNames;var wi=Object.getPrototypeOf,vi=Object.prototype.hasOwnProperty;var Le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ti=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yi(t))!vi.call(e,o)&&o!==r&&Gn(e,o,{get:()=>t[o],enumerable:!(n=Pi(t,o))||n.enumerable});return e};var Hn=(e,t,r)=>(r=e!=null?Fi(wi(e)):{},Ti(t||!e||!e.__esModule?Gn(r,"default",{value:e,enumerable:!0}):r,e));var tr=Le((Ep,er)=>{"use strict";er.exports=function(){if(process.env.npm_config_user_agent)return Ri(process.env.npm_config_user_agent)};function Ri(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=Le(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.throwUnsupportedData=qe.throwUnknownDataType=qe.getType=void 0;function qo(e){return Object.prototype.toString.call(e)}qe.getType=qo;function Ru(e){throw new TypeError("unsupported data type: "+qo(e))}qe.throwUnknownDataType=Ru;function Nu(e){throw new TypeError("unsupported data type: "+e)}qe.throwUnsupportedData=Nu});var jn=Le(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.s_to_num=H.int_str_to_s=H.num_to_s=H.big_int_to_s=H.int_to_s=H.s_to_big_int=H.s_to_int=void 0;var Ke="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Ke+=t}var ft=Ke.length,kn={};for(let e=0;e<ft;e++){let t=Ke[e];kn[t]=e}function Ln(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=kn[o];i*=r,t+=i,r*=ft}return t}H.s_to_int=Ln;function Jo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(ft);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(kn[i]);a*=r,t+=a,r*=n}return t}H.s_to_big_int=Jo;function _n(e){if(e===0)return Ke[0];let t=[];for(;e!==0;){let r=e%ft,n=Ke[r];t.push(n),e-=r,e/=ft}return t.reverse().join("")}H.int_to_s=_n;function Wo(e){let t=BigInt(0),r=BigInt(ft);if(e===t)return Ke[0];let n=[];for(;e!==t;){let o=e%r,i=Ke[Number(o)];n.push(i),e/=r}return n.reverse().join("")}H.big_int_to_s=Wo;function Qo(e){return e.split("").reverse().join("")}function Yo(e){if(e<0)return"-"+Yo(-e);let[t,r]=e.toString().split(".");if(!r)if(t.includes("e")){let[i,a]=t.split("e");t=i,r="0e"+a}else return _n(e);let n;r&&([r,n]=r.split("e")),t=Gt(t),r=Qo(r),r=Gt(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=Gt(n),o+=n}return o}H.num_to_s=Yo;function Gt(e){let t=+e;return t.toString()===e&&t+1!==t&&t-1!==t?_n(t):":"+Wo(BigInt(e))}H.int_str_to_s=Gt;function On(e){return e[0]===":"?Jo(e.substring(1)).toString():Ln(e).toString()}function Go(e){if(e[0]==="-")return-Go(e.substr(1));let[t,r,n]=e.split(".");if(!r)return Ln(t);t=On(t),r=On(r),r=Qo(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=On(n),o+=i?-n:+n}return+o}H.s_to_num=Go});var $n=Le(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.decodeStr=X.encodeStr=X.decodeBool=X.encodeBool=X.decodeKey=X.decodeNum=X.encodeNum=void 0;var Vn=jn();function Bu(e){return"n|"+(0,Vn.num_to_s)(e)}X.encodeNum=Bu;function Ou(e){return e=e.replace("n|",""),(0,Vn.s_to_num)(e)}X.decodeNum=Ou;function ku(e){return typeof e=="number"?e:(0,Vn.s_to_int)(e)}X.decodeKey=ku;function Lu(e){return e?"b|T":"b|F"}X.encodeBool=Lu;function _u(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}X.decodeBool=_u;function ju(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}X.encodeStr=ju;function Vu(e){return e[0]+e[1]==="s|"?e.substr(2):e}X.decodeStr=Vu});var Kn=Le(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.config=void 0;Ht.config={sort_key:!1,error_on_nan:!1,error_on_infinite:!1}});var qn=Le(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.addValue=xe.makeInMemoryMemory=xe.makeInMemoryCache=xe.makeInMemoryStore=xe.memToValues=void 0;var zn=Kn(),Mn=Bn(),Un=$n(),$u=jn();function Ku(e){return e.store.toArray()}xe.memToValues=Ku;function Ho(){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}}}xe.makeInMemoryStore=Ho;function Xo(){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}}}xe.makeInMemoryCache=Xo;function Mu(){return{store:Ho(),cache:Xo(),keyCount:0}}xe.makeInMemoryMemory=Mu;function tt(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=(0,$u.num_to_s)(r);return e.store.add(t),e.cache.setValue(t,n),n}function Uu(e,t){zn.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=Nt(e,t,void 0);return e.cache.setSchema(r,n),n}function Nt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return Nt(e,null,r);break;case"object":if(t===null)return tt(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":Nt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),tt(e,n)}else{let n=Object.keys(t);if(n.length===0)return tt(e,"o|");let o="o",i=Uu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=Nt(e,s,t);o+="|"+u}return tt(e,o)}case"boolean":return tt(e,(0,Un.encodeBool)(t));case"number":return Number.isNaN(t)?(zn.config.error_on_nan&&(0,Mn.throwUnsupportedData)("[number NaN]"),""):Number.POSITIVE_INFINITY===t||Number.NEGATIVE_INFINITY===t?(zn.config.error_on_infinite&&(0,Mn.throwUnsupportedData)("[number Infinity]"),""):tt(e,(0,Un.encodeNum)(t));case"string":return tt(e,(0,Un.encodeStr)(t))}return(0,Mn.throwUnknownDataType)(t)}xe.addValue=Nt});var Wn=Le(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.decompress=Je.decode=Je.compress=void 0;var zu=Bn(),Xt=$n(),Jn=qn();function qu(e){let t=(0,Jn.makeInMemoryMemory)(),r=(0,Jn.addValue)(t,e,void 0);return[(0,Jn.memToValues)(t),r]}Je.compress=qu;function Ju(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=Bt(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=Bt(e,p),r[u]=p}return r}function Wu(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=Bt(e,a),o[i]=a}return o}function Bt(e,t){if(t===""||t==="_")return null;let r=(0,Xt.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(0,Xt.decodeBool)(n);case"o|":return Ju(e,n);case"n|":return(0,Xt.decodeNum)(n);case"a|":return Wu(e,n);default:return(0,Xt.decodeStr)(n)}}return(0,zu.throwUnknownDataType)(n)}Je.decode=Bt;function Qu(e){let[t,r]=e;return Bt(t,r)}Je.decompress=Qu});var ei=Le(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.trimUndefinedRecursively=dt.trimUndefined=void 0;function Yu(e){for(let t in e)e[t]===void 0&&delete e[t]}dt.trimUndefined=Yu;function Gu(e){Zo(e,new Set)}dt.trimUndefinedRecursively=Gu;function Zo(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)&&Zo(n,t)}}});var ri=Le(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.config=Z.trimUndefinedRecursively=Z.trimUndefined=Z.addValue=Z.decode=Z.decompress=Z.compress=void 0;var ti=Wn();Object.defineProperty(Z,"compress",{enumerable:!0,get:function(){return ti.compress}});Object.defineProperty(Z,"decompress",{enumerable:!0,get:function(){return ti.decompress}});var Hu=Wn();Object.defineProperty(Z,"decode",{enumerable:!0,get:function(){return Hu.decode}});var Xu=qn();Object.defineProperty(Z,"addValue",{enumerable:!0,get:function(){return Xu.addValue}});var ni=ei();Object.defineProperty(Z,"trimUndefined",{enumerable:!0,get:function(){return ni.trimUndefined}});Object.defineProperty(Z,"trimUndefinedRecursively",{enumerable:!0,get:function(){return ni.trimUndefinedRecursively}});var Zu=Kn();Object.defineProperty(Z,"config",{enumerable:!0,get:function(){return Zu.config}})});var bi="1.9.19",Xn=process.env.OVERRIDE_VERSION??bi;function ne(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var Ii=["node_modules","dist","build","public"];async function ie(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(Ii.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 f=await r(u,i+1);if(f)return f}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await ne(e)?"ts":"js"}`;return e.join(t,i)}return n}async function gt(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 Zn(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 Dt(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 Dt(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var rr=Hn(tr(),1);function Ae(e){return e.endsWith(".mapper.tsx")||e.endsWith(".mapper.jsx")||e.endsWith(".mapper.ts")||e.endsWith(".mapper.js")||e.endsWith(".mapper.mjs")}function N(e,t,r){t=he(t),r=he(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=he(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function he(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 nr(o==="index"?e.basename(e.dirname(t)):o)}function nr(e){return K(e).replace(/ /g,"")}function le(e,t){let r=e.extname(t),n=he(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function M(e,t){let r=he(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 O(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 ae(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function V(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 xt(e){return typeof e=="number"}function nt(e){return typeof e=="boolean"}function re(e){return typeof e=="string"}function rt(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function ue(e){return JSON.parse(JSON.stringify(e))}function kt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function or(){try{let e=(0,rr.default)();if(e?.name)return e.name}catch{}return"npm"}async function Ye(e){let t=[],r=await gt(e,e.getRepoRootDir());if(r){let n=await sr(r,e);t.push(...n)}return t}async function ar(e){let t=await gt(e,e.getRepoRootDir());return t?.scripts?.dev?t.scripts.dev.includes("--turbopack"):!1}async function sr(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Ni)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};ir.has(o)&&(i.version=await ir.get(o)(t)),r.push(i)}}return r}function rn(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var ir=new Map([["next",async e=>{if(!e.spawnSync)return;let t=or(),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:rn(a),minor:rn(s),patch:rn(u)}}]]),Ni=["@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 me(e){let t=ur(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function fe(e,t){t=typeof t=="object"&&t!=null?t:{};let r=ur(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function ur(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function Fe(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await Bi(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 Bi(e,t){let r=await e.readFile(t);return typeof r=="string"?pr(r):null}function pr(e){let t={},r=e.replace(/\r\n?/gm,`
|
|
3
|
-
`),n;for(;(n=
|
|
4
|
-
`),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var
|
|
2
|
+
var Pi=Object.create;var rn=Object.defineProperty;var yi=Object.getOwnPropertyDescriptor;var wi=Object.getOwnPropertyNames;var vi=Object.getPrototypeOf,Ti=Object.prototype.hasOwnProperty;var bi=(e,t,r)=>t in e?rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Le=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Ii=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of wi(t))!Ti.call(e,o)&&o!==r&&rn(e,o,{get:()=>t[o],enumerable:!(n=yi(t,o))||n.enumerable});return e};var Hn=(e,t,r)=>(r=e!=null?Pi(vi(e)):{},Ii(t||!e||!e.__esModule?rn(r,"default",{value:e,enumerable:!0}):r,e));var Xn=(e,t,r)=>bi(e,typeof t!="symbol"?t+"":t,r);var nr=Le((Ap,tr)=>{"use strict";tr.exports=function(){if(process.env.npm_config_user_agent)return Bi(process.env.npm_config_user_agent)};function Bi(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 On=Le(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.throwUnsupportedData=qe.throwUnknownDataType=qe.getType=void 0;function Jo(e){return Object.prototype.toString.call(e)}qe.getType=Jo;function Bu(e){throw new TypeError("unsupported data type: "+Jo(e))}qe.throwUnknownDataType=Bu;function Ou(e){throw new TypeError("unsupported data type: "+e)}qe.throwUnsupportedData=Ou});var Vn=Le(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.s_to_num=H.int_str_to_s=H.num_to_s=H.big_int_to_s=H.int_to_s=H.s_to_big_int=H.s_to_int=void 0;var Ke="";for(let e=0;e<10;e++){let t=String.fromCharCode(48+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(65+e);Ke+=t}for(let e=0;e<26;e++){let t=String.fromCharCode(97+e);Ke+=t}var ft=Ke.length,Ln={};for(let e=0;e<ft;e++){let t=Ke[e];Ln[t]=e}function _n(e){let t=0,r=1;for(let n=e.length-1;n>=0;n--){let o=e[n],i=Ln[o];i*=r,t+=i,r*=ft}return t}H.s_to_int=_n;function Wo(e){let t=BigInt(0),r=BigInt(1),n=BigInt(ft);for(let o=e.length-1;o>=0;o--){let i=e[o],a=BigInt(Ln[i]);a*=r,t+=a,r*=n}return t}H.s_to_big_int=Wo;function jn(e){if(e===0)return Ke[0];let t=[];for(;e!==0;){let r=e%ft,n=Ke[r];t.push(n),e-=r,e/=ft}return t.reverse().join("")}H.int_to_s=jn;function Qo(e){let t=BigInt(0),r=BigInt(ft);if(e===t)return Ke[0];let n=[];for(;e!==t;){let o=e%r,i=Ke[Number(o)];n.push(i),e/=r}return n.reverse().join("")}H.big_int_to_s=Qo;function Yo(e){return e.split("").reverse().join("")}function Go(e){if(e<0)return"-"+Go(-e);let[t,r]=e.toString().split(".");if(!r)if(t.includes("e")){let[i,a]=t.split("e");t=i,r="0e"+a}else return jn(e);let n;r&&([r,n]=r.split("e")),t=Gt(t),r=Yo(r),r=Gt(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=Gt(n),o+=n}return o}H.num_to_s=Go;function Gt(e){let t=+e;return t.toString()===e&&t+1!==t&&t-1!==t?jn(t):":"+Qo(BigInt(e))}H.int_str_to_s=Gt;function kn(e){return e[0]===":"?Wo(e.substring(1)).toString():_n(e).toString()}function Ho(e){if(e[0]==="-")return-Ho(e.substr(1));let[t,r,n]=e.split(".");if(!r)return _n(t);t=kn(t),r=kn(r),r=Yo(r);let o=t+"."+r;if(n){o+="e";let i=!1;n[0]==="-"&&(i=!0,n=n.slice(1)),n=kn(n),o+=i?-n:+n}return+o}H.s_to_num=Ho});var Kn=Le(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.decodeStr=X.encodeStr=X.decodeBool=X.encodeBool=X.decodeKey=X.decodeNum=X.encodeNum=void 0;var $n=Vn();function ku(e){return"n|"+(0,$n.num_to_s)(e)}X.encodeNum=ku;function Lu(e){return e=e.replace("n|",""),(0,$n.s_to_num)(e)}X.decodeNum=Lu;function _u(e){return typeof e=="number"?e:(0,$n.s_to_int)(e)}X.decodeKey=_u;function ju(e){return e?"b|T":"b|F"}X.encodeBool=ju;function Vu(e){switch(e){case"b|T":return!0;case"b|F":return!1}return!!e}X.decodeBool=Vu;function $u(e){switch(e[0]+e[1]){case"b|":case"o|":case"n|":case"a|":case"s|":e="s|"+e}return e}X.encodeStr=$u;function Ku(e){return e[0]+e[1]==="s|"?e.substr(2):e}X.decodeStr=Ku});var Mn=Le(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.config=void 0;Ht.config={sort_key:!1,error_on_nan:!1,error_on_infinite:!1}});var Jn=Le(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.addValue=xe.makeInMemoryMemory=xe.makeInMemoryCache=xe.makeInMemoryStore=xe.memToValues=void 0;var qn=Mn(),Un=On(),zn=Kn(),Mu=Vn();function Uu(e){return e.store.toArray()}xe.memToValues=Uu;function Xo(){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}}}xe.makeInMemoryStore=Xo;function Zo(){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}}}xe.makeInMemoryCache=Zo;function zu(){return{store:Xo(),cache:Zo(),keyCount:0}}xe.makeInMemoryMemory=zu;function tt(e,t){if(e.cache.hasValue(t))return e.cache.getValue(t);let r=e.keyCount++,n=(0,Mu.num_to_s)(r);return e.store.add(t),e.cache.setValue(t,n),n}function qu(e,t){qn.config.sort_key&&t.sort();let r=t.join(",");if(e.cache.hasSchema(r))return e.cache.getSchema(r);let n=Nt(e,t,void 0);return e.cache.setSchema(r,n),n}function Nt(e,t,r){if(t===null)return"";switch(typeof t){case"undefined":if(Array.isArray(r))return Nt(e,null,r);break;case"object":if(t===null)return tt(e,null);if(Array.isArray(t)){let n="a";for(let o=0;o<t.length;o++){let i=t[o],a=i===null?"_":Nt(e,i,t);n+="|"+a}return n==="a"&&(n="a|"),tt(e,n)}else{let n=Object.keys(t);if(n.length===0)return tt(e,"o|");let o="o",i=qu(e,n);o+="|"+i;for(let a of n){let s=t[a],u=Nt(e,s,t);o+="|"+u}return tt(e,o)}case"boolean":return tt(e,(0,zn.encodeBool)(t));case"number":return Number.isNaN(t)?(qn.config.error_on_nan&&(0,Un.throwUnsupportedData)("[number NaN]"),""):Number.POSITIVE_INFINITY===t||Number.NEGATIVE_INFINITY===t?(qn.config.error_on_infinite&&(0,Un.throwUnsupportedData)("[number Infinity]"),""):tt(e,(0,zn.encodeNum)(t));case"string":return tt(e,(0,zn.encodeStr)(t))}return(0,Un.throwUnknownDataType)(t)}xe.addValue=Nt});var Qn=Le(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.decompress=Je.decode=Je.compress=void 0;var Ju=On(),Xt=Kn(),Wn=Jn();function Wu(e){let t=(0,Wn.makeInMemoryMemory)(),r=(0,Wn.addValue)(t,e,void 0);return[(0,Wn.memToValues)(t),r]}Je.compress=Wu;function Qu(e,t){if(t==="o|")return{};let r={},n=t.split("|"),o=n[1],i=Bt(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=Bt(e,p),r[u]=p}return r}function Yu(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=Bt(e,a),o[i]=a}return o}function Bt(e,t){if(t===""||t==="_")return null;let r=(0,Xt.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(0,Xt.decodeBool)(n);case"o|":return Qu(e,n);case"n|":return(0,Xt.decodeNum)(n);case"a|":return Yu(e,n);default:return(0,Xt.decodeStr)(n)}}return(0,Ju.throwUnknownDataType)(n)}Je.decode=Bt;function Gu(e){let[t,r]=e;return Bt(t,r)}Je.decompress=Gu});var ti=Le(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.trimUndefinedRecursively=dt.trimUndefined=void 0;function Hu(e){for(let t in e)e[t]===void 0&&delete e[t]}dt.trimUndefined=Hu;function Xu(e){ei(e,new Set)}dt.trimUndefinedRecursively=Xu;function ei(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)&&ei(n,t)}}});var oi=Le(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.config=Z.trimUndefinedRecursively=Z.trimUndefined=Z.addValue=Z.decode=Z.decompress=Z.compress=void 0;var ni=Qn();Object.defineProperty(Z,"compress",{enumerable:!0,get:function(){return ni.compress}});Object.defineProperty(Z,"decompress",{enumerable:!0,get:function(){return ni.decompress}});var Zu=Qn();Object.defineProperty(Z,"decode",{enumerable:!0,get:function(){return Zu.decode}});var ep=Jn();Object.defineProperty(Z,"addValue",{enumerable:!0,get:function(){return ep.addValue}});var ri=ti();Object.defineProperty(Z,"trimUndefined",{enumerable:!0,get:function(){return ri.trimUndefined}});Object.defineProperty(Z,"trimUndefinedRecursively",{enumerable:!0,get:function(){return ri.trimUndefinedRecursively}});var tp=Mn();Object.defineProperty(Z,"config",{enumerable:!0,get:function(){return tp.config}})});var Ri="1.9.21",Zn=process.env.OVERRIDE_VERSION??Ri;function ne(e){let t=e.join(e.getAppRootDir(),"tsconfig.json");return e.exists(t)}var Ni=["node_modules","dist","build","public"];async function ie(e,t){async function r(o,i){if(i>10)return;let a=await e.readdir(o);for(let s of a){if(Ni.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 f=await r(u,i+1);if(f)return f}}}}let n=await r(e.getAppRootDir(),0);if(!n){let i=`builder-registry.${await ne(e)?"ts":"js"}`;return e.join(t,i)}return n}async function gt(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 er(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 Dt(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 Dt(e,a,r);if(u)return u}}))).find(i=>typeof i=="string")}var or=Hn(nr(),1);function Ae(e){return e.endsWith(".mapper.tsx")||e.endsWith(".mapper.jsx")||e.endsWith(".mapper.ts")||e.endsWith(".mapper.js")||e.endsWith(".mapper.mjs")}function N(e,t,r){t=he(t),r=he(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=he(e.normalize(o)),o.startsWith(".")||(o="./"+o),o}function he(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 rr(o==="index"?e.basename(e.dirname(t)):o)}function rr(e){return K(e).replace(/ /g,"")}function le(e,t){let r=e.extname(t),n=he(e.basename(t,r)).split("/").pop();return K(n==="index"?e.basename(e.dirname(t)):n)}function M(e,t){let r=he(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 O(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 ae(e){return e.sort((t,r)=>t.name.toLocaleLowerCase().localeCompare(r.name.toLocaleLowerCase()))}async function V(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 xt(e){return typeof e=="number"}function nt(e){return typeof e=="boolean"}function re(e){return typeof e=="string"}function rt(e){return typeof e=="string"?/^[A-Z][A-Za-z0-9]*$/.test(e):!1}function ue(e){return JSON.parse(JSON.stringify(e))}function kt(e,t,r){for(let n of t)if(e.dirname(r).includes(n))return!0;return!1}function ir(){try{let e=(0,or.default)();if(e?.name)return e.name}catch{}return"npm"}async function Ye(e){let t=[],r=await gt(e,e.getRepoRootDir());if(r){let n=await ur(r,e);t.push(...n)}return t}async function sr(e){let t=await gt(e,e.getRepoRootDir());return t?.scripts?.dev?t.scripts.dev.includes("--turbopack"):!1}async function ur(e,t){let r=[];if(e&&typeof e=="object"){let n=new Set(Object.keys({...e.dependencies,...e.devDependencies}));for(let o of Oi)if(n.has(o)&&!r.some(i=>i.name===o)){let i={name:o};ar.has(o)&&(i.version=await ar.get(o)(t)),r.push(i)}}return r}function on(e){let t=parseInt(e);return Number.isNaN(t)?void 0:t}var ar=new Map([["next",async e=>{if(!e.spawnSync)return;let t=ir(),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:on(a),minor:on(s),patch:on(u)}}]]),Oi=["@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 me(e){let t=pr(e),r=await e.readFile(t);return typeof r=="string"?JSON.parse(r):{}}async function fe(e,t){t=typeof t=="object"&&t!=null?t:{};let r=pr(e);await e.writeFile(r,JSON.stringify(t??{},null,2))}function pr(e){let t=e.getAppRootDir();return e.join(t,"node_modules",".builder","builder-cache.json")}async function Fe(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),o),a=await ki(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 ki(e,t){let r=await e.readFile(t);return typeof r=="string"?cr(r):null}function cr(e){let t={},r=e.replace(/\r\n?/gm,`
|
|
3
|
+
`),n;for(;(n=Li.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,`
|
|
4
|
+
`),i=i.replace(/\\r/g,"\r")),t[o]=i}return t}var Li=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;async function Pe(e,t,r,n){let o="# https://www.builder.io/c/docs/using-your-api-key",i=await e.readFile(t);try{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+=`
|
|
5
5
|
|
|
6
6
|
${o}
|
|
7
7
|
${r}=${n}
|
|
8
8
|
|
|
9
9
|
`,await e.writeFile(t,i),"update";else return e.debug(`Creating new .env file with "${r}" at ${t}`),i=[o,`${r}=${n}`,""].join(`
|
|
10
|
-
`),await e.writeFile(t,i),"create"}catch(a){if(a&&String(a).includes("EACCES"))return e.debug(`Permssion denied, failed to create or modify .env file with "${r}=${n}" at ${t}`),"permission-error";e.Sentry?.captureException(a)}return null}async function Ct(e){return await Fe(e,[".env.local",".env.development.local",".env.production.local",".env.development",".env.production",".env"],ye)}async function
|
|
10
|
+
`),await e.writeFile(t,i),"create"}catch(a){if(a&&String(a).includes("EACCES"))return e.debug(`Permssion denied, failed to create or modify .env file with "${r}=${n}" at ${t}`),"permission-error";e.Sentry?.captureException(a)}return null}async function Ct(e){return await Fe(e,[".env.local",".env.development.local",".env.production.local",".env.development",".env.production",".env"],ye)}async function lr(e,t){let r=await Ct(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var ye="NEXT_PUBLIC_BUILDER_API_KEY";var y={gen1:"Gen 1",gen2:"Gen 2"};function b(e,t=""){return e.ts.createSourceFile("module.tsx",typeof t=="string"?t:"",e.ts.ScriptTarget.Latest,void 0)}function Lt(e,t=""){let r=b(e,t?.trim());if(r.statements.length===0)throw new Error(`No statements found in code: ${t}`);return r.statements[0]}function j(e,t,r){if(t){let n=e.ts.createPrinter({newLine:e.ts.NewLineKind.LineFeed,removeComments:r});return e.ts.isSourceFile(t)?n.printFile(t).trim()+`
|
|
11
11
|
`:n.printNode(e.ts.EmitHint.Unspecified,t,e.ts.createSourceFile("module.tsx","",e.ts.ScriptTarget.Latest)).trim()+`
|
|
12
|
-
`}return""}function ot(e,t,r,n,o=!0){let i=t.properties.filter(s=>e.ts.isPropertyAssignment(s)),a=ki(e,t,r);return a>-1?n==null&&o?e.ts.factory.updateObjectLiteralExpression(t,i.filter((s,u)=>u!==a)):(i[a]=e.ts.factory.updatePropertyAssignment(i[a],i[a].name,ht(e,n)),e.ts.factory.updateObjectLiteralExpression(t,i)):(n!=null&&i.push(e.ts.factory.createPropertyAssignment(r,ht(e,n))),e.ts.factory.updateObjectLiteralExpression(t,i))}function ki(e,t,r){return t.properties.findIndex(n=>L(e,n)===r)}function Et(e,t){switch(t.kind){case e.ts.SyntaxKind.ArrayLiteralExpression:return _i(e,t);case e.ts.SyntaxKind.ObjectLiteralExpression:return Li(e,t);case e.ts.SyntaxKind.StringLiteral:return t.text;case e.ts.SyntaxKind.NumericLiteral:return Number(t.text);case e.ts.SyntaxKind.NoSubstitutionTemplateLiteral:return t.text;case e.ts.SyntaxKind.TrueKeyword:return!0;case e.ts.SyntaxKind.FalseKeyword:return!1;case e.ts.SyntaxKind.Identifier:switch(t.escapedText){case"undefined":return;case"null":return null;case"String":return String;case"Number":return Number;case"Boolean":return Boolean;case"NaN":return NaN}}}function Li(e,t){let r={};if(t&&e.ts.isObjectLiteralExpression(t)){for(let n of t.properties)if(e.ts.isPropertyAssignment(n)){let o=L(e,n);o&&(r[o]=Et(e,n.initializer))}}return r}function _i(e,t){return t&&e.ts.isArrayLiteralExpression(t)?t.elements.map(r=>Et(e,r)):[]}function L(e,t){if(t&&e.ts.isPropertyAssignment(t)){let r=t.name;switch(r.kind){case e.ts.SyntaxKind.Identifier:return r.text;case e.ts.SyntaxKind.StringLiteral:case e.ts.SyntaxKind.NumericLiteral:return r.text;case e.ts.SyntaxKind.ComputedPropertyName:let n=r.expression;if(e.ts.isStringLiteral(n)||e.ts.isNumericLiteral(n))return r.expression.text}}}function ht(e,t){return on(e,t,new WeakSet)}function on(e,t,r){return t===void 0?e.ts.factory.createIdentifier("undefined"):t===null?e.ts.factory.createIdentifier("null"):typeof t=="string"?e.ts.factory.createStringLiteral(t):typeof t=="number"?isNaN(t)?e.ts.factory.createIdentifier("NaN"):e.ts.factory.createNumericLiteral(t):t===!0?e.ts.factory.createTrue():t===!1?e.ts.factory.createFalse():t===String?e.ts.factory.createIdentifier("String"):t===Number?e.ts.factory.createIdentifier("Number"):t===Boolean?e.ts.factory.createIdentifier("Boolean"):Array.isArray(t)?ji(e,t,r):typeof t=="object"?Vi(e,t,r):e.ts.factory.createIdentifier(t)}function ji(e,t,r){let n=t.map(o=>on(e,o,r));return e.ts.factory.createArrayLiteralExpression(n,!0)}function Vi(e,t,r){if(r.has(t))return e.ts.factory.createIdentifier("undefined");r.add(t);let n=Object.keys(t).map(o=>e.ts.factory.createPropertyAssignment(o,on(e,t[o],r)));return e.ts.factory.createObjectLiteralExpression(n,!0)}function Ge(e,t,r){let n=[];if(!r)return n;let o=null;if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r)){let i=r.parameters;if(i.length>0){let a=i[0],s=t.getTypeAtLocation(a);s.aliasTypeArguments&&s.aliasTypeArguments.length>0&&(s=s.aliasTypeArguments[0]),!!(s.flags&e.ts.TypeFlags.Object)&&(o=s.getProperties())}}else if(e.ts.isIdentifier(r)){let i=t.getTypeAtLocation(r),a=i.symbol?.valueDeclaration;if(a&&e.ts.isClassDeclaration(a)){let u=a.heritageClauses?.find(p=>p.token===e.ts.SyntaxKind.ExtendsKeyword)?.types;if(u){for(let p of u)if(t.getSymbolAtLocation(p.expression)?.name==="Component"){if(e.ts.isExpressionWithTypeArguments(p)){let m=p.typeArguments;if(m){let c=m[0];o=t.getTypeFromTypeNode(c).getProperties()}}break}}}if(!o){let s=i.getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}else if(e.ts.isExportSpecifier(r)){let i=t.getSymbolAtLocation(r.name);if(i){let s=t.getTypeOfSymbolAtLocation(i,r).getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}if(o)for(let i of o){let a=$i(e,t,i);a&&n.push(a)}return n=n.filter(mr),n.length>0?n:Ki(e,r)}function $i(e,t,r){let n=r.valueDeclaration,o=r.getName();if(n||(n=r.getDeclarations()?.[0]),n&&e.ts.isPropertySignature(n)){if(o!=="children"&&n.getSourceFile().fileName.includes("node_modules/@types/"))return null;let i="string",a;if(n?.type){let u=t.getTypeFromTypeNode(n.type),p=t.typeToString(u),f=an(p);f.knownType?i=f.builderType:Ui(p)||u.flags&e.ts.TypeFlags.StringLike?i="string":u.flags&e.ts.TypeFlags.NumberLike?i="number":u.flags&e.ts.TypeFlags.IndexedAccess?i="list":u.flags&e.ts.TypeFlags.Object||u.isUnion()&&u.types.every(m=>m.flags&e.ts.TypeFlags.Object)||u.isIntersection()&&u.types.some(m=>m.flags&e.ts.TypeFlags.Object)?i="object":i="string",p!==i&&(a=p)}let s={name:o,type:i,isRegistered:!1};if(a&&n.type){let u=Wi(e,t,t.getTypeFromTypeNode(n.type));s.meta=s.meta||{},u&&u.length>0&&s.type==="string"&&u.every(qi)?s.enum=u.map(Ji):s.meta.ts=a}return n.questionToken||(s.required=!0),s}return null}function Ki(e,t){let r=[],n=e.ts.getJSDocCommentsAndTags(t);for(let o of n)if(!(!e.ts.isJSDoc(o)||!o.tags))for(let i of o.tags){if(!e.ts.isJSDocParameterTag(i)||i.tagName.text!=="param")continue;let s=i.typeExpression?.type;if(!s||!e.ts.isJSDocTypeLiteral(s))continue;let u=s.jsDocPropertyTags;if(u)for(let p of u){if(!e.ts.isJSDocPropertyLikeTag(p))continue;let f=p.name;if(!e.ts.isQualifiedName(f))continue;let m=p.typeExpression;if(!m)continue;let c="";switch(m.type.kind){case e.ts.SyntaxKind.StringKeyword:{c="string";break}case e.ts.SyntaxKind.NumberKeyword:{c="number";break}case e.ts.SyntaxKind.BooleanKeyword:{c="boolean";break}default:continue}let D={name:f.right.text,type:c,isRegistered:!1};r.push(D)}}return r.filter(mr)}var Mi=["ClassicComponent","FunctionComponent","IntrinsicElements","JSX","ReactNode","ReactElement","ReactPortal"];function Ui(e){return typeof e!="string"?!1:!!Mi.some(t=>e.includes(t))}function an(e){return typeof e=="string"&&(e=e.trim(),zi.some(t=>t.value===e))?{builderType:e,knownType:!0}:{builderType:"string",knownType:!1}}var zi=[{value:"boolean",text:"boolean"},{value:"color",text:"color (provides a color in hex or rgb)"},{value:"date",text:"date (same format as the Date constructor)"},{value:"email",text:"email"},{value:"file",text:"file (uploads a file and provides a url)"},{value:"list",text:"list (collection of items)"},{value:"longText",text:"longText (multiline text editor)"},{value:"number",text:"number"},{value:"object",text:"object (set of specific names and values)"},{value:"richText",text:"richText (provides value as html)"},{value:"string",text:"string"}];function qi(e){return/^['"].*['"]$/.test(e)}function Ji(e){return(e.startsWith('"')||e.startsWith("'"))&&(e.endsWith('"')||e.endsWith("'"))?e.slice(1,-1):e}var Wi=(e,t,r)=>{let n=new Set;lr(e,t,r,n);let o=n.delete("true"),i=n.delete("false");(o||i)&&n.add("boolean");let a=Array.from(n.keys()).sort();if(a.length>1&&(a=a.map(s=>s.indexOf("=>")>=0?`(${s})`:s)),!(a.length>20))return a},Qi=(e,t,r)=>{let n=e.ts.TypeFormatFlags.InElementType|e.ts.TypeFormatFlags.NoTruncation;return t.typeToString(r,void 0,n)},lr=(e,t,r,n)=>{if(r.isUnion())r.types.forEach(o=>{lr(e,t,o,n)});else if(r.isLiteral()){let o=Qi(e,t,r);n.add(o)}};function mr(e){let t=e?.name;if(typeof t!="string"||t===""||t.startsWith("aria")||t.startsWith("data-"))return!1;if(t.startsWith("on")&&t.length>2){let r=t.charAt(2);if(r.toUpperCase()===r)return!1}return!Yi.has(t.toLowerCase())}var Yi=new Set(["about","accessKey","accessKeyLabel","asChild","autoCapitalize","autoCorrect","autoFocus","autoSave","blur","contentEditable","contextMenu","dangerouslySetInnerHTML","datatype","defaultChecked","defaultValue","dir","draggable","enterKeyHint","focus","form","formAction","formEncType","formMethod","formNoValidate","formTarget","inlist","innerText","inputMode","is","isContentEditable","itemID","itemProp","itemRef","itemScope","itemType","lang","nonce","offsetHeight","offsetLeft","offsetTop","offsetWidth","outerText","prefix","property","radioGroup","rel","resource","results","rev","role","security","slot","spellCheck","suppressContentEditableWarning","suppressHydrationWarning","tabIndex","translate","typeof","unselectable","vocab"].map(e=>e.toLowerCase()));function se(e,t,r){for(let n of r.properties){if(!e.ts.isPropertyAssignment(n))continue;let o=L(e,n);if(o==="name"&&e.ts.isStringLiteral(n.initializer)){t.name=n.initializer.text;continue}if(o==="description"&&e.ts.isStringLiteral(n.initializer)){t.description=n.initializer.text;continue}if(o==="image"&&e.ts.isStringLiteral(n.initializer)){t.image=n.initializer.text;continue}if(o==="inputs"&&e.ts.isArrayLiteralExpression(n.initializer)){let i=Gi(e,n.initializer);pe(t,i);continue}if(o==="meta"&&e.ts.isObjectLiteralExpression(n.initializer)){let i=Et(e,n.initializer);i&&typeof i=="object"&&(t.meta=i);continue}}return t}function Gi(e,t){let r=[];for(let n of t.elements)e.ts.isObjectLiteralExpression(n)&&r.push(Hi(e,n));return r}function Hi(e,t){let r=Et(e,t),n=oa(r);return n.isRegistered=!0,n}function W(e,t,r){let n=Zi(r);return t=ot(e,t,"name",n.name,!1),t=ot(e,t,"description",n.description),t=ot(e,t,"image",n.image),t=ot(e,t,"meta",n.meta),t=Xi(e,t,n),ia(e,t)}function Xi(e,t,r){let n=null,o=t.properties.filter(s=>e.ts.isPropertyAssignment(s)&&e.ts.isIdentifier(s.name)),i=o.findIndex(s=>e.ts.isIdentifier(s.name)&&s.name.text==="inputs"),a=[...r.inputs??[]];if(i>-1){if(a.length===0)return ot(e,t,"inputs",null);let s=o[i];e.ts.isPropertyAssignment(s)&&e.ts.isArrayLiteralExpression(s.initializer)&&(n=s.initializer)}return a.length===0?t:(n=ta(e,n||e.ts.factory.createArrayLiteralExpression(),a),i>-1?o[i]=e.ts.factory.updatePropertyAssignment(o[i],o[i].name,n):o.push(e.ts.factory.createPropertyAssignment("inputs",n)),e.ts.factory.updateObjectLiteralExpression(t,o))}function Zi(e){return{name:e.name,description:e.description,image:e.image,inputs:(e.inputs||[]).filter(r=>r.isRegistered).map(ea),...e.meta?{meta:{...e.meta}}:{}}}function ea(e){let t={name:e.name,type:e.type};return(re(e.defaultValue)||xt(e.defaultValue)||nt(e.defaultValue))&&(t.defaultValue=e.defaultValue),re(e.friendlyName)&&(t.friendlyName=e.friendlyName),re(e.helperText)&&(t.helperText=e.helperText),e.required===!0&&(t.required=!0),Array.isArray(e.enum)&&(t.enum=e.enum),e.hideFromUI===!0&&(t.hideFromUI=!0),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(t.meta=e.meta),t}function ta(e,t,r){let n=t.elements.filter(o=>{if(!e.ts.isObjectLiteralExpression(o))return!1;let i=o.properties.find(s=>L(e,s)==="name");if(!i)return!1;let a=i.initializer;return e.ts.isStringLiteral(a)?r.some(s=>s.name===a.text):!1});for(let o of r)n=na(e,n,o);return n.sort((o,i)=>{let a=o.properties.find(c=>L(e,c)==="name"),s=i.properties.find(c=>L(e,c)==="name"),u=a?.initializer,p=s?.initializer,f=u&&e.ts.isStringLiteral(u)?u.text:"zz",m=p&&e.ts.isStringLiteral(p)?p.text:"zz";return f.toLowerCase().localeCompare(m.toLowerCase())}),e.ts.factory.updateArrayLiteralExpression(t,n)}function na(e,t,r){let n=t.findIndex(o=>o.properties.some(i=>{let a=L(e,i);return e.ts.isPropertyAssignment(i)&&a==="name"&&e.ts.isStringLiteral(i.initializer)&&i.initializer.text===r.name}));if(n>-1)t[n]=fr(e,t[n],r);else{let o=fr(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("name",e.ts.factory.createStringLiteral(r.name))],!0),r);t.push(o)}return t}function fr(e,t,r){let n=t.properties.filter(i=>e.ts.isPropertyAssignment(i)),o=Object.keys(r).filter(i=>i!=="isRegistered");for(let i of o)n=ra(e,n,r,i);return n=aa(e,n.filter(i=>{let a=L(e,i);return o.includes(a)})),e.ts.factory.updateObjectLiteralExpression(t,n)}function ra(e,t,r,n){let o=t.findIndex(i=>e.ts.isIdentifier(i.name)&&i.name.text===n);return o>-1?t[o]=e.ts.factory.updatePropertyAssignment(t[o],t[o].name,ht(e,r[n])):t.push(e.ts.factory.createPropertyAssignment(n,ht(e,r[n]))),t}function pe(e,t){for(let r of t){let n=e.inputs.findIndex(o=>o.name===r.name);n>-1?(r.isRegistered||!e.inputs[n].isRegistered)&&(e.inputs[n]=r):e.inputs.push(r)}e.acceptsChildren=sn(e)}function oa(e){let t=an(e.type),r={name:e.name.trim(),type:t.builderType};return re(e.friendlyName)&&e.friendlyName.trim()!==e.name.trim()&&(r.friendlyName=e.friendlyName),(re(e.defaultValue)||xt(e.defaultValue)||nt(e.defaultValue))&&(r.defaultValue=e.defaultValue),re(e.helperText)&&(r.helperText=e.helperText),nt(e.required)&&(r.required=e.required),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(r.meta=e.meta),Array.isArray(e.enum)&&e.enum.length>0&&(r.enum=e.enum),e.hideFromUI===!0&&(r.hideFromUI=!0),un(r)}function sn(e){let t=e.inputs.some(n=>n.name==="children"),r=e.inputs.some(n=>n.meta?.ts==="ReactNode");return!!(t||r||e.acceptsChildren===!0)}function un(e){if(e.name==="children"&&(e.hideFromUI=!0,delete e.required),e.type==="object"&&e.defaultValue==null&&(e.hideFromUI=!0),e.type==="list"&&e.defaultValue==null&&(e.hideFromUI=!0),e.meta){let t=e.meta.ts;typeof t=="string"&&(t=t.trim(),t.endsWith("ReactNode")&&(t="ReactNode"),e.meta.ts=t,t==="ReactNode"&&(e.hideFromUI=!0))}return e}function ia(e,t){let r=[...t.properties].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz";if(i==="inputs")return 1;let s=dr.indexOf(i),u=dr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)});return e.ts.factory.updateObjectLiteralExpression(t,r)}var dr=["component","name","description"];function aa(e,t){return[...t].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz",s=gr.indexOf(i),u=gr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)})}var gr=["name","type"];function it(e,t){for(let r of t.properties){if(!e.ts.isPropertyAssignment(r)||!e.ts.isIdentifier(r.name))continue;if(L(e,r)==="canHaveChildren"){let{initializer:o}=r;return o.kind===e.ts.SyntaxKind.TrueKeyword}}return!1}function Dr(e,t){let r=`Builder.registerComponent(
|
|
12
|
+
`}return""}function ot(e,t,r,n,o=!0){let i=t.properties.filter(s=>e.ts.isPropertyAssignment(s)),a=_i(e,t,r);return a>-1?n==null&&o?e.ts.factory.updateObjectLiteralExpression(t,i.filter((s,u)=>u!==a)):(i[a]=e.ts.factory.updatePropertyAssignment(i[a],i[a].name,ht(e,n)),e.ts.factory.updateObjectLiteralExpression(t,i)):(n!=null&&i.push(e.ts.factory.createPropertyAssignment(r,ht(e,n))),e.ts.factory.updateObjectLiteralExpression(t,i))}function _i(e,t,r){return t.properties.findIndex(n=>L(e,n)===r)}function Et(e,t){switch(t.kind){case e.ts.SyntaxKind.ArrayLiteralExpression:return Vi(e,t);case e.ts.SyntaxKind.ObjectLiteralExpression:return ji(e,t);case e.ts.SyntaxKind.StringLiteral:return t.text;case e.ts.SyntaxKind.NumericLiteral:return Number(t.text);case e.ts.SyntaxKind.NoSubstitutionTemplateLiteral:return t.text;case e.ts.SyntaxKind.TrueKeyword:return!0;case e.ts.SyntaxKind.FalseKeyword:return!1;case e.ts.SyntaxKind.Identifier:switch(t.escapedText){case"undefined":return;case"null":return null;case"String":return String;case"Number":return Number;case"Boolean":return Boolean;case"NaN":return NaN}}}function ji(e,t){let r={};if(t&&e.ts.isObjectLiteralExpression(t)){for(let n of t.properties)if(e.ts.isPropertyAssignment(n)){let o=L(e,n);o&&(r[o]=Et(e,n.initializer))}}return r}function Vi(e,t){return t&&e.ts.isArrayLiteralExpression(t)?t.elements.map(r=>Et(e,r)):[]}function L(e,t){if(t&&e.ts.isPropertyAssignment(t)){let r=t.name;switch(r.kind){case e.ts.SyntaxKind.Identifier:return r.text;case e.ts.SyntaxKind.StringLiteral:case e.ts.SyntaxKind.NumericLiteral:return r.text;case e.ts.SyntaxKind.ComputedPropertyName:let n=r.expression;if(e.ts.isStringLiteral(n)||e.ts.isNumericLiteral(n))return r.expression.text}}}function ht(e,t){return an(e,t,new WeakSet)}function an(e,t,r){return t===void 0?e.ts.factory.createIdentifier("undefined"):t===null?e.ts.factory.createIdentifier("null"):typeof t=="string"?e.ts.factory.createStringLiteral(t):typeof t=="number"?isNaN(t)?e.ts.factory.createIdentifier("NaN"):e.ts.factory.createNumericLiteral(t):t===!0?e.ts.factory.createTrue():t===!1?e.ts.factory.createFalse():t===String?e.ts.factory.createIdentifier("String"):t===Number?e.ts.factory.createIdentifier("Number"):t===Boolean?e.ts.factory.createIdentifier("Boolean"):Array.isArray(t)?$i(e,t,r):typeof t=="object"?Ki(e,t,r):e.ts.factory.createIdentifier(t)}function $i(e,t,r){let n=t.map(o=>an(e,o,r));return e.ts.factory.createArrayLiteralExpression(n,!0)}function Ki(e,t,r){if(r.has(t))return e.ts.factory.createIdentifier("undefined");r.add(t);let n=Object.keys(t).map(o=>e.ts.factory.createPropertyAssignment(o,an(e,t[o],r)));return e.ts.factory.createObjectLiteralExpression(n,!0)}function Ge(e,t,r){let n=[];if(!r)return n;let o=null;if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r)){let i=r.parameters;if(i.length>0){let a=i[0],s=t.getTypeAtLocation(a);s.aliasTypeArguments&&s.aliasTypeArguments.length>0&&(s=s.aliasTypeArguments[0]),!!(s.flags&e.ts.TypeFlags.Object)&&(o=s.getProperties())}}else if(e.ts.isIdentifier(r)){let i=t.getTypeAtLocation(r),a=i.symbol?.valueDeclaration;if(a&&e.ts.isClassDeclaration(a)){let u=a.heritageClauses?.find(p=>p.token===e.ts.SyntaxKind.ExtendsKeyword)?.types;if(u){for(let p of u)if(t.getSymbolAtLocation(p.expression)?.name==="Component"){if(e.ts.isExpressionWithTypeArguments(p)){let m=p.typeArguments;if(m){let c=m[0];o=t.getTypeFromTypeNode(c).getProperties()}}break}}}if(!o){let s=i.getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}else if(e.ts.isExportSpecifier(r)){let i=t.getSymbolAtLocation(r.name);if(i){let s=t.getTypeOfSymbolAtLocation(i,r).getCallSignatures();if(s.length>0){let u=s[0].getParameters();u.length>0&&(o=t.getTypeOfSymbolAtLocation(u[0],r).getProperties())}}}if(o)for(let i of o){let a=Mi(e,t,i);a&&n.push(a)}return n=n.filter(fr),n.length>0?n:Ui(e,r)}function Mi(e,t,r){let n=r.valueDeclaration,o=r.getName();if(n||(n=r.getDeclarations()?.[0]),n&&e.ts.isPropertySignature(n)){if(o!=="children"&&n.getSourceFile().fileName.includes("node_modules/@types/"))return null;let i="string",a;if(n?.type){let u=t.getTypeFromTypeNode(n.type),p=t.typeToString(u),f=sn(p);f.knownType?i=f.builderType:qi(p)||u.flags&e.ts.TypeFlags.StringLike?i="string":u.flags&e.ts.TypeFlags.NumberLike?i="number":u.flags&e.ts.TypeFlags.IndexedAccess?i="list":u.flags&e.ts.TypeFlags.Object||u.isUnion()&&u.types.every(m=>m.flags&e.ts.TypeFlags.Object)||u.isIntersection()&&u.types.some(m=>m.flags&e.ts.TypeFlags.Object)?i="object":i="string",p!==i&&(a=p)}let s={name:o,type:i,isRegistered:!1};if(a&&n.type){let u=Yi(e,t,t.getTypeFromTypeNode(n.type));s.meta=s.meta||{},u&&u.length>0&&s.type==="string"&&u.every(Wi)?s.enum=u.map(Qi):s.meta.ts=a}return n.questionToken||(s.required=!0),s}return null}function Ui(e,t){let r=[],n=e.ts.getJSDocCommentsAndTags(t);for(let o of n)if(!(!e.ts.isJSDoc(o)||!o.tags))for(let i of o.tags){if(!e.ts.isJSDocParameterTag(i)||i.tagName.text!=="param")continue;let s=i.typeExpression?.type;if(!s||!e.ts.isJSDocTypeLiteral(s))continue;let u=s.jsDocPropertyTags;if(u)for(let p of u){if(!e.ts.isJSDocPropertyLikeTag(p))continue;let f=p.name;if(!e.ts.isQualifiedName(f))continue;let m=p.typeExpression;if(!m)continue;let c="";switch(m.type.kind){case e.ts.SyntaxKind.StringKeyword:{c="string";break}case e.ts.SyntaxKind.NumberKeyword:{c="number";break}case e.ts.SyntaxKind.BooleanKeyword:{c="boolean";break}default:continue}let D={name:f.right.text,type:c,isRegistered:!1};r.push(D)}}return r.filter(fr)}var zi=["ClassicComponent","FunctionComponent","IntrinsicElements","JSX","ReactNode","ReactElement","ReactPortal"];function qi(e){return typeof e!="string"?!1:!!zi.some(t=>e.includes(t))}function sn(e){return typeof e=="string"&&(e=e.trim(),Ji.some(t=>t.value===e))?{builderType:e,knownType:!0}:{builderType:"string",knownType:!1}}var Ji=[{value:"boolean",text:"boolean"},{value:"color",text:"color (provides a color in hex or rgb)"},{value:"date",text:"date (same format as the Date constructor)"},{value:"email",text:"email"},{value:"file",text:"file (uploads a file and provides a url)"},{value:"list",text:"list (collection of items)"},{value:"longText",text:"longText (multiline text editor)"},{value:"number",text:"number"},{value:"object",text:"object (set of specific names and values)"},{value:"richText",text:"richText (provides value as html)"},{value:"string",text:"string"}];function Wi(e){return/^['"].*['"]$/.test(e)}function Qi(e){return(e.startsWith('"')||e.startsWith("'"))&&(e.endsWith('"')||e.endsWith("'"))?e.slice(1,-1):e}var Yi=(e,t,r)=>{let n=new Set;mr(e,t,r,n);let o=n.delete("true"),i=n.delete("false");(o||i)&&n.add("boolean");let a=Array.from(n.keys()).sort();if(a.length>1&&(a=a.map(s=>s.indexOf("=>")>=0?`(${s})`:s)),!(a.length>20))return a},Gi=(e,t,r)=>{let n=e.ts.TypeFormatFlags.InElementType|e.ts.TypeFormatFlags.NoTruncation;return t.typeToString(r,void 0,n)},mr=(e,t,r,n)=>{if(r.isUnion())r.types.forEach(o=>{mr(e,t,o,n)});else if(r.isLiteral()){let o=Gi(e,t,r);n.add(o)}};function fr(e){let t=e?.name;if(typeof t!="string"||t===""||t.startsWith("aria")||t.startsWith("data-"))return!1;if(t.startsWith("on")&&t.length>2){let r=t.charAt(2);if(r.toUpperCase()===r)return!1}return!Hi.has(t.toLowerCase())}var Hi=new Set(["about","accessKey","accessKeyLabel","asChild","autoCapitalize","autoCorrect","autoFocus","autoSave","blur","contentEditable","contextMenu","dangerouslySetInnerHTML","datatype","defaultChecked","defaultValue","dir","draggable","enterKeyHint","focus","form","formAction","formEncType","formMethod","formNoValidate","formTarget","inlist","innerText","inputMode","is","isContentEditable","itemID","itemProp","itemRef","itemScope","itemType","lang","nonce","offsetHeight","offsetLeft","offsetTop","offsetWidth","outerText","prefix","property","radioGroup","rel","resource","results","rev","role","security","slot","spellCheck","suppressContentEditableWarning","suppressHydrationWarning","tabIndex","translate","typeof","unselectable","vocab"].map(e=>e.toLowerCase()));function se(e,t,r){for(let n of r.properties){if(!e.ts.isPropertyAssignment(n))continue;let o=L(e,n);if(o==="name"&&e.ts.isStringLiteral(n.initializer)){t.name=n.initializer.text;continue}if(o==="description"&&e.ts.isStringLiteral(n.initializer)){t.description=n.initializer.text;continue}if(o==="image"&&e.ts.isStringLiteral(n.initializer)){t.image=n.initializer.text;continue}if(o==="inputs"&&e.ts.isArrayLiteralExpression(n.initializer)){let i=Xi(e,n.initializer);pe(t,i);continue}if(o==="meta"&&e.ts.isObjectLiteralExpression(n.initializer)){let i=Et(e,n.initializer);i&&typeof i=="object"&&(t.meta=i);continue}}return t}function Xi(e,t){let r=[];for(let n of t.elements)e.ts.isObjectLiteralExpression(n)&&r.push(Zi(e,n));return r}function Zi(e,t){let r=Et(e,t),n=aa(r);return n.isRegistered=!0,n}function W(e,t,r){let n=ta(r);return t=ot(e,t,"name",n.name,!1),t=ot(e,t,"description",n.description),t=ot(e,t,"image",n.image),t=ot(e,t,"meta",n.meta),t=ea(e,t,n),sa(e,t)}function ea(e,t,r){let n=null,o=t.properties.filter(s=>e.ts.isPropertyAssignment(s)&&e.ts.isIdentifier(s.name)),i=o.findIndex(s=>e.ts.isIdentifier(s.name)&&s.name.text==="inputs"),a=[...r.inputs??[]];if(i>-1){if(a.length===0)return ot(e,t,"inputs",null);let s=o[i];e.ts.isPropertyAssignment(s)&&e.ts.isArrayLiteralExpression(s.initializer)&&(n=s.initializer)}return a.length===0?t:(n=ra(e,n||e.ts.factory.createArrayLiteralExpression(),a),i>-1?o[i]=e.ts.factory.updatePropertyAssignment(o[i],o[i].name,n):o.push(e.ts.factory.createPropertyAssignment("inputs",n)),e.ts.factory.updateObjectLiteralExpression(t,o))}function ta(e){return{name:e.name,description:e.description,image:e.image,inputs:(e.inputs||[]).filter(r=>r.isRegistered).map(na),...e.meta?{meta:{...e.meta}}:{}}}function na(e){let t={name:e.name,type:e.type};return(re(e.defaultValue)||xt(e.defaultValue)||nt(e.defaultValue))&&(t.defaultValue=e.defaultValue),re(e.friendlyName)&&(t.friendlyName=e.friendlyName),re(e.helperText)&&(t.helperText=e.helperText),e.required===!0&&(t.required=!0),Array.isArray(e.enum)&&(t.enum=e.enum),e.hideFromUI===!0&&(t.hideFromUI=!0),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(t.meta=e.meta),t}function ra(e,t,r){let n=t.elements.filter(o=>{if(!e.ts.isObjectLiteralExpression(o))return!1;let i=o.properties.find(s=>L(e,s)==="name");if(!i)return!1;let a=i.initializer;return e.ts.isStringLiteral(a)?r.some(s=>s.name===a.text):!1});for(let o of r)n=oa(e,n,o);return n.sort((o,i)=>{let a=o.properties.find(c=>L(e,c)==="name"),s=i.properties.find(c=>L(e,c)==="name"),u=a?.initializer,p=s?.initializer,f=u&&e.ts.isStringLiteral(u)?u.text:"zz",m=p&&e.ts.isStringLiteral(p)?p.text:"zz";return f.toLowerCase().localeCompare(m.toLowerCase())}),e.ts.factory.updateArrayLiteralExpression(t,n)}function oa(e,t,r){let n=t.findIndex(o=>o.properties.some(i=>{let a=L(e,i);return e.ts.isPropertyAssignment(i)&&a==="name"&&e.ts.isStringLiteral(i.initializer)&&i.initializer.text===r.name}));if(n>-1)t[n]=dr(e,t[n],r);else{let o=dr(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("name",e.ts.factory.createStringLiteral(r.name))],!0),r);t.push(o)}return t}function dr(e,t,r){let n=t.properties.filter(i=>e.ts.isPropertyAssignment(i)),o=Object.keys(r).filter(i=>i!=="isRegistered");for(let i of o)n=ia(e,n,r,i);return n=ua(e,n.filter(i=>{let a=L(e,i);return o.includes(a)})),e.ts.factory.updateObjectLiteralExpression(t,n)}function ia(e,t,r,n){let o=t.findIndex(i=>e.ts.isIdentifier(i.name)&&i.name.text===n);return o>-1?t[o]=e.ts.factory.updatePropertyAssignment(t[o],t[o].name,ht(e,r[n])):t.push(e.ts.factory.createPropertyAssignment(n,ht(e,r[n]))),t}function pe(e,t){for(let r of t){let n=e.inputs.findIndex(o=>o.name===r.name);n>-1?(r.isRegistered||!e.inputs[n].isRegistered)&&(e.inputs[n]=r):e.inputs.push(r)}e.acceptsChildren=un(e)}function aa(e){let t=sn(e.type),r={name:e.name.trim(),type:t.builderType};return re(e.friendlyName)&&e.friendlyName.trim()!==e.name.trim()&&(r.friendlyName=e.friendlyName),(re(e.defaultValue)||xt(e.defaultValue)||nt(e.defaultValue))&&(r.defaultValue=e.defaultValue),re(e.helperText)&&(r.helperText=e.helperText),nt(e.required)&&(r.required=e.required),typeof e.meta=="object"&&e.meta!=null&&Object.keys(e.meta).length>0&&(r.meta=e.meta),Array.isArray(e.enum)&&e.enum.length>0&&(r.enum=e.enum),e.hideFromUI===!0&&(r.hideFromUI=!0),pn(r)}function un(e){let t=e.inputs.some(n=>n.name==="children"),r=e.inputs.some(n=>n.meta?.ts==="ReactNode");return!!(t||r||e.acceptsChildren===!0)}function pn(e){if(e.name==="children"&&(e.hideFromUI=!0,delete e.required),e.type==="object"&&e.defaultValue==null&&(e.hideFromUI=!0),e.type==="list"&&e.defaultValue==null&&(e.hideFromUI=!0),e.meta){let t=e.meta.ts;typeof t=="string"&&(t=t.trim(),t.endsWith("ReactNode")&&(t="ReactNode"),e.meta.ts=t,t==="ReactNode"&&(e.hideFromUI=!0))}return e}function sa(e,t){let r=[...t.properties].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz";if(i==="inputs")return 1;let s=gr.indexOf(i),u=gr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)});return e.ts.factory.updateObjectLiteralExpression(t,r)}var gr=["component","name","description"];function ua(e,t){return[...t].sort((n,o)=>{let i=L(e,n)||"zz",a=L(e,o)||"zz",s=Dr.indexOf(i),u=Dr.indexOf(a);return s>-1?u>-1&&s>u?1:-1:u>-1?s>-1&&u<s?-1:1:i.localeCompare(a)})}var Dr=["name","type"];function it(e,t){for(let r of t.properties){if(!e.ts.isPropertyAssignment(r)||!e.ts.isIdentifier(r.name))continue;if(L(e,r)==="canHaveChildren"){let{initializer:o}=r;return o.kind===e.ts.SyntaxKind.TrueKeyword}}return!1}function xr(e,t){let r=`Builder.registerComponent(
|
|
13
13
|
`;if(e.appDir)t.acceptsChildren?r+=` withChildren(${t.importName}),
|
|
14
14
|
`:r+=` ${t.importName},
|
|
15
15
|
`;else{let o=t.externalImportPath?t.externalImportPath:N(e,e.registryPath,t.filePath);t.exportName==="default"?t.acceptsChildren?r+=` withChildren(dynamic(() => import(${JSON.stringify(o)}))),
|
|
@@ -19,8 +19,8 @@ ${r}=${n}
|
|
|
19
19
|
`}r+=` {
|
|
20
20
|
name: "${t.name}",
|
|
21
21
|
}
|
|
22
|
-
`,r+=");";let n=Lt(e,r);return
|
|
23
|
-
`,getSourceFile:s=>{if(s=e.normalize(s),s.includes("node_modules")){let p=St.get(s);if(p)return b(e,p.content)}let u;try{u=e.readFileSync(s)}catch{console.error(`Could not read: ${s}`),u==null}if(u==null){let p=e.basename(s),f=e.extname(p).toLowerCase();if(s.startsWith(o)&&f===".ts"&&(u=Cr.get(p),u==null&&typeof self<"u"&&typeof fetch=="function"))throw new jt(p)}return s.includes("node_modules")&&(u?St.set(s,{exists:!0,content:u}):St.set(s,{exists:!1})),b(e,u)},readFile:s=>{let u=e.readFileSync(s);return typeof u=="string"?u:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return sa(e,a,t,r)}catch(s){if(s instanceof jt){await ua(e,s.libName);continue}throw e.Sentry?.captureException(s),new Error(`createTsProgram() Could not create program for: ${t[0]}`,{cause:s})}}function sa(e,t,r,n){let o={rootNames:[...r],host:t,options:{}},i=e.ts.findConfigFile(e.dirname(r[0]),a=>e.existsSync(a));if(i){let a=xr.get(i);if(!a){let s=e.ts.readConfigFile(i,u=>{let p=e.readFileSync(u);return typeof p=="string"?p:void 0});s.error?e.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:s.error,tsConfigPath:i}}):(a=e.ts.parseJsonConfigFileContent(s.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(p,f)=>e.readdirSync(p),fileExists:p=>e.existsSync(p),readFile:p=>e.readFileSync(p)||void 0},e.dirname(i),void 0,i).options,xr.set(i,a))}a&&(o.options=ue(a))}return o.options.noEmit=!0,o.options.isolatedModules=!1,o.options.strict=!1,o.options.jsx=e.ts.JsxEmit.Preserve,o.options.allowJs=!0,Object.assign(o.options,n),e.ts.createProgram(o)}async function at(e,t,r){r||(r=await G(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var jt=class{constructor(t){this.libName=t}};async function ua(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;_t.has(t)||_t.set(t,fetch(r).then(n=>n.text()).then(n=>{Cr.set(t,n)})),await _t.get(t),_t.delete(t)}var Cr=new Map,_t=new Map,St=new Map,xr=new Map;function I(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=pa(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=ca(e,t,r.defaultImport,r.importPath,n)),t}function pa(e,t,r,n,o,i){return i==="cjs"?Er(e,t,null,r,n):hr(e,t,null,r,n,o)}function ca(e,t,r,n,o){return o==="cjs"?Er(e,t,r,null,n):hr(e,t,r,null,n,!1)}function hr(e,t,r,n,o,i){let a=[...t.statements],s=0,u=!1,p=!1;for(let d=0;d<a.length;d++){let D=a[d];if(!e.ts.isImportDeclaration(D)||(s=d,!D.moduleSpecifier||!e.ts.isStringLiteral(D.moduleSpecifier))||D.moduleSpecifier.text!==o||!!D.importClause?.isTypeOnly!==i)continue;let g=[],x=D.importClause?.namedBindings;if(x&&e.ts.isNamedImports(x)&&x.elements&&g.push(...x.elements),typeof n=="string"){if(g.some(C=>C.name.text===n))return t;g.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),g.sort((C,E)=>C.name.text.localeCompare(E.name.text)),u=!0}let l=D.importClause?D.importClause.name:void 0;if(typeof r=="string"){if(l&&l.text===r)return t;l=e.ts.factory.createIdentifier(r),p=!0}if(u||p)return a[d]=e.ts.factory.updateImportDeclaration(D,void 0,e.ts.factory.createImportClause(i,l,e.ts.factory.createNamedImports(g)),D.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let f,m;typeof r=="string"&&(f=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let c=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,f,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,c),e.ts.factory.updateSourceFile(t,a)}function Er(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let u=i[s];if(e.ts.isVariableStatement(u))for(let p=0;p<u.declarationList.declarations.length;p++){let f=[...u.declarationList.declarations],m=f[p],c=m.initializer;if(!c||!e.ts.isCallExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="require"||c.arguments.length!==1)continue;let D=c.arguments[0];if(e.ts.isStringLiteral(D)&&(a=s,D.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let g=[...m.name.elements];return g.some(l=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)?!1:l.name.text===n)?t:(g.push(e.ts.factory.createBindingElement(void 0,void 0,n)),g.sort((l,C)=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:l.name.text.localeCompare(C.name.text)),f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(g),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function de(e,t,r="esm"){return r==="cjs"?ma(e,t):la(e,t)}function la(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}else!n.exportClause&&n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:n});continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function ma(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function fa(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function we(e,t,r,n){let o=fa(e,r,n);if(o){let i=await At(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getAppRootDir(),i);return{displayFilePath:O(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function st(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function J(e,t,r){let n=st(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function Vt(e,t){if(t){if(da(e,t))return!0;let r=!1;if(t.forEachChild(n=>{Vt(e,n)&&(r=!0)}),r)return!0}return!1}function da(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function At(e,t){let r=e.extname(t).toLowerCase();if(r===""||!cn.includes(r)){for(let n of cn){let o=t+n;if(await e.exists(o))return o}for(let n of cn){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var cn=[".tsx",".jsx",".ts",".js"];function ut(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=ga(e,i);return a?[{name:a}]:void 0}function ga(e,t){if(typeof t=="string"){t=e.normalize(he(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function ge(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}function Sr(e,t,r="esm"){return r==="cjs"?Ca(e,t):xa(e,t)}var Da=/^(@\w|\w)/;function xa(e,t){let r=[];for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&e.ts.isLiteralExpression(n.moduleSpecifier)){if(!Da.test(n.moduleSpecifier.text)||n.importClause?.isTypeOnly)continue;if(n.importClause&&n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings))for(let o of n.importClause.namedBindings.elements)o.isTypeOnly||r.push({isDefaultExport:!1,statement:n,node:o.name});n.importClause&&n.importClause.name&&r.push({isDefaultExport:!0,statement:n,node:n.importClause.name})}return r}function Ca(e,t){return[]}async function pt(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await G(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let p=(await Me(e,o,a.filePath,s,!1)).find(f=>f.cmpInfo.id===a.id);p&&(a.inputs=Ge(e,o,p.node.fnNode))}return a}))}async function ct(e,t,r,n){if(t.node.fnNode){let{sourceFile:o,typeChecker:i}=await at(e,t.cmpInfo.filePath,r),s=(await Me(e,i,t.cmpInfo.filePath,o,n)).find(u=>u.cmpInfo.id===t.cmpInfo.id);if(!s)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,s.node.fnNode)}return[]}async function Fr(e,t,r){let n=e.extname(t).toLowerCase();if(n===".tsx"||n===".jsx"||n===".ts"||n===".js"){let o=await e.readFile(t);if(o)return ha(e,t,o,r)}return null}function ha(e,t,r,n=!1){let o=b(e,r);return Me(e,null,t,o,n)}async function Me(e,t,r,n,o){let i=[];for(let s of n.statements)if(e.ts.isExpressionStatement(s)&&e.ts.isStringLiteral(s.expression)&&s.expression.text==="use server")return i;let a=de(e,n);return o&&a.push(...Sr(e,n)),r=e.normalize(r),await Promise.all(a.map(async s=>{let u=await Ea(e,t,r,s);i.push(...u)})),i}async function Ea(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!rt(s.name.text))continue;let u=_e(e,t,s.initializer);if(u){let p=u.name||s.name.text,f=n.isDefaultExport?"default":p,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:O(e,r),name:K(p),inputs:[],exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}}return o}if(e.ts.isArrowFunction(n.node)){let s=_e(e,t,n.node);if(s){let u=le(e,r),p=n.isDefaultExport?"default":u,f=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,p),displayFilePath:O(e,r),name:u,inputs:[],exportName:p,exportType:f,importName:Qe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps,framework:"react"},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!rt(s))return o;let u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:O(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Qe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}return o}if((e.ts.isExportSpecifier(n.node)||e.ts.isIdentifier(n.node))&&rt(n.node.getText())){let s,u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named",c=Sa(e,n.node)?.moduleSpecifier??Aa(e,n.node)?.moduleSpecifier;if(c&&e.ts.isStringLiteral(c)){let d=t?.getSymbolAtLocation(c);if(d&&d.declarations&&d.declarations.length>0){let D=d.declarations[0];(!e.ts.isSourceFile(D)||e.ts.isSourceFile(D)&&D.fileName.includes("node_modules"))&&(s=c.text)}}o.push({cmpInfo:{id:await V(e,r,f,s),displayFilePath:O(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Qe(e,r),filePath:r,relFilePath:i,importPath:s||a,externalImportPath:s,dependencies:u.deps,framework:"react"},node:u})}return o}if(e.ts.isExportDeclaration(n.node)&&n.node.exportClause===void 0){let s=n.node.moduleSpecifier;if(s&&e.ts.isStringLiteral(s)){let u=await Pa(e,t,r,s);o.push(...u)}return o}return o}function Sa(e,t){for(;t;){if(e.ts.isExportDeclaration(t))return t;t=t.parent}return null}function Aa(e,t){for(;t;){if(e.ts.isImportDeclaration(t))return t;t=t.parent}return null}function _e(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return Vt(e,r.body)?{name:"",fnNode:r,deps:ut(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return Vt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:ut(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(e.ts.isPropertyAccessExpression(n)){let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:_e(e,t,o[0])}else if(e.ts.isIdentifier(n)&&(n.text==="observer"||n.text==="forwardRef")){let o=r.arguments;return o.length===0?null:_e(e,t,o[0])}return null}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!rt(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:ut(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:ut(e,t,n)}}if(e.ts.isIdentifier(r))return{name:r.text||"",fnNode:r,deps:ut(e,t,r)};if(e.ts.isExpressionStatement(r)){let n=r.expression;if(e.ts.isAsExpression(n)&&e.ts.isIdentifier(n.type)&&n.type.text==="default")return _e(e,t,n.expression)}if(e.ts.isVariableStatement(r)){for(let n of r.declarationList.declarations)if(n.initializer&&e.ts.isAsExpression(n.initializer)){let o=n.initializer;if(e.ts.isIdentifier(o.type)&&o.type.text==="default"){let i=_e(e,t,o.expression);if(i&&e.ts.isIdentifier(n.name))return{name:n.name.text,fnNode:i.fnNode,deps:i.deps}}}}return null}async function Pr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(kt(e,Fa,i.fileName)||a===e.reactConfigPath||a===e.builderComponentPath)return;let s=await Me(e,o,a,i,a===e.registryPath);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Fa=new Set(["node_modules","dist"]);async function Pa(e,t,r,n){let o=[],i=n.text;if(!t)return o;try{let a=t.getSymbolAtLocation(n);if(!a)return o;let s=t.getExportsOfModule(a);for(let u of s){let p=u.valueDeclaration||u.declarations?.[0];if(!p)continue;let f=u.name;if(!rt(f)&&f!=="default"||!yr(e,t,p))continue;let m=_e(e,t,p);if(m){let c=u.name,d=c==="default"?"default":"named",D=K(c),g=c==="default"?Qe(e,r):c;o.push({cmpInfo:{id:await V(e,r,c,i),displayFilePath:O(e,r),name:D,inputs:[],exportName:c,exportType:d,importName:g,filePath:r,relFilePath:e.relative(e.getAppRootDir(),r),importPath:i,externalImportPath:i,dependencies:m.deps,framework:"react"},node:m})}}}catch(a){e.Sentry?.captureException(new Error(`Error processing module ${i}:`,{cause:a}),{extra:{modulePath:i,filePath:r}})}return o}function yr(e,t,r){if(e.ts.isInterfaceDeclaration(r)||e.ts.isTypeAliasDeclaration(r))return!1;if(e.ts.isExportSpecifier(r)){let n=t.getSymbolAtLocation(r.name);if(n){let i=t.getAliasedSymbol(n).declarations?.[0];if(i)return yr(e,t,i)}return!1}if(e.ts.isFunctionDeclaration(r)||e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)){let n=t.getSignatureFromDeclaration(r);if(n){let o=t.getReturnTypeOfSignature(n);return Ar(o,t)}}return e.ts.isClassDeclaration(r)?r.heritageClauses?.some(o=>o.types.some(i=>i.expression.getText()==="React.Component"||i.expression.getText()==="Component"))??!1:e.ts.isVariableDeclaration(r)?t.getTypeAtLocation(r).getCallSignatures().some(i=>Ar(t.getReturnTypeOfSignature(i),t)):!1}function Ar(e,t){let r=t.typeToString(e);return r==="JSX.Element"||r==="Element"||r.includes("ReactElement")||r.includes("React.ReactElement")||r.includes("ReactNode")}async function wr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&ya.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.builderComponentPath)return;let u=await Me(e,o,s,i,s===e.registryPath||Ae(s));r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var ya=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ve(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let u=a.moduleSpecifier.text;if(!u.startsWith(".")&&!u.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...ln(e,r),...ln(e,n),...ln(e,o),...i])}function De(e){let t=e.split(`
|
|
22
|
+
`,r+=");";let n=Lt(e,r);return cn(e,n,t)}function cn(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;r.acceptsChildren?e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"||(o[0]=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[o[0]])):e.ts.isCallExpression(o[0])&&e.ts.isIdentifier(o[0].expression)&&o[0].expression.text==="withChildren"&&(o[0]=o[0].arguments[0]);let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=W(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function G(e,t,r){if(!Array.isArray(t)||t.length===0)throw new Error(`createTsProgram() Invalid filePaths: ${t}`);let n=await er(e,t[0]),o=e.join(n,"typescript","lib"),i=new Map,a={fileExists:s=>{if(s=e.normalize(s),s.includes("node_modules")){let u=St.get(s);if(!u){try{e.statSync(s).isFile()?u={exists:!0,content:e.readFileSync(s)}:u={exists:!1}}catch{u={exists:!1}}St.set(s,u)}return u.exists}if(!i.has(s))if(e.existsSync(s)){let p=e.statSync(s);i.set(s,p.isFile())}else i.set(s,!1);return i.get(s)},getCanonicalFileName:s=>e.normalize(s),getCurrentDirectory:()=>e.cwd(),getDefaultLibFileName:()=>e.join(o,"lib.d.ts"),getDefaultLibLocation:()=>o,getNewLine:()=>`
|
|
23
|
+
`,getSourceFile:s=>{if(s=e.normalize(s),s.includes("node_modules")){let p=St.get(s);if(p)return b(e,p.content)}let u;try{u=e.readFileSync(s)}catch{console.error(`Could not read: ${s}`),u==null}if(u==null){let p=e.basename(s),f=e.extname(p).toLowerCase();if(s.startsWith(o)&&f===".ts"&&(u=hr.get(p),u==null&&typeof self<"u"&&typeof fetch=="function"))throw new jt(p)}return s.includes("node_modules")&&(u?St.set(s,{exists:!0,content:u}):St.set(s,{exists:!1})),b(e,u)},readFile:s=>{let u=e.readFileSync(s);return typeof u=="string"?u:void 0},useCaseSensitiveFileNames:()=>!1,writeFile:()=>{}};for(;;)try{return pa(e,a,t,r)}catch(s){if(s instanceof jt){await ca(e,s.libName);continue}throw e.Sentry?.captureException(s),new Error(`createTsProgram() Could not create program for: ${t[0]}`,{cause:s})}}function pa(e,t,r,n){let o={rootNames:[...r],host:t,options:{}},i=e.ts.findConfigFile(e.dirname(r[0]),a=>e.existsSync(a));if(i){let a=Cr.get(i);if(!a){let s=e.ts.readConfigFile(i,u=>{let p=e.readFileSync(u);return typeof p=="string"?p:void 0});s.error?e.Sentry?.captureException(new Error("Error reading tsconfig for createTsProgram"),{extra:{error:s.error,tsConfigPath:i}}):(a=e.ts.parseJsonConfigFileContent(s.config,e.ts.sys||{useCaseSensitiveFileNames:!1,readDirectory:(p,f)=>e.readdirSync(p),fileExists:p=>e.existsSync(p),readFile:p=>e.readFileSync(p)||void 0},e.dirname(i),void 0,i).options,Cr.set(i,a))}a&&(o.options=ue(a))}return o.options.noEmit=!0,o.options.isolatedModules=!1,o.options.strict=!1,o.options.jsx=e.ts.JsxEmit.Preserve,o.options.allowJs=!0,Object.assign(o.options,n),e.ts.createProgram(o)}async function at(e,t,r){r||(r=await G(e,[t]));let n=r.getSourceFile(t);if(!n)throw new Error(`getTypeChecker() Could not find source file: ${t}`);return{typeChecker:r.getTypeChecker(),sourceFile:n}}var jt=class{constructor(t){Xn(this,"libName");this.libName=t}};async function ca(e,t){let r=`https://cdn.jsdelivr.net/npm/typescript@${e.ts.version}/lib/${t}`;_t.has(t)||_t.set(t,fetch(r).then(n=>n.text()).then(n=>{hr.set(t,n)})),await _t.get(t),_t.delete(t)}var hr=new Map,_t=new Map,St=new Map,Cr=new Map;function I(e,t,r,n="esm"){return Array.isArray(r.namedImports)&&r.namedImports.forEach(o=>{t=la(e,t,o,r.importPath,!!r.isTypeOnly,n)}),typeof r.defaultImport=="string"&&(t=ma(e,t,r.defaultImport,r.importPath,n)),t}function la(e,t,r,n,o,i){return i==="cjs"?Sr(e,t,null,r,n):Er(e,t,null,r,n,o)}function ma(e,t,r,n,o){return o==="cjs"?Sr(e,t,r,null,n):Er(e,t,r,null,n,!1)}function Er(e,t,r,n,o,i){let a=[...t.statements],s=0,u=!1,p=!1;for(let d=0;d<a.length;d++){let D=a[d];if(!e.ts.isImportDeclaration(D)||(s=d,!D.moduleSpecifier||!e.ts.isStringLiteral(D.moduleSpecifier))||D.moduleSpecifier.text!==o||!!D.importClause?.isTypeOnly!==i)continue;let g=[],x=D.importClause?.namedBindings;if(x&&e.ts.isNamedImports(x)&&x.elements&&g.push(...x.elements),typeof n=="string"){if(g.some(C=>C.name.text===n))return t;g.push(e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))),g.sort((C,E)=>C.name.text.localeCompare(E.name.text)),u=!0}let l=D.importClause?D.importClause.name:void 0;if(typeof r=="string"){if(l&&l.text===r)return t;l=e.ts.factory.createIdentifier(r),p=!0}if(u||p)return a[d]=e.ts.factory.updateImportDeclaration(D,void 0,e.ts.factory.createImportClause(i,l,e.ts.factory.createNamedImports(g)),D.moduleSpecifier,void 0),e.ts.factory.updateSourceFile(t,a)}let f,m;typeof r=="string"&&(f=e.ts.factory.createIdentifier(r)),typeof n=="string"&&(m=e.ts.factory.createNamedImports([e.ts.factory.createImportSpecifier(!1,void 0,e.ts.factory.createIdentifier(n))]));let c=e.ts.factory.createImportDeclaration(void 0,e.ts.factory.createImportClause(i,f,m),e.ts.factory.createStringLiteral(o));return a.splice(s,0,c),e.ts.factory.updateSourceFile(t,a)}function Sr(e,t,r,n,o){let i=[...t.statements],a=0;for(let s=0;s<i.length;s++){let u=i[s];if(e.ts.isVariableStatement(u))for(let p=0;p<u.declarationList.declarations.length;p++){let f=[...u.declarationList.declarations],m=f[p],c=m.initializer;if(!c||!e.ts.isCallExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="require"||c.arguments.length!==1)continue;let D=c.arguments[0];if(e.ts.isStringLiteral(D)&&(a=s,D.text===o)){if(e.ts.isIdentifier(m.name)&&typeof r=="string")return m.name.text===r?t:(f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createIdentifier(r),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i));if(e.ts.isObjectBindingPattern(m.name)&&typeof n=="string"){let g=[...m.name.elements];return g.some(l=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)?!1:l.name.text===n)?t:(g.push(e.ts.factory.createBindingElement(void 0,void 0,n)),g.sort((l,C)=>!e.ts.isBindingElement(l)||!e.ts.isIdentifier(l.name)||!e.ts.isBindingElement(C)||!e.ts.isIdentifier(C.name)?0:l.name.text.localeCompare(C.name.text)),f[p]=e.ts.factory.updateVariableDeclaration(m,e.ts.factory.createObjectBindingPattern(g),m.exclamationToken,m.type,m.initializer),i[s]=e.ts.factory.updateVariableStatement(u,u.modifiers,e.ts.factory.updateVariableDeclarationList(u.declarationList,f)),e.ts.factory.updateSourceFile(t,i))}}}}if(typeof r=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}if(typeof n=="string"){let s=e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(e.ts.factory.createObjectBindingPattern([e.ts.factory.createBindingElement(void 0,void 0,n)]),void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral(o)]))],e.ts.NodeFlags.Const));return i.splice(a,0,s),e.ts.factory.updateSourceFile(t,i)}return t}function de(e,t,r="esm"){return r==="cjs"?da(e,t):fa(e,t)}function fa(e,t){let r=[];for(let n of t.statements){if(e.ts.isExportDeclaration(n)){if(n.exportClause&&e.ts.isNamedExports(n.exportClause)){for(let o of n.exportClause.elements)if(n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:o}),e.ts.isIdentifier(o.name)){let i=o.name.text;for(let a of t.statements)if(e.ts.isVariableStatement(a))for(let s of a.declarationList.declarations)e.ts.isIdentifier(s.name)&&s.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a});else e.ts.isFunctionDeclaration(a)&&a.name&&a.name.text===i&&r.push({isDefaultExport:!1,statement:a,node:a})}}else!n.exportClause&&n.moduleSpecifier&&r.push({isDefaultExport:!1,statement:n,node:n});continue}if(e.ts.isExportAssignment(n)){let o=n.flags===e.ts.NodeFlags.None,i=n.expression;if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements){if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:o,statement:s,node:s});e.ts.isFunctionDeclaration(s)&&s.name?.text===a&&r.push({isDefaultExport:o,statement:s,node:s})}}else(e.ts.isArrowFunction(i)||e.ts.isCallExpression(i)||e.ts.isFunctionDeclaration(i)||e.ts.isObjectLiteralExpression(i))&&r.push({isDefaultExport:o,statement:n,node:i});continue}if((e.ts.isVariableStatement(n)||e.ts.isFunctionDeclaration(n))&&n.modifiers&&n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.ExportKeyword)){r.push({isDefaultExport:n.modifiers.some(o=>o.kind===e.ts.SyntaxKind.DefaultKeyword),statement:n,node:n});continue}}return r}function da(e,t){let r=[];for(let n of t.statements)if(e.ts.isExpressionStatement(n)&&e.ts.isBinaryExpression(n.expression)&&e.ts.isPropertyAccessExpression(n.expression.left)){let o=n.expression.left,i=n.expression.right;if(!e.ts.isIdentifier(o.expression))continue;if(o.expression.text==="module"&&o.name.text==="exports"){if(e.ts.isIdentifier(i)){let a=i.text;for(let s of t.statements)if(e.ts.isVariableStatement(s))for(let u of s.declarationList.declarations)e.ts.isIdentifier(u.name)&&u.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s});else e.ts.isFunctionDeclaration(s)&&s.name&&s.name.text===a&&r.push({isDefaultExport:!0,statement:s,node:s})}else r.push({isDefaultExport:!0,statement:n,node:i});continue}}return r}function ga(e,t,r){for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&n.importClause){if(n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings)){for(let o of n.importClause.namedBindings.elements)if(e.ts.isIdentifier(o.name)&&o.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"named"}}if(n.importClause.name&&n.importClause.name.text===r&&e.ts.isStringLiteral(n.moduleSpecifier))return{importPath:n.moduleSpecifier.text,exportType:"default"}}return null}async function we(e,t,r,n){let o=ga(e,r,n);if(o){let i=await At(e,e.normalize(e.resolve(e.dirname(t),o.importPath))),a=e.relative(e.getAppRootDir(),i);return{displayFilePath:O(e,i),filePath:i,relFilePath:a,importPath:o.importPath,exportType:o.exportType}}return null}function st(e,t,r){for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(e.ts.isVariableStatement(o)){for(let i of o.declarationList.declarations)if(e.ts.isIdentifier(i.name)&&i.name.text===r)return{statement:o,statementIndex:n}}}return null}function J(e,t,r){let n=st(e,t,r);if(n&&n.statement.declarationList.declarations.length>0){let o=n.statement.declarationList.declarations[0];if(o.initializer&&e.ts.isArrayLiteralExpression(o.initializer))return{statement:n.statement,statementIndex:n.statementIndex,variableDeclaration:o,arrayLiteralExp:o.initializer}}return null}function Vt(e,t){if(t){if(Da(e,t))return!0;let r=!1;if(t.forEachChild(n=>{Vt(e,n)&&(r=!0)}),r)return!0}return!1}function Da(e,t){return e.ts.isJsxElement(t)||e.ts.isJsxOpeningElement(t)||e.ts.isJsxOpeningFragment(t)||e.ts.isJsxSelfClosingElement(t)||e.ts.isJsxFragment(t)||e.ts.isJsxChild(t)}async function At(e,t){let r=e.extname(t).toLowerCase();if(r===""||!ln.includes(r)){for(let n of ln){let o=t+n;if(await e.exists(o))return o}for(let n of ln){let o=e.join(t,"index"+n);if(await e.exists(o))return o}}return t}var ln=[".tsx",".jsx",".ts",".js"];function ut(e,t,r){if(!r||!t)return;let n=t.getSymbolAtLocation(r);if(!n)return;let o=n.valueDeclaration;if(!o)return;let i=o.getSourceFile().fileName,a=xa(e,i);return a?[{name:a}]:void 0}function xa(e,t){if(typeof t=="string"){t=e.normalize(he(t));let r=t.split("/"),n=r.lastIndexOf("node_modules");if(n>-1){let o=r.slice(n+1),i=o[0];if(i)return i.startsWith("@")&&o[1]&&(i+="/"+o[1]),i}}}function ge(e){let t=[];for(let r of e)if(r.dependencies)for(let n of r.dependencies)t.some(o=>o.name===n.name)||t.push({...n});return t.sort((r,n)=>r.name.localeCompare(n.name))}function Ar(e,t,r="esm"){return r==="cjs"?Ea(e,t):ha(e,t)}var Ca=/^(@\w|\w)/;function ha(e,t){let r=[];for(let n of t.statements)if(e.ts.isImportDeclaration(n)&&e.ts.isLiteralExpression(n.moduleSpecifier)){if(!Ca.test(n.moduleSpecifier.text)||n.importClause?.isTypeOnly)continue;if(n.importClause&&n.importClause.namedBindings&&e.ts.isNamedImports(n.importClause.namedBindings))for(let o of n.importClause.namedBindings.elements)o.isTypeOnly||r.push({isDefaultExport:!1,statement:n,node:o.name});n.importClause&&n.importClause.name&&r.push({isDefaultExport:!0,statement:n,node:n.importClause.name})}return r}function Ea(e,t){return[]}async function pt(e,t){if(!t.some(a=>!a.isRegistered))return t;let n=await G(e,t.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(t.map(async a=>{let s=n.getSourceFile(a.filePath);if(s){let p=(await Me(e,o,a.filePath,s,!1)).find(f=>f.cmpInfo.id===a.id);p&&(a.inputs=Ge(e,o,p.node.fnNode))}return a}))}async function ct(e,t,r,n){if(t.node.fnNode){let{sourceFile:o,typeChecker:i}=await at(e,t.cmpInfo.filePath,r),s=(await Me(e,i,t.cmpInfo.filePath,o,n)).find(u=>u.cmpInfo.id===t.cmpInfo.id);if(!s)throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,s.node.fnNode)}return[]}async function Pr(e,t,r){let n=e.extname(t).toLowerCase();if(n===".tsx"||n===".jsx"||n===".ts"||n===".js"){let o=await e.readFile(t);if(o)return Sa(e,t,o,r)}return null}function Sa(e,t,r,n=!1){let o=b(e,r);return Me(e,null,t,o,n)}async function Me(e,t,r,n,o){let i=[];for(let s of n.statements)if(e.ts.isExpressionStatement(s)&&e.ts.isStringLiteral(s.expression)&&s.expression.text==="use server")return i;let a=de(e,n);return o&&a.push(...Ar(e,n)),r=e.normalize(r),await Promise.all(a.map(async s=>{let u=await Aa(e,t,r,s);i.push(...u)})),i}async function Aa(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);if(e.ts.isVariableStatement(n.node)){for(let s of n.node.declarationList.declarations){if(!e.ts.isIdentifier(s.name)||!rt(s.name.text))continue;let u=_e(e,t,s.initializer);if(u){let p=u.name||s.name.text,f=n.isDefaultExport?"default":p,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:O(e,r),name:K(p),inputs:[],exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}}return o}if(e.ts.isArrowFunction(n.node)){let s=_e(e,t,n.node);if(s){let u=le(e,r),p=n.isDefaultExport?"default":u,f=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,p),displayFilePath:O(e,r),name:u,inputs:[],exportName:p,exportType:f,importName:Qe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:s.deps,framework:"react"},node:s})}return o}if(e.ts.isFunctionExpression(n.node)||e.ts.isFunctionDeclaration(n.node)){let s=n.node.name?.text;if(s&&!rt(s))return o;let u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named";o.push({cmpInfo:{id:await V(e,r,f),displayFilePath:O(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Qe(e,r),filePath:r,relFilePath:i,importPath:a,dependencies:u.deps,framework:"react"},node:u})}return o}if((e.ts.isExportSpecifier(n.node)||e.ts.isIdentifier(n.node))&&rt(n.node.getText())){let s,u=_e(e,t,n.node);if(u){let p=u.name||le(e,r),f=n.isDefaultExport||!u.name?"default":u.name,m=n.isDefaultExport?"default":"named",c=Fa(e,n.node)?.moduleSpecifier??Pa(e,n.node)?.moduleSpecifier;if(c&&e.ts.isStringLiteral(c)){let d=t?.getSymbolAtLocation(c);if(d&&d.declarations&&d.declarations.length>0){let D=d.declarations[0];(!e.ts.isSourceFile(D)||e.ts.isSourceFile(D)&&D.fileName.includes("node_modules"))&&(s=c.text)}}o.push({cmpInfo:{id:await V(e,r,f,s),displayFilePath:O(e,r),name:p,inputs:[],exportName:f,exportType:m,importName:u.name||Qe(e,r),filePath:r,relFilePath:i,importPath:s||a,externalImportPath:s,dependencies:u.deps,framework:"react"},node:u})}return o}if(e.ts.isExportDeclaration(n.node)&&n.node.exportClause===void 0){let s=n.node.moduleSpecifier;if(s&&e.ts.isStringLiteral(s)){let u=await wa(e,t,r,s);o.push(...u)}return o}return o}function Fa(e,t){for(;t;){if(e.ts.isExportDeclaration(t))return t;t=t.parent}return null}function Pa(e,t){for(;t;){if(e.ts.isImportDeclaration(t))return t;t=t.parent}return null}function _e(e,t,r){if(!r)return null;if(e.ts.isArrowFunction(r))return Vt(e,r.body)?{name:"",fnNode:r,deps:ut(e,t,r)}:null;if(e.ts.isFunctionExpression(r)||e.ts.isFunctionDeclaration(r))return Vt(e,r.body)?{name:r.name?.text||"",fnNode:r,deps:ut(e,t,r)}:null;if(e.ts.isCallExpression(r)){let n=r.expression;if(e.ts.isPropertyAccessExpression(n)){let o=r.arguments;if(o.length===0)return null;let i=n.expression;if(!e.ts.isIdentifier(i)||i.text!=="React")return null;let a=n.name;return!e.ts.isIdentifier(a)||a.text!=="forwardRef"?null:_e(e,t,o[0])}else if(e.ts.isIdentifier(n)&&(n.text==="observer"||n.text==="forwardRef")){let o=r.arguments;return o.length===0?null:_e(e,t,o[0])}return null}if(!t)return null;if(e.ts.isPropertyAccessExpression(r)){let n=r.expression,o=r.name;if(!e.ts.isIdentifier(n)||!e.ts.isIdentifier(o)||!rt(o.text))return null;let a=t.getTypeAtLocation(o).getCallSignatures();if(a.length>0&&a[0].getParameters().length>0)return{name:"",fnNode:o,deps:ut(e,t,o)}}if(e.ts.isExportSpecifier(r)){let n=r.name;return{name:n.text||"",fnNode:n,deps:ut(e,t,n)}}if(e.ts.isIdentifier(r))return{name:r.text||"",fnNode:r,deps:ut(e,t,r)};if(e.ts.isExpressionStatement(r)){let n=r.expression;if(e.ts.isAsExpression(n)&&e.ts.isIdentifier(n.type)&&n.type.text==="default")return _e(e,t,n.expression)}if(e.ts.isVariableStatement(r)){for(let n of r.declarationList.declarations)if(n.initializer&&e.ts.isAsExpression(n.initializer)){let o=n.initializer;if(e.ts.isIdentifier(o.type)&&o.type.text==="default"){let i=_e(e,t,o.expression);if(i&&e.ts.isIdentifier(n.name))return{name:n.name.text,fnNode:i.fnNode,deps:i.deps}}}}return null}async function yr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.normalize(i.fileName);if(kt(e,ya,i.fileName)||a===e.reactConfigPath||a===e.builderComponentPath)return;let s=await Me(e,o,a,i,a===e.registryPath);r.push(...s)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var ya=new Set(["node_modules","dist"]);async function wa(e,t,r,n){let o=[],i=n.text;if(!t)return o;try{let a=t.getSymbolAtLocation(n);if(!a)return o;let s=t.getExportsOfModule(a);for(let u of s){let p=u.valueDeclaration||u.declarations?.[0];if(!p)continue;let f=u.name;if(!rt(f)&&f!=="default"||!wr(e,t,p))continue;let m=_e(e,t,p);if(m){let c=u.name,d=c==="default"?"default":"named",D=K(c),g=c==="default"?Qe(e,r):c;o.push({cmpInfo:{id:await V(e,r,c,i),displayFilePath:O(e,r),name:D,inputs:[],exportName:c,exportType:d,importName:g,filePath:r,relFilePath:e.relative(e.getAppRootDir(),r),importPath:i,externalImportPath:i,dependencies:m.deps,framework:"react"},node:m})}}}catch(a){e.Sentry?.captureException(new Error(`Error processing module ${i}:`,{cause:a}),{extra:{modulePath:i,filePath:r}})}return o}function wr(e,t,r){if(e.ts.isInterfaceDeclaration(r)||e.ts.isTypeAliasDeclaration(r))return!1;if(e.ts.isExportSpecifier(r)){let n=t.getSymbolAtLocation(r.name);if(n){let i=t.getAliasedSymbol(n).declarations?.[0];if(i)return wr(e,t,i)}return!1}if(e.ts.isFunctionDeclaration(r)||e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r)){let n=t.getSignatureFromDeclaration(r);if(n){let o=t.getReturnTypeOfSignature(n);return Fr(o,t)}}return e.ts.isClassDeclaration(r)?r.heritageClauses?.some(o=>o.types.some(i=>i.expression.getText()==="React.Component"||i.expression.getText()==="Component"))??!1:e.ts.isVariableDeclaration(r)?t.getTypeAtLocation(r).getCallSignatures().some(i=>Fr(t.getReturnTypeOfSignature(i),t)):!1}function Fr(e,t){let r=t.typeToString(e);return r==="JSX.Element"||r==="Element"||r.includes("ReactElement")||r.includes("React.ReactElement")||r.includes("ReactNode")}async function vr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(e.appDir&&va.has(a)||e.dirname(i.fileName).includes("node_modules"))return;let s=e.normalize(i.fileName);if(s===e.nextConfigPath||s===e.builderComponentPath)return;let u=await Me(e,o,s,i,s===e.registryPath||Ae(s));r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var va=new Set(["default.tsx","default.ts","default.jsx","default.js","error.tsx","error.ts","error.jsx","error.js","layout.tsx","layout.ts","layout.jsx","layout.js","loading.tsx","loading.ts","loading.jsx","loading.js","not-found.tsx","not-found.ts","not-found.jsx","not-found.js","page.tsx","page.ts","page.jsx","page.js","route.tsx","route.ts","route.jsx","route.js","template.tsx","template.ts","template.jsx","template.js"]);function ve(e,t){let r=[],n=[],o=[],i=[];for(let a of t.statements){if(e.ts.isImportDeclaration(a)){if(e.ts.isStringLiteral(a.moduleSpecifier)){let u=a.moduleSpecifier.text;if(!u.startsWith(".")&&!u.startsWith("/")){r.push(a);continue}}let s=a.importClause;if(s){if(s.namedBindings){n.push(a);continue}if(s.name){n.push(a);continue}}o.push(a);continue}i.push(a)}return e.ts.factory.updateSourceFile(t,[...mn(e,r),...mn(e,n),...mn(e,o),...i])}function De(e){let t=e.split(`
|
|
24
24
|
`).map(n=>n.trimEnd());e="";let r=!1;for(let n=t.length-1;n>=0;n--){let o=t[n];!r&&o.startsWith("import ")&&(r=!0,o=o+`
|
|
25
25
|
`),/^builder.init(.*)$/.test(o)&&(o=o+`
|
|
26
26
|
`),t[n-1]&&!t[n-1].includes("*/")&&(o.trim().startsWith("Builder.registerComponent")&&(o=`
|
|
@@ -29,8 +29,8 @@ ${r}=${n}
|
|
|
29
29
|
`+o),o.trim().startsWith("export ")&&(o=`
|
|
30
30
|
`+o)),e=o+`
|
|
31
31
|
`+e}return e.trim()+`
|
|
32
|
-
`}function
|
|
33
|
-
${e}`),e}function Ir(e,t){let r=t.statements.filter(n=>!(e.ts.isExpressionStatement(n)&&e.ts.isStringLiteral(n.expression)&&e.ts.isStringLiteral(n.expression)&&n.expression.text==="use client"));return e.ts.factory.updateSourceFile(t,r)}function Te(e,t){return t.sort((r,n)=>{if(e.ts.isObjectLiteralExpression(r)&&e.ts.isObjectLiteralExpression(n)){let o=Tr(e,r),i=Tr(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())}return 1})}function Tr(e,t){let r=t.properties.find(n=>L(e,n)==="name");return r&&e.ts.isPropertyAssignment(r)&&e.ts.isStringLiteral(r.initializer)?r.initializer.text:"zzzz"}async function Rr(e){let t=await e.readFile(e.registryPath);return t?wa(e,t):{components:[],sourceFile:b(e,"")}}async function wa(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?Ta(e,r):va(e,r)}async function va(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isCallExpression(m)){let c=e.ts.isIdentifier(m.expression)&&m.expression.text;if(c==="withChildren"){let D=dn(e,m.arguments[0]);if(e.ts.isCallExpression(D)){let g=await mn(e,n,D,f,!0);g&&r.push(g)}else{let g=D;if(e.ts.isIdentifier(g)){let x=await fn(e,t,n,g,f,!0);x&&r.push(x)}}continue}if(c==="dynamic"){let D=await mn(e,n,m,f,!1);D&&r.push(D);continue}let d=dn(e,m.arguments[0]);if(e.ts.isCallExpression(d)&&e.ts.isIdentifier(d.expression)&&d.expression.text==="dynamic"){let D=await mn(e,n,d,f,!1);D&&r.push(D);continue}if(e.ts.isIdentifier(d)){let D=await fn(e,t,n,d,f,!1);D&&r.push(D);continue}continue}if(e.ts.isIdentifier(m)){let c=await fn(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}function dn(e,t){return e.ts.isCallExpression(t)?(e.ts.isIdentifier(t.expression)&&t.expression.text)==="dynamic"?t:dn(e,t.arguments[0]):t}async function mn(e,t,r,n,o){let i={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:t,acceptsChildren:o,framework:"react"},a=r.arguments;if(a.length===0)return null;let s=a[0];if(!e.ts.isArrowFunction(s))return null;let u=s.body;if(e.ts.isCallExpression(u)){if(u.expression.kind!==e.ts.SyntaxKind.ImportKeyword||u.arguments.length!==1)return null;let f=u.arguments[0];if(!e.ts.isStringLiteral(f))return null;let m=f.text,c=await lt(e,m);i.filePath=c,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(c)?i.importPath=M(e,i.filePath):(i.externalImportPath=m,i.importPath=i.externalImportPath),i.name=le(e,i.filePath),i.importName="default",i.exportName="default",i.exportType="default"}else if(e.ts.isPropertyAccessExpression(u)){let p=u.expression;if(!e.ts.isParenthesizedExpression(p))return null;let f=p.expression;if(!e.ts.isAwaitExpression(f))return null;let m=f.expression;if(!e.ts.isCallExpression(m)||m.expression.kind!==e.ts.SyntaxKind.ImportKeyword||m.arguments.length!==1)return null;let d=m.arguments[0];if(!e.ts.isStringLiteral(d)||!e.ts.isIdentifier(u.name))return null;let D=d.text,g=await lt(e,D);i.filePath=g,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(g)?i.importPath=M(e,i.filePath):(i.externalImportPath=D,i.importPath=i.externalImportPath),i.name=K(u.name.text),i.importName=u.name.text,i.exportName=u.name.text,i.exportType="named"}else return null;return i=se(e,i,n),i.displayFilePath=O(e,i.filePath),i.filePath&&i.exportName&&(i.id=await V(e,i.filePath,i.exportName,i.externalImportPath)),i}async function fn(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;let f=await lt(e,p.text);a.filePath=f,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(f)?a.importPath=M(e,a.filePath):(a.externalImportPath=p.text,a.importPath=a.externalImportPath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await lt(e,f.text);a.filePath=m,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=O(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function lt(e,t){return At(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}function Nr(e,t,r){let n=!1,o=0,i=[...t.statements];for(let p=0;p<i.length;p++){let f=i[p];if(e.ts.isImportDeclaration(f)){o=p;continue}if(!e.ts.isExpressionStatement(f))continue;let m=f.expression;if(!e.ts.isCallExpression(m))continue;let c=m.expression;if(!e.ts.isPropertyAccessExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="builder")continue;if(c.name.text=="init"){n=!0;break}else continue}if(n)return t;let a=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("process"),e.ts.factory.createIdentifier("env")),e.ts.factory.createIdentifier(ye)),s=r?e.ts.factory.createNonNullExpression(a):a,u=e.ts.factory.createExpressionStatement(e.ts.factory.createCallExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("builder"),e.ts.factory.createIdentifier("init")),void 0,[s]));return i.splice(o+1,0,u),e.ts.factory.updateSourceFile(t,i)}async function Ta(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 gn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function gn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};it(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isCallExpression(u)&&(e.ts.isIdentifier(u.expression)&&u.expression.text)==="dynamic"){let d=u.arguments;if(d.length===0)return null;let D=d[0];if(!e.ts.isArrowFunction(D))return null;let g=D.body;if(e.ts.isCallExpression(g)){if(g.expression.kind!==e.ts.SyntaxKind.ImportKeyword||g.arguments.length!==1)return null;let l=g.arguments[0];if(!e.ts.isStringLiteral(l))return null;let C=l.text,E=await lt(e,C);n.filePath=E,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(E)?n.importPath=M(e,n.filePath):(n.externalImportPath=C,n.importPath=n.externalImportPath),n.name=le(e,n.filePath),n.importName="default",n.exportName="default",n.exportType="default"}else if(e.ts.isPropertyAccessExpression(g)){let x=g.expression;if(!e.ts.isParenthesizedExpression(x))return null;let l=x.expression;if(!e.ts.isAwaitExpression(l))return null;let C=l.expression;if(!e.ts.isCallExpression(C)||C.expression.kind!==e.ts.SyntaxKind.ImportKeyword||C.arguments.length!==1)return null;let F=C.arguments[0];if(!e.ts.isStringLiteral(F)||!e.ts.isIdentifier(g.name))return null;let A=F.text,S=await lt(e,A);n.filePath=S,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(S)?n.importPath=M(e,n.filePath):(n.externalImportPath=A,n.importPath=n.externalImportPath),n.name=K(g.name.text),n.importName=g.name.text,n.exportName=g.name.text,n.exportType="named"}else return null;return n=se(e,n,r),n.displayFilePath=O(e,n.filePath),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.importPath=M(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}function be(e,t){let r=[...t.statements],n=!1;for(let o=t.statements.length-1;o>=0;o--){let i=t.statements[o];if(e.ts.isImportDeclaration(i)&&i.importClause){let a=!1,s=i.importClause.namedBindings;if(s&&e.ts.isNamedImports(s)&&s.elements){let u=[...s.elements];for(let p=u.length-1;p>=0;p--){let f=u[p];if(e.ts.isImportSpecifier(f)){let m=f.name;if(m&&e.ts.isIdentifier(m)){let c=m.text;Br(e,t,c)||u.splice(p,1)}}}if(u.length===0)a=!0;else if(s.elements.length!==u.length){let p=e.ts.factory.updateImportClause(i.importClause,!1,i.importClause.name,e.ts.factory.createNamedImports(u)),f=e.ts.factory.updateImportDeclaration(i,void 0,p,i.moduleSpecifier,void 0);r[o]=f,n=!0}}else if(i.importClause.name&&e.ts.isIdentifier(i.importClause.name)){let u=i.importClause.name.text;Br(e,t,u)||(a=!0)}a&&(r.splice(o,1),n=!0)}}return n?e.ts.factory.updateSourceFile(t,r):t}function Br(e,t,r){let n=!1;function o(i){if(!e.ts.isImportDeclaration(i)){if(e.ts.isIdentifier(i)&&i.text===r){n=!0;return}e.ts.forEachChild(i,o)}}return e.ts.forEachChild(t,o),n}function Ie(e,t,r,n,o,i,a){let s=null,u=null,p=null,f=-1;t=ue(t),r=ue(r);let m=t.find(d=>d.id===e),c=r.find(d=>d.id===e);if(n)c||(s={...ue(m),inputs:ue(m.inputs).map(d=>(d.isRegistered=!0,d))},f=r.length,r.push(s));else if(typeof c?.nodeIndex=="number"&&c.nodeIndex>-1){if(o)f=c.nodeIndex,u=ue(c),r=r.filter(d=>d.id!==e);else if(i!=null)ba(c,i),f=c.nodeIndex,p=c;else if(a!=null){let d=c.inputs.find(D=>D.name===a.name);d&&(a.registerInput===!1?d.isRegistered=!1:(Ia(d,a),d.isRegistered=!0),p=c,f=c.nodeIndex)}}return{addCmpToRegistry:s,removeCmpFromRegistry:u,updateRegisteredCmp:p,nodeIndex:f,components:Ee(t,r)}}function Ee(e,t){let r=ae([...t.map(n=>(n.isRegistered=!0,n)),...e.filter(n=>!t.some(o=>o.id===n.id)).map(n=>(n.isRegistered=!1,n))]);return r.forEach(n=>{n.inputs=n.inputs.map(un),n.inputs.sort((a,s)=>a.name.toLowerCase().localeCompare(s.name.toLowerCase()));let o=t.find(a=>a.id===n.id);o&&(o.acceptsChildren=sn(n));let i=e.find(a=>a.id===n.id&&a.externalImportPath);i&&(n.filePath=i.filePath,n.relFilePath=i.relFilePath)}),r}function ba(e,t){re(t.name)?e.name=t.name:t.name===null&&(e.name=e.importName),re(t.description)?e.description=t.description:t.description===null&&delete e.description,re(t.image)?e.image=t.image:t.image===null&&delete e.image}function Ia(e,t){re(t.type)&&(e.type=t.type),re(t.friendlyName)?e.friendlyName=t.friendlyName:t.friendlyName===null&&delete e.friendlyName,re(t.defaultValue)||xt(t.defaultValue)||nt(t.defaultValue)?e.defaultValue=t.defaultValue:t.defaultValue===null&&delete e.defaultValue,re(t.helperText)?e.helperText=t.helperText:t.helperText===null&&delete e.helperText,t.required===!0?e.required=t.required:(t.required===null||t.required===!1)&&delete e.required}async function Ue(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".jsx"||u===".ts"||u===".js"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await G(e,[...t])}function Re(e,t,r){return st(e,t,r.variableName)?t:Ra(e,t,r)}function Ra(e,t,r){let n=typeof r.arrayType=="string"?e.ts.factory.createArrayTypeNode(e.ts.factory.createTypeReferenceNode(r.arrayType,void 0)):void 0,o=e.ts.factory.createArrayLiteralExpression([]),i=e.ts.factory.createVariableDeclaration(r.variableName,void 0,n,o),a=e.ts.factory.createVariableDeclarationList([i],e.ts.NodeFlags.Const),s=e.ts.factory.createModifier(e.ts.SyntaxKind.ExportKeyword),u=e.ts.factory.createVariableStatement([s],a),p=[...t.statements,u];return e.ts.factory.updateSourceFile(t,p)}async function Ne(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m,c]=await Promise.all([wr(e,u),Rr(e),ne(e),Ct(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await pt(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await G(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await ct(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));pe(B,$);let k=d.findIndex(w=>w.id===S.cmpInfo.id);d[k].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:Y,variableDeclaration:_}=await Oa(e,l,S);if(P.addCmpToRegistry)w.push(Ba(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[kr(e,P.updateRegisteredCmp),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(Y,Y.modifiers,e.ts.factory.updateVariableDeclarationList(Y.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=Or(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(We=>We.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(Dr(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=pn(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=Nr(e,l,m),l=Or(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l),e.appDir&&(l=Ir(e,l));let E=j(e,l);E=De(E),e.appDir&&(E=br(E)),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}function kr(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.appDir?e.ts.factory.createPropertyAssignment("component",r):e.ts.factory.createPropertyAssignment("component",ka(e,t))}function Na(e){return e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())}function Ba(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([kr(e,t),...t.acceptsChildren?[Na(e)]:[]],!0),t)}async function Oa(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 gn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function Or(e,t,r){if(e.appDir){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}}else r=I(e,r,{defaultImport:"dynamic",importPath:"next/dynamic"});return r}function ka(e,t){let r=t.externalImportPath?t.externalImportPath:N(e,e.registryPath,t.filePath),n=t.exportName!=="default",o;n?o=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createAwaitExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)])),e.ts.factory.createIdentifier(t.exportName)):o=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)]);let i=e.ts.factory.createArrowFunction(n?[e.ts.factory.createModifier(e.ts.SyntaxKind.AsyncKeyword)]:void 0,void 0,[],void 0,e.ts.factory.createToken(e.ts.SyntaxKind.EqualsGreaterThanToken),o);return e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("dynamic"),void 0,[i])}async function _r(e){let t=[],r=await $a(e,t);return await Mr(e,t,r),e.appDir?(e.debug(`ensure builder setup for next.js app ${e.appDir}`),await _a(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure builder setup for next.js pages ${e.pagesDir}`),await ja(e,e.pagesDir,t)),t}async function jr(e){let t=[];return await Mr(e,t),e.appDir?(e.debug(`ensure figma-imports setup for next.js app ${e.appDir}`),await La(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure figma-imports setup for next.js pages ${e.pagesDir}`),await Va(e,e.pagesDir,t)),t}async function La(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"figma-imports",n);if(!await e.exists(o)){let i=await e.formatCode(o,$r({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,Vr(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}async function _a(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"[...page]",n);if(!await e.exists(o)){let i=await e.formatCode(o,$r({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,Vr(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}function Vr(e){let t=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
|
|
32
|
+
`}function mn(e,t){return t.sort((r,n)=>{let o=Tr(e,r),i=Tr(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())})}function Tr(e,t){let r=t.importClause;if(r){let n=r.namedBindings;if(n&&e.ts.isNamedImports(n)&&n.elements.length>0)return n.elements[0].name.text;if(r.name)return r.name.text}return t.moduleSpecifier&&e.ts.isStringLiteral(t.moduleSpecifier)?t.moduleSpecifier.text:""}function Ir(e){return typeof e=="string"&&!e.includes("'use client'")&&!e.includes(`"use client"'`)&&(e=`"use client"
|
|
33
|
+
${e}`),e}function Rr(e,t){let r=t.statements.filter(n=>!(e.ts.isExpressionStatement(n)&&e.ts.isStringLiteral(n.expression)&&e.ts.isStringLiteral(n.expression)&&n.expression.text==="use client"));return e.ts.factory.updateSourceFile(t,r)}function Te(e,t){return t.sort((r,n)=>{if(e.ts.isObjectLiteralExpression(r)&&e.ts.isObjectLiteralExpression(n)){let o=br(e,r),i=br(e,n);return o.toLocaleLowerCase().localeCompare(i.toLocaleLowerCase())}return 1})}function br(e,t){let r=t.properties.find(n=>L(e,n)==="name");return r&&e.ts.isPropertyAssignment(r)&&e.ts.isStringLiteral(r.initializer)?r.initializer.text:"zzzz"}async function Nr(e){let t=await e.readFile(e.registryPath);return t?Ta(e,t):{components:[],sourceFile:b(e,"")}}async function Ta(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?Ia(e,r):ba(e,r)}async function ba(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isCallExpression(m)){let c=e.ts.isIdentifier(m.expression)&&m.expression.text;if(c==="withChildren"){let D=gn(e,m.arguments[0]);if(e.ts.isCallExpression(D)){let g=await fn(e,n,D,f,!0);g&&r.push(g)}else{let g=D;if(e.ts.isIdentifier(g)){let x=await dn(e,t,n,g,f,!0);x&&r.push(x)}}continue}if(c==="dynamic"){let D=await fn(e,n,m,f,!1);D&&r.push(D);continue}let d=gn(e,m.arguments[0]);if(e.ts.isCallExpression(d)&&e.ts.isIdentifier(d.expression)&&d.expression.text==="dynamic"){let D=await fn(e,n,d,f,!1);D&&r.push(D);continue}if(e.ts.isIdentifier(d)){let D=await dn(e,t,n,d,f,!1);D&&r.push(D);continue}continue}if(e.ts.isIdentifier(m)){let c=await dn(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}function gn(e,t){return e.ts.isCallExpression(t)?(e.ts.isIdentifier(t.expression)&&t.expression.text)==="dynamic"?t:gn(e,t.arguments[0]):t}async function fn(e,t,r,n,o){let i={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:t,acceptsChildren:o,framework:"react"},a=r.arguments;if(a.length===0)return null;let s=a[0];if(!e.ts.isArrowFunction(s))return null;let u=s.body;if(e.ts.isCallExpression(u)){if(u.expression.kind!==e.ts.SyntaxKind.ImportKeyword||u.arguments.length!==1)return null;let f=u.arguments[0];if(!e.ts.isStringLiteral(f))return null;let m=f.text,c=await lt(e,m);i.filePath=c,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(c)?i.importPath=M(e,i.filePath):(i.externalImportPath=m,i.importPath=i.externalImportPath),i.name=le(e,i.filePath),i.importName="default",i.exportName="default",i.exportType="default"}else if(e.ts.isPropertyAccessExpression(u)){let p=u.expression;if(!e.ts.isParenthesizedExpression(p))return null;let f=p.expression;if(!e.ts.isAwaitExpression(f))return null;let m=f.expression;if(!e.ts.isCallExpression(m)||m.expression.kind!==e.ts.SyntaxKind.ImportKeyword||m.arguments.length!==1)return null;let d=m.arguments[0];if(!e.ts.isStringLiteral(d)||!e.ts.isIdentifier(u.name))return null;let D=d.text,g=await lt(e,D);i.filePath=g,i.relFilePath=e.relative(e.getAppRootDir(),i.filePath),await e.exists(g)?i.importPath=M(e,i.filePath):(i.externalImportPath=D,i.importPath=i.externalImportPath),i.name=K(u.name.text),i.importName=u.name.text,i.exportName=u.name.text,i.exportType="named"}else return null;return i=se(e,i,n),i.displayFilePath=O(e,i.filePath),i.filePath&&i.exportName&&(i.id=await V(e,i.filePath,i.exportName,i.externalImportPath)),i}async function dn(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;let f=await lt(e,p.text);a.filePath=f,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(f)?a.importPath=M(e,a.filePath):(a.externalImportPath=p.text,a.importPath=a.externalImportPath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await lt(e,f.text);a.filePath=m,a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=O(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function lt(e,t){return At(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}function Br(e,t,r){let n=!1,o=0,i=[...t.statements];for(let p=0;p<i.length;p++){let f=i[p];if(e.ts.isImportDeclaration(f)){o=p;continue}if(!e.ts.isExpressionStatement(f))continue;let m=f.expression;if(!e.ts.isCallExpression(m))continue;let c=m.expression;if(!e.ts.isPropertyAccessExpression(c))continue;let d=c.expression;if(!e.ts.isIdentifier(d)||d.text!=="builder")continue;if(c.name.text=="init"){n=!0;break}else continue}if(n)return t;let a=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("process"),e.ts.factory.createIdentifier("env")),e.ts.factory.createIdentifier(ye)),s=r?e.ts.factory.createNonNullExpression(a):a,u=e.ts.factory.createExpressionStatement(e.ts.factory.createCallExpression(e.ts.factory.createPropertyAccessExpression(e.ts.factory.createIdentifier("builder"),e.ts.factory.createIdentifier("init")),void 0,[s]));return i.splice(o+1,0,u),e.ts.factory.updateSourceFile(t,i)}async function Ia(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 Dn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Dn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};it(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isCallExpression(u)&&(e.ts.isIdentifier(u.expression)&&u.expression.text)==="dynamic"){let d=u.arguments;if(d.length===0)return null;let D=d[0];if(!e.ts.isArrowFunction(D))return null;let g=D.body;if(e.ts.isCallExpression(g)){if(g.expression.kind!==e.ts.SyntaxKind.ImportKeyword||g.arguments.length!==1)return null;let l=g.arguments[0];if(!e.ts.isStringLiteral(l))return null;let C=l.text,E=await lt(e,C);n.filePath=E,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(E)?n.importPath=M(e,n.filePath):(n.externalImportPath=C,n.importPath=n.externalImportPath),n.name=le(e,n.filePath),n.importName="default",n.exportName="default",n.exportType="default"}else if(e.ts.isPropertyAccessExpression(g)){let x=g.expression;if(!e.ts.isParenthesizedExpression(x))return null;let l=x.expression;if(!e.ts.isAwaitExpression(l))return null;let C=l.expression;if(!e.ts.isCallExpression(C)||C.expression.kind!==e.ts.SyntaxKind.ImportKeyword||C.arguments.length!==1)return null;let F=C.arguments[0];if(!e.ts.isStringLiteral(F)||!e.ts.isIdentifier(g.name))return null;let A=F.text,S=await lt(e,A);n.filePath=S,n.relFilePath=e.relative(e.getAppRootDir(),n.filePath),await e.exists(S)?n.importPath=M(e,n.filePath):(n.externalImportPath=A,n.importPath=n.externalImportPath),n.name=K(g.name.text),n.importName=g.name.text,n.exportName=g.name.text,n.exportType="named"}else return null;return n=se(e,n,r),n.displayFilePath=O(e,n.filePath),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.importPath=M(e,p.filePath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}function be(e,t){let r=[...t.statements],n=!1;for(let o=t.statements.length-1;o>=0;o--){let i=t.statements[o];if(e.ts.isImportDeclaration(i)&&i.importClause){let a=!1,s=i.importClause.namedBindings;if(s&&e.ts.isNamedImports(s)&&s.elements){let u=[...s.elements];for(let p=u.length-1;p>=0;p--){let f=u[p];if(e.ts.isImportSpecifier(f)){let m=f.name;if(m&&e.ts.isIdentifier(m)){let c=m.text;Or(e,t,c)||u.splice(p,1)}}}if(u.length===0)a=!0;else if(s.elements.length!==u.length){let p=e.ts.factory.updateImportClause(i.importClause,!1,i.importClause.name,e.ts.factory.createNamedImports(u)),f=e.ts.factory.updateImportDeclaration(i,void 0,p,i.moduleSpecifier,void 0);r[o]=f,n=!0}}else if(i.importClause.name&&e.ts.isIdentifier(i.importClause.name)){let u=i.importClause.name.text;Or(e,t,u)||(a=!0)}a&&(r.splice(o,1),n=!0)}}return n?e.ts.factory.updateSourceFile(t,r):t}function Or(e,t,r){let n=!1;function o(i){if(!e.ts.isImportDeclaration(i)){if(e.ts.isIdentifier(i)&&i.text===r){n=!0;return}e.ts.forEachChild(i,o)}}return e.ts.forEachChild(t,o),n}function Ie(e,t,r,n,o,i,a){let s=null,u=null,p=null,f=-1;t=ue(t),r=ue(r);let m=t.find(d=>d.id===e),c=r.find(d=>d.id===e);if(n)c||(s={...ue(m),inputs:ue(m.inputs).map(d=>(d.isRegistered=!0,d))},f=r.length,r.push(s));else if(typeof c?.nodeIndex=="number"&&c.nodeIndex>-1){if(o)f=c.nodeIndex,u=ue(c),r=r.filter(d=>d.id!==e);else if(i!=null)Ra(c,i),f=c.nodeIndex,p=c;else if(a!=null){let d=c.inputs.find(D=>D.name===a.name);d&&(a.registerInput===!1?d.isRegistered=!1:(Na(d,a),d.isRegistered=!0),p=c,f=c.nodeIndex)}}return{addCmpToRegistry:s,removeCmpFromRegistry:u,updateRegisteredCmp:p,nodeIndex:f,components:Ee(t,r)}}function Ee(e,t){let r=ae([...t.map(n=>(n.isRegistered=!0,n)),...e.filter(n=>!t.some(o=>o.id===n.id)).map(n=>(n.isRegistered=!1,n))]);return r.forEach(n=>{n.inputs=n.inputs.map(pn),n.inputs.sort((a,s)=>a.name.toLowerCase().localeCompare(s.name.toLowerCase()));let o=t.find(a=>a.id===n.id);o&&(o.acceptsChildren=un(n));let i=e.find(a=>a.id===n.id&&a.externalImportPath);i&&(n.filePath=i.filePath,n.relFilePath=i.relFilePath)}),r}function Ra(e,t){re(t.name)?e.name=t.name:t.name===null&&(e.name=e.importName),re(t.description)?e.description=t.description:t.description===null&&delete e.description,re(t.image)?e.image=t.image:t.image===null&&delete e.image}function Na(e,t){re(t.type)&&(e.type=t.type),re(t.friendlyName)?e.friendlyName=t.friendlyName:t.friendlyName===null&&delete e.friendlyName,re(t.defaultValue)||xt(t.defaultValue)||nt(t.defaultValue)?e.defaultValue=t.defaultValue:t.defaultValue===null&&delete e.defaultValue,re(t.helperText)?e.helperText=t.helperText:t.helperText===null&&delete e.helperText,t.required===!0?e.required=t.required:(t.required===null||t.required===!1)&&delete e.required}async function Ue(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".jsx"||u===".ts"||u===".js"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await G(e,[...t])}function Re(e,t,r){return st(e,t,r.variableName)?t:Ba(e,t,r)}function Ba(e,t,r){let n=typeof r.arrayType=="string"?e.ts.factory.createArrayTypeNode(e.ts.factory.createTypeReferenceNode(r.arrayType,void 0)):void 0,o=e.ts.factory.createArrayLiteralExpression([]),i=e.ts.factory.createVariableDeclaration(r.variableName,void 0,n,o),a=e.ts.factory.createVariableDeclarationList([i],e.ts.NodeFlags.Const),s=e.ts.factory.createModifier(e.ts.SyntaxKind.ExportKeyword),u=e.ts.factory.createVariableStatement([s],a),p=[...t.statements,u];return e.ts.factory.updateSourceFile(t,p)}async function Ne(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m,c]=await Promise.all([vr(e,u),Nr(e),ne(e),Ct(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await pt(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await G(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await ct(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));pe(B,$);let k=d.findIndex(w=>w.id===S.cmpInfo.id);d[k].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:Y,variableDeclaration:_}=await La(e,l,S);if(P.addCmpToRegistry)w.push(ka(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[Lr(e,P.updateRegisteredCmp),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(Y,Y.modifiers,e.ts.factory.updateVariableDeclarationList(Y.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=kr(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(We=>We.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(xr(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=cn(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=Br(e,l,m),l=kr(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l),e.appDir&&(l=Rr(e,l));let E=j(e,l);E=De(E),e.appDir&&(E=Ir(E)),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}function Lr(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.appDir?e.ts.factory.createPropertyAssignment("component",r):e.ts.factory.createPropertyAssignment("component",_a(e,t))}function Oa(e){return e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())}function ka(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([Lr(e,t),...t.acceptsChildren?[Oa(e)]:[]],!0),t)}async function La(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 Dn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function kr(e,t,r){if(e.appDir){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}}else r=I(e,r,{defaultImport:"dynamic",importPath:"next/dynamic"});return r}function _a(e,t){let r=t.externalImportPath?t.externalImportPath:N(e,e.registryPath,t.filePath),n=t.exportName!=="default",o;n?o=e.ts.factory.createPropertyAccessExpression(e.ts.factory.createAwaitExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)])),e.ts.factory.createIdentifier(t.exportName)):o=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("import"),void 0,[e.ts.factory.createStringLiteral(r)]);let i=e.ts.factory.createArrowFunction(n?[e.ts.factory.createModifier(e.ts.SyntaxKind.AsyncKeyword)]:void 0,void 0,[],void 0,e.ts.factory.createToken(e.ts.SyntaxKind.EqualsGreaterThanToken),o);return e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("dynamic"),void 0,[i])}async function jr(e){let t=[],r=await Ma(e,t);return await Ur(e,t,r),e.appDir?(e.debug(`ensure builder setup for next.js app ${e.appDir}`),await Va(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure builder setup for next.js pages ${e.pagesDir}`),await $a(e,e.pagesDir,t)),t}async function Vr(e){let t=[];return await Ur(e,t),e.appDir?(e.debug(`ensure figma-imports setup for next.js app ${e.appDir}`),await ja(e,e.appDir,t)):e.pagesDir&&(e.debug(`ensure figma-imports setup for next.js pages ${e.pagesDir}`),await Ka(e,e.pagesDir,t)),t}async function ja(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"figma-imports",n);if(!await e.exists(o)){let i=await e.formatCode(o,Kr({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,$r(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}async function Va(e,t,r){let n=`page.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,"[...page]",n);if(!await e.exists(o)){let i=await e.formatCode(o,Kr({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}if(!await e.exists(e.builderComponentPath)){let i=await e.formatCode(e.builderComponentPath,$r(e));await e.writeFile(e.builderComponentPath,i),r.push({filePath:e.builderComponentPath,modifiedType:"create"})}}function $r(e){let t=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
|
|
34
34
|
"use client";
|
|
35
35
|
import { ${t?"BuilderContent, ":""} isPreviewing, Content } from "@builder.io/sdk-react";
|
|
36
36
|
import DefaultErrorPage from "next/error";
|
|
@@ -89,7 +89,7 @@ export function RenderBuilderContent({ content, model }${t?": BuilderPageProps":
|
|
|
89
89
|
// DefaultErrorPage with a 404.
|
|
90
90
|
return <DefaultErrorPage statusCode={404} />;
|
|
91
91
|
}
|
|
92
|
-
`.trimStart()}function
|
|
92
|
+
`.trimStart()}function _r(e){return e.features.asyncParams?`
|
|
93
93
|
interface PageProps {
|
|
94
94
|
params: Promise<{
|
|
95
95
|
page: string[];
|
|
@@ -99,14 +99,14 @@ interface PageProps {
|
|
|
99
99
|
params: {
|
|
100
100
|
page: string[];
|
|
101
101
|
};
|
|
102
|
-
}`}function
|
|
102
|
+
}`}function Kr({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.builderComponentPath);return e.sdkVersion===y.gen2?`
|
|
103
103
|
import { fetchOneEntry } from "@builder.io/sdk-react";
|
|
104
104
|
import { RenderBuilderContent } from ${JSON.stringify(o)};
|
|
105
105
|
|
|
106
106
|
// Builder Public API Key set in .env file
|
|
107
107
|
const PUBLIC_API_KEY = process.env.${ye}${n?"!":""};
|
|
108
108
|
|
|
109
|
-
${n?
|
|
109
|
+
${n?_r(e):""}
|
|
110
110
|
|
|
111
111
|
export default async function Page(props${n?": PageProps":""}) {
|
|
112
112
|
const builderModelName = "${r}";
|
|
@@ -134,7 +134,7 @@ import { RenderBuilderContent } from ${JSON.stringify(o)};
|
|
|
134
134
|
|
|
135
135
|
// Builder Public API Key set in .env file
|
|
136
136
|
builder.init(process.env.${ye}${n?"!":""});
|
|
137
|
-
${n?
|
|
137
|
+
${n?_r(e):""}
|
|
138
138
|
|
|
139
139
|
export default async function Page(props${n?": PageProps":""}) {
|
|
140
140
|
const builderModelName = "${r}";
|
|
@@ -157,7 +157,7 @@ export default async function Page(props${n?": PageProps":""}) {
|
|
|
157
157
|
</>
|
|
158
158
|
);
|
|
159
159
|
}
|
|
160
|
-
`.trimStart()}async function
|
|
160
|
+
`.trimStart()}async function $a(e,t,r){let n=`[...page].${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,n);if(!await e.exists(o)){let i=await e.formatCode(o,Mr({sys:e,routePath:o,modelName:"page"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}}async function Ka(e,t,r){let n=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`,o=e.join(t,n);if(!await e.exists(o)){let i=await e.formatCode(o,Mr({sys:e,routePath:o,modelName:"figma-imports"}));await e.writeFile(o,i),r.push({filePath:o,modifiedType:"create"})}}function Mr({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
|
|
161
161
|
import React from "react";
|
|
162
162
|
import { useRouter } from "next/router";
|
|
163
163
|
${n?'import type { BuilderContent } from "@builder.io/sdk-react";':""}
|
|
@@ -321,7 +321,7 @@ export default function Page({ page }${n?": { page: BuilderContent | null }":""}
|
|
|
321
321
|
</>
|
|
322
322
|
);
|
|
323
323
|
}
|
|
324
|
-
`.trimStart()}async function
|
|
324
|
+
`.trimStart()}async function Ma(e,t){let n=e.typescriptEnabled?"tsx":"jsx",o=e.join(e.componentsDir,"Counter"),i=e.join(o,`Counter.${n}`),a=e.join(o,"styles.module.css"),{component:s,styles:u}=Ua(e);if(!await e.exists(i)){let p=await e.formatCode(i,s);await e.writeFile(i,p),t.push({filePath:i,modifiedType:"create"})}return await e.exists(a)||(await e.writeFile(a,u),t.push({filePath:a,modifiedType:"create"})),i}function Ua(e){let t=e.typescriptEnabled,r=`
|
|
325
325
|
"use client"
|
|
326
326
|
import React, { useState } from "react";
|
|
327
327
|
import styles from "./styles.module.css";
|
|
@@ -384,18 +384,18 @@ export default Counter;
|
|
|
384
384
|
font-size: 42px;
|
|
385
385
|
text-align: center;
|
|
386
386
|
}
|
|
387
|
-
`.trimStart();return{component:r,styles:n}}async function
|
|
387
|
+
`.trimStart();return{component:r,styles:n}}async function Ur(e,t,r){if(!await e.exists(e.registryPath)){if(e.sdkVersion===y.gen2){let i=za(e);await e.writeFile(e.registryPath,i)}else await e.writeFile(e.registryPath,"");t.push({filePath:e.registryPath,modifiedType:"create"})}if(!r)return;let o=(await Ne(e,null,!1,!1,null,null,!1,!1)).components.find(i=>i.filePath===r);o&&await Ne(e,o.id,!0,!1,null,null,!0,!1)}function za(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-react";
|
|
388
388
|
|
|
389
389
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
390
390
|
];`:`export const CUSTOM_COMPONENTS = [
|
|
391
391
|
];
|
|
392
|
-
`}async function mt(e){let t=await gt(e,e.getRepoRootDir());if(t&&typeof t=="object"){let r=new Set(Object.keys({...t.dependencies,...t.devDependencies}));if(r.has("@builder.io/sdk-react"))return y.gen2;if(r.has("@builder.io/react"))return y.gen1}return null}async function
|
|
392
|
+
`}async function mt(e){let t=await gt(e,e.getRepoRootDir());if(t&&typeof t=="object"){let r=new Set(Object.keys({...t.dependencies,...t.devDependencies}));if(r.has("@builder.io/sdk-react"))return y.gen2;if(r.has("@builder.io/react"))return y.gen1}return null}async function zr(e){let t=await qa(e);return{builderPageOptions:async()=>({templateContentId:"3de2f13211234071a4b19a17b4fbc5a7",pathname:"/builder-demo",title:"Builder + Next.js Demo Page"}),ensureBuilderSetup:()=>jr(t),ensureFigmaImportPage:()=>Vr(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Ne(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Ne(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Ne(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Ne(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Ne(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Ne(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Ct(t),setPublicApiKey:n=>lr(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function qa(e){let t=e.getAppRootDir(),r=e.join(t,"src"),n=await Ja(e),o=await ne(e),i=e.getFrameworks().find(p=>p.name==="next"),a={asyncParams:i?.version?.major!==void 0&&i.version.major>=15},s={},u={...e,addExternalPackage:p=>{s[e.join(t,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>s[p]??e.readFileSync(p),existsSync:p=>!!s[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===t?[...f,...Object.keys(s).map(m=>m.slice(t.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===t?[...f,...Object.keys(s).map(m=>m.slice(t.length+1))]:f},appDir:null,pagesDir:null,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",nextConfigPath:n,typescriptEnabled:o,features:a};if(e.sdkVersion?u.sdkVersion=e.sdkVersion:u.sdkVersion=await mt(u),await e.exists(r)){u.srcDir=r,u.componentsDir=e.join(r,"components");let p=e.join(r,"app");await e.exists(p)&&(u.appDir=p);let f=e.join(r,"pages");await e.exists(f)&&(u.pagesDir=f),u.registryPath=await ie(e,r)}else u.componentsDir=e.join(t,"components"),u.registryPath=await ie(e,t);if(u.builderComponentPath=e.join(u.componentsDir,`builder.${o?"tsx":"jsx"}`),!u.appDir){let p=e.join(t,"app");await e.exists(p)&&(u.appDir=p)}if(!u.pagesDir){let p=e.join(t,"pages");await e.exists(p)&&(u.pagesDir=p)}if(!u.appDir&&!u.pagesDir&&!e.ignoreMissingConfig)throw new Error(`Could not find Next.js "app" or "pages" directory. Searched in "${t}".`);return u}async function Ja(e){let t=e.join(e.getAppRootDir(),"next.config.ts");if(await e.exists(t))return t;let r=e.join(e.getAppRootDir(),"next.config.mjs");if(await e.exists(r))return r;let n=e.join(e.getAppRootDir(),"next.config.js");if(await e.exists(n))return n;throw new Error(`Could not find Next.js config file. Searched for "next.config.ts", "next.config.mjs" and "next.config.js" in "${e.getAppRootDir()}".`)}async function Ft(e){return await Fe(e,[".env"],Jr)}async function qr(e,t){Wa(t);let r=await Ft(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}function Wa(e){typeof process<"u"&&(process.env[Jr]=e)}var Jr="PUBLIC_BUILDER_API_KEY";function Wr(e,t,r){if(r.length===0)return e;let n=e.split(`
|
|
393
393
|
`),o=n.findIndex(s=>s.includes(r));if(o===-1||n.some(s=>s.includes(t[0])))return e;let a=["/**",...t.map(s=>` * ${s.trim()}`)," */"];return n.splice(o,0,...a),n.join(`
|
|
394
|
-
`)}async function
|
|
394
|
+
`)}async function Yr(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(a.startsWith(".")||Ga.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await $t(e,o,s,i);r.push(...u)})),r}async function Gr(e,t){if(e.extname(t).toLowerCase()===".tsx"){let n=await e.readFile(t);if(n)return Qa(e,t,n)}return null}function Qa(e,t,r){let n=b(e,r);return $t(e,null,t,n)}async function $t(e,t,r,n){r=e.normalize(r);let o=[],i=de(e,n);return await Promise.all(i.map(async a=>{let s=await Ya(e,t,r,a);s&&o.push(s)})),o}async function Ya(e,t,r,n){let o=e.relative(e.getAppRootDir(),r),i=M(e,r);if(e.ts.isVariableStatement(n.node))for(let a of n.node.declarationList.declarations){let s=Qr(e,a.initializer);if(s&&e.ts.isIdentifier(a.name)){let u=a.name.text;return{cmpInfo:{id:await V(e,r,u),displayFilePath:O(e,r),name:K(u),inputs:[],exportName:n.isDefaultExport?"default":u,exportType:n.isDefaultExport?"default":"named",importName:u,filePath:r,relFilePath:o,importPath:i,framework:"qwik"},node:s}}}else if(e.ts.isCallExpression(n.node)){let a=Qr(e,n.node);if(a)return{cmpInfo:{id:await V(e,r,"default"),displayFilePath:O(e,r),name:le(e,r),inputs:[],exportName:"default",exportType:"default",importName:Qe(e,r),filePath:r,relFilePath:o,importPath:i,framework:"qwik"},node:a}}return null}function Qr(e,t){if(t&&e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)&&t.expression.text==="component$"&&t.arguments.length>0){let r=t.arguments[0];if(e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r))return{callExpression:t,fnNode:r}}return null}var Ga=new Set(["node_modules","layout.tsx","404.tsx","router-head.tsx"]);async function Hr(e,t){let r=t.node.fnNode;if((e.ts.isArrowFunction(r)||e.ts.isFunctionExpression(r))&&r.parameters.length>0){let{sourceFile:o,typeChecker:i}=await at(e,t.cmpInfo.filePath,null);if(!(await $t(e,i,t.cmpInfo.filePath,o)).find(u=>u.cmpInfo.id===t.cmpInfo.id))throw new Error(`createComponentInputs() Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return Ge(e,i,r)}return[]}async function Xr(e){return xn(e)}async function xn(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,Ha),t.push({filePath:e.registryPath,modifiedType:"create"})),t}var Ha=`import type { RegisteredComponent } from "@builder.io/sdk-qwik";
|
|
395
395
|
|
|
396
396
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
397
397
|
];
|
|
398
|
-
`;async function Xr(e){await Dn(e);let t=await e.readFile(e.registryPath);return t?Ga(e,t):{components:[],sourceFile:b(e,"")}}async function Ga(e,t){let r=b(e,t);return Ha(e,r)}async function Ha(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 xn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function xn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"qwik"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"&&e.ts.isIdentifier(o.initializer)){let a=o.initializer.text;n.name===""&&(n.name=K(a)),n.importName=a;let s=await we(e,e.registryPath,t,a);if(!s)continue;n.filePath=s.filePath,n.relFilePath=s.relFilePath,n.importPath=M(e,s.filePath),n.displayFilePath=s.displayFilePath,n.exportType=s.exportType;let u=await Yr(e,s.filePath);if(u&&u.length>0)if(u.length===1)n.exportName=u[0].cmpInfo.exportName;else{let p=u.find(f=>f.cmpInfo.exportName===a);p&&(n.exportName=p.cmpInfo.exportName)}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName)),n}async function Zr(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".ts"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await G(e,[...t])}async function He(e,t,r,n,o,i,a,s){let u=await Zr(e),[p,f,m]=await Promise.all([Qr(e,u),Xr(e),Ft(e)]),c=p.map(g=>g.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D;if(t!=null){let g=p.find(P=>P.cmpInfo.id===t);if(!g)throw new Error(`Component ${t} not found`);let x=f.sourceFile,l=D.components.find(P=>P.id===t),C=await Gr(e,g);pe(l,C),t=Array.isArray(t)?t[0]:t;let E=Ie(t,c,d,r,n,o,i),{elements:F,elmIndex:A,statementIndex:S,statement:B,variableDeclaration:$}=await Za(e,x,g),k=!1;if(E.addCmpToRegistry?(F.push(Xa(e,E.addCmpToRegistry)),k=!0):E.removeCmpFromRegistry?(F.splice(A,1),k=!0):E.updateRegisteredCmp&&(F[A]=W(e,F[A],E.updateRegisteredCmp),k=!0),k&&a){let P=[...x.statements];P[S]=e.ts.factory.updateVariableStatement(B,B.modifiers,e.ts.factory.updateVariableDeclarationList(B.declarationList,[e.ts.factory.updateVariableDeclaration($,$.name,$.exclamationToken,$.type,e.ts.factory.createArrayLiteralExpression(Te(e,F)))])),x=e.ts.factory.updateSourceFile(x,P),l.exportType==="named"?x=I(e,x,{namedImports:[l.importName],importPath:N(e,e.registryPath,l.filePath)}):x=I(e,x,{defaultImport:l.importName,importPath:N(e,e.registryPath,l.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-qwik",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),x=be(e,x),x=ve(e,x);let w=j(e,x);w=De(w),w=Jr(w,es,"CUSTOM_COMPONENTS"),w=await e.formatCode(e.registryPath,w),await e.writeFile(e.registryPath,w)}D.components=E.components}return D}function Xa(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName))],!0),t)}async function Za(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 xn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}var es=["This array is used to integrate custom components within Builder.","https://www.builder.io/c/docs/custom-components-intro","",'These components will be found the "Custom Components"',"section of Builder's visual editor.",'You can also turn on "components only mode" to limit',"editing to only these components.","https://www.builder.io/c/docs/guides/components-only-mode"];async function eo(e){let t=await ts(e);return{builderPageOptions:async()=>({templateContentId:"dc70f1d979ad416d8fd357137eb9ddfb",pathname:"/",title:"Builder + Qwik Demo Page"}),ensureBuilderSetup:()=>Hr(t),ensureFigmaImportPage:async()=>[],getRegistryPath:()=>t.registryPath,getRegistry:n=>He(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{},loadComponent:async n=>{let o=await He(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>He(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>He(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>He(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>He(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Ft(t),setPublicApiKey:n=>zr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-qwik"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function ts(e){let t=await Dt(e,e.getAppRootDir(),"components");if(!t)throw new Error(`Could not find components directory within project: ${e.getAppRootDir()}`);let r=await ie(e,t),n=e.join(e.getAppRootDir(),".env");return{...e,componentsDir:t,registryPath:r,envPath:n}}async function Pt(e){return await Fe(e,[".env"],yt)}async function to(e,t){let r=await Pt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var yt="PUBLIC_BUILDER_KEY";var ns=new Set(["dist","node_modules"]);async function no(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker(),i=e.join(e.getAppRootDir(),"build");return await Promise.all(n.map(async a=>{let s=e.basename(a.fileName);if(s.startsWith(".")||s==="node_modules"||kt(e,ns,a.fileName)||rs.has(s)||s.includes("$."))return;let u=e.normalize(a.fileName);if(u===e.remixConfigPath||u===i)return;let p=await Me(e,o,u,a,u===e.registryPath);r.push(...p)})),r}var rs=new Set(["root.tsx","root.ts","root.jsx","root.js","_index.tsx","_index.jsx","_index.ts","_index.js"]);async function ro(e){await Kt(e);let t=await e.readFile(e.registryPath);return t?os(e,t):{components:[],sourceFile:b(e,"")}}async function os(e,t){let r=b(e,t);return is(e,r)}async function is(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 Cn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Cn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};e.sdkVersion===y.gen2&&it(e,r)&&(n.acceptsChildren=!0);for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){(e.ts.isIdentifier(s.expression)&&s.expression.text)==="withChildren"&&(n.acceptsChildren=!0);let f=s.arguments[0];e.ts.isIdentifier(f)&&(a=f.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(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 Fr(e,u.filePath,e.registryPath===u.filePath||Ae(u.filePath));if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Be(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m]=await Promise.all([no(e,u),ro(e),Pt(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await pt(e,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await G(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await ct(e,A,F,e.registryPath===A.cmpInfo.filePath||Ae(A.cmpInfo.filePath));pe(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let k=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:Y}=await ss(e,x,A);if(k.addCmpToRegistry)P.push(as(e,k.addCmpToRegistry)),g=!0;else if(k.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(k.updateRegisteredCmp){let _=W(e,P[w],k.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[oo(e,k.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)});let te=e.sdkVersion===y.gen2?"@builder.io/sdk-react":"@builder.io/react";x=I(e,x,{namedImports:["RegisteredComponent"],importPath:te,isTypeOnly:!0}),S.acceptsChildren&&e.sdkVersion!==y.gen2&&(x=I(e,x,{namedImports:["withChildren"],importPath:"@builder.io/react"})),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=k.components,d=k.components.filter(We=>We.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function oo(e,t){if(e.sdkVersion===y.gen2)return e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName));let r=e.ts.factory.createIdentifier(t.importName),n=t.acceptsChildren?e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[r]):r;return e.ts.factory.createPropertyAssignment("component",n)}function as(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([oo(e,t),...t.acceptsChildren&&e.sdkVersion===y.gen2?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}async function ss(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 Cn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function io(e){let t=[],r=await cs(e,t);return t.push(...await Kt(e)),await ms(e,r),await ps(e,t),t}async function ao(e){let t=[];return t.push(...await Kt(e)),await us(e,t),t}async function us(e,t){let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureFigmaImportRoute, hasLocaleParam"),r=`($locale).${r}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureFigmaImportRoute, hasRoute: ${o}`);let i=await e.formatCode(n,so({sys:e,routePath:n,modelName:"figma-imports"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}async function ps(e,t){let r=`$.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureAppRoute, hasLocaleParam"),r=`($locale).${r}`),e.sdkVersion===y.gen2&&(r=`($slug)._index.${e.typescriptEnabled?"tsx":"jsx"}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureAppRoute, hasRoute: ${o}`);let i=await e.formatCode(n,so({sys:e,routePath:n,modelName:"page"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}function so({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.registryPath),i="",a="";n&&(i="import type { LoaderArgs } from '@remix-run/server-runtime';",a=": LoaderArgs");let s=`process.env.${yt}`,u="";return e.getFrameworks().some(p=>p.name==="@shopify/remix-oxygen")&&(s=`context.env.${yt}`,u=", context"),n&&(s+="!"),e.sdkVersion===y.gen2?`
|
|
398
|
+
`;async function Zr(e){await xn(e);let t=await e.readFile(e.registryPath);return t?Xa(e,t):{components:[],sourceFile:b(e,"")}}async function Xa(e,t){let r=b(e,t);return Za(e,r)}async function Za(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 Cn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Cn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"qwik"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"&&e.ts.isIdentifier(o.initializer)){let a=o.initializer.text;n.name===""&&(n.name=K(a)),n.importName=a;let s=await we(e,e.registryPath,t,a);if(!s)continue;n.filePath=s.filePath,n.relFilePath=s.relFilePath,n.importPath=M(e,s.filePath),n.displayFilePath=s.displayFilePath,n.exportType=s.exportType;let u=await Gr(e,s.filePath);if(u&&u.length>0)if(u.length===1)n.exportName=u[0].cmpInfo.exportName;else{let p=u.find(f=>f.cmpInfo.exportName===a);p&&(n.exportName=p.cmpInfo.exportName)}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName)),n}async function eo(e){let t=new Set,r=async o=>{let i=await e.readdir(o);await Promise.all(i.map(async a=>{if(a.startsWith(".")||a==="node_modules")return;let s=e.join(o,a),u=e.extname(a).toLowerCase();if(u===".tsx"||u===".ts"){t.add(s);return}(await e.stat(s)).isDirectory()&&await r(s)}))};return await r(e.getAppRootDir()),await G(e,[...t])}async function He(e,t,r,n,o,i,a,s){let u=await eo(e),[p,f,m]=await Promise.all([Yr(e,u),Zr(e),Ft(e)]),c=p.map(g=>g.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D;if(t!=null){let g=p.find(P=>P.cmpInfo.id===t);if(!g)throw new Error(`Component ${t} not found`);let x=f.sourceFile,l=D.components.find(P=>P.id===t),C=await Hr(e,g);pe(l,C),t=Array.isArray(t)?t[0]:t;let E=Ie(t,c,d,r,n,o,i),{elements:F,elmIndex:A,statementIndex:S,statement:B,variableDeclaration:$}=await ts(e,x,g),k=!1;if(E.addCmpToRegistry?(F.push(es(e,E.addCmpToRegistry)),k=!0):E.removeCmpFromRegistry?(F.splice(A,1),k=!0):E.updateRegisteredCmp&&(F[A]=W(e,F[A],E.updateRegisteredCmp),k=!0),k&&a){let P=[...x.statements];P[S]=e.ts.factory.updateVariableStatement(B,B.modifiers,e.ts.factory.updateVariableDeclarationList(B.declarationList,[e.ts.factory.updateVariableDeclaration($,$.name,$.exclamationToken,$.type,e.ts.factory.createArrayLiteralExpression(Te(e,F)))])),x=e.ts.factory.updateSourceFile(x,P),l.exportType==="named"?x=I(e,x,{namedImports:[l.importName],importPath:N(e,e.registryPath,l.filePath)}):x=I(e,x,{defaultImport:l.importName,importPath:N(e,e.registryPath,l.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-qwik",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),x=be(e,x),x=ve(e,x);let w=j(e,x);w=De(w),w=Wr(w,ns,"CUSTOM_COMPONENTS"),w=await e.formatCode(e.registryPath,w),await e.writeFile(e.registryPath,w)}D.components=E.components}return D}function es(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName))],!0),t)}async function ts(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 Cn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}var ns=["This array is used to integrate custom components within Builder.","https://www.builder.io/c/docs/custom-components-intro","",'These components will be found the "Custom Components"',"section of Builder's visual editor.",'You can also turn on "components only mode" to limit',"editing to only these components.","https://www.builder.io/c/docs/guides/components-only-mode"];async function to(e){let t=await rs(e);return{builderPageOptions:async()=>({templateContentId:"dc70f1d979ad416d8fd357137eb9ddfb",pathname:"/",title:"Builder + Qwik Demo Page"}),ensureBuilderSetup:()=>Xr(t),ensureFigmaImportPage:async()=>[],getRegistryPath:()=>t.registryPath,getRegistry:n=>He(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{},loadComponent:async n=>{let o=await He(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>He(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>He(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>He(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>He(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Ft(t),setPublicApiKey:n=>qr(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-qwik"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function rs(e){let t=await Dt(e,e.getAppRootDir(),"components");if(!t)throw new Error(`Could not find components directory within project: ${e.getAppRootDir()}`);let r=await ie(e,t),n=e.join(e.getAppRootDir(),".env");return{...e,componentsDir:t,registryPath:r,envPath:n}}async function Pt(e){return await Fe(e,[".env"],yt)}async function no(e,t){let r=await Pt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var yt="PUBLIC_BUILDER_KEY";var os=new Set(["dist","node_modules"]);async function ro(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker(),i=e.join(e.getAppRootDir(),"build");return await Promise.all(n.map(async a=>{let s=e.basename(a.fileName);if(s.startsWith(".")||s==="node_modules"||kt(e,os,a.fileName)||is.has(s)||s.includes("$."))return;let u=e.normalize(a.fileName);if(u===e.remixConfigPath||u===i)return;let p=await Me(e,o,u,a,u===e.registryPath);r.push(...p)})),r}var is=new Set(["root.tsx","root.ts","root.jsx","root.js","_index.tsx","_index.jsx","_index.ts","_index.js"]);async function oo(e){await Kt(e);let t=await e.readFile(e.registryPath);return t?as(e,t):{components:[],sourceFile:b(e,"")}}async function as(e,t){let r=b(e,t);return ss(e,r)}async function ss(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 hn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function hn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};e.sdkVersion===y.gen2&&it(e,r)&&(n.acceptsChildren=!0);for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(e,o)==="component"){let a,{initializer:s}=o;if(e.ts.isIdentifier(s))a=s.text;else if(e.ts.isCallExpression(s)){(e.ts.isIdentifier(s.expression)&&s.expression.text)==="withChildren"&&(n.acceptsChildren=!0);let f=s.arguments[0];e.ts.isIdentifier(f)&&(a=f.text)}if(!a)continue;n.name===""&&(n.name=K(a)),n.importName=a;let u=await we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(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 Pr(e,u.filePath,e.registryPath===u.filePath||Ae(u.filePath));if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Be(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m]=await Promise.all([ro(e,u),oo(e),Pt(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await pt(e,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await G(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await ct(e,A,F,e.registryPath===A.cmpInfo.filePath||Ae(A.cmpInfo.filePath));pe(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let k=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:Y}=await ps(e,x,A);if(k.addCmpToRegistry)P.push(us(e,k.addCmpToRegistry)),g=!0;else if(k.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(k.updateRegisteredCmp){let _=W(e,P[w],k.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[io(e,k.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)});let te=e.sdkVersion===y.gen2?"@builder.io/sdk-react":"@builder.io/react";x=I(e,x,{namedImports:["RegisteredComponent"],importPath:te,isTypeOnly:!0}),S.acceptsChildren&&e.sdkVersion!==y.gen2&&(x=I(e,x,{namedImports:["withChildren"],importPath:"@builder.io/react"})),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=k.components,d=k.components.filter(We=>We.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function io(e,t){if(e.sdkVersion===y.gen2)return e.ts.factory.createPropertyAssignment("component",e.ts.factory.createIdentifier(t.importName));let r=e.ts.factory.createIdentifier(t.importName),n=t.acceptsChildren?e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("withChildren"),void 0,[r]):r;return e.ts.factory.createPropertyAssignment("component",n)}function us(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([io(e,t),...t.acceptsChildren&&e.sdkVersion===y.gen2?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}async function ps(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 hn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function ao(e){let t=[],r=await ms(e,t);return t.push(...await Kt(e)),await ds(e,r),await ls(e,t),t}async function so(e){let t=[];return t.push(...await Kt(e)),await cs(e,t),t}async function cs(e,t){let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureFigmaImportRoute, hasLocaleParam"),r=`($locale).${r}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureFigmaImportRoute, hasRoute: ${o}`);let i=await e.formatCode(n,uo({sys:e,routePath:n,modelName:"figma-imports"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}async function ls(e,t){let r=`$.${e.typescriptEnabled?"tsx":"jsx"}`;e.hasLocaleParam&&(e.debug("remixEnsureAppRoute, hasLocaleParam"),r=`($locale).${r}`),e.sdkVersion===y.gen2&&(r=`($slug)._index.${e.typescriptEnabled?"tsx":"jsx"}`);let n=e.join(e.routesDir,r),o=await e.exists(n);e.debug(`remixEnsureAppRoute, hasRoute: ${o}`);let i=await e.formatCode(n,uo({sys:e,routePath:n,modelName:"page"}));await e.writeFile(n,i),t.push({filePath:n,modifiedType:o?"update":"create"})}function uo({sys:e,routePath:t,modelName:r}){let n=e.typescriptEnabled,o=N(e,t,e.registryPath),i="",a="";n&&(i="import type { LoaderArgs } from '@remix-run/server-runtime';",a=": LoaderArgs");let s=`process.env.${yt}`,u="";return e.getFrameworks().some(p=>p.name==="@shopify/remix-oxygen")&&(s=`context.env.${yt}`,u=", context"),n&&(s+="!"),e.sdkVersion===y.gen2?`
|
|
399
399
|
|
|
400
400
|
import {
|
|
401
401
|
Content,
|
|
@@ -505,7 +505,7 @@ declare global {
|
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
`:""}
|
|
508
|
-
`}async function
|
|
508
|
+
`}async function ms(e,t){let n=e.typescriptEnabled?"tsx":"jsx",o=e.join(e.componentsDir,"Counter"),i=e.join(o,`Counter.${n}`),a=e.join(o,"styles.module.css"),{component:s,styles:u}=fs(e),p=await e.exists(i);if(e.debug(`remixEnsureCounterComponent, hasCounterCmp: ${p}`),!p){let m=await e.formatCode(i,s);await e.writeFile(i,m),t.push({filePath:i,modifiedType:"create"})}let f=await e.exists(a);return e.debug(`remixEnsureCounterComponent, hasCounterStyles: ${f}`),f||(await e.writeFile(a,u),t.push({filePath:a,modifiedType:"create"})),i}function fs(e){let t=e.typescriptEnabled,r=`
|
|
509
509
|
import { useState } from "react";
|
|
510
510
|
import styles from "./styles.module.css";
|
|
511
511
|
${t?`
|
|
@@ -568,17 +568,17 @@ export default Counter;
|
|
|
568
568
|
font-size: 42px;
|
|
569
569
|
text-align: center;
|
|
570
570
|
}
|
|
571
|
-
`.trimStart();return{component:r,styles:n}}async function
|
|
571
|
+
`.trimStart();return{component:r,styles:n}}async function ds(e,t){let n=(await Be(e,null,!1,!1,null,null,!1,!1)).components.find(o=>o.filePath===t);n&&await Be(e,n.id,!0,!1,null,null,!0,!1)}async function Kt(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,gs(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}function gs(e){let t=e.sdkVersion===y.gen2;return e.typescriptEnabled?`import type { RegisteredComponent } from ${t?'"@builder.io/sdk-react"':'"@builder.io/react"'};
|
|
572
572
|
|
|
573
573
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
574
574
|
];`:`export const CUSTOM_COMPONENTS = [
|
|
575
575
|
];
|
|
576
|
-
`}async function
|
|
576
|
+
`}async function po(e){let t=await Ds(e);return{builderPageOptions:async()=>{let n="/builder-demo",o=t.hasLocaleParam?`/en-us${n}`:void 0;return{templateContentId:"a5c9eef7909d4fc99554264a17de22c9",pathname:n,localePathname:o,title:"Builder + Remix Demo Page"}},ensureBuilderSetup:()=>ao(t),ensureFigmaImportPage:()=>so(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Be(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Be(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Be(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Be(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Be(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Be(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Pt(t),setPublicApiKey:n=>no(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Ds(e){let t=await Cs(e),r=e.getAppRootDir(),n=await hs(e),o=e.dirname(n),i=e.join(o,"components"),a=await ne(e),s=await ie(e,o),u={},p={...e,registryPath:s,remixConfigPath:t,typescriptEnabled:a,appDir:o,componentsDir:i,routesDir:n,hasLocaleParam:await xs(e,n),addExternalPackage:f=>{u[e.join(r,f,"index.ts")]=`export * from "${f}";`},readFileSync:f=>u[f]??e.readFileSync(f),existsSync:f=>!!u[f]||e.existsSync(f),readdirSync:f=>{let m=e.readdirSync(f);return f===r?[...m,...Object.keys(u).map(c=>c.slice(r.length+1))]:m},readdir:async f=>{let m=await e.readdir(f);return f===r?[...m,...Object.keys(u).map(c=>c.slice(r.length+1))]:m}};return e.sdkVersion?p.sdkVersion=e.sdkVersion:p.sdkVersion=await mt(p),p}async function xs(e,t){return(await e.readdir(t)).some(n=>n.startsWith("($locale)."))}async function Cs(e){let t=["remix.config.ts","remix.config.js","vite.config.ts","vite.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Remix config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function hs(e){let t=await Dt(e,e.getAppRootDir(),"routes");if(t)return t;throw new Error(`Could not find Remix "routes" directory in "${e.getAppRootDir()}". Please ensure this command is ran from within your Remix project's directory.`)}async function wt(e){let t=[".env"],r=e.configType==="vite"?vt:Mt;return await Fe(e,t,r)}async function co(e,t){let r=await wt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var vt="VITE_PUBLIC_BUILDER_KEY",Mt="PUBLIC_BUILDER_KEY";function lo(e,t){let r=`Builder.registerComponent(
|
|
577
577
|
`;r+=` ${t.importName},
|
|
578
578
|
`,r+=` {
|
|
579
579
|
name: "${t.name}",
|
|
580
580
|
}
|
|
581
|
-
`,r+=");";let n=Lt(e,r);return
|
|
581
|
+
`,r+=");";let n=Lt(e,r);return En(e,n,t)}function En(e,t,r){if(!e.ts.isExpressionStatement(t))return t;let n=t.expression;if(!e.ts.isCallExpression(n))return t;let o=[...n.arguments];if(o.length<2)return t;let i=o[1];return e.ts.isObjectLiteralExpression(i)?(o[1]=W(e,i,r),e.ts.factory.updateExpressionStatement(t,e.ts.factory.updateCallExpression(n,n.expression,n.typeArguments,o))):t}async function mo(e){let t=await e.readFile(e.registryPath);return t?Es(e,t):{components:[],sourceFile:b(e,"")}}async function Es(e,t){let r=b(e,t);return e.sdkVersion===y.gen2?Fs(e,r):Ss(e,r)}async function Ss(e,t){let r=[];for(let n=0;n<t.statements.length;n++){let o=t.statements[n];if(!e.ts.isExpressionStatement(o))continue;let i=o.expression;if(!e.ts.isCallExpression(i))continue;let a=i.expression;if(!e.ts.isPropertyAccessExpression(a))continue;let s=a.expression;if(!e.ts.isIdentifier(s)||s.text!=="Builder"||a.name.text!=="registerComponent")continue;let p=i.arguments;if(p.length<2)continue;let f=p[1];if(!e.ts.isObjectLiteralExpression(f))continue;let m=p[0];if(e.ts.isIdentifier(m)){let c=await As(e,t,n,m,f,!1);c&&r.push(c);continue}}return{sourceFile:t,components:ae(r)}}async function As(e,t,r,n,o,i){let a={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],nodeIndex:r,acceptsChildren:i,framework:"react"},s=t.statements.filter(p=>e.ts.isImportDeclaration(p)),u=s.find(p=>p.importClause&&p.importClause.name?.text===n.text);if(u){let p=u.moduleSpecifier;if(!e.ts.isStringLiteral(p))return null;a.filePath=await Sn(e,p.text),a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),a.importPath=M(e,a.filePath),a.name=le(e,a.filePath),a.importName=n.text,a.exportName="default",a.exportType="default"}else{let p=s.find(c=>!c.importClause||!c.importClause.namedBindings||!e.ts.isNamedImports(c.importClause.namedBindings)?!1:c.importClause.namedBindings.elements.some(d=>d.name.text===n.text));if(!p)return null;let f=p.moduleSpecifier;if(!e.ts.isStringLiteral(f))return null;let m=await Sn(e,f.text);a.filePath=await Sn(e,f.text),a.relFilePath=e.relative(e.getAppRootDir(),a.filePath),await e.exists(m)?a.importPath=M(e,a.filePath):(a.externalImportPath=f.text,a.importPath=a.externalImportPath),a.name=K(n.text),a.importName=n.text,a.exportName=n.text,a.exportType="named"}return a=se(e,a,o),a.displayFilePath=O(e,a.filePath),a.filePath&&a.exportName&&(a.id=await V(e,a.filePath,a.exportName,a.externalImportPath)),a}function Sn(e,t){return At(e,e.normalize(e.resolve(e.dirname(e.registryPath),t)))}async function Fs(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 An(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function An(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],acceptsChildren:!1,framework:"react"};it(e,r)&&(n.acceptsChildren=!0);for(let i of r.properties){if(!e.ts.isPropertyAssignment(i)||!e.ts.isIdentifier(i.name))continue;if(L(e,i)==="component"){let s,{initializer:u}=i;if(e.ts.isIdentifier(u)&&(s=u.text),!s)continue;n.name===""&&(n.name=K(s)),n.importName=s;let p=await we(e,e.registryPath,t,s);if(!p)continue;n.filePath=p.filePath,n.relFilePath=p.relFilePath,await e.exists(p.filePath)?n.importPath=M(e,p.filePath):(n.externalImportPath=p.importPath,n.importPath=n.externalImportPath),n.displayFilePath=p.displayFilePath,n.exportType=p.exportType;let f=t.statements.filter(c=>e.ts.isImportDeclaration(c)),m=f.find(c=>c.importClause&&c.importClause.name?.text===s);if(m){let c=m.moduleSpecifier;if(!e.ts.isStringLiteral(c))return null;n.exportName="default"}else{let c=f.find(D=>!D.importClause||!D.importClause.namedBindings||!e.ts.isNamedImports(D.importClause.namedBindings)?!1:D.importClause.namedBindings.elements.some(g=>g.name.text===s));if(!c)return null;let d=c.moduleSpecifier;if(!e.ts.isStringLiteral(d))return null;n.exportName=s}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function Oe(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m,c]=await Promise.all([yr(e,u),mo(e),ne(e),wt(e)]),d=p.map(E=>E.cmpInfo),D=f.components,g={components:Ee(d,D),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(d),publicApiKey:c.envValue??void 0,devToolsVersion:e.version};if(s)return g.components=await pt(e,g.components),g;let x=!1,l=f.sourceFile,C=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(C.length>0){let E=C.map(S=>{let B=p.find($=>$.cmpInfo.id===S);if(!B)throw new Error(`Component ${S} not found`);return B}),F=Array.from(new Set(E.map(S=>S.cmpInfo.filePath))),A=await G(e,F);for(let S of E){let B=g.components.find(w=>w.id===S.cmpInfo.id),$=await ct(e,S,A,e.registryPath===S.cmpInfo.filePath||Ae(S.cmpInfo.filePath));pe(B,$);let k=d.findIndex(w=>w.id===S.cmpInfo.id);d[k].inputs=$;let P=Ie(S.cmpInfo.id,d,D,r,n,o,i);if(e.sdkVersion===y.gen2){let{elements:w,elmIndex:ee,statementIndex:Ce,statement:Y,variableDeclaration:_}=await Ps(e,l,S);if(P.addCmpToRegistry)w.push(ys(e,P.addCmpToRegistry)),x=!0;else if(P.removeCmpFromRegistry)w.splice(ee,1),x=!0;else if(P.updateRegisteredCmp){let te=W(e,w[ee],P.updateRegisteredCmp),We=e.ts.factory.createIdentifier(P.updateRegisteredCmp.importName);w[ee]=e.ts.factory.updateObjectLiteralExpression(te,[e.ts.factory.createPropertyAssignment("component",We),...te.properties.slice(1)]),x=!0}if(x&&a){let te=[...l.statements];te[Ce]=e.ts.factory.updateVariableStatement(Y,Y.modifiers,e.ts.factory.updateVariableDeclarationList(Y.declarationList,[e.ts.factory.updateVariableDeclaration(_,_.name,_.exclamationToken,_.type,e.ts.factory.createArrayLiteralExpression(Te(e,w)))])),l=e.ts.factory.updateSourceFile(l,te),l=fo(e,P,l),l=I(e,l,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-react",isTypeOnly:!0}),l=Re(e,l,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),g.components=P.components,D=P.components.filter(We=>We.isRegistered)}}else{let w=[...l.statements];P.addCmpToRegistry?(w.push(lo(e,P.addCmpToRegistry)),x=!0):P.removeCmpFromRegistry?(w.splice(P.nodeIndex,1),x=!0):P.updateRegisteredCmp&&(w[P.nodeIndex]=En(e,w[P.nodeIndex],P.updateRegisteredCmp),x=!0),x&&a&&(l=e.ts.factory.updateSourceFile(l,w),l=I(e,l,{namedImports:["Builder","builder"],importPath:"@builder.io/react"}),l=fo(e,P,l),B?.acceptsChildren&&(l=I(e,l,{namedImports:["withChildren"],importPath:"@builder.io/react"})),g.components=P.components,D=P.components.filter(ee=>ee.isRegistered))}}}if(x&&a){l=be(e,l),l=ve(e,l);let E=j(e,l);E=De(E),E=await e.formatCode(e.registryPath,E),await e.writeFile(e.registryPath,E)}return g}async function Ps(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 An(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}function ys(e,t){let r=e.ts.factory.createIdentifier(t.importName);return W(e,e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("component",r),...t.acceptsChildren?[e.ts.factory.createPropertyAssignment("canHaveChildren",e.ts.factory.createTrue())]:[]],!0),t)}function fo(e,t,r){let n=t.addCmpToRegistry||t.updateRegisteredCmp;if(n){let o=n.externalImportPath?n.externalImportPath:N(e,e.registryPath,n.filePath);n.exportType==="default"?r=I(e,r,{defaultImport:n.importName,importPath:o}):n.exportType==="named"&&(r=I(e,r,{namedImports:[n.importName],importPath:o}))}return r}async function go(e){let t=[],r=await ws(e,t);if(await Co(e,t,r),!await e.exists(e.builderComponentPath)){let n=await e.formatCode(e.builderComponentPath,xo(e,e.builderComponentPath));await e.writeFile(e.builderComponentPath,n),t.push({filePath:e.builderComponentPath,modifiedType:"create"})}return t}async function Do(e){let t=[];await Co(e,t);let r=`figma-imports.${e.typescriptEnabled?"tsx":"jsx"}`,n=e.join(e.componentsDir,r);if(!await e.exists(n)){let o=await e.formatCode(n,xo(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}function xo(e,t,r="page"){let n=e.typescriptEnabled;return e.sdkVersion===y.gen2?`
|
|
582
582
|
import React from "react";
|
|
583
583
|
import {
|
|
584
584
|
Content,
|
|
@@ -688,7 +688,7 @@ export default function BuilderPage() {
|
|
|
688
688
|
</>
|
|
689
689
|
);
|
|
690
690
|
}
|
|
691
|
-
`.trimStart()}async function
|
|
691
|
+
`.trimStart()}async function Co(e,t,r){if(!await e.exists(e.registryPath)){if(e.sdkVersion===y.gen2){let i=Ts(e);await e.writeFile(e.registryPath,i)}else await e.writeFile(e.registryPath,"");t.push({filePath:e.registryPath,modifiedType:"create"})}if(!r)return;let o=(await Oe(e,null,!1,!1,null,null,!1,!1)).components.find(i=>i.filePath===r);o&&await Oe(e,o.id,!0,!1,null,null,!0,!1)}async function ws(e,t){let n=e.typescriptEnabled?"tsx":"jsx",o=e.join(e.componentsDir,"Counter"),i=e.join(o,`Counter.${n}`),a=e.join(o,"styles.module.css"),{component:s,styles:u}=vs(e);if(!await e.exists(i)){let p=await e.formatCode(i,s);await e.writeFile(i,p),t.push({filePath:i,modifiedType:"create"})}return await e.exists(a)||(await e.writeFile(a,u),t.push({filePath:a,modifiedType:"create"})),i}function vs(e){let t=e.typescriptEnabled,r=`
|
|
692
692
|
"use client"
|
|
693
693
|
import React, { useState } from "react";
|
|
694
694
|
import styles from "./styles.module.css";
|
|
@@ -751,31 +751,31 @@ export default Counter;
|
|
|
751
751
|
font-size: 42px;
|
|
752
752
|
text-align: center;
|
|
753
753
|
}
|
|
754
|
-
`.trimStart();return{component:r,styles:n}}function
|
|
754
|
+
`.trimStart();return{component:r,styles:n}}function Ts(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-react";
|
|
755
755
|
|
|
756
756
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
757
757
|
];`:`export const CUSTOM_COMPONENTS = [
|
|
758
758
|
];
|
|
759
|
-
`}async function
|
|
759
|
+
`}async function ho(e){let t=await bs(e);return{builderPageOptions:async()=>({templateContentId:"2e36438034894a8abf279ea9e6d3596f",pathname:"/builder-demo",title:"Builder + React Demo Page"}),ensureBuilderSetup:()=>go(t),ensureFigmaImportPage:()=>Do(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>Oe(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await Oe(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>Oe(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>Oe(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>Oe(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>Oe(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>wt(t),setPublicApiKey:n=>co(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-react"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/react"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function bs(e){let t=await Is(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",reactConfigPath:t,typescriptEnabled:o,configType:"",addExternalPackage:s=>{i[e.join(r,s,"index.ts")]=`export * from "${s}";`},readFileSync:s=>i[s]??e.readFileSync(s),existsSync:s=>!!i[s]||e.existsSync(s),readdirSync:s=>{let u=e.readdirSync(s);return s===r?[...u,...Object.keys(i).map(p=>p.slice(r.length+1))]:u},readdir:async s=>{let u=await e.readdir(s);return s===r?[...u,...Object.keys(i).map(p=>p.slice(r.length+1))]:u}};return e.sdkVersion?a.sdkVersion=e.sdkVersion:a.sdkVersion=await mt(a),t.includes("webpack.config")&&(a.configType="webpack"),t.includes("vite.config")&&(a.configType="vite"),await e.exists(n)?(a.srcDir=n,a.componentsDir=e.join(n,"components"),a.registryPath=await ie(e,n),a.builderComponentPath=e.join(a.srcDir,`builder-page.${o?"tsx":"jsx"}`)):(a.componentsDir=e.join(r,"components"),a.registryPath=await ie(e,r),a.builderComponentPath=e.join(r,`builder-page.${o?"tsx":"jsx"}`)),a}async function Is(e){let t=["vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find React config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function Tt(e){return await Rs(e,["environment.ts"],Ut)}async function Eo(e,t){let r=await Tt(e),n=await ks(e,r.file,r.envKey,t);return{...r,modifiedType:n}}async function Rs(e,t,r){let n={envKey:r,envValue:null,file:""};for(let o of t){let i=e.join(e.getAppRootDir(),"src","environments",o),a=await Ns(e,i);if(typeof a=="string"&&a.length>0&&a!=="YOUR_API_KEY")return n.envValue=a,n.file=i,n}return n.file=e.join(e.getAppRootDir(),"src","environments",t[t.length-1]),n}async function Ns(e,t){let r=await e.readFile(t);return r?Bs(e,r):""}function Bs(e,t){let r=b(e,t),n="",i=st(e,r,"environment");if(i&&i.statement.declarationList.declarations.length>0){let s=i.statement.declarationList.declarations[0].initializer;s&&e.ts.isObjectLiteralExpression(s)&&s.properties.forEach(u=>{e.ts.isPropertyAssignment(u)&&e.ts.isIdentifier(u.name)&&u.name.text===Ut&&e.ts.isStringLiteral(u.initializer)&&(n=u.initializer.text)})}return n}async function Os(e,t,r,n){let o=b(e,t),a=st(e,o,"environment");if(a&&a.statement.declarationList.declarations.length>0){let s=a.statement.declarationList,u=s.declarations[0],p=u.initializer;if(p&&e.ts.isObjectLiteralExpression(p)){let f=e.ts.factory.createPropertyAssignment(e.ts.factory.createIdentifier(r),e.ts.factory.createStringLiteral(n)),m=e.ts.factory.createNodeArray([...p.properties,f]),c=e.ts.factory.updateObjectLiteralExpression(p,m),d=e.ts.factory.updateVariableDeclaration(u,u.name,u.exclamationToken,u.type,c),D=e.ts.factory.updateVariableDeclarationList(s,[d]);return e.ts.factory.updateVariableStatement(a.statement,a.statement.modifiers,D)}return null}return null}async function ks(e,t,r,n){let o=await e.readFile(t);if(o)if(o.includes(r))e.debug(`"${r}" already set in ${t}`);else{e.debug(`Add "${r}" to ${t}`);let i=await Os(e,o,r,n);if(i){let a=j(e,i),s=await e.formatCode(t,a);await e.writeFile(t,s)}return"update"}else{e.debug(`Creating new env file with "${r}" at ${t}`);let i=`
|
|
760
760
|
// https://www.builder.io/c/docs/using-your-api-key
|
|
761
761
|
export const environment = {
|
|
762
762
|
production: false,
|
|
763
763
|
builderApiKey: "${n}",
|
|
764
764
|
};
|
|
765
|
-
`.trimStart(),a=await e.formatCode(t,i);return await e.writeFile(t,a),"create"}return null}var Ut="builderApiKey";async function So(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(Ls(e,i.fileName)||a.startsWith(".")||a==="node_modules"||Os.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await zt(e,o,s,i);r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Os=new Set([]),ks=new Set(["node_modules"]);function Ls(e,t){for(let r of ks)if(e.dirname(t).includes(r))return!0;return!1}async function Ao(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return _s(e,t,n)}return null}function _s(e,t,r){let n=b(e,r);return zt(e,null,t,n)}async function zt(e,t,r,n){let o=[],i={};r=e.normalize(r);let a=n.statements.filter(f=>e.ts.isClassDeclaration(f)&&Ms(e,f)),s=n.statements.find(f=>e.ts.isImportDeclaration(f)&&e.ts.isStringLiteral(f.moduleSpecifier)&&f.moduleSpecifier.text==="@angular/core");if(s&&e.ts.isImportDeclaration(s)){let f=s.importClause?.namedBindings;if(f&&e.ts.isNamedImports(f)){let m=f.elements.find(c=>(c.propertyName??c.name).text==="input");m&&(i.inputSignalImportName=m.name.text)}}let u=await Vs(e,t,r,n),p=Us(e,n);return await Promise.all(a.map(async f=>{let m=await js(e,t,r,f,p,i);o.push(...m)})),o.push(...u),o}async function An(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await at(e,t.cmpInfo.filePath,r),a=(await zt(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return a.cmpInfo.inputs}return[]}async function Fo(e,t,r){let n=await G(e,r.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(r.filter(a=>!(a.name.endsWith("Page")||a.name.endsWith("Module")||a.name==="AppComponent")).map(async a=>{if(!a.isRegistered){let s=n.getSourceFile(a.filePath);if(s){let p=(await zt(e,o,a.filePath,s)).find(f=>f.cmpInfo.id===a.id);if(p){a.inputs=Ge(e,o,p.node.fnNode);let f=t.find(m=>m.cmpInfo.id===a.id);if(f){let m=await An(e,f,n);pe(a,m)}}}}return a}))}async function js(e,t,r,n,o,i){let a=[],s=e.relative(e.getAppRootDir(),r),u=M(e,r),p=n.name?.text;if(!p)return a;let f=!1;n.modifiers&&(f=n.modifiers.some(D=>D.kind===e.ts.SyntaxKind.DefaultKeyword));let m=f?"default":p,c=f?"default":"named",d=[];return n.members.forEach(D=>{if(e.ts.isPropertyDeclaration(D)||e.ts.isGetAccessor(D)||e.ts.isSetAccessor(D)){let l=(e.ts.getDecorators(D)??[]).find(E=>$s(e,E))!==void 0&&e.ts.isIdentifier(D.name),C=i?.inputSignalImportName!==void 0&&e.ts.isIdentifier(D.name)&&Ks(e,D,i.inputSignalImportName);if(l||C){let E="any";if(e.ts.isSetAccessor(D))E=Eo(e,D.parameters[0].type);else if(D.type&&t){let A=t.getTypeAtLocation(D.type);E=t.typeToString(A)}else E=Eo(e,D.type);let F={name:D.name.text,type:o[E]?"string":E};o[E]&&(F.enum=o[E]),d.push(F)}}}),a.push({cmpInfo:{id:await V(e,r,p),displayFilePath:O(e,r),name:K(p),inputs:d,exportName:m,exportType:c,importName:p,filePath:r,relFilePath:s,importPath:u,meta:{...qs(e,n)},framework:"angular"},node:{name:p,fnNode:n,deps:void 0}}),a}async function Vs(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);for(let s of n.statements)if(e.ts.isExportDeclaration(s)&&s.exportClause&&e.ts.isNamedExports(s.exportClause))for(let u of s.exportClause.elements){let p=u.name?.text;if(!p)continue;let f=p,m="named",c=[];if(t){let g=t.getSymbolAtLocation(u.name);if(g){let x=t.getDeclaredTypeOfSymbol(g);t.getPropertiesOfType(x).forEach(C=>{let E=C.getDeclarations();E&&E.forEach(F=>{if(e.ts.isPropertyDeclaration(F)){let A=t.getTypeAtLocation(F),S={name:C.getName(),type:zs(e,t,A)};c.push(S)}})})}}let d=e.ts.isExportSpecifier(u)&&u.parent?u.parent.parent:void 0,D;if(d){let g=d.moduleSpecifier;if(g&&e.ts.isStringLiteral(g)){let x=t?.getSymbolAtLocation(g);if(x&&x.declarations&&x.declarations.length>0){let l=x.declarations[0];(!e.ts.isSourceFile(l)||e.ts.isSourceFile(l)&&l.fileName.includes("node_modules"))&&(D=g.text)}}}o.push({cmpInfo:{id:await V(e,r,p,D),displayFilePath:O(e,r),name:K(p),inputs:c,exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:D||a,externalImportPath:D,framework:"angular"},node:{name:p,fnNode:u,deps:void 0}})}else if(e.ts.isExportDeclaration(s)&&!s.exportClause&&s.moduleSpecifier&&e.ts.isStringLiteral(s.moduleSpecifier)){let u=s.moduleSpecifier.text;if(t)try{let p=t.getSymbolAtLocation(s.moduleSpecifier);if(p&&p.exports){let f=t.getExportsOfModule(p);for(let m of f)if(m.flags&e.ts.SymbolFlags.Class){let c=m.getName();if(c.startsWith("_"))continue;o.push({cmpInfo:{id:await V(e,r,c,u),displayFilePath:O(e,r),name:K(c),inputs:[],exportName:c,exportType:"named",importName:c,filePath:r,relFilePath:i,importPath:u,externalImportPath:u,framework:"angular"},node:{name:c,fnNode:s,deps:void 0}})}}}catch(p){console.warn(`Error processing star export from ${u}:`,p)}}return o}function $s(e,t){return Po(e,t,"Input")}function Ks(e,t,r){return e.ts.isPropertyDeclaration(t)&&t.initializer!==void 0&&e.ts.isCallExpression(t.initializer)&&e.ts.isIdentifier(t.initializer.expression)&&t.initializer.expression.text===r}function Po(e,t,r){if(e.ts.isCallExpression(t.expression)){let n=t.expression;if(e.ts.isIdentifier(n.expression))return n.expression?.text===r}return!1}function Ms(e,t){return!!e.ts.getDecorators(t)?.some(o=>e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="Component")}function Eo(e,t){if(!t)return"any";let r="any";switch(t.kind){case e.ts.SyntaxKind.StringKeyword:r="string";break;case e.ts.SyntaxKind.NumberKeyword:r="number";break;case e.ts.SyntaxKind.BooleanKeyword:r="boolean";break;case e.ts.SyntaxKind.TypeReference:e.ts.isTypeReferenceNode(t)&&e.ts.isIdentifier(t.typeName)&&(r=t.typeName.text);break}return r.includes("|")?"string":r}function Us(e,t){let r={};return e.ts.forEachChild(t,n=>{e.ts.isTypeAliasDeclaration(n)&&e.ts.isUnionTypeNode(n.type)&&n.type.types.every(o=>e.ts.isLiteralTypeNode(o)&&e.ts.isStringLiteral(o.literal))&&(r[n.name.text]=n.type.types.map(o=>o.literal.text))}),r}function zs(e,t,r){let n=t.typeToString(r);if(n==="any"){let o=r.getSymbol();if(o){let i=o.getDeclarations();if(i&&i.length>0){let a=i[0];if(e.ts.isVariableDeclaration(a)){let s=a.type;s&&(n=t.typeToString(t.getTypeAtLocation(s)))}}}}return n}function qs(e,t){let{getDecorators:r,isCallExpression:n,isIdentifier:o,isObjectLiteralExpression:i,isPropertyAssignment:a,isStringLiteral:s,SyntaxKind:u}=e.ts,p,f;return r(t)?.forEach(c=>{if(Po(e,c,"Component")){let{expression:d}=c;if(n(d)){let[D]=d.arguments;i(D)&&D.properties.forEach(g=>{a(g)&&o(g.name)&&(g.name.escapedText==="selector"&&s(g.initializer)&&(p=g.initializer.text),g.name.escapedText==="standalone"&&(f=g.initializer.kind===u.TrueKeyword))})}}}),{selector:p,standalone:f}}async function qt(e,t,r){let n=e.typescriptEnabled?".ts":".js",o=`app.module${n}`,i=e.join(e.appDir,o),a=await e.readFile(i);if(!a){e.Sentry?.captureException(new Error(`Unable to read app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}let s=await Js(e,i,t,r,a);if(!s){e.Sentry?.captureException(new Error(`Unable to update app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}return await e.writeFile(i,s),i}async function Js(e,t,r,n,o){let i=o,a=b(e,o),s=N(e,t,n);a=I(e,a,{namedImports:[r],importPath:s}),a=I(e,a,{namedImports:["Content"],importPath:"@builder.io/sdk-angular"});let u=[];for(let p of a.statements)if(e.ts.isClassDeclaration(p)&&p.name?.text==="AppModule"){let f=Ws(e,r,p);u.push(f)}else u.push(p);return a=e.ts.factory.updateSourceFile(a,u),i=j(e,a),i}function Ws(e,t,r){let n=e.ts.getDecorators(r);if(n){for(let o of n)if(e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="NgModule"){let i=o.expression.arguments;if(i.length===1&&e.ts.isObjectLiteralExpression(i[0])){let a=yo(e,i[0],"declarations",t);if(a){let s=yo(e,a,"imports","Content");if(s&&(a=s),a){let u=e.ts.factory.updateDecorator(o,e.ts.factory.updateCallExpression(o.expression,o.expression.expression,o.expression.typeArguments,[a])),f=[...n.map(m=>m===o?u:m),...e.ts.getModifiers(r)||[]];return e.ts.factory.updateClassDeclaration(r,f,r.name,r.typeParameters,r.heritageClauses,r.members)}}}}}return r}function yo(e,t,r,n){let o=[...t.properties],i=o.findIndex(s=>L(e,s)===r);if(i>-1){let s=o[i];if(e.ts.isPropertyAssignment(s)&&s.initializer&&e.ts.isArrayLiteralExpression(s.initializer)){let u=wo(e,s.initializer,n);return u?(o[i]=e.ts.factory.updatePropertyAssignment(s,s.name,u),e.ts.factory.updateObjectLiteralExpression(t,o)):null}return null}let a=wo(e,e.ts.factory.createArrayLiteralExpression([],!0),n);return a?e.ts.factory.updateObjectLiteralExpression(t,[...o,e.ts.factory.createPropertyAssignment(r,a)]):null}function wo(e,t,r){return t.elements.some(o=>e.ts.isIdentifier(o)?o.text===r:!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier(r)])}async function Fn(e,t,r,n){let i=`app.routes${e.typescriptEnabled?".ts":".js"}`,a=e.join(e.appDir,i);try{if(e.magicast){let s=await e.magicast.loadFile(a);Object.keys(s.exports).length===0&&(s.exports.routes=[]);let p=Object.keys(s.exports)[0],f=s.exports[p];if(f.find(c=>c.path===t))return;let m=e.magicast.builders.raw("{}");if(m.path=t,m.component=e.magicast.builders.raw(r),f.push(m),s.imports.$items.find(c=>c.imported===r))return;s.imports.$append({imported:r,from:n}),await e.magicast.writeFile(s,a)}}catch(s){let u=null;try{u=e.readFileSync(a)}catch(p){e.Sentry?.captureException(p,{level:"warning"})}e.Sentry?.captureException(s,{extra:{content:u,appRoutesPath:a,componentName:r,componentPath:n}})}}var Qs=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,Ys=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,Gs=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Pn={Space_Separator:Qs,ID_Start:Ys,ID_Continue:Gs},q={isSpaceSeparator(e){return typeof e=="string"&&Pn.Space_Separator.test(e)},isIdStartChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||Pn.ID_Start.test(e))},isIdContinueChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="\u200C"||e==="\u200D"||Pn.ID_Continue.test(e))},isDigit(e){return typeof e=="string"&&/[0-9]/.test(e)},isHexDigit(e){return typeof e=="string"&&/[0-9A-Fa-f]/.test(e)}},wn,oe,Ve,Wt,ze,Se,Q,bn,It,Hs=function(t,r){wn=String(t),oe="start",Ve=[],Wt=0,ze=1,Se=0,Q=void 0,bn=void 0,It=void 0;do Q=Xs(),tu[oe]();while(Q.type!=="eof");return typeof r=="function"?vn({"":It},"",r):It};function vn(e,t,r){let n=e[t];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let o=0;o<n.length;o++){let i=String(o),a=vn(n,i,r);a===void 0?delete n[i]:Object.defineProperty(n,i,{value:a,writable:!0,enumerable:!0,configurable:!0})}else for(let o in n){let i=vn(n,o,r);i===void 0?delete n[o]:Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0})}return r.call(e,t,n)}var T,v,bt,je,R;function Xs(){for(T="default",v="",bt=!1,je=1;;){R=$e();let e=To[T]();if(e)return e}}function $e(){if(wn[Wt])return String.fromCodePoint(wn.codePointAt(Wt))}function h(){let e=$e();return e===`
|
|
766
|
-
`?(ze++,Se=0):e?Se+=e.length:Se++,e&&(Wt+=e.length),e}var
|
|
767
|
-
`:case"\r":case"\u2028":case"\u2029":h();return;case"/":h(),T="comment";return;case void 0:return h(),U("eof")}if(q.isSpaceSeparator(R)){h();return}return
|
|
768
|
-
`:case"\r":case"\u2028":case"\u2029":h(),T="default";return;case void 0:return h(),U("eof")}h()},value(){switch(R){case"{":case"[":return U("punctuator",h());case"n":return h(),Xe("ull"),U("null",null);case"t":return h(),Xe("rue"),U("boolean",!0);case"f":return h(),Xe("alse"),U("boolean",!1);case"-":case"+":h()==="-"&&(je=-1),T="sign";return;case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Xe("nfinity"),U("numeric",1/0);case"N":return h(),Xe("aN"),U("numeric",NaN);case'"':case"'":bt=h()==='"',v="",T="string";return}throw z(h())},identifierNameStartEscape(){if(R!=="u")throw z(h());h();let e=
|
|
769
|
-
`:case"\r":throw z(h());case"\u2028":case"\u2029":
|
|
770
|
-
`;case"r":return h(),"\r";case"t":return h()," ";case"v":return h(),"\v";case"0":if(h(),q.isDigit($e()))throw z(h());return"\0";case"x":return h(),
|
|
765
|
+
`.trimStart(),a=await e.formatCode(t,i);return await e.writeFile(t,a),"create"}return null}var Ut="builderApiKey";async function Ao(e,t){let r=[],n=t.getSourceFiles(),o=t.getTypeChecker();return await Promise.all(n.map(async i=>{let a=e.basename(i.fileName);if(js(e,i.fileName)||a.startsWith(".")||a==="node_modules"||Ls.has(a))return;let s=e.normalize(i.fileName);if(s===e.registryPath)return;let u=await zt(e,o,s,i);r.push(...u)})),r.sort((i,a)=>i.cmpInfo.name.localeCompare(a.cmpInfo.name))}var Ls=new Set([]),_s=new Set(["node_modules"]);function js(e,t){for(let r of _s)if(e.dirname(t).includes(r))return!0;return!1}async function Fo(e,t){let r=e.extname(t).toLowerCase();if(r===".tsx"||r===".jsx"||r===".ts"||r===".js"){let n=await e.readFile(t);if(n)return Vs(e,t,n)}return null}function Vs(e,t,r){let n=b(e,r);return zt(e,null,t,n)}async function zt(e,t,r,n){let o=[],i={};r=e.normalize(r);let a=n.statements.filter(f=>e.ts.isClassDeclaration(f)&&zs(e,f)),s=n.statements.find(f=>e.ts.isImportDeclaration(f)&&e.ts.isStringLiteral(f.moduleSpecifier)&&f.moduleSpecifier.text==="@angular/core");if(s&&e.ts.isImportDeclaration(s)){let f=s.importClause?.namedBindings;if(f&&e.ts.isNamedImports(f)){let m=f.elements.find(c=>(c.propertyName??c.name).text==="input");m&&(i.inputSignalImportName=m.name.text)}}let u=await Ks(e,t,r,n),p=qs(e,n);return await Promise.all(a.map(async f=>{let m=await $s(e,t,r,f,p,i);o.push(...m)})),o.push(...u),o}async function Fn(e,t,r){if(t.node.fnNode){let{sourceFile:n,typeChecker:o}=await at(e,t.cmpInfo.filePath,r),a=(await zt(e,o,t.cmpInfo.filePath,n)).find(s=>s.cmpInfo.id===t.cmpInfo.id);if(!a)throw new Error(`Could not find component ${t.cmpInfo.name} in ${t.cmpInfo.filePath}`);return a.cmpInfo.inputs}return[]}async function Po(e,t,r){let n=await G(e,r.map(a=>a.filePath)),o=n.getTypeChecker();return await Promise.all(r.filter(a=>!(a.name.endsWith("Page")||a.name.endsWith("Module")||a.name==="AppComponent")).map(async a=>{if(!a.isRegistered){let s=n.getSourceFile(a.filePath);if(s){let p=(await zt(e,o,a.filePath,s)).find(f=>f.cmpInfo.id===a.id);if(p){a.inputs=Ge(e,o,p.node.fnNode);let f=t.find(m=>m.cmpInfo.id===a.id);if(f){let m=await Fn(e,f,n);pe(a,m)}}}}return a}))}async function $s(e,t,r,n,o,i){let a=[],s=e.relative(e.getAppRootDir(),r),u=M(e,r),p=n.name?.text;if(!p)return a;let f=!1;n.modifiers&&(f=n.modifiers.some(D=>D.kind===e.ts.SyntaxKind.DefaultKeyword));let m=f?"default":p,c=f?"default":"named",d=[];return n.members.forEach(D=>{if(e.ts.isPropertyDeclaration(D)||e.ts.isGetAccessor(D)||e.ts.isSetAccessor(D)){let l=(e.ts.getDecorators(D)??[]).find(E=>Ms(e,E))!==void 0&&e.ts.isIdentifier(D.name),C=i?.inputSignalImportName!==void 0&&e.ts.isIdentifier(D.name)&&Us(e,D,i.inputSignalImportName);if(l||C){let E="any";if(e.ts.isSetAccessor(D))E=So(e,D.parameters[0].type);else if(D.type&&t){let A=t.getTypeAtLocation(D.type);E=t.typeToString(A)}else E=So(e,D.type);let F={name:D.name.text,type:o[E]?"string":E};o[E]&&(F.enum=o[E]),d.push(F)}}}),a.push({cmpInfo:{id:await V(e,r,p),displayFilePath:O(e,r),name:K(p),inputs:d,exportName:m,exportType:c,importName:p,filePath:r,relFilePath:s,importPath:u,meta:{...Ws(e,n)},framework:"angular"},node:{name:p,fnNode:n,deps:void 0}}),a}async function Ks(e,t,r,n){let o=[],i=e.relative(e.getAppRootDir(),r),a=M(e,r);for(let s of n.statements)if(e.ts.isExportDeclaration(s)&&s.exportClause&&e.ts.isNamedExports(s.exportClause))for(let u of s.exportClause.elements){let p=u.name?.text;if(!p)continue;let f=p,m="named",c=[];if(t){let g=t.getSymbolAtLocation(u.name);if(g){let x=t.getDeclaredTypeOfSymbol(g);t.getPropertiesOfType(x).forEach(C=>{let E=C.getDeclarations();E&&E.forEach(F=>{if(e.ts.isPropertyDeclaration(F)){let A=t.getTypeAtLocation(F),S={name:C.getName(),type:Js(e,t,A)};c.push(S)}})})}}let d=e.ts.isExportSpecifier(u)&&u.parent?u.parent.parent:void 0,D;if(d){let g=d.moduleSpecifier;if(g&&e.ts.isStringLiteral(g)){let x=t?.getSymbolAtLocation(g);if(x&&x.declarations&&x.declarations.length>0){let l=x.declarations[0];(!e.ts.isSourceFile(l)||e.ts.isSourceFile(l)&&l.fileName.includes("node_modules"))&&(D=g.text)}}}o.push({cmpInfo:{id:await V(e,r,p,D),displayFilePath:O(e,r),name:K(p),inputs:c,exportName:f,exportType:m,importName:p,filePath:r,relFilePath:i,importPath:D||a,externalImportPath:D,framework:"angular"},node:{name:p,fnNode:u,deps:void 0}})}else if(e.ts.isExportDeclaration(s)&&!s.exportClause&&s.moduleSpecifier&&e.ts.isStringLiteral(s.moduleSpecifier)){let u=s.moduleSpecifier.text;if(t)try{let p=t.getSymbolAtLocation(s.moduleSpecifier);if(p&&p.exports){let f=t.getExportsOfModule(p);for(let m of f)if(m.flags&e.ts.SymbolFlags.Class){let c=m.getName();if(c.startsWith("_"))continue;o.push({cmpInfo:{id:await V(e,r,c,u),displayFilePath:O(e,r),name:K(c),inputs:[],exportName:c,exportType:"named",importName:c,filePath:r,relFilePath:i,importPath:u,externalImportPath:u,framework:"angular"},node:{name:c,fnNode:s,deps:void 0}})}}}catch(p){console.warn(`Error processing star export from ${u}:`,p)}}return o}function Ms(e,t){return yo(e,t,"Input")}function Us(e,t,r){return e.ts.isPropertyDeclaration(t)&&t.initializer!==void 0&&e.ts.isCallExpression(t.initializer)&&e.ts.isIdentifier(t.initializer.expression)&&t.initializer.expression.text===r}function yo(e,t,r){if(e.ts.isCallExpression(t.expression)){let n=t.expression;if(e.ts.isIdentifier(n.expression))return n.expression?.text===r}return!1}function zs(e,t){return!!e.ts.getDecorators(t)?.some(o=>e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="Component")}function So(e,t){if(!t)return"any";let r="any";switch(t.kind){case e.ts.SyntaxKind.StringKeyword:r="string";break;case e.ts.SyntaxKind.NumberKeyword:r="number";break;case e.ts.SyntaxKind.BooleanKeyword:r="boolean";break;case e.ts.SyntaxKind.TypeReference:e.ts.isTypeReferenceNode(t)&&e.ts.isIdentifier(t.typeName)&&(r=t.typeName.text);break}return r.includes("|")?"string":r}function qs(e,t){let r={};return e.ts.forEachChild(t,n=>{e.ts.isTypeAliasDeclaration(n)&&e.ts.isUnionTypeNode(n.type)&&n.type.types.every(o=>e.ts.isLiteralTypeNode(o)&&e.ts.isStringLiteral(o.literal))&&(r[n.name.text]=n.type.types.map(o=>o.literal.text))}),r}function Js(e,t,r){let n=t.typeToString(r);if(n==="any"){let o=r.getSymbol();if(o){let i=o.getDeclarations();if(i&&i.length>0){let a=i[0];if(e.ts.isVariableDeclaration(a)){let s=a.type;s&&(n=t.typeToString(t.getTypeAtLocation(s)))}}}}return n}function Ws(e,t){let{getDecorators:r,isCallExpression:n,isIdentifier:o,isObjectLiteralExpression:i,isPropertyAssignment:a,isStringLiteral:s,SyntaxKind:u}=e.ts,p,f;return r(t)?.forEach(c=>{if(yo(e,c,"Component")){let{expression:d}=c;if(n(d)){let[D]=d.arguments;i(D)&&D.properties.forEach(g=>{a(g)&&o(g.name)&&(g.name.escapedText==="selector"&&s(g.initializer)&&(p=g.initializer.text),g.name.escapedText==="standalone"&&(f=g.initializer.kind===u.TrueKeyword))})}}}),{selector:p,standalone:f}}async function qt(e,t,r){let n=e.typescriptEnabled?".ts":".js",o=`app.module${n}`,i=e.join(e.appDir,o),a=await e.readFile(i);if(!a){e.Sentry?.captureException(new Error(`Unable to read app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}let s=await Qs(e,i,t,r,a);if(!s){e.Sentry?.captureException(new Error(`Unable to update app.module.${n} at ${i}`),{extra:{appModuleCode:a,appModulePath:i}});return}return await e.writeFile(i,s),i}async function Qs(e,t,r,n,o){let i=o,a=b(e,o),s=N(e,t,n);a=I(e,a,{namedImports:[r],importPath:s}),a=I(e,a,{namedImports:["Content"],importPath:"@builder.io/sdk-angular"});let u=[];for(let p of a.statements)if(e.ts.isClassDeclaration(p)&&p.name?.text==="AppModule"){let f=Ys(e,r,p);u.push(f)}else u.push(p);return a=e.ts.factory.updateSourceFile(a,u),i=j(e,a),i}function Ys(e,t,r){let n=e.ts.getDecorators(r);if(n){for(let o of n)if(e.ts.isCallExpression(o.expression)&&e.ts.isIdentifier(o.expression.expression)&&o.expression.expression.text==="NgModule"){let i=o.expression.arguments;if(i.length===1&&e.ts.isObjectLiteralExpression(i[0])){let a=wo(e,i[0],"declarations",t);if(a){let s=wo(e,a,"imports","Content");if(s&&(a=s),a){let u=e.ts.factory.updateDecorator(o,e.ts.factory.updateCallExpression(o.expression,o.expression.expression,o.expression.typeArguments,[a])),f=[...n.map(m=>m===o?u:m),...e.ts.getModifiers(r)||[]];return e.ts.factory.updateClassDeclaration(r,f,r.name,r.typeParameters,r.heritageClauses,r.members)}}}}}return r}function wo(e,t,r,n){let o=[...t.properties],i=o.findIndex(s=>L(e,s)===r);if(i>-1){let s=o[i];if(e.ts.isPropertyAssignment(s)&&s.initializer&&e.ts.isArrayLiteralExpression(s.initializer)){let u=vo(e,s.initializer,n);return u?(o[i]=e.ts.factory.updatePropertyAssignment(s,s.name,u),e.ts.factory.updateObjectLiteralExpression(t,o)):null}return null}let a=vo(e,e.ts.factory.createArrayLiteralExpression([],!0),n);return a?e.ts.factory.updateObjectLiteralExpression(t,[...o,e.ts.factory.createPropertyAssignment(r,a)]):null}function vo(e,t,r){return t.elements.some(o=>e.ts.isIdentifier(o)?o.text===r:!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier(r)])}async function Pn(e,t,r,n){let i=`app.routes${e.typescriptEnabled?".ts":".js"}`,a=e.join(e.appDir,i);try{if(e.magicast){let s=await e.magicast.loadFile(a);Object.keys(s.exports).length===0&&(s.exports.routes=[]);let p=Object.keys(s.exports)[0],f=s.exports[p];if(f.find(c=>c.path===t))return;let m=e.magicast.builders.raw("{}");if(m.path=t,m.component=e.magicast.builders.raw(r),f.push(m),s.imports.$items.find(c=>c.imported===r))return;s.imports.$append({imported:r,from:n}),await e.magicast.writeFile(s,a)}}catch(s){let u=null;try{u=e.readFileSync(a)}catch(p){e.Sentry?.captureException(p,{level:"warning"})}e.Sentry?.captureException(s,{extra:{content:u,appRoutesPath:a,componentName:r,componentPath:n}})}}var Gs=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,Hs=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,Xs=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,yn={Space_Separator:Gs,ID_Start:Hs,ID_Continue:Xs},q={isSpaceSeparator(e){return typeof e=="string"&&yn.Space_Separator.test(e)},isIdStartChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||yn.ID_Start.test(e))},isIdContinueChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="\u200C"||e==="\u200D"||yn.ID_Continue.test(e))},isDigit(e){return typeof e=="string"&&/[0-9]/.test(e)},isHexDigit(e){return typeof e=="string"&&/[0-9A-Fa-f]/.test(e)}},vn,oe,Ve,Wt,ze,Se,Q,In,It,Zs=function(t,r){vn=String(t),oe="start",Ve=[],Wt=0,ze=1,Se=0,Q=void 0,In=void 0,It=void 0;do Q=eu(),ru[oe]();while(Q.type!=="eof");return typeof r=="function"?Tn({"":It},"",r):It};function Tn(e,t,r){let n=e[t];if(n!=null&&typeof n=="object")if(Array.isArray(n))for(let o=0;o<n.length;o++){let i=String(o),a=Tn(n,i,r);a===void 0?delete n[i]:Object.defineProperty(n,i,{value:a,writable:!0,enumerable:!0,configurable:!0})}else for(let o in n){let i=Tn(n,o,r);i===void 0?delete n[o]:Object.defineProperty(n,o,{value:i,writable:!0,enumerable:!0,configurable:!0})}return r.call(e,t,n)}var T,v,bt,je,R;function eu(){for(T="default",v="",bt=!1,je=1;;){R=$e();let e=bo[T]();if(e)return e}}function $e(){if(vn[Wt])return String.fromCodePoint(vn.codePointAt(Wt))}function h(){let e=$e();return e===`
|
|
766
|
+
`?(ze++,Se=0):e?Se+=e.length:Se++,e&&(Wt+=e.length),e}var bo={default(){switch(R){case" ":case"\v":case"\f":case" ":case"\xA0":case"\uFEFF":case`
|
|
767
|
+
`:case"\r":case"\u2028":case"\u2029":h();return;case"/":h(),T="comment";return;case void 0:return h(),U("eof")}if(q.isSpaceSeparator(R)){h();return}return bo[oe]()},comment(){switch(R){case"*":h(),T="multiLineComment";return;case"/":h(),T="singleLineComment";return}throw z(h())},multiLineComment(){switch(R){case"*":h(),T="multiLineCommentAsterisk";return;case void 0:throw z(h())}h()},multiLineCommentAsterisk(){switch(R){case"*":h();return;case"/":h(),T="default";return;case void 0:throw z(h())}h(),T="multiLineComment"},singleLineComment(){switch(R){case`
|
|
768
|
+
`:case"\r":case"\u2028":case"\u2029":h(),T="default";return;case void 0:return h(),U("eof")}h()},value(){switch(R){case"{":case"[":return U("punctuator",h());case"n":return h(),Xe("ull"),U("null",null);case"t":return h(),Xe("rue"),U("boolean",!0);case"f":return h(),Xe("alse"),U("boolean",!1);case"-":case"+":h()==="-"&&(je=-1),T="sign";return;case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Xe("nfinity"),U("numeric",1/0);case"N":return h(),Xe("aN"),U("numeric",NaN);case'"':case"'":bt=h()==='"',v="",T="string";return}throw z(h())},identifierNameStartEscape(){if(R!=="u")throw z(h());h();let e=bn();switch(e){case"$":case"_":break;default:if(!q.isIdStartChar(e))throw To();break}v+=e,T="identifierName"},identifierName(){switch(R){case"$":case"_":case"\u200C":case"\u200D":v+=h();return;case"\\":h(),T="identifierNameEscape";return}if(q.isIdContinueChar(R)){v+=h();return}return U("identifier",v)},identifierNameEscape(){if(R!=="u")throw z(h());h();let e=bn();switch(e){case"$":case"_":case"\u200C":case"\u200D":break;default:if(!q.isIdContinueChar(e))throw To();break}v+=e,T="identifierName"},sign(){switch(R){case".":v=h(),T="decimalPointLeading";return;case"0":v=h(),T="zero";return;case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":v=h(),T="decimalInteger";return;case"I":return h(),Xe("nfinity"),U("numeric",je*(1/0));case"N":return h(),Xe("aN"),U("numeric",NaN)}throw z(h())},zero(){switch(R){case".":v+=h(),T="decimalPoint";return;case"e":case"E":v+=h(),T="decimalExponent";return;case"x":case"X":v+=h(),T="hexadecimal";return}return U("numeric",je*0)},decimalInteger(){switch(R){case".":v+=h(),T="decimalPoint";return;case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},decimalPointLeading(){if(q.isDigit(R)){v+=h(),T="decimalFraction";return}throw z(h())},decimalPoint(){switch(R){case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h(),T="decimalFraction";return}return U("numeric",je*Number(v))},decimalFraction(){switch(R){case"e":case"E":v+=h(),T="decimalExponent";return}if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},decimalExponent(){switch(R){case"+":case"-":v+=h(),T="decimalExponentSign";return}if(q.isDigit(R)){v+=h(),T="decimalExponentInteger";return}throw z(h())},decimalExponentSign(){if(q.isDigit(R)){v+=h(),T="decimalExponentInteger";return}throw z(h())},decimalExponentInteger(){if(q.isDigit(R)){v+=h();return}return U("numeric",je*Number(v))},hexadecimal(){if(q.isHexDigit(R)){v+=h(),T="hexadecimalInteger";return}throw z(h())},hexadecimalInteger(){if(q.isHexDigit(R)){v+=h();return}return U("numeric",je*Number(v))},string(){switch(R){case"\\":h(),v+=tu();return;case'"':if(bt)return h(),U("string",v);v+=h();return;case"'":if(!bt)return h(),U("string",v);v+=h();return;case`
|
|
769
|
+
`:case"\r":throw z(h());case"\u2028":case"\u2029":ou(R);break;case void 0:throw z(h())}v+=h()},start(){switch(R){case"{":case"[":return U("punctuator",h())}T="value"},beforePropertyName(){switch(R){case"$":case"_":v=h(),T="identifierName";return;case"\\":h(),T="identifierNameStartEscape";return;case"}":return U("punctuator",h());case'"':case"'":bt=h()==='"',T="string";return}if(q.isIdStartChar(R)){v+=h(),T="identifierName";return}throw z(h())},afterPropertyName(){if(R===":")return U("punctuator",h());throw z(h())},beforePropertyValue(){T="value"},afterPropertyValue(){switch(R){case",":case"}":return U("punctuator",h())}throw z(h())},beforeArrayValue(){if(R==="]")return U("punctuator",h());T="value"},afterArrayValue(){switch(R){case",":case"]":return U("punctuator",h())}throw z(h())},end(){throw z(h())}};function U(e,t){return{type:e,value:t,line:ze,column:Se}}function Xe(e){for(let t of e){if($e()!==t)throw z(h());h()}}function tu(){switch($e()){case"b":return h(),"\b";case"f":return h(),"\f";case"n":return h(),`
|
|
770
|
+
`;case"r":return h(),"\r";case"t":return h()," ";case"v":return h(),"\v";case"0":if(h(),q.isDigit($e()))throw z(h());return"\0";case"x":return h(),nu();case"u":return h(),bn();case`
|
|
771
771
|
`:case"\u2028":case"\u2029":return h(),"";case"\r":return h(),$e()===`
|
|
772
|
-
`&&h(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":throw z(h());case void 0:throw z(h())}return h()}function
|
|
772
|
+
`&&h(),"";case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":throw z(h());case void 0:throw z(h())}return h()}function nu(){let e="",t=$e();if(!q.isHexDigit(t)||(e+=h(),t=$e(),!q.isHexDigit(t)))throw z(h());return e+=h(),String.fromCodePoint(parseInt(e,16))}function bn(){let e="",t=4;for(;t-- >0;){let r=$e();if(!q.isHexDigit(r))throw z(h());e+=h()}return String.fromCodePoint(parseInt(e,16))}var ru={start(){if(Q.type==="eof")throw Ze();wn()},beforePropertyName(){switch(Q.type){case"identifier":case"string":In=Q.value,oe="afterPropertyName";return;case"punctuator":Jt();return;case"eof":throw Ze()}},afterPropertyName(){if(Q.type==="eof")throw Ze();oe="beforePropertyValue"},beforePropertyValue(){if(Q.type==="eof")throw Ze();wn()},beforeArrayValue(){if(Q.type==="eof")throw Ze();if(Q.type==="punctuator"&&Q.value==="]"){Jt();return}wn()},afterPropertyValue(){if(Q.type==="eof")throw Ze();switch(Q.value){case",":oe="beforePropertyName";return;case"}":Jt()}},afterArrayValue(){if(Q.type==="eof")throw Ze();switch(Q.value){case",":oe="beforeArrayValue";return;case"]":Jt()}},end(){}};function wn(){let e;switch(Q.type){case"punctuator":switch(Q.value){case"{":e={};break;case"[":e=[];break}break;case"null":case"boolean":case"numeric":case"string":e=Q.value;break}if(It===void 0)It=e;else{let t=Ve[Ve.length-1];Array.isArray(t)?t.push(e):Object.defineProperty(t,In,{value:e,writable:!0,enumerable:!0,configurable:!0})}if(e!==null&&typeof e=="object")Ve.push(e),Array.isArray(e)?oe="beforeArrayValue":oe="beforePropertyName";else{let t=Ve[Ve.length-1];t==null?oe="end":Array.isArray(t)?oe="afterArrayValue":oe="afterPropertyValue"}}function Jt(){Ve.pop();let e=Ve[Ve.length-1];e==null?oe="end":Array.isArray(e)?oe="afterArrayValue":oe="afterPropertyValue"}function z(e){return Qt(e===void 0?`JSON5: invalid end of input at ${ze}:${Se}`:`JSON5: invalid character '${Io(e)}' at ${ze}:${Se}`)}function Ze(){return Qt(`JSON5: invalid end of input at ${ze}:${Se}`)}function To(){return Se-=5,Qt(`JSON5: invalid identifier character at ${ze}:${Se}`)}function ou(e){console.warn(`JSON5: '${Io(e)}' in strings is not valid ECMAScript; consider escaping`)}function Io(e){let t={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(t[e])return t[e];if(e<" "){let r=e.charCodeAt(0).toString(16);return"\\x"+("00"+r).substring(r.length)}return e}function Qt(e){let t=new SyntaxError(e);return t.lineNumber=ze,t.columnNumber=Se,t}var iu=function(t,r,n){let o=[],i="",a,s,u="",p;if(r!=null&&typeof r=="object"&&!Array.isArray(r)&&(n=r.space,p=r.quote,r=r.replacer),typeof r=="function")s=r;else if(Array.isArray(r)){a=[];for(let g of r){let x;typeof g=="string"?x=g:(typeof g=="number"||g instanceof String||g instanceof Number)&&(x=String(g)),x!==void 0&&a.indexOf(x)<0&&a.push(x)}}return n instanceof Number?n=Number(n):n instanceof String&&(n=String(n)),typeof n=="number"?n>0&&(n=Math.min(10,Math.floor(n)),u=" ".substr(0,n)):typeof n=="string"&&(u=n.substr(0,10)),f("",{"":t});function f(g,x){let l=x[g];switch(l!=null&&(typeof l.toJSON5=="function"?l=l.toJSON5(g):typeof l.toJSON=="function"&&(l=l.toJSON(g))),s&&(l=s.call(x,g,l)),l instanceof Number?l=Number(l):l instanceof String?l=String(l):l instanceof Boolean&&(l=l.valueOf()),l){case null:return"null";case!0:return"true";case!1:return"false"}if(typeof l=="string")return m(l,!1);if(typeof l=="number")return String(l);if(typeof l=="object")return Array.isArray(l)?D(l):c(l)}function m(g){let x={"'":.1,'"':.2},l={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"},C="";for(let F=0;F<g.length;F++){let A=g[F];switch(A){case"'":case'"':x[A]++,C+=A;continue;case"\0":if(q.isDigit(g[F+1])){C+="\\x00";continue}}if(l[A]){C+=l[A];continue}if(A<" "){let S=A.charCodeAt(0).toString(16);C+="\\x"+("00"+S).substring(S.length);continue}C+=A}let E=p||Object.keys(x).reduce((F,A)=>x[F]<x[A]?F:A);return C=C.replace(new RegExp(E,"g"),l[E]),E+C+E}function c(g){if(o.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");o.push(g);let x=i;i=i+u;let l=a||Object.keys(g),C=[];for(let F of l){let A=f(F,g);if(A!==void 0){let S=d(F)+":";u!==""&&(S+=" "),S+=A,C.push(S)}}let E;if(C.length===0)E="{}";else{let F;if(u==="")F=C.join(","),E="{"+F+"}";else{let A=`,
|
|
773
773
|
`+i;F=C.join(A),E=`{
|
|
774
774
|
`+i+F+`,
|
|
775
775
|
`+x+"}"}}return o.pop(),i=x,E}function d(g){if(g.length===0)return m(g,!0);let x=String.fromCodePoint(g.codePointAt(0));if(!q.isIdStartChar(x))return m(g,!0);for(let l=x.length;l<g.length;l++)if(!q.isIdContinueChar(String.fromCodePoint(g.codePointAt(l))))return m(g,!0);return g}function D(g){if(o.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");o.push(g);let x=i;i=i+u;let l=[];for(let E=0;E<g.length;E++){let F=f(String(E),g);l.push(F!==void 0?F:"null")}let C;if(l.length===0)C="[]";else if(u==="")C="["+l.join(",")+"]";else{let E=`,
|
|
776
776
|
`+i,F=l.join(E);C=`[
|
|
777
777
|
`+i+F+`,
|
|
778
|
-
`+x+"]"}return o.pop(),i=x,C}},
|
|
778
|
+
`+x+"]"}return o.pop(),i=x,C}},au={parse:Zs,stringify:iu},su=au,Ro=su;async function No(e){let t=e.ts.findConfigFile(e.getAppRootDir(),e.existsSync);if(t){let r=await e.readFile(t);if(!r)return;let n=Ro.parse(r);if(!n||typeof n!="object"||Array.isArray(n))return;let o=n.compilerOptions;if(!o||typeof o!="object"||Array.isArray(o))return;let i=o.paths;(!i||typeof i!="object"||Array.isArray(i))&&(o.paths={},i=o.paths),Object.assign(o.paths,{"~/*":["./src/*"]}),await e.writeFile(t,JSON.stringify(n,null,2))}}async function Bo(e){let t=[],r=await cu(e,t);t.push(...await Yt(e)),await uu(e,r);let n="BuilderPage";if(!await e.exists(e.builderPageComponentPath)){let o=await e.formatCode(e.builderPageComponentPath,ko(e,n,e.builderPageComponentPath,"builder-page","page",!0));await e.writeFile(e.builderPageComponentPath,o),t.push({filePath:e.builderPageComponentPath,modifiedType:"create"})}if(e.hasAppModule){await qt(e,"Counter",r);let o=await qt(e,n,e.builderPageComponentPath);o&&t.push({filePath:o,modifiedType:"update"})}return await Pn(e,"**",n,"./components/builder-page.component"),t}async function Oo(e){let t=[];t.push(...await Yt(e));let r="FigmaImportsPage",n="figma-imports.component",o=e.join(e.componentsDir,`${n}.${e.typescriptEnabled?"ts":"js"}`);if(!await e.exists(o)){let i=await e.formatCode(o,ko(e,r,o,"figma-imports","figma-imports",!1));await e.writeFile(o,i),t.push({filePath:o,modifiedType:"create"})}if(e.hasAppModule){let i=await qt(e,r,o);i&&t.push({filePath:i,modifiedType:"update"})}return await Pn(e,"figma-imports",r,`./components/${n}`),await No(e),t}async function Yt(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,pu(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}async function uu(e,t){let n=(await ke(e,null,!1,!1,null,null,!1,!1)).components.find(o=>o.filePath===t);n&&await ke(e,n.id,!0,!1,null,null,!0,!1)}function ko(e,t,r,n,o,i){let a=!e.hasAppModule,s=N(e,r,e.registryPath),u=e.join(e.getAppRootDir(),"src","environments","environment.ts"),p=N(e,r,u),f=i?` <ng-container *ngIf="content || isPreviewing; else notFound">
|
|
779
779
|
<builder-content
|
|
780
780
|
[model]="model"
|
|
781
781
|
[content]="content"
|
|
@@ -841,12 +841,12 @@ export class ${t} {
|
|
|
841
841
|
}
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
-
`.trimStart()}function
|
|
844
|
+
`.trimStart()}function pu(e){return e.typescriptEnabled?`import type { RegisteredComponent } from "@builder.io/sdk-angular";
|
|
845
845
|
|
|
846
846
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
847
847
|
];`:`export const CUSTOM_COMPONENTS = [
|
|
848
848
|
];
|
|
849
|
-
`}async function
|
|
849
|
+
`}async function cu(e,t){let n=e.typescriptEnabled?"ts":"js",o=e.join(e.componentsDir,`counter.component.${n}`),i=await e.exists(o);e.debug(`angularEnsureCounterComponent, hasCounterCmp: ${i}`);let a=lu(e);if(!i){let s=await e.formatCode(o,a);await e.writeFile(o,s),t.push({filePath:o,modifiedType:"create"})}return o}function lu(e){return`
|
|
850
850
|
import { Component, Input } from '@angular/core';
|
|
851
851
|
|
|
852
852
|
@Component({
|
|
@@ -914,7 +914,7 @@ export class Counter {
|
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
916
|
|
|
917
|
-
`.trimStart()}async function ko(e){await Yt(e);let t=await e.readFile(e.registryPath);return t?cu(e,t):{components:[],sourceFile:b(e,"")}}async function cu(e,t){let r=b(e,t);return lu(e,r)}async function lu(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 In(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function In(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"angular"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(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 we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(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 Ao(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function ke(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m]=await Promise.all([So(e,u),ko(e),Tt(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await Fo(e,p,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await G(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await An(e,A,F);pe(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let k=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:Y}=await fu(e,x,A);if(k.addCmpToRegistry)P.push(mu(e,k.addCmpToRegistry)),g=!0;else if(k.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(k.updateRegisteredCmp){let _=W(e,P[w],k.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[Lo(e,k.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=k.components,d=k.components.filter(te=>te.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function Lo(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function mu(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([Lo(e,t)],!0),t)}async function fu(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 In(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function _o(e){let t=await du(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>No(t),ensureFigmaImportPage:()=>Bo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>ke(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await ke(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>ke(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>ke(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>ke(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>ke(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Tt(t),setPublicApiKey:n=>ho(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function du(e){let t=await gu(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i=e.join(n,"app"),a=await ie(e,i),s={},u={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1,addExternalPackage:m=>{s[e.join(r,m,"index.ts")]=`export * from "${m}";`},readFileSync:m=>s[m]??e.readFileSync(m),existsSync:m=>!!s[m]||e.existsSync(m),readdirSync:m=>{let c=e.readdirSync(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c},readdir:async m=>{let c=await e.readdir(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c}};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);u.srcDir=n,u.appDir=i,u.componentsDir=e.join(u.appDir,"components"),u.builderPageComponentPath=e.join(u.componentsDir,`builder-page.component.${o?"ts":"js"}`);let p=`app.module.${o?"ts":"js"}`,f=e.join(u.appDir,p);return await e.exists(f)&&(u.hasAppModule=!0),u}async function gu(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;if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}async function Rt(e){let t=e.configType==="vite"?Du:xu;return await Fe(e,[".env"],t)}async function jo(e,t){let r=await Rt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var Du="VITE_PUBLIC_BUILDER_KEY",xu="PUBLIC_BUILDER_KEY";async function $o(e,t,r){try{let n=await e.readFile(t);if(!n)return null;let o=e.relative(e.getAppRootDir(),t),i=t.split("/").pop()?.replace(".vue","")||"UnknownComponent",a=Su(i),s=hu(n,r),u=Cu(n);return{id:Au(t),name:a,filePath:o,relFilePath:o,inputs:s,framework:"vue",exportType:"default",exportName:"default",importName:a,importPath:o,vueApiType:u}}catch(n){return console.warn(`Failed to parse Vue component ${t}:`,n),null}}function Cu(e){return/<script[^>]*\s+setup[^>]*>/.test(e)?"composition-setup":/import\s+\{[^}]*\b(ref|reactive|computed|watch|onMounted|defineComponent)\b[^}]*\}\s+from\s+['"]vue['"]/.test(e)||/setup\s*\([^)]*\)\s*\{/.test(e)?"composition":"options"}function hu(e,t){if(!t)return[];let r=[],n=[/defineProps<\s*\{([^}]+)\}\s*>\s*\(\s*\)/g,/defineProps\s*\(\s*\{([^}]+)\}\s*\)/g,/defineProps\s*\(\s*\[([^\]]+)\]\s*\)/g];for(let u of n){let p;for(;(p=u.exec(e))!==null;){let f=p[1];f.includes(":")?r.push(...Rn(f)):r.push(...Vo(f))}}let o=/props\s*:\s*(\{[^}]+\}|\[[^\]]+\])/g,i;for(;(i=o.exec(e))!==null;){let u=i[1];if(u.startsWith("{")){let p=u.slice(1,-1);r.push(...Rn(p))}else{let p=u.slice(1,-1);r.push(...Vo(p))}}let a=/setup\s*\(\s*props\s*(?::\s*\{([^}]+)\})?\s*[,)]?/g,s;for(;(s=a.exec(e))!==null;)s[1]&&r.push(...Rn(s[1]));return Eu(r)}function Rn(e){let t=[],r=/(\w+)\s*:\s*([^,;]+)/g,n;for(;(n=r.exec(e))!==null;){let[,a,s]=n;t.push({name:a.trim(),type:Nn(s.trim()),required:!s.includes("?")&&!s.includes("undefined")})}let o=/(\w+)\s*:\s*\{([^}]+)\}/g;for(;(n=o.exec(e))!==null;){let[,a,s]=n,u=s.match(/type\s*:\s*(\w+)/),p=s.match(/required\s*:\s*(true|false)/),f=s.match(/default\s*:\s*([^,}]+)/);t.push({name:a.trim(),type:u?Nn(u[1]):"any",required:p?p[1]==="true":!1,defaultValue:f?f[1].trim():void 0})}let i=/(\w+)\s*:\s*(\w+)(?=\s*[,}])/g;for(;(n=i.exec(e))!==null;){let[,a,s]=n;t.some(u=>u.name===a.trim())||t.push({name:a.trim(),type:Nn(s.trim()),required:!1})}return t}function Vo(e){let t=[],r=e.split(",").map(n=>n.trim().replace(/['"]/g,"")).filter(n=>n.length>0);for(let n of r)t.push({name:n,type:"any",required:!1});return t}function Nn(e){let t={String:"string",Number:"number",Boolean:"boolean",Array:"any[]",Object:"object",Function:"function",Date:"Date",Symbol:"symbol",string:"string",number:"number",boolean:"boolean",object:"object",function:"function"},r=e.replace(/\s*\|\s*undefined/g,"").replace(/\?$/,"");return t[r]||r||"any"}function Eu(e){let t=new Set;return e.filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}function Su(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^(.)/,(t,r)=>r?r.toUpperCase():"")}function Au(e){return e.replace(/[^a-zA-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}async function et(e,t){let r=await Fu(e,t.readAllInputTypes),n=await Rt(e);return{components:r,registryPath:e.registryPath,registryDisplayPath:e.relative(e.getAppRootDir(),e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(r),publicApiKey:n.envValue??void 0,devToolsVersion:e.version}}async function Fu(e,t){let r=[],n=await Pu(e,e.getAppRootDir());for(let o of n){let i=await $o(e,o,t);i&&r.push(i)}return r}async function Pu(e,t){let r=[],n=async i=>{try{let a=await e.readdir(i);for(let s of a){let u=e.join(i,s);(await e.stat(u)).isDirectory()?!s.startsWith(".")&&s!=="node_modules"&&s!=="dist"&&s!=="build"&&s!==".nuxt"&&s!==".output"&&await n(u):s.endsWith(".vue")&&r.push(u)}}catch{}};await n(t);let o=["components","pages","layouts"];for(let i of o){let a=e.join(t,i);try{(await e.stat(a)).isDirectory()&&await n(a)}catch{}}return r}async function Ko(e){let t={errors:[]};try{await Uo(e)}catch(r){t.errors.push(r instanceof Error?r.message:String(r))}return t}async function Mo(e){let t=[];t.push(...await Uo(e));let n=e.join(e.componentsDir,"FigmaImports.vue");if(!await e.exists(n)){let o=await e.formatCode(n,yu(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}async function Uo(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,vu(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}function yu(e,t,r="page"){let n=N(e,t,e.registryPath),o=e.typescriptEnabled;return e.isNuxt?`<template>
|
|
917
|
+
`.trimStart()}async function Lo(e){await Yt(e);let t=await e.readFile(e.registryPath);return t?mu(e,t):{components:[],sourceFile:b(e,"")}}async function mu(e,t){let r=b(e,t);return fu(e,r)}async function fu(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 Rn(e,t,o);a&&(a.nodeIndex=i,r.push(a))})),{sourceFile:t,components:ae(r)}}async function Rn(e,t,r){if(!e.ts.isObjectLiteralExpression(r))return null;let n={id:"",name:"",displayFilePath:"",exportName:"",importName:"",filePath:"",relFilePath:"",importPath:"",inputs:[],framework:"angular"};for(let o of r.properties){if(!e.ts.isPropertyAssignment(o)||!e.ts.isIdentifier(o.name))continue;if(L(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 we(e,e.registryPath,t,a);if(!u)continue;if(n.filePath=u.filePath,n.relFilePath=u.relFilePath,await e.exists(u.filePath)?n.importPath=M(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 Fo(e,u.filePath);if(p&&p.length>0)if(p.length===1)n.exportName=p[0].cmpInfo.exportName;else{let f=p.find(m=>m.cmpInfo.exportName===a);f&&(n.exportName=f.cmpInfo.exportName)}}continue}}return n=se(e,n,r),n.filePath&&n.exportName&&(n.id=await V(e,n.filePath,n.exportName,n.externalImportPath)),n}async function ke(e,t,r,n,o,i,a,s){let u=await Ue(e),[p,f,m]=await Promise.all([Ao(e,u),Lo(e),Tt(e)]),c=p.map(C=>C.cmpInfo),d=f.components,D={components:Ee(c,d),registryPath:e.registryPath,registryDisplayPath:O(e,e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(c),publicApiKey:m.envValue??void 0,devToolsVersion:e.version};if(s)return D.components=await Po(e,p,D.components),D;let g=!1,x=f.sourceFile,l=Array.isArray(t)?t:typeof t=="string"?[t]:[];if(l.length>0){let C=l.map(A=>{let S=p.find(B=>B.cmpInfo.id===A);if(!S)throw new Error(`Component ${A} not found`);return S}),E=Array.from(new Set(C.map(A=>A.cmpInfo.filePath))),F=await G(e,E);for(let A of C){let S=D.components.find(_=>_.id===A.cmpInfo.id),B=await Fn(e,A,F);pe(S,B);let $=c.findIndex(_=>_.id===A.cmpInfo.id);c[$].inputs=B;let k=Ie(A.cmpInfo.id,c,d,r,n,o,i),{elements:P,elmIndex:w,statementIndex:ee,statement:Ce,variableDeclaration:Y}=await gu(e,x,A);if(k.addCmpToRegistry)P.push(du(e,k.addCmpToRegistry)),g=!0;else if(k.removeCmpFromRegistry)P.splice(w,1),g=!0;else if(k.updateRegisteredCmp){let _=W(e,P[w],k.updateRegisteredCmp);P[w]=e.ts.factory.updateObjectLiteralExpression(_,[_o(e,k.updateRegisteredCmp),..._.properties.slice(1)]),g=!0}if(g&&a){let _=[...x.statements];_[ee]=e.ts.factory.updateVariableStatement(Ce,Ce.modifiers,e.ts.factory.updateVariableDeclarationList(Ce.declarationList,[e.ts.factory.updateVariableDeclaration(Y,Y.name,Y.exclamationToken,Y.type,e.ts.factory.createArrayLiteralExpression(Te(e,P)))])),x=e.ts.factory.updateSourceFile(x,_),S.exportType==="named"?x=I(e,x,{namedImports:[S.importName],importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}):x=I(e,x,{defaultImport:S.importName,importPath:S.externalImportPath?S.externalImportPath:N(e,e.registryPath,S.filePath)}),x=I(e,x,{namedImports:["RegisteredComponent"],importPath:"@builder.io/sdk-angular",isTypeOnly:!0}),x=Re(e,x,{variableName:"CUSTOM_COMPONENTS",arrayType:"RegisteredComponent"}),D.components=k.components,d=k.components.filter(te=>te.isRegistered)}}}if(g&&a){x=be(e,x),x=ve(e,x);let C=j(e,x);C=De(C),C=await e.formatCode(e.registryPath,C),await e.writeFile(e.registryPath,C)}return D}function _o(e,t){let r=e.ts.factory.createIdentifier(t.importName);return e.ts.factory.createPropertyAssignment("component",r)}function du(e,t){return W(e,e.ts.factory.createObjectLiteralExpression([_o(e,t)],!0),t)}async function gu(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 Rn(e,t,o[a]))?.id===r.cmpInfo.id){i=a;break}return{...n,elements:o,elmIndex:i}}async function jo(e){let t=await Du(e);return{builderPageOptions:async()=>({templateContentId:"f0b8016ac92e474699293211a268ebaa",pathname:"/builder-demo",title:"Builder + Angular Demo Page"}),ensureBuilderSetup:()=>Bo(t),ensureFigmaImportPage:()=>Oo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>ke(t,null,!1,!1,null,null,!1,!!n?.readAllInputTypes),addExternalPackage:async n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await ke(t,n.cmpId,!1,!1,null,null,!1,!1);return{...o,component:o.components.find(i=>i.id===n.cmpId)}},registerComponent:n=>ke(t,n.cmpId,!0,!1,null,null,!0,!1),setRegisteredComponentInfo:n=>ke(t,n.cmpId,!1,!1,n,null,!0,!1),setRegisteredComponentInput:n=>ke(t,n.cmpId,!1,!1,null,n,!0,!1),unregisterComponent:n=>ke(t,n.cmpId,!1,!0,null,null,!0,!1),getPublicApiKey:()=>Tt(t),setPublicApiKey:n=>Eo(t,n.publicApiKey),getDependencies:n=>[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-angular"},{name:"concurrently"}],getDevRunCommand:()=>"builder-dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Du(e){let t=await xu(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i=e.join(n,"app"),a=await ie(e,i),s={},u={...e,srcDir:"",appDir:"",componentsDir:"",registryPath:a,angularConfigPath:t,typescriptEnabled:o,builderPageComponentPath:"",hasAppModule:!1,addExternalPackage:m=>{s[e.join(r,m,"index.ts")]=`export * from "${m}";`},readFileSync:m=>s[m]??e.readFileSync(m),existsSync:m=>!!s[m]||e.existsSync(m),readdirSync:m=>{let c=e.readdirSync(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c},readdir:async m=>{let c=await e.readdir(m);return m===r?[...c,...Object.keys(s).map(d=>d.slice(r.length+1))]:c}};if(!await e.exists(n))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);u.srcDir=n,u.appDir=i,u.componentsDir=e.join(u.appDir,"components"),u.builderPageComponentPath=e.join(u.componentsDir,`builder-page.component.${o?"ts":"js"}`);let p=`app.module.${o?"ts":"js"}`,f=e.join(u.appDir,p);return await e.exists(f)&&(u.hasAppModule=!0),u}async function xu(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;if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Angular config file. Searched for angular.json & project.json in "${e.getAppRootDir()}".`)}async function Rt(e){let t=e.configType==="vite"?Cu:hu;return await Fe(e,[".env"],t)}async function Vo(e,t){let r=await Rt(e),n=await Pe(e,r.file,r.envKey,t);return{...r,modifiedType:n}}var Cu="VITE_PUBLIC_BUILDER_KEY",hu="PUBLIC_BUILDER_KEY";async function Ko(e,t,r){try{let n=await e.readFile(t);if(!n)return null;let o=e.relative(e.getAppRootDir(),t),i=t.split("/").pop()?.replace(".vue","")||"UnknownComponent",a=Fu(i),s=Su(n,r),u=Eu(n);return{id:Pu(t),name:a,filePath:o,relFilePath:o,inputs:s,framework:"vue",exportType:"default",exportName:"default",importName:a,importPath:o,vueApiType:u}}catch(n){return console.warn(`Failed to parse Vue component ${t}:`,n),null}}function Eu(e){return/<script[^>]*\s+setup[^>]*>/.test(e)?"composition-setup":/import\s+\{[^}]*\b(ref|reactive|computed|watch|onMounted|defineComponent)\b[^}]*\}\s+from\s+['"]vue['"]/.test(e)||/setup\s*\([^)]*\)\s*\{/.test(e)?"composition":"options"}function Su(e,t){if(!t)return[];let r=[],n=[/defineProps<\s*\{([^}]+)\}\s*>\s*\(\s*\)/g,/defineProps\s*\(\s*\{([^}]+)\}\s*\)/g,/defineProps\s*\(\s*\[([^\]]+)\]\s*\)/g];for(let u of n){let p;for(;(p=u.exec(e))!==null;){let f=p[1];f.includes(":")?r.push(...Nn(f)):r.push(...$o(f))}}let o=/props\s*:\s*(\{[^}]+\}|\[[^\]]+\])/g,i;for(;(i=o.exec(e))!==null;){let u=i[1];if(u.startsWith("{")){let p=u.slice(1,-1);r.push(...Nn(p))}else{let p=u.slice(1,-1);r.push(...$o(p))}}let a=/setup\s*\(\s*props\s*(?::\s*\{([^}]+)\})?\s*[,)]?/g,s;for(;(s=a.exec(e))!==null;)s[1]&&r.push(...Nn(s[1]));return Au(r)}function Nn(e){let t=[],r=/(\w+)\s*:\s*([^,;]+)/g,n;for(;(n=r.exec(e))!==null;){let[,a,s]=n;t.push({name:a.trim(),type:Bn(s.trim()),required:!s.includes("?")&&!s.includes("undefined")})}let o=/(\w+)\s*:\s*\{([^}]+)\}/g;for(;(n=o.exec(e))!==null;){let[,a,s]=n,u=s.match(/type\s*:\s*(\w+)/),p=s.match(/required\s*:\s*(true|false)/),f=s.match(/default\s*:\s*([^,}]+)/);t.push({name:a.trim(),type:u?Bn(u[1]):"any",required:p?p[1]==="true":!1,defaultValue:f?f[1].trim():void 0})}let i=/(\w+)\s*:\s*(\w+)(?=\s*[,}])/g;for(;(n=i.exec(e))!==null;){let[,a,s]=n;t.some(u=>u.name===a.trim())||t.push({name:a.trim(),type:Bn(s.trim()),required:!1})}return t}function $o(e){let t=[],r=e.split(",").map(n=>n.trim().replace(/['"]/g,"")).filter(n=>n.length>0);for(let n of r)t.push({name:n,type:"any",required:!1});return t}function Bn(e){let t={String:"string",Number:"number",Boolean:"boolean",Array:"any[]",Object:"object",Function:"function",Date:"Date",Symbol:"symbol",string:"string",number:"number",boolean:"boolean",object:"object",function:"function"},r=e.replace(/\s*\|\s*undefined/g,"").replace(/\?$/,"");return t[r]||r||"any"}function Au(e){let t=new Set;return e.filter(r=>t.has(r.name)?!1:(t.add(r.name),!0))}function Fu(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^(.)/,(t,r)=>r?r.toUpperCase():"")}function Pu(e){return e.replace(/[^a-zA-Z0-9]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").toLowerCase()}async function et(e,t){let r=await yu(e,t.readAllInputTypes),n=await Rt(e);return{components:r,registryPath:e.registryPath,registryDisplayPath:e.relative(e.getAppRootDir(),e.registryPath),frameworks:e.getFrameworks(),dependencies:ge(r),publicApiKey:n.envValue??void 0,devToolsVersion:e.version}}async function yu(e,t){let r=[],n=await wu(e,e.getAppRootDir());for(let o of n){let i=await Ko(e,o,t);i&&r.push(i)}return r}async function wu(e,t){let r=[],n=async i=>{try{let a=await e.readdir(i);for(let s of a){let u=e.join(i,s);(await e.stat(u)).isDirectory()?!s.startsWith(".")&&s!=="node_modules"&&s!=="dist"&&s!=="build"&&s!==".nuxt"&&s!==".output"&&await n(u):s.endsWith(".vue")&&r.push(u)}}catch{}};await n(t);let o=["components","pages","layouts"];for(let i of o){let a=e.join(t,i);try{(await e.stat(a)).isDirectory()&&await n(a)}catch{}}return r}async function Mo(e){let t={errors:[]};try{await zo(e)}catch(r){t.errors.push(r instanceof Error?r.message:String(r))}return t}async function Uo(e){let t=[];t.push(...await zo(e));let n=e.join(e.componentsDir,"FigmaImports.vue");if(!await e.exists(n)){let o=await e.formatCode(n,vu(e,n,"figma-imports"));await e.writeFile(n,o),t.push({filePath:n,modifiedType:"create"})}return t}async function zo(e){let t=[];return await e.exists(e.registryPath)||(await e.writeFile(e.registryPath,bu(e)),t.push({filePath:e.registryPath,modifiedType:"create"})),t}function vu(e,t,r="page"){let n=N(e,t,e.registryPath),o=e.typescriptEnabled;return e.isNuxt?`<template>
|
|
918
918
|
<div>
|
|
919
919
|
<div v-if="pending">Loading...</div>
|
|
920
920
|
<div v-else-if="error">Error loading content</div>
|
|
@@ -970,7 +970,7 @@ export default defineComponent({
|
|
|
970
970
|
},
|
|
971
971
|
setup() {
|
|
972
972
|
const model = '${r}'
|
|
973
|
-
const apiKey = ${
|
|
973
|
+
const apiKey = ${Tu(e)}
|
|
974
974
|
const content = ref${o?"<any>":""}(null)
|
|
975
975
|
const loading = ref(true)
|
|
976
976
|
const customComponents = CUSTOM_COMPONENTS
|
|
@@ -1003,7 +1003,7 @@ export default defineComponent({
|
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
1005
|
})
|
|
1006
|
-
</script>`}function
|
|
1006
|
+
</script>`}function Tu(e){return e.isNuxt?"useRuntimeConfig().public.builderApiKey":e.configType==="vite"?"import.meta.env.VITE_BUILDER_API_KEY":"process.env.VUE_APP_BUILDER_API_KEY"}function bu(e){return`import type { RegisteredComponent } from "@builder.io/sdk-vue";
|
|
1007
1007
|
|
|
1008
1008
|
export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
1009
1009
|
// Add your Vue components here
|
|
@@ -1020,7 +1020,7 @@ export const CUSTOM_COMPONENTS: RegisteredComponent[] = [
|
|
|
1020
1020
|
// ]
|
|
1021
1021
|
// }
|
|
1022
1022
|
];
|
|
1023
|
-
`}async function zo(e){let t=await Tu(e);return{builderPageOptions:async()=>({templateContentId:"vue-demo-template-id",pathname:"/builder-demo",title:"Builder + Vue Demo Page"}),ensureBuilderSetup:async()=>(await Ko(t)).errors.length>0?[]:[],ensureFigmaImportPage:()=>Mo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>et(t,{readAllInputTypes:!!n?.readAllInputTypes}),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await et(t,{readAllInputTypes:!1}),i=o.components.find(a=>a.id===n.cmpId);return{...o,component:i}},registerComponent:async n=>et(t,{readAllInputTypes:!1}),setRegisteredComponentInfo:async n=>et(t,{readAllInputTypes:!1}),setRegisteredComponentInput:async n=>et(t,{readAllInputTypes:!1}),unregisterComponent:async n=>et(t,{readAllInputTypes:!1}),getPublicApiKey:()=>Rt(t),setPublicApiKey:n=>jo(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-vue"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/vue"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Tu(e){let t=await bu(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",vueConfigPath:t,typescriptEnabled:o,configType:"",isNuxt:await Iu(e),addExternalPackage:p=>{i[e.join(r,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>i[p]??e.readFileSync(p),existsSync:p=>!!i[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f}};t.includes("webpack.config")&&(a.configType="webpack"),(t.includes("vite.config")||t.includes("nuxt.config"))&&(a.configType="vite");let s=await e.exists(n);a.srcDir=s?n:null;let u=[e.join(r,"components"),e.join(r,"src","components"),e.join(r,"app","components")];for(let p of u)if(await e.exists(p)){a.componentsDir=p;break}return a.componentsDir||(a.componentsDir=s?e.join(n,"components"):e.join(r,"components")),a.registryPath=await ie(e,a.componentsDir),a}async function bu(e){let t=["nuxt.config.ts","nuxt.config.js","vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts","vue.config.js","vue.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Vue config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function Iu(e){let t=["nuxt.config.ts","nuxt.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return!0}try{let r=e.join(e.getAppRootDir(),"package.json");if(await e.exists(r)){let n=JSON.parse(await e.readFile(r)||"{}"),o={...n.dependencies,...n.devDependencies};return!!(o.nuxt||o["@nuxt/kit"]||o.nuxt3)}}catch{}return!1}var Zt=Hn(ri(),1);async function oi(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:he(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:ue(i.inputs)};return ue(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,Zt.compress)(n);return btoa(JSON.stringify(o))}async function ii(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,Zt.decompress)(o),a=ue(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=he(e.normalize(s.filePath)),p=n.components.find(m=>he(m.filePath).endsWith(u)&&m.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 m of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:m.name,type:m.type,required:m.required,defaultValue:m.defaultValue,friendlyName:m.friendlyName,helperText:m.helperText});e.debug(`set input (${p.id}) info`);let f=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=ue(f)}return a}var ce={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik",vue:"vue"},gg={[ce.react]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ce.remix]:[{version:y.gen1,recommended:!1},{version:y.gen2,recommended:!0}],[ce.angular]:[{version:y.gen2,recommended:!0}],[ce.next]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ce.qwik]:[{version:y.gen2,recommended:!0}],[ce.vue]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}]};async function ai(e,t){let r=[],n=new Set;async function o(i){let a=e.join(i,"package.json");try{if(!await e.exists(a))return null;let u=await e.readFile(a);if(u===null)throw new Error(`Failed to read package.json at ${a}`);let p=JSON.parse(u);if(typeof p.name!="string"||p.name.trim()===""||n.has(p.name))return null;n.add(p.name);let f={name:p.name,subPackages:[]},m=await e.readdir(i);for(let c of m)c!=="node_modules"&&(await e.stat(e.join(i,c))).isDirectory()&&f.subPackages.push(c);return r.push(f),f}catch(s){return e.Sentry?.captureException(s,{level:"warning"}),null}}try{let i=e.join(t,"package.json");if(await e.exists(i)){let s=await e.readFile(i);if(s!==null){let u=JSON.parse(s),p={...u.dependencies,...u.devDependencies};for(let f of Object.keys(p)){let m=e.join(t,"node_modules",f);await o(m)}if(Array.isArray(u.workspaces))for(let f of u.workspaces){let m=await e.readdir(e.join(t,f));for(let c of m){let d=e.join(t,f,c);await o(d)}}}}}catch(i){e.Sentry?.captureException(i,{level:"warning"})}return r}var ep={"@builder.io/qwik-city":eo,next:Ur,"@remix-run/react":uo,react:Co,"@angular/core":_o,vue:zo},tp={"@builder.io/qwik-city":ce.qwik,next:ce.next,"@remix-run/react":ce.remix,react:ce.react,"@angular/core":ce.angular,vue:ce.vue};async function np(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 Ye(e)),e.frameworks.length===0)throw new Error("Supported Devtools framework for not found");for(let t of e.frameworks){let r=ep[t.name];if(r)try{let n=await r(e);return{...n,exportRegistry:()=>oi(e,n),importRegistry:i=>ii(e,n,i),framework:tp[t.name],findAllDependencies:async()=>await ai(e,e.getRepoRootDir())}}catch(n){e.Sentry?.captureException(n,{level:"warning"})}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function si(e){function t(m){if(typeof m!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(m))}function r(m,c){let d="",D=0,g=-1,x=0,l;for(let C=0;C<=m.length;++C){if(C<m.length)l=m.charCodeAt(C);else{if(l===47)break;l=47}if(l===47){if(!(g===C-1||x===1))if(g!==C-1&&x===2){if(d.length<2||D!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let E=d.lastIndexOf("/");if(E!==d.length-1){E===-1?(d="",D=0):(d=d.slice(0,E),D=d.length-1-d.lastIndexOf("/")),g=C,x=0;continue}}else if(d.length===2||d.length===1){d="",D=0,g=C,x=0;continue}}c&&(d.length>0?d+="/..":d="..",D=2)}else d.length>0?d+="/"+m.slice(g+1,C):d=m.slice(g+1,C),D=C-g-1;g=C,x=0}else l===46&&x!==-1?++x:x=-1}return d}let n=function(...c){let d="",D=!1;for(let g=c.length-1;g>=-1&&!D;g--){let x;g>=0?x=c[g]:e.cwd?x=e.cwd():x="/",t(x),x.length!==0&&(d=x+"/"+d,D=x.charCodeAt(0)===47)}return d=r(d,!D),D?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,D=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&D&&(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 D=1;for(;D<c.length&&c.charCodeAt(D)===47;++D);let g=c.length,x=g-D,l=1;for(;l<d.length&&d.charCodeAt(l)===47;++l);let E=d.length-l,F=x<E?x:E,A=-1,S=0;for(;S<=F;++S){if(S===F){if(E>F){if(d.charCodeAt(l+S)===47)return d.slice(l+S+1);if(S===0)return d.slice(l+S)}else x>F&&(c.charCodeAt(D+S)===47?A=S:S===0&&(A=0));break}let $=c.charCodeAt(D+S),k=d.charCodeAt(l+S);if($!==k)break;$===47&&(A=S)}let B="";for(S=D+A+1;S<=g;++S)(S===g||c.charCodeAt(S)===47)&&(B.length===0?B+="..":B+="/..");return B.length>0?B+d.slice(l+A):(l+=A,d.charCodeAt(l)===47&&++l,d.slice(l))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let D=0;D<c.length;++D){let g=c[D];t(g),g.length>0&&(d===void 0?d=g:d+="/"+g)}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 D=0,g=-1,x=!0,l;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let C=d.length-1,E=-1;for(l=c.length-1;l>=0;--l){let F=c.charCodeAt(l);if(F===47){if(!x){D=l+1;break}}else E===-1&&(x=!1,E=l+1),C>=0&&(F===d.charCodeAt(C)?--C===-1&&(g=l):(C=-1,g=E))}return D===g?g=E:g===-1&&(g=c.length),c.slice(D,g)}else{for(l=c.length-1;l>=0;--l)if(c.charCodeAt(l)===47){if(!x){D=l+1;break}}else g===-1&&(x=!1,g=l+1);return g===-1?"":c.slice(D,g)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),D=d===47,g=-1,x=!0;for(let l=c.length-1;l>=1;--l)if(d=c.charCodeAt(l),d===47){if(!x){g=l;break}}else x=!1;return g===-1?D?"/":".":D&&g===1?"//":c.slice(0,g)},extname:function(c){t(c);let d=-1,D=0,g=-1,x=!0,l=0;for(let C=c.length-1;C>=0;--C){let E=c.charCodeAt(C);if(E===47){if(!x){D=C+1;break}continue}g===-1&&(x=!1,g=C+1),E===46?d===-1?d=C:l!==1&&(l=1):d!==-1&&(l=-1)}return d===-1||g===-1||l===0||l===1&&d===g-1&&d===D+1?"":c.slice(d,g)}}}async function rp(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=si({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[C]of o)if((C+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let C=l===t()?l:l+"/",E=C.split("/").length-1,F=[];for(let[A]of o)if(A.split("/").slice(0,E).join("/")+"/"===C){let $=A.split("/")[E];$&&!F.includes($)&&F.push($)}return F.sort()},p=async(l,C=[])=>{l=i(l);let E=l===t()?l:l+"/",F=[],A=new Set(C);for(let[S]of o)S.startsWith(E)&&(S.slice(E.length).split("/").some(k=>A.has(k))||F.push(S));return F.sort()},f=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?C:null},m=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?new TextEncoder().encode(C):C instanceof Uint8Array?C:null},c=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l),size:a(l)?0:o.get(l)?.length??0}),d=async l=>{if(typeof crypto<"u"){let F=new TextEncoder().encode(l),A=await crypto.subtle.digest("SHA-256",F);return Array.from(new Uint8Array(A)).map(S=>S.toString(16).padStart(2,"0")).join("")}let C=0;for(let E=0;E<l.length;E++){let F=l.charCodeAt(E);C=(C<<5)-C+F,C|=0}return Number(Math.abs(C)).toString(36)},D=new Set,g={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readdirRecursive:p,readFile:async l=>f(l),readFileSync:f,readFileSyncBuffer:l=>m(l),stat:async l=>c(l),statSync:c,writeFile:async(l,C)=>{l=i(l),o.set(l,C);let E={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let F of D)await F(E)},unlink:async l=>{l=i(l),o.delete(l)},unlinkSync:l=>{l=i(l),o.delete(l)},hash:d,getDeviceId:async()=>typeof navigator<"u"?d(navigator.userAgent):"",getRepoInfo:async()=>({hasGit:!1,remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,C)=>C,on:(l,C)=>{l==="change"&&D.add(C)},off:(l,C)=>{l==="change"&&D.delete(C)},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,Sentry:void 0},x=await Ye(g);return g.getFrameworks=e.getFrameworks?e.getFrameworks:()=>x,g}async function ui(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(await ar(e))return console.warn("Turbopack does not support the Builder.io devtools cli. Please disable Turbopack or manually integrate Builder.io into your Next.js project."),o;if(pi(e,n))return o;let s=de(e,n,"cjs"),u=de(e,n);if(s.length!==1&&u.length!==1)throw new Error("Expected an export from file");if(u.length===1){let m=u[0];if(!m.isDefaultExport)throw new Error("Expected a default export from file");let c=m.statement;if(!e.ts.isVariableStatement(c))throw new Error(`Unexpected export type in ${t}
|
|
1023
|
+
`}async function qo(e){let t=await Iu(e);return{builderPageOptions:async()=>({templateContentId:"vue-demo-template-id",pathname:"/builder-demo",title:"Builder + Vue Demo Page"}),ensureBuilderSetup:async()=>(await Mo(t)).errors.length>0?[]:[],ensureFigmaImportPage:()=>Uo(t),getRegistryPath:()=>t.registryPath,getRegistry:n=>et(t,{readAllInputTypes:!!n?.readAllInputTypes}),addExternalPackage:n=>{t.addExternalPackage(n)},loadComponent:async n=>{let o=await et(t,{readAllInputTypes:!1}),i=o.components.find(a=>a.id===n.cmpId);return{...o,component:i}},registerComponent:async n=>et(t,{readAllInputTypes:!1}),setRegisteredComponentInfo:async n=>et(t,{readAllInputTypes:!1}),setRegisteredComponentInput:async n=>et(t,{readAllInputTypes:!1}),unregisterComponent:async n=>et(t,{readAllInputTypes:!1}),getPublicApiKey:()=>Rt(t),setPublicApiKey:n=>Vo(t,n.publicApiKey),getDependencies:n=>n.sdkVersion===y.gen2?[{name:"@builder.io/dev-tools"},{name:"@builder.io/sdk-vue"}]:[{name:"@builder.io/dev-tools"},{name:"@builder.io/vue"},{name:"@builder.io/sdk"}],getDevRunCommand:()=>"dev",getCache:()=>me(t),setCache:n=>fe(t,n)}}async function Iu(e){let t=await Ru(e),r=e.getAppRootDir(),n=e.join(r,"src"),o=await ne(e),i={},a={...e,srcDir:null,builderComponentPath:"",componentsDir:"",registryPath:"",vueConfigPath:t,typescriptEnabled:o,configType:"",isNuxt:await Nu(e),addExternalPackage:p=>{i[e.join(r,p,"index.ts")]=`export * from "${p}";`},readFileSync:p=>i[p]??e.readFileSync(p),existsSync:p=>!!i[p]||e.existsSync(p),readdirSync:p=>{let f=e.readdirSync(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f},readdir:async p=>{let f=await e.readdir(p);return p===r?[...f,...Object.keys(i).map(m=>m.slice(r.length+1))]:f}};t.includes("webpack.config")&&(a.configType="webpack"),(t.includes("vite.config")||t.includes("nuxt.config"))&&(a.configType="vite");let s=await e.exists(n);a.srcDir=s?n:null;let u=[e.join(r,"components"),e.join(r,"src","components"),e.join(r,"app","components")];for(let p of u)if(await e.exists(p)){a.componentsDir=p;break}return a.componentsDir||(a.componentsDir=s?e.join(n,"components"):e.join(r,"components")),a.registryPath=await ie(e,a.componentsDir),a}async function Ru(e){let t=["nuxt.config.ts","nuxt.config.js","vite.config.ts","vite.config.js","webpack.config.js","webpack.config.ts","vue.config.js","vue.config.ts"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return n}if(e.ignoreMissingConfig)return"";throw new Error(`Could not find Vue config file. Searched for ${t.join(", ")} in "${e.getAppRootDir()}".`)}async function Nu(e){let t=["nuxt.config.ts","nuxt.config.js"];for(let r of t){let n=e.join(e.getAppRootDir(),r);if(await e.exists(n))return!0}try{let r=e.join(e.getAppRootDir(),"package.json");if(await e.exists(r)){let n=JSON.parse(await e.readFile(r)||"{}"),o={...n.dependencies,...n.devDependencies};return!!(o.nuxt||o["@nuxt/kit"]||o.nuxt3)}}catch{}return!1}var Zt=Hn(oi(),1);async function ii(e,t){let n={components:(await t.getRegistry()).components.filter(i=>i.isRegistered).map(i=>{let a={filePath:he(e.relative(e.getAppRootDir(),i.filePath)),name:i.name,image:i.image,description:i.description,exportName:i.exportName,inputs:ue(i.inputs)};return ue(a)}),version:1};e.debug("exporting registry components:",n.components.length);let o=(0,Zt.compress)(n);return btoa(JSON.stringify(o))}async function ai(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,Zt.decompress)(o),a=ue(n);e.debug("importing registry components:",i.components.length);for(let s of i.components){let u=he(e.normalize(s.filePath)),p=n.components.find(m=>he(m.filePath).endsWith(u)&&m.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 m of s.inputs)e.debug(`set input (${p.id})`),await t.setRegisteredComponentInput({cmpId:p.id,name:m.name,type:m.type,required:m.required,defaultValue:m.defaultValue,friendlyName:m.friendlyName,helperText:m.helperText});e.debug(`set input (${p.id}) info`);let f=await t.setRegisteredComponentInfo({cmpId:p.id,name:s.name,image:s.image,description:s.description});a=ue(f)}return a}var ce={react:"react",remix:"remix",angular:"angular",next:"next",qwik:"qwik",vue:"vue"},Cg={[ce.react]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ce.remix]:[{version:y.gen1,recommended:!1},{version:y.gen2,recommended:!0}],[ce.angular]:[{version:y.gen2,recommended:!0}],[ce.next]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}],[ce.qwik]:[{version:y.gen2,recommended:!0}],[ce.vue]:[{version:y.gen1,recommended:!0},{version:y.gen2,recommended:!1}]};async function si(e,t){let r=[],n=new Set;async function o(i){let a=e.join(i,"package.json");try{if(!await e.exists(a))return null;let u=await e.readFile(a);if(u===null)throw new Error(`Failed to read package.json at ${a}`);let p=JSON.parse(u);if(typeof p.name!="string"||p.name.trim()===""||n.has(p.name))return null;n.add(p.name);let f={name:p.name,subPackages:[]},m=await e.readdir(i);for(let c of m)c!=="node_modules"&&(await e.stat(e.join(i,c))).isDirectory()&&f.subPackages.push(c);return r.push(f),f}catch(s){return e.Sentry?.captureException(s,{level:"warning"}),null}}try{let i=e.join(t,"package.json");if(await e.exists(i)){let s=await e.readFile(i);if(s!==null){let u=JSON.parse(s),p={...u.dependencies,...u.devDependencies};for(let f of Object.keys(p)){let m=e.join(t,"node_modules",f);await o(m)}if(Array.isArray(u.workspaces))for(let f of u.workspaces){let m=await e.readdir(e.join(t,f));for(let c of m){let d=e.join(t,f,c);await o(d)}}}}}catch(i){e.Sentry?.captureException(i,{level:"warning"})}return r}var np={"@builder.io/qwik-city":to,next:zr,"@remix-run/react":po,react:ho,"@angular/core":jo,vue:qo},rp={"@builder.io/qwik-city":ce.qwik,next:ce.next,"@remix-run/react":ce.remix,react:ce.react,"@angular/core":ce.angular,vue:ce.vue};async function op(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 Ye(e)),e.frameworks.length===0)throw new Error("Supported Devtools framework for not found");for(let t of e.frameworks){let r=np[t.name];if(r)try{let n=await r(e);return{...n,exportRegistry:()=>ii(e,n),importRegistry:i=>ai(e,n,i),framework:rp[t.name],findAllDependencies:async()=>await si(e,e.getRepoRootDir())}}catch(n){e.Sentry?.captureException(n,{level:"warning"})}}throw new Error(`Devtools framework not found for ${e.getAppRootDir()}, ${JSON.stringify(e.frameworks,null,2)}`)}function ui(e){function t(m){if(typeof m!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(m))}function r(m,c){let d="",D=0,g=-1,x=0,l;for(let C=0;C<=m.length;++C){if(C<m.length)l=m.charCodeAt(C);else{if(l===47)break;l=47}if(l===47){if(!(g===C-1||x===1))if(g!==C-1&&x===2){if(d.length<2||D!==2||d.charCodeAt(d.length-1)!==46||d.charCodeAt(d.length-2)!==46){if(d.length>2){let E=d.lastIndexOf("/");if(E!==d.length-1){E===-1?(d="",D=0):(d=d.slice(0,E),D=d.length-1-d.lastIndexOf("/")),g=C,x=0;continue}}else if(d.length===2||d.length===1){d="",D=0,g=C,x=0;continue}}c&&(d.length>0?d+="/..":d="..",D=2)}else d.length>0?d+="/"+m.slice(g+1,C):d=m.slice(g+1,C),D=C-g-1;g=C,x=0}else l===46&&x!==-1?++x:x=-1}return d}let n=function(...c){let d="",D=!1;for(let g=c.length-1;g>=-1&&!D;g--){let x;g>=0?x=c[g]:e.cwd?x=e.cwd():x="/",t(x),x.length!==0&&(d=x+"/"+d,D=x.charCodeAt(0)===47)}return d=r(d,!D),D?d.length>0?"/"+d:"/":d.length>0?d:"."},o=function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0)===47,D=c.charCodeAt(c.length-1)===47;return c=r(c,!d),c.length===0&&!d&&(c="."),c.length>0&&D&&(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 D=1;for(;D<c.length&&c.charCodeAt(D)===47;++D);let g=c.length,x=g-D,l=1;for(;l<d.length&&d.charCodeAt(l)===47;++l);let E=d.length-l,F=x<E?x:E,A=-1,S=0;for(;S<=F;++S){if(S===F){if(E>F){if(d.charCodeAt(l+S)===47)return d.slice(l+S+1);if(S===0)return d.slice(l+S)}else x>F&&(c.charCodeAt(D+S)===47?A=S:S===0&&(A=0));break}let $=c.charCodeAt(D+S),k=d.charCodeAt(l+S);if($!==k)break;$===47&&(A=S)}let B="";for(S=D+A+1;S<=g;++S)(S===g||c.charCodeAt(S)===47)&&(B.length===0?B+="..":B+="/..");return B.length>0?B+d.slice(l+A):(l+=A,d.charCodeAt(l)===47&&++l,d.slice(l))},resolve:n,join:function(...c){if(c.length===0)return".";let d;for(let D=0;D<c.length;++D){let g=c[D];t(g),g.length>0&&(d===void 0?d=g:d+="/"+g)}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 D=0,g=-1,x=!0,l;if(d!==void 0&&d.length>0&&d.length<=c.length){if(d.length===c.length&&d===c)return"";let C=d.length-1,E=-1;for(l=c.length-1;l>=0;--l){let F=c.charCodeAt(l);if(F===47){if(!x){D=l+1;break}}else E===-1&&(x=!1,E=l+1),C>=0&&(F===d.charCodeAt(C)?--C===-1&&(g=l):(C=-1,g=E))}return D===g?g=E:g===-1&&(g=c.length),c.slice(D,g)}else{for(l=c.length-1;l>=0;--l)if(c.charCodeAt(l)===47){if(!x){D=l+1;break}}else g===-1&&(x=!1,g=l+1);return g===-1?"":c.slice(D,g)}},normalize:o,dirname:function(c){if(t(c),c.length===0)return".";let d=c.charCodeAt(0),D=d===47,g=-1,x=!0;for(let l=c.length-1;l>=1;--l)if(d=c.charCodeAt(l),d===47){if(!x){g=l;break}}else x=!1;return g===-1?D?"/":".":D&&g===1?"//":c.slice(0,g)},extname:function(c){t(c);let d=-1,D=0,g=-1,x=!0,l=0;for(let C=c.length-1;C>=0;--C){let E=c.charCodeAt(C);if(E===47){if(!x){D=C+1;break}continue}g===-1&&(x=!1,g=C+1),E===46?d===-1?d=C:l!==1&&(l=1):d!==-1&&(l=-1)}return d===-1||g===-1||l===0||l===1&&d===g-1&&d===D+1?"":c.slice(d,g)}}}async function ip(e){let t=e.getRepoRootDir?e.getRepoRootDir:()=>"/",r=e.cwd?e.cwd:()=>"/",n=ui({cwd:r,...e}),o=new Map,i=l=>n.normalize(n.resolve(r(),l)),a=l=>{for(let[C]of o)if((C+"/").startsWith(l))return!0;return l===t()},s=l=>(l=i(l),o.has(l)?!0:a(l)),u=l=>{l=i(l);let C=l===t()?l:l+"/",E=C.split("/").length-1,F=[];for(let[A]of o)if(A.split("/").slice(0,E).join("/")+"/"===C){let $=A.split("/")[E];$&&!F.includes($)&&F.push($)}return F.sort()},p=async(l,C=[])=>{l=i(l);let E=l===t()?l:l+"/",F=[],A=new Set(C);for(let[S]of o)S.startsWith(E)&&(S.slice(E.length).split("/").some(k=>A.has(k))||F.push(S));return F.sort()},f=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?C:null},m=l=>{l=i(l);let C=o.get(l);return typeof C=="string"?new TextEncoder().encode(C):C instanceof Uint8Array?C:null},c=l=>(l=i(l),{isFile:()=>o.has(l),isDirectory:()=>!o.has(l)&&a(l),size:a(l)?0:o.get(l)?.length??0}),d=async l=>{if(typeof crypto<"u"){let F=new TextEncoder().encode(l),A=await crypto.subtle.digest("SHA-256",F);return Array.from(new Uint8Array(A)).map(S=>S.toString(16).padStart(2,"0")).join("")}let C=0;for(let E=0;E<l.length;E++){let F=l.charCodeAt(E);C=(C<<5)-C+F,C|=0}return Number(Math.abs(C)).toString(36)},D=new Set,g={getRepoRootDir:t,getAppRootDir:t,getCwdDir:r,cwd:r,exists:async l=>s(l),existsSync:s,readdir:async l=>u(l),readdirSync:u,readdirRecursive:p,readFile:async l=>f(l),readFileSync:f,readFileSyncBuffer:l=>m(l),stat:async l=>c(l),statSync:c,writeFile:async(l,C)=>{l=i(l),o.set(l,C);let E={path:l,basename:n.basename(l),dirname:n.dirname(l),extname:n.extname(l)};for(let F of D)await F(E)},unlink:async l=>{l=i(l),o.delete(l)},unlinkSync:l=>{l=i(l),o.delete(l)},hash:d,getDeviceId:async()=>typeof navigator<"u"?d(navigator.userAgent):"",getRepoInfo:async()=>({hasGit:!1,remoteUrl:"",defaultBranch:"",currentBranch:"",commit:""}),formatCode:async(l,C)=>C,on:(l,C)=>{l==="change"&&D.add(C)},off:(l,C)=>{l==="change"&&D.delete(C)},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,Sentry:void 0},x=await Ye(g);return g.getFrameworks=e.getFrameworks?e.getFrameworks:()=>x,g}async function pi(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(await sr(e))return console.warn("Turbopack does not support the Builder.io devtools cli. Please disable Turbopack or manually integrate Builder.io into your Next.js project."),o;if(ci(e,n))return o;let s=de(e,n,"cjs"),u=de(e,n);if(s.length!==1&&u.length!==1)throw new Error("Expected an export from file");if(u.length===1){let m=u[0];if(!m.isDefaultExport)throw new Error("Expected a default export from file");let c=m.statement;if(!e.ts.isVariableStatement(c))throw new Error(`Unexpected export type in ${t}
|
|
1024
1024
|
Found config content:
|
|
1025
1025
|
${r}
|
|
1026
1026
|
|
|
@@ -1049,7 +1049,7 @@ Detected export type: ${p?.statement.kind??"none"}
|
|
|
1049
1049
|
Valid formats:
|
|
1050
1050
|
1. module.exports = { ... }
|
|
1051
1051
|
2. module.exports = (phase, config) => { return { ... } }
|
|
1052
|
-
3. export default { ... }`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let m=p.statement;if(!e.ts.isExpressionStatement(m))throw new Error("Expected an expression statement for the default export");let c=m.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let d=
|
|
1052
|
+
3. export default { ... }`);if(e.ts.isObjectLiteralExpression(p.node)||e.ts.isCallExpression(p.node)){let m=p.statement;if(!e.ts.isExpressionStatement(m))throw new Error("Expected an expression statement for the default export");let c=m.expression;if(!e.ts.isBinaryExpression(c))throw new Error("Expected a binary expression for the default export");let d=Yn(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(m);return D[g]=e.ts.factory.updateExpressionStatement(m,e.ts.factory.updateBinaryExpression(c,c.left,c.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c.right]))),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}let f=p.statement;if(e.ts.isVariableStatement(f)){let m=[...f.declarationList.declarations];if(m.length!==1)throw new Error("Expected a single variable declaration");let c=m[0];if(!c.initializer)throw new Error("Expected an initializer on the declaration");let d=c.initializer;if(e.ts.isObjectLiteralExpression(d)||e.ts.isCallExpression(d)){let D=Yn(e,n);n=D.sourceFile;let g=[...n.statements],x=g.indexOf(f);return g[x]=e.ts.factory.updateVariableStatement(f,f.modifiers,e.ts.factory.updateVariableDeclarationList(f.declarationList,[e.ts.factory.updateVariableDeclaration(c,c.name,c.exclamationToken,c.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(D.withFnVariableName),void 0,[d]))])),n=e.ts.factory.updateSourceFile(n,g),o.content=j(e,n),o.outcome="added",o}throw new Error(`Unexpected initializer on the variable statement in ${t}
|
|
1053
1053
|
Found config content:
|
|
1054
1054
|
${r}
|
|
1055
1055
|
|
|
@@ -1058,17 +1058,17 @@ The config variable must be initialized with either:
|
|
|
1058
1058
|
2. A function call: const nextConfig = withSomePlugin({ /* config */ })
|
|
1059
1059
|
|
|
1060
1060
|
Current initializer type: ${d.kind}
|
|
1061
|
-
Expected types: ${e.ts.SyntaxKind.ObjectLiteralExpression} or ${e.ts.SyntaxKind.CallExpression}`)}if(e.ts.isArrowFunction(p.node)){let m=p.node,c=p.statement;if(!e.ts.isExpressionStatement(c))throw new Error("Expected an expression statement for the default export");let d=c.expression;if(!e.ts.isBinaryExpression(d))throw new Error("Expected a binary expression for the default export");let g=p.node.body;if(!e.ts.isBlock(g))throw new Error("Expected a block body on the next config function");let x=[...g.statements],l=x.findIndex(S=>e.ts.isReturnStatement(S));if(l===-1)throw new Error("Expected a return statement on the next config function");let C=x[l],E=Qn(e,n);n=E.sourceFile,x[l]=e.ts.factory.updateReturnStatement(C,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(E.withFnVariableName),void 0,[C.expression]));let F=[...n.statements],A=F.indexOf(c);return F[A]=e.ts.factory.updateExpressionStatement(c,e.ts.factory.updateBinaryExpression(d,d.left,d.operatorToken,e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,e.ts.factory.updateBlock(g,x)))),n=e.ts.factory.updateSourceFile(n,F),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function pi(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Qn(e,t){let r=pi(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function mi(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(fi(e,n))return o;let a=de(e,n,"cjs"),s=de(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let u=a[0];if(s.length===1){let f=s[0];if(!f.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let m=f.statement;if(!e.ts.isExportAssignment(m))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(m.expression)){let c="builderDevTools()",d=op(e,m.expression);if(!d)return o;let D=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[d]),g=[...n.statements],x=g.indexOf(m);return g[x]=e.ts.factory.updateExportAssignment(m,m.modifiers,D),n=e.ts.factory.updateSourceFile(n,g),n=I(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=j(e,n),o.outcome="added",o}}if(!u.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(u.node)||e.ts.isCallExpression(u.node)){let f=u.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let m=f.expression;if(!e.ts.isBinaryExpression(m))throw new Error("Expected a binary expression for the default export");let c=ci(e,n);n=c.sourceFile;let d=[...n.statements],D=d.indexOf(f);return d[D]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(m,m.left,m.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[m.right]))),n=e.ts.factory.updateSourceFile(n,d),o.content=j(e,n),o.outcome="added",o}let p=u.statement;if(e.ts.isVariableStatement(p)){let f=[...p.declarationList.declarations];if(f.length!==1)throw new Error("Expected a single variable declaration");let m=f[0];if(!m.initializer)throw new Error("Expected an initializer on the declaration");let c=m.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let d=ci(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(p);return D[g]=e.ts.factory.updateVariableStatement(p,p.modifiers,e.ts.factory.updateVariableDeclarationList(p.declarationList,[e.ts.factory.updateVariableDeclaration(m,m.name,m.exclamationToken,m.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function fi(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function ci(e,t){let r=fi(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function op(e,t){let r=[...t.properties],n=r.findIndex(i=>L(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=li(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=li(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function li(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function gi(e,t,r){try{let n=await ip(e,t,r,"builderDevTools","@builder.io/dev-tools/vite");return{content:n.content,filePath:n.filePath,fileName:n.fileName,outcome:n.outcome}}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}async function ip(e,t,r,n,o){try{if(n==="builderDevTools"&&r.includes(n)&&r.includes(o)&&(r.includes(`plugins: [${n}()]`)||r.includes(`plugins: [ ${n}()]`)))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};if(n==="jsxLocPlugin"&&o==="@builder.io/vite-plugin-jsx-loc"&&r.includes(n)&&r.includes(o)&&b(e,r).statements.some(c=>{if(e.ts.isImportDeclaration(c)){let d=c.moduleSpecifier.text;if((d===o||d.includes(n))&&c.importClause?.namedBindings&&e.ts.isNamedImports(c.importClause.namedBindings))return c.importClause.namedBindings.elements.some(D=>D.name.text===n)}return!1}))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};let i=b(e,r),a=de(e,i);if(a.length!==1)throw new Error(`Expected an export from ${t}`);let s=a[0];if(!s.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let u=s.statement;if(!e.ts.isExportAssignment(u))throw new Error(`Expected an export assignment from ${t}`);let p={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(e.ts.isCallExpression(s.node)&&e.ts.isIdentifier(s.node.expression)&&s.node.expression.text==="defineConfig"){let f=[...s.node.arguments];if(f.length===0)throw new Error("Expected an argument in defineConfig()");let m=f[0];if(e.ts.isArrowFunction(m)){let c=ap(e,m,n);if(!c)return p;f[0]=e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,c);let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,f)),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}if(e.ts.isObjectLiteralExpression(m)){let c=en(e,m,n);if(!c)return p;let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,[c])),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(u.expression)){let f=en(e,u.expression,n);if(!f)return p;let m=[...i.statements],c=m.indexOf(u);return m[c]=e.ts.factory.updateExportAssignment(u,u.modifiers,f),i=e.ts.factory.updateSourceFile(i,m),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error(`Unable to parse ${t}`)}catch(i){throw e.Sentry?.captureException(i,{extra:{configFilePath:t,configContent:r},level:"warning"}),i}}function ap(e,t,r){let n=t.body;if(!e.ts.isBlock(n)){if(e.ts.isParenthesizedExpression(n)&&e.ts.isObjectLiteralExpression(n.expression)){let u=en(e,n.expression,r);if(u)return u}return null}let o=[...n.statements],i=o.findIndex(u=>e.ts.isReturnStatement(u));if(i===-1){let u=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());o.push(u),i=o.length-1}let a=o[i];if(!a.expression||!e.ts.isObjectLiteralExpression(a.expression))return null;let s=en(e,a.expression,r);return s?(o[i]=e.ts.factory.updateReturnStatement(a,s),e.ts.factory.updateBlock(n,o)):null}function en(e,t,r){if(pp(e)){let a=sp(e,t);a&&(t=a)}let n=[...t.properties],o=n.findIndex(a=>tn(e,a)==="plugins");if(o>-1){let a=n[o];if(e.ts.isPropertyAssignment(a)&&a.initializer)if(e.ts.isArrayLiteralExpression(a.initializer)){let s=di(e,a.initializer,r);if(s)return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,s),e.ts.factory.updateObjectLiteralExpression(t,n)}else{let s=e.ts.factory.createSpreadElement(a.initializer),u=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[]),p=e.ts.factory.createArrayLiteralExpression([s,u],!0);return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,p),e.ts.factory.updateObjectLiteralExpression(t,n)}return null}let i=di(e,e.ts.factory.createArrayLiteralExpression([],!0),r);return i?e.ts.factory.updateObjectLiteralExpression(t,[...n,e.ts.factory.createPropertyAssignment("plugins",i)]):null}function di(e,t,r){return t.elements.some(o=>{if(e.ts.isCallExpression(o)&&e.ts.isIdentifier(o.expression))return o.expression.text===r;if(e.ts.isBinaryExpression(o)&&o.operatorToken.kind===e.ts.SyntaxKind.AmpersandAmpersandToken){let i=o.right;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression))return i.expression.text===r}if(e.ts.isConditionalExpression(o)){let i=o.whenTrue,a=o.whenFalse;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression)&&i.expression.text===r||e.ts.isCallExpression(a)&&e.ts.isIdentifier(a.expression)&&a.expression.text===r)return!0}if(e.ts.isCallExpression(o)&&e.ts.isPropertyAccessExpression(o.expression)){let i=o.expression.expression;if(e.ts.isArrayLiteralExpression(i))return i.elements.some(a=>Ot(e,a,r))}return!1})?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[])])}function Ot(e,t,r){return e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)?t.expression.text===r:e.ts.isBinaryExpression(t)?Ot(e,t.left,r)||Ot(e,t.right,r):e.ts.isConditionalExpression(t)?Ot(e,t.whenTrue,r)||Ot(e,t.whenFalse,r):!1}function sp(e,t){let r=[...t.properties],n=r.findIndex(i=>tn(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=up(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Yn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=r.findIndex(u=>tn(e,u)==="plugins"),a=[...r],s=e.ts.factory.createPropertyAssignment("ssr",e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]));return i>-1?a.splice(i,0,s):a.push(s),e.ts.factory.updateObjectLiteralExpression(t,a)}return null}function up(e,t){let r=[...t.properties],n=r.findIndex(i=>tn(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Yn(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Yn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function Yn(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function tn(e,t){return(e.ts.isPropertyAssignment(t)||e.ts.isMethodDeclaration(t))&&(e.ts.isIdentifier(t.name)||e.ts.isStringLiteral(t.name))?t.name.text:""}function pp(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function Di(e,t,r){return e.debug("Updating Webpack config to include Builder.io plugin..."),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function Ci(e,t,r){e.debug("Angular config updates are currently in progress...");try{await mp(e)}catch(n){e.Sentry?.captureException(new Error("Unable to update package.json.",{cause:n}))}return await cp(e),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function cp(e){let t=e.getAppRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await lp(e,o);await e.writeFile(n,i)}async function lp(e,t){let r=t,n=b(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=I(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
|
|
1061
|
+
Expected types: ${e.ts.SyntaxKind.ObjectLiteralExpression} or ${e.ts.SyntaxKind.CallExpression}`)}if(e.ts.isArrowFunction(p.node)){let m=p.node,c=p.statement;if(!e.ts.isExpressionStatement(c))throw new Error("Expected an expression statement for the default export");let d=c.expression;if(!e.ts.isBinaryExpression(d))throw new Error("Expected a binary expression for the default export");let g=p.node.body;if(!e.ts.isBlock(g))throw new Error("Expected a block body on the next config function");let x=[...g.statements],l=x.findIndex(S=>e.ts.isReturnStatement(S));if(l===-1)throw new Error("Expected a return statement on the next config function");let C=x[l],E=Yn(e,n);n=E.sourceFile,x[l]=e.ts.factory.updateReturnStatement(C,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(E.withFnVariableName),void 0,[C.expression]));let F=[...n.statements],A=F.indexOf(c);return F[A]=e.ts.factory.updateExpressionStatement(c,e.ts.factory.updateBinaryExpression(d,d.left,d.operatorToken,e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,e.ts.factory.updateBlock(g,x)))),n=e.ts.factory.updateSourceFile(n,F),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function ci(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/next"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function Yn(e,t){let r=ci(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/next")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}async function fi(e,t,r){try{let n=b(e,r),o={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(di(e,n))return o;let a=de(e,n,"cjs"),s=de(e,n);if(a.length!==1&&s.length!==1)throw new Error(`Expected an export from ${t}`);let u=a[0];if(s.length===1){let f=s[0];if(!f.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let m=f.statement;if(!e.ts.isExportAssignment(m))throw new Error(`Expected an export assignment from ${t}`);if(e.ts.isObjectLiteralExpression(m.expression)){let c="builderDevTools()",d=ap(e,m.expression);if(!d)return o;let D=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c),void 0,[d]),g=[...n.statements],x=g.indexOf(m);return g[x]=e.ts.factory.updateExportAssignment(m,m.modifiers,D),n=e.ts.factory.updateSourceFile(n,g),n=I(e,n,{defaultImport:"builderDevTools",importPath:"@builder.io/dev-tools/remix"}),o.content=j(e,n),o.outcome="added",o}}if(!u.isDefaultExport)throw new Error(`Expected a default export from ${t}`);if(e.ts.isObjectLiteralExpression(u.node)||e.ts.isCallExpression(u.node)){let f=u.statement;if(!e.ts.isExpressionStatement(f))throw new Error("Expected an expression statement for the default export");let m=f.expression;if(!e.ts.isBinaryExpression(m))throw new Error("Expected a binary expression for the default export");let c=li(e,n);n=c.sourceFile;let d=[...n.statements],D=d.indexOf(f);return d[D]=e.ts.factory.updateExpressionStatement(f,e.ts.factory.updateBinaryExpression(m,m.left,m.operatorToken,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(c.withFnVariableName),void 0,[m.right]))),n=e.ts.factory.updateSourceFile(n,d),o.content=j(e,n),o.outcome="added",o}let p=u.statement;if(e.ts.isVariableStatement(p)){let f=[...p.declarationList.declarations];if(f.length!==1)throw new Error("Expected a single variable declaration");let m=f[0];if(!m.initializer)throw new Error("Expected an initializer on the declaration");let c=m.initializer;if(e.ts.isObjectLiteralExpression(c)||e.ts.isCallExpression(c)){let d=li(e,n);n=d.sourceFile;let D=[...n.statements],g=D.indexOf(p);return D[g]=e.ts.factory.updateVariableStatement(p,p.modifiers,e.ts.factory.updateVariableDeclarationList(p.declarationList,[e.ts.factory.updateVariableDeclaration(m,m.name,m.exclamationToken,m.type,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(d.withFnVariableName),void 0,[c]))])),n=e.ts.factory.updateSourceFile(n,D),o.content=j(e,n),o.outcome="added",o}throw new Error("Unexpected initializer on the variable statement")}throw new Error("Unexpected export type")}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}function di(e,t){for(let r of t.statements)if(e.ts.isVariableStatement(r))for(let n of r.declarationList.declarations){if(!n.initializer||!e.ts.isCallExpression(n.initializer))continue;let o=n.initializer.expression;if(!e.ts.isCallExpression(o)||!e.ts.isIdentifier(o.expression)||o.expression.text!=="require")continue;let i=o.arguments[0];if(!(!i||!e.ts.isStringLiteral(i))&&i.text==="@builder.io/dev-tools/remix"&&e.ts.isIdentifier(n.name))return n.name.text}return null}function li(e,t){let r=di(e,t);return r||(r="withBuilderDevTools",t=e.ts.factory.updateSourceFile(t,[e.ts.factory.createVariableStatement(void 0,e.ts.factory.createVariableDeclarationList([e.ts.factory.createVariableDeclaration(r,void 0,void 0,e.ts.factory.createCallExpression(e.ts.factory.createCallExpression(e.ts.factory.createIdentifier("require"),void 0,[e.ts.factory.createStringLiteral("@builder.io/dev-tools/remix")]),void 0,[]))],e.ts.NodeFlags.Const)),...t.statements])),{withFnVariableName:r,sourceFile:t}}function ap(e,t){let r=[...t.properties],n=r.findIndex(i=>L(e,i)==="serverDependenciesToBundle");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=mi(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=mi(e,e.ts.factory.createArrayLiteralExpression([],!0));return o?e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("serverDependenciesToBundle",o)]):null}function mi(e,t){return t.elements.some(n=>e.ts.isCallExpression(n)&&e.ts.isIdentifier(n.expression)?n.expression.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createIdentifier('"@builder.io/react"')])}async function Di(e,t,r){try{let n=await sp(e,t,r,"builderDevTools","@builder.io/dev-tools/vite");return{content:n.content,filePath:n.filePath,fileName:n.fileName,outcome:n.outcome}}catch(n){throw e.Sentry?.captureException(n,{extra:{configFilePath:t,configContent:r},level:"warning"}),n}}async function sp(e,t,r,n,o){try{if(n==="builderDevTools"&&r.includes(n)&&r.includes(o)&&(r.includes(`plugins: [${n}()]`)||r.includes(`plugins: [ ${n}()]`)))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};if(n==="jsxLocPlugin"&&o==="@builder.io/vite-plugin-jsx-loc"&&r.includes(n)&&r.includes(o)&&b(e,r).statements.some(c=>{if(e.ts.isImportDeclaration(c)){let d=c.moduleSpecifier.text;if((d===o||d.includes(n))&&c.importClause?.namedBindings&&e.ts.isNamedImports(c.importClause.namedBindings))return c.importClause.namedBindings.elements.some(D=>D.name.text===n)}return!1}))return{content:r,filePath:t,fileName:e.basename(t),outcome:"already-exists"};let i=b(e,r),a=de(e,i);if(a.length!==1)throw new Error(`Expected an export from ${t}`);let s=a[0];if(!s.isDefaultExport)throw new Error(`Expected a default export from ${t}`);let u=s.statement;if(!e.ts.isExportAssignment(u))throw new Error(`Expected an export assignment from ${t}`);let p={content:r,filePath:t,fileName:e.basename(t),outcome:"no-update"};if(e.ts.isCallExpression(s.node)&&e.ts.isIdentifier(s.node.expression)&&s.node.expression.text==="defineConfig"){let f=[...s.node.arguments];if(f.length===0)throw new Error("Expected an argument in defineConfig()");let m=f[0];if(e.ts.isArrowFunction(m)){let c=up(e,m,n);if(!c)return p;f[0]=e.ts.factory.updateArrowFunction(m,m.modifiers,m.typeParameters,m.parameters,m.type,m.equalsGreaterThanToken,c);let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,f)),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}if(e.ts.isObjectLiteralExpression(m)){let c=en(e,m,n);if(!c)return p;let d=[...i.statements],D=d.indexOf(u);return d[D]=e.ts.factory.updateExportAssignment(u,void 0,e.ts.factory.updateCallExpression(s.node,s.node.expression,s.node.typeArguments,[c])),i=e.ts.factory.updateSourceFile(i,d),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error("Unsupported argument in defineConfig()")}if(e.ts.isObjectLiteralExpression(u.expression)){let f=en(e,u.expression,n);if(!f)return p;let m=[...i.statements],c=m.indexOf(u);return m[c]=e.ts.factory.updateExportAssignment(u,u.modifiers,f),i=e.ts.factory.updateSourceFile(i,m),i=I(e,i,{namedImports:[n],importPath:o}),p.content=j(e,i),p.outcome="added",p}throw new Error(`Unable to parse ${t}`)}catch(i){throw e.Sentry?.captureException(i,{extra:{configFilePath:t,configContent:r},level:"warning"}),i}}function up(e,t,r){let n=t.body;if(!e.ts.isBlock(n)){if(e.ts.isParenthesizedExpression(n)&&e.ts.isObjectLiteralExpression(n.expression)){let u=en(e,n.expression,r);if(u)return u}return null}let o=[...n.statements],i=o.findIndex(u=>e.ts.isReturnStatement(u));if(i===-1){let u=e.ts.factory.createReturnStatement(e.ts.factory.createObjectLiteralExpression());o.push(u),i=o.length-1}let a=o[i];if(!a.expression||!e.ts.isObjectLiteralExpression(a.expression))return null;let s=en(e,a.expression,r);return s?(o[i]=e.ts.factory.updateReturnStatement(a,s),e.ts.factory.updateBlock(n,o)):null}function en(e,t,r){if(lp(e)){let a=pp(e,t);a&&(t=a)}let n=[...t.properties],o=n.findIndex(a=>tn(e,a)==="plugins");if(o>-1){let a=n[o];if(e.ts.isPropertyAssignment(a)&&a.initializer)if(e.ts.isArrayLiteralExpression(a.initializer)){let s=gi(e,a.initializer,r);if(s)return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,s),e.ts.factory.updateObjectLiteralExpression(t,n)}else{let s=e.ts.factory.createSpreadElement(a.initializer),u=e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[]),p=e.ts.factory.createArrayLiteralExpression([s,u],!0);return n[o]=e.ts.factory.updatePropertyAssignment(a,a.name,p),e.ts.factory.updateObjectLiteralExpression(t,n)}return null}let i=gi(e,e.ts.factory.createArrayLiteralExpression([],!0),r);return i?e.ts.factory.updateObjectLiteralExpression(t,[...n,e.ts.factory.createPropertyAssignment("plugins",i)]):null}function gi(e,t,r){return t.elements.some(o=>{if(e.ts.isCallExpression(o)&&e.ts.isIdentifier(o.expression))return o.expression.text===r;if(e.ts.isBinaryExpression(o)&&o.operatorToken.kind===e.ts.SyntaxKind.AmpersandAmpersandToken){let i=o.right;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression))return i.expression.text===r}if(e.ts.isConditionalExpression(o)){let i=o.whenTrue,a=o.whenFalse;if(e.ts.isCallExpression(i)&&e.ts.isIdentifier(i.expression)&&i.expression.text===r||e.ts.isCallExpression(a)&&e.ts.isIdentifier(a.expression)&&a.expression.text===r)return!0}if(e.ts.isCallExpression(o)&&e.ts.isPropertyAccessExpression(o.expression)){let i=o.expression.expression;if(e.ts.isArrayLiteralExpression(i))return i.elements.some(a=>Ot(e,a,r))}return!1})?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createCallExpression(e.ts.factory.createIdentifier(r),void 0,[])])}function Ot(e,t,r){return e.ts.isCallExpression(t)&&e.ts.isIdentifier(t.expression)?t.expression.text===r:e.ts.isBinaryExpression(t)?Ot(e,t.left,r)||Ot(e,t.right,r):e.ts.isConditionalExpression(t)?Ot(e,t.whenTrue,r)||Ot(e,t.whenFalse,r):!1}function pp(e,t){let r=[...t.properties],n=r.findIndex(i=>tn(e,i)==="ssr");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isObjectLiteralExpression(i.initializer)){let a=cp(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Gn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o){let i=r.findIndex(u=>tn(e,u)==="plugins"),a=[...r],s=e.ts.factory.createPropertyAssignment("ssr",e.ts.factory.createObjectLiteralExpression([e.ts.factory.createPropertyAssignment("noExternal",o)]));return i>-1?a.splice(i,0,s):a.push(s),e.ts.factory.updateObjectLiteralExpression(t,a)}return null}function cp(e,t){let r=[...t.properties],n=r.findIndex(i=>tn(e,i)==="noExternal");if(n>-1){let i=r[n];if(e.ts.isPropertyAssignment(i)&&i.initializer&&e.ts.isArrayLiteralExpression(i.initializer)){let a=Gn(e,i.initializer);if(a)return r[n]=e.ts.factory.updatePropertyAssignment(i,i.name,a),e.ts.factory.updateObjectLiteralExpression(t,r)}return null}let o=Gn(e,e.ts.factory.createArrayLiteralExpression([],!0));if(o)return e.ts.factory.updateObjectLiteralExpression(t,[...r,e.ts.factory.createPropertyAssignment("noExternal",o)])}function Gn(e,t){return t.elements.some(n=>e.ts.isStringLiteral(n)?n.text==="@builder.io/react":!1)?null:e.ts.factory.updateArrayLiteralExpression(t,[...t.elements,e.ts.factory.createStringLiteral("@builder.io/react")])}function tn(e,t){return(e.ts.isPropertyAssignment(t)||e.ts.isMethodDeclaration(t))&&(e.ts.isIdentifier(t.name)||e.ts.isStringLiteral(t.name))?t.name.text:""}function lp(e){return e.getFrameworks().some(t=>t.name==="@remix-run/react")}async function xi(e,t,r){return e.debug("Updating Webpack config to include Builder.io plugin..."),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function hi(e,t,r){e.debug("Angular config updates are currently in progress...");try{await dp(e)}catch(n){e.Sentry?.captureException(new Error("Unable to update package.json.",{cause:n}))}return await mp(e),{content:r,fileName:e.basename(t),filePath:t,outcome:"added"}}async function mp(e){let t=e.getAppRootDir(),r=e.join(t,"src");if(!await e.exists(r))throw new Error(`Could not find src directory. Searched for src in "${e.getAppRootDir()}".`);let n=e.join(r,"main.ts"),o=await e.readFile(n);if(!o)throw new Error(`Unable to read main.ts at ${n}`);let i=await fp(e,o);await e.writeFile(n,i)}async function fp(e,t){let r=t,n=b(e,t),o=!1;for(let a of n.statements)if(e.ts.isExpressionStatement(a)&&e.ts.isCallExpression(a.expression)&&e.ts.isPropertyAccessExpression(a.expression.expression)&&e.ts.isCallExpression(a.expression.expression.expression)&&e.ts.isIdentifier(a.expression.expression.expression.expression)&&a.expression.expression.expression.expression.text==="builderDevTools"){o=!0;break}n=I(e,n,{namedImports:["builderDevTools"],importPath:"@builder.io/dev-tools/angular"});let i=`
|
|
1062
1062
|
builderDevTools().catch((err: Error) =>
|
|
1063
1063
|
console.error("Error starting dev tools:", err)
|
|
1064
|
-
);`;return r=j(e,n),o||(r+=i),r}async function
|
|
1065
|
-
`}var
|
|
1064
|
+
);`;return r=j(e,n),o||(r+=i),r}async function dp(e){let t=e.getRepoRootDir(),r=e.join(t,"package.json"),n=await e.readFile(r);if(!n)throw new Error(`Unable to read package.json at ${r}`);let o=gp(e,n);o&&await e.writeFile(r,o)}function gp(e,t){let r=JSON.parse(t);if(r.scripts=r.scripts||{},r.scripts[Ci])return;let n=r.scripts.start||r.scripts.dev||"ng serve";if(!n.includes("concurrently")){let o=e.getRepoRootDir(),i=e.getAppRootDir(),a=o===i?"":` --cwd ${e.relative(o,i)}`,s=`concurrently "${n}" "${Dp}${a}"`;r.scripts.start=s,r.scripts[Ci]=s}return JSON.stringify(r,null,2)+`
|
|
1065
|
+
`}var Ci="builder-dev",Dp="npx builder-dev-tools";var Si=[{id:"next",configFileNames:["next.config.ts","next.config.js","next.config.mjs"],ensureConfigPlugin:pi},{id:"vite",configFileNames:["vite.config.ts","vite.config.js"],ensureConfigPlugin:Di},{id:"remix",configFileNames:["remix.config.ts","remix.config.js"],ensureConfigPlugin:fi},{id:"webpack",configFileNames:["webpack.config.ts","webpack.config.js"],ensureConfigPlugin:xi},{id:"angular",configFileNames:["angular.json","project.json"],ensureConfigPlugin:hi}];async function Ai(e){let t=e.resolve("/");for(let n of Si)for(let o of n.configFileNames){let i=e.getAppRootDir();for(let a=0;a<10;a++)try{let s=e.join(i,o),u=e.readFileSync(s);if(typeof u=="string")return{id:n.id,filePath:s,content:u};if(i===t)break;i=e.dirname(i)}catch(s){if((s?.message??"").includes("Invalid path"))break;throw s}}if((await Ye(e)).some(n=>n.name==="next")){let n=e.join(e.getAppRootDir(),"next.config.js");return await e.writeFile(n,Ei),{id:"next",filePath:n,content:Ei}}return null}async function xp(e){let t=await Ai(e);if(!t)throw new Error("Unable to find config file, such as next.config.js or vite.config.js.");let n=await Si.find(o=>o.id===t.id).ensureConfigPlugin(e,t.filePath,t.content);return(n.outcome==="added"||n.outcome==="already-exists")&&(e.debug(`Successfully updated ${t.filePath}`),n.content=De(n.content),n.content=await e.formatCode(n.filePath,n.content),await e.writeFile(t.filePath,n.content)),n}var Ei=`
|
|
1066
1066
|
/** @type {import('next').NextConfig} */
|
|
1067
1067
|
const nextConfig = {
|
|
1068
1068
|
}
|
|
1069
1069
|
|
|
1070
1070
|
module.exports = nextConfig
|
|
1071
|
-
`.trimStart();var
|
|
1071
|
+
`.trimStart();var Fi="/~builder-dev-tools.js";function Cp(e){try{if(typeof e!="string"||e.trim().length===0)return console.error("Missing devtool server url"),"";let t=new URL(Fi,e);t.searchParams.set("v",nn);let r=JSON.stringify(nn),n=`/* Builder Devtools v${nn} */
|
|
1072
1072
|
`;return n+=`(() => {
|
|
1073
1073
|
`,n+=` if (typeof document !== "undefined") {
|
|
1074
1074
|
`,n+=` let devToolsScript = document.head.querySelector("script[data-builder-dev-tools]");
|
|
@@ -1081,4 +1081,4 @@ module.exports = nextConfig
|
|
|
1081
1081
|
`,n+=` }
|
|
1082
1082
|
`,n+=` }
|
|
1083
1083
|
`,n+=`})();
|
|
1084
|
-
`,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var nn=
|
|
1084
|
+
`,n}catch(t){return console.error(`Failed to create devtools client script: ${t.message||t}`),""}}var nn=Zn;export{op as createDevTools,ip as createDevToolsSys,Ye as detectFrameworks,ur as detectFrameworksFromPackageJson,xp as ensureConfigPlugin,Ai as findBuildToolConfig,Cp as getClientScript,cr as parseDotEnvContent,nn as version};
|