@n8n-zengchao/chat 0.62.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 +289 -0
- package/dist/App.vue.d.ts +2 -0
- package/dist/__stories__/App.stories.d.ts +18 -0
- package/dist/__tests__/Input.spec.d.ts +1 -0
- package/dist/__tests__/api/generic.spec.d.ts +1 -0
- package/dist/__tests__/api/message.spec.d.ts +1 -0
- package/dist/__tests__/index.spec.d.ts +1 -0
- package/dist/__tests__/plugins/chat.spec.d.ts +1 -0
- package/dist/__tests__/plugins/chat.test.d.ts +1 -0
- package/dist/__tests__/setup.d.ts +0 -0
- package/dist/__tests__/utils/create.d.ts +5 -0
- package/dist/__tests__/utils/fetch.d.ts +13 -0
- package/dist/__tests__/utils/index.d.ts +3 -0
- package/dist/__tests__/utils/selectors.d.ts +12 -0
- package/dist/__tests__/utils/streaming.spec.d.ts +1 -0
- package/dist/__tests__/utils/streamingHandlers.spec.d.ts +1 -0
- package/dist/_basePickBy-aQilsjEs.mjs +106 -0
- package/dist/_baseUniq-Agc10qFQ.mjs +232 -0
- package/dist/api/generic.d.ts +7 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/message.d.ts +11 -0
- package/dist/arc-EhYU_DB1.mjs +79 -0
- package/dist/architecture-U656AL7Q-B1STlXpR.mjs +10 -0
- package/dist/architectureDiagram-VXUJARFQ-DOVAbXSw.mjs +4054 -0
- package/dist/array-B5w981Vk.mjs +5 -0
- package/dist/blockDiagram-VD42YOAC-BsX3Fkg3.mjs +3013 -0
- package/dist/c4Diagram-YG6GDRKO-B5JaLuX6.mjs +2957 -0
- package/dist/channel-CqrIo07y.mjs +4 -0
- package/dist/chat.bundle.es.js +37656 -0
- package/dist/chat.bundle.umd.js +2784 -0
- package/dist/chat.es.js +35738 -0
- package/dist/chat.umd.js +2776 -0
- package/dist/chunk-4BX2VUAB-dn0RXIrC.mjs +7 -0
- package/dist/chunk-55IACEB6-DrIttNoL.mjs +7 -0
- package/dist/chunk-76Q3JFCE-D7DMbWeQ.mjs +20 -0
- package/dist/chunk-ABZYJK2D-_NXv778f.mjs +2516 -0
- package/dist/chunk-ATLVNIR6-CBnG7Ev9.mjs +66 -0
- package/dist/chunk-B4BG7PRW-DElmmAse.mjs +3109 -0
- package/dist/chunk-CVBHYZKI-kPsSw5G9.mjs +11 -0
- package/dist/chunk-DI55MBZ5-Bw6uFFfD.mjs +1995 -0
- package/dist/chunk-DZXZ2BO8.mjs +19 -0
- package/dist/chunk-EXTU4WIE-DWzncOZf.mjs +8 -0
- package/dist/chunk-FMBD7UC4-CQf-nVrj.mjs +4 -0
- package/dist/chunk-FPAJGGOC-HRc6DGju.mjs +12254 -0
- package/dist/chunk-FWNWRKHM-CGiJVNMo.mjs +57 -0
- package/dist/chunk-HN2XXSSU-DMfVdeUE.mjs +75 -0
- package/dist/chunk-JA3XYJ7Z-b0Li4NN8.mjs +1834 -0
- package/dist/chunk-JZLCHNYA-C_4MLySW.mjs +4862 -0
- package/dist/chunk-KS23V3DP-BRKOfbU6.mjs +136 -0
- package/dist/chunk-LBM3YZW2-JIQK8wiH.mjs +20 -0
- package/dist/chunk-LHMN2FUI-PNCyIUgu.mjs +20 -0
- package/dist/chunk-MI3HLSF2-B9GTCmLp.mjs +1146 -0
- package/dist/chunk-N4CR4FBY-CjlmnCPD.mjs +40 -0
- package/dist/chunk-O7ZBX7Z2-DmJUfqJj.mjs +27 -0
- package/dist/chunk-QN33PNHL-nN1zLFSf.mjs +24 -0
- package/dist/chunk-QXUST7PY-CY78Btj9.mjs +487 -0
- package/dist/chunk-QZHKN3VN-BF5N1pfB.mjs +12 -0
- package/dist/chunk-S3R3BYOJ-BhFsv0Go.mjs +1076 -0
- package/dist/chunk-S6J4BHB3-BvrWTdbl.mjs +20 -0
- package/dist/chunk-T53DSG4Q-XzY06amw.mjs +25 -0
- package/dist/chunk-TZMSLE5B-DVmJQ8eg.mjs +57 -0
- package/dist/classDiagram-2ON5EDUG-CKxiEVX9.mjs +33 -0
- package/dist/classDiagram-v2-WZHVMYZB-sAa_2keq.mjs +33 -0
- package/dist/clone-nkGlb0Gn.mjs +8 -0
- package/dist/components/Button.vue.d.ts +17 -0
- package/dist/components/Chat.vue.d.ts +2 -0
- package/dist/components/ChatFile.vue.d.ts +11 -0
- package/dist/components/ChatWindow.vue.d.ts +2 -0
- package/dist/components/GetStarted.vue.d.ts +2 -0
- package/dist/components/GetStartedFooter.vue.d.ts +2 -0
- package/dist/components/Input.vue.d.ts +39 -0
- package/dist/components/Layout.vue.d.ts +23 -0
- package/dist/components/Message.vue.d.ts +39 -0
- package/dist/components/MessageTyping.vue.d.ts +76 -0
- package/dist/components/MessagesList.vue.d.ts +164 -0
- package/dist/components/PoweredBy.vue.d.ts +2 -0
- package/dist/components/index.d.ts +10 -0
- package/dist/composables/index.d.ts +3 -0
- package/dist/composables/useChat.d.ts +2 -0
- package/dist/composables/useI18n.d.ts +4 -0
- package/dist/composables/useOptions.d.ts +4 -0
- package/dist/constants/defaults.d.ts +3 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/localStorage.d.ts +2 -0
- package/dist/constants/symbols.d.ts +4 -0
- package/dist/cose-bilkent-S5V4N54A-1lKG2PUg.mjs +2251 -0
- package/dist/cytoscape.esm-Dls1_mGy.mjs +18108 -0
- package/dist/dagre-6UL2VRFP-CbWFu9xQ.mjs +300 -0
- package/dist/dagre-DEdOheHq.mjs +1385 -0
- package/dist/defaultLocale-CyoQm63E.mjs +178 -0
- package/dist/diagram-PSM6KHXK-CJcHbrJH.mjs +499 -0
- package/dist/diagram-QEK2KX5R-XQ9XOVL4.mjs +228 -0
- package/dist/diagram-S2PKOQOG-CmRfaeSf.mjs +146 -0
- package/dist/dist-BT0fjU7K.mjs +50 -0
- package/dist/erDiagram-Q2GNP2WA-iuoUWHwm.mjs +1603 -0
- package/dist/event-buses/chatEventBus.d.ts +1 -0
- package/dist/event-buses/index.d.ts +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/flowDiagram-NV44I4VS-D3GMS8-G.mjs +4132 -0
- package/dist/ganttDiagram-LVOFAZNH-DMTZVZDR.mjs +2832 -0
- package/dist/gitGraph-F6HP7TQM-CrdUzURw.mjs +10 -0
- package/dist/gitGraphDiagram-NY62KEGX-DipP5Fgt.mjs +636 -0
- package/dist/graphlib-D9eH5icd.mjs +224 -0
- package/dist/index.d.ts +2 -0
- package/dist/info-NVLQJR56-C-93Yf3U.mjs +10 -0
- package/dist/infoDiagram-F6ZHWCRC-jM50s26K.mjs +33 -0
- package/dist/init-CYeu4QfE.mjs +14 -0
- package/dist/isArrayLikeObject-BPcFdnyK.mjs +459 -0
- package/dist/isUndefined-BvarJ1wS.mjs +374 -0
- package/dist/journeyDiagram-XKPGCS4Q-BEEO_0Bh.mjs +885 -0
- package/dist/kanban-definition-3W4ZIXB7-B8u_HDmL.mjs +971 -0
- package/dist/katex-Dc1vXbUC.mjs +22094 -0
- package/dist/line-BJxACIPZ.mjs +31 -0
- package/dist/linear-DHHVI-cj.mjs +251 -0
- package/dist/math-Byg0NvhS.mjs +9 -0
- package/dist/mermaid-parser.core-YT4qvimq.mjs +49 -0
- package/dist/mindmap-definition-VGOIOE7T-ah41V88S.mjs +960 -0
- package/dist/now-DsJMgI1z.mjs +6 -0
- package/dist/ordinal-L0-EVPg8.mjs +62 -0
- package/dist/packet-BFZMPI3H-Cs4kRHct.mjs +10 -0
- package/dist/path-BcDHwjEr.mjs +80 -0
- package/dist/pie-7BOR55EZ-YZ5Xu4o6.mjs +10 -0
- package/dist/pieDiagram-ADFJNKIX-CqI33m1a.mjs +174 -0
- package/dist/plugins/chat.d.ts +3 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/quadrantDiagram-AYHSOK5B-DDv2X9c1.mjs +1971 -0
- package/dist/radar-NHE76QYJ-TpirOFtv.mjs +10 -0
- package/dist/requirementDiagram-UZGBJVZJ-DXa77VzO.mjs +2194 -0
- package/dist/sankeyDiagram-TZEHDZUN--B9DInJC.mjs +885 -0
- package/dist/sequenceDiagram-WL72ISMW-Dqn9jJ3g.mjs +3562 -0
- package/dist/src-DdwtiGjk.mjs +1976 -0
- package/dist/stateDiagram-FKZM4ZOC-D3eEcVjS.mjs +226 -0
- package/dist/stateDiagram-v2-4FDKWEC3-dzwJ4caL.mjs +32 -0
- package/dist/style.css +3 -0
- package/dist/timeline-definition-IT6M3QCI-z93ry7RN.mjs +831 -0
- package/dist/toInteger-1S_4Byef.mjs +36 -0
- package/dist/treemap-KMMF4GRG-BlF0Ev1z.mjs +10 -0
- package/dist/types/chat.d.ts +13 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/messages.d.ts +17 -0
- package/dist/types/options.d.ts +33 -0
- package/dist/types/streaming.d.ts +18 -0
- package/dist/types/webhook.d.ts +19 -0
- package/dist/utils/event-bus.d.ts +8 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/mount.d.ts +1 -0
- package/dist/utils/streaming.d.ts +26 -0
- package/dist/utils/streamingHandlers.d.ts +6 -0
- package/dist/utils/utils.d.ts +1 -0
- package/dist/xychartDiagram-PRI3JC2R-C3aDcgBz.mjs +2022 -0
- package/package.json +78 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*! Package version @n8n/chat@0.62.0 */
|
|
2
|
+
import "./isArrayLikeObject-BPcFdnyK.mjs";
|
|
3
|
+
import "./isUndefined-BvarJ1wS.mjs";
|
|
4
|
+
import "./toInteger-1S_4Byef.mjs";
|
|
5
|
+
import "./_baseUniq-Agc10qFQ.mjs";
|
|
6
|
+
import "./chunk-FPAJGGOC-HRc6DGju.mjs";
|
|
7
|
+
import "./_basePickBy-aQilsjEs.mjs";
|
|
8
|
+
import "./clone-nkGlb0Gn.mjs";
|
|
9
|
+
import { n as createGitGraphServices, t as GitGraphModule } from "./chunk-S6J4BHB3-BvrWTdbl.mjs";
|
|
10
|
+
export { GitGraphModule, createGitGraphServices };
|
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
/*! Package version @n8n/chat@0.62.0 */
|
|
2
|
+
import "./isArrayLikeObject-BPcFdnyK.mjs";
|
|
3
|
+
import "./isUndefined-BvarJ1wS.mjs";
|
|
4
|
+
import "./toInteger-1S_4Byef.mjs";
|
|
5
|
+
import "./_baseUniq-Agc10qFQ.mjs";
|
|
6
|
+
import "./chunk-FPAJGGOC-HRc6DGju.mjs";
|
|
7
|
+
import "./_basePickBy-aQilsjEs.mjs";
|
|
8
|
+
import { g as utils_default, i as cleanAndMerge, m as random } from "./chunk-S3R3BYOJ-BhFsv0Go.mjs";
|
|
9
|
+
import "./clone-nkGlb0Gn.mjs";
|
|
10
|
+
import { g as log, h as __name, p as select_default } from "./src-DdwtiGjk.mjs";
|
|
11
|
+
import { B as setAccTitle, C as getDiagramTitle, K as setupGraphViewbox2, U as setDiagramTitle, _ as getAccDescription, a as clear, b as getConfig2, d as defaultConfig_default, s as common_default, v as getAccTitle, y as getConfig, z as setAccDescription } from "./chunk-ABZYJK2D-_NXv778f.mjs";
|
|
12
|
+
import "./math-Byg0NvhS.mjs";
|
|
13
|
+
import "./dist-BT0fjU7K.mjs";
|
|
14
|
+
import "./chunk-O7ZBX7Z2-DmJUfqJj.mjs";
|
|
15
|
+
import "./chunk-S6J4BHB3-BvrWTdbl.mjs";
|
|
16
|
+
import "./chunk-LBM3YZW2-JIQK8wiH.mjs";
|
|
17
|
+
import "./chunk-76Q3JFCE-D7DMbWeQ.mjs";
|
|
18
|
+
import "./chunk-T53DSG4Q-XzY06amw.mjs";
|
|
19
|
+
import "./chunk-LHMN2FUI-PNCyIUgu.mjs";
|
|
20
|
+
import "./chunk-FWNWRKHM-CGiJVNMo.mjs";
|
|
21
|
+
import { t as populateCommonDb } from "./chunk-4BX2VUAB-dn0RXIrC.mjs";
|
|
22
|
+
import { t as parse } from "./mermaid-parser.core-YT4qvimq.mjs";
|
|
23
|
+
import { t as ImperativeState } from "./chunk-QZHKN3VN-BF5N1pfB.mjs";
|
|
24
|
+
var commitType = {
|
|
25
|
+
NORMAL: 0,
|
|
26
|
+
REVERSE: 1,
|
|
27
|
+
HIGHLIGHT: 2,
|
|
28
|
+
MERGE: 3,
|
|
29
|
+
CHERRY_PICK: 4
|
|
30
|
+
}, DEFAULT_GITGRAPH_CONFIG = defaultConfig_default.gitGraph, getConfig3 = /* @__PURE__ */ __name(() => cleanAndMerge({
|
|
31
|
+
...DEFAULT_GITGRAPH_CONFIG,
|
|
32
|
+
...getConfig().gitGraph
|
|
33
|
+
}), "getConfig"), state = new ImperativeState(() => {
|
|
34
|
+
let p = getConfig3(), H = p.mainBranchName, U = p.mainBranchOrder;
|
|
35
|
+
return {
|
|
36
|
+
mainBranchName: H,
|
|
37
|
+
commits: /* @__PURE__ */ new Map(),
|
|
38
|
+
head: null,
|
|
39
|
+
branchConfig: /* @__PURE__ */ new Map([[H, {
|
|
40
|
+
name: H,
|
|
41
|
+
order: U
|
|
42
|
+
}]]),
|
|
43
|
+
branches: /* @__PURE__ */ new Map([[H, null]]),
|
|
44
|
+
currBranch: H,
|
|
45
|
+
direction: "LR",
|
|
46
|
+
seq: 0,
|
|
47
|
+
options: {}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
function getID() {
|
|
51
|
+
return random({ length: 7 });
|
|
52
|
+
}
|
|
53
|
+
__name(getID, "getID");
|
|
54
|
+
function uniqBy(p, H) {
|
|
55
|
+
let U = /* @__PURE__ */ Object.create(null);
|
|
56
|
+
return p.reduce((p, W) => {
|
|
57
|
+
let G = H(W);
|
|
58
|
+
return U[G] || (U[G] = !0, p.push(W)), p;
|
|
59
|
+
}, []);
|
|
60
|
+
}
|
|
61
|
+
__name(uniqBy, "uniqBy");
|
|
62
|
+
var setDirection = /* @__PURE__ */ __name(function(p) {
|
|
63
|
+
state.records.direction = p;
|
|
64
|
+
}, "setDirection"), setOptions = /* @__PURE__ */ __name(function(p) {
|
|
65
|
+
log.debug("options str", p), p = p?.trim(), p ||= "{}";
|
|
66
|
+
try {
|
|
67
|
+
state.records.options = JSON.parse(p);
|
|
68
|
+
} catch (p) {
|
|
69
|
+
log.error("error while parsing gitGraph options", p.message);
|
|
70
|
+
}
|
|
71
|
+
}, "setOptions"), getOptions = /* @__PURE__ */ __name(function() {
|
|
72
|
+
return state.records.options;
|
|
73
|
+
}, "getOptions"), commit = /* @__PURE__ */ __name(function(p) {
|
|
74
|
+
let H = p.msg, U = p.id, G = p.type, K = p.tags;
|
|
75
|
+
log.info("commit", H, U, G, K), log.debug("Entering commit:", H, U, G, K);
|
|
76
|
+
let q = getConfig3();
|
|
77
|
+
U = common_default.sanitizeText(U, q), H = common_default.sanitizeText(H, q), K = K?.map((p) => common_default.sanitizeText(p, q));
|
|
78
|
+
let J = {
|
|
79
|
+
id: U || state.records.seq + "-" + getID(),
|
|
80
|
+
message: H,
|
|
81
|
+
seq: state.records.seq++,
|
|
82
|
+
type: G ?? commitType.NORMAL,
|
|
83
|
+
tags: K ?? [],
|
|
84
|
+
parents: state.records.head == null ? [] : [state.records.head.id],
|
|
85
|
+
branch: state.records.currBranch
|
|
86
|
+
};
|
|
87
|
+
state.records.head = J, log.info("main branch", q.mainBranchName), state.records.commits.has(J.id) && log.warn(`Commit ID ${J.id} already exists`), state.records.commits.set(J.id, J), state.records.branches.set(state.records.currBranch, J.id), log.debug("in pushCommit " + J.id);
|
|
88
|
+
}, "commit"), branch = /* @__PURE__ */ __name(function(p) {
|
|
89
|
+
let H = p.name, U = p.order;
|
|
90
|
+
if (H = common_default.sanitizeText(H, getConfig3()), state.records.branches.has(H)) throw Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${H}")`);
|
|
91
|
+
state.records.branches.set(H, state.records.head == null ? null : state.records.head.id), state.records.branchConfig.set(H, {
|
|
92
|
+
name: H,
|
|
93
|
+
order: U
|
|
94
|
+
}), checkout(H), log.debug("in createBranch");
|
|
95
|
+
}, "branch"), merge = /* @__PURE__ */ __name((p) => {
|
|
96
|
+
let H = p.branch, U = p.id, G = p.type, K = p.tags, q = getConfig3();
|
|
97
|
+
H = common_default.sanitizeText(H, q), U &&= common_default.sanitizeText(U, q);
|
|
98
|
+
let J = state.records.branches.get(state.records.currBranch), Y = state.records.branches.get(H), X = J ? state.records.commits.get(J) : void 0, Z = Y ? state.records.commits.get(Y) : void 0;
|
|
99
|
+
if (X && Z && X.branch === H) throw Error(`Cannot merge branch '${H}' into itself.`);
|
|
100
|
+
if (state.records.currBranch === H) {
|
|
101
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Cannot merge a branch to itself");
|
|
102
|
+
throw p.hash = {
|
|
103
|
+
text: `merge ${H}`,
|
|
104
|
+
token: `merge ${H}`,
|
|
105
|
+
expected: ["branch abc"]
|
|
106
|
+
}, p;
|
|
107
|
+
}
|
|
108
|
+
if (X === void 0 || !X) {
|
|
109
|
+
let p = /* @__PURE__ */ Error(`Incorrect usage of "merge". Current branch (${state.records.currBranch})has no commits`);
|
|
110
|
+
throw p.hash = {
|
|
111
|
+
text: `merge ${H}`,
|
|
112
|
+
token: `merge ${H}`,
|
|
113
|
+
expected: ["commit"]
|
|
114
|
+
}, p;
|
|
115
|
+
}
|
|
116
|
+
if (!state.records.branches.has(H)) {
|
|
117
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Branch to be merged (" + H + ") does not exist");
|
|
118
|
+
throw p.hash = {
|
|
119
|
+
text: `merge ${H}`,
|
|
120
|
+
token: `merge ${H}`,
|
|
121
|
+
expected: [`branch ${H}`]
|
|
122
|
+
}, p;
|
|
123
|
+
}
|
|
124
|
+
if (Z === void 0 || !Z) {
|
|
125
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Branch to be merged (" + H + ") has no commits");
|
|
126
|
+
throw p.hash = {
|
|
127
|
+
text: `merge ${H}`,
|
|
128
|
+
token: `merge ${H}`,
|
|
129
|
+
expected: ["\"commit\""]
|
|
130
|
+
}, p;
|
|
131
|
+
}
|
|
132
|
+
if (X === Z) {
|
|
133
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Both branches have same head");
|
|
134
|
+
throw p.hash = {
|
|
135
|
+
text: `merge ${H}`,
|
|
136
|
+
token: `merge ${H}`,
|
|
137
|
+
expected: ["branch abc"]
|
|
138
|
+
}, p;
|
|
139
|
+
}
|
|
140
|
+
if (U && state.records.commits.has(U)) {
|
|
141
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"merge\". Commit with id:" + U + " already exists, use different custom id");
|
|
142
|
+
throw p.hash = {
|
|
143
|
+
text: `merge ${H} ${U} ${G} ${K?.join(" ")}`,
|
|
144
|
+
token: `merge ${H} ${U} ${G} ${K?.join(" ")}`,
|
|
145
|
+
expected: [`merge ${H} ${U}_UNIQUE ${G} ${K?.join(" ")}`]
|
|
146
|
+
}, p;
|
|
147
|
+
}
|
|
148
|
+
let Q = Y || "", $ = {
|
|
149
|
+
id: U || `${state.records.seq}-${getID()}`,
|
|
150
|
+
message: `merged branch ${H} into ${state.records.currBranch}`,
|
|
151
|
+
seq: state.records.seq++,
|
|
152
|
+
parents: state.records.head == null ? [] : [state.records.head.id, Q],
|
|
153
|
+
branch: state.records.currBranch,
|
|
154
|
+
type: commitType.MERGE,
|
|
155
|
+
customType: G,
|
|
156
|
+
customId: !!U,
|
|
157
|
+
tags: K ?? []
|
|
158
|
+
};
|
|
159
|
+
state.records.head = $, state.records.commits.set($.id, $), state.records.branches.set(state.records.currBranch, $.id), log.debug(state.records.branches), log.debug("in mergeBranch");
|
|
160
|
+
}, "merge"), cherryPick = /* @__PURE__ */ __name(function(p) {
|
|
161
|
+
let H = p.id, U = p.targetId, G = p.tags, K = p.parent;
|
|
162
|
+
log.debug("Entering cherryPick:", H, U, G);
|
|
163
|
+
let q = getConfig3();
|
|
164
|
+
if (H = common_default.sanitizeText(H, q), U = common_default.sanitizeText(U, q), G = G?.map((p) => common_default.sanitizeText(p, q)), K = common_default.sanitizeText(K, q), !H || !state.records.commits.has(H)) {
|
|
165
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"cherryPick\". Source commit id should exist and provided");
|
|
166
|
+
throw p.hash = {
|
|
167
|
+
text: `cherryPick ${H} ${U}`,
|
|
168
|
+
token: `cherryPick ${H} ${U}`,
|
|
169
|
+
expected: ["cherry-pick abc"]
|
|
170
|
+
}, p;
|
|
171
|
+
}
|
|
172
|
+
let J = state.records.commits.get(H);
|
|
173
|
+
if (J === void 0 || !J) throw Error("Incorrect usage of \"cherryPick\". Source commit id should exist and provided");
|
|
174
|
+
if (K && !(Array.isArray(J.parents) && J.parents.includes(K))) throw /* @__PURE__ */ Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");
|
|
175
|
+
let Y = J.branch;
|
|
176
|
+
if (J.type === commitType.MERGE && !K) throw /* @__PURE__ */ Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");
|
|
177
|
+
if (!U || !state.records.commits.has(U)) {
|
|
178
|
+
if (Y === state.records.currBranch) {
|
|
179
|
+
let p = /* @__PURE__ */ Error("Incorrect usage of \"cherryPick\". Source commit is already on current branch");
|
|
180
|
+
throw p.hash = {
|
|
181
|
+
text: `cherryPick ${H} ${U}`,
|
|
182
|
+
token: `cherryPick ${H} ${U}`,
|
|
183
|
+
expected: ["cherry-pick abc"]
|
|
184
|
+
}, p;
|
|
185
|
+
}
|
|
186
|
+
let p = state.records.branches.get(state.records.currBranch);
|
|
187
|
+
if (p === void 0 || !p) {
|
|
188
|
+
let p = /* @__PURE__ */ Error(`Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits`);
|
|
189
|
+
throw p.hash = {
|
|
190
|
+
text: `cherryPick ${H} ${U}`,
|
|
191
|
+
token: `cherryPick ${H} ${U}`,
|
|
192
|
+
expected: ["cherry-pick abc"]
|
|
193
|
+
}, p;
|
|
194
|
+
}
|
|
195
|
+
let q = state.records.commits.get(p);
|
|
196
|
+
if (q === void 0 || !q) {
|
|
197
|
+
let p = /* @__PURE__ */ Error(`Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits`);
|
|
198
|
+
throw p.hash = {
|
|
199
|
+
text: `cherryPick ${H} ${U}`,
|
|
200
|
+
token: `cherryPick ${H} ${U}`,
|
|
201
|
+
expected: ["cherry-pick abc"]
|
|
202
|
+
}, p;
|
|
203
|
+
}
|
|
204
|
+
let X = {
|
|
205
|
+
id: state.records.seq + "-" + getID(),
|
|
206
|
+
message: `cherry-picked ${J?.message} into ${state.records.currBranch}`,
|
|
207
|
+
seq: state.records.seq++,
|
|
208
|
+
parents: state.records.head == null ? [] : [state.records.head.id, J.id],
|
|
209
|
+
branch: state.records.currBranch,
|
|
210
|
+
type: commitType.CHERRY_PICK,
|
|
211
|
+
tags: G ? G.filter(Boolean) : [`cherry-pick:${J.id}${J.type === commitType.MERGE ? `|parent:${K}` : ""}`]
|
|
212
|
+
};
|
|
213
|
+
state.records.head = X, state.records.commits.set(X.id, X), state.records.branches.set(state.records.currBranch, X.id), log.debug(state.records.branches), log.debug("in cherryPick");
|
|
214
|
+
}
|
|
215
|
+
}, "cherryPick"), checkout = /* @__PURE__ */ __name(function(p) {
|
|
216
|
+
if (p = common_default.sanitizeText(p, getConfig3()), state.records.branches.has(p)) {
|
|
217
|
+
state.records.currBranch = p;
|
|
218
|
+
let H = state.records.branches.get(state.records.currBranch);
|
|
219
|
+
H === void 0 || !H ? state.records.head = null : state.records.head = state.records.commits.get(H) ?? null;
|
|
220
|
+
} else {
|
|
221
|
+
let H = /* @__PURE__ */ Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${p}")`);
|
|
222
|
+
throw H.hash = {
|
|
223
|
+
text: `checkout ${p}`,
|
|
224
|
+
token: `checkout ${p}`,
|
|
225
|
+
expected: [`branch ${p}`]
|
|
226
|
+
}, H;
|
|
227
|
+
}
|
|
228
|
+
}, "checkout");
|
|
229
|
+
function upsert(p, H, U) {
|
|
230
|
+
let W = p.indexOf(H);
|
|
231
|
+
W === -1 ? p.push(U) : p.splice(W, 1, U);
|
|
232
|
+
}
|
|
233
|
+
__name(upsert, "upsert");
|
|
234
|
+
function prettyPrintCommitHistory(p) {
|
|
235
|
+
let H = p.reduce((p, H) => p.seq > H.seq ? p : H, p[0]), U = "";
|
|
236
|
+
p.forEach(function(p) {
|
|
237
|
+
p === H ? U += " *" : U += " |";
|
|
238
|
+
});
|
|
239
|
+
let G = [
|
|
240
|
+
U,
|
|
241
|
+
H.id,
|
|
242
|
+
H.seq
|
|
243
|
+
];
|
|
244
|
+
for (let p in state.records.branches) state.records.branches.get(p) === H.id && G.push(p);
|
|
245
|
+
if (log.debug(G.join(" ")), H.parents && H.parents.length == 2 && H.parents[0] && H.parents[1]) {
|
|
246
|
+
let U = state.records.commits.get(H.parents[0]);
|
|
247
|
+
upsert(p, H, U), H.parents[1] && p.push(state.records.commits.get(H.parents[1]));
|
|
248
|
+
} else if (H.parents.length == 0) return;
|
|
249
|
+
else if (H.parents[0]) {
|
|
250
|
+
let U = state.records.commits.get(H.parents[0]);
|
|
251
|
+
upsert(p, H, U);
|
|
252
|
+
}
|
|
253
|
+
p = uniqBy(p, (p) => p.id), prettyPrintCommitHistory(p);
|
|
254
|
+
}
|
|
255
|
+
__name(prettyPrintCommitHistory, "prettyPrintCommitHistory");
|
|
256
|
+
var prettyPrint = /* @__PURE__ */ __name(function() {
|
|
257
|
+
log.debug(state.records.commits);
|
|
258
|
+
let p = getCommitsArray()[0];
|
|
259
|
+
prettyPrintCommitHistory([p]);
|
|
260
|
+
}, "prettyPrint"), clear2 = /* @__PURE__ */ __name(function() {
|
|
261
|
+
state.reset(), clear();
|
|
262
|
+
}, "clear"), getBranchesAsObjArray = /* @__PURE__ */ __name(function() {
|
|
263
|
+
return [...state.records.branchConfig.values()].map((p, H) => p.order !== null && p.order !== void 0 ? p : {
|
|
264
|
+
...p,
|
|
265
|
+
order: parseFloat(`0.${H}`)
|
|
266
|
+
}).sort((p, H) => (p.order ?? 0) - (H.order ?? 0)).map(({ name: p }) => ({ name: p }));
|
|
267
|
+
}, "getBranchesAsObjArray"), getBranches = /* @__PURE__ */ __name(function() {
|
|
268
|
+
return state.records.branches;
|
|
269
|
+
}, "getBranches"), getCommits = /* @__PURE__ */ __name(function() {
|
|
270
|
+
return state.records.commits;
|
|
271
|
+
}, "getCommits"), getCommitsArray = /* @__PURE__ */ __name(function() {
|
|
272
|
+
let p = [...state.records.commits.values()];
|
|
273
|
+
return p.forEach(function(p) {
|
|
274
|
+
log.debug(p.id);
|
|
275
|
+
}), p.sort((p, H) => p.seq - H.seq), p;
|
|
276
|
+
}, "getCommitsArray"), db = {
|
|
277
|
+
commitType,
|
|
278
|
+
getConfig: getConfig3,
|
|
279
|
+
setDirection,
|
|
280
|
+
setOptions,
|
|
281
|
+
getOptions,
|
|
282
|
+
commit,
|
|
283
|
+
branch,
|
|
284
|
+
merge,
|
|
285
|
+
cherryPick,
|
|
286
|
+
checkout,
|
|
287
|
+
prettyPrint,
|
|
288
|
+
clear: clear2,
|
|
289
|
+
getBranchesAsObjArray,
|
|
290
|
+
getBranches,
|
|
291
|
+
getCommits,
|
|
292
|
+
getCommitsArray,
|
|
293
|
+
getCurrentBranch: /* @__PURE__ */ __name(function() {
|
|
294
|
+
return state.records.currBranch;
|
|
295
|
+
}, "getCurrentBranch"),
|
|
296
|
+
getDirection: /* @__PURE__ */ __name(function() {
|
|
297
|
+
return state.records.direction;
|
|
298
|
+
}, "getDirection"),
|
|
299
|
+
getHead: /* @__PURE__ */ __name(function() {
|
|
300
|
+
return state.records.head;
|
|
301
|
+
}, "getHead"),
|
|
302
|
+
setAccTitle,
|
|
303
|
+
getAccTitle,
|
|
304
|
+
getAccDescription,
|
|
305
|
+
setAccDescription,
|
|
306
|
+
setDiagramTitle,
|
|
307
|
+
getDiagramTitle
|
|
308
|
+
}, populate = /* @__PURE__ */ __name((p, H) => {
|
|
309
|
+
populateCommonDb(p, H), p.dir && H.setDirection(p.dir);
|
|
310
|
+
for (let U of p.statements) parseStatement(U, H);
|
|
311
|
+
}, "populate"), parseStatement = /* @__PURE__ */ __name((p, H) => {
|
|
312
|
+
let U = {
|
|
313
|
+
Commit: /* @__PURE__ */ __name((p) => H.commit(parseCommit(p)), "Commit"),
|
|
314
|
+
Branch: /* @__PURE__ */ __name((p) => H.branch(parseBranch(p)), "Branch"),
|
|
315
|
+
Merge: /* @__PURE__ */ __name((p) => H.merge(parseMerge(p)), "Merge"),
|
|
316
|
+
Checkout: /* @__PURE__ */ __name((p) => H.checkout(parseCheckout(p)), "Checkout"),
|
|
317
|
+
CherryPicking: /* @__PURE__ */ __name((p) => H.cherryPick(parseCherryPicking(p)), "CherryPicking")
|
|
318
|
+
}[p.$type];
|
|
319
|
+
U ? U(p) : log.error(`Unknown statement type: ${p.$type}`);
|
|
320
|
+
}, "parseStatement"), parseCommit = /* @__PURE__ */ __name((p) => ({
|
|
321
|
+
id: p.id,
|
|
322
|
+
msg: p.message ?? "",
|
|
323
|
+
type: p.type === void 0 ? commitType.NORMAL : commitType[p.type],
|
|
324
|
+
tags: p.tags ?? void 0
|
|
325
|
+
}), "parseCommit"), parseBranch = /* @__PURE__ */ __name((p) => ({
|
|
326
|
+
name: p.name,
|
|
327
|
+
order: p.order ?? 0
|
|
328
|
+
}), "parseBranch"), parseMerge = /* @__PURE__ */ __name((p) => ({
|
|
329
|
+
branch: p.branch,
|
|
330
|
+
id: p.id ?? "",
|
|
331
|
+
type: p.type === void 0 ? void 0 : commitType[p.type],
|
|
332
|
+
tags: p.tags ?? void 0
|
|
333
|
+
}), "parseMerge"), parseCheckout = /* @__PURE__ */ __name((p) => p.branch, "parseCheckout"), parseCherryPicking = /* @__PURE__ */ __name((p) => ({
|
|
334
|
+
id: p.id,
|
|
335
|
+
targetId: "",
|
|
336
|
+
tags: p.tags?.length === 0 ? void 0 : p.tags,
|
|
337
|
+
parent: p.parent
|
|
338
|
+
}), "parseCherryPicking"), parser = { parse: /* @__PURE__ */ __name(async (p) => {
|
|
339
|
+
let H = await parse("gitGraph", p);
|
|
340
|
+
log.debug(H), populate(H, db);
|
|
341
|
+
}, "parse") }, DEFAULT_GITGRAPH_CONFIG2 = getConfig2()?.gitGraph, LAYOUT_OFFSET = 10, COMMIT_STEP = 40, PX = 4, PY = 2, THEME_COLOR_LIMIT = 8, branchPos = /* @__PURE__ */ new Map(), commitPos = /* @__PURE__ */ new Map(), defaultPos = 30, allCommitsDict = /* @__PURE__ */ new Map(), lanes = [], maxPos = 0, dir = "LR", clear3 = /* @__PURE__ */ __name(() => {
|
|
342
|
+
branchPos.clear(), commitPos.clear(), allCommitsDict.clear(), maxPos = 0, lanes = [], dir = "LR";
|
|
343
|
+
}, "clear"), drawText = /* @__PURE__ */ __name((p) => {
|
|
344
|
+
let H = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
345
|
+
return (typeof p == "string" ? p.split(/\\n|\n|<br\s*\/?>/gi) : p).forEach((p) => {
|
|
346
|
+
let U = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
|
347
|
+
U.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve"), U.setAttribute("dy", "1em"), U.setAttribute("x", "0"), U.setAttribute("class", "row"), U.textContent = p.trim(), H.appendChild(U);
|
|
348
|
+
}), H;
|
|
349
|
+
}, "drawText"), findClosestParent = /* @__PURE__ */ __name((p) => {
|
|
350
|
+
let H, U, W;
|
|
351
|
+
return dir === "BT" ? (U = /* @__PURE__ */ __name((p, H) => p <= H, "comparisonFunc"), W = Infinity) : (U = /* @__PURE__ */ __name((p, H) => p >= H, "comparisonFunc"), W = 0), p.forEach((p) => {
|
|
352
|
+
let G = dir === "TB" || dir == "BT" ? commitPos.get(p)?.y : commitPos.get(p)?.x;
|
|
353
|
+
G !== void 0 && U(G, W) && (H = p, W = G);
|
|
354
|
+
}), H;
|
|
355
|
+
}, "findClosestParent"), findClosestParentBT = /* @__PURE__ */ __name((p) => {
|
|
356
|
+
let H = "", U = Infinity;
|
|
357
|
+
return p.forEach((p) => {
|
|
358
|
+
let W = commitPos.get(p).y;
|
|
359
|
+
W <= U && (H = p, U = W);
|
|
360
|
+
}), H || void 0;
|
|
361
|
+
}, "findClosestParentBT"), setParallelBTPos = /* @__PURE__ */ __name((p, H, U) => {
|
|
362
|
+
let W = U, G = U, K = [];
|
|
363
|
+
p.forEach((p) => {
|
|
364
|
+
let U = H.get(p);
|
|
365
|
+
if (!U) throw Error(`Commit not found for key ${p}`);
|
|
366
|
+
U.parents.length ? (W = calculateCommitPosition(U), G = Math.max(W, G)) : K.push(U), setCommitPosition(U, W);
|
|
367
|
+
}), W = G, K.forEach((p) => {
|
|
368
|
+
setRootPosition(p, W, U);
|
|
369
|
+
}), p.forEach((p) => {
|
|
370
|
+
let U = H.get(p);
|
|
371
|
+
if (U?.parents.length) {
|
|
372
|
+
let p = findClosestParentBT(U.parents);
|
|
373
|
+
W = commitPos.get(p).y - COMMIT_STEP, W <= G && (G = W);
|
|
374
|
+
let H = branchPos.get(U.branch).pos, K = W - LAYOUT_OFFSET;
|
|
375
|
+
commitPos.set(U.id, {
|
|
376
|
+
x: H,
|
|
377
|
+
y: K
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}, "setParallelBTPos"), findClosestParentPos = /* @__PURE__ */ __name((p) => {
|
|
382
|
+
let H = findClosestParent(p.parents.filter((p) => p !== null));
|
|
383
|
+
if (!H) throw Error(`Closest parent not found for commit ${p.id}`);
|
|
384
|
+
let U = commitPos.get(H)?.y;
|
|
385
|
+
if (U === void 0) throw Error(`Closest parent position not found for commit ${p.id}`);
|
|
386
|
+
return U;
|
|
387
|
+
}, "findClosestParentPos"), calculateCommitPosition = /* @__PURE__ */ __name((p) => findClosestParentPos(p) + COMMIT_STEP, "calculateCommitPosition"), setCommitPosition = /* @__PURE__ */ __name((p, H) => {
|
|
388
|
+
let U = branchPos.get(p.branch);
|
|
389
|
+
if (!U) throw Error(`Branch not found for commit ${p.id}`);
|
|
390
|
+
let W = U.pos, G = H + LAYOUT_OFFSET;
|
|
391
|
+
return commitPos.set(p.id, {
|
|
392
|
+
x: W,
|
|
393
|
+
y: G
|
|
394
|
+
}), {
|
|
395
|
+
x: W,
|
|
396
|
+
y: G
|
|
397
|
+
};
|
|
398
|
+
}, "setCommitPosition"), setRootPosition = /* @__PURE__ */ __name((p, H, U) => {
|
|
399
|
+
let W = branchPos.get(p.branch);
|
|
400
|
+
if (!W) throw Error(`Branch not found for commit ${p.id}`);
|
|
401
|
+
let G = H + U, K = W.pos;
|
|
402
|
+
commitPos.set(p.id, {
|
|
403
|
+
x: K,
|
|
404
|
+
y: G
|
|
405
|
+
});
|
|
406
|
+
}, "setRootPosition"), drawCommitBullet = /* @__PURE__ */ __name((p, H, U, W, G, K) => {
|
|
407
|
+
if (K === commitType.HIGHLIGHT) p.append("rect").attr("x", U.x - 10).attr("y", U.y - 10).attr("width", 20).attr("height", 20).attr("class", `commit ${H.id} commit-highlight${G % THEME_COLOR_LIMIT} ${W}-outer`), p.append("rect").attr("x", U.x - 6).attr("y", U.y - 6).attr("width", 12).attr("height", 12).attr("class", `commit ${H.id} commit${G % THEME_COLOR_LIMIT} ${W}-inner`);
|
|
408
|
+
else if (K === commitType.CHERRY_PICK) p.append("circle").attr("cx", U.x).attr("cy", U.y).attr("r", 10).attr("class", `commit ${H.id} ${W}`), p.append("circle").attr("cx", U.x - 3).attr("cy", U.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${H.id} ${W}`), p.append("circle").attr("cx", U.x + 3).attr("cy", U.y + 2).attr("r", 2.75).attr("fill", "#fff").attr("class", `commit ${H.id} ${W}`), p.append("line").attr("x1", U.x + 3).attr("y1", U.y + 1).attr("x2", U.x).attr("y2", U.y - 5).attr("stroke", "#fff").attr("class", `commit ${H.id} ${W}`), p.append("line").attr("x1", U.x - 3).attr("y1", U.y + 1).attr("x2", U.x).attr("y2", U.y - 5).attr("stroke", "#fff").attr("class", `commit ${H.id} ${W}`);
|
|
409
|
+
else {
|
|
410
|
+
let q = p.append("circle");
|
|
411
|
+
if (q.attr("cx", U.x), q.attr("cy", U.y), q.attr("r", H.type === commitType.MERGE ? 9 : 10), q.attr("class", `commit ${H.id} commit${G % THEME_COLOR_LIMIT}`), K === commitType.MERGE) {
|
|
412
|
+
let K = p.append("circle");
|
|
413
|
+
K.attr("cx", U.x), K.attr("cy", U.y), K.attr("r", 6), K.attr("class", `commit ${W} ${H.id} commit${G % THEME_COLOR_LIMIT}`);
|
|
414
|
+
}
|
|
415
|
+
K === commitType.REVERSE && p.append("path").attr("d", `M ${U.x - 5},${U.y - 5}L${U.x + 5},${U.y + 5}M${U.x - 5},${U.y + 5}L${U.x + 5},${U.y - 5}`).attr("class", `commit ${W} ${H.id} commit${G % THEME_COLOR_LIMIT}`);
|
|
416
|
+
}
|
|
417
|
+
}, "drawCommitBullet"), drawCommitLabel = /* @__PURE__ */ __name((p, H, U, W) => {
|
|
418
|
+
if (H.type !== commitType.CHERRY_PICK && (H.customId && H.type === commitType.MERGE || H.type !== commitType.MERGE) && DEFAULT_GITGRAPH_CONFIG2?.showCommitLabel) {
|
|
419
|
+
let G = p.append("g"), K = G.insert("rect").attr("class", "commit-label-bkg"), q = G.append("text").attr("x", W).attr("y", U.y + 25).attr("class", "commit-label").text(H.id), J = q.node()?.getBBox();
|
|
420
|
+
if (J && (K.attr("x", U.posWithOffset - J.width / 2 - PY).attr("y", U.y + 13.5).attr("width", J.width + 2 * PY).attr("height", J.height + 2 * PY), dir === "TB" || dir === "BT" ? (K.attr("x", U.x - (J.width + 4 * PX + 5)).attr("y", U.y - 12), q.attr("x", U.x - (J.width + 4 * PX)).attr("y", U.y + J.height - 12)) : q.attr("x", U.posWithOffset - J.width / 2), DEFAULT_GITGRAPH_CONFIG2.rotateCommitLabel)) if (dir === "TB" || dir === "BT") q.attr("transform", "rotate(-45, " + U.x + ", " + U.y + ")"), K.attr("transform", "rotate(-45, " + U.x + ", " + U.y + ")");
|
|
421
|
+
else {
|
|
422
|
+
let p = -7.5 - (J.width + 10) / 25 * 9.5, H = 10 + J.width / 25 * 8.5;
|
|
423
|
+
G.attr("transform", "translate(" + p + ", " + H + ") rotate(-45, " + W + ", " + U.y + ")");
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}, "drawCommitLabel"), drawCommitTags = /* @__PURE__ */ __name((p, H, U, W) => {
|
|
427
|
+
if (H.tags.length > 0) {
|
|
428
|
+
let G = 0, K = 0, q = 0, J = [];
|
|
429
|
+
for (let W of H.tags.reverse()) {
|
|
430
|
+
let H = p.insert("polygon"), Y = p.append("circle"), X = p.append("text").attr("y", U.y - 16 - G).attr("class", "tag-label").text(W), Z = X.node()?.getBBox();
|
|
431
|
+
if (!Z) throw Error("Tag bbox not found");
|
|
432
|
+
K = Math.max(K, Z.width), q = Math.max(q, Z.height), X.attr("x", U.posWithOffset - Z.width / 2), J.push({
|
|
433
|
+
tag: X,
|
|
434
|
+
hole: Y,
|
|
435
|
+
rect: H,
|
|
436
|
+
yOffset: G
|
|
437
|
+
}), G += 20;
|
|
438
|
+
}
|
|
439
|
+
for (let { tag: p, hole: H, rect: G, yOffset: Y } of J) {
|
|
440
|
+
let J = q / 2, X = U.y - 19.2 - Y;
|
|
441
|
+
if (G.attr("class", "tag-label-bkg").attr("points", `
|
|
442
|
+
${W - K / 2 - PX / 2},${X + PY}
|
|
443
|
+
${W - K / 2 - PX / 2},${X - PY}
|
|
444
|
+
${U.posWithOffset - K / 2 - PX},${X - J - PY}
|
|
445
|
+
${U.posWithOffset + K / 2 + PX},${X - J - PY}
|
|
446
|
+
${U.posWithOffset + K / 2 + PX},${X + J + PY}
|
|
447
|
+
${U.posWithOffset - K / 2 - PX},${X + J + PY}`), H.attr("cy", X).attr("cx", W - K / 2 + PX / 2).attr("r", 1.5).attr("class", "tag-hole"), dir === "TB" || dir === "BT") {
|
|
448
|
+
let q = W + Y;
|
|
449
|
+
G.attr("class", "tag-label-bkg").attr("points", `
|
|
450
|
+
${U.x},${q + 2}
|
|
451
|
+
${U.x},${q - 2}
|
|
452
|
+
${U.x + LAYOUT_OFFSET},${q - J - 2}
|
|
453
|
+
${U.x + LAYOUT_OFFSET + K + 4},${q - J - 2}
|
|
454
|
+
${U.x + LAYOUT_OFFSET + K + 4},${q + J + 2}
|
|
455
|
+
${U.x + LAYOUT_OFFSET},${q + J + 2}`).attr("transform", "translate(12,12) rotate(45, " + U.x + "," + W + ")"), H.attr("cx", U.x + PX / 2).attr("cy", q).attr("transform", "translate(12,12) rotate(45, " + U.x + "," + W + ")"), p.attr("x", U.x + 5).attr("y", q + 3).attr("transform", "translate(14,14) rotate(45, " + U.x + "," + W + ")");
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}, "drawCommitTags"), getCommitClassType = /* @__PURE__ */ __name((p) => {
|
|
460
|
+
switch (p.customType ?? p.type) {
|
|
461
|
+
case commitType.NORMAL: return "commit-normal";
|
|
462
|
+
case commitType.REVERSE: return "commit-reverse";
|
|
463
|
+
case commitType.HIGHLIGHT: return "commit-highlight";
|
|
464
|
+
case commitType.MERGE: return "commit-merge";
|
|
465
|
+
case commitType.CHERRY_PICK: return "commit-cherry-pick";
|
|
466
|
+
default: return "commit-normal";
|
|
467
|
+
}
|
|
468
|
+
}, "getCommitClassType"), calculatePosition = /* @__PURE__ */ __name((p, H, U, W) => {
|
|
469
|
+
let G = {
|
|
470
|
+
x: 0,
|
|
471
|
+
y: 0
|
|
472
|
+
};
|
|
473
|
+
if (p.parents.length > 0) {
|
|
474
|
+
let U = findClosestParent(p.parents);
|
|
475
|
+
if (U) {
|
|
476
|
+
let K = W.get(U) ?? G;
|
|
477
|
+
return H === "TB" ? K.y + COMMIT_STEP : H === "BT" ? (W.get(p.id) ?? G).y - COMMIT_STEP : K.x + COMMIT_STEP;
|
|
478
|
+
}
|
|
479
|
+
} else if (H === "TB") return defaultPos;
|
|
480
|
+
else if (H === "BT") return (W.get(p.id) ?? G).y - COMMIT_STEP;
|
|
481
|
+
else return 0;
|
|
482
|
+
return 0;
|
|
483
|
+
}, "calculatePosition"), getCommitPosition = /* @__PURE__ */ __name((p, H, U) => {
|
|
484
|
+
let W = dir === "BT" && U ? H : H + LAYOUT_OFFSET, G = dir === "TB" || dir === "BT" ? W : branchPos.get(p.branch)?.pos, K = dir === "TB" || dir === "BT" ? branchPos.get(p.branch)?.pos : W;
|
|
485
|
+
if (K === void 0 || G === void 0) throw Error(`Position were undefined for commit ${p.id}`);
|
|
486
|
+
return {
|
|
487
|
+
x: K,
|
|
488
|
+
y: G,
|
|
489
|
+
posWithOffset: W
|
|
490
|
+
};
|
|
491
|
+
}, "getCommitPosition"), drawCommits = /* @__PURE__ */ __name((p, H, U) => {
|
|
492
|
+
if (!DEFAULT_GITGRAPH_CONFIG2) throw Error("GitGraph config not found");
|
|
493
|
+
let W = p.append("g").attr("class", "commit-bullets"), K = p.append("g").attr("class", "commit-labels"), q = dir === "TB" || dir === "BT" ? defaultPos : 0, J = [...H.keys()], Y = DEFAULT_GITGRAPH_CONFIG2?.parallelCommits ?? !1, X = /* @__PURE__ */ __name((p, U) => {
|
|
494
|
+
let W = H.get(p)?.seq, G = H.get(U)?.seq;
|
|
495
|
+
return W !== void 0 && G !== void 0 ? W - G : 0;
|
|
496
|
+
}, "sortKeys"), Z = J.sort(X);
|
|
497
|
+
dir === "BT" && (Y && setParallelBTPos(Z, H, q), Z = Z.reverse()), Z.forEach((p) => {
|
|
498
|
+
let G = H.get(p);
|
|
499
|
+
if (!G) throw Error(`Commit not found for key ${p}`);
|
|
500
|
+
Y && (q = calculatePosition(G, dir, q, commitPos));
|
|
501
|
+
let J = getCommitPosition(G, q, Y);
|
|
502
|
+
if (U) {
|
|
503
|
+
let p = getCommitClassType(G), H = G.customType ?? G.type;
|
|
504
|
+
drawCommitBullet(W, G, J, p, branchPos.get(G.branch)?.index ?? 0, H), drawCommitLabel(K, G, J, q), drawCommitTags(K, G, J, q);
|
|
505
|
+
}
|
|
506
|
+
dir === "TB" || dir === "BT" ? commitPos.set(G.id, {
|
|
507
|
+
x: J.x,
|
|
508
|
+
y: J.posWithOffset
|
|
509
|
+
}) : commitPos.set(G.id, {
|
|
510
|
+
x: J.posWithOffset,
|
|
511
|
+
y: J.y
|
|
512
|
+
}), q = dir === "BT" && Y ? q + COMMIT_STEP : q + COMMIT_STEP + LAYOUT_OFFSET, q > maxPos && (maxPos = q);
|
|
513
|
+
});
|
|
514
|
+
}, "drawCommits"), shouldRerouteArrow = /* @__PURE__ */ __name((p, H, U, W, K) => {
|
|
515
|
+
let q = (dir === "TB" || dir === "BT" ? U.x < W.x : U.y < W.y) ? H.branch : p.branch, J = /* @__PURE__ */ __name((p) => p.branch === q, "isOnBranchToGetCurve"), Y = /* @__PURE__ */ __name((U) => U.seq > p.seq && U.seq < H.seq, "isBetweenCommits");
|
|
516
|
+
return [...K.values()].some((p) => Y(p) && J(p));
|
|
517
|
+
}, "shouldRerouteArrow"), findLane = /* @__PURE__ */ __name((p, H, U = 0) => {
|
|
518
|
+
let W = p + Math.abs(p - H) / 2;
|
|
519
|
+
return U > 5 ? W : lanes.every((p) => Math.abs(p - W) >= 10) ? (lanes.push(W), W) : findLane(p, H - Math.abs(p - H) / 5, U + 1);
|
|
520
|
+
}, "findLane"), drawArrow = /* @__PURE__ */ __name((p, H, U, W) => {
|
|
521
|
+
let G = commitPos.get(H.id), K = commitPos.get(U.id);
|
|
522
|
+
if (G === void 0 || K === void 0) throw Error(`Commit positions not found for commits ${H.id} and ${U.id}`);
|
|
523
|
+
let q = shouldRerouteArrow(H, U, G, K, W), J = "", Y = "", X = 0, Z = 0, Q = branchPos.get(U.branch)?.index;
|
|
524
|
+
U.type === commitType.MERGE && H.id !== U.parents[0] && (Q = branchPos.get(H.branch)?.index);
|
|
525
|
+
let $;
|
|
526
|
+
if (q) {
|
|
527
|
+
J = "A 10 10, 0, 0, 0,", Y = "A 10 10, 0, 0, 1,", X = 10, Z = 10;
|
|
528
|
+
let p = G.y < K.y ? findLane(G.y, K.y) : findLane(K.y, G.y), U = G.x < K.x ? findLane(G.x, K.x) : findLane(K.x, G.x);
|
|
529
|
+
dir === "TB" ? G.x < K.x ? $ = `M ${G.x} ${G.y} L ${U - X} ${G.y} ${Y} ${U} ${G.y + Z} L ${U} ${K.y - X} ${J} ${U + Z} ${K.y} L ${K.x} ${K.y}` : (Q = branchPos.get(H.branch)?.index, $ = `M ${G.x} ${G.y} L ${U + X} ${G.y} ${J} ${U} ${G.y + Z} L ${U} ${K.y - X} ${Y} ${U - Z} ${K.y} L ${K.x} ${K.y}`) : dir === "BT" ? G.x < K.x ? $ = `M ${G.x} ${G.y} L ${U - X} ${G.y} ${J} ${U} ${G.y - Z} L ${U} ${K.y + X} ${Y} ${U + Z} ${K.y} L ${K.x} ${K.y}` : (Q = branchPos.get(H.branch)?.index, $ = `M ${G.x} ${G.y} L ${U + X} ${G.y} ${Y} ${U} ${G.y - Z} L ${U} ${K.y + X} ${J} ${U - Z} ${K.y} L ${K.x} ${K.y}`) : G.y < K.y ? $ = `M ${G.x} ${G.y} L ${G.x} ${p - X} ${J} ${G.x + Z} ${p} L ${K.x - X} ${p} ${Y} ${K.x} ${p + Z} L ${K.x} ${K.y}` : (Q = branchPos.get(H.branch)?.index, $ = `M ${G.x} ${G.y} L ${G.x} ${p + X} ${Y} ${G.x + Z} ${p} L ${K.x - X} ${p} ${J} ${K.x} ${p - Z} L ${K.x} ${K.y}`);
|
|
530
|
+
} else J = "A 20 20, 0, 0, 0,", Y = "A 20 20, 0, 0, 1,", X = 20, Z = 20, dir === "TB" ? (G.x < K.x && ($ = U.type === commitType.MERGE && H.id !== U.parents[0] ? `M ${G.x} ${G.y} L ${G.x} ${K.y - X} ${J} ${G.x + Z} ${K.y} L ${K.x} ${K.y}` : `M ${G.x} ${G.y} L ${K.x - X} ${G.y} ${Y} ${K.x} ${G.y + Z} L ${K.x} ${K.y}`), G.x > K.x && (J = "A 20 20, 0, 0, 0,", Y = "A 20 20, 0, 0, 1,", X = 20, Z = 20, $ = U.type === commitType.MERGE && H.id !== U.parents[0] ? `M ${G.x} ${G.y} L ${G.x} ${K.y - X} ${Y} ${G.x - Z} ${K.y} L ${K.x} ${K.y}` : `M ${G.x} ${G.y} L ${K.x + X} ${G.y} ${J} ${K.x} ${G.y + Z} L ${K.x} ${K.y}`), G.x === K.x && ($ = `M ${G.x} ${G.y} L ${K.x} ${K.y}`)) : dir === "BT" ? (G.x < K.x && ($ = U.type === commitType.MERGE && H.id !== U.parents[0] ? `M ${G.x} ${G.y} L ${G.x} ${K.y + X} ${Y} ${G.x + Z} ${K.y} L ${K.x} ${K.y}` : `M ${G.x} ${G.y} L ${K.x - X} ${G.y} ${J} ${K.x} ${G.y - Z} L ${K.x} ${K.y}`), G.x > K.x && (J = "A 20 20, 0, 0, 0,", Y = "A 20 20, 0, 0, 1,", X = 20, Z = 20, $ = U.type === commitType.MERGE && H.id !== U.parents[0] ? `M ${G.x} ${G.y} L ${G.x} ${K.y + X} ${J} ${G.x - Z} ${K.y} L ${K.x} ${K.y}` : `M ${G.x} ${G.y} L ${K.x - X} ${G.y} ${J} ${K.x} ${G.y - Z} L ${K.x} ${K.y}`), G.x === K.x && ($ = `M ${G.x} ${G.y} L ${K.x} ${K.y}`)) : (G.y < K.y && ($ = U.type === commitType.MERGE && H.id !== U.parents[0] ? `M ${G.x} ${G.y} L ${K.x - X} ${G.y} ${Y} ${K.x} ${G.y + Z} L ${K.x} ${K.y}` : `M ${G.x} ${G.y} L ${G.x} ${K.y - X} ${J} ${G.x + Z} ${K.y} L ${K.x} ${K.y}`), G.y > K.y && ($ = U.type === commitType.MERGE && H.id !== U.parents[0] ? `M ${G.x} ${G.y} L ${K.x - X} ${G.y} ${J} ${K.x} ${G.y - Z} L ${K.x} ${K.y}` : `M ${G.x} ${G.y} L ${G.x} ${K.y + X} ${Y} ${G.x + Z} ${K.y} L ${K.x} ${K.y}`), G.y === K.y && ($ = `M ${G.x} ${G.y} L ${K.x} ${K.y}`));
|
|
531
|
+
if ($ === void 0) throw Error("Line definition not found");
|
|
532
|
+
p.append("path").attr("d", $).attr("class", "arrow arrow" + Q % THEME_COLOR_LIMIT);
|
|
533
|
+
}, "drawArrow"), drawArrows = /* @__PURE__ */ __name((p, H) => {
|
|
534
|
+
let U = p.append("g").attr("class", "commit-arrows");
|
|
535
|
+
[...H.keys()].forEach((p) => {
|
|
536
|
+
let W = H.get(p);
|
|
537
|
+
W.parents && W.parents.length > 0 && W.parents.forEach((p) => {
|
|
538
|
+
drawArrow(U, H.get(p), W, H);
|
|
539
|
+
});
|
|
540
|
+
});
|
|
541
|
+
}, "drawArrows"), drawBranches = /* @__PURE__ */ __name((p, H) => {
|
|
542
|
+
let U = p.append("g");
|
|
543
|
+
H.forEach((p, H) => {
|
|
544
|
+
let W = H % THEME_COLOR_LIMIT, G = branchPos.get(p.name)?.pos;
|
|
545
|
+
if (G === void 0) throw Error(`Position not found for branch ${p.name}`);
|
|
546
|
+
let K = U.append("line");
|
|
547
|
+
K.attr("x1", 0), K.attr("y1", G), K.attr("x2", maxPos), K.attr("y2", G), K.attr("class", "branch branch" + W), dir === "TB" ? (K.attr("y1", defaultPos), K.attr("x1", G), K.attr("y2", maxPos), K.attr("x2", G)) : dir === "BT" && (K.attr("y1", maxPos), K.attr("x1", G), K.attr("y2", defaultPos), K.attr("x2", G)), lanes.push(G);
|
|
548
|
+
let q = p.name, J = drawText(q), Y = U.insert("rect"), X = U.insert("g").attr("class", "branchLabel").insert("g").attr("class", "label branch-label" + W);
|
|
549
|
+
X.node().appendChild(J);
|
|
550
|
+
let Z = J.getBBox();
|
|
551
|
+
Y.attr("class", "branchLabelBkg label" + W).attr("rx", 4).attr("ry", 4).attr("x", -Z.width - 4 - (DEFAULT_GITGRAPH_CONFIG2?.rotateCommitLabel === !0 ? 30 : 0)).attr("y", -Z.height / 2 + 8).attr("width", Z.width + 18).attr("height", Z.height + 4), X.attr("transform", "translate(" + (-Z.width - 14 - (DEFAULT_GITGRAPH_CONFIG2?.rotateCommitLabel === !0 ? 30 : 0)) + ", " + (G - Z.height / 2 - 1) + ")"), dir === "TB" ? (Y.attr("x", G - Z.width / 2 - 10).attr("y", 0), X.attr("transform", "translate(" + (G - Z.width / 2 - 5) + ", 0)")) : dir === "BT" ? (Y.attr("x", G - Z.width / 2 - 10).attr("y", maxPos), X.attr("transform", "translate(" + (G - Z.width / 2 - 5) + ", " + maxPos + ")")) : Y.attr("transform", "translate(-19, " + (G - Z.height / 2) + ")");
|
|
552
|
+
});
|
|
553
|
+
}, "drawBranches"), setBranchPosition = /* @__PURE__ */ __name(function(p, H, U, W, G) {
|
|
554
|
+
return branchPos.set(p, {
|
|
555
|
+
pos: H,
|
|
556
|
+
index: U
|
|
557
|
+
}), H += 50 + (G ? 40 : 0) + (dir === "TB" || dir === "BT" ? W.width / 2 : 0), H;
|
|
558
|
+
}, "setBranchPosition"), diagram = {
|
|
559
|
+
parser,
|
|
560
|
+
db,
|
|
561
|
+
renderer: { draw: /* @__PURE__ */ __name(function(H, U, G, q) {
|
|
562
|
+
if (clear3(), log.debug("in gitgraph renderer", H + "\n", "id:", U, G), !DEFAULT_GITGRAPH_CONFIG2) throw Error("GitGraph config not found");
|
|
563
|
+
let J = DEFAULT_GITGRAPH_CONFIG2.rotateCommitLabel ?? !1, X = q.db;
|
|
564
|
+
allCommitsDict = X.getCommits();
|
|
565
|
+
let Z = X.getBranchesAsObjArray();
|
|
566
|
+
dir = X.getDirection();
|
|
567
|
+
let Q = select_default(`[id="${U}"]`), $ = 0;
|
|
568
|
+
Z.forEach((p, H) => {
|
|
569
|
+
let U = drawText(p.name), W = Q.append("g"), G = W.insert("g").attr("class", "branchLabel"), K = G.insert("g").attr("class", "label branch-label");
|
|
570
|
+
K.node()?.appendChild(U);
|
|
571
|
+
let q = U.getBBox();
|
|
572
|
+
$ = setBranchPosition(p.name, $, H, q, J), K.remove(), G.remove(), W.remove();
|
|
573
|
+
}), drawCommits(Q, allCommitsDict, !1), DEFAULT_GITGRAPH_CONFIG2.showBranches && drawBranches(Q, Z), drawArrows(Q, allCommitsDict), drawCommits(Q, allCommitsDict, !0), utils_default.insertTitle(Q, "gitTitleText", DEFAULT_GITGRAPH_CONFIG2.titleTopMargin ?? 0, X.getDiagramTitle()), setupGraphViewbox2(void 0, Q, DEFAULT_GITGRAPH_CONFIG2.diagramPadding, DEFAULT_GITGRAPH_CONFIG2.useMaxWidth);
|
|
574
|
+
}, "draw") },
|
|
575
|
+
styles: /* @__PURE__ */ __name((p) => `
|
|
576
|
+
.commit-id,
|
|
577
|
+
.commit-msg,
|
|
578
|
+
.branch-label {
|
|
579
|
+
fill: lightgrey;
|
|
580
|
+
color: lightgrey;
|
|
581
|
+
font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
|
582
|
+
font-family: var(--mermaid-font-family);
|
|
583
|
+
}
|
|
584
|
+
${[
|
|
585
|
+
0,
|
|
586
|
+
1,
|
|
587
|
+
2,
|
|
588
|
+
3,
|
|
589
|
+
4,
|
|
590
|
+
5,
|
|
591
|
+
6,
|
|
592
|
+
7
|
|
593
|
+
].map((H) => `
|
|
594
|
+
.branch-label${H} { fill: ${p["gitBranchLabel" + H]}; }
|
|
595
|
+
.commit${H} { stroke: ${p["git" + H]}; fill: ${p["git" + H]}; }
|
|
596
|
+
.commit-highlight${H} { stroke: ${p["gitInv" + H]}; fill: ${p["gitInv" + H]}; }
|
|
597
|
+
.label${H} { fill: ${p["git" + H]}; }
|
|
598
|
+
.arrow${H} { stroke: ${p["git" + H]}; }
|
|
599
|
+
`).join("\n")}
|
|
600
|
+
|
|
601
|
+
.branch {
|
|
602
|
+
stroke-width: 1;
|
|
603
|
+
stroke: ${p.lineColor};
|
|
604
|
+
stroke-dasharray: 2;
|
|
605
|
+
}
|
|
606
|
+
.commit-label { font-size: ${p.commitLabelFontSize}; fill: ${p.commitLabelColor};}
|
|
607
|
+
.commit-label-bkg { font-size: ${p.commitLabelFontSize}; fill: ${p.commitLabelBackground}; opacity: 0.5; }
|
|
608
|
+
.tag-label { font-size: ${p.tagLabelFontSize}; fill: ${p.tagLabelColor};}
|
|
609
|
+
.tag-label-bkg { fill: ${p.tagLabelBackground}; stroke: ${p.tagLabelBorder}; }
|
|
610
|
+
.tag-hole { fill: ${p.textColor}; }
|
|
611
|
+
|
|
612
|
+
.commit-merge {
|
|
613
|
+
stroke: ${p.primaryColor};
|
|
614
|
+
fill: ${p.primaryColor};
|
|
615
|
+
}
|
|
616
|
+
.commit-reverse {
|
|
617
|
+
stroke: ${p.primaryColor};
|
|
618
|
+
fill: ${p.primaryColor};
|
|
619
|
+
stroke-width: 3;
|
|
620
|
+
}
|
|
621
|
+
.commit-highlight-outer {
|
|
622
|
+
}
|
|
623
|
+
.commit-highlight-inner {
|
|
624
|
+
stroke: ${p.primaryColor};
|
|
625
|
+
fill: ${p.primaryColor};
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
.arrow { stroke-width: 8; stroke-linecap: round; fill: none}
|
|
629
|
+
.gitTitleText {
|
|
630
|
+
text-anchor: middle;
|
|
631
|
+
font-size: 18px;
|
|
632
|
+
fill: ${p.textColor};
|
|
633
|
+
}
|
|
634
|
+
`, "getStyles")
|
|
635
|
+
};
|
|
636
|
+
export { diagram };
|