@genome-spy/core 0.36.0 → 0.37.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 +1 -0
- package/dist/{index.es.js → bundled/index.es.js} +4227 -4085
- package/dist/{index.js → bundled/index.js} +191 -55
- package/dist/src/data/collector.d.ts +36 -0
- package/dist/src/data/collector.d.ts.map +1 -0
- package/dist/src/data/collector.js +184 -0
- package/dist/src/data/collector.test.js +84 -0
- package/dist/src/data/dataFlow.d.ts +65 -0
- package/dist/src/data/dataFlow.d.ts.map +1 -0
- package/dist/src/data/dataFlow.js +142 -0
- package/dist/src/data/dataFlow.test.js +5 -0
- package/dist/src/data/facetNode.d.ts +17 -0
- package/dist/src/data/facetNode.d.ts.map +1 -0
- package/dist/src/data/facetNode.js +17 -0
- package/dist/src/data/flow.test.js +72 -0
- package/dist/src/data/flowNode.d.ts +136 -0
- package/dist/src/data/flowNode.d.ts.map +1 -0
- package/dist/src/data/flowNode.js +286 -0
- package/dist/src/data/flowNode.test.js +50 -0
- package/dist/src/data/flowOptimizer.d.ts +27 -0
- package/dist/src/data/flowOptimizer.d.ts.map +1 -0
- package/dist/src/data/flowOptimizer.js +133 -0
- package/dist/src/data/flowOptimizer.test.js +193 -0
- package/dist/src/data/flowTestUtils.d.ts +30 -0
- package/dist/src/data/flowTestUtils.d.ts.map +1 -0
- package/dist/src/data/flowTestUtils.js +63 -0
- package/dist/src/data/formats/fasta.d.ts +20 -0
- package/dist/src/data/formats/fasta.d.ts.map +1 -0
- package/dist/src/data/formats/fasta.js +32 -0
- package/dist/src/data/formats/fasta.test.js +27 -0
- package/dist/src/data/sources/dataSource.d.ts +12 -0
- package/dist/src/data/sources/dataSource.d.ts.map +1 -0
- package/dist/src/data/sources/dataSource.js +25 -0
- package/dist/src/data/sources/dataSourceFactory.d.ts +16 -0
- package/dist/src/data/sources/dataSourceFactory.d.ts.map +1 -0
- package/dist/src/data/sources/dataSourceFactory.js +127 -0
- package/dist/src/data/sources/dataUtils.d.ts +50 -0
- package/dist/src/data/sources/dataUtils.d.ts.map +1 -0
- package/dist/src/data/sources/dataUtils.js +83 -0
- package/dist/src/data/sources/dynamic/README.md +3 -0
- package/dist/src/data/sources/dynamic/axisGenomeSource.d.ts +13 -0
- package/dist/src/data/sources/dynamic/axisGenomeSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/axisGenomeSource.js +19 -0
- package/dist/src/data/sources/dynamic/axisTickSource.d.ts +18 -0
- package/dist/src/data/sources/dynamic/axisTickSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/axisTickSource.js +73 -0
- package/dist/src/data/sources/dynamic/bamSource.d.ts +46 -0
- package/dist/src/data/sources/dynamic/bamSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/bamSource.js +115 -0
- package/dist/src/data/sources/dynamic/bigBedSource.d.ts +51 -0
- package/dist/src/data/sources/dynamic/bigBedSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/bigBedSource.js +128 -0
- package/dist/src/data/sources/dynamic/bigWigSource.d.ts +58 -0
- package/dist/src/data/sources/dynamic/bigWigSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/bigWigSource.js +166 -0
- package/dist/src/data/sources/dynamic/gff3Source.d.ts +8 -0
- package/dist/src/data/sources/dynamic/gff3Source.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/gff3Source.js +19 -0
- package/dist/src/data/sources/dynamic/indexedFastaSource.d.ts +30 -0
- package/dist/src/data/sources/dynamic/indexedFastaSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/indexedFastaSource.js +86 -0
- package/dist/src/data/sources/dynamic/singleAxisLazySource.d.ts +42 -0
- package/dist/src/data/sources/dynamic/singleAxisLazySource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/singleAxisLazySource.js +129 -0
- package/dist/src/data/sources/dynamic/tabixSource.d.ts +54 -0
- package/dist/src/data/sources/dynamic/tabixSource.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/tabixSource.js +140 -0
- package/dist/src/data/sources/dynamic/windowedMixin.d.ts +32 -0
- package/dist/src/data/sources/dynamic/windowedMixin.d.ts.map +1 -0
- package/dist/src/data/sources/dynamic/windowedMixin.js +53 -0
- package/dist/src/data/sources/inlineSource.d.ts +16 -0
- package/dist/src/data/sources/inlineSource.d.ts.map +1 -0
- package/dist/src/data/sources/inlineSource.js +68 -0
- package/dist/src/data/sources/inlineSource.test.js +56 -0
- package/dist/src/data/sources/namedSource.d.ts +25 -0
- package/dist/src/data/sources/namedSource.d.ts.map +1 -0
- package/dist/src/data/sources/namedSource.js +80 -0
- package/dist/src/data/sources/sequenceSource.d.ts +17 -0
- package/dist/src/data/sources/sequenceSource.d.ts.map +1 -0
- package/dist/src/data/sources/sequenceSource.js +47 -0
- package/dist/src/data/sources/sequenceSource.test.js +46 -0
- package/dist/src/data/sources/urlSource.d.ts +16 -0
- package/dist/src/data/sources/urlSource.d.ts.map +1 -0
- package/dist/src/data/sources/urlSource.js +74 -0
- package/dist/src/data/transforms/aggregate.d.ts +18 -0
- package/dist/src/data/transforms/aggregate.d.ts.map +1 -0
- package/dist/src/data/transforms/aggregate.js +67 -0
- package/dist/src/data/transforms/clone.d.ts +15 -0
- package/dist/src/data/transforms/clone.d.ts.map +1 -0
- package/dist/src/data/transforms/clone.js +40 -0
- package/dist/src/data/transforms/clone.test.js +11 -0
- package/dist/src/data/transforms/coverage.d.ts +30 -0
- package/dist/src/data/transforms/coverage.d.ts.map +1 -0
- package/dist/src/data/transforms/coverage.js +183 -0
- package/dist/src/data/transforms/coverage.test.js +123 -0
- package/dist/src/data/transforms/filter.d.ts +12 -0
- package/dist/src/data/transforms/filter.d.ts.map +1 -0
- package/dist/src/data/transforms/filter.js +33 -0
- package/dist/src/data/transforms/filter.test.js +18 -0
- package/dist/src/data/transforms/filterScoredLabels.d.ts +29 -0
- package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -0
- package/dist/src/data/transforms/filterScoredLabels.js +134 -0
- package/dist/src/data/transforms/flatten.d.ts +10 -0
- package/dist/src/data/transforms/flatten.d.ts.map +1 -0
- package/dist/src/data/transforms/flatten.js +68 -0
- package/dist/src/data/transforms/flatten.test.js +93 -0
- package/dist/src/data/transforms/flattenCompressedExons.d.ts +19 -0
- package/dist/src/data/transforms/flattenCompressedExons.d.ts.map +1 -0
- package/dist/src/data/transforms/flattenCompressedExons.js +53 -0
- package/dist/src/data/transforms/flattenDelimited.d.ts +10 -0
- package/dist/src/data/transforms/flattenDelimited.d.ts.map +1 -0
- package/dist/src/data/transforms/flattenDelimited.js +66 -0
- package/dist/src/data/transforms/flattenDelimited.test.js +87 -0
- package/dist/src/data/transforms/flattenSequence.d.ts +11 -0
- package/dist/src/data/transforms/flattenSequence.d.ts.map +1 -0
- package/dist/src/data/transforms/flattenSequence.js +35 -0
- package/dist/src/data/transforms/flattenSequence.test.js +34 -0
- package/dist/src/data/transforms/formula.d.ts +13 -0
- package/dist/src/data/transforms/formula.d.ts.map +1 -0
- package/dist/src/data/transforms/formula.js +35 -0
- package/dist/src/data/transforms/formula.test.js +19 -0
- package/dist/src/data/transforms/identifier.d.ts +40 -0
- package/dist/src/data/transforms/identifier.d.ts.map +1 -0
- package/dist/src/data/transforms/identifier.js +106 -0
- package/dist/src/data/transforms/identifier.test.js +83 -0
- package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts +10 -0
- package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -0
- package/dist/src/data/transforms/linearizeGenomicCoordinate.js +97 -0
- package/dist/src/data/transforms/measureText.d.ts +18 -0
- package/dist/src/data/transforms/measureText.d.ts.map +1 -0
- package/dist/src/data/transforms/measureText.js +42 -0
- package/dist/src/data/transforms/pileup.d.ts +10 -0
- package/dist/src/data/transforms/pileup.d.ts.map +1 -0
- package/dist/src/data/transforms/pileup.js +126 -0
- package/dist/src/data/transforms/pileup.test.js +70 -0
- package/dist/src/data/transforms/project.d.ts +13 -0
- package/dist/src/data/transforms/project.d.ts.map +1 -0
- package/dist/src/data/transforms/project.js +38 -0
- package/dist/src/data/transforms/project.test.js +32 -0
- package/dist/src/data/transforms/regexExtract.d.ts +13 -0
- package/dist/src/data/transforms/regexExtract.d.ts.map +1 -0
- package/dist/src/data/transforms/regexExtract.js +57 -0
- package/dist/src/data/transforms/regexExtract.test.js +67 -0
- package/dist/src/data/transforms/regexFold.d.ts +14 -0
- package/dist/src/data/transforms/regexFold.d.ts.map +1 -0
- package/dist/src/data/transforms/regexFold.js +139 -0
- package/dist/src/data/transforms/regexFold.test.js +160 -0
- package/dist/src/data/transforms/sample.d.ts +42 -0
- package/dist/src/data/transforms/sample.d.ts.map +1 -0
- package/dist/src/data/transforms/sample.js +99 -0
- package/dist/src/data/transforms/sample.test.js +38 -0
- package/dist/src/data/transforms/stack.d.ts +11 -0
- package/dist/src/data/transforms/stack.d.ts.map +1 -0
- package/dist/src/data/transforms/stack.js +134 -0
- package/dist/src/data/transforms/stack.test.js +91 -0
- package/dist/src/data/transforms/transformFactory.d.ts +12 -0
- package/dist/src/data/transforms/transformFactory.d.ts.map +1 -0
- package/dist/src/data/transforms/transformFactory.js +59 -0
- package/dist/src/encoder/accessor.d.ts +15 -0
- package/dist/src/encoder/accessor.d.ts.map +1 -0
- package/dist/src/encoder/accessor.js +76 -0
- package/dist/src/encoder/accessor.test.js +47 -0
- package/dist/src/encoder/encoder.d.ts +144 -0
- package/dist/src/encoder/encoder.d.ts.map +1 -0
- package/dist/src/encoder/encoder.js +400 -0
- package/dist/src/encoder/encoder.test.js +98 -0
- package/dist/src/fonts/Lato-Regular.json +1267 -0
- package/dist/src/fonts/Lato-Regular.png +0 -0
- package/dist/src/fonts/OFL.txt +93 -0
- package/dist/src/fonts/README.md +3 -0
- package/dist/src/fonts/bmFontManager.d.ts +182 -0
- package/dist/src/fonts/bmFontManager.d.ts.map +1 -0
- package/dist/src/fonts/bmFontManager.js +359 -0
- package/dist/src/fonts/bmFontMetrics.d.ts +45 -0
- package/dist/src/fonts/bmFontMetrics.d.ts.map +1 -0
- package/dist/src/fonts/bmFontMetrics.js +108 -0
- package/dist/src/genome/genome.d.ts +172 -0
- package/dist/src/genome/genome.d.ts.map +1 -0
- package/dist/src/genome/genome.js +379 -0
- package/dist/src/genome/genome.test.js +226 -0
- package/dist/src/genome/genomeStore.d.ts +20 -0
- package/dist/src/genome/genomeStore.d.ts.map +1 -0
- package/dist/src/genome/genomeStore.js +54 -0
- package/dist/src/genome/locusFormat.d.ts +14 -0
- package/dist/src/genome/locusFormat.d.ts.map +1 -0
- package/dist/src/genome/locusFormat.js +37 -0
- package/dist/src/genome/scaleIndex.d.ts +6 -0
- package/dist/src/genome/scaleIndex.d.ts.map +1 -0
- package/dist/src/genome/scaleIndex.js +165 -0
- package/dist/src/genome/scaleIndex.test.js +78 -0
- package/dist/src/genome/scaleLocus.d.ts +3 -0
- package/dist/src/genome/scaleLocus.d.ts.map +1 -0
- package/dist/src/genome/scaleLocus.js +101 -0
- package/dist/src/genome/scaleLocus.test.js +4 -0
- package/dist/src/genomeSpy.d.ts +141 -0
- package/dist/src/genomeSpy.d.ts.map +1 -0
- package/dist/src/genomeSpy.js +788 -0
- package/dist/src/gl/arrayBuilder.d.ts +71 -0
- package/dist/src/gl/arrayBuilder.d.ts.map +1 -0
- package/dist/src/gl/arrayBuilder.js +199 -0
- package/dist/src/gl/dataToVertices.d.ts +194 -0
- package/dist/src/gl/dataToVertices.d.ts.map +1 -0
- package/dist/src/gl/dataToVertices.js +639 -0
- package/dist/src/gl/includes/common.glsl.js +2 -0
- package/dist/src/gl/includes/picking.fragment.glsl.js +2 -0
- package/dist/src/gl/includes/picking.vertex.glsl.js +2 -0
- package/dist/src/gl/includes/sampleFacet.glsl.js +2 -0
- package/dist/src/gl/includes/scales.glsl.js +2 -0
- package/dist/src/gl/link.fragment.glsl.js +2 -0
- package/dist/src/gl/link.vertex.glsl.js +2 -0
- package/dist/src/gl/point.fragment.glsl.js +2 -0
- package/dist/src/gl/point.vertex.glsl.js +2 -0
- package/dist/src/gl/rect.fragment.glsl.js +2 -0
- package/dist/src/gl/rect.vertex.glsl.js +2 -0
- package/dist/src/gl/rule.fragment.glsl.js +2 -0
- package/dist/src/gl/rule.vertex.glsl.js +2 -0
- package/dist/src/gl/text.fragment.glsl.js +2 -0
- package/dist/src/gl/text.vertex.glsl.js +2 -0
- package/dist/src/gl/webGLHelper.d.ts +118 -0
- package/dist/src/gl/webGLHelper.d.ts.map +1 -0
- package/dist/src/gl/webGLHelper.js +513 -0
- package/dist/src/img/bowtie.svg +1 -0
- package/dist/src/img/genomespy-favicon.svg +34 -0
- package/dist/src/index.d.ts +15 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.html +11 -0
- package/dist/src/index.js +129 -0
- package/dist/src/marks/link.d.ts +11 -0
- package/dist/src/marks/link.d.ts.map +1 -0
- package/dist/src/marks/link.js +175 -0
- package/dist/src/marks/mark.d.ts +226 -0
- package/dist/src/marks/mark.d.ts.map +1 -0
- package/dist/src/marks/mark.js +1004 -0
- package/dist/src/marks/markUtils.d.ts +23 -0
- package/dist/src/marks/markUtils.d.ts.map +1 -0
- package/dist/src/marks/markUtils.js +125 -0
- package/dist/src/marks/pointMark.d.ts +11 -0
- package/dist/src/marks/pointMark.d.ts.map +1 -0
- package/dist/src/marks/pointMark.js +251 -0
- package/dist/src/marks/rectMark.d.ts +18 -0
- package/dist/src/marks/rectMark.d.ts.map +1 -0
- package/dist/src/marks/rectMark.js +255 -0
- package/dist/src/marks/rule.d.ts +6 -0
- package/dist/src/marks/rule.d.ts.map +1 -0
- package/dist/src/marks/rule.js +250 -0
- package/dist/src/marks/text.d.ts +13 -0
- package/dist/src/marks/text.d.ts.map +1 -0
- package/dist/src/marks/text.js +279 -0
- package/dist/src/scale/colorUtils.d.ts +34 -0
- package/dist/src/scale/colorUtils.d.ts.map +1 -0
- package/dist/src/scale/colorUtils.js +184 -0
- package/dist/src/scale/glslScaleGenerator.d.ts +45 -0
- package/dist/src/scale/glslScaleGenerator.d.ts.map +1 -0
- package/dist/src/scale/glslScaleGenerator.js +506 -0
- package/dist/src/scale/scale.d.ts +10 -0
- package/dist/src/scale/scale.d.ts.map +1 -0
- package/dist/src/scale/scale.js +456 -0
- package/dist/src/scale/scale.test.js +324 -0
- package/dist/src/scale/ticks.d.ts +47 -0
- package/dist/src/scale/ticks.d.ts.map +1 -0
- package/dist/src/scale/ticks.js +203 -0
- package/dist/src/scale/ticks.test.js +40 -0
- package/dist/src/singlePageApp.d.ts +2 -0
- package/dist/src/singlePageApp.d.ts.map +1 -0
- package/dist/src/singlePageApp.js +13 -0
- package/dist/src/spec/axis.d.ts +402 -0
- package/dist/src/spec/channel.d.ts +440 -0
- package/dist/src/spec/data.d.ts +370 -0
- package/dist/src/spec/font.d.ts +15 -0
- package/dist/src/spec/genome.d.ts +35 -0
- package/dist/src/spec/mark.d.ts +435 -0
- package/dist/src/spec/root.d.ts +22 -0
- package/dist/src/spec/sampleView.d.ts +185 -0
- package/dist/src/spec/scale.d.ts +273 -0
- package/dist/src/spec/title.d.ts +102 -0
- package/dist/src/spec/tooltip.d.ts +9 -0
- package/dist/src/spec/transform.d.ts +504 -0
- package/dist/src/spec/view.d.ts +214 -0
- package/dist/src/styles/genome-spy.css.d.ts +3 -0
- package/dist/src/styles/genome-spy.css.d.ts.map +1 -0
- package/dist/src/styles/genome-spy.css.js +114 -0
- package/dist/src/styles/genome-spy.scss +153 -0
- package/dist/src/tooltip/dataTooltipHandler.d.ts +2 -0
- package/dist/src/tooltip/dataTooltipHandler.d.ts.map +1 -0
- package/dist/src/tooltip/dataTooltipHandler.js +64 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +2 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts.map +1 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.js +78 -0
- package/dist/src/tooltip/tooltipHandler.d.ts +9 -0
- package/dist/src/tooltip/tooltipHandler.d.ts.map +1 -0
- package/dist/src/tooltip/tooltipHandler.ts +12 -0
- package/dist/src/types/bmFont.d.ts +58 -0
- package/dist/src/types/embedApi.d.ts +67 -0
- package/dist/src/types/encoder.d.ts +84 -0
- package/dist/src/types/flowBatch.d.ts +40 -0
- package/dist/src/types/rendering.d.ts +65 -0
- package/dist/src/types/scaleResolutionApi.d.ts +40 -0
- package/dist/src/types/viewContext.d.ts +85 -0
- package/dist/src/utils/addBaseUrl.d.ts +6 -0
- package/dist/src/utils/addBaseUrl.d.ts.map +1 -0
- package/dist/src/utils/addBaseUrl.js +19 -0
- package/dist/src/utils/addBaseUrl.test.js +22 -0
- package/dist/src/utils/animator.d.ts +41 -0
- package/dist/src/utils/animator.d.ts.map +1 -0
- package/dist/src/utils/animator.js +83 -0
- package/dist/src/utils/arrayUtils.d.ts +34 -0
- package/dist/src/utils/arrayUtils.d.ts.map +1 -0
- package/dist/src/utils/arrayUtils.js +61 -0
- package/dist/src/utils/binnedIndex.d.ts +23 -0
- package/dist/src/utils/binnedIndex.d.ts.map +1 -0
- package/dist/src/utils/binnedIndex.js +167 -0
- package/dist/src/utils/binnedIndex.test.js +155 -0
- package/dist/src/utils/clamp.d.ts +7 -0
- package/dist/src/utils/clamp.d.ts.map +1 -0
- package/dist/src/utils/clamp.js +8 -0
- package/dist/src/utils/cloner.d.ts +16 -0
- package/dist/src/utils/cloner.d.ts.map +1 -0
- package/dist/src/utils/cloner.js +34 -0
- package/dist/src/utils/cloner.test.js +24 -0
- package/dist/src/utils/coalesce.d.ts +6 -0
- package/dist/src/utils/coalesce.d.ts.map +1 -0
- package/dist/src/utils/coalesce.js +11 -0
- package/dist/src/utils/coalesce.test.js +16 -0
- package/dist/src/utils/concatIterables.d.ts +8 -0
- package/dist/src/utils/concatIterables.d.ts.map +1 -0
- package/dist/src/utils/concatIterables.js +26 -0
- package/dist/src/utils/concatIterables.test.js +8 -0
- package/dist/src/utils/debounce.d.ts +8 -0
- package/dist/src/utils/debounce.d.ts.map +1 -0
- package/dist/src/utils/debounce.js +37 -0
- package/dist/src/utils/domainArray.d.ts +61 -0
- package/dist/src/utils/domainArray.d.ts.map +1 -0
- package/dist/src/utils/domainArray.js +216 -0
- package/dist/src/utils/domainArray.test.js +130 -0
- package/dist/src/utils/eerp.d.ts +12 -0
- package/dist/src/utils/eerp.d.ts.map +1 -0
- package/dist/src/utils/eerp.js +13 -0
- package/dist/src/utils/expression.d.ts +9 -0
- package/dist/src/utils/expression.d.ts.map +1 -0
- package/dist/src/utils/expression.js +32 -0
- package/dist/src/utils/field.d.ts +17 -0
- package/dist/src/utils/field.d.ts.map +1 -0
- package/dist/src/utils/field.js +28 -0
- package/dist/src/utils/formatObject.d.ts +7 -0
- package/dist/src/utils/formatObject.d.ts.map +1 -0
- package/dist/src/utils/formatObject.js +37 -0
- package/dist/src/utils/indexer.d.ts +16 -0
- package/dist/src/utils/indexer.d.ts.map +1 -0
- package/dist/src/utils/indexer.js +43 -0
- package/dist/src/utils/indexer.test.js +47 -0
- package/dist/src/utils/inertia.d.ts +42 -0
- package/dist/src/utils/inertia.d.ts.map +1 -0
- package/dist/src/utils/inertia.js +124 -0
- package/dist/src/utils/interactionEvent.d.ts +26 -0
- package/dist/src/utils/interactionEvent.d.ts.map +1 -0
- package/dist/src/utils/interactionEvent.js +33 -0
- package/dist/src/utils/iterateNestedMaps.d.ts +11 -0
- package/dist/src/utils/iterateNestedMaps.d.ts.map +1 -0
- package/dist/src/utils/iterateNestedMaps.js +21 -0
- package/dist/src/utils/iterateNestedMaps.test.js +33 -0
- package/dist/src/utils/kWayMerge.d.ts +9 -0
- package/dist/src/utils/kWayMerge.d.ts.map +1 -0
- package/dist/src/utils/kWayMerge.js +42 -0
- package/dist/src/utils/kWayMerge.test.js +26 -0
- package/dist/src/utils/layout/flexLayout.d.ts +182 -0
- package/dist/src/utils/layout/flexLayout.d.ts.map +1 -0
- package/dist/src/utils/layout/flexLayout.js +381 -0
- package/dist/src/utils/layout/flexLayout.test.js +323 -0
- package/dist/src/utils/layout/grid.d.ts +29 -0
- package/dist/src/utils/layout/grid.d.ts.map +1 -0
- package/dist/src/utils/layout/grid.js +95 -0
- package/dist/src/utils/layout/grid.test.js +71 -0
- package/dist/src/utils/layout/padding.d.ts +83 -0
- package/dist/src/utils/layout/padding.d.ts.map +1 -0
- package/dist/src/utils/layout/padding.js +155 -0
- package/dist/src/utils/layout/point.d.ts +16 -0
- package/dist/src/utils/layout/point.d.ts.map +1 -0
- package/dist/src/utils/layout/point.js +23 -0
- package/dist/src/utils/layout/rectangle.d.ts +142 -0
- package/dist/src/utils/layout/rectangle.d.ts.map +1 -0
- package/dist/src/utils/layout/rectangle.js +296 -0
- package/dist/src/utils/layout/rectangle.test.js +172 -0
- package/dist/src/utils/mergeObjects.d.ts +15 -0
- package/dist/src/utils/mergeObjects.d.ts.map +1 -0
- package/dist/src/utils/mergeObjects.js +99 -0
- package/dist/src/utils/mergeObjects.test.js +42 -0
- package/dist/src/utils/numberExtractor.d.ts +9 -0
- package/dist/src/utils/numberExtractor.d.ts.map +1 -0
- package/dist/src/utils/numberExtractor.js +24 -0
- package/dist/src/utils/numberExtractor.test.js +6 -0
- package/dist/src/utils/point.d.ts +9 -0
- package/dist/src/utils/point.d.ts.map +1 -0
- package/dist/src/utils/point.js +14 -0
- package/dist/src/utils/propertyCacher.d.ts +30 -0
- package/dist/src/utils/propertyCacher.d.ts.map +1 -0
- package/dist/src/utils/propertyCacher.js +70 -0
- package/dist/src/utils/propertyCacher.test.js +85 -0
- package/dist/src/utils/propertyCoalescer.d.ts +15 -0
- package/dist/src/utils/propertyCoalescer.d.ts.map +1 -0
- package/dist/src/utils/propertyCoalescer.js +42 -0
- package/dist/src/utils/propertyCoalescer.test.js +22 -0
- package/dist/src/utils/reservationMap.d.ts +42 -0
- package/dist/src/utils/reservationMap.d.ts.map +1 -0
- package/dist/src/utils/reservationMap.js +103 -0
- package/dist/src/utils/reservationMap.test.js +20 -0
- package/dist/src/utils/scaleNull.d.ts +13 -0
- package/dist/src/utils/scaleNull.d.ts.map +1 -0
- package/dist/src/utils/scaleNull.js +21 -0
- package/dist/src/utils/setOperations.d.ts +31 -0
- package/dist/src/utils/setOperations.d.ts.map +1 -0
- package/dist/src/utils/setOperations.js +75 -0
- package/dist/src/utils/smoothstep.d.ts +7 -0
- package/dist/src/utils/smoothstep.d.ts.map +1 -0
- package/dist/src/utils/smoothstep.js +10 -0
- package/dist/src/utils/throttle.d.ts +8 -0
- package/dist/src/utils/throttle.d.ts.map +1 -0
- package/dist/src/utils/throttle.js +34 -0
- package/dist/src/utils/topK.d.ts +22 -0
- package/dist/src/utils/topK.d.ts.map +1 -0
- package/dist/src/utils/topK.js +76 -0
- package/dist/src/utils/topK.test.js +64 -0
- package/dist/src/utils/transition.d.ts +44 -0
- package/dist/src/utils/transition.d.ts.map +1 -0
- package/dist/src/utils/transition.js +74 -0
- package/dist/src/utils/trees.d.ts +56 -0
- package/dist/src/utils/trees.d.ts.map +1 -0
- package/dist/src/utils/trees.js +92 -0
- package/dist/src/utils/trees.test.js +130 -0
- package/dist/src/utils/ui/tooltip.d.ts +50 -0
- package/dist/src/utils/ui/tooltip.d.ts.map +1 -0
- package/dist/src/utils/ui/tooltip.js +189 -0
- package/dist/src/utils/url.d.ts +9 -0
- package/dist/src/utils/url.d.ts.map +1 -0
- package/dist/src/utils/url.js +22 -0
- package/dist/src/utils/variableTools.d.ts +14 -0
- package/dist/src/utils/variableTools.d.ts.map +1 -0
- package/dist/src/utils/variableTools.js +24 -0
- package/dist/src/utils/variableTools.test.js +13 -0
- package/dist/src/view/axisGridView.d.ts +39 -0
- package/dist/src/view/axisGridView.d.ts.map +1 -0
- package/dist/src/view/axisGridView.js +246 -0
- package/dist/src/view/axisResolution.d.ts +24 -0
- package/dist/src/view/axisResolution.d.ts.map +1 -0
- package/dist/src/view/axisResolution.js +141 -0
- package/dist/src/view/axisResolution.test.js +201 -0
- package/dist/src/view/axisView.d.ts +49 -0
- package/dist/src/view/axisView.d.ts.map +1 -0
- package/dist/src/view/axisView.js +629 -0
- package/dist/src/view/concatView.d.ts +16 -0
- package/dist/src/view/concatView.d.ts.map +1 -0
- package/dist/src/view/concatView.js +84 -0
- package/dist/src/view/containerView.d.ts +43 -0
- package/dist/src/view/containerView.d.ts.map +1 -0
- package/dist/src/view/containerView.js +137 -0
- package/dist/src/view/facetView.d.ts +71 -0
- package/dist/src/view/facetView.d.ts.map +1 -0
- package/dist/src/view/facetView.js +492 -0
- package/dist/src/view/flowBuilder.d.ts +37 -0
- package/dist/src/view/flowBuilder.d.ts.map +1 -0
- package/dist/src/view/flowBuilder.js +383 -0
- package/dist/src/view/flowBuilder.test.js +125 -0
- package/dist/src/view/gridView.d.ts +111 -0
- package/dist/src/view/gridView.d.ts.map +1 -0
- package/dist/src/view/gridView.js +1086 -0
- package/dist/src/view/implicitRootView.d.ts +9 -0
- package/dist/src/view/implicitRootView.d.ts.map +1 -0
- package/dist/src/view/implicitRootView.js +23 -0
- package/dist/src/view/importView.d.ts +17 -0
- package/dist/src/view/importView.d.ts.map +1 -0
- package/dist/src/view/importView.js +22 -0
- package/dist/src/view/layerView.d.ts +25 -0
- package/dist/src/view/layerView.d.ts.map +1 -0
- package/dist/src/view/layerView.js +77 -0
- package/dist/src/view/renderingContext/bufferedViewRenderingContext.d.ts +30 -0
- package/dist/src/view/renderingContext/bufferedViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/bufferedViewRenderingContext.js +175 -0
- package/dist/src/view/renderingContext/compositeViewRenderingContext.d.ts +14 -0
- package/dist/src/view/renderingContext/compositeViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/compositeViewRenderingContext.js +51 -0
- package/dist/src/view/renderingContext/debuggingViewRenderingContext.d.ts +51 -0
- package/dist/src/view/renderingContext/debuggingViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/debuggingViewRenderingContext.js +94 -0
- package/dist/src/view/renderingContext/layoutRecorderViewRenderingContext.d.ts +60 -0
- package/dist/src/view/renderingContext/layoutRecorderViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/layoutRecorderViewRenderingContext.js +128 -0
- package/dist/src/view/renderingContext/simpleViewRenderingContext.d.ts +19 -0
- package/dist/src/view/renderingContext/simpleViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/simpleViewRenderingContext.js +64 -0
- package/dist/src/view/renderingContext/svgViewRenderingContext.d.ts +22 -0
- package/dist/src/view/renderingContext/svgViewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/svgViewRenderingContext.js +125 -0
- package/dist/src/view/renderingContext/viewRenderingContext.d.ts +33 -0
- package/dist/src/view/renderingContext/viewRenderingContext.d.ts.map +1 -0
- package/dist/src/view/renderingContext/viewRenderingContext.js +41 -0
- package/dist/src/view/scaleResolution.d.ts +170 -0
- package/dist/src/view/scaleResolution.d.ts.map +1 -0
- package/dist/src/view/scaleResolution.js +874 -0
- package/dist/src/view/scaleResolution.test.js +658 -0
- package/dist/src/view/testUtils.d.ts +30 -0
- package/dist/src/view/testUtils.d.ts.map +1 -0
- package/dist/src/view/testUtils.js +101 -0
- package/dist/src/view/title.d.ts +6 -0
- package/dist/src/view/title.d.ts.map +1 -0
- package/dist/src/view/title.js +165 -0
- package/dist/src/view/unitView.d.ts +93 -0
- package/dist/src/view/unitView.d.ts.map +1 -0
- package/dist/src/view/unitView.js +345 -0
- package/dist/src/view/view.d.ts +291 -0
- package/dist/src/view/view.d.ts.map +1 -0
- package/dist/src/view/view.js +691 -0
- package/dist/src/view/view.test.js +214 -0
- package/dist/src/view/viewFactory.d.ts +76 -0
- package/dist/src/view/viewFactory.d.ts.map +1 -0
- package/dist/src/view/viewFactory.js +178 -0
- package/dist/src/view/viewFactory.test.js +17 -0
- package/dist/src/view/viewUtils.d.ts +90 -0
- package/dist/src/view/viewUtils.d.ts.map +1 -0
- package/dist/src/view/viewUtils.js +326 -0
- package/dist/src/view/zoom.d.ts +23 -0
- package/dist/src/view/zoom.d.ts.map +1 -0
- package/dist/src/view/zoom.js +89 -0
- package/package.json +15 -12
- package/dist/style.css +0 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects (materializes) the data that flows through this node.
|
|
3
|
+
* The collected data can be optionally grouped and sorted.
|
|
4
|
+
*
|
|
5
|
+
* Grouping is primarily intended for handling faceted data.
|
|
6
|
+
*/
|
|
7
|
+
export default class Collector extends FlowNode {
|
|
8
|
+
/**
|
|
9
|
+
* @param {import("../spec/transform").CollectParams} [params]
|
|
10
|
+
*/
|
|
11
|
+
constructor(params?: import("../spec/transform").CollectParams);
|
|
12
|
+
params: import("../spec/transform").CollectParams;
|
|
13
|
+
/** @type {(function(Collector):void)[]} */
|
|
14
|
+
observers: ((arg0: Collector) => void)[];
|
|
15
|
+
/** @type {Map<any | any[], import("./flowNode").Data>} TODO: proper type for key */
|
|
16
|
+
facetBatches: Map<any | any[], import("./flowNode").Data>;
|
|
17
|
+
_init(): void;
|
|
18
|
+
/** @type {import("./flowNode").Data} */
|
|
19
|
+
_data: import("./flowNode").Data;
|
|
20
|
+
/**
|
|
21
|
+
* @returns {Iterable<import("./flowNode").Datum>}
|
|
22
|
+
*/
|
|
23
|
+
getData(): Iterable<import("./flowNode").Datum>;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {(datum: import("./flowNode").Datum) => void} visitor
|
|
27
|
+
*/
|
|
28
|
+
visitData(visitor: (datum: import("./flowNode").Datum) => void): void;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the total number of data items collected.
|
|
31
|
+
*/
|
|
32
|
+
getItemCount(): number;
|
|
33
|
+
_checkStatus(): void;
|
|
34
|
+
}
|
|
35
|
+
import FlowNode from "./flowNode";
|
|
36
|
+
//# sourceMappingURL=collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../../src/data/collector.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH;IAKI;;OAEG;IACH,qBAFW,OAAO,mBAAmB,EAAE,aAAa,EAcnD;IATG,kDAA2C;IAE3C,2CAA2C;IAC3C,mBADqB,SAAS,KAAE,IAAI,IACjB;IAEnB,oFAAoF;IACpF,cADW,IAAI,GAAG,GAAG,GAAG,EAAE,EAAE,OAAO,YAAY,EAAE,IAAI,CAAC,CACzB;IAKjC,cAOC;IANG,wCAAwC;IACxC,OADW,OAAO,YAAY,EAAE,IAAI,CACrB;IAuFnB;;OAEG;IACH,WAFa,SAAS,OAAO,YAAY,EAAE,KAAK,CAAC,CAuBhD;IAED;;;OAGG;IACH,2BAFmB,OAAO,YAAY,EAAE,KAAK,KAAK,IAAI,QAUrD;IAED;;OAEG;IACH,uBAMC;IAED,qBAMC;CACJ;qBAnLyD,YAAY"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { InternMap } from "internmap";
|
|
2
|
+
import { group } from "d3-array";
|
|
3
|
+
import { compare } from "vega-util";
|
|
4
|
+
import iterateNestedMaps from "../utils/iterateNestedMaps";
|
|
5
|
+
import FlowNode, { BEHAVIOR_COLLECTS, isFacetBatch } from "./flowNode";
|
|
6
|
+
import { field } from "../utils/field";
|
|
7
|
+
import { asArray } from "../utils/arrayUtils";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Collects (materializes) the data that flows through this node.
|
|
11
|
+
* The collected data can be optionally grouped and sorted.
|
|
12
|
+
*
|
|
13
|
+
* Grouping is primarily intended for handling faceted data.
|
|
14
|
+
*/
|
|
15
|
+
export default class Collector extends FlowNode {
|
|
16
|
+
get behavior() {
|
|
17
|
+
return BEHAVIOR_COLLECTS;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {import("../spec/transform").CollectParams} [params]
|
|
22
|
+
*/
|
|
23
|
+
constructor(params) {
|
|
24
|
+
super();
|
|
25
|
+
|
|
26
|
+
this.params = params ?? { type: "collect" };
|
|
27
|
+
|
|
28
|
+
/** @type {(function(Collector):void)[]} */
|
|
29
|
+
this.observers = [];
|
|
30
|
+
|
|
31
|
+
/** @type {Map<any | any[], import("./flowNode").Data>} TODO: proper type for key */
|
|
32
|
+
this.facetBatches = undefined;
|
|
33
|
+
|
|
34
|
+
this._init();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_init() {
|
|
38
|
+
/** @type {import("./flowNode").Data} */
|
|
39
|
+
this._data = [];
|
|
40
|
+
|
|
41
|
+
// TODO: Consider nested maps
|
|
42
|
+
this.facetBatches = new InternMap([], JSON.stringify);
|
|
43
|
+
this.facetBatches.set(undefined, this._data);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
reset() {
|
|
47
|
+
super.reset();
|
|
48
|
+
this._init();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param {import("./flowNode").Datum} datum
|
|
54
|
+
*/
|
|
55
|
+
handle(datum) {
|
|
56
|
+
this._data.push(datum);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {import("../types/flowBatch").FlowBatch} flowBatch
|
|
61
|
+
*/
|
|
62
|
+
beginBatch(flowBatch) {
|
|
63
|
+
if (isFacetBatch(flowBatch)) {
|
|
64
|
+
this._data = [];
|
|
65
|
+
this.facetBatches.set(asArray(flowBatch.facetId), this._data);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
complete() {
|
|
70
|
+
const sort = this.params?.sort;
|
|
71
|
+
// Vega's "compare" function is incredibly slow (uses megamorphic field accessor)
|
|
72
|
+
// TODO: Implement a replacement for static data types
|
|
73
|
+
const comparator = sort ? compare(sort.field, sort.order) : undefined;
|
|
74
|
+
|
|
75
|
+
/** @param {any[]} data */
|
|
76
|
+
const sortData = (data) => {
|
|
77
|
+
if (comparator) {
|
|
78
|
+
data.sort(comparator);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
if (this.params.groupby?.length) {
|
|
83
|
+
if (this.facetBatches.size > 1) {
|
|
84
|
+
throw new Error("TODO: Support faceted data!");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const accessors = this.params.groupby.map((fieldName) =>
|
|
88
|
+
field(fieldName)
|
|
89
|
+
);
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
const groups = group(this._data, ...accessors);
|
|
92
|
+
|
|
93
|
+
this.facetBatches.clear();
|
|
94
|
+
for (const [key, data] of iterateNestedMaps(groups)) {
|
|
95
|
+
this.facetBatches.set(key, data);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const data of this.facetBatches.values()) {
|
|
100
|
+
// TODO: Only sort if not already sorted
|
|
101
|
+
sortData(data);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.children.length) {
|
|
105
|
+
for (const [key, data] of this.facetBatches.entries()) {
|
|
106
|
+
if (key) {
|
|
107
|
+
/** @type {import("../types/flowBatch").FacetBatch} */
|
|
108
|
+
const facetBatch = { type: "facet", facetId: key };
|
|
109
|
+
for (const child of this.children) {
|
|
110
|
+
child.beginBatch(facetBatch);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const datum of data) {
|
|
114
|
+
this._propagate(datum);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
super.complete();
|
|
120
|
+
|
|
121
|
+
for (const observer of this.observers) {
|
|
122
|
+
observer(this);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @returns {Iterable<import("./flowNode").Datum>}
|
|
128
|
+
*/
|
|
129
|
+
getData() {
|
|
130
|
+
this._checkStatus();
|
|
131
|
+
|
|
132
|
+
switch (this.facetBatches.size) {
|
|
133
|
+
case 0:
|
|
134
|
+
return [];
|
|
135
|
+
case 1:
|
|
136
|
+
return [...this.facetBatches.values()][0];
|
|
137
|
+
default: {
|
|
138
|
+
const groups = this.facetBatches;
|
|
139
|
+
return {
|
|
140
|
+
[Symbol.iterator]: function* generator() {
|
|
141
|
+
for (const data of groups.values()) {
|
|
142
|
+
for (let i = 0; i < data.length; i++) {
|
|
143
|
+
yield data[i];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
*
|
|
154
|
+
* @param {(datum: import("./flowNode").Datum) => void} visitor
|
|
155
|
+
*/
|
|
156
|
+
visitData(visitor) {
|
|
157
|
+
this._checkStatus();
|
|
158
|
+
|
|
159
|
+
for (const data of this.facetBatches.values()) {
|
|
160
|
+
for (let i = 0; i < data.length; i++) {
|
|
161
|
+
visitor(data[i]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Returns the total number of data items collected.
|
|
168
|
+
*/
|
|
169
|
+
getItemCount() {
|
|
170
|
+
let count = 0;
|
|
171
|
+
for (const data of this.facetBatches.values()) {
|
|
172
|
+
count += data.length;
|
|
173
|
+
}
|
|
174
|
+
return count;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_checkStatus() {
|
|
178
|
+
if (!this.completed) {
|
|
179
|
+
throw new Error(
|
|
180
|
+
"Data propagation is not completed! No data are available."
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { expect, test } from "vitest";
|
|
2
|
+
|
|
3
|
+
import Collector from "./collector";
|
|
4
|
+
|
|
5
|
+
const data = [1, 5, 2, 4, 3].map((x) => ({ x }));
|
|
6
|
+
|
|
7
|
+
test("Collector collects data", () => {
|
|
8
|
+
const collector = new Collector();
|
|
9
|
+
|
|
10
|
+
for (const d of data) {
|
|
11
|
+
collector.handle(d);
|
|
12
|
+
}
|
|
13
|
+
collector.complete();
|
|
14
|
+
|
|
15
|
+
expect(collector.getData()).toEqual(data);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("Collector collects and sorts data", () => {
|
|
19
|
+
const collector = new Collector({
|
|
20
|
+
type: "collect",
|
|
21
|
+
sort: { field: ["x"] },
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
for (const d of data) {
|
|
25
|
+
collector.handle(d);
|
|
26
|
+
}
|
|
27
|
+
collector.complete();
|
|
28
|
+
|
|
29
|
+
expect([...collector.getData()]).toEqual(
|
|
30
|
+
[1, 2, 3, 4, 5].map((x) => ({ x }))
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("Collector collects, groups, and sorts data", () => {
|
|
35
|
+
const collector = new Collector({
|
|
36
|
+
type: "collect",
|
|
37
|
+
sort: { field: ["x"] },
|
|
38
|
+
groupby: ["a", "b"],
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const data = [
|
|
42
|
+
{ a: 1, b: 1, x: 1 },
|
|
43
|
+
{ a: 1, b: 2, x: 2 },
|
|
44
|
+
{ a: 1, b: 2, x: 3 },
|
|
45
|
+
{ a: 2, b: 1, x: 4 },
|
|
46
|
+
{ a: 2, b: 1, x: 5 },
|
|
47
|
+
{ a: 2, b: 2, x: 6 },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
for (const d of data) {
|
|
51
|
+
collector.handle(d);
|
|
52
|
+
}
|
|
53
|
+
collector.complete();
|
|
54
|
+
|
|
55
|
+
const cd = [...collector.getData()];
|
|
56
|
+
|
|
57
|
+
expect(cd.map((d) => ({ x: d.x }))).toEqual(
|
|
58
|
+
[1, 2, 3, 4, 5, 6].map((x) => ({ x }))
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
/** @param {any[]} group*/
|
|
62
|
+
const getGroupX = (group) =>
|
|
63
|
+
collector.facetBatches.get(group).map((d) => d.x);
|
|
64
|
+
|
|
65
|
+
expect(getGroupX([1, 1])).toEqual([1]);
|
|
66
|
+
expect(getGroupX([1, 2])).toEqual([2, 3]);
|
|
67
|
+
expect(getGroupX([2, 1])).toEqual([4, 5]);
|
|
68
|
+
expect(getGroupX([2, 2])).toEqual([6]);
|
|
69
|
+
|
|
70
|
+
expect(new Set(collector.facetBatches.keys())).toEqual(
|
|
71
|
+
new Set([
|
|
72
|
+
[1, 1],
|
|
73
|
+
[1, 2],
|
|
74
|
+
[2, 1],
|
|
75
|
+
[2, 2],
|
|
76
|
+
])
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("Collector throws on incomplete flow", () => {
|
|
81
|
+
const collector = new Collector();
|
|
82
|
+
|
|
83
|
+
expect(() => collector.getData()).toThrow();
|
|
84
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template H A key (string, object, whatever) that is used to retrieve
|
|
3
|
+
* data sources and collectors.
|
|
4
|
+
*/
|
|
5
|
+
export default class DataFlow<H> {
|
|
6
|
+
/** @type {Map<H, import("./sources/dataSource").default>} */
|
|
7
|
+
_dataSourcesByHost: Map<H, import("./sources/dataSource").default>;
|
|
8
|
+
/** @type {Map<H, import("./collector").default>} */
|
|
9
|
+
_collectorsByHost: Map<H, import("./collector").default>;
|
|
10
|
+
/** @type {Map<H, (function(import("./collector").default):void)[]>} */
|
|
11
|
+
_observers: Map<H, ((arg0: import("./collector").default) => void)[]>;
|
|
12
|
+
get dataSources(): import("./sources/dataSource").default[];
|
|
13
|
+
get collectors(): import("./collector").default[];
|
|
14
|
+
/**
|
|
15
|
+
* Adds a callback function that will be called when a collector has completed.
|
|
16
|
+
*
|
|
17
|
+
* @param {function(import("./collector").default):void} callback
|
|
18
|
+
* @param {H} key
|
|
19
|
+
*/
|
|
20
|
+
addObserver(callback: (arg0: import("./collector").default) => void, key: H): void;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {import("./collector").default} collector
|
|
24
|
+
* @param {H} key
|
|
25
|
+
*/
|
|
26
|
+
_relayObserverCallback(collector: import("./collector").default, key: H): void;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param {import("./sources/dataSource").default} dataSource
|
|
30
|
+
* @param {H} key
|
|
31
|
+
*/
|
|
32
|
+
addDataSource(dataSource: import("./sources/dataSource").default, key: H): void;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param {H} key
|
|
36
|
+
*/
|
|
37
|
+
findDataSourceByKey(key: H): import("./sources/dataSource").default;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {string} name
|
|
41
|
+
*/
|
|
42
|
+
findNamedDataSource(name: string): {
|
|
43
|
+
dataSource: NamedSource;
|
|
44
|
+
hosts: H[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param {import("./collector").default} collector
|
|
49
|
+
* @param {H} key
|
|
50
|
+
*/
|
|
51
|
+
addCollector(collector: import("./collector").default, key: H): void;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param {H} key
|
|
55
|
+
*/
|
|
56
|
+
findCollectorByKey(key: H): import("./collector").default;
|
|
57
|
+
/**
|
|
58
|
+
* Allows the flow nodes to perform final initialization after the flow
|
|
59
|
+
* structure has been built and optimized.
|
|
60
|
+
* Must be called before any data are to be propagated.
|
|
61
|
+
*/
|
|
62
|
+
initialize(): void;
|
|
63
|
+
}
|
|
64
|
+
import NamedSource from "./sources/namedSource";
|
|
65
|
+
//# sourceMappingURL=dataFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataFlow.d.ts","sourceRoot":"","sources":["../../../src/data/dataFlow.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IAEQ,6DAA6D;IAC7D,oBADW,IAAI,CAAC,EAAE,OAAO,sBAAsB,EAAE,OAAO,CAAC,CACtB;IAEnC,oDAAoD;IACpD,mBADW,IAAI,CAAC,EAAE,OAAO,aAAa,EAAE,OAAO,CAAC,CACd;IAElC,uEAAuE;IACvE,2BAD4B,OAAO,aAAa,EAAE,OAAO,KAAE,IAAI,KACpC;IAG/B,4DAEC;IAED,kDAEC;IAED;;;;;OAKG;IACH,6BAHoB,OAAO,aAAa,EAAE,OAAO,KAAE,IAAI,OAC5C,CAAC,QAUX;IAED;;;;OAIG;IACH,kCAHW,OAAO,aAAa,EAAE,OAAO,OAC7B,CAAC,QAUX;IAED;;;;OAIG;IACH,0BAHW,OAAO,sBAAsB,EAAE,OAAO,OACtC,CAAC,QAIX;IAED;;;OAGG;IACH,yBAFW,CAAC,0CAIX;IAED;;;OAGG;IACH,0BAFW,MAAM;;;MAiChB;IAED;;;;OAIG;IACH,wBAHW,OAAO,aAAa,EAAE,OAAO,OAC7B,CAAC,QAOX;IAED;;;OAGG;IACH,wBAFW,CAAC,iCAIX;IAED;;;;OAIG;IACH,mBAIC;CACJ;wBA7IuB,uBAAuB"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import NamedSource from "./sources/namedSource";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @template H A key (string, object, whatever) that is used to retrieve
|
|
5
|
+
* data sources and collectors.
|
|
6
|
+
*/
|
|
7
|
+
export default class DataFlow {
|
|
8
|
+
constructor() {
|
|
9
|
+
/** @type {Map<H, import("./sources/dataSource").default>} */
|
|
10
|
+
this._dataSourcesByHost = new Map();
|
|
11
|
+
|
|
12
|
+
/** @type {Map<H, import("./collector").default>} */
|
|
13
|
+
this._collectorsByHost = new Map();
|
|
14
|
+
|
|
15
|
+
/** @type {Map<H, (function(import("./collector").default):void)[]>} */
|
|
16
|
+
this._observers = new Map();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get dataSources() {
|
|
20
|
+
return [...new Set(this._dataSourcesByHost.values()).values()];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get collectors() {
|
|
24
|
+
return [...this._collectorsByHost.values()];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Adds a callback function that will be called when a collector has completed.
|
|
29
|
+
*
|
|
30
|
+
* @param {function(import("./collector").default):void} callback
|
|
31
|
+
* @param {H} key
|
|
32
|
+
*/
|
|
33
|
+
addObserver(callback, key) {
|
|
34
|
+
let arr = this._observers.get(key);
|
|
35
|
+
if (!arr) {
|
|
36
|
+
arr = [];
|
|
37
|
+
this._observers.set(key, arr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
arr.push(callback);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param {import("./collector").default} collector
|
|
46
|
+
* @param {H} key
|
|
47
|
+
*/
|
|
48
|
+
_relayObserverCallback(collector, key) {
|
|
49
|
+
const arr = this._observers.get(key);
|
|
50
|
+
if (arr) {
|
|
51
|
+
for (const callback of arr) {
|
|
52
|
+
// eslint-disable-next-line callback-return
|
|
53
|
+
callback(collector);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {import("./sources/dataSource").default} dataSource
|
|
61
|
+
* @param {H} key
|
|
62
|
+
*/
|
|
63
|
+
addDataSource(dataSource, key) {
|
|
64
|
+
this._dataSourcesByHost.set(key, dataSource);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param {H} key
|
|
70
|
+
*/
|
|
71
|
+
findDataSourceByKey(key) {
|
|
72
|
+
return this._dataSourcesByHost.get(key);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param {string} name
|
|
78
|
+
*/
|
|
79
|
+
findNamedDataSource(name) {
|
|
80
|
+
/** @type {NamedSource} */
|
|
81
|
+
let namedSource;
|
|
82
|
+
/** @type {H[]} */
|
|
83
|
+
let hosts = [];
|
|
84
|
+
|
|
85
|
+
// Note: If a named sources with the same name are present at multiple locations in the
|
|
86
|
+
// view hierarchy, the should actually be exactly the same instance. It's arranged that
|
|
87
|
+
// way in the data flow optimization phase.
|
|
88
|
+
|
|
89
|
+
for (const [host, dataSource] of this._dataSourcesByHost.entries()) {
|
|
90
|
+
if (dataSource instanceof NamedSource) {
|
|
91
|
+
if (name == dataSource.identifier) {
|
|
92
|
+
if (namedSource && namedSource !== dataSource) {
|
|
93
|
+
// TODO: Write a test case for this and remove the runtime check.
|
|
94
|
+
throw new Error(
|
|
95
|
+
`Found multiple instances of named data: ${name}. Data flow optimization is broken (it's a bug).`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
namedSource = dataSource;
|
|
99
|
+
hosts.push(host);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (namedSource) {
|
|
105
|
+
return {
|
|
106
|
+
dataSource: namedSource,
|
|
107
|
+
hosts,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
*
|
|
114
|
+
* @param {import("./collector").default} collector
|
|
115
|
+
* @param {H} key
|
|
116
|
+
*/
|
|
117
|
+
addCollector(collector, key) {
|
|
118
|
+
this._collectorsByHost.set(key, collector);
|
|
119
|
+
collector.observers.push((collector) =>
|
|
120
|
+
this._relayObserverCallback(collector, key)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @param {H} key
|
|
127
|
+
*/
|
|
128
|
+
findCollectorByKey(key) {
|
|
129
|
+
return this._collectorsByHost.get(key);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Allows the flow nodes to perform final initialization after the flow
|
|
134
|
+
* structure has been built and optimized.
|
|
135
|
+
* Must be called before any data are to be propagated.
|
|
136
|
+
*/
|
|
137
|
+
initialize() {
|
|
138
|
+
for (const ds of this.dataSources) {
|
|
139
|
+
ds.visit((node) => node.initialize());
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} FacetParams
|
|
3
|
+
* @prop {string[]} groupby
|
|
4
|
+
*/
|
|
5
|
+
export default class FacetNode extends FlowNode {
|
|
6
|
+
/**
|
|
7
|
+
* @param {FacetParams} params
|
|
8
|
+
*/
|
|
9
|
+
constructor(params: FacetParams);
|
|
10
|
+
/** @type {Map<any | any[], FlowNode>} */
|
|
11
|
+
subflows: Map<any | any[], FlowNode>;
|
|
12
|
+
}
|
|
13
|
+
export type FacetParams = {
|
|
14
|
+
groupby: string[];
|
|
15
|
+
};
|
|
16
|
+
import FlowNode from "./flowNode";
|
|
17
|
+
//# sourceMappingURL=facetNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facetNode.d.ts","sourceRoot":"","sources":["../../../src/data/facetNode.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IACI;;OAEG;IACH,oBAFW,WAAW,EAOrB;IAFG,yCAAyC;IACzC,UADW,IAAI,GAAG,GAAG,GAAG,EAAE,EAAE,QAAQ,CAAC,CACZ;CAEhC;;aAZS,MAAM,EAAE;;qBAJG,YAAY"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import FlowNode from "./flowNode";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {object} FacetParams
|
|
5
|
+
* @prop {string[]} groupby
|
|
6
|
+
*/
|
|
7
|
+
export default class FacetNode extends FlowNode {
|
|
8
|
+
/**
|
|
9
|
+
* @param {FacetParams} params
|
|
10
|
+
*/
|
|
11
|
+
constructor(params) {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
/** @type {Map<any | any[], FlowNode>} */
|
|
15
|
+
this.subflows = new Map();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import FilterTransform from "./transforms/filter";
|
|
3
|
+
import FormulaTransform from "./transforms/formula";
|
|
4
|
+
import Collector from "./collector";
|
|
5
|
+
import { SynchronousSequenceSource } from "./flowTestUtils";
|
|
6
|
+
|
|
7
|
+
describe("Test flow graphs", () => {
|
|
8
|
+
test("Trivial graph: sequence to collector", () => {
|
|
9
|
+
const source = new SynchronousSequenceSource(5);
|
|
10
|
+
const collector = new Collector();
|
|
11
|
+
source.addChild(collector);
|
|
12
|
+
|
|
13
|
+
source.dispatch();
|
|
14
|
+
|
|
15
|
+
expect(collector.getData()).toEqual(
|
|
16
|
+
[0, 1, 2, 3, 4].map((d) => ({
|
|
17
|
+
data: d,
|
|
18
|
+
}))
|
|
19
|
+
);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("Trivial branching: sequence to two collectors", () => {
|
|
23
|
+
const source = new SynchronousSequenceSource(5);
|
|
24
|
+
const collector1 = new Collector();
|
|
25
|
+
source.addChild(collector1);
|
|
26
|
+
const collector2 = new Collector();
|
|
27
|
+
source.addChild(collector2);
|
|
28
|
+
|
|
29
|
+
source.dispatch();
|
|
30
|
+
|
|
31
|
+
expect(collector1.getData()).not.toBe(collector2._data);
|
|
32
|
+
|
|
33
|
+
expect(collector1.getData()).toEqual(
|
|
34
|
+
[0, 1, 2, 3, 4].map((d) => ({
|
|
35
|
+
data: d,
|
|
36
|
+
}))
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(collector2.getData()).toEqual(
|
|
40
|
+
[0, 1, 2, 3, 4].map((d) => ({
|
|
41
|
+
data: d,
|
|
42
|
+
}))
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("Longer chain of nodes", () => {
|
|
47
|
+
const source = new SynchronousSequenceSource(10);
|
|
48
|
+
const filter = new FilterTransform({
|
|
49
|
+
type: "filter",
|
|
50
|
+
expr: "datum.data < 5",
|
|
51
|
+
});
|
|
52
|
+
const formula = new FormulaTransform({
|
|
53
|
+
type: "formula",
|
|
54
|
+
expr: "datum.data * 2",
|
|
55
|
+
as: "data",
|
|
56
|
+
});
|
|
57
|
+
const collector = new Collector();
|
|
58
|
+
|
|
59
|
+
source.addChild(filter);
|
|
60
|
+
filter.addChild(formula);
|
|
61
|
+
formula.addChild(collector);
|
|
62
|
+
|
|
63
|
+
source.visit((node) => node.initialize());
|
|
64
|
+
source.dispatch();
|
|
65
|
+
|
|
66
|
+
expect(collector.getData()).toEqual(
|
|
67
|
+
[0, 2, 4, 6, 8].map((d) => ({
|
|
68
|
+
data: d,
|
|
69
|
+
}))
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
});
|