@dskripchenko/diagrams 1.0.0 → 1.0.2
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/index.cjs +20 -11
- package/dist/index.mjs +20 -11
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -398,6 +398,7 @@ function context() {
|
|
|
398
398
|
canvasContext = null;
|
|
399
399
|
try {
|
|
400
400
|
const g = globalThis;
|
|
401
|
+
if (g.navigator?.userAgent?.includes("jsdom")) return canvasContext;
|
|
401
402
|
if (typeof g.OffscreenCanvas === "function") canvasContext = new g.OffscreenCanvas(1, 1).getContext("2d");
|
|
402
403
|
else if (g.document && typeof g.document.createElement === "function") canvasContext = g.document.createElement("canvas").getContext("2d");
|
|
403
404
|
if (canvasContext && canvasContext.measureText("M").width <= 0) canvasContext = null;
|
|
@@ -6079,6 +6080,7 @@ function actor(a) {
|
|
|
6079
6080
|
ry: 4
|
|
6080
6081
|
}), renderLabel(a.label, a.x, a.top + a.height / 2, { className: "dg-actor-label" })]);
|
|
6081
6082
|
}
|
|
6083
|
+
/** A block's outline and section rules: drawn under the activation bars. */
|
|
6082
6084
|
function frame(f) {
|
|
6083
6085
|
const parts = [el("rect", {
|
|
6084
6086
|
class: "dg-block",
|
|
@@ -6087,6 +6089,21 @@ function frame(f) {
|
|
|
6087
6089
|
width: f.right - f.left,
|
|
6088
6090
|
height: f.bottom - f.top
|
|
6089
6091
|
})];
|
|
6092
|
+
for (const section of f.sections) parts.push(el("line", {
|
|
6093
|
+
class: "dg-block-sep",
|
|
6094
|
+
x1: f.left,
|
|
6095
|
+
y1: section.y,
|
|
6096
|
+
x2: f.right,
|
|
6097
|
+
y2: section.y
|
|
6098
|
+
}));
|
|
6099
|
+
return el("g", { class: `dg-frame dg-frame-${f.block}` }, parts);
|
|
6100
|
+
}
|
|
6101
|
+
/**
|
|
6102
|
+
* A block's tab and guard texts: drawn over the activation bars, which would
|
|
6103
|
+
* otherwise cut through a label like "loop" that sits on a lifeline.
|
|
6104
|
+
*/
|
|
6105
|
+
function frameLabels(f) {
|
|
6106
|
+
const parts = [];
|
|
6090
6107
|
if (f.tab) {
|
|
6091
6108
|
const w = f.tabWidth;
|
|
6092
6109
|
const tab = [
|
|
@@ -6105,17 +6122,8 @@ function frame(f) {
|
|
|
6105
6122
|
anchor: "start",
|
|
6106
6123
|
className: "dg-block-guard"
|
|
6107
6124
|
}));
|
|
6108
|
-
for (const section of f.sections) {
|
|
6109
|
-
|
|
6110
|
-
class: "dg-block-sep",
|
|
6111
|
-
x1: f.left,
|
|
6112
|
-
y1: section.y,
|
|
6113
|
-
x2: f.right,
|
|
6114
|
-
y2: section.y
|
|
6115
|
-
}));
|
|
6116
|
-
if (section.guard) parts.push(renderLabel(section.guard, (f.left + f.right) / 2, section.y + 4 + section.guard.height / 2, { className: "dg-block-guard" }));
|
|
6117
|
-
}
|
|
6118
|
-
return el("g", { class: `dg-frame dg-frame-${f.block}` }, parts);
|
|
6125
|
+
for (const section of f.sections) if (section.guard) parts.push(renderLabel(section.guard, (f.left + f.right) / 2, section.y + 4 + section.guard.height / 2, { className: "dg-block-guard" }));
|
|
6126
|
+
return el("g", { class: `dg-frame-labels dg-frame-${f.block}` }, parts.filter((p) => !!p));
|
|
6119
6127
|
}
|
|
6120
6128
|
function message(m, prefix) {
|
|
6121
6129
|
const kind = markerFor(m.head);
|
|
@@ -6197,6 +6205,7 @@ function renderSequenceLayout(layout, id, title, description) {
|
|
|
6197
6205
|
width: 10,
|
|
6198
6206
|
height: a.bottom - a.top
|
|
6199
6207
|
}))),
|
|
6208
|
+
el("g", { class: "dg-frame-label-layer" }, layout.frames.map(frameLabels)),
|
|
6200
6209
|
el("g", { class: "dg-messages" }, layout.messages.map((m) => message(m, id))),
|
|
6201
6210
|
el("g", { class: "dg-notes" }, layout.notes.map((n) => el("g", { class: "dg-note-group" }, [el("rect", {
|
|
6202
6211
|
class: "dg-note",
|
package/dist/index.mjs
CHANGED
|
@@ -397,6 +397,7 @@ function context() {
|
|
|
397
397
|
canvasContext = null;
|
|
398
398
|
try {
|
|
399
399
|
const g = globalThis;
|
|
400
|
+
if (g.navigator?.userAgent?.includes("jsdom")) return canvasContext;
|
|
400
401
|
if (typeof g.OffscreenCanvas === "function") canvasContext = new g.OffscreenCanvas(1, 1).getContext("2d");
|
|
401
402
|
else if (g.document && typeof g.document.createElement === "function") canvasContext = g.document.createElement("canvas").getContext("2d");
|
|
402
403
|
if (canvasContext && canvasContext.measureText("M").width <= 0) canvasContext = null;
|
|
@@ -6078,6 +6079,7 @@ function actor(a) {
|
|
|
6078
6079
|
ry: 4
|
|
6079
6080
|
}), renderLabel(a.label, a.x, a.top + a.height / 2, { className: "dg-actor-label" })]);
|
|
6080
6081
|
}
|
|
6082
|
+
/** A block's outline and section rules: drawn under the activation bars. */
|
|
6081
6083
|
function frame(f) {
|
|
6082
6084
|
const parts = [el("rect", {
|
|
6083
6085
|
class: "dg-block",
|
|
@@ -6086,6 +6088,21 @@ function frame(f) {
|
|
|
6086
6088
|
width: f.right - f.left,
|
|
6087
6089
|
height: f.bottom - f.top
|
|
6088
6090
|
})];
|
|
6091
|
+
for (const section of f.sections) parts.push(el("line", {
|
|
6092
|
+
class: "dg-block-sep",
|
|
6093
|
+
x1: f.left,
|
|
6094
|
+
y1: section.y,
|
|
6095
|
+
x2: f.right,
|
|
6096
|
+
y2: section.y
|
|
6097
|
+
}));
|
|
6098
|
+
return el("g", { class: `dg-frame dg-frame-${f.block}` }, parts);
|
|
6099
|
+
}
|
|
6100
|
+
/**
|
|
6101
|
+
* A block's tab and guard texts: drawn over the activation bars, which would
|
|
6102
|
+
* otherwise cut through a label like "loop" that sits on a lifeline.
|
|
6103
|
+
*/
|
|
6104
|
+
function frameLabels(f) {
|
|
6105
|
+
const parts = [];
|
|
6089
6106
|
if (f.tab) {
|
|
6090
6107
|
const w = f.tabWidth;
|
|
6091
6108
|
const tab = [
|
|
@@ -6104,17 +6121,8 @@ function frame(f) {
|
|
|
6104
6121
|
anchor: "start",
|
|
6105
6122
|
className: "dg-block-guard"
|
|
6106
6123
|
}));
|
|
6107
|
-
for (const section of f.sections) {
|
|
6108
|
-
|
|
6109
|
-
class: "dg-block-sep",
|
|
6110
|
-
x1: f.left,
|
|
6111
|
-
y1: section.y,
|
|
6112
|
-
x2: f.right,
|
|
6113
|
-
y2: section.y
|
|
6114
|
-
}));
|
|
6115
|
-
if (section.guard) parts.push(renderLabel(section.guard, (f.left + f.right) / 2, section.y + 4 + section.guard.height / 2, { className: "dg-block-guard" }));
|
|
6116
|
-
}
|
|
6117
|
-
return el("g", { class: `dg-frame dg-frame-${f.block}` }, parts);
|
|
6124
|
+
for (const section of f.sections) if (section.guard) parts.push(renderLabel(section.guard, (f.left + f.right) / 2, section.y + 4 + section.guard.height / 2, { className: "dg-block-guard" }));
|
|
6125
|
+
return el("g", { class: `dg-frame-labels dg-frame-${f.block}` }, parts.filter((p) => !!p));
|
|
6118
6126
|
}
|
|
6119
6127
|
function message(m, prefix) {
|
|
6120
6128
|
const kind = markerFor(m.head);
|
|
@@ -6196,6 +6204,7 @@ function renderSequenceLayout(layout, id, title, description) {
|
|
|
6196
6204
|
width: 10,
|
|
6197
6205
|
height: a.bottom - a.top
|
|
6198
6206
|
}))),
|
|
6207
|
+
el("g", { class: "dg-frame-label-layer" }, layout.frames.map(frameLabels)),
|
|
6199
6208
|
el("g", { class: "dg-messages" }, layout.messages.map((m) => message(m, id))),
|
|
6200
6209
|
el("g", { class: "dg-notes" }, layout.notes.map((n) => el("g", { class: "dg-note-group" }, [el("rect", {
|
|
6201
6210
|
class: "dg-note",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dskripchenko/diagrams",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Mermaid-syntax diagrams rendered to SVG with zero runtime dependencies — flowchart, sequence, state, pie, gantt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"diagram",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=20"
|
|
32
32
|
},
|
|
33
|
-
"packageManager": "pnpm@10.28.0",
|
|
34
33
|
"publishConfig": {
|
|
35
34
|
"access": "public"
|
|
36
35
|
},
|
|
@@ -50,21 +49,12 @@
|
|
|
50
49
|
"dist",
|
|
51
50
|
"!dist/**/*.map"
|
|
52
51
|
],
|
|
53
|
-
"scripts": {
|
|
54
|
-
"build": "tsc --noEmit -p tsconfig.build.json && vite build",
|
|
55
|
-
"test": "vitest run",
|
|
56
|
-
"test:watch": "vitest",
|
|
57
|
-
"lint": "eslint src tests scripts",
|
|
58
|
-
"typecheck": "tsc --noEmit",
|
|
59
|
-
"changeset": "changeset",
|
|
60
|
-
"release": "pnpm build && changeset publish",
|
|
61
|
-
"check:browser": "node scripts/browser-check.mjs"
|
|
62
|
-
},
|
|
63
52
|
"devDependencies": {
|
|
64
53
|
"@changesets/cli": "^3.0.3",
|
|
65
54
|
"@eslint/js": "^10.0.1",
|
|
66
55
|
"@microsoft/api-extractor": "^7.59.4",
|
|
67
56
|
"eslint": "^10.13.0",
|
|
57
|
+
"jsdom": "^29.1.1",
|
|
68
58
|
"playwright": "1.64.1",
|
|
69
59
|
"prettier": "^3.9.10",
|
|
70
60
|
"typescript": "^6.0.3",
|
|
@@ -72,5 +62,15 @@
|
|
|
72
62
|
"vite": "^8.3.5",
|
|
73
63
|
"vite-plugin-dts": "^5.1.2",
|
|
74
64
|
"vitest": "^5.0.5"
|
|
65
|
+
},
|
|
66
|
+
"scripts": {
|
|
67
|
+
"build": "tsc --noEmit -p tsconfig.build.json && vite build",
|
|
68
|
+
"test": "vitest run",
|
|
69
|
+
"test:watch": "vitest",
|
|
70
|
+
"lint": "eslint src tests scripts",
|
|
71
|
+
"typecheck": "tsc --noEmit",
|
|
72
|
+
"changeset": "changeset",
|
|
73
|
+
"release": "pnpm build && changeset publish",
|
|
74
|
+
"check:browser": "node scripts/browser-check.mjs"
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|