@poe-platform/safe-bash 0.1.765 → 0.1.767

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.
@@ -32347,10 +32347,11 @@ function evaluateContentStreamToDisplayList(params) {
32347
32347
  const patArr = params.cosDoc.resolveArray(dArr.items[0]);
32348
32348
  const phaseNode = params.cosDoc.resolve(dArr.items[1]);
32349
32349
  if (patArr) {
32350
- st.dashArray = patArr.items.map((it) => {
32350
+ const dashArray = patArr.items.map((it) => {
32351
32351
  const r = params.cosDoc.resolve(it);
32352
32352
  return r?.kind === "number" ? r.value : 0;
32353
- }).filter((n) => n > 0);
32353
+ }).filter((n) => n >= 0);
32354
+ st.dashArray = dashArray.some((value) => value > 0) ? dashArray : void 0;
32354
32355
  st.dashPhase = phaseNode?.kind === "number" ? phaseNode.value : 0;
32355
32356
  }
32356
32357
  }
@@ -32405,8 +32406,9 @@ function evaluateContentStreamToDisplayList(params) {
32405
32406
  const st = curState();
32406
32407
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
32407
32408
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
32408
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
32409
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
32409
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
32410
+ const isolated = isolation?.kind === "boolean" && isolation.value;
32411
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
32410
32412
  const formStreamBytes = params.cosDoc.decodeStream(form);
32411
32413
  const formNodes = parseContentStream(formStreamBytes);
32412
32414
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -32424,8 +32426,8 @@ function evaluateContentStreamToDisplayList(params) {
32424
32426
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
32425
32427
  nextCtm = multiplyMatrices(formMat, nextCtm);
32426
32428
  }
32427
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
32428
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
32429
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
32430
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
32429
32431
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
32430
32432
  if (bboxArr && bboxArr.items.length >= 4) {
32431
32433
  const bn = (idx, fb = 0) => {
@@ -32459,7 +32461,7 @@ function evaluateContentStreamToDisplayList(params) {
32459
32461
  const parentOperations = capturedOperations;
32460
32462
  const children = [];
32461
32463
  const nextState = { ...st, ctm: nextCtm };
32462
- if (isolate) {
32464
+ if (compositeGroup) {
32463
32465
  capturedOperations = children;
32464
32466
  nextState.fillAlpha = nextState.strokeAlpha = 1;
32465
32467
  nextState.blendMode = "Normal";
@@ -32477,7 +32479,7 @@ function evaluateContentStreamToDisplayList(params) {
32477
32479
  stateStack.pop();
32478
32480
  capturedOperations = parentOperations;
32479
32481
  }
32480
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
32482
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
32481
32483
  };
32482
32484
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
32483
32485
  for (const node of nodes) {
@@ -34145,7 +34147,7 @@ function dashSubpath(path, pattern, phase) {
34145
34147
  while (remaining <= 0) {
34146
34148
  if (++steps > MAX_STROKE_VERTICES) throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
34147
34149
  if (index % 2 === 0) {
34148
- if (pattern[index] === 0) result.push({ points: [point, point], closed: false });
34150
+ if (pattern[index] === 0) result.push({ points: [point, point], closed: false, zeroLengthDash: true });
34149
34151
  flush();
34150
34152
  }
34151
34153
  index = (index + 1) % pattern.length;
@@ -34160,7 +34162,7 @@ function dashSubpath(path, pattern, phase) {
34160
34162
  throw new PdfError("E_LIMIT", "Stroke dash expansion exceeds the vertex limit");
34161
34163
  }
34162
34164
  let distance = 0;
34163
- while (distance < length) {
34165
+ while (length - distance > 8 * Number.EPSILON * Math.max(1, length)) {
34164
34166
  const point = [start[0] + dx * distance / length, start[1] + dy * distance / length];
34165
34167
  advance(point);
34166
34168
  const step = Math.min(remaining, length - distance);
@@ -34275,7 +34277,15 @@ function strokeOutlines(paths, width, cap, join, miterLimit, dashArray = [], das
34275
34277
  let closed = subpath.closed;
34276
34278
  if (closed && points.length > 1 && Math.hypot(points[0][0] - points[points.length - 1][0], points[0][1] - points[points.length - 1][1]) <= 1e-14) points.pop();
34277
34279
  if (points.length < 3) closed = false;
34278
- if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
34280
+ if (points.length === 1 && cap === 2 && subpath.zeroLengthDash) {
34281
+ contour = [];
34282
+ const [x, y] = points[0];
34283
+ add(x - half, y - half);
34284
+ add(x + half, y - half);
34285
+ add(x + half, y + half);
34286
+ add(x - half, y + half);
34287
+ contours.push(contour);
34288
+ } else if (points.length === 1 && subpath.points.length > 1 && cap === 1) {
34279
34289
  contour = [];
34280
34290
  const [x, y] = points[0];
34281
34291
  addCap([x, y], [x + 1, y]);
@@ -35072,7 +35082,7 @@ function prepareStroke(path, scale) {
35072
35082
  }
35073
35083
  return { matrix, width, dashArray, dashPhase };
35074
35084
  }
35075
- function strokeEdges(path, pageHeight, scale) {
35085
+ function strokeContours(path, pageHeight, scale) {
35076
35086
  const stroke = prepareStroke(path, scale);
35077
35087
  if (!stroke) return [];
35078
35088
  const inverse = inverseStrokeMatrix(stroke.matrix);
@@ -35096,7 +35106,7 @@ function strokeEdges(path, pageHeight, scale) {
35096
35106
  stroke.dashArray?.map((value) => Math.max(0, value * strokeScale)),
35097
35107
  stroke.dashPhase * strokeScale
35098
35108
  );
35099
- return pathsToEdges(contours.map((points) => ({ points: points.map(toScreen), closed: true })));
35109
+ return contours.map((points) => points.map(toScreen));
35100
35110
  }
35101
35111
  function pathsToEdges(paths, closeSubpaths = false) {
35102
35112
  const edges = [];
@@ -35243,6 +35253,9 @@ function renderSoftMask(mask, displayList, scale) {
35243
35253
  }
35244
35254
  return bitmap;
35245
35255
  }
35256
+ function hasBlendModes(operations) {
35257
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
35258
+ }
35246
35259
  function renderDisplayListToBitmap(displayList, options = {}) {
35247
35260
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
35248
35261
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -35251,11 +35264,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
35251
35264
  const width = Math.max(1, Math.round(displayList.width * scale));
35252
35265
  const height = Math.max(1, Math.round(displayList.height * scale));
35253
35266
  const rgba = new Uint8Array(width * height * 4);
35267
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
35268
+ const transparent = options.transparent || deferBackground;
35254
35269
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
35255
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
35256
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
35257
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
35258
- const bgA = options.transparent ? 0 : 255;
35270
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
35271
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
35272
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
35273
+ const bgA = transparent ? 0 : 255;
35259
35274
  for (let i = 0; i < width * height; i++) {
35260
35275
  rgba[i * 4] = bgR;
35261
35276
  rgba[i * 4 + 1] = bgG;
@@ -35349,7 +35364,7 @@ function renderDisplayListToBitmap(displayList, options = {}) {
35349
35364
  if (path.strokeColor) {
35350
35365
  const rawSw = path.strokeWidth * scale * (path.strokeMatrix ? Math.hypot(path.strokeMatrix[0], path.strokeMatrix[1]) : 1);
35351
35366
  const strokeAlpha = options.thinLineMode === "shape" && rawSw < 1 ? (path.strokeAlpha ?? 1) * Math.max(0.25, rawSw) : path.strokeAlpha ?? 1;
35352
- const edges = strokeEdges(path, displayList.height, scale);
35367
+ const edges = pathsToEdges(strokeContours(path, displayList.height, scale).map((points) => ({ points, closed: true })));
35353
35368
  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;
35354
35369
  fillEdgesScanline4x4(
35355
35370
  rgba,
@@ -35432,6 +35447,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
35432
35447
  }
35433
35448
  }
35434
35449
  }
35450
+ if (deferBackground) {
35451
+ for (let i = 0; i < rgba.length; i += 4) {
35452
+ const alpha = rgba[i + 3] / 255;
35453
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
35454
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
35455
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
35456
+ rgba[i + 3] = 255;
35457
+ }
35458
+ }
35435
35459
  let result = { width, height, data: rgba };
35436
35460
  if (Math.abs(scaleX - scaleY) > 1e-6) {
35437
35461
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PdfDocument,
3
3
  renderPdfPageToPng
4
- } from "./chunk-KO4PXCNL.js";
4
+ } from "./chunk-2JQONXIY.js";
5
5
  import {
6
6
  init_buffer
7
7
  } from "./chunk-HX3SHTCE.js";
@@ -48,11 +48,11 @@ import {
48
48
  trimImage,
49
49
  unflattenImage,
50
50
  unpremultiplyRgbaImage
51
- } from "./chunk-SVL6HYQL.js";
51
+ } from "./chunk-A5S6M37L.js";
52
52
  import {
53
53
  PdfDocument,
54
54
  encodePng
55
- } from "./chunk-KO4PXCNL.js";
55
+ } from "./chunk-2JQONXIY.js";
56
56
  import {
57
57
  createLuaFilterCapability
58
58
  } from "./chunk-Y2KHC6TZ.js";