@weasel-js/diagram-formats 1.15.1 → 1.15.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.js +14 -12
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { placedPagesOf, scenePoseAdapter, pageHolding, layoutPages, PAGES_DOC_KEY, pagesOf, nextPageId, addPage, documentOf, isAnnotationLayer, boundsOfPath, layoutTextPose, warmRender, renderSceneToPixels, planPixelRender, viewToMat3, createRasterSession, composeWorldPose, derivedDepOf, IDENTITY_POSE_COMPOSITION, pageName, derivedPartsOf, INHERIT, resolvePartPaint, createScene, mat3, effectivePose } from '@weasel-js/core';
|
|
2
2
|
import { DIAGRAM_TYPES, FLOWCHART_NOTATION, sequenceLayout, diagramThemeFrom, dataEdgeStyle, dataRegionStyle, dataNodeStyle, DIAGRAM_THEME_KEY, diagramLabelOf, endLabelIdOf, sequenceRootOf, offPageSplits, diagramNotationOf, documentBoundsOf, DIAGRAM_TYPE_DOC_KEY, diagramTypeDocValue, themeDocValue, diagramTypeOfNotation, diagramShape, markShape, diagramScene, sequencePartOf, diagramEdgeOf, diagramContainerOf, NODE_STROKE_WIDTH, poolAxisOf, titleIdOf, sequenceSpecs, diagramThemeOf, layoutOwnsRoute, EDGE_STROKE_WIDTH, LAYOUTS, edgeIdOf, themeFont, layoutOwnsPort, DEFAULT_PORTS, LANE_STROKE_WIDTH } from '@weasel-js/diagram';
|
|
3
|
+
import { tryNormalizeHex, parseColor, normalizeHex, rgbaToHex } from '@weasel-js/paint';
|
|
4
|
+
import { deepEqual } from '@weasel-js/registry';
|
|
3
5
|
import { svgNodesFromKit, svgLeafFromKit, warmSvg, serializeSvg, escapeAttr, svgPaintFromKit, svgStrokeFromKit } from '@weasel-js/svg';
|
|
4
6
|
import { replayGitGraph, parseGanttEnd, parseGanttStart, formatGanttEnd, formatGanttStart, plotRootOf, plotSpecs } from '@weasel-js/plot';
|
|
5
7
|
import { writePdf, registryFontSource } from '@weasel-js/pdf';
|
|
@@ -137,7 +139,6 @@ var Warnings = class {
|
|
|
137
139
|
return [...this.seen].map((m) => this.listed.has(m) ? `${m}: ${[...this.listed.get(m)].join(", ")}.` : m);
|
|
138
140
|
}
|
|
139
141
|
};
|
|
140
|
-
var hex2 = (n) => Math.round(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
|
|
141
142
|
var NAMED = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
|
|
142
143
|
function decodeEntities(text3, hash = false) {
|
|
143
144
|
const re = hash ? /[&#](#x[\da-f]+|#\d+|x[\da-f]+(?=;)|\d+|[a-z]+);/gi : /&(#x[\da-f]+|#\d+|[a-z]+);/gi;
|
|
@@ -456,8 +457,6 @@ function parseDot(text3) {
|
|
|
456
457
|
return { kind: "edge", ends, attrs: attrList2(), line };
|
|
457
458
|
}
|
|
458
459
|
}
|
|
459
|
-
|
|
460
|
-
// src/dot/values.ts
|
|
461
460
|
function labelLines(label, self, graph) {
|
|
462
461
|
if (label.html) return markupLines(label.value).filter((l, i, all) => l !== "" || i > 0 && i < all.length - 1);
|
|
463
462
|
const lines = [""];
|
|
@@ -485,7 +484,7 @@ function hsvHex(h, s, v) {
|
|
|
485
484
|
const k = (n + h * 6) % 6;
|
|
486
485
|
return v - v * s * Math.max(0, Math.min(k, 4 - k, 1));
|
|
487
486
|
};
|
|
488
|
-
return
|
|
487
|
+
return rgbaToHex([f(5), f(3), f(1)]);
|
|
489
488
|
}
|
|
490
489
|
function dotColor(value) {
|
|
491
490
|
const first = value.split(":")[0].split(";")[0].trim();
|
|
@@ -907,17 +906,20 @@ function graphOut(doc, opts, format, holdsPools = false) {
|
|
|
907
906
|
return { page, theme, ...tree, byId, edges: [...page.data.edges], warnings };
|
|
908
907
|
}
|
|
909
908
|
function hexColor(css) {
|
|
910
|
-
|
|
911
|
-
if (
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
909
|
+
if (css.startsWith("#")) return tryNormalizeHex(css) ?? css;
|
|
910
|
+
if (!/^rgba?\(/i.test(css)) return css;
|
|
911
|
+
let rgba;
|
|
912
|
+
try {
|
|
913
|
+
rgba = parseColor(css);
|
|
914
|
+
} catch {
|
|
915
|
+
return css;
|
|
916
|
+
}
|
|
917
|
+
return normalizeHex(rgbaToHex(rgba), /\/|(?:,[^,]*){3}/.test(css) ? "rgba" : "rgb");
|
|
916
918
|
}
|
|
917
919
|
function changed(style, base) {
|
|
918
920
|
const out = {};
|
|
919
921
|
for (const key of Object.keys(style)) {
|
|
920
|
-
if (
|
|
922
|
+
if (!deepEqual(style[key], base[key], { undefinedAsAbsent: true })) out[key] = style[key];
|
|
921
923
|
}
|
|
922
924
|
return out;
|
|
923
925
|
}
|
|
@@ -6748,7 +6750,7 @@ var ROUTERS = ["straight", "bezier", "orthogonal", "avoid"];
|
|
|
6748
6750
|
var dataOf = (node) => node?.data ?? {};
|
|
6749
6751
|
var traitOf = (node) => dataOf(node).diagram ?? null;
|
|
6750
6752
|
var colorOf2 = (paint) => typeof paint?.paint?.color === "string" ? paint.paint.color : void 0;
|
|
6751
|
-
var same = (a, b) =>
|
|
6753
|
+
var same = (a, b) => deepEqual(a, b, { undefinedAsAbsent: true });
|
|
6752
6754
|
var moved2 = (p, by) => ({ x: p.x - by.x, y: p.y - by.y });
|
|
6753
6755
|
function kindOf2(node) {
|
|
6754
6756
|
if (sequenceRootOf(node) !== null) return "sequence";
|