@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.
- package/dist/{AnnotationListSnapshot-DDxHpJQU.d.cts → AnnotationListSnapshot-C1U3XUxP.d.cts} +310 -88
- package/dist/{AnnotationListSnapshot-DDxHpJQU.d.ts → AnnotationListSnapshot-C1U3XUxP.d.ts} +310 -88
- package/dist/{DocumentSecurityService-BV4_YXkU.d.cts → DocumentSecurityService-6rhztZlz.d.cts} +2 -2
- package/dist/{DocumentSecurityService-o9aeTHwT.d.ts → DocumentSecurityService-7nL9aY75.d.ts} +2 -2
- package/dist/{Engine-D9je6GdU.d.cts → Engine-CWnAKccD.d.ts} +15 -3
- package/dist/{Engine-DOoVem7_.d.ts → Engine-D3868xIU.d.cts} +15 -3
- package/dist/{builders-B_KufGJ9.js → builders-Cdz34nbF.js} +26 -2
- package/dist/builders-Cdz34nbF.js.map +1 -0
- package/dist/{builders-Cp_rlGob.cjs → builders-Do6_4KnS.cjs} +31 -1
- package/dist/builders-Do6_4KnS.cjs.map +1 -0
- package/dist/conformance.cjs +218 -7
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +8 -2
- package/dist/conformance.d.ts +8 -2
- package/dist/conformance.js +218 -7
- package/dist/conformance.js.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/{resolver-DiPMTfcy.js → resolver-CHG4waXL.js} +2 -1
- package/dist/resolver-CHG4waXL.js.map +1 -0
- package/dist/{resolver-DAZWVoJL.cjs → resolver-D-jumvgM.cjs} +2 -1
- package/dist/resolver-D-jumvgM.cjs.map +1 -0
- package/dist/runtime.cjs +3 -2
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +3 -3
- package/dist/{schemas-D1pxEv3t.cjs → schemas-CS5iPpX5.cjs} +168 -80
- package/dist/schemas-CS5iPpX5.cjs.map +1 -0
- package/dist/{schemas-DAnu8tuW.js → schemas-XGrNVMDd.js} +157 -81
- package/dist/schemas-XGrNVMDd.js.map +1 -0
- package/dist/wire.cjs +43 -2
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +181 -8
- package/dist/wire.d.ts +181 -8
- package/dist/wire.js +39 -3
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/dist/builders-B_KufGJ9.js.map +0 -1
- package/dist/builders-Cp_rlGob.cjs.map +0 -1
- package/dist/resolver-DAZWVoJL.cjs.map +0 -1
- package/dist/resolver-DiPMTfcy.js.map +0 -1
- package/dist/schemas-D1pxEv3t.cjs.map +0 -1
- package/dist/schemas-DAnu8tuW.js.map +0 -1
package/dist/conformance.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { An as HighlightDraft,
|
|
2
|
-
import { t as Engine } from "./Engine-
|
|
1
|
+
import { An as HighlightDraft, Ds as CharMapAnchor, cl as LinePoints, dl as PdfRect, jl as DocumentMetadata, ll as PdfPoint, n as AnnotationListSnapshotAllPages, ol as InkList, t as AnnotationListPageSnapshot } from "./AnnotationListSnapshot-C1U3XUxP.cjs";
|
|
2
|
+
import { t as Engine } from "./Engine-D3868xIU.cjs";
|
|
3
3
|
//#region src/conformance/runMetadataConformance.d.ts
|
|
4
4
|
interface ConformanceTestRunner {
|
|
5
5
|
describe(name: string, fn: () => void): void;
|
|
@@ -16,6 +16,7 @@ interface ConformanceExpect {
|
|
|
16
16
|
toHaveLength(expected: number): void;
|
|
17
17
|
toMatch(re: RegExp): void;
|
|
18
18
|
toMatchObject(shape: Record<string, unknown>): void;
|
|
19
|
+
toContain(expected: unknown): void;
|
|
19
20
|
toBeInstanceOf(ctor: Function): void;
|
|
20
21
|
toBeTruthy(): void;
|
|
21
22
|
rejects: {
|
|
@@ -101,6 +102,11 @@ interface ActionsConformanceFixtures {
|
|
|
101
102
|
page: ConformanceFixture;
|
|
102
103
|
annotation: ConformanceFixture;
|
|
103
104
|
field: ConformanceFixture;
|
|
105
|
+
/** `action_payloads.pdf` — every executable payload shape on one page of
|
|
106
|
+
* /NM-keyed links. REQUIRED on both flavours: payload parity is a gate. */
|
|
107
|
+
payloads: ConformanceFixture;
|
|
108
|
+
/** `open_action_dest.pdf` — a destination-form catalog `/OpenAction`. */
|
|
109
|
+
openDestination: ConformanceFixture;
|
|
104
110
|
/** A page whose only annotation is a Link with a `/S /JavaScript` action.
|
|
105
111
|
* Optional: the javascript-link classification test skips without it. */
|
|
106
112
|
javascriptLink?: ConformanceFixture;
|
package/dist/conformance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { An as HighlightDraft,
|
|
2
|
-
import { t as Engine } from "./Engine-
|
|
1
|
+
import { An as HighlightDraft, Ds as CharMapAnchor, cl as LinePoints, dl as PdfRect, jl as DocumentMetadata, ll as PdfPoint, n as AnnotationListSnapshotAllPages, ol as InkList, t as AnnotationListPageSnapshot } from "./AnnotationListSnapshot-C1U3XUxP.js";
|
|
2
|
+
import { t as Engine } from "./Engine-CWnAKccD.js";
|
|
3
3
|
//#region src/conformance/runMetadataConformance.d.ts
|
|
4
4
|
interface ConformanceTestRunner {
|
|
5
5
|
describe(name: string, fn: () => void): void;
|
|
@@ -16,6 +16,7 @@ interface ConformanceExpect {
|
|
|
16
16
|
toHaveLength(expected: number): void;
|
|
17
17
|
toMatch(re: RegExp): void;
|
|
18
18
|
toMatchObject(shape: Record<string, unknown>): void;
|
|
19
|
+
toContain(expected: unknown): void;
|
|
19
20
|
toBeInstanceOf(ctor: Function): void;
|
|
20
21
|
toBeTruthy(): void;
|
|
21
22
|
rejects: {
|
|
@@ -101,6 +102,11 @@ interface ActionsConformanceFixtures {
|
|
|
101
102
|
page: ConformanceFixture;
|
|
102
103
|
annotation: ConformanceFixture;
|
|
103
104
|
field: ConformanceFixture;
|
|
105
|
+
/** `action_payloads.pdf` — every executable payload shape on one page of
|
|
106
|
+
* /NM-keyed links. REQUIRED on both flavours: payload parity is a gate. */
|
|
107
|
+
payloads: ConformanceFixture;
|
|
108
|
+
/** `open_action_dest.pdf` — a destination-form catalog `/OpenAction`. */
|
|
109
|
+
openDestination: ConformanceFixture;
|
|
104
110
|
/** A page whose only annotation is a Link with a `/S /JavaScript` action.
|
|
105
111
|
* Optional: the javascript-link classification test skips without it. */
|
|
106
112
|
javascriptLink?: ConformanceFixture;
|
package/dist/conformance.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { f as pdfQuadBounds, i as EngineError, n as foldText, u as isRotatedGeometryRun } from "./fold-BfyxxwS6.js";
|
|
2
2
|
import { f as EngineErrorCode, o as sliceTextByChars } from "./PageInsertBlankInput-WKY0tr6S.js";
|
|
3
3
|
import { t as AbortError } from "./AbortError-8-9JAX1Y.js";
|
|
4
|
-
import { A as FormSetValueResultSchema, B as PageDeleteResultSchema, O as FormImportResultSchema, Ot as FormSnapshotSchema, Pt as AnnotationDTOSchema, U as PageFlattenResultSchema, W as PageGeometrySnapshotSchema, Y as PageListSnapshotSchema, Z as PageMoveResultSchema, a as AnnotationCreateResultSchema, at as PageTextSnapshotSchema, c as AnnotationListPageSnapshotSchema, d as AnnotationUpdateResultSchema, k as FormRepairResultSchema, l as AnnotationListSnapshotAllPagesSchema,
|
|
4
|
+
import { A as FormSetValueResultSchema, B as PageDeleteResultSchema, O as FormImportResultSchema, Ot as FormSnapshotSchema, Pt as AnnotationDTOSchema, U as PageFlattenResultSchema, W as PageGeometrySnapshotSchema, Y as PageListSnapshotSchema, Z as PageMoveResultSchema, a as AnnotationCreateResultSchema, at as PageTextSnapshotSchema, c as AnnotationListPageSnapshotSchema, d as AnnotationUpdateResultSchema, k as FormRepairResultSchema, l as AnnotationListSnapshotAllPagesSchema, mt as SearchSliceSchema, nt as PageRotateResultSchema, o as AnnotationDeleteResultSchema, pr as DocumentActionsSnapshotSchema, st as RedactionApplyResultSchema, u as AnnotationMoveResultSchema } from "./schemas-XGrNVMDd.js";
|
|
5
5
|
//#region src/conformance/runMetadataConformance.ts
|
|
6
6
|
/**
|
|
7
7
|
* The conformance harness is transport-agnostic. It takes the test runner as
|
|
@@ -369,6 +369,13 @@ function emptyFlags() {
|
|
|
369
369
|
}
|
|
370
370
|
//#endregion
|
|
371
371
|
//#region src/conformance/runActionsConformance.ts
|
|
372
|
+
/** The script payload rides only the javascript/rendition arms. */
|
|
373
|
+
function scriptOf(node) {
|
|
374
|
+
if (!node) return "";
|
|
375
|
+
if (node.type === "javascript") return node.script;
|
|
376
|
+
if (node.type === "rendition") return node.script ?? "";
|
|
377
|
+
return "";
|
|
378
|
+
}
|
|
372
379
|
/** Action extraction parity. These tests assert data only; no script executes. */
|
|
373
380
|
function runActionsConformance(runner, opts) {
|
|
374
381
|
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
@@ -388,10 +395,10 @@ function runActionsConformance(runner, opts) {
|
|
|
388
395
|
expect(DocumentActionsSnapshotSchema.safeParse(snapshot).success).toBe(true);
|
|
389
396
|
expect(snapshot.openAction).toBeNull();
|
|
390
397
|
expect(snapshot.willSave?.root?.type).toBe("javascript");
|
|
391
|
-
expect(snapshot.willSave?.root
|
|
392
|
-
expect(snapshot.didSave?.root
|
|
393
|
-
expect(snapshot.willPrint?.root
|
|
394
|
-
expect(snapshot.didPrint?.root
|
|
398
|
+
expect(scriptOf(snapshot.willSave?.root)).toMatch(/Will Save/);
|
|
399
|
+
expect(scriptOf(snapshot.didSave?.root)).toMatch(/Did Save/);
|
|
400
|
+
expect(scriptOf(snapshot.willPrint?.root)).toMatch(/Will Print/);
|
|
401
|
+
expect(scriptOf(snapshot.didPrint?.root)).toMatch(/Did Print/);
|
|
395
402
|
const form = await doc.forms.list();
|
|
396
403
|
expect(form.calculationOrder).toEqual([{
|
|
397
404
|
kind: "objectNumber",
|
|
@@ -438,7 +445,7 @@ function runActionsConformance(runner, opts) {
|
|
|
438
445
|
expect(link?.subtype).toBe("link");
|
|
439
446
|
if (link?.subtype === "link") expect(link.target).toEqual({ kind: "javascript" });
|
|
440
447
|
expect(link?.actions?.activate?.root?.type).toBe("javascript");
|
|
441
|
-
expect(link?.actions?.activate?.root
|
|
448
|
+
expect(scriptOf(link?.actions?.activate?.root)).toMatch(/app\.alert/);
|
|
442
449
|
} finally {
|
|
443
450
|
await doc.close();
|
|
444
451
|
}
|
|
@@ -449,7 +456,7 @@ function runActionsConformance(runner, opts) {
|
|
|
449
456
|
const form = await doc.forms.list();
|
|
450
457
|
expect(form.fields).toHaveLength(1);
|
|
451
458
|
expect(form.fields[0].actions?.format?.root?.type).toBe("javascript");
|
|
452
|
-
expect(form.fields[0].actions?.format?.root
|
|
459
|
+
expect(scriptOf(form.fields[0].actions?.format?.root)).toMatch(/AFDate_FormatEx/);
|
|
453
460
|
const page = (await doc.pages.list()).pages[0];
|
|
454
461
|
const widget = (await doc.page(page.pageObjectNumber).annotations.list()).annotations[0];
|
|
455
462
|
expect(widget.actions).toBe(void 0);
|
|
@@ -457,6 +464,210 @@ function runActionsConformance(runner, opts) {
|
|
|
457
464
|
await doc.close();
|
|
458
465
|
}
|
|
459
466
|
});
|
|
467
|
+
test("carries interpreter payloads on every executable node", async () => {
|
|
468
|
+
const doc = await open(engine, opts, opts.fixtures.payloads);
|
|
469
|
+
try {
|
|
470
|
+
const page = (await doc.pages.list()).pages[0];
|
|
471
|
+
const snapshot = await doc.page(page.pageObjectNumber).annotations.list();
|
|
472
|
+
const pon = page.pageObjectNumber;
|
|
473
|
+
const rootOf = (nm) => {
|
|
474
|
+
const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
|
|
475
|
+
expect(Boolean(annotation)).toBe(true);
|
|
476
|
+
return annotation?.actions?.activate?.root ?? null;
|
|
477
|
+
};
|
|
478
|
+
const targetOf = (nm) => {
|
|
479
|
+
const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
|
|
480
|
+
return annotation?.subtype === "link" ? annotation.target : null;
|
|
481
|
+
};
|
|
482
|
+
expect(rootOf("goto-fitr")).toMatchObject({
|
|
483
|
+
type: "goto",
|
|
484
|
+
destination: {
|
|
485
|
+
kind: "fitR",
|
|
486
|
+
pageObjectNumber: pon,
|
|
487
|
+
left: 10,
|
|
488
|
+
bottom: 20,
|
|
489
|
+
right: 300,
|
|
490
|
+
top: 400
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
expect(targetOf("goto-fitr")).toMatchObject({
|
|
494
|
+
kind: "goto",
|
|
495
|
+
destination: { kind: "fitR" }
|
|
496
|
+
});
|
|
497
|
+
expect(rootOf("uri-map")).toMatchObject({
|
|
498
|
+
type: "uri",
|
|
499
|
+
uri: "https://example.test/map",
|
|
500
|
+
isMap: true
|
|
501
|
+
});
|
|
502
|
+
expect(rootOf("named-next")).toMatchObject({
|
|
503
|
+
type: "named",
|
|
504
|
+
name: "NextPage"
|
|
505
|
+
});
|
|
506
|
+
const mixed = rootOf("hide-mixed");
|
|
507
|
+
expect(mixed).toMatchObject({
|
|
508
|
+
type: "hide",
|
|
509
|
+
hide: false
|
|
510
|
+
});
|
|
511
|
+
const mixedTargets = mixed?.type === "hide" ? mixed.targets : [];
|
|
512
|
+
expect(mixedTargets).toHaveLength(2);
|
|
513
|
+
expect(mixedTargets[0]).toEqual({
|
|
514
|
+
kind: "name",
|
|
515
|
+
name: "note1"
|
|
516
|
+
});
|
|
517
|
+
expect(mixedTargets[1]?.kind === "objectNumber" && mixedTargets[1].objectNumber > 0).toBe(true);
|
|
518
|
+
expect(rootOf("hide-scalar")).toMatchObject({
|
|
519
|
+
type: "hide",
|
|
520
|
+
targets: [{
|
|
521
|
+
kind: "name",
|
|
522
|
+
name: "fieldB"
|
|
523
|
+
}],
|
|
524
|
+
hide: true
|
|
525
|
+
});
|
|
526
|
+
expect(rootOf("reset-include")).toMatchObject({
|
|
527
|
+
type: "reset-form",
|
|
528
|
+
fields: [{
|
|
529
|
+
kind: "name",
|
|
530
|
+
name: "calc1"
|
|
531
|
+
}],
|
|
532
|
+
exclude: true
|
|
533
|
+
});
|
|
534
|
+
expect(rootOf("reset-absent")).toMatchObject({
|
|
535
|
+
type: "reset-form",
|
|
536
|
+
fields: null,
|
|
537
|
+
exclude: true
|
|
538
|
+
});
|
|
539
|
+
expect(rootOf("reset-empty")).toMatchObject({
|
|
540
|
+
type: "reset-form",
|
|
541
|
+
fields: [],
|
|
542
|
+
exclude: false
|
|
543
|
+
});
|
|
544
|
+
expect(rootOf("submit-urlspec")).toMatchObject({
|
|
545
|
+
type: "submit-form",
|
|
546
|
+
payload: {
|
|
547
|
+
url: "https://uf.example.test/submit",
|
|
548
|
+
fields: [{
|
|
549
|
+
kind: "name",
|
|
550
|
+
name: "parent"
|
|
551
|
+
}],
|
|
552
|
+
flags: {
|
|
553
|
+
raw: 0,
|
|
554
|
+
exclude: false,
|
|
555
|
+
format: "fdf",
|
|
556
|
+
method: "post"
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
expect(rootOf("submit-compat-xfdf")).toMatchObject({
|
|
561
|
+
type: "submit-form",
|
|
562
|
+
payload: {
|
|
563
|
+
url: "https://example.test/xfdf",
|
|
564
|
+
fields: [{
|
|
565
|
+
kind: "name",
|
|
566
|
+
name: "noexport"
|
|
567
|
+
}, {
|
|
568
|
+
kind: "name",
|
|
569
|
+
name: "plain"
|
|
570
|
+
}],
|
|
571
|
+
flags: {
|
|
572
|
+
raw: 35,
|
|
573
|
+
exclude: true,
|
|
574
|
+
includeNoValueFields: true,
|
|
575
|
+
format: "xfdf",
|
|
576
|
+
method: "post"
|
|
577
|
+
},
|
|
578
|
+
charSet: "utf-8"
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
expect(rootOf("submit-pdf-get")).toMatchObject({
|
|
582
|
+
type: "submit-form",
|
|
583
|
+
payload: {
|
|
584
|
+
url: "https://example.test/pdf",
|
|
585
|
+
fields: null,
|
|
586
|
+
flags: {
|
|
587
|
+
raw: 264,
|
|
588
|
+
format: "pdf",
|
|
589
|
+
method: "get"
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
expect(rootOf("launch-app")).toMatchObject({
|
|
594
|
+
type: "launch",
|
|
595
|
+
filePath: "app.exe"
|
|
596
|
+
});
|
|
597
|
+
expect(rootOf("gotor-file")).toMatchObject({
|
|
598
|
+
type: "goto-remote",
|
|
599
|
+
filePath: "other.pdf"
|
|
600
|
+
});
|
|
601
|
+
const chain = rootOf("chain-js-goto-hide");
|
|
602
|
+
expect(chain).toMatchObject({
|
|
603
|
+
type: "javascript",
|
|
604
|
+
script: "app.alert('chain');"
|
|
605
|
+
});
|
|
606
|
+
expect(chain?.next[0]).toMatchObject({
|
|
607
|
+
type: "goto",
|
|
608
|
+
destination: {
|
|
609
|
+
kind: "xyz",
|
|
610
|
+
pageObjectNumber: pon,
|
|
611
|
+
left: 5,
|
|
612
|
+
top: 10,
|
|
613
|
+
zoom: 1.25
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
expect(chain?.next[0]?.next[0]).toMatchObject({
|
|
617
|
+
type: "hide",
|
|
618
|
+
targets: [{
|
|
619
|
+
kind: "name",
|
|
620
|
+
name: "note1"
|
|
621
|
+
}],
|
|
622
|
+
hide: true
|
|
623
|
+
});
|
|
624
|
+
} finally {
|
|
625
|
+
await doc.close();
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
test("degrades unreadable payloads to unknown with payload-dropped", async () => {
|
|
629
|
+
const doc = await open(engine, opts, opts.fixtures.payloads);
|
|
630
|
+
try {
|
|
631
|
+
const page = (await doc.pages.list()).pages[0];
|
|
632
|
+
const snapshot = await doc.page(page.pageObjectNumber).annotations.list();
|
|
633
|
+
for (const [nm, subtype] of [
|
|
634
|
+
["goto-malformed", "GoTo"],
|
|
635
|
+
["hide-partial", "Hide"],
|
|
636
|
+
["submit-not-url", "SubmitForm"],
|
|
637
|
+
["submit-no-f", "SubmitForm"]
|
|
638
|
+
]) {
|
|
639
|
+
const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
|
|
640
|
+
const tree = annotation?.actions?.activate;
|
|
641
|
+
expect(tree?.root).toMatchObject({
|
|
642
|
+
type: "unknown",
|
|
643
|
+
subtype
|
|
644
|
+
});
|
|
645
|
+
expect(tree?.warnings ?? []).toContain("payload-dropped");
|
|
646
|
+
if (annotation?.subtype === "link") expect(annotation.target).toEqual({ kind: "unsupported" });
|
|
647
|
+
}
|
|
648
|
+
} finally {
|
|
649
|
+
await doc.close();
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
test("reads a destination-form /OpenAction as openDestination", async () => {
|
|
653
|
+
const doc = await open(engine, opts, opts.fixtures.openDestination);
|
|
654
|
+
try {
|
|
655
|
+
expect(Boolean(doc.actions)).toBe(true);
|
|
656
|
+
const snapshot = await doc.actions.read();
|
|
657
|
+
expect(DocumentActionsSnapshotSchema.safeParse(snapshot).success).toBe(true);
|
|
658
|
+
expect(snapshot.openAction).toBeNull();
|
|
659
|
+
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
660
|
+
expect(snapshot.openDestination).toEqual({
|
|
661
|
+
kind: "xyz",
|
|
662
|
+
pageObjectNumber: pon,
|
|
663
|
+
left: 10,
|
|
664
|
+
top: 700,
|
|
665
|
+
zoom: 1.5
|
|
666
|
+
});
|
|
667
|
+
} finally {
|
|
668
|
+
await doc.close();
|
|
669
|
+
}
|
|
670
|
+
});
|
|
460
671
|
});
|
|
461
672
|
}
|
|
462
673
|
async function open(engine, opts, fixture) {
|