@docx-editor.dev/core 0.0.1 → 2.1.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.
Files changed (116) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +91 -2
  3. package/THIRD_PARTY_NOTICES.md +18 -0
  4. package/dist/automation.cjs +1 -0
  5. package/dist/automation.d.cts +74 -0
  6. package/dist/automation.d.ts +74 -0
  7. package/dist/automation.js +1 -0
  8. package/dist/binding.cjs +1 -0
  9. package/dist/binding.d.cts +88 -0
  10. package/dist/binding.d.ts +88 -0
  11. package/dist/binding.js +1 -0
  12. package/dist/chunk-2DTQDAN7.js +2 -0
  13. package/dist/chunk-3JKQE4QJ.cjs +2 -0
  14. package/dist/chunk-4WWEDTTE.js +2 -0
  15. package/dist/chunk-6WIIHJFY.js +1 -0
  16. package/dist/chunk-7VQ7YLW3.cjs +1 -0
  17. package/dist/chunk-BS554B6D.cjs +2 -0
  18. package/dist/chunk-BZK64YU3.cjs +10 -0
  19. package/dist/chunk-CZFUMACF.cjs +12 -0
  20. package/dist/chunk-GQQOL4PV.js +1 -0
  21. package/dist/chunk-HBL3NNH5.cjs +1 -0
  22. package/dist/chunk-JQFDLZXQ.cjs +2 -0
  23. package/dist/chunk-O2WQY7IT.cjs +5 -0
  24. package/dist/chunk-PC76F2HR.cjs +1 -0
  25. package/dist/chunk-QRAUDDVY.js +2 -0
  26. package/dist/chunk-REZUWYB7.js +1 -0
  27. package/dist/chunk-STCITBJK.js +12 -0
  28. package/dist/chunk-TBBXCC7D.js +5 -0
  29. package/dist/chunk-TSXT537P.cjs +12 -0
  30. package/dist/chunk-WOGYVM3W.js +12 -0
  31. package/dist/chunk-Y7TA7TPF.js +10 -0
  32. package/dist/content-control-walk-CbTqHq6O.d.cts +56 -0
  33. package/dist/content-control-walk-D06GijR0.d.ts +56 -0
  34. package/dist/contracts/document.cjs +1 -0
  35. package/dist/contracts/document.d.cts +246 -0
  36. package/dist/contracts/document.d.ts +246 -0
  37. package/dist/contracts/document.js +0 -0
  38. package/dist/contracts/editor.cjs +1 -0
  39. package/dist/contracts/editor.d.cts +11 -0
  40. package/dist/contracts/editor.d.ts +11 -0
  41. package/dist/contracts/editor.js +1 -0
  42. package/dist/contracts/interaction.cjs +1 -0
  43. package/dist/contracts/interaction.d.cts +11 -0
  44. package/dist/contracts/interaction.d.ts +11 -0
  45. package/dist/contracts/interaction.js +0 -0
  46. package/dist/contracts/modules.cjs +1 -0
  47. package/dist/contracts/modules.d.cts +117 -0
  48. package/dist/contracts/modules.d.ts +117 -0
  49. package/dist/contracts/modules.js +1 -0
  50. package/dist/contracts/types.cjs +1 -0
  51. package/dist/contracts/types.d.cts +452 -0
  52. package/dist/contracts/types.d.ts +452 -0
  53. package/dist/contracts/types.js +0 -0
  54. package/dist/custom-node-writes-YqISlSRl.d.cts +885 -0
  55. package/dist/custom-node-writes-ttKuYd0M.d.ts +885 -0
  56. package/dist/editor-B93PggnR.d.cts +1690 -0
  57. package/dist/editor-CFsSrxGR.d.ts +1690 -0
  58. package/dist/editor.cjs +1 -0
  59. package/dist/editor.css +7106 -0
  60. package/dist/editor.d.cts +271 -0
  61. package/dist/editor.d.ts +271 -0
  62. package/dist/editor.js +1 -0
  63. package/dist/hf-references-BdjsQNE_.d.ts +71 -0
  64. package/dist/hf-references-CgEOSw3i.d.cts +71 -0
  65. package/dist/image-resources-C_YnqPhn.d.ts +203 -0
  66. package/dist/image-resources-DwpNnTg3.d.cts +203 -0
  67. package/dist/index-BjZelfWL.d.cts +2532 -0
  68. package/dist/index-DP1yJJ3R.d.ts +2532 -0
  69. package/dist/index.cjs +1 -0
  70. package/dist/index.d.cts +22 -0
  71. package/dist/index.d.ts +22 -0
  72. package/dist/index.js +1 -0
  73. package/dist/layout.cjs +1 -0
  74. package/dist/layout.d.cts +2366 -0
  75. package/dist/layout.d.ts +2366 -0
  76. package/dist/layout.js +1 -0
  77. package/dist/note-nodes-BPSTVDMr.d.ts +108 -0
  78. package/dist/note-nodes-C6DLxlvj.d.cts +108 -0
  79. package/dist/ooxml-package-CR5us6ad.d.cts +354 -0
  80. package/dist/ooxml-package-D_CtywTW.d.ts +354 -0
  81. package/dist/ooxml-tree-BU0e3DVi.d.cts +871 -0
  82. package/dist/ooxml-tree-BU0e3DVi.d.ts +871 -0
  83. package/dist/output.cjs +1 -0
  84. package/dist/output.d.cts +158 -0
  85. package/dist/output.d.ts +158 -0
  86. package/dist/output.js +1 -0
  87. package/dist/protocol-BWVA3Q1p.d.ts +1255 -0
  88. package/dist/protocol-FAz_nPm_.d.cts +1255 -0
  89. package/dist/review-reads-CsoXSvUg.d.ts +401 -0
  90. package/dist/review-reads-qW0jvdF1.d.cts +401 -0
  91. package/dist/review-support-D64Wu236.d.cts +358 -0
  92. package/dist/review-support-nsLXC9jf.d.ts +358 -0
  93. package/dist/revision-projection-72ZApe-g.d.cts +84 -0
  94. package/dist/revision-projection-DHAkcD_L.d.ts +84 -0
  95. package/dist/semantic-cell-selection-D_8RbPII.d.ts +427 -0
  96. package/dist/semantic-cell-selection-DwLB71fF.d.cts +427 -0
  97. package/dist/semantic-interaction-CXH2wFqi.d.ts +187 -0
  98. package/dist/semantic-interaction-DqcEonqD.d.cts +187 -0
  99. package/dist/semantic-paint-drawings-B5Wk2so5.d.ts +21 -0
  100. package/dist/semantic-paint-drawings-x8g44lD_.d.cts +21 -0
  101. package/dist/semantic-records-COVFW5aS.d.cts +1505 -0
  102. package/dist/semantic-records-zTC0_1zi.d.ts +1505 -0
  103. package/dist/shaped-measurer-AFnFxoot.d.cts +613 -0
  104. package/dist/shaped-measurer-CZXL-a6v.d.ts +613 -0
  105. package/dist/store.cjs +1 -0
  106. package/dist/store.d.cts +2153 -0
  107. package/dist/store.d.ts +2153 -0
  108. package/dist/store.js +1 -0
  109. package/dist/tree-op-types-DWLCllG7.d.ts +1486 -0
  110. package/dist/tree-op-types-UOXlRUqQ.d.cts +1486 -0
  111. package/dist/tree-session-BtVFXsF6.d.ts +580 -0
  112. package/dist/tree-session-DxIOHUOD.d.cts +580 -0
  113. package/dist/tree-store-B1lEkdXc.d.cts +273 -0
  114. package/dist/tree-store-BscFPB7x.d.ts +273 -0
  115. package/package.json +110 -8
  116. package/index.js +0 -1
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 EigenPal Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,5 +1,94 @@
1
+ <p align="center">
2
+ <a href="https://www.docx-editor.dev/">
3
+ <img src="https://raw.githubusercontent.com/eigenpal/docx-editor/main/.github/assets/header.png" alt="DOCX Editor — .docx in, .docx out. Open source, client-side." width="500" />
4
+ </a>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <a href="https://www.npmjs.com/package/@docx-editor.dev/core"><img src="https://img.shields.io/npm/v/@docx-editor.dev/core.svg?style=flat-square&color=3B5BDB" alt="npm version" /></a>
9
+ <a href="https://www.npmjs.com/package/@docx-editor.dev/core"><img src="https://img.shields.io/npm/dm/@docx-editor.dev/core.svg?style=flat-square&color=3B5BDB" alt="npm downloads" /></a>
10
+ <a href="https://github.com/eigenpal/docx-editor/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache_2.0-blue.svg?style=flat-square&color=3B5BDB" alt="license" /></a>
11
+ <a href="https://www.docx-editor.dev/docs"><img src="https://img.shields.io/badge/Docs-3B5BDB?style=flat-square&logo=readthedocs&logoColor=white" alt="Documentation" /></a>
12
+ </p>
13
+
1
14
  # @docx-editor.dev/core
2
15
 
3
- Placeholder package reserving this name. The published editor currently lives at [`@eigenpal/docx-editor-core`](https://www.npmjs.com/package/@eigenpal/docx-editor-core).
16
+ The engine behind [docx-editor.dev](https://docx-editor.dev). It reads a `.docx` into a
17
+ canonical document tree, lays that tree out into pages, paints them, and writes the tree back
18
+ to OOXML. No framework dependency and no UI.
19
+
20
+ Most apps never install this directly — [`@docx-editor.dev/react`](https://www.npmjs.com/package/@docx-editor.dev/react)
21
+ carries it. Reach for it when you are writing your own adapter, or when you need the contract
22
+ types to write a function signature.
23
+
24
+ ```bash
25
+ npm install @docx-editor.dev/core
26
+ ```
27
+
28
+ ## Entry points
29
+
30
+ ```ts
31
+ import { createDocxEditor, loadFonts, WORD_DEFAULT_FONT } from '@docx-editor.dev/core';
32
+ import type { Editor, EditorSnapshot } from '@docx-editor.dev/core';
33
+ ```
34
+
35
+ The root covers most uses: creating an editor, the `Editor` contract it implements, fonts,
36
+ the chrome registry, and the document model types. Subpaths expose the canonical tree, the
37
+ layout pass, and the paint step directly.
38
+
39
+ | Subpath | What's there |
40
+ | ------------------------- | -------------------------------------------------------------------------------------------- |
41
+ | `.` | Create an editor, the contract, fonts, the chrome registry, the document model. |
42
+ | `./editor` | Everything the root re-exports, plus the paginated surface and ruler geometry. |
43
+ | `./contracts/editor` | `Editor`, `EditorCommand`, `EditorQuery`, `EditorSnapshot`, `PageSetup`. |
44
+ | `./contracts/document` | The document-level edit and query vocabulary. |
45
+ | `./contracts/interaction` | Semantic addressing (`SemanticTarget`) and the `InteractionOutcome` an attempt answers with. |
46
+ | `./contracts/types` | Document model types. |
47
+ | `./contracts/modules` | `EditorModule` — the shape `@docx-editor.dev/pro` implements. |
48
+ | `./store` | The canonical tree and its transactional store. |
49
+ | `./layout` | The DOM-free layout pass. |
50
+ | `./output` | Serialization. |
51
+ | `./automation` | The object model behind `@docx-editor.dev/editor-api`. |
52
+ | `./styles/editor.css` | The one editor stylesheet, shared by packaged and custom chrome. |
53
+
54
+ ## Architecture
55
+
56
+ ```
57
+ bytes → bounded OPC/XML read → canonical OOXML tree → layout → painted pages → serialize
58
+ ```
59
+
60
+ There is one document model. The painted pages are the editable surface: they are
61
+ `contenteditable`, but the DOM is a picture. Browser mutations are prevented and re-expressed
62
+ as tree operations, so the browser never invents markup inside your document.
63
+
64
+ Nodes are typed where layout needs them and generic everywhere else, preserving the element
65
+ verbatim. Content the engine does not model is carried rather than dropped, so a document full
66
+ of unknown extensions still opens, edits, and saves.
67
+
68
+ ## Fidelity
69
+
70
+ Everything you do not edit comes back byte for byte, including parts the engine does not model:
71
+ custom XML, embedded fonts, macros, media, unknown extensions. On save, modeled parts are
72
+ re-emitted normalized; everything else is repacked from the original file untouched. Two
73
+ oracles gate this in CI: a canonical fingerprint over the tree, and a save-and-reopen semantic
74
+ digest.
75
+
76
+ ## Untrusted input
77
+
78
+ A `.docx` is a zip of XML that whoever sent it controls end to end. The engine sanitizes at the
79
+ parse boundary: URL allowlisting, entity and zip-bomb limits, recursion and element caps, no
80
+ zero-click external fetches, escaping on the way back out.
81
+
82
+ Anything you render from document data (a font name, a hyperlink target, a comment body) is
83
+ still attacker-controlled at your boundary. Render it as text; do not build markup or URLs
84
+ from it.
85
+
86
+ ## Documentation
87
+
88
+ - [Core overview](https://www.docx-editor.dev/docs/2.x/core)
89
+ - [Architecture](https://www.docx-editor.dev/docs/2.x/core/architecture)
90
+ - [Word fidelity](https://www.docx-editor.dev/docs/2.x/word-fidelity)
91
+
92
+ ## License
4
93
 
5
- See [docx-editor.dev](https://docx-editor.dev/) for docs.
94
+ Apache-2.0
@@ -0,0 +1,18 @@
1
+ # Third-party notices
2
+
3
+ `@docx-editor.dev/core` is distributed under Apache-2.0. Its published bundles also contain
4
+ source from the open-source packages listed below, redistributed here under
5
+ their own licenses, reproduced in full.
6
+
7
+ Those copies are not verbatim. The build inlines, minifies and tree-shakes
8
+ them, and includes only the parts each bundle reaches, so what ships is a
9
+ modified form of the original source.
10
+
11
+ This file covers code copied INTO the published bundles. Packages this one
12
+ declares as `dependencies` or `peerDependencies` are installed separately by
13
+ the consumer and are not repeated here.
14
+
15
+ Generated by `bun run notices:generate` from the build's esbuild metafile.
16
+ Do not edit by hand.
17
+
18
+ No third-party code is bundled into this package.
@@ -0,0 +1 @@
1
+ 'use strict';var chunkPC76F2HR_cjs=require('./chunk-PC76F2HR.cjs'),chunkBZK64YU3_cjs=require('./chunk-BZK64YU3.cjs');var y=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),h=Object.freeze({kind:"body"});function I(e,r={}){let t=chunkBZK64YU3_cjs.wb(e,r.limits??{});if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let a=t.package.parts.get(t.package.mainDocumentPart);if(!a)return {ok:false,reason:"no-main-document-part",detail:t.package.mainDocumentPart};let o=new chunkBZK64YU3_cjs.Af(t.package,chunkBZK64YU3_cjs.Nc(a));return {ok:true,host:chunkPC76F2HR_cjs.g({port:v(o),capabilities:y})}}function T(e,r,t){let a=e.partFor(t);if(!a)return null;let o=chunkBZK64YU3_cjs.Pc(e.currentPackage(),r,a.name);return o?(e.replacePackageShell(o.pkg),o.relationshipId):null}function v(e){let r=true;return {revision:()=>e.packageRevision,currentPackage:()=>r?e.currentPackage():null,apply(t,a=h){if(!r)return {ok:false,reason:"disposed"};let o=t(i=>T(e,i,a));if(o===null)return {ok:false,reason:"unsupported-target"};let n=e.transact(a,i=>{for(let k of o)i.apply(k);});return n.ok?{ok:true,changed:n.change!==null}:{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},applyLifecycle(t){if(!r)return {ok:false,reason:"disposed"};let a=e.applyLifecycleOp(t);return a.ok?{ok:true,changed:a.change!==null}:{ok:false,reason:a.detail?`${a.reason}: ${a.detail}`:a.reason}},applyCommentWrite(t,a){if(!r)return {ok:false,reason:"disposed"};let o=e.resolveStory(a);if(!o.ok)return {ok:false,reason:o.reason};o.store.graftPackage(()=>e.currentPackage());let n=t.kind==="reply"?chunkBZK64YU3_cjs.Bf(o.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date},replyToCommentId:t.parentCommentId}):chunkBZK64YU3_cjs.Cf(o.store,t.commentId,t.resolved);return n.ok?(e.replacePackageShell(o.store.package),{ok:true,changed:true,..."commentId"in n?{commentId:n.commentId}:{}}):{ok:false,reason:n.reason}},applyCustomNodeWrite(t,a){if(!r)return {ok:false,reason:"disposed"};let o=e.resolveStory(a);if(!o.ok)return {ok:false,reason:o.reason};o.store.graftPackage(()=>e.currentPackage());let n=chunkBZK64YU3_cjs.If(o.store,t);return n.ok?(e.replacePackageShell(o.store.package),{ok:true,changed:n.change!==null}):{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},save:()=>r?chunkBZK64YU3_cjs.xb(e.currentPackage()):null,subscribe:t=>e.subscribe(()=>t()),dispose(){r=false;}}}Object.defineProperty(exports,"AUTOMATION_COMMAND_OPERATIONS",{enumerable:true,get:function(){return chunkPC76F2HR_cjs.c}});Object.defineProperty(exports,"AUTOMATION_QUERY_OPERATIONS",{enumerable:true,get:function(){return chunkPC76F2HR_cjs.b}});Object.defineProperty(exports,"AUTOMATION_SOLITARY_OPERATIONS",{enumerable:true,get:function(){return chunkPC76F2HR_cjs.d}});Object.defineProperty(exports,"HEADER_FOOTER_VARIANTS",{enumerable:true,get:function(){return chunkPC76F2HR_cjs.a}});Object.defineProperty(exports,"isAutomationCommand",{enumerable:true,get:function(){return chunkPC76F2HR_cjs.f}});Object.defineProperty(exports,"isSolitaryAutomationCommand",{enumerable:true,get:function(){return chunkPC76F2HR_cjs.e}});exports.SERVER_AUTOMATION_CAPABILITIES=y;exports.createServerAutomationHost=I;
@@ -0,0 +1,74 @@
1
+ import { A as AutomationCapabilities, a as AutomationHost } from './protocol-FAz_nPm_.cjs';
2
+ export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationUnsubscribe, L as AutomationValue, M as isAutomationCommand, N as isSolitaryAutomationCommand } from './protocol-FAz_nPm_.cjs';
3
+ import { H as HeaderFooterVariant } from './hf-references-CgEOSw3i.cjs';
4
+ import { N as NoteKind } from './note-nodes-C6DLxlvj.cjs';
5
+ import { a as OoxmlPackageLimits, b as OoxmlPackageRejection } from './ooxml-package-CR5us6ad.cjs';
6
+ import './ooxml-tree-BU0e3DVi.cjs';
7
+
8
+ /** The variants a section can declare furniture for. */
9
+ declare const HEADER_FOOTER_VARIANTS: readonly HeaderFooterVariant[];
10
+ /**
11
+ * Which story an operation acts on: the main body, one header/footer variant of one section, or
12
+ * one note.
13
+ *
14
+ * A header is addressed by section INDEX plus variant rather than by relationship id, because
15
+ * that is how a caller thinks about it and because a section inheriting its predecessor's header
16
+ * has no relationship of its own to name.
17
+ */
18
+ type AutomationStoryId = {
19
+ readonly kind: 'body';
20
+ } | {
21
+ readonly kind: 'header' | 'footer';
22
+ /** Position of the section in the document, from zero. */
23
+ readonly sectionIndex: number;
24
+ readonly variant: HeaderFooterVariant;
25
+ } | {
26
+ readonly kind: 'note';
27
+ readonly noteKind: NoteKind;
28
+ readonly noteId: number;
29
+ };
30
+
31
+ /** What a headless host can do. It paints nothing, so it claims nothing about painting. */
32
+ declare const SERVER_AUTOMATION_CAPABILITIES: AutomationCapabilities;
33
+ /**
34
+ * Why bytes could not be opened as a document: any bounded-reader rejection, plus the package
35
+ * that parsed but carried no main document part.
36
+ */
37
+ type ServerAutomationHostRejection = OoxmlPackageRejection | 'no-main-document-part';
38
+ /**
39
+ * A host over the opened bytes, or a refusal.
40
+ *
41
+ * A result rather than a throw: these bytes are untrusted input, and a malformed upload should
42
+ * be a value the caller inspects rather than an exception from inside a zip decoder.
43
+ */
44
+ type ServerAutomationHostResult = {
45
+ readonly ok: true;
46
+ readonly host: AutomationHost;
47
+ } | {
48
+ readonly ok: false;
49
+ readonly reason: ServerAutomationHostRejection;
50
+ readonly detail?: string;
51
+ };
52
+ /**
53
+ * How a headless host opens a document. Every field is optional.
54
+ *
55
+ * @public
56
+ */
57
+ interface ServerAutomationHostOptions {
58
+ /**
59
+ * Tighter budgets for the bounded reader — zip ratio, part count, XML depth.
60
+ *
61
+ * Exposed because a server opening documents it did not author is exactly where a caller
62
+ * may want smaller limits than the defaults. Omitted means the engine's own defaults.
63
+ */
64
+ readonly limits?: OoxmlPackageLimits;
65
+ }
66
+ /**
67
+ * Open DOCX bytes into a headless automation host.
68
+ *
69
+ * A typed rejection rather than a throw: every failure here is a property of the FILE, and a
70
+ * caller needs to tell "not a package" from "this package is hostile" from "no body".
71
+ */
72
+ declare function createServerAutomationHost(bytes: Uint8Array, options?: ServerAutomationHostOptions): ServerAutomationHostResult;
73
+
74
+ export { AutomationCapabilities, AutomationHost, type AutomationStoryId, HEADER_FOOTER_VARIANTS, SERVER_AUTOMATION_CAPABILITIES, type ServerAutomationHostOptions, type ServerAutomationHostRejection, type ServerAutomationHostResult, createServerAutomationHost };
@@ -0,0 +1,74 @@
1
+ import { A as AutomationCapabilities, a as AutomationHost } from './protocol-BWVA3Q1p.js';
2
+ export { b as AUTOMATION_COMMAND_OPERATIONS, c as AUTOMATION_QUERY_OPERATIONS, d as AUTOMATION_SOLITARY_OPERATIONS, e as AutomationAlignment, f as AutomationBatchRequest, g as AutomationBatchResponse, h as AutomationChangeEvent, i as AutomationContentControlLock, j as AutomationContentControlRangeLocation, k as AutomationContentControlScope, l as AutomationContentControlSubtype, m as AutomationContentControlValue, n as AutomationError, o as AutomationErrorCode, p as AutomationFontRead, q as AutomationFontWrite, r as AutomationHandle, s as AutomationHandleRef, t as AutomationObjectKind, u as AutomationOperation, v as AutomationOperationKind, w as AutomationOperationResult, x as AutomationPageOrientation, y as AutomationPageSetupRead, z as AutomationPageSetupWrite, B as AutomationParagraphFormatRead, C as AutomationParagraphFormatWrite, D as AutomationParagraphRef, E as AutomationPoint, F as AutomationSaveResult, G as AutomationSearchOptions, H as AutomationSelectionMode, I as AutomationSpan, J as AutomationSpanRef, K as AutomationUnsubscribe, L as AutomationValue, M as isAutomationCommand, N as isSolitaryAutomationCommand } from './protocol-BWVA3Q1p.js';
3
+ import { H as HeaderFooterVariant } from './hf-references-BdjsQNE_.js';
4
+ import { N as NoteKind } from './note-nodes-BPSTVDMr.js';
5
+ import { a as OoxmlPackageLimits, b as OoxmlPackageRejection } from './ooxml-package-D_CtywTW.js';
6
+ import './ooxml-tree-BU0e3DVi.js';
7
+
8
+ /** The variants a section can declare furniture for. */
9
+ declare const HEADER_FOOTER_VARIANTS: readonly HeaderFooterVariant[];
10
+ /**
11
+ * Which story an operation acts on: the main body, one header/footer variant of one section, or
12
+ * one note.
13
+ *
14
+ * A header is addressed by section INDEX plus variant rather than by relationship id, because
15
+ * that is how a caller thinks about it and because a section inheriting its predecessor's header
16
+ * has no relationship of its own to name.
17
+ */
18
+ type AutomationStoryId = {
19
+ readonly kind: 'body';
20
+ } | {
21
+ readonly kind: 'header' | 'footer';
22
+ /** Position of the section in the document, from zero. */
23
+ readonly sectionIndex: number;
24
+ readonly variant: HeaderFooterVariant;
25
+ } | {
26
+ readonly kind: 'note';
27
+ readonly noteKind: NoteKind;
28
+ readonly noteId: number;
29
+ };
30
+
31
+ /** What a headless host can do. It paints nothing, so it claims nothing about painting. */
32
+ declare const SERVER_AUTOMATION_CAPABILITIES: AutomationCapabilities;
33
+ /**
34
+ * Why bytes could not be opened as a document: any bounded-reader rejection, plus the package
35
+ * that parsed but carried no main document part.
36
+ */
37
+ type ServerAutomationHostRejection = OoxmlPackageRejection | 'no-main-document-part';
38
+ /**
39
+ * A host over the opened bytes, or a refusal.
40
+ *
41
+ * A result rather than a throw: these bytes are untrusted input, and a malformed upload should
42
+ * be a value the caller inspects rather than an exception from inside a zip decoder.
43
+ */
44
+ type ServerAutomationHostResult = {
45
+ readonly ok: true;
46
+ readonly host: AutomationHost;
47
+ } | {
48
+ readonly ok: false;
49
+ readonly reason: ServerAutomationHostRejection;
50
+ readonly detail?: string;
51
+ };
52
+ /**
53
+ * How a headless host opens a document. Every field is optional.
54
+ *
55
+ * @public
56
+ */
57
+ interface ServerAutomationHostOptions {
58
+ /**
59
+ * Tighter budgets for the bounded reader — zip ratio, part count, XML depth.
60
+ *
61
+ * Exposed because a server opening documents it did not author is exactly where a caller
62
+ * may want smaller limits than the defaults. Omitted means the engine's own defaults.
63
+ */
64
+ readonly limits?: OoxmlPackageLimits;
65
+ }
66
+ /**
67
+ * Open DOCX bytes into a headless automation host.
68
+ *
69
+ * A typed rejection rather than a throw: every failure here is a property of the FILE, and a
70
+ * caller needs to tell "not a package" from "this package is hostile" from "no body".
71
+ */
72
+ declare function createServerAutomationHost(bytes: Uint8Array, options?: ServerAutomationHostOptions): ServerAutomationHostResult;
73
+
74
+ export { AutomationCapabilities, AutomationHost, type AutomationStoryId, HEADER_FOOTER_VARIANTS, SERVER_AUTOMATION_CAPABILITIES, type ServerAutomationHostOptions, type ServerAutomationHostRejection, type ServerAutomationHostResult, createServerAutomationHost };
@@ -0,0 +1 @@
1
+ import {g}from'./chunk-6WIIHJFY.js';export{c as AUTOMATION_COMMAND_OPERATIONS,b as AUTOMATION_QUERY_OPERATIONS,d as AUTOMATION_SOLITARY_OPERATIONS,a as HEADER_FOOTER_VARIANTS,f as isAutomationCommand,e as isSolitaryAutomationCommand}from'./chunk-6WIIHJFY.js';import {wb,Af,Nc,xb,If,Bf,Cf,Pc}from'./chunk-Y7TA7TPF.js';var y=Object.freeze({document:true,save:true,events:true,selection:false,scrolling:false,layout:false}),h=Object.freeze({kind:"body"});function I(e,r={}){let t=wb(e,r.limits??{});if(!t.ok)return {ok:false,reason:t.reason,...t.detail?{detail:t.detail}:{}};let a=t.package.parts.get(t.package.mainDocumentPart);if(!a)return {ok:false,reason:"no-main-document-part",detail:t.package.mainDocumentPart};let o=new Af(t.package,Nc(a));return {ok:true,host:g({port:v(o),capabilities:y})}}function T(e,r,t){let a=e.partFor(t);if(!a)return null;let o=Pc(e.currentPackage(),r,a.name);return o?(e.replacePackageShell(o.pkg),o.relationshipId):null}function v(e){let r=true;return {revision:()=>e.packageRevision,currentPackage:()=>r?e.currentPackage():null,apply(t,a=h){if(!r)return {ok:false,reason:"disposed"};let o=t(i=>T(e,i,a));if(o===null)return {ok:false,reason:"unsupported-target"};let n=e.transact(a,i=>{for(let k of o)i.apply(k);});return n.ok?{ok:true,changed:n.change!==null}:{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},applyLifecycle(t){if(!r)return {ok:false,reason:"disposed"};let a=e.applyLifecycleOp(t);return a.ok?{ok:true,changed:a.change!==null}:{ok:false,reason:a.detail?`${a.reason}: ${a.detail}`:a.reason}},applyCommentWrite(t,a){if(!r)return {ok:false,reason:"disposed"};let o=e.resolveStory(a);if(!o.ok)return {ok:false,reason:o.reason};o.store.graftPackage(()=>e.currentPackage());let n=t.kind==="reply"?Bf(o.store,{anchor:t.anchor,author:t.author,text:t.text,...t.date===void 0?{}:{date:t.date},replyToCommentId:t.parentCommentId}):Cf(o.store,t.commentId,t.resolved);return n.ok?(e.replacePackageShell(o.store.package),{ok:true,changed:true,..."commentId"in n?{commentId:n.commentId}:{}}):{ok:false,reason:n.reason}},applyCustomNodeWrite(t,a){if(!r)return {ok:false,reason:"disposed"};let o=e.resolveStory(a);if(!o.ok)return {ok:false,reason:o.reason};o.store.graftPackage(()=>e.currentPackage());let n=If(o.store,t);return n.ok?(e.replacePackageShell(o.store.package),{ok:true,changed:n.change!==null}):{ok:false,reason:n.detail?`${n.reason}: ${n.detail}`:n.reason}},save:()=>r?xb(e.currentPackage()):null,subscribe:t=>e.subscribe(()=>t()),dispose(){r=false;}}}export{y as SERVER_AUTOMATION_CAPABILITIES,I as createServerAutomationHost};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkO2WQY7IT_cjs=require('./chunk-O2WQY7IT.cjs');require('./chunk-BS554B6D.cjs'),require('./chunk-JQFDLZXQ.cjs'),require('./chunk-BZK64YU3.cjs');Object.defineProperty(exports,"PROJECTION_ORIGIN",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.k}});Object.defineProperty(exports,"bodyParagraphs",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.c}});Object.defineProperty(exports,"docToTreeOps",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.f}});Object.defineProperty(exports,"mountTreeSurface",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.l}});Object.defineProperty(exports,"openTreeSession",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.j}});Object.defineProperty(exports,"partHasNode",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.g}});Object.defineProperty(exports,"reconcileDoc",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.h}});Object.defineProperty(exports,"runPropsOf",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.b}});Object.defineProperty(exports,"treeSchema",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.a}});Object.defineProperty(exports,"treeToDoc",{enumerable:true,get:function(){return chunkO2WQY7IT_cjs.e}});
@@ -0,0 +1,88 @@
1
+ import { Node, Schema } from 'prosemirror-model';
2
+ import { O as OoxmlProperty } from './tree-op-types-UOXlRUqQ.cjs';
3
+ import { T as TreeDocxSession } from './tree-session-DxIOHUOD.cjs';
4
+ export { D as DocumentStyleEntry, M as MapResult, O as OpenTreeSessionResult, P as PROJECTION_ORIGIN, a as TreeApplyResult, b as TreeBindingRejection, c as TreeSessionRejection, d as bodyParagraphs, e as docToTreeOps, o as openTreeSession, p as partHasNode, r as reconcileDoc, t as treeToDoc } from './tree-session-DxIOHUOD.cjs';
5
+ export { S as StoryScope, a as StoryTargetRejection } from './custom-node-writes-YqISlSRl.cjs';
6
+ import { EditorView } from 'prosemirror-view';
7
+ import './ooxml-tree-BU0e3DVi.cjs';
8
+ import './image-resources-DwpNnTg3.cjs';
9
+ import './ooxml-package-CR5us6ad.cjs';
10
+ import './review-support-D64Wu236.cjs';
11
+ import './contracts/modules.cjs';
12
+ import './revision-projection-72ZApe-g.cjs';
13
+ import './hf-references-CgEOSw3i.cjs';
14
+ import './tree-store-B1lEkdXc.cjs';
15
+ import './note-nodes-C6DLxlvj.cjs';
16
+
17
+ /** Attributes carried by a projected paragraph. */
18
+ interface ParagraphAttrs {
19
+ /** The canonical tree node id this paragraph projects. */
20
+ readonly nodeId: string | null;
21
+ /** Accepted `w:pPr` children, as authored. */
22
+ readonly props: readonly OoxmlProperty[];
23
+ }
24
+ /**
25
+ * The ProseMirror schema the canonical tree projects into.
26
+ *
27
+ * Deliberately minimal. It models only what an editing surface must manipulate directly —
28
+ * paragraphs, text, tabs, breaks, and run properties as marks — because everything it does NOT
29
+ * model stays on the tree and is preserved losslessly there. Widening this schema moves content
30
+ * out of the tree's custody, which is the opposite of what it is for.
31
+ *
32
+ * The node and mark unions are written out rather than inferred from the spec below. Inferred,
33
+ * tsup's dts worker emits their members in an order that varies run to run, so the generated
34
+ * `binding.api.md` differed between builds of identical source and `api:check` failed at random.
35
+ * An explicit annotation pins the emitted order. Adding a node or mark to the spec means adding
36
+ * it here too — the compiler rejects the assignment otherwise.
37
+ */
38
+ declare const treeSchema: Schema<'doc' | 'paragraph' | 'text' | 'tab' | 'hardBreak' | 'pageBreak' | 'unknownInline', 'runProps'>;
39
+ /** The accepted run properties carried by a text node, or an empty list. */
40
+ declare function runPropsOf(node: Node): readonly OoxmlProperty[];
41
+
42
+ /** How a tree surface is mounted. */
43
+ interface TreeSurfaceOptions {
44
+ /** Called after every commit or refusal, so a host can show revision and rejection state. */
45
+ readonly onChange?: (state: TreeSurfaceState) => void;
46
+ }
47
+ /**
48
+ * Everything observable about a mounted tree surface.
49
+ *
50
+ * `lastRejection` is part of the state rather than a thrown error because a refused edit is an
51
+ * ordinary outcome here — the binding refuses anything it cannot explain, and the host shows why
52
+ * instead of the edit vanishing.
53
+ */
54
+ interface TreeSurfaceState {
55
+ readonly revision: number;
56
+ readonly canUndo: boolean;
57
+ readonly canRedo: boolean;
58
+ /** The reason the last transaction was refused, or null when the last one committed. */
59
+ readonly lastRejection: string | null;
60
+ }
61
+ /**
62
+ * A mounted ProseMirror view bound to a {@link TreeDocxSession}.
63
+ *
64
+ * Every committed transaction becomes tree ops through the binding; a transaction the binding
65
+ * cannot explain is refused and reported through {@link TreeSurfaceState.lastRejection}, leaving
66
+ * the tree untouched.
67
+ */
68
+ interface TreeSurface {
69
+ readonly view: EditorView;
70
+ state(): TreeSurfaceState;
71
+ undo(): void;
72
+ redo(): void;
73
+ /** Toggle one accepted run property across the current selection. */
74
+ toggleRunProperty(localName: string, attributes?: Record<string, string>): void;
75
+ destroy(): void;
76
+ }
77
+ /**
78
+ * Mount an editable ProseMirror view over a session's body story.
79
+ *
80
+ * The reference binding, not the production surface — `mountPaginatedSurface` is what the shipped
81
+ * editor uses. This one exists to exercise the tree↔ProseMirror contract directly, without
82
+ * pagination or painting in the way.
83
+ *
84
+ * Call {@link TreeSurface.destroy} to release the view.
85
+ */
86
+ declare function mountTreeSurface(mount: HTMLElement, session: TreeDocxSession, options?: TreeSurfaceOptions): TreeSurface;
87
+
88
+ export { type ParagraphAttrs, TreeDocxSession, type TreeSurface, type TreeSurfaceOptions, type TreeSurfaceState, mountTreeSurface, runPropsOf, treeSchema };