@diagrammo/dgmo 0.8.4 → 0.8.5
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/.claude/commands/dgmo.md +267 -0
- package/dist/cli.cjs +188 -185
- package/dist/editor.cjs +2 -0
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.js +2 -0
- package/dist/editor.js.map +1 -1
- package/dist/highlight.cjs +560 -0
- package/dist/highlight.cjs.map +1 -0
- package/dist/highlight.d.cts +32 -0
- package/dist/highlight.d.ts +32 -0
- package/dist/highlight.js +530 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.cjs +117 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +116 -9
- package/dist/index.js.map +1 -1
- package/docs/language-reference.md +17 -9
- package/gallery/fixtures/slope.dgmo +7 -6
- package/package.json +26 -6
- package/src/cli.ts +43 -1
- package/src/d3.ts +161 -19
- package/src/editor/highlight-api.ts +444 -0
- package/src/editor/keywords.ts +2 -0
- package/src/index.ts +96 -31
package/dist/index.cjs
CHANGED
|
@@ -25874,6 +25874,7 @@ function parseVisualization(content, palette) {
|
|
|
25874
25874
|
let timelineEraBlockIndent = 0;
|
|
25875
25875
|
let inTimelineMarkerBlock = false;
|
|
25876
25876
|
let timelineMarkerBlockIndent = 0;
|
|
25877
|
+
let inSlopePeriodBlock = false;
|
|
25877
25878
|
const timelineAliasMap = /* @__PURE__ */ new Map();
|
|
25878
25879
|
const VALID_D3_TYPES = /* @__PURE__ */ new Set([
|
|
25879
25880
|
"slope",
|
|
@@ -26329,6 +26330,118 @@ function parseVisualization(content, palette) {
|
|
|
26329
26330
|
continue;
|
|
26330
26331
|
}
|
|
26331
26332
|
}
|
|
26333
|
+
if (result.type === "slope") {
|
|
26334
|
+
if (inSlopePeriodBlock) {
|
|
26335
|
+
if (indent > 0) {
|
|
26336
|
+
result.periods.push(line10);
|
|
26337
|
+
continue;
|
|
26338
|
+
}
|
|
26339
|
+
inSlopePeriodBlock = false;
|
|
26340
|
+
}
|
|
26341
|
+
if (result.data.length === 0) {
|
|
26342
|
+
const periodMatch = line10.match(/^period\b(.*)$/i);
|
|
26343
|
+
if (periodMatch) {
|
|
26344
|
+
if (result.periods.length > 0 && !inSlopePeriodBlock) {
|
|
26345
|
+
warn(
|
|
26346
|
+
lineNumber,
|
|
26347
|
+
`Duplicate 'period' directive \u2014 periods are already defined`
|
|
26348
|
+
);
|
|
26349
|
+
}
|
|
26350
|
+
const rest = periodMatch[1].trim();
|
|
26351
|
+
if (rest) {
|
|
26352
|
+
const periodLabels = rest.split(/\s+/);
|
|
26353
|
+
result.periods.push(...periodLabels);
|
|
26354
|
+
} else {
|
|
26355
|
+
inSlopePeriodBlock = true;
|
|
26356
|
+
}
|
|
26357
|
+
continue;
|
|
26358
|
+
}
|
|
26359
|
+
}
|
|
26360
|
+
if (result.periods.length === 0 && line10.includes(",") && !line10.includes(":")) {
|
|
26361
|
+
const tokens = line10.split(",").map((t) => t.trim()).filter(Boolean);
|
|
26362
|
+
const looksLikePeriods = tokens.length >= 2 && tokens.every((t) => t.length <= 20);
|
|
26363
|
+
if (looksLikePeriods) {
|
|
26364
|
+
return fail(
|
|
26365
|
+
lineNumber,
|
|
26366
|
+
`Period lines require the 'period' keyword \u2014 use 'period ${tokens.join(" ")}'`
|
|
26367
|
+
);
|
|
26368
|
+
}
|
|
26369
|
+
}
|
|
26370
|
+
if (line10.includes(":")) {
|
|
26371
|
+
const colonPos = line10.indexOf(":");
|
|
26372
|
+
const afterColon = line10.substring(colonPos + 1).trim();
|
|
26373
|
+
const numericTokens = afterColon.split(/[,\s]+/).filter((v) => /^-?\d/.test(v));
|
|
26374
|
+
if (numericTokens.length >= 1) {
|
|
26375
|
+
const allTokens = afterColon.split(/[,\s]+/).filter(Boolean);
|
|
26376
|
+
if (numericTokens.length >= allTokens.length * 0.5) {
|
|
26377
|
+
const label = line10.substring(0, colonPos).trim();
|
|
26378
|
+
return fail(
|
|
26379
|
+
lineNumber,
|
|
26380
|
+
`Colons are no longer used in slope data rows \u2014 use '${label} ${numericTokens.join(" ")}'`
|
|
26381
|
+
);
|
|
26382
|
+
}
|
|
26383
|
+
}
|
|
26384
|
+
}
|
|
26385
|
+
if (result.periods.length >= 2) {
|
|
26386
|
+
const P = result.periods.length;
|
|
26387
|
+
const tokens = line10.split(/\s+/);
|
|
26388
|
+
const values = [];
|
|
26389
|
+
let rightIdx = tokens.length - 1;
|
|
26390
|
+
while (rightIdx >= 0 && values.length < P) {
|
|
26391
|
+
const raw = tokens[rightIdx].replace(/,/g, "");
|
|
26392
|
+
const num = parseFloat(raw);
|
|
26393
|
+
if (!isNaN(num) && /^-?\d/.test(raw)) {
|
|
26394
|
+
values.unshift(num);
|
|
26395
|
+
rightIdx--;
|
|
26396
|
+
} else {
|
|
26397
|
+
break;
|
|
26398
|
+
}
|
|
26399
|
+
}
|
|
26400
|
+
if (values.length < P) {
|
|
26401
|
+
warn(
|
|
26402
|
+
lineNumber,
|
|
26403
|
+
`Data row has ${values.length} numeric value(s) but ${P} period(s) are defined \u2014 expected ${P} values`
|
|
26404
|
+
);
|
|
26405
|
+
continue;
|
|
26406
|
+
}
|
|
26407
|
+
const labelTokens = tokens.slice(0, rightIdx + 1);
|
|
26408
|
+
const joinedLabel = labelTokens.join(" ");
|
|
26409
|
+
if (!joinedLabel) {
|
|
26410
|
+
warn(
|
|
26411
|
+
lineNumber,
|
|
26412
|
+
`Data row has no label \u2014 add a label before the numeric values`
|
|
26413
|
+
);
|
|
26414
|
+
continue;
|
|
26415
|
+
}
|
|
26416
|
+
const colorMatch = joinedLabel.match(/^(.+?)\(([^)]+)\)\s*$/);
|
|
26417
|
+
const labelPart = colorMatch ? colorMatch[1].trim() : joinedLabel;
|
|
26418
|
+
const colorPart = colorMatch ? resolveColor(colorMatch[2].trim(), palette) : null;
|
|
26419
|
+
if (!labelPart) {
|
|
26420
|
+
warn(
|
|
26421
|
+
lineNumber,
|
|
26422
|
+
`Data row has no label \u2014 add a label before the numeric values`
|
|
26423
|
+
);
|
|
26424
|
+
continue;
|
|
26425
|
+
}
|
|
26426
|
+
if (/^\d[\d,.]*$/.test(labelPart)) {
|
|
26427
|
+
warn(
|
|
26428
|
+
lineNumber,
|
|
26429
|
+
`Label '${labelPart}' looks numeric \u2014 this may indicate too many values or a missing label`
|
|
26430
|
+
);
|
|
26431
|
+
}
|
|
26432
|
+
result.data.push({
|
|
26433
|
+
label: labelPart,
|
|
26434
|
+
values,
|
|
26435
|
+
color: colorPart,
|
|
26436
|
+
lineNumber
|
|
26437
|
+
});
|
|
26438
|
+
continue;
|
|
26439
|
+
}
|
|
26440
|
+
if (firstLineParsed) {
|
|
26441
|
+
warn(lineNumber, `Unexpected line: '${line10}'.`);
|
|
26442
|
+
}
|
|
26443
|
+
continue;
|
|
26444
|
+
}
|
|
26332
26445
|
const colonIndex = line10.indexOf(":");
|
|
26333
26446
|
if (colonIndex !== -1) {
|
|
26334
26447
|
const rawKey = line10.substring(0, colonIndex).trim();
|
|
@@ -26418,13 +26531,6 @@ function parseVisualization(content, palette) {
|
|
|
26418
26531
|
}
|
|
26419
26532
|
continue;
|
|
26420
26533
|
}
|
|
26421
|
-
if (result.periods.length === 0 && line10.includes(",") && !line10.includes(":")) {
|
|
26422
|
-
const periods = line10.split(",").map((p) => p.trim()).filter(Boolean);
|
|
26423
|
-
if (periods.length >= 2) {
|
|
26424
|
-
result.periods = periods;
|
|
26425
|
-
continue;
|
|
26426
|
-
}
|
|
26427
|
-
}
|
|
26428
26534
|
if (firstLineParsed) {
|
|
26429
26535
|
warn(lineNumber, `Unexpected line: '${line10}'.`);
|
|
26430
26536
|
}
|
|
@@ -26562,13 +26668,13 @@ function parseVisualization(content, palette) {
|
|
|
26562
26668
|
if (result.periods.length < 2) {
|
|
26563
26669
|
return fail(
|
|
26564
26670
|
1,
|
|
26565
|
-
|
|
26671
|
+
"Missing 'period' directive. Add 'period 2020 2024' before data rows (minimum 2 periods required)"
|
|
26566
26672
|
);
|
|
26567
26673
|
}
|
|
26568
26674
|
if (result.data.length === 0) {
|
|
26569
26675
|
warn(
|
|
26570
26676
|
1,
|
|
26571
|
-
|
|
26677
|
+
"No data lines found. Add data as 'Label value1 value2' (e.g., 'Blackbeard 40 4')"
|
|
26572
26678
|
);
|
|
26573
26679
|
}
|
|
26574
26680
|
for (const item of result.data) {
|
|
@@ -29828,6 +29934,7 @@ __export(index_exports, {
|
|
|
29828
29934
|
parseC4: () => parseC4,
|
|
29829
29935
|
parseChart: () => parseChart,
|
|
29830
29936
|
parseClassDiagram: () => parseClassDiagram,
|
|
29937
|
+
parseDataRowValues: () => parseDataRowValues,
|
|
29831
29938
|
parseDgmo: () => parseDgmo,
|
|
29832
29939
|
parseDgmoChartType: () => parseDgmoChartType,
|
|
29833
29940
|
parseERDiagram: () => parseERDiagram,
|
|
@@ -31586,6 +31693,7 @@ init_branding();
|
|
|
31586
31693
|
parseC4,
|
|
31587
31694
|
parseChart,
|
|
31588
31695
|
parseClassDiagram,
|
|
31696
|
+
parseDataRowValues,
|
|
31589
31697
|
parseDgmo,
|
|
31590
31698
|
parseDgmoChartType,
|
|
31591
31699
|
parseERDiagram,
|