@bendyline/squisq-formats 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container/index.d.ts +7 -5
- package/dist/container/index.js +39 -70
- package/dist/container/index.js.map +1 -1
- package/dist/docx/index.d.ts +128 -15
- package/dist/docx/index.js +17 -22
- package/dist/docx/index.js.map +1 -1
- package/dist/epub/index.d.ts +66 -11
- package/dist/epub/index.js +10 -18
- package/dist/epub/index.js.map +1 -1
- package/dist/html/index.d.ts +278 -15
- package/dist/html/index.js +26 -165
- package/dist/html/index.js.map +1 -1
- package/dist/index.d.ts +9 -38
- package/dist/index.js +62 -37
- package/dist/index.js.map +1 -1
- package/dist/ooxml/index.d.ts +353 -14
- package/dist/ooxml/index.js +116 -22
- package/dist/ooxml/index.js.map +1 -1
- package/dist/pdf/index.d.ts +143 -17
- package/dist/pdf/index.js +16 -25
- package/dist/pdf/index.js.map +1 -1
- package/dist/pptx/index.d.ts +83 -8
- package/dist/pptx/index.js +14 -34
- package/dist/pptx/index.js.map +1 -1
- package/dist/xlsx/index.d.ts +12 -9
- package/dist/xlsx/index.js +12 -44
- package/dist/xlsx/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/__tests__/container.test.d.ts +0 -8
- package/dist/__tests__/container.test.d.ts.map +0 -1
- package/dist/__tests__/container.test.js +0 -147
- package/dist/__tests__/container.test.js.map +0 -1
- package/dist/__tests__/docxExport.test.d.ts +0 -8
- package/dist/__tests__/docxExport.test.d.ts.map +0 -1
- package/dist/__tests__/docxExport.test.js +0 -383
- package/dist/__tests__/docxExport.test.js.map +0 -1
- package/dist/__tests__/docxImport.test.d.ts +0 -8
- package/dist/__tests__/docxImport.test.d.ts.map +0 -1
- package/dist/__tests__/docxImport.test.js +0 -309
- package/dist/__tests__/docxImport.test.js.map +0 -1
- package/dist/__tests__/epub.test.d.ts +0 -8
- package/dist/__tests__/epub.test.d.ts.map +0 -1
- package/dist/__tests__/epub.test.js +0 -472
- package/dist/__tests__/epub.test.js.map +0 -1
- package/dist/__tests__/html.test.d.ts +0 -8
- package/dist/__tests__/html.test.d.ts.map +0 -1
- package/dist/__tests__/html.test.js +0 -317
- package/dist/__tests__/html.test.js.map +0 -1
- package/dist/__tests__/ooxml.test.d.ts +0 -5
- package/dist/__tests__/ooxml.test.d.ts.map +0 -1
- package/dist/__tests__/ooxml.test.js +0 -152
- package/dist/__tests__/ooxml.test.js.map +0 -1
- package/dist/__tests__/pdfExport.test.d.ts +0 -8
- package/dist/__tests__/pdfExport.test.d.ts.map +0 -1
- package/dist/__tests__/pdfExport.test.js +0 -275
- package/dist/__tests__/pdfExport.test.js.map +0 -1
- package/dist/__tests__/pdfImport.test.d.ts +0 -11
- package/dist/__tests__/pdfImport.test.d.ts.map +0 -1
- package/dist/__tests__/pdfImport.test.js +0 -254
- package/dist/__tests__/pdfImport.test.js.map +0 -1
- package/dist/__tests__/plainHtml.test.d.ts +0 -5
- package/dist/__tests__/plainHtml.test.d.ts.map +0 -1
- package/dist/__tests__/plainHtml.test.js +0 -327
- package/dist/__tests__/plainHtml.test.js.map +0 -1
- package/dist/__tests__/plainHtmlBundle.test.d.ts +0 -11
- package/dist/__tests__/plainHtmlBundle.test.d.ts.map +0 -1
- package/dist/__tests__/plainHtmlBundle.test.js +0 -210
- package/dist/__tests__/plainHtmlBundle.test.js.map +0 -1
- package/dist/__tests__/roundTrip.test.d.ts +0 -7
- package/dist/__tests__/roundTrip.test.d.ts.map +0 -1
- package/dist/__tests__/roundTrip.test.js +0 -173
- package/dist/__tests__/roundTrip.test.js.map +0 -1
- package/dist/container/index.d.ts.map +0 -1
- package/dist/docx/export.d.ts +0 -69
- package/dist/docx/export.d.ts.map +0 -1
- package/dist/docx/export.js +0 -985
- package/dist/docx/export.js.map +0 -1
- package/dist/docx/import.d.ts +0 -65
- package/dist/docx/import.d.ts.map +0 -1
- package/dist/docx/import.js +0 -779
- package/dist/docx/import.js.map +0 -1
- package/dist/docx/index.d.ts.map +0 -1
- package/dist/docx/styles.d.ts +0 -68
- package/dist/docx/styles.d.ts.map +0 -1
- package/dist/docx/styles.js +0 -125
- package/dist/docx/styles.js.map +0 -1
- package/dist/epub/export.d.ts +0 -72
- package/dist/epub/export.d.ts.map +0 -1
- package/dist/epub/export.js +0 -698
- package/dist/epub/export.js.map +0 -1
- package/dist/epub/index.d.ts.map +0 -1
- package/dist/html/docsHtmlBundle.d.ts +0 -53
- package/dist/html/docsHtmlBundle.d.ts.map +0 -1
- package/dist/html/docsHtmlBundle.js +0 -299
- package/dist/html/docsHtmlBundle.js.map +0 -1
- package/dist/html/htmlTemplate.d.ts +0 -70
- package/dist/html/htmlTemplate.d.ts.map +0 -1
- package/dist/html/htmlTemplate.js +0 -282
- package/dist/html/htmlTemplate.js.map +0 -1
- package/dist/html/imageUtils.d.ts +0 -29
- package/dist/html/imageUtils.d.ts.map +0 -1
- package/dist/html/imageUtils.js +0 -63
- package/dist/html/imageUtils.js.map +0 -1
- package/dist/html/index.d.ts.map +0 -1
- package/dist/html/plainHtml.d.ts +0 -79
- package/dist/html/plainHtml.d.ts.map +0 -1
- package/dist/html/plainHtml.js +0 -614
- package/dist/html/plainHtml.js.map +0 -1
- package/dist/html/plainHtmlBundle.d.ts +0 -93
- package/dist/html/plainHtmlBundle.d.ts.map +0 -1
- package/dist/html/plainHtmlBundle.js +0 -357
- package/dist/html/plainHtmlBundle.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/ooxml/index.d.ts.map +0 -1
- package/dist/ooxml/namespaces.d.ts +0 -77
- package/dist/ooxml/namespaces.d.ts.map +0 -1
- package/dist/ooxml/namespaces.js +0 -104
- package/dist/ooxml/namespaces.js.map +0 -1
- package/dist/ooxml/reader.d.ts +0 -52
- package/dist/ooxml/reader.d.ts.map +0 -1
- package/dist/ooxml/reader.js +0 -190
- package/dist/ooxml/reader.js.map +0 -1
- package/dist/ooxml/types.d.ts +0 -82
- package/dist/ooxml/types.d.ts.map +0 -1
- package/dist/ooxml/types.js +0 -9
- package/dist/ooxml/types.js.map +0 -1
- package/dist/ooxml/writer.d.ts +0 -71
- package/dist/ooxml/writer.d.ts.map +0 -1
- package/dist/ooxml/writer.js +0 -200
- package/dist/ooxml/writer.js.map +0 -1
- package/dist/ooxml/xmlUtils.d.ts +0 -76
- package/dist/ooxml/xmlUtils.d.ts.map +0 -1
- package/dist/ooxml/xmlUtils.js +0 -108
- package/dist/ooxml/xmlUtils.js.map +0 -1
- package/dist/pdf/export.d.ts +0 -56
- package/dist/pdf/export.d.ts.map +0 -1
- package/dist/pdf/export.js +0 -768
- package/dist/pdf/export.js.map +0 -1
- package/dist/pdf/import.d.ts +0 -94
- package/dist/pdf/import.d.ts.map +0 -1
- package/dist/pdf/import.js +0 -796
- package/dist/pdf/import.js.map +0 -1
- package/dist/pdf/index.d.ts.map +0 -1
- package/dist/pdf/styles.d.ts +0 -142
- package/dist/pdf/styles.d.ts.map +0 -1
- package/dist/pdf/styles.js +0 -145
- package/dist/pdf/styles.js.map +0 -1
- package/dist/pptx/export.d.ts +0 -75
- package/dist/pptx/export.d.ts.map +0 -1
- package/dist/pptx/export.js +0 -724
- package/dist/pptx/export.js.map +0 -1
- package/dist/pptx/index.d.ts.map +0 -1
- package/dist/pptx/styles.d.ts +0 -54
- package/dist/pptx/styles.d.ts.map +0 -1
- package/dist/pptx/styles.js +0 -73
- package/dist/pptx/styles.js.map +0 -1
- package/dist/pptx/templates.d.ts +0 -24
- package/dist/pptx/templates.d.ts.map +0 -1
- package/dist/pptx/templates.js +0 -158
- package/dist/pptx/templates.js.map +0 -1
- package/dist/xlsx/index.d.ts.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ContentContainer, MemoryContentContainer } from '@bendyline/squisq/storage';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Container ZIP serialization — convert between ContentContainer and ZIP archives.
|
|
3
5
|
*
|
|
@@ -10,8 +12,7 @@
|
|
|
10
12
|
* audio/narration.mp3
|
|
11
13
|
* timing.json
|
|
12
14
|
*/
|
|
13
|
-
|
|
14
|
-
import { MemoryContentContainer } from '@bendyline/squisq/storage';
|
|
15
|
+
|
|
15
16
|
/**
|
|
16
17
|
* Serialize a ContentContainer to a ZIP blob.
|
|
17
18
|
*
|
|
@@ -21,7 +22,7 @@ import { MemoryContentContainer } from '@bendyline/squisq/storage';
|
|
|
21
22
|
* @param container — The container to serialize
|
|
22
23
|
* @returns A Blob containing the ZIP archive
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
declare function containerToZip(container: ContentContainer): Promise<Blob>;
|
|
25
26
|
/**
|
|
26
27
|
* Deserialize a ZIP archive into a MemoryContentContainer.
|
|
27
28
|
*
|
|
@@ -32,5 +33,6 @@ export declare function containerToZip(container: ContentContainer): Promise<Blo
|
|
|
32
33
|
* @param zipData — The ZIP archive as ArrayBuffer, Uint8Array, or Blob
|
|
33
34
|
* @returns A MemoryContentContainer populated with the ZIP's contents
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
declare function zipToContainer(zipData: ArrayBuffer | Uint8Array | Blob): Promise<MemoryContentContainer>;
|
|
37
|
+
|
|
38
|
+
export { containerToZip, zipToContainer };
|
package/dist/container/index.js
CHANGED
|
@@ -1,74 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* timing.json
|
|
12
|
-
*/
|
|
13
|
-
import JSZip from 'jszip';
|
|
14
|
-
import { MemoryContentContainer } from '@bendyline/squisq/storage';
|
|
15
|
-
/**
|
|
16
|
-
* Serialize a ContentContainer to a ZIP blob.
|
|
17
|
-
*
|
|
18
|
-
* All files in the container are written to the ZIP archive preserving
|
|
19
|
-
* their path structure. The resulting blob can be saved as a .zip file.
|
|
20
|
-
*
|
|
21
|
-
* @param container — The container to serialize
|
|
22
|
-
* @returns A Blob containing the ZIP archive
|
|
23
|
-
*/
|
|
24
|
-
export async function containerToZip(container) {
|
|
25
|
-
const zip = new JSZip();
|
|
26
|
-
const entries = await container.listFiles();
|
|
27
|
-
for (const entry of entries) {
|
|
28
|
-
const data = await container.readFile(entry.path);
|
|
29
|
-
if (data) {
|
|
30
|
-
zip.file(entry.path, new Uint8Array(data));
|
|
31
|
-
}
|
|
1
|
+
// src/container/index.ts
|
|
2
|
+
import JSZip from "jszip";
|
|
3
|
+
import { MemoryContentContainer } from "@bendyline/squisq/storage";
|
|
4
|
+
async function containerToZip(container) {
|
|
5
|
+
const zip = new JSZip();
|
|
6
|
+
const entries = await container.listFiles();
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
const data = await container.readFile(entry.path);
|
|
9
|
+
if (data) {
|
|
10
|
+
zip.file(entry.path, new Uint8Array(data));
|
|
32
11
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
12
|
+
}
|
|
13
|
+
return zip.generateAsync({
|
|
14
|
+
type: "blob",
|
|
15
|
+
compression: "DEFLATE",
|
|
16
|
+
compressionOptions: { level: 6 }
|
|
17
|
+
});
|
|
38
18
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const entryPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;
|
|
59
|
-
if (!entryPath)
|
|
60
|
-
return;
|
|
61
|
-
// Path-traversal protection: reject absolute paths, backslashes, and .. segments
|
|
62
|
-
if (entryPath.startsWith('/') ||
|
|
63
|
-
entryPath.includes('\\') ||
|
|
64
|
-
entryPath.split('/').some((seg) => seg === '..')) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
filePromises.push(zipEntry.async('arraybuffer').then((data) => {
|
|
68
|
-
return container.writeFile(entryPath, data);
|
|
69
|
-
}));
|
|
70
|
-
});
|
|
71
|
-
await Promise.all(filePromises);
|
|
72
|
-
return container;
|
|
19
|
+
async function zipToContainer(zipData) {
|
|
20
|
+
const zip = await JSZip.loadAsync(zipData);
|
|
21
|
+
const container = new MemoryContentContainer();
|
|
22
|
+
const filePromises = [];
|
|
23
|
+
zip.forEach((relativePath, zipEntry) => {
|
|
24
|
+
if (zipEntry.dir) return;
|
|
25
|
+
const entryPath = relativePath.startsWith("/") ? relativePath.slice(1) : relativePath;
|
|
26
|
+
if (!entryPath) return;
|
|
27
|
+
if (entryPath.startsWith("/") || entryPath.includes("\\") || entryPath.split("/").some((seg) => seg === "..")) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
filePromises.push(
|
|
31
|
+
zipEntry.async("arraybuffer").then((data) => {
|
|
32
|
+
return container.writeFile(entryPath, data);
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
await Promise.all(filePromises);
|
|
37
|
+
return container;
|
|
73
38
|
}
|
|
39
|
+
export {
|
|
40
|
+
containerToZip,
|
|
41
|
+
zipToContainer
|
|
42
|
+
};
|
|
74
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/container/index.ts"],"sourcesContent":["/**\n * Container ZIP serialization — convert between ContentContainer and ZIP archives.\n *\n * Uses JSZip (already a formats dependency) to serialize a ContentContainer to\n * a ZIP blob and to deserialize a ZIP blob into a MemoryContentContainer.\n *\n * ZIP structure mirrors the container's flat path hierarchy directly:\n * index.md\n * images/hero.jpg\n * audio/narration.mp3\n * timing.json\n */\n\nimport JSZip from 'jszip';\nimport type { ContentContainer } from '@bendyline/squisq/storage';\nimport { MemoryContentContainer } from '@bendyline/squisq/storage';\n\n/**\n * Serialize a ContentContainer to a ZIP blob.\n *\n * All files in the container are written to the ZIP archive preserving\n * their path structure. The resulting blob can be saved as a .zip file.\n *\n * @param container — The container to serialize\n * @returns A Blob containing the ZIP archive\n */\nexport async function containerToZip(container: ContentContainer): Promise<Blob> {\n const zip = new JSZip();\n const entries = await container.listFiles();\n\n for (const entry of entries) {\n const data = await container.readFile(entry.path);\n if (data) {\n zip.file(entry.path, new Uint8Array(data));\n }\n }\n\n return zip.generateAsync({\n type: 'blob',\n compression: 'DEFLATE',\n compressionOptions: { level: 6 },\n });\n}\n\n/**\n * Deserialize a ZIP archive into a MemoryContentContainer.\n *\n * Reads all files from the ZIP and writes them into a new MemoryContentContainer.\n * Directory entries are skipped. The resulting container can be used immediately\n * for rendering, editing, or saving to persistent storage.\n *\n * @param zipData — The ZIP archive as ArrayBuffer, Uint8Array, or Blob\n * @returns A MemoryContentContainer populated with the ZIP's contents\n */\nexport async function zipToContainer(\n zipData: ArrayBuffer | Uint8Array | Blob,\n): Promise<MemoryContentContainer> {\n const zip = await JSZip.loadAsync(zipData);\n const container = new MemoryContentContainer();\n\n const filePromises: Promise<void>[] = [];\n\n zip.forEach((relativePath, zipEntry) => {\n // Skip directories\n if (zipEntry.dir) return;\n\n // Strip leading slash if present\n const entryPath = relativePath.startsWith('/') ? relativePath.slice(1) : relativePath;\n if (!entryPath) return;\n\n // Path-traversal protection: reject absolute paths, backslashes, and .. segments\n if (\n entryPath.startsWith('/') ||\n entryPath.includes('\\\\') ||\n entryPath.split('/').some((seg) => seg === '..')\n ) {\n return;\n }\n\n filePromises.push(\n zipEntry.async('arraybuffer').then((data) => {\n return container.writeFile(entryPath, data);\n }),\n );\n });\n\n await Promise.all(filePromises);\n return container;\n}\n"],"mappings":";AAaA,OAAO,WAAW;AAElB,SAAS,8BAA8B;AAWvC,eAAsB,eAAe,WAA4C;AAC/E,QAAM,MAAM,IAAI,MAAM;AACtB,QAAM,UAAU,MAAM,UAAU,UAAU;AAE1C,aAAW,SAAS,SAAS;AAC3B,UAAM,OAAO,MAAM,UAAU,SAAS,MAAM,IAAI;AAChD,QAAI,MAAM;AACR,UAAI,KAAK,MAAM,MAAM,IAAI,WAAW,IAAI,CAAC;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO,IAAI,cAAc;AAAA,IACvB,MAAM;AAAA,IACN,aAAa;AAAA,IACb,oBAAoB,EAAE,OAAO,EAAE;AAAA,EACjC,CAAC;AACH;AAYA,eAAsB,eACpB,SACiC;AACjC,QAAM,MAAM,MAAM,MAAM,UAAU,OAAO;AACzC,QAAM,YAAY,IAAI,uBAAuB;AAE7C,QAAM,eAAgC,CAAC;AAEvC,MAAI,QAAQ,CAAC,cAAc,aAAa;AAEtC,QAAI,SAAS,IAAK;AAGlB,UAAM,YAAY,aAAa,WAAW,GAAG,IAAI,aAAa,MAAM,CAAC,IAAI;AACzE,QAAI,CAAC,UAAW;AAGhB,QACE,UAAU,WAAW,GAAG,KACxB,UAAU,SAAS,IAAI,KACvB,UAAU,MAAM,GAAG,EAAE,KAAK,CAAC,QAAQ,QAAQ,IAAI,GAC/C;AACA;AAAA,IACF;AAEA,iBAAa;AAAA,MACX,SAAS,MAAM,aAAa,EAAE,KAAK,CAAC,SAAS;AAC3C,eAAO,UAAU,UAAU,WAAW,IAAI;AAAA,MAC5C,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AAED,QAAM,QAAQ,IAAI,YAAY;AAC9B,SAAO;AACT;","names":[]}
|
package/dist/docx/index.d.ts
CHANGED
|
@@ -1,23 +1,136 @@
|
|
|
1
|
+
import { Doc } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
import { ContentContainer } from '@bendyline/squisq/storage';
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
6
|
+
* DOCX Export
|
|
3
7
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
8
|
+
* Converts a squisq MarkdownDocument (or Doc) into a .docx file
|
|
9
|
+
* by generating WordprocessingML XML and assembling the OOXML package.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
11
|
+
* No third-party docx library — all XML is generated directly using
|
|
12
|
+
* the shared ooxml/ infrastructure of this package.
|
|
8
13
|
*
|
|
9
14
|
* @example
|
|
10
15
|
* ```ts
|
|
11
|
-
* import {
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* import { parseMarkdown } from '@bendyline/squisq/markdown';
|
|
17
|
+
* import { markdownDocToDocx } from '@bendyline/squisq-formats/docx';
|
|
18
|
+
*
|
|
19
|
+
* const md = parseMarkdown('# Hello\n\nWorld **bold** text');
|
|
20
|
+
* const blob = await markdownDocToDocx(md);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Options for DOCX export.
|
|
26
|
+
*/
|
|
27
|
+
interface DocxExportOptions {
|
|
28
|
+
/** Document title (appears in core properties) */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Document author */
|
|
31
|
+
author?: string;
|
|
32
|
+
/** Document description */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Default body font family. Default: "Calibri" */
|
|
35
|
+
defaultFont?: string;
|
|
36
|
+
/** Default body font size in points. Default: 11 */
|
|
37
|
+
defaultFontSize?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Squisq theme ID to apply (e.g., 'documentary', 'cinematic').
|
|
40
|
+
* When set, overrides fonts with the theme's typography and applies
|
|
41
|
+
* the theme's primary color to headings.
|
|
42
|
+
*/
|
|
43
|
+
themeId?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Pre-resolved image data keyed by image URL/path as it appears in the
|
|
46
|
+
* markdown source. When provided, images are embedded in the .docx file
|
|
47
|
+
* as binary parts instead of emitting placeholder text.
|
|
48
|
+
*/
|
|
49
|
+
images?: Map<string, {
|
|
50
|
+
data: ArrayBuffer | Uint8Array;
|
|
51
|
+
contentType: string;
|
|
52
|
+
}>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Convert a MarkdownDocument to a .docx Blob.
|
|
56
|
+
*
|
|
57
|
+
* @param doc - The parsed markdown document
|
|
58
|
+
* @param options - Export options
|
|
59
|
+
* @returns An ArrayBuffer containing the .docx file
|
|
60
|
+
*/
|
|
61
|
+
declare function markdownDocToDocx(doc: MarkdownDocument, options?: DocxExportOptions): Promise<ArrayBuffer>;
|
|
62
|
+
/**
|
|
63
|
+
* Convert a squisq Doc to a .docx Blob.
|
|
64
|
+
*
|
|
65
|
+
* Convenience wrapper that converts Doc → MarkdownDocument → DOCX.
|
|
66
|
+
*
|
|
67
|
+
* @param doc - The squisq Doc
|
|
68
|
+
* @param options - Export options
|
|
69
|
+
* @returns An ArrayBuffer containing the .docx file
|
|
70
|
+
*/
|
|
71
|
+
declare function docToDocx(doc: Doc, options?: DocxExportOptions): Promise<ArrayBuffer>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* DOCX Import
|
|
75
|
+
*
|
|
76
|
+
* Parses a .docx file (Office Open XML WordprocessingML) and converts
|
|
77
|
+
* its content into a squisq MarkdownDocument (or Doc).
|
|
78
|
+
*
|
|
79
|
+
* Uses JSZip + DOMParser to read the archive and parse the XML — no
|
|
80
|
+
* third-party docx library. Handles headings, paragraphs, inline
|
|
81
|
+
* formatting (bold, italic, strikethrough), hyperlinks, lists, tables,
|
|
82
|
+
* blockquotes, code blocks, images, and footnotes.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { docxToMarkdownDoc } from '@bendyline/squisq-formats/docx';
|
|
87
|
+
*
|
|
88
|
+
* const response = await fetch('document.docx');
|
|
89
|
+
* const data = await response.arrayBuffer();
|
|
90
|
+
* const doc = await docxToMarkdownDoc(data);
|
|
17
91
|
* ```
|
|
18
92
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Options for DOCX import.
|
|
96
|
+
*/
|
|
97
|
+
interface DocxImportOptions {
|
|
98
|
+
/**
|
|
99
|
+
* Whether to extract embedded images as base64 data URIs.
|
|
100
|
+
* When false, images are represented as `[Image]` placeholders.
|
|
101
|
+
* Default: false
|
|
102
|
+
*/
|
|
103
|
+
extractImages?: boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Convert a .docx file to a MarkdownDocument.
|
|
107
|
+
*
|
|
108
|
+
* @param data - The raw .docx file as ArrayBuffer or Blob
|
|
109
|
+
* @param options - Import options
|
|
110
|
+
* @returns A MarkdownDocument representing the document content
|
|
111
|
+
*/
|
|
112
|
+
declare function docxToMarkdownDoc(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<MarkdownDocument>;
|
|
113
|
+
/**
|
|
114
|
+
* Convert a .docx file to a squisq Doc.
|
|
115
|
+
*
|
|
116
|
+
* Convenience wrapper: DOCX → MarkdownDocument → Doc.
|
|
117
|
+
*
|
|
118
|
+
* @param data - The raw .docx file as ArrayBuffer or Blob
|
|
119
|
+
* @param options - Import options
|
|
120
|
+
* @returns A squisq Doc
|
|
121
|
+
*/
|
|
122
|
+
declare function docxToDoc(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<Doc>;
|
|
123
|
+
/**
|
|
124
|
+
* Convert a .docx file to a ContentContainer with markdown + extracted images.
|
|
125
|
+
*
|
|
126
|
+
* The container will contain:
|
|
127
|
+
* - The primary markdown document (index.md)
|
|
128
|
+
* - Any embedded images under images/ (e.g., images/image1.png)
|
|
129
|
+
*
|
|
130
|
+
* @param data - The raw .docx file as ArrayBuffer or Blob
|
|
131
|
+
* @param options - Import options
|
|
132
|
+
* @returns A ContentContainer with the document and its media
|
|
133
|
+
*/
|
|
134
|
+
declare function docxToContainer(data: ArrayBuffer | Blob, options?: DocxImportOptions): Promise<ContentContainer>;
|
|
135
|
+
|
|
136
|
+
export { type DocxExportOptions, type DocxImportOptions, docToDocx, docxToContainer, docxToDoc, docxToMarkdownDoc, markdownDocToDocx };
|
package/dist/docx/index.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
// Export
|
|
20
|
-
export { markdownDocToDocx, docToDocx } from './export.js';
|
|
21
|
-
// Import
|
|
22
|
-
export { docxToMarkdownDoc, docxToDoc, docxToContainer } from './import.js';
|
|
1
|
+
import {
|
|
2
|
+
docToDocx,
|
|
3
|
+
docxToContainer,
|
|
4
|
+
docxToDoc,
|
|
5
|
+
docxToMarkdownDoc,
|
|
6
|
+
markdownDocToDocx
|
|
7
|
+
} from "../chunk-UDS45KUJ.js";
|
|
8
|
+
import "../chunk-YN5HFCEW.js";
|
|
9
|
+
import "../chunk-7DEUGIOO.js";
|
|
10
|
+
import "../chunk-U4MRIFKL.js";
|
|
11
|
+
export {
|
|
12
|
+
docToDocx,
|
|
13
|
+
docxToContainer,
|
|
14
|
+
docxToDoc,
|
|
15
|
+
docxToMarkdownDoc,
|
|
16
|
+
markdownDocToDocx
|
|
17
|
+
};
|
|
23
18
|
//# sourceMappingURL=index.js.map
|
package/dist/docx/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/epub/index.d.ts
CHANGED
|
@@ -1,20 +1,75 @@
|
|
|
1
|
+
import { AudioSegment, Doc } from '@bendyline/squisq/schemas';
|
|
2
|
+
import { MarkdownDocument } from '@bendyline/squisq/markdown';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
*
|
|
5
|
+
* EPUB 3 Export
|
|
3
6
|
*
|
|
4
|
-
*
|
|
7
|
+
* Converts a MarkdownDocument (or Doc) to an EPUB 3 file (.epub).
|
|
5
8
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* An EPUB is a ZIP archive containing XHTML chapter files, images,
|
|
10
|
+
* a package manifest (content.opf), and a navigation document (toc.xhtml).
|
|
11
|
+
* Content is split into chapters at H1/H2 heading boundaries.
|
|
12
|
+
*
|
|
13
|
+
* Uses JSZip for packaging (already a dependency), escapeXml from the
|
|
14
|
+
* OOXML utils, and image utilities from the HTML exporter.
|
|
9
15
|
*
|
|
10
16
|
* @example
|
|
11
17
|
* ```ts
|
|
12
|
-
* import { markdownDocToEpub
|
|
18
|
+
* import { markdownDocToEpub } from '@bendyline/squisq-formats/epub';
|
|
13
19
|
*
|
|
14
|
-
* const epub = await markdownDocToEpub(markdownDoc, {
|
|
15
|
-
*
|
|
20
|
+
* const epub = await markdownDocToEpub(markdownDoc, {
|
|
21
|
+
* title: 'My Book',
|
|
22
|
+
* author: 'Jane Doe',
|
|
23
|
+
* });
|
|
16
24
|
* ```
|
|
17
25
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
|
|
27
|
+
interface EpubExportOptions {
|
|
28
|
+
/** Book title (default: 'Untitled') */
|
|
29
|
+
title?: string;
|
|
30
|
+
/** Author name */
|
|
31
|
+
author?: string;
|
|
32
|
+
/** Book description / summary */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** BCP-47 language code (default: 'en') */
|
|
35
|
+
language?: string;
|
|
36
|
+
/** Publisher name */
|
|
37
|
+
publisher?: string;
|
|
38
|
+
/** Squisq theme ID for CSS styling */
|
|
39
|
+
themeId?: string;
|
|
40
|
+
/** Pre-resolved image data keyed by relative path as it appears in the markdown */
|
|
41
|
+
images?: Map<string, ArrayBuffer>;
|
|
42
|
+
/** Cover image data (JPEG or PNG) */
|
|
43
|
+
coverImage?: ArrayBuffer;
|
|
44
|
+
/**
|
|
45
|
+
* Audio narration data keyed by segment src/name.
|
|
46
|
+
* When provided alongside audioSegments, EPUB 3 Media Overlays (SMIL)
|
|
47
|
+
* are generated for synchronized audio playback.
|
|
48
|
+
*/
|
|
49
|
+
audio?: Map<string, ArrayBuffer>;
|
|
50
|
+
/**
|
|
51
|
+
* Audio segment metadata (from Doc.audio.segments).
|
|
52
|
+
* Required together with `audio` to generate Media Overlays.
|
|
53
|
+
* Each segment's duration and startTime are used to build SMIL timing.
|
|
54
|
+
*/
|
|
55
|
+
audioSegments?: AudioSegment[];
|
|
56
|
+
/** Total document duration in seconds (used for Media Overlay metadata) */
|
|
57
|
+
totalDuration?: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Convert a MarkdownDocument to an EPUB 3 file.
|
|
61
|
+
*
|
|
62
|
+
* Chapters are split at H1/H2 heading boundaries. All referenced images
|
|
63
|
+
* (provided via `options.images`) are embedded in the archive.
|
|
64
|
+
*/
|
|
65
|
+
declare function markdownDocToEpub(doc: MarkdownDocument, options?: EpubExportOptions): Promise<ArrayBuffer>;
|
|
66
|
+
/**
|
|
67
|
+
* Convert a squisq Doc to an EPUB 3 file.
|
|
68
|
+
*
|
|
69
|
+
* Convenience wrapper: Doc → MarkdownDocument → EPUB.
|
|
70
|
+
* When the Doc has audio segments and `options.audio` is provided,
|
|
71
|
+
* EPUB 3 Media Overlays are generated for narrated playback.
|
|
72
|
+
*/
|
|
73
|
+
declare function docToEpub(doc: Doc, options?: EpubExportOptions): Promise<ArrayBuffer>;
|
|
74
|
+
|
|
75
|
+
export { type EpubExportOptions, docToEpub, markdownDocToEpub };
|
package/dist/epub/index.js
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { markdownDocToEpub, docToEpub } from '@bendyline/squisq-formats/epub';
|
|
13
|
-
*
|
|
14
|
-
* const epub = await markdownDocToEpub(markdownDoc, { title: 'My Book' });
|
|
15
|
-
* const epub2 = await docToEpub(doc, { author: 'Jane Doe' });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export { markdownDocToEpub, docToEpub } from './export.js';
|
|
1
|
+
import {
|
|
2
|
+
docToEpub,
|
|
3
|
+
markdownDocToEpub
|
|
4
|
+
} from "../chunk-ERZ627GR.js";
|
|
5
|
+
import "../chunk-U4MRIFKL.js";
|
|
6
|
+
import "../chunk-A3FHLTY5.js";
|
|
7
|
+
export {
|
|
8
|
+
docToEpub,
|
|
9
|
+
markdownDocToEpub
|
|
10
|
+
};
|
|
19
11
|
//# sourceMappingURL=index.js.map
|
package/dist/epub/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|