@embedpdf/engine-core 3.0.0-next.10 → 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.
- package/dist/{AnnotationListSnapshot-DDxHpJQU.d.cts → AnnotationListSnapshot-x6tKulNV.d.cts} +461 -114
- package/dist/{AnnotationListSnapshot-DDxHpJQU.d.ts → AnnotationListSnapshot-x6tKulNV.d.ts} +461 -114
- package/dist/{DocumentSecurityService-o9aeTHwT.d.ts → DocumentSecurityService-9MawYxP-.d.ts} +2 -2
- package/dist/{DocumentSecurityService-BV4_YXkU.d.cts → DocumentSecurityService-CK0pejAK.d.cts} +2 -2
- package/dist/{Engine-DOoVem7_.d.ts → Engine--0XF0UAK.d.cts} +68 -3
- package/dist/{Engine-D9je6GdU.d.cts → Engine-Ds0ytbl6.d.ts} +68 -3
- package/dist/{builders-Cp_rlGob.cjs → builders-8Hl1AYNU.cjs} +44 -8
- package/dist/builders-8Hl1AYNU.cjs.map +1 -0
- package/dist/{builders-B_KufGJ9.js → builders-DOjcKDWQ.js} +39 -9
- package/dist/builders-DOjcKDWQ.js.map +1 -0
- package/dist/conformance.cjs +769 -101
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +56 -3
- package/dist/conformance.d.ts +56 -3
- package/dist/conformance.js +767 -102
- package/dist/conformance.js.map +1 -1
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/{resolver-DiPMTfcy.js → resolver-CHG4waXL.js} +2 -1
- package/dist/resolver-CHG4waXL.js.map +1 -0
- package/dist/{resolver-DAZWVoJL.cjs → resolver-D-jumvgM.cjs} +2 -1
- package/dist/resolver-D-jumvgM.cjs.map +1 -0
- package/dist/runtime.cjs +3 -2
- package/dist/runtime.d.cts +66 -5
- package/dist/runtime.d.ts +66 -5
- package/dist/runtime.js +3 -3
- package/dist/{schemas-DAnu8tuW.js → schemas-DOyVEPk7.js} +206 -84
- package/dist/schemas-DOyVEPk7.js.map +1 -0
- package/dist/{schemas-D1pxEv3t.cjs → schemas-RChsAMWw.cjs} +259 -83
- package/dist/schemas-RChsAMWw.cjs.map +1 -0
- package/dist/wire.cjs +65 -2
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +210 -8
- package/dist/wire.d.ts +210 -8
- package/dist/wire.js +54 -3
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/dist/builders-B_KufGJ9.js.map +0 -1
- package/dist/builders-Cp_rlGob.cjs.map +0 -1
- package/dist/resolver-DAZWVoJL.cjs.map +0 -1
- package/dist/resolver-DiPMTfcy.js.map +0 -1
- package/dist/schemas-D1pxEv3t.cjs.map +0 -1
- package/dist/schemas-DAnu8tuW.js.map +0 -1
package/dist/conformance.cjs
CHANGED
|
@@ -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-
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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({
|
|
@@ -370,6 +370,13 @@ function emptyFlags() {
|
|
|
370
370
|
}
|
|
371
371
|
//#endregion
|
|
372
372
|
//#region src/conformance/runActionsConformance.ts
|
|
373
|
+
/** The script payload rides only the javascript/rendition arms. */
|
|
374
|
+
function scriptOf(node) {
|
|
375
|
+
if (!node) return "";
|
|
376
|
+
if (node.type === "javascript") return node.script;
|
|
377
|
+
if (node.type === "rendition") return node.script ?? "";
|
|
378
|
+
return "";
|
|
379
|
+
}
|
|
373
380
|
/** Action extraction parity. These tests assert data only; no script executes. */
|
|
374
381
|
function runActionsConformance(runner, opts) {
|
|
375
382
|
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
@@ -389,10 +396,10 @@ function runActionsConformance(runner, opts) {
|
|
|
389
396
|
expect(require_schemas.DocumentActionsSnapshotSchema.safeParse(snapshot).success).toBe(true);
|
|
390
397
|
expect(snapshot.openAction).toBeNull();
|
|
391
398
|
expect(snapshot.willSave?.root?.type).toBe("javascript");
|
|
392
|
-
expect(snapshot.willSave?.root
|
|
393
|
-
expect(snapshot.didSave?.root
|
|
394
|
-
expect(snapshot.willPrint?.root
|
|
395
|
-
expect(snapshot.didPrint?.root
|
|
399
|
+
expect(scriptOf(snapshot.willSave?.root)).toMatch(/Will Save/);
|
|
400
|
+
expect(scriptOf(snapshot.didSave?.root)).toMatch(/Did Save/);
|
|
401
|
+
expect(scriptOf(snapshot.willPrint?.root)).toMatch(/Will Print/);
|
|
402
|
+
expect(scriptOf(snapshot.didPrint?.root)).toMatch(/Did Print/);
|
|
396
403
|
const form = await doc.forms.list();
|
|
397
404
|
expect(form.calculationOrder).toEqual([{
|
|
398
405
|
kind: "objectNumber",
|
|
@@ -439,7 +446,7 @@ function runActionsConformance(runner, opts) {
|
|
|
439
446
|
expect(link?.subtype).toBe("link");
|
|
440
447
|
if (link?.subtype === "link") expect(link.target).toEqual({ kind: "javascript" });
|
|
441
448
|
expect(link?.actions?.activate?.root?.type).toBe("javascript");
|
|
442
|
-
expect(link?.actions?.activate?.root
|
|
449
|
+
expect(scriptOf(link?.actions?.activate?.root)).toMatch(/app\.alert/);
|
|
443
450
|
} finally {
|
|
444
451
|
await doc.close();
|
|
445
452
|
}
|
|
@@ -450,7 +457,7 @@ function runActionsConformance(runner, opts) {
|
|
|
450
457
|
const form = await doc.forms.list();
|
|
451
458
|
expect(form.fields).toHaveLength(1);
|
|
452
459
|
expect(form.fields[0].actions?.format?.root?.type).toBe("javascript");
|
|
453
|
-
expect(form.fields[0].actions?.format?.root
|
|
460
|
+
expect(scriptOf(form.fields[0].actions?.format?.root)).toMatch(/AFDate_FormatEx/);
|
|
454
461
|
const page = (await doc.pages.list()).pages[0];
|
|
455
462
|
const widget = (await doc.page(page.pageObjectNumber).annotations.list()).annotations[0];
|
|
456
463
|
expect(widget.actions).toBe(void 0);
|
|
@@ -458,6 +465,210 @@ function runActionsConformance(runner, opts) {
|
|
|
458
465
|
await doc.close();
|
|
459
466
|
}
|
|
460
467
|
});
|
|
468
|
+
test("carries interpreter payloads on every executable node", async () => {
|
|
469
|
+
const doc = await open(engine, opts, opts.fixtures.payloads);
|
|
470
|
+
try {
|
|
471
|
+
const page = (await doc.pages.list()).pages[0];
|
|
472
|
+
const snapshot = await doc.page(page.pageObjectNumber).annotations.list();
|
|
473
|
+
const pon = page.pageObjectNumber;
|
|
474
|
+
const rootOf = (nm) => {
|
|
475
|
+
const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
|
|
476
|
+
expect(Boolean(annotation)).toBe(true);
|
|
477
|
+
return annotation?.actions?.activate?.root ?? null;
|
|
478
|
+
};
|
|
479
|
+
const targetOf = (nm) => {
|
|
480
|
+
const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
|
|
481
|
+
return annotation?.subtype === "link" ? annotation.target : null;
|
|
482
|
+
};
|
|
483
|
+
expect(rootOf("goto-fitr")).toMatchObject({
|
|
484
|
+
type: "goto",
|
|
485
|
+
destination: {
|
|
486
|
+
kind: "fitR",
|
|
487
|
+
pageObjectNumber: pon,
|
|
488
|
+
left: 10,
|
|
489
|
+
bottom: 20,
|
|
490
|
+
right: 300,
|
|
491
|
+
top: 400
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
expect(targetOf("goto-fitr")).toMatchObject({
|
|
495
|
+
kind: "goto",
|
|
496
|
+
destination: { kind: "fitR" }
|
|
497
|
+
});
|
|
498
|
+
expect(rootOf("uri-map")).toMatchObject({
|
|
499
|
+
type: "uri",
|
|
500
|
+
uri: "https://example.test/map",
|
|
501
|
+
isMap: true
|
|
502
|
+
});
|
|
503
|
+
expect(rootOf("named-next")).toMatchObject({
|
|
504
|
+
type: "named",
|
|
505
|
+
name: "NextPage"
|
|
506
|
+
});
|
|
507
|
+
const mixed = rootOf("hide-mixed");
|
|
508
|
+
expect(mixed).toMatchObject({
|
|
509
|
+
type: "hide",
|
|
510
|
+
hide: false
|
|
511
|
+
});
|
|
512
|
+
const mixedTargets = mixed?.type === "hide" ? mixed.targets : [];
|
|
513
|
+
expect(mixedTargets).toHaveLength(2);
|
|
514
|
+
expect(mixedTargets[0]).toEqual({
|
|
515
|
+
kind: "name",
|
|
516
|
+
name: "note1"
|
|
517
|
+
});
|
|
518
|
+
expect(mixedTargets[1]?.kind === "objectNumber" && mixedTargets[1].objectNumber > 0).toBe(true);
|
|
519
|
+
expect(rootOf("hide-scalar")).toMatchObject({
|
|
520
|
+
type: "hide",
|
|
521
|
+
targets: [{
|
|
522
|
+
kind: "name",
|
|
523
|
+
name: "fieldB"
|
|
524
|
+
}],
|
|
525
|
+
hide: true
|
|
526
|
+
});
|
|
527
|
+
expect(rootOf("reset-include")).toMatchObject({
|
|
528
|
+
type: "reset-form",
|
|
529
|
+
fields: [{
|
|
530
|
+
kind: "name",
|
|
531
|
+
name: "calc1"
|
|
532
|
+
}],
|
|
533
|
+
exclude: true
|
|
534
|
+
});
|
|
535
|
+
expect(rootOf("reset-absent")).toMatchObject({
|
|
536
|
+
type: "reset-form",
|
|
537
|
+
fields: null,
|
|
538
|
+
exclude: true
|
|
539
|
+
});
|
|
540
|
+
expect(rootOf("reset-empty")).toMatchObject({
|
|
541
|
+
type: "reset-form",
|
|
542
|
+
fields: [],
|
|
543
|
+
exclude: false
|
|
544
|
+
});
|
|
545
|
+
expect(rootOf("submit-urlspec")).toMatchObject({
|
|
546
|
+
type: "submit-form",
|
|
547
|
+
payload: {
|
|
548
|
+
url: "https://uf.example.test/submit",
|
|
549
|
+
fields: [{
|
|
550
|
+
kind: "name",
|
|
551
|
+
name: "parent"
|
|
552
|
+
}],
|
|
553
|
+
flags: {
|
|
554
|
+
raw: 0,
|
|
555
|
+
exclude: false,
|
|
556
|
+
format: "fdf",
|
|
557
|
+
method: "post"
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
expect(rootOf("submit-compat-xfdf")).toMatchObject({
|
|
562
|
+
type: "submit-form",
|
|
563
|
+
payload: {
|
|
564
|
+
url: "https://example.test/xfdf",
|
|
565
|
+
fields: [{
|
|
566
|
+
kind: "name",
|
|
567
|
+
name: "noexport"
|
|
568
|
+
}, {
|
|
569
|
+
kind: "name",
|
|
570
|
+
name: "plain"
|
|
571
|
+
}],
|
|
572
|
+
flags: {
|
|
573
|
+
raw: 35,
|
|
574
|
+
exclude: true,
|
|
575
|
+
includeNoValueFields: true,
|
|
576
|
+
format: "xfdf",
|
|
577
|
+
method: "post"
|
|
578
|
+
},
|
|
579
|
+
charSet: "utf-8"
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
expect(rootOf("submit-pdf-get")).toMatchObject({
|
|
583
|
+
type: "submit-form",
|
|
584
|
+
payload: {
|
|
585
|
+
url: "https://example.test/pdf",
|
|
586
|
+
fields: null,
|
|
587
|
+
flags: {
|
|
588
|
+
raw: 264,
|
|
589
|
+
format: "pdf",
|
|
590
|
+
method: "get"
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
expect(rootOf("launch-app")).toMatchObject({
|
|
595
|
+
type: "launch",
|
|
596
|
+
filePath: "app.exe"
|
|
597
|
+
});
|
|
598
|
+
expect(rootOf("gotor-file")).toMatchObject({
|
|
599
|
+
type: "goto-remote",
|
|
600
|
+
filePath: "other.pdf"
|
|
601
|
+
});
|
|
602
|
+
const chain = rootOf("chain-js-goto-hide");
|
|
603
|
+
expect(chain).toMatchObject({
|
|
604
|
+
type: "javascript",
|
|
605
|
+
script: "app.alert('chain');"
|
|
606
|
+
});
|
|
607
|
+
expect(chain?.next[0]).toMatchObject({
|
|
608
|
+
type: "goto",
|
|
609
|
+
destination: {
|
|
610
|
+
kind: "xyz",
|
|
611
|
+
pageObjectNumber: pon,
|
|
612
|
+
left: 5,
|
|
613
|
+
top: 10,
|
|
614
|
+
zoom: 1.25
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
expect(chain?.next[0]?.next[0]).toMatchObject({
|
|
618
|
+
type: "hide",
|
|
619
|
+
targets: [{
|
|
620
|
+
kind: "name",
|
|
621
|
+
name: "note1"
|
|
622
|
+
}],
|
|
623
|
+
hide: true
|
|
624
|
+
});
|
|
625
|
+
} finally {
|
|
626
|
+
await doc.close();
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
test("degrades unreadable payloads to unknown with payload-dropped", async () => {
|
|
630
|
+
const doc = await open(engine, opts, opts.fixtures.payloads);
|
|
631
|
+
try {
|
|
632
|
+
const page = (await doc.pages.list()).pages[0];
|
|
633
|
+
const snapshot = await doc.page(page.pageObjectNumber).annotations.list();
|
|
634
|
+
for (const [nm, subtype] of [
|
|
635
|
+
["goto-malformed", "GoTo"],
|
|
636
|
+
["hide-partial", "Hide"],
|
|
637
|
+
["submit-not-url", "SubmitForm"],
|
|
638
|
+
["submit-no-f", "SubmitForm"]
|
|
639
|
+
]) {
|
|
640
|
+
const annotation = snapshot.annotations.find((candidate) => candidate.nm === nm);
|
|
641
|
+
const tree = annotation?.actions?.activate;
|
|
642
|
+
expect(tree?.root).toMatchObject({
|
|
643
|
+
type: "unknown",
|
|
644
|
+
subtype
|
|
645
|
+
});
|
|
646
|
+
expect(tree?.warnings ?? []).toContain("payload-dropped");
|
|
647
|
+
if (annotation?.subtype === "link") expect(annotation.target).toEqual({ kind: "unsupported" });
|
|
648
|
+
}
|
|
649
|
+
} finally {
|
|
650
|
+
await doc.close();
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
test("reads a destination-form /OpenAction as openDestination", async () => {
|
|
654
|
+
const doc = await open(engine, opts, opts.fixtures.openDestination);
|
|
655
|
+
try {
|
|
656
|
+
expect(Boolean(doc.actions)).toBe(true);
|
|
657
|
+
const snapshot = await doc.actions.read();
|
|
658
|
+
expect(require_schemas.DocumentActionsSnapshotSchema.safeParse(snapshot).success).toBe(true);
|
|
659
|
+
expect(snapshot.openAction).toBeNull();
|
|
660
|
+
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
661
|
+
expect(snapshot.openDestination).toEqual({
|
|
662
|
+
kind: "xyz",
|
|
663
|
+
pageObjectNumber: pon,
|
|
664
|
+
left: 10,
|
|
665
|
+
top: 700,
|
|
666
|
+
zoom: 1.5
|
|
667
|
+
});
|
|
668
|
+
} finally {
|
|
669
|
+
await doc.close();
|
|
670
|
+
}
|
|
671
|
+
});
|
|
461
672
|
});
|
|
462
673
|
}
|
|
463
674
|
async function open(engine, opts, fixture) {
|
|
@@ -598,7 +809,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
598
809
|
if (engine) await engine.destroy();
|
|
599
810
|
});
|
|
600
811
|
test("create appends without shifting indices and leaves weak refs valid", async () => {
|
|
601
|
-
const doc = await openFixture$
|
|
812
|
+
const doc = await openFixture$18(engine, opts);
|
|
602
813
|
try {
|
|
603
814
|
const page = doc.page(fix.pageObjectNumber);
|
|
604
815
|
const before = await page.annotations.list();
|
|
@@ -634,7 +845,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
634
845
|
}
|
|
635
846
|
});
|
|
636
847
|
test("create + update honor annotation flags (set on create, merge on patch)", async () => {
|
|
637
|
-
const doc = await openFixture$
|
|
848
|
+
const doc = await openFixture$18(engine, opts);
|
|
638
849
|
try {
|
|
639
850
|
const page = doc.page(fix.pageObjectNumber);
|
|
640
851
|
const draft = {
|
|
@@ -669,7 +880,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
669
880
|
}
|
|
670
881
|
});
|
|
671
882
|
test("create shape annotations (circle + square) round-trip shape fields", async () => {
|
|
672
|
-
const doc = await openFixture$
|
|
883
|
+
const doc = await openFixture$18(engine, opts);
|
|
673
884
|
try {
|
|
674
885
|
const page = doc.page(fix.pageObjectNumber);
|
|
675
886
|
const circleDraft = {
|
|
@@ -750,7 +961,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
750
961
|
}
|
|
751
962
|
});
|
|
752
963
|
test("cloudy border (/BE) + rect differences (/RD) are tri-state", async () => {
|
|
753
|
-
const doc = await openFixture$
|
|
964
|
+
const doc = await openFixture$18(engine, opts);
|
|
754
965
|
try {
|
|
755
966
|
const page = doc.page(fix.pageObjectNumber);
|
|
756
967
|
const plainDraft = {
|
|
@@ -829,7 +1040,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
829
1040
|
}
|
|
830
1041
|
});
|
|
831
1042
|
test("update echoes the appearance verdict: moves preserve /AP, restyles re-bake", async () => {
|
|
832
|
-
const doc = await openFixture$
|
|
1043
|
+
const doc = await openFixture$18(engine, opts);
|
|
833
1044
|
try {
|
|
834
1045
|
const page = doc.page(fix.pageObjectNumber);
|
|
835
1046
|
const draft = {
|
|
@@ -904,7 +1115,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
904
1115
|
}
|
|
905
1116
|
});
|
|
906
1117
|
test("a partial /DA patch preserves the unpatched font members", async () => {
|
|
907
|
-
const doc = await openFixture$
|
|
1118
|
+
const doc = await openFixture$18(engine, opts);
|
|
908
1119
|
try {
|
|
909
1120
|
const page = doc.page(fix.pageObjectNumber);
|
|
910
1121
|
const draft = {
|
|
@@ -960,7 +1171,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
960
1171
|
}
|
|
961
1172
|
});
|
|
962
1173
|
test("box transform is tri-state: rect-only moves keep rotation, null flattens", async () => {
|
|
963
|
-
const doc = await openFixture$
|
|
1174
|
+
const doc = await openFixture$18(engine, opts);
|
|
964
1175
|
try {
|
|
965
1176
|
const page = doc.page(fix.pageObjectNumber);
|
|
966
1177
|
const draft = {
|
|
@@ -1021,7 +1232,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1021
1232
|
}
|
|
1022
1233
|
});
|
|
1023
1234
|
test("create vertex + line annotations (polygon/polyline/line) round-trip geometry", async () => {
|
|
1024
|
-
const doc = await openFixture$
|
|
1235
|
+
const doc = await openFixture$18(engine, opts);
|
|
1025
1236
|
try {
|
|
1026
1237
|
const page = doc.page(fix.pageObjectNumber);
|
|
1027
1238
|
const polygonDraft = {
|
|
@@ -1152,7 +1363,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1152
1363
|
}
|
|
1153
1364
|
});
|
|
1154
1365
|
test("create free-text + callout round-trip text/colour/intent fields", async () => {
|
|
1155
|
-
const doc = await openFixture$
|
|
1366
|
+
const doc = await openFixture$18(engine, opts);
|
|
1156
1367
|
try {
|
|
1157
1368
|
const page = doc.page(fix.pageObjectNumber);
|
|
1158
1369
|
const freeTextDraft = {
|
|
@@ -1248,7 +1459,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1248
1459
|
}
|
|
1249
1460
|
});
|
|
1250
1461
|
test("update a free-text patches alignment + colours and is non-structural", async () => {
|
|
1251
|
-
const doc = await openFixture$
|
|
1462
|
+
const doc = await openFixture$18(engine, opts);
|
|
1252
1463
|
try {
|
|
1253
1464
|
const page = doc.page(fix.pageObjectNumber);
|
|
1254
1465
|
const created = await page.annotations.create({
|
|
@@ -1309,7 +1520,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1309
1520
|
}
|
|
1310
1521
|
});
|
|
1311
1522
|
test("create redact (area + text) round-trips label + colour fields", async () => {
|
|
1312
|
-
const doc = await openFixture$
|
|
1523
|
+
const doc = await openFixture$18(engine, opts);
|
|
1313
1524
|
try {
|
|
1314
1525
|
const page = doc.page(fix.pageObjectNumber);
|
|
1315
1526
|
const areaDraft = {
|
|
@@ -1389,7 +1600,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1389
1600
|
}
|
|
1390
1601
|
});
|
|
1391
1602
|
test("update a redact patches the label and clears it, non-structurally", async () => {
|
|
1392
|
-
const doc = await openFixture$
|
|
1603
|
+
const doc = await openFixture$18(engine, opts);
|
|
1393
1604
|
try {
|
|
1394
1605
|
const page = doc.page(fix.pageObjectNumber);
|
|
1395
1606
|
const created = await page.annotations.create({
|
|
@@ -1466,7 +1677,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1466
1677
|
}
|
|
1467
1678
|
});
|
|
1468
1679
|
test("create + update a caret round-trips color/opacity/rect differences", async () => {
|
|
1469
|
-
const doc = await openFixture$
|
|
1680
|
+
const doc = await openFixture$18(engine, opts);
|
|
1470
1681
|
try {
|
|
1471
1682
|
const page = doc.page(fix.pageObjectNumber);
|
|
1472
1683
|
const caretDraft = {
|
|
@@ -1546,7 +1757,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1546
1757
|
}
|
|
1547
1758
|
});
|
|
1548
1759
|
test("update an ink annotation patches strokes + color and is non-structural", async () => {
|
|
1549
|
-
const doc = await openFixture$
|
|
1760
|
+
const doc = await openFixture$18(engine, opts);
|
|
1550
1761
|
try {
|
|
1551
1762
|
const page = doc.page(fix.pageObjectNumber);
|
|
1552
1763
|
const created = await page.annotations.create({
|
|
@@ -1597,7 +1808,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1597
1808
|
}
|
|
1598
1809
|
});
|
|
1599
1810
|
test("ink highlight intent + blend round-trip and unrelated patches preserve blend", async () => {
|
|
1600
|
-
const doc = await openFixture$
|
|
1811
|
+
const doc = await openFixture$18(engine, opts);
|
|
1601
1812
|
try {
|
|
1602
1813
|
const page = doc.page(fix.pageObjectNumber);
|
|
1603
1814
|
const created = await page.annotations.create({
|
|
@@ -1640,7 +1851,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1640
1851
|
}
|
|
1641
1852
|
});
|
|
1642
1853
|
test("update a polyline patches vertices + line endings and is non-structural", async () => {
|
|
1643
|
-
const doc = await openFixture$
|
|
1854
|
+
const doc = await openFixture$18(engine, opts);
|
|
1644
1855
|
try {
|
|
1645
1856
|
const page = doc.page(fix.pageObjectNumber);
|
|
1646
1857
|
const created = await page.annotations.create({
|
|
@@ -1689,7 +1900,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1689
1900
|
}
|
|
1690
1901
|
});
|
|
1691
1902
|
test("update a shape annotation patches color and is non-structural", async () => {
|
|
1692
|
-
const doc = await openFixture$
|
|
1903
|
+
const doc = await openFixture$18(engine, opts);
|
|
1693
1904
|
try {
|
|
1694
1905
|
const page = doc.page(fix.pageObjectNumber);
|
|
1695
1906
|
const created = await page.annotations.create({
|
|
@@ -1738,7 +1949,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1738
1949
|
}
|
|
1739
1950
|
});
|
|
1740
1951
|
if (opts.supportsAppearanceRasters) test("creating a shape bakes an /AP appearance the reader can rasterize", async () => {
|
|
1741
|
-
const doc = await openFixture$
|
|
1952
|
+
const doc = await openFixture$18(engine, opts);
|
|
1742
1953
|
try {
|
|
1743
1954
|
const page = doc.page(fix.pageObjectNumber);
|
|
1744
1955
|
const created = await page.annotations.create({
|
|
@@ -1768,7 +1979,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1768
1979
|
}
|
|
1769
1980
|
});
|
|
1770
1981
|
test("update on a durable annotation is non-structural and never touches /NM", async () => {
|
|
1771
|
-
const doc = await openFixture$
|
|
1982
|
+
const doc = await openFixture$18(engine, opts);
|
|
1772
1983
|
try {
|
|
1773
1984
|
const page = doc.page(fix.pageObjectNumber);
|
|
1774
1985
|
const before = await page.annotations.list();
|
|
@@ -1794,7 +2005,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1794
2005
|
}
|
|
1795
2006
|
});
|
|
1796
2007
|
if (fix.expectsWeakAnnotation) test("update on a weak annotation stamps a UUID v4 /NM and upgrades the ref", async () => {
|
|
1797
|
-
const doc = await openFixture$
|
|
2008
|
+
const doc = await openFixture$18(engine, opts);
|
|
1798
2009
|
try {
|
|
1799
2010
|
const page = doc.page(fix.pageObjectNumber);
|
|
1800
2011
|
const before = await page.annotations.list();
|
|
@@ -1824,7 +2035,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1824
2035
|
}
|
|
1825
2036
|
});
|
|
1826
2037
|
test("delete by objectNumber removes the annotation and reports a stable id", async () => {
|
|
1827
|
-
const doc = await openFixture$
|
|
2038
|
+
const doc = await openFixture$18(engine, opts);
|
|
1828
2039
|
try {
|
|
1829
2040
|
const page = doc.page(fix.pageObjectNumber);
|
|
1830
2041
|
const draft = {
|
|
@@ -1854,7 +2065,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1854
2065
|
}
|
|
1855
2066
|
});
|
|
1856
2067
|
if (fix.expectsWeakAnnotation) test("delete by index of a weak annotation reports deleted: null and refetch reason", async () => {
|
|
1857
|
-
const doc = await openFixture$
|
|
2068
|
+
const doc = await openFixture$18(engine, opts);
|
|
1858
2069
|
try {
|
|
1859
2070
|
const page = doc.page(fix.pageObjectNumber);
|
|
1860
2071
|
const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -1877,7 +2088,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1877
2088
|
}
|
|
1878
2089
|
});
|
|
1879
2090
|
test("abort on create rejects with AbortError", async () => {
|
|
1880
|
-
const doc = await openFixture$
|
|
2091
|
+
const doc = await openFixture$18(engine, opts);
|
|
1881
2092
|
try {
|
|
1882
2093
|
const page = doc.page(fix.pageObjectNumber);
|
|
1883
2094
|
const draft = {
|
|
@@ -1893,7 +2104,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1893
2104
|
}
|
|
1894
2105
|
});
|
|
1895
2106
|
test("update with a stale index revision throws InvalidReference", async () => {
|
|
1896
|
-
const doc = await openFixture$
|
|
2107
|
+
const doc = await openFixture$18(engine, opts);
|
|
1897
2108
|
try {
|
|
1898
2109
|
const page = doc.page(fix.pageObjectNumber);
|
|
1899
2110
|
const weak = (await page.annotations.list()).annotations.find((a) => a.identityQuality === "weak");
|
|
@@ -1920,7 +2131,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1920
2131
|
}
|
|
1921
2132
|
});
|
|
1922
2133
|
test("move single durable annotation reorders within the page (single-as-batch)", async () => {
|
|
1923
|
-
const doc = await openFixture$
|
|
2134
|
+
const doc = await openFixture$18(engine, opts);
|
|
1924
2135
|
try {
|
|
1925
2136
|
const page = doc.page(fix.pageObjectNumber);
|
|
1926
2137
|
const aDraft = {
|
|
@@ -1964,7 +2175,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1964
2175
|
}
|
|
1965
2176
|
});
|
|
1966
2177
|
test("move multi-block preserves caller-supplied order at the destination", async () => {
|
|
1967
|
-
const doc = await openFixture$
|
|
2178
|
+
const doc = await openFixture$18(engine, opts);
|
|
1968
2179
|
try {
|
|
1969
2180
|
const page = doc.page(fix.pageObjectNumber);
|
|
1970
2181
|
const ids = await Promise.all([
|
|
@@ -2003,7 +2214,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2003
2214
|
}
|
|
2004
2215
|
});
|
|
2005
2216
|
if (fix.expectsWeakAnnotation) test("move on a weak annotation upgrades it to durable /NM (one rev bump for batch)", async () => {
|
|
2006
|
-
const doc = await openFixture$
|
|
2217
|
+
const doc = await openFixture$18(engine, opts);
|
|
2007
2218
|
try {
|
|
2008
2219
|
const page = doc.page(fix.pageObjectNumber);
|
|
2009
2220
|
const before = await page.annotations.list();
|
|
@@ -2028,7 +2239,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2028
2239
|
}
|
|
2029
2240
|
});
|
|
2030
2241
|
test("move with a stale index revision rejects (locked rev-token guard)", async () => {
|
|
2031
|
-
const doc = await openFixture$
|
|
2242
|
+
const doc = await openFixture$18(engine, opts);
|
|
2032
2243
|
try {
|
|
2033
2244
|
const page = doc.page(fix.pageObjectNumber);
|
|
2034
2245
|
const a = await page.annotations.create({
|
|
@@ -2066,7 +2277,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2066
2277
|
}
|
|
2067
2278
|
});
|
|
2068
2279
|
test("move with out-of-range toIndex rejects with InvalidArg", async () => {
|
|
2069
|
-
const doc = await openFixture$
|
|
2280
|
+
const doc = await openFixture$18(engine, opts);
|
|
2070
2281
|
try {
|
|
2071
2282
|
const page = doc.page(fix.pageObjectNumber);
|
|
2072
2283
|
const a = await page.annotations.create({
|
|
@@ -2090,7 +2301,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2090
2301
|
}
|
|
2091
2302
|
});
|
|
2092
2303
|
test("move with duplicate refs rejects with InvalidArg", async () => {
|
|
2093
|
-
const doc = await openFixture$
|
|
2304
|
+
const doc = await openFixture$18(engine, opts);
|
|
2094
2305
|
try {
|
|
2095
2306
|
const page = doc.page(fix.pageObjectNumber);
|
|
2096
2307
|
const a = await page.annotations.create({
|
|
@@ -2113,7 +2324,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2113
2324
|
}
|
|
2114
2325
|
});
|
|
2115
2326
|
test("abort on move rejects with AbortError", async () => {
|
|
2116
|
-
const doc = await openFixture$
|
|
2327
|
+
const doc = await openFixture$18(engine, opts);
|
|
2117
2328
|
try {
|
|
2118
2329
|
const page = doc.page(fix.pageObjectNumber);
|
|
2119
2330
|
const a = await page.annotations.create({
|
|
@@ -2134,7 +2345,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2134
2345
|
}
|
|
2135
2346
|
});
|
|
2136
2347
|
test("a page move does NOT bump per-page RevisionTokens (weak refs survive reorder)", async () => {
|
|
2137
|
-
const doc = await openFixture$
|
|
2348
|
+
const doc = await openFixture$18(engine, opts);
|
|
2138
2349
|
try {
|
|
2139
2350
|
const list = await doc.pages.list();
|
|
2140
2351
|
if (list.pages.length < 1) return;
|
|
@@ -2149,7 +2360,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2149
2360
|
}
|
|
2150
2361
|
});
|
|
2151
2362
|
test("create a reply links /IRT and defaults /RT to \"reply\", reporting the parent", async () => {
|
|
2152
|
-
const doc = await openFixture$
|
|
2363
|
+
const doc = await openFixture$18(engine, opts);
|
|
2153
2364
|
try {
|
|
2154
2365
|
const page = doc.page(fix.pageObjectNumber);
|
|
2155
2366
|
const parent = await page.annotations.create({
|
|
@@ -2183,7 +2394,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2183
2394
|
}
|
|
2184
2395
|
});
|
|
2185
2396
|
test("create a grouped subordinate writes /RT /Group", async () => {
|
|
2186
|
-
const doc = await openFixture$
|
|
2397
|
+
const doc = await openFixture$18(engine, opts);
|
|
2187
2398
|
try {
|
|
2188
2399
|
const page = doc.page(fix.pageObjectNumber);
|
|
2189
2400
|
const primary = await page.annotations.create({
|
|
@@ -2214,7 +2425,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2214
2425
|
}
|
|
2215
2426
|
});
|
|
2216
2427
|
test("create link annotations round-trip uri, goto/xyz, goto/fitH, and dead targets", async () => {
|
|
2217
|
-
const doc = await openFixture$
|
|
2428
|
+
const doc = await openFixture$18(engine, opts);
|
|
2218
2429
|
try {
|
|
2219
2430
|
const page = doc.page(fix.pageObjectNumber);
|
|
2220
2431
|
const uri = await page.annotations.create({
|
|
@@ -2291,7 +2502,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2291
2502
|
}
|
|
2292
2503
|
});
|
|
2293
2504
|
test("a link patch retargets in both directions (uri→goto, goto→uri) and moves the rect", async () => {
|
|
2294
|
-
const doc = await openFixture$
|
|
2505
|
+
const doc = await openFixture$18(engine, opts);
|
|
2295
2506
|
try {
|
|
2296
2507
|
const page = doc.page(fix.pageObjectNumber);
|
|
2297
2508
|
const created = await page.annotations.create({
|
|
@@ -2346,7 +2557,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2346
2557
|
}
|
|
2347
2558
|
});
|
|
2348
2559
|
test("a link patch clears the target with null — a dead link on re-read", async () => {
|
|
2349
|
-
const doc = await openFixture$
|
|
2560
|
+
const doc = await openFixture$18(engine, opts);
|
|
2350
2561
|
try {
|
|
2351
2562
|
const page = doc.page(fix.pageObjectNumber);
|
|
2352
2563
|
const created = await page.annotations.create({
|
|
@@ -2385,7 +2596,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2385
2596
|
}
|
|
2386
2597
|
});
|
|
2387
2598
|
test("a link grouped to a highlight round-trips /IRT + /RT /Group with its target", async () => {
|
|
2388
|
-
const doc = await openFixture$
|
|
2599
|
+
const doc = await openFixture$18(engine, opts);
|
|
2389
2600
|
try {
|
|
2390
2601
|
const page = doc.page(fix.pageObjectNumber);
|
|
2391
2602
|
const parent = await page.annotations.create({
|
|
@@ -2419,7 +2630,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2419
2630
|
}
|
|
2420
2631
|
});
|
|
2421
2632
|
test("replace-text round-trips /IT and groups StrikeOut under its Caret", async () => {
|
|
2422
|
-
const doc = await openFixture$
|
|
2633
|
+
const doc = await openFixture$18(engine, opts);
|
|
2423
2634
|
try {
|
|
2424
2635
|
const page = doc.page(fix.pageObjectNumber);
|
|
2425
2636
|
const caret = await page.annotations.create({
|
|
@@ -2471,7 +2682,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2471
2682
|
}
|
|
2472
2683
|
});
|
|
2473
2684
|
test("patch inReplyTo: null clears /IRT and /RT (back to top-level)", async () => {
|
|
2474
|
-
const doc = await openFixture$
|
|
2685
|
+
const doc = await openFixture$18(engine, opts);
|
|
2475
2686
|
try {
|
|
2476
2687
|
const page = doc.page(fix.pageObjectNumber);
|
|
2477
2688
|
const parent = await page.annotations.create({
|
|
@@ -2498,7 +2709,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2498
2709
|
}
|
|
2499
2710
|
});
|
|
2500
2711
|
test("create with a cross-page /IRT parent throws InvalidArg", async () => {
|
|
2501
|
-
const doc = await openFixture$
|
|
2712
|
+
const doc = await openFixture$18(engine, opts);
|
|
2502
2713
|
try {
|
|
2503
2714
|
const page = doc.page(fix.pageObjectNumber);
|
|
2504
2715
|
const parent = await page.annotations.create({
|
|
@@ -2529,7 +2740,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2529
2740
|
}
|
|
2530
2741
|
});
|
|
2531
2742
|
test("a review-status reply round-trips /State + /StateModel + /Subj", async () => {
|
|
2532
|
-
const doc = await openFixture$
|
|
2743
|
+
const doc = await openFixture$18(engine, opts);
|
|
2533
2744
|
try {
|
|
2534
2745
|
const page = doc.page(fix.pageObjectNumber);
|
|
2535
2746
|
const target = await page.annotations.create({
|
|
@@ -2563,7 +2774,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2563
2774
|
}
|
|
2564
2775
|
});
|
|
2565
2776
|
test("a draft /State without /StateModel is rejected with InvalidArg", async () => {
|
|
2566
|
-
const doc = await openFixture$
|
|
2777
|
+
const doc = await openFixture$18(engine, opts);
|
|
2567
2778
|
try {
|
|
2568
2779
|
const page = doc.page(fix.pageObjectNumber);
|
|
2569
2780
|
let caught;
|
|
@@ -2582,7 +2793,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2582
2793
|
}
|
|
2583
2794
|
});
|
|
2584
2795
|
test("null-clear patches truly remove /State, /StateModel, /Subj and /Contents", async () => {
|
|
2585
|
-
const doc = await openFixture$
|
|
2796
|
+
const doc = await openFixture$18(engine, opts);
|
|
2586
2797
|
try {
|
|
2587
2798
|
const page = doc.page(fix.pageObjectNumber);
|
|
2588
2799
|
const note = await page.annotations.create({
|
|
@@ -2629,7 +2840,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2629
2840
|
}
|
|
2630
2841
|
});
|
|
2631
2842
|
test("custom state models round-trip verbatim", async () => {
|
|
2632
|
-
const doc = await openFixture$
|
|
2843
|
+
const doc = await openFixture$18(engine, opts);
|
|
2633
2844
|
try {
|
|
2634
2845
|
const page = doc.page(fix.pageObjectNumber);
|
|
2635
2846
|
const custom = await page.annotations.create({
|
|
@@ -2657,7 +2868,7 @@ async function beginWeakEditIfRequired(doc, pageObjectNumber, fix) {
|
|
|
2657
2868
|
if (doc.capabilities.weakAnnotationEditSessions !== "required" || !fix.expectsWeakAnnotation) return null;
|
|
2658
2869
|
return doc.annotations.beginWeakEdit([pageObjectNumber]);
|
|
2659
2870
|
}
|
|
2660
|
-
async function openFixture$
|
|
2871
|
+
async function openFixture$18(engine, opts) {
|
|
2661
2872
|
if (opts.openKind === "bytes") {
|
|
2662
2873
|
const bytes = await opts.fixture.bytes();
|
|
2663
2874
|
return engine.open({
|
|
@@ -3247,7 +3458,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3247
3458
|
if (engine) await engine.destroy();
|
|
3248
3459
|
});
|
|
3249
3460
|
test("renders the expected set of appearances with valid output", async () => {
|
|
3250
|
-
const doc = await openFixture$
|
|
3461
|
+
const doc = await openFixture$17(engine, opts);
|
|
3251
3462
|
try {
|
|
3252
3463
|
const { pageState, appearances } = await collect(doc, opts, useRaw);
|
|
3253
3464
|
expect(pageState.pageObjectNumber).toBe(opts.fixture.pageObjectNumber);
|
|
@@ -3274,7 +3485,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3274
3485
|
}
|
|
3275
3486
|
});
|
|
3276
3487
|
if (opts.fixture.expectsWeakAppearance) test("weak (index-only) annotations are emitted, not dropped", async () => {
|
|
3277
|
-
const doc = await openFixture$
|
|
3488
|
+
const doc = await openFixture$17(engine, opts);
|
|
3278
3489
|
try {
|
|
3279
3490
|
const { appearances } = await collect(doc, opts, useRaw);
|
|
3280
3491
|
const weak = appearances.find((a) => a.ref.kind === "index");
|
|
@@ -3284,7 +3495,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3284
3495
|
}
|
|
3285
3496
|
});
|
|
3286
3497
|
if (useRaw) test("rendered appearances are not blank (non-zero alpha)", async () => {
|
|
3287
|
-
const doc = await openFixture$
|
|
3498
|
+
const doc = await openFixture$17(engine, opts);
|
|
3288
3499
|
try {
|
|
3289
3500
|
const { appearances } = await collect(doc, opts, useRaw);
|
|
3290
3501
|
const anyVisible = appearances.some((a) => a.raster !== null && hasOpaquePixel(a.raster));
|
|
@@ -3294,7 +3505,7 @@ function runAnnotationAppearanceConformance(runner, opts) {
|
|
|
3294
3505
|
}
|
|
3295
3506
|
});
|
|
3296
3507
|
test("abort() rejects with AbortError", async () => {
|
|
3297
|
-
const doc = await openFixture$
|
|
3508
|
+
const doc = await openFixture$17(engine, opts);
|
|
3298
3509
|
try {
|
|
3299
3510
|
const page = doc.page(opts.fixture.pageObjectNumber);
|
|
3300
3511
|
const p = useRaw ? page.annotations.renderAppearances({ scale: 1 }) : page.annotations.renderAppearanceImages({
|
|
@@ -3349,7 +3560,7 @@ function hasOpaquePixel(raster) {
|
|
|
3349
3560
|
}
|
|
3350
3561
|
return false;
|
|
3351
3562
|
}
|
|
3352
|
-
async function openFixture$
|
|
3563
|
+
async function openFixture$17(engine, opts) {
|
|
3353
3564
|
if (opts.openKind === "bytes") {
|
|
3354
3565
|
const bytes = await opts.fixture.bytes();
|
|
3355
3566
|
return engine.open({
|
|
@@ -3418,7 +3629,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3418
3629
|
if (engine) await engine.destroy();
|
|
3419
3630
|
});
|
|
3420
3631
|
test("pages.list() returns every page in display order, durable PONs only", async () => {
|
|
3421
|
-
const doc = await openFixture$
|
|
3632
|
+
const doc = await openFixture$16(engine, opts);
|
|
3422
3633
|
try {
|
|
3423
3634
|
const list = await doc.pages.list();
|
|
3424
3635
|
expect(require_schemas.PageListSnapshotSchema.safeParse(list).success).toBe(true);
|
|
@@ -3437,7 +3648,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3437
3648
|
}
|
|
3438
3649
|
});
|
|
3439
3650
|
test("pages.move() reorders pages and returns the full post-move order", async () => {
|
|
3440
|
-
const doc = await openFixture$
|
|
3651
|
+
const doc = await openFixture$16(engine, opts);
|
|
3441
3652
|
try {
|
|
3442
3653
|
const before = await doc.pages.list();
|
|
3443
3654
|
if (before.pages.length < 3) return;
|
|
@@ -3461,7 +3672,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3461
3672
|
}
|
|
3462
3673
|
});
|
|
3463
3674
|
test("weak index-based annotation refs survive a page reorder", async () => {
|
|
3464
|
-
const doc = await openFixture$
|
|
3675
|
+
const doc = await openFixture$16(engine, opts);
|
|
3465
3676
|
try {
|
|
3466
3677
|
const list = await doc.pages.list();
|
|
3467
3678
|
if (list.pages.length < 2) return;
|
|
@@ -3498,7 +3709,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3498
3709
|
}
|
|
3499
3710
|
});
|
|
3500
3711
|
test("pages.move() rejects duplicate PONs with InvalidArg", async () => {
|
|
3501
|
-
const doc = await openFixture$
|
|
3712
|
+
const doc = await openFixture$16(engine, opts);
|
|
3502
3713
|
try {
|
|
3503
3714
|
const list = await doc.pages.list();
|
|
3504
3715
|
if (list.pages.length < 1) return;
|
|
@@ -3515,7 +3726,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3515
3726
|
}
|
|
3516
3727
|
});
|
|
3517
3728
|
test("pages.move() rejects out-of-range destIndex with InvalidArg", async () => {
|
|
3518
|
-
const doc = await openFixture$
|
|
3729
|
+
const doc = await openFixture$16(engine, opts);
|
|
3519
3730
|
try {
|
|
3520
3731
|
const list = await doc.pages.list();
|
|
3521
3732
|
if (list.pages.length < 1) return;
|
|
@@ -3532,7 +3743,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3532
3743
|
}
|
|
3533
3744
|
});
|
|
3534
3745
|
test("pages.move() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3535
|
-
const doc = await openFixture$
|
|
3746
|
+
const doc = await openFixture$16(engine, opts);
|
|
3536
3747
|
try {
|
|
3537
3748
|
const list = await doc.pages.list();
|
|
3538
3749
|
let bogus = 0;
|
|
@@ -3550,7 +3761,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3550
3761
|
}
|
|
3551
3762
|
});
|
|
3552
3763
|
test("abort on pages.move() rejects with AbortError", async () => {
|
|
3553
|
-
const doc = await openFixture$
|
|
3764
|
+
const doc = await openFixture$16(engine, opts);
|
|
3554
3765
|
try {
|
|
3555
3766
|
const list = await doc.pages.list();
|
|
3556
3767
|
if (list.pages.length < 1) return;
|
|
@@ -3564,7 +3775,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
3564
3775
|
});
|
|
3565
3776
|
});
|
|
3566
3777
|
}
|
|
3567
|
-
async function openFixture$
|
|
3778
|
+
async function openFixture$16(engine, opts) {
|
|
3568
3779
|
if (opts.openKind === "bytes") {
|
|
3569
3780
|
const bytes = await opts.fixture.bytes();
|
|
3570
3781
|
return engine.open({
|
|
@@ -3638,7 +3849,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3638
3849
|
if (engine) await engine.destroy();
|
|
3639
3850
|
});
|
|
3640
3851
|
test("pages.rotate() sets the absolute rotation and returns the full layout", async () => {
|
|
3641
|
-
const doc = await openFixture$
|
|
3852
|
+
const doc = await openFixture$15(engine, opts);
|
|
3642
3853
|
try {
|
|
3643
3854
|
const before = await doc.pages.list();
|
|
3644
3855
|
const target = before.pages[0];
|
|
@@ -3657,7 +3868,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3657
3868
|
}
|
|
3658
3869
|
});
|
|
3659
3870
|
test("absolute rotation is idempotent: setting the same value twice is a no-op", async () => {
|
|
3660
|
-
const doc = await openFixture$
|
|
3871
|
+
const doc = await openFixture$15(engine, opts);
|
|
3661
3872
|
try {
|
|
3662
3873
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3663
3874
|
const first = await doc.pages.rotate([pon], 180);
|
|
@@ -3668,7 +3879,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3668
3879
|
}
|
|
3669
3880
|
});
|
|
3670
3881
|
test("one rotation applies to EVERY listed page (the multi-select gesture)", async () => {
|
|
3671
|
-
const doc = await openFixture$
|
|
3882
|
+
const doc = await openFixture$15(engine, opts);
|
|
3672
3883
|
try {
|
|
3673
3884
|
const list = await doc.pages.list();
|
|
3674
3885
|
if (list.pages.length < 2) return;
|
|
@@ -3680,7 +3891,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3680
3891
|
}
|
|
3681
3892
|
});
|
|
3682
3893
|
test("weak index-based annotation refs survive a rotate (no revision bump)", async () => {
|
|
3683
|
-
const doc = await openFixture$
|
|
3894
|
+
const doc = await openFixture$15(engine, opts);
|
|
3684
3895
|
try {
|
|
3685
3896
|
const hostPon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3686
3897
|
const hostPage = doc.page(hostPon);
|
|
@@ -3710,7 +3921,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3710
3921
|
}
|
|
3711
3922
|
});
|
|
3712
3923
|
test("pages.rotate() rejects an invalid rotation value with InvalidArg", async () => {
|
|
3713
|
-
const doc = await openFixture$
|
|
3924
|
+
const doc = await openFixture$15(engine, opts);
|
|
3714
3925
|
try {
|
|
3715
3926
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3716
3927
|
let caught;
|
|
@@ -3725,7 +3936,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3725
3936
|
}
|
|
3726
3937
|
});
|
|
3727
3938
|
test("pages.rotate() rejects duplicate PONs with InvalidArg", async () => {
|
|
3728
|
-
const doc = await openFixture$
|
|
3939
|
+
const doc = await openFixture$15(engine, opts);
|
|
3729
3940
|
try {
|
|
3730
3941
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3731
3942
|
let caught;
|
|
@@ -3740,7 +3951,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3740
3951
|
}
|
|
3741
3952
|
});
|
|
3742
3953
|
test("pages.rotate() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3743
|
-
const doc = await openFixture$
|
|
3954
|
+
const doc = await openFixture$15(engine, opts);
|
|
3744
3955
|
try {
|
|
3745
3956
|
const list = await doc.pages.list();
|
|
3746
3957
|
let bogus = 0;
|
|
@@ -3758,7 +3969,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3758
3969
|
}
|
|
3759
3970
|
});
|
|
3760
3971
|
test("abort on pages.rotate() rejects with AbortError", async () => {
|
|
3761
|
-
const doc = await openFixture$
|
|
3972
|
+
const doc = await openFixture$15(engine, opts);
|
|
3762
3973
|
try {
|
|
3763
3974
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3764
3975
|
const p = doc.pages.rotate([pon], 90);
|
|
@@ -3770,7 +3981,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
3770
3981
|
});
|
|
3771
3982
|
});
|
|
3772
3983
|
}
|
|
3773
|
-
async function openFixture$
|
|
3984
|
+
async function openFixture$15(engine, opts) {
|
|
3774
3985
|
if (opts.openKind === "bytes") {
|
|
3775
3986
|
const bytes = await opts.fixture.bytes();
|
|
3776
3987
|
return engine.open({
|
|
@@ -3833,7 +4044,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3833
4044
|
if (engine) await engine.destroy();
|
|
3834
4045
|
});
|
|
3835
4046
|
test("pages.delete() removes the page and returns the surviving layout", async () => {
|
|
3836
|
-
const doc = await openFixture$
|
|
4047
|
+
const doc = await openFixture$14(engine, opts);
|
|
3837
4048
|
try {
|
|
3838
4049
|
const before = await doc.pages.list();
|
|
3839
4050
|
if (before.pages.length < 2) return;
|
|
@@ -3854,7 +4065,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3854
4065
|
}
|
|
3855
4066
|
});
|
|
3856
4067
|
test("addressing a deleted page afterwards is a clean NotFound", async () => {
|
|
3857
|
-
const doc = await openFixture$
|
|
4068
|
+
const doc = await openFixture$14(engine, opts);
|
|
3858
4069
|
try {
|
|
3859
4070
|
const before = await doc.pages.list();
|
|
3860
4071
|
if (before.pages.length < 2) return;
|
|
@@ -3872,7 +4083,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3872
4083
|
}
|
|
3873
4084
|
});
|
|
3874
4085
|
test("surviving pages keep their weak index-based annotation refs", async () => {
|
|
3875
|
-
const doc = await openFixture$
|
|
4086
|
+
const doc = await openFixture$14(engine, opts);
|
|
3876
4087
|
try {
|
|
3877
4088
|
const list = await doc.pages.list();
|
|
3878
4089
|
if (list.pages.length < 2) return;
|
|
@@ -3905,7 +4116,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3905
4116
|
}
|
|
3906
4117
|
});
|
|
3907
4118
|
test("deleting EVERY page is rejected with InvalidArg", async () => {
|
|
3908
|
-
const doc = await openFixture$
|
|
4119
|
+
const doc = await openFixture$14(engine, opts);
|
|
3909
4120
|
try {
|
|
3910
4121
|
const list = await doc.pages.list();
|
|
3911
4122
|
let caught;
|
|
@@ -3920,7 +4131,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3920
4131
|
}
|
|
3921
4132
|
});
|
|
3922
4133
|
test("pages.delete() rejects duplicate PONs with InvalidArg", async () => {
|
|
3923
|
-
const doc = await openFixture$
|
|
4134
|
+
const doc = await openFixture$14(engine, opts);
|
|
3924
4135
|
try {
|
|
3925
4136
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
3926
4137
|
let caught;
|
|
@@ -3935,7 +4146,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3935
4146
|
}
|
|
3936
4147
|
});
|
|
3937
4148
|
test("pages.delete() rejects unknown PON with NotFound or InvalidArg", async () => {
|
|
3938
|
-
const doc = await openFixture$
|
|
4149
|
+
const doc = await openFixture$14(engine, opts);
|
|
3939
4150
|
try {
|
|
3940
4151
|
const list = await doc.pages.list();
|
|
3941
4152
|
let bogus = 0;
|
|
@@ -3953,7 +4164,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3953
4164
|
}
|
|
3954
4165
|
});
|
|
3955
4166
|
test("abort on pages.delete() rejects with AbortError", async () => {
|
|
3956
|
-
const doc = await openFixture$
|
|
4167
|
+
const doc = await openFixture$14(engine, opts);
|
|
3957
4168
|
try {
|
|
3958
4169
|
const list = await doc.pages.list();
|
|
3959
4170
|
if (list.pages.length < 2) return;
|
|
@@ -3967,7 +4178,224 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
3967
4178
|
});
|
|
3968
4179
|
});
|
|
3969
4180
|
}
|
|
3970
|
-
async function openFixture$
|
|
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) {
|
|
3971
4399
|
if (opts.openKind === "bytes") {
|
|
3972
4400
|
const bytes = await opts.fixture.bytes();
|
|
3973
4401
|
return engine.open({
|
|
@@ -3982,6 +4410,243 @@ async function openFixture$11(engine, opts) {
|
|
|
3982
4410
|
});
|
|
3983
4411
|
}
|
|
3984
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
|
|
3985
4650
|
//#region src/conformance/runPageFlattenConformance.ts
|
|
3986
4651
|
/** Transport-neutral coverage for the content + annotation flatten rail. */
|
|
3987
4652
|
function runPageFlattenConformance(runner, opts) {
|
|
@@ -6015,12 +6680,15 @@ exports.diffAnnotationListSnapshot = diffAnnotationListSnapshot;
|
|
|
6015
6680
|
exports.diffAnnotationListSnapshotAll = diffAnnotationListSnapshotAll;
|
|
6016
6681
|
exports.runActionsConformance = runActionsConformance;
|
|
6017
6682
|
exports.runAnnotationAppearanceConformance = runAnnotationAppearanceConformance;
|
|
6683
|
+
exports.runAnnotationAppearanceExportConformance = runAnnotationAppearanceExportConformance;
|
|
6684
|
+
exports.runAnnotationFlattenConformance = runAnnotationFlattenConformance;
|
|
6018
6685
|
exports.runAnnotationMutationConformance = runAnnotationMutationConformance;
|
|
6019
6686
|
exports.runAnnotationReadConformance = runAnnotationReadConformance;
|
|
6020
6687
|
exports.runAttachmentConformance = runAttachmentConformance;
|
|
6021
6688
|
exports.runDocumentEventsConformance = runDocumentEventsConformance;
|
|
6022
6689
|
exports.runFormConformance = runFormConformance;
|
|
6023
6690
|
exports.runMetadataConformance = runMetadataConformance;
|
|
6691
|
+
exports.runNamedPagesConformance = runNamedPagesConformance;
|
|
6024
6692
|
exports.runPageDeleteConformance = runPageDeleteConformance;
|
|
6025
6693
|
exports.runPageExtractConformance = runPageExtractConformance;
|
|
6026
6694
|
exports.runPageFlattenConformance = runPageFlattenConformance;
|