bun-docx 0.1.1 → 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/README.md +16 -14
- package/dist/index.js +1773 -1170
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,6 +44,9 @@ docx insert FILE --after p3 --runs '[{"type":"text","text":"X","bold":true}]'
|
|
|
44
44
|
docx edit FILE --at p3 --text "..." | --runs '[...]'
|
|
45
45
|
docx delete FILE --at p3
|
|
46
46
|
|
|
47
|
+
docx find FILE QUERY [--regex] [--ignore-case] [--all] [--nth N]
|
|
48
|
+
docx replace FILE PATTERN REPLACEMENT [--regex] [--ignore-case] [--all] [--limit N] [--dry-run]
|
|
49
|
+
|
|
47
50
|
docx comments add FILE --range p3:5-20 --text "..." [--author NAME]
|
|
48
51
|
docx comments reply FILE --to c0 --text "..."
|
|
49
52
|
docx comments resolve FILE --id c0 [--unset]
|
|
@@ -56,8 +59,8 @@ docx images extract FILE --to ./media [--id imgN]
|
|
|
56
59
|
docx images replace FILE --at imgN --with ./new.png
|
|
57
60
|
|
|
58
61
|
docx track-changes FILE on|off
|
|
59
|
-
docx schema [--ts]
|
|
60
|
-
docx locators [--json]
|
|
62
|
+
docx info schema [--ts]
|
|
63
|
+
docx info locators [--json]
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
Every command has `--help`. All mutating commands accept `--dry-run`. JSON output by default for `read` and `*.list`; structured `{ok, code, error, hint}` on failure.
|
|
@@ -72,7 +75,7 @@ tN table N; tN:rRcC for cell at row R, col C
|
|
|
72
75
|
cN, imgN comment / image ids
|
|
73
76
|
```
|
|
74
77
|
|
|
75
|
-
Run `docx locators` for the full reference.
|
|
78
|
+
Run `docx info locators` for the full reference.
|
|
76
79
|
|
|
77
80
|
## Development
|
|
78
81
|
|
|
@@ -109,8 +112,7 @@ src/
|
|
|
109
112
|
comments/ # add | reply | resolve | delete | restore | list
|
|
110
113
|
images/ # list | extract | replace
|
|
111
114
|
track-changes/ # FILE on|off
|
|
112
|
-
|
|
113
|
-
locators-cmd/ # grammar reference
|
|
115
|
+
info/ # schema | locators (reference output)
|
|
114
116
|
core/
|
|
115
117
|
package/ # JSZip open/close, named-part read/write
|
|
116
118
|
parser/ # XmlNode class + parse/serialize + JSX factory
|
|
@@ -118,13 +120,13 @@ src/
|
|
|
118
120
|
ast/ # types + DocView + XML→AST reader
|
|
119
121
|
locators/ # parse "p3:5-20" + resolve to refs
|
|
120
122
|
tests/
|
|
121
|
-
core/, cli/, integration/
|
|
122
|
-
fixtures/
|
|
123
|
+
core/, cli/, integration/
|
|
124
|
+
fixtures/
|
|
123
125
|
```
|
|
124
126
|
|
|
125
127
|
## How It Works
|
|
126
128
|
|
|
127
|
-
**In-place XML mutation.** The AST returned by `read` is a
|
|
129
|
+
**In-place XML mutation.** The AST returned by `read` is a _view_ over the parsed XML tree, not a separate model. When you `edit` or `comments add`, we mutate the underlying XML nodes directly and serialize back. Anything we don't model in the AST (custom styles, theme colors, schema extensions) survives because we never re-emit untouched regions.
|
|
128
130
|
|
|
129
131
|
**JSX for emitters.** Constructing OOXML fragments imperatively (`<w:rPr>` → `<w:b/>` → `<w:color w:val="800080"/>`) gets verbose. We write emitters in JSX with a custom factory: `<w.rPr><w.b/><w.color w-val="800080"/></w.rPr>` becomes the right `XmlNode` tree. Component names are PascalCase (`<Paragraph>`, `<RunProperties>`); they return `XmlNode | null` so empty wrappers get omitted automatically.
|
|
130
132
|
|
|
@@ -140,11 +142,11 @@ tests/
|
|
|
140
142
|
|
|
141
143
|
GitHub Actions (`.github/workflows/ci.yml`) runs four jobs on push to `main` and on PRs:
|
|
142
144
|
|
|
143
|
-
| Job
|
|
144
|
-
|
|
145
|
-
| `check`
|
|
146
|
-
| `unit-tests`
|
|
147
|
-
| `integration-tests` | Installs LibreOffice, runs `bun run test:integration`
|
|
148
|
-
| `build-binary`
|
|
145
|
+
| Job | What |
|
|
146
|
+
| ------------------- | ----------------------------------------------------------- |
|
|
147
|
+
| `check` | `biome check . && knip-bun && tsc --noEmit` |
|
|
148
|
+
| `unit-tests` | `bun run test:unit` (core + cli, fast) |
|
|
149
|
+
| `integration-tests` | Installs LibreOffice, runs `bun run test:integration` |
|
|
150
|
+
| `build-binary` | Smoke-builds via `bun build --compile` and runs `--version` |
|
|
149
151
|
|
|
150
152
|
`.github/workflows/release.yml` triggers on `v*` tags, matrix-builds the five binaries, and uploads them to a GitHub Release via [`softprops/action-gh-release`](https://github.com/softprops/action-gh-release).
|