likec4 1.36.1 → 1.37.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/{index-iX7kahqQ.js → index-CIsxIzOH.js} +23 -53
- package/__app__/src/main.js +2052 -1804
- package/__app__/src/style.css +1 -1
- package/__app__/src/webcomponent.tsx +0 -22
- package/dist/cli/index.mjs +255 -255
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/shared/likec4.B6V1NOky.mjs +258 -0
- package/dist/shared/likec4.B7noVoso.mjs +2 -0
- package/dist/shared/{likec4.C9tWFblu.mjs → likec4.BKp9_9LQ.mjs} +1729 -1714
- package/dist/shared/{likec4.CoVNuZKl.d.mts → likec4.cqC6tNHO.d.mts} +2108 -2038
- package/dist/vite-plugin/index.d.mts +2 -2
- package/dist/vite-plugin/index.mjs +2 -2
- package/dist/vite-plugin/internal.mjs +7 -9
- package/package.json +15 -15
- package/react/index.d.mts +2145 -72
- package/react/index.mjs +37 -50
- package/vite-plugin-modules.d.ts +2 -1
- package/dist/shared/likec4.0TN5MWXf.mjs +0 -239
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LikeC4Model } from '@likec4/core/model';
|
|
2
2
|
import { UnknownLayouted } from './model/index.mjs';
|
|
3
|
-
import { W as WorkspaceFolder, a as LikeC4Services, L as LikeC4LanguageServices, b as LikeC4Views, R as Range } from './shared/likec4.
|
|
3
|
+
import { W as WorkspaceFolder, a as LikeC4Services, L as LikeC4LanguageServices, b as LikeC4Views, R as Range } from './shared/likec4.cqC6tNHO.mjs';
|
|
4
4
|
import { ProjectId, NonEmptyArray } from '@likec4/core';
|
|
5
5
|
import { DiagramView } from '@likec4/core/types';
|
|
6
6
|
export * from '@likec4/core/types';
|
|
7
7
|
import 'type-fest';
|
|
8
|
-
import '/home/runner/work/likec4/likec4/node_modules/.pnpm/@types+picomatch@4.0.2/node_modules/@types/picomatch/
|
|
8
|
+
import '/home/runner/work/likec4/likec4/node_modules/.pnpm/@types+picomatch@4.0.2/node_modules/@types/picomatch/index.d.ts';
|
|
9
9
|
import '@likec4/core/utils';
|
|
10
10
|
|
|
11
11
|
type Logger = {
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LikeC4Model as o}from"@likec4/core/model";export{L as LikeC4}from"./shared/likec4.
|
|
1
|
+
import{LikeC4Model as o}from"@likec4/core/model";export{L as LikeC4}from"./shared/likec4.BKp9_9LQ.mjs";import"node:fs";import"node:path";import"node:url";import"./shared/likec4.BeWJWU7_.mjs";import"tty";import"node:util";import"util";import"path";import"os";import"crypto";import"net";import"url";import"fs";import"child_process";import"@likec4/core";import"@likec4/core/types";import"events";import"@hpcc-js/wasm-graphviz";import"buffer";import"@likec4/core/compute-view";import"@likec4/core/utils";
|
|
2
2
|
import"node:process";import"boxen";import"node:child_process";import"node:events";import"node:fs/promises";import"node:stream/promises";import"node:readline/promises";import"node:os";import"fs/promises";function t(r){return o.create(r)}export{t as createLikeC4Model};
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import{invariant as ce,isNonEmptyArray as le}from"@likec4/core";import{relative as pe}from"node:path";import{k as ue}from"./likec4.B7noVoso.mjs";import{f as fe,g as J,T as ge,N as W,i as he,n as U,j as _,u as I,l as me,C as we,m as Ie,a as Ne,b as ye,c as ve,d as V,e as ke,h as G,L as $e}from"./likec4.BKp9_9LQ.mjs";import{compareNatural as Le}from"@likec4/core/utils";import{u as je}from"./likec4.BeWJWU7_.mjs";import{RichText as Se}from"@likec4/core/types";function Ce(...n){return je(Re,n)}function Re(n,e){
|
|
2
|
+
let i={};for(let t of e)t in n&&(i[t]=n[t]);return i}function Te(n){var e,i;if(n){if("astNode"in n)return Me(n);if(Array.isArray(n))return n.reduce(z,void 0);{const t=n,r=Ee(t)?be((i=(e=t?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:t?.astNode):void 0;return C(t,r)}}else return}function Ee(n){return typeof n<"u"&&"element"in n&&"text"in n}function be(n){try{return J(n).uri.toString()}catch{return}}function Me(n){var e,i;const{astNode:t,property:r,index:s}=n??{},a=(e=t?.$cstNode)!==
|
|
3
|
+
null&&e!==void 0?e:t?.$textRegion;if(!(t===void 0||a===void 0)){if(r===void 0)return C(a,O(t));{const o=c=>s!==void 0&&s>-1&&Array.isArray(t[r])?s<c.length?c[s]:void 0:c.reduce(z,void 0);if(!((i=a.assignments)===null||i===void 0)&&i[r]){const c=o(a.assignments[r]);return c&&C(c,O(t))}else if(t.$cstNode){const c=o(fe(t.$cstNode,r));return c&&C(c,O(t))}else return}}}function O(n){var e,i,t,r;return n.$cstNode?(i=(e=J(n))===null||e===void 0?void 0:e.uri)===null||i===void 0?void 0:i.toString():n.$textRegion?
|
|
4
|
+
n.$textRegion.documentURI||((r=(t=new ge(n,s=>s.$container?[s.$container]:[]).find(s=>{var a;return(a=s.$textRegion)===null||a===void 0?void 0:a.documentURI}))===null||t===void 0?void 0:t.$textRegion)===null||r===void 0?void 0:r.documentURI):void 0}function C(n,e){var i,t;const r={offset:n.offset,end:(i=n.end)!==null&&i!==void 0?i:n.offset+n.length,length:(t=n.length)!==null&&t!==void 0?t:n.end-n.offset};return n.range&&(r.range=n.range),e??(e=n.fileURI),e&&(r.fileURI=e),r}function z(n,e){var i,
|
|
5
|
+
t;if(n){if(!e)return n&&C(n)}else return e&&C(e);const r=(i=n.end)!==null&&i!==void 0?i:n.offset+n.length,s=(t=e.end)!==null&&t!==void 0?t:e.offset+e.length,a=Math.min(n.offset,e.offset),o=Math.max(r,s),c=o-a,h={offset:a,end:o,length:c};if(n.range&&e.range&&(h.range={start:e.range.start.line<n.range.start.line||e.range.start.line===n.range.start.line&&e.range.start.character<n.range.start.character?e.range.start:n.range.start,end:e.range.end.line>n.range.end.line||e.range.end.line===n.range.end.
|
|
6
|
+
line&&e.range.end.character>n.range.end.character?e.range.end:n.range.end}),n.fileURI||e.fileURI){const p=n.fileURI,f=e.fileURI,u=p&&f&&p!==f?`<unmergable text regions of ${p}, ${f}>`:p??f;h.fileURI=u}return h}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=="number"&&(this.defaultIndentation="".padStart(e))}get content(){
|
|
7
|
+
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 t=i&&this.currentPosition;this.lines[this.currentLineNumber].push(e),this.length+=e.length,t&&this.indentPendingTraceRegions(t)}}indentPendingTraceRegions(e){
|
|
8
|
+
for(let i=this.traceData.length-1;i>=0;i--){const t=this.traceData[i];t.targetStart&&t.targetStart.offset===e.offset&&(t.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(){this.length-=this.lines[this.currentLineNumber].join("").length,this.lines[this.
|
|
9
|
+
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,t=>{var r,s;return(s=(r=this.traceData[this.traceData.length-1])===null||r===void 0?void 0:r.children)===null||s===void 0?void 0:s.push(t)});return this.traceData.push(i),i}popTraceRegion(e){const i=this.traceData.pop();return this.assertTrue(i===e,"Trace region misma\
|
|
10
|
+
tch!"),i}getParentTraceSourceFileURI(){var e;for(let i=this.traceData.length-1;i>-1;i--){const t=(e=this.traceData[i].sourceRegion)===null||e===void 0?void 0:e.fileURI;if(t)return t}}assertTrue(e,i){if(!e)throw new Error(i)}}function Ue(n,e,i){const t={sourceRegion:n,targetRegion:void 0,children:[],targetStart:e,complete:r=>{var s,a;return t.targetRegion={offset:t.targetStart.offset,end:r.offset,length:r.offset-t.targetStart.offset,range:{start:{line:t.targetStart.line,character:t.targetStart.character},
|
|
11
|
+
end:{line:r.line,character:r.character}}},delete t.targetStart,((s=t.children)===null||s===void 0?void 0:s.length)===0&&delete t.children,!((a=t.targetRegion)===null||a===void 0)&&a.length&&i(t),delete t.complete,t}};return t}function Pe(n,e){const i=new xe(e),t=i.pushTraceRegion(void 0);B(n,i),i.popTraceRegion(t),t.complete&&t.complete(i.currentPosition);const r=t.children&&t.children.length===1?t.children[0]:void 0,s=r?.targetRegion,a=t.targetRegion;return s&&r.sourceRegion&&s.offset===a.offset&&
|
|
12
|
+
s.length===a.length?{text:i.content,trace:r}:{text:i.content,trace:t}}function B(n,e){typeof n=="string"?De(n,e):n instanceof A?_e(n,e):n instanceof g?H(n,e):n instanceof b&&Oe(n,e)}function Y(n,e){return typeof n=="string"?n.length!==0:n instanceof g?n.contents.some(i=>Y(i,e)):n instanceof b?!(n.ifNotEmpty&&e.currentLineContent.length===0):!1}function De(n,e){n&&(q(e,!1),e.append(n))}function q(n,e){var i;if(n.pendingIndent){let t="";for(const r of n.relevantIndents.filter(s=>s.indentEmptyLines||
|
|
13
|
+
!e))t+=(i=r.indentation)!==null&&i!==void 0?i:n.defaultIndentation;n.append(t,!0),n.pendingIndent=!1}}function H(n,e){let i;const t=Te(n.tracedSource);t&&(i=e.pushTraceRegion(t));for(const r of n.contents)B(r,e);if(i){e.popTraceRegion(i);const r=e.getParentTraceSourceFileURI();r&&t?.fileURI===r&&delete t.fileURI,i.complete&&i.complete(e.currentPosition)}}function _e(n,e){var i;if(Y(n,e)){n.indentImmediately&&!e.pendingIndent&&e.append((i=n.indentation)!==null&&i!==void 0?i:e.defaultIndentation,!0);
|
|
14
|
+
try{e.increaseIndent(n),H(n,e)}finally{e.decreaseIndent()}}}function Oe(n,e){n.ifNotEmpty&&!Fe(e.currentLineContent)?e.resetCurrentLine():(q(e,!0),e.append(n.lineDelimiter),e.addNewLine())}function Fe(n){return n.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");const Ae=/\S|$/;function Je(n){const e=n.filter(t=>t.length>0).map(t=>t.search(Ae)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function L(n,...e){const i=Ve(n),t=Ge(n,e,i);return Be(t)}function We(n,e,i){return(t,...r)=>qe(
|
|
15
|
+
n,e,i)(L(t,...r))}function Ve(n){const e=n.join("_").split(W),i=e.length>1&&e[0].trim().length===0,t=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:t,trimLastLine:e.length!==1&&e[e.length-1].trim().length===0};{let r=i?e.slice(1):e;r=t?r.slice(0,r.length-1):r,r=r.filter(a=>a.length!==0);const s=Je(r);return{indentation:s,omitFirstLine:i,omitLastLine:t&&(e[e.
|
|
16
|
+
length-1].length<s||!e[e.length-1].startsWith(r[0].substring(0,s)))}}}function Ge(n,e,{indentation:i,omitFirstLine:t,omitLastLine:r,trimLastLine:s}){const a=[];n.forEach((h,p)=>{a.push(...h.split(W).map((f,u)=>u===0||f.length<i?f:f.substring(i)).reduce(p===0?(f,u,m)=>m===0?t?[]:[u]:m===1&&f.length===0?[u]:f.concat(P,u):(f,u,m)=>m===0?[u]:f.concat(P,u),[]).filter(f=>!(typeof f=="string"&&f.length===0)).concat(E(e[p])?e[p]:e[p]!==void 0?{content:String(e[p])}:p<e.length?K:[]))});const o=a.length,c=o!==
|
|
17
|
+
0?a[o-1]:void 0;return(r||s)&&typeof c=="string"&&c.trim().length===0?t&&o!==1&&a[o-2]===P?a.slice(0,o-2):a.slice(0,o-1):a}const P={isNewLine:!0},K={isUndefinedSegment:!0},X=n=>n===P,F=n=>n===K,ze=n=>n.content!==void 0;function Be(n){return n.reduce((i,t,r)=>F(t)?i:X(t)?{node:r!==0&&(F(n[r-1])||E(n[r-1]))||r>1&&typeof n[r-1]=="string"&&(F(n[r-2])||E(n[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{var s;const a=(r===0||X(n[r-1]))&&typeof t=="string"&&t.length!==0?"".padStart(
|
|
18
|
+
t.length-t.trimStart().length):"",o=ze(t)?t.content:t;let c;return{node:i.indented?i.node:a.length!==0?i.node.indent({indentation:a,indentImmediately:!1,indentedChildren:h=>c=h.append(o)}):i.node.append(o),indented:c??((s=i.indented)===null||s===void 0?void 0:s.append(o))}})(),{node:new g}).node}const Ye=typeof process>"u"?`
|
|
19
|
+
`:process.platform==="win32"?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`;function E(n){return n instanceof g||n instanceof A||n instanceof b}function j(n,e){return E(n)?Pe(n,e).text:String(n)}class g{constructor(...e){this.contents=[],this.append(...e)}isEmpty(){return this.contents.length===0}trace(e,i,t){if(he(e)){if(this.tracedSource={astNode:e,property:i,index:t},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(d)}appendNewLineIf(e){return e?this.append(d):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,...t)=>this.appendTemplate(i,...t):()=>this}indent(e){const{indentedChildren:i,indentation:t,indentEmptyLines:r,indentImmediately:s}=Array.isArray(e)||typeof e=="function"?{indentedChildren:e}:typeof e=="object"?e:{},a=new A(t,s,r);return this.contents.push(a),Array.isArray(i)?a.append(...i):i&&a.append(i),this}appendTraced(e,i,t){return r=>this.append(new g().trace(e,i,t).append(r))}appendTracedIf(e,i,t,r){return e?this.appendTraced(typeof i=="function"?
|
|
24
|
+
i():i,t,r):()=>this}appendTracedTemplate(e,i,t){return(r,...s)=>this.append(We(e,i,t)(r,...s))}appendTracedTemplateIf(e,i,t,r){return e?this.appendTracedTemplate(typeof i=="function"?i():i,t,r):()=>this}}function qe(n,e,i){return t=>t instanceof g&&t.tracedSource===void 0?t.trace(n,e,i):new g().trace(n,e,i).append(t)}class A extends g{constructor(e,i=!0,t=!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=t}}class b{constructor(e,i=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??Ye,this.ifNotEmpty=i}}const d=new b,He=new b(void 0,!0),Q=n=>n===void 0||typeof n=="string"||E(n)?n:String(n);function v(n,e=Q,i={}){const t=typeof e=="function"?e:Q,{filter:r,prefix:s,suffix:a,separator:o,appendNewLineIfNotEmpty:c,skipNewLineAfterLastItem:h}=typeof e=="object"?e:i,p=typeof s=="function"?s:()=>s,f=typeof a=="function"?a:()=>a;return Ke(n,(u,m,w,l)=>{
|
|
26
|
+
if(r&&!r(m,w,l))return u;const N=t(m,w,l);return N===void 0?u:(u??(u=new g)).append(p(m,w,l)).append(N).append(f(m,w,l)).appendIf(!l,o).appendNewLineIfNotEmptyIf(!u.isEmpty()&&!!c&&(!l||!h))})}function Ke(n,e,i){const t=n[Symbol.iterator]();let r=t.next(),s=0,a=i;for(;!r.done;){const o=t.next();a=e(a,r.value,s,!!o.done),r=o,s++}return a}const Xe=n=>n.charAt(0).toLocaleUpperCase()+n.slice(1),Qe=n=>n.split(".").map(Xe).join(""),Ze=n=>Qe(n.parent?n.id.slice(n.parent.length+1):n.id),en=({autoLayout:n})=>{
|
|
27
|
+
switch(n.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},nn=({shape:n})=>{switch(n){case"queue":case"cylinder":case"rectangle":case"person":return n;case"storage":return"stored_data";case"mobile":case"browser":return"rectangle"}};function Z(n){const e=n.$view,{nodes:i,edges:t}=e,r=new Map,s=(o,c)=>{const h=Ze(o),p=(c?c+".":"")+h;r.set(o.id,p);const f=JSON.stringify(o.title),u=nn(o);return new g().append(h,": {",d).indent({indentedChildren:m=>m.
|
|
28
|
+
append("label: ",f,d).appendIf(u!=="rectangle","shape: ",u,d).appendIf(o.children.length>0,d,v(i.filter(w=>w.parent===o.id),w=>s(w,p))),indentation:2}).append("}",d)},a=o=>new g().append(r.get(o.source)," -> ",r.get(o.target)).append(c=>o.label&&c.append(": ",JSON.stringify(o.label)));return j(new g().append("direction: ",en(e),d,d).append(v(i.filter(o=>U(o.parent)),o=>s(o),{appendNewLineIfNotEmpty:!0})).appendIf(t.length>0,d,v(t,o=>a(o),{appendNewLineIfNotEmpty:!0})))}const tn=n=>n.charAt(0).toLocaleUpperCase()+
|
|
29
|
+
n.slice(1),rn=n=>n.split(".").map(tn).join(""),on=n=>rn(n.parent?n.id.slice(n.parent.length+1):n.id),an=({shape:n})=>{switch(n){case"queue":case"cylinder":return["[(",")]"];case"person":return["[fa:fa-user ","]"];case"storage":return["([","])"];case"mobile":case"browser":case"rectangle":return["[","]"]}};function ee(n){const e=n.$view,{nodes:i,edges:t}=e,r=new Map,s=(o,c)=>{const h=on(o),p=(c?c+".":"")+h;r.set(o.id,p);const f=o.title.replaceAll(`
|
|
30
|
+
`,"\\n"),u=an(o),m=new g;return o.children.length>0?m.append("subgraph ",p,"[",JSON.stringify(o.title),"]",d).indent({indentedChildren:[v(i.filter(w=>w.parent===o.id),w=>s(w,p),{appendNewLineIfNotEmpty:!0})],indentation:2}).append("end",d):m.append(p,u[0],f,u[1]),m},a=o=>new g().append(r.get(o.source)," -.",o.label?' "'+o.label.replaceAll(`
|
|
31
|
+
`,"\\n")+'" .-':"-","> ",r.get(o.target));return j(new g().appendIf(e.title!==null&&e.title.length>0,"---",d,`title: ${JSON.stringify(e.title)}`,d,"---",d).append("graph ",e.autoLayout.direction,d).indent({indentedChildren:o=>{o.append(v(i.filter(c=>U(c.parent)),c=>s(c),{appendNewLineIfNotEmpty:!0})).appendIf(t.length>0,v(t,c=>a(c),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}const sn=n=>n.charAt(0).toLocaleUpperCase()+n.slice(1),D=n=>n.split(".").map(sn).join(""),ne=n=>D(n.parent?n.id.slice(
|
|
32
|
+
n.parent.length+1):n.id),R=(n,e,i="#3b82f6")=>{switch(n){case"blue":case"primary":return"#3b82f6";case"amber":return"#a35829";case"gray":return"#737373";case"green":return"#428a4f";case"indigo":return"#6366f1";case"slate":case"muted":return"#64748b";case"red":return"#ac4d39";case"sky":case"secondary":return"#0284c7";case null:case void 0:return i;default:return e(n)||n}},dn=({autoLayout:n})=>{switch(n.direction){case"TB":return"top to bottom";case"BT":return console.warn("Bottom to top direction\
|
|
33
|
+
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"}},te=({shape:n})=>{switch(n){case"queue":case"rectangle":case"person":return n;case"storage":case"cylinder":return"database";case"mobile":case"browser":return"rectangle"}},T=n=>U(n)?null:JSON.stringify(n).slice(1,-1);function ie(n){const e=n.$view,i=n.$model.specification.customColors??
|
|
34
|
+
{},{nodes:t,edges:r}=e,s=new Map(Object.entries(i)),a=l=>N=>s.get(N)?.elements[l],o=l=>N=>s.get(N)?.relationships[l],c=new Map,h=()=>new g().append('title "',e.title||e.id,'"',d).append(dn(e)," direction",d),p=()=>new g().append("hide stereotype",d).append("skinparam ranksep ","60",d).append("skinparam nodesep ","30",d).append("skinparam {",d).indent({indentedChildren:l=>l.append("arrowFontSize ","10",d).append("defaultTextAlignment ","center",d).append("wrapWidth ","200",d).append("maxMessageSi\
|
|
35
|
+
ze ","100",d).append("shadowing ","false",d),indentation:2}).append("}",d),f=l=>{const N=te(l),y=D(l.id);return new g().append("skinparam ",N,"<<",y,">>","{",d).indent({indentedChildren:$=>$.append("BackgroundColor ",R(l.color,a("fill")),d).append("FontColor ",s.has(l.color)?R(l.color,a("hiContrast")):"#FFFFFF",d).append("BorderColor ",R(l.color,a("stroke")),d),indentation:2}).append("}",d)},u=l=>{const N=te(l),y=D(l.id),$=T(l.title)||ne(l),k=T(l.technology);c.set(l.id,y);const x=Se.from(l.description);
|
|
36
|
+
return new g().append(N," ").append('"').append("==",$).appendIf(!!k,"\\n","<size:10>[",k,"]</size>").appendIf(x.nonEmpty,"\\n\\n",T(x.text)).append('"'," <<",y,">> ","as ",y,d)},m=l=>{const N=T(l.title)||ne(l),y=D(l.id);return c.set(l.id,y),new g().append('rectangle "',N,'" <<',y,">> as ",y," {",d).indent({indentedChildren:$=>$.append("skinparam ","RectangleBorderColor<<",y,">> ",R(l.color,a("fill")),d).append("skinparam ","RectangleFontColor<<",y,">> ",R(l.color,a("fill")),d).append("skinparam\
|
|
37
|
+
","RectangleBorderStyle<<",y,">> ","dashed",d,d).append(v(t.filter(k=>k.parent===l.id),k=>k.children.length>0?m(k):u(k))),indentation:2}).append("}",d)},w=l=>{const N=T(l.technology)||"",y=T(l.label)||"",$=R(l.color,o("lineColor"),"#777777"),k=x=>`<color:${x}>`;return new g().append(c.get(l.source)," .[",$,",thickness=2].> ",c.get(l.target)).appendIf(!!(y||N),' : "',k($)).appendIf(!!y,y,k($)).appendIf(!!(y&&N),"\\n").appendIf(!!N,k($),"<size:8>[",N,"]</size>").appendIf(!!(y||N),'"').append(d)};
|
|
38
|
+
return j(new g().append("@startuml",d).append(h(),d).append(p(),d).append(v(t.filter(l=>l.children.length==0),l=>f(l),{appendNewLineIfNotEmpty:!0})).append(v(t.filter(l=>U(l.parent)),l=>l.children.length>0?m(l):u(l),{appendNewLineIfNotEmpty:!0})).appendIf(r.length>0,d,v(r,l=>w(l),{appendNewLineIfNotEmpty:!0})).append("@enduml",d))}function S(n){return{matches:e=>{let{module:i,projectId:t}=e.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.groups??e.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.
|
|
39
|
+
groups??{};return!i||!t?null:(i.endsWith(".js")&&(i=i.slice(0,-3)),i===n?t:null)},virtualId:e=>_("likec4:plugin",e,n)+".js"}}const cn={"<":"\\u003C",">":"\\u003E","/":"\\u002F","\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};function ln(n){return n.replace(/[<>\b\f\n\r\t\0\u2028\u2029\\]/g,e=>cn[e])}function M(n,e){return{id:`likec4:${n}`,virtualId:`likec4:plugin/${n}.js`,async load({likec4:i,logger:t,projects:r,assetsDir:s}){t.
|
|
40
|
+
info(I.dim(`generating likec4:${n}`));const a=r.map(({id:o})=>{const c=ln(JSON.stringify(_(`likec4:${n}`,o)));return` ${JSON.stringify(o)}: () => import(${c})`});return`
|
|
41
|
+
export let ${e}Fn = {
|
|
42
|
+
${a.join(`,
|
|
43
|
+
`)}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function ${e}(projectId) {
|
|
47
|
+
const fn = ${e}Fn[projectId]
|
|
48
|
+
if (!fn) {
|
|
49
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
50
|
+
}
|
|
51
|
+
return await fn()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (import.meta.hot) {
|
|
55
|
+
import.meta.hot.accept(md => {
|
|
56
|
+
if (!import.meta.hot.data.$update) {
|
|
57
|
+
import.meta.hot.data.$update = ${e}Fn
|
|
58
|
+
}
|
|
59
|
+
const update = md.${e}Fn
|
|
60
|
+
if (update) {
|
|
61
|
+
Object.assign(import.meta.hot.data.$update, update)
|
|
62
|
+
} else {
|
|
63
|
+
import.meta.hot.invalidate()
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
`}}}function pn(n){const e=new g;return e.appendTemplate`
|
|
68
|
+
/******************************************************************************
|
|
69
|
+
* This file was generated
|
|
70
|
+
* DO NOT EDIT MANUALLY!
|
|
71
|
+
******************************************************************************/
|
|
72
|
+
/* eslint-disable */
|
|
73
|
+
|
|
74
|
+
export function d2Source(viewId) {
|
|
75
|
+
switch (viewId) {
|
|
76
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(v([...n.views()],t=>L`
|
|
77
|
+
case ${JSON.stringify(t.id)}: {
|
|
78
|
+
return ${JSON.stringify(Z(t))}
|
|
79
|
+
}
|
|
80
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
81
|
+
default: {
|
|
82
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
83
|
+
}
|
|
84
|
+
`}}).append(d," }",d).appendTemplate`
|
|
85
|
+
}
|
|
86
|
+
`.append(d,d),j(e)}const un={...S("d2"),async load({likec4:n,project:e,logger:i}){i.info(I.dim(`generating likec4:d2/${e.id}`));const t=await n.computedModel(e.id);return pn(t)}},fn=M("d2","loadD2Sources");function gn(n){const e=new g;return e.appendTemplate`
|
|
87
|
+
/******************************************************************************
|
|
88
|
+
* This file was generated
|
|
89
|
+
* DO NOT EDIT MANUALLY!
|
|
90
|
+
******************************************************************************/
|
|
91
|
+
/* eslint-disable */
|
|
92
|
+
|
|
93
|
+
export function dotSource(viewId) {
|
|
94
|
+
switch (viewId) {
|
|
95
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(v(Object.keys(n),t=>L`
|
|
96
|
+
case ${JSON.stringify(t)}: {
|
|
97
|
+
return ${JSON.stringify(n[t].dot)}
|
|
98
|
+
}
|
|
99
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
100
|
+
default: {
|
|
101
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
102
|
+
}
|
|
103
|
+
`}}).append(d," }",d).appendTemplate`
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function svgSource(viewId) {
|
|
107
|
+
switch (viewId) {
|
|
108
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(v(Object.keys(n),t=>L`
|
|
109
|
+
case ${JSON.stringify(t)}: {
|
|
110
|
+
return ${JSON.stringify(n[t].svg)}
|
|
111
|
+
}
|
|
112
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
113
|
+
default: {
|
|
114
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
115
|
+
}
|
|
116
|
+
`}}).append(d," }",d,"}",d,d),j(e)}const hn={...S("dot"),async load({likec4:n,project:e,logger:i}){i.info(I.dim(`generating likec4:dot/${e.id}`));const t=await n.views.viewsAsGraphvizOut(e.id),r=me(t,({id:s,svg:a,dot:o})=>[s,{dot:o,svg:a}]);return gn(r)}},mn=M("dot","loadDotSources");function wn(n){const e=we(n.flatMap(r=>r.nodes.map(s=>s.icon)),ye(r=>ve(r)&&!(r.toLowerCase().startsWith("http:")||r.toLowerCase().startsWith("https:"))),Ne(),Ie(Le)),{imports:i,cases:t}=e.reduce((r,s,a)=>{
|
|
117
|
+
const o=s.startsWith("file:"),c="Icon"+a.toString().padStart(2,"0");if(o)return r.imports.push(`import ${c} from '${s}?inline'`),r.cases.push(` '${s}': () => jsx('img', { src: ${c} })`),r;const[h,p]=s.split(":");return r.imports.push(`import ${c} from 'likec4/icons/${h}/${p}'`),r.cases.push(` '${h}:${p}': ${c}`),r},{imports:[],cases:[]});return`
|
|
118
|
+
import { jsx } from 'react/jsx-runtime'
|
|
119
|
+
${i.join(`
|
|
120
|
+
`)}
|
|
121
|
+
|
|
122
|
+
const Icons = {
|
|
123
|
+
${t.join(`,
|
|
124
|
+
`)}
|
|
125
|
+
}
|
|
126
|
+
export function IconRenderer(props) {
|
|
127
|
+
const IconComponent = Icons[props.node.icon ?? '']
|
|
128
|
+
if (!IconComponent) {
|
|
129
|
+
return null
|
|
130
|
+
}
|
|
131
|
+
return jsx(IconComponent, props)
|
|
132
|
+
}
|
|
133
|
+
`}const In={...S("icons"),async load({likec4:n,project:e,logger:i}){i.info(I.dim(`generating likec4:icons/${e.id}`));const t=await n.views.computedViews(e.id);return wn(t)}},Nn={id:"likec4:icons",virtualId:"likec4:plugin/icons.jsx",async load({likec4:n,projects:e,logger:i}){i.info(I.dim("generating likec4:icons"));const{imports:t,cases:r}=e.reduce((s,{id:a},o)=>{const c="Icons"+o.toString().padStart(2,"0"),h=_("likec4:icons",a);return s.imports.push(`import { IconRenderer as ${c} } from ${JSON.stringify(
|
|
134
|
+
h)}`),s.cases.push(` case ${JSON.stringify(a)}: return ${c}`),s},{imports:[],cases:[]});return`
|
|
135
|
+
import { jsx } from 'react/jsx-runtime'
|
|
136
|
+
${t.join(`
|
|
137
|
+
`)}
|
|
138
|
+
|
|
139
|
+
function getProjectIcons(projectId) {
|
|
140
|
+
switch (projectId) {
|
|
141
|
+
${r.join(`
|
|
142
|
+
`)}
|
|
143
|
+
default:
|
|
144
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function ProjectIcons({ projectId, ...props }) {
|
|
149
|
+
const IconComponent = getProjectIcons(projectId)
|
|
150
|
+
return jsx(IconComponent, props)
|
|
151
|
+
}
|
|
152
|
+
`}};function yn(n){const e=new g;return e.appendTemplate`
|
|
153
|
+
/******************************************************************************
|
|
154
|
+
* This file was generated
|
|
155
|
+
* DO NOT EDIT MANUALLY!
|
|
156
|
+
******************************************************************************/
|
|
157
|
+
/* eslint-disable */
|
|
158
|
+
|
|
159
|
+
export function mmdSource(viewId) {
|
|
160
|
+
switch (viewId) {
|
|
161
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(v([...n.views()],t=>L`
|
|
162
|
+
case ${JSON.stringify(t.id)}: {
|
|
163
|
+
return ${JSON.stringify(ee(t))}
|
|
164
|
+
}
|
|
165
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
166
|
+
default: {
|
|
167
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
168
|
+
}
|
|
169
|
+
`}}).append(d," }",d).appendTemplate`
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
`.append(d,d),j(e)}const vn={...S("mmd"),async load({likec4:n,project:e,logger:i}){i.info(I.dim(`generating virtual:likec4/mmd/${e.id}`));const t=await n.computedModel(e.id);return yn(t)}},kn=M("mmd","loadMmdSources"),$n=n=>`
|
|
173
|
+
import { createHooksForModel, atom } from 'likec4/vite-plugin/internal'
|
|
174
|
+
|
|
175
|
+
export const $likec4data = atom(${V.stringify(n.$data)})
|
|
176
|
+
|
|
177
|
+
export const {
|
|
178
|
+
updateModel,
|
|
179
|
+
$likec4model,
|
|
180
|
+
useLikeC4Model,
|
|
181
|
+
useLikeC4Views,
|
|
182
|
+
useLikeC4View
|
|
183
|
+
} = createHooksForModel($likec4data)
|
|
184
|
+
|
|
185
|
+
if (import.meta.hot) {
|
|
186
|
+
import.meta.hot.accept(md => {
|
|
187
|
+
if (!import.meta.hot.data.$update) {
|
|
188
|
+
import.meta.hot.data.$update = updateModel
|
|
189
|
+
}
|
|
190
|
+
const update = md.$likec4data?.get()
|
|
191
|
+
if (update) {
|
|
192
|
+
import.meta.hot.data.$update(update)
|
|
193
|
+
} else {
|
|
194
|
+
import.meta.hot.invalidate()
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
`,Ln={...S("model"),async load({likec4:n,project:e,logger:i,assetsDir:t}){i.info(I.dim(`generating likec4:model/${e.id}`));const r=await n.layoutedModel(e.id);return $n(r)}},jn=M("model","loadModel"),Sn=n=>`
|
|
199
|
+
export const isSingleProject = ${n.length===1};
|
|
200
|
+
export const projects = ${V.stringify(n,null,2)};
|
|
201
|
+
`,re={id:"likec4:projects",virtualId:"likec4:plugin/projects.js",async load({logger:n,projects:e}){return n.info(I.dim("generating likec4:projects")),Sn(ke(e,Ce(["id","title"])))}};function Cn(n){const e=new g;return e.appendTemplate`
|
|
202
|
+
/******************************************************************************
|
|
203
|
+
* This file was generated
|
|
204
|
+
* DO NOT EDIT MANUALLY!
|
|
205
|
+
******************************************************************************/
|
|
206
|
+
/* eslint-disable */
|
|
207
|
+
|
|
208
|
+
export function pumlSource(viewId) {
|
|
209
|
+
switch (viewId) {
|
|
210
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(v([...n.views()],t=>L`
|
|
211
|
+
case ${JSON.stringify(t.id)}: {
|
|
212
|
+
return ${JSON.stringify(ie(t))}
|
|
213
|
+
}
|
|
214
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
215
|
+
default: {
|
|
216
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
217
|
+
}
|
|
218
|
+
`}}).append(d," }",d).appendTemplate`
|
|
219
|
+
}
|
|
220
|
+
`.append(d,d),j(e)}const Rn={...S("puml"),async load({likec4:n,project:e,logger:i}){i.info(I.dim(`generating likec4:puml/${e.id}`));const t=await n.computedModel(e.id);return Cn(t)}},Tn=M("puml","loadPumlSources"),oe=n=>`
|
|
221
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
222
|
+
import { LikeC4ModelProvider as Provider, LikeC4View as GenericView, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
|
|
223
|
+
import { IconRenderer } from 'likec4:icons/${n}'
|
|
224
|
+
|
|
225
|
+
import { useLikeC4Model, useLikeC4Views, useLikeC4View } from 'likec4:model/${n}'
|
|
226
|
+
|
|
227
|
+
export function LikeC4ModelProvider({ children }) {
|
|
228
|
+
const likeC4Model = useLikeC4Model()
|
|
229
|
+
return (_jsx(Provider, { likec4model: likeC4Model, children: children }));
|
|
230
|
+
}
|
|
231
|
+
export function LikeC4View(props) {
|
|
232
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericView, { renderIcon: IconRenderer, ...props }) }));
|
|
233
|
+
}
|
|
234
|
+
export function ReactLikeC4(props) {
|
|
235
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericReactLikeC4, { renderIcon: IconRenderer, ...props }) }));
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export {
|
|
239
|
+
useLikeC4Model,
|
|
240
|
+
useLikeC4View,
|
|
241
|
+
useLikeC4Views
|
|
242
|
+
}
|
|
243
|
+
`,En={...S("react"),async load({project:n,logger:e}){return e.info(I.dim(`generating likec4:react/${n.id}`)),oe(n.id)}},bn={id:"likec4:react",virtualId:"likec4:plugin/react.js",async load({logger:n,projects:e}){const i=G(e);return n.info(I.dim("generating likec4:react for")+" "+i.id),oe(i.id)}},Mn=n=>`
|
|
244
|
+
export { IconRenderer } from 'likec4:icons/${n}'
|
|
245
|
+
export {
|
|
246
|
+
$likec4data,
|
|
247
|
+
$likec4model,
|
|
248
|
+
useLikeC4Model,
|
|
249
|
+
useLikeC4Views,
|
|
250
|
+
useLikeC4View
|
|
251
|
+
} from 'likec4:model/${n}'
|
|
252
|
+
export const projectId = ${JSON.stringify(n)}
|
|
253
|
+
`,xn={id:"likec4:single-project",virtualId:"likec4:plugin/single-project.js",async load({likec4:n,logger:e,projects:i,assetsDir:t}){const r=G(i);return e.info(I.dim("generating likec4:single-project for")+" "+r.id),Mn(r.id)}},ae=[Ln,In,un,hn,vn,Rn],se=[...ae,En],de=[re,jn,xn,bn,fn,mn,kn,Tn,Nn],Un=n=>{const e=n.toLowerCase();return e.endsWith(".c4")||e.endsWith(".likec4")||e.endsWith(".like-c4")||e.endsWith(".likec4rc")||e.endsWith("likec4.config.json")};function Pn({useOverviewGraph:n=!1,...e}){
|
|
254
|
+
let i,t,r,s;return{name:"vite-plugin-likec4",async configResolved(a){if(i=a.root,t=a.logger,n===!0){const o=a.resolve.alias.find(c=>c.find==="likec4/previews")?.replacement;o?(s=o,t.info(I.dim("likec4/previews alias")+" "+I.dim(s))):t.warn("likec4/previews alias not found")}e.languageServices?r=e.languageServices:r=(await $e.fromWorkspace(e.workspace??a.root,{logger:t,graphviz:e.graphviz??"wasm",printErrors:e.printErrors??!0,throwIfInvalid:e.throwIfInvalid??!1})).languageServices,s=r.workspaceUri.
|
|
255
|
+
fsPath},resolveId(a){for(const o of se){const c=o.matches(a);if(c)return o.virtualId(c)}for(const o of de)if(o.id===a)return o.virtualId;return null},async load(a){for(const o of se){const c=o.matches(a);if(c){const h=r.project(c);return await o.load({logger:t,likec4:r,project:h,assetsDir:s,useOverviewGraph:n})}}for(const o of de)if(o.virtualId===a){const c=r.projects();return ce(le(c)),await o.load({logger:t,likec4:r,projects:c,assetsDir:s,useOverviewGraph:n})}return null},configureServer(a){let o=r.
|
|
256
|
+
projects();const c=o.map(({folder:p})=>p.fsPath);for(const p of c)t.info(`${I.dim("watch")} ${p}`);const h=p=>f=>{Un(f)&&r.notifyUpdate({[p]:f})};a.watcher.add(c).on("add",h("changed")).on("change",h("changed")).on("unlink",h("removed")),r.builder.onModelParsed(async()=>{const[p]=r.getErrors();if(p){a.ws.send({type:"error",err:{name:"LikeC4ValidationError",message:`Validation failed
|
|
257
|
+
`+p.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:pe(i,p.sourceFsPath),line:p.range.start.line+1,column:p.range.start.character+1}}});return}const f=r.projects();if(!ue(f,o)){o=f;const u=a.moduleGraph.getModuleById(re.virtualId);if(u&&u.importers.size>0){t.info(`${I.green("reload")} ${I.dim(u.id??u.url)}`);try{await a.reloadModule(u)}catch(m){t.error(m)}}}for(const u of o)for(const m of ae){const w=a.moduleGraph.getModuleById(m.virtualId(u.id));if(w&&w.importers.size>0){t.info(
|
|
258
|
+
`${I.green("reload")} ${I.dim(w.id??w.url)}`);try{await a.reloadModule(w)}catch(l){t.error(l)}}}})}}}export{g as C,Pn as L,d as N,ee as a,Z as b,L as e,ie as g,v as j,j as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{u as s}from"./likec4.BeWJWU7_.mjs";function l(...t){return s(i,t)}function i(t,e){if(t===e||Object.is(t,e))return!0;if(typeof t!="object"||typeof e!="object"||t===null||e===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;if(Array.isArray(t))return a(t,e);if(t instanceof Map)return c(t,e);if(t instanceof Set)return g(t,e);if(t instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp)return t.toString()===e.toString();if(Object.keys(t).length!==Object.keys(
|
|
2
|
+
e).length)return!1;for(let[r,f]of Object.entries(t))if(!(r in e)||!i(f,e[r]))return!1;return!0}function a(t,e){if(t.length!==e.length)return!1;for(let[r,f]of t.entries())if(!i(f,e[r]))return!1;return!0}function c(t,e){if(t.size!==e.size)return!1;for(let[r,f]of t.entries())if(!e.has(r)||!i(f,e.get(r)))return!1;return!0}function g(t,e){if(t.size!==e.size)return!1;let r=[...e];for(let f of t){let u=!1;for(let[o,n]of r.entries())if(i(f,n)){u=!0,r.splice(o,1);break}if(!u)return!1}return!0}export{l as k};
|