@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
|
+
import {
|
|
2
|
+
HEAD
|
|
3
|
+
} from "./chunk-YDKPEKGZ.js";
|
|
4
|
+
import {
|
|
5
|
+
carrier,
|
|
6
|
+
cs,
|
|
7
|
+
esc,
|
|
8
|
+
pathOf,
|
|
9
|
+
write
|
|
10
|
+
} from "./chunk-6ZUKJ3VO.js";
|
|
11
|
+
import {
|
|
12
|
+
EASE,
|
|
13
|
+
LOOK,
|
|
14
|
+
MOTION,
|
|
15
|
+
TYPE,
|
|
16
|
+
along,
|
|
17
|
+
badgeOnPath,
|
|
18
|
+
badgeRect,
|
|
19
|
+
boxColors,
|
|
20
|
+
boxWidth,
|
|
21
|
+
gapBetween,
|
|
22
|
+
hasWide,
|
|
23
|
+
layoutStrip,
|
|
24
|
+
pathLength,
|
|
25
|
+
placeLabel,
|
|
26
|
+
replaceSameSpot,
|
|
27
|
+
stripNeed,
|
|
28
|
+
textBox,
|
|
29
|
+
textWidth
|
|
30
|
+
} from "./chunk-JNSHZTPF.js";
|
|
31
|
+
|
|
32
|
+
// src/layout/git.ts
|
|
33
|
+
function walk(diagram) {
|
|
34
|
+
const branches = (diagram.git?.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, HEAD];
|
|
51
|
+
const at = new Map(names.map((n) => [n, []]));
|
|
52
|
+
const heads = [];
|
|
53
|
+
const visible = (ref) => ref === HEAD ? attached === null ? headAt : null : tips.get(ref) ?? null;
|
|
54
|
+
const freeRow = (commit2) => {
|
|
55
|
+
const list = 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 = slot ?? (ref === 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 = rows.get(target) ?? [];
|
|
79
|
+
list[to.row] = ref;
|
|
80
|
+
rows.set(target, list);
|
|
81
|
+
most.set(target, Math.max(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(...byId.get(id)?.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 !== HEAD && !tips.has(ref) || !byId.has(e.to)) return;
|
|
112
|
+
settle(
|
|
113
|
+
s,
|
|
114
|
+
k,
|
|
115
|
+
() => {
|
|
116
|
+
if (ref === 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) at.get(n)?.push(n === HEAD ? headAt : 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 byId.get(id)?.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 : tips.get(e.branch) ?? null;
|
|
144
|
+
const joined = e.merge !== void 0 && e.merge !== e.branch ? 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: at.get(name) ?? [], ...name === HEAD ? { attached: heads } : {} }));
|
|
174
|
+
return { branches, made, links, moves, refs, tags, rows: most };
|
|
175
|
+
}
|
|
176
|
+
function cubic(p0, c1, c2, p3) {
|
|
177
|
+
const n = 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(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(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 = 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 } = LOOK;
|
|
220
|
+
const walked = walk(diagram);
|
|
221
|
+
const notes = new Map((diagram.git?.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[(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) => (col.get(p) ?? -1) + 1), (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: TYPE.gitHash }] : [],
|
|
233
|
+
...c.note !== void 0 ? [{ text: c.note, style: TYPE.gitNote }] : []
|
|
234
|
+
];
|
|
235
|
+
const textW = (c) => Math.max(0, ...linesOf(c).map((line) => textWidth(line.text, line.style)));
|
|
236
|
+
const tagW = (ref) => textWidth(ref, hasWide(ref) ? TYPE.carrierJa : 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, textWidth(id, TYPE.regionName), textWidth(notes.get(id) ?? "", 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 = diagram.steps[mv.step]?.events[mv.event];
|
|
246
|
+
return mv.line && mv.to && source?.type === "edge" && source.label !== void 0 ? [walked.made.find((c) => c.id === mv.to?.commit)?.branch ?? ""] : [];
|
|
247
|
+
})
|
|
248
|
+
);
|
|
249
|
+
const extraRows = (branch) => Math.max(0, ...walked.made.filter((c) => c.branch === branch).map((c) => (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 * (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) => textBox(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(walked.made.find((m) => m.id === c.copy)?.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 (made?.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 = laneOf.get(c.branch)?.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 = diagram.steps[m.step]?.events[m.event];
|
|
319
|
+
const carried = m.line && source?.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 = boxColors(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 = (lanes[1] ?? lanes[0])?.line ?? margin + B.h / 2;
|
|
342
|
+
const boxes = diagram.boxes.map((b, i) => {
|
|
343
|
+
const w = boxWidth(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: 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: headers[i]?.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, stripNeed(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 = layoutStrip(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 } = 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) => gapBetween(badgeRect(p), a) >= LOOK.label.touch));
|
|
434
|
+
}
|
|
435
|
+
function clearOnPath(points, taken, avoid) {
|
|
436
|
+
const { r, inset, along: start, short } = LOOK.badge;
|
|
437
|
+
const length = pathLength(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 = along(points, d);
|
|
442
|
+
const rect = badgeRect(p);
|
|
443
|
+
if (taken.every(([x, y]) => Math.hypot(p[0] - x, p[1] - y) >= apart) && avoid.every((a) => gapBetween(rect, a) >= LOOK.label.touch)) return p;
|
|
444
|
+
}
|
|
445
|
+
return void 0;
|
|
446
|
+
}
|
|
447
|
+
function badgesOf(diagram, layout) {
|
|
448
|
+
const { inset } = 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 = mark?.target ? besideCommit(mark.target, taken, avoid) : void 0;
|
|
459
|
+
if (mark && (mark.points || near)) {
|
|
460
|
+
const points = mark.points;
|
|
461
|
+
const point = near ?? (points ? clearOnPath(points, taken, avoid) ?? badgeOnPath(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 === layout.refs[0]?.at[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: (lane?.x ?? 0) + (lane?.w ?? 0) - inset - LOOK.badge.r, y: (lane?.y ?? 0) + inset + LOOK.badge.r, color: lane?.color ?? "slate" });
|
|
485
|
+
});
|
|
486
|
+
return replaceSameSpot(out);
|
|
487
|
+
}
|
|
488
|
+
function labelsOf(diagram, layout) {
|
|
489
|
+
const G = 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 = diagram.steps[move.step]?.events[move.event];
|
|
496
|
+
if (source?.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 = layout.lanes[0]?.id === target.branch;
|
|
500
|
+
const w = textWidth(source.label, hasWide(source.label) ? TYPE.labelJa : TYPE.label) + 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 = 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, (layout.lanes[0]?.tagBase ?? G.tag) + LOOK.carrier.tagH / 2) - LOOK.label.soft - 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) => badgeRect([b.x, b.y]));
|
|
506
|
+
const tags = layout.tags.filter((t) => t.step === move.step);
|
|
507
|
+
labels.push(
|
|
508
|
+
placeLabel(
|
|
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 = LOOK.carrier;
|
|
522
|
+
const ja = hasWide(text);
|
|
523
|
+
const w = textWidth(text, ja ? TYPE.carrierJa : 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="${LOOK.baseline.carrier}" text-anchor="middle">${esc(text)}</text>`;
|
|
525
|
+
}
|
|
526
|
+
function drawGit(layout, diagram, timeline, ctx) {
|
|
527
|
+
const { m } = ctx;
|
|
528
|
+
const G = 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 = pathOf(l.points);
|
|
535
|
+
if (l.kind === "copy") return `<g style="${cs(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 }, EASE.inOut],
|
|
539
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
540
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
541
|
+
[m.last, { opacity: 1, "stroke-dashoffset": 0 }, EASE.inOut],
|
|
542
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
543
|
+
]);
|
|
544
|
+
return `<g style="${cs(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 = timeOf(c.step, c.event)?.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 = (c.text?.lines ?? []).map((line, k) => {
|
|
551
|
+
const hash = k === 0 && c.hash !== void 0;
|
|
552
|
+
const baseline = c.text?.baselines[k] ?? c.cy;
|
|
553
|
+
return write(ctx.ink, hash ? "dg-git-h" : "dg-git-n", c.cx, baseline, line, hash ? TYPE.gitHash : 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 + LOOK.baseline.badge)}" text-anchor="middle">${esc(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 : timeOf(c.orphan, c.orphanEvent ?? 0)?.drawn;
|
|
559
|
+
const orphan = orphanAt === void 0 ? "" : `<g class="dg-a" data-orphan="${esc(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 + LOOK.baseline.badge)}" text-anchor="middle">${esc(c.id)}</text></g>`;
|
|
560
|
+
return `<g data-commit="${esc(c.id)}" style="${cs(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: 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 }, EASE.inOut],
|
|
570
|
+
[time.start + 0.05, { opacity: 1 }],
|
|
571
|
+
[time.drawn, { "stroke-dashoffset": 0 }],
|
|
572
|
+
[end, { opacity: 1 }, EASE.inOut],
|
|
573
|
+
[end + 0.4, { opacity: 0 }],
|
|
574
|
+
[m.total, { opacity: 0, "stroke-dashoffset": 0 }]
|
|
575
|
+
]);
|
|
576
|
+
return [`<g style="${cs(mv.color)}"><path class="dg-e-on dg-a" pathLength="1" d="${pathOf(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 = diagram.steps[t.step]?.events[t.event];
|
|
581
|
+
if (!mv?.line || source?.type !== "edge") return [];
|
|
582
|
+
const edge = { step: t.step, event: t.event, from: mv.ref, to: mv.target ?? mv.ref, points: mv.line, color: mv.color, carry: source.carry };
|
|
583
|
+
return [carrier(edge, { ...t, start: t.depart, end: t.arrive + 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 + MOTION.fade, from[0], from[1]], [b - MOTION.fade, to[0], to[1]]);
|
|
608
|
+
fades.push([a, { opacity: 1 }, EASE.inOut], [a + MOTION.fade, { opacity: 0 }], [b - MOTION.fade, { opacity: 0 }, 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 - MOTION.fade;
|
|
616
|
+
fades.push([show, { opacity: 0 }, EASE.out], [show + MOTION.fade, { opacity: 1 }]);
|
|
617
|
+
on = true;
|
|
618
|
+
} else if (!to && on) {
|
|
619
|
+
fades.push([b, { opacity: 1 }, EASE.inOut], [b + 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 }, 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="${esc(ref)}" style="${style}">${tagShape(ref, ctx.sh)}</g>`;
|
|
632
|
+
}
|
|
633
|
+
export {
|
|
634
|
+
drawGit,
|
|
635
|
+
layoutGit
|
|
636
|
+
};
|
|
637
|
+
//# sourceMappingURL=git-C4RVNFT6.js.map
|