@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 CHANGED
@@ -56088,6 +56088,59 @@ function getRotateFn(mode) {
56088
56088
  if (mode === "angled") return () => Math.round(Math.random() * 30 - 15);
56089
56089
  return () => 0;
56090
56090
  }
56091
+ function hasCanvas2d() {
56092
+ try {
56093
+ if (typeof document === "undefined") return false;
56094
+ const canvas = document.createElement("canvas");
56095
+ return typeof canvas.getContext === "function" && !!canvas.getContext("2d");
56096
+ } catch {
56097
+ return false;
56098
+ }
56099
+ }
56100
+ function estimateWordWidth(text, size) {
56101
+ return text.length * size * WORDCLOUD_GLYPH_ADVANCE;
56102
+ }
56103
+ function layoutWordsNoCanvas(words, width, height, padding, rotateFn) {
56104
+ const sorted = [...words].sort((a, b) => b.size - a.size);
56105
+ const placed = [];
56106
+ const maxR = Math.sqrt(width * width + height * height) / 2;
56107
+ const aspect = width > 0 ? height / width : 1;
56108
+ for (const w of sorted) {
56109
+ const rotate = rotateFn();
56110
+ const rawW = estimateWordWidth(w.text, w.size) + padding * 2;
56111
+ const rawH = w.size + padding * 2;
56112
+ const rad = rotate * Math.PI / 180;
56113
+ const cos = Math.abs(Math.cos(rad));
56114
+ const sin = Math.abs(Math.sin(rad));
56115
+ const halfW = (rawW * cos + rawH * sin) / 2;
56116
+ const halfH = (rawW * sin + rawH * cos) / 2;
56117
+ let spot = null;
56118
+ for (let t = 0; t < 4e3; t++) {
56119
+ const a = t * 0.25;
56120
+ const r = a * 1.4;
56121
+ if (r > maxR) break;
56122
+ const x = Math.cos(a) * r;
56123
+ const y = Math.sin(a) * r * aspect;
56124
+ if (x - halfW < -width / 2 || x + halfW > width / 2 || y - halfH < -height / 2 || y + halfH > height / 2) {
56125
+ continue;
56126
+ }
56127
+ let collides = false;
56128
+ for (const p of placed) {
56129
+ if (Math.abs(x - p.x) < halfW + p.halfW && Math.abs(y - p.y) < halfH + p.halfH) {
56130
+ collides = true;
56131
+ break;
56132
+ }
56133
+ }
56134
+ if (!collides) {
56135
+ spot = { x, y };
56136
+ break;
56137
+ }
56138
+ }
56139
+ if (!spot) continue;
56140
+ placed.push({ ...w, rotate, x: spot.x, y: spot.y, halfW, halfH });
56141
+ }
56142
+ return placed;
56143
+ }
56091
56144
  function renderWordCloud(container, parsed, palette, _isDark, onClickItem, exportDims) {
56092
56145
  const { words, cloudOptions } = parsed;
56093
56146
  const title = parsed.noTitle ? null : parsed.title;
@@ -56128,21 +56181,24 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
56128
56181
  "transform",
56129
56182
  `translate(${width / 2},${sTitleHeight + cloudHeight / 2})`
56130
56183
  );
56131
- (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(sPadding).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
56184
+ const sized = words.map((w) => ({ ...w, size: fontSize(w.weight) }));
56185
+ const draw = (layoutWords) => {
56132
56186
  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]).style(
56133
56187
  "cursor",
56134
56188
  (d) => onClickItem && d.lineNumber ? "pointer" : "default"
56135
- ).attr("text-anchor", "middle").attr(
56136
- "transform",
56137
- (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
56138
- ).attr("data-line-number", (d) => {
56189
+ ).attr("text-anchor", "middle").attr("transform", (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`).attr("data-line-number", (d) => {
56139
56190
  const ln = d.lineNumber;
56140
56191
  return ln ? String(ln) : null;
56141
56192
  }).text((d) => d.text).on("click", (_event, d) => {
56142
56193
  const ln = d.lineNumber;
56143
56194
  if (onClickItem && ln) onClickItem(ln);
56144
56195
  });
56145
- }).start();
56196
+ };
56197
+ if (!hasCanvas2d()) {
56198
+ draw(layoutWordsNoCanvas(sized, width, cloudHeight, sPadding, rotateFn));
56199
+ return;
56200
+ }
56201
+ (0, import_d3_cloud.default)().size([width, cloudHeight]).words(sized).padding(sPadding).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", draw).start();
56146
56202
  }
56147
56203
  function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
56148
56204
  return new Promise((resolve) => {
@@ -56180,13 +56236,19 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
56180
56236
  "transform",
56181
56237
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
56182
56238
  );
56183
- (0, import_d3_cloud.default)().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(2).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
56239
+ const sized = words.map((w) => ({ ...w, size: fontSize(w.weight) }));
56240
+ const draw = (layoutWords) => {
56184
56241
  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(
56185
56242
  "transform",
56186
56243
  (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
56187
56244
  ).text((d) => d.text);
56188
56245
  resolve();
56189
- }).start();
56246
+ };
56247
+ if (!hasCanvas2d()) {
56248
+ draw(layoutWordsNoCanvas(sized, width, cloudHeight, 2, rotateFn));
56249
+ return;
56250
+ }
56251
+ (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();
56190
56252
  });
56191
56253
  }
56192
56254
  function fitCirclesToContainerAsymmetric(circles, w, h, mLeft, mRight, mTop, mBottom) {
@@ -57997,7 +58059,7 @@ async function renderForExport(content, theme, palette, viewState, options) {
57997
58059
  }
57998
58060
  return finalizeSvgExport(container, theme, effectivePalette);
57999
58061
  }
58000
- 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;
58062
+ 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;
58001
58063
  var init_d3 = __esm({
58002
58064
  "src/d3.ts"() {
58003
58065
  "use strict";
@@ -58164,6 +58226,7 @@ var init_d3 = __esm({
58164
58226
  ARC_BASELINE_STROKE_WIDTH = 1;
58165
58227
  timelineCollapseState = /* @__PURE__ */ new WeakMap();
58166
58228
  tlBandClipCounter = 0;
58229
+ WORDCLOUD_GLYPH_ADVANCE = 0.62;
58167
58230
  EXPORT_WIDTH = 1200;
58168
58231
  EXPORT_HEIGHT = 800;
58169
58232
  }
@@ -58911,31 +58974,52 @@ init_d3();
58911
58974
  init_echarts();
58912
58975
  init_dgmo_router();
58913
58976
  init_registry();
58914
- async function ensureDom() {
58915
- if (typeof document !== "undefined") return;
58977
+ var DOM_GLOBALS = [
58978
+ "document",
58979
+ "window",
58980
+ "navigator",
58981
+ "HTMLElement",
58982
+ "SVGElement"
58983
+ ];
58984
+ var domRefCount = 0;
58985
+ var domInstallPromise = null;
58986
+ var domInstalledByUs = false;
58987
+ async function installDom() {
58916
58988
  const { JSDOM } = await loadJsdom();
58917
- const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>");
58918
- const win = dom.window;
58919
- Object.defineProperty(globalThis, "document", {
58920
- value: win.document,
58921
- configurable: true
58922
- });
58923
- Object.defineProperty(globalThis, "window", {
58924
- value: win,
58925
- configurable: true
58926
- });
58927
- Object.defineProperty(globalThis, "navigator", {
58928
- value: win.navigator,
58929
- configurable: true
58930
- });
58931
- Object.defineProperty(globalThis, "HTMLElement", {
58932
- value: win.HTMLElement,
58933
- configurable: true
58934
- });
58935
- Object.defineProperty(globalThis, "SVGElement", {
58936
- value: win.SVGElement,
58937
- configurable: true
58989
+ const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>", {
58990
+ url: "http://localhost/"
58938
58991
  });
58992
+ const win = dom.window;
58993
+ const values = {
58994
+ document: win.document,
58995
+ window: win,
58996
+ navigator: win.navigator,
58997
+ HTMLElement: win.HTMLElement,
58998
+ SVGElement: win.SVGElement
58999
+ };
59000
+ for (const key of DOM_GLOBALS) {
59001
+ Object.defineProperty(globalThis, key, {
59002
+ value: values[key],
59003
+ configurable: true
59004
+ });
59005
+ }
59006
+ domInstalledByUs = true;
59007
+ }
59008
+ async function acquireDom() {
59009
+ if (typeof document !== "undefined" && !domInstalledByUs) return;
59010
+ domRefCount++;
59011
+ if (!domInstallPromise) domInstallPromise = installDom();
59012
+ await domInstallPromise;
59013
+ }
59014
+ function releaseDom() {
59015
+ if (!domInstalledByUs) return;
59016
+ if (--domRefCount > 0) return;
59017
+ for (const key of DOM_GLOBALS) {
59018
+ delete globalThis[key];
59019
+ }
59020
+ domInstalledByUs = false;
59021
+ domInstallPromise = null;
59022
+ domRefCount = 0;
58939
59023
  }
58940
59024
  async function loadJsdom() {
58941
59025
  const spec = ["js", "dom"].join("");
@@ -58969,16 +59053,21 @@ async function render(content, options) {
58969
59053
  );
58970
59054
  return { svg: svg2, diagnostics };
58971
59055
  }
58972
- await ensureDom();
58973
- const svg = await renderForExport(content, theme, paletteColors, viewState, {
58974
- ...options?.c4Level !== void 0 && { c4Level: options.c4Level },
58975
- ...options?.c4System !== void 0 && { c4System: options.c4System },
58976
- ...options?.c4Container !== void 0 && {
58977
- c4Container: options.c4Container
58978
- },
58979
- ...options?.tagGroup !== void 0 && { tagGroup: options.tagGroup },
58980
- ...options?.mapData !== void 0 && { mapData: options.mapData }
58981
- });
59056
+ await acquireDom();
59057
+ let svg;
59058
+ try {
59059
+ svg = await renderForExport(content, theme, paletteColors, viewState, {
59060
+ ...options?.c4Level !== void 0 && { c4Level: options.c4Level },
59061
+ ...options?.c4System !== void 0 && { c4System: options.c4System },
59062
+ ...options?.c4Container !== void 0 && {
59063
+ c4Container: options.c4Container
59064
+ },
59065
+ ...options?.tagGroup !== void 0 && { tagGroup: options.tagGroup },
59066
+ ...options?.mapData !== void 0 && { mapData: options.mapData }
59067
+ });
59068
+ } finally {
59069
+ releaseDom();
59070
+ }
58982
59071
  if (chartType === "map") {
58983
59072
  try {
58984
59073
  const [{ parseMap: parseMap2 }, { resolveMap: resolveMap2 }, { loadMapData: loadMapData2 }] = await Promise.all(
package/dist/advanced.js CHANGED
@@ -56117,6 +56117,59 @@ function getRotateFn(mode) {
56117
56117
  if (mode === "angled") return () => Math.round(Math.random() * 30 - 15);
56118
56118
  return () => 0;
56119
56119
  }
56120
+ function hasCanvas2d() {
56121
+ try {
56122
+ if (typeof document === "undefined") return false;
56123
+ const canvas = document.createElement("canvas");
56124
+ return typeof canvas.getContext === "function" && !!canvas.getContext("2d");
56125
+ } catch {
56126
+ return false;
56127
+ }
56128
+ }
56129
+ function estimateWordWidth(text, size) {
56130
+ return text.length * size * WORDCLOUD_GLYPH_ADVANCE;
56131
+ }
56132
+ function layoutWordsNoCanvas(words, width, height, padding, rotateFn) {
56133
+ const sorted = [...words].sort((a, b) => b.size - a.size);
56134
+ const placed = [];
56135
+ const maxR = Math.sqrt(width * width + height * height) / 2;
56136
+ const aspect = width > 0 ? height / width : 1;
56137
+ for (const w of sorted) {
56138
+ const rotate = rotateFn();
56139
+ const rawW = estimateWordWidth(w.text, w.size) + padding * 2;
56140
+ const rawH = w.size + padding * 2;
56141
+ const rad = rotate * Math.PI / 180;
56142
+ const cos = Math.abs(Math.cos(rad));
56143
+ const sin = Math.abs(Math.sin(rad));
56144
+ const halfW = (rawW * cos + rawH * sin) / 2;
56145
+ const halfH = (rawW * sin + rawH * cos) / 2;
56146
+ let spot = null;
56147
+ for (let t = 0; t < 4e3; t++) {
56148
+ const a = t * 0.25;
56149
+ const r = a * 1.4;
56150
+ if (r > maxR) break;
56151
+ const x = Math.cos(a) * r;
56152
+ const y = Math.sin(a) * r * aspect;
56153
+ if (x - halfW < -width / 2 || x + halfW > width / 2 || y - halfH < -height / 2 || y + halfH > height / 2) {
56154
+ continue;
56155
+ }
56156
+ let collides = false;
56157
+ for (const p of placed) {
56158
+ if (Math.abs(x - p.x) < halfW + p.halfW && Math.abs(y - p.y) < halfH + p.halfH) {
56159
+ collides = true;
56160
+ break;
56161
+ }
56162
+ }
56163
+ if (!collides) {
56164
+ spot = { x, y };
56165
+ break;
56166
+ }
56167
+ }
56168
+ if (!spot) continue;
56169
+ placed.push({ ...w, rotate, x: spot.x, y: spot.y, halfW, halfH });
56170
+ }
56171
+ return placed;
56172
+ }
56120
56173
  function renderWordCloud(container, parsed, palette, _isDark, onClickItem, exportDims) {
56121
56174
  const { words, cloudOptions } = parsed;
56122
56175
  const title = parsed.noTitle ? null : parsed.title;
@@ -56157,21 +56210,24 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
56157
56210
  "transform",
56158
56211
  `translate(${width / 2},${sTitleHeight + cloudHeight / 2})`
56159
56212
  );
56160
- cloud().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(sPadding).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
56213
+ const sized = words.map((w) => ({ ...w, size: fontSize(w.weight) }));
56214
+ const draw = (layoutWords) => {
56161
56215
  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]).style(
56162
56216
  "cursor",
56163
56217
  (d) => onClickItem && d.lineNumber ? "pointer" : "default"
56164
- ).attr("text-anchor", "middle").attr(
56165
- "transform",
56166
- (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
56167
- ).attr("data-line-number", (d) => {
56218
+ ).attr("text-anchor", "middle").attr("transform", (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`).attr("data-line-number", (d) => {
56168
56219
  const ln = d.lineNumber;
56169
56220
  return ln ? String(ln) : null;
56170
56221
  }).text((d) => d.text).on("click", (_event, d) => {
56171
56222
  const ln = d.lineNumber;
56172
56223
  if (onClickItem && ln) onClickItem(ln);
56173
56224
  });
56174
- }).start();
56225
+ };
56226
+ if (!hasCanvas2d()) {
56227
+ draw(layoutWordsNoCanvas(sized, width, cloudHeight, sPadding, rotateFn));
56228
+ return;
56229
+ }
56230
+ cloud().size([width, cloudHeight]).words(sized).padding(sPadding).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", draw).start();
56175
56231
  }
56176
56232
  function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
56177
56233
  return new Promise((resolve) => {
@@ -56209,13 +56265,19 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
56209
56265
  "transform",
56210
56266
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
56211
56267
  );
56212
- cloud().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(2).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
56268
+ const sized = words.map((w) => ({ ...w, size: fontSize(w.weight) }));
56269
+ const draw = (layoutWords) => {
56213
56270
  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(
56214
56271
  "transform",
56215
56272
  (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`
56216
56273
  ).text((d) => d.text);
56217
56274
  resolve();
56218
- }).start();
56275
+ };
56276
+ if (!hasCanvas2d()) {
56277
+ draw(layoutWordsNoCanvas(sized, width, cloudHeight, 2, rotateFn));
56278
+ return;
56279
+ }
56280
+ cloud().size([width, cloudHeight]).words(sized).padding(2).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", draw).start();
56219
56281
  });
56220
56282
  }
56221
56283
  function fitCirclesToContainerAsymmetric(circles, w, h, mLeft, mRight, mTop, mBottom) {
@@ -58026,7 +58088,7 @@ async function renderForExport(content, theme, palette, viewState, options) {
58026
58088
  }
58027
58089
  return finalizeSvgExport(container, theme, effectivePalette);
58028
58090
  }
58029
- var 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;
58091
+ var 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;
58030
58092
  var init_d3 = __esm({
58031
58093
  "src/d3.ts"() {
58032
58094
  "use strict";
@@ -58188,6 +58250,7 @@ var init_d3 = __esm({
58188
58250
  ARC_BASELINE_STROKE_WIDTH = 1;
58189
58251
  timelineCollapseState = /* @__PURE__ */ new WeakMap();
58190
58252
  tlBandClipCounter = 0;
58253
+ WORDCLOUD_GLYPH_ADVANCE = 0.62;
58191
58254
  EXPORT_WIDTH = 1200;
58192
58255
  EXPORT_HEIGHT = 800;
58193
58256
  }
@@ -58659,31 +58722,52 @@ init_d3();
58659
58722
  init_echarts();
58660
58723
  init_dgmo_router();
58661
58724
  init_registry();
58662
- async function ensureDom() {
58663
- if (typeof document !== "undefined") return;
58725
+ var DOM_GLOBALS = [
58726
+ "document",
58727
+ "window",
58728
+ "navigator",
58729
+ "HTMLElement",
58730
+ "SVGElement"
58731
+ ];
58732
+ var domRefCount = 0;
58733
+ var domInstallPromise = null;
58734
+ var domInstalledByUs = false;
58735
+ async function installDom() {
58664
58736
  const { JSDOM } = await loadJsdom();
58665
- const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>");
58666
- const win = dom.window;
58667
- Object.defineProperty(globalThis, "document", {
58668
- value: win.document,
58669
- configurable: true
58670
- });
58671
- Object.defineProperty(globalThis, "window", {
58672
- value: win,
58673
- configurable: true
58674
- });
58675
- Object.defineProperty(globalThis, "navigator", {
58676
- value: win.navigator,
58677
- configurable: true
58678
- });
58679
- Object.defineProperty(globalThis, "HTMLElement", {
58680
- value: win.HTMLElement,
58681
- configurable: true
58682
- });
58683
- Object.defineProperty(globalThis, "SVGElement", {
58684
- value: win.SVGElement,
58685
- configurable: true
58737
+ const dom = new JSDOM("<!DOCTYPE html><html><body></body></html>", {
58738
+ url: "http://localhost/"
58686
58739
  });
58740
+ const win = dom.window;
58741
+ const values = {
58742
+ document: win.document,
58743
+ window: win,
58744
+ navigator: win.navigator,
58745
+ HTMLElement: win.HTMLElement,
58746
+ SVGElement: win.SVGElement
58747
+ };
58748
+ for (const key of DOM_GLOBALS) {
58749
+ Object.defineProperty(globalThis, key, {
58750
+ value: values[key],
58751
+ configurable: true
58752
+ });
58753
+ }
58754
+ domInstalledByUs = true;
58755
+ }
58756
+ async function acquireDom() {
58757
+ if (typeof document !== "undefined" && !domInstalledByUs) return;
58758
+ domRefCount++;
58759
+ if (!domInstallPromise) domInstallPromise = installDom();
58760
+ await domInstallPromise;
58761
+ }
58762
+ function releaseDom() {
58763
+ if (!domInstalledByUs) return;
58764
+ if (--domRefCount > 0) return;
58765
+ for (const key of DOM_GLOBALS) {
58766
+ delete globalThis[key];
58767
+ }
58768
+ domInstalledByUs = false;
58769
+ domInstallPromise = null;
58770
+ domRefCount = 0;
58687
58771
  }
58688
58772
  async function loadJsdom() {
58689
58773
  const spec = ["js", "dom"].join("");
@@ -58717,16 +58801,21 @@ async function render(content, options) {
58717
58801
  );
58718
58802
  return { svg: svg2, diagnostics };
58719
58803
  }
58720
- await ensureDom();
58721
- const svg = await renderForExport(content, theme, paletteColors, viewState, {
58722
- ...options?.c4Level !== void 0 && { c4Level: options.c4Level },
58723
- ...options?.c4System !== void 0 && { c4System: options.c4System },
58724
- ...options?.c4Container !== void 0 && {
58725
- c4Container: options.c4Container
58726
- },
58727
- ...options?.tagGroup !== void 0 && { tagGroup: options.tagGroup },
58728
- ...options?.mapData !== void 0 && { mapData: options.mapData }
58729
- });
58804
+ await acquireDom();
58805
+ let svg;
58806
+ try {
58807
+ svg = await renderForExport(content, theme, paletteColors, viewState, {
58808
+ ...options?.c4Level !== void 0 && { c4Level: options.c4Level },
58809
+ ...options?.c4System !== void 0 && { c4System: options.c4System },
58810
+ ...options?.c4Container !== void 0 && {
58811
+ c4Container: options.c4Container
58812
+ },
58813
+ ...options?.tagGroup !== void 0 && { tagGroup: options.tagGroup },
58814
+ ...options?.mapData !== void 0 && { mapData: options.mapData }
58815
+ });
58816
+ } finally {
58817
+ releaseDom();
58818
+ }
58730
58819
  if (chartType === "map") {
58731
58820
  try {
58732
58821
  const [{ parseMap: parseMap2 }, { resolveMap: resolveMap2 }, { loadMapData: loadMapData2 }] = await Promise.all(