@poe-platform/safe-bash 0.1.833 → 0.1.835

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.
@@ -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 tx = mapX(parseSvgCoord(attrs.x, 0, vbW)), ty = mapY(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, startX = anchor === "middle" ? tx - totalW / 2 : anchor === "end" ? tx - totalW : tx, baseTopY = Math.round(ty - glyphH);
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))
@@ -5203,7 +5216,7 @@ function readWebpMetadata(bytes) {
5203
5216
  }
5204
5217
  function createWebpEncoder(img, hasAlpha, options) {
5205
5218
  let { width, height } = img, numPixels = width * height;
5206
- if (!Number.isSafeInteger(width) || width <= 0 || !Number.isSafeInteger(height) || height <= 0 || !Number.isSafeInteger(numPixels))
5219
+ if (!Number.isSafeInteger(width) || width <= 0 || width > 16384 || !Number.isSafeInteger(height) || height <= 0 || height > 16384 || !Number.isSafeInteger(numPixels))
5207
5220
  throw new RangeError("Invalid WebP dimensions");
5208
5221
  let vp8lBuf = new Uint8Array(4096);
5209
5222
  vp8lBuf[0] = 47;
@@ -6618,7 +6631,7 @@ var Pixels = class {
6618
6631
  async function* encodeWebpFromStorage(image, storage, signal, options) {
6619
6632
  signal.throwIfAborted();
6620
6633
  let length = image.width * image.height * 4;
6621
- if (!Number.isSafeInteger(image.width) || image.width <= 0 || !Number.isSafeInteger(image.height) || image.height <= 0 || !Number.isSafeInteger(image.position) || image.position < 0 || !Number.isSafeInteger(length) || !Number.isSafeInteger(image.position + length))
6634
+ if (!Number.isSafeInteger(image.width) || image.width <= 0 || image.width > 16384 || !Number.isSafeInteger(image.height) || image.height <= 0 || image.height > 16384 || !Number.isSafeInteger(image.position) || image.position < 0 || !Number.isSafeInteger(length) || !Number.isSafeInteger(image.position + length))
6622
6635
  throw new RangeError("Invalid WebP backing allocation");
6623
6636
  let pixels = new Pixels(image, storage, signal), hasAlpha = !1;
6624
6637
  for (let at = 0; at < length && !hasAlpha; at += 4096) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-bash",
3
- "version": "0.1.833",
3
+ "version": "0.1.835",
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.833",
1418
+ "@poe-platform/safe-fs": "0.1.835",
1419
1419
  "pdf-lib": "1.17.1",
1420
1420
  "@types/node": "^25.2.2",
1421
1421
  "@formatjs/intl-numberformat": "9.4.0",