@wonderwhy-er/desktop-commander 0.2.38 → 0.2.39

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 (364) hide show
  1. package/README.md +53 -2
  2. package/dist/handlers/filesystem-handlers.d.ts +5 -0
  3. package/dist/handlers/filesystem-handlers.js +14 -2
  4. package/dist/remote-device/desktop-commander-integration.js +1 -1
  5. package/dist/search-manager.js +31 -38
  6. package/dist/server.js +8 -3
  7. package/dist/terminal-manager.js +4 -2
  8. package/dist/tools/edit.js +34 -1
  9. package/dist/tools/filesystem.js +91 -3
  10. package/dist/tools/improved-process-tools.js +2 -1
  11. package/dist/ui/config-editor/app.js +840 -0
  12. package/dist/ui/config-editor/array-modal.d.ts +19 -0
  13. package/dist/ui/config-editor/array-modal.js +185 -0
  14. package/dist/ui/config-editor/config-editor-runtime.js +65 -14096
  15. package/dist/ui/config-editor/main.js +2 -0
  16. package/dist/ui/config-editor/src/App.d.ts +43 -0
  17. package/dist/ui/config-editor/src/components/layout.d.ts +4 -0
  18. package/dist/ui/config-editor/src/components/layout.js +83 -0
  19. package/dist/ui/config-editor/src/components/toolbar.d.ts +1 -0
  20. package/dist/ui/config-editor/src/components/toolbar.js +21 -0
  21. package/dist/ui/config-editor/src/config-values.d.ts +6 -0
  22. package/dist/ui/config-editor/src/config-values.js +61 -0
  23. package/dist/ui/config-editor/src/contracts.d.ts +14 -0
  24. package/dist/ui/config-editor/src/contracts.js +3 -0
  25. package/dist/ui/config-editor/src/directory-browser.d.ts +6 -0
  26. package/dist/ui/config-editor/src/directory-browser.js +71 -0
  27. package/dist/ui/config-editor/src/layout.d.ts +5 -0
  28. package/dist/ui/config-editor/src/layout.js +90 -0
  29. package/dist/ui/config-editor/src/parsing.d.ts +5 -0
  30. package/dist/ui/config-editor/src/parsing.js +50 -0
  31. package/dist/ui/config-editor/src/toolbar.d.ts +1 -0
  32. package/dist/ui/config-editor/src/toolbar.js +18 -0
  33. package/dist/ui/config-editor/src/types.d.ts +17 -0
  34. package/dist/ui/config-editor/src/types.js +3 -0
  35. package/dist/ui/config-editor/src/utils/config-values.d.ts +9 -0
  36. package/dist/ui/config-editor/src/utils/config-values.js +61 -0
  37. package/dist/ui/config-editor/src/utils/directory-browser.d.ts +31 -0
  38. package/dist/ui/config-editor/src/utils/directory-browser.js +201 -0
  39. package/dist/ui/config-editor/src/utils/parsing.d.ts +8 -0
  40. package/dist/ui/config-editor/src/utils/parsing.js +50 -0
  41. package/dist/ui/config-editor/styles.css +2 -1
  42. package/dist/ui/file-preview/{src/app.d.ts → app.d.ts} +1 -1
  43. package/dist/ui/file-preview/app.js +2020 -0
  44. package/dist/ui/file-preview/components/code-viewer.d.ts +6 -0
  45. package/dist/ui/file-preview/components/code-viewer.js +73 -0
  46. package/dist/ui/file-preview/components/highlighting.d.ts +2 -0
  47. package/dist/ui/file-preview/components/highlighting.js +54 -0
  48. package/dist/ui/file-preview/components/html-renderer.d.ts +5 -0
  49. package/dist/ui/file-preview/components/html-renderer.js +47 -0
  50. package/dist/ui/file-preview/components/markdown-renderer.d.ts +1 -0
  51. package/dist/ui/file-preview/components/markdown-renderer.js +67 -0
  52. package/dist/ui/file-preview/components/toolbar.d.ts +6 -0
  53. package/dist/ui/file-preview/components/toolbar.js +75 -0
  54. package/dist/ui/file-preview/image-preview.d.ts +3 -0
  55. package/dist/ui/file-preview/image-preview.js +21 -0
  56. package/dist/ui/file-preview/main.js +5 -0
  57. package/dist/ui/file-preview/markdown/editor.d.ts +36 -0
  58. package/dist/ui/file-preview/markdown/editor.js +643 -0
  59. package/dist/ui/file-preview/markdown/linking.d.ts +9 -0
  60. package/dist/ui/file-preview/markdown/linking.js +210 -0
  61. package/dist/ui/file-preview/markdown/outline.d.ts +7 -0
  62. package/dist/ui/file-preview/markdown/outline.js +40 -0
  63. package/dist/ui/file-preview/markdown/preview.d.ts +8 -0
  64. package/dist/ui/file-preview/markdown/preview.js +33 -0
  65. package/dist/ui/file-preview/markdown/slugify.d.ts +3 -0
  66. package/dist/ui/file-preview/markdown/slugify.js +31 -0
  67. package/dist/ui/file-preview/markdown/toc.d.ts +11 -0
  68. package/dist/ui/file-preview/markdown/toc.js +75 -0
  69. package/dist/ui/file-preview/markdown/utils.d.ts +1 -0
  70. package/dist/ui/file-preview/markdown/utils.js +15 -0
  71. package/dist/ui/file-preview/markdown/workspace-controller.d.ts +25 -0
  72. package/dist/ui/file-preview/markdown/workspace-controller.js +40 -0
  73. package/dist/ui/file-preview/preview-runtime.js +384 -26533
  74. package/dist/ui/file-preview/shared/preview-file-types.d.ts +1 -1
  75. package/dist/ui/file-preview/src/App.d.ts +4 -0
  76. package/dist/ui/file-preview/src/App.js +564 -0
  77. package/dist/ui/file-preview/src/components/CodeViewer.d.ts +6 -0
  78. package/dist/ui/file-preview/src/components/CodeViewer.js +60 -0
  79. package/dist/ui/file-preview/src/components/HtmlRenderer.d.ts +8 -0
  80. package/dist/ui/file-preview/src/components/HtmlRenderer.js +45 -0
  81. package/dist/ui/file-preview/src/components/MarkdownRenderer.d.ts +1 -0
  82. package/dist/ui/file-preview/src/components/MarkdownRenderer.js +15 -0
  83. package/dist/ui/file-preview/src/components/editor-toolbar.d.ts +15 -0
  84. package/dist/ui/file-preview/src/components/editor-toolbar.js +384 -0
  85. package/dist/ui/file-preview/src/components/markdown-editor.d.ts +29 -0
  86. package/dist/ui/file-preview/src/components/markdown-editor.js +535 -0
  87. package/dist/ui/file-preview/src/components/markdown-renderer.js +47 -9
  88. package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
  89. package/dist/ui/file-preview/src/directory-controller.js +233 -0
  90. package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
  91. package/dist/ui/file-preview/src/document-layout.js +109 -0
  92. package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
  93. package/dist/ui/file-preview/src/document-outline.js +97 -0
  94. package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
  95. package/dist/ui/file-preview/src/document-workspace.js +33 -0
  96. package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
  97. package/dist/ui/file-preview/src/file-type-handlers.js +98 -0
  98. package/dist/ui/file-preview/src/host/external-actions.d.ts +19 -0
  99. package/dist/ui/file-preview/src/host/external-actions.js +94 -0
  100. package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
  101. package/dist/ui/file-preview/src/host/selection-context.js +106 -0
  102. package/dist/ui/file-preview/src/markdown/block-merge.d.ts +25 -0
  103. package/dist/ui/file-preview/src/markdown/block-merge.js +86 -0
  104. package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
  105. package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
  106. package/dist/ui/file-preview/src/markdown/controller.d.ts +38 -0
  107. package/dist/ui/file-preview/src/markdown/controller.js +921 -0
  108. package/dist/ui/file-preview/src/markdown/editor.d.ts +35 -0
  109. package/dist/ui/file-preview/src/markdown/editor.js +691 -0
  110. package/dist/ui/file-preview/src/markdown/link-modal.d.ts +13 -0
  111. package/dist/ui/file-preview/src/markdown/link-modal.js +213 -0
  112. package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
  113. package/dist/ui/file-preview/src/markdown/linking.js +228 -0
  114. package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
  115. package/dist/ui/file-preview/src/markdown/outline.js +16 -0
  116. package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
  117. package/dist/ui/file-preview/src/markdown/parser.js +38 -0
  118. package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
  119. package/dist/ui/file-preview/src/markdown/preview.js +20 -0
  120. package/dist/ui/file-preview/src/markdown/raw-editor.d.ts +8 -0
  121. package/dist/ui/file-preview/src/markdown/raw-editor.js +61 -0
  122. package/dist/ui/file-preview/src/markdown/selection-toolbar.d.ts +14 -0
  123. package/dist/ui/file-preview/src/markdown/selection-toolbar.js +128 -0
  124. package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
  125. package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
  126. package/dist/ui/file-preview/src/markdown/toc.d.ts +11 -0
  127. package/dist/ui/file-preview/src/markdown/toc.js +75 -0
  128. package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
  129. package/dist/ui/file-preview/src/markdown/utils.js +15 -0
  130. package/dist/ui/file-preview/src/markdown-workspace/editor.d.ts +36 -0
  131. package/dist/ui/file-preview/src/markdown-workspace/editor.js +643 -0
  132. package/dist/ui/file-preview/src/markdown-workspace/linking.d.ts +9 -0
  133. package/dist/ui/file-preview/src/markdown-workspace/linking.js +210 -0
  134. package/dist/ui/file-preview/src/markdown-workspace/outline.d.ts +7 -0
  135. package/dist/ui/file-preview/src/markdown-workspace/outline.js +40 -0
  136. package/dist/ui/file-preview/src/markdown-workspace/preview.d.ts +8 -0
  137. package/dist/ui/file-preview/src/markdown-workspace/preview.js +33 -0
  138. package/dist/ui/file-preview/src/markdown-workspace/slugify.d.ts +3 -0
  139. package/dist/ui/file-preview/src/markdown-workspace/slugify.js +31 -0
  140. package/dist/ui/file-preview/src/markdown-workspace/toc.d.ts +11 -0
  141. package/dist/ui/file-preview/src/markdown-workspace/toc.js +75 -0
  142. package/dist/ui/file-preview/src/markdown-workspace/utils.d.ts +1 -0
  143. package/dist/ui/file-preview/src/markdown-workspace/utils.js +15 -0
  144. package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.d.ts +25 -0
  145. package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.js +40 -0
  146. package/dist/ui/file-preview/src/model.d.ts +34 -0
  147. package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
  148. package/dist/ui/file-preview/src/panel-actions.js +182 -0
  149. package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
  150. package/dist/ui/file-preview/src/path-utils.js +64 -0
  151. package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
  152. package/dist/ui/file-preview/src/payload-utils.js +94 -0
  153. package/dist/ui/file-preview/styles.css +1066 -233
  154. package/dist/ui/file-preview/types.d.ts +1 -0
  155. package/dist/ui/server-integration.d.ts +13 -0
  156. package/dist/ui/server-integration.js +31 -0
  157. package/dist/ui/shared/ToolHeader.d.ts +9 -0
  158. package/dist/ui/shared/ToolHeader.js +29 -0
  159. package/dist/ui/shared/app-bootstrap.d.ts +9 -0
  160. package/dist/ui/shared/app-bootstrap.js +15 -0
  161. package/dist/ui/shared/guards.d.ts +1 -0
  162. package/dist/ui/shared/guards.js +3 -0
  163. package/dist/ui/shared/host-lifecycle.d.ts +1 -0
  164. package/dist/ui/shared/host-lifecycle.js +8 -2
  165. package/dist/ui/shared/widget-state.d.ts +6 -1
  166. package/dist/ui/shared/widget-state.js +102 -4
  167. package/dist/utils/files/base.d.ts +2 -0
  168. package/dist/utils/open-browser.js +1 -1
  169. package/dist/utils/ui-call-context.d.ts +8 -0
  170. package/dist/utils/ui-call-context.js +72 -0
  171. package/dist/version.d.ts +1 -1
  172. package/dist/version.js +1 -1
  173. package/package.json +6 -1
  174. package/dist/data/spec-kit-prompts.json +0 -123
  175. package/dist/handlers/macos-control-handlers.d.ts +0 -16
  176. package/dist/handlers/macos-control-handlers.js +0 -81
  177. package/dist/handlers/node-handlers.d.ts +0 -6
  178. package/dist/handlers/node-handlers.js +0 -73
  179. package/dist/handlers/test-crash-handler.d.ts +0 -11
  180. package/dist/handlers/test-crash-handler.js +0 -26
  181. package/dist/http-index.d.ts +0 -45
  182. package/dist/http-index.js +0 -51
  183. package/dist/http-server-auto-tunnel.js +0 -667
  184. package/dist/http-server-named-tunnel.d.ts +0 -2
  185. package/dist/http-server-named-tunnel.js +0 -167
  186. package/dist/http-server-tunnel.d.ts +0 -2
  187. package/dist/http-server-tunnel.js +0 -111
  188. package/dist/http-server.d.ts +0 -2
  189. package/dist/http-server.js +0 -270
  190. package/dist/index-oauth.d.ts +0 -2
  191. package/dist/index-oauth.js +0 -201
  192. package/dist/lib.d.ts +0 -10
  193. package/dist/lib.js +0 -10
  194. package/dist/oauth/auth-middleware.d.ts +0 -20
  195. package/dist/oauth/auth-middleware.js +0 -62
  196. package/dist/oauth/index.d.ts +0 -3
  197. package/dist/oauth/index.js +0 -3
  198. package/dist/oauth/oauth-manager.d.ts +0 -80
  199. package/dist/oauth/oauth-manager.js +0 -179
  200. package/dist/oauth/oauth-routes.d.ts +0 -3
  201. package/dist/oauth/oauth-routes.js +0 -377
  202. package/dist/oauth/provider.d.ts +0 -22
  203. package/dist/oauth/provider.js +0 -124
  204. package/dist/oauth/server.d.ts +0 -18
  205. package/dist/oauth/server.js +0 -160
  206. package/dist/oauth/types.d.ts +0 -54
  207. package/dist/oauth/types.js +0 -2
  208. package/dist/remote-device/templates/auth-success.d.ts +0 -1
  209. package/dist/remote-device/templates/auth-success.js +0 -30
  210. package/dist/setup.log +0 -275
  211. package/dist/test-setup.js +0 -14
  212. package/dist/tools/docx/builders/html-builder.d.ts +0 -17
  213. package/dist/tools/docx/builders/html-builder.js +0 -92
  214. package/dist/tools/docx/builders/image.d.ts +0 -14
  215. package/dist/tools/docx/builders/image.js +0 -84
  216. package/dist/tools/docx/builders/index.d.ts +0 -11
  217. package/dist/tools/docx/builders/index.js +0 -11
  218. package/dist/tools/docx/builders/markdown-builder.d.ts +0 -2
  219. package/dist/tools/docx/builders/markdown-builder.js +0 -260
  220. package/dist/tools/docx/builders/paragraph.d.ts +0 -12
  221. package/dist/tools/docx/builders/paragraph.js +0 -29
  222. package/dist/tools/docx/builders/table.d.ts +0 -10
  223. package/dist/tools/docx/builders/table.js +0 -138
  224. package/dist/tools/docx/builders/utils.d.ts +0 -5
  225. package/dist/tools/docx/builders/utils.js +0 -18
  226. package/dist/tools/docx/constants.d.ts +0 -32
  227. package/dist/tools/docx/constants.js +0 -61
  228. package/dist/tools/docx/converters/markdown-to-html.d.ts +0 -17
  229. package/dist/tools/docx/converters/markdown-to-html.js +0 -111
  230. package/dist/tools/docx/create.d.ts +0 -21
  231. package/dist/tools/docx/create.js +0 -386
  232. package/dist/tools/docx/dom.d.ts +0 -139
  233. package/dist/tools/docx/dom.js +0 -448
  234. package/dist/tools/docx/errors.d.ts +0 -28
  235. package/dist/tools/docx/errors.js +0 -48
  236. package/dist/tools/docx/extractors/images.d.ts +0 -14
  237. package/dist/tools/docx/extractors/images.js +0 -40
  238. package/dist/tools/docx/extractors/metadata.d.ts +0 -14
  239. package/dist/tools/docx/extractors/metadata.js +0 -64
  240. package/dist/tools/docx/extractors/sections.d.ts +0 -14
  241. package/dist/tools/docx/extractors/sections.js +0 -61
  242. package/dist/tools/docx/html.d.ts +0 -17
  243. package/dist/tools/docx/html.js +0 -111
  244. package/dist/tools/docx/index.d.ts +0 -10
  245. package/dist/tools/docx/index.js +0 -10
  246. package/dist/tools/docx/markdown.d.ts +0 -84
  247. package/dist/tools/docx/markdown.js +0 -507
  248. package/dist/tools/docx/modify.d.ts +0 -28
  249. package/dist/tools/docx/modify.js +0 -271
  250. package/dist/tools/docx/operations/handlers/index.d.ts +0 -39
  251. package/dist/tools/docx/operations/handlers/index.js +0 -152
  252. package/dist/tools/docx/operations/html-manipulator.d.ts +0 -24
  253. package/dist/tools/docx/operations/html-manipulator.js +0 -352
  254. package/dist/tools/docx/operations/index.d.ts +0 -14
  255. package/dist/tools/docx/operations/index.js +0 -61
  256. package/dist/tools/docx/operations/operation-handlers.d.ts +0 -3
  257. package/dist/tools/docx/operations/operation-handlers.js +0 -67
  258. package/dist/tools/docx/operations/preprocessor.d.ts +0 -14
  259. package/dist/tools/docx/operations/preprocessor.js +0 -44
  260. package/dist/tools/docx/operations/xml-replacer.d.ts +0 -9
  261. package/dist/tools/docx/operations/xml-replacer.js +0 -35
  262. package/dist/tools/docx/operations.d.ts +0 -13
  263. package/dist/tools/docx/operations.js +0 -13
  264. package/dist/tools/docx/ops/delete-paragraph-at-body-index.d.ts +0 -11
  265. package/dist/tools/docx/ops/delete-paragraph-at-body-index.js +0 -23
  266. package/dist/tools/docx/ops/header-replace-text-exact.d.ts +0 -13
  267. package/dist/tools/docx/ops/header-replace-text-exact.js +0 -55
  268. package/dist/tools/docx/ops/index.d.ts +0 -17
  269. package/dist/tools/docx/ops/index.js +0 -70
  270. package/dist/tools/docx/ops/insert-image-after-text.d.ts +0 -24
  271. package/dist/tools/docx/ops/insert-image-after-text.js +0 -128
  272. package/dist/tools/docx/ops/insert-paragraph-after-text.d.ts +0 -12
  273. package/dist/tools/docx/ops/insert-paragraph-after-text.js +0 -74
  274. package/dist/tools/docx/ops/insert-table-after-text.d.ts +0 -19
  275. package/dist/tools/docx/ops/insert-table-after-text.js +0 -57
  276. package/dist/tools/docx/ops/replace-hyperlink-url.d.ts +0 -12
  277. package/dist/tools/docx/ops/replace-hyperlink-url.js +0 -37
  278. package/dist/tools/docx/ops/replace-paragraph-at-body-index.d.ts +0 -9
  279. package/dist/tools/docx/ops/replace-paragraph-at-body-index.js +0 -25
  280. package/dist/tools/docx/ops/replace-paragraph-text-exact.d.ts +0 -21
  281. package/dist/tools/docx/ops/replace-paragraph-text-exact.js +0 -36
  282. package/dist/tools/docx/ops/replace-table-cell-text.d.ts +0 -25
  283. package/dist/tools/docx/ops/replace-table-cell-text.js +0 -85
  284. package/dist/tools/docx/ops/set-color-for-paragraph-exact.d.ts +0 -9
  285. package/dist/tools/docx/ops/set-color-for-paragraph-exact.js +0 -24
  286. package/dist/tools/docx/ops/set-color-for-style.d.ts +0 -13
  287. package/dist/tools/docx/ops/set-color-for-style.js +0 -31
  288. package/dist/tools/docx/ops/set-paragraph-style-at-body-index.d.ts +0 -8
  289. package/dist/tools/docx/ops/set-paragraph-style-at-body-index.js +0 -57
  290. package/dist/tools/docx/ops/table-set-cell-text.d.ts +0 -9
  291. package/dist/tools/docx/ops/table-set-cell-text.js +0 -40
  292. package/dist/tools/docx/parsers/image-extractor.d.ts +0 -18
  293. package/dist/tools/docx/parsers/image-extractor.js +0 -61
  294. package/dist/tools/docx/parsers/index.d.ts +0 -9
  295. package/dist/tools/docx/parsers/index.js +0 -9
  296. package/dist/tools/docx/parsers/paragraph-parser.d.ts +0 -2
  297. package/dist/tools/docx/parsers/paragraph-parser.js +0 -88
  298. package/dist/tools/docx/parsers/table-parser.d.ts +0 -9
  299. package/dist/tools/docx/parsers/table-parser.js +0 -72
  300. package/dist/tools/docx/parsers/xml-parser.d.ts +0 -25
  301. package/dist/tools/docx/parsers/xml-parser.js +0 -71
  302. package/dist/tools/docx/parsers/zip-reader.d.ts +0 -23
  303. package/dist/tools/docx/parsers/zip-reader.js +0 -52
  304. package/dist/tools/docx/read.d.ts +0 -27
  305. package/dist/tools/docx/read.js +0 -308
  306. package/dist/tools/docx/relationships.d.ts +0 -22
  307. package/dist/tools/docx/relationships.js +0 -76
  308. package/dist/tools/docx/structure.d.ts +0 -25
  309. package/dist/tools/docx/structure.js +0 -102
  310. package/dist/tools/docx/styled-html-parser.d.ts +0 -23
  311. package/dist/tools/docx/styled-html-parser.js +0 -1262
  312. package/dist/tools/docx/types.d.ts +0 -213
  313. package/dist/tools/docx/types.js +0 -5
  314. package/dist/tools/docx/utils/escaping.d.ts +0 -13
  315. package/dist/tools/docx/utils/escaping.js +0 -26
  316. package/dist/tools/docx/utils/images.d.ts +0 -9
  317. package/dist/tools/docx/utils/images.js +0 -26
  318. package/dist/tools/docx/utils/index.d.ts +0 -12
  319. package/dist/tools/docx/utils/index.js +0 -17
  320. package/dist/tools/docx/utils/markdown.d.ts +0 -13
  321. package/dist/tools/docx/utils/markdown.js +0 -32
  322. package/dist/tools/docx/utils/paths.d.ts +0 -15
  323. package/dist/tools/docx/utils/paths.js +0 -27
  324. package/dist/tools/docx/utils/versioning.d.ts +0 -25
  325. package/dist/tools/docx/utils/versioning.js +0 -55
  326. package/dist/tools/docx/utils.d.ts +0 -101
  327. package/dist/tools/docx/utils.js +0 -299
  328. package/dist/tools/docx/validate.d.ts +0 -33
  329. package/dist/tools/docx/validate.js +0 -49
  330. package/dist/tools/docx/validators.d.ts +0 -13
  331. package/dist/tools/docx/validators.js +0 -40
  332. package/dist/tools/docx/write.d.ts +0 -17
  333. package/dist/tools/docx/write.js +0 -88
  334. package/dist/tools/docx/xml-view-test.js +0 -63
  335. package/dist/tools/docx/xml-view.d.ts +0 -56
  336. package/dist/tools/docx/xml-view.js +0 -169
  337. package/dist/tools/docx/zip.d.ts +0 -21
  338. package/dist/tools/docx/zip.js +0 -35
  339. package/dist/tools/macos-control/ax-adapter.d.ts +0 -55
  340. package/dist/tools/macos-control/ax-adapter.js +0 -438
  341. package/dist/tools/macos-control/cdp-adapter.d.ts +0 -23
  342. package/dist/tools/macos-control/cdp-adapter.js +0 -402
  343. package/dist/tools/macos-control/orchestrator.d.ts +0 -77
  344. package/dist/tools/macos-control/orchestrator.js +0 -136
  345. package/dist/tools/macos-control/role-aliases.d.ts +0 -5
  346. package/dist/tools/macos-control/role-aliases.js +0 -34
  347. package/dist/tools/macos-control/types.d.ts +0 -129
  348. package/dist/tools/pdf-processor.d.ts +0 -1
  349. package/dist/tools/pdf-processor.js +0 -3
  350. package/dist/tools/search.d.ts +0 -32
  351. package/dist/tools/search.js +0 -202
  352. package/dist/ui/file-preview/src/app.js +0 -714
  353. package/dist/utils/crash-logger.d.ts +0 -18
  354. package/dist/utils/crash-logger.js +0 -44
  355. package/dist/utils/dedent.d.ts +0 -8
  356. package/dist/utils/dedent.js +0 -38
  357. /package/dist/ui/config-editor/{src/app.d.ts → app.d.ts} +0 -0
  358. /package/dist/{http-server-auto-tunnel.d.ts → ui/config-editor/main.d.ts} +0 -0
  359. /package/dist/ui/config-editor/src/{app.js → App.js} +0 -0
  360. /package/dist/{test-docx.d.ts → ui/file-preview/main.d.ts} +0 -0
  361. /package/dist/ui/file-preview/src/components/{toolbar.d.ts → Toolbar.d.ts} +0 -0
  362. /package/dist/ui/file-preview/src/components/{toolbar.js → Toolbar.js} +0 -0
  363. /package/dist/{tools/docx/xml-view-test.d.ts → ui/file-preview/src/model.js} +0 -0
  364. /package/dist/{tools/macos-control → ui/file-preview}/types.js +0 -0
@@ -1,13 +0,0 @@
1
- /**
2
- * Op: header_replace_text_exact
3
- *
4
- * Find ALL header XML files (word/header1.xml, header2.xml, …)
5
- * in the ZIP, locate the first paragraph matching exact trimmed text,
6
- * and replace its text minimally.
7
- *
8
- * This op modifies header XML files inside the ZIP — not document.xml body.
9
- * It receives the PizZip instance from the orchestrator.
10
- */
11
- import PizZip from 'pizzip';
12
- import type { HeaderReplaceTextExactOp, OpResult } from '../types.js';
13
- export declare function applyHeaderReplaceTextExact(_body: Element, op: HeaderReplaceTextExactOp, zip: PizZip): OpResult;
@@ -1,55 +0,0 @@
1
- /**
2
- * Op: header_replace_text_exact
3
- *
4
- * Find ALL header XML files (word/header1.xml, header2.xml, …)
5
- * in the ZIP, locate the first paragraph matching exact trimmed text,
6
- * and replace its text minimally.
7
- *
8
- * This op modifies header XML files inside the ZIP — not document.xml body.
9
- * It receives the PizZip instance from the orchestrator.
10
- */
11
- import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
12
- import { nodeListToArray, getParagraphText, setParagraphTextMinimal } from '../dom.js';
13
- export function applyHeaderReplaceTextExact(_body, op, zip) {
14
- const target = op.from.trim();
15
- let totalMatched = 0;
16
- // Iterate over all files in word/ looking for header*.xml
17
- const files = zip.folder('word');
18
- if (!files) {
19
- return { op, status: 'skipped', matched: 0, reason: 'no_word_folder' };
20
- }
21
- // PizZip file listing
22
- const headerPattern = /^word\/header\d+\.xml$/;
23
- const allFiles = Object.keys(zip.files);
24
- const headerPaths = allFiles.filter((f) => headerPattern.test(f));
25
- if (headerPaths.length === 0) {
26
- return { op, status: 'skipped', matched: 0, reason: 'no_header_files' };
27
- }
28
- for (const headerPath of headerPaths) {
29
- const entry = zip.file(headerPath);
30
- if (!entry)
31
- continue;
32
- const xmlStr = entry.asText();
33
- const dom = new DOMParser().parseFromString(xmlStr, 'application/xml');
34
- // Find all w:p elements in the header
35
- const paragraphs = dom.getElementsByTagName('w:p');
36
- let modified = false;
37
- for (const p of nodeListToArray(paragraphs)) {
38
- const pEl = p;
39
- if (getParagraphText(pEl).trim() === target) {
40
- setParagraphTextMinimal(pEl, op.to);
41
- totalMatched++;
42
- modified = true;
43
- break; // first match per header file
44
- }
45
- }
46
- if (modified) {
47
- const newXml = new XMLSerializer().serializeToString(dom);
48
- zip.file(headerPath, newXml);
49
- }
50
- }
51
- if (totalMatched === 0) {
52
- return { op, status: 'skipped', matched: 0, reason: 'no_match_in_headers' };
53
- }
54
- return { op, status: 'applied', matched: totalMatched };
55
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Op dispatcher — routes each op to its implementation.
3
- *
4
- * Open/Closed Principle: adding a new op type requires only
5
- * a new file + one extra case here; existing ops stay untouched.
6
- */
7
- import PizZip from 'pizzip';
8
- import type { DocxOp, OpResult } from '../types.js';
9
- /**
10
- * Apply a single operation.
11
- *
12
- * @param body The w:body element (for DOM-based body ops)
13
- * @param op The operation descriptor
14
- * @param zip Optional PizZip instance — required for ops that modify
15
- * files outside word/document.xml (e.g. hyperlinks, headers)
16
- */
17
- export declare function applyOp(body: Element, op: DocxOp, zip?: PizZip): OpResult;
@@ -1,70 +0,0 @@
1
- /**
2
- * Op dispatcher — routes each op to its implementation.
3
- *
4
- * Open/Closed Principle: adding a new op type requires only
5
- * a new file + one extra case here; existing ops stay untouched.
6
- */
7
- import { applyReplaceParagraphTextExact } from './replace-paragraph-text-exact.js';
8
- import { applyReplaceParagraphAtBodyIndex } from './replace-paragraph-at-body-index.js';
9
- import { applySetColorForStyle } from './set-color-for-style.js';
10
- import { applySetColorForParagraphExact } from './set-color-for-paragraph-exact.js';
11
- import { applySetParagraphStyleAtBodyIndex } from './set-paragraph-style-at-body-index.js';
12
- import { applyInsertParagraphAfterText } from './insert-paragraph-after-text.js';
13
- import { applyDeleteParagraphAtBodyIndex } from './delete-paragraph-at-body-index.js';
14
- import { applyTableSetCellText } from './table-set-cell-text.js';
15
- import { applyReplaceTableCellText } from './replace-table-cell-text.js';
16
- import { applyReplaceHyperlinkUrl } from './replace-hyperlink-url.js';
17
- import { applyHeaderReplaceTextExact } from './header-replace-text-exact.js';
18
- import { applyInsertTable } from './insert-table-after-text.js';
19
- import { applyInsertImage } from './insert-image-after-text.js';
20
- /**
21
- * Apply a single operation.
22
- *
23
- * @param body The w:body element (for DOM-based body ops)
24
- * @param op The operation descriptor
25
- * @param zip Optional PizZip instance — required for ops that modify
26
- * files outside word/document.xml (e.g. hyperlinks, headers)
27
- */
28
- export function applyOp(body, op, zip) {
29
- switch (op.type) {
30
- case 'replace_paragraph_text_exact':
31
- return applyReplaceParagraphTextExact(body, op);
32
- case 'replace_paragraph_at_body_index':
33
- return applyReplaceParagraphAtBodyIndex(body, op);
34
- case 'set_color_for_style':
35
- return applySetColorForStyle(body, op);
36
- case 'set_color_for_paragraph_exact':
37
- return applySetColorForParagraphExact(body, op);
38
- case 'set_paragraph_style_at_body_index':
39
- return applySetParagraphStyleAtBodyIndex(body, op);
40
- case 'insert_paragraph_after_text':
41
- return applyInsertParagraphAfterText(body, op);
42
- case 'delete_paragraph_at_body_index':
43
- return applyDeleteParagraphAtBodyIndex(body, op);
44
- case 'table_set_cell_text':
45
- return applyTableSetCellText(body, op);
46
- case 'replace_table_cell_text':
47
- return applyReplaceTableCellText(body, op);
48
- case 'replace_hyperlink_url':
49
- if (!zip)
50
- return { op, status: 'skipped', matched: 0, reason: 'zip_required_for_hyperlink_op' };
51
- return applyReplaceHyperlinkUrl(body, op, zip);
52
- case 'header_replace_text_exact':
53
- if (!zip)
54
- return { op, status: 'skipped', matched: 0, reason: 'zip_required_for_header_op' };
55
- return applyHeaderReplaceTextExact(body, op, zip);
56
- case 'insert_table':
57
- return applyInsertTable(body, op);
58
- case 'insert_image':
59
- if (!zip)
60
- return { op, status: 'skipped', matched: 0, reason: 'zip_required_for_image_op' };
61
- return applyInsertImage(body, op, zip);
62
- default:
63
- return {
64
- op,
65
- status: 'skipped',
66
- matched: 0,
67
- reason: `unknown_op_type: ${op.type}`,
68
- };
69
- }
70
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Op: insert_image
3
- *
4
- * Insert an image into the DOCX relative to a paragraph anchor.
5
- *
6
- * Supports two positioning modes:
7
- * - `after` — insert immediately AFTER the first paragraph matching text
8
- * - `before` — insert immediately BEFORE the first paragraph matching text
9
- *
10
- * Exactly one of `after` or `before` must be provided.
11
- *
12
- * The image is read from disk, added to word/media/ in the ZIP,
13
- * and a w:drawing reference is created inside a new paragraph.
14
- *
15
- * Requires the PizZip instance because it modifies:
16
- * - word/media/imageN.ext (binary blob)
17
- * - word/_rels/document.xml.rels (relationship entry)
18
- * - [Content_Types].xml (content-type override)
19
- *
20
- * This is a structural op — increases bodyChildCount by 1.
21
- */
22
- import PizZip from 'pizzip';
23
- import type { InsertImageOp, OpResult } from '../types.js';
24
- export declare function applyInsertImage(body: Element, op: InsertImageOp, zip: PizZip): OpResult;
@@ -1,128 +0,0 @@
1
- /**
2
- * Op: insert_image
3
- *
4
- * Insert an image into the DOCX relative to a paragraph anchor.
5
- *
6
- * Supports two positioning modes:
7
- * - `after` — insert immediately AFTER the first paragraph matching text
8
- * - `before` — insert immediately BEFORE the first paragraph matching text
9
- *
10
- * Exactly one of `after` or `before` must be provided.
11
- *
12
- * The image is read from disk, added to word/media/ in the ZIP,
13
- * and a w:drawing reference is created inside a new paragraph.
14
- *
15
- * Requires the PizZip instance because it modifies:
16
- * - word/media/imageN.ext (binary blob)
17
- * - word/_rels/document.xml.rels (relationship entry)
18
- * - [Content_Types].xml (content-type override)
19
- *
20
- * This is a structural op — increases bodyChildCount by 1.
21
- */
22
- import fs from 'fs';
23
- import path from 'path';
24
- import { DOMParser } from '@xmldom/xmldom';
25
- import { getBodyChildren, getParagraphText } from '../dom.js';
26
- import { addImageRelationship, ensureContentType } from '../relationships.js';
27
- import { escapeXmlAttr } from '../builders/utils.js';
28
- import { pixelsToEmu, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, NAMESPACES } from '../constants.js';
29
- // ─── Op implementation ───────────────────────────────────────────────
30
- export function applyInsertImage(body, op, zip) {
31
- // ── Validate anchor ─────────────────────────────────────────────
32
- const anchorText = op.before ?? op.after;
33
- const position = op.before ? 'before' : 'after';
34
- if (!anchorText) {
35
- return { op, status: 'skipped', matched: 0, reason: 'no_anchor: provide "after" or "before"' };
36
- }
37
- // ── Validate image file exists ──────────────────────────────────
38
- const imgPath = op.imagePath;
39
- if (!fs.existsSync(imgPath)) {
40
- return { op, status: 'skipped', matched: 0, reason: `image_not_found: ${imgPath}` };
41
- }
42
- // ── Find target paragraph ───────────────────────────────────────
43
- const children = getBodyChildren(body);
44
- const target = anchorText.trim();
45
- for (let i = 0; i < children.length; i++) {
46
- const child = children[i];
47
- if (child.nodeName !== 'w:p')
48
- continue;
49
- if (getParagraphText(child).trim() === target) {
50
- const doc = body.ownerDocument;
51
- if (!doc)
52
- return { op, status: 'skipped', matched: 0, reason: 'no_owner_document' };
53
- // ── Read image (sync) ────────────────────────────────────
54
- const imgBuffer = fs.readFileSync(imgPath);
55
- const ext = path.extname(imgPath).toLowerCase();
56
- const baseName = path.basename(imgPath);
57
- // ── Find next available media filename ────────────────────
58
- let mediaIndex = 1;
59
- while (zip.file(`word/media/image${mediaIndex}${ext}`)) {
60
- mediaIndex++;
61
- }
62
- const mediaFileName = `image${mediaIndex}${ext}`;
63
- // ── Add image to ZIP ──────────────────────────────────────
64
- zip.file(`word/media/${mediaFileName}`, imgBuffer);
65
- // ── Add relationship ─────────────────────────────────────
66
- const rId = addImageRelationship(zip, mediaFileName);
67
- // ── Ensure Content_Types entry ───────────────────────────
68
- ensureContentType(zip, ext);
69
- // ── Compute dimensions (EMU) ─────────────────────────────
70
- const widthPx = op.width ?? DEFAULT_IMAGE_WIDTH;
71
- const heightPx = op.height ?? DEFAULT_IMAGE_HEIGHT;
72
- const widthEmu = pixelsToEmu(widthPx);
73
- const heightEmu = pixelsToEmu(heightPx);
74
- // ── Build drawing XML ────────────────────────────────────
75
- const altText = op.altText ?? baseName;
76
- const drawingXmlStr = buildDrawingXml(rId, widthEmu, heightEmu, altText, mediaFileName);
77
- // ── Parse drawing XML into a paragraph ───────────────────
78
- const drawingFragment = new DOMParser().parseFromString(`<w:p xmlns:w="${NAMESPACES.W}">` +
79
- `<w:r>${drawingXmlStr}</w:r></w:p>`, 'application/xml');
80
- const imgP = doc.importNode(drawingFragment.documentElement, true);
81
- // ── Insert at the correct position ──────────────────────
82
- if (position === 'before') {
83
- // Insert BEFORE the matched paragraph
84
- body.insertBefore(imgP, child);
85
- }
86
- else {
87
- // Insert AFTER the matched paragraph
88
- const nextSibling = child.nextSibling;
89
- if (nextSibling) {
90
- body.insertBefore(imgP, nextSibling);
91
- }
92
- else {
93
- body.appendChild(imgP);
94
- }
95
- }
96
- return { op, status: 'applied', matched: 1 };
97
- }
98
- }
99
- return { op, status: 'skipped', matched: 0, reason: 'no_match' };
100
- }
101
- // ─── Drawing XML builder (shared with builders/image.ts) ────────────────
102
- function buildDrawingXml(rId, widthEmu, heightEmu, altText, fileName) {
103
- return (`<w:drawing xmlns:w="${NAMESPACES.W}">` +
104
- `<wp:inline distT="0" distB="0" distL="0" distR="0" ` +
105
- `xmlns:wp="${NAMESPACES.WP}">` +
106
- `<wp:extent cx="${widthEmu}" cy="${heightEmu}"/>` +
107
- `<wp:docPr id="1" name="${fileName}" descr="${escapeXmlAttr(altText)}"/>` +
108
- `<a:graphic xmlns:a="${NAMESPACES.A}">` +
109
- `<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">` +
110
- `<pic:pic xmlns:pic="${NAMESPACES.PIC}">` +
111
- `<pic:nvPicPr>` +
112
- `<pic:cNvPr id="0" name="${fileName}" descr="${escapeXmlAttr(altText)}"/>` +
113
- `<pic:cNvPicPr/>` +
114
- `</pic:nvPicPr>` +
115
- `<pic:blipFill>` +
116
- `<a:blip r:embed="${rId}" xmlns:r="${NAMESPACES.R}"/>` +
117
- `<a:stretch><a:fillRect/></a:stretch>` +
118
- `</pic:blipFill>` +
119
- `<pic:spPr>` +
120
- `<a:xfrm><a:off x="0" y="0"/><a:ext cx="${widthEmu}" cy="${heightEmu}"/></a:xfrm>` +
121
- `<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>` +
122
- `</pic:spPr>` +
123
- `</pic:pic>` +
124
- `</a:graphicData>` +
125
- `</a:graphic>` +
126
- `</wp:inline>` +
127
- `</w:drawing>`);
128
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Op: insert_paragraph_after_text
3
- *
4
- * Find the FIRST paragraph whose trimmed text === `after`, then insert
5
- * a new w:p immediately after it. Optionally applies a style to the
6
- * new paragraph.
7
- *
8
- * NOTE: This is a structural op — it increases bodyChildCount by 1.
9
- * The orchestrator must account for this when validating invariants.
10
- */
11
- import type { InsertParagraphAfterTextOp, OpResult } from '../types.js';
12
- export declare function applyInsertParagraphAfterText(body: Element, op: InsertParagraphAfterTextOp): OpResult;
@@ -1,74 +0,0 @@
1
- /**
2
- * Op: insert_paragraph_after_text
3
- *
4
- * Find the FIRST paragraph whose trimmed text === `after`, then insert
5
- * a new w:p immediately after it. Optionally applies a style to the
6
- * new paragraph.
7
- *
8
- * NOTE: This is a structural op — it increases bodyChildCount by 1.
9
- * The orchestrator must account for this when validating invariants.
10
- */
11
- import { getBodyChildren, getParagraphText } from '../dom.js';
12
- export function applyInsertParagraphAfterText(body, op) {
13
- const children = getBodyChildren(body);
14
- const target = op.after.trim();
15
- // Special case: if document is empty, append the paragraph
16
- if (children.length === 0) {
17
- const doc = body.ownerDocument;
18
- if (!doc)
19
- return { op, status: 'skipped', matched: 0, reason: 'no_owner_document' };
20
- const newP = doc.createElement('w:p');
21
- if (op.style) {
22
- const pPr = doc.createElement('w:pPr');
23
- const pStyle = doc.createElement('w:pStyle');
24
- pStyle.setAttribute('w:val', op.style);
25
- pPr.appendChild(pStyle);
26
- newP.appendChild(pPr);
27
- }
28
- const newR = doc.createElement('w:r');
29
- const newT = doc.createElement('w:t');
30
- newT.setAttribute('xml:space', 'preserve');
31
- newT.textContent = op.text;
32
- newR.appendChild(newT);
33
- newP.appendChild(newR);
34
- body.appendChild(newP);
35
- return { op, status: 'applied', matched: 0, reason: 'empty_document_append' };
36
- }
37
- // Normal case: find matching paragraph
38
- for (let i = 0; i < children.length; i++) {
39
- const child = children[i];
40
- if (child.nodeName !== 'w:p')
41
- continue;
42
- if (getParagraphText(child).trim() === target) {
43
- const doc = body.ownerDocument;
44
- if (!doc)
45
- return { op, status: 'skipped', matched: 0, reason: 'no_owner_document' };
46
- // Build new paragraph: <w:p><w:r><w:t>text</w:t></w:r></w:p>
47
- const newP = doc.createElement('w:p');
48
- // Optionally set style
49
- if (op.style) {
50
- const pPr = doc.createElement('w:pPr');
51
- const pStyle = doc.createElement('w:pStyle');
52
- pStyle.setAttribute('w:val', op.style);
53
- pPr.appendChild(pStyle);
54
- newP.appendChild(pPr);
55
- }
56
- const newR = doc.createElement('w:r');
57
- const newT = doc.createElement('w:t');
58
- newT.setAttribute('xml:space', 'preserve');
59
- newT.textContent = op.text;
60
- newR.appendChild(newT);
61
- newP.appendChild(newR);
62
- // Insert after the matched child
63
- const nextSibling = child.nextSibling;
64
- if (nextSibling) {
65
- body.insertBefore(newP, nextSibling);
66
- }
67
- else {
68
- body.appendChild(newP);
69
- }
70
- return { op, status: 'applied', matched: 1 };
71
- }
72
- }
73
- return { op, status: 'skipped', matched: 0, reason: 'no_match' };
74
- }
@@ -1,19 +0,0 @@
1
- /**
2
- * Op: insert_table
3
- *
4
- * Insert a new w:tbl (table) relative to a paragraph anchor.
5
- *
6
- * Supports two positioning modes:
7
- * - `after` — insert immediately AFTER the first paragraph matching text
8
- * - `before` — insert immediately BEFORE the first paragraph matching text
9
- *
10
- * Exactly one of `after` or `before` must be provided.
11
- *
12
- * Accepts `headers` (optional) and `rows` as string arrays.
13
- * Optionally accepts `colWidths` (array of numbers in twips).
14
- *
15
- * This is a structural op — increases bodyChildCount by 1.
16
- * The orchestrator must account for this when validating invariants.
17
- */
18
- import type { InsertTableOp, OpResult } from '../types.js';
19
- export declare function applyInsertTable(body: Element, op: InsertTableOp): OpResult;
@@ -1,57 +0,0 @@
1
- /**
2
- * Op: insert_table
3
- *
4
- * Insert a new w:tbl (table) relative to a paragraph anchor.
5
- *
6
- * Supports two positioning modes:
7
- * - `after` — insert immediately AFTER the first paragraph matching text
8
- * - `before` — insert immediately BEFORE the first paragraph matching text
9
- *
10
- * Exactly one of `after` or `before` must be provided.
11
- *
12
- * Accepts `headers` (optional) and `rows` as string arrays.
13
- * Optionally accepts `colWidths` (array of numbers in twips).
14
- *
15
- * This is a structural op — increases bodyChildCount by 1.
16
- * The orchestrator must account for this when validating invariants.
17
- */
18
- import { getBodyChildren, getParagraphText } from '../dom.js';
19
- import { buildTable } from '../builders/index.js';
20
- // ─── Op implementation ───────────────────────────────────────────────
21
- export function applyInsertTable(body, op) {
22
- // Determine anchor text and position
23
- const anchorText = op.before ?? op.after;
24
- const position = op.before ? 'before' : 'after';
25
- if (!anchorText) {
26
- return { op, status: 'skipped', matched: 0, reason: 'no_anchor: provide "after" or "before"' };
27
- }
28
- const children = getBodyChildren(body);
29
- const target = anchorText.trim();
30
- for (let i = 0; i < children.length; i++) {
31
- const child = children[i];
32
- if (child.nodeName !== 'w:p')
33
- continue;
34
- if (getParagraphText(child).trim() === target) {
35
- const doc = body.ownerDocument;
36
- if (!doc)
37
- return { op, status: 'skipped', matched: 0, reason: 'no_owner_document' };
38
- const tbl = buildTable(doc, op);
39
- if (position === 'before') {
40
- // Insert BEFORE the matched paragraph
41
- body.insertBefore(tbl, child);
42
- }
43
- else {
44
- // Insert AFTER the matched paragraph
45
- const nextSibling = child.nextSibling;
46
- if (nextSibling) {
47
- body.insertBefore(tbl, nextSibling);
48
- }
49
- else {
50
- body.appendChild(tbl);
51
- }
52
- }
53
- return { op, status: 'applied', matched: 1 };
54
- }
55
- }
56
- return { op, status: 'skipped', matched: 0, reason: 'no_match' };
57
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Op: replace_hyperlink_url
3
- *
4
- * Find all hyperlink relationships in word/_rels/document.xml.rels
5
- * whose Target matches `oldUrl` and replace with `newUrl`.
6
- *
7
- * This op modifies the .rels file inside the ZIP — not document.xml body.
8
- * It receives the PizZip instance from the orchestrator.
9
- */
10
- import PizZip from 'pizzip';
11
- import type { ReplaceHyperlinkUrlOp, OpResult } from '../types.js';
12
- export declare function applyReplaceHyperlinkUrl(_body: Element, op: ReplaceHyperlinkUrlOp, zip: PizZip): OpResult;
@@ -1,37 +0,0 @@
1
- /**
2
- * Op: replace_hyperlink_url
3
- *
4
- * Find all hyperlink relationships in word/_rels/document.xml.rels
5
- * whose Target matches `oldUrl` and replace with `newUrl`.
6
- *
7
- * This op modifies the .rels file inside the ZIP — not document.xml body.
8
- * It receives the PizZip instance from the orchestrator.
9
- */
10
- import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
11
- import { nodeListToArray } from '../dom.js';
12
- export function applyReplaceHyperlinkUrl(_body, op, zip) {
13
- const relsPath = 'word/_rels/document.xml.rels';
14
- const relsEntry = zip.file(relsPath);
15
- if (!relsEntry) {
16
- return { op, status: 'skipped', matched: 0, reason: 'no_rels_file' };
17
- }
18
- const relsXml = relsEntry.asText();
19
- const relsDom = new DOMParser().parseFromString(relsXml, 'application/xml');
20
- const relationships = relsDom.getElementsByTagName('Relationship');
21
- let matched = 0;
22
- for (const rel of nodeListToArray(relationships)) {
23
- const relEl = rel;
24
- const target = relEl.getAttribute('Target');
25
- if (target === op.oldUrl) {
26
- relEl.setAttribute('Target', op.newUrl);
27
- matched++;
28
- }
29
- }
30
- if (matched === 0) {
31
- return { op, status: 'skipped', matched: 0, reason: 'url_not_found' };
32
- }
33
- // Write modified .rels back to zip
34
- const newRelsXml = new XMLSerializer().serializeToString(relsDom);
35
- zip.file(relsPath, newRelsXml);
36
- return { op, status: 'applied', matched };
37
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Op: replace_paragraph_at_body_index
3
- *
4
- * Target the child of w:body at the given bodyChildIndex.
5
- * If it is not a w:p → skip with reason "not_a_paragraph".
6
- * Otherwise apply the same minimal text replacement.
7
- */
8
- import type { ReplaceParagraphAtBodyIndexOp, OpResult } from '../types.js';
9
- export declare function applyReplaceParagraphAtBodyIndex(body: Element, op: ReplaceParagraphAtBodyIndexOp): OpResult;
@@ -1,25 +0,0 @@
1
- /**
2
- * Op: replace_paragraph_at_body_index
3
- *
4
- * Target the child of w:body at the given bodyChildIndex.
5
- * If it is not a w:p → skip with reason "not_a_paragraph".
6
- * Otherwise apply the same minimal text replacement.
7
- */
8
- import { getBodyChildren, setParagraphTextMinimal } from '../dom.js';
9
- export function applyReplaceParagraphAtBodyIndex(body, op) {
10
- const children = getBodyChildren(body);
11
- if (op.bodyChildIndex < 0 || op.bodyChildIndex >= children.length) {
12
- return {
13
- op,
14
- status: 'skipped',
15
- matched: 0,
16
- reason: `bodyChildIndex ${op.bodyChildIndex} out of range (0..${children.length - 1})`,
17
- };
18
- }
19
- const child = children[op.bodyChildIndex];
20
- if (child.nodeName !== 'w:p') {
21
- return { op, status: 'skipped', matched: 0, reason: 'not_a_paragraph' };
22
- }
23
- setParagraphTextMinimal(child, op.to);
24
- return { op, status: 'applied', matched: 1 };
25
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Op: replace_paragraph_text_exact
3
- *
4
- * Find FIRST paragraph whose trimmed text === `from` **anywhere in the body**,
5
- * including paragraphs inside table cells, content controls, etc.
6
- *
7
- * Replacement behavior:
8
- * - Replaces the matched paragraph's text while preserving all its run styles
9
- * - Preserves all other paragraphs in the same cell (if the paragraph is in a table cell)
10
- * - Preserves paragraph properties (w:pPr) and run properties (w:rPr)
11
- *
12
- * This is useful when you want to replace a specific paragraph by its exact text,
13
- * especially in table cells where you want to replace one paragraph while keeping
14
- * others intact. For example, replacing "LAWN AND LANDSCAPE" with "EARTH AND MOUNTAIN"
15
- * in a cell that also contains a subtitle paragraph will preserve the subtitle.
16
- *
17
- * Note: For replacing entire cell content (matching by full cell text), use
18
- * `replace_table_cell_text` instead.
19
- */
20
- import type { ReplaceParagraphTextExactOp, OpResult } from '../types.js';
21
- export declare function applyReplaceParagraphTextExact(body: Element, op: ReplaceParagraphTextExactOp): OpResult;
@@ -1,36 +0,0 @@
1
- /**
2
- * Op: replace_paragraph_text_exact
3
- *
4
- * Find FIRST paragraph whose trimmed text === `from` **anywhere in the body**,
5
- * including paragraphs inside table cells, content controls, etc.
6
- *
7
- * Replacement behavior:
8
- * - Replaces the matched paragraph's text while preserving all its run styles
9
- * - Preserves all other paragraphs in the same cell (if the paragraph is in a table cell)
10
- * - Preserves paragraph properties (w:pPr) and run properties (w:rPr)
11
- *
12
- * This is useful when you want to replace a specific paragraph by its exact text,
13
- * especially in table cells where you want to replace one paragraph while keeping
14
- * others intact. For example, replacing "LAWN AND LANDSCAPE" with "EARTH AND MOUNTAIN"
15
- * in a cell that also contains a subtitle paragraph will preserve the subtitle.
16
- *
17
- * Note: For replacing entire cell content (matching by full cell text), use
18
- * `replace_table_cell_text` instead.
19
- */
20
- import { getParagraphText, setParagraphTextPreservingStyles } from '../dom.js';
21
- export function applyReplaceParagraphTextExact(body, op) {
22
- const target = op.from.trim();
23
- // Traverse **all** paragraphs in the body, not just direct body children.
24
- // This includes paragraphs inside table cells, content controls, etc.
25
- const paragraphs = body.getElementsByTagName('w:p');
26
- for (let i = 0; i < paragraphs.length; i++) {
27
- const p = paragraphs.item(i);
28
- const paragraphText = getParagraphText(p).trim();
29
- if (paragraphText === target) {
30
- // Preserve all run styles (colors, bold, italic, etc.) when replacing
31
- setParagraphTextPreservingStyles(p, op.to);
32
- return { op, status: 'applied', matched: 1 };
33
- }
34
- }
35
- return { op, status: 'skipped', matched: 0, reason: 'no_match' };
36
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Op: replace_table_cell_text
3
- *
4
- * Goal: Replace the "logical value" of a cell while preserving layout and styles.
5
- *
6
- * Matching strategy (tried in order):
7
- * 1. Match by full cell text (all paragraphs joined with spaces)
8
- * 2. Match by first paragraph text only
9
- *
10
- * When the caller passes FULL cell text in `from` / `to` (common for LLMs), we
11
- * interpret the change like this:
12
- *
13
- * from: "<OLD_TITLE> <SUBTITLE ...>"
14
- * to: "<NEW_TITLE> <SUBTITLE ...>"
15
- *
16
- * i.e. only the *title* (first paragraph) changed, the rest of the cell content
17
- * stayed the same. We detect the unchanged suffix and compute NEW_TITLE by
18
- * stripping that suffix from `to`. Then we only change the first paragraph text,
19
- * keeping all other paragraphs (subtitle, etc.) exactly as they were.
20
- *
21
- * If we cannot safely detect that pattern, we fall back to treating `from`/`to`
22
- * as simple first‑paragraph values.
23
- */
24
- import type { ReplaceTableCellTextOp, OpResult } from '../types.js';
25
- export declare function applyReplaceTableCellText(body: Element, op: ReplaceTableCellTextOp): OpResult;