@embedpdf/engine-services 3.0.0-next.2 → 3.0.0-next.4

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.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PdfFunctions, PdfRuntimeMemory, PdfRuntimeModule, Ptr } from "@embedpdf/engine-runtime";
2
- import { ActionReadBudget, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationListMutationMeta, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationMutationKind, AnnotationRef, AnnotationStableId, AnnotationUpdateResult, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileInfo, AttachmentFileWorkerPayload, DocumentActionsSnapshot, DocumentEvent, DocumentEventInit, DocumentEventStream, DocumentMetadata, DocumentSecurityProbeInfo, EmbeddedFileItem, EmbeddedFileRef, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormSetValueResult, FormSnapshot, FormWidgetRef, MetadataPatch, MetadataUpdateResult, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometrySnapshot, PageInsertResult, PageListSnapshot, PageMoveResult, PageObjectNumber, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionToken, SearchRequest, SearchSlice, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
2
+ import { ActionReadBudget, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationListMutationMeta, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationMutationKind, AnnotationRef, AnnotationStableId, AnnotationUpdateResult, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileInfo, AttachmentFileWorkerPayload, DocumentActionsSnapshot, DocumentEvent, DocumentEventInit, DocumentEventStream, DocumentMetadata, DocumentSecurityProbeInfo, EmbeddedFileItem, EmbeddedFileRef, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormSetValueResult, FormSnapshot, FormWidgetRef, MetadataPatch, MetadataUpdateResult, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometryRun, PageGeometrySnapshot, PageInsertResult, PageListSnapshot, PageMoveResult, PageObjectNumber, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfQuad, PdfRect, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionToken, SearchRequest, SearchSlice, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
3
3
  //#region src/runtime/lifecycle/bootstrap.d.ts
4
4
  /**
5
5
  * Initialize the thread-confined PDFium runtime for the calling thread. Each
@@ -626,6 +626,7 @@ declare class RedactionApplier {
626
626
  */
627
627
  private preflight;
628
628
  private applyAllOnPage;
629
+ private pageHasRedactAnnotations;
629
630
  private applyRefsOnPage;
630
631
  }
631
632
  //#endregion
@@ -658,21 +659,93 @@ declare class PageTextReader {
658
659
  }
659
660
  //#endregion
660
661
  //#region src/features/geometry/PageGeometryReader.d.ts
662
+ /**
663
+ * One glyph as read from `EPDFText_GetCharGeometry`, plus the run-grouping
664
+ * context sampled alongside it. Pure data — no native handles — so the
665
+ * grouping stage below is a pure function the tests can drive directly.
666
+ */
667
+ interface RawGeometryGlyphRecord {
668
+ /** Grouping key: the glyph's text object handle (opaque identity). */
669
+ objectKey: number | bigint;
670
+ /** Sampled at each text object's first glyph (run splits inherit it). */
671
+ fontSize?: number;
672
+ /**
673
+ * Wire flags (bit 1 = space, bit 2 = empty). Synthesized-but-visible
674
+ * glyphs (/ActualText pieces) stay 0, exactly like the legacy reader —
675
+ * they represent real, selectable text.
676
+ */
677
+ flags: number;
678
+ /** Page-space AABB (zeroed when empty). */
679
+ looseBox: PdfRect;
680
+ tightBox?: PdfRect;
681
+ /** Oriented cells — real glyphs with a usable (non-singular) matrix only. */
682
+ looseQuad?: PdfQuad;
683
+ tightQuad?: PdfQuad;
684
+ /** Native uprightness of the char matrix (empty glyphs: true, inert). */
685
+ upright: boolean;
686
+ /** Baseline angle (radians CCW, PDF y-up); 0 when upright. */
687
+ rotation: number;
688
+ /** True when the ascent vector maps opposite the rotated +y (det < 0). */
689
+ ascentFlip: boolean;
690
+ }
661
691
  /**
662
692
  * Geometry-only text layout reader.
663
693
  *
664
694
  * Emits geometry in PDF user space (y-up edges) — the canonical engine
665
695
  * geometry. The viewer converts to content/view space via the page geometry
666
696
  * matrix; this reader applies NO Y-flip or device transform.
697
+ *
698
+ * One `EPDFText_GetCharGeometry` call per glyph supplies boxes, oriented
699
+ * cells, and flags together; `buildRunsFromRawGlyphs` then groups glyphs
700
+ * into the upright/rotated run union. Upright runs are byte-identical to the
701
+ * pre-orientation reader (quads the native layer offers are deliberately
702
+ * dropped — the dominant case never pays for orientation).
667
703
  */
668
704
  declare class PageGeometryReader {
669
705
  private readonly runtime;
670
706
  private readonly session;
671
707
  constructor(runtime: PdfRuntimeModule, session: DocumentSession);
672
708
  read(pageObjectNumber: PageObjectNumber, signal: AbortSignal): PageGeometrySnapshot;
673
- private buildRunsFromGlyphs;
674
- private readGlyphInfo;
709
+ private readGlyphRaw;
675
710
  }
711
+ /**
712
+ * Group per-glyph records into the run union. Pure — exported for tests.
713
+ *
714
+ * Runs split on text-object change (the legacy rule) and on orientation
715
+ * change between classifiable glyphs (θ drift / mixed orientation). A run's
716
+ * variant is decided by its FIRST classifiable glyph:
717
+ * - empty glyphs never classify (they adopt the run's variant);
718
+ * - real glyphs WITHOUT an oriented cell (singular matrix, synthesized
719
+ * /ActualText pieces) classify as upright — box-only data degrades to
720
+ * exactly the legacy behavior;
721
+ * - real glyphs with a non-upright matrix classify as rotated.
722
+ * Runs that never see a classifiable glyph emit as upright (degenerate,
723
+ * legacy behavior).
724
+ */
725
+ declare function buildRunsFromRawGlyphs(records: RawGeometryGlyphRecord[]): PageGeometryRun[];
726
+ //#endregion
727
+ //#region src/runtime/memory/structs.d.ts
728
+ /** Generated from `EPDF_CHAR_GEOMETRY`; pinned by native static_asserts. */
729
+ declare const EPDF_CHAR_GEOMETRY_LAYOUT: {
730
+ readonly bytes: 124;
731
+ readonly offsets: {
732
+ readonly looseBox: 0;
733
+ readonly tightBox: 16;
734
+ readonly looseQuad: 32;
735
+ readonly tightQuad: 64;
736
+ readonly matrix: 96;
737
+ readonly flags: 120;
738
+ };
739
+ readonly flags: {
740
+ readonly hasTightBox: number;
741
+ readonly hasLooseQuad: number;
742
+ readonly hasTightQuad: number;
743
+ readonly upright: number;
744
+ readonly space: number;
745
+ readonly empty: number;
746
+ readonly synthesized: number;
747
+ };
748
+ };
676
749
  //#endregion
677
750
  //#region src/features/render/PageRenderReader.d.ts
678
751
  declare class PageRenderReader {
@@ -1477,5 +1550,5 @@ declare class WorkerHost {
1477
1550
  private saveLayerArtifact;
1478
1551
  }
1479
1552
  //#endregion
1480
- export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CloseStack, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EventHub, FontRegistrar, FormMutator, FormReader, FormsEffectsApplier, type ImpactInputs, type LayerSource, LocalRevisionAuthority, MetadataMutator, MetadataReader, type MutationKind, type OpenedPdfDocument, type OpenedPdfDocumentKind, PageGeometryReader, PagesReader as PageLayoutReader, PagesReader, PagePtrPool, PageRenderReader as PageRasterReader, PageRenderReader, type PageRecord, PageTextReader, PagesExtractor, PagesFlattener, PagesInserter, RawAnnotationReader, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, type StartupFontSpec, WorkerHost, computeMutationImpact, destroyLibrary, disposeFormModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, throwIfAborted, writeAttachmentFilePayload };
1553
+ export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CloseStack, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EPDF_CHAR_GEOMETRY_LAYOUT, EventHub, FontRegistrar, FormMutator, FormReader, FormsEffectsApplier, type ImpactInputs, type LayerSource, LocalRevisionAuthority, MetadataMutator, MetadataReader, type MutationKind, type OpenedPdfDocument, type OpenedPdfDocumentKind, PageGeometryReader, PagesReader as PageLayoutReader, PagesReader, PagePtrPool, PageRenderReader as PageRasterReader, PageRenderReader, type PageRecord, PageTextReader, PagesExtractor, PagesFlattener, PagesInserter, RawAnnotationReader, type RawGeometryGlyphRecord, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, type StartupFontSpec, WorkerHost, buildRunsFromRawGlyphs, computeMutationImpact, destroyLibrary, disposeFormModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, throwIfAborted, writeAttachmentFilePayload };
1481
1554
  //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ActionReadBudget, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationListMutationMeta, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationMutationKind, AnnotationRef, AnnotationStableId, AnnotationUpdateResult, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileInfo, AttachmentFileWorkerPayload, DocumentActionsSnapshot, DocumentEvent, DocumentEventInit, DocumentEventStream, DocumentMetadata, DocumentSecurityProbeInfo, EmbeddedFileItem, EmbeddedFileRef, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormSetValueResult, FormSnapshot, FormWidgetRef, MetadataPatch, MetadataUpdateResult, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometrySnapshot, PageInsertResult, PageListSnapshot, PageMoveResult, PageObjectNumber, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionToken, SearchRequest, SearchSlice, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
1
+ import { ActionReadBudget, AnnotationActor, AnnotationAppearanceRenderOptions, AnnotationAppearancesResult, AnnotationCreateResult, AnnotationDeleteResult, AnnotationListMutationMeta, AnnotationListPageSnapshot, AnnotationListSnapshotAllPages, AnnotationMoveResult, AnnotationMutationKind, AnnotationRef, AnnotationStableId, AnnotationUpdateResult, AttachmentCreateResult, AttachmentDeleteResult, AttachmentFileInfo, AttachmentFileWorkerPayload, DocumentActionsSnapshot, DocumentEvent, DocumentEventInit, DocumentEventStream, DocumentMetadata, DocumentSecurityProbeInfo, EmbeddedFileItem, EmbeddedFileRef, FormDataFormat, FormEffect, FormEffectsResult, FormFieldDTO, FormFieldDraft, FormFieldPatch, FormFieldRef, FormFieldValue, FormImportResult, FormRepairResult, FormSetValueResult, FormSnapshot, FormWidgetRef, MetadataPatch, MetadataUpdateResult, PageDeleteResult, PageFlattenResult, PageFlattenUsage, PageGeometryRun, PageGeometrySnapshot, PageInsertResult, PageListSnapshot, PageMoveResult, PageObjectNumber, PageRenderOptions, PageRotateResult, PageRotation, PageState, PageTextSnapshot, PdfActionTree, PdfQuad, PdfRect, PdfSaveMode, RedactionApplyResult, RedactionApplyScope, RevisionToken, SearchRequest, SearchSlice, WeakAnnotationState, WireAnnotationDraft, WireAnnotationPatch, WireAttachmentFile, WirePack, WireResource, WireResourceMap, WorkerRequest, WorkerResponse } from "@embedpdf/engine-core/runtime";
2
2
  import { PdfFunctions, PdfRuntimeMemory, PdfRuntimeModule, Ptr } from "@embedpdf/engine-runtime";
3
3
  //#region src/runtime/lifecycle/bootstrap.d.ts
4
4
  /**
@@ -626,6 +626,7 @@ declare class RedactionApplier {
626
626
  */
627
627
  private preflight;
628
628
  private applyAllOnPage;
629
+ private pageHasRedactAnnotations;
629
630
  private applyRefsOnPage;
630
631
  }
631
632
  //#endregion
@@ -658,21 +659,93 @@ declare class PageTextReader {
658
659
  }
659
660
  //#endregion
660
661
  //#region src/features/geometry/PageGeometryReader.d.ts
662
+ /**
663
+ * One glyph as read from `EPDFText_GetCharGeometry`, plus the run-grouping
664
+ * context sampled alongside it. Pure data — no native handles — so the
665
+ * grouping stage below is a pure function the tests can drive directly.
666
+ */
667
+ interface RawGeometryGlyphRecord {
668
+ /** Grouping key: the glyph's text object handle (opaque identity). */
669
+ objectKey: number | bigint;
670
+ /** Sampled at each text object's first glyph (run splits inherit it). */
671
+ fontSize?: number;
672
+ /**
673
+ * Wire flags (bit 1 = space, bit 2 = empty). Synthesized-but-visible
674
+ * glyphs (/ActualText pieces) stay 0, exactly like the legacy reader —
675
+ * they represent real, selectable text.
676
+ */
677
+ flags: number;
678
+ /** Page-space AABB (zeroed when empty). */
679
+ looseBox: PdfRect;
680
+ tightBox?: PdfRect;
681
+ /** Oriented cells — real glyphs with a usable (non-singular) matrix only. */
682
+ looseQuad?: PdfQuad;
683
+ tightQuad?: PdfQuad;
684
+ /** Native uprightness of the char matrix (empty glyphs: true, inert). */
685
+ upright: boolean;
686
+ /** Baseline angle (radians CCW, PDF y-up); 0 when upright. */
687
+ rotation: number;
688
+ /** True when the ascent vector maps opposite the rotated +y (det < 0). */
689
+ ascentFlip: boolean;
690
+ }
661
691
  /**
662
692
  * Geometry-only text layout reader.
663
693
  *
664
694
  * Emits geometry in PDF user space (y-up edges) — the canonical engine
665
695
  * geometry. The viewer converts to content/view space via the page geometry
666
696
  * matrix; this reader applies NO Y-flip or device transform.
697
+ *
698
+ * One `EPDFText_GetCharGeometry` call per glyph supplies boxes, oriented
699
+ * cells, and flags together; `buildRunsFromRawGlyphs` then groups glyphs
700
+ * into the upright/rotated run union. Upright runs are byte-identical to the
701
+ * pre-orientation reader (quads the native layer offers are deliberately
702
+ * dropped — the dominant case never pays for orientation).
667
703
  */
668
704
  declare class PageGeometryReader {
669
705
  private readonly runtime;
670
706
  private readonly session;
671
707
  constructor(runtime: PdfRuntimeModule, session: DocumentSession);
672
708
  read(pageObjectNumber: PageObjectNumber, signal: AbortSignal): PageGeometrySnapshot;
673
- private buildRunsFromGlyphs;
674
- private readGlyphInfo;
709
+ private readGlyphRaw;
675
710
  }
711
+ /**
712
+ * Group per-glyph records into the run union. Pure — exported for tests.
713
+ *
714
+ * Runs split on text-object change (the legacy rule) and on orientation
715
+ * change between classifiable glyphs (θ drift / mixed orientation). A run's
716
+ * variant is decided by its FIRST classifiable glyph:
717
+ * - empty glyphs never classify (they adopt the run's variant);
718
+ * - real glyphs WITHOUT an oriented cell (singular matrix, synthesized
719
+ * /ActualText pieces) classify as upright — box-only data degrades to
720
+ * exactly the legacy behavior;
721
+ * - real glyphs with a non-upright matrix classify as rotated.
722
+ * Runs that never see a classifiable glyph emit as upright (degenerate,
723
+ * legacy behavior).
724
+ */
725
+ declare function buildRunsFromRawGlyphs(records: RawGeometryGlyphRecord[]): PageGeometryRun[];
726
+ //#endregion
727
+ //#region src/runtime/memory/structs.d.ts
728
+ /** Generated from `EPDF_CHAR_GEOMETRY`; pinned by native static_asserts. */
729
+ declare const EPDF_CHAR_GEOMETRY_LAYOUT: {
730
+ readonly bytes: 124;
731
+ readonly offsets: {
732
+ readonly looseBox: 0;
733
+ readonly tightBox: 16;
734
+ readonly looseQuad: 32;
735
+ readonly tightQuad: 64;
736
+ readonly matrix: 96;
737
+ readonly flags: 120;
738
+ };
739
+ readonly flags: {
740
+ readonly hasTightBox: number;
741
+ readonly hasLooseQuad: number;
742
+ readonly hasTightQuad: number;
743
+ readonly upright: number;
744
+ readonly space: number;
745
+ readonly empty: number;
746
+ readonly synthesized: number;
747
+ };
748
+ };
676
749
  //#endregion
677
750
  //#region src/features/render/PageRenderReader.d.ts
678
751
  declare class PageRenderReader {
@@ -1477,5 +1550,5 @@ declare class WorkerHost {
1477
1550
  private saveLayerArtifact;
1478
1551
  }
1479
1552
  //#endregion
1480
- export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CloseStack, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EventHub, FontRegistrar, FormMutator, FormReader, FormsEffectsApplier, type ImpactInputs, type LayerSource, LocalRevisionAuthority, MetadataMutator, MetadataReader, type MutationKind, type OpenedPdfDocument, type OpenedPdfDocumentKind, PageGeometryReader, PagesReader as PageLayoutReader, PagesReader, PagePtrPool, PageRenderReader as PageRasterReader, PageRenderReader, type PageRecord, PageTextReader, PagesExtractor, PagesFlattener, PagesInserter, RawAnnotationReader, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, type StartupFontSpec, WorkerHost, computeMutationImpact, destroyLibrary, disposeFormModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, throwIfAborted, writeAttachmentFilePayload };
1553
+ export { ALL_STANDARD_SECURITY_PERMISSIONS, type AcquiredBaseDocument, ActionReadBudgetTracker, AnnotationAppearanceReader, AnnotationMutator, AnnotationReader, AttachmentMutator, AttachmentReader, BaseDocumentRegistry, CloseStack, DocumentActionsReader, PagesMutator as DocumentPagesMutator, PagesMutator, DocumentSaver, DocumentSession, EPDF_CHAR_GEOMETRY_LAYOUT, EventHub, FontRegistrar, FormMutator, FormReader, FormsEffectsApplier, type ImpactInputs, type LayerSource, LocalRevisionAuthority, MetadataMutator, MetadataReader, type MutationKind, type OpenedPdfDocument, type OpenedPdfDocumentKind, PageGeometryReader, PagesReader as PageLayoutReader, PagesReader, PagePtrPool, PageRenderReader as PageRasterReader, PageRenderReader, type PageRecord, PageTextReader, PagesExtractor, PagesFlattener, PagesInserter, RawAnnotationReader, type RawGeometryGlyphRecord, RedactionApplier, type RevisionAuthority, SearchReader, SecurityReader, SessionEventPublisher, type StartupFontSpec, WorkerHost, buildRunsFromRawGlyphs, computeMutationImpact, destroyLibrary, disposeFormModel, ensureInitialized, formatPdfDate, generateUuid, hasAllStandardSecurityPermissions, normalizeU32, openFatMemoryDocument, openLayerDocument, pdfDateToIso, readActionModel, readAttachmentFileInfo, throwIfAborted, writeAttachmentFilePayload };
1481
1554
  //# sourceMappingURL=index.d.ts.map