@qrcommunication/gigapdf-lib 0.65.0 → 0.66.0

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.ts CHANGED
@@ -483,40 +483,292 @@ interface GigaCharStyle {
483
483
  color: [number, number, number] | null;
484
484
  valign: 'baseline' | 'super' | 'sub';
485
485
  }
486
- /** An inline node (tagged): a styled run, a line break, an image, or a link. */
486
+ /** An axis-aligned placement box, lower-left `(x,y)` + size, in PDF points. */
487
+ interface GigaRect {
488
+ x: number;
489
+ y: number;
490
+ w: number;
491
+ h: number;
492
+ }
493
+ /** A hyperlink destination (tagged; mirror of `model::LinkTarget`). */
494
+ type GigaLinkTarget = {
495
+ t: 'url';
496
+ v: string;
497
+ } | {
498
+ t: 'page';
499
+ v: number;
500
+ };
501
+ /**
502
+ * An inline (within-paragraph) node, tagged by `t` (mirror of `model::Inline`).
503
+ * `run` carries the styled text + its `source_index` back to the editable
504
+ * content-stream operator; `br` is a hard line break; `image` an inline image;
505
+ * `link` wraps children with a destination.
506
+ */
487
507
  type GigaInline = {
488
508
  t: 'run';
509
+ v: GigaInlineRun;
510
+ } | {
511
+ t: 'br';
512
+ } | {
513
+ t: 'image';
514
+ v: GigaImageRef;
515
+ } | {
516
+ t: 'link';
517
+ href: GigaLinkTarget;
518
+ children: GigaInline[];
519
+ };
520
+ /** A styled span of text (mirror of `model::InlineRun`). */
521
+ interface GigaInlineRun {
489
522
  text: string;
490
523
  style: GigaCharStyle;
524
+ /** Index of the source content-stream run for in-place round-tripping, or `null`. */
491
525
  source_index: number | null;
526
+ }
527
+ /** Paragraph-level formatting (mirror of `model::style::ParagraphStyle`). */
528
+ interface GigaParagraphStyle {
529
+ align: 'left' | 'center' | 'right' | 'justify';
530
+ space_before_pt: number;
531
+ space_after_pt: number;
532
+ indent_left_pt: number;
533
+ indent_right_pt: number;
534
+ /** First-line indent (positive) or hanging indent (negative), in points. */
535
+ first_line_pt: number;
536
+ /** Leading policy: font-natural, a size multiple, or a fixed point value. */
537
+ line_height: {
538
+ t: 'normal';
539
+ } | {
540
+ t: 'multiple';
541
+ v: number;
542
+ } | {
543
+ t: 'points';
544
+ v: number;
545
+ };
546
+ }
547
+ /** A paragraph: its own style, an optional named-style ref, and its inline runs. */
548
+ interface GigaParagraph {
549
+ style: GigaParagraphStyle;
550
+ /** Named style this paragraph derives from, if any. */
551
+ style_ref: string | null;
552
+ runs: GigaInline[];
553
+ }
554
+ /** A heading (`level` 1..=6) wrapping a paragraph (mirror of `model::Heading`). */
555
+ interface GigaHeading {
556
+ level: number;
557
+ para: GigaParagraph;
558
+ }
559
+ /** A list bullet/number style (tagged; mirror of `model::ListMarker`). */
560
+ type GigaListMarker = {
561
+ t: 'bullet';
562
+ v: string;
492
563
  } | {
493
- t: 'break';
564
+ t: 'decimal';
494
565
  } | {
495
- t: 'image';
496
- [k: string]: unknown;
566
+ t: 'lower_alpha';
497
567
  } | {
498
- t: 'link';
499
- [k: string]: unknown;
568
+ t: 'upper_alpha';
569
+ } | {
570
+ t: 'lower_roman';
571
+ } | {
572
+ t: 'upper_roman';
500
573
  };
501
- /** A block payload (tagged by `t`); only the common shapes are spelled out. */
502
- interface GigaBlockKind {
503
- t: 'paragraph' | 'heading' | 'list' | 'table' | 'image' | 'shape' | 'textbox' | 'sheet' | 'slide';
504
- /** The variant body — e.g. a paragraph carries `{ runs: GigaInline[], … }`. */
505
- v?: unknown;
574
+ /** One list item: nested blocks at a given `level` (mirror of `model::ListItem`). */
575
+ interface GigaListItem {
576
+ blocks: GigaBlock[];
577
+ level: number;
578
+ }
579
+ /** An ordered or unordered list (mirror of `model::List`). */
580
+ interface GigaList {
581
+ ordered: boolean;
582
+ marker: GigaListMarker;
583
+ items: GigaListItem[];
584
+ }
585
+ /** A table cell: block content, span, and optional RGB shading (`model::Cell`). */
586
+ interface GigaTableCell {
587
+ blocks: GigaBlock[];
588
+ col_span: number;
589
+ row_span: number;
590
+ /** RGB `0..=1` background, or `null` for no shading. */
591
+ shading: [number, number, number] | null;
592
+ }
593
+ /** A table row: its cells and an optional fixed height in points (`model::Row`). */
594
+ interface GigaTableRow {
595
+ cells: GigaTableCell[];
596
+ height: number | null;
597
+ }
598
+ /** A table/cell border (mirror of `model::BorderStyle`). */
599
+ interface GigaBorderStyle {
600
+ width: number;
601
+ color: [number, number, number];
602
+ }
603
+ /** A table: rows of cells, explicit column widths, and a border (`model::Table`). */
604
+ interface GigaTable {
605
+ rows: GigaTableRow[];
606
+ col_widths: number[];
607
+ border: GigaBorderStyle;
608
+ }
609
+ /** A reference to an image blob in the document's resource table (`model::ImageRef`). */
610
+ interface GigaImageRef {
611
+ /** Content-hash key into `GigaDocument.resources.images`. */
612
+ resource: number;
613
+ alt: string | null;
614
+ }
615
+ /** A single vector path segment (tagged; mirror of `content::vector::PathSeg`). */
616
+ type GigaPathSeg = {
617
+ t: 'm';
618
+ x: number;
619
+ y: number;
620
+ } | {
621
+ t: 'l';
622
+ x: number;
623
+ y: number;
624
+ } | {
625
+ t: 'c';
626
+ x1: number;
627
+ y1: number;
628
+ x2: number;
629
+ y2: number;
630
+ x: number;
631
+ y: number;
632
+ } | {
633
+ t: 'z';
634
+ };
635
+ /** A vector shape: a path with fill/stroke styling (mirror of `model::Shape`). */
636
+ interface GigaShape {
637
+ segments: GigaPathSeg[];
638
+ /** RGB `0..=1` fill, or `null` when unfilled. */
639
+ fill: [number, number, number] | null;
640
+ /** RGB `0..=1` stroke, or `null` when unstroked. */
641
+ stroke: [number, number, number] | null;
642
+ stroke_width: number;
643
+ dash: number[];
506
644
  }
645
+ /** A free-floating text box holding a list of blocks (mirror of `model::TextBox`). */
646
+ interface GigaTextBox {
647
+ blocks: GigaBlock[];
648
+ }
649
+ /** A typed spreadsheet cell (mirror of `model::SheetCell`). */
650
+ interface GigaSheetCell {
651
+ value: GigaCellValue;
652
+ number_format: string | null;
653
+ /** RGB `0..=1` cell fill, or `null` for none. */
654
+ fill: [number, number, number] | null;
655
+ style: GigaCharStyle;
656
+ }
657
+ /** One spreadsheet row (mirror of `model::SheetRow`). */
658
+ interface GigaSheetRow {
659
+ cells: GigaSheetCell[];
660
+ }
661
+ /** An inclusive merged-cell rectangle `(r0,c0)..=(r1,c1)`, zero-based. */
662
+ interface GigaMergeRange {
663
+ r0: number;
664
+ c0: number;
665
+ r1: number;
666
+ c1: number;
667
+ }
668
+ /** A single named worksheet (mirror of `model::Sheet`). */
669
+ interface GigaSheet {
670
+ name: string;
671
+ rows: GigaSheetRow[];
672
+ merges: GigaMergeRange[];
673
+ col_widths: number[];
674
+ }
675
+ /** A block of spreadsheet content: one or more sheets (mirror of `model::SheetBlock`). */
676
+ interface GigaSheetBlock {
677
+ sheets: GigaSheet[];
678
+ }
679
+ /** A slide layout placeholder role (tagged; mirror of `model::PlaceholderRole`). */
680
+ type GigaPlaceholderRole = {
681
+ t: 'title';
682
+ } | {
683
+ t: 'subtitle';
684
+ } | {
685
+ t: 'body';
686
+ } | {
687
+ t: 'other';
688
+ v: string;
689
+ };
690
+ /** A slide placeholder: a block tagged with its semantic role (`model::Placeholder`). */
691
+ interface GigaPlaceholder {
692
+ role: GigaPlaceholderRole;
693
+ block: GigaBlock;
694
+ }
695
+ /** Resolved page size + margins, in points (mirror of `model::geom::PageGeometry`). */
696
+ interface GigaPageGeometry {
697
+ width: number;
698
+ height: number;
699
+ margins: {
700
+ top: number;
701
+ right: number;
702
+ bottom: number;
703
+ left: number;
704
+ };
705
+ }
706
+ /** A single slide (mirror of `model::Slide`). */
707
+ interface GigaSlide {
708
+ geometry: GigaPageGeometry;
709
+ shapes: GigaBlock[];
710
+ placeholders: GigaPlaceholder[];
711
+ notes: GigaBlock[] | null;
712
+ }
713
+ /** A block of presentation content: an ordered list of slides (`model::SlideBlock`). */
714
+ interface GigaSlideBlock {
715
+ slides: GigaSlide[];
716
+ }
717
+ /**
718
+ * A block payload, **fully typed and discriminated by `t`** (mirror of
719
+ * `model::BlockKind`'s JSON). Narrow on `kind.t` to read the variant body in
720
+ * `kind.v` — e.g. a `paragraph` exposes `v.runs` (each `run` carrying
721
+ * `style.bold`/`style.italic`/`style.size_pt`/`style.color`), a `heading` its
722
+ * `v.level`, a `table` its `v.rows[].cells[]` (with `col_span`/`row_span`), and a
723
+ * `list` its `v.ordered` + `v.items`. This is what lets a thin editor render the
724
+ * recognised structure (bold, headings, tables, lists) 1:1.
725
+ */
726
+ type GigaBlockKind = {
727
+ t: 'paragraph';
728
+ v: GigaParagraph;
729
+ } | {
730
+ t: 'heading';
731
+ v: GigaHeading;
732
+ } | {
733
+ t: 'list';
734
+ v: GigaList;
735
+ } | {
736
+ t: 'table';
737
+ v: GigaTable;
738
+ } | {
739
+ t: 'image';
740
+ v: GigaImageRef;
741
+ } | {
742
+ t: 'shape';
743
+ v: GigaShape;
744
+ } | {
745
+ t: 'textbox';
746
+ v: GigaTextBox;
747
+ } | {
748
+ t: 'sheet';
749
+ v: GigaSheetBlock;
750
+ } | {
751
+ t: 'slide';
752
+ v: GigaSlideBlock;
753
+ };
754
+ /** Block rotation (tagged; mirror of `model::geom::Rotation`). */
755
+ type GigaRotation = {
756
+ t: 'd0';
757
+ } | {
758
+ t: 'd90';
759
+ } | {
760
+ t: 'd180';
761
+ } | {
762
+ t: 'd270';
763
+ } | {
764
+ t: 'deg';
765
+ v: number;
766
+ };
507
767
  /** A block: a stable id, an optional placement frame + rotation, and its kind. */
508
768
  interface GigaBlock {
509
769
  id: number;
510
- frame: {
511
- x: number;
512
- y: number;
513
- w: number;
514
- h: number;
515
- } | null;
516
- rotation: {
517
- t: 'd0' | 'd90' | 'd180' | 'd270' | 'deg';
518
- v?: number;
519
- };
770
+ frame: GigaRect | null;
771
+ rotation: GigaRotation;
520
772
  kind: GigaBlockKind;
521
773
  }
522
774
  /** A page: a list of blocks; `absolute` flags slide/form (positioned) layout. */
@@ -526,20 +778,30 @@ interface GigaPage {
526
778
  }
527
779
  /** A section: one page geometry, optional running header/footer, and its pages. */
528
780
  interface GigaSection {
529
- geometry: {
530
- width: number;
531
- height: number;
532
- [k: string]: unknown;
533
- };
781
+ geometry: GigaPageGeometry;
534
782
  header: GigaBlock[] | null;
535
783
  footer: GigaBlock[] | null;
536
784
  pages: GigaPage[];
537
785
  }
786
+ /**
787
+ * A document outline (bookmark) entry — a label, a zero-based destination page,
788
+ * and nested children (mirror of `model::OutlineNode`). Populated by
789
+ * {@link GigaPdf.officeToModel}/reconstruction from the source's own bookmarks
790
+ * (PDF `/Outlines`) or, lacking those, from detected headings.
791
+ */
792
+ interface GigaOutlineNode {
793
+ /** The bookmark label. */
794
+ title: string;
795
+ /** Zero-based destination page in the document's flattened page sequence. */
796
+ page: number;
797
+ /** Nested sub-bookmarks. */
798
+ children: GigaOutlineNode[];
799
+ }
538
800
  /**
539
801
  * The unified editable document model — the format-neutral tree every format
540
802
  * lowers into and is reconstructed from. `v` is the envelope version. Leaves
541
- * beyond what a host typically edits (`styles`, `outline`, `resources`) are
542
- * carried opaquely so a round-trip preserves them.
803
+ * beyond what a host typically edits (`styles`, `resources`) are carried
804
+ * opaquely so a round-trip preserves them.
543
805
  */
544
806
  interface GigaDocument {
545
807
  v: number;
@@ -552,7 +814,8 @@ interface GigaDocument {
552
814
  };
553
815
  styles: unknown;
554
816
  sections: GigaSection[];
555
- outline: unknown[];
817
+ /** Bookmark / chapter hierarchy (empty when the source has none). */
818
+ outline: GigaOutlineNode[];
556
819
  resources: unknown;
557
820
  }
558
821
  /**
@@ -1485,4 +1748,4 @@ declare class GigaPdfDoc {
1485
1748
  }): boolean;
1486
1749
  }
1487
1750
 
1488
- export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type DocumentLanguage, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaInline, type GigaPage, GigaPdfDoc, GigaPdfEngine, type GigaSection, type GigaStylePatch, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type LayerInfo, type LinkInfo, type ModelOp, type NamedDest, type OutlineEntry, type PageInfo, type PageMargins, type PathSegment, type RadioOption, type SearchHit, type SignP12Options, type TextElementInfo, type TextLine, type TextRunInfo, type VectorPathInfo, type XlsxSheet };
1751
+ export { type AnnotationInfo, type Attachment, type Box, type DecodedImage, type DocumentLanguage, type Element, type EmbeddedFont, type FieldInfo, type FieldKind, type FieldStyle, type FontInfo, type GigaBlock, type GigaBlockAddr, type GigaBlockKind, type GigaBorderStyle, type GigaCellValue, type GigaCharStyle, type GigaDocument, type GigaGeneric, type GigaHeading, type GigaImageRef, type GigaInline, type GigaInlineRun, type GigaLinkTarget, type GigaList, type GigaListItem, type GigaListMarker, type GigaMergeRange, type GigaOutlineNode, type GigaPage, type GigaPageGeometry, type GigaParagraph, type GigaParagraphStyle, type GigaPathSeg, GigaPdfDoc, GigaPdfEngine, type GigaPlaceholder, type GigaPlaceholderRole, type GigaRect, type GigaRotation, type GigaSection, type GigaShape, type GigaSheet, type GigaSheetBlock, type GigaSheetCell, type GigaSheetRow, type GigaSlide, type GigaSlideBlock, type GigaStylePatch, type GigaTable, type GigaTableCell, type GigaTableRow, type GigaTextBox, type HeaderFooterAlign, type HeaderFooterSpec, type HtmlFont, type HtmlFontRequest, type HtmlMargins, type HtmlRenderOptions, type HtmlResource, type HtmlResourceNeed, type ImageElementInfo, type LayerInfo, type LinkInfo, type ModelOp, type NamedDest, type OutlineEntry, type PageInfo, type PageMargins, type PathSegment, type RadioOption, type SearchHit, type SignP12Options, type TextElementInfo, type TextLine, type TextRunInfo, type VectorPathInfo, type XlsxSheet };