+8889
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+3782
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2593
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+2048
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+101
@@ -0,0 +1,101 @@
|
||||
import {
|
||||
insertEdge,
|
||||
insertEdgeLabel,
|
||||
markers_default,
|
||||
positionEdgeLabel
|
||||
} from "./chunk-LMNIJLJF.js";
|
||||
import {
|
||||
insertCluster,
|
||||
insertNode,
|
||||
labelHelper
|
||||
} from "./chunk-POGYG5DQ.js";
|
||||
import {
|
||||
interpolateToCurve
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import {
|
||||
common_default,
|
||||
getConfig
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/chunk-336JU56O.mjs
|
||||
var internalHelpers = {
|
||||
common: common_default,
|
||||
getConfig,
|
||||
insertCluster,
|
||||
insertEdge,
|
||||
insertEdgeLabel,
|
||||
insertMarkers: markers_default,
|
||||
insertNode,
|
||||
interpolateToCurve,
|
||||
labelHelper,
|
||||
log,
|
||||
positionEdgeLabel
|
||||
};
|
||||
var layoutAlgorithms = {};
|
||||
var registerLayoutLoaders = __name((loaders) => {
|
||||
for (const loader of loaders) {
|
||||
layoutAlgorithms[loader.name] = loader;
|
||||
}
|
||||
}, "registerLayoutLoaders");
|
||||
var registerDefaultLayoutLoaders = __name(() => {
|
||||
registerLayoutLoaders([
|
||||
{
|
||||
name: "dagre",
|
||||
loader: __name(async () => await import("./dagre-KV5264BT-2SB4YWJ2.js"), "loader")
|
||||
},
|
||||
...true ? [
|
||||
{
|
||||
name: "cose-bilkent",
|
||||
loader: __name(async () => await import("./cose-bilkent-S5V4N54A-ZC3OT2QD.js"), "loader")
|
||||
}
|
||||
] : []
|
||||
]);
|
||||
}, "registerDefaultLayoutLoaders");
|
||||
registerDefaultLayoutLoaders();
|
||||
var render = __name(async (data4Layout, svg) => {
|
||||
if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {
|
||||
throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);
|
||||
}
|
||||
if (data4Layout.diagramId) {
|
||||
for (const node of data4Layout.nodes) {
|
||||
const originalDomId = node.domId || node.id;
|
||||
node.domId = `${data4Layout.diagramId}-${originalDomId}`;
|
||||
}
|
||||
}
|
||||
const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];
|
||||
const layoutRenderer = await layoutDefinition.loader();
|
||||
const { theme, themeVariables } = data4Layout.config;
|
||||
const { useGradient, gradientStart, gradientStop } = themeVariables;
|
||||
const svgId = svg.attr("id");
|
||||
svg.append("defs").append("filter").attr("id", `${svgId}-drop-shadow`).attr("height", "130%").attr("width", "130%").append("feDropShadow").attr("dx", "4").attr("dy", "4").attr("stdDeviation", 0).attr("flood-opacity", "0.06").attr("flood-color", `${(theme == null ? void 0 : theme.includes("dark")) ? "#FFFFFF" : "#000000"}`);
|
||||
svg.append("defs").append("filter").attr("id", `${svgId}-drop-shadow-small`).attr("height", "150%").attr("width", "150%").append("feDropShadow").attr("dx", "2").attr("dy", "2").attr("stdDeviation", 0).attr("flood-opacity", "0.06").attr("flood-color", `${(theme == null ? void 0 : theme.includes("dark")) ? "#FFFFFF" : "#000000"}`);
|
||||
if (useGradient) {
|
||||
const gradient = svg.append("linearGradient").attr("id", svg.attr("id") + "-gradient").attr("gradientUnits", "objectBoundingBox").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%");
|
||||
gradient.append("svg:stop").attr("offset", "0%").attr("stop-color", gradientStart).attr("stop-opacity", 1);
|
||||
gradient.append("svg:stop").attr("offset", "100%").attr("stop-color", gradientStop).attr("stop-opacity", 1);
|
||||
}
|
||||
return layoutRenderer.render(data4Layout, svg, internalHelpers, {
|
||||
algorithm: layoutDefinition.algorithm
|
||||
});
|
||||
}, "render");
|
||||
var getRegisteredLayoutAlgorithm = __name((algorithm = "", { fallback = "dagre" } = {}) => {
|
||||
if (algorithm in layoutAlgorithms) {
|
||||
return algorithm;
|
||||
}
|
||||
if (fallback in layoutAlgorithms) {
|
||||
log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);
|
||||
return fallback;
|
||||
}
|
||||
throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);
|
||||
}, "getRegisteredLayoutAlgorithm");
|
||||
|
||||
export {
|
||||
registerLayoutLoaders,
|
||||
render,
|
||||
getRegisteredLayoutAlgorithm
|
||||
};
|
||||
//# sourceMappingURL=chunk-GSSDQWQG.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../mermaid/dist/chunks/mermaid.core/chunk-336JU56O.mjs"],
|
||||
"sourcesContent": ["import {\n insertEdge,\n insertEdgeLabel,\n markers_default,\n positionEdgeLabel\n} from \"./chunk-ENJZ2VHE.mjs\";\nimport {\n insertCluster,\n insertNode,\n labelHelper\n} from \"./chunk-5FUZZQ4R.mjs\";\nimport {\n interpolateToCurve\n} from \"./chunk-5PVQY5BW.mjs\";\nimport {\n common_default,\n getConfig\n} from \"./chunk-ICPOFSXX.mjs\";\nimport {\n __name,\n log\n} from \"./chunk-AGHRB4JF.mjs\";\n\n// src/internals.ts\nvar internalHelpers = {\n common: common_default,\n getConfig,\n insertCluster,\n insertEdge,\n insertEdgeLabel,\n insertMarkers: markers_default,\n insertNode,\n interpolateToCurve,\n labelHelper,\n log,\n positionEdgeLabel\n};\n\n// src/rendering-util/render.ts\nvar layoutAlgorithms = {};\nvar registerLayoutLoaders = /* @__PURE__ */ __name((loaders) => {\n for (const loader of loaders) {\n layoutAlgorithms[loader.name] = loader;\n }\n}, \"registerLayoutLoaders\");\nvar registerDefaultLayoutLoaders = /* @__PURE__ */ __name(() => {\n registerLayoutLoaders([\n {\n name: \"dagre\",\n loader: /* @__PURE__ */ __name(async () => await import(\"./dagre-KV5264BT.mjs\"), \"loader\")\n },\n ...true ? [\n {\n name: \"cose-bilkent\",\n loader: /* @__PURE__ */ __name(async () => await import(\"./cose-bilkent-S5V4N54A.mjs\"), \"loader\")\n }\n ] : []\n ]);\n}, \"registerDefaultLayoutLoaders\");\nregisterDefaultLayoutLoaders();\nvar render = /* @__PURE__ */ __name(async (data4Layout, svg) => {\n if (!(data4Layout.layoutAlgorithm in layoutAlgorithms)) {\n throw new Error(`Unknown layout algorithm: ${data4Layout.layoutAlgorithm}`);\n }\n if (data4Layout.diagramId) {\n for (const node of data4Layout.nodes) {\n const originalDomId = node.domId || node.id;\n node.domId = `${data4Layout.diagramId}-${originalDomId}`;\n }\n }\n const layoutDefinition = layoutAlgorithms[data4Layout.layoutAlgorithm];\n const layoutRenderer = await layoutDefinition.loader();\n const { theme, themeVariables } = data4Layout.config;\n const { useGradient, gradientStart, gradientStop } = themeVariables;\n const svgId = svg.attr(\"id\");\n svg.append(\"defs\").append(\"filter\").attr(\"id\", `${svgId}-drop-shadow`).attr(\"height\", \"130%\").attr(\"width\", \"130%\").append(\"feDropShadow\").attr(\"dx\", \"4\").attr(\"dy\", \"4\").attr(\"stdDeviation\", 0).attr(\"flood-opacity\", \"0.06\").attr(\"flood-color\", `${theme?.includes(\"dark\") ? \"#FFFFFF\" : \"#000000\"}`);\n svg.append(\"defs\").append(\"filter\").attr(\"id\", `${svgId}-drop-shadow-small`).attr(\"height\", \"150%\").attr(\"width\", \"150%\").append(\"feDropShadow\").attr(\"dx\", \"2\").attr(\"dy\", \"2\").attr(\"stdDeviation\", 0).attr(\"flood-opacity\", \"0.06\").attr(\"flood-color\", `${theme?.includes(\"dark\") ? \"#FFFFFF\" : \"#000000\"}`);\n if (useGradient) {\n const gradient = svg.append(\"linearGradient\").attr(\"id\", svg.attr(\"id\") + \"-gradient\").attr(\"gradientUnits\", \"objectBoundingBox\").attr(\"x1\", \"0%\").attr(\"y1\", \"0%\").attr(\"x2\", \"100%\").attr(\"y2\", \"0%\");\n gradient.append(\"svg:stop\").attr(\"offset\", \"0%\").attr(\"stop-color\", gradientStart).attr(\"stop-opacity\", 1);\n gradient.append(\"svg:stop\").attr(\"offset\", \"100%\").attr(\"stop-color\", gradientStop).attr(\"stop-opacity\", 1);\n }\n return layoutRenderer.render(data4Layout, svg, internalHelpers, {\n algorithm: layoutDefinition.algorithm\n });\n}, \"render\");\nvar getRegisteredLayoutAlgorithm = /* @__PURE__ */ __name((algorithm = \"\", { fallback = \"dagre\" } = {}) => {\n if (algorithm in layoutAlgorithms) {\n return algorithm;\n }\n if (fallback in layoutAlgorithms) {\n log.warn(`Layout algorithm ${algorithm} is not registered. Using ${fallback} as fallback.`);\n return fallback;\n }\n throw new Error(`Both layout algorithms ${algorithm} and ${fallback} are not registered.`);\n}, \"getRegisteredLayoutAlgorithm\");\n\nexport {\n registerLayoutLoaders,\n render,\n getRegisteredLayoutAlgorithm\n};\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAI,kBAAkB;AAAA,EACpB,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,eAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,IAAI,mBAAmB,CAAC;AACxB,IAAI,wBAAwC,OAAO,CAAC,YAAY;AAC9D,aAAW,UAAU,SAAS;AAC5B,qBAAiB,OAAO,IAAI,IAAI;AAAA,EAClC;AACF,GAAG,uBAAuB;AAC1B,IAAI,+BAA+C,OAAO,MAAM;AAC9D,wBAAsB;AAAA,IACpB;AAAA,MACE,MAAM;AAAA,MACN,QAAwB,OAAO,YAAY,MAAM,OAAO,8BAAsB,GAAG,QAAQ;AAAA,IAC3F;AAAA,IACA,GAAG,OAAO;AAAA,MACR;AAAA,QACE,MAAM;AAAA,QACN,QAAwB,OAAO,YAAY,MAAM,OAAO,qCAA6B,GAAG,QAAQ;AAAA,MAClG;AAAA,IACF,IAAI,CAAC;AAAA,EACP,CAAC;AACH,GAAG,8BAA8B;AACjC,6BAA6B;AAC7B,IAAI,SAAyB,OAAO,OAAO,aAAa,QAAQ;AAC9D,MAAI,EAAE,YAAY,mBAAmB,mBAAmB;AACtD,UAAM,IAAI,MAAM,6BAA6B,YAAY,eAAe,EAAE;AAAA,EAC5E;AACA,MAAI,YAAY,WAAW;AACzB,eAAW,QAAQ,YAAY,OAAO;AACpC,YAAM,gBAAgB,KAAK,SAAS,KAAK;AACzC,WAAK,QAAQ,GAAG,YAAY,SAAS,IAAI,aAAa;AAAA,IACxD;AAAA,EACF;AACA,QAAM,mBAAmB,iBAAiB,YAAY,eAAe;AACrE,QAAM,iBAAiB,MAAM,iBAAiB,OAAO;AACrD,QAAM,EAAE,OAAO,eAAe,IAAI,YAAY;AAC9C,QAAM,EAAE,aAAa,eAAe,aAAa,IAAI;AACrD,QAAM,QAAQ,IAAI,KAAK,IAAI;AAC3B,MAAI,OAAO,MAAM,EAAE,OAAO,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK,cAAc,EAAE,KAAK,UAAU,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,OAAO,cAAc,EAAE,KAAK,MAAM,GAAG,EAAE,KAAK,MAAM,GAAG,EAAE,KAAK,gBAAgB,CAAC,EAAE,KAAK,iBAAiB,MAAM,EAAE,KAAK,eAAe,IAAG,+BAAO,SAAS,WAAU,YAAY,SAAS,EAAE;AACzS,MAAI,OAAO,MAAM,EAAE,OAAO,QAAQ,EAAE,KAAK,MAAM,GAAG,KAAK,oBAAoB,EAAE,KAAK,UAAU,MAAM,EAAE,KAAK,SAAS,MAAM,EAAE,OAAO,cAAc,EAAE,KAAK,MAAM,GAAG,EAAE,KAAK,MAAM,GAAG,EAAE,KAAK,gBAAgB,CAAC,EAAE,KAAK,iBAAiB,MAAM,EAAE,KAAK,eAAe,IAAG,+BAAO,SAAS,WAAU,YAAY,SAAS,EAAE;AAC/S,MAAI,aAAa;AACf,UAAM,WAAW,IAAI,OAAO,gBAAgB,EAAE,KAAK,MAAM,IAAI,KAAK,IAAI,IAAI,WAAW,EAAE,KAAK,iBAAiB,mBAAmB,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,MAAM,MAAM,EAAE,KAAK,MAAM,IAAI;AACtM,aAAS,OAAO,UAAU,EAAE,KAAK,UAAU,IAAI,EAAE,KAAK,cAAc,aAAa,EAAE,KAAK,gBAAgB,CAAC;AACzG,aAAS,OAAO,UAAU,EAAE,KAAK,UAAU,MAAM,EAAE,KAAK,cAAc,YAAY,EAAE,KAAK,gBAAgB,CAAC;AAAA,EAC5G;AACA,SAAO,eAAe,OAAO,aAAa,KAAK,iBAAiB;AAAA,IAC9D,WAAW,iBAAiB;AAAA,EAC9B,CAAC;AACH,GAAG,QAAQ;AACX,IAAI,+BAA+C,OAAO,CAAC,YAAY,IAAI,EAAE,WAAW,QAAQ,IAAI,CAAC,MAAM;AACzG,MAAI,aAAa,kBAAkB;AACjC,WAAO;AAAA,EACT;AACA,MAAI,YAAY,kBAAkB;AAChC,QAAI,KAAK,oBAAoB,SAAS,6BAA6B,QAAQ,eAAe;AAC1F,WAAO;AAAA,EACT;AACA,QAAM,IAAI,MAAM,0BAA0B,SAAS,QAAQ,QAAQ,sBAAsB;AAC3F,GAAG,8BAA8B;",
|
||||
"names": []
|
||||
}
|
||||
+1046
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2736
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2049
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+1053
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+68
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
parseFontSize
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import {
|
||||
defaultConfig_default,
|
||||
getConfig2
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import {
|
||||
__name
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/chunk-ZZ45TVLE.mjs
|
||||
var getSubGraphTitleMargins = __name(({
|
||||
flowchart
|
||||
}) => {
|
||||
var _a, _b;
|
||||
const subGraphTitleTopMargin = ((_a = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _a.top) ?? 0;
|
||||
const subGraphTitleBottomMargin = ((_b = flowchart == null ? void 0 : flowchart.subGraphTitleMargin) == null ? void 0 : _b.bottom) ?? 0;
|
||||
const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin;
|
||||
return {
|
||||
subGraphTitleTopMargin,
|
||||
subGraphTitleBottomMargin,
|
||||
subGraphTitleTotalMargin
|
||||
};
|
||||
}, "getSubGraphTitleMargins");
|
||||
async function configureLabelImages(container, labelText) {
|
||||
const images = container.getElementsByTagName("img");
|
||||
if (!images || images.length === 0) {
|
||||
return;
|
||||
}
|
||||
const noImgText = labelText.replace(/<img[^>]*>/g, "").trim() === "";
|
||||
await Promise.all(
|
||||
[...images].map(
|
||||
(img) => new Promise((res) => {
|
||||
function setupImage() {
|
||||
img.style.display = "flex";
|
||||
img.style.flexDirection = "column";
|
||||
if (noImgText) {
|
||||
const bodyFontSize = getConfig2().fontSize ? getConfig2().fontSize : window.getComputedStyle(document.body).fontSize;
|
||||
const enlargingFactor = 5;
|
||||
const [parsedBodyFontSize = defaultConfig_default.fontSize] = parseFontSize(bodyFontSize);
|
||||
const width = parsedBodyFontSize * enlargingFactor + "px";
|
||||
img.style.minWidth = width;
|
||||
img.style.maxWidth = width;
|
||||
} else {
|
||||
img.style.width = "100%";
|
||||
}
|
||||
res(img);
|
||||
}
|
||||
__name(setupImage, "setupImage");
|
||||
setTimeout(() => {
|
||||
if (img.complete) {
|
||||
setupImage();
|
||||
}
|
||||
});
|
||||
img.addEventListener("error", setupImage);
|
||||
img.addEventListener("load", setupImage);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
__name(configureLabelImages, "configureLabelImages");
|
||||
|
||||
export {
|
||||
getSubGraphTitleMargins,
|
||||
configureLabelImages
|
||||
};
|
||||
//# sourceMappingURL=chunk-LN4HZV3Y.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../mermaid/dist/chunks/mermaid.core/chunk-ZZ45TVLE.mjs"],
|
||||
"sourcesContent": ["import {\n parseFontSize\n} from \"./chunk-5PVQY5BW.mjs\";\nimport {\n defaultConfig_default,\n getConfig2 as getConfig\n} from \"./chunk-ICPOFSXX.mjs\";\nimport {\n __name\n} from \"./chunk-AGHRB4JF.mjs\";\n\n// src/utils/subGraphTitleMargins.ts\nvar getSubGraphTitleMargins = /* @__PURE__ */ __name(({\n flowchart\n}) => {\n const subGraphTitleTopMargin = flowchart?.subGraphTitleMargin?.top ?? 0;\n const subGraphTitleBottomMargin = flowchart?.subGraphTitleMargin?.bottom ?? 0;\n const subGraphTitleTotalMargin = subGraphTitleTopMargin + subGraphTitleBottomMargin;\n return {\n subGraphTitleTopMargin,\n subGraphTitleBottomMargin,\n subGraphTitleTotalMargin\n };\n}, \"getSubGraphTitleMargins\");\n\n// src/rendering-util/rendering-elements/shapes/labelImageUtils.ts\nasync function configureLabelImages(container, labelText) {\n const images = container.getElementsByTagName(\"img\");\n if (!images || images.length === 0) {\n return;\n }\n const noImgText = labelText.replace(/<img[^>]*>/g, \"\").trim() === \"\";\n await Promise.all(\n [...images].map(\n (img) => new Promise((res) => {\n function setupImage() {\n img.style.display = \"flex\";\n img.style.flexDirection = \"column\";\n if (noImgText) {\n const bodyFontSize = getConfig().fontSize ? getConfig().fontSize : window.getComputedStyle(document.body).fontSize;\n const enlargingFactor = 5;\n const [parsedBodyFontSize = defaultConfig_default.fontSize] = parseFontSize(bodyFontSize);\n const width = parsedBodyFontSize * enlargingFactor + \"px\";\n img.style.minWidth = width;\n img.style.maxWidth = width;\n } else {\n img.style.width = \"100%\";\n }\n res(img);\n }\n __name(setupImage, \"setupImage\");\n setTimeout(() => {\n if (img.complete) {\n setupImage();\n }\n });\n img.addEventListener(\"error\", setupImage);\n img.addEventListener(\"load\", setupImage);\n })\n )\n );\n}\n__name(configureLabelImages, \"configureLabelImages\");\n\nexport {\n configureLabelImages,\n getSubGraphTitleMargins\n};\n"],
|
||||
"mappings": ";;;;;;;;;;;;AAYA,IAAI,0BAA0C,OAAO,CAAC;AAAA,EACpD;AACF,MAAM;AAdN;AAeE,QAAM,2BAAyB,4CAAW,wBAAX,mBAAgC,QAAO;AACtE,QAAM,8BAA4B,4CAAW,wBAAX,mBAAgC,WAAU;AAC5E,QAAM,2BAA2B,yBAAyB;AAC1D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF,GAAG,yBAAyB;AAG5B,eAAe,qBAAqB,WAAW,WAAW;AACxD,QAAM,SAAS,UAAU,qBAAqB,KAAK;AACnD,MAAI,CAAC,UAAU,OAAO,WAAW,GAAG;AAClC;AAAA,EACF;AACA,QAAM,YAAY,UAAU,QAAQ,eAAe,EAAE,EAAE,KAAK,MAAM;AAClE,QAAM,QAAQ;AAAA,IACZ,CAAC,GAAG,MAAM,EAAE;AAAA,MACV,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ;AAC5B,iBAAS,aAAa;AACpB,cAAI,MAAM,UAAU;AACpB,cAAI,MAAM,gBAAgB;AAC1B,cAAI,WAAW;AACb,kBAAM,eAAe,WAAU,EAAE,WAAW,WAAU,EAAE,WAAW,OAAO,iBAAiB,SAAS,IAAI,EAAE;AAC1G,kBAAM,kBAAkB;AACxB,kBAAM,CAAC,qBAAqB,sBAAsB,QAAQ,IAAI,cAAc,YAAY;AACxF,kBAAM,QAAQ,qBAAqB,kBAAkB;AACrD,gBAAI,MAAM,WAAW;AACrB,gBAAI,MAAM,WAAW;AAAA,UACvB,OAAO;AACL,gBAAI,MAAM,QAAQ;AAAA,UACpB;AACA,cAAI,GAAG;AAAA,QACT;AACA,eAAO,YAAY,YAAY;AAC/B,mBAAW,MAAM;AACf,cAAI,IAAI,UAAU;AAChB,uBAAW;AAAA,UACb;AAAA,QACF,CAAC;AACD,YAAI,iBAAiB,SAAS,UAAU;AACxC,YAAI,iBAAiB,QAAQ,UAAU;AAAA,MACzC,CAAC;AAAA,IACH;AAAA,EACF;AACF;AACA,OAAO,sBAAsB,sBAAsB;",
|
||||
"names": []
|
||||
}
|
||||
+5567
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+91
@@ -0,0 +1,91 @@
|
||||
import {
|
||||
__name
|
||||
} from "./chunk-S4AGLBPD.js";
|
||||
|
||||
// node_modules/@mermaid-js/parser/dist/mermaid-parser.core.mjs
|
||||
var parsers = {};
|
||||
var initializers = {
|
||||
info: __name(async () => {
|
||||
const { createInfoServices: createInfoServices2 } = await import("./info-OMHHGYJF-FWJRZDVY.js");
|
||||
const parser = createInfoServices2().Info.parser.LangiumParser;
|
||||
parsers.info = parser;
|
||||
}, "info"),
|
||||
packet: __name(async () => {
|
||||
const { createPacketServices: createPacketServices2 } = await import("./packet-4T2RLAQJ-2LQDH5JO.js");
|
||||
const parser = createPacketServices2().Packet.parser.LangiumParser;
|
||||
parsers.packet = parser;
|
||||
}, "packet"),
|
||||
pie: __name(async () => {
|
||||
const { createPieServices: createPieServices2 } = await import("./pie-ZZUOXDRM-KQGNYE5Y.js");
|
||||
const parser = createPieServices2().Pie.parser.LangiumParser;
|
||||
parsers.pie = parser;
|
||||
}, "pie"),
|
||||
treeView: __name(async () => {
|
||||
const { createTreeViewServices: createTreeViewServices2 } = await import("./treeView-SZITEDCU-TBMOS4J3.js");
|
||||
const parser = createTreeViewServices2().TreeView.parser.LangiumParser;
|
||||
parsers.treeView = parser;
|
||||
}, "treeView"),
|
||||
architecture: __name(async () => {
|
||||
const { createArchitectureServices: createArchitectureServices2 } = await import("./architecture-YZFGNWBL-NAU23UHH.js");
|
||||
const parser = createArchitectureServices2().Architecture.parser.LangiumParser;
|
||||
parsers.architecture = parser;
|
||||
}, "architecture"),
|
||||
gitGraph: __name(async () => {
|
||||
const { createGitGraphServices: createGitGraphServices2 } = await import("./gitGraph-7Q5UKJZL-ODOWYJI5.js");
|
||||
const parser = createGitGraphServices2().GitGraph.parser.LangiumParser;
|
||||
parsers.gitGraph = parser;
|
||||
}, "gitGraph"),
|
||||
radar: __name(async () => {
|
||||
const { createRadarServices: createRadarServices2 } = await import("./radar-PYXPWWZC-PFNTPJ6C.js");
|
||||
const parser = createRadarServices2().Radar.parser.LangiumParser;
|
||||
parsers.radar = parser;
|
||||
}, "radar"),
|
||||
treemap: __name(async () => {
|
||||
const { createTreemapServices: createTreemapServices2 } = await import("./treemap-W4RFUUIX-JB5N3RDV.js");
|
||||
const parser = createTreemapServices2().Treemap.parser.LangiumParser;
|
||||
parsers.treemap = parser;
|
||||
}, "treemap"),
|
||||
wardley: __name(async () => {
|
||||
const { createWardleyServices: createWardleyServices2 } = await import("./wardley-RL74JXVD-Y6MKPAVO.js");
|
||||
const parser = createWardleyServices2().Wardley.parser.LangiumParser;
|
||||
parsers.wardley = parser;
|
||||
}, "wardley")
|
||||
};
|
||||
async function parse(diagramType, text) {
|
||||
const initializer = initializers[diagramType];
|
||||
if (!initializer) {
|
||||
throw new Error(`Unknown diagram type: ${diagramType}`);
|
||||
}
|
||||
if (!parsers[diagramType]) {
|
||||
await initializer();
|
||||
}
|
||||
const parser = parsers[diagramType];
|
||||
const result = parser.parse(text);
|
||||
if (result.lexerErrors.length > 0 || result.parserErrors.length > 0) {
|
||||
throw new MermaidParseError(result);
|
||||
}
|
||||
return result.value;
|
||||
}
|
||||
__name(parse, "parse");
|
||||
var _a;
|
||||
var MermaidParseError = (_a = class extends Error {
|
||||
constructor(result) {
|
||||
const lexerErrors = result.lexerErrors.map((err) => {
|
||||
const line = err.line !== void 0 && !isNaN(err.line) ? err.line : "?";
|
||||
const column = err.column !== void 0 && !isNaN(err.column) ? err.column : "?";
|
||||
return `Lexer error on line ${line}, column ${column}: ${err.message}`;
|
||||
}).join("\n");
|
||||
const parserErrors = result.parserErrors.map((err) => {
|
||||
const line = err.token.startLine !== void 0 && !isNaN(err.token.startLine) ? err.token.startLine : "?";
|
||||
const column = err.token.startColumn !== void 0 && !isNaN(err.token.startColumn) ? err.token.startColumn : "?";
|
||||
return `Parse error on line ${line}, column ${column}: ${err.message}`;
|
||||
}).join("\n");
|
||||
super(`Parsing failed: ${lexerErrors} ${parserErrors}`);
|
||||
this.result = result;
|
||||
}
|
||||
}, __name(_a, "MermaidParseError"), _a);
|
||||
|
||||
export {
|
||||
parse
|
||||
};
|
||||
//# sourceMappingURL=chunk-R5NQBCLB.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+6974
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2041
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+46
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
ClassDB,
|
||||
classDiagram_default,
|
||||
classRenderer_v3_unified_default,
|
||||
styles_default
|
||||
} from "./chunk-WNLCKUOK.js";
|
||||
import "./chunk-Q6MYXZJ3.js";
|
||||
import "./chunk-DTWU5TRM.js";
|
||||
import "./chunk-NLS3CDEU.js";
|
||||
import "./chunk-YVBSFUGN.js";
|
||||
import "./chunk-GSSDQWQG.js";
|
||||
import "./chunk-LMNIJLJF.js";
|
||||
import "./chunk-POGYG5DQ.js";
|
||||
import "./chunk-N2C52BYW.js";
|
||||
import "./chunk-IHPTUWR5.js";
|
||||
import "./chunk-LN4HZV3Y.js";
|
||||
import "./chunk-TNWHCC6S.js";
|
||||
import "./chunk-HX7G7X5J.js";
|
||||
import "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-6PBFFD2Q.mjs
|
||||
var diagram = {
|
||||
parser: classDiagram_default,
|
||||
get db() {
|
||||
return new ClassDB();
|
||||
},
|
||||
renderer: classRenderer_v3_unified_default,
|
||||
styles: styles_default,
|
||||
init: __name((cnf) => {
|
||||
if (!cnf.class) {
|
||||
cnf.class = {};
|
||||
}
|
||||
cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
}, "init")
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=classDiagram-6PBFFD2Q-ZDYBHCGS.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../mermaid/dist/chunks/mermaid.core/classDiagram-6PBFFD2Q.mjs"],
|
||||
"sourcesContent": ["import {\n ClassDB,\n classDiagram_default,\n classRenderer_v3_unified_default,\n styles_default\n} from \"./chunk-4TB4RGXK.mjs\";\nimport \"./chunk-FMBD7UC4.mjs\";\nimport \"./chunk-YZCP3GAM.mjs\";\nimport \"./chunk-55IACEB6.mjs\";\nimport \"./chunk-EDXVE4YY.mjs\";\nimport \"./chunk-336JU56O.mjs\";\nimport \"./chunk-ENJZ2VHE.mjs\";\nimport \"./chunk-BSJP7CBP.mjs\";\nimport \"./chunk-5FUZZQ4R.mjs\";\nimport \"./chunk-ZZ45TVLE.mjs\";\nimport \"./chunk-X2U36JSP.mjs\";\nimport \"./chunk-U2HBQHQK.mjs\";\nimport \"./chunk-5PVQY5BW.mjs\";\nimport \"./chunk-ICPOFSXX.mjs\";\nimport {\n __name\n} from \"./chunk-AGHRB4JF.mjs\";\n\n// src/diagrams/class/classDiagram.ts\nvar diagram = {\n parser: classDiagram_default,\n get db() {\n return new ClassDB();\n },\n renderer: classRenderer_v3_unified_default,\n styles: styles_default,\n init: /* @__PURE__ */ __name((cnf) => {\n if (!cnf.class) {\n cnf.class = {};\n }\n cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;\n }, \"init\")\n};\nexport {\n diagram\n};\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAI,UAAU;AAAA,EACZ,QAAQ;AAAA,EACR,IAAI,KAAK;AACP,WAAO,IAAI,QAAQ;AAAA,EACrB;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAsB,OAAO,CAAC,QAAQ;AACpC,QAAI,CAAC,IAAI,OAAO;AACd,UAAI,QAAQ,CAAC;AAAA,IACf;AACA,QAAI,MAAM,sBAAsB,IAAI;AAAA,EACtC,GAAG,MAAM;AACX;",
|
||||
"names": []
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
ClassDB,
|
||||
classDiagram_default,
|
||||
classRenderer_v3_unified_default,
|
||||
styles_default
|
||||
} from "./chunk-WNLCKUOK.js";
|
||||
import "./chunk-Q6MYXZJ3.js";
|
||||
import "./chunk-DTWU5TRM.js";
|
||||
import "./chunk-NLS3CDEU.js";
|
||||
import "./chunk-YVBSFUGN.js";
|
||||
import "./chunk-GSSDQWQG.js";
|
||||
import "./chunk-LMNIJLJF.js";
|
||||
import "./chunk-POGYG5DQ.js";
|
||||
import "./chunk-N2C52BYW.js";
|
||||
import "./chunk-IHPTUWR5.js";
|
||||
import "./chunk-LN4HZV3Y.js";
|
||||
import "./chunk-TNWHCC6S.js";
|
||||
import "./chunk-HX7G7X5J.js";
|
||||
import "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/classDiagram-v2-HSJHXN6E.mjs
|
||||
var diagram = {
|
||||
parser: classDiagram_default,
|
||||
get db() {
|
||||
return new ClassDB();
|
||||
},
|
||||
renderer: classRenderer_v3_unified_default,
|
||||
styles: styles_default,
|
||||
init: __name((cnf) => {
|
||||
if (!cnf.class) {
|
||||
cnf.class = {};
|
||||
}
|
||||
cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
}, "init")
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=classDiagram-v2-HSJHXN6E-X6473I6M.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../mermaid/dist/chunks/mermaid.core/classDiagram-v2-HSJHXN6E.mjs"],
|
||||
"sourcesContent": ["import {\n ClassDB,\n classDiagram_default,\n classRenderer_v3_unified_default,\n styles_default\n} from \"./chunk-4TB4RGXK.mjs\";\nimport \"./chunk-FMBD7UC4.mjs\";\nimport \"./chunk-YZCP3GAM.mjs\";\nimport \"./chunk-55IACEB6.mjs\";\nimport \"./chunk-EDXVE4YY.mjs\";\nimport \"./chunk-336JU56O.mjs\";\nimport \"./chunk-ENJZ2VHE.mjs\";\nimport \"./chunk-BSJP7CBP.mjs\";\nimport \"./chunk-5FUZZQ4R.mjs\";\nimport \"./chunk-ZZ45TVLE.mjs\";\nimport \"./chunk-X2U36JSP.mjs\";\nimport \"./chunk-U2HBQHQK.mjs\";\nimport \"./chunk-5PVQY5BW.mjs\";\nimport \"./chunk-ICPOFSXX.mjs\";\nimport {\n __name\n} from \"./chunk-AGHRB4JF.mjs\";\n\n// src/diagrams/class/classDiagram-v2.ts\nvar diagram = {\n parser: classDiagram_default,\n get db() {\n return new ClassDB();\n },\n renderer: classRenderer_v3_unified_default,\n styles: styles_default,\n init: /* @__PURE__ */ __name((cnf) => {\n if (!cnf.class) {\n cnf.class = {};\n }\n cnf.class.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;\n }, \"init\")\n};\nexport {\n diagram\n};\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAI,UAAU;AAAA,EACZ,QAAQ;AAAA,EACR,IAAI,KAAK;AACP,WAAO,IAAI,QAAQ;AAAA,EACrB;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAsB,OAAO,CAAC,QAAQ;AACpC,QAAI,CAAC,IAAI,OAAO;AACd,UAAI,QAAQ,CAAC;AAAA,IACf;AACA,QAAI,MAAM,sBAAsB,IAAI;AAAA,EACtC,GAAG,MAAM;AACX;",
|
||||
"names": []
|
||||
}
|
||||
+742
@@ -0,0 +1,742 @@
|
||||
import {
|
||||
layout
|
||||
} from "./chunk-6G6LCPI6.js";
|
||||
import {
|
||||
Graph,
|
||||
clone_default,
|
||||
isUndefined_default
|
||||
} from "./chunk-WBQMGXEP.js";
|
||||
import {
|
||||
map_default
|
||||
} from "./chunk-K3ORWWMK.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
clear as clear3,
|
||||
insertEdge,
|
||||
insertEdgeLabel,
|
||||
markers_default,
|
||||
positionEdgeLabel
|
||||
} from "./chunk-LMNIJLJF.js";
|
||||
import {
|
||||
clear,
|
||||
clear2,
|
||||
insertCluster,
|
||||
insertNode,
|
||||
positionNode,
|
||||
setNodeElem,
|
||||
updateNodeBounds
|
||||
} from "./chunk-POGYG5DQ.js";
|
||||
import "./chunk-N2C52BYW.js";
|
||||
import "./chunk-IHPTUWR5.js";
|
||||
import {
|
||||
getSubGraphTitleMargins
|
||||
} from "./chunk-LN4HZV3Y.js";
|
||||
import "./chunk-TNWHCC6S.js";
|
||||
import "./chunk-HX7G7X5J.js";
|
||||
import "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
getConfig2
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/dagre-d3-es/src/graphlib/json.js
|
||||
function write(g) {
|
||||
var json = {
|
||||
options: {
|
||||
directed: g.isDirected(),
|
||||
multigraph: g.isMultigraph(),
|
||||
compound: g.isCompound()
|
||||
},
|
||||
nodes: writeNodes(g),
|
||||
edges: writeEdges(g)
|
||||
};
|
||||
if (!isUndefined_default(g.graph())) {
|
||||
json.value = clone_default(g.graph());
|
||||
}
|
||||
return json;
|
||||
}
|
||||
function writeNodes(g) {
|
||||
return map_default(g.nodes(), function(v) {
|
||||
var nodeValue = g.node(v);
|
||||
var parent = g.parent(v);
|
||||
var node = { v };
|
||||
if (!isUndefined_default(nodeValue)) {
|
||||
node.value = nodeValue;
|
||||
}
|
||||
if (!isUndefined_default(parent)) {
|
||||
node.parent = parent;
|
||||
}
|
||||
return node;
|
||||
});
|
||||
}
|
||||
function writeEdges(g) {
|
||||
return map_default(g.edges(), function(e) {
|
||||
var edgeValue = g.edge(e);
|
||||
var edge = { v: e.v, w: e.w };
|
||||
if (!isUndefined_default(e.name)) {
|
||||
edge.name = e.name;
|
||||
}
|
||||
if (!isUndefined_default(edgeValue)) {
|
||||
edge.value = edgeValue;
|
||||
}
|
||||
return edge;
|
||||
});
|
||||
}
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/dagre-KV5264BT.mjs
|
||||
var clusterDb = /* @__PURE__ */ new Map();
|
||||
var descendants = /* @__PURE__ */ new Map();
|
||||
var parents = /* @__PURE__ */ new Map();
|
||||
var clear4 = __name(() => {
|
||||
descendants.clear();
|
||||
parents.clear();
|
||||
clusterDb.clear();
|
||||
}, "clear");
|
||||
var isDescendant = __name((id, ancestorId) => {
|
||||
const ancestorDescendants = descendants.get(ancestorId) || [];
|
||||
log.trace("In isDescendant", ancestorId, " ", id, " = ", ancestorDescendants.includes(id));
|
||||
return ancestorDescendants.includes(id);
|
||||
}, "isDescendant");
|
||||
var edgeInCluster = __name((edge, clusterId) => {
|
||||
const clusterDescendants = descendants.get(clusterId) || [];
|
||||
log.info("Descendants of ", clusterId, " is ", clusterDescendants);
|
||||
log.info("Edge is ", edge);
|
||||
if (edge.v === clusterId || edge.w === clusterId) {
|
||||
return false;
|
||||
}
|
||||
if (!clusterDescendants) {
|
||||
log.debug("Tilt, ", clusterId, ",not in descendants");
|
||||
return false;
|
||||
}
|
||||
return clusterDescendants.includes(edge.v) || isDescendant(edge.v, clusterId) || isDescendant(edge.w, clusterId) || clusterDescendants.includes(edge.w);
|
||||
}, "edgeInCluster");
|
||||
var copy = __name((clusterId, graph, newGraph, rootId) => {
|
||||
log.warn(
|
||||
"Copying children of ",
|
||||
clusterId,
|
||||
"root",
|
||||
rootId,
|
||||
"data",
|
||||
graph.node(clusterId),
|
||||
rootId
|
||||
);
|
||||
const nodes = graph.children(clusterId) || [];
|
||||
if (clusterId !== rootId) {
|
||||
nodes.push(clusterId);
|
||||
}
|
||||
log.warn("Copying (nodes) clusterId", clusterId, "nodes", nodes);
|
||||
nodes.forEach((node) => {
|
||||
if (graph.children(node).length > 0) {
|
||||
copy(node, graph, newGraph, rootId);
|
||||
} else {
|
||||
const data = graph.node(node);
|
||||
log.info("cp ", node, " to ", rootId, " with parent ", clusterId);
|
||||
newGraph.setNode(node, data);
|
||||
if (rootId !== graph.parent(node)) {
|
||||
log.warn("Setting parent", node, graph.parent(node));
|
||||
newGraph.setParent(node, graph.parent(node));
|
||||
}
|
||||
if (clusterId !== rootId && node !== clusterId) {
|
||||
log.debug("Setting parent", node, clusterId);
|
||||
newGraph.setParent(node, clusterId);
|
||||
} else {
|
||||
log.info("In copy ", clusterId, "root", rootId, "data", graph.node(clusterId), rootId);
|
||||
log.debug(
|
||||
"Not Setting parent for node=",
|
||||
node,
|
||||
"cluster!==rootId",
|
||||
clusterId !== rootId,
|
||||
"node!==clusterId",
|
||||
node !== clusterId
|
||||
);
|
||||
}
|
||||
const edges = graph.edges(node);
|
||||
log.debug("Copying Edges", edges);
|
||||
edges.forEach((edge) => {
|
||||
log.info("Edge", edge);
|
||||
const data2 = graph.edge(edge.v, edge.w, edge.name);
|
||||
log.info("Edge data", data2, rootId);
|
||||
try {
|
||||
if (edgeInCluster(edge, rootId)) {
|
||||
log.info("Copying as ", edge.v, edge.w, data2, edge.name);
|
||||
newGraph.setEdge(edge.v, edge.w, data2, edge.name);
|
||||
log.info("newGraph edges ", newGraph.edges(), newGraph.edge(newGraph.edges()[0]));
|
||||
} else {
|
||||
log.info(
|
||||
"Skipping copy of edge ",
|
||||
edge.v,
|
||||
"-->",
|
||||
edge.w,
|
||||
" rootId: ",
|
||||
rootId,
|
||||
" clusterId:",
|
||||
clusterId
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
log.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
log.debug("Removing node", node);
|
||||
graph.removeNode(node);
|
||||
});
|
||||
}, "copy");
|
||||
var extractDescendants = __name((id, graph) => {
|
||||
const children = graph.children(id);
|
||||
let res = [...children];
|
||||
for (const child of children) {
|
||||
parents.set(child, id);
|
||||
res = [...res, ...extractDescendants(child, graph)];
|
||||
}
|
||||
return res;
|
||||
}, "extractDescendants");
|
||||
var findCommonEdges = __name((graph, id1, id2) => {
|
||||
const edges1 = graph.edges().filter((edge) => edge.v === id1 || edge.w === id1);
|
||||
const edges2 = graph.edges().filter((edge) => edge.v === id2 || edge.w === id2);
|
||||
const edges1Prim = edges1.map((edge) => {
|
||||
return { v: edge.v === id1 ? id2 : edge.v, w: edge.w === id1 ? id1 : edge.w };
|
||||
});
|
||||
const edges2Prim = edges2.map((edge) => {
|
||||
return { v: edge.v, w: edge.w };
|
||||
});
|
||||
const result = edges1Prim.filter((edgeIn1) => {
|
||||
return edges2Prim.some((edge) => edgeIn1.v === edge.v && edgeIn1.w === edge.w);
|
||||
});
|
||||
return result;
|
||||
}, "findCommonEdges");
|
||||
var findNonClusterChild = __name((id, graph, clusterId) => {
|
||||
const children = graph.children(id);
|
||||
log.trace("Searching children of id ", id, children);
|
||||
if (children.length < 1) {
|
||||
return id;
|
||||
}
|
||||
let reserve;
|
||||
for (const child of children) {
|
||||
const _id = findNonClusterChild(child, graph, clusterId);
|
||||
const commonEdges = findCommonEdges(graph, clusterId, _id);
|
||||
if (_id) {
|
||||
if (commonEdges.length > 0) {
|
||||
reserve = _id;
|
||||
} else {
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return reserve;
|
||||
}, "findNonClusterChild");
|
||||
var getAnchorId = __name((id) => {
|
||||
if (!clusterDb.has(id)) {
|
||||
return id;
|
||||
}
|
||||
if (!clusterDb.get(id).externalConnections) {
|
||||
return id;
|
||||
}
|
||||
if (clusterDb.has(id)) {
|
||||
return clusterDb.get(id).id;
|
||||
}
|
||||
return id;
|
||||
}, "getAnchorId");
|
||||
var adjustClustersAndEdges = __name((graph, depth) => {
|
||||
if (!graph || depth > 10) {
|
||||
log.debug("Opting out, no graph ");
|
||||
return;
|
||||
} else {
|
||||
log.debug("Opting in, graph ");
|
||||
}
|
||||
graph.nodes().forEach(function(id) {
|
||||
const children = graph.children(id);
|
||||
if (children.length > 0) {
|
||||
log.warn(
|
||||
"Cluster identified",
|
||||
id,
|
||||
" Replacement id in edges: ",
|
||||
findNonClusterChild(id, graph, id)
|
||||
);
|
||||
descendants.set(id, extractDescendants(id, graph));
|
||||
clusterDb.set(id, { id: findNonClusterChild(id, graph, id), clusterData: graph.node(id) });
|
||||
}
|
||||
});
|
||||
graph.nodes().forEach(function(id) {
|
||||
const children = graph.children(id);
|
||||
const edges = graph.edges();
|
||||
if (children.length > 0) {
|
||||
log.debug("Cluster identified", id, descendants);
|
||||
edges.forEach((edge) => {
|
||||
const d1 = isDescendant(edge.v, id);
|
||||
const d2 = isDescendant(edge.w, id);
|
||||
if (d1 ^ d2) {
|
||||
log.warn("Edge: ", edge, " leaves cluster ", id);
|
||||
log.warn("Descendants of XXX ", id, ": ", descendants.get(id));
|
||||
clusterDb.get(id).externalConnections = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
log.debug("Not a cluster ", id, descendants);
|
||||
}
|
||||
});
|
||||
for (let id of clusterDb.keys()) {
|
||||
const nonClusterChild = clusterDb.get(id).id;
|
||||
const parent = graph.parent(nonClusterChild);
|
||||
if (parent !== id && clusterDb.has(parent) && !clusterDb.get(parent).externalConnections) {
|
||||
clusterDb.get(id).id = parent;
|
||||
}
|
||||
}
|
||||
graph.edges().forEach(function(e) {
|
||||
const edge = graph.edge(e);
|
||||
log.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e));
|
||||
log.warn("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
|
||||
let v = e.v;
|
||||
let w = e.w;
|
||||
log.warn(
|
||||
"Fix XXX",
|
||||
clusterDb,
|
||||
"ids:",
|
||||
e.v,
|
||||
e.w,
|
||||
"Translating: ",
|
||||
clusterDb.get(e.v),
|
||||
" --- ",
|
||||
clusterDb.get(e.w)
|
||||
);
|
||||
if (clusterDb.get(e.v) || clusterDb.get(e.w)) {
|
||||
log.warn("Fixing and trying - removing XXX", e.v, e.w, e.name);
|
||||
v = getAnchorId(e.v);
|
||||
w = getAnchorId(e.w);
|
||||
graph.removeEdge(e.v, e.w, e.name);
|
||||
if (v !== e.v) {
|
||||
const parent = graph.parent(v);
|
||||
clusterDb.get(parent).externalConnections = true;
|
||||
edge.fromCluster = e.v;
|
||||
}
|
||||
if (w !== e.w) {
|
||||
const parent = graph.parent(w);
|
||||
clusterDb.get(parent).externalConnections = true;
|
||||
edge.toCluster = e.w;
|
||||
}
|
||||
log.warn("Fix Replacing with XXX", v, w, e.name);
|
||||
graph.setEdge(v, w, edge, e.name);
|
||||
}
|
||||
});
|
||||
log.warn("Adjusted Graph", write(graph));
|
||||
extractor(graph, 0);
|
||||
log.trace(clusterDb);
|
||||
}, "adjustClustersAndEdges");
|
||||
var extractor = __name((graph, depth) => {
|
||||
var _a, _b;
|
||||
log.warn("extractor - ", depth, write(graph), graph.children("D"));
|
||||
if (depth > 10) {
|
||||
log.error("Bailing out");
|
||||
return;
|
||||
}
|
||||
let nodes = graph.nodes();
|
||||
let hasChildren = false;
|
||||
for (const node of nodes) {
|
||||
const children = graph.children(node);
|
||||
hasChildren = hasChildren || children.length > 0;
|
||||
}
|
||||
if (!hasChildren) {
|
||||
log.debug("Done, no node has children", graph.nodes());
|
||||
return;
|
||||
}
|
||||
log.debug("Nodes = ", nodes, depth);
|
||||
for (const node of nodes) {
|
||||
log.debug(
|
||||
"Extracting node",
|
||||
node,
|
||||
clusterDb,
|
||||
clusterDb.has(node) && !clusterDb.get(node).externalConnections,
|
||||
!graph.parent(node),
|
||||
graph.node(node),
|
||||
graph.children("D"),
|
||||
" Depth ",
|
||||
depth
|
||||
);
|
||||
if (!clusterDb.has(node)) {
|
||||
log.debug("Not a cluster", node, depth);
|
||||
} else if (!clusterDb.get(node).externalConnections && graph.children(node) && graph.children(node).length > 0) {
|
||||
log.warn(
|
||||
"Cluster without external connections, without a parent and with children",
|
||||
node,
|
||||
depth
|
||||
);
|
||||
const graphSettings = graph.graph();
|
||||
let dir = graphSettings.rankdir === "TB" ? "LR" : "TB";
|
||||
if ((_b = (_a = clusterDb.get(node)) == null ? void 0 : _a.clusterData) == null ? void 0 : _b.dir) {
|
||||
dir = clusterDb.get(node).clusterData.dir;
|
||||
log.warn("Fixing dir", clusterDb.get(node).clusterData.dir, dir);
|
||||
}
|
||||
const clusterGraph = new Graph({
|
||||
multigraph: true,
|
||||
compound: true
|
||||
}).setGraph({
|
||||
rankdir: dir,
|
||||
nodesep: 50,
|
||||
ranksep: 50,
|
||||
marginx: 8,
|
||||
marginy: 8
|
||||
}).setDefaultEdgeLabel(function() {
|
||||
return {};
|
||||
});
|
||||
log.warn("Old graph before copy", write(graph));
|
||||
copy(node, graph, clusterGraph, node);
|
||||
graph.setNode(node, {
|
||||
clusterNode: true,
|
||||
id: node,
|
||||
clusterData: clusterDb.get(node).clusterData,
|
||||
label: clusterDb.get(node).label,
|
||||
graph: clusterGraph
|
||||
});
|
||||
log.warn("New graph after copy node: (", node, ")", write(clusterGraph));
|
||||
log.debug("Old graph after copy", write(graph));
|
||||
} else {
|
||||
log.warn(
|
||||
"Cluster ** ",
|
||||
node,
|
||||
" **not meeting the criteria !externalConnections:",
|
||||
!clusterDb.get(node).externalConnections,
|
||||
" no parent: ",
|
||||
!graph.parent(node),
|
||||
" children ",
|
||||
graph.children(node) && graph.children(node).length > 0,
|
||||
graph.children("D"),
|
||||
depth
|
||||
);
|
||||
log.debug(clusterDb);
|
||||
}
|
||||
}
|
||||
nodes = graph.nodes();
|
||||
log.warn("New list of nodes", nodes);
|
||||
for (const node of nodes) {
|
||||
const data = graph.node(node);
|
||||
log.warn(" Now next level", node, data);
|
||||
if (data == null ? void 0 : data.clusterNode) {
|
||||
extractor(data.graph, depth + 1);
|
||||
}
|
||||
}
|
||||
}, "extractor");
|
||||
var sorter = __name((graph, nodes) => {
|
||||
if (nodes.length === 0) {
|
||||
return [];
|
||||
}
|
||||
let result = Object.assign([], nodes);
|
||||
nodes.forEach((node) => {
|
||||
const children = graph.children(node);
|
||||
const sorted = sorter(graph, children);
|
||||
result = [...result, ...sorted];
|
||||
});
|
||||
return result;
|
||||
}, "sorter");
|
||||
var sortNodesByHierarchy = __name((graph) => sorter(graph, graph.children()), "sortNodesByHierarchy");
|
||||
var recursiveRender = __name(async (_elem, graph, diagramType, id, parentCluster, siteConfig) => {
|
||||
log.warn("Graph in recursive render:XAX", write(graph), parentCluster);
|
||||
const dir = graph.graph().rankdir;
|
||||
log.trace("Dir in recursive render - dir:", dir);
|
||||
const elem = _elem.insert("g").attr("class", "root");
|
||||
if (!graph.nodes()) {
|
||||
log.info("No nodes found for", graph);
|
||||
} else {
|
||||
log.info("Recursive render XXX", graph.nodes());
|
||||
}
|
||||
if (graph.edges().length > 0) {
|
||||
log.info("Recursive edges", graph.edge(graph.edges()[0]));
|
||||
}
|
||||
const clusters = elem.insert("g").attr("class", "clusters");
|
||||
const edgePaths = elem.insert("g").attr("class", "edgePaths");
|
||||
const edgeLabels = elem.insert("g").attr("class", "edgeLabels");
|
||||
const nodes = elem.insert("g").attr("class", "nodes");
|
||||
await Promise.all(
|
||||
graph.nodes().map(async function(v) {
|
||||
const node = graph.node(v);
|
||||
if (parentCluster !== void 0) {
|
||||
const data = JSON.parse(JSON.stringify(parentCluster.clusterData));
|
||||
log.trace(
|
||||
"Setting data for parent cluster XXX\n Node.id = ",
|
||||
v,
|
||||
"\n data=",
|
||||
data.height,
|
||||
"\nParent cluster",
|
||||
parentCluster.height
|
||||
);
|
||||
graph.setNode(parentCluster.id, data);
|
||||
if (!graph.parent(v)) {
|
||||
log.trace("Setting parent", v, parentCluster.id);
|
||||
graph.setParent(v, parentCluster.id, data);
|
||||
}
|
||||
}
|
||||
log.info("(Insert) Node XXX" + v + ": " + JSON.stringify(graph.node(v)));
|
||||
if (node == null ? void 0 : node.clusterNode) {
|
||||
log.info("Cluster identified XBX", v, node.width, graph.node(v));
|
||||
const { ranksep, nodesep } = graph.graph();
|
||||
node.graph.setGraph({
|
||||
...node.graph.graph(),
|
||||
ranksep: ranksep + 25,
|
||||
nodesep
|
||||
});
|
||||
const o = await recursiveRender(
|
||||
nodes,
|
||||
node.graph,
|
||||
diagramType,
|
||||
id,
|
||||
graph.node(v),
|
||||
siteConfig
|
||||
);
|
||||
const newEl = o.elem;
|
||||
updateNodeBounds(node, newEl);
|
||||
node.diff = o.diff || 0;
|
||||
log.info(
|
||||
"New compound node after recursive render XAX",
|
||||
v,
|
||||
"width",
|
||||
// node,
|
||||
node.width,
|
||||
"height",
|
||||
node.height
|
||||
// node.x,
|
||||
// node.y
|
||||
);
|
||||
setNodeElem(newEl, node);
|
||||
} else {
|
||||
if (graph.children(v).length > 0) {
|
||||
log.trace(
|
||||
"Cluster - the non recursive path XBX",
|
||||
v,
|
||||
node.id,
|
||||
node,
|
||||
node.width,
|
||||
"Graph:",
|
||||
graph
|
||||
);
|
||||
log.trace(findNonClusterChild(node.id, graph));
|
||||
clusterDb.set(node.id, { id: findNonClusterChild(node.id, graph), node });
|
||||
} else {
|
||||
log.trace("Node - the non recursive path XAX", v, nodes, graph.node(v), dir);
|
||||
await insertNode(nodes, graph.node(v), { config: siteConfig, dir });
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
const processEdges = __name(async () => {
|
||||
const edgePromises = graph.edges().map(async function(e) {
|
||||
const edge = graph.edge(e.v, e.w, e.name);
|
||||
log.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e));
|
||||
log.info("Edge " + e.v + " -> " + e.w + ": ", e, " ", JSON.stringify(graph.edge(e)));
|
||||
log.info(
|
||||
"Fix",
|
||||
clusterDb,
|
||||
"ids:",
|
||||
e.v,
|
||||
e.w,
|
||||
"Translating: ",
|
||||
clusterDb.get(e.v),
|
||||
clusterDb.get(e.w)
|
||||
);
|
||||
await insertEdgeLabel(edgeLabels, edge);
|
||||
});
|
||||
await Promise.all(edgePromises);
|
||||
}, "processEdges");
|
||||
await processEdges();
|
||||
log.info("Graph before layout:", JSON.stringify(write(graph)));
|
||||
log.info("############################################# XXX");
|
||||
log.info("### Layout ### XXX");
|
||||
log.info("############################################# XXX");
|
||||
layout(graph);
|
||||
log.info("Graph after layout:", JSON.stringify(write(graph)));
|
||||
let diff = 0;
|
||||
let { subGraphTitleTotalMargin } = getSubGraphTitleMargins(siteConfig);
|
||||
await Promise.all(
|
||||
sortNodesByHierarchy(graph).map(async function(v) {
|
||||
var _a;
|
||||
const node = graph.node(v);
|
||||
log.info(
|
||||
"Position XBX => " + v + ": (" + node.x,
|
||||
"," + node.y,
|
||||
") width: ",
|
||||
node.width,
|
||||
" height: ",
|
||||
node.height
|
||||
);
|
||||
if (node == null ? void 0 : node.clusterNode) {
|
||||
node.y += subGraphTitleTotalMargin;
|
||||
log.info(
|
||||
"A tainted cluster node XBX1",
|
||||
v,
|
||||
node.id,
|
||||
node.width,
|
||||
node.height,
|
||||
node.x,
|
||||
node.y,
|
||||
graph.parent(v)
|
||||
);
|
||||
clusterDb.get(node.id).node = node;
|
||||
positionNode(node);
|
||||
} else {
|
||||
if (graph.children(v).length > 0) {
|
||||
log.info(
|
||||
"A pure cluster node XBX1",
|
||||
v,
|
||||
node.id,
|
||||
node.x,
|
||||
node.y,
|
||||
node.width,
|
||||
node.height,
|
||||
graph.parent(v)
|
||||
);
|
||||
node.height += subGraphTitleTotalMargin;
|
||||
graph.node(node.parentId);
|
||||
const halfPadding = (node == null ? void 0 : node.padding) / 2 || 0;
|
||||
const labelHeight = ((_a = node == null ? void 0 : node.labelBBox) == null ? void 0 : _a.height) || 0;
|
||||
const offsetY = labelHeight - halfPadding || 0;
|
||||
log.debug("OffsetY", offsetY, "labelHeight", labelHeight, "halfPadding", halfPadding);
|
||||
await insertCluster(clusters, node);
|
||||
clusterDb.get(node.id).node = node;
|
||||
} else {
|
||||
const parent = graph.node(node.parentId);
|
||||
node.y += subGraphTitleTotalMargin / 2;
|
||||
log.info(
|
||||
"A regular node XBX1 - using the padding",
|
||||
node.id,
|
||||
"parent",
|
||||
node.parentId,
|
||||
node.width,
|
||||
node.height,
|
||||
node.x,
|
||||
node.y,
|
||||
"offsetY",
|
||||
node.offsetY,
|
||||
"parent",
|
||||
parent,
|
||||
parent == null ? void 0 : parent.offsetY,
|
||||
node
|
||||
);
|
||||
positionNode(node);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
graph.edges().forEach(function(e) {
|
||||
const edge = graph.edge(e);
|
||||
log.info("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(edge), edge);
|
||||
edge.points.forEach((point) => point.y += subGraphTitleTotalMargin / 2);
|
||||
const startNode = graph.node(e.v);
|
||||
var endNode = graph.node(e.w);
|
||||
const paths = insertEdge(edgePaths, edge, clusterDb, diagramType, startNode, endNode, id);
|
||||
positionEdgeLabel(edge, paths);
|
||||
});
|
||||
graph.nodes().forEach(function(v) {
|
||||
const n = graph.node(v);
|
||||
log.info(v, n.type, n.diff);
|
||||
if (n.isGroup) {
|
||||
diff = n.diff;
|
||||
}
|
||||
});
|
||||
log.warn("Returning from recursive render XAX", elem, diff);
|
||||
return { elem, diff };
|
||||
}, "recursiveRender");
|
||||
var render = __name(async (data4Layout, svg) => {
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
const graph = new Graph({
|
||||
multigraph: true,
|
||||
compound: true
|
||||
}).setGraph({
|
||||
rankdir: data4Layout.direction,
|
||||
nodesep: ((_a = data4Layout.config) == null ? void 0 : _a.nodeSpacing) || ((_c = (_b = data4Layout.config) == null ? void 0 : _b.flowchart) == null ? void 0 : _c.nodeSpacing) || data4Layout.nodeSpacing,
|
||||
ranksep: ((_d = data4Layout.config) == null ? void 0 : _d.rankSpacing) || ((_f = (_e = data4Layout.config) == null ? void 0 : _e.flowchart) == null ? void 0 : _f.rankSpacing) || data4Layout.rankSpacing,
|
||||
marginx: 8,
|
||||
marginy: 8
|
||||
}).setDefaultEdgeLabel(function() {
|
||||
return {};
|
||||
});
|
||||
const element = svg.select("g");
|
||||
markers_default(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
|
||||
clear2();
|
||||
clear3();
|
||||
clear();
|
||||
clear4();
|
||||
data4Layout.nodes.forEach((node) => {
|
||||
graph.setNode(node.id, { ...node });
|
||||
if (node.parentId) {
|
||||
graph.setParent(node.id, node.parentId);
|
||||
}
|
||||
});
|
||||
log.debug("Edges:", data4Layout.edges);
|
||||
data4Layout.edges.forEach((edge) => {
|
||||
if (edge.start === edge.end) {
|
||||
const nodeId = edge.start;
|
||||
const specialId1 = nodeId + "---" + nodeId + "---1";
|
||||
const specialId2 = nodeId + "---" + nodeId + "---2";
|
||||
const node = graph.node(nodeId);
|
||||
graph.setNode(specialId1, {
|
||||
domId: specialId1,
|
||||
id: specialId1,
|
||||
parentId: node.parentId,
|
||||
labelStyle: "",
|
||||
label: "",
|
||||
padding: 0,
|
||||
shape: "labelRect",
|
||||
// shape: 'rect',
|
||||
style: "",
|
||||
width: 10,
|
||||
height: 10
|
||||
});
|
||||
graph.setParent(specialId1, node.parentId);
|
||||
graph.setNode(specialId2, {
|
||||
domId: specialId2,
|
||||
id: specialId2,
|
||||
parentId: node.parentId,
|
||||
labelStyle: "",
|
||||
padding: 0,
|
||||
// shape: 'rect',
|
||||
shape: "labelRect",
|
||||
label: "",
|
||||
style: "",
|
||||
width: 10,
|
||||
height: 10
|
||||
});
|
||||
graph.setParent(specialId2, node.parentId);
|
||||
const edge1 = structuredClone(edge);
|
||||
const edgeMid = structuredClone(edge);
|
||||
const edge2 = structuredClone(edge);
|
||||
edge1.label = "";
|
||||
edge1.arrowTypeEnd = "none";
|
||||
edge1.id = nodeId + "-cyclic-special-1";
|
||||
edgeMid.arrowTypeStart = "none";
|
||||
edgeMid.arrowTypeEnd = "none";
|
||||
edgeMid.id = nodeId + "-cyclic-special-mid";
|
||||
edge2.label = "";
|
||||
if (node.isGroup) {
|
||||
edge1.fromCluster = nodeId;
|
||||
edge2.toCluster = nodeId;
|
||||
}
|
||||
edge2.id = nodeId + "-cyclic-special-2";
|
||||
edge2.arrowTypeStart = "none";
|
||||
graph.setEdge(nodeId, specialId1, edge1, nodeId + "-cyclic-special-0");
|
||||
graph.setEdge(specialId1, specialId2, edgeMid, nodeId + "-cyclic-special-1");
|
||||
graph.setEdge(specialId2, nodeId, edge2, nodeId + "-cyc<lic-special-2");
|
||||
} else {
|
||||
graph.setEdge(edge.start, edge.end, { ...edge }, edge.id);
|
||||
}
|
||||
});
|
||||
log.warn("Graph at first:", JSON.stringify(write(graph)));
|
||||
adjustClustersAndEdges(graph);
|
||||
log.warn("Graph after XAX:", JSON.stringify(write(graph)));
|
||||
const siteConfig = getConfig2();
|
||||
await recursiveRender(
|
||||
element,
|
||||
graph,
|
||||
data4Layout.type,
|
||||
data4Layout.diagramId,
|
||||
void 0,
|
||||
siteConfig
|
||||
);
|
||||
}, "render");
|
||||
export {
|
||||
render
|
||||
};
|
||||
//# sourceMappingURL=dagre-KV5264BT-2SB4YWJ2.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+6057
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+214
@@ -0,0 +1,214 @@
|
||||
import {
|
||||
ImperativeState
|
||||
} from "./chunk-VPVLR6E4.js";
|
||||
import {
|
||||
populateCommonDb
|
||||
} from "./chunk-BEGFPAJS.js";
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
cleanAndMerge
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
clear,
|
||||
configureSvgSize,
|
||||
defaultConfig_default,
|
||||
getAccDescription,
|
||||
getAccTitle,
|
||||
getConfig,
|
||||
getDiagramTitle,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/diagram-5BDNPKRD.mjs
|
||||
var state = new ImperativeState(() => ({
|
||||
cnt: 1,
|
||||
stack: [
|
||||
{
|
||||
id: 0,
|
||||
level: -1,
|
||||
name: "/",
|
||||
children: []
|
||||
}
|
||||
]
|
||||
}));
|
||||
var clear2 = __name(() => {
|
||||
state.reset();
|
||||
clear();
|
||||
}, "clear");
|
||||
var getRoot = __name(() => {
|
||||
return state.records.stack[0];
|
||||
}, "getRoot");
|
||||
var getCount = __name(() => state.records.cnt, "getCount");
|
||||
var defaultConfig = defaultConfig_default.treeView;
|
||||
var getConfig2 = __name(() => {
|
||||
return cleanAndMerge(defaultConfig, getConfig().treeView);
|
||||
}, "getConfig");
|
||||
var addNode = __name((level, name) => {
|
||||
while (level <= state.records.stack[state.records.stack.length - 1].level) {
|
||||
state.records.stack.pop();
|
||||
}
|
||||
const node = {
|
||||
id: state.records.cnt++,
|
||||
level,
|
||||
name,
|
||||
children: []
|
||||
};
|
||||
state.records.stack[state.records.stack.length - 1].children.push(node);
|
||||
state.records.stack.push(node);
|
||||
}, "addNode");
|
||||
var db = {
|
||||
clear: clear2,
|
||||
addNode,
|
||||
getRoot,
|
||||
getCount,
|
||||
getConfig: getConfig2,
|
||||
getAccTitle,
|
||||
getAccDescription,
|
||||
getDiagramTitle,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
};
|
||||
var db_default = db;
|
||||
var populate = __name((ast) => {
|
||||
populateCommonDb(ast, db_default);
|
||||
ast.nodes.map((node) => db_default.addNode(node.indent ? parseInt(node.indent) : 0, node.name));
|
||||
}, "populate");
|
||||
var parser = {
|
||||
parse: __name(async (input) => {
|
||||
const ast = await parse("treeView", input);
|
||||
log.debug(ast);
|
||||
populate(ast);
|
||||
}, "parse")
|
||||
};
|
||||
var positionLabel = __name((x, y, node, domElem, config) => {
|
||||
const label = domElem.append("text").text(node.name).attr("dominant-baseline", "middle").attr("class", "treeView-node-label");
|
||||
const { height: labelHeight, width: labelWidth } = label.node().getBBox();
|
||||
const height = labelHeight + config.paddingY * 2;
|
||||
const width = labelWidth + config.paddingX * 2;
|
||||
label.attr("x", x + config.paddingX);
|
||||
label.attr("y", y + height / 2);
|
||||
node.BBox = {
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height
|
||||
};
|
||||
}, "positionLabel");
|
||||
var positionLine = __name((domElem, x1, y1, x2, y2, lineThickness) => {
|
||||
return domElem.append("line").attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2).attr("stroke-width", lineThickness).attr("class", "treeView-node-line");
|
||||
}, "positionLine");
|
||||
var drawTree = __name((elem, root, config) => {
|
||||
let totalHeight = 0;
|
||||
let totalWidth = 0;
|
||||
const drawNode = __name((elem2, node, config2, depth) => {
|
||||
const indent = depth * (config2.rowIndent + config2.paddingX);
|
||||
positionLabel(indent, totalHeight, node, elem2, config2);
|
||||
const { height, width } = node.BBox;
|
||||
positionLine(
|
||||
elem2,
|
||||
indent - config2.rowIndent,
|
||||
totalHeight + height / 2,
|
||||
indent,
|
||||
totalHeight + height / 2,
|
||||
config2.lineThickness
|
||||
);
|
||||
totalWidth = Math.max(totalWidth, indent + width);
|
||||
totalHeight += height;
|
||||
}, "drawNode");
|
||||
const processNode = __name((node, depth = 0) => {
|
||||
drawNode(elem, node, config, depth);
|
||||
node.children.forEach((child) => {
|
||||
processNode(child, depth + 1);
|
||||
});
|
||||
const { x, y, height } = node.BBox;
|
||||
if (node.children.length) {
|
||||
const { y: endY, height: endHeight } = node.children[node.children.length - 1].BBox;
|
||||
positionLine(
|
||||
elem,
|
||||
x + config.paddingX,
|
||||
y + height,
|
||||
x + config.paddingX,
|
||||
endY + endHeight / 2 + config.lineThickness / 2,
|
||||
config.lineThickness
|
||||
);
|
||||
}
|
||||
}, "processNode");
|
||||
processNode(root);
|
||||
return { totalHeight, totalWidth };
|
||||
}, "drawTree");
|
||||
var draw = __name((text, id, _ver, diagObj) => {
|
||||
log.debug("Rendering treeView diagram\n" + text);
|
||||
const db2 = diagObj.db;
|
||||
const root = db2.getRoot();
|
||||
const config = db2.getConfig();
|
||||
const svg = selectSvgElement(id);
|
||||
const treeElem = svg.append("g");
|
||||
treeElem.attr("class", "tree-view");
|
||||
const { totalHeight, totalWidth } = drawTree(treeElem, root, config);
|
||||
svg.attr("viewBox", `-${config.lineThickness / 2} 0 ${totalWidth} ${totalHeight}`);
|
||||
configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth);
|
||||
}, "draw");
|
||||
var renderer = {
|
||||
draw
|
||||
};
|
||||
var renderer_default = renderer;
|
||||
var defaultTreeViewDiagramStyles = {
|
||||
labelFontSize: "16px",
|
||||
labelColor: "black",
|
||||
lineColor: "black"
|
||||
};
|
||||
var styles = __name(({
|
||||
treeView
|
||||
}) => {
|
||||
const { labelFontSize, labelColor, lineColor } = cleanAndMerge(
|
||||
defaultTreeViewDiagramStyles,
|
||||
treeView
|
||||
);
|
||||
return `
|
||||
.treeView-node-label {
|
||||
font-size: ${labelFontSize};
|
||||
fill: ${labelColor};
|
||||
}
|
||||
.treeView-node-line {
|
||||
stroke: ${lineColor};
|
||||
}
|
||||
`;
|
||||
}, "styles");
|
||||
var styles_default = styles;
|
||||
var diagram = {
|
||||
db: db_default,
|
||||
renderer: renderer_default,
|
||||
parser,
|
||||
styles: styles_default
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=diagram-5BDNPKRD-IMF7AYPE.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+578
@@ -0,0 +1,578 @@
|
||||
import {
|
||||
populateCommonDb
|
||||
} from "./chunk-BEGFPAJS.js";
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
setupViewPortForSVG
|
||||
} from "./chunk-YVBSFUGN.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
isLabelStyle,
|
||||
styles2String
|
||||
} from "./chunk-N2C52BYW.js";
|
||||
import {
|
||||
cleanAndMerge
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
clear,
|
||||
configureSvgSize,
|
||||
defaultConfig_default,
|
||||
getAccDescription,
|
||||
getAccTitle,
|
||||
getConfig,
|
||||
getDiagramTitle,
|
||||
getThemeVariables3,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
format,
|
||||
hierarchy,
|
||||
log,
|
||||
ordinal,
|
||||
select_default,
|
||||
treemap_default
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/diagram-G4DWMVQ6.mjs
|
||||
var _a;
|
||||
var TreeMapDB = (_a = class {
|
||||
constructor() {
|
||||
this.nodes = [];
|
||||
this.levels = /* @__PURE__ */ new Map();
|
||||
this.outerNodes = [];
|
||||
this.classes = /* @__PURE__ */ new Map();
|
||||
this.setAccTitle = setAccTitle;
|
||||
this.getAccTitle = getAccTitle;
|
||||
this.setDiagramTitle = setDiagramTitle;
|
||||
this.getDiagramTitle = getDiagramTitle;
|
||||
this.getAccDescription = getAccDescription;
|
||||
this.setAccDescription = setAccDescription;
|
||||
}
|
||||
getNodes() {
|
||||
return this.nodes;
|
||||
}
|
||||
getConfig() {
|
||||
const defaultConfig = defaultConfig_default;
|
||||
const userConfig = getConfig();
|
||||
return cleanAndMerge({
|
||||
...defaultConfig.treemap,
|
||||
...userConfig.treemap ?? {}
|
||||
});
|
||||
}
|
||||
addNode(node, level) {
|
||||
this.nodes.push(node);
|
||||
this.levels.set(node, level);
|
||||
if (level === 0) {
|
||||
this.outerNodes.push(node);
|
||||
this.root ?? (this.root = node);
|
||||
}
|
||||
}
|
||||
getRoot() {
|
||||
return { name: "", children: this.outerNodes };
|
||||
}
|
||||
addClass(id, _style) {
|
||||
const styleClass = this.classes.get(id) ?? { id, styles: [], textStyles: [] };
|
||||
const styles = _style.replace(/\\,/g, "§§§").replace(/,/g, ";").replace(/§§§/g, ",").split(";");
|
||||
if (styles) {
|
||||
styles.forEach((s) => {
|
||||
if (isLabelStyle(s)) {
|
||||
if (styleClass == null ? void 0 : styleClass.textStyles) {
|
||||
styleClass.textStyles.push(s);
|
||||
} else {
|
||||
styleClass.textStyles = [s];
|
||||
}
|
||||
}
|
||||
if (styleClass == null ? void 0 : styleClass.styles) {
|
||||
styleClass.styles.push(s);
|
||||
} else {
|
||||
styleClass.styles = [s];
|
||||
}
|
||||
});
|
||||
}
|
||||
this.classes.set(id, styleClass);
|
||||
}
|
||||
getClasses() {
|
||||
return this.classes;
|
||||
}
|
||||
getStylesForClass(classSelector) {
|
||||
var _a2;
|
||||
return ((_a2 = this.classes.get(classSelector)) == null ? void 0 : _a2.styles) ?? [];
|
||||
}
|
||||
clear() {
|
||||
clear();
|
||||
this.nodes = [];
|
||||
this.levels = /* @__PURE__ */ new Map();
|
||||
this.outerNodes = [];
|
||||
this.classes = /* @__PURE__ */ new Map();
|
||||
this.root = void 0;
|
||||
}
|
||||
}, __name(_a, "TreeMapDB"), _a);
|
||||
function buildHierarchy(items) {
|
||||
if (!items.length) {
|
||||
return [];
|
||||
}
|
||||
const root = [];
|
||||
const stack = [];
|
||||
items.forEach((item) => {
|
||||
const node = {
|
||||
name: item.name,
|
||||
children: item.type === "Leaf" ? void 0 : []
|
||||
};
|
||||
node.classSelector = item == null ? void 0 : item.classSelector;
|
||||
if (item == null ? void 0 : item.cssCompiledStyles) {
|
||||
node.cssCompiledStyles = item.cssCompiledStyles;
|
||||
}
|
||||
if (item.type === "Leaf" && item.value !== void 0) {
|
||||
node.value = item.value;
|
||||
}
|
||||
while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {
|
||||
stack.pop();
|
||||
}
|
||||
if (stack.length === 0) {
|
||||
root.push(node);
|
||||
} else {
|
||||
const parent = stack[stack.length - 1].node;
|
||||
if (parent.children) {
|
||||
parent.children.push(node);
|
||||
} else {
|
||||
parent.children = [node];
|
||||
}
|
||||
}
|
||||
if (item.type !== "Leaf") {
|
||||
stack.push({ node, level: item.level });
|
||||
}
|
||||
});
|
||||
return root;
|
||||
}
|
||||
__name(buildHierarchy, "buildHierarchy");
|
||||
var populate = __name((ast, db) => {
|
||||
populateCommonDb(ast, db);
|
||||
const items = [];
|
||||
for (const row of ast.TreemapRows ?? []) {
|
||||
if (row.$type === "ClassDefStatement") {
|
||||
db.addClass(row.className ?? "", row.styleText ?? "");
|
||||
}
|
||||
}
|
||||
for (const row of ast.TreemapRows ?? []) {
|
||||
const item = row.item;
|
||||
if (!item) {
|
||||
continue;
|
||||
}
|
||||
const level = row.indent ? parseInt(row.indent) : 0;
|
||||
const name = getItemName(item);
|
||||
const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];
|
||||
const cssCompiledStyles = styles.length > 0 ? styles : void 0;
|
||||
const itemData = {
|
||||
level,
|
||||
name,
|
||||
type: item.$type,
|
||||
value: item.value,
|
||||
classSelector: item.classSelector,
|
||||
cssCompiledStyles
|
||||
};
|
||||
items.push(itemData);
|
||||
}
|
||||
const hierarchyNodes = buildHierarchy(items);
|
||||
const addNodesRecursively = __name((nodes, level) => {
|
||||
for (const node of nodes) {
|
||||
db.addNode(node, level);
|
||||
if (node.children && node.children.length > 0) {
|
||||
addNodesRecursively(node.children, level + 1);
|
||||
}
|
||||
}
|
||||
}, "addNodesRecursively");
|
||||
addNodesRecursively(hierarchyNodes, 0);
|
||||
}, "populate");
|
||||
var getItemName = __name((item) => {
|
||||
return item.name ? String(item.name) : "";
|
||||
}, "getItemName");
|
||||
var parser = {
|
||||
// @ts-expect-error - TreeMapDB is not assignable to DiagramDB
|
||||
parser: { yy: void 0 },
|
||||
parse: __name(async (text) => {
|
||||
var _a2;
|
||||
try {
|
||||
const parseFunc = parse;
|
||||
const ast = await parseFunc("treemap", text);
|
||||
log.debug("Treemap AST:", ast);
|
||||
const db = (_a2 = parser.parser) == null ? void 0 : _a2.yy;
|
||||
if (!(db instanceof TreeMapDB)) {
|
||||
throw new Error(
|
||||
"parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
|
||||
);
|
||||
}
|
||||
populate(ast, db);
|
||||
} catch (error) {
|
||||
log.error("Error parsing treemap:", error);
|
||||
throw error;
|
||||
}
|
||||
}, "parse")
|
||||
};
|
||||
var DEFAULT_INNER_PADDING = 10;
|
||||
var SECTION_INNER_PADDING = 10;
|
||||
var SECTION_HEADER_HEIGHT = 25;
|
||||
var draw = __name((_text, id, _version, diagram2) => {
|
||||
const treemapDb = diagram2.db;
|
||||
const config = treemapDb.getConfig();
|
||||
const treemapInnerPadding = config.padding ?? DEFAULT_INNER_PADDING;
|
||||
const title = treemapDb.getDiagramTitle();
|
||||
const root = treemapDb.getRoot();
|
||||
const { themeVariables } = getConfig();
|
||||
if (!root) {
|
||||
return;
|
||||
}
|
||||
const titleHeight = title ? 30 : 0;
|
||||
const svg = selectSvgElement(id);
|
||||
const width = config.nodeWidth ? config.nodeWidth * SECTION_INNER_PADDING : 960;
|
||||
const height = config.nodeHeight ? config.nodeHeight * SECTION_INNER_PADDING : 500;
|
||||
const svgWidth = width;
|
||||
const svgHeight = height + titleHeight;
|
||||
svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
|
||||
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
||||
let valueFormat;
|
||||
try {
|
||||
const formatStr = config.valueFormat || ",";
|
||||
if (formatStr === "$0,0") {
|
||||
valueFormat = __name((value) => "$" + format(",")(value), "valueFormat");
|
||||
} else if (formatStr.startsWith("$") && formatStr.includes(",")) {
|
||||
const precision = /\.\d+/.exec(formatStr);
|
||||
const precisionStr = precision ? precision[0] : "";
|
||||
valueFormat = __name((value) => "$" + format("," + precisionStr)(value), "valueFormat");
|
||||
} else if (formatStr.startsWith("$")) {
|
||||
const restOfFormat = formatStr.substring(1);
|
||||
valueFormat = __name((value) => "$" + format(restOfFormat || "")(value), "valueFormat");
|
||||
} else {
|
||||
valueFormat = format(formatStr);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error("Error creating format function:", error);
|
||||
valueFormat = format(",");
|
||||
}
|
||||
const colorScale = ordinal().range([
|
||||
"transparent",
|
||||
themeVariables.cScale0,
|
||||
themeVariables.cScale1,
|
||||
themeVariables.cScale2,
|
||||
themeVariables.cScale3,
|
||||
themeVariables.cScale4,
|
||||
themeVariables.cScale5,
|
||||
themeVariables.cScale6,
|
||||
themeVariables.cScale7,
|
||||
themeVariables.cScale8,
|
||||
themeVariables.cScale9,
|
||||
themeVariables.cScale10,
|
||||
themeVariables.cScale11
|
||||
]);
|
||||
const colorScalePeer = ordinal().range([
|
||||
"transparent",
|
||||
themeVariables.cScalePeer0,
|
||||
themeVariables.cScalePeer1,
|
||||
themeVariables.cScalePeer2,
|
||||
themeVariables.cScalePeer3,
|
||||
themeVariables.cScalePeer4,
|
||||
themeVariables.cScalePeer5,
|
||||
themeVariables.cScalePeer6,
|
||||
themeVariables.cScalePeer7,
|
||||
themeVariables.cScalePeer8,
|
||||
themeVariables.cScalePeer9,
|
||||
themeVariables.cScalePeer10,
|
||||
themeVariables.cScalePeer11
|
||||
]);
|
||||
const colorScaleLabel = ordinal().range([
|
||||
themeVariables.cScaleLabel0,
|
||||
themeVariables.cScaleLabel1,
|
||||
themeVariables.cScaleLabel2,
|
||||
themeVariables.cScaleLabel3,
|
||||
themeVariables.cScaleLabel4,
|
||||
themeVariables.cScaleLabel5,
|
||||
themeVariables.cScaleLabel6,
|
||||
themeVariables.cScaleLabel7,
|
||||
themeVariables.cScaleLabel8,
|
||||
themeVariables.cScaleLabel9,
|
||||
themeVariables.cScaleLabel10,
|
||||
themeVariables.cScaleLabel11
|
||||
]);
|
||||
if (title) {
|
||||
svg.append("text").attr("x", svgWidth / 2).attr("y", titleHeight / 2).attr("class", "treemapTitle").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
|
||||
}
|
||||
const g = svg.append("g").attr("transform", `translate(0, ${titleHeight})`).attr("class", "treemapContainer");
|
||||
const hierarchyRoot = hierarchy(root).sum((d) => d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));
|
||||
const treemapLayout = treemap_default().size([width, height]).paddingTop(
|
||||
(d) => d.children && d.children.length > 0 ? SECTION_HEADER_HEIGHT + SECTION_INNER_PADDING : 0
|
||||
).paddingInner(treemapInnerPadding).paddingLeft((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingRight((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingBottom((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).round(true);
|
||||
const treemapData = treemapLayout(hierarchyRoot);
|
||||
const branchNodes = treemapData.descendants().filter((d) => d.children && d.children.length > 0);
|
||||
const sections = g.selectAll(".treemapSection").data(branchNodes).enter().append("g").attr("class", "treemapSection").attr("transform", (d) => `translate(${d.x0},${d.y0})`);
|
||||
sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", SECTION_HEADER_HEIGHT).attr("class", "treemapSectionHeader").attr("fill", "none").attr("fill-opacity", 0.6).attr("stroke-width", 0.6).attr("style", (d) => {
|
||||
if (d.depth === 0) {
|
||||
return "display: none;";
|
||||
}
|
||||
return "";
|
||||
});
|
||||
sections.append("clipPath").attr("id", (_d, i) => `clip-section-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 12)).attr("height", SECTION_HEADER_HEIGHT);
|
||||
sections.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", (_d, i) => {
|
||||
return `treemapSection section${i}`;
|
||||
}).attr("fill", (d) => colorScale(d.data.name)).attr("fill-opacity", 0.6).attr("stroke", (d) => colorScalePeer(d.data.name)).attr("stroke-width", 2).attr("stroke-opacity", 0.4).attr("style", (d) => {
|
||||
if (d.depth === 0) {
|
||||
return "display: none;";
|
||||
}
|
||||
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
||||
return styles.nodeStyles + ";" + styles.borderStyles.join(";");
|
||||
});
|
||||
sections.append("text").attr("class", "treemapSectionLabel").attr("x", 6).attr("y", SECTION_HEADER_HEIGHT / 2).attr("dominant-baseline", "middle").text((d) => d.depth === 0 ? "" : d.data.name).attr("font-weight", "bold").attr("style", (d) => {
|
||||
if (d.depth === 0) {
|
||||
return "display: none;";
|
||||
}
|
||||
const labelStyles = "dominant-baseline: middle; font-size: 12px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
|
||||
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
||||
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
||||
}).each(function(d) {
|
||||
if (d.depth === 0) {
|
||||
return;
|
||||
}
|
||||
const self = select_default(this);
|
||||
const originalText = d.data.name;
|
||||
self.text(originalText);
|
||||
const totalHeaderWidth = d.x1 - d.x0;
|
||||
const labelXPosition = 6;
|
||||
let spaceForTextContent;
|
||||
if (config.showValues !== false && d.value) {
|
||||
const valueEndsAtXRelative = totalHeaderWidth - 10;
|
||||
const estimatedValueTextActualWidth = 30;
|
||||
const gapBetweenLabelAndValue = 10;
|
||||
const labelMustEndBeforeX = valueEndsAtXRelative - estimatedValueTextActualWidth - gapBetweenLabelAndValue;
|
||||
spaceForTextContent = labelMustEndBeforeX - labelXPosition;
|
||||
} else {
|
||||
const labelOwnRightPadding = 6;
|
||||
spaceForTextContent = totalHeaderWidth - labelXPosition - labelOwnRightPadding;
|
||||
}
|
||||
const minimumWidthToDisplay = 15;
|
||||
const actualAvailableWidth = Math.max(minimumWidthToDisplay, spaceForTextContent);
|
||||
const textNode = self.node();
|
||||
const currentTextContentLength = textNode.getComputedTextLength();
|
||||
if (currentTextContentLength > actualAvailableWidth) {
|
||||
const ellipsis = "...";
|
||||
let currentTruncatedText = originalText;
|
||||
while (currentTruncatedText.length > 0) {
|
||||
currentTruncatedText = originalText.substring(0, currentTruncatedText.length - 1);
|
||||
if (currentTruncatedText.length === 0) {
|
||||
self.text(ellipsis);
|
||||
if (textNode.getComputedTextLength() > actualAvailableWidth) {
|
||||
self.text("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
self.text(currentTruncatedText + ellipsis);
|
||||
if (textNode.getComputedTextLength() <= actualAvailableWidth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (config.showValues !== false) {
|
||||
sections.append("text").attr("class", "treemapSectionValue").attr("x", (d) => d.x1 - d.x0 - 10).attr("y", SECTION_HEADER_HEIGHT / 2).attr("text-anchor", "end").attr("dominant-baseline", "middle").text((d) => d.value ? valueFormat(d.value) : "").attr("font-style", "italic").attr("style", (d) => {
|
||||
if (d.depth === 0) {
|
||||
return "display: none;";
|
||||
}
|
||||
const labelStyles = "text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:" + colorScaleLabel(d.data.name) + "; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;";
|
||||
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
||||
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
||||
});
|
||||
}
|
||||
const leafNodes = treemapData.leaves();
|
||||
const cell = g.selectAll(".treemapLeafGroup").data(leafNodes).enter().append("g").attr("class", (d, i) => {
|
||||
return `treemapNode treemapLeafGroup leaf${i}${d.data.classSelector ? ` ${d.data.classSelector}` : ""}x`;
|
||||
}).attr("transform", (d) => `translate(${d.x0},${d.y0})`);
|
||||
cell.append("rect").attr("width", (d) => d.x1 - d.x0).attr("height", (d) => d.y1 - d.y0).attr("class", "treemapLeaf").attr("fill", (d) => {
|
||||
return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
|
||||
}).attr("style", (d) => {
|
||||
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
||||
return styles.nodeStyles;
|
||||
}).attr("fill-opacity", 0.3).attr("stroke", (d) => {
|
||||
return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);
|
||||
}).attr("stroke-width", 3);
|
||||
cell.append("clipPath").attr("id", (_d, i) => `clip-${id}-${i}`).append("rect").attr("width", (d) => Math.max(0, d.x1 - d.x0 - 4)).attr("height", (d) => Math.max(0, d.y1 - d.y0 - 4));
|
||||
const leafLabels = cell.append("text").attr("class", "treemapLabel").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", (d) => (d.y1 - d.y0) / 2).attr("style", (d) => {
|
||||
const labelStyles = "text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:" + colorScaleLabel(d.data.name) + ";";
|
||||
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
||||
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
||||
}).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.data.name);
|
||||
leafLabels.each(function(d) {
|
||||
const self = select_default(this);
|
||||
const nodeWidth = d.x1 - d.x0;
|
||||
const nodeHeight = d.y1 - d.y0;
|
||||
const textNode = self.node();
|
||||
const padding = 4;
|
||||
const availableWidth = nodeWidth - 2 * padding;
|
||||
const availableHeight = nodeHeight - 2 * padding;
|
||||
if (availableWidth < 10 || availableHeight < 10) {
|
||||
self.style("display", "none");
|
||||
return;
|
||||
}
|
||||
let currentLabelFontSize = parseInt(self.style("font-size"), 10);
|
||||
const minLabelFontSize = 8;
|
||||
const originalValueRelFontSize = 28;
|
||||
const valueScaleFactor = 0.6;
|
||||
const minValueFontSize = 6;
|
||||
const spacingBetweenLabelAndValue = 2;
|
||||
while (textNode.getComputedTextLength() > availableWidth && currentLabelFontSize > minLabelFontSize) {
|
||||
currentLabelFontSize--;
|
||||
self.style("font-size", `${currentLabelFontSize}px`);
|
||||
}
|
||||
let prospectiveValueFontSize = Math.max(
|
||||
minValueFontSize,
|
||||
Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
|
||||
);
|
||||
let combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
|
||||
while (combinedHeight > availableHeight && currentLabelFontSize > minLabelFontSize) {
|
||||
currentLabelFontSize--;
|
||||
prospectiveValueFontSize = Math.max(
|
||||
minValueFontSize,
|
||||
Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))
|
||||
);
|
||||
if (prospectiveValueFontSize < minValueFontSize && currentLabelFontSize === minLabelFontSize) {
|
||||
break;
|
||||
}
|
||||
self.style("font-size", `${currentLabelFontSize}px`);
|
||||
combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;
|
||||
if (prospectiveValueFontSize <= minValueFontSize && combinedHeight > availableHeight) {
|
||||
}
|
||||
}
|
||||
self.style("font-size", `${currentLabelFontSize}px`);
|
||||
if (textNode.getComputedTextLength() > availableWidth || currentLabelFontSize < minLabelFontSize || availableHeight < currentLabelFontSize) {
|
||||
self.style("display", "none");
|
||||
}
|
||||
});
|
||||
if (config.showValues !== false) {
|
||||
const leafValues = cell.append("text").attr("class", "treemapValue").attr("x", (d) => (d.x1 - d.x0) / 2).attr("y", function(d) {
|
||||
return (d.y1 - d.y0) / 2;
|
||||
}).attr("style", (d) => {
|
||||
const labelStyles = "text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:" + colorScaleLabel(d.data.name) + ";";
|
||||
const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });
|
||||
return labelStyles + styles.labelStyles.replace("color:", "fill:");
|
||||
}).attr("clip-path", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.value ? valueFormat(d.value) : "");
|
||||
leafValues.each(function(d) {
|
||||
const valueTextElement = select_default(this);
|
||||
const parentCellNode = this.parentNode;
|
||||
if (!parentCellNode) {
|
||||
valueTextElement.style("display", "none");
|
||||
return;
|
||||
}
|
||||
const labelElement = select_default(parentCellNode).select(".treemapLabel");
|
||||
if (labelElement.empty() || labelElement.style("display") === "none") {
|
||||
valueTextElement.style("display", "none");
|
||||
return;
|
||||
}
|
||||
const finalLabelFontSize = parseFloat(labelElement.style("font-size"));
|
||||
const originalValueFontSize = 28;
|
||||
const valueScaleFactor = 0.6;
|
||||
const minValueFontSize = 6;
|
||||
const spacingBetweenLabelAndValue = 2;
|
||||
const actualValueFontSize = Math.max(
|
||||
minValueFontSize,
|
||||
Math.min(originalValueFontSize, Math.round(finalLabelFontSize * valueScaleFactor))
|
||||
);
|
||||
valueTextElement.style("font-size", `${actualValueFontSize}px`);
|
||||
const labelCenterY = (d.y1 - d.y0) / 2;
|
||||
const valueTopActualY = labelCenterY + finalLabelFontSize / 2 + spacingBetweenLabelAndValue;
|
||||
valueTextElement.attr("y", valueTopActualY);
|
||||
const nodeWidth = d.x1 - d.x0;
|
||||
const nodeTotalHeight = d.y1 - d.y0;
|
||||
const cellBottomPadding = 4;
|
||||
const maxValueBottomY = nodeTotalHeight - cellBottomPadding;
|
||||
const availableWidthForValue = nodeWidth - 2 * 4;
|
||||
if (valueTextElement.node().getComputedTextLength() > availableWidthForValue || valueTopActualY + actualValueFontSize > maxValueBottomY || actualValueFontSize < minValueFontSize) {
|
||||
valueTextElement.style("display", "none");
|
||||
} else {
|
||||
valueTextElement.style("display", null);
|
||||
}
|
||||
});
|
||||
}
|
||||
const diagramPadding = config.diagramPadding ?? 8;
|
||||
setupViewPortForSVG(svg, diagramPadding, "flowchart", (config == null ? void 0 : config.useMaxWidth) || false);
|
||||
}, "draw");
|
||||
var getClasses = __name(function(_text, diagramObj) {
|
||||
return diagramObj.db.getClasses();
|
||||
}, "getClasses");
|
||||
var renderer = { draw, getClasses };
|
||||
var defaultTreemapStyleOptions = {
|
||||
sectionStrokeColor: "black",
|
||||
sectionStrokeWidth: "1",
|
||||
sectionFillColor: "#efefef",
|
||||
leafStrokeColor: "black",
|
||||
leafStrokeWidth: "1",
|
||||
leafFillColor: "#efefef",
|
||||
labelFontSize: "12px",
|
||||
valueFontSize: "10px",
|
||||
titleFontSize: "14px"
|
||||
};
|
||||
var getStyles = __name(({
|
||||
treemap: treemap2
|
||||
} = {}) => {
|
||||
const defaultThemeVariables = getThemeVariables3();
|
||||
const currentConfig = getConfig();
|
||||
const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
|
||||
const options = cleanAndMerge(defaultTreemapStyleOptions, treemap2);
|
||||
const titleColor = options.titleColor ?? themeVariables.titleColor;
|
||||
const labelColor = options.labelColor ?? themeVariables.textColor;
|
||||
const valueColor = options.valueColor ?? themeVariables.textColor;
|
||||
return `
|
||||
.treemapNode.section {
|
||||
stroke: ${options.sectionStrokeColor};
|
||||
stroke-width: ${options.sectionStrokeWidth};
|
||||
fill: ${options.sectionFillColor};
|
||||
}
|
||||
.treemapNode.leaf {
|
||||
stroke: ${options.leafStrokeColor};
|
||||
stroke-width: ${options.leafStrokeWidth};
|
||||
fill: ${options.leafFillColor};
|
||||
}
|
||||
.treemapLabel {
|
||||
fill: ${labelColor};
|
||||
font-size: ${options.labelFontSize};
|
||||
}
|
||||
.treemapValue {
|
||||
fill: ${valueColor};
|
||||
font-size: ${options.valueFontSize};
|
||||
}
|
||||
.treemapTitle {
|
||||
fill: ${titleColor};
|
||||
font-size: ${options.titleFontSize};
|
||||
}
|
||||
`;
|
||||
}, "getStyles");
|
||||
var styles_default = getStyles;
|
||||
var diagram = {
|
||||
parser,
|
||||
get db() {
|
||||
return new TreeMapDB();
|
||||
},
|
||||
renderer,
|
||||
styles: styles_default
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=diagram-G4DWMVQ6-GQLFITVI.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+349
@@ -0,0 +1,349 @@
|
||||
import {
|
||||
populateCommonDb
|
||||
} from "./chunk-BEGFPAJS.js";
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
cleanAndMerge
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
clear,
|
||||
configureSvgSize,
|
||||
defaultConfig_default,
|
||||
getAccDescription,
|
||||
getAccTitle,
|
||||
getConfig,
|
||||
getDiagramTitle,
|
||||
getThemeVariables3,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/diagram-MMDJMWI5.mjs
|
||||
var defaultOptions = {
|
||||
showLegend: true,
|
||||
ticks: 5,
|
||||
max: null,
|
||||
min: 0,
|
||||
graticule: "circle"
|
||||
};
|
||||
var defaultRadarData = {
|
||||
axes: [],
|
||||
curves: [],
|
||||
options: defaultOptions
|
||||
};
|
||||
var data = structuredClone(defaultRadarData);
|
||||
var DEFAULT_RADAR_CONFIG = defaultConfig_default.radar;
|
||||
var getConfig2 = __name(() => {
|
||||
const config = cleanAndMerge({
|
||||
...DEFAULT_RADAR_CONFIG,
|
||||
...getConfig().radar
|
||||
});
|
||||
return config;
|
||||
}, "getConfig");
|
||||
var getAxes = __name(() => data.axes, "getAxes");
|
||||
var getCurves = __name(() => data.curves, "getCurves");
|
||||
var getOptions = __name(() => data.options, "getOptions");
|
||||
var setAxes = __name((axes) => {
|
||||
data.axes = axes.map((axis) => {
|
||||
return {
|
||||
name: axis.name,
|
||||
label: axis.label ?? axis.name
|
||||
};
|
||||
});
|
||||
}, "setAxes");
|
||||
var setCurves = __name((curves) => {
|
||||
data.curves = curves.map((curve) => {
|
||||
return {
|
||||
name: curve.name,
|
||||
label: curve.label ?? curve.name,
|
||||
entries: computeCurveEntries(curve.entries)
|
||||
};
|
||||
});
|
||||
}, "setCurves");
|
||||
var computeCurveEntries = __name((entries) => {
|
||||
if (entries[0].axis == void 0) {
|
||||
return entries.map((entry) => entry.value);
|
||||
}
|
||||
const axes = getAxes();
|
||||
if (axes.length === 0) {
|
||||
throw new Error("Axes must be populated before curves for reference entries");
|
||||
}
|
||||
return axes.map((axis) => {
|
||||
const entry = entries.find((entry2) => {
|
||||
var _a;
|
||||
return ((_a = entry2.axis) == null ? void 0 : _a.$refText) === axis.name;
|
||||
});
|
||||
if (entry === void 0) {
|
||||
throw new Error("Missing entry for axis " + axis.label);
|
||||
}
|
||||
return entry.value;
|
||||
});
|
||||
}, "computeCurveEntries");
|
||||
var setOptions = __name((options) => {
|
||||
var _a, _b, _c, _d, _e;
|
||||
const optionMap = options.reduce(
|
||||
(acc, option) => {
|
||||
acc[option.name] = option;
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
data.options = {
|
||||
showLegend: ((_a = optionMap.showLegend) == null ? void 0 : _a.value) ?? defaultOptions.showLegend,
|
||||
ticks: ((_b = optionMap.ticks) == null ? void 0 : _b.value) ?? defaultOptions.ticks,
|
||||
max: ((_c = optionMap.max) == null ? void 0 : _c.value) ?? defaultOptions.max,
|
||||
min: ((_d = optionMap.min) == null ? void 0 : _d.value) ?? defaultOptions.min,
|
||||
graticule: ((_e = optionMap.graticule) == null ? void 0 : _e.value) ?? defaultOptions.graticule
|
||||
};
|
||||
}, "setOptions");
|
||||
var clear2 = __name(() => {
|
||||
clear();
|
||||
data = structuredClone(defaultRadarData);
|
||||
}, "clear");
|
||||
var db = {
|
||||
getAxes,
|
||||
getCurves,
|
||||
getOptions,
|
||||
setAxes,
|
||||
setCurves,
|
||||
setOptions,
|
||||
getConfig: getConfig2,
|
||||
clear: clear2,
|
||||
setAccTitle,
|
||||
getAccTitle,
|
||||
setDiagramTitle,
|
||||
getDiagramTitle,
|
||||
getAccDescription,
|
||||
setAccDescription
|
||||
};
|
||||
var populate = __name((ast) => {
|
||||
populateCommonDb(ast, db);
|
||||
const { axes, curves, options } = ast;
|
||||
db.setAxes(axes);
|
||||
db.setCurves(curves);
|
||||
db.setOptions(options);
|
||||
}, "populate");
|
||||
var parser = {
|
||||
parse: __name(async (input) => {
|
||||
const ast = await parse("radar", input);
|
||||
log.debug(ast);
|
||||
populate(ast);
|
||||
}, "parse")
|
||||
};
|
||||
var draw = __name((_text, id, _version, diagram2) => {
|
||||
const db2 = diagram2.db;
|
||||
const axes = db2.getAxes();
|
||||
const curves = db2.getCurves();
|
||||
const options = db2.getOptions();
|
||||
const config = db2.getConfig();
|
||||
const title = db2.getDiagramTitle();
|
||||
const svg = selectSvgElement(id);
|
||||
const g = drawFrame(svg, config);
|
||||
const maxValue = options.max ?? Math.max(...curves.map((curve) => Math.max(...curve.entries)));
|
||||
const minValue = options.min;
|
||||
const radius = Math.min(config.width, config.height) / 2;
|
||||
drawGraticule(g, axes, radius, options.ticks, options.graticule);
|
||||
drawAxes(g, axes, radius, config);
|
||||
drawCurves(g, axes, curves, minValue, maxValue, options.graticule, config);
|
||||
drawLegend(g, curves, options.showLegend, config);
|
||||
g.append("text").attr("class", "radarTitle").text(title).attr("x", 0).attr("y", -config.height / 2 - config.marginTop);
|
||||
}, "draw");
|
||||
var drawFrame = __name((svg, config) => {
|
||||
const totalWidth = config.width + config.marginLeft + config.marginRight;
|
||||
const totalHeight = config.height + config.marginTop + config.marginBottom;
|
||||
const center = {
|
||||
x: config.marginLeft + config.width / 2,
|
||||
y: config.marginTop + config.height / 2
|
||||
};
|
||||
configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth ?? true);
|
||||
svg.attr("viewBox", `0 0 ${totalWidth} ${totalHeight}`);
|
||||
return svg.append("g").attr("transform", `translate(${center.x}, ${center.y})`);
|
||||
}, "drawFrame");
|
||||
var drawGraticule = __name((g, axes, radius, ticks, graticule) => {
|
||||
if (graticule === "circle") {
|
||||
for (let i = 0; i < ticks; i++) {
|
||||
const r = radius * (i + 1) / ticks;
|
||||
g.append("circle").attr("r", r).attr("class", "radarGraticule");
|
||||
}
|
||||
} else if (graticule === "polygon") {
|
||||
const numAxes = axes.length;
|
||||
for (let i = 0; i < ticks; i++) {
|
||||
const r = radius * (i + 1) / ticks;
|
||||
const points = axes.map((_, j) => {
|
||||
const angle = 2 * j * Math.PI / numAxes - Math.PI / 2;
|
||||
const x = r * Math.cos(angle);
|
||||
const y = r * Math.sin(angle);
|
||||
return `${x},${y}`;
|
||||
}).join(" ");
|
||||
g.append("polygon").attr("points", points).attr("class", "radarGraticule");
|
||||
}
|
||||
}
|
||||
}, "drawGraticule");
|
||||
var drawAxes = __name((g, axes, radius, config) => {
|
||||
const numAxes = axes.length;
|
||||
for (let i = 0; i < numAxes; i++) {
|
||||
const label = axes[i].label;
|
||||
const angle = 2 * i * Math.PI / numAxes - Math.PI / 2;
|
||||
g.append("line").attr("x1", 0).attr("y1", 0).attr("x2", radius * config.axisScaleFactor * Math.cos(angle)).attr("y2", radius * config.axisScaleFactor * Math.sin(angle)).attr("class", "radarAxisLine");
|
||||
g.append("text").text(label).attr("x", radius * config.axisLabelFactor * Math.cos(angle)).attr("y", radius * config.axisLabelFactor * Math.sin(angle)).attr("class", "radarAxisLabel");
|
||||
}
|
||||
}, "drawAxes");
|
||||
function drawCurves(g, axes, curves, minValue, maxValue, graticule, config) {
|
||||
const numAxes = axes.length;
|
||||
const radius = Math.min(config.width, config.height) / 2;
|
||||
curves.forEach((curve, index) => {
|
||||
if (curve.entries.length !== numAxes) {
|
||||
return;
|
||||
}
|
||||
const points = curve.entries.map((entry, i) => {
|
||||
const angle = 2 * Math.PI * i / numAxes - Math.PI / 2;
|
||||
const r = relativeRadius(entry, minValue, maxValue, radius);
|
||||
const x = r * Math.cos(angle);
|
||||
const y = r * Math.sin(angle);
|
||||
return { x, y };
|
||||
});
|
||||
if (graticule === "circle") {
|
||||
g.append("path").attr("d", closedRoundCurve(points, config.curveTension)).attr("class", `radarCurve-${index}`);
|
||||
} else if (graticule === "polygon") {
|
||||
g.append("polygon").attr("points", points.map((p) => `${p.x},${p.y}`).join(" ")).attr("class", `radarCurve-${index}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
__name(drawCurves, "drawCurves");
|
||||
function relativeRadius(value, minValue, maxValue, radius) {
|
||||
const clippedValue = Math.min(Math.max(value, minValue), maxValue);
|
||||
return radius * (clippedValue - minValue) / (maxValue - minValue);
|
||||
}
|
||||
__name(relativeRadius, "relativeRadius");
|
||||
function closedRoundCurve(points, tension) {
|
||||
const numPoints = points.length;
|
||||
let d = `M${points[0].x},${points[0].y}`;
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
const p0 = points[(i - 1 + numPoints) % numPoints];
|
||||
const p1 = points[i];
|
||||
const p2 = points[(i + 1) % numPoints];
|
||||
const p3 = points[(i + 2) % numPoints];
|
||||
const cp1 = {
|
||||
x: p1.x + (p2.x - p0.x) * tension,
|
||||
y: p1.y + (p2.y - p0.y) * tension
|
||||
};
|
||||
const cp2 = {
|
||||
x: p2.x - (p3.x - p1.x) * tension,
|
||||
y: p2.y - (p3.y - p1.y) * tension
|
||||
};
|
||||
d += ` C${cp1.x},${cp1.y} ${cp2.x},${cp2.y} ${p2.x},${p2.y}`;
|
||||
}
|
||||
return `${d} Z`;
|
||||
}
|
||||
__name(closedRoundCurve, "closedRoundCurve");
|
||||
function drawLegend(g, curves, showLegend, config) {
|
||||
if (!showLegend) {
|
||||
return;
|
||||
}
|
||||
const legendX = (config.width / 2 + config.marginRight) * 3 / 4;
|
||||
const legendY = -(config.height / 2 + config.marginTop) * 3 / 4;
|
||||
const lineHeight = 20;
|
||||
curves.forEach((curve, index) => {
|
||||
const itemGroup = g.append("g").attr("transform", `translate(${legendX}, ${legendY + index * lineHeight})`);
|
||||
itemGroup.append("rect").attr("width", 12).attr("height", 12).attr("class", `radarLegendBox-${index}`);
|
||||
itemGroup.append("text").attr("x", 16).attr("y", 0).attr("class", "radarLegendText").text(curve.label);
|
||||
});
|
||||
}
|
||||
__name(drawLegend, "drawLegend");
|
||||
var renderer = { draw };
|
||||
var genIndexStyles = __name((themeVariables, radarOptions) => {
|
||||
let sections = "";
|
||||
for (let i = 0; i < themeVariables.THEME_COLOR_LIMIT; i++) {
|
||||
const indexColor = themeVariables[`cScale${i}`];
|
||||
sections += `
|
||||
.radarCurve-${i} {
|
||||
color: ${indexColor};
|
||||
fill: ${indexColor};
|
||||
fill-opacity: ${radarOptions.curveOpacity};
|
||||
stroke: ${indexColor};
|
||||
stroke-width: ${radarOptions.curveStrokeWidth};
|
||||
}
|
||||
.radarLegendBox-${i} {
|
||||
fill: ${indexColor};
|
||||
fill-opacity: ${radarOptions.curveOpacity};
|
||||
stroke: ${indexColor};
|
||||
}
|
||||
`;
|
||||
}
|
||||
return sections;
|
||||
}, "genIndexStyles");
|
||||
var buildRadarStyleOptions = __name((radar) => {
|
||||
const defaultThemeVariables = getThemeVariables3();
|
||||
const currentConfig = getConfig();
|
||||
const themeVariables = cleanAndMerge(defaultThemeVariables, currentConfig.themeVariables);
|
||||
const radarOptions = cleanAndMerge(themeVariables.radar, radar);
|
||||
return { themeVariables, radarOptions };
|
||||
}, "buildRadarStyleOptions");
|
||||
var styles = __name(({ radar } = {}) => {
|
||||
const { themeVariables, radarOptions } = buildRadarStyleOptions(radar);
|
||||
return `
|
||||
.radarTitle {
|
||||
font-size: ${themeVariables.fontSize};
|
||||
color: ${themeVariables.titleColor};
|
||||
dominant-baseline: hanging;
|
||||
text-anchor: middle;
|
||||
}
|
||||
.radarAxisLine {
|
||||
stroke: ${radarOptions.axisColor};
|
||||
stroke-width: ${radarOptions.axisStrokeWidth};
|
||||
}
|
||||
.radarAxisLabel {
|
||||
dominant-baseline: middle;
|
||||
text-anchor: middle;
|
||||
font-size: ${radarOptions.axisLabelFontSize}px;
|
||||
color: ${radarOptions.axisColor};
|
||||
}
|
||||
.radarGraticule {
|
||||
fill: ${radarOptions.graticuleColor};
|
||||
fill-opacity: ${radarOptions.graticuleOpacity};
|
||||
stroke: ${radarOptions.graticuleColor};
|
||||
stroke-width: ${radarOptions.graticuleStrokeWidth};
|
||||
}
|
||||
.radarLegendText {
|
||||
text-anchor: start;
|
||||
font-size: ${radarOptions.legendFontSize}px;
|
||||
dominant-baseline: hanging;
|
||||
}
|
||||
${genIndexStyles(themeVariables, radarOptions)}
|
||||
`;
|
||||
}, "styles");
|
||||
var diagram = {
|
||||
parser,
|
||||
db,
|
||||
renderer,
|
||||
styles
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=diagram-MMDJMWI5-H3XSHQUY.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+254
@@ -0,0 +1,254 @@
|
||||
import {
|
||||
populateCommonDb
|
||||
} from "./chunk-BEGFPAJS.js";
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
cleanAndMerge
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
clear,
|
||||
configureSvgSize,
|
||||
defaultConfig_default,
|
||||
getAccDescription,
|
||||
getAccTitle,
|
||||
getConfig,
|
||||
getDiagramTitle,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/diagram-TYMM5635.mjs
|
||||
var DEFAULT_PACKET_CONFIG = defaultConfig_default.packet;
|
||||
var _a;
|
||||
var PacketDB = (_a = class {
|
||||
constructor() {
|
||||
this.packet = [];
|
||||
this.setAccTitle = setAccTitle;
|
||||
this.getAccTitle = getAccTitle;
|
||||
this.setDiagramTitle = setDiagramTitle;
|
||||
this.getDiagramTitle = getDiagramTitle;
|
||||
this.getAccDescription = getAccDescription;
|
||||
this.setAccDescription = setAccDescription;
|
||||
}
|
||||
getConfig() {
|
||||
const config = cleanAndMerge({
|
||||
...DEFAULT_PACKET_CONFIG,
|
||||
...getConfig().packet
|
||||
});
|
||||
if (config.showBits) {
|
||||
config.paddingY += 10;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
getPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
pushWord(word) {
|
||||
if (word.length > 0) {
|
||||
this.packet.push(word);
|
||||
}
|
||||
}
|
||||
clear() {
|
||||
clear();
|
||||
this.packet = [];
|
||||
}
|
||||
}, __name(_a, "PacketDB"), _a);
|
||||
var maxPacketSize = 1e4;
|
||||
var populate = __name((ast, db) => {
|
||||
populateCommonDb(ast, db);
|
||||
let lastBit = -1;
|
||||
let word = [];
|
||||
let row = 1;
|
||||
const { bitsPerRow } = db.getConfig();
|
||||
for (let { start, end, bits, label } of ast.blocks) {
|
||||
if (start !== void 0 && end !== void 0 && end < start) {
|
||||
throw new Error(`Packet block ${start} - ${end} is invalid. End must be greater than start.`);
|
||||
}
|
||||
start ?? (start = lastBit + 1);
|
||||
if (start !== lastBit + 1) {
|
||||
throw new Error(
|
||||
`Packet block ${start} - ${end ?? start} is not contiguous. It should start from ${lastBit + 1}.`
|
||||
);
|
||||
}
|
||||
if (bits === 0) {
|
||||
throw new Error(`Packet block ${start} is invalid. Cannot have a zero bit field.`);
|
||||
}
|
||||
end ?? (end = start + (bits ?? 1) - 1);
|
||||
bits ?? (bits = end - start + 1);
|
||||
lastBit = end;
|
||||
log.debug(`Packet block ${start} - ${lastBit} with label ${label}`);
|
||||
while (word.length <= bitsPerRow + 1 && db.getPacket().length < maxPacketSize) {
|
||||
const [block, nextBlock] = getNextFittingBlock({ start, end, bits, label }, row, bitsPerRow);
|
||||
word.push(block);
|
||||
if (block.end + 1 === row * bitsPerRow) {
|
||||
db.pushWord(word);
|
||||
word = [];
|
||||
row++;
|
||||
}
|
||||
if (!nextBlock) {
|
||||
break;
|
||||
}
|
||||
({ start, end, bits, label } = nextBlock);
|
||||
}
|
||||
}
|
||||
db.pushWord(word);
|
||||
}, "populate");
|
||||
var getNextFittingBlock = __name((block, row, bitsPerRow) => {
|
||||
if (block.start === void 0) {
|
||||
throw new Error("start should have been set during first phase");
|
||||
}
|
||||
if (block.end === void 0) {
|
||||
throw new Error("end should have been set during first phase");
|
||||
}
|
||||
if (block.start > block.end) {
|
||||
throw new Error(`Block start ${block.start} is greater than block end ${block.end}.`);
|
||||
}
|
||||
if (block.end + 1 <= row * bitsPerRow) {
|
||||
return [block, void 0];
|
||||
}
|
||||
const rowEnd = row * bitsPerRow - 1;
|
||||
const rowStart = row * bitsPerRow;
|
||||
return [
|
||||
{
|
||||
start: block.start,
|
||||
end: rowEnd,
|
||||
label: block.label,
|
||||
bits: rowEnd - block.start
|
||||
},
|
||||
{
|
||||
start: rowStart,
|
||||
end: block.end,
|
||||
label: block.label,
|
||||
bits: block.end - rowStart
|
||||
}
|
||||
];
|
||||
}, "getNextFittingBlock");
|
||||
var parser = {
|
||||
// @ts-expect-error - PacketDB is not assignable to DiagramDB
|
||||
parser: { yy: void 0 },
|
||||
parse: __name(async (input) => {
|
||||
var _a2;
|
||||
const ast = await parse("packet", input);
|
||||
const db = (_a2 = parser.parser) == null ? void 0 : _a2.yy;
|
||||
if (!(db instanceof PacketDB)) {
|
||||
throw new Error(
|
||||
"parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
|
||||
);
|
||||
}
|
||||
log.debug(ast);
|
||||
populate(ast, db);
|
||||
}, "parse")
|
||||
};
|
||||
var draw = __name((_text, id, _version, diagram2) => {
|
||||
const db = diagram2.db;
|
||||
const config = db.getConfig();
|
||||
const { rowHeight, paddingY, bitWidth, bitsPerRow } = config;
|
||||
const words = db.getPacket();
|
||||
const title = db.getDiagramTitle();
|
||||
const totalRowHeight = rowHeight + paddingY;
|
||||
const svgHeight = totalRowHeight * (words.length + 1) - (title ? 0 : rowHeight);
|
||||
const svgWidth = bitWidth * bitsPerRow + 2;
|
||||
const svg = selectSvgElement(id);
|
||||
svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
|
||||
configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
|
||||
for (const [word, packet] of words.entries()) {
|
||||
drawWord(svg, packet, word, config);
|
||||
}
|
||||
svg.append("text").text(title).attr("x", svgWidth / 2).attr("y", svgHeight - totalRowHeight / 2).attr("dominant-baseline", "middle").attr("text-anchor", "middle").attr("class", "packetTitle");
|
||||
}, "draw");
|
||||
var drawWord = __name((svg, word, rowNumber, { rowHeight, paddingX, paddingY, bitWidth, bitsPerRow, showBits }) => {
|
||||
const group = svg.append("g");
|
||||
const wordY = rowNumber * (rowHeight + paddingY) + paddingY;
|
||||
for (const block of word) {
|
||||
const blockX = block.start % bitsPerRow * bitWidth + 1;
|
||||
const width = (block.end - block.start + 1) * bitWidth - paddingX;
|
||||
group.append("rect").attr("x", blockX).attr("y", wordY).attr("width", width).attr("height", rowHeight).attr("class", "packetBlock");
|
||||
group.append("text").attr("x", blockX + width / 2).attr("y", wordY + rowHeight / 2).attr("class", "packetLabel").attr("dominant-baseline", "middle").attr("text-anchor", "middle").text(block.label);
|
||||
if (!showBits) {
|
||||
continue;
|
||||
}
|
||||
const isSingleBlock = block.end === block.start;
|
||||
const bitNumberY = wordY - 2;
|
||||
group.append("text").attr("x", blockX + (isSingleBlock ? width / 2 : 0)).attr("y", bitNumberY).attr("class", "packetByte start").attr("dominant-baseline", "auto").attr("text-anchor", isSingleBlock ? "middle" : "start").text(block.start);
|
||||
if (!isSingleBlock) {
|
||||
group.append("text").attr("x", blockX + width).attr("y", bitNumberY).attr("class", "packetByte end").attr("dominant-baseline", "auto").attr("text-anchor", "end").text(block.end);
|
||||
}
|
||||
}
|
||||
}, "drawWord");
|
||||
var renderer = { draw };
|
||||
var defaultPacketStyleOptions = {
|
||||
byteFontSize: "10px",
|
||||
startByteColor: "black",
|
||||
endByteColor: "black",
|
||||
labelColor: "black",
|
||||
labelFontSize: "12px",
|
||||
titleColor: "black",
|
||||
titleFontSize: "14px",
|
||||
blockStrokeColor: "black",
|
||||
blockStrokeWidth: "1",
|
||||
blockFillColor: "#efefef"
|
||||
};
|
||||
var styles = __name(({ packet } = {}) => {
|
||||
const options = cleanAndMerge(defaultPacketStyleOptions, packet);
|
||||
return `
|
||||
.packetByte {
|
||||
font-size: ${options.byteFontSize};
|
||||
}
|
||||
.packetByte.start {
|
||||
fill: ${options.startByteColor};
|
||||
}
|
||||
.packetByte.end {
|
||||
fill: ${options.endByteColor};
|
||||
}
|
||||
.packetLabel {
|
||||
fill: ${options.labelColor};
|
||||
font-size: ${options.labelFontSize};
|
||||
}
|
||||
.packetTitle {
|
||||
fill: ${options.titleColor};
|
||||
font-size: ${options.titleFontSize};
|
||||
}
|
||||
.packetBlock {
|
||||
stroke: ${options.blockStrokeColor};
|
||||
stroke-width: ${options.blockStrokeWidth};
|
||||
fill: ${options.blockFillColor};
|
||||
}
|
||||
`;
|
||||
}, "styles");
|
||||
var diagram = {
|
||||
parser,
|
||||
get db() {
|
||||
return new PacketDB();
|
||||
},
|
||||
renderer,
|
||||
styles
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=diagram-TYMM5635-CFW6SUOY.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+1348
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2506
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+2654
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+1957
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+59
@@ -0,0 +1,59 @@
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
configureSvgSize
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/infoDiagram-42DDH7IO.mjs
|
||||
var parser = {
|
||||
parse: __name(async (input) => {
|
||||
const ast = await parse("info", input);
|
||||
log.debug(ast);
|
||||
}, "parse")
|
||||
};
|
||||
var DEFAULT_INFO_DB = {
|
||||
version: "11.14.0" + (true ? "" : "-tiny")
|
||||
};
|
||||
var getVersion = __name(() => DEFAULT_INFO_DB.version, "getVersion");
|
||||
var db = {
|
||||
getVersion
|
||||
};
|
||||
var draw = __name((text, id, version) => {
|
||||
log.debug("rendering info diagram\n" + text);
|
||||
const svg = selectSvgElement(id);
|
||||
configureSvgSize(svg, 100, 400, true);
|
||||
const group = svg.append("g");
|
||||
group.append("text").attr("x", 100).attr("y", 40).attr("class", "version").attr("font-size", 32).style("text-anchor", "middle").text(`v${version}`);
|
||||
}, "draw");
|
||||
var renderer = { draw };
|
||||
var diagram = {
|
||||
parser,
|
||||
db,
|
||||
renderer
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=infoDiagram-42DDH7IO-SPOK6NRM.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../mermaid/dist/chunks/mermaid.core/infoDiagram-42DDH7IO.mjs"],
|
||||
"sourcesContent": ["import {\n selectSvgElement\n} from \"./chunk-426QAEUC.mjs\";\nimport {\n configureSvgSize\n} from \"./chunk-ICPOFSXX.mjs\";\nimport {\n __name,\n log\n} from \"./chunk-AGHRB4JF.mjs\";\n\n// src/diagrams/info/infoParser.ts\nimport { parse } from \"@mermaid-js/parser\";\nvar parser = {\n parse: /* @__PURE__ */ __name(async (input) => {\n const ast = await parse(\"info\", input);\n log.debug(ast);\n }, \"parse\")\n};\n\n// src/diagrams/info/infoDb.ts\nvar DEFAULT_INFO_DB = {\n version: \"11.14.0\" + (true ? \"\" : \"-tiny\")\n};\nvar getVersion = /* @__PURE__ */ __name(() => DEFAULT_INFO_DB.version, \"getVersion\");\nvar db = {\n getVersion\n};\n\n// src/diagrams/info/infoRenderer.ts\nvar draw = /* @__PURE__ */ __name((text, id, version) => {\n log.debug(\"rendering info diagram\\n\" + text);\n const svg = selectSvgElement(id);\n configureSvgSize(svg, 100, 400, true);\n const group = svg.append(\"g\");\n group.append(\"text\").attr(\"x\", 100).attr(\"y\", 40).attr(\"class\", \"version\").attr(\"font-size\", 32).style(\"text-anchor\", \"middle\").text(`v${version}`);\n}, \"draw\");\nvar renderer = { draw };\n\n// src/diagrams/info/infoDiagram.ts\nvar diagram = {\n parser,\n db,\n renderer\n};\nexport {\n diagram\n};\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,IAAI,SAAS;AAAA,EACX,OAAuB,OAAO,OAAO,UAAU;AAC7C,UAAM,MAAM,MAAM,MAAM,QAAQ,KAAK;AACrC,QAAI,MAAM,GAAG;AAAA,EACf,GAAG,OAAO;AACZ;AAGA,IAAI,kBAAkB;AAAA,EACpB,SAAS,aAAa,OAAO,KAAK;AACpC;AACA,IAAI,aAA6B,OAAO,MAAM,gBAAgB,SAAS,YAAY;AACnF,IAAI,KAAK;AAAA,EACP;AACF;AAGA,IAAI,OAAuB,OAAO,CAAC,MAAM,IAAI,YAAY;AACvD,MAAI,MAAM,6BAA6B,IAAI;AAC3C,QAAM,MAAM,iBAAiB,EAAE;AAC/B,mBAAiB,KAAK,KAAK,KAAK,IAAI;AACpC,QAAM,QAAQ,IAAI,OAAO,GAAG;AAC5B,QAAM,OAAO,MAAM,EAAE,KAAK,KAAK,GAAG,EAAE,KAAK,KAAK,EAAE,EAAE,KAAK,SAAS,SAAS,EAAE,KAAK,aAAa,EAAE,EAAE,MAAM,eAAe,QAAQ,EAAE,KAAK,IAAI,OAAO,EAAE;AACpJ,GAAG,MAAM;AACT,IAAI,WAAW,EAAE,KAAK;AAGtB,IAAI,UAAU;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AACF;",
|
||||
"names": []
|
||||
}
|
||||
+1011
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+1132
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+1555
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+239
@@ -0,0 +1,239 @@
|
||||
import {
|
||||
populateCommonDb
|
||||
} from "./chunk-BEGFPAJS.js";
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
cleanAndMerge,
|
||||
parseFontSize
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
clear,
|
||||
configureSvgSize,
|
||||
defaultConfig_default,
|
||||
getAccDescription,
|
||||
getAccTitle,
|
||||
getConfig2,
|
||||
getDiagramTitle,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
arc_default,
|
||||
log,
|
||||
ordinal,
|
||||
pie_default
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/pieDiagram-DEJITSTG.mjs
|
||||
var DEFAULT_PIE_CONFIG = defaultConfig_default.pie;
|
||||
var DEFAULT_PIE_DB = {
|
||||
sections: /* @__PURE__ */ new Map(),
|
||||
showData: false,
|
||||
config: DEFAULT_PIE_CONFIG
|
||||
};
|
||||
var sections = DEFAULT_PIE_DB.sections;
|
||||
var showData = DEFAULT_PIE_DB.showData;
|
||||
var config = structuredClone(DEFAULT_PIE_CONFIG);
|
||||
var getConfig22 = __name(() => structuredClone(config), "getConfig");
|
||||
var clear2 = __name(() => {
|
||||
sections = /* @__PURE__ */ new Map();
|
||||
showData = DEFAULT_PIE_DB.showData;
|
||||
clear();
|
||||
}, "clear");
|
||||
var addSection = __name(({ label, value }) => {
|
||||
if (value < 0) {
|
||||
throw new Error(
|
||||
`"${label}" has invalid value: ${value}. Negative values are not allowed in pie charts. All slice values must be >= 0.`
|
||||
);
|
||||
}
|
||||
if (!sections.has(label)) {
|
||||
sections.set(label, value);
|
||||
log.debug(`added new section: ${label}, with value: ${value}`);
|
||||
}
|
||||
}, "addSection");
|
||||
var getSections = __name(() => sections, "getSections");
|
||||
var setShowData = __name((toggle) => {
|
||||
showData = toggle;
|
||||
}, "setShowData");
|
||||
var getShowData = __name(() => showData, "getShowData");
|
||||
var db = {
|
||||
getConfig: getConfig22,
|
||||
clear: clear2,
|
||||
setDiagramTitle,
|
||||
getDiagramTitle,
|
||||
setAccTitle,
|
||||
getAccTitle,
|
||||
setAccDescription,
|
||||
getAccDescription,
|
||||
addSection,
|
||||
getSections,
|
||||
setShowData,
|
||||
getShowData
|
||||
};
|
||||
var populateDb = __name((ast, db2) => {
|
||||
populateCommonDb(ast, db2);
|
||||
db2.setShowData(ast.showData);
|
||||
ast.sections.map(db2.addSection);
|
||||
}, "populateDb");
|
||||
var parser = {
|
||||
parse: __name(async (input) => {
|
||||
const ast = await parse("pie", input);
|
||||
log.debug(ast);
|
||||
populateDb(ast, db);
|
||||
}, "parse")
|
||||
};
|
||||
var getStyles = __name((options) => `
|
||||
.pieCircle{
|
||||
stroke: ${options.pieStrokeColor};
|
||||
stroke-width : ${options.pieStrokeWidth};
|
||||
opacity : ${options.pieOpacity};
|
||||
}
|
||||
.pieOuterCircle{
|
||||
stroke: ${options.pieOuterStrokeColor};
|
||||
stroke-width: ${options.pieOuterStrokeWidth};
|
||||
fill: none;
|
||||
}
|
||||
.pieTitleText {
|
||||
text-anchor: middle;
|
||||
font-size: ${options.pieTitleTextSize};
|
||||
fill: ${options.pieTitleTextColor};
|
||||
font-family: ${options.fontFamily};
|
||||
}
|
||||
.slice {
|
||||
font-family: ${options.fontFamily};
|
||||
fill: ${options.pieSectionTextColor};
|
||||
font-size:${options.pieSectionTextSize};
|
||||
// fill: white;
|
||||
}
|
||||
.legend text {
|
||||
fill: ${options.pieLegendTextColor};
|
||||
font-family: ${options.fontFamily};
|
||||
font-size: ${options.pieLegendTextSize};
|
||||
}
|
||||
`, "getStyles");
|
||||
var pieStyles_default = getStyles;
|
||||
var createPieArcs = __name((sections2) => {
|
||||
const sum = [...sections2.values()].reduce((acc, val) => acc + val, 0);
|
||||
const pieData = [...sections2.entries()].map(([label, value]) => ({ label, value })).filter((d) => d.value / sum * 100 >= 1);
|
||||
const pie = pie_default().value((d) => d.value).sort(null);
|
||||
return pie(pieData);
|
||||
}, "createPieArcs");
|
||||
var draw = __name((text, id, _version, diagObj) => {
|
||||
var _a;
|
||||
log.debug("rendering pie chart\n" + text);
|
||||
const db2 = diagObj.db;
|
||||
const globalConfig = getConfig2();
|
||||
const pieConfig = cleanAndMerge(db2.getConfig(), globalConfig.pie);
|
||||
const MARGIN = 40;
|
||||
const LEGEND_RECT_SIZE = 18;
|
||||
const LEGEND_SPACING = 4;
|
||||
const height = 450;
|
||||
const pieWidth = height;
|
||||
const svg = selectSvgElement(id);
|
||||
const group = svg.append("g");
|
||||
group.attr("transform", "translate(" + pieWidth / 2 + "," + height / 2 + ")");
|
||||
const { themeVariables } = globalConfig;
|
||||
let [outerStrokeWidth] = parseFontSize(themeVariables.pieOuterStrokeWidth);
|
||||
outerStrokeWidth ?? (outerStrokeWidth = 2);
|
||||
const textPosition = pieConfig.textPosition;
|
||||
const radius = Math.min(pieWidth, height) / 2 - MARGIN;
|
||||
const arcGenerator = arc_default().innerRadius(0).outerRadius(radius);
|
||||
const labelArcGenerator = arc_default().innerRadius(radius * textPosition).outerRadius(radius * textPosition);
|
||||
group.append("circle").attr("cx", 0).attr("cy", 0).attr("r", radius + outerStrokeWidth / 2).attr("class", "pieOuterCircle");
|
||||
const sections2 = db2.getSections();
|
||||
const arcs = createPieArcs(sections2);
|
||||
const myGeneratedColors = [
|
||||
themeVariables.pie1,
|
||||
themeVariables.pie2,
|
||||
themeVariables.pie3,
|
||||
themeVariables.pie4,
|
||||
themeVariables.pie5,
|
||||
themeVariables.pie6,
|
||||
themeVariables.pie7,
|
||||
themeVariables.pie8,
|
||||
themeVariables.pie9,
|
||||
themeVariables.pie10,
|
||||
themeVariables.pie11,
|
||||
themeVariables.pie12
|
||||
];
|
||||
let sum = 0;
|
||||
sections2.forEach((section) => {
|
||||
sum += section;
|
||||
});
|
||||
const filteredArcs = arcs.filter((datum) => (datum.data.value / sum * 100).toFixed(0) !== "0");
|
||||
const color = ordinal(myGeneratedColors).domain([
|
||||
...sections2.keys()
|
||||
]);
|
||||
group.selectAll("mySlices").data(filteredArcs).enter().append("path").attr("d", arcGenerator).attr("fill", (datum) => {
|
||||
return color(datum.data.label);
|
||||
}).attr("class", "pieCircle");
|
||||
group.selectAll("mySlices").data(filteredArcs).enter().append("text").text((datum) => {
|
||||
return (datum.data.value / sum * 100).toFixed(0) + "%";
|
||||
}).attr("transform", (datum) => {
|
||||
return "translate(" + labelArcGenerator.centroid(datum) + ")";
|
||||
}).style("text-anchor", "middle").attr("class", "slice");
|
||||
const titleText = group.append("text").text(db2.getDiagramTitle()).attr("x", 0).attr("y", -(height - 50) / 2).attr("class", "pieTitleText");
|
||||
const allSectionData = [...sections2.entries()].map(([label, value]) => ({
|
||||
label,
|
||||
value
|
||||
}));
|
||||
const legend = group.selectAll(".legend").data(allSectionData).enter().append("g").attr("class", "legend").attr("transform", (_datum, index) => {
|
||||
const height2 = LEGEND_RECT_SIZE + LEGEND_SPACING;
|
||||
const offset = height2 * allSectionData.length / 2;
|
||||
const horizontal = 12 * LEGEND_RECT_SIZE;
|
||||
const vertical = index * height2 - offset;
|
||||
return "translate(" + horizontal + "," + vertical + ")";
|
||||
});
|
||||
legend.append("rect").attr("width", LEGEND_RECT_SIZE).attr("height", LEGEND_RECT_SIZE).style("fill", (d) => color(d.label)).style("stroke", (d) => color(d.label));
|
||||
legend.append("text").attr("x", LEGEND_RECT_SIZE + LEGEND_SPACING).attr("y", LEGEND_RECT_SIZE - LEGEND_SPACING).text((d) => {
|
||||
if (db2.getShowData()) {
|
||||
return `${d.label} [${d.value}]`;
|
||||
}
|
||||
return d.label;
|
||||
});
|
||||
const longestTextWidth = Math.max(
|
||||
...legend.selectAll("text").nodes().map((node) => (node == null ? void 0 : node.getBoundingClientRect().width) ?? 0)
|
||||
);
|
||||
const chartAndLegendWidth = pieWidth + MARGIN + LEGEND_RECT_SIZE + LEGEND_SPACING + longestTextWidth;
|
||||
const titleWidth = ((_a = titleText.node()) == null ? void 0 : _a.getBoundingClientRect().width) ?? 0;
|
||||
const titleLeft = pieWidth / 2 - titleWidth / 2;
|
||||
const titleRight = pieWidth / 2 + titleWidth / 2;
|
||||
const viewBoxX = Math.min(0, titleLeft);
|
||||
const viewBoxRight = Math.max(chartAndLegendWidth, titleRight);
|
||||
const totalWidth = viewBoxRight - viewBoxX;
|
||||
svg.attr("viewBox", `${viewBoxX} 0 ${totalWidth} ${height}`);
|
||||
configureSvgSize(svg, height, totalWidth, pieConfig.useMaxWidth);
|
||||
}, "draw");
|
||||
var renderer = { draw };
|
||||
var diagram = {
|
||||
parser,
|
||||
db,
|
||||
renderer,
|
||||
styles: pieStyles_default
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=pieDiagram-DEJITSTG-B2LEWLGH.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+1311
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+4663
File diff suppressed because one or more lines are too long
+7
File diff suppressed because one or more lines are too long
+495
@@ -0,0 +1,495 @@
|
||||
import {
|
||||
StateDB,
|
||||
stateDiagram_default,
|
||||
styles_default
|
||||
} from "./chunk-KQJD2BDO.js";
|
||||
import {
|
||||
layout
|
||||
} from "./chunk-6G6LCPI6.js";
|
||||
import {
|
||||
Graph
|
||||
} from "./chunk-WBQMGXEP.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import "./chunk-NLS3CDEU.js";
|
||||
import "./chunk-YVBSFUGN.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import "./chunk-GSSDQWQG.js";
|
||||
import "./chunk-LMNIJLJF.js";
|
||||
import "./chunk-POGYG5DQ.js";
|
||||
import "./chunk-N2C52BYW.js";
|
||||
import "./chunk-IHPTUWR5.js";
|
||||
import "./chunk-LN4HZV3Y.js";
|
||||
import "./chunk-TNWHCC6S.js";
|
||||
import "./chunk-HX7G7X5J.js";
|
||||
import {
|
||||
utils_default
|
||||
} from "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import {
|
||||
common_default,
|
||||
configureSvgSize,
|
||||
getConfig2,
|
||||
getUrl
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
basis_default,
|
||||
line_default,
|
||||
log,
|
||||
select_default
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-FHFEXIEX.mjs
|
||||
var drawStartState = __name((g) => g.append("circle").attr("class", "start-state").attr("r", getConfig2().state.sizeUnit).attr("cx", getConfig2().state.padding + getConfig2().state.sizeUnit).attr("cy", getConfig2().state.padding + getConfig2().state.sizeUnit), "drawStartState");
|
||||
var drawDivider = __name((g) => g.append("line").style("stroke", "grey").style("stroke-dasharray", "3").attr("x1", getConfig2().state.textHeight).attr("class", "divider").attr("x2", getConfig2().state.textHeight * 2).attr("y1", 0).attr("y2", 0), "drawDivider");
|
||||
var drawSimpleState = __name((g, stateDef) => {
|
||||
const state = g.append("text").attr("x", 2 * getConfig2().state.padding).attr("y", getConfig2().state.textHeight + 2 * getConfig2().state.padding).attr("font-size", getConfig2().state.fontSize).attr("class", "state-title").text(stateDef.id);
|
||||
const classBox = state.node().getBBox();
|
||||
g.insert("rect", ":first-child").attr("x", getConfig2().state.padding).attr("y", getConfig2().state.padding).attr("width", classBox.width + 2 * getConfig2().state.padding).attr("height", classBox.height + 2 * getConfig2().state.padding).attr("rx", getConfig2().state.radius);
|
||||
return state;
|
||||
}, "drawSimpleState");
|
||||
var drawDescrState = __name((g, stateDef) => {
|
||||
const addTspan = __name(function(textEl, txt, isFirst2) {
|
||||
const tSpan = textEl.append("tspan").attr("x", 2 * getConfig2().state.padding).text(txt);
|
||||
if (!isFirst2) {
|
||||
tSpan.attr("dy", getConfig2().state.textHeight);
|
||||
}
|
||||
}, "addTspan");
|
||||
const title = g.append("text").attr("x", 2 * getConfig2().state.padding).attr("y", getConfig2().state.textHeight + 1.3 * getConfig2().state.padding).attr("font-size", getConfig2().state.fontSize).attr("class", "state-title").text(stateDef.descriptions[0]);
|
||||
const titleBox = title.node().getBBox();
|
||||
const titleHeight = titleBox.height;
|
||||
const description = g.append("text").attr("x", getConfig2().state.padding).attr(
|
||||
"y",
|
||||
titleHeight + getConfig2().state.padding * 0.4 + getConfig2().state.dividerMargin + getConfig2().state.textHeight
|
||||
).attr("class", "state-description");
|
||||
let isFirst = true;
|
||||
let isSecond = true;
|
||||
stateDef.descriptions.forEach(function(descr) {
|
||||
if (!isFirst) {
|
||||
addTspan(description, descr, isSecond);
|
||||
isSecond = false;
|
||||
}
|
||||
isFirst = false;
|
||||
});
|
||||
const descrLine = g.append("line").attr("x1", getConfig2().state.padding).attr("y1", getConfig2().state.padding + titleHeight + getConfig2().state.dividerMargin / 2).attr("y2", getConfig2().state.padding + titleHeight + getConfig2().state.dividerMargin / 2).attr("class", "descr-divider");
|
||||
const descrBox = description.node().getBBox();
|
||||
const width = Math.max(descrBox.width, titleBox.width);
|
||||
descrLine.attr("x2", width + 3 * getConfig2().state.padding);
|
||||
g.insert("rect", ":first-child").attr("x", getConfig2().state.padding).attr("y", getConfig2().state.padding).attr("width", width + 2 * getConfig2().state.padding).attr("height", descrBox.height + titleHeight + 2 * getConfig2().state.padding).attr("rx", getConfig2().state.radius);
|
||||
return g;
|
||||
}, "drawDescrState");
|
||||
var addTitleAndBox = __name((g, stateDef, altBkg) => {
|
||||
const pad = getConfig2().state.padding;
|
||||
const dblPad = 2 * getConfig2().state.padding;
|
||||
const orgBox = g.node().getBBox();
|
||||
const orgWidth = orgBox.width;
|
||||
const orgX = orgBox.x;
|
||||
const title = g.append("text").attr("x", 0).attr("y", getConfig2().state.titleShift).attr("font-size", getConfig2().state.fontSize).attr("class", "state-title").text(stateDef.id);
|
||||
const titleBox = title.node().getBBox();
|
||||
const titleWidth = titleBox.width + dblPad;
|
||||
let width = Math.max(titleWidth, orgWidth);
|
||||
if (width === orgWidth) {
|
||||
width = width + dblPad;
|
||||
}
|
||||
let startX;
|
||||
const graphBox = g.node().getBBox();
|
||||
if (stateDef.doc) {
|
||||
}
|
||||
startX = orgX - pad;
|
||||
if (titleWidth > orgWidth) {
|
||||
startX = (orgWidth - width) / 2 + pad;
|
||||
}
|
||||
if (Math.abs(orgX - graphBox.x) < pad && titleWidth > orgWidth) {
|
||||
startX = orgX - (titleWidth - orgWidth) / 2;
|
||||
}
|
||||
const lineY = 1 - getConfig2().state.textHeight;
|
||||
g.insert("rect", ":first-child").attr("x", startX).attr("y", lineY).attr("class", altBkg ? "alt-composit" : "composit").attr("width", width).attr(
|
||||
"height",
|
||||
graphBox.height + getConfig2().state.textHeight + getConfig2().state.titleShift + 1
|
||||
).attr("rx", "0");
|
||||
title.attr("x", startX + pad);
|
||||
if (titleWidth <= orgWidth) {
|
||||
title.attr("x", orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);
|
||||
}
|
||||
g.insert("rect", ":first-child").attr("x", startX).attr(
|
||||
"y",
|
||||
getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
|
||||
).attr("width", width).attr("height", getConfig2().state.textHeight * 3).attr("rx", getConfig2().state.radius);
|
||||
g.insert("rect", ":first-child").attr("x", startX).attr(
|
||||
"y",
|
||||
getConfig2().state.titleShift - getConfig2().state.textHeight - getConfig2().state.padding
|
||||
).attr("width", width).attr("height", graphBox.height + 3 + 2 * getConfig2().state.textHeight).attr("rx", getConfig2().state.radius);
|
||||
return g;
|
||||
}, "addTitleAndBox");
|
||||
var drawEndState = __name((g) => {
|
||||
g.append("circle").attr("class", "end-state-outer").attr("r", getConfig2().state.sizeUnit + getConfig2().state.miniPadding).attr(
|
||||
"cx",
|
||||
getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
|
||||
).attr(
|
||||
"cy",
|
||||
getConfig2().state.padding + getConfig2().state.sizeUnit + getConfig2().state.miniPadding
|
||||
);
|
||||
return g.append("circle").attr("class", "end-state-inner").attr("r", getConfig2().state.sizeUnit).attr("cx", getConfig2().state.padding + getConfig2().state.sizeUnit + 2).attr("cy", getConfig2().state.padding + getConfig2().state.sizeUnit + 2);
|
||||
}, "drawEndState");
|
||||
var drawForkJoinState = __name((g, stateDef) => {
|
||||
let width = getConfig2().state.forkWidth;
|
||||
let height = getConfig2().state.forkHeight;
|
||||
if (stateDef.parentId) {
|
||||
let tmp = width;
|
||||
width = height;
|
||||
height = tmp;
|
||||
}
|
||||
return g.append("rect").style("stroke", "black").style("fill", "black").attr("width", width).attr("height", height).attr("x", getConfig2().state.padding).attr("y", getConfig2().state.padding);
|
||||
}, "drawForkJoinState");
|
||||
var _drawLongText = __name((_text, x, y, g) => {
|
||||
let textHeight = 0;
|
||||
const textElem = g.append("text");
|
||||
textElem.style("text-anchor", "start");
|
||||
textElem.attr("class", "noteText");
|
||||
let text = _text.replace(/\r\n/g, "<br/>");
|
||||
text = text.replace(/\n/g, "<br/>");
|
||||
const lines = text.split(common_default.lineBreakRegex);
|
||||
let tHeight = 1.25 * getConfig2().state.noteMargin;
|
||||
for (const line2 of lines) {
|
||||
const txt = line2.trim();
|
||||
if (txt.length > 0) {
|
||||
const span = textElem.append("tspan");
|
||||
span.text(txt);
|
||||
if (tHeight === 0) {
|
||||
const textBounds = span.node().getBBox();
|
||||
tHeight += textBounds.height;
|
||||
}
|
||||
textHeight += tHeight;
|
||||
span.attr("x", x + getConfig2().state.noteMargin);
|
||||
span.attr("y", y + textHeight + 1.25 * getConfig2().state.noteMargin);
|
||||
}
|
||||
}
|
||||
return { textWidth: textElem.node().getBBox().width, textHeight };
|
||||
}, "_drawLongText");
|
||||
var drawNote = __name((text, g) => {
|
||||
g.attr("class", "state-note");
|
||||
const note = g.append("rect").attr("x", 0).attr("y", getConfig2().state.padding);
|
||||
const rectElem = g.append("g");
|
||||
const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);
|
||||
note.attr("height", textHeight + 2 * getConfig2().state.noteMargin);
|
||||
note.attr("width", textWidth + getConfig2().state.noteMargin * 2);
|
||||
return note;
|
||||
}, "drawNote");
|
||||
var drawState = __name(function(elem, stateDef) {
|
||||
const id = stateDef.id;
|
||||
const stateInfo = {
|
||||
id,
|
||||
label: stateDef.id,
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
const g = elem.append("g").attr("id", id).attr("class", "stateGroup");
|
||||
if (stateDef.type === "start") {
|
||||
drawStartState(g);
|
||||
}
|
||||
if (stateDef.type === "end") {
|
||||
drawEndState(g);
|
||||
}
|
||||
if (stateDef.type === "fork" || stateDef.type === "join") {
|
||||
drawForkJoinState(g, stateDef);
|
||||
}
|
||||
if (stateDef.type === "note") {
|
||||
drawNote(stateDef.note.text, g);
|
||||
}
|
||||
if (stateDef.type === "divider") {
|
||||
drawDivider(g);
|
||||
}
|
||||
if (stateDef.type === "default" && stateDef.descriptions.length === 0) {
|
||||
drawSimpleState(g, stateDef);
|
||||
}
|
||||
if (stateDef.type === "default" && stateDef.descriptions.length > 0) {
|
||||
drawDescrState(g, stateDef);
|
||||
}
|
||||
const stateBox = g.node().getBBox();
|
||||
stateInfo.width = stateBox.width + 2 * getConfig2().state.padding;
|
||||
stateInfo.height = stateBox.height + 2 * getConfig2().state.padding;
|
||||
return stateInfo;
|
||||
}, "drawState");
|
||||
var edgeCount = 0;
|
||||
var drawEdge = __name(function(elem, path, relation) {
|
||||
const getRelationType = __name(function(type) {
|
||||
switch (type) {
|
||||
case StateDB.relationType.AGGREGATION:
|
||||
return "aggregation";
|
||||
case StateDB.relationType.EXTENSION:
|
||||
return "extension";
|
||||
case StateDB.relationType.COMPOSITION:
|
||||
return "composition";
|
||||
case StateDB.relationType.DEPENDENCY:
|
||||
return "dependency";
|
||||
}
|
||||
}, "getRelationType");
|
||||
path.points = path.points.filter((p) => !Number.isNaN(p.y));
|
||||
const lineData = path.points;
|
||||
const lineFunction = line_default().x(function(d) {
|
||||
return d.x;
|
||||
}).y(function(d) {
|
||||
return d.y;
|
||||
}).curve(basis_default);
|
||||
const svgPath = elem.append("path").attr("d", lineFunction(lineData)).attr("id", "edge" + edgeCount).attr("class", "transition");
|
||||
let url = "";
|
||||
if (getConfig2().state.arrowMarkerAbsolute) {
|
||||
url = getUrl(true);
|
||||
}
|
||||
svgPath.attr(
|
||||
"marker-end",
|
||||
"url(" + url + "#" + getRelationType(StateDB.relationType.DEPENDENCY) + "End)"
|
||||
);
|
||||
if (relation.title !== void 0) {
|
||||
const label = elem.append("g").attr("class", "stateLabel");
|
||||
const { x, y } = utils_default.calcLabelPosition(path.points);
|
||||
const rows = common_default.getRows(relation.title);
|
||||
let titleHeight = 0;
|
||||
const titleRows = [];
|
||||
let maxWidth = 0;
|
||||
let minX = 0;
|
||||
for (let i = 0; i <= rows.length; i++) {
|
||||
const title = label.append("text").attr("text-anchor", "middle").text(rows[i]).attr("x", x).attr("y", y + titleHeight);
|
||||
const boundsTmp = title.node().getBBox();
|
||||
maxWidth = Math.max(maxWidth, boundsTmp.width);
|
||||
minX = Math.min(minX, boundsTmp.x);
|
||||
log.info(boundsTmp.x, x, y + titleHeight);
|
||||
if (titleHeight === 0) {
|
||||
const titleBox = title.node().getBBox();
|
||||
titleHeight = titleBox.height;
|
||||
log.info("Title height", titleHeight, y);
|
||||
}
|
||||
titleRows.push(title);
|
||||
}
|
||||
let boxHeight = titleHeight * rows.length;
|
||||
if (rows.length > 1) {
|
||||
const heightAdj = (rows.length - 1) * titleHeight * 0.5;
|
||||
titleRows.forEach((title, i) => title.attr("y", y + i * titleHeight - heightAdj));
|
||||
boxHeight = titleHeight * rows.length;
|
||||
}
|
||||
const bounds = label.node().getBBox();
|
||||
label.insert("rect", ":first-child").attr("class", "box").attr("x", x - maxWidth / 2 - getConfig2().state.padding / 2).attr("y", y - boxHeight / 2 - getConfig2().state.padding / 2 - 3.5).attr("width", maxWidth + getConfig2().state.padding).attr("height", boxHeight + getConfig2().state.padding);
|
||||
log.info(bounds);
|
||||
}
|
||||
edgeCount++;
|
||||
}, "drawEdge");
|
||||
var conf;
|
||||
var transformationLog = {};
|
||||
var setConf = __name(function() {
|
||||
}, "setConf");
|
||||
var insertMarkers = __name(function(elem) {
|
||||
elem.append("defs").append("marker").attr("id", "dependencyEnd").attr("refX", 19).attr("refY", 7).attr("markerWidth", 20).attr("markerHeight", 28).attr("orient", "auto").append("path").attr("d", "M 19,7 L9,13 L14,7 L9,1 Z");
|
||||
}, "insertMarkers");
|
||||
var draw = __name(function(text, id, _version, diagObj) {
|
||||
conf = getConfig2().state;
|
||||
const securityLevel = getConfig2().securityLevel;
|
||||
let sandboxElement;
|
||||
if (securityLevel === "sandbox") {
|
||||
sandboxElement = select_default("#i" + id);
|
||||
}
|
||||
const root = securityLevel === "sandbox" ? select_default(sandboxElement.nodes()[0].contentDocument.body) : select_default("body");
|
||||
const doc = securityLevel === "sandbox" ? sandboxElement.nodes()[0].contentDocument : document;
|
||||
log.debug("Rendering diagram " + text);
|
||||
const diagram2 = root.select(`[id='${id}']`);
|
||||
insertMarkers(diagram2);
|
||||
const rootDoc = diagObj.db.getRootDoc();
|
||||
const rootG = diagram2.append("g").attr("id", id + "-root");
|
||||
renderDoc(rootDoc, rootG, void 0, false, root, doc, diagObj);
|
||||
const padding = conf.padding;
|
||||
const bounds = diagram2.node().getBBox();
|
||||
const width = bounds.width + padding * 2;
|
||||
const height = bounds.height + padding * 2;
|
||||
const svgWidth = width * 1.75;
|
||||
configureSvgSize(diagram2, height, svgWidth, conf.useMaxWidth);
|
||||
diagram2.attr(
|
||||
"viewBox",
|
||||
`${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + " " + height
|
||||
);
|
||||
}, "draw");
|
||||
var getLabelWidth = __name((text) => {
|
||||
return text ? text.length * conf.fontSizeFactor : 1;
|
||||
}, "getLabelWidth");
|
||||
var renderDoc = __name((doc, diagram2, parentId, altBkg, root, domDocument, diagObj) => {
|
||||
const graph = new Graph({
|
||||
compound: true,
|
||||
multigraph: true
|
||||
});
|
||||
let i;
|
||||
let edgeFreeDoc = true;
|
||||
for (i = 0; i < doc.length; i++) {
|
||||
if (doc[i].stmt === "relation") {
|
||||
edgeFreeDoc = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (parentId) {
|
||||
graph.setGraph({
|
||||
rankdir: "LR",
|
||||
multigraph: true,
|
||||
compound: true,
|
||||
// acyclicer: 'greedy',
|
||||
ranker: "tight-tree",
|
||||
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
|
||||
nodeSep: edgeFreeDoc ? 1 : 50,
|
||||
isMultiGraph: true
|
||||
// ranksep: 5,
|
||||
// nodesep: 1
|
||||
});
|
||||
} else {
|
||||
graph.setGraph({
|
||||
rankdir: "TB",
|
||||
multigraph: true,
|
||||
compound: true,
|
||||
// isCompound: true,
|
||||
// acyclicer: 'greedy',
|
||||
// ranker: 'longest-path'
|
||||
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
|
||||
nodeSep: edgeFreeDoc ? 1 : 50,
|
||||
ranker: "tight-tree",
|
||||
// ranker: 'network-simplex'
|
||||
isMultiGraph: true
|
||||
});
|
||||
}
|
||||
graph.setDefaultEdgeLabel(function() {
|
||||
return {};
|
||||
});
|
||||
const states = diagObj.db.getStates();
|
||||
const relations = diagObj.db.getRelations();
|
||||
const keys = Object.keys(states);
|
||||
let first = true;
|
||||
for (const key of keys) {
|
||||
const stateDef = states[key];
|
||||
if (parentId) {
|
||||
stateDef.parentId = parentId;
|
||||
}
|
||||
let node;
|
||||
if (stateDef.doc) {
|
||||
let sub = diagram2.append("g").attr("id", stateDef.id).attr("class", "stateGroup");
|
||||
node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg, root, domDocument, diagObj);
|
||||
if (first) {
|
||||
sub = addTitleAndBox(sub, stateDef, altBkg);
|
||||
let boxBounds = sub.node().getBBox();
|
||||
node.width = boxBounds.width;
|
||||
node.height = boxBounds.height + conf.padding / 2;
|
||||
transformationLog[stateDef.id] = { y: conf.compositTitleSize };
|
||||
} else {
|
||||
let boxBounds = sub.node().getBBox();
|
||||
node.width = boxBounds.width;
|
||||
node.height = boxBounds.height;
|
||||
}
|
||||
} else {
|
||||
node = drawState(diagram2, stateDef, graph);
|
||||
}
|
||||
if (stateDef.note) {
|
||||
const noteDef = {
|
||||
descriptions: [],
|
||||
id: stateDef.id + "-note",
|
||||
note: stateDef.note,
|
||||
type: "note"
|
||||
};
|
||||
const note = drawState(diagram2, noteDef, graph);
|
||||
if (stateDef.note.position === "left of") {
|
||||
graph.setNode(node.id + "-note", note);
|
||||
graph.setNode(node.id, node);
|
||||
} else {
|
||||
graph.setNode(node.id, node);
|
||||
graph.setNode(node.id + "-note", note);
|
||||
}
|
||||
graph.setParent(node.id, node.id + "-group");
|
||||
graph.setParent(node.id + "-note", node.id + "-group");
|
||||
} else {
|
||||
graph.setNode(node.id, node);
|
||||
}
|
||||
}
|
||||
log.debug("Count=", graph.nodeCount(), graph);
|
||||
let cnt = 0;
|
||||
relations.forEach(function(relation) {
|
||||
cnt++;
|
||||
log.debug("Setting edge", relation);
|
||||
graph.setEdge(
|
||||
relation.id1,
|
||||
relation.id2,
|
||||
{
|
||||
relation,
|
||||
width: getLabelWidth(relation.title),
|
||||
height: conf.labelHeight * common_default.getRows(relation.title).length,
|
||||
labelpos: "c"
|
||||
},
|
||||
"id" + cnt
|
||||
);
|
||||
});
|
||||
layout(graph);
|
||||
log.debug("Graph after layout", graph.nodes());
|
||||
const svgElem = diagram2.node();
|
||||
graph.nodes().forEach(function(v) {
|
||||
if (v !== void 0 && graph.node(v) !== void 0) {
|
||||
log.warn("Node " + v + ": " + JSON.stringify(graph.node(v)));
|
||||
root.select("#" + svgElem.id + " #" + v).attr(
|
||||
"transform",
|
||||
"translate(" + (graph.node(v).x - graph.node(v).width / 2) + "," + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + " )"
|
||||
);
|
||||
root.select("#" + svgElem.id + " #" + v).attr("data-x-shift", graph.node(v).x - graph.node(v).width / 2);
|
||||
const dividers = domDocument.querySelectorAll("#" + svgElem.id + " #" + v + " .divider");
|
||||
dividers.forEach((divider) => {
|
||||
const parent = divider.parentElement;
|
||||
let pWidth = 0;
|
||||
let pShift = 0;
|
||||
if (parent) {
|
||||
if (parent.parentElement) {
|
||||
pWidth = parent.parentElement.getBBox().width;
|
||||
}
|
||||
pShift = parseInt(parent.getAttribute("data-x-shift"), 10);
|
||||
if (Number.isNaN(pShift)) {
|
||||
pShift = 0;
|
||||
}
|
||||
}
|
||||
divider.setAttribute("x1", 0 - pShift + 8);
|
||||
divider.setAttribute("x2", pWidth - pShift - 8);
|
||||
});
|
||||
} else {
|
||||
log.debug("No Node " + v + ": " + JSON.stringify(graph.node(v)));
|
||||
}
|
||||
});
|
||||
let stateBox = svgElem.getBBox();
|
||||
graph.edges().forEach(function(e) {
|
||||
if (e !== void 0 && graph.edge(e) !== void 0) {
|
||||
log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
|
||||
drawEdge(diagram2, graph.edge(e), graph.edge(e).relation);
|
||||
}
|
||||
});
|
||||
stateBox = svgElem.getBBox();
|
||||
const stateInfo = {
|
||||
id: parentId ? parentId : "root",
|
||||
label: parentId ? parentId : "root",
|
||||
width: 0,
|
||||
height: 0
|
||||
};
|
||||
stateInfo.width = stateBox.width + 2 * conf.padding;
|
||||
stateInfo.height = stateBox.height + 2 * conf.padding;
|
||||
log.debug("Doc rendered", stateInfo, graph);
|
||||
return stateInfo;
|
||||
}, "renderDoc");
|
||||
var stateRenderer_default = {
|
||||
setConf,
|
||||
draw
|
||||
};
|
||||
var diagram = {
|
||||
parser: stateDiagram_default,
|
||||
get db() {
|
||||
return new StateDB(1);
|
||||
},
|
||||
renderer: stateRenderer_default,
|
||||
styles: styles_default,
|
||||
init: __name((cnf) => {
|
||||
if (!cnf.state) {
|
||||
cnf.state = {};
|
||||
}
|
||||
cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
}, "init")
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=stateDiagram-FHFEXIEX-7ATV6PPH.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+44
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
StateDB,
|
||||
stateDiagram_default,
|
||||
stateRenderer_v3_unified_default,
|
||||
styles_default
|
||||
} from "./chunk-KQJD2BDO.js";
|
||||
import "./chunk-NLS3CDEU.js";
|
||||
import "./chunk-YVBSFUGN.js";
|
||||
import "./chunk-GSSDQWQG.js";
|
||||
import "./chunk-LMNIJLJF.js";
|
||||
import "./chunk-POGYG5DQ.js";
|
||||
import "./chunk-N2C52BYW.js";
|
||||
import "./chunk-IHPTUWR5.js";
|
||||
import "./chunk-LN4HZV3Y.js";
|
||||
import "./chunk-TNWHCC6S.js";
|
||||
import "./chunk-HX7G7X5J.js";
|
||||
import "./chunk-GUBXVVWZ.js";
|
||||
import "./chunk-MOBZPS7F.js";
|
||||
import "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/stateDiagram-v2-QKLJ7IA2.mjs
|
||||
var diagram = {
|
||||
parser: stateDiagram_default,
|
||||
get db() {
|
||||
return new StateDB(2);
|
||||
},
|
||||
renderer: stateRenderer_v3_unified_default,
|
||||
styles: styles_default,
|
||||
init: __name((cnf) => {
|
||||
if (!cnf.state) {
|
||||
cnf.state = {};
|
||||
}
|
||||
cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
|
||||
}, "init")
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=stateDiagram-v2-QKLJ7IA2-7INTSFRA.js.map
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../mermaid/dist/chunks/mermaid.core/stateDiagram-v2-QKLJ7IA2.mjs"],
|
||||
"sourcesContent": ["import {\n StateDB,\n stateDiagram_default,\n stateRenderer_v3_unified_default,\n styles_default\n} from \"./chunk-OYMX7WX6.mjs\";\nimport \"./chunk-55IACEB6.mjs\";\nimport \"./chunk-EDXVE4YY.mjs\";\nimport \"./chunk-336JU56O.mjs\";\nimport \"./chunk-ENJZ2VHE.mjs\";\nimport \"./chunk-BSJP7CBP.mjs\";\nimport \"./chunk-5FUZZQ4R.mjs\";\nimport \"./chunk-ZZ45TVLE.mjs\";\nimport \"./chunk-X2U36JSP.mjs\";\nimport \"./chunk-U2HBQHQK.mjs\";\nimport \"./chunk-5PVQY5BW.mjs\";\nimport \"./chunk-ICPOFSXX.mjs\";\nimport {\n __name\n} from \"./chunk-AGHRB4JF.mjs\";\n\n// src/diagrams/state/stateDiagram-v2.ts\nvar diagram = {\n parser: stateDiagram_default,\n get db() {\n return new StateDB(2);\n },\n renderer: stateRenderer_v3_unified_default,\n styles: styles_default,\n init: /* @__PURE__ */ __name((cnf) => {\n if (!cnf.state) {\n cnf.state = {};\n }\n cnf.state.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;\n }, \"init\")\n};\nexport {\n diagram\n};\n"],
|
||||
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,IAAI,UAAU;AAAA,EACZ,QAAQ;AAAA,EACR,IAAI,KAAK;AACP,WAAO,IAAI,QAAQ,CAAC;AAAA,EACtB;AAAA,EACA,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,MAAsB,OAAO,CAAC,QAAQ;AACpC,QAAI,CAAC,IAAI,OAAO;AACd,UAAI,QAAQ,CAAC;AAAA,IACf;AACA,QAAI,MAAM,sBAAsB,IAAI;AAAA,EACtC,GAAG,MAAM;AACX;",
|
||||
"names": []
|
||||
}
|
||||
+1655
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2551
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+940
@@ -0,0 +1,940 @@
|
||||
import {
|
||||
populateCommonDb
|
||||
} from "./chunk-BEGFPAJS.js";
|
||||
import {
|
||||
parse
|
||||
} from "./chunk-R5NQBCLB.js";
|
||||
import "./chunk-JH6V2QOE.js";
|
||||
import "./chunk-QLH66CIT.js";
|
||||
import "./chunk-SHHXTPWA.js";
|
||||
import "./chunk-JLNTX6TF.js";
|
||||
import "./chunk-IELG6YWI.js";
|
||||
import "./chunk-ZOQ3FUUK.js";
|
||||
import "./chunk-TAVNOOKD.js";
|
||||
import "./chunk-5D6MANWW.js";
|
||||
import "./chunk-E3W5VJ2T.js";
|
||||
import "./chunk-S4AGLBPD.js";
|
||||
import "./chunk-K3ORWWMK.js";
|
||||
import {
|
||||
selectSvgElement
|
||||
} from "./chunk-QBIGODNM.js";
|
||||
import "./chunk-BQ2Z5GT2.js";
|
||||
import {
|
||||
clear,
|
||||
configureSvgSize,
|
||||
getAccDescription,
|
||||
getAccTitle,
|
||||
getConfig2,
|
||||
getDiagramTitle,
|
||||
sanitizeText,
|
||||
setAccDescription,
|
||||
setAccTitle,
|
||||
setDiagramTitle
|
||||
} from "./chunk-6YWVU24R.js";
|
||||
import "./chunk-5ZDVNSGT.js";
|
||||
import {
|
||||
__name,
|
||||
log
|
||||
} from "./chunk-XOKMXDAB.js";
|
||||
import "./chunk-DBU5TJLK.js";
|
||||
|
||||
// node_modules/mermaid/dist/chunks/mermaid.core/wardleyDiagram-NUSXRM2D.mjs
|
||||
var toPercent = __name((value, context) => {
|
||||
const normalized = value <= 1 ? value * 100 : value;
|
||||
if (normalized < 0 || normalized > 100) {
|
||||
throw new Error(
|
||||
`${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`
|
||||
);
|
||||
}
|
||||
return normalized;
|
||||
}, "toPercent");
|
||||
var toCoordinates = __name((visibility, evolution, context) => {
|
||||
return {
|
||||
x: toPercent(evolution, `${context} evolution`),
|
||||
y: toPercent(visibility, `${context} visibility`)
|
||||
};
|
||||
}, "toCoordinates");
|
||||
var getFlowFromPort = __name((port) => {
|
||||
if (!port) {
|
||||
return void 0;
|
||||
}
|
||||
if (port === "+<>") {
|
||||
return "bidirectional";
|
||||
}
|
||||
if (port === "+<") {
|
||||
return "backward";
|
||||
}
|
||||
if (port === "+>") {
|
||||
return "forward";
|
||||
}
|
||||
return void 0;
|
||||
}, "getFlowFromPort");
|
||||
var extractFlowFromArrow = __name((arrow) => {
|
||||
if (!(arrow == null ? void 0 : arrow.startsWith("+"))) {
|
||||
return {};
|
||||
}
|
||||
const labelMatch = /^\+'([^']*)'/.exec(arrow);
|
||||
const flowLabel = labelMatch == null ? void 0 : labelMatch[1];
|
||||
if (arrow.includes("<>")) {
|
||||
return { flow: "bidirectional", label: flowLabel };
|
||||
}
|
||||
if (arrow.includes("<")) {
|
||||
return { flow: "backward", label: flowLabel };
|
||||
}
|
||||
if (arrow.includes(">")) {
|
||||
return { flow: "forward", label: flowLabel };
|
||||
}
|
||||
return { label: flowLabel };
|
||||
}, "extractFlowFromArrow");
|
||||
var populateDb = __name((ast, db) => {
|
||||
populateCommonDb(ast, db);
|
||||
if (ast.size) {
|
||||
db.setSize(ast.size.width, ast.size.height);
|
||||
}
|
||||
if (ast.evolution) {
|
||||
const stages = ast.evolution.stages.map((stage) => {
|
||||
if (stage.secondName) {
|
||||
return `${stage.name.trim()} / ${stage.secondName.trim()}`;
|
||||
}
|
||||
return stage.name.trim();
|
||||
});
|
||||
const stageBoundaries = ast.evolution.stages.filter((stage) => stage.boundary !== void 0).map((stage) => stage.boundary);
|
||||
db.updateAxes({ stages, stageBoundaries });
|
||||
}
|
||||
ast.anchors.forEach((anchor) => {
|
||||
const coords = toCoordinates(anchor.visibility, anchor.evolution, `Anchor "${anchor.name}"`);
|
||||
db.addNode(anchor.name, anchor.name, coords.x, coords.y, "anchor");
|
||||
});
|
||||
ast.components.forEach((component) => {
|
||||
var _a2;
|
||||
const coords = toCoordinates(
|
||||
component.visibility,
|
||||
component.evolution,
|
||||
`Component "${component.name}"`
|
||||
);
|
||||
const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
|
||||
const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
|
||||
const sourceStrategy = (_a2 = component.decorator) == null ? void 0 : _a2.strategy;
|
||||
db.addNode(
|
||||
component.name,
|
||||
component.name,
|
||||
coords.x,
|
||||
coords.y,
|
||||
"component",
|
||||
labelOffsetX,
|
||||
labelOffsetY,
|
||||
component.inertia,
|
||||
sourceStrategy
|
||||
);
|
||||
});
|
||||
ast.notes.forEach((note) => {
|
||||
const coords = toCoordinates(note.visibility, note.evolution, `Note "${note.text}"`);
|
||||
db.addNote(note.text, coords.x, coords.y);
|
||||
});
|
||||
ast.pipelines.forEach((pipeline) => {
|
||||
const parentNode = db.getNode(pipeline.parent);
|
||||
if (!parentNode || typeof parentNode.y !== "number") {
|
||||
throw new Error(
|
||||
`Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`
|
||||
);
|
||||
}
|
||||
const parentY = parentNode.y;
|
||||
db.startPipeline(pipeline.parent);
|
||||
pipeline.components.forEach((component) => {
|
||||
const componentId = `${pipeline.parent}_${component.name}`;
|
||||
const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
|
||||
const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
|
||||
const x = toPercent(component.evolution, `Pipeline component "${component.name}" evolution`);
|
||||
db.addNode(
|
||||
componentId,
|
||||
component.name,
|
||||
x,
|
||||
parentY,
|
||||
"pipeline-component",
|
||||
labelOffsetX,
|
||||
labelOffsetY
|
||||
);
|
||||
db.addPipelineComponent(pipeline.parent, componentId);
|
||||
});
|
||||
});
|
||||
ast.links.forEach((link) => {
|
||||
const isDashed = !!link.arrow && (link.arrow.includes("-.->") || link.arrow.includes(".-."));
|
||||
let flow = getFlowFromPort(link.fromPort) ?? getFlowFromPort(link.toPort);
|
||||
const { flow: arrowFlow, label: flowLabel } = extractFlowFromArrow(link.arrow);
|
||||
if (!flow && arrowFlow) {
|
||||
flow = arrowFlow;
|
||||
}
|
||||
const annotation = link.linkLabel;
|
||||
const label = flowLabel ?? annotation;
|
||||
db.addLink(link.from, link.to, isDashed, label, flow);
|
||||
});
|
||||
ast.evolves.forEach((evolve) => {
|
||||
const node = db.getNode(evolve.component);
|
||||
if ((node == null ? void 0 : node.y) !== void 0) {
|
||||
const target = toPercent(evolve.target, `Evolve target for "${evolve.component}"`);
|
||||
db.addTrend(evolve.component, target, node.y);
|
||||
}
|
||||
});
|
||||
if (ast.annotations.length > 0) {
|
||||
const annotationsBox = ast.annotations[0];
|
||||
const coords = toCoordinates(annotationsBox.x, annotationsBox.y, "Annotations box");
|
||||
db.setAnnotationsBox(coords.x, coords.y);
|
||||
}
|
||||
ast.annotation.forEach((annotation) => {
|
||||
const coords = toCoordinates(annotation.x, annotation.y, `Annotation ${annotation.number}`);
|
||||
db.addAnnotation(annotation.number, [{ x: coords.x, y: coords.y }], annotation.text);
|
||||
});
|
||||
ast.accelerators.forEach((accelerator) => {
|
||||
const coords = toCoordinates(accelerator.x, accelerator.y, `Accelerator "${accelerator.name}"`);
|
||||
db.addAccelerator(accelerator.name, coords.x, coords.y);
|
||||
});
|
||||
ast.deaccelerators.forEach((deaccelerator) => {
|
||||
const coords = toCoordinates(
|
||||
deaccelerator.x,
|
||||
deaccelerator.y,
|
||||
`Deaccelerator "${deaccelerator.name}"`
|
||||
);
|
||||
db.addDeaccelerator(deaccelerator.name, coords.x, coords.y);
|
||||
});
|
||||
}, "populateDb");
|
||||
var parser = {
|
||||
parser: {
|
||||
// @ts-expect-error - WardleyDB is not assignable to DiagramDB
|
||||
yy: void 0
|
||||
},
|
||||
parse: __name(async (input) => {
|
||||
var _a2;
|
||||
const ast = await parse("wardley", input);
|
||||
log.debug(ast);
|
||||
const db = (_a2 = parser.parser) == null ? void 0 : _a2.yy;
|
||||
if (!db || typeof db.addNode !== "function") {
|
||||
throw new Error(
|
||||
"parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
|
||||
);
|
||||
}
|
||||
populateDb(ast, db);
|
||||
}, "parse")
|
||||
};
|
||||
var _a;
|
||||
var WardleyBuilder = (_a = class {
|
||||
constructor() {
|
||||
this.nodes = /* @__PURE__ */ new Map();
|
||||
this.links = [];
|
||||
this.trends = /* @__PURE__ */ new Map();
|
||||
this.pipelines = /* @__PURE__ */ new Map();
|
||||
this.annotations = [];
|
||||
this.notes = [];
|
||||
this.accelerators = [];
|
||||
this.deaccelerators = [];
|
||||
this.axes = {};
|
||||
}
|
||||
addNode(node) {
|
||||
const existing = this.nodes.get(node.id) ?? { id: node.id, label: node.label };
|
||||
const merged = {
|
||||
...existing,
|
||||
...node,
|
||||
className: node.className ?? existing.className,
|
||||
labelOffsetX: node.labelOffsetX ?? existing.labelOffsetX,
|
||||
labelOffsetY: node.labelOffsetY ?? existing.labelOffsetY
|
||||
};
|
||||
this.nodes.set(node.id, merged);
|
||||
}
|
||||
addLink(link) {
|
||||
this.links.push(link);
|
||||
}
|
||||
addTrend(trend) {
|
||||
this.trends.set(trend.nodeId, trend);
|
||||
}
|
||||
startPipeline(nodeId) {
|
||||
this.pipelines.set(nodeId, { nodeId, componentIds: [] });
|
||||
const node = this.nodes.get(nodeId);
|
||||
if (node) {
|
||||
node.isPipelineParent = true;
|
||||
}
|
||||
}
|
||||
addPipelineComponent(pipelineNodeId, componentId) {
|
||||
const pipeline = this.pipelines.get(pipelineNodeId);
|
||||
if (pipeline) {
|
||||
pipeline.componentIds.push(componentId);
|
||||
}
|
||||
const node = this.nodes.get(componentId);
|
||||
if (node) {
|
||||
node.inPipeline = true;
|
||||
}
|
||||
}
|
||||
addAnnotation(annotation) {
|
||||
this.annotations.push(annotation);
|
||||
}
|
||||
addNote(note) {
|
||||
this.notes.push(note);
|
||||
}
|
||||
addAccelerator(accelerator) {
|
||||
this.accelerators.push(accelerator);
|
||||
}
|
||||
addDeaccelerator(deaccelerator) {
|
||||
this.deaccelerators.push(deaccelerator);
|
||||
}
|
||||
setAnnotationsBox(x, y) {
|
||||
this.annotationsBox = { x, y };
|
||||
}
|
||||
setAxes(partial) {
|
||||
this.axes = {
|
||||
...this.axes,
|
||||
...partial
|
||||
};
|
||||
}
|
||||
setSize(width, height) {
|
||||
this.size = { width, height };
|
||||
}
|
||||
getNode(id) {
|
||||
return this.nodes.get(id);
|
||||
}
|
||||
build() {
|
||||
const nodes = [];
|
||||
for (const node of this.nodes.values()) {
|
||||
if (typeof node.x !== "number" || typeof node.y !== "number") {
|
||||
throw new Error(`Node "${node.label}" is missing coordinates`);
|
||||
}
|
||||
nodes.push(node);
|
||||
}
|
||||
return {
|
||||
nodes,
|
||||
links: [...this.links],
|
||||
trends: [...this.trends.values()],
|
||||
pipelines: [...this.pipelines.values()],
|
||||
annotations: [...this.annotations],
|
||||
notes: [...this.notes],
|
||||
accelerators: [...this.accelerators],
|
||||
deaccelerators: [...this.deaccelerators],
|
||||
annotationsBox: this.annotationsBox,
|
||||
axes: { ...this.axes },
|
||||
size: this.size
|
||||
};
|
||||
}
|
||||
clear() {
|
||||
this.nodes.clear();
|
||||
this.links = [];
|
||||
this.trends.clear();
|
||||
this.pipelines.clear();
|
||||
this.annotations = [];
|
||||
this.notes = [];
|
||||
this.accelerators = [];
|
||||
this.deaccelerators = [];
|
||||
this.annotationsBox = void 0;
|
||||
this.axes = {};
|
||||
this.size = void 0;
|
||||
}
|
||||
}, __name(_a, "WardleyBuilder"), _a);
|
||||
var builder = new WardleyBuilder();
|
||||
function textSanitizer(text) {
|
||||
const config = getConfig2();
|
||||
return sanitizeText(text.trim(), config);
|
||||
}
|
||||
__name(textSanitizer, "textSanitizer");
|
||||
function getConfig22() {
|
||||
return getConfig2()["wardley-beta"];
|
||||
}
|
||||
__name(getConfig22, "getConfig");
|
||||
function addNode(id, label, x, y, className, labelOffsetX, labelOffsetY, inertia, sourceStrategy) {
|
||||
builder.addNode({
|
||||
id,
|
||||
label: textSanitizer(label),
|
||||
x,
|
||||
y,
|
||||
className,
|
||||
labelOffsetX,
|
||||
labelOffsetY,
|
||||
inertia,
|
||||
sourceStrategy
|
||||
});
|
||||
}
|
||||
__name(addNode, "addNode");
|
||||
function addLink(sourceId, targetId, dashed = false, label, flow) {
|
||||
builder.addLink({ source: sourceId, target: targetId, dashed, label, flow });
|
||||
}
|
||||
__name(addLink, "addLink");
|
||||
function addTrend(nodeId, targetX, targetY) {
|
||||
builder.addTrend({ nodeId, targetX, targetY });
|
||||
}
|
||||
__name(addTrend, "addTrend");
|
||||
function addAnnotation(number, coordinates, text) {
|
||||
builder.addAnnotation({
|
||||
number,
|
||||
coordinates,
|
||||
text: text ? textSanitizer(text) : void 0
|
||||
});
|
||||
}
|
||||
__name(addAnnotation, "addAnnotation");
|
||||
function addNote(text, x, y) {
|
||||
builder.addNote({
|
||||
text: textSanitizer(text),
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
__name(addNote, "addNote");
|
||||
function addAccelerator(name, x, y) {
|
||||
builder.addAccelerator({
|
||||
name: textSanitizer(name),
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
__name(addAccelerator, "addAccelerator");
|
||||
function addDeaccelerator(name, x, y) {
|
||||
builder.addDeaccelerator({
|
||||
name: textSanitizer(name),
|
||||
x,
|
||||
y
|
||||
});
|
||||
}
|
||||
__name(addDeaccelerator, "addDeaccelerator");
|
||||
function setAnnotationsBox(x, y) {
|
||||
builder.setAnnotationsBox(x, y);
|
||||
}
|
||||
__name(setAnnotationsBox, "setAnnotationsBox");
|
||||
function setSize(width, height) {
|
||||
builder.setSize(width, height);
|
||||
}
|
||||
__name(setSize, "setSize");
|
||||
function startPipeline(nodeId) {
|
||||
builder.startPipeline(nodeId);
|
||||
}
|
||||
__name(startPipeline, "startPipeline");
|
||||
function addPipelineComponent(pipelineNodeId, componentId) {
|
||||
builder.addPipelineComponent(pipelineNodeId, componentId);
|
||||
}
|
||||
__name(addPipelineComponent, "addPipelineComponent");
|
||||
function updateAxes(partial) {
|
||||
const sanitized = {};
|
||||
if (partial.xLabel) {
|
||||
sanitized.xLabel = textSanitizer(partial.xLabel);
|
||||
}
|
||||
if (partial.yLabel) {
|
||||
sanitized.yLabel = textSanitizer(partial.yLabel);
|
||||
}
|
||||
if (partial.stages) {
|
||||
sanitized.stages = partial.stages.map((stage) => textSanitizer(stage));
|
||||
}
|
||||
if (partial.stageBoundaries) {
|
||||
sanitized.stageBoundaries = partial.stageBoundaries;
|
||||
}
|
||||
builder.setAxes(sanitized);
|
||||
}
|
||||
__name(updateAxes, "updateAxes");
|
||||
function getNode(id) {
|
||||
return builder.getNode(id);
|
||||
}
|
||||
__name(getNode, "getNode");
|
||||
function getWardleyData() {
|
||||
return builder.build();
|
||||
}
|
||||
__name(getWardleyData, "getWardleyData");
|
||||
function clear2() {
|
||||
builder.clear();
|
||||
clear();
|
||||
}
|
||||
__name(clear2, "clear");
|
||||
var wardleyDb_default = {
|
||||
getConfig: getConfig22,
|
||||
addNode,
|
||||
addLink,
|
||||
addTrend,
|
||||
addAnnotation,
|
||||
addNote,
|
||||
addAccelerator,
|
||||
addDeaccelerator,
|
||||
setAnnotationsBox,
|
||||
setSize,
|
||||
startPipeline,
|
||||
addPipelineComponent,
|
||||
updateAxes,
|
||||
getNode,
|
||||
getWardleyData,
|
||||
clear: clear2,
|
||||
setAccTitle,
|
||||
getAccTitle,
|
||||
setDiagramTitle,
|
||||
getDiagramTitle,
|
||||
getAccDescription,
|
||||
setAccDescription
|
||||
};
|
||||
var DEFAULT_STAGES = ["Genesis", "Custom Built", "Product", "Commodity"];
|
||||
var getTheme = __name(() => {
|
||||
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
||||
const { themeVariables } = getConfig2();
|
||||
return {
|
||||
backgroundColor: ((_a2 = themeVariables.wardley) == null ? void 0 : _a2.backgroundColor) ?? themeVariables.background ?? "#fff",
|
||||
axisColor: ((_b = themeVariables.wardley) == null ? void 0 : _b.axisColor) ?? "#000",
|
||||
axisTextColor: ((_c = themeVariables.wardley) == null ? void 0 : _c.axisTextColor) ?? themeVariables.primaryTextColor ?? "#222",
|
||||
gridColor: ((_d = themeVariables.wardley) == null ? void 0 : _d.gridColor) ?? "rgba(100, 100, 100, 0.2)",
|
||||
componentFill: ((_e = themeVariables.wardley) == null ? void 0 : _e.componentFill) ?? "#fff",
|
||||
componentStroke: ((_f = themeVariables.wardley) == null ? void 0 : _f.componentStroke) ?? "#000",
|
||||
componentLabelColor: ((_g = themeVariables.wardley) == null ? void 0 : _g.componentLabelColor) ?? themeVariables.primaryTextColor ?? "#222",
|
||||
linkStroke: ((_h = themeVariables.wardley) == null ? void 0 : _h.linkStroke) ?? "#000",
|
||||
evolutionStroke: ((_i = themeVariables.wardley) == null ? void 0 : _i.evolutionStroke) ?? "#dc3545",
|
||||
annotationStroke: ((_j = themeVariables.wardley) == null ? void 0 : _j.annotationStroke) ?? "#000",
|
||||
annotationTextColor: ((_k = themeVariables.wardley) == null ? void 0 : _k.annotationTextColor) ?? themeVariables.primaryTextColor ?? "#222",
|
||||
annotationFill: ((_l = themeVariables.wardley) == null ? void 0 : _l.annotationFill) ?? themeVariables.background ?? "#fff"
|
||||
};
|
||||
}, "getTheme");
|
||||
var getConfigValues = __name(() => {
|
||||
const wardleyConfig = getConfig2()["wardley-beta"];
|
||||
return {
|
||||
width: (wardleyConfig == null ? void 0 : wardleyConfig.width) ?? 900,
|
||||
height: (wardleyConfig == null ? void 0 : wardleyConfig.height) ?? 600,
|
||||
padding: (wardleyConfig == null ? void 0 : wardleyConfig.padding) ?? 48,
|
||||
nodeRadius: (wardleyConfig == null ? void 0 : wardleyConfig.nodeRadius) ?? 6,
|
||||
nodeLabelOffset: (wardleyConfig == null ? void 0 : wardleyConfig.nodeLabelOffset) ?? 8,
|
||||
axisFontSize: (wardleyConfig == null ? void 0 : wardleyConfig.axisFontSize) ?? 12,
|
||||
labelFontSize: (wardleyConfig == null ? void 0 : wardleyConfig.labelFontSize) ?? 10,
|
||||
showGrid: (wardleyConfig == null ? void 0 : wardleyConfig.showGrid) ?? false,
|
||||
useMaxWidth: (wardleyConfig == null ? void 0 : wardleyConfig.useMaxWidth) ?? true
|
||||
};
|
||||
}, "getConfigValues");
|
||||
var draw = __name((text, id, _version, diagObj) => {
|
||||
var _a2, _b;
|
||||
log.debug("Rendering Wardley map\n" + text);
|
||||
const configValues = getConfigValues();
|
||||
const theme = getTheme();
|
||||
const squareSize = configValues.nodeRadius * 1.6;
|
||||
const db = diagObj.db;
|
||||
const data = db.getWardleyData();
|
||||
const title = db.getDiagramTitle();
|
||||
const width = ((_a2 = data.size) == null ? void 0 : _a2.width) ?? configValues.width;
|
||||
const height = ((_b = data.size) == null ? void 0 : _b.height) ?? configValues.height;
|
||||
const svg = selectSvgElement(id);
|
||||
svg.selectAll("*").remove();
|
||||
configureSvgSize(svg, height, width, configValues.useMaxWidth);
|
||||
svg.attr("viewBox", `0 0 ${width} ${height}`);
|
||||
const root = svg.append("g").attr("class", "wardley-map");
|
||||
const defs = svg.append("defs");
|
||||
defs.append("marker").attr("id", `arrow-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto-start-reverse").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.evolutionStroke).attr("stroke", "none");
|
||||
defs.append("marker").attr("id", `link-arrow-end-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
|
||||
defs.append("marker").attr("id", `link-arrow-start-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 1).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
|
||||
root.append("rect").attr("class", "wardley-background").attr("width", width).attr("height", height).attr("fill", theme.backgroundColor);
|
||||
const chartWidth = width - configValues.padding * 2;
|
||||
const chartHeight = height - configValues.padding * 2;
|
||||
if (title) {
|
||||
root.append("text").attr("class", "wardley-title").attr("x", width / 2).attr("y", configValues.padding / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize * 1.05).attr("font-weight", "bold").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
|
||||
}
|
||||
const projectX = __name((value) => configValues.padding + value / 100 * chartWidth, "projectX");
|
||||
const projectY = __name((value) => height - configValues.padding - value / 100 * chartHeight, "projectY");
|
||||
const axisGroup = root.append("g").attr("class", "wardley-axes");
|
||||
axisGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
|
||||
axisGroup.append("line").attr("x1", configValues.padding).attr("x2", configValues.padding).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
|
||||
const xLabel = data.axes.xLabel ?? "Evolution";
|
||||
const yLabel = data.axes.yLabel ?? "Visibility";
|
||||
axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-x").attr("x", configValues.padding + chartWidth / 2).attr("y", height - configValues.padding / 4).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").text(xLabel);
|
||||
axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-y").attr("x", configValues.padding / 3).attr("y", configValues.padding + chartHeight / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").attr(
|
||||
"transform",
|
||||
`rotate(-90 ${configValues.padding / 3} ${configValues.padding + chartHeight / 2})`
|
||||
).text(yLabel);
|
||||
const stages = data.axes.stages && data.axes.stages.length > 0 ? data.axes.stages : DEFAULT_STAGES;
|
||||
if (stages.length > 0) {
|
||||
const stageGroup = root.append("g").attr("class", "wardley-stages");
|
||||
const boundaries = data.axes.stageBoundaries;
|
||||
const stagePositions = [];
|
||||
if (boundaries && boundaries.length === stages.length) {
|
||||
let prevBoundary = 0;
|
||||
boundaries.forEach((boundary) => {
|
||||
stagePositions.push({ start: prevBoundary, end: boundary });
|
||||
prevBoundary = boundary;
|
||||
});
|
||||
} else {
|
||||
const stageWidth = 1 / stages.length;
|
||||
stages.forEach((_, index) => {
|
||||
stagePositions.push({
|
||||
start: index * stageWidth,
|
||||
end: (index + 1) * stageWidth
|
||||
});
|
||||
});
|
||||
}
|
||||
stages.forEach((stage, index) => {
|
||||
const pos = stagePositions[index];
|
||||
const startX = configValues.padding + pos.start * chartWidth;
|
||||
const endX = configValues.padding + pos.end * chartWidth;
|
||||
const centerX = (startX + endX) / 2;
|
||||
if (index > 0) {
|
||||
stageGroup.append("line").attr("x1", startX).attr("x2", startX).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", "#000").attr("stroke-width", 1).attr("stroke-dasharray", "5 5").attr("opacity", 0.8);
|
||||
}
|
||||
stageGroup.append("text").attr("class", "wardley-stage-label").attr("x", centerX).attr("y", height - configValues.padding / 1.5).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize - 2).attr("text-anchor", "middle").text(stage);
|
||||
});
|
||||
}
|
||||
if (configValues.showGrid) {
|
||||
const gridGroup = root.append("g").attr("class", "wardley-grid");
|
||||
for (let i = 1; i < 4; i++) {
|
||||
const ratio = i / 4;
|
||||
const x = configValues.padding + chartWidth * ratio;
|
||||
gridGroup.append("line").attr("x1", x).attr("x2", x).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
|
||||
gridGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding - chartHeight * ratio).attr("y2", height - configValues.padding - chartHeight * ratio).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
|
||||
}
|
||||
}
|
||||
const positions = /* @__PURE__ */ new Map();
|
||||
data.nodes.forEach((node) => {
|
||||
positions.set(node.id, {
|
||||
x: projectX(node.x),
|
||||
y: projectY(node.y),
|
||||
node
|
||||
});
|
||||
});
|
||||
if (data.pipelines.length > 0) {
|
||||
const pipelineGroup = root.append("g").attr("class", "wardley-pipelines");
|
||||
const pipelineLinksGroup = root.append("g").attr("class", "wardley-pipeline-links");
|
||||
data.pipelines.forEach((pipeline) => {
|
||||
if (pipeline.componentIds.length === 0) {
|
||||
return;
|
||||
}
|
||||
const sortedComponents = pipeline.componentIds.map((id2) => ({ id: id2, pos: positions.get(id2), node: data.nodes.find((n) => n.id === id2) })).filter((c) => c.pos && c.node).sort((a, b) => a.node.x - b.node.x);
|
||||
for (let i = 0; i < sortedComponents.length - 1; i++) {
|
||||
const current = sortedComponents[i];
|
||||
const next = sortedComponents[i + 1];
|
||||
pipelineLinksGroup.append("line").attr("class", "wardley-pipeline-evolution-link").attr("x1", current.pos.x).attr("y1", current.pos.y).attr("x2", next.pos.x).attr("y2", next.pos.y).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4");
|
||||
}
|
||||
let minX = Infinity;
|
||||
let maxX = -Infinity;
|
||||
let y = 0;
|
||||
pipeline.componentIds.forEach((componentId) => {
|
||||
const pos = positions.get(componentId);
|
||||
if (pos) {
|
||||
minX = Math.min(minX, pos.x);
|
||||
maxX = Math.max(maxX, pos.x);
|
||||
y = pos.y;
|
||||
}
|
||||
});
|
||||
if (minX !== Infinity && maxX !== -Infinity) {
|
||||
const padding = 15;
|
||||
const height2 = configValues.nodeRadius * 4;
|
||||
const boxTop = y - height2 / 2;
|
||||
const parentPos = positions.get(pipeline.nodeId);
|
||||
if (parentPos) {
|
||||
const centerX = (minX + maxX) / 2;
|
||||
parentPos.x = centerX;
|
||||
parentPos.y = boxTop - squareSize / 6;
|
||||
}
|
||||
pipelineGroup.append("rect").attr("class", "wardley-pipeline-box").attr("x", minX - padding).attr("y", boxTop).attr("width", maxX - minX + padding * 2).attr("height", height2).attr("fill", "none").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
|
||||
}
|
||||
});
|
||||
}
|
||||
const linksGroup = root.append("g").attr("class", "wardley-links");
|
||||
const pipelineMap = /* @__PURE__ */ new Map();
|
||||
data.pipelines.forEach((pipeline) => {
|
||||
pipelineMap.set(pipeline.nodeId, new Set(pipeline.componentIds));
|
||||
});
|
||||
const validLinks = data.links.filter((link) => {
|
||||
if (!positions.has(link.source) || !positions.has(link.target)) {
|
||||
return false;
|
||||
}
|
||||
const pipelineComponents = pipelineMap.get(link.target);
|
||||
if (pipelineComponents == null ? void 0 : pipelineComponents.has(link.source)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class", (link) => `wardley-link${link.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const sourceNode = data.nodes.find((n) => n.id === link.source);
|
||||
const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
|
||||
const dx = targetPos.x - sourcePos.x;
|
||||
const dy = targetPos.y - sourcePos.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
return sourcePos.x + dx / distance * radius;
|
||||
}).attr("y1", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const sourceNode = data.nodes.find((n) => n.id === link.source);
|
||||
const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
|
||||
const dx = targetPos.x - sourcePos.x;
|
||||
const dy = targetPos.y - sourcePos.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
return sourcePos.y + dy / distance * radius;
|
||||
}).attr("x2", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const targetNode = data.nodes.find((n) => n.id === link.target);
|
||||
const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
|
||||
const dx = sourcePos.x - targetPos.x;
|
||||
const dy = sourcePos.y - targetPos.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
return targetPos.x + dx / distance * radius;
|
||||
}).attr("y2", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const targetNode = data.nodes.find((n) => n.id === link.target);
|
||||
const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
|
||||
const dx = sourcePos.x - targetPos.x;
|
||||
const dy = sourcePos.y - targetPos.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
return targetPos.y + dy / distance * radius;
|
||||
}).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (link) => link.dashed ? "6 6" : null).attr("marker-end", (link) => {
|
||||
if (link.flow === "forward" || link.flow === "bidirectional") {
|
||||
return `url(#link-arrow-end-${id})`;
|
||||
}
|
||||
return null;
|
||||
}).attr("marker-start", (link) => {
|
||||
if (link.flow === "backward" || link.flow === "bidirectional") {
|
||||
return `url(#link-arrow-start-${id})`;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
linksGroup.selectAll("text").data(validLinks.filter((link) => link.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const midX = (sourcePos.x + targetPos.x) / 2;
|
||||
const dy = targetPos.y - sourcePos.y;
|
||||
const dx = targetPos.x - sourcePos.x;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
const offset = 8;
|
||||
const perpX = dy / distance;
|
||||
return midX + perpX * offset;
|
||||
}).attr("y", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const midY = (sourcePos.y + targetPos.y) / 2;
|
||||
const dx = targetPos.x - sourcePos.x;
|
||||
const dy = targetPos.y - sourcePos.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
const offset = 8;
|
||||
const perpY = -dx / distance;
|
||||
return midY + perpY * offset;
|
||||
}).attr("fill", theme.axisTextColor).attr("font-size", configValues.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (link) => {
|
||||
const sourcePos = positions.get(link.source);
|
||||
const targetPos = positions.get(link.target);
|
||||
const midX = (sourcePos.x + targetPos.x) / 2;
|
||||
const midY = (sourcePos.y + targetPos.y) / 2;
|
||||
const dx = targetPos.x - sourcePos.x;
|
||||
const dy = targetPos.y - sourcePos.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
const offset = 8;
|
||||
const perpX = dy / distance;
|
||||
const perpY = -dx / distance;
|
||||
const labelX = midX + perpX * offset;
|
||||
const labelY = midY + perpY * offset;
|
||||
let angle = Math.atan2(dy, dx) * 180 / Math.PI;
|
||||
if (angle > 90 || angle < -90) {
|
||||
angle += 180;
|
||||
}
|
||||
return `rotate(${angle} ${labelX} ${labelY})`;
|
||||
}).text((link) => link.label);
|
||||
const trendGroup = root.append("g").attr("class", "wardley-trends");
|
||||
const trendsWithPositions = data.trends.map((trend) => {
|
||||
const origin = positions.get(trend.nodeId);
|
||||
if (!origin) {
|
||||
return null;
|
||||
}
|
||||
const targetX = projectX(trend.targetX);
|
||||
const targetY = projectY(trend.targetY);
|
||||
const dx = targetX - origin.x;
|
||||
const dy = targetY - origin.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
const shortenBy = configValues.nodeRadius + 2;
|
||||
const adjustedX2 = distance > shortenBy ? targetX - dx / distance * shortenBy : targetX;
|
||||
const adjustedY2 = distance > shortenBy ? targetY - dy / distance * shortenBy : targetY;
|
||||
return {
|
||||
origin,
|
||||
targetX,
|
||||
targetY,
|
||||
adjustedX2,
|
||||
adjustedY2
|
||||
};
|
||||
}).filter((trend) => trend !== null);
|
||||
trendGroup.selectAll("line").data(trendsWithPositions).enter().append("line").attr("class", "wardley-trend").attr("x1", (trend) => trend.origin.x).attr("y1", (trend) => trend.origin.y).attr("x2", (trend) => trend.adjustedX2).attr("y2", (trend) => trend.adjustedY2).attr("stroke", theme.evolutionStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4").attr("marker-end", `url(#arrow-${id})`);
|
||||
const nodesGroup = root.append("g").attr("class", "wardley-nodes");
|
||||
const nodeEnter = nodesGroup.selectAll("g").data(data.nodes).enter().append("g").attr(
|
||||
"class",
|
||||
(node) => ["wardley-node", node.className ? `wardley-node--${node.className}` : ""].filter(Boolean).join(" ")
|
||||
);
|
||||
nodeEnter.filter((node) => node.sourceStrategy === "outsource").append("circle").attr("class", "wardley-outsource-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#666").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
nodeEnter.filter((node) => node.sourceStrategy === "buy").append("circle").attr("class", "wardley-buy-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#ccc").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
nodeEnter.filter((node) => node.sourceStrategy === "build").append("circle").attr("class", "wardley-build-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#eee").attr("stroke", "#000").attr("stroke-width", 1);
|
||||
const marketNodes = nodeEnter.filter((node) => node.sourceStrategy === "market");
|
||||
marketNodes.append("circle").attr("class", "wardley-market-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
nodeEnter.filter(
|
||||
(node) => !node.isPipelineParent && node.sourceStrategy !== "market" && node.className !== "anchor"
|
||||
).append("circle").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
const smallCircleRadius = configValues.nodeRadius * 0.7;
|
||||
const triangleRadius = configValues.nodeRadius * 1.2;
|
||||
marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x).attr("y1", (node) => positions.get(node.id).y - triangleRadius).attr("x2", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x).attr("y2", (node) => positions.get(node.id).y - triangleRadius).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y - triangleRadius).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
|
||||
marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
|
||||
marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
|
||||
nodeEnter.filter((node) => node.isPipelineParent === true).append("rect").attr("x", (node) => positions.get(node.id).x - squareSize / 2).attr("y", (node) => positions.get(node.id).y - squareSize / 2).attr("width", squareSize).attr("height", squareSize).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
nodeEnter.filter((node) => node.inertia === true).append("line").attr("class", "wardley-inertia").attr("x1", (node) => {
|
||||
const pos = positions.get(node.id);
|
||||
let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
|
||||
if (node.sourceStrategy) {
|
||||
offset += configValues.nodeRadius + 10;
|
||||
}
|
||||
return pos.x + offset;
|
||||
}).attr("y1", (node) => {
|
||||
const pos = positions.get(node.id);
|
||||
const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
|
||||
return pos.y - lineHeight / 2;
|
||||
}).attr("x2", (node) => {
|
||||
const pos = positions.get(node.id);
|
||||
let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
|
||||
if (node.sourceStrategy) {
|
||||
offset += configValues.nodeRadius + 10;
|
||||
}
|
||||
return pos.x + offset;
|
||||
}).attr("y2", (node) => {
|
||||
const pos = positions.get(node.id);
|
||||
const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
|
||||
return pos.y + lineHeight / 2;
|
||||
}).attr("stroke", theme.componentStroke).attr("stroke-width", 6);
|
||||
nodeEnter.append("text").attr("x", (node) => {
|
||||
const pos = positions.get(node.id);
|
||||
if (node.className === "anchor") {
|
||||
return node.labelOffsetX !== void 0 ? pos.x + node.labelOffsetX : pos.x;
|
||||
}
|
||||
let defaultOffset = configValues.nodeLabelOffset;
|
||||
if (node.sourceStrategy && node.labelOffsetX === void 0) {
|
||||
defaultOffset += 10;
|
||||
}
|
||||
const customOffset = node.labelOffsetX ?? defaultOffset;
|
||||
return pos.x + customOffset;
|
||||
}).attr("y", (node) => {
|
||||
const pos = positions.get(node.id);
|
||||
if (node.className === "anchor") {
|
||||
return node.labelOffsetY !== void 0 ? pos.y + node.labelOffsetY : pos.y - 3;
|
||||
}
|
||||
let defaultOffset = -configValues.nodeLabelOffset;
|
||||
if (node.sourceStrategy && node.labelOffsetY === void 0) {
|
||||
defaultOffset -= 10;
|
||||
}
|
||||
const customOffset = node.labelOffsetY ?? defaultOffset;
|
||||
return pos.y + customOffset;
|
||||
}).attr("class", "wardley-node-label").attr("fill", (node) => {
|
||||
if (node.className === "evolved") {
|
||||
return theme.evolutionStroke;
|
||||
}
|
||||
if (node.className === "anchor") {
|
||||
return "#000";
|
||||
}
|
||||
return theme.componentLabelColor;
|
||||
}).attr("font-size", configValues.labelFontSize).attr("font-weight", (node) => node.className === "anchor" ? "bold" : "normal").attr("text-anchor", (node) => node.className === "anchor" ? "middle" : "start").attr("dominant-baseline", (node) => node.className === "anchor" ? "middle" : "auto").text((node) => node.label);
|
||||
if (data.annotations.length > 0) {
|
||||
const annotationsGroup = root.append("g").attr("class", "wardley-annotations");
|
||||
data.annotations.forEach((annotation) => {
|
||||
const projectedCoords = annotation.coordinates.map((coord) => ({
|
||||
x: projectX(coord.x),
|
||||
y: projectY(coord.y)
|
||||
}));
|
||||
if (projectedCoords.length > 1) {
|
||||
for (let i = 0; i < projectedCoords.length - 1; i++) {
|
||||
annotationsGroup.append("line").attr("class", "wardley-annotation-line").attr("x1", projectedCoords[i].x).attr("y1", projectedCoords[i].y).attr("x2", projectedCoords[i + 1].x).attr("y2", projectedCoords[i + 1].y).attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("stroke-dasharray", "4 4");
|
||||
}
|
||||
}
|
||||
projectedCoords.forEach((coord) => {
|
||||
const annotationNode = annotationsGroup.append("g").attr("class", "wardley-annotation");
|
||||
annotationNode.append("circle").attr("cx", coord.x).attr("cy", coord.y).attr("r", 10).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5);
|
||||
annotationNode.append("text").attr("x", coord.x).attr("y", coord.y).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(annotation.number);
|
||||
});
|
||||
});
|
||||
if (data.annotationsBox) {
|
||||
let boxX = projectX(data.annotationsBox.x);
|
||||
let boxY = projectY(data.annotationsBox.y);
|
||||
const padding = 10;
|
||||
const lineHeight = 16;
|
||||
const fontSize = 11;
|
||||
const textBoxGroup = annotationsGroup.append("g").attr("class", "wardley-annotations-box");
|
||||
const sortedAnnotations = [...data.annotations].filter((a) => a.text).sort((a, b) => a.number - b.number);
|
||||
const textElements = [];
|
||||
sortedAnnotations.forEach((annotation, idx) => {
|
||||
const text2 = textBoxGroup.append("text").attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight).attr("font-size", fontSize).attr("fill", theme.axisTextColor).attr("text-anchor", "start").attr("dominant-baseline", "middle").text(`${annotation.number}. ${annotation.text}`);
|
||||
textElements.push(text2);
|
||||
});
|
||||
if (textElements.length > 0) {
|
||||
let maxWidth = 0;
|
||||
let maxHeight = 0;
|
||||
textElements.forEach((text2) => {
|
||||
const textNode = text2.node();
|
||||
const textWidth = textNode.getComputedTextLength();
|
||||
maxWidth = Math.max(maxWidth, textWidth);
|
||||
const bbox = textNode.getBBox();
|
||||
maxHeight = Math.max(maxHeight, bbox.height);
|
||||
});
|
||||
const boxWidth = maxWidth + padding * 2 + 105;
|
||||
const boxHeight = sortedAnnotations.length * lineHeight + padding * 2 + maxHeight / 2;
|
||||
const minX = configValues.padding;
|
||||
const maxX = width - configValues.padding - boxWidth;
|
||||
const minY = configValues.padding;
|
||||
const maxY = height - configValues.padding - boxHeight;
|
||||
boxX = Math.max(minX, Math.min(boxX, maxX));
|
||||
boxY = Math.max(minY, Math.min(boxY, maxY));
|
||||
textElements.forEach((text2, idx) => {
|
||||
text2.attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight);
|
||||
});
|
||||
textBoxGroup.insert("rect", "text").attr("x", boxX).attr("y", boxY).attr("width", boxWidth).attr("height", boxHeight).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.notes.length > 0) {
|
||||
const notesGroup = root.append("g").attr("class", "wardley-notes");
|
||||
data.notes.forEach((note) => {
|
||||
const noteX = projectX(note.x);
|
||||
const noteY = projectY(note.y);
|
||||
notesGroup.append("text").attr("x", noteX).attr("y", noteY).attr("text-anchor", "start").attr("font-size", 11).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(note.text);
|
||||
});
|
||||
}
|
||||
if (data.accelerators.length > 0) {
|
||||
const acceleratorsGroup = root.append("g").attr("class", "wardley-accelerators");
|
||||
data.accelerators.forEach((accelerator) => {
|
||||
const accX = projectX(accelerator.x);
|
||||
const accY = projectY(accelerator.y);
|
||||
const arrowWidth = 60;
|
||||
const arrowHeight = 30;
|
||||
const arrowHeadWidth = 20;
|
||||
const arrowPath = `
|
||||
M ${accX} ${accY - arrowHeight / 2}
|
||||
L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2}
|
||||
L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2 - 8}
|
||||
L ${accX + arrowWidth} ${accY}
|
||||
L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2 + 8}
|
||||
L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2}
|
||||
L ${accX} ${accY + arrowHeight / 2}
|
||||
Z
|
||||
`;
|
||||
acceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
acceleratorsGroup.append("text").attr("x", accX + arrowWidth / 2).attr("y", accY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(accelerator.name);
|
||||
});
|
||||
}
|
||||
if (data.deaccelerators.length > 0) {
|
||||
const deacceleratorsGroup = root.append("g").attr("class", "wardley-deaccelerators");
|
||||
data.deaccelerators.forEach((deaccelerator) => {
|
||||
const decX = projectX(deaccelerator.x);
|
||||
const decY = projectY(deaccelerator.y);
|
||||
const arrowWidth = 60;
|
||||
const arrowHeight = 30;
|
||||
const arrowHeadWidth = 20;
|
||||
const arrowPath = `
|
||||
M ${decX + arrowWidth} ${decY - arrowHeight / 2}
|
||||
L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2}
|
||||
L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2 - 8}
|
||||
L ${decX} ${decY}
|
||||
L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2 + 8}
|
||||
L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2}
|
||||
L ${decX + arrowWidth} ${decY + arrowHeight / 2}
|
||||
Z
|
||||
`;
|
||||
deacceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
|
||||
deacceleratorsGroup.append("text").attr("x", decX + arrowWidth / 2).attr("y", decY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(deaccelerator.name);
|
||||
});
|
||||
}
|
||||
}, "draw");
|
||||
var wardleyRenderer_default = {
|
||||
draw
|
||||
};
|
||||
var diagram = {
|
||||
parser,
|
||||
db: wardleyDb_default,
|
||||
renderer: wardleyRenderer_default,
|
||||
styles: __name(() => "", "styles")
|
||||
};
|
||||
export {
|
||||
diagram
|
||||
};
|
||||
//# sourceMappingURL=wardleyDiagram-NUSXRM2D-FB3VHWKT.js.map
|
||||
+7
File diff suppressed because one or more lines are too long
+1932
File diff suppressed because it is too large
Load Diff
+7
File diff suppressed because one or more lines are too long
+2844
File diff suppressed because it is too large
Load Diff
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Sasha Koss and Lesha Koss https://kossnocorp.mit-license.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
🔥️ **NEW**: [date-fns v4.0 with first-class time zone support is out!](https://blog.date-fns.org/v40-with-time-zone-support/)
|
||||
|
||||
<img alt="date-fns" title="date-fns" src="https://raw.githubusercontent.com/date-fns/date-fns/master/docs/logotype.svg" width="150" />
|
||||
|
||||
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js
|
||||
|
||||
👉 [Documentation](https://date-fns.org/)
|
||||
|
||||
👉 [Blog](https://blog.date-fns.org/)
|
||||
|
||||
<hr>
|
||||
|
||||
It's like [Lodash](https://lodash.com) for dates
|
||||
|
||||
- It has [**200+ functions** for all occasions](https://date-fns.org/docs/Getting-Started/).
|
||||
- **Modular**: Pick what you need. Works with webpack, Browserify, or Rollup and also supports tree-shaking.
|
||||
- **Native dates**: Uses existing native type. It doesn't extend core objects for safety's sake.
|
||||
- **Immutable & Pure**: Built using pure functions and always returns a new date instance.
|
||||
- **TypeScript**: The library is 100% TypeScript with brand-new handcrafted types.
|
||||
- **I18n**: Dozens of locales. Include only what you need.
|
||||
- [and many more benefits](https://date-fns.org/)
|
||||
|
||||
```js
|
||||
import { compareAsc, format } from "date-fns";
|
||||
|
||||
format(new Date(2014, 1, 11), "yyyy-MM-dd");
|
||||
//=> '2014-02-11'
|
||||
|
||||
const dates = [
|
||||
new Date(1995, 6, 2),
|
||||
new Date(1987, 1, 11),
|
||||
new Date(1989, 6, 10),
|
||||
];
|
||||
dates.sort(compareAsc);
|
||||
//=> [
|
||||
// Wed Feb 11 1987 00:00:00,
|
||||
// Mon Jul 10 1989 00:00:00,
|
||||
// Sun Jul 02 1995 00:00:00
|
||||
// ]
|
||||
```
|
||||
|
||||
The library is available as an [npm package](https://www.npmjs.com/package/date-fns).
|
||||
To install the package run:
|
||||
|
||||
```bash
|
||||
npm install date-fns --save
|
||||
```
|
||||
|
||||
## Docs
|
||||
|
||||
[See date-fns.org](https://date-fns.org/) for more details, API,
|
||||
and other docs.
|
||||
|
||||
<br />
|
||||
|
||||
## License
|
||||
|
||||
[MIT © Sasha Koss](https://kossnocorp.mit-license.org/)
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Security updates are applied only to the latest release.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.**
|
||||
This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released.
|
||||
Please disclose it to [Sasha Koss](mailto:koss@nocorp.me). This project is maintained by a team of volunteers
|
||||
on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure.
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
exports.addLeadingZeros = addLeadingZeros;
|
||||
function addLeadingZeros(number, targetLength) {
|
||||
const sign = number < 0 ? "-" : "";
|
||||
const output = Math.abs(number).toString().padStart(targetLength, "0");
|
||||
return sign + output;
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export declare function addLeadingZeros(
|
||||
number: number,
|
||||
targetLength: number,
|
||||
): string;
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export declare function addLeadingZeros(
|
||||
number: number,
|
||||
targetLength: number,
|
||||
): string;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export function addLeadingZeros(number, targetLength) {
|
||||
const sign = number < 0 ? "-" : "";
|
||||
const output = Math.abs(number).toString().padStart(targetLength, "0");
|
||||
return sign + output;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "defaultLocale", {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return _index.enUS;
|
||||
},
|
||||
});
|
||||
var _index = require("../locale/en-US.cjs");
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { enUS as defaultLocale } from "../locale/en-US.js";
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { enUS as defaultLocale } from "../locale/en-US.js";
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { enUS as defaultLocale } from "../locale/en-US.js";
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
exports.getDefaultOptions = getDefaultOptions;
|
||||
exports.setDefaultOptions = setDefaultOptions;
|
||||
|
||||
let defaultOptions = {};
|
||||
|
||||
function getDefaultOptions() {
|
||||
return defaultOptions;
|
||||
}
|
||||
|
||||
function setDefaultOptions(newOptions) {
|
||||
defaultOptions = newOptions;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import type {
|
||||
FirstWeekContainsDateOptions,
|
||||
Locale,
|
||||
LocalizedOptions,
|
||||
WeekOptions,
|
||||
} from "../types.js";
|
||||
export type DefaultOptions = LocalizedOptions<keyof Locale> &
|
||||
WeekOptions &
|
||||
FirstWeekContainsDateOptions;
|
||||
export declare function getDefaultOptions(): DefaultOptions;
|
||||
export declare function setDefaultOptions(newOptions: DefaultOptions): void;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import type {
|
||||
FirstWeekContainsDateOptions,
|
||||
Locale,
|
||||
LocalizedOptions,
|
||||
WeekOptions,
|
||||
} from "../types.js";
|
||||
export type DefaultOptions = LocalizedOptions<keyof Locale> &
|
||||
WeekOptions &
|
||||
FirstWeekContainsDateOptions;
|
||||
export declare function getDefaultOptions(): DefaultOptions;
|
||||
export declare function setDefaultOptions(newOptions: DefaultOptions): void;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
let defaultOptions = {};
|
||||
|
||||
export function getDefaultOptions() {
|
||||
return defaultOptions;
|
||||
}
|
||||
|
||||
export function setDefaultOptions(newOptions) {
|
||||
defaultOptions = newOptions;
|
||||
}
|
||||
+780
@@ -0,0 +1,780 @@
|
||||
"use strict";
|
||||
exports.formatters = void 0;
|
||||
var _index = require("../../getDayOfYear.cjs");
|
||||
var _index2 = require("../../getISOWeek.cjs");
|
||||
var _index3 = require("../../getISOWeekYear.cjs");
|
||||
var _index4 = require("../../getWeek.cjs");
|
||||
var _index5 = require("../../getWeekYear.cjs");
|
||||
|
||||
var _index6 = require("../addLeadingZeros.cjs");
|
||||
var _index7 = require("./lightFormatters.cjs");
|
||||
|
||||
const dayPeriodEnum = {
|
||||
am: "am",
|
||||
pm: "pm",
|
||||
midnight: "midnight",
|
||||
noon: "noon",
|
||||
morning: "morning",
|
||||
afternoon: "afternoon",
|
||||
evening: "evening",
|
||||
night: "night",
|
||||
};
|
||||
|
||||
/*
|
||||
* | | Unit | | Unit |
|
||||
* |-----|--------------------------------|-----|--------------------------------|
|
||||
* | a | AM, PM | A* | Milliseconds in day |
|
||||
* | b | AM, PM, noon, midnight | B | Flexible day period |
|
||||
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
|
||||
* | d | Day of month | D | Day of year |
|
||||
* | e | Local day of week | E | Day of week |
|
||||
* | f | | F* | Day of week in month |
|
||||
* | g* | Modified Julian day | G | Era |
|
||||
* | h | Hour [1-12] | H | Hour [0-23] |
|
||||
* | i! | ISO day of week | I! | ISO week of year |
|
||||
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
|
||||
* | k | Hour [1-24] | K | Hour [0-11] |
|
||||
* | l* | (deprecated) | L | Stand-alone month |
|
||||
* | m | Minute | M | Month |
|
||||
* | n | | N | |
|
||||
* | o! | Ordinal number modifier | O | Timezone (GMT) |
|
||||
* | p! | Long localized time | P! | Long localized date |
|
||||
* | q | Stand-alone quarter | Q | Quarter |
|
||||
* | r* | Related Gregorian year | R! | ISO week-numbering year |
|
||||
* | s | Second | S | Fraction of second |
|
||||
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
|
||||
* | u | Extended year | U* | Cyclic year |
|
||||
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
|
||||
* | w | Local week of year | W* | Week of month |
|
||||
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
|
||||
* | y | Year (abs) | Y | Local week-numbering year |
|
||||
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
|
||||
*
|
||||
* Letters marked by * are not implemented but reserved by Unicode standard.
|
||||
*
|
||||
* Letters marked by ! are non-standard, but implemented by date-fns:
|
||||
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
|
||||
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
|
||||
* i.e. 7 for Sunday, 1 for Monday, etc.
|
||||
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
|
||||
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
|
||||
* `R` is supposed to be used in conjunction with `I` and `i`
|
||||
* for universal ISO week-numbering date, whereas
|
||||
* `Y` is supposed to be used in conjunction with `w` and `e`
|
||||
* for week-numbering date specific to the locale.
|
||||
* - `P` is long localized date format
|
||||
* - `p` is long localized time format
|
||||
*/
|
||||
|
||||
const formatters = (exports.formatters = {
|
||||
// Era
|
||||
G: function (date, token, localize) {
|
||||
const era = date.getFullYear() > 0 ? 1 : 0;
|
||||
switch (token) {
|
||||
// AD, BC
|
||||
case "G":
|
||||
case "GG":
|
||||
case "GGG":
|
||||
return localize.era(era, { width: "abbreviated" });
|
||||
// A, B
|
||||
case "GGGGG":
|
||||
return localize.era(era, { width: "narrow" });
|
||||
// Anno Domini, Before Christ
|
||||
case "GGGG":
|
||||
default:
|
||||
return localize.era(era, { width: "wide" });
|
||||
}
|
||||
},
|
||||
|
||||
// Year
|
||||
y: function (date, token, localize) {
|
||||
// Ordinal number
|
||||
if (token === "yo") {
|
||||
const signedYear = date.getFullYear();
|
||||
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
||||
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
||||
return localize.ordinalNumber(year, { unit: "year" });
|
||||
}
|
||||
|
||||
return _index7.lightFormatters.y(date, token);
|
||||
},
|
||||
|
||||
// Local week-numbering year
|
||||
Y: function (date, token, localize, options) {
|
||||
const signedWeekYear = (0, _index5.getWeekYear)(date, options);
|
||||
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
||||
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
|
||||
|
||||
// Two digit year
|
||||
if (token === "YY") {
|
||||
const twoDigitYear = weekYear % 100;
|
||||
return (0, _index6.addLeadingZeros)(twoDigitYear, 2);
|
||||
}
|
||||
|
||||
// Ordinal number
|
||||
if (token === "Yo") {
|
||||
return localize.ordinalNumber(weekYear, { unit: "year" });
|
||||
}
|
||||
|
||||
// Padding
|
||||
return (0, _index6.addLeadingZeros)(weekYear, token.length);
|
||||
},
|
||||
|
||||
// ISO week-numbering year
|
||||
R: function (date, token) {
|
||||
const isoWeekYear = (0, _index3.getISOWeekYear)(date);
|
||||
|
||||
// Padding
|
||||
return (0, _index6.addLeadingZeros)(isoWeekYear, token.length);
|
||||
},
|
||||
|
||||
// Extended year. This is a single number designating the year of this calendar system.
|
||||
// The main difference between `y` and `u` localizers are B.C. years:
|
||||
// | Year | `y` | `u` |
|
||||
// |------|-----|-----|
|
||||
// | AC 1 | 1 | 1 |
|
||||
// | BC 1 | 1 | 0 |
|
||||
// | BC 2 | 2 | -1 |
|
||||
// Also `yy` always returns the last two digits of a year,
|
||||
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
|
||||
u: function (date, token) {
|
||||
const year = date.getFullYear();
|
||||
return (0, _index6.addLeadingZeros)(year, token.length);
|
||||
},
|
||||
|
||||
// Quarter
|
||||
Q: function (date, token, localize) {
|
||||
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
||||
switch (token) {
|
||||
// 1, 2, 3, 4
|
||||
case "Q":
|
||||
return String(quarter);
|
||||
// 01, 02, 03, 04
|
||||
case "QQ":
|
||||
return (0, _index6.addLeadingZeros)(quarter, 2);
|
||||
// 1st, 2nd, 3rd, 4th
|
||||
case "Qo":
|
||||
return localize.ordinalNumber(quarter, { unit: "quarter" });
|
||||
// Q1, Q2, Q3, Q4
|
||||
case "QQQ":
|
||||
return localize.quarter(quarter, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
||||
case "QQQQQ":
|
||||
return localize.quarter(quarter, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// 1st quarter, 2nd quarter, ...
|
||||
case "QQQQ":
|
||||
default:
|
||||
return localize.quarter(quarter, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Stand-alone quarter
|
||||
q: function (date, token, localize) {
|
||||
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
||||
switch (token) {
|
||||
// 1, 2, 3, 4
|
||||
case "q":
|
||||
return String(quarter);
|
||||
// 01, 02, 03, 04
|
||||
case "qq":
|
||||
return (0, _index6.addLeadingZeros)(quarter, 2);
|
||||
// 1st, 2nd, 3rd, 4th
|
||||
case "qo":
|
||||
return localize.ordinalNumber(quarter, { unit: "quarter" });
|
||||
// Q1, Q2, Q3, Q4
|
||||
case "qqq":
|
||||
return localize.quarter(quarter, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
});
|
||||
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
||||
case "qqqqq":
|
||||
return localize.quarter(quarter, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// 1st quarter, 2nd quarter, ...
|
||||
case "qqqq":
|
||||
default:
|
||||
return localize.quarter(quarter, {
|
||||
width: "wide",
|
||||
context: "standalone",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Month
|
||||
M: function (date, token, localize) {
|
||||
const month = date.getMonth();
|
||||
switch (token) {
|
||||
case "M":
|
||||
case "MM":
|
||||
return _index7.lightFormatters.M(date, token);
|
||||
// 1st, 2nd, ..., 12th
|
||||
case "Mo":
|
||||
return localize.ordinalNumber(month + 1, { unit: "month" });
|
||||
// Jan, Feb, ..., Dec
|
||||
case "MMM":
|
||||
return localize.month(month, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// J, F, ..., D
|
||||
case "MMMMM":
|
||||
return localize.month(month, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// January, February, ..., December
|
||||
case "MMMM":
|
||||
default:
|
||||
return localize.month(month, { width: "wide", context: "formatting" });
|
||||
}
|
||||
},
|
||||
|
||||
// Stand-alone month
|
||||
L: function (date, token, localize) {
|
||||
const month = date.getMonth();
|
||||
switch (token) {
|
||||
// 1, 2, ..., 12
|
||||
case "L":
|
||||
return String(month + 1);
|
||||
// 01, 02, ..., 12
|
||||
case "LL":
|
||||
return (0, _index6.addLeadingZeros)(month + 1, 2);
|
||||
// 1st, 2nd, ..., 12th
|
||||
case "Lo":
|
||||
return localize.ordinalNumber(month + 1, { unit: "month" });
|
||||
// Jan, Feb, ..., Dec
|
||||
case "LLL":
|
||||
return localize.month(month, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
});
|
||||
// J, F, ..., D
|
||||
case "LLLLL":
|
||||
return localize.month(month, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// January, February, ..., December
|
||||
case "LLLL":
|
||||
default:
|
||||
return localize.month(month, { width: "wide", context: "standalone" });
|
||||
}
|
||||
},
|
||||
|
||||
// Local week of year
|
||||
w: function (date, token, localize, options) {
|
||||
const week = (0, _index4.getWeek)(date, options);
|
||||
|
||||
if (token === "wo") {
|
||||
return localize.ordinalNumber(week, { unit: "week" });
|
||||
}
|
||||
|
||||
return (0, _index6.addLeadingZeros)(week, token.length);
|
||||
},
|
||||
|
||||
// ISO week of year
|
||||
I: function (date, token, localize) {
|
||||
const isoWeek = (0, _index2.getISOWeek)(date);
|
||||
|
||||
if (token === "Io") {
|
||||
return localize.ordinalNumber(isoWeek, { unit: "week" });
|
||||
}
|
||||
|
||||
return (0, _index6.addLeadingZeros)(isoWeek, token.length);
|
||||
},
|
||||
|
||||
// Day of the month
|
||||
d: function (date, token, localize) {
|
||||
if (token === "do") {
|
||||
return localize.ordinalNumber(date.getDate(), { unit: "date" });
|
||||
}
|
||||
|
||||
return _index7.lightFormatters.d(date, token);
|
||||
},
|
||||
|
||||
// Day of year
|
||||
D: function (date, token, localize) {
|
||||
const dayOfYear = (0, _index.getDayOfYear)(date);
|
||||
|
||||
if (token === "Do") {
|
||||
return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
|
||||
}
|
||||
|
||||
return (0, _index6.addLeadingZeros)(dayOfYear, token.length);
|
||||
},
|
||||
|
||||
// Day of week
|
||||
E: function (date, token, localize) {
|
||||
const dayOfWeek = date.getDay();
|
||||
switch (token) {
|
||||
// Tue
|
||||
case "E":
|
||||
case "EE":
|
||||
case "EEE":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// T
|
||||
case "EEEEE":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tu
|
||||
case "EEEEEE":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tuesday
|
||||
case "EEEE":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Local day of week
|
||||
e: function (date, token, localize, options) {
|
||||
const dayOfWeek = date.getDay();
|
||||
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
||||
switch (token) {
|
||||
// Numerical value (Nth day of week with current locale or weekStartsOn)
|
||||
case "e":
|
||||
return String(localDayOfWeek);
|
||||
// Padded numerical value
|
||||
case "ee":
|
||||
return (0, _index6.addLeadingZeros)(localDayOfWeek, 2);
|
||||
// 1st, 2nd, ..., 7th
|
||||
case "eo":
|
||||
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
|
||||
case "eee":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// T
|
||||
case "eeeee":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tu
|
||||
case "eeeeee":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tuesday
|
||||
case "eeee":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Stand-alone local day of week
|
||||
c: function (date, token, localize, options) {
|
||||
const dayOfWeek = date.getDay();
|
||||
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
||||
switch (token) {
|
||||
// Numerical value (same as in `e`)
|
||||
case "c":
|
||||
return String(localDayOfWeek);
|
||||
// Padded numerical value
|
||||
case "cc":
|
||||
return (0, _index6.addLeadingZeros)(localDayOfWeek, token.length);
|
||||
// 1st, 2nd, ..., 7th
|
||||
case "co":
|
||||
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
|
||||
case "ccc":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
});
|
||||
// T
|
||||
case "ccccc":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// Tu
|
||||
case "cccccc":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "standalone",
|
||||
});
|
||||
// Tuesday
|
||||
case "cccc":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "standalone",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// ISO day of week
|
||||
i: function (date, token, localize) {
|
||||
const dayOfWeek = date.getDay();
|
||||
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
|
||||
switch (token) {
|
||||
// 2
|
||||
case "i":
|
||||
return String(isoDayOfWeek);
|
||||
// 02
|
||||
case "ii":
|
||||
return (0, _index6.addLeadingZeros)(isoDayOfWeek, token.length);
|
||||
// 2nd
|
||||
case "io":
|
||||
return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
|
||||
// Tue
|
||||
case "iii":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// T
|
||||
case "iiiii":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tu
|
||||
case "iiiiii":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tuesday
|
||||
case "iiii":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// AM or PM
|
||||
a: function (date, token, localize) {
|
||||
const hours = date.getHours();
|
||||
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
||||
|
||||
switch (token) {
|
||||
case "a":
|
||||
case "aa":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
case "aaa":
|
||||
return localize
|
||||
.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
})
|
||||
.toLowerCase();
|
||||
case "aaaaa":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
case "aaaa":
|
||||
default:
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// AM, PM, midnight, noon
|
||||
b: function (date, token, localize) {
|
||||
const hours = date.getHours();
|
||||
let dayPeriodEnumValue;
|
||||
if (hours === 12) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.noon;
|
||||
} else if (hours === 0) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.midnight;
|
||||
} else {
|
||||
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
case "b":
|
||||
case "bb":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
case "bbb":
|
||||
return localize
|
||||
.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
})
|
||||
.toLowerCase();
|
||||
case "bbbbb":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
case "bbbb":
|
||||
default:
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// in the morning, in the afternoon, in the evening, at night
|
||||
B: function (date, token, localize) {
|
||||
const hours = date.getHours();
|
||||
let dayPeriodEnumValue;
|
||||
if (hours >= 17) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.evening;
|
||||
} else if (hours >= 12) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.afternoon;
|
||||
} else if (hours >= 4) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.morning;
|
||||
} else {
|
||||
dayPeriodEnumValue = dayPeriodEnum.night;
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
case "B":
|
||||
case "BB":
|
||||
case "BBB":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
case "BBBBB":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
case "BBBB":
|
||||
default:
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Hour [1-12]
|
||||
h: function (date, token, localize) {
|
||||
if (token === "ho") {
|
||||
let hours = date.getHours() % 12;
|
||||
if (hours === 0) hours = 12;
|
||||
return localize.ordinalNumber(hours, { unit: "hour" });
|
||||
}
|
||||
|
||||
return _index7.lightFormatters.h(date, token);
|
||||
},
|
||||
|
||||
// Hour [0-23]
|
||||
H: function (date, token, localize) {
|
||||
if (token === "Ho") {
|
||||
return localize.ordinalNumber(date.getHours(), { unit: "hour" });
|
||||
}
|
||||
|
||||
return _index7.lightFormatters.H(date, token);
|
||||
},
|
||||
|
||||
// Hour [0-11]
|
||||
K: function (date, token, localize) {
|
||||
const hours = date.getHours() % 12;
|
||||
|
||||
if (token === "Ko") {
|
||||
return localize.ordinalNumber(hours, { unit: "hour" });
|
||||
}
|
||||
|
||||
return (0, _index6.addLeadingZeros)(hours, token.length);
|
||||
},
|
||||
|
||||
// Hour [1-24]
|
||||
k: function (date, token, localize) {
|
||||
let hours = date.getHours();
|
||||
if (hours === 0) hours = 24;
|
||||
|
||||
if (token === "ko") {
|
||||
return localize.ordinalNumber(hours, { unit: "hour" });
|
||||
}
|
||||
|
||||
return (0, _index6.addLeadingZeros)(hours, token.length);
|
||||
},
|
||||
|
||||
// Minute
|
||||
m: function (date, token, localize) {
|
||||
if (token === "mo") {
|
||||
return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
|
||||
}
|
||||
|
||||
return _index7.lightFormatters.m(date, token);
|
||||
},
|
||||
|
||||
// Second
|
||||
s: function (date, token, localize) {
|
||||
if (token === "so") {
|
||||
return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
|
||||
}
|
||||
|
||||
return _index7.lightFormatters.s(date, token);
|
||||
},
|
||||
|
||||
// Fraction of second
|
||||
S: function (date, token) {
|
||||
return _index7.lightFormatters.S(date, token);
|
||||
},
|
||||
|
||||
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
|
||||
X: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
if (timezoneOffset === 0) {
|
||||
return "Z";
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
// Hours and optional minutes
|
||||
case "X":
|
||||
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds without `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `XX`
|
||||
case "XXXX":
|
||||
case "XX": // Hours and minutes without `:` delimiter
|
||||
return formatTimezone(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds with `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `XXX`
|
||||
case "XXXXX":
|
||||
case "XXX": // Hours and minutes with `:` delimiter
|
||||
default:
|
||||
return formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
|
||||
x: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
switch (token) {
|
||||
// Hours and optional minutes
|
||||
case "x":
|
||||
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds without `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `xx`
|
||||
case "xxxx":
|
||||
case "xx": // Hours and minutes without `:` delimiter
|
||||
return formatTimezone(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds with `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `xxx`
|
||||
case "xxxxx":
|
||||
case "xxx": // Hours and minutes with `:` delimiter
|
||||
default:
|
||||
return formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Timezone (GMT)
|
||||
O: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
switch (token) {
|
||||
// Short
|
||||
case "O":
|
||||
case "OO":
|
||||
case "OOO":
|
||||
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
||||
// Long
|
||||
case "OOOO":
|
||||
default:
|
||||
return "GMT" + formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Timezone (specific non-location)
|
||||
z: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
switch (token) {
|
||||
// Short
|
||||
case "z":
|
||||
case "zz":
|
||||
case "zzz":
|
||||
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
||||
// Long
|
||||
case "zzzz":
|
||||
default:
|
||||
return "GMT" + formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Seconds timestamp
|
||||
t: function (date, token, _localize) {
|
||||
const timestamp = Math.trunc(+date / 1000);
|
||||
return (0, _index6.addLeadingZeros)(timestamp, token.length);
|
||||
},
|
||||
|
||||
// Milliseconds timestamp
|
||||
T: function (date, token, _localize) {
|
||||
return (0, _index6.addLeadingZeros)(+date, token.length);
|
||||
},
|
||||
});
|
||||
|
||||
function formatTimezoneShort(offset, delimiter = "") {
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
const absOffset = Math.abs(offset);
|
||||
const hours = Math.trunc(absOffset / 60);
|
||||
const minutes = absOffset % 60;
|
||||
if (minutes === 0) {
|
||||
return sign + String(hours);
|
||||
}
|
||||
return (
|
||||
sign + String(hours) + delimiter + (0, _index6.addLeadingZeros)(minutes, 2)
|
||||
);
|
||||
}
|
||||
|
||||
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
|
||||
if (offset % 60 === 0) {
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
return sign + (0, _index6.addLeadingZeros)(Math.abs(offset) / 60, 2);
|
||||
}
|
||||
return formatTimezone(offset, delimiter);
|
||||
}
|
||||
|
||||
function formatTimezone(offset, delimiter = "") {
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
const absOffset = Math.abs(offset);
|
||||
const hours = (0, _index6.addLeadingZeros)(Math.trunc(absOffset / 60), 2);
|
||||
const minutes = (0, _index6.addLeadingZeros)(absOffset % 60, 2);
|
||||
return sign + hours + delimiter + minutes;
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { Localize } from "../../locale/types.js";
|
||||
import type {
|
||||
FirstWeekContainsDateOptions,
|
||||
LocalizedOptions,
|
||||
WeekOptions,
|
||||
} from "../../types.js";
|
||||
type Formatter = (
|
||||
date: Date,
|
||||
token: string,
|
||||
localize: Localize,
|
||||
options: Required<
|
||||
LocalizedOptions<"options"> & WeekOptions & FirstWeekContainsDateOptions
|
||||
>,
|
||||
) => string;
|
||||
export declare const formatters: {
|
||||
[token: string]: Formatter;
|
||||
};
|
||||
export {};
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { Localize } from "../../locale/types.js";
|
||||
import type {
|
||||
FirstWeekContainsDateOptions,
|
||||
LocalizedOptions,
|
||||
WeekOptions,
|
||||
} from "../../types.js";
|
||||
type Formatter = (
|
||||
date: Date,
|
||||
token: string,
|
||||
localize: Localize,
|
||||
options: Required<
|
||||
LocalizedOptions<"options"> & WeekOptions & FirstWeekContainsDateOptions
|
||||
>,
|
||||
) => string;
|
||||
export declare const formatters: {
|
||||
[token: string]: Formatter;
|
||||
};
|
||||
export {};
|
||||
+776
@@ -0,0 +1,776 @@
|
||||
import { getDayOfYear } from "../../getDayOfYear.js";
|
||||
import { getISOWeek } from "../../getISOWeek.js";
|
||||
import { getISOWeekYear } from "../../getISOWeekYear.js";
|
||||
import { getWeek } from "../../getWeek.js";
|
||||
import { getWeekYear } from "../../getWeekYear.js";
|
||||
|
||||
import { addLeadingZeros } from "../addLeadingZeros.js";
|
||||
import { lightFormatters } from "./lightFormatters.js";
|
||||
|
||||
const dayPeriodEnum = {
|
||||
am: "am",
|
||||
pm: "pm",
|
||||
midnight: "midnight",
|
||||
noon: "noon",
|
||||
morning: "morning",
|
||||
afternoon: "afternoon",
|
||||
evening: "evening",
|
||||
night: "night",
|
||||
};
|
||||
|
||||
/*
|
||||
* | | Unit | | Unit |
|
||||
* |-----|--------------------------------|-----|--------------------------------|
|
||||
* | a | AM, PM | A* | Milliseconds in day |
|
||||
* | b | AM, PM, noon, midnight | B | Flexible day period |
|
||||
* | c | Stand-alone local day of week | C* | Localized hour w/ day period |
|
||||
* | d | Day of month | D | Day of year |
|
||||
* | e | Local day of week | E | Day of week |
|
||||
* | f | | F* | Day of week in month |
|
||||
* | g* | Modified Julian day | G | Era |
|
||||
* | h | Hour [1-12] | H | Hour [0-23] |
|
||||
* | i! | ISO day of week | I! | ISO week of year |
|
||||
* | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
|
||||
* | k | Hour [1-24] | K | Hour [0-11] |
|
||||
* | l* | (deprecated) | L | Stand-alone month |
|
||||
* | m | Minute | M | Month |
|
||||
* | n | | N | |
|
||||
* | o! | Ordinal number modifier | O | Timezone (GMT) |
|
||||
* | p! | Long localized time | P! | Long localized date |
|
||||
* | q | Stand-alone quarter | Q | Quarter |
|
||||
* | r* | Related Gregorian year | R! | ISO week-numbering year |
|
||||
* | s | Second | S | Fraction of second |
|
||||
* | t! | Seconds timestamp | T! | Milliseconds timestamp |
|
||||
* | u | Extended year | U* | Cyclic year |
|
||||
* | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
|
||||
* | w | Local week of year | W* | Week of month |
|
||||
* | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
|
||||
* | y | Year (abs) | Y | Local week-numbering year |
|
||||
* | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
|
||||
*
|
||||
* Letters marked by * are not implemented but reserved by Unicode standard.
|
||||
*
|
||||
* Letters marked by ! are non-standard, but implemented by date-fns:
|
||||
* - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
|
||||
* - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
|
||||
* i.e. 7 for Sunday, 1 for Monday, etc.
|
||||
* - `I` is ISO week of year, as opposed to `w` which is local week of year.
|
||||
* - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
|
||||
* `R` is supposed to be used in conjunction with `I` and `i`
|
||||
* for universal ISO week-numbering date, whereas
|
||||
* `Y` is supposed to be used in conjunction with `w` and `e`
|
||||
* for week-numbering date specific to the locale.
|
||||
* - `P` is long localized date format
|
||||
* - `p` is long localized time format
|
||||
*/
|
||||
|
||||
export const formatters = {
|
||||
// Era
|
||||
G: function (date, token, localize) {
|
||||
const era = date.getFullYear() > 0 ? 1 : 0;
|
||||
switch (token) {
|
||||
// AD, BC
|
||||
case "G":
|
||||
case "GG":
|
||||
case "GGG":
|
||||
return localize.era(era, { width: "abbreviated" });
|
||||
// A, B
|
||||
case "GGGGG":
|
||||
return localize.era(era, { width: "narrow" });
|
||||
// Anno Domini, Before Christ
|
||||
case "GGGG":
|
||||
default:
|
||||
return localize.era(era, { width: "wide" });
|
||||
}
|
||||
},
|
||||
|
||||
// Year
|
||||
y: function (date, token, localize) {
|
||||
// Ordinal number
|
||||
if (token === "yo") {
|
||||
const signedYear = date.getFullYear();
|
||||
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
||||
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
||||
return localize.ordinalNumber(year, { unit: "year" });
|
||||
}
|
||||
|
||||
return lightFormatters.y(date, token);
|
||||
},
|
||||
|
||||
// Local week-numbering year
|
||||
Y: function (date, token, localize, options) {
|
||||
const signedWeekYear = getWeekYear(date, options);
|
||||
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
||||
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
|
||||
|
||||
// Two digit year
|
||||
if (token === "YY") {
|
||||
const twoDigitYear = weekYear % 100;
|
||||
return addLeadingZeros(twoDigitYear, 2);
|
||||
}
|
||||
|
||||
// Ordinal number
|
||||
if (token === "Yo") {
|
||||
return localize.ordinalNumber(weekYear, { unit: "year" });
|
||||
}
|
||||
|
||||
// Padding
|
||||
return addLeadingZeros(weekYear, token.length);
|
||||
},
|
||||
|
||||
// ISO week-numbering year
|
||||
R: function (date, token) {
|
||||
const isoWeekYear = getISOWeekYear(date);
|
||||
|
||||
// Padding
|
||||
return addLeadingZeros(isoWeekYear, token.length);
|
||||
},
|
||||
|
||||
// Extended year. This is a single number designating the year of this calendar system.
|
||||
// The main difference between `y` and `u` localizers are B.C. years:
|
||||
// | Year | `y` | `u` |
|
||||
// |------|-----|-----|
|
||||
// | AC 1 | 1 | 1 |
|
||||
// | BC 1 | 1 | 0 |
|
||||
// | BC 2 | 2 | -1 |
|
||||
// Also `yy` always returns the last two digits of a year,
|
||||
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
|
||||
u: function (date, token) {
|
||||
const year = date.getFullYear();
|
||||
return addLeadingZeros(year, token.length);
|
||||
},
|
||||
|
||||
// Quarter
|
||||
Q: function (date, token, localize) {
|
||||
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
||||
switch (token) {
|
||||
// 1, 2, 3, 4
|
||||
case "Q":
|
||||
return String(quarter);
|
||||
// 01, 02, 03, 04
|
||||
case "QQ":
|
||||
return addLeadingZeros(quarter, 2);
|
||||
// 1st, 2nd, 3rd, 4th
|
||||
case "Qo":
|
||||
return localize.ordinalNumber(quarter, { unit: "quarter" });
|
||||
// Q1, Q2, Q3, Q4
|
||||
case "QQQ":
|
||||
return localize.quarter(quarter, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
||||
case "QQQQQ":
|
||||
return localize.quarter(quarter, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// 1st quarter, 2nd quarter, ...
|
||||
case "QQQQ":
|
||||
default:
|
||||
return localize.quarter(quarter, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Stand-alone quarter
|
||||
q: function (date, token, localize) {
|
||||
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
||||
switch (token) {
|
||||
// 1, 2, 3, 4
|
||||
case "q":
|
||||
return String(quarter);
|
||||
// 01, 02, 03, 04
|
||||
case "qq":
|
||||
return addLeadingZeros(quarter, 2);
|
||||
// 1st, 2nd, 3rd, 4th
|
||||
case "qo":
|
||||
return localize.ordinalNumber(quarter, { unit: "quarter" });
|
||||
// Q1, Q2, Q3, Q4
|
||||
case "qqq":
|
||||
return localize.quarter(quarter, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
});
|
||||
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
||||
case "qqqqq":
|
||||
return localize.quarter(quarter, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// 1st quarter, 2nd quarter, ...
|
||||
case "qqqq":
|
||||
default:
|
||||
return localize.quarter(quarter, {
|
||||
width: "wide",
|
||||
context: "standalone",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Month
|
||||
M: function (date, token, localize) {
|
||||
const month = date.getMonth();
|
||||
switch (token) {
|
||||
case "M":
|
||||
case "MM":
|
||||
return lightFormatters.M(date, token);
|
||||
// 1st, 2nd, ..., 12th
|
||||
case "Mo":
|
||||
return localize.ordinalNumber(month + 1, { unit: "month" });
|
||||
// Jan, Feb, ..., Dec
|
||||
case "MMM":
|
||||
return localize.month(month, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// J, F, ..., D
|
||||
case "MMMMM":
|
||||
return localize.month(month, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// January, February, ..., December
|
||||
case "MMMM":
|
||||
default:
|
||||
return localize.month(month, { width: "wide", context: "formatting" });
|
||||
}
|
||||
},
|
||||
|
||||
// Stand-alone month
|
||||
L: function (date, token, localize) {
|
||||
const month = date.getMonth();
|
||||
switch (token) {
|
||||
// 1, 2, ..., 12
|
||||
case "L":
|
||||
return String(month + 1);
|
||||
// 01, 02, ..., 12
|
||||
case "LL":
|
||||
return addLeadingZeros(month + 1, 2);
|
||||
// 1st, 2nd, ..., 12th
|
||||
case "Lo":
|
||||
return localize.ordinalNumber(month + 1, { unit: "month" });
|
||||
// Jan, Feb, ..., Dec
|
||||
case "LLL":
|
||||
return localize.month(month, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
});
|
||||
// J, F, ..., D
|
||||
case "LLLLL":
|
||||
return localize.month(month, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// January, February, ..., December
|
||||
case "LLLL":
|
||||
default:
|
||||
return localize.month(month, { width: "wide", context: "standalone" });
|
||||
}
|
||||
},
|
||||
|
||||
// Local week of year
|
||||
w: function (date, token, localize, options) {
|
||||
const week = getWeek(date, options);
|
||||
|
||||
if (token === "wo") {
|
||||
return localize.ordinalNumber(week, { unit: "week" });
|
||||
}
|
||||
|
||||
return addLeadingZeros(week, token.length);
|
||||
},
|
||||
|
||||
// ISO week of year
|
||||
I: function (date, token, localize) {
|
||||
const isoWeek = getISOWeek(date);
|
||||
|
||||
if (token === "Io") {
|
||||
return localize.ordinalNumber(isoWeek, { unit: "week" });
|
||||
}
|
||||
|
||||
return addLeadingZeros(isoWeek, token.length);
|
||||
},
|
||||
|
||||
// Day of the month
|
||||
d: function (date, token, localize) {
|
||||
if (token === "do") {
|
||||
return localize.ordinalNumber(date.getDate(), { unit: "date" });
|
||||
}
|
||||
|
||||
return lightFormatters.d(date, token);
|
||||
},
|
||||
|
||||
// Day of year
|
||||
D: function (date, token, localize) {
|
||||
const dayOfYear = getDayOfYear(date);
|
||||
|
||||
if (token === "Do") {
|
||||
return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
|
||||
}
|
||||
|
||||
return addLeadingZeros(dayOfYear, token.length);
|
||||
},
|
||||
|
||||
// Day of week
|
||||
E: function (date, token, localize) {
|
||||
const dayOfWeek = date.getDay();
|
||||
switch (token) {
|
||||
// Tue
|
||||
case "E":
|
||||
case "EE":
|
||||
case "EEE":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// T
|
||||
case "EEEEE":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tu
|
||||
case "EEEEEE":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tuesday
|
||||
case "EEEE":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Local day of week
|
||||
e: function (date, token, localize, options) {
|
||||
const dayOfWeek = date.getDay();
|
||||
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
||||
switch (token) {
|
||||
// Numerical value (Nth day of week with current locale or weekStartsOn)
|
||||
case "e":
|
||||
return String(localDayOfWeek);
|
||||
// Padded numerical value
|
||||
case "ee":
|
||||
return addLeadingZeros(localDayOfWeek, 2);
|
||||
// 1st, 2nd, ..., 7th
|
||||
case "eo":
|
||||
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
|
||||
case "eee":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// T
|
||||
case "eeeee":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tu
|
||||
case "eeeeee":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tuesday
|
||||
case "eeee":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Stand-alone local day of week
|
||||
c: function (date, token, localize, options) {
|
||||
const dayOfWeek = date.getDay();
|
||||
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
||||
switch (token) {
|
||||
// Numerical value (same as in `e`)
|
||||
case "c":
|
||||
return String(localDayOfWeek);
|
||||
// Padded numerical value
|
||||
case "cc":
|
||||
return addLeadingZeros(localDayOfWeek, token.length);
|
||||
// 1st, 2nd, ..., 7th
|
||||
case "co":
|
||||
return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
|
||||
case "ccc":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "standalone",
|
||||
});
|
||||
// T
|
||||
case "ccccc":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "standalone",
|
||||
});
|
||||
// Tu
|
||||
case "cccccc":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "standalone",
|
||||
});
|
||||
// Tuesday
|
||||
case "cccc":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "standalone",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// ISO day of week
|
||||
i: function (date, token, localize) {
|
||||
const dayOfWeek = date.getDay();
|
||||
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
|
||||
switch (token) {
|
||||
// 2
|
||||
case "i":
|
||||
return String(isoDayOfWeek);
|
||||
// 02
|
||||
case "ii":
|
||||
return addLeadingZeros(isoDayOfWeek, token.length);
|
||||
// 2nd
|
||||
case "io":
|
||||
return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
|
||||
// Tue
|
||||
case "iii":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
// T
|
||||
case "iiiii":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tu
|
||||
case "iiiiii":
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "short",
|
||||
context: "formatting",
|
||||
});
|
||||
// Tuesday
|
||||
case "iiii":
|
||||
default:
|
||||
return localize.day(dayOfWeek, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// AM or PM
|
||||
a: function (date, token, localize) {
|
||||
const hours = date.getHours();
|
||||
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
||||
|
||||
switch (token) {
|
||||
case "a":
|
||||
case "aa":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
case "aaa":
|
||||
return localize
|
||||
.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
})
|
||||
.toLowerCase();
|
||||
case "aaaaa":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
case "aaaa":
|
||||
default:
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// AM, PM, midnight, noon
|
||||
b: function (date, token, localize) {
|
||||
const hours = date.getHours();
|
||||
let dayPeriodEnumValue;
|
||||
if (hours === 12) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.noon;
|
||||
} else if (hours === 0) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.midnight;
|
||||
} else {
|
||||
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
case "b":
|
||||
case "bb":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
case "bbb":
|
||||
return localize
|
||||
.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
})
|
||||
.toLowerCase();
|
||||
case "bbbbb":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
case "bbbb":
|
||||
default:
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// in the morning, in the afternoon, in the evening, at night
|
||||
B: function (date, token, localize) {
|
||||
const hours = date.getHours();
|
||||
let dayPeriodEnumValue;
|
||||
if (hours >= 17) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.evening;
|
||||
} else if (hours >= 12) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.afternoon;
|
||||
} else if (hours >= 4) {
|
||||
dayPeriodEnumValue = dayPeriodEnum.morning;
|
||||
} else {
|
||||
dayPeriodEnumValue = dayPeriodEnum.night;
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
case "B":
|
||||
case "BB":
|
||||
case "BBB":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "abbreviated",
|
||||
context: "formatting",
|
||||
});
|
||||
case "BBBBB":
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "narrow",
|
||||
context: "formatting",
|
||||
});
|
||||
case "BBBB":
|
||||
default:
|
||||
return localize.dayPeriod(dayPeriodEnumValue, {
|
||||
width: "wide",
|
||||
context: "formatting",
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// Hour [1-12]
|
||||
h: function (date, token, localize) {
|
||||
if (token === "ho") {
|
||||
let hours = date.getHours() % 12;
|
||||
if (hours === 0) hours = 12;
|
||||
return localize.ordinalNumber(hours, { unit: "hour" });
|
||||
}
|
||||
|
||||
return lightFormatters.h(date, token);
|
||||
},
|
||||
|
||||
// Hour [0-23]
|
||||
H: function (date, token, localize) {
|
||||
if (token === "Ho") {
|
||||
return localize.ordinalNumber(date.getHours(), { unit: "hour" });
|
||||
}
|
||||
|
||||
return lightFormatters.H(date, token);
|
||||
},
|
||||
|
||||
// Hour [0-11]
|
||||
K: function (date, token, localize) {
|
||||
const hours = date.getHours() % 12;
|
||||
|
||||
if (token === "Ko") {
|
||||
return localize.ordinalNumber(hours, { unit: "hour" });
|
||||
}
|
||||
|
||||
return addLeadingZeros(hours, token.length);
|
||||
},
|
||||
|
||||
// Hour [1-24]
|
||||
k: function (date, token, localize) {
|
||||
let hours = date.getHours();
|
||||
if (hours === 0) hours = 24;
|
||||
|
||||
if (token === "ko") {
|
||||
return localize.ordinalNumber(hours, { unit: "hour" });
|
||||
}
|
||||
|
||||
return addLeadingZeros(hours, token.length);
|
||||
},
|
||||
|
||||
// Minute
|
||||
m: function (date, token, localize) {
|
||||
if (token === "mo") {
|
||||
return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
|
||||
}
|
||||
|
||||
return lightFormatters.m(date, token);
|
||||
},
|
||||
|
||||
// Second
|
||||
s: function (date, token, localize) {
|
||||
if (token === "so") {
|
||||
return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
|
||||
}
|
||||
|
||||
return lightFormatters.s(date, token);
|
||||
},
|
||||
|
||||
// Fraction of second
|
||||
S: function (date, token) {
|
||||
return lightFormatters.S(date, token);
|
||||
},
|
||||
|
||||
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
|
||||
X: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
if (timezoneOffset === 0) {
|
||||
return "Z";
|
||||
}
|
||||
|
||||
switch (token) {
|
||||
// Hours and optional minutes
|
||||
case "X":
|
||||
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds without `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `XX`
|
||||
case "XXXX":
|
||||
case "XX": // Hours and minutes without `:` delimiter
|
||||
return formatTimezone(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds with `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `XXX`
|
||||
case "XXXXX":
|
||||
case "XXX": // Hours and minutes with `:` delimiter
|
||||
default:
|
||||
return formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
|
||||
x: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
switch (token) {
|
||||
// Hours and optional minutes
|
||||
case "x":
|
||||
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds without `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `xx`
|
||||
case "xxxx":
|
||||
case "xx": // Hours and minutes without `:` delimiter
|
||||
return formatTimezone(timezoneOffset);
|
||||
|
||||
// Hours, minutes and optional seconds with `:` delimiter
|
||||
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
||||
// so this token always has the same output as `xxx`
|
||||
case "xxxxx":
|
||||
case "xxx": // Hours and minutes with `:` delimiter
|
||||
default:
|
||||
return formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Timezone (GMT)
|
||||
O: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
switch (token) {
|
||||
// Short
|
||||
case "O":
|
||||
case "OO":
|
||||
case "OOO":
|
||||
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
||||
// Long
|
||||
case "OOOO":
|
||||
default:
|
||||
return "GMT" + formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Timezone (specific non-location)
|
||||
z: function (date, token, _localize) {
|
||||
const timezoneOffset = date.getTimezoneOffset();
|
||||
|
||||
switch (token) {
|
||||
// Short
|
||||
case "z":
|
||||
case "zz":
|
||||
case "zzz":
|
||||
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
||||
// Long
|
||||
case "zzzz":
|
||||
default:
|
||||
return "GMT" + formatTimezone(timezoneOffset, ":");
|
||||
}
|
||||
},
|
||||
|
||||
// Seconds timestamp
|
||||
t: function (date, token, _localize) {
|
||||
const timestamp = Math.trunc(+date / 1000);
|
||||
return addLeadingZeros(timestamp, token.length);
|
||||
},
|
||||
|
||||
// Milliseconds timestamp
|
||||
T: function (date, token, _localize) {
|
||||
return addLeadingZeros(+date, token.length);
|
||||
},
|
||||
};
|
||||
|
||||
function formatTimezoneShort(offset, delimiter = "") {
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
const absOffset = Math.abs(offset);
|
||||
const hours = Math.trunc(absOffset / 60);
|
||||
const minutes = absOffset % 60;
|
||||
if (minutes === 0) {
|
||||
return sign + String(hours);
|
||||
}
|
||||
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
|
||||
}
|
||||
|
||||
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
|
||||
if (offset % 60 === 0) {
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
|
||||
}
|
||||
return formatTimezone(offset, delimiter);
|
||||
}
|
||||
|
||||
function formatTimezone(offset, delimiter = "") {
|
||||
const sign = offset > 0 ? "-" : "+";
|
||||
const absOffset = Math.abs(offset);
|
||||
const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
|
||||
const minutes = addLeadingZeros(absOffset % 60, 2);
|
||||
return sign + hours + delimiter + minutes;
|
||||
}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
exports.lightFormatters = void 0;
|
||||
var _index = require("../addLeadingZeros.cjs");
|
||||
|
||||
/*
|
||||
* | | Unit | | Unit |
|
||||
* |-----|--------------------------------|-----|--------------------------------|
|
||||
* | a | AM, PM | A* | |
|
||||
* | d | Day of month | D | |
|
||||
* | h | Hour [1-12] | H | Hour [0-23] |
|
||||
* | m | Minute | M | Month |
|
||||
* | s | Second | S | Fraction of second |
|
||||
* | y | Year (abs) | Y | |
|
||||
*
|
||||
* Letters marked by * are not implemented but reserved by Unicode standard.
|
||||
*/
|
||||
|
||||
const lightFormatters = (exports.lightFormatters = {
|
||||
// Year
|
||||
y(date, token) {
|
||||
// From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
|
||||
// | Year | y | yy | yyy | yyyy | yyyyy |
|
||||
// |----------|-------|----|-------|-------|-------|
|
||||
// | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
|
||||
// | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
|
||||
// | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
|
||||
// | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
|
||||
// | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
|
||||
|
||||
const signedYear = date.getFullYear();
|
||||
// Returns 1 for 1 BC (which is year 0 in JavaScript)
|
||||
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
||||
return (0, _index.addLeadingZeros)(
|
||||
token === "yy" ? year % 100 : year,
|
||||
token.length,
|
||||
);
|
||||
},
|
||||
|
||||
// Month
|
||||
M(date, token) {
|
||||
const month = date.getMonth();
|
||||
return token === "M"
|
||||
? String(month + 1)
|
||||
: (0, _index.addLeadingZeros)(month + 1, 2);
|
||||
},
|
||||
|
||||
// Day of the month
|
||||
d(date, token) {
|
||||
return (0, _index.addLeadingZeros)(date.getDate(), token.length);
|
||||
},
|
||||
|
||||
// AM or PM
|
||||
a(date, token) {
|
||||
const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
|
||||
|
||||
switch (token) {
|
||||
case "a":
|
||||
case "aa":
|
||||
return dayPeriodEnumValue.toUpperCase();
|
||||
case "aaa":
|
||||
return dayPeriodEnumValue;
|
||||
case "aaaaa":
|
||||
return dayPeriodEnumValue[0];
|
||||
case "aaaa":
|
||||
default:
|
||||
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
|
||||
}
|
||||
},
|
||||
|
||||
// Hour [1-12]
|
||||
h(date, token) {
|
||||
return (0, _index.addLeadingZeros)(
|
||||
date.getHours() % 12 || 12,
|
||||
token.length,
|
||||
);
|
||||
},
|
||||
|
||||
// Hour [0-23]
|
||||
H(date, token) {
|
||||
return (0, _index.addLeadingZeros)(date.getHours(), token.length);
|
||||
},
|
||||
|
||||
// Minute
|
||||
m(date, token) {
|
||||
return (0, _index.addLeadingZeros)(date.getMinutes(), token.length);
|
||||
},
|
||||
|
||||
// Second
|
||||
s(date, token) {
|
||||
return (0, _index.addLeadingZeros)(date.getSeconds(), token.length);
|
||||
},
|
||||
|
||||
// Fraction of second
|
||||
S(date, token) {
|
||||
const numberOfDigits = token.length;
|
||||
const milliseconds = date.getMilliseconds();
|
||||
const fractionalSeconds = Math.trunc(
|
||||
milliseconds * Math.pow(10, numberOfDigits - 3),
|
||||
);
|
||||
return (0, _index.addLeadingZeros)(fractionalSeconds, token.length);
|
||||
},
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
export declare const lightFormatters: {
|
||||
y(date: Date, token: string): string;
|
||||
M(date: Date, token: string): string;
|
||||
d(date: Date, token: string): string;
|
||||
a(date: Date, token: string): string;
|
||||
h(date: Date, token: string): string;
|
||||
H(date: Date, token: string): string;
|
||||
m(date: Date, token: string): string;
|
||||
s(date: Date, token: string): string;
|
||||
S(date: Date, token: string): string;
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user