@bendyline/squisq-formats 1.4.1 → 2.0.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/README.md +48 -2
- package/dist/{chunk-WWBIKRNP.js → chunk-2CSZJEAL.js} +13 -11
- package/dist/chunk-2CSZJEAL.js.map +1 -0
- package/dist/{chunk-RTS5XBZ7.js → chunk-2EFDWKC6.js} +262 -84
- package/dist/chunk-2EFDWKC6.js.map +1 -0
- package/dist/chunk-2PRVLAU3.js +740 -0
- package/dist/chunk-2PRVLAU3.js.map +1 -0
- package/dist/{chunk-SHLPSADL.js → chunk-4HJ6AK2Q.js} +54 -193
- package/dist/chunk-4HJ6AK2Q.js.map +1 -0
- package/dist/{chunk-5LSSWZPU.js → chunk-4VUWTSGM.js} +72 -25
- package/dist/chunk-4VUWTSGM.js.map +1 -0
- package/dist/{chunk-YESS7VY3.js → chunk-CVNVD7VH.js} +154 -39
- package/dist/chunk-CVNVD7VH.js.map +1 -0
- package/dist/chunk-CX3LH47J.js +99 -0
- package/dist/chunk-CX3LH47J.js.map +1 -0
- package/dist/{chunk-D7IFPWNZ.js → chunk-GVS2XXV6.js} +27 -26
- package/dist/chunk-GVS2XXV6.js.map +1 -0
- package/dist/chunk-H7T5DXUU.js +479 -0
- package/dist/chunk-H7T5DXUU.js.map +1 -0
- package/dist/{chunk-EHLGMSTE.js → chunk-HBSCRS5P.js} +10 -8
- package/dist/chunk-HBSCRS5P.js.map +1 -0
- package/dist/{chunk-46FMDOWZ.js → chunk-LXYLOOST.js} +49 -17
- package/dist/chunk-LXYLOOST.js.map +1 -0
- package/dist/{chunk-MJGRI6XR.js → chunk-MLX2BOJC.js} +12 -7
- package/dist/chunk-MLX2BOJC.js.map +1 -0
- package/dist/chunk-NKAJPJ4G.js +106 -0
- package/dist/chunk-NKAJPJ4G.js.map +1 -0
- package/dist/{chunk-DQAZR57U.js → chunk-O3GVVND4.js} +1 -1
- package/dist/chunk-ODL3SSPT.js +18 -0
- package/dist/chunk-ODL3SSPT.js.map +1 -0
- package/dist/chunk-X4USWOQ2.js +131 -0
- package/dist/chunk-X4USWOQ2.js.map +1 -0
- package/dist/chunk-XTLQXR4U.js +195 -0
- package/dist/chunk-XTLQXR4U.js.map +1 -0
- package/dist/chunk-YRT7GQ5Y.js +28 -0
- package/dist/chunk-YRT7GQ5Y.js.map +1 -0
- package/dist/chunk-ZZ7D4DN6.js +97 -0
- package/dist/chunk-ZZ7D4DN6.js.map +1 -0
- package/dist/container/index.d.ts +6 -2
- package/dist/container/index.js +15 -17
- package/dist/container/index.js.map +1 -1
- package/dist/docx/index.d.ts +6 -2
- package/dist/docx/index.js +5 -3
- package/dist/epub/index.d.ts +3 -1
- package/dist/epub/index.js +3 -3
- package/dist/export-Djev9BLU.d.ts +69 -0
- package/dist/extract-LNOA7DBK.js +15 -0
- package/dist/extract-LNOA7DBK.js.map +1 -0
- package/dist/html/index.d.ts +15 -85
- package/dist/html/index.js +3 -3
- package/dist/images-7FBWPKE3.js +7 -0
- package/dist/images-7FBWPKE3.js.map +1 -0
- package/dist/import-DTkDxHmZ.d.ts +84 -0
- package/dist/import-Yivc3kZM.d.ts +136 -0
- package/dist/index.d.ts +13 -4
- package/dist/index.js +30 -11
- package/dist/infer/index.d.ts +138 -0
- package/dist/infer/index.js +28 -0
- package/dist/infer/index.js.map +1 -0
- package/dist/layouts-7OUUVAGU.js +12 -0
- package/dist/layouts-7OUUVAGU.js.map +1 -0
- package/dist/layouts-CZ0bdsNL.d.ts +150 -0
- package/dist/mapTheme-IR27S6IV.js +11 -0
- package/dist/mapTheme-IR27S6IV.js.map +1 -0
- package/dist/ooxml/index.d.ts +21 -127
- package/dist/ooxml/index.js +31 -9
- package/dist/pdf/index.d.ts +3 -1
- package/dist/pdf/index.js +1 -1
- package/dist/pptx/index.d.ts +8 -108
- package/dist/pptx/index.js +13 -4
- package/dist/reader-Gof6OrJX.d.ts +140 -0
- package/dist/registry/index.d.ts +46 -8
- package/dist/registry/index.js +5 -2
- package/dist/themeReader-DPw4J5Ss.d.ts +56 -0
- package/dist/xlsx/index.d.ts +6 -66
- package/dist/xlsx/index.js +4 -2
- package/dist/zipLimits-bGYMS9cI.d.ts +29 -0
- package/package.json +8 -2
- package/src/__tests__/container.test.ts +41 -0
- package/src/__tests__/convert.test.ts +167 -0
- package/src/__tests__/epub.test.ts +102 -1
- package/src/__tests__/html.test.ts +62 -0
- package/src/__tests__/inferTheme.test.ts +135 -0
- package/src/__tests__/lossyWarnings.test.ts +41 -0
- package/src/__tests__/ooxml.test.ts +59 -2
- package/src/__tests__/ooxmlThemeReader.test.ts +92 -0
- package/src/__tests__/plainHtml.test.ts +15 -1
- package/src/__tests__/plainHtmlBundle.test.ts +18 -0
- package/src/__tests__/pptxImport.test.ts +30 -0
- package/src/__tests__/pptxInferFixtures.ts +314 -0
- package/src/__tests__/pptxLayoutInfer.test.ts +395 -0
- package/src/__tests__/zipSafety.test.ts +317 -0
- package/src/container/index.ts +20 -29
- package/src/docx/export.ts +4 -2
- package/src/docx/import.ts +4 -3
- package/src/epub/export.ts +94 -25
- package/src/html/docsHtmlBundle.ts +6 -2
- package/src/html/htmlTemplate.ts +31 -6
- package/src/html/imageUtils.ts +14 -5
- package/src/html/index.ts +12 -1
- package/src/html/plainHtml.ts +7 -3
- package/src/html/plainHtmlBundle.ts +11 -9
- package/src/index.ts +20 -0
- package/src/infer/extract.ts +127 -0
- package/src/infer/index.ts +168 -0
- package/src/infer/mapTheme.ts +176 -0
- package/src/infer/types.ts +27 -0
- package/src/ooxml/index.ts +14 -0
- package/src/ooxml/readUtils.ts +44 -0
- package/src/ooxml/reader.ts +87 -28
- package/src/ooxml/themeReader.ts +197 -0
- package/src/ooxml/types.ts +8 -9
- package/src/ooxml/writer.ts +28 -10
- package/src/pdf/export.ts +4 -2
- package/src/pdf/import.ts +40 -34
- package/src/pptx/export.ts +4 -2
- package/src/pptx/import.ts +214 -32
- package/src/pptx/index.ts +14 -0
- package/src/pptx/layouts.ts +1168 -0
- package/src/registry/convert.ts +54 -23
- package/src/registry/defaultFormats.ts +131 -44
- package/src/registry/index.ts +3 -0
- package/src/registry/types.ts +52 -6
- package/src/shared/boundedZipArchive.ts +342 -0
- package/src/shared/fidelity.ts +130 -0
- package/src/shared/zipEntryCount.ts +97 -0
- package/src/shared/zipLimits.ts +286 -0
- package/src/shared/zipSafety.ts +19 -0
- package/src/xlsx/import.ts +3 -2
- package/dist/chunk-46FMDOWZ.js.map +0 -1
- package/dist/chunk-5LSSWZPU.js.map +0 -1
- package/dist/chunk-D7IFPWNZ.js.map +0 -1
- package/dist/chunk-EHLGMSTE.js.map +0 -1
- package/dist/chunk-MJGRI6XR.js.map +0 -1
- package/dist/chunk-RTS5XBZ7.js.map +0 -1
- package/dist/chunk-SHLPSADL.js.map +0 -1
- package/dist/chunk-WWBIKRNP.js.map +0 -1
- package/dist/chunk-YESS7VY3.js.map +0 -1
- /package/dist/{chunk-DQAZR57U.js.map → chunk-O3GVVND4.js.map} +0 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ThemeRegistry, Doc } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
import { O as OoxmlOpenOptions } from './reader-Gof6OrJX.js';
|
|
4
|
+
import { ContentContainer } from '@bendyline/squisq/storage';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* PPTX Export
|
|
8
|
+
*
|
|
9
|
+
* Converts a squisq MarkdownDocument (or Doc) into a .pptx file
|
|
10
|
+
* by generating PresentationML + DrawingML XML and assembling the
|
|
11
|
+
* OOXML package.
|
|
12
|
+
*
|
|
13
|
+
* Slide segmentation: each H1 or H2 heading starts a new slide.
|
|
14
|
+
* The heading becomes the slide title; content below becomes the body.
|
|
15
|
+
*
|
|
16
|
+
* Supports:
|
|
17
|
+
* - Theme-based styling (background, text colors, fonts from squisq themes)
|
|
18
|
+
* - Image embedding (pass images as ArrayBuffers via options)
|
|
19
|
+
* - Inline formatting (bold, italic, strikethrough, code, links)
|
|
20
|
+
* - Lists, code blocks, blockquotes, tables, math
|
|
21
|
+
*
|
|
22
|
+
* No third-party pptx library — all XML is generated directly using
|
|
23
|
+
* the shared ooxml/ infrastructure.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { parseMarkdown } from '@bendyline/squisq/markdown';
|
|
28
|
+
* import { markdownDocToPptx } from '@bendyline/squisq-formats/pptx';
|
|
29
|
+
*
|
|
30
|
+
* const md = parseMarkdown('# Slide 1\n\nHello world\n\n## Slide 2\n\nMore content');
|
|
31
|
+
* const blob = await markdownDocToPptx(md, { themeId: 'documentary' });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Options for PPTX export.
|
|
37
|
+
*/
|
|
38
|
+
interface PptxExportOptions {
|
|
39
|
+
/** Presentation title (appears in core properties) */
|
|
40
|
+
title?: string;
|
|
41
|
+
/** Presentation author */
|
|
42
|
+
author?: string;
|
|
43
|
+
/** Presentation description */
|
|
44
|
+
description?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Which heading depth triggers a new slide.
|
|
47
|
+
* - `'h1'` — only H1 headings start slides
|
|
48
|
+
* - `'h2'` — H1 and H2 headings start slides (default)
|
|
49
|
+
* - `'heading'` — any heading (H1–H6) starts a slide
|
|
50
|
+
*/
|
|
51
|
+
slideBreak?: 'h1' | 'h2' | 'heading';
|
|
52
|
+
/** Default body font family. Default: "Calibri" */
|
|
53
|
+
defaultFont?: string;
|
|
54
|
+
/** Default body font size in points. Default: 18 */
|
|
55
|
+
defaultFontSize?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Squisq theme ID to apply (e.g., 'documentary', 'cinematic', 'bold').
|
|
58
|
+
* Controls slide background, text colors, and fonts.
|
|
59
|
+
* Falls back to the document's frontmatter `themeId` if not set here.
|
|
60
|
+
*/
|
|
61
|
+
themeId?: string;
|
|
62
|
+
/** Explicit caller-owned registry for non-document custom themes. */
|
|
63
|
+
themeRegistry?: ThemeRegistry;
|
|
64
|
+
/**
|
|
65
|
+
* Image data keyed by the path/URL used in markdown.
|
|
66
|
+
* When provided, images are embedded as picture shapes instead of
|
|
67
|
+
* showing `[Image: alt]` placeholders.
|
|
68
|
+
*/
|
|
69
|
+
images?: Map<string, ArrayBuffer>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert a MarkdownDocument to a .pptx ArrayBuffer.
|
|
73
|
+
*/
|
|
74
|
+
declare function markdownDocToPptx(doc: MarkdownDocument, options?: PptxExportOptions): Promise<ArrayBuffer>;
|
|
75
|
+
/**
|
|
76
|
+
* Convert a squisq Doc to a .pptx ArrayBuffer.
|
|
77
|
+
*
|
|
78
|
+
* Convenience wrapper: Doc -> MarkdownDocument -> PPTX.
|
|
79
|
+
*/
|
|
80
|
+
declare function docToPptx(doc: Doc, options?: PptxExportOptions): Promise<ArrayBuffer>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* PPTX import — PresentationML (.pptx) → MarkdownDocument.
|
|
84
|
+
*
|
|
85
|
+
* Reuses the shared ooxml/ reader. Reads slide order from
|
|
86
|
+
* `ppt/presentation.xml` (`<p:sldIdLst>`), resolves each slide part via
|
|
87
|
+
* relationships, and converts each slide to: an H2 of the title placeholder
|
|
88
|
+
* (or "Slide N"), the remaining text as a bullet list, and any slide tables
|
|
89
|
+
* (`<a:tbl>`) as markdown tables. Text lives in the DrawingML namespace
|
|
90
|
+
* (`a:p` / `a:r` / `a:t`) inside PresentationML shapes (`p:sp`).
|
|
91
|
+
*
|
|
92
|
+
* Theme + layout inference (default ON): the deck's theme part is compiled
|
|
93
|
+
* into a Squisq custom theme and carried in the returned document's
|
|
94
|
+
* frontmatter (`squisq-custom-themes` + `squisq-theme`); slide layouts are
|
|
95
|
+
* classified against the built-in template set, distinctive ones become
|
|
96
|
+
* `squisq-custom-templates` definitions, and each slide's heading is
|
|
97
|
+
* annotated (`{[templateName …]}`) per its layout's verdict. Pass
|
|
98
|
+
* `inferTheme: false` / `inferLayouts: false` for legacy plain imports.
|
|
99
|
+
* Inference never fails an import — extraction errors degrade to plain
|
|
100
|
+
* output with a console warning.
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
interface PptxImportOptions extends OoxmlOpenOptions {
|
|
104
|
+
/**
|
|
105
|
+
* Whether to extract embedded slide images into the document as image nodes
|
|
106
|
+
* (referencing `images/imageN.ext`). When false, pictures are ignored so the
|
|
107
|
+
* markdown never carries dangling image references with no backing container.
|
|
108
|
+
* `pptxToContainer` forces this on. Default: false.
|
|
109
|
+
*/
|
|
110
|
+
extractImages?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Infer a Squisq theme from the deck's theme part (colors + fonts) and
|
|
113
|
+
* carry it in the returned document's frontmatter (`squisq-custom-themes`
|
|
114
|
+
* + `squisq-theme`). Default: true — pass false for a legacy import with
|
|
115
|
+
* no frontmatter.
|
|
116
|
+
*/
|
|
117
|
+
inferTheme?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Derive custom layout templates from the deck's slide layouts/masters
|
|
120
|
+
* (`squisq-custom-templates` frontmatter) and annotate slide headings
|
|
121
|
+
* with matching built-in or generated templates. Default: true.
|
|
122
|
+
*/
|
|
123
|
+
inferLayouts?: boolean;
|
|
124
|
+
}
|
|
125
|
+
declare function pptxToMarkdownDoc(data: ArrayBuffer | Blob, options?: PptxImportOptions): Promise<MarkdownDocument>;
|
|
126
|
+
/**
|
|
127
|
+
* Convert a .pptx file to a ContentContainer with markdown + extracted images.
|
|
128
|
+
*
|
|
129
|
+
* The container holds the primary markdown document plus every embedded slide
|
|
130
|
+
* image under `images/` (e.g. `images/image1.png`). Image extraction is always
|
|
131
|
+
* forced on here so the markdown's image references resolve inside the
|
|
132
|
+
* container. Mirrors `docxToContainer`.
|
|
133
|
+
*/
|
|
134
|
+
declare function pptxToContainer(data: ArrayBuffer | Blob, options?: PptxImportOptions): Promise<ContentContainer>;
|
|
135
|
+
|
|
136
|
+
export { type PptxExportOptions as P, type PptxImportOptions as a, pptxToContainer as b, docToPptx as d, markdownDocToPptx as m, pptxToMarkdownDoc as p };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
export { DocxExportOptions, DocxImportOptions, docToDocx, docxToDoc, docxToMarkdownDoc, markdownDocToDocx } from './docx/index.js';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export { pptxToDoc } from './pptx/index.js';
|
|
3
|
+
export { xlsxToDoc } from './xlsx/index.js';
|
|
4
4
|
export { CsvExportOptions, CsvImportOptions, csvToDoc, csvToMarkdownDoc, markdownDocToCsv, parseCsv } from './csv/index.js';
|
|
5
5
|
export { PdfExportOptions, PdfImportOptions, configurePdfWorker, docToPdf, markdownDocToPdf, pdfToDoc, pdfToMarkdownDoc } from './pdf/index.js';
|
|
6
|
-
export {
|
|
6
|
+
export { HtmlZipExportOptions, docToHtml, docToHtmlZip } from './html/index.js';
|
|
7
7
|
export { EpubExportOptions, docToEpub, markdownDocToEpub } from './epub/index.js';
|
|
8
|
-
export {
|
|
8
|
+
export { ExtractedFileTheme, InferSourceFormat, InferThemeOptions, InferredFileTheme, compileExtractedTheme, inferThemeFromFile } from './infer/index.js';
|
|
9
|
+
export { BUILTIN_FORMAT_IDS, BuiltinFormatOptions, ConversionError, ConversionErrorCode, ConversionErrorOptions, ConversionResult, ConvertOptions, ConvertSource, DbkFormatOptions, FormatDefinition, FormatId, FormatRegistry, MarkdownFormatOptions, NormalizedInput, convert, createRegistry, defaultFormats, defaultRegistry } from './registry/index.js';
|
|
10
|
+
export { Z as ZipSafetyError, a as ZipSafetyErrorCode, b as ZipSafetyErrorOptions, c as ZipSafetyLimits } from './zipLimits-bGYMS9cI.js';
|
|
11
|
+
export { H as HtmlExportOptions, a as HtmlImportOptions, c as collectImagePaths, h as htmlToMarkdown, b as htmlToMarkdownDoc, d as htmlToMarkdownDocSync } from './import-DTkDxHmZ.js';
|
|
12
|
+
export { P as PptxExportOptions, a as PptxImportOptions, d as docToPptx, m as markdownDocToPptx, p as pptxToMarkdownDoc } from './import-Yivc3kZM.js';
|
|
13
|
+
export { X as XlsxExportOptions, a as XlsxImportOptions, d as docToXlsx, m as markdownDocToXlsx, x as xlsxToMarkdownDoc } from './export-Djev9BLU.js';
|
|
9
14
|
import '@bendyline/squisq/schemas';
|
|
10
15
|
import '@bendyline/squisq/markdown';
|
|
16
|
+
import './reader-Gof6OrJX.js';
|
|
11
17
|
import '@bendyline/squisq/storage';
|
|
18
|
+
import './layouts-CZ0bdsNL.js';
|
|
19
|
+
import './themeReader-DPw4J5Ss.js';
|
|
20
|
+
import '@bendyline/squisq/transform';
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,44 @@
|
|
|
1
1
|
import {
|
|
2
2
|
docToEpub,
|
|
3
3
|
markdownDocToEpub
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4VUWTSGM.js";
|
|
5
5
|
import {
|
|
6
6
|
BUILTIN_FORMAT_IDS,
|
|
7
|
-
ConversionError,
|
|
8
7
|
convert,
|
|
9
8
|
createRegistry,
|
|
10
9
|
defaultFormats,
|
|
11
10
|
defaultRegistry
|
|
12
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-2EFDWKC6.js";
|
|
12
|
+
import {
|
|
13
|
+
inferThemeFromFile
|
|
14
|
+
} from "./chunk-ZZ7D4DN6.js";
|
|
15
|
+
import {
|
|
16
|
+
ConversionError
|
|
17
|
+
} from "./chunk-ODL3SSPT.js";
|
|
18
|
+
import "./chunk-CX3LH47J.js";
|
|
19
|
+
import {
|
|
20
|
+
compileExtractedTheme
|
|
21
|
+
} from "./chunk-NKAJPJ4G.js";
|
|
13
22
|
import {
|
|
14
23
|
docToDocx,
|
|
15
24
|
docxToDoc,
|
|
16
25
|
docxToMarkdownDoc,
|
|
17
26
|
markdownDocToDocx
|
|
18
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-2CSZJEAL.js";
|
|
19
28
|
import {
|
|
20
29
|
docToPptx,
|
|
21
30
|
markdownDocToPptx,
|
|
22
31
|
pptxToDoc,
|
|
23
32
|
pptxToMarkdownDoc
|
|
24
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-CVNVD7VH.js";
|
|
34
|
+
import "./chunk-2PRVLAU3.js";
|
|
25
35
|
import "./chunk-6M7Z25LA.js";
|
|
26
36
|
import {
|
|
27
37
|
docToXlsx,
|
|
28
38
|
markdownDocToXlsx,
|
|
29
39
|
xlsxToDoc,
|
|
30
40
|
xlsxToMarkdownDoc
|
|
31
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-HBSCRS5P.js";
|
|
32
42
|
import "./chunk-PN52A5AA.js";
|
|
33
43
|
import {
|
|
34
44
|
csvToDoc,
|
|
@@ -36,15 +46,21 @@ import {
|
|
|
36
46
|
markdownDocToCsv,
|
|
37
47
|
parseCsv
|
|
38
48
|
} from "./chunk-RFAPOKHJ.js";
|
|
39
|
-
import "./chunk-
|
|
49
|
+
import "./chunk-X4USWOQ2.js";
|
|
50
|
+
import "./chunk-YRT7GQ5Y.js";
|
|
51
|
+
import "./chunk-XTLQXR4U.js";
|
|
40
52
|
import "./chunk-U4MRIFKL.js";
|
|
53
|
+
import "./chunk-4HJ6AK2Q.js";
|
|
54
|
+
import {
|
|
55
|
+
ZipSafetyError
|
|
56
|
+
} from "./chunk-H7T5DXUU.js";
|
|
41
57
|
import {
|
|
42
58
|
configurePdfWorker,
|
|
43
59
|
docToPdf,
|
|
44
60
|
markdownDocToPdf,
|
|
45
61
|
pdfToDoc,
|
|
46
62
|
pdfToMarkdownDoc
|
|
47
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-GVS2XXV6.js";
|
|
48
64
|
import "./chunk-SSUPBUF5.js";
|
|
49
65
|
import {
|
|
50
66
|
collectImagePaths,
|
|
@@ -53,13 +69,15 @@ import {
|
|
|
53
69
|
htmlToMarkdown,
|
|
54
70
|
htmlToMarkdownDoc,
|
|
55
71
|
htmlToMarkdownDocSync
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
72
|
+
} from "./chunk-LXYLOOST.js";
|
|
73
|
+
import "./chunk-MLX2BOJC.js";
|
|
74
|
+
import "./chunk-O3GVVND4.js";
|
|
59
75
|
export {
|
|
60
76
|
BUILTIN_FORMAT_IDS,
|
|
61
77
|
ConversionError,
|
|
78
|
+
ZipSafetyError,
|
|
62
79
|
collectImagePaths,
|
|
80
|
+
compileExtractedTheme,
|
|
63
81
|
configurePdfWorker,
|
|
64
82
|
convert,
|
|
65
83
|
createRegistry,
|
|
@@ -79,6 +97,7 @@ export {
|
|
|
79
97
|
htmlToMarkdown,
|
|
80
98
|
htmlToMarkdownDoc,
|
|
81
99
|
htmlToMarkdownDocSync,
|
|
100
|
+
inferThemeFromFile,
|
|
82
101
|
markdownDocToCsv,
|
|
83
102
|
markdownDocToDocx,
|
|
84
103
|
markdownDocToEpub,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Theme, DeepPartial, CustomTemplateDefinition } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { a as OoxmlPackage, O as OoxmlOpenOptions } from '../reader-Gof6OrJX.js';
|
|
3
|
+
import { O as OoxmlColorScheme, a as OoxmlFontScheme } from '../themeReader-DPw4J5Ss.js';
|
|
4
|
+
import { P as PptxColorHints } from '../layouts-CZ0bdsNL.js';
|
|
5
|
+
import '../zipLimits-bGYMS9cI.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Shared types for file-import theme inference.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Source formats theme inference supports. PDF carries no theme tables. */
|
|
12
|
+
type InferSourceFormat = 'docx' | 'pptx' | 'xlsx';
|
|
13
|
+
/** The four surface/text scheme slots a color map can point at. */
|
|
14
|
+
type SchemeSlot = 'dk1' | 'lt1' | 'dk2' | 'lt2';
|
|
15
|
+
/**
|
|
16
|
+
* Raw theme extraction from one office file, before mapping onto a Squisq
|
|
17
|
+
* `Theme`. `colorMap` records which scheme slots back the document's
|
|
18
|
+
* background/text — PPTX masters carry `<p:clrMap bg1=… tx1=…>` and DOCX may
|
|
19
|
+
* carry `w:clrSchemeMapping`; dark decks map `bg1="dk1"` and invert here.
|
|
20
|
+
*/
|
|
21
|
+
interface ExtractedFileTheme {
|
|
22
|
+
sourceFormat: InferSourceFormat;
|
|
23
|
+
/** `a:theme@name` when present (e.g. "Office Theme", "Ion"). */
|
|
24
|
+
themeName?: string;
|
|
25
|
+
colors?: OoxmlColorScheme;
|
|
26
|
+
colorMap: {
|
|
27
|
+
bg1: SchemeSlot;
|
|
28
|
+
tx1: SchemeSlot;
|
|
29
|
+
};
|
|
30
|
+
fonts?: OoxmlFontScheme;
|
|
31
|
+
warnings: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Per-format theme extraction: locate the theme part of an already-opened
|
|
36
|
+
* OOXML package, parse it, and resolve the document's background/text color
|
|
37
|
+
* mapping. Returns null when the file has no theme part at all.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* DOCX: theme hangs off `word/document.xml`; an optional
|
|
42
|
+
* `w:clrSchemeMapping` in `word/settings.xml` remaps bg1/t1 slots
|
|
43
|
+
* (values `light1`/`dark1`/`light2`/`dark2`).
|
|
44
|
+
*/
|
|
45
|
+
declare function extractDocxTheme(pkg: OoxmlPackage): Promise<ExtractedFileTheme | null>;
|
|
46
|
+
/**
|
|
47
|
+
* PPTX: theme hangs off the first slide master, whose `<p:clrMap>` records
|
|
48
|
+
* which scheme slots back the deck's background/text (dark decks set
|
|
49
|
+
* `bg1="dk1" tx1="lt1"`).
|
|
50
|
+
*/
|
|
51
|
+
declare function extractPptxTheme(pkg: OoxmlPackage): Promise<ExtractedFileTheme | null>;
|
|
52
|
+
/** XLSX: theme hangs off `xl/workbook.xml`; no color remapping exists. */
|
|
53
|
+
declare function extractXlsxTheme(pkg: OoxmlPackage): Promise<ExtractedFileTheme | null>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Map a raw OOXML theme extraction onto a compiled Squisq `Theme`.
|
|
57
|
+
*
|
|
58
|
+
* Only a handful of seeds are taken from the file (lead accents, background,
|
|
59
|
+
* text, major/minor fonts); `compileTheme` derives the rest of the palette
|
|
60
|
+
* via OKLCh so the result is always a complete, validated theme that stays
|
|
61
|
+
* re-editable in the customizer (seeds are recorded on `Theme.seedColors`).
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
interface CompileExtractedOptions {
|
|
65
|
+
/** Preferred display name for the compiled theme (e.g. the file's basename). */
|
|
66
|
+
nameHint?: string;
|
|
67
|
+
}
|
|
68
|
+
interface MappedThemePartial {
|
|
69
|
+
partial: DeepPartial<Theme>;
|
|
70
|
+
warnings: string[];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build the `DeepPartial<Theme>` for an extraction. Exported for tests; most
|
|
74
|
+
* callers want {@link compileExtractedTheme}.
|
|
75
|
+
*/
|
|
76
|
+
declare function extractedThemeToPartial(extraction: ExtractedFileTheme, opts?: CompileExtractedOptions): MappedThemePartial;
|
|
77
|
+
/**
|
|
78
|
+
* Compile an extraction into a full validated Squisq theme. Mapping warnings
|
|
79
|
+
* (dropped accents, low-contrast surfaces) are returned alongside; extraction
|
|
80
|
+
* warnings stay on `extraction.warnings`.
|
|
81
|
+
*/
|
|
82
|
+
declare function compileExtractedTheme(extraction: ExtractedFileTheme, opts?: CompileExtractedOptions): {
|
|
83
|
+
theme: Theme;
|
|
84
|
+
warnings: string[];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Build the color hints the PPTX layout generator uses to resolve scheme
|
|
88
|
+
* color references (`a:schemeClr val="accent1"`, `bg1`, `tx1`, …) on
|
|
89
|
+
* decorative shapes.
|
|
90
|
+
*/
|
|
91
|
+
declare function colorHintsFromExtraction(extraction: ExtractedFileTheme): PptxColorHints;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @bendyline/squisq-formats Infer Module
|
|
95
|
+
*
|
|
96
|
+
* "Infer theme and layouts from a file import": read the OOXML theme
|
|
97
|
+
* (colors + fonts) out of a DOCX/PPTX/XLSX file and compile it into a
|
|
98
|
+
* Squisq `Theme`; for PPTX, optionally derive custom layout templates
|
|
99
|
+
* from the deck's slide layouts/masters.
|
|
100
|
+
*
|
|
101
|
+
* Consumers:
|
|
102
|
+
* - the editor's theme customizer surfaces (upload / drag-drop a file)
|
|
103
|
+
* - the PPTX importer (theme + layouts ride along as frontmatter)
|
|
104
|
+
*
|
|
105
|
+
* PDF is deliberately unsupported: PDF files carry no theme tables, so
|
|
106
|
+
* inference would produce a mostly-default theme. `inferThemeFromFile`
|
|
107
|
+
* rejects PDF bytes with a clear `ConversionError`.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
interface InferThemeOptions extends OoxmlOpenOptions {
|
|
111
|
+
/** Skip sniffing when the caller already knows the format (e.g. from the extension). */
|
|
112
|
+
format?: InferSourceFormat;
|
|
113
|
+
/** PPTX only: also derive custom layout templates from slide layouts/masters. */
|
|
114
|
+
inferLayouts?: boolean;
|
|
115
|
+
/** Preferred display name for the compiled theme (e.g. the file's basename). */
|
|
116
|
+
nameHint?: string;
|
|
117
|
+
}
|
|
118
|
+
interface InferredFileTheme {
|
|
119
|
+
/** Compiled, validated Squisq theme (`custom-<slug>` id, seeds recorded). */
|
|
120
|
+
theme: Theme;
|
|
121
|
+
/** Raw extraction, for callers mapping into their own editing model. */
|
|
122
|
+
extraction: ExtractedFileTheme;
|
|
123
|
+
/** Present only for PPTX with `inferLayouts` and ≥1 non-redundant layout. */
|
|
124
|
+
layouts?: CustomTemplateDefinition[];
|
|
125
|
+
/** Non-fatal notes: sysClr fallbacks, dropped accents, skipped layouts, … */
|
|
126
|
+
warnings: string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Infer a Squisq theme (and, for PPTX, optionally custom layout templates)
|
|
130
|
+
* from an office file's bytes.
|
|
131
|
+
*
|
|
132
|
+
* Throws `ConversionError`:
|
|
133
|
+
* - `unsupported-input` for PDF bytes (no theme tables to read)
|
|
134
|
+
* - `invalid-input` for non-OOXML data or files with no theme part
|
|
135
|
+
*/
|
|
136
|
+
declare function inferThemeFromFile(data: ArrayBuffer | Blob, options?: InferThemeOptions): Promise<InferredFileTheme>;
|
|
137
|
+
|
|
138
|
+
export { type CompileExtractedOptions, type ExtractedFileTheme, type InferSourceFormat, type InferThemeOptions, type InferredFileTheme, type MappedThemePartial, type SchemeSlot, colorHintsFromExtraction, compileExtractedTheme, extractDocxTheme, extractPptxTheme, extractXlsxTheme, extractedThemeToPartial, inferThemeFromFile };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
inferThemeFromFile
|
|
3
|
+
} from "../chunk-ZZ7D4DN6.js";
|
|
4
|
+
import "../chunk-ODL3SSPT.js";
|
|
5
|
+
import {
|
|
6
|
+
extractDocxTheme,
|
|
7
|
+
extractPptxTheme,
|
|
8
|
+
extractXlsxTheme
|
|
9
|
+
} from "../chunk-CX3LH47J.js";
|
|
10
|
+
import {
|
|
11
|
+
colorHintsFromExtraction,
|
|
12
|
+
compileExtractedTheme,
|
|
13
|
+
extractedThemeToPartial
|
|
14
|
+
} from "../chunk-NKAJPJ4G.js";
|
|
15
|
+
import "../chunk-X4USWOQ2.js";
|
|
16
|
+
import "../chunk-YRT7GQ5Y.js";
|
|
17
|
+
import "../chunk-4HJ6AK2Q.js";
|
|
18
|
+
import "../chunk-H7T5DXUU.js";
|
|
19
|
+
export {
|
|
20
|
+
colorHintsFromExtraction,
|
|
21
|
+
compileExtractedTheme,
|
|
22
|
+
extractDocxTheme,
|
|
23
|
+
extractPptxTheme,
|
|
24
|
+
extractXlsxTheme,
|
|
25
|
+
extractedThemeToPartial,
|
|
26
|
+
inferThemeFromFile
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
analyzePptxLayouts,
|
|
3
|
+
inspectPptxLayouts
|
|
4
|
+
} from "./chunk-2PRVLAU3.js";
|
|
5
|
+
import "./chunk-YRT7GQ5Y.js";
|
|
6
|
+
import "./chunk-4HJ6AK2Q.js";
|
|
7
|
+
import "./chunk-H7T5DXUU.js";
|
|
8
|
+
export {
|
|
9
|
+
analyzePptxLayouts,
|
|
10
|
+
inspectPptxLayouts
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=layouts-7OUUVAGU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { CustomTemplateDefinition } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { O as OoxmlOpenOptions, a as OoxmlPackage } from './reader-Gof6OrJX.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* PPTX slide-layout inference — reads the layouts/masters a deck actually
|
|
6
|
+
* uses and, per layout, either matches it to a close built-in Squisq
|
|
7
|
+
* template (title, sectionHeader, twoColumn, leftFeature, …) or generates a
|
|
8
|
+
* reusable `CustomTemplateDefinition` from its placeholder geometry.
|
|
9
|
+
*
|
|
10
|
+
* The classifier is a deterministic three-stage waterfall — the layout's
|
|
11
|
+
* `type` attribute, then well-known layout names, then placeholder-set
|
|
12
|
+
* geometry — biased toward *not* templating: a title over a single body
|
|
13
|
+
* flows better as plain markdown, and only genuinely distinctive geometry
|
|
14
|
+
* (side-by-side content, positioned picture placeholders) becomes a custom
|
|
15
|
+
* template.
|
|
16
|
+
*
|
|
17
|
+
* Shared by the PPTX importer (`inferLayouts`) and the theme dialog's
|
|
18
|
+
* `inspectPptxLayouts` — one implementation, two consumers.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** Percent-of-slide rect, 0–100 per axis (2-decimal precision). */
|
|
22
|
+
interface PctRect {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
w: number;
|
|
26
|
+
h: number;
|
|
27
|
+
}
|
|
28
|
+
type PlaceholderKind = 'title' | 'subtitle' | 'text' | 'picture' | 'table' | 'chart' | 'other';
|
|
29
|
+
interface PlaceholderTextStyle {
|
|
30
|
+
fontSizePt?: number;
|
|
31
|
+
bold?: boolean;
|
|
32
|
+
align?: 'left' | 'center' | 'right';
|
|
33
|
+
anchor?: 'top' | 'middle' | 'bottom';
|
|
34
|
+
}
|
|
35
|
+
interface ExtractedPlaceholder {
|
|
36
|
+
kind: PlaceholderKind;
|
|
37
|
+
/** `p:ph@type` verbatim ('' when absent — spec default is body). */
|
|
38
|
+
rawType: string;
|
|
39
|
+
/** `p:ph@idx`, default 0. */
|
|
40
|
+
idx: number;
|
|
41
|
+
/** Geometry resolved through the layout→master inheritance chain. */
|
|
42
|
+
rect: PctRect;
|
|
43
|
+
inheritedFromMaster: boolean;
|
|
44
|
+
vertical: boolean;
|
|
45
|
+
textStyle?: PlaceholderTextStyle;
|
|
46
|
+
}
|
|
47
|
+
interface ExtractedDecoration {
|
|
48
|
+
shape: 'rect' | 'line';
|
|
49
|
+
rect: PctRect;
|
|
50
|
+
fill?: string;
|
|
51
|
+
stroke?: string;
|
|
52
|
+
strokeWidthPx?: number;
|
|
53
|
+
borderRadius?: number;
|
|
54
|
+
}
|
|
55
|
+
interface ExtractedSlideLayout {
|
|
56
|
+
partPath: string;
|
|
57
|
+
/** `p:cSld@name` ('' when absent). */
|
|
58
|
+
name: string;
|
|
59
|
+
/** `p:sldLayout@type` (ST_SlideLayoutType) when present. */
|
|
60
|
+
typeAttr?: string;
|
|
61
|
+
masterPath?: string;
|
|
62
|
+
masterName?: string;
|
|
63
|
+
/** Content placeholders — dt/ftr/sldNum/hdr chrome already excluded. */
|
|
64
|
+
placeholders: ExtractedPlaceholder[];
|
|
65
|
+
decorations: ExtractedDecoration[];
|
|
66
|
+
/** Number of slides in this deck using this layout (0 = defined but unused). */
|
|
67
|
+
slideCount: number;
|
|
68
|
+
}
|
|
69
|
+
/** Scheme-color hints for decoration fills, supplied by theme extraction. */
|
|
70
|
+
interface PptxColorHints {
|
|
71
|
+
text?: string;
|
|
72
|
+
background?: string;
|
|
73
|
+
/** `a:schemeClr@val` (accent1…, bg1, tx1, dk1, …) → resolved hex. */
|
|
74
|
+
schemeColors?: Record<string, string>;
|
|
75
|
+
}
|
|
76
|
+
type BuiltinParamSpec = 'titleSubtitle' | 'comparisonPairs' | 'featureImage' | 'photoGridGate';
|
|
77
|
+
type LayoutVerdict = {
|
|
78
|
+
kind: 'plain';
|
|
79
|
+
} | {
|
|
80
|
+
kind: 'skip';
|
|
81
|
+
} | {
|
|
82
|
+
kind: 'builtin';
|
|
83
|
+
template: string;
|
|
84
|
+
paramSpec?: BuiltinParamSpec;
|
|
85
|
+
/** For `comparisonPairs`: placeholder idx lists per column, top-to-bottom. */
|
|
86
|
+
columns?: {
|
|
87
|
+
left: number[];
|
|
88
|
+
right: number[];
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'custom';
|
|
92
|
+
def: CustomTemplateDefinition;
|
|
93
|
+
};
|
|
94
|
+
interface AnalyzedLayout {
|
|
95
|
+
extracted: ExtractedSlideLayout;
|
|
96
|
+
verdict: LayoutVerdict;
|
|
97
|
+
/** Human-readable caveats: dropped regions, unsupported placeholders, … */
|
|
98
|
+
notes: string[];
|
|
99
|
+
}
|
|
100
|
+
interface PptxLayoutInference {
|
|
101
|
+
slideSize: {
|
|
102
|
+
cx: number;
|
|
103
|
+
cy: number;
|
|
104
|
+
};
|
|
105
|
+
layouts: AnalyzedLayout[];
|
|
106
|
+
byLayoutPath: Map<string, AnalyzedLayout>;
|
|
107
|
+
layoutPathBySlide: Map<string, string>;
|
|
108
|
+
warnings: string[];
|
|
109
|
+
}
|
|
110
|
+
interface AnalyzePptxLayoutsOptions extends OoxmlOpenOptions {
|
|
111
|
+
/** Also analyze layouts no slide references (default false). */
|
|
112
|
+
includeUnused?: boolean;
|
|
113
|
+
colors?: PptxColorHints;
|
|
114
|
+
/** Cap on generated custom templates (default 12); excess downgrades to plain. */
|
|
115
|
+
maxTemplates?: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Analyze the deck's slide layouts: extract placeholder geometry (with
|
|
119
|
+
* master inheritance), classify each layout against the built-in template
|
|
120
|
+
* set, and generate custom template definitions for the distinctive ones.
|
|
121
|
+
*/
|
|
122
|
+
declare function analyzePptxLayouts(pkg: OoxmlPackage, options?: AnalyzePptxLayoutsOptions): Promise<PptxLayoutInference>;
|
|
123
|
+
interface PptxLayoutSummary {
|
|
124
|
+
layoutPath: string;
|
|
125
|
+
name: string;
|
|
126
|
+
masterName?: string;
|
|
127
|
+
typeAttr?: string;
|
|
128
|
+
slideCount: number;
|
|
129
|
+
verdict: 'builtin' | 'custom' | 'plain' | 'skip';
|
|
130
|
+
/** Set when verdict is 'builtin' — the close built-in alternative. */
|
|
131
|
+
builtinTemplate?: string;
|
|
132
|
+
/** Set when verdict is 'custom' — ready to save as a doc/library template. */
|
|
133
|
+
customTemplate?: CustomTemplateDefinition;
|
|
134
|
+
notes?: string[];
|
|
135
|
+
}
|
|
136
|
+
type InspectPptxLayoutsOptions = AnalyzePptxLayoutsOptions;
|
|
137
|
+
/**
|
|
138
|
+
* Inspect a deck's layouts without importing it — used by the theme dialog
|
|
139
|
+
* to list what a PPTX would contribute (built-in matches shown as
|
|
140
|
+
* informational rows; custom templates offered for confirmation).
|
|
141
|
+
*/
|
|
142
|
+
declare function inspectPptxLayouts(data: ArrayBuffer | Blob, options?: InspectPptxLayoutsOptions): Promise<{
|
|
143
|
+
layouts: PptxLayoutSummary[];
|
|
144
|
+
slideSize: {
|
|
145
|
+
cx: number;
|
|
146
|
+
cy: number;
|
|
147
|
+
};
|
|
148
|
+
}>;
|
|
149
|
+
|
|
150
|
+
export { type AnalyzePptxLayoutsOptions as A, type ExtractedPlaceholder as E, type InspectPptxLayoutsOptions as I, type LayoutVerdict as L, type PptxColorHints as P, type AnalyzedLayout as a, type ExtractedSlideLayout as b, type PptxLayoutInference as c, type PptxLayoutSummary as d, analyzePptxLayouts as e, inspectPptxLayouts as i };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
colorHintsFromExtraction,
|
|
3
|
+
compileExtractedTheme,
|
|
4
|
+
extractedThemeToPartial
|
|
5
|
+
} from "./chunk-NKAJPJ4G.js";
|
|
6
|
+
export {
|
|
7
|
+
colorHintsFromExtraction,
|
|
8
|
+
compileExtractedTheme,
|
|
9
|
+
extractedThemeToPartial
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=mapTheme-IR27S6IV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|