@json-to-office/jto-ops 6.8.0 → 7.0.1

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
@@ -59,6 +59,12 @@ interface GeneratorOptions {
59
59
  };
60
60
  /** Opaque canonical prologue output shared by analysis and rendering. */
61
61
  prepared?: PreparedDocument;
62
+ /**
63
+ * Registered code components. Quality preparation expands them the way
64
+ * generation does, so `analyzeQuality` and `prepareDocument` judge what a
65
+ * plugin emits and report it at the invocation the author wrote (#453).
66
+ */
67
+ plugins?: readonly any[];
62
68
  }
63
69
  interface GeneratorResult {
64
70
  generateBuffer: (document: any) => Promise<Buffer>;
@@ -753,6 +759,120 @@ declare function requestedFontsFromFacts(format: FormatName, facts: readonly Qua
753
759
  declared: boolean;
754
760
  }[]): RequestedFont[];
755
761
 
762
+ /**
763
+ * The matrix inventory (#343): every JSON block definition the playground
764
+ * templates embed, found by the same extraction MCP discovery publishes as
765
+ * `jto://blocks`, and for each one the conditions it is supported on — theme,
766
+ * canvas, font, slot edge — with a stated reason for every condition it is
767
+ * not. Nothing is omitted silently: a condition a definition does not get is
768
+ * an exclusion with a reason, and a template with no definitions is listed
769
+ * with none.
770
+ *
771
+ * Applicability is decided from the template, never from a list of blocks:
772
+ *
773
+ * - A template on a bundled theme is authored against theme roles and
774
+ * tokens, so its definitions are supported on every bundled theme of the
775
+ * format, in the design faces and in the fallback faces. A report's are
776
+ * supported on every page size its themes scale for; a deck's on the slide
777
+ * shape the template is drawn on, because that is where its slot budgets
778
+ * are measured — another shape lays out, but holds fewer words.
779
+ * - A template carrying its own theme object is authored against that
780
+ * object: absolute geometry fitted to its own faces and its own canvas. Its
781
+ * definitions are supported there only; a bundled theme, another canvas or
782
+ * a wider fallback face would be a different design, not a boundary.
783
+ * - A definition with no slots has one document, so `min` is `max`.
784
+ *
785
+ * The profile a template's definitions are judged under is the one the
786
+ * blueprint drawing on that template names; a template no blueprint uses is
787
+ * judged under the format's default. The module is pure: themes, blueprints
788
+ * and profiles are handed in, so a new theme or template gains its cases
789
+ * without an edit here.
790
+ */
791
+
792
+ type MatrixFormat = 'docx' | 'pptx';
793
+ interface MatrixTemplateSource {
794
+ /** File name, as the gallery and `jto://blocks` name it. */
795
+ name: string;
796
+ document: unknown;
797
+ }
798
+ interface MatrixBlueprintSource {
799
+ id: string;
800
+ format: string;
801
+ profile: string;
802
+ /** The template whose definitions the blueprint invokes. */
803
+ definitions: string;
804
+ }
805
+ interface MatrixProfileSource {
806
+ id: string;
807
+ rules?: Readonly<Record<string, {
808
+ parameters?: Readonly<Record<string, unknown>>;
809
+ }>>;
810
+ }
811
+ interface MatrixInventoryOptions {
812
+ /** The bundled theme names of each format. */
813
+ themes: Readonly<Record<MatrixFormat, readonly string[]>>;
814
+ blueprints?: readonly MatrixBlueprintSource[];
815
+ /** Shipped profiles by id, to read the roles a profile requires present. */
816
+ profiles?: Readonly<Record<string, MatrixProfileSource>>;
817
+ }
818
+ interface MatrixExclusion {
819
+ /** `theme minimal`, `canvas standard43`, `font fallback`, `edge min`. */
820
+ condition: string;
821
+ reason: string;
822
+ }
823
+ interface MatrixConditions {
824
+ themes: string[];
825
+ canvases: MatrixCanvas[];
826
+ fonts: MatrixFont[];
827
+ edges: MatrixEdge[];
828
+ }
829
+ interface MatrixInventoryTemplate {
830
+ template: string;
831
+ format: MatrixFormat;
832
+ /** The bundled theme the template names, or `inline` for a theme object. */
833
+ theme: string;
834
+ /** The blueprint profile its definitions are judged under, when one uses it. */
835
+ profile?: string;
836
+ /** Slot roles that profile requires present, so `min` keeps them. */
837
+ requiredRoles: string[];
838
+ /** Every definition the template embeds, in authored order. */
839
+ definitions: string[];
840
+ /** The conditions a whole-template case is supported on. */
841
+ conditions: MatrixConditions;
842
+ exclusions: MatrixExclusion[];
843
+ }
844
+ interface MatrixInventoryEntry extends MatrixConditions {
845
+ /** `<template>#<definition pointer>`. */
846
+ id: string;
847
+ template: string;
848
+ format: MatrixFormat;
849
+ name: string;
850
+ definitionPointer: string;
851
+ /** Definitions this one invokes, dependencies first. */
852
+ dependencies: string[];
853
+ profile?: string;
854
+ requiredRoles: string[];
855
+ exclusions: MatrixExclusion[];
856
+ }
857
+ interface MatrixInventory {
858
+ templates: MatrixInventoryTemplate[];
859
+ entries: MatrixInventoryEntry[];
860
+ }
861
+ /** Every condition of a format, whether or not a definition gets it. */
862
+ declare function matrixUniverse(format: MatrixFormat, themes: readonly string[]): MatrixConditions;
863
+ declare function templateFormat(name: string, document: unknown): MatrixFormat | undefined;
864
+ /** The inventory over every template handed in, in the order given. */
865
+ declare function buildMatrixInventory(templates: readonly MatrixTemplateSource[], options: MatrixInventoryOptions): MatrixInventory;
866
+ /**
867
+ * Conditions of the universe an entry neither gets nor excludes, and
868
+ * conditions it both gets and excludes. Empty for a complete inventory.
869
+ */
870
+ declare function inventoryGaps(entry: MatrixConditions & {
871
+ exclusions: readonly MatrixExclusion[];
872
+ }, universe: MatrixConditions): string[];
873
+ /** One line per template and entry, for a suite's log. */
874
+ declare function describeInventory(inventory: MatrixInventory): string;
875
+
756
876
  /**
757
877
  * The block boundary matrix (#343, report portion): every JSON block
758
878
  * definition a playground template embeds, invoked at the edges of its own
@@ -778,9 +898,11 @@ declare function requestedFontsFromFacts(format: FormatName, facts: readonly Qua
778
898
  type Rec = Record<string, unknown>;
779
899
  type MatrixEdge = 'min' | 'max';
780
900
  type MatrixFont = 'design' | 'fallback';
781
- type MatrixCanvas = 'A4' | 'LETTER';
901
+ /** Page sizes for reports; the two slide shapes theme scales key for decks. */
902
+ type MatrixCanvas = 'A4' | 'LETTER' | 'wide169' | 'standard43';
782
903
  interface BlockMatrixDefinition {
783
904
  name: string;
905
+ format: MatrixFormat;
784
906
  /** The template the definition is embedded in, as the catalog names it. */
785
907
  template: string;
786
908
  /** Where inside that template: `/props/blocks/<name>`. */
@@ -819,6 +941,26 @@ interface CaseConditions {
819
941
  canvas?: MatrixCanvas;
820
942
  requiredRoles?: readonly string[];
821
943
  }
944
+ /**
945
+ * The same faces for a deck. PPTX themes take family names and a deck has
946
+ * no theme overrides, so the fallback case carries an inline copy of the
947
+ * bundled theme with these two roles replaced.
948
+ */
949
+ declare const PPTX_FALLBACK_FONTS: {
950
+ readonly heading: "DejaVu Sans";
951
+ readonly body: "DejaVu Sans";
952
+ };
953
+ /** 16:9 and 4:3 at the sizes the house deck and PowerPoint use. */
954
+ declare const PPTX_CANVAS_SIZE: {
955
+ readonly wide169: {
956
+ readonly slideWidth: 13.333;
957
+ readonly slideHeight: 7.5;
958
+ };
959
+ readonly standard43: {
960
+ readonly slideWidth: 10;
961
+ readonly slideHeight: 7.5;
962
+ };
963
+ };
822
964
  /**
823
965
  * The face every LibreOffice ships with, bundled inside the application on
824
966
  * each platform: what a design font degrades to when the host lacks it, and
@@ -836,14 +978,14 @@ declare const FALLBACK_FONTS: {
836
978
  };
837
979
  };
838
980
  /** A 4x2 PNG: an image with an aspect ratio, and no bytes outside the process. */
839
- declare const MATRIX_IMAGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAABytg0kAAAAFElEQVR42mNk+M9QzwAFjDAGACPuA/8fMSCgAAAAAElFTkSuQmCC";
981
+ declare const MATRIX_IMAGE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAAEklEQVR42mOIrt34HxkzoAsAAE/xFEFoJgXRAAAAAElFTkSuQmCC";
840
982
  /**
841
983
  * The widest number of a given length: a true minus, thousands separators
842
984
  * and one decimal, every glyph at tabular width. `−1,234,567.0` for 12.
843
985
  */
844
986
  declare function widestNumber(length: number, seed?: number): string;
845
987
  /** A slot's value at an edge; `undefined` means "leave it out". */
846
- declare function boundarySlotValue(slot: BlockSlot, name: string, edge: MatrixEdge, seed?: number): unknown;
988
+ declare function boundarySlotValue(slot: BlockSlot, name: string, edge: MatrixEdge, seed?: number, format?: MatrixFormat): unknown;
847
989
  /**
848
990
  * One invocation of a definition with every slot at the edge: optional slots
849
991
  * left out at `min` (so defaults are what renders), every slot at `max`.
@@ -851,18 +993,23 @@ declare function boundarySlotValue(slot: BlockSlot, name: string, edge: MatrixEd
851
993
  * is never optional to that profile, so `requiredRoles` keeps it at `min`.
852
994
  * Columns whose cells must count the rows do; nothing else knows a block.
853
995
  */
854
- declare function boundaryInvocation(name: string, definition: JsonBlockDefinition, edge: MatrixEdge, seed?: number, requiredRoles?: readonly string[]): Rec;
996
+ declare function boundaryInvocation(name: string, definition: JsonBlockDefinition, edge: MatrixEdge, seed?: number, requiredRoles?: readonly string[], format?: MatrixFormat): Rec;
855
997
  /**
856
998
  * The same invocation one past the edge: the first budgeted string a word
857
999
  * over, or the first bounded array an item over. What a slot violation
858
1000
  * looks like, so a suite can prove it is reported at the authored pointer.
859
1001
  */
860
- declare function overBudgetInvocation(name: string, definition: JsonBlockDefinition, seed?: number): {
1002
+ declare function overBudgetInvocation(name: string, definition: JsonBlockDefinition, seed?: number, format?: MatrixFormat): {
861
1003
  invocation: Rec;
862
1004
  slot: string;
863
1005
  kind: 'words' | 'items';
864
1006
  } | undefined;
865
- /** Every definition a template embeds, with the template's own example of it. */
1007
+ /**
1008
+ * Every definition a template embeds, with the template's own example of it.
1009
+ * The definitions come from the extraction MCP discovery publishes, so the
1010
+ * matrix covers exactly what an agent can copy; a template whose definitions
1011
+ * do not validate is an error here, not a template with fewer blocks.
1012
+ */
866
1013
  declare function enumerateBlockDefinitions(template: unknown, templateName: string): BlockMatrixDefinition[];
867
1014
  /**
868
1015
  * A small report with one block at its edge: the chrome at the template's
@@ -874,6 +1021,49 @@ declare function blockCaseDocument(entries: readonly BlockMatrixDefinition[], na
874
1021
  declare function reportCaseDocument(template: unknown, edge: MatrixEdge, theme: string, { font, canvas, requiredRoles }?: CaseConditions): Rec;
875
1022
  /** Every case the options span, in a stable order. */
876
1023
  declare function generateBlockMatrix(template: unknown, templateName: string, options: BlockMatrixOptions): BlockMatrixCase[];
1024
+ interface DeckCaseConditions extends CaseConditions {
1025
+ /**
1026
+ * A bundled theme's object, for the fallback-font case: a deck has no
1027
+ * theme overrides, so the faces go into an inline copy of the theme.
1028
+ */
1029
+ themeObject?: (name: string) => Rec | undefined;
1030
+ }
1031
+ /**
1032
+ * A deck with one block at its edge: the template's cover at its nominal
1033
+ * values first, when the template has one and it is not the block under
1034
+ * test, so the slide under test is where footer rules start counting.
1035
+ */
1036
+ declare function deckBlockCaseDocument(template: unknown, entries: readonly BlockMatrixDefinition[], name: string, edge: MatrixEdge, theme: string, { font, canvas, requiredRoles, themeObject, }?: DeckCaseConditions): Rec;
1037
+ /** The whole deck with every invocation at the edge. */
1038
+ declare function deckReportCaseDocument(template: unknown, edge: MatrixEdge, theme: string, { font, canvas, requiredRoles, themeObject, }?: DeckCaseConditions): Rec;
1039
+ interface MatrixCase extends BlockMatrixCase {
1040
+ format: MatrixFormat;
1041
+ template: string;
1042
+ /** The profile the template's blueprint judges it under, when one does. */
1043
+ profile?: string;
1044
+ }
1045
+ /** Which of the inventory's supported conditions a run takes. */
1046
+ interface MatrixSelection {
1047
+ templates?: readonly string[];
1048
+ themes?: readonly string[];
1049
+ fonts?: readonly MatrixFont[];
1050
+ edges?: readonly MatrixEdge[];
1051
+ canvases?: readonly MatrixCanvas[];
1052
+ /** Whether the per-definition cases are generated. Default true. */
1053
+ blocks?: boolean;
1054
+ /** Whether the whole-template cases are generated. Default true. */
1055
+ report?: boolean;
1056
+ }
1057
+ /**
1058
+ * Every case the inventory supports under a selection, in a stable order:
1059
+ * template, theme, font, canvas, edge, then each definition before the
1060
+ * whole template. A template whose definitions all lack slots has no
1061
+ * whole-template case: at either edge it is the template itself, which is
1062
+ * gallery coverage.
1063
+ */
1064
+ declare function generateMatrixCases(inventory: MatrixInventory, templates: readonly MatrixTemplateSource[], selection?: MatrixSelection, { themeObject }?: {
1065
+ themeObject?: (name: string) => Rec | undefined;
1066
+ }): MatrixCase[];
877
1067
 
878
1068
  /**
879
1069
  * Make resolved fonts visible to the LibreOffice child process for the
@@ -1066,4 +1256,4 @@ declare function emitDiagnostic(text: string, tone?: DiagnosticTone): void;
1066
1256
  */
1067
1257
  declare const stderrDiagnosticSink: DiagnosticSink;
1068
1258
 
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 };
1259
+ export { type BlockMatrixCase, type BlockMatrixDefinition, type BlockMatrixOptions, type CaseConditions, type DeckCaseConditions, 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 MatrixBlueprintSource, type MatrixCanvas, type MatrixCase, type MatrixConditions, type MatrixEdge, type MatrixExclusion, type MatrixFont, type MatrixFormat, type MatrixInventory, type MatrixInventoryEntry, type MatrixInventoryOptions, type MatrixInventoryTemplate, type MatrixProfileSource, type MatrixSelection, type MatrixTemplateSource, NoopFontStager, PPTX_CANVAS_SIZE, PPTX_FALLBACK_FONTS, 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, buildMatrixInventory, clearRasterizerCache, createAdapter, createLibreOfficePptxBatchRasterizer, createLibreOfficePptxRasterizer, deckBlockCaseDocument, deckReportCaseDocument, describeInventory, emitDiagnostic, enumerateBlockDefinitions, extractPdfFonts, extractPdfPageInk, extractPdfTextGeometry, familyRendered, generateBlockMatrix, generateMatrixCases, getFontStager, getRasterizerCacheStats, inkedRows, inventoryGaps, matrixUniverse, normalizeForMatch, overBudgetInvocation, pageInkFromPgm, parsePdfFonts, parsePdfTextBbox, parsePgm, pdffontsAvailable, pdftotextAvailable, readingOrder, renderedInventoryFromFacts, reportCaseDocument, requestedFontsFromFacts, runWithDiagnosticSink, stderrDiagnosticSink, templateFormat, widestNumber };