@poe-platform/safe-bash 0.1.759 → 0.1.761

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.
Files changed (38) hide show
  1. package/dist/image-ast/index.browser.js +74 -17
  2. package/dist/image-ast/index.js +74 -17
  3. package/dist/pdf-ast/ast.d.ts +8 -3
  4. package/dist/pdf-ast/index.js +80 -20
  5. package/dist/safe-bash/chunks/{chunk-AYPUGSOV.js → chunk-CRQDMBQA.js} +123 -8
  6. package/dist/safe-bash/command-chunks/{chunk-HVEAK3OS.js → chunk-6VX5ZQL5.js} +2 -2
  7. package/dist/safe-bash/command-chunks/{chunk-7JA44PVV.js → chunk-GR725WRX.js} +1 -1
  8. package/dist/safe-bash/command-chunks/{chunk-BAUGDXLZ.js → chunk-OSMLVM7P.js} +79 -17
  9. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -1
  10. package/dist/safe-bash/commands/htmlq/index.js +4 -1
  11. package/dist/safe-bash/commands/python/index.browser.js +1 -1
  12. package/dist/safe-bash/commands/python/index.d.ts +1 -1
  13. package/dist/safe-bash/commands/python/llm-capability.d.ts +7 -3
  14. package/dist/safe-bash/commands/python/llm-capability.js +149 -10
  15. package/dist/safe-bash/core.browser.js +4 -3
  16. package/dist/safe-bash/shell/runtime.js +1 -1
  17. package/dist/safe-bash-command-ffmpeg/index.js +3125 -3085
  18. package/dist/safe-bash-command-gh/index.js +128 -27
  19. package/dist/safe-bash-command-git/LICENSE +21 -0
  20. package/dist/safe-bash-command-imagemagick/index.js +2 -2
  21. package/dist/safe-bash-command-pandoc/command.js +3 -3
  22. package/dist/safe-bash-command-pandoc/index.js +3 -3
  23. package/dist/safe-bash-command-pdfimages/index.js +74 -17
  24. package/dist/safe-bash-command-pdfinfo/index.js +78 -20
  25. package/dist/safe-bash-command-pdftk/index.js +74 -17
  26. package/dist/safe-bash-command-pdftoppm/index.js +78 -20
  27. package/dist/safe-bash-command-pdftotext/index.js +74 -17
  28. package/dist/safe-bash-command-qpdf/index.js +74 -17
  29. package/dist/safe-bash-command-sips/index.js +2 -2
  30. package/dist/safe-bash-command-soffice/index.js +1 -1
  31. package/dist/safe-bash-command-ssconvert/index.js +74 -17
  32. package/dist/safe-bash-command-wkhtmltopdf/index.js +74 -17
  33. package/dist/safe-bash-io-engine/internal.d.ts +2 -2
  34. package/dist/safe-bash-mcp/index.d.ts +1 -1
  35. package/package.json +2 -2
  36. package/third-party/pdf-ast/THIRD_PARTY_NOTICES.md +30 -0
  37. package/third-party/pdf-ast/licenses/AGG-2.3.txt +7 -0
  38. package/third-party/pdf-ast/licenses/MIT.txt +21 -0
@@ -2488,6 +2488,19 @@ function formatCommandOutputSync(options) {
2488
2488
  }
2489
2489
 
2490
2490
  // packages/safe-bash-command-gh/dist/commands/issue.js
2491
+ function extractRepoAndSelectorFromIssueArg(selector, explicitRepoFlag) {
2492
+ if (selector?.startsWith("https://") || selector?.startsWith("http://")) {
2493
+ const url = new URL(selector);
2494
+ const parts = url.pathname.split("/");
2495
+ if (parts.length === 5 && parts[1] && parts[2] && parts[3] === "issues" && parts[4] && Number.isSafeInteger(Number(parts[4])) && Number(parts[4]) > 0) {
2496
+ return {
2497
+ repoOverride: explicitRepoFlag ?? `${url.host}/${parts[1]}/${parts[2]}`,
2498
+ selector: parts[4]
2499
+ };
2500
+ }
2501
+ }
2502
+ return { repoOverride: explicitRepoFlag, selector };
2503
+ }
2491
2504
  var ISSUE_JSON_FIELDS = [
2492
2505
  "assignees",
2493
2506
  "author",
@@ -2643,9 +2656,10 @@ async function handleIssueCommand(env, rawArgs) {
2643
2656
  if (subcommand === "view") {
2644
2657
  const schemas = [{ short: "c", long: "comments", type: "boolean" }];
2645
2658
  const parsed = parseCommandArgs(restArgs, schemas);
2646
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2659
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2660
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2647
2661
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2648
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2662
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2649
2663
  if (getBoolFlag(parsed, "web")) {
2650
2664
  if (openBrowser)
2651
2665
  await openBrowser(issue.url);
@@ -2691,9 +2705,10 @@ ${c.body}
2691
2705
  { short: "r", long: "reason", type: "string" }
2692
2706
  ];
2693
2707
  const parsed = parseCommandArgs(restArgs, schemas);
2694
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2708
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2709
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2695
2710
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2696
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2711
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2697
2712
  const commentText = getStringFlag(parsed, "comment");
2698
2713
  if (commentText) {
2699
2714
  const id = backend.nextId();
@@ -2726,14 +2741,54 @@ ${c.body}
2726
2741
  if (subcommand === "comment") {
2727
2742
  const schemas = [
2728
2743
  { short: "b", long: "body", type: "string" },
2729
- { short: "F", long: "body-file", type: "string" }
2744
+ { short: "F", long: "body-file", type: "string" },
2745
+ { long: "edit-last", type: "boolean" },
2746
+ { long: "delete-last", type: "boolean" },
2747
+ { long: "create-if-none", type: "boolean" }
2730
2748
  ];
2731
2749
  const parsed = parseCommandArgs(restArgs, schemas);
2732
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2750
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2751
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2733
2752
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2734
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2753
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2754
+ const activeUser = backend.getActiveUser();
2755
+ let lastIndex = -1;
2756
+ for (let index = issue.comments.length - 1; index >= 0; index--) {
2757
+ if (issue.comments[index].author.login === activeUser) {
2758
+ lastIndex = index;
2759
+ break;
2760
+ }
2761
+ }
2762
+ if (getBoolFlag(parsed, "delete-last")) {
2763
+ if (lastIndex < 0) {
2764
+ await writeErr("no comments found for current user\n");
2765
+ return 1;
2766
+ }
2767
+ issue.comments.splice(lastIndex, 1);
2768
+ issue.updatedAt = backend.isoNow();
2769
+ await writeOut("Comment deleted\n");
2770
+ return 0;
2771
+ }
2735
2772
  const bodyFile = getStringFlag(parsed, "body-file");
2736
2773
  const body = bodyFile !== void 0 ? bodyFile === "-" ? stdinText : decodeUtf8(await context.fs.readFile(resolvePath2(context.cwd, bodyFile), { signal: context.signal })) : getStringFlag(parsed, "body") ?? "";
2774
+ if (!body) {
2775
+ await writeErr("body cannot be blank; provide -b/--body or -F/--body-file\n");
2776
+ return 1;
2777
+ }
2778
+ if (getBoolFlag(parsed, "edit-last")) {
2779
+ if (lastIndex >= 0) {
2780
+ const previous = issue.comments[lastIndex];
2781
+ issue.comments[lastIndex] = { ...previous, body, updatedAt: backend.isoNow() };
2782
+ issue.updatedAt = issue.comments[lastIndex].updatedAt;
2783
+ await writeOut(`${previous.url}
2784
+ `);
2785
+ return 0;
2786
+ }
2787
+ if (!getBoolFlag(parsed, "create-if-none")) {
2788
+ await writeErr("no comments found for current user to edit\n");
2789
+ return 1;
2790
+ }
2791
+ }
2737
2792
  const id = backend.nextId();
2738
2793
  const ts = backend.isoNow();
2739
2794
  const c = {
@@ -2745,6 +2800,7 @@ ${c.body}
2745
2800
  url: `${issue.url}#issuecomment-${id}`
2746
2801
  };
2747
2802
  issue.comments.push(c);
2803
+ issue.updatedAt = ts;
2748
2804
  await writeOut(`${c.url}
2749
2805
  `);
2750
2806
  return 0;
@@ -2753,19 +2809,26 @@ ${c.body}
2753
2809
  const schemas = [
2754
2810
  { short: "t", long: "title", type: "string" },
2755
2811
  { short: "b", long: "body", type: "string" },
2812
+ { short: "F", long: "body-file", type: "string" },
2813
+ { short: "m", long: "milestone", type: "string" },
2814
+ { long: "remove-milestone", type: "boolean" },
2815
+ { long: "add-project", type: "string[]" },
2816
+ { long: "remove-project", type: "string[]" },
2756
2817
  { long: "add-label", type: "string[]" },
2757
2818
  { long: "remove-label", type: "string[]" },
2758
2819
  { long: "add-assignee", type: "string[]" },
2759
2820
  { long: "remove-assignee", type: "string[]" }
2760
2821
  ];
2761
2822
  const parsed = parseCommandArgs(restArgs, schemas);
2762
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2823
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2824
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2763
2825
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2764
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2826
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2765
2827
  const title = getStringFlag(parsed, "title");
2766
2828
  if (title !== void 0)
2767
2829
  issue.title = title;
2768
- const body = getStringFlag(parsed, "body");
2830
+ const bodyFile = getStringFlag(parsed, "body-file");
2831
+ const body = bodyFile !== void 0 ? bodyFile === "-" ? stdinText : decodeUtf8(await context.fs.readFile(resolvePath2(context.cwd, bodyFile), { signal: context.signal })) : getStringFlag(parsed, "body");
2769
2832
  if (body !== void 0)
2770
2833
  issue.body = body;
2771
2834
  for (const lblName of getStringArrayFlag(parsed, "add-label")) {
@@ -2783,15 +2846,38 @@ ${c.body}
2783
2846
  if (rmLabels.length > 0) {
2784
2847
  issue.labels = issue.labels.filter((l) => !rmLabels.includes(l.name.toLowerCase()));
2785
2848
  }
2849
+ for (const login of getStringArrayFlag(parsed, "add-assignee")) {
2850
+ const resolved = login === "@me" ? backend.getActiveUser() : login;
2851
+ if (!issue.assignees.some((a) => a.login.toLowerCase() === resolved.toLowerCase())) {
2852
+ issue.assignees.push({ login: resolved });
2853
+ }
2854
+ }
2855
+ const removeAssignees = getStringArrayFlag(parsed, "remove-assignee").map((login) => (login === "@me" ? backend.getActiveUser() : login).toLowerCase());
2856
+ issue.assignees = issue.assignees.filter((a) => !removeAssignees.includes(a.login.toLowerCase()));
2857
+ const milestone = getStringFlag(parsed, "milestone");
2858
+ if (getBoolFlag(parsed, "remove-milestone")) {
2859
+ issue.milestone = null;
2860
+ } else if (milestone !== void 0) {
2861
+ issue.milestone = { id: backend.nextId(), number: 1, title: milestone, description: "", state: "open" };
2862
+ }
2863
+ for (const title2 of getStringArrayFlag(parsed, "add-project")) {
2864
+ if (!issue.projectItems.some((project) => project.title === title2)) {
2865
+ issue.projectItems.push({ title: title2 });
2866
+ }
2867
+ }
2868
+ const removeProjects = getStringArrayFlag(parsed, "remove-project");
2869
+ issue.projectItems = issue.projectItems.filter((project) => !removeProjects.includes(project.title));
2870
+ issue.updatedAt = backend.isoNow();
2786
2871
  await writeOut(`${issue.url}
2787
2872
  `);
2788
2873
  return 0;
2789
2874
  }
2790
2875
  if (subcommand === "delete") {
2791
2876
  const parsed = parseCommandArgs(restArgs, []);
2792
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2877
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2878
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2793
2879
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2794
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2880
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2795
2881
  repo.issues.delete(issue.number);
2796
2882
  await writeOut(`\u2713 Deleted issue #${issue.number}
2797
2883
  `);
@@ -2799,9 +2885,10 @@ ${c.body}
2799
2885
  }
2800
2886
  if (subcommand === "pin" || subcommand === "unpin") {
2801
2887
  const parsed = parseCommandArgs(restArgs, []);
2802
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2888
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2889
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2803
2890
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2804
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2891
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2805
2892
  issue.isPinned = subcommand === "pin";
2806
2893
  await writeOut(`\u2713 ${subcommand === "pin" ? "Pinned" : "Unpinned"} issue #${issue.number}
2807
2894
  `);
@@ -2809,9 +2896,10 @@ ${c.body}
2809
2896
  }
2810
2897
  if (subcommand === "lock" || subcommand === "unlock") {
2811
2898
  const parsed = parseCommandArgs(restArgs, [{ short: "r", long: "reason", type: "string" }]);
2812
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2899
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2900
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2813
2901
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2814
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2902
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2815
2903
  issue.locked = subcommand === "lock";
2816
2904
  await writeOut(`\u2713 ${subcommand === "lock" ? "Locked" : "Unlocked"} issue #${issue.number}
2817
2905
  `);
@@ -2819,9 +2907,10 @@ ${c.body}
2819
2907
  }
2820
2908
  if (subcommand === "transfer") {
2821
2909
  const parsed = parseCommandArgs(restArgs, []);
2822
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2910
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2911
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2823
2912
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2824
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2913
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2825
2914
  const destSpec = parsed.positionals[1];
2826
2915
  if (!destSpec) {
2827
2916
  await writeErr("destination repository required\n");
@@ -2848,9 +2937,10 @@ ${c.body}
2848
2937
  { short: "l", long: "list", type: "boolean" }
2849
2938
  ];
2850
2939
  const parsed = parseCommandArgs(restArgs, schemas);
2851
- const coords = await resolveRepoFromContext(context, parsed.repoFlag, backend.defaultHost, backend.getActiveUser());
2940
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
2941
+ const coords = await resolveRepoFromContext(context, repoOverride, backend.defaultHost, backend.getActiveUser());
2852
2942
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
2853
- const issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
2943
+ const issue = backend.resolveIssue(repo, selector ?? "1");
2854
2944
  if (getBoolFlag(parsed, "list")) {
2855
2945
  await writeOut(issue.linkedBranches.map((b) => `${b} ${repo.url}/tree/${b}`).join("\n") + (issue.linkedBranches.length > 0 ? "\n" : ""));
2856
2946
  return 0;
@@ -8902,13 +8992,14 @@ Copyright (c) ${coords.owner}
8902
8992
  const parsed = parseCommandArgs(rest, [{ short: "c", long: "comments", type: "boolean" }]);
8903
8993
  if (parsed.help || getBoolFlag(parsed, "web"))
8904
8994
  return void 0;
8905
- const coords = resolveRepoSync(parsed.repoFlag, env, backend.defaultHost, backend.getActiveUser(), cwd, readFileSync);
8995
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
8996
+ const coords = resolveRepoSync(repoOverride, env, backend.defaultHost, backend.getActiveUser(), cwd, readFileSync);
8906
8997
  if (!coords)
8907
8998
  return void 0;
8908
8999
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
8909
9000
  let issue;
8910
9001
  try {
8911
- issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
9002
+ issue = backend.resolveIssue(repo, selector ?? "1");
8912
9003
  } catch {
8913
9004
  return void 0;
8914
9005
  }
@@ -8944,13 +9035,14 @@ ${c.body}
8944
9035
  { short: "c", long: "comment", type: "string" },
8945
9036
  { short: "r", long: "reason", type: "string" }
8946
9037
  ]);
8947
- const coords = resolveRepoSync(parsed.repoFlag, env, backend.defaultHost, backend.getActiveUser(), cwd, readFileSync);
9038
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
9039
+ const coords = resolveRepoSync(repoOverride, env, backend.defaultHost, backend.getActiveUser(), cwd, readFileSync);
8948
9040
  if (!coords)
8949
9041
  return void 0;
8950
9042
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
8951
9043
  let issue;
8952
9044
  try {
8953
- issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
9045
+ issue = backend.resolveIssue(repo, selector ?? "1");
8954
9046
  } catch {
8955
9047
  return void 0;
8956
9048
  }
@@ -8980,17 +9072,26 @@ ${c.body}
8980
9072
  `;
8981
9073
  }
8982
9074
  if (sub === "comment") {
8983
- const parsed = parseCommandArgs(rest, [{ short: "b", long: "body", type: "string" }]);
9075
+ const parsed = parseCommandArgs(rest, [
9076
+ { short: "b", long: "body", type: "string" },
9077
+ { short: "F", long: "body-file", type: "string" },
9078
+ { long: "edit-last", type: "boolean" },
9079
+ { long: "delete-last", type: "boolean" },
9080
+ { long: "create-if-none", type: "boolean" }
9081
+ ]);
9082
+ if (["body-file", "edit-last", "delete-last", "create-if-none"].some((flag) => parsed.flags.has(flag)))
9083
+ return void 0;
8984
9084
  const body = getStringFlag(parsed, "body");
8985
9085
  if (body === void 0)
8986
9086
  return void 0;
8987
- const coords = resolveRepoSync(parsed.repoFlag, env, backend.defaultHost, backend.getActiveUser(), cwd, readFileSync);
9087
+ const { repoOverride, selector } = extractRepoAndSelectorFromIssueArg(parsed.positionals[0], parsed.repoFlag);
9088
+ const coords = resolveRepoSync(repoOverride, env, backend.defaultHost, backend.getActiveUser(), cwd, readFileSync);
8988
9089
  if (!coords)
8989
9090
  return void 0;
8990
9091
  const repo = backend.getOrCreateRepo(coords.owner, coords.name);
8991
9092
  let issue;
8992
9093
  try {
8993
- issue = backend.resolveIssue(repo, parsed.positionals[0] ?? "1");
9094
+ issue = backend.resolveIssue(repo, selector ?? "1");
8994
9095
  } catch {
8995
9096
  return void 0;
8996
9097
  }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Poe Platform
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -28,8 +28,8 @@ import {
28
28
  thresholdImage,
29
29
  tintImage,
30
30
  trimImage
31
- } from "../safe-bash/command-chunks/chunk-7JA44PVV.js";
32
- import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
31
+ } from "../safe-bash/command-chunks/chunk-GR725WRX.js";
32
+ import "../safe-bash/command-chunks/chunk-OSMLVM7P.js";
33
33
  import {
34
34
  init_buffer
35
35
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -2,11 +2,11 @@ import {
2
2
  createPandocCommand,
3
3
  createPandocCommands,
4
4
  pandocCommands
5
- } from "../safe-bash/command-chunks/chunk-HVEAK3OS.js";
5
+ } from "../safe-bash/command-chunks/chunk-6VX5ZQL5.js";
6
6
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
7
7
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
8
- import "../safe-bash/command-chunks/chunk-7JA44PVV.js";
9
- import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
8
+ import "../safe-bash/command-chunks/chunk-GR725WRX.js";
9
+ import "../safe-bash/command-chunks/chunk-OSMLVM7P.js";
10
10
  import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
11
11
  import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
12
12
  import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
@@ -21,11 +21,11 @@ import {
21
21
  readDocument,
22
22
  resolveConversionArgs,
23
23
  writeDocument
24
- } from "../safe-bash/command-chunks/chunk-HVEAK3OS.js";
24
+ } from "../safe-bash/command-chunks/chunk-6VX5ZQL5.js";
25
25
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
26
26
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
27
- import "../safe-bash/command-chunks/chunk-7JA44PVV.js";
28
- import "../safe-bash/command-chunks/chunk-BAUGDXLZ.js";
27
+ import "../safe-bash/command-chunks/chunk-GR725WRX.js";
28
+ import "../safe-bash/command-chunks/chunk-OSMLVM7P.js";
29
29
  import {
30
30
  createLuaFilterCapability
31
31
  } from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
@@ -36259,7 +36259,7 @@ function evaluateContentStreamToDisplayList(params) {
36259
36259
  const [x, y] = transformPoint(st.ctm, seg.x, seg.y);
36260
36260
  transformedSegments.push({ kind: "cubic", x1, y1, x2, y2, x, y });
36261
36261
  } else if (seg.kind === "rect") {
36262
- if (hasRotOrShear) {
36262
+ if (hasRotOrShear || seg.width * st.ctm[0] < 0 || seg.height * st.ctm[3] < 0) {
36263
36263
  const [p0x, p0y] = transformPoint(st.ctm, seg.x, seg.y);
36264
36264
  const [p1x, p1y] = transformPoint(st.ctm, seg.x + seg.width, seg.y);
36265
36265
  const [p2x, p2y] = transformPoint(st.ctm, seg.x + seg.width, seg.y + seg.height);
@@ -36292,7 +36292,12 @@ function evaluateContentStreamToDisplayList(params) {
36292
36292
  transformedSegments.push({ kind: "close" });
36293
36293
  }
36294
36294
  }
36295
- if (node.clip && transformedSegments.length > 0) {
36295
+ const applyClip = () => {
36296
+ if (!node.clip) return;
36297
+ st.clipPaths = [...st.clipPaths ?? [], {
36298
+ segments: transformedSegments,
36299
+ fillRule: node.clip === "W*" ? "evenodd" : "nonzero"
36300
+ }];
36296
36301
  let cMinX = Infinity, cMinY = Infinity, cMaxX = -Infinity, cMaxY = -Infinity;
36297
36302
  for (const s of transformedSegments) {
36298
36303
  if (s.kind === "move" || s.kind === "line") {
@@ -36320,8 +36325,11 @@ function evaluateContentStreamToDisplayList(params) {
36320
36325
  Math.min(st.clipRect[3], cMaxY)
36321
36326
  ] : [cMinX, cMinY, cMaxX, cMaxY];
36322
36327
  }
36328
+ };
36329
+ if (node.paint === "n") {
36330
+ applyClip();
36331
+ break;
36323
36332
  }
36324
- if (node.paint === "n") break;
36325
36333
  const isFill = ["f", "F", "f*", "B", "B*", "b", "b*"].includes(node.paint);
36326
36334
  const isStroke = ["S", "s", "B", "B*", "b", "b*"].includes(node.paint);
36327
36335
  let evaluatedFillPattern = false;
@@ -36454,7 +36462,10 @@ function evaluateContentStreamToDisplayList(params) {
36454
36462
  }
36455
36463
  }
36456
36464
  }
36457
- if (evaluatedFillPattern && !isStroke) break;
36465
+ if (evaluatedFillPattern && !isStroke) {
36466
+ applyClip();
36467
+ break;
36468
+ }
36458
36469
  const fillRule = node.paint.includes("*") ? "evenodd" : "nonzero";
36459
36470
  const ctmScale = Math.max(1e-6, Math.hypot(st.ctm[0], st.ctm[1]));
36460
36471
  const scaledStrokeWidth = st.strokeWidth === 0 ? 0 : st.strokeWidth * ctmScale;
@@ -36474,6 +36485,7 @@ function evaluateContentStreamToDisplayList(params) {
36474
36485
  ...st.dashPhase !== void 0 ? { dashPhase: st.dashPhase } : {},
36475
36486
  ...st.clipRect ? { clipRect: [...st.clipRect] } : {}
36476
36487
  } });
36488
+ applyClip();
36477
36489
  break;
36478
36490
  }
36479
36491
  case "xobject": {
@@ -39008,6 +39020,39 @@ function createTrueTypeFontHandle(truetype) {
39008
39020
  }
39009
39021
  };
39010
39022
  }
39023
+ function flattenCubic(x1, y1, x2, y2, x3, y3, x4, y4) {
39024
+ const points = [[x1, y1]];
39025
+ const subdivide = (ax, ay, bx, by, cx, cy, dx, dy, level) => {
39026
+ if (level > 16) return;
39027
+ const abx = (ax + bx) / 2, aby = (ay + by) / 2;
39028
+ const bcx = (bx + cx) / 2, bcy = (by + cy) / 2;
39029
+ const cdx = (cx + dx) / 2, cdy = (cy + dy) / 2;
39030
+ const abcx = (abx + bcx) / 2, abcy = (aby + bcy) / 2;
39031
+ const bcdx = (bcx + cdx) / 2, bcdy = (bcy + cdy) / 2;
39032
+ const midx = (abcx + bcdx) / 2, midy = (abcy + bcdy) / 2;
39033
+ const chordX = dx - ax, chordY = dy - ay;
39034
+ const d2 = Math.abs((bx - dx) * chordY - (by - dy) * chordX);
39035
+ const d3 = Math.abs((cx - dx) * chordY - (cy - dy) * chordX);
39036
+ const significant2 = d2 > 1e-30, significant3 = d3 > 1e-30;
39037
+ if (!significant2 && !significant3) {
39038
+ if (Math.abs(ax + cx - 2 * bx) + Math.abs(ay + cy - 2 * by) + Math.abs(bx + dx - 2 * cx) + Math.abs(by + dy - 2 * cy) <= 4) {
39039
+ points.push([midx, midy]);
39040
+ return;
39041
+ }
39042
+ } else {
39043
+ const distance = (significant2 ? d2 : 0) + (significant3 ? d3 : 0);
39044
+ if (distance * distance <= 0.25 * (chordX * chordX + chordY * chordY)) {
39045
+ points.push([bcx, bcy]);
39046
+ return;
39047
+ }
39048
+ }
39049
+ subdivide(ax, ay, abx, aby, abcx, abcy, midx, midy, level + 1);
39050
+ subdivide(midx, midy, bcdx, bcdy, cdx, cdy, dx, dy, level + 1);
39051
+ };
39052
+ subdivide(x1, y1, x2, y2, x3, y3, x4, y4, 0);
39053
+ points.push([x4, y4]);
39054
+ return points;
39055
+ }
39011
39056
  function encodePng(bitmap) {
39012
39057
  return encodeRgbaToPng(bitmap.width, bitmap.height, bitmap.data);
39013
39058
  }
@@ -39925,14 +39970,11 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
39925
39970
  const [p1x, p1y] = toScreen(seg.x1, seg.y1);
39926
39971
  const [p2x, p2y] = toScreen(seg.x2, seg.y2);
39927
39972
  const [p3x, p3y] = toScreen(seg.x, seg.y);
39928
- const steps = 12;
39973
+ const points = flattenCubic(curX, curY, p1x, p1y, p2x, p2y, p3x, p3y);
39929
39974
  let px = curX;
39930
39975
  let py = curY;
39931
- for (let s = 1; s <= steps; s++) {
39932
- const t = s / steps;
39933
- const mt = 1 - t;
39934
- const qx = mt * mt * mt * curX + 3 * mt * mt * t * p1x + 3 * mt * t * t * p2x + t * t * t * p3x;
39935
- const qy = mt * mt * mt * curY + 3 * mt * mt * t * p1y + 3 * mt * t * t * p2y + t * t * t * p3y;
39976
+ for (let i = 1; i < points.length; i++) {
39977
+ const [qx, qy] = points[i];
39936
39978
  edges.push({ x0: px, y0: py, x1: qx, y1: qy });
39937
39979
  px = qx;
39938
39980
  py = qy;
@@ -39951,8 +39993,8 @@ function segmentsToScreenEdges(segments, pageHeight, scale, closeSubpaths = fals
39951
39993
  if (closeSubpaths && hasOpenSubpath && (curX !== startX || curY !== startY)) {
39952
39994
  edges.push({ x0: curX, y0: curY, x1: startX, y1: startY });
39953
39995
  }
39954
- const [rx0, ry0] = toScreen(seg.x, seg.y + seg.height);
39955
- const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y);
39996
+ const [rx0, ry0] = toScreen(seg.x, seg.y);
39997
+ const [rx1, ry1] = toScreen(seg.x + seg.width, seg.y + seg.height);
39956
39998
  edges.push(
39957
39999
  { x0: rx0, y0: ry0, x1: rx1, y1: ry0 },
39958
40000
  { x0: rx1, y0: ry0, x1: rx1, y1: ry1 },
@@ -40095,21 +40137,24 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40095
40137
  }
40096
40138
  const aaVec = options.antialiasVector !== false;
40097
40139
  const aaTxt = options.antialiasText !== false;
40098
- const clipMasks = /* @__PURE__ */ new Map();
40140
+ let cachedClips;
40141
+ let cachedClipMask;
40099
40142
  const imageClipMasks = /* @__PURE__ */ new Map();
40100
40143
  for (const original of paintOperations(displayList)) {
40101
40144
  if (original.kind === "glyph" && (original.value.renderMode === 3 || !original.value.outline && !original.value.unicode.trim())) continue;
40102
40145
  const operation = original.kind === "glyph" ? { kind: "path", value: glyphPaint(original.value) } : original;
40103
40146
  const clips = original.value.clipPaths;
40104
- let clipMask = clips ? clipMasks.get(clips) : void 0;
40147
+ let clipMask = clips && clips === cachedClips ? cachedClipMask : void 0;
40105
40148
  if (clips && !clipMask) {
40106
40149
  clipMask = new Uint8Array(width * height * 4).fill(255);
40107
- for (const segments of clips) {
40150
+ for (const clip of clips) {
40151
+ const { segments, fillRule } = "segments" in clip ? clip : { segments: clip, fillRule: "nonzero" };
40108
40152
  const layer = new Uint8Array(width * height * 4);
40109
- fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 });
40153
+ fillEdgesScanline4x4(layer, width, height, segmentsToScreenEdges(segments, displayList.height, scale, true), { r: 1, g: 1, b: 1 }, 1, fillRule);
40110
40154
  for (let i = 3; i < layer.length; i += 4) clipMask[i] = Math.round(clipMask[i] * layer[i] / 255);
40111
40155
  }
40112
- clipMasks.set(clips, clipMask);
40156
+ cachedClips = clips;
40157
+ cachedClipMask = clipMask;
40113
40158
  }
40114
40159
  const imageClips = original.value.clipImages;
40115
40160
  if (imageClips) {
@@ -41258,3 +41303,15 @@ export {
41258
41303
  * Copyright 2017 Mozilla Foundation. Licensed under Apache-2.0.
41259
41304
  * See licenses/PDFJS-APACHE-2.0.txt and THIRD_PARTY_NOTICES.md.
41260
41305
  */
41306
+ /*!
41307
+ * Anti-Grain Geometry - Version 2.3
41308
+ * Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
41309
+ *
41310
+ * Permission to copy, use, modify, sell and distribute this software
41311
+ * is granted provided this copyright notice appears in all copies.
41312
+ * This software is provided "as is" without express or implied
41313
+ * warranty, and with no claim as to its suitability for any purpose.
41314
+ *
41315
+ * Adapted from PDFium third_party/agg23/agg_curves.cpp, curve4_div.
41316
+ * See THIRD_PARTY_NOTICES.md for the pinned revision and adaptations.
41317
+ */