docx-kit 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/node.d.ts DELETED
@@ -1,77 +0,0 @@
1
- import { Document } from "docx";
2
-
3
- //#region src/node/fs.d.ts
4
- /**
5
- * Save a compiled document to a file on disk.
6
- *
7
- * Uses `Packer.toBuffer()` to produce the .docx binary, then
8
- * writes via `node:fs/promises`. This function is **Node.js only**.
9
- *
10
- * @param doc - — A compiled `docx` `Document` instance
11
- * @param filename - — Output file path (e.g. `"report.docx"`)
12
- *
13
- * @example
14
- * ```ts
15
- * import { saveDocument } from 'docx-kit/node'
16
- *
17
- * const doc = await compileDocument({ ... })
18
- * await saveDocument(doc, 'report.docx')
19
- * ```
20
- */
21
- declare function saveDocument(doc: Document, filename: string): Promise<void>;
22
- //#endregion
23
- //#region src/node/dataUrl.d.ts
24
- /**
25
- * Node.js base64 data-URL decoder (uses `Buffer` from `node:buffer`).
26
- *
27
- * @module node/dataUrl
28
- */
29
- /**
30
- * Decode a base64 data-URL to raw bytes using Node.js `Buffer`.
31
- *
32
- * Strips the `"data:*;base64,"` prefix and decodes via
33
- * `Buffer.from(base64, 'base64')`.
34
- *
35
- * @param dataUrl - — A base64 data-URI string (e.g. `"data:image/png;base64,iVBO..."`)
36
- * @returns Raw bytes as `Uint8Array`
37
- *
38
- * @example
39
- * ```ts
40
- * import { dataUrlToUint8Array } from 'docx-kit/node'
41
- *
42
- * const bytes = await dataUrlToUint8Array('data:image/png;base64,iVBORw...')
43
- * ```
44
- */
45
- declare function dataUrlToUint8Array(dataUrl: string): Promise<Uint8Array>;
46
- //#endregion
47
- //#region src/node.d.ts
48
- /**
49
- * ### ❌ `echartsPlugin()` — Not available in Node.js
50
- *
51
- * The ECharts plugin requires a browser `window` and `document` to
52
- * render charts into a DOM container. Node.js has no native DOM.
53
- *
54
- * **Workarounds:**
55
- * - Use a server-side canvas library (e.g. `node-canvas` + `echarts`)
56
- * - Pre-render charts on the client and pass the image data to docx-kit
57
- *
58
- * @deprecated This API is not available in Node.js. See workarounds above.
59
- */
60
- declare const echartsPlugin: never;
61
- /**
62
- * ### ❌ `normalizeImageData()` — Not built-in for Node.js
63
- *
64
- * This utility converts `Blob` instances to `Uint8Array`. While `Blob`
65
- * is available in Node.js ≥ 18, it is rarely the carrier for image data
66
- * in Node workflows (most users work with `Buffer` or file paths directly).
67
- *
68
- * If you need Blob→Uint8Array in Node.js, use:
69
- * ```ts
70
- * const bytes = new Uint8Array(await blob.arrayBuffer())
71
- * ```
72
- *
73
- * @deprecated Use inline `new Uint8Array(await blob.arrayBuffer())` instead.
74
- */
75
- declare const normalizeImageData: never;
76
- //#endregion
77
- export { dataUrlToUint8Array, echartsPlugin, normalizeImageData, saveDocument };
package/dist/node.js DELETED
@@ -1,30 +0,0 @@
1
- import { n as saveDocument } from "./fs-DF8ug9Wi.js";
2
- //#region src/node/dataUrl.ts
3
- /**
4
- * Node.js base64 data-URL decoder (uses `Buffer` from `node:buffer`).
5
- *
6
- * @module node/dataUrl
7
- */
8
- /**
9
- * Decode a base64 data-URL to raw bytes using Node.js `Buffer`.
10
- *
11
- * Strips the `"data:*;base64,"` prefix and decodes via
12
- * `Buffer.from(base64, 'base64')`.
13
- *
14
- * @param dataUrl - — A base64 data-URI string (e.g. `"data:image/png;base64,iVBO..."`)
15
- * @returns Raw bytes as `Uint8Array`
16
- *
17
- * @example
18
- * ```ts
19
- * import { dataUrlToUint8Array } from 'docx-kit/node'
20
- *
21
- * const bytes = await dataUrlToUint8Array('data:image/png;base64,iVBORw...')
22
- * ```
23
- */
24
- async function dataUrlToUint8Array(dataUrl) {
25
- const { Buffer } = await import("node:buffer");
26
- const base64 = dataUrl.split(",")[1];
27
- return new Uint8Array(Buffer.from(base64, "base64"));
28
- }
29
- //#endregion
30
- export { dataUrlToUint8Array, saveDocument };
File without changes