@json-to-office/jto-ops 1.4.0 → 1.11.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 +82 -1
- package/dist/index.js +391 -60
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FontRuntimeOpts, GenerationWarning, RendererStatus, PptxBatchRasterizer, PptxRasterizer, ResolvedFont } from '@json-to-office/shared';
|
|
2
|
+
import { QualityProfile, QualityPolicy, PreparedDocument, QualityAnalysis } from '@json-to-office/quality';
|
|
2
3
|
|
|
3
4
|
type FormatName = 'docx' | 'pptx';
|
|
4
5
|
interface GeneratorOptions {
|
|
@@ -26,6 +27,14 @@ interface GeneratorOptions {
|
|
|
26
27
|
* Undefined means the format's default (`docxjs` / `pptxgenjs`).
|
|
27
28
|
*/
|
|
28
29
|
renderer?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Rasterize a PNG fallback for each inline SVG. Defaults to true.
|
|
32
|
+
*
|
|
33
|
+
* DOCX only — pptx embeds SVG without a raster twin. Only readers older than
|
|
34
|
+
* Word 2016 draw it, and producing it dominates the render of a document
|
|
35
|
+
* whose artwork is many small SVGs.
|
|
36
|
+
*/
|
|
37
|
+
svgRasterFallback?: boolean;
|
|
29
38
|
/**
|
|
30
39
|
* Optional sink for structured generation warnings (FONT_UNRESOLVED and
|
|
31
40
|
* friends). Mirrors core-docx's `JsonGenerationOptions.warnings`, and is the
|
|
@@ -37,6 +46,13 @@ interface GeneratorOptions {
|
|
|
37
46
|
* `GeneratorResult` — allocate one array per logical request.
|
|
38
47
|
*/
|
|
39
48
|
warnings?: GenerationWarning[];
|
|
49
|
+
/** Design profile and invocation-specific enforcement. */
|
|
50
|
+
quality?: {
|
|
51
|
+
profile?: QualityProfile;
|
|
52
|
+
policy?: QualityPolicy;
|
|
53
|
+
};
|
|
54
|
+
/** Opaque canonical prologue output shared by analysis and rendering. */
|
|
55
|
+
prepared?: PreparedDocument;
|
|
40
56
|
}
|
|
41
57
|
interface GeneratorResult {
|
|
42
58
|
generateBuffer: (document: any) => Promise<Buffer>;
|
|
@@ -67,8 +83,14 @@ interface FormatAdapter {
|
|
|
67
83
|
valid: boolean;
|
|
68
84
|
errors?: any[];
|
|
69
85
|
};
|
|
86
|
+
/** Analyze format-specific design quality with profiles, policy, and gate. */
|
|
87
|
+
analyzeQuality?(doc: unknown, options?: GeneratorOptions): Promise<QualityAnalysis>;
|
|
88
|
+
/** Prepare effective values and provenance once for official pipelines. */
|
|
89
|
+
prepareDocument?(doc: unknown, options?: GeneratorOptions): Promise<PreparedDocument>;
|
|
70
90
|
generateSchema(options?: any): any;
|
|
71
91
|
getBuiltinThemes(): Record<string, any>;
|
|
92
|
+
/** Full values for ESM hosts; falls back to `getBuiltinThemes` for plugins. */
|
|
93
|
+
getBuiltinThemeValues?(): Promise<Record<string, any>>;
|
|
72
94
|
resolveTheme(options: GeneratorOptions): Promise<any>;
|
|
73
95
|
loadCustomThemes(options: GeneratorOptions): Promise<Record<string, any> | undefined>;
|
|
74
96
|
/**
|
|
@@ -107,8 +129,13 @@ declare class DocxFormatAdapter implements FormatAdapter {
|
|
|
107
129
|
valid: boolean;
|
|
108
130
|
errors?: any[];
|
|
109
131
|
};
|
|
132
|
+
analyzeQuality(doc: unknown, options?: GeneratorOptions): Promise<QualityAnalysis>;
|
|
133
|
+
prepareDocument(doc: unknown, options?: GeneratorOptions): Promise<PreparedDocument>;
|
|
134
|
+
/** Prepare into a caller-owned sink; `prepareDocument` owns the reporting. */
|
|
135
|
+
private prepareModel;
|
|
110
136
|
generateSchema(_options?: any): any;
|
|
111
137
|
getBuiltinThemes(): Record<string, any>;
|
|
138
|
+
getBuiltinThemeValues(): Promise<Record<string, any>>;
|
|
112
139
|
resolveTheme(options: GeneratorOptions): Promise<any>;
|
|
113
140
|
/**
|
|
114
141
|
* Resolve `theme`/`themePath` once for a whole run: `themePath` is read a
|
|
@@ -134,8 +161,13 @@ declare class PptxFormatAdapter implements FormatAdapter {
|
|
|
134
161
|
valid: boolean;
|
|
135
162
|
errors?: any[];
|
|
136
163
|
};
|
|
164
|
+
analyzeQuality(doc: unknown, options?: GeneratorOptions): Promise<QualityAnalysis>;
|
|
165
|
+
prepareDocument(doc: unknown, options?: GeneratorOptions): Promise<PreparedDocument>;
|
|
166
|
+
/** Prepare into a caller-owned sink; `prepareDocument` owns the reporting. */
|
|
167
|
+
private prepareModel;
|
|
137
168
|
generateSchema(_options?: any): any;
|
|
138
169
|
getBuiltinThemes(): Record<string, any>;
|
|
170
|
+
getBuiltinThemeValues(): Promise<Record<string, any>>;
|
|
139
171
|
resolveTheme(options: GeneratorOptions): Promise<any>;
|
|
140
172
|
/**
|
|
141
173
|
* Resolve `theme`/`themePath` once for a whole run: `themePath` is read a
|
|
@@ -230,6 +262,55 @@ declare function createLibreOfficePptxBatchRasterizer(options?: {
|
|
|
230
262
|
cacheDir?: string | null;
|
|
231
263
|
}): PptxBatchRasterizer;
|
|
232
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Text geometry from a rendered PDF — the ground truth the quality
|
|
267
|
+
* estimators are guessing at (#216 follow-up).
|
|
268
|
+
*
|
|
269
|
+
* The pptx preview pipeline already produces a PDF (soffice → pdftoppm) and
|
|
270
|
+
* uses it purely as a bitmap source. That PDF records the exact position of
|
|
271
|
+
* every glyph as laid out by LibreOffice — the same engine the quality rules
|
|
272
|
+
* try to predict. `pdftotext -bbox` (poppler, already a rasterizer
|
|
273
|
+
* dependency alongside pdftoppm) dumps per-word bounding boxes; this module
|
|
274
|
+
* parses them into slide-space points so callers can compare a rule's
|
|
275
|
+
* estimate against what the renderer actually did.
|
|
276
|
+
*
|
|
277
|
+
* Coordinates: PDF points (1/72 in), origin at the page's top-left corner,
|
|
278
|
+
* y increasing downward — the same frame as authored inches × 72. A PDF page
|
|
279
|
+
* rendered from a slide has the slide's dimensions, so word boxes compare
|
|
280
|
+
* directly against authored shape geometry with no transform.
|
|
281
|
+
*
|
|
282
|
+
* Consumers: the quality ground-truth harness (estimator calibration) today;
|
|
283
|
+
* a `rendered`-certainty analysis pass tomorrow.
|
|
284
|
+
*/
|
|
285
|
+
/** One word as laid out on the page, in PDF points, top-left origin. */
|
|
286
|
+
interface PdfTextWord {
|
|
287
|
+
text: string;
|
|
288
|
+
xMin: number;
|
|
289
|
+
yMin: number;
|
|
290
|
+
xMax: number;
|
|
291
|
+
yMax: number;
|
|
292
|
+
}
|
|
293
|
+
/** One PDF page: its size in points plus every word poppler segmented. */
|
|
294
|
+
interface PdfTextPage {
|
|
295
|
+
widthPt: number;
|
|
296
|
+
heightPt: number;
|
|
297
|
+
words: PdfTextWord[];
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Parse `pdftotext -bbox` output (XHTML with `<page>`/`<word>` elements).
|
|
301
|
+
* Pure — feed it a captured document for tests, or the runner's stdout.
|
|
302
|
+
*/
|
|
303
|
+
declare function parsePdfTextBbox(bboxXml: string): PdfTextPage[];
|
|
304
|
+
/** True when a `pdftotext` binary is reachable — lets harnesses skip early. */
|
|
305
|
+
declare function pdftotextAvailable(): Promise<boolean>;
|
|
306
|
+
/**
|
|
307
|
+
* Extract per-word text geometry from a PDF on disk. One pdftotext spawn,
|
|
308
|
+
* output streamed through stdout — nothing else touches the filesystem.
|
|
309
|
+
*/
|
|
310
|
+
declare function extractPdfTextGeometry(pdfPath: string, options?: {
|
|
311
|
+
timeoutMs?: number;
|
|
312
|
+
}): Promise<PdfTextPage[]>;
|
|
313
|
+
|
|
233
314
|
/**
|
|
234
315
|
* Make resolved fonts visible to the LibreOffice child process for the
|
|
235
316
|
* duration of one PDF conversion, then clean up.
|
|
@@ -421,4 +502,4 @@ declare function emitDiagnostic(text: string, tone?: DiagnosticTone): void;
|
|
|
421
502
|
*/
|
|
422
503
|
declare const stderrDiagnosticSink: DiagnosticSink;
|
|
423
504
|
|
|
424
|
-
export { type DiagnosticSink, type DiagnosticTone, DocxFormatAdapter, type FontStageHandle, type FontStageOptions, type FontStager, FontconfigStager, type FormatAdapter, type FormatName, type GeneratorOptions, type GeneratorResult, MacOSCoreTextStager, NoopFontStager, PptxFormatAdapter, type RasterizerCacheStats, WindowsFontStager, clearRasterizerCache, createAdapter, createLibreOfficePptxBatchRasterizer, createLibreOfficePptxRasterizer, emitDiagnostic, getFontStager, getRasterizerCacheStats, runWithDiagnosticSink, stderrDiagnosticSink };
|
|
505
|
+
export { type DiagnosticSink, type DiagnosticTone, DocxFormatAdapter, type FontStageHandle, type FontStageOptions, type FontStager, FontconfigStager, type FormatAdapter, type FormatName, type GeneratorOptions, type GeneratorResult, MacOSCoreTextStager, NoopFontStager, type PdfTextPage, type PdfTextWord, PptxFormatAdapter, type RasterizerCacheStats, WindowsFontStager, clearRasterizerCache, createAdapter, createLibreOfficePptxBatchRasterizer, createLibreOfficePptxRasterizer, emitDiagnostic, extractPdfTextGeometry, getFontStager, getRasterizerCacheStats, parsePdfTextBbox, pdftotextAvailable, runWithDiagnosticSink, stderrDiagnosticSink };
|