@embedpdf/engine-core 3.0.0-next.10 → 3.0.0-next.11

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 (45) hide show
  1. package/dist/{AnnotationListSnapshot-DDxHpJQU.d.cts → AnnotationListSnapshot-C1U3XUxP.d.cts} +310 -88
  2. package/dist/{AnnotationListSnapshot-DDxHpJQU.d.ts → AnnotationListSnapshot-C1U3XUxP.d.ts} +310 -88
  3. package/dist/{DocumentSecurityService-BV4_YXkU.d.cts → DocumentSecurityService-6rhztZlz.d.cts} +2 -2
  4. package/dist/{DocumentSecurityService-o9aeTHwT.d.ts → DocumentSecurityService-7nL9aY75.d.ts} +2 -2
  5. package/dist/{Engine-D9je6GdU.d.cts → Engine-CWnAKccD.d.ts} +15 -3
  6. package/dist/{Engine-DOoVem7_.d.ts → Engine-D3868xIU.d.cts} +15 -3
  7. package/dist/{builders-B_KufGJ9.js → builders-Cdz34nbF.js} +26 -2
  8. package/dist/builders-Cdz34nbF.js.map +1 -0
  9. package/dist/{builders-Cp_rlGob.cjs → builders-Do6_4KnS.cjs} +31 -1
  10. package/dist/builders-Do6_4KnS.cjs.map +1 -0
  11. package/dist/conformance.cjs +218 -7
  12. package/dist/conformance.cjs.map +1 -1
  13. package/dist/conformance.d.cts +8 -2
  14. package/dist/conformance.d.ts +8 -2
  15. package/dist/conformance.js +218 -7
  16. package/dist/conformance.js.map +1 -1
  17. package/dist/index.cjs +3 -2
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +3 -3
  21. package/dist/{resolver-DiPMTfcy.js → resolver-CHG4waXL.js} +2 -1
  22. package/dist/resolver-CHG4waXL.js.map +1 -0
  23. package/dist/{resolver-DAZWVoJL.cjs → resolver-D-jumvgM.cjs} +2 -1
  24. package/dist/resolver-D-jumvgM.cjs.map +1 -0
  25. package/dist/runtime.cjs +3 -2
  26. package/dist/runtime.d.cts +4 -4
  27. package/dist/runtime.d.ts +4 -4
  28. package/dist/runtime.js +3 -3
  29. package/dist/{schemas-D1pxEv3t.cjs → schemas-CS5iPpX5.cjs} +168 -80
  30. package/dist/schemas-CS5iPpX5.cjs.map +1 -0
  31. package/dist/{schemas-DAnu8tuW.js → schemas-XGrNVMDd.js} +157 -81
  32. package/dist/schemas-XGrNVMDd.js.map +1 -0
  33. package/dist/wire.cjs +43 -2
  34. package/dist/wire.cjs.map +1 -1
  35. package/dist/wire.d.cts +181 -8
  36. package/dist/wire.d.ts +181 -8
  37. package/dist/wire.js +39 -3
  38. package/dist/wire.js.map +1 -1
  39. package/package.json +1 -1
  40. package/dist/builders-B_KufGJ9.js.map +0 -1
  41. package/dist/builders-Cp_rlGob.cjs.map +0 -1
  42. package/dist/resolver-DAZWVoJL.cjs.map +0 -1
  43. package/dist/resolver-DiPMTfcy.js.map +0 -1
  44. package/dist/schemas-D1pxEv3t.cjs.map +0 -1
  45. package/dist/schemas-DAnu8tuW.js.map +0 -1
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_fold = require("./fold-C7I5GpBz.cjs");
3
3
  const require_PageInsertBlankInput = require("./PageInsertBlankInput-CzShuSJI.cjs");
4
4
  const require_AbortError = require("./AbortError-CRSooKsk.cjs");
5
- const require_schemas = require("./schemas-D1pxEv3t.cjs");
5
+ const require_schemas = require("./schemas-CS5iPpX5.cjs");
6
6
  //#region src/conformance/runMetadataConformance.ts
7
7
  /**
8
8
  * The conformance harness is transport-agnostic. It takes the test runner as
@@ -370,6 +370,13 @@ function emptyFlags() {
370
370
  }
371
371
  //#endregion
372
372
  //#region src/conformance/runActionsConformance.ts
373
+ /** The script payload rides only the javascript/rendition arms. */
374
+ function scriptOf(node) {
375
+ if (!node) return "";
376
+ if (node.type === "javascript") return node.script;
377
+ if (node.type === "rendition") return node.script ?? "";
378
+ return "";
379
+ }
373
380
  /** Action extraction parity. These tests assert data only; no script executes. */
374
381
  function runActionsConformance(runner, opts) {
375
382
  const { describe, test, beforeAll, afterAll, expect } = runner;
@@ -389,10 +396,10 @@ function runActionsConformance(runner, opts) {
389
396
  expect(require_schemas.DocumentActionsSnapshotSchema.safeParse(snapshot).success).toBe(true);
390
397
  expect(snapshot.openAction).toBeNull();
391
398
  expect(snapshot.willSave?.root?.type).toBe("javascript");
392
- expect(snapshot.willSave?.root?.script ?? "").toMatch(/Will Save/);
393
- expect(snapshot.didSave?.root?.script ?? "").toMatch(/Did Save/);
394
- expect(snapshot.willPrint?.root?.script ?? "").toMatch(/Will Print/);
395
- expect(snapshot.didPrint?.root?.script ?? "").toMatch(/Did Print/);
399
+ expect(scriptOf(snapshot.willSave?.root)).toMatch(/Will Save/);
400
+ expect(scriptOf(snapshot.didSave?.root)).toMatch(/Did Save/);
401
+ expect(scriptOf(snapshot.willPrint?.root)).toMatch(/Will Print/);
402
+ expect(scriptOf(snapshot.didPrint?.root)).toMatch(/Did Print/);
396
403
  const form = await doc.forms.list();
397
404
  expect(form.calculationOrder).toEqual([{
398
405
  kind: "objectNumber",
@@ -439,7 +446,7 @@ function runActionsConformance(runner, opts) {
439
446
  expect(link?.subtype).toBe("link");
440
447
  if (link?.subtype === "link") expect(link.target).toEqual({ kind: "javascript" });
441
448
  expect(link?.actions?.activate?.root?.type).toBe("javascript");
442
- expect(link?.actions?.activate?.root?.script ?? "").toMatch(/app\.alert/);
449
+ expect(scriptOf(link?.actions?.activate?.root)).toMatch(/app\.alert/);
443
450
  } finally {
444
451
  await doc.close();
445
452
  }
@@ -450,7 +457,7 @@ function runActionsConformance(runner, opts) {
450
457
  const form = await doc.forms.list();
451
458
  expect(form.fields).toHaveLength(1);
452
459
  expect(form.fields[0].actions?.format?.root?.type).toBe("javascript");
453
- expect(form.fields[0].actions?.format?.root?.script ?? "").toMatch(/AFDate_FormatEx/);
460
+ expect(scriptOf(form.fields[0].actions?.format?.root)).toMatch(/AFDate_FormatEx/);
454
461
  const page = (await doc.pages.list()).pages[0];
455
462
  const widget = (await doc.page(page.pageObjectNumber).annotations.list()).annotations[0];
456
463
  expect(widget.actions).toBe(void 0);
@@ -458,6 +465,210 @@ function runActionsConformance(runner, opts) {
458
465
  await doc.close();
459
466
  }
460
467
  });
468
+ test("carries interpreter payloads on every executable node", async () => {
469
+ const doc = await open(engine, opts, opts.fixtures.payloads);
470
+ try {
471
+ const page = (await doc.pages.list()).pages[0];
472
+ const snapshot = await doc.page(page.pageObjectNumber).annotations.list();
473
+ const pon = page.pageObjectNumber;
474
+ const rootOf = (nm) => {
475
+ const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
476
+ expect(Boolean(annotation)).toBe(true);
477
+ return annotation?.actions?.activate?.root ?? null;
478
+ };
479
+ const targetOf = (nm) => {
480
+ const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
481
+ return annotation?.subtype === "link" ? annotation.target : null;
482
+ };
483
+ expect(rootOf("goto-fitr")).toMatchObject({
484
+ type: "goto",
485
+ destination: {
486
+ kind: "fitR",
487
+ pageObjectNumber: pon,
488
+ left: 10,
489
+ bottom: 20,
490
+ right: 300,
491
+ top: 400
492
+ }
493
+ });
494
+ expect(targetOf("goto-fitr")).toMatchObject({
495
+ kind: "goto",
496
+ destination: { kind: "fitR" }
497
+ });
498
+ expect(rootOf("uri-map")).toMatchObject({
499
+ type: "uri",
500
+ uri: "https://example.test/map",
501
+ isMap: true
502
+ });
503
+ expect(rootOf("named-next")).toMatchObject({
504
+ type: "named",
505
+ name: "NextPage"
506
+ });
507
+ const mixed = rootOf("hide-mixed");
508
+ expect(mixed).toMatchObject({
509
+ type: "hide",
510
+ hide: false
511
+ });
512
+ const mixedTargets = mixed?.type === "hide" ? mixed.targets : [];
513
+ expect(mixedTargets).toHaveLength(2);
514
+ expect(mixedTargets[0]).toEqual({
515
+ kind: "name",
516
+ name: "note1"
517
+ });
518
+ expect(mixedTargets[1]?.kind === "objectNumber" && mixedTargets[1].objectNumber > 0).toBe(true);
519
+ expect(rootOf("hide-scalar")).toMatchObject({
520
+ type: "hide",
521
+ targets: [{
522
+ kind: "name",
523
+ name: "fieldB"
524
+ }],
525
+ hide: true
526
+ });
527
+ expect(rootOf("reset-include")).toMatchObject({
528
+ type: "reset-form",
529
+ fields: [{
530
+ kind: "name",
531
+ name: "calc1"
532
+ }],
533
+ exclude: true
534
+ });
535
+ expect(rootOf("reset-absent")).toMatchObject({
536
+ type: "reset-form",
537
+ fields: null,
538
+ exclude: true
539
+ });
540
+ expect(rootOf("reset-empty")).toMatchObject({
541
+ type: "reset-form",
542
+ fields: [],
543
+ exclude: false
544
+ });
545
+ expect(rootOf("submit-urlspec")).toMatchObject({
546
+ type: "submit-form",
547
+ payload: {
548
+ url: "https://uf.example.test/submit",
549
+ fields: [{
550
+ kind: "name",
551
+ name: "parent"
552
+ }],
553
+ flags: {
554
+ raw: 0,
555
+ exclude: false,
556
+ format: "fdf",
557
+ method: "post"
558
+ }
559
+ }
560
+ });
561
+ expect(rootOf("submit-compat-xfdf")).toMatchObject({
562
+ type: "submit-form",
563
+ payload: {
564
+ url: "https://example.test/xfdf",
565
+ fields: [{
566
+ kind: "name",
567
+ name: "noexport"
568
+ }, {
569
+ kind: "name",
570
+ name: "plain"
571
+ }],
572
+ flags: {
573
+ raw: 35,
574
+ exclude: true,
575
+ includeNoValueFields: true,
576
+ format: "xfdf",
577
+ method: "post"
578
+ },
579
+ charSet: "utf-8"
580
+ }
581
+ });
582
+ expect(rootOf("submit-pdf-get")).toMatchObject({
583
+ type: "submit-form",
584
+ payload: {
585
+ url: "https://example.test/pdf",
586
+ fields: null,
587
+ flags: {
588
+ raw: 264,
589
+ format: "pdf",
590
+ method: "get"
591
+ }
592
+ }
593
+ });
594
+ expect(rootOf("launch-app")).toMatchObject({
595
+ type: "launch",
596
+ filePath: "app.exe"
597
+ });
598
+ expect(rootOf("gotor-file")).toMatchObject({
599
+ type: "goto-remote",
600
+ filePath: "other.pdf"
601
+ });
602
+ const chain = rootOf("chain-js-goto-hide");
603
+ expect(chain).toMatchObject({
604
+ type: "javascript",
605
+ script: "app.alert('chain');"
606
+ });
607
+ expect(chain?.next[0]).toMatchObject({
608
+ type: "goto",
609
+ destination: {
610
+ kind: "xyz",
611
+ pageObjectNumber: pon,
612
+ left: 5,
613
+ top: 10,
614
+ zoom: 1.25
615
+ }
616
+ });
617
+ expect(chain?.next[0]?.next[0]).toMatchObject({
618
+ type: "hide",
619
+ targets: [{
620
+ kind: "name",
621
+ name: "note1"
622
+ }],
623
+ hide: true
624
+ });
625
+ } finally {
626
+ await doc.close();
627
+ }
628
+ });
629
+ test("degrades unreadable payloads to unknown with payload-dropped", async () => {
630
+ const doc = await open(engine, opts, opts.fixtures.payloads);
631
+ try {
632
+ const page = (await doc.pages.list()).pages[0];
633
+ const snapshot = await doc.page(page.pageObjectNumber).annotations.list();
634
+ for (const [nm, subtype] of [
635
+ ["goto-malformed", "GoTo"],
636
+ ["hide-partial", "Hide"],
637
+ ["submit-not-url", "SubmitForm"],
638
+ ["submit-no-f", "SubmitForm"]
639
+ ]) {
640
+ const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
641
+ const tree = annotation?.actions?.activate;
642
+ expect(tree?.root).toMatchObject({
643
+ type: "unknown",
644
+ subtype
645
+ });
646
+ expect(tree?.warnings ?? []).toContain("payload-dropped");
647
+ if (annotation?.subtype === "link") expect(annotation.target).toEqual({ kind: "unsupported" });
648
+ }
649
+ } finally {
650
+ await doc.close();
651
+ }
652
+ });
653
+ test("reads a destination-form /OpenAction as openDestination", async () => {
654
+ const doc = await open(engine, opts, opts.fixtures.openDestination);
655
+ try {
656
+ expect(Boolean(doc.actions)).toBe(true);
657
+ const snapshot = await doc.actions.read();
658
+ expect(require_schemas.DocumentActionsSnapshotSchema.safeParse(snapshot).success).toBe(true);
659
+ expect(snapshot.openAction).toBeNull();
660
+ const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
661
+ expect(snapshot.openDestination).toEqual({
662
+ kind: "xyz",
663
+ pageObjectNumber: pon,
664
+ left: 10,
665
+ top: 700,
666
+ zoom: 1.5
667
+ });
668
+ } finally {
669
+ await doc.close();
670
+ }
671
+ });
461
672
  });
462
673
  }
463
674
  async function open(engine, opts, fixture) {