@embedpdf/engine-core 3.0.0-next.3 → 3.0.0-next.5
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-CjSasIlL.js → AbortError-BsHuCO1S.js} +2 -2
- package/dist/{AbortError-CjSasIlL.js.map → AbortError-BsHuCO1S.js.map} +1 -1
- package/dist/{AbortError-ByBflvEl.cjs → AbortError-DmWeq9sx.cjs} +2 -2
- package/dist/{AbortError-ByBflvEl.cjs.map → AbortError-DmWeq9sx.cjs.map} +1 -1
- package/dist/{AnnotationListSnapshot-W0RCsyDE.d.cts → AnnotationListSnapshot-CHjkcIaL.d.cts} +345 -36
- package/dist/{AnnotationListSnapshot-W0RCsyDE.d.ts → AnnotationListSnapshot-CHjkcIaL.d.ts} +345 -36
- package/dist/{DocumentSecurityService-Df79fgpe.d.cts → DocumentSecurityService-B1uv4FaK.d.cts} +2 -2
- package/dist/{DocumentSecurityService-B-tULKNY.d.ts → DocumentSecurityService-CrxGktMI.d.ts} +2 -2
- package/dist/{Engine-B7Oe7f5i.d.ts → Engine-BE6r06QI.d.ts} +4 -4
- package/dist/{Engine-D9loFZc1.d.cts → Engine-BOaRwtKa.d.cts} +4 -4
- package/dist/{builders-BvikWRuO.cjs → builders-BsUc2A1U.cjs} +426 -223
- package/dist/builders-BsUc2A1U.cjs.map +1 -0
- package/dist/{builders-C548U47M.js → builders-CF5gKkOa.js} +382 -167
- package/dist/builders-CF5gKkOa.js.map +1 -0
- package/dist/{subtype-BvAzLCGC.js → charmap-CUukAMhR.js} +140 -2
- package/dist/charmap-CUukAMhR.js.map +1 -0
- package/dist/{subtype-qejjVr6h.cjs → charmap-D6PLtRiC.cjs} +169 -1
- package/dist/charmap-D6PLtRiC.cjs.map +1 -0
- package/dist/conformance.cjs +511 -177
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +99 -3
- package/dist/conformance.d.ts +99 -3
- package/dist/conformance.js +467 -136
- package/dist/conformance.js.map +1 -1
- package/dist/{fold-IaMph3CO.cjs → fold-BeT1GxLP.cjs} +235 -4
- package/dist/fold-BeT1GxLP.cjs.map +1 -0
- package/dist/{fold-CB4fAOOy.js → fold-DemV94jf.js} +162 -3
- package/dist/fold-DemV94jf.js.map +1 -0
- package/dist/index.cjs +33 -18
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/runtime.cjs +38 -23
- package/dist/runtime.d.cts +4 -4
- package/dist/runtime.d.ts +4 -4
- package/dist/runtime.js +5 -5
- package/dist/{schemas-B_1VyFsm.cjs → schemas-CyWwm0Zf.cjs} +64 -30
- package/dist/schemas-CyWwm0Zf.cjs.map +1 -0
- package/dist/{schemas-9OpSSeM6.js → schemas-ES6-TkIl.js} +44 -10
- package/dist/schemas-ES6-TkIl.js.map +1 -0
- package/dist/wire.cjs +14 -1
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +19 -9
- package/dist/wire.d.ts +19 -9
- 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-BeT1GxLP.cjs");
|
|
3
|
+
const require_charmap = require("./charmap-D6PLtRiC.cjs");
|
|
4
|
+
const require_AbortError = require("./AbortError-DmWeq9sx.cjs");
|
|
5
|
+
const require_schemas = require("./schemas-CyWwm0Zf.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$16(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$16(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$16(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$16(engine, opts);
|
|
55
55
|
await doc.close();
|
|
56
56
|
let caught;
|
|
57
57
|
try {
|
|
@@ -60,10 +60,10 @@ function runMetadataConformance(runner, opts) {
|
|
|
60
60
|
caught = err;
|
|
61
61
|
}
|
|
62
62
|
expect(caught).toBeTruthy();
|
|
63
|
-
expect(require_fold.EngineError.is(caught,
|
|
63
|
+
expect(require_fold.EngineError.is(caught, require_charmap.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$16(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$16(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$16(engine, opts);
|
|
99
99
|
await doc.close();
|
|
100
100
|
let caught;
|
|
101
101
|
try {
|
|
@@ -104,11 +104,11 @@ function runMetadataConformance(runner, opts) {
|
|
|
104
104
|
caught = err;
|
|
105
105
|
}
|
|
106
106
|
expect(caught).toBeTruthy();
|
|
107
|
-
expect(require_fold.EngineError.is(caught,
|
|
107
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
async function openFixture$
|
|
111
|
+
async function openFixture$16(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$15(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$15(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$15(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$15(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$15(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$15(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$15(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$15(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$15(engine, opts);
|
|
327
327
|
try {
|
|
328
328
|
let caught;
|
|
329
329
|
try {
|
|
@@ -332,14 +332,14 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
332
332
|
caught = err;
|
|
333
333
|
}
|
|
334
334
|
expect(caught).toBeTruthy();
|
|
335
|
-
expect(require_fold.EngineError.is(caught,
|
|
335
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound)).toBe(true);
|
|
336
336
|
} finally {
|
|
337
337
|
await doc.close();
|
|
338
338
|
}
|
|
339
339
|
});
|
|
340
340
|
});
|
|
341
341
|
}
|
|
342
|
-
async function openFixture$
|
|
342
|
+
async function openFixture$15(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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");
|
|
@@ -1913,13 +1913,13 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1913
1913
|
} catch (err) {
|
|
1914
1914
|
caught = err;
|
|
1915
1915
|
}
|
|
1916
|
-
expect(require_fold.EngineError.is(caught,
|
|
1916
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidReference)).toBe(true);
|
|
1917
1917
|
} finally {
|
|
1918
1918
|
await doc.close();
|
|
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$14(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$14(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$14(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$14(engine, opts);
|
|
2031
2031
|
try {
|
|
2032
2032
|
const page = doc.page(fix.pageObjectNumber);
|
|
2033
2033
|
const a = await page.annotations.create({
|
|
@@ -2059,13 +2059,13 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2059
2059
|
} finally {
|
|
2060
2060
|
await weakSession?.release();
|
|
2061
2061
|
}
|
|
2062
|
-
expect(require_fold.EngineError.is(caught,
|
|
2062
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidReference)).toBe(true);
|
|
2063
2063
|
} finally {
|
|
2064
2064
|
await doc.close();
|
|
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$14(engine, opts);
|
|
2069
2069
|
try {
|
|
2070
2070
|
const page = doc.page(fix.pageObjectNumber);
|
|
2071
2071
|
const a = await page.annotations.create({
|
|
@@ -2083,13 +2083,13 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2083
2083
|
} finally {
|
|
2084
2084
|
await weakSession?.release();
|
|
2085
2085
|
}
|
|
2086
|
-
expect(require_fold.EngineError.is(caught,
|
|
2086
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
2087
2087
|
} finally {
|
|
2088
2088
|
await doc.close();
|
|
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$14(engine, opts);
|
|
2093
2093
|
try {
|
|
2094
2094
|
const page = doc.page(fix.pageObjectNumber);
|
|
2095
2095
|
const a = await page.annotations.create({
|
|
@@ -2106,13 +2106,13 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2106
2106
|
} finally {
|
|
2107
2107
|
await weakSession?.release();
|
|
2108
2108
|
}
|
|
2109
|
-
expect(require_fold.EngineError.is(caught,
|
|
2109
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
2110
2110
|
} finally {
|
|
2111
2111
|
await doc.close();
|
|
2112
2112
|
}
|
|
2113
2113
|
});
|
|
2114
2114
|
test("abort on move rejects with AbortError", async () => {
|
|
2115
|
-
const doc = await openFixture$
|
|
2115
|
+
const doc = await openFixture$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(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$14(engine, opts);
|
|
2501
2501
|
try {
|
|
2502
2502
|
const page = doc.page(fix.pageObjectNumber);
|
|
2503
2503
|
const parent = await page.annotations.create({
|
|
@@ -2522,7 +2522,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2522
2522
|
} catch (err) {
|
|
2523
2523
|
caught = err;
|
|
2524
2524
|
}
|
|
2525
|
-
expect(require_fold.EngineError.is(caught,
|
|
2525
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
2526
2526
|
} finally {
|
|
2527
2527
|
await doc.close();
|
|
2528
2528
|
}
|
|
@@ -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$14(engine, opts) {
|
|
2537
2537
|
if (opts.openKind === "bytes") {
|
|
2538
2538
|
const bytes = await opts.fixture.bytes();
|
|
2539
2539
|
return engine.open({
|
|
@@ -2699,7 +2699,7 @@ function runFormConformance(runner, opts) {
|
|
|
2699
2699
|
await expect(doc.forms.setValue(radioRef, {
|
|
2700
2700
|
type: "toggle",
|
|
2701
2701
|
state: null
|
|
2702
|
-
})).rejects.toMatchObject({ code:
|
|
2702
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
2703
2703
|
const check = await doc.forms.setValue({
|
|
2704
2704
|
kind: "fqn",
|
|
2705
2705
|
name: "opt_check"
|
|
@@ -2727,7 +2727,7 @@ function runFormConformance(runner, opts) {
|
|
|
2727
2727
|
}, {
|
|
2728
2728
|
type: "toggle",
|
|
2729
2729
|
state: "On"
|
|
2730
|
-
})).rejects.toMatchObject({ code:
|
|
2730
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
2731
2731
|
const field = await doc.forms.get({
|
|
2732
2732
|
kind: "fqn",
|
|
2733
2733
|
name: "maxlen_text"
|
|
@@ -2831,7 +2831,7 @@ function runFormConformance(runner, opts) {
|
|
|
2831
2831
|
}, {
|
|
2832
2832
|
type: "choice",
|
|
2833
2833
|
values: ["foo", "bar"]
|
|
2834
|
-
})).rejects.toMatchObject({ code:
|
|
2834
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
2835
2835
|
} finally {
|
|
2836
2836
|
await doc.close();
|
|
2837
2837
|
}
|
|
@@ -2901,7 +2901,7 @@ function runFormConformance(runner, opts) {
|
|
|
2901
2901
|
test("rejects garbage import payloads", async () => {
|
|
2902
2902
|
const doc = await open(opts.fixtures.toggleFields);
|
|
2903
2903
|
try {
|
|
2904
|
-
await expect(doc.forms.importData(new TextEncoder().encode("not a form payload"))).rejects.toMatchObject({ code:
|
|
2904
|
+
await expect(doc.forms.importData(new TextEncoder().encode("not a form payload"))).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
2905
2905
|
} finally {
|
|
2906
2906
|
await doc.close();
|
|
2907
2907
|
}
|
|
@@ -3008,7 +3008,7 @@ function runFormConformance(runner, opts) {
|
|
|
3008
3008
|
g: 247,
|
|
3009
3009
|
b: 219
|
|
3010
3010
|
});
|
|
3011
|
-
await expect(page.annotations.delete(widgetRef)).rejects.toMatchObject({ code:
|
|
3011
|
+
await expect(page.annotations.delete(widgetRef)).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
3012
3012
|
await doc.forms.detachWidget(field.field.ref, {
|
|
3013
3013
|
annotObjectNumber: widgetRef.annotObjectNumber,
|
|
3014
3014
|
pageObjectNumber: pon
|
|
@@ -3072,7 +3072,7 @@ function runFormConformance(runner, opts) {
|
|
|
3072
3072
|
await expect(doc.forms.updateField(created.field.ref, {
|
|
3073
3073
|
family: "radio",
|
|
3074
3074
|
name: "unison_radio"
|
|
3075
|
-
})).rejects.toMatchObject({ code:
|
|
3075
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
3076
3076
|
const before = await doc.page(pon).annotations.list();
|
|
3077
3077
|
const removed = await doc.forms.deleteField(created.field.ref);
|
|
3078
3078
|
expect(removed.removedWidgets.length).toBe(2);
|
|
@@ -3081,7 +3081,7 @@ function runFormConformance(runner, opts) {
|
|
|
3081
3081
|
await expect(doc.forms.get({
|
|
3082
3082
|
kind: "fqn",
|
|
3083
3083
|
name: "renamed_radio"
|
|
3084
|
-
})).rejects.toMatchObject({ code:
|
|
3084
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.NotFound });
|
|
3085
3085
|
} finally {
|
|
3086
3086
|
await doc.close();
|
|
3087
3087
|
}
|
|
@@ -3092,7 +3092,7 @@ function runFormConformance(runner, opts) {
|
|
|
3092
3092
|
await expect(doc.forms.get({
|
|
3093
3093
|
kind: "fqn",
|
|
3094
3094
|
name: "no.such.field"
|
|
3095
|
-
})).rejects.toMatchObject({ code:
|
|
3095
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.NotFound });
|
|
3096
3096
|
} finally {
|
|
3097
3097
|
await doc.close();
|
|
3098
3098
|
}
|
|
@@ -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$13(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$13(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$13(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$13(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$13(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$12(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$12(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$12(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$12(engine, opts);
|
|
3378
3378
|
try {
|
|
3379
3379
|
const list = await doc.pages.list();
|
|
3380
3380
|
if (list.pages.length < 1) return;
|
|
@@ -3385,13 +3385,13 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3385
3385
|
} catch (err) {
|
|
3386
3386
|
caught = err;
|
|
3387
3387
|
}
|
|
3388
|
-
expect(require_fold.EngineError.is(caught,
|
|
3388
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3389
3389
|
} finally {
|
|
3390
3390
|
await doc.close();
|
|
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$12(engine, opts);
|
|
3395
3395
|
try {
|
|
3396
3396
|
const list = await doc.pages.list();
|
|
3397
3397
|
if (list.pages.length < 1) return;
|
|
@@ -3402,13 +3402,13 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3402
3402
|
} catch (err) {
|
|
3403
3403
|
caught = err;
|
|
3404
3404
|
}
|
|
3405
|
-
expect(require_fold.EngineError.is(caught,
|
|
3405
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3406
3406
|
} finally {
|
|
3407
3407
|
await doc.close();
|
|
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$12(engine, opts);
|
|
3412
3412
|
try {
|
|
3413
3413
|
const list = await doc.pages.list();
|
|
3414
3414
|
let bogus = 0;
|
|
@@ -3420,13 +3420,13 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3420
3420
|
} catch (err) {
|
|
3421
3421
|
caught = err;
|
|
3422
3422
|
}
|
|
3423
|
-
expect(require_fold.EngineError.is(caught,
|
|
3423
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound) || require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3424
3424
|
} finally {
|
|
3425
3425
|
await doc.close();
|
|
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$12(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$12(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$11(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$11(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$11(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$11(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$11(engine, opts);
|
|
3590
3590
|
try {
|
|
3591
3591
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3592
3592
|
let caught;
|
|
@@ -3595,13 +3595,13 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3595
3595
|
} catch (err) {
|
|
3596
3596
|
caught = err;
|
|
3597
3597
|
}
|
|
3598
|
-
expect(require_fold.EngineError.is(caught,
|
|
3598
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3599
3599
|
} finally {
|
|
3600
3600
|
await doc.close();
|
|
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$11(engine, opts);
|
|
3605
3605
|
try {
|
|
3606
3606
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3607
3607
|
let caught;
|
|
@@ -3610,13 +3610,13 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3610
3610
|
} catch (err) {
|
|
3611
3611
|
caught = err;
|
|
3612
3612
|
}
|
|
3613
|
-
expect(require_fold.EngineError.is(caught,
|
|
3613
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3614
3614
|
} finally {
|
|
3615
3615
|
await doc.close();
|
|
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$11(engine, opts);
|
|
3620
3620
|
try {
|
|
3621
3621
|
const list = await doc.pages.list();
|
|
3622
3622
|
let bogus = 0;
|
|
@@ -3628,13 +3628,13 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3628
3628
|
} catch (err) {
|
|
3629
3629
|
caught = err;
|
|
3630
3630
|
}
|
|
3631
|
-
expect(require_fold.EngineError.is(caught,
|
|
3631
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound) || require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3632
3632
|
} finally {
|
|
3633
3633
|
await doc.close();
|
|
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$11(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$11(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$10(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$10(engine, opts);
|
|
3734
3734
|
try {
|
|
3735
3735
|
const before = await doc.pages.list();
|
|
3736
3736
|
if (before.pages.length < 2) return;
|
|
@@ -3742,13 +3742,13 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3742
3742
|
} catch (err) {
|
|
3743
3743
|
caught = err;
|
|
3744
3744
|
}
|
|
3745
|
-
expect(require_fold.EngineError.is(caught,
|
|
3745
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound)).toBe(true);
|
|
3746
3746
|
} finally {
|
|
3747
3747
|
await doc.close();
|
|
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$10(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$10(engine, opts);
|
|
3785
3785
|
try {
|
|
3786
3786
|
const list = await doc.pages.list();
|
|
3787
3787
|
let caught;
|
|
@@ -3790,13 +3790,13 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3790
3790
|
} catch (err) {
|
|
3791
3791
|
caught = err;
|
|
3792
3792
|
}
|
|
3793
|
-
expect(require_fold.EngineError.is(caught,
|
|
3793
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3794
3794
|
} finally {
|
|
3795
3795
|
await doc.close();
|
|
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$10(engine, opts);
|
|
3800
3800
|
try {
|
|
3801
3801
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3802
3802
|
let caught;
|
|
@@ -3805,13 +3805,13 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3805
3805
|
} catch (err) {
|
|
3806
3806
|
caught = err;
|
|
3807
3807
|
}
|
|
3808
|
-
expect(require_fold.EngineError.is(caught,
|
|
3808
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3809
3809
|
} finally {
|
|
3810
3810
|
await doc.close();
|
|
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$10(engine, opts);
|
|
3815
3815
|
try {
|
|
3816
3816
|
const list = await doc.pages.list();
|
|
3817
3817
|
let bogus = 0;
|
|
@@ -3823,13 +3823,13 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3823
3823
|
} catch (err) {
|
|
3824
3824
|
caught = err;
|
|
3825
3825
|
}
|
|
3826
|
-
expect(require_fold.EngineError.is(caught,
|
|
3826
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound) || require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3827
3827
|
} finally {
|
|
3828
3828
|
await doc.close();
|
|
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$10(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$10(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$9(engine, opts);
|
|
3875
3875
|
try {
|
|
3876
3876
|
if (!doc.pages.flatten) return;
|
|
3877
3877
|
const layoutBefore = await doc.pages.list();
|
|
@@ -3898,14 +3898,14 @@ function runPageFlattenConformance(runner, opts) {
|
|
|
3898
3898
|
expect(noOp.meta).toBeNull();
|
|
3899
3899
|
expect(events).toHaveLength(1);
|
|
3900
3900
|
unsubscribe();
|
|
3901
|
-
await expect(doc.pages.flatten([pageObjectNumber, pageObjectNumber])).rejects.toMatchObject({ code:
|
|
3901
|
+
await expect(doc.pages.flatten([pageObjectNumber, pageObjectNumber])).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
3902
3902
|
} finally {
|
|
3903
3903
|
await doc.close();
|
|
3904
3904
|
}
|
|
3905
3905
|
});
|
|
3906
3906
|
});
|
|
3907
3907
|
}
|
|
3908
|
-
async function openFixture$
|
|
3908
|
+
async function openFixture$9(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$8(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$8(engine, opts);
|
|
4018
4018
|
try {
|
|
4019
4019
|
if (!doc.redaction) return;
|
|
4020
4020
|
const pageObjectNumber = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
@@ -4050,7 +4050,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
4050
4050
|
await expect(doc.redaction.apply({
|
|
4051
4051
|
kind: "pages",
|
|
4052
4052
|
pageObjectNumbers: [pageObjectNumber, pageObjectNumber]
|
|
4053
|
-
})).rejects.toMatchObject({ code:
|
|
4053
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
4054
4054
|
const notRedact = await page.annotations.create({
|
|
4055
4055
|
subtype: "highlight",
|
|
4056
4056
|
quadPoints: COLLATERAL_QUAD
|
|
@@ -4058,14 +4058,14 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
4058
4058
|
await expect(doc.redaction.apply({
|
|
4059
4059
|
kind: "annotations",
|
|
4060
4060
|
refs: [notRedact.created.ref]
|
|
4061
|
-
})).rejects.toMatchObject({ code:
|
|
4061
|
+
})).rejects.toMatchObject({ code: require_charmap.EngineErrorCode.InvalidArg });
|
|
4062
4062
|
} finally {
|
|
4063
4063
|
await doc.close();
|
|
4064
4064
|
}
|
|
4065
4065
|
});
|
|
4066
4066
|
});
|
|
4067
4067
|
}
|
|
4068
|
-
async function openFixture$
|
|
4068
|
+
async function openFixture$8(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$7(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$7(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$7(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$7(engine, opts);
|
|
4161
4161
|
try {
|
|
4162
4162
|
let caught;
|
|
4163
4163
|
try {
|
|
@@ -4165,14 +4165,14 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4165
4165
|
} catch (err) {
|
|
4166
4166
|
caught = err;
|
|
4167
4167
|
}
|
|
4168
|
-
expect(require_fold.EngineError.is(caught,
|
|
4168
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4169
4169
|
} finally {
|
|
4170
4170
|
await doc.close();
|
|
4171
4171
|
}
|
|
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$7(engine, opts);
|
|
4176
4176
|
try {
|
|
4177
4177
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
4178
4178
|
let caught;
|
|
@@ -4181,14 +4181,14 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4181
4181
|
} catch (err) {
|
|
4182
4182
|
caught = err;
|
|
4183
4183
|
}
|
|
4184
|
-
expect(require_fold.EngineError.is(caught,
|
|
4184
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4185
4185
|
} finally {
|
|
4186
4186
|
await doc.close();
|
|
4187
4187
|
}
|
|
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$7(engine, opts);
|
|
4192
4192
|
try {
|
|
4193
4193
|
const list = await doc.pages.list();
|
|
4194
4194
|
let bogus = 0;
|
|
@@ -4200,14 +4200,14 @@ function runPageExtractConformance(runner, opts) {
|
|
|
4200
4200
|
} catch (err) {
|
|
4201
4201
|
caught = err;
|
|
4202
4202
|
}
|
|
4203
|
-
expect(require_fold.EngineError.is(caught,
|
|
4203
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound) || require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4204
4204
|
} finally {
|
|
4205
4205
|
await doc.close();
|
|
4206
4206
|
}
|
|
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$7(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$7(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$6(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$6(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$6(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$6(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$6(engine, opts);
|
|
4573
4573
|
try {
|
|
4574
4574
|
let caught;
|
|
4575
4575
|
try {
|
|
@@ -4577,14 +4577,14 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4577
4577
|
} catch (err) {
|
|
4578
4578
|
caught = err;
|
|
4579
4579
|
}
|
|
4580
|
-
expect(require_fold.EngineError.is(caught,
|
|
4580
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4581
4581
|
caught = void 0;
|
|
4582
4582
|
try {
|
|
4583
4583
|
await doc.pages.insert(new TextEncoder().encode("not a pdf at all"));
|
|
4584
4584
|
} catch (err) {
|
|
4585
4585
|
caught = err;
|
|
4586
4586
|
}
|
|
4587
|
-
expect(require_fold.EngineError.is(caught,
|
|
4587
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.MalformedPdf)).toBe(true);
|
|
4588
4588
|
const list = await doc.pages.list();
|
|
4589
4589
|
expect(list.pageCount > 0).toBe(true);
|
|
4590
4590
|
} finally {
|
|
@@ -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$6(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]);
|
|
@@ -4603,14 +4603,14 @@ function runPageInsertConformance(runner, opts) {
|
|
|
4603
4603
|
} catch (err) {
|
|
4604
4604
|
caught = err;
|
|
4605
4605
|
}
|
|
4606
|
-
expect(require_fold.EngineError.is(caught,
|
|
4606
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4607
4607
|
} finally {
|
|
4608
4608
|
await doc.close();
|
|
4609
4609
|
}
|
|
4610
4610
|
});
|
|
4611
4611
|
});
|
|
4612
4612
|
}
|
|
4613
|
-
async function openFixture$
|
|
4613
|
+
async function openFixture$6(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$5(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$5(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$5(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$5(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$5(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$5(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$5(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$4(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$4(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$4(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$4(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$3(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$3(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$3(engine, opts);
|
|
5000
5000
|
try {
|
|
5001
5001
|
let caught;
|
|
5002
5002
|
try {
|
|
@@ -5005,13 +5005,13 @@ function runPageTextConformance(runner, opts) {
|
|
|
5005
5005
|
caught = err;
|
|
5006
5006
|
}
|
|
5007
5007
|
expect(caught).toBeTruthy();
|
|
5008
|
-
expect(require_fold.EngineError.is(caught,
|
|
5008
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.NotFound)).toBe(true);
|
|
5009
5009
|
} finally {
|
|
5010
5010
|
await doc.close();
|
|
5011
5011
|
}
|
|
5012
5012
|
});
|
|
5013
5013
|
test("abort() on read rejects with AbortError", async () => {
|
|
5014
|
-
const doc = await openFixture$
|
|
5014
|
+
const doc = await openFixture$3(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$3(engine, opts);
|
|
5025
5025
|
const page = doc.page(opts.fixture.pageObjectNumber);
|
|
5026
5026
|
await doc.close();
|
|
5027
5027
|
let caught;
|
|
@@ -5031,10 +5031,324 @@ function runPageTextConformance(runner, opts) {
|
|
|
5031
5031
|
caught = err;
|
|
5032
5032
|
}
|
|
5033
5033
|
expect(caught).toBeTruthy();
|
|
5034
|
-
expect(require_fold.EngineError.is(caught,
|
|
5034
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
5035
|
+
});
|
|
5036
|
+
});
|
|
5037
|
+
}
|
|
5038
|
+
async function openFixture$3(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/runTextDivergenceConformance.ts
|
|
5054
|
+
function runTextDivergenceConformance(runner, opts) {
|
|
5055
|
+
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
5056
|
+
const fixture = opts.fixture;
|
|
5057
|
+
describe(`text divergence conformance: ${opts.label} [${fixture.id}]`, () => {
|
|
5058
|
+
let engine;
|
|
5059
|
+
beforeAll(async () => {
|
|
5060
|
+
engine = await opts.makeEngine();
|
|
5061
|
+
});
|
|
5062
|
+
afterAll(async () => {
|
|
5063
|
+
if (engine) await engine.destroy();
|
|
5064
|
+
});
|
|
5065
|
+
test("snapshot is schema-valid with the exact text, charCount, and charMap", async () => {
|
|
5066
|
+
const doc = await openFixture$2(engine, opts);
|
|
5067
|
+
try {
|
|
5068
|
+
const snap = await doc.page(fixture.pageObjectNumber).text.read();
|
|
5069
|
+
expect(require_schemas.PageTextSnapshotSchema.safeParse(snap).success).toBe(true);
|
|
5070
|
+
expect(snap.text).toBe(fixture.exactText);
|
|
5071
|
+
expect(snap.charCount).toBe(fixture.expectedCharCount);
|
|
5072
|
+
const anchors = snap.charMap ?? null;
|
|
5073
|
+
if (fixture.expectedCharMap === null) expect(anchors === null || anchors.length === 0).toBe(true);
|
|
5074
|
+
else expect(anchors === null ? null : anchors.map((a) => [a[0], a[1]])).toEqual(fixture.expectedCharMap.map((a) => [a[0], a[1]]));
|
|
5075
|
+
} finally {
|
|
5076
|
+
await doc.close();
|
|
5077
|
+
}
|
|
5078
|
+
});
|
|
5079
|
+
test("char-space slicing round-trips through the map", async () => {
|
|
5080
|
+
const doc = await openFixture$2(engine, opts);
|
|
5081
|
+
try {
|
|
5082
|
+
const snap = await doc.page(fixture.pageObjectNumber).text.read();
|
|
5083
|
+
expect(require_charmap.sliceTextByChars(snap, 0, snap.charCount)).toBe(snap.text);
|
|
5084
|
+
for (const s of fixture.slices ?? []) expect(require_charmap.sliceTextByChars(snap, s.from, s.to)).toBe(s.text);
|
|
5085
|
+
} finally {
|
|
5086
|
+
await doc.close();
|
|
5087
|
+
}
|
|
5088
|
+
});
|
|
5089
|
+
if (fixture.search) {
|
|
5090
|
+
const probe = fixture.search;
|
|
5091
|
+
test("search hits address character space and join the text by slicing", async () => {
|
|
5092
|
+
const doc = await openFixture$2(engine, opts);
|
|
5093
|
+
try {
|
|
5094
|
+
const hit = (await doc.search.query({
|
|
5095
|
+
query: { text: probe.query },
|
|
5096
|
+
mode: "rects"
|
|
5097
|
+
})).matches.find((m) => m.pageObjectNumber === fixture.pageObjectNumber);
|
|
5098
|
+
expect(hit === void 0).toBe(false);
|
|
5099
|
+
expect(hit.charStart).toBe(probe.charStart);
|
|
5100
|
+
expect(hit.charCount).toBe(probe.charCount);
|
|
5101
|
+
expect(hit.segments.length > 0).toBe(true);
|
|
5102
|
+
const snap = await doc.page(fixture.pageObjectNumber).text.read();
|
|
5103
|
+
expect(require_charmap.sliceTextByChars(snap, hit.charStart, hit.charStart + hit.charCount)).toBe(probe.matchedText);
|
|
5104
|
+
} finally {
|
|
5105
|
+
await doc.close();
|
|
5106
|
+
}
|
|
5107
|
+
});
|
|
5108
|
+
}
|
|
5109
|
+
});
|
|
5110
|
+
}
|
|
5111
|
+
async function openFixture$2(engine, opts) {
|
|
5112
|
+
if (opts.openKind === "bytes") {
|
|
5113
|
+
const bytes = await opts.fixture.bytes();
|
|
5114
|
+
return engine.open({
|
|
5115
|
+
kind: "bytes",
|
|
5116
|
+
id: opts.fixture.id,
|
|
5117
|
+
bytes
|
|
5118
|
+
});
|
|
5119
|
+
}
|
|
5120
|
+
return engine.open({
|
|
5121
|
+
kind: "id",
|
|
5122
|
+
id: opts.fixture.cloudId ?? opts.fixture.id
|
|
5123
|
+
});
|
|
5124
|
+
}
|
|
5125
|
+
/**
|
|
5126
|
+
* THE pinned divergence cases — one table, consumed by both engines' suites
|
|
5127
|
+
* so expected values cannot drift. Values verified against the wasm runtime
|
|
5128
|
+
* (see each case). All fixtures are single-page; the page's indirect object
|
|
5129
|
+
* number is 3 in each.
|
|
5130
|
+
*/
|
|
5131
|
+
const TEXT_DIVERGENCE_CASES = {
|
|
5132
|
+
/** Leading NON-PRINTING character: 31 character slots, 30 text units —
|
|
5133
|
+
* every text offset shifts by one, encoded by the single anchor [1, 0].
|
|
5134
|
+
* The searchex embeddertest for this fixture pins the same +1 shift. */
|
|
5135
|
+
bug1139: {
|
|
5136
|
+
resource: "bug_1139.pdf",
|
|
5137
|
+
pageObjectNumber: 3,
|
|
5138
|
+
exactText: "Hello, world!\r\nGoodbye, world!",
|
|
5139
|
+
expectedCharCount: 31,
|
|
5140
|
+
expectedCharMap: [[1, 0]],
|
|
5141
|
+
slices: [
|
|
5142
|
+
{
|
|
5143
|
+
from: 0,
|
|
5144
|
+
to: 1,
|
|
5145
|
+
text: ""
|
|
5146
|
+
},
|
|
5147
|
+
{
|
|
5148
|
+
from: 1,
|
|
5149
|
+
to: 7,
|
|
5150
|
+
text: "Hello,"
|
|
5151
|
+
},
|
|
5152
|
+
{
|
|
5153
|
+
from: 16,
|
|
5154
|
+
to: 23,
|
|
5155
|
+
text: "Goodbye"
|
|
5156
|
+
}
|
|
5157
|
+
],
|
|
5158
|
+
search: {
|
|
5159
|
+
query: "Goodbye",
|
|
5160
|
+
charStart: 16,
|
|
5161
|
+
charCount: 7,
|
|
5162
|
+
matchedText: "Goodbye"
|
|
5163
|
+
}
|
|
5164
|
+
},
|
|
5165
|
+
/** `/ActualText` replacement: the span's real glyphs are REPLACED by one
|
|
5166
|
+
* synthetic kPiece character per ActualText character, lockstep with the
|
|
5167
|
+
* text (identity map), with synthesized evenly-divided boxes — so search
|
|
5168
|
+
* segments exist and extraction yields the ActualText, not the glyphs. */
|
|
5169
|
+
actualText: {
|
|
5170
|
+
resource: "bug_384770169.pdf",
|
|
5171
|
+
pageObjectNumber: 3,
|
|
5172
|
+
exactText: "What is my favorite food?",
|
|
5173
|
+
expectedCharCount: 25,
|
|
5174
|
+
expectedCharMap: null,
|
|
5175
|
+
slices: [{
|
|
5176
|
+
from: 11,
|
|
5177
|
+
to: 19,
|
|
5178
|
+
text: "favorite"
|
|
5179
|
+
}],
|
|
5180
|
+
search: {
|
|
5181
|
+
query: "favorite",
|
|
5182
|
+
charStart: 11,
|
|
5183
|
+
charCount: 8,
|
|
5184
|
+
matchedText: "favorite"
|
|
5185
|
+
}
|
|
5186
|
+
},
|
|
5187
|
+
/** Supplementary-plane text via a ToUnicode surrogate pair: PDFium stores
|
|
5188
|
+
* one character-list entry PER SURROGATE HALF in lockstep with the text
|
|
5189
|
+
* (identity map, no divergence in this representation) — and the emoji
|
|
5190
|
+
* SURVIVES extraction end to end. The combined-astral representation
|
|
5191
|
+
* (font-cmap path, one entry per code point → a [+2] anchor) is covered
|
|
5192
|
+
* by the charmap unit tests and the reader's divergent walk. */
|
|
5193
|
+
astralToUnicode: {
|
|
5194
|
+
resource: "embedpdf_astral_tounicode.pdf",
|
|
5195
|
+
pageObjectNumber: 3,
|
|
5196
|
+
exactText: "😀B!",
|
|
5197
|
+
expectedCharCount: 4,
|
|
5198
|
+
expectedCharMap: null,
|
|
5199
|
+
slices: [{
|
|
5200
|
+
from: 0,
|
|
5201
|
+
to: 2,
|
|
5202
|
+
text: "😀"
|
|
5203
|
+
}, {
|
|
5204
|
+
from: 2,
|
|
5205
|
+
to: 3,
|
|
5206
|
+
text: "B"
|
|
5207
|
+
}],
|
|
5208
|
+
search: {
|
|
5209
|
+
query: "B!",
|
|
5210
|
+
charStart: 2,
|
|
5211
|
+
charCount: 2,
|
|
5212
|
+
matchedText: "B!"
|
|
5213
|
+
}
|
|
5214
|
+
}
|
|
5215
|
+
};
|
|
5216
|
+
//#endregion
|
|
5217
|
+
//#region src/conformance/runPageGeometryOrientationConformance.ts
|
|
5218
|
+
const FLAG_EMPTY = 2;
|
|
5219
|
+
/** Absolute tolerance for coordinate assertions (PDF points). */
|
|
5220
|
+
const COORD_TOLERANCE = .001;
|
|
5221
|
+
/** Tolerance for baseline-angle assertions (radians). */
|
|
5222
|
+
const ANGLE_TOLERANCE = .001;
|
|
5223
|
+
function runPageGeometryOrientationConformance(runner, opts) {
|
|
5224
|
+
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
5225
|
+
describe(`page geometry orientation conformance: ${opts.label} [${opts.fixture.id}]`, () => {
|
|
5226
|
+
let engine;
|
|
5227
|
+
beforeAll(async () => {
|
|
5228
|
+
engine = await opts.makeEngine();
|
|
5229
|
+
});
|
|
5230
|
+
afterAll(async () => {
|
|
5231
|
+
if (engine) await engine.destroy();
|
|
5232
|
+
});
|
|
5233
|
+
const readSnapshot = async () => {
|
|
5234
|
+
const doc = await openFixture$1(engine, opts);
|
|
5235
|
+
return {
|
|
5236
|
+
snapshot: await doc.page(opts.fixture.pageObjectNumber).geometry.read(),
|
|
5237
|
+
close: () => doc.close()
|
|
5238
|
+
};
|
|
5239
|
+
};
|
|
5240
|
+
test("snapshot round-trips the wire schema", async () => {
|
|
5241
|
+
const { snapshot, close } = await readSnapshot();
|
|
5242
|
+
try {
|
|
5243
|
+
const parsed = require_schemas.PageGeometrySnapshotSchema.safeParse(snapshot);
|
|
5244
|
+
expect(parsed.success).toBe(true);
|
|
5245
|
+
if (parsed.success) expect(parsed.data).toEqual(snapshot);
|
|
5246
|
+
} finally {
|
|
5247
|
+
await close();
|
|
5248
|
+
}
|
|
5249
|
+
});
|
|
5250
|
+
test("run charStart indices tile the page glyph sequence", async () => {
|
|
5251
|
+
const { snapshot, close } = await readSnapshot();
|
|
5252
|
+
try {
|
|
5253
|
+
let next = 0;
|
|
5254
|
+
for (const run of snapshot.runs) {
|
|
5255
|
+
expect(run.charStart).toBe(next);
|
|
5256
|
+
next += run.glyphs.length;
|
|
5257
|
+
}
|
|
5258
|
+
} finally {
|
|
5259
|
+
await close();
|
|
5260
|
+
}
|
|
5261
|
+
});
|
|
5262
|
+
test("runs match the fixture orientation expectation", async () => {
|
|
5263
|
+
const { snapshot, close } = await readSnapshot();
|
|
5264
|
+
try {
|
|
5265
|
+
const expectation = opts.fixture.expectation;
|
|
5266
|
+
if (expectation.kind === "upright") {
|
|
5267
|
+
for (const run of snapshot.runs) {
|
|
5268
|
+
expect(require_fold.isRotatedGeometryRun(run)).toBe(false);
|
|
5269
|
+
if (require_fold.isRotatedGeometryRun(run)) continue;
|
|
5270
|
+
for (const glyph of run.glyphs) {
|
|
5271
|
+
expect("looseQuad" in glyph).toBe(false);
|
|
5272
|
+
if (glyph.flags & FLAG_EMPTY) expect(glyph.looseBox).toEqual({
|
|
5273
|
+
left: 0,
|
|
5274
|
+
bottom: 0,
|
|
5275
|
+
right: 0,
|
|
5276
|
+
top: 0
|
|
5277
|
+
});
|
|
5278
|
+
}
|
|
5279
|
+
}
|
|
5280
|
+
return;
|
|
5281
|
+
}
|
|
5282
|
+
if (expectation.kind === "empty-only") {
|
|
5283
|
+
for (const run of snapshot.runs) {
|
|
5284
|
+
expect(require_fold.isRotatedGeometryRun(run)).toBe(false);
|
|
5285
|
+
if (require_fold.isRotatedGeometryRun(run)) continue;
|
|
5286
|
+
for (const glyph of run.glyphs) {
|
|
5287
|
+
expect(glyph.flags & FLAG_EMPTY).toBe(FLAG_EMPTY);
|
|
5288
|
+
expect(glyph.looseBox).toEqual({
|
|
5289
|
+
left: 0,
|
|
5290
|
+
bottom: 0,
|
|
5291
|
+
right: 0,
|
|
5292
|
+
top: 0
|
|
5293
|
+
});
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
return;
|
|
5297
|
+
}
|
|
5298
|
+
const rotatedRuns = snapshot.runs.filter(require_fold.isRotatedGeometryRun);
|
|
5299
|
+
expect(rotatedRuns.length >= (expectation.minRotatedRuns ?? 1)).toBe(true);
|
|
5300
|
+
for (const run of rotatedRuns) {
|
|
5301
|
+
expect(expectation.rotations.some((angle) => angleClose(run.rotation, angle, ANGLE_TOLERANCE))).toBe(true);
|
|
5302
|
+
expect(run.ascentFlip).toBe(expectation.ascentFlip);
|
|
5303
|
+
assertRotatedRunGeometry(run);
|
|
5304
|
+
}
|
|
5305
|
+
if (expectation.sheared) {
|
|
5306
|
+
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);
|
|
5307
|
+
expect(shearedGlyphs.length > 0).toBe(true);
|
|
5308
|
+
}
|
|
5309
|
+
} finally {
|
|
5310
|
+
await close();
|
|
5311
|
+
}
|
|
5035
5312
|
});
|
|
5313
|
+
function assertRotatedRunGeometry(run) {
|
|
5314
|
+
for (const glyph of run.glyphs) {
|
|
5315
|
+
if (glyph.flags & FLAG_EMPTY) {
|
|
5316
|
+
expect(glyph.looseQuad).toEqual({
|
|
5317
|
+
p1: {
|
|
5318
|
+
x: 0,
|
|
5319
|
+
y: 0
|
|
5320
|
+
},
|
|
5321
|
+
p2: {
|
|
5322
|
+
x: 0,
|
|
5323
|
+
y: 0
|
|
5324
|
+
},
|
|
5325
|
+
p3: {
|
|
5326
|
+
x: 0,
|
|
5327
|
+
y: 0
|
|
5328
|
+
},
|
|
5329
|
+
p4: {
|
|
5330
|
+
x: 0,
|
|
5331
|
+
y: 0
|
|
5332
|
+
}
|
|
5333
|
+
});
|
|
5334
|
+
continue;
|
|
5335
|
+
}
|
|
5336
|
+
const q = glyph.looseQuad;
|
|
5337
|
+
expect(Math.abs(q.p2.x - q.p1.x - (q.p4.x - q.p3.x)) <= COORD_TOLERANCE).toBe(true);
|
|
5338
|
+
expect(Math.abs(q.p2.y - q.p1.y - (q.p4.y - q.p3.y)) <= COORD_TOLERANCE).toBe(true);
|
|
5339
|
+
const bounds = require_fold.pdfQuadBounds(q);
|
|
5340
|
+
expect(bounds.left >= run.rect.left - COORD_TOLERANCE).toBe(true);
|
|
5341
|
+
expect(bounds.right <= run.rect.right + COORD_TOLERANCE).toBe(true);
|
|
5342
|
+
expect(bounds.bottom >= run.rect.bottom - COORD_TOLERANCE).toBe(true);
|
|
5343
|
+
expect(bounds.top <= run.rect.top + COORD_TOLERANCE).toBe(true);
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5036
5346
|
});
|
|
5037
5347
|
}
|
|
5348
|
+
function angleClose(a, b, tolerance) {
|
|
5349
|
+
const delta = a - b;
|
|
5350
|
+
return Math.abs(Math.atan2(Math.sin(delta), Math.cos(delta))) <= tolerance;
|
|
5351
|
+
}
|
|
5038
5352
|
async function openFixture$1(engine, opts) {
|
|
5039
5353
|
if (opts.openKind === "bytes") {
|
|
5040
5354
|
const bytes = await opts.fixture.bytes();
|
|
@@ -5090,10 +5404,27 @@ function runSearchConformance(runner, opts) {
|
|
|
5090
5404
|
expect(matches.some((m) => m.pageObjectNumber === fixture.presentPageObjectNumber)).toBe(true);
|
|
5091
5405
|
for (const m of matches) {
|
|
5092
5406
|
expect(m.charCount > 0).toBe(true);
|
|
5093
|
-
expect(m.
|
|
5094
|
-
for (const
|
|
5095
|
-
expect(
|
|
5096
|
-
expect(
|
|
5407
|
+
expect(m.segments.length > 0).toBe(true);
|
|
5408
|
+
for (const s of m.segments) {
|
|
5409
|
+
expect(s.rect.right > s.rect.left).toBe(true);
|
|
5410
|
+
expect(s.rect.top > s.rect.bottom).toBe(true);
|
|
5411
|
+
const xs = [
|
|
5412
|
+
s.quad.p1.x,
|
|
5413
|
+
s.quad.p2.x,
|
|
5414
|
+
s.quad.p3.x,
|
|
5415
|
+
s.quad.p4.x
|
|
5416
|
+
];
|
|
5417
|
+
const ys = [
|
|
5418
|
+
s.quad.p1.y,
|
|
5419
|
+
s.quad.p2.y,
|
|
5420
|
+
s.quad.p3.y,
|
|
5421
|
+
s.quad.p4.y
|
|
5422
|
+
];
|
|
5423
|
+
expect(Math.abs(s.rect.left - Math.min(...xs)) < .001).toBe(true);
|
|
5424
|
+
expect(Math.abs(s.rect.right - Math.max(...xs)) < .001).toBe(true);
|
|
5425
|
+
expect(Math.abs(s.rect.bottom - Math.min(...ys)) < .001).toBe(true);
|
|
5426
|
+
expect(Math.abs(s.rect.top - Math.max(...ys)) < .001).toBe(true);
|
|
5427
|
+
expect(s.advance === 1 || s.advance === -1).toBe(true);
|
|
5097
5428
|
}
|
|
5098
5429
|
}
|
|
5099
5430
|
} finally {
|
|
@@ -5193,7 +5524,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5193
5524
|
} catch (err) {
|
|
5194
5525
|
caught = err;
|
|
5195
5526
|
}
|
|
5196
|
-
expect(require_fold.EngineError.is(caught,
|
|
5527
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5197
5528
|
} finally {
|
|
5198
5529
|
await doc.close();
|
|
5199
5530
|
}
|
|
@@ -5210,7 +5541,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5210
5541
|
} catch (err) {
|
|
5211
5542
|
caught = err;
|
|
5212
5543
|
}
|
|
5213
|
-
expect(require_fold.EngineError.is(caught,
|
|
5544
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5214
5545
|
} finally {
|
|
5215
5546
|
await doc.close();
|
|
5216
5547
|
}
|
|
@@ -5225,7 +5556,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5225
5556
|
expect(matches.length > 0).toBe(true);
|
|
5226
5557
|
for (const m of matches) {
|
|
5227
5558
|
expect(m.charCount > 0).toBe(true);
|
|
5228
|
-
expect(m.
|
|
5559
|
+
expect(m.segments.length > 0).toBe(true);
|
|
5229
5560
|
}
|
|
5230
5561
|
} finally {
|
|
5231
5562
|
await doc.close();
|
|
@@ -5266,7 +5597,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5266
5597
|
} catch (err) {
|
|
5267
5598
|
caught = err;
|
|
5268
5599
|
}
|
|
5269
|
-
expect(require_fold.EngineError.is(caught,
|
|
5600
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5270
5601
|
} finally {
|
|
5271
5602
|
await doc.close();
|
|
5272
5603
|
}
|
|
@@ -5288,7 +5619,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5288
5619
|
} catch (err) {
|
|
5289
5620
|
caught = err;
|
|
5290
5621
|
}
|
|
5291
|
-
expect(require_fold.EngineError.is(caught,
|
|
5622
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5292
5623
|
}
|
|
5293
5624
|
} finally {
|
|
5294
5625
|
await doc.close();
|
|
@@ -5323,7 +5654,7 @@ function runSearchConformance(runner, opts) {
|
|
|
5323
5654
|
} catch (err) {
|
|
5324
5655
|
caught = err;
|
|
5325
5656
|
}
|
|
5326
|
-
expect(require_fold.EngineError.is(caught,
|
|
5657
|
+
expect(require_fold.EngineError.is(caught, require_charmap.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
5327
5658
|
});
|
|
5328
5659
|
});
|
|
5329
5660
|
}
|
|
@@ -5390,6 +5721,7 @@ function diffAnnotation(i, a, b, errs) {
|
|
|
5390
5721
|
if (a.nm !== b.nm) errs.push(`annotations[${i}].nm mismatch: ${a.nm} vs ${b.nm}`);
|
|
5391
5722
|
}
|
|
5392
5723
|
//#endregion
|
|
5724
|
+
exports.TEXT_DIVERGENCE_CASES = TEXT_DIVERGENCE_CASES;
|
|
5393
5725
|
exports.diffAnnotationListSnapshot = diffAnnotationListSnapshot;
|
|
5394
5726
|
exports.diffAnnotationListSnapshotAll = diffAnnotationListSnapshotAll;
|
|
5395
5727
|
exports.runActionsConformance = runActionsConformance;
|
|
@@ -5403,6 +5735,7 @@ exports.runMetadataConformance = runMetadataConformance;
|
|
|
5403
5735
|
exports.runPageDeleteConformance = runPageDeleteConformance;
|
|
5404
5736
|
exports.runPageExtractConformance = runPageExtractConformance;
|
|
5405
5737
|
exports.runPageFlattenConformance = runPageFlattenConformance;
|
|
5738
|
+
exports.runPageGeometryOrientationConformance = runPageGeometryOrientationConformance;
|
|
5406
5739
|
exports.runPageInsertConformance = runPageInsertConformance;
|
|
5407
5740
|
exports.runPageReorderConformance = runPageReorderConformance;
|
|
5408
5741
|
exports.runPageRotateConformance = runPageRotateConformance;
|
|
@@ -5410,5 +5743,6 @@ exports.runPageTextConformance = runPageTextConformance;
|
|
|
5410
5743
|
exports.runPieceInfoConformance = runPieceInfoConformance;
|
|
5411
5744
|
exports.runRedactionApplyConformance = runRedactionApplyConformance;
|
|
5412
5745
|
exports.runSearchConformance = runSearchConformance;
|
|
5746
|
+
exports.runTextDivergenceConformance = runTextDivergenceConformance;
|
|
5413
5747
|
|
|
5414
5748
|
//# sourceMappingURL=conformance.cjs.map
|