likec4 1.41.0 → 1.42.0
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/__app__/src/likec4.js +11659 -12120
- package/__app__/src/main.js +185 -129
- package/__app__/src/style.css +1 -1
- package/__app__/src/vendors.js +38519 -17031
- package/__app__/src/webcomponent.js +68 -0
- package/config/package.json +2 -2
- package/config/schema.json +575 -0
- package/dist/cli/index.mjs +557 -553
- package/dist/config/index.d.mts +4 -1
- package/dist/config/index.mjs +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +47 -4
- package/dist/model/index.mjs +1 -1
- package/dist/shared/likec4.B5Q51Z1F.mjs +543 -0
- package/dist/shared/likec4.BCSBNe4z.d.mts +6808 -0
- package/dist/shared/likec4.CB2-Uaub.mjs +47 -0
- package/dist/shared/likec4.CJVbsoPD.mjs +256 -0
- package/dist/shared/{likec4.3AlS7pfZ.d.mts → likec4.CaOUU1HJ.d.mts} +204 -149
- package/dist/shared/likec4.DOUP9ptn.mjs +1 -0
- package/dist/shared/{likec4.C8C0fF8a.mjs → likec4.DO_7oUns.mjs} +1 -1
- package/dist/shared/likec4.DdxVkEIS.mjs +4038 -0
- package/dist/vite-plugin/index.d.mts +4 -3
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal.mjs +3 -3
- package/icons/all/package.json +4 -0
- package/model/builder/package.json +4 -0
- package/model/package.json +4 -0
- package/package.json +42 -42
- package/react/index.d.ts +6655 -0
- package/react/index.js +48628 -0
- package/react/package.json +3 -2
- package/vite-plugin/package.json +2 -2
- package/vite-plugin-modules.d.ts +5 -5
- package/__app__/src/webcomponent.tsx +0 -81
- package/dist/shared/likec4.CdNNo2L4.mjs +0 -1
- package/dist/shared/likec4.CxmGAh_J.mjs +0 -144
- package/dist/shared/likec4.DX1wM3Or.d.mts +0 -1704
- package/dist/shared/likec4.Db3cTW-C.mjs +0 -257
- package/dist/shared/likec4.bxIrQhth.mjs +0 -4174
- package/react/index.d.mts +0 -6578
- package/react/index.mjs +0 -185
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import{isStepEdgeId as rt,getParallelStepsPrefix as it}from"@likec4/core/types";import{Stack as D,isAncestor as G,nonNullable as E,invariant as C,nonexhaustive as st,DefaultMap as nt}from"@likec4/core/utils";import{t as v,e as ot,a as X}from"./likec4.DOUP9ptn.mjs";const at={done:!0,hasNext:!1},H={done:!1,hasNext:!1},lt=()=>at,U=o=>({hasNext:!0,next:o,done:!1});function j(o,...t){let e=o,r=t.map(s=>"lazy"in s?ht(s):void 0),i=0;for(;i<t.length;){if(r[i]===void 0||!ct(e)){let l=t[i];e=l(e),i+=1;continue}
|
|
2
|
+
let s=[];for(let l=i;l<t.length;l++){let c=r[l];if(c===void 0||(s.push(c),c.isSingle))break}let n=[];for(let l of e)if(T(l,n,s))break;let{isSingle:a}=s.at(-1);e=a?n[0]:n,i+=s.length}return e}function T(o,t,e){if(e.length===0)return t.push(o),!1;let r=o,i=H,s=!1;for(let[n,a]of e.entries()){let{index:l,items:c}=a;if(c.push(r),i=a(r,l,c),a.index+=1,i.hasNext){if(i.hasMany??!1){for(let u of i.next)if(T(u,t,e.slice(n+1)))return!0;return s}r=i.next}if(!i.hasNext)break;i.done&&(s=!0)}return i.hasNext&&
|
|
3
|
+
t.push(r),s}function ht(o){let{lazy:t,lazyArgs:e}=o,r=t(...e);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function ct(o){return typeof o=="string"||typeof o=="object"&&!!o&&Symbol.iterator in o}function I(...o){return v(ut,o)}const ut=(o,t)=>o.length>=t;function ft(o,t){return typeof o=="object"?Y(o,t):ot(Y,[],dt)}const Y=(o,t)=>t===void 0?o.flat():o.flat(t),dt=o=>o===void 0||o===1?mt:o<=0?U:t=>Array.isArray(t)?{next:t.flat(o-1),hasNext:!0,hasMany:!0,done:!1}:{next:t,hasNext:!0,
|
|
4
|
+
done:!1},mt=o=>Array.isArray(o)?{next:o,hasNext:!0,hasMany:!0,done:!1}:{next:o,hasNext:!0,done:!1};function W(...o){return v(pt,o)}const pt=(o,t)=>{let e=Object.create(null);for(let r=0;r<o.length;r++){let i=o[r],s=t(i,r,o);if(s!==void 0){let n=e[s];n===void 0?e[s]=[i]:n.push(i)}}return Object.setPrototypeOf(e,Object.prototype),e};function wt(...o){return v(_t,o)}function _t(o,t){let e=Object.create(null);for(let r of o){let i=r?.[t];if(i!==void 0){let s=e[i];s===void 0?e[i]=[r]:s.push(r)}}return Object.
|
|
5
|
+
setPrototypeOf(e,Object.prototype),e}function J(...o){return v(bt,o)}const bt=o=>o.at(-1);function A(...o){return v(gt,o,yt)}const gt=(o,t)=>o.map(t),yt=o=>(t,e,r)=>({done:!1,hasNext:!0,next:o(t,e,r)});function xt(...o){return v(vt,o)}const vt=o=>o.length===1?o[0]:void 0;function q(...o){return v(Object.values,o)}const Z=60,Mt=32,M=80,K=32,Q=50,tt=30,Et=22;function S(){return new O}class O{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(t){return this.
|
|
6
|
+
array[t]}contains(t){return this.index[t.id()]!==void 0}find(t){const e=this.index[t.id()];return e===void 0?void 0:this.array[e]}setDefault(t,e){const r=this.index[t.id()];if(r===void 0){const i=new R(t,e());return this.index[t.id()]=this.array.length,this.array.push(i),i}else return this.array[r]}insert(t,e){const r=new R(t,e),i=this.index[t.id()];return i===void 0?(this.index[t.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(t){const e=this.index[t.id()];if(e===void 0)return;
|
|
7
|
+
this.index[t.id()]=void 0;const r=this.array[e],i=this.array.pop();return r!==i&&(this.array[e]=i,this.index[i.first.id()]=e),r}copy(){const t=new O;for(let e=0;e<this.array.length;e++){const r=this.array[e].copy();t.array[e]=r,t.index[r.first.id()]=e}return t}}class R{first;second;constructor(t,e){this.first=t,this.second=e}copy(){return new R(this.first,this.second)}}class L{constructor(t=""){this._name=t}id(){return this._id}name(){return this._name}setName(t){this._name=t}context(){return this.
|
|
8
|
+
_context}setContext(t){this._context=t}value(){return this._value}setValue(t){this._value=t}plus(t){return new g(this,t)}minus(t){return new g(this,typeof t=="number"?-t:[-1,t])}multiply(t){return new g([t,this])}divide(t){return new g([1/t,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+"["+this._name+":"+this._value+"]"}_name;_value=0;_context=null;_id=St++}let St=0;class g{constructor(){let t=kt(arguments);this._terms=t.terms,this._constant=t.constant}terms(){
|
|
9
|
+
return this._terms}constant(){return this._constant}value(){let t=this._constant;for(let e=0,r=this._terms.size();e<r;e++){let i=this._terms.itemAt(e);t+=i.first.value()*i.second}return t}plus(t){return new g(this,t)}minus(t){return new g(this,typeof t=="number"?-t:[-1,t])}multiply(t){return new g([t,this])}divide(t){return new g([1/t,this])}isConstant(){return this._terms.size()==0}toString(){let t=this._terms.array.map(function(e){return e.second+"*"+e.first.toString()}).join(" + ");return!this.
|
|
10
|
+
isConstant()&&this._constant!==0&&(t+=" + "),t+=this._constant,t}_terms;_constant}function kt(o){let t=0,e=()=>0,r=S();for(let i=0,s=o.length;i<s;++i){let n=o[i];if(typeof n=="number")t+=n;else if(n instanceof L)r.setDefault(n,e).second+=1;else if(n instanceof g){t+=n.constant();let a=n.terms();for(let l=0,c=a.size();l<c;l++){let u=a.itemAt(l);r.setDefault(u.first,e).second+=u.second}}else if(n instanceof Array){if(n.length!==2)throw new Error("array must have length 2");let a=n[0],l=n[1];if(typeof a!=
|
|
11
|
+
"number")throw new Error("array item 0 must be a number");if(l instanceof L)r.setDefault(l,e).second+=a;else if(l instanceof g){t+=l.constant()*a;let c=l.terms();for(let u=0,h=c.size();u<h;u++){let f=c.itemAt(u);r.setDefault(f.first,e).second+=f.second*a}}else throw new Error("array item 1 must be a variable or expression")}else throw new Error("invalid Expression argument: "+n)}return{terms:r,constant:t}}class m{static create(t,e,r,i=1){let s=0;return s+=Math.max(0,Math.min(1e3,t*i))*1e6,s+=Math.
|
|
12
|
+
max(0,Math.min(1e3,e*i))*1e3,s+=Math.max(0,Math.min(1e3,r*i)),s}static required=m.create(1e3,1e3,1e3);static strong=m.create(1,0,0);static medium=m.create(0,1,0);static weak=m.create(0,0,1);static clip(t){return Math.max(0,Math.min(m.required,t))}}var b;(function(o){o[o.Le=0]="Le",o[o.Ge=1]="Ge",o[o.Eq=2]="Eq"})(b||(b={}));class N{constructor(t,e,r,i=m.required){this._operator=e,this._strength=m.clip(i),r===void 0&&t instanceof g?this._expression=t:this._expression=t.minus(r)}id(){return this._id}expression(){
|
|
13
|
+
return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+" "+["<=",">=","="][this._operator]+" 0 ("+this._strength.toString()+")"}_expression;_operator;_strength;_id=At++}let At=0;class Vt{maxIterations=1e3;constructor(){}createConstraint(t,e,r,i=m.required){let s=new N(t,e,r,i);return this.addConstraint(s),s}addConstraint(t){if(this._cnMap.find(t)!==void 0)throw new Error("duplicate constraint");let r=this._createRow(t),i=r.
|
|
14
|
+
row,s=r.tag,n=this._chooseSubject(i,s);if(n.type()===d.Invalid&&i.allDummies())if(P(i.constant()))n=s.marker;else throw new Error("unsatisfiable constraint");if(n.type()===d.Invalid){if(!this._addWithArtificialVariable(i))throw new Error("unsatisfiable constraint")}else i.solveFor(n),this._substitute(n,i),this._rowMap.insert(n,i);this._cnMap.insert(t,s),this._optimize(this._objective)}removeConstraint(t){let e=this._cnMap.erase(t);if(e===void 0)throw new Error("unknown constraint");this._removeConstraintEffects(
|
|
15
|
+
t,e.second);let r=e.second.marker,i=this._rowMap.erase(r);if(i===void 0){let s=this._getMarkerLeavingSymbol(r);if(s.type()===d.Invalid)throw new Error("failed to find leaving row");i=this._rowMap.erase(s),i.second.solveForEx(s,r),this._substitute(r,i.second)}this._optimize(this._objective)}hasConstraint(t){return this._cnMap.contains(t)}getConstraints(){return this._cnMap.array.map(({first:t})=>t)}addEditVariable(t,e){if(this._editMap.find(t)!==void 0)throw new Error("duplicate edit variable");if(e=
|
|
16
|
+
m.clip(e),e===m.required)throw new Error("bad required strength");let i=new g(t),s=new N(i,b.Eq,void 0,e);this.addConstraint(s);let a={tag:this._cnMap.find(s).second,constraint:s,constant:0};this._editMap.insert(t,a)}removeEditVariable(t){let e=this._editMap.erase(t);if(e===void 0)throw new Error("unknown edit variable");this.removeConstraint(e.second.constraint)}hasEditVariable(t){return this._editMap.contains(t)}suggestValue(t,e){let r=this._editMap.find(t);if(r===void 0)throw new Error("unkno\
|
|
17
|
+
wn edit variable");let i=this._rowMap,s=r.second,n=e-s.constant;s.constant=e;let a=s.tag.marker,l=i.find(a);if(l!==void 0){l.second.add(-n)<0&&this._infeasibleRows.push(a),this._dualOptimize();return}let c=s.tag.other;if(l=i.find(c),l!==void 0){l.second.add(n)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let u=0,h=i.size();u<h;++u){let f=i.itemAt(u),w=f.second,p=w.coefficientFor(a);p!==0&&w.add(n*p)<0&&f.first.type()!==d.External&&this._infeasibleRows.push(f.first)}this._dualOptimize()}updateVariables(){
|
|
18
|
+
let t=this._varMap,e=this._rowMap;for(let r=0,i=t.size();r<i;++r){let s=t.itemAt(r),n=e.find(s.second);n!==void 0?s.first.setValue(n.second.constant()):s.first.setValue(0)}}_getVarSymbol(t){let e=()=>this._makeSymbol(d.External);return this._varMap.setDefault(t,e).second}_createRow(t){let e=t.expression(),r=new B(e.constant()),i=e.terms();for(let l=0,c=i.size();l<c;++l){let u=i.itemAt(l);if(!P(u.second)){let h=this._getVarSymbol(u.first),f=this._rowMap.find(h);f!==void 0?r.insertRow(f.second,u.second):
|
|
19
|
+
r.insertSymbol(h,u.second)}}let s=this._objective,n=t.strength(),a={marker:x,other:x};switch(t.op()){case b.Le:case b.Ge:{let l=t.op()===b.Le?1:-1,c=this._makeSymbol(d.Slack);if(a.marker=c,r.insertSymbol(c,l),n<m.required){let u=this._makeSymbol(d.Error);a.other=u,r.insertSymbol(u,-l),s.insertSymbol(u,n)}break}case b.Eq:{if(n<m.required){let l=this._makeSymbol(d.Error),c=this._makeSymbol(d.Error);a.marker=l,a.other=c,r.insertSymbol(l,-1),r.insertSymbol(c,1),s.insertSymbol(l,n),s.insertSymbol(c,n)}else{
|
|
20
|
+
let l=this._makeSymbol(d.Dummy);a.marker=l,r.insertSymbol(l)}break}}return r.constant()<0&&r.reverseSign(),{row:r,tag:a}}_chooseSubject(t,e){let r=t.cells();for(let s=0,n=r.size();s<n;++s){let a=r.itemAt(s);if(a.first.type()===d.External)return a.first}let i=e.marker.type();return(i===d.Slack||i===d.Error)&&t.coefficientFor(e.marker)<0?e.marker:(i=e.other.type(),(i===d.Slack||i===d.Error)&&t.coefficientFor(e.other)<0?e.other:x)}_addWithArtificialVariable(t){let e=this._makeSymbol(d.Slack);this._rowMap.
|
|
21
|
+
insert(e,t.copy()),this._artificial=t.copy(),this._optimize(this._artificial);let r=P(this._artificial.constant());this._artificial=null;let i=this._rowMap.erase(e);if(i!==void 0){let n=i.second;if(n.isConstant())return r;let a=this._anyPivotableSymbol(n);if(a.type()===d.Invalid)return!1;n.solveForEx(e,a),this._substitute(a,n),this._rowMap.insert(a,n)}let s=this._rowMap;for(let n=0,a=s.size();n<a;++n)s.itemAt(n).second.removeSymbol(e);return this._objective.removeSymbol(e),r}_substitute(t,e){let r=this.
|
|
22
|
+
_rowMap;for(let i=0,s=r.size();i<s;++i){let n=r.itemAt(i);n.second.substitute(t,e),n.second.constant()<0&&n.first.type()!==d.External&&this._infeasibleRows.push(n.first)}this._objective.substitute(t,e),this._artificial&&this._artificial.substitute(t,e)}_optimize(t){let e=0;for(;e<this.maxIterations;){let r=this._getEnteringSymbol(t);if(r.type()===d.Invalid)return;let i=this._getLeavingSymbol(r);if(i.type()===d.Invalid)throw new Error("the objective is unbounded");let s=this._rowMap.erase(i).second;
|
|
23
|
+
s.solveForEx(i,r),this._substitute(r,s),this._rowMap.insert(r,s),e++}throw new Error("solver iterations exceeded")}_dualOptimize(){let t=this._rowMap,e=this._infeasibleRows;for(;e.length!==0;){let r=e.pop(),i=t.find(r);if(i!==void 0&&i.second.constant()<0){let s=this._getDualEnteringSymbol(i.second);if(s.type()===d.Invalid)throw new Error("dual optimize failed");let n=i.second;t.erase(r),n.solveForEx(r,s),this._substitute(s,n),t.insert(s,n)}}}_getEnteringSymbol(t){let e=t.cells();for(let r=0,i=e.
|
|
24
|
+
size();r<i;++r){let s=e.itemAt(r),n=s.first;if(s.second<0&&n.type()!==d.Dummy)return n}return x}_getDualEnteringSymbol(t){let e=Number.MAX_VALUE,r=x,i=t.cells();for(let s=0,n=i.size();s<n;++s){let a=i.itemAt(s),l=a.first,c=a.second;if(c>0&&l.type()!==d.Dummy){let h=this._objective.coefficientFor(l)/c;h<e&&(e=h,r=l)}}return r}_getLeavingSymbol(t){let e=Number.MAX_VALUE,r=x,i=this._rowMap;for(let s=0,n=i.size();s<n;++s){let a=i.itemAt(s),l=a.first;if(l.type()!==d.External){let c=a.second,u=c.coefficientFor(
|
|
25
|
+
t);if(u<0){let h=-c.constant()/u;h<e&&(e=h,r=l)}}}return r}_getMarkerLeavingSymbol(t){let e=Number.MAX_VALUE,r=e,i=e,s=x,n=s,a=s,l=s,c=this._rowMap;for(let u=0,h=c.size();u<h;++u){let f=c.itemAt(u),w=f.second,p=w.coefficientFor(t);if(p===0)continue;let _=f.first;if(_.type()===d.External)l=_;else if(p<0){let y=-w.constant()/p;y<r&&(r=y,n=_)}else{let y=w.constant()/p;y<i&&(i=y,a=_)}}return n!==s?n:a!==s?a:l}_removeConstraintEffects(t,e){e.marker.type()===d.Error&&this._removeMarkerEffects(e.marker,
|
|
26
|
+
t.strength()),e.other.type()===d.Error&&this._removeMarkerEffects(e.other,t.strength())}_removeMarkerEffects(t,e){let r=this._rowMap.find(t);r!==void 0?this._objective.insertRow(r.second,-e):this._objective.insertSymbol(t,-e)}_anyPivotableSymbol(t){let e=t.cells();for(let r=0,i=e.size();r<i;++r){let s=e.itemAt(r),n=s.first.type();if(n===d.Slack||n===d.Error)return s.first}return x}_makeSymbol(t){return new et(t,this._idTick++)}_cnMap=Pt();_rowMap=Rt();_varMap=Bt();_editMap=$t();_infeasibleRows=[];_objective=new B;_artificial=null;_idTick=0}
|
|
27
|
+
function P(o){let t=1e-8;return o<0?-o<t:o<t}function Pt(){return S()}function Rt(){return S()}function Bt(){return S()}function $t(){return S()}var d;(function(o){o[o.Invalid=0]="Invalid",o[o.External=1]="External",o[o.Slack=2]="Slack",o[o.Error=3]="Error",o[o.Dummy=4]="Dummy"})(d||(d={}));let et=class{constructor(t,e){this._id=e,this._type=t}id(){return this._id}type(){return this._type}_id;_type},x=new et(d.Invalid,-1);class B{constructor(t=0){this._constant=t}cells(){return this._cellMap}constant(){
|
|
28
|
+
return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let t=this._cellMap;for(let e=0,r=t.size();e<r;++e)if(t.itemAt(e).first.type()!==d.Dummy)return!1;return!0}copy(){let t=new B(this._constant);return t._cellMap=this._cellMap.copy(),t}add(t){return this._constant+=t}insertSymbol(t,e=1){let r=this._cellMap.setDefault(t,()=>0);P(r.second+=e)&&this._cellMap.erase(t)}insertRow(t,e=1){this._constant+=t._constant*e;let r=t._cellMap;for(let i=0,s=r.size();i<s;++i){let n=r.itemAt(
|
|
29
|
+
i);this.insertSymbol(n.first,n.second*e)}}removeSymbol(t){this._cellMap.erase(t)}reverseSign(){this._constant=-this._constant;let t=this._cellMap;for(let e=0,r=t.size();e<r;++e){let i=t.itemAt(e);i.second=-i.second}}solveFor(t){let e=this._cellMap,i=-1/e.erase(t).second;this._constant*=i;for(let s=0,n=e.size();s<n;++s)e.itemAt(s).second*=i}solveForEx(t,e){this.insertSymbol(t,-1),this.solveFor(e)}coefficientFor(t){let e=this._cellMap.find(t);return e!==void 0?e.second:0}substitute(t,e){let r=this.
|
|
30
|
+
_cellMap.erase(t);r!==void 0&&this.insertRow(e,r.second)}_cellMap=S();_constant}function zt(o){return j(o,W(t=>t.parallelPrefix??void 0),X((t,e)=>t.reduce((r,i)=>(r.min.column=Math.min(r.min.column,i.from.column,i.to.column),r.min.row=Math.min(r.min.row,i.from.row,i.to.row),r.max.column=Math.max(r.max.column,i.from.column,i.to.column),r.max.row=Math.max(r.max.row,i.from.row,i.to.row),r),{parallelPrefix:e,min:{column:1/0,row:1/0},max:{column:-1/0,row:-1/0}})),q())}function Ct(o,t){if(o.length===0||
|
|
31
|
+
o.length===t.length)return[];const e=n=>E(t.find(a=>a.id===n));function r(n){const a=n.parent?e(n.parent):null;return a?[a,...r(a)]:[]}const i=new D,s=[];return o.forEach(n=>{const a=r(n);if(a.length===0){i.clear();return}const l=D.from(a);let c,u;for(;c=i.peek()?.node,u=l.peek(),!(!u||!c);){if(G(u.id,c.id)||u.id===c.id){l.pop();continue}if(!G(c.id,u.id)){i.pop();continue}break}for(;u=l.pop();){const h={node:u,from:n,to:n,nested:[]};let f=i.peek();f?f.nested.push(h):s.push(h),i.push(h)}i.forEach(
|
|
32
|
+
h=>h.to=n)}),s}class jt{#e=new Vt;#r;#n=[];#o;#i;#s;#t=[];#a=[];constructor({actors:t,steps:e,compounds:r}){this.#s=this.newVar(tt),this.#o=this.newVar(0),this.#i=this.newVar(0),this.#r=this.addActors(t);for(const n of r){const a=this.addCompound(n),l=a[0];this.constraint(l.y1,"==",0,m.strong),this.put(this.#i).after(l.bottom),this.put(this.#s).after(l.y2),this.#n.push(...a)}for(const n of e)this.addStep(n);for(const n of zt(e))this.addParallelRect(n);const i=this.#r[0];this.constraint(i.offset.
|
|
33
|
+
left,"==",0,m.strong);const s=this.#r.reduce((n,a)=>(this.put(a.x).after(n.right,Z),this.put(a.offset.left,m.strong).after(n.offset.right,Mt),this.constraint(a.centerY,"==",n.centerY,m.strong),this.put(this.#s).after(a.offset.bottom),a));if(this.put(this.#o).after(s.offset.right),this.put(this.#i).after(J(this.#t)?.bottom??this.#s),r.length>0)for(const n of this.#n){const a=n.from.column,l=n.to.column;let c=Math.max(n.from.maxRow,n.to.maxRow);for(let h=a+1;h<l;h++){const f=this.actorBox(h);c=Math.
|
|
34
|
+
max(c,f.maxRow)}const u=E(this.#t[c],`row ${c} not found`);this.put(n.bottom).after(u.bottom,16),this.put(this.#i).after(n.bottom)}this.#e.updateVariables()}getParallelBoxes(){return this.#a.map(({parallelPrefix:t,x1:e,y1:r,x2:i,y2:s})=>({parallelPrefix:t,x:e.value(),y:r.value(),width:i.value()-e.value(),height:s.value()-r.value()}))}getActorBox(t){const e=this.actorBox(t);return{x:e.x.value(),y:e.y.value(),width:e.width,height:e.height}}getCompoundBoxes(){return this.#n.map(({node:t,depth:e,x1:r,
|
|
35
|
+
y1:i,x2:s,bottom:n})=>({node:t,depth:e,x:r.value(),y:i.value(),width:s.value()-r.value(),height:n.value()-i.value()}))}getPortCenter(t,e){const{column:r,row:i}=e==="source"?t.from:t.to,s=this.actorBox(r).centerX,{y:n}=E(this.#t[i]);return{cx:s.value(),cy:n.value()+K/2+t.offset,height:e==="source"?40:24}}getViewBounds(){return{x:0,y:0,width:this.#o.value(),height:this.#i.value()}}actorBox(t){if(typeof t!="number"){const e=typeof t=="string"?t:t.id;t=this.#r.findIndex(r=>r.actor.id===e),C(t>=0,`ac\
|
|
36
|
+
tor ${e} not found`)}return E(this.#r[t],`actor at index ${t} not found`)}addActors(t){let e=0;return A(t,(r,i)=>{const s=this.newVar(e);e+=r.width+Z;const n=this.newVar(0),a={column:i,actor:r,x:s,y:n,centerX:s.plus(Math.round(r.width/2)),centerY:n.plus(Math.round(r.height/2)),width:r.width,height:r.height,right:s.plus(r.width),bottom:n.plus(r.height),minRow:1/0,maxRow:-1/0},l=this.newVar(0),c=this.newVar(0),u=this.newVar(0),h=this.newVar(0);return this.put(l,m.strong).before(n),this.put(c,m.strong).
|
|
37
|
+
before(s),this.put(u,m.strong).after(a.right),this.put(h,m.strong).after(a.bottom),{...a,offset:{top:l,left:c,right:u,bottom:h}}})}addStep(t){const e=this.actorBox(t.source),r=this.actorBox(t.target);e.minRow=Math.min(e.minRow,t.from.row),e.maxRow=Math.max(e.maxRow,t.from.row),r.minRow=Math.min(r.minRow,t.to.row),r.maxRow=Math.max(r.maxRow,t.to.row);const[i,s]=e.column<=r.column?[e,r]:[r,e],n=(t.label?.width??100)+Q;i!==s?this.constraint(i.centerX.plus(n),"<=",s.centerX):this.constraint(i.centerX.
|
|
38
|
+
plus(n),"<=",i.offset.right);let a=t.label?.height?t.label.height+Q+K/2:M;return a=Math.max(a,M)+t.offset,this.ensureRow(t.from.row,a),t.isSelfLoop&&this.ensureRow(t.to.row,M),this}addParallelRect({parallelPrefix:t,min:e,max:r}){const i=this.actorBox(e.column).centerX.minus(30),s=this.actorBox(r.column).centerX.plus(30),n=this.#t[e.row],a=this.#t[r.row];C(n&&a,`parallel box invalid minRow=${e.row} maxRow=${r.row}`);const l=this.newVar(0);this.put(l).before(n.y,40);const c=a.bottom,u=e.row>0&&this.#t[e.
|
|
39
|
+
row-1];u&&this.put(l).after(u.bottom,16);const h=r.row<this.#t.length-1&&this.#t[r.row+1];h&&this.put(c).before(h.y,16),this.#a.push({parallelPrefix:t,x1:i,y1:l,x2:s,y2:c})}addCompound(t){const e=[],r=t.nested.flatMap(p=>{const _=this.addCompound(p);return e.push(_[0]),_}),i=Math.max(...r.map(p=>p.depth+1),0),s=this.actorBox(t.from),n=this.actorBox(t.to),a=s.offset.left.minus(32);s.offset.left=a;const l=n.offset.right.plus(32);n.offset.right=l;const c=this.newVar(0),u=xt(e);let h,f;switch(!0){case!!u:{
|
|
40
|
+
h=u.y1.minus(40),f=u.y2.plus(32),this.put(c).after(u.bottom,32);break}case n===s:{h=this.newVar(0),f=this.newVar(0),this.put(h).before(s.offset.top,52),this.put(f).after(s.offset.bottom,32),this.put(c).after(f);break}case e.length>0:{h=this.newVar(0),f=this.newVar(0);for(const p of e)this.put(h).before(p.y1,32),this.put(f).after(p.y2,32),this.put(c).after(p.bottom,32);break}default:{h=this.newVar(0),f=this.newVar(0);for(var w=s.column;w<=n.column;w++){const p=this.actorBox(w).offset;this.put(h).
|
|
41
|
+
before(p.top,52),this.put(f).after(p.bottom,32)}this.put(c).after(f);break}}for(var w=s.column;w<=n.column;w++){const _=this.actorBox(w).offset;_.top=h,_.bottom=f}return[{node:t.node,depth:i,from:s,to:n,x1:a,y1:h,x2:l,y2:f,bottom:c},...r]}ensureRow(t,e){for(;t>=this.#t.length;){const i=this.#t.length>0&&this.#t[this.#t.length-1]?.bottom||this.#s.plus(tt),s=this.newVar(this.#t.length*M);this.put(s).after(i);const n=this.newVar(M);this.require(n,">=",M),this.#t.push({y:s,height:n,bottom:s.plus(n),
|
|
42
|
+
lastHeight:M})}const r=E(this.#t[t]);e>r.lastHeight&&(r.lastHeight=e,this.require(r.height,">=",e),this.#e.suggestValue(r.height,e))}newVar(t){const e=new L;return this.#e.addEditVariable(e,m.weak),typeof t=="number"&&(this.#e.suggestValue(e,t),this.constraint(e,">=",0,m.strong)),e}require(t,e,r=void 0){switch(this.constraint(t,e,r,m.required),e){case"<=":case">=":this.constraint(t,"==",r,m.weak);break;case"<= 0":case">= 0":this.constraint(t,"== 0",void 0,m.weak);break}}constraint(t,e,r=void 0,i=m.
|
|
43
|
+
medium){let s;switch(e){case"==":s=b.Eq;break;case">=":s=b.Ge;break;case"<=":s=b.Le;break;case"== 0":{s=b.Eq,r=0;break}case">= 0":{s=b.Ge,r=0;break}case"<= 0":{s=b.Le,r=0;break}default:st(e)}this.#e.addConstraint(new N(t,s,r??0,i))}put(t,e=m.required){const r=e===m.required?m.medium:m.weak;return{before:(i,s)=>{s&&(i=i.minus(s)),this.constraint(t,"<=",i,e),this.constraint(t,"==",i,r)},after:(i,s)=>{s&&(i=i.plus(s)),this.constraint(t,">=",i,e),this.constraint(t,"==",i,r)}}}}function It(o){const t=new Set,
|
|
44
|
+
e=h=>E(o.nodes.find(f=>f.id===h)),r=[];for(const h of o.edges.filter(f=>rt(f.id))){const f=e(h.source),w=e(h.target);if(f.children.length||w.children.length){console.error("Sequence view does not support nested actors");continue}t.add(f),t.add(w),r.push({edge:h,source:f,target:w})}const i=o.nodes.filter(h=>t.has(h));C(I(i,1),"actors array must not be empty");const s=new nt(()=>[]),n=[];let a=0;for(const{edge:h,source:f,target:w}of r){const p=n.at(-1);let _=i.indexOf(f),y=i.indexOf(w);const k=f===
|
|
45
|
+
w,V=_>y,F=it(h.id);let $=!1;p&&p.target==f&&p.parallelPrefix===F&&($=p.isSelfLoop!==k||p.isBack===V),$||a++;const z={id:h.id,from:{column:_,row:a},to:{column:y,row:k?++a:a},edge:h,isSelfLoop:k,isBack:V,parallelPrefix:F,offset:$?(p?.offset??0)+Et:0,source:f,target:w,label:h.labelBBox?{height:h.labelBBox.height+8+(h.navigateTo?20:0),width:h.labelBBox.width+16,text:h.label}:null};n.push(z),s.get(f).push({step:z,row:a,type:"source",position:V&&!k?"left":"right"}),s.get(w).push({step:z,row:a,type:"ta\
|
|
46
|
+
rget",position:V||k?"right":"left"})}const l=new jt({actors:i,steps:n,compounds:Ct(i,o.nodes)}),c=l.getViewBounds(),u=j(l.getCompoundBoxes(),A(({node:h,...f})=>({...f,id:h.id,origin:h.id})),wt("id"),X((h,f)=>I(h,2)?A(h,(w,p)=>({...w,id:`${f}-${p+1}`})):h),q(),ft());return{actors:i.map(h=>qt({actor:h,ports:s.get(h),layout:l})),compounds:u,steps:A(n,h=>({id:h.id,sourceHandle:h.id+"_source",targetHandle:h.id+"_target",...h.label&&{labelBBox:{width:h.label.width,height:h.label.height}}})),parallelAreas:l.
|
|
47
|
+
getParallelBoxes(),bounds:c}}function qt({actor:o,ports:t,layout:e}){const{x:r,y:i,width:s,height:n}=e.getActorBox(o);return{id:o.id,x:r,y:i,width:s,height:n,ports:t.map(a=>{const l=e.getPortCenter(a.step,a.type);return{id:`${a.step.id}_${a.type}`,cx:l.cx-r,cy:l.cy-i,height:l.height,type:a.type,position:a.position}})}}export{A as a,q as b,It as c,I as d,H as e,W as f,J as g,lt as n,U as r,j as t};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import{invariant as pe,isNonEmptyArray as ue}from"@likec4/core";import{relative as fe}from"node:path";import{t as ge}from"./likec4.DO_7oUns.mjs";import{t as he,a as A}from"./likec4.CB2-Uaub.mjs";import{t as me}from"./likec4.DOUP9ptn.mjs";import{f as we,g as J,T as Ie,N as V,i as Ne,e as x,j as _,u as N,t as ye,a as ve,n as $e,b as Le,c as ke,d as G,L as je}from"./likec4.DdxVkEIS.mjs";import{compareNatural as Se}from"@likec4/core/utils";import{l as W}from"./likec4.B5Q51Z1F.mjs";import{RichText as Ce}from"@likec4/core/types";
|
|
2
|
+
function z(...t){return me(Re,t)}function Re(t,e){let i={};for(let n of e)n in t&&(i[n]=t[n]);return i}function Te(t){var e,i;if(t){if("astNode"in t)return be(t);if(Array.isArray(t))return t.reduce(B,void 0);{const n=t,r=Ee(n)?Me((i=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:n?.astNode):void 0;return S(n,r)}}else return}function Ee(t){return typeof t<"u"&&"element"in t&&"text"in t}function Me(t){try{return J(t).uri.toString()}catch{return}}function be(t){var e,i;const{
|
|
3
|
+
astNode:n,property:r,index:a}=t??{},c=(e=n?.$cstNode)!==null&&e!==void 0?e:n?.$textRegion;if(!(n===void 0||c===void 0)){if(r===void 0)return S(c,D(n));{const o=d=>a!==void 0&&a>-1&&Array.isArray(n[r])?a<d.length?d[a]:void 0:d.reduce(B,void 0);if(!((i=c.assignments)===null||i===void 0)&&i[r]){const d=o(c.assignments[r]);return d&&S(d,D(n))}else if(n.$cstNode){const d=o(we(n.$cstNode,r));return d&&S(d,D(n))}else return}}}function D(t){var e,i,n,r;return t.$cstNode?(i=(e=J(t))===null||e===void 0?void 0:
|
|
4
|
+
e.uri)===null||i===void 0?void 0:i.toString():t.$textRegion?t.$textRegion.documentURI||((r=(n=new Ie(t,a=>a.$container?[a.$container]:[]).find(a=>{var c;return(c=a.$textRegion)===null||c===void 0?void 0:c.documentURI}))===null||n===void 0?void 0:n.$textRegion)===null||r===void 0?void 0:r.documentURI):void 0}function S(t,e){var i,n;const r={offset:t.offset,end:(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,length:(n=t.length)!==null&&n!==void 0?n:t.end-t.offset};return t.range&&(r.range=t.range),
|
|
5
|
+
e??(e=t.fileURI),e&&(r.fileURI=e),r}function B(t,e){var i,n;if(t){if(!e)return t&&S(t)}else return e&&S(e);const r=(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,a=(n=e.end)!==null&&n!==void 0?n:e.offset+e.length,c=Math.min(t.offset,e.offset),o=Math.max(r,a),d=o-c,u={offset:c,end:o,length:d};if(t.range&&e.range&&(u.range={start:e.range.start.line<t.range.start.line||e.range.start.line===t.range.start.line&&e.range.start.character<t.range.start.character?e.range.start:t.range.start,end:e.range.
|
|
6
|
+
end.line>t.range.end.line||e.range.end.line===t.range.end.line&&e.range.end.character>t.range.end.character?e.range.end:t.range.end}),t.fileURI||e.fileURI){const f=t.fileURI,g=e.fileURI,p=f&&g&&f!==g?`<unmergable text regions of ${f}, ${g}>`:f??g;u.fileURI=p}return u}class xe{constructor(e){this.defaultIndentation=" ",this.pendingIndent=!0,this.currentIndents=[],this.recentNonImmediateIndents=[],this.traceData=[],this.lines=[[]],this.length=0,typeof e=="string"?this.defaultIndentation=e:typeof e==
|
|
7
|
+
"number"&&(this.defaultIndentation="".padStart(e))}get content(){return this.lines.map(e=>e.join("")).join("")}get contentLength(){return this.length}get currentLineNumber(){return this.lines.length-1}get currentLineContent(){return this.lines[this.currentLineNumber].join("")}get currentPosition(){return{offset:this.contentLength,line:this.currentLineNumber,character:this.currentLineContent.length}}append(e,i){if(e.length>0){const n=i&&this.currentPosition;this.lines[this.currentLineNumber].push(
|
|
8
|
+
e),this.length+=e.length,n&&this.indentPendingTraceRegions(n)}}indentPendingTraceRegions(e){for(let i=this.traceData.length-1;i>=0;i--){const n=this.traceData[i];n.targetStart&&n.targetStart.offset===e.offset&&(n.targetStart=this.currentPosition)}}increaseIndent(e){this.currentIndents.push(e),e.indentImmediately||this.recentNonImmediateIndents.push(e)}decreaseIndent(){this.currentIndents.pop()}get relevantIndents(){return this.currentIndents.filter(e=>!this.recentNonImmediateIndents.includes(e))}resetCurrentLine(){
|
|
9
|
+
this.length-=this.lines[this.currentLineNumber].join("").length,this.lines[this.currentLineNumber]=[],this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}addNewLine(){this.lines.push([]),this.pendingIndent=!0,this.recentNonImmediateIndents.length=0}pushTraceRegion(e){const i=Ue(e,this.currentPosition,n=>{var r,a;return(a=(r=this.traceData[this.traceData.length-1])===null||r===void 0?void 0:r.children)===null||a===void 0?void 0:a.push(n)});return this.traceData.push(i),i}popTraceRegion(e){
|
|
10
|
+
const i=this.traceData.pop();return this.assertTrue(i===e,"Trace region mismatch!"),i}getParentTraceSourceFileURI(){var e;for(let i=this.traceData.length-1;i>-1;i--){const n=(e=this.traceData[i].sourceRegion)===null||e===void 0?void 0:e.fileURI;if(n)return n}}assertTrue(e,i){if(!e)throw new Error(i)}}function Ue(t,e,i){const n={sourceRegion:t,targetRegion:void 0,children:[],targetStart:e,complete:r=>{var a,c;return n.targetRegion={offset:n.targetStart.offset,end:r.offset,length:r.offset-n.targetStart.
|
|
11
|
+
offset,range:{start:{line:n.targetStart.line,character:n.targetStart.character},end:{line:r.line,character:r.character}}},delete n.targetStart,((a=n.children)===null||a===void 0?void 0:a.length)===0&&delete n.children,!((c=n.targetRegion)===null||c===void 0)&&c.length&&i(n),delete n.complete,n}};return n}function Pe(t,e){const i=new xe(e),n=i.pushTraceRegion(void 0);q(t,i),i.popTraceRegion(n),n.complete&&n.complete(i.currentPosition);const r=n.children&&n.children.length===1?n.children[0]:void 0,
|
|
12
|
+
a=r?.targetRegion,c=n.targetRegion;return a&&r.sourceRegion&&a.offset===c.offset&&a.length===c.length?{text:i.content,trace:r}:{text:i.content,trace:n}}function q(t,e){typeof t=="string"?_e(t,e):t instanceof F?De(t,e):t instanceof h?K(t,e):t instanceof E&&Oe(t,e)}function Y(t,e){return typeof t=="string"?t.length!==0:t instanceof h?t.contents.some(i=>Y(i,e)):t instanceof E?!(t.ifNotEmpty&&e.currentLineContent.length===0):!1}function _e(t,e){t&&(H(e,!1),e.append(t))}function H(t,e){var i;if(t.pendingIndent){
|
|
13
|
+
let n="";for(const r of t.relevantIndents.filter(a=>a.indentEmptyLines||!e))n+=(i=r.indentation)!==null&&i!==void 0?i:t.defaultIndentation;t.append(n,!0),t.pendingIndent=!1}}function K(t,e){let i;const n=Te(t.tracedSource);n&&(i=e.pushTraceRegion(n));for(const r of t.contents)q(r,e);if(i){e.popTraceRegion(i);const r=e.getParentTraceSourceFileURI();r&&n?.fileURI===r&&delete n.fileURI,i.complete&&i.complete(e.currentPosition)}}function De(t,e){var i;if(Y(t,e)){t.indentImmediately&&!e.pendingIndent&&
|
|
14
|
+
e.append((i=t.indentation)!==null&&i!==void 0?i:e.defaultIndentation,!0);try{e.increaseIndent(t),K(t,e)}finally{e.decreaseIndent()}}}function Oe(t,e){t.ifNotEmpty&&!Fe(e.currentLineContent)?e.resetCurrentLine():(H(e,!0),e.append(t.lineDelimiter),e.addNewLine())}function Fe(t){return t.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");const Ae=/\S|$/;function Je(t){const e=t.filter(n=>n.length>0).map(n=>n.search(Ae)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function L(t,...e){
|
|
15
|
+
const i=Ge(t),n=We(t,e,i);return Be(n)}function Ve(t,e,i){return(n,...r)=>Ye(t,e,i)(L(n,...r))}function Ge(t){const e=t.join("_").split(V),i=e.length>1&&e[0].trim().length===0,n=i&&e.length>1&&e[e.length-1].trim().length===0;if(e.length===1||e.length!==0&&e[0].trim().length!==0||e.length===2&&e[1].trim().length===0)return{indentation:0,omitFirstLine:i,omitLastLine:n,trimLastLine:e.length!==1&&e[e.length-1].trim().length===0};{let r=i?e.slice(1):e;r=n?r.slice(0,r.length-1):r,r=r.filter(c=>c.length!==
|
|
16
|
+
0);const a=Je(r);return{indentation:a,omitFirstLine:i,omitLastLine:n&&(e[e.length-1].length<a||!e[e.length-1].startsWith(r[0].substring(0,a)))}}}function We(t,e,{indentation:i,omitFirstLine:n,omitLastLine:r,trimLastLine:a}){const c=[];t.forEach((u,f)=>{c.push(...u.split(V).map((g,p)=>p===0||g.length<i?g:g.substring(i)).reduce(f===0?(g,p,w)=>w===0?n?[]:[p]:w===1&&g.length===0?[p]:g.concat(U,p):(g,p,w)=>w===0?[p]:g.concat(U,p),[]).filter(g=>!(typeof g=="string"&&g.length===0)).concat(T(e[f])?e[f]:
|
|
17
|
+
e[f]!==void 0?{content:String(e[f])}:f<e.length?X:[]))});const o=c.length,d=o!==0?c[o-1]:void 0;return(r||a)&&typeof d=="string"&&d.trim().length===0?n&&o!==1&&c[o-2]===U?c.slice(0,o-2):c.slice(0,o-1):c}const U={isNewLine:!0},X={isUndefinedSegment:!0},Q=t=>t===U,O=t=>t===X,ze=t=>t.content!==void 0;function Be(t){return t.reduce((i,n,r)=>O(n)?i:Q(n)?{node:r!==0&&(O(t[r-1])||T(t[r-1]))||r>1&&typeof t[r-1]=="string"&&(O(t[r-2])||T(t[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{
|
|
18
|
+
var a;const c=(r===0||Q(t[r-1]))&&typeof n=="string"&&n.length!==0?"".padStart(n.length-n.trimStart().length):"",o=ze(n)?n.content:n;let d;return{node:i.indented?i.node:c.length!==0?i.node.indent({indentation:c,indentImmediately:!1,indentedChildren:u=>d=u.append(o)}):i.node.append(o),indented:d??((a=i.indented)===null||a===void 0?void 0:a.append(o))}})(),{node:new h}).node}const qe=typeof process>"u"?`
|
|
19
|
+
`:process.platform==="win32"?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`;function T(t){return t instanceof h||t instanceof F||t instanceof E}function k(t,e){return T(t)?Pe(t,e).text:String(t)}class h{constructor(...e){this.contents=[],this.append(...e)}isEmpty(){return this.contents.length===0}trace(e,i,n){if(Ne(e)){if(this.tracedSource={astNode:e,property:i,index:n},this.tracedSource.property===void 0&&this.tracedSource.index!==void 0&&this.tracedSource.index>-1)throw new Error("Generation support: 'property' argument must not be 'undefined' if a non-negative valu\
|
|
22
|
+
e is assigned to 'index' in 'CompositeGeneratorNode.trace(...)'.")}else this.tracedSource=e;return this}append(...e){for(const i of e)typeof i=="function"?i(this):i&&this.contents.push(i);return this}appendIf(e,...i){return e?this.append(...i):this}appendNewLine(){return this.append(s)}appendNewLineIf(e){return e?this.append(s):this}appendNewLineIfNotEmpty(){return this.append(He)}appendNewLineIfNotEmptyIf(e){return e?this.appendNewLineIfNotEmpty():this}appendTemplate(e,...i){return this.append(
|
|
23
|
+
L(e,...i))}appendTemplateIf(e){return e?(i,...n)=>this.appendTemplate(i,...n):()=>this}indent(e){const{indentedChildren:i,indentation:n,indentEmptyLines:r,indentImmediately:a}=Array.isArray(e)||typeof e=="function"?{indentedChildren:e}:typeof e=="object"?e:{},c=new F(n,a,r);return this.contents.push(c),Array.isArray(i)?c.append(...i):i&&c.append(i),this}appendTraced(e,i,n){return r=>this.append(new h().trace(e,i,n).append(r))}appendTracedIf(e,i,n,r){return e?this.appendTraced(typeof i=="function"?
|
|
24
|
+
i():i,n,r):()=>this}appendTracedTemplate(e,i,n){return(r,...a)=>this.append(Ve(e,i,n)(r,...a))}appendTracedTemplateIf(e,i,n,r){return e?this.appendTracedTemplate(typeof i=="function"?i():i,n,r):()=>this}}function Ye(t,e,i){return n=>n instanceof h&&n.tracedSource===void 0?n.trace(t,e,i):new h().trace(t,e,i).append(n)}class F extends h{constructor(e,i=!0,n=!1){super(),this.indentImmediately=!0,this.indentEmptyLines=!1,typeof e=="string"?this.indentation=e:typeof e=="number"&&(this.indentation="".
|
|
25
|
+
padStart(e)),this.indentImmediately=i,this.indentEmptyLines=n}}class E{constructor(e,i=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??qe,this.ifNotEmpty=i}}const s=new E,He=new E(void 0,!0),Z=t=>t===void 0||typeof t=="string"||T(t)?t:String(t);function y(t,e=Z,i={}){const n=typeof e=="function"?e:Z,{filter:r,prefix:a,suffix:c,separator:o,appendNewLineIfNotEmpty:d,skipNewLineAfterLastItem:u}=typeof e=="object"?e:i,f=typeof a=="function"?a:(()=>a),g=typeof c=="function"?c:(()=>c);return Ke(t,(p,w,l,m)=>{
|
|
26
|
+
if(r&&!r(w,l,m))return p;const I=n(w,l,m);return I===void 0?p:(p??(p=new h)).append(f(w,l,m)).append(I).append(g(w,l,m)).appendIf(!m,o).appendNewLineIfNotEmptyIf(!p.isEmpty()&&!!d&&(!m||!u))})}function Ke(t,e,i){const n=t[Symbol.iterator]();let r=n.next(),a=0,c=i;for(;!r.done;){const o=n.next();c=e(c,r.value,a,!!o.done),r=o,a++}return c}const Xe=t=>t.charAt(0).toLocaleUpperCase()+t.slice(1),Qe=t=>t.split(".").map(Xe).join(""),Ze=t=>Qe(t.parent?t.id.slice(t.parent.length+1):t.id),et=({autoLayout:t})=>{
|
|
27
|
+
switch(t.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},tt=({shape:t})=>{switch(t){case"queue":case"cylinder":case"rectangle":case"person":return t;case"storage":return"stored_data";case"mobile":case"browser":return"rectangle"}};function ee(t){const e=t.$view,{nodes:i,edges:n}=e,r=new Map,a=(o,d)=>{const u=Ze(o),f=(d?d+".":"")+u;r.set(o.id,f);const g=JSON.stringify(o.title),p=tt(o);return new h().append(u,": {",s).indent({indentedChildren:w=>w.
|
|
28
|
+
append("label: ",g,s).appendIf(p!=="rectangle","shape: ",p,s).appendIf(o.children.length>0,s,y(i.filter(l=>l.parent===o.id),l=>a(l,f))),indentation:2}).append("}",s)},c=o=>new h().append(r.get(o.source)," -> ",r.get(o.target)).append(d=>o.label&&d.append(": ",JSON.stringify(o.label)));return k(new h().append("direction: ",et(e),s,s).append(y(i.filter(o=>x(o.parent)),o=>a(o),{appendNewLineIfNotEmpty:!0})).appendIf(n.length>0,s,y(n,o=>c(o),{appendNewLineIfNotEmpty:!0})))}const nt=t=>t.charAt(0).toLocaleUpperCase()+
|
|
29
|
+
t.slice(1),it=t=>t.split(".").map(nt).join(""),rt=t=>it(t.parent?t.id.slice(t.parent.length+1):t.id),ot=({shape:t})=>{switch(t){case"queue":case"cylinder":return["[(",")]"];case"person":return["[fa:fa-user ","]"];case"storage":return["([","])"];case"mobile":case"browser":case"rectangle":return["[","]"]}};function te(t){const e=t.$view,{nodes:i,edges:n}=e,r=new Map,a=(o,d)=>{const u=rt(o),f=(d?d+".":"")+u;r.set(o.id,f);const g=o.title.replaceAll(`
|
|
30
|
+
`,"\\n"),p=ot(o),w=new h;return o.children.length>0?w.append("subgraph ",f,"[",JSON.stringify(o.title),"]",s).indent({indentedChildren:[y(i.filter(l=>l.parent===o.id),l=>a(l,f),{appendNewLineIfNotEmpty:!0})],indentation:2}).append("end",s):w.append(f,p[0],g,p[1]),w},c=o=>new h().append(r.get(o.source)," -.",o.label?' "'+o.label.replaceAll(`
|
|
31
|
+
`,"\\n")+'" .-':"-","> ",r.get(o.target));return k(new h().appendIf(e.title!==null&&e.title.length>0,"---",s,`title: ${JSON.stringify(e.title)}`,s,"---",s).append("graph ",e.autoLayout.direction,s).indent({indentedChildren:o=>{o.append(y(i.filter(d=>x(d.parent)),d=>a(d),{appendNewLineIfNotEmpty:!0})).appendIf(n.length>0,y(n,d=>c(d),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}const at=t=>t.charAt(0).toLocaleUpperCase()+t.slice(1),P=t=>t.split(".").map(at).join(""),ne=t=>P(t.parent?t.id.slice(
|
|
32
|
+
t.parent.length+1):t.id),C=(t,e,i="#3b82f6")=>t?e(t)??i:i,st=({autoLayout:t})=>{switch(t.direction){case"TB":return"top to bottom";case"BT":return console.warn("Bottom to top direction is not supported. Defaulting to top to bottom."),"top to bottom";case"LR":return"left to right";case"RL":return console.warn("Right to left direction is not supported. Defaulting to left to right."),"left to right"}},ie=({shape:t})=>{switch(t){case"queue":case"rectangle":case"person":return t;case"storage":case"cy\
|
|
33
|
+
linder":return"database";case"mobile":case"browser":return"rectangle"}},R=t=>x(t)?null:JSON.stringify(t).slice(1,-1);function re(t){const e=t.$view,i=t.$model.$styles.theme.colors,{nodes:n,edges:r}=e,a=l=>m=>m in i?i[m].elements[l]:void 0,c=l=>m=>m in i?i[m].relationships[l]:void 0,o=new Map,d=()=>new h().append('title "',e.title||e.id,'"',s).append(st(e)," direction",s),u=()=>new h().append("hide stereotype",s).append("skinparam ranksep ","60",s).append("skinparam nodesep ","30",s).append("skin\
|
|
34
|
+
param {",s).indent({indentedChildren:l=>l.append("arrowFontSize ","10",s).append("defaultTextAlignment ","center",s).append("wrapWidth ","200",s).append("maxMessageSize ","100",s).append("shadowing ","false",s),indentation:2}).append("}",s),f=l=>{const m=ie(l),I=P(l.id);return new h().append("skinparam ",m,"<<",I,">>","{",s).indent({indentedChildren:$=>$.append("BackgroundColor ",C(l.color,a("fill")),s).append("FontColor ",C(l.color,a("hiContrast"),"#FFFFFF"),s).append("BorderColor ",C(l.color,a(
|
|
35
|
+
"stroke")),s),indentation:2}).append("}",s)},g=l=>{const m=ie(l),I=P(l.id),$=R(l.title)||ne(l),v=R(l.technology);o.set(l.id,I);const b=Ce.from(l.description);return new h().append(m," ").append('"').append("==",$).appendIf(!!v,"\\n","<size:10>[",v,"]</size>").appendIf(b.nonEmpty,"\\n\\n",R(b.text)).append('"'," <<",I,">> ","as ",I,s)},p=l=>{const m=R(l.title)||ne(l),I=P(l.id);return o.set(l.id,I),new h().append('rectangle "',m,'" <<',I,">> as ",I," {",s).indent({indentedChildren:$=>$.append("ski\
|
|
36
|
+
nparam ","RectangleBorderColor<<",I,">> ",C(l.color,a("fill")),s).append("skinparam ","RectangleFontColor<<",I,">> ",C(l.color,a("fill")),s).append("skinparam ","RectangleBorderStyle<<",I,">> ","dashed",s,s).append(y(n.filter(v=>v.parent===l.id),v=>v.children.length>0?p(v):g(v))),indentation:2}).append("}",s)},w=l=>{const m=R(l.technology)||"",I=R(l.label)||"",$=C(l.color,c("line"),"#777777"),v=b=>`<color:${b}>`;return new h().append(o.get(l.source)," .[",$,",thickness=2].> ",o.get(l.target)).appendIf(
|
|
37
|
+
!!(I||m),' : "',v($)).appendIf(!!I,I,v($)).appendIf(!!(I&&m),"\\n").appendIf(!!m,v($),"<size:8>[",m,"]</size>").appendIf(!!(I||m),'"').append(s)};return k(new h().append("@startuml",s).append(d(),s).append(u(),s).append(y(n.filter(l=>l.children.length==0),l=>f(l),{appendNewLineIfNotEmpty:!0})).append(y(n.filter(l=>x(l.parent)),l=>l.children.length>0?p(l):g(l),{appendNewLineIfNotEmpty:!0})).appendIf(r.length>0,s,y(r,l=>w(l),{appendNewLineIfNotEmpty:!0})).append("@enduml",s))}function j(t){return{
|
|
38
|
+
matches:e=>{let{module:i,projectId:n}=e.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.groups??e.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!i||!n?null:(i.endsWith(".js")&&(i=i.slice(0,-3)),i===t?n:null)},virtualId:e=>_("likec4:plugin",e,t)+".js"}}const dt={"<":"\\u003C",">":"\\u003E","/":"\\u002F","\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};function ct(t){return t.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g,
|
|
39
|
+
e=>dt[e])}function M(t,e){return{id:`likec4:${t}`,virtualId:`likec4:plugin/${t}.js`,async load({logger:i,projects:n}){i.info(N.dim(`generating likec4:${t}`));const r=n.map(({id:a})=>{const c=ct(JSON.stringify(_(`likec4:${t}`,a)));return` ${JSON.stringify(a)}: () => import(${c})`});return`
|
|
40
|
+
export let ${e}Fn = {
|
|
41
|
+
${r.join(`,
|
|
42
|
+
`)}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function ${e}(projectId) {
|
|
46
|
+
const fn = ${e}Fn[projectId]
|
|
47
|
+
if (!fn) {
|
|
48
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
49
|
+
}
|
|
50
|
+
return await fn()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (import.meta.hot) {
|
|
54
|
+
import.meta.hot.accept(md => {
|
|
55
|
+
if (!import.meta.hot.data.$update) {
|
|
56
|
+
import.meta.hot.data.$update = ${e}Fn
|
|
57
|
+
}
|
|
58
|
+
const update = md.${e}Fn
|
|
59
|
+
if (update) {
|
|
60
|
+
Object.assign(import.meta.hot.data.$update, update)
|
|
61
|
+
} else {
|
|
62
|
+
import.meta.hot.invalidate()
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
`}}}function lt(t){const e=new h;return e.appendTemplate`
|
|
67
|
+
/******************************************************************************
|
|
68
|
+
* This file was generated
|
|
69
|
+
* DO NOT EDIT MANUALLY!
|
|
70
|
+
******************************************************************************/
|
|
71
|
+
/* eslint-disable */
|
|
72
|
+
|
|
73
|
+
export function d2Source(viewId) {
|
|
74
|
+
switch (viewId) {
|
|
75
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y([...t.views()],n=>L`
|
|
76
|
+
case ${JSON.stringify(n.id)}: {
|
|
77
|
+
return ${JSON.stringify(ee(n))}
|
|
78
|
+
}
|
|
79
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
80
|
+
default: {
|
|
81
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
82
|
+
}
|
|
83
|
+
`}}).append(s," }",s).appendTemplate`
|
|
84
|
+
}
|
|
85
|
+
`.append(s,s),k(e)}const pt={...j("d2"),async load({likec4:t,project:e,logger:i}){i.info(N.dim(`generating likec4:d2/${e.id}`));const n=await t.computedModel(e.id);return lt(n)}},ut=M("d2","loadD2Sources");function ft(t){const e=new h;return e.appendTemplate`
|
|
86
|
+
/******************************************************************************
|
|
87
|
+
* This file was generated
|
|
88
|
+
* DO NOT EDIT MANUALLY!
|
|
89
|
+
******************************************************************************/
|
|
90
|
+
/* eslint-disable */
|
|
91
|
+
|
|
92
|
+
export function dotSource(viewId) {
|
|
93
|
+
switch (viewId) {
|
|
94
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y(Object.keys(t),n=>L`
|
|
95
|
+
case ${JSON.stringify(n)}: {
|
|
96
|
+
return ${JSON.stringify(t[n].dot)}
|
|
97
|
+
}
|
|
98
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
99
|
+
default: {
|
|
100
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
101
|
+
}
|
|
102
|
+
`}}).append(s," }",s).appendTemplate`
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function svgSource(viewId) {
|
|
106
|
+
switch (viewId) {
|
|
107
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y(Object.keys(t),n=>L`
|
|
108
|
+
case ${JSON.stringify(n)}: {
|
|
109
|
+
return ${JSON.stringify(t[n].svg)}
|
|
110
|
+
}
|
|
111
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
112
|
+
default: {
|
|
113
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
114
|
+
}
|
|
115
|
+
`}}).append(s," }",s,"}",s,s),k(e)}const gt={...j("dot"),async load({likec4:t,project:e,logger:i}){i.info(N.dim(`generating likec4:dot/${e.id}`));const n=await t.views.viewsAsGraphvizOut(e.id),r=ye(n,({id:a,svg:c,dot:o})=>[a,{dot:o,svg:c}]);return ft(r)}},ht=M("dot","loadDotSources");function mt(t){const e=he(t.flatMap(r=>r.nodes.map(a=>a.icon)),Le(r=>ke(r)&&!(r.toLowerCase().startsWith("http:")||r.toLowerCase().startsWith("https:"))),$e(),ve(Se)),{imports:i,cases:n}=e.reduce((r,a,c)=>{
|
|
116
|
+
const o=a.startsWith("file:"),d="Icon"+c.toString().padStart(2,"0");if(o)return r.imports.push(`import ${d} from '${a}?inline'`),r.cases.push(` '${a}': () => jsx('img', { src: ${d} })`),r;const[u,f]=a.split(":");return r.imports.push(`import ${d} from 'likec4/icons/${u}/${f}'`),r.cases.push(` '${u}:${f}': ${d}`),r},{imports:[],cases:[]});return`
|
|
117
|
+
import { jsx } from 'react/jsx-runtime'
|
|
118
|
+
${i.join(`
|
|
119
|
+
`)}
|
|
120
|
+
|
|
121
|
+
const Icons = {
|
|
122
|
+
${n.join(`,
|
|
123
|
+
`)}
|
|
124
|
+
}
|
|
125
|
+
export function IconRenderer(props) {
|
|
126
|
+
const IconComponent = Icons[props.node.icon ?? '']
|
|
127
|
+
if (!IconComponent) {
|
|
128
|
+
return null
|
|
129
|
+
}
|
|
130
|
+
return jsx(IconComponent, props)
|
|
131
|
+
}
|
|
132
|
+
`}const wt={...j("icons"),async load({likec4:t,project:e,logger:i}){i.info(N.dim(`generating likec4:icons/${e.id}`));const n=await t.views.computedViews(e.id);return mt(n)}},It={id:"likec4:icons",virtualId:"likec4:plugin/icons.jsx",async load({projects:t,logger:e}){e.info(N.dim("generating likec4:icons"));const{imports:i,cases:n}=t.reduce((r,{id:a},c)=>{const o="Icons"+c.toString().padStart(2,"0"),d=_("likec4:icons",a);return r.imports.push(`import { IconRenderer as ${o} } from ${JSON.stringify(
|
|
133
|
+
d)}`),r.cases.push(` case ${JSON.stringify(a)}: return ${o}`),r},{imports:[],cases:[]});return`
|
|
134
|
+
import { jsx } from 'react/jsx-runtime'
|
|
135
|
+
${i.join(`
|
|
136
|
+
`)}
|
|
137
|
+
|
|
138
|
+
function getProjectIcons(projectId) {
|
|
139
|
+
switch (projectId) {
|
|
140
|
+
${n.join(`
|
|
141
|
+
`)}
|
|
142
|
+
default:
|
|
143
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function ProjectIcons({ projectId, ...props }) {
|
|
148
|
+
const IconComponent = getProjectIcons(projectId)
|
|
149
|
+
return jsx(IconComponent, props)
|
|
150
|
+
}
|
|
151
|
+
`}};function Nt(t){const e=new h;return e.appendTemplate`
|
|
152
|
+
/******************************************************************************
|
|
153
|
+
* This file was generated
|
|
154
|
+
* DO NOT EDIT MANUALLY!
|
|
155
|
+
******************************************************************************/
|
|
156
|
+
/* eslint-disable */
|
|
157
|
+
|
|
158
|
+
export function mmdSource(viewId) {
|
|
159
|
+
switch (viewId) {
|
|
160
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y([...t.views()],n=>L`
|
|
161
|
+
case ${JSON.stringify(n.id)}: {
|
|
162
|
+
return ${JSON.stringify(te(n))}
|
|
163
|
+
}
|
|
164
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
165
|
+
default: {
|
|
166
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
167
|
+
}
|
|
168
|
+
`}}).append(s," }",s).appendTemplate`
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
`.append(s,s),k(e)}const yt={...j("mmd"),async load({likec4:t,project:e,logger:i}){i.info(N.dim(`generating virtual:likec4/mmd/${e.id}`));const n=await t.computedModel(e.id);return Nt(n)}},vt=M("mmd","loadMmdSources"),$t=t=>`
|
|
172
|
+
import { createHooksForModel, atom } from 'likec4/vite-plugin/internal'
|
|
173
|
+
|
|
174
|
+
export const $likec4data = atom(${W.stringify(t.$data)})
|
|
175
|
+
|
|
176
|
+
export const {
|
|
177
|
+
updateModel,
|
|
178
|
+
$likec4model,
|
|
179
|
+
useLikeC4Model,
|
|
180
|
+
useLikeC4Views,
|
|
181
|
+
useLikeC4View
|
|
182
|
+
} = createHooksForModel($likec4data)
|
|
183
|
+
|
|
184
|
+
if (import.meta.hot) {
|
|
185
|
+
import.meta.hot.accept(md => {
|
|
186
|
+
if (!import.meta.hot.data.$update) {
|
|
187
|
+
import.meta.hot.data.$update = updateModel
|
|
188
|
+
}
|
|
189
|
+
const update = md.$likec4data?.get()
|
|
190
|
+
if (update) {
|
|
191
|
+
import.meta.hot.data.$update(update)
|
|
192
|
+
} else {
|
|
193
|
+
import.meta.hot.invalidate()
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
}
|
|
197
|
+
`,Lt={...j("model"),async load({likec4:t,project:e,logger:i}){i.info(N.dim(`generating likec4:model/${e.id}`));const n=await t.layoutedModel(e.id);return $t(n)}},oe=M("model","loadModel"),kt=t=>`
|
|
198
|
+
export const isSingleProject = ${t.length===1};
|
|
199
|
+
export const projects = ${W.stringify(t,null,2)};
|
|
200
|
+
`,ae={id:"likec4:projects",virtualId:"likec4:plugin/projects.js",async load({logger:t,projects:e}){return t.info(N.dim("generating likec4:projects")),kt(A(e,z(["id","title"])))}};function jt(t){const e=new h;return e.appendTemplate`
|
|
201
|
+
/******************************************************************************
|
|
202
|
+
* This file was generated
|
|
203
|
+
* DO NOT EDIT MANUALLY!
|
|
204
|
+
******************************************************************************/
|
|
205
|
+
/* eslint-disable */
|
|
206
|
+
|
|
207
|
+
export function pumlSource(viewId) {
|
|
208
|
+
switch (viewId) {
|
|
209
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y([...t.views()],n=>L`
|
|
210
|
+
case ${JSON.stringify(n.id)}: {
|
|
211
|
+
return ${JSON.stringify(re(n))}
|
|
212
|
+
}
|
|
213
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
214
|
+
default: {
|
|
215
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
216
|
+
}
|
|
217
|
+
`}}).append(s," }",s).appendTemplate`
|
|
218
|
+
}
|
|
219
|
+
`.append(s,s),k(e)}const St={...j("puml"),async load({likec4:t,project:e,logger:i}){i.info(N.dim(`generating likec4:puml/${e.id}`));const n=await t.computedModel(e.id);return jt(n)}},Ct=M("puml","loadPumlSources"),se=t=>`
|
|
220
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
221
|
+
import { LikeC4ModelProvider as Provider, LikeC4View as GenericView, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
|
|
222
|
+
import { IconRenderer } from 'likec4:icons/${t}'
|
|
223
|
+
|
|
224
|
+
import { useLikeC4Model, useLikeC4Views, useLikeC4View } from 'likec4:model/${t}'
|
|
225
|
+
|
|
226
|
+
export function LikeC4ModelProvider({ children }) {
|
|
227
|
+
const likeC4Model = useLikeC4Model()
|
|
228
|
+
return (_jsx(Provider, { likec4model: likeC4Model, children: children }));
|
|
229
|
+
}
|
|
230
|
+
export function LikeC4View(props) {
|
|
231
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericView, { renderIcon: IconRenderer, ...props }) }));
|
|
232
|
+
}
|
|
233
|
+
export function ReactLikeC4(props) {
|
|
234
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericReactLikeC4, { renderIcon: IconRenderer, ...props }) }));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
useLikeC4Model,
|
|
239
|
+
useLikeC4View,
|
|
240
|
+
useLikeC4Views
|
|
241
|
+
}
|
|
242
|
+
`,Rt={...j("react"),async load({project:t,logger:e}){return e.info(N.dim(`generating likec4:react/${t.id}`)),se(t.id)}},Tt={id:"likec4:react",virtualId:"likec4:plugin/react.js",async load({logger:t,projects:e}){const i=G(e);return t.info(N.dim("generating likec4:react for")+" "+i.id),se(i.id)}},Et=t=>`
|
|
243
|
+
export { IconRenderer } from 'likec4:icons/${t}'
|
|
244
|
+
export {
|
|
245
|
+
$likec4data,
|
|
246
|
+
$likec4model,
|
|
247
|
+
useLikeC4Model,
|
|
248
|
+
useLikeC4Views,
|
|
249
|
+
useLikeC4View
|
|
250
|
+
} from 'likec4:model/${t}'
|
|
251
|
+
export const projectId = ${JSON.stringify(t)}
|
|
252
|
+
`,Mt={id:"likec4:single-project",virtualId:"likec4:plugin/single-project.js",async load({logger:t,projects:e}){const i=G(e);return t.info(N.dim("generating likec4:single-project for")+" "+i.id),Et(i.id)}},de=[Lt,wt,pt,gt,yt,St],ce=[...de,Rt],le=[ae,oe,Mt,Tt,ut,ht,vt,Ct,It];function bt({useOverviewGraph:t=!1,...e}){let i,n,r,a,c=e.watch??!1;return{name:"vite-plugin-likec4",async configResolved(o){if(i=o.root,n=o.logger,t===!0){const d=o.resolve.alias.find(u=>u.find==="likec4/previews")?.replacement;
|
|
253
|
+
d?(a=d,n.info(N.dim("likec4/previews alias")+" "+N.dim(a))):n.warn("likec4/previews alias not found")}if(e.languageServices)r=e.languageServices;else{const d=c=e.watch??o.mode==="development";r=(await je.fromWorkspace(e.workspace??o.root,{logger:n,graphviz:e.graphviz??"wasm",printErrors:e.printErrors??!0,throwIfInvalid:e.throwIfInvalid??!1,watch:d})).languageServices}a=r.workspaceUri.fsPath},resolveId(o){for(const d of ce){const u=d.matches(o);if(u)return d.virtualId(u)}for(const d of le)if(d.id===
|
|
254
|
+
o)return d.virtualId;return null},async load(o){for(const d of ce){const u=d.matches(o);if(u){const f=r.project(u);return await d.load({logger:n,likec4:r,project:f,assetsDir:a,useOverviewGraph:t})}}for(const d of le)if(d.virtualId===o){const u=r.projects();return pe(ue(u)),await d.load({logger:n,likec4:r,projects:u,assetsDir:a,useOverviewGraph:t})}return null},configureServer(o){const d=()=>A(r.projects(),z(["id","title"]));let u=d();const f=async g=>{const p=o.moduleGraph.getModuleById(g);if(p&&
|
|
255
|
+
p.importers.size>0){n.info(`${N.green("reload")} ${N.dim(p.id??p.url)}`);try{await o.reloadModule(p)}catch(w){n.error(w)}}};r.builder.onModelParsed(async()=>{const[g]=r.getErrors();if(g){o.ws.send({type:"error",err:{name:"LikeC4ValidationError",message:`Validation failed
|
|
256
|
+
`+g.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:fe(i,g.sourceFsPath),line:g.range.start.line+1,column:g.range.start.character+1}}});return}const p=d();ge(p,u)||(u=p,await f(ae.virtualId),await f(oe.virtualId));for(const w of u)for(const l of de)await f(l.virtualId(w.id))})},async buildEnd(){c&&await r.dispose()}}}export{h as C,bt as L,s as N,te as a,ee as b,L as e,re as g,y as j,k as t};
|