@embedpdf/engine-core 3.0.0-next.3 → 3.0.0-next.4
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-ByBflvEl.cjs → AbortError-BFwCIKC6.cjs} +2 -2
- package/dist/{AbortError-ByBflvEl.cjs.map → AbortError-BFwCIKC6.cjs.map} +1 -1
- package/dist/{AbortError-CjSasIlL.js → AbortError-D0w0N4pJ.js} +2 -2
- package/dist/{AbortError-CjSasIlL.js.map → AbortError-D0w0N4pJ.js.map} +1 -1
- package/dist/{AnnotationListSnapshot-W0RCsyDE.d.cts → AnnotationListSnapshot-_Z600IzD.d.cts} +216 -20
- package/dist/{AnnotationListSnapshot-W0RCsyDE.d.ts → AnnotationListSnapshot-_Z600IzD.d.ts} +216 -20
- package/dist/{DocumentSecurityService-B-tULKNY.d.ts → DocumentSecurityService-BR4tesJK.d.ts} +2 -2
- package/dist/{DocumentSecurityService-Df79fgpe.d.cts → DocumentSecurityService-CoHQf0Ju.d.cts} +2 -2
- package/dist/{Engine-D9loFZc1.d.cts → Engine-LHgbW5z-.d.cts} +4 -4
- package/dist/{Engine-B7Oe7f5i.d.ts → Engine-h_6P4pjM.d.ts} +4 -4
- package/dist/{builders-C548U47M.js → builders-BWgXkLKd.js} +382 -167
- package/dist/builders-BWgXkLKd.js.map +1 -0
- package/dist/{builders-BvikWRuO.cjs → builders-CBK8k_cn.cjs} +423 -220
- package/dist/builders-CBK8k_cn.cjs.map +1 -0
- package/dist/conformance.cjs +303 -135
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +37 -3
- package/dist/conformance.d.ts +37 -3
- package/dist/conformance.js +303 -136
- package/dist/conformance.js.map +1 -1
- package/dist/{fold-CB4fAOOy.js → fold-D3_ZiKOg.js} +162 -3
- package/dist/fold-D3_ZiKOg.js.map +1 -0
- package/dist/{fold-IaMph3CO.cjs → fold-M6iEyY8X.cjs} +233 -2
- package/dist/fold-M6iEyY8X.cjs.map +1 -0
- package/dist/index.cjs +22 -12
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/runtime.cjs +23 -13
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +5 -5
- package/dist/{schemas-9OpSSeM6.js → schemas-C32v81cE.js} +29 -4
- package/dist/schemas-C32v81cE.js.map +1 -0
- package/dist/{schemas-B_1VyFsm.cjs → schemas-CLByd6ze.cjs} +29 -4
- package/dist/schemas-CLByd6ze.cjs.map +1 -0
- package/dist/{subtype-qejjVr6h.cjs → subtype-C4XA7C16.cjs} +9 -1
- package/dist/subtype-C4XA7C16.cjs.map +1 -0
- package/dist/{subtype-BvAzLCGC.js → subtype-DsxZbJtP.js} +9 -1
- package/dist/subtype-DsxZbJtP.js.map +1 -0
- package/dist/wire.cjs +14 -1
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +13 -4
- package/dist/wire.d.ts +13 -4
- package/dist/wire.js +14 -2
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/dist/builders-BvikWRuO.cjs.map +0 -1
- package/dist/builders-C548U47M.js.map +0 -1
- package/dist/fold-CB4fAOOy.js.map +0 -1
- package/dist/fold-IaMph3CO.cjs.map +0 -1
- package/dist/schemas-9OpSSeM6.js.map +0 -1
- package/dist/schemas-B_1VyFsm.cjs.map +0 -1
- package/dist/subtype-BvAzLCGC.js.map +0 -1
- package/dist/subtype-qejjVr6h.cjs.map +0 -1
package/dist/conformance.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_AbortError = require("./AbortError-
|
|
5
|
-
const require_schemas = require("./schemas-
|
|
2
|
+
const require_fold = require("./fold-M6iEyY8X.cjs");
|
|
3
|
+
const require_subtype = require("./subtype-C4XA7C16.cjs");
|
|
4
|
+
const require_AbortError = require("./AbortError-BFwCIKC6.cjs");
|
|
5
|
+
const require_schemas = require("./schemas-CLByd6ze.cjs");
|
|
6
6
|
//#region src/conformance/runMetadataConformance.ts
|
|
7
7
|
/**
|
|
8
8
|
* The conformance harness is transport-agnostic. It takes the test runner as
|
|
@@ -19,7 +19,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
19
19
|
if (engine) await engine.destroy();
|
|
20
20
|
});
|
|
21
21
|
test("reads metadata from sample fixture", async () => {
|
|
22
|
-
const doc = await openFixture$
|
|
22
|
+
const doc = await openFixture$15(engine, opts);
|
|
23
23
|
try {
|
|
24
24
|
const meta = await doc.metadata.read();
|
|
25
25
|
expect(meta).toMatchObject(opts.fixture.expected);
|
|
@@ -29,7 +29,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
test("abort() before completion rejects with AbortError", async () => {
|
|
32
|
-
const doc = await openFixture$
|
|
32
|
+
const doc = await openFixture$15(engine, opts);
|
|
33
33
|
try {
|
|
34
34
|
const p = doc.metadata.read();
|
|
35
35
|
p.abort("test");
|
|
@@ -39,7 +39,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
test("aborting one read does not affect a concurrent one", async () => {
|
|
42
|
-
const doc = await openFixture$
|
|
42
|
+
const doc = await openFixture$15(engine, opts);
|
|
43
43
|
try {
|
|
44
44
|
const a = doc.metadata.read();
|
|
45
45
|
const b = doc.metadata.read();
|
|
@@ -51,7 +51,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
test("metadata after close throws DocNotOpen", async () => {
|
|
54
|
-
const doc = await openFixture$
|
|
54
|
+
const doc = await openFixture$15(engine, opts);
|
|
55
55
|
await doc.close();
|
|
56
56
|
let caught;
|
|
57
57
|
try {
|
|
@@ -63,7 +63,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
63
63
|
expect(require_fold.EngineError.is(caught, require_subtype.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
64
64
|
});
|
|
65
65
|
test("update() sets standard + custom fields and a subsequent read observes them", async () => {
|
|
66
|
-
const doc = await openFixture$
|
|
66
|
+
const doc = await openFixture$15(engine, opts);
|
|
67
67
|
try {
|
|
68
68
|
const result = await doc.metadata.update({
|
|
69
69
|
title: "Conformance Title",
|
|
@@ -82,7 +82,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
test("update() clears a field with null", async () => {
|
|
85
|
-
const doc = await openFixture$
|
|
85
|
+
const doc = await openFixture$15(engine, opts);
|
|
86
86
|
try {
|
|
87
87
|
await doc.metadata.update({ title: "To Be Cleared" });
|
|
88
88
|
const set = await doc.metadata.read();
|
|
@@ -95,7 +95,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
test("update() after close throws DocNotOpen", async () => {
|
|
98
|
-
const doc = await openFixture$
|
|
98
|
+
const doc = await openFixture$15(engine, opts);
|
|
99
99
|
await doc.close();
|
|
100
100
|
let caught;
|
|
101
101
|
try {
|
|
@@ -108,7 +108,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
async function openFixture$
|
|
111
|
+
async function openFixture$15(engine, opts) {
|
|
112
112
|
if (opts.openKind === "bytes") {
|
|
113
113
|
const bytes = await opts.fixture.bytes();
|
|
114
114
|
return engine.open({
|
|
@@ -135,7 +135,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
135
135
|
if (engine) await engine.destroy();
|
|
136
136
|
});
|
|
137
137
|
test("listRawAll returns one entry per page with valid PageState", async () => {
|
|
138
|
-
const doc = await openFixture$
|
|
138
|
+
const doc = await openFixture$14(engine, opts);
|
|
139
139
|
try {
|
|
140
140
|
const snap = await doc.annotations.listRawAll();
|
|
141
141
|
expect(require_schemas.AnnotationListSnapshotAllPagesSchema.safeParse(snap).success).toBe(true);
|
|
@@ -148,7 +148,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
test("listRaw on the test page returns the expected counts and DTO shape", async () => {
|
|
151
|
-
const doc = await openFixture$
|
|
151
|
+
const doc = await openFixture$14(engine, opts);
|
|
152
152
|
try {
|
|
153
153
|
const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
154
154
|
expect(require_schemas.AnnotationListPageSnapshotSchema.safeParse(snap).success).toBe(true);
|
|
@@ -178,7 +178,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
180
|
test("shape/vertex/line annotations expose their family fields", async () => {
|
|
181
|
-
const doc = await openFixture$
|
|
181
|
+
const doc = await openFixture$14(engine, opts);
|
|
182
182
|
try {
|
|
183
183
|
const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
184
184
|
for (const a of snap.annotations) {
|
|
@@ -237,7 +237,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
test("full page list dispatches per-subtype and matches raw counts", async () => {
|
|
240
|
-
const doc = await openFixture$
|
|
240
|
+
const doc = await openFixture$14(engine, opts);
|
|
241
241
|
try {
|
|
242
242
|
const full = await doc.page(opts.fixture.pageObjectNumber).annotations.list();
|
|
243
243
|
expect(require_schemas.AnnotationListPageSnapshotSchema.safeParse(full).success).toBe(true);
|
|
@@ -247,7 +247,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
247
247
|
}
|
|
248
248
|
});
|
|
249
249
|
test("every annotation DTO satisfies AnnotationDTOSchema (discriminated union)", async () => {
|
|
250
|
-
const doc = await openFixture$
|
|
250
|
+
const doc = await openFixture$14(engine, opts);
|
|
251
251
|
try {
|
|
252
252
|
const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
253
253
|
for (const a of snap.annotations) {
|
|
@@ -287,7 +287,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
287
287
|
});
|
|
288
288
|
if (opts.fixture.expectsWeakAnnotation) {
|
|
289
289
|
test("weak annotations carry identityQuality: weak and ref.kind: index", async () => {
|
|
290
|
-
const doc = await openFixture$
|
|
290
|
+
const doc = await openFixture$14(engine, opts);
|
|
291
291
|
try {
|
|
292
292
|
const weak = (await doc.annotations.listRaw(opts.fixture.pageObjectNumber)).annotations.find((a) => a.identityQuality === "weak");
|
|
293
293
|
expect(weak !== void 0).toBe(true);
|
|
@@ -297,7 +297,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
297
297
|
}
|
|
298
298
|
});
|
|
299
299
|
test("a stale revision token throws InvalidReference", async () => {
|
|
300
|
-
const doc = await openFixture$
|
|
300
|
+
const doc = await openFixture$14(engine, opts);
|
|
301
301
|
try {
|
|
302
302
|
const snap = await doc.page(opts.fixture.pageObjectNumber).annotations.list();
|
|
303
303
|
const weak = snap.annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -313,7 +313,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
test("abort() on listRaw rejects with AbortError", async () => {
|
|
316
|
-
const doc = await openFixture$
|
|
316
|
+
const doc = await openFixture$14(engine, opts);
|
|
317
317
|
try {
|
|
318
318
|
const p = doc.annotations.listRaw(opts.fixture.pageObjectNumber);
|
|
319
319
|
p.abort("test");
|
|
@@ -323,7 +323,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
323
323
|
}
|
|
324
324
|
});
|
|
325
325
|
test("listRaw on an unknown pageObjectNumber throws NotFound", async () => {
|
|
326
|
-
const doc = await openFixture$
|
|
326
|
+
const doc = await openFixture$14(engine, opts);
|
|
327
327
|
try {
|
|
328
328
|
let caught;
|
|
329
329
|
try {
|
|
@@ -339,7 +339,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
339
339
|
});
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
|
-
async function openFixture$
|
|
342
|
+
async function openFixture$14(engine, opts) {
|
|
343
343
|
if (opts.openKind === "bytes") {
|
|
344
344
|
const bytes = await opts.fixture.bytes();
|
|
345
345
|
return engine.open({
|
|
@@ -597,7 +597,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
597
597
|
if (engine) await engine.destroy();
|
|
598
598
|
});
|
|
599
599
|
test("create appends without shifting indices and leaves weak refs valid", async () => {
|
|
600
|
-
const doc = await openFixture$
|
|
600
|
+
const doc = await openFixture$13(engine, opts);
|
|
601
601
|
try {
|
|
602
602
|
const page = doc.page(fix.pageObjectNumber);
|
|
603
603
|
const before = await page.annotations.list();
|
|
@@ -633,7 +633,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
633
633
|
}
|
|
634
634
|
});
|
|
635
635
|
test("create + update honor annotation flags (set on create, merge on patch)", async () => {
|
|
636
|
-
const doc = await openFixture$
|
|
636
|
+
const doc = await openFixture$13(engine, opts);
|
|
637
637
|
try {
|
|
638
638
|
const page = doc.page(fix.pageObjectNumber);
|
|
639
639
|
const draft = {
|
|
@@ -668,7 +668,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
668
668
|
}
|
|
669
669
|
});
|
|
670
670
|
test("create shape annotations (circle + square) round-trip shape fields", async () => {
|
|
671
|
-
const doc = await openFixture$
|
|
671
|
+
const doc = await openFixture$13(engine, opts);
|
|
672
672
|
try {
|
|
673
673
|
const page = doc.page(fix.pageObjectNumber);
|
|
674
674
|
const circleDraft = {
|
|
@@ -749,7 +749,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
749
749
|
}
|
|
750
750
|
});
|
|
751
751
|
test("cloudy border (/BE) + rect differences (/RD) are tri-state", async () => {
|
|
752
|
-
const doc = await openFixture$
|
|
752
|
+
const doc = await openFixture$13(engine, opts);
|
|
753
753
|
try {
|
|
754
754
|
const page = doc.page(fix.pageObjectNumber);
|
|
755
755
|
const plainDraft = {
|
|
@@ -828,7 +828,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
828
828
|
}
|
|
829
829
|
});
|
|
830
830
|
test("update echoes the appearance verdict: moves preserve /AP, restyles re-bake", async () => {
|
|
831
|
-
const doc = await openFixture$
|
|
831
|
+
const doc = await openFixture$13(engine, opts);
|
|
832
832
|
try {
|
|
833
833
|
const page = doc.page(fix.pageObjectNumber);
|
|
834
834
|
const draft = {
|
|
@@ -903,7 +903,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
903
903
|
}
|
|
904
904
|
});
|
|
905
905
|
test("a partial /DA patch preserves the unpatched font members", async () => {
|
|
906
|
-
const doc = await openFixture$
|
|
906
|
+
const doc = await openFixture$13(engine, opts);
|
|
907
907
|
try {
|
|
908
908
|
const page = doc.page(fix.pageObjectNumber);
|
|
909
909
|
const draft = {
|
|
@@ -959,7 +959,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
959
959
|
}
|
|
960
960
|
});
|
|
961
961
|
test("box transform is tri-state: rect-only moves keep rotation, null flattens", async () => {
|
|
962
|
-
const doc = await openFixture$
|
|
962
|
+
const doc = await openFixture$13(engine, opts);
|
|
963
963
|
try {
|
|
964
964
|
const page = doc.page(fix.pageObjectNumber);
|
|
965
965
|
const draft = {
|
|
@@ -1020,7 +1020,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1020
1020
|
}
|
|
1021
1021
|
});
|
|
1022
1022
|
test("create vertex + line annotations (polygon/polyline/line) round-trip geometry", async () => {
|
|
1023
|
-
const doc = await openFixture$
|
|
1023
|
+
const doc = await openFixture$13(engine, opts);
|
|
1024
1024
|
try {
|
|
1025
1025
|
const page = doc.page(fix.pageObjectNumber);
|
|
1026
1026
|
const polygonDraft = {
|
|
@@ -1151,7 +1151,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
});
|
|
1153
1153
|
test("create free-text + callout round-trip text/colour/intent fields", async () => {
|
|
1154
|
-
const doc = await openFixture$
|
|
1154
|
+
const doc = await openFixture$13(engine, opts);
|
|
1155
1155
|
try {
|
|
1156
1156
|
const page = doc.page(fix.pageObjectNumber);
|
|
1157
1157
|
const freeTextDraft = {
|
|
@@ -1247,7 +1247,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1247
1247
|
}
|
|
1248
1248
|
});
|
|
1249
1249
|
test("update a free-text patches alignment + colours and is non-structural", async () => {
|
|
1250
|
-
const doc = await openFixture$
|
|
1250
|
+
const doc = await openFixture$13(engine, opts);
|
|
1251
1251
|
try {
|
|
1252
1252
|
const page = doc.page(fix.pageObjectNumber);
|
|
1253
1253
|
const created = await page.annotations.create({
|
|
@@ -1308,7 +1308,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
});
|
|
1310
1310
|
test("create redact (area + text) round-trips label + colour fields", async () => {
|
|
1311
|
-
const doc = await openFixture$
|
|
1311
|
+
const doc = await openFixture$13(engine, opts);
|
|
1312
1312
|
try {
|
|
1313
1313
|
const page = doc.page(fix.pageObjectNumber);
|
|
1314
1314
|
const areaDraft = {
|
|
@@ -1388,7 +1388,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
});
|
|
1390
1390
|
test("update a redact patches the label and clears it, non-structurally", async () => {
|
|
1391
|
-
const doc = await openFixture$
|
|
1391
|
+
const doc = await openFixture$13(engine, opts);
|
|
1392
1392
|
try {
|
|
1393
1393
|
const page = doc.page(fix.pageObjectNumber);
|
|
1394
1394
|
const created = await page.annotations.create({
|
|
@@ -1465,7 +1465,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1465
1465
|
}
|
|
1466
1466
|
});
|
|
1467
1467
|
test("create + update a caret round-trips color/opacity/rect differences", async () => {
|
|
1468
|
-
const doc = await openFixture$
|
|
1468
|
+
const doc = await openFixture$13(engine, opts);
|
|
1469
1469
|
try {
|
|
1470
1470
|
const page = doc.page(fix.pageObjectNumber);
|
|
1471
1471
|
const caretDraft = {
|
|
@@ -1545,7 +1545,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1545
1545
|
}
|
|
1546
1546
|
});
|
|
1547
1547
|
test("update an ink annotation patches strokes + color and is non-structural", async () => {
|
|
1548
|
-
const doc = await openFixture$
|
|
1548
|
+
const doc = await openFixture$13(engine, opts);
|
|
1549
1549
|
try {
|
|
1550
1550
|
const page = doc.page(fix.pageObjectNumber);
|
|
1551
1551
|
const created = await page.annotations.create({
|
|
@@ -1596,7 +1596,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1596
1596
|
}
|
|
1597
1597
|
});
|
|
1598
1598
|
test("ink highlight intent + blend round-trip and unrelated patches preserve blend", async () => {
|
|
1599
|
-
const doc = await openFixture$
|
|
1599
|
+
const doc = await openFixture$13(engine, opts);
|
|
1600
1600
|
try {
|
|
1601
1601
|
const page = doc.page(fix.pageObjectNumber);
|
|
1602
1602
|
const created = await page.annotations.create({
|
|
@@ -1639,7 +1639,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1639
1639
|
}
|
|
1640
1640
|
});
|
|
1641
1641
|
test("update a polyline patches vertices + line endings and is non-structural", async () => {
|
|
1642
|
-
const doc = await openFixture$
|
|
1642
|
+
const doc = await openFixture$13(engine, opts);
|
|
1643
1643
|
try {
|
|
1644
1644
|
const page = doc.page(fix.pageObjectNumber);
|
|
1645
1645
|
const created = await page.annotations.create({
|
|
@@ -1688,7 +1688,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1688
1688
|
}
|
|
1689
1689
|
});
|
|
1690
1690
|
test("update a shape annotation patches color and is non-structural", async () => {
|
|
1691
|
-
const doc = await openFixture$
|
|
1691
|
+
const doc = await openFixture$13(engine, opts);
|
|
1692
1692
|
try {
|
|
1693
1693
|
const page = doc.page(fix.pageObjectNumber);
|
|
1694
1694
|
const created = await page.annotations.create({
|
|
@@ -1737,7 +1737,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1737
1737
|
}
|
|
1738
1738
|
});
|
|
1739
1739
|
if (opts.supportsAppearanceRasters) test("creating a shape bakes an /AP appearance the reader can rasterize", async () => {
|
|
1740
|
-
const doc = await openFixture$
|
|
1740
|
+
const doc = await openFixture$13(engine, opts);
|
|
1741
1741
|
try {
|
|
1742
1742
|
const page = doc.page(fix.pageObjectNumber);
|
|
1743
1743
|
const created = await page.annotations.create({
|
|
@@ -1767,7 +1767,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
});
|
|
1769
1769
|
test("update on a durable annotation is non-structural and never touches /NM", async () => {
|
|
1770
|
-
const doc = await openFixture$
|
|
1770
|
+
const doc = await openFixture$13(engine, opts);
|
|
1771
1771
|
try {
|
|
1772
1772
|
const page = doc.page(fix.pageObjectNumber);
|
|
1773
1773
|
const before = await page.annotations.list();
|
|
@@ -1793,7 +1793,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
});
|
|
1795
1795
|
if (fix.expectsWeakAnnotation) test("update on a weak annotation stamps a UUID v4 /NM and upgrades the ref", async () => {
|
|
1796
|
-
const doc = await openFixture$
|
|
1796
|
+
const doc = await openFixture$13(engine, opts);
|
|
1797
1797
|
try {
|
|
1798
1798
|
const page = doc.page(fix.pageObjectNumber);
|
|
1799
1799
|
const before = await page.annotations.list();
|
|
@@ -1823,7 +1823,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1823
1823
|
}
|
|
1824
1824
|
});
|
|
1825
1825
|
test("delete by objectNumber removes the annotation and reports a stable id", async () => {
|
|
1826
|
-
const doc = await openFixture$
|
|
1826
|
+
const doc = await openFixture$13(engine, opts);
|
|
1827
1827
|
try {
|
|
1828
1828
|
const page = doc.page(fix.pageObjectNumber);
|
|
1829
1829
|
const draft = {
|
|
@@ -1853,7 +1853,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1853
1853
|
}
|
|
1854
1854
|
});
|
|
1855
1855
|
if (fix.expectsWeakAnnotation) test("delete by index of a weak annotation reports deleted: null and refetch reason", async () => {
|
|
1856
|
-
const doc = await openFixture$
|
|
1856
|
+
const doc = await openFixture$13(engine, opts);
|
|
1857
1857
|
try {
|
|
1858
1858
|
const page = doc.page(fix.pageObjectNumber);
|
|
1859
1859
|
const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -1876,7 +1876,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1876
1876
|
}
|
|
1877
1877
|
});
|
|
1878
1878
|
test("abort on create rejects with AbortError", async () => {
|
|
1879
|
-
const doc = await openFixture$
|
|
1879
|
+
const doc = await openFixture$13(engine, opts);
|
|
1880
1880
|
try {
|
|
1881
1881
|
const page = doc.page(fix.pageObjectNumber);
|
|
1882
1882
|
const draft = {
|
|
@@ -1892,7 +1892,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1892
1892
|
}
|
|
1893
1893
|
});
|
|
1894
1894
|
test("update with a stale index revision throws InvalidReference", async () => {
|
|
1895
|
-
const doc = await openFixture$
|
|
1895
|
+
const doc = await openFixture$13(engine, opts);
|
|
1896
1896
|
try {
|
|
1897
1897
|
const page = doc.page(fix.pageObjectNumber);
|
|
1898
1898
|
const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -1919,7 +1919,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1919
1919
|
}
|
|
1920
1920
|
});
|
|
1921
1921
|
test("move single durable annotation reorders within the page (single-as-batch)", async () => {
|
|
1922
|
-
const doc = await openFixture$
|
|
1922
|
+
const doc = await openFixture$13(engine, opts);
|
|
1923
1923
|
try {
|
|
1924
1924
|
const page = doc.page(fix.pageObjectNumber);
|
|
1925
1925
|
const aDraft = {
|
|
@@ -1963,7 +1963,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1963
1963
|
}
|
|
1964
1964
|
});
|
|
1965
1965
|
test("move multi-block preserves caller-supplied order at the destination", async () => {
|
|
1966
|
-
const doc = await openFixture$
|
|
1966
|
+
const doc = await openFixture$13(engine, opts);
|
|
1967
1967
|
try {
|
|
1968
1968
|
const page = doc.page(fix.pageObjectNumber);
|
|
1969
1969
|
const ids = await Promise.all([
|
|
@@ -2002,7 +2002,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2002
2002
|
}
|
|
2003
2003
|
});
|
|
2004
2004
|
if (fix.expectsWeakAnnotation) test("move on a weak annotation upgrades it to durable /NM (one rev bump for batch)", async () => {
|
|
2005
|
-
const doc = await openFixture$
|
|
2005
|
+
const doc = await openFixture$13(engine, opts);
|
|
2006
2006
|
try {
|
|
2007
2007
|
const page = doc.page(fix.pageObjectNumber);
|
|
2008
2008
|
const before = await page.annotations.list();
|
|
@@ -2027,7 +2027,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2027
2027
|
}
|
|
2028
2028
|
});
|
|
2029
2029
|
test("move with a stale index revision rejects (locked rev-token guard)", async () => {
|
|
2030
|
-
const doc = await openFixture$
|
|
2030
|
+
const doc = await openFixture$13(engine, opts);
|
|
2031
2031
|
try {
|
|
2032
2032
|
const page = doc.page(fix.pageObjectNumber);
|
|
2033
2033
|
const a = await page.annotations.create({
|
|
@@ -2065,7 +2065,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2065
2065
|
}
|
|
2066
2066
|
});
|
|
2067
2067
|
test("move with out-of-range toIndex rejects with InvalidArg", async () => {
|
|
2068
|
-
const doc = await openFixture$
|
|
2068
|
+
const doc = await openFixture$13(engine, opts);
|
|
2069
2069
|
try {
|
|
2070
2070
|
const page = doc.page(fix.pageObjectNumber);
|
|
2071
2071
|
const a = await page.annotations.create({
|
|
@@ -2089,7 +2089,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2089
2089
|
}
|
|
2090
2090
|
});
|
|
2091
2091
|
test("move with duplicate refs rejects with InvalidArg", async () => {
|
|
2092
|
-
const doc = await openFixture$
|
|
2092
|
+
const doc = await openFixture$13(engine, opts);
|
|
2093
2093
|
try {
|
|
2094
2094
|
const page = doc.page(fix.pageObjectNumber);
|
|
2095
2095
|
const a = await page.annotations.create({
|
|
@@ -2112,7 +2112,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2112
2112
|
}
|
|
2113
2113
|
});
|
|
2114
2114
|
test("abort on move rejects with AbortError", async () => {
|
|
2115
|
-
const doc = await openFixture$
|
|
2115
|
+
const doc = await openFixture$13(engine, opts);
|
|
2116
2116
|
try {
|
|
2117
2117
|
const page = doc.page(fix.pageObjectNumber);
|
|
2118
2118
|
const a = await page.annotations.create({
|
|
@@ -2133,7 +2133,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2133
2133
|
}
|
|
2134
2134
|
});
|
|
2135
2135
|
test("a page move does NOT bump per-page RevisionTokens (weak refs survive reorder)", async () => {
|
|
2136
|
-
const doc = await openFixture$
|
|
2136
|
+
const doc = await openFixture$13(engine, opts);
|
|
2137
2137
|
try {
|
|
2138
2138
|
const list = await doc.pages.list();
|
|
2139
2139
|
if (list.pages.length < 1) return;
|
|
@@ -2148,7 +2148,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2148
2148
|
}
|
|
2149
2149
|
});
|
|
2150
2150
|
test("create a reply links /IRT and defaults /RT to \"reply\", reporting the parent", async () => {
|
|
2151
|
-
const doc = await openFixture$
|
|
2151
|
+
const doc = await openFixture$13(engine, opts);
|
|
2152
2152
|
try {
|
|
2153
2153
|
const page = doc.page(fix.pageObjectNumber);
|
|
2154
2154
|
const parent = await page.annotations.create({
|
|
@@ -2182,7 +2182,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2182
2182
|
}
|
|
2183
2183
|
});
|
|
2184
2184
|
test("create a grouped subordinate writes /RT /Group", async () => {
|
|
2185
|
-
const doc = await openFixture$
|
|
2185
|
+
const doc = await openFixture$13(engine, opts);
|
|
2186
2186
|
try {
|
|
2187
2187
|
const page = doc.page(fix.pageObjectNumber);
|
|
2188
2188
|
const primary = await page.annotations.create({
|
|
@@ -2213,7 +2213,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2213
2213
|
}
|
|
2214
2214
|
});
|
|
2215
2215
|
test("create link annotations round-trip uri, goto/xyz, goto/fitH, and dead targets", async () => {
|
|
2216
|
-
const doc = await openFixture$
|
|
2216
|
+
const doc = await openFixture$13(engine, opts);
|
|
2217
2217
|
try {
|
|
2218
2218
|
const page = doc.page(fix.pageObjectNumber);
|
|
2219
2219
|
const uri = await page.annotations.create({
|
|
@@ -2290,7 +2290,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2290
2290
|
}
|
|
2291
2291
|
});
|
|
2292
2292
|
test("a link patch retargets in both directions (uri→goto, goto→uri) and moves the rect", async () => {
|
|
2293
|
-
const doc = await openFixture$
|
|
2293
|
+
const doc = await openFixture$13(engine, opts);
|
|
2294
2294
|
try {
|
|
2295
2295
|
const page = doc.page(fix.pageObjectNumber);
|
|
2296
2296
|
const created = await page.annotations.create({
|
|
@@ -2345,7 +2345,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2345
2345
|
}
|
|
2346
2346
|
});
|
|
2347
2347
|
test("a link patch clears the target with null — a dead link on re-read", async () => {
|
|
2348
|
-
const doc = await openFixture$
|
|
2348
|
+
const doc = await openFixture$13(engine, opts);
|
|
2349
2349
|
try {
|
|
2350
2350
|
const page = doc.page(fix.pageObjectNumber);
|
|
2351
2351
|
const created = await page.annotations.create({
|
|
@@ -2384,7 +2384,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2384
2384
|
}
|
|
2385
2385
|
});
|
|
2386
2386
|
test("a link grouped to a highlight round-trips /IRT + /RT /Group with its target", async () => {
|
|
2387
|
-
const doc = await openFixture$
|
|
2387
|
+
const doc = await openFixture$13(engine, opts);
|
|
2388
2388
|
try {
|
|
2389
2389
|
const page = doc.page(fix.pageObjectNumber);
|
|
2390
2390
|
const parent = await page.annotations.create({
|
|
@@ -2418,7 +2418,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2418
2418
|
}
|
|
2419
2419
|
});
|
|
2420
2420
|
test("replace-text round-trips /IT and groups StrikeOut under its Caret", async () => {
|
|
2421
|
-
const doc = await openFixture$
|
|
2421
|
+
const doc = await openFixture$13(engine, opts);
|
|
2422
2422
|
try {
|
|
2423
2423
|
const page = doc.page(fix.pageObjectNumber);
|
|
2424
2424
|
const caret = await page.annotations.create({
|
|
@@ -2470,7 +2470,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2470
2470
|
}
|
|
2471
2471
|
});
|
|
2472
2472
|
test("patch inReplyTo: null clears /IRT and /RT (back to top-level)", async () => {
|
|
2473
|
-
const doc = await openFixture$
|
|
2473
|
+
const doc = await openFixture$13(engine, opts);
|
|
2474
2474
|
try {
|
|
2475
2475
|
const page = doc.page(fix.pageObjectNumber);
|
|
2476
2476
|
const parent = await page.annotations.create({
|
|
@@ -2497,7 +2497,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2497
2497
|
}
|
|
2498
2498
|
});
|
|
2499
2499
|
test("create with a cross-page /IRT parent throws InvalidArg", async () => {
|
|
2500
|
-
const doc = await openFixture$
|
|
2500
|
+
const doc = await openFixture$13(engine, opts);
|
|
2501
2501
|
try {
|
|
2502
2502
|
const page = doc.page(fix.pageObjectNumber);
|
|
2503
2503
|
const parent = await page.annotations.create({
|
|
@@ -2533,7 +2533,7 @@ async function beginWeakEditIfRequired(doc, pageObjectNumber, fix) {
|
|
|
2533
2533
|
if (doc.capabilities.weakAnnotationEditSessions !== "required" || !fix.expectsWeakAnnotation) return null;
|
|
2534
2534
|
return doc.annotations.beginWeakEdit([pageObjectNumber]);
|
|
2535
2535
|
}
|
|
2536
|
-
async function openFixture$
|
|
2536
|
+
async function openFixture$13(engine, opts) {
|
|
2537
2537
|
if (opts.openKind === "bytes") {
|
|
2538
2538
|
const bytes = await opts.fixture.bytes();
|
|
2539
2539
|
return engine.open({
|
|
@@ -3123,7 +3123,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3123
3123
|
if (engine) await engine.destroy();
|
|
3124
3124
|
});
|
|
3125
3125
|
test("renders the expected set of appearances with valid output", async () => {
|
|
3126
|
-
const doc = await openFixture$
|
|
3126
|
+
const doc = await openFixture$12(engine, opts);
|
|
3127
3127
|
try {
|
|
3128
3128
|
const { pageState, appearances } = await collect(doc, opts, useRaw);
|
|
3129
3129
|
expect(pageState.pageObjectNumber).toBe(opts.fixture.pageObjectNumber);
|
|
@@ -3150,7 +3150,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3150
3150
|
}
|
|
3151
3151
|
});
|
|
3152
3152
|
if (opts.fixture.expectsWeakAppearance) test("weak (index-only) annotations are emitted, not dropped", async () => {
|
|
3153
|
-
const doc = await openFixture$
|
|
3153
|
+
const doc = await openFixture$12(engine, opts);
|
|
3154
3154
|
try {
|
|
3155
3155
|
const { appearances } = await collect(doc, opts, useRaw);
|
|
3156
3156
|
const weak = appearances.find((a) => a.ref.kind === "index");
|
|
@@ -3160,7 +3160,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3160
3160
|
}
|
|
3161
3161
|
});
|
|
3162
3162
|
if (useRaw) test("rendered appearances are not blank (non-zero alpha)", async () => {
|
|
3163
|
-
const doc = await openFixture$
|
|
3163
|
+
const doc = await openFixture$12(engine, opts);
|
|
3164
3164
|
try {
|
|
3165
3165
|
const { appearances } = await collect(doc, opts, useRaw);
|
|
3166
3166
|
const anyVisible = appearances.some((a) => a.raster !== null && hasOpaquePixel(a.raster));
|
|
@@ -3170,7 +3170,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3170
3170
|
}
|
|
3171
3171
|
});
|
|
3172
3172
|
test("abort() rejects with AbortError", async () => {
|
|
3173
|
-
const doc = await openFixture$
|
|
3173
|
+
const doc = await openFixture$12(engine, opts);
|
|
3174
3174
|
try {
|
|
3175
3175
|
const page = doc.page(opts.fixture.pageObjectNumber);
|
|
3176
3176
|
const p = useRaw ? page.annotations.renderAppearances({ scale: 1 }) : page.annotations.renderAppearanceImages({
|
|
@@ -3225,7 +3225,7 @@ function hasOpaquePixel(raster) {
|
|
|
3225
3225
|
}
|
|
3226
3226
|
return false;
|
|
3227
3227
|
}
|
|
3228
|
-
async function openFixture$
|
|
3228
|
+
async function openFixture$12(engine, opts) {
|
|
3229
3229
|
if (opts.openKind === "bytes") {
|
|
3230
3230
|
const bytes = await opts.fixture.bytes();
|
|
3231
3231
|
return engine.open({
|
|
@@ -3294,7 +3294,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3294
3294
|
if (engine) await engine.destroy();
|
|
3295
3295
|
});
|
|
3296
3296
|
test("pages.list() returns every page in display order, durable PONs only", async () => {
|
|
3297
|
-
const doc = await openFixture$
|
|
3297
|
+
const doc = await openFixture$11(engine, opts);
|
|
3298
3298
|
try {
|
|
3299
3299
|
const list = await doc.pages.list();
|
|
3300
3300
|
expect(require_schemas.PageListSnapshotSchema.safeParse(list).success).toBe(true);
|
|
@@ -3313,7 +3313,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3313
3313
|
}
|
|
3314
3314
|
});
|
|
3315
3315
|
test("pages.move() reorders pages and returns the full post-move order", async () => {
|
|
3316
|
-
const doc = await openFixture$
|
|
3316
|
+
const doc = await openFixture$11(engine, opts);
|
|
3317
3317
|
try {
|
|
3318
3318
|
const before = await doc.pages.list();
|
|
3319
3319
|
if (before.pages.length < 3) return;
|
|
@@ -3337,7 +3337,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3337
3337
|
}
|
|
3338
3338
|
});
|
|
3339
3339
|
test("weak index-based annotation refs survive a page reorder", async () => {
|
|
3340
|
-
const doc = await openFixture$
|
|
3340
|
+
const doc = await openFixture$11(engine, opts);
|
|
3341
3341
|
try {
|
|
3342
3342
|
const list = await doc.pages.list();
|
|
3343
3343
|
if (list.pages.length < 2) return;
|
|
@@ -3374,7 +3374,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3374
3374
|
}
|
|
3375
3375
|
});
|
|
3376
3376
|
test("pages.move() rejects duplicate PONs with InvalidArg", async () => {
|
|
3377
|
-
const doc = await openFixture$
|
|
3377
|
+
const doc = await openFixture$11(engine, opts);
|
|
3378
3378
|
try {
|
|
3379
3379
|
const list = await doc.pages.list();
|
|
3380
3380
|
if (list.pages.length < 1) return;
|
|
@@ -3391,7 +3391,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3391
3391
|
}
|
|
3392
3392
|
});
|
|
3393
3393
|
test("pages.move() rejects out-of-range destIndex with InvalidArg", async () => {
|
|
3394
|
-
const doc = await openFixture$
|
|
3394
|
+
const doc = await openFixture$11(engine, opts);
|
|
3395
3395
|
try {
|
|
3396
3396
|
const list = await doc.pages.list();
|
|
3397
3397
|
if (list.pages.length < 1) return;
|
|
@@ -3408,7 +3408,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3408
3408
|
}
|
|
3409
3409
|
});
|
|
3410
3410
|
test("pages.move() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3411
|
-
const doc = await openFixture$
|
|
3411
|
+
const doc = await openFixture$11(engine, opts);
|
|
3412
3412
|
try {
|
|
3413
3413
|
const list = await doc.pages.list();
|
|
3414
3414
|
let bogus = 0;
|
|
@@ -3426,7 +3426,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3426
3426
|
}
|
|
3427
3427
|
});
|
|
3428
3428
|
test("abort on pages.move() rejects with AbortError", async () => {
|
|
3429
|
-
const doc = await openFixture$
|
|
3429
|
+
const doc = await openFixture$11(engine, opts);
|
|
3430
3430
|
try {
|
|
3431
3431
|
const list = await doc.pages.list();
|
|
3432
3432
|
if (list.pages.length < 1) return;
|
|
@@ -3440,7 +3440,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3440
3440
|
});
|
|
3441
3441
|
});
|
|
3442
3442
|
}
|
|
3443
|
-
async function openFixture$
|
|
3443
|
+
async function openFixture$11(engine, opts) {
|
|
3444
3444
|
if (opts.openKind === "bytes") {
|
|
3445
3445
|
const bytes = await opts.fixture.bytes();
|
|
3446
3446
|
return engine.open({
|
|
@@ -3514,7 +3514,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3514
3514
|
if (engine) await engine.destroy();
|
|
3515
3515
|
});
|
|
3516
3516
|
test("pages.rotate() sets the absolute rotation and returns the full layout", async () => {
|
|
3517
|
-
const doc = await openFixture$
|
|
3517
|
+
const doc = await openFixture$10(engine, opts);
|
|
3518
3518
|
try {
|
|
3519
3519
|
const before = await doc.pages.list();
|
|
3520
3520
|
const target = before.pages[0];
|
|
@@ -3533,7 +3533,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3533
3533
|
}
|
|
3534
3534
|
});
|
|
3535
3535
|
test("absolute rotation is idempotent: setting the same value twice is a no-op", async () => {
|
|
3536
|
-
const doc = await openFixture$
|
|
3536
|
+
const doc = await openFixture$10(engine, opts);
|
|
3537
3537
|
try {
|
|
3538
3538
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3539
3539
|
const first = await doc.pages.rotate([pon], 180);
|
|
@@ -3544,7 +3544,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3544
3544
|
}
|
|
3545
3545
|
});
|
|
3546
3546
|
test("one rotation applies to EVERY listed page (the multi-select gesture)", async () => {
|
|
3547
|
-
const doc = await openFixture$
|
|
3547
|
+
const doc = await openFixture$10(engine, opts);
|
|
3548
3548
|
try {
|
|
3549
3549
|
const list = await doc.pages.list();
|
|
3550
3550
|
if (list.pages.length < 2) return;
|
|
@@ -3556,7 +3556,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3556
3556
|
}
|
|
3557
3557
|
});
|
|
3558
3558
|
test("weak index-based annotation refs survive a rotate (no revision bump)", async () => {
|
|
3559
|
-
const doc = await openFixture$
|
|
3559
|
+
const doc = await openFixture$10(engine, opts);
|
|
3560
3560
|
try {
|
|
3561
3561
|
const hostPon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3562
3562
|
const hostPage = doc.page(hostPon);
|
|
@@ -3586,7 +3586,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3586
3586
|
}
|
|
3587
3587
|
});
|
|
3588
3588
|
test("pages.rotate() rejects an invalid rotation value with InvalidArg", async () => {
|
|
3589
|
-
const doc = await openFixture$
|
|
3589
|
+
const doc = await openFixture$10(engine, opts);
|
|
3590
3590
|
try {
|
|
3591
3591
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3592
3592
|
let caught;
|
|
@@ -3601,7 +3601,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3601
3601
|
}
|
|
3602
3602
|
});
|
|
3603
3603
|
test("pages.rotate() rejects duplicate PONs with InvalidArg", async () => {
|
|
3604
|
-
const doc = await openFixture$
|
|
3604
|
+
const doc = await openFixture$10(engine, opts);
|
|
3605
3605
|
try {
|
|
3606
3606
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3607
3607
|
let caught;
|
|
@@ -3616,7 +3616,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3616
3616
|
}
|
|
3617
3617
|
});
|
|
3618
3618
|
test("pages.rotate() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3619
|
-
const doc = await openFixture$
|
|
3619
|
+
const doc = await openFixture$10(engine, opts);
|
|
3620
3620
|
try {
|
|
3621
3621
|
const list = await doc.pages.list();
|
|
3622
3622
|
let bogus = 0;
|
|
@@ -3634,7 +3634,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3634
3634
|
}
|
|
3635
3635
|
});
|
|
3636
3636
|
test("abort on pages.rotate() rejects with AbortError", async () => {
|
|
3637
|
-
const doc = await openFixture$
|
|
3637
|
+
const doc = await openFixture$10(engine, opts);
|
|
3638
3638
|
try {
|
|
3639
3639
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3640
3640
|
const p = doc.pages.rotate([pon], 90);
|
|
@@ -3646,7 +3646,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3646
3646
|
});
|
|
3647
3647
|
});
|
|
3648
3648
|
}
|
|
3649
|
-
async function openFixture$
|
|
3649
|
+
async function openFixture$10(engine, opts) {
|
|
3650
3650
|
if (opts.openKind === "bytes") {
|
|
3651
3651
|
const bytes = await opts.fixture.bytes();
|
|
3652
3652
|
return engine.open({
|
|
@@ -3709,7 +3709,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3709
3709
|
if (engine) await engine.destroy();
|
|
3710
3710
|
});
|
|
3711
3711
|
test("pages.delete() removes the page and returns the surviving layout", async () => {
|
|
3712
|
-
const doc = await openFixture$
|
|
3712
|
+
const doc = await openFixture$9(engine, opts);
|
|
3713
3713
|
try {
|
|
3714
3714
|
const before = await doc.pages.list();
|
|
3715
3715
|
if (before.pages.length < 2) return;
|
|
@@ -3730,7 +3730,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3730
3730
|
}
|
|
3731
3731
|
});
|
|
3732
3732
|
test("addressing a deleted page afterwards is a clean NotFound", async () => {
|
|
3733
|
-
const doc = await openFixture$
|
|
3733
|
+
const doc = await openFixture$9(engine, opts);
|
|
3734
3734
|
try {
|
|
3735
3735
|
const before = await doc.pages.list();
|
|
3736
3736
|
if (before.pages.length < 2) return;
|
|
@@ -3748,7 +3748,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3748
3748
|
}
|
|
3749
3749
|
});
|
|
3750
3750
|
test("surviving pages keep their weak index-based annotation refs", async () => {
|
|
3751
|
-
const doc = await openFixture$
|
|
3751
|
+
const doc = await openFixture$9(engine, opts);
|
|
3752
3752
|
try {
|
|
3753
3753
|
const list = await doc.pages.list();
|
|
3754
3754
|
if (list.pages.length < 2) return;
|
|
@@ -3781,7 +3781,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3781
3781
|
}
|
|
3782
3782
|
});
|
|
3783
3783
|
test("deleting EVERY page is rejected with InvalidArg", async () => {
|
|
3784
|
-
const doc = await openFixture$
|
|
3784
|
+
const doc = await openFixture$9(engine, opts);
|
|
3785
3785
|
try {
|
|
3786
3786
|
const list = await doc.pages.list();
|
|
3787
3787
|
let caught;
|
|
@@ -3796,7 +3796,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3796
3796
|
}
|
|
3797
3797
|
});
|
|
3798
3798
|
test("pages.delete() rejects duplicate PONs with InvalidArg", async () => {
|
|
3799
|
-
const doc = await openFixture$
|
|
3799
|
+
const doc = await openFixture$9(engine, opts);
|
|
3800
3800
|
try {
|
|
3801
3801
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3802
3802
|
let caught;
|
|
@@ -3811,7 +3811,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3811
3811
|
}
|
|
3812
3812
|
});
|
|
3813
3813
|
test("pages.delete() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3814
|
-
const doc = await openFixture$
|
|
3814
|
+
const doc = await openFixture$9(engine, opts);
|
|
3815
3815
|
try {
|
|
3816
3816
|
const list = await doc.pages.list();
|
|
3817
3817
|
let bogus = 0;
|
|
@@ -3829,7 +3829,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3829
3829
|
}
|
|
3830
3830
|
});
|
|
3831
3831
|
test("abort on pages.delete() rejects with AbortError", async () => {
|
|
3832
|
-
const doc = await openFixture$
|
|
3832
|
+
const doc = await openFixture$9(engine, opts);
|
|
3833
3833
|
try {
|
|
3834
3834
|
const list = await doc.pages.list();
|
|
3835
3835
|
if (list.pages.length < 2) return;
|
|
@@ -3843,7 +3843,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3843
3843
|
});
|
|
3844
3844
|
});
|
|
3845
3845
|
}
|
|
3846
|
-
async function openFixture$
|
|
3846
|
+
async function openFixture$9(engine, opts) {
|
|
3847
3847
|
if (opts.openKind === "bytes") {
|
|
3848
3848
|
const bytes = await opts.fixture.bytes();
|
|
3849
3849
|
return engine.open({
|
|
@@ -3871,7 +3871,7 @@ function runPageFlattenConformance(runner, opts) {
|
|
|
3871
3871
|
if (engine) await engine.destroy();
|
|
3872
3872
|
});
|
|
3873
3873
|
test("flattens eligible appearances once without changing layout", async () => {
|
|
3874
|
-
const doc = await openFixture$
|
|
3874
|
+
const doc = await openFixture$8(engine, opts);
|
|
3875
3875
|
try {
|
|
3876
3876
|
if (!doc.pages.flatten) return;
|
|
3877
3877
|
const layoutBefore = await doc.pages.list();
|
|
@@ -3905,7 +3905,7 @@ function runPageFlattenConformance(runner, opts) {
|
|
|
3905
3905
|
});
|
|
3906
3906
|
});
|
|
3907
3907
|
}
|
|
3908
|
-
async function openFixture$
|
|
3908
|
+
async function openFixture$8(engine, opts) {
|
|
3909
3909
|
if (opts.openKind === "bytes") return engine.open({
|
|
3910
3910
|
kind: "bytes",
|
|
3911
3911
|
id: opts.fixture.id,
|
|
@@ -3960,7 +3960,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
3960
3960
|
if (engine) await engine.destroy();
|
|
3961
3961
|
});
|
|
3962
3962
|
test("annotations scope applies the marked redaction and counts collateral", async () => {
|
|
3963
|
-
const doc = await openFixture$
|
|
3963
|
+
const doc = await openFixture$7(engine, opts);
|
|
3964
3964
|
try {
|
|
3965
3965
|
if (!doc.redaction) return;
|
|
3966
3966
|
const layoutBefore = await doc.pages.list();
|
|
@@ -4014,7 +4014,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
4014
4014
|
}
|
|
4015
4015
|
});
|
|
4016
4016
|
test("pages scope applies everything once and validates its input", async () => {
|
|
4017
|
-
const doc = await openFixture$
|
|
4017
|
+
const doc = await openFixture$7(engine, opts);
|
|
4018
4018
|
try {
|
|
4019
4019
|
if (!doc.redaction) return;
|
|
4020
4020
|
const pageObjectNumber = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
@@ -4065,7 +4065,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
4065
4065
|
});
|
|
4066
4066
|
});
|
|
4067
4067
|
}
|
|
4068
|
-
async function openFixture$
|
|
4068
|
+
async function openFixture$7(engine, opts) {
|
|
4069
4069
|
if (opts.openKind === "bytes") return engine.open({
|
|
4070
4070
|
kind: "bytes",
|
|
4071
4071
|
id: opts.fixture.id,
|
|
@@ -4108,7 +4108,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4108
4108
|
let supported = false;
|
|
4109
4109
|
beforeAll(async () => {
|
|
4110
4110
|
engine = await opts.makeEngine();
|
|
4111
|
-
const probe = await openFixture$
|
|
4111
|
+
const probe = await openFixture$6(engine, opts);
|
|
4112
4112
|
supported = probe.pages.extract !== void 0;
|
|
4113
4113
|
await probe.close();
|
|
4114
4114
|
});
|
|
@@ -4117,7 +4117,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4117
4117
|
});
|
|
4118
4118
|
test("pages.extract() returns standalone PDF bytes and leaves the source untouched", async () => {
|
|
4119
4119
|
if (!supported) return;
|
|
4120
|
-
const doc = await openFixture$
|
|
4120
|
+
const doc = await openFixture$6(engine, opts);
|
|
4121
4121
|
try {
|
|
4122
4122
|
const before = await doc.pages.list();
|
|
4123
4123
|
const target = before.pages[before.pages.length - 1];
|
|
@@ -4133,7 +4133,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4133
4133
|
});
|
|
4134
4134
|
test("extracted bytes re-open as a document with the requested pages, in caller order", async () => {
|
|
4135
4135
|
if (!supported || opts.openKind !== "bytes") return;
|
|
4136
|
-
const doc = await openFixture$
|
|
4136
|
+
const doc = await openFixture$6(engine, opts);
|
|
4137
4137
|
let extracted = null;
|
|
4138
4138
|
try {
|
|
4139
4139
|
const list = await doc.pages.list();
|
|
@@ -4157,7 +4157,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4157
4157
|
});
|
|
4158
4158
|
test("pages.extract() rejects empty input with InvalidArg", async () => {
|
|
4159
4159
|
if (!supported) return;
|
|
4160
|
-
const doc = await openFixture$
|
|
4160
|
+
const doc = await openFixture$6(engine, opts);
|
|
4161
4161
|
try {
|
|
4162
4162
|
let caught;
|
|
4163
4163
|
try {
|
|
@@ -4172,7 +4172,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4172
4172
|
});
|
|
4173
4173
|
test("pages.extract() rejects duplicate PONs with InvalidArg", async () => {
|
|
4174
4174
|
if (!supported) return;
|
|
4175
|
-
const doc = await openFixture$
|
|
4175
|
+
const doc = await openFixture$6(engine, opts);
|
|
4176
4176
|
try {
|
|
4177
4177
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
4178
4178
|
let caught;
|
|
@@ -4188,7 +4188,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4188
4188
|
});
|
|
4189
4189
|
test("pages.extract() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
4190
4190
|
if (!supported) return;
|
|
4191
|
-
const doc = await openFixture$
|
|
4191
|
+
const doc = await openFixture$6(engine, opts);
|
|
4192
4192
|
try {
|
|
4193
4193
|
const list = await doc.pages.list();
|
|
4194
4194
|
let bogus = 0;
|
|
@@ -4207,7 +4207,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4207
4207
|
});
|
|
4208
4208
|
test("abort on pages.extract() rejects with AbortError", async () => {
|
|
4209
4209
|
if (!supported) return;
|
|
4210
|
-
const doc = await openFixture$
|
|
4210
|
+
const doc = await openFixture$6(engine, opts);
|
|
4211
4211
|
try {
|
|
4212
4212
|
const list = await doc.pages.list();
|
|
4213
4213
|
const p = doc.pages.extract([list.pages[0].pageObjectNumber]);
|
|
@@ -4219,7 +4219,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4219
4219
|
});
|
|
4220
4220
|
});
|
|
4221
4221
|
}
|
|
4222
|
-
async function openFixture$
|
|
4222
|
+
async function openFixture$6(engine, opts) {
|
|
4223
4223
|
if (opts.openKind === "bytes") {
|
|
4224
4224
|
const bytes = await opts.fixture.bytes();
|
|
4225
4225
|
return engine.open({
|
|
@@ -4502,7 +4502,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4502
4502
|
let supported = false;
|
|
4503
4503
|
beforeAll(async () => {
|
|
4504
4504
|
engine = await opts.makeEngine();
|
|
4505
|
-
const probe = await openFixture$
|
|
4505
|
+
const probe = await openFixture$5(engine, opts);
|
|
4506
4506
|
supported = probe.pages.insert !== void 0 && probe.pages.extract !== void 0;
|
|
4507
4507
|
await probe.close();
|
|
4508
4508
|
});
|
|
@@ -4511,7 +4511,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4511
4511
|
});
|
|
4512
4512
|
test("appends every source page with fresh PONs; existing pages keep identity", async () => {
|
|
4513
4513
|
if (!supported) return;
|
|
4514
|
-
const doc = await openFixture$
|
|
4514
|
+
const doc = await openFixture$5(engine, opts);
|
|
4515
4515
|
try {
|
|
4516
4516
|
const before = await doc.pages.list();
|
|
4517
4517
|
const beforePons = before.pages.map((p) => p.pageObjectNumber);
|
|
@@ -4530,7 +4530,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4530
4530
|
});
|
|
4531
4531
|
test("destIndex places the block mid-document, in source order", async () => {
|
|
4532
4532
|
if (!supported) return;
|
|
4533
|
-
const doc = await openFixture$
|
|
4533
|
+
const doc = await openFixture$5(engine, opts);
|
|
4534
4534
|
try {
|
|
4535
4535
|
const before = await doc.pages.list();
|
|
4536
4536
|
if (before.pages.length < 2) return;
|
|
@@ -4548,7 +4548,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4548
4548
|
});
|
|
4549
4549
|
test("the inserted pages persist through save → re-open", async () => {
|
|
4550
4550
|
if (!supported || opts.openKind !== "bytes") return;
|
|
4551
|
-
const doc = await openFixture$
|
|
4551
|
+
const doc = await openFixture$5(engine, opts);
|
|
4552
4552
|
let reopened = null;
|
|
4553
4553
|
try {
|
|
4554
4554
|
const before = await doc.pages.list();
|
|
@@ -4569,7 +4569,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4569
4569
|
});
|
|
4570
4570
|
test("empty bytes reject with InvalidArg; garbage rejects with MalformedPdf", async () => {
|
|
4571
4571
|
if (!supported) return;
|
|
4572
|
-
const doc = await openFixture$
|
|
4572
|
+
const doc = await openFixture$5(engine, opts);
|
|
4573
4573
|
try {
|
|
4574
4574
|
let caught;
|
|
4575
4575
|
try {
|
|
@@ -4593,7 +4593,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4593
4593
|
});
|
|
4594
4594
|
test("out-of-range destIndex rejects with InvalidArg", async () => {
|
|
4595
4595
|
if (!supported) return;
|
|
4596
|
-
const doc = await openFixture$
|
|
4596
|
+
const doc = await openFixture$5(engine, opts);
|
|
4597
4597
|
try {
|
|
4598
4598
|
const before = await doc.pages.list();
|
|
4599
4599
|
const single = await doc.pages.extract([before.pages[0].pageObjectNumber]);
|
|
@@ -4610,7 +4610,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4610
4610
|
});
|
|
4611
4611
|
});
|
|
4612
4612
|
}
|
|
4613
|
-
async function openFixture$
|
|
4613
|
+
async function openFixture$5(engine, opts) {
|
|
4614
4614
|
if (opts.openKind === "bytes") {
|
|
4615
4615
|
const bytes = await opts.fixture.bytes();
|
|
4616
4616
|
return engine.open({
|
|
@@ -4651,7 +4651,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4651
4651
|
let supported = false;
|
|
4652
4652
|
beforeAll(async () => {
|
|
4653
4653
|
engine = await opts.makeEngine();
|
|
4654
|
-
const probe = await openFixture$
|
|
4654
|
+
const probe = await openFixture$4(engine, opts);
|
|
4655
4655
|
supported = probe.pieceInfo !== void 0;
|
|
4656
4656
|
await probe.close();
|
|
4657
4657
|
});
|
|
@@ -4660,7 +4660,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4660
4660
|
});
|
|
4661
4661
|
test("doc-level: the full value vocabulary round-trips with tags intact", async () => {
|
|
4662
4662
|
if (!supported) return;
|
|
4663
|
-
const doc = await openFixture$
|
|
4663
|
+
const doc = await openFixture$4(engine, opts);
|
|
4664
4664
|
try {
|
|
4665
4665
|
await doc.pieceInfo.update(APP, {
|
|
4666
4666
|
name: "Standard Stamps",
|
|
@@ -4700,7 +4700,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4700
4700
|
});
|
|
4701
4701
|
test("page-level: the stamp schema round-trips on a page", async () => {
|
|
4702
4702
|
if (!supported) return;
|
|
4703
|
-
const doc = await openFixture$
|
|
4703
|
+
const doc = await openFixture$4(engine, opts);
|
|
4704
4704
|
try {
|
|
4705
4705
|
const list = await doc.pages.list();
|
|
4706
4706
|
const page = doc.page(list.pages[0].pageObjectNumber);
|
|
@@ -4726,7 +4726,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4726
4726
|
});
|
|
4727
4727
|
test("writes persist through save → re-open", async () => {
|
|
4728
4728
|
if (!supported || opts.openKind !== "bytes") return;
|
|
4729
|
-
const doc = await openFixture$
|
|
4729
|
+
const doc = await openFixture$4(engine, opts);
|
|
4730
4730
|
let reopened = null;
|
|
4731
4731
|
try {
|
|
4732
4732
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
@@ -4759,7 +4759,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4759
4759
|
});
|
|
4760
4760
|
test("null deletes a key; clear removes an entry; siblings survive", async () => {
|
|
4761
4761
|
if (!supported) return;
|
|
4762
|
-
const doc = await openFixture$
|
|
4762
|
+
const doc = await openFixture$4(engine, opts);
|
|
4763
4763
|
try {
|
|
4764
4764
|
await doc.pieceInfo.update(APP, {
|
|
4765
4765
|
name: "A",
|
|
@@ -4785,7 +4785,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4785
4785
|
});
|
|
4786
4786
|
test("an application that was never written reads as null", async () => {
|
|
4787
4787
|
if (!supported) return;
|
|
4788
|
-
const doc = await openFixture$
|
|
4788
|
+
const doc = await openFixture$4(engine, opts);
|
|
4789
4789
|
try {
|
|
4790
4790
|
expect(await doc.pieceInfo.read("EMBD_NeverWritten")).toBe(null);
|
|
4791
4791
|
const list = await doc.pages.list();
|
|
@@ -4796,7 +4796,7 @@ function runPieceInfoConformance(runner, opts) {
|
|
|
4796
4796
|
});
|
|
4797
4797
|
});
|
|
4798
4798
|
}
|
|
4799
|
-
async function openFixture$
|
|
4799
|
+
async function openFixture$4(engine, opts) {
|
|
4800
4800
|
if (opts.openKind === "bytes") {
|
|
4801
4801
|
const bytes = await opts.fixture.bytes();
|
|
4802
4802
|
return engine.open({
|
|
@@ -4859,7 +4859,7 @@ function runDocumentEventsConformance(runner, opts) {
|
|
|
4859
4859
|
if (engine) await engine.destroy();
|
|
4860
4860
|
});
|
|
4861
4861
|
test("every confirmed mutation publishes exactly one event, results verbatim", async () => {
|
|
4862
|
-
const doc = await openFixture$
|
|
4862
|
+
const doc = await openFixture$3(engine, opts);
|
|
4863
4863
|
try {
|
|
4864
4864
|
const events = [];
|
|
4865
4865
|
doc.events.subscribe((event) => events.push(event));
|
|
@@ -4918,7 +4918,7 @@ function runDocumentEventsConformance(runner, opts) {
|
|
|
4918
4918
|
}
|
|
4919
4919
|
});
|
|
4920
4920
|
test("a FAILED mutation publishes nothing (events are ground truth)", async () => {
|
|
4921
|
-
const doc = await openFixture$
|
|
4921
|
+
const doc = await openFixture$3(engine, opts);
|
|
4922
4922
|
try {
|
|
4923
4923
|
const events = [];
|
|
4924
4924
|
doc.events.subscribe((event) => events.push(event));
|
|
@@ -4936,7 +4936,7 @@ function runDocumentEventsConformance(runner, opts) {
|
|
|
4936
4936
|
}
|
|
4937
4937
|
});
|
|
4938
4938
|
test("unsubscribe stops delivery", async () => {
|
|
4939
|
-
const doc = await openFixture$
|
|
4939
|
+
const doc = await openFixture$3(engine, opts);
|
|
4940
4940
|
try {
|
|
4941
4941
|
const events = [];
|
|
4942
4942
|
doc.events.subscribe((event) => events.push(event))();
|
|
@@ -4949,7 +4949,7 @@ function runDocumentEventsConformance(runner, opts) {
|
|
|
4949
4949
|
});
|
|
4950
4950
|
});
|
|
4951
4951
|
}
|
|
4952
|
-
async function openFixture$
|
|
4952
|
+
async function openFixture$3(engine, opts) {
|
|
4953
4953
|
if (opts.openKind === "bytes") {
|
|
4954
4954
|
const bytes = await opts.fixture.bytes();
|
|
4955
4955
|
return engine.open({
|
|
@@ -4976,7 +4976,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
4976
4976
|
if (engine) await engine.destroy();
|
|
4977
4977
|
});
|
|
4978
4978
|
test("read() returns a PageTextSnapshot with non-empty text", async () => {
|
|
4979
|
-
const doc = await openFixture$
|
|
4979
|
+
const doc = await openFixture$2(engine, opts);
|
|
4980
4980
|
try {
|
|
4981
4981
|
const snap = await doc.page(opts.fixture.pageObjectNumber).text.read();
|
|
4982
4982
|
expect(require_schemas.PageTextSnapshotSchema.safeParse(snap).success).toBe(true);
|
|
@@ -4987,7 +4987,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
4987
4987
|
}
|
|
4988
4988
|
});
|
|
4989
4989
|
test("extracted text contains the expected substring", async () => {
|
|
4990
|
-
const doc = await openFixture$
|
|
4990
|
+
const doc = await openFixture$2(engine, opts);
|
|
4991
4991
|
try {
|
|
4992
4992
|
const snap = await doc.page(opts.fixture.pageObjectNumber).text.read();
|
|
4993
4993
|
expect(snap.text.includes(opts.fixture.expectedSubstring)).toBe(true);
|
|
@@ -4996,7 +4996,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
4996
4996
|
}
|
|
4997
4997
|
});
|
|
4998
4998
|
test("read() on an unknown pageObjectNumber throws NotFound", async () => {
|
|
4999
|
-
const doc = await openFixture$
|
|
4999
|
+
const doc = await openFixture$2(engine, opts);
|
|
5000
5000
|
try {
|
|
5001
5001
|
let caught;
|
|
5002
5002
|
try {
|
|
@@ -5011,7 +5011,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
5011
5011
|
}
|
|
5012
5012
|
});
|
|
5013
5013
|
test("abort() on read rejects with AbortError", async () => {
|
|
5014
|
-
const doc = await openFixture$
|
|
5014
|
+
const doc = await openFixture$2(engine, opts);
|
|
5015
5015
|
try {
|
|
5016
5016
|
const p = doc.page(opts.fixture.pageObjectNumber).text.read();
|
|
5017
5017
|
p.abort("test");
|
|
@@ -5021,7 +5021,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
5021
5021
|
}
|
|
5022
5022
|
});
|
|
5023
5023
|
test("read after close throws DocNotOpen", async () => {
|
|
5024
|
-
const doc = await openFixture$
|
|
5024
|
+
const doc = await openFixture$2(engine, opts);
|
|
5025
5025
|
const page = doc.page(opts.fixture.pageObjectNumber);
|
|
5026
5026
|
await doc.close();
|
|
5027
5027
|
let caught;
|
|
@@ -5035,6 +5035,156 @@ function runPageTextConformance(runner, opts) {
|
|
|
5035
5035
|
});
|
|
5036
5036
|
});
|
|
5037
5037
|
}
|
|
5038
|
+
async function openFixture$2(engine, opts) {
|
|
5039
|
+
if (opts.openKind === "bytes") {
|
|
5040
|
+
const bytes = await opts.fixture.bytes();
|
|
5041
|
+
return engine.open({
|
|
5042
|
+
kind: "bytes",
|
|
5043
|
+
id: opts.fixture.id,
|
|
5044
|
+
bytes
|
|
5045
|
+
});
|
|
5046
|
+
}
|
|
5047
|
+
return engine.open({
|
|
5048
|
+
kind: "id",
|
|
5049
|
+
id: opts.fixture.cloudId ?? opts.fixture.id
|
|
5050
|
+
});
|
|
5051
|
+
}
|
|
5052
|
+
//#endregion
|
|
5053
|
+
//#region src/conformance/runPageGeometryOrientationConformance.ts
|
|
5054
|
+
const FLAG_EMPTY = 2;
|
|
5055
|
+
/** Absolute tolerance for coordinate assertions (PDF points). */
|
|
5056
|
+
const COORD_TOLERANCE = .001;
|
|
5057
|
+
/** Tolerance for baseline-angle assertions (radians). */
|
|
5058
|
+
const ANGLE_TOLERANCE = .001;
|
|
5059
|
+
function runPageGeometryOrientationConformance(runner, opts) {
|
|
5060
|
+
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
5061
|
+
describe(`page geometry orientation conformance: ${opts.label} [${opts.fixture.id}]`, () => {
|
|
5062
|
+
let engine;
|
|
5063
|
+
beforeAll(async () => {
|
|
5064
|
+
engine = await opts.makeEngine();
|
|
5065
|
+
});
|
|
5066
|
+
afterAll(async () => {
|
|
5067
|
+
if (engine) await engine.destroy();
|
|
5068
|
+
});
|
|
5069
|
+
const readSnapshot = async () => {
|
|
5070
|
+
const doc = await openFixture$1(engine, opts);
|
|
5071
|
+
return {
|
|
5072
|
+
snapshot: await doc.page(opts.fixture.pageObjectNumber).geometry.read(),
|
|
5073
|
+
close: () => doc.close()
|
|
5074
|
+
};
|
|
5075
|
+
};
|
|
5076
|
+
test("snapshot round-trips the wire schema", async () => {
|
|
5077
|
+
const { snapshot, close } = await readSnapshot();
|
|
5078
|
+
try {
|
|
5079
|
+
const parsed = require_schemas.PageGeometrySnapshotSchema.safeParse(snapshot);
|
|
5080
|
+
expect(parsed.success).toBe(true);
|
|
5081
|
+
if (parsed.success) expect(parsed.data).toEqual(snapshot);
|
|
5082
|
+
} finally {
|
|
5083
|
+
await close();
|
|
5084
|
+
}
|
|
5085
|
+
});
|
|
5086
|
+
test("run charStart indices tile the page glyph sequence", async () => {
|
|
5087
|
+
const { snapshot, close } = await readSnapshot();
|
|
5088
|
+
try {
|
|
5089
|
+
let next = 0;
|
|
5090
|
+
for (const run of snapshot.runs) {
|
|
5091
|
+
expect(run.charStart).toBe(next);
|
|
5092
|
+
next += run.glyphs.length;
|
|
5093
|
+
}
|
|
5094
|
+
} finally {
|
|
5095
|
+
await close();
|
|
5096
|
+
}
|
|
5097
|
+
});
|
|
5098
|
+
test("runs match the fixture orientation expectation", async () => {
|
|
5099
|
+
const { snapshot, close } = await readSnapshot();
|
|
5100
|
+
try {
|
|
5101
|
+
const expectation = opts.fixture.expectation;
|
|
5102
|
+
if (expectation.kind === "upright") {
|
|
5103
|
+
for (const run of snapshot.runs) {
|
|
5104
|
+
expect(require_fold.isRotatedGeometryRun(run)).toBe(false);
|
|
5105
|
+
if (require_fold.isRotatedGeometryRun(run)) continue;
|
|
5106
|
+
for (const glyph of run.glyphs) {
|
|
5107
|
+
expect("looseQuad" in glyph).toBe(false);
|
|
5108
|
+
if (glyph.flags & FLAG_EMPTY) expect(glyph.looseBox).toEqual({
|
|
5109
|
+
left: 0,
|
|
5110
|
+
bottom: 0,
|
|
5111
|
+
right: 0,
|
|
5112
|
+
top: 0
|
|
5113
|
+
});
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
return;
|
|
5117
|
+
}
|
|
5118
|
+
if (expectation.kind === "empty-only") {
|
|
5119
|
+
for (const run of snapshot.runs) {
|
|
5120
|
+
expect(require_fold.isRotatedGeometryRun(run)).toBe(false);
|
|
5121
|
+
if (require_fold.isRotatedGeometryRun(run)) continue;
|
|
5122
|
+
for (const glyph of run.glyphs) {
|
|
5123
|
+
expect(glyph.flags & FLAG_EMPTY).toBe(FLAG_EMPTY);
|
|
5124
|
+
expect(glyph.looseBox).toEqual({
|
|
5125
|
+
left: 0,
|
|
5126
|
+
bottom: 0,
|
|
5127
|
+
right: 0,
|
|
5128
|
+
top: 0
|
|
5129
|
+
});
|
|
5130
|
+
}
|
|
5131
|
+
}
|
|
5132
|
+
return;
|
|
5133
|
+
}
|
|
5134
|
+
const rotatedRuns = snapshot.runs.filter(require_fold.isRotatedGeometryRun);
|
|
5135
|
+
expect(rotatedRuns.length >= (expectation.minRotatedRuns ?? 1)).toBe(true);
|
|
5136
|
+
for (const run of rotatedRuns) {
|
|
5137
|
+
expect(expectation.rotations.some((angle) => angleClose(run.rotation, angle, ANGLE_TOLERANCE))).toBe(true);
|
|
5138
|
+
expect(run.ascentFlip).toBe(expectation.ascentFlip);
|
|
5139
|
+
assertRotatedRunGeometry(run);
|
|
5140
|
+
}
|
|
5141
|
+
if (expectation.sheared) {
|
|
5142
|
+
const shearedGlyphs = rotatedRuns.flatMap((run) => run.glyphs).filter((glyph) => (glyph.flags & FLAG_EMPTY) === 0 && Math.abs(glyph.looseQuad.p3.x - glyph.looseQuad.p1.x) > 1);
|
|
5143
|
+
expect(shearedGlyphs.length > 0).toBe(true);
|
|
5144
|
+
}
|
|
5145
|
+
} finally {
|
|
5146
|
+
await close();
|
|
5147
|
+
}
|
|
5148
|
+
});
|
|
5149
|
+
function assertRotatedRunGeometry(run) {
|
|
5150
|
+
for (const glyph of run.glyphs) {
|
|
5151
|
+
if (glyph.flags & FLAG_EMPTY) {
|
|
5152
|
+
expect(glyph.looseQuad).toEqual({
|
|
5153
|
+
p1: {
|
|
5154
|
+
x: 0,
|
|
5155
|
+
y: 0
|
|
5156
|
+
},
|
|
5157
|
+
p2: {
|
|
5158
|
+
x: 0,
|
|
5159
|
+
y: 0
|
|
5160
|
+
},
|
|
5161
|
+
p3: {
|
|
5162
|
+
x: 0,
|
|
5163
|
+
y: 0
|
|
5164
|
+
},
|
|
5165
|
+
p4: {
|
|
5166
|
+
x: 0,
|
|
5167
|
+
y: 0
|
|
5168
|
+
}
|
|
5169
|
+
});
|
|
5170
|
+
continue;
|
|
5171
|
+
}
|
|
5172
|
+
const q = glyph.looseQuad;
|
|
5173
|
+
expect(Math.abs(q.p2.x - q.p1.x - (q.p4.x - q.p3.x)) <= COORD_TOLERANCE).toBe(true);
|
|
5174
|
+
expect(Math.abs(q.p2.y - q.p1.y - (q.p4.y - q.p3.y)) <= COORD_TOLERANCE).toBe(true);
|
|
5175
|
+
const bounds = require_fold.pdfQuadBounds(q);
|
|
5176
|
+
expect(bounds.left >= run.rect.left - COORD_TOLERANCE).toBe(true);
|
|
5177
|
+
expect(bounds.right <= run.rect.right + COORD_TOLERANCE).toBe(true);
|
|
5178
|
+
expect(bounds.bottom >= run.rect.bottom - COORD_TOLERANCE).toBe(true);
|
|
5179
|
+
expect(bounds.top <= run.rect.top + COORD_TOLERANCE).toBe(true);
|
|
5180
|
+
}
|
|
5181
|
+
}
|
|
5182
|
+
});
|
|
5183
|
+
}
|
|
5184
|
+
function angleClose(a, b, tolerance) {
|
|
5185
|
+
const delta = a - b;
|
|
5186
|
+
return Math.abs(Math.atan2(Math.sin(delta), Math.cos(delta))) <= tolerance;
|
|
5187
|
+
}
|
|
5038
5188
|
async function openFixture$1(engine, opts) {
|
|
5039
5189
|
if (opts.openKind === "bytes") {
|
|
5040
5190
|
const bytes = await opts.fixture.bytes();
|
|
@@ -5090,10 +5240,27 @@ function runSearchConformance(runner, opts) {
|
|
|
5090
5240
|
expect(matches.some((m) => m.pageObjectNumber === fixture.presentPageObjectNumber)).toBe(true);
|
|
5091
5241
|
for (const m of matches) {
|
|
5092
5242
|
expect(m.charCount > 0).toBe(true);
|
|
5093
|
-
expect(m.
|
|
5094
|
-
for (const
|
|
5095
|
-
expect(
|
|
5096
|
-
expect(
|
|
5243
|
+
expect(m.segments.length > 0).toBe(true);
|
|
5244
|
+
for (const s of m.segments) {
|
|
5245
|
+
expect(s.rect.right > s.rect.left).toBe(true);
|
|
5246
|
+
expect(s.rect.top > s.rect.bottom).toBe(true);
|
|
5247
|
+
const xs = [
|
|
5248
|
+
s.quad.p1.x,
|
|
5249
|
+
s.quad.p2.x,
|
|
5250
|
+
s.quad.p3.x,
|
|
5251
|
+
s.quad.p4.x
|
|
5252
|
+
];
|
|
5253
|
+
const ys = [
|
|
5254
|
+
s.quad.p1.y,
|
|
5255
|
+
s.quad.p2.y,
|
|
5256
|
+
s.quad.p3.y,
|
|
5257
|
+
s.quad.p4.y
|
|
5258
|
+
];
|
|
5259
|
+
expect(Math.abs(s.rect.left - Math.min(...xs)) < .001).toBe(true);
|
|
5260
|
+
expect(Math.abs(s.rect.right - Math.max(...xs)) < .001).toBe(true);
|
|
5261
|
+
expect(Math.abs(s.rect.bottom - Math.min(...ys)) < .001).toBe(true);
|
|
5262
|
+
expect(Math.abs(s.rect.top - Math.max(...ys)) < .001).toBe(true);
|
|
5263
|
+
expect(s.advance === 1 || s.advance === -1).toBe(true);
|
|
5097
5264
|
}
|
|
5098
5265
|
}
|
|
5099
5266
|
} finally {
|
|
@@ -5225,7 +5392,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5225
5392
|
expect(matches.length > 0).toBe(true);
|
|
5226
5393
|
for (const m of matches) {
|
|
5227
5394
|
expect(m.charCount > 0).toBe(true);
|
|
5228
|
-
expect(m.
|
|
5395
|
+
expect(m.segments.length > 0).toBe(true);
|
|
5229
5396
|
}
|
|
5230
5397
|
} finally {
|
|
5231
5398
|
await doc.close();
|
|
@@ -5403,6 +5570,7 @@ exports.runMetadataConformance = runMetadataConformance;
|
|
|
5403
5570
|
exports.runPageDeleteConformance = runPageDeleteConformance;
|
|
5404
5571
|
exports.runPageExtractConformance = runPageExtractConformance;
|
|
5405
5572
|
exports.runPageFlattenConformance = runPageFlattenConformance;
|
|
5573
|
+
exports.runPageGeometryOrientationConformance = runPageGeometryOrientationConformance;
|
|
5406
5574
|
exports.runPageInsertConformance = runPageInsertConformance;
|
|
5407
5575
|
exports.runPageReorderConformance = runPageReorderConformance;
|
|
5408
5576
|
exports.runPageRotateConformance = runPageRotateConformance;
|