@beyondwork/docx-react-component 1.0.29 → 1.0.30
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/package.json +65 -96
- package/src/README.md +85 -0
- package/src/api/README.md +26 -0
- package/src/api/public-types.ts +1952 -0
- package/src/api/session-state.ts +62 -0
- package/src/compare/diff-engine.ts +623 -0
- package/src/compare/export-redlines.ts +280 -0
- package/src/compare/index.ts +25 -0
- package/src/compare/snapshot.ts +97 -0
- package/src/component-inventory.md +99 -0
- package/src/core/README.md +10 -0
- package/src/core/commands/README.md +3 -0
- package/{dist/chunk-TJBP2K4T.js → src/core/commands/formatting-commands.ts} +536 -196
- package/src/core/commands/image-commands.ts +373 -0
- package/src/core/commands/index.ts +1879 -0
- package/src/core/commands/list-commands.ts +565 -0
- package/src/core/commands/paragraph-layout-commands.ts +339 -0
- package/src/core/commands/review-commands.ts +108 -0
- package/{dist/core/commands/section-layout-commands.cjs → src/core/commands/section-layout-commands.ts} +340 -137
- package/src/core/commands/structural-helpers.ts +309 -0
- package/{dist/core/commands/style-commands.cjs → src/core/commands/style-commands.ts} +113 -65
- package/src/core/commands/table-structure-commands.ts +854 -0
- package/{dist/chunk-UZXBISGO.js → src/core/commands/text-commands.ts} +142 -86
- package/src/core/schema/README.md +3 -0
- package/src/core/schema/text-schema.ts +516 -0
- package/src/core/search/search-text.ts +357 -0
- package/src/core/selection/README.md +3 -0
- package/src/core/selection/mapping.ts +289 -0
- package/src/core/selection/review-anchors.ts +183 -0
- package/src/core/state/README.md +3 -0
- package/src/core/state/editor-state.ts +892 -0
- package/src/core/state/text-transaction.ts +869 -0
- package/src/formats/xlsx/io/parse-shared-strings.ts +41 -0
- package/src/formats/xlsx/io/parse-sheet.ts +459 -0
- package/src/formats/xlsx/io/parse-styles.ts +59 -0
- package/src/formats/xlsx/io/parse-workbook.ts +75 -0
- package/src/formats/xlsx/io/serialize-shared-strings.ts +72 -0
- package/src/formats/xlsx/io/serialize-sheet.ts +333 -0
- package/src/formats/xlsx/io/serialize-styles.ts +98 -0
- package/src/formats/xlsx/io/serialize-workbook.ts +429 -0
- package/src/formats/xlsx/io/xlsx-session.ts +314 -0
- package/src/formats/xlsx/model/cell.ts +189 -0
- package/src/formats/xlsx/model/sheet.ts +326 -0
- package/src/formats/xlsx/model/styles.ts +118 -0
- package/src/formats/xlsx/model/workbook.ts +453 -0
- package/src/formats/xlsx/runtime/cell-commands.ts +567 -0
- package/src/formats/xlsx/runtime/sheet-commands.ts +206 -0
- package/src/formats/xlsx/runtime/workbook-runtime.ts +177 -0
- package/src/formats/xlsx/runtime/workbook-transaction.ts +822 -0
- package/src/index.ts +142 -0
- package/src/io/README.md +10 -0
- package/src/io/docx-session.ts +3175 -0
- package/src/io/export/README.md +3 -0
- package/src/io/export/export-session.ts +220 -0
- package/src/io/export/minimal-docx.ts +115 -0
- package/src/io/export/reattach-preserved-parts.ts +54 -0
- package/src/io/export/serialize-comments.ts +947 -0
- package/src/io/export/serialize-footnotes.ts +394 -0
- package/src/io/export/serialize-headers-footers.ts +368 -0
- package/src/io/export/serialize-main-document.ts +1342 -0
- package/src/io/export/serialize-numbering.ts +218 -0
- package/src/io/export/serialize-revisions.ts +389 -0
- package/src/io/export/serialize-runtime-revisions.ts +463 -0
- package/src/io/export/serialize-tables.ts +174 -0
- package/src/io/export/split-review-boundaries.ts +356 -0
- package/src/io/export/split-story-blocks-for-runtime-revisions.ts +252 -0
- package/src/io/export/table-properties-xml.ts +318 -0
- package/src/io/normalize/README.md +3 -0
- package/src/io/normalize/normalize-text.ts +670 -0
- package/src/io/ooxml/README.md +3 -0
- package/src/io/ooxml/highlight-colors.ts +39 -0
- package/src/io/ooxml/numbering-sentinels.ts +44 -0
- package/src/io/ooxml/parse-comments.ts +852 -0
- package/src/io/ooxml/parse-complex-content.ts +287 -0
- package/src/io/ooxml/parse-fields.ts +834 -0
- package/src/io/ooxml/parse-footnotes.ts +952 -0
- package/src/io/ooxml/parse-headers-footers.ts +1212 -0
- package/src/io/ooxml/parse-inline-media.ts +461 -0
- package/src/io/ooxml/parse-main-document.ts +2947 -0
- package/src/io/ooxml/parse-numbering.ts +747 -0
- package/src/io/ooxml/parse-revisions.ts +1045 -0
- package/src/io/ooxml/parse-settings.ts +184 -0
- package/src/io/ooxml/parse-shapes.ts +296 -0
- package/src/io/ooxml/parse-styles.ts +639 -0
- package/src/io/ooxml/parse-tables.ts +627 -0
- package/src/io/ooxml/parse-theme.ts +346 -0
- package/src/io/ooxml/part-manifest.ts +136 -0
- package/src/io/ooxml/revision-boundaries.ts +475 -0
- package/src/io/ooxml/workflow-payload.ts +544 -0
- package/src/io/opc/README.md +3 -0
- package/src/io/opc/corrupt-package.ts +166 -0
- package/src/io/opc/docx-package.ts +74 -0
- package/src/io/opc/package-reader.ts +325 -0
- package/src/io/opc/package-writer.ts +273 -0
- package/src/io/source-package-provenance.ts +241 -0
- package/{dist/chunk-RMH72RZI.js → src/legal/bookmarks.ts} +130 -44
- package/src/legal/cross-references.ts +414 -0
- package/src/legal/defined-terms.ts +203 -0
- package/src/legal/index.ts +32 -0
- package/src/legal/signature-blocks.ts +259 -0
- package/src/model/README.md +3 -0
- package/src/model/canonical-document.ts +2722 -0
- package/src/model/cds-1.0.0.ts +212 -0
- package/src/model/snapshot.ts +760 -0
- package/src/preservation/README.md +3 -0
- package/src/preservation/markup-compatibility.ts +48 -0
- package/src/preservation/opaque-fragment-store.ts +89 -0
- package/src/preservation/opaque-region.ts +233 -0
- package/src/preservation/package-preservation.ts +113 -0
- package/src/preservation/preserved-part-manifest.ts +56 -0
- package/src/preservation/relationship-retention.ts +57 -0
- package/src/preservation/store.ts +255 -0
- package/src/review/README.md +16 -0
- package/src/review/store/README.md +3 -0
- package/src/review/store/comment-anchors.ts +70 -0
- package/src/review/store/comment-remapping.ts +154 -0
- package/src/review/store/comment-store.ts +349 -0
- package/src/review/store/comment-thread.ts +109 -0
- package/src/review/store/revision-actions.ts +423 -0
- package/src/review/store/revision-store.ts +323 -0
- package/src/review/store/revision-types.ts +182 -0
- package/src/review/store/runtime-comment-store.ts +43 -0
- package/src/runtime/README.md +3 -0
- package/src/runtime/ai-action-policy.ts +764 -0
- package/src/runtime/context-analytics.ts +824 -0
- package/src/runtime/document-layout.ts +332 -0
- package/src/runtime/document-locations.ts +521 -0
- package/src/runtime/document-navigation.ts +616 -0
- package/src/runtime/document-outline.ts +440 -0
- package/src/runtime/document-runtime.ts +4055 -0
- package/src/runtime/document-search.ts +145 -0
- package/src/runtime/event-refresh-hints.ts +137 -0
- package/src/runtime/numbering-prefix.ts +244 -0
- package/src/runtime/page-layout-estimation.ts +305 -0
- package/src/runtime/read-only-diagnostics-runtime.ts +241 -0
- package/src/runtime/resolved-numbering-geometry.ts +293 -0
- package/src/runtime/review-runtime.ts +44 -0
- package/src/runtime/revision-runtime.ts +107 -0
- package/src/runtime/session-capabilities.ts +192 -0
- package/src/runtime/story-context.ts +164 -0
- package/src/runtime/story-targeting.ts +162 -0
- package/src/runtime/suggestions-snapshot.ts +137 -0
- package/src/runtime/surface-projection.ts +1553 -0
- package/src/runtime/table-commands.ts +173 -0
- package/src/runtime/table-schema.ts +309 -0
- package/src/runtime/table-style-resolver.ts +409 -0
- package/src/runtime/view-state.ts +493 -0
- package/src/runtime/virtualized-rendering.ts +258 -0
- package/src/runtime/workflow-markup.ts +393 -0
- package/src/ui/README.md +30 -0
- package/src/ui/WordReviewEditor.tsx +5268 -0
- package/src/ui/browser-export.ts +52 -0
- package/src/ui/comments/README.md +3 -0
- package/src/ui/compatibility/README.md +3 -0
- package/src/ui/editor-command-bag.ts +127 -0
- package/src/ui/editor-runtime-boundary.ts +1558 -0
- package/src/ui/editor-shell-view.tsx +144 -0
- package/src/ui/editor-surface/README.md +3 -0
- package/src/ui/editor-surface-controller.tsx +66 -0
- package/src/ui/headless/comment-decoration-model.ts +124 -0
- package/src/ui/headless/preserve-editor-selection.ts +5 -0
- package/src/ui/headless/revision-decoration-model.ts +128 -0
- package/src/ui/headless/selection-helpers.ts +54 -0
- package/src/ui/headless/selection-tool-context.ts +19 -0
- package/src/ui/headless/selection-tool-resolver.ts +752 -0
- package/src/ui/headless/selection-tool-types.ts +129 -0
- package/src/ui/headless/selection-toolbar-model.ts +11 -0
- package/src/ui/headless/use-editor-keyboard.ts +103 -0
- package/src/ui/review/README.md +3 -0
- package/src/ui/runtime-shortcut-dispatch.ts +365 -0
- package/src/ui/runtime-snapshot-selectors.ts +197 -0
- package/src/ui/shared/revision-filters.ts +31 -0
- package/src/ui/status/README.md +3 -0
- package/src/ui/theme/README.md +3 -0
- package/src/ui/toolbar/README.md +3 -0
- package/src/ui/workflow-surface-blocked-rails.ts +94 -0
- package/src/ui-tailwind/chrome/chrome-preset-model.ts +107 -0
- package/src/ui-tailwind/chrome/chrome-preset-toolbar.tsx +15 -0
- package/src/ui-tailwind/chrome/review-queue-bar.tsx +97 -0
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +64 -0
- package/src/ui-tailwind/chrome/tw-context-analytics-summary.tsx +122 -0
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +121 -0
- package/src/ui-tailwind/chrome/tw-layout-panel.tsx +114 -0
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +30 -0
- package/src/ui-tailwind/chrome/tw-page-ruler.tsx +365 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-blocked.tsx +23 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-comment.tsx +35 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-formatting.tsx +37 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +298 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-structure.tsx +116 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-suggestion.tsx +29 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-workflow.tsx +27 -0
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +186 -0
- package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +139 -0
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +200 -0
- package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +58 -0
- package/src/ui-tailwind/chrome/use-before-unload.ts +20 -0
- package/src/ui-tailwind/editor-surface/perf-probe.ts +179 -0
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +189 -0
- package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +31 -0
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +411 -0
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +123 -0
- package/src/ui-tailwind/editor-surface/pm-schema.ts +927 -0
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +567 -0
- package/src/ui-tailwind/editor-surface/search-plugin.ts +168 -0
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +65 -0
- package/src/ui-tailwind/editor-surface/tw-caret.tsx +12 -0
- package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +150 -0
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +129 -0
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +58 -0
- package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +151 -0
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +1047 -0
- package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +111 -0
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +503 -0
- package/src/ui-tailwind/index.ts +62 -0
- package/src/ui-tailwind/page-chrome-model.ts +27 -0
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +406 -0
- package/src/ui-tailwind/review/tw-health-panel.tsx +149 -0
- package/src/ui-tailwind/review/tw-review-rail.tsx +122 -0
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +164 -0
- package/src/ui-tailwind/status/tw-status-bar.tsx +65 -0
- package/{dist → src}/ui-tailwind/theme/editor-theme.css +58 -40
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +52 -0
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +1133 -0
- package/src/ui-tailwind/tw-review-workspace.tsx +1460 -0
- package/src/validation/README.md +3 -0
- package/src/validation/compatibility-engine.ts +878 -0
- package/src/validation/compatibility-report.ts +161 -0
- package/src/validation/diagnostics.ts +204 -0
- package/src/validation/docx-comment-proof.ts +720 -0
- package/src/validation/import-diagnostics.ts +128 -0
- package/src/validation/low-priority-word-surfaces.ts +373 -0
- package/dist/canonical-document-BLEbzL2J.d.cts +0 -844
- package/dist/canonical-document-BLEbzL2J.d.ts +0 -844
- package/dist/chunk-2FJS5GZM.js +0 -763
- package/dist/chunk-2FJS5GZM.js.map +0 -1
- package/dist/chunk-2OQBZS3F.js +0 -446
- package/dist/chunk-2OQBZS3F.js.map +0 -1
- package/dist/chunk-2S7W4KFO.js +0 -127
- package/dist/chunk-2S7W4KFO.js.map +0 -1
- package/dist/chunk-2TG72QSW.js +0 -3874
- package/dist/chunk-2TG72QSW.js.map +0 -1
- package/dist/chunk-36QNIZBO.js +0 -532
- package/dist/chunk-36QNIZBO.js.map +0 -1
- package/dist/chunk-4AQOYAW4.js +0 -3069
- package/dist/chunk-4AQOYAW4.js.map +0 -1
- package/dist/chunk-4D5EWJ3P.js +0 -77
- package/dist/chunk-4D5EWJ3P.js.map +0 -1
- package/dist/chunk-5FN54NDH.js +0 -2257
- package/dist/chunk-5FN54NDH.js.map +0 -1
- package/dist/chunk-BOYGQYRQ.js +0 -7306
- package/dist/chunk-BOYGQYRQ.js.map +0 -1
- package/dist/chunk-CN3XMECL.js +0 -212
- package/dist/chunk-CN3XMECL.js.map +0 -1
- package/dist/chunk-EBI3BX6U.js +0 -164
- package/dist/chunk-EBI3BX6U.js.map +0 -1
- package/dist/chunk-EILUG3VB.js +0 -1275
- package/dist/chunk-EILUG3VB.js.map +0 -1
- package/dist/chunk-FUDY333O.js +0 -70
- package/dist/chunk-FUDY333O.js.map +0 -1
- package/dist/chunk-GBVOWFIK.js +0 -1237
- package/dist/chunk-GBVOWFIK.js.map +0 -1
- package/dist/chunk-H4TQ3H3Y.js +0 -262
- package/dist/chunk-H4TQ3H3Y.js.map +0 -1
- package/dist/chunk-JGB3IXZO.js +0 -189
- package/dist/chunk-JGB3IXZO.js.map +0 -1
- package/dist/chunk-KD2QRQPY.js +0 -4342
- package/dist/chunk-KD2QRQPY.js.map +0 -1
- package/dist/chunk-KLMXQVYK.js +0 -369
- package/dist/chunk-KLMXQVYK.js.map +0 -1
- package/dist/chunk-KZUG5KFQ.js +0 -214
- package/dist/chunk-KZUG5KFQ.js.map +0 -1
- package/dist/chunk-QDAQ4CJU.js +0 -345
- package/dist/chunk-QDAQ4CJU.js.map +0 -1
- package/dist/chunk-RMH72RZI.js.map +0 -1
- package/dist/chunk-SWKWQZXM.js +0 -117
- package/dist/chunk-SWKWQZXM.js.map +0 -1
- package/dist/chunk-TJBP2K4T.js.map +0 -1
- package/dist/chunk-TLCEAQDQ.js +0 -542
- package/dist/chunk-TLCEAQDQ.js.map +0 -1
- package/dist/chunk-UZXBISGO.js.map +0 -1
- package/dist/chunk-WGBAKP3Q.js +0 -3220
- package/dist/chunk-WGBAKP3Q.js.map +0 -1
- package/dist/compare/index.cjs +0 -5475
- package/dist/compare/index.cjs.map +0 -1
- package/dist/compare/index.d.cts +0 -114
- package/dist/compare/index.d.ts +0 -114
- package/dist/compare/index.js +0 -731
- package/dist/compare/index.js.map +0 -1
- package/dist/core/commands/formatting-commands.cjs +0 -828
- package/dist/core/commands/formatting-commands.cjs.map +0 -1
- package/dist/core/commands/formatting-commands.d.cts +0 -63
- package/dist/core/commands/formatting-commands.d.ts +0 -63
- package/dist/core/commands/formatting-commands.js +0 -37
- package/dist/core/commands/formatting-commands.js.map +0 -1
- package/dist/core/commands/image-commands.cjs +0 -2023
- package/dist/core/commands/image-commands.cjs.map +0 -1
- package/dist/core/commands/image-commands.d.cts +0 -58
- package/dist/core/commands/image-commands.d.ts +0 -58
- package/dist/core/commands/image-commands.js +0 -18
- package/dist/core/commands/image-commands.js.map +0 -1
- package/dist/core/commands/section-layout-commands.cjs.map +0 -1
- package/dist/core/commands/section-layout-commands.d.cts +0 -62
- package/dist/core/commands/section-layout-commands.d.ts +0 -62
- package/dist/core/commands/section-layout-commands.js +0 -21
- package/dist/core/commands/section-layout-commands.js.map +0 -1
- package/dist/core/commands/style-commands.cjs.map +0 -1
- package/dist/core/commands/style-commands.d.cts +0 -13
- package/dist/core/commands/style-commands.d.ts +0 -13
- package/dist/core/commands/style-commands.js +0 -9
- package/dist/core/commands/style-commands.js.map +0 -1
- package/dist/core/commands/table-structure-commands.cjs +0 -1883
- package/dist/core/commands/table-structure-commands.cjs.map +0 -1
- package/dist/core/commands/table-structure-commands.d.cts +0 -59
- package/dist/core/commands/table-structure-commands.d.ts +0 -59
- package/dist/core/commands/table-structure-commands.js +0 -12
- package/dist/core/commands/table-structure-commands.js.map +0 -1
- package/dist/core/commands/text-commands.cjs +0 -2391
- package/dist/core/commands/text-commands.cjs.map +0 -1
- package/dist/core/commands/text-commands.d.cts +0 -24
- package/dist/core/commands/text-commands.d.ts +0 -24
- package/dist/core/commands/text-commands.js +0 -28
- package/dist/core/commands/text-commands.js.map +0 -1
- package/dist/core/selection/mapping.cjs +0 -200
- package/dist/core/selection/mapping.cjs.map +0 -1
- package/dist/core/selection/mapping.d.cts +0 -2
- package/dist/core/selection/mapping.d.ts +0 -2
- package/dist/core/selection/mapping.js +0 -31
- package/dist/core/selection/mapping.js.map +0 -1
- package/dist/core/state/editor-state.cjs +0 -2278
- package/dist/core/state/editor-state.cjs.map +0 -1
- package/dist/core/state/editor-state.d.cts +0 -2
- package/dist/core/state/editor-state.d.ts +0 -2
- package/dist/core/state/editor-state.js +0 -26
- package/dist/core/state/editor-state.js.map +0 -1
- package/dist/index.cjs +0 -38553
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -15
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -7856
- package/dist/index.js.map +0 -1
- package/dist/io/docx-session.cjs +0 -16236
- package/dist/io/docx-session.cjs.map +0 -1
- package/dist/io/docx-session.d.cts +0 -21
- package/dist/io/docx-session.d.ts +0 -21
- package/dist/io/docx-session.js +0 -18
- package/dist/io/docx-session.js.map +0 -1
- package/dist/legal/index.cjs +0 -3900
- package/dist/legal/index.cjs.map +0 -1
- package/dist/legal/index.d.cts +0 -86
- package/dist/legal/index.d.ts +0 -86
- package/dist/legal/index.js +0 -616
- package/dist/legal/index.js.map +0 -1
- package/dist/public-types-7ZL_94cz.d.ts +0 -1573
- package/dist/public-types-CeMaDueh.d.cts +0 -1573
- package/dist/public-types.cjs +0 -19
- package/dist/public-types.cjs.map +0 -1
- package/dist/public-types.d.cts +0 -2
- package/dist/public-types.d.ts +0 -2
- package/dist/public-types.js +0 -1
- package/dist/public-types.js.map +0 -1
- package/dist/runtime/document-runtime.cjs +0 -11140
- package/dist/runtime/document-runtime.cjs.map +0 -1
- package/dist/runtime/document-runtime.d.cts +0 -231
- package/dist/runtime/document-runtime.d.ts +0 -231
- package/dist/runtime/document-runtime.js +0 -21
- package/dist/runtime/document-runtime.js.map +0 -1
- package/dist/structural-helpers-CilgOVhh.d.cts +0 -10
- package/dist/structural-helpers-q0Gd-eBN.d.ts +0 -10
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs +0 -313
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +0 -1
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +0 -67
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +0 -67
- package/dist/ui-tailwind/editor-surface/search-plugin.js +0 -23
- package/dist/ui-tailwind/editor-surface/search-plugin.js.map +0 -1
- package/dist/ui-tailwind/index.cjs +0 -4833
- package/dist/ui-tailwind/index.cjs.map +0 -1
- package/dist/ui-tailwind/index.d.cts +0 -617
- package/dist/ui-tailwind/index.d.ts +0 -617
- package/dist/ui-tailwind/index.js +0 -575
- package/dist/ui-tailwind/index.js.map +0 -1
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CompatibilityReport,
|
|
3
|
+
DocumentNavigationSnapshot,
|
|
4
|
+
FieldSnapshot,
|
|
5
|
+
ProtectionSnapshot,
|
|
6
|
+
RuntimeRenderSnapshot,
|
|
7
|
+
} from "../api/public-types.ts";
|
|
8
|
+
import { parseCommentsFromOoxml } from "../io/ooxml/parse-comments.ts";
|
|
9
|
+
import { readOpcPackage } from "../io/opc/package-reader.ts";
|
|
10
|
+
|
|
11
|
+
export interface ClosureValidationContext {
|
|
12
|
+
renderSnapshot: Pick<
|
|
13
|
+
RuntimeRenderSnapshot,
|
|
14
|
+
| "isReady"
|
|
15
|
+
| "fatalError"
|
|
16
|
+
| "comments"
|
|
17
|
+
| "trackedChanges"
|
|
18
|
+
| "surface"
|
|
19
|
+
| "pageLayout"
|
|
20
|
+
>;
|
|
21
|
+
navigation?: Pick<DocumentNavigationSnapshot, "pages">;
|
|
22
|
+
compatibility: Pick<CompatibilityReport, "errors" | "featureEntries">;
|
|
23
|
+
surface: RuntimeRenderSnapshot["surface"];
|
|
24
|
+
fieldSnapshot?: FieldSnapshot;
|
|
25
|
+
protectionSnapshot?: ProtectionSnapshot;
|
|
26
|
+
harnessShowcase?: HarnessShowcaseValidationContext;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const HARNESS_SHOWCASE_AREAS = [
|
|
30
|
+
"workflow-overlay",
|
|
31
|
+
"blocked-commands",
|
|
32
|
+
"preserve-only",
|
|
33
|
+
"search-candidates",
|
|
34
|
+
"right-rail",
|
|
35
|
+
"multi-scope",
|
|
36
|
+
"public-api",
|
|
37
|
+
"sidebar-integration",
|
|
38
|
+
"policy-yaml",
|
|
39
|
+
"harness-lifecycle",
|
|
40
|
+
"export-continuity",
|
|
41
|
+
"main-story-text",
|
|
42
|
+
"paragraph-structure",
|
|
43
|
+
"secondary-story-text",
|
|
44
|
+
"formatting-property-list",
|
|
45
|
+
"table-field-slices",
|
|
46
|
+
"fail-closed-boundaries",
|
|
47
|
+
"media-section-fail-closed",
|
|
48
|
+
"continuity-proof",
|
|
49
|
+
"harness-suggestion-telemetry",
|
|
50
|
+
] as const;
|
|
51
|
+
|
|
52
|
+
export type HarnessShowcaseArea =
|
|
53
|
+
(typeof HARNESS_SHOWCASE_AREAS)[number];
|
|
54
|
+
|
|
55
|
+
export interface HarnessShowcaseAreaProof {
|
|
56
|
+
demonstrated: boolean;
|
|
57
|
+
detail?: string;
|
|
58
|
+
proofArtifacts?: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface HarnessShowcaseValidationContext {
|
|
62
|
+
areas: Partial<Record<HarnessShowcaseArea, HarnessShowcaseAreaProof>>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type ClosureValidationCheck =
|
|
66
|
+
| { type: "mustLoad" }
|
|
67
|
+
| { type: "compatibilityFeature"; featureKey: string; featureClass: string }
|
|
68
|
+
| { type: "minTrackedChanges"; count: number }
|
|
69
|
+
| { type: "maxTrackedChanges"; count: number }
|
|
70
|
+
| { type: "minCommentThreads"; count: number }
|
|
71
|
+
| { type: "lockedFragmentCountAtLeast"; count: number }
|
|
72
|
+
| { type: "surfaceBlockKind"; kind: string; count?: number }
|
|
73
|
+
| { type: "opaqueBlockLabelPrefix"; value: string }
|
|
74
|
+
| { type: "opaqueInlineLabelPrefix"; value: string }
|
|
75
|
+
| {
|
|
76
|
+
type: "trackedChangeMatch";
|
|
77
|
+
kind?: "insertion" | "deletion" | "formatting" | "move" | "property-change";
|
|
78
|
+
actionability?: "actionable" | "preserve-only";
|
|
79
|
+
status?: "active" | "accepted" | "rejected" | "detached";
|
|
80
|
+
preserveOnlyReasonIncludes?: string[];
|
|
81
|
+
}
|
|
82
|
+
| {
|
|
83
|
+
type: "fieldEntryMatch";
|
|
84
|
+
fieldFamily?: string;
|
|
85
|
+
supported?: boolean;
|
|
86
|
+
refreshStatus?: string;
|
|
87
|
+
displayTextIncludes?: string[];
|
|
88
|
+
fieldTarget?: string;
|
|
89
|
+
}
|
|
90
|
+
| {
|
|
91
|
+
type: "protectionMatch";
|
|
92
|
+
hasDocumentProtection?: boolean;
|
|
93
|
+
editType?: string;
|
|
94
|
+
enforcementActive?: boolean;
|
|
95
|
+
enforcedRangeCountAtLeast?: number;
|
|
96
|
+
preservedRangeCountAtLeast?: number;
|
|
97
|
+
rangeId?: string;
|
|
98
|
+
rangeEnforced?: boolean;
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
type: "secondaryStoryMatch";
|
|
102
|
+
kind: "header" | "footer" | "footnote" | "endnote";
|
|
103
|
+
relationshipId?: string;
|
|
104
|
+
variant?: "default" | "first" | "even";
|
|
105
|
+
noteId?: string;
|
|
106
|
+
minBlockCount?: number;
|
|
107
|
+
}
|
|
108
|
+
| {
|
|
109
|
+
type: "pageLayoutMatch";
|
|
110
|
+
sectionIndex?: number;
|
|
111
|
+
orientation?: "portrait" | "landscape";
|
|
112
|
+
columns?: number;
|
|
113
|
+
differentFirstPage?: boolean;
|
|
114
|
+
differentOddEvenPages?: boolean;
|
|
115
|
+
headerVariantCountAtLeast?: number;
|
|
116
|
+
footerVariantCountAtLeast?: number;
|
|
117
|
+
}
|
|
118
|
+
| {
|
|
119
|
+
type: "commentThreadMatch";
|
|
120
|
+
commentId?: string;
|
|
121
|
+
status?: "open" | "resolved" | "detached";
|
|
122
|
+
entryCount?: number;
|
|
123
|
+
anchorKind?: "range" | "node" | "detached";
|
|
124
|
+
bodyIncludes?: string[];
|
|
125
|
+
entryBodies?: string[];
|
|
126
|
+
entryAuthorIds?: string[];
|
|
127
|
+
authorId?: string;
|
|
128
|
+
}
|
|
129
|
+
| {
|
|
130
|
+
type: "harnessShowcase";
|
|
131
|
+
area: HarnessShowcaseArea;
|
|
132
|
+
claim: string;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export interface ClosureValidationResult {
|
|
136
|
+
type: string;
|
|
137
|
+
passed: boolean;
|
|
138
|
+
reason: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface DocxCommentProof {
|
|
142
|
+
partPresence: {
|
|
143
|
+
commentsXml: boolean;
|
|
144
|
+
commentsExtendedXml: boolean;
|
|
145
|
+
commentsIdsXml: boolean;
|
|
146
|
+
peopleXml: boolean;
|
|
147
|
+
};
|
|
148
|
+
serializedCommentIds: string[];
|
|
149
|
+
peopleAuthors: string[];
|
|
150
|
+
threads: Array<{
|
|
151
|
+
commentId: string;
|
|
152
|
+
rootCommentId?: string;
|
|
153
|
+
status: "open" | "resolved" | "detached";
|
|
154
|
+
entryCount: number;
|
|
155
|
+
bodies: string[];
|
|
156
|
+
authorIds: string[];
|
|
157
|
+
anchorKind: "range" | "node" | "detached";
|
|
158
|
+
}>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function evaluateHarnessShowcaseCheck(
|
|
162
|
+
check: Extract<ClosureValidationCheck, { type: "harnessShowcase" }>,
|
|
163
|
+
context: HarnessShowcaseValidationContext,
|
|
164
|
+
): ClosureValidationResult {
|
|
165
|
+
const areaProof = context.areas[check.area];
|
|
166
|
+
if (!areaProof) {
|
|
167
|
+
return {
|
|
168
|
+
type: check.type,
|
|
169
|
+
passed: false,
|
|
170
|
+
reason: `missing harness showcase proof for area ${check.area}: ${check.claim}`,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
type: check.type,
|
|
176
|
+
passed: areaProof.demonstrated,
|
|
177
|
+
reason:
|
|
178
|
+
areaProof.detail ??
|
|
179
|
+
`expected harness showcase proof for area ${check.area}: ${check.claim}`,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function evaluateClosureCheck(
|
|
184
|
+
check: ClosureValidationCheck,
|
|
185
|
+
context: ClosureValidationContext,
|
|
186
|
+
): ClosureValidationResult {
|
|
187
|
+
switch (check.type) {
|
|
188
|
+
case "mustLoad":
|
|
189
|
+
return {
|
|
190
|
+
type: check.type,
|
|
191
|
+
passed:
|
|
192
|
+
context.renderSnapshot.isReady &&
|
|
193
|
+
context.renderSnapshot.fatalError === undefined &&
|
|
194
|
+
context.compatibility.errors.length === 0,
|
|
195
|
+
reason: "exported artifact did not reload into a healthy runtime",
|
|
196
|
+
};
|
|
197
|
+
case "compatibilityFeature": {
|
|
198
|
+
const passed = context.compatibility.featureEntries.some(
|
|
199
|
+
(entry) =>
|
|
200
|
+
entry.featureKey === check.featureKey &&
|
|
201
|
+
entry.featureClass === check.featureClass,
|
|
202
|
+
);
|
|
203
|
+
return {
|
|
204
|
+
type: check.type,
|
|
205
|
+
passed,
|
|
206
|
+
reason: `missing compatibility feature ${check.featureKey}:${check.featureClass}`,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
case "minTrackedChanges":
|
|
210
|
+
return {
|
|
211
|
+
type: check.type,
|
|
212
|
+
passed: context.renderSnapshot.trackedChanges.totalCount >= check.count,
|
|
213
|
+
reason: `expected at least ${check.count} tracked changes`,
|
|
214
|
+
};
|
|
215
|
+
case "maxTrackedChanges":
|
|
216
|
+
return {
|
|
217
|
+
type: check.type,
|
|
218
|
+
passed: context.renderSnapshot.trackedChanges.totalCount <= check.count,
|
|
219
|
+
reason: `expected at most ${check.count} tracked changes`,
|
|
220
|
+
};
|
|
221
|
+
case "minCommentThreads":
|
|
222
|
+
return {
|
|
223
|
+
type: check.type,
|
|
224
|
+
passed: context.renderSnapshot.comments.totalCount >= check.count,
|
|
225
|
+
reason: `expected at least ${check.count} comment threads`,
|
|
226
|
+
};
|
|
227
|
+
case "lockedFragmentCountAtLeast":
|
|
228
|
+
return {
|
|
229
|
+
type: check.type,
|
|
230
|
+
passed: (context.surface?.lockedFragmentIds.length ?? 0) >= check.count,
|
|
231
|
+
reason: `expected at least ${check.count} locked fragments`,
|
|
232
|
+
};
|
|
233
|
+
case "surfaceBlockKind":
|
|
234
|
+
return {
|
|
235
|
+
type: check.type,
|
|
236
|
+
passed:
|
|
237
|
+
(context.surface?.blocks.filter((block) => block.kind === check.kind).length ?? 0) >=
|
|
238
|
+
(check.count ?? 1),
|
|
239
|
+
reason: `expected at least ${check.count ?? 1} surface blocks of kind ${check.kind}`,
|
|
240
|
+
};
|
|
241
|
+
case "opaqueBlockLabelPrefix":
|
|
242
|
+
return {
|
|
243
|
+
type: check.type,
|
|
244
|
+
passed:
|
|
245
|
+
context.surface?.blocks.some(
|
|
246
|
+
(block) =>
|
|
247
|
+
block.kind === "opaque_block" &&
|
|
248
|
+
typeof block.label === "string" &&
|
|
249
|
+
block.label.startsWith(check.value),
|
|
250
|
+
) ?? false,
|
|
251
|
+
reason: `expected an opaque block label starting with ${check.value}`,
|
|
252
|
+
};
|
|
253
|
+
case "opaqueInlineLabelPrefix":
|
|
254
|
+
return {
|
|
255
|
+
type: check.type,
|
|
256
|
+
passed: hasOpaqueInlineLabelPrefix(context.surface, check.value),
|
|
257
|
+
reason: `expected an opaque inline label starting with ${check.value}`,
|
|
258
|
+
};
|
|
259
|
+
case "trackedChangeMatch": {
|
|
260
|
+
const passed = context.renderSnapshot.trackedChanges.revisions.some((revision) => {
|
|
261
|
+
if (check.kind && revision.kind !== check.kind) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (check.actionability && revision.actionability !== check.actionability) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
if (check.status && revision.status !== check.status) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (
|
|
271
|
+
check.preserveOnlyReasonIncludes &&
|
|
272
|
+
!check.preserveOnlyReasonIncludes.every((fragment) =>
|
|
273
|
+
(revision.preserveOnlyReason ?? "").includes(fragment),
|
|
274
|
+
)
|
|
275
|
+
) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
return true;
|
|
279
|
+
});
|
|
280
|
+
return {
|
|
281
|
+
type: check.type,
|
|
282
|
+
passed,
|
|
283
|
+
reason: `expected a tracked change matching ${describeTrackedChangeMatch(check)}`,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
case "fieldEntryMatch": {
|
|
287
|
+
const passed =
|
|
288
|
+
context.fieldSnapshot?.fields.some((field) => {
|
|
289
|
+
if (check.fieldFamily && field.fieldFamily !== check.fieldFamily) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
if (check.supported !== undefined && field.supported !== check.supported) {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
if (check.refreshStatus && field.refreshStatus !== check.refreshStatus) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
if (check.fieldTarget && field.fieldTarget !== check.fieldTarget) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
if (
|
|
302
|
+
check.displayTextIncludes &&
|
|
303
|
+
!check.displayTextIncludes.every((fragment) => field.displayText.includes(fragment))
|
|
304
|
+
) {
|
|
305
|
+
return false;
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
}) ?? false;
|
|
309
|
+
return {
|
|
310
|
+
type: check.type,
|
|
311
|
+
passed,
|
|
312
|
+
reason: `expected a field entry matching ${describeFieldEntryMatch(check)}`,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
case "protectionMatch": {
|
|
316
|
+
const snapshot = context.protectionSnapshot;
|
|
317
|
+
const passed = Boolean(
|
|
318
|
+
snapshot &&
|
|
319
|
+
(check.hasDocumentProtection === undefined ||
|
|
320
|
+
snapshot.hasDocumentProtection === check.hasDocumentProtection) &&
|
|
321
|
+
(check.editType === undefined || snapshot.editType === check.editType) &&
|
|
322
|
+
(check.enforcementActive === undefined ||
|
|
323
|
+
snapshot.enforcementActive === check.enforcementActive) &&
|
|
324
|
+
(check.enforcedRangeCountAtLeast === undefined ||
|
|
325
|
+
snapshot.enforcedRangeCount >= check.enforcedRangeCountAtLeast) &&
|
|
326
|
+
(check.preservedRangeCountAtLeast === undefined ||
|
|
327
|
+
snapshot.preservedRangeCount >= check.preservedRangeCountAtLeast) &&
|
|
328
|
+
(!check.rangeId ||
|
|
329
|
+
snapshot.ranges.some((range) =>
|
|
330
|
+
range.rangeId === check.rangeId &&
|
|
331
|
+
(check.rangeEnforced === undefined || range.enforced === check.rangeEnforced),
|
|
332
|
+
))
|
|
333
|
+
);
|
|
334
|
+
return {
|
|
335
|
+
type: check.type,
|
|
336
|
+
passed,
|
|
337
|
+
reason: `expected protection snapshot matching ${describeProtectionMatch(check)}`,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
case "secondaryStoryMatch": {
|
|
341
|
+
const passed =
|
|
342
|
+
context.surface?.secondaryStories.some((story) => {
|
|
343
|
+
if (story.target.kind !== check.kind) {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (
|
|
347
|
+
"relationshipId" in story.target &&
|
|
348
|
+
check.relationshipId &&
|
|
349
|
+
story.target.relationshipId !== check.relationshipId
|
|
350
|
+
) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
if ("variant" in story.target && check.variant && story.target.variant !== check.variant) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
if ("noteId" in story.target && check.noteId && story.target.noteId !== check.noteId) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
if ((check.minBlockCount ?? 0) > story.blocks.length) {
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
return true;
|
|
363
|
+
}) ?? false;
|
|
364
|
+
return {
|
|
365
|
+
type: check.type,
|
|
366
|
+
passed,
|
|
367
|
+
reason: `expected secondary story ${describeSecondaryStoryMatch(check)}`,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
case "pageLayoutMatch": {
|
|
371
|
+
const layouts = getLayoutsForCheck(context, check);
|
|
372
|
+
const headerVariantCount = countUniqueStoryVariants(layouts, "headerVariants");
|
|
373
|
+
const footerVariantCount = countUniqueStoryVariants(layouts, "footerVariants");
|
|
374
|
+
const passed = Boolean(
|
|
375
|
+
layouts.length > 0 &&
|
|
376
|
+
layouts.some(
|
|
377
|
+
(layout) =>
|
|
378
|
+
(check.orientation === undefined || layout.orientation === check.orientation) &&
|
|
379
|
+
(check.columns === undefined || layout.columns === check.columns) &&
|
|
380
|
+
(check.differentFirstPage === undefined ||
|
|
381
|
+
layout.differentFirstPage === check.differentFirstPage) &&
|
|
382
|
+
(check.differentOddEvenPages === undefined ||
|
|
383
|
+
layout.differentOddEvenPages === check.differentOddEvenPages),
|
|
384
|
+
) &&
|
|
385
|
+
(check.headerVariantCountAtLeast === undefined ||
|
|
386
|
+
headerVariantCount >= check.headerVariantCountAtLeast) &&
|
|
387
|
+
(check.footerVariantCountAtLeast === undefined ||
|
|
388
|
+
footerVariantCount >= check.footerVariantCountAtLeast)
|
|
389
|
+
);
|
|
390
|
+
return {
|
|
391
|
+
type: check.type,
|
|
392
|
+
passed,
|
|
393
|
+
reason: `expected page layout ${describePageLayoutMatch(check)}`,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
case "commentThreadMatch": {
|
|
397
|
+
const passed = context.renderSnapshot.comments.threads.some((thread) =>
|
|
398
|
+
matchesCommentThread(thread, check),
|
|
399
|
+
);
|
|
400
|
+
return {
|
|
401
|
+
type: check.type,
|
|
402
|
+
passed,
|
|
403
|
+
reason: `expected a comment thread matching ${describeCommentThreadMatch(check)}`,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
case "harnessShowcase":
|
|
407
|
+
return evaluateHarnessShowcaseCheck(check, context.harnessShowcase ?? { areas: {} });
|
|
408
|
+
default:
|
|
409
|
+
return {
|
|
410
|
+
type: (check as { type: string }).type,
|
|
411
|
+
passed: false,
|
|
412
|
+
reason: `unknown closure validation check type ${(check as { type: string }).type}`,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export function extractDocxCommentProof(bytes: Uint8Array): DocxCommentProof {
|
|
418
|
+
const packageFile = readOpcPackage(bytes);
|
|
419
|
+
const documentXml = decodePartText(packageFile.parts.get("/word/document.xml")?.bytes);
|
|
420
|
+
const commentsXml = decodePartText(packageFile.parts.get("/word/comments.xml")?.bytes);
|
|
421
|
+
const commentsExtendedXml = decodePartText(
|
|
422
|
+
packageFile.parts.get("/word/commentsExtended.xml")?.bytes,
|
|
423
|
+
);
|
|
424
|
+
const commentsIdsXml = decodePartText(packageFile.parts.get("/word/commentsIds.xml")?.bytes);
|
|
425
|
+
const peopleXml = decodePartText(packageFile.parts.get("/word/people.xml")?.bytes);
|
|
426
|
+
const parsedComments =
|
|
427
|
+
documentXml && commentsXml
|
|
428
|
+
? parseCommentsFromOoxml(documentXml, {
|
|
429
|
+
commentsXml,
|
|
430
|
+
commentsExtendedXml,
|
|
431
|
+
commentsIdsXml,
|
|
432
|
+
peopleXml,
|
|
433
|
+
})
|
|
434
|
+
: {
|
|
435
|
+
threads: [],
|
|
436
|
+
definitions: [],
|
|
437
|
+
peopleAuthors: [],
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
return {
|
|
441
|
+
partPresence: {
|
|
442
|
+
commentsXml: commentsXml.length > 0,
|
|
443
|
+
commentsExtendedXml: commentsExtendedXml.length > 0,
|
|
444
|
+
commentsIdsXml: commentsIdsXml.length > 0,
|
|
445
|
+
peopleXml: peopleXml.length > 0,
|
|
446
|
+
},
|
|
447
|
+
serializedCommentIds: parsedComments.definitions.map((definition) => definition.commentId),
|
|
448
|
+
peopleAuthors: [...parsedComments.peopleAuthors],
|
|
449
|
+
threads: parsedComments.threads.map((thread) => ({
|
|
450
|
+
commentId: thread.commentId,
|
|
451
|
+
rootCommentId: thread.metadata?.rootOoxmlCommentId,
|
|
452
|
+
status: thread.status,
|
|
453
|
+
entryCount: thread.entries.length,
|
|
454
|
+
bodies: thread.entries.map((entry) => entry.body),
|
|
455
|
+
authorIds: [...new Set(thread.entries.map((entry) => entry.authorId))],
|
|
456
|
+
anchorKind: thread.anchor.kind,
|
|
457
|
+
})),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
function hasOpaqueInlineLabelPrefix(
|
|
462
|
+
surface: RuntimeRenderSnapshot["surface"],
|
|
463
|
+
prefix: string,
|
|
464
|
+
): boolean {
|
|
465
|
+
if (!surface) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
for (const block of surface.blocks) {
|
|
470
|
+
if (block.kind !== "paragraph") {
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (
|
|
475
|
+
block.segments.some(
|
|
476
|
+
(segment) =>
|
|
477
|
+
segment.kind === "opaque_inline" &&
|
|
478
|
+
typeof segment.label === "string" &&
|
|
479
|
+
segment.label.startsWith(prefix),
|
|
480
|
+
)
|
|
481
|
+
) {
|
|
482
|
+
return true;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
return false;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function matchesCommentThread(
|
|
490
|
+
thread: RuntimeRenderSnapshot["comments"]["threads"][number],
|
|
491
|
+
check: Extract<ClosureValidationCheck, { type: "commentThreadMatch" }>,
|
|
492
|
+
): boolean {
|
|
493
|
+
if (check.commentId && thread.commentId !== check.commentId) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
if (check.status && thread.status !== check.status) {
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
if (typeof check.entryCount === "number" && thread.entries.length !== check.entryCount) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
if (check.anchorKind && thread.anchor.kind !== check.anchorKind) {
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
if (check.authorId && thread.createdBy !== check.authorId) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
if (check.bodyIncludes?.length) {
|
|
509
|
+
const bodies = thread.entries.map((entry) => entry.body);
|
|
510
|
+
for (const expectedBody of check.bodyIncludes) {
|
|
511
|
+
if (!bodies.some((body) => body.includes(expectedBody))) {
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
if (check.entryBodies?.length) {
|
|
517
|
+
if (thread.entries.length < check.entryBodies.length) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
for (let index = 0; index < check.entryBodies.length; index += 1) {
|
|
521
|
+
const expectedBody = check.entryBodies[index];
|
|
522
|
+
const actualBody = thread.entries[index]?.body;
|
|
523
|
+
if (typeof expectedBody !== "string" || actualBody !== expectedBody) {
|
|
524
|
+
return false;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
if (check.entryAuthorIds?.length) {
|
|
529
|
+
if (thread.entries.length < check.entryAuthorIds.length) {
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
for (let index = 0; index < check.entryAuthorIds.length; index += 1) {
|
|
533
|
+
const expectedAuthorId = check.entryAuthorIds[index];
|
|
534
|
+
const actualAuthorId = thread.entries[index]?.authorId;
|
|
535
|
+
if (typeof expectedAuthorId !== "string" || actualAuthorId !== expectedAuthorId) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function describeTrackedChangeMatch(
|
|
544
|
+
check: Extract<ClosureValidationCheck, { type: "trackedChangeMatch" }>,
|
|
545
|
+
): string {
|
|
546
|
+
return [
|
|
547
|
+
check.kind ? `kind=${check.kind}` : undefined,
|
|
548
|
+
check.actionability ? `actionability=${check.actionability}` : undefined,
|
|
549
|
+
check.status ? `status=${check.status}` : undefined,
|
|
550
|
+
check.preserveOnlyReasonIncludes?.length
|
|
551
|
+
? `preserveOnlyReasonIncludes=${check.preserveOnlyReasonIncludes.join(",")}`
|
|
552
|
+
: undefined,
|
|
553
|
+
]
|
|
554
|
+
.filter(Boolean)
|
|
555
|
+
.join(" ");
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function describeFieldEntryMatch(
|
|
559
|
+
check: Extract<ClosureValidationCheck, { type: "fieldEntryMatch" }>,
|
|
560
|
+
): string {
|
|
561
|
+
return [
|
|
562
|
+
check.fieldFamily ? `fieldFamily=${check.fieldFamily}` : undefined,
|
|
563
|
+
check.supported !== undefined ? `supported=${String(check.supported)}` : undefined,
|
|
564
|
+
check.refreshStatus ? `refreshStatus=${check.refreshStatus}` : undefined,
|
|
565
|
+
check.fieldTarget ? `fieldTarget=${check.fieldTarget}` : undefined,
|
|
566
|
+
check.displayTextIncludes?.length
|
|
567
|
+
? `displayTextIncludes=${check.displayTextIncludes.join(",")}`
|
|
568
|
+
: undefined,
|
|
569
|
+
]
|
|
570
|
+
.filter(Boolean)
|
|
571
|
+
.join(" ");
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
function describeProtectionMatch(
|
|
575
|
+
check: Extract<ClosureValidationCheck, { type: "protectionMatch" }>,
|
|
576
|
+
): string {
|
|
577
|
+
return [
|
|
578
|
+
check.hasDocumentProtection !== undefined
|
|
579
|
+
? `hasDocumentProtection=${String(check.hasDocumentProtection)}`
|
|
580
|
+
: undefined,
|
|
581
|
+
check.editType ? `editType=${check.editType}` : undefined,
|
|
582
|
+
check.enforcementActive !== undefined
|
|
583
|
+
? `enforcementActive=${String(check.enforcementActive)}`
|
|
584
|
+
: undefined,
|
|
585
|
+
check.enforcedRangeCountAtLeast !== undefined
|
|
586
|
+
? `enforcedRangeCountAtLeast=${String(check.enforcedRangeCountAtLeast)}`
|
|
587
|
+
: undefined,
|
|
588
|
+
check.preservedRangeCountAtLeast !== undefined
|
|
589
|
+
? `preservedRangeCountAtLeast=${String(check.preservedRangeCountAtLeast)}`
|
|
590
|
+
: undefined,
|
|
591
|
+
check.rangeId ? `rangeId=${check.rangeId}` : undefined,
|
|
592
|
+
check.rangeEnforced !== undefined
|
|
593
|
+
? `rangeEnforced=${String(check.rangeEnforced)}`
|
|
594
|
+
: undefined,
|
|
595
|
+
]
|
|
596
|
+
.filter(Boolean)
|
|
597
|
+
.join(" ");
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
function getLayoutsForCheck(
|
|
601
|
+
context: ClosureValidationContext,
|
|
602
|
+
check: Extract<ClosureValidationCheck, { type: "pageLayoutMatch" }>,
|
|
603
|
+
) {
|
|
604
|
+
const navigationLayouts =
|
|
605
|
+
context.navigation?.pages
|
|
606
|
+
.filter((page) => check.sectionIndex === undefined || page.sectionIndex === check.sectionIndex)
|
|
607
|
+
.map((page) => page.layout) ?? [];
|
|
608
|
+
if (navigationLayouts.length > 0) {
|
|
609
|
+
return navigationLayouts;
|
|
610
|
+
}
|
|
611
|
+
const activeLayout = context.renderSnapshot.pageLayout;
|
|
612
|
+
if (
|
|
613
|
+
activeLayout &&
|
|
614
|
+
(check.sectionIndex === undefined || activeLayout.sectionIndex === check.sectionIndex)
|
|
615
|
+
) {
|
|
616
|
+
return [activeLayout];
|
|
617
|
+
}
|
|
618
|
+
return [];
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
function countUniqueStoryVariants(
|
|
622
|
+
layouts: Array<{
|
|
623
|
+
headerVariants: Array<{ variant: string; relationshipId: string }>;
|
|
624
|
+
footerVariants: Array<{ variant: string; relationshipId: string }>;
|
|
625
|
+
}>,
|
|
626
|
+
key: "headerVariants" | "footerVariants",
|
|
627
|
+
) {
|
|
628
|
+
const variants = new Set<string>();
|
|
629
|
+
for (const layout of layouts) {
|
|
630
|
+
for (const variant of layout[key]) {
|
|
631
|
+
variants.add(`${variant.variant}:${variant.relationshipId}`);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return variants.size;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
function describeCommentThreadMatch(
|
|
638
|
+
check: Extract<ClosureValidationCheck, { type: "commentThreadMatch" }>,
|
|
639
|
+
): string {
|
|
640
|
+
const parts: string[] = [];
|
|
641
|
+
if (check.commentId) {
|
|
642
|
+
parts.push(`commentId=${check.commentId}`);
|
|
643
|
+
}
|
|
644
|
+
if (check.status) {
|
|
645
|
+
parts.push(`status=${check.status}`);
|
|
646
|
+
}
|
|
647
|
+
if (typeof check.entryCount === "number") {
|
|
648
|
+
parts.push(`entryCount=${check.entryCount}`);
|
|
649
|
+
}
|
|
650
|
+
if (check.anchorKind) {
|
|
651
|
+
parts.push(`anchorKind=${check.anchorKind}`);
|
|
652
|
+
}
|
|
653
|
+
if (check.authorId) {
|
|
654
|
+
parts.push(`authorId=${check.authorId}`);
|
|
655
|
+
}
|
|
656
|
+
if (check.bodyIncludes?.length) {
|
|
657
|
+
parts.push(`bodyIncludes=${check.bodyIncludes.join(" | ")}`);
|
|
658
|
+
}
|
|
659
|
+
if (check.entryBodies?.length) {
|
|
660
|
+
parts.push(`entryBodies=${check.entryBodies.join(" | ")}`);
|
|
661
|
+
}
|
|
662
|
+
if (check.entryAuthorIds?.length) {
|
|
663
|
+
parts.push(`entryAuthorIds=${check.entryAuthorIds.join(" | ")}`);
|
|
664
|
+
}
|
|
665
|
+
return parts.length > 0 ? parts.join(", ") : "any thread";
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
function describeSecondaryStoryMatch(
|
|
669
|
+
check: Extract<ClosureValidationCheck, { type: "secondaryStoryMatch" }>,
|
|
670
|
+
): string {
|
|
671
|
+
const parts = [`kind=${check.kind}`];
|
|
672
|
+
if (check.relationshipId) {
|
|
673
|
+
parts.push(`relationshipId=${check.relationshipId}`);
|
|
674
|
+
}
|
|
675
|
+
if (check.variant) {
|
|
676
|
+
parts.push(`variant=${check.variant}`);
|
|
677
|
+
}
|
|
678
|
+
if (check.noteId) {
|
|
679
|
+
parts.push(`noteId=${check.noteId}`);
|
|
680
|
+
}
|
|
681
|
+
if (typeof check.minBlockCount === "number") {
|
|
682
|
+
parts.push(`minBlockCount=${check.minBlockCount}`);
|
|
683
|
+
}
|
|
684
|
+
return parts.join(", ");
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
function describePageLayoutMatch(
|
|
688
|
+
check: Extract<ClosureValidationCheck, { type: "pageLayoutMatch" }>,
|
|
689
|
+
): string {
|
|
690
|
+
const parts: string[] = [];
|
|
691
|
+
if (typeof check.sectionIndex === "number") {
|
|
692
|
+
parts.push(`sectionIndex=${check.sectionIndex}`);
|
|
693
|
+
}
|
|
694
|
+
if (check.orientation) {
|
|
695
|
+
parts.push(`orientation=${check.orientation}`);
|
|
696
|
+
}
|
|
697
|
+
if (typeof check.columns === "number") {
|
|
698
|
+
parts.push(`columns=${check.columns}`);
|
|
699
|
+
}
|
|
700
|
+
if (typeof check.differentFirstPage === "boolean") {
|
|
701
|
+
parts.push(`differentFirstPage=${check.differentFirstPage}`);
|
|
702
|
+
}
|
|
703
|
+
if (typeof check.differentOddEvenPages === "boolean") {
|
|
704
|
+
parts.push(`differentOddEvenPages=${check.differentOddEvenPages}`);
|
|
705
|
+
}
|
|
706
|
+
if (typeof check.headerVariantCountAtLeast === "number") {
|
|
707
|
+
parts.push(`headerVariantCountAtLeast=${check.headerVariantCountAtLeast}`);
|
|
708
|
+
}
|
|
709
|
+
if (typeof check.footerVariantCountAtLeast === "number") {
|
|
710
|
+
parts.push(`footerVariantCountAtLeast=${check.footerVariantCountAtLeast}`);
|
|
711
|
+
}
|
|
712
|
+
return parts.length > 0 ? parts.join(", ") : "present";
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
function decodePartText(bytes: Uint8Array | undefined): string {
|
|
716
|
+
if (!bytes) {
|
|
717
|
+
return "";
|
|
718
|
+
}
|
|
719
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
720
|
+
}
|