react-cheminfo 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -28
- package/lib/chrome/ui/HeaderToggle.d.ts +52 -0
- package/lib/chrome/ui/HeaderToggle.d.ts.map +1 -0
- package/lib/chrome/ui/HeaderToggle.js +31 -0
- package/lib/chrome/ui/HeaderToggle.js.map +1 -0
- package/lib/chrome/ui/index.d.ts +2 -0
- package/lib/chrome/ui/index.d.ts.map +1 -1
- package/lib/chrome/ui/index.js +1 -0
- package/lib/chrome/ui/index.js.map +1 -1
- package/lib/citation/core/gfn2Paper.d.ts +10 -0
- package/lib/citation/core/gfn2Paper.d.ts.map +1 -0
- package/lib/citation/core/gfn2Paper.js +28 -0
- package/lib/citation/core/gfn2Paper.js.map +1 -0
- package/lib/citation/core/index.d.ts +1 -0
- package/lib/citation/core/index.d.ts.map +1 -1
- package/lib/citation/core/index.js +1 -0
- package/lib/citation/core/index.js.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.d.ts +8 -7
- package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
- package/lib/clipboard/ui/ClickToCopy.js +3 -3
- package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
- package/lib/conformers.d.ts +27 -0
- package/lib/conformers.d.ts.map +1 -0
- package/lib/conformers.js +19 -0
- package/lib/conformers.js.map +1 -0
- package/lib/core.d.ts +1 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +1 -0
- package/lib/core.js.map +1 -1
- package/lib/credits/core/credits.d.ts +12 -0
- package/lib/credits/core/credits.d.ts.map +1 -1
- package/lib/credits/core/credits.js +14 -0
- package/lib/credits/core/credits.js.map +1 -1
- package/lib/ecosystem/core/index.d.ts +1 -1
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts +11 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +7 -2
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.d.ts.map +1 -1
- package/lib/ecosystem/ui/EcosystemLinks.js +3 -1
- package/lib/ecosystem/ui/EcosystemLinks.js.map +1 -1
- package/lib/ecosystem/ui/SiteTile.d.ts.map +1 -1
- package/lib/ecosystem/ui/SiteTile.js +3 -1
- package/lib/ecosystem/ui/SiteTile.js.map +1 -1
- package/lib/format/core/index.d.ts +1 -1
- package/lib/format/core/index.d.ts.map +1 -1
- package/lib/format/core/index.js +1 -1
- package/lib/format/core/index.js.map +1 -1
- package/lib/format/core/words.d.ts +9 -0
- package/lib/format/core/words.d.ts.map +1 -1
- package/lib/format/core/words.js +16 -0
- package/lib/format/core/words.js.map +1 -1
- package/lib/language/core/index.d.ts +3 -0
- package/lib/language/core/index.d.ts.map +1 -0
- package/lib/language/core/index.js +3 -0
- package/lib/language/core/index.js.map +1 -0
- package/lib/language/core/languageName.d.ts +8 -0
- package/lib/language/core/languageName.d.ts.map +1 -0
- package/lib/language/core/languageName.js +16 -0
- package/lib/language/core/languageName.js.map +1 -0
- package/lib/language/core/languageParam.d.ts +35 -0
- package/lib/language/core/languageParam.d.ts.map +1 -0
- package/lib/language/core/languageParam.js +67 -0
- package/lib/language/core/languageParam.js.map +1 -0
- package/lib/language/ui/SiteLanguage.d.ts +20 -0
- package/lib/language/ui/SiteLanguage.d.ts.map +1 -0
- package/lib/language/ui/SiteLanguage.js +14 -0
- package/lib/language/ui/SiteLanguage.js.map +1 -0
- package/lib/language/ui/index.d.ts +4 -0
- package/lib/language/ui/index.d.ts.map +1 -0
- package/lib/language/ui/index.js +3 -0
- package/lib/language/ui/index.js.map +1 -0
- package/lib/language/ui/siteLanguageContext.d.ts +12 -0
- package/lib/language/ui/siteLanguageContext.d.ts.map +1 -0
- package/lib/language/ui/siteLanguageContext.js +19 -0
- package/lib/language/ui/siteLanguageContext.js.map +1 -0
- package/lib/orbital/core/atomicOrbitals.d.ts +9 -1
- package/lib/orbital/core/atomicOrbitals.d.ts.map +1 -1
- package/lib/orbital/core/atomicOrbitals.js +7 -0
- package/lib/orbital/core/atomicOrbitals.js.map +1 -1
- package/lib/orbital/core/hydrogenic.d.ts +2 -1
- package/lib/orbital/core/hydrogenic.d.ts.map +1 -1
- package/lib/orbital/core/hydrogenic.js +2 -1
- package/lib/orbital/core/hydrogenic.js.map +1 -1
- package/lib/orbital/core/index.d.ts +1 -0
- package/lib/orbital/core/index.d.ts.map +1 -1
- package/lib/orbital/core/index.js +1 -0
- package/lib/orbital/core/index.js.map +1 -1
- package/lib/orbital/core/slaterEnergy.d.ts +35 -0
- package/lib/orbital/core/slaterEnergy.d.ts.map +1 -0
- package/lib/orbital/core/slaterEnergy.js +66 -0
- package/lib/orbital/core/slaterEnergy.js.map +1 -0
- package/lib/overlay/core/index.d.ts +2 -2
- package/lib/overlay/core/index.d.ts.map +1 -1
- package/lib/overlay/core/index.js +1 -1
- package/lib/overlay/core/index.js.map +1 -1
- package/lib/overlay/core/overlayMarks.d.ts +20 -5
- package/lib/overlay/core/overlayMarks.d.ts.map +1 -1
- package/lib/overlay/core/overlayMarks.js +31 -5
- package/lib/overlay/core/overlayMarks.js.map +1 -1
- package/lib/overlay/ui/OverlayLegendMark.js +5 -0
- package/lib/overlay/ui/OverlayLegendMark.js.map +1 -1
- package/lib/projection/core/index.d.ts +4 -4
- package/lib/projection/core/index.d.ts.map +1 -1
- package/lib/projection/core/index.js +2 -2
- package/lib/projection/core/index.js.map +1 -1
- package/lib/projection/core/projectionCopy.d.ts +2 -0
- package/lib/projection/core/projectionCopy.d.ts.map +1 -1
- package/lib/projection/core/projectionCopy.js +1 -0
- package/lib/projection/core/projectionCopy.js.map +1 -1
- package/lib/projection/core/projectionGroupings.d.ts +44 -0
- package/lib/projection/core/projectionGroupings.d.ts.map +1 -0
- package/lib/projection/core/projectionGroupings.js +132 -0
- package/lib/projection/core/projectionGroupings.js.map +1 -0
- package/lib/projection/core/projectionOptions.d.ts +16 -6
- package/lib/projection/core/projectionOptions.d.ts.map +1 -1
- package/lib/projection/core/projectionOptions.js +7 -1
- package/lib/projection/core/projectionOptions.js.map +1 -1
- package/lib/projection/core/projectionPanelWords.d.ts +6 -0
- package/lib/projection/core/projectionPanelWords.d.ts.map +1 -1
- package/lib/projection/core/projectionPanelWords.js +4 -0
- package/lib/projection/core/projectionPanelWords.js.map +1 -1
- package/lib/projection/core/projectionSamples.d.ts +63 -32
- package/lib/projection/core/projectionSamples.d.ts.map +1 -1
- package/lib/projection/core/projectionSamples.js +1 -80
- package/lib/projection/core/projectionSamples.js.map +1 -1
- package/lib/projection/core/projectionStrings.d.ts +2 -0
- package/lib/projection/core/projectionStrings.d.ts.map +1 -1
- package/lib/projection/core/projectionStrings.js +10 -1
- package/lib/projection/core/projectionStrings.js.map +1 -1
- package/lib/projection/core/resolveProjectionOptions.d.ts +8 -3
- package/lib/projection/core/resolveProjectionOptions.d.ts.map +1 -1
- package/lib/projection/core/resolveProjectionOptions.js +58 -5
- package/lib/projection/core/resolveProjectionOptions.js.map +1 -1
- package/lib/projection/ui/ProjectionBar.d.ts +1 -1
- package/lib/projection/ui/ProjectionBar.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionBar.js +3 -1
- package/lib/projection/ui/ProjectionBar.js.map +1 -1
- package/lib/projection/ui/ProjectionGroupingPickers.d.ts +38 -0
- package/lib/projection/ui/ProjectionGroupingPickers.d.ts.map +1 -0
- package/lib/projection/ui/ProjectionGroupingPickers.js +33 -0
- package/lib/projection/ui/ProjectionGroupingPickers.js.map +1 -0
- package/lib/projection/ui/ProjectionMapControls.d.ts +6 -7
- package/lib/projection/ui/ProjectionMapControls.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionMapControls.js +11 -9
- package/lib/projection/ui/ProjectionMapControls.js.map +1 -1
- package/lib/projection/ui/ProjectionMapLegend.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionMapLegend.js +1 -1
- package/lib/projection/ui/ProjectionMapLegend.js.map +1 -1
- package/lib/projection/ui/ProjectionMapMore.d.ts +2 -2
- package/lib/projection/ui/ProjectionMapMore.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionMapMore.js +7 -5
- package/lib/projection/ui/ProjectionMapMore.js.map +1 -1
- package/lib/projection/ui/ProjectionMapTab.d.ts +15 -6
- package/lib/projection/ui/ProjectionMapTab.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionMapTab.js +11 -7
- package/lib/projection/ui/ProjectionMapTab.js.map +1 -1
- package/lib/projection/ui/ProjectionPairsMore.d.ts +3 -7
- package/lib/projection/ui/ProjectionPairsMore.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionPairsMore.js +4 -5
- package/lib/projection/ui/ProjectionPairsMore.js.map +1 -1
- package/lib/projection/ui/ProjectionPairsTab.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionPairsTab.js +2 -2
- package/lib/projection/ui/ProjectionPairsTab.js.map +1 -1
- package/lib/projection/ui/ProjectionPanel.d.ts +1 -1
- package/lib/projection/ui/ProjectionPanel.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionPanel.js +1 -1
- package/lib/projection/ui/ProjectionPanel.js.map +1 -1
- package/lib/projection/ui/ProjectionReadout.d.ts +7 -1
- package/lib/projection/ui/ProjectionReadout.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionReadout.js +19 -7
- package/lib/projection/ui/ProjectionReadout.js.map +1 -1
- package/lib/projection/ui/ProjectionSpaceControls.d.ts +3 -5
- package/lib/projection/ui/ProjectionSpaceControls.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionSpaceControls.js +9 -7
- package/lib/projection/ui/ProjectionSpaceControls.js.map +1 -1
- package/lib/projection/ui/ProjectionSpaceMore.d.ts +2 -2
- package/lib/projection/ui/ProjectionSpaceMore.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionSpaceMore.js +5 -4
- package/lib/projection/ui/ProjectionSpaceMore.js.map +1 -1
- package/lib/projection/ui/ProjectionSpaceTab.d.ts +11 -3
- package/lib/projection/ui/ProjectionSpaceTab.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionSpaceTab.js +7 -4
- package/lib/projection/ui/ProjectionSpaceTab.js.map +1 -1
- package/lib/projection/ui/ProjectionViewer.d.ts.map +1 -1
- package/lib/projection/ui/ProjectionViewer.js +1 -0
- package/lib/projection/ui/ProjectionViewer.js.map +1 -1
- package/lib/projection/ui/projectionBarReadings.d.ts +4 -1
- package/lib/projection/ui/projectionBarReadings.d.ts.map +1 -1
- package/lib/projection/ui/projectionBarReadings.js +14 -4
- package/lib/projection/ui/projectionBarReadings.js.map +1 -1
- package/lib/projection/ui/projectionBarSlots.d.ts +4 -2
- package/lib/projection/ui/projectionBarSlots.d.ts.map +1 -1
- package/lib/projection/ui/projectionBarSlots.js +3 -7
- package/lib/projection/ui/projectionBarSlots.js.map +1 -1
- package/lib/projection/ui/projectionMapChoices.d.ts +31 -6
- package/lib/projection/ui/projectionMapChoices.d.ts.map +1 -1
- package/lib/projection/ui/projectionMapChoices.js +58 -9
- package/lib/projection/ui/projectionMapChoices.js.map +1 -1
- package/lib/projection/ui/projectionMapChrome.d.ts +3 -9
- package/lib/projection/ui/projectionMapChrome.d.ts.map +1 -1
- package/lib/projection/ui/projectionMapChrome.js +41 -27
- package/lib/projection/ui/projectionMapChrome.js.map +1 -1
- package/lib/projection/ui/projectionMapCorner.d.ts +25 -0
- package/lib/projection/ui/projectionMapCorner.d.ts.map +1 -0
- package/lib/projection/ui/projectionMapCorner.js +46 -0
- package/lib/projection/ui/projectionMapCorner.js.map +1 -0
- package/lib/projection/ui/projectionMapModel.d.ts +9 -18
- package/lib/projection/ui/projectionMapModel.d.ts.map +1 -1
- package/lib/projection/ui/projectionMapModel.js +14 -39
- package/lib/projection/ui/projectionMapModel.js.map +1 -1
- package/lib/projection/ui/projectionMapView.d.ts +3 -1
- package/lib/projection/ui/projectionMapView.d.ts.map +1 -1
- package/lib/projection/ui/projectionMapView.js +9 -4
- package/lib/projection/ui/projectionMapView.js.map +1 -1
- package/lib/projection/ui/projectionSelectionSentence.d.ts +10 -0
- package/lib/projection/ui/projectionSelectionSentence.d.ts.map +1 -0
- package/lib/projection/ui/projectionSelectionSentence.js +18 -0
- package/lib/projection/ui/projectionSelectionSentence.js.map +1 -0
- package/lib/projection/ui/projectionStateApi.d.ts +47 -0
- package/lib/projection/ui/projectionStateApi.d.ts.map +1 -0
- package/lib/projection/ui/projectionStateApi.js +9 -0
- package/lib/projection/ui/projectionStateApi.js.map +1 -0
- package/lib/projection/ui/projectionTabModels.js +1 -1
- package/lib/projection/ui/projectionTabModels.js.map +1 -1
- package/lib/projection/ui/useProjectionState.d.ts +1 -29
- package/lib/projection/ui/useProjectionState.d.ts.map +1 -1
- package/lib/projection/ui/useProjectionState.js +13 -5
- package/lib/projection/ui/useProjectionState.js.map +1 -1
- package/lib/scatter/core/index.d.ts +1 -0
- package/lib/scatter/core/index.d.ts.map +1 -1
- package/lib/scatter/core/index.js +1 -0
- package/lib/scatter/core/index.js.map +1 -1
- package/lib/scatter/core/pointShape.d.ts +18 -0
- package/lib/scatter/core/pointShape.d.ts.map +1 -0
- package/lib/scatter/core/pointShape.js +70 -0
- package/lib/scatter/core/pointShape.js.map +1 -0
- package/lib/scatter/ui/ScatterPlot.d.ts.map +1 -1
- package/lib/scatter/ui/ScatterPlot.js +3 -2
- package/lib/scatter/ui/ScatterPlot.js.map +1 -1
- package/lib/scatter/ui/ScatterPointLayer.d.ts +14 -1
- package/lib/scatter/ui/ScatterPointLayer.d.ts.map +1 -1
- package/lib/scatter/ui/ScatterPointLayer.js +15 -3
- package/lib/scatter/ui/ScatterPointLayer.js.map +1 -1
- package/lib/scatter/ui/scatterFigureProps.d.ts +13 -0
- package/lib/scatter/ui/scatterFigureProps.d.ts.map +1 -1
- package/lib/scatter/ui/scatterMarkGlyph.d.ts +2 -1
- package/lib/scatter/ui/scatterMarkGlyph.d.ts.map +1 -1
- package/lib/scatter/ui/scatterMarkGlyph.js +7 -1
- package/lib/scatter/ui/scatterMarkGlyph.js.map +1 -1
- package/lib/scatter3d/ui/ScatterCloud.d.ts.map +1 -1
- package/lib/scatter3d/ui/ScatterCloud.js +2 -1
- package/lib/scatter3d/ui/ScatterCloud.js.map +1 -1
- package/lib/shared/ui/MenuButton.d.ts +3 -2
- package/lib/shared/ui/MenuButton.d.ts.map +1 -1
- package/lib/shared/ui/MenuButton.js +1 -1
- package/lib/shared/ui/MenuButton.js.map +1 -1
- package/lib/structure/core/conformerMinimise.d.ts +36 -0
- package/lib/structure/core/conformerMinimise.d.ts.map +1 -0
- package/lib/structure/core/conformerMinimise.js +81 -0
- package/lib/structure/core/conformerMinimise.js.map +1 -0
- package/lib/structure/core/conformerMinimum.d.ts +62 -0
- package/lib/structure/core/conformerMinimum.d.ts.map +1 -0
- package/lib/structure/core/conformerMinimum.js +90 -0
- package/lib/structure/core/conformerMinimum.js.map +1 -0
- package/lib/structure/core/conformerOptions.d.ts +62 -0
- package/lib/structure/core/conformerOptions.d.ts.map +1 -0
- package/lib/structure/core/conformerOptions.js +83 -0
- package/lib/structure/core/conformerOptions.js.map +1 -0
- package/lib/structure/core/conformerRefine.d.ts +104 -0
- package/lib/structure/core/conformerRefine.d.ts.map +1 -0
- package/lib/structure/core/conformerRefine.js +130 -0
- package/lib/structure/core/conformerRefine.js.map +1 -0
- package/lib/structure/core/conformerRefineRank.d.ts +36 -0
- package/lib/structure/core/conformerRefineRank.d.ts.map +1 -0
- package/lib/structure/core/conformerRefineRank.js +69 -0
- package/lib/structure/core/conformerRefineRank.js.map +1 -0
- package/lib/structure/core/conformerSession.d.ts +50 -0
- package/lib/structure/core/conformerSession.d.ts.map +1 -0
- package/lib/structure/core/conformerSession.js +88 -0
- package/lib/structure/core/conformerSession.js.map +1 -0
- package/lib/structure/core/conformerShape.d.ts +36 -0
- package/lib/structure/core/conformerShape.d.ts.map +1 -0
- package/lib/structure/core/conformerShape.js +150 -0
- package/lib/structure/core/conformerShape.js.map +1 -0
- package/lib/structure/core/conformers.d.ts +107 -0
- package/lib/structure/core/conformers.d.ts.map +1 -0
- package/lib/structure/core/conformers.js +149 -0
- package/lib/structure/core/conformers.js.map +1 -0
- package/lib/structure/core/geometryRelaxer.d.ts +66 -0
- package/lib/structure/core/geometryRelaxer.d.ts.map +1 -0
- package/lib/structure/core/geometryRelaxer.js +2 -0
- package/lib/structure/core/geometryRelaxer.js.map +1 -0
- package/lib/structure/core/index.d.ts +4 -0
- package/lib/structure/core/index.d.ts.map +1 -1
- package/lib/structure/core/index.js +2 -0
- package/lib/structure/core/index.js.map +1 -1
- package/lib/structure/core/moleculeCoordinates.d.ts +31 -0
- package/lib/structure/core/moleculeCoordinates.d.ts.map +1 -0
- package/lib/structure/core/moleculeCoordinates.js +80 -0
- package/lib/structure/core/moleculeCoordinates.js.map +1 -0
- package/lib/structure/core/molfileExport.d.ts +42 -0
- package/lib/structure/core/molfileExport.d.ts.map +1 -0
- package/lib/structure/core/molfileExport.js +47 -0
- package/lib/structure/core/molfileExport.js.map +1 -0
- package/lib/structure/core/oclResources.d.ts +12 -0
- package/lib/structure/core/oclResources.d.ts.map +1 -0
- package/lib/structure/core/oclResources.js +35 -0
- package/lib/structure/core/oclResources.js.map +1 -0
- package/lib/translate/core/catalog.d.ts +61 -0
- package/lib/translate/core/catalog.d.ts.map +1 -0
- package/lib/translate/core/catalog.js +49 -0
- package/lib/translate/core/catalog.js.map +1 -0
- package/lib/translate/core/checkTranslation.d.ts +32 -0
- package/lib/translate/core/checkTranslation.d.ts.map +1 -0
- package/lib/translate/core/checkTranslation.js +98 -0
- package/lib/translate/core/checkTranslation.js.map +1 -0
- package/lib/translate/core/contribution.d.ts +88 -0
- package/lib/translate/core/contribution.d.ts.map +1 -0
- package/lib/translate/core/contribution.js +14 -0
- package/lib/translate/core/contribution.js.map +1 -0
- package/lib/translate/core/index.d.ts +19 -0
- package/lib/translate/core/index.d.ts.map +1 -0
- package/lib/translate/core/index.js +15 -0
- package/lib/translate/core/index.js.map +1 -0
- package/lib/translate/core/marker.d.ts +45 -0
- package/lib/translate/core/marker.d.ts.map +1 -0
- package/lib/translate/core/marker.js +79 -0
- package/lib/translate/core/marker.js.map +1 -0
- package/lib/translate/core/mergeMessages.d.ts +35 -0
- package/lib/translate/core/mergeMessages.d.ts.map +1 -0
- package/lib/translate/core/mergeMessages.js +69 -0
- package/lib/translate/core/mergeMessages.js.map +1 -0
- package/lib/translate/core/session.d.ts +102 -0
- package/lib/translate/core/session.d.ts.map +1 -0
- package/lib/translate/core/session.js +162 -0
- package/lib/translate/core/session.js.map +1 -0
- package/lib/translate/core/start.d.ts +70 -0
- package/lib/translate/core/start.d.ts.map +1 -0
- package/lib/translate/core/start.js +73 -0
- package/lib/translate/core/start.js.map +1 -0
- package/lib/translate/core/suggestions.d.ts +77 -0
- package/lib/translate/core/suggestions.d.ts.map +1 -0
- package/lib/translate/core/suggestions.js +143 -0
- package/lib/translate/core/suggestions.js.map +1 -0
- package/lib/translate/core/tables.d.ts +100 -0
- package/lib/translate/core/tables.d.ts.map +1 -0
- package/lib/translate/core/tables.js +51 -0
- package/lib/translate/core/tables.js.map +1 -0
- package/lib/translate.d.ts +2 -0
- package/lib/translate.d.ts.map +1 -0
- package/lib/translate.js +6 -0
- package/lib/translate.js.map +1 -0
- package/lib/ui.d.ts +1 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +1 -0
- package/lib/ui.js.map +1 -1
- package/lib/xtb/core/xtbRelaxer.d.ts +61 -0
- package/lib/xtb/core/xtbRelaxer.d.ts.map +1 -0
- package/lib/xtb/core/xtbRelaxer.js +108 -0
- package/lib/xtb/core/xtbRelaxer.js.map +1 -0
- package/lib/xtb.d.ts +11 -0
- package/lib/xtb.d.ts.map +1 -0
- package/lib/xtb.js +10 -0
- package/lib/xtb.js.map +1 -0
- package/package.json +18 -11
- package/src/chrome/ui/HeaderToggle.tsx +100 -0
- package/src/chrome/ui/index.ts +2 -0
- package/src/citation/core/gfn2Paper.ts +32 -0
- package/src/citation/core/index.ts +1 -0
- package/src/clipboard/ui/ClickToCopy.tsx +8 -7
- package/src/conformers.ts +87 -0
- package/src/core.ts +1 -0
- package/src/credits/core/credits.ts +16 -0
- package/src/ecosystem/core/index.ts +1 -0
- package/src/ecosystem/core/sites.ts +20 -2
- package/src/ecosystem/ui/EcosystemLinks.tsx +3 -1
- package/src/ecosystem/ui/SiteTile.tsx +3 -1
- package/src/format/core/index.ts +1 -1
- package/src/format/core/words.ts +19 -0
- package/src/language/core/index.ts +7 -0
- package/src/language/core/languageName.ts +16 -0
- package/src/language/core/languageParam.ts +70 -0
- package/src/language/ui/SiteLanguage.tsx +26 -0
- package/src/language/ui/index.ts +3 -0
- package/src/language/ui/siteLanguageContext.ts +20 -0
- package/src/orbital/core/atomicOrbitals.ts +17 -1
- package/src/orbital/core/hydrogenic.ts +2 -1
- package/src/orbital/core/index.ts +1 -0
- package/src/orbital/core/slaterEnergy.ts +83 -0
- package/src/overlay/core/index.ts +6 -2
- package/src/overlay/core/overlayMarks.ts +51 -6
- package/src/overlay/ui/OverlayLegendMark.tsx +5 -0
- package/src/projection/core/index.ts +11 -3
- package/src/projection/core/projectionCopy.ts +3 -0
- package/src/projection/core/projectionGroupings.ts +174 -0
- package/src/projection/core/projectionOptions.ts +18 -7
- package/src/projection/core/projectionPanelWords.ts +10 -0
- package/src/projection/core/projectionSamples.ts +62 -120
- package/src/projection/core/projectionStrings.ts +12 -1
- package/src/projection/core/resolveProjectionOptions.ts +66 -4
- package/src/projection/ui/ProjectionBar.tsx +4 -2
- package/src/projection/ui/ProjectionGroupingPickers.tsx +91 -0
- package/src/projection/ui/ProjectionMapControls.tsx +29 -32
- package/src/projection/ui/ProjectionMapLegend.tsx +1 -1
- package/src/projection/ui/ProjectionMapMore.tsx +14 -4
- package/src/projection/ui/ProjectionMapTab.tsx +27 -9
- package/src/projection/ui/ProjectionPairsMore.tsx +12 -21
- package/src/projection/ui/ProjectionPairsTab.tsx +5 -2
- package/src/projection/ui/ProjectionPanel.tsx +7 -3
- package/src/projection/ui/ProjectionReadout.tsx +28 -8
- package/src/projection/ui/ProjectionSpaceControls.tsx +20 -27
- package/src/projection/ui/ProjectionSpaceMore.tsx +12 -3
- package/src/projection/ui/ProjectionSpaceTab.tsx +23 -6
- package/src/projection/ui/ProjectionViewer.tsx +1 -0
- package/src/projection/ui/projectionBarReadings.ts +24 -8
- package/src/projection/ui/projectionBarSlots.tsx +10 -9
- package/src/projection/ui/projectionMapChoices.ts +71 -14
- package/src/projection/ui/projectionMapChrome.ts +55 -30
- package/src/projection/ui/projectionMapCorner.ts +67 -0
- package/src/projection/ui/projectionMapModel.ts +20 -59
- package/src/projection/ui/projectionMapView.ts +15 -8
- package/src/projection/ui/projectionSelectionSentence.ts +22 -0
- package/src/projection/ui/projectionStateApi.ts +57 -0
- package/src/projection/ui/projectionTabModels.ts +1 -1
- package/src/projection/ui/useProjectionState.ts +33 -37
- package/src/scatter/core/index.ts +1 -0
- package/src/scatter/core/pointShape.ts +80 -0
- package/src/scatter/ui/ScatterPlot.tsx +4 -1
- package/src/scatter/ui/ScatterPointLayer.tsx +39 -11
- package/src/scatter/ui/scatterFigureProps.ts +13 -0
- package/src/scatter/ui/scatterMarkGlyph.tsx +9 -1
- package/src/scatter3d/ui/ScatterCloud.tsx +3 -0
- package/src/shared/ui/MenuButton.tsx +4 -3
- package/src/structure/core/conformerMinimise.ts +99 -0
- package/src/structure/core/conformerMinimum.ts +125 -0
- package/src/structure/core/conformerOptions.ts +125 -0
- package/src/structure/core/conformerRefine.ts +234 -0
- package/src/structure/core/conformerRefineRank.ts +89 -0
- package/src/structure/core/conformerSession.ts +123 -0
- package/src/structure/core/conformerShape.ts +181 -0
- package/src/structure/core/conformers.ts +282 -0
- package/src/structure/core/geometryRelaxer.ts +71 -0
- package/src/structure/core/index.ts +13 -0
- package/src/structure/core/moleculeCoordinates.ts +93 -0
- package/src/structure/core/molfileExport.ts +62 -0
- package/src/structure/core/oclResources.ts +41 -0
- package/src/translate/core/catalog.ts +83 -0
- package/src/translate/core/checkTranslation.ts +128 -0
- package/src/translate/core/contribution.ts +99 -0
- package/src/translate/core/index.ts +72 -0
- package/src/translate/core/marker.ts +85 -0
- package/src/translate/core/mergeMessages.ts +74 -0
- package/src/translate/core/session.ts +250 -0
- package/src/translate/core/start.ts +121 -0
- package/src/translate/core/suggestions.ts +211 -0
- package/src/translate/core/tables.ts +120 -0
- package/src/translate.ts +5 -0
- package/src/ui.ts +1 -0
- package/src/xtb/core/xtbRelaxer.ts +160 -0
- package/src/xtb.ts +16 -0
- package/styles/chrome.css +61 -30
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { CatalogSource, MessageRef, Messages } from './catalog.ts';
|
|
2
|
+
import type { TranslatableTable } from './tables.ts';
|
|
3
|
+
/** The values a message's placeholders are filled with. */
|
|
4
|
+
export type MessageValues = Record<string, string | number | Date>;
|
|
5
|
+
/** The version of the page ↔ overlay protocol this session speaks. */
|
|
6
|
+
export declare const BRIDGE_PROTOCOL = 2;
|
|
7
|
+
/** Where a page in translate mode exposes its session to the overlay. */
|
|
8
|
+
export declare const BRIDGE_GLOBAL = "__cheminfoTranslate";
|
|
9
|
+
/** A catalog as the overlay sees it: the source, what is published, the edits. */
|
|
10
|
+
export interface CatalogSnapshot extends CatalogSource {
|
|
11
|
+
/** The locale file as published with the site. */
|
|
12
|
+
translation: Messages;
|
|
13
|
+
/** The messages edited in the overlay and not yet submitted. */
|
|
14
|
+
drafts: Messages;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* What a page in translate mode offers the overlay. It is the only contract
|
|
18
|
+
* between the two, so an overlay released later still drives a page built
|
|
19
|
+
* earlier as long as the protocol number matches.
|
|
20
|
+
*/
|
|
21
|
+
export interface TranslateBridge {
|
|
22
|
+
/** The protocol version; the overlay refuses a page speaking another. */
|
|
23
|
+
readonly protocol: typeof BRIDGE_PROTOCOL;
|
|
24
|
+
/** The locale being translated into. */
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
/** Every catalog the page registered. */
|
|
27
|
+
catalogs: () => CatalogSnapshot[];
|
|
28
|
+
/**
|
|
29
|
+
* The tables of the page whose rows a translator may write — the element
|
|
30
|
+
* sheet, a list of ions — with the columns that are text rather than
|
|
31
|
+
* measurement. Empty on a page that shows no table.
|
|
32
|
+
*/
|
|
33
|
+
tables: () => TranslatableTable[];
|
|
34
|
+
/** The message a marker found in the DOM stands for. */
|
|
35
|
+
resolveMarker: (id: number) => MessageRef | undefined;
|
|
36
|
+
/** Show an edited message on the page; `undefined` removes the edit. */
|
|
37
|
+
setDraft: (ref: MessageRef, message: string | undefined) => void;
|
|
38
|
+
/** Be told whenever a draft changes; returns the function that stops it. */
|
|
39
|
+
subscribe: (listener: () => void) => () => void;
|
|
40
|
+
}
|
|
41
|
+
/** How a session is set up. */
|
|
42
|
+
export interface TranslateSessionOptions {
|
|
43
|
+
/** The locale messages are shown in. */
|
|
44
|
+
locale: string;
|
|
45
|
+
/** Every catalog the page renders from. */
|
|
46
|
+
catalogs: readonly CatalogSource[];
|
|
47
|
+
/**
|
|
48
|
+
* The published messages of `locale`, by catalog id.
|
|
49
|
+
* @default {}
|
|
50
|
+
*/
|
|
51
|
+
translations?: Readonly<Record<string, Messages>>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether every formatted message carries its invisible marker, which is
|
|
54
|
+
* what translate mode is.
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
marked?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The tables whose rows are translated, declared so the overlay can offer
|
|
60
|
+
* them as a grid: a cell of a table is rarely on the page being looked at,
|
|
61
|
+
* and 118 of them are never Alt-clicked one by one.
|
|
62
|
+
* @default []
|
|
63
|
+
*/
|
|
64
|
+
tables?: readonly TranslatableTable[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Formats the messages of a page, and in translate mode lets the overlay edit
|
|
68
|
+
* them live: a draft replaces the published message as soon as it can be
|
|
69
|
+
* formatted, and a draft that cannot is ignored rather than breaking the page.
|
|
70
|
+
*/
|
|
71
|
+
export declare class TranslateSession implements TranslateBridge {
|
|
72
|
+
#private;
|
|
73
|
+
readonly protocol = 2;
|
|
74
|
+
readonly locale: string;
|
|
75
|
+
constructor(options: TranslateSessionOptions);
|
|
76
|
+
/**
|
|
77
|
+
* Increases on every draft change, for a view that re-renders on it.
|
|
78
|
+
* @returns The current version.
|
|
79
|
+
*/
|
|
80
|
+
get version(): number;
|
|
81
|
+
/**
|
|
82
|
+
* Format one message: the draft, else the published translation, else the
|
|
83
|
+
* English message — the first that passes its check against the English
|
|
84
|
+
* one and formats. A draft that drops a placeholder formats without error,
|
|
85
|
+
* so the check, not the formatting, is what keeps it off the page.
|
|
86
|
+
* @param catalogId - The catalog the message belongs to.
|
|
87
|
+
* @param key - The key of the message.
|
|
88
|
+
* @param values - What the placeholders are filled with.
|
|
89
|
+
* @returns The text to show; the key itself when no catalog has it.
|
|
90
|
+
*/
|
|
91
|
+
format(catalogId: string, key: string, values?: MessageValues): string;
|
|
92
|
+
catalogs(): CatalogSnapshot[];
|
|
93
|
+
/**
|
|
94
|
+
* The tables whose rows a translator may write.
|
|
95
|
+
* @returns One entry per table the page declared.
|
|
96
|
+
*/
|
|
97
|
+
tables(): TranslatableTable[];
|
|
98
|
+
resolveMarker(id: number): MessageRef | undefined;
|
|
99
|
+
setDraft(ref: MessageRef, message: string | undefined): void;
|
|
100
|
+
subscribe(listener: () => void): () => void;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/translate/core/session.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD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ACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CACvC;AAQD;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,eAAe;;IACtD,SAAgB,QAAQ,KAAmB;IAC3C,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAWZ,OAAO,EAAE,uBAAuB;IAoBnD;;;OAGG;IACH,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED;;;;;;;;;OASG;IACI,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa;IAmB7D,QAAQ,IAAI,eAAe,EAAE;IAYpC;;;OAGG;IACI,MAAM,IAAI,iBAAiB,EAAE;IAI7B,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIjD,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAc5D,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;CAqDnD"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { IntlMessageFormat } from 'intl-messageformat';
|
|
2
|
+
import { SOURCE_LOCALE, ownMessage } from "./catalog.js";
|
|
3
|
+
import { checkTranslation } from "./checkTranslation.js";
|
|
4
|
+
import { markText } from "./marker.js";
|
|
5
|
+
/** The version of the page ↔ overlay protocol this session speaks. */
|
|
6
|
+
export const BRIDGE_PROTOCOL = 2;
|
|
7
|
+
/** Where a page in translate mode exposes its session to the overlay. */
|
|
8
|
+
export const BRIDGE_GLOBAL = '__cheminfoTranslate';
|
|
9
|
+
/**
|
|
10
|
+
* Formats the messages of a page, and in translate mode lets the overlay edit
|
|
11
|
+
* them live: a draft replaces the published message as soon as it can be
|
|
12
|
+
* formatted, and a draft that cannot is ignored rather than breaking the page.
|
|
13
|
+
*/
|
|
14
|
+
export class TranslateSession {
|
|
15
|
+
protocol = BRIDGE_PROTOCOL;
|
|
16
|
+
locale;
|
|
17
|
+
#marked;
|
|
18
|
+
#catalogs = new Map();
|
|
19
|
+
#ids = new Map();
|
|
20
|
+
#refs = [];
|
|
21
|
+
#listeners = new Set();
|
|
22
|
+
#formatters = new Map();
|
|
23
|
+
#checked = new Map();
|
|
24
|
+
#tables;
|
|
25
|
+
#version = 0;
|
|
26
|
+
constructor(options) {
|
|
27
|
+
const { locale, catalogs, translations = {}, marked = false, tables = [], } = options;
|
|
28
|
+
this.locale = locale;
|
|
29
|
+
this.#marked = marked;
|
|
30
|
+
this.#tables = tables;
|
|
31
|
+
for (const source of catalogs) {
|
|
32
|
+
this.#catalogs.set(source.id, {
|
|
33
|
+
source,
|
|
34
|
+
translation: translations[source.id] ?? {},
|
|
35
|
+
drafts: new Map(),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Increases on every draft change, for a view that re-renders on it.
|
|
41
|
+
* @returns The current version.
|
|
42
|
+
*/
|
|
43
|
+
get version() {
|
|
44
|
+
return this.#version;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Format one message: the draft, else the published translation, else the
|
|
48
|
+
* English message — the first that passes its check against the English
|
|
49
|
+
* one and formats. A draft that drops a placeholder formats without error,
|
|
50
|
+
* so the check, not the formatting, is what keeps it off the page.
|
|
51
|
+
* @param catalogId - The catalog the message belongs to.
|
|
52
|
+
* @param key - The key of the message.
|
|
53
|
+
* @param values - What the placeholders are filled with.
|
|
54
|
+
* @returns The text to show; the key itself when no catalog has it.
|
|
55
|
+
*/
|
|
56
|
+
format(catalogId, key, values) {
|
|
57
|
+
const catalog = this.#catalogs.get(catalogId);
|
|
58
|
+
if (catalog === undefined)
|
|
59
|
+
return key;
|
|
60
|
+
const source = ownMessage(catalog.source.messages, key);
|
|
61
|
+
if (source === undefined)
|
|
62
|
+
return key;
|
|
63
|
+
const draft = this.#usable(source, catalog.drafts.get(key));
|
|
64
|
+
const translation = this.#usable(source, ownMessage(catalog.translation, key));
|
|
65
|
+
const text = this.#tryFormat(draft, this.locale, values) ??
|
|
66
|
+
this.#tryFormat(translation, this.locale, values) ??
|
|
67
|
+
this.#tryFormat(source, SOURCE_LOCALE, values) ??
|
|
68
|
+
source;
|
|
69
|
+
return this.#marked ? markText(text, this.#idOf(catalogId, key)) : text;
|
|
70
|
+
}
|
|
71
|
+
catalogs() {
|
|
72
|
+
const snapshots = [];
|
|
73
|
+
for (const { source, translation, drafts } of this.#catalogs.values()) {
|
|
74
|
+
snapshots.push({
|
|
75
|
+
...source,
|
|
76
|
+
translation,
|
|
77
|
+
drafts: Object.fromEntries(drafts),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return snapshots;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The tables whose rows a translator may write.
|
|
84
|
+
* @returns One entry per table the page declared.
|
|
85
|
+
*/
|
|
86
|
+
tables() {
|
|
87
|
+
return [...this.#tables];
|
|
88
|
+
}
|
|
89
|
+
resolveMarker(id) {
|
|
90
|
+
return this.#refs[id];
|
|
91
|
+
}
|
|
92
|
+
setDraft(ref, message) {
|
|
93
|
+
const catalog = this.#catalogs.get(ref.catalogId);
|
|
94
|
+
if (catalog === undefined)
|
|
95
|
+
return;
|
|
96
|
+
if (ownMessage(catalog.source.messages, ref.key) === undefined)
|
|
97
|
+
return;
|
|
98
|
+
if (catalog.drafts.get(ref.key) === message)
|
|
99
|
+
return;
|
|
100
|
+
if (message === undefined) {
|
|
101
|
+
catalog.drafts.delete(ref.key);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
catalog.drafts.set(ref.key, message);
|
|
105
|
+
}
|
|
106
|
+
this.#version++;
|
|
107
|
+
for (const listener of this.#listeners)
|
|
108
|
+
listener();
|
|
109
|
+
}
|
|
110
|
+
subscribe(listener) {
|
|
111
|
+
this.#listeners.add(listener);
|
|
112
|
+
return () => {
|
|
113
|
+
this.#listeners.delete(listener);
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
#idOf(catalogId, key) {
|
|
117
|
+
const name = `${catalogId}\n${key}`;
|
|
118
|
+
let id = this.#ids.get(name);
|
|
119
|
+
if (id === undefined) {
|
|
120
|
+
id = this.#refs.length;
|
|
121
|
+
this.#refs.push({ catalogId, key });
|
|
122
|
+
this.#ids.set(name, id);
|
|
123
|
+
}
|
|
124
|
+
return id;
|
|
125
|
+
}
|
|
126
|
+
#usable(source, message) {
|
|
127
|
+
if (message === undefined)
|
|
128
|
+
return undefined;
|
|
129
|
+
const name = JSON.stringify([source, message]);
|
|
130
|
+
let usable = this.#checked.get(name);
|
|
131
|
+
if (usable === undefined) {
|
|
132
|
+
usable = checkTranslation(source, message).length === 0;
|
|
133
|
+
this.#checked.set(name, usable);
|
|
134
|
+
}
|
|
135
|
+
return usable ? message : undefined;
|
|
136
|
+
}
|
|
137
|
+
#tryFormat(message, locale, values) {
|
|
138
|
+
if (message === undefined)
|
|
139
|
+
return undefined;
|
|
140
|
+
const name = `${locale}\n${message}`;
|
|
141
|
+
let formatter = this.#formatters.get(name);
|
|
142
|
+
if (formatter === undefined) {
|
|
143
|
+
try {
|
|
144
|
+
formatter = new IntlMessageFormat(message, locale);
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
formatter = null;
|
|
148
|
+
}
|
|
149
|
+
this.#formatters.set(name, formatter);
|
|
150
|
+
}
|
|
151
|
+
if (formatter === null)
|
|
152
|
+
return undefined;
|
|
153
|
+
try {
|
|
154
|
+
const output = formatter.format(values);
|
|
155
|
+
return Array.isArray(output) ? output.join('') : String(output);
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/translate/core/session.ts"],"names":[],"mappings":"AAAA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B,MAAc,EACd,MAAiC;QAEjC,IAAI,OAAO,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC5C,MAAM,IAAI,GAAG,GAAG,MAAM,KAAK,OAAO,EAAE,CAAC;QACrC,IAAI,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,SAAS,GAAG,IAAI,iBAAiB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACrD,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,SAAS,KAAK,IAAI;YAAE,OAAO,SAAS,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACxC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAClE,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a page into a translatable one.
|
|
3
|
+
*
|
|
4
|
+
* A site opened with `?translate=<locale>` formats every message with its
|
|
5
|
+
* invisible marker, hands its session to the overlay as
|
|
6
|
+
* `window.__cheminfoTranslate`, and loads that overlay from
|
|
7
|
+
* translate.cheminfo.org. Nothing of this is paid for by an ordinary visit:
|
|
8
|
+
* the site imports this module only once it has seen the parameter.
|
|
9
|
+
*/
|
|
10
|
+
import type { CatalogSource, Messages } from './catalog.ts';
|
|
11
|
+
import { TranslateSession } from './session.ts';
|
|
12
|
+
import type { TranslatableTable } from './tables.ts';
|
|
13
|
+
/** The query parameter that opens a page in translate mode. */
|
|
14
|
+
export declare const TRANSLATE_PARAM = "translate";
|
|
15
|
+
/** Where the overlay is served from unless a site says otherwise. */
|
|
16
|
+
export declare const TRANSLATE_ORIGIN = "https://translate.cheminfo.org";
|
|
17
|
+
/**
|
|
18
|
+
* The locale a page is being translated into, from its address:
|
|
19
|
+
* `?translate=fr` opens the overlay for French.
|
|
20
|
+
* @param search - The query string, e.g. `location.search`.
|
|
21
|
+
* @returns The locale, or `undefined` when the page is not in translate mode,
|
|
22
|
+
* or names English, or names something that is not a language at all.
|
|
23
|
+
*/
|
|
24
|
+
export declare function readTranslateLocale(search: string): string | undefined;
|
|
25
|
+
/** How a page enters translate mode. */
|
|
26
|
+
export interface StartTranslatingOptions {
|
|
27
|
+
/** The locale being translated into, from {@link readTranslateLocale}. */
|
|
28
|
+
locale: string;
|
|
29
|
+
/** Every catalog the page renders messages from. */
|
|
30
|
+
catalogs: readonly CatalogSource[];
|
|
31
|
+
/**
|
|
32
|
+
* The published messages of the locale, by catalog id, so the overlay opens
|
|
33
|
+
* on what the site already ships rather than on English.
|
|
34
|
+
* @default {}
|
|
35
|
+
*/
|
|
36
|
+
translations?: Readonly<Record<string, Messages>>;
|
|
37
|
+
/**
|
|
38
|
+
* The tables whose rows a translator may write.
|
|
39
|
+
* @default []
|
|
40
|
+
*/
|
|
41
|
+
tables?: readonly TranslatableTable[];
|
|
42
|
+
/**
|
|
43
|
+
* Where the overlay is loaded from.
|
|
44
|
+
* @default 'https://translate.cheminfo.org'
|
|
45
|
+
*/
|
|
46
|
+
origin?: string;
|
|
47
|
+
/**
|
|
48
|
+
* The document the overlay script is added to.
|
|
49
|
+
* @default globalThis.document
|
|
50
|
+
*/
|
|
51
|
+
document?: Document;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Put a page into translate mode.
|
|
55
|
+
*
|
|
56
|
+
* The session is exposed before the overlay is loaded, so the overlay finds a
|
|
57
|
+
* page already formatting marked messages. The site is handed the session back
|
|
58
|
+
* and must format through it from then on — that is what makes an edit show up
|
|
59
|
+
* as it is typed.
|
|
60
|
+
* @param options - See {@link StartTranslatingOptions}.
|
|
61
|
+
* @returns The session the page formats through.
|
|
62
|
+
*/
|
|
63
|
+
export declare function startTranslating(options: StartTranslatingOptions): TranslateSession;
|
|
64
|
+
/**
|
|
65
|
+
* Add the overlay script to the page, once.
|
|
66
|
+
* @param origin - Where the overlay is served from.
|
|
67
|
+
* @param target - The document to add it to.
|
|
68
|
+
*/
|
|
69
|
+
export declare function loadOverlay(origin: string, target?: Document): void;
|
|
70
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../../src/translate/core/start.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAiB,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,+DAA+D;AAC/D,eAAO,MAAM,eAAe,cAAc,CAAC;AAE3C,qEAAqE;AACrE,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMtE;AAED,wCAAwC;AACxC,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC;;;;OAIG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAClD;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,uBAAuB,GAC/B,gBAAgB,CAoBlB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,WAAsB,GAC3B,IAAI,CAWN"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turning a page into a translatable one.
|
|
3
|
+
*
|
|
4
|
+
* A site opened with `?translate=<locale>` formats every message with its
|
|
5
|
+
* invisible marker, hands its session to the overlay as
|
|
6
|
+
* `window.__cheminfoTranslate`, and loads that overlay from
|
|
7
|
+
* translate.cheminfo.org. Nothing of this is paid for by an ordinary visit:
|
|
8
|
+
* the site imports this module only once it has seen the parameter.
|
|
9
|
+
*/
|
|
10
|
+
import { isLanguageTag } from "../../language/core/languageParam.js";
|
|
11
|
+
import { SOURCE_LOCALE } from "./catalog.js";
|
|
12
|
+
import { BRIDGE_GLOBAL, TranslateSession } from "./session.js";
|
|
13
|
+
/** The query parameter that opens a page in translate mode. */
|
|
14
|
+
export const TRANSLATE_PARAM = 'translate';
|
|
15
|
+
/** Where the overlay is served from unless a site says otherwise. */
|
|
16
|
+
export const TRANSLATE_ORIGIN = 'https://translate.cheminfo.org';
|
|
17
|
+
/**
|
|
18
|
+
* The locale a page is being translated into, from its address:
|
|
19
|
+
* `?translate=fr` opens the overlay for French.
|
|
20
|
+
* @param search - The query string, e.g. `location.search`.
|
|
21
|
+
* @returns The locale, or `undefined` when the page is not in translate mode,
|
|
22
|
+
* or names English, or names something that is not a language at all.
|
|
23
|
+
*/
|
|
24
|
+
export function readTranslateLocale(search) {
|
|
25
|
+
const value = new URLSearchParams(search).get(TRANSLATE_PARAM);
|
|
26
|
+
if (value === null || value === SOURCE_LOCALE || !isLanguageTag(value)) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Put a page into translate mode.
|
|
33
|
+
*
|
|
34
|
+
* The session is exposed before the overlay is loaded, so the overlay finds a
|
|
35
|
+
* page already formatting marked messages. The site is handed the session back
|
|
36
|
+
* and must format through it from then on — that is what makes an edit show up
|
|
37
|
+
* as it is typed.
|
|
38
|
+
* @param options - See {@link StartTranslatingOptions}.
|
|
39
|
+
* @returns The session the page formats through.
|
|
40
|
+
*/
|
|
41
|
+
export function startTranslating(options) {
|
|
42
|
+
const { locale, catalogs, translations = {}, tables = [], origin = TRANSLATE_ORIGIN, document: target = globalThis.document, } = options;
|
|
43
|
+
const session = new TranslateSession({
|
|
44
|
+
locale,
|
|
45
|
+
catalogs,
|
|
46
|
+
translations,
|
|
47
|
+
tables,
|
|
48
|
+
marked: true,
|
|
49
|
+
});
|
|
50
|
+
Object.assign(globalThis, { [BRIDGE_GLOBAL]: session });
|
|
51
|
+
loadOverlay(origin, target);
|
|
52
|
+
return session;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Add the overlay script to the page, once.
|
|
56
|
+
* @param origin - Where the overlay is served from.
|
|
57
|
+
* @param target - The document to add it to.
|
|
58
|
+
*/
|
|
59
|
+
export function loadOverlay(origin, target = globalThis.document) {
|
|
60
|
+
if (target === undefined)
|
|
61
|
+
return;
|
|
62
|
+
const src = `${origin.replace(/\/$/, '')}/overlay.js`;
|
|
63
|
+
for (const loaded of target.querySelectorAll('script')) {
|
|
64
|
+
if (loaded.src === src)
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const script = target.createElement('script');
|
|
68
|
+
script.type = 'module';
|
|
69
|
+
script.src = src;
|
|
70
|
+
script.async = true;
|
|
71
|
+
target.head.append(script);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=start.js.map
|
|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EAAE,MAAM,CAAC,CAAC;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,MAAc,EACd,MAAM,GAAG,UAAU,CAAC,QAAQ;IAE5B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO;IACjC,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC;IACtD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACvD,IAAI,MAAM,CAAC,GAAG,KAAK,GAAG;YAAE,OAAO;IACjC,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC9C,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;IACvB,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a translator is offered before typing: the translations already made
|
|
3
|
+
* for the same English, for English that differs only where the text is not
|
|
4
|
+
* language, and for English that merely looks like it.
|
|
5
|
+
*
|
|
6
|
+
* A table is where this earns its place. Half of 118 element names are the
|
|
7
|
+
* same word in two languages and the other half differ by an ending; a column
|
|
8
|
+
* of quantities is a handful of phrases repeated with one word changed. A
|
|
9
|
+
* translator who is shown what was done three rows above confirms instead of
|
|
10
|
+
* typing, and the column stays consistent with itself — which is the thing a
|
|
11
|
+
* long table loses first.
|
|
12
|
+
*
|
|
13
|
+
* Nothing here invents a translation. Every suggestion is a translation
|
|
14
|
+
* somebody already wrote, either as it stands or with the part that is not
|
|
15
|
+
* language put back.
|
|
16
|
+
*/
|
|
17
|
+
/** One message already translated, which a suggestion is drawn from. */
|
|
18
|
+
export interface TranslatedPair {
|
|
19
|
+
/** The key it is kept under, so the translator can see where it came from. */
|
|
20
|
+
key: string;
|
|
21
|
+
/** The English message. */
|
|
22
|
+
source: string;
|
|
23
|
+
/** Its translation. */
|
|
24
|
+
target: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* How a suggestion was arrived at.
|
|
28
|
+
*
|
|
29
|
+
* - `exact` — the same English message, translated elsewhere.
|
|
30
|
+
* - `pattern` — English that differs only in a part that is not language (a
|
|
31
|
+
* number, a symbol, a formula), with that part put back into the
|
|
32
|
+
* translation.
|
|
33
|
+
* - `similar` — English that looks like this one; the translation is offered
|
|
34
|
+
* to be adapted, not to be taken as it is.
|
|
35
|
+
*/
|
|
36
|
+
export type SuggestionKind = 'exact' | 'pattern' | 'similar';
|
|
37
|
+
/** One translation offered for a message. */
|
|
38
|
+
export interface MessageSuggestion {
|
|
39
|
+
/** What goes in the box if the translator takes it. */
|
|
40
|
+
message: string;
|
|
41
|
+
/** How it was arrived at. */
|
|
42
|
+
kind: SuggestionKind;
|
|
43
|
+
/** Between 0 and 1; 1 is the same English message. */
|
|
44
|
+
score: number;
|
|
45
|
+
/** The already-translated message it was drawn from. */
|
|
46
|
+
from: TranslatedPair;
|
|
47
|
+
}
|
|
48
|
+
/** How suggestions are chosen. */
|
|
49
|
+
export interface SuggestionOptions {
|
|
50
|
+
/**
|
|
51
|
+
* The most suggestions to return.
|
|
52
|
+
* @default 5
|
|
53
|
+
*/
|
|
54
|
+
limit?: number;
|
|
55
|
+
/**
|
|
56
|
+
* How alike two English messages must be before one is offered for the
|
|
57
|
+
* other, between 0 and 1.
|
|
58
|
+
* @default 0.55
|
|
59
|
+
*/
|
|
60
|
+
minimumScore?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The translations worth offering for one English message.
|
|
64
|
+
* @param source - The English message being translated.
|
|
65
|
+
* @param pairs - Every message already translated in this language.
|
|
66
|
+
* @param options - See {@link SuggestionOptions}.
|
|
67
|
+
* @returns The suggestions, best first; empty when nothing is close enough.
|
|
68
|
+
*/
|
|
69
|
+
export declare function messageSuggestions(source: string, pairs: readonly TranslatedPair[], options?: SuggestionOptions): MessageSuggestion[];
|
|
70
|
+
/**
|
|
71
|
+
* How alike two messages are, as the suggestions rank them.
|
|
72
|
+
* @param first - One message.
|
|
73
|
+
* @param second - The other.
|
|
74
|
+
* @returns 1 when they are the same, 0 when they share nothing.
|
|
75
|
+
*/
|
|
76
|
+
export declare function messageSimilarity(first: string, second: string): number;
|
|
77
|
+
//# sourceMappingURL=suggestions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestions.d.ts","sourceRoot":"","sources":["../../../src/translate/core/suggestions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC;IACZ,2BAA2B;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7D,6CAA6C;AAC7C,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,6BAA6B;IAC7B,IAAI,EAAE,cAAc,CAAC;IACrB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,kCAAkC;AAClC,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,SAAS,cAAc,EAAE,EAChC,OAAO,GAAE,iBAAsB,GAC9B,iBAAiB,EAAE,CAqBrB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIvE"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a translator is offered before typing: the translations already made
|
|
3
|
+
* for the same English, for English that differs only where the text is not
|
|
4
|
+
* language, and for English that merely looks like it.
|
|
5
|
+
*
|
|
6
|
+
* A table is where this earns its place. Half of 118 element names are the
|
|
7
|
+
* same word in two languages and the other half differ by an ending; a column
|
|
8
|
+
* of quantities is a handful of phrases repeated with one word changed. A
|
|
9
|
+
* translator who is shown what was done three rows above confirms instead of
|
|
10
|
+
* typing, and the column stays consistent with itself — which is the thing a
|
|
11
|
+
* long table loses first.
|
|
12
|
+
*
|
|
13
|
+
* Nothing here invents a translation. Every suggestion is a translation
|
|
14
|
+
* somebody already wrote, either as it stands or with the part that is not
|
|
15
|
+
* language put back.
|
|
16
|
+
*/
|
|
17
|
+
import leven from 'leven';
|
|
18
|
+
const DEFAULT_LIMIT = 5;
|
|
19
|
+
const DEFAULT_MINIMUM = 0.55;
|
|
20
|
+
const KIND_ORDER = {
|
|
21
|
+
exact: 0,
|
|
22
|
+
pattern: 1,
|
|
23
|
+
similar: 2,
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The translations worth offering for one English message.
|
|
27
|
+
* @param source - The English message being translated.
|
|
28
|
+
* @param pairs - Every message already translated in this language.
|
|
29
|
+
* @param options - See {@link SuggestionOptions}.
|
|
30
|
+
* @returns The suggestions, best first; empty when nothing is close enough.
|
|
31
|
+
*/
|
|
32
|
+
export function messageSuggestions(source, pairs, options = {}) {
|
|
33
|
+
const { limit = DEFAULT_LIMIT, minimumScore = DEFAULT_MINIMUM } = options;
|
|
34
|
+
if (source === '' || limit <= 0)
|
|
35
|
+
return [];
|
|
36
|
+
const found = [];
|
|
37
|
+
for (const pair of pairs) {
|
|
38
|
+
if (pair.target === '' || pair.source === '')
|
|
39
|
+
continue;
|
|
40
|
+
const suggestion = suggestFrom(source, pair, minimumScore);
|
|
41
|
+
if (suggestion !== undefined)
|
|
42
|
+
found.push(suggestion);
|
|
43
|
+
}
|
|
44
|
+
found.sort(compareSuggestions);
|
|
45
|
+
const best = [];
|
|
46
|
+
const taken = new Set();
|
|
47
|
+
for (const suggestion of found) {
|
|
48
|
+
if (taken.has(suggestion.message))
|
|
49
|
+
continue;
|
|
50
|
+
taken.add(suggestion.message);
|
|
51
|
+
best.push(suggestion);
|
|
52
|
+
if (best.length === limit)
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return best;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* How alike two messages are, as the suggestions rank them.
|
|
59
|
+
* @param first - One message.
|
|
60
|
+
* @param second - The other.
|
|
61
|
+
* @returns 1 when they are the same, 0 when they share nothing.
|
|
62
|
+
*/
|
|
63
|
+
export function messageSimilarity(first, second) {
|
|
64
|
+
const longest = Math.max(first.length, second.length);
|
|
65
|
+
if (longest === 0)
|
|
66
|
+
return 1;
|
|
67
|
+
return 1 - leven(first, second) / longest;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The best offer one already-translated message can make for another.
|
|
71
|
+
* @param source - The English being translated.
|
|
72
|
+
* @param pair - The already-translated message to draw from.
|
|
73
|
+
* @param minimumScore - How alike the two must be to be worth offering.
|
|
74
|
+
* @returns The suggestion, or `undefined` when the pair is too far away.
|
|
75
|
+
*/
|
|
76
|
+
function suggestFrom(source, pair, minimumScore) {
|
|
77
|
+
if (pair.source === source) {
|
|
78
|
+
return { message: pair.target, kind: 'exact', score: 1, from: pair };
|
|
79
|
+
}
|
|
80
|
+
// An edit can never be smaller than the difference in length, so a pair that
|
|
81
|
+
// cannot reach the threshold is dropped before the distance is computed.
|
|
82
|
+
const longest = Math.max(source.length, pair.source.length);
|
|
83
|
+
const shortest = Math.min(source.length, pair.source.length);
|
|
84
|
+
if (longest === 0 || shortest / longest < minimumScore)
|
|
85
|
+
return undefined;
|
|
86
|
+
const pattern = patternSuggestion(source, pair);
|
|
87
|
+
if (pattern !== undefined && pattern.score >= minimumScore)
|
|
88
|
+
return pattern;
|
|
89
|
+
const score = messageSimilarity(source, pair.source);
|
|
90
|
+
if (score < minimumScore)
|
|
91
|
+
return undefined;
|
|
92
|
+
return { message: pair.target, kind: 'similar', score, from: pair };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A translation whose English differs from this one only in a run of text
|
|
96
|
+
* that survives into the translation unchanged — a number, a symbol, a
|
|
97
|
+
* formula. That run is the only thing put back, so nothing is invented.
|
|
98
|
+
* @param source - The English being translated.
|
|
99
|
+
* @param pair - The already-translated message to draw from.
|
|
100
|
+
* @returns The suggestion, or `undefined` when the run cannot be put back.
|
|
101
|
+
*/
|
|
102
|
+
function patternSuggestion(source, pair) {
|
|
103
|
+
const prefix = commonPrefix(source, pair.source);
|
|
104
|
+
const suffix = commonSuffix(source.slice(prefix), pair.source.slice(prefix));
|
|
105
|
+
const own = source.slice(prefix, source.length - suffix);
|
|
106
|
+
const theirs = pair.source.slice(prefix, pair.source.length - suffix);
|
|
107
|
+
if (theirs === '')
|
|
108
|
+
return undefined;
|
|
109
|
+
// The varying run must appear once and only once, or putting it back would
|
|
110
|
+
// be a guess about which occurrence was meant.
|
|
111
|
+
const at = pair.target.indexOf(theirs);
|
|
112
|
+
if (at === -1 || pair.target.includes(theirs, at + 1))
|
|
113
|
+
return undefined;
|
|
114
|
+
const message = pair.target.slice(0, at) + own + pair.target.slice(at + theirs.length);
|
|
115
|
+
const kept = prefix + suffix;
|
|
116
|
+
const score = kept / Math.max(source.length, pair.source.length);
|
|
117
|
+
return { message, kind: 'pattern', score, from: pair };
|
|
118
|
+
}
|
|
119
|
+
function commonPrefix(first, second) {
|
|
120
|
+
const limit = Math.min(first.length, second.length);
|
|
121
|
+
let length = 0;
|
|
122
|
+
while (length < limit && first[length] === second[length])
|
|
123
|
+
length++;
|
|
124
|
+
return length;
|
|
125
|
+
}
|
|
126
|
+
function commonSuffix(first, second) {
|
|
127
|
+
const limit = Math.min(first.length, second.length);
|
|
128
|
+
let length = 0;
|
|
129
|
+
while (length < limit &&
|
|
130
|
+
first[first.length - 1 - length] === second[second.length - 1 - length]) {
|
|
131
|
+
length++;
|
|
132
|
+
}
|
|
133
|
+
return length;
|
|
134
|
+
}
|
|
135
|
+
function compareSuggestions(first, second) {
|
|
136
|
+
if (first.kind !== second.kind) {
|
|
137
|
+
return KIND_ORDER[first.kind] - KIND_ORDER[second.kind];
|
|
138
|
+
}
|
|
139
|
+
if (first.score !== second.score)
|
|
140
|
+
return second.score - first.score;
|
|
141
|
+
return first.from.key < second.from.key ? -1 : 1;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=suggestions.js.map
|