likec4 1.48.0 → 1.50.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/README.md +11 -1
- package/__app__/src/likec4.js +5941 -4496
- package/__app__/src/routes/index.js +3 -153
- package/__app__/src/routes/projects.js +21 -1087
- package/__app__/src/routes/single.js +1228 -16
- package/__app__/src/style.css +1 -1
- package/__app__/src/vendors.js +4649 -1897
- package/__app__/src/webcomponent.js +1 -1
- package/config/schema.json +169 -141
- package/dist/THIRD-PARTY-LICENSES.md +1769 -0
- package/dist/_chunks/LikeC4.mjs +1154 -202
- package/dist/_chunks/binary.mjs +72 -0
- package/dist/_chunks/index.d.mts +234 -140
- package/dist/_chunks/index2.d.mts +2043 -1828
- package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +30 -0
- package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
- package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
- package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
- package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
- package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
- package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
- package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +114 -14
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
- package/dist/_chunks/libs/@nanostores/react.d.mts +61 -1
- package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
- package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +1 -10
- package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
- package/dist/_chunks/libs/ajv.mjs +1 -777
- package/dist/_chunks/libs/atomically.mjs +1 -362
- package/dist/_chunks/libs/birpc.mjs +1 -201
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
- package/dist/_chunks/libs/chevrotain.mjs +55 -6229
- package/dist/_chunks/libs/conf.mjs +1 -2258
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/esm-env.mjs +1 -5
- package/dist/_chunks/libs/eventemitter3.mjs +1 -243
- package/dist/_chunks/libs/fast-equals.mjs +1 -446
- package/dist/_chunks/libs/find-up-simple.mjs +1 -24
- package/dist/_chunks/libs/get-port.mjs +1 -107
- package/dist/_chunks/libs/is-docker.mjs +1 -26
- package/dist/_chunks/libs/is-error-instance.mjs +1 -26
- package/dist/_chunks/libs/is-inside-container.mjs +1 -20
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/isexe.mjs +1 -127
- package/dist/_chunks/libs/json5.mjs +14 -959
- package/dist/_chunks/libs/khroma.mjs +1 -605
- package/dist/_chunks/libs/ky.mjs +2 -807
- package/dist/_chunks/libs/langium.d.mts +2913 -2876
- package/dist/_chunks/libs/langium.mjs +33 -20351
- package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
- package/dist/_chunks/libs/p-limit.mjs +1 -120
- package/dist/_chunks/libs/p-queue.mjs +1 -449
- package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
- package/dist/_chunks/libs/package-up.mjs +1 -10
- package/dist/_chunks/libs/pako.mjs +1 -0
- package/dist/_chunks/libs/parse-ms.mjs +1 -36
- package/dist/_chunks/libs/pathe.mjs +1 -0
- package/dist/_chunks/libs/picomatch.mjs +1 -1673
- package/dist/_chunks/libs/pretty-ms.mjs +1 -80
- package/dist/_chunks/libs/remeda.mjs +2 -690
- package/dist/_chunks/libs/safe-stringify.mjs +1 -21
- package/dist/_chunks/libs/strip-indent.mjs +1 -15
- package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
- package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
- package/dist/_chunks/libs/ufo.mjs +1 -240
- package/dist/_chunks/libs/which.mjs +1 -84
- package/dist/_chunks/libs/word-wrap.mjs +12 -43
- package/dist/_chunks/rolldown-runtime.mjs +1 -48
- package/dist/_chunks/sequence.mjs +1 -0
- package/dist/_chunks/src.mjs +15 -0
- package/dist/_chunks/src2.mjs +499 -0
- package/dist/cli/index.mjs +77 -1952
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +1 -6
- package/dist/index.d.mts +150 -7
- package/dist/index.mjs +1 -21
- package/dist/model/builder.mjs +1 -3
- package/dist/model/index.d.mts +57 -3
- package/dist/model/index.mjs +1 -5
- package/dist/vite-plugin/index.d.mts +7 -3
- package/dist/vite-plugin/index.mjs +1 -22
- package/dist/vite-plugin/internal.d.mts +6 -7
- package/dist/vite-plugin/internal.mjs +1 -68
- package/package.json +64 -45
- package/react/{index.d.ts → index.d.mts} +114 -72
- package/react/{index.js → index.mjs} +21320 -22041
- package/react/package.json +2 -5
- package/vite-plugin-modules.d.ts +10 -5
- package/dist/_chunks/LikeC4.d.mts +0 -121
- package/dist/_chunks/config-app.prod.d.mts +0 -18
- package/dist/_chunks/config-app.prod.mjs +0 -188
- package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
- package/dist/_chunks/define-config.mjs +0 -409
- package/dist/_chunks/index3.d.mts +0 -60
- package/dist/_chunks/libs/@chevrotain/gast.mjs +0 -3969
- package/dist/_chunks/libs/hono.mjs +0 -1829
- package/dist/_chunks/libs/nanoid.mjs +0 -29
- package/dist/_chunks/libs/nanostores.d.mts +0 -63
- package/dist/_chunks/libs/nanostores.mjs +0 -198
- package/dist/_chunks/model.mjs +0 -12
- package/dist/_chunks/module.d.mts +0 -71
- package/dist/_chunks/module.mjs +0 -18657
- package/dist/_chunks/plugin.mjs +0 -996
- package/dist/_chunks/sequence-view.mjs +0 -575
- package/dist/_chunks/vite-build.mjs +0 -69
- package/dist/_chunks/vite-dev.mjs +0 -79
- package/dist/_chunks/vite-preview.mjs +0 -27
- package/dist/language/module.d.mts +0 -5
- package/dist/language/module.mjs +0 -20
- package/dist/vite/vite-build.d.mts +0 -26
- package/dist/vite/vite-build.mjs +0 -27
- package/dist/vite/vite-dev.d.mts +0 -34
- package/dist/vite/vite-dev.mjs +0 -29
- package/dist/vite/vite-preview.d.mts +0 -20
- package/dist/vite/vite-preview.mjs +0 -26
- /package/dist/_chunks/{index4.d.mts → libs/@chevrotain/types.d.mts} +0 -0
|
@@ -1,575 +0,0 @@
|
|
|
1
|
-
import { G as t$7, M as t$8, N as t$1, d as t$6, g as t$4, h as t$5, p as t$2, q as t, t as t$3, z as n } from "./libs/remeda.mjs";
|
|
2
|
-
import { a as Variable, i as Strength, n as Constraint, r as Operator, t as Solver } from "./libs/@lume/kiwi.mjs";
|
|
3
|
-
import { getParallelStepsPrefix, isStepEdgeId } from "@likec4/core/types";
|
|
4
|
-
import { DefaultMap, Stack, invariant, isAncestor, nonNullable, nonexhaustive } from "@likec4/core/utils";
|
|
5
|
-
|
|
6
|
-
//#region ../layouts/src/sequence/const.ts
|
|
7
|
-
const ACTOR_GAP = 60;
|
|
8
|
-
const COLUMN_GAP = 32;
|
|
9
|
-
const MIN_ROW_HEIGHT = 80;
|
|
10
|
-
const PORT_HEIGHT = 32;
|
|
11
|
-
const STEP_LABEL_MARGIN = 50;
|
|
12
|
-
const FIRST_STEP_OFFSET = 30;
|
|
13
|
-
const CONTINUOUS_OFFSET = 22;
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region ../layouts/src/sequence/utils.ts
|
|
17
|
-
/**
|
|
18
|
-
* From steps find boxes that must be marked as parallel on the layout
|
|
19
|
-
*/
|
|
20
|
-
function findParallelRects(steps) {
|
|
21
|
-
return t(steps, t$1((s) => s.parallelPrefix ?? void 0), t$2((steps, parallelPrefix) => {
|
|
22
|
-
return steps.reduce((acc, step) => {
|
|
23
|
-
acc.min.column = Math.min(acc.min.column, step.from.column, step.to.column);
|
|
24
|
-
acc.min.row = Math.min(acc.min.row, step.from.row, step.to.row);
|
|
25
|
-
acc.max.column = Math.max(acc.max.column, step.from.column, step.to.column);
|
|
26
|
-
acc.max.row = Math.max(acc.max.row, step.from.row, step.to.row);
|
|
27
|
-
return acc;
|
|
28
|
-
}, {
|
|
29
|
-
parallelPrefix,
|
|
30
|
-
min: {
|
|
31
|
-
column: Infinity,
|
|
32
|
-
row: Infinity
|
|
33
|
-
},
|
|
34
|
-
max: {
|
|
35
|
-
column: -Infinity,
|
|
36
|
-
row: -Infinity
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}), t$3());
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Builds a tree of compounds from actors and nodes.
|
|
43
|
-
* @param actors the actors in the sequence view
|
|
44
|
-
* @param nodes the nodes in likec4 diagram
|
|
45
|
-
* @returns an array of compounds where each compound is a node in the sequence view
|
|
46
|
-
* that is an ancestor of one of the actors
|
|
47
|
-
*/
|
|
48
|
-
function buildCompounds(actors, nodes) {
|
|
49
|
-
if (actors.length === 0 || actors.length === nodes.length) return [];
|
|
50
|
-
const getNode = (id) => nonNullable(nodes.find((n) => n.id === id));
|
|
51
|
-
function parentsLookup(node) {
|
|
52
|
-
const parent = node.parent ? getNode(node.parent) : null;
|
|
53
|
-
if (parent) return [parent, ...parentsLookup(parent)];
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
const stack = new Stack();
|
|
57
|
-
const result = [];
|
|
58
|
-
actors.forEach((actor) => {
|
|
59
|
-
const _ancestors = parentsLookup(actor);
|
|
60
|
-
if (_ancestors.length === 0) {
|
|
61
|
-
stack.clear();
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const ancestors = Stack.from(_ancestors);
|
|
65
|
-
let compound;
|
|
66
|
-
let parent;
|
|
67
|
-
while (true) {
|
|
68
|
-
compound = stack.peek()?.node;
|
|
69
|
-
parent = ancestors.peek();
|
|
70
|
-
if (!parent || !compound) break;
|
|
71
|
-
if (isAncestor(parent.id, compound.id) || parent.id === compound.id) {
|
|
72
|
-
ancestors.pop();
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (!isAncestor(compound.id, parent.id)) {
|
|
76
|
-
stack.pop();
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
while (parent = ancestors.pop()) {
|
|
82
|
-
const parentAsCompound = {
|
|
83
|
-
node: parent,
|
|
84
|
-
from: actor,
|
|
85
|
-
to: actor,
|
|
86
|
-
nested: []
|
|
87
|
-
};
|
|
88
|
-
let compound = stack.peek();
|
|
89
|
-
if (!compound) result.push(parentAsCompound);
|
|
90
|
-
else compound.nested.push(parentAsCompound);
|
|
91
|
-
stack.push(parentAsCompound);
|
|
92
|
-
}
|
|
93
|
-
stack.forEach((c) => c.to = actor);
|
|
94
|
-
});
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region ../layouts/src/sequence/layouter.ts
|
|
100
|
-
var SequenceViewLayouter = class {
|
|
101
|
-
#solver = new Solver();
|
|
102
|
-
#actors;
|
|
103
|
-
#compounds = [];
|
|
104
|
-
#viewportRight;
|
|
105
|
-
#viewportBottom;
|
|
106
|
-
#rowsTop;
|
|
107
|
-
#rows = [];
|
|
108
|
-
#parallelBoxes = [];
|
|
109
|
-
constructor({ actors, steps, compounds }) {
|
|
110
|
-
this.#rowsTop = this.newVar(FIRST_STEP_OFFSET);
|
|
111
|
-
this.#viewportRight = this.newVar(0);
|
|
112
|
-
this.#viewportBottom = this.newVar(0);
|
|
113
|
-
this.#actors = this.addActors(actors);
|
|
114
|
-
for (const compound of compounds) {
|
|
115
|
-
const result = this.addCompound(compound);
|
|
116
|
-
const toplevel = result[0];
|
|
117
|
-
this.constraint(toplevel.y1, "==", 0, Strength.strong);
|
|
118
|
-
this.put(this.#viewportBottom).after(toplevel.bottom);
|
|
119
|
-
this.put(this.#rowsTop).after(toplevel.y2);
|
|
120
|
-
this.#compounds.push(...result);
|
|
121
|
-
}
|
|
122
|
-
for (const step of steps) this.addStep(step);
|
|
123
|
-
for (const parallelRect of findParallelRects(steps)) this.addParallelRect(parallelRect);
|
|
124
|
-
const firstActor = this.#actors[0];
|
|
125
|
-
this.constraint(firstActor.offset.left, "==", 0, Strength.strong);
|
|
126
|
-
const lastActor = this.#actors.reduce((prev, actor) => {
|
|
127
|
-
this.put(actor.x).after(prev.right, ACTOR_GAP);
|
|
128
|
-
this.put(actor.offset.left, Strength.strong).after(prev.offset.right, COLUMN_GAP);
|
|
129
|
-
this.constraint(actor.centerY, "==", prev.centerY, Strength.strong);
|
|
130
|
-
this.put(this.#rowsTop).after(actor.offset.bottom);
|
|
131
|
-
return actor;
|
|
132
|
-
});
|
|
133
|
-
this.put(this.#viewportRight).after(lastActor.offset.right);
|
|
134
|
-
this.put(this.#viewportBottom).after(t$4(this.#rows)?.bottom ?? this.#rowsTop);
|
|
135
|
-
if (compounds.length > 0) for (const compound of this.#compounds) {
|
|
136
|
-
const from = compound.from.column;
|
|
137
|
-
const to = compound.to.column;
|
|
138
|
-
let maxRow = Math.max(compound.from.maxRow, compound.to.maxRow);
|
|
139
|
-
for (let i = from + 1; i < to; i++) {
|
|
140
|
-
const actorBox = this.actorBox(i);
|
|
141
|
-
maxRow = Math.max(maxRow, actorBox.maxRow);
|
|
142
|
-
}
|
|
143
|
-
const lastRow = nonNullable(this.#rows[maxRow], `row ${maxRow} not found`);
|
|
144
|
-
this.put(compound.bottom).after(lastRow.bottom, 16);
|
|
145
|
-
this.put(this.#viewportBottom).after(compound.bottom);
|
|
146
|
-
}
|
|
147
|
-
this.#solver.updateVariables();
|
|
148
|
-
}
|
|
149
|
-
getParallelBoxes() {
|
|
150
|
-
return this.#parallelBoxes.map(({ parallelPrefix, x1, y1, x2, y2 }) => ({
|
|
151
|
-
parallelPrefix,
|
|
152
|
-
x: x1.value(),
|
|
153
|
-
y: y1.value(),
|
|
154
|
-
width: x2.value() - x1.value(),
|
|
155
|
-
height: y2.value() - y1.value()
|
|
156
|
-
}));
|
|
157
|
-
}
|
|
158
|
-
getActorBox(actor) {
|
|
159
|
-
const actorBox = this.actorBox(actor);
|
|
160
|
-
return {
|
|
161
|
-
x: actorBox.x.value(),
|
|
162
|
-
y: actorBox.y.value(),
|
|
163
|
-
width: actorBox.width,
|
|
164
|
-
height: actorBox.height
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
getCompoundBoxes() {
|
|
168
|
-
return this.#compounds.map(({ node, depth, x1, y1, x2, bottom }) => ({
|
|
169
|
-
node,
|
|
170
|
-
depth,
|
|
171
|
-
x: x1.value(),
|
|
172
|
-
y: y1.value(),
|
|
173
|
-
width: x2.value() - x1.value(),
|
|
174
|
-
height: bottom.value() - y1.value()
|
|
175
|
-
}));
|
|
176
|
-
}
|
|
177
|
-
getPortCenter(step, type) {
|
|
178
|
-
const { column, row } = type === "source" ? step.from : step.to;
|
|
179
|
-
const x = this.actorBox(column).centerX;
|
|
180
|
-
const { y } = nonNullable(this.#rows[row]);
|
|
181
|
-
return {
|
|
182
|
-
cx: x.value(),
|
|
183
|
-
cy: y.value() + PORT_HEIGHT / 2 + step.offset,
|
|
184
|
-
height: type === "source" ? 40 : 24
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
getViewBounds() {
|
|
188
|
-
return {
|
|
189
|
-
x: 0,
|
|
190
|
-
y: 0,
|
|
191
|
-
width: this.#viewportRight.value(),
|
|
192
|
-
height: this.#viewportBottom.value()
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
actorBox(actor) {
|
|
196
|
-
if (typeof actor !== "number") {
|
|
197
|
-
const id = typeof actor === "string" ? actor : actor.id;
|
|
198
|
-
actor = this.#actors.findIndex((a) => a.actor.id === id);
|
|
199
|
-
invariant(actor >= 0, `actor ${id} not found`);
|
|
200
|
-
}
|
|
201
|
-
return nonNullable(this.#actors[actor], `actor at index ${actor} not found`);
|
|
202
|
-
}
|
|
203
|
-
addActors(actors) {
|
|
204
|
-
let accX = 0;
|
|
205
|
-
return t$5(actors, (actor, column) => {
|
|
206
|
-
const x = this.newVar(accX);
|
|
207
|
-
accX += actor.width + ACTOR_GAP;
|
|
208
|
-
const y = this.newVar(0);
|
|
209
|
-
const actorBox = {
|
|
210
|
-
column,
|
|
211
|
-
actor,
|
|
212
|
-
x,
|
|
213
|
-
y,
|
|
214
|
-
centerX: x.plus(Math.round(actor.width / 2)),
|
|
215
|
-
centerY: y.plus(Math.round(actor.height / 2)),
|
|
216
|
-
width: actor.width,
|
|
217
|
-
height: actor.height,
|
|
218
|
-
right: x.plus(actor.width),
|
|
219
|
-
bottom: y.plus(actor.height),
|
|
220
|
-
minRow: Infinity,
|
|
221
|
-
maxRow: -Infinity
|
|
222
|
-
};
|
|
223
|
-
const top = this.newVar(0), left = this.newVar(0), right = this.newVar(0), bottom = this.newVar(0);
|
|
224
|
-
this.put(top, Strength.strong).before(y);
|
|
225
|
-
this.put(left, Strength.strong).before(x);
|
|
226
|
-
this.put(right, Strength.strong).after(actorBox.right);
|
|
227
|
-
this.put(bottom, Strength.strong).after(actorBox.bottom);
|
|
228
|
-
return {
|
|
229
|
-
...actorBox,
|
|
230
|
-
offset: {
|
|
231
|
-
top,
|
|
232
|
-
left,
|
|
233
|
-
right,
|
|
234
|
-
bottom
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
addStep(step) {
|
|
240
|
-
const source = this.actorBox(step.source);
|
|
241
|
-
const target = this.actorBox(step.target);
|
|
242
|
-
source.minRow = Math.min(source.minRow, step.from.row);
|
|
243
|
-
source.maxRow = Math.max(source.maxRow, step.from.row);
|
|
244
|
-
target.minRow = Math.min(target.minRow, step.to.row);
|
|
245
|
-
target.maxRow = Math.max(target.maxRow, step.to.row);
|
|
246
|
-
const [left, right] = source.column <= target.column ? [source, target] : [target, source];
|
|
247
|
-
const width = (step.label?.width ?? 100) + STEP_LABEL_MARGIN;
|
|
248
|
-
if (left !== right) this.constraint(left.centerX.plus(width), "<=", right.centerX);
|
|
249
|
-
else this.constraint(left.centerX.plus(width), "<=", left.offset.right);
|
|
250
|
-
let height = step.label?.height ? step.label.height + STEP_LABEL_MARGIN + PORT_HEIGHT / 2 : MIN_ROW_HEIGHT;
|
|
251
|
-
height = Math.max(height, MIN_ROW_HEIGHT) + step.offset;
|
|
252
|
-
this.ensureRow(step.from.row, height);
|
|
253
|
-
if (step.isSelfLoop) this.ensureRow(step.to.row, MIN_ROW_HEIGHT);
|
|
254
|
-
return this;
|
|
255
|
-
}
|
|
256
|
-
addParallelRect({ parallelPrefix, min, max }) {
|
|
257
|
-
const x1 = this.actorBox(min.column).centerX.minus(30);
|
|
258
|
-
const x2 = this.actorBox(max.column).centerX.plus(30);
|
|
259
|
-
const firstRow = this.#rows[min.row];
|
|
260
|
-
const lastRow = this.#rows[max.row];
|
|
261
|
-
invariant(firstRow && lastRow, `parallel box invalid minRow=${min.row} maxRow=${max.row}`);
|
|
262
|
-
const y1 = this.newVar(0);
|
|
263
|
-
this.put(y1).before(firstRow.y, 40);
|
|
264
|
-
const y2 = lastRow.bottom;
|
|
265
|
-
const rowBefore = min.row > 0 && this.#rows[min.row - 1];
|
|
266
|
-
if (rowBefore) this.put(y1).after(rowBefore.bottom, 16);
|
|
267
|
-
const rowAfter = max.row < this.#rows.length - 1 && this.#rows[max.row + 1];
|
|
268
|
-
if (rowAfter) this.put(y2).before(rowAfter.y, 16);
|
|
269
|
-
this.#parallelBoxes.push({
|
|
270
|
-
parallelPrefix,
|
|
271
|
-
x1,
|
|
272
|
-
y1,
|
|
273
|
-
x2,
|
|
274
|
-
y2
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
addCompound(compound) {
|
|
278
|
-
const PADDING = 32;
|
|
279
|
-
const PADDING_TOP = 40;
|
|
280
|
-
const PADDING_TOP_FROM_ACTOR = 52;
|
|
281
|
-
const children = [];
|
|
282
|
-
const nested = compound.nested.flatMap((c) => {
|
|
283
|
-
const result = this.addCompound(c);
|
|
284
|
-
children.push(result[0]);
|
|
285
|
-
return result;
|
|
286
|
-
});
|
|
287
|
-
const depth = Math.max(...nested.map((c) => c.depth + 1), 0);
|
|
288
|
-
const from = this.actorBox(compound.from);
|
|
289
|
-
const to = this.actorBox(compound.to);
|
|
290
|
-
const x1 = from.offset.left.minus(PADDING);
|
|
291
|
-
from.offset.left = x1;
|
|
292
|
-
const x2 = to.offset.right.plus(PADDING);
|
|
293
|
-
to.offset.right = x2;
|
|
294
|
-
const bottom = this.newVar(0);
|
|
295
|
-
const onlyChild = t$6(children);
|
|
296
|
-
let y1, y2;
|
|
297
|
-
switch (true) {
|
|
298
|
-
case !!onlyChild:
|
|
299
|
-
y1 = onlyChild.y1.minus(PADDING_TOP);
|
|
300
|
-
y2 = onlyChild.y2.plus(PADDING);
|
|
301
|
-
this.put(bottom).after(onlyChild.bottom, PADDING);
|
|
302
|
-
break;
|
|
303
|
-
case to === from:
|
|
304
|
-
y1 = this.newVar(0);
|
|
305
|
-
y2 = this.newVar(0);
|
|
306
|
-
this.put(y1).before(from.offset.top, PADDING_TOP_FROM_ACTOR);
|
|
307
|
-
this.put(y2).after(from.offset.bottom, PADDING);
|
|
308
|
-
this.put(bottom).after(y2);
|
|
309
|
-
break;
|
|
310
|
-
case children.length > 0:
|
|
311
|
-
y1 = this.newVar(0);
|
|
312
|
-
y2 = this.newVar(0);
|
|
313
|
-
for (const child of children) {
|
|
314
|
-
this.put(y1).before(child.y1, PADDING);
|
|
315
|
-
this.put(y2).after(child.y2, PADDING);
|
|
316
|
-
this.put(bottom).after(child.bottom, PADDING);
|
|
317
|
-
}
|
|
318
|
-
break;
|
|
319
|
-
default:
|
|
320
|
-
y1 = this.newVar(0);
|
|
321
|
-
y2 = this.newVar(0);
|
|
322
|
-
for (var col = from.column; col <= to.column; col++) {
|
|
323
|
-
const offset = this.actorBox(col).offset;
|
|
324
|
-
this.put(y1).before(offset.top, PADDING_TOP_FROM_ACTOR);
|
|
325
|
-
this.put(y2).after(offset.bottom, PADDING);
|
|
326
|
-
}
|
|
327
|
-
this.put(bottom).after(y2);
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
for (var col = from.column; col <= to.column; col++) {
|
|
331
|
-
const offset = this.actorBox(col).offset;
|
|
332
|
-
offset.top = y1;
|
|
333
|
-
offset.bottom = y2;
|
|
334
|
-
}
|
|
335
|
-
return [{
|
|
336
|
-
node: compound.node,
|
|
337
|
-
depth,
|
|
338
|
-
from,
|
|
339
|
-
to,
|
|
340
|
-
x1,
|
|
341
|
-
y1,
|
|
342
|
-
x2,
|
|
343
|
-
y2,
|
|
344
|
-
bottom
|
|
345
|
-
}, ...nested];
|
|
346
|
-
}
|
|
347
|
-
ensureRow(row, rowHeight) {
|
|
348
|
-
while (row >= this.#rows.length) {
|
|
349
|
-
const prevRowY = this.#rows.length > 0 && this.#rows[this.#rows.length - 1]?.bottom || this.#rowsTop.plus(FIRST_STEP_OFFSET);
|
|
350
|
-
const y = this.newVar(this.#rows.length * MIN_ROW_HEIGHT);
|
|
351
|
-
this.put(y).after(prevRowY);
|
|
352
|
-
const height = this.newVar(MIN_ROW_HEIGHT);
|
|
353
|
-
this.require(height, ">=", MIN_ROW_HEIGHT);
|
|
354
|
-
this.#rows.push({
|
|
355
|
-
y,
|
|
356
|
-
height,
|
|
357
|
-
bottom: y.plus(height),
|
|
358
|
-
lastHeight: MIN_ROW_HEIGHT
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
const rowVar = nonNullable(this.#rows[row]);
|
|
362
|
-
if (rowHeight > rowVar.lastHeight) {
|
|
363
|
-
rowVar.lastHeight = rowHeight;
|
|
364
|
-
this.require(rowVar.height, ">=", rowHeight);
|
|
365
|
-
this.#solver.suggestValue(rowVar.height, rowHeight);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
newVar(initialValue) {
|
|
369
|
-
const v = new Variable();
|
|
370
|
-
this.#solver.addEditVariable(v, Strength.weak);
|
|
371
|
-
if (typeof initialValue === "number") {
|
|
372
|
-
this.#solver.suggestValue(v, initialValue);
|
|
373
|
-
this.constraint(v, ">=", 0, Strength.strong);
|
|
374
|
-
}
|
|
375
|
-
return v;
|
|
376
|
-
}
|
|
377
|
-
/**
|
|
378
|
-
* Adds a required constraint:
|
|
379
|
-
* Also adds a weak constraint == if the operator is <= or >=
|
|
380
|
-
*/
|
|
381
|
-
require(left, op, right = void 0) {
|
|
382
|
-
this.constraint(left, op, right, Strength.required);
|
|
383
|
-
switch (op) {
|
|
384
|
-
case "<=":
|
|
385
|
-
case ">=":
|
|
386
|
-
this.constraint(left, "==", right, Strength.weak);
|
|
387
|
-
break;
|
|
388
|
-
case "<= 0":
|
|
389
|
-
case ">= 0":
|
|
390
|
-
this.constraint(left, "== 0", void 0, Strength.weak);
|
|
391
|
-
break;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Adds a constraint with medium strength by default
|
|
396
|
-
*/
|
|
397
|
-
constraint(left, op, right = void 0, strength = Strength.medium) {
|
|
398
|
-
let operator;
|
|
399
|
-
switch (op) {
|
|
400
|
-
case "==":
|
|
401
|
-
operator = Operator.Eq;
|
|
402
|
-
break;
|
|
403
|
-
case ">=":
|
|
404
|
-
operator = Operator.Ge;
|
|
405
|
-
break;
|
|
406
|
-
case "<=":
|
|
407
|
-
operator = Operator.Le;
|
|
408
|
-
break;
|
|
409
|
-
case "== 0":
|
|
410
|
-
operator = Operator.Eq;
|
|
411
|
-
right = 0;
|
|
412
|
-
break;
|
|
413
|
-
case ">= 0":
|
|
414
|
-
operator = Operator.Ge;
|
|
415
|
-
right = 0;
|
|
416
|
-
break;
|
|
417
|
-
case "<= 0":
|
|
418
|
-
operator = Operator.Le;
|
|
419
|
-
right = 0;
|
|
420
|
-
break;
|
|
421
|
-
default: nonexhaustive(op);
|
|
422
|
-
}
|
|
423
|
-
this.#solver.addConstraint(new Constraint(left, operator, right ?? 0, strength));
|
|
424
|
-
}
|
|
425
|
-
put(variable, strength = Strength.required) {
|
|
426
|
-
const eqStrength = strength === Strength.required ? Strength.medium : Strength.weak;
|
|
427
|
-
return {
|
|
428
|
-
before: (other, gap) => {
|
|
429
|
-
if (gap) other = other.minus(gap);
|
|
430
|
-
this.constraint(variable, "<=", other, strength);
|
|
431
|
-
this.constraint(variable, "==", other, eqStrength);
|
|
432
|
-
},
|
|
433
|
-
after: (other, gap) => {
|
|
434
|
-
if (gap) other = other.plus(gap);
|
|
435
|
-
this.constraint(variable, ">=", other, strength);
|
|
436
|
-
this.constraint(variable, "==", other, eqStrength);
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
//#endregion
|
|
443
|
-
//#region ../layouts/src/sequence/sequence-view.ts
|
|
444
|
-
function calcSequenceLayout(view) {
|
|
445
|
-
const actorNodes = /* @__PURE__ */ new Set();
|
|
446
|
-
const getNode = (id) => nonNullable(view.nodes.find((n) => n.id === id));
|
|
447
|
-
const preparedSteps = [];
|
|
448
|
-
for (const edge of view.edges.filter((e) => isStepEdgeId(e.id))) {
|
|
449
|
-
const source = getNode(edge.source);
|
|
450
|
-
const target = getNode(edge.target);
|
|
451
|
-
if (source.children.length || target.children.length) {
|
|
452
|
-
console.error("Sequence view does not support nested actors");
|
|
453
|
-
continue;
|
|
454
|
-
}
|
|
455
|
-
actorNodes.add(source);
|
|
456
|
-
actorNodes.add(target);
|
|
457
|
-
preparedSteps.push({
|
|
458
|
-
edge,
|
|
459
|
-
source,
|
|
460
|
-
target
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
const actors = view.nodes.filter((n) => actorNodes.has(n));
|
|
464
|
-
invariant(t$7(actors, 1), "actors array must not be empty");
|
|
465
|
-
const actorPorts = new DefaultMap(() => []);
|
|
466
|
-
const steps = [];
|
|
467
|
-
let row = 0;
|
|
468
|
-
for (const { edge, source, target } of preparedSteps) {
|
|
469
|
-
const prevStep = steps.at(-1);
|
|
470
|
-
let sourceColumn = actors.indexOf(source);
|
|
471
|
-
let targetColumn = actors.indexOf(target);
|
|
472
|
-
const isSelfLoop = source === target;
|
|
473
|
-
const isBack = sourceColumn > targetColumn;
|
|
474
|
-
const parallelPrefix = getParallelStepsPrefix(edge.id);
|
|
475
|
-
let isContinuing = false;
|
|
476
|
-
if (prevStep && prevStep.target == source && prevStep.parallelPrefix === parallelPrefix) isContinuing = prevStep.isSelfLoop !== isSelfLoop || prevStep.isBack === isBack;
|
|
477
|
-
if (!isContinuing) row++;
|
|
478
|
-
const step = {
|
|
479
|
-
id: edge.id,
|
|
480
|
-
from: {
|
|
481
|
-
column: sourceColumn,
|
|
482
|
-
row
|
|
483
|
-
},
|
|
484
|
-
to: {
|
|
485
|
-
column: targetColumn,
|
|
486
|
-
row: isSelfLoop ? ++row : row
|
|
487
|
-
},
|
|
488
|
-
edge,
|
|
489
|
-
isSelfLoop,
|
|
490
|
-
isBack,
|
|
491
|
-
parallelPrefix,
|
|
492
|
-
offset: isContinuing ? (prevStep?.offset ?? 0) + CONTINUOUS_OFFSET : 0,
|
|
493
|
-
source,
|
|
494
|
-
target,
|
|
495
|
-
label: edge.labelBBox ? {
|
|
496
|
-
height: edge.labelBBox.height + 8 + (edge.navigateTo ? 20 : 0),
|
|
497
|
-
width: edge.labelBBox.width + 16,
|
|
498
|
-
text: edge.label
|
|
499
|
-
} : null
|
|
500
|
-
};
|
|
501
|
-
steps.push(step);
|
|
502
|
-
actorPorts.get(source).push({
|
|
503
|
-
step,
|
|
504
|
-
row,
|
|
505
|
-
type: "source",
|
|
506
|
-
position: isBack && !isSelfLoop ? "left" : "right"
|
|
507
|
-
});
|
|
508
|
-
actorPorts.get(target).push({
|
|
509
|
-
step,
|
|
510
|
-
row,
|
|
511
|
-
type: "target",
|
|
512
|
-
position: isBack || isSelfLoop ? "right" : "left"
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
const layout = new SequenceViewLayouter({
|
|
516
|
-
actors,
|
|
517
|
-
steps,
|
|
518
|
-
compounds: buildCompounds(actors, view.nodes)
|
|
519
|
-
});
|
|
520
|
-
const bounds = layout.getViewBounds();
|
|
521
|
-
const compounds = t(layout.getCompoundBoxes(), t$5(({ node, ...box }) => ({
|
|
522
|
-
...box,
|
|
523
|
-
id: node.id,
|
|
524
|
-
origin: node.id
|
|
525
|
-
})), t$8("id"), t$2((boxes, id) => {
|
|
526
|
-
if (t$7(boxes, 2)) return t$5(boxes, (box, i) => ({
|
|
527
|
-
...box,
|
|
528
|
-
id: `${id}-${i + 1}`
|
|
529
|
-
}));
|
|
530
|
-
return boxes;
|
|
531
|
-
}), t$3(), n());
|
|
532
|
-
return {
|
|
533
|
-
actors: actors.map((actor) => toSeqActor({
|
|
534
|
-
actor,
|
|
535
|
-
ports: actorPorts.get(actor),
|
|
536
|
-
layout
|
|
537
|
-
})),
|
|
538
|
-
compounds,
|
|
539
|
-
steps: t$5(steps, (s) => ({
|
|
540
|
-
id: s.id,
|
|
541
|
-
sourceHandle: s.id + "_source",
|
|
542
|
-
targetHandle: s.id + "_target",
|
|
543
|
-
...s.label && { labelBBox: {
|
|
544
|
-
width: s.label.width,
|
|
545
|
-
height: s.label.height
|
|
546
|
-
} }
|
|
547
|
-
})),
|
|
548
|
-
parallelAreas: layout.getParallelBoxes(),
|
|
549
|
-
bounds
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
function toSeqActor({ actor, ports, layout }) {
|
|
553
|
-
const { x, y, width, height } = layout.getActorBox(actor);
|
|
554
|
-
return {
|
|
555
|
-
id: actor.id,
|
|
556
|
-
x,
|
|
557
|
-
y,
|
|
558
|
-
width,
|
|
559
|
-
height,
|
|
560
|
-
ports: ports.map((p) => {
|
|
561
|
-
const bbox = layout.getPortCenter(p.step, p.type);
|
|
562
|
-
return {
|
|
563
|
-
id: `${p.step.id}_${p.type}`,
|
|
564
|
-
cx: bbox.cx - x,
|
|
565
|
-
cy: bbox.cy - y,
|
|
566
|
-
height: bbox.height,
|
|
567
|
-
type: p.type,
|
|
568
|
-
position: p.position
|
|
569
|
-
};
|
|
570
|
-
})
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
//#endregion
|
|
575
|
-
export { calcSequenceLayout as t };
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { t as u } from "./libs/tinyrainbow.mjs";
|
|
2
|
-
import { a as mkTempPublicDir, t as viteConfig } from "./config-app.prod.mjs";
|
|
3
|
-
import { t as viteWebcomponentConfig } from "./config-webcomponent.prod.mjs";
|
|
4
|
-
import { copyFileSync, existsSync, readdirSync, rmSync } from "node:fs";
|
|
5
|
-
import { join, resolve } from "node:path";
|
|
6
|
-
import { mkdtemp } from "node:fs/promises";
|
|
7
|
-
import { tmpdir } from "node:os";
|
|
8
|
-
import { build } from "vite";
|
|
9
|
-
|
|
10
|
-
//#region src/vite/vite-build.ts
|
|
11
|
-
const Assets = ["favicon.ico", "robots.txt"];
|
|
12
|
-
async function viteBuild({ buildWebcomponent = true, webcomponentPrefix = "likec4", title, languageServices, likec4AssetsDir, outputSingleFile, ...cfg }) {
|
|
13
|
-
likec4AssetsDir ??= await mkdtemp(join(tmpdir(), ".likec4-assets-"));
|
|
14
|
-
const config = await viteConfig({
|
|
15
|
-
...cfg,
|
|
16
|
-
languageServices,
|
|
17
|
-
likec4AssetsDir,
|
|
18
|
-
webcomponentPrefix,
|
|
19
|
-
title,
|
|
20
|
-
outputSingleFile
|
|
21
|
-
});
|
|
22
|
-
const outDirWasEmpty = !existsSync(config.build.outDir) || readdirSync(config.build.outDir).length === 0;
|
|
23
|
-
const publicDir = await mkTempPublicDir();
|
|
24
|
-
for (const asset of Assets) {
|
|
25
|
-
const origin = resolve(config.root, asset);
|
|
26
|
-
if (existsSync(origin)) copyFileSync(origin, resolve(publicDir, asset));
|
|
27
|
-
}
|
|
28
|
-
const projects = languageServices.languageServices.projects();
|
|
29
|
-
if (projects.length === 1) {
|
|
30
|
-
const computed = await languageServices.viewsService.computedViews();
|
|
31
|
-
const diagrams = await languageServices.diagrams();
|
|
32
|
-
if (diagrams.length === 0) {
|
|
33
|
-
process.exitCode = 1;
|
|
34
|
-
throw new Error("no views found");
|
|
35
|
-
}
|
|
36
|
-
if (diagrams.length === computed.length) config.customLogger.info(`${u.dim("workspace:")} ${u.green(`✓ all views layouted`)}`);
|
|
37
|
-
else config.customLogger.warn(`${u.dim("workspace:")} ${u.yellow(`✗ layouted ${diagrams.length} of ${computed.length} views`)}`);
|
|
38
|
-
diagrams.forEach((view) => {
|
|
39
|
-
if (view.hasLayoutDrift || !!view.drifts && view.drifts.length > 0) config.customLogger.warn(u.dim("view") + " " + u.red(view.id) + " " + u.yellow(`is out of date, layout drift detected`));
|
|
40
|
-
});
|
|
41
|
-
} else for (const project of projects) {
|
|
42
|
-
const computed = await languageServices.viewsService.computedViews(project.id);
|
|
43
|
-
if (computed.length === 0) config.customLogger.warn(`${u.dim("project:")} ${project.id} ${u.yellow(`✗ no views found`)}`);
|
|
44
|
-
else config.customLogger.info(`${u.dim("project:")} ${project.id} ${u.green(`${computed.length} views`)}`);
|
|
45
|
-
}
|
|
46
|
-
if (buildWebcomponent && !outputSingleFile) await build(await viteWebcomponentConfig({
|
|
47
|
-
webcomponentPrefix,
|
|
48
|
-
languageServices,
|
|
49
|
-
outDir: publicDir,
|
|
50
|
-
base: config.base
|
|
51
|
-
}));
|
|
52
|
-
await build({
|
|
53
|
-
...config,
|
|
54
|
-
publicDir,
|
|
55
|
-
mode: "production"
|
|
56
|
-
});
|
|
57
|
-
if (outputSingleFile) {
|
|
58
|
-
if (!outDirWasEmpty) {
|
|
59
|
-
config.customLogger.warn(u.yellow("outDir was not empty, skipping cleanup"));
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
for (let extraFile of readdirSync(resolve(config.build.outDir)).filter((f) => f !== "index.html")) rmSync(resolve(config.build.outDir, extraFile), { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
const indexHtml = resolve(config.build.outDir, "index.html");
|
|
65
|
-
if (existsSync(indexHtml)) copyFileSync(indexHtml, resolve(config.build.outDir, "404.html"));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { viteBuild as n, Assets as t };
|