likec4 1.25.0 → 1.26.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__/react/likec4.tsx +12 -28
- package/__app__/src/main.js +48928 -3
- package/__app__/src/style.css +1 -1
- package/__app__/webcomponent/webcomponent.js +2 -16
- package/dist/cli/index.mjs +727 -1112
- package/dist/index.d.mts +11 -16022
- package/dist/index.d.ts +11 -16022
- package/dist/index.mjs +1 -1
- package/dist/model/index.d.mts +2 -2
- package/dist/model/index.d.ts +2 -2
- package/dist/shared/likec4.C0X7XZt3.mjs +3682 -0
- package/dist/shared/likec4.Cz9mPeTQ.mjs +356 -0
- package/dist/shared/likec4.Y_4a6gTW.d.mts +2063 -0
- package/dist/shared/likec4.Y_4a6gTW.d.ts +2063 -0
- package/dist/vite-plugin/index.d.mts +48 -0
- package/dist/vite-plugin/index.d.ts +48 -0
- package/dist/vite-plugin/index.mjs +2 -0
- package/package.json +37 -24
- package/react/index.d.ts +17 -9
- package/react/index.js +6924 -5918
- package/react/{style.css → likec4.css} +1 -1
- package/vite-plugin-modules.d.ts +88 -0
- package/__app__/src/chunks/-index-overview-BQqR8e0d.js +0 -310
- package/__app__/src/chunks/-view-lazy-data-CI4xD57c.js +0 -9
- package/__app__/src/chunks/likec4-DRDnYFvy.js +0 -6150
- package/__app__/src/chunks/main-iM8EmCL0.js +0 -25402
- package/__app__/src/chunks/mantine-B7q9iXnB.js +0 -13363
- package/__app__/src/chunks/tanstack-router-MjA2OK6n.js +0 -2925
- package/__app__/src/icons.js +0 -9
- package/dist/shared/likec4.DX7xzn9M.mjs +0 -3608
- /package/__app__/src/{chunks/index-C6pszJh8.js → index-C6pszJh8.js} +0 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import{relative as Q}from"node:path";import{f as Z,g as b,T as ee,N as U,i as te,l as y,n as _,j as T,u as m,a as ne,C as ie,b as re,c as O,d as oe,t as se,m as ae,p as de,e as le,L as ce}from"./likec4.C0X7XZt3.mjs";import{sortNaturalByFqn as A,compareNatural as pe}from"@likec4/core";function ue(t){var e,i;if(t){if("astNode"in t)return he(t);if(Array.isArray(t))return t.reduce(J,void 0);{const n=t,r=fe(n)?ge((i=(e=n?.root)===null||e===void 0?void 0:e.astNode)!==null&&i!==void 0?i:n?.astNode):void 0;
|
|
2
|
+
return C(n,r)}}else return}function fe(t){return typeof t<"u"&&"element"in t&&"text"in t}function ge(t){try{return b(t).uri.toString()}catch{return}}function he(t){var e,i;const{astNode:n,property:r,index:s}=t??{},o=(e=n?.$cstNode)!==null&&e!==void 0?e:n?.$textRegion;if(!(n===void 0||o===void 0)){if(r===void 0)return C(o,R(n));{const a=d=>s!==void 0&&s>-1&&Array.isArray(n[r])?s<d.length?d[s]:void 0:d.reduce(J,void 0);if(!((i=o.assignments)===null||i===void 0)&&i[r]){const d=a(o.assignments[r]);return d&&
|
|
3
|
+
C(d,R(n))}else if(n.$cstNode){const d=a(Z(n.$cstNode,r));return d&&C(d,R(n))}else return}}}function R(t){var e,i,n,r;return t.$cstNode?(i=(e=b(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 ee(t,s=>s.$container?[s.$container]:[]).find(s=>{var o;return(o=s.$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 C(t,e){var i,
|
|
4
|
+
n;const r={offset:t.offset,end:(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,length:(n=t.length)!==null&&n!==void 0?n:t.end-t.offset};return t.range&&(r.range=t.range),e??(e=t.fileURI),e&&(r.fileURI=e),r}function J(t,e){var i,n;if(t){if(!e)return t&&C(t)}else return e&&C(e);const r=(i=t.end)!==null&&i!==void 0?i:t.offset+t.length,s=(n=e.end)!==null&&n!==void 0?n:e.offset+e.length,o=Math.min(t.offset,e.offset),a=Math.max(r,s),d=a-o,c={offset:o,end:a,length:d};if(t.range&&e.range&&(c.range={start:e.
|
|
5
|
+
range.start.line<t.range.start.line||e.range.start.line===t.range.start.line&&e.range.start.character<t.range.start.character?e.range.start:t.range.start,end:e.range.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 me{constructor(e){this.defaultIndentation=" ",this.pendingIndent=
|
|
6
|
+
!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.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.
|
|
7
|
+
currentLineNumber,character:this.currentLineContent.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.
|
|
8
|
+
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.currentLineNumber]=[],this.pendingIndent=!0}addNewLine(){this.pendingIndent=!0,this.lines.push([]),this.recentNonImmediateIndents.length=0}pushTraceRegion(e){const i=we(e,this.currentPosition,n=>{var r,s;return(s=(r=this.traceData[this.traceData.
|
|
9
|
+
length-1])===null||r===void 0?void 0:r.children)===null||s===void 0?void 0:s.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 we(t,e,i){const n={sourceRegion:t,targetRegion:void 0,
|
|
10
|
+
children:[],targetStart:e,complete:r=>{var s,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,((s=n.children)===null||s===void 0?void 0:s.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 me(e),n=i.pushTraceRegion(
|
|
11
|
+
void 0);G(t,i),i.popTraceRegion(n),n.complete&&n.complete(i.currentPosition);const r=n.children&&n.children.length===1?n.children[0]:void 0,s=r?.targetRegion,o=n.targetRegion;return s&&r.sourceRegion&&s.offset===o.offset&&s.length===o.length?{text:i.content,trace:r}:{text:i.content,trace:n}}function G(t,e){typeof t=="string"?ke(t,e):t instanceof V?Le(t,e):t instanceof g?q(t,e):t instanceof N&&ye(t,e)}function W(t,e){return typeof t=="string"?t.length!==0:t instanceof g?t.contents.some(i=>W(i,e)):
|
|
12
|
+
t instanceof N?!(t.ifNotEmpty&&e.currentLineContent.length===0):!1}function ke(t,e){t&&(e.pendingIndent&&F(e,!1),e.append(t))}function F(t,e){var i;let n="";for(const r of t.relevantIndents.filter(s=>s.indentEmptyLines||!e))n+=(i=r.indentation)!==null&&i!==void 0?i:t.defaultIndentation;t.append(n,!0),t.pendingIndent=!1}function q(t,e){let i;const n=ue(t.tracedSource);n&&(i=e.pushTraceRegion(n));for(const r of t.contents)G(r,e);if(i){e.popTraceRegion(i);const r=e.getParentTraceSourceFileURI();r&&
|
|
13
|
+
n?.fileURI===r&&delete n.fileURI,i.complete&&i.complete(e.currentPosition)}}function Le(t,e){var i;if(W(t,e)){t.indentImmediately&&!e.pendingIndent&&e.append((i=t.indentation)!==null&&i!==void 0?i:e.defaultIndentation,!0);try{e.increaseIndent(t),q(t,e)}finally{e.decreaseIndent()}}}function ye(t,e){t.ifNotEmpty&&!Ce(e.currentLineContent)?e.resetCurrentLine():(e.pendingIndent&&F(e,!0),e.append(t.lineDelimiter),e.addNewLine())}function Ce(t){return t.trimStart()!==""}Object.freeze("__\xABSKIP^NEW^LINE\
|
|
14
|
+
^IF^EMPTY\xBB__");const ve=/\S|$/;function Ne(t){const e=t.filter(n=>n.length>0).map(n=>n.search(ve)),i=e.length===0?0:Math.min(...e);return Math.max(0,i)}function I(t,...e){const i=je(t),n=Se(t,e,i);return Me(n)}function $e(t,e,i){return(n,...r)=>Ee(t,e,i)(I(n,...r))}function je(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,
|
|
15
|
+
omitFirstLine:i,omitLastLine:n,trimLastLine:e.length!==1&&e[e.length-1].trim().length===0};{let r=i?e.slice(1):e;r=n?r.slice(0,r.length-1):r,r=r.filter(o=>o.length!==0);const s=Ne(r);return{indentation:s,omitFirstLine:i,omitLastLine:n&&(e[e.length-1].length<s||!e[e.length-1].startsWith(r[0].substring(0,s)))}}}function Se(t,e,{indentation:i,omitFirstLine:n,omitLastLine:r,trimLastLine:s}){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?
|
|
16
|
+
(u,p,h)=>h===0?n?[]:[p]:h===1&&u.length===0?[p]:u.concat(M,p):(u,p,h)=>h===0?[p]:u.concat(M,p),[]).filter(u=>!(typeof u=="string"&&u.length===0)).concat(v(e[f])?e[f]:e[f]!==void 0?{content:String(e[f])}:f<e.length?Y:[]))});const a=o.length,d=a!==0?o[a-1]:void 0;return(r||s)&&typeof d=="string"&&d.trim().length===0?n&&a!==1&&o[a-2]===M?o.slice(0,a-2):o.slice(0,a-1):o}const M={isNewLine:!0},Y={isUndefinedSegment:!0},X=t=>t===M,E=t=>t===Y,Te=t=>t.content!==void 0;function Me(t){return t.reduce((i,n,r)=>E(
|
|
17
|
+
n)?i:X(n)?{node:r!==0&&(E(t[r-1])||v(t[r-1]))||r>1&&typeof t[r-1]=="string"&&(E(t[r-2])||v(t[r-2]))?i.node.appendNewLineIfNotEmpty():i.node.appendNewLine()}:(()=>{var s;const o=(r===0||X(t[r-1]))&&typeof n=="string"&&n.length!==0?"".padStart(n.length-n.trimStart().length):"",a=Te(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(a)}):i.node.append(a),indented:d??((s=i.indented)===null||s===void 0?void 0:
|
|
18
|
+
s.append(a))}})(),{node:new g}).node}const Re=typeof process>"u"?`
|
|
19
|
+
`:process.platform==="win32"?`\r
|
|
20
|
+
`:`
|
|
21
|
+
`;function v(t){return t instanceof g||t instanceof V||t instanceof N}function k(t,e){return v(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(te(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(Ve)}appendNewLineIfNotEmptyIf(e){return e?this.appendNewLineIfNotEmpty():this}appendTemplate(e,...i){return this.append(
|
|
23
|
+
I(e,...i))}appendTemplateIf(e){return e?(i,...n)=>this.appendTemplate(i,...n):()=>this}indent(e){const{indentedChildren:i,indentation:n,indentEmptyLines:r,indentImmediately:s}=Array.isArray(e)||typeof e=="function"?{indentedChildren:e}:typeof e=="object"?e:{},o=new V(n,s,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,...s)=>this.append($e(e,i,n)(r,...s))}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 V 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 N{constructor(e,i=!1){this.ifNotEmpty=!1,this.lineDelimiter=e??Re,this.ifNotEmpty=i}}const l=new N,Ve=new N(void 0,!0),z=t=>t===void 0||typeof t=="string"||v(t)?t:String(t);function w(t,e=z,i={}){const n=typeof e=="function"?e:z,{filter:r,prefix:s,suffix:o,separator:a,appendNewLineIfNotEmpty:d,skipNewLineAfterLastItem:c}=typeof e=="object"?e:i,f=typeof s=="function"?s:()=>s,u=typeof o=="function"?o:()=>o;return xe(t,(p,h,S,L)=>{
|
|
26
|
+
if(r&&!r(h,S,L))return p;const P=n(h,S,L);return P===void 0?p:(p??(p=new g)).append(f(h,S,L)).append(P).append(u(h,S,L)).appendIf(!L,a).appendNewLineIfNotEmptyIf(!p.isEmpty()&&!!d&&(!L||!c))})}function xe(t,e,i){const n=t[Symbol.iterator]();let r=n.next(),s=0,o=i;for(;!r.done;){const a=n.next();o=e(o,r.value,s,!!a.done),r=a,s++}return o}const De=t=>t.charAt(0).toLocaleUpperCase()+t.slice(1),Pe=t=>t.split(".").map(De).join(""),be=t=>Pe(t.parent?t.id.slice(t.parent.length+1):t.id),Ue=({autoLayout:t})=>{
|
|
27
|
+
switch(t.direction){case"TB":return"down";case"BT":return"up";case"LR":return"right";case"RL":return"left"}},_e=({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 B(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,a)=>{const d=be(o),c=(a?a+".":"")+d;n.set(o.id,c);const f=JSON.stringify(o.title),u=_e(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,w(e.filter(h=>h.parent===o.id),h=>r(h,c))),indentation:2}).append("}",l)},s=o=>new g().append(n.get(o.source)," -> ",n.get(o.target)).append(a=>o.label&&a.append(": ",JSON.stringify(o.label)));return k(new g().append("direction: ",Ue(t),l,l).append(w(e.filter(o=>_(o.parent)),o=>r(o),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,l,w(i,o=>s(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),Ge=({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 K(t){const{nodes:e,edges:i}=t,n=new Map,r=(o,a)=>{const d=Je(o),c=(a?a+".":"")+d;n.set(o.id,c);const f=o.title.replaceAll(`
|
|
30
|
+
`,"\\n"),u=Ge(o),p=new g;return o.children.length>0?p.append("subgraph ",c,"[",JSON.stringify(o.title),"]",l).indent({indentedChildren:[w(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},s=o=>new g().append(n.get(o.source)," -.",o.label?' "'+o.label.replaceAll(`
|
|
31
|
+
`,"\\n")+'" .-':"-","> ",n.get(o.target));return k(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(w(e.filter(a=>_(a.parent)),a=>r(a),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,w(i,a=>s(a),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function We(t){const e=new g;return e.appendTemplate`
|
|
32
|
+
/* prettier-ignore-start */
|
|
33
|
+
/* eslint-disable */
|
|
34
|
+
|
|
35
|
+
/******************************************************************************
|
|
36
|
+
* This file was generated
|
|
37
|
+
* DO NOT EDIT MANUALLY!
|
|
38
|
+
******************************************************************************/
|
|
39
|
+
|
|
40
|
+
import { LikeC4Model } from 'likec4/model'
|
|
41
|
+
|
|
42
|
+
export const likeC4Model = LikeC4Model.fromDump(${y.stringify(t.$model,{space:2,quote:"'"})})
|
|
43
|
+
|
|
44
|
+
export type LikeC4ModelTypes = typeof likeC4Model.Aux
|
|
45
|
+
export type LikeC4ElementId = LikeC4ModelTypes['Fqn']
|
|
46
|
+
export type LikeC4DeploymentId = LikeC4ModelTypes['Deployment']
|
|
47
|
+
export type LikeC4ViewId = LikeC4ModelTypes['ViewId']
|
|
48
|
+
|
|
49
|
+
/* prettier-ignore-end */
|
|
50
|
+
`,k(e)}function Fe(t){return w(t,e=>I`${y.stringify(e.id)}`,{separator:" | "})}function qe(t){const e=Array.from(t),i=new g;return i.appendTemplate`
|
|
51
|
+
/******************************************************************************
|
|
52
|
+
* This file was generated
|
|
53
|
+
* DO NOT EDIT MANUALLY!
|
|
54
|
+
******************************************************************************/
|
|
55
|
+
/* prettier-ignore-start */
|
|
56
|
+
/* eslint-disable */
|
|
57
|
+
|
|
58
|
+
// @ts-nocheck
|
|
59
|
+
|
|
60
|
+
import type { DiagramView } from 'likec4'
|
|
61
|
+
`.append(l,l),e.length===0?(i.append("export {}",l),k(i)):(i.appendTemplate`
|
|
62
|
+
export type LikeC4ViewId = ${Fe(e)};
|
|
63
|
+
export const LikeC4Views = {
|
|
64
|
+
`.indent({indentation:2,indentedChildren(n){n.appendNewLineIf(e.length>1).append(w(e,r=>I`${y.stringify(r.id)}: (${y.stringify(r)} as unknown) as DiagramView`,{separator:",",appendNewLineIfNotEmpty:!0}))}}).append("} as const satisfies Record<LikeC4ViewId, DiagramView>",l,l).appendTemplate`
|
|
65
|
+
export type LikeC4Views = typeof LikeC4Views
|
|
66
|
+
|
|
67
|
+
export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId {
|
|
68
|
+
return (
|
|
69
|
+
value != null &&
|
|
70
|
+
typeof value === 'string' &&
|
|
71
|
+
!!LikeC4Views[value]
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* prettier-ignore-end */
|
|
76
|
+
`.append(l),k(i))}function $(t){t instanceof Set&&(t=[...t].sort(pe));const e=t.map(i=>` | ${JSON.stringify(i)}`);return e.length===0&&e.push(" never"),e.join(`
|
|
77
|
+
`)+";"}function Ye(t){const{fqns:e,tags:i,kinds:n}=A([...t.elements()]).reduce((o,a)=>(o.fqns.push(a.id),o.kinds.add(a.kind),o.tags.push(...a.tags),o),{fqns:[],kinds:new Set,tags:[]}),r=A([...t.deployment.elements()]).map(o=>o.id),{viewIds:s}=[...t.views()].reduce((o,a)=>(o.viewIds.add(a.id),o.tags.push(...a.tags),o.tags.push(...a.includedTags),o),{viewIds:new Set,tags:i});return`
|
|
78
|
+
/* prettier-ignore-start */
|
|
79
|
+
/* eslint-disable */
|
|
80
|
+
|
|
81
|
+
/******************************************************************************
|
|
82
|
+
* This file was generated
|
|
83
|
+
* DO NOT EDIT MANUALLY!
|
|
84
|
+
******************************************************************************/
|
|
85
|
+
|
|
86
|
+
import type { PropsWithChildren } from 'react'
|
|
87
|
+
import type { JSX } from 'react/jsx-runtime'
|
|
88
|
+
import type {
|
|
89
|
+
DiagramView,
|
|
90
|
+
LikeC4Model as GenericLikeC4Model,
|
|
91
|
+
} from 'likec4/model'
|
|
92
|
+
import type {
|
|
93
|
+
LikeC4ViewProps as GenericLikeC4ViewProps,
|
|
94
|
+
ReactLikeC4Props as GenericReactLikeC4Props
|
|
95
|
+
} from 'likec4/react'
|
|
96
|
+
|
|
97
|
+
type LikeC4ElementId =
|
|
98
|
+
${$(e)}
|
|
99
|
+
|
|
100
|
+
type LikeC4DeploymentId =
|
|
101
|
+
${$(r)}
|
|
102
|
+
|
|
103
|
+
type LikeC4ViewId =
|
|
104
|
+
${$(s)}
|
|
105
|
+
|
|
106
|
+
type LikeC4ElementKind =
|
|
107
|
+
${$(n)}
|
|
108
|
+
|
|
109
|
+
type LikeC4Tag =
|
|
110
|
+
${$(new Set(i))}
|
|
111
|
+
|
|
112
|
+
declare function isLikeC4ViewId(value: unknown): value is LikeC4ViewId;
|
|
113
|
+
|
|
114
|
+
type Aux = GenericLikeC4Model.Typed<LikeC4ElementId, LikeC4DeploymentId, LikeC4ViewId, DiagramView<LikeC4ViewId>>;
|
|
115
|
+
type LikeC4Model = GenericLikeC4Model<Aux>;
|
|
116
|
+
type LikeC4ViewModel = GenericLikeC4Model.View<Aux>;
|
|
117
|
+
|
|
118
|
+
declare const likeC4Model: LikeC4Model;
|
|
119
|
+
declare function useLikeC4Model(): LikeC4Model;
|
|
120
|
+
declare function useLikeC4View(viewId: LikeC4ViewId): DiagramView<LikeC4ViewId>;
|
|
121
|
+
|
|
122
|
+
declare function LikeC4ModelProvider(props: PropsWithChildren): JSX.Element;
|
|
123
|
+
|
|
124
|
+
type IconRendererProps = {
|
|
125
|
+
node: {
|
|
126
|
+
id: string
|
|
127
|
+
title: string
|
|
128
|
+
icon?: string | undefined
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
declare function RenderIcon(props: IconRendererProps): JSX.Element;
|
|
132
|
+
|
|
133
|
+
type LikeC4ViewProps = GenericLikeC4ViewProps<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>;
|
|
134
|
+
declare function LikeC4View({viewId, ...props}: LikeC4ViewProps): JSX.Element;
|
|
135
|
+
|
|
136
|
+
type ReactLikeC4Props = GenericReactLikeC4Props<LikeC4ViewId, LikeC4Tag, LikeC4ElementKind>
|
|
137
|
+
declare function ReactLikeC4({viewId, ...props}: ReactLikeC4Props): JSX.Element;
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
type LikeC4ElementId,
|
|
141
|
+
type LikeC4DeploymentId,
|
|
142
|
+
type LikeC4ViewId,
|
|
143
|
+
type LikeC4Tag,
|
|
144
|
+
type LikeC4ElementKind,
|
|
145
|
+
type LikeC4ViewProps,
|
|
146
|
+
type ReactLikeC4Props,
|
|
147
|
+
type LikeC4Model,
|
|
148
|
+
isLikeC4ViewId,
|
|
149
|
+
useLikeC4Model,
|
|
150
|
+
useLikeC4View,
|
|
151
|
+
useLikeC4ViewModel,
|
|
152
|
+
likeC4Model,
|
|
153
|
+
LikeC4ModelProvider,
|
|
154
|
+
LikeC4View,
|
|
155
|
+
RenderIcon,
|
|
156
|
+
ReactLikeC4
|
|
157
|
+
}
|
|
158
|
+
/* prettier-ignore-end */
|
|
159
|
+
`.trimStart()}function j(t){return{matches:e=>{let{module:i,projectId:n}=e.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.groups??e.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!i||!n?null:(i.endsWith(".js")&&(i=i.slice(0,-3)),i===t?n:null)},virtualId:e=>T("likec4:plugin",e,t)+".js"}}function x(t,e){return{id:`likec4:${t}`,virtualId:`likec4:plugin/${t}.js`,async load({likec4:i,logger:n,projects:r,assetsDir:s}){n.info(m.dim(`generating likec4:${t}`));const o=r.map(
|
|
160
|
+
({id:a})=>{const d=T(`likec4:${t}`,a);return` case ${JSON.stringify(a)}: return await import(${JSON.stringify(d)})`});return`
|
|
161
|
+
export async function ${e}(projectId) {
|
|
162
|
+
switch (projectId) {
|
|
163
|
+
${o.join(`
|
|
164
|
+
`)}
|
|
165
|
+
default: throw new Error('Unknown projectId: ' + projectId)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
`}}}const Xe=t=>{const e=new g;return e.appendTemplate`
|
|
169
|
+
/******************************************************************************
|
|
170
|
+
* This file was generated
|
|
171
|
+
* DO NOT EDIT MANUALLY!
|
|
172
|
+
******************************************************************************/
|
|
173
|
+
/* eslint-disable */
|
|
174
|
+
|
|
175
|
+
export function d2Source(viewId) {
|
|
176
|
+
switch (viewId) {
|
|
177
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(w(t,n=>I`
|
|
178
|
+
case ${JSON.stringify(n.id)}: {
|
|
179
|
+
return ${JSON.stringify(B(n))}
|
|
180
|
+
}
|
|
181
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
182
|
+
default: {
|
|
183
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
184
|
+
}
|
|
185
|
+
`}}).append(l," }",l).appendTemplate`
|
|
186
|
+
}
|
|
187
|
+
`.append(l,l),k(e)},ze={...j("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 Xe(n)}},Be=x("d2","loadD2Sources");function Ke(t){const e=new g;return e.appendTemplate`
|
|
188
|
+
/******************************************************************************
|
|
189
|
+
* This file was generated
|
|
190
|
+
* DO NOT EDIT MANUALLY!
|
|
191
|
+
******************************************************************************/
|
|
192
|
+
/* eslint-disable */
|
|
193
|
+
|
|
194
|
+
export function dotSource(viewId) {
|
|
195
|
+
switch (viewId) {
|
|
196
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(w(Object.keys(t),n=>I`
|
|
197
|
+
case ${JSON.stringify(n)}: {
|
|
198
|
+
return ${JSON.stringify(t[n].dot)}
|
|
199
|
+
}
|
|
200
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
201
|
+
default: {
|
|
202
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
203
|
+
}
|
|
204
|
+
`}}).append(l," }",l).appendTemplate`
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function svgSource(viewId) {
|
|
208
|
+
switch (viewId) {
|
|
209
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(w(Object.keys(t),n=>I`
|
|
210
|
+
case ${JSON.stringify(n)}: {
|
|
211
|
+
return ${JSON.stringify(t[n].svg)}
|
|
212
|
+
}
|
|
213
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
214
|
+
default: {
|
|
215
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
216
|
+
}
|
|
217
|
+
`}}).append(l," }",l,"}",l,l),k(e)}const He={...j("dot"),async load({likec4:t,projectId:e,logger:i}){i.info(m.dim(`generating likec4:dot/${e}`));const n=await t.views.viewsAsGraphvizOut(),r=ne(n,({id:s,svg:o,dot:a})=>[s,{dot:a,svg:o}]);return Ke(r)}},Qe=x("dot","loadDotSources");function Ze(t){const e=ie(t.flatMap(r=>r.nodes.map(s=>s.icon)),O(se),O(r=>oe(r)&&!r.toLowerCase().startsWith("http")),re()).sort(),{imports:i,cases:n}=e.reduce((r,s,o)=>{const[a,d]=s.split(":"),c="Icon"+o.toString().
|
|
218
|
+
padStart(2,"0");return r.imports.push(`import ${c} from 'likec4/icons/${a}/${d}'`),r.cases.push(` '${a}:${d}': ${c}`),r},{imports:[],cases:[]});return`
|
|
219
|
+
import { jsxs, jsx } from 'react/jsx-runtime'
|
|
220
|
+
${i.join(`
|
|
221
|
+
`)}
|
|
222
|
+
|
|
223
|
+
export const Icons = {
|
|
224
|
+
${n.join(`,
|
|
225
|
+
`)}
|
|
226
|
+
}
|
|
227
|
+
export function IconRenderer({ node }) {
|
|
228
|
+
const IconComponent = Icons[node.icon ?? '']
|
|
229
|
+
if (!IconComponent) {
|
|
230
|
+
return null
|
|
231
|
+
}
|
|
232
|
+
return jsx(IconComponent, {node})
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
if (import.meta.hot) {
|
|
236
|
+
import.meta.hot.accept(md => {
|
|
237
|
+
const update = md.Icons
|
|
238
|
+
if (update) {
|
|
239
|
+
if (!import.meta.hot.data.icons) {
|
|
240
|
+
import.meta.hot.data.icons = Icons
|
|
241
|
+
}
|
|
242
|
+
Object.assign(import.meta.hot.data.icons, update)
|
|
243
|
+
} else {
|
|
244
|
+
import.meta.hot.invalidate()
|
|
245
|
+
}
|
|
246
|
+
})
|
|
247
|
+
}
|
|
248
|
+
`}const et={...j("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 Ze(n)}},tt={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((s,{id:o},a)=>{const d="Icons"+a.toString().padStart(2,"0"),c=T("likec4:icons",o);return s.imports.push(`import { IconRenderer as ${d} } from ${JSON.stringify(
|
|
249
|
+
c)}`),s.cases.push(` case ${JSON.stringify(o)}: return ${d}`),s},{imports:[],cases:[]});return`
|
|
250
|
+
${n.join(`
|
|
251
|
+
`)}
|
|
252
|
+
|
|
253
|
+
export function ProjectIcons(projectId) {
|
|
254
|
+
switch (projectId) {
|
|
255
|
+
${r.join(`
|
|
256
|
+
`)}
|
|
257
|
+
default:
|
|
258
|
+
throw new Error('Unknown projectId: ' + projectId)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
`}};function nt(t){const e=new g;return e.appendTemplate`
|
|
262
|
+
/******************************************************************************
|
|
263
|
+
* This file was generated
|
|
264
|
+
* DO NOT EDIT MANUALLY!
|
|
265
|
+
******************************************************************************/
|
|
266
|
+
/* eslint-disable */
|
|
267
|
+
|
|
268
|
+
export function mmdSource(viewId) {
|
|
269
|
+
switch (viewId) {
|
|
270
|
+
`.appendNewLine().indent({indentation:4,indentedChildren(i){i.append(w(t,n=>I`
|
|
271
|
+
case ${JSON.stringify(n.id)}: {
|
|
272
|
+
return ${JSON.stringify(K(n))}
|
|
273
|
+
}
|
|
274
|
+
`,{appendNewLineIfNotEmpty:!0})).appendTemplate`
|
|
275
|
+
default: {
|
|
276
|
+
throw new Error('Unknown viewId: ' + viewId)
|
|
277
|
+
}
|
|
278
|
+
`}}).append(l," }",l).appendTemplate`
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
`.append(l,l),k(e)}const it={...j("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 nt(n)}},rt=x("mmd","loadMmdSources"),ot=t=>`
|
|
282
|
+
'use client'
|
|
283
|
+
|
|
284
|
+
import { createLikeC4Model } from 'likec4/model'
|
|
285
|
+
import { nano, createHooksForModel } from 'likec4/react'
|
|
286
|
+
|
|
287
|
+
export const $likec4data = nano.atom(${y.stringify(t.$model)})
|
|
288
|
+
|
|
289
|
+
export const {
|
|
290
|
+
updateModel,
|
|
291
|
+
$likec4model,
|
|
292
|
+
useLikeC4Model,
|
|
293
|
+
useLikeC4Views,
|
|
294
|
+
useLikeC4View
|
|
295
|
+
}= /* @__PURE__ */ createHooksForModel($likec4data)
|
|
296
|
+
|
|
297
|
+
if (import.meta.hot) {
|
|
298
|
+
import.meta.hot.accept(md => {
|
|
299
|
+
if (!import.meta.hot.data.$update) {
|
|
300
|
+
import.meta.hot.data.$update = updateModel
|
|
301
|
+
}
|
|
302
|
+
const update = md.$likec4data?.value
|
|
303
|
+
if (update) {
|
|
304
|
+
import.meta.hot.data.$update(update)
|
|
305
|
+
} else {
|
|
306
|
+
import.meta.hot.invalidate()
|
|
307
|
+
}
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
`,st={...j("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 ot(r)}},at={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")),`
|
|
311
|
+
export async function loadModel(projectId) {
|
|
312
|
+
switch (projectId) {
|
|
313
|
+
${i.map(({id:r})=>{const s=T("likec4:model",r);return` case ${JSON.stringify(r)}: return await import(${JSON.stringify(s)})`}).join(`
|
|
314
|
+
`)}
|
|
315
|
+
default: throw new Error('Unknown projectId: ' + projectId)
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
`}},dt=t=>`
|
|
319
|
+
export const isSingleProject = ${t.length===1};
|
|
320
|
+
export const projects = ${y.stringify(t,null,2)};
|
|
321
|
+
`,lt={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")),dt(ae(i,de("id")))}},ct=()=>`
|
|
322
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
323
|
+
import { LikeC4ModelProvider as Provider, LikeC4View as GenericLikeC4View, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
|
|
324
|
+
import { IconRenderer, useLikeC4Model, useLikeC4View, useLikeC4Views } from 'likec4:single-project';
|
|
325
|
+
|
|
326
|
+
export function LikeC4ModelProvider({ children }) {
|
|
327
|
+
const likeC4Model = useLikeC4Model()
|
|
328
|
+
return (_jsx(Provider, { likec4model: likeC4Model, children: children }));
|
|
329
|
+
}
|
|
330
|
+
export function LikeC4View(props) {
|
|
331
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericLikeC4View, { renderIcon: IconRenderer, ...props }) }));
|
|
332
|
+
}
|
|
333
|
+
export function ReactLikeC4(props) {
|
|
334
|
+
return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericReactLikeC4, { renderIcon: IconRenderer, ...props }) }));
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export {
|
|
338
|
+
useLikeC4Model,
|
|
339
|
+
useLikeC4View,
|
|
340
|
+
useLikeC4Views
|
|
341
|
+
}
|
|
342
|
+
`,pt={id:"likec4:react",virtualId:"likec4:plugin/react.js",async load({logger:t}){return t.info(m.dim("generating likec4:react")),ct()}},ut=t=>`
|
|
343
|
+
export { IconRenderer } from 'likec4:icons/${t}'
|
|
344
|
+
export {
|
|
345
|
+
$likec4data,
|
|
346
|
+
$likec4model,
|
|
347
|
+
useLikeC4Model,
|
|
348
|
+
useLikeC4Views,
|
|
349
|
+
useLikeC4View
|
|
350
|
+
} from 'likec4:model/${t}'
|
|
351
|
+
export const projectId = ${JSON.stringify(t)}
|
|
352
|
+
`,ft={id:"likec4:single-project",virtualId:"likec4:plugin/single-project.js",async load({likec4:t,logger:e,projects:i,assetsDir:n}){const r=le(i);return e.info(m.dim("generating likec4:single-project for")+" "+r.id),ut(r.id)}},D=[st,et,ze,He,it],H=[lt,at,ft,pt,Be,Qe,rt,tt],gt=t=>{const e=t.toLowerCase();return e.endsWith(".c4")||e.endsWith(".likec4")||e.endsWith(".like-c4")};function ht({useOverviewGraph:t=!1,...e}){let i,n,r,s;return{name:"vite-plugin-likec4",async configResolved(o){if(i=o.root,
|
|
353
|
+
n=o.logger,t===!0){const a=o.resolve.alias.find(d=>d.find==="likec4/previews")?.replacement;a?(s=a,n.info(m.dim("likec4/previews alias")+" "+m.dim(s))):n.warn("likec4/previews alias not found")}e.languageServices?r=e.languageServices:r=(await ce.fromWorkspace(e.workspace??o.root,{graphviz:e.graphviz??"wasm",printErrors:e.printErrors??!0,throwIfInvalid:e.throwIfInvalid??!1})).languageServices,s=r.workspaceUri.fsPath},resolveId(o){for(const a of D){const d=a.matches(o);if(d)return a.virtualId(d)}for(const a of H)
|
|
354
|
+
if(a.id===o)return a.virtualId;return null},async load(o){for(const a of D){const d=a.matches(o);if(d)return await a.load({logger:n,likec4:r,projectId:d,assetsDir:s,useOverviewGraph:t})}for(const a of H)if(a.virtualId===o){const d=await r.projects();return await a.load({logger:n,likec4:r,projects:d,assetsDir:s,useOverviewGraph:t})}return null},configureServer(o){const a=r.projects().map(({folder:c})=>c.fsPath);for(const c of a)n.info(`${m.dim("watch")} ${c}`);const d=c=>f=>{gt(f)&&r.notifyUpdate(
|
|
355
|
+
{[c]:f})};o.watcher.add(a).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
|
|
356
|
+
`+c.message.slice(0,500),stack:"",plugin:"vite-plugin-likec4",loc:{file:Q(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 D){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{qe as J,ht as L,B as P,K as S,Ye as Y,We as q};
|