@wonderwhy-er/desktop-commander 0.2.37 → 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.
- package/README.md +290 -100
- package/dist/command-manager.js +6 -3
- package/dist/config-field-definitions.d.ts +41 -0
- package/dist/config-field-definitions.js +37 -0
- package/dist/config-manager.d.ts +2 -0
- package/dist/config-manager.js +22 -2
- package/dist/handlers/filesystem-handlers.d.ts +5 -0
- package/dist/handlers/filesystem-handlers.js +19 -12
- package/dist/remote-device/desktop-commander-integration.js +1 -1
- package/dist/remote-device/remote-channel.js +1 -1
- package/dist/search-manager.js +31 -38
- package/dist/server.js +11 -4
- package/dist/terminal-manager.js +4 -2
- package/dist/tools/config.d.ts +71 -0
- package/dist/tools/config.js +117 -2
- package/dist/tools/edit.js +34 -1
- package/dist/tools/filesystem.js +91 -3
- package/dist/tools/improved-process-tools.js +2 -1
- package/dist/tools/schemas.d.ts +3 -0
- package/dist/tools/schemas.js +1 -0
- package/dist/types.d.ts +0 -1
- package/dist/ui/config-editor/app.d.ts +43 -0
- package/dist/ui/config-editor/app.js +840 -0
- package/dist/ui/config-editor/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/array-modal.js +185 -0
- package/dist/ui/config-editor/config-editor-runtime.js +150 -0
- package/dist/ui/config-editor/index.html +13 -0
- package/dist/ui/config-editor/main.js +2 -0
- package/dist/ui/config-editor/src/App.d.ts +43 -0
- package/dist/ui/config-editor/src/App.js +840 -0
- package/dist/ui/config-editor/src/array-modal.d.ts +19 -0
- package/dist/ui/config-editor/src/array-modal.js +185 -0
- package/dist/ui/config-editor/src/components/layout.d.ts +4 -0
- package/dist/ui/config-editor/src/components/layout.js +83 -0
- package/dist/ui/config-editor/src/components/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/components/toolbar.js +21 -0
- package/dist/ui/config-editor/src/config-values.d.ts +6 -0
- package/dist/ui/config-editor/src/config-values.js +61 -0
- package/dist/ui/config-editor/src/contracts.d.ts +14 -0
- package/dist/ui/config-editor/src/contracts.js +3 -0
- package/dist/ui/config-editor/src/directory-browser.d.ts +6 -0
- package/dist/ui/config-editor/src/directory-browser.js +71 -0
- package/dist/ui/config-editor/src/layout.d.ts +5 -0
- package/dist/ui/config-editor/src/layout.js +90 -0
- package/dist/ui/config-editor/src/main.js +2 -0
- package/dist/ui/config-editor/src/parsing.d.ts +5 -0
- package/dist/ui/config-editor/src/parsing.js +50 -0
- package/dist/ui/config-editor/src/toolbar.d.ts +1 -0
- package/dist/ui/config-editor/src/toolbar.js +18 -0
- package/dist/ui/config-editor/src/types.d.ts +17 -0
- package/dist/ui/config-editor/src/types.js +3 -0
- package/dist/ui/config-editor/src/utils/config-values.d.ts +9 -0
- package/dist/ui/config-editor/src/utils/config-values.js +61 -0
- package/dist/ui/config-editor/src/utils/directory-browser.d.ts +31 -0
- package/dist/ui/config-editor/src/utils/directory-browser.js +201 -0
- package/dist/ui/config-editor/src/utils/parsing.d.ts +8 -0
- package/dist/ui/config-editor/src/utils/parsing.js +50 -0
- package/dist/ui/config-editor/styles.css +587 -0
- package/dist/ui/file-preview/app.d.ts +8 -0
- package/dist/ui/file-preview/app.js +2020 -0
- package/dist/ui/file-preview/components/code-viewer.d.ts +6 -0
- package/dist/ui/file-preview/components/code-viewer.js +73 -0
- package/dist/ui/file-preview/components/highlighting.d.ts +2 -0
- package/dist/ui/file-preview/components/highlighting.js +54 -0
- package/dist/ui/file-preview/components/html-renderer.d.ts +5 -0
- package/dist/ui/file-preview/components/html-renderer.js +47 -0
- package/dist/ui/file-preview/components/markdown-renderer.d.ts +1 -0
- package/dist/ui/file-preview/components/markdown-renderer.js +67 -0
- package/dist/ui/file-preview/components/toolbar.d.ts +6 -0
- package/dist/ui/file-preview/components/toolbar.js +75 -0
- package/dist/ui/file-preview/image-preview.d.ts +3 -0
- package/dist/ui/file-preview/image-preview.js +21 -0
- package/dist/ui/file-preview/main.js +5 -0
- package/dist/ui/file-preview/markdown/editor.d.ts +36 -0
- package/dist/ui/file-preview/markdown/editor.js +643 -0
- package/dist/ui/file-preview/markdown/linking.d.ts +9 -0
- package/dist/ui/file-preview/markdown/linking.js +210 -0
- package/dist/ui/file-preview/markdown/outline.d.ts +7 -0
- package/dist/ui/file-preview/markdown/outline.js +40 -0
- package/dist/ui/file-preview/markdown/preview.d.ts +8 -0
- package/dist/ui/file-preview/markdown/preview.js +33 -0
- package/dist/ui/file-preview/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/markdown/toc.js +75 -0
- package/dist/ui/file-preview/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/markdown/utils.js +15 -0
- package/dist/ui/file-preview/markdown/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/markdown/workspace-controller.js +40 -0
- package/dist/ui/file-preview/preview-runtime.js +399 -13969
- package/dist/ui/file-preview/shared/preview-file-types.d.ts +1 -1
- package/dist/ui/file-preview/shared/preview-file-types.js +3 -1
- package/dist/ui/file-preview/src/App.d.ts +4 -0
- package/dist/ui/file-preview/src/App.js +564 -0
- package/dist/ui/file-preview/src/components/CodeViewer.d.ts +6 -0
- package/dist/ui/file-preview/src/components/CodeViewer.js +60 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.d.ts +8 -0
- package/dist/ui/file-preview/src/components/HtmlRenderer.js +45 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.d.ts +1 -0
- package/dist/ui/file-preview/src/components/MarkdownRenderer.js +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.d.ts +15 -0
- package/dist/ui/file-preview/src/components/editor-toolbar.js +384 -0
- package/dist/ui/file-preview/src/components/html-renderer.d.ts +1 -5
- package/dist/ui/file-preview/src/components/html-renderer.js +11 -27
- package/dist/ui/file-preview/src/components/markdown-editor.d.ts +29 -0
- package/dist/ui/file-preview/src/components/markdown-editor.js +535 -0
- package/dist/ui/file-preview/src/components/markdown-renderer.js +47 -9
- package/dist/ui/file-preview/src/directory-controller.d.ts +8 -0
- package/dist/ui/file-preview/src/directory-controller.js +233 -0
- package/dist/ui/file-preview/src/document-layout.d.ts +20 -0
- package/dist/ui/file-preview/src/document-layout.js +109 -0
- package/dist/ui/file-preview/src/document-outline.d.ts +17 -0
- package/dist/ui/file-preview/src/document-outline.js +97 -0
- package/dist/ui/file-preview/src/document-workspace.d.ts +19 -0
- package/dist/ui/file-preview/src/document-workspace.js +33 -0
- package/dist/ui/file-preview/src/file-type-handlers.d.ts +10 -0
- package/dist/ui/file-preview/src/file-type-handlers.js +98 -0
- package/dist/ui/file-preview/src/host/external-actions.d.ts +19 -0
- package/dist/ui/file-preview/src/host/external-actions.js +94 -0
- package/dist/ui/file-preview/src/host/selection-context.d.ts +9 -0
- package/dist/ui/file-preview/src/host/selection-context.js +106 -0
- package/dist/ui/file-preview/src/markdown/block-merge.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown/block-merge.js +86 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.d.ts +40 -0
- package/dist/ui/file-preview/src/markdown/conflict-dialog.js +163 -0
- package/dist/ui/file-preview/src/markdown/controller.d.ts +38 -0
- package/dist/ui/file-preview/src/markdown/controller.js +921 -0
- package/dist/ui/file-preview/src/markdown/editor.d.ts +35 -0
- package/dist/ui/file-preview/src/markdown/editor.js +691 -0
- package/dist/ui/file-preview/src/markdown/link-modal.d.ts +13 -0
- package/dist/ui/file-preview/src/markdown/link-modal.js +213 -0
- package/dist/ui/file-preview/src/markdown/linking.d.ts +16 -0
- package/dist/ui/file-preview/src/markdown/linking.js +228 -0
- package/dist/ui/file-preview/src/markdown/outline.d.ts +2 -0
- package/dist/ui/file-preview/src/markdown/outline.js +16 -0
- package/dist/ui/file-preview/src/markdown/parser.d.ts +30 -0
- package/dist/ui/file-preview/src/markdown/parser.js +38 -0
- package/dist/ui/file-preview/src/markdown/preview.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/preview.js +20 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown/raw-editor.js +61 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.d.ts +14 -0
- package/dist/ui/file-preview/src/markdown/selection-toolbar.js +128 -0
- package/dist/ui/file-preview/src/markdown/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.d.ts +36 -0
- package/dist/ui/file-preview/src/markdown-workspace/editor.js +643 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.d.ts +9 -0
- package/dist/ui/file-preview/src/markdown-workspace/linking.js +210 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.d.ts +7 -0
- package/dist/ui/file-preview/src/markdown-workspace/outline.js +40 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.d.ts +8 -0
- package/dist/ui/file-preview/src/markdown-workspace/preview.js +33 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.d.ts +3 -0
- package/dist/ui/file-preview/src/markdown-workspace/slugify.js +31 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.d.ts +11 -0
- package/dist/ui/file-preview/src/markdown-workspace/toc.js +75 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.d.ts +1 -0
- package/dist/ui/file-preview/src/markdown-workspace/utils.js +15 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.d.ts +25 -0
- package/dist/ui/file-preview/src/markdown-workspace/workspace-controller.js +40 -0
- package/dist/ui/file-preview/src/model.d.ts +34 -0
- package/dist/ui/file-preview/src/panel-actions.d.ts +17 -0
- package/dist/ui/file-preview/src/panel-actions.js +182 -0
- package/dist/ui/file-preview/src/path-utils.d.ts +6 -0
- package/dist/ui/file-preview/src/path-utils.js +64 -0
- package/dist/ui/file-preview/src/payload-utils.d.ts +11 -0
- package/dist/ui/file-preview/src/payload-utils.js +94 -0
- package/dist/ui/file-preview/styles.css +1144 -277
- package/dist/ui/file-preview/types.d.ts +1 -0
- package/dist/ui/file-preview/types.js +1 -0
- package/dist/ui/resources.d.ts +7 -0
- package/dist/ui/resources.js +16 -2
- package/dist/ui/server-integration.d.ts +13 -0
- package/dist/ui/server-integration.js +31 -0
- package/dist/ui/shared/ToolHeader.d.ts +9 -0
- package/dist/ui/shared/ToolHeader.js +29 -0
- package/dist/ui/shared/app-bootstrap.d.ts +9 -0
- package/dist/ui/shared/app-bootstrap.js +15 -0
- package/dist/ui/shared/compact-row.d.ts +11 -0
- package/dist/ui/shared/compact-row.js +18 -0
- package/dist/ui/shared/guards.d.ts +1 -0
- package/dist/ui/shared/guards.js +3 -0
- package/dist/ui/shared/host-context.d.ts +15 -0
- package/dist/ui/shared/host-context.js +51 -0
- package/dist/ui/shared/host-lifecycle.d.ts +1 -0
- package/dist/ui/shared/host-lifecycle.js +8 -2
- package/dist/ui/shared/tool-bridge.d.ts +30 -0
- package/dist/ui/shared/tool-bridge.js +137 -0
- package/dist/ui/shared/tool-shell.d.ts +9 -0
- package/dist/ui/shared/tool-shell.js +46 -4
- package/dist/ui/shared/ui-event-tracker.d.ts +9 -0
- package/dist/ui/shared/ui-event-tracker.js +27 -0
- package/dist/ui/shared/widget-state.d.ts +6 -1
- package/dist/ui/shared/widget-state.js +102 -4
- package/dist/utils/capture.js +3 -3
- package/dist/utils/files/base.d.ts +2 -0
- package/dist/utils/open-browser.js +1 -1
- package/dist/utils/ui-call-context.d.ts +8 -0
- package/dist/utils/ui-call-context.js +72 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -4
- package/dist/data/spec-kit-prompts.json +0 -123
- package/dist/handlers/node-handlers.d.ts +0 -6
- package/dist/handlers/node-handlers.js +0 -73
- package/dist/handlers/test-crash-handler.d.ts +0 -11
- package/dist/handlers/test-crash-handler.js +0 -26
- package/dist/http-index.d.ts +0 -45
- package/dist/http-index.js +0 -51
- package/dist/http-server-auto-tunnel.js +0 -667
- package/dist/http-server-named-tunnel.d.ts +0 -2
- package/dist/http-server-named-tunnel.js +0 -167
- package/dist/http-server-tunnel.d.ts +0 -2
- package/dist/http-server-tunnel.js +0 -111
- package/dist/http-server.d.ts +0 -2
- package/dist/http-server.js +0 -270
- package/dist/index-oauth.d.ts +0 -2
- package/dist/index-oauth.js +0 -201
- package/dist/oauth/auth-middleware.d.ts +0 -20
- package/dist/oauth/auth-middleware.js +0 -62
- package/dist/oauth/index.d.ts +0 -3
- package/dist/oauth/index.js +0 -3
- package/dist/oauth/oauth-manager.d.ts +0 -80
- package/dist/oauth/oauth-manager.js +0 -179
- package/dist/oauth/oauth-routes.d.ts +0 -3
- package/dist/oauth/oauth-routes.js +0 -377
- package/dist/oauth/provider.d.ts +0 -22
- package/dist/oauth/provider.js +0 -124
- package/dist/oauth/server.d.ts +0 -18
- package/dist/oauth/server.js +0 -160
- package/dist/oauth/types.d.ts +0 -54
- package/dist/oauth/types.js +0 -2
- package/dist/remote-device/templates/auth-success.d.ts +0 -1
- package/dist/remote-device/templates/auth-success.js +0 -30
- package/dist/setup.log +0 -275
- package/dist/test-setup.js +0 -14
- package/dist/tools/docx/builders/html-builder.d.ts +0 -17
- package/dist/tools/docx/builders/html-builder.js +0 -92
- package/dist/tools/docx/builders/image.d.ts +0 -14
- package/dist/tools/docx/builders/image.js +0 -84
- package/dist/tools/docx/builders/index.d.ts +0 -11
- package/dist/tools/docx/builders/index.js +0 -11
- package/dist/tools/docx/builders/markdown-builder.d.ts +0 -2
- package/dist/tools/docx/builders/markdown-builder.js +0 -260
- package/dist/tools/docx/builders/paragraph.d.ts +0 -12
- package/dist/tools/docx/builders/paragraph.js +0 -29
- package/dist/tools/docx/builders/table.d.ts +0 -10
- package/dist/tools/docx/builders/table.js +0 -138
- package/dist/tools/docx/builders/utils.d.ts +0 -5
- package/dist/tools/docx/builders/utils.js +0 -18
- package/dist/tools/docx/constants.d.ts +0 -32
- package/dist/tools/docx/constants.js +0 -61
- package/dist/tools/docx/converters/markdown-to-html.d.ts +0 -17
- package/dist/tools/docx/converters/markdown-to-html.js +0 -111
- package/dist/tools/docx/create.d.ts +0 -21
- package/dist/tools/docx/create.js +0 -386
- package/dist/tools/docx/dom.d.ts +0 -139
- package/dist/tools/docx/dom.js +0 -448
- package/dist/tools/docx/errors.d.ts +0 -28
- package/dist/tools/docx/errors.js +0 -48
- package/dist/tools/docx/extractors/images.d.ts +0 -14
- package/dist/tools/docx/extractors/images.js +0 -40
- package/dist/tools/docx/extractors/metadata.d.ts +0 -14
- package/dist/tools/docx/extractors/metadata.js +0 -64
- package/dist/tools/docx/extractors/sections.d.ts +0 -14
- package/dist/tools/docx/extractors/sections.js +0 -61
- package/dist/tools/docx/html.d.ts +0 -17
- package/dist/tools/docx/html.js +0 -111
- package/dist/tools/docx/index.d.ts +0 -10
- package/dist/tools/docx/index.js +0 -10
- package/dist/tools/docx/markdown.d.ts +0 -84
- package/dist/tools/docx/markdown.js +0 -507
- package/dist/tools/docx/modify.d.ts +0 -28
- package/dist/tools/docx/modify.js +0 -271
- package/dist/tools/docx/operations/handlers/index.d.ts +0 -39
- package/dist/tools/docx/operations/handlers/index.js +0 -152
- package/dist/tools/docx/operations/html-manipulator.d.ts +0 -24
- package/dist/tools/docx/operations/html-manipulator.js +0 -352
- package/dist/tools/docx/operations/index.d.ts +0 -14
- package/dist/tools/docx/operations/index.js +0 -61
- package/dist/tools/docx/operations/operation-handlers.d.ts +0 -3
- package/dist/tools/docx/operations/operation-handlers.js +0 -67
- package/dist/tools/docx/operations/preprocessor.d.ts +0 -14
- package/dist/tools/docx/operations/preprocessor.js +0 -44
- package/dist/tools/docx/operations/xml-replacer.d.ts +0 -9
- package/dist/tools/docx/operations/xml-replacer.js +0 -35
- package/dist/tools/docx/operations.d.ts +0 -13
- package/dist/tools/docx/operations.js +0 -13
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.d.ts +0 -11
- package/dist/tools/docx/ops/delete-paragraph-at-body-index.js +0 -23
- package/dist/tools/docx/ops/header-replace-text-exact.d.ts +0 -13
- package/dist/tools/docx/ops/header-replace-text-exact.js +0 -55
- package/dist/tools/docx/ops/index.d.ts +0 -17
- package/dist/tools/docx/ops/index.js +0 -70
- package/dist/tools/docx/ops/insert-image-after-text.d.ts +0 -24
- package/dist/tools/docx/ops/insert-image-after-text.js +0 -128
- package/dist/tools/docx/ops/insert-paragraph-after-text.d.ts +0 -12
- package/dist/tools/docx/ops/insert-paragraph-after-text.js +0 -74
- package/dist/tools/docx/ops/insert-table-after-text.d.ts +0 -19
- package/dist/tools/docx/ops/insert-table-after-text.js +0 -57
- package/dist/tools/docx/ops/replace-hyperlink-url.d.ts +0 -12
- package/dist/tools/docx/ops/replace-hyperlink-url.js +0 -37
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.d.ts +0 -9
- package/dist/tools/docx/ops/replace-paragraph-at-body-index.js +0 -25
- package/dist/tools/docx/ops/replace-paragraph-text-exact.d.ts +0 -21
- package/dist/tools/docx/ops/replace-paragraph-text-exact.js +0 -36
- package/dist/tools/docx/ops/replace-table-cell-text.d.ts +0 -25
- package/dist/tools/docx/ops/replace-table-cell-text.js +0 -85
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.d.ts +0 -9
- package/dist/tools/docx/ops/set-color-for-paragraph-exact.js +0 -24
- package/dist/tools/docx/ops/set-color-for-style.d.ts +0 -13
- package/dist/tools/docx/ops/set-color-for-style.js +0 -31
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.d.ts +0 -8
- package/dist/tools/docx/ops/set-paragraph-style-at-body-index.js +0 -57
- package/dist/tools/docx/ops/table-set-cell-text.d.ts +0 -9
- package/dist/tools/docx/ops/table-set-cell-text.js +0 -40
- package/dist/tools/docx/parsers/image-extractor.d.ts +0 -18
- package/dist/tools/docx/parsers/image-extractor.js +0 -61
- package/dist/tools/docx/parsers/index.d.ts +0 -9
- package/dist/tools/docx/parsers/index.js +0 -9
- package/dist/tools/docx/parsers/paragraph-parser.d.ts +0 -2
- package/dist/tools/docx/parsers/paragraph-parser.js +0 -88
- package/dist/tools/docx/parsers/table-parser.d.ts +0 -9
- package/dist/tools/docx/parsers/table-parser.js +0 -72
- package/dist/tools/docx/parsers/xml-parser.d.ts +0 -25
- package/dist/tools/docx/parsers/xml-parser.js +0 -71
- package/dist/tools/docx/parsers/zip-reader.d.ts +0 -23
- package/dist/tools/docx/parsers/zip-reader.js +0 -52
- package/dist/tools/docx/read.d.ts +0 -27
- package/dist/tools/docx/read.js +0 -308
- package/dist/tools/docx/relationships.d.ts +0 -22
- package/dist/tools/docx/relationships.js +0 -76
- package/dist/tools/docx/structure.d.ts +0 -25
- package/dist/tools/docx/structure.js +0 -102
- package/dist/tools/docx/styled-html-parser.d.ts +0 -23
- package/dist/tools/docx/styled-html-parser.js +0 -1262
- package/dist/tools/docx/types.d.ts +0 -213
- package/dist/tools/docx/types.js +0 -5
- package/dist/tools/docx/utils/escaping.d.ts +0 -13
- package/dist/tools/docx/utils/escaping.js +0 -26
- package/dist/tools/docx/utils/images.d.ts +0 -9
- package/dist/tools/docx/utils/images.js +0 -26
- package/dist/tools/docx/utils/index.d.ts +0 -12
- package/dist/tools/docx/utils/index.js +0 -17
- package/dist/tools/docx/utils/markdown.d.ts +0 -13
- package/dist/tools/docx/utils/markdown.js +0 -32
- package/dist/tools/docx/utils/paths.d.ts +0 -15
- package/dist/tools/docx/utils/paths.js +0 -27
- package/dist/tools/docx/utils/versioning.d.ts +0 -25
- package/dist/tools/docx/utils/versioning.js +0 -55
- package/dist/tools/docx/utils.d.ts +0 -101
- package/dist/tools/docx/utils.js +0 -299
- package/dist/tools/docx/validate.d.ts +0 -33
- package/dist/tools/docx/validate.js +0 -49
- package/dist/tools/docx/validators.d.ts +0 -13
- package/dist/tools/docx/validators.js +0 -40
- package/dist/tools/docx/write.d.ts +0 -17
- package/dist/tools/docx/write.js +0 -88
- package/dist/tools/docx/xml-view-test.js +0 -63
- package/dist/tools/docx/xml-view.d.ts +0 -56
- package/dist/tools/docx/xml-view.js +0 -169
- package/dist/tools/docx/zip.d.ts +0 -21
- package/dist/tools/docx/zip.js +0 -35
- package/dist/tools/pdf-processor.js +0 -3
- package/dist/tools/search.d.ts +0 -32
- package/dist/tools/search.js +0 -202
- package/dist/ui/file-preview/src/app.d.ts +0 -4
- package/dist/ui/file-preview/src/app.js +0 -800
- package/dist/utils/crash-logger.d.ts +0 -18
- package/dist/utils/crash-logger.js +0 -44
- package/dist/utils/dedent.d.ts +0 -8
- package/dist/utils/dedent.js +0 -38
- /package/dist/{http-server-auto-tunnel.d.ts → ui/config-editor/main.d.ts} +0 -0
- /package/dist/{test-docx.d.ts → ui/config-editor/src/main.d.ts} +0 -0
- /package/dist/{tools/docx/xml-view-test.d.ts → ui/file-preview/main.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.d.ts → Toolbar.d.ts} +0 -0
- /package/dist/ui/file-preview/src/components/{toolbar.js → Toolbar.js} +0 -0
- /package/dist/{tools/pdf-processor.d.ts → ui/file-preview/src/model.js} +0 -0
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions for DOCX operations.
|
|
3
|
-
* Single source of truth for every type used across the DOCX module.
|
|
4
|
-
*/
|
|
5
|
-
export interface DocxMetadata {
|
|
6
|
-
title?: string;
|
|
7
|
-
author?: string;
|
|
8
|
-
subject?: string;
|
|
9
|
-
creator?: string;
|
|
10
|
-
paragraphCount: number;
|
|
11
|
-
wordCount: number;
|
|
12
|
-
}
|
|
13
|
-
export interface DocxParagraph {
|
|
14
|
-
index: number;
|
|
15
|
-
text: string;
|
|
16
|
-
hasText: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface DocxRun {
|
|
19
|
-
text: string;
|
|
20
|
-
bold?: boolean;
|
|
21
|
-
italic?: boolean;
|
|
22
|
-
color?: string;
|
|
23
|
-
fontSize?: number;
|
|
24
|
-
fontName?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface DocxModification {
|
|
27
|
-
type: 'replace' | 'insert' | 'delete' | 'style';
|
|
28
|
-
paragraphIndex?: number;
|
|
29
|
-
findText?: string;
|
|
30
|
-
replaceText?: string;
|
|
31
|
-
insertText?: string;
|
|
32
|
-
style?: {
|
|
33
|
-
color?: string;
|
|
34
|
-
bold?: boolean;
|
|
35
|
-
italic?: boolean;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export interface ParagraphOutline {
|
|
39
|
-
bodyChildIndex: number;
|
|
40
|
-
paragraphIndex: number;
|
|
41
|
-
style: string | null;
|
|
42
|
-
text: string;
|
|
43
|
-
}
|
|
44
|
-
export interface TableOutline {
|
|
45
|
-
bodyChildIndex: number;
|
|
46
|
-
tableIndex: number;
|
|
47
|
-
style: string | null;
|
|
48
|
-
headers?: string[];
|
|
49
|
-
rows: string[][];
|
|
50
|
-
}
|
|
51
|
-
export interface ImageOutline {
|
|
52
|
-
bodyChildIndex: number;
|
|
53
|
-
imageIndex: number;
|
|
54
|
-
mediaPath: string;
|
|
55
|
-
rId: string;
|
|
56
|
-
altText?: string;
|
|
57
|
-
}
|
|
58
|
-
export interface ReadDocxResult {
|
|
59
|
-
path: string;
|
|
60
|
-
paragraphs: ParagraphOutline[];
|
|
61
|
-
tables: TableOutline[];
|
|
62
|
-
images: ImageOutline[];
|
|
63
|
-
stylesSeen: string[];
|
|
64
|
-
counts: {
|
|
65
|
-
tables: number;
|
|
66
|
-
images: number;
|
|
67
|
-
bodyChildren: number;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
export interface WriteDocxStats {
|
|
71
|
-
tablesBefore: number;
|
|
72
|
-
tablesAfter: number;
|
|
73
|
-
bodyChildrenBefore: number;
|
|
74
|
-
bodyChildrenAfter: number;
|
|
75
|
-
bodySignatureBefore: string;
|
|
76
|
-
bodySignatureAfter: string;
|
|
77
|
-
}
|
|
78
|
-
export interface WriteDocxResult {
|
|
79
|
-
outputPath: string;
|
|
80
|
-
results: OpResult[];
|
|
81
|
-
stats: WriteDocxStats;
|
|
82
|
-
warnings: string[];
|
|
83
|
-
}
|
|
84
|
-
export interface BodySnapshot {
|
|
85
|
-
bodyChildCount: number;
|
|
86
|
-
tableCount: number;
|
|
87
|
-
signature: string;
|
|
88
|
-
}
|
|
89
|
-
export interface ReplaceParagraphTextExactOp {
|
|
90
|
-
type: 'replace_paragraph_text_exact';
|
|
91
|
-
from: string;
|
|
92
|
-
to: string;
|
|
93
|
-
}
|
|
94
|
-
export interface ReplaceParagraphAtBodyIndexOp {
|
|
95
|
-
type: 'replace_paragraph_at_body_index';
|
|
96
|
-
bodyChildIndex: number;
|
|
97
|
-
to: string;
|
|
98
|
-
}
|
|
99
|
-
export interface SetColorForStyleOp {
|
|
100
|
-
type: 'set_color_for_style';
|
|
101
|
-
style: string;
|
|
102
|
-
color: string;
|
|
103
|
-
}
|
|
104
|
-
export interface SetColorForParagraphExactOp {
|
|
105
|
-
type: 'set_color_for_paragraph_exact';
|
|
106
|
-
text: string;
|
|
107
|
-
color: string;
|
|
108
|
-
}
|
|
109
|
-
export interface SetParagraphStyleAtBodyIndexOp {
|
|
110
|
-
type: 'set_paragraph_style_at_body_index';
|
|
111
|
-
bodyChildIndex: number;
|
|
112
|
-
style: string;
|
|
113
|
-
}
|
|
114
|
-
export interface InsertParagraphAfterTextOp {
|
|
115
|
-
type: 'insert_paragraph_after_text';
|
|
116
|
-
after: string;
|
|
117
|
-
text: string;
|
|
118
|
-
style?: string;
|
|
119
|
-
}
|
|
120
|
-
export interface DeleteParagraphAtBodyIndexOp {
|
|
121
|
-
type: 'delete_paragraph_at_body_index';
|
|
122
|
-
bodyChildIndex: number;
|
|
123
|
-
}
|
|
124
|
-
export interface TableSetCellTextOp {
|
|
125
|
-
type: 'table_set_cell_text';
|
|
126
|
-
tableIndex: number;
|
|
127
|
-
row: number;
|
|
128
|
-
col: number;
|
|
129
|
-
text: string;
|
|
130
|
-
}
|
|
131
|
-
export interface ReplaceTableCellTextOp {
|
|
132
|
-
type: 'replace_table_cell_text';
|
|
133
|
-
from: string;
|
|
134
|
-
to: string;
|
|
135
|
-
}
|
|
136
|
-
export interface ReplaceHyperlinkUrlOp {
|
|
137
|
-
type: 'replace_hyperlink_url';
|
|
138
|
-
oldUrl: string;
|
|
139
|
-
newUrl: string;
|
|
140
|
-
}
|
|
141
|
-
export interface HeaderReplaceTextExactOp {
|
|
142
|
-
type: 'header_replace_text_exact';
|
|
143
|
-
from: string;
|
|
144
|
-
to: string;
|
|
145
|
-
}
|
|
146
|
-
export interface InsertTableOp {
|
|
147
|
-
type: 'insert_table';
|
|
148
|
-
/** Exact trimmed text of the paragraph to insert AFTER. Mutually exclusive with `before`. */
|
|
149
|
-
after?: string;
|
|
150
|
-
/** Exact trimmed text of the paragraph to insert BEFORE. Mutually exclusive with `after`. */
|
|
151
|
-
before?: string;
|
|
152
|
-
/** Optional header row (bold cells) */
|
|
153
|
-
headers?: string[];
|
|
154
|
-
/** Data rows — each row is an array of cell strings */
|
|
155
|
-
rows: string[][];
|
|
156
|
-
/** Optional column widths in twips (1/20 pt). Defaults to auto. */
|
|
157
|
-
colWidths?: number[];
|
|
158
|
-
/** Optional table style id (e.g. 'TableGrid') */
|
|
159
|
-
style?: string;
|
|
160
|
-
}
|
|
161
|
-
export interface InsertImageOp {
|
|
162
|
-
type: 'insert_image';
|
|
163
|
-
/** Exact trimmed text of the paragraph to insert AFTER. Mutually exclusive with `before`. */
|
|
164
|
-
after?: string;
|
|
165
|
-
/** Exact trimmed text of the paragraph to insert BEFORE. Mutually exclusive with `after`. */
|
|
166
|
-
before?: string;
|
|
167
|
-
/** Absolute or relative path to the image file */
|
|
168
|
-
imagePath: string;
|
|
169
|
-
/** Image width in pixels (default 300) */
|
|
170
|
-
width?: number;
|
|
171
|
-
/** Image height in pixels (default 200) */
|
|
172
|
-
height?: number;
|
|
173
|
-
/** Alt text for accessibility */
|
|
174
|
-
altText?: string;
|
|
175
|
-
}
|
|
176
|
-
export type DocxOp = ReplaceParagraphTextExactOp | ReplaceParagraphAtBodyIndexOp | SetColorForStyleOp | SetColorForParagraphExactOp | SetParagraphStyleAtBodyIndexOp | InsertParagraphAfterTextOp | DeleteParagraphAtBodyIndexOp | TableSetCellTextOp | ReplaceTableCellTextOp | ReplaceHyperlinkUrlOp | HeaderReplaceTextExactOp | InsertTableOp | InsertImageOp;
|
|
177
|
-
export interface OpResult {
|
|
178
|
-
op: DocxOp;
|
|
179
|
-
status: 'applied' | 'skipped';
|
|
180
|
-
matched: number;
|
|
181
|
-
reason?: string;
|
|
182
|
-
}
|
|
183
|
-
export interface DocxContentParagraph {
|
|
184
|
-
type: 'paragraph';
|
|
185
|
-
text: string;
|
|
186
|
-
style?: string | null;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Cell content can be:
|
|
190
|
-
* - A string (simple case, creates one paragraph)
|
|
191
|
-
* - An array of paragraphs (allows multiple paragraphs with different styles per cell)
|
|
192
|
-
*/
|
|
193
|
-
export type DocxTableCellContent = string | DocxContentParagraph[];
|
|
194
|
-
export interface DocxContentTable {
|
|
195
|
-
type: 'table';
|
|
196
|
-
/** Header cells - can be strings or arrays of paragraphs */
|
|
197
|
-
headers?: DocxTableCellContent[];
|
|
198
|
-
/** Data rows - each cell can be a string or array of paragraphs */
|
|
199
|
-
rows: DocxTableCellContent[][];
|
|
200
|
-
colWidths?: number[];
|
|
201
|
-
style?: string;
|
|
202
|
-
}
|
|
203
|
-
export interface DocxContentImage {
|
|
204
|
-
type: 'image';
|
|
205
|
-
imagePath: string;
|
|
206
|
-
width?: number;
|
|
207
|
-
height?: number;
|
|
208
|
-
altText?: string;
|
|
209
|
-
}
|
|
210
|
-
export type DocxContentItem = DocxContentParagraph | DocxContentTable | DocxContentImage;
|
|
211
|
-
export interface DocxContentStructure {
|
|
212
|
-
items: DocxContentItem[];
|
|
213
|
-
}
|
package/dist/tools/docx/types.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML Escaping Utilities
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for escaping HTML special characters and regex patterns.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/escaping
|
|
7
|
-
*/
|
|
8
|
-
/** Escape HTML special characters in text content. */
|
|
9
|
-
export declare function escapeHtml(text: string): string;
|
|
10
|
-
/** Escape a value for safe use inside an HTML attribute (double- and single-quoted). */
|
|
11
|
-
export declare function escapeHtmlAttribute(value: string): string;
|
|
12
|
-
/** Escape special regex characters for literal string matching. */
|
|
13
|
-
export declare function escapeRegExp(str: string): string;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML Escaping Utilities
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for escaping HTML special characters and regex patterns.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/escaping
|
|
7
|
-
*/
|
|
8
|
-
const HTML_ESCAPE_MAP = {
|
|
9
|
-
'&': '&',
|
|
10
|
-
'<': '<',
|
|
11
|
-
'>': '>',
|
|
12
|
-
'"': '"',
|
|
13
|
-
"'": ''',
|
|
14
|
-
};
|
|
15
|
-
/** Escape HTML special characters in text content. */
|
|
16
|
-
export function escapeHtml(text) {
|
|
17
|
-
return text.replace(/[&<>"']/g, (ch) => HTML_ESCAPE_MAP[ch] || ch);
|
|
18
|
-
}
|
|
19
|
-
/** Escape a value for safe use inside an HTML attribute (double- and single-quoted). */
|
|
20
|
-
export function escapeHtmlAttribute(value) {
|
|
21
|
-
return value.replace(/"/g, '"').replace(/'/g, ''');
|
|
22
|
-
}
|
|
23
|
-
/** Escape special regex characters for literal string matching. */
|
|
24
|
-
export function escapeRegExp(str) {
|
|
25
|
-
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
26
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Utilities
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for MIME type detection and image path handling.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/images
|
|
7
|
-
*/
|
|
8
|
-
/** Derive MIME type from a file extension or data URL. Returns `null` if unrecognised. */
|
|
9
|
-
export declare function getMimeType(source: string): string | null;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Utilities
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for MIME type detection and image path handling.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/images
|
|
7
|
-
*/
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { isDataUrl } from './paths.js';
|
|
10
|
-
/** Derive MIME type from a file extension or data URL. Returns `null` if unrecognised. */
|
|
11
|
-
export function getMimeType(source) {
|
|
12
|
-
if (isDataUrl(source)) {
|
|
13
|
-
const match = source.match(/^data:([^;]+);/);
|
|
14
|
-
return match ? match[1] : null;
|
|
15
|
-
}
|
|
16
|
-
const MIME_BY_EXT = {
|
|
17
|
-
'.png': 'image/png',
|
|
18
|
-
'.jpg': 'image/jpeg',
|
|
19
|
-
'.jpeg': 'image/jpeg',
|
|
20
|
-
'.gif': 'image/gif',
|
|
21
|
-
'.bmp': 'image/bmp',
|
|
22
|
-
'.webp': 'image/webp',
|
|
23
|
-
'.svg': 'image/svg+xml',
|
|
24
|
-
};
|
|
25
|
-
return MIME_BY_EXT[path.extname(source).toLowerCase()] || null;
|
|
26
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOCX Utilities — Re-exports
|
|
3
|
-
*
|
|
4
|
-
* Centralized re-exports for all utility modules.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils
|
|
7
|
-
*/
|
|
8
|
-
export { escapeHtml, escapeHtmlAttribute, escapeRegExp } from './escaping.js';
|
|
9
|
-
export { isDataUrl, isUrl, isDocxPath, resolveImagePath } from './paths.js';
|
|
10
|
-
export { getMimeType } from './images.js';
|
|
11
|
-
export { convertToHtmlIfNeeded } from './markdown.js';
|
|
12
|
-
export { generateOutputPath } from './versioning.js';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOCX Utilities — Re-exports
|
|
3
|
-
*
|
|
4
|
-
* Centralized re-exports for all utility modules.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils
|
|
7
|
-
*/
|
|
8
|
-
// Escaping
|
|
9
|
-
export { escapeHtml, escapeHtmlAttribute, escapeRegExp } from './escaping.js';
|
|
10
|
-
// Paths & URLs
|
|
11
|
-
export { isDataUrl, isUrl, isDocxPath, resolveImagePath } from './paths.js';
|
|
12
|
-
// Images
|
|
13
|
-
export { getMimeType } from './images.js';
|
|
14
|
-
// Markdown
|
|
15
|
-
export { convertToHtmlIfNeeded } from './markdown.js';
|
|
16
|
-
// Versioning
|
|
17
|
-
export { generateOutputPath } from './versioning.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Markdown Conversion Utilities
|
|
3
|
-
*
|
|
4
|
-
* Lightweight markdown-to-HTML conversion for backward compatibility.
|
|
5
|
-
* Used by filesystem.ts and DOCX file-handler.
|
|
6
|
-
*
|
|
7
|
-
* @module docx/utils/markdown
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Convert simple markdown to HTML if the content appears to be markdown.
|
|
11
|
-
* If it already contains HTML tags it is returned unchanged.
|
|
12
|
-
*/
|
|
13
|
-
export declare function convertToHtmlIfNeeded(content: string): string;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Markdown Conversion Utilities
|
|
3
|
-
*
|
|
4
|
-
* Lightweight markdown-to-HTML conversion for backward compatibility.
|
|
5
|
-
* Used by filesystem.ts and DOCX file-handler.
|
|
6
|
-
*
|
|
7
|
-
* @module docx/utils/markdown
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Convert simple markdown to HTML if the content appears to be markdown.
|
|
11
|
-
* If it already contains HTML tags it is returned unchanged.
|
|
12
|
-
*/
|
|
13
|
-
export function convertToHtmlIfNeeded(content) {
|
|
14
|
-
const hasMarkdown = /^#{1,6}\s|^\*\*|^\[.*\]\(|^\|.*\|/.test(content);
|
|
15
|
-
const hasHtmlTags = /<[a-z][\s\S]*>/i.test(content);
|
|
16
|
-
if (!hasMarkdown || hasHtmlTags)
|
|
17
|
-
return content;
|
|
18
|
-
let html = content;
|
|
19
|
-
html = html.replace(/^### (.*)$/gm, '<h3>$1</h3>');
|
|
20
|
-
html = html.replace(/^## (.*)$/gm, '<h2>$1</h2>');
|
|
21
|
-
html = html.replace(/^# (.*)$/gm, '<h1>$1</h1>');
|
|
22
|
-
html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
|
23
|
-
html = html.replace(/\*(.*?)\*/g, '<em>$1</em>');
|
|
24
|
-
html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '<img src="$2" alt="$1" />');
|
|
25
|
-
html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '<a href="$2">$1</a>');
|
|
26
|
-
return html
|
|
27
|
-
.split('\n\n')
|
|
28
|
-
.map((p) => p.trim())
|
|
29
|
-
.filter(Boolean)
|
|
30
|
-
.map((p) => `<p>${p.replace(/\n/g, '<br>')}</p>`)
|
|
31
|
-
.join('\n');
|
|
32
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path and URL Utilities
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for path detection, resolution, and URL validation.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/paths
|
|
7
|
-
*/
|
|
8
|
-
/** Check if a string is a base64 data URL. */
|
|
9
|
-
export declare function isDataUrl(src: string): boolean;
|
|
10
|
-
/** Check if a string is an HTTP(S) URL. */
|
|
11
|
-
export declare function isUrl(src: string): boolean;
|
|
12
|
-
/** Check if a file path has a `.docx` extension. */
|
|
13
|
-
export declare function isDocxPath(filePath: string): boolean;
|
|
14
|
-
/** Resolve an image path relative to a base directory (pass-through for absolute, URL, and data URLs). */
|
|
15
|
-
export declare function resolveImagePath(imagePath: string, baseDir?: string): string;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path and URL Utilities
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for path detection, resolution, and URL validation.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/paths
|
|
7
|
-
*/
|
|
8
|
-
import path from 'path';
|
|
9
|
-
/** Check if a string is a base64 data URL. */
|
|
10
|
-
export function isDataUrl(src) {
|
|
11
|
-
return src.startsWith('data:') && src.includes('base64,');
|
|
12
|
-
}
|
|
13
|
-
/** Check if a string is an HTTP(S) URL. */
|
|
14
|
-
export function isUrl(src) {
|
|
15
|
-
return src.startsWith('http://') || src.startsWith('https://');
|
|
16
|
-
}
|
|
17
|
-
/** Check if a file path has a `.docx` extension. */
|
|
18
|
-
export function isDocxPath(filePath) {
|
|
19
|
-
return filePath.toLowerCase().endsWith('.docx');
|
|
20
|
-
}
|
|
21
|
-
/** Resolve an image path relative to a base directory (pass-through for absolute, URL, and data URLs). */
|
|
22
|
-
export function resolveImagePath(imagePath, baseDir) {
|
|
23
|
-
if (path.isAbsolute(imagePath) || isUrl(imagePath) || isDataUrl(imagePath)) {
|
|
24
|
-
return imagePath;
|
|
25
|
-
}
|
|
26
|
-
return baseDir ? path.join(baseDir, imagePath) : path.resolve(imagePath);
|
|
27
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Versioning Utilities
|
|
3
|
-
*
|
|
4
|
-
* Generates versioned output paths for DOCX modifications.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/versioning
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Generate the versioned output path for a DOCX modification.
|
|
10
|
-
*
|
|
11
|
-
* Strategy:
|
|
12
|
-
* - Look at existing sibling files `{base}_vN.ext` and pick the next N.
|
|
13
|
-
* - If no versions exist yet, start at `_v1`.
|
|
14
|
-
* - If some versions exist, always return the highest existing + 1.
|
|
15
|
-
*
|
|
16
|
-
* This gives you `version_i` per update over time **even if** every request
|
|
17
|
-
* always uses the original file as `filePath`, while still producing only
|
|
18
|
-
* ONE output file per request (callers invoke this once per edit).
|
|
19
|
-
*
|
|
20
|
-
* Examples:
|
|
21
|
-
* demo.docx → demo_v1.docx (always _v1, overwrites if exists)
|
|
22
|
-
* demo_v1.docx → demo_v2.docx (increments to _v2, overwrites if exists)
|
|
23
|
-
* demo_v2.docx → demo_v3.docx (increments to _v3, overwrites if exists)
|
|
24
|
-
*/
|
|
25
|
-
export declare function generateOutputPath(filePath: string): Promise<string>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Versioning Utilities
|
|
3
|
-
*
|
|
4
|
-
* Generates versioned output paths for DOCX modifications.
|
|
5
|
-
*
|
|
6
|
-
* @module docx/utils/versioning
|
|
7
|
-
*/
|
|
8
|
-
import fs from 'fs/promises';
|
|
9
|
-
import path from 'path';
|
|
10
|
-
/**
|
|
11
|
-
* Generate the versioned output path for a DOCX modification.
|
|
12
|
-
*
|
|
13
|
-
* Strategy:
|
|
14
|
-
* - Look at existing sibling files `{base}_vN.ext` and pick the next N.
|
|
15
|
-
* - If no versions exist yet, start at `_v1`.
|
|
16
|
-
* - If some versions exist, always return the highest existing + 1.
|
|
17
|
-
*
|
|
18
|
-
* This gives you `version_i` per update over time **even if** every request
|
|
19
|
-
* always uses the original file as `filePath`, while still producing only
|
|
20
|
-
* ONE output file per request (callers invoke this once per edit).
|
|
21
|
-
*
|
|
22
|
-
* Examples:
|
|
23
|
-
* demo.docx → demo_v1.docx (always _v1, overwrites if exists)
|
|
24
|
-
* demo_v1.docx → demo_v2.docx (increments to _v2, overwrites if exists)
|
|
25
|
-
* demo_v2.docx → demo_v3.docx (increments to _v3, overwrites if exists)
|
|
26
|
-
*/
|
|
27
|
-
export async function generateOutputPath(filePath) {
|
|
28
|
-
const dir = path.dirname(filePath);
|
|
29
|
-
const ext = path.extname(filePath);
|
|
30
|
-
const baseName = path.basename(filePath, ext);
|
|
31
|
-
// Normalise base to strip any existing _vN suffix so that
|
|
32
|
-
// passing in either "demo.docx" or "demo_v3.docx" still
|
|
33
|
-
// continues the same version sequence.
|
|
34
|
-
const cleanBase = baseName.replace(/_v\d+$/, '');
|
|
35
|
-
try {
|
|
36
|
-
const entries = await fs.readdir(dir);
|
|
37
|
-
let maxVersion = 0;
|
|
38
|
-
const versionRegex = new RegExp(`^${cleanBase}_v(\\d+)${ext.replace('.', '\\.')}$`, 'i');
|
|
39
|
-
for (const entry of entries) {
|
|
40
|
-
const match = entry.match(versionRegex);
|
|
41
|
-
if (match) {
|
|
42
|
-
const v = parseInt(match[1], 10);
|
|
43
|
-
if (!Number.isNaN(v) && v > maxVersion) {
|
|
44
|
-
maxVersion = v;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const nextVersion = maxVersion + 1 || 1;
|
|
49
|
-
return path.join(dir, `${cleanBase}_v${nextVersion}${ext}`);
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
// If we can't list the directory for any reason, fall back to _v1.
|
|
53
|
-
return path.join(dir, `${cleanBase}_v1${ext}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DOCX Utility Functions
|
|
3
|
-
* Helper functions for DOCX operations, validation, and data transformation
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Check if a string is a valid data URL
|
|
7
|
-
*/
|
|
8
|
-
export declare function isDataUrl(src: string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Check if a source is a URL (http/https)
|
|
11
|
-
*/
|
|
12
|
-
export declare function isUrl(src: string): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Parse data URL into buffer
|
|
15
|
-
* @returns Buffer if successful, null if invalid
|
|
16
|
-
*/
|
|
17
|
-
export declare function parseDataUrl(dataUrl: string): Buffer | null;
|
|
18
|
-
/**
|
|
19
|
-
* Resolve image path relative to base directory
|
|
20
|
-
*/
|
|
21
|
-
export declare function resolveImagePath(imagePath: string, baseDir?: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Check if a file exists
|
|
24
|
-
*/
|
|
25
|
-
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Validate image file
|
|
28
|
-
*/
|
|
29
|
-
export declare function validateImageFile(imagePath: string): Promise<{
|
|
30
|
-
valid: boolean;
|
|
31
|
-
error?: string;
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* Escape special regex characters for literal string matching
|
|
35
|
-
*/
|
|
36
|
-
export declare function escapeRegExp(str: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Validate markdown table format
|
|
39
|
-
*/
|
|
40
|
-
export declare function isValidMarkdownTable(markdown: string): boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Build a markdown table from a 2D array of rows
|
|
43
|
-
*/
|
|
44
|
-
export declare function buildMarkdownTableFromRows(rows: string[][]): string;
|
|
45
|
-
/**
|
|
46
|
-
* Parse markdown table into 2D array
|
|
47
|
-
*/
|
|
48
|
-
export declare function parseMarkdownTable(markdown: string): string[][] | null;
|
|
49
|
-
/**
|
|
50
|
-
* Get MIME type from file extension or data URL
|
|
51
|
-
*/
|
|
52
|
-
export declare function getMimeType(source: string): string | null;
|
|
53
|
-
/**
|
|
54
|
-
* Format file size in human-readable format
|
|
55
|
-
*/
|
|
56
|
-
export declare function formatFileSize(bytes: number): string;
|
|
57
|
-
/**
|
|
58
|
-
* Normalize line endings to \n
|
|
59
|
-
*/
|
|
60
|
-
export declare function normalizeLineEndings(text: string): string;
|
|
61
|
-
/**
|
|
62
|
-
* Split markdown into lines, preserving empty lines
|
|
63
|
-
*/
|
|
64
|
-
export declare function splitMarkdownLines(markdown: string): string[];
|
|
65
|
-
/**
|
|
66
|
-
* Validate DOCX file path
|
|
67
|
-
*/
|
|
68
|
-
export declare function isDocxPath(filePath: string): boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Extract file name without extension
|
|
71
|
-
*/
|
|
72
|
-
export declare function getFileNameWithoutExtension(filePath: string): string;
|
|
73
|
-
export { DocxError, DocxErrorCode, withErrorContext } from './errors.js';
|
|
74
|
-
/**
|
|
75
|
-
* Image data prepared for DOCX embedding
|
|
76
|
-
*/
|
|
77
|
-
export interface PreparedImage {
|
|
78
|
-
buffer: Buffer;
|
|
79
|
-
width?: number;
|
|
80
|
-
height?: number;
|
|
81
|
-
altText: string;
|
|
82
|
-
mimeType: string;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Load and prepare an image for DOCX embedding
|
|
86
|
-
* Handles both local files and data URLs
|
|
87
|
-
*
|
|
88
|
-
* @param imagePath - Path to image file or data URL
|
|
89
|
-
* @param altText - Alternative text for the image
|
|
90
|
-
* @param baseDir - Base directory for resolving relative paths
|
|
91
|
-
* @returns Prepared image data ready for embedding
|
|
92
|
-
*/
|
|
93
|
-
export declare function prepareImageForDocx(imagePath: string, altText?: string, baseDir?: string): Promise<PreparedImage>;
|
|
94
|
-
/**
|
|
95
|
-
* Create an ImageRun instance for embedding in DOCX paragraphs
|
|
96
|
-
* This is a lower-level utility for direct image insertion
|
|
97
|
-
*
|
|
98
|
-
* @param imageData - Prepared image data
|
|
99
|
-
* @returns ImageRun instance ready to be added to a paragraph
|
|
100
|
-
*/
|
|
101
|
-
export declare function createImageRun(imageData: PreparedImage): any;
|