@akshay-rajput/git-graph-svg 1.0.1

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 ADDED
@@ -0,0 +1,207 @@
1
+ # GitGraphSVG
2
+
3
+ A lightweight, customizable **SVG-based Git commit graph renderer for
4
+ React**.
5
+
6
+ `GitGraphSVG` renders a commit history with branching and merging
7
+ support, automatic lane allocation, and customizable node/edge
8
+ rendering.
9
+
10
+ ------------------------------------------------------------------------
11
+
12
+ ## ✨ Features
13
+
14
+ - 🔀 Automatic branch lane management\
15
+ - 🎨 Customizable color palette\
16
+ - 🧩 Render overrides (`renderNode`, `renderEdge`)\
17
+ - 📐 Fully SVG-based (no canvas)\
18
+ - ⚡ Lightweight & dependency-free
19
+
20
+ ------------------------------------------------------------------------
21
+
22
+ ## 🚀 Basic Usage
23
+
24
+ ``` tsx
25
+ import { GitGraphSVG, CommitItem } from "./GitGraphSVG";
26
+
27
+ const commits: CommitItem[] = [
28
+ {
29
+ id: "a1",
30
+ message: "Initial commit",
31
+ author: "Akshay",
32
+ date: "2026-02-18T09:12:45",
33
+ parents: [],
34
+ },
35
+ {
36
+ id: "b2",
37
+ message: "Add feature",
38
+ author: "Akshay",
39
+ date: "2026-02-18T10:30:12",
40
+ parents: ["a1"],
41
+ },
42
+ ];
43
+
44
+ export default function App() {
45
+ return <GitGraphSVG commits={commits} />;
46
+ }
47
+ ```
48
+
49
+ ------------------------------------------------------------------------
50
+
51
+ ## 📘 Data Model
52
+
53
+ ### CommitItem
54
+
55
+ ``` ts
56
+ export interface CommitItem {
57
+ id: string;
58
+ message: string;
59
+ author: string;
60
+ date: string;
61
+ parents: string[];
62
+ }
63
+ ```
64
+
65
+ Each commit must reference its parent commit IDs in the `parents` array.
66
+
67
+ ------------------------------------------------------------------------
68
+
69
+ ## ⚙️ Props
70
+
71
+ ``` ts
72
+ export interface GitGraphSVGProps {
73
+ commits: CommitItem[];
74
+
75
+ rowHeight?: number;
76
+ laneWidth?: number;
77
+ colorPalette?: string[];
78
+
79
+ renderNode?: (commit: _CommitItem) => React.ReactNode;
80
+
81
+ renderEdge?: (
82
+ from: _CommitItem,
83
+ to: _CommitItem,
84
+ defaultPath: string
85
+ ) => React.ReactNode;
86
+ }
87
+ ```
88
+
89
+ ------------------------------------------------------------------------
90
+
91
+ ## 🎨 Custom Rendering
92
+
93
+ You can override how nodes and edges are rendered.
94
+
95
+ ### Custom Nodes
96
+
97
+ ``` tsx
98
+ <GitGraphSVG
99
+ commits={commits}
100
+ renderNode={(commit) => (
101
+ <g key={commit.id}>
102
+ <circle
103
+ cx={commit.cx}
104
+ cy={commit.cy}
105
+ r={8}
106
+ fill="white"
107
+ stroke={commit.color}
108
+ strokeWidth={3}
109
+ />
110
+ <text
111
+ x={commit.cx}
112
+ y={commit.cy - 10}
113
+ textAnchor="middle"
114
+ fontSize={10}
115
+ >
116
+ {commit.id}
117
+ </text>
118
+ </g>
119
+ )}
120
+ />
121
+ ```
122
+
123
+ ------------------------------------------------------------------------
124
+
125
+ ### Custom Edges
126
+
127
+ ``` tsx
128
+ <GitGraphSVG
129
+ commits={commits}
130
+ renderEdge={(from, to, path) => (
131
+ <path
132
+ key={`${from.id}-${to.id}`}
133
+ d={path}
134
+ stroke="black"
135
+ strokeDasharray="4 2"
136
+ fill="none"
137
+ />
138
+ )}
139
+ />
140
+ ```
141
+
142
+ ------------------------------------------------------------------------
143
+
144
+ ## 🎨 Default Configuration
145
+
146
+ ``` ts
147
+ const LANE_WIDTH = 50;
148
+ const NODE_RADIUS = 5;
149
+
150
+ const COLOR_PALETTE = [
151
+ "#3a86ff",
152
+ "#8338ec",
153
+ "#ff006e",
154
+ "#fb5607",
155
+ "#ffbe0b"
156
+ ];
157
+ ```
158
+
159
+ If more branches exist than available colors, random colors are
160
+ generated automatically.
161
+
162
+ ------------------------------------------------------------------------
163
+
164
+ ## 📏 Layout Rules
165
+
166
+ - Vertical spacing = `rowHeight`
167
+ - Horizontal spacing = `laneWidth`
168
+ - SVG width = `lanesCount * laneWidth`
169
+ - SVG height = `commits.length * rowHeight`
170
+
171
+ ------------------------------------------------------------------------
172
+
173
+ ## 🔄 Merge & Branch Handling
174
+
175
+ - Straight lines are drawn when commits stay in the same lane.
176
+ - Smooth Bézier curves are used when switching lanes.
177
+ - Multiple parents are supported.
178
+ - Lane colors are automatically reassigned when branches end.
179
+
180
+ ------------------------------------------------------------------------
181
+
182
+ ## 🧠 Design Philosophy
183
+
184
+ `GitGraphSVG` is designed as a **rendering engine**, not a UI component.
185
+
186
+ It: - Calculates layout - Assigns lanes and colors - Generates edge
187
+ paths - Exposes rendering hooks
188
+
189
+ You control the visual layer.
190
+
191
+ ------------------------------------------------------------------------
192
+
193
+ ## 🚀 Possible Future Enhancements
194
+
195
+ - Animations
196
+ - Hover interactions
197
+ - Zoom & pan
198
+ - Horizontal layout support
199
+ - Stepped lane transitions
200
+ - Commit grouping
201
+ - Performance optimization for large graphs
202
+
203
+ ------------------------------------------------------------------------
204
+
205
+ ## 📜 License
206
+
207
+ MIT
@@ -0,0 +1,22 @@
1
+ import { default as React } from 'react';
2
+ export interface CommitItem {
3
+ id: string;
4
+ message: string;
5
+ author: string;
6
+ date: string;
7
+ parents: string[];
8
+ }
9
+ export interface GitGraphSVGProps {
10
+ commits: CommitItem[];
11
+ rowHeight?: number;
12
+ colorPalette?: string[];
13
+ laneWidth?: number;
14
+ }
15
+ export interface _CommitItem extends CommitItem {
16
+ color: string;
17
+ lane: number;
18
+ cx: number;
19
+ cy: number;
20
+ prev: _CommitItem[];
21
+ }
22
+ export declare const GitGraphSVG: React.FC<GitGraphSVGProps>;
@@ -0,0 +1,715 @@
1
+ import ae, { useMemo as dr } from "react";
2
+ var K = { exports: {} }, U = {};
3
+ var je;
4
+ function vr() {
5
+ if (je) return U;
6
+ je = 1;
7
+ var F = ae, k = /* @__PURE__ */ Symbol.for("react.element"), Y = /* @__PURE__ */ Symbol.for("react.fragment"), P = Object.prototype.hasOwnProperty, O = F.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, x = { key: !0, ref: !0, __self: !0, __source: !0 };
8
+ function R(S, b, w) {
9
+ var g, T = {}, i = null, f = null;
10
+ w !== void 0 && (i = "" + w), b.key !== void 0 && (i = "" + b.key), b.ref !== void 0 && (f = b.ref);
11
+ for (g in b) P.call(b, g) && !x.hasOwnProperty(g) && (T[g] = b[g]);
12
+ if (S && S.defaultProps) for (g in b = S.defaultProps, b) T[g] === void 0 && (T[g] = b[g]);
13
+ return { $$typeof: k, type: S, key: i, ref: f, props: T, _owner: O.current };
14
+ }
15
+ return U.Fragment = Y, U.jsx = R, U.jsxs = R, U;
16
+ }
17
+ var N = {};
18
+ var $e;
19
+ function pr() {
20
+ return $e || ($e = 1, process.env.NODE_ENV !== "production" && (function() {
21
+ var F = ae, k = /* @__PURE__ */ Symbol.for("react.element"), Y = /* @__PURE__ */ Symbol.for("react.portal"), P = /* @__PURE__ */ Symbol.for("react.fragment"), O = /* @__PURE__ */ Symbol.for("react.strict_mode"), x = /* @__PURE__ */ Symbol.for("react.profiler"), R = /* @__PURE__ */ Symbol.for("react.provider"), S = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), w = /* @__PURE__ */ Symbol.for("react.suspense"), g = /* @__PURE__ */ Symbol.for("react.suspense_list"), T = /* @__PURE__ */ Symbol.for("react.memo"), i = /* @__PURE__ */ Symbol.for("react.lazy"), f = /* @__PURE__ */ Symbol.for("react.offscreen"), p = Symbol.iterator, E = "@@iterator";
22
+ function l(e) {
23
+ if (e === null || typeof e != "object")
24
+ return null;
25
+ var r = p && e[p] || e[E];
26
+ return typeof r == "function" ? r : null;
27
+ }
28
+ var d = F.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
29
+ function h(e) {
30
+ {
31
+ for (var r = arguments.length, n = new Array(r > 1 ? r - 1 : 0), t = 1; t < r; t++)
32
+ n[t - 1] = arguments[t];
33
+ j("error", e, n);
34
+ }
35
+ }
36
+ function j(e, r, n) {
37
+ {
38
+ var t = d.ReactDebugCurrentFrame, u = t.getStackAddendum();
39
+ u !== "" && (r += "%s", n = n.concat([u]));
40
+ var s = n.map(function(o) {
41
+ return String(o);
42
+ });
43
+ s.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, s);
44
+ }
45
+ }
46
+ var C = !1, I = !1, Ae = !1, Fe = !1, Ie = !1, oe;
47
+ oe = /* @__PURE__ */ Symbol.for("react.module.reference");
48
+ function Me(e) {
49
+ return !!(typeof e == "string" || typeof e == "function" || e === P || e === x || Ie || e === O || e === w || e === g || Fe || e === f || C || I || Ae || typeof e == "object" && e !== null && (e.$$typeof === i || e.$$typeof === T || e.$$typeof === R || e.$$typeof === S || e.$$typeof === b || // This needs to include all possible module reference object
50
+ // types supported by any Flight configuration anywhere since
51
+ // we don't know which Flight build this will end up being used
52
+ // with.
53
+ e.$$typeof === oe || e.getModuleId !== void 0));
54
+ }
55
+ function We(e, r, n) {
56
+ var t = e.displayName;
57
+ if (t)
58
+ return t;
59
+ var u = r.displayName || r.name || "";
60
+ return u !== "" ? n + "(" + u + ")" : n;
61
+ }
62
+ function ie(e) {
63
+ return e.displayName || "Context";
64
+ }
65
+ function $(e) {
66
+ if (e == null)
67
+ return null;
68
+ if (typeof e.tag == "number" && h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
69
+ return e.displayName || e.name || null;
70
+ if (typeof e == "string")
71
+ return e;
72
+ switch (e) {
73
+ case P:
74
+ return "Fragment";
75
+ case Y:
76
+ return "Portal";
77
+ case x:
78
+ return "Profiler";
79
+ case O:
80
+ return "StrictMode";
81
+ case w:
82
+ return "Suspense";
83
+ case g:
84
+ return "SuspenseList";
85
+ }
86
+ if (typeof e == "object")
87
+ switch (e.$$typeof) {
88
+ case S:
89
+ var r = e;
90
+ return ie(r) + ".Consumer";
91
+ case R:
92
+ var n = e;
93
+ return ie(n._context) + ".Provider";
94
+ case b:
95
+ return We(e, e.render, "ForwardRef");
96
+ case T:
97
+ var t = e.displayName || null;
98
+ return t !== null ? t : $(e.type) || "Memo";
99
+ case i: {
100
+ var u = e, s = u._payload, o = u._init;
101
+ try {
102
+ return $(o(s));
103
+ } catch {
104
+ return null;
105
+ }
106
+ }
107
+ }
108
+ return null;
109
+ }
110
+ var D = Object.assign, L = 0, ue, se, le, ce, fe, de, ve;
111
+ function pe() {
112
+ }
113
+ pe.__reactDisabledLog = !0;
114
+ function Ye() {
115
+ {
116
+ if (L === 0) {
117
+ ue = console.log, se = console.info, le = console.warn, ce = console.error, fe = console.group, de = console.groupCollapsed, ve = console.groupEnd;
118
+ var e = {
119
+ configurable: !0,
120
+ enumerable: !0,
121
+ value: pe,
122
+ writable: !0
123
+ };
124
+ Object.defineProperties(console, {
125
+ info: e,
126
+ log: e,
127
+ warn: e,
128
+ error: e,
129
+ group: e,
130
+ groupCollapsed: e,
131
+ groupEnd: e
132
+ });
133
+ }
134
+ L++;
135
+ }
136
+ }
137
+ function Le() {
138
+ {
139
+ if (L--, L === 0) {
140
+ var e = {
141
+ configurable: !0,
142
+ enumerable: !0,
143
+ writable: !0
144
+ };
145
+ Object.defineProperties(console, {
146
+ log: D({}, e, {
147
+ value: ue
148
+ }),
149
+ info: D({}, e, {
150
+ value: se
151
+ }),
152
+ warn: D({}, e, {
153
+ value: le
154
+ }),
155
+ error: D({}, e, {
156
+ value: ce
157
+ }),
158
+ group: D({}, e, {
159
+ value: fe
160
+ }),
161
+ groupCollapsed: D({}, e, {
162
+ value: de
163
+ }),
164
+ groupEnd: D({}, e, {
165
+ value: ve
166
+ })
167
+ });
168
+ }
169
+ L < 0 && h("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
170
+ }
171
+ }
172
+ var z = d.ReactCurrentDispatcher, H;
173
+ function J(e, r, n) {
174
+ {
175
+ if (H === void 0)
176
+ try {
177
+ throw Error();
178
+ } catch (u) {
179
+ var t = u.stack.trim().match(/\n( *(at )?)/);
180
+ H = t && t[1] || "";
181
+ }
182
+ return `
183
+ ` + H + e;
184
+ }
185
+ }
186
+ var X = !1, q;
187
+ {
188
+ var Ve = typeof WeakMap == "function" ? WeakMap : Map;
189
+ q = new Ve();
190
+ }
191
+ function he(e, r) {
192
+ if (!e || X)
193
+ return "";
194
+ {
195
+ var n = q.get(e);
196
+ if (n !== void 0)
197
+ return n;
198
+ }
199
+ var t;
200
+ X = !0;
201
+ var u = Error.prepareStackTrace;
202
+ Error.prepareStackTrace = void 0;
203
+ var s;
204
+ s = z.current, z.current = null, Ye();
205
+ try {
206
+ if (r) {
207
+ var o = function() {
208
+ throw Error();
209
+ };
210
+ if (Object.defineProperty(o.prototype, "props", {
211
+ set: function() {
212
+ throw Error();
213
+ }
214
+ }), typeof Reflect == "object" && Reflect.construct) {
215
+ try {
216
+ Reflect.construct(o, []);
217
+ } catch (_) {
218
+ t = _;
219
+ }
220
+ Reflect.construct(e, [], o);
221
+ } else {
222
+ try {
223
+ o.call();
224
+ } catch (_) {
225
+ t = _;
226
+ }
227
+ e.call(o.prototype);
228
+ }
229
+ } else {
230
+ try {
231
+ throw Error();
232
+ } catch (_) {
233
+ t = _;
234
+ }
235
+ e();
236
+ }
237
+ } catch (_) {
238
+ if (_ && t && typeof _.stack == "string") {
239
+ for (var a = _.stack.split(`
240
+ `), y = t.stack.split(`
241
+ `), c = a.length - 1, v = y.length - 1; c >= 1 && v >= 0 && a[c] !== y[v]; )
242
+ v--;
243
+ for (; c >= 1 && v >= 0; c--, v--)
244
+ if (a[c] !== y[v]) {
245
+ if (c !== 1 || v !== 1)
246
+ do
247
+ if (c--, v--, v < 0 || a[c] !== y[v]) {
248
+ var m = `
249
+ ` + a[c].replace(" at new ", " at ");
250
+ return e.displayName && m.includes("<anonymous>") && (m = m.replace("<anonymous>", e.displayName)), typeof e == "function" && q.set(e, m), m;
251
+ }
252
+ while (c >= 1 && v >= 0);
253
+ break;
254
+ }
255
+ }
256
+ } finally {
257
+ X = !1, z.current = s, Le(), Error.prepareStackTrace = u;
258
+ }
259
+ var W = e ? e.displayName || e.name : "", A = W ? J(W) : "";
260
+ return typeof e == "function" && q.set(e, A), A;
261
+ }
262
+ function Ue(e, r, n) {
263
+ return he(e, !1);
264
+ }
265
+ function Ne(e) {
266
+ var r = e.prototype;
267
+ return !!(r && r.isReactComponent);
268
+ }
269
+ function B(e, r, n) {
270
+ if (e == null)
271
+ return "";
272
+ if (typeof e == "function")
273
+ return he(e, Ne(e));
274
+ if (typeof e == "string")
275
+ return J(e);
276
+ switch (e) {
277
+ case w:
278
+ return J("Suspense");
279
+ case g:
280
+ return J("SuspenseList");
281
+ }
282
+ if (typeof e == "object")
283
+ switch (e.$$typeof) {
284
+ case b:
285
+ return Ue(e.render);
286
+ case T:
287
+ return B(e.type, r, n);
288
+ case i: {
289
+ var t = e, u = t._payload, s = t._init;
290
+ try {
291
+ return B(s(u), r, n);
292
+ } catch {
293
+ }
294
+ }
295
+ }
296
+ return "";
297
+ }
298
+ var V = Object.prototype.hasOwnProperty, be = {}, ge = d.ReactDebugCurrentFrame;
299
+ function G(e) {
300
+ if (e) {
301
+ var r = e._owner, n = B(e.type, e._source, r ? r.type : null);
302
+ ge.setExtraStackFrame(n);
303
+ } else
304
+ ge.setExtraStackFrame(null);
305
+ }
306
+ function Je(e, r, n, t, u) {
307
+ {
308
+ var s = Function.call.bind(V);
309
+ for (var o in e)
310
+ if (s(e, o)) {
311
+ var a = void 0;
312
+ try {
313
+ if (typeof e[o] != "function") {
314
+ var y = Error((t || "React class") + ": " + n + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
315
+ throw y.name = "Invariant Violation", y;
316
+ }
317
+ a = e[o](r, o, t, n, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
318
+ } catch (c) {
319
+ a = c;
320
+ }
321
+ a && !(a instanceof Error) && (G(u), h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", t || "React class", n, o, typeof a), G(null)), a instanceof Error && !(a.message in be) && (be[a.message] = !0, G(u), h("Failed %s type: %s", n, a.message), G(null));
322
+ }
323
+ }
324
+ }
325
+ var qe = Array.isArray;
326
+ function Z(e) {
327
+ return qe(e);
328
+ }
329
+ function Be(e) {
330
+ {
331
+ var r = typeof Symbol == "function" && Symbol.toStringTag, n = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
332
+ return n;
333
+ }
334
+ }
335
+ function Ge(e) {
336
+ try {
337
+ return Ee(e), !1;
338
+ } catch {
339
+ return !0;
340
+ }
341
+ }
342
+ function Ee(e) {
343
+ return "" + e;
344
+ }
345
+ function ye(e) {
346
+ if (Ge(e))
347
+ return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Be(e)), Ee(e);
348
+ }
349
+ var _e = d.ReactCurrentOwner, Ke = {
350
+ key: !0,
351
+ ref: !0,
352
+ __self: !0,
353
+ __source: !0
354
+ }, Re, me;
355
+ function ze(e) {
356
+ if (V.call(e, "ref")) {
357
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
358
+ if (r && r.isReactWarning)
359
+ return !1;
360
+ }
361
+ return e.ref !== void 0;
362
+ }
363
+ function He(e) {
364
+ if (V.call(e, "key")) {
365
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
366
+ if (r && r.isReactWarning)
367
+ return !1;
368
+ }
369
+ return e.key !== void 0;
370
+ }
371
+ function Xe(e, r) {
372
+ typeof e.ref == "string" && _e.current;
373
+ }
374
+ function Ze(e, r) {
375
+ {
376
+ var n = function() {
377
+ Re || (Re = !0, h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
378
+ };
379
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
380
+ get: n,
381
+ configurable: !0
382
+ });
383
+ }
384
+ }
385
+ function Qe(e, r) {
386
+ {
387
+ var n = function() {
388
+ me || (me = !0, h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
389
+ };
390
+ n.isReactWarning = !0, Object.defineProperty(e, "ref", {
391
+ get: n,
392
+ configurable: !0
393
+ });
394
+ }
395
+ }
396
+ var er = function(e, r, n, t, u, s, o) {
397
+ var a = {
398
+ // This tag allows us to uniquely identify this as a React Element
399
+ $$typeof: k,
400
+ // Built-in properties that belong on the element
401
+ type: e,
402
+ key: r,
403
+ ref: n,
404
+ props: o,
405
+ // Record the component responsible for creating this element.
406
+ _owner: s
407
+ };
408
+ return a._store = {}, Object.defineProperty(a._store, "validated", {
409
+ configurable: !1,
410
+ enumerable: !1,
411
+ writable: !0,
412
+ value: !1
413
+ }), Object.defineProperty(a, "_self", {
414
+ configurable: !1,
415
+ enumerable: !1,
416
+ writable: !1,
417
+ value: t
418
+ }), Object.defineProperty(a, "_source", {
419
+ configurable: !1,
420
+ enumerable: !1,
421
+ writable: !1,
422
+ value: u
423
+ }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
424
+ };
425
+ function rr(e, r, n, t, u) {
426
+ {
427
+ var s, o = {}, a = null, y = null;
428
+ n !== void 0 && (ye(n), a = "" + n), He(r) && (ye(r.key), a = "" + r.key), ze(r) && (y = r.ref, Xe(r, u));
429
+ for (s in r)
430
+ V.call(r, s) && !Ke.hasOwnProperty(s) && (o[s] = r[s]);
431
+ if (e && e.defaultProps) {
432
+ var c = e.defaultProps;
433
+ for (s in c)
434
+ o[s] === void 0 && (o[s] = c[s]);
435
+ }
436
+ if (a || y) {
437
+ var v = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
438
+ a && Ze(o, v), y && Qe(o, v);
439
+ }
440
+ return er(e, a, y, u, t, _e.current, o);
441
+ }
442
+ }
443
+ var Q = d.ReactCurrentOwner, Te = d.ReactDebugCurrentFrame;
444
+ function M(e) {
445
+ if (e) {
446
+ var r = e._owner, n = B(e.type, e._source, r ? r.type : null);
447
+ Te.setExtraStackFrame(n);
448
+ } else
449
+ Te.setExtraStackFrame(null);
450
+ }
451
+ var ee;
452
+ ee = !1;
453
+ function re(e) {
454
+ return typeof e == "object" && e !== null && e.$$typeof === k;
455
+ }
456
+ function Oe() {
457
+ {
458
+ if (Q.current) {
459
+ var e = $(Q.current.type);
460
+ if (e)
461
+ return `
462
+
463
+ Check the render method of \`` + e + "`.";
464
+ }
465
+ return "";
466
+ }
467
+ }
468
+ function nr(e) {
469
+ return "";
470
+ }
471
+ var xe = {};
472
+ function tr(e) {
473
+ {
474
+ var r = Oe();
475
+ if (!r) {
476
+ var n = typeof e == "string" ? e : e.displayName || e.name;
477
+ n && (r = `
478
+
479
+ Check the top-level render call using <` + n + ">.");
480
+ }
481
+ return r;
482
+ }
483
+ }
484
+ function Ce(e, r) {
485
+ {
486
+ if (!e._store || e._store.validated || e.key != null)
487
+ return;
488
+ e._store.validated = !0;
489
+ var n = tr(r);
490
+ if (xe[n])
491
+ return;
492
+ xe[n] = !0;
493
+ var t = "";
494
+ e && e._owner && e._owner !== Q.current && (t = " It was passed a child from " + $(e._owner.type) + "."), M(e), h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', n, t), M(null);
495
+ }
496
+ }
497
+ function Se(e, r) {
498
+ {
499
+ if (typeof e != "object")
500
+ return;
501
+ if (Z(e))
502
+ for (var n = 0; n < e.length; n++) {
503
+ var t = e[n];
504
+ re(t) && Ce(t, r);
505
+ }
506
+ else if (re(e))
507
+ e._store && (e._store.validated = !0);
508
+ else if (e) {
509
+ var u = l(e);
510
+ if (typeof u == "function" && u !== e.entries)
511
+ for (var s = u.call(e), o; !(o = s.next()).done; )
512
+ re(o.value) && Ce(o.value, r);
513
+ }
514
+ }
515
+ }
516
+ function ar(e) {
517
+ {
518
+ var r = e.type;
519
+ if (r == null || typeof r == "string")
520
+ return;
521
+ var n;
522
+ if (typeof r == "function")
523
+ n = r.propTypes;
524
+ else if (typeof r == "object" && (r.$$typeof === b || // Note: Memo only checks outer props here.
525
+ // Inner props are checked in the reconciler.
526
+ r.$$typeof === T))
527
+ n = r.propTypes;
528
+ else
529
+ return;
530
+ if (n) {
531
+ var t = $(r);
532
+ Je(n, e.props, "prop", t, e);
533
+ } else if (r.PropTypes !== void 0 && !ee) {
534
+ ee = !0;
535
+ var u = $(r);
536
+ h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", u || "Unknown");
537
+ }
538
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
539
+ }
540
+ }
541
+ function or(e) {
542
+ {
543
+ for (var r = Object.keys(e.props), n = 0; n < r.length; n++) {
544
+ var t = r[n];
545
+ if (t !== "children" && t !== "key") {
546
+ M(e), h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", t), M(null);
547
+ break;
548
+ }
549
+ }
550
+ e.ref !== null && (M(e), h("Invalid attribute `ref` supplied to `React.Fragment`."), M(null));
551
+ }
552
+ }
553
+ var Pe = {};
554
+ function we(e, r, n, t, u, s) {
555
+ {
556
+ var o = Me(e);
557
+ if (!o) {
558
+ var a = "";
559
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
560
+ var y = nr();
561
+ y ? a += y : a += Oe();
562
+ var c;
563
+ e === null ? c = "null" : Z(e) ? c = "array" : e !== void 0 && e.$$typeof === k ? (c = "<" + ($(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : c = typeof e, h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", c, a);
564
+ }
565
+ var v = rr(e, r, n, u, s);
566
+ if (v == null)
567
+ return v;
568
+ if (o) {
569
+ var m = r.children;
570
+ if (m !== void 0)
571
+ if (t)
572
+ if (Z(m)) {
573
+ for (var W = 0; W < m.length; W++)
574
+ Se(m[W], e);
575
+ Object.freeze && Object.freeze(m);
576
+ } else
577
+ h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
578
+ else
579
+ Se(m, e);
580
+ }
581
+ if (V.call(r, "key")) {
582
+ var A = $(e), _ = Object.keys(r).filter(function(fr) {
583
+ return fr !== "key";
584
+ }), ne = _.length > 0 ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}";
585
+ if (!Pe[A + ne]) {
586
+ var cr = _.length > 0 ? "{" + _.join(": ..., ") + ": ...}" : "{}";
587
+ h(`A props object containing a "key" prop is being spread into JSX:
588
+ let props = %s;
589
+ <%s {...props} />
590
+ React keys must be passed directly to JSX without using spread:
591
+ let props = %s;
592
+ <%s key={someKey} {...props} />`, ne, A, cr, A), Pe[A + ne] = !0;
593
+ }
594
+ }
595
+ return e === P ? or(v) : ar(v), v;
596
+ }
597
+ }
598
+ function ir(e, r, n) {
599
+ return we(e, r, n, !0);
600
+ }
601
+ function ur(e, r, n) {
602
+ return we(e, r, n, !1);
603
+ }
604
+ var sr = ur, lr = ir;
605
+ N.Fragment = P, N.jsx = sr, N.jsxs = lr;
606
+ })()), N;
607
+ }
608
+ var ke;
609
+ function hr() {
610
+ return ke || (ke = 1, process.env.NODE_ENV === "production" ? K.exports = vr() : K.exports = pr()), K.exports;
611
+ }
612
+ var te = hr();
613
+ const De = 50, br = 5, gr = [
614
+ "#3a86ff",
615
+ "#8338ec",
616
+ "#ff006e",
617
+ "#fb5607",
618
+ "#ffbe0b"
619
+ ], yr = ({
620
+ commits: F,
621
+ rowHeight: k,
622
+ colorPalette: Y,
623
+ laneWidth: P
624
+ }) => {
625
+ const O = P || De, x = k || De, R = (Y || gr).map((i, f) => ({
626
+ color: i,
627
+ branch: null,
628
+ lane: f + 1
629
+ }));
630
+ function S() {
631
+ var i = R.findIndex((p) => !p.branch);
632
+ if (i > -1)
633
+ return R[i];
634
+ var f = {
635
+ color: "#" + Math.floor(Math.random() * 16777215).toString(16),
636
+ branch: null,
637
+ lane: R.length + 1
638
+ };
639
+ return R.push(f), f;
640
+ }
641
+ const [b, w] = ae.useState(0), g = dr(() => {
642
+ var i = [];
643
+ const f = /* @__PURE__ */ new Map();
644
+ return F.forEach((p, E) => {
645
+ var l = {
646
+ ...p,
647
+ color: "",
648
+ lane: 0,
649
+ cx: 0,
650
+ cy: 0,
651
+ prev: []
652
+ // initialize empty
653
+ }, d = R.find((C) => C.branch == p.id);
654
+ d || (d = S());
655
+ var h = R.find((C) => C.branch == p.parents[0]);
656
+ h ? d.branch = null : d.branch = p.parents[0], l.color = d.color, l.lane = d.lane, l.cx = l.lane * O - O / 2, l.cy = x * E + O / 2;
657
+ var j = R.reduce((C, I) => I.branch !== null ? C + 1 : C, 0);
658
+ j > b && w(j), i.push(l), f.set(l.id, l);
659
+ }), i.forEach((p) => {
660
+ p.parents.forEach((E) => {
661
+ const l = f.get(E);
662
+ l && l.prev.push(p);
663
+ });
664
+ }), i;
665
+ }, [F, x, O]);
666
+ function T(i, f) {
667
+ const p = i.cx, E = i.cy, l = f.cx, d = f.cy;
668
+ if (p === l)
669
+ return `M ${p} ${E} L ${l} ${d}`;
670
+ const h = d > E ? 1 : -1, j = x * h, C = E + j;
671
+ if (Math.abs(d - E) <= x) {
672
+ const I = (E + d) / 2;
673
+ return `
674
+ M ${p} ${E}
675
+ C ${p} ${I},
676
+ ${l} ${I},
677
+ ${l} ${d}
678
+ `;
679
+ }
680
+ return `
681
+ M ${p} ${E}
682
+ C ${p} ${E + j / 2},
683
+ ${l} ${E + j / 2},
684
+ ${l} ${C}
685
+ L ${l} ${d}
686
+ `;
687
+ }
688
+ return /* @__PURE__ */ te.jsxs("svg", { width: b * O + 100, height: x * g.length, children: [
689
+ g.flatMap(
690
+ (i) => i.prev.map((f) => /* @__PURE__ */ te.jsx(
691
+ "path",
692
+ {
693
+ d: T(i, f),
694
+ fill: "none",
695
+ stroke: i.lane <= f.lane ? f.color : i.color,
696
+ strokeWidth: 2
697
+ },
698
+ `${i.id}-${f.id}`
699
+ ))
700
+ ),
701
+ g.map((i) => /* @__PURE__ */ te.jsx(
702
+ "circle",
703
+ {
704
+ cx: i.cx,
705
+ cy: i.cy,
706
+ r: br,
707
+ fill: i.color
708
+ },
709
+ i.id
710
+ ))
711
+ ] });
712
+ };
713
+ export {
714
+ yr as GitGraphSVG
715
+ };
@@ -0,0 +1,25 @@
1
+ (function(D,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],P):(D=typeof globalThis<"u"?globalThis:D||self,P(D.GitRepoGraph={},D.React))})(this,(function(D,P){"use strict";var B={exports:{}},V={};var ie;function Fe(){if(ie)return V;ie=1;var M=P,A=Symbol.for("react.element"),N=Symbol.for("react.fragment"),w=Object.prototype.hasOwnProperty,O=M.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,S={key:!0,ref:!0,__self:!0,__source:!0};function R(C,b,j){var g,m={},i=null,f=null;j!==void 0&&(i=""+j),b.key!==void 0&&(i=""+b.key),b.ref!==void 0&&(f=b.ref);for(g in b)w.call(b,g)&&!S.hasOwnProperty(g)&&(m[g]=b[g]);if(C&&C.defaultProps)for(g in b=C.defaultProps,b)m[g]===void 0&&(m[g]=b[g]);return{$$typeof:A,type:C,key:i,ref:f,props:m,_owner:O.current}}return V.Fragment=N,V.jsx=R,V.jsxs=R,V}var U={};var ue;function Ie(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&(function(){var M=P,A=Symbol.for("react.element"),N=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),R=Symbol.for("react.provider"),C=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),p=Symbol.iterator,y="@@iterator";function l(e){if(e===null||typeof e!="object")return null;var r=p&&e[p]||e[y];return typeof r=="function"?r:null}var d=M.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function h(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];k("error",e,t)}}function k(e,r,t){{var n=d.ReactDebugCurrentFrame,u=n.getStackAddendum();u!==""&&(r+="%s",t=t.concat([u]));var s=t.map(function(o){return String(o)});s.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,s)}}var x=!1,W=!1,Ve=!1,Ue=!1,Ne=!1,ce;ce=Symbol.for("react.module.reference");function Ge(e){return!!(typeof e=="string"||typeof e=="function"||e===w||e===S||Ne||e===O||e===j||e===g||Ue||e===f||x||W||Ve||typeof e=="object"&&e!==null&&(e.$$typeof===i||e.$$typeof===m||e.$$typeof===R||e.$$typeof===C||e.$$typeof===b||e.$$typeof===ce||e.getModuleId!==void 0))}function Je(e,r,t){var n=e.displayName;if(n)return n;var u=r.displayName||r.name||"";return u!==""?t+"("+u+")":t}function fe(e){return e.displayName||"Context"}function $(e){if(e==null)return null;if(typeof e.tag=="number"&&h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case N:return"Portal";case S:return"Profiler";case O:return"StrictMode";case j:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case C:var r=e;return fe(r)+".Consumer";case R:var t=e;return fe(t._context)+".Provider";case b:return Je(e,e.render,"ForwardRef");case m:var n=e.displayName||null;return n!==null?n:$(e.type)||"Memo";case i:{var u=e,s=u._payload,o=u._init;try{return $(o(s))}catch{return null}}}return null}var F=Object.assign,G=0,de,ve,pe,he,be,ge,ye;function Ee(){}Ee.__reactDisabledLog=!0;function Be(){{if(G===0){de=console.log,ve=console.info,pe=console.warn,he=console.error,be=console.group,ge=console.groupCollapsed,ye=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ee,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}G++}}function Ke(){{if(G--,G===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:F({},e,{value:de}),info:F({},e,{value:ve}),warn:F({},e,{value:pe}),error:F({},e,{value:he}),group:F({},e,{value:be}),groupCollapsed:F({},e,{value:ge}),groupEnd:F({},e,{value:ye})})}G<0&&h("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Z=d.ReactCurrentDispatcher,Q;function K(e,r,t){{if(Q===void 0)try{throw Error()}catch(u){var n=u.stack.trim().match(/\n( *(at )?)/);Q=n&&n[1]||""}return`
2
+ `+Q+e}}var ee=!1,q;{var qe=typeof WeakMap=="function"?WeakMap:Map;q=new qe}function _e(e,r){if(!e||ee)return"";{var t=q.get(e);if(t!==void 0)return t}var n;ee=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var s;s=Z.current,Z.current=null,Be();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(_){n=_}Reflect.construct(e,[],o)}else{try{o.call()}catch(_){n=_}e.call(o.prototype)}}else{try{throw Error()}catch(_){n=_}e()}}catch(_){if(_&&n&&typeof _.stack=="string"){for(var a=_.stack.split(`
3
+ `),E=n.stack.split(`
4
+ `),c=a.length-1,v=E.length-1;c>=1&&v>=0&&a[c]!==E[v];)v--;for(;c>=1&&v>=0;c--,v--)if(a[c]!==E[v]){if(c!==1||v!==1)do if(c--,v--,v<0||a[c]!==E[v]){var T=`
5
+ `+a[c].replace(" at new "," at ");return e.displayName&&T.includes("<anonymous>")&&(T=T.replace("<anonymous>",e.displayName)),typeof e=="function"&&q.set(e,T),T}while(c>=1&&v>=0);break}}}finally{ee=!1,Z.current=s,Ke(),Error.prepareStackTrace=u}var L=e?e.displayName||e.name:"",I=L?K(L):"";return typeof e=="function"&&q.set(e,I),I}function ze(e,r,t){return _e(e,!1)}function He(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function z(e,r,t){if(e==null)return"";if(typeof e=="function")return _e(e,He(e));if(typeof e=="string")return K(e);switch(e){case j:return K("Suspense");case g:return K("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case b:return ze(e.render);case m:return z(e.type,r,t);case i:{var n=e,u=n._payload,s=n._init;try{return z(s(u),r,t)}catch{}}}return""}var J=Object.prototype.hasOwnProperty,Re={},Te=d.ReactDebugCurrentFrame;function H(e){if(e){var r=e._owner,t=z(e.type,e._source,r?r.type:null);Te.setExtraStackFrame(t)}else Te.setExtraStackFrame(null)}function Xe(e,r,t,n,u){{var s=Function.call.bind(J);for(var o in e)if(s(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var E=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw E.name="Invariant Violation",E}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){a=c}a&&!(a instanceof Error)&&(H(u),h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),H(null)),a instanceof Error&&!(a.message in Re)&&(Re[a.message]=!0,H(u),h("Failed %s type: %s",t,a.message),H(null))}}}var Ze=Array.isArray;function re(e){return Ze(e)}function Qe(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function er(e){try{return me(e),!1}catch{return!0}}function me(e){return""+e}function Oe(e){if(er(e))return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Qe(e)),me(e)}var Se=d.ReactCurrentOwner,rr={key:!0,ref:!0,__self:!0,__source:!0},xe,Ce;function tr(e){if(J.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function nr(e){if(J.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function ar(e,r){typeof e.ref=="string"&&Se.current}function or(e,r){{var t=function(){xe||(xe=!0,h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function ir(e,r){{var t=function(){Ce||(Ce=!0,h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var ur=function(e,r,t,n,u,s,o){var a={$$typeof:A,type:e,key:r,ref:t,props:o,_owner:s};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function sr(e,r,t,n,u){{var s,o={},a=null,E=null;t!==void 0&&(Oe(t),a=""+t),nr(r)&&(Oe(r.key),a=""+r.key),tr(r)&&(E=r.ref,ar(r,u));for(s in r)J.call(r,s)&&!rr.hasOwnProperty(s)&&(o[s]=r[s]);if(e&&e.defaultProps){var c=e.defaultProps;for(s in c)o[s]===void 0&&(o[s]=c[s])}if(a||E){var v=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&or(o,v),E&&ir(o,v)}return ur(e,a,E,u,n,Se.current,o)}}var te=d.ReactCurrentOwner,Pe=d.ReactDebugCurrentFrame;function Y(e){if(e){var r=e._owner,t=z(e.type,e._source,r?r.type:null);Pe.setExtraStackFrame(t)}else Pe.setExtraStackFrame(null)}var ne;ne=!1;function ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===A}function we(){{if(te.current){var e=$(te.current.type);if(e)return`
6
+
7
+ Check the render method of \``+e+"`."}return""}}function lr(e){return""}var je={};function cr(e){{var r=we();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
8
+
9
+ Check the top-level render call using <`+t+">.")}return r}}function ke(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=cr(r);if(je[t])return;je[t]=!0;var n="";e&&e._owner&&e._owner!==te.current&&(n=" It was passed a child from "+$(e._owner.type)+"."),Y(e),h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),Y(null)}}function $e(e,r){{if(typeof e!="object")return;if(re(e))for(var t=0;t<e.length;t++){var n=e[t];ae(n)&&ke(n,r)}else if(ae(e))e._store&&(e._store.validated=!0);else if(e){var u=l(e);if(typeof u=="function"&&u!==e.entries)for(var s=u.call(e),o;!(o=s.next()).done;)ae(o.value)&&ke(o.value,r)}}}function fr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===b||r.$$typeof===m))t=r.propTypes;else return;if(t){var n=$(r);Xe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!ne){ne=!0;var u=$(r);h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function dr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){Y(e),h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),Y(null);break}}e.ref!==null&&(Y(e),h("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var De={};function Ae(e,r,t,n,u,s){{var o=Ge(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var E=lr();E?a+=E:a+=we();var c;e===null?c="null":re(e)?c="array":e!==void 0&&e.$$typeof===A?(c="<"+($(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):c=typeof e,h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",c,a)}var v=sr(e,r,t,u,s);if(v==null)return v;if(o){var T=r.children;if(T!==void 0)if(n)if(re(T)){for(var L=0;L<T.length;L++)$e(T[L],e);Object.freeze&&Object.freeze(T)}else h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $e(T,e)}if(J.call(r,"key")){var I=$(e),_=Object.keys(r).filter(function(yr){return yr!=="key"}),oe=_.length>0?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}";if(!De[I+oe]){var gr=_.length>0?"{"+_.join(": ..., ")+": ...}":"{}";h(`A props object containing a "key" prop is being spread into JSX:
10
+ let props = %s;
11
+ <%s {...props} />
12
+ React keys must be passed directly to JSX without using spread:
13
+ let props = %s;
14
+ <%s key={someKey} {...props} />`,oe,I,gr,I),De[I+oe]=!0}}return e===w?dr(v):fr(v),v}}function vr(e,r,t){return Ae(e,r,t,!0)}function pr(e,r,t){return Ae(e,r,t,!1)}var hr=pr,br=vr;U.Fragment=w,U.jsx=hr,U.jsxs=br})()),U}var se;function Me(){return se||(se=1,process.env.NODE_ENV==="production"?B.exports=Fe():B.exports=Ie()),B.exports}var X=Me();const le=50,We=5,Ye=["#3a86ff","#8338ec","#ff006e","#fb5607","#ffbe0b"],Le=({commits:M,rowHeight:A,colorPalette:N,laneWidth:w})=>{const O=w||le,S=A||le,R=(N||Ye).map((i,f)=>({color:i,branch:null,lane:f+1}));function C(){var i=R.findIndex(p=>!p.branch);if(i>-1)return R[i];var f={color:"#"+Math.floor(Math.random()*16777215).toString(16),branch:null,lane:R.length+1};return R.push(f),f}const[b,j]=P.useState(0),g=P.useMemo(()=>{var i=[];const f=new Map;return M.forEach((p,y)=>{var l={...p,color:"",lane:0,cx:0,cy:0,prev:[]},d=R.find(x=>x.branch==p.id);d||(d=C());var h=R.find(x=>x.branch==p.parents[0]);h?d.branch=null:d.branch=p.parents[0],l.color=d.color,l.lane=d.lane,l.cx=l.lane*O-O/2,l.cy=S*y+O/2;var k=R.reduce((x,W)=>W.branch!==null?x+1:x,0);k>b&&j(k),i.push(l),f.set(l.id,l)}),i.forEach(p=>{p.parents.forEach(y=>{const l=f.get(y);l&&l.prev.push(p)})}),i},[M,S,O]);function m(i,f){const p=i.cx,y=i.cy,l=f.cx,d=f.cy;if(p===l)return`M ${p} ${y} L ${l} ${d}`;const h=d>y?1:-1,k=S*h,x=y+k;if(Math.abs(d-y)<=S){const W=(y+d)/2;return`
15
+ M ${p} ${y}
16
+ C ${p} ${W},
17
+ ${l} ${W},
18
+ ${l} ${d}
19
+ `}return`
20
+ M ${p} ${y}
21
+ C ${p} ${y+k/2},
22
+ ${l} ${y+k/2},
23
+ ${l} ${x}
24
+ L ${l} ${d}
25
+ `}return X.jsxs("svg",{width:b*O+100,height:S*g.length,children:[g.flatMap(i=>i.prev.map(f=>X.jsx("path",{d:m(i,f),fill:"none",stroke:i.lane<=f.lane?f.color:i.color,strokeWidth:2},`${i.id}-${f.id}`))),g.map(i=>X.jsx("circle",{cx:i.cx,cy:i.cy,r:We,fill:i.color},i.id))]})};D.GitGraphSVG=Le,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,2 @@
1
+ export { GitGraphSVG } from './components/GitGraph/GitGraph';
2
+ export type { GitGraphSVGProps, CommitItem } from './components/GitGraph/GitGraph';
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@akshay-rajput/git-graph-svg",
3
+ "private": false,
4
+ "version": "1.0.1",
5
+ "main": "dist/git-repo-graph.umd.js",
6
+ "module": "dist/git-repo-graph.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "type": "module",
9
+ "license": "MIT",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "peerDependencies": {
17
+ "react": "^18.0.0",
18
+ "react-dom": "^18.0.0"
19
+ },
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "tsc -b && vite build",
23
+ "lint": "eslint .",
24
+ "preview": "vite preview"
25
+ },
26
+ "devDependencies": {
27
+ "@eslint/js": "^9.39.1",
28
+ "@types/delaunator": "^5.0.3",
29
+ "@types/node": "^24.10.1",
30
+ "@types/react": "^18.3.28",
31
+ "@types/react-dom": "^18.3.7",
32
+ "@vitejs/plugin-react": "^5.1.1",
33
+ "eslint": "^9.39.1",
34
+ "eslint-plugin-react-hooks": "^7.0.1",
35
+ "eslint-plugin-react-refresh": "^0.4.24",
36
+ "globals": "^16.5.0",
37
+ "typescript": "~5.9.3",
38
+ "typescript-eslint": "^8.48.0",
39
+ "vite": "^7.3.1",
40
+ "vite-plugin-dts": "^4.5.4"
41
+ },
42
+ "dependencies": {
43
+ "delaunator": "^5.0.1"
44
+ }
45
+ }