@stll/folio-core 0.0.1-placeholder.0 → 0.1.1
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/LICENSE +202 -0
- package/NOTICE.md +29 -0
- package/README.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ai-edits/apply.d.ts +35 -0
- package/dist/ai-edits/apply.js +683 -0
- package/dist/ai-edits/clean-text.d.ts +28 -0
- package/dist/ai-edits/clean-text.js +23 -0
- package/dist/ai-edits/headless.d.ts +225 -0
- package/dist/ai-edits/headless.js +513 -0
- package/dist/ai-edits/index.d.ts +6 -0
- package/dist/ai-edits/index.js +5 -0
- package/dist/ai-edits/inline-emphasis.d.ts +38 -0
- package/dist/ai-edits/inline-emphasis.js +78 -0
- package/dist/ai-edits/snapshot.d.ts +9 -0
- package/dist/ai-edits/snapshot.js +195 -0
- package/dist/ai-edits/types.d.ts +156 -0
- package/dist/ai-edits/types.js +0 -0
- package/dist/ai-edits/word-diff.d.ts +20 -0
- package/dist/ai-edits/word-diff.js +77 -0
- package/dist/ai-suggestions/apply.d.ts +17 -0
- package/dist/ai-suggestions/apply.js +64 -0
- package/dist/ai-suggestions/conflict.d.ts +22 -0
- package/dist/ai-suggestions/conflict.js +67 -0
- package/dist/ai-suggestions/text-positions.d.ts +21 -0
- package/dist/ai-suggestions/text-positions.js +48 -0
- package/dist/ai-suggestions/types.d.ts +199 -0
- package/dist/ai-suggestions/types.js +59 -0
- package/dist/content-controls/errors.d.ts +52 -0
- package/dist/content-controls/errors.js +36 -0
- package/dist/content-controls/findContentControls.d.ts +55 -0
- package/dist/content-controls/findContentControls.js +75 -0
- package/dist/content-controls/index.d.ts +4 -0
- package/dist/content-controls/index.js +4 -0
- package/dist/content-controls/mutateContentControls.d.ts +51 -0
- package/dist/content-controls/mutateContentControls.js +377 -0
- package/dist/controller/folioEditor.d.ts +21 -0
- package/dist/controller/folioEditor.js +29 -0
- package/dist/controller/folioEditorEvents.d.ts +23 -0
- package/dist/controller/folioEditorEvents.js +24 -0
- package/dist/controller/hiddenEditorApi.d.ts +35 -0
- package/dist/controller/hiddenEditorApi.js +112 -0
- package/dist/controller/hiddenEditorManager.d.ts +93 -0
- package/dist/controller/hiddenEditorManager.js +308 -0
- package/dist/controller/layoutPipeline.d.ts +63 -0
- package/dist/controller/layoutPipeline.js +406 -0
- package/dist/controller/layoutScheduler.d.ts +41 -0
- package/dist/controller/layoutScheduler.js +59 -0
- package/dist/controller/layoutSession.d.ts +24 -0
- package/dist/controller/layoutSession.js +13 -0
- package/dist/docx/blockContentParser.d.ts +13 -0
- package/dist/docx/blockContentParser.js +289 -0
- package/dist/docx/bookmarkParser.d.ts +178 -0
- package/dist/docx/bookmarkParser.js +246 -0
- package/dist/docx/bookmarkPlacement.d.ts +10 -0
- package/dist/docx/bookmarkPlacement.js +50 -0
- package/dist/docx/bulletMarkers.d.ts +4 -0
- package/dist/docx/bulletMarkers.js +42 -0
- package/dist/docx/commentParser.d.ts +34 -0
- package/dist/docx/commentParser.js +127 -0
- package/dist/docx/commentReferenceNormalization.d.ts +25 -0
- package/dist/docx/commentReferenceNormalization.js +97 -0
- package/dist/docx/commentReplyMarkers.d.ts +20 -0
- package/dist/docx/commentReplyMarkers.js +123 -0
- package/dist/docx/compatibility.d.ts +12 -0
- package/dist/docx/compatibility.js +77 -0
- package/dist/docx/documentParser.d.ts +65 -0
- package/dist/docx/documentParser.js +209 -0
- package/dist/docx/drawingUtils.d.ts +56 -0
- package/dist/docx/drawingUtils.js +305 -0
- package/dist/docx/fieldParser.d.ts +228 -0
- package/dist/docx/fieldParser.js +559 -0
- package/dist/docx/footnoteParser.d.ts +109 -0
- package/dist/docx/footnoteParser.js +270 -0
- package/dist/docx/headerFooterParser.d.ts +119 -0
- package/dist/docx/headerFooterParser.js +266 -0
- package/dist/docx/headerFooterRefParser.d.ts +22 -0
- package/dist/docx/headerFooterRefParser.js +52 -0
- package/dist/docx/headerFooterReferenceNormalization.d.ts +19 -0
- package/dist/docx/headerFooterReferenceNormalization.js +64 -0
- package/dist/docx/hyperlinkParser.d.ts +108 -0
- package/dist/docx/hyperlinkParser.js +230 -0
- package/dist/docx/imageParser.d.ts +93 -0
- package/dist/docx/imageParser.js +522 -0
- package/dist/docx/mathToMathml.d.ts +15 -0
- package/dist/docx/mathToMathml.js +357 -0
- package/dist/docx/modelValidation.d.ts +13 -0
- package/dist/docx/modelValidation.js +21 -0
- package/dist/docx/normalizeBaseDirection.d.ts +12 -0
- package/dist/docx/normalizeBaseDirection.js +81 -0
- package/dist/docx/notePropertiesParser.d.ts +16 -0
- package/dist/docx/notePropertiesParser.js +99 -0
- package/dist/docx/numberingParser.d.ts +86 -0
- package/dist/docx/numberingParser.js +735 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +25 -0
- package/dist/docx/numberingReferenceNormalization.js +22 -0
- package/dist/docx/paragraphParser.d.ts +86 -0
- package/dist/docx/paragraphParser.js +1132 -0
- package/dist/docx/paragraphTraversal.d.ts +19 -0
- package/dist/docx/paragraphTraversal.js +76 -0
- package/dist/docx/parser.d.ts +67 -0
- package/dist/docx/parser.js +391 -0
- package/dist/docx/parserEnums.d.ts +45 -0
- package/dist/docx/parserEnums.js +70 -0
- package/dist/docx/relsParser.d.ts +160 -0
- package/dist/docx/relsParser.js +235 -0
- package/dist/docx/replyToComment.d.ts +29 -0
- package/dist/docx/replyToComment.js +73 -0
- package/dist/docx/rezip.d.ts +166 -0
- package/dist/docx/rezip.js +1194 -0
- package/dist/docx/runConsolidator.d.ts +57 -0
- package/dist/docx/runConsolidator.js +224 -0
- package/dist/docx/runParser.d.ts +78 -0
- package/dist/docx/runParser.js +661 -0
- package/dist/docx/sdtProperties.d.ts +15 -0
- package/dist/docx/sdtProperties.js +290 -0
- package/dist/docx/sdtPropertiesPatch.d.ts +16 -0
- package/dist/docx/sdtPropertiesPatch.js +144 -0
- package/dist/docx/sectionParser.d.ts +95 -0
- package/dist/docx/sectionParser.js +534 -0
- package/dist/docx/selectiveSave.d.ts +25 -0
- package/dist/docx/selectiveSave.js +247 -0
- package/dist/docx/selectiveSaveFlags.d.ts +33 -0
- package/dist/docx/selectiveSaveFlags.js +11 -0
- package/dist/docx/selectiveSaveTripwire.d.ts +33 -0
- package/dist/docx/selectiveSaveTripwire.js +79 -0
- package/dist/docx/selectiveXmlPatch.d.ts +103 -0
- package/dist/docx/selectiveXmlPatch.js +493 -0
- package/dist/docx/serializer/blockSdtSerializer.d.ts +6 -0
- package/dist/docx/serializer/blockSdtSerializer.js +88 -0
- package/dist/docx/serializer/borderSerializer.d.ts +25 -0
- package/dist/docx/serializer/borderSerializer.js +44 -0
- package/dist/docx/serializer/commentSerializer.d.ts +31 -0
- package/dist/docx/serializer/commentSerializer.js +184 -0
- package/dist/docx/serializer/documentSerializer.d.ts +65 -0
- package/dist/docx/serializer/documentSerializer.js +199 -0
- package/dist/docx/serializer/headerFooterSerializer.d.ts +12 -0
- package/dist/docx/serializer/headerFooterSerializer.js +84 -0
- package/dist/docx/serializer/noteSerializer.d.ts +19 -0
- package/dist/docx/serializer/noteSerializer.js +70 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +12 -0
- package/dist/docx/serializer/numberingSerializer.js +93 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +48 -0
- package/dist/docx/serializer/paragraphSerializer.js +559 -0
- package/dist/docx/serializer/runSerializer.d.ts +56 -0
- package/dist/docx/serializer/runSerializer.js +621 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +6 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +187 -0
- package/dist/docx/serializer/tableSerializer.d.ts +79 -0
- package/dist/docx/serializer/tableSerializer.js +422 -0
- package/dist/docx/serializer/xmlUtils.d.ts +20 -0
- package/dist/docx/serializer/xmlUtils.js +25 -0
- package/dist/docx/settingsParser.d.ts +8 -0
- package/dist/docx/settingsParser.js +36 -0
- package/dist/docx/shapeParser.d.ts +20 -0
- package/dist/docx/shapeParser.js +272 -0
- package/dist/docx/styleParser.d.ts +50 -0
- package/dist/docx/styleParser.js +905 -0
- package/dist/docx/tableParser.d.ts +202 -0
- package/dist/docx/tableParser.js +811 -0
- package/dist/docx/textBoxParser.d.ts +117 -0
- package/dist/docx/textBoxParser.js +262 -0
- package/dist/docx/themeParser.d.ts +77 -0
- package/dist/docx/themeParser.js +330 -0
- package/dist/docx/trackedMoveRangeNormalization.d.ts +22 -0
- package/dist/docx/trackedMoveRangeNormalization.js +100 -0
- package/dist/docx/unzip.d.ts +118 -0
- package/dist/docx/unzip.js +383 -0
- package/dist/docx/vmlImageParser.d.ts +16 -0
- package/dist/docx/vmlImageParser.js +100 -0
- package/dist/docx/watermarkParser.d.ts +45 -0
- package/dist/docx/watermarkParser.js +348 -0
- package/dist/docx/wrapTypes.d.ts +29 -0
- package/dist/docx/wrapTypes.js +48 -0
- package/dist/docx/xmlParser.d.ts +297 -0
- package/dist/docx/xmlParser.js +527 -0
- package/dist/fields/bookmarkPages.d.ts +13 -0
- package/dist/fields/bookmarkPages.js +66 -0
- package/dist/fields/bookmarkText.d.ts +16 -0
- package/dist/fields/bookmarkText.js +61 -0
- package/dist/fields/evaluateField.d.ts +23 -0
- package/dist/fields/evaluateField.js +77 -0
- package/dist/fields/fieldContext.d.ts +21 -0
- package/dist/fields/fieldContext.js +0 -0
- package/dist/fields/resolveFieldValues.d.ts +44 -0
- package/dist/fields/resolveFieldValues.js +204 -0
- package/dist/fields/sectionPageCounts.d.ts +11 -0
- package/dist/fields/sectionPageCounts.js +16 -0
- package/dist/fields/seqValues.d.ts +14 -0
- package/dist/fields/seqValues.js +36 -0
- package/dist/fonts/embeddedFontTable.d.ts +42 -0
- package/dist/fonts/embeddedFontTable.js +80 -0
- package/dist/fonts/embeddedFonts.d.ts +46 -0
- package/dist/fonts/embeddedFonts.js +112 -0
- package/dist/fonts/fontDeobfuscation.d.ts +30 -0
- package/dist/fonts/fontDeobfuscation.js +57 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +23 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +57 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +316 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +74 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +432 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +36 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.js +176 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +65 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +1309 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +17 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.js +36 -0
- package/dist/layout-bridge/dom/clickToPositionDom.d.ts +66 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +304 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.d.ts +7 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.js +17 -0
- package/dist/layout-bridge/dom/findHfPmSpans.d.ts +62 -0
- package/dist/layout-bridge/dom/findHfPmSpans.js +197 -0
- package/dist/layout-bridge/engine/clickToPosition.d.ts +66 -0
- package/dist/layout-bridge/engine/clickToPosition.js +403 -0
- package/dist/layout-bridge/engine/hitTest.d.ts +135 -0
- package/dist/layout-bridge/engine/hitTest.js +375 -0
- package/dist/layout-bridge/engine/measuring/index.d.ts +10 -0
- package/dist/layout-bridge/engine/measuring/index.js +9 -0
- package/dist/layout-bridge/engine/selectionRects.d.ts +59 -0
- package/dist/layout-bridge/engine/selectionRects.js +485 -0
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +7 -0
- package/dist/layout-bridge/engine/tableWidthUtils.js +25 -0
- package/dist/layout-engine/index.d.ts +44 -0
- package/dist/layout-engine/index.js +691 -0
- package/dist/layout-engine/keep-together.d.ts +43 -0
- package/dist/layout-engine/keep-together.js +98 -0
- package/dist/layout-engine/layoutInstrumentation.d.ts +50 -0
- package/dist/layout-engine/layoutInstrumentation.js +43 -0
- package/dist/layout-engine/lineFlow.d.ts +8 -0
- package/dist/layout-engine/lineFlow.js +17 -0
- package/dist/layout-engine/measure/cache.d.ts +93 -0
- package/dist/layout-engine/measure/cache.js +245 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.d.ts +20 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.js +29 -0
- package/dist/layout-engine/measure/featureFlags.d.ts +44 -0
- package/dist/layout-engine/measure/featureFlags.js +19 -0
- package/dist/layout-engine/measure/floatingZones.d.ts +89 -0
- package/dist/layout-engine/measure/floatingZones.js +152 -0
- package/dist/layout-engine/measure/font-metrics.worker.d.ts +17 -0
- package/dist/layout-engine/measure/font-metrics.worker.js +104 -0
- package/dist/layout-engine/measure/index.d.ts +9 -0
- package/dist/layout-engine/measure/index.js +8 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +40 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +76 -0
- package/dist/layout-engine/measure/measureBlocks.d.ts +25 -0
- package/dist/layout-engine/measure/measureBlocks.js +450 -0
- package/dist/layout-engine/measure/measureContainer.d.ts +24 -0
- package/dist/layout-engine/measure/measureContainer.js +280 -0
- package/dist/layout-engine/measure/measureHelpers.d.ts +82 -0
- package/dist/layout-engine/measure/measureHelpers.js +156 -0
- package/dist/layout-engine/measure/measureParagraph.d.ts +61 -0
- package/dist/layout-engine/measure/measureParagraph.js +724 -0
- package/dist/layout-engine/measure/measureProvider.d.ts +23 -0
- package/dist/layout-engine/measure/measureProvider.js +35 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +61 -0
- package/dist/layout-engine/measure/measureTypes.js +0 -0
- package/dist/layout-engine/measure/measureWorker.d.ts +54 -0
- package/dist/layout-engine/measure/measureWorker.js +249 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +88 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.js +20 -0
- package/dist/layout-engine/measure/tableCellFloating.d.ts +26 -0
- package/dist/layout-engine/measure/tableCellFloating.js +99 -0
- package/dist/layout-engine/paginator.d.ts +84 -0
- package/dist/layout-engine/paginator.js +348 -0
- package/dist/layout-engine/paragraphFragmentRange.d.ts +9 -0
- package/dist/layout-engine/paragraphFragmentRange.js +40 -0
- package/dist/layout-engine/section-breaks.d.ts +78 -0
- package/dist/layout-engine/section-breaks.js +182 -0
- package/dist/layout-engine/tableRowBreak.d.ts +23 -0
- package/dist/layout-engine/tableRowBreak.js +147 -0
- package/dist/layout-engine/textBoxFlow.d.ts +50 -0
- package/dist/layout-engine/textBoxFlow.js +160 -0
- package/dist/layout-engine/types.d.ts +1031 -0
- package/dist/layout-engine/types.js +100 -0
- package/dist/layout-painter/documentColors.d.ts +4 -0
- package/dist/layout-painter/documentColors.js +40 -0
- package/dist/layout-painter/index.d.ts +110 -0
- package/dist/layout-painter/index.js +182 -0
- package/dist/layout-painter/registry/modules/image.d.ts +6 -0
- package/dist/layout-painter/registry/modules/image.js +17 -0
- package/dist/layout-painter/registry/modules/paragraph.d.ts +6 -0
- package/dist/layout-painter/registry/modules/paragraph.js +18 -0
- package/dist/layout-painter/registry/modules/table.d.ts +6 -0
- package/dist/layout-painter/registry/modules/table.js +16 -0
- package/dist/layout-painter/registry/modules/textBox.d.ts +6 -0
- package/dist/layout-painter/registry/modules/textBox.js +13 -0
- package/dist/layout-painter/registry/modules.d.ts +6 -0
- package/dist/layout-painter/registry/modules.js +26 -0
- package/dist/layout-painter/registry/registry.d.ts +24 -0
- package/dist/layout-painter/registry/registry.js +53 -0
- package/dist/layout-painter/registry/types.d.ts +61 -0
- package/dist/layout-painter/registry/types.js +0 -0
- package/dist/layout-painter/renderFragment.d.ts +32 -0
- package/dist/layout-painter/renderFragment.js +114 -0
- package/dist/layout-painter/renderImage.d.ts +88 -0
- package/dist/layout-painter/renderImage.js +130 -0
- package/dist/layout-painter/renderPage.d.ts +264 -0
- package/dist/layout-painter/renderPage.js +1795 -0
- package/dist/layout-painter/renderParagraph.d.ts +93 -0
- package/dist/layout-painter/renderParagraph.js +1300 -0
- package/dist/layout-painter/renderTable.d.ts +36 -0
- package/dist/layout-painter/renderTable.js +432 -0
- package/dist/layout-painter/renderTextBox.d.ts +22 -0
- package/dist/layout-painter/renderTextBox.js +67 -0
- package/dist/layout-painter/renderUtils.d.ts +42 -0
- package/dist/layout-painter/renderUtils.js +30 -0
- package/dist/layout-painter/renderWatermark.d.ts +16 -0
- package/dist/layout-painter/renderWatermark.js +61 -0
- package/dist/layout-painter/sdtBoundary.d.ts +6 -0
- package/dist/layout-painter/sdtBoundary.js +28 -0
- package/dist/managers/ContextMenuManager.d.ts +28 -0
- package/dist/managers/ContextMenuManager.js +48 -0
- package/dist/managers/DocumentLoaderManager.d.ts +47 -0
- package/dist/managers/DocumentLoaderManager.js +69 -0
- package/dist/managers/EditorModeManager.d.ts +28 -0
- package/dist/managers/EditorModeManager.js +50 -0
- package/dist/managers/ErrorManager.d.ts +26 -0
- package/dist/managers/ErrorManager.js +85 -0
- package/dist/managers/FindReplaceManager.d.ts +54 -0
- package/dist/managers/FindReplaceManager.js +104 -0
- package/dist/managers/HistoryManager.d.ts +92 -0
- package/dist/managers/HistoryManager.js +193 -0
- package/dist/managers/Subscribable.d.ts +34 -0
- package/dist/managers/Subscribable.js +46 -0
- package/dist/managers/TableSelectionManager.d.ts +74 -0
- package/dist/managers/TableSelectionManager.js +225 -0
- package/dist/managers/editorShortcuts.d.ts +42 -0
- package/dist/managers/editorShortcuts.js +60 -0
- package/dist/managers/types.d.ts +41 -0
- package/dist/managers/types.js +0 -0
- package/dist/markdown/annotations.d.ts +14 -0
- package/dist/markdown/annotations.js +42 -0
- package/dist/markdown/escape.d.ts +36 -0
- package/dist/markdown/escape.js +59 -0
- package/dist/markdown/fromMarkdown.d.ts +11 -0
- package/dist/markdown/fromMarkdown.js +223 -0
- package/dist/markdown/headings.d.ts +13 -0
- package/dist/markdown/headings.js +20 -0
- package/dist/markdown/images.d.ts +13 -0
- package/dist/markdown/images.js +63 -0
- package/dist/markdown/index.d.ts +18 -0
- package/dist/markdown/index.js +33 -0
- package/dist/markdown/internals.d.ts +15 -0
- package/dist/markdown/internals.js +35 -0
- package/dist/markdown/renderBlock.d.ts +7 -0
- package/dist/markdown/renderBlock.js +68 -0
- package/dist/markdown/renderParagraph.d.ts +11 -0
- package/dist/markdown/renderParagraph.js +64 -0
- package/dist/markdown/renderRuns.d.ts +11 -0
- package/dist/markdown/renderRuns.js +265 -0
- package/dist/markdown/renderTable.d.ts +8 -0
- package/dist/markdown/renderTable.js +229 -0
- package/dist/markdown/trailers.d.ts +13 -0
- package/dist/markdown/trailers.js +54 -0
- package/dist/markdown/types.d.ts +118 -0
- package/dist/markdown/types.js +0 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +4 -0
- package/dist/paged-layout/LayoutSelectionGate.d.ts +80 -0
- package/dist/paged-layout/LayoutSelectionGate.js +131 -0
- package/dist/paged-layout/headerFooterMargins.d.ts +73 -0
- package/dist/paged-layout/headerFooterMargins.js +120 -0
- package/dist/paged-layout/hiddenEditorScroll.d.ts +4 -0
- package/dist/paged-layout/hiddenEditorScroll.js +4 -0
- package/dist/paged-layout/incrementalMeasure.d.ts +33 -0
- package/dist/paged-layout/incrementalMeasure.js +56 -0
- package/dist/paged-layout/rangeProjection.d.ts +51 -0
- package/dist/paged-layout/rangeProjection.js +153 -0
- package/dist/paged-layout/readOnlyEditAttempt.d.ts +5 -0
- package/dist/paged-layout/readOnlyEditAttempt.js +22 -0
- package/dist/paged-layout/scrollNavigation.d.ts +23 -0
- package/dist/paged-layout/scrollNavigation.js +31 -0
- package/dist/paged-layout/scrollPageInfo.d.ts +41 -0
- package/dist/paged-layout/scrollPageInfo.js +34 -0
- package/dist/paged-layout/scrollToPmPosition.d.ts +17 -0
- package/dist/paged-layout/scrollToPmPosition.js +95 -0
- package/dist/paged-layout/sectionBlockWidths.d.ts +35 -0
- package/dist/paged-layout/sectionBlockWidths.js +52 -0
- package/dist/paged-layout/sectionGeometry.d.ts +21 -0
- package/dist/paged-layout/sectionGeometry.js +36 -0
- package/dist/paged-layout/selectionViewportRect.d.ts +29 -0
- package/dist/paged-layout/selectionViewportRect.js +55 -0
- package/dist/paged-layout/tableColumnResize.d.ts +19 -0
- package/dist/paged-layout/tableColumnResize.js +28 -0
- package/dist/paged-layout/tableInsertButtonGeometry.d.ts +15 -0
- package/dist/paged-layout/tableInsertButtonGeometry.js +15 -0
- package/dist/paged-layout/transactionDirtyRange.d.ts +7 -0
- package/dist/paged-layout/transactionDirtyRange.js +27 -0
- package/dist/paged-layout/zoomScrollAnchor.d.ts +40 -0
- package/dist/paged-layout/zoomScrollAnchor.js +25 -0
- package/dist/prosemirror/attrs/index.d.ts +80 -0
- package/dist/prosemirror/attrs/index.js +1218 -0
- package/dist/prosemirror/autospacingBase.d.ts +11 -0
- package/dist/prosemirror/autospacingBase.js +16 -0
- package/dist/prosemirror/commands/comments.d.ts +93 -0
- package/dist/prosemirror/commands/comments.js +435 -0
- package/dist/prosemirror/commands/contentControls.d.ts +45 -0
- package/dist/prosemirror/commands/contentControls.js +294 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +15 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.js +19 -0
- package/dist/prosemirror/commands/formatPainter.d.ts +31 -0
- package/dist/prosemirror/commands/formatPainter.js +130 -0
- package/dist/prosemirror/commands/formatting.d.ts +32 -0
- package/dist/prosemirror/commands/formatting.js +45 -0
- package/dist/prosemirror/commands/hyperlink.d.ts +31 -0
- package/dist/prosemirror/commands/hyperlink.js +79 -0
- package/dist/prosemirror/commands/image.d.ts +59 -0
- package/dist/prosemirror/commands/image.js +219 -0
- package/dist/prosemirror/commands/index.d.ts +13 -0
- package/dist/prosemirror/commands/index.js +13 -0
- package/dist/prosemirror/commands/pageBreak.d.ts +10 -0
- package/dist/prosemirror/commands/pageBreak.js +47 -0
- package/dist/prosemirror/commands/paragraph.d.ts +39 -0
- package/dist/prosemirror/commands/paragraph.js +64 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +39 -0
- package/dist/prosemirror/commands/pastePlainText.js +67 -0
- package/dist/prosemirror/commands/table.d.ts +83 -0
- package/dist/prosemirror/commands/table.js +105 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +27 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +1550 -0
- package/dist/prosemirror/conversion/index.d.ts +4 -0
- package/dist/prosemirror/conversion/index.js +4 -0
- package/dist/prosemirror/conversion/runShadingMark.d.ts +16 -0
- package/dist/prosemirror/conversion/runShadingMark.js +39 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +39 -0
- package/dist/prosemirror/conversion/toProseDoc.js +1404 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +43 -0
- package/dist/prosemirror/extensions/ExtensionManager.js +86 -0
- package/dist/prosemirror/extensions/StarterKit.d.ts +16 -0
- package/dist/prosemirror/extensions/StarterKit.js +132 -0
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +12 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.js +28 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +25 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +619 -0
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/TextExtension.js +12 -0
- package/dist/prosemirror/extensions/create.d.ts +17 -0
- package/dist/prosemirror/extensions/create.js +129 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +106 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +172 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +38 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +21 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.js +20 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +44 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +19 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.js +24 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +15 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +66 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +91 -0
- package/dist/prosemirror/extensions/features/ListExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +340 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +60 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +35 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +188 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +34 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +145 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +17 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +31 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.js +27 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +31 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.js +159 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.js +41 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +64 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +55 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +92 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +115 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +146 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.js +34 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.js +21 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +75 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +33 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +50 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +31 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +22 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +113 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +60 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +34 -0
- package/dist/prosemirror/extensions/marks/markUtils.js +233 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +122 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +38 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.js +18 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +132 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.js +56 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +107 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +30 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +502 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.js +27 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +1972 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +150 -0
- package/dist/prosemirror/extensions/types.d.ts +101 -0
- package/dist/prosemirror/extensions/types.js +10 -0
- package/dist/prosemirror/findReplaceSelection.d.ts +23 -0
- package/dist/prosemirror/findReplaceSelection.js +86 -0
- package/dist/prosemirror/index.d.ts +25 -0
- package/dist/prosemirror/index.js +23 -0
- package/dist/prosemirror/insertOperations.d.ts +12 -0
- package/dist/prosemirror/insertOperations.js +19 -0
- package/dist/prosemirror/paragraphDirection.d.ts +42 -0
- package/dist/prosemirror/paragraphDirection.js +33 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +40 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.js +90 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +42 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +135 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +60 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.js +120 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +123 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +283 -0
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +56 -0
- package/dist/prosemirror/plugins/contentControlWidgets.js +192 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +37 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.js +55 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +18 -0
- package/dist/prosemirror/plugins/documentStyles.js +46 -0
- package/dist/prosemirror/plugins/index.d.ts +3 -0
- package/dist/prosemirror/plugins/index.js +3 -0
- package/dist/prosemirror/plugins/pmTextScan.d.ts +19 -0
- package/dist/prosemirror/plugins/pmTextScan.js +39 -0
- package/dist/prosemirror/plugins/selectionTracker.d.ts +43 -0
- package/dist/prosemirror/plugins/selectionTracker.js +179 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +70 -0
- package/dist/prosemirror/plugins/suggestionMode.js +489 -0
- package/dist/prosemirror/plugins/templateDirectives.d.ts +25 -0
- package/dist/prosemirror/plugins/templateDirectives.js +67 -0
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +49 -0
- package/dist/prosemirror/plugins/templatePreviewValues.js +117 -0
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +57 -0
- package/dist/prosemirror/plugins/templateSlashMenu.js +184 -0
- package/dist/prosemirror/schema/index.d.ts +15 -0
- package/dist/prosemirror/schema/index.js +20 -0
- package/dist/prosemirror/schema/marks.d.ts +118 -0
- package/dist/prosemirror/schema/marks.js +0 -0
- package/dist/prosemirror/schema/nodes.d.ts +389 -0
- package/dist/prosemirror/schema/nodes.js +0 -0
- package/dist/prosemirror/selectionState.d.ts +23 -0
- package/dist/prosemirror/selectionState.js +111 -0
- package/dist/prosemirror/styles/index.d.ts +2 -0
- package/dist/prosemirror/styles/index.js +2 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +32 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +108 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +94 -0
- package/dist/prosemirror/styles/styleResolver.js +200 -0
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +26 -0
- package/dist/prosemirror/utils/findParagraphByParaId.js +37 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +110 -0
- package/dist/prosemirror/utils/tabCalculator.js +137 -0
- package/dist/prosemirror/validation.d.ts +20 -0
- package/dist/prosemirror/validation.js +177 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +6 -0
- package/dist/style-engine/index.d.ts +3 -0
- package/dist/style-engine/index.js +2 -0
- package/dist/style-engine/styleEngine.d.ts +67 -0
- package/dist/style-engine/styleEngine.js +70 -0
- package/dist/types/block-id.d.ts +66 -0
- package/dist/types/block-id.js +73 -0
- package/dist/types/colors.d.ts +2 -0
- package/dist/types/colors.js +0 -0
- package/dist/types/content.d.ts +2 -0
- package/dist/types/content.js +0 -0
- package/dist/types/document.d.ts +7 -0
- package/dist/types/document.js +0 -0
- package/dist/types/documentEnumValues.d.ts +89 -0
- package/dist/types/documentEnumValues.js +693 -0
- package/dist/types/formatting.d.ts +2 -0
- package/dist/types/formatting.js +0 -0
- package/dist/types/index.d.ts +107 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/authorColors.d.ts +16 -0
- package/dist/utils/authorColors.js +30 -0
- package/dist/utils/baseDirection.d.ts +23 -0
- package/dist/utils/baseDirection.js +34 -0
- package/dist/utils/clipboard.d.ts +126 -0
- package/dist/utils/clipboard.js +622 -0
- package/dist/utils/colorResolver.d.ts +158 -0
- package/dist/utils/colorResolver.js +557 -0
- package/dist/utils/createDocument.d.ts +50 -0
- package/dist/utils/createDocument.js +262 -0
- package/dist/utils/documentLoaderBehavior.d.ts +22 -0
- package/dist/utils/documentLoaderBehavior.js +14 -0
- package/dist/utils/docxInput.d.ts +22 -0
- package/dist/utils/docxInput.js +16 -0
- package/dist/utils/domGuards.d.ts +59 -0
- package/dist/utils/domGuards.js +82 -0
- package/dist/utils/fontFamilyMerge.d.ts +7 -0
- package/dist/utils/fontFamilyMerge.js +31 -0
- package/dist/utils/fontLoader.d.ts +50 -0
- package/dist/utils/fontLoader.js +177 -0
- package/dist/utils/fontResolver.d.ts +61 -0
- package/dist/utils/fontResolver.js +651 -0
- package/dist/utils/fontWeights.d.ts +4 -0
- package/dist/utils/fontWeights.js +4 -0
- package/dist/utils/formatToStyle.d.ts +103 -0
- package/dist/utils/formatToStyle.js +289 -0
- package/dist/utils/headerFooter.d.ts +74 -0
- package/dist/utils/headerFooter.js +257 -0
- package/dist/utils/headingCollector.d.ts +22 -0
- package/dist/utils/headingCollector.js +36 -0
- package/dist/utils/hexId.d.ts +33 -0
- package/dist/utils/hexId.js +37 -0
- package/dist/utils/imageValidation.d.ts +5 -0
- package/dist/utils/imageValidation.js +31 -0
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -0
- package/dist/utils/paragraphFormattingMerge.js +68 -0
- package/dist/utils/replaceText.d.ts +17 -0
- package/dist/utils/replaceText.js +161 -0
- package/dist/utils/rotationBoundingBox.d.ts +12 -0
- package/dist/utils/rotationBoundingBox.js +36 -0
- package/dist/utils/scriptSegments.d.ts +36 -0
- package/dist/utils/scriptSegments.js +52 -0
- package/dist/utils/tableOperations.d.ts +87 -0
- package/dist/utils/tableOperations.js +259 -0
- package/dist/utils/textFormattingMerge.d.ts +6 -0
- package/dist/utils/textFormattingMerge.js +31 -0
- package/dist/utils/tiffConverter.d.ts +18 -0
- package/dist/utils/tiffConverter.js +83 -0
- package/dist/utils/units.d.ts +99 -0
- package/dist/utils/units.js +139 -0
- package/dist/utils/urlSecurity.d.ts +7 -0
- package/dist/utils/urlSecurity.js +65 -0
- package/dist/watermark/index.d.ts +39 -0
- package/dist/watermark/index.js +149 -0
- package/package.json +122 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FontMetrics, FontStyle, RunMeasurement, TextMeasurement } from "./measureTypes.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/measure/measureProvider.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Swappable text-measurement backend. A canvas implementation is installed at
|
|
6
|
+
* the composition roots; a Rust/WASM or headless provider can be installed via
|
|
7
|
+
* `setMeasureProvider` without the layout engine importing canvas directly.
|
|
8
|
+
*/
|
|
9
|
+
type MeasureProvider = {
|
|
10
|
+
getFontMetrics: (style: FontStyle) => FontMetrics;
|
|
11
|
+
measureTextWidth: (text: string, style: FontStyle) => number;
|
|
12
|
+
measureText: (text: string, style: FontStyle) => TextMeasurement;
|
|
13
|
+
measureRun: (text: string, style: FontStyle) => RunMeasurement;
|
|
14
|
+
};
|
|
15
|
+
declare const getMeasureProvider: () => MeasureProvider;
|
|
16
|
+
declare const setMeasureProvider: (provider: MeasureProvider) => void;
|
|
17
|
+
declare const resetMeasureProvider: () => void;
|
|
18
|
+
declare const getFontMetrics: (style: FontStyle) => FontMetrics;
|
|
19
|
+
declare const measureTextWidth: (text: string, style: FontStyle) => number;
|
|
20
|
+
declare const measureText: (text: string, style: FontStyle) => TextMeasurement;
|
|
21
|
+
declare const measureRun: (text: string, style: FontStyle) => RunMeasurement;
|
|
22
|
+
//#endregion
|
|
23
|
+
export { MeasureProvider, getFontMetrics, getMeasureProvider, measureRun, measureText, measureTextWidth, resetMeasureProvider, setMeasureProvider };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { panic } from "better-result";
|
|
2
|
+
//#region src/layout-engine/measure/measureProvider.ts
|
|
3
|
+
/**
|
|
4
|
+
* Swappable text-measurement seam.
|
|
5
|
+
*
|
|
6
|
+
* Holds the provider interface, the active-provider registry, and the four
|
|
7
|
+
* public delegators the layout engine measures through. This module is pure:
|
|
8
|
+
* it never imports the canvas backend, so the engine's import graph stays
|
|
9
|
+
* canvas-free. The default provider throws — a composition root must install a
|
|
10
|
+
* concrete backend first (the React editor and the bun test preload call
|
|
11
|
+
* `installCanvasMeasureProvider()`).
|
|
12
|
+
*/
|
|
13
|
+
const throwingMeasureProvider = {
|
|
14
|
+
getFontMetrics: () => noProvider(),
|
|
15
|
+
measureTextWidth: () => noProvider(),
|
|
16
|
+
measureText: () => noProvider(),
|
|
17
|
+
measureRun: () => noProvider()
|
|
18
|
+
};
|
|
19
|
+
function noProvider() {
|
|
20
|
+
panic("No MeasureProvider installed — install canvasMeasureProvider (the React editor and the test preload do this).");
|
|
21
|
+
}
|
|
22
|
+
let activeMeasureProvider = throwingMeasureProvider;
|
|
23
|
+
const getMeasureProvider = () => activeMeasureProvider;
|
|
24
|
+
const setMeasureProvider = (provider) => {
|
|
25
|
+
activeMeasureProvider = provider;
|
|
26
|
+
};
|
|
27
|
+
const resetMeasureProvider = () => {
|
|
28
|
+
activeMeasureProvider = throwingMeasureProvider;
|
|
29
|
+
};
|
|
30
|
+
const getFontMetrics = (style) => activeMeasureProvider.getFontMetrics(style);
|
|
31
|
+
const measureTextWidth = (text, style) => activeMeasureProvider.measureTextWidth(text, style);
|
|
32
|
+
const measureText = (text, style) => activeMeasureProvider.measureText(text, style);
|
|
33
|
+
const measureRun = (text, style) => activeMeasureProvider.measureRun(text, style);
|
|
34
|
+
//#endregion
|
|
35
|
+
export { getFontMetrics, getMeasureProvider, measureRun, measureText, measureTextWidth, resetMeasureProvider, setMeasureProvider };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
declare namespace measureTypes_d_exports {
|
|
2
|
+
export { FontMetrics, FontStyle, RunMeasurement, TextMeasurement };
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Measurement data shapes.
|
|
6
|
+
*
|
|
7
|
+
* Pure type declarations shared by the provider seam (`measureProvider.ts`),
|
|
8
|
+
* the pure helpers (`measureHelpers.ts`), and the canvas implementation
|
|
9
|
+
* (`measureContainer.ts`). Types only — this module has no runtime and never
|
|
10
|
+
* pulls canvas/DOM into an importer's graph.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Font styling properties for measurement
|
|
14
|
+
*/
|
|
15
|
+
type FontStyle = {
|
|
16
|
+
fontFamily?: string;
|
|
17
|
+
/**
|
|
18
|
+
* East-Asian font for CJK code points. When set, `measureTextWidth` /
|
|
19
|
+
* `measureRun` measure CJK code points with this font and the rest with
|
|
20
|
+
* `fontFamily`, matching the painter's per-script span split so wrapping
|
|
21
|
+
* and click positioning stay in sync.
|
|
22
|
+
*/
|
|
23
|
+
eastAsiaFontFamily?: string;
|
|
24
|
+
fontSize?: number;
|
|
25
|
+
bold?: boolean;
|
|
26
|
+
italic?: boolean;
|
|
27
|
+
letterSpacing?: number;
|
|
28
|
+
textTransform?: "uppercase";
|
|
29
|
+
fontVariant?: "small-caps";
|
|
30
|
+
horizontalScale?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Typography metrics for a font
|
|
34
|
+
*/
|
|
35
|
+
type FontMetrics = {
|
|
36
|
+
fontSize: number;
|
|
37
|
+
ascent: number;
|
|
38
|
+
descent: number;
|
|
39
|
+
lineHeight: number;
|
|
40
|
+
fontFamily: string; /** OS/2 single-line ratio for OOXML line spacing calculation */
|
|
41
|
+
singleLineRatio: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Result of measuring a text string
|
|
45
|
+
*/
|
|
46
|
+
type TextMeasurement = {
|
|
47
|
+
width: number;
|
|
48
|
+
height: number;
|
|
49
|
+
ascent: number;
|
|
50
|
+
descent: number;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Result of measuring a run of text
|
|
54
|
+
*/
|
|
55
|
+
type RunMeasurement = {
|
|
56
|
+
width: number;
|
|
57
|
+
charWidths: number[];
|
|
58
|
+
metrics: FontMetrics;
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { FontMetrics, FontStyle, RunMeasurement, TextMeasurement, measureTypes_d_exports };
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { MeasureWorkerRequest, MeasureWorkerResponse } from "./measureWorkerProtocol.js";
|
|
2
|
+
|
|
3
|
+
//#region src/layout-engine/measure/measureWorker.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Minimal duck-typed transport so tests can supply a fake instead of a
|
|
6
|
+
* real `Worker`. Mirrors the subset of `Worker` we use.
|
|
7
|
+
*/
|
|
8
|
+
type MeasureWorkerTransport = {
|
|
9
|
+
postMessage: (message: MeasureWorkerRequest) => void;
|
|
10
|
+
addEventListener: {
|
|
11
|
+
(type: "message", listener: (event: {
|
|
12
|
+
data: MeasureWorkerResponse;
|
|
13
|
+
}) => void): void;
|
|
14
|
+
(type: "error", listener: (event: unknown) => void): void;
|
|
15
|
+
};
|
|
16
|
+
terminate: () => void;
|
|
17
|
+
};
|
|
18
|
+
type TransportFactory = () => MeasureWorkerTransport;
|
|
19
|
+
/**
|
|
20
|
+
* Test-only: inject a transport factory in place of the real `Worker`
|
|
21
|
+
* constructor. Pass `null` to restore production behaviour.
|
|
22
|
+
*/
|
|
23
|
+
declare function __setMeasureWorkerTransport(factory: TransportFactory | null): void;
|
|
24
|
+
/**
|
|
25
|
+
* Enqueue a measurement for asynchronous pre-warming. Returns
|
|
26
|
+
* immediately. The caller has already filled the cache synchronously
|
|
27
|
+
* for the *current* probe; this prefetch is only useful for *future*
|
|
28
|
+
* probes (re-layouts triggered by font-ready, page-resize, or
|
|
29
|
+
* suggestion-mode toggles, which all re-measure the same runs).
|
|
30
|
+
*
|
|
31
|
+
* No-op when the feature flag is OFF, when the host lacks
|
|
32
|
+
* `OffscreenCanvas`/`Worker`, or when the proxy has been disabled by
|
|
33
|
+
* a previous error.
|
|
34
|
+
*/
|
|
35
|
+
declare function prefetchMeasurement(text: string, font: string, letterSpacing: number, horizontalScale: number, fontCacheKey: string, fontFingerprintWidth: number): void;
|
|
36
|
+
declare function canPrefetchMeasurement(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Test-only: synchronously drain the pending queue. The caller is
|
|
39
|
+
* expected to have already attached its assertions to the cache or to
|
|
40
|
+
* the injected transport.
|
|
41
|
+
*/
|
|
42
|
+
declare function __flushMeasureQueueForTests(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Test-only: dispose the proxy. Safe to call when nothing is live.
|
|
45
|
+
*/
|
|
46
|
+
declare function __disposeMeasureProxyForTests(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Test-only: report whether the proxy considers itself alive. Useful
|
|
49
|
+
* for asserting that flag/feature-detection gating actually short-
|
|
50
|
+
* circuits worker construction.
|
|
51
|
+
*/
|
|
52
|
+
declare function __isMeasureProxyLiveForTests(): boolean;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { MeasureWorkerTransport, __disposeMeasureProxyForTests, __flushMeasureQueueForTests, __isMeasureProxyLiveForTests, __setMeasureWorkerTransport, canPrefetchMeasurement, prefetchMeasurement };
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { getTextWidthCacheGeneration, setCachedTextWidth } from "./cache.js";
|
|
2
|
+
import { isWorkerFontMetricsEnabled } from "./featureFlags.js";
|
|
3
|
+
//#region src/layout-engine/measure/measureWorker.ts
|
|
4
|
+
/**
|
|
5
|
+
* Main-thread proxy for the off-main-thread font-measurement worker.
|
|
6
|
+
*
|
|
7
|
+
* Lifecycle:
|
|
8
|
+
* 1. Caller enqueues a request via `prefetchMeasurement`.
|
|
9
|
+
* 2. The proxy debounces and batches enqueued requests on a ~10 ms
|
|
10
|
+
* tick, deduping by cache key.
|
|
11
|
+
* 3. The flushed batch is posted to the worker.
|
|
12
|
+
* 4. The worker replies with widths; the proxy writes them into the
|
|
13
|
+
* main-thread LRU cache via `setCachedTextWidth`.
|
|
14
|
+
*
|
|
15
|
+
* The proxy is **never** on the critical path. `measureTextWidth` on
|
|
16
|
+
* the main thread always returns synchronously from either the cache or
|
|
17
|
+
* a direct canvas read. The worker only pre-warms entries so subsequent
|
|
18
|
+
* re-layout passes (font-ready, page-resize, suggestion-mode toggles)
|
|
19
|
+
* hit the cache instead of the main-thread canvas.
|
|
20
|
+
*
|
|
21
|
+
* Gating:
|
|
22
|
+
* - `isWorkerFontMetricsEnabled()` is checked on every enqueue. If
|
|
23
|
+
* the flag is OFF, the function is a no-op and no worker is ever
|
|
24
|
+
* constructed.
|
|
25
|
+
* - `OffscreenCanvas` and `Worker` are feature-detected at first
|
|
26
|
+
* enqueue. Missing either disables the proxy for the session.
|
|
27
|
+
* - Any worker construction or message-port error disables the proxy
|
|
28
|
+
* for the session; subsequent enqueues are no-ops.
|
|
29
|
+
*
|
|
30
|
+
* Tests inject a fake transport via `__setMeasureWorkerTransport`. In
|
|
31
|
+
* production the transport is `null` and the real `Worker` is
|
|
32
|
+
* constructed on demand.
|
|
33
|
+
*/
|
|
34
|
+
let injectedTransportFactory = null;
|
|
35
|
+
/**
|
|
36
|
+
* Test-only: inject a transport factory in place of the real `Worker`
|
|
37
|
+
* constructor. Pass `null` to restore production behaviour.
|
|
38
|
+
*/
|
|
39
|
+
function __setMeasureWorkerTransport(factory) {
|
|
40
|
+
injectedTransportFactory = factory;
|
|
41
|
+
disposeProxy();
|
|
42
|
+
isDead = false;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* True when the host environment exposes both `Worker` and
|
|
46
|
+
* `OffscreenCanvas`. Older Safari, jsdom, SSR, and bun:test (without a
|
|
47
|
+
* DOM shim) all return `false` and route to the main-thread fallback.
|
|
48
|
+
*
|
|
49
|
+
* Detection is intentionally cheap and re-runnable — tests reset
|
|
50
|
+
* globals between cases.
|
|
51
|
+
*/
|
|
52
|
+
function isWorkerMeasurementSupported() {
|
|
53
|
+
if (injectedTransportFactory !== null) return true;
|
|
54
|
+
return typeof Worker !== "undefined" && typeof OffscreenCanvas !== "undefined" && typeof URL !== "undefined";
|
|
55
|
+
}
|
|
56
|
+
let state = null;
|
|
57
|
+
let isDead = false;
|
|
58
|
+
/**
|
|
59
|
+
* Dispose any live worker, reset queue. Idempotent. Called when the
|
|
60
|
+
* worker reports an unrecoverable error or when tests swap transports.
|
|
61
|
+
*/
|
|
62
|
+
function disposeProxy(unrecoverable = false) {
|
|
63
|
+
if (state === null) {
|
|
64
|
+
if (unrecoverable) isDead = true;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
state.dead = true;
|
|
68
|
+
if (state.flushTimer !== null) clearTimeout(state.flushTimer);
|
|
69
|
+
try {
|
|
70
|
+
state.transport.terminate();
|
|
71
|
+
} catch {}
|
|
72
|
+
state = null;
|
|
73
|
+
if (unrecoverable) isDead = true;
|
|
74
|
+
}
|
|
75
|
+
function makeKey(text, fontCacheKey, letterSpacing) {
|
|
76
|
+
return `${text}|${fontCacheKey}|${letterSpacing}`;
|
|
77
|
+
}
|
|
78
|
+
function createTransport() {
|
|
79
|
+
if (injectedTransportFactory !== null) try {
|
|
80
|
+
return injectedTransportFactory();
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
return new Worker(new URL("font-metrics.worker.ts", import.meta.url), { type: "module" });
|
|
86
|
+
} catch {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function ensureProxy() {
|
|
91
|
+
if (isDead) return null;
|
|
92
|
+
if (state !== null) return state.dead ? null : state;
|
|
93
|
+
if (!isWorkerMeasurementSupported()) {
|
|
94
|
+
isDead = true;
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
const transport = createTransport();
|
|
98
|
+
if (transport === null) {
|
|
99
|
+
isDead = true;
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const next = {
|
|
103
|
+
transport,
|
|
104
|
+
pending: /* @__PURE__ */ new Map(),
|
|
105
|
+
inFlightGenerations: /* @__PURE__ */ new Map(),
|
|
106
|
+
flushTimer: null,
|
|
107
|
+
nextRequestId: 0,
|
|
108
|
+
dead: false
|
|
109
|
+
};
|
|
110
|
+
transport.addEventListener("message", (event) => {
|
|
111
|
+
handleResponse(next, event.data);
|
|
112
|
+
});
|
|
113
|
+
transport.addEventListener("error", () => {
|
|
114
|
+
disposeProxy(true);
|
|
115
|
+
});
|
|
116
|
+
state = next;
|
|
117
|
+
return state;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* How long to wait before flushing the queue, in milliseconds. Short
|
|
121
|
+
* enough to keep the worker warm and ahead of the binary-search probes,
|
|
122
|
+
* long enough to amortise `postMessage` overhead across a typical
|
|
123
|
+
* paragraph's worth of probes.
|
|
124
|
+
*/
|
|
125
|
+
const FLUSH_INTERVAL_MS = 10;
|
|
126
|
+
/**
|
|
127
|
+
* Cap on entries per round trip. Prevents one runaway paragraph (think
|
|
128
|
+
* an unbroken 200 KB CDATA dump from a paste) from monopolising a
|
|
129
|
+
* single message. Excess entries flush on the next tick.
|
|
130
|
+
*/
|
|
131
|
+
const MAX_BATCH_SIZE = 256;
|
|
132
|
+
function scheduleFlush(current) {
|
|
133
|
+
if (current.flushTimer !== null) return;
|
|
134
|
+
current.flushTimer = setTimeout(() => {
|
|
135
|
+
current.flushTimer = null;
|
|
136
|
+
flush(current);
|
|
137
|
+
}, FLUSH_INTERVAL_MS);
|
|
138
|
+
}
|
|
139
|
+
function flush(current) {
|
|
140
|
+
if (current.pending.size === 0 || current.dead) return;
|
|
141
|
+
const cacheGeneration = getTextWidthCacheGeneration();
|
|
142
|
+
const entries = [];
|
|
143
|
+
for (const entry of current.pending.values()) {
|
|
144
|
+
if (entries.length >= MAX_BATCH_SIZE) break;
|
|
145
|
+
current.pending.delete(makeKey(entry.text, entry.fontCacheKey, entry.letterSpacing));
|
|
146
|
+
if (entry.cacheGeneration !== cacheGeneration) continue;
|
|
147
|
+
entries.push({
|
|
148
|
+
text: entry.text,
|
|
149
|
+
font: entry.font,
|
|
150
|
+
fontCacheKey: entry.fontCacheKey,
|
|
151
|
+
fontFingerprintWidth: entry.fontFingerprintWidth,
|
|
152
|
+
letterSpacing: entry.letterSpacing,
|
|
153
|
+
horizontalScale: entry.horizontalScale
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (entries.length === 0) {
|
|
157
|
+
if (current.pending.size > 0) scheduleFlush(current);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const id = current.nextRequestId;
|
|
161
|
+
current.nextRequestId += 1;
|
|
162
|
+
current.inFlightGenerations.set(id, cacheGeneration);
|
|
163
|
+
try {
|
|
164
|
+
current.transport.postMessage({
|
|
165
|
+
type: "measure",
|
|
166
|
+
id,
|
|
167
|
+
entries
|
|
168
|
+
});
|
|
169
|
+
} catch {
|
|
170
|
+
current.inFlightGenerations.delete(id);
|
|
171
|
+
disposeProxy(true);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (current.pending.size > 0) scheduleFlush(current);
|
|
175
|
+
}
|
|
176
|
+
function handleResponse(current, message) {
|
|
177
|
+
if (state !== current || current.dead) return;
|
|
178
|
+
const requestGeneration = current.inFlightGenerations.get(message.id);
|
|
179
|
+
current.inFlightGenerations.delete(message.id);
|
|
180
|
+
if (requestGeneration === void 0) return;
|
|
181
|
+
if (!message.ok) {
|
|
182
|
+
disposeProxy(true);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (requestGeneration !== getTextWidthCacheGeneration()) return;
|
|
186
|
+
for (const entry of message.entries) setCachedTextWidth(entry.text, entry.fontCacheKey, entry.letterSpacing, entry.width);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Enqueue a measurement for asynchronous pre-warming. Returns
|
|
190
|
+
* immediately. The caller has already filled the cache synchronously
|
|
191
|
+
* for the *current* probe; this prefetch is only useful for *future*
|
|
192
|
+
* probes (re-layouts triggered by font-ready, page-resize, or
|
|
193
|
+
* suggestion-mode toggles, which all re-measure the same runs).
|
|
194
|
+
*
|
|
195
|
+
* No-op when the feature flag is OFF, when the host lacks
|
|
196
|
+
* `OffscreenCanvas`/`Worker`, or when the proxy has been disabled by
|
|
197
|
+
* a previous error.
|
|
198
|
+
*/
|
|
199
|
+
function prefetchMeasurement(text, font, letterSpacing, horizontalScale, fontCacheKey, fontFingerprintWidth) {
|
|
200
|
+
if (!isWorkerFontMetricsEnabled()) return;
|
|
201
|
+
if (!text) return;
|
|
202
|
+
const current = ensureProxy();
|
|
203
|
+
if (current === null) return;
|
|
204
|
+
const key = makeKey(text, fontCacheKey, letterSpacing);
|
|
205
|
+
if (current.pending.has(key)) return;
|
|
206
|
+
current.pending.set(key, {
|
|
207
|
+
text,
|
|
208
|
+
font,
|
|
209
|
+
fontCacheKey,
|
|
210
|
+
fontFingerprintWidth,
|
|
211
|
+
letterSpacing,
|
|
212
|
+
horizontalScale,
|
|
213
|
+
cacheGeneration: getTextWidthCacheGeneration()
|
|
214
|
+
});
|
|
215
|
+
scheduleFlush(current);
|
|
216
|
+
}
|
|
217
|
+
function canPrefetchMeasurement() {
|
|
218
|
+
return isWorkerFontMetricsEnabled() && !isDead && isWorkerMeasurementSupported();
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Test-only: synchronously drain the pending queue. The caller is
|
|
222
|
+
* expected to have already attached its assertions to the cache or to
|
|
223
|
+
* the injected transport.
|
|
224
|
+
*/
|
|
225
|
+
function __flushMeasureQueueForTests() {
|
|
226
|
+
if (state === null) return;
|
|
227
|
+
if (state.flushTimer !== null) {
|
|
228
|
+
clearTimeout(state.flushTimer);
|
|
229
|
+
state.flushTimer = null;
|
|
230
|
+
}
|
|
231
|
+
flush(state);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Test-only: dispose the proxy. Safe to call when nothing is live.
|
|
235
|
+
*/
|
|
236
|
+
function __disposeMeasureProxyForTests() {
|
|
237
|
+
disposeProxy();
|
|
238
|
+
isDead = false;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Test-only: report whether the proxy considers itself alive. Useful
|
|
242
|
+
* for asserting that flag/feature-detection gating actually short-
|
|
243
|
+
* circuits worker construction.
|
|
244
|
+
*/
|
|
245
|
+
function __isMeasureProxyLiveForTests() {
|
|
246
|
+
return state !== null && !state.dead;
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
export { __disposeMeasureProxyForTests, __flushMeasureQueueForTests, __isMeasureProxyLiveForTests, __setMeasureWorkerTransport, canPrefetchMeasurement, prefetchMeasurement };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/measureWorkerProtocol.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Wire format shared between the main-thread proxy
|
|
4
|
+
* (`measureWorker.ts`) and the worker entry
|
|
5
|
+
* (`font-metrics.worker.ts`).
|
|
6
|
+
*
|
|
7
|
+
* The protocol is intentionally minimal: a batched request carrying an
|
|
8
|
+
* array of measurement inputs, and a matching response with widths in
|
|
9
|
+
* the same order. The worker is a pure function — no state, no cache.
|
|
10
|
+
* The main thread owns the LRU cache and is the sole authority on what
|
|
11
|
+
* is worth measuring.
|
|
12
|
+
*
|
|
13
|
+
* Keep this file tiny and dependency-free so it can be imported from
|
|
14
|
+
* both contexts.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Single measurement request inside a batch. Mirrors the inputs that
|
|
18
|
+
* `measureTextWidth` already takes on the main thread.
|
|
19
|
+
*
|
|
20
|
+
* `font` is the already-built CSS font string (output of
|
|
21
|
+
* `buildFontString`) so the worker does not need to know about the font
|
|
22
|
+
* resolver or `FontStyle` shape.
|
|
23
|
+
*
|
|
24
|
+
* `horizontalScale` is the multiplier (1.0 = 100 %), so the worker can
|
|
25
|
+
* apply it after the canvas measurement and return the final width.
|
|
26
|
+
*
|
|
27
|
+
* `fontCacheKey` is the main-thread cache identity. It intentionally
|
|
28
|
+
* differs from `font` when scale metadata is appended.
|
|
29
|
+
*
|
|
30
|
+
* `fontFingerprintWidth` is the main-thread width for
|
|
31
|
+
* `WORKER_FONT_FINGERPRINT_TEXT` in the same `font`. The worker checks
|
|
32
|
+
* the same sentinel before measuring and skips entries whose font
|
|
33
|
+
* metrics do not match, which prevents worker fallback fonts from
|
|
34
|
+
* poisoning the main-thread cache.
|
|
35
|
+
*/
|
|
36
|
+
type MeasureRequestEntry = {
|
|
37
|
+
text: string;
|
|
38
|
+
font: string;
|
|
39
|
+
fontCacheKey: string;
|
|
40
|
+
fontFingerprintWidth: number;
|
|
41
|
+
letterSpacing: number;
|
|
42
|
+
horizontalScale: number;
|
|
43
|
+
};
|
|
44
|
+
declare const WORKER_FONT_FINGERPRINT_TEXT = "HAMBURGEFONTS ivwqy 0123456789";
|
|
45
|
+
/**
|
|
46
|
+
* Count whole code points (not UTF-16 units) so letter spacing is applied once
|
|
47
|
+
* per rendered glyph — an astral character is one glyph spanning two units.
|
|
48
|
+
* Shared by the main thread (`measureContainer`) and the worker so their cached
|
|
49
|
+
* widths agree on astral text with letter spacing. Allocation-free.
|
|
50
|
+
*/
|
|
51
|
+
declare function countCodePoints(text: string): number;
|
|
52
|
+
/**
|
|
53
|
+
* Worker → main response for a single entry. Echoes the input keys the
|
|
54
|
+
* proxy needs in order to look up the right cache slot.
|
|
55
|
+
*/
|
|
56
|
+
type MeasureResponseEntry = {
|
|
57
|
+
text: string;
|
|
58
|
+
fontCacheKey: string;
|
|
59
|
+
letterSpacing: number;
|
|
60
|
+
width: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* `main → worker` message. `id` lets the proxy reject stale batches if
|
|
64
|
+
* the worker is replaced mid-flight.
|
|
65
|
+
*/
|
|
66
|
+
type MeasureWorkerRequest = {
|
|
67
|
+
type: "measure";
|
|
68
|
+
id: number;
|
|
69
|
+
entries: readonly MeasureRequestEntry[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* `worker → main` message. `ok: false` means the worker hit an
|
|
73
|
+
* unrecoverable error (e.g., no `OffscreenCanvas` after all); the proxy
|
|
74
|
+
* disables itself for the session.
|
|
75
|
+
*/
|
|
76
|
+
type MeasureWorkerResponse = {
|
|
77
|
+
type: "measure-result";
|
|
78
|
+
id: number;
|
|
79
|
+
ok: true;
|
|
80
|
+
entries: readonly MeasureResponseEntry[];
|
|
81
|
+
} | {
|
|
82
|
+
type: "measure-result";
|
|
83
|
+
id: number;
|
|
84
|
+
ok: false;
|
|
85
|
+
error: string;
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { MeasureRequestEntry, MeasureResponseEntry, MeasureWorkerRequest, MeasureWorkerResponse, WORKER_FONT_FINGERPRINT_TEXT, countCodePoints };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/layout-engine/measure/measureWorkerProtocol.ts
|
|
2
|
+
const WORKER_FONT_FINGERPRINT_TEXT = "HAMBURGEFONTS ivwqy 0123456789";
|
|
3
|
+
/**
|
|
4
|
+
* Count whole code points (not UTF-16 units) so letter spacing is applied once
|
|
5
|
+
* per rendered glyph — an astral character is one glyph spanning two units.
|
|
6
|
+
* Shared by the main thread (`measureContainer`) and the worker so their cached
|
|
7
|
+
* widths agree on astral text with letter spacing. Allocation-free.
|
|
8
|
+
*/
|
|
9
|
+
function countCodePoints(text) {
|
|
10
|
+
let count = 0;
|
|
11
|
+
let i = 0;
|
|
12
|
+
while (i < text.length) {
|
|
13
|
+
const code = text.codePointAt(i);
|
|
14
|
+
i += code !== void 0 && code > 65535 ? 2 : 1;
|
|
15
|
+
count += 1;
|
|
16
|
+
}
|
|
17
|
+
return count;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { WORKER_FONT_FINGERPRINT_TEXT, countCodePoints };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TableCell, TableCellMeasure } from "../types.js";
|
|
2
|
+
import { FloatingImageZone } from "./floatingZones.js";
|
|
3
|
+
|
|
4
|
+
//#region src/layout-engine/measure/tableCellFloating.d.ts
|
|
5
|
+
type TableCellFloatingImage = {
|
|
6
|
+
src: string;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
alt?: string;
|
|
10
|
+
transform?: string;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
side: "left" | "right";
|
|
14
|
+
distTop: number;
|
|
15
|
+
distBottom: number;
|
|
16
|
+
distLeft: number;
|
|
17
|
+
distRight: number;
|
|
18
|
+
wrapText?: "bothSides" | "left" | "right" | "largest";
|
|
19
|
+
pmStart?: number;
|
|
20
|
+
pmEnd?: number;
|
|
21
|
+
};
|
|
22
|
+
declare function getTableCellContentWidth(cell: TableCell | undefined, cellMeasure: TableCellMeasure): number;
|
|
23
|
+
declare function getTableCellFloatingImages(cell: TableCell, cellMeasure: TableCellMeasure, contentWidth: number): TableCellFloatingImage[];
|
|
24
|
+
declare function buildTableCellFloatingZones(floatingImages: TableCellFloatingImage[], contentWidth: number): FloatingImageZone[];
|
|
25
|
+
//#endregion
|
|
26
|
+
export { TableCellFloatingImage, buildTableCellFloatingZones, getTableCellContentWidth, getTableCellFloatingImages };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { emuToPixels } from "../../utils/units.js";
|
|
2
|
+
import { isFloatingImageRun } from "../types.js";
|
|
3
|
+
import { clampFloatingWrapMargins } from "./clampFloatingWrapMargins.js";
|
|
4
|
+
//#region src/layout-engine/measure/tableCellFloating.ts
|
|
5
|
+
function getTableCellContentWidth(cell, cellMeasure) {
|
|
6
|
+
const padLeft = cell?.padding?.left ?? 7;
|
|
7
|
+
const padRight = cell?.padding?.right ?? 7;
|
|
8
|
+
return Math.max(0, cellMeasure.width - padLeft - padRight);
|
|
9
|
+
}
|
|
10
|
+
function getTableCellFloatingImages(cell, cellMeasure, contentWidth) {
|
|
11
|
+
const result = [];
|
|
12
|
+
let paragraphY = 0;
|
|
13
|
+
for (let blockIndex = 0; blockIndex < cell.blocks.length; blockIndex++) {
|
|
14
|
+
const block = cell.blocks[blockIndex];
|
|
15
|
+
if (block?.kind !== "paragraph") {
|
|
16
|
+
const blockMeasure = cellMeasure.blocks[blockIndex];
|
|
17
|
+
if (blockMeasure?.kind === "table") paragraphY += blockMeasure.totalHeight;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
for (const run of block.runs) {
|
|
21
|
+
if (run.kind !== "image" || !isFloatingImageRun(run)) continue;
|
|
22
|
+
const position = run.position;
|
|
23
|
+
const distTop = run.distTop ?? 0;
|
|
24
|
+
const distBottom = run.distBottom ?? 0;
|
|
25
|
+
const distLeft = run.distLeft ?? 12;
|
|
26
|
+
const distRight = run.distRight ?? 12;
|
|
27
|
+
let side = "left";
|
|
28
|
+
let x = 0;
|
|
29
|
+
if (position?.horizontal) {
|
|
30
|
+
const horizontal = position.horizontal;
|
|
31
|
+
if (horizontal.align === "right") {
|
|
32
|
+
side = "right";
|
|
33
|
+
x = contentWidth - run.width;
|
|
34
|
+
} else if (horizontal.align === "left") x = 0;
|
|
35
|
+
else if (horizontal.align === "center") x = (contentWidth - run.width) / 2;
|
|
36
|
+
else if (horizontal.posOffset !== void 0) {
|
|
37
|
+
x = emuToPixels(horizontal.posOffset);
|
|
38
|
+
side = x > contentWidth / 2 ? "right" : "left";
|
|
39
|
+
}
|
|
40
|
+
} else if (run.cssFloat === "right") {
|
|
41
|
+
side = "right";
|
|
42
|
+
x = contentWidth - run.width;
|
|
43
|
+
}
|
|
44
|
+
let y = paragraphY;
|
|
45
|
+
if (position?.vertical) {
|
|
46
|
+
const vertical = position.vertical;
|
|
47
|
+
if (vertical.posOffset !== void 0) y = paragraphY + emuToPixels(vertical.posOffset);
|
|
48
|
+
else if (vertical.align === "top") y = 0;
|
|
49
|
+
}
|
|
50
|
+
x = Math.max(0, Math.min(x, contentWidth - run.width));
|
|
51
|
+
let wrapText = "bothSides";
|
|
52
|
+
if (run.cssFloat === "left") wrapText = "right";
|
|
53
|
+
else if (run.cssFloat === "right") wrapText = "left";
|
|
54
|
+
result.push({
|
|
55
|
+
src: run.src,
|
|
56
|
+
width: run.width,
|
|
57
|
+
height: run.height,
|
|
58
|
+
...run.alt !== void 0 ? { alt: run.alt } : {},
|
|
59
|
+
...run.transform !== void 0 ? { transform: run.transform } : {},
|
|
60
|
+
x,
|
|
61
|
+
y,
|
|
62
|
+
side,
|
|
63
|
+
distTop,
|
|
64
|
+
distBottom,
|
|
65
|
+
distLeft,
|
|
66
|
+
distRight,
|
|
67
|
+
wrapText,
|
|
68
|
+
...run.pmStart !== void 0 ? { pmStart: run.pmStart } : {},
|
|
69
|
+
...run.pmEnd !== void 0 ? { pmEnd: run.pmEnd } : {}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const blockMeasure = cellMeasure.blocks[blockIndex];
|
|
73
|
+
if (blockMeasure?.kind === "paragraph") paragraphY += blockMeasure.totalHeight;
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
function buildTableCellFloatingZones(floatingImages, contentWidth) {
|
|
78
|
+
return floatingImages.map((img) => {
|
|
79
|
+
const rectRight = img.x + img.width + img.distRight;
|
|
80
|
+
const rectTop = img.y - img.distTop;
|
|
81
|
+
const rectBottom = img.y + img.height + img.distBottom;
|
|
82
|
+
let leftMargin = 0;
|
|
83
|
+
let rightMargin = 0;
|
|
84
|
+
const wrapText = img.wrapText ?? "bothSides";
|
|
85
|
+
if (wrapText === "right") leftMargin = rectRight;
|
|
86
|
+
else if (wrapText === "left") rightMargin = contentWidth - (img.x - img.distLeft);
|
|
87
|
+
else if (img.side === "left") leftMargin = rectRight;
|
|
88
|
+
else rightMargin = contentWidth - (img.x - img.distLeft);
|
|
89
|
+
const clamped = clampFloatingWrapMargins(leftMargin, rightMargin, contentWidth);
|
|
90
|
+
return {
|
|
91
|
+
leftMargin: clamped.leftMargin,
|
|
92
|
+
rightMargin: clamped.rightMargin,
|
|
93
|
+
topY: rectTop,
|
|
94
|
+
bottomY: rectBottom
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
export { buildTableCellFloatingZones, getTableCellContentWidth, getTableCellFloatingImages };
|