@bendyline/squisq-formats 1.4.2 → 2.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/README.md +48 -2
- package/dist/chunk-2KPARF2P.js +99 -0
- package/dist/chunk-2KPARF2P.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-ABVI556T.js} +154 -39
- package/dist/chunk-ABVI556T.js.map +1 -0
- package/dist/{chunk-WWBIKRNP.js → chunk-CRAVSMPZ.js} +13 -11
- package/dist/chunk-CRAVSMPZ.js.map +1 -0
- package/dist/chunk-FE6OJV6O.js +560 -0
- package/dist/chunk-FE6OJV6O.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-RTS5XBZ7.js → chunk-HTW2M27H.js} +341 -100
- package/dist/chunk-HTW2M27H.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-QRVN6A6E.js +127 -0
- package/dist/chunk-QRVN6A6E.js.map +1 -0
- package/dist/chunk-U32AG3G3.js +195 -0
- package/dist/chunk-U32AG3G3.js.map +1 -0
- package/dist/{chunk-EHLGMSTE.js → chunk-VJJM2SSH.js} +10 -8
- package/dist/chunk-VJJM2SSH.js.map +1 -0
- package/dist/chunk-VSYHZECT.js +778 -0
- package/dist/chunk-VSYHZECT.js.map +1 -0
- package/dist/{chunk-SHLPSADL.js → chunk-WC7WULGV.js} +81 -189
- package/dist/chunk-WC7WULGV.js.map +1 -0
- package/dist/chunk-XKUMNGBW.js +131 -0
- package/dist/chunk-XKUMNGBW.js.map +1 -0
- package/dist/chunk-YRT7GQ5Y.js +28 -0
- package/dist/chunk-YRT7GQ5Y.js.map +1 -0
- package/dist/container/index.d.ts +13 -3
- package/dist/container/index.js +23 -20
- 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-D2NkylDT.d.ts +69 -0
- package/dist/extract-H6RXJMHP.js +15 -0
- package/dist/extract-H6RXJMHP.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-K8mfc0fz.d.ts +136 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +33 -12
- 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-BHrgZ5FS.d.ts +150 -0
- package/dist/layouts-QVPK3ZCU.js +12 -0
- package/dist/layouts-QVPK3ZCU.js.map +1 -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-B9L8Ucbj.d.ts +140 -0
- package/dist/registry/index.d.ts +60 -8
- package/dist/registry/index.js +9 -4
- package/dist/themeReader-DJKErl_j.d.ts +56 -0
- package/dist/xlsx/index.d.ts +6 -66
- package/dist/xlsx/index.js +4 -2
- package/dist/zipLimits-BOKCB7qk.d.ts +31 -0
- package/package.json +8 -2
- package/src/__tests__/container.test.ts +41 -0
- package/src/__tests__/convert.test.ts +310 -1
- 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 +76 -2
- package/src/__tests__/ooxmlCancellation.test.ts +113 -0
- 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 +37 -32
- 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 +23 -0
- package/src/infer/extract.ts +127 -0
- package/src/infer/index.ts +199 -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 +129 -29
- 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 +1222 -0
- package/src/registry/convert.ts +168 -53
- package/src/registry/defaultFormats.ts +135 -45
- package/src/registry/index.ts +6 -1
- package/src/registry/types.ts +69 -6
- package/src/shared/boundedZipArchive.ts +383 -0
- package/src/shared/fidelity.ts +130 -0
- package/src/shared/zipEntryCount.ts +151 -0
- package/src/shared/zipLimits.ts +296 -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 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { ThemeRegistry, Doc } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* HTML Template Generation for SquisqPlayer Exports
|
|
6
|
+
*
|
|
7
|
+
* Generates complete, self-contained HTML documents that load the SquisqPlayer
|
|
8
|
+
* IIFE bundle and render a Doc as either an interactive slideshow or a static
|
|
9
|
+
* scrollable document.
|
|
10
|
+
*
|
|
11
|
+
* Two variants:
|
|
12
|
+
* 1. **Inline** — All JS, CSS, and images are embedded in the HTML (single file).
|
|
13
|
+
* 2. **External** — JS is referenced via `<script src>`, images via relative paths.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface HtmlExportOptions {
|
|
17
|
+
/** The IIFE player bundle source code (from @bendyline/squisq-react/standalone-source) */
|
|
18
|
+
playerScript: string;
|
|
19
|
+
/**
|
|
20
|
+
* Map of relative image paths (as they appear in the Doc) to binary image data.
|
|
21
|
+
* For inline HTML export, these are converted to base64 data URIs.
|
|
22
|
+
* For ZIP export, these are written as separate files.
|
|
23
|
+
*/
|
|
24
|
+
images?: Map<string, ArrayBuffer>;
|
|
25
|
+
/**
|
|
26
|
+
* Map of audio segment identifiers to binary audio data.
|
|
27
|
+
* Keys should match the audio segment `name` or `url` fields in the Doc.
|
|
28
|
+
* Only used in ZIP exports — single HTML uses timer-based playback.
|
|
29
|
+
*/
|
|
30
|
+
audio?: Map<string, ArrayBuffer>;
|
|
31
|
+
/** Rendering mode: 'slideshow' (interactive, default) or 'static' (scrollable) */
|
|
32
|
+
mode?: 'slideshow' | 'static';
|
|
33
|
+
/** HTML page title (default: 'Squisq Document') */
|
|
34
|
+
title?: string;
|
|
35
|
+
/** Auto-play slideshow on load (default: false) */
|
|
36
|
+
autoPlay?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Squisq theme ID to apply (e.g., 'documentary', 'cinematic').
|
|
39
|
+
* When set, the theme is assigned to the Doc before rendering,
|
|
40
|
+
* so the SquisqPlayer renders with that theme's colors and typography.
|
|
41
|
+
*/
|
|
42
|
+
themeId?: string;
|
|
43
|
+
/** Explicit caller-owned registry for non-document custom themes. */
|
|
44
|
+
themeRegistry?: ThemeRegistry;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Collect all relative image paths referenced in a Doc's layers and template blocks.
|
|
48
|
+
* Returns a Set of unique relative paths that need to be resolved.
|
|
49
|
+
*/
|
|
50
|
+
declare function collectImagePaths(doc: Doc): Set<string>;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* HTML Import Module — @bendyline/squisq-formats/html
|
|
54
|
+
*
|
|
55
|
+
* Converts an HTML document (or fragment) into a squisq `MarkdownDocument`.
|
|
56
|
+
* Built on the existing `parseHtmlToNodes` (parse5-backed) + `sanitizeHtmlNodes`
|
|
57
|
+
* from `@bendyline/squisq/markdown`, so no new dependency is introduced.
|
|
58
|
+
*
|
|
59
|
+
* The primary consumer is email: HTML mail bodies are hostile input, so the
|
|
60
|
+
* parse is sanitized by default (scripts/styles/event handlers/dangerous URLs
|
|
61
|
+
* stripped) before the tree is walked into markdown nodes.
|
|
62
|
+
*
|
|
63
|
+
* Two entry points mirror the docx/pdf importers:
|
|
64
|
+
* - `htmlToMarkdownDoc(data, options?)` → `MarkdownDocument`
|
|
65
|
+
* - `htmlToMarkdown(html, options?)` → markdown string (convenience for the
|
|
66
|
+
* string-in/string-out path email body conversion needs)
|
|
67
|
+
*/
|
|
68
|
+
|
|
69
|
+
interface HtmlImportOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Strip scripts / styles / event handlers / dangerous URLs before walking
|
|
72
|
+
* the tree. Default `true` — HTML email is untrusted; only disable for
|
|
73
|
+
* trusted input where you want raw fidelity.
|
|
74
|
+
*/
|
|
75
|
+
sanitize?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** Parse HTML into a squisq `MarkdownDocument`. */
|
|
78
|
+
declare function htmlToMarkdownDocSync(html: string, options?: HtmlImportOptions): MarkdownDocument;
|
|
79
|
+
/** Async, ArrayBuffer-accepting entry mirroring docx/pdf importers. */
|
|
80
|
+
declare function htmlToMarkdownDoc(data: ArrayBuffer | Uint8Array | string, options?: HtmlImportOptions): Promise<MarkdownDocument>;
|
|
81
|
+
/** Convenience string→string conversion (used for email HTML bodies). */
|
|
82
|
+
declare function htmlToMarkdown(html: string, options?: HtmlImportOptions): string;
|
|
83
|
+
|
|
84
|
+
export { type HtmlExportOptions as H, type HtmlImportOptions as a, htmlToMarkdownDoc as b, collectImagePaths as c, htmlToMarkdownDocSync as d, htmlToMarkdown as h };
|
|
@@ -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-B9L8Ucbj.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,21 @@
|
|
|
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, PreparedConversion, PreparedExportOptions, convert, createRegistry, defaultFormats, defaultRegistry, prepareConversion } from './registry/index.js';
|
|
10
|
+
export { Z as ZipSafetyError, a as ZipSafetyErrorCode, b as ZipSafetyErrorOptions, c as ZipSafetyLimits } from './zipLimits-BOKCB7qk.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-K8mfc0fz.js';
|
|
13
|
+
export { X as XlsxExportOptions, a as XlsxImportOptions, d as docToXlsx, m as markdownDocToXlsx, x as xlsxToMarkdownDoc } from './export-D2NkylDT.js';
|
|
9
14
|
import '@bendyline/squisq/schemas';
|
|
10
15
|
import '@bendyline/squisq/markdown';
|
|
16
|
+
import './reader-B9L8Ucbj.js';
|
|
11
17
|
import '@bendyline/squisq/storage';
|
|
18
|
+
import './layouts-BHrgZ5FS.js';
|
|
19
|
+
import './themeReader-DJKErl_j.js';
|
|
20
|
+
import '@bendyline/squisq/transform';
|
|
21
|
+
import './container/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,45 @@
|
|
|
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
|
-
defaultRegistry
|
|
12
|
-
|
|
10
|
+
defaultRegistry,
|
|
11
|
+
prepareConversion
|
|
12
|
+
} from "./chunk-HTW2M27H.js";
|
|
13
|
+
import {
|
|
14
|
+
inferThemeFromFile
|
|
15
|
+
} from "./chunk-QRVN6A6E.js";
|
|
16
|
+
import {
|
|
17
|
+
ConversionError
|
|
18
|
+
} from "./chunk-ODL3SSPT.js";
|
|
19
|
+
import "./chunk-2KPARF2P.js";
|
|
20
|
+
import {
|
|
21
|
+
compileExtractedTheme
|
|
22
|
+
} from "./chunk-NKAJPJ4G.js";
|
|
13
23
|
import {
|
|
14
24
|
docToDocx,
|
|
15
25
|
docxToDoc,
|
|
16
26
|
docxToMarkdownDoc,
|
|
17
27
|
markdownDocToDocx
|
|
18
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-CRAVSMPZ.js";
|
|
19
29
|
import {
|
|
20
30
|
docToPptx,
|
|
21
31
|
markdownDocToPptx,
|
|
22
32
|
pptxToDoc,
|
|
23
33
|
pptxToMarkdownDoc
|
|
24
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-ABVI556T.js";
|
|
35
|
+
import "./chunk-VSYHZECT.js";
|
|
25
36
|
import "./chunk-6M7Z25LA.js";
|
|
26
37
|
import {
|
|
27
38
|
docToXlsx,
|
|
28
39
|
markdownDocToXlsx,
|
|
29
40
|
xlsxToDoc,
|
|
30
41
|
xlsxToMarkdownDoc
|
|
31
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-VJJM2SSH.js";
|
|
32
43
|
import "./chunk-PN52A5AA.js";
|
|
33
44
|
import {
|
|
34
45
|
csvToDoc,
|
|
@@ -36,15 +47,21 @@ import {
|
|
|
36
47
|
markdownDocToCsv,
|
|
37
48
|
parseCsv
|
|
38
49
|
} from "./chunk-RFAPOKHJ.js";
|
|
39
|
-
import "./chunk-
|
|
50
|
+
import "./chunk-XKUMNGBW.js";
|
|
51
|
+
import "./chunk-YRT7GQ5Y.js";
|
|
52
|
+
import "./chunk-U32AG3G3.js";
|
|
40
53
|
import "./chunk-U4MRIFKL.js";
|
|
54
|
+
import "./chunk-WC7WULGV.js";
|
|
55
|
+
import {
|
|
56
|
+
ZipSafetyError
|
|
57
|
+
} from "./chunk-FE6OJV6O.js";
|
|
41
58
|
import {
|
|
42
59
|
configurePdfWorker,
|
|
43
60
|
docToPdf,
|
|
44
61
|
markdownDocToPdf,
|
|
45
62
|
pdfToDoc,
|
|
46
63
|
pdfToMarkdownDoc
|
|
47
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-GVS2XXV6.js";
|
|
48
65
|
import "./chunk-SSUPBUF5.js";
|
|
49
66
|
import {
|
|
50
67
|
collectImagePaths,
|
|
@@ -53,13 +70,15 @@ import {
|
|
|
53
70
|
htmlToMarkdown,
|
|
54
71
|
htmlToMarkdownDoc,
|
|
55
72
|
htmlToMarkdownDocSync
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
73
|
+
} from "./chunk-LXYLOOST.js";
|
|
74
|
+
import "./chunk-MLX2BOJC.js";
|
|
75
|
+
import "./chunk-O3GVVND4.js";
|
|
59
76
|
export {
|
|
60
77
|
BUILTIN_FORMAT_IDS,
|
|
61
78
|
ConversionError,
|
|
79
|
+
ZipSafetyError,
|
|
62
80
|
collectImagePaths,
|
|
81
|
+
compileExtractedTheme,
|
|
63
82
|
configurePdfWorker,
|
|
64
83
|
convert,
|
|
65
84
|
createRegistry,
|
|
@@ -79,6 +98,7 @@ export {
|
|
|
79
98
|
htmlToMarkdown,
|
|
80
99
|
htmlToMarkdownDoc,
|
|
81
100
|
htmlToMarkdownDocSync,
|
|
101
|
+
inferThemeFromFile,
|
|
82
102
|
markdownDocToCsv,
|
|
83
103
|
markdownDocToDocx,
|
|
84
104
|
markdownDocToEpub,
|
|
@@ -90,6 +110,7 @@ export {
|
|
|
90
110
|
pdfToMarkdownDoc,
|
|
91
111
|
pptxToDoc,
|
|
92
112
|
pptxToMarkdownDoc,
|
|
113
|
+
prepareConversion,
|
|
93
114
|
xlsxToDoc,
|
|
94
115
|
xlsxToMarkdownDoc
|
|
95
116
|
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Theme, DeepPartial, CustomTemplateDefinition } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { a as OoxmlPackage, O as OoxmlOpenOptions } from '../reader-B9L8Ucbj.js';
|
|
3
|
+
import { O as OoxmlColorScheme, a as OoxmlFontScheme } from '../themeReader-DJKErl_j.js';
|
|
4
|
+
import { P as PptxColorHints } from '../layouts-BHrgZ5FS.js';
|
|
5
|
+
import '../zipLimits-BOKCB7qk.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-QRVN6A6E.js";
|
|
4
|
+
import "../chunk-ODL3SSPT.js";
|
|
5
|
+
import {
|
|
6
|
+
extractDocxTheme,
|
|
7
|
+
extractPptxTheme,
|
|
8
|
+
extractXlsxTheme
|
|
9
|
+
} from "../chunk-2KPARF2P.js";
|
|
10
|
+
import {
|
|
11
|
+
colorHintsFromExtraction,
|
|
12
|
+
compileExtractedTheme,
|
|
13
|
+
extractedThemeToPartial
|
|
14
|
+
} from "../chunk-NKAJPJ4G.js";
|
|
15
|
+
import "../chunk-XKUMNGBW.js";
|
|
16
|
+
import "../chunk-YRT7GQ5Y.js";
|
|
17
|
+
import "../chunk-WC7WULGV.js";
|
|
18
|
+
import "../chunk-FE6OJV6O.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":[]}
|