# UnifiedWriter v5.56.0 DOCM / VBA / Script Engine Foundation

## Scope

v5.56.0 adds the first DOCM and macro compatibility layer for UnifiedWriter.
The purpose is not to emulate the Windows/Office host environment. The purpose
is to preserve macro-enabled Word documents and convert browser-safe document
editing macros into UnifiedWriter JavaScript macros where practical.

## Implemented in v5.53.0-v5.56.0

- DOCM import path with `vbaProject.bin` preservation.
- DOCM export path that restores preserved macro parts into an OOXML package.
- UWPSX macro metadata package:
  - `macros/manifest.json`
  - `macros/security.json`
  - `macros/scripts.json`
  - `macros/vba/modules.json`
  - `macros/vba/compatibility-report.json`
  - `macros/vba/preserved-parts.json`
  - `macros/vba/vbaProject.bin.base64`
  - `macros/execution-log.json`
- Browser-safe macro diagnostics.
- UnifiedWriter JavaScript Script Engine foundation.
- VBA-to-JS partial translator for document editing statements.
- Development menu entries for Macro diagnostics, VBA viewer, Script Engine and VBA-to-JS translation.

## Explicitly out of scope

The following VBA features are OS/Office host automation and are intentionally
unsupported in UnifiedWriter:

- FileSystemObject
- Shell
- external DLL calls
- Win32 API calls
- ActiveX
- COM Automation / COM integration
- external application automation
- direct Host OS file-system operations

These APIs are classified as unsupported by macro diagnostics and are not
translated or executed.

## Supported direction

The supported compatibility target is browser-safe Word document automation:

- Document
- Selection
- Range
- Paragraph
- Table / Cell / Row / Column
- Font / ParagraphFormat / Style
- InlineShape / Image
- Header / Footer
- Footnote / Endnote
- Comment
- Bookmark
- Page setup
- safe document event equivalents

## Security model

Macro execution is disabled by default. A user/session must explicitly allow
execution in the Script Engine dialog. Even then, the runtime blocks browser and
OS-level escape APIs such as `window`, `document`, `fetch`, `XMLHttpRequest`,
`eval`, `Function`, `localStorage`, `indexedDB`, `FileReader`, `ActiveXObject`,
`CreateObject`, `Shell`, and `FileSystemObject`.

The runtime context exposes only a limited UnifiedWriter document API through
`ctx.document`, `ctx.selection`, and future document-model wrappers.

## Notes

Full MS-OVBA decompression and complete VBA syntax coverage are future work.
The current code viewer includes a best-effort printable stream scanner so that
macro diagnostics can detect common document-object model calls and unsafe OS
APIs while preserving the original `vbaProject.bin` losslessly.
