Files
docx/package.json
T
DolanandClaude Opus 5.5 ea08b9677c feat: write macro-enabled documents with VBA macros, from docx/macros (#471) (#3791)
* feat: write macro-enabled documents with VBA macros, from docx/macros (#471)

A document's macros, the macros option, make it a macro-enabled
document (.docm): its main part has the macro-enabled content type, it
has the VBA project, word/vbaProject.bin, and Packer gives it a .docm's
MIME type. The events of the document the macros handle, such as
Document_Open, are listed in word/vbaData.xml, as Word only runs the
handlers of the events listed there.

createMacros, in a new entry, docx/macros, writes the macros from VBA
code: ThisDocument's, modules and class modules. It writes the VBA
project as [MS-OVBA] describes, in a compound file ([MS-CFB]), without
a compiled cache, so Word compiles the code when it first runs it, and
lists the events ThisDocument has handlers for. A vbaProject.bin from a
.docm Word saved goes in macros too, with the events it handles.

Checked in Word for Mac 16.114: Document_Open runs when the document
opens, and so do macros in modules that use class modules and Office's
library. LibreOffice imports the modules, and the Open XML SDK validator
passes the demos for each version of Office since 2010. The demos
workflow now validates a .docm as it does a .docx.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix: give a character beyond U+FFFF as two ChrW in createMacros' error

createMacros' error for a character Windows-1252 doesn't have said to
write it with ChrW and its code point, such as ChrW(&H1F600) for an
emoji. ChrW only takes a UTF-16 code unit, up to &HFFFF, so that fails
in Word. The error now gives one ChrW for each code unit: the surrogate
pair, ChrW(&HD83D) & ChrW(&HDE00), which Word for Mac turns into the
emoji. The docs say so too.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say how to run the macros of a .docm downloaded in Word for Windows

The macros docs said Word asks whether to enable a .docm's macros when
it opens. Word for Windows doesn't for a file from the internet, such
as a .docm a web page made with docx and the browser downloaded: it
blocks its macros without an Enable Content button. The docs now say to
unblock the file in its Properties, that an organization's policy can
still block macros, and that Word for Mac isn't affected.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 00:13:28 +01:00

219 lines
7.1 KiB
JSON

{
"name": "docx",
"version": "9.12.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"
}
},
"./layout": {
"import": {
"types": "./dist/layout.d.ts",
"default": "./dist/layout.mjs"
},
"require": {
"types": "./dist/layout.d.cts",
"default": "./dist/layout.cjs"
}
},
"./html": {
"import": {
"types": "./dist/html.d.ts",
"default": "./dist/html.mjs"
},
"require": {
"types": "./dist/html.d.cts",
"default": "./dist/html.cjs"
}
},
"./macros": {
"import": {
"types": "./dist/macros.d.ts",
"default": "./dist/macros.mjs"
},
"require": {
"types": "./dist/macros.d.cts",
"default": "./dist/macros.cjs"
}
}
},
"typesVersions": {
"*": {
"shapes": [
"./dist/shapes.d.ts"
],
"watermarks": [
"./dist/watermarks.d.ts"
],
"charts": [
"./dist/charts.d.ts"
],
"math": [
"./dist/math.d.ts"
],
"layout": [
"./dist/layout.d.ts"
],
"html": [
"./dist/html.d.ts"
],
"macros": [
"./dist/macros.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 && vite build --config vite.entries.config.ts --mode layout && vite build --config vite.entries.config.ts --mode html && vite build --config vite.entries.config.ts --mode macros",
"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 src/layout/index.ts src/html/index.ts src/macros/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"
},
"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/pngjs": "^6.0.5",
"@types/unzipper": "^0.10.4",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"@typescript/native": "npm:typescript@7.0.2",
"@vitest/coverage-v8": "^5.0.2",
"@vitest/ui": "^5.0.2",
"cspell": "^10.0.0",
"css-select": "^7.0.0",
"css-what": "^8.0.0",
"docsify-cli": "^5.0.0",
"domhandler": "^6.0.1",
"eslint": "^10.11.0",
"eslint-import-resolver-typescript": "^4.3.2",
"eslint-plugin-functional": "^10.0.1",
"eslint-plugin-import-x": "^4.17.1",
"eslint-plugin-jsdoc": "^65.0.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-unicorn": "^78.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",
"parse5": "^8.0.1",
"parse5-htmlparser2-tree-adapter": "^8.0.1",
"pixelmatch": "^8.0.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": "npm:@typescript/typescript6@6.0.2",
"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"
}
}