@cardenelabs/dragon 0.43.0 → 0.45.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 +21 -0
- package/dist/cli.cjs +6804 -5032
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +6804 -5032
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +7172 -5536
- package/dist/export.cjs.map +1 -1
- package/dist/export.d.cts +1 -1
- package/dist/export.d.ts +1 -1
- package/dist/export.js +7171 -5537
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +12244 -10449
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -3
- package/dist/index.d.ts +55 -3
- package/dist/index.js +12244 -10449
- package/dist/index.js.map +1 -1
- package/dist/{ink-B6s_SMXG.d.cts → ink-DeDtzaTL.d.cts} +27 -3
- package/dist/{ink-B6s_SMXG.d.ts → ink-DeDtzaTL.d.ts} +27 -3
- package/dist/light/chunk-6ZUKJ3VO.js +489 -0
- package/dist/light/chunk-6ZUKJ3VO.js.map +1 -0
- package/dist/light/chunk-CLS6JVKK.cjs +84 -0
- package/dist/light/chunk-CLS6JVKK.cjs.map +1 -0
- package/dist/light/chunk-JNSHZTPF.js +1141 -0
- package/dist/light/chunk-JNSHZTPF.js.map +1 -0
- package/dist/light/chunk-OUQ44P45.cjs +489 -0
- package/dist/light/chunk-OUQ44P45.cjs.map +1 -0
- package/dist/light/chunk-VRAW7VAQ.cjs +1141 -0
- package/dist/light/chunk-VRAW7VAQ.cjs.map +1 -0
- package/dist/light/chunk-YDKPEKGZ.js +84 -0
- package/dist/light/chunk-YDKPEKGZ.js.map +1 -0
- package/dist/light/git-C4RVNFT6.js +637 -0
- package/dist/light/git-C4RVNFT6.js.map +1 -0
- package/dist/light/git-I7D7RIW2.cjs +637 -0
- package/dist/light/git-I7D7RIW2.cjs.map +1 -0
- package/dist/light/index.cjs +9885 -0
- package/dist/light/index.cjs.map +1 -0
- package/dist/light/index.d.cts +976 -0
- package/dist/light/index.d.ts +976 -0
- package/dist/light/index.js +9885 -0
- package/dist/light/index.js.map +1 -0
- package/dist/light/lineup-FAIKTH3Y.cjs +283 -0
- package/dist/light/lineup-FAIKTH3Y.cjs.map +1 -0
- package/dist/light/lineup-YEG4HHEI.js +283 -0
- package/dist/light/lineup-YEG4HHEI.js.map +1 -0
- package/dist/light/state-P3LIVI3K.js +335 -0
- package/dist/light/state-P3LIVI3K.js.map +1 -0
- package/dist/light/state-ZZUK6AQT.cjs +335 -0
- package/dist/light/state-ZZUK6AQT.cjs.map +1 -0
- package/dist/light/time-64DJKYAL.cjs +719 -0
- package/dist/light/time-64DJKYAL.cjs.map +1 -0
- package/dist/light/time-B5WUQOFP.js +719 -0
- package/dist/light/time-B5WUQOFP.js.map +1 -0
- package/dist/light/tree-5HPREYW2.js +478 -0
- package/dist/light/tree-5HPREYW2.js.map +1 -0
- package/dist/light/tree-66EH4QVI.cjs +478 -0
- package/dist/light/tree-66EH4QVI.cjs.map +1 -0
- package/dist/node.cjs +1932 -680
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +1932 -680
- package/dist/node.js.map +1 -1
- package/dist/player.global.js +3 -3
- package/package.json +14 -2
- package/src/api.ts +71 -0
- package/src/field-messages.ts +6 -0
- package/src/figure-text.ts +4 -0
- package/src/index.ts +6 -65
- package/src/kinds/all.ts +16 -0
- package/src/kinds/git.ts +3 -0
- package/src/kinds/lineup.ts +3 -0
- package/src/kinds/registry.ts +46 -0
- package/src/kinds/state.ts +2 -0
- package/src/kinds/time.ts +3 -0
- package/src/kinds/tree.ts +3 -0
- package/src/layout/git.ts +0 -1
- package/src/layout/lineup.ts +218 -0
- package/src/layout/time.ts +0 -1
- package/src/layout/tree.ts +0 -1
- package/src/light.ts +31 -0
- package/src/look/values.ts +31 -2
- package/src/messages.ts +54 -0
- package/src/parser.ts +123 -1
- package/src/player-global.ts +3 -0
- package/src/player.ts +1 -1
- package/src/printer.ts +30 -1
- package/src/render/draw.ts +731 -0
- package/src/render/lineup.ts +184 -0
- package/src/render/parts.ts +19 -7
- package/src/render/svg.ts +4 -697
- package/src/render/time.ts +1 -4
- package/src/render/tree.ts +3 -2
- package/src/schema.ts +52 -4
- package/src/schemas/diagram.schema.json +145 -22
- package/src/schemas/validate-diagram.js +1 -1
- package/src/timeline.ts +14 -0
- package/src/view.ts +1 -1
- package/src/words.ts +15 -2
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
var _chunkCLS6JVKKcjs = require('./chunk-CLS6JVKK.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkOUQ44P45cjs = require('./chunk-OUQ44P45.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunkVRAW7VAQcjs = require('./chunk-VRAW7VAQ.cjs');
|
|
31
|
+
|
|
32
|
+
// src/layout/git.ts
|
|
33
|
+
function walk(diagram) {
|
|
34
|
+
const branches = (_nullishCoalesce(_optionalChain([diagram, 'access', _2 => _2.git, 'optionalAccess', _3 => _3.branches]), () => ( []))).map((b) => b.id);
|
|
35
|
+
const lane = (id) => {
|
|
36
|
+
if (!branches.includes(id)) branches.push(id);
|
|
37
|
+
};
|
|
38
|
+
for (const step of diagram.steps) for (const e of step.events) if (e.type === "commit" || e.type === "branch") lane(e.branch);
|
|
39
|
+
const tips = new Map(branches.map((b) => [b, null]));
|
|
40
|
+
let headAt = null;
|
|
41
|
+
let attached = null;
|
|
42
|
+
const made = [];
|
|
43
|
+
const byId = /* @__PURE__ */ new Map();
|
|
44
|
+
const links = [];
|
|
45
|
+
const moves = [];
|
|
46
|
+
const tags = [];
|
|
47
|
+
const rows = /* @__PURE__ */ new Map();
|
|
48
|
+
const most = /* @__PURE__ */ new Map();
|
|
49
|
+
const shown = /* @__PURE__ */ new Map();
|
|
50
|
+
const names = [...branches, _chunkCLS6JVKKcjs.HEAD];
|
|
51
|
+
const at = new Map(names.map((n) => [n, []]));
|
|
52
|
+
const heads = [];
|
|
53
|
+
const visible = (ref) => ref === _chunkCLS6JVKKcjs.HEAD ? attached === null ? headAt : null : _nullishCoalesce(tips.get(ref), () => ( null));
|
|
54
|
+
const freeRow = (commit2) => {
|
|
55
|
+
const list = _nullishCoalesce(rows.get(commit2), () => ( []));
|
|
56
|
+
const free = list.indexOf(null);
|
|
57
|
+
return free < 0 ? list.length : free;
|
|
58
|
+
};
|
|
59
|
+
const settle = (step, event, change, lineFor) => {
|
|
60
|
+
const before = new Map(names.map((n) => [n, visible(n)]));
|
|
61
|
+
const headBefore = headAt;
|
|
62
|
+
change();
|
|
63
|
+
const changed = names.filter((n) => before.get(n) !== visible(n));
|
|
64
|
+
const leaving = changed.map((ref) => {
|
|
65
|
+
const slot = shown.get(ref);
|
|
66
|
+
if (slot) {
|
|
67
|
+
rows.get(slot.commit)[slot.row] = null;
|
|
68
|
+
shown.delete(ref);
|
|
69
|
+
}
|
|
70
|
+
return { ref, slot };
|
|
71
|
+
});
|
|
72
|
+
for (const { ref, slot } of leaving) {
|
|
73
|
+
const from = _nullishCoalesce(slot, () => ( (ref === _chunkCLS6JVKKcjs.HEAD && headBefore !== null ? { commit: headBefore, row: freeRow(headBefore) } : void 0)));
|
|
74
|
+
const target = visible(ref);
|
|
75
|
+
let to;
|
|
76
|
+
if (target !== null) {
|
|
77
|
+
to = { commit: target, row: freeRow(target) };
|
|
78
|
+
const list = _nullishCoalesce(rows.get(target), () => ( []));
|
|
79
|
+
list[to.row] = ref;
|
|
80
|
+
rows.set(target, list);
|
|
81
|
+
most.set(target, Math.max(_nullishCoalesce(most.get(target), () => ( 0)), list.filter((r) => r !== null).length));
|
|
82
|
+
shown.set(ref, to);
|
|
83
|
+
}
|
|
84
|
+
moves.push({ ref, step, event, ...from ? { from } : {}, ...to ? { to } : {}, line: ref === lineFor });
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const prune = (step, event) => {
|
|
88
|
+
const reach = /* @__PURE__ */ new Set();
|
|
89
|
+
const stack = [...tips.values(), headAt].filter((c) => c !== null);
|
|
90
|
+
while (stack.length > 0) {
|
|
91
|
+
const id = stack.pop();
|
|
92
|
+
if (reach.has(id)) continue;
|
|
93
|
+
reach.add(id);
|
|
94
|
+
stack.push(..._nullishCoalesce(_optionalChain([byId, 'access', _4 => _4.get, 'call', _5 => _5(id), 'optionalAccess', _6 => _6.parents]), () => ( [])));
|
|
95
|
+
}
|
|
96
|
+
for (const c of made) if (!reach.has(c.id) && c.orphan === void 0) c.orphan = { step, event };
|
|
97
|
+
};
|
|
98
|
+
diagram.steps.forEach((step, s) => {
|
|
99
|
+
step.events.forEach((e, k) => {
|
|
100
|
+
if (e.type === "commit") commit(e, s, k);
|
|
101
|
+
else if (e.type === "branch") {
|
|
102
|
+
if (!byId.has(e.from)) return;
|
|
103
|
+
if (laneOf(e.from) !== e.branch) links.push({ kind: "branch", from: e.from, to: e.branch, step: s, event: k });
|
|
104
|
+
settle(s, k, () => {
|
|
105
|
+
tips.set(e.branch, e.from);
|
|
106
|
+
attached = e.branch;
|
|
107
|
+
headAt = e.from;
|
|
108
|
+
});
|
|
109
|
+
} else if (e.type === "edge") {
|
|
110
|
+
const ref = e.from;
|
|
111
|
+
if (ref !== _chunkCLS6JVKKcjs.HEAD && !tips.has(ref) || !byId.has(e.to)) return;
|
|
112
|
+
settle(
|
|
113
|
+
s,
|
|
114
|
+
k,
|
|
115
|
+
() => {
|
|
116
|
+
if (ref === _chunkCLS6JVKKcjs.HEAD) {
|
|
117
|
+
attached = null;
|
|
118
|
+
headAt = e.to;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
tips.set(ref, e.to);
|
|
122
|
+
if (attached === ref) headAt = e.to;
|
|
123
|
+
else if (attached === null && headAt === e.to) attached = ref;
|
|
124
|
+
},
|
|
125
|
+
ref
|
|
126
|
+
);
|
|
127
|
+
} else return;
|
|
128
|
+
prune(s, k);
|
|
129
|
+
});
|
|
130
|
+
for (const n of names) _optionalChain([at, 'access', _7 => _7.get, 'call', _8 => _8(n), 'optionalAccess', _9 => _9.push, 'call', _10 => _10(n === _chunkCLS6JVKKcjs.HEAD ? headAt : _nullishCoalesce(tips.get(n), () => ( null)))]);
|
|
131
|
+
heads.push(attached);
|
|
132
|
+
for (const n of names) {
|
|
133
|
+
const slot = shown.get(n);
|
|
134
|
+
if (slot) tags.push({ ref: n, step: s, slot });
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
function laneOf(id) {
|
|
138
|
+
return _optionalChain([byId, 'access', _11 => _11.get, 'call', _12 => _12(id), 'optionalAccess', _13 => _13.branch]);
|
|
139
|
+
}
|
|
140
|
+
function commit(e, s, k) {
|
|
141
|
+
if (byId.has(e.id)) return;
|
|
142
|
+
const copy = e.copy !== void 0 && byId.has(e.copy) ? e.copy : void 0;
|
|
143
|
+
const base = copy !== void 0 && attached === null && headAt !== null ? headAt : _nullishCoalesce(tips.get(e.branch), () => ( null));
|
|
144
|
+
const joined = e.merge !== void 0 && e.merge !== e.branch ? _nullishCoalesce(tips.get(e.merge), () => ( void 0)) : void 0;
|
|
145
|
+
const parents = [...new Set([base, joined].filter((c2) => c2 !== null && c2 !== void 0))];
|
|
146
|
+
const c = {
|
|
147
|
+
id: e.id,
|
|
148
|
+
branch: e.branch,
|
|
149
|
+
parents,
|
|
150
|
+
...joined !== void 0 && joined !== base ? { joined } : {},
|
|
151
|
+
...copy !== void 0 ? { copy } : {},
|
|
152
|
+
...e.hash !== void 0 ? { hash: e.hash } : {},
|
|
153
|
+
...e.note !== void 0 ? { note: e.note } : {},
|
|
154
|
+
step: s,
|
|
155
|
+
event: k
|
|
156
|
+
};
|
|
157
|
+
made.push(c);
|
|
158
|
+
byId.set(c.id, c);
|
|
159
|
+
for (const p of parents) links.push({ kind: "parent", from: p, to: c.id, step: s, event: k });
|
|
160
|
+
if (copy !== void 0) links.push({ kind: "copy", from: copy, to: c.id, step: s, event: k });
|
|
161
|
+
const first = attached === null && headAt === null;
|
|
162
|
+
settle(s, k, () => {
|
|
163
|
+
if (copy === void 0) {
|
|
164
|
+
tips.set(e.branch, c.id);
|
|
165
|
+
if (attached === e.branch) headAt = c.id;
|
|
166
|
+
} else if (attached === null) headAt = c.id;
|
|
167
|
+
if (first) {
|
|
168
|
+
attached = e.branch;
|
|
169
|
+
headAt = c.id;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const refs = names.map((name) => ({ name, at: _nullishCoalesce(at.get(name), () => ( [])), ...name === _chunkCLS6JVKKcjs.HEAD ? { attached: heads } : {} }));
|
|
174
|
+
return { branches, made, links, moves, refs, tags, rows: most };
|
|
175
|
+
}
|
|
176
|
+
function cubic(p0, c1, c2, p3) {
|
|
177
|
+
const n = _chunkVRAW7VAQcjs.LOOK.git.samples;
|
|
178
|
+
return Array.from({ length: n }, (_, k) => {
|
|
179
|
+
const t = (k + 1) / n;
|
|
180
|
+
const u = 1 - t;
|
|
181
|
+
const at = (i) => u * u * u * p0[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * p3[i];
|
|
182
|
+
return [at(0), at(1)];
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function elbow(from, to) {
|
|
186
|
+
if (Math.abs(from[1] - to[1]) < 0.5) return [from, to];
|
|
187
|
+
return from[1] > to[1] ? [from, [from[0], to[1]], to] : [from, [to[0], from[1]], to];
|
|
188
|
+
}
|
|
189
|
+
function fork(p, tx, ty) {
|
|
190
|
+
const sign = ty > p.cy ? 1 : -1;
|
|
191
|
+
const p0 = [p.cx, p.cy + sign * p.r];
|
|
192
|
+
const turn = Math.max(0, Math.min(_chunkVRAW7VAQcjs.LOOK.git.turn, tx - p.cx));
|
|
193
|
+
const p3 = [p.cx + turn, ty];
|
|
194
|
+
const curve = cubic(p0, [p0[0], p0[1] + (ty - p0[1]) * 0.7], [p.cx + turn * 0.2, ty], p3);
|
|
195
|
+
return [p0, ...curve, ...tx > p3[0] ? [[tx, ty]] : []];
|
|
196
|
+
}
|
|
197
|
+
function join(p, c) {
|
|
198
|
+
const sign = c.cy < p.cy ? 1 : -1;
|
|
199
|
+
const p0 = [p.cx + p.r, p.cy];
|
|
200
|
+
const p3 = [c.cx, c.cy + sign * c.r];
|
|
201
|
+
const turn = Math.max(0, Math.min(_chunkVRAW7VAQcjs.LOOK.git.turn, c.cx - p0[0]));
|
|
202
|
+
const h = [c.cx - turn, p.cy];
|
|
203
|
+
const curve = cubic(h, [c.cx - turn * 0.2, p.cy], [c.cx, p3[1] + (p.cy - p3[1]) * 0.7], p3);
|
|
204
|
+
return [p0, ...h[0] > p0[0] ? [h] : [], ...curve];
|
|
205
|
+
}
|
|
206
|
+
function copyLine(p, c) {
|
|
207
|
+
if (Math.abs(p.cy - c.cy) < 0.5) {
|
|
208
|
+
const top = p.cy - p.r;
|
|
209
|
+
const lift = _chunkVRAW7VAQcjs.LOOK.git.turn * 0.7;
|
|
210
|
+
return [[p.cx, top], ...cubic([p.cx, top], [p.cx, top - lift], [c.cx, top - lift], [c.cx, top])];
|
|
211
|
+
}
|
|
212
|
+
const sign = c.cy < p.cy ? -1 : 1;
|
|
213
|
+
const p0 = [p.cx, p.cy + sign * p.r];
|
|
214
|
+
const p3 = [c.cx, c.cy - sign * c.r];
|
|
215
|
+
const mid = (p3[1] - p0[1]) * 0.5;
|
|
216
|
+
return [p0, ...cubic(p0, [p0[0], p0[1] + mid], [p3[0], p3[1] - mid], p3)];
|
|
217
|
+
}
|
|
218
|
+
function layoutGit(diagram) {
|
|
219
|
+
const { margin, gap, box: B, region: R, git: G, carrier: C } = _chunkVRAW7VAQcjs.LOOK;
|
|
220
|
+
const walked = walk(diagram);
|
|
221
|
+
const notes = new Map((_nullishCoalesce(_optionalChain([diagram, 'access', _14 => _14.git, 'optionalAccess', _15 => _15.branches]), () => ( []))).map((b) => [b.id, b.note]));
|
|
222
|
+
const laneIndex = new Map(walked.branches.map((id, i) => [id, i]));
|
|
223
|
+
const colorOf = (branch) => G.colors[(_nullishCoalesce(laneIndex.get(branch), () => ( 0))) % G.colors.length];
|
|
224
|
+
const col = /* @__PURE__ */ new Map();
|
|
225
|
+
const laneLast = /* @__PURE__ */ new Map();
|
|
226
|
+
for (const c of walked.made) {
|
|
227
|
+
const k = Math.max(0, ...c.parents.map((p) => (_nullishCoalesce(col.get(p), () => ( -1))) + 1), (_nullishCoalesce(laneLast.get(c.branch), () => ( -1))) + 1);
|
|
228
|
+
col.set(c.id, k);
|
|
229
|
+
laneLast.set(c.branch, k);
|
|
230
|
+
}
|
|
231
|
+
const linesOf = (c) => [
|
|
232
|
+
...c.hash !== void 0 ? [{ text: c.hash, style: _chunkVRAW7VAQcjs.TYPE.gitHash }] : [],
|
|
233
|
+
...c.note !== void 0 ? [{ text: c.note, style: _chunkVRAW7VAQcjs.TYPE.gitNote }] : []
|
|
234
|
+
];
|
|
235
|
+
const textW = (c) => Math.max(0, ...linesOf(c).map((line) => _chunkVRAW7VAQcjs.textWidth.call(void 0, line.text, line.style)));
|
|
236
|
+
const tagW = (ref) => _chunkVRAW7VAQcjs.textWidth.call(void 0, ref, _chunkVRAW7VAQcjs.hasWide.call(void 0, ref) ? _chunkVRAW7VAQcjs.TYPE.carrierJa : _chunkVRAW7VAQcjs.TYPE.carrier) + C.tagPadX * 2;
|
|
237
|
+
const refWidth = Math.max(0, ...walked.refs.map((r) => tagW(r.name)));
|
|
238
|
+
const pitch = Math.max(G.pitch, ...walked.made.map((c) => textW(c) + G.textGap), refWidth + G.textGap);
|
|
239
|
+
const headers = walked.branches.map((id) => ({ w: Math.max(R.icon, _chunkVRAW7VAQcjs.textWidth.call(void 0, id, _chunkVRAW7VAQcjs.TYPE.regionName), _chunkVRAW7VAQcjs.textWidth.call(void 0, _nullishCoalesce(notes.get(id), () => ( "")), _chunkVRAW7VAQcjs.TYPE.regionNote)) }));
|
|
240
|
+
const headerRight = margin + R.inset + Math.max(0, ...headers.map((h) => h.w));
|
|
241
|
+
const firstHalf = Math.max(G.r, ...walked.made.filter((c) => col.get(c.id) === 0 && laneIndex.get(c.branch) === 0).map((c) => textW(c) / 2), refWidth / 2);
|
|
242
|
+
const x0 = Math.max(G.x0, headerRight + gap + firstHalf);
|
|
243
|
+
const named = new Set(
|
|
244
|
+
walked.moves.flatMap((mv) => {
|
|
245
|
+
const source = _optionalChain([diagram, 'access', _16 => _16.steps, 'access', _17 => _17[mv.step], 'optionalAccess', _18 => _18.events, 'access', _19 => _19[mv.event]]);
|
|
246
|
+
return mv.line && mv.to && _optionalChain([source, 'optionalAccess', _20 => _20.type]) === "edge" && source.label !== void 0 ? [_nullishCoalesce(_optionalChain([walked, 'access', _21 => _21.made, 'access', _22 => _22.find, 'call', _23 => _23((c) => c.id === _optionalChain([mv, 'access', _24 => _24.to, 'optionalAccess', _25 => _25.commit])), 'optionalAccess', _26 => _26.branch]), () => ( ""))] : [];
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
const extraRows = (branch) => Math.max(0, ...walked.made.filter((c) => c.branch === branch).map((c) => (_nullishCoalesce(walked.rows.get(c.id), () => ( 0))) - 2)) * G.row;
|
|
250
|
+
const topText = walked.made.some((c) => laneIndex.get(c.branch) === 0 && linesOf(c).length > 0);
|
|
251
|
+
const lanes = [];
|
|
252
|
+
let y = margin;
|
|
253
|
+
walked.branches.forEach((id, i) => {
|
|
254
|
+
const top = i === 0;
|
|
255
|
+
const tagBase = top && topText ? G.tagTop : G.tag;
|
|
256
|
+
const line = y + (top ? G.topLine - (G.tagTop - tagBase) : G.line) + extraRows(id);
|
|
257
|
+
const h = line - y + (top ? G.topBelow : named.has(id) ? G.below : G.bare);
|
|
258
|
+
lanes.push({ id, x: margin, y, w: 0, h, line, color: colorOf(id), tagBase });
|
|
259
|
+
y += h + R.gap;
|
|
260
|
+
});
|
|
261
|
+
const lanesBottom = y - R.gap;
|
|
262
|
+
const laneOf = new Map(lanes.map((l) => [l.id, l]));
|
|
263
|
+
const commits = walked.made.map((c) => {
|
|
264
|
+
const lane = laneOf.get(c.branch);
|
|
265
|
+
const isTop = laneIndex.get(c.branch) === 0;
|
|
266
|
+
const cx = x0 + pitch * (_nullishCoalesce(col.get(c.id), () => ( 0))) + (isTop ? 0 : pitch / 2);
|
|
267
|
+
const cy = lane.line;
|
|
268
|
+
const lines = linesOf(c);
|
|
269
|
+
const baselines = lines.map((_, k) => isTop ? cy - G.above - (lines.length - 1 - k) * G.lineStep : cy + G.under + k * G.lineStep);
|
|
270
|
+
const boxes2 = lines.map((line, k) => _chunkVRAW7VAQcjs.textBox.call(void 0, line.text, cx, baselines[k], line.style, "middle"));
|
|
271
|
+
const text = boxes2.length === 0 ? void 0 : { ...union(boxes2), lines: lines.map((line) => line.text), baselines };
|
|
272
|
+
const color = c.copy !== void 0 ? colorOf(_nullishCoalesce(_optionalChain([walked, 'access', _27 => _27.made, 'access', _28 => _28.find, 'call', _29 => _29((m) => m.id === c.copy), 'optionalAccess', _30 => _30.branch]), () => ( c.branch))) : colorOf(c.branch);
|
|
273
|
+
return {
|
|
274
|
+
id: c.id,
|
|
275
|
+
branch: c.branch,
|
|
276
|
+
color,
|
|
277
|
+
cx,
|
|
278
|
+
cy,
|
|
279
|
+
r: G.r,
|
|
280
|
+
step: c.step,
|
|
281
|
+
event: c.event,
|
|
282
|
+
parents: c.parents,
|
|
283
|
+
...c.copy !== void 0 ? { copy: c.copy } : {},
|
|
284
|
+
...c.hash !== void 0 ? { hash: c.hash } : {},
|
|
285
|
+
...c.note !== void 0 ? { note: c.note } : {},
|
|
286
|
+
...text ? { text } : {},
|
|
287
|
+
...c.orphan ? { orphan: c.orphan.step, orphanEvent: c.orphan.event } : {}
|
|
288
|
+
};
|
|
289
|
+
});
|
|
290
|
+
const placed = new Map(commits.map((c) => [c.id, c]));
|
|
291
|
+
const links = walked.links.flatMap((l) => {
|
|
292
|
+
const from = placed.get(l.from);
|
|
293
|
+
if (!from) return [];
|
|
294
|
+
if (l.kind === "branch") {
|
|
295
|
+
if (!walked.made.some((c) => c.branch === l.to)) return [];
|
|
296
|
+
const lane = laneOf.get(l.to);
|
|
297
|
+
return [{ ...l, points: fork(from, from.cx + G.turn, lane.line), color: colorOf(l.to) }];
|
|
298
|
+
}
|
|
299
|
+
const to = placed.get(l.to);
|
|
300
|
+
const made = walked.made.find((m) => m.id === l.to);
|
|
301
|
+
let points;
|
|
302
|
+
if (l.kind === "copy") points = copyLine(from, to);
|
|
303
|
+
else if (Math.abs(from.cy - to.cy) < 0.5) points = [[from.cx + from.r, from.cy], [to.cx - to.r, to.cy]];
|
|
304
|
+
else if (_optionalChain([made, 'optionalAccess', _31 => _31.joined]) === l.from) points = join(from, to);
|
|
305
|
+
else points = fork(from, to.cx - to.r, to.cy);
|
|
306
|
+
return [{ ...l, points, color: to.color }];
|
|
307
|
+
});
|
|
308
|
+
const tagRect = (ref, slot) => {
|
|
309
|
+
const c = placed.get(slot.commit);
|
|
310
|
+
const base = _nullishCoalesce(_optionalChain([laneOf, 'access', _32 => _32.get, 'call', _33 => _33(c.branch), 'optionalAccess', _34 => _34.tagBase]), () => ( G.tag));
|
|
311
|
+
const w = tagW(ref);
|
|
312
|
+
return { x: c.cx - w / 2, y: c.cy - base - slot.row * G.row - C.tagH / 2, w, h: C.tagH };
|
|
313
|
+
};
|
|
314
|
+
const center2 = (r) => [r.x + r.w / 2, r.y + r.h / 2];
|
|
315
|
+
const moves = walked.moves.map((m) => {
|
|
316
|
+
const from = m.from ? tagRect(m.ref, m.from) : void 0;
|
|
317
|
+
const to = m.to ? tagRect(m.ref, m.to) : void 0;
|
|
318
|
+
const source = _optionalChain([diagram, 'access', _35 => _35.steps, 'access', _36 => _36[m.step], 'optionalAccess', _37 => _37.events, 'access', _38 => _38[m.event]]);
|
|
319
|
+
const carried = m.line && _optionalChain([source, 'optionalAccess', _39 => _39.type]) === "edge" && source.carry.kind !== "none" && !(source.carry.kind === "tag" && source.carry.text === source.from);
|
|
320
|
+
return {
|
|
321
|
+
ref: m.ref,
|
|
322
|
+
step: m.step,
|
|
323
|
+
event: m.event,
|
|
324
|
+
...from ? { from } : {},
|
|
325
|
+
...to ? { to } : {},
|
|
326
|
+
...m.to ? { target: m.to.commit } : {},
|
|
327
|
+
...carried ? { carried: true } : {},
|
|
328
|
+
...m.line && from && to ? { line: elbow(center2(from), center2(to)) } : {},
|
|
329
|
+
color: "slate"
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
const tags = walked.tags.map((t) => ({ ...tagRect(t.ref, t.slot), ref: t.ref, step: t.step }));
|
|
333
|
+
const colors = _chunkVRAW7VAQcjs.boxColors.call(void 0, diagram);
|
|
334
|
+
const right = Math.max(
|
|
335
|
+
x0,
|
|
336
|
+
...commits.flatMap((c) => [c.cx + c.r, ...c.text ? [c.text.x + c.text.w] : []]),
|
|
337
|
+
...tags.map((t) => t.x + t.w),
|
|
338
|
+
...moves.flatMap((m) => [m.from, m.to].flatMap((r) => r ? [r.x + r.w] : []))
|
|
339
|
+
);
|
|
340
|
+
const boxX = right + G.boxGap;
|
|
341
|
+
const firstCy = _nullishCoalesce(_optionalChain([(_nullishCoalesce(lanes[1], () => ( lanes[0]))), 'optionalAccess', _40 => _40.line]), () => ( margin + B.h / 2));
|
|
342
|
+
const boxes = diagram.boxes.map((b, i) => {
|
|
343
|
+
const w = _chunkVRAW7VAQcjs.boxWidth.call(void 0, diagram, b.id, true);
|
|
344
|
+
const cy = firstCy + i * (B.h + gap);
|
|
345
|
+
return {
|
|
346
|
+
id: b.id,
|
|
347
|
+
name: b.name,
|
|
348
|
+
...b.sub !== void 0 ? { sub: b.sub } : {},
|
|
349
|
+
...b.icon !== void 0 ? { icon: b.icon } : {},
|
|
350
|
+
color: _nullishCoalesce(colors.get(b.id), () => ( "slate")),
|
|
351
|
+
x: boxX,
|
|
352
|
+
y: cy - B.h / 2,
|
|
353
|
+
w,
|
|
354
|
+
h: B.h,
|
|
355
|
+
cx: boxX + w / 2,
|
|
356
|
+
cy
|
|
357
|
+
};
|
|
358
|
+
});
|
|
359
|
+
const regions = lanes.map((lane, i) => {
|
|
360
|
+
const note = notes.get(lane.id);
|
|
361
|
+
return {
|
|
362
|
+
id: lane.id,
|
|
363
|
+
lines: [lane.id],
|
|
364
|
+
...note !== void 0 ? { note } : {},
|
|
365
|
+
icon: "branch",
|
|
366
|
+
color: lane.color,
|
|
367
|
+
x: lane.x,
|
|
368
|
+
y: lane.y,
|
|
369
|
+
w: 0,
|
|
370
|
+
h: lane.h,
|
|
371
|
+
header: { x: lane.x + R.inset, y: lane.y + R.inset, w: _nullishCoalesce(_optionalChain([headers, 'access', _41 => _41[i], 'optionalAccess', _42 => _42.w]), () => ( 0)), h: R.nameY - R.inset + (note !== void 0 ? R.line : 0) + gap / 2 }
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
const layout = {
|
|
375
|
+
kind: "git",
|
|
376
|
+
width: 0,
|
|
377
|
+
height: 0,
|
|
378
|
+
regions,
|
|
379
|
+
boxes,
|
|
380
|
+
lifelines: [],
|
|
381
|
+
edges: [],
|
|
382
|
+
labels: [],
|
|
383
|
+
actions: [],
|
|
384
|
+
badges: [],
|
|
385
|
+
paths: [],
|
|
386
|
+
ends: [],
|
|
387
|
+
lanes,
|
|
388
|
+
commits,
|
|
389
|
+
links,
|
|
390
|
+
tags,
|
|
391
|
+
refs: walked.refs,
|
|
392
|
+
moves
|
|
393
|
+
};
|
|
394
|
+
layout.badges = badgesOf(diagram, layout);
|
|
395
|
+
layout.labels = labelsOf(diagram, layout);
|
|
396
|
+
const contentRight = Math.max(right, ...boxes.map((b) => b.x + b.w), ...layout.labels.map((l) => l.x + l.w)) + R.pad;
|
|
397
|
+
const width = Math.max(contentRight + margin, _chunkVRAW7VAQcjs.stripNeed.call(void 0, diagram) + margin * 2);
|
|
398
|
+
for (const region of regions) region.w = width - margin * 2;
|
|
399
|
+
for (const lane of lanes) lane.w = width - margin * 2;
|
|
400
|
+
const bottom = Math.max(lanesBottom, ...boxes.map((b) => b.y + b.h), ...layout.labels.map((l) => l.y + l.h));
|
|
401
|
+
const strip = _chunkVRAW7VAQcjs.layoutStrip.call(void 0, diagram, margin, bottom + gap, width - margin * 2);
|
|
402
|
+
layout.width = width;
|
|
403
|
+
layout.height = (strip ? strip.y + strip.h : bottom) + margin;
|
|
404
|
+
if (strip) layout.strip = strip;
|
|
405
|
+
layout.badges = badgesOf(diagram, layout);
|
|
406
|
+
return layout;
|
|
407
|
+
}
|
|
408
|
+
function union(rects) {
|
|
409
|
+
const x = Math.min(...rects.map((r) => r.x));
|
|
410
|
+
const y = Math.min(...rects.map((r) => r.y));
|
|
411
|
+
return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
|
|
412
|
+
}
|
|
413
|
+
function firstMark(layout, step) {
|
|
414
|
+
const marks = [
|
|
415
|
+
...layout.links.filter((l) => l.step === step && l.kind !== "copy").map((l) => ({ event: l.event, points: l.points, color: l.color })),
|
|
416
|
+
...layout.moves.flatMap((m) => {
|
|
417
|
+
const target = layout.commits.find((c) => c.id === m.target);
|
|
418
|
+
return m.step === step && m.line && target ? [{ event: m.event, target, color: target.color }] : [];
|
|
419
|
+
})
|
|
420
|
+
].sort((a, b) => a.event - b.event);
|
|
421
|
+
return marks[0];
|
|
422
|
+
}
|
|
423
|
+
function besideCommit(c, taken, avoid) {
|
|
424
|
+
const { r, inset } = _chunkVRAW7VAQcjs.LOOK.badge;
|
|
425
|
+
const d = c.r + inset + r;
|
|
426
|
+
const apart = r * 2 + inset;
|
|
427
|
+
const spots = [
|
|
428
|
+
[c.cx + d, c.cy],
|
|
429
|
+
[c.cx, c.cy + d],
|
|
430
|
+
[c.cx - d, c.cy],
|
|
431
|
+
[c.cx, c.cy - d]
|
|
432
|
+
];
|
|
433
|
+
return spots.find((p) => taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => _chunkVRAW7VAQcjs.gapBetween.call(void 0, _chunkVRAW7VAQcjs.badgeRect.call(void 0, p), a) >= _chunkVRAW7VAQcjs.LOOK.label.touch));
|
|
434
|
+
}
|
|
435
|
+
function clearOnPath(points, taken, avoid) {
|
|
436
|
+
const { r, inset, along: start, short } = _chunkVRAW7VAQcjs.LOOK.badge;
|
|
437
|
+
const length = _chunkVRAW7VAQcjs.pathLength.call(void 0, points);
|
|
438
|
+
const first = length < short ? Math.min(r + 1, length / 2) : start;
|
|
439
|
+
const apart = r * 2 + inset;
|
|
440
|
+
for (let d = first; d <= length; d += 1) {
|
|
441
|
+
const p = _chunkVRAW7VAQcjs.along.call(void 0, points, d);
|
|
442
|
+
const rect = _chunkVRAW7VAQcjs.badgeRect.call(void 0, p);
|
|
443
|
+
if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => _chunkVRAW7VAQcjs.gapBetween.call(void 0, rect, a) >= _chunkVRAW7VAQcjs.LOOK.label.touch)) return p;
|
|
444
|
+
}
|
|
445
|
+
return void 0;
|
|
446
|
+
}
|
|
447
|
+
function badgesOf(diagram, layout) {
|
|
448
|
+
const { inset } = _chunkVRAW7VAQcjs.LOOK.badge;
|
|
449
|
+
const taken = [];
|
|
450
|
+
const all = [...layout.links.map((l) => l.points), ...layout.moves.flatMap((m) => m.line ? [m.line] : [])];
|
|
451
|
+
const out = [];
|
|
452
|
+
const avoid = [
|
|
453
|
+
...layout.tags,
|
|
454
|
+
...layout.commits.flatMap((c) => [{ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }, ...c.text ? [c.text] : []])
|
|
455
|
+
];
|
|
456
|
+
diagram.steps.forEach((step, s) => {
|
|
457
|
+
const mark = firstMark(layout, s);
|
|
458
|
+
const near = _optionalChain([mark, 'optionalAccess', _43 => _43.target]) ? besideCommit(mark.target, taken, avoid) : void 0;
|
|
459
|
+
if (mark && (mark.points || near)) {
|
|
460
|
+
const points = mark.points;
|
|
461
|
+
const point = _nullishCoalesce(near, () => ( (points ? _nullishCoalesce(clearOnPath(points, taken, avoid), () => ( _chunkVRAW7VAQcjs.badgeOnPath.call(void 0, points, taken, all.filter((p) => p !== points)))) : [0, 0])));
|
|
462
|
+
taken.push(point);
|
|
463
|
+
out.push({ step: s, x: point[0], y: point[1], color: mark.color });
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const box = step.events.flatMap((e) => e.type === "swap" || e.type === "action" ? [e.box] : []).map((id) => layout.boxes.find((b) => b.id === id))[0];
|
|
467
|
+
if (box) {
|
|
468
|
+
out.push({ step: s, x: box.x, y: box.y, color: box.color });
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
if (layout.strip && step.events.some((e) => e.type === "strip")) {
|
|
472
|
+
out.push({ step: s, x: layout.strip.x + inset, y: layout.strip.y + inset, color: "slate" });
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const tip = layout.commits.find((c) => c.id === _optionalChain([layout, 'access', _44 => _44.refs, 'access', _45 => _45[0], 'optionalAccess', _46 => _46.at, 'access', _47 => _47[s]]));
|
|
476
|
+
const spot = tip ? besideCommit(tip, taken, avoid) : void 0;
|
|
477
|
+
if (tip && spot) {
|
|
478
|
+
taken.push(spot);
|
|
479
|
+
out.push({ step: s, x: spot[0], y: spot[1], color: tip.color });
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const before = out[out.length - 1];
|
|
483
|
+
const lane = layout.lanes[0];
|
|
484
|
+
out.push(before ? { ...before, step: s } : { step: s, x: (_nullishCoalesce(_optionalChain([lane, 'optionalAccess', _48 => _48.x]), () => ( 0))) + (_nullishCoalesce(_optionalChain([lane, 'optionalAccess', _49 => _49.w]), () => ( 0))) - inset - _chunkVRAW7VAQcjs.LOOK.badge.r, y: (_nullishCoalesce(_optionalChain([lane, 'optionalAccess', _50 => _50.y]), () => ( 0))) + inset + _chunkVRAW7VAQcjs.LOOK.badge.r, color: _nullishCoalesce(_optionalChain([lane, 'optionalAccess', _51 => _51.color]), () => ( "slate")) });
|
|
485
|
+
});
|
|
486
|
+
return _chunkVRAW7VAQcjs.replaceSameSpot.call(void 0, out);
|
|
487
|
+
}
|
|
488
|
+
function labelsOf(diagram, layout) {
|
|
489
|
+
const G = _chunkVRAW7VAQcjs.LOOK.git;
|
|
490
|
+
const labels = [];
|
|
491
|
+
const circles = layout.commits.map((c) => ({ x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 }));
|
|
492
|
+
const texts = layout.commits.flatMap((c) => c.text ? [c.text] : []);
|
|
493
|
+
const headers = layout.regions.map((r) => r.header);
|
|
494
|
+
for (const move of layout.moves) {
|
|
495
|
+
const source = _optionalChain([diagram, 'access', _52 => _52.steps, 'access', _53 => _53[move.step], 'optionalAccess', _54 => _54.events, 'access', _55 => _55[move.event]]);
|
|
496
|
+
if (_optionalChain([source, 'optionalAccess', _56 => _56.type]) !== "edge" || source.label === void 0 || !move.line) continue;
|
|
497
|
+
const target = layout.commits.find((c) => c.id === source.to);
|
|
498
|
+
if (!target) continue;
|
|
499
|
+
const top = _optionalChain([layout, 'access', _57 => _57.lanes, 'access', _58 => _58[0], 'optionalAccess', _59 => _59.id]) === target.branch;
|
|
500
|
+
const w = _chunkVRAW7VAQcjs.textWidth.call(void 0, source.label, _chunkVRAW7VAQcjs.hasWide.call(void 0, source.label) ? _chunkVRAW7VAQcjs.TYPE.labelJa : _chunkVRAW7VAQcjs.TYPE.label) + _chunkVRAW7VAQcjs.LOOK.label.padX * 2;
|
|
501
|
+
const [mx] = move.line.reduce((sum, p) => [sum[0] + p[0] / move.line.length, 0], [0, 0]);
|
|
502
|
+
const rows = Math.max(0, ...layout.tags.filter((t) => t.step === move.step && Math.abs(t.x + t.w / 2 - target.cx) < 0.5).map((t) => target.cy - t.y));
|
|
503
|
+
const side = _nullishCoalesce(source.labelSide, () => ( (top ? "above" : "below")));
|
|
504
|
+
const base = source.labelSide !== void 0 ? void 0 : top ? { x: mx - w / 2, y: target.cy - Math.max(rows, (_nullishCoalesce(_optionalChain([layout, 'access', _60 => _60.lanes, 'access', _61 => _61[0], 'optionalAccess', _62 => _62.tagBase]), () => ( G.tag))) + _chunkVRAW7VAQcjs.LOOK.carrier.tagH / 2) - _chunkVRAW7VAQcjs.LOOK.label.soft - _chunkVRAW7VAQcjs.LOOK.label.h } : { x: mx - w / 2, y: target.cy + G.labelUnder };
|
|
505
|
+
const seen = layout.badges.filter((b) => b.step <= move.step).map((b) => _chunkVRAW7VAQcjs.badgeRect.call(void 0, [b.x, b.y]));
|
|
506
|
+
const tags = layout.tags.filter((t) => t.step === move.step);
|
|
507
|
+
labels.push(
|
|
508
|
+
_chunkVRAW7VAQcjs.placeLabel.call(void 0,
|
|
509
|
+
{ step: move.step, event: move.event, text: source.label, points: move.line, color: move.color, side, ...base ? { base } : {} },
|
|
510
|
+
{ hard: [...circles, ...layout.boxes], soft: [...texts, ...tags, ...headers, ...labels.filter((l) => l.step === move.step)], touch: seen }
|
|
511
|
+
)
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
return labels;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/render/git.ts
|
|
518
|
+
var r1 = (v) => Math.round(v * 100) / 100;
|
|
519
|
+
var center = (r) => [r.x + r.w / 2, r.y + r.h / 2];
|
|
520
|
+
function tagShape(text, sh) {
|
|
521
|
+
const C = _chunkVRAW7VAQcjs.LOOK.carrier;
|
|
522
|
+
const ja = _chunkVRAW7VAQcjs.hasWide.call(void 0, text);
|
|
523
|
+
const w = _chunkVRAW7VAQcjs.textWidth.call(void 0, text, ja ? _chunkVRAW7VAQcjs.TYPE.carrierJa : _chunkVRAW7VAQcjs.TYPE.carrier) + C.tagPadX * 2;
|
|
524
|
+
return `<rect class="dg-car" x="${r1(-w / 2)}" y="${-C.tagH / 2}" width="${r1(w)}" height="${C.tagH}" rx="${C.tagH / 2}" ${sh}/><text class="dg-car-t${ja ? " dg-car-tj" : ""}" y="${_chunkVRAW7VAQcjs.LOOK.baseline.carrier}" text-anchor="middle">${_chunkOUQ44P45cjs.esc.call(void 0, text)}</text>`;
|
|
525
|
+
}
|
|
526
|
+
function drawGit(layout, diagram, timeline, ctx) {
|
|
527
|
+
const { m } = ctx;
|
|
528
|
+
const G = _chunkVRAW7VAQcjs.LOOK.git;
|
|
529
|
+
const timeOf = (step, event) => timeline.edges.find((t) => t.step === step && t.event === event);
|
|
530
|
+
const links = layout.links.map((l) => {
|
|
531
|
+
const time = timeOf(l.step, l.event);
|
|
532
|
+
if (!time) return "";
|
|
533
|
+
ctx.traces.push({ from: l.from, to: l.to, points: l.points, shown: [[time.start, Number.POSITIVE_INFINITY]] });
|
|
534
|
+
const d = _chunkOUQ44P45cjs.pathOf.call(void 0, l.points);
|
|
535
|
+
if (l.kind === "copy") return `<g style="${_chunkOUQ44P45cjs.cs.call(void 0, l.color)}"><path class="dg-git-cp dg-a" d="${d}" style="${m.vis(time.start, m.last)}"/></g>`;
|
|
536
|
+
const kf = m.kf([
|
|
537
|
+
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
538
|
+
[time.start, { opacity: 0, "stroke-dashoffset": 1 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
539
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
540
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
541
|
+
[m.last, { opacity: 1, "stroke-dashoffset": 0 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
542
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
543
|
+
]);
|
|
544
|
+
return `<g style="${_chunkOUQ44P45cjs.cs.call(void 0, l.color)}"><path class="dg-git-l dg-a" pathLength="1" d="${d}" style="${kf}"/></g>`;
|
|
545
|
+
}).join("");
|
|
546
|
+
const commits = layout.commits.map((c) => {
|
|
547
|
+
const at = _nullishCoalesce(_optionalChain([timeOf, 'call', _63 => _63(c.step, c.event), 'optionalAccess', _64 => _64.drawn]), () => ( 0));
|
|
548
|
+
const ring = { x: c.cx - c.r, y: c.cy - c.r, w: c.r * 2, h: c.r * 2 };
|
|
549
|
+
ctx.ink.push({ text: c.id, rect: ring, shown: [[at, Number.POSITIVE_INFINITY]], boxed: true });
|
|
550
|
+
const lines2 = (_nullishCoalesce(_optionalChain([c, 'access', _65 => _65.text, 'optionalAccess', _66 => _66.lines]), () => ( []))).map((line, k) => {
|
|
551
|
+
const hash = k === 0 && c.hash !== void 0;
|
|
552
|
+
const baseline = _nullishCoalesce(_optionalChain([c, 'access', _67 => _67.text, 'optionalAccess', _68 => _68.baselines, 'access', _69 => _69[k]]), () => ( c.cy));
|
|
553
|
+
return _chunkOUQ44P45cjs.write.call(void 0, ctx.ink, hash ? "dg-git-h" : "dg-git-n", c.cx, baseline, line, hash ? _chunkVRAW7VAQcjs.TYPE.gitHash : _chunkVRAW7VAQcjs.TYPE.gitNote, [[at, Number.POSITIVE_INFINITY]], "middle");
|
|
554
|
+
}).join("");
|
|
555
|
+
const id = `<text class="dg-git-id" x="${r1(c.cx)}" y="${r1(c.cy + _chunkVRAW7VAQcjs.LOOK.baseline.badge)}" text-anchor="middle">${_chunkOUQ44P45cjs.esc.call(void 0, c.id)}</text>`;
|
|
556
|
+
const node = `<g class="dg-popc dg-a" style="${m.pop(at)}"><circle class="dg-git-c" cx="${r1(c.cx)}" cy="${r1(c.cy)}" r="${c.r}" ${ctx.sh}/>${id}</g>`;
|
|
557
|
+
const text = lines2 === "" ? "" : `<g class="dg-a" style="${m.vis(at)}">${lines2}</g>`;
|
|
558
|
+
const orphanAt = c.orphan === void 0 ? void 0 : _optionalChain([timeOf, 'call', _70 => _70(c.orphan, _nullishCoalesce(c.orphanEvent, () => ( 0))), 'optionalAccess', _71 => _71.drawn]);
|
|
559
|
+
const orphan = orphanAt === void 0 ? "" : `<g class="dg-a" data-orphan="${_chunkOUQ44P45cjs.esc.call(void 0, c.id)}" style="${m.vis(orphanAt, m.last, { f: 0.5 })}"><circle class="dg-git-old" cx="${r1(c.cx)}" cy="${r1(c.cy)}" r="${G.orphan}"/><text class="dg-git-oldl" x="${r1(c.cx)}" y="${r1(c.cy + _chunkVRAW7VAQcjs.LOOK.baseline.badge)}" text-anchor="middle">${_chunkOUQ44P45cjs.esc.call(void 0, c.id)}</text></g>`;
|
|
560
|
+
return `<g data-commit="${_chunkOUQ44P45cjs.esc.call(void 0, c.id)}" style="${_chunkOUQ44P45cjs.cs.call(void 0, c.color)}">${node}${text}${orphan}</g>`;
|
|
561
|
+
}).join("");
|
|
562
|
+
const lines = layout.moves.flatMap((mv) => {
|
|
563
|
+
const time = timeOf(mv.step, mv.event);
|
|
564
|
+
if (!mv.line || !time) return [];
|
|
565
|
+
const end = timeline.steps[mv.step].end;
|
|
566
|
+
ctx.traces.push({ from: mv.ref, to: _nullishCoalesce(mv.target, () => ( mv.ref)), points: mv.line, shown: [[time.start, end + 0.4]] });
|
|
567
|
+
const kf = m.kf([
|
|
568
|
+
[0, { opacity: 0, "stroke-dashoffset": 1 }],
|
|
569
|
+
[time.start, { opacity: 0, "stroke-dashoffset": 1 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
570
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
571
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
572
|
+
[end, { opacity: 1 }, _chunkVRAW7VAQcjs.EASE.inOut],
|
|
573
|
+
[end + 0.4, { opacity: 0 }],
|
|
574
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
575
|
+
]);
|
|
576
|
+
return [`<g style="${_chunkOUQ44P45cjs.cs.call(void 0, mv.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${_chunkOUQ44P45cjs.pathOf.call(void 0, mv.line)}" style="${kf}"/></g>`];
|
|
577
|
+
}).join("");
|
|
578
|
+
const carried = timeline.carriers.flatMap((t) => {
|
|
579
|
+
const mv = layout.moves.find((x) => x.step === t.step && x.event === t.event && x.line);
|
|
580
|
+
const source = _optionalChain([diagram, 'access', _72 => _72.steps, 'access', _73 => _73[t.step], 'optionalAccess', _74 => _74.events, 'access', _75 => _75[t.event]]);
|
|
581
|
+
if (!_optionalChain([mv, 'optionalAccess', _76 => _76.line]) || _optionalChain([source, 'optionalAccess', _77 => _77.type]) !== "edge") return [];
|
|
582
|
+
const edge = { step: t.step, event: t.event, from: mv.ref, to: _nullishCoalesce(mv.target, () => ( mv.ref)), points: mv.line, color: mv.color, carry: source.carry };
|
|
583
|
+
return [_chunkOUQ44P45cjs.carrier.call(void 0, edge, { ...t, start: t.depart, end: t.arrive + _chunkVRAW7VAQcjs.MOTION.fade }, ctx)];
|
|
584
|
+
}).join("");
|
|
585
|
+
const refs = [...new Set(layout.moves.map((mv) => mv.ref))];
|
|
586
|
+
const tags = refs.map((ref) => tagMotion(ref, layout.moves.filter((mv) => mv.ref === ref), timeOf, ctx)).join("") + carried;
|
|
587
|
+
return { links, lines, commits, tags };
|
|
588
|
+
}
|
|
589
|
+
function tagMotion(ref, list, timeOf, ctx) {
|
|
590
|
+
const { m } = ctx;
|
|
591
|
+
const points = [];
|
|
592
|
+
const fades = [[0, { opacity: 0 }]];
|
|
593
|
+
let on = false;
|
|
594
|
+
let rest;
|
|
595
|
+
const leave = (t) => {
|
|
596
|
+
if (rest) ctx.ink.push({ text: ref, rect: rest.rect, shown: [[rest.since, t]], boxed: true });
|
|
597
|
+
rest = void 0;
|
|
598
|
+
};
|
|
599
|
+
for (const mv of list) {
|
|
600
|
+
const time = timeOf(mv.step, mv.event);
|
|
601
|
+
if (!time) continue;
|
|
602
|
+
const { start: a, drawn: b } = time;
|
|
603
|
+
const from = mv.from ? center(mv.from) : void 0;
|
|
604
|
+
const to = mv.to ? center(mv.to) : void 0;
|
|
605
|
+
leave(a);
|
|
606
|
+
if (mv.carried && from && to && on) {
|
|
607
|
+
points.push([a + _chunkVRAW7VAQcjs.MOTION.fade, from[0], from[1]], [b - _chunkVRAW7VAQcjs.MOTION.fade, to[0], to[1]]);
|
|
608
|
+
fades.push([a, { opacity: 1 }, _chunkVRAW7VAQcjs.EASE.inOut], [a + _chunkVRAW7VAQcjs.MOTION.fade, { opacity: 0 }], [b - _chunkVRAW7VAQcjs.MOTION.fade, { opacity: 0 }, _chunkVRAW7VAQcjs.EASE.out], [b, { opacity: 1 }]);
|
|
609
|
+
rest = { rect: mv.to, since: b };
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
if (from) points.push([a, from[0], from[1]]);
|
|
613
|
+
if (to) points.push([b, to[0], to[1]]);
|
|
614
|
+
if (to && !on) {
|
|
615
|
+
const show = from ? a : b - _chunkVRAW7VAQcjs.MOTION.fade;
|
|
616
|
+
fades.push([show, { opacity: 0 }, _chunkVRAW7VAQcjs.EASE.out], [show + _chunkVRAW7VAQcjs.MOTION.fade, { opacity: 1 }]);
|
|
617
|
+
on = true;
|
|
618
|
+
} else if (!to && on) {
|
|
619
|
+
fades.push([b, { opacity: 1 }, _chunkVRAW7VAQcjs.EASE.inOut], [b + _chunkVRAW7VAQcjs.MOTION.untilFade, { opacity: 0 }]);
|
|
620
|
+
on = false;
|
|
621
|
+
}
|
|
622
|
+
if (mv.to) rest = { rect: mv.to, since: b };
|
|
623
|
+
}
|
|
624
|
+
leave(Number.POSITIVE_INFINITY);
|
|
625
|
+
if (points.length === 0) return "";
|
|
626
|
+
const first = points[0];
|
|
627
|
+
const last = points[points.length - 1];
|
|
628
|
+
if (on) fades.push([m.last, { opacity: 1 }, _chunkVRAW7VAQcjs.EASE.inOut], [m.total, { opacity: 0 }]);
|
|
629
|
+
else fades.push([m.total, { opacity: 0 }]);
|
|
630
|
+
const style = m.move([[0, first[1], first[2]], ...points, [m.total, last[1], last[2]]], fades);
|
|
631
|
+
return `<g class="dg-a" data-ref="${_chunkOUQ44P45cjs.esc.call(void 0, ref)}" style="${style}">${tagShape(ref, ctx.sh)}</g>`;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
|
|
635
|
+
|
|
636
|
+
exports.drawGit = drawGit; exports.layoutGit = layoutGit;
|
|
637
|
+
//# sourceMappingURL=git-I7D7RIW2.cjs.map
|