@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.
Files changed (139) hide show
  1. package/README.md +48 -2
  2. package/dist/{chunk-WWBIKRNP.js → chunk-2CSZJEAL.js} +13 -11
  3. package/dist/chunk-2CSZJEAL.js.map +1 -0
  4. package/dist/{chunk-RTS5XBZ7.js → chunk-2EFDWKC6.js} +262 -84
  5. package/dist/chunk-2EFDWKC6.js.map +1 -0
  6. package/dist/chunk-2PRVLAU3.js +740 -0
  7. package/dist/chunk-2PRVLAU3.js.map +1 -0
  8. package/dist/{chunk-SHLPSADL.js → chunk-4HJ6AK2Q.js} +54 -193
  9. package/dist/chunk-4HJ6AK2Q.js.map +1 -0
  10. package/dist/{chunk-5LSSWZPU.js → chunk-4VUWTSGM.js} +72 -25
  11. package/dist/chunk-4VUWTSGM.js.map +1 -0
  12. package/dist/{chunk-YESS7VY3.js → chunk-CVNVD7VH.js} +154 -39
  13. package/dist/chunk-CVNVD7VH.js.map +1 -0
  14. package/dist/chunk-CX3LH47J.js +99 -0
  15. package/dist/chunk-CX3LH47J.js.map +1 -0
  16. package/dist/{chunk-D7IFPWNZ.js → chunk-GVS2XXV6.js} +27 -26
  17. package/dist/chunk-GVS2XXV6.js.map +1 -0
  18. package/dist/chunk-H7T5DXUU.js +479 -0
  19. package/dist/chunk-H7T5DXUU.js.map +1 -0
  20. package/dist/{chunk-EHLGMSTE.js → chunk-HBSCRS5P.js} +10 -8
  21. package/dist/chunk-HBSCRS5P.js.map +1 -0
  22. package/dist/{chunk-46FMDOWZ.js → chunk-LXYLOOST.js} +49 -17
  23. package/dist/chunk-LXYLOOST.js.map +1 -0
  24. package/dist/{chunk-MJGRI6XR.js → chunk-MLX2BOJC.js} +12 -7
  25. package/dist/chunk-MLX2BOJC.js.map +1 -0
  26. package/dist/chunk-NKAJPJ4G.js +106 -0
  27. package/dist/chunk-NKAJPJ4G.js.map +1 -0
  28. package/dist/{chunk-DQAZR57U.js → chunk-O3GVVND4.js} +1 -1
  29. package/dist/chunk-ODL3SSPT.js +18 -0
  30. package/dist/chunk-ODL3SSPT.js.map +1 -0
  31. package/dist/chunk-X4USWOQ2.js +131 -0
  32. package/dist/chunk-X4USWOQ2.js.map +1 -0
  33. package/dist/chunk-XTLQXR4U.js +195 -0
  34. package/dist/chunk-XTLQXR4U.js.map +1 -0
  35. package/dist/chunk-YRT7GQ5Y.js +28 -0
  36. package/dist/chunk-YRT7GQ5Y.js.map +1 -0
  37. package/dist/chunk-ZZ7D4DN6.js +97 -0
  38. package/dist/chunk-ZZ7D4DN6.js.map +1 -0
  39. package/dist/container/index.d.ts +6 -2
  40. package/dist/container/index.js +15 -17
  41. package/dist/container/index.js.map +1 -1
  42. package/dist/docx/index.d.ts +6 -2
  43. package/dist/docx/index.js +5 -3
  44. package/dist/epub/index.d.ts +3 -1
  45. package/dist/epub/index.js +3 -3
  46. package/dist/export-Djev9BLU.d.ts +69 -0
  47. package/dist/extract-LNOA7DBK.js +15 -0
  48. package/dist/extract-LNOA7DBK.js.map +1 -0
  49. package/dist/html/index.d.ts +15 -85
  50. package/dist/html/index.js +3 -3
  51. package/dist/images-7FBWPKE3.js +7 -0
  52. package/dist/images-7FBWPKE3.js.map +1 -0
  53. package/dist/import-DTkDxHmZ.d.ts +84 -0
  54. package/dist/import-Yivc3kZM.d.ts +136 -0
  55. package/dist/index.d.ts +13 -4
  56. package/dist/index.js +30 -11
  57. package/dist/infer/index.d.ts +138 -0
  58. package/dist/infer/index.js +28 -0
  59. package/dist/infer/index.js.map +1 -0
  60. package/dist/layouts-7OUUVAGU.js +12 -0
  61. package/dist/layouts-7OUUVAGU.js.map +1 -0
  62. package/dist/layouts-CZ0bdsNL.d.ts +150 -0
  63. package/dist/mapTheme-IR27S6IV.js +11 -0
  64. package/dist/mapTheme-IR27S6IV.js.map +1 -0
  65. package/dist/ooxml/index.d.ts +21 -127
  66. package/dist/ooxml/index.js +31 -9
  67. package/dist/pdf/index.d.ts +3 -1
  68. package/dist/pdf/index.js +1 -1
  69. package/dist/pptx/index.d.ts +8 -108
  70. package/dist/pptx/index.js +13 -4
  71. package/dist/reader-Gof6OrJX.d.ts +140 -0
  72. package/dist/registry/index.d.ts +46 -8
  73. package/dist/registry/index.js +5 -2
  74. package/dist/themeReader-DPw4J5Ss.d.ts +56 -0
  75. package/dist/xlsx/index.d.ts +6 -66
  76. package/dist/xlsx/index.js +4 -2
  77. package/dist/zipLimits-bGYMS9cI.d.ts +29 -0
  78. package/package.json +8 -2
  79. package/src/__tests__/container.test.ts +41 -0
  80. package/src/__tests__/convert.test.ts +167 -0
  81. package/src/__tests__/epub.test.ts +102 -1
  82. package/src/__tests__/html.test.ts +62 -0
  83. package/src/__tests__/inferTheme.test.ts +135 -0
  84. package/src/__tests__/lossyWarnings.test.ts +41 -0
  85. package/src/__tests__/ooxml.test.ts +59 -2
  86. package/src/__tests__/ooxmlThemeReader.test.ts +92 -0
  87. package/src/__tests__/plainHtml.test.ts +15 -1
  88. package/src/__tests__/plainHtmlBundle.test.ts +18 -0
  89. package/src/__tests__/pptxImport.test.ts +30 -0
  90. package/src/__tests__/pptxInferFixtures.ts +314 -0
  91. package/src/__tests__/pptxLayoutInfer.test.ts +395 -0
  92. package/src/__tests__/zipSafety.test.ts +317 -0
  93. package/src/container/index.ts +20 -29
  94. package/src/docx/export.ts +4 -2
  95. package/src/docx/import.ts +4 -3
  96. package/src/epub/export.ts +94 -25
  97. package/src/html/docsHtmlBundle.ts +6 -2
  98. package/src/html/htmlTemplate.ts +31 -6
  99. package/src/html/imageUtils.ts +14 -5
  100. package/src/html/index.ts +12 -1
  101. package/src/html/plainHtml.ts +7 -3
  102. package/src/html/plainHtmlBundle.ts +11 -9
  103. package/src/index.ts +20 -0
  104. package/src/infer/extract.ts +127 -0
  105. package/src/infer/index.ts +168 -0
  106. package/src/infer/mapTheme.ts +176 -0
  107. package/src/infer/types.ts +27 -0
  108. package/src/ooxml/index.ts +14 -0
  109. package/src/ooxml/readUtils.ts +44 -0
  110. package/src/ooxml/reader.ts +87 -28
  111. package/src/ooxml/themeReader.ts +197 -0
  112. package/src/ooxml/types.ts +8 -9
  113. package/src/ooxml/writer.ts +28 -10
  114. package/src/pdf/export.ts +4 -2
  115. package/src/pdf/import.ts +40 -34
  116. package/src/pptx/export.ts +4 -2
  117. package/src/pptx/import.ts +214 -32
  118. package/src/pptx/index.ts +14 -0
  119. package/src/pptx/layouts.ts +1168 -0
  120. package/src/registry/convert.ts +54 -23
  121. package/src/registry/defaultFormats.ts +131 -44
  122. package/src/registry/index.ts +3 -0
  123. package/src/registry/types.ts +52 -6
  124. package/src/shared/boundedZipArchive.ts +342 -0
  125. package/src/shared/fidelity.ts +130 -0
  126. package/src/shared/zipEntryCount.ts +97 -0
  127. package/src/shared/zipLimits.ts +286 -0
  128. package/src/shared/zipSafety.ts +19 -0
  129. package/src/xlsx/import.ts +3 -2
  130. package/dist/chunk-46FMDOWZ.js.map +0 -1
  131. package/dist/chunk-5LSSWZPU.js.map +0 -1
  132. package/dist/chunk-D7IFPWNZ.js.map +0 -1
  133. package/dist/chunk-EHLGMSTE.js.map +0 -1
  134. package/dist/chunk-MJGRI6XR.js.map +0 -1
  135. package/dist/chunk-RTS5XBZ7.js.map +0 -1
  136. package/dist/chunk-SHLPSADL.js.map +0 -1
  137. package/dist/chunk-WWBIKRNP.js.map +0 -1
  138. package/dist/chunk-YESS7VY3.js.map +0 -1
  139. /package/dist/{chunk-DQAZR57U.js.map → chunk-O3GVVND4.js.map} +0 -0
@@ -1,138 +1,32 @@
1
- import JSZip from 'jszip';
1
+ import { R as Relationship, C as CoreProperties } from '../reader-Gof6OrJX.js';
2
+ export { b as ContentTypeMap, O as OoxmlOpenOptions, a as OoxmlPackage, P as PackagePart, c as PendingRelationship, g as getCoreProperties, d as getPartBinary, e as getPartRelationships, f as getPartXml, o as openPackage } from '../reader-Gof6OrJX.js';
3
+ export { Z as ZipSafetyError, a as ZipSafetyErrorCode, b as ZipSafetyErrorOptions, c as ZipSafetyLimits } from '../zipLimits-bGYMS9cI.js';
4
+ export { O as OoxmlColorScheme, a as OoxmlFontScheme, b as OoxmlTheme, p as parseThemeXml, r as readThemePart } from '../themeReader-DPw4J5Ss.js';
2
5
 
3
6
  /**
4
- * OOXML Types
7
+ * Shared DOM-read helpers for OOXML importers.
5
8
  *
6
- * Shared type definitions for all Office Open XML formats (DOCX, PPTX, XLSX).
7
- * These model the common structural elements of the OOXML package format:
8
- * ZIP archive, relationships, content types, and core properties.
9
+ * Every importer walks parts with `getElementsByTagNameNS` and resolves
10
+ * relationship targets relative to the referencing part; these helpers hold
11
+ * the common pieces so new readers (theme, slide layouts) don't re-implement
12
+ * them per format.
9
13
  */
10
14
 
11
15
  /**
12
- * An opened OOXML package wraps the JSZip archive plus parsed
13
- * structural metadata (content types, root relationships).
16
+ * Read a namespaced attribute with a qualified-name fallback for documents
17
+ * whose producer omitted the namespace declaration (e.g. `r:id`).
14
18
  */
15
- interface OoxmlPackage {
16
- /** The underlying JSZip archive */
17
- zip: JSZip;
18
- /** Parsed [Content_Types].xml entries */
19
- contentTypes: ContentTypeMap;
20
- /** Root-level relationships (_rels/.rels) */
21
- rootRelationships: Relationship[];
22
- }
23
- /**
24
- * Content type map built from [Content_Types].xml.
25
- * Maps part paths → content type strings plus extension defaults.
26
- */
27
- interface ContentTypeMap {
28
- /** Explicit overrides: partName → contentType */
29
- overrides: Map<string, string>;
30
- /** Default extensions: extension → contentType */
31
- defaults: Map<string, string>;
32
- }
33
- /**
34
- * An OOXML relationship entry (from any _rels/*.rels file).
35
- */
36
- interface Relationship {
37
- /** Relationship ID (e.g., "rId1") */
38
- id: string;
39
- /** Relationship type URI (e.g., "http://...officedocument/...") */
40
- type: string;
41
- /** Target path or URL */
42
- target: string;
43
- /** "Internal" (default) or "External" for hyperlinks */
44
- targetMode?: 'Internal' | 'External';
45
- }
46
- /**
47
- * Document core properties from docProps/core.xml (Dublin Core metadata).
48
- */
49
- interface CoreProperties {
50
- title?: string;
51
- subject?: string;
52
- creator?: string;
53
- keywords?: string;
54
- description?: string;
55
- lastModifiedBy?: string;
56
- revision?: string;
57
- created?: string;
58
- modified?: string;
59
- }
60
- /**
61
- * A part (file) that will be written into an OOXML package.
62
- */
63
- interface PackagePart {
64
- /** Path within the ZIP (e.g., "word/document.xml") */
65
- path: string;
66
- /** XML or text content (mutually exclusive with binaryContent) */
67
- content?: string;
68
- /** Binary content (mutually exclusive with content) */
69
- binaryContent?: ArrayBuffer | Uint8Array;
70
- /** MIME content type for [Content_Types].xml */
71
- contentType: string;
72
- }
73
- /**
74
- * A relationship to be written into a _rels/*.rels file.
75
- * `sourcePart` identifies which part the relationship belongs to.
76
- * Use "" (empty string) for root-level relationships (_rels/.rels).
77
- */
78
- interface PendingRelationship {
79
- /** The part this relationship belongs to ("" for root) */
80
- sourcePart: string;
81
- /** The relationship entry */
82
- relationship: Relationship;
83
- }
84
-
85
- /**
86
- * OOXML Package Reader
87
- *
88
- * Opens OOXML archives (.docx, .pptx, .xlsx) and parses their
89
- * structural metadata: [Content_Types].xml, relationships, and
90
- * core properties.
91
- *
92
- * Uses JSZip to unzip and the browser's DOMParser to parse XML.
93
- */
94
-
95
- /**
96
- * Open an OOXML package from raw data.
97
- *
98
- * Parses the ZIP archive, [Content_Types].xml, and root relationships.
99
- *
100
- * @param data - The raw .docx/.pptx/.xlsx file as ArrayBuffer or Blob
101
- * @returns A parsed OoxmlPackage
102
- */
103
- declare function openPackage(data: ArrayBuffer | Blob): Promise<OoxmlPackage>;
104
- /**
105
- * Parse relationships for a specific part.
106
- *
107
- * @param pkg - The OOXML package (or the zip directly)
108
- * @param partPath - The part path (e.g., "word/document.xml").
109
- * Use "" for root-level relationships (_rels/.rels).
110
- * @returns Array of relationship entries
111
- */
112
- declare function getPartRelationships(pkg: OoxmlPackage, partPath: string): Promise<Relationship[]>;
113
- /**
114
- * Extract an XML part from the package and parse it as a DOM Document.
115
- *
116
- * @param pkg - The OOXML package
117
- * @param partPath - Path within the archive (e.g., "word/document.xml")
118
- * @returns Parsed XML Document, or null if the part doesn't exist
119
- */
120
- declare function getPartXml(pkg: OoxmlPackage, partPath: string): Promise<Document | null>;
19
+ declare function attrNS(el: Element, ns: string, local: string, qualified: string): string | null;
20
+ /** Directory portion of a part path, e.g. `ppt/slides/slide1.xml` → `ppt/slides`. */
21
+ declare function baseDirOf(path: string): string;
121
22
  /**
122
- * Extract a binary part from the package (e.g., an image from word/media/).
123
- *
124
- * @param pkg - The OOXML package
125
- * @param partPath - Path within the archive
126
- * @returns The binary content, or null if the part doesn't exist
127
- */
128
- declare function getPartBinary(pkg: OoxmlPackage, partPath: string): Promise<ArrayBuffer | null>;
129
- /**
130
- * Parse core document properties from docProps/core.xml.
131
- *
132
- * @param pkg - The OOXML package
133
- * @returns Parsed core properties (all fields optional)
23
+ * Resolve a relationship target against the referencing part's directory.
24
+ * Absolute targets (leading `/`) are package-rooted; relative targets may
25
+ * climb with `..` segments (e.g. `../slideLayouts/slideLayout1.xml`).
134
26
  */
135
- declare function getCoreProperties(pkg: OoxmlPackage): Promise<CoreProperties>;
27
+ declare function resolveTarget(baseDir: string, target: string): string;
28
+ /** First relationship of the given type, if any. */
29
+ declare function findRelByType(rels: Relationship[], type: string): Relationship | undefined;
136
30
 
137
31
  /**
138
32
  * OOXML Package Writer
@@ -362,4 +256,4 @@ declare const CONTENT_TYPE_XLSX_STYLES = "application/vnd.openxmlformats-officed
362
256
  /** Relationship type: Worksheet */
363
257
  declare const REL_WORKSHEET = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet";
364
258
 
365
- export { CONTENT_TYPE_CORE_PROPERTIES, CONTENT_TYPE_DOCX_DOCUMENT, CONTENT_TYPE_DOCX_FONT_TABLE, CONTENT_TYPE_DOCX_FOOTNOTES, CONTENT_TYPE_DOCX_NUMBERING, CONTENT_TYPE_DOCX_SETTINGS, CONTENT_TYPE_DOCX_STYLES, CONTENT_TYPE_PPTX_PRESENTATION, CONTENT_TYPE_PPTX_SLIDE, CONTENT_TYPE_PPTX_SLIDE_LAYOUT, CONTENT_TYPE_PPTX_SLIDE_MASTER, CONTENT_TYPE_PPTX_THEME, CONTENT_TYPE_RELATIONSHIPS, CONTENT_TYPE_XLSX_STYLES, CONTENT_TYPE_XLSX_WORKBOOK, CONTENT_TYPE_XLSX_WORKSHEET, type ContentTypeMap, type CoreProperties, NS_CONTENT_TYPES, NS_CORE_PROPERTIES, NS_DC, NS_DCTERMS, NS_DRAWINGML, NS_MC, NS_PICTURE, NS_PML, NS_R, NS_RELATIONSHIPS, NS_SML, NS_WML, NS_WP_DRAWING, NS_XSI, type OoxmlPackage, type OoxmlPackageBuilder, type PackagePart, type PendingRelationship, REL_CORE_PROPERTIES, REL_EXTENDED_PROPERTIES, REL_FONT_TABLE, REL_FOOTNOTES, REL_HYPERLINK, REL_IMAGE, REL_NUMBERING, REL_OFFICE_DOCUMENT, REL_SETTINGS, REL_SLIDE, REL_SLIDE_LAYOUT, REL_SLIDE_MASTER, REL_STYLES, REL_THEME, REL_WORKSHEET, type Relationship, attrString, createPackage, escapeXml, getCoreProperties, getPartBinary, getPartRelationships, getPartXml, openPackage, selfClosingElement, textElement, xmlDeclaration, xmlElement };
259
+ export { CONTENT_TYPE_CORE_PROPERTIES, CONTENT_TYPE_DOCX_DOCUMENT, CONTENT_TYPE_DOCX_FONT_TABLE, CONTENT_TYPE_DOCX_FOOTNOTES, CONTENT_TYPE_DOCX_NUMBERING, CONTENT_TYPE_DOCX_SETTINGS, CONTENT_TYPE_DOCX_STYLES, CONTENT_TYPE_PPTX_PRESENTATION, CONTENT_TYPE_PPTX_SLIDE, CONTENT_TYPE_PPTX_SLIDE_LAYOUT, CONTENT_TYPE_PPTX_SLIDE_MASTER, CONTENT_TYPE_PPTX_THEME, CONTENT_TYPE_RELATIONSHIPS, CONTENT_TYPE_XLSX_STYLES, CONTENT_TYPE_XLSX_WORKBOOK, CONTENT_TYPE_XLSX_WORKSHEET, CoreProperties, NS_CONTENT_TYPES, NS_CORE_PROPERTIES, NS_DC, NS_DCTERMS, NS_DRAWINGML, NS_MC, NS_PICTURE, NS_PML, NS_R, NS_RELATIONSHIPS, NS_SML, NS_WML, NS_WP_DRAWING, NS_XSI, type OoxmlPackageBuilder, REL_CORE_PROPERTIES, REL_EXTENDED_PROPERTIES, REL_FONT_TABLE, REL_FOOTNOTES, REL_HYPERLINK, REL_IMAGE, REL_NUMBERING, REL_OFFICE_DOCUMENT, REL_SETTINGS, REL_SLIDE, REL_SLIDE_LAYOUT, REL_SLIDE_MASTER, REL_STYLES, REL_THEME, REL_WORKSHEET, Relationship, attrNS, attrString, baseDirOf, createPackage, escapeXml, findRelByType, resolveTarget, selfClosingElement, textElement, xmlDeclaration, xmlElement };
@@ -1,3 +1,24 @@
1
+ import {
2
+ parseThemeXml,
3
+ readThemePart
4
+ } from "../chunk-X4USWOQ2.js";
5
+ import {
6
+ attrNS,
7
+ baseDirOf,
8
+ findRelByType,
9
+ resolveTarget
10
+ } from "../chunk-YRT7GQ5Y.js";
11
+ import {
12
+ createPackage
13
+ } from "../chunk-XTLQXR4U.js";
14
+ import {
15
+ attrString,
16
+ escapeXml,
17
+ selfClosingElement,
18
+ textElement,
19
+ xmlDeclaration,
20
+ xmlElement
21
+ } from "../chunk-U4MRIFKL.js";
1
22
  import {
2
23
  CONTENT_TYPE_CORE_PROPERTIES,
3
24
  CONTENT_TYPE_DOCX_DOCUMENT,
@@ -44,21 +65,15 @@ import {
44
65
  REL_STYLES,
45
66
  REL_THEME,
46
67
  REL_WORKSHEET,
47
- createPackage,
48
68
  getCoreProperties,
49
69
  getPartBinary,
50
70
  getPartRelationships,
51
71
  getPartXml,
52
72
  openPackage
53
- } from "../chunk-SHLPSADL.js";
73
+ } from "../chunk-4HJ6AK2Q.js";
54
74
  import {
55
- attrString,
56
- escapeXml,
57
- selfClosingElement,
58
- textElement,
59
- xmlDeclaration,
60
- xmlElement
61
- } from "../chunk-U4MRIFKL.js";
75
+ ZipSafetyError
76
+ } from "../chunk-H7T5DXUU.js";
62
77
  export {
63
78
  CONTENT_TYPE_CORE_PROPERTIES,
64
79
  CONTENT_TYPE_DOCX_DOCUMENT,
@@ -105,14 +120,21 @@ export {
105
120
  REL_STYLES,
106
121
  REL_THEME,
107
122
  REL_WORKSHEET,
123
+ ZipSafetyError,
124
+ attrNS,
108
125
  attrString,
126
+ baseDirOf,
109
127
  createPackage,
110
128
  escapeXml,
129
+ findRelByType,
111
130
  getCoreProperties,
112
131
  getPartBinary,
113
132
  getPartRelationships,
114
133
  getPartXml,
115
134
  openPackage,
135
+ parseThemeXml,
136
+ readThemePart,
137
+ resolveTarget,
116
138
  selfClosingElement,
117
139
  textElement,
118
140
  xmlDeclaration,
@@ -1,4 +1,4 @@
1
- import { Doc } from '@bendyline/squisq/schemas';
1
+ import { ThemeRegistry, Doc } from '@bendyline/squisq/schemas';
2
2
  import { MarkdownDocument } from '@bendyline/squisq/markdown';
3
3
  import { ContentContainer } from '@bendyline/squisq/storage';
4
4
 
@@ -45,6 +45,8 @@ interface PdfExportOptions {
45
45
  * Font changes are not supported (pdf-lib uses standard 14 PDF fonts only).
46
46
  */
47
47
  themeId?: string;
48
+ /** Explicit caller-owned registry for non-document custom themes. */
49
+ themeRegistry?: ThemeRegistry;
48
50
  }
49
51
  /**
50
52
  * Convert a MarkdownDocument to a PDF ArrayBuffer.
package/dist/pdf/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  pdfToContainer,
6
6
  pdfToDoc,
7
7
  pdfToMarkdownDoc
8
- } from "../chunk-D7IFPWNZ.js";
8
+ } from "../chunk-GVS2XXV6.js";
9
9
  import "../chunk-SSUPBUF5.js";
10
10
  export {
11
11
  configurePdfWorker,
@@ -1,111 +1,11 @@
1
+ import { a as PptxImportOptions } from '../import-Yivc3kZM.js';
2
+ export { P as PptxExportOptions, d as docToPptx, m as markdownDocToPptx, b as pptxToContainer, p as pptxToMarkdownDoc } from '../import-Yivc3kZM.js';
1
3
  import { Doc } from '@bendyline/squisq/schemas';
2
- import { MarkdownDocument } from '@bendyline/squisq/markdown';
3
- import { ContentContainer } from '@bendyline/squisq/storage';
4
-
5
- /**
6
- * PPTX Export
7
- *
8
- * Converts a squisq MarkdownDocument (or Doc) into a .pptx file
9
- * by generating PresentationML + DrawingML XML and assembling the
10
- * OOXML package.
11
- *
12
- * Slide segmentation: each H1 or H2 heading starts a new slide.
13
- * The heading becomes the slide title; content below becomes the body.
14
- *
15
- * Supports:
16
- * - Theme-based styling (background, text colors, fonts from squisq themes)
17
- * - Image embedding (pass images as ArrayBuffers via options)
18
- * - Inline formatting (bold, italic, strikethrough, code, links)
19
- * - Lists, code blocks, blockquotes, tables, math
20
- *
21
- * No third-party pptx library — all XML is generated directly using
22
- * the shared ooxml/ infrastructure.
23
- *
24
- * @example
25
- * ```ts
26
- * import { parseMarkdown } from '@bendyline/squisq/markdown';
27
- * import { markdownDocToPptx } from '@bendyline/squisq-formats/pptx';
28
- *
29
- * const md = parseMarkdown('# Slide 1\n\nHello world\n\n## Slide 2\n\nMore content');
30
- * const blob = await markdownDocToPptx(md, { themeId: 'documentary' });
31
- * ```
32
- */
33
-
34
- /**
35
- * Options for PPTX export.
36
- */
37
- interface PptxExportOptions {
38
- /** Presentation title (appears in core properties) */
39
- title?: string;
40
- /** Presentation author */
41
- author?: string;
42
- /** Presentation description */
43
- description?: string;
44
- /**
45
- * Which heading depth triggers a new slide.
46
- * - `'h1'` — only H1 headings start slides
47
- * - `'h2'` — H1 and H2 headings start slides (default)
48
- * - `'heading'` — any heading (H1–H6) starts a slide
49
- */
50
- slideBreak?: 'h1' | 'h2' | 'heading';
51
- /** Default body font family. Default: "Calibri" */
52
- defaultFont?: string;
53
- /** Default body font size in points. Default: 18 */
54
- defaultFontSize?: number;
55
- /**
56
- * Squisq theme ID to apply (e.g., 'documentary', 'cinematic', 'bold').
57
- * Controls slide background, text colors, and fonts.
58
- * Falls back to the document's frontmatter `themeId` if not set here.
59
- */
60
- themeId?: string;
61
- /**
62
- * Image data keyed by the path/URL used in markdown.
63
- * When provided, images are embedded as picture shapes instead of
64
- * showing `[Image: alt]` placeholders.
65
- */
66
- images?: Map<string, ArrayBuffer>;
67
- }
68
- /**
69
- * Convert a MarkdownDocument to a .pptx ArrayBuffer.
70
- */
71
- declare function markdownDocToPptx(doc: MarkdownDocument, options?: PptxExportOptions): Promise<ArrayBuffer>;
72
- /**
73
- * Convert a squisq Doc to a .pptx ArrayBuffer.
74
- *
75
- * Convenience wrapper: Doc -> MarkdownDocument -> PPTX.
76
- */
77
- declare function docToPptx(doc: Doc, options?: PptxExportOptions): Promise<ArrayBuffer>;
78
-
79
- /**
80
- * PPTX import — PresentationML (.pptx) → MarkdownDocument.
81
- *
82
- * Reuses the shared ooxml/ reader. Reads slide order from
83
- * `ppt/presentation.xml` (`<p:sldIdLst>`), resolves each slide part via
84
- * relationships, and converts each slide to: an H2 of the title placeholder
85
- * (or "Slide N"), the remaining text as a bullet list, and any slide tables
86
- * (`<a:tbl>`) as markdown tables. Text lives in the DrawingML namespace
87
- * (`a:p` / `a:r` / `a:t`) inside PresentationML shapes (`p:sp`).
88
- */
89
-
90
- interface PptxImportOptions {
91
- /**
92
- * Whether to extract embedded slide images into the document as image nodes
93
- * (referencing `images/imageN.ext`). When false, pictures are ignored so the
94
- * markdown never carries dangling image references with no backing container.
95
- * `pptxToContainer` forces this on. Default: false.
96
- */
97
- extractImages?: boolean;
98
- }
99
- declare function pptxToMarkdownDoc(data: ArrayBuffer | Blob, options?: PptxImportOptions): Promise<MarkdownDocument>;
100
- /**
101
- * Convert a .pptx file to a ContentContainer with markdown + extracted images.
102
- *
103
- * The container holds the primary markdown document plus every embedded slide
104
- * image under `images/` (e.g. `images/image1.png`). Image extraction is always
105
- * forced on here so the markdown's image references resolve inside the
106
- * container. Mirrors `docxToContainer`.
107
- */
108
- declare function pptxToContainer(data: ArrayBuffer | Blob, options?: PptxImportOptions): Promise<ContentContainer>;
4
+ export { A as AnalyzePptxLayoutsOptions, a as AnalyzedLayout, E as ExtractedPlaceholder, b as ExtractedSlideLayout, I as InspectPptxLayoutsOptions, L as LayoutVerdict, P as PptxColorHints, c as PptxLayoutInference, d as PptxLayoutSummary, e as analyzePptxLayouts, i as inspectPptxLayouts } from '../layouts-CZ0bdsNL.js';
5
+ import '@bendyline/squisq/markdown';
6
+ import '../reader-Gof6OrJX.js';
7
+ import '../zipLimits-bGYMS9cI.js';
8
+ import '@bendyline/squisq/storage';
109
9
 
110
10
  /**
111
11
  * @bendyline/squisq-formats PPTX Module
@@ -129,4 +29,4 @@ declare function pptxToContainer(data: ArrayBuffer | Blob, options?: PptxImportO
129
29
  */
130
30
  declare function pptxToDoc(data: ArrayBuffer | Blob, options?: PptxImportOptions): Promise<Doc>;
131
31
 
132
- export { type PptxExportOptions, type PptxImportOptions, docToPptx, markdownDocToPptx, pptxToContainer, pptxToDoc, pptxToMarkdownDoc };
32
+ export { PptxImportOptions, pptxToDoc };
@@ -4,16 +4,25 @@ import {
4
4
  pptxToContainer,
5
5
  pptxToDoc,
6
6
  pptxToMarkdownDoc
7
- } from "../chunk-YESS7VY3.js";
7
+ } from "../chunk-CVNVD7VH.js";
8
+ import {
9
+ analyzePptxLayouts,
10
+ inspectPptxLayouts
11
+ } from "../chunk-2PRVLAU3.js";
8
12
  import "../chunk-6M7Z25LA.js";
9
13
  import "../chunk-PN52A5AA.js";
10
- import "../chunk-SHLPSADL.js";
14
+ import "../chunk-YRT7GQ5Y.js";
15
+ import "../chunk-XTLQXR4U.js";
11
16
  import "../chunk-U4MRIFKL.js";
17
+ import "../chunk-4HJ6AK2Q.js";
18
+ import "../chunk-H7T5DXUU.js";
12
19
  import "../chunk-SSUPBUF5.js";
13
- import "../chunk-MJGRI6XR.js";
14
- import "../chunk-DQAZR57U.js";
20
+ import "../chunk-MLX2BOJC.js";
21
+ import "../chunk-O3GVVND4.js";
15
22
  export {
23
+ analyzePptxLayouts,
16
24
  docToPptx,
25
+ inspectPptxLayouts,
17
26
  markdownDocToPptx,
18
27
  pptxToContainer,
19
28
  pptxToDoc,
@@ -0,0 +1,140 @@
1
+ import { c as ZipSafetyLimits } from './zipLimits-bGYMS9cI.js';
2
+
3
+ /**
4
+ * OOXML Types
5
+ *
6
+ * Shared type definitions for all Office Open XML formats (DOCX, PPTX, XLSX).
7
+ * These model the common structural elements of the OOXML package format:
8
+ * relationships, content types, and core properties.
9
+ */
10
+ /**
11
+ * An opened OOXML package. Instances are created only by `openPackage`; the
12
+ * archive remains private so every part read goes through the bounded reader.
13
+ */
14
+ declare const ooxmlPackageBrand: unique symbol;
15
+ interface OoxmlPackage {
16
+ /** Nominal brand: callers cannot manually construct a safety-bypassing package. */
17
+ readonly [ooxmlPackageBrand]: never;
18
+ /** Parsed [Content_Types].xml entries */
19
+ readonly contentTypes: ContentTypeMap;
20
+ /** Root-level relationships (_rels/.rels) */
21
+ readonly rootRelationships: readonly Relationship[];
22
+ }
23
+ /**
24
+ * Content type map built from [Content_Types].xml.
25
+ * Maps part paths → content type strings plus extension defaults.
26
+ */
27
+ interface ContentTypeMap {
28
+ /** Explicit overrides: partName → contentType */
29
+ overrides: Map<string, string>;
30
+ /** Default extensions: extension → contentType */
31
+ defaults: Map<string, string>;
32
+ }
33
+ /**
34
+ * An OOXML relationship entry (from any _rels/*.rels file).
35
+ */
36
+ interface Relationship {
37
+ /** Relationship ID (e.g., "rId1") */
38
+ id: string;
39
+ /** Relationship type URI (e.g., "http://...officedocument/...") */
40
+ type: string;
41
+ /** Target path or URL */
42
+ target: string;
43
+ /** "Internal" (default) or "External" for hyperlinks */
44
+ targetMode?: 'Internal' | 'External';
45
+ }
46
+ /**
47
+ * Document core properties from docProps/core.xml (Dublin Core metadata).
48
+ */
49
+ interface CoreProperties {
50
+ title?: string;
51
+ subject?: string;
52
+ creator?: string;
53
+ keywords?: string;
54
+ description?: string;
55
+ lastModifiedBy?: string;
56
+ revision?: string;
57
+ created?: string;
58
+ modified?: string;
59
+ }
60
+ /**
61
+ * A part (file) that will be written into an OOXML package.
62
+ */
63
+ interface PackagePart {
64
+ /** Path within the ZIP (e.g., "word/document.xml") */
65
+ path: string;
66
+ /** XML or text content (mutually exclusive with binaryContent) */
67
+ content?: string;
68
+ /** Binary content (mutually exclusive with content) */
69
+ binaryContent?: ArrayBuffer | Uint8Array;
70
+ /** MIME content type for [Content_Types].xml */
71
+ contentType: string;
72
+ }
73
+ /**
74
+ * A relationship to be written into a _rels/*.rels file.
75
+ * `sourcePart` identifies which part the relationship belongs to.
76
+ * Use "" (empty string) for root-level relationships (_rels/.rels).
77
+ */
78
+ interface PendingRelationship {
79
+ /** The part this relationship belongs to ("" for root) */
80
+ sourcePart: string;
81
+ /** The relationship entry */
82
+ relationship: Relationship;
83
+ }
84
+
85
+ /**
86
+ * OOXML Package Reader
87
+ *
88
+ * Opens OOXML archives (.docx, .pptx, .xlsx) and parses their
89
+ * structural metadata: [Content_Types].xml, relationships, and
90
+ * core properties.
91
+ *
92
+ * Uses bounded JSZip member streams and a platform DOMParser (with an xmldom
93
+ * fallback in bare Node/SSR) to parse XML.
94
+ */
95
+
96
+ type OoxmlOpenOptions = ZipSafetyLimits;
97
+ /**
98
+ * Open an OOXML package from raw data.
99
+ *
100
+ * Parses the ZIP archive, [Content_Types].xml, and root relationships.
101
+ *
102
+ * @param data - The raw .docx/.pptx/.xlsx file as ArrayBuffer or Blob
103
+ * @param limits - Optional archive count, size, and compression-ratio limits
104
+ * @returns A parsed OoxmlPackage
105
+ */
106
+ declare function openPackage(data: ArrayBuffer | Blob, limits?: OoxmlOpenOptions): Promise<OoxmlPackage>;
107
+ /**
108
+ * Parse relationships for a specific part.
109
+ *
110
+ * @param pkg - The OOXML package (or the zip directly)
111
+ * @param partPath - The part path (e.g., "word/document.xml").
112
+ * Use "" for root-level relationships (_rels/.rels).
113
+ * @returns Array of relationship entries
114
+ */
115
+ declare function getPartRelationships(pkg: OoxmlPackage, partPath: string): Promise<Relationship[]>;
116
+ /**
117
+ * Extract an XML part from the package and parse it as a DOM Document.
118
+ *
119
+ * @param pkg - The OOXML package
120
+ * @param partPath - Path within the archive (e.g., "word/document.xml")
121
+ * @returns Parsed XML Document, or null if the part doesn't exist
122
+ */
123
+ declare function getPartXml(pkg: OoxmlPackage, partPath: string): Promise<Document | null>;
124
+ /**
125
+ * Extract a binary part from the package (e.g., an image from word/media/).
126
+ *
127
+ * @param pkg - The OOXML package
128
+ * @param partPath - Path within the archive
129
+ * @returns The binary content, or null if the part doesn't exist
130
+ */
131
+ declare function getPartBinary(pkg: OoxmlPackage, partPath: string): Promise<ArrayBuffer | null>;
132
+ /**
133
+ * Parse core document properties from docProps/core.xml.
134
+ *
135
+ * @param pkg - The OOXML package
136
+ * @returns Parsed core properties (all fields optional)
137
+ */
138
+ declare function getCoreProperties(pkg: OoxmlPackage): Promise<CoreProperties>;
139
+
140
+ export { type CoreProperties as C, type OoxmlOpenOptions as O, type PackagePart as P, type Relationship as R, type OoxmlPackage as a, type ContentTypeMap as b, type PendingRelationship as c, getPartBinary as d, getPartRelationships as e, getPartXml as f, getCoreProperties as g, openPackage as o };
@@ -1,6 +1,16 @@
1
- import { Doc } from '@bendyline/squisq/schemas';
2
- import { MarkdownDocument } from '@bendyline/squisq/markdown';
1
+ import { Doc, ThemeRegistry } from '@bendyline/squisq/schemas';
2
+ import { TransformStyleInput, TransformStyleRegistry } from '@bendyline/squisq/transform';
3
+ import { ParseOptions, StringifyOptions, MarkdownDocument } from '@bendyline/squisq/markdown';
3
4
  import { ContentContainer } from '@bendyline/squisq/storage';
5
+ import { DocxImportOptions, DocxExportOptions } from '../docx/index.js';
6
+ import { a as PptxImportOptions, P as PptxExportOptions } from '../import-Yivc3kZM.js';
7
+ import { a as XlsxImportOptions, X as XlsxExportOptions } from '../export-Djev9BLU.js';
8
+ import { CsvImportOptions, CsvExportOptions } from '../csv/index.js';
9
+ import { PdfImportOptions, PdfExportOptions } from '../pdf/index.js';
10
+ import { a as HtmlImportOptions, H as HtmlExportOptions } from '../import-DTkDxHmZ.js';
11
+ import { EpubExportOptions } from '../epub/index.js';
12
+ import { c as ZipSafetyLimits } from '../zipLimits-bGYMS9cI.js';
13
+ import '../reader-Gof6OrJX.js';
4
14
 
5
15
  /**
6
16
  * Format registry — shared types.
@@ -27,6 +37,30 @@ interface ConversionResult {
27
37
  /** Non-fatal notes accumulated during conversion (may be empty). */
28
38
  warnings: string[];
29
39
  }
40
+ interface MarkdownFormatOptions {
41
+ parse?: ParseOptions;
42
+ stringify?: StringifyOptions;
43
+ }
44
+ /** Resource limits applied when importing a DBK/ZIP container. */
45
+ type DbkFormatOptions = ZipSafetyLimits;
46
+ /**
47
+ * Strongly typed option bags for built-in formats. Import and export options
48
+ * share a bag because a single conversion may use the format on either side.
49
+ * Custom registries may add arbitrary keys through the intersection used by
50
+ * {@link ConvertOptions.formatOptions}.
51
+ */
52
+ interface BuiltinFormatOptions {
53
+ md: MarkdownFormatOptions;
54
+ docx: DocxImportOptions & DocxExportOptions;
55
+ pptx: PptxImportOptions & PptxExportOptions;
56
+ xlsx: XlsxImportOptions & XlsxExportOptions;
57
+ csv: CsvImportOptions & CsvExportOptions;
58
+ pdf: PdfImportOptions & PdfExportOptions;
59
+ html: HtmlImportOptions & Partial<Omit<HtmlExportOptions, 'playerScript'>>;
60
+ htmlzip: Partial<Omit<HtmlExportOptions, 'playerScript'>>;
61
+ epub: EpubExportOptions;
62
+ dbk: DbkFormatOptions;
63
+ }
30
64
  /**
31
65
  * A source normalized into every shape an exporter might need. `doc` is always
32
66
  * present; `markdownDoc` is present when the source was markdown-shaped (an
@@ -46,16 +80,20 @@ interface ConvertOptions {
46
80
  from?: FormatId;
47
81
  /** Theme id to apply to the exported document. */
48
82
  themeId?: string;
49
- /** Transform style id to apply before export. */
50
- transformStyle?: string;
83
+ /** Explicit caller-owned registry for non-document custom themes. */
84
+ themeRegistry?: ThemeRegistry;
85
+ /** Built-in/registry id or call-scoped style to apply before export. */
86
+ transformStyle?: TransformStyleInput;
87
+ /** Explicit caller-owned registry used to resolve transform style ids. */
88
+ transformRegistry?: TransformStyleRegistry;
51
89
  /** Content-aware auto-templating when deriving a Doc from markdown. */
52
90
  autoTemplates?: boolean;
53
- /** Title hint for exporters that support one (epub, html). */
91
+ /** Title hint for exporters that expose document metadata. */
54
92
  title?: string;
55
93
  /** Lazily resolve the standalone player IIFE bundle (required for HTML export). */
56
94
  resolvePlayerScript?: () => Promise<string>;
57
- /** Per-format escape hatch for extra options. */
58
- formatOptions?: Record<FormatId, Record<string, unknown>>;
95
+ /** Typed per-format options for built-ins; custom format ids remain extensible. */
96
+ formatOptions?: Partial<BuiltinFormatOptions> & Record<FormatId, unknown>;
59
97
  }
60
98
  /** Describes how a single format imports to / exports from the squisq model. */
61
99
  interface FormatDefinition {
@@ -164,4 +202,4 @@ declare function defaultFormats(): FormatDefinition[];
164
202
  */
165
203
  declare function convert(source: ConvertSource, to: FormatId, options?: ConvertOptions): Promise<ConversionResult>;
166
204
 
167
- export { BUILTIN_FORMAT_IDS, ConversionError, type ConversionErrorCode, type ConversionErrorOptions, type ConversionResult, type ConvertOptions, type ConvertSource, type FormatDefinition, type FormatId, type FormatRegistry, type NormalizedInput, convert, createRegistry, defaultFormats, defaultRegistry };
205
+ export { BUILTIN_FORMAT_IDS, type BuiltinFormatOptions, ConversionError, type ConversionErrorCode, type ConversionErrorOptions, type ConversionResult, type ConvertOptions, type ConvertSource, type DbkFormatOptions, type FormatDefinition, type FormatId, type FormatRegistry, type MarkdownFormatOptions, type NormalizedInput, convert, createRegistry, defaultFormats, defaultRegistry };
@@ -1,11 +1,14 @@
1
1
  import {
2
2
  BUILTIN_FORMAT_IDS,
3
- ConversionError,
4
3
  convert,
5
4
  createRegistry,
6
5
  defaultFormats,
7
6
  defaultRegistry
8
- } from "../chunk-RTS5XBZ7.js";
7
+ } from "../chunk-2EFDWKC6.js";
8
+ import {
9
+ ConversionError
10
+ } from "../chunk-ODL3SSPT.js";
11
+ import "../chunk-H7T5DXUU.js";
9
12
  export {
10
13
  BUILTIN_FORMAT_IDS,
11
14
  ConversionError,