likec4 1.35.0 → 1.36.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/main.js +1757 -902
- 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.CcP3mRJH.d.mts → likec4.CoVNuZKl.d.mts} +38 -16
- package/dist/shared/likec4.D8qlxD_Y.mjs +239 -0
- package/dist/shared/{likec4.B4j8eNO5.mjs → likec4.DWIqzE5d.mjs} +1618 -1616
- package/dist/vite-plugin/index.d.mts +1 -1
- package/dist/vite-plugin/index.mjs +1 -1
- package/package.json +17 -16
- package/react/index.d.mts +174 -22
- package/react/index.mjs +74 -61
- package/vite-plugin-modules.d.ts +2 -1
- package/dist/shared/likec4.SsV1pHm2.mjs +0 -239
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{k as He,o as kh,
|
|
2
|
+
import{k as He,o as kh,p as At,q as Ur,t as ur,r as ua,C as xh,e as Mh,d as Bt,u as K,w as la,s as qh,v as Uh,x as at,y as fa,z as Hr,A as Hh,B as Ot,D as Fh,h as da,E as ha,c as Vh,L as rt,j as pa,F as zh,G as nt,H as Gh,I as Bh,n as Wh,J as Wt,K as lr,M as Ps,O as ma,P as Kh,Q as Yh}from"../shared/likec4.DWIqzE5d.mjs";import he,{existsSync as Ct,copyFileSync as ga,readdirSync as Xh,rmSync as Is}from"node:fs";import Se,{hrtime as Jh,cwd as Ns,exit as ya,stdout as Qh,argv as Zh}from"node:process";
|
|
3
3
|
import{strictEqual as ep,notStrictEqual as tp}from"assert";import Ts,{resolve as Fe,dirname as js,normalize as rp,relative as np,extname as sp,basename as ip}from"path";import{statSync as $a,readdirSync as op,readFileSync as Ls,writeFile as ap}from"fs";import _a,{format as va,inspect as cp}from"util";import{fileURLToPath as up}from"url";import me,{resolve as ge,dirname as Pt,join as fr,relative as gt,extname as dr,isAbsolute as Ds,basename as Fr}from"node:path";import ba,{mkdtemp as Vr,writeFile as It,
|
|
4
|
-
mkdir as ct,stat as ks,copyFile as lp,rm as fp}from"node:fs/promises";import hr,{tmpdir as zr}from"node:os";import{fileURLToPath as wa}from"node:url";import xs from"@vitejs/plugin-react";import{j as Ea,e as Sa,C as dp,t as Ra,N as Kt,L as Ms,g as hp,a as pp,b as mp}from"../shared/likec4.
|
|
4
|
+
mkdir as ct,stat as ks,copyFile as lp,rm as fp}from"node:fs/promises";import hr,{tmpdir as zr}from"node:os";import{fileURLToPath as wa}from"node:url";import xs from"@vitejs/plugin-react";import{j as Ea,e as Sa,C as dp,t as Ra,N as Kt,L as Ms,g as hp,a as pp,b as mp}from"../shared/likec4.D8qlxD_Y.mjs";import{build as pr,createServer as gp,preview as yp}from"vite";import $p from"node:module";import{compareNatural as _p,sortNaturalByFqn as vp,invariant as Gr,hasAtLeast as qs,nonexhaustive as Aa,delay as Oa}from"@likec4/core";
|
|
5
5
|
import{chromium as Ca}from"playwright";import bp from"node:net";import{setTimeout as wp}from"node:timers/promises";import{promisify as Ie,isDeepStrictEqual as Ep}from"node:util";import mr from"node:crypto";import Sp from"node:assert";import{u as Rp}from"../shared/likec4.BeWJWU7_.mjs";import"tty";import"os";import"crypto";import"net";import"child_process";import"@likec4/core/types";import"events";import"@hpcc-js/wasm-graphviz";import"@likec4/core/model";import"buffer";import"@likec4/core/compute-view";
|
|
6
6
|
import"@likec4/core/utils";import"boxen";import"node:child_process";import"node:events";import"node:stream/promises";import"node:readline/promises";import"fs/promises";function Ap(...t){return Rp(Op,t)}var Op=t=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`,Us,Pa;function Ia(){return Pa||(Pa=1,Us=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,s,i;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(s=n;s--!==0;)
|
|
7
7
|
if(!t(e[s],r[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(r).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[s]))return!1;for(s=n;s--!==0;){var o=i[s];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}),Us}let Hs;function Cp(){
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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.CoVNuZKl.mjs';
|
|
4
4
|
import { ProjectId, NonEmptyArray } from '@likec4/core';
|
|
5
5
|
import { DiagramView } from '@likec4/core/types';
|
|
6
6
|
export * from '@likec4/core/types';
|
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.DWIqzE5d.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};
|
|
@@ -15717,13 +15717,14 @@ declare function readonly<TInput>(): ReadonlyAction<TInput>;
|
|
|
15717
15717
|
|
|
15718
15718
|
declare const ProjectConfig: ObjectSchema<{
|
|
15719
15719
|
readonly name: SchemaWithPipe<readonly [StringSchema<undefined>, NonEmptyAction<string, "Project name cannot be empty">, ExcludesAction<string, "default", "Project name cannot be \"default\"">, ExcludesAction<string, ".", "Project name cannot contain \".\", try to use A-z, 0-9, _ and -">, ExcludesAction<string, "@", "Project name cannot contain \"@\", try to use A-z, 0-9, _ and -">, ExcludesAction<string, "#", "Project name cannot contain \"#\", try to use A-z, 0-9, _ and -">, DescriptionAction<string, "Project name, must be unique in the workspace">]>;
|
|
15720
|
+
readonly title: OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, NonEmptyAction<string, "Project title cannot be empty if specified">, DescriptionAction<string, "A human readable title for the project">]>, undefined>;
|
|
15720
15721
|
readonly contactPerson: OptionalSchema<SchemaWithPipe<readonly [StringSchema<undefined>, NonEmptyAction<string, "Contact person cannot be empty if specified">, DescriptionAction<string, "A person who has been involved in creating or maintaining this project">]>, undefined>;
|
|
15721
15722
|
readonly exclude: OptionalSchema<SchemaWithPipe<readonly [ArraySchema<StringSchema<undefined>, undefined>, DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"**/node_modules/**/*\"]">]>, undefined>;
|
|
15722
15723
|
}, undefined>;
|
|
15723
15724
|
type ProjectConfig = InferOutput<typeof ProjectConfig>;
|
|
15724
15725
|
|
|
15725
15726
|
/******************************************************************************
|
|
15726
|
-
* This file was generated by langium-cli 3.5.
|
|
15727
|
+
* This file was generated by langium-cli 3.5.2.
|
|
15727
15728
|
* DO NOT EDIT MANUALLY!
|
|
15728
15729
|
******************************************************************************/
|
|
15729
15730
|
|
|
@@ -17389,7 +17390,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17389
17390
|
isValid: IsValidFn;
|
|
17390
17391
|
readonly services: LikeC4Services;
|
|
17391
17392
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17392
|
-
|
|
17393
|
+
get project(): {
|
|
17393
17394
|
id: ProjectId;
|
|
17394
17395
|
folder: ProjectId;
|
|
17395
17396
|
config: Readonly<ProjectConfig>;
|
|
@@ -17482,7 +17483,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17482
17483
|
isValid: IsValidFn;
|
|
17483
17484
|
readonly services: LikeC4Services;
|
|
17484
17485
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17485
|
-
|
|
17486
|
+
get project(): {
|
|
17486
17487
|
id: ProjectId;
|
|
17487
17488
|
folder: ProjectId;
|
|
17488
17489
|
config: Readonly<ProjectConfig>;
|
|
@@ -17537,7 +17538,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17537
17538
|
isValid: IsValidFn;
|
|
17538
17539
|
readonly services: LikeC4Services;
|
|
17539
17540
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17540
|
-
|
|
17541
|
+
get project(): {
|
|
17541
17542
|
id: ProjectId;
|
|
17542
17543
|
folder: ProjectId;
|
|
17543
17544
|
config: Readonly<ProjectConfig>;
|
|
@@ -17606,7 +17607,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17606
17607
|
isValid: IsValidFn;
|
|
17607
17608
|
readonly services: LikeC4Services;
|
|
17608
17609
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17609
|
-
|
|
17610
|
+
get project(): {
|
|
17610
17611
|
id: ProjectId;
|
|
17611
17612
|
folder: ProjectId;
|
|
17612
17613
|
config: Readonly<ProjectConfig>;
|
|
@@ -17668,7 +17669,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17668
17669
|
isValid: IsValidFn;
|
|
17669
17670
|
readonly services: LikeC4Services;
|
|
17670
17671
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17671
|
-
|
|
17672
|
+
get project(): {
|
|
17672
17673
|
id: ProjectId;
|
|
17673
17674
|
folder: ProjectId;
|
|
17674
17675
|
config: Readonly<ProjectConfig>;
|
|
@@ -17738,7 +17739,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17738
17739
|
isValid: IsValidFn;
|
|
17739
17740
|
readonly services: LikeC4Services;
|
|
17740
17741
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17741
|
-
|
|
17742
|
+
get project(): {
|
|
17742
17743
|
id: ProjectId;
|
|
17743
17744
|
folder: ProjectId;
|
|
17744
17745
|
config: Readonly<ProjectConfig>;
|
|
@@ -17801,7 +17802,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17801
17802
|
isValid: IsValidFn;
|
|
17802
17803
|
readonly services: LikeC4Services;
|
|
17803
17804
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17804
|
-
|
|
17805
|
+
get project(): {
|
|
17805
17806
|
id: ProjectId;
|
|
17806
17807
|
folder: ProjectId;
|
|
17807
17808
|
config: Readonly<ProjectConfig>;
|
|
@@ -17844,7 +17845,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17844
17845
|
isValid: IsValidFn;
|
|
17845
17846
|
readonly services: LikeC4Services;
|
|
17846
17847
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17847
|
-
|
|
17848
|
+
get project(): {
|
|
17848
17849
|
id: ProjectId;
|
|
17849
17850
|
folder: ProjectId;
|
|
17850
17851
|
config: Readonly<ProjectConfig>;
|
|
@@ -17902,7 +17903,7 @@ declare const DocumentParserFromMixins: {
|
|
|
17902
17903
|
isValid: IsValidFn;
|
|
17903
17904
|
readonly services: LikeC4Services;
|
|
17904
17905
|
readonly doc: ParsedLikeC4LangiumDocument;
|
|
17905
|
-
|
|
17906
|
+
get project(): {
|
|
17906
17907
|
id: ProjectId;
|
|
17907
17908
|
folder: ProjectId;
|
|
17908
17909
|
config: Readonly<ProjectConfig>;
|
|
@@ -18009,21 +18010,42 @@ declare namespace ChangeView {
|
|
|
18009
18010
|
}
|
|
18010
18011
|
|
|
18011
18012
|
type GraphvizOut = {
|
|
18012
|
-
dot: string;
|
|
18013
|
-
diagram: DiagramView;
|
|
18013
|
+
readonly dot: string;
|
|
18014
|
+
readonly diagram: DiagramView;
|
|
18014
18015
|
};
|
|
18015
18016
|
type GraphvizSvgOut = {
|
|
18016
|
-
id: ViewId;
|
|
18017
|
-
dot: string;
|
|
18018
|
-
svg: string;
|
|
18017
|
+
readonly id: ViewId;
|
|
18018
|
+
readonly dot: string;
|
|
18019
|
+
readonly svg: string;
|
|
18019
18020
|
};
|
|
18020
18021
|
interface LikeC4Views {
|
|
18021
18022
|
readonly layouter: GraphvizLayouter;
|
|
18023
|
+
/**
|
|
18024
|
+
* Returns computed views (i.e. views with predicates computed)
|
|
18025
|
+
*/
|
|
18022
18026
|
computedViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<ComputedView[]>;
|
|
18023
|
-
|
|
18027
|
+
/**
|
|
18028
|
+
* Returns all layouted views (i.e. views with layout computed)
|
|
18029
|
+
* Result includes dot and diagram
|
|
18030
|
+
*/
|
|
18031
|
+
layoutAllViews(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<GraphvizOut[]>;
|
|
18032
|
+
/**
|
|
18033
|
+
* Returns layouted view (i.e. view with layout computed)
|
|
18034
|
+
* Result includes dot and diagram
|
|
18035
|
+
*/
|
|
18024
18036
|
layoutView(viewId: ViewId, projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<GraphvizOut | null>;
|
|
18037
|
+
/**
|
|
18038
|
+
* Returns diagrams (i.e. views with layout computed)
|
|
18039
|
+
*/
|
|
18025
18040
|
diagrams(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<DiagramView>>;
|
|
18041
|
+
/**
|
|
18042
|
+
* Returns all layouted views as Graphviz output (i.e. views with layout computed)
|
|
18043
|
+
*/
|
|
18026
18044
|
viewsAsGraphvizOut(projectId?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<Array<GraphvizSvgOut>>;
|
|
18045
|
+
/**
|
|
18046
|
+
* Open view in the preview panel.
|
|
18047
|
+
* (works only if running as a vscode extension)
|
|
18048
|
+
*/
|
|
18027
18049
|
openView(viewId: ViewId, projectId?: ProjectId | undefined): Promise<void>;
|
|
18028
18050
|
}
|
|
18029
18051
|
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import{invariant as de,isNonEmptyArray as ce}from"@likec4/core";import{relative as le}from"node:path";import{f as pe,g as J,T as ue,N as V,i as fe,n as x,j as U,u as N,l as ge,C as he,m as me,a as we,b as Ie,c as Ne,d as W,e as ye,h as G,L as ve}from"./likec4.DWIqzE5d.mjs";import{compareNatural as ke}from"@likec4/core/utils";import{u as Le}from"./likec4.BeWJWU7_.mjs";import{RichText as $e}from"@likec4/core/types";function je(...n){return Le(Se,n)}function Se(n,e){let i={};for(let t of e)t in n&&
|
|
2
|
+
(i[t]=n[t]);return i}function Ce(n){var e,i;if(n){if("astNode"in n)return Ee(n);if(Array.isArray(n))return n.reduce(z,void 0);{const t=n,r=Re(t)?Te((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 Re(n){return typeof n<"u"&&"element"in n&&"text"in n}function Te(n){try{return J(n).uri.toString()}catch{return}}function Ee(n){var e,i;const{astNode:t,property:r,index:a}=n??{},s=(e=t?.$cstNode)!==null&&e!==void 0?e:t?.$textRegion;
|
|
3
|
+
if(!(t===void 0||s===void 0)){if(r===void 0)return C(s,O(t));{const o=d=>a!==void 0&&a>-1&&Array.isArray(t[r])?a<d.length?d[a]:void 0:d.reduce(z,void 0);if(!((i=s.assignments)===null||i===void 0)&&i[r]){const d=o(s.assignments[r]);return d&&C(d,O(t))}else if(t.$cstNode){const d=o(pe(t.$cstNode,r));return d&&C(d,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?n.$textRegion.documentURI||
|
|
4
|
+
((r=(t=new ue(n,a=>a.$container?[a.$container]:[]).find(a=>{var s;return(s=a.$textRegion)===null||s===void 0?void 0:s.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,t;if(n){if(!e)return n&&C(n)}else
|
|
5
|
+
return e&&C(e);const r=(i=n.end)!==null&&i!==void 0?i:n.offset+n.length,a=(t=e.end)!==null&&t!==void 0?t:e.offset+e.length,s=Math.min(n.offset,e.offset),o=Math.max(r,a),d=o-s,p={offset:s,end:o,length:d};if(n.range&&e.range&&(p.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.line&&e.range.end.character>n.range.
|
|
6
|
+
end.character?e.range.end:n.range.end}),n.fileURI||e.fileURI){const u=n.fileURI,h=e.fileURI,f=u&&h&&u!==h?`<unmergable text regions of ${u}, ${h}>`:u??h;p.fileURI=f}return p}class Me{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(){return this.lines.map(e=>e.
|
|
7
|
+
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=be(e,this.currentPosition,t=>{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(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 be(n,e,i){const t={sourceRegion:n,targetRegion:void 0,children:[],targetStart:e,complete:r=>{var a,s;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,((a=t.children)===null||a===void 0?void 0:a.length)===0&&delete t.children,!((s=t.targetRegion)===null||s===void 0)&&s.length&&i(t),delete t.complete,t}};return t}function xe(n,e){const i=new Me(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,a=r?.targetRegion,s=t.targetRegion;return a&&r.sourceRegion&&a.offset===s.offset&&
|
|
12
|
+
a.length===s.length?{text:i.content,trace:r}:{text:i.content,trace:t}}function B(n,e){typeof n=="string"?Ue(n,e):n instanceof F?De(n,e):n instanceof g?H(n,e):n instanceof M&&_e(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 M?!(n.ifNotEmpty&&e.currentLineContent.length===0):!1}function Ue(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(a=>a.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=Ce(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 De(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 _e(n,e){n.ifNotEmpty&&!Pe(e.currentLineContent)?e.resetCurrentLine():(q(e,!0),e.append(n.lineDelimiter),e.addNewLine())}function Pe(n){return n.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE^IF^EMPTY\xBB__");const Oe=/\S|$/;function Ae(n){const e=n.filter(t=>t.length>0).map(t=>t.search(Oe)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function $(n,...e){const i=Je(n),t=Ve(n,e,i);return Ge(t)}function Fe(n,e,i){return(t,...r)=>Be(
|
|
15
|
+
n,e,i)($(t,...r))}function Je(n){const e=n.join("_").split(V),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(s=>s.length!==0);const a=Ae(r);return{indentation:a,omitFirstLine:i,omitLastLine:t&&(e[e.
|
|
16
|
+
length-1].length<a||!e[e.length-1].startsWith(r[0].substring(0,a)))}}}function Ve(n,e,{indentation:i,omitFirstLine:t,omitLastLine:r,trimLastLine:a}){const s=[];n.forEach((p,u)=>{s.push(...p.split(V).map((h,f)=>f===0||h.length<i?h:h.substring(i)).reduce(u===0?(h,f,m)=>m===0?t?[]:[f]:m===1&&h.length===0?[f]:h.concat(D,f):(h,f,m)=>m===0?[f]:h.concat(D,f),[]).filter(h=>!(typeof h=="string"&&h.length===0)).concat(E(e[u])?e[u]:e[u]!==void 0?{content:String(e[u])}:u<e.length?K:[]))});const o=s.length,d=o!==
|
|
17
|
+
0?s[o-1]:void 0;return(r||a)&&typeof d=="string"&&d.trim().length===0?t&&o!==1&&s[o-2]===D?s.slice(0,o-2):s.slice(0,o-1):s}const D={isNewLine:!0},K={isUndefinedSegment:!0},X=n=>n===D,A=n=>n===K,We=n=>n.content!==void 0;function Ge(n){return n.reduce((i,t,r)=>A(t)?i:X(t)?{node:r!==0&&(A(n[r-1])||E(n[r-1]))||r>1&&typeof n[r-1]=="string"&&(A(n[r-2])||E(n[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{var a;const s=(r===0||X(n[r-1]))&&typeof t=="string"&&t.length!==0?"".padStart(
|
|
18
|
+
t.length-t.trimStart().length):"",o=We(t)?t.content:t;let d;return{node:i.indented?i.node:s.length!==0?i.node.indent({indentation:s,indentImmediately:!1,indentedChildren:p=>d=p.append(o)}):i.node.append(o),indented:d??((a=i.indented)===null||a===void 0?void 0:a.append(o))}})(),{node:new g}).node}const ze=typeof process>"u"?`
|
|
19
|
+
`:process.platform==="win32"?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`;function E(n){return n instanceof g||n instanceof F||n instanceof M}function j(n,e){return E(n)?xe(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(fe(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(c)}appendNewLineIf(e){return e?this.append(c):this}appendNewLineIfNotEmpty(){return this.append(Ye)}appendNewLineIfNotEmptyIf(e){return e?this.appendNewLineIfNotEmpty():this}appendTemplate(e,...i){return this.append(
|
|
23
|
+
$(e,...i))}appendTemplateIf(e){return e?(i,...t)=>this.appendTemplate(i,...t):()=>this}indent(e){const{indentedChildren:i,indentation:t,indentEmptyLines:r,indentImmediately:a}=Array.isArray(e)||typeof e=="function"?{indentedChildren:e}:typeof e=="object"?e:{},s=new F(t,a,r);return this.contents.push(s),Array.isArray(i)?s.append(...i):i&&s.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,...a)=>this.append(Fe(e,i,t)(r,...a))}appendTracedTemplateIf(e,i,t,r){return e?this.appendTracedTemplate(typeof i=="function"?i():i,t,r):()=>this}}function Be(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 F 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 M{constructor(e,i=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??ze,this.ifNotEmpty=i}}const c=new M,Ye=new M(void 0,!0),Q=n=>n===void 0||typeof n=="string"||E(n)?n:String(n);function y(n,e=Q,i={}){const t=typeof e=="function"?e:Q,{filter:r,prefix:a,suffix:s,separator:o,appendNewLineIfNotEmpty:d,skipNewLineAfterLastItem:p}=typeof e=="object"?e:i,u=typeof a=="function"?a:()=>a,h=typeof s=="function"?s:()=>s;return qe(n,(f,m,v,l)=>{
|
|
26
|
+
if(r&&!r(m,v,l))return f;const w=t(m,v,l);return w===void 0?f:(f??(f=new g)).append(u(m,v,l)).append(w).append(h(m,v,l)).appendIf(!l,o).appendNewLineIfNotEmptyIf(!f.isEmpty()&&!!d&&(!l||!p))})}function qe(n,e,i){const t=n[Symbol.iterator]();let r=t.next(),a=0,s=i;for(;!r.done;){const o=t.next();s=e(s,r.value,a,!!o.done),r=o,a++}return s}const He=n=>n.charAt(0).toLocaleUpperCase()+n.slice(1),Ke=n=>n.split(".").map(He).join(""),Xe=n=>Ke(n.parent?n.id.slice(n.parent.length+1):n.id),Qe=({autoLayout:n})=>{
|
|
27
|
+
switch(n.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},Ze=({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,a=(o,d)=>{const p=Xe(o),u=(d?d+".":"")+p;r.set(o.id,u);const h=JSON.stringify(o.title),f=Ze(o);return new g().append(p,": {",c).indent({indentedChildren:m=>m.
|
|
28
|
+
append("label: ",h,c).appendIf(f!=="rectangle","shape: ",f,c).appendIf(o.children.length>0,c,y(i.filter(v=>v.parent===o.id),v=>a(v,u))),indentation:2}).append("}",c)},s=o=>new g().append(r.get(o.source)," -> ",r.get(o.target)).append(d=>o.label&&d.append(": ",JSON.stringify(o.label)));return j(new g().append("direction: ",Qe(e),c,c).append(y(i.filter(o=>x(o.parent)),o=>a(o),{appendNewLineIfNotEmpty:!0})).appendIf(t.length>0,c,y(t,o=>s(o),{appendNewLineIfNotEmpty:!0})))}const en=n=>n.charAt(0).toLocaleUpperCase()+
|
|
29
|
+
n.slice(1),nn=n=>n.split(".").map(en).join(""),tn=n=>nn(n.parent?n.id.slice(n.parent.length+1):n.id),rn=({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,a=(o,d)=>{const p=tn(o),u=(d?d+".":"")+p;r.set(o.id,u);const h=o.title.replaceAll(`
|
|
30
|
+
`,"\\n"),f=rn(o),m=new g;return o.children.length>0?m.append("subgraph ",u,"[",JSON.stringify(o.title),"]",c).indent({indentedChildren:[y(i.filter(v=>v.parent===o.id),v=>a(v,u),{appendNewLineIfNotEmpty:!0})],indentation:2}).append("end",c):m.append(u,f[0],h,f[1]),m},s=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,"---",c,`title: ${JSON.stringify(e.title)}`,c,"---",c).append("graph ",e.autoLayout.direction,c).indent({indentedChildren:o=>{o.append(y(i.filter(d=>x(d.parent)),d=>a(d),{appendNewLineIfNotEmpty:!0})).appendIf(t.length>0,y(t,d=>s(d),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}const on=n=>n.charAt(0).toLocaleUpperCase()+n.slice(1),_=n=>n.split(".").map(on).join(""),ne=n=>_(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}},an=({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=>x(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,a=new Map(Object.entries(i)),s=l=>w=>a.get(w)?.elements[l],o=l=>w=>a.get(w)?.relationships[l],d=new Map,p=()=>new g().append('title "',e.title||e.id,'"',c).append(an(e)," direction",c),u=()=>new g().append("hide stereotype",c).append("skinparam ranksep ","60",c).append("skinparam nodesep ","30",c).append("skinparam {",c).indent({indentedChildren:l=>l.append("arrowFontSize ","10",c).append("defaultTextAlignment ","center",c).append("wrapWidth ","200",c).append("maxMessageSi\
|
|
35
|
+
ze ","100",c).append("shadowing ","false",c),indentation:2}).append("}",c),h=l=>{const w=te(l),I=_(l.id);return new g().append("skinparam ",w,"<<",I,">>","{",c).indent({indentedChildren:L=>L.append("BackgroundColor ",R(l.color,s("fill")),c).append("FontColor ",a.has(l.color)?R(l.color,s("hiContrast")):"#FFFFFF",c).append("BorderColor ",R(l.color,s("stroke")),c),indentation:2}).append("}",c)},f=l=>{const w=te(l),I=_(l.id),L=T(l.title)||ne(l),k=T(l.technology);d.set(l.id,I);const b=$e.from(l.description);
|
|
36
|
+
return new g().append(w," ").append('"').append("==",L).appendIf(!!k,"\\n","<size:10>[",k,"]</size>").appendIf(b.nonEmpty,"\\n\\n",T(b.text)).append('"'," <<",I,">> ","as ",I,c)},m=l=>{const w=T(l.title)||ne(l),I=_(l.id);return d.set(l.id,I),new g().append('rectangle "',w,'" <<',I,">> as ",I," {",c).indent({indentedChildren:L=>L.append("skinparam ","RectangleBorderColor<<",I,">> ",R(l.color,s("fill")),c).append("skinparam ","RectangleFontColor<<",I,">> ",R(l.color,s("fill")),c).append("skinparam\
|
|
37
|
+
","RectangleBorderStyle<<",I,">> ","dashed",c,c).append(y(t.filter(k=>k.parent===l.id),k=>k.children.length>0?m(k):f(k))),indentation:2}).append("}",c)},v=l=>{const w=T(l.technology)||"",I=T(l.label)||"",L=R(l.color,o("lineColor"),"#777777"),k=b=>`<color:${b}>`;return new g().append(d.get(l.source)," .[",L,",thickness=2].> ",d.get(l.target)).appendIf(!!(I||w),' : "',k(L)).appendIf(!!I,I,k(L)).appendIf(!!(I&&w),"\\n").appendIf(!!w,k(L),"<size:8>[",w,"]</size>").appendIf(!!(I||w),'"').append(c)};
|
|
38
|
+
return j(new g().append("@startuml",c).append(p(),c).append(u(),c).append(y(t.filter(l=>l.children.length==0),l=>h(l),{appendNewLineIfNotEmpty:!0})).append(y(t.filter(l=>x(l.parent)),l=>l.children.length>0?m(l):f(l),{appendNewLineIfNotEmpty:!0})).appendIf(r.length>0,c,y(r,l=>v(l),{appendNewLineIfNotEmpty:!0})).append("@enduml",c))}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=>U("likec4:plugin",e,n)+".js"}}function P(n,e){return{id:`likec4:${n}`,virtualId:`likec4:plugin/${n}.js`,async load({likec4:i,logger:t,projects:r,assetsDir:a}){t.info(N.dim(`generating likec4:${n}`));const s=r.map(({id:o})=>{const d=U(`likec4:${n}`,o);return` case ${JSON.stringify(o)}: return await import(${JSON.stringify(d)})`});return`
|
|
40
|
+
export async function ${e}(projectId) {
|
|
41
|
+
switch (projectId) {
|
|
42
|
+
${s.join(`
|
|
43
|
+
`)}
|
|
44
|
+
default: throw new Error('Unknown projectId: ' + projectId)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`}}}function sn(n){const e=new g;return e.appendTemplate`
|
|
48
|
+
/******************************************************************************
|
|
49
|
+
* This file was generated
|
|
50
|
+
* DO NOT EDIT MANUALLY!
|
|
51
|
+
******************************************************************************/
|
|
52
|
+
/* eslint-disable */
|
|
53
|
+
|
|
54
|
+
export function d2Source(viewId) {
|
|
55
|
+
switch (viewId) {
|
|
56
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y([...n.views()],t=>$`
|
|
57
|
+
case ${JSON.stringify(t.id)}: {
|
|
58
|
+
return ${JSON.stringify(Z(t))}
|
|
59
|
+
}
|
|
60
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
61
|
+
default: {
|
|
62
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
63
|
+
}
|
|
64
|
+
`}}).append(c," }",c).appendTemplate`
|
|
65
|
+
}
|
|
66
|
+
`.append(c,c),j(e)}const dn={...S("d2"),async load({likec4:n,projectId:e,logger:i}){i.info(N.dim(`generating likec4:d2/${e}`));const t=await n.computedModel(e);return sn(t)}},cn=P("d2","loadD2Sources");function ln(n){const e=new g;return e.appendTemplate`
|
|
67
|
+
/******************************************************************************
|
|
68
|
+
* This file was generated
|
|
69
|
+
* DO NOT EDIT MANUALLY!
|
|
70
|
+
******************************************************************************/
|
|
71
|
+
/* eslint-disable */
|
|
72
|
+
|
|
73
|
+
export function dotSource(viewId) {
|
|
74
|
+
switch (viewId) {
|
|
75
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y(Object.keys(n),t=>$`
|
|
76
|
+
case ${JSON.stringify(t)}: {
|
|
77
|
+
return ${JSON.stringify(n[t].dot)}
|
|
78
|
+
}
|
|
79
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
80
|
+
default: {
|
|
81
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
82
|
+
}
|
|
83
|
+
`}}).append(c," }",c).appendTemplate`
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function svgSource(viewId) {
|
|
87
|
+
switch (viewId) {
|
|
88
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y(Object.keys(n),t=>$`
|
|
89
|
+
case ${JSON.stringify(t)}: {
|
|
90
|
+
return ${JSON.stringify(n[t].svg)}
|
|
91
|
+
}
|
|
92
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
93
|
+
default: {
|
|
94
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
95
|
+
}
|
|
96
|
+
`}}).append(c," }",c,"}",c,c),j(e)}const pn={...S("dot"),async load({likec4:n,projectId:e,logger:i}){i.info(N.dim(`generating likec4:dot/${e}`));const t=await n.views.viewsAsGraphvizOut(e),r=ge(t,({id:a,svg:s,dot:o})=>[a,{dot:o,svg:s}]);return ln(r)}},un=P("dot","loadDotSources");function fn(n){const e=he(n.flatMap(r=>r.nodes.map(a=>a.icon)),Ie(r=>Ne(r)&&!(r.toLowerCase().startsWith("http:")||r.toLowerCase().startsWith("https:"))),we(),me(ke)),{imports:i,cases:t}=e.reduce((r,a,s)=>{const o=a.
|
|
97
|
+
startsWith("file:"),d="Icon"+s.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[p,u]=a.split(":");return r.imports.push(`import ${d} from 'likec4/icons/${p}/${u}'`),r.cases.push(` '${p}:${u}': ${d}`),r},{imports:[],cases:[]});return`
|
|
98
|
+
import { jsx } from 'react/jsx-runtime'
|
|
99
|
+
${i.join(`
|
|
100
|
+
`)}
|
|
101
|
+
|
|
102
|
+
const Icons = {
|
|
103
|
+
${t.join(`,
|
|
104
|
+
`)}
|
|
105
|
+
}
|
|
106
|
+
export function IconRenderer({ node }) {
|
|
107
|
+
const IconComponent = Icons[node.icon ?? '']
|
|
108
|
+
if (!IconComponent) {
|
|
109
|
+
return null
|
|
110
|
+
}
|
|
111
|
+
return jsx(IconComponent, {node})
|
|
112
|
+
}
|
|
113
|
+
`}const gn={...S("icons"),async load({likec4:n,projectId:e,logger:i}){i.info(N.dim(`generating likec4:icons/${e}`));const t=await n.views.computedViews(e);return fn(t)}},hn={id:"likec4:icons",virtualId:"likec4:plugin/icons.jsx",async load({likec4:n,projects:e,logger:i}){i.info(N.dim("generating likec4:icons"));const{imports:t,cases:r}=e.reduce((a,{id:s},o)=>{const d="Icons"+o.toString().padStart(2,"0"),p=U("likec4:icons",s);return a.imports.push(`import { IconRenderer as ${d} } from ${JSON.stringify(
|
|
114
|
+
p)}`),a.cases.push(` case ${JSON.stringify(s)}: return ${d}`),a},{imports:[],cases:[]});return`
|
|
115
|
+
${t.join(`
|
|
116
|
+
`)}
|
|
117
|
+
|
|
118
|
+
export function ProjectIcons(projectId) {
|
|
119
|
+
switch (projectId) {
|
|
120
|
+
${r.join(`
|
|
121
|
+
`)}
|
|
122
|
+
default:
|
|
123
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
`}};function mn(n){const e=new g;return e.appendTemplate`
|
|
127
|
+
/******************************************************************************
|
|
128
|
+
* This file was generated
|
|
129
|
+
* DO NOT EDIT MANUALLY!
|
|
130
|
+
******************************************************************************/
|
|
131
|
+
/* eslint-disable */
|
|
132
|
+
|
|
133
|
+
export function mmdSource(viewId) {
|
|
134
|
+
switch (viewId) {
|
|
135
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y([...n.views()],t=>$`
|
|
136
|
+
case ${JSON.stringify(t.id)}: {
|
|
137
|
+
return ${JSON.stringify(ee(t))}
|
|
138
|
+
}
|
|
139
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
140
|
+
default: {
|
|
141
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
142
|
+
}
|
|
143
|
+
`}}).append(c," }",c).appendTemplate`
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
`.append(c,c),j(e)}const wn={...S("mmd"),async load({likec4:n,projectId:e,logger:i}){i.info(N.dim(`generating virtual:likec4/mmd/${e}`));const t=await n.computedModel(e);return mn(t)}},In=P("mmd","loadMmdSources"),Nn=n=>`
|
|
147
|
+
import { createHooksForModel, atom } from 'likec4/vite-plugin/internal'
|
|
148
|
+
|
|
149
|
+
export const $likec4data = atom(${W.stringify(n.$data)})
|
|
150
|
+
|
|
151
|
+
export const {
|
|
152
|
+
updateModel,
|
|
153
|
+
$likec4model,
|
|
154
|
+
useLikeC4Model,
|
|
155
|
+
useLikeC4Views,
|
|
156
|
+
useLikeC4View
|
|
157
|
+
}= /* @__PURE__ */ createHooksForModel($likec4data)
|
|
158
|
+
|
|
159
|
+
if (import.meta.hot) {
|
|
160
|
+
import.meta.hot.accept(md => {
|
|
161
|
+
if (!import.meta.hot.data.$update) {
|
|
162
|
+
import.meta.hot.data.$update = updateModel
|
|
163
|
+
}
|
|
164
|
+
const update = md.$likec4data?.value
|
|
165
|
+
if (update) {
|
|
166
|
+
import.meta.hot.data.$update(update)
|
|
167
|
+
} else {
|
|
168
|
+
import.meta.hot.invalidate()
|
|
169
|
+
}
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
`,yn={...S("model"),async load({likec4:n,projectId:e,logger:i,assetsDir:t}){i.info(N.dim(`generating likec4:model/${e}`));const r=await n.layoutedModel(e);return Nn(r)}},vn={id:"likec4:model",virtualId:"likec4:plugin/model.js",async load({likec4:n,logger:e,projects:i,assetsDir:t}){return e.info(N.dim("generating likec4:model")),`
|
|
173
|
+
export async function loadModel(projectId) {
|
|
174
|
+
switch (projectId) {
|
|
175
|
+
${i.map(({id:r})=>{const a=U("likec4:model",r);return` case ${JSON.stringify(r)}: return await import(${JSON.stringify(a)})`}).join(`
|
|
176
|
+
`)}
|
|
177
|
+
default: throw new Error('Unknown projectId: ' + projectId)
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
`}},kn=n=>`
|
|
181
|
+
export const isSingleProject = ${n.length===1};
|
|
182
|
+
export const projects = ${W.stringify(n,null,2)};
|
|
183
|
+
`,Ln={id:"likec4:projects",virtualId:"likec4:plugin/projects.js",async load({likec4:n,logger:e,projects:i,assetsDir:t}){return e.info(N.dim("generating likec4:projects")),kn(ye(i,je(["id","title"])))}};function $n(n){const e=new g;return e.appendTemplate`
|
|
184
|
+
/******************************************************************************
|
|
185
|
+
* This file was generated
|
|
186
|
+
* DO NOT EDIT MANUALLY!
|
|
187
|
+
******************************************************************************/
|
|
188
|
+
/* eslint-disable */
|
|
189
|
+
|
|
190
|
+
export function pumlSource(viewId) {
|
|
191
|
+
switch (viewId) {
|
|
192
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(y([...n.views()],t=>$`
|
|
193
|
+
case ${JSON.stringify(t.id)}: {
|
|
194
|
+
return ${JSON.stringify(ie(t))}
|
|
195
|
+
}
|
|
196
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
197
|
+
default: {
|
|
198
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
199
|
+
}
|
|
200
|
+
`}}).append(c," }",c).appendTemplate`
|
|
201
|
+
}
|
|
202
|
+
`.append(c,c),j(e)}const jn={...S("puml"),async load({likec4:n,projectId:e,logger:i}){i.info(N.dim(`generating likec4:puml/${e}`));const t=await n.computedModel(e);return $n(t)}},Sn=P("puml","loadPumlSources"),re=n=>`
|
|
203
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
204
|
+
import { LikeC4ModelProvider as Provider, LikeC4View as GenericView, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
|
|
205
|
+
import { IconRenderer } from 'likec4:icons/${n}'
|
|
206
|
+
|
|
207
|
+
import { useLikeC4Model, useLikeC4Views, useLikeC4View } from 'likec4:model/${n}'
|
|
208
|
+
|
|
209
|
+
export function LikeC4ModelProvider({ children }) {
|
|
210
|
+
const likeC4Model = useLikeC4Model()
|
|
211
|
+
return (_jsx(Provider, { likec4model: likeC4Model, children: children }));
|
|
212
|
+
}
|
|
213
|
+
export function LikeC4View(props) {
|
|
214
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericView, { renderIcon: IconRenderer, ...props }) }));
|
|
215
|
+
}
|
|
216
|
+
export function ReactLikeC4(props) {
|
|
217
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericReactLikeC4, { renderIcon: IconRenderer, ...props }) }));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export {
|
|
221
|
+
useLikeC4Model,
|
|
222
|
+
useLikeC4View,
|
|
223
|
+
useLikeC4Views
|
|
224
|
+
}
|
|
225
|
+
`,Cn={...S("react"),async load({projectId:n,logger:e}){return e.info(N.dim(`generating likec4:react/${n}`)),re(n)}},Rn={id:"likec4:react",virtualId:"likec4:plugin/react.js",async load({logger:n,projects:e}){const i=G(e);return n.info(N.dim("generating likec4:react for")+" "+i.id),re(i.id)}},Tn=n=>`
|
|
226
|
+
export { IconRenderer } from 'likec4:icons/${n}'
|
|
227
|
+
export {
|
|
228
|
+
$likec4data,
|
|
229
|
+
$likec4model,
|
|
230
|
+
useLikeC4Model,
|
|
231
|
+
useLikeC4Views,
|
|
232
|
+
useLikeC4View
|
|
233
|
+
} from 'likec4:model/${n}'
|
|
234
|
+
export const projectId = ${JSON.stringify(n)}
|
|
235
|
+
`,En={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(N.dim("generating likec4:single-project for")+" "+r.id),Tn(r.id)}},oe=[yn,gn,dn,pn,wn,jn],ae=[...oe,Cn],se=[Ln,vn,En,Rn,cn,un,In,Sn,hn],Mn=n=>{const e=n.toLowerCase();return e.endsWith(".c4")||e.endsWith(".likec4")||e.endsWith(".like-c4")};function bn({useOverviewGraph:n=!1,...e}){let i,t,r,a;return{name:"vite-plugin-likec4",async configResolved(s){
|
|
236
|
+
if(i=s.root,t=s.logger,n===!0){const o=s.resolve.alias.find(d=>d.find==="likec4/previews")?.replacement;o?(a=o,t.info(N.dim("likec4/previews alias")+" "+N.dim(a))):t.warn("likec4/previews alias not found")}e.languageServices?r=e.languageServices:r=(await ve.fromWorkspace(e.workspace??s.root,{logger:t,graphviz:e.graphviz??"wasm",printErrors:e.printErrors??!0,throwIfInvalid:e.throwIfInvalid??!1})).languageServices,a=r.workspaceUri.fsPath},resolveId(s){for(const o of ae){const d=o.matches(s);if(d)return o.
|
|
237
|
+
virtualId(d)}for(const o of se)if(o.id===s)return o.virtualId;return null},async load(s){for(const o of ae){const d=o.matches(s);if(d)return await o.load({logger:t,likec4:r,projectId:d,assetsDir:a,useOverviewGraph:n})}for(const o of se)if(o.virtualId===s){const d=(await r.projects()).map(p=>({id:p.id,title:p.config.title??p.id,folder:p.folder}));return de(ce(d)),await o.load({logger:t,likec4:r,projects:d,assetsDir:a,useOverviewGraph:n})}return null},configureServer(s){const o=r.projects().map(({
|
|
238
|
+
folder:p})=>p.fsPath);for(const p of o)t.info(`${N.dim("watch")} ${p}`);const d=p=>u=>{Mn(u)&&r.notifyUpdate({[p]:u})};s.watcher.add(o).on("add",d("changed")).on("change",d("changed")).on("unlink",d("removed")),r.builder.onModelParsed(async()=>{const[p]=r.getErrors();if(p){s.ws.send({type:"error",err:{name:"LikeC4ValidationError",message:`Validation failed
|
|
239
|
+
`+p.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:le(i,p.sourceFsPath),line:p.range.start.line+1,column:p.range.start.character+1}}});return}for(const u of r.projects())for(const h of oe){const f=s.moduleGraph.getModuleById(h.virtualId(u.id));if(f&&f.importers.size>0){t.info(`${N.green("reload")} ${N.dim(f.id??f.url)}`);try{await s.reloadModule(f)}catch(m){t.error(m)}}}})}}}export{g as C,bn as L,c as N,ee as a,Z as b,$ as e,ie as g,y as j,j as t};
|