mirror of
https://github.com/dolanmiu/docx.git
synced 2026-11-30 16:47:55 +01:00
* feat: live examples in the docs, which run, draw the document next to the code, and can be edited and downloaded The docs' code examples were plain snippets, often fragments that couldn't run. A code block marked ```ts live is now an example readers can see and change: the page runs it with docx, draws the document it makes next to the code with docx-preview, and offers the .docx to download. Clicking the code opens an editor (Monaco) that knows docx's types, the pages are drawn again as the code changes, and View closes the editor. Split, Code and Preview show the code and the pages side by side, or one of them. The demos a page includes are live too. Every example in the docs that builds or patches a document is now live: 443 of them, each a whole file with its imports, so it runs as written. Code about other things, such as installing, bundlers or servers, stays plain. Running them showed docs that were wrong, fixed here: - Landscape: docx swaps a landscape page's width and height itself, so the docs' swapped sizes made a tall page marked as landscape - Comments: `comments.children` takes plain objects, not `new Comment(...)` - Custom properties are text only - APIs that no longer exist: MathText, Row, `.then` on Packer.toStream, patchDocument(buffer, ...), createParagraph().heading1(), a border's `value`, TextRun's `.break()` - The templates and patcher examples read files that aren't in the repository. They now patch the templates in demo/assets, or make their own `npm run build.docs` copies docx's browser builds into docs/live-examples/lib, so the docs use the docx they describe, and the Pages workflow runs it. The folder is gitignored, and cspell and ESLint skip it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ * docs: the bullet examples draw a bullet, and the patcher's usage writes the patched document "ὠ" is U+1F60, a Greek omega, since \u takes four hex digits, so the two live bullet examples on the numbering page drew it as each item's bullet. They use "•" now. The patcher's usage example now awaits patchDocument and writes the document it makes, as the example after it does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
178 lines
5.6 KiB
JSON
178 lines
5.6 KiB
JSON
{
|
|
"name": "docx",
|
|
"version": "9.8.0",
|
|
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",
|
|
"type": "module",
|
|
"main": "dist/index.umd.cjs",
|
|
"module": "./dist/index.mjs",
|
|
"types": "./dist/index.d.ts",
|
|
"exports": {
|
|
".": {
|
|
"import": {
|
|
"types": "./dist/index.d.ts",
|
|
"default": "./dist/index.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/index.d.cts",
|
|
"default": "./dist/index.cjs"
|
|
}
|
|
},
|
|
"./shapes": {
|
|
"import": {
|
|
"types": "./dist/shapes.d.ts",
|
|
"default": "./dist/shapes.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/shapes.d.cts",
|
|
"default": "./dist/shapes.cjs"
|
|
}
|
|
},
|
|
"./watermarks": {
|
|
"import": {
|
|
"types": "./dist/watermarks.d.ts",
|
|
"default": "./dist/watermarks.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/watermarks.d.cts",
|
|
"default": "./dist/watermarks.cjs"
|
|
}
|
|
},
|
|
"./charts": {
|
|
"import": {
|
|
"types": "./dist/charts.d.ts",
|
|
"default": "./dist/charts.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/charts.d.cts",
|
|
"default": "./dist/charts.cjs"
|
|
}
|
|
},
|
|
"./math": {
|
|
"import": {
|
|
"types": "./dist/math.d.ts",
|
|
"default": "./dist/math.mjs"
|
|
},
|
|
"require": {
|
|
"types": "./dist/math.d.cts",
|
|
"default": "./dist/math.cjs"
|
|
}
|
|
}
|
|
},
|
|
"typesVersions": {
|
|
"*": {
|
|
"shapes": [
|
|
"./dist/shapes.d.ts"
|
|
],
|
|
"watermarks": [
|
|
"./dist/watermarks.d.ts"
|
|
],
|
|
"charts": [
|
|
"./dist/charts.d.ts"
|
|
],
|
|
"math": [
|
|
"./dist/math.d.ts"
|
|
]
|
|
}
|
|
},
|
|
"files": [
|
|
"dist"
|
|
],
|
|
"scripts": {
|
|
"build": "tsc && vite build && vite build --config vite.entries.config.ts --mode shapes && vite build --config vite.entries.config.ts --mode watermarks && vite build --config vite.entries.config.ts --mode charts && vite build --config vite.entries.config.ts --mode math",
|
|
"test": "vitest --ui --coverage",
|
|
"test:ci": "vitest run --coverage",
|
|
"prepublishOnly": "npm run build --omit=dev",
|
|
"lint": "eslint --config eslint.config.ts",
|
|
"predemo": "npm run build",
|
|
"demo": "tsx ./demo/index.ts",
|
|
"typedoc": "typedoc src/index.ts src/shapes/index.ts src/watermarks/index.ts src/charts/index.ts src/math/index.ts --tsconfig tsconfig.typedoc.json",
|
|
"prettier": "prettier -l \"{src,scripts,demo,docs}/**/*.{ts,html,md}\"",
|
|
"prettier:fix": "npm run prettier -- --write",
|
|
"cspell": "cspell \"{src,demo,docs,scripts}/**/*.{ts,scss,html,md}\" && cspell \"./*.*\"",
|
|
"build.docs": "npm run build && mkdir -p docs/live-examples/lib && cp dist/*.iife.js dist/*.d.ts docs/live-examples/lib/",
|
|
"serve.docs": "cd docs && docsify serve",
|
|
"extract": "tsx scripts/extract-document.ts",
|
|
"check-api": "tsx scripts/check-api.ts",
|
|
"run-ts": "tsx"
|
|
},
|
|
"pre-commit": [
|
|
"prettier",
|
|
"lint"
|
|
],
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "git+https://github.com/dolanmiu/docx.git"
|
|
},
|
|
"keywords": [
|
|
"docx",
|
|
"office",
|
|
"word",
|
|
"generate",
|
|
"creator",
|
|
"create",
|
|
"document",
|
|
"doc",
|
|
"officegen",
|
|
"clippy"
|
|
],
|
|
"dependencies": {
|
|
"@types/node": "^26.6.2",
|
|
"hash.js": "^1.1.7",
|
|
"jszip": "^3.10.1",
|
|
"nanoid": "^6.0.1",
|
|
"xml": "^1.0.1",
|
|
"xml-js": "^1.6.8"
|
|
},
|
|
"author": "Dolan Miu",
|
|
"license": "MIT",
|
|
"bugs": {
|
|
"url": "https://github.com/dolanmiu/docx/issues"
|
|
},
|
|
"homepage": "https://docx.js.org",
|
|
"devDependencies": {
|
|
"@eslint/js": "^10.0.1",
|
|
"@microsoft/api-extractor": "^7.58.7",
|
|
"@types/inquirer": "^9.0.3",
|
|
"@types/pngjs": "^6.0.5",
|
|
"@types/unzipper": "^0.10.4",
|
|
"@types/xml": "^1.0.8",
|
|
"@typescript-eslint/eslint-plugin": "^8.8.1",
|
|
"@typescript-eslint/parser": "^8.8.1",
|
|
"@vitest/coverage-v8": "^5.0.2",
|
|
"@vitest/ui": "^5.0.2",
|
|
"cspell": "^10.0.0",
|
|
"docsify-cli": "^5.0.0",
|
|
"eslint": "^10.11.0",
|
|
"eslint-import-resolver-typescript": "^4.3.2",
|
|
"eslint-plugin-functional": "^9.0.3",
|
|
"eslint-plugin-import-x": "^4.17.1",
|
|
"eslint-plugin-jsdoc": "^64.5.4",
|
|
"eslint-plugin-no-null": "^1.0.2",
|
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
"eslint-plugin-unicorn": "^76.0.0",
|
|
"execa": "^10.0.1",
|
|
"glob": "^13.0.3",
|
|
"globals": "^17.12.0",
|
|
"inquirer": "^14.0.0",
|
|
"jiti": "^2.3.3",
|
|
"jsdom": "^30.1.0",
|
|
"pixelmatch": "^7.2.0",
|
|
"pngjs": "^7.0.0",
|
|
"pre-commit": "^2.0.0",
|
|
"prettier": "^3.1.1",
|
|
"tsconfig-paths": "^4.0.0",
|
|
"tsx": "^4.7.0",
|
|
"typedoc": "^0.28.2",
|
|
"typescript": "5.9.3",
|
|
"typescript-eslint": "^8.10.0",
|
|
"unzipper": "^0.12.3",
|
|
"vite": "^8.0.0",
|
|
"vite-plugin-dts": "^5.0.1",
|
|
"vite-plugin-node-polyfills": "^0.28.0",
|
|
"vitest": "^5.0.2"
|
|
},
|
|
"engines": {
|
|
"node": ">=10"
|
|
}
|
|
}
|