@cloudpdf/engine 3.0.0-next.11 → 3.0.0-next.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -560,6 +560,31 @@ var CloudDocumentPagesService = class {
560
560
  return result;
561
561
  });
562
562
  }
563
+ setName(input) {
564
+ return this.runNameMutation(_embedpdf_engine_core_wire.wirePaths.layerPagesNames(this.docId, this.layerName), input, input.name, input.pageObjectNumber);
565
+ }
566
+ removeName(input) {
567
+ return this.runNameMutation(_embedpdf_engine_core_wire.wirePaths.layerPagesNamesDelete(this.docId, this.layerName), input, input.name, null);
568
+ }
569
+ /**
570
+ * Named pages are LAYOUT: both verbs share the page-move patch exactly —
571
+ * docVersion + layoutVersion advance, no per-page pin changes, so the
572
+ * cached manifest is patched in place and the fresh layout is published.
573
+ */
574
+ runNameMutation(path, body, name, pageObjectNumber) {
575
+ if (this.isClosed()) return _embedpdf_engine_core_runtime.AbortablePromise.rejectReason(new _embedpdf_engine_core_runtime.EngineError(_embedpdf_engine_core_runtime.EngineErrorCode.DocNotOpen, `document ${this.docId} is closed`));
576
+ return _embedpdf_engine_core_runtime.AbortablePromise.run(async (signal) => {
577
+ const result = await this.http.postJson(path, body, (raw) => _embedpdf_engine_core_wire.PageNameResultSchema.parse(raw), signal);
578
+ if (result.cache) this.manifest.applyPageStructure(result.cache);
579
+ this.publisher.publishLocal({
580
+ type: "pages.named",
581
+ name,
582
+ pageObjectNumber,
583
+ ...result
584
+ });
585
+ return result;
586
+ });
587
+ }
563
588
  rotate(pageObjectNumbers, rotation) {
564
589
  if (this.isClosed()) return _embedpdf_engine_core_runtime.AbortablePromise.rejectReason(new _embedpdf_engine_core_runtime.EngineError(_embedpdf_engine_core_runtime.EngineErrorCode.DocNotOpen, `document ${this.docId} is closed`));
565
590
  return _embedpdf_engine_core_runtime.AbortablePromise.run(async (signal) => {
@@ -1185,6 +1210,29 @@ var CloudPageAnnotationsService = class {
1185
1210
  return this.absorbMutation(result, "annotation.moved");
1186
1211
  });
1187
1212
  }
1213
+ flatten(refs, usage = "display") {
1214
+ if (this.isClosed()) return _embedpdf_engine_core_runtime.AbortablePromise.rejectReason(new _embedpdf_engine_core_runtime.EngineError(_embedpdf_engine_core_runtime.EngineErrorCode.DocNotOpen, `document ${this.docId} is closed`));
1215
+ for (const r of refs) if (r.pageObjectNumber !== this.pageObjectNumber) return _embedpdf_engine_core_runtime.AbortablePromise.rejectReason(new _embedpdf_engine_core_runtime.EngineError(_embedpdf_engine_core_runtime.EngineErrorCode.InvalidArg, `flatten ref points at page ${r.pageObjectNumber}; service is bound to page ${this.pageObjectNumber}`));
1216
+ const path = _embedpdf_engine_core_wire.wirePaths.layerPageAnnotationsFlatten(this.docId, this.layerName, this.pageObjectNumber);
1217
+ return _embedpdf_engine_core_runtime.AbortablePromise.run(async (signal) => {
1218
+ const result = await this.http.postJson(path, {
1219
+ refs,
1220
+ usage
1221
+ }, (raw) => _embedpdf_engine_core_wire.AnnotationFlattenResultSchema.parse(raw), signal);
1222
+ if (result.meta === null) return result;
1223
+ this.manifest.apply(result.meta, ["content", "annotations"]);
1224
+ this.publisher.publishLocal({
1225
+ type: "annotations.flattened",
1226
+ ...result
1227
+ });
1228
+ return result;
1229
+ });
1230
+ }
1231
+ exportAppearance(refs) {
1232
+ if (this.isClosed()) return _embedpdf_engine_core_runtime.AbortablePromise.rejectReason(new _embedpdf_engine_core_runtime.EngineError(_embedpdf_engine_core_runtime.EngineErrorCode.DocNotOpen, `document ${this.docId} is closed`));
1233
+ for (const r of refs) if (r.pageObjectNumber !== this.pageObjectNumber) return _embedpdf_engine_core_runtime.AbortablePromise.rejectReason(new _embedpdf_engine_core_runtime.EngineError(_embedpdf_engine_core_runtime.EngineErrorCode.InvalidArg, `exportAppearance ref points at page ${r.pageObjectNumber}; service is bound to page ${this.pageObjectNumber}`));
1234
+ return _embedpdf_engine_core_runtime.AbortablePromise.run(async (signal) => this.http.postJsonBytes(_embedpdf_engine_core_wire.wirePaths.layerPageAnnotationsAppearance(this.docId, this.layerName, this.pageObjectNumber), { refs }, signal));
1235
+ }
1188
1236
  /**
1189
1237
  * Patch the cached manifest, then publish the mutation to the document's
1190
1238
  * event stream (in that order — listeners reading the manifest in their