@poe-platform/safe-bash 0.1.764 → 0.1.765

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.
@@ -32212,11 +32212,10 @@ function evaluateContentStreamToDisplayList(params) {
32212
32212
  } else if (operator === "d") {
32213
32213
  const arrNode = ops[0]?.kind === "array" ? ops[0] : void 0;
32214
32214
  if (arrNode) {
32215
- const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
32216
- const nums = arrNode.items.map((it) => it.kind === "number" ? it.value * ctmScale : 0).filter((v) => v >= 0);
32215
+ const nums = arrNode.items.map((it) => it.kind === "number" ? it.value : 0).filter((v) => v >= 0);
32217
32216
  const sum = nums.reduce((a, b) => a + b, 0);
32218
32217
  st.dashArray = sum > 0 ? nums : void 0;
32219
- st.dashPhase = num(1, 0) * ctmScale;
32218
+ st.dashPhase = num(1, 0);
32220
32219
  } else {
32221
32220
  st.dashArray = void 0;
32222
32221
  st.dashPhase = void 0;
@@ -32752,15 +32751,14 @@ function evaluateContentStreamToDisplayList(params) {
32752
32751
  break;
32753
32752
  }
32754
32753
  const fillRule = node.paint.includes("*") ? "evenodd" : "nonzero";
32755
- const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
32756
- const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
32757
32754
  emit({ kind: "path", value: {
32758
32755
  segments: transformedSegments,
32759
32756
  fillColor: isFill && !evaluatedFillPattern ? st.fillColor : void 0,
32760
32757
  fillAlpha: isFill && !evaluatedFillPattern ? st.fillAlpha : void 0,
32761
32758
  strokeColor: isStroke ? st.strokeColor : void 0,
32762
32759
  strokeAlpha: isStroke ? st.strokeAlpha : void 0,
32763
- strokeWidth: scaledStrokeWidth,
32760
+ strokeWidth: st.strokeWidth,
32761
+ ...isStroke ? { strokeMatrix: [...st.ctm] } : {},
32764
32762
  ...st.lineCap !== 0 ? { lineCap: st.lineCap } : {},
32765
32763
  ...st.lineJoin !== 0 ? { lineJoin: st.lineJoin } : {},
32766
32764
  ...st.miterLimit !== 10 ? { miterLimit: st.miterLimit } : {},
@@ -32948,14 +32946,14 @@ function evaluateContentStreamToDisplayList(params) {
32948
32946
  if (st.textRenderMode >= 4 && st.textRenderMode <= 7) pendingTextClip.push(...transformedGlyphSegs);
32949
32947
  const isFillGlyph = st.textRenderMode === 0 || st.textRenderMode === 2 || st.textRenderMode === 4 || st.textRenderMode === 6;
32950
32948
  const isStrokeGlyph = st.textRenderMode === 1 || st.textRenderMode === 2 || st.textRenderMode === 5 || st.textRenderMode === 6;
32951
- const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
32952
32949
  const paint = {
32953
32950
  segments: transformedGlyphSegs,
32954
32951
  fillColor: isFillGlyph ? st.fillColor : void 0,
32955
32952
  fillAlpha: isFillGlyph ? st.fillAlpha : void 0,
32956
32953
  strokeColor: isStrokeGlyph ? st.strokeColor : void 0,
32957
32954
  strokeAlpha: isStrokeGlyph ? st.strokeAlpha : void 0,
32958
- strokeWidth: isStrokeGlyph ? st.strokeWidth * ctmScale : 0,
32955
+ strokeWidth: isStrokeGlyph ? st.strokeWidth : 0,
32956
+ ...isStrokeGlyph ? { strokeMatrix: [...st.ctm] } : {},
32959
32957
  fillRule: "nonzero",
32960
32958
  ...st.blendMode && st.blendMode !== "Normal" ? { blendMode: st.blendMode } : {},
32961
32959
  ...st.clipRect ? { clipRect: [...st.clipRect] } : {}
@@ -35001,11 +34999,10 @@ function blendPixel(rgba, width, height, px, py, color, alpha, blendMode, clipMa
35001
34999
  rgba[idx + 2] = Math.round((effB * a + cbB * dstA * (1 - a)) / outA * 255);
35002
35000
  rgba[idx + 3] = Math.round(outA * 255);
35003
35001
  }
35004
- function segmentsToScreenPaths(segments, pageHeight, scale) {
35002
+ function segmentsToScreenPaths(segments, pageHeight, scale, toScreen = (x, y) => [x * scale, (pageHeight - y) * scale]) {
35005
35003
  const paths = [];
35006
35004
  let points = [];
35007
35005
  let current = [0, 0];
35008
- const toScreen = (x, y) => [x * scale, (pageHeight - y) * scale];
35009
35006
  for (const segment of segments) {
35010
35007
  if (segment.kind === "move") {
35011
35008
  if (points.length) paths.push({ points, closed: false });
@@ -35044,6 +35041,63 @@ function segmentsToScreenPaths(segments, pageHeight, scale) {
35044
35041
  if (points.length) paths.push({ points, closed: false });
35045
35042
  return paths;
35046
35043
  }
35044
+ function inverseStrokeMatrix(matrix) {
35045
+ const [a, b, c, d, e, f] = matrix;
35046
+ const det = a * d - b * c;
35047
+ if (!Number.isFinite(det) || det === 0) return void 0;
35048
+ return [d / det, -b / det, -c / det, a / det, (c * f - d * e) / det, (b * e - a * f) / det];
35049
+ }
35050
+ function prepareStroke(path, scale) {
35051
+ const matrix = path.strokeMatrix ? [...path.strokeMatrix] : [1, 0, 0, 1, 0, 0];
35052
+ const [a, b, c, d] = matrix;
35053
+ const area = Math.abs(a * d - b * c) * scale * scale;
35054
+ if (!(area > 0) || !Number.isFinite(area)) return void 0;
35055
+ const normX = Math.hypot(a, b) * scale, normY = Math.hypot(c, d) * scale;
35056
+ let width = path.strokeWidth || 1;
35057
+ const scaleX = path.strokeWidth === 0 ? normY / area : Math.max(1, normY / (width * area));
35058
+ const scaleY = path.strokeWidth === 0 ? normX / area : Math.max(1, normX / (width * area));
35059
+ let dashArray = path.dashArray, dashPhase = path.dashPhase ?? 0;
35060
+ if (scaleX === scaleY) {
35061
+ width *= scaleX;
35062
+ } else {
35063
+ matrix[0] *= scaleX;
35064
+ matrix[1] *= scaleX;
35065
+ matrix[2] *= scaleY;
35066
+ matrix[3] *= scaleY;
35067
+ if (dashArray?.length) {
35068
+ const dashScale = Math.max(scaleX, scaleY);
35069
+ dashArray = dashArray.map((value) => value / dashScale);
35070
+ dashPhase /= dashScale;
35071
+ }
35072
+ }
35073
+ return { matrix, width, dashArray, dashPhase };
35074
+ }
35075
+ function strokeEdges(path, pageHeight, scale) {
35076
+ const stroke = prepareStroke(path, scale);
35077
+ if (!stroke) return [];
35078
+ const inverse = inverseStrokeMatrix(stroke.matrix);
35079
+ if (!inverse) return [];
35080
+ const [a, b, c, d, e, f] = stroke.matrix;
35081
+ const strokeScale = scale * Math.hypot(a, b, c, d);
35082
+ const project = (x, y) => [
35083
+ (inverse[0] * x + inverse[2] * y + inverse[4]) * strokeScale,
35084
+ (inverse[1] * x + inverse[3] * y + inverse[5]) * strokeScale
35085
+ ];
35086
+ const toScreen = ([x, y]) => [
35087
+ (a * x / strokeScale + c * y / strokeScale + e) * scale,
35088
+ (pageHeight - b * x / strokeScale - d * y / strokeScale - f) * scale
35089
+ ];
35090
+ const contours = strokeOutlines(
35091
+ segmentsToScreenPaths(path.segments, pageHeight, scale, project),
35092
+ stroke.width * strokeScale,
35093
+ path.lineCap ?? 0,
35094
+ path.lineJoin ?? 0,
35095
+ path.miterLimit ?? 10,
35096
+ stroke.dashArray?.map((value) => Math.max(0, value * strokeScale)),
35097
+ stroke.dashPhase * strokeScale
35098
+ );
35099
+ return pathsToEdges(contours.map((points) => ({ points: points.map(toScreen), closed: true })));
35100
+ }
35047
35101
  function pathsToEdges(paths, closeSubpaths = false) {
35048
35102
  const edges = [];
35049
35103
  for (const { points, closed } of paths) {
@@ -35293,19 +35347,9 @@ function renderDisplayListToBitmap(displayList, options = {}) {
35293
35347
  fillEdgesScanline4x4(rgba, width, height, edges, path.fillColor, path.fillAlpha ?? 1, path.fillRule ?? "nonzero", clipScreen, original.kind === "glyph" ? aaTxt : aaVec, path.blendMode, clipMask);
35294
35348
  }
35295
35349
  if (path.strokeColor) {
35296
- const rawSw = path.strokeWidth * scale;
35297
- const sw = Math.max(1, rawSw);
35350
+ const rawSw = path.strokeWidth * scale * (path.strokeMatrix ? Math.hypot(path.strokeMatrix[0], path.strokeMatrix[1]) : 1);
35298
35351
  const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
35299
- const contours = strokeOutlines(
35300
- segmentsToScreenPaths(path.segments, displayList.height, scale),
35301
- sw,
35302
- path.lineCap ?? 0,
35303
- path.lineJoin ?? 0,
35304
- path.miterLimit ?? 10,
35305
- path.dashArray?.map((value) => Math.max(0, value * scale)),
35306
- (path.dashPhase ?? 0) * scale
35307
- );
35308
- const edges = pathsToEdges(contours.map((points) => ({ points, closed: true })));
35352
+ const edges = strokeEdges(path, displayList.height, scale);
35309
35353
  const clipScreen = path.clipRect ? [path.clipRect[0] * scale, (displayList.height - path.clipRect[3]) * scale, path.clipRect[2] * scale, (displayList.height - path.clipRect[1]) * scale] : void 0;
35310
35354
  fillEdgesScanline4x4(
35311
35355
  rgba,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PdfDocument,
3
3
  renderPdfPageToPng
4
- } from "./chunk-G3IIEU2N.js";
4
+ } from "./chunk-KO4PXCNL.js";
5
5
  import {
6
6
  init_buffer
7
7
  } from "./chunk-HX3SHTCE.js";