@json-to-office/jto-ops 6.0.0 → 6.8.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
@@ -1,5 +1,5 @@
1
1
  import { FontRuntimeOpts, ServicesConfig, GenerationWarning, RendererStatus, PptxBatchRasterizer, PptxRasterizer, JsonBlockDefinition, BlockSlot, ResolvedFont } from '@json-to-office/shared';
2
- import { QualityProfile, QualityPolicy, PreparedDocument, QualityAnalysis, QualityRulePack, QualityDiagnostic, QualityAnalyzeOptions } from '@json-to-office/quality';
2
+ import { QualityProfile, QualityPolicy, PreparedDocument, QualityAnalysis, QualityRulePack, QualityDiagnostic, QualityAnalyzeOptions, QualityFact } from '@json-to-office/quality';
3
3
 
4
4
  type FormatName = 'docx' | 'pptx';
5
5
  interface GeneratorOptions {
@@ -469,7 +469,7 @@ declare function extractPdfFonts(pdfPath: string, options?: {
469
469
  * pass over it, memoised per fact, so eight rules cost one search.
470
470
  */
471
471
 
472
- type RenderedRuleId = 'rendered/clip' | 'rendered/spill' | 'rendered/overlap' | 'rendered/text-missing' | 'rendered/font-substituted' | 'rendered/empty-page' | 'rendered/heading-stranded' | 'rendered/paragraph-split' | 'rendered/page-underfilled';
472
+ type RenderedRuleId = 'rendered/clip' | 'rendered/spill' | 'rendered/overlap' | 'rendered/text-missing' | 'rendered/font-substituted' | 'rendered/empty-page' | 'rendered/heading-stranded' | 'rendered/paragraph-split' | 'rendered/table-split' | 'rendered/page-underfilled';
473
473
  declare const RENDERED_QUALITY_RULES: QualityRulePack;
474
474
 
475
475
  /**
@@ -499,6 +499,9 @@ declare const RENDERED_QUALITY_RULES: QualityRulePack;
499
499
  * every occurrence. `assignInventory` resolves them by reading order: the
500
500
  * inventory is walked in document order and the stream is in page order, so
501
501
  * the next unclaimed occurrence at or after the previous claim is the one.
502
+ * Where the format knows more before rendering — a slide is its own page,
503
+ * and its text boxes sit where the deck put them — the entry says so, and
504
+ * only an occurrence on that page, preferably inside that box, is its own.
502
505
  */
503
506
 
504
507
  /** Fold rendered and authored text into one comparable form. */
@@ -522,6 +525,8 @@ interface OccurrencePart {
522
525
  interface TextOccurrence {
523
526
  /** Offset into the document stream, for ordering. */
524
527
  at: number;
528
+ /** Offset just past the match: `[at, end)` is the range a claim holds. */
529
+ end: number;
525
530
  /** First and last page the match touches; equal unless it breaks across. */
526
531
  pageIndex: number;
527
532
  endPageIndex: number;
@@ -541,8 +546,15 @@ interface TextOccurrence {
541
546
  * fragment of their row) and the rows stay a line apart. A block reads
542
547
  * column by column, so a cell's lines come out together; a row of one
543
548
  * fragment outside any block — prose — reads as it lies.
549
+ *
550
+ * Rotated text — a chart's value-axis title — has no rows or columns to
551
+ * take part in. It reads as one run in the order poppler gave it, after the
552
+ * page's upright text: inside that text it could fall between two lines of
553
+ * a paragraph and cut it in two, and a slide's takeaway set beside a chart
554
+ * then reads as clipped, or as never rendered at all. Across a document the
555
+ * stream sets it after every page (`indexDocument`).
544
556
  */
545
- declare function readingOrder(words: readonly PdfTextWord[]): number[];
557
+ declare function readingOrder(words: readonly PdfTextWord[], lines?: readonly PdfTextLine[]): number[];
546
558
  /** What an inventory entry needs to be matched: its text, in reading order. */
547
559
  interface InventoryEntry {
548
560
  path: string;
@@ -555,6 +567,26 @@ interface InventoryEntry {
555
567
  * `missing`, when there is not.
556
568
  */
557
569
  optional?: boolean;
570
+ /**
571
+ * The 0-based page the text is drawn on, when the format knows it before
572
+ * rendering: a slide is its own page. Only an occurrence starting there
573
+ * is the entry's — "13 pts" on slide 2 is not "+1.3 pts" on slide 8,
574
+ * however alike the two fold.
575
+ */
576
+ page?: number;
577
+ /**
578
+ * Where on that page the text was laid out, in PDF points: a slide text
579
+ * box. Of the entry's occurrences, one inside this region is its own. A
580
+ * section tracker that repeats the first word of the title under it is
581
+ * two occurrences of one word, and reading order cannot say which box
582
+ * painted which; the boxes can.
583
+ */
584
+ region?: {
585
+ xMin: number;
586
+ yMin: number;
587
+ xMax: number;
588
+ yMax: number;
589
+ };
558
590
  }
559
591
  type MappingStatus = 'mapped' | 'ambiguous' | 'missing' | 'skipped';
560
592
  interface InventoryMatch<T extends InventoryEntry = InventoryEntry> {
@@ -588,6 +620,13 @@ interface InventoryAssignment<T extends InventoryEntry> {
588
620
  * finds the second "Total". An entry with no occurrence is `missing` —
589
621
  * fully clipped, or never set — unless it is optional, and one whose every
590
622
  * occurrence was already claimed is `ambiguous`.
623
+ *
624
+ * A claim holds the whole range it matched, not just where it starts: a
625
+ * rendered word belongs to one authored string, so "Revenue" inside a title
626
+ * another entry already owns is not free for a tracker that says "Revenue".
627
+ * An entry that names its page looks only there, and one that names its
628
+ * region takes the occurrence lying most inside it before reading order is
629
+ * consulted at all.
591
630
  */
592
631
  declare function assignInventory<T extends InventoryEntry>(pages: readonly PdfTextPage[], inventory: readonly T[]): InventoryAssignment<T>;
593
632
 
@@ -690,6 +729,30 @@ declare const VISIBLE_SPILL_PT = 2;
690
729
  */
691
730
  declare function analyzeRenderedDocument(input: RenderedAnalysisInput, options?: QualityAnalyzeOptions): RenderedAnalysis;
692
731
 
732
+ /**
733
+ * The authored side of the rendered pass (#344): the text inventory and the
734
+ * requested font families, read off a prepared document's quality facts.
735
+ *
736
+ * `jto_preview` and the ground-truth harness both hand the pass this, so the
737
+ * mapping a measurement scores is the mapping the tool ships. Every pointer
738
+ * in it has already been through the block source maps, and lands on a slot
739
+ * the author can patch.
740
+ */
741
+
742
+ /** The text inventory a format's facts expose, as the analysis reads it. */
743
+ declare function renderedInventoryFromFacts(format: FormatName, facts: readonly QualityFact[]): RenderedTextEntry[];
744
+ /**
745
+ * Families the pass should find in the PDF: every family the document's
746
+ * text uses (a `font-family` fact, with its pointer) plus every family the
747
+ * render resolved from a declared source. A theme family nothing on the page
748
+ * uses — the default mono face in a report without code — is never embedded
749
+ * and must not read as substituted.
750
+ */
751
+ declare function requestedFontsFromFacts(format: FormatName, facts: readonly QualityFact[], resolvedFonts: readonly {
752
+ family: string;
753
+ declared: boolean;
754
+ }[]): RequestedFont[];
755
+
693
756
  /**
694
757
  * The block boundary matrix (#343, report portion): every JSON block
695
758
  * definition a playground template embeds, invoked at the edges of its own
@@ -1003,4 +1066,4 @@ declare function emitDiagnostic(text: string, tone?: DiagnosticTone): void;
1003
1066
  */
1004
1067
  declare const stderrDiagnosticSink: DiagnosticSink;
1005
1068
 
1006
- export { type BlockMatrixCase, type BlockMatrixDefinition, type BlockMatrixOptions, type CaseConditions, type DiagnosticSink, type DiagnosticTone, DocxFormatAdapter, type ExtractPdfPageInkOptions, FALLBACK_FONTS, type FontStageHandle, type FontStageOptions, type FontStager, FontconfigStager, type FormatAdapter, type FormatName, type GeneratorOptions, type GeneratorResult, INK_DPI, INK_THRESHOLD, type InventoryEntry, type InventoryMatch, MATRIX_IMAGE, MacOSCoreTextStager, type MappingStatus, type MatrixCanvas, type MatrixEdge, type MatrixFont, NoopFontStager, type PdfFontInfo, type PdfPageInk, type PdfTextLine, type PdfTextPage, type PdfTextWord, type Pgm, PptxFormatAdapter, RENDERED_QUALITY_RULES, type RasterizerCacheStats, type RenderedAnalysis, type RenderedAnalysisInput, type RenderedAnalysisSummary, type RenderedMapping, type RenderedRuleId, type RenderedTextEntry, type RequestedFont, type TextOccurrence, VISIBLE_SPILL_PT, WindowsFontStager, analyzeRenderedDocument, assignInventory, authoredTextForMatch, blockCaseDocument, boundaryInvocation, boundarySlotValue, clearRasterizerCache, createAdapter, createLibreOfficePptxBatchRasterizer, createLibreOfficePptxRasterizer, emitDiagnostic, enumerateBlockDefinitions, extractPdfFonts, extractPdfPageInk, extractPdfTextGeometry, familyRendered, generateBlockMatrix, getFontStager, getRasterizerCacheStats, inkedRows, normalizeForMatch, overBudgetInvocation, pageInkFromPgm, parsePdfFonts, parsePdfTextBbox, parsePgm, pdffontsAvailable, pdftotextAvailable, readingOrder, reportCaseDocument, runWithDiagnosticSink, stderrDiagnosticSink, widestNumber };
1069
+ export { type BlockMatrixCase, type BlockMatrixDefinition, type BlockMatrixOptions, type CaseConditions, type DiagnosticSink, type DiagnosticTone, DocxFormatAdapter, type ExtractPdfPageInkOptions, FALLBACK_FONTS, type FontStageHandle, type FontStageOptions, type FontStager, FontconfigStager, type FormatAdapter, type FormatName, type GeneratorOptions, type GeneratorResult, INK_DPI, INK_THRESHOLD, type InventoryEntry, type InventoryMatch, MATRIX_IMAGE, MacOSCoreTextStager, type MappingStatus, type MatrixCanvas, type MatrixEdge, type MatrixFont, NoopFontStager, type PdfFontInfo, type PdfPageInk, type PdfTextLine, type PdfTextPage, type PdfTextWord, type Pgm, PptxFormatAdapter, RENDERED_QUALITY_RULES, type RasterizerCacheStats, type RenderedAnalysis, type RenderedAnalysisInput, type RenderedAnalysisSummary, type RenderedMapping, type RenderedRuleId, type RenderedTextEntry, type RequestedFont, type TextOccurrence, VISIBLE_SPILL_PT, WindowsFontStager, analyzeRenderedDocument, assignInventory, authoredTextForMatch, blockCaseDocument, boundaryInvocation, boundarySlotValue, clearRasterizerCache, createAdapter, createLibreOfficePptxBatchRasterizer, createLibreOfficePptxRasterizer, emitDiagnostic, enumerateBlockDefinitions, extractPdfFonts, extractPdfPageInk, extractPdfTextGeometry, familyRendered, generateBlockMatrix, getFontStager, getRasterizerCacheStats, inkedRows, normalizeForMatch, overBudgetInvocation, pageInkFromPgm, parsePdfFonts, parsePdfTextBbox, parsePgm, pdffontsAvailable, pdftotextAvailable, readingOrder, renderedInventoryFromFacts, reportCaseDocument, requestedFontsFromFacts, runWithDiagnosticSink, stderrDiagnosticSink, widestNumber };