likec4 1.27.0 → 1.27.2
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/main.js +2415 -6900
- package/__app__/src/style.css +1 -1
- package/dist/cli/index.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/likec4.CfxVv3pJ.mjs +227 -0
- package/dist/shared/{likec4.CqOVETmH.mjs → likec4.D_S6au6n.mjs} +1612 -1611
- package/dist/shared/{likec4.C0T-ybr5.d.mts → likec4.QmEWuoHf.d.mts} +4 -4
- package/dist/vite-plugin/index.d.mts +1 -1
- package/dist/vite-plugin/index.mjs +1 -1
- package/package.json +22 -22
- package/react/index.d.mts +33 -24
- package/react/index.mjs +54 -54
- package/dist/shared/likec4.DRE45BE_.mjs +0 -226
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{h as tt,k as gh,o as at,q as ws,d as zt,u as ee,w as yh,r as _h,s as $h,v as St,t as vh,e as ea,x as ta,c as wh,L as rt,y as bh,z as nt,A as Eh,B as Sh,n as Rh,D as Ah,E as Gt,F as ra,G as Oh,H as or,I as bs,J as na,K as Ch,
|
|
2
|
+
import{h as tt,k as gh,o as at,q as ws,d as zt,u as ee,w as yh,r as _h,s as $h,v as St,t as vh,e as ea,x as ta,c as wh,L as rt,y as bh,z as nt,A as Eh,B as Sh,n as Rh,D as Ah,E as Gt,F as ra,G as Oh,H as or,I as bs,J as na,K as Ch,Y as Ph}from"../shared/likec4.D_S6au6n.mjs";import Re,{hrtime as Ih,cwd as Es,exit as sa,stdout as Th,argv as Nh}from"node:process";import{strictEqual as jh,notStrictEqual as Lh}from"assert";import Ss,{resolve as Ue,dirname as Rs,normalize as Dh,relative as kh,extname as Mh,
|
|
3
3
|
basename as xh}from"path";import{statSync as ia,readdirSync as qh,readFileSync as As,writeFile as Hh}from"fs";import oa,{format as aa,inspect as Uh}from"util";import{fileURLToPath as Fh}from"url";import $e,{resolve as ge,dirname as Rt,join as ar,relative as At,extname as cr,isAbsolute as Os,basename as Lr}from"node:path";import pe,{existsSync as Ot,copyFileSync as ca,readdirSync as Vh,rmSync as Cs}from"node:fs";import{mkdtemp as Dr,writeFile as Ct,mkdir as ct,stat as Ps,copyFile as zh,rm as Gh}from"node:fs/promises";
|
|
4
|
-
import ur,{tmpdir as kr}from"node:os";import{fileURLToPath as ua}from"node:url";import Is from"@vitejs/plugin-react";import{C as la,t as Ts,j as fa,e as da,N as Bt,L as Ns,g as Bh,a as Wh}from"../shared/likec4.
|
|
4
|
+
import ur,{tmpdir as kr}from"node:os";import{fileURLToPath as ua}from"node:url";import Is from"@vitejs/plugin-react";import{C as la,t as Ts,j as fa,e as da,N as Bt,L as Ns,g as Bh,a as Wh}from"../shared/likec4.CfxVv3pJ.mjs";import{build as lr,createServer as Kh,preview as Yh}from"vite";import{sortNaturalByFqn as ha,compareNatural as Xh,hasAtLeast as Jh,invariant as js,nonexhaustive as pa,delay as ma}from"@likec4/core";import{chromium as ga}from"playwright";import Qh from"node:net";import{setTimeout as Zh}from"node:timers/promises";
|
|
5
5
|
import{promisify as Ie,isDeepStrictEqual as ep}from"node:util";import fr from"node:crypto";import tp from"node:assert";import"tty";import"os";import"crypto";import"net";import"child_process";import"@likec4/core/types";import"events";import"buffer";import"@hpcc-js/wasm-graphviz";import"@likec4/core/compute-view";import"@likec4/core/utils";import"boxen";import"node:child_process";import"node:events";import"node:stream/promises";import"fs/promises";import"@likec4/core/model";const rp={right:cp,center:up},
|
|
6
6
|
np=0,Mr=1,sp=2,xr=3;class ip{constructor(e){var r;this.width=e.width,this.wrap=(r=e.wrap)!==null&&r!==void 0?r:!0,this.rows=[]}span(...e){const r=this.div(...e);r.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(""),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]=="string")return this.applyLayoutDSL(e[0]);const r=e.map(n=>typeof n=="string"?this.colFromString(n):n);return this.rows.push(r),r}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]=="string"&&/[\t\n]/.
|
|
7
7
|
test(e[0])}applyLayoutDSL(e){const r=e.split(`
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { DiagramView, ProjectId, NonEmptyArray } from '@likec4/core';
|
|
|
2
2
|
export { AbstractRelation, AutoLayoutDirection, BBox, Color, ComputedDeploymentView, ComputedDynamicView, ComputedEdge, ComputedElementView, ComputedLikeC4ModelData, ComputedNode, ComputedView, DeployedInstance, DeploymentElement, DeploymentNode, DeploymentNodeKind, DeploymentRelation, DeploymentView, DiagramEdge, DiagramNode, DiagramView, DynamicView, EdgeId, Element, ElementKind, ElementView, Fqn, HexColorLiteral, LayoutedLikeC4ModelData, LikeC4View, NodeId, ParsedLikeC4ModelData, Point, RelationExpr, RelationId, StepEdgeId, Tag, ThemeColor, ViewId, XYPoint } from '@likec4/core';
|
|
3
3
|
import { LikeC4Model } from '@likec4/core/model';
|
|
4
4
|
export { AnyAux, Aux, LikeC4DeploymentModel, LikeC4Model, LikeC4ViewModel } from '@likec4/core/model';
|
|
5
|
-
import { L as LikeC4LanguageServices, a as LikeC4Views, R as Range } from './shared/likec4.
|
|
5
|
+
import { L as LikeC4LanguageServices, a as LikeC4Views, R as Range } from './shared/likec4.QmEWuoHf.mjs';
|
|
6
6
|
import 'type-fest';
|
|
7
7
|
import '@likec4/core/types';
|
|
8
8
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"@likec4/core";export{LikeC4DeploymentModel,LikeC4Model,LikeC4ViewModel}from"@likec4/core/model";export{L as LikeC4}from"./shared/likec4.
|
|
1
|
+
import"@likec4/core";export{LikeC4DeploymentModel,LikeC4Model,LikeC4ViewModel}from"@likec4/core/model";export{L as LikeC4}from"./shared/likec4.D_S6au6n.mjs";import"node:fs";import"node:path";import"node:url";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/types";import"events";import"buffer";import"@hpcc-js/wasm-graphviz";import"@likec4/core/compute-view";import"@likec4/core/utils";import"node:process";
|
|
2
2
|
import"boxen";import"node:child_process";import"node:events";import"node:fs/promises";import"node:stream/promises";import"node:os";import"fs/promises";
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import{relative as Z}from"node:path";import{f as ee,g as x,T as te,N as U,i as ne,n as _,j as S,u as m,l as ie,C as re,a as oe,b as D,c as ae,t as se,d as P,m as de,p as ce,e as O,L as le}from"./likec4.D_S6au6n.mjs";function pe(t){var e,i;if(t){if("astNode"in t)return ge(t);if(Array.isArray(t))return t.reduce(A,void 0);{const n=t,r=ue(n)?fe((i=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:n?.astNode):void 0;return v(n,r)}}else return}function ue(t){return typeof t<"u"&&"e\
|
|
2
|
+
lement"in t&&"text"in t}function fe(t){try{return x(t).uri.toString()}catch{return}}function ge(t){var e,i;const{astNode:n,property:r,index:a}=t??{},o=(e=n?.$cstNode)!==null&&e!==void 0?e:n?.$textRegion;if(!(n===void 0||o===void 0)){if(r===void 0)return v(o,T(n));{const s=d=>a!==void 0&&a>-1&&Array.isArray(n[r])?a<d.length?d[a]:void 0:d.reduce(A,void 0);if(!((i=o.assignments)===null||i===void 0)&&i[r]){const d=s(o.assignments[r]);return d&&v(d,T(n))}else if(n.$cstNode){const d=s(ee(n.$cstNode,r));
|
|
3
|
+
return d&&v(d,T(n))}else return}}}function T(t){var e,i,n,r;return t.$cstNode?(i=(e=x(t))===null||e===void 0?void 0:e.uri)===null||i===void 0?void 0:i.toString():t.$textRegion?t.$textRegion.documentURI||((r=(n=new te(t,a=>a.$container?[a.$container]:[]).find(a=>{var o;return(o=a.$textRegion)===null||o===void 0?void 0:o.documentURI}))===null||n===void 0?void 0:n.$textRegion)===null||r===void 0?void 0:r.documentURI):void 0}function v(t,e){var i,n;const r={offset:t.offset,end:(i=t.end)!==null&&i!==
|
|
4
|
+
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),e??(e=t.fileURI),e&&(r.fileURI=e),r}function A(t,e){var i,n;if(t){if(!e)return t&&v(t)}else return e&&v(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,o=Math.min(t.offset,e.offset),s=Math.max(r,a),d=s-o,c={offset:o,end:s,length:d};if(t.range&&e.range&&(c.range={start:e.range.start.line<t.range.start.line||e.range.start.
|
|
5
|
+
line===t.range.start.line&&e.range.start.character<t.range.start.character?e.range.start:t.range.start,end:e.range.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,u=e.fileURI,p=f&&u&&f!==u?`<unmergable text regions of ${f}, ${u}>`:f??u;c.fileURI=p}return c}class he{constructor(e){this.defaultIndentation=" ",this.pendingIndent=!0,this.currentIndents=[],this.recentNonImmediateIndents=
|
|
6
|
+
[],this.traceData=[],this.lines=[[]],this.length=0,typeof e=="string"?this.defaultIndentation=e:typeof e=="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.
|
|
7
|
+
length}}append(e,i){if(e.length>0){const n=i&&this.currentPosition;this.lines[this.currentLineNumber].push(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(){
|
|
8
|
+
return this.currentIndents.filter(e=>!this.recentNonImmediateIndents.includes(e))}resetCurrentLine(){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=me(e,this.currentPosition,n=>{var r,a;return(a=(r=this.traceData[this.traceData.length-1])===null||r===void 0?void 0:
|
|
9
|
+
r.children)===null||a===void 0?void 0:a.push(n)});return this.traceData.push(i),i}popTraceRegion(e){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 me(t,e,i){const n={sourceRegion:t,targetRegion:void 0,children:[],targetStart:e,complete:r=>{
|
|
10
|
+
var a,o;return n.targetRegion={offset:n.targetStart.offset,end:r.offset,length:r.offset-n.targetStart.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,!((o=n.targetRegion)===null||o===void 0)&&o.length&&i(n),delete n.complete,n}};return n}function Ie(t,e){const i=new he(e),n=i.pushTraceRegion(void 0);J(t,i),i.popTraceRegion(n),n.
|
|
11
|
+
complete&&n.complete(i.currentPosition);const r=n.children&&n.children.length===1?n.children[0]:void 0,a=r?.targetRegion,o=n.targetRegion;return a&&r.sourceRegion&&a.offset===o.offset&&a.length===o.length?{text:i.content,trace:r}:{text:i.content,trace:n}}function J(t,e){typeof t=="string"?we(t,e):t instanceof E?Ne(t,e):t instanceof g?G(t,e):t instanceof j&&ve(t,e)}function V(t,e){return typeof t=="string"?t.length!==0:t instanceof g?t.contents.some(i=>V(i,e)):t instanceof j?!(t.ifNotEmpty&&e.currentLineContent.
|
|
12
|
+
length===0):!1}function we(t,e){t&&(W(e,!1),e.append(t))}function W(t,e){var i;if(t.pendingIndent){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 G(t,e){let i;const n=pe(t.tracedSource);n&&(i=e.pushTraceRegion(n));for(const r of t.contents)J(r,e);if(i){e.popTraceRegion(i);const r=e.getParentTraceSourceFileURI();r&&n?.fileURI===r&&delete n.fileURI,i.complete&&i.complete(
|
|
13
|
+
e.currentPosition)}}function Ne(t,e){var i;if(V(t,e)){t.indentImmediately&&!e.pendingIndent&&e.append((i=t.indentation)!==null&&i!==void 0?i:e.defaultIndentation,!0);try{e.increaseIndent(t),G(t,e)}finally{e.decreaseIndent()}}}function ve(t,e){t.ifNotEmpty&&!ye(e.currentLineContent)?e.resetCurrentLine():(W(e,!0),e.append(t.lineDelimiter),e.addNewLine())}function ye(t){return t.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");const ke=/\S|$/;function Le(t){const e=t.filter(n=>n.
|
|
14
|
+
length>0).map(n=>n.search(ke)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function w(t,...e){const i=$e(t),n=Se(t,e,i);return Te(n)}function je(t,e,i){return(n,...r)=>Ee(t,e,i)(w(n,...r))}function $e(t){const e=t.join("_").split(U),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.
|
|
15
|
+
length-1].trim().length===0};{let r=i?e.slice(1):e;r=n?r.slice(0,r.length-1):r,r=r.filter(o=>o.length!==0);const a=Le(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 Se(t,e,{indentation:i,omitFirstLine:n,omitLastLine:r,trimLastLine:a}){const o=[];t.forEach((c,f)=>{o.push(...c.split(U).map((u,p)=>p===0||u.length<i?u:u.substring(i)).reduce(f===0?(u,p,h)=>h===0?n?[]:[p]:h===1&&u.length===0?[p]:u.concat(R,p):
|
|
16
|
+
(u,p,h)=>h===0?[p]:u.concat(R,p),[]).filter(u=>!(typeof u=="string"&&u.length===0)).concat(L(e[f])?e[f]:e[f]!==void 0?{content:String(e[f])}:f<e.length?F:[]))});const s=o.length,d=s!==0?o[s-1]:void 0;return(r||a)&&typeof d=="string"&&d.trim().length===0?n&&s!==1&&o[s-2]===R?o.slice(0,s-2):o.slice(0,s-1):o}const R={isNewLine:!0},F={isUndefinedSegment:!0},z=t=>t===R,C=t=>t===F,Re=t=>t.content!==void 0;function Te(t){return t.reduce((i,n,r)=>C(n)?i:z(n)?{node:r!==0&&(C(t[r-1])||L(t[r-1]))||r>1&&typeof t[r-
|
|
17
|
+
1]=="string"&&(C(t[r-2])||L(t[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{var a;const o=(r===0||z(t[r-1]))&&typeof n=="string"&&n.length!==0?"".padStart(n.length-n.trimStart().length):"",s=Re(n)?n.content:n;let d;return{node:i.indented?i.node:o.length!==0?i.node.indent({indentation:o,indentImmediately:!1,indentedChildren:c=>d=c.append(s)}):i.node.append(s),indented:d??((a=i.indented)===null||a===void 0?void 0:a.append(s))}})(),{node:new g}).node}const Ce=typeof process>
|
|
18
|
+
"u"?`
|
|
19
|
+
`:process.platform==="win32"?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`;function L(t){return t instanceof g||t instanceof E||t instanceof j}function y(t,e){return L(t)?Ie(t,e).text:String(t)}class g{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(l)}appendNewLineIf(e){return e?this.append(l):this}appendNewLineIfNotEmpty(){return this.append(Me)}appendNewLineIfNotEmptyIf(e){return e?this.appendNewLineIfNotEmpty():this}appendTemplate(e,...i){return this.append(
|
|
23
|
+
w(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:{},o=new E(n,a,r);return this.contents.push(o),Array.isArray(i)?o.append(...i):i&&o.append(i),this}appendTraced(e,i,n){return r=>this.append(new g().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(je(e,i,n)(r,...a))}appendTracedTemplateIf(e,i,n,r){return e?this.appendTracedTemplate(typeof i=="function"?i():i,n,r):()=>this}}function Ee(t,e,i){return n=>n instanceof g&&n.tracedSource===void 0?n.trace(t,e,i):new g().trace(t,e,i).append(n)}class E extends g{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 j{constructor(e,i=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??Ce,this.ifNotEmpty=i}}const l=new j,Me=new j(void 0,!0),B=t=>t===void 0||typeof t=="string"||L(t)?t:String(t);function I(t,e=B,i={}){const n=typeof e=="function"?e:B,{filter:r,prefix:a,suffix:o,separator:s,appendNewLineIfNotEmpty:d,skipNewLineAfterLastItem:c}=typeof e=="object"?e:i,f=typeof a=="function"?a:()=>a,u=typeof o=="function"?o:()=>o;return be(t,(p,h,$,N)=>{
|
|
26
|
+
if(r&&!r(h,$,N))return p;const b=n(h,$,N);return b===void 0?p:(p??(p=new g)).append(f(h,$,N)).append(b).append(u(h,$,N)).appendIf(!N,s).appendNewLineIfNotEmptyIf(!p.isEmpty()&&!!d&&(!N||!c))})}function be(t,e,i){const n=t[Symbol.iterator]();let r=n.next(),a=0,o=i;for(;!r.done;){const s=n.next();o=e(o,r.value,a,!!s.done),r=s,a++}return o}const xe=t=>t.charAt(0).toLocaleUpperCase()+t.slice(1),Ue=t=>t.split(".").map(xe).join(""),_e=t=>Ue(t.parent?t.id.slice(t.parent.length+1):t.id),De=({autoLayout:t})=>{
|
|
27
|
+
switch(t.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},Pe=({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 Y(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,s)=>{const d=_e(o),c=(s?s+".":"")+d;n.set(o.id,c);const f=JSON.stringify(o.title),u=Pe(o);return new g().append(d,": {",l).indent({indentedChildren:p=>p.append("lab\
|
|
28
|
+
el: ",f,l).appendIf(u!=="rectangle","shape: ",u,l).appendIf(o.children.length>0,l,I(e.filter(h=>h.parent===o.id),h=>r(h,c))),indentation:2}).append("}",l)},a=o=>new g().append(n.get(o.source)," -> ",n.get(o.target)).append(s=>o.label&&s.append(": ",JSON.stringify(o.label)));return y(new g().append("direction: ",De(t),l,l).append(I(e.filter(o=>_(o.parent)),o=>r(o),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,l,I(i,o=>a(o),{appendNewLineIfNotEmpty:!0})))}const Oe=t=>t.charAt(0).toLocaleUpperCase()+
|
|
29
|
+
t.slice(1),Ae=t=>t.split(".").map(Oe).join(""),Je=t=>Ae(t.parent?t.id.slice(t.parent.length+1):t.id),Ve=({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 q(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,s)=>{const d=Je(o),c=(s?s+".":"")+d;n.set(o.id,c);const f=o.title.replaceAll(`
|
|
30
|
+
`,"\\n"),u=Ve(o),p=new g;return o.children.length>0?p.append("subgraph ",c,"[",JSON.stringify(o.title),"]",l).indent({indentedChildren:[I(e.filter(h=>h.parent===o.id),h=>r(h,c),{appendNewLineIfNotEmpty:!0})],indentation:2}).append("end",l):p.append(c,u[0],f,u[1]),p},a=o=>new g().append(n.get(o.source)," -.",o.label?' "'+o.label.replaceAll(`
|
|
31
|
+
`,"\\n")+'" .-':"-","> ",n.get(o.target));return y(new g().appendIf(t.title!==null&&t.title.length>0,"---",l,`title: ${JSON.stringify(t.title)}`,l,"---",l).append("graph ",t.autoLayout.direction,l).indent({indentedChildren:o=>{o.append(I(e.filter(s=>_(s.parent)),s=>r(s),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,I(i,s=>a(s),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function k(t){return{matches:e=>{let{module:i,projectId:n}=e.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.
|
|
32
|
+
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=>S("likec4:plugin",e,t)+".js"}}function M(t,e){return{id:`likec4:${t}`,virtualId:`likec4:plugin/${t}.js`,async load({likec4:i,logger:n,projects:r,assetsDir:a}){n.info(m.dim(`generating likec4:${t}`));const o=r.map(({id:s})=>{const d=S(`likec4:${t}`,s);return` case ${JSON.stringify(s)}: return await import(${JSON.stringify(d)})`});return`
|
|
33
|
+
export async function ${e}(projectId) {
|
|
34
|
+
switch (projectId) {
|
|
35
|
+
${o.join(`
|
|
36
|
+
`)}
|
|
37
|
+
default: throw new Error('Unknown projectId: ' + projectId)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`}}}const We=t=>{const e=new g;return e.appendTemplate`
|
|
41
|
+
/******************************************************************************
|
|
42
|
+
* This file was generated
|
|
43
|
+
* DO NOT EDIT MANUALLY!
|
|
44
|
+
******************************************************************************/
|
|
45
|
+
/* eslint-disable */
|
|
46
|
+
|
|
47
|
+
export function d2Source(viewId) {
|
|
48
|
+
switch (viewId) {
|
|
49
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(I(t,n=>w`
|
|
50
|
+
case ${JSON.stringify(n.id)}: {
|
|
51
|
+
return ${JSON.stringify(Y(n))}
|
|
52
|
+
}
|
|
53
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
54
|
+
default: {
|
|
55
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
56
|
+
}
|
|
57
|
+
`}}).append(l," }",l).appendTemplate`
|
|
58
|
+
}
|
|
59
|
+
`.append(l,l),y(e)},Ge={...k("d2"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:d2/${e}`));const n=await t.views.computedViews(e);return We(n)}},Fe=M("d2","loadD2Sources");function ze(t){const e=new g;return e.appendTemplate`
|
|
60
|
+
/******************************************************************************
|
|
61
|
+
* This file was generated
|
|
62
|
+
* DO NOT EDIT MANUALLY!
|
|
63
|
+
******************************************************************************/
|
|
64
|
+
/* eslint-disable */
|
|
65
|
+
|
|
66
|
+
export function dotSource(viewId) {
|
|
67
|
+
switch (viewId) {
|
|
68
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(I(Object.keys(t),n=>w`
|
|
69
|
+
case ${JSON.stringify(n)}: {
|
|
70
|
+
return ${JSON.stringify(t[n].dot)}
|
|
71
|
+
}
|
|
72
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
73
|
+
default: {
|
|
74
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
75
|
+
}
|
|
76
|
+
`}}).append(l," }",l).appendTemplate`
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function svgSource(viewId) {
|
|
80
|
+
switch (viewId) {
|
|
81
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(I(Object.keys(t),n=>w`
|
|
82
|
+
case ${JSON.stringify(n)}: {
|
|
83
|
+
return ${JSON.stringify(t[n].svg)}
|
|
84
|
+
}
|
|
85
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
86
|
+
default: {
|
|
87
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
88
|
+
}
|
|
89
|
+
`}}).append(l," }",l,"}",l,l),y(e)}const Be={...k("dot"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:dot/${e}`));const n=await t.views.viewsAsGraphvizOut(),r=ie(n,({id:a,svg:o,dot:s})=>[a,{dot:s,svg:o}]);return ze(r)}},Ye=M("dot","loadDotSources");function qe(t){const e=re(t.flatMap(r=>r.nodes.map(a=>a.icon)),D(se),D(r=>ae(r)&&!r.toLowerCase().startsWith("http")),oe()).sort(),{imports:i,cases:n}=e.reduce((r,a,o)=>{const[s,d]=a.split(":"),c="Icon"+o.toString().
|
|
90
|
+
padStart(2,"0");return r.imports.push(`import ${c} from 'likec4/icons/${s}/${d}'`),r.cases.push(` '${s}:${d}': ${c}`),r},{imports:[],cases:[]});return`
|
|
91
|
+
import { jsx } from 'react/jsx-runtime'
|
|
92
|
+
${i.join(`
|
|
93
|
+
`)}
|
|
94
|
+
|
|
95
|
+
export const Icons = {
|
|
96
|
+
${n.join(`,
|
|
97
|
+
`)}
|
|
98
|
+
}
|
|
99
|
+
export function IconRenderer({ node }) {
|
|
100
|
+
const IconComponent = Icons[node.icon ?? '']
|
|
101
|
+
if (!IconComponent) {
|
|
102
|
+
return null
|
|
103
|
+
}
|
|
104
|
+
return jsx(IconComponent, {node})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (import.meta.hot) {
|
|
108
|
+
import.meta.hot.accept(md => {
|
|
109
|
+
const update = md.Icons
|
|
110
|
+
if (update) {
|
|
111
|
+
if (!import.meta.hot.data.icons) {
|
|
112
|
+
import.meta.hot.data.icons = Icons
|
|
113
|
+
}
|
|
114
|
+
Object.assign(import.meta.hot.data.icons, update)
|
|
115
|
+
} else {
|
|
116
|
+
import.meta.hot.invalidate()
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
`}const He={...k("icons"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:icons/${e}`));const n=await t.views.computedViews(e);return qe(n)}},Ke={id:"likec4:icons",virtualId:"likec4:plugin/icons.js",async load({likec4:t,projects:e,logger:i}){i.info(m.dim("generating likec4:icons"));const{imports:n,cases:r}=e.reduce((a,{id:o},s)=>{const d="Icons"+s.toString().padStart(2,"0"),c=S("likec4:icons",o);return a.imports.push(`import { IconRenderer as ${d} } from ${JSON.stringify(
|
|
121
|
+
c)}`),a.cases.push(` case ${JSON.stringify(o)}: return ${d}`),a},{imports:[],cases:[]});return`
|
|
122
|
+
${n.join(`
|
|
123
|
+
`)}
|
|
124
|
+
|
|
125
|
+
export function ProjectIcons(projectId) {
|
|
126
|
+
switch (projectId) {
|
|
127
|
+
${r.join(`
|
|
128
|
+
`)}
|
|
129
|
+
default:
|
|
130
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
`}};function Xe(t){const e=new g;return e.appendTemplate`
|
|
134
|
+
/******************************************************************************
|
|
135
|
+
* This file was generated
|
|
136
|
+
* DO NOT EDIT MANUALLY!
|
|
137
|
+
******************************************************************************/
|
|
138
|
+
/* eslint-disable */
|
|
139
|
+
|
|
140
|
+
export function mmdSource(viewId) {
|
|
141
|
+
switch (viewId) {
|
|
142
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(I(t,n=>w`
|
|
143
|
+
case ${JSON.stringify(n.id)}: {
|
|
144
|
+
return ${JSON.stringify(q(n))}
|
|
145
|
+
}
|
|
146
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
147
|
+
default: {
|
|
148
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
149
|
+
}
|
|
150
|
+
`}}).append(l," }",l).appendTemplate`
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
`.append(l,l),y(e)}const Qe={...k("mmd"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating virtual:likec4/mmd/${e}`));const n=await t.views.computedViews(e);return Xe(n)}},Ze=M("mmd","loadMmdSources"),et=t=>`
|
|
154
|
+
import { nano, createHooksForModel } from 'likec4/react'
|
|
155
|
+
|
|
156
|
+
export const $likec4data = nano.atom(${P.stringify(t.$model)})
|
|
157
|
+
|
|
158
|
+
export const {
|
|
159
|
+
updateModel,
|
|
160
|
+
$likec4model,
|
|
161
|
+
useLikeC4Model,
|
|
162
|
+
useLikeC4Views,
|
|
163
|
+
useLikeC4View
|
|
164
|
+
}= /* @__PURE__ */ createHooksForModel($likec4data)
|
|
165
|
+
|
|
166
|
+
if (import.meta.hot) {
|
|
167
|
+
import.meta.hot.accept(md => {
|
|
168
|
+
if (!import.meta.hot.data.$update) {
|
|
169
|
+
import.meta.hot.data.$update = updateModel
|
|
170
|
+
}
|
|
171
|
+
const update = md.$likec4data?.value
|
|
172
|
+
if (update) {
|
|
173
|
+
import.meta.hot.data.$update(update)
|
|
174
|
+
} else {
|
|
175
|
+
import.meta.hot.invalidate()
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
`,tt={...k("model"),async load({likec4:t,projectId:e,logger:i,assetsDir:n}){i.info(m.dim(`generating likec4:model/${e}`));const r=await t.layoutedModel(e);return et(r)}},nt={id:"likec4:model",virtualId:"likec4:plugin/model.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){return e.info(m.dim("generating likec4:model")),`
|
|
180
|
+
export async function loadModel(projectId) {
|
|
181
|
+
switch (projectId) {
|
|
182
|
+
${i.map(({id:r})=>{const a=S("likec4:model",r);return` case ${JSON.stringify(r)}: return await import(${JSON.stringify(a)})`}).join(`
|
|
183
|
+
`)}
|
|
184
|
+
default: throw new Error('Unknown projectId: ' + projectId)
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
`}},it=t=>`
|
|
188
|
+
export const isSingleProject = ${t.length===1};
|
|
189
|
+
export const projects = ${P.stringify(t,null,2)};
|
|
190
|
+
`,rt={id:"likec4:projects",virtualId:"likec4:plugin/projects.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){return e.info(m.dim("generating likec4:projects")),it(de(i,ce("id")))}},H=t=>`
|
|
191
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
192
|
+
import { LikeC4ModelProvider as Provider, LikeC4View as GenericView, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
|
|
193
|
+
import { IconRenderer } from 'likec4:icons/${t}'
|
|
194
|
+
|
|
195
|
+
import { useLikeC4Model, useLikeC4Views, useLikeC4View } from 'likec4:model/${t}'
|
|
196
|
+
|
|
197
|
+
export function LikeC4ModelProvider({ children }) {
|
|
198
|
+
const likeC4Model = useLikeC4Model()
|
|
199
|
+
return (_jsx(Provider, { likec4model: likeC4Model, children: children }));
|
|
200
|
+
}
|
|
201
|
+
export function LikeC4View(props) {
|
|
202
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericView, { renderIcon: IconRenderer, ...props }) }));
|
|
203
|
+
}
|
|
204
|
+
export function ReactLikeC4(props) {
|
|
205
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericReactLikeC4, { renderIcon: IconRenderer, ...props }) }));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export {
|
|
209
|
+
useLikeC4Model,
|
|
210
|
+
useLikeC4View,
|
|
211
|
+
useLikeC4Views
|
|
212
|
+
}
|
|
213
|
+
`,ot={...k("react"),async load({projectId:t,logger:e}){return e.info(m.dim(`generating likec4:react/${t}`)),H(t)}},at={id:"likec4:react",virtualId:"likec4:plugin/react.js",async load({logger:t,projects:e}){const i=O(e);return t.info(m.dim("generating likec4:react for")+" "+i.id),H(i.id)}},st=t=>`
|
|
214
|
+
export { IconRenderer } from 'likec4:icons/${t}'
|
|
215
|
+
export {
|
|
216
|
+
$likec4data,
|
|
217
|
+
$likec4model,
|
|
218
|
+
useLikeC4Model,
|
|
219
|
+
useLikeC4Views,
|
|
220
|
+
useLikeC4View
|
|
221
|
+
} from 'likec4:model/${t}'
|
|
222
|
+
export const projectId = ${JSON.stringify(t)}
|
|
223
|
+
`,dt={id:"likec4:single-project",virtualId:"likec4:plugin/single-project.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){const r=O(i);return e.info(m.dim("generating likec4:single-project for")+" "+r.id),st(r.id)}},K=[tt,He,Ge,Be,Qe],X=[...K,ot],Q=[rt,nt,dt,at,Fe,Ye,Ze,Ke],ct=t=>{const e=t.toLowerCase();return e.endsWith(".c4")||e.endsWith(".likec4")||e.endsWith(".like-c4")};function lt({useOverviewGraph:t=!1,...e}){let i,n,r,a;return{name:"vite-plugin-likec4",async configResolved(o){
|
|
224
|
+
if(i=o.root,n=o.logger,t===!0){const s=o.resolve.alias.find(d=>d.find==="likec4/previews")?.replacement;s?(a=s,n.info(m.dim("likec4/previews alias")+" "+m.dim(a))):n.warn("likec4/previews alias not found")}e.languageServices?r=e.languageServices:r=(await le.fromWorkspace(e.workspace??o.root,{logger:n,graphviz:e.graphviz??"wasm",printErrors:e.printErrors??!0,throwIfInvalid:e.throwIfInvalid??!1})).languageServices,a=r.workspaceUri.fsPath},resolveId(o){for(const s of X){const d=s.matches(o);if(d)return s.
|
|
225
|
+
virtualId(d)}for(const s of Q)if(s.id===o)return s.virtualId;return null},async load(o){for(const s of X){const d=s.matches(o);if(d)return await s.load({logger:n,likec4:r,projectId:d,assetsDir:a,useOverviewGraph:t})}for(const s of Q)if(s.virtualId===o){const d=await r.projects();return await s.load({logger:n,likec4:r,projects:d,assetsDir:a,useOverviewGraph:t})}return null},configureServer(o){const s=r.projects().map(({folder:c})=>c.fsPath);for(const c of s)n.info(`${m.dim("watch")} ${c}`);const d=c=>f=>{
|
|
226
|
+
ct(f)&&r.notifyUpdate({[c]:f})};o.watcher.add(s).on("add",d("changed")).on("change",d("changed")).on("unlink",d("removed")),r.builder.onModelParsed(async()=>{const[c]=r.getErrors();if(c){o.ws.send({type:"error",err:{name:"LikeC4ValidationError",message:`Validation failed
|
|
227
|
+
`+c.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:Z(i,c.sourceFsPath),line:c.range.start.line+1,column:c.range.start.character+1}}});return}for(const f of r.projects())for(const u of K){const p=o.moduleGraph.getModuleById(u.virtualId(f.id));if(p&&p.importers.size>0){n.info(`${m.green("reload")} ${m.dim(p.id??p.url)}`);try{await o.reloadModule(p)}catch(h){n.error(h)}}}})}}}export{g as C,lt as L,l as N,Y as a,w as e,q as g,I as j,y as t};
|