@poe-platform/safe-bash 0.1.833 → 0.1.834
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/image-ast/index.js +14 -1
- package/package.json +2 -2
package/dist/image-ast/index.js
CHANGED
|
@@ -1129,11 +1129,24 @@ function* rasterSvgElement(element, viewport) {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
}, effScaleX = Math.hypot(activeCtm[0], activeCtm[1]), effScaleY = Math.hypot(activeCtm[2], activeCtm[3]), fillAttr = attrs.fill ?? (tag === "line" ? "none" : "#000000"), opAttr = parseFloat(attrs.opacity ?? "1"), fillOpAttr = parseFloat(attrs["fill-opacity"] ?? "1"), opacity = (Number.isFinite(opAttr) ? opAttr : 1) * (Number.isFinite(fillOpAttr) ? fillOpAttr : 1), fill = fillAttr === "none" ? { r: 0, g: 0, b: 0, a: 0 } : parseColor(fillAttr), effAlpha = Math.round(fill.a * (Number.isFinite(opacity) ? opacity : 1)), strokeAttr = attrs.stroke, stroke = strokeAttr && strokeAttr !== "none" ? parseColor(strokeAttr) : { r: 0, g: 0, b: 0, a: 0 }, strokeW = parseSvgCoord(attrs["stroke-width"], 1, vbW) * ((effScaleX + effScaleY) / 2);
|
|
1131
1131
|
if (tag === "text" && effAlpha > 0 && textLength > 0) {
|
|
1132
|
-
let
|
|
1132
|
+
let [a, b, c, d] = activeCtm, determinant = a * d - b * c;
|
|
1133
|
+
if (!Number.isFinite(determinant) || determinant === 0) return;
|
|
1134
|
+
let transformed = b !== 0 || c !== 0 || a <= 0 || d <= 0 || a !== d, [tx, ty] = mapPt(parseSvgCoord(attrs.x, 0, vbW), parseSvgCoord(attrs.y, 0, vbH)), fontSize = Math.max(6, parseSvgCoord(attrs["font-size"], 12, vbH) * effScaleY), glyphH = Math.max(7, Math.round(fontSize * 0.76)), glyphW = Math.max(5, Math.round(glyphH * (5 / 7))), advanceX = Math.max(glyphW + 1, Math.round(glyphW * 1.2)), anchor = (attrs["text-anchor"] ?? "start").toLowerCase(), totalW = textLength * advanceX, originX = transformed ? 0 : tx, startX = anchor === "middle" ? originX - totalW / 2 : anchor === "end" ? originX - totalW : originX, baseTopY = Math.round((transformed ? 0 : ty) - glyphH);
|
|
1133
1135
|
for (let ci = 0; ci < textLength; ci++) {
|
|
1134
1136
|
let ch = yield { kind: "character", index: ci };
|
|
1135
1137
|
if (ch <= 32) continue;
|
|
1136
1138
|
let glyphIdx = Math.max(0, Math.min(94, ch - 32)), charTopY = baseTopY + (ch === 103 || ch === 106 || ch === 112 || ch === 113 || ch === 121 || ch === 44 || ch === 59 ? Math.max(1, Math.round(glyphH / 7)) : 0), charLeftX = Math.round(startX + ci * advanceX);
|
|
1139
|
+
if (transformed) {
|
|
1140
|
+
let corners = [[charLeftX, charTopY], [charLeftX + glyphW, charTopY], [charLeftX, charTopY + glyphH], [charLeftX + glyphW, charTopY + glyphH]].map(([x, y]) => [tx + (a * x + c * y) / effScaleY, ty + (b * x + d * y) / effScaleY]), minX = Math.max(0, Math.floor(Math.min(...corners.map((p) => p[0])))), maxX = Math.min(width, Math.ceil(Math.max(...corners.map((p) => p[0])))), minY = Math.max(0, Math.floor(Math.min(...corners.map((p) => p[1])))), maxY = Math.min(height, Math.ceil(Math.max(...corners.map((p) => p[1]))));
|
|
1141
|
+
for (let screenY = minY; screenY < maxY; screenY++) for (let screenX = minX; screenX < maxX; screenX++) {
|
|
1142
|
+
++rasterWork % 16384 === 0 && (yield void 0);
|
|
1143
|
+
let dx = screenX + 0.5 - tx, dy = screenY + 0.5 - ty, px = (d * dx - c * dy) / determinant * effScaleY - charLeftX, py = (a * dy - b * dx) / determinant * effScaleY - charTopY;
|
|
1144
|
+
if (px < 0 || py < 0 || px >= glyphW || py >= glyphH) continue;
|
|
1145
|
+
let gx = Math.floor(Math.floor(px) * 5 / glyphW), gy = Math.floor(Math.floor(py) * 7 / glyphH);
|
|
1146
|
+
(FONT_5X7[glyphIdx * 5 + gx] & 1 << gy) !== 0 && (yield* blendPixel(screenX, screenY, fill.r, fill.g, fill.b, effAlpha));
|
|
1147
|
+
}
|
|
1148
|
+
continue;
|
|
1149
|
+
}
|
|
1137
1150
|
for (let py = 0; py < glyphH; py++) {
|
|
1138
1151
|
let gy = Math.min(6, Math.floor(py * 7 / glyphH)), screenY = charTopY + py;
|
|
1139
1152
|
if (!(screenY < 0 || screenY >= height))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poe-platform/safe-bash",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.834",
|
|
4
4
|
"description": "Extensible virtual shell with pluggable filesystems and streaming commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1415,7 +1415,7 @@
|
|
|
1415
1415
|
"access": "public"
|
|
1416
1416
|
},
|
|
1417
1417
|
"dependencies": {
|
|
1418
|
-
"@poe-platform/safe-fs": "0.1.
|
|
1418
|
+
"@poe-platform/safe-fs": "0.1.834",
|
|
1419
1419
|
"pdf-lib": "1.17.1",
|
|
1420
1420
|
"@types/node": "^25.2.2",
|
|
1421
1421
|
"@formatjs/intl-numberformat": "9.4.0",
|