@diagrammo/dgmo 0.46.0 → 0.47.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/dist/advanced.d.cts +3 -855
- package/dist/advanced.d.ts +3 -855
- package/dist/advanced.js +541 -70107
- package/dist/analyzer-UYKBXAKR.js +15 -0
- package/dist/auto.cjs +1 -1
- package/dist/auto.js +1 -1
- package/dist/auto.mjs +1 -1
- package/dist/block.js +83 -69417
- package/dist/calculator-LDYQCDDY.js +11 -0
- package/dist/charts-d3-QOZHKTCT.js +25 -0
- package/dist/chunk-2DXMZRWJ.js +800 -0
- package/dist/chunk-2LACINWN.js +786 -0
- package/dist/chunk-33LCUH4H.js +893 -0
- package/dist/chunk-3CIOJ5YJ.js +35 -0
- package/dist/chunk-3HDBAXF5.js +86 -0
- package/dist/chunk-3JLKYGBQ.js +290 -0
- package/dist/chunk-3MQQNXPD.js +415 -0
- package/dist/chunk-3R5POCTZ.js +967 -0
- package/dist/chunk-3SMGIJDD.js +112 -0
- package/dist/chunk-44CM72SQ.js +409 -0
- package/dist/chunk-4GRI7MEB.js +1604 -0
- package/dist/chunk-4OHACBGX.js +606 -0
- package/dist/chunk-5DH3KYFH.js +21 -0
- package/dist/chunk-5MLYVTYM.js +76 -0
- package/dist/chunk-5QXL4NYS.js +553 -0
- package/dist/chunk-5WRI5ZAA.js +31 -0
- package/dist/chunk-6EK55ART.js +117 -0
- package/dist/chunk-6FZYCKXB.js +2065 -0
- package/dist/chunk-6HO5ZTXK.js +277 -0
- package/dist/chunk-6KFWC4CO.js +7 -0
- package/dist/chunk-6MTWIQVO.js +121 -0
- package/dist/chunk-6NYWYNBI.js +329 -0
- package/dist/chunk-6SM5NJQH.js +620 -0
- package/dist/chunk-725LDASD.js +422 -0
- package/dist/chunk-76OWZ3BA.js +130 -0
- package/dist/chunk-7JEGTRLD.js +338 -0
- package/dist/chunk-A44USUV7.js +923 -0
- package/dist/chunk-A4GOY3PE.js +25 -0
- package/dist/chunk-A4VFQH5G.js +251 -0
- package/dist/chunk-AELOBFW5.js +375 -0
- package/dist/chunk-AN2MOO5T.js +522 -0
- package/dist/chunk-BMR4CIEO.js +41 -0
- package/dist/chunk-BS7SV7C3.js +51 -0
- package/dist/chunk-BUPDIHML.js +613 -0
- package/dist/chunk-BUVJFRPY.js +887 -0
- package/dist/chunk-C3Z4DX3V.js +112 -0
- package/dist/chunk-CI2G3OEB.js +1818 -0
- package/dist/chunk-CKNVO24D.js +54 -0
- package/dist/chunk-CUVHQHZ7.js +391 -0
- package/dist/chunk-CXK4DZH3.js +114 -0
- package/dist/chunk-DKEPS5LH.js +315 -0
- package/dist/chunk-DU7W62N5.js +487 -0
- package/dist/chunk-DZAQBW35.js +751 -0
- package/dist/chunk-EB6FPQUP.js +316 -0
- package/dist/chunk-EMS2SK26.js +376 -0
- package/dist/chunk-ERLBPDGU.js +510 -0
- package/dist/chunk-EVCVDTXE.js +732 -0
- package/dist/chunk-FCIIHT24.js +384 -0
- package/dist/chunk-FFUN5D66.js +97 -0
- package/dist/chunk-FITOLXSX.js +714 -0
- package/dist/chunk-FMDSF3OV.js +68 -0
- package/dist/chunk-FNB3PNGF.js +410 -0
- package/dist/chunk-G2H74XJZ.js +2104 -0
- package/dist/chunk-GMR5MFHJ.js +339 -0
- package/dist/chunk-H6PI3KJT.js +305 -0
- package/dist/chunk-I46X5VUA.js +59 -0
- package/dist/chunk-I5IGB56C.js +255 -0
- package/dist/chunk-IH6ZMVQ5.js +3950 -0
- package/dist/chunk-IJZFN3HM.js +463 -0
- package/dist/chunk-IPWPWM6R.js +3079 -0
- package/dist/chunk-IYULMRBE.js +23 -0
- package/dist/chunk-IZMRON6C.js +167 -0
- package/dist/chunk-J5FIXQRT.js +813 -0
- package/dist/chunk-JED6ZDEE.js +73 -0
- package/dist/chunk-JEUJOX5X.js +136 -0
- package/dist/chunk-JM4LEPY3.js +436 -0
- package/dist/chunk-L3UHP6TD.js +101 -0
- package/dist/chunk-L66GEFB6.js +524 -0
- package/dist/chunk-LIOHW36Z.js +469 -0
- package/dist/chunk-LP7EC4MI.js +16 -0
- package/dist/chunk-MITI6NOL.js +548 -0
- package/dist/chunk-MO5YHHMQ.js +168 -0
- package/dist/chunk-MZSBFAPJ.js +885 -0
- package/dist/chunk-NNAAJVBU.js +9 -0
- package/dist/chunk-NOTA6TEI.js +47 -0
- package/dist/chunk-NURGB5Z4.js +335 -0
- package/dist/chunk-NX4EQS3U.js +1062 -0
- package/dist/chunk-NXMESY4J.js +1 -0
- package/dist/chunk-OJR3MQYV.js +1458 -0
- package/dist/chunk-OURHMODR.js +454 -0
- package/dist/chunk-P235SVAH.js +1057 -0
- package/dist/chunk-P4RH4OSP.js +1038 -0
- package/dist/chunk-P6T66CCZ.js +226 -0
- package/dist/chunk-PBAHEPLQ.js +223 -0
- package/dist/chunk-PBHE5UG6.js +1530 -0
- package/dist/chunk-PDKUANDZ.js +35 -0
- package/dist/chunk-PWIHZ6NJ.js +296 -0
- package/dist/chunk-QEBUY5NY.js +1685 -0
- package/dist/chunk-QLCCJEJI.js +253 -0
- package/dist/chunk-QOOUC2J5.js +52 -0
- package/dist/chunk-QYTPPDAO.js +402 -0
- package/dist/chunk-R3XI2VC7.js +801 -0
- package/dist/chunk-RCERWOJR.js +154 -0
- package/dist/chunk-RJE5JTVK.js +362 -0
- package/dist/chunk-RTLBSQ3G.js +1155 -0
- package/dist/chunk-RUNNI6VE.js +448 -0
- package/dist/chunk-RVMRZAPB.js +354 -0
- package/dist/chunk-RYEGFMUO.js +955 -0
- package/dist/chunk-RZCF2VVM.js +528 -0
- package/dist/chunk-SML67VPV.js +1025 -0
- package/dist/chunk-SQ7IY53Q.js +44 -0
- package/dist/chunk-SQAG3UXH.js +161 -0
- package/dist/chunk-SRTU6HMQ.js +1851 -0
- package/dist/chunk-T2OE3YQB.js +550 -0
- package/dist/chunk-T3UBLACL.js +299 -0
- package/dist/chunk-TLVIHFRO.js +296 -0
- package/dist/chunk-TYS6CSS5.js +52 -0
- package/dist/chunk-U6EQI3U6.js +130 -0
- package/dist/chunk-UJ4FJLBF.js +86 -0
- package/dist/chunk-ULOEATBZ.js +347 -0
- package/dist/chunk-UNCCZ3NU.js +127 -0
- package/dist/chunk-USZW2HHU.js +197 -0
- package/dist/chunk-UWN33VNX.js +1610 -0
- package/dist/chunk-UZ7EZW3B.js +40 -0
- package/dist/chunk-VOKGH627.js +37 -0
- package/dist/chunk-WBRZJOEC.js +204 -0
- package/dist/chunk-WCSOJFU3.js +380 -0
- package/dist/chunk-WCT3NYCV.js +160 -0
- package/dist/chunk-WVAJFAIA.js +529 -0
- package/dist/chunk-X5LCYCL5.js +394 -0
- package/dist/chunk-XAKEUMEJ.js +1256 -0
- package/dist/chunk-Y2ZE3MSG.js +590 -0
- package/dist/chunk-Y3J7VR52.js +646 -0
- package/dist/chunk-Y5QGVTVC.js +33 -0
- package/dist/chunk-YAA6IID3.js +548 -0
- package/dist/chunk-YGJTDXVR.js +692 -0
- package/dist/chunk-YRYKTYMQ.js +186 -0
- package/dist/chunk-YYVTBZZC.js +61 -0
- package/dist/chunk-Z5CGSFJB.js +647 -0
- package/dist/chunk-Z72XRXD4.js +787 -0
- package/dist/chunk-ZGR7ULFJ.js +978 -0
- package/dist/chunk-ZJEL4H2R.js +851 -0
- package/dist/chunk-ZO27FGJS.js +554 -0
- package/dist/collapse-CLPJD2RL.js +11 -0
- package/dist/collapse-SLINJQW6.js +9 -0
- package/dist/collapse-ZWUFFCK2.js +9 -0
- package/dist/compute-G55RG53N.js +8 -0
- package/dist/dgmo-router-DZCIDUO5.js +73 -0
- package/dist/dimensions-J3FHIMJ6.js +22 -0
- package/dist/element.cjs +1 -1
- package/dist/element.js +1 -1
- package/dist/element.mjs +1 -1
- package/dist/flowchart-parser-ZNSKIBVR.js +21 -0
- package/dist/flowchart-renderer-ZAEOL4DX.js +35 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -469
- package/dist/index.d.ts +3 -469
- package/dist/index.js +137 -69685
- package/dist/layout-46N4JJYK.js +17 -0
- package/dist/layout-5RA6QWR6.js +26 -0
- package/dist/layout-5T6RH5M6.js +14 -0
- package/dist/layout-7QXCNOVS.js +13 -0
- package/dist/layout-EE6GE46Y.js +17 -0
- package/dist/layout-G23F7LDH.js +9 -0
- package/dist/layout-HRBZPFCN.js +23 -0
- package/dist/layout-HWDSRX5E.js +20 -0
- package/dist/layout-HYZPWAK5.js +18 -0
- package/dist/layout-N76NR4ZO.js +19 -0
- package/dist/layout-OB3RI63S.js +14 -0
- package/dist/layout-S2QBYSK2.js +15 -0
- package/dist/layout-UM5F4DJB.js +15 -0
- package/dist/layout-search-OYV77HHS.js +1655 -0
- package/dist/load-data-EHDDZ5ZS.js +8 -0
- package/dist/palettes-PRJ2RI6D.js +56 -0
- package/dist/parser-2MFP2H2E.js +11 -0
- package/dist/parser-3STE62GB.js +21 -0
- package/dist/parser-4FL2CMDG.js +18 -0
- package/dist/parser-4OGOBJJ4.js +13 -0
- package/dist/parser-6BTRLKRZ.js +15 -0
- package/dist/parser-AQETEVRW.js +21 -0
- package/dist/parser-CFZD5IBL.js +12 -0
- package/dist/parser-FUSKFGZN.js +16 -0
- package/dist/parser-I6KXEYFK.js +13 -0
- package/dist/parser-IXSZZQHY.js +18 -0
- package/dist/parser-JAL2HD4I.js +13 -0
- package/dist/parser-KNSQSKQO.js +20 -0
- package/dist/parser-N5O4IHUN.js +13 -0
- package/dist/parser-NGU3ETO6.js +16 -0
- package/dist/parser-NRAI6O25.js +19 -0
- package/dist/parser-O5J4VBII.js +11 -0
- package/dist/parser-OV7NOBW6.js +21 -0
- package/dist/parser-PQ3POX45.js +23 -0
- package/dist/parser-TFZFBVWN.js +11 -0
- package/dist/parser-TRTHDFPP.js +18 -0
- package/dist/parser-VQP2UJ6W.js +11 -0
- package/dist/parser-XDVELHRK.js +13 -0
- package/dist/parser-XKRP7QKP.js +11 -0
- package/dist/parser-Y6WTBU76.js +14 -0
- package/dist/parser-ZSDPZYQP.js +12 -0
- package/dist/renderer-2XQQQ6QR.js +28 -0
- package/dist/renderer-5NDVNDAZ.js +26 -0
- package/dist/renderer-6EEZHMH4.js +26 -0
- package/dist/renderer-6W5462RB.js +43 -0
- package/dist/renderer-7MVLWWQD.js +22 -0
- package/dist/renderer-AWWAF6XD.js +33 -0
- package/dist/renderer-BYCNMBF7.js +34 -0
- package/dist/renderer-CLJHQPBJ.js +29 -0
- package/dist/renderer-GHPZMFU2.js +15 -0
- package/dist/renderer-JGBKUCZD.js +16 -0
- package/dist/renderer-KQB7UGDS.js +19 -0
- package/dist/renderer-PGX2TKVS.js +24 -0
- package/dist/renderer-QIWVHWZO.js +15 -0
- package/dist/renderer-RPOA5YPZ.js +35 -0
- package/dist/renderer-SMIBCRVB.js +24 -0
- package/dist/renderer-T7YKC5VP.js +28 -0
- package/dist/renderer-TOCOVLHS.js +37 -0
- package/dist/renderer-UWA5XS74.js +39 -0
- package/dist/renderer-VACVQYML.js +25 -0
- package/dist/renderer-W4M6QLIJ.js +37 -0
- package/dist/renderer-WZRREQ2P.js +23 -0
- package/dist/renderer-YY2OSF6E.js +27 -0
- package/dist/renderer-Z7I3W2PP.js +24 -0
- package/dist/renderer-ZGNTUWC4.js +22 -0
- package/dist/renderer-ZTR3DER3.js +19 -0
- package/dist/renderer-radial-C32GPJQ7.js +21 -0
- package/dist/resolver-NOAA7ID7.js +13 -0
- package/dist/state-collapse-HCGD6IVJ.js +8 -0
- package/dist/state-parser-Z2V23ATR.js +18 -0
- package/dist/state-renderer-RFYHSP4K.js +34 -0
- package/dist/themes-1-CuKpeH.d.cts +908 -0
- package/dist/themes-1-CuKpeH.d.ts +908 -0
- package/package.json +1 -1
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractDatePrefix,
|
|
3
|
+
parseTimelineDate
|
|
4
|
+
} from "./chunk-GMR5MFHJ.js";
|
|
5
|
+
import {
|
|
6
|
+
AUTO_TAG_COLOR_SENTINEL,
|
|
7
|
+
finalizeAutoTagColors,
|
|
8
|
+
injectDefaultTagMetadata,
|
|
9
|
+
matchTagBlockHeading,
|
|
10
|
+
stripDefaultModifier,
|
|
11
|
+
tagAttrKey,
|
|
12
|
+
validateTagGroupNames,
|
|
13
|
+
validateTagValues
|
|
14
|
+
} from "./chunk-QLCCJEJI.js";
|
|
15
|
+
import {
|
|
16
|
+
EVENT_LINE_REGISTRY,
|
|
17
|
+
extractColor,
|
|
18
|
+
measureIndent,
|
|
19
|
+
parseFirstLine,
|
|
20
|
+
splitNameAndMeta,
|
|
21
|
+
tryParseSharedOption,
|
|
22
|
+
warnUnknownMetaKeys,
|
|
23
|
+
withTagAliases
|
|
24
|
+
} from "./chunk-Y3J7VR52.js";
|
|
25
|
+
import {
|
|
26
|
+
emit,
|
|
27
|
+
formatDgmoError,
|
|
28
|
+
makeDgmoError,
|
|
29
|
+
makeFail,
|
|
30
|
+
suggest
|
|
31
|
+
} from "./chunk-CXK4DZH3.js";
|
|
32
|
+
|
|
33
|
+
// src/event-line/diagnostics.ts
|
|
34
|
+
var EVENT_LINE_DX = {
|
|
35
|
+
// parser.ts: 'event-line has no events.'
|
|
36
|
+
NO_EVENTS: {
|
|
37
|
+
code: "E_EVENT_LINE_NO_EVENTS",
|
|
38
|
+
severity: "error",
|
|
39
|
+
chartType: "event-line",
|
|
40
|
+
title: "No events",
|
|
41
|
+
message: "event-line has no events.",
|
|
42
|
+
hint: "Add at least one event line (e.g. `2020 Something happened`) below the header.",
|
|
43
|
+
example: `event-line Empty`
|
|
44
|
+
},
|
|
45
|
+
// parser.ts parseEventHeader:
|
|
46
|
+
// `Use ISO dates (YYYY, YYYY-MM, or YYYY-MM-DD). Got '${firstToken}'.`
|
|
47
|
+
BAD_DATE: {
|
|
48
|
+
code: "E_EVENT_LINE_BAD_DATE",
|
|
49
|
+
// Runtime: emitted at `warning` despite the E_ prefix (see registry allowlist).
|
|
50
|
+
severity: "warning",
|
|
51
|
+
chartType: "event-line",
|
|
52
|
+
title: "Non-ISO date",
|
|
53
|
+
message: (p) => `Use ISO dates (YYYY, YYYY-MM, or YYYY-MM-DD). Got '${p.token ?? "7/16/1969"}'.`,
|
|
54
|
+
hint: "Write dates as YYYY, YYYY-MM, or YYYY-MM-DD \u2014 slash and dot separators are not parsed.",
|
|
55
|
+
example: `event-line X
|
|
56
|
+
|
|
57
|
+
7/16/1969 Liftoff
|
|
58
|
+
Departs.`
|
|
59
|
+
},
|
|
60
|
+
// parser.ts emits three wordings under this one code (each passes the full
|
|
61
|
+
// wording as `reason`):
|
|
62
|
+
// directive handler: `event-line is horizontal-only in v1; \`direction ${dir}\`
|
|
63
|
+
// (vertical orientation) is a fast-follow.`
|
|
64
|
+
// `section` seam: 'Group events with `[Name]` era brackets (§28.6a), not `section`.'
|
|
65
|
+
// parseEventHeader: 'event-line events are points; a date range (`->`) is not
|
|
66
|
+
// supported — using the start date.'
|
|
67
|
+
UNSUPPORTED: {
|
|
68
|
+
code: "E_EVENT_LINE_UNSUPPORTED",
|
|
69
|
+
// Runtime: emitted at `warning` despite the E_ prefix (see registry allowlist).
|
|
70
|
+
severity: "warning",
|
|
71
|
+
chartType: "event-line",
|
|
72
|
+
title: "Unsupported construct",
|
|
73
|
+
message: (p) => typeof p.reason === "string" && p.reason ? p.reason : "event-line is horizontal-only in v1; `direction TB` (vertical orientation) is a fast-follow.",
|
|
74
|
+
hint: "Only horizontal (`direction LR`) is supported; use `[Name]` era brackets (not `section`); events are single points, not date ranges (`->`).",
|
|
75
|
+
example: `event-line X
|
|
76
|
+
direction TB
|
|
77
|
+
|
|
78
|
+
2020 A
|
|
79
|
+
one`
|
|
80
|
+
},
|
|
81
|
+
// parser.ts validateEraDateOrder, two wordings switched by `rel`/`edge`:
|
|
82
|
+
// `… but dated after era "${ahead.era}" begins (${ahead.date}). …` rel=after, edge=begins
|
|
83
|
+
// `… but dated before era "${behind.era}" ends (${behind.date}). …` rel=before, edge=ends
|
|
84
|
+
ERA_DATE_ORDER: {
|
|
85
|
+
code: "E_EVENT_LINE_ERA_DATE_ORDER",
|
|
86
|
+
// Runtime: emitted at `warning` despite the E_ prefix (see registry allowlist).
|
|
87
|
+
severity: "warning",
|
|
88
|
+
chartType: "event-line",
|
|
89
|
+
title: "Event breaks era chronology",
|
|
90
|
+
message: (p) => `"${p.label ?? "Sean Curtis CTO"}" (${p.date ?? "2025-04-15"}) is in era "${p.era ?? "Curtis"}" but dated ${p.rel ?? "after"} era "${p.otherEra ?? "Vasanth"}" ${p.edge ?? "begins"} (${p.otherDate ?? "2025-05-09"}). event-line eras run left-to-right by date \u2014 fix the date or move it to the right era, or their brackets will overlap.`,
|
|
91
|
+
hint: "Eras render as date-spanning brackets; keep every event dated within its era, or move it to the era that covers its date.",
|
|
92
|
+
example: `event-line X
|
|
93
|
+
|
|
94
|
+
[Vasanth]
|
|
95
|
+
2025-04-01 Opening Day Outage
|
|
96
|
+
2025-05-09 Fire Kevin C
|
|
97
|
+
|
|
98
|
+
[Curtis]
|
|
99
|
+
2025-04-15 Sean Curtis CTO
|
|
100
|
+
2025-09-01 The incident`
|
|
101
|
+
},
|
|
102
|
+
// parser.ts validateEventDateOrder:
|
|
103
|
+
// `"${ev.label}" (${ev.date}) is out of order — it is dated before
|
|
104
|
+
// "${prev.label}" (${prev.date}) listed above it. event-line reads
|
|
105
|
+
// left-to-right by date; list events chronologically.`
|
|
106
|
+
DATE_ORDER: {
|
|
107
|
+
code: "E_EVENT_LINE_DATE_ORDER",
|
|
108
|
+
// Runtime: emitted at `warning` despite the E_ prefix (see registry allowlist).
|
|
109
|
+
severity: "warning",
|
|
110
|
+
chartType: "event-line",
|
|
111
|
+
title: "Events out of chronological order",
|
|
112
|
+
message: (p) => `"${p.label ?? "C"}" (${p.date ?? "2022"}) is out of order \u2014 it is dated before "${p.prevLabel ?? "B"}" (${p.prevDate ?? "2024"}) listed above it. event-line reads left-to-right by date; list events chronologically.`,
|
|
113
|
+
hint: "List dated events chronologically top-to-bottom; a later-listed event dated before the one above it is almost always a slip.",
|
|
114
|
+
example: `event-line X
|
|
115
|
+
|
|
116
|
+
2020 A
|
|
117
|
+
2024 B
|
|
118
|
+
2022 C`
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var EVENT_LINE_DIAGNOSTICS = Object.values(EVENT_LINE_DX);
|
|
122
|
+
|
|
123
|
+
// src/event-line/parser.ts
|
|
124
|
+
var NON_ISO_DATE_RE = /^\d{1,4}[/.]\d/;
|
|
125
|
+
var TBD_RE = /^TBD\b/i;
|
|
126
|
+
var SIDE_RE = /^side\s+(above|below|alternate)\b/i;
|
|
127
|
+
var ERA_RE = /^\[([^\]]+)\]\s*(.*)$/;
|
|
128
|
+
var ERA_COLLAPSED_RE = /\bcollapsed:\s*(true|false)\b/i;
|
|
129
|
+
var SECTION_SEAM_RE = /^section\b/i;
|
|
130
|
+
var DIRECTION_RE = /^direction\s+(\w+)/i;
|
|
131
|
+
function parseEventLine(content, palette) {
|
|
132
|
+
const options = {
|
|
133
|
+
scale: true,
|
|
134
|
+
side: "alternate",
|
|
135
|
+
noTitle: false,
|
|
136
|
+
noBox: false,
|
|
137
|
+
noLegend: false
|
|
138
|
+
};
|
|
139
|
+
const result = {
|
|
140
|
+
type: "event-line",
|
|
141
|
+
title: null,
|
|
142
|
+
titleLineNumber: null,
|
|
143
|
+
events: [],
|
|
144
|
+
eras: [],
|
|
145
|
+
tagGroups: [],
|
|
146
|
+
options,
|
|
147
|
+
diagnostics: [],
|
|
148
|
+
error: null
|
|
149
|
+
};
|
|
150
|
+
const fail = makeFail(result);
|
|
151
|
+
const pushWarning = (line, message, code) => {
|
|
152
|
+
result.diagnostics.push(makeDgmoError(line, message, "warning", code));
|
|
153
|
+
};
|
|
154
|
+
const pushError = (line, message, code) => {
|
|
155
|
+
const diag = makeDgmoError(line, message, "error", code);
|
|
156
|
+
result.diagnostics.push(diag);
|
|
157
|
+
if (!result.error) result.error = formatDgmoError(diag);
|
|
158
|
+
};
|
|
159
|
+
if (!content?.trim()) return fail(0, "No content provided");
|
|
160
|
+
const lines = content.split("\n");
|
|
161
|
+
let contentStarted = false;
|
|
162
|
+
let headerParsed = false;
|
|
163
|
+
const sharedOptions = {};
|
|
164
|
+
let currentTagGroup = null;
|
|
165
|
+
let currentEvent = null;
|
|
166
|
+
let currentEra = null;
|
|
167
|
+
let eraIndent = -1;
|
|
168
|
+
let currentEventIndent = 0;
|
|
169
|
+
const aliasMap = /* @__PURE__ */ new Map();
|
|
170
|
+
for (let i = 0; i < lines.length; i++) {
|
|
171
|
+
const line = lines[i];
|
|
172
|
+
const lineNumber = i + 1;
|
|
173
|
+
const trimmed = line.trim();
|
|
174
|
+
if (!trimmed) {
|
|
175
|
+
currentTagGroup = null;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (trimmed.startsWith("//")) continue;
|
|
179
|
+
const indent = measureIndent(line);
|
|
180
|
+
if (!headerParsed) {
|
|
181
|
+
const firstLine = parseFirstLine(trimmed);
|
|
182
|
+
if (firstLine?.chartType === "event-line") {
|
|
183
|
+
result.title = firstLine.title ?? null;
|
|
184
|
+
result.titleLineNumber = lineNumber;
|
|
185
|
+
headerParsed = true;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
let msg = 'Expected "event-line [Title]" as the first line.';
|
|
189
|
+
const hint = suggest(firstLine?.chartType ?? trimmed, ["event-line"]);
|
|
190
|
+
if (hint) msg += ` ${hint}`;
|
|
191
|
+
return fail(lineNumber, msg);
|
|
192
|
+
}
|
|
193
|
+
const tagBlockMatch = matchTagBlockHeading(trimmed);
|
|
194
|
+
if (tagBlockMatch) {
|
|
195
|
+
if (contentStarted) {
|
|
196
|
+
pushError(
|
|
197
|
+
lineNumber,
|
|
198
|
+
"Tag groups must appear before event-line content",
|
|
199
|
+
"E_TAG_DECLARED_AFTER_CONTENT"
|
|
200
|
+
);
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
currentTagGroup = {
|
|
204
|
+
name: tagBlockMatch.name,
|
|
205
|
+
...tagBlockMatch.alias !== void 0 && {
|
|
206
|
+
alias: tagBlockMatch.alias
|
|
207
|
+
},
|
|
208
|
+
entries: [],
|
|
209
|
+
lineNumber
|
|
210
|
+
};
|
|
211
|
+
if (tagBlockMatch.alias) {
|
|
212
|
+
aliasMap.set(
|
|
213
|
+
tagBlockMatch.alias.toLowerCase(),
|
|
214
|
+
tagAttrKey(tagBlockMatch.name)
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
aliasMap.set(
|
|
218
|
+
tagAttrKey(tagBlockMatch.name),
|
|
219
|
+
tagAttrKey(tagBlockMatch.name)
|
|
220
|
+
);
|
|
221
|
+
result.tagGroups.push(currentTagGroup);
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (currentTagGroup && !contentStarted && indent > 0) {
|
|
225
|
+
const { text: cleanEntry, isDefault } = stripDefaultModifier(trimmed);
|
|
226
|
+
const { label, color } = extractColor(
|
|
227
|
+
cleanEntry,
|
|
228
|
+
palette,
|
|
229
|
+
result.diagnostics,
|
|
230
|
+
lineNumber
|
|
231
|
+
);
|
|
232
|
+
if (isDefault || currentTagGroup.entries.length === 0) {
|
|
233
|
+
currentTagGroup.defaultValue = label;
|
|
234
|
+
}
|
|
235
|
+
currentTagGroup.entries.push({
|
|
236
|
+
value: label,
|
|
237
|
+
color: color ?? AUTO_TAG_COLOR_SENTINEL,
|
|
238
|
+
lineNumber
|
|
239
|
+
});
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (currentEvent && indent > currentEventIndent) {
|
|
243
|
+
const descLine = trimmed.startsWith("- ") ? `\u2022 ${trimmed.substring(2)}` : trimmed;
|
|
244
|
+
currentEvent.description.push(descLine);
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const eraMatch = trimmed.match(ERA_RE);
|
|
248
|
+
if (eraMatch) {
|
|
249
|
+
contentStarted = true;
|
|
250
|
+
currentTagGroup = null;
|
|
251
|
+
currentEvent = null;
|
|
252
|
+
const name = eraMatch[1].trim();
|
|
253
|
+
let rest = (eraMatch[2] ?? "").trim();
|
|
254
|
+
let collapsed = false;
|
|
255
|
+
const cm = rest.match(ERA_COLLAPSED_RE);
|
|
256
|
+
if (cm) {
|
|
257
|
+
collapsed = cm[1].toLowerCase() === "true";
|
|
258
|
+
rest = (rest.slice(0, cm.index) + rest.slice(cm.index + cm[0].length)).trim();
|
|
259
|
+
}
|
|
260
|
+
let color = null;
|
|
261
|
+
if (rest) {
|
|
262
|
+
const token = rest.split(/\s+/).pop();
|
|
263
|
+
const ex = extractColor(
|
|
264
|
+
`x ${token}`,
|
|
265
|
+
palette,
|
|
266
|
+
result.diagnostics,
|
|
267
|
+
lineNumber
|
|
268
|
+
);
|
|
269
|
+
if (ex.color !== void 0) color = token;
|
|
270
|
+
}
|
|
271
|
+
const era = { name, color, collapsed, lineNumber };
|
|
272
|
+
result.eras.push(era);
|
|
273
|
+
currentEra = name;
|
|
274
|
+
eraIndent = indent;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (indent === 0) {
|
|
278
|
+
currentTagGroup = null;
|
|
279
|
+
if (trimmed.toLowerCase() === "no-scale") {
|
|
280
|
+
options.scale = false;
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const sideMatch = trimmed.match(SIDE_RE);
|
|
284
|
+
if (sideMatch) {
|
|
285
|
+
options.side = sideMatch[1].toLowerCase();
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (trimmed.toLowerCase() === "no-box") {
|
|
289
|
+
options.noBox = true;
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (trimmed.toLowerCase() === "no-legend") {
|
|
293
|
+
options.noLegend = true;
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
const dirMatch = trimmed.match(DIRECTION_RE);
|
|
297
|
+
if (dirMatch) {
|
|
298
|
+
const dir = dirMatch[1].toUpperCase();
|
|
299
|
+
if (dir !== "LR") {
|
|
300
|
+
result.diagnostics.push(
|
|
301
|
+
emit(EVENT_LINE_DX.UNSUPPORTED, lineNumber, {
|
|
302
|
+
reason: `event-line is horizontal-only in v1; \`direction ${dir}\` (vertical orientation) is a fast-follow.`
|
|
303
|
+
})
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (tryParseSharedOption(trimmed, sharedOptions)) continue;
|
|
309
|
+
if (SECTION_SEAM_RE.test(trimmed)) {
|
|
310
|
+
result.diagnostics.push(
|
|
311
|
+
emit(EVENT_LINE_DX.UNSUPPORTED, lineNumber, {
|
|
312
|
+
reason: "Group events with `[Name]` era brackets (\xA728.6a), not `section`."
|
|
313
|
+
})
|
|
314
|
+
);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
const inEra = currentEra !== null && indent > eraIndent;
|
|
319
|
+
if (!inEra) currentEra = null;
|
|
320
|
+
contentStarted = true;
|
|
321
|
+
const event = parseEventHeader(
|
|
322
|
+
trimmed,
|
|
323
|
+
lineNumber,
|
|
324
|
+
currentEra,
|
|
325
|
+
aliasMap,
|
|
326
|
+
result.diagnostics,
|
|
327
|
+
pushWarning
|
|
328
|
+
);
|
|
329
|
+
result.events.push(event);
|
|
330
|
+
currentEvent = event;
|
|
331
|
+
currentEventIndent = indent;
|
|
332
|
+
}
|
|
333
|
+
options.noTitle = sharedOptions["no-title"] === "on";
|
|
334
|
+
resolveFutureEvents(result.events);
|
|
335
|
+
finalizeAutoTagColors(result.tagGroups, palette);
|
|
336
|
+
if (result.tagGroups.length > 0) {
|
|
337
|
+
validateTagValues(result.events, result.tagGroups, pushWarning, suggest);
|
|
338
|
+
validateTagGroupNames(result.tagGroups, pushWarning);
|
|
339
|
+
injectDefaultTagMetadata(result.events, result.tagGroups);
|
|
340
|
+
}
|
|
341
|
+
if (result.events.length === 0 && !result.error) {
|
|
342
|
+
const diag = emit(EVENT_LINE_DX.NO_EVENTS, result.titleLineNumber ?? 1);
|
|
343
|
+
result.diagnostics.push(diag);
|
|
344
|
+
result.error = formatDgmoError(diag);
|
|
345
|
+
}
|
|
346
|
+
const eraFlaggedLines = /* @__PURE__ */ new Set();
|
|
347
|
+
if (options.scale) {
|
|
348
|
+
validateEraDateOrder(result.events, result.eras, (err) => {
|
|
349
|
+
eraFlaggedLines.add(err.line);
|
|
350
|
+
result.diagnostics.push(err);
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
validateEventDateOrder(result.events, eraFlaggedLines, result.diagnostics);
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
function resolveFutureEvents(events) {
|
|
357
|
+
const realVals = events.filter((e) => !e.future && e.dateValue !== null).map((e) => e.dateValue);
|
|
358
|
+
if (realVals.length === 0) return;
|
|
359
|
+
const hiAll = Math.max(...realVals);
|
|
360
|
+
const loAll = Math.min(...realVals);
|
|
361
|
+
const pad = hiAll > loAll ? (hiAll - loAll) * 0.15 : 1;
|
|
362
|
+
const prevReal = [];
|
|
363
|
+
let carry = null;
|
|
364
|
+
for (const e of events) {
|
|
365
|
+
prevReal.push(carry);
|
|
366
|
+
if (!e.future && e.dateValue !== null) carry = e.dateValue;
|
|
367
|
+
}
|
|
368
|
+
const nextReal = new Array(events.length).fill(null);
|
|
369
|
+
carry = null;
|
|
370
|
+
for (let i2 = events.length - 1; i2 >= 0; i2--) {
|
|
371
|
+
nextReal[i2] = carry;
|
|
372
|
+
const e = events[i2];
|
|
373
|
+
if (!e.future && e.dateValue !== null) carry = e.dateValue;
|
|
374
|
+
}
|
|
375
|
+
let i = 0;
|
|
376
|
+
while (i < events.length) {
|
|
377
|
+
if (!events[i].future) {
|
|
378
|
+
i++;
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
const lo = prevReal[i];
|
|
382
|
+
const hi = nextReal[i];
|
|
383
|
+
let j = i;
|
|
384
|
+
while (j < events.length && events[j].future && prevReal[j] === lo && nextReal[j] === hi)
|
|
385
|
+
j++;
|
|
386
|
+
const group = events.slice(i, j);
|
|
387
|
+
const g = group.length;
|
|
388
|
+
if (lo !== null && hi !== null) {
|
|
389
|
+
group.forEach((e, k) => {
|
|
390
|
+
e.dateValue = lo + (hi - lo) * (k + 1) / (g + 1);
|
|
391
|
+
e.futureSpan = [lo, hi];
|
|
392
|
+
});
|
|
393
|
+
} else if (lo === null && hi !== null) {
|
|
394
|
+
const left = hi - pad;
|
|
395
|
+
group.forEach((e, k) => {
|
|
396
|
+
e.dateValue = left + (hi - left) * (k + 1) / (g + 1);
|
|
397
|
+
e.futureSpan = [left, hi];
|
|
398
|
+
});
|
|
399
|
+
} else {
|
|
400
|
+
group.forEach((e, k) => {
|
|
401
|
+
e.dateValue = hiAll + pad * (k + 1);
|
|
402
|
+
e.futureSpan = null;
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
i = j;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
function validateEventDateOrder(events, skipLines, diagnostics) {
|
|
409
|
+
let prev = null;
|
|
410
|
+
for (const ev of events) {
|
|
411
|
+
if (ev.future || ev.dateValue === null) continue;
|
|
412
|
+
if (prev && ev.dateValue < prev.dateValue && !skipLines.has(ev.lineNumber)) {
|
|
413
|
+
diagnostics.push(
|
|
414
|
+
emit(EVENT_LINE_DX.DATE_ORDER, ev.lineNumber, {
|
|
415
|
+
label: ev.label,
|
|
416
|
+
date: ev.date,
|
|
417
|
+
prevLabel: prev.label,
|
|
418
|
+
prevDate: prev.date
|
|
419
|
+
})
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
prev = ev;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
function validateEraDateOrder(events, eras, emitWarn) {
|
|
426
|
+
if (eras.length < 2) return;
|
|
427
|
+
const order = new Map(eras.map((e, i) => [e.name, i]));
|
|
428
|
+
const dated = events.filter(
|
|
429
|
+
(e) => !e.future && e.dateValue !== null && e.era !== null && order.has(e.era)
|
|
430
|
+
);
|
|
431
|
+
if (dated.length === 0) return;
|
|
432
|
+
const perEra = /* @__PURE__ */ new Map();
|
|
433
|
+
for (const ev of dated) {
|
|
434
|
+
const idx = order.get(ev.era);
|
|
435
|
+
const cur = perEra.get(idx);
|
|
436
|
+
if (!cur) {
|
|
437
|
+
perEra.set(idx, { min: ev, max: ev });
|
|
438
|
+
} else {
|
|
439
|
+
if (ev.dateValue < cur.min.dateValue) cur.min = ev;
|
|
440
|
+
if (ev.dateValue > cur.max.dateValue) cur.max = ev;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
const n = eras.length;
|
|
444
|
+
const prefixMax = new Array(n).fill(null);
|
|
445
|
+
const suffixMin = new Array(n).fill(null);
|
|
446
|
+
for (let k = 1; k < n; k++) {
|
|
447
|
+
const prev = perEra.get(k - 1)?.max ?? null;
|
|
448
|
+
const carried = prefixMax[k - 1] ?? null;
|
|
449
|
+
prefixMax[k] = prev && (!carried || prev.dateValue > carried.dateValue) ? prev : carried;
|
|
450
|
+
}
|
|
451
|
+
for (let k = n - 2; k >= 0; k--) {
|
|
452
|
+
const next = perEra.get(k + 1)?.min ?? null;
|
|
453
|
+
const carried = suffixMin[k + 1] ?? null;
|
|
454
|
+
suffixMin[k] = next && (!carried || next.dateValue < carried.dateValue) ? next : carried;
|
|
455
|
+
}
|
|
456
|
+
for (const ev of dated) {
|
|
457
|
+
const k = order.get(ev.era);
|
|
458
|
+
const ahead = suffixMin[k];
|
|
459
|
+
const behind = prefixMax[k];
|
|
460
|
+
if (ahead && ev.dateValue > ahead.dateValue) {
|
|
461
|
+
emitWarn(
|
|
462
|
+
emit(EVENT_LINE_DX.ERA_DATE_ORDER, ev.lineNumber, {
|
|
463
|
+
label: ev.label,
|
|
464
|
+
date: ev.date,
|
|
465
|
+
era: ev.era,
|
|
466
|
+
rel: "after",
|
|
467
|
+
otherEra: ahead.era,
|
|
468
|
+
edge: "begins",
|
|
469
|
+
otherDate: ahead.date
|
|
470
|
+
})
|
|
471
|
+
);
|
|
472
|
+
} else if (behind && ev.dateValue < behind.dateValue) {
|
|
473
|
+
emitWarn(
|
|
474
|
+
emit(EVENT_LINE_DX.ERA_DATE_ORDER, ev.lineNumber, {
|
|
475
|
+
label: ev.label,
|
|
476
|
+
date: ev.date,
|
|
477
|
+
era: ev.era,
|
|
478
|
+
rel: "before",
|
|
479
|
+
otherEra: behind.era,
|
|
480
|
+
edge: "ends",
|
|
481
|
+
otherDate: behind.date
|
|
482
|
+
})
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
function parseEventHeader(trimmed, lineNumber, era, aliasMap, diagnostics, pushWarning) {
|
|
488
|
+
let date = null;
|
|
489
|
+
let dateValue = null;
|
|
490
|
+
let future = false;
|
|
491
|
+
let remainder = trimmed;
|
|
492
|
+
const tbdMatch = trimmed.match(TBD_RE);
|
|
493
|
+
if (tbdMatch) {
|
|
494
|
+
date = "TBD";
|
|
495
|
+
future = true;
|
|
496
|
+
remainder = trimmed.slice(tbdMatch[0].length).trimStart();
|
|
497
|
+
}
|
|
498
|
+
const prefix = future ? null : extractDatePrefix(trimmed);
|
|
499
|
+
if (prefix) {
|
|
500
|
+
date = prefix.startDate;
|
|
501
|
+
dateValue = parseTimelineDate(prefix.startDate);
|
|
502
|
+
remainder = prefix.remainder || "";
|
|
503
|
+
if (prefix.endDate) {
|
|
504
|
+
diagnostics.push(
|
|
505
|
+
emit(EVENT_LINE_DX.UNSUPPORTED, lineNumber, {
|
|
506
|
+
reason: "event-line events are points; a date range (`->`) is not supported \u2014 using the start date."
|
|
507
|
+
})
|
|
508
|
+
);
|
|
509
|
+
}
|
|
510
|
+
} else if (!future && NON_ISO_DATE_RE.test(trimmed)) {
|
|
511
|
+
const firstToken = trimmed.split(/\s+/)[0];
|
|
512
|
+
diagnostics.push(
|
|
513
|
+
emit(EVENT_LINE_DX.BAD_DATE, lineNumber, { token: firstToken })
|
|
514
|
+
);
|
|
515
|
+
}
|
|
516
|
+
const registry = withTagAliases(
|
|
517
|
+
EVENT_LINE_REGISTRY,
|
|
518
|
+
new Set(aliasMap.keys())
|
|
519
|
+
);
|
|
520
|
+
const split = splitNameAndMeta(
|
|
521
|
+
remainder,
|
|
522
|
+
registry,
|
|
523
|
+
aliasMap,
|
|
524
|
+
void 0,
|
|
525
|
+
diagnostics,
|
|
526
|
+
lineNumber
|
|
527
|
+
);
|
|
528
|
+
warnUnknownMetaKeys(
|
|
529
|
+
split.meta,
|
|
530
|
+
registry,
|
|
531
|
+
(msg) => pushWarning(lineNumber, msg),
|
|
532
|
+
split.name
|
|
533
|
+
);
|
|
534
|
+
const metadata = { ...split.meta };
|
|
535
|
+
if (split.color !== void 0) metadata["color"] = split.color;
|
|
536
|
+
return {
|
|
537
|
+
label: split.name || remainder.trim(),
|
|
538
|
+
lineNumber,
|
|
539
|
+
date,
|
|
540
|
+
dateValue,
|
|
541
|
+
future,
|
|
542
|
+
futureSpan: null,
|
|
543
|
+
metadata,
|
|
544
|
+
description: [],
|
|
545
|
+
era
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
export {
|
|
550
|
+
EVENT_LINE_DIAGNOSTICS,
|
|
551
|
+
parseEventLine
|
|
552
|
+
};
|
|
553
|
+
//# sourceMappingURL=chunk-5QXL4NYS.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
__commonJS,
|
|
29
|
+
__toESM
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=chunk-5WRI5ZAA.js.map
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NOTE_GAP
|
|
3
|
+
} from "./chunk-5DH3KYFH.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/notes/place.ts
|
|
6
|
+
var NOTE_CLEAR = 14;
|
|
7
|
+
var intersects = (a, b, pad) => !(a.right + pad <= b.left || b.right + pad <= a.left || a.bottom + pad <= b.top || b.bottom + pad <= a.top);
|
|
8
|
+
function placeNotes(obstacles, requests, direction) {
|
|
9
|
+
const placements = /* @__PURE__ */ new Map();
|
|
10
|
+
const occupied = obstacles.map((p) => ({
|
|
11
|
+
left: p.x - p.width / 2,
|
|
12
|
+
top: p.y - p.height / 2,
|
|
13
|
+
right: p.x + p.width / 2,
|
|
14
|
+
bottom: p.y + p.height / 2
|
|
15
|
+
}));
|
|
16
|
+
for (const req of requests) {
|
|
17
|
+
if (req.collapsed) {
|
|
18
|
+
placements.set(req.key, {
|
|
19
|
+
collapsed: true,
|
|
20
|
+
side: "right",
|
|
21
|
+
x: 0,
|
|
22
|
+
y: 0
|
|
23
|
+
});
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const p = req.node;
|
|
27
|
+
const cx = p.x;
|
|
28
|
+
const cy = p.y;
|
|
29
|
+
const nodeLeft = cx - p.width / 2;
|
|
30
|
+
const nodeRight = cx + p.width / 2;
|
|
31
|
+
const nodeTop = cy - p.height / 2;
|
|
32
|
+
const nodeBottom = cy + p.height / 2;
|
|
33
|
+
const { noteW, noteH } = req;
|
|
34
|
+
const rectFor = (side) => {
|
|
35
|
+
switch (side) {
|
|
36
|
+
case "right": {
|
|
37
|
+
const left = nodeRight + NOTE_GAP;
|
|
38
|
+
const top = cy - noteH / 2;
|
|
39
|
+
return { left, top, right: left + noteW, bottom: top + noteH };
|
|
40
|
+
}
|
|
41
|
+
case "left": {
|
|
42
|
+
const right = nodeLeft - NOTE_GAP;
|
|
43
|
+
const top = cy - noteH / 2;
|
|
44
|
+
return { left: right - noteW, top, right, bottom: top + noteH };
|
|
45
|
+
}
|
|
46
|
+
case "below": {
|
|
47
|
+
const left = cx - noteW / 2;
|
|
48
|
+
const top = nodeBottom + NOTE_GAP;
|
|
49
|
+
return { left, top, right: left + noteW, bottom: top + noteH };
|
|
50
|
+
}
|
|
51
|
+
case "above":
|
|
52
|
+
default: {
|
|
53
|
+
const left = cx - noteW / 2;
|
|
54
|
+
const bottom = nodeTop - NOTE_GAP;
|
|
55
|
+
return { left, top: bottom - noteH, right: left + noteW, bottom };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const order = direction === "LR" ? ["below", "above"] : ["right", "left"];
|
|
60
|
+
let chosen = null;
|
|
61
|
+
for (const side of order) {
|
|
62
|
+
const rect = rectFor(side);
|
|
63
|
+
if (!occupied.some((o) => intersects(rect, o, NOTE_CLEAR))) {
|
|
64
|
+
chosen = { rect, side };
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!chosen) {
|
|
69
|
+
const side = order[0];
|
|
70
|
+
let rect = rectFor(side);
|
|
71
|
+
const axisIsY = side === "above" || side === "below";
|
|
72
|
+
const outward = side === "below" || side === "right" ? 1 : -1;
|
|
73
|
+
for (let guard = 0; guard < 50; guard++) {
|
|
74
|
+
const blockers = occupied.filter(
|
|
75
|
+
(o) => intersects(rect, o, NOTE_CLEAR)
|
|
76
|
+
);
|
|
77
|
+
if (blockers.length === 0) break;
|
|
78
|
+
if (axisIsY && outward > 0) {
|
|
79
|
+
const top = Math.max(...blockers.map((b) => b.bottom)) + NOTE_CLEAR;
|
|
80
|
+
rect = { ...rect, top, bottom: top + noteH };
|
|
81
|
+
} else if (axisIsY) {
|
|
82
|
+
const bottom = Math.min(...blockers.map((b) => b.top)) - NOTE_CLEAR;
|
|
83
|
+
rect = { ...rect, bottom, top: bottom - noteH };
|
|
84
|
+
} else if (outward > 0) {
|
|
85
|
+
const left = Math.max(...blockers.map((b) => b.right)) + NOTE_CLEAR;
|
|
86
|
+
rect = { ...rect, left, right: left + noteW };
|
|
87
|
+
} else {
|
|
88
|
+
const right = Math.min(...blockers.map((b) => b.left)) - NOTE_CLEAR;
|
|
89
|
+
rect = { ...rect, right, left: right - noteW };
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
chosen = { rect, side };
|
|
93
|
+
}
|
|
94
|
+
occupied.push(chosen.rect);
|
|
95
|
+
placements.set(req.key, {
|
|
96
|
+
collapsed: false,
|
|
97
|
+
side: chosen.side,
|
|
98
|
+
x: chosen.rect.left - p.x,
|
|
99
|
+
y: chosen.rect.top - p.y
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return placements;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/utils/notes/bounds.ts
|
|
106
|
+
function noteCanvasShift(minX, minY, margin = 20) {
|
|
107
|
+
return {
|
|
108
|
+
shiftX: minX < 0 ? margin - minX : 0,
|
|
109
|
+
shiftY: minY < 0 ? margin - minY : 0
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
placeNotes,
|
|
115
|
+
noteCanvasShift
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=chunk-6EK55ART.js.map
|