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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{AnnotationListSnapshot-C1U3XUxP.d.cts → AnnotationListSnapshot-x6tKulNV.d.cts} +153 -28
  2. package/dist/{AnnotationListSnapshot-C1U3XUxP.d.ts → AnnotationListSnapshot-x6tKulNV.d.ts} +153 -28
  3. package/dist/{DocumentSecurityService-7nL9aY75.d.ts → DocumentSecurityService-9MawYxP-.d.ts} +2 -2
  4. package/dist/{DocumentSecurityService-6rhztZlz.d.cts → DocumentSecurityService-CK0pejAK.d.cts} +2 -2
  5. package/dist/{Engine-D3868xIU.d.cts → Engine--0XF0UAK.d.cts} +56 -3
  6. package/dist/{Engine-CWnAKccD.d.ts → Engine-Ds0ytbl6.d.ts} +56 -3
  7. package/dist/{builders-Do6_4KnS.cjs → builders-8Hl1AYNU.cjs} +14 -8
  8. package/dist/builders-8Hl1AYNU.cjs.map +1 -0
  9. package/dist/{builders-Cdz34nbF.js → builders-DOjcKDWQ.js} +14 -8
  10. package/dist/builders-DOjcKDWQ.js.map +1 -0
  11. package/dist/conformance.cjs +552 -95
  12. package/dist/conformance.cjs.map +1 -1
  13. package/dist/conformance.d.cts +50 -3
  14. package/dist/conformance.d.ts +50 -3
  15. package/dist/conformance.js +550 -96
  16. package/dist/conformance.js.map +1 -1
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +1 -1
  21. package/dist/runtime.cjs +1 -1
  22. package/dist/runtime.d.cts +66 -5
  23. package/dist/runtime.d.ts +66 -5
  24. package/dist/runtime.js +1 -1
  25. package/dist/{schemas-XGrNVMDd.js → schemas-DOyVEPk7.js} +51 -5
  26. package/dist/schemas-DOyVEPk7.js.map +1 -0
  27. package/dist/{schemas-CS5iPpX5.cjs → schemas-RChsAMWw.cjs} +92 -4
  28. package/dist/schemas-RChsAMWw.cjs.map +1 -0
  29. package/dist/wire.cjs +23 -1
  30. package/dist/wire.cjs.map +1 -1
  31. package/dist/wire.d.cts +32 -3
  32. package/dist/wire.d.ts +32 -3
  33. package/dist/wire.js +17 -2
  34. package/dist/wire.js.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/builders-Cdz34nbF.js.map +0 -1
  37. package/dist/builders-Do6_4KnS.cjs.map +0 -1
  38. package/dist/schemas-CS5iPpX5.cjs.map +0 -1
  39. package/dist/schemas-XGrNVMDd.js.map +0 -1
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_fold = require("./fold-C7I5GpBz.cjs");
3
3
  const require_PageInsertBlankInput = require("./PageInsertBlankInput-CzShuSJI.cjs");
4
4
  const require_AbortError = require("./AbortError-CRSooKsk.cjs");
5
- const require_schemas = require("./schemas-CS5iPpX5.cjs");
5
+ const require_schemas = require("./schemas-RChsAMWw.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$17(engine, opts);
22
+ const doc = await openFixture$20(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$17(engine, opts);
32
+ const doc = await openFixture$20(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$17(engine, opts);
42
+ const doc = await openFixture$20(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$17(engine, opts);
54
+ const doc = await openFixture$20(engine, opts);
55
55
  await doc.close();
56
56
  let caught;
57
57
  try {
@@ -63,7 +63,7 @@ function runMetadataConformance(runner, opts) {
63
63
  expect(require_fold.EngineError.is(caught, require_PageInsertBlankInput.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$17(engine, opts);
66
+ const doc = await openFixture$20(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$17(engine, opts);
85
+ const doc = await openFixture$20(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$17(engine, opts);
98
+ const doc = await openFixture$20(engine, opts);
99
99
  await doc.close();
100
100
  let caught;
101
101
  try {
@@ -108,7 +108,7 @@ function runMetadataConformance(runner, opts) {
108
108
  });
109
109
  });
110
110
  }
111
- async function openFixture$17(engine, opts) {
111
+ async function openFixture$20(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$16(engine, opts);
138
+ const doc = await openFixture$19(engine, opts);
139
139
  try {
140
140
  const snap = await doc.annotations.listRawAll();
141
141
  expect(require_schemas.AnnotationListSnapshotAllPagesSchema.safeParse(snap).success).toBe(true);
@@ -149,7 +149,7 @@ function runAnnotationReadConformance(runner, opts) {
149
149
  }
150
150
  });
151
151
  test("listRaw on the test page returns the expected counts and DTO shape", async () => {
152
- const doc = await openFixture$16(engine, opts);
152
+ const doc = await openFixture$19(engine, opts);
153
153
  try {
154
154
  const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
155
155
  expect(require_schemas.AnnotationListPageSnapshotSchema.safeParse(snap).success).toBe(true);
@@ -179,7 +179,7 @@ function runAnnotationReadConformance(runner, opts) {
179
179
  }
180
180
  });
181
181
  test("shape/vertex/line annotations expose their family fields", async () => {
182
- const doc = await openFixture$16(engine, opts);
182
+ const doc = await openFixture$19(engine, opts);
183
183
  try {
184
184
  const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
185
185
  for (const a of snap.annotations) {
@@ -238,7 +238,7 @@ function runAnnotationReadConformance(runner, opts) {
238
238
  }
239
239
  });
240
240
  test("full page list dispatches per-subtype and matches raw counts", async () => {
241
- const doc = await openFixture$16(engine, opts);
241
+ const doc = await openFixture$19(engine, opts);
242
242
  try {
243
243
  const full = await doc.page(opts.fixture.pageObjectNumber).annotations.list();
244
244
  expect(require_schemas.AnnotationListPageSnapshotSchema.safeParse(full).success).toBe(true);
@@ -248,7 +248,7 @@ function runAnnotationReadConformance(runner, opts) {
248
248
  }
249
249
  });
250
250
  test("every annotation DTO satisfies AnnotationDTOSchema (discriminated union)", async () => {
251
- const doc = await openFixture$16(engine, opts);
251
+ const doc = await openFixture$19(engine, opts);
252
252
  try {
253
253
  const snap = await doc.annotations.listRaw(opts.fixture.pageObjectNumber);
254
254
  for (const a of snap.annotations) {
@@ -288,7 +288,7 @@ function runAnnotationReadConformance(runner, opts) {
288
288
  });
289
289
  if (opts.fixture.expectsWeakAnnotation) {
290
290
  test("weak annotations carry identityQuality: weak and ref.kind: index", async () => {
291
- const doc = await openFixture$16(engine, opts);
291
+ const doc = await openFixture$19(engine, opts);
292
292
  try {
293
293
  const weak = (await doc.annotations.listRaw(opts.fixture.pageObjectNumber)).annotations.find((a) => a.identityQuality === "weak");
294
294
  expect(weak !== void 0).toBe(true);
@@ -298,7 +298,7 @@ function runAnnotationReadConformance(runner, opts) {
298
298
  }
299
299
  });
300
300
  test("a stale revision token throws InvalidReference", async () => {
301
- const doc = await openFixture$16(engine, opts);
301
+ const doc = await openFixture$19(engine, opts);
302
302
  try {
303
303
  const snap = await doc.page(opts.fixture.pageObjectNumber).annotations.list();
304
304
  const weak = snap.annotations.find((a) => a.identityQuality === "weak");
@@ -314,7 +314,7 @@ function runAnnotationReadConformance(runner, opts) {
314
314
  });
315
315
  }
316
316
  test("abort() on listRaw rejects with AbortError", async () => {
317
- const doc = await openFixture$16(engine, opts);
317
+ const doc = await openFixture$19(engine, opts);
318
318
  try {
319
319
  const p = doc.annotations.listRaw(opts.fixture.pageObjectNumber);
320
320
  p.abort("test");
@@ -324,7 +324,7 @@ function runAnnotationReadConformance(runner, opts) {
324
324
  }
325
325
  });
326
326
  test("listRaw on an unknown pageObjectNumber throws NotFound", async () => {
327
- const doc = await openFixture$16(engine, opts);
327
+ const doc = await openFixture$19(engine, opts);
328
328
  try {
329
329
  let caught;
330
330
  try {
@@ -340,7 +340,7 @@ function runAnnotationReadConformance(runner, opts) {
340
340
  });
341
341
  });
342
342
  }
343
- async function openFixture$16(engine, opts) {
343
+ async function openFixture$19(engine, opts) {
344
344
  if (opts.openKind === "bytes") {
345
345
  const bytes = await opts.fixture.bytes();
346
346
  return engine.open({
@@ -809,7 +809,7 @@ function runAnnotationMutationConformance(runner, opts) {
809
809
  if (engine) await engine.destroy();
810
810
  });
811
811
  test("create appends without shifting indices and leaves weak refs valid", async () => {
812
- const doc = await openFixture$15(engine, opts);
812
+ const doc = await openFixture$18(engine, opts);
813
813
  try {
814
814
  const page = doc.page(fix.pageObjectNumber);
815
815
  const before = await page.annotations.list();
@@ -845,7 +845,7 @@ function runAnnotationMutationConformance(runner, opts) {
845
845
  }
846
846
  });
847
847
  test("create + update honor annotation flags (set on create, merge on patch)", async () => {
848
- const doc = await openFixture$15(engine, opts);
848
+ const doc = await openFixture$18(engine, opts);
849
849
  try {
850
850
  const page = doc.page(fix.pageObjectNumber);
851
851
  const draft = {
@@ -880,7 +880,7 @@ function runAnnotationMutationConformance(runner, opts) {
880
880
  }
881
881
  });
882
882
  test("create shape annotations (circle + square) round-trip shape fields", async () => {
883
- const doc = await openFixture$15(engine, opts);
883
+ const doc = await openFixture$18(engine, opts);
884
884
  try {
885
885
  const page = doc.page(fix.pageObjectNumber);
886
886
  const circleDraft = {
@@ -961,7 +961,7 @@ function runAnnotationMutationConformance(runner, opts) {
961
961
  }
962
962
  });
963
963
  test("cloudy border (/BE) + rect differences (/RD) are tri-state", async () => {
964
- const doc = await openFixture$15(engine, opts);
964
+ const doc = await openFixture$18(engine, opts);
965
965
  try {
966
966
  const page = doc.page(fix.pageObjectNumber);
967
967
  const plainDraft = {
@@ -1040,7 +1040,7 @@ function runAnnotationMutationConformance(runner, opts) {
1040
1040
  }
1041
1041
  });
1042
1042
  test("update echoes the appearance verdict: moves preserve /AP, restyles re-bake", async () => {
1043
- const doc = await openFixture$15(engine, opts);
1043
+ const doc = await openFixture$18(engine, opts);
1044
1044
  try {
1045
1045
  const page = doc.page(fix.pageObjectNumber);
1046
1046
  const draft = {
@@ -1115,7 +1115,7 @@ function runAnnotationMutationConformance(runner, opts) {
1115
1115
  }
1116
1116
  });
1117
1117
  test("a partial /DA patch preserves the unpatched font members", async () => {
1118
- const doc = await openFixture$15(engine, opts);
1118
+ const doc = await openFixture$18(engine, opts);
1119
1119
  try {
1120
1120
  const page = doc.page(fix.pageObjectNumber);
1121
1121
  const draft = {
@@ -1171,7 +1171,7 @@ function runAnnotationMutationConformance(runner, opts) {
1171
1171
  }
1172
1172
  });
1173
1173
  test("box transform is tri-state: rect-only moves keep rotation, null flattens", async () => {
1174
- const doc = await openFixture$15(engine, opts);
1174
+ const doc = await openFixture$18(engine, opts);
1175
1175
  try {
1176
1176
  const page = doc.page(fix.pageObjectNumber);
1177
1177
  const draft = {
@@ -1232,7 +1232,7 @@ function runAnnotationMutationConformance(runner, opts) {
1232
1232
  }
1233
1233
  });
1234
1234
  test("create vertex + line annotations (polygon/polyline/line) round-trip geometry", async () => {
1235
- const doc = await openFixture$15(engine, opts);
1235
+ const doc = await openFixture$18(engine, opts);
1236
1236
  try {
1237
1237
  const page = doc.page(fix.pageObjectNumber);
1238
1238
  const polygonDraft = {
@@ -1363,7 +1363,7 @@ function runAnnotationMutationConformance(runner, opts) {
1363
1363
  }
1364
1364
  });
1365
1365
  test("create free-text + callout round-trip text/colour/intent fields", async () => {
1366
- const doc = await openFixture$15(engine, opts);
1366
+ const doc = await openFixture$18(engine, opts);
1367
1367
  try {
1368
1368
  const page = doc.page(fix.pageObjectNumber);
1369
1369
  const freeTextDraft = {
@@ -1459,7 +1459,7 @@ function runAnnotationMutationConformance(runner, opts) {
1459
1459
  }
1460
1460
  });
1461
1461
  test("update a free-text patches alignment + colours and is non-structural", async () => {
1462
- const doc = await openFixture$15(engine, opts);
1462
+ const doc = await openFixture$18(engine, opts);
1463
1463
  try {
1464
1464
  const page = doc.page(fix.pageObjectNumber);
1465
1465
  const created = await page.annotations.create({
@@ -1520,7 +1520,7 @@ function runAnnotationMutationConformance(runner, opts) {
1520
1520
  }
1521
1521
  });
1522
1522
  test("create redact (area + text) round-trips label + colour fields", async () => {
1523
- const doc = await openFixture$15(engine, opts);
1523
+ const doc = await openFixture$18(engine, opts);
1524
1524
  try {
1525
1525
  const page = doc.page(fix.pageObjectNumber);
1526
1526
  const areaDraft = {
@@ -1600,7 +1600,7 @@ function runAnnotationMutationConformance(runner, opts) {
1600
1600
  }
1601
1601
  });
1602
1602
  test("update a redact patches the label and clears it, non-structurally", async () => {
1603
- const doc = await openFixture$15(engine, opts);
1603
+ const doc = await openFixture$18(engine, opts);
1604
1604
  try {
1605
1605
  const page = doc.page(fix.pageObjectNumber);
1606
1606
  const created = await page.annotations.create({
@@ -1677,7 +1677,7 @@ function runAnnotationMutationConformance(runner, opts) {
1677
1677
  }
1678
1678
  });
1679
1679
  test("create + update a caret round-trips color/opacity/rect differences", async () => {
1680
- const doc = await openFixture$15(engine, opts);
1680
+ const doc = await openFixture$18(engine, opts);
1681
1681
  try {
1682
1682
  const page = doc.page(fix.pageObjectNumber);
1683
1683
  const caretDraft = {
@@ -1757,7 +1757,7 @@ function runAnnotationMutationConformance(runner, opts) {
1757
1757
  }
1758
1758
  });
1759
1759
  test("update an ink annotation patches strokes + color and is non-structural", async () => {
1760
- const doc = await openFixture$15(engine, opts);
1760
+ const doc = await openFixture$18(engine, opts);
1761
1761
  try {
1762
1762
  const page = doc.page(fix.pageObjectNumber);
1763
1763
  const created = await page.annotations.create({
@@ -1808,7 +1808,7 @@ function runAnnotationMutationConformance(runner, opts) {
1808
1808
  }
1809
1809
  });
1810
1810
  test("ink highlight intent + blend round-trip and unrelated patches preserve blend", async () => {
1811
- const doc = await openFixture$15(engine, opts);
1811
+ const doc = await openFixture$18(engine, opts);
1812
1812
  try {
1813
1813
  const page = doc.page(fix.pageObjectNumber);
1814
1814
  const created = await page.annotations.create({
@@ -1851,7 +1851,7 @@ function runAnnotationMutationConformance(runner, opts) {
1851
1851
  }
1852
1852
  });
1853
1853
  test("update a polyline patches vertices + line endings and is non-structural", async () => {
1854
- const doc = await openFixture$15(engine, opts);
1854
+ const doc = await openFixture$18(engine, opts);
1855
1855
  try {
1856
1856
  const page = doc.page(fix.pageObjectNumber);
1857
1857
  const created = await page.annotations.create({
@@ -1900,7 +1900,7 @@ function runAnnotationMutationConformance(runner, opts) {
1900
1900
  }
1901
1901
  });
1902
1902
  test("update a shape annotation patches color and is non-structural", async () => {
1903
- const doc = await openFixture$15(engine, opts);
1903
+ const doc = await openFixture$18(engine, opts);
1904
1904
  try {
1905
1905
  const page = doc.page(fix.pageObjectNumber);
1906
1906
  const created = await page.annotations.create({
@@ -1949,7 +1949,7 @@ function runAnnotationMutationConformance(runner, opts) {
1949
1949
  }
1950
1950
  });
1951
1951
  if (opts.supportsAppearanceRasters) test("creating a shape bakes an /AP appearance the reader can rasterize", async () => {
1952
- const doc = await openFixture$15(engine, opts);
1952
+ const doc = await openFixture$18(engine, opts);
1953
1953
  try {
1954
1954
  const page = doc.page(fix.pageObjectNumber);
1955
1955
  const created = await page.annotations.create({
@@ -1979,7 +1979,7 @@ function runAnnotationMutationConformance(runner, opts) {
1979
1979
  }
1980
1980
  });
1981
1981
  test("update on a durable annotation is non-structural and never touches /NM", async () => {
1982
- const doc = await openFixture$15(engine, opts);
1982
+ const doc = await openFixture$18(engine, opts);
1983
1983
  try {
1984
1984
  const page = doc.page(fix.pageObjectNumber);
1985
1985
  const before = await page.annotations.list();
@@ -2005,7 +2005,7 @@ function runAnnotationMutationConformance(runner, opts) {
2005
2005
  }
2006
2006
  });
2007
2007
  if (fix.expectsWeakAnnotation) test("update on a weak annotation stamps a UUID v4 /NM and upgrades the ref", async () => {
2008
- const doc = await openFixture$15(engine, opts);
2008
+ const doc = await openFixture$18(engine, opts);
2009
2009
  try {
2010
2010
  const page = doc.page(fix.pageObjectNumber);
2011
2011
  const before = await page.annotations.list();
@@ -2035,7 +2035,7 @@ function runAnnotationMutationConformance(runner, opts) {
2035
2035
  }
2036
2036
  });
2037
2037
  test("delete by objectNumber removes the annotation and reports a stable id", async () => {
2038
- const doc = await openFixture$15(engine, opts);
2038
+ const doc = await openFixture$18(engine, opts);
2039
2039
  try {
2040
2040
  const page = doc.page(fix.pageObjectNumber);
2041
2041
  const draft = {
@@ -2065,7 +2065,7 @@ function runAnnotationMutationConformance(runner, opts) {
2065
2065
  }
2066
2066
  });
2067
2067
  if (fix.expectsWeakAnnotation) test("delete by index of a weak annotation reports deleted: null and refetch reason", async () => {
2068
- const doc = await openFixture$15(engine, opts);
2068
+ const doc = await openFixture$18(engine, opts);
2069
2069
  try {
2070
2070
  const page = doc.page(fix.pageObjectNumber);
2071
2071
  const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
@@ -2088,7 +2088,7 @@ function runAnnotationMutationConformance(runner, opts) {
2088
2088
  }
2089
2089
  });
2090
2090
  test("abort on create rejects with AbortError", async () => {
2091
- const doc = await openFixture$15(engine, opts);
2091
+ const doc = await openFixture$18(engine, opts);
2092
2092
  try {
2093
2093
  const page = doc.page(fix.pageObjectNumber);
2094
2094
  const draft = {
@@ -2104,7 +2104,7 @@ function runAnnotationMutationConformance(runner, opts) {
2104
2104
  }
2105
2105
  });
2106
2106
  test("update with a stale index revision throws InvalidReference", async () => {
2107
- const doc = await openFixture$15(engine, opts);
2107
+ const doc = await openFixture$18(engine, opts);
2108
2108
  try {
2109
2109
  const page = doc.page(fix.pageObjectNumber);
2110
2110
  const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
@@ -2131,7 +2131,7 @@ function runAnnotationMutationConformance(runner, opts) {
2131
2131
  }
2132
2132
  });
2133
2133
  test("move single durable annotation reorders within the page (single-as-batch)", async () => {
2134
- const doc = await openFixture$15(engine, opts);
2134
+ const doc = await openFixture$18(engine, opts);
2135
2135
  try {
2136
2136
  const page = doc.page(fix.pageObjectNumber);
2137
2137
  const aDraft = {
@@ -2175,7 +2175,7 @@ function runAnnotationMutationConformance(runner, opts) {
2175
2175
  }
2176
2176
  });
2177
2177
  test("move multi-block preserves caller-supplied order at the destination", async () => {
2178
- const doc = await openFixture$15(engine, opts);
2178
+ const doc = await openFixture$18(engine, opts);
2179
2179
  try {
2180
2180
  const page = doc.page(fix.pageObjectNumber);
2181
2181
  const ids = await Promise.all([
@@ -2214,7 +2214,7 @@ function runAnnotationMutationConformance(runner, opts) {
2214
2214
  }
2215
2215
  });
2216
2216
  if (fix.expectsWeakAnnotation) test("move on a weak annotation upgrades it to durable /NM (one rev bump for batch)", async () => {
2217
- const doc = await openFixture$15(engine, opts);
2217
+ const doc = await openFixture$18(engine, opts);
2218
2218
  try {
2219
2219
  const page = doc.page(fix.pageObjectNumber);
2220
2220
  const before = await page.annotations.list();
@@ -2239,7 +2239,7 @@ function runAnnotationMutationConformance(runner, opts) {
2239
2239
  }
2240
2240
  });
2241
2241
  test("move with a stale index revision rejects (locked rev-token guard)", async () => {
2242
- const doc = await openFixture$15(engine, opts);
2242
+ const doc = await openFixture$18(engine, opts);
2243
2243
  try {
2244
2244
  const page = doc.page(fix.pageObjectNumber);
2245
2245
  const a = await page.annotations.create({
@@ -2277,7 +2277,7 @@ function runAnnotationMutationConformance(runner, opts) {
2277
2277
  }
2278
2278
  });
2279
2279
  test("move with out-of-range toIndex rejects with InvalidArg", async () => {
2280
- const doc = await openFixture$15(engine, opts);
2280
+ const doc = await openFixture$18(engine, opts);
2281
2281
  try {
2282
2282
  const page = doc.page(fix.pageObjectNumber);
2283
2283
  const a = await page.annotations.create({
@@ -2301,7 +2301,7 @@ function runAnnotationMutationConformance(runner, opts) {
2301
2301
  }
2302
2302
  });
2303
2303
  test("move with duplicate refs rejects with InvalidArg", async () => {
2304
- const doc = await openFixture$15(engine, opts);
2304
+ const doc = await openFixture$18(engine, opts);
2305
2305
  try {
2306
2306
  const page = doc.page(fix.pageObjectNumber);
2307
2307
  const a = await page.annotations.create({
@@ -2324,7 +2324,7 @@ function runAnnotationMutationConformance(runner, opts) {
2324
2324
  }
2325
2325
  });
2326
2326
  test("abort on move rejects with AbortError", async () => {
2327
- const doc = await openFixture$15(engine, opts);
2327
+ const doc = await openFixture$18(engine, opts);
2328
2328
  try {
2329
2329
  const page = doc.page(fix.pageObjectNumber);
2330
2330
  const a = await page.annotations.create({
@@ -2345,7 +2345,7 @@ function runAnnotationMutationConformance(runner, opts) {
2345
2345
  }
2346
2346
  });
2347
2347
  test("a page move does NOT bump per-page RevisionTokens (weak refs survive reorder)", async () => {
2348
- const doc = await openFixture$15(engine, opts);
2348
+ const doc = await openFixture$18(engine, opts);
2349
2349
  try {
2350
2350
  const list = await doc.pages.list();
2351
2351
  if (list.pages.length < 1) return;
@@ -2360,7 +2360,7 @@ function runAnnotationMutationConformance(runner, opts) {
2360
2360
  }
2361
2361
  });
2362
2362
  test("create a reply links /IRT and defaults /RT to \"reply\", reporting the parent", async () => {
2363
- const doc = await openFixture$15(engine, opts);
2363
+ const doc = await openFixture$18(engine, opts);
2364
2364
  try {
2365
2365
  const page = doc.page(fix.pageObjectNumber);
2366
2366
  const parent = await page.annotations.create({
@@ -2394,7 +2394,7 @@ function runAnnotationMutationConformance(runner, opts) {
2394
2394
  }
2395
2395
  });
2396
2396
  test("create a grouped subordinate writes /RT /Group", async () => {
2397
- const doc = await openFixture$15(engine, opts);
2397
+ const doc = await openFixture$18(engine, opts);
2398
2398
  try {
2399
2399
  const page = doc.page(fix.pageObjectNumber);
2400
2400
  const primary = await page.annotations.create({
@@ -2425,7 +2425,7 @@ function runAnnotationMutationConformance(runner, opts) {
2425
2425
  }
2426
2426
  });
2427
2427
  test("create link annotations round-trip uri, goto/xyz, goto/fitH, and dead targets", async () => {
2428
- const doc = await openFixture$15(engine, opts);
2428
+ const doc = await openFixture$18(engine, opts);
2429
2429
  try {
2430
2430
  const page = doc.page(fix.pageObjectNumber);
2431
2431
  const uri = await page.annotations.create({
@@ -2502,7 +2502,7 @@ function runAnnotationMutationConformance(runner, opts) {
2502
2502
  }
2503
2503
  });
2504
2504
  test("a link patch retargets in both directions (uri→goto, goto→uri) and moves the rect", async () => {
2505
- const doc = await openFixture$15(engine, opts);
2505
+ const doc = await openFixture$18(engine, opts);
2506
2506
  try {
2507
2507
  const page = doc.page(fix.pageObjectNumber);
2508
2508
  const created = await page.annotations.create({
@@ -2557,7 +2557,7 @@ function runAnnotationMutationConformance(runner, opts) {
2557
2557
  }
2558
2558
  });
2559
2559
  test("a link patch clears the target with null — a dead link on re-read", async () => {
2560
- const doc = await openFixture$15(engine, opts);
2560
+ const doc = await openFixture$18(engine, opts);
2561
2561
  try {
2562
2562
  const page = doc.page(fix.pageObjectNumber);
2563
2563
  const created = await page.annotations.create({
@@ -2596,7 +2596,7 @@ function runAnnotationMutationConformance(runner, opts) {
2596
2596
  }
2597
2597
  });
2598
2598
  test("a link grouped to a highlight round-trips /IRT + /RT /Group with its target", async () => {
2599
- const doc = await openFixture$15(engine, opts);
2599
+ const doc = await openFixture$18(engine, opts);
2600
2600
  try {
2601
2601
  const page = doc.page(fix.pageObjectNumber);
2602
2602
  const parent = await page.annotations.create({
@@ -2630,7 +2630,7 @@ function runAnnotationMutationConformance(runner, opts) {
2630
2630
  }
2631
2631
  });
2632
2632
  test("replace-text round-trips /IT and groups StrikeOut under its Caret", async () => {
2633
- const doc = await openFixture$15(engine, opts);
2633
+ const doc = await openFixture$18(engine, opts);
2634
2634
  try {
2635
2635
  const page = doc.page(fix.pageObjectNumber);
2636
2636
  const caret = await page.annotations.create({
@@ -2682,7 +2682,7 @@ function runAnnotationMutationConformance(runner, opts) {
2682
2682
  }
2683
2683
  });
2684
2684
  test("patch inReplyTo: null clears /IRT and /RT (back to top-level)", async () => {
2685
- const doc = await openFixture$15(engine, opts);
2685
+ const doc = await openFixture$18(engine, opts);
2686
2686
  try {
2687
2687
  const page = doc.page(fix.pageObjectNumber);
2688
2688
  const parent = await page.annotations.create({
@@ -2709,7 +2709,7 @@ function runAnnotationMutationConformance(runner, opts) {
2709
2709
  }
2710
2710
  });
2711
2711
  test("create with a cross-page /IRT parent throws InvalidArg", async () => {
2712
- const doc = await openFixture$15(engine, opts);
2712
+ const doc = await openFixture$18(engine, opts);
2713
2713
  try {
2714
2714
  const page = doc.page(fix.pageObjectNumber);
2715
2715
  const parent = await page.annotations.create({
@@ -2740,7 +2740,7 @@ function runAnnotationMutationConformance(runner, opts) {
2740
2740
  }
2741
2741
  });
2742
2742
  test("a review-status reply round-trips /State + /StateModel + /Subj", async () => {
2743
- const doc = await openFixture$15(engine, opts);
2743
+ const doc = await openFixture$18(engine, opts);
2744
2744
  try {
2745
2745
  const page = doc.page(fix.pageObjectNumber);
2746
2746
  const target = await page.annotations.create({
@@ -2774,7 +2774,7 @@ function runAnnotationMutationConformance(runner, opts) {
2774
2774
  }
2775
2775
  });
2776
2776
  test("a draft /State without /StateModel is rejected with InvalidArg", async () => {
2777
- const doc = await openFixture$15(engine, opts);
2777
+ const doc = await openFixture$18(engine, opts);
2778
2778
  try {
2779
2779
  const page = doc.page(fix.pageObjectNumber);
2780
2780
  let caught;
@@ -2793,7 +2793,7 @@ function runAnnotationMutationConformance(runner, opts) {
2793
2793
  }
2794
2794
  });
2795
2795
  test("null-clear patches truly remove /State, /StateModel, /Subj and /Contents", async () => {
2796
- const doc = await openFixture$15(engine, opts);
2796
+ const doc = await openFixture$18(engine, opts);
2797
2797
  try {
2798
2798
  const page = doc.page(fix.pageObjectNumber);
2799
2799
  const note = await page.annotations.create({
@@ -2840,7 +2840,7 @@ function runAnnotationMutationConformance(runner, opts) {
2840
2840
  }
2841
2841
  });
2842
2842
  test("custom state models round-trip verbatim", async () => {
2843
- const doc = await openFixture$15(engine, opts);
2843
+ const doc = await openFixture$18(engine, opts);
2844
2844
  try {
2845
2845
  const page = doc.page(fix.pageObjectNumber);
2846
2846
  const custom = await page.annotations.create({
@@ -2868,7 +2868,7 @@ async function beginWeakEditIfRequired(doc, pageObjectNumber, fix) {
2868
2868
  if (doc.capabilities.weakAnnotationEditSessions !== "required" || !fix.expectsWeakAnnotation) return null;
2869
2869
  return doc.annotations.beginWeakEdit([pageObjectNumber]);
2870
2870
  }
2871
- async function openFixture$15(engine, opts) {
2871
+ async function openFixture$18(engine, opts) {
2872
2872
  if (opts.openKind === "bytes") {
2873
2873
  const bytes = await opts.fixture.bytes();
2874
2874
  return engine.open({
@@ -3458,7 +3458,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
3458
3458
  if (engine) await engine.destroy();
3459
3459
  });
3460
3460
  test("renders the expected set of appearances with valid output", async () => {
3461
- const doc = await openFixture$14(engine, opts);
3461
+ const doc = await openFixture$17(engine, opts);
3462
3462
  try {
3463
3463
  const { pageState, appearances } = await collect(doc, opts, useRaw);
3464
3464
  expect(pageState.pageObjectNumber).toBe(opts.fixture.pageObjectNumber);
@@ -3485,7 +3485,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
3485
3485
  }
3486
3486
  });
3487
3487
  if (opts.fixture.expectsWeakAppearance) test("weak (index-only) annotations are emitted, not dropped", async () => {
3488
- const doc = await openFixture$14(engine, opts);
3488
+ const doc = await openFixture$17(engine, opts);
3489
3489
  try {
3490
3490
  const { appearances } = await collect(doc, opts, useRaw);
3491
3491
  const weak = appearances.find((a) => a.ref.kind === "index");
@@ -3495,7 +3495,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
3495
3495
  }
3496
3496
  });
3497
3497
  if (useRaw) test("rendered appearances are not blank (non-zero alpha)", async () => {
3498
- const doc = await openFixture$14(engine, opts);
3498
+ const doc = await openFixture$17(engine, opts);
3499
3499
  try {
3500
3500
  const { appearances } = await collect(doc, opts, useRaw);
3501
3501
  const anyVisible = appearances.some((a) => a.raster !== null && hasOpaquePixel(a.raster));
@@ -3505,7 +3505,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
3505
3505
  }
3506
3506
  });
3507
3507
  test("abort() rejects with AbortError", async () => {
3508
- const doc = await openFixture$14(engine, opts);
3508
+ const doc = await openFixture$17(engine, opts);
3509
3509
  try {
3510
3510
  const page = doc.page(opts.fixture.pageObjectNumber);
3511
3511
  const p = useRaw ? page.annotations.renderAppearances({ scale: 1 }) : page.annotations.renderAppearanceImages({
@@ -3560,7 +3560,7 @@ function hasOpaquePixel(raster) {
3560
3560
  }
3561
3561
  return false;
3562
3562
  }
3563
- async function openFixture$14(engine, opts) {
3563
+ async function openFixture$17(engine, opts) {
3564
3564
  if (opts.openKind === "bytes") {
3565
3565
  const bytes = await opts.fixture.bytes();
3566
3566
  return engine.open({
@@ -3629,7 +3629,7 @@ function runPageReorderConformance(runner, opts) {
3629
3629
  if (engine) await engine.destroy();
3630
3630
  });
3631
3631
  test("pages.list() returns every page in display order, durable PONs only", async () => {
3632
- const doc = await openFixture$13(engine, opts);
3632
+ const doc = await openFixture$16(engine, opts);
3633
3633
  try {
3634
3634
  const list = await doc.pages.list();
3635
3635
  expect(require_schemas.PageListSnapshotSchema.safeParse(list).success).toBe(true);
@@ -3648,7 +3648,7 @@ function runPageReorderConformance(runner, opts) {
3648
3648
  }
3649
3649
  });
3650
3650
  test("pages.move() reorders pages and returns the full post-move order", async () => {
3651
- const doc = await openFixture$13(engine, opts);
3651
+ const doc = await openFixture$16(engine, opts);
3652
3652
  try {
3653
3653
  const before = await doc.pages.list();
3654
3654
  if (before.pages.length < 3) return;
@@ -3672,7 +3672,7 @@ function runPageReorderConformance(runner, opts) {
3672
3672
  }
3673
3673
  });
3674
3674
  test("weak index-based annotation refs survive a page reorder", async () => {
3675
- const doc = await openFixture$13(engine, opts);
3675
+ const doc = await openFixture$16(engine, opts);
3676
3676
  try {
3677
3677
  const list = await doc.pages.list();
3678
3678
  if (list.pages.length < 2) return;
@@ -3709,7 +3709,7 @@ function runPageReorderConformance(runner, opts) {
3709
3709
  }
3710
3710
  });
3711
3711
  test("pages.move() rejects duplicate PONs with InvalidArg", async () => {
3712
- const doc = await openFixture$13(engine, opts);
3712
+ const doc = await openFixture$16(engine, opts);
3713
3713
  try {
3714
3714
  const list = await doc.pages.list();
3715
3715
  if (list.pages.length < 1) return;
@@ -3726,7 +3726,7 @@ function runPageReorderConformance(runner, opts) {
3726
3726
  }
3727
3727
  });
3728
3728
  test("pages.move() rejects out-of-range destIndex with InvalidArg", async () => {
3729
- const doc = await openFixture$13(engine, opts);
3729
+ const doc = await openFixture$16(engine, opts);
3730
3730
  try {
3731
3731
  const list = await doc.pages.list();
3732
3732
  if (list.pages.length < 1) return;
@@ -3743,7 +3743,7 @@ function runPageReorderConformance(runner, opts) {
3743
3743
  }
3744
3744
  });
3745
3745
  test("pages.move() rejects unknown PON with NotFound or InvalidArg", async () => {
3746
- const doc = await openFixture$13(engine, opts);
3746
+ const doc = await openFixture$16(engine, opts);
3747
3747
  try {
3748
3748
  const list = await doc.pages.list();
3749
3749
  let bogus = 0;
@@ -3761,7 +3761,7 @@ function runPageReorderConformance(runner, opts) {
3761
3761
  }
3762
3762
  });
3763
3763
  test("abort on pages.move() rejects with AbortError", async () => {
3764
- const doc = await openFixture$13(engine, opts);
3764
+ const doc = await openFixture$16(engine, opts);
3765
3765
  try {
3766
3766
  const list = await doc.pages.list();
3767
3767
  if (list.pages.length < 1) return;
@@ -3775,7 +3775,7 @@ function runPageReorderConformance(runner, opts) {
3775
3775
  });
3776
3776
  });
3777
3777
  }
3778
- async function openFixture$13(engine, opts) {
3778
+ async function openFixture$16(engine, opts) {
3779
3779
  if (opts.openKind === "bytes") {
3780
3780
  const bytes = await opts.fixture.bytes();
3781
3781
  return engine.open({
@@ -3849,7 +3849,7 @@ function runPageRotateConformance(runner, opts) {
3849
3849
  if (engine) await engine.destroy();
3850
3850
  });
3851
3851
  test("pages.rotate() sets the absolute rotation and returns the full layout", async () => {
3852
- const doc = await openFixture$12(engine, opts);
3852
+ const doc = await openFixture$15(engine, opts);
3853
3853
  try {
3854
3854
  const before = await doc.pages.list();
3855
3855
  const target = before.pages[0];
@@ -3868,7 +3868,7 @@ function runPageRotateConformance(runner, opts) {
3868
3868
  }
3869
3869
  });
3870
3870
  test("absolute rotation is idempotent: setting the same value twice is a no-op", async () => {
3871
- const doc = await openFixture$12(engine, opts);
3871
+ const doc = await openFixture$15(engine, opts);
3872
3872
  try {
3873
3873
  const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
3874
3874
  const first = await doc.pages.rotate([pon], 180);
@@ -3879,7 +3879,7 @@ function runPageRotateConformance(runner, opts) {
3879
3879
  }
3880
3880
  });
3881
3881
  test("one rotation applies to EVERY listed page (the multi-select gesture)", async () => {
3882
- const doc = await openFixture$12(engine, opts);
3882
+ const doc = await openFixture$15(engine, opts);
3883
3883
  try {
3884
3884
  const list = await doc.pages.list();
3885
3885
  if (list.pages.length < 2) return;
@@ -3891,7 +3891,7 @@ function runPageRotateConformance(runner, opts) {
3891
3891
  }
3892
3892
  });
3893
3893
  test("weak index-based annotation refs survive a rotate (no revision bump)", async () => {
3894
- const doc = await openFixture$12(engine, opts);
3894
+ const doc = await openFixture$15(engine, opts);
3895
3895
  try {
3896
3896
  const hostPon = (await doc.pages.list()).pages[0].pageObjectNumber;
3897
3897
  const hostPage = doc.page(hostPon);
@@ -3921,7 +3921,7 @@ function runPageRotateConformance(runner, opts) {
3921
3921
  }
3922
3922
  });
3923
3923
  test("pages.rotate() rejects an invalid rotation value with InvalidArg", async () => {
3924
- const doc = await openFixture$12(engine, opts);
3924
+ const doc = await openFixture$15(engine, opts);
3925
3925
  try {
3926
3926
  const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
3927
3927
  let caught;
@@ -3936,7 +3936,7 @@ function runPageRotateConformance(runner, opts) {
3936
3936
  }
3937
3937
  });
3938
3938
  test("pages.rotate() rejects duplicate PONs with InvalidArg", async () => {
3939
- const doc = await openFixture$12(engine, opts);
3939
+ const doc = await openFixture$15(engine, opts);
3940
3940
  try {
3941
3941
  const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
3942
3942
  let caught;
@@ -3951,7 +3951,7 @@ function runPageRotateConformance(runner, opts) {
3951
3951
  }
3952
3952
  });
3953
3953
  test("pages.rotate() rejects unknown PON with NotFound or InvalidArg", async () => {
3954
- const doc = await openFixture$12(engine, opts);
3954
+ const doc = await openFixture$15(engine, opts);
3955
3955
  try {
3956
3956
  const list = await doc.pages.list();
3957
3957
  let bogus = 0;
@@ -3969,7 +3969,7 @@ function runPageRotateConformance(runner, opts) {
3969
3969
  }
3970
3970
  });
3971
3971
  test("abort on pages.rotate() rejects with AbortError", async () => {
3972
- const doc = await openFixture$12(engine, opts);
3972
+ const doc = await openFixture$15(engine, opts);
3973
3973
  try {
3974
3974
  const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
3975
3975
  const p = doc.pages.rotate([pon], 90);
@@ -3981,7 +3981,7 @@ function runPageRotateConformance(runner, opts) {
3981
3981
  });
3982
3982
  });
3983
3983
  }
3984
- async function openFixture$12(engine, opts) {
3984
+ async function openFixture$15(engine, opts) {
3985
3985
  if (opts.openKind === "bytes") {
3986
3986
  const bytes = await opts.fixture.bytes();
3987
3987
  return engine.open({
@@ -4044,7 +4044,7 @@ function runPageDeleteConformance(runner, opts) {
4044
4044
  if (engine) await engine.destroy();
4045
4045
  });
4046
4046
  test("pages.delete() removes the page and returns the surviving layout", async () => {
4047
- const doc = await openFixture$11(engine, opts);
4047
+ const doc = await openFixture$14(engine, opts);
4048
4048
  try {
4049
4049
  const before = await doc.pages.list();
4050
4050
  if (before.pages.length < 2) return;
@@ -4065,7 +4065,7 @@ function runPageDeleteConformance(runner, opts) {
4065
4065
  }
4066
4066
  });
4067
4067
  test("addressing a deleted page afterwards is a clean NotFound", async () => {
4068
- const doc = await openFixture$11(engine, opts);
4068
+ const doc = await openFixture$14(engine, opts);
4069
4069
  try {
4070
4070
  const before = await doc.pages.list();
4071
4071
  if (before.pages.length < 2) return;
@@ -4083,7 +4083,7 @@ function runPageDeleteConformance(runner, opts) {
4083
4083
  }
4084
4084
  });
4085
4085
  test("surviving pages keep their weak index-based annotation refs", async () => {
4086
- const doc = await openFixture$11(engine, opts);
4086
+ const doc = await openFixture$14(engine, opts);
4087
4087
  try {
4088
4088
  const list = await doc.pages.list();
4089
4089
  if (list.pages.length < 2) return;
@@ -4116,7 +4116,7 @@ function runPageDeleteConformance(runner, opts) {
4116
4116
  }
4117
4117
  });
4118
4118
  test("deleting EVERY page is rejected with InvalidArg", async () => {
4119
- const doc = await openFixture$11(engine, opts);
4119
+ const doc = await openFixture$14(engine, opts);
4120
4120
  try {
4121
4121
  const list = await doc.pages.list();
4122
4122
  let caught;
@@ -4131,7 +4131,7 @@ function runPageDeleteConformance(runner, opts) {
4131
4131
  }
4132
4132
  });
4133
4133
  test("pages.delete() rejects duplicate PONs with InvalidArg", async () => {
4134
- const doc = await openFixture$11(engine, opts);
4134
+ const doc = await openFixture$14(engine, opts);
4135
4135
  try {
4136
4136
  const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
4137
4137
  let caught;
@@ -4146,7 +4146,7 @@ function runPageDeleteConformance(runner, opts) {
4146
4146
  }
4147
4147
  });
4148
4148
  test("pages.delete() rejects unknown PON with NotFound or InvalidArg", async () => {
4149
- const doc = await openFixture$11(engine, opts);
4149
+ const doc = await openFixture$14(engine, opts);
4150
4150
  try {
4151
4151
  const list = await doc.pages.list();
4152
4152
  let bogus = 0;
@@ -4164,7 +4164,7 @@ function runPageDeleteConformance(runner, opts) {
4164
4164
  }
4165
4165
  });
4166
4166
  test("abort on pages.delete() rejects with AbortError", async () => {
4167
- const doc = await openFixture$11(engine, opts);
4167
+ const doc = await openFixture$14(engine, opts);
4168
4168
  try {
4169
4169
  const list = await doc.pages.list();
4170
4170
  if (list.pages.length < 2) return;
@@ -4178,7 +4178,224 @@ function runPageDeleteConformance(runner, opts) {
4178
4178
  });
4179
4179
  });
4180
4180
  }
4181
- async function openFixture$11(engine, opts) {
4181
+ async function openFixture$14(engine, opts) {
4182
+ if (opts.openKind === "bytes") {
4183
+ const bytes = await opts.fixture.bytes();
4184
+ return engine.open({
4185
+ kind: "bytes",
4186
+ id: opts.fixture.id,
4187
+ bytes
4188
+ });
4189
+ }
4190
+ return engine.open({
4191
+ kind: "id",
4192
+ id: opts.fixture.cloudId ?? opts.fixture.id
4193
+ });
4194
+ }
4195
+ //#endregion
4196
+ //#region src/conformance/runNamedPagesConformance.ts
4197
+ /**
4198
+ * Named-pages conformance: the catalog's `/Names /Pages` registry as LAYOUT
4199
+ * data. Locks the invariants both engines must share — do not loosen
4200
+ * without re-reading `NamedPageEntry` and `PageNameResult`:
4201
+ *
4202
+ * 1. `pages.list().namedPages` is present (possibly empty) and every
4203
+ * registration resolves to a page in `pages`, a template, or is
4204
+ * reported dangling — never silently dropped.
4205
+ * 2. `pages.setName()` creates or replaces by decoded key (idempotent),
4206
+ * `replace` renames in one job, and the result IS the new layout.
4207
+ * 3. `pages.removeName()` drops the registration and nothing else.
4208
+ * 4. Deleting a page removes every registration pointing at it — inside
4209
+ * the delete, with no plugin in the loop.
4210
+ * 5. Non-ASCII keys round-trip unchanged (Acrobat writes UTF-16 + BOM).
4211
+ *
4212
+ * Skips cleanly when the engine does not implement the optional members.
4213
+ */
4214
+ function runNamedPagesConformance(runner, opts) {
4215
+ const { describe, test, beforeAll, afterAll, expect } = runner;
4216
+ describe(`named pages conformance: ${opts.label}`, () => {
4217
+ let engine;
4218
+ beforeAll(async () => {
4219
+ engine = await opts.makeEngine();
4220
+ });
4221
+ afterAll(async () => {
4222
+ if (engine) await engine.destroy();
4223
+ });
4224
+ test("pages.list() carries namedPages and every entry resolves", async () => {
4225
+ const doc = await openFixture$13(engine, opts);
4226
+ try {
4227
+ const layout = await doc.pages.list();
4228
+ require_schemas.PageListSnapshotSchema.parse(layout);
4229
+ expect(Array.isArray(layout.namedPages)).toBe(true);
4230
+ const pons = new Set(layout.pages.map((page) => page.pageObjectNumber));
4231
+ for (const entry of layout.namedPages ?? []) {
4232
+ expect(entry.name.length > 0).toBe(true);
4233
+ if (entry.target.kind === "page") expect(pons.has(entry.target.pageObjectNumber)).toBe(true);
4234
+ }
4235
+ } finally {
4236
+ await doc.close();
4237
+ }
4238
+ });
4239
+ test("pages.setName() registers, replaces by key, and renames via `replace`", async () => {
4240
+ const doc = await openFixture$13(engine, opts);
4241
+ try {
4242
+ if (!doc.pages.setName) return;
4243
+ const before = await doc.pages.list();
4244
+ const [first, second] = before.pages;
4245
+ const baseline = (before.namedPages ?? []).length;
4246
+ const created = await doc.pages.setName({
4247
+ name: "Approved=Goedgekeurd",
4248
+ pageObjectNumber: first.pageObjectNumber
4249
+ });
4250
+ require_schemas.PageNameResultSchema.parse(created);
4251
+ expect(created.layout.pages.length).toBe(before.pages.length);
4252
+ expect(find(created, "Approved=Goedgekeurd")).toEqual({
4253
+ kind: "page",
4254
+ pageObjectNumber: first.pageObjectNumber
4255
+ });
4256
+ expect((created.layout.namedPages ?? []).length).toBe(baseline + 1);
4257
+ if (created.cache) {
4258
+ expect(created.cache.docVersion > created.cache.previousDocVersion).toBe(true);
4259
+ expect(created.cache.layoutVersion > 0).toBe(true);
4260
+ }
4261
+ const listed = await doc.pages.list();
4262
+ expect(listed.namedPages).toEqual(created.layout.namedPages);
4263
+ const replaced = await doc.pages.setName({
4264
+ name: "Approved=Goedgekeurd",
4265
+ pageObjectNumber: second.pageObjectNumber
4266
+ });
4267
+ expect(find(replaced, "Approved=Goedgekeurd")).toEqual({
4268
+ kind: "page",
4269
+ pageObjectNumber: second.pageObjectNumber
4270
+ });
4271
+ expect((replaced.layout.namedPages ?? []).length).toBe(baseline + 1);
4272
+ const renamed = await doc.pages.setName({
4273
+ name: "Approved=Approved",
4274
+ pageObjectNumber: second.pageObjectNumber,
4275
+ replace: "Approved=Goedgekeurd"
4276
+ });
4277
+ expect(find(renamed, "Approved=Goedgekeurd")).toBe(void 0);
4278
+ expect(find(renamed, "Approved=Approved")).toEqual({
4279
+ kind: "page",
4280
+ pageObjectNumber: second.pageObjectNumber
4281
+ });
4282
+ expect((renamed.layout.namedPages ?? []).length).toBe(baseline + 1);
4283
+ } finally {
4284
+ await doc.close();
4285
+ }
4286
+ });
4287
+ test("non-ASCII keys round-trip through set → list", async () => {
4288
+ const doc = await openFixture$13(engine, opts);
4289
+ try {
4290
+ if (!doc.pages.setName) return;
4291
+ const before = await doc.pages.list();
4292
+ const key = "Stämpel=Stämpel 日本";
4293
+ const result = await doc.pages.setName({
4294
+ name: key,
4295
+ pageObjectNumber: before.pages[0].pageObjectNumber
4296
+ });
4297
+ expect(find(result, key)).toEqual({
4298
+ kind: "page",
4299
+ pageObjectNumber: before.pages[0].pageObjectNumber
4300
+ });
4301
+ const listed = await doc.pages.list();
4302
+ expect((listed.namedPages ?? []).some((entry) => entry.name === key)).toBe(true);
4303
+ } finally {
4304
+ await doc.close();
4305
+ }
4306
+ });
4307
+ test("pages.removeName() drops the registration and keeps the page", async () => {
4308
+ const doc = await openFixture$13(engine, opts);
4309
+ try {
4310
+ if (!doc.pages.setName || !doc.pages.removeName) return;
4311
+ const before = await doc.pages.list();
4312
+ await doc.pages.setName({
4313
+ name: "Draft=Concept",
4314
+ pageObjectNumber: before.pages[0].pageObjectNumber
4315
+ });
4316
+ const removed = await doc.pages.removeName({ name: "Draft=Concept" });
4317
+ require_schemas.PageNameResultSchema.parse(removed);
4318
+ expect(find(removed, "Draft=Concept")).toBe(void 0);
4319
+ expect(removed.layout.pages.length).toBe(before.pages.length);
4320
+ await expect(doc.pages.removeName({ name: "Draft=Concept" })).rejects.toMatchObject({ code: require_PageInsertBlankInput.EngineErrorCode.NotFound });
4321
+ } finally {
4322
+ await doc.close();
4323
+ }
4324
+ });
4325
+ test("pages.setName() rejects an empty name and an unknown page", async () => {
4326
+ const doc = await openFixture$13(engine, opts);
4327
+ try {
4328
+ if (!doc.pages.setName) return;
4329
+ const before = await doc.pages.list();
4330
+ await expect(doc.pages.setName({
4331
+ name: "",
4332
+ pageObjectNumber: before.pages[0].pageObjectNumber
4333
+ })).rejects.toMatchObject({ code: require_PageInsertBlankInput.EngineErrorCode.InvalidArg });
4334
+ let unknownPage = null;
4335
+ try {
4336
+ await doc.pages.setName({
4337
+ name: "Ghost=Ghost",
4338
+ pageObjectNumber: 987654321
4339
+ });
4340
+ } catch (error) {
4341
+ unknownPage = error;
4342
+ }
4343
+ expect(require_fold.EngineError.is(unknownPage, require_PageInsertBlankInput.EngineErrorCode.NotFound) || require_fold.EngineError.is(unknownPage, require_PageInsertBlankInput.EngineErrorCode.InvalidArg)).toBe(true);
4344
+ } finally {
4345
+ await doc.close();
4346
+ }
4347
+ });
4348
+ test("deleting a page removes every registration pointing at it", async () => {
4349
+ const doc = await openFixture$13(engine, opts);
4350
+ try {
4351
+ if (!doc.pages.setName) return;
4352
+ const before = await doc.pages.list();
4353
+ if (before.pages.length < 2) return;
4354
+ const victim = before.pages[1].pageObjectNumber;
4355
+ const survivor = before.pages[0].pageObjectNumber;
4356
+ await doc.pages.setName({
4357
+ name: "Victim=One",
4358
+ pageObjectNumber: victim
4359
+ });
4360
+ await doc.pages.setName({
4361
+ name: "Victim=Two",
4362
+ pageObjectNumber: victim
4363
+ });
4364
+ await doc.pages.setName({
4365
+ name: "Survivor",
4366
+ pageObjectNumber: survivor
4367
+ });
4368
+ const deleted = await doc.pages.delete([victim]);
4369
+ const names = (deleted.layout.namedPages ?? []).map((entry) => entry.name);
4370
+ expect(names.includes("Victim=One")).toBe(false);
4371
+ expect(names.includes("Victim=Two")).toBe(false);
4372
+ expect(names).toContain("Survivor");
4373
+ expect((deleted.layout.namedPages ?? []).some((entry) => entry.target.kind === "dangling")).toBe(false);
4374
+ } finally {
4375
+ await doc.close();
4376
+ }
4377
+ });
4378
+ test("abort on pages.setName() rejects with AbortError", async () => {
4379
+ const doc = await openFixture$13(engine, opts);
4380
+ try {
4381
+ if (!doc.pages.setName) return;
4382
+ const before = await doc.pages.list();
4383
+ const promise = doc.pages.setName({
4384
+ name: "Aborted=Aborted",
4385
+ pageObjectNumber: before.pages[0].pageObjectNumber
4386
+ });
4387
+ promise.abort();
4388
+ await expect(promise).rejects.toBeInstanceOf(require_AbortError.AbortError);
4389
+ } finally {
4390
+ await doc.close();
4391
+ }
4392
+ });
4393
+ });
4394
+ }
4395
+ function find(result, name) {
4396
+ return (result.layout.namedPages ?? []).find((entry) => entry.name === name)?.target;
4397
+ }
4398
+ async function openFixture$13(engine, opts) {
4182
4399
  if (opts.openKind === "bytes") {
4183
4400
  const bytes = await opts.fixture.bytes();
4184
4401
  return engine.open({
@@ -4193,6 +4410,243 @@ async function openFixture$11(engine, opts) {
4193
4410
  });
4194
4411
  }
4195
4412
  //#endregion
4413
+ //#region src/conformance/runAnnotationFlattenConformance.ts
4414
+ const square$1 = (left, bottom) => ({
4415
+ subtype: "square",
4416
+ rect: {
4417
+ left,
4418
+ bottom,
4419
+ right: left + 40,
4420
+ top: bottom + 40
4421
+ },
4422
+ color: {
4423
+ r: 20,
4424
+ g: 40,
4425
+ b: 220
4426
+ },
4427
+ strokeWidth: 2
4428
+ });
4429
+ /**
4430
+ * Selective annotation flatten: `page(pon).annotations.flatten(refs)` is
4431
+ * `pages.flatten` for a chosen set. Locks, on every engine:
4432
+ * 1. only the given refs are painted and removed; the rest of the page's
4433
+ * annotations are untouched;
4434
+ * 2. per-ref status (`applied` / `skipped`), one `annotations.flattened`
4435
+ * event, a `meta` with that page's new pins, layout unchanged;
4436
+ * 3. a hidden ref is `skipped`; a ref on another page rejects `InvalidArg`
4437
+ * with nothing mutated.
4438
+ * Skips cleanly when the engine does not implement the optional member.
4439
+ */
4440
+ function runAnnotationFlattenConformance(runner, opts) {
4441
+ const { describe, test, beforeAll, afterAll, expect } = runner;
4442
+ describe(`annotation flatten conformance: ${opts.label}`, () => {
4443
+ let engine;
4444
+ beforeAll(async () => {
4445
+ engine = await opts.makeEngine();
4446
+ });
4447
+ afterAll(async () => {
4448
+ if (engine) await engine.destroy();
4449
+ });
4450
+ test("flattens exactly the given refs and reports per-ref status", async () => {
4451
+ const doc = await openFixture$12(engine, opts);
4452
+ try {
4453
+ const layoutBefore = await doc.pages.list();
4454
+ const pon = layoutBefore.pages[0].pageObjectNumber;
4455
+ const page = doc.page(pon);
4456
+ if (!page.annotations.flatten) return;
4457
+ const a = (await page.annotations.create(square$1(20, 20))).created.ref;
4458
+ const b = (await page.annotations.create(square$1(80, 20))).created.ref;
4459
+ const c = (await page.annotations.create(square$1(140, 20))).created.ref;
4460
+ await page.annotations.update(c, {
4461
+ subtype: "square",
4462
+ flags: { hidden: true }
4463
+ });
4464
+ const before = await page.annotations.list();
4465
+ const events = [];
4466
+ const unsubscribe = doc.events.subscribe((event) => {
4467
+ if (event.type === "annotations.flattened") events.push(event);
4468
+ });
4469
+ const result = await page.annotations.flatten([a, c], "display");
4470
+ unsubscribe();
4471
+ expect(require_schemas.AnnotationFlattenResultSchema.safeParse(result).success).toBe(true);
4472
+ expect(result.pageObjectNumber).toBe(pon);
4473
+ expect(result.usage).toBe("display");
4474
+ expect(result.results.map((item) => item.status)).toEqual(["applied", "skipped"]);
4475
+ expect(result.meta === null).toBe(false);
4476
+ expect(events).toHaveLength(1);
4477
+ expect(await doc.pages.list()).toEqual(layoutBefore);
4478
+ const after = await page.annotations.list();
4479
+ expect(after.annotations.length).toBe(before.annotations.length - 1);
4480
+ expect(after.annotations.some((dto) => sameRef(dto.ref, b))).toBe(true);
4481
+ expect(after.annotations.some((dto) => sameRef(dto.ref, c))).toBe(true);
4482
+ expect(after.annotations.some((dto) => sameRef(dto.ref, a))).toBe(false);
4483
+ expect(after.pageState.revision.generation > before.pageState.revision.generation).toBe(true);
4484
+ } finally {
4485
+ await doc.close();
4486
+ }
4487
+ });
4488
+ test("a ref on another page rejects InvalidArg and mutates nothing", async () => {
4489
+ const doc = await openFixture$12(engine, opts);
4490
+ try {
4491
+ const layout = await doc.pages.list();
4492
+ if (layout.pages.length < 2) return;
4493
+ const page0 = doc.page(layout.pages[0].pageObjectNumber);
4494
+ const page1 = doc.page(layout.pages[1].pageObjectNumber);
4495
+ if (!page0.annotations.flatten) return;
4496
+ const own = (await page0.annotations.create(square$1(20, 100))).created.ref;
4497
+ const foreign = (await page1.annotations.create(square$1(20, 100))).created.ref;
4498
+ const countBefore = (await page0.annotations.list()).annotations.length;
4499
+ await expect(page0.annotations.flatten([own, foreign])).rejects.toMatchObject({ code: require_PageInsertBlankInput.EngineErrorCode.InvalidArg });
4500
+ expect((await page0.annotations.list()).annotations.length).toBe(countBefore);
4501
+ } finally {
4502
+ await doc.close();
4503
+ }
4504
+ });
4505
+ test("an empty ref list rejects InvalidArg; an unknown ref rejects", async () => {
4506
+ const doc = await openFixture$12(engine, opts);
4507
+ try {
4508
+ const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
4509
+ const page = doc.page(pon);
4510
+ if (!page.annotations.flatten) return;
4511
+ await expect(page.annotations.flatten([])).rejects.toMatchObject({ code: require_PageInsertBlankInput.EngineErrorCode.InvalidArg });
4512
+ let unknown = null;
4513
+ try {
4514
+ await page.annotations.flatten([{
4515
+ kind: "objectNumber",
4516
+ pageObjectNumber: pon,
4517
+ annotObjectNumber: 987654321
4518
+ }]);
4519
+ } catch (error) {
4520
+ unknown = error;
4521
+ }
4522
+ expect(require_fold.EngineError.is(unknown, require_PageInsertBlankInput.EngineErrorCode.NotFound) || require_fold.EngineError.is(unknown, require_PageInsertBlankInput.EngineErrorCode.InvalidArg) || require_fold.EngineError.is(unknown, require_PageInsertBlankInput.EngineErrorCode.InvalidReference)).toBe(true);
4523
+ } finally {
4524
+ await doc.close();
4525
+ }
4526
+ });
4527
+ });
4528
+ }
4529
+ function sameRef(left, right) {
4530
+ if (left.kind === "objectNumber" && right.kind === "objectNumber") return left.annotObjectNumber === right.annotObjectNumber;
4531
+ return JSON.stringify(left) === JSON.stringify(right);
4532
+ }
4533
+ async function openFixture$12(engine, opts) {
4534
+ if (opts.openKind === "bytes") return engine.open({
4535
+ kind: "bytes",
4536
+ id: opts.fixture.id,
4537
+ bytes: await opts.fixture.bytes()
4538
+ });
4539
+ return engine.open({
4540
+ kind: "id",
4541
+ id: opts.fixture.cloudId ?? opts.fixture.id
4542
+ });
4543
+ }
4544
+ //#endregion
4545
+ //#region src/conformance/runAnnotationAppearanceExportConformance.ts
4546
+ const PDF_MAGIC$1 = [
4547
+ 37,
4548
+ 80,
4549
+ 68,
4550
+ 70
4551
+ ];
4552
+ const square = (left, bottom, size = 40) => ({
4553
+ subtype: "square",
4554
+ rect: {
4555
+ left,
4556
+ bottom,
4557
+ right: left + size,
4558
+ top: bottom + size
4559
+ },
4560
+ color: {
4561
+ r: 220,
4562
+ g: 20,
4563
+ b: 20
4564
+ },
4565
+ strokeWidth: 2
4566
+ });
4567
+ /**
4568
+ * `page(pon).annotations.exportAppearance(refs)`: the chosen annotations'
4569
+ * appearances as ONE single-page PDF sized to their union /Rect. Locks:
4570
+ * 1. bytes are a PDF; the source page is untouched (no mutation, no
4571
+ * revision bump);
4572
+ * 2. re-opened (local engines), the page is exactly the union size and the
4573
+ * requested count of annotations is gone — they are content now;
4574
+ * 3. a ref on another page rejects `InvalidArg`; an empty list rejects.
4575
+ * Skips cleanly when the engine does not implement the optional member.
4576
+ */
4577
+ function runAnnotationAppearanceExportConformance(runner, opts) {
4578
+ const { describe, test, beforeAll, afterAll, expect } = runner;
4579
+ describe(`annotation appearance export conformance: ${opts.label}`, () => {
4580
+ let engine;
4581
+ beforeAll(async () => {
4582
+ engine = await opts.makeEngine();
4583
+ });
4584
+ afterAll(async () => {
4585
+ if (engine) await engine.destroy();
4586
+ });
4587
+ test("returns a single-page PDF sized to the union rect; source untouched", async () => {
4588
+ const doc = await openFixture$11(engine, opts);
4589
+ let exported = null;
4590
+ try {
4591
+ const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
4592
+ const page = doc.page(pon);
4593
+ if (!page.annotations.exportAppearance) return;
4594
+ const a = (await page.annotations.create(square(20, 20))).created.ref;
4595
+ const b = (await page.annotations.create(square(100, 60, 30))).created.ref;
4596
+ const before = await page.annotations.list();
4597
+ const bytes = await page.annotations.exportAppearance([a, b]);
4598
+ expect(bytes.length > 4).toBe(true);
4599
+ expect([...bytes.subarray(0, 4)]).toEqual(PDF_MAGIC$1);
4600
+ const after = await page.annotations.list();
4601
+ expect(after.annotations.length).toBe(before.annotations.length);
4602
+ expect(after.pageState.revision.generation).toBe(before.pageState.revision.generation);
4603
+ if (opts.openKind !== "bytes") return;
4604
+ exported = await engine.open({
4605
+ kind: "bytes",
4606
+ id: `${opts.fixture.id}-appearance`,
4607
+ bytes
4608
+ });
4609
+ const layout = await exported.pages.list();
4610
+ expect(layout.pageCount).toBe(1);
4611
+ expect(Math.round(layout.pages[0].size.width)).toBe(110);
4612
+ expect(Math.round(layout.pages[0].size.height)).toBe(70);
4613
+ const exportedPage = exported.page(layout.pages[0].pageObjectNumber);
4614
+ expect((await exportedPage.annotations.list()).annotations).toHaveLength(0);
4615
+ } finally {
4616
+ if (exported) await exported.close();
4617
+ await doc.close();
4618
+ }
4619
+ });
4620
+ test("a ref on another page and an empty list reject InvalidArg", async () => {
4621
+ const doc = await openFixture$11(engine, opts);
4622
+ try {
4623
+ const layout = await doc.pages.list();
4624
+ const page0 = doc.page(layout.pages[0].pageObjectNumber);
4625
+ if (!page0.annotations.exportAppearance) return;
4626
+ await expect(page0.annotations.exportAppearance([])).rejects.toMatchObject({ code: require_PageInsertBlankInput.EngineErrorCode.InvalidArg });
4627
+ if (layout.pages.length < 2) return;
4628
+ const page1 = doc.page(layout.pages[1].pageObjectNumber);
4629
+ const own = (await page0.annotations.create(square(20, 100))).created.ref;
4630
+ const foreign = (await page1.annotations.create(square(20, 100))).created.ref;
4631
+ await expect(page0.annotations.exportAppearance([own, foreign])).rejects.toMatchObject({ code: require_PageInsertBlankInput.EngineErrorCode.InvalidArg });
4632
+ } finally {
4633
+ await doc.close();
4634
+ }
4635
+ });
4636
+ });
4637
+ }
4638
+ async function openFixture$11(engine, opts) {
4639
+ if (opts.openKind === "bytes") return engine.open({
4640
+ kind: "bytes",
4641
+ id: opts.fixture.id,
4642
+ bytes: await opts.fixture.bytes()
4643
+ });
4644
+ return engine.open({
4645
+ kind: "id",
4646
+ id: opts.fixture.cloudId ?? opts.fixture.id
4647
+ });
4648
+ }
4649
+ //#endregion
4196
4650
  //#region src/conformance/runPageFlattenConformance.ts
4197
4651
  /** Transport-neutral coverage for the content + annotation flatten rail. */
4198
4652
  function runPageFlattenConformance(runner, opts) {
@@ -6226,12 +6680,15 @@ exports.diffAnnotationListSnapshot = diffAnnotationListSnapshot;
6226
6680
  exports.diffAnnotationListSnapshotAll = diffAnnotationListSnapshotAll;
6227
6681
  exports.runActionsConformance = runActionsConformance;
6228
6682
  exports.runAnnotationAppearanceConformance = runAnnotationAppearanceConformance;
6683
+ exports.runAnnotationAppearanceExportConformance = runAnnotationAppearanceExportConformance;
6684
+ exports.runAnnotationFlattenConformance = runAnnotationFlattenConformance;
6229
6685
  exports.runAnnotationMutationConformance = runAnnotationMutationConformance;
6230
6686
  exports.runAnnotationReadConformance = runAnnotationReadConformance;
6231
6687
  exports.runAttachmentConformance = runAttachmentConformance;
6232
6688
  exports.runDocumentEventsConformance = runDocumentEventsConformance;
6233
6689
  exports.runFormConformance = runFormConformance;
6234
6690
  exports.runMetadataConformance = runMetadataConformance;
6691
+ exports.runNamedPagesConformance = runNamedPagesConformance;
6235
6692
  exports.runPageDeleteConformance = runPageDeleteConformance;
6236
6693
  exports.runPageExtractConformance = runPageExtractConformance;
6237
6694
  exports.runPageFlattenConformance = runPageFlattenConformance;