@embedpdf/engine-core 3.0.0-next.7 → 3.0.0-next.9
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/{AbortError-BsHuCO1S.js → AbortError-8-9JAX1Y.js} +2 -2
- package/dist/{AbortError-BsHuCO1S.js.map → AbortError-8-9JAX1Y.js.map} +1 -1
- package/dist/{AbortError-DmWeq9sx.cjs → AbortError-CRSooKsk.cjs} +2 -2
- package/dist/{AbortError-DmWeq9sx.cjs.map → AbortError-CRSooKsk.cjs.map} +1 -1
- package/dist/{AnnotationListSnapshot-CHjkcIaL.d.cts → AnnotationListSnapshot-Bwfnb1i-.d.cts} +25 -2
- package/dist/{AnnotationListSnapshot-CHjkcIaL.d.ts → AnnotationListSnapshot-Bwfnb1i-.d.ts} +25 -2
- package/dist/{DocumentSecurityService-CrxGktMI.d.ts → DocumentSecurityService-CqLXyTVM.d.ts} +2 -2
- package/dist/{DocumentSecurityService-B1uv4FaK.d.cts → DocumentSecurityService-DQNpYCXs.d.cts} +2 -2
- package/dist/{Engine-BE6r06QI.d.ts → Engine-C25gzAFz.d.ts} +26 -16
- package/dist/{Engine-BOaRwtKa.d.cts → Engine-COFJU7sA.d.cts} +26 -16
- package/dist/{charmap-D6PLtRiC.cjs → PageInsertBlankInput-CzShuSJI.cjs} +16 -1
- package/dist/PageInsertBlankInput-CzShuSJI.cjs.map +1 -0
- package/dist/{charmap-CUukAMhR.js → PageInsertBlankInput-WKY0tr6S.js} +11 -2
- package/dist/PageInsertBlankInput-WKY0tr6S.js.map +1 -0
- package/dist/{builders-BsUc2A1U.cjs → builders-B5CgvJ3j.cjs} +6 -6
- package/dist/{builders-BsUc2A1U.cjs.map → builders-B5CgvJ3j.cjs.map} +1 -1
- package/dist/{builders-CF5gKkOa.js → builders-CGcBlTrv.js} +3 -3
- package/dist/{builders-CF5gKkOa.js.map → builders-CGcBlTrv.js.map} +1 -1
- package/dist/conformance.cjs +337 -178
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +26 -6
- package/dist/conformance.d.ts +26 -6
- package/dist/conformance.js +292 -134
- package/dist/conformance.js.map +1 -1
- package/dist/{fold-DemV94jf.js → fold-BfyxxwS6.js} +2 -2
- package/dist/{fold-DemV94jf.js.map → fold-BfyxxwS6.js.map} +1 -1
- package/dist/{fold-BeT1GxLP.cjs → fold-C7I5GpBz.cjs} +4 -4
- package/dist/{fold-BeT1GxLP.cjs.map → fold-C7I5GpBz.cjs.map} +1 -1
- package/dist/index.cjs +15 -14
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/runtime.cjs +20 -19
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +103 -5
- package/dist/runtime.d.ts +103 -5
- package/dist/runtime.js +5 -5
- package/dist/{schemas-ES6-TkIl.js → schemas-BKRZZ-g1.js} +38 -4
- package/dist/{schemas-ES6-TkIl.js.map → schemas-BKRZZ-g1.js.map} +1 -1
- package/dist/{schemas-CyWwm0Zf.cjs → schemas-DlxjcDIl.cjs} +82 -24
- package/dist/{schemas-CyWwm0Zf.cjs.map → schemas-DlxjcDIl.cjs.map} +1 -1
- package/dist/wire.cjs +37 -3
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +72 -8
- package/dist/wire.d.ts +72 -8
- package/dist/wire.js +34 -4
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/dist/charmap-CUukAMhR.js.map +0 -1
- package/dist/charmap-D6PLtRiC.cjs.map +0 -1
package/dist/conformance.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as pdfQuadBounds, i as EngineError, n as foldText, u as isRotatedGeometryRun } from "./fold-
|
|
2
|
-
import {
|
|
3
|
-
import { t as AbortError } from "./AbortError-
|
|
4
|
-
import { A as FormSetValueResultSchema,
|
|
1
|
+
import { f as pdfQuadBounds, i as EngineError, n as foldText, u as isRotatedGeometryRun } from "./fold-BfyxxwS6.js";
|
|
2
|
+
import { f as EngineErrorCode, o as sliceTextByChars } from "./PageInsertBlankInput-WKY0tr6S.js";
|
|
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, mr as DocumentActionsSnapshotSchema, mt as SearchSliceSchema, nt as PageRotateResultSchema, o as AnnotationDeleteResultSchema, st as RedactionApplyResultSchema, u as AnnotationMoveResultSchema } from "./schemas-BKRZZ-g1.js";
|
|
5
5
|
//#region src/conformance/runMetadataConformance.ts
|
|
6
6
|
/**
|
|
7
7
|
* The conformance harness is transport-agnostic. It takes the test runner as
|
|
@@ -18,7 +18,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
18
18
|
if (engine) await engine.destroy();
|
|
19
19
|
});
|
|
20
20
|
test("reads metadata from sample fixture", async () => {
|
|
21
|
-
const doc = await openFixture$
|
|
21
|
+
const doc = await openFixture$17(engine, opts);
|
|
22
22
|
try {
|
|
23
23
|
const meta = await doc.metadata.read();
|
|
24
24
|
expect(meta).toMatchObject(opts.fixture.expected);
|
|
@@ -28,7 +28,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
test("abort() before completion rejects with AbortError", async () => {
|
|
31
|
-
const doc = await openFixture$
|
|
31
|
+
const doc = await openFixture$17(engine, opts);
|
|
32
32
|
try {
|
|
33
33
|
const p = doc.metadata.read();
|
|
34
34
|
p.abort("test");
|
|
@@ -38,7 +38,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
40
|
test("aborting one read does not affect a concurrent one", async () => {
|
|
41
|
-
const doc = await openFixture$
|
|
41
|
+
const doc = await openFixture$17(engine, opts);
|
|
42
42
|
try {
|
|
43
43
|
const a = doc.metadata.read();
|
|
44
44
|
const b = doc.metadata.read();
|
|
@@ -50,7 +50,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
test("metadata after close throws DocNotOpen", async () => {
|
|
53
|
-
const doc = await openFixture$
|
|
53
|
+
const doc = await openFixture$17(engine, opts);
|
|
54
54
|
await doc.close();
|
|
55
55
|
let caught;
|
|
56
56
|
try {
|
|
@@ -62,7 +62,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
62
62
|
expect(EngineError.is(caught, EngineErrorCode.DocNotOpen)).toBe(true);
|
|
63
63
|
});
|
|
64
64
|
test("update() sets standard + custom fields and a subsequent read observes them", async () => {
|
|
65
|
-
const doc = await openFixture$
|
|
65
|
+
const doc = await openFixture$17(engine, opts);
|
|
66
66
|
try {
|
|
67
67
|
const result = await doc.metadata.update({
|
|
68
68
|
title: "Conformance Title",
|
|
@@ -81,7 +81,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
test("update() clears a field with null", async () => {
|
|
84
|
-
const doc = await openFixture$
|
|
84
|
+
const doc = await openFixture$17(engine, opts);
|
|
85
85
|
try {
|
|
86
86
|
await doc.metadata.update({ title: "To Be Cleared" });
|
|
87
87
|
const set = await doc.metadata.read();
|
|
@@ -94,7 +94,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
test("update() after close throws DocNotOpen", async () => {
|
|
97
|
-
const doc = await openFixture$
|
|
97
|
+
const doc = await openFixture$17(engine, opts);
|
|
98
98
|
await doc.close();
|
|
99
99
|
let caught;
|
|
100
100
|
try {
|
|
@@ -107,7 +107,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
107
107
|
});
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
async function openFixture$
|
|
110
|
+
async function openFixture$17(engine, opts) {
|
|
111
111
|
if (opts.openKind === "bytes") {
|
|
112
112
|
const bytes = await opts.fixture.bytes();
|
|
113
113
|
return engine.open({
|
|
@@ -134,7 +134,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
134
134
|
if (engine) await engine.destroy();
|
|
135
135
|
});
|
|
136
136
|
test("listRawAll returns one entry per page with valid PageState", async () => {
|
|
137
|
-
const doc = await openFixture$
|
|
137
|
+
const doc = await openFixture$16(engine, opts);
|
|
138
138
|
try {
|
|
139
139
|
const snap = await doc.annotations.listRawAll();
|
|
140
140
|
expect(AnnotationListSnapshotAllPagesSchema.safeParse(snap).success).toBe(true);
|
|
@@ -147,7 +147,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
test("listRaw on the test page returns the expected counts and DTO shape", async () => {
|
|
150
|
-
const doc = await openFixture$
|
|
150
|
+
const doc = await openFixture$16(engine, opts);
|
|
151
151
|
try {
|
|
152
152
|
const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
153
153
|
expect(AnnotationListPageSnapshotSchema.safeParse(snap).success).toBe(true);
|
|
@@ -177,7 +177,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
test("shape/vertex/line annotations expose their family fields", async () => {
|
|
180
|
-
const doc = await openFixture$
|
|
180
|
+
const doc = await openFixture$16(engine, opts);
|
|
181
181
|
try {
|
|
182
182
|
const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
183
183
|
for (const a of snap.annotations) {
|
|
@@ -236,7 +236,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
238
|
test("full page list dispatches per-subtype and matches raw counts", async () => {
|
|
239
|
-
const doc = await openFixture$
|
|
239
|
+
const doc = await openFixture$16(engine, opts);
|
|
240
240
|
try {
|
|
241
241
|
const full = await doc.page(opts.fixture.pageObjectNumber).annotations.list();
|
|
242
242
|
expect(AnnotationListPageSnapshotSchema.safeParse(full).success).toBe(true);
|
|
@@ -246,7 +246,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
246
246
|
}
|
|
247
247
|
});
|
|
248
248
|
test("every annotation DTO satisfies AnnotationDTOSchema (discriminated union)", async () => {
|
|
249
|
-
const doc = await openFixture$
|
|
249
|
+
const doc = await openFixture$16(engine, opts);
|
|
250
250
|
try {
|
|
251
251
|
const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
252
252
|
for (const a of snap.annotations) {
|
|
@@ -286,7 +286,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
286
286
|
});
|
|
287
287
|
if (opts.fixture.expectsWeakAnnotation) {
|
|
288
288
|
test("weak annotations carry identityQuality: weak and ref.kind: index", async () => {
|
|
289
|
-
const doc = await openFixture$
|
|
289
|
+
const doc = await openFixture$16(engine, opts);
|
|
290
290
|
try {
|
|
291
291
|
const weak = (await doc.annotations.listRaw(opts.fixture.pageObjectNumber)).annotations.find((a) => a.identityQuality === "weak");
|
|
292
292
|
expect(weak !== void 0).toBe(true);
|
|
@@ -296,7 +296,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
test("a stale revision token throws InvalidReference", async () => {
|
|
299
|
-
const doc = await openFixture$
|
|
299
|
+
const doc = await openFixture$16(engine, opts);
|
|
300
300
|
try {
|
|
301
301
|
const snap = await doc.page(opts.fixture.pageObjectNumber).annotations.list();
|
|
302
302
|
const weak = snap.annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -312,7 +312,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
314
|
test("abort() on listRaw rejects with AbortError", async () => {
|
|
315
|
-
const doc = await openFixture$
|
|
315
|
+
const doc = await openFixture$16(engine, opts);
|
|
316
316
|
try {
|
|
317
317
|
const p = doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
318
318
|
p.abort("test");
|
|
@@ -322,7 +322,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
322
322
|
}
|
|
323
323
|
});
|
|
324
324
|
test("listRaw on an unknown pageObjectNumber throws NotFound", async () => {
|
|
325
|
-
const doc = await openFixture$
|
|
325
|
+
const doc = await openFixture$16(engine, opts);
|
|
326
326
|
try {
|
|
327
327
|
let caught;
|
|
328
328
|
try {
|
|
@@ -338,7 +338,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
338
338
|
});
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
|
-
async function openFixture$
|
|
341
|
+
async function openFixture$16(engine, opts) {
|
|
342
342
|
if (opts.openKind === "bytes") {
|
|
343
343
|
const bytes = await opts.fixture.bytes();
|
|
344
344
|
return engine.open({
|
|
@@ -596,7 +596,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
596
596
|
if (engine) await engine.destroy();
|
|
597
597
|
});
|
|
598
598
|
test("create appends without shifting indices and leaves weak refs valid", async () => {
|
|
599
|
-
const doc = await openFixture$
|
|
599
|
+
const doc = await openFixture$15(engine, opts);
|
|
600
600
|
try {
|
|
601
601
|
const page = doc.page(fix.pageObjectNumber);
|
|
602
602
|
const before = await page.annotations.list();
|
|
@@ -632,7 +632,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
632
632
|
}
|
|
633
633
|
});
|
|
634
634
|
test("create + update honor annotation flags (set on create, merge on patch)", async () => {
|
|
635
|
-
const doc = await openFixture$
|
|
635
|
+
const doc = await openFixture$15(engine, opts);
|
|
636
636
|
try {
|
|
637
637
|
const page = doc.page(fix.pageObjectNumber);
|
|
638
638
|
const draft = {
|
|
@@ -667,7 +667,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
667
667
|
}
|
|
668
668
|
});
|
|
669
669
|
test("create shape annotations (circle + square) round-trip shape fields", async () => {
|
|
670
|
-
const doc = await openFixture$
|
|
670
|
+
const doc = await openFixture$15(engine, opts);
|
|
671
671
|
try {
|
|
672
672
|
const page = doc.page(fix.pageObjectNumber);
|
|
673
673
|
const circleDraft = {
|
|
@@ -748,7 +748,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
748
748
|
}
|
|
749
749
|
});
|
|
750
750
|
test("cloudy border (/BE) + rect differences (/RD) are tri-state", async () => {
|
|
751
|
-
const doc = await openFixture$
|
|
751
|
+
const doc = await openFixture$15(engine, opts);
|
|
752
752
|
try {
|
|
753
753
|
const page = doc.page(fix.pageObjectNumber);
|
|
754
754
|
const plainDraft = {
|
|
@@ -827,7 +827,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
827
827
|
}
|
|
828
828
|
});
|
|
829
829
|
test("update echoes the appearance verdict: moves preserve /AP, restyles re-bake", async () => {
|
|
830
|
-
const doc = await openFixture$
|
|
830
|
+
const doc = await openFixture$15(engine, opts);
|
|
831
831
|
try {
|
|
832
832
|
const page = doc.page(fix.pageObjectNumber);
|
|
833
833
|
const draft = {
|
|
@@ -902,7 +902,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
902
902
|
}
|
|
903
903
|
});
|
|
904
904
|
test("a partial /DA patch preserves the unpatched font members", async () => {
|
|
905
|
-
const doc = await openFixture$
|
|
905
|
+
const doc = await openFixture$15(engine, opts);
|
|
906
906
|
try {
|
|
907
907
|
const page = doc.page(fix.pageObjectNumber);
|
|
908
908
|
const draft = {
|
|
@@ -958,7 +958,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
958
958
|
}
|
|
959
959
|
});
|
|
960
960
|
test("box transform is tri-state: rect-only moves keep rotation, null flattens", async () => {
|
|
961
|
-
const doc = await openFixture$
|
|
961
|
+
const doc = await openFixture$15(engine, opts);
|
|
962
962
|
try {
|
|
963
963
|
const page = doc.page(fix.pageObjectNumber);
|
|
964
964
|
const draft = {
|
|
@@ -1019,7 +1019,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1019
1019
|
}
|
|
1020
1020
|
});
|
|
1021
1021
|
test("create vertex + line annotations (polygon/polyline/line) round-trip geometry", async () => {
|
|
1022
|
-
const doc = await openFixture$
|
|
1022
|
+
const doc = await openFixture$15(engine, opts);
|
|
1023
1023
|
try {
|
|
1024
1024
|
const page = doc.page(fix.pageObjectNumber);
|
|
1025
1025
|
const polygonDraft = {
|
|
@@ -1150,7 +1150,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1150
1150
|
}
|
|
1151
1151
|
});
|
|
1152
1152
|
test("create free-text + callout round-trip text/colour/intent fields", async () => {
|
|
1153
|
-
const doc = await openFixture$
|
|
1153
|
+
const doc = await openFixture$15(engine, opts);
|
|
1154
1154
|
try {
|
|
1155
1155
|
const page = doc.page(fix.pageObjectNumber);
|
|
1156
1156
|
const freeTextDraft = {
|
|
@@ -1246,7 +1246,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1246
1246
|
}
|
|
1247
1247
|
});
|
|
1248
1248
|
test("update a free-text patches alignment + colours and is non-structural", async () => {
|
|
1249
|
-
const doc = await openFixture$
|
|
1249
|
+
const doc = await openFixture$15(engine, opts);
|
|
1250
1250
|
try {
|
|
1251
1251
|
const page = doc.page(fix.pageObjectNumber);
|
|
1252
1252
|
const created = await page.annotations.create({
|
|
@@ -1307,7 +1307,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1307
1307
|
}
|
|
1308
1308
|
});
|
|
1309
1309
|
test("create redact (area + text) round-trips label + colour fields", async () => {
|
|
1310
|
-
const doc = await openFixture$
|
|
1310
|
+
const doc = await openFixture$15(engine, opts);
|
|
1311
1311
|
try {
|
|
1312
1312
|
const page = doc.page(fix.pageObjectNumber);
|
|
1313
1313
|
const areaDraft = {
|
|
@@ -1387,7 +1387,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
});
|
|
1389
1389
|
test("update a redact patches the label and clears it, non-structurally", async () => {
|
|
1390
|
-
const doc = await openFixture$
|
|
1390
|
+
const doc = await openFixture$15(engine, opts);
|
|
1391
1391
|
try {
|
|
1392
1392
|
const page = doc.page(fix.pageObjectNumber);
|
|
1393
1393
|
const created = await page.annotations.create({
|
|
@@ -1464,7 +1464,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1464
1464
|
}
|
|
1465
1465
|
});
|
|
1466
1466
|
test("create + update a caret round-trips color/opacity/rect differences", async () => {
|
|
1467
|
-
const doc = await openFixture$
|
|
1467
|
+
const doc = await openFixture$15(engine, opts);
|
|
1468
1468
|
try {
|
|
1469
1469
|
const page = doc.page(fix.pageObjectNumber);
|
|
1470
1470
|
const caretDraft = {
|
|
@@ -1544,7 +1544,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1544
1544
|
}
|
|
1545
1545
|
});
|
|
1546
1546
|
test("update an ink annotation patches strokes + color and is non-structural", async () => {
|
|
1547
|
-
const doc = await openFixture$
|
|
1547
|
+
const doc = await openFixture$15(engine, opts);
|
|
1548
1548
|
try {
|
|
1549
1549
|
const page = doc.page(fix.pageObjectNumber);
|
|
1550
1550
|
const created = await page.annotations.create({
|
|
@@ -1595,7 +1595,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1595
1595
|
}
|
|
1596
1596
|
});
|
|
1597
1597
|
test("ink highlight intent + blend round-trip and unrelated patches preserve blend", async () => {
|
|
1598
|
-
const doc = await openFixture$
|
|
1598
|
+
const doc = await openFixture$15(engine, opts);
|
|
1599
1599
|
try {
|
|
1600
1600
|
const page = doc.page(fix.pageObjectNumber);
|
|
1601
1601
|
const created = await page.annotations.create({
|
|
@@ -1638,7 +1638,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1638
1638
|
}
|
|
1639
1639
|
});
|
|
1640
1640
|
test("update a polyline patches vertices + line endings and is non-structural", async () => {
|
|
1641
|
-
const doc = await openFixture$
|
|
1641
|
+
const doc = await openFixture$15(engine, opts);
|
|
1642
1642
|
try {
|
|
1643
1643
|
const page = doc.page(fix.pageObjectNumber);
|
|
1644
1644
|
const created = await page.annotations.create({
|
|
@@ -1687,7 +1687,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1687
1687
|
}
|
|
1688
1688
|
});
|
|
1689
1689
|
test("update a shape annotation patches color and is non-structural", async () => {
|
|
1690
|
-
const doc = await openFixture$
|
|
1690
|
+
const doc = await openFixture$15(engine, opts);
|
|
1691
1691
|
try {
|
|
1692
1692
|
const page = doc.page(fix.pageObjectNumber);
|
|
1693
1693
|
const created = await page.annotations.create({
|
|
@@ -1736,7 +1736,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1736
1736
|
}
|
|
1737
1737
|
});
|
|
1738
1738
|
if (opts.supportsAppearanceRasters) test("creating a shape bakes an /AP appearance the reader can rasterize", async () => {
|
|
1739
|
-
const doc = await openFixture$
|
|
1739
|
+
const doc = await openFixture$15(engine, opts);
|
|
1740
1740
|
try {
|
|
1741
1741
|
const page = doc.page(fix.pageObjectNumber);
|
|
1742
1742
|
const created = await page.annotations.create({
|
|
@@ -1766,7 +1766,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1766
1766
|
}
|
|
1767
1767
|
});
|
|
1768
1768
|
test("update on a durable annotation is non-structural and never touches /NM", async () => {
|
|
1769
|
-
const doc = await openFixture$
|
|
1769
|
+
const doc = await openFixture$15(engine, opts);
|
|
1770
1770
|
try {
|
|
1771
1771
|
const page = doc.page(fix.pageObjectNumber);
|
|
1772
1772
|
const before = await page.annotations.list();
|
|
@@ -1792,7 +1792,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1792
1792
|
}
|
|
1793
1793
|
});
|
|
1794
1794
|
if (fix.expectsWeakAnnotation) test("update on a weak annotation stamps a UUID v4 /NM and upgrades the ref", async () => {
|
|
1795
|
-
const doc = await openFixture$
|
|
1795
|
+
const doc = await openFixture$15(engine, opts);
|
|
1796
1796
|
try {
|
|
1797
1797
|
const page = doc.page(fix.pageObjectNumber);
|
|
1798
1798
|
const before = await page.annotations.list();
|
|
@@ -1822,7 +1822,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
});
|
|
1824
1824
|
test("delete by objectNumber removes the annotation and reports a stable id", async () => {
|
|
1825
|
-
const doc = await openFixture$
|
|
1825
|
+
const doc = await openFixture$15(engine, opts);
|
|
1826
1826
|
try {
|
|
1827
1827
|
const page = doc.page(fix.pageObjectNumber);
|
|
1828
1828
|
const draft = {
|
|
@@ -1852,7 +1852,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1852
1852
|
}
|
|
1853
1853
|
});
|
|
1854
1854
|
if (fix.expectsWeakAnnotation) test("delete by index of a weak annotation reports deleted: null and refetch reason", async () => {
|
|
1855
|
-
const doc = await openFixture$
|
|
1855
|
+
const doc = await openFixture$15(engine, opts);
|
|
1856
1856
|
try {
|
|
1857
1857
|
const page = doc.page(fix.pageObjectNumber);
|
|
1858
1858
|
const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -1875,7 +1875,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
});
|
|
1877
1877
|
test("abort on create rejects with AbortError", async () => {
|
|
1878
|
-
const doc = await openFixture$
|
|
1878
|
+
const doc = await openFixture$15(engine, opts);
|
|
1879
1879
|
try {
|
|
1880
1880
|
const page = doc.page(fix.pageObjectNumber);
|
|
1881
1881
|
const draft = {
|
|
@@ -1891,7 +1891,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1891
1891
|
}
|
|
1892
1892
|
});
|
|
1893
1893
|
test("update with a stale index revision throws InvalidReference", async () => {
|
|
1894
|
-
const doc = await openFixture$
|
|
1894
|
+
const doc = await openFixture$15(engine, opts);
|
|
1895
1895
|
try {
|
|
1896
1896
|
const page = doc.page(fix.pageObjectNumber);
|
|
1897
1897
|
const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -1918,7 +1918,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
});
|
|
1920
1920
|
test("move single durable annotation reorders within the page (single-as-batch)", async () => {
|
|
1921
|
-
const doc = await openFixture$
|
|
1921
|
+
const doc = await openFixture$15(engine, opts);
|
|
1922
1922
|
try {
|
|
1923
1923
|
const page = doc.page(fix.pageObjectNumber);
|
|
1924
1924
|
const aDraft = {
|
|
@@ -1962,7 +1962,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1962
1962
|
}
|
|
1963
1963
|
});
|
|
1964
1964
|
test("move multi-block preserves caller-supplied order at the destination", async () => {
|
|
1965
|
-
const doc = await openFixture$
|
|
1965
|
+
const doc = await openFixture$15(engine, opts);
|
|
1966
1966
|
try {
|
|
1967
1967
|
const page = doc.page(fix.pageObjectNumber);
|
|
1968
1968
|
const ids = await Promise.all([
|
|
@@ -2001,7 +2001,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2001
2001
|
}
|
|
2002
2002
|
});
|
|
2003
2003
|
if (fix.expectsWeakAnnotation) test("move on a weak annotation upgrades it to durable /NM (one rev bump for batch)", async () => {
|
|
2004
|
-
const doc = await openFixture$
|
|
2004
|
+
const doc = await openFixture$15(engine, opts);
|
|
2005
2005
|
try {
|
|
2006
2006
|
const page = doc.page(fix.pageObjectNumber);
|
|
2007
2007
|
const before = await page.annotations.list();
|
|
@@ -2026,7 +2026,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2026
2026
|
}
|
|
2027
2027
|
});
|
|
2028
2028
|
test("move with a stale index revision rejects (locked rev-token guard)", async () => {
|
|
2029
|
-
const doc = await openFixture$
|
|
2029
|
+
const doc = await openFixture$15(engine, opts);
|
|
2030
2030
|
try {
|
|
2031
2031
|
const page = doc.page(fix.pageObjectNumber);
|
|
2032
2032
|
const a = await page.annotations.create({
|
|
@@ -2064,7 +2064,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
});
|
|
2066
2066
|
test("move with out-of-range toIndex rejects with InvalidArg", async () => {
|
|
2067
|
-
const doc = await openFixture$
|
|
2067
|
+
const doc = await openFixture$15(engine, opts);
|
|
2068
2068
|
try {
|
|
2069
2069
|
const page = doc.page(fix.pageObjectNumber);
|
|
2070
2070
|
const a = await page.annotations.create({
|
|
@@ -2088,7 +2088,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2088
2088
|
}
|
|
2089
2089
|
});
|
|
2090
2090
|
test("move with duplicate refs rejects with InvalidArg", async () => {
|
|
2091
|
-
const doc = await openFixture$
|
|
2091
|
+
const doc = await openFixture$15(engine, opts);
|
|
2092
2092
|
try {
|
|
2093
2093
|
const page = doc.page(fix.pageObjectNumber);
|
|
2094
2094
|
const a = await page.annotations.create({
|
|
@@ -2111,7 +2111,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2111
2111
|
}
|
|
2112
2112
|
});
|
|
2113
2113
|
test("abort on move rejects with AbortError", async () => {
|
|
2114
|
-
const doc = await openFixture$
|
|
2114
|
+
const doc = await openFixture$15(engine, opts);
|
|
2115
2115
|
try {
|
|
2116
2116
|
const page = doc.page(fix.pageObjectNumber);
|
|
2117
2117
|
const a = await page.annotations.create({
|
|
@@ -2132,7 +2132,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2132
2132
|
}
|
|
2133
2133
|
});
|
|
2134
2134
|
test("a page move does NOT bump per-page RevisionTokens (weak refs survive reorder)", async () => {
|
|
2135
|
-
const doc = await openFixture$
|
|
2135
|
+
const doc = await openFixture$15(engine, opts);
|
|
2136
2136
|
try {
|
|
2137
2137
|
const list = await doc.pages.list();
|
|
2138
2138
|
if (list.pages.length < 1) return;
|
|
@@ -2147,7 +2147,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2147
2147
|
}
|
|
2148
2148
|
});
|
|
2149
2149
|
test("create a reply links /IRT and defaults /RT to \"reply\", reporting the parent", async () => {
|
|
2150
|
-
const doc = await openFixture$
|
|
2150
|
+
const doc = await openFixture$15(engine, opts);
|
|
2151
2151
|
try {
|
|
2152
2152
|
const page = doc.page(fix.pageObjectNumber);
|
|
2153
2153
|
const parent = await page.annotations.create({
|
|
@@ -2181,7 +2181,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2181
2181
|
}
|
|
2182
2182
|
});
|
|
2183
2183
|
test("create a grouped subordinate writes /RT /Group", async () => {
|
|
2184
|
-
const doc = await openFixture$
|
|
2184
|
+
const doc = await openFixture$15(engine, opts);
|
|
2185
2185
|
try {
|
|
2186
2186
|
const page = doc.page(fix.pageObjectNumber);
|
|
2187
2187
|
const primary = await page.annotations.create({
|
|
@@ -2212,7 +2212,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2212
2212
|
}
|
|
2213
2213
|
});
|
|
2214
2214
|
test("create link annotations round-trip uri, goto/xyz, goto/fitH, and dead targets", async () => {
|
|
2215
|
-
const doc = await openFixture$
|
|
2215
|
+
const doc = await openFixture$15(engine, opts);
|
|
2216
2216
|
try {
|
|
2217
2217
|
const page = doc.page(fix.pageObjectNumber);
|
|
2218
2218
|
const uri = await page.annotations.create({
|
|
@@ -2289,7 +2289,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2289
2289
|
}
|
|
2290
2290
|
});
|
|
2291
2291
|
test("a link patch retargets in both directions (uri→goto, goto→uri) and moves the rect", async () => {
|
|
2292
|
-
const doc = await openFixture$
|
|
2292
|
+
const doc = await openFixture$15(engine, opts);
|
|
2293
2293
|
try {
|
|
2294
2294
|
const page = doc.page(fix.pageObjectNumber);
|
|
2295
2295
|
const created = await page.annotations.create({
|
|
@@ -2344,7 +2344,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2344
2344
|
}
|
|
2345
2345
|
});
|
|
2346
2346
|
test("a link patch clears the target with null — a dead link on re-read", async () => {
|
|
2347
|
-
const doc = await openFixture$
|
|
2347
|
+
const doc = await openFixture$15(engine, opts);
|
|
2348
2348
|
try {
|
|
2349
2349
|
const page = doc.page(fix.pageObjectNumber);
|
|
2350
2350
|
const created = await page.annotations.create({
|
|
@@ -2383,7 +2383,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2383
2383
|
}
|
|
2384
2384
|
});
|
|
2385
2385
|
test("a link grouped to a highlight round-trips /IRT + /RT /Group with its target", async () => {
|
|
2386
|
-
const doc = await openFixture$
|
|
2386
|
+
const doc = await openFixture$15(engine, opts);
|
|
2387
2387
|
try {
|
|
2388
2388
|
const page = doc.page(fix.pageObjectNumber);
|
|
2389
2389
|
const parent = await page.annotations.create({
|
|
@@ -2417,7 +2417,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2417
2417
|
}
|
|
2418
2418
|
});
|
|
2419
2419
|
test("replace-text round-trips /IT and groups StrikeOut under its Caret", async () => {
|
|
2420
|
-
const doc = await openFixture$
|
|
2420
|
+
const doc = await openFixture$15(engine, opts);
|
|
2421
2421
|
try {
|
|
2422
2422
|
const page = doc.page(fix.pageObjectNumber);
|
|
2423
2423
|
const caret = await page.annotations.create({
|
|
@@ -2469,7 +2469,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2469
2469
|
}
|
|
2470
2470
|
});
|
|
2471
2471
|
test("patch inReplyTo: null clears /IRT and /RT (back to top-level)", async () => {
|
|
2472
|
-
const doc = await openFixture$
|
|
2472
|
+
const doc = await openFixture$15(engine, opts);
|
|
2473
2473
|
try {
|
|
2474
2474
|
const page = doc.page(fix.pageObjectNumber);
|
|
2475
2475
|
const parent = await page.annotations.create({
|
|
@@ -2496,7 +2496,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2496
2496
|
}
|
|
2497
2497
|
});
|
|
2498
2498
|
test("create with a cross-page /IRT parent throws InvalidArg", async () => {
|
|
2499
|
-
const doc = await openFixture$
|
|
2499
|
+
const doc = await openFixture$15(engine, opts);
|
|
2500
2500
|
try {
|
|
2501
2501
|
const page = doc.page(fix.pageObjectNumber);
|
|
2502
2502
|
const parent = await page.annotations.create({
|
|
@@ -2532,7 +2532,7 @@ async function beginWeakEditIfRequired(doc, pageObjectNumber, fix) {
|
|
|
2532
2532
|
if (doc.capabilities.weakAnnotationEditSessions !== "required" || !fix.expectsWeakAnnotation) return null;
|
|
2533
2533
|
return doc.annotations.beginWeakEdit([pageObjectNumber]);
|
|
2534
2534
|
}
|
|
2535
|
-
async function openFixture$
|
|
2535
|
+
async function openFixture$15(engine, opts) {
|
|
2536
2536
|
if (opts.openKind === "bytes") {
|
|
2537
2537
|
const bytes = await opts.fixture.bytes();
|
|
2538
2538
|
return engine.open({
|
|
@@ -3122,7 +3122,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3122
3122
|
if (engine) await engine.destroy();
|
|
3123
3123
|
});
|
|
3124
3124
|
test("renders the expected set of appearances with valid output", async () => {
|
|
3125
|
-
const doc = await openFixture$
|
|
3125
|
+
const doc = await openFixture$14(engine, opts);
|
|
3126
3126
|
try {
|
|
3127
3127
|
const { pageState, appearances } = await collect(doc, opts, useRaw);
|
|
3128
3128
|
expect(pageState.pageObjectNumber).toBe(opts.fixture.pageObjectNumber);
|
|
@@ -3149,7 +3149,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3149
3149
|
}
|
|
3150
3150
|
});
|
|
3151
3151
|
if (opts.fixture.expectsWeakAppearance) test("weak (index-only) annotations are emitted, not dropped", async () => {
|
|
3152
|
-
const doc = await openFixture$
|
|
3152
|
+
const doc = await openFixture$14(engine, opts);
|
|
3153
3153
|
try {
|
|
3154
3154
|
const { appearances } = await collect(doc, opts, useRaw);
|
|
3155
3155
|
const weak = appearances.find((a) => a.ref.kind === "index");
|
|
@@ -3159,7 +3159,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3159
3159
|
}
|
|
3160
3160
|
});
|
|
3161
3161
|
if (useRaw) test("rendered appearances are not blank (non-zero alpha)", async () => {
|
|
3162
|
-
const doc = await openFixture$
|
|
3162
|
+
const doc = await openFixture$14(engine, opts);
|
|
3163
3163
|
try {
|
|
3164
3164
|
const { appearances } = await collect(doc, opts, useRaw);
|
|
3165
3165
|
const anyVisible = appearances.some((a) => a.raster !== null && hasOpaquePixel(a.raster));
|
|
@@ -3169,7 +3169,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3169
3169
|
}
|
|
3170
3170
|
});
|
|
3171
3171
|
test("abort() rejects with AbortError", async () => {
|
|
3172
|
-
const doc = await openFixture$
|
|
3172
|
+
const doc = await openFixture$14(engine, opts);
|
|
3173
3173
|
try {
|
|
3174
3174
|
const page = doc.page(opts.fixture.pageObjectNumber);
|
|
3175
3175
|
const p = useRaw ? page.annotations.renderAppearances({ scale: 1 }) : page.annotations.renderAppearanceImages({
|
|
@@ -3224,7 +3224,7 @@ function hasOpaquePixel(raster) {
|
|
|
3224
3224
|
}
|
|
3225
3225
|
return false;
|
|
3226
3226
|
}
|
|
3227
|
-
async function openFixture$
|
|
3227
|
+
async function openFixture$14(engine, opts) {
|
|
3228
3228
|
if (opts.openKind === "bytes") {
|
|
3229
3229
|
const bytes = await opts.fixture.bytes();
|
|
3230
3230
|
return engine.open({
|
|
@@ -3293,7 +3293,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3293
3293
|
if (engine) await engine.destroy();
|
|
3294
3294
|
});
|
|
3295
3295
|
test("pages.list() returns every page in display order, durable PONs only", async () => {
|
|
3296
|
-
const doc = await openFixture$
|
|
3296
|
+
const doc = await openFixture$13(engine, opts);
|
|
3297
3297
|
try {
|
|
3298
3298
|
const list = await doc.pages.list();
|
|
3299
3299
|
expect(PageListSnapshotSchema.safeParse(list).success).toBe(true);
|
|
@@ -3312,7 +3312,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3312
3312
|
}
|
|
3313
3313
|
});
|
|
3314
3314
|
test("pages.move() reorders pages and returns the full post-move order", async () => {
|
|
3315
|
-
const doc = await openFixture$
|
|
3315
|
+
const doc = await openFixture$13(engine, opts);
|
|
3316
3316
|
try {
|
|
3317
3317
|
const before = await doc.pages.list();
|
|
3318
3318
|
if (before.pages.length < 3) return;
|
|
@@ -3336,7 +3336,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3336
3336
|
}
|
|
3337
3337
|
});
|
|
3338
3338
|
test("weak index-based annotation refs survive a page reorder", async () => {
|
|
3339
|
-
const doc = await openFixture$
|
|
3339
|
+
const doc = await openFixture$13(engine, opts);
|
|
3340
3340
|
try {
|
|
3341
3341
|
const list = await doc.pages.list();
|
|
3342
3342
|
if (list.pages.length < 2) return;
|
|
@@ -3373,7 +3373,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3373
3373
|
}
|
|
3374
3374
|
});
|
|
3375
3375
|
test("pages.move() rejects duplicate PONs with InvalidArg", async () => {
|
|
3376
|
-
const doc = await openFixture$
|
|
3376
|
+
const doc = await openFixture$13(engine, opts);
|
|
3377
3377
|
try {
|
|
3378
3378
|
const list = await doc.pages.list();
|
|
3379
3379
|
if (list.pages.length < 1) return;
|
|
@@ -3390,7 +3390,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3390
3390
|
}
|
|
3391
3391
|
});
|
|
3392
3392
|
test("pages.move() rejects out-of-range destIndex with InvalidArg", async () => {
|
|
3393
|
-
const doc = await openFixture$
|
|
3393
|
+
const doc = await openFixture$13(engine, opts);
|
|
3394
3394
|
try {
|
|
3395
3395
|
const list = await doc.pages.list();
|
|
3396
3396
|
if (list.pages.length < 1) return;
|
|
@@ -3407,7 +3407,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3407
3407
|
}
|
|
3408
3408
|
});
|
|
3409
3409
|
test("pages.move() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3410
|
-
const doc = await openFixture$
|
|
3410
|
+
const doc = await openFixture$13(engine, opts);
|
|
3411
3411
|
try {
|
|
3412
3412
|
const list = await doc.pages.list();
|
|
3413
3413
|
let bogus = 0;
|
|
@@ -3425,7 +3425,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3425
3425
|
}
|
|
3426
3426
|
});
|
|
3427
3427
|
test("abort on pages.move() rejects with AbortError", async () => {
|
|
3428
|
-
const doc = await openFixture$
|
|
3428
|
+
const doc = await openFixture$13(engine, opts);
|
|
3429
3429
|
try {
|
|
3430
3430
|
const list = await doc.pages.list();
|
|
3431
3431
|
if (list.pages.length < 1) return;
|
|
@@ -3439,7 +3439,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3439
3439
|
});
|
|
3440
3440
|
});
|
|
3441
3441
|
}
|
|
3442
|
-
async function openFixture$
|
|
3442
|
+
async function openFixture$13(engine, opts) {
|
|
3443
3443
|
if (opts.openKind === "bytes") {
|
|
3444
3444
|
const bytes = await opts.fixture.bytes();
|
|
3445
3445
|
return engine.open({
|
|
@@ -3513,7 +3513,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3513
3513
|
if (engine) await engine.destroy();
|
|
3514
3514
|
});
|
|
3515
3515
|
test("pages.rotate() sets the absolute rotation and returns the full layout", async () => {
|
|
3516
|
-
const doc = await openFixture$
|
|
3516
|
+
const doc = await openFixture$12(engine, opts);
|
|
3517
3517
|
try {
|
|
3518
3518
|
const before = await doc.pages.list();
|
|
3519
3519
|
const target = before.pages[0];
|
|
@@ -3532,7 +3532,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3532
3532
|
}
|
|
3533
3533
|
});
|
|
3534
3534
|
test("absolute rotation is idempotent: setting the same value twice is a no-op", async () => {
|
|
3535
|
-
const doc = await openFixture$
|
|
3535
|
+
const doc = await openFixture$12(engine, opts);
|
|
3536
3536
|
try {
|
|
3537
3537
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3538
3538
|
const first = await doc.pages.rotate([pon], 180);
|
|
@@ -3543,7 +3543,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3543
3543
|
}
|
|
3544
3544
|
});
|
|
3545
3545
|
test("one rotation applies to EVERY listed page (the multi-select gesture)", async () => {
|
|
3546
|
-
const doc = await openFixture$
|
|
3546
|
+
const doc = await openFixture$12(engine, opts);
|
|
3547
3547
|
try {
|
|
3548
3548
|
const list = await doc.pages.list();
|
|
3549
3549
|
if (list.pages.length < 2) return;
|
|
@@ -3555,7 +3555,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3555
3555
|
}
|
|
3556
3556
|
});
|
|
3557
3557
|
test("weak index-based annotation refs survive a rotate (no revision bump)", async () => {
|
|
3558
|
-
const doc = await openFixture$
|
|
3558
|
+
const doc = await openFixture$12(engine, opts);
|
|
3559
3559
|
try {
|
|
3560
3560
|
const hostPon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3561
3561
|
const hostPage = doc.page(hostPon);
|
|
@@ -3585,7 +3585,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3585
3585
|
}
|
|
3586
3586
|
});
|
|
3587
3587
|
test("pages.rotate() rejects an invalid rotation value with InvalidArg", async () => {
|
|
3588
|
-
const doc = await openFixture$
|
|
3588
|
+
const doc = await openFixture$12(engine, opts);
|
|
3589
3589
|
try {
|
|
3590
3590
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3591
3591
|
let caught;
|
|
@@ -3600,7 +3600,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3600
3600
|
}
|
|
3601
3601
|
});
|
|
3602
3602
|
test("pages.rotate() rejects duplicate PONs with InvalidArg", async () => {
|
|
3603
|
-
const doc = await openFixture$
|
|
3603
|
+
const doc = await openFixture$12(engine, opts);
|
|
3604
3604
|
try {
|
|
3605
3605
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3606
3606
|
let caught;
|
|
@@ -3615,7 +3615,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3615
3615
|
}
|
|
3616
3616
|
});
|
|
3617
3617
|
test("pages.rotate() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3618
|
-
const doc = await openFixture$
|
|
3618
|
+
const doc = await openFixture$12(engine, opts);
|
|
3619
3619
|
try {
|
|
3620
3620
|
const list = await doc.pages.list();
|
|
3621
3621
|
let bogus = 0;
|
|
@@ -3633,7 +3633,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3633
3633
|
}
|
|
3634
3634
|
});
|
|
3635
3635
|
test("abort on pages.rotate() rejects with AbortError", async () => {
|
|
3636
|
-
const doc = await openFixture$
|
|
3636
|
+
const doc = await openFixture$12(engine, opts);
|
|
3637
3637
|
try {
|
|
3638
3638
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3639
3639
|
const p = doc.pages.rotate([pon], 90);
|
|
@@ -3645,7 +3645,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3645
3645
|
});
|
|
3646
3646
|
});
|
|
3647
3647
|
}
|
|
3648
|
-
async function openFixture$
|
|
3648
|
+
async function openFixture$12(engine, opts) {
|
|
3649
3649
|
if (opts.openKind === "bytes") {
|
|
3650
3650
|
const bytes = await opts.fixture.bytes();
|
|
3651
3651
|
return engine.open({
|
|
@@ -3708,7 +3708,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3708
3708
|
if (engine) await engine.destroy();
|
|
3709
3709
|
});
|
|
3710
3710
|
test("pages.delete() removes the page and returns the surviving layout", async () => {
|
|
3711
|
-
const doc = await openFixture$
|
|
3711
|
+
const doc = await openFixture$11(engine, opts);
|
|
3712
3712
|
try {
|
|
3713
3713
|
const before = await doc.pages.list();
|
|
3714
3714
|
if (before.pages.length < 2) return;
|
|
@@ -3729,7 +3729,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3729
3729
|
}
|
|
3730
3730
|
});
|
|
3731
3731
|
test("addressing a deleted page afterwards is a clean NotFound", async () => {
|
|
3732
|
-
const doc = await openFixture$
|
|
3732
|
+
const doc = await openFixture$11(engine, opts);
|
|
3733
3733
|
try {
|
|
3734
3734
|
const before = await doc.pages.list();
|
|
3735
3735
|
if (before.pages.length < 2) return;
|
|
@@ -3747,7 +3747,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3747
3747
|
}
|
|
3748
3748
|
});
|
|
3749
3749
|
test("surviving pages keep their weak index-based annotation refs", async () => {
|
|
3750
|
-
const doc = await openFixture$
|
|
3750
|
+
const doc = await openFixture$11(engine, opts);
|
|
3751
3751
|
try {
|
|
3752
3752
|
const list = await doc.pages.list();
|
|
3753
3753
|
if (list.pages.length < 2) return;
|
|
@@ -3780,7 +3780,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3780
3780
|
}
|
|
3781
3781
|
});
|
|
3782
3782
|
test("deleting EVERY page is rejected with InvalidArg", async () => {
|
|
3783
|
-
const doc = await openFixture$
|
|
3783
|
+
const doc = await openFixture$11(engine, opts);
|
|
3784
3784
|
try {
|
|
3785
3785
|
const list = await doc.pages.list();
|
|
3786
3786
|
let caught;
|
|
@@ -3795,7 +3795,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3795
3795
|
}
|
|
3796
3796
|
});
|
|
3797
3797
|
test("pages.delete() rejects duplicate PONs with InvalidArg", async () => {
|
|
3798
|
-
const doc = await openFixture$
|
|
3798
|
+
const doc = await openFixture$11(engine, opts);
|
|
3799
3799
|
try {
|
|
3800
3800
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3801
3801
|
let caught;
|
|
@@ -3810,7 +3810,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3810
3810
|
}
|
|
3811
3811
|
});
|
|
3812
3812
|
test("pages.delete() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3813
|
-
const doc = await openFixture$
|
|
3813
|
+
const doc = await openFixture$11(engine, opts);
|
|
3814
3814
|
try {
|
|
3815
3815
|
const list = await doc.pages.list();
|
|
3816
3816
|
let bogus = 0;
|
|
@@ -3828,7 +3828,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3828
3828
|
}
|
|
3829
3829
|
});
|
|
3830
3830
|
test("abort on pages.delete() rejects with AbortError", async () => {
|
|
3831
|
-
const doc = await openFixture$
|
|
3831
|
+
const doc = await openFixture$11(engine, opts);
|
|
3832
3832
|
try {
|
|
3833
3833
|
const list = await doc.pages.list();
|
|
3834
3834
|
if (list.pages.length < 2) return;
|
|
@@ -3842,7 +3842,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3842
3842
|
});
|
|
3843
3843
|
});
|
|
3844
3844
|
}
|
|
3845
|
-
async function openFixture$
|
|
3845
|
+
async function openFixture$11(engine, opts) {
|
|
3846
3846
|
if (opts.openKind === "bytes") {
|
|
3847
3847
|
const bytes = await opts.fixture.bytes();
|
|
3848
3848
|
return engine.open({
|
|
@@ -3870,7 +3870,7 @@ function runPageFlattenConformance(runner, opts) {
|
|
|
3870
3870
|
if (engine) await engine.destroy();
|
|
3871
3871
|
});
|
|
3872
3872
|
test("flattens eligible appearances once without changing layout", async () => {
|
|
3873
|
-
const doc = await openFixture$
|
|
3873
|
+
const doc = await openFixture$10(engine, opts);
|
|
3874
3874
|
try {
|
|
3875
3875
|
if (!doc.pages.flatten) return;
|
|
3876
3876
|
const layoutBefore = await doc.pages.list();
|
|
@@ -3904,7 +3904,7 @@ function runPageFlattenConformance(runner, opts) {
|
|
|
3904
3904
|
});
|
|
3905
3905
|
});
|
|
3906
3906
|
}
|
|
3907
|
-
async function openFixture$
|
|
3907
|
+
async function openFixture$10(engine, opts) {
|
|
3908
3908
|
if (opts.openKind === "bytes") return engine.open({
|
|
3909
3909
|
kind: "bytes",
|
|
3910
3910
|
id: opts.fixture.id,
|
|
@@ -3959,7 +3959,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
3959
3959
|
if (engine) await engine.destroy();
|
|
3960
3960
|
});
|
|
3961
3961
|
test("annotations scope applies the marked redaction and counts collateral", async () => {
|
|
3962
|
-
const doc = await openFixture$
|
|
3962
|
+
const doc = await openFixture$9(engine, opts);
|
|
3963
3963
|
try {
|
|
3964
3964
|
if (!doc.redaction) return;
|
|
3965
3965
|
const layoutBefore = await doc.pages.list();
|
|
@@ -4013,7 +4013,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
4013
4013
|
}
|
|
4014
4014
|
});
|
|
4015
4015
|
test("pages scope applies everything once and validates its input", async () => {
|
|
4016
|
-
const doc = await openFixture$
|
|
4016
|
+
const doc = await openFixture$9(engine, opts);
|
|
4017
4017
|
try {
|
|
4018
4018
|
if (!doc.redaction) return;
|
|
4019
4019
|
const pageObjectNumber = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
@@ -4064,7 +4064,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
4064
4064
|
});
|
|
4065
4065
|
});
|
|
4066
4066
|
}
|
|
4067
|
-
async function openFixture$
|
|
4067
|
+
async function openFixture$9(engine, opts) {
|
|
4068
4068
|
if (opts.openKind === "bytes") return engine.open({
|
|
4069
4069
|
kind: "bytes",
|
|
4070
4070
|
id: opts.fixture.id,
|
|
@@ -4104,19 +4104,14 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4104
4104
|
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
4105
4105
|
describe(`page extract conformance: ${opts.label}`, () => {
|
|
4106
4106
|
let engine;
|
|
4107
|
-
let supported = false;
|
|
4108
4107
|
beforeAll(async () => {
|
|
4109
4108
|
engine = await opts.makeEngine();
|
|
4110
|
-
const probe = await openFixture$7(engine, opts);
|
|
4111
|
-
supported = probe.pages.extract !== void 0;
|
|
4112
|
-
await probe.close();
|
|
4113
4109
|
});
|
|
4114
4110
|
afterAll(async () => {
|
|
4115
4111
|
if (engine) await engine.destroy();
|
|
4116
4112
|
});
|
|
4117
4113
|
test("pages.extract() returns standalone PDF bytes and leaves the source untouched", async () => {
|
|
4118
|
-
|
|
4119
|
-
const doc = await openFixture$7(engine, opts);
|
|
4114
|
+
const doc = await openFixture$8(engine, opts);
|
|
4120
4115
|
try {
|
|
4121
4116
|
const before = await doc.pages.list();
|
|
4122
4117
|
const target = before.pages[before.pages.length - 1];
|
|
@@ -4131,8 +4126,8 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4131
4126
|
}
|
|
4132
4127
|
});
|
|
4133
4128
|
test("extracted bytes re-open as a document with the requested pages, in caller order", async () => {
|
|
4134
|
-
if (
|
|
4135
|
-
const doc = await openFixture$
|
|
4129
|
+
if (opts.openKind !== "bytes") return;
|
|
4130
|
+
const doc = await openFixture$8(engine, opts);
|
|
4136
4131
|
let extracted = null;
|
|
4137
4132
|
try {
|
|
4138
4133
|
const list = await doc.pages.list();
|
|
@@ -4155,8 +4150,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4155
4150
|
}
|
|
4156
4151
|
});
|
|
4157
4152
|
test("pages.extract() rejects empty input with InvalidArg", async () => {
|
|
4158
|
-
|
|
4159
|
-
const doc = await openFixture$7(engine, opts);
|
|
4153
|
+
const doc = await openFixture$8(engine, opts);
|
|
4160
4154
|
try {
|
|
4161
4155
|
let caught;
|
|
4162
4156
|
try {
|
|
@@ -4170,8 +4164,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4170
4164
|
}
|
|
4171
4165
|
});
|
|
4172
4166
|
test("pages.extract() rejects duplicate PONs with InvalidArg", async () => {
|
|
4173
|
-
|
|
4174
|
-
const doc = await openFixture$7(engine, opts);
|
|
4167
|
+
const doc = await openFixture$8(engine, opts);
|
|
4175
4168
|
try {
|
|
4176
4169
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
4177
4170
|
let caught;
|
|
@@ -4186,8 +4179,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4186
4179
|
}
|
|
4187
4180
|
});
|
|
4188
4181
|
test("pages.extract() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
4189
|
-
|
|
4190
|
-
const doc = await openFixture$7(engine, opts);
|
|
4182
|
+
const doc = await openFixture$8(engine, opts);
|
|
4191
4183
|
try {
|
|
4192
4184
|
const list = await doc.pages.list();
|
|
4193
4185
|
let bogus = 0;
|
|
@@ -4205,8 +4197,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4205
4197
|
}
|
|
4206
4198
|
});
|
|
4207
4199
|
test("abort on pages.extract() rejects with AbortError", async () => {
|
|
4208
|
-
|
|
4209
|
-
const doc = await openFixture$7(engine, opts);
|
|
4200
|
+
const doc = await openFixture$8(engine, opts);
|
|
4210
4201
|
try {
|
|
4211
4202
|
const list = await doc.pages.list();
|
|
4212
4203
|
const p = doc.pages.extract([list.pages[0].pageObjectNumber]);
|
|
@@ -4218,7 +4209,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4218
4209
|
});
|
|
4219
4210
|
});
|
|
4220
4211
|
}
|
|
4221
|
-
async function openFixture$
|
|
4212
|
+
async function openFixture$8(engine, opts) {
|
|
4222
4213
|
if (opts.openKind === "bytes") {
|
|
4223
4214
|
const bytes = await opts.fixture.bytes();
|
|
4224
4215
|
return engine.open({
|
|
@@ -4480,9 +4471,9 @@ function runAttachmentConformance(runner, opts) {
|
|
|
4480
4471
|
//#endregion
|
|
4481
4472
|
//#region src/conformance/runPageInsertConformance.ts
|
|
4482
4473
|
/**
|
|
4483
|
-
* Page insert conformance. `pages.insert
|
|
4484
|
-
*
|
|
4485
|
-
*
|
|
4474
|
+
* Page insert conformance. `pages.insert` is a REQUIRED member — this suite
|
|
4475
|
+
* runs unconditionally on every engine, so an implementation that loses the
|
|
4476
|
+
* verb fails loudly instead of being skipped past.
|
|
4486
4477
|
*
|
|
4487
4478
|
* Invariants:
|
|
4488
4479
|
* 1. Every page of the source bytes is COPIED in at `destIndex` (omitted →
|
|
@@ -4498,19 +4489,14 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4498
4489
|
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
4499
4490
|
describe(`page insert conformance: ${opts.label}`, () => {
|
|
4500
4491
|
let engine;
|
|
4501
|
-
let supported = false;
|
|
4502
4492
|
beforeAll(async () => {
|
|
4503
4493
|
engine = await opts.makeEngine();
|
|
4504
|
-
const probe = await openFixture$6(engine, opts);
|
|
4505
|
-
supported = probe.pages.insert !== void 0 && probe.pages.extract !== void 0;
|
|
4506
|
-
await probe.close();
|
|
4507
4494
|
});
|
|
4508
4495
|
afterAll(async () => {
|
|
4509
4496
|
if (engine) await engine.destroy();
|
|
4510
4497
|
});
|
|
4511
4498
|
test("appends every source page with fresh PONs; existing pages keep identity", async () => {
|
|
4512
|
-
|
|
4513
|
-
const doc = await openFixture$6(engine, opts);
|
|
4499
|
+
const doc = await openFixture$7(engine, opts);
|
|
4514
4500
|
try {
|
|
4515
4501
|
const before = await doc.pages.list();
|
|
4516
4502
|
const beforePons = before.pages.map((p) => p.pageObjectNumber);
|
|
@@ -4528,8 +4514,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4528
4514
|
}
|
|
4529
4515
|
});
|
|
4530
4516
|
test("destIndex places the block mid-document, in source order", async () => {
|
|
4531
|
-
|
|
4532
|
-
const doc = await openFixture$6(engine, opts);
|
|
4517
|
+
const doc = await openFixture$7(engine, opts);
|
|
4533
4518
|
try {
|
|
4534
4519
|
const before = await doc.pages.list();
|
|
4535
4520
|
if (before.pages.length < 2) return;
|
|
@@ -4546,8 +4531,8 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4546
4531
|
}
|
|
4547
4532
|
});
|
|
4548
4533
|
test("the inserted pages persist through save → re-open", async () => {
|
|
4549
|
-
if (
|
|
4550
|
-
const doc = await openFixture$
|
|
4534
|
+
if (opts.openKind !== "bytes") return;
|
|
4535
|
+
const doc = await openFixture$7(engine, opts);
|
|
4551
4536
|
let reopened = null;
|
|
4552
4537
|
try {
|
|
4553
4538
|
const before = await doc.pages.list();
|
|
@@ -4567,8 +4552,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4567
4552
|
}
|
|
4568
4553
|
});
|
|
4569
4554
|
test("empty bytes reject with InvalidArg; garbage rejects with MalformedPdf", async () => {
|
|
4570
|
-
|
|
4571
|
-
const doc = await openFixture$6(engine, opts);
|
|
4555
|
+
const doc = await openFixture$7(engine, opts);
|
|
4572
4556
|
try {
|
|
4573
4557
|
let caught;
|
|
4574
4558
|
try {
|
|
@@ -4591,8 +4575,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4591
4575
|
}
|
|
4592
4576
|
});
|
|
4593
4577
|
test("out-of-range destIndex rejects with InvalidArg", async () => {
|
|
4594
|
-
|
|
4595
|
-
const doc = await openFixture$6(engine, opts);
|
|
4578
|
+
const doc = await openFixture$7(engine, opts);
|
|
4596
4579
|
try {
|
|
4597
4580
|
const before = await doc.pages.list();
|
|
4598
4581
|
const single = await doc.pages.extract([before.pages[0].pageObjectNumber]);
|
|
@@ -4609,6 +4592,159 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4609
4592
|
});
|
|
4610
4593
|
});
|
|
4611
4594
|
}
|
|
4595
|
+
async function openFixture$7(engine, opts) {
|
|
4596
|
+
if (opts.openKind === "bytes") {
|
|
4597
|
+
const bytes = await opts.fixture.bytes();
|
|
4598
|
+
return engine.open({
|
|
4599
|
+
kind: "bytes",
|
|
4600
|
+
id: opts.fixture.id,
|
|
4601
|
+
bytes
|
|
4602
|
+
});
|
|
4603
|
+
}
|
|
4604
|
+
return engine.open({
|
|
4605
|
+
kind: "id",
|
|
4606
|
+
id: opts.fixture.cloudId ?? opts.fixture.id
|
|
4607
|
+
});
|
|
4608
|
+
}
|
|
4609
|
+
//#endregion
|
|
4610
|
+
//#region src/conformance/runPageInsertBlankConformance.ts
|
|
4611
|
+
/** An on-purpose non-default size so the assertions can't pass by accident. */
|
|
4612
|
+
const SIZE = {
|
|
4613
|
+
width: 396,
|
|
4614
|
+
height: 612
|
|
4615
|
+
};
|
|
4616
|
+
/**
|
|
4617
|
+
* Blank-page insert conformance. `pages.insertBlank` is a REQUIRED member —
|
|
4618
|
+
* the suite runs unconditionally on every engine (no fixture bytes are
|
|
4619
|
+
* needed at all, which is the point of the verb), so an implementation that
|
|
4620
|
+
* loses the verb fails loudly instead of being skipped past.
|
|
4621
|
+
*
|
|
4622
|
+
* Invariants:
|
|
4623
|
+
* 1. `count` blank pages of exactly `size` appear at `destIndex` (omitted
|
|
4624
|
+
* → append), rotation 0; the result lists their fresh PONs in insertion
|
|
4625
|
+
* order and they agree with the returned layout.
|
|
4626
|
+
* 2. Pre-existing pages keep their identity: same PONs before and after,
|
|
4627
|
+
* in the expected positions (an insert never invalidates neighbours).
|
|
4628
|
+
* 3. The mutation persists through save → re-open (bytes engines only).
|
|
4629
|
+
* 4. Non-positive size / count outside [1, PAGE_INSERT_BLANK_MAX_COUNT] /
|
|
4630
|
+
* out-of-range destIndex reject with InvalidArg, leaving the document
|
|
4631
|
+
* untouched.
|
|
4632
|
+
*/
|
|
4633
|
+
function runPageInsertBlankConformance(runner, opts) {
|
|
4634
|
+
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
4635
|
+
describe(`page insert-blank conformance: ${opts.label}`, () => {
|
|
4636
|
+
let engine;
|
|
4637
|
+
beforeAll(async () => {
|
|
4638
|
+
engine = await opts.makeEngine();
|
|
4639
|
+
});
|
|
4640
|
+
afterAll(async () => {
|
|
4641
|
+
if (engine) await engine.destroy();
|
|
4642
|
+
});
|
|
4643
|
+
test("appends one blank page of the requested size with a fresh PON", async () => {
|
|
4644
|
+
const doc = await openFixture$6(engine, opts);
|
|
4645
|
+
try {
|
|
4646
|
+
const before = await doc.pages.list();
|
|
4647
|
+
const beforePons = before.pages.map((p) => p.pageObjectNumber);
|
|
4648
|
+
const result = await doc.pages.insertBlank({ size: SIZE });
|
|
4649
|
+
expect(result.insertedPageObjectNumbers.length).toBe(1);
|
|
4650
|
+
expect(result.layout.pageCount).toBe(before.pageCount + 1);
|
|
4651
|
+
expect(result.layout.pages.slice(0, before.pageCount).map((p) => p.pageObjectNumber)).toEqual(beforePons);
|
|
4652
|
+
const newPon = result.insertedPageObjectNumbers[0];
|
|
4653
|
+
expect(beforePons.includes(newPon)).toBe(false);
|
|
4654
|
+
const appended = result.layout.pages[before.pageCount];
|
|
4655
|
+
expect(appended.pageObjectNumber).toBe(newPon);
|
|
4656
|
+
expect(appended.size).toEqual(SIZE);
|
|
4657
|
+
expect(appended.rotation).toBe(0);
|
|
4658
|
+
} finally {
|
|
4659
|
+
await doc.close();
|
|
4660
|
+
}
|
|
4661
|
+
});
|
|
4662
|
+
test("destIndex + count places the blank block mid-document", async () => {
|
|
4663
|
+
const doc = await openFixture$6(engine, opts);
|
|
4664
|
+
try {
|
|
4665
|
+
const before = await doc.pages.list();
|
|
4666
|
+
if (before.pages.length < 2) return;
|
|
4667
|
+
const beforePons = before.pages.map((p) => p.pageObjectNumber);
|
|
4668
|
+
const result = await doc.pages.insertBlank({
|
|
4669
|
+
size: SIZE,
|
|
4670
|
+
count: 2
|
|
4671
|
+
}, 1);
|
|
4672
|
+
expect(result.insertedPageObjectNumbers.length).toBe(2);
|
|
4673
|
+
expect(result.insertedPageObjectNumbers[0] === result.insertedPageObjectNumbers[1]).toBe(false);
|
|
4674
|
+
const pons = result.layout.pages.map((p) => p.pageObjectNumber);
|
|
4675
|
+
expect(pons[0]).toBe(beforePons[0]);
|
|
4676
|
+
expect(pons.slice(1, 3)).toEqual(result.insertedPageObjectNumbers);
|
|
4677
|
+
expect(pons.slice(3)).toEqual(beforePons.slice(1));
|
|
4678
|
+
expect(result.layout.pages[1].size).toEqual(SIZE);
|
|
4679
|
+
expect(result.layout.pages[2].size).toEqual(SIZE);
|
|
4680
|
+
} finally {
|
|
4681
|
+
await doc.close();
|
|
4682
|
+
}
|
|
4683
|
+
});
|
|
4684
|
+
test("the blank pages persist through save → re-open", async () => {
|
|
4685
|
+
if (opts.openKind !== "bytes") return;
|
|
4686
|
+
const doc = await openFixture$6(engine, opts);
|
|
4687
|
+
let reopened = null;
|
|
4688
|
+
try {
|
|
4689
|
+
const before = await doc.pages.list();
|
|
4690
|
+
await doc.pages.insertBlank({ size: SIZE });
|
|
4691
|
+
const bytes = await doc.download();
|
|
4692
|
+
reopened = await engine.open({
|
|
4693
|
+
kind: "bytes",
|
|
4694
|
+
id: `${opts.fixture.id}-insert-blank-reopen`,
|
|
4695
|
+
bytes
|
|
4696
|
+
});
|
|
4697
|
+
const after = await reopened.pages.list();
|
|
4698
|
+
expect(after.pageCount).toBe(before.pageCount + 1);
|
|
4699
|
+
const tail = after.pages[after.pageCount - 1];
|
|
4700
|
+
expect(Math.round(tail.size.width)).toBe(SIZE.width);
|
|
4701
|
+
expect(Math.round(tail.size.height)).toBe(SIZE.height);
|
|
4702
|
+
} finally {
|
|
4703
|
+
if (reopened) await reopened.close();
|
|
4704
|
+
await doc.close();
|
|
4705
|
+
}
|
|
4706
|
+
});
|
|
4707
|
+
test("non-positive size, bad count, and out-of-range destIndex reject with InvalidArg", async () => {
|
|
4708
|
+
const doc = await openFixture$6(engine, opts);
|
|
4709
|
+
try {
|
|
4710
|
+
const before = await doc.pages.list();
|
|
4711
|
+
const rejects = [
|
|
4712
|
+
() => doc.pages.insertBlank({ size: {
|
|
4713
|
+
width: 0,
|
|
4714
|
+
height: 612
|
|
4715
|
+
} }),
|
|
4716
|
+
() => doc.pages.insertBlank({ size: {
|
|
4717
|
+
width: 396,
|
|
4718
|
+
height: -10
|
|
4719
|
+
} }),
|
|
4720
|
+
() => doc.pages.insertBlank({
|
|
4721
|
+
size: SIZE,
|
|
4722
|
+
count: 0
|
|
4723
|
+
}),
|
|
4724
|
+
() => doc.pages.insertBlank({
|
|
4725
|
+
size: SIZE,
|
|
4726
|
+
count: 101
|
|
4727
|
+
}),
|
|
4728
|
+
() => doc.pages.insertBlank({ size: SIZE }, before.pageCount + 1)
|
|
4729
|
+
];
|
|
4730
|
+
for (const attempt of rejects) {
|
|
4731
|
+
let caught;
|
|
4732
|
+
try {
|
|
4733
|
+
await attempt();
|
|
4734
|
+
} catch (err) {
|
|
4735
|
+
caught = err;
|
|
4736
|
+
}
|
|
4737
|
+
expect(EngineError.is(caught, EngineErrorCode.InvalidArg)).toBe(true);
|
|
4738
|
+
}
|
|
4739
|
+
const list = await doc.pages.list();
|
|
4740
|
+
expect(list.pageCount).toBe(before.pageCount);
|
|
4741
|
+
expect(list.pages.map((p) => p.pageObjectNumber)).toEqual(before.pages.map((p) => p.pageObjectNumber));
|
|
4742
|
+
} finally {
|
|
4743
|
+
await doc.close();
|
|
4744
|
+
}
|
|
4745
|
+
});
|
|
4746
|
+
});
|
|
4747
|
+
}
|
|
4612
4748
|
async function openFixture$6(engine, opts) {
|
|
4613
4749
|
if (opts.openKind === "bytes") {
|
|
4614
4750
|
const bytes = await opts.fixture.bytes();
|
|
@@ -4916,6 +5052,28 @@ function runDocumentEventsConformance(runner, opts) {
|
|
|
4916
5052
|
await doc.close();
|
|
4917
5053
|
}
|
|
4918
5054
|
});
|
|
5055
|
+
test("pages.inserted rides verbatim", async () => {
|
|
5056
|
+
const doc = await openFixture$4(engine, opts);
|
|
5057
|
+
try {
|
|
5058
|
+
const events = [];
|
|
5059
|
+
doc.events.subscribe((event) => events.push(event));
|
|
5060
|
+
const inserted = await doc.pages.insertBlank({ size: {
|
|
5061
|
+
width: 396,
|
|
5062
|
+
height: 612
|
|
5063
|
+
} }, 0);
|
|
5064
|
+
expect(events.map((event) => event.type)).toEqual(["pages.inserted"]);
|
|
5065
|
+
const [evInserted] = events;
|
|
5066
|
+
if (evInserted.type === "pages.inserted") {
|
|
5067
|
+
expect(evInserted.insertedPageObjectNumbers).toEqual(inserted.insertedPageObjectNumbers);
|
|
5068
|
+
expect(evInserted.layout).toEqual(inserted.layout);
|
|
5069
|
+
expect(evInserted.cache).toEqual(inserted.cache);
|
|
5070
|
+
expect(evInserted.destIndex).toBe(0);
|
|
5071
|
+
expect(evInserted.origin.kind).toBe("local");
|
|
5072
|
+
}
|
|
5073
|
+
} finally {
|
|
5074
|
+
await doc.close();
|
|
5075
|
+
}
|
|
5076
|
+
});
|
|
4919
5077
|
test("a FAILED mutation publishes nothing (events are ground truth)", async () => {
|
|
4920
5078
|
const doc = await openFixture$4(engine, opts);
|
|
4921
5079
|
try {
|
|
@@ -5720,6 +5878,6 @@ function diffAnnotation(i, a, b, errs) {
|
|
|
5720
5878
|
if (a.nm !== b.nm) errs.push(`annotations[${i}].nm mismatch: ${a.nm} vs ${b.nm}`);
|
|
5721
5879
|
}
|
|
5722
5880
|
//#endregion
|
|
5723
|
-
export { TEXT_DIVERGENCE_CASES, diffAnnotationListSnapshot, diffAnnotationListSnapshotAll, runActionsConformance, runAnnotationAppearanceConformance, runAnnotationMutationConformance, runAnnotationReadConformance, runAttachmentConformance, runDocumentEventsConformance, runFormConformance, runMetadataConformance, runPageDeleteConformance, runPageExtractConformance, runPageFlattenConformance, runPageGeometryOrientationConformance, runPageInsertConformance, runPageReorderConformance, runPageRotateConformance, runPageTextConformance, runPieceInfoConformance, runRedactionApplyConformance, runSearchConformance, runTextDivergenceConformance };
|
|
5881
|
+
export { TEXT_DIVERGENCE_CASES, diffAnnotationListSnapshot, diffAnnotationListSnapshotAll, runActionsConformance, runAnnotationAppearanceConformance, runAnnotationMutationConformance, runAnnotationReadConformance, runAttachmentConformance, runDocumentEventsConformance, runFormConformance, runMetadataConformance, runPageDeleteConformance, runPageExtractConformance, runPageFlattenConformance, runPageGeometryOrientationConformance, runPageInsertBlankConformance, runPageInsertConformance, runPageReorderConformance, runPageRotateConformance, runPageTextConformance, runPieceInfoConformance, runRedactionApplyConformance, runSearchConformance, runTextDivergenceConformance };
|
|
5724
5882
|
|
|
5725
5883
|
//# sourceMappingURL=conformance.js.map
|