@legionworks/facet 1.9.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/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +23 -0
- package/README.md +158 -0
- package/dist/gallery/chunk-4g8rem85.css +656 -0
- package/dist/gallery/chunk-c6s9k9ty.js +5970 -0
- package/dist/gallery/frame/artifact.css +8424 -0
- package/dist/gallery/frame/chunks/abnfDiagram-N423BO3Z-jj74szbm.js +155 -0
- package/dist/gallery/frame/chunks/architecture-TIHT7OUA-cvdjn7dt.js +10 -0
- package/dist/gallery/frame/chunks/architectureDiagram-T3A2C74G-n4z77eg6.js +8675 -0
- package/dist/gallery/frame/chunks/blockDiagram-VBNYF7ZC-7xsqzrd1.js +3529 -0
- package/dist/gallery/frame/chunks/c4Diagram-5PPSVZJV-z2zjs7wx.js +2413 -0
- package/dist/gallery/frame/chunks/classDiagram-JCYQIIEL-ve8rngqp.js +47 -0
- package/dist/gallery/frame/chunks/classDiagram-v2-OCEON4UE-8cfaxb8z.js +47 -0
- package/dist/gallery/frame/chunks/cose-bilkent-JH36ORCC-sn92qexx.js +4822 -0
- package/dist/gallery/frame/chunks/cynefin-VYW2F7L2-tqjv913d.js +10 -0
- package/dist/gallery/frame/chunks/cynefinDiagram-MW4NZA55-c1c0dj12.js +500 -0
- package/dist/gallery/frame/chunks/dagre-VZM6K2ZE-7tyg4yt2.js +476 -0
- package/dist/gallery/frame/chunks/diagram-7IWD3JNH-y4eng9sc.js +526 -0
- package/dist/gallery/frame/chunks/diagram-B4RE2ZJO-rn3p7j5h.js +673 -0
- package/dist/gallery/frame/chunks/diagram-LBJQPF4R-w4a2cm9q.js +255 -0
- package/dist/gallery/frame/chunks/diagram-Q27KOJAE-aqc2v7wy.js +575 -0
- package/dist/gallery/frame/chunks/diagram-UB23O5K3-xncy8nyd.js +355 -0
- package/dist/gallery/frame/chunks/ebnfDiagram-BXEA7PRR-acwgxz16.js +175 -0
- package/dist/gallery/frame/chunks/erDiagram-JOGREHBK-mzp5nswt.js +1332 -0
- package/dist/gallery/frame/chunks/eventmodeling-45OFAUF4-sg07qr0c.js +10 -0
- package/dist/gallery/frame/chunks/flowDiagram-UKHOOZJN-2e5ygs44.js +29 -0
- package/dist/gallery/frame/chunks/ganttDiagram-PKOTCBZU-p2hhh7hr.js +2620 -0
- package/dist/gallery/frame/chunks/gitGraph-TEB2WS4Q-j6kw0naa.js +10 -0
- package/dist/gallery/frame/chunks/gitGraphDiagram-DS77QQ5N-4z9z8wjm.js +1347 -0
- package/dist/gallery/frame/chunks/info-DKCQHKI2-mpt80jd3.js +10 -0
- package/dist/gallery/frame/chunks/infoDiagram-6WML65LV-5rqm3mgg.js +65 -0
- package/dist/gallery/frame/chunks/ishikawaDiagram-WSZJBQD7-b51z96jy.js +975 -0
- package/dist/gallery/frame/chunks/journeyDiagram-NVQOT4AX-9jbfp0pk.js +1272 -0
- package/dist/gallery/frame/chunks/kanban-definition-27J2QSJJ-4x0vx4se.js +1116 -0
- package/dist/gallery/frame/chunks/katex-xfgk95tv.js +14034 -0
- package/dist/gallery/frame/chunks/markdown-1s5vwkf2.js +9 -0
- package/dist/gallery/frame/chunks/markdown-2h6bwsms.js +3239 -0
- package/dist/gallery/frame/chunks/markdown-2x113yh8.js +107 -0
- package/dist/gallery/frame/chunks/markdown-30b7rwmp.js +1943 -0
- package/dist/gallery/frame/chunks/markdown-356bfj4g.js +2031 -0
- package/dist/gallery/frame/chunks/markdown-44n9ea69.js +2406 -0
- package/dist/gallery/frame/chunks/markdown-56enrf2r.js +39 -0
- package/dist/gallery/frame/chunks/markdown-5avymm8t.js +725 -0
- package/dist/gallery/frame/chunks/markdown-6r4svars.js +33 -0
- package/dist/gallery/frame/chunks/markdown-6zz8efx2.js +24 -0
- package/dist/gallery/frame/chunks/markdown-7jp6prnb.js +19 -0
- package/dist/gallery/frame/chunks/markdown-809k7q41.js +55 -0
- package/dist/gallery/frame/chunks/markdown-82xmzhzd.js +1076 -0
- package/dist/gallery/frame/chunks/markdown-92n37gd4.js +7627 -0
- package/dist/gallery/frame/chunks/markdown-ag2sssf8.js +36 -0
- package/dist/gallery/frame/chunks/markdown-b4s7ntq2.js +19 -0
- package/dist/gallery/frame/chunks/markdown-c9k0fvp1.js +100 -0
- package/dist/gallery/frame/chunks/markdown-ceefymn8.js +125 -0
- package/dist/gallery/frame/chunks/markdown-d1wfbs70.js +243 -0
- package/dist/gallery/frame/chunks/markdown-dy5sgjhc.js +11022 -0
- package/dist/gallery/frame/chunks/markdown-dz3z5w30.js +30868 -0
- package/dist/gallery/frame/chunks/markdown-eg6ngz7y.js +30340 -0
- package/dist/gallery/frame/chunks/markdown-ff5wvb43.js +1149 -0
- package/dist/gallery/frame/chunks/markdown-ffg06nfz.js +86 -0
- package/dist/gallery/frame/chunks/markdown-fvfncadf.js +472 -0
- package/dist/gallery/frame/chunks/markdown-gvyszqpv.js +19 -0
- package/dist/gallery/frame/chunks/markdown-gx1p0ew0.js +88 -0
- package/dist/gallery/frame/chunks/markdown-gxye5frz.js +65 -0
- package/dist/gallery/frame/chunks/markdown-h7pzv34e.js +105 -0
- package/dist/gallery/frame/chunks/markdown-hab789t9.js +47 -0
- package/dist/gallery/frame/chunks/markdown-hjp6sj8t.js +125 -0
- package/dist/gallery/frame/chunks/markdown-jka64qgp.js +1993 -0
- package/dist/gallery/frame/chunks/markdown-k8xkn8mw.js +56 -0
- package/dist/gallery/frame/chunks/markdown-m7frq8x8.js +112 -0
- package/dist/gallery/frame/chunks/markdown-p740v4qm.js +36 -0
- package/dist/gallery/frame/chunks/markdown-pxfeh231.js +57 -0
- package/dist/gallery/frame/chunks/markdown-pzgd8z3s.js +87 -0
- package/dist/gallery/frame/chunks/markdown-qx3cngz2.js +1673 -0
- package/dist/gallery/frame/chunks/markdown-rawhfvvc.js +85 -0
- package/dist/gallery/frame/chunks/markdown-rd8w0ng9.js +49 -0
- package/dist/gallery/frame/chunks/markdown-rm2yxfjj.js +2773 -0
- package/dist/gallery/frame/chunks/markdown-s1jatrnk.js +993 -0
- package/dist/gallery/frame/chunks/markdown-sgfg5vvq.js +59 -0
- package/dist/gallery/frame/chunks/markdown-t4ethv9d.js +409 -0
- package/dist/gallery/frame/chunks/markdown-tnmabqvz.js +36 -0
- package/dist/gallery/frame/chunks/markdown-tvdpppw8.js +5292 -0
- package/dist/gallery/frame/chunks/markdown-v0x27twr.js +22 -0
- package/dist/gallery/frame/chunks/markdown-v14td68x.js +36 -0
- package/dist/gallery/frame/chunks/markdown-w6sgd54z.js +36 -0
- package/dist/gallery/frame/chunks/markdown-xw8dsk8b.js +2125 -0
- package/dist/gallery/frame/chunks/markdown-y18mve73.js +85 -0
- package/dist/gallery/frame/chunks/markdown-yengsms5.js +427 -0
- package/dist/gallery/frame/chunks/markdown-z1wc0v0d.js +1826 -0
- package/dist/gallery/frame/chunks/markdown-zazx9h4n.js +329 -0
- package/dist/gallery/frame/chunks/mermaid-de7p4v0x.js +30 -0
- package/dist/gallery/frame/chunks/mindmap-definition-FAOFIHXS-ra44cbem.js +1216 -0
- package/dist/gallery/frame/chunks/packet-7NZHBO7P-xppm5913.js +10 -0
- package/dist/gallery/frame/chunks/pegDiagram-VL7TDLO6-a2a4wg03.js +163 -0
- package/dist/gallery/frame/chunks/pie-RZYD4A2V-hnbxk152.js +10 -0
- package/dist/gallery/frame/chunks/pieDiagram-7S7Q4E2Y-f1vxjtmx.js +311 -0
- package/dist/gallery/frame/chunks/quadrantDiagram-CIZ2JOQS-ywafa6kh.js +1390 -0
- package/dist/gallery/frame/chunks/radar-I7S5WNFK-ewqd27se.js +10 -0
- package/dist/gallery/frame/chunks/railroad-3IZDKUUU-5hy4bdx3.js +10 -0
- package/dist/gallery/frame/chunks/railroad-abnf-AHOZXSZD-bh5sxz0d.js +10 -0
- package/dist/gallery/frame/chunks/railroad-ebnf-EBAXGLYW-6b9c3zeh.js +10 -0
- package/dist/gallery/frame/chunks/railroad-peg-LSFZ7HO6-avc8v39s.js +10 -0
- package/dist/gallery/frame/chunks/railroadDiagram-AXF67PYL-qc61wax4.js +131 -0
- package/dist/gallery/frame/chunks/requirementDiagram-LRYGKXZP-9bs4786c.js +1295 -0
- package/dist/gallery/frame/chunks/sankeyDiagram-W5VNT64P-awt1em8b.js +1339 -0
- package/dist/gallery/frame/chunks/sequenceDiagram-SI44F4Z6-qaf9mz3t.js +4324 -0
- package/dist/gallery/frame/chunks/sizeCapture-X5ZJPWSS-9fq685xd.js +64 -0
- package/dist/gallery/frame/chunks/stateDiagram-OKZ733FA-vx7a7hh0.js +456 -0
- package/dist/gallery/frame/chunks/stateDiagram-v2-UEYNNEHI-x4m6ws5t.js +46 -0
- package/dist/gallery/frame/chunks/swimlanes-SLNWSIFB-e4mxm1gh.js +8287 -0
- package/dist/gallery/frame/chunks/swimlanesDiagram-ULZ7WXOC-0h93e2qq.js +42 -0
- package/dist/gallery/frame/chunks/timeline-definition-Z64GVDOM-wp0bhbzg.js +1549 -0
- package/dist/gallery/frame/chunks/treeView-QDETBFTQ-hcx7n0vt.js +10 -0
- package/dist/gallery/frame/chunks/treemap-6X3UGDF4-av02skdw.js +10 -0
- package/dist/gallery/frame/chunks/vennDiagram-T6HMQDX7-pmvk1p7n.js +2566 -0
- package/dist/gallery/frame/chunks/wardley-OPB4EBWU-njsp6e40.js +10 -0
- package/dist/gallery/frame/chunks/wardleyDiagram-T6FBY63Y-eggmnv4z.js +979 -0
- package/dist/gallery/frame/chunks/xychartDiagram-ELKLHX3M-q40tnpe5.js +1954 -0
- package/dist/gallery/frame/frame.css +183 -0
- package/dist/gallery/frame/runtime/chart.js +42744 -0
- package/dist/gallery/frame/runtime/html.js +14 -0
- package/dist/gallery/frame/runtime/markdown.js +1403 -0
- package/dist/gallery/frame/runtime/mermaid.js +32 -0
- package/dist/gallery/frame/runtime/svg.js +14 -0
- package/dist/gallery/frame/runtime/tsx.js +52 -0
- package/dist/gallery/index.html +104 -0
- package/docs/reference/cli.md +163 -0
- package/docs/reference/export.md +106 -0
- package/docs/reference/html.md +215 -0
- package/docs/reference/http.md +85 -0
- package/docs/reference/mcp.md +78 -0
- package/docs/reference/security.md +119 -0
- package/docs/reference/storage.md +93 -0
- package/docs/reference/tsx.md +101 -0
- package/docs/reference/validation.md +212 -0
- package/package.json +89 -0
- package/scripts/build-gallery.ts +127 -0
- package/scripts/launch-netns.sh +67 -0
- package/skills/facet/SKILL.md +100 -0
- package/src/cli/client.ts +311 -0
- package/src/cli/commands/create.ts +49 -0
- package/src/cli/commands/doctor.ts +249 -0
- package/src/cli/commands/export.ts +179 -0
- package/src/cli/commands/instantiate.ts +35 -0
- package/src/cli/commands/list.ts +49 -0
- package/src/cli/commands/open.ts +75 -0
- package/src/cli/commands/pin.ts +39 -0
- package/src/cli/commands/promote.ts +49 -0
- package/src/cli/commands/publish.ts +122 -0
- package/src/cli/commands/read-back.ts +56 -0
- package/src/cli/commands/status.ts +114 -0
- package/src/cli/commands/watch.ts +146 -0
- package/src/cli/main.ts +522 -0
- package/src/cli/output.ts +106 -0
- package/src/cli/parser.ts +376 -0
- package/src/cli/presenter.ts +212 -0
- package/src/cli/service-metadata.ts +134 -0
- package/src/cli/spawn-service.ts +326 -0
- package/src/css.d.ts +4 -0
- package/src/gallery-web/app.ts +1581 -0
- package/src/gallery-web/export-menu.ts +121 -0
- package/src/gallery-web/export.ts +112 -0
- package/src/gallery-web/favicon.ts +54 -0
- package/src/gallery-web/frame/entries/chart.ts +6 -0
- package/src/gallery-web/frame/entries/html.ts +6 -0
- package/src/gallery-web/frame/entries/markdown.ts +6 -0
- package/src/gallery-web/frame/entries/mermaid.ts +6 -0
- package/src/gallery-web/frame/entries/svg.ts +6 -0
- package/src/gallery-web/frame/entries/tsx.ts +6 -0
- package/src/gallery-web/frame/frame-payload.ts +91 -0
- package/src/gallery-web/frame/renderer-validation.ts +13 -0
- package/src/gallery-web/frame/renderers/chart.ts +182 -0
- package/src/gallery-web/frame/renderers/dompurify-shim.ts +112 -0
- package/src/gallery-web/frame/renderers/html.ts +48 -0
- package/src/gallery-web/frame/renderers/markdown.ts +81 -0
- package/src/gallery-web/frame/renderers/mermaid.ts +120 -0
- package/src/gallery-web/frame/renderers/registry.ts +260 -0
- package/src/gallery-web/frame/renderers/svg.ts +393 -0
- package/src/gallery-web/frame/renderers/tsx.ts +61 -0
- package/src/gallery-web/frame/runtime.ts +501 -0
- package/src/gallery-web/frame/styles/artifact.css +8424 -0
- package/src/gallery-web/frame/styles/frame.css +183 -0
- package/src/gallery-web/frame/styles/html-source.css +23 -0
- package/src/gallery-web/frame/view-box.ts +33 -0
- package/src/gallery-web/frame-html.ts +72 -0
- package/src/gallery-web/index.html +104 -0
- package/src/gallery-web/session.ts +107 -0
- package/src/gallery-web/sse-client.ts +212 -0
- package/src/gallery-web/styles/app.css +420 -0
- package/src/gallery-web/styles/tokens.css +112 -0
- package/src/gallery-web/styles/verdict.css +186 -0
- package/src/gallery-web/swap.ts +64 -0
- package/src/gallery-web/theme.ts +40 -0
- package/src/gallery-web/view-state.ts +93 -0
- package/src/harness-adapters/claude-code/README.md +10 -0
- package/src/harness-adapters/claude-code/facet.sh +4 -0
- package/src/harness-adapters/codex/README.md +10 -0
- package/src/harness-adapters/codex/facet.sh +4 -0
- package/src/harness-adapters/mcp/README.md +13 -0
- package/src/harness-adapters/mcp/cli-bridge.ts +216 -0
- package/src/harness-adapters/mcp/main.ts +15 -0
- package/src/harness-adapters/mcp/server.ts +164 -0
- package/src/harness-adapters/mcp/tool-schemas.ts +53 -0
- package/src/harness-adapters/opencode/README.md +10 -0
- package/src/harness-adapters/opencode/facet.sh +4 -0
- package/src/runtime/compiled-entrypoints.ts +69 -0
- package/src/service/dispatcher.ts +717 -0
- package/src/service/export.ts +218 -0
- package/src/service/http-utils.ts +55 -0
- package/src/service/lexical/expectations.ts +210 -0
- package/src/service/lifecycle/idle-controller.ts +125 -0
- package/src/service/lifecycle/orphan-cleanup.ts +128 -0
- package/src/service/lifecycle/process-lock.ts +235 -0
- package/src/service/main.ts +136 -0
- package/src/service/process.ts +240 -0
- package/src/service/router-guards.ts +239 -0
- package/src/service/router.ts +627 -0
- package/src/service/security/auth.ts +168 -0
- package/src/service/security/host-origin.ts +138 -0
- package/src/service/security/http-guards.ts +13 -0
- package/src/service/security/leases.ts +182 -0
- package/src/service/security/token-store.ts +138 -0
- package/src/service/server.ts +356 -0
- package/src/service/store/database.ts +61 -0
- package/src/service/store/evidence-retention.ts +234 -0
- package/src/service/store/migrations.ts +167 -0
- package/src/service/store/repository-lifecycle.ts +121 -0
- package/src/service/store/repository.ts +732 -0
- package/src/service/store/schema.ts +218 -0
- package/src/service/stored-verdict.ts +97 -0
- package/src/service/stream.ts +301 -0
- package/src/service/verdict-enrichment.ts +45 -0
- package/src/shared/build/frame-bundle-plugins.ts +61 -0
- package/src/shared/build-mode.ts +28 -0
- package/src/shared/config/evidence-read.ts +98 -0
- package/src/shared/config/limits.ts +56 -0
- package/src/shared/config/paths.ts +96 -0
- package/src/shared/contracts/artifact-types.ts +2 -0
- package/src/shared/contracts/artifact.ts +98 -0
- package/src/shared/contracts/commands/_shared.ts +59 -0
- package/src/shared/contracts/commands/guards.ts +86 -0
- package/src/shared/contracts/commands/index.ts +204 -0
- package/src/shared/contracts/commands/names.ts +35 -0
- package/src/shared/contracts/commands/requests.ts +149 -0
- package/src/shared/contracts/commands/results.ts +200 -0
- package/src/shared/contracts/envelope.ts +140 -0
- package/src/shared/contracts/events.ts +41 -0
- package/src/shared/contracts/observed-counts.ts +19 -0
- package/src/shared/contracts/renderers.ts +6 -0
- package/src/shared/contracts/validation.ts +296 -0
- package/src/shared/errors/facet-error.ts +127 -0
- package/src/shared/errors/store-error.ts +68 -0
- package/src/shared/evidence-image.ts +37 -0
- package/src/shared/export.ts +31 -0
- package/src/shared/html/policy.ts +108 -0
- package/src/shared/html/style-vocabulary.ts +352 -0
- package/src/shared/logging/logger.ts +108 -0
- package/src/shared/logging/redact.ts +49 -0
- package/src/shared/security/frozen-csp.ts +13 -0
- package/src/shared/storage-version.ts +2 -0
- package/src/shared/tsx/execution.ts +29 -0
- package/src/shared/tsx/import-policy.ts +94 -0
- package/src/shared/util/dir-permissions.ts +94 -0
- package/src/shared/util/mermaid-nodes.ts +230 -0
- package/src/shared/util/process.ts +67 -0
- package/src/shared/util/time.ts +21 -0
- package/src/shared/version.ts +3 -0
- package/src/validation/sandbox/limits.ts +41 -0
- package/src/validation/sandbox/netns.ts +177 -0
- package/src/validation/tier0/chart.ts +177 -0
- package/src/validation/tier0/dom-shim.ts +54 -0
- package/src/validation/tier0/html.ts +408 -0
- package/src/validation/tier0/markdown.ts +285 -0
- package/src/validation/tier0/mermaid.ts +98 -0
- package/src/validation/tier0/runner.ts +504 -0
- package/src/validation/tier0/svg.ts +321 -0
- package/src/validation/tier0/tsx/allowlist-resolver.ts +77 -0
- package/src/validation/tier0/tsx/ast-policy-capabilities.ts +238 -0
- package/src/validation/tier0/tsx/ast-policy-shared.ts +71 -0
- package/src/validation/tier0/tsx/ast-policy.ts +181 -0
- package/src/validation/tier0/tsx/compiler.ts +156 -0
- package/src/validation/tier0/worker-dispatch.ts +211 -0
- package/src/validation/tier0/worker-entry.ts +96 -0
- package/src/validation/tier0/worker-input.ts +75 -0
- package/src/validation/tier1/browser-process.ts +147 -0
- package/src/validation/tier1/cdp-pipe.ts +281 -0
- package/src/validation/tier1/entries/chart.ts +5 -0
- package/src/validation/tier1/entries/html.ts +6 -0
- package/src/validation/tier1/entries/markdown.ts +5 -0
- package/src/validation/tier1/entries/mermaid.ts +5 -0
- package/src/validation/tier1/entries/svg.ts +5 -0
- package/src/validation/tier1/entries/tsx.ts +5 -0
- package/src/validation/tier1/frame-target.ts +162 -0
- package/src/validation/tier1/harness-entry.ts +261 -0
- package/src/validation/tier1/harness.ts +215 -0
- package/src/validation/tier1/isolated-probe.ts +94 -0
- package/src/validation/tier1/launcher.ts +177 -0
- package/src/validation/tier1/limits.ts +80 -0
- package/src/validation/tier1/nonce.ts +17 -0
- package/src/validation/tier1/protocol-probe.ts +519 -0
- package/src/validation/tier1/runner.ts +1122 -0
- package/src/validation/tier1/verdict.ts +246 -0
- package/src/validation/tier1/webp.ts +69 -0
- package/templates/README.md +88 -0
- package/templates/bar-compare.vl.json +63 -0
- package/templates/capacity-report.tsx +102 -0
- package/templates/decision-record.md +24 -0
- package/templates/deployment-state.mmd +40 -0
- package/templates/exemplar.md +91 -0
- package/templates/facet-story.tsx +799 -0
- package/templates/fleet-dashboard.html +141 -0
- package/templates/html-release-ledger.html +91 -0
- package/templates/html-status-report.html +114 -0
- package/templates/incident-console.tsx +147 -0
- package/templates/legion-boundaries.mmd +23 -0
- package/templates/legion-flow.mmd +15 -0
- package/templates/legion-sequence.mmd +14 -0
- package/templates/legion-state.mmd +7 -0
- package/templates/metric-card.svg +29 -0
- package/templates/observability-map.svg +101 -0
- package/templates/pipeline-audit.md +108 -0
- package/templates/release-metrics.vl.json +98 -0
- package/templates/service-topology.mmd +47 -0
- package/templates/status-report.md +32 -0
- package/templates/system-map.svg +53 -0
- package/templates/timeseries.vl.json +71 -0
- package/templates/tsx-interactive-counter.tsx +19 -0
- package/templates/tsx-status-report.tsx +31 -0
|
@@ -0,0 +1,1347 @@
|
|
|
1
|
+
import {
|
|
2
|
+
populateCommonDb
|
|
3
|
+
} from "./markdown-b4s7ntq2.js";
|
|
4
|
+
import {
|
|
5
|
+
parse
|
|
6
|
+
} from "./markdown-ceefymn8.js";
|
|
7
|
+
import {
|
|
8
|
+
ImperativeState
|
|
9
|
+
} from "./markdown-7jp6prnb.js";
|
|
10
|
+
import"./markdown-gx1p0ew0.js";
|
|
11
|
+
import"./markdown-pxfeh231.js";
|
|
12
|
+
import"./markdown-y18mve73.js";
|
|
13
|
+
import"./markdown-2x113yh8.js";
|
|
14
|
+
import"./markdown-56enrf2r.js";
|
|
15
|
+
import"./markdown-ag2sssf8.js";
|
|
16
|
+
import"./markdown-tnmabqvz.js";
|
|
17
|
+
import"./markdown-hab789t9.js";
|
|
18
|
+
import"./markdown-gxye5frz.js";
|
|
19
|
+
import"./markdown-k8xkn8mw.js";
|
|
20
|
+
import"./markdown-p740v4qm.js";
|
|
21
|
+
import"./markdown-ffg06nfz.js";
|
|
22
|
+
import"./markdown-w6sgd54z.js";
|
|
23
|
+
import"./markdown-rawhfvvc.js";
|
|
24
|
+
import"./markdown-v14td68x.js";
|
|
25
|
+
import"./markdown-dz3z5w30.js";
|
|
26
|
+
import {
|
|
27
|
+
cleanAndMerge,
|
|
28
|
+
random,
|
|
29
|
+
utils_default
|
|
30
|
+
} from "./markdown-ff5wvb43.js";
|
|
31
|
+
import"./markdown-pzgd8z3s.js";
|
|
32
|
+
import {
|
|
33
|
+
clear,
|
|
34
|
+
common_default,
|
|
35
|
+
defaultConfig_default,
|
|
36
|
+
getAccDescription,
|
|
37
|
+
getAccTitle,
|
|
38
|
+
getConfig,
|
|
39
|
+
getConfig2,
|
|
40
|
+
getDiagramTitle,
|
|
41
|
+
setAccDescription,
|
|
42
|
+
setAccTitle,
|
|
43
|
+
setDiagramTitle,
|
|
44
|
+
setupGraphViewbox2
|
|
45
|
+
} from "./markdown-92n37gd4.js";
|
|
46
|
+
import {
|
|
47
|
+
log,
|
|
48
|
+
select_default
|
|
49
|
+
} from "./markdown-xw8dsk8b.js";
|
|
50
|
+
import {
|
|
51
|
+
__name
|
|
52
|
+
} from "./markdown-1s5vwkf2.js";
|
|
53
|
+
import"./markdown-dy5sgjhc.js";
|
|
54
|
+
import"./markdown-809k7q41.js";
|
|
55
|
+
|
|
56
|
+
// node_modules/mermaid/dist/chunks/mermaid.core/gitGraphDiagram-DS77QQ5N.mjs
|
|
57
|
+
var commitType = {
|
|
58
|
+
NORMAL: 0,
|
|
59
|
+
REVERSE: 1,
|
|
60
|
+
HIGHLIGHT: 2,
|
|
61
|
+
MERGE: 3,
|
|
62
|
+
CHERRY_PICK: 4
|
|
63
|
+
};
|
|
64
|
+
var DEFAULT_GITGRAPH_CONFIG = defaultConfig_default.gitGraph;
|
|
65
|
+
var getConfig3 = /* @__PURE__ */ __name(() => {
|
|
66
|
+
const config = cleanAndMerge({
|
|
67
|
+
...DEFAULT_GITGRAPH_CONFIG,
|
|
68
|
+
...getConfig().gitGraph
|
|
69
|
+
});
|
|
70
|
+
return config;
|
|
71
|
+
}, "getConfig");
|
|
72
|
+
var state = new ImperativeState(() => {
|
|
73
|
+
const config = getConfig3();
|
|
74
|
+
const mainBranchName = config.mainBranchName;
|
|
75
|
+
const mainBranchOrder = config.mainBranchOrder;
|
|
76
|
+
return {
|
|
77
|
+
mainBranchName,
|
|
78
|
+
commits: /* @__PURE__ */ new Map,
|
|
79
|
+
head: null,
|
|
80
|
+
branchConfig: /* @__PURE__ */ new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]),
|
|
81
|
+
branches: /* @__PURE__ */ new Map([[mainBranchName, null]]),
|
|
82
|
+
currBranch: mainBranchName,
|
|
83
|
+
direction: "LR",
|
|
84
|
+
seq: 0,
|
|
85
|
+
options: {}
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
function getID() {
|
|
89
|
+
return random({ length: 7 });
|
|
90
|
+
}
|
|
91
|
+
__name(getID, "getID");
|
|
92
|
+
function uniqBy(list, fn) {
|
|
93
|
+
const recordMap = /* @__PURE__ */ Object.create(null);
|
|
94
|
+
return list.reduce((out, item) => {
|
|
95
|
+
const key = fn(item);
|
|
96
|
+
if (!recordMap[key]) {
|
|
97
|
+
recordMap[key] = true;
|
|
98
|
+
out.push(item);
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}, []);
|
|
102
|
+
}
|
|
103
|
+
__name(uniqBy, "uniqBy");
|
|
104
|
+
var setDirection = /* @__PURE__ */ __name(function(dir2) {
|
|
105
|
+
state.records.direction = dir2;
|
|
106
|
+
}, "setDirection");
|
|
107
|
+
var setOptions = /* @__PURE__ */ __name(function(rawOptString) {
|
|
108
|
+
log.debug("options str", rawOptString);
|
|
109
|
+
rawOptString = rawOptString?.trim();
|
|
110
|
+
rawOptString = rawOptString || "{}";
|
|
111
|
+
try {
|
|
112
|
+
state.records.options = JSON.parse(rawOptString);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
log.error("error while parsing gitGraph options", e.message);
|
|
115
|
+
}
|
|
116
|
+
}, "setOptions");
|
|
117
|
+
var getOptions = /* @__PURE__ */ __name(function() {
|
|
118
|
+
return state.records.options;
|
|
119
|
+
}, "getOptions");
|
|
120
|
+
var commit = /* @__PURE__ */ __name(function(commitDB) {
|
|
121
|
+
let msg = commitDB.msg;
|
|
122
|
+
let id = commitDB.id;
|
|
123
|
+
const type = commitDB.type;
|
|
124
|
+
let tags = commitDB.tags;
|
|
125
|
+
log.info("commit", msg, id, type, tags);
|
|
126
|
+
log.debug("Entering commit:", msg, id, type, tags);
|
|
127
|
+
const config = getConfig3();
|
|
128
|
+
id = common_default.sanitizeText(id, config);
|
|
129
|
+
msg = common_default.sanitizeText(msg, config);
|
|
130
|
+
tags = tags?.map((tag) => common_default.sanitizeText(tag, config));
|
|
131
|
+
const newCommit = {
|
|
132
|
+
id: id ? id : state.records.seq + "-" + getID(),
|
|
133
|
+
message: msg,
|
|
134
|
+
seq: state.records.seq++,
|
|
135
|
+
type: type ?? commitType.NORMAL,
|
|
136
|
+
tags: tags ?? [],
|
|
137
|
+
parents: state.records.head == null ? [] : [state.records.head.id],
|
|
138
|
+
branch: state.records.currBranch
|
|
139
|
+
};
|
|
140
|
+
state.records.head = newCommit;
|
|
141
|
+
log.info("main branch", config.mainBranchName);
|
|
142
|
+
if (state.records.commits.has(newCommit.id)) {
|
|
143
|
+
log.warn(`Commit ID ${newCommit.id} already exists`);
|
|
144
|
+
}
|
|
145
|
+
state.records.commits.set(newCommit.id, newCommit);
|
|
146
|
+
state.records.branches.set(state.records.currBranch, newCommit.id);
|
|
147
|
+
log.debug("in pushCommit " + newCommit.id);
|
|
148
|
+
}, "commit");
|
|
149
|
+
var branch = /* @__PURE__ */ __name(function(branchDB) {
|
|
150
|
+
let name = branchDB.name;
|
|
151
|
+
const order = branchDB.order;
|
|
152
|
+
name = common_default.sanitizeText(name, getConfig3());
|
|
153
|
+
if (state.records.branches.has(name)) {
|
|
154
|
+
throw new Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")`);
|
|
155
|
+
}
|
|
156
|
+
state.records.branches.set(name, state.records.head != null ? state.records.head.id : null);
|
|
157
|
+
state.records.branchConfig.set(name, { name, order });
|
|
158
|
+
checkout(name);
|
|
159
|
+
log.debug("in createBranch");
|
|
160
|
+
}, "branch");
|
|
161
|
+
var merge = /* @__PURE__ */ __name((mergeDB) => {
|
|
162
|
+
let otherBranch = mergeDB.branch;
|
|
163
|
+
let customId = mergeDB.id;
|
|
164
|
+
const overrideType = mergeDB.type;
|
|
165
|
+
const customTags = mergeDB.tags;
|
|
166
|
+
const config = getConfig3();
|
|
167
|
+
otherBranch = common_default.sanitizeText(otherBranch, config);
|
|
168
|
+
if (customId) {
|
|
169
|
+
customId = common_default.sanitizeText(customId, config);
|
|
170
|
+
}
|
|
171
|
+
const currentBranchCheck = state.records.branches.get(state.records.currBranch);
|
|
172
|
+
const otherBranchCheck = state.records.branches.get(otherBranch);
|
|
173
|
+
const currentCommit = currentBranchCheck ? state.records.commits.get(currentBranchCheck) : undefined;
|
|
174
|
+
const otherCommit = otherBranchCheck ? state.records.commits.get(otherBranchCheck) : undefined;
|
|
175
|
+
if (currentCommit && otherCommit && currentCommit.branch === otherBranch) {
|
|
176
|
+
throw new Error(`Cannot merge branch '${otherBranch}' into itself.`);
|
|
177
|
+
}
|
|
178
|
+
if (state.records.currBranch === otherBranch) {
|
|
179
|
+
const error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself');
|
|
180
|
+
error.hash = {
|
|
181
|
+
text: `merge ${otherBranch}`,
|
|
182
|
+
token: `merge ${otherBranch}`,
|
|
183
|
+
expected: ["branch abc"]
|
|
184
|
+
};
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
if (currentCommit === undefined || !currentCommit) {
|
|
188
|
+
const error = new Error(`Incorrect usage of "merge". Current branch (${state.records.currBranch})has no commits`);
|
|
189
|
+
error.hash = {
|
|
190
|
+
text: `merge ${otherBranch}`,
|
|
191
|
+
token: `merge ${otherBranch}`,
|
|
192
|
+
expected: ["commit"]
|
|
193
|
+
};
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
if (!state.records.branches.has(otherBranch)) {
|
|
197
|
+
const error = new Error('Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") does not exist");
|
|
198
|
+
error.hash = {
|
|
199
|
+
text: `merge ${otherBranch}`,
|
|
200
|
+
token: `merge ${otherBranch}`,
|
|
201
|
+
expected: [`branch ${otherBranch}`]
|
|
202
|
+
};
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
if (otherCommit === undefined || !otherCommit) {
|
|
206
|
+
const error = new Error('Incorrect usage of "merge". Branch to be merged (' + otherBranch + ") has no commits");
|
|
207
|
+
error.hash = {
|
|
208
|
+
text: `merge ${otherBranch}`,
|
|
209
|
+
token: `merge ${otherBranch}`,
|
|
210
|
+
expected: ['"commit"']
|
|
211
|
+
};
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
if (currentCommit === otherCommit) {
|
|
215
|
+
const error = new Error('Incorrect usage of "merge". Both branches have same head');
|
|
216
|
+
error.hash = {
|
|
217
|
+
text: `merge ${otherBranch}`,
|
|
218
|
+
token: `merge ${otherBranch}`,
|
|
219
|
+
expected: ["branch abc"]
|
|
220
|
+
};
|
|
221
|
+
throw error;
|
|
222
|
+
}
|
|
223
|
+
if (customId && state.records.commits.has(customId)) {
|
|
224
|
+
const error = new Error('Incorrect usage of "merge". Commit with id:' + customId + " already exists, use different custom id");
|
|
225
|
+
error.hash = {
|
|
226
|
+
text: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(" ")}`,
|
|
227
|
+
token: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(" ")}`,
|
|
228
|
+
expected: [
|
|
229
|
+
`merge ${otherBranch} ${customId}_UNIQUE ${overrideType} ${customTags?.join(" ")}`
|
|
230
|
+
]
|
|
231
|
+
};
|
|
232
|
+
throw error;
|
|
233
|
+
}
|
|
234
|
+
const verifiedBranch = otherBranchCheck ? otherBranchCheck : "";
|
|
235
|
+
const commit2 = {
|
|
236
|
+
id: customId || `${state.records.seq}-${getID()}`,
|
|
237
|
+
message: `merged branch ${otherBranch} into ${state.records.currBranch}`,
|
|
238
|
+
seq: state.records.seq++,
|
|
239
|
+
parents: state.records.head == null ? [] : [state.records.head.id, verifiedBranch],
|
|
240
|
+
branch: state.records.currBranch,
|
|
241
|
+
type: commitType.MERGE,
|
|
242
|
+
customType: overrideType,
|
|
243
|
+
customId: customId ? true : false,
|
|
244
|
+
tags: customTags ?? []
|
|
245
|
+
};
|
|
246
|
+
state.records.head = commit2;
|
|
247
|
+
state.records.commits.set(commit2.id, commit2);
|
|
248
|
+
state.records.branches.set(state.records.currBranch, commit2.id);
|
|
249
|
+
log.debug(state.records.branches);
|
|
250
|
+
log.debug("in mergeBranch");
|
|
251
|
+
}, "merge");
|
|
252
|
+
var cherryPick = /* @__PURE__ */ __name(function(cherryPickDB) {
|
|
253
|
+
let sourceId = cherryPickDB.id;
|
|
254
|
+
let targetId = cherryPickDB.targetId;
|
|
255
|
+
let tags = cherryPickDB.tags;
|
|
256
|
+
let parentCommitId = cherryPickDB.parent;
|
|
257
|
+
log.debug("Entering cherryPick:", sourceId, targetId, tags);
|
|
258
|
+
const config = getConfig3();
|
|
259
|
+
sourceId = common_default.sanitizeText(sourceId, config);
|
|
260
|
+
targetId = common_default.sanitizeText(targetId, config);
|
|
261
|
+
tags = tags?.map((tag) => common_default.sanitizeText(tag, config));
|
|
262
|
+
parentCommitId = common_default.sanitizeText(parentCommitId, config);
|
|
263
|
+
if (!sourceId || !state.records.commits.has(sourceId)) {
|
|
264
|
+
const error = new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');
|
|
265
|
+
error.hash = {
|
|
266
|
+
text: `cherryPick ${sourceId} ${targetId}`,
|
|
267
|
+
token: `cherryPick ${sourceId} ${targetId}`,
|
|
268
|
+
expected: ["cherry-pick abc"]
|
|
269
|
+
};
|
|
270
|
+
throw error;
|
|
271
|
+
}
|
|
272
|
+
const sourceCommit = state.records.commits.get(sourceId);
|
|
273
|
+
if (sourceCommit === undefined || !sourceCommit) {
|
|
274
|
+
throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided');
|
|
275
|
+
}
|
|
276
|
+
if (parentCommitId && !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId))) {
|
|
277
|
+
const error = new Error("Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.");
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
const sourceCommitBranch = sourceCommit.branch;
|
|
281
|
+
if (sourceCommit.type === commitType.MERGE && !parentCommitId) {
|
|
282
|
+
const error = new Error("Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.");
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
if (!targetId || !state.records.commits.has(targetId)) {
|
|
286
|
+
if (sourceCommitBranch === state.records.currBranch) {
|
|
287
|
+
const error = new Error('Incorrect usage of "cherryPick". Source commit is already on current branch');
|
|
288
|
+
error.hash = {
|
|
289
|
+
text: `cherryPick ${sourceId} ${targetId}`,
|
|
290
|
+
token: `cherryPick ${sourceId} ${targetId}`,
|
|
291
|
+
expected: ["cherry-pick abc"]
|
|
292
|
+
};
|
|
293
|
+
throw error;
|
|
294
|
+
}
|
|
295
|
+
const currentCommitId = state.records.branches.get(state.records.currBranch);
|
|
296
|
+
if (currentCommitId === undefined || !currentCommitId) {
|
|
297
|
+
const error = new Error(`Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits`);
|
|
298
|
+
error.hash = {
|
|
299
|
+
text: `cherryPick ${sourceId} ${targetId}`,
|
|
300
|
+
token: `cherryPick ${sourceId} ${targetId}`,
|
|
301
|
+
expected: ["cherry-pick abc"]
|
|
302
|
+
};
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
const currentCommit = state.records.commits.get(currentCommitId);
|
|
306
|
+
if (currentCommit === undefined || !currentCommit) {
|
|
307
|
+
const error = new Error(`Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits`);
|
|
308
|
+
error.hash = {
|
|
309
|
+
text: `cherryPick ${sourceId} ${targetId}`,
|
|
310
|
+
token: `cherryPick ${sourceId} ${targetId}`,
|
|
311
|
+
expected: ["cherry-pick abc"]
|
|
312
|
+
};
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
const commit2 = {
|
|
316
|
+
id: state.records.seq + "-" + getID(),
|
|
317
|
+
message: `cherry-picked ${sourceCommit?.message} into ${state.records.currBranch}`,
|
|
318
|
+
seq: state.records.seq++,
|
|
319
|
+
parents: state.records.head == null ? [] : [state.records.head.id, sourceCommit.id],
|
|
320
|
+
branch: state.records.currBranch,
|
|
321
|
+
type: commitType.CHERRY_PICK,
|
|
322
|
+
tags: tags ? tags.filter(Boolean) : [
|
|
323
|
+
`cherry-pick:${sourceCommit.id}${sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : ""}`
|
|
324
|
+
]
|
|
325
|
+
};
|
|
326
|
+
state.records.head = commit2;
|
|
327
|
+
state.records.commits.set(commit2.id, commit2);
|
|
328
|
+
state.records.branches.set(state.records.currBranch, commit2.id);
|
|
329
|
+
log.debug(state.records.branches);
|
|
330
|
+
log.debug("in cherryPick");
|
|
331
|
+
}
|
|
332
|
+
}, "cherryPick");
|
|
333
|
+
var checkout = /* @__PURE__ */ __name(function(branch2) {
|
|
334
|
+
branch2 = common_default.sanitizeText(branch2, getConfig3());
|
|
335
|
+
if (!state.records.branches.has(branch2)) {
|
|
336
|
+
const error = new Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${branch2}")`);
|
|
337
|
+
error.hash = {
|
|
338
|
+
text: `checkout ${branch2}`,
|
|
339
|
+
token: `checkout ${branch2}`,
|
|
340
|
+
expected: [`branch ${branch2}`]
|
|
341
|
+
};
|
|
342
|
+
throw error;
|
|
343
|
+
} else {
|
|
344
|
+
state.records.currBranch = branch2;
|
|
345
|
+
const id = state.records.branches.get(state.records.currBranch);
|
|
346
|
+
if (id === undefined || !id) {
|
|
347
|
+
state.records.head = null;
|
|
348
|
+
} else {
|
|
349
|
+
state.records.head = state.records.commits.get(id) ?? null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}, "checkout");
|
|
353
|
+
function upsert(arr, key, newVal) {
|
|
354
|
+
const index = arr.indexOf(key);
|
|
355
|
+
if (index === -1) {
|
|
356
|
+
arr.push(newVal);
|
|
357
|
+
} else {
|
|
358
|
+
arr.splice(index, 1, newVal);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
__name(upsert, "upsert");
|
|
362
|
+
function prettyPrintCommitHistory(commitArr) {
|
|
363
|
+
const commit2 = commitArr.reduce((out, commit3) => {
|
|
364
|
+
if (out.seq > commit3.seq) {
|
|
365
|
+
return out;
|
|
366
|
+
}
|
|
367
|
+
return commit3;
|
|
368
|
+
}, commitArr[0]);
|
|
369
|
+
let line = "";
|
|
370
|
+
commitArr.forEach(function(c) {
|
|
371
|
+
if (c === commit2) {
|
|
372
|
+
line += "\t*";
|
|
373
|
+
} else {
|
|
374
|
+
line += "\t|";
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
const label = [line, commit2.id, commit2.seq];
|
|
378
|
+
for (const branch2 in state.records.branches) {
|
|
379
|
+
if (state.records.branches.get(branch2) === commit2.id) {
|
|
380
|
+
label.push(branch2);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
log.debug(label.join(" "));
|
|
384
|
+
if (commit2.parents && commit2.parents.length == 2 && commit2.parents[0] && commit2.parents[1]) {
|
|
385
|
+
const newCommit = state.records.commits.get(commit2.parents[0]);
|
|
386
|
+
upsert(commitArr, commit2, newCommit);
|
|
387
|
+
if (commit2.parents[1]) {
|
|
388
|
+
commitArr.push(state.records.commits.get(commit2.parents[1]));
|
|
389
|
+
}
|
|
390
|
+
} else if (commit2.parents.length == 0) {
|
|
391
|
+
return;
|
|
392
|
+
} else {
|
|
393
|
+
if (commit2.parents[0]) {
|
|
394
|
+
const newCommit = state.records.commits.get(commit2.parents[0]);
|
|
395
|
+
upsert(commitArr, commit2, newCommit);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
commitArr = uniqBy(commitArr, (c) => c.id);
|
|
399
|
+
prettyPrintCommitHistory(commitArr);
|
|
400
|
+
}
|
|
401
|
+
__name(prettyPrintCommitHistory, "prettyPrintCommitHistory");
|
|
402
|
+
var prettyPrint = /* @__PURE__ */ __name(function() {
|
|
403
|
+
log.debug(state.records.commits);
|
|
404
|
+
const node = getCommitsArray()[0];
|
|
405
|
+
prettyPrintCommitHistory([node]);
|
|
406
|
+
}, "prettyPrint");
|
|
407
|
+
var clear2 = /* @__PURE__ */ __name(function() {
|
|
408
|
+
state.reset();
|
|
409
|
+
clear();
|
|
410
|
+
}, "clear");
|
|
411
|
+
var getBranchesAsObjArray = /* @__PURE__ */ __name(function() {
|
|
412
|
+
const branchesArray = [...state.records.branchConfig.values()].map((branchConfig, i) => {
|
|
413
|
+
if (branchConfig.order !== null && branchConfig.order !== undefined) {
|
|
414
|
+
return branchConfig;
|
|
415
|
+
}
|
|
416
|
+
return {
|
|
417
|
+
...branchConfig,
|
|
418
|
+
order: parseFloat(`0.${i}`)
|
|
419
|
+
};
|
|
420
|
+
}).sort((a, b) => (a.order ?? 0) - (b.order ?? 0)).map(({ name }) => ({ name }));
|
|
421
|
+
return branchesArray;
|
|
422
|
+
}, "getBranchesAsObjArray");
|
|
423
|
+
var getBranches = /* @__PURE__ */ __name(function() {
|
|
424
|
+
return state.records.branches;
|
|
425
|
+
}, "getBranches");
|
|
426
|
+
var getCommits = /* @__PURE__ */ __name(function() {
|
|
427
|
+
return state.records.commits;
|
|
428
|
+
}, "getCommits");
|
|
429
|
+
var getCommitsArray = /* @__PURE__ */ __name(function() {
|
|
430
|
+
const commitArr = [...state.records.commits.values()];
|
|
431
|
+
commitArr.forEach(function(o) {
|
|
432
|
+
log.debug(o.id);
|
|
433
|
+
});
|
|
434
|
+
commitArr.sort((a, b) => a.seq - b.seq);
|
|
435
|
+
return commitArr;
|
|
436
|
+
}, "getCommitsArray");
|
|
437
|
+
var getCurrentBranch = /* @__PURE__ */ __name(function() {
|
|
438
|
+
return state.records.currBranch;
|
|
439
|
+
}, "getCurrentBranch");
|
|
440
|
+
var getDirection = /* @__PURE__ */ __name(function() {
|
|
441
|
+
return state.records.direction;
|
|
442
|
+
}, "getDirection");
|
|
443
|
+
var getHead = /* @__PURE__ */ __name(function() {
|
|
444
|
+
return state.records.head;
|
|
445
|
+
}, "getHead");
|
|
446
|
+
var db = {
|
|
447
|
+
commitType,
|
|
448
|
+
getConfig: getConfig3,
|
|
449
|
+
setDirection,
|
|
450
|
+
setOptions,
|
|
451
|
+
getOptions,
|
|
452
|
+
commit,
|
|
453
|
+
branch,
|
|
454
|
+
merge,
|
|
455
|
+
cherryPick,
|
|
456
|
+
checkout,
|
|
457
|
+
prettyPrint,
|
|
458
|
+
clear: clear2,
|
|
459
|
+
getBranchesAsObjArray,
|
|
460
|
+
getBranches,
|
|
461
|
+
getCommits,
|
|
462
|
+
getCommitsArray,
|
|
463
|
+
getCurrentBranch,
|
|
464
|
+
getDirection,
|
|
465
|
+
getHead,
|
|
466
|
+
setAccTitle,
|
|
467
|
+
getAccTitle,
|
|
468
|
+
getAccDescription,
|
|
469
|
+
setAccDescription,
|
|
470
|
+
setDiagramTitle,
|
|
471
|
+
getDiagramTitle
|
|
472
|
+
};
|
|
473
|
+
var populate = /* @__PURE__ */ __name((ast, db2) => {
|
|
474
|
+
populateCommonDb(ast, db2);
|
|
475
|
+
if (ast.dir) {
|
|
476
|
+
db2.setDirection(ast.dir);
|
|
477
|
+
}
|
|
478
|
+
for (const statement of ast.statements) {
|
|
479
|
+
parseStatement(statement, db2);
|
|
480
|
+
}
|
|
481
|
+
}, "populate");
|
|
482
|
+
var parseStatement = /* @__PURE__ */ __name((statement, db2) => {
|
|
483
|
+
const parsers = {
|
|
484
|
+
Commit: /* @__PURE__ */ __name((stmt) => db2.commit(parseCommit(stmt)), "Commit"),
|
|
485
|
+
Branch: /* @__PURE__ */ __name((stmt) => db2.branch(parseBranch(stmt)), "Branch"),
|
|
486
|
+
Merge: /* @__PURE__ */ __name((stmt) => db2.merge(parseMerge(stmt)), "Merge"),
|
|
487
|
+
Checkout: /* @__PURE__ */ __name((stmt) => db2.checkout(parseCheckout(stmt)), "Checkout"),
|
|
488
|
+
CherryPicking: /* @__PURE__ */ __name((stmt) => db2.cherryPick(parseCherryPicking(stmt)), "CherryPicking")
|
|
489
|
+
};
|
|
490
|
+
const parser2 = parsers[statement.$type];
|
|
491
|
+
if (parser2) {
|
|
492
|
+
parser2(statement);
|
|
493
|
+
} else {
|
|
494
|
+
log.error(`Unknown statement type: ${statement.$type}`);
|
|
495
|
+
}
|
|
496
|
+
}, "parseStatement");
|
|
497
|
+
var parseCommit = /* @__PURE__ */ __name((commit2) => {
|
|
498
|
+
const commitDB = {
|
|
499
|
+
id: commit2.id,
|
|
500
|
+
msg: commit2.message ?? "",
|
|
501
|
+
type: commit2.type !== undefined ? commitType[commit2.type] : commitType.NORMAL,
|
|
502
|
+
tags: commit2.tags ?? undefined
|
|
503
|
+
};
|
|
504
|
+
return commitDB;
|
|
505
|
+
}, "parseCommit");
|
|
506
|
+
var parseBranch = /* @__PURE__ */ __name((branch2) => {
|
|
507
|
+
const branchDB = {
|
|
508
|
+
name: branch2.name,
|
|
509
|
+
order: branch2.order ?? 0
|
|
510
|
+
};
|
|
511
|
+
return branchDB;
|
|
512
|
+
}, "parseBranch");
|
|
513
|
+
var parseMerge = /* @__PURE__ */ __name((merge2) => {
|
|
514
|
+
const mergeDB = {
|
|
515
|
+
branch: merge2.branch,
|
|
516
|
+
id: merge2.id ?? "",
|
|
517
|
+
type: merge2.type !== undefined ? commitType[merge2.type] : undefined,
|
|
518
|
+
tags: merge2.tags ?? undefined
|
|
519
|
+
};
|
|
520
|
+
return mergeDB;
|
|
521
|
+
}, "parseMerge");
|
|
522
|
+
var parseCheckout = /* @__PURE__ */ __name((checkout2) => {
|
|
523
|
+
const branch2 = checkout2.branch;
|
|
524
|
+
return branch2;
|
|
525
|
+
}, "parseCheckout");
|
|
526
|
+
var parseCherryPicking = /* @__PURE__ */ __name((cherryPicking) => {
|
|
527
|
+
const cherryPickDB = {
|
|
528
|
+
id: cherryPicking.id,
|
|
529
|
+
targetId: "",
|
|
530
|
+
tags: cherryPicking.tags?.length === 0 ? undefined : cherryPicking.tags,
|
|
531
|
+
parent: cherryPicking.parent
|
|
532
|
+
};
|
|
533
|
+
return cherryPickDB;
|
|
534
|
+
}, "parseCherryPicking");
|
|
535
|
+
var parser = {
|
|
536
|
+
parse: /* @__PURE__ */ __name(async (input) => {
|
|
537
|
+
const ast = await parse("gitGraph", input);
|
|
538
|
+
log.debug(ast);
|
|
539
|
+
populate(ast, db);
|
|
540
|
+
}, "parse")
|
|
541
|
+
};
|
|
542
|
+
if (undefined) {}
|
|
543
|
+
var LAYOUT_OFFSET = 10;
|
|
544
|
+
var COMMIT_STEP = 40;
|
|
545
|
+
var PX = 4;
|
|
546
|
+
var PY = 2;
|
|
547
|
+
var THEME_COLOR_LIMIT = 8;
|
|
548
|
+
var REDUX_GEOMETRY_THEMES = /* @__PURE__ */ new Set(["redux", "redux-dark", "redux-color", "redux-dark-color"]);
|
|
549
|
+
var REDUX_BRANCH_LABEL_PADDING_Y = 12;
|
|
550
|
+
var COLOR_THEMES = /* @__PURE__ */ new Set(["redux-color", "redux-dark-color"]);
|
|
551
|
+
var DARK_THEMES = /* @__PURE__ */ new Set(["dark", "redux-dark", "redux-dark-color", "neo-dark"]);
|
|
552
|
+
var calcColorIndex = /* @__PURE__ */ __name((rawIndex, limit, avoidDefaultColor = false) => {
|
|
553
|
+
if (avoidDefaultColor && rawIndex > 0) {
|
|
554
|
+
return (rawIndex - 1) % (limit - 1) + 1;
|
|
555
|
+
}
|
|
556
|
+
return rawIndex % limit;
|
|
557
|
+
}, "calcColorIndex");
|
|
558
|
+
var branchPos = /* @__PURE__ */ new Map;
|
|
559
|
+
var commitPos = /* @__PURE__ */ new Map;
|
|
560
|
+
var defaultPos = 30;
|
|
561
|
+
var allCommitsDict = /* @__PURE__ */ new Map;
|
|
562
|
+
var lanes = [];
|
|
563
|
+
var maxPos = 0;
|
|
564
|
+
var dir = "LR";
|
|
565
|
+
var clear3 = /* @__PURE__ */ __name(() => {
|
|
566
|
+
branchPos.clear();
|
|
567
|
+
commitPos.clear();
|
|
568
|
+
allCommitsDict.clear();
|
|
569
|
+
maxPos = 0;
|
|
570
|
+
lanes = [];
|
|
571
|
+
dir = "LR";
|
|
572
|
+
}, "clear");
|
|
573
|
+
var drawText = /* @__PURE__ */ __name((txt) => {
|
|
574
|
+
const svgLabel = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
575
|
+
const rows = typeof txt === "string" ? txt.split(/\\n|\n|<br\s*\/?>/gi) : txt;
|
|
576
|
+
rows.forEach((row) => {
|
|
577
|
+
const tspan = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
|
578
|
+
tspan.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
|
|
579
|
+
tspan.setAttribute("dy", "1em");
|
|
580
|
+
tspan.setAttribute("x", "0");
|
|
581
|
+
tspan.setAttribute("class", "row");
|
|
582
|
+
tspan.textContent = row.trim();
|
|
583
|
+
svgLabel.appendChild(tspan);
|
|
584
|
+
});
|
|
585
|
+
return svgLabel;
|
|
586
|
+
}, "drawText");
|
|
587
|
+
var findClosestParent = /* @__PURE__ */ __name((parents) => {
|
|
588
|
+
let closestParent;
|
|
589
|
+
let comparisonFunc;
|
|
590
|
+
let targetPosition;
|
|
591
|
+
if (dir === "BT") {
|
|
592
|
+
comparisonFunc = /* @__PURE__ */ __name((a, b) => a <= b, "comparisonFunc");
|
|
593
|
+
targetPosition = Infinity;
|
|
594
|
+
} else {
|
|
595
|
+
comparisonFunc = /* @__PURE__ */ __name((a, b) => a >= b, "comparisonFunc");
|
|
596
|
+
targetPosition = 0;
|
|
597
|
+
}
|
|
598
|
+
parents.forEach((parent) => {
|
|
599
|
+
const parentPosition = dir === "TB" || dir == "BT" ? commitPos.get(parent)?.y : commitPos.get(parent)?.x;
|
|
600
|
+
if (parentPosition !== undefined && comparisonFunc(parentPosition, targetPosition)) {
|
|
601
|
+
closestParent = parent;
|
|
602
|
+
targetPosition = parentPosition;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
return closestParent;
|
|
606
|
+
}, "findClosestParent");
|
|
607
|
+
var findClosestParentBT = /* @__PURE__ */ __name((parents) => {
|
|
608
|
+
let closestParent = "";
|
|
609
|
+
let maxPosition = Infinity;
|
|
610
|
+
parents.forEach((parent) => {
|
|
611
|
+
const parentPosition = commitPos.get(parent).y;
|
|
612
|
+
if (parentPosition <= maxPosition) {
|
|
613
|
+
closestParent = parent;
|
|
614
|
+
maxPosition = parentPosition;
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
return closestParent || undefined;
|
|
618
|
+
}, "findClosestParentBT");
|
|
619
|
+
var setParallelBTPos = /* @__PURE__ */ __name((sortedKeys, commits, defaultPos2) => {
|
|
620
|
+
let curPos = defaultPos2;
|
|
621
|
+
let maxPosition = defaultPos2;
|
|
622
|
+
const roots = [];
|
|
623
|
+
sortedKeys.forEach((key) => {
|
|
624
|
+
const commit2 = commits.get(key);
|
|
625
|
+
if (!commit2) {
|
|
626
|
+
throw new Error(`Commit not found for key ${key}`);
|
|
627
|
+
}
|
|
628
|
+
if (commit2.parents.length) {
|
|
629
|
+
curPos = calculateCommitPosition(commit2);
|
|
630
|
+
maxPosition = Math.max(curPos, maxPosition);
|
|
631
|
+
} else {
|
|
632
|
+
roots.push(commit2);
|
|
633
|
+
}
|
|
634
|
+
setCommitPosition(commit2, curPos);
|
|
635
|
+
});
|
|
636
|
+
curPos = maxPosition;
|
|
637
|
+
roots.forEach((commit2) => {
|
|
638
|
+
setRootPosition(commit2, curPos, defaultPos2);
|
|
639
|
+
});
|
|
640
|
+
sortedKeys.forEach((key) => {
|
|
641
|
+
const commit2 = commits.get(key);
|
|
642
|
+
if (commit2?.parents.length) {
|
|
643
|
+
const closestParent = findClosestParentBT(commit2.parents);
|
|
644
|
+
curPos = commitPos.get(closestParent).y - COMMIT_STEP;
|
|
645
|
+
if (curPos <= maxPosition) {
|
|
646
|
+
maxPosition = curPos;
|
|
647
|
+
}
|
|
648
|
+
const x = branchPos.get(commit2.branch).pos;
|
|
649
|
+
const y = curPos - LAYOUT_OFFSET;
|
|
650
|
+
commitPos.set(commit2.id, { x, y });
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
}, "setParallelBTPos");
|
|
654
|
+
var findClosestParentPos = /* @__PURE__ */ __name((commit2) => {
|
|
655
|
+
const closestParent = findClosestParent(commit2.parents.filter((p) => p !== null));
|
|
656
|
+
if (!closestParent) {
|
|
657
|
+
throw new Error(`Closest parent not found for commit ${commit2.id}`);
|
|
658
|
+
}
|
|
659
|
+
const closestParentPos = commitPos.get(closestParent)?.y;
|
|
660
|
+
if (closestParentPos === undefined) {
|
|
661
|
+
throw new Error(`Closest parent position not found for commit ${commit2.id}`);
|
|
662
|
+
}
|
|
663
|
+
return closestParentPos;
|
|
664
|
+
}, "findClosestParentPos");
|
|
665
|
+
var calculateCommitPosition = /* @__PURE__ */ __name((commit2) => {
|
|
666
|
+
const closestParentPos = findClosestParentPos(commit2);
|
|
667
|
+
return closestParentPos + COMMIT_STEP;
|
|
668
|
+
}, "calculateCommitPosition");
|
|
669
|
+
var setCommitPosition = /* @__PURE__ */ __name((commit2, curPos) => {
|
|
670
|
+
const branch2 = branchPos.get(commit2.branch);
|
|
671
|
+
if (!branch2) {
|
|
672
|
+
throw new Error(`Branch not found for commit ${commit2.id}`);
|
|
673
|
+
}
|
|
674
|
+
const x = branch2.pos;
|
|
675
|
+
const y = curPos + LAYOUT_OFFSET;
|
|
676
|
+
commitPos.set(commit2.id, { x, y });
|
|
677
|
+
return { x, y };
|
|
678
|
+
}, "setCommitPosition");
|
|
679
|
+
var setRootPosition = /* @__PURE__ */ __name((commit2, curPos, defaultPos2) => {
|
|
680
|
+
const branch2 = branchPos.get(commit2.branch);
|
|
681
|
+
if (!branch2) {
|
|
682
|
+
throw new Error(`Branch not found for commit ${commit2.id}`);
|
|
683
|
+
}
|
|
684
|
+
const y = curPos + defaultPos2;
|
|
685
|
+
const x = branch2.pos;
|
|
686
|
+
commitPos.set(commit2.id, { x, y });
|
|
687
|
+
}, "setRootPosition");
|
|
688
|
+
var drawCommitBullet = /* @__PURE__ */ __name((gBullets, commit2, commitPosition, typeClass, branchIndex, commitSymbolType) => {
|
|
689
|
+
const { theme } = getConfig2();
|
|
690
|
+
const useReduxGeometry = REDUX_GEOMETRY_THEMES.has(theme ?? "");
|
|
691
|
+
const useColorTheme = COLOR_THEMES.has(theme ?? "");
|
|
692
|
+
const isDark = DARK_THEMES.has(theme ?? "");
|
|
693
|
+
if (commitSymbolType === commitType.HIGHLIGHT) {
|
|
694
|
+
gBullets.append("rect").attr("x", commitPosition.x - 10 + (useReduxGeometry ? 3 : 0)).attr("y", commitPosition.y - 10 + (useReduxGeometry ? 3 : 0)).attr("width", useReduxGeometry ? 14 : 20).attr("height", useReduxGeometry ? 14 : 20).attr("class", `commit ${commit2.id} commit-highlight${calcColorIndex(branchIndex, THEME_COLOR_LIMIT, useColorTheme)} ${typeClass}-outer`);
|
|
695
|
+
gBullets.append("rect").attr("x", commitPosition.x - 6 + (useReduxGeometry ? 2 : 0)).attr("y", commitPosition.y - 6 + (useReduxGeometry ? 2 : 0)).attr("width", useReduxGeometry ? 8 : 12).attr("height", useReduxGeometry ? 8 : 12).attr("class", `commit ${commit2.id} commit${calcColorIndex(branchIndex, THEME_COLOR_LIMIT, useColorTheme)} ${typeClass}-inner`);
|
|
696
|
+
} else if (commitSymbolType === commitType.CHERRY_PICK) {
|
|
697
|
+
gBullets.append("circle").attr("cx", commitPosition.x).attr("cy", commitPosition.y).attr("r", useReduxGeometry ? 7 : 10).attr("class", `commit ${commit2.id} ${typeClass}`);
|
|
698
|
+
gBullets.append("circle").attr("cx", commitPosition.x - 3).attr("cy", commitPosition.y + 2).attr("r", useReduxGeometry ? 2.5 : 2.75).attr("fill", isDark ? "#000000" : "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
|
|
699
|
+
gBullets.append("circle").attr("cx", commitPosition.x + 3).attr("cy", commitPosition.y + 2).attr("r", useReduxGeometry ? 2.5 : 2.75).attr("fill", isDark ? "#000000" : "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
|
|
700
|
+
gBullets.append("line").attr("x1", commitPosition.x + 3).attr("y1", commitPosition.y + 1).attr("x2", commitPosition.x).attr("y2", commitPosition.y - 5).attr("stroke", isDark ? "#000000" : "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
|
|
701
|
+
gBullets.append("line").attr("x1", commitPosition.x - 3).attr("y1", commitPosition.y + 1).attr("x2", commitPosition.x).attr("y2", commitPosition.y - 5).attr("stroke", isDark ? "#000000" : "#fff").attr("class", `commit ${commit2.id} ${typeClass}`);
|
|
702
|
+
} else {
|
|
703
|
+
const circle = gBullets.append("circle");
|
|
704
|
+
circle.attr("cx", commitPosition.x);
|
|
705
|
+
circle.attr("cy", commitPosition.y);
|
|
706
|
+
circle.attr("r", useReduxGeometry ? 7 : 10);
|
|
707
|
+
circle.attr("class", `commit ${commit2.id} commit${calcColorIndex(branchIndex, THEME_COLOR_LIMIT, useColorTheme)}`);
|
|
708
|
+
if (commitSymbolType === commitType.MERGE) {
|
|
709
|
+
const circle2 = gBullets.append("circle");
|
|
710
|
+
circle2.attr("cx", commitPosition.x);
|
|
711
|
+
circle2.attr("cy", commitPosition.y);
|
|
712
|
+
circle2.attr("r", useReduxGeometry ? 5 : 6);
|
|
713
|
+
circle2.attr("class", `commit ${typeClass} ${commit2.id} commit${calcColorIndex(branchIndex, THEME_COLOR_LIMIT, useColorTheme)}`);
|
|
714
|
+
}
|
|
715
|
+
if (commitSymbolType === commitType.REVERSE) {
|
|
716
|
+
const cross = gBullets.append("path");
|
|
717
|
+
const constValue = useReduxGeometry ? 4 : 5;
|
|
718
|
+
cross.attr("d", `M ${commitPosition.x - constValue},${commitPosition.y - constValue}L${commitPosition.x + constValue},${commitPosition.y + constValue}M${commitPosition.x - constValue},${commitPosition.y + constValue}L${commitPosition.x + constValue},${commitPosition.y - constValue}`).attr("class", `commit ${typeClass} ${commit2.id} commit${calcColorIndex(branchIndex, THEME_COLOR_LIMIT, useColorTheme)}`);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}, "drawCommitBullet");
|
|
722
|
+
var drawCommitLabel = /* @__PURE__ */ __name((gLabels, commit2, commitPosition, pos, gitGraphConfig) => {
|
|
723
|
+
if (commit2.type !== commitType.CHERRY_PICK && (commit2.customId && commit2.type === commitType.MERGE || commit2.type !== commitType.MERGE) && gitGraphConfig.showCommitLabel) {
|
|
724
|
+
const wrapper = gLabels.append("g");
|
|
725
|
+
const labelBkg = wrapper.insert("rect").attr("class", "commit-label-bkg");
|
|
726
|
+
const text = wrapper.append("text").attr("x", pos).attr("y", commitPosition.y + 25).attr("class", "commit-label").text(commit2.id);
|
|
727
|
+
const bbox = text.node()?.getBBox();
|
|
728
|
+
if (bbox) {
|
|
729
|
+
labelBkg.attr("x", commitPosition.posWithOffset - bbox.width / 2 - PY).attr("y", commitPosition.y + 13.5).attr("width", bbox.width + 2 * PY).attr("height", bbox.height + 2 * PY);
|
|
730
|
+
if (dir === "TB" || dir === "BT") {
|
|
731
|
+
labelBkg.attr("x", commitPosition.x - (bbox.width + 4 * PX + 5)).attr("y", commitPosition.y - 12);
|
|
732
|
+
text.attr("x", commitPosition.x - (bbox.width + 4 * PX)).attr("y", commitPosition.y + bbox.height - 12);
|
|
733
|
+
} else {
|
|
734
|
+
text.attr("x", commitPosition.posWithOffset - bbox.width / 2);
|
|
735
|
+
}
|
|
736
|
+
if (gitGraphConfig.rotateCommitLabel) {
|
|
737
|
+
if (dir === "TB" || dir === "BT") {
|
|
738
|
+
text.attr("transform", "rotate(-45, " + commitPosition.x + ", " + commitPosition.y + ")");
|
|
739
|
+
labelBkg.attr("transform", "rotate(-45, " + commitPosition.x + ", " + commitPosition.y + ")");
|
|
740
|
+
} else {
|
|
741
|
+
const r_x = -7.5 - (bbox.width + 10) / 25 * 9.5;
|
|
742
|
+
const r_y = 10 + bbox.width / 25 * 8.5;
|
|
743
|
+
wrapper.attr("transform", "translate(" + r_x + ", " + r_y + ") rotate(-45, " + pos + ", " + commitPosition.y + ")");
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}, "drawCommitLabel");
|
|
749
|
+
var drawCommitTags = /* @__PURE__ */ __name((gLabels, commit2, commitPosition, pos) => {
|
|
750
|
+
if (commit2.tags.length > 0) {
|
|
751
|
+
let yOffset = 0;
|
|
752
|
+
let maxTagBboxWidth = 0;
|
|
753
|
+
let maxTagBboxHeight = 0;
|
|
754
|
+
const tagElements = [];
|
|
755
|
+
for (const tagValue of commit2.tags.reverse()) {
|
|
756
|
+
const rect = gLabels.insert("polygon");
|
|
757
|
+
const hole = gLabels.append("circle");
|
|
758
|
+
const tag = gLabels.append("text").attr("y", commitPosition.y - 16 - yOffset).attr("class", "tag-label").text(tagValue);
|
|
759
|
+
const tagBbox = tag.node()?.getBBox();
|
|
760
|
+
if (!tagBbox) {
|
|
761
|
+
throw new Error("Tag bbox not found");
|
|
762
|
+
}
|
|
763
|
+
maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width);
|
|
764
|
+
maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height);
|
|
765
|
+
tag.attr("x", commitPosition.posWithOffset - tagBbox.width / 2);
|
|
766
|
+
tagElements.push({
|
|
767
|
+
tag,
|
|
768
|
+
hole,
|
|
769
|
+
rect,
|
|
770
|
+
yOffset
|
|
771
|
+
});
|
|
772
|
+
yOffset += 20;
|
|
773
|
+
}
|
|
774
|
+
for (const { tag, hole, rect, yOffset: yOffset2 } of tagElements) {
|
|
775
|
+
const h2 = maxTagBboxHeight / 2;
|
|
776
|
+
const ly = commitPosition.y - 19.2 - yOffset2;
|
|
777
|
+
rect.attr("class", "tag-label-bkg").attr("points", `
|
|
778
|
+
${pos - maxTagBboxWidth / 2 - PX / 2},${ly + PY}
|
|
779
|
+
${pos - maxTagBboxWidth / 2 - PX / 2},${ly - PY}
|
|
780
|
+
${commitPosition.posWithOffset - maxTagBboxWidth / 2 - PX},${ly - h2 - PY}
|
|
781
|
+
${commitPosition.posWithOffset + maxTagBboxWidth / 2 + PX},${ly - h2 - PY}
|
|
782
|
+
${commitPosition.posWithOffset + maxTagBboxWidth / 2 + PX},${ly + h2 + PY}
|
|
783
|
+
${commitPosition.posWithOffset - maxTagBboxWidth / 2 - PX},${ly + h2 + PY}`);
|
|
784
|
+
hole.attr("cy", ly).attr("cx", pos - maxTagBboxWidth / 2 + PX / 2).attr("r", 1.5).attr("class", "tag-hole");
|
|
785
|
+
if (dir === "TB" || dir === "BT") {
|
|
786
|
+
const yOrigin = pos + yOffset2;
|
|
787
|
+
rect.attr("class", "tag-label-bkg").attr("points", `
|
|
788
|
+
${commitPosition.x},${yOrigin + 2}
|
|
789
|
+
${commitPosition.x},${yOrigin - 2}
|
|
790
|
+
${commitPosition.x + LAYOUT_OFFSET},${yOrigin - h2 - 2}
|
|
791
|
+
${commitPosition.x + LAYOUT_OFFSET + maxTagBboxWidth + 4},${yOrigin - h2 - 2}
|
|
792
|
+
${commitPosition.x + LAYOUT_OFFSET + maxTagBboxWidth + 4},${yOrigin + h2 + 2}
|
|
793
|
+
${commitPosition.x + LAYOUT_OFFSET},${yOrigin + h2 + 2}`).attr("transform", "translate(12,12) rotate(45, " + commitPosition.x + "," + pos + ")");
|
|
794
|
+
hole.attr("cx", commitPosition.x + PX / 2).attr("cy", yOrigin).attr("transform", "translate(12,12) rotate(45, " + commitPosition.x + "," + pos + ")");
|
|
795
|
+
tag.attr("x", commitPosition.x + 5).attr("y", yOrigin + 3).attr("transform", "translate(14,14) rotate(45, " + commitPosition.x + "," + pos + ")");
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}, "drawCommitTags");
|
|
800
|
+
var getCommitClassType = /* @__PURE__ */ __name((commit2) => {
|
|
801
|
+
const commitSymbolType = commit2.customType ?? commit2.type;
|
|
802
|
+
switch (commitSymbolType) {
|
|
803
|
+
case commitType.NORMAL:
|
|
804
|
+
return "commit-normal";
|
|
805
|
+
case commitType.REVERSE:
|
|
806
|
+
return "commit-reverse";
|
|
807
|
+
case commitType.HIGHLIGHT:
|
|
808
|
+
return "commit-highlight";
|
|
809
|
+
case commitType.MERGE:
|
|
810
|
+
return "commit-merge";
|
|
811
|
+
case commitType.CHERRY_PICK:
|
|
812
|
+
return "commit-cherry-pick";
|
|
813
|
+
default:
|
|
814
|
+
return "commit-normal";
|
|
815
|
+
}
|
|
816
|
+
}, "getCommitClassType");
|
|
817
|
+
var calculatePosition = /* @__PURE__ */ __name((commit2, dir2, pos, commitPos2) => {
|
|
818
|
+
const defaultCommitPosition = { x: 0, y: 0 };
|
|
819
|
+
if (commit2.parents.length > 0) {
|
|
820
|
+
const closestParent = findClosestParent(commit2.parents);
|
|
821
|
+
if (closestParent) {
|
|
822
|
+
const parentPosition = commitPos2.get(closestParent) ?? defaultCommitPosition;
|
|
823
|
+
if (dir2 === "TB") {
|
|
824
|
+
return parentPosition.y + COMMIT_STEP;
|
|
825
|
+
} else if (dir2 === "BT") {
|
|
826
|
+
const currentPosition = commitPos2.get(commit2.id) ?? defaultCommitPosition;
|
|
827
|
+
return currentPosition.y - COMMIT_STEP;
|
|
828
|
+
} else {
|
|
829
|
+
return parentPosition.x + COMMIT_STEP;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
} else {
|
|
833
|
+
if (dir2 === "TB") {
|
|
834
|
+
return defaultPos;
|
|
835
|
+
} else if (dir2 === "BT") {
|
|
836
|
+
const currentPosition = commitPos2.get(commit2.id) ?? defaultCommitPosition;
|
|
837
|
+
return currentPosition.y - COMMIT_STEP;
|
|
838
|
+
} else {
|
|
839
|
+
return 0;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
return 0;
|
|
843
|
+
}, "calculatePosition");
|
|
844
|
+
var getCommitPosition = /* @__PURE__ */ __name((commit2, pos, isParallelCommits) => {
|
|
845
|
+
const posWithOffset = dir === "BT" && isParallelCommits ? pos : pos + LAYOUT_OFFSET;
|
|
846
|
+
const branchY = branchPos.get(commit2.branch)?.pos;
|
|
847
|
+
const x = dir === "TB" || dir === "BT" ? branchPos.get(commit2.branch)?.pos : posWithOffset;
|
|
848
|
+
if (x === undefined || branchY === undefined) {
|
|
849
|
+
throw new Error(`Position were undefined for commit ${commit2.id}`);
|
|
850
|
+
}
|
|
851
|
+
const useReduxGeometry = REDUX_GEOMETRY_THEMES.has(getConfig2().theme ?? "");
|
|
852
|
+
const y = dir === "TB" || dir === "BT" ? posWithOffset : branchY + (useReduxGeometry ? REDUX_BRANCH_LABEL_PADDING_Y / 2 + 1 : -2);
|
|
853
|
+
return { x, y, posWithOffset };
|
|
854
|
+
}, "getCommitPosition");
|
|
855
|
+
var drawCommits = /* @__PURE__ */ __name((svg, commits, modifyGraph, gitGraphConfig) => {
|
|
856
|
+
const gBullets = svg.append("g").attr("class", "commit-bullets");
|
|
857
|
+
const gLabels = svg.append("g").attr("class", "commit-labels");
|
|
858
|
+
let pos = dir === "TB" || dir === "BT" ? defaultPos : 0;
|
|
859
|
+
const keys = [...commits.keys()];
|
|
860
|
+
const isParallelCommits = gitGraphConfig.parallelCommits ?? false;
|
|
861
|
+
const sortKeys = /* @__PURE__ */ __name((a, b) => {
|
|
862
|
+
const seqA = commits.get(a)?.seq;
|
|
863
|
+
const seqB = commits.get(b)?.seq;
|
|
864
|
+
return seqA !== undefined && seqB !== undefined ? seqA - seqB : 0;
|
|
865
|
+
}, "sortKeys");
|
|
866
|
+
let sortedKeys = keys.sort(sortKeys);
|
|
867
|
+
if (dir === "BT") {
|
|
868
|
+
if (isParallelCommits) {
|
|
869
|
+
setParallelBTPos(sortedKeys, commits, pos);
|
|
870
|
+
}
|
|
871
|
+
sortedKeys = sortedKeys.reverse();
|
|
872
|
+
}
|
|
873
|
+
sortedKeys.forEach((key) => {
|
|
874
|
+
const commit2 = commits.get(key);
|
|
875
|
+
if (!commit2) {
|
|
876
|
+
throw new Error(`Commit not found for key ${key}`);
|
|
877
|
+
}
|
|
878
|
+
if (isParallelCommits) {
|
|
879
|
+
pos = calculatePosition(commit2, dir, pos, commitPos);
|
|
880
|
+
}
|
|
881
|
+
const commitPosition = getCommitPosition(commit2, pos, isParallelCommits);
|
|
882
|
+
if (modifyGraph) {
|
|
883
|
+
const typeClass = getCommitClassType(commit2);
|
|
884
|
+
const commitSymbolType = commit2.customType ?? commit2.type;
|
|
885
|
+
const branchIndex = branchPos.get(commit2.branch)?.index ?? 0;
|
|
886
|
+
drawCommitBullet(gBullets, commit2, commitPosition, typeClass, branchIndex, commitSymbolType);
|
|
887
|
+
drawCommitLabel(gLabels, commit2, commitPosition, pos, gitGraphConfig);
|
|
888
|
+
drawCommitTags(gLabels, commit2, commitPosition, pos);
|
|
889
|
+
}
|
|
890
|
+
if (dir === "TB" || dir === "BT") {
|
|
891
|
+
commitPos.set(commit2.id, { x: commitPosition.x, y: commitPosition.posWithOffset });
|
|
892
|
+
} else {
|
|
893
|
+
commitPos.set(commit2.id, { x: commitPosition.posWithOffset, y: commitPosition.y });
|
|
894
|
+
}
|
|
895
|
+
pos = dir === "BT" && isParallelCommits ? pos + COMMIT_STEP : pos + COMMIT_STEP + LAYOUT_OFFSET;
|
|
896
|
+
if (pos > maxPos) {
|
|
897
|
+
maxPos = pos;
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}, "drawCommits");
|
|
901
|
+
var shouldRerouteArrow = /* @__PURE__ */ __name((commitA, commitB, p1, p2, allCommits) => {
|
|
902
|
+
const commitBIsFurthest = dir === "TB" || dir === "BT" ? p1.x < p2.x : p1.y < p2.y;
|
|
903
|
+
const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch;
|
|
904
|
+
const isOnBranchToGetCurve = /* @__PURE__ */ __name((x) => x.branch === branchToGetCurve, "isOnBranchToGetCurve");
|
|
905
|
+
const isBetweenCommits = /* @__PURE__ */ __name((x) => x.seq > commitA.seq && x.seq < commitB.seq, "isBetweenCommits");
|
|
906
|
+
return [...allCommits.values()].some((commitX) => {
|
|
907
|
+
return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX);
|
|
908
|
+
});
|
|
909
|
+
}, "shouldRerouteArrow");
|
|
910
|
+
var findLane = /* @__PURE__ */ __name((y1, y2, depth = 0) => {
|
|
911
|
+
const candidate = y1 + Math.abs(y1 - y2) / 2;
|
|
912
|
+
if (depth > 5) {
|
|
913
|
+
return candidate;
|
|
914
|
+
}
|
|
915
|
+
const ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10);
|
|
916
|
+
if (ok) {
|
|
917
|
+
lanes.push(candidate);
|
|
918
|
+
return candidate;
|
|
919
|
+
}
|
|
920
|
+
const diff = Math.abs(y1 - y2);
|
|
921
|
+
return findLane(y1, y2 - diff / 5, depth + 1);
|
|
922
|
+
}, "findLane");
|
|
923
|
+
var drawArrow = /* @__PURE__ */ __name((svg, commitA, commitB, allCommits) => {
|
|
924
|
+
const { theme: arrowTheme } = getConfig2();
|
|
925
|
+
const useColorTheme = COLOR_THEMES.has(arrowTheme ?? "");
|
|
926
|
+
const p1 = commitPos.get(commitA.id);
|
|
927
|
+
const p2 = commitPos.get(commitB.id);
|
|
928
|
+
if (p1 === undefined || p2 === undefined) {
|
|
929
|
+
throw new Error(`Commit positions not found for commits ${commitA.id} and ${commitB.id}`);
|
|
930
|
+
}
|
|
931
|
+
const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits);
|
|
932
|
+
let arc = "";
|
|
933
|
+
let arc2 = "";
|
|
934
|
+
let radius = 0;
|
|
935
|
+
let offset = 0;
|
|
936
|
+
let colorClassNum = branchPos.get(commitB.branch)?.index;
|
|
937
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
938
|
+
colorClassNum = branchPos.get(commitA.branch)?.index;
|
|
939
|
+
}
|
|
940
|
+
let lineDef;
|
|
941
|
+
if (arrowNeedsRerouting) {
|
|
942
|
+
arc = "A 10 10, 0, 0, 0,";
|
|
943
|
+
arc2 = "A 10 10, 0, 0, 1,";
|
|
944
|
+
radius = 10;
|
|
945
|
+
offset = 10;
|
|
946
|
+
const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y);
|
|
947
|
+
const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x);
|
|
948
|
+
if (dir === "TB") {
|
|
949
|
+
if (p1.x < p2.x) {
|
|
950
|
+
lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
951
|
+
} else {
|
|
952
|
+
colorClassNum = branchPos.get(commitA.branch)?.index;
|
|
953
|
+
lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${p1.y + offset} L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
954
|
+
}
|
|
955
|
+
} else if (dir === "BT") {
|
|
956
|
+
if (p1.x < p2.x) {
|
|
957
|
+
lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc2} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
958
|
+
} else {
|
|
959
|
+
colorClassNum = branchPos.get(commitA.branch)?.index;
|
|
960
|
+
lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc2} ${lineX} ${p1.y - offset} L ${lineX} ${p2.y + radius} ${arc} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
961
|
+
}
|
|
962
|
+
} else {
|
|
963
|
+
if (p1.y < p2.y) {
|
|
964
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`;
|
|
965
|
+
} else {
|
|
966
|
+
colorClassNum = branchPos.get(commitA.branch)?.index;
|
|
967
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${p1.x + offset} ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
} else {
|
|
971
|
+
arc = "A 20 20, 0, 0, 0,";
|
|
972
|
+
arc2 = "A 20 20, 0, 0, 1,";
|
|
973
|
+
radius = 20;
|
|
974
|
+
offset = 20;
|
|
975
|
+
if (dir === "TB") {
|
|
976
|
+
if (p1.x < p2.x) {
|
|
977
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
978
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
979
|
+
} else {
|
|
980
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
if (p1.x > p2.x) {
|
|
984
|
+
arc = "A 20 20, 0, 0, 0,";
|
|
985
|
+
arc2 = "A 20 20, 0, 0, 1,";
|
|
986
|
+
radius = 20;
|
|
987
|
+
offset = 20;
|
|
988
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
989
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
990
|
+
} else {
|
|
991
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
if (p1.x === p2.x) {
|
|
995
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
|
|
996
|
+
}
|
|
997
|
+
} else if (dir === "BT") {
|
|
998
|
+
if (p1.x < p2.x) {
|
|
999
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
1000
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
1001
|
+
} else {
|
|
1002
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (p1.x > p2.x) {
|
|
1006
|
+
arc = "A 20 20, 0, 0, 0,";
|
|
1007
|
+
arc2 = "A 20 20, 0, 0, 1,";
|
|
1008
|
+
radius = 20;
|
|
1009
|
+
offset = 20;
|
|
1010
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
1011
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x - offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
1012
|
+
} else {
|
|
1013
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc2} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
if (p1.x === p2.x) {
|
|
1017
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
|
|
1018
|
+
}
|
|
1019
|
+
} else {
|
|
1020
|
+
if (p1.y < p2.y) {
|
|
1021
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
1022
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${p1.y + offset} L ${p2.x} ${p2.y}`;
|
|
1023
|
+
} else {
|
|
1024
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
if (p1.y > p2.y) {
|
|
1028
|
+
if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) {
|
|
1029
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${p1.y - offset} L ${p2.x} ${p2.y}`;
|
|
1030
|
+
} else {
|
|
1031
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${p2.y} L ${p2.x} ${p2.y}`;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
if (p1.y === p2.y) {
|
|
1035
|
+
lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
if (lineDef === undefined) {
|
|
1040
|
+
throw new Error("Line definition not found");
|
|
1041
|
+
}
|
|
1042
|
+
svg.append("path").attr("d", lineDef).attr("class", "arrow arrow" + calcColorIndex(colorClassNum, THEME_COLOR_LIMIT, useColorTheme));
|
|
1043
|
+
}, "drawArrow");
|
|
1044
|
+
var drawArrows = /* @__PURE__ */ __name((svg, commits) => {
|
|
1045
|
+
const gArrows = svg.append("g").attr("class", "commit-arrows");
|
|
1046
|
+
[...commits.keys()].forEach((key) => {
|
|
1047
|
+
const commit2 = commits.get(key);
|
|
1048
|
+
if (commit2.parents && commit2.parents.length > 0) {
|
|
1049
|
+
commit2.parents.forEach((parent) => {
|
|
1050
|
+
drawArrow(gArrows, commits.get(parent), commit2, commits);
|
|
1051
|
+
});
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
1054
|
+
}, "drawArrows");
|
|
1055
|
+
var drawBranches = /* @__PURE__ */ __name((svg, branches, gitGraphConfig, id) => {
|
|
1056
|
+
const { look, theme, themeVariables } = getConfig2();
|
|
1057
|
+
const { dropShadow, THEME_COLOR_LIMIT: themeColorLimit } = themeVariables;
|
|
1058
|
+
const useReduxGeometry = REDUX_GEOMETRY_THEMES.has(theme ?? "");
|
|
1059
|
+
const useColorTheme = COLOR_THEMES.has(theme ?? "");
|
|
1060
|
+
const g = svg.append("g");
|
|
1061
|
+
branches.forEach((branch2, index) => {
|
|
1062
|
+
const adjustIndexForTheme = calcColorIndex(index, useReduxGeometry ? themeColorLimit : THEME_COLOR_LIMIT, useColorTheme);
|
|
1063
|
+
const pos = branchPos.get(branch2.name)?.pos;
|
|
1064
|
+
if (pos === undefined) {
|
|
1065
|
+
throw new Error(`Position not found for branch ${branch2.name}`);
|
|
1066
|
+
}
|
|
1067
|
+
const spineY = dir === "TB" || dir === "BT" ? pos : useReduxGeometry ? pos + REDUX_BRANCH_LABEL_PADDING_Y / 2 + 1 : pos - 2;
|
|
1068
|
+
const line = g.append("line");
|
|
1069
|
+
line.attr("x1", 0);
|
|
1070
|
+
line.attr("y1", spineY);
|
|
1071
|
+
line.attr("x2", maxPos);
|
|
1072
|
+
line.attr("y2", spineY);
|
|
1073
|
+
line.attr("class", "branch branch" + adjustIndexForTheme);
|
|
1074
|
+
if (dir === "TB") {
|
|
1075
|
+
line.attr("y1", defaultPos);
|
|
1076
|
+
line.attr("x1", pos);
|
|
1077
|
+
line.attr("y2", maxPos);
|
|
1078
|
+
line.attr("x2", pos);
|
|
1079
|
+
} else if (dir === "BT") {
|
|
1080
|
+
line.attr("y1", maxPos);
|
|
1081
|
+
line.attr("x1", pos);
|
|
1082
|
+
line.attr("y2", defaultPos);
|
|
1083
|
+
line.attr("x2", pos);
|
|
1084
|
+
}
|
|
1085
|
+
lanes.push(spineY);
|
|
1086
|
+
const name = branch2.name;
|
|
1087
|
+
const labelElement = drawText(name);
|
|
1088
|
+
const bkg = g.insert("rect");
|
|
1089
|
+
const branchLabel = g.insert("g").attr("class", "branchLabel");
|
|
1090
|
+
const label = branchLabel.insert("g").attr("class", "label branch-label" + adjustIndexForTheme);
|
|
1091
|
+
label.node().appendChild(labelElement);
|
|
1092
|
+
const bbox = labelElement.getBBox();
|
|
1093
|
+
const borderRadius = useReduxGeometry ? 0 : 4;
|
|
1094
|
+
const labelPaddingX = useReduxGeometry ? 16 : 0;
|
|
1095
|
+
const labelPaddingY = useReduxGeometry ? REDUX_BRANCH_LABEL_PADDING_Y : 0;
|
|
1096
|
+
if (look === "neo") {
|
|
1097
|
+
bkg.attr("data-look", `neo`);
|
|
1098
|
+
}
|
|
1099
|
+
bkg.attr("class", "branchLabelBkg label" + adjustIndexForTheme).attr("style", look === "neo" ? `filter:${useReduxGeometry ? `url(#${id}-drop-shadow)` : dropShadow}` : "").attr("rx", borderRadius).attr("ry", borderRadius).attr("x", -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)).attr("y", -bbox.height / 2 + 10).attr("width", bbox.width + 18 + labelPaddingX).attr("height", bbox.height + 4 + labelPaddingY);
|
|
1100
|
+
label.attr("transform", "translate(" + (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0) + labelPaddingX / 2) + ", " + (spineY - bbox.height / 2 - 2) + ")");
|
|
1101
|
+
if (dir === "TB") {
|
|
1102
|
+
bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", 0);
|
|
1103
|
+
label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", 0)");
|
|
1104
|
+
if (useReduxGeometry) {
|
|
1105
|
+
bkg.attr("transform", `translate(${-labelPaddingX / 2 - 3}, ${-labelPaddingY - 10})`);
|
|
1106
|
+
label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", " + (-labelPaddingY * 2 + 7) + ")");
|
|
1107
|
+
}
|
|
1108
|
+
} else if (dir === "BT") {
|
|
1109
|
+
bkg.attr("x", pos - bbox.width / 2 - 10).attr("y", maxPos);
|
|
1110
|
+
label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", " + maxPos + ")");
|
|
1111
|
+
if (useReduxGeometry) {
|
|
1112
|
+
bkg.attr("transform", `translate(${-labelPaddingX / 2 - 3}, ${labelPaddingY + 10})`);
|
|
1113
|
+
label.attr("transform", "translate(" + (pos - bbox.width / 2 - 5) + ", " + (maxPos + labelPaddingY * 2 + 4) + ")");
|
|
1114
|
+
}
|
|
1115
|
+
} else {
|
|
1116
|
+
bkg.attr("transform", "translate(-19, " + (spineY - 12 - labelPaddingY / 2) + ")");
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
}, "drawBranches");
|
|
1120
|
+
var setBranchPosition = /* @__PURE__ */ __name(function(name, pos, index, bbox, rotateCommitLabel) {
|
|
1121
|
+
branchPos.set(name, { pos, index });
|
|
1122
|
+
pos += 50 + (rotateCommitLabel ? 40 : 0) + (dir === "TB" || dir === "BT" ? bbox.width / 2 : 0);
|
|
1123
|
+
return pos;
|
|
1124
|
+
}, "setBranchPosition");
|
|
1125
|
+
var draw = /* @__PURE__ */ __name(function(txt, id, ver, diagObj) {
|
|
1126
|
+
clear3();
|
|
1127
|
+
log.debug("in gitgraph renderer", txt + `
|
|
1128
|
+
`, "id:", id, ver);
|
|
1129
|
+
const db2 = diagObj.db;
|
|
1130
|
+
if (!db2.getConfig) {
|
|
1131
|
+
log.error("getConfig method is not available on db");
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
const gitGraphConfig = db2.getConfig();
|
|
1135
|
+
const rotateCommitLabel = gitGraphConfig.rotateCommitLabel ?? false;
|
|
1136
|
+
allCommitsDict = db2.getCommits();
|
|
1137
|
+
const branches = db2.getBranchesAsObjArray();
|
|
1138
|
+
dir = db2.getDirection();
|
|
1139
|
+
const diagram2 = select_default(`[id="${id}"]`);
|
|
1140
|
+
const { look, theme, themeVariables } = getConfig2();
|
|
1141
|
+
const { useGradient, gradientStart, gradientStop, filterColor } = themeVariables;
|
|
1142
|
+
if (useGradient) {
|
|
1143
|
+
const gradient = diagram2.append("defs").append("linearGradient").attr("id", id + "-gradient").attr("gradientUnits", "objectBoundingBox").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
|
|
1144
|
+
gradient.append("stop").attr("offset", "0%").attr("stop-color", gradientStart).attr("stop-opacity", 1);
|
|
1145
|
+
gradient.append("stop").attr("offset", "100%").attr("stop-color", gradientStop).attr("stop-opacity", 1);
|
|
1146
|
+
}
|
|
1147
|
+
if (look === "neo" && REDUX_GEOMETRY_THEMES.has(theme ?? "")) {
|
|
1148
|
+
diagram2.append("defs").append("filter").attr("id", id + "-drop-shadow").attr("height", "130%").attr("width", "130%").append("feDropShadow").attr("dx", "4").attr("dy", "4").attr("stdDeviation", 0).attr("flood-opacity", "0.06").attr("flood-color", filterColor);
|
|
1149
|
+
}
|
|
1150
|
+
let pos = 0;
|
|
1151
|
+
branches.forEach((branch2, index) => {
|
|
1152
|
+
const labelElement = drawText(branch2.name);
|
|
1153
|
+
const g = diagram2.append("g");
|
|
1154
|
+
const branchLabel = g.insert("g").attr("class", "branchLabel");
|
|
1155
|
+
const label = branchLabel.insert("g").attr("class", "label branch-label");
|
|
1156
|
+
label.node()?.appendChild(labelElement);
|
|
1157
|
+
const bbox = labelElement.getBBox();
|
|
1158
|
+
pos = setBranchPosition(branch2.name, pos, index, bbox, rotateCommitLabel);
|
|
1159
|
+
label.remove();
|
|
1160
|
+
branchLabel.remove();
|
|
1161
|
+
g.remove();
|
|
1162
|
+
});
|
|
1163
|
+
drawCommits(diagram2, allCommitsDict, false, gitGraphConfig);
|
|
1164
|
+
if (gitGraphConfig.showBranches) {
|
|
1165
|
+
drawBranches(diagram2, branches, gitGraphConfig, id);
|
|
1166
|
+
}
|
|
1167
|
+
drawArrows(diagram2, allCommitsDict);
|
|
1168
|
+
drawCommits(diagram2, allCommitsDict, true, gitGraphConfig);
|
|
1169
|
+
utils_default.insertTitle(diagram2, "gitTitleText", gitGraphConfig.titleTopMargin ?? 0, db2.getDiagramTitle());
|
|
1170
|
+
setupGraphViewbox2(undefined, diagram2, gitGraphConfig.diagramPadding, gitGraphConfig.useMaxWidth);
|
|
1171
|
+
}, "draw");
|
|
1172
|
+
var gitGraphRenderer_default = {
|
|
1173
|
+
draw
|
|
1174
|
+
};
|
|
1175
|
+
if (undefined) {}
|
|
1176
|
+
var GIT_NAMED_COLOR_COUNT = 8;
|
|
1177
|
+
var REDUX_GEOMETRY_THEMES2 = /* @__PURE__ */ new Set(["redux", "redux-dark", "redux-color", "redux-dark-color"]);
|
|
1178
|
+
var COLOR_THEMES2 = /* @__PURE__ */ new Set(["redux-color", "redux-dark-color"]);
|
|
1179
|
+
var NEO_THEMES = /* @__PURE__ */ new Set(["neo", "neo-dark"]);
|
|
1180
|
+
var DARK_THEMES2 = /* @__PURE__ */ new Set(["dark", "redux-dark", "redux-dark-color", "neo-dark"]);
|
|
1181
|
+
var NEO_COLOR_GEN_THEMES = /* @__PURE__ */ new Set([
|
|
1182
|
+
"redux",
|
|
1183
|
+
"redux-dark",
|
|
1184
|
+
"redux-color",
|
|
1185
|
+
"redux-dark-color",
|
|
1186
|
+
"neo",
|
|
1187
|
+
"neo-dark"
|
|
1188
|
+
]);
|
|
1189
|
+
var genGitGraphGradient = /* @__PURE__ */ __name((options) => {
|
|
1190
|
+
const { svgId } = options;
|
|
1191
|
+
let sections = "";
|
|
1192
|
+
if (options.useGradient && svgId) {
|
|
1193
|
+
for (let i = 0;i < options.THEME_COLOR_LIMIT; i++) {
|
|
1194
|
+
sections += `
|
|
1195
|
+
.label${i} { fill: ${options.mainBkg}; stroke: url(${svgId}-gradient); stroke-width: ${options.strokeWidth};}
|
|
1196
|
+
`;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return sections;
|
|
1200
|
+
}, "genGitGraphGradient");
|
|
1201
|
+
var genColor = /* @__PURE__ */ __name((options) => {
|
|
1202
|
+
const config = getConfig();
|
|
1203
|
+
const { theme, themeVariables } = config;
|
|
1204
|
+
const { borderColorArray } = themeVariables;
|
|
1205
|
+
const useReduxGeometry = REDUX_GEOMETRY_THEMES2.has(theme);
|
|
1206
|
+
if (NEO_THEMES.has(theme)) {
|
|
1207
|
+
let sections = "";
|
|
1208
|
+
for (let i = 0;i < options.THEME_COLOR_LIMIT; i++) {
|
|
1209
|
+
if (i === 0) {
|
|
1210
|
+
sections += `
|
|
1211
|
+
.branch-label${i} { fill: ${options.nodeBorder};}
|
|
1212
|
+
.commit${i} { stroke: ${options.nodeBorder}; }
|
|
1213
|
+
.commit-highlight${i} { stroke: ${options.nodeBorder}; fill: ${options.nodeBorder}; }
|
|
1214
|
+
.arrow${i} { stroke: ${options.nodeBorder}; }
|
|
1215
|
+
.commit-bullets { fill: ${options.nodeBorder}; }
|
|
1216
|
+
.commit-cherry-pick${i} { stroke: ${options.nodeBorder}; }
|
|
1217
|
+
${genGitGraphGradient(options)}`;
|
|
1218
|
+
} else {
|
|
1219
|
+
const ci = i % GIT_NAMED_COLOR_COUNT;
|
|
1220
|
+
sections += `
|
|
1221
|
+
.branch-label${i} { fill: ${options["gitBranchLabel" + ci]}; }
|
|
1222
|
+
.commit${i} { stroke: ${options["git" + ci]}; fill: ${options["git" + ci]}; }
|
|
1223
|
+
.commit-highlight${i} { stroke: ${options["gitInv" + ci]}; fill: ${options["gitInv" + ci]}; }
|
|
1224
|
+
.arrow${i} { stroke: ${options["git" + ci]}; }
|
|
1225
|
+
`;
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
return sections;
|
|
1229
|
+
} else if (!COLOR_THEMES2.has(theme)) {
|
|
1230
|
+
let sections = "";
|
|
1231
|
+
for (let i = 0;i < options.THEME_COLOR_LIMIT; i++) {
|
|
1232
|
+
sections += `
|
|
1233
|
+
.branch-label${i} { fill: ${options.nodeBorder}; ${useReduxGeometry ? `font-weight:${options.noteFontWeight}` : ""} }
|
|
1234
|
+
.commit${i} { stroke: ${options.nodeBorder}; }
|
|
1235
|
+
.commit-highlight${i} { stroke: ${options.nodeBorder}; fill: ${options.nodeBorder}; }
|
|
1236
|
+
.label${i} { fill: ${options.mainBkg}; stroke: ${options.nodeBorder}; stroke-width: ${options.strokeWidth}; ${useReduxGeometry ? `font-weight:${options.noteFontWeight}` : ""}}
|
|
1237
|
+
.arrow${i} { stroke: ${options.nodeBorder}; }
|
|
1238
|
+
.commit-bullets { fill: ${options.nodeBorder}; }
|
|
1239
|
+
.commit-cherry-pick${i} { stroke: ${options.nodeBorder}; }
|
|
1240
|
+
`;
|
|
1241
|
+
}
|
|
1242
|
+
return sections;
|
|
1243
|
+
} else {
|
|
1244
|
+
let sections = "";
|
|
1245
|
+
for (let i = 0;i < options.THEME_COLOR_LIMIT; i++) {
|
|
1246
|
+
if (i === 0) {
|
|
1247
|
+
sections += `
|
|
1248
|
+
.branch-label${i} { fill: ${options.nodeBorder}; ${useReduxGeometry ? `font-weight:${options.noteFontWeight}` : ""} }
|
|
1249
|
+
.commit${i} { stroke: ${options.nodeBorder}; }
|
|
1250
|
+
.commit-highlight${i} { stroke: ${options.nodeBorder}; fill: ${options.mainBkg}; }
|
|
1251
|
+
.label${i} { fill: ${options.mainBkg}; stroke: ${options.nodeBorder}; stroke-width: ${options.strokeWidth}; ${useReduxGeometry ? `font-weight:${options.noteFontWeight}` : ""} }
|
|
1252
|
+
.arrow${i} { stroke: ${options.nodeBorder}; }
|
|
1253
|
+
.commit-bullets { fill: ${options.nodeBorder}; }
|
|
1254
|
+
`;
|
|
1255
|
+
} else {
|
|
1256
|
+
const colorIndex = i % borderColorArray.length;
|
|
1257
|
+
sections += `
|
|
1258
|
+
.branch-label${i} { fill: ${options.nodeBorder}; ${useReduxGeometry ? `font-weight:${options.noteFontWeight}` : ""} }
|
|
1259
|
+
.commit${i} { stroke: ${borderColorArray[colorIndex]}; fill: ${borderColorArray[colorIndex]}; }
|
|
1260
|
+
.commit-highlight${i} { stroke: ${borderColorArray[colorIndex]}; fill: ${borderColorArray[colorIndex]}; }
|
|
1261
|
+
.label${i} { fill: ${DARK_THEMES2.has(theme) ? options.mainBkg : borderColorArray[colorIndex]}; stroke: ${borderColorArray[colorIndex]}; stroke-width: ${options.strokeWidth}; }
|
|
1262
|
+
.arrow${i} { stroke: ${borderColorArray[colorIndex]}; }
|
|
1263
|
+
`;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return sections;
|
|
1267
|
+
}
|
|
1268
|
+
}, "genColor");
|
|
1269
|
+
var normalTheme = /* @__PURE__ */ __name((options) => {
|
|
1270
|
+
return `${Array.from({ length: options.THEME_COLOR_LIMIT }, (_, i) => i).map((i) => {
|
|
1271
|
+
const ci = i % GIT_NAMED_COLOR_COUNT;
|
|
1272
|
+
return `
|
|
1273
|
+
.branch-label${i} { fill: ${options["gitBranchLabel" + ci]}; }
|
|
1274
|
+
.commit${i} { stroke: ${options["git" + ci]}; fill: ${options["git" + ci]}; }
|
|
1275
|
+
.commit-highlight${i} { stroke: ${options["gitInv" + ci]}; fill: ${options["gitInv" + ci]}; }
|
|
1276
|
+
.label${i} { fill: ${options["git" + ci]}; }
|
|
1277
|
+
.arrow${i} { stroke: ${options["git" + ci]}; }
|
|
1278
|
+
`;
|
|
1279
|
+
}).join(`
|
|
1280
|
+
`)}`;
|
|
1281
|
+
}, "normalTheme");
|
|
1282
|
+
var getStyles = /* @__PURE__ */ __name((options) => {
|
|
1283
|
+
const config = getConfig();
|
|
1284
|
+
const { theme } = config;
|
|
1285
|
+
const useNeoColorGen = NEO_COLOR_GEN_THEMES.has(theme);
|
|
1286
|
+
return `
|
|
1287
|
+
.commit-id,
|
|
1288
|
+
.commit-msg,
|
|
1289
|
+
.branch-label {
|
|
1290
|
+
fill: lightgrey;
|
|
1291
|
+
color: lightgrey;
|
|
1292
|
+
font-family: 'trebuchet ms', verdana, arial, sans-serif;
|
|
1293
|
+
font-family: var(--mermaid-font-family);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
${useNeoColorGen ? genColor(options) : normalTheme(options)}
|
|
1297
|
+
|
|
1298
|
+
.branch {
|
|
1299
|
+
stroke-width: ${options.strokeWidth};
|
|
1300
|
+
stroke: ${options.commitLineColor ?? options.lineColor};
|
|
1301
|
+
stroke-dasharray: ${useNeoColorGen ? "4 2" : "2"};
|
|
1302
|
+
}
|
|
1303
|
+
.commit-label { font-size: ${options.commitLabelFontSize}; fill: ${useNeoColorGen ? options.nodeBorder : options.commitLabelColor}; ${useNeoColorGen ? `font-weight:${options.noteFontWeight};` : ""}}
|
|
1304
|
+
.commit-label-bkg { font-size: ${options.commitLabelFontSize}; fill: ${useNeoColorGen ? "transparent" : options.commitLabelBackground}; opacity: ${useNeoColorGen ? "" : 0.5}; }
|
|
1305
|
+
.tag-label { font-size: ${options.tagLabelFontSize}; fill: ${options.tagLabelColor};}
|
|
1306
|
+
.tag-label-bkg { fill: ${useNeoColorGen ? options.mainBkg : options.tagLabelBackground}; stroke: ${useNeoColorGen ? options.nodeBorder : options.tagLabelBorder}; ${useNeoColorGen ? `filter:${options.dropShadow}` : ""} }
|
|
1307
|
+
.tag-hole { fill: ${options.textColor}; }
|
|
1308
|
+
|
|
1309
|
+
.commit-merge {
|
|
1310
|
+
stroke: ${useNeoColorGen ? options.mainBkg : options.primaryColor};
|
|
1311
|
+
fill: ${useNeoColorGen ? options.mainBkg : options.primaryColor};
|
|
1312
|
+
}
|
|
1313
|
+
.commit-reverse {
|
|
1314
|
+
stroke: ${useNeoColorGen ? options.mainBkg : options.primaryColor};
|
|
1315
|
+
fill: ${useNeoColorGen ? options.mainBkg : options.primaryColor};
|
|
1316
|
+
stroke-width: ${useNeoColorGen ? options.strokeWidth : 3};
|
|
1317
|
+
}
|
|
1318
|
+
.commit-highlight-outer {
|
|
1319
|
+
}
|
|
1320
|
+
.commit-highlight-inner {
|
|
1321
|
+
stroke: ${useNeoColorGen ? options.mainBkg : options.primaryColor};
|
|
1322
|
+
fill: ${useNeoColorGen ? options.mainBkg : options.primaryColor};
|
|
1323
|
+
}
|
|
1324
|
+
|
|
1325
|
+
.arrow {
|
|
1326
|
+
/* Intentional: neo themes keep the bold 8px arrow (like classic themes); only redux-geometry themes use the thinner options.strokeWidth. */
|
|
1327
|
+
stroke-width: ${REDUX_GEOMETRY_THEMES2.has(theme) ? options.strokeWidth : 8};
|
|
1328
|
+
stroke-linecap: round;
|
|
1329
|
+
fill: none
|
|
1330
|
+
}
|
|
1331
|
+
.gitTitleText {
|
|
1332
|
+
text-anchor: middle;
|
|
1333
|
+
font-size: 18px;
|
|
1334
|
+
fill: ${options.textColor};
|
|
1335
|
+
}
|
|
1336
|
+
`;
|
|
1337
|
+
}, "getStyles");
|
|
1338
|
+
var styles_default = getStyles;
|
|
1339
|
+
var diagram = {
|
|
1340
|
+
parser,
|
|
1341
|
+
db,
|
|
1342
|
+
renderer: gitGraphRenderer_default,
|
|
1343
|
+
styles: styles_default
|
|
1344
|
+
};
|
|
1345
|
+
export {
|
|
1346
|
+
diagram
|
|
1347
|
+
};
|