@markdy/renderer-dom 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +31 -19
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6224,8 +6224,12 @@ function createDiagram(opts) {
|
|
|
6224
6224
|
const hasInitialHeightConstraint = initialContainerHeight > 0 && !container.style.aspectRatio;
|
|
6225
6225
|
function detectContainerOrientation(previous) {
|
|
6226
6226
|
const width = container.clientWidth || (typeof window === "undefined" ? 1024 : window.innerWidth);
|
|
6227
|
-
const
|
|
6227
|
+
const currentHeight = container.clientHeight || 0;
|
|
6228
|
+
const height = hasInitialHeightConstraint ? currentHeight > 0 ? currentHeight : initialContainerHeight : 0;
|
|
6228
6229
|
const breakpoint = previous === "portrait" ? 672 : previous === "landscape" ? 608 : 640;
|
|
6230
|
+
if (width <= 440) {
|
|
6231
|
+
return "portrait";
|
|
6232
|
+
}
|
|
6229
6233
|
if (height > 0) {
|
|
6230
6234
|
const ratio = width / height;
|
|
6231
6235
|
const ratioBreakpoint = previous === "portrait" ? 1.15 : previous === "landscape" ? 0.88 : 1;
|
|
@@ -6234,7 +6238,7 @@ function createDiagram(opts) {
|
|
|
6234
6238
|
}
|
|
6235
6239
|
return "portrait";
|
|
6236
6240
|
}
|
|
6237
|
-
return
|
|
6241
|
+
return "landscape";
|
|
6238
6242
|
}
|
|
6239
6243
|
const ast = parse(code);
|
|
6240
6244
|
for (const w of ast.diagnostics) {
|
|
@@ -6615,7 +6619,7 @@ function createDiagram(opts) {
|
|
|
6615
6619
|
meta: {
|
|
6616
6620
|
...ast.meta,
|
|
6617
6621
|
direction,
|
|
6618
|
-
...
|
|
6622
|
+
...shouldAdaptOrientation ? { explicitWidth: false, explicitHeight: false } : {}
|
|
6619
6623
|
}
|
|
6620
6624
|
};
|
|
6621
6625
|
const candidate = compilePlan(candidateAst, plan.theme);
|
|
@@ -6753,23 +6757,31 @@ function createDiagram(opts) {
|
|
|
6753
6757
|
const isHeightConstrained = hasInitialHeightConstraint || vHeight > 0 && Math.abs(vHeight - naturalHeight) > 2;
|
|
6754
6758
|
const containerRatio = vWidth / Math.max(1, vHeight);
|
|
6755
6759
|
let currentOrientation = activeOrientation;
|
|
6756
|
-
|
|
6757
|
-
const
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6760
|
+
const score = (orientation) => {
|
|
6761
|
+
const { bounds: bounds2 } = layoutForDirection(directionForOrientation(orientation));
|
|
6762
|
+
const widthScale2 = vWidth * targetRatio / bounds2.width;
|
|
6763
|
+
const heightScale = isHeightConstrained ? Math.max(1, vHeight - 24) * targetRatio / bounds2.height : 1;
|
|
6764
|
+
return {
|
|
6765
|
+
fit: Math.min(1, widthScale2, heightScale),
|
|
6766
|
+
widthScale: widthScale2,
|
|
6767
|
+
bounds: bounds2
|
|
6762
6768
|
};
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6769
|
+
};
|
|
6770
|
+
const scoreP = score("portrait");
|
|
6771
|
+
const scoreL = score("landscape");
|
|
6772
|
+
if (activeOrientation === "landscape") {
|
|
6773
|
+
if (detectedOrientation === "portrait") {
|
|
6774
|
+
currentOrientation = "portrait";
|
|
6775
|
+
} else if (!isHeightConstrained && scoreP.widthScale >= 0.7 && scoreL.widthScale < 0.65) {
|
|
6776
|
+
currentOrientation = "portrait";
|
|
6777
|
+
} else if (scoreP.fit > scoreL.fit * 1.25) {
|
|
6778
|
+
currentOrientation = "portrait";
|
|
6779
|
+
}
|
|
6780
|
+
} else {
|
|
6781
|
+
if (detectedOrientation === "landscape" && (scoreL.fit >= Math.min(0.85, scoreP.fit) || scoreL.widthScale >= 0.75)) {
|
|
6782
|
+
currentOrientation = "landscape";
|
|
6783
|
+
} else if (scoreL.fit > scoreP.fit * 1.25) {
|
|
6784
|
+
currentOrientation = "landscape";
|
|
6773
6785
|
}
|
|
6774
6786
|
}
|
|
6775
6787
|
if (currentOrientation !== activeOrientation) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markdy/renderer-dom",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Browser renderer for diagram-native animated MarkdyScript architecture diagrams, built on the Web Animations API.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"html2canvas": "^1.4.1",
|
|
49
|
-
"@markdy/core": "1.4.
|
|
49
|
+
"@markdy/core": "1.4.6"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"jsdom": "^29.1.1",
|
|
53
53
|
"tsup": "^8.5.1",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
55
|
"vitest": "^4.1.7",
|
|
56
|
-
"@markdy/stdlib-systems": "1.4.
|
|
56
|
+
"@markdy/stdlib-systems": "1.4.6"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsup",
|