@fugood/bricks-cli 2.26.2-beta.0 → 2.26.2-beta.1
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/lib/1010.js +1 -1
- package/lib/1374.js +1 -1
- package/lib/1708.js +2 -2
- package/lib/2486.js +1 -1
- package/lib/2517.js +7 -7
- package/lib/2678.js +7 -0
- package/lib/3223.js +4 -4
- package/lib/3774.js +3 -3
- package/lib/4456.js +2 -2
- package/lib/6194.js +2 -1
- package/lib/6818.js +1 -1
- package/lib/7294.js +2 -2
- package/lib/7511.js +1 -1
- package/lib/8310.js +3 -0
- package/lib/8412.js +1 -0
- package/lib/907.js +60 -40
- package/lib/9439.js +46 -26
- package/lib/index.js +57 -52
- package/lib/lib.js +101 -81
- package/package.json +5 -5
- package/lib/4642.js +0 -9
package/lib/3223.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const __rspack_esm_id=3223;export const __rspack_esm_ids=[3223];export const __webpack_modules__={85(e,r,t){let{checkConfig:o,checkConfigDeprecatedFeatures:
|
|
2
|
-
Valid codes: ${f.join(", ")}`);let d=e=>(!t||t.includes(e))&&(!p||!p.includes(e)),h=[],g=o(e,{checkCalc:!0,checkExpressions:!0,checkActionRefs:!0,checkItemsEventMaps:!0,checkAutomation:l,maxLinkFindings:1e4}),m=(e,r,t)=>{d(r)&&(e||[]).forEach(e=>h.push({hint:null,...t(e)}))};m(g.schema,"schema-error",e=>({severity:"error",code:"schema-error",path:e.instancePath||e.dataPath||"/",message:e.message,hint:e.params?.pattern?`pattern: ${e.params.pattern}`:null})),m(g.ref,"ref-error",e=>({severity:"error",code:"ref-error",path:e.field,message:e.message})),m(g.calc,"calc-error",e=>({severity:"error",code:"calc-error",path:e.field,message:e.message})),m(g.expression,"expression-error",e=>({severity:"error",code:"expression-error",path:e.field,message:e.message})),m(g.actionRef,"action-ref-error",e=>({severity:"error",code:"action-ref-error",path:e.field,message:e.message})),m(g.itemsEventMap,"items-event-map-error",e=>({severity:"error",code:"items-event-map-error",path:e.field,message:e.message})),d("deprecated-feature")&&
|
|
3
|
-
${o} (${
|
|
4
|
-
`),
|
|
1
|
+
export const __rspack_esm_id=3223;export const __rspack_esm_ids=[3223];export const __webpack_modules__={85(e,r,t){let{checkConfig:o,checkConfigDeprecatedFeatures:i,lintConfig:s,lintRuleCodes:n}=t(38890),a=["schema-error","ref-error","calc-error","expression-error","action-ref-error","items-event-map-error","deprecated-feature"],c={error:0,warning:1,info:2},p=async(e,{type:r="app",only:t=null,ignore:p=null,checkAutomation:l=!1}={})=>{let f=[...a,...n],u=[...t||[],...p||[]].filter(e=>!f.includes(e));if(u.length>0)throw Error(`Unknown rule code(s): ${u.join(", ")}
|
|
2
|
+
Valid codes: ${f.join(", ")}`);let d=e=>(!t||t.includes(e))&&(!p||!p.includes(e)),h=[],g=o(e,{checkCalc:!0,checkExpressions:!0,checkActionRefs:!0,checkItemsEventMaps:!0,checkAutomation:l,maxLinkFindings:1e4}),m=(e,r,t)=>{d(r)&&(e||[]).forEach(e=>h.push({hint:null,...t(e)}))};m(g.schema,"schema-error",e=>({severity:"error",code:"schema-error",path:e.instancePath||e.dataPath||"/",message:e.message,hint:e.params?.pattern?`pattern: ${e.params.pattern}`:null})),m(g.ref,"ref-error",e=>({severity:"error",code:"ref-error",path:e.field,message:e.message})),m(g.calc,"calc-error",e=>({severity:"error",code:"calc-error",path:e.field,message:e.message})),m(g.expression,"expression-error",e=>({severity:"error",code:"expression-error",path:e.field,message:e.message})),m(g.actionRef,"action-ref-error",e=>({severity:"error",code:"action-ref-error",path:e.field,message:e.message})),m(g.itemsEventMap,"items-event-map-error",e=>({severity:"error",code:"items-event-map-error",path:e.field,message:e.message})),d("deprecated-feature")&&i(e).forEach(e=>h.push({severity:"warning",code:"deprecated-feature",path:e.id,message:e.data,hint:null}));let y=!g.valid;if(!y){let o=t?t.filter(e=>n.includes(e)):null,i=p?p.filter(e=>n.includes(e)):null;(!o||o.length>0)&&h.push(...s(e,{configType:r,only:o,ignore:i}))}h.sort((e,r)=>c[e.severity]-c[r.severity]);let v={errors:h.filter(e=>"error"===e.severity).length,warnings:h.filter(e=>"warning"===e.severity).length,infos:h.filter(e=>"info"===e.severity).length};return{ok:0===v.errors,valid:g.valid,lintSkipped:y,summary:v,issues:h}},l=[["error","Errors"],["warning","Warnings"],["info","Info"]];r.L3=a,r.Q$=p,r.Lf=(e,{strict:r=!1}={})=>e.summary.errors>0||r&&e.summary.warnings>0?1:0,r.EA=e=>{let r=[];r.push("\nConfig Doctor Report");let{target:t}=e;if(t){let e="file"===t.source?`${t.type} config: ${t.path}`:`${t.type}: ${t.id}${t.composed?" (composed)":""}`;r.push(e)}if(r.push("─".repeat(60)),0===e.issues.length)return r.push("✓ No issues found"),r.join("\n");l.forEach(([t,o])=>{let i=e.issues.filter(e=>e.severity===t);0!==i.length&&(r.push(`
|
|
3
|
+
${o} (${i.length})
|
|
4
|
+
`),i.forEach((e,t)=>{r.push(` ${t+1}. [${e.code}] ${e.path||""}`),r.push(` ${e.message}`),e.hint&&r.push(` ↳ ${e.hint}`)}))}),e.lintSkipped&&r.push("\n ⚠ Lint rules skipped — fix schema/reference errors first"),r.push("\n"+"─".repeat(60));let{errors:o,warnings:i,infos:s}=e.summary,n=[];return o>0&&n.push(`✗ ${o} error(s)`),i>0&&n.push(`⚠ ${i} warning(s)`),s>0&&n.push(`ℹ ${s} info`),r.push(n.join(" ")),r.join("\n")}},63322(e,r,t){t.r(r),t.d(r,{BUILTIN_ISSUE_CODES:()=>a.L3,buildConfigDoctorReport:()=>a.Q$,getDoctorExitCode:()=>a.Lf,loadConfigForDoctor:()=>u,parseCodesOption:()=>l,renderConfigDoctorReport:()=>a.EA,runConfigDoctor:()=>d});var o,i,s=t(99436),n=t(79896),a=t(85),c=t(56493),p=t(1757),l=e=>"string"==typeof e&&e?e.split(",").map(e=>e.trim()).filter(Boolean):null,f=(e,r="The fetched record has no config")=>{if(!e)throw Error(r);return"string"==typeof e?JSON.parse(e):e},u=(o=s(function*(e,r,{composed:t=!1}={}){if(n.existsSync(r))return{config:JSON.parse(n.readFileSync(r,"utf-8")),target:{type:e,source:"file",path:r}};var o=(0,c.requireAuth)();if("app"===e){var i=yield o.application({id:r,composed:t});if(!i)throw Error(`Application not found: ${r}`);return{config:f(i.config),target:{type:e,source:"remote",id:r,composed:t}}}var s=yield o.module({id:r});if(!s)throw Error(`Module not found: ${r}`);var a=(0,p.z)(s)?(0,p.f)(s,r,"Source config"):void 0;return{config:f(s.config,a),target:{type:e,source:"remote",id:r}}}),function(e,r){return o.apply(this,arguments)}),d=(i=s(function*(e,r,t){var o=l(t.only),i=l(t.ignore),s=yield u(e,r,{composed:!!t.composed}),n=s.config,c=s.target,p=yield(0,a.Q$)(n,{type:e,only:o,ignore:i,checkAutomation:!!t.validateAutomation});return p.target=c,{report:p,exitCode:(0,a.Lf)(p,{strict:!!t.strict})}}),function(e,r,t){return i.apply(this,arguments)})}};
|
package/lib/3774.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const __rspack_esm_id=3774;export const __rspack_esm_ids=[3774];export const __webpack_modules__={85949(e,t,r){r.a(e,async function(e,i){try{r.r(t),r.d(t,{__test__:()=>th,register:()=>ty});var n,a,s,o,l,d,p,c,u,f,m,y,h,v,b,w,x,_,g,j,P,k,E,S,$,A,I,C,O,N,T,R=r(68832),D=r(99436),F=r(44668),L=r(5018),B=r(63315),Y=r(30409),U=r(40906),q=r(59410),z=r(2235),K=r(46773),M=r(80004),V=r(58135),G=r(11978),J=r(79491),Z=r(51455),W=r(77598),H=r(76760),X=r(84867),Q=r(54452),ee=r(98009),et=r(3540),er=e([J]);function ei(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(ei=function(){return!!e})()}J=(er.then?(await er)():er)[0];var en=z.default||z,ea=M.default||M,es={"bricks.ts":{kind:"brick",namespace:"bricks",varPrefix:"b",idType:"brick",idPrefix:"BRICK_",typename:"Brick"},"generators.ts":{kind:"generator",namespace:"generators",varPrefix:"g",idType:"generator",idPrefix:"GENERATOR_",typename:"Generator"},"canvases.ts":{kind:"canvas",namespace:"canvases",varPrefix:"c",idType:"canvas",idPrefix:"CANVAS_",typename:"Canvas"},"data.ts":{kind:"data",namespace:"data",varPrefix:"d",idType:"data",idPrefix:"PROPERTY_BANK_DATA_NODE_",typename:"Data"},"animations.ts":{kind:"animation",namespace:"animations",varPrefix:"a",idType:"animation",idPrefix:"ANIMATION_",typename:"Animation"}},eo=function(e){function t(e,r,i,n=!1){var a,s,o;return L(this,t),s=t,o=[r],s=Y(s),(a=B(this,ei()?Reflect.construct(s,o||[],Y(this).constructor):s.apply(this,o))).name="EntryEditingError",a.code=e,a.details=i,a.isMcpError=n,a}return U(t,e),F(t)}(q(Error)),el=(e,t)=>{if(H.isAbsolute(t))throw new eo("invalid_file","File must be project-relative",{file:t});var r=H.resolve(e,t),i=H.relative(e,r);if(i.startsWith("..")||H.isAbsolute(i))throw new eo("invalid_file","File must stay inside the project directory",{file:t});return r},ed=(e,t)=>{try{return(0,K.parse)(e,{sourceType:"module",plugins:["typescript","topLevelAwait"],errorRecovery:!1})}catch(e){throw new eo("parse_failed",`Cannot parse ${t} as TypeScript: ${e.message}. Edit this file directly.`,{file:t},!0)}},ep=(n=D(function*(e,t){var r=yield(0,ee.LJ)(e,t);if(!r)throw new eo("invalid_file","File must stay inside the project directory",{file:(0,ee.RI)(e,t)});var i=yield(0,Z.readFile)(r,"utf8"),n=(0,ee.RI)(e,t);return{source:i,ast:ed(i,n),projectDir:e,absPath:t,ioPath:r,relPath:n,kind:(e=>{var t=H.basename(e),r=es[t];if(!r)throw new eo("unsupported_file",`Unsupported entry file: ${t}`,{file:e,expected:Object.keys(es)});return r})(t)}}),function(e,t){return n.apply(this,arguments)}),ec=(a=D(function*(e,t){var r=yield(0,ee.z5)(e,t);if(!r)throw new eo("invalid_file","File must stay inside the project directory",{file:(0,ee.RI)(e,t)});return r}),function(e,t){return a.apply(this,arguments)}),eu=(e,t)=>{var r=(0,ee.Zj)(e.ast);if(t.entry){var i=r.find(e=>e.name===t.entry);if(i)return i;var n=r.filter(e=>e.alias===t.entry);if(1===n.length)return n[0];if(n.length>1)throw new eo("ambiguous_reference",`Alias is ambiguous: ${t.entry}`,{file:e.relPath,entry:t.entry,matches:n.map(e=>e.name)});throw new eo("entry_not_found",`Entry not found (by name or alias): ${t.entry}`,{file:e.relPath,entry:t.entry})}if(t.id){var a=r.find(e=>e.id===t.id);if(!a)throw new eo("entry_not_found",`Entry id not found: ${t.id}`,{file:e.relPath,id:t.id});return a}throw new eo("missing_target","Provide entry or id")},ef=e=>e.split(H.sep).find(e=>/^subspace-\d+$/.test(e))||"unknown-subspace",em=e=>{var t=e.split(H.sep),r=t.findIndex(e=>/^subspace-\d+$/.test(e));if(r<0)throw new eo("invalid_file","Entry file must be inside subspaces/subspace-N",{file:e});return t.slice(0,r+1).join(H.sep)},ey=(s=D(function*(e){var t=H.join(e,"subspaces");return(yield(0,Z.readdir)(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&/^subspace-\d+$/.test(e.name)).map(e=>H.join(t,e.name)).sort()}),function(e){return s.apply(this,arguments)}),eh=(o=D(function*(e){var t=Object.keys(es),r=yield(0,Z.readdir)(e,{withFileTypes:!0}).catch(()=>[]),i=new Set(r.filter(e=>e.isFile()).map(e=>e.name));return t.filter(e=>i.has(e)).map(t=>H.join(e,t))}),function(e){return o.apply(this,arguments)}),ev=(l=D(function*(e){var t=yield ey(e);return(yield Promise.all(t.map(eh))).flat()}),function(e){return l.apply(this,arguments)}),eb=(d=D(function*(e,t){if(t.file)return el(e,t.file);if(!t.id)throw new eo("missing_file","Provide file, or provide id for global lookup");for(var r of yield ev(e)){var i=yield ep(e,r);if((0,ee.Zj)(i.ast).find(e=>e.id===t.id))return r}throw new eo("entry_not_found",`Entry id not found: ${t.id}`,{id:t.id})}),function(e,t){return d.apply(this,arguments)}),ew=(p=D(function*(e,t){var r=yield eb(e,t),i=yield ep(e,r),n=eu(i,t),a=((e,t)=>{if(!e.object)throw new eo("fallback_recommended",`Entry ${e.name} in ${t} is not a top-level exported object literal. Edit this file directly for this one.`,{file:t,entry:e.name,check:"top-level export const object literal"});return e.object})(n,i.relPath);return{parsed:i,entry:n,object:a}}),function(e,t){return p.apply(this,arguments)}),ex=(e,t)=>V.callExpression(V.identifier("makeId"),t?[V.stringLiteral(e),V.stringLiteral(t)]:[V.stringLiteral(e)]),e_=e=>{var t=[];for(var r of e.split(".").filter(Boolean))for(var i=/([^\[\]]+)|\[(\d+)\]/g,n=void 0;n=i.exec(r);)n[1]&&t.push({key:n[1]}),n[2]&&t.push({index:Number(n[2])});if(0===t.length)throw new eo("invalid_path",`Invalid path: ${e}`,{path:e});return t},eg=e=>V.isTSAsExpression(e)||V.isTSSatisfiesExpression(e)||V.isTSNonNullExpression(e)||V.isParenthesizedExpression(e)?eg(e.expression):e,ej=(e,t)=>{var r=eg(e);if(!V.isObjectExpression(r))throw new eo("fallback_recommended",`Target path ${t} is not an object literal. Edit this file directly for this one.`,{path:t,expected:"object literal",actual:r.type});return r},eP=(e,t)=>{var r=eg(e);if(!V.isArrayExpression(r))throw new eo("fallback_recommended",`Target path ${t} is not an array literal. Edit this file directly for this one.`,{path:t,expected:"array literal",actual:r.type});return r},ek=e=>"array"==("index"in e?"array":"object")?V.arrayExpression([]):V.objectExpression([]),eE=(c=D(function*(e,t,r,i){for(var n=e_(t),a=e,s=0;s<n.length;s+=1){var o=n[s],l=s===n.length-1;if("key"in o){var d=ej(a,t);if(l)return void(0,ee.HJ)(d,o.key,(yield eF(r,i)));var p=n[s+1],c=(0,ee.bf)(d,o.key);c||(c=V.objectProperty((0,ee.zu)(o.key),ek(p)),d.properties.push(c)),a=c.value;continue}var u=eP(a,t);if(o.index<0||o.index>u.elements.length)throw new eo("invalid_path",`Array index out of range for ${t}`,{path:t,index:o.index});if(l){u.elements[o.index]=yield eF(r,i);return}u.elements[o.index]||(u.elements[o.index]=ek(n[s+1])),a=u.elements[o.index]}}),function(e,t,r,i){return c.apply(this,arguments)}),eS=(e,t)=>{for(var r=e_(t),i=e,n=0;n<r.length;n+=1){var a=r[n],s=n===r.length-1;if("key"in a){var o=ej(i,t);if(s)return void(0,ee.jc)(o,a.key);var l=(0,ee.bf)(o,a.key);if(!l)return;i=l.value;continue}var d=eP(i,t);if(a.index<0||a.index>=d.elements.length)return;if(s)return void d.elements.splice(a.index,1);var p=d.elements[a.index];if(!p)return;i=p}},e$=(e,t)=>{var r=(0,ee.bf)(e,"switches");if(!r)throw new eo("fallback_recommended","Entry has no switches array",{path:"switches"});var i=eP(r.value,"switches"),n="number"==typeof t?t:i.elements.findIndex(e=>V.isObjectExpression(e)&&(0,ee.JJ)(e,"id")===t);if(n<0||n>=i.elements.length)throw new eo("entry_not_found",`Switch not found: ${t}`,{switch:t});var a=i.elements[n];if(!V.isObjectExpression(a))throw new eo("fallback_recommended",`Switch ${String(t)} is not an object literal. Edit this file directly for this one.`,{switch:t});return a},eA=(e,t)=>{var r=t.replace(/\.[tj]sx?$/,""),i=H.relative(H.dirname(e),r).replace(/\\/g,"/");return i.startsWith(".")||(i=`./${i}`),i},eI=(e,t,r)=>{for(var i of e.ast.program.body)if(V.isImportDeclaration(i)&&i.source.value===t){var n=i.specifiers.find(e=>V.isImportDefaultSpecifier(e));if(n)return n.local.name}var a=(0,ee.R0)(e.ast,r),s=V.importDeclaration([V.importDefaultSpecifier(V.identifier(a))],V.stringLiteral(t));return(0,ee.Pb)(e.ast,s),a},eC=e=>{(0,ee.Kx)(e.parsed.ast,"type",e.typeImports),(0,ee.Kx)(e.parsed.ast,"value",e.valueImports)},eO=(u=D(function*(e,t,r){if(null==r||""===r)return t;if("number"==typeof r)return H.join(e,"subspaces",`subspace-${r}`);var i=String(r);if(/^\d+$/.test(i))return H.join(e,"subspaces",`subspace-${i}`);if(/^subspace-\d+$/.test(i))return H.join(e,"subspaces",i);if(i.includes("/"))return el(e,i);var n,a=yield ey(e),s=function*(){var t=H.join(o,"index.ts"),r=yield(0,Z.readFile)(t,"utf8").catch(()=>"");if(!r)return 0;var n=ed(r,(0,ee.RI)(e,t)),a=!1;if(ea(n,{ObjectProperty(e){"id"===(0,ee.Gp)(e.node.key)&&V.isStringLiteral(e.node.value)&&e.node.value.value===i&&(a=!0,e.stop())}}),a)return{v:o}};for(var o of a)if(n=yield*s(),0!==n&&n)return n.v;throw new eo("reference_not_found",`Subspace not found: ${i}`,{subspace:i})}),function(e,t,r){return u.apply(this,arguments)}),eN=(f=D(function*(e,t){var r,i,n=em(e.parsed.absPath),a=yield eO(e.projectDir,n,t),s=H.basename(a),o=/^subspace-(\d+)$/.exec(s);if(!o)throw new eo("invalid_subspace",`Not a subspace directory: ${s}`,{subspace:t});var l=H.join(a,"index.ts"),d=yield(0,Z.readFile)(l,"utf8").catch(()=>null);if(null==d)throw new eo("reference_not_found",`Subspace not found: ${t}`,{subspace:t});var p=(r=ed(d,(0,ee.RI)(e.projectDir,l)),ea(r,{ObjectProperty(e){if("id"===(0,ee.Gp)(e.node.key)){var t=e.node.value;V.isStringLiteral(t)&&t.value.startsWith("SUBSPACE_")&&(i=t.value,e.stop())}}}),i);if(!p)throw new eo("invalid_subspace",`Subspace index has no SUBSPACE_ id: ${s}/index.ts`,{subspace:t});return{id:p,index:Number(o[1]),label:s,indexPath:l,isCurrent:H.resolve(a)===H.resolve(n)}}),function(e,t){return f.apply(this,arguments)}),eT=(m=D(function*(e,t){var r=yield eN(e,t);if(r.isCurrent)return e.references.push({input:t,id:r.id,sameFile:!1,display:`'${r.id}'`,targetAbsPath:r.indexPath}),{resolved:r,expression:V.stringLiteral(r.id)};var i=eI(e.parsed,`../${r.label}`,`subspace${r.index}`);return e.references.push({input:t,id:r.id,sameFile:!1,display:`() => ${i}`,targetAbsPath:r.indexPath}),{resolved:r,expression:V.arrowFunctionExpression([],V.identifier(i))}}),function(e,t){return m.apply(this,arguments)}),eR=(y=D(function*(e,t,r,i){var n=em(t),a=yield eO(e,n,i),s=yield eh(a),o=[];for(var l of s){var d=yield ep(e,l),p=d.kind;for(var c of(0,ee.Zj)(d.ast))if(c.name===r||c.id===r||c.alias===r){var u=H.resolve(l)===H.resolve(t),f=H.basename(a);o.push({input:r,id:c.id,alias:c.alias,varName:c.name,namespace:p.namespace,display:`${p.namespace}.${c.name}`,targetAbsPath:l,sameFile:u,subspaceLabel:f,importSource:u?void 0:eA(t,l)})}}if(0===o.length)throw new eo("reference_not_found",`Reference not found: ${r}`,{ref:r,subspace:i??H.basename(n)});if(o.length>1)throw new eo("ambiguous_reference",`Reference is ambiguous: ${r}`,{ref:r,matches:o.map(t=>({file:(0,ee.RI)(e,t.targetAbsPath),entry:t.varName,id:t.id,alias:t.alias}))});return o[0]}),function(e,t,r,i){return y.apply(this,arguments)}),eD=(h=D(function*(e,t,r){var i=yield eR(t.projectDir,t.parsed.absPath,e,r);if(i.sameFile)return t.references.push(i),V.identifier(i.varName);var n=em(t.parsed.absPath),a=em(i.targetAbsPath),s=i.subspaceLabel.replace(/[^a-zA-Z0-9_$]/g,""),o=n===a?i.namespace:`${s}${i.namespace[0].toUpperCase()}${i.namespace.slice(1)}`,l=((e,t,r,i)=>{for(var n of e.ast.program.body)if(V.isImportDeclaration(n)&&n.source.value===r){var a=n.specifiers.find(V.isImportNamespaceSpecifier);if(a)return a.local.name}var s=(0,ee.R0)(e.ast,i),o=V.importDeclaration([V.importNamespaceSpecifier(V.identifier(s))],V.stringLiteral(r));return(0,ee.Pb)(e.ast,o),s})(t.parsed,i.namespace,i.importSource,o);return i.importLocal=l,t.references.push({...i,display:`${l}.${i.varName}`,importLocal:l}),V.memberExpression(V.identifier(l),V.identifier(i.varName))}),function(e,t,r){return h.apply(this,arguments)}),eF=(v=D(function*(e,t){if((0,ee.u4)(e)&&"string"==typeof e.expr&&1===Object.keys(e).length){var r=e.expr;try{return(0,K.parseExpression)(r,{plugins:["typescript"]})}catch(e){throw new eo("invalid_expr",`Invalid TypeScript expression: ${e.message}`,{expr:r})}}if((0,ee.u4)(e)&&"string"==typeof e.link){t.valueImports.add("linkData");var i=yield eD(e.link,t,e.subspace);return V.callExpression(V.identifier("linkData"),[V.arrowFunctionExpression([],i)])}if((0,ee.u4)(e)&&"string"==typeof e.ref){var n=yield eD(e.ref,t,e.subspace);return V.arrowFunctionExpression([],n)}if(Array.isArray(e))return V.arrayExpression((yield Promise.all(e.map(e=>eF(e,t)))));if((0,ee.u4)(e)){var a,s=yield Promise.all(Object.entries(e).map((a=D(function*([e,r]){return V.objectProperty((0,ee.zu)(e),(yield eF(r,t)))}),function(e){return a.apply(this,arguments)})));return V.objectExpression(s)}return void 0===e?V.identifier("undefined"):V.valueToNode(e)}),function(e,t){return v.apply(this,arguments)}),eL=e=>e.map(e=>({input:e.input,id:e.id,alias:e.alias,resolved:e.importLocal?`${e.importLocal}.${e.varName}`:e.sameFile?e.varName:e.display,file:e.targetAbsPath})),eB=(b=D(function*(e){var t=en(e.ast,{comments:!0},e.source).code,r=yield(0,J.format)(e.absPath,t,ee.Hn);if(r.errors.length>0)throw new eo("format_failed",`oxfmt failed for ${e.relPath}`,{file:e.relPath,errors:r.errors});return r.code}),function(e){return b.apply(this,arguments)}),eY=(w=D(function*(e,t){var r=yield eB(t);return ed(r,t.relPath),yield e.writeFile(t.ioPath??(yield ec(t.projectDir,t.absPath)),r),r}),function(e,t){return w.apply(this,arguments)}),eU=(e,t)=>{if(e){var r=ef(e.absPath);return`${t?.name||"entry"} (${e.kind.kind}, ${r})`}},eq=(x=D(function*(e,t,r,i){var n={ts:new Date().toISOString(),tool:t,op:r?.op||(r?.set?"set":r?.unset?"unset":t),target:{file:r?.file,entry:r?.entry,id:r?.id},provenance:(0,et.S)()};try{var a=yield(0,Q.G$)(e,r.verify,i),s={...n,...a};return yield(0,et.a)(e,s).catch(e=>{s.auditError=e.message}),s}catch(i){var o=i instanceof eo?i:new eo("error",i.message||String(i),void 0,!0),l="fallback_recommended"===o.code?"fallback_recommended":"error",d={...n,outcome:l,input:r,error:{code:o.code,message:o.message,details:o.details},summary:"fallback_recommended"===l?`${t} could not safely edit this standard path; edit the file directly`:`${t} failed: ${o.message}`,isError:o.isMcpError||"error"===l};return yield(0,et.a)(e,d).catch(e=>{d.auditError=e.message}),d}}),function(e,t,r,i){return x.apply(this,arguments)}),ez=(_=D(function*(e,t){var r;return eq(e,"edit_entry",t,(r=D(function*(r){var i=yield ew(e,t),n=i.parsed,a=i.entry,s=i.object,o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=null==t.switch?s:e$(s,t.switch);for(var d of Object.entries(t.set||{})){var p=R(d,2),c=p[0],u=p[1];yield eE(l,c,u,o)}for(var f of[...t.unset||[]].sort((e,t)=>{for(var r=e_(e).map(e=>"index"in e?e.index:-1),i=e_(t).map(e=>"index"in e?e.index:-1),n=0;n<Math.min(r.length,i.length);n+=1)if(r[n]!==i[n])return i[n]-r[n];return i.length-r.length}))eS(l,f);eC(o),yield eY(r,n);var m=eU(n,a);return{file:n.relPath,entry:a.name,id:a.id,change:{set:t.set||{},unset:t.unset||[],references:eL(o.references)},summary:`edited ${m}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return _.apply(this,arguments)}),eK=e=>{switch(e){case"IfStatement":return"an if statement";case"ForStatement":case"ForOfStatement":case"ForInStatement":return"a for loop";case"WhileStatement":case"DoWhileStatement":return"a while loop";case"SwitchStatement":return"a switch statement";case"TryStatement":return"a try/catch block";case"FunctionDeclaration":return"a function declaration";case"ReturnStatement":return"a return before the final statement";default:return`a ${e}`}},eM=(e,t)=>{for(var r=0;r<e.length;r+=1){var i=e[r],n=r===e.length-1;if("ExpressionStatement"===i.type){var a=eV(i.expression);if(a)return a;continue}if("VariableDeclaration"===i.type){for(var s of i.declarations)if("Identifier"!==s.id.type||!s.init)return"a destructuring or uninitialized declaration";continue}if(t&&n&&"ReturnStatement"===i.type){var o=i.argument?eV(i.argument):null;if(o)return o;continue}return eK(i.type)}return null},eV=e=>{if(e?.type!=="CallExpression"||e.arguments?.length||e.callee?.type!=="ArrowFunctionExpression"&&e.callee?.type!=="FunctionExpression")return null;var t=e.callee.body;return t?.type==="BlockStatement"?eM(t.body,!0):eV(t)},eG=(g=D(function*(e,t){if(e?.expr)return eF(e,t);var r,i=(e=>{if(!(0,ee.u4)(e)||!(0,ee.u4)(e.action))return e;var t=e.action,r={handler:e.handler,name:t.name??t.__actionName,waitAsync:e.waitAsync};if(t.cast&&(r.cast=t.cast),Array.isArray(t.params))for(var i of(r.params={},t.params)){if(!(0,ee.u4)(i)||"string"!=typeof i.input)throw new eo("invalid_action",'Compiled action params entries require { input: "name", value }',{param:i});r.params[i.input]=i.value}if(Array.isArray(t.dataParams))for(var n of(r.dataParams={},t.dataParams)){var a=(0,ee.u4)(n?.input)?n.input.ref:n?.input;if("string"!=typeof a||!a)throw new eo("invalid_action","Compiled action dataParams entries require { input: dataRef, value }",{param:n});r.dataParams[a]=n.value}return r})(e),n=i?.name;if(!n)throw new eo("invalid_action","Action requires name");if("PROPERTY_BANK_EXPRESSION"===n&&(0,ee.u4)(i.params)){var a=i.params.expression;"string"==typeof a&&(e=>{try{t=(0,G.qg)(e,{ecmaVersion:2020})}catch(t){throw new eo("invalid_action",`PROPERTY_BANK_EXPRESSION does not parse: ${t.message}`,{expression:e})}var t,r=eM(t.body,!1);if(r)throw new eo("invalid_action",`PROPERTY_BANK_EXPRESSION cannot evaluate ${r}: the runtime folds the expression into a single expression (expression statements, simple const/let declarations, and a final return inside an IIFE only). Use ternaries instead of statements, or move branching logic to a DataCalculationScript.`,{expression:e})})(a)}var s="System",o=i.cast;if("system"===i.handler||null==i.handler)r=V.stringLiteral("system"),o||=`SystemAction${n.toLowerCase().split("_").filter(Boolean).map(e=>`${e[0].toUpperCase()}${e.slice(1)}`).join("")}`;else if((0,ee.u4)(i.handler)&&"string"==typeof i.handler.ref){var l=yield eR(t.projectDir,t.parsed.absPath,i.handler.ref,i.handler.subspace);if("bricks"!==l.namespace&&"generators"!==l.namespace)throw new eo("invalid_action",`Action handler must be a brick or generator, got ${l.namespace}: ${i.handler.ref}`,{handler:i.handler});s="bricks"===l.namespace?"Brick":"Generator";var d=yield eD(i.handler.ref,t,i.handler.subspace);r=V.arrowFunctionExpression([],d)}else if((0,ee.u4)(i.handler)&&null!=i.handler.subspace)r=(yield eT(t,i.handler.subspace)).expression,s="Subspace";else throw new eo("invalid_action","Unsupported action handler",{handler:i.handler});var p=[V.objectProperty(V.identifier("__actionName"),V.stringLiteral(n)),V.objectProperty(V.identifier("parent"),V.stringLiteral(s)),V.objectProperty(V.identifier("name"),V.stringLiteral(n))];if(i.params){var c,u=yield Promise.all(Object.entries(i.params).map((c=D(function*([e,r]){return V.objectExpression([V.objectProperty(V.identifier("input"),V.stringLiteral(e)),V.objectProperty(V.identifier("value"),(yield eF(r,t)))])}),function(e){return c.apply(this,arguments)})));p.push(V.objectProperty(V.identifier("params"),V.arrayExpression(u)))}if(i.dataParams){var f,m=yield Promise.all(Object.entries(i.dataParams).map((f=D(function*([e,r]){var i=yield eD(e,t);return V.objectExpression([V.objectProperty(V.identifier("input"),V.arrowFunctionExpression([],i)),V.objectProperty(V.identifier("value"),(yield eF(r,t)))])}),function(e){return f.apply(this,arguments)})));p.push(V.objectProperty(V.identifier("dataParams"),V.arrayExpression(m)))}var y=V.objectExpression(p);return o&&(t.typeImports.add(o),y=V.tsAsExpression(y,V.tsTypeReference(V.identifier(o)))),V.objectExpression([V.objectProperty(V.identifier("handler"),r),V.objectProperty(V.identifier("action"),y),V.objectProperty(V.identifier("waitAsync"),V.booleanLiteral(!!i.waitAsync))])}),function(e,t){return g.apply(this,arguments)}),eJ=(e,t,r)=>{var i=(0,ee.bf)(e,t);return i||(i=V.objectProperty((0,ee.zu)(t),V.objectExpression([])),e.properties.push(i)),ej(i.value,r)},eZ=(e,t,r)=>{var i=(0,ee.bf)(e,t);return i||(i=V.objectProperty((0,ee.zu)(t),V.arrayExpression([])),e.properties.push(i)),eP(i.value,r)},eW=(j=D(function*(e,t){var r;return eq(e,"edit_events",t,(r=D(function*(r){var i=yield ew(e,t),n=i.parsed,a=i.entry,s=i.object,o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=null==t.switch?s:e$(s,t.switch),d=t.op;if("clear"===d||"remove"===d||"move"===d){var p=(0,ee.bf)(l,"events"),c=p?ej(p.value,"events"):null,u=c?(0,ee.bf)(c,t.event):null,f=u?eP(u.value,`events.${t.event}`):null;if("clear"===d)c&&(0,ee.jc)(c,t.event);else if("move"===d){if(null==t.index)throw new eo("invalid_index","move requires index");if(!f||t.index<0||t.index>=f.elements.length)throw new eo("invalid_index","move index out of range",{index:t.index});var m=Number(t.to);if(!Number.isFinite(m)||m<0||m>=f.elements.length)throw new eo("invalid_index","move requires valid to index",{to:t.to});var y=f.elements.splice(t.index,1),h=R(y,1)[0];f.elements.splice(m,0,h)}else{if(null==t.index)throw new eo("invalid_index","remove requires index");if(!f||t.index<0||t.index>=f.elements.length)throw new eo("invalid_index","remove index out of range",{index:t.index});f.elements.splice(t.index,1),0===f.elements.length&&c&&(0,ee.jc)(c,t.event)}}else if("add"===d||"replace"===d){var v=yield eG(t.action,o),b=eJ(l,"events","events"),w=eZ(b,t.event,`events.${t.event}`),x=t.index??w.elements.length;if("replace"===d){if(x<0||x>=w.elements.length)throw new eo("invalid_index","replace index out of range",{index:x});w.elements[x]=v}else{if(x<0||x>w.elements.length)throw new eo("invalid_index","add index out of range",{index:x});w.elements.splice(x,0,v)}}else throw new eo("invalid_op",`Unsupported edit_events op: ${d}`);return eC(o),yield eY(r,n),{file:n.relPath,entry:a.name,id:a.id,change:{event:t.event,op:d,index:t.index,references:eL(o.references)},summary:`${d} event ${t.event} on ${eU(n,a)}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return j.apply(this,arguments)}),eH=e=>{if((0,ee.u4)(e)&&"string"==typeof e.expr)return e;if(!(0,ee.u4)(e))throw new eo("invalid_item","Canvas item requires frame { x, y, width, height }");for(var t of["x","y","width","height"])if("number"!=typeof e[t])throw new eo("invalid_item",`Canvas item frame requires numeric ${t}`,{frame:e});return e},eX=(P=D(function*(e,t,r){if(!e?.ref&&e?.subspace==null)throw new eo("invalid_item","Canvas item requires ref (brick) or subspace (embed)");var i,n=eH(e.frame??r);if(e.ref){var a=yield eD(e.ref,t,e.subspace);i=V.arrowFunctionExpression([],a)}else{var s=yield eT(t,e.subspace),o=s.resolved,l=s.expression;if(o.isCurrent)throw new eo("invalid_item","A subspace cannot embed itself",{subspace:e.subspace});i=l}return V.objectExpression([V.objectProperty(V.identifier("item"),i),V.objectProperty(V.identifier("frame"),(yield eF(n,t))),...null==e.animations?[]:[V.objectProperty(V.identifier("animations"),(yield eF(e.animations,t)))],...null==e.hidden?[]:[V.objectProperty(V.identifier("hidden"),V.booleanLiteral(!!e.hidden))]])}),function(e,t,r){return P.apply(this,arguments)}),eQ=(k=D(function*(e,t){var r;return eq(e,"edit_canvas_items",t,(r=D(function*(r){var i=yield ew(e,t),n=i.parsed,a=i.entry,s=i.object;if("canvas"!==n.kind.kind)throw new eo("invalid_file","edit_canvas_items only edits canvases.ts entries",{file:n.relPath});var o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=eZ(s,"items","items"),d=t.op;if("add"===d||"replace"===d){var p=yield eX(t.item,o,t.frame),c=t.index??l.elements.length;if("replace"===d){if(c<0||c>=l.elements.length)throw new eo("invalid_index","replace index out of range",{index:c});l.elements[c]=p}else{if(c<0||c>l.elements.length)throw new eo("invalid_index","add index out of range",{index:c});l.elements.splice(c,0,p)}}else if("remove"===d){if(null==t.index)throw new eo("invalid_index","remove requires index");if(t.index<0||t.index>=l.elements.length)throw new eo("invalid_index","remove index out of range",{index:t.index});l.elements.splice(t.index,1)}else if("move"===d){if(null==t.index)throw new eo("invalid_index","move requires index");if(!t.frame)throw new eo("invalid_item","move requires frame");if(t.index<0||t.index>=l.elements.length)throw new eo("invalid_index","move index out of range",{index:t.index});var u=l.elements[t.index];if(!V.isObjectExpression(u))throw new eo("fallback_recommended","Canvas item is not an object literal",{index:t.index});(0,ee.HJ)(u,"frame",(yield eF(eH(t.frame),o)))}else throw new eo("invalid_op",`Unsupported edit_canvas_items op: ${d}`);return eC(o),yield eY(r,n),{file:n.relPath,entry:a.name,id:a.id,change:{op:d,index:t.index,references:eL(o.references)},summary:`${d} canvas item on ${eU(n,a)}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return k.apply(this,arguments)}),e0=(E=D(function*(e,t){var r=(e=>{switch(e?.__typename){case"SwitchCondInnerStateCurrentCanvas":return{type:"inner_state",key:"current_canvas",value:e.value,subspace:e.subspace};case"SwitchCondInnerStateOutlet":return{type:"inner_state",outlet:e.outlet,value:e.value};case"SwitchCondData":return{type:"property_bank",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondPropertyBankByItemKey":return{type:"property_bank_by_item_key",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondItemKeyMapping":return{type:"item_key_mapping",key:e.key,value:e.value};default:return e}})(e);if(r?.expr)return eF(r,t);if(r?.type==="inner_state"&&"current_canvas"===r.key){var i=yield eD(r.value,t,r.subspace);return V.objectExpression([V.objectProperty(V.identifier("__typename"),V.stringLiteral("SwitchCondInnerStateCurrentCanvas")),V.objectProperty(V.identifier("value"),V.arrowFunctionExpression([],i))])}if(r?.type==="inner_state"){var n=r.outlet||r.key;if(!n)throw new eo("invalid_switch","Switch inner-state outlet condition requires outlet or key");return V.objectExpression([V.objectProperty(V.identifier("__typename"),V.stringLiteral("SwitchCondInnerStateOutlet")),V.objectProperty(V.identifier("outlet"),V.stringLiteral(n)),V.objectProperty(V.identifier("value"),(yield eF(r.value,t)))])}if(r?.type==="item_key_mapping"){if(!r.key)throw new eo("invalid_switch","Switch item key mapping condition requires key");return V.objectExpression([V.objectProperty(V.identifier("__typename"),V.stringLiteral("SwitchCondItemKeyMapping")),V.objectProperty(V.identifier("key"),V.stringLiteral(r.key)),V.objectProperty(V.identifier("value"),(yield eF(r.value,t)))])}var a=r?.ref||r?.data||r?.key;if(!a)throw new eo("invalid_switch","Switch condition requires data ref");var s=yield eD(a,t,r.subspace);return V.objectExpression([V.objectProperty(V.identifier("__typename"),V.stringLiteral(r?.type==="property_bank_by_item_key"?"SwitchCondPropertyBankByItemKey":"SwitchCondData")),V.objectProperty(V.identifier("data"),V.arrowFunctionExpression([],s)),V.objectProperty(V.identifier("value"),(yield eF(r.value,t)))])}),function(e,t){return E.apply(this,arguments)}),e1=new Set(["id","title","description","conds","override","property","outlets","animation","events","disabled","break"]),e4=(S=D(function*(e,t){for(var r of Object.keys(e))if(!e1.has(r))throw new eo("invalid_switch",`Unknown switch field: ${r}`,{field:r,supported:Array.from(e1)});if(void 0!==e.events)throw new eo("invalid_switch","Set switch events with edit_events using its switch parameter");if(e.id&&!/^BRICK_STATE_GROUP_[0-9a-fA-F-]{36}$/.test(e.id))throw new eo("invalid_switch","Switch id must match BRICK_STATE_GROUP_<uuid>; omit id to generate one",{id:e.id});var i,n=e.id?V.stringLiteral(e.id):ex("switch");e.id||t.valueImports.add("makeId");var a=[V.objectProperty(V.identifier("id"),n)];for(var s of(null!=e.title&&a.push(V.objectProperty(V.identifier("title"),V.stringLiteral(e.title))),null!=e.description&&a.push(V.objectProperty(V.identifier("description"),V.stringLiteral(e.description))),e.conds&&a.push(V.objectProperty(V.identifier("conds"),V.arrayExpression((yield Promise.all(e.conds.map((i=D(function*(e){return V.objectExpression([V.objectProperty(V.identifier("method"),V.stringLiteral(e.method||"==")),V.objectProperty(V.identifier("cond"),(yield e0(e.cond||e,t)))])}),function(e){return i.apply(this,arguments)}))))))),e.override&&a.push(V.objectProperty(V.identifier("override"),(yield eF(e.override,t)))),["property","outlets","animation"]))null!=e[s]&&a.push(V.objectProperty(V.identifier(s),(yield eF(e[s],t))));return null!=e.disabled&&a.push(V.objectProperty(V.identifier("disabled"),V.booleanLiteral(!!e.disabled))),null!=e.break&&a.push(V.objectProperty(V.identifier("break"),V.booleanLiteral(!!e.break))),V.objectExpression(a)}),function(e,t){return S.apply(this,arguments)}),e5=($=D(function*(e,t){var r;return eq(e,"edit_switches",t,(r=D(function*(r){var i=yield ew(e,t),n=i.parsed,a=i.entry,s=i.object,o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=eZ(s,"switches","switches"),d=t.op,p=e=>"number"==typeof e?e:e?l.elements.findIndex(t=>V.isObjectExpression(t)&&(0,ee.JJ)(t,"id")===e):-1;if("add"===d||"replace"===d){var c=yield e4(t.switch||{},o),u=null==t.index?l.elements.length:p(t.index);if("replace"===d){if(u<0||u>=l.elements.length)throw new eo("invalid_index","replace index out of range",{index:u});l.elements[u]=c}else{if(u<0||u>l.elements.length)throw new eo("invalid_index","add requires a valid switch id or index",{index:t.index});l.elements.splice(u,0,c)}}else if("remove"===d){var f=p(t.index);if(f<0||f>=l.elements.length)throw new eo("invalid_index","remove requires a valid switch id or index",{index:t.index});l.elements.splice(f,1)}else if("move"===d){var m=p(t.index);if(m<0||m>=l.elements.length)throw new eo("invalid_index","move requires a valid switch id or index",{index:t.index});var y=Number(t.to);if(!Number.isFinite(y)||y<0||y>=l.elements.length)throw new eo("invalid_index","move requires valid to index",{to:t.to});var h=l.elements.splice(m,1),v=R(h,1)[0];l.elements.splice(y,0,v)}else throw new eo("invalid_op",`Unsupported edit_switches op: ${d}`);return eC(o),yield eY(r,n),{file:n.relPath,entry:a.name,id:a.id,change:{op:d,index:t.index,references:eL(o.references)},summary:`${d} switch on ${eU(n,a)}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return $.apply(this,arguments)}),e9=(A=D(function*(e,t,r,i){var n=[V.objectProperty(V.identifier("__typename"),V.stringLiteral(e.typename)),V.objectProperty(V.identifier("id"),r)];return t.alias&&n.push(V.objectProperty(V.identifier("alias"),V.stringLiteral(t.alias))),null!=t.title&&n.push(V.objectProperty(V.identifier("title"),V.stringLiteral(t.title))),null!=t.description&&n.push(V.objectProperty(V.identifier("description"),V.stringLiteral(t.description))),"brick"===e.kind||"generator"===e.kind?(n.push(V.objectProperty(V.identifier("templateKey"),V.stringLiteral(t.templateKey||""))),n.push(V.objectProperty(V.identifier("property"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("events"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("outlets"),V.objectExpression([]))),"brick"===e.kind&&n.push(V.objectProperty(V.identifier("animation"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("switches"),V.arrayExpression([])))):"canvas"===e.kind?(n.push(V.objectProperty(V.identifier("property"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("events"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("switches"),V.arrayExpression([]))),n.push(V.objectProperty(V.identifier("items"),V.arrayExpression([])))):"data"===e.kind?(n.push(V.objectProperty(V.identifier("type"),V.stringLiteral(t.dataType||"any"))),n.push(V.objectProperty(V.identifier("schema"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("events"),V.objectExpression([]))),n.push(V.objectProperty(V.identifier("value"),V.identifier("undefined")))):"animation"===e.kind&&(n.push(V.objectProperty(V.identifier("runType"),V.stringLiteral("once"))),n.push(V.objectProperty(V.identifier("property"),V.stringLiteral("opacity"))),n.push(V.objectProperty(V.identifier("config"),(yield eF({__type:"AnimationTimingConfig",toValue:1,duration:300,easing:"",delay:0,isInteraction:!0},i))))),V.objectExpression(n)}),function(e,t,r,i){return A.apply(this,arguments)}),e8=(I=D(function*(e,t,r){var i=H.basename(t);for(var n of(yield ev(e)).filter(e=>H.basename(e)===i)){var a=yield ep(e,n);if((0,ee.Zj)(a.ast).some(e=>e.alias===r))return!0}return!1}),function(e,t,r){return I.apply(this,arguments)}),e3=(C=D(function*(e,t){var r;return eq(e,"new_entry",t,(r=D(function*(r){if(!t.file)throw new eo("missing_file","new_entry requires file");if(!t.type)throw new eo("missing_type","new_entry requires TypeScript type");var i=el(e,t.file),n=yield ep(e,i),a=new Set((0,ee.Zj)(n.ast).map(e=>e.name)),s="string"==typeof t.id?t.id:void 0,o=s||"string"!=typeof t.alias||!t.alias||(yield e8(e,i,t.alias))?void 0:t.alias,l=s?V.stringLiteral(s):ex(n.kind.idType,o),d=t.entry||((e,t,r,i)=>{var n,a=(e=>{if(!e)return null;var t=e.replace(/[^a-zA-Z0-9_$]/g,"");return t?(/^[0-9]/.test(t)&&(t=`_${t}`),t):null})(i)||(r?`${t.varPrefix}${n=r.replace(/^[A-Z_]+/g,""),`${n.substr(15,3)}${n.substr(20,1)}`}`:`${t.varPrefix}Entry`);if(!e.has(a))return a;for(var s=1;e.has(`${a}${s}`);)s+=1;return`${a}${s}`})(a,n.kind,s,t.alias||t.title),p={projectDir:e,parsed:n,references:[],typeImports:new Set([t.type]),valueImports:new Set};s||p.valueImports.add("makeId");var c=yield e9(n.kind,t,l,p),u=V.variableDeclarator(V.identifier(d),c);for(var f of(u.id.typeAnnotation=V.tsTypeAnnotation(V.tsTypeReference(V.identifier(t.type))),n.ast.program.body.push(V.exportNamedDeclaration(V.variableDeclaration("const",[u]))),Object.entries(t.set||{}))){var m=R(f,2),y=m[0],h=m[1];yield eE(c,y,h,p)}for(var v of t.events||[]){if(!(0,ee.u4)(v)||"string"!=typeof v.event||!v.event||!v.action)throw new eo("invalid_action","events entries require { event, action }",{event:v});var b=eJ(c,"events","events");eZ(b,v.event,`events.${v.event}`).elements.push((yield eG(v.action,p)))}return eC(p),yield eY(r,n),{file:n.relPath,entry:d,id:s,idExpression:s??(o?`makeId('${n.kind.idType}', '${o}')`:`makeId('${n.kind.idType}')`),change:{set:t.set||{},events:t.events||[],references:eL(p.references)},summary:`created ${d} (${n.kind.kind}, ${ef(n.absPath)})`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return C.apply(this,arguments)}),e2=(e,t)=>{var r;return V.isArrowFunctionExpression(e)&&0===e.params.length&&(r=e.body,!!r&&(V.isIdentifier(r)?r.name===t.varName:!!V.isMemberExpression(r)&&!!V.isIdentifier(r.object)&&!!V.isIdentifier(r.property)&&r.object.name===t.namespace&&r.property.name===t.varName))},e6=(e,t)=>V.isCallExpression(e)&&V.isIdentifier(e.callee,{name:"linkData"})&&e2(e.arguments[0],t),e7=(e,t)=>{if(!e)return!1;if(e2(e,t)||e6(e,t))return!0;var r=!1;return ea(V.file(V.program([V.expressionStatement(V.cloneNode(e,!0))])),{ArrowFunctionExpression(e){e2(e.node,t)&&(r=!0,e.stop())},CallExpression(e){e6(e.node,t)&&(r=!0,e.stop())}}),r},te=(e,t,r,i=[],n={})=>{if(V.isProgram(e))return void e.body.forEach((e,a)=>te(e,t,r,[...i,String(a)],n));if(V.isExportNamedDeclaration(e)&&e.declaration)return void te(e.declaration,t,r,i,n);if(V.isVariableDeclaration(e))return void e.declarations.forEach((e,a)=>te(e,t,r,[...i,String(a)],n));if(V.isVariableDeclarator(e)&&e.init)return void te(e.init,t,r,i,n);if(V.isObjectExpression(e)){for(var a=e.properties.length-1;a>=0;a-=1){var s=e.properties[a];if(V.isObjectProperty(s)){var o=(0,ee.Gp)(s.key)||`property-${a}`,l=[...i,o];if(e2(s.value,t)||e6(s.value,t)){i.includes("outlets")?(e.properties.splice(a,1),r.push({action:"drop_outlet",path:l.join(".")})):n.dataCalc&&("output"===o||"error"===o)?(s.value=V.nullLiteral(),r.push({action:"null_output",path:l.join(".")})):(s.value=V.identifier("undefined"),r.push({action:"null_link",path:l.join(".")}));continue}te(s.value,t,r,l,n)}}return}if(V.isArrayExpression(e))for(var d=i[i.length-1],p=i.includes("events")&&"events"!==d,c=n.dataCalc?["items","params","dataParams","conds","switches","inputs","outputs"]:["items","params","dataParams","conds","switches"],u=e.elements.length-1;u>=0;u-=1){var f=e.elements[u];if(f){var m=[...i,String(u)];if(e7(f,t)&&(c.includes(d)||p||e2(f,t))){e.elements.splice(u,1),r.push({action:p?"delete_event_handler":n.dataCalc&&("inputs"===d||"outputs"===d)?"remove_io_item":"remove_reference_item",path:m.join(".")});continue}te(f,t,r,m,n)}}},tt=(e,t)=>V.isObjectExpression(e)&&"DataCalculationData"===(0,ee.JJ)(e,"__typename")&&e2((0,ee.bf)(e,"data")?.value,t),tr=(e,t)=>{var r=V.isArrowFunctionExpression(e)&&0===e.params.length?e.body:e;return V.isIdentifier(r)&&t.has(r.name)},ti=(e,t)=>{var r=e.ast.program.body.indexOf(t.node);r>=0&&e.ast.program.body.splice(r,1)},tn=(O=D(function*(e,t,r){if("project"===r)return ev(e);var i=em(t),n=yield eh(i),a=H.join(i,"data-calc"),s=yield(0,Z.readdir)(a,{withFileTypes:!0}).catch(()=>[]);return[...n,...s.filter(e=>e.isFile()&&e.name.endsWith(".ts")).map(e=>H.join(a,e.name))]}),function(e,t,r){return O.apply(this,arguments)}),ta=(N=D(function*(e,t){var r;return eq(e,"remove_entry",t,(r=D(function*(r){var i,n=yield ew(e,t),a=n.parsed,s=n.entry,o={varName:s.name,namespace:a.kind.namespace,id:s.id},l=yield tn(e,a.absPath,t.scope),d=[],p=yield Promise.all(l.map((i=D(function*(t){var r=yield(0,Z.readFile)(t,"utf8");return{absPath:t,relPath:(0,ee.RI)(e,t),source:r,ast:ed(r,(0,ee.RI)(e,t)),kind:es[H.basename(t)]||a.kind}}),function(e){return i.apply(this,arguments)}))),c=function*(e){var t,r,i,n,l;(n=(e.absPath===a.absPath?(t=s.name,r=V.cloneNode(e.ast,!0),i={...e,ast:r},ti(i,eu(i,{entry:t})),i):e).ast,l=[],ea(n,{ArrowFunctionExpression(e){e2(e.node,o)&&l.push({type:"ref",loc:e.node.loc?.start})},CallExpression(e){e6(e.node,o)&&l.push({type:"link",loc:e.node.loc?.start})}}),l).forEach(t=>d.push({file:e.relPath,...t}))};for(var u of p)yield*c(u);if(t.strict&&d.length>0)return{file:a.relPath,entry:s.name,id:s.id,outcome:"refused",touchedSites:d,verify:{status:"skipped",errors:[]},summary:`refused to remove ${eU(a,s)}; ${d.length} reference(s) found`};var f=function*(t){var i=[],n={dataCalc:t.absPath.split(H.sep).includes("data-calc")};if(n.dataCalc&&((e,t,r)=>{for(var i=new Set,n=e.program.body,a=n.length-1;a>=0;a-=1){var s=n[a],o=V.isExportNamedDeclaration(s)?s.declaration:s;V.isVariableDeclaration(o)&&(o.declarations=o.declarations.filter(e=>!(V.isIdentifier(e.id)&&tt(e.init,t))||(i.add(e.id.name),r.push({action:"remove_calc_node",path:e.id.name}),!1)),0===o.declarations.length&&n.splice(a,1))}if(0!==i.size){var l=[],d=new Set;for(var p of(ea(e,{ArrayExpression(e){if(!e.findParent(e=>d.has(e.node))){var t=e.parentPath.isObjectProperty()?(0,ee.Gp)(e.parent.key):void 0;e.node.elements.forEach((n,a)=>{(tr(n,i)||V.isObjectExpression(n)&&["node","source","target"].some(e=>tr((0,ee.bf)(n,e)?.value,i)))&&(d.add(n),l.push({elements:e.node.elements,index:a}),r.push({action:"inputs"===t||"outputs"===t?"remove_io_item":"remove_reference_item",path:`${(e=>{for(var t=[],r=e;r&&!r.isProgram();r=r.parentPath){if(r.isVariableDeclarator()){V.isIdentifier(r.node.id)&&t.unshift(r.node.id.name);break}"elements"===r.listKey&&t.unshift(String(r.key)),r.isObjectProperty()&&t.unshift((0,ee.Gp)(r.node.key))}return t.join(".")})(e)}.${a}`}))})}}}),l.reverse())){var c=p.elements,u=p.index;c.splice(u,1)}}})(t.ast,o,i),t.absPath===a.absPath&&(ti(t,eu(t,{entry:s.name})),i.push({action:"remove_entry",path:s.name})),te(t.ast.program,o,i,[],n),0===i.length)return 1;var l=yield eB(t);ed(l,t.relPath),yield r.writeFile((yield ec(e,t.absPath)),l),i.forEach(e=>d.push({file:t.relPath,...e}))};for(var m of p)if(yield*f(m))continue;return{file:a.relPath,entry:s.name,id:s.id,touchedSites:d,summary:`removed ${eU(a,s)} with ${d.length} touched site(s)`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return N.apply(this,arguments)}),ts=(T=D(function*(e,t){var r;return eq(e,"new_subspace",t,(r=D(function*(r){var i=H.join(e,"root.ts"),n=(0,ee.RI)(e,i),a=yield(0,Z.readFile)(i,"utf8").catch(()=>null);if(null==a)throw new eo("invalid_file","Project has no root.ts to wire the subspace into");var s={source:a,ast:ed(a,n),projectDir:e,absPath:i,relPath:n},o=s.ast.program.body.find(e=>V.isExportDefaultDeclaration(e));if(!o||!V.isArrayExpression(o.declaration))throw new eo("fallback_recommended","root.ts default export is not a subspace array literal; wire the new subspace manually",{file:n});var l=(yield ey(e)).reduce((e,t)=>{var r=/^subspace-(\d+)$/.exec(H.basename(t));return r?Math.max(e,Number(r[1])):e},-1)+1,d=`subspace-${l}`,p=H.join(e,"subspaces",d),c=`SUBSPACE_${(0,W.randomUUID)()}`,u=`CANVAS_${(0,W.randomUUID)()}`,f=(({subspaceId:e,canvasId:t,title:r,description:i,layout:n,portal:a})=>{var s=[`width: ${n.width}`,`height: ${n.height}`,...n.resizeMode?[`resizeMode: '${n.resizeMode}'`]:[]];return{"data.ts":"import type { Data } from 'bricks-ctor'\n","bricks.ts":"import type { Brick } from 'bricks-ctor'\n","generators.ts":"import type { Generator } from 'bricks-ctor'\n","animations.ts":"import type { Animation } from 'bricks-ctor'\n","canvases.ts":`import type { Canvas } from 'bricks-ctor'
|
|
1
|
+
export const __rspack_esm_id=3774;export const __rspack_esm_ids=[3774];export const __webpack_modules__={56320(e,t,r){r.d(t,{FZ:()=>l,Fv:()=>a,Ux:()=>i,Vk:()=>n,Xn:()=>s,kO:()=>o,xQ:()=>p,xn:()=>d});var i=e=>"./canvases"===e||"./canvases.ts"===e||"./canvases.js"===e||"./canvases/index"===e||"./canvases/index.ts"===e||"./canvases/index.js"===e,n=e=>{for(var t=e;t&&("TSAsExpression"===t.type||"TSSatisfiesExpression"===t.type||"TSNonNullExpression"===t.type||"ParenthesizedExpression"===t.type);)t=t.expression;return t},a=(e,t)=>e.properties.find(e=>{var r;return"ObjectProperty"===e.type&&((r=e.key)?"Identifier"===r.type?r.name:"StringLiteral"===r.type||"NumericLiteral"===r.type?String(r.value):null:null)===t}),s=e=>{for(var t of e.program.body)if("ExportDefaultDeclaration"===t.type){var r=n(t.declaration);if(r?.type==="ObjectExpression")return r}return null},o=e=>e?.type!=="ImportSpecifier"?null:"Identifier"===e.imported.type?e.imported.name:"StringLiteral"===e.imported.type?e.imported.value:null,l=e=>{var t=[],r=new Map;for(var n of e.program.body)if("ImportDeclaration"===n.type&&"type"!==n.importKind&&i(n.source.value)){for(var a of n.specifiers)if("type"!==a.importKind)if("ImportNamespaceSpecifier"===a.type)t.push(a.local.name);else{var s=o(a);s&&r.set(a.local.name,s)}}return{namespaceImports:t,namedImports:r}},d=(e,t)=>{if(!e)return null;var r=n(e);return"MemberExpression"===r.type&&!r.computed&&"Identifier"===r.object.type&&"Identifier"===r.property.type&&t.namespaceImports.includes(r.object.name)?r.property.name:"Identifier"===r.type&&t.namedImports.has(r.name)?t.namedImports.get(r.name):null},p=(e,t)=>{if(!e)return null;var r=n(e);return"CallExpression"!==r.type||"MemberExpression"!==r.callee.type||r.callee.computed||"Identifier"!==r.callee.object.type||"Object"!==r.callee.object.name||"Identifier"!==r.callee.property.type||"values"!==r.callee.property.name||1!==r.arguments.length||"Identifier"!==r.arguments[0].type||!t.namespaceImports.includes(r.arguments[0].name)?null:{namespace:r.arguments[0].name}}},85949(e,t,r){r.a(e,async function(e,i){try{r.r(t),r.d(t,{__test__:()=>tj,register:()=>t_});var n,a,s,o,l,d,p,c,u,f,m,y,v,h,b,x,w,g,_,j,P,k,E,$,S,I,A,O,C,N,R,T,D,F=r(68832),L=r(99436),B=r(44668),K=r(5018),Y=r(63315),U=r(30409),M=r(40906),q=r(59410),z=r(2235),V=r(46773),J=r(80004),G=r(58135),Z=r(11978),W=r(79491),X=r(51455),H=r(77598),Q=r(76760),ee=r(84867),et=r(54452),er=r(98009),ei=r(56320),en=r(3540),ea=e([W]);function es(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(es=function(){return!!e})()}W=(ea.then?(await ea)():ea)[0];var eo=z.default||z,el=J.default||J,ed={"bricks.ts":{kind:"brick",namespace:"bricks",varPrefix:"b",idType:"brick",idPrefix:"BRICK_",typename:"Brick"},"generators.ts":{kind:"generator",namespace:"generators",varPrefix:"g",idType:"generator",idPrefix:"GENERATOR_",typename:"Generator"},"canvases.ts":{kind:"canvas",namespace:"canvases",varPrefix:"c",idType:"canvas",idPrefix:"CANVAS_",typename:"Canvas"},"data.ts":{kind:"data",namespace:"data",varPrefix:"d",idType:"data",idPrefix:"PROPERTY_BANK_DATA_NODE_",typename:"Data"},"animations.ts":{kind:"animation",namespace:"animations",varPrefix:"a",idType:"animation",idPrefix:"ANIMATION_",typename:"Animation"}},ep=function(e){function t(e,r,i,n=!1){var a,s,o;return K(this,t),s=t,o=[r],s=U(s),(a=Y(this,es()?Reflect.construct(s,o||[],U(this).constructor):s.apply(this,o))).name="EntryEditingError",a.code=e,a.details=i,a.isMcpError=n,a}return M(t,e),B(t)}(q(Error)),ec=(e,t)=>{if(Q.isAbsolute(t))throw new ep("invalid_file","File must be project-relative",{file:t});var r=Q.resolve(e,t),i=Q.relative(e,r);if(i.startsWith("..")||Q.isAbsolute(i))throw new ep("invalid_file","File must stay inside the project directory",{file:t});return r},eu=(e,t)=>{try{return(0,V.parse)(e,{sourceType:"module",plugins:["typescript","topLevelAwait"],errorRecovery:!1})}catch(e){throw new ep("parse_failed",`Cannot parse ${t} as TypeScript: ${e.message}. Edit this file directly.`,{file:t},!0)}},ef=(n=L(function*(e,t){var r=yield(0,er.LJ)(e,t);if(!r)throw new ep("invalid_file","File must stay inside the project directory",{file:(0,er.RI)(e,t)});var i=yield(0,X.readFile)(r,"utf8"),n=(0,er.RI)(e,t);return{source:i,ast:eu(i,n),projectDir:e,absPath:t,ioPath:r,relPath:n,kind:(e=>{var t=Q.basename(e),r=ed[t];if(!r)throw new ep("unsupported_file",`Unsupported entry file: ${t}`,{file:e,expected:Object.keys(ed)});return r})(t)}}),function(e,t){return n.apply(this,arguments)}),em=(a=L(function*(e,t){var r=yield(0,er.z5)(e,t);if(!r)throw new ep("invalid_file","File must stay inside the project directory",{file:(0,er.RI)(e,t)});return r}),function(e,t){return a.apply(this,arguments)}),ey=(e,t)=>{var r=(0,er.Zj)(e.ast);if(t.entry){var i=r.find(e=>e.name===t.entry);if(i)return i;var n=r.filter(e=>e.alias===t.entry);if(1===n.length)return n[0];if(n.length>1)throw new ep("ambiguous_reference",`Alias is ambiguous: ${t.entry}`,{file:e.relPath,entry:t.entry,matches:n.map(e=>e.name)});throw new ep("entry_not_found",`Entry not found (by name or alias): ${t.entry}`,{file:e.relPath,entry:t.entry})}if(t.id){var a=r.find(e=>e.id===t.id);if(!a)throw new ep("entry_not_found",`Entry id not found: ${t.id}`,{file:e.relPath,id:t.id});return a}throw new ep("missing_target","Provide entry or id")},ev=e=>e.split(Q.sep).find(e=>/^subspace-\d+$/.test(e))||"unknown-subspace",eh=e=>{var t=e.split(Q.sep),r=t.findIndex(e=>/^subspace-\d+$/.test(e));if(r<0)throw new ep("invalid_file","Entry file must be inside subspaces/subspace-N",{file:e});return t.slice(0,r+1).join(Q.sep)},eb=(s=L(function*(e){var t=Q.join(e,"subspaces");return(yield(0,X.readdir)(t,{withFileTypes:!0}).catch(()=>[])).filter(e=>e.isDirectory()&&/^subspace-\d+$/.test(e.name)).map(e=>Q.join(t,e.name)).sort()}),function(e){return s.apply(this,arguments)}),ex=(o=L(function*(e){var t=Object.keys(ed),r=yield(0,X.readdir)(e,{withFileTypes:!0}).catch(()=>[]),i=new Set(r.filter(e=>e.isFile()).map(e=>e.name));return t.filter(e=>i.has(e)).map(t=>Q.join(e,t))}),function(e){return o.apply(this,arguments)}),ew=(l=L(function*(e){var t=yield eb(e);return(yield Promise.all(t.map(ex))).flat()}),function(e){return l.apply(this,arguments)}),eg=(d=L(function*(e,t){if(t.file)return ec(e,t.file);if(!t.id)throw new ep("missing_file","Provide file, or provide id for global lookup");for(var r of yield ew(e)){var i=yield ef(e,r);if((0,er.Zj)(i.ast).find(e=>e.id===t.id))return r}throw new ep("entry_not_found",`Entry id not found: ${t.id}`,{id:t.id})}),function(e,t){return d.apply(this,arguments)}),e_=(p=L(function*(e,t){var r=yield eg(e,t),i=yield ef(e,r),n=ey(i,t),a=((e,t)=>{if(!e.object)throw new ep("fallback_recommended",`Entry ${e.name} in ${t} is not a top-level exported object literal. Edit this file directly for this one.`,{file:t,entry:e.name,check:"top-level export const object literal"});return e.object})(n,i.relPath);return{parsed:i,entry:n,object:a}}),function(e,t){return p.apply(this,arguments)}),ej=(e,t)=>G.callExpression(G.identifier("makeId"),t?[G.stringLiteral(e),G.stringLiteral(t)]:[G.stringLiteral(e)]),eP=e=>{var t=[];for(var r of e.split(".").filter(Boolean))for(var i=/([^\[\]]+)|\[(\d+)\]/g,n=void 0;n=i.exec(r);)n[1]&&t.push({key:n[1]}),n[2]&&t.push({index:Number(n[2])});if(0===t.length)throw new ep("invalid_path",`Invalid path: ${e}`,{path:e});return t},ek=ei.Vk,eE=(e,t)=>{var r=ek(e);if(!G.isObjectExpression(r))throw new ep("fallback_recommended",`Target path ${t} is not an object literal. Edit this file directly for this one.`,{path:t,expected:"object literal",actual:r.type});return r},e$=(e,t)=>{var r=ek(e);if(!G.isArrayExpression(r))throw new ep("fallback_recommended",`Target path ${t} is not an array literal. Edit this file directly for this one.`,{path:t,expected:"array literal",actual:r.type});return r},eS=e=>"array"==("index"in e?"array":"object")?G.arrayExpression([]):G.objectExpression([]),eI=(c=L(function*(e,t,r,i){for(var n=eP(t),a=e,s=0;s<n.length;s+=1){var o=n[s],l=s===n.length-1;if("key"in o){var d=eE(a,t);if(l)return void(0,er.HJ)(d,o.key,(yield eK(r,i)));var p=n[s+1],c=(0,er.bf)(d,o.key);c||(c=G.objectProperty((0,er.zu)(o.key),eS(p)),d.properties.push(c)),a=c.value;continue}var u=e$(a,t);if(o.index<0||o.index>u.elements.length)throw new ep("invalid_path",`Array index out of range for ${t}`,{path:t,index:o.index});if(l){u.elements[o.index]=yield eK(r,i);return}u.elements[o.index]||(u.elements[o.index]=eS(n[s+1])),a=u.elements[o.index]}}),function(e,t,r,i){return c.apply(this,arguments)}),eA=(e,t)=>{for(var r=eP(t),i=e,n=0;n<r.length;n+=1){var a=r[n],s=n===r.length-1;if("key"in a){var o=eE(i,t);if(s)return void(0,er.jc)(o,a.key);var l=(0,er.bf)(o,a.key);if(!l)return;i=l.value;continue}var d=e$(i,t);if(a.index<0||a.index>=d.elements.length)return;if(s)return void d.elements.splice(a.index,1);var p=d.elements[a.index];if(!p)return;i=p}},eO=(e,t)=>{var r=(0,er.bf)(e,"switches");if(!r)throw new ep("fallback_recommended","Entry has no switches array",{path:"switches"});var i=e$(r.value,"switches"),n="number"==typeof t?t:i.elements.findIndex(e=>G.isObjectExpression(e)&&(0,er.JJ)(e,"id")===t);if(n<0||n>=i.elements.length)throw new ep("entry_not_found",`Switch not found: ${t}`,{switch:t});var a=i.elements[n];if(!G.isObjectExpression(a))throw new ep("fallback_recommended",`Switch ${String(t)} is not an object literal. Edit this file directly for this one.`,{switch:t});return a},eC=(e,t)=>{var r=t.replace(/\.[tj]sx?$/,""),i=Q.relative(Q.dirname(e),r).replace(/\\/g,"/");return i.startsWith(".")||(i=`./${i}`),i},eN=(e,t,r)=>{for(var i of e.ast.program.body)if(G.isImportDeclaration(i)&&i.source.value===t){var n=i.specifiers.find(e=>G.isImportDefaultSpecifier(e));if(n)return n.local.name}var a=(0,er.R0)(e.ast,r),s=G.importDeclaration([G.importDefaultSpecifier(G.identifier(a))],G.stringLiteral(t));return(0,er.Pb)(e.ast,s),a},eR=e=>{(0,er.Kx)(e.parsed.ast,"type",e.typeImports),(0,er.Kx)(e.parsed.ast,"value",e.valueImports)},eT=(u=L(function*(e,t,r){if(null==r||""===r)return t;if("number"==typeof r)return Q.join(e,"subspaces",`subspace-${r}`);var i=String(r);if(/^\d+$/.test(i))return Q.join(e,"subspaces",`subspace-${i}`);if(/^subspace-\d+$/.test(i))return Q.join(e,"subspaces",i);if(i.includes("/"))return ec(e,i);var n,a=yield eb(e),s=function*(){var t=Q.join(o,"index.ts"),r=yield(0,X.readFile)(t,"utf8").catch(()=>"");if(!r)return 0;var n=eu(r,(0,er.RI)(e,t)),a=!1;if(el(n,{ObjectProperty(e){"id"===(0,er.Gp)(e.node.key)&&G.isStringLiteral(e.node.value)&&e.node.value.value===i&&(a=!0,e.stop())}}),a)return{v:o}};for(var o of a)if(n=yield*s(),0!==n&&n)return n.v;throw new ep("reference_not_found",`Subspace not found: ${i}`,{subspace:i})}),function(e,t,r){return u.apply(this,arguments)}),eD=(f=L(function*(e,t){var r,i,n=eh(e.parsed.absPath),a=yield eT(e.projectDir,n,t),s=Q.basename(a),o=/^subspace-(\d+)$/.exec(s);if(!o)throw new ep("invalid_subspace",`Not a subspace directory: ${s}`,{subspace:t});var l=Q.join(a,"index.ts"),d=yield(0,X.readFile)(l,"utf8").catch(()=>null);if(null==d)throw new ep("reference_not_found",`Subspace not found: ${t}`,{subspace:t});var p=(r=eu(d,(0,er.RI)(e.projectDir,l)),el(r,{ObjectProperty(e){if("id"===(0,er.Gp)(e.node.key)){var t=e.node.value;G.isStringLiteral(t)&&t.value.startsWith("SUBSPACE_")&&(i=t.value,e.stop())}}}),i);if(!p)throw new ep("invalid_subspace",`Subspace index has no SUBSPACE_ id: ${s}/index.ts`,{subspace:t});return{id:p,index:Number(o[1]),label:s,indexPath:l,isCurrent:Q.resolve(a)===Q.resolve(n)}}),function(e,t){return f.apply(this,arguments)}),eF=(m=L(function*(e,t){var r=yield eD(e,t);if(r.isCurrent)return e.references.push({input:t,id:r.id,sameFile:!1,display:`'${r.id}'`,targetAbsPath:r.indexPath}),{resolved:r,expression:G.stringLiteral(r.id)};var i=eN(e.parsed,`../${r.label}`,`subspace${r.index}`);return e.references.push({input:t,id:r.id,sameFile:!1,display:`() => ${i}`,targetAbsPath:r.indexPath}),{resolved:r,expression:G.arrowFunctionExpression([],G.identifier(i))}}),function(e,t){return m.apply(this,arguments)}),eL=(y=L(function*(e,t,r,i){var n=eh(t),a=yield eT(e,n,i),s=yield ex(a),o=[];for(var l of s){var d=yield ef(e,l),p=d.kind;for(var c of(0,er.Zj)(d.ast))if(c.name===r||c.id===r||c.alias===r){var u=Q.resolve(l)===Q.resolve(t),f=Q.basename(a);o.push({input:r,id:c.id,alias:c.alias,varName:c.name,namespace:p.namespace,display:`${p.namespace}.${c.name}`,targetAbsPath:l,sameFile:u,subspaceLabel:f,importSource:u?void 0:eC(t,l)})}}if(0===o.length)throw new ep("reference_not_found",`Reference not found: ${r}`,{ref:r,subspace:i??Q.basename(n)});if(o.length>1)throw new ep("ambiguous_reference",`Reference is ambiguous: ${r}`,{ref:r,matches:o.map(t=>({file:(0,er.RI)(e,t.targetAbsPath),entry:t.varName,id:t.id,alias:t.alias}))});return o[0]}),function(e,t,r,i){return y.apply(this,arguments)}),eB=(v=L(function*(e,t,r){var i=yield eL(t.projectDir,t.parsed.absPath,e,r);if(i.sameFile)return t.references.push(i),G.identifier(i.varName);var n=eh(t.parsed.absPath),a=eh(i.targetAbsPath),s=i.subspaceLabel.replace(/[^a-zA-Z0-9_$]/g,""),o=n===a?i.namespace:`${s}${i.namespace[0].toUpperCase()}${i.namespace.slice(1)}`,l=((e,t,r,i)=>{for(var n of e.ast.program.body)if(G.isImportDeclaration(n)&&n.source.value===r){var a=n.specifiers.find(G.isImportNamespaceSpecifier);if(a)return a.local.name}var s=(0,er.R0)(e.ast,i),o=G.importDeclaration([G.importNamespaceSpecifier(G.identifier(s))],G.stringLiteral(r));return(0,er.Pb)(e.ast,o),s})(t.parsed,i.namespace,i.importSource,o);return i.importLocal=l,t.references.push({...i,display:`${l}.${i.varName}`,importLocal:l}),G.memberExpression(G.identifier(l),G.identifier(i.varName))}),function(e,t,r){return v.apply(this,arguments)}),eK=(h=L(function*(e,t){if((0,er.u4)(e)&&"string"==typeof e.expr&&1===Object.keys(e).length){var r=e.expr;try{return(0,V.parseExpression)(r,{plugins:["typescript"]})}catch(e){throw new ep("invalid_expr",`Invalid TypeScript expression: ${e.message}`,{expr:r})}}if((0,er.u4)(e)&&"string"==typeof e.link){t.valueImports.add("linkData");var i=yield eB(e.link,t,e.subspace);return G.callExpression(G.identifier("linkData"),[G.arrowFunctionExpression([],i)])}if((0,er.u4)(e)&&"string"==typeof e.ref){var n=yield eB(e.ref,t,e.subspace);return G.arrowFunctionExpression([],n)}if(Array.isArray(e))return G.arrayExpression((yield Promise.all(e.map(e=>eK(e,t)))));if((0,er.u4)(e)){var a,s=yield Promise.all(Object.entries(e).map((a=L(function*([e,r]){return G.objectProperty((0,er.zu)(e),(yield eK(r,t)))}),function(e){return a.apply(this,arguments)})));return G.objectExpression(s)}return void 0===e?G.identifier("undefined"):G.valueToNode(e)}),function(e,t){return h.apply(this,arguments)}),eY=e=>e.map(e=>({input:e.input,id:e.id,alias:e.alias,resolved:e.importLocal?`${e.importLocal}.${e.varName}`:e.sameFile?e.varName:e.display,file:e.targetAbsPath})),eU=(b=L(function*(e){var t=eo(e.ast,{comments:!0},e.source).code,r=yield(0,W.format)(e.absPath,t,er.Hn);if(r.errors.length>0)throw new ep("format_failed",`oxfmt failed for ${e.relPath}`,{file:e.relPath,errors:r.errors});return r.code}),function(e){return b.apply(this,arguments)}),eM=(x=L(function*(e,t){var r=yield eU(t);return eu(r,t.relPath),yield e.writeFile(t.ioPath??(yield em(t.projectDir,t.absPath)),r),r}),function(e,t){return x.apply(this,arguments)}),eq=(e,t)=>{if(e){var r=ev(e.absPath);return`${t?.name||"entry"} (${e.kind.kind}, ${r})`}},ez=(w=L(function*(e,t,r,i){var n={ts:new Date().toISOString(),tool:t,op:r?.op||(r?.set?"set":r?.unset?"unset":t),target:{file:r?.file,entry:r?.entry,id:r?.id},provenance:(0,en.S)()};try{var a=yield(0,et.G$)(e,r.verify,i),s={...n,...a};return yield(0,en.a)(e,s).catch(e=>{s.auditError=e.message}),s}catch(i){var o=i instanceof ep?i:new ep("error",i.message||String(i),void 0,!0),l="fallback_recommended"===o.code?"fallback_recommended":"error",d={...n,outcome:l,input:r,error:{code:o.code,message:o.message,details:o.details},summary:"fallback_recommended"===l?`${t} could not safely edit this standard path; edit the file directly`:`${t} failed: ${o.message}`,isError:o.isMcpError||"error"===l};return yield(0,en.a)(e,d).catch(e=>{d.auditError=e.message}),d}}),function(e,t,r,i){return w.apply(this,arguments)}),eV=(g=L(function*(e,t){var r;return ez(e,"edit_entry",t,(r=L(function*(r){var i=yield e_(e,t),n=i.parsed,a=i.entry,s=i.object,o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=null==t.switch?s:eO(s,t.switch);for(var d of Object.entries(t.set||{})){var p=F(d,2),c=p[0],u=p[1];yield eI(l,c,u,o)}for(var f of[...t.unset||[]].sort((e,t)=>{for(var r=eP(e).map(e=>"index"in e?e.index:-1),i=eP(t).map(e=>"index"in e?e.index:-1),n=0;n<Math.min(r.length,i.length);n+=1)if(r[n]!==i[n])return i[n]-r[n];return i.length-r.length}))eA(l,f);eR(o),yield eM(r,n);var m=eq(n,a);return{file:n.relPath,entry:a.name,id:a.id,change:{set:t.set||{},unset:t.unset||[],references:eY(o.references)},summary:`edited ${m}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return g.apply(this,arguments)}),eJ=e=>{switch(e){case"IfStatement":return"an if statement";case"ForStatement":case"ForOfStatement":case"ForInStatement":return"a for loop";case"WhileStatement":case"DoWhileStatement":return"a while loop";case"SwitchStatement":return"a switch statement";case"TryStatement":return"a try/catch block";case"FunctionDeclaration":return"a function declaration";case"ReturnStatement":return"a return before the final statement";default:return`a ${e}`}},eG=(e,t)=>{for(var r=0;r<e.length;r+=1){var i=e[r],n=r===e.length-1;if("ExpressionStatement"===i.type){var a=eZ(i.expression);if(a)return a;continue}if("VariableDeclaration"===i.type){for(var s of i.declarations)if("Identifier"!==s.id.type||!s.init)return"a destructuring or uninitialized declaration";continue}if(t&&n&&"ReturnStatement"===i.type){var o=i.argument?eZ(i.argument):null;if(o)return o;continue}return eJ(i.type)}return null},eZ=e=>{if(e?.type!=="CallExpression"||e.arguments?.length||e.callee?.type!=="ArrowFunctionExpression"&&e.callee?.type!=="FunctionExpression")return null;var t=e.callee.body;return t?.type==="BlockStatement"?eG(t.body,!0):eZ(t)},eW=(_=L(function*(e,t){if(e?.expr)return eK(e,t);var r,i=(e=>{if(!(0,er.u4)(e)||!(0,er.u4)(e.action))return e;var t=e.action,r={handler:e.handler,name:t.name??t.__actionName,waitAsync:e.waitAsync};if(t.cast&&(r.cast=t.cast),Array.isArray(t.params))for(var i of(r.params={},t.params)){if(!(0,er.u4)(i)||"string"!=typeof i.input)throw new ep("invalid_action",'Compiled action params entries require { input: "name", value }',{param:i});r.params[i.input]=i.value}if(Array.isArray(t.dataParams))for(var n of(r.dataParams={},t.dataParams)){var a=(0,er.u4)(n?.input)?n.input.ref:n?.input;if("string"!=typeof a||!a)throw new ep("invalid_action","Compiled action dataParams entries require { input: dataRef, value }",{param:n});r.dataParams[a]=n.value}return r})(e),n=i?.name;if(!n)throw new ep("invalid_action","Action requires name");if("PROPERTY_BANK_EXPRESSION"===n&&(0,er.u4)(i.params)){var a=i.params.expression;"string"==typeof a&&(e=>{try{t=(0,Z.qg)(e,{ecmaVersion:2020})}catch(t){throw new ep("invalid_action",`PROPERTY_BANK_EXPRESSION does not parse: ${t.message}`,{expression:e})}var t,r=eG(t.body,!1);if(r)throw new ep("invalid_action",`PROPERTY_BANK_EXPRESSION cannot evaluate ${r}: the runtime folds the expression into a single expression (expression statements, simple const/let declarations, and a final return inside an IIFE only). Use ternaries instead of statements, or move branching logic to a DataCalculationScript.`,{expression:e})})(a)}var s="System",o=i.cast;if("system"===i.handler||null==i.handler)r=G.stringLiteral("system"),o||=`SystemAction${n.toLowerCase().split("_").filter(Boolean).map(e=>`${e[0].toUpperCase()}${e.slice(1)}`).join("")}`;else if((0,er.u4)(i.handler)&&"string"==typeof i.handler.ref){var l=yield eL(t.projectDir,t.parsed.absPath,i.handler.ref,i.handler.subspace);if("bricks"!==l.namespace&&"generators"!==l.namespace)throw new ep("invalid_action",`Action handler must be a brick or generator, got ${l.namespace}: ${i.handler.ref}`,{handler:i.handler});s="bricks"===l.namespace?"Brick":"Generator";var d=yield eB(i.handler.ref,t,i.handler.subspace);r=G.arrowFunctionExpression([],d)}else if((0,er.u4)(i.handler)&&null!=i.handler.subspace)r=(yield eF(t,i.handler.subspace)).expression,s="Subspace";else throw new ep("invalid_action","Unsupported action handler",{handler:i.handler});var p=[G.objectProperty(G.identifier("__actionName"),G.stringLiteral(n)),G.objectProperty(G.identifier("parent"),G.stringLiteral(s)),G.objectProperty(G.identifier("name"),G.stringLiteral(n))];if(i.params){var c,u=yield Promise.all(Object.entries(i.params).map((c=L(function*([e,r]){return G.objectExpression([G.objectProperty(G.identifier("input"),G.stringLiteral(e)),G.objectProperty(G.identifier("value"),(yield eK(r,t)))])}),function(e){return c.apply(this,arguments)})));p.push(G.objectProperty(G.identifier("params"),G.arrayExpression(u)))}if(i.dataParams){var f,m=yield Promise.all(Object.entries(i.dataParams).map((f=L(function*([e,r]){var i=yield eB(e,t);return G.objectExpression([G.objectProperty(G.identifier("input"),G.arrowFunctionExpression([],i)),G.objectProperty(G.identifier("value"),(yield eK(r,t)))])}),function(e){return f.apply(this,arguments)})));p.push(G.objectProperty(G.identifier("dataParams"),G.arrayExpression(m)))}var y=G.objectExpression(p);return o&&(t.typeImports.add(o),y=G.tsAsExpression(y,G.tsTypeReference(G.identifier(o)))),G.objectExpression([G.objectProperty(G.identifier("handler"),r),G.objectProperty(G.identifier("action"),y),G.objectProperty(G.identifier("waitAsync"),G.booleanLiteral(!!i.waitAsync))])}),function(e,t){return _.apply(this,arguments)}),eX=(e,t,r)=>{var i=(0,er.bf)(e,t);return i||(i=G.objectProperty((0,er.zu)(t),G.objectExpression([])),e.properties.push(i)),eE(i.value,r)},eH=(e,t,r)=>{var i=(0,er.bf)(e,t);return i||(i=G.objectProperty((0,er.zu)(t),G.arrayExpression([])),e.properties.push(i)),e$(i.value,r)},eQ=(j=L(function*(e,t){var r;return ez(e,"edit_events",t,(r=L(function*(r){var i=yield e_(e,t),n=i.parsed,a=i.entry,s=i.object,o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=null==t.switch?s:eO(s,t.switch),d=t.op;if("clear"===d||"remove"===d||"move"===d){var p=(0,er.bf)(l,"events"),c=p?eE(p.value,"events"):null,u=c?(0,er.bf)(c,t.event):null,f=u?e$(u.value,`events.${t.event}`):null;if("clear"===d)c&&(0,er.jc)(c,t.event);else if("move"===d){if(null==t.index)throw new ep("invalid_index","move requires index");if(!f||t.index<0||t.index>=f.elements.length)throw new ep("invalid_index","move index out of range",{index:t.index});var m=Number(t.to);if(!Number.isFinite(m)||m<0||m>=f.elements.length)throw new ep("invalid_index","move requires valid to index",{to:t.to});var y=f.elements.splice(t.index,1),v=F(y,1)[0];f.elements.splice(m,0,v)}else{if(null==t.index)throw new ep("invalid_index","remove requires index");if(!f||t.index<0||t.index>=f.elements.length)throw new ep("invalid_index","remove index out of range",{index:t.index});f.elements.splice(t.index,1),0===f.elements.length&&c&&(0,er.jc)(c,t.event)}}else if("add"===d||"replace"===d){var h=yield eW(t.action,o),b=eX(l,"events","events"),x=eH(b,t.event,`events.${t.event}`),w=t.index??x.elements.length;if("replace"===d){if(w<0||w>=x.elements.length)throw new ep("invalid_index","replace index out of range",{index:w});x.elements[w]=h}else{if(w<0||w>x.elements.length)throw new ep("invalid_index","add index out of range",{index:w});x.elements.splice(w,0,h)}}else throw new ep("invalid_op",`Unsupported edit_events op: ${d}`);return eR(o),yield eM(r,n),{file:n.relPath,entry:a.name,id:a.id,change:{event:t.event,op:d,index:t.index,references:eY(o.references)},summary:`${d} event ${t.event} on ${eq(n,a)}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return j.apply(this,arguments)}),e0=e=>{if((0,er.u4)(e)&&"string"==typeof e.expr)return e;if(!(0,er.u4)(e))throw new ep("invalid_item","Canvas item requires frame { x, y, width, height }");for(var t of["x","y","width","height"])if("number"!=typeof e[t])throw new ep("invalid_item",`Canvas item frame requires numeric ${t}`,{frame:e});return e},e1=(P=L(function*(e,t,r){if(!e?.ref&&e?.subspace==null)throw new ep("invalid_item","Canvas item requires ref (brick) or subspace (embed)");var i,n=e0(e.frame??r);if(e.ref){var a=yield eB(e.ref,t,e.subspace);i=G.arrowFunctionExpression([],a)}else{var s=yield eF(t,e.subspace),o=s.resolved,l=s.expression;if(o.isCurrent)throw new ep("invalid_item","A subspace cannot embed itself",{subspace:e.subspace});i=l}return G.objectExpression([G.objectProperty(G.identifier("item"),i),G.objectProperty(G.identifier("frame"),(yield eK(n,t))),...null==e.animations?[]:[G.objectProperty(G.identifier("animations"),(yield eK(e.animations,t)))],...null==e.hidden?[]:[G.objectProperty(G.identifier("hidden"),G.booleanLiteral(!!e.hidden))]])}),function(e,t,r){return P.apply(this,arguments)}),e4=(k=L(function*(e,t){var r;return ez(e,"edit_canvas_items",t,(r=L(function*(r){var i=yield e_(e,t),n=i.parsed,a=i.entry,s=i.object;if("canvas"!==n.kind.kind)throw new ep("invalid_file","edit_canvas_items only edits canvases.ts entries",{file:n.relPath});var o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=eH(s,"items","items"),d=t.op;if("add"===d||"replace"===d){var p=yield e1(t.item,o,t.frame),c=t.index??l.elements.length;if("replace"===d){if(c<0||c>=l.elements.length)throw new ep("invalid_index","replace index out of range",{index:c});l.elements[c]=p}else{if(c<0||c>l.elements.length)throw new ep("invalid_index","add index out of range",{index:c});l.elements.splice(c,0,p)}}else if("remove"===d){if(null==t.index)throw new ep("invalid_index","remove requires index");if(t.index<0||t.index>=l.elements.length)throw new ep("invalid_index","remove index out of range",{index:t.index});l.elements.splice(t.index,1)}else if("move"===d){if(null==t.index)throw new ep("invalid_index","move requires index");if(!t.frame)throw new ep("invalid_item","move requires frame");if(t.index<0||t.index>=l.elements.length)throw new ep("invalid_index","move index out of range",{index:t.index});var u=l.elements[t.index];if(!G.isObjectExpression(u))throw new ep("fallback_recommended","Canvas item is not an object literal",{index:t.index});(0,er.HJ)(u,"frame",(yield eK(e0(t.frame),o)))}else throw new ep("invalid_op",`Unsupported edit_canvas_items op: ${d}`);return eR(o),yield eM(r,n),{file:n.relPath,entry:a.name,id:a.id,change:{op:d,index:t.index,references:eY(o.references)},summary:`${d} canvas item on ${eq(n,a)}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return k.apply(this,arguments)}),e5=(E=L(function*(e,t){var r=(e=>{switch(e?.__typename){case"SwitchCondInnerStateCurrentCanvas":return{type:"inner_state",key:"current_canvas",value:e.value,subspace:e.subspace};case"SwitchCondInnerStateOutlet":return{type:"inner_state",outlet:e.outlet,value:e.value};case"SwitchCondData":return{type:"property_bank",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondPropertyBankByItemKey":return{type:"property_bank_by_item_key",ref:e.data??e.ref,value:e.value,subspace:e.subspace};case"SwitchCondItemKeyMapping":return{type:"item_key_mapping",key:e.key,value:e.value};default:return e}})(e);if(r?.expr)return eK(r,t);if(r?.type==="inner_state"&&"current_canvas"===r.key){var i=yield eB(r.value,t,r.subspace);return G.objectExpression([G.objectProperty(G.identifier("__typename"),G.stringLiteral("SwitchCondInnerStateCurrentCanvas")),G.objectProperty(G.identifier("value"),G.arrowFunctionExpression([],i))])}if(r?.type==="inner_state"){var n=r.outlet||r.key;if(!n)throw new ep("invalid_switch","Switch inner-state outlet condition requires outlet or key");return G.objectExpression([G.objectProperty(G.identifier("__typename"),G.stringLiteral("SwitchCondInnerStateOutlet")),G.objectProperty(G.identifier("outlet"),G.stringLiteral(n)),G.objectProperty(G.identifier("value"),(yield eK(r.value,t)))])}if(r?.type==="item_key_mapping"){if(!r.key)throw new ep("invalid_switch","Switch item key mapping condition requires key");return G.objectExpression([G.objectProperty(G.identifier("__typename"),G.stringLiteral("SwitchCondItemKeyMapping")),G.objectProperty(G.identifier("key"),G.stringLiteral(r.key)),G.objectProperty(G.identifier("value"),(yield eK(r.value,t)))])}var a=r?.ref||r?.data||r?.key;if(!a)throw new ep("invalid_switch","Switch condition requires data ref");var s=yield eB(a,t,r.subspace);return G.objectExpression([G.objectProperty(G.identifier("__typename"),G.stringLiteral(r?.type==="property_bank_by_item_key"?"SwitchCondPropertyBankByItemKey":"SwitchCondData")),G.objectProperty(G.identifier("data"),G.arrowFunctionExpression([],s)),G.objectProperty(G.identifier("value"),(yield eK(r.value,t)))])}),function(e,t){return E.apply(this,arguments)}),e9=new Set(["id","title","description","conds","override","property","outlets","animation","events","disabled","break"]),e8=($=L(function*(e,t){for(var r of Object.keys(e))if(!e9.has(r))throw new ep("invalid_switch",`Unknown switch field: ${r}`,{field:r,supported:Array.from(e9)});if(void 0!==e.events)throw new ep("invalid_switch","Set switch events with edit_events using its switch parameter");if(e.id&&!/^BRICK_STATE_GROUP_[0-9a-fA-F-]{36}$/.test(e.id))throw new ep("invalid_switch","Switch id must match BRICK_STATE_GROUP_<uuid>; omit id to generate one",{id:e.id});var i,n=e.id?G.stringLiteral(e.id):ej("switch");e.id||t.valueImports.add("makeId");var a=[G.objectProperty(G.identifier("id"),n)];for(var s of(null!=e.title&&a.push(G.objectProperty(G.identifier("title"),G.stringLiteral(e.title))),null!=e.description&&a.push(G.objectProperty(G.identifier("description"),G.stringLiteral(e.description))),e.conds&&a.push(G.objectProperty(G.identifier("conds"),G.arrayExpression((yield Promise.all(e.conds.map((i=L(function*(e){return G.objectExpression([G.objectProperty(G.identifier("method"),G.stringLiteral(e.method||"==")),G.objectProperty(G.identifier("cond"),(yield e5(e.cond||e,t)))])}),function(e){return i.apply(this,arguments)}))))))),e.override&&a.push(G.objectProperty(G.identifier("override"),(yield eK(e.override,t)))),["property","outlets","animation"]))null!=e[s]&&a.push(G.objectProperty(G.identifier(s),(yield eK(e[s],t))));return null!=e.disabled&&a.push(G.objectProperty(G.identifier("disabled"),G.booleanLiteral(!!e.disabled))),null!=e.break&&a.push(G.objectProperty(G.identifier("break"),G.booleanLiteral(!!e.break))),G.objectExpression(a)}),function(e,t){return $.apply(this,arguments)}),e2=(S=L(function*(e,t){var r;return ez(e,"edit_switches",t,(r=L(function*(r){var i=yield e_(e,t),n=i.parsed,a=i.entry,s=i.object,o={projectDir:e,parsed:n,references:[],typeImports:new Set,valueImports:new Set},l=eH(s,"switches","switches"),d=t.op,p=e=>"number"==typeof e?e:e?l.elements.findIndex(t=>G.isObjectExpression(t)&&(0,er.JJ)(t,"id")===e):-1;if("add"===d||"replace"===d){var c=yield e8(t.switch||{},o),u=null==t.index?l.elements.length:p(t.index);if("replace"===d){if(u<0||u>=l.elements.length)throw new ep("invalid_index","replace index out of range",{index:u});l.elements[u]=c}else{if(u<0||u>l.elements.length)throw new ep("invalid_index","add requires a valid switch id or index",{index:t.index});l.elements.splice(u,0,c)}}else if("remove"===d){var f=p(t.index);if(f<0||f>=l.elements.length)throw new ep("invalid_index","remove requires a valid switch id or index",{index:t.index});l.elements.splice(f,1)}else if("move"===d){var m=p(t.index);if(m<0||m>=l.elements.length)throw new ep("invalid_index","move requires a valid switch id or index",{index:t.index});var y=Number(t.to);if(!Number.isFinite(y)||y<0||y>=l.elements.length)throw new ep("invalid_index","move requires valid to index",{to:t.to});var v=l.elements.splice(m,1),h=F(v,1)[0];l.elements.splice(y,0,h)}else throw new ep("invalid_op",`Unsupported edit_switches op: ${d}`);return eR(o),yield eM(r,n),{file:n.relPath,entry:a.name,id:a.id,change:{op:d,index:t.index,references:eY(o.references)},summary:`${d} switch on ${eq(n,a)}`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return S.apply(this,arguments)}),e3=(I=L(function*(e,t,r,i){var n=[G.objectProperty(G.identifier("__typename"),G.stringLiteral(e.typename)),G.objectProperty(G.identifier("id"),r)];return t.alias&&n.push(G.objectProperty(G.identifier("alias"),G.stringLiteral(t.alias))),null!=t.title&&n.push(G.objectProperty(G.identifier("title"),G.stringLiteral(t.title))),null!=t.description&&n.push(G.objectProperty(G.identifier("description"),G.stringLiteral(t.description))),"brick"===e.kind||"generator"===e.kind?(n.push(G.objectProperty(G.identifier("templateKey"),G.stringLiteral(t.templateKey||""))),n.push(G.objectProperty(G.identifier("property"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("events"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("outlets"),G.objectExpression([]))),"brick"===e.kind&&n.push(G.objectProperty(G.identifier("animation"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("switches"),G.arrayExpression([])))):"canvas"===e.kind?(n.push(G.objectProperty(G.identifier("property"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("events"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("switches"),G.arrayExpression([]))),n.push(G.objectProperty(G.identifier("items"),G.arrayExpression([])))):"data"===e.kind?(n.push(G.objectProperty(G.identifier("type"),G.stringLiteral(t.dataType||"any"))),n.push(G.objectProperty(G.identifier("schema"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("events"),G.objectExpression([]))),n.push(G.objectProperty(G.identifier("value"),G.identifier("undefined")))):"animation"===e.kind&&(n.push(G.objectProperty(G.identifier("runType"),G.stringLiteral("once"))),n.push(G.objectProperty(G.identifier("property"),G.stringLiteral("opacity"))),n.push(G.objectProperty(G.identifier("config"),(yield eK({__type:"AnimationTimingConfig",toValue:1,duration:300,easing:"",delay:0,isInteraction:!0},i))))),G.objectExpression(n)}),function(e,t,r,i){return I.apply(this,arguments)}),e6=(A=L(function*(e,t,r){var i=Q.basename(t);for(var n of(yield ew(e)).filter(e=>Q.basename(e)===i)){var a=yield ef(e,n);if((0,er.Zj)(a.ast).some(e=>e.alias===r))return!0}return!1}),function(e,t,r){return A.apply(this,arguments)}),e7=(O=L(function*(e,t){var r,i,n,a=Q.join(t,"index.ts"),s=(0,er.RI)(e,a);try{r=yield(0,X.lstat)(a)}catch(e){if(e?.code==="ENOENT")return{parsed:null,relPath:s,skippedReason:"index.ts not found"};return{parsed:null,relPath:s,skippedReason:`could not read index.ts (${e.message})`}}if(!r)return{parsed:null,relPath:s,skippedReason:"index.ts not found"};try{i=yield(0,er.LJ)(e,a)}catch(e){return{parsed:null,relPath:s,skippedReason:e?.code==="ENOENT"?"index.ts symlink target not found":`could not resolve index.ts (${e.message})`}}if(!i)return{parsed:null,relPath:s,skippedReason:"index.ts is outside the project directory"};try{n=yield(0,X.readFile)(i,"utf8")}catch(e){return{parsed:null,relPath:s,skippedReason:`could not read index.ts (${e.message})`}}try{return{parsed:{projectDir:e,absPath:a,ioPath:i,relPath:s,source:n,ast:eu(n,s)},relPath:s,skippedReason:null}}catch{return{parsed:null,relPath:s,skippedReason:"index.ts could not be parsed as TypeScript"}}}),function(e,t){return O.apply(this,arguments)}),te=(C=L(function*(e,t,r,i){var n=eh(r.absPath),a=yield e7(t,n),s=a.parsed,o=a.relPath,l=a.skippedReason;if(!s)return{file:o,status:"not_updated",reason:l};var d=(0,ei.Xn)(s.ast);if(!d)return{file:s.relPath,status:"not_updated",reason:"no default-export object literal"};var p=(0,er.bf)(d,"canvases");if(!p)return{file:s.relPath,status:"not_updated",reason:"no canvases property"};var c=(0,ei.FZ)(s.ast),u=ek(p.value);if(G.isArrayExpression(u)){if(u.elements.some(e=>(0,ei.xn)(e,c)===i))return{file:s.relPath,status:"already_present"};var f=((e,t)=>{if(t.namespaceImports.length>0)return t.namespaceImports[0];var r=(0,er.R0)(e,"canvases");return(0,er.Pb)(e,G.importDeclaration([G.importNamespaceSpecifier(G.identifier(r))],G.stringLiteral("./canvases"))),t.namespaceImports.push(r),r})(s.ast,c);return u.elements.push(G.memberExpression(G.identifier(f),G.identifier(i))),yield eM(e,s),{file:s.relPath,status:"appended"}}var m=(0,ei.xQ)(u,c);if(m){var y=(e=>{var t=[];for(var r of e.program.body){if(G.isExportAllDeclaration(r)){if("type"===r.exportKind)continue;return{ok:!1,reason:"re-export (export *)"}}if(G.isExportDefaultDeclaration(r))return{ok:!1,reason:"default export"};if(G.isExportNamedDeclaration(r)&&"type"!==r.exportKind){if(r.source)return{ok:!1,reason:"re-export"};if(r.specifiers.length>0){if(r.specifiers.some(e=>"type"!==e.exportKind))return{ok:!1,reason:"export specifier list"};continue}var i=r.declaration;if(i&&!(G.isTSTypeAliasDeclaration(i)||G.isTSInterfaceDeclaration(i))&&!i.declare){if(!G.isVariableDeclaration(i))return{ok:!1,reason:`non-const export (${i.type})`};if("const"!==i.kind)return{ok:!1,reason:`non-const export (${i.kind})`};for(var n of i.declarations){if(!G.isIdentifier(n.id))return{ok:!1,reason:"destructured or spread export"};t.push(n.id.name)}}}}return{ok:!0,names:t}})(r.ast);return y.ok?(p.value=G.arrayExpression(y.names.map(e=>G.memberExpression(G.identifier(m.namespace),G.identifier(e)))),yield eM(e,s),{file:s.relPath,status:"converted",canvases:y.names}):{file:s.relPath,status:"kept_legacy",reason:y.reason}}return{file:s.relPath,status:"not_updated",reason:"canvases is not an array literal or Object.values(canvases)"}}),function(e,t,r,i){return C.apply(this,arguments)}),tt=(e,t,r,i,n,a)=>{for(var s=e.elements.length-1;s>=0;s-=1)(0,ei.xn)(e.elements[s],r)===t&&(e.elements.splice(s,1),a.push({action:i,path:`${n}.${s}`}))},tr=(N=L(function*(e,t){var r;return ez(e,"new_entry",t,(r=L(function*(r){if(!t.file)throw new ep("missing_file","new_entry requires file");if(!t.type)throw new ep("missing_type","new_entry requires TypeScript type");var i,n=ec(e,t.file),a=yield ef(e,n),s=new Set((0,er.Zj)(a.ast).map(e=>e.name)),o="string"==typeof t.id?t.id:void 0,l=o||"string"!=typeof t.alias||!t.alias||(yield e6(e,n,t.alias))?void 0:t.alias,d=o?G.stringLiteral(o):ej(a.kind.idType,l),p=t.entry||((e,t,r,i)=>{var n,a=(e=>{if(!e)return null;var t=e.replace(/[^a-zA-Z0-9_$]/g,"");return t?(/^[0-9]/.test(t)&&(t=`_${t}`),t):null})(i)||(r?`${t.varPrefix}${n=r.replace(/^[A-Z_]+/g,""),`${n.substr(15,3)}${n.substr(20,1)}`}`:`${t.varPrefix}Entry`);if(!e.has(a))return a;for(var s=1;e.has(`${a}${s}`);)s+=1;return`${a}${s}`})(s,a.kind,o,t.alias||t.title),c={projectDir:e,parsed:a,references:[],typeImports:new Set([t.type]),valueImports:new Set};o||c.valueImports.add("makeId");var u=yield e3(a.kind,t,d,c),f=G.variableDeclarator(G.identifier(p),u);for(var m of(f.id.typeAnnotation=G.tsTypeAnnotation(G.tsTypeReference(G.identifier(t.type))),a.ast.program.body.push(G.exportNamedDeclaration(G.variableDeclaration("const",[f]))),Object.entries(t.set||{}))){var y=F(m,2),v=y[0],h=y[1];yield eI(u,v,h,c)}for(var b of t.events||[]){if(!(0,er.u4)(b)||"string"!=typeof b.event||!b.event||!b.action)throw new ep("invalid_action","events entries require { event, action }",{event:b});var x=eX(u,"events","events");eH(x,b.event,`events.${b.event}`).elements.push((yield eW(b.action,c)))}eR(c),yield eM(r,a),"canvas"===a.kind.kind&&(i=yield te(r,e,a,p));var w=`created ${p} (${a.kind.kind}, ${ev(a.absPath)})`,g=w;return i?.status==="appended"?g=`${w} and appended to ${i.file}`:i?.status==="already_present"?g=`${w} (already listed in ${i.file})`:i?.status==="converted"?g=`${w}; converted ${i.file} from Object.values(canvases) to an explicit canvases array — existing canvases now follow canvases.ts declaration order`:i?.status==="kept_legacy"?g=`${w}; left Object.values(canvases) in ${i.file} unchanged because canvases.ts has a non-standard export (${i.reason})`:i?.status==="not_updated"&&(g=`${w}; ${i.file} was not updated (${i.reason}) — check its canvases list`),{file:a.relPath,entry:p,id:o,idExpression:o??(l?`makeId('${a.kind.idType}', '${l}')`:`makeId('${a.kind.idType}')`),change:{set:t.set||{},events:t.events||[],references:eY(c.references),...i?{indexUpdate:i}:{}},summary:g}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return N.apply(this,arguments)}),ti=(e,t)=>{var r;return G.isArrowFunctionExpression(e)&&0===e.params.length&&(r=e.body,!!r&&(G.isIdentifier(r)?r.name===t.varName:!!G.isMemberExpression(r)&&!!G.isIdentifier(r.object)&&!!G.isIdentifier(r.property)&&r.object.name===t.namespace&&r.property.name===t.varName))},tn=(e,t)=>G.isCallExpression(e)&&G.isIdentifier(e.callee,{name:"linkData"})&&ti(e.arguments[0],t),ta=(e,t)=>{if(!e)return!1;if(ti(e,t)||tn(e,t))return!0;var r=!1;return el(G.file(G.program([G.expressionStatement(G.cloneNode(e,!0))])),{ArrowFunctionExpression(e){ti(e.node,t)&&(r=!0,e.stop())},CallExpression(e){tn(e.node,t)&&(r=!0,e.stop())}}),r},ts=(e,t,r,i=[],n={})=>{if(G.isProgram(e))return void e.body.forEach((e,a)=>ts(e,t,r,[...i,String(a)],n));if(G.isExportNamedDeclaration(e)&&e.declaration)return void ts(e.declaration,t,r,i,n);if(G.isVariableDeclaration(e))return void e.declarations.forEach((e,a)=>ts(e,t,r,[...i,String(a)],n));if(G.isVariableDeclarator(e)&&e.init)return void ts(e.init,t,r,i,n);if(G.isObjectExpression(e)){for(var a=e.properties.length-1;a>=0;a-=1){var s=e.properties[a];if(G.isObjectProperty(s)){var o=(0,er.Gp)(s.key)||`property-${a}`,l=[...i,o];if(ti(s.value,t)||tn(s.value,t)){i.includes("outlets")?(e.properties.splice(a,1),r.push({action:"drop_outlet",path:l.join(".")})):n.dataCalc&&("output"===o||"error"===o)?(s.value=G.nullLiteral(),r.push({action:"null_output",path:l.join(".")})):(s.value=G.identifier("undefined"),r.push({action:"null_link",path:l.join(".")}));continue}ts(s.value,t,r,l,n)}}return}if(G.isArrayExpression(e))for(var d=i[i.length-1],p=i.includes("events")&&"events"!==d,c=n.dataCalc?["items","params","dataParams","conds","switches","inputs","outputs"]:["items","params","dataParams","conds","switches"],u=e.elements.length-1;u>=0;u-=1){var f=e.elements[u];if(f){var m=[...i,String(u)];if(ta(f,t)&&(c.includes(d)||p||ti(f,t))){e.elements.splice(u,1),r.push({action:p?"delete_event_handler":n.dataCalc&&("inputs"===d||"outputs"===d)?"remove_io_item":"remove_reference_item",path:m.join(".")});continue}ts(f,t,r,m,n)}}},to=(e,t)=>G.isObjectExpression(e)&&"DataCalculationData"===(0,er.JJ)(e,"__typename")&&ti((0,er.bf)(e,"data")?.value,t),tl=(e,t)=>{var r=G.isArrowFunctionExpression(e)&&0===e.params.length?e.body:e;return G.isIdentifier(r)&&t.has(r.name)},td=(e,t)=>{var r=[];return el(e,{ArrowFunctionExpression(e){ti(e.node,t)&&r.push({type:"ref",loc:e.node.loc?.start})},CallExpression(e){tn(e.node,t)&&r.push({type:"link",loc:e.node.loc?.start})}}),r},tp=(e,t)=>{var r=e.ast.program.body.indexOf(t.node);r>=0&&e.ast.program.body.splice(r,1)},tc=(R=L(function*(e,t,r){if("project"===r)return ew(e);var i=eh(t),n=yield ex(i),a=Q.join(i,"data-calc"),s=yield(0,X.readdir)(a,{withFileTypes:!0}).catch(()=>[]);return[...n,...s.filter(e=>e.isFile()&&e.name.endsWith(".ts")).map(e=>Q.join(a,e.name))]}),function(e,t,r){return R.apply(this,arguments)}),tu=(T=L(function*(e,t){var r;return ez(e,"remove_entry",t,(r=L(function*(r){var i,n=yield e_(e,t),a=n.parsed,s=n.entry,o={varName:s.name,namespace:a.kind.namespace,id:s.id},l=yield tc(e,a.absPath,t.scope),d=[],p=yield Promise.all(l.map((i=L(function*(t){var r=yield(0,X.readFile)(t,"utf8");return{absPath:t,relPath:(0,er.RI)(e,t),source:r,ast:eu(r,(0,er.RI)(e,t)),kind:ed[Q.basename(t)]||a.kind}}),function(e){return i.apply(this,arguments)}))),c=function*(e){var t,r,i,n=e.absPath===a.absPath?(t=s.name,r=G.cloneNode(e.ast,!0),i={...e,ast:r},tp(i,ey(i,{entry:t})),i):e;td(n.ast,o).forEach(t=>d.push({file:e.relPath,...t}))};for(var u of p)yield*c(u);var f=null,m=null,y=null,v=[],h=null;if("canvas"===a.kind.kind){var b=yield e7(e,eh(a.absPath));if((f=b.parsed)||!b.skippedReason||(h=`${b.relPath} was not updated (${b.skippedReason})`),f){for(var x of(m=(0,ei.Xn)(f.ast),v=((y=(0,ei.FZ)(f.ast)).namespaceImports.length>0?[...new Set(y.namespaceImports)]:[o.namespace]).map(e=>({...o,namespace:e})),y.namedImports)){var w=F(x,2),g=w[0];w[1]===o.varName&&g!==o.varName&&v.push({...o,varName:g})}var _=m?(0,er.bf)(m,"rootCanvas"):null;if(_&&(0,ei.xn)(_.value,y)===o.varName)if(t.strict)d.push({file:f.relPath,type:"rootCanvas",loc:_.value.loc?.start});else throw new ep("invalid_item",`Cannot remove rootCanvas ${s.name} of ${f.relPath}`,{file:f.relPath,entry:s.name});var j=new Set;for(var P of v)for(var k of td(f.ast,P)){var E=`${k.type}:${k.loc?.line}:${k.loc?.column}`;j.has(E)||(j.add(E),d.push({file:f.relPath,...k}))}}}if(t.strict&&d.length>0)return{file:a.relPath,entry:s.name,id:s.id,outcome:"refused",touchedSites:d,verify:{status:"skipped",errors:[]},summary:`refused to remove ${eq(a,s)}; ${d.length} reference(s) found`};var $=function*(t){var i=[],n={dataCalc:t.absPath.split(Q.sep).includes("data-calc")};if(n.dataCalc&&((e,t,r)=>{for(var i=new Set,n=e.program.body,a=n.length-1;a>=0;a-=1){var s=n[a],o=G.isExportNamedDeclaration(s)?s.declaration:s;G.isVariableDeclaration(o)&&(o.declarations=o.declarations.filter(e=>!(G.isIdentifier(e.id)&&to(e.init,t))||(i.add(e.id.name),r.push({action:"remove_calc_node",path:e.id.name}),!1)),0===o.declarations.length&&n.splice(a,1))}if(0!==i.size){var l=[],d=new Set;for(var p of(el(e,{ArrayExpression(e){if(!e.findParent(e=>d.has(e.node))){var t=e.parentPath.isObjectProperty()?(0,er.Gp)(e.parent.key):void 0;e.node.elements.forEach((n,a)=>{(tl(n,i)||G.isObjectExpression(n)&&["node","source","target"].some(e=>tl((0,er.bf)(n,e)?.value,i)))&&(d.add(n),l.push({elements:e.node.elements,index:a}),r.push({action:"inputs"===t||"outputs"===t?"remove_io_item":"remove_reference_item",path:`${(e=>{for(var t=[],r=e;r&&!r.isProgram();r=r.parentPath){if(r.isVariableDeclarator()){G.isIdentifier(r.node.id)&&t.unshift(r.node.id.name);break}"elements"===r.listKey&&t.unshift(String(r.key)),r.isObjectProperty()&&t.unshift((0,er.Gp)(r.node.key))}return t.join(".")})(e)}.${a}`}))})}}}),l.reverse())){var c=p.elements,u=p.index;c.splice(u,1)}}})(t.ast,o,i),t.absPath===a.absPath&&(tp(t,ey(t,{entry:s.name})),i.push({action:"remove_entry",path:s.name})),ts(t.ast.program,o,i,[],n),0===i.length)return 1;var l=yield eU(t);eu(l,t.relPath),yield r.writeFile((yield em(e,t.absPath)),l),i.forEach(e=>d.push({file:t.relPath,...e}))};for(var S of p)if(yield*$(S))continue;if(f&&m){var I=[],A=(0,er.bf)(m,"canvases");if(A){var O=ek(A.value);G.isArrayExpression(O)?tt(O,o.varName,y,"remove_canvas_registration","canvases",I):!(0,ei.xQ)(O,y)&&((e,t,r)=>{if(!e)return!1;if((0,ei.xn)(e,r)===t)return!0;var i=!1;return el(G.file(G.program([G.expressionStatement(G.cloneNode(e,!0))])),{MemberExpression(e){(0,ei.xn)(e.node,r)===t&&(i=!0,e.stop())},Identifier(e){e.isReferencedIdentifier()&&(0,ei.xn)(e.node,r)===t&&(i=!0,e.stop())}}),i})(O,o.varName,y)&&(h=`${f.relPath} canvases property references ${s.name} in a non-array expression and was not updated`)}var C=(0,er.bf)(m,"unexpanded"),N=C?ek(C.value):null;if(N&&G.isObjectExpression(N)){var R=(0,er.bf)(N,"canvas"),T=R?ek(R.value):null;T&&G.isArrayExpression(T)&&tt(T,o.varName,y,"remove_unexpanded_canvas","unexpanded.canvas",I)}for(var D of v)ts(m,D,I,[],{dataCalc:!1});((e,t)=>{for(var r=e.program.body,i=!1,n=r.length-1;n>=0;n-=1){var a=r[n];if(G.isImportDeclaration(a)&&"type"!==a.importKind&&(0,ei.Ux)(a.source.value)){var s=a.specifiers.length;a.specifiers=a.specifiers.filter(e=>{var r=(0,ei.kO)(e);return!r||r!==t}),a.specifiers.length<s&&(i=!0,0===a.specifiers.length&&r.splice(n,1))}}return i})(f.ast,o.varName)&&I.push({action:"remove_canvas_import",path:o.varName}),I.length>0&&(yield eM(r,f),I.forEach(e=>d.push({file:f.relPath,...e})))}var B=`removed ${eq(a,s)} with ${d.length} touched site(s)`;return{file:a.relPath,entry:s.name,id:s.id,touchedSites:d,summary:h?`${B}; ${h}`:B}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return T.apply(this,arguments)}),tf=(D=L(function*(e,t){var r;return ez(e,"new_subspace",t,(r=L(function*(r){var i=Q.join(e,"root.ts"),n=(0,er.RI)(e,i),a=yield(0,X.readFile)(i,"utf8").catch(()=>null);if(null==a)throw new ep("invalid_file","Project has no root.ts to wire the subspace into");var s={source:a,ast:eu(a,n),projectDir:e,absPath:i,relPath:n},o=s.ast.program.body.find(e=>G.isExportDefaultDeclaration(e));if(!o||!G.isArrayExpression(o.declaration))throw new ep("fallback_recommended","root.ts default export is not a subspace array literal; wire the new subspace manually",{file:n});var l=(yield eb(e)).reduce((e,t)=>{var r=/^subspace-(\d+)$/.exec(Q.basename(t));return r?Math.max(e,Number(r[1])):e},-1)+1,d=`subspace-${l}`,p=Q.join(e,"subspaces",d),c=`SUBSPACE_${(0,H.randomUUID)()}`,u=`CANVAS_${(0,H.randomUUID)()}`,f=(({subspaceId:e,canvasId:t,title:r,description:i,layout:n,portal:a})=>{var s=[`width: ${n.width}`,`height: ${n.height}`,...n.resizeMode?[`resizeMode: '${n.resizeMode}'`]:[]];return{"data.ts":"import type { Data } from 'bricks-ctor'\n","bricks.ts":"import type { Brick } from 'bricks-ctor'\n","generators.ts":"import type { Generator } from 'bricks-ctor'\n","animations.ts":"import type { Animation } from 'bricks-ctor'\n","canvases.ts":`import type { Canvas } from 'bricks-ctor'
|
|
2
2
|
|
|
3
3
|
export const cMain: Canvas = {
|
|
4
4
|
__typename: 'Canvas',
|
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
portal: '${a}',`:""}
|
|
27
27
|
layout: { ${s.join(", ")} },
|
|
28
28
|
rootCanvas: canvases.cMain,
|
|
29
|
-
canvases:
|
|
29
|
+
canvases: [canvases.cMain],
|
|
30
30
|
animations: Object.values(animations),
|
|
31
31
|
bricks: Object.values(bricks),
|
|
32
32
|
generators: Object.values(generators),
|
|
@@ -37,4 +37,4 @@ export default {
|
|
|
37
37
|
} as Subspace
|
|
38
38
|
|
|
39
39
|
export { bricks, generators, canvases, data }
|
|
40
|
-
`}})({subspaceId:c,canvasId:u,title:t.title,description:t.description??"",layout:{width:t.layout?.width??96,height:t.layout?.height??54,resizeMode:t.layout?.resizeMode},portal:t.portal});yield r.mkdir(
|
|
40
|
+
`}})({subspaceId:c,canvasId:u,title:t.title,description:t.description??"",layout:{width:t.layout?.width??96,height:t.layout?.height??54,resizeMode:t.layout?.resizeMode},portal:t.portal});yield r.mkdir(Q.join(p,"data-calc"));var m=[];for(var y of Object.entries(f)){var v=F(y,2),h=v[0],b=v[1],x=Q.join(p,h),w=yield(0,W.format)(x,b,er.Hn);yield r.writeFile((yield em(e,x)),w.errors.length>0?b:w.code),m.push((0,er.RI)(e,x))}var g=eN(s,`./subspaces/${d}`,`subspace${l}`);return o.declaration.elements.push(G.identifier(g)),yield eM(r,s),{subspace:d,id:c,index:l,files:m,change:{op:"new_subspace",rootImport:g},summary:`new_subspace ${d} (${t.title}) wired into root.ts`}}),function(e){return r.apply(this,arguments)}))}),function(e,t){return D.apply(this,arguments)}),tm=e=>({content:[{type:"text",text:JSON.stringify(e,null,2)}],isError:e.isError||void 0}),ty=ee.bz().describe('Value grammar: JSON scalars/arrays/objects emit literals; { link: "dataIdOrAlias" } emits linkData(() => data.dX) for property/data-link values; { ref: "idOrAliasOrVar", subspace?: "subspace-1"|1|"SUBSPACE_id" } emits () => namespace.varName; { expr: "raw TypeScript expression" } is spliced verbatim.'),tv=ee.Yj().describe("Dotted entry path to edit, for example title, property.url, outlets.response, animation.showStart, value, type, switches[0].property.text, or items[0].frame."),th=ee.Yj().describe("Project-relative entry file path, for example subspaces/subspace-0/bricks.ts, generators.ts, canvases.ts, data.ts, or animations.ts."),tb=ee.Yj().describe("Exported const name or entity alias to edit, for example bWelcomeText, gApiClient, cMain, or an alias like welcomeText."),tx=ee.Yj().describe("Entry id fallback. When file is omitted, scans project subspaces for this id."),tw=ee.zM().describe("Override compile verification for this call. Defaults to BRICKS_CTOR_MCP_EDIT_VERIFY, otherwise true."),tg={file:th.optional(),entry:tb.optional(),id:tx.optional(),verify:tw.optional()};function t_(e,t){var r,i,n,a,s,o,l;e.tool("edit_entry","Edit map-shaped facets on an existing bricks-ctor entry by source AST. Use set/unset with dotted paths and the shared value grammar."+et.Yl,{...tg,set:ee.g1(tv,ty).describe("Map of dotted paths to values. Values use the shared grammar: JSON literals, { link }, { ref }, or { expr }.").optional(),unset:ee.YO(tv).describe("Dotted paths to remove.").optional(),switch:ee.KC([ee.Yj(),ee.ai()]).describe("Optional switch id or zero-based switch index; edits that switch object instead of the entry root.").optional()},(r=L(function*(e){return tm((yield eV(t,e)))}),function(e){return r.apply(this,arguments)})),e.tool("edit_events","Edit an event action array on an entry or switch. Adds/removes/replaces/moves/clears EventAction objects."+et.Yl,{...tg,event:ee.Yj().describe("Camel-case source event key such as onPress, showStart, update, enter, or firstEnter."),op:ee.k5(["add","remove","replace","move","clear"]).describe("Array operation. add inserts at index or appends; replace/remove require index; move reorders index to `to`; clear removes the event key."),index:ee.ai().describe("Zero-based event action index. For add this is the insertion position.").optional(),to:ee.ai().describe("Destination zero-based index for move.").optional(),action:ty.describe('For add/replace, the flattened form: { handler: "system"|{ref}|{subspace: "subspace-1"|1|"SUBSPACE_id"}, name: "ACTION_NAME", params?: { inputName: value }, dataParams?: { dataRef: value }, cast?: "TypeName", waitAsync?: boolean }. Cross-subspace {subspace} handlers emit a () => subspaceN getter; the emitting subspace itself stays a literal id. The compiled source form { handler, action: { name, params: [...], dataParams: [...] }, waitAsync } and { expr: "raw EventAction" } are also accepted.').optional(),switch:ee.KC([ee.Yj(),ee.ai()]).describe("Optional switch id or zero-based switch index; edits that switch events object.").optional()},(i=L(function*(e){return tm((yield eQ(t,e)))}),function(e){return i.apply(this,arguments)})),e.tool("edit_canvas_items","Edit a Canvas entry items array. Use add/remove/replace to place bricks or move to update an item frame."+et.Yl,{...tg,op:ee.k5(["add","remove","replace","move"]).describe("Canvas item operation. add inserts/appends, replace/remove use index, move updates frame at index."),index:ee.ai().describe("Zero-based canvas item index.").optional(),item:ty.describe('For add/replace: { ref: "brickIdOrAliasOrVar", subspace?: ..., frame: { x, y, width, height, ... }, hidden?: boolean } places a brick; { subspace: "subspace-1"|1|"SUBSPACE_id", frame: ..., animations?: { showStart?, standby?, breatheStart?: { ref: "animationIdOrAliasOrVar" } } } without ref embeds that subspace (emits a () => subspaceN getter; item animations are for an embedded subspace only, a brick keeps its animations on the brick). Frames require numeric x/y/width/height.').optional(),frame:ty.describe("Replacement frame such as { x, y, width, height }. Required for move; for add/replace it is used when item.frame is omitted.").optional()},(n=L(function*(e){return tm((yield e4(t,e)))}),function(e){return n.apply(this,arguments)})),e.tool("edit_switches","Edit an entry switches array. Use edit_entry/edit_events with switch when changing switch facet bodies."+et.Yl,{...tg,op:ee.k5(["add","remove","replace","move"]).describe("Switch array operation. add inserts/appends, replace/remove use index, move reorders to `to`."),index:ee.KC([ee.Yj(),ee.ai()]).describe("Switch id or zero-based switch index. For add, this is optional insertion position.").optional(),to:ee.ai().describe("Destination zero-based index for move.").optional(),switch:ty.describe('For add/replace: { id? (BRICK_STATE_GROUP_<uuid>; omit to auto-generate), title?, description?, conds?: [{ method: "=="|"!="|">"|"<"|">="|"<=", cond }], override?: { animation?, event?, property?, outlet? }, property?, outlets?, animation?, disabled?, break? }. Cond forms: { type: "inner_state", key: "current_canvas", value: canvasRef }, { type: "inner_state", outlet: "outletName", value }, { type: "property_bank", ref: dataRef, value }, { type: "property_bank_by_item_key", ref: dataRef, value }, { type: "item_key_mapping", key: "<item field path>", value }, a compiled { __typename: "SwitchCond..." } object, or { expr }. Set switch events with edit_events using its switch parameter.').optional()},(a=L(function*(e){return tm((yield e2(t,e)))}),function(e){return a.apply(this,arguments)})),e.tool("new_entry","Create a minimal standard-style exported entry skeleton in an entry file, then optionally apply set/events edits. For canvases.ts, also appends the new canvas to the subspace index.ts canvases array (move it there if it belongs earlier in the flow)."+et.Yl,{file:th,entry:tb.describe("Optional exported const name. Defaults from alias/title/id.").optional(),templateKey:ee.Yj().describe("Brick/generator templateKey such as BRICK_TEXT or GENERATOR_HTTP.").optional(),type:ee.Yj().describe("TypeScript type imported from bricks-ctor, for example BrickText, GeneratorHTTP, Canvas, Data, or Animation."),alias:ee.Yj().describe("Optional entry alias. Also influences default exported const name.").optional(),title:ee.Yj().describe("Optional entry title.").optional(),description:ee.Yj().describe("Optional entry description.").optional(),id:tx.describe("Optional explicit id. If omitted, the tool generates one with the file-kind prefix.").optional(),dataType:ee.Yj().describe("For data.ts only: initial Data.type value. Defaults to any.").optional(),set:ee.g1(tv,ty).describe("Optional initial dotted-path values applied after creating the skeleton. Values use JSON literals, { link }, { ref }, or { expr }.").optional(),events:ee.YO(ty).describe("Optional initial event actions as objects with { event, action }.").optional(),verify:tw.optional()},(s=L(function*(e){return tm((yield tr(t,e)))}),function(e){return s.apply(this,arguments)})),e.tool("remove_entry","Remove an entry. By default cascades same-subspace references in standard entry object/array shapes (and removes a canvas from the subspace index.ts canvases array); strict mode refuses when references exist."+et.Yl,{...tg,strict:ee.zM().describe("When true, do not edit files; refuse and return reference sites if the entry is referenced.").optional(),scope:ee.k5(["subspace","project"]).describe("Reference scan scope. subspace is default; project scans all subspaces.").optional()},(o=L(function*(e){return tm((yield tu(t,e)))}),function(e){return o.apply(this,arguments)})),e.tool("new_subspace","Scaffold a new subspaces/subspace-N directory (standard entry files + root canvas, fixed SUBSPACE_ id) and wire it into root.ts. Embed it afterwards with edit_canvas_items { subspace } or target it with edit_events { handler: { subspace } }."+et.Yl,{title:ee.Yj().describe("Subspace title shown in the editor."),description:ee.Yj().describe("Optional subspace description.").optional(),layout:ee.Ik({width:ee.ai(),height:ee.ai(),resizeMode:ee.k5(["cover","stretch"]).optional()}).describe("Subspace grid the embed frame scales; defaults to { width: 96, height: 54 }. Use a smaller grid plus resizeMode: 'stretch' for panel modules.").optional(),portal:ee.k5(["top","left","bottom","right"]).describe("Dock the subspace to a viewport edge as an always-on overlay instead of a canvas-embeddable module.").optional(),verify:tw.optional()},(l=L(function*(e){return tm((yield tf(t,e)))}),function(e){return l.apply(this,arguments)}))}var tj={editEntry:eV,editEvents:eQ,editCanvasItems:e4,editSwitches:e2,newEntry:tr,newSubspace:tf,removeEntry:tu,resolveReference:eL};i()}catch(e){i(e)}})}};
|
package/lib/4456.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const __rspack_esm_id=4456;export const __rspack_esm_ids=[4456];export const __webpack_modules__={44187(e){e.exports=function(e,t,i,n){var o=-1,r=null==e?0:e.length;for(n&&r&&(i=e[++o]);++o<r;)i=t(i,e[o],o,e);return i}},39546(e){var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},51035(e){e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},93640(e,t,i){var n=i(44187),o=i(45881),r=i(39850),u=RegExp("['’]","g");e.exports=function(e){return function(t){return n(r(o(t).replace(u,"")),e,"")}}},69968(e,t,i){e.exports=i(51035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})},15813(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},10482(e){var t="\\ud800-\\udfff",i="\\u2700-\\u27bf",n="a-z\\xdf-\\xf6\\xf8-\\xff",o="A-Z\\xc0-\\xd6\\xd8-\\xde",r="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u="['’]",a="["+r+"]",l="["+n+"]",
|
|
1
|
+
export const __rspack_esm_id=4456;export const __rspack_esm_ids=[4456];export const __webpack_modules__={44187(e){e.exports=function(e,t,i,n){var o=-1,r=null==e?0:e.length;for(n&&r&&(i=e[++o]);++o<r;)i=t(i,e[o],o,e);return i}},39546(e){var t=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;e.exports=function(e){return e.match(t)||[]}},51035(e){e.exports=function(e){return function(t){return null==e?void 0:e[t]}}},93640(e,t,i){var n=i(44187),o=i(45881),r=i(39850),u=RegExp("['’]","g");e.exports=function(e){return function(t){return n(r(o(t).replace(u,"")),e,"")}}},69968(e,t,i){e.exports=i(51035)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"})},15813(e){var t=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;e.exports=function(e){return t.test(e)}},10482(e){var t="\\ud800-\\udfff",i="\\u2700-\\u27bf",n="a-z\\xdf-\\xf6\\xf8-\\xff",o="A-Z\\xc0-\\xd6\\xd8-\\xde",r="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",u="['’]",a="["+r+"]",l="["+n+"]",s="[^"+t+r+"\\d+"+i+n+o+"]",c="(?:\\ud83c[\\udde6-\\uddff]){2}",d="[\\ud800-\\udbff][\\udc00-\\udfff]",f="["+o+"]",p="(?:"+l+"|"+s+")",g="(?:"+f+"|"+s+")",h="(?:"+u+"(?:d|ll|m|re|s|t|ve))?",m="(?:"+u+"(?:D|LL|M|RE|S|T|VE))?",x="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",y="[\\ufe0e\\ufe0f]?",v="(?:\\u200d(?:"+["[^"+t+"]",c,d].join("|")+")"+y+x+")*",b="(?:"+["["+i+"]",c,d].join("|")+")"+(y+x+v),A=RegExp([f+"?"+l+"+"+h+"(?="+[a,f,"$"].join("|")+")",g+"+"+m+"(?="+[a,f+p,"$"].join("|")+")",f+"?"+p+"+"+h,f+"+"+m,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",b].join("|"),"g");e.exports=function(e){return e.match(A)||[]}},45881(e,t,i){var n=i(69968),o=i(95243),r=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,u=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");e.exports=function(e){return(e=o(e))&&e.replace(r,n).replace(u,"")}},10750(e,t,i){e.exports=i(93640)(function(e,t,i){return e+(i?"-":"")+t.toLowerCase()})},39850(e,t,i){var n=i(39546),o=i(15813),r=i(95243),u=i(10482);e.exports=function(e,t,i){return(e=r(e),void 0===(t=i?void 0:t))?o(e)?u(e):n(e):e.match(t)||[]}},58891(e,t,i){i.r(t),i.d(t,{initProject:()=>p});var n,o,r=i(99436),u=i(16928),a=i(73284),l=i(14636),s=i(27521),c=i(56493),d=i(77768),f=(n=r(function*(e,t){console.log(a.default.bold.cyan(`
|
|
2
2
|
Initialize BRICKS Project: ${t}
|
|
3
|
-
`));var i=yield(0,
|
|
3
|
+
`));var i=yield(0,s.checkbox)({message:"Select files to include:",choices:[{name:"GitHub Actions workflow (.github/workflows/ci.yml)",value:"githubActions",checked:!1!==e.githubActions},{name:"AGENTS.md",value:"agents",checked:!1!==e.agents},{name:"CLAUDE.md",value:"claude",checked:!1!==e.claude},{name:"GEMINI.md",value:"gemini",checked:!0===e.gemini}]}),n=yield(0,s.checkbox)({message:"Select post-generation steps:",choices:[{name:"Run bun install",value:"install",checked:!1!==e.install},{name:"Initialize git repository",value:"git",checked:!1!==e.git}]}),o=e.output?u.resolve(e.output):u.join(process.cwd(),t),r=yield(0,s.input)({message:"Output directory:",default:o});return{githubActions:i.includes("githubActions"),agents:i.includes("agents"),claude:i.includes("claude"),gemini:i.includes("gemini"),install:n.includes("install"),git:n.includes("git"),output:r,outputAsTarget:!0}}),function(e,t){return n.apply(this,arguments)}),p=(o=r(function*(e,t,i){var n=(0,c.requireAuth)(),o=i.json,r=i.yes||o,s="application"===e?n.applicationProject:n.moduleProject,p=o?null:(0,l.default)(`Fetching ${e} info...`).start(),g="bricks-ctor";try{var h=yield s({id:t,buildApplicationOnly:!0});h?.files&&(g=(0,d.kU)(h.files)),p&&p.stop()}catch{p&&p.stop()}var m={...i};if(!r)try{var x=yield f(i,g);m={...i,...x}}catch{console.log(a.default.yellow("\nCancelled")),process.exit(0)}p=o?null:(0,l.default)(`Fetching ${e} project...`).start();var y=!!m.output;try{var v=yield(0,d.BZ)(e,t,{client:n,output:y?m.output:process.cwd(),outputAsTarget:y||!0===m.outputAsTarget,install:m.install,git:m.git,githubActions:m.githubActions,agents:m.agents,claude:m.claude,gemini:m.gemini});p&&p.succeed(`Project created: ${a.default.green(v.path)} (${v.files} files)`),!o&&v.warnings.length>0&&(console.log(""),console.log(a.default.yellow("Warning: the project source does not keep this config data:")),v.warnings.forEach(e=>console.log(a.default.yellow(` - ${e}`)))),o?console.log(JSON.stringify(v)):(console.log(""),console.log(a.default.bold.green("Project initialized successfully!")),console.log(""),console.log(a.default.bold("Next steps:")),console.log(a.default.gray(` cd ${u.basename(v.path)}`)),v.bunInstalled||console.log(a.default.gray(" bun install")),console.log(a.default.gray(" bun invoke-simulator")),console.log(""),console.log(a.default.gray(`For more information, see ${u.basename(v.path)}/README.md`)))}catch(t){o?console.error(JSON.stringify({error:t.message})):p?p.fail(`Failed to initialize ${e} project: ${t.message}`):console.error(a.default.red(`Failed to initialize ${e} project: ${t.message}`)),process.exit(1)}}),function(e,t,i){return o.apply(this,arguments)})},77768(e,t,i){i.d(t,{BZ:()=>y,KN:()=>h,kU:()=>g,o0:()=>x,oz:()=>m});var n,o,r,u,a=i(99436),l=i(16928),s=i(79896),c=i(35317),d=i(10750),f=(e,t,i)=>new Promise((n,o)=>{var r=(0,c.spawn)(e,t,{cwd:i,stdio:["pipe","ignore","pipe"]}),u=[];r.stderr.on("data",e=>u.push(e)),r.on("close",e=>{0===e?n():o(Error(Buffer.concat(u).toString().trim()||`Command failed with code ${e}`))}),r.on("error",o)}),p=(n=a(function*(e,t){try{var n=(yield i.e(7456).then(i.bind(i,79491))).format;return(yield n(t,e,{trailingComma:"all",tabWidth:2,semi:!1,singleQuote:!0,printWidth:100})).code}catch{}return e}),function(e,t){return n.apply(this,arguments)}),g=(e=[])=>{var t=e.find(e=>"application.json"===e.name);if(!t)return"bricks-ctor";try{var i=JSON.parse(t.input);return d(i.name||"bricks-ctor")}catch{return"bricks-ctor"}},h=(o=a(function*(e,t){var i;return Promise.all(e.map((i=a(function*(e){var i=l.join(t,e.name),n=e.input;return e.formatable&&(n=yield p(n,i)),{...e,filePath:i,content:n}}),function(e){return i.apply(this,arguments)})))}),function(e,t){return o.apply(this,arguments)}),m=e=>{e.forEach(e=>{s.mkdirSync(l.dirname(e.filePath),{recursive:!0}),s.writeFileSync(e.filePath,e.content)})},x=(r=a(function*(e,t={}){var i="function"==typeof t.onStatus?t.onStatus:()=>{},n=!1,o=!1;if(!1!==t.install){i("Installing dependencies (bun install)...");try{yield f("bun",["install"],e),n=!0}catch{}}if(!1!==t.git){i("Initializing git repository...");try{yield f("git",["init"],e),yield f("git",["add","."],e),yield f("git",["-c","user.name=BRICKS CLI","-c","user.email=cli@bricks.tools","commit","-m","chore: initialize commit"],e),o=!0}catch{}}return{bunInstalled:n,gitInitialized:o}}),function(e){return r.apply(this,arguments)}),y=(u=a(function*(e,t,i){var n=i.client,o=i.output,r=i.outputAsTarget;if(!n)throw Error("client is required");if(!o)throw Error("output directory is required");var u=(e=>{for(var t=l.resolve(e);;){if(s.existsSync(l.join(t,"application.json"))||s.existsSync(l.join(t,"module.json")))return t;var i=l.dirname(t);if(i===t)return null;t=i}})(r?l.dirname(l.resolve(o)):o);if(u)throw Error(`Cannot initialize a new BRICKS project inside an existing project (${u}). Choose a directory outside the project.`);var a="application"===e?n.applicationProject:n.moduleProject,c=yield a({id:t,buildApplicationOnly:!1,setupGitHubActions:!1!==i.githubActions,setupAgents:!1!==i.agents,setupClaudeCode:!1!==i.claude,setupGeminiCLI:!0===i.gemini});if(!c?.files)throw Error(`${e} project not found`);var d=g(c.files),f=r?l.resolve(o):l.resolve(o,d);if(s.existsSync(f))throw Error(`Directory already exists: ${f}`);s.mkdirSync(f,{recursive:!0}),m((yield h(c.files,f)));var p=yield x(f,i),y=p.bunInstalled,v=p.gitInitialized;return{success:!0,path:f,files:c.files.length,warnings:c.warnings||[],bunInstalled:y,gitInitialized:v}}),function(e,t,i){return u.apply(this,arguments)})}};
|