@embedpdf/engine-core 3.0.0-next.13 → 3.0.0-next.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AbortError-DHqPBnYc.js → AbortError-DwuHPK_I.js} +2 -2
- package/dist/{AbortError-DHqPBnYc.js.map → AbortError-DwuHPK_I.js.map} +1 -1
- package/dist/{AbortError-Cq2igpZ6.cjs → AbortError-P0RU0Mgg.cjs} +4 -4
- package/dist/{AbortError-Cq2igpZ6.cjs.map → AbortError-P0RU0Mgg.cjs.map} +1 -1
- package/dist/{AnnotationListSnapshot-D3mFut1e.d.cts → AnnotationListSnapshot-D9R5n2Kf.d.cts} +237 -7
- package/dist/{AnnotationListSnapshot-D3mFut1e.d.ts → AnnotationListSnapshot-D9R5n2Kf.d.ts} +237 -7
- package/dist/{DocumentSecurityService-ClTZc0zO.d.cts → DocumentSecurityService-CIx1MT0T.d.cts} +2 -2
- package/dist/{DocumentSecurityService-_JRjqvoI.d.ts → DocumentSecurityService-Ca6EK3-3.d.ts} +2 -2
- package/dist/{Engine-Bx0NOfmd.d.cts → Engine-EWWHhEIi.d.ts} +17 -4
- package/dist/{Engine-DxtpCYcP.d.ts → Engine-FNaAEjfb.d.cts} +17 -4
- package/dist/conformance.cjs +382 -95
- package/dist/conformance.cjs.map +1 -1
- package/dist/conformance.d.cts +7 -3
- package/dist/conformance.d.ts +7 -3
- package/dist/conformance.js +302 -16
- package/dist/conformance.js.map +1 -1
- package/dist/derive-BbsDk_Kz.cjs +880 -0
- package/dist/derive-BbsDk_Kz.cjs.map +1 -0
- package/dist/derive-DAFJolWu.js +647 -0
- package/dist/derive-DAFJolWu.js.map +1 -0
- package/dist/{PageInsertBlankInput-cHq9-i-z.js → format-Bbphf4zR.js} +59 -2
- package/dist/format-Bbphf4zR.js.map +1 -0
- package/dist/{PageInsertBlankInput-CqXBmFhN.cjs → format-D_epWlob.cjs} +70 -1
- package/dist/format-D_epWlob.cjs.map +1 -0
- package/dist/index.cjs +127 -107
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/runtime.cjs +137 -117
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +29 -5
- package/dist/runtime.d.ts +29 -5
- package/dist/runtime.js +5 -5
- package/dist/{schemas-BLARNCgx.js → schemas-CFQGvWiu.js} +134 -4
- package/dist/schemas-CFQGvWiu.js.map +1 -0
- package/dist/{schemas-DIqFMmrC.cjs → schemas-D0g6tKa9.cjs} +250 -24
- package/dist/schemas-D0g6tKa9.cjs.map +1 -0
- package/dist/{builders-Bqm8yTpi.cjs → viewport-BWeNHZmb.cjs} +71 -132
- package/dist/viewport-BWeNHZmb.cjs.map +1 -0
- package/dist/{builders-Dqo2X-dt.js → viewport-CvMcadfQ.js} +39 -88
- package/dist/viewport-CvMcadfQ.js.map +1 -0
- package/dist/wire.cjs +25 -2
- package/dist/wire.cjs.map +1 -1
- package/dist/wire.d.cts +2739 -8
- package/dist/wire.d.ts +2739 -8
- package/dist/wire.js +10 -3
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/dist/PageInsertBlankInput-CqXBmFhN.cjs.map +0 -1
- package/dist/PageInsertBlankInput-cHq9-i-z.js.map +0 -1
- package/dist/builders-Bqm8yTpi.cjs.map +0 -1
- package/dist/builders-Dqo2X-dt.js.map +0 -1
- package/dist/fold-2V29cxCV.cjs +0 -447
- package/dist/fold-2V29cxCV.cjs.map +0 -1
- package/dist/fold-CdEJTBTn.js +0 -334
- package/dist/fold-CdEJTBTn.js.map +0 -1
- package/dist/schemas-BLARNCgx.js.map +0 -1
- package/dist/schemas-DIqFMmrC.cjs.map +0 -1
package/dist/conformance.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_AbortError = require("./AbortError-
|
|
5
|
-
const require_schemas = require("./schemas-
|
|
2
|
+
const require_derive = require("./derive-BbsDk_Kz.cjs");
|
|
3
|
+
const require_format = require("./format-D_epWlob.cjs");
|
|
4
|
+
const require_AbortError = require("./AbortError-P0RU0Mgg.cjs");
|
|
5
|
+
const require_schemas = require("./schemas-D0g6tKa9.cjs");
|
|
6
6
|
//#region src/conformance/runMetadataConformance.ts
|
|
7
7
|
/**
|
|
8
8
|
* The conformance harness is transport-agnostic. It takes the test runner as
|
|
@@ -60,7 +60,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
60
60
|
caught = err;
|
|
61
61
|
}
|
|
62
62
|
expect(caught).toBeTruthy();
|
|
63
|
-
expect(
|
|
63
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
64
64
|
});
|
|
65
65
|
test("update() sets standard + custom fields and a subsequent read observes them", async () => {
|
|
66
66
|
const doc = await openFixture$20(engine, opts);
|
|
@@ -104,7 +104,7 @@ function runMetadataConformance(runner, opts) {
|
|
|
104
104
|
caught = err;
|
|
105
105
|
}
|
|
106
106
|
expect(caught).toBeTruthy();
|
|
107
|
-
expect(
|
|
107
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
}
|
|
@@ -123,6 +123,270 @@ async function openFixture$20(engine, opts) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
//#endregion
|
|
126
|
+
//#region src/conformance/runMeasurementConformance.ts
|
|
127
|
+
/** Shared numerical, persistence and calibration contract for local and HTTP engines. */
|
|
128
|
+
function runMeasurementConformance(runner, opts) {
|
|
129
|
+
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
130
|
+
describe(`measurement conformance: ${opts.label}`, () => {
|
|
131
|
+
let engine;
|
|
132
|
+
beforeAll(async () => {
|
|
133
|
+
engine = await opts.makeEngine();
|
|
134
|
+
});
|
|
135
|
+
afterAll(async () => {
|
|
136
|
+
await engine?.destroy();
|
|
137
|
+
});
|
|
138
|
+
const open = async () => opts.openKind === "bytes" ? engine.open({
|
|
139
|
+
kind: "bytes",
|
|
140
|
+
id: opts.fixture.id,
|
|
141
|
+
bytes: await opts.fixture.bytes()
|
|
142
|
+
}) : engine.open({
|
|
143
|
+
kind: "id",
|
|
144
|
+
id: opts.fixture.cloudId ?? opts.fixture.id
|
|
145
|
+
});
|
|
146
|
+
const scale = require_derive.measureFromKnownLength(100, {
|
|
147
|
+
value: 3,
|
|
148
|
+
unit: "m"
|
|
149
|
+
});
|
|
150
|
+
const rect = {
|
|
151
|
+
left: 0,
|
|
152
|
+
bottom: 0,
|
|
153
|
+
right: 100,
|
|
154
|
+
top: 100
|
|
155
|
+
};
|
|
156
|
+
const vertices = [
|
|
157
|
+
{
|
|
158
|
+
x: 0,
|
|
159
|
+
y: 0
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
x: 100,
|
|
163
|
+
y: 0
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
x: 100,
|
|
167
|
+
y: 100
|
|
168
|
+
}
|
|
169
|
+
];
|
|
170
|
+
test("geometry derives contents while caption patches retain placement", async () => {
|
|
171
|
+
const doc = await open();
|
|
172
|
+
try {
|
|
173
|
+
const page = doc.page((await doc.pages.list()).pages[0].pageObjectNumber);
|
|
174
|
+
const created = (await page.annotations.create({
|
|
175
|
+
subtype: "line",
|
|
176
|
+
intent: "LineDimension",
|
|
177
|
+
rect,
|
|
178
|
+
measure: scale,
|
|
179
|
+
linePoints: {
|
|
180
|
+
start: vertices[0],
|
|
181
|
+
end: vertices[1]
|
|
182
|
+
},
|
|
183
|
+
caption: {
|
|
184
|
+
enabled: true,
|
|
185
|
+
offset: {
|
|
186
|
+
along: 10,
|
|
187
|
+
perpendicular: 20
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
})).created;
|
|
191
|
+
const inert = await page.annotations.update(created.ref, {
|
|
192
|
+
subtype: "line",
|
|
193
|
+
contents: "999 m"
|
|
194
|
+
});
|
|
195
|
+
expect(inert.updated.contents).toBe("3 m");
|
|
196
|
+
expect(inert.appearance).toEqual({
|
|
197
|
+
action: "preserved",
|
|
198
|
+
changed: false
|
|
199
|
+
});
|
|
200
|
+
const changed = await page.annotations.update(created.ref, {
|
|
201
|
+
subtype: "line",
|
|
202
|
+
linePoints: {
|
|
203
|
+
start: vertices[0],
|
|
204
|
+
end: {
|
|
205
|
+
x: 200,
|
|
206
|
+
y: 0
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
expect(changed.updated.contents).toBe("6 m");
|
|
211
|
+
expect(changed.appearance.changed).toBe(true);
|
|
212
|
+
const hidden = await page.annotations.update(created.ref, {
|
|
213
|
+
subtype: "line",
|
|
214
|
+
caption: { enabled: false }
|
|
215
|
+
});
|
|
216
|
+
expect(hidden.updated).toMatchObject({
|
|
217
|
+
contents: "6 m",
|
|
218
|
+
caption: {
|
|
219
|
+
enabled: false,
|
|
220
|
+
offset: {
|
|
221
|
+
along: 10,
|
|
222
|
+
perpendicular: 20
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
expect(hidden.appearance.changed).toBe(true);
|
|
227
|
+
const reset = await page.annotations.update(created.ref, {
|
|
228
|
+
subtype: "line",
|
|
229
|
+
caption: {
|
|
230
|
+
enabled: true,
|
|
231
|
+
offset: null
|
|
232
|
+
},
|
|
233
|
+
measure: null
|
|
234
|
+
});
|
|
235
|
+
expect(reset.updated.contents).toBe("6 m");
|
|
236
|
+
expect(reset.updated.subtype === "line" && reset.updated.caption?.offset === void 0).toBe(true);
|
|
237
|
+
expect(require_derive.measurementReadout(reset.updated)).toEqual({ unavailable: "no-measure" });
|
|
238
|
+
} finally {
|
|
239
|
+
await doc.close();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
test("all three kinds derive labels, save, reopen and retain captions", async () => {
|
|
243
|
+
let doc = await open();
|
|
244
|
+
try {
|
|
245
|
+
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
246
|
+
const drafts = [
|
|
247
|
+
{
|
|
248
|
+
subtype: "line",
|
|
249
|
+
rect,
|
|
250
|
+
intent: "LineDimension",
|
|
251
|
+
measure: require_derive.measureFromKnownLength(1, {
|
|
252
|
+
value: 1.00000001,
|
|
253
|
+
unit: "m"
|
|
254
|
+
}),
|
|
255
|
+
contents: "wrong",
|
|
256
|
+
linePoints: {
|
|
257
|
+
start: vertices[0],
|
|
258
|
+
end: {
|
|
259
|
+
x: 3.4450000001,
|
|
260
|
+
y: 0
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
caption: {
|
|
264
|
+
enabled: true,
|
|
265
|
+
offset: {
|
|
266
|
+
along: 10,
|
|
267
|
+
perpendicular: 20
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
subtype: "polyline",
|
|
273
|
+
rect,
|
|
274
|
+
intent: "PolyLineDimension",
|
|
275
|
+
measure: scale,
|
|
276
|
+
contents: "wrong",
|
|
277
|
+
vertices,
|
|
278
|
+
caption: {
|
|
279
|
+
enabled: true,
|
|
280
|
+
center: {
|
|
281
|
+
x: 0,
|
|
282
|
+
y: 0
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
subtype: "polygon",
|
|
288
|
+
rect,
|
|
289
|
+
intent: "PolygonDimension",
|
|
290
|
+
measure: scale,
|
|
291
|
+
contents: "wrong",
|
|
292
|
+
vertices,
|
|
293
|
+
caption: {
|
|
294
|
+
enabled: true,
|
|
295
|
+
center: {
|
|
296
|
+
x: 50,
|
|
297
|
+
y: 30
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
];
|
|
302
|
+
const saved = [];
|
|
303
|
+
for (const draft of drafts) {
|
|
304
|
+
const preview = require_derive.measurementReadout(draft);
|
|
305
|
+
const a = (await doc.page(pon).annotations.create(draft)).created;
|
|
306
|
+
expect(a.contents).toBe("label" in preview ? preview.label : void 0);
|
|
307
|
+
saved.push(a);
|
|
308
|
+
}
|
|
309
|
+
const bytes = opts.openKind === "bytes" ? await doc.download() : void 0;
|
|
310
|
+
await doc.close();
|
|
311
|
+
doc = bytes ? await engine.open({
|
|
312
|
+
kind: "bytes",
|
|
313
|
+
id: `${opts.fixture.id}-saved`,
|
|
314
|
+
bytes
|
|
315
|
+
}) : await open();
|
|
316
|
+
const page = doc.page((await doc.pages.list()).pages[0].pageObjectNumber);
|
|
317
|
+
const list = (await page.annotations.list()).annotations;
|
|
318
|
+
for (const before of saved) {
|
|
319
|
+
const a = list.find((a) => require_derive.refKey(a.ref) === require_derive.refKey(before.ref));
|
|
320
|
+
expect(a.contents).toBe(before.contents);
|
|
321
|
+
if (a.subtype !== "line" && a.subtype !== "polygon" && a.subtype !== "polyline") throw new Error("Missing dimension");
|
|
322
|
+
expect(a.caption).toEqual("caption" in before ? before.caption : void 0);
|
|
323
|
+
const result = await page.annotations.update(a.ref, {
|
|
324
|
+
subtype: a.subtype,
|
|
325
|
+
color: {
|
|
326
|
+
r: 0,
|
|
327
|
+
g: 0,
|
|
328
|
+
b: 255
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
expect(result.updated.contents).toBe(before.contents);
|
|
332
|
+
}
|
|
333
|
+
} finally {
|
|
334
|
+
await doc.close();
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
test("calibration updates only viewports and emits one event per write", async () => {
|
|
338
|
+
const doc = await open();
|
|
339
|
+
try {
|
|
340
|
+
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
341
|
+
const page = doc.page(pon);
|
|
342
|
+
if (!page.measure) throw new Error("Measurement service is required");
|
|
343
|
+
const foreign = (await page.measure.viewports()).filter((v) => !v.owned);
|
|
344
|
+
const annotations = (await page.annotations.list()).annotations;
|
|
345
|
+
const events = [];
|
|
346
|
+
const off = doc.events.subscribe((event) => events.push(event));
|
|
347
|
+
try {
|
|
348
|
+
await page.measure.setScale(scale);
|
|
349
|
+
expect((await page.measure.viewports()).filter((v) => v.owned)).toHaveLength(1);
|
|
350
|
+
expect((await page.annotations.list()).annotations).toEqual(annotations);
|
|
351
|
+
await page.measure.setScale(null);
|
|
352
|
+
expect(await page.measure.viewports()).toEqual(foreign);
|
|
353
|
+
const changes = events.filter((e) => e.type === "page.viewportsChanged");
|
|
354
|
+
expect(changes).toHaveLength(2);
|
|
355
|
+
for (const event of changes) expect(event).toMatchObject({
|
|
356
|
+
pageObjectNumber: pon,
|
|
357
|
+
meta: { affectedPages: [] }
|
|
358
|
+
});
|
|
359
|
+
} finally {
|
|
360
|
+
off();
|
|
361
|
+
}
|
|
362
|
+
} finally {
|
|
363
|
+
await doc.close();
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
test("invalid and immediately aborted calibration leaves the previous scale intact", async () => {
|
|
367
|
+
const doc = await open();
|
|
368
|
+
try {
|
|
369
|
+
const page = doc.page((await doc.pages.list()).pages[0].pageObjectNumber);
|
|
370
|
+
await page.measure.setScale(scale);
|
|
371
|
+
const before = await page.measure.viewports();
|
|
372
|
+
await expect(page.measure.setScale({
|
|
373
|
+
...scale,
|
|
374
|
+
x: [{
|
|
375
|
+
unit: "m",
|
|
376
|
+
conversion: 0
|
|
377
|
+
}]
|
|
378
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
379
|
+
const pending = page.measure.setScale(null);
|
|
380
|
+
pending.abort("conformance");
|
|
381
|
+
await expect(pending).rejects.toBeInstanceOf(require_AbortError.AbortError);
|
|
382
|
+
expect(await page.measure.viewports()).toEqual(before);
|
|
383
|
+
} finally {
|
|
384
|
+
await doc.close();
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
//#endregion
|
|
126
390
|
//#region src/conformance/runAnnotationReadConformance.ts
|
|
127
391
|
function runAnnotationReadConformance(runner, opts) {
|
|
128
392
|
const { describe, test, beforeAll, afterAll, expect } = runner;
|
|
@@ -333,7 +597,7 @@ function runAnnotationReadConformance(runner, opts) {
|
|
|
333
597
|
caught = err;
|
|
334
598
|
}
|
|
335
599
|
expect(caught).toBeTruthy();
|
|
336
|
-
expect(
|
|
600
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound)).toBe(true);
|
|
337
601
|
} finally {
|
|
338
602
|
await doc.close();
|
|
339
603
|
}
|
|
@@ -1777,7 +2041,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
1777
2041
|
} catch (err) {
|
|
1778
2042
|
caught = err;
|
|
1779
2043
|
}
|
|
1780
|
-
expect(
|
|
2044
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
1781
2045
|
const after = (await page.annotations.list()).annotations.find((a) => a.index === created.created.index);
|
|
1782
2046
|
expect(after?.contents).toBe("x");
|
|
1783
2047
|
const agreed = await page.annotations.update(ref, {
|
|
@@ -2406,7 +2670,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2406
2670
|
} catch (err) {
|
|
2407
2671
|
caught = err;
|
|
2408
2672
|
}
|
|
2409
|
-
expect(
|
|
2673
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidReference)).toBe(true);
|
|
2410
2674
|
} finally {
|
|
2411
2675
|
await doc.close();
|
|
2412
2676
|
}
|
|
@@ -2552,7 +2816,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2552
2816
|
} finally {
|
|
2553
2817
|
await weakSession?.release();
|
|
2554
2818
|
}
|
|
2555
|
-
expect(
|
|
2819
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidReference)).toBe(true);
|
|
2556
2820
|
} finally {
|
|
2557
2821
|
await doc.close();
|
|
2558
2822
|
}
|
|
@@ -2576,7 +2840,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2576
2840
|
} finally {
|
|
2577
2841
|
await weakSession?.release();
|
|
2578
2842
|
}
|
|
2579
|
-
expect(
|
|
2843
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
2580
2844
|
} finally {
|
|
2581
2845
|
await doc.close();
|
|
2582
2846
|
}
|
|
@@ -2599,7 +2863,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
2599
2863
|
} finally {
|
|
2600
2864
|
await weakSession?.release();
|
|
2601
2865
|
}
|
|
2602
|
-
expect(
|
|
2866
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
2603
2867
|
} finally {
|
|
2604
2868
|
await doc.close();
|
|
2605
2869
|
}
|
|
@@ -3015,7 +3279,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
3015
3279
|
} catch (err) {
|
|
3016
3280
|
caught = err;
|
|
3017
3281
|
}
|
|
3018
|
-
expect(
|
|
3282
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3019
3283
|
} finally {
|
|
3020
3284
|
await doc.close();
|
|
3021
3285
|
}
|
|
@@ -3068,7 +3332,7 @@ function runAnnotationMutationConformance(runner, opts) {
|
|
|
3068
3332
|
} catch (err) {
|
|
3069
3333
|
caught = err;
|
|
3070
3334
|
}
|
|
3071
|
-
expect(
|
|
3335
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
3072
3336
|
} finally {
|
|
3073
3337
|
await doc.close();
|
|
3074
3338
|
}
|
|
@@ -3315,7 +3579,7 @@ function runFormConformance(runner, opts) {
|
|
|
3315
3579
|
await expect(doc.forms.setValue(radioRef, {
|
|
3316
3580
|
type: "toggle",
|
|
3317
3581
|
state: null
|
|
3318
|
-
})).rejects.toMatchObject({ code:
|
|
3582
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
3319
3583
|
const check = await doc.forms.setValue({
|
|
3320
3584
|
kind: "fqn",
|
|
3321
3585
|
name: "opt_check"
|
|
@@ -3343,7 +3607,7 @@ function runFormConformance(runner, opts) {
|
|
|
3343
3607
|
}, {
|
|
3344
3608
|
type: "toggle",
|
|
3345
3609
|
state: "On"
|
|
3346
|
-
})).rejects.toMatchObject({ code:
|
|
3610
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
3347
3611
|
const field = await doc.forms.get({
|
|
3348
3612
|
kind: "fqn",
|
|
3349
3613
|
name: "maxlen_text"
|
|
@@ -3447,7 +3711,7 @@ function runFormConformance(runner, opts) {
|
|
|
3447
3711
|
}, {
|
|
3448
3712
|
type: "choice",
|
|
3449
3713
|
values: ["foo", "bar"]
|
|
3450
|
-
})).rejects.toMatchObject({ code:
|
|
3714
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
3451
3715
|
} finally {
|
|
3452
3716
|
await doc.close();
|
|
3453
3717
|
}
|
|
@@ -3517,7 +3781,7 @@ function runFormConformance(runner, opts) {
|
|
|
3517
3781
|
test("rejects garbage import payloads", async () => {
|
|
3518
3782
|
const doc = await open(opts.fixtures.toggleFields);
|
|
3519
3783
|
try {
|
|
3520
|
-
await expect(doc.forms.importData(new TextEncoder().encode("not a form payload"))).rejects.toMatchObject({ code:
|
|
3784
|
+
await expect(doc.forms.importData(new TextEncoder().encode("not a form payload"))).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
3521
3785
|
} finally {
|
|
3522
3786
|
await doc.close();
|
|
3523
3787
|
}
|
|
@@ -3624,7 +3888,7 @@ function runFormConformance(runner, opts) {
|
|
|
3624
3888
|
g: 247,
|
|
3625
3889
|
b: 219
|
|
3626
3890
|
});
|
|
3627
|
-
await expect(page.annotations.delete(widgetRef)).rejects.toMatchObject({ code:
|
|
3891
|
+
await expect(page.annotations.delete(widgetRef)).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
3628
3892
|
await doc.forms.detachWidget(field.field.ref, {
|
|
3629
3893
|
annotObjectNumber: widgetRef.annotObjectNumber,
|
|
3630
3894
|
pageObjectNumber: pon
|
|
@@ -3688,7 +3952,7 @@ function runFormConformance(runner, opts) {
|
|
|
3688
3952
|
await expect(doc.forms.updateField(created.field.ref, {
|
|
3689
3953
|
family: "radio",
|
|
3690
3954
|
name: "unison_radio"
|
|
3691
|
-
})).rejects.toMatchObject({ code:
|
|
3955
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
3692
3956
|
const before = await doc.page(pon).annotations.list();
|
|
3693
3957
|
const removed = await doc.forms.deleteField(created.field.ref);
|
|
3694
3958
|
expect(removed.removedWidgets.length).toBe(2);
|
|
@@ -3697,7 +3961,7 @@ function runFormConformance(runner, opts) {
|
|
|
3697
3961
|
await expect(doc.forms.get({
|
|
3698
3962
|
kind: "fqn",
|
|
3699
3963
|
name: "renamed_radio"
|
|
3700
|
-
})).rejects.toMatchObject({ code:
|
|
3964
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.NotFound });
|
|
3701
3965
|
} finally {
|
|
3702
3966
|
await doc.close();
|
|
3703
3967
|
}
|
|
@@ -3708,7 +3972,7 @@ function runFormConformance(runner, opts) {
|
|
|
3708
3972
|
await expect(doc.forms.get({
|
|
3709
3973
|
kind: "fqn",
|
|
3710
3974
|
name: "no.such.field"
|
|
3711
|
-
})).rejects.toMatchObject({ code:
|
|
3975
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.NotFound });
|
|
3712
3976
|
} finally {
|
|
3713
3977
|
await doc.close();
|
|
3714
3978
|
}
|
|
@@ -4001,7 +4265,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
4001
4265
|
} catch (err) {
|
|
4002
4266
|
caught = err;
|
|
4003
4267
|
}
|
|
4004
|
-
expect(
|
|
4268
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4005
4269
|
} finally {
|
|
4006
4270
|
await doc.close();
|
|
4007
4271
|
}
|
|
@@ -4018,7 +4282,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
4018
4282
|
} catch (err) {
|
|
4019
4283
|
caught = err;
|
|
4020
4284
|
}
|
|
4021
|
-
expect(
|
|
4285
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4022
4286
|
} finally {
|
|
4023
4287
|
await doc.close();
|
|
4024
4288
|
}
|
|
@@ -4036,7 +4300,7 @@ function runPageReorderConformance(runner, opts) {
|
|
|
4036
4300
|
} catch (err) {
|
|
4037
4301
|
caught = err;
|
|
4038
4302
|
}
|
|
4039
|
-
expect(
|
|
4303
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound) || require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4040
4304
|
} finally {
|
|
4041
4305
|
await doc.close();
|
|
4042
4306
|
}
|
|
@@ -4211,7 +4475,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
4211
4475
|
} catch (err) {
|
|
4212
4476
|
caught = err;
|
|
4213
4477
|
}
|
|
4214
|
-
expect(
|
|
4478
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4215
4479
|
} finally {
|
|
4216
4480
|
await doc.close();
|
|
4217
4481
|
}
|
|
@@ -4226,7 +4490,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
4226
4490
|
} catch (err) {
|
|
4227
4491
|
caught = err;
|
|
4228
4492
|
}
|
|
4229
|
-
expect(
|
|
4493
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4230
4494
|
} finally {
|
|
4231
4495
|
await doc.close();
|
|
4232
4496
|
}
|
|
@@ -4244,7 +4508,7 @@ function runPageRotateConformance(runner, opts) {
|
|
|
4244
4508
|
} catch (err) {
|
|
4245
4509
|
caught = err;
|
|
4246
4510
|
}
|
|
4247
|
-
expect(
|
|
4511
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound) || require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4248
4512
|
} finally {
|
|
4249
4513
|
await doc.close();
|
|
4250
4514
|
}
|
|
@@ -4358,7 +4622,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
4358
4622
|
} catch (err) {
|
|
4359
4623
|
caught = err;
|
|
4360
4624
|
}
|
|
4361
|
-
expect(
|
|
4625
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound)).toBe(true);
|
|
4362
4626
|
} finally {
|
|
4363
4627
|
await doc.close();
|
|
4364
4628
|
}
|
|
@@ -4406,7 +4670,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
4406
4670
|
} catch (err) {
|
|
4407
4671
|
caught = err;
|
|
4408
4672
|
}
|
|
4409
|
-
expect(
|
|
4673
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4410
4674
|
} finally {
|
|
4411
4675
|
await doc.close();
|
|
4412
4676
|
}
|
|
@@ -4421,7 +4685,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
4421
4685
|
} catch (err) {
|
|
4422
4686
|
caught = err;
|
|
4423
4687
|
}
|
|
4424
|
-
expect(
|
|
4688
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4425
4689
|
} finally {
|
|
4426
4690
|
await doc.close();
|
|
4427
4691
|
}
|
|
@@ -4439,7 +4703,7 @@ function runPageDeleteConformance(runner, opts) {
|
|
|
4439
4703
|
} catch (err) {
|
|
4440
4704
|
caught = err;
|
|
4441
4705
|
}
|
|
4442
|
-
expect(
|
|
4706
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound) || require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4443
4707
|
} finally {
|
|
4444
4708
|
await doc.close();
|
|
4445
4709
|
}
|
|
@@ -4598,7 +4862,7 @@ function runNamedPagesConformance(runner, opts) {
|
|
|
4598
4862
|
require_schemas.PageNameResultSchema.parse(removed);
|
|
4599
4863
|
expect(find(removed, "Draft=Concept")).toBe(void 0);
|
|
4600
4864
|
expect(removed.layout.pages.length).toBe(before.pages.length);
|
|
4601
|
-
await expect(doc.pages.removeName({ name: "Draft=Concept" })).rejects.toMatchObject({ code:
|
|
4865
|
+
await expect(doc.pages.removeName({ name: "Draft=Concept" })).rejects.toMatchObject({ code: require_format.EngineErrorCode.NotFound });
|
|
4602
4866
|
} finally {
|
|
4603
4867
|
await doc.close();
|
|
4604
4868
|
}
|
|
@@ -4611,7 +4875,7 @@ function runNamedPagesConformance(runner, opts) {
|
|
|
4611
4875
|
await expect(doc.pages.setName({
|
|
4612
4876
|
name: "",
|
|
4613
4877
|
pageObjectNumber: before.pages[0].pageObjectNumber
|
|
4614
|
-
})).rejects.toMatchObject({ code:
|
|
4878
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
4615
4879
|
let unknownPage = null;
|
|
4616
4880
|
try {
|
|
4617
4881
|
await doc.pages.setName({
|
|
@@ -4621,7 +4885,7 @@ function runNamedPagesConformance(runner, opts) {
|
|
|
4621
4885
|
} catch (error) {
|
|
4622
4886
|
unknownPage = error;
|
|
4623
4887
|
}
|
|
4624
|
-
expect(
|
|
4888
|
+
expect(require_derive.EngineError.is(unknownPage, require_format.EngineErrorCode.NotFound) || require_derive.EngineError.is(unknownPage, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
4625
4889
|
} finally {
|
|
4626
4890
|
await doc.close();
|
|
4627
4891
|
}
|
|
@@ -4777,7 +5041,7 @@ function runAnnotationFlattenConformance(runner, opts) {
|
|
|
4777
5041
|
const own = (await page0.annotations.create(square$1(20, 100))).created.ref;
|
|
4778
5042
|
const foreign = (await page1.annotations.create(square$1(20, 100))).created.ref;
|
|
4779
5043
|
const countBefore = (await page0.annotations.list()).annotations.length;
|
|
4780
|
-
await expect(page0.annotations.flatten([own, foreign])).rejects.toMatchObject({ code:
|
|
5044
|
+
await expect(page0.annotations.flatten([own, foreign])).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
4781
5045
|
expect((await page0.annotations.list()).annotations.length).toBe(countBefore);
|
|
4782
5046
|
} finally {
|
|
4783
5047
|
await doc.close();
|
|
@@ -4789,7 +5053,7 @@ function runAnnotationFlattenConformance(runner, opts) {
|
|
|
4789
5053
|
const pon = (await doc.pages.list()).pages[0].pageObjectNumber;
|
|
4790
5054
|
const page = doc.page(pon);
|
|
4791
5055
|
if (!page.annotations.flatten) return;
|
|
4792
|
-
await expect(page.annotations.flatten([])).rejects.toMatchObject({ code:
|
|
5056
|
+
await expect(page.annotations.flatten([])).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
4793
5057
|
let unknown = null;
|
|
4794
5058
|
try {
|
|
4795
5059
|
await page.annotations.flatten([{
|
|
@@ -4800,7 +5064,7 @@ function runAnnotationFlattenConformance(runner, opts) {
|
|
|
4800
5064
|
} catch (error) {
|
|
4801
5065
|
unknown = error;
|
|
4802
5066
|
}
|
|
4803
|
-
expect(
|
|
5067
|
+
expect(require_derive.EngineError.is(unknown, require_format.EngineErrorCode.NotFound) || require_derive.EngineError.is(unknown, require_format.EngineErrorCode.InvalidArg) || require_derive.EngineError.is(unknown, require_format.EngineErrorCode.InvalidReference)).toBe(true);
|
|
4804
5068
|
} finally {
|
|
4805
5069
|
await doc.close();
|
|
4806
5070
|
}
|
|
@@ -4904,12 +5168,12 @@ function runAnnotationAppearanceExportConformance(runner, opts) {
|
|
|
4904
5168
|
const layout = await doc.pages.list();
|
|
4905
5169
|
const page0 = doc.page(layout.pages[0].pageObjectNumber);
|
|
4906
5170
|
if (!page0.annotations.exportAppearance) return;
|
|
4907
|
-
await expect(page0.annotations.exportAppearance([])).rejects.toMatchObject({ code:
|
|
5171
|
+
await expect(page0.annotations.exportAppearance([])).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
4908
5172
|
if (layout.pages.length < 2) return;
|
|
4909
5173
|
const page1 = doc.page(layout.pages[1].pageObjectNumber);
|
|
4910
5174
|
const own = (await page0.annotations.create(square(20, 100))).created.ref;
|
|
4911
5175
|
const foreign = (await page1.annotations.create(square(20, 100))).created.ref;
|
|
4912
|
-
await expect(page0.annotations.exportAppearance([own, foreign])).rejects.toMatchObject({ code:
|
|
5176
|
+
await expect(page0.annotations.exportAppearance([own, foreign])).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
4913
5177
|
} finally {
|
|
4914
5178
|
await doc.close();
|
|
4915
5179
|
}
|
|
@@ -4968,7 +5232,7 @@ function runPageFlattenConformance(runner, opts) {
|
|
|
4968
5232
|
expect(noOp.meta).toBeNull();
|
|
4969
5233
|
expect(events).toHaveLength(1);
|
|
4970
5234
|
unsubscribe();
|
|
4971
|
-
await expect(doc.pages.flatten([pageObjectNumber, pageObjectNumber])).rejects.toMatchObject({ code:
|
|
5235
|
+
await expect(doc.pages.flatten([pageObjectNumber, pageObjectNumber])).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
4972
5236
|
} finally {
|
|
4973
5237
|
await doc.close();
|
|
4974
5238
|
}
|
|
@@ -5120,7 +5384,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
5120
5384
|
await expect(doc.redaction.apply({
|
|
5121
5385
|
kind: "pages",
|
|
5122
5386
|
pageObjectNumbers: [pageObjectNumber, pageObjectNumber]
|
|
5123
|
-
})).rejects.toMatchObject({ code:
|
|
5387
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
5124
5388
|
const notRedact = await page.annotations.create({
|
|
5125
5389
|
subtype: "highlight",
|
|
5126
5390
|
quadPoints: COLLATERAL_QUAD
|
|
@@ -5128,7 +5392,7 @@ function runRedactionApplyConformance(runner, opts) {
|
|
|
5128
5392
|
await expect(doc.redaction.apply({
|
|
5129
5393
|
kind: "annotations",
|
|
5130
5394
|
refs: [notRedact.created.ref]
|
|
5131
|
-
})).rejects.toMatchObject({ code:
|
|
5395
|
+
})).rejects.toMatchObject({ code: require_format.EngineErrorCode.InvalidArg });
|
|
5132
5396
|
} finally {
|
|
5133
5397
|
await doc.close();
|
|
5134
5398
|
}
|
|
@@ -5229,7 +5493,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
5229
5493
|
} catch (err) {
|
|
5230
5494
|
caught = err;
|
|
5231
5495
|
}
|
|
5232
|
-
expect(
|
|
5496
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5233
5497
|
} finally {
|
|
5234
5498
|
await doc.close();
|
|
5235
5499
|
}
|
|
@@ -5244,7 +5508,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
5244
5508
|
} catch (err) {
|
|
5245
5509
|
caught = err;
|
|
5246
5510
|
}
|
|
5247
|
-
expect(
|
|
5511
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5248
5512
|
} finally {
|
|
5249
5513
|
await doc.close();
|
|
5250
5514
|
}
|
|
@@ -5262,7 +5526,7 @@ function runPageExtractConformance(runner, opts) {
|
|
|
5262
5526
|
} catch (err) {
|
|
5263
5527
|
caught = err;
|
|
5264
5528
|
}
|
|
5265
|
-
expect(
|
|
5529
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound) || require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5266
5530
|
} finally {
|
|
5267
5531
|
await doc.close();
|
|
5268
5532
|
}
|
|
@@ -5376,7 +5640,7 @@ function runAttachmentConformance(runner, opts) {
|
|
|
5376
5640
|
await expect(doc.attachments.download({
|
|
5377
5641
|
kind: "key",
|
|
5378
5642
|
key: "conformance-no-such-key.bin"
|
|
5379
|
-
})).rejects.toBeInstanceOf(
|
|
5643
|
+
})).rejects.toBeInstanceOf(require_derive.EngineError);
|
|
5380
5644
|
} finally {
|
|
5381
5645
|
await doc.close();
|
|
5382
5646
|
}
|
|
@@ -5412,7 +5676,7 @@ function runAttachmentConformance(runner, opts) {
|
|
|
5412
5676
|
await expect(doc.attachments.create({
|
|
5413
5677
|
data,
|
|
5414
5678
|
name: "0-conformance.bin"
|
|
5415
|
-
})).rejects.toBeInstanceOf(
|
|
5679
|
+
})).rejects.toBeInstanceOf(require_derive.EngineError);
|
|
5416
5680
|
const content = await doc.attachments.download({
|
|
5417
5681
|
kind: "key",
|
|
5418
5682
|
key: created.key
|
|
@@ -5432,7 +5696,7 @@ function runAttachmentConformance(runner, opts) {
|
|
|
5432
5696
|
await expect(doc.attachments.delete({
|
|
5433
5697
|
kind: "key",
|
|
5434
5698
|
key: created.key
|
|
5435
|
-
})).rejects.toBeInstanceOf(
|
|
5699
|
+
})).rejects.toBeInstanceOf(require_derive.EngineError);
|
|
5436
5700
|
} finally {
|
|
5437
5701
|
await doc.close();
|
|
5438
5702
|
}
|
|
@@ -5631,14 +5895,14 @@ function runPageInsertConformance(runner, opts) {
|
|
|
5631
5895
|
} catch (err) {
|
|
5632
5896
|
caught = err;
|
|
5633
5897
|
}
|
|
5634
|
-
expect(
|
|
5898
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5635
5899
|
caught = void 0;
|
|
5636
5900
|
try {
|
|
5637
5901
|
await doc.pages.insert(new TextEncoder().encode("not a pdf at all"));
|
|
5638
5902
|
} catch (err) {
|
|
5639
5903
|
caught = err;
|
|
5640
5904
|
}
|
|
5641
|
-
expect(
|
|
5905
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.MalformedPdf)).toBe(true);
|
|
5642
5906
|
const list = await doc.pages.list();
|
|
5643
5907
|
expect(list.pageCount > 0).toBe(true);
|
|
5644
5908
|
} finally {
|
|
@@ -5656,7 +5920,7 @@ function runPageInsertConformance(runner, opts) {
|
|
|
5656
5920
|
} catch (err) {
|
|
5657
5921
|
caught = err;
|
|
5658
5922
|
}
|
|
5659
|
-
expect(
|
|
5923
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5660
5924
|
} finally {
|
|
5661
5925
|
await doc.close();
|
|
5662
5926
|
}
|
|
@@ -5805,7 +6069,7 @@ function runPageInsertBlankConformance(runner, opts) {
|
|
|
5805
6069
|
} catch (err) {
|
|
5806
6070
|
caught = err;
|
|
5807
6071
|
}
|
|
5808
|
-
expect(
|
|
6072
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
5809
6073
|
}
|
|
5810
6074
|
const list = await doc.pages.list();
|
|
5811
6075
|
expect(list.pageCount).toBe(before.pageCount);
|
|
@@ -6238,7 +6502,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
6238
6502
|
caught = err;
|
|
6239
6503
|
}
|
|
6240
6504
|
expect(caught).toBeTruthy();
|
|
6241
|
-
expect(
|
|
6505
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound)).toBe(true);
|
|
6242
6506
|
} finally {
|
|
6243
6507
|
await doc.close();
|
|
6244
6508
|
}
|
|
@@ -6264,7 +6528,7 @@ function runPageTextConformance(runner, opts) {
|
|
|
6264
6528
|
caught = err;
|
|
6265
6529
|
}
|
|
6266
6530
|
expect(caught).toBeTruthy();
|
|
6267
|
-
expect(
|
|
6531
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
6268
6532
|
});
|
|
6269
6533
|
});
|
|
6270
6534
|
}
|
|
@@ -6313,8 +6577,8 @@ function runTextDivergenceConformance(runner, opts) {
|
|
|
6313
6577
|
const doc = await openFixture$2(engine, opts);
|
|
6314
6578
|
try {
|
|
6315
6579
|
const snap = await doc.page(fixture.pageObjectNumber).text.read();
|
|
6316
|
-
expect(
|
|
6317
|
-
for (const s of fixture.slices ?? []) expect(
|
|
6580
|
+
expect(require_format.sliceTextByChars(snap, 0, snap.charCount)).toBe(snap.text);
|
|
6581
|
+
for (const s of fixture.slices ?? []) expect(require_format.sliceTextByChars(snap, s.from, s.to)).toBe(s.text);
|
|
6318
6582
|
} finally {
|
|
6319
6583
|
await doc.close();
|
|
6320
6584
|
}
|
|
@@ -6333,7 +6597,7 @@ function runTextDivergenceConformance(runner, opts) {
|
|
|
6333
6597
|
expect(hit.charCount).toBe(probe.charCount);
|
|
6334
6598
|
expect(hit.segments.length > 0).toBe(true);
|
|
6335
6599
|
const snap = await doc.page(fixture.pageObjectNumber).text.read();
|
|
6336
|
-
expect(
|
|
6600
|
+
expect(require_format.sliceTextByChars(snap, hit.charStart, hit.charStart + hit.charCount)).toBe(probe.matchedText);
|
|
6337
6601
|
} finally {
|
|
6338
6602
|
await doc.close();
|
|
6339
6603
|
}
|
|
@@ -6498,8 +6762,8 @@ function runPageGeometryOrientationConformance(runner, opts) {
|
|
|
6498
6762
|
const expectation = opts.fixture.expectation;
|
|
6499
6763
|
if (expectation.kind === "upright") {
|
|
6500
6764
|
for (const run of snapshot.runs) {
|
|
6501
|
-
expect(
|
|
6502
|
-
if (
|
|
6765
|
+
expect(require_derive.isRotatedGeometryRun(run)).toBe(false);
|
|
6766
|
+
if (require_derive.isRotatedGeometryRun(run)) continue;
|
|
6503
6767
|
for (const glyph of run.glyphs) {
|
|
6504
6768
|
expect("looseQuad" in glyph).toBe(false);
|
|
6505
6769
|
if (glyph.flags & FLAG_EMPTY) expect(glyph.looseBox).toEqual({
|
|
@@ -6514,8 +6778,8 @@ function runPageGeometryOrientationConformance(runner, opts) {
|
|
|
6514
6778
|
}
|
|
6515
6779
|
if (expectation.kind === "empty-only") {
|
|
6516
6780
|
for (const run of snapshot.runs) {
|
|
6517
|
-
expect(
|
|
6518
|
-
if (
|
|
6781
|
+
expect(require_derive.isRotatedGeometryRun(run)).toBe(false);
|
|
6782
|
+
if (require_derive.isRotatedGeometryRun(run)) continue;
|
|
6519
6783
|
for (const glyph of run.glyphs) {
|
|
6520
6784
|
expect(glyph.flags & FLAG_EMPTY).toBe(FLAG_EMPTY);
|
|
6521
6785
|
expect(glyph.looseBox).toEqual({
|
|
@@ -6528,7 +6792,7 @@ function runPageGeometryOrientationConformance(runner, opts) {
|
|
|
6528
6792
|
}
|
|
6529
6793
|
return;
|
|
6530
6794
|
}
|
|
6531
|
-
const rotatedRuns = snapshot.runs.filter(
|
|
6795
|
+
const rotatedRuns = snapshot.runs.filter(require_derive.isRotatedGeometryRun);
|
|
6532
6796
|
expect(rotatedRuns.length >= (expectation.minRotatedRuns ?? 1)).toBe(true);
|
|
6533
6797
|
for (const run of rotatedRuns) {
|
|
6534
6798
|
expect(expectation.rotations.some((angle) => angleClose(run.rotation, angle, ANGLE_TOLERANCE))).toBe(true);
|
|
@@ -6569,7 +6833,7 @@ function runPageGeometryOrientationConformance(runner, opts) {
|
|
|
6569
6833
|
const q = glyph.looseQuad;
|
|
6570
6834
|
expect(Math.abs(q.p2.x - q.p1.x - (q.p4.x - q.p3.x)) <= COORD_TOLERANCE).toBe(true);
|
|
6571
6835
|
expect(Math.abs(q.p2.y - q.p1.y - (q.p4.y - q.p3.y)) <= COORD_TOLERANCE).toBe(true);
|
|
6572
|
-
const bounds =
|
|
6836
|
+
const bounds = require_derive.pdfQuadBounds(q);
|
|
6573
6837
|
expect(bounds.left >= run.rect.left - COORD_TOLERANCE).toBe(true);
|
|
6574
6838
|
expect(bounds.right <= run.rect.right + COORD_TOLERANCE).toBe(true);
|
|
6575
6839
|
expect(bounds.bottom >= run.rect.bottom - COORD_TOLERANCE).toBe(true);
|
|
@@ -6686,7 +6950,7 @@ function runSearchConformance(runner, opts) {
|
|
|
6686
6950
|
expect(!!m.snippet).toBe(true);
|
|
6687
6951
|
const s = m.snippet;
|
|
6688
6952
|
const hit = s.text.slice(s.matchStart, s.matchStart + s.matchLength);
|
|
6689
|
-
expect(
|
|
6953
|
+
expect(require_derive.foldText(hit).folded).toBe(require_derive.foldText(fixture.presentLiteral).folded);
|
|
6690
6954
|
}
|
|
6691
6955
|
const rects = await collectAll(doc, {
|
|
6692
6956
|
query: { text: fixture.presentLiteral },
|
|
@@ -6757,7 +7021,7 @@ function runSearchConformance(runner, opts) {
|
|
|
6757
7021
|
} catch (err) {
|
|
6758
7022
|
caught = err;
|
|
6759
7023
|
}
|
|
6760
|
-
expect(
|
|
7024
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
6761
7025
|
} finally {
|
|
6762
7026
|
await doc.close();
|
|
6763
7027
|
}
|
|
@@ -6774,7 +7038,7 @@ function runSearchConformance(runner, opts) {
|
|
|
6774
7038
|
} catch (err) {
|
|
6775
7039
|
caught = err;
|
|
6776
7040
|
}
|
|
6777
|
-
expect(
|
|
7041
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
6778
7042
|
} finally {
|
|
6779
7043
|
await doc.close();
|
|
6780
7044
|
}
|
|
@@ -6817,20 +7081,42 @@ function runSearchConformance(runner, opts) {
|
|
|
6817
7081
|
await doc.close();
|
|
6818
7082
|
}
|
|
6819
7083
|
});
|
|
6820
|
-
test("
|
|
7084
|
+
test("ignoreWhitespace keeps every default hit and finds the space-free needle", async () => {
|
|
6821
7085
|
const doc = await openFixture(engine, opts);
|
|
6822
7086
|
try {
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
7087
|
+
const key = (m) => `${m.pageObjectNumber}:${m.charStart}:${m.charCount}`;
|
|
7088
|
+
const plain = await collectAll(doc, { query: { text: fixture.presentLiteral } });
|
|
7089
|
+
const relaxed = await collectAll(doc, { query: {
|
|
7090
|
+
text: fixture.presentLiteral,
|
|
7091
|
+
ignoreWhitespace: true
|
|
7092
|
+
} });
|
|
7093
|
+
const relaxedKeys = new Set(relaxed.matches.map(key));
|
|
7094
|
+
for (const m of plain.matches) expect(relaxedKeys.has(key(m))).toBe(true);
|
|
7095
|
+
const squashed = await collectAll(doc, { query: {
|
|
7096
|
+
text: fixture.presentLiteral.replace(/\s+/g, ""),
|
|
7097
|
+
ignoreWhitespace: true
|
|
7098
|
+
} });
|
|
7099
|
+
expect(squashed.matches.map(key)).toEqual(relaxed.matches.map(key));
|
|
7100
|
+
} finally {
|
|
7101
|
+
await doc.close();
|
|
7102
|
+
}
|
|
7103
|
+
});
|
|
7104
|
+
test("regex + matchDiacritics / ignoreWhitespace are rejected with InvalidArg", async () => {
|
|
7105
|
+
const doc = await openFixture(engine, opts);
|
|
7106
|
+
try {
|
|
7107
|
+
for (const flags of [{ matchDiacritics: true }, { ignoreWhitespace: true }]) {
|
|
7108
|
+
let caught;
|
|
7109
|
+
try {
|
|
7110
|
+
await doc.search.query({ query: {
|
|
7111
|
+
text: fixture.presentRegex,
|
|
7112
|
+
regex: true,
|
|
7113
|
+
...flags
|
|
7114
|
+
} });
|
|
7115
|
+
} catch (err) {
|
|
7116
|
+
caught = err;
|
|
7117
|
+
}
|
|
7118
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
6832
7119
|
}
|
|
6833
|
-
expect(require_fold.EngineError.is(caught, require_PageInsertBlankInput.EngineErrorCode.InvalidArg)).toBe(true);
|
|
6834
7120
|
} finally {
|
|
6835
7121
|
await doc.close();
|
|
6836
7122
|
}
|
|
@@ -6852,7 +7138,7 @@ function runSearchConformance(runner, opts) {
|
|
|
6852
7138
|
} catch (err) {
|
|
6853
7139
|
caught = err;
|
|
6854
7140
|
}
|
|
6855
|
-
expect(
|
|
7141
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.InvalidArg)).toBe(true);
|
|
6856
7142
|
}
|
|
6857
7143
|
} finally {
|
|
6858
7144
|
await doc.close();
|
|
@@ -6887,7 +7173,7 @@ function runSearchConformance(runner, opts) {
|
|
|
6887
7173
|
} catch (err) {
|
|
6888
7174
|
caught = err;
|
|
6889
7175
|
}
|
|
6890
|
-
expect(
|
|
7176
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.DocNotOpen)).toBe(true);
|
|
6891
7177
|
});
|
|
6892
7178
|
});
|
|
6893
7179
|
}
|
|
@@ -7021,7 +7307,7 @@ function runSignatureConformance(runner, opts) {
|
|
|
7021
7307
|
} catch (err) {
|
|
7022
7308
|
caught = err;
|
|
7023
7309
|
}
|
|
7024
|
-
expect(
|
|
7310
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound)).toBe(true);
|
|
7025
7311
|
} finally {
|
|
7026
7312
|
await doc.close();
|
|
7027
7313
|
}
|
|
@@ -7133,14 +7419,14 @@ function runSignatureConformance(runner, opts) {
|
|
|
7133
7419
|
} catch (err) {
|
|
7134
7420
|
caught = err;
|
|
7135
7421
|
}
|
|
7136
|
-
expect(
|
|
7422
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.ProtectedDocument)).toBe(true);
|
|
7137
7423
|
caught = void 0;
|
|
7138
7424
|
try {
|
|
7139
7425
|
await doc.download({ mode: "rewrite" });
|
|
7140
7426
|
} catch (err) {
|
|
7141
7427
|
caught = err;
|
|
7142
7428
|
}
|
|
7143
|
-
expect(
|
|
7429
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.ProtectedDocument)).toBe(true);
|
|
7144
7430
|
const saved = await doc.download();
|
|
7145
7431
|
expect(saved.byteLength >= snapshot.revisions[1].end).toBe(true);
|
|
7146
7432
|
} finally {
|
|
@@ -7202,7 +7488,7 @@ function runSignatureConformance(runner, opts) {
|
|
|
7202
7488
|
} catch (err) {
|
|
7203
7489
|
caught = err;
|
|
7204
7490
|
}
|
|
7205
|
-
expect(
|
|
7491
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.ProtectedDocument)).toBe(true);
|
|
7206
7492
|
const field = await doc.forms.get(lockedRef);
|
|
7207
7493
|
expect(field.family).toBe("text");
|
|
7208
7494
|
expect(field.value === "changed").toBe(false);
|
|
@@ -7246,7 +7532,7 @@ function runSignatureConformance(runner, opts) {
|
|
|
7246
7532
|
} catch (err) {
|
|
7247
7533
|
caught = err;
|
|
7248
7534
|
}
|
|
7249
|
-
expect(
|
|
7535
|
+
expect(require_derive.EngineError.is(caught, require_format.EngineErrorCode.NotFound)).toBe(true);
|
|
7250
7536
|
} finally {
|
|
7251
7537
|
await doc.close();
|
|
7252
7538
|
}
|
|
@@ -7340,7 +7626,7 @@ function runAnalysisTests(runner, opts, engineOf, permitEngineOf, supported) {
|
|
|
7340
7626
|
}
|
|
7341
7627
|
const partial = await open(engineOf(), opts, opts.fixtures.partialChain);
|
|
7342
7628
|
try {
|
|
7343
|
-
expect(await caughtCode(() => partial.signatures.analyze({ since: { signatureIndex: 0 } }))).toBe(
|
|
7629
|
+
expect(await caughtCode(() => partial.signatures.analyze({ since: { signatureIndex: 0 } }))).toBe(require_format.EngineErrorCode.InvalidArg);
|
|
7344
7630
|
const byRevision = await partial.signatures.analyze({ since: { revisionIndex: 0 } });
|
|
7345
7631
|
expect(byRevision.later.revisionCount).toBe(2);
|
|
7346
7632
|
expect(byRevision.steps).toHaveLength(0);
|
|
@@ -7413,7 +7699,7 @@ async function caughtCode(run) {
|
|
|
7413
7699
|
await run();
|
|
7414
7700
|
return null;
|
|
7415
7701
|
} catch (err) {
|
|
7416
|
-
return err instanceof
|
|
7702
|
+
return err instanceof require_derive.EngineError ? err.code : "not-an-engine-error";
|
|
7417
7703
|
}
|
|
7418
7704
|
}
|
|
7419
7705
|
function runSigningTests(runner, opts, engineOf, supported) {
|
|
@@ -7455,11 +7741,11 @@ function runSigningTests(runner, opts, engineOf, supported) {
|
|
|
7455
7741
|
expect(prepared.byteRange[0]).toBe(0);
|
|
7456
7742
|
expect(prepared.byteRange[2] > prepared.byteRange[1]).toBe(true);
|
|
7457
7743
|
expect(prepared.expectedVersion.baseSha256).toBe(v0.sha256);
|
|
7458
|
-
expect(await caughtCode(() => doc.signatures.prepare({ field: sigRef() }))).toBe(
|
|
7744
|
+
expect(await caughtCode(() => doc.signatures.prepare({ field: sigRef() }))).toBe(require_format.EngineErrorCode.SigningPending);
|
|
7459
7745
|
expect(await caughtCode(() => doc.forms.setValue(textRef(), {
|
|
7460
7746
|
type: "text",
|
|
7461
7747
|
value: "x"
|
|
7462
|
-
}))).toBe(
|
|
7748
|
+
}))).toBe(require_format.EngineErrorCode.SigningPending);
|
|
7463
7749
|
const during = await doc.signatures.list();
|
|
7464
7750
|
expect(during.signatures[0].signed).toBe(false);
|
|
7465
7751
|
expect((await doc.version()).sha256).toBe(v0.sha256);
|
|
@@ -7470,7 +7756,7 @@ function runSigningTests(runner, opts, engineOf, supported) {
|
|
|
7470
7756
|
baseSha256: prepared.expectedVersion.baseSha256,
|
|
7471
7757
|
editsVersion: prepared.expectedVersion.editsVersion + 1
|
|
7472
7758
|
}
|
|
7473
|
-
}))).toBe(
|
|
7759
|
+
}))).toBe(require_format.EngineErrorCode.SigningVersionMismatch);
|
|
7474
7760
|
const result = await doc.signatures.complete({
|
|
7475
7761
|
signingId: prepared.signingId,
|
|
7476
7762
|
cms: FAKE_CMS,
|
|
@@ -7518,7 +7804,7 @@ function runSigningTests(runner, opts, engineOf, supported) {
|
|
|
7518
7804
|
type: "text",
|
|
7519
7805
|
value: "after"
|
|
7520
7806
|
});
|
|
7521
|
-
expect(await caughtCode(() => doc.signatures.prepare({ field: sigRef() }))).toBe(
|
|
7807
|
+
expect(await caughtCode(() => doc.signatures.prepare({ field: sigRef() }))).toBe(require_format.EngineErrorCode.SignatureRefused);
|
|
7522
7808
|
expect(events.filter((t) => t === "signature.prepared")).toHaveLength(1);
|
|
7523
7809
|
expect(events.filter((t) => t === "signature.completed")).toHaveLength(1);
|
|
7524
7810
|
expect(events.filter((t) => t === "document.versioned")).toHaveLength(1);
|
|
@@ -7579,8 +7865,8 @@ function runSigningTests(runner, opts, engineOf, supported) {
|
|
|
7579
7865
|
expect(doc.security.allows("doc.pages.assemble")).toBe(false);
|
|
7580
7866
|
expect(doc.security.allows("doc.forms.fill")).toBe(true);
|
|
7581
7867
|
const list = await doc.pages.list();
|
|
7582
|
-
expect(await caughtCode(() => doc.pages.delete([list.pages[0].pageObjectNumber]))).toBe(
|
|
7583
|
-
expect(await caughtCode(() => doc.download({ mode: "rewrite" }))).toBe(
|
|
7868
|
+
expect(await caughtCode(() => doc.pages.delete([list.pages[0].pageObjectNumber]))).toBe(require_format.EngineErrorCode.ProtectedDocument);
|
|
7869
|
+
expect(await caughtCode(() => doc.download({ mode: "rewrite" }))).toBe(require_format.EngineErrorCode.ProtectedDocument);
|
|
7584
7870
|
await doc.forms.setValue(textRef(), {
|
|
7585
7871
|
type: "text",
|
|
7586
7872
|
value: "filled"
|
|
@@ -7619,7 +7905,7 @@ function runSigningTests(runner, opts, engineOf, supported) {
|
|
|
7619
7905
|
expect(await caughtCode(() => doc.forms.setValue(textRef(), {
|
|
7620
7906
|
type: "text",
|
|
7621
7907
|
value: "nope"
|
|
7622
|
-
}))).toBe(
|
|
7908
|
+
}))).toBe(require_format.EngineErrorCode.ProtectedDocument);
|
|
7623
7909
|
} finally {
|
|
7624
7910
|
await doc.close();
|
|
7625
7911
|
}
|
|
@@ -7641,7 +7927,7 @@ function runSigningTests(runner, opts, engineOf, supported) {
|
|
|
7641
7927
|
signingId: prepared.signingId,
|
|
7642
7928
|
cms: FAKE_CMS,
|
|
7643
7929
|
expectedVersion: prepared.expectedVersion
|
|
7644
|
-
}))).toBe(
|
|
7930
|
+
}))).toBe(require_format.EngineErrorCode.NotFound);
|
|
7645
7931
|
} finally {
|
|
7646
7932
|
await doc.close();
|
|
7647
7933
|
}
|
|
@@ -7752,6 +8038,7 @@ exports.runAnnotationReadConformance = runAnnotationReadConformance;
|
|
|
7752
8038
|
exports.runAttachmentConformance = runAttachmentConformance;
|
|
7753
8039
|
exports.runDocumentEventsConformance = runDocumentEventsConformance;
|
|
7754
8040
|
exports.runFormConformance = runFormConformance;
|
|
8041
|
+
exports.runMeasurementConformance = runMeasurementConformance;
|
|
7755
8042
|
exports.runMetadataConformance = runMetadataConformance;
|
|
7756
8043
|
exports.runNamedPagesConformance = runNamedPagesConformance;
|
|
7757
8044
|
exports.runPageDeleteConformance = runPageDeleteConformance;
|