@diagrammo/dgmo 0.25.3 → 0.25.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/dist/advanced.cjs +131 -42
- package/dist/advanced.js +131 -42
- package/dist/auto.cjs +123 -37
- package/dist/auto.js +95 -95
- package/dist/auto.mjs +123 -37
- package/dist/cli.cjs +144 -144
- package/dist/index.cjs +122 -36
- package/dist/index.js +122 -36
- package/dist/internal.cjs +131 -42
- package/dist/internal.js +131 -42
- package/package.json +1 -1
- package/src/cli.ts +0 -9
- package/src/d3.ts +180 -46
- package/src/render.ts +80 -39
package/dist/auto.cjs
CHANGED
|
@@ -55726,6 +55726,59 @@ function getRotateFn(mode) {
|
|
|
55726
55726
|
if (mode === "angled") return () => Math.round(Math.random() * 30 - 15);
|
|
55727
55727
|
return () => 0;
|
|
55728
55728
|
}
|
|
55729
|
+
function hasCanvas2d() {
|
|
55730
|
+
try {
|
|
55731
|
+
if (typeof document === "undefined") return false;
|
|
55732
|
+
const canvas = document.createElement("canvas");
|
|
55733
|
+
return typeof canvas.getContext === "function" && !!canvas.getContext("2d");
|
|
55734
|
+
} catch {
|
|
55735
|
+
return false;
|
|
55736
|
+
}
|
|
55737
|
+
}
|
|
55738
|
+
function estimateWordWidth(text, size) {
|
|
55739
|
+
return text.length * size * WORDCLOUD_GLYPH_ADVANCE;
|
|
55740
|
+
}
|
|
55741
|
+
function layoutWordsNoCanvas(words, width, height, padding, rotateFn) {
|
|
55742
|
+
const sorted = [...words].sort((a, b) => b.size - a.size);
|
|
55743
|
+
const placed = [];
|
|
55744
|
+
const maxR = Math.sqrt(width * width + height * height) / 2;
|
|
55745
|
+
const aspect = width > 0 ? height / width : 1;
|
|
55746
|
+
for (const w of sorted) {
|
|
55747
|
+
const rotate = rotateFn();
|
|
55748
|
+
const rawW = estimateWordWidth(w.text, w.size) + padding * 2;
|
|
55749
|
+
const rawH = w.size + padding * 2;
|
|
55750
|
+
const rad = rotate * Math.PI / 180;
|
|
55751
|
+
const cos = Math.abs(Math.cos(rad));
|
|
55752
|
+
const sin = Math.abs(Math.sin(rad));
|
|
55753
|
+
const halfW = (rawW * cos + rawH * sin) / 2;
|
|
55754
|
+
const halfH = (rawW * sin + rawH * cos) / 2;
|
|
55755
|
+
let spot = null;
|
|
55756
|
+
for (let t = 0; t < 4e3; t++) {
|
|
55757
|
+
const a = t * 0.25;
|
|
55758
|
+
const r = a * 1.4;
|
|
55759
|
+
if (r > maxR) break;
|
|
55760
|
+
const x = Math.cos(a) * r;
|
|
55761
|
+
const y = Math.sin(a) * r * aspect;
|
|
55762
|
+
if (x - halfW < -width / 2 || x + halfW > width / 2 || y - halfH < -height / 2 || y + halfH > height / 2) {
|
|
55763
|
+
continue;
|
|
55764
|
+
}
|
|
55765
|
+
let collides = false;
|
|
55766
|
+
for (const p of placed) {
|
|
55767
|
+
if (Math.abs(x - p.x) < halfW + p.halfW && Math.abs(y - p.y) < halfH + p.halfH) {
|
|
55768
|
+
collides = true;
|
|
55769
|
+
break;
|
|
55770
|
+
}
|
|
55771
|
+
}
|
|
55772
|
+
if (!collides) {
|
|
55773
|
+
spot = { x, y };
|
|
55774
|
+
break;
|
|
55775
|
+
}
|
|
55776
|
+
}
|
|
55777
|
+
if (!spot) continue;
|
|
55778
|
+
placed.push({ ...w, rotate, x: spot.x, y: spot.y, halfW, halfH });
|
|
55779
|
+
}
|
|
55780
|
+
return placed;
|
|
55781
|
+
}
|
|
55729
55782
|
function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
|
|
55730
55783
|
return new Promise((resolve) => {
|
|
55731
55784
|
d3Selection23.select(container).selectAll(":not([data-d3-tooltip])").remove();
|
|
@@ -55762,13 +55815,19 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
|
|
|
55762
55815
|
"transform",
|
|
55763
55816
|
`translate(${width / 2},${titleHeight + cloudHeight / 2})`
|
|
55764
55817
|
);
|
|
55765
|
-
|
|
55818
|
+
const sized = words.map((w) => ({ ...w, size: fontSize(w.weight) }));
|
|
55819
|
+
const draw = (layoutWords) => {
|
|
55766
55820
|
g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", FONT_FAMILY).style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).attr("text-anchor", "middle").attr(
|
|
55767
55821
|
"transform",
|
|
55768
55822
|
(d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
|
|
55769
55823
|
).text((d) => d.text);
|
|
55770
55824
|
resolve();
|
|
55771
|
-
}
|
|
55825
|
+
};
|
|
55826
|
+
if (!hasCanvas2d()) {
|
|
55827
|
+
draw(layoutWordsNoCanvas(sized, width, cloudHeight, 2, rotateFn));
|
|
55828
|
+
return;
|
|
55829
|
+
}
|
|
55830
|
+
(0, import_d3_cloud.default)().size([width, cloudHeight]).words(sized).padding(2).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", draw).start();
|
|
55772
55831
|
});
|
|
55773
55832
|
}
|
|
55774
55833
|
function fitCirclesToContainerAsymmetric(circles, w, h, mLeft, mRight, mTop, mBottom) {
|
|
@@ -57579,7 +57638,7 @@ async function renderForExport(content, theme, palette, viewState, options) {
|
|
|
57579
57638
|
}
|
|
57580
57639
|
return finalizeSvgExport(container, theme, effectivePalette);
|
|
57581
57640
|
}
|
|
57582
|
-
var d3Scale2, d3Selection23, d3Shape11, d3Array, import_d3_cloud, DEFAULT_CLOUD_OPTIONS, STOP_WORDS, SLOPE_MARGIN, SLOPE_LABEL_FONT_SIZE, SLOPE_CHAR_WIDTH, ARC_MARGIN_TOP, ARC_MARGIN_RIGHT, ARC_MARGIN_BOTTOM, ARC_MARGIN_LEFT, ARC_MARGIN_LEFT_VERTICAL, ARC_NODE_RADIUS, ARC_NODE_STROKE_WIDTH, ARC_NODE_LABEL_FONT, ARC_GROUP_LABEL_FONT, ARC_BAND_HALF_W, ARC_BAND_HALF_H, ARC_BAND_RADIUS, ARC_BAND_LABEL_X_OFFSET, ARC_BAND_LABEL_Y_OFFSET, ARC_BAND_LABEL_BOTTOM_OFFSET, ARC_NODE_LABEL_X_OFFSET, ARC_NODE_LABEL_Y_OFFSET, ARC_STROKE_MIN, ARC_STROKE_MAX, ARC_BASELINE_STROKE_WIDTH, timelineCollapseState, tlBandClipCounter, EXPORT_WIDTH, EXPORT_HEIGHT;
|
|
57641
|
+
var d3Scale2, d3Selection23, d3Shape11, d3Array, import_d3_cloud, DEFAULT_CLOUD_OPTIONS, STOP_WORDS, SLOPE_MARGIN, SLOPE_LABEL_FONT_SIZE, SLOPE_CHAR_WIDTH, ARC_MARGIN_TOP, ARC_MARGIN_RIGHT, ARC_MARGIN_BOTTOM, ARC_MARGIN_LEFT, ARC_MARGIN_LEFT_VERTICAL, ARC_NODE_RADIUS, ARC_NODE_STROKE_WIDTH, ARC_NODE_LABEL_FONT, ARC_GROUP_LABEL_FONT, ARC_BAND_HALF_W, ARC_BAND_HALF_H, ARC_BAND_RADIUS, ARC_BAND_LABEL_X_OFFSET, ARC_BAND_LABEL_Y_OFFSET, ARC_BAND_LABEL_BOTTOM_OFFSET, ARC_NODE_LABEL_X_OFFSET, ARC_NODE_LABEL_Y_OFFSET, ARC_STROKE_MIN, ARC_STROKE_MAX, ARC_BASELINE_STROKE_WIDTH, timelineCollapseState, tlBandClipCounter, WORDCLOUD_GLYPH_ADVANCE, EXPORT_WIDTH, EXPORT_HEIGHT;
|
|
57583
57642
|
var init_d3 = __esm({
|
|
57584
57643
|
"src/d3.ts"() {
|
|
57585
57644
|
"use strict";
|
|
@@ -57745,6 +57804,7 @@ var init_d3 = __esm({
|
|
|
57745
57804
|
ARC_BASELINE_STROKE_WIDTH = 1;
|
|
57746
57805
|
timelineCollapseState = /* @__PURE__ */ new WeakMap();
|
|
57747
57806
|
tlBandClipCounter = 0;
|
|
57807
|
+
WORDCLOUD_GLYPH_ADVANCE = 0.62;
|
|
57748
57808
|
EXPORT_WIDTH = 1200;
|
|
57749
57809
|
EXPORT_HEIGHT = 800;
|
|
57750
57810
|
}
|
|
@@ -58226,31 +58286,52 @@ init_d3();
|
|
|
58226
58286
|
init_echarts();
|
|
58227
58287
|
init_dgmo_router();
|
|
58228
58288
|
init_registry();
|
|
58229
|
-
|
|
58230
|
-
|
|
58289
|
+
var DOM_GLOBALS = [
|
|
58290
|
+
"document",
|
|
58291
|
+
"window",
|
|
58292
|
+
"navigator",
|
|
58293
|
+
"HTMLElement",
|
|
58294
|
+
"SVGElement"
|
|
58295
|
+
];
|
|
58296
|
+
var domRefCount = 0;
|
|
58297
|
+
var domInstallPromise = null;
|
|
58298
|
+
var domInstalledByUs = false;
|
|
58299
|
+
async function installDom() {
|
|
58231
58300
|
const { JSDOM } = await loadJsdom();
|
|
58232
|
-
const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>"
|
|
58233
|
-
|
|
58234
|
-
Object.defineProperty(globalThis, "document", {
|
|
58235
|
-
value: win.document,
|
|
58236
|
-
configurable: true
|
|
58237
|
-
});
|
|
58238
|
-
Object.defineProperty(globalThis, "window", {
|
|
58239
|
-
value: win,
|
|
58240
|
-
configurable: true
|
|
58241
|
-
});
|
|
58242
|
-
Object.defineProperty(globalThis, "navigator", {
|
|
58243
|
-
value: win.navigator,
|
|
58244
|
-
configurable: true
|
|
58245
|
-
});
|
|
58246
|
-
Object.defineProperty(globalThis, "HTMLElement", {
|
|
58247
|
-
value: win.HTMLElement,
|
|
58248
|
-
configurable: true
|
|
58249
|
-
});
|
|
58250
|
-
Object.defineProperty(globalThis, "SVGElement", {
|
|
58251
|
-
value: win.SVGElement,
|
|
58252
|
-
configurable: true
|
|
58301
|
+
const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>", {
|
|
58302
|
+
url: "http://localhost/"
|
|
58253
58303
|
});
|
|
58304
|
+
const win = dom.window;
|
|
58305
|
+
const values = {
|
|
58306
|
+
document: win.document,
|
|
58307
|
+
window: win,
|
|
58308
|
+
navigator: win.navigator,
|
|
58309
|
+
HTMLElement: win.HTMLElement,
|
|
58310
|
+
SVGElement: win.SVGElement
|
|
58311
|
+
};
|
|
58312
|
+
for (const key of DOM_GLOBALS) {
|
|
58313
|
+
Object.defineProperty(globalThis, key, {
|
|
58314
|
+
value: values[key],
|
|
58315
|
+
configurable: true
|
|
58316
|
+
});
|
|
58317
|
+
}
|
|
58318
|
+
domInstalledByUs = true;
|
|
58319
|
+
}
|
|
58320
|
+
async function acquireDom() {
|
|
58321
|
+
if (typeof document !== "undefined" && !domInstalledByUs) return;
|
|
58322
|
+
domRefCount++;
|
|
58323
|
+
if (!domInstallPromise) domInstallPromise = installDom();
|
|
58324
|
+
await domInstallPromise;
|
|
58325
|
+
}
|
|
58326
|
+
function releaseDom() {
|
|
58327
|
+
if (!domInstalledByUs) return;
|
|
58328
|
+
if (--domRefCount > 0) return;
|
|
58329
|
+
for (const key of DOM_GLOBALS) {
|
|
58330
|
+
delete globalThis[key];
|
|
58331
|
+
}
|
|
58332
|
+
domInstalledByUs = false;
|
|
58333
|
+
domInstallPromise = null;
|
|
58334
|
+
domRefCount = 0;
|
|
58254
58335
|
}
|
|
58255
58336
|
async function loadJsdom() {
|
|
58256
58337
|
const spec = ["js", "dom"].join("");
|
|
@@ -58284,16 +58365,21 @@ async function render(content, options) {
|
|
|
58284
58365
|
);
|
|
58285
58366
|
return { svg: svg2, diagnostics };
|
|
58286
58367
|
}
|
|
58287
|
-
await
|
|
58288
|
-
|
|
58289
|
-
|
|
58290
|
-
|
|
58291
|
-
|
|
58292
|
-
|
|
58293
|
-
|
|
58294
|
-
|
|
58295
|
-
|
|
58296
|
-
|
|
58368
|
+
await acquireDom();
|
|
58369
|
+
let svg;
|
|
58370
|
+
try {
|
|
58371
|
+
svg = await renderForExport(content, theme, paletteColors, viewState, {
|
|
58372
|
+
...options?.c4Level !== void 0 && { c4Level: options.c4Level },
|
|
58373
|
+
...options?.c4System !== void 0 && { c4System: options.c4System },
|
|
58374
|
+
...options?.c4Container !== void 0 && {
|
|
58375
|
+
c4Container: options.c4Container
|
|
58376
|
+
},
|
|
58377
|
+
...options?.tagGroup !== void 0 && { tagGroup: options.tagGroup },
|
|
58378
|
+
...options?.mapData !== void 0 && { mapData: options.mapData }
|
|
58379
|
+
});
|
|
58380
|
+
} finally {
|
|
58381
|
+
releaseDom();
|
|
58382
|
+
}
|
|
58297
58383
|
if (chartType === "map") {
|
|
58298
58384
|
try {
|
|
58299
58385
|
const [{ parseMap: parseMap2 }, { resolveMap: resolveMap2 }, { loadMapData: loadMapData2 }] = await Promise.all(
|
|
@@ -59158,7 +59244,7 @@ pre.dgmo, code.language-dgmo, pre > code.language-dgmo,
|
|
|
59158
59244
|
|
|
59159
59245
|
// src/auto/index.ts
|
|
59160
59246
|
init_safe_href();
|
|
59161
|
-
var VERSION = "0.25.
|
|
59247
|
+
var VERSION = "0.25.5";
|
|
59162
59248
|
var DEFAULTS = {
|
|
59163
59249
|
theme: "auto",
|
|
59164
59250
|
palette: "nord",
|