docx-kit 0.2.0 → 0.3.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 ADDED
@@ -0,0 +1,82 @@
1
+ import { academicPreset } from "@docxkit/preset-academic";
2
+ import { classicPreset } from "@docxkit/preset-classic";
3
+ import { modernPreset } from "@docxkit/preset-modern";
4
+ import { minimalTheme } from "@docxkit/theme-minimal";
5
+ import { oceanTheme } from "@docxkit/theme-ocean";
6
+ import { warmTheme } from "@docxkit/theme-warm";
7
+ import { DocxPreset, DocxTheme, dataUrlToUint8Array } from "@docxkit/core";
8
+ import { TocOptions, TocOptions as TocOptions$1, tocPlugin } from "@docxkit/plugin-toc";
9
+ import { BadgeOptions, BadgeOptions as BadgeOptions$1, badgePlugin } from "@docxkit/plugin-badge";
10
+ import { QRCodePluginOptions, QRCodePluginOptions as QRCodePluginOptions$1, qrcodePlugin } from "@docxkit/plugin-qrcode";
11
+ import { CalloutOptions, CalloutOptions as CalloutOptions$1, calloutPlugin } from "@docxkit/plugin-callout";
12
+ import { DividerOptions, DividerOptions as DividerOptions$1, dividerPlugin } from "@docxkit/plugin-divider";
13
+ import { InvoiceLineItem, InvoiceOptions, InvoiceOptions as InvoiceOptions$1, InvoiceParty, invoicePlugin } from "@docxkit/plugin-invoice";
14
+ import { TimelineEvent, TimelineOptions, TimelineOptions as TimelineOptions$1, timelinePlugin } from "@docxkit/plugin-timeline";
15
+ import { ChangelogEntry, ChangelogOptions, ChangelogOptions as ChangelogOptions$1, changelogPlugin } from "@docxkit/plugin-changelog";
16
+ import { WatermarkOptions, WatermarkOptions as WatermarkOptions$1, watermarkPlugin } from "@docxkit/plugin-watermark";
17
+ import { CodeBlockOptions, CodeBlockOptions as CodeBlockOptions$1, codeBlockPlugin } from "@docxkit/plugin-code-block";
18
+ import { CoverPageOptions, CoverPageOptions as CoverPageOptions$1, coverPagePlugin } from "@docxkit/plugin-cover-page";
19
+ import { ColAlign, ColFormat, DataTableOptions, DataTableOptions as DataTableOptions$1, dataTablePlugin } from "@docxkit/plugin-data-table";
20
+ import { LetterheadOptions, LetterheadOptions as LetterheadOptions$1, letterheadPlugin } from "@docxkit/plugin-letterhead";
21
+ import { PageNumberOptions, PageNumberOptions as PageNumberOptions$1, pageNumberPlugin } from "@docxkit/plugin-page-number";
22
+ import { Document } from "docx";
23
+ import { PropertyItem, PropertyTableOptions, PropertyTableOptions as PropertyTableOptions$1, propertyTablePlugin } from "@docxkit/plugin-property-table";
24
+ import { AgendaItem, MeetingMinutesOptions, MeetingMinutesOptions as MeetingMinutesOptions$1, meetingMinutesPlugin } from "@docxkit/plugin-meeting-minutes";
25
+ import { SignatureBlockOptions, SignatureBlockOptions as SignatureBlockOptions$1, SignatureParty, signatureBlockPlugin } from "@docxkit/plugin-signature-block";
26
+ import { EChartsPluginOptions } from "@docxkit/plugin-echarts";
27
+ export * from "@docxkit/core";
28
+
29
+ //#region src/types/plugin-map.d.ts
30
+ declare module '@docxkit/core' {
31
+ interface BuiltinPluginMap {
32
+ badge: BadgeOptions$1;
33
+ callout: CalloutOptions$1;
34
+ changelog: ChangelogOptions$1;
35
+ codeBlock: CodeBlockOptions$1;
36
+ coverPage: CoverPageOptions$1;
37
+ dataTable: DataTableOptions$1;
38
+ divider: DividerOptions$1;
39
+ echarts: EChartsPluginOptions;
40
+ invoice: InvoiceOptions$1;
41
+ letterhead: LetterheadOptions$1;
42
+ meetingMinutes: MeetingMinutesOptions$1;
43
+ pageNumber: PageNumberOptions$1;
44
+ propertyTable: PropertyTableOptions$1;
45
+ qrcode: QRCodePluginOptions$1;
46
+ signatureBlock: SignatureBlockOptions$1;
47
+ timeline: TimelineOptions$1;
48
+ toc: TocOptions$1;
49
+ watermark: WatermarkOptions$1;
50
+ }
51
+ }
52
+ //#endregion
53
+ //#region src/node/fs.d.ts
54
+ /**
55
+ * Save a compiled document to a file on disk.
56
+ *
57
+ * Uses `Packer.toBuffer()` to produce the .docx binary, then
58
+ * writes via `node:fs/promises`. This function is **Node.js only**.
59
+ *
60
+ * @param doc - — A compiled `docx` `Document` instance
61
+ * @param filename - — Output file path (e.g. `"report.docx"`)
62
+ * @returns A promise that resolves when the file has been written
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { saveDocument } from 'docx-kit/node'
67
+ *
68
+ * const doc = await compileDocument({ ... })
69
+ * await saveDocument(doc, 'report.docx')
70
+ * ```
71
+ */
72
+ declare function saveDocument(doc: Document, filename: string): Promise<void>;
73
+ //#endregion
74
+ //#region src/node.d.ts
75
+ declare const BUILTIN_PRESETS: ReadonlyMap<string, DocxPreset>;
76
+ declare const PRESET_LIST: readonly DocxPreset[];
77
+ declare function usePreset(id: string): DocxPreset | undefined;
78
+ declare const BUILTIN_THEMES: ReadonlyMap<string, DocxTheme>;
79
+ declare const THEME_LIST: readonly DocxTheme[];
80
+ declare function useTheme(id: string): DocxTheme | undefined;
81
+ //#endregion
82
+ export { type AgendaItem, BUILTIN_PRESETS, BUILTIN_THEMES, type BadgeOptions, type CalloutOptions, type ChangelogEntry, type ChangelogOptions, type CodeBlockOptions, type ColAlign, type ColFormat, type CoverPageOptions, type DataTableOptions, type DividerOptions, type InvoiceLineItem, type InvoiceOptions, type InvoiceParty, type LetterheadOptions, type MeetingMinutesOptions, PRESET_LIST, type PageNumberOptions, type PropertyItem, type PropertyTableOptions, type QRCodePluginOptions, type SignatureBlockOptions, type SignatureParty, THEME_LIST, type TimelineEvent, type TimelineOptions, type TocOptions, type WatermarkOptions, academicPreset, badgePlugin, calloutPlugin, changelogPlugin, classicPreset, codeBlockPlugin, coverPagePlugin, dataTablePlugin, dataUrlToUint8Array, dividerPlugin, invoicePlugin, letterheadPlugin, meetingMinutesPlugin, minimalTheme, modernPreset, oceanTheme, pageNumberPlugin, propertyTablePlugin, qrcodePlugin, saveDocument, signatureBlockPlugin, timelinePlugin, tocPlugin, usePreset, useTheme, warmTheme, watermarkPlugin };
package/dist/node.js ADDED
@@ -0,0 +1,92 @@
1
+ import { academicPreset } from "@docxkit/preset-academic";
2
+ import { classicPreset } from "@docxkit/preset-classic";
3
+ import { modernPreset } from "@docxkit/preset-modern";
4
+ import { minimalTheme } from "@docxkit/theme-minimal";
5
+ import { oceanTheme } from "@docxkit/theme-ocean";
6
+ import { warmTheme } from "@docxkit/theme-warm";
7
+ import { dataUrlToUint8Array } from "@docxkit/core";
8
+ import { tocPlugin } from "@docxkit/plugin-toc";
9
+ import { badgePlugin } from "@docxkit/plugin-badge";
10
+ import { qrcodePlugin } from "@docxkit/plugin-qrcode";
11
+ import { calloutPlugin } from "@docxkit/plugin-callout";
12
+ import { dividerPlugin } from "@docxkit/plugin-divider";
13
+ import { invoicePlugin } from "@docxkit/plugin-invoice";
14
+ import { timelinePlugin } from "@docxkit/plugin-timeline";
15
+ import { changelogPlugin } from "@docxkit/plugin-changelog";
16
+ import { watermarkPlugin } from "@docxkit/plugin-watermark";
17
+ import { codeBlockPlugin } from "@docxkit/plugin-code-block";
18
+ import { coverPagePlugin } from "@docxkit/plugin-cover-page";
19
+ import { dataTablePlugin } from "@docxkit/plugin-data-table";
20
+ import { letterheadPlugin } from "@docxkit/plugin-letterhead";
21
+ import { pageNumberPlugin } from "@docxkit/plugin-page-number";
22
+ import { Packer } from "docx";
23
+ import { propertyTablePlugin } from "@docxkit/plugin-property-table";
24
+ import { meetingMinutesPlugin } from "@docxkit/plugin-meeting-minutes";
25
+ import { signatureBlockPlugin } from "@docxkit/plugin-signature-block";
26
+ export * from "@docxkit/core";
27
+ //#region src/node/fs.ts
28
+ /**
29
+ * Node.js filesystem utilities for saving documents to disk.
30
+ *
31
+ * @module node/fs
32
+ */
33
+ /**
34
+ * Save a compiled document to a file on disk.
35
+ *
36
+ * Uses `Packer.toBuffer()` to produce the .docx binary, then
37
+ * writes via `node:fs/promises`. This function is **Node.js only**.
38
+ *
39
+ * @param doc - — A compiled `docx` `Document` instance
40
+ * @param filename - — Output file path (e.g. `"report.docx"`)
41
+ * @returns A promise that resolves when the file has been written
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * import { saveDocument } from 'docx-kit/node'
46
+ *
47
+ * const doc = await compileDocument({ ... })
48
+ * await saveDocument(doc, 'report.docx')
49
+ * ```
50
+ */
51
+ async function saveDocument(doc, filename) {
52
+ const { writeFile } = await import("node:fs/promises");
53
+ await writeFile(filename, await Packer.toBuffer(doc));
54
+ }
55
+ //#endregion
56
+ //#region src/node.ts
57
+ /**
58
+ * docx-kit — Node.js platform entry.
59
+ *
60
+ * Import from 'docx-kit/node'.
61
+ *
62
+ * @module docx-kit/node
63
+ * @packageDocumentation
64
+ */
65
+ const BUILTIN_PRESETS = new Map([
66
+ [academicPreset.id, academicPreset],
67
+ [classicPreset.id, classicPreset],
68
+ [modernPreset.id, modernPreset]
69
+ ]);
70
+ const PRESET_LIST = [
71
+ classicPreset,
72
+ modernPreset,
73
+ academicPreset
74
+ ];
75
+ function usePreset(id) {
76
+ return BUILTIN_PRESETS.get(id);
77
+ }
78
+ const BUILTIN_THEMES = new Map([
79
+ [minimalTheme.id, minimalTheme],
80
+ [oceanTheme.id, oceanTheme],
81
+ [warmTheme.id, warmTheme]
82
+ ]);
83
+ const THEME_LIST = [
84
+ minimalTheme,
85
+ oceanTheme,
86
+ warmTheme
87
+ ];
88
+ function useTheme(id) {
89
+ return BUILTIN_THEMES.get(id);
90
+ }
91
+ //#endregion
92
+ export { BUILTIN_PRESETS, BUILTIN_THEMES, PRESET_LIST, THEME_LIST, academicPreset, badgePlugin, calloutPlugin, changelogPlugin, classicPreset, codeBlockPlugin, coverPagePlugin, dataTablePlugin, dataUrlToUint8Array, dividerPlugin, invoicePlugin, letterheadPlugin, meetingMinutesPlugin, minimalTheme, modernPreset, oceanTheme, pageNumberPlugin, propertyTablePlugin, qrcodePlugin, saveDocument, signatureBlockPlugin, timelinePlugin, tocPlugin, usePreset, useTheme, warmTheme, watermarkPlugin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "docx-kit",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "description": "CSS-like DOCX API Kit — a type-safe, plugin-extensible DOCX generation library built on dolanmiu/docx.",
6
6
  "keywords": [
7
7
  "document",
@@ -21,7 +21,8 @@
21
21
  "homepage": "https://github.com/ntnyq/docx-kit#readme",
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "ntnyq/docx-kit"
24
+ "url": "https://github.com/ntnyq/docx-kit",
25
+ "directory": "packages/docx-kit"
25
26
  },
26
27
  "bugs": {
27
28
  "url": "https://github.com/ntnyq/docx-kit/issues"
@@ -32,13 +33,41 @@
32
33
  "types": "./dist/browser.d.ts",
33
34
  "default": "./dist/browser.js"
34
35
  },
36
+ "./ai": {
37
+ "types": "./dist/ai-proxy.d.ts",
38
+ "default": "./dist/ai-proxy.js"
39
+ },
35
40
  "./browser": {
36
41
  "types": "./dist/browser.d.ts",
37
42
  "default": "./dist/browser.js"
38
43
  },
44
+ "./loader": {
45
+ "types": "./dist/loader-proxy.d.ts",
46
+ "default": "./dist/loader-proxy.js"
47
+ },
48
+ "./loader/browser": {
49
+ "types": "./dist/loader-proxy.d.ts",
50
+ "default": "./dist/loader-proxy.js"
51
+ },
52
+ "./loader/node": {
53
+ "types": "./dist/loader-proxy.d.ts",
54
+ "default": "./dist/loader-proxy.js"
55
+ },
56
+ "./mcp": {
57
+ "types": "./dist/mcp-proxy.d.ts",
58
+ "default": "./dist/mcp-proxy.js"
59
+ },
39
60
  "./node": {
40
- "types": "./dist/node.d.mts",
41
- "default": "./dist/node.mjs"
61
+ "types": "./dist/node.d.ts",
62
+ "default": "./dist/node.js"
63
+ },
64
+ "./pdk": {
65
+ "types": "./dist/pdk-proxy.d.ts",
66
+ "default": "./dist/pdk-proxy.js"
67
+ },
68
+ "./registry": {
69
+ "types": "./dist/registry-proxy.d.ts",
70
+ "default": "./dist/registry-proxy.js"
42
71
  }
43
72
  },
44
73
  "main": "./dist/browser.js",
@@ -51,56 +80,43 @@
51
80
  },
52
81
  "sideEffects": false,
53
82
  "peerDependencies": {
54
- "echarts": ">=5.0.0",
55
- "highlight.js": ">=11.0.0",
56
- "qrcode": ">=1.5.0"
57
- },
58
- "peerDependenciesMeta": {
59
- "echarts": {
60
- "optional": true
61
- },
62
- "highlight.js": {
63
- "optional": true
64
- },
65
- "qrcode": {
66
- "optional": true
67
- }
68
- },
69
- "dependencies": {
70
83
  "docx": "^9.7.1"
71
84
  },
72
- "devDependencies": {
73
- "@ntnyq/eslint-config": "^6.1.5",
74
- "@ntnyq/prettier-config": "^3.0.1",
75
- "@types/node": "^25.9.2",
76
- "@types/qrcode": "^1.5.6",
77
- "bumpp": "^11.1.0",
78
- "echarts": "^6.1.0",
79
- "eslint": "^10.4.1",
80
- "husky": "^9.1.7",
81
- "nano-staged": "^1.0.2",
82
- "npm-run-all2": "^9.0.1",
83
- "prettier": "^3.8.4",
84
- "qrcode": "^1.5.4",
85
- "tsdown": "^0.22.2",
86
- "typescript": "^6.0.3",
87
- "vite": "^8.0.16",
88
- "vitest": "^4.1.8"
89
- },
90
- "nano-staged": {
91
- "*.{js,ts,mjs,cjs,md,vue,yml,yaml,toml,json}": "eslint --fix",
92
- "*.{css,scss,html}": "prettier -uw"
85
+ "dependencies": {
86
+ "@docxkit/ai": "0.3.0",
87
+ "@docxkit/loader": "0.3.0",
88
+ "@docxkit/mcp": "0.3.0",
89
+ "@docxkit/plugin-code-block": "0.3.0",
90
+ "@docxkit/core": "0.3.0",
91
+ "@docxkit/plugin-callout": "0.3.0",
92
+ "@docxkit/pdk": "0.3.0",
93
+ "@docxkit/plugin-invoice": "0.3.0",
94
+ "@docxkit/plugin-badge": "0.3.0",
95
+ "@docxkit/plugin-cover-page": "0.3.0",
96
+ "@docxkit/plugin-changelog": "0.3.0",
97
+ "@docxkit/plugin-divider": "0.3.0",
98
+ "@docxkit/plugin-letterhead": "0.3.0",
99
+ "@docxkit/plugin-echarts": "0.3.0",
100
+ "@docxkit/plugin-property-table": "0.3.0",
101
+ "@docxkit/plugin-timeline": "0.3.0",
102
+ "@docxkit/plugin-meeting-minutes": "0.3.0",
103
+ "@docxkit/plugin-signature-block": "0.3.0",
104
+ "@docxkit/plugin-watermark": "0.3.0",
105
+ "@docxkit/preset-academic": "0.3.0",
106
+ "@docxkit/plugin-data-table": "0.3.0",
107
+ "@docxkit/plugin-qrcode": "0.3.0",
108
+ "@docxkit/plugin-toc": "0.3.0",
109
+ "@docxkit/preset-classic": "0.3.0",
110
+ "@docxkit/plugin-page-number": "0.3.0",
111
+ "@docxkit/theme-ocean": "0.3.0",
112
+ "@docxkit/renderer": "0.3.0",
113
+ "@docxkit/theme-warm": "0.3.0",
114
+ "@docxkit/preset-modern": "0.3.0",
115
+ "@docxkit/theme-minimal": "0.3.0",
116
+ "@docxkit/registry": "0.3.0"
93
117
  },
94
118
  "scripts": {
95
119
  "build": "tsdown",
96
- "dev": "tsdown --watch",
97
- "docs:build": "pnpm -C docs run build",
98
- "docs:dev": "pnpm -C docs run dev",
99
- "lint": "eslint",
100
- "release": "run-s release:check release:version",
101
- "release:check": "run-s lint typecheck test",
102
- "release:version": "bumpp",
103
- "test": "vitest",
104
- "typecheck": "tsc --noEmit"
120
+ "dev": "tsdown --watch"
105
121
  }
106
122
  }