@genome-spy/core 0.67.0 → 0.69.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/dist/bundle/index.es.js +15884 -13130
- package/dist/bundle/index.js +130 -149
- package/dist/schema.json +6498 -6191
- package/dist/src/data/collector.d.ts +20 -0
- package/dist/src/data/collector.d.ts.map +1 -1
- package/dist/src/data/collector.js +148 -0
- package/dist/src/data/dataFlow.d.ts +6 -0
- package/dist/src/data/dataFlow.d.ts.map +1 -1
- package/dist/src/data/dataFlow.js +20 -0
- package/dist/src/data/flowInit.d.ts.map +1 -1
- package/dist/src/data/flowInit.js +2 -3
- package/dist/src/data/flowNode.d.ts +33 -10
- package/dist/src/data/flowNode.d.ts.map +1 -1
- package/dist/src/data/flowNode.js +84 -13
- package/dist/src/data/flowTestUtils.d.ts +2 -2
- package/dist/src/data/flowTestUtils.d.ts.map +1 -1
- package/dist/src/data/flowTestUtils.js +5 -4
- package/dist/src/data/keyIndex.d.ts +18 -0
- package/dist/src/data/keyIndex.d.ts.map +1 -0
- package/dist/src/data/keyIndex.js +241 -0
- package/dist/src/data/keyIndex.test.d.ts +2 -0
- package/dist/src/data/keyIndex.test.d.ts.map +1 -0
- package/dist/src/data/sources/dataSource.d.ts.map +1 -1
- package/dist/src/data/sources/dataSource.js +7 -3
- package/dist/src/data/sources/dataSourceFactory.d.ts +14 -12
- package/dist/src/data/sources/dataSourceFactory.d.ts.map +1 -1
- package/dist/src/data/sources/dataSourceFactory.js +52 -16
- package/dist/src/data/sources/lazy/bigBedSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/bigBedSource.js +11 -10
- package/dist/src/data/sources/lazy/bigWigSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/bigWigSource.js +11 -10
- package/dist/src/data/sources/lazy/mockLazySource.d.ts +29 -0
- package/dist/src/data/sources/lazy/mockLazySource.d.ts.map +1 -0
- package/dist/src/data/sources/lazy/mockLazySource.js +44 -0
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +22 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisLazySource.js +34 -2
- package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +16 -1
- package/dist/src/data/sources/lazy/tabixSource.d.ts +0 -1
- package/dist/src/data/sources/lazy/tabixSource.d.ts.map +1 -1
- package/dist/src/data/sources/lazy/tabixSource.js +56 -16
- package/dist/src/data/sources/sequenceSource.d.ts.map +1 -1
- package/dist/src/data/sources/sequenceSource.js +5 -3
- package/dist/src/data/sources/urlSource.d.ts.map +1 -1
- package/dist/src/data/sources/urlSource.js +7 -3
- package/dist/src/data/transforms/filter.d.ts +4 -4
- package/dist/src/data/transforms/filter.d.ts.map +1 -1
- package/dist/src/data/transforms/filter.js +13 -7
- package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
- package/dist/src/data/transforms/filterScoredLabels.js +11 -6
- package/dist/src/data/transforms/filterScoredLabels.test.d.ts +2 -0
- package/dist/src/data/transforms/filterScoredLabels.test.d.ts.map +1 -0
- package/dist/src/data/transforms/formula.d.ts +4 -4
- package/dist/src/data/transforms/formula.d.ts.map +1 -1
- package/dist/src/data/transforms/formula.js +12 -6
- package/dist/src/data/transforms/measureText.d.ts +2 -2
- package/dist/src/data/transforms/measureText.d.ts.map +1 -1
- package/dist/src/data/transforms/measureText.js +16 -12
- package/dist/src/data/transforms/stack.d.ts.map +1 -1
- package/dist/src/data/transforms/stack.js +1 -0
- package/dist/src/data/transforms/transform.d.ts +2 -2
- package/dist/src/data/transforms/transform.d.ts.map +1 -1
- package/dist/src/data/transforms/transform.js +3 -3
- package/dist/src/encoder/accessor.d.ts +51 -4
- package/dist/src/encoder/accessor.d.ts.map +1 -1
- package/dist/src/encoder/accessor.js +174 -10
- package/dist/src/encoder/encoder.d.ts +11 -2
- package/dist/src/encoder/encoder.d.ts.map +1 -1
- package/dist/src/encoder/encoder.js +29 -9
- package/dist/src/encoder/metadataChannels.d.ts +15 -0
- package/dist/src/encoder/metadataChannels.d.ts.map +1 -0
- package/dist/src/encoder/metadataChannels.js +65 -0
- package/dist/src/encoder/metadataChannels.test.d.ts +2 -0
- package/dist/src/encoder/metadataChannels.test.d.ts.map +1 -0
- package/dist/src/genome/genome.d.ts +8 -0
- package/dist/src/genome/genome.d.ts.map +1 -1
- package/dist/src/genome/genome.js +16 -1
- package/dist/src/genome/scaleLocus.d.ts.map +1 -1
- package/dist/src/genome/scaleLocus.js +14 -1
- package/dist/src/genomeSpy/containerUi.d.ts +0 -1
- package/dist/src/genomeSpy/containerUi.d.ts.map +1 -1
- package/dist/src/genomeSpy/containerUi.js +0 -14
- package/dist/src/genomeSpy/inputBindingManager.js +1 -1
- package/dist/src/genomeSpy/interactionController.d.ts.map +1 -1
- package/dist/src/genomeSpy/interactionController.js +7 -1
- package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +3 -7
- package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -1
- package/dist/src/genomeSpy/loadingIndicatorManager.js +68 -20
- package/dist/src/genomeSpy/loadingStatusRegistry.d.ts +52 -0
- package/dist/src/genomeSpy/loadingStatusRegistry.d.ts.map +1 -0
- package/dist/src/genomeSpy/loadingStatusRegistry.js +86 -0
- package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -1
- package/dist/src/genomeSpy/viewContextFactory.js +0 -1
- package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -1
- package/dist/src/genomeSpy/viewDataInit.js +56 -11
- package/dist/src/genomeSpy.d.ts +0 -2
- package/dist/src/genomeSpy.d.ts.map +1 -1
- package/dist/src/genomeSpy.js +47 -27
- package/dist/src/gl/glslScaleGenerator.js +1 -1
- package/dist/src/marks/mark.d.ts.map +1 -1
- package/dist/src/marks/mark.js +40 -41
- package/dist/src/marks/markUtils.js +1 -1
- package/dist/src/marks/point.d.ts.map +1 -1
- package/dist/src/marks/point.js +4 -6
- package/dist/src/paramRuntime/expressionCompiler.d.ts +7 -0
- package/dist/src/paramRuntime/expressionCompiler.d.ts.map +1 -0
- package/dist/src/paramRuntime/expressionCompiler.js +10 -0
- package/dist/src/paramRuntime/expressionRef.d.ts +20 -0
- package/dist/src/paramRuntime/expressionRef.d.ts.map +1 -0
- package/dist/src/paramRuntime/expressionRef.js +95 -0
- package/dist/src/paramRuntime/expressionRef.test.d.ts +2 -0
- package/dist/src/paramRuntime/expressionRef.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/graphRuntime.d.ts +176 -0
- package/dist/src/paramRuntime/graphRuntime.d.ts.map +1 -0
- package/dist/src/paramRuntime/graphRuntime.js +628 -0
- package/dist/src/paramRuntime/graphRuntime.test.d.ts +2 -0
- package/dist/src/paramRuntime/graphRuntime.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/index.d.ts +9 -0
- package/dist/src/paramRuntime/index.d.ts.map +1 -0
- package/dist/src/paramRuntime/index.js +8 -0
- package/dist/src/paramRuntime/lifecycleRegistry.d.ts +27 -0
- package/dist/src/paramRuntime/lifecycleRegistry.d.ts.map +1 -0
- package/dist/src/paramRuntime/lifecycleRegistry.js +54 -0
- package/dist/src/paramRuntime/paramRuntime.d.ts +165 -0
- package/dist/src/paramRuntime/paramRuntime.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramRuntime.js +222 -0
- package/dist/src/paramRuntime/paramRuntime.test.d.ts +2 -0
- package/dist/src/paramRuntime/paramRuntime.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramStore.d.ts +68 -0
- package/dist/src/paramRuntime/paramStore.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramStore.js +148 -0
- package/dist/src/paramRuntime/paramStore.test.d.ts +2 -0
- package/dist/src/paramRuntime/paramStore.test.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramUtils.d.ts +86 -0
- package/dist/src/paramRuntime/paramUtils.d.ts.map +1 -0
- package/dist/src/paramRuntime/paramUtils.js +272 -0
- package/dist/src/paramRuntime/selectionStore.d.ts +6 -0
- package/dist/src/paramRuntime/selectionStore.d.ts.map +1 -0
- package/dist/src/paramRuntime/selectionStore.js +13 -0
- package/dist/src/paramRuntime/types.d.ts +16 -0
- package/dist/src/paramRuntime/types.d.ts.map +1 -0
- package/dist/src/paramRuntime/types.js +25 -0
- package/dist/src/paramRuntime/viewParamRuntime.d.ts +164 -0
- package/dist/src/paramRuntime/viewParamRuntime.d.ts.map +1 -0
- package/dist/src/paramRuntime/viewParamRuntime.js +443 -0
- package/dist/src/scale/scale.d.ts +6 -1
- package/dist/src/scale/scale.d.ts.map +1 -1
- package/dist/src/scale/scale.js +83 -23
- package/dist/src/scales/axisResolution.d.ts.map +1 -1
- package/dist/src/scales/axisResolution.js +10 -0
- package/dist/src/scales/{scaleDomainAggregator.d.ts → domainPlanner.d.ts} +6 -3
- package/dist/src/scales/domainPlanner.d.ts.map +1 -0
- package/dist/src/scales/{scaleDomainAggregator.js → domainPlanner.js} +128 -10
- package/dist/src/scales/domainPlanner.test.d.ts +2 -0
- package/dist/src/scales/domainPlanner.test.d.ts.map +1 -0
- package/dist/src/scales/scaleInstanceManager.d.ts +6 -3
- package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -1
- package/dist/src/scales/scaleInstanceManager.js +17 -11
- package/dist/src/scales/scaleInteractionController.d.ts +6 -0
- package/dist/src/scales/scaleInteractionController.d.ts.map +1 -1
- package/dist/src/scales/scaleInteractionController.js +41 -3
- package/dist/src/scales/scaleResolution.d.ts +20 -17
- package/dist/src/scales/scaleResolution.d.ts.map +1 -1
- package/dist/src/scales/scaleResolution.js +188 -71
- package/dist/src/scales/scaleResolution.test.d.ts.map +1 -1
- package/dist/src/selection/selection.d.ts +21 -0
- package/dist/src/selection/selection.d.ts.map +1 -1
- package/dist/src/selection/selection.js +83 -1
- package/dist/src/spec/channel.d.ts +52 -15
- package/dist/src/spec/coreSchemaRoot.d.ts +53 -0
- package/dist/src/spec/data.d.ts +4 -0
- package/dist/src/spec/parameter.d.ts +16 -11
- package/dist/src/spec/root.d.ts +1 -1
- package/dist/src/spec/testing.d.ts +12 -0
- package/dist/src/spec/testing.d.ts.map +1 -0
- package/dist/src/spec/testing.js +20 -0
- package/dist/src/spec/view.d.ts +157 -41
- package/dist/src/styles/genome-spy.css +3 -31
- package/dist/src/styles/genome-spy.css.d.ts +1 -1
- package/dist/src/styles/genome-spy.css.d.ts.map +1 -1
- package/dist/src/styles/genome-spy.css.js +0 -29
- package/dist/src/tooltip/dataTooltipHandler.d.ts +1 -1
- package/dist/src/tooltip/dataTooltipHandler.js +23 -32
- package/dist/src/tooltip/dataTooltipHandler.test.d.ts +2 -0
- package/dist/src/tooltip/dataTooltipHandler.test.d.ts.map +1 -0
- package/dist/src/tooltip/flattenDatumRows.d.ts +13 -0
- package/dist/src/tooltip/flattenDatumRows.d.ts.map +1 -0
- package/dist/src/tooltip/flattenDatumRows.js +47 -0
- package/dist/src/tooltip/flattenDatumRows.test.d.ts +2 -0
- package/dist/src/tooltip/flattenDatumRows.test.d.ts.map +1 -0
- package/dist/src/tooltip/refseqGeneTooltipHandler.d.ts +1 -1
- package/dist/src/tooltip/refseqGeneTooltipHandler.js +7 -1
- package/dist/src/tooltip/tooltipContext.d.ts +13 -0
- package/dist/src/tooltip/tooltipContext.d.ts.map +1 -0
- package/dist/src/tooltip/tooltipContext.js +543 -0
- package/dist/src/tooltip/tooltipContext.test.d.ts +2 -0
- package/dist/src/tooltip/tooltipContext.test.d.ts.map +1 -0
- package/dist/src/tooltip/tooltipHandler.d.ts +40 -1
- package/dist/src/tooltip/tooltipHandler.d.ts.map +1 -1
- package/dist/src/tooltip/tooltipHandler.ts +62 -1
- package/dist/src/types/encoder.d.ts +38 -3
- package/dist/src/types/rendering.d.ts +4 -3
- package/dist/src/types/viewContext.d.ts +0 -14
- package/dist/src/utils/inputBinding.d.ts +10 -2
- package/dist/src/utils/inputBinding.d.ts.map +1 -1
- package/dist/src/utils/inputBinding.js +12 -3
- package/dist/src/utils/throttle.d.ts +4 -1
- package/dist/src/utils/throttle.d.ts.map +1 -1
- package/dist/src/utils/throttle.js +54 -23
- package/dist/src/utils/throttle.test.d.ts +2 -0
- package/dist/src/utils/throttle.test.d.ts.map +1 -0
- package/dist/src/utils/transition.d.ts +21 -0
- package/dist/src/utils/transition.d.ts.map +1 -1
- package/dist/src/utils/transition.js +28 -0
- package/dist/src/utils/ui/tooltip.d.ts.map +1 -1
- package/dist/src/utils/ui/tooltip.js +7 -1
- package/dist/src/utils/ui/tooltip.test.d.ts +2 -0
- package/dist/src/utils/ui/tooltip.test.d.ts.map +1 -0
- package/dist/src/view/axisGridView.d.ts.map +1 -1
- package/dist/src/view/axisGridView.js +22 -5
- package/dist/src/view/axisView.d.ts.map +1 -1
- package/dist/src/view/axisView.js +20 -5
- package/dist/src/view/concatView.js +3 -3
- package/dist/src/view/containerMutationHelper.js +1 -1
- package/dist/src/view/containerView.d.ts +9 -5
- package/dist/src/view/containerView.d.ts.map +1 -1
- package/dist/src/view/containerView.js +34 -9
- package/dist/src/view/dataReadiness.d.ts +46 -0
- package/dist/src/view/dataReadiness.d.ts.map +1 -0
- package/dist/src/view/dataReadiness.js +267 -0
- package/dist/src/view/dataReadiness.test.d.ts +2 -0
- package/dist/src/view/dataReadiness.test.d.ts.map +1 -0
- package/dist/src/view/facetView.d.ts.map +1 -1
- package/dist/src/view/facetView.js +7 -5
- package/dist/src/view/flowBuilder.d.ts.map +1 -1
- package/dist/src/view/flowBuilder.js +17 -4
- package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
- package/dist/src/view/gridView/gridChild.js +16 -3
- package/dist/src/view/gridView/gridView.d.ts.map +1 -1
- package/dist/src/view/gridView/gridView.js +119 -2
- package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
- package/dist/src/view/gridView/scrollbar.js +3 -0
- package/dist/src/view/gridView/selectionRect.d.ts +6 -10
- package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
- package/dist/src/view/gridView/selectionRect.js +22 -24
- package/dist/src/view/gridView/separatorView.d.ts +51 -0
- package/dist/src/view/gridView/separatorView.d.ts.map +1 -0
- package/dist/src/view/gridView/separatorView.js +275 -0
- package/dist/src/view/layerView.d.ts.map +1 -1
- package/dist/src/view/layerView.js +7 -5
- package/dist/src/view/layout/flexLayout.d.ts +0 -30
- package/dist/src/view/layout/flexLayout.d.ts.map +1 -1
- package/dist/src/view/layout/flexLayout.js +0 -86
- package/dist/src/view/multiscale.d.ts +35 -0
- package/dist/src/view/multiscale.d.ts.map +1 -0
- package/dist/src/view/multiscale.js +233 -0
- package/dist/src/view/multiscale.test.d.ts +2 -0
- package/dist/src/view/multiscale.test.d.ts.map +1 -0
- package/dist/src/view/testUtils.d.ts.map +1 -1
- package/dist/src/view/testUtils.js +6 -1
- package/dist/src/view/unitView.d.ts +8 -13
- package/dist/src/view/unitView.d.ts.map +1 -1
- package/dist/src/view/unitView.js +120 -45
- package/dist/src/view/view.d.ts +27 -18
- package/dist/src/view/view.d.ts.map +1 -1
- package/dist/src/view/view.js +298 -37
- package/dist/src/view/viewFactory.d.ts +0 -12
- package/dist/src/view/viewFactory.d.ts.map +1 -1
- package/dist/src/view/viewFactory.js +55 -25
- package/dist/src/view/viewParamRuntime.test.d.ts +2 -0
- package/dist/src/view/viewParamRuntime.test.d.ts.map +1 -0
- package/dist/src/view/viewSelectors.d.ts +148 -0
- package/dist/src/view/viewSelectors.d.ts.map +1 -0
- package/dist/src/view/viewSelectors.js +776 -0
- package/dist/src/view/viewSelectors.test.d.ts +2 -0
- package/dist/src/view/viewSelectors.test.d.ts.map +1 -0
- package/dist/src/view/viewUtils.d.ts +0 -8
- package/dist/src/view/viewUtils.d.ts.map +1 -1
- package/dist/src/view/viewUtils.js +1 -21
- package/package.json +4 -4
- package/dist/src/scales/scaleDomainAggregator.d.ts.map +0 -1
- package/dist/src/scales/scaleDomainAggregator.test.d.ts +0 -2
- package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +0 -1
- package/dist/src/spec/sampleView.d.ts +0 -197
- package/dist/src/view/paramMediator.d.ts +0 -149
- package/dist/src/view/paramMediator.d.ts.map +0 -1
- package/dist/src/view/paramMediator.js +0 -478
- package/dist/src/view/paramMediator.test.d.ts +0 -2
- package/dist/src/view/paramMediator.test.d.ts.map +0 -1
package/dist/src/view/view.d.ts
CHANGED
|
@@ -27,9 +27,6 @@ export const VISIT_STOP: "VISIT_STOP";
|
|
|
27
27
|
* @typedef {object} ViewOptions
|
|
28
28
|
* @prop {boolean} [blockEncodingInheritance]
|
|
29
29
|
* Don't inherit encodings from parent. Default: false.
|
|
30
|
-
* @prop {boolean} [contributesToScaleDomain]
|
|
31
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
32
|
-
* domain. Default: true
|
|
33
30
|
* @prop {boolean} [layersChildren]
|
|
34
31
|
* View's children are layered on top of each other and they have the same
|
|
35
32
|
* coordinates as their parent.
|
|
@@ -60,7 +57,6 @@ export default class View {
|
|
|
60
57
|
context: import("../types/viewContext.js").default;
|
|
61
58
|
layoutParent: import("./containerView.js").default;
|
|
62
59
|
dataParent: View;
|
|
63
|
-
name: string;
|
|
64
60
|
spec: import("../spec/view.js").ViewSpec;
|
|
65
61
|
resolutions: {
|
|
66
62
|
/**
|
|
@@ -79,11 +75,6 @@ export default class View {
|
|
|
79
75
|
* Don't inherit encodings from parent. Default: false.
|
|
80
76
|
*/
|
|
81
77
|
blockEncodingInheritance: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
84
|
-
* domain. Default: true
|
|
85
|
-
*/
|
|
86
|
-
contributesToScaleDomain: boolean;
|
|
87
78
|
/**
|
|
88
79
|
* View's children are layered on top of each other and they have the same
|
|
89
80
|
* coordinates as their parent.
|
|
@@ -100,8 +91,22 @@ export default class View {
|
|
|
100
91
|
* @type {Record<import("../spec/channel.js").PrimaryPositionalChannel, boolean>}
|
|
101
92
|
*/
|
|
102
93
|
needsAxes: Record<import("../spec/channel.js").PrimaryPositionalChannel, boolean>;
|
|
103
|
-
/** @type {
|
|
104
|
-
|
|
94
|
+
/** @type {ViewParamRuntime} */
|
|
95
|
+
paramRuntime: ViewParamRuntime;
|
|
96
|
+
/**
|
|
97
|
+
* Effective view name. Equals the explicit name (`spec.name`) when provided,
|
|
98
|
+
* otherwise falls back to an auto-generated default name.
|
|
99
|
+
*/
|
|
100
|
+
get name(): string;
|
|
101
|
+
/**
|
|
102
|
+
* The explicit name from the spec (`spec.name`), if any.
|
|
103
|
+
*/
|
|
104
|
+
get explicitName(): string;
|
|
105
|
+
/**
|
|
106
|
+
* The auto-generated default name that was assigned by the parent/factory.
|
|
107
|
+
* Intended for debugging only.
|
|
108
|
+
*/
|
|
109
|
+
get defaultName(): string;
|
|
105
110
|
/**
|
|
106
111
|
* Returns the coords of the view. If view has been faceted, returns the coords
|
|
107
112
|
* of an arbitrary facet. If all or specific facet coords are needed, use `facetCoords`.
|
|
@@ -134,6 +139,7 @@ export default class View {
|
|
|
134
139
|
* @returns {FlexDimensions}
|
|
135
140
|
*/
|
|
136
141
|
getViewportSize(): FlexDimensions;
|
|
142
|
+
registerStepSizeInvalidation(): void;
|
|
137
143
|
isConfiguredVisible(): boolean;
|
|
138
144
|
isVisibleInSpec(): boolean;
|
|
139
145
|
/**
|
|
@@ -146,6 +152,12 @@ export default class View {
|
|
|
146
152
|
* @returns {boolean}
|
|
147
153
|
*/
|
|
148
154
|
isVisible(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Returns true if this view or any ancestor is marked as domain inert.
|
|
157
|
+
*
|
|
158
|
+
* @returns {boolean}
|
|
159
|
+
*/
|
|
160
|
+
isDomainInert(): boolean;
|
|
149
161
|
/**
|
|
150
162
|
* @returns {"none" | "pending" | "ready"}
|
|
151
163
|
*/
|
|
@@ -186,8 +198,9 @@ export default class View {
|
|
|
186
198
|
*
|
|
187
199
|
* @param {string} type
|
|
188
200
|
* @param {function(BroadcastMessage):void} handler
|
|
201
|
+
* @returns {() => void}
|
|
189
202
|
*/
|
|
190
|
-
_addBroadcastHandler(type: string, handler: (arg0: BroadcastMessage) => void): void;
|
|
203
|
+
_addBroadcastHandler(type: string, handler: (arg0: BroadcastMessage) => void): () => void;
|
|
191
204
|
/**
|
|
192
205
|
* Handles an interactionEvent
|
|
193
206
|
*
|
|
@@ -250,6 +263,7 @@ export default class View {
|
|
|
250
263
|
* pass. The order is depth first, pre order.
|
|
251
264
|
*/
|
|
252
265
|
onBeforeRender(): void;
|
|
266
|
+
hasRendered(): boolean;
|
|
253
267
|
render(context: import("./renderingContext/viewRenderingContext.js").default, coords: import("./layout/rectangle.js").default, options?: import("../types/rendering.js").RenderingOptions): void;
|
|
254
268
|
/**
|
|
255
269
|
* Returns the encodings specified in this view combined with the inherited
|
|
@@ -372,18 +386,13 @@ export type ViewOptions = {
|
|
|
372
386
|
* Don't inherit encodings from parent. Default: false.
|
|
373
387
|
*/
|
|
374
388
|
blockEncodingInheritance?: boolean;
|
|
375
|
-
/**
|
|
376
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
377
|
-
* domain. Default: true
|
|
378
|
-
*/
|
|
379
|
-
contributesToScaleDomain?: boolean;
|
|
380
389
|
/**
|
|
381
390
|
* View's children are layered on top of each other and they have the same
|
|
382
391
|
* coordinates as their parent.
|
|
383
392
|
*/
|
|
384
393
|
layersChildren?: boolean;
|
|
385
394
|
};
|
|
386
|
-
import
|
|
395
|
+
import ViewParamRuntime from "../paramRuntime/viewParamRuntime.js";
|
|
387
396
|
import Padding from "./layout/padding.js";
|
|
388
397
|
import { FlexDimensions } from "./layout/flexLayout.js";
|
|
389
398
|
//# sourceMappingURL=view.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/view/view.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/view/view.js"],"names":[],"mappings":"AA4BA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,EAAJ,IAAI,KAAE,IAAI,CAAC;IACrC,aAAa,CAAC,EAAE,CAAS,IAAI,EAAJ,IAAI,KAAE,IAAI,CAAA;CAAC;;;;;UAIlC,OAAO,iBAAiB,EAAE,kBAAkB;;;;cAC5C,GAAG;;gDAGF,OAAO,uBAAuB,EAAE,OAAO,SAEvC,OAAO,8BAA8B,EAAE,OAAO;;;;;+BAG/C,OAAO;;;;;qBAEP,OAAO;;6BA3CY,qCAAqC;oBAb9C,qBAAqB;+BADlC,wBAAwB"}
|
package/dist/src/view/view.js
CHANGED
|
@@ -9,14 +9,15 @@ import {
|
|
|
9
9
|
initPropertyCache,
|
|
10
10
|
invalidatePrefix,
|
|
11
11
|
} from "../utils/propertyCacher.js";
|
|
12
|
-
import { isNumber, isString, span } from "vega-util";
|
|
12
|
+
import { isArray, isNumber, isString, span } from "vega-util";
|
|
13
13
|
import { scaleLog } from "d3-scale";
|
|
14
14
|
import { isFieldDef, getPrimaryChannel } from "../encoder/encoder.js";
|
|
15
15
|
import { concatUrl } from "../utils/url.js";
|
|
16
16
|
import { isDiscrete, bandSpace } from "vega-scale";
|
|
17
17
|
import { peek } from "../utils/arrayUtils.js";
|
|
18
18
|
import ViewError from "./viewError.js";
|
|
19
|
-
import
|
|
19
|
+
import ViewParamRuntime from "../paramRuntime/viewParamRuntime.js";
|
|
20
|
+
import { isExprRef } from "../paramRuntime/paramUtils.js";
|
|
20
21
|
import { InternMap } from "internmap";
|
|
21
22
|
import { endWithSlash } from "../utils/addBaseUrl.js";
|
|
22
23
|
|
|
@@ -58,14 +59,14 @@ const defaultOpacityFunction = (parentOpacity) => parentOpacity;
|
|
|
58
59
|
* @typedef {object} ViewOptions
|
|
59
60
|
* @prop {boolean} [blockEncodingInheritance]
|
|
60
61
|
* Don't inherit encodings from parent. Default: false.
|
|
61
|
-
* @prop {boolean} [contributesToScaleDomain]
|
|
62
|
-
* Whether ScaleResolution should include this view or its children in the
|
|
63
|
-
* domain. Default: true
|
|
64
62
|
* @prop {boolean} [layersChildren]
|
|
65
63
|
* View's children are layered on top of each other and they have the same
|
|
66
64
|
* coordinates as their parent.
|
|
67
65
|
*/
|
|
68
66
|
export default class View {
|
|
67
|
+
/** @type {string | undefined} */
|
|
68
|
+
#defaultName;
|
|
69
|
+
|
|
69
70
|
/** @type {Record<string, (function(BroadcastMessage):void)[]>} */
|
|
70
71
|
#broadcastHandlers = {};
|
|
71
72
|
|
|
@@ -81,6 +82,9 @@ export default class View {
|
|
|
81
82
|
/** @type {(value: number) => void} */
|
|
82
83
|
#heightSetter;
|
|
83
84
|
|
|
85
|
+
/** @type {boolean} */
|
|
86
|
+
#hasRendered = false;
|
|
87
|
+
|
|
84
88
|
/**
|
|
85
89
|
* @type {function(number):number}
|
|
86
90
|
*/
|
|
@@ -122,7 +126,7 @@ export default class View {
|
|
|
122
126
|
this.context = context;
|
|
123
127
|
this.layoutParent = layoutParent;
|
|
124
128
|
this.dataParent = dataParent;
|
|
125
|
-
this
|
|
129
|
+
this.#defaultName = name;
|
|
126
130
|
this.spec = spec;
|
|
127
131
|
|
|
128
132
|
this.resolutions = {
|
|
@@ -142,7 +146,6 @@ export default class View {
|
|
|
142
146
|
|
|
143
147
|
this.options = {
|
|
144
148
|
blockEncodingInheritance: false,
|
|
145
|
-
contributesToScaleDomain: true,
|
|
146
149
|
...options,
|
|
147
150
|
};
|
|
148
151
|
|
|
@@ -158,15 +161,15 @@ export default class View {
|
|
|
158
161
|
*/
|
|
159
162
|
this.needsAxes = { x: false, y: false };
|
|
160
163
|
|
|
161
|
-
/** @type {
|
|
162
|
-
this.
|
|
163
|
-
() => this.dataParent?.
|
|
164
|
+
/** @type {ViewParamRuntime} */
|
|
165
|
+
this.paramRuntime = new ViewParamRuntime(
|
|
166
|
+
() => this.dataParent?.paramRuntime
|
|
164
167
|
);
|
|
165
168
|
|
|
166
169
|
if (spec.params) {
|
|
167
170
|
for (const param of spec.params) {
|
|
168
171
|
// TODO: If interval selection, validate `encodings` or provides defaults
|
|
169
|
-
this.
|
|
172
|
+
this.paramRuntime.registerParam(param);
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
|
|
@@ -176,14 +179,37 @@ export default class View {
|
|
|
176
179
|
// doesn't make much sense, but it's used in the App's SampleView
|
|
177
180
|
// to set the height to sample facets' height.
|
|
178
181
|
const allocateIfFree = (/** @type {string} */ name) =>
|
|
179
|
-
this.
|
|
182
|
+
this.paramRuntime.findRuntimeForParam(name)
|
|
180
183
|
? undefined
|
|
181
|
-
: this.
|
|
184
|
+
: this.paramRuntime.allocateSetter(name, 0);
|
|
182
185
|
this.#heightSetter = allocateIfFree("height");
|
|
183
186
|
this.#widthSetter = allocateIfFree("width");
|
|
184
187
|
}
|
|
185
188
|
}
|
|
186
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Effective view name. Equals the explicit name (`spec.name`) when provided,
|
|
192
|
+
* otherwise falls back to an auto-generated default name.
|
|
193
|
+
*/
|
|
194
|
+
get name() {
|
|
195
|
+
return this.spec.name ?? this.#defaultName;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The explicit name from the spec (`spec.name`), if any.
|
|
200
|
+
*/
|
|
201
|
+
get explicitName() {
|
|
202
|
+
return this.spec.name;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The auto-generated default name that was assigned by the parent/factory.
|
|
207
|
+
* Intended for debugging only.
|
|
208
|
+
*/
|
|
209
|
+
get defaultName() {
|
|
210
|
+
return this.#defaultName;
|
|
211
|
+
}
|
|
212
|
+
|
|
187
213
|
/**
|
|
188
214
|
* Returns the coords of the view. If view has been faceted, returns the coords
|
|
189
215
|
* of an arbitrary facet. If all or specific facet coords are needed, use `facetCoords`.
|
|
@@ -265,11 +291,12 @@ export default class View {
|
|
|
265
291
|
*/
|
|
266
292
|
#getDimensionSize(dimension) {
|
|
267
293
|
let value = this.spec[dimension];
|
|
294
|
+
const needsStepInvalidation = isStepSize(value);
|
|
268
295
|
|
|
269
296
|
const viewport =
|
|
270
297
|
dimension == "viewportWidth" || dimension == "viewportHeight";
|
|
271
298
|
|
|
272
|
-
if (
|
|
299
|
+
if (needsStepInvalidation) {
|
|
273
300
|
if (viewport) {
|
|
274
301
|
throw new ViewError(
|
|
275
302
|
`Cannot use step-based size with "${dimension}"!`,
|
|
@@ -313,7 +340,7 @@ export default class View {
|
|
|
313
340
|
return { px: steps * stepSize, grow: 0 };
|
|
314
341
|
} else {
|
|
315
342
|
throw new ViewError(
|
|
316
|
-
|
|
343
|
+
`Cannot use step-based size with "${dimension}"!`,
|
|
317
344
|
this
|
|
318
345
|
);
|
|
319
346
|
}
|
|
@@ -325,6 +352,36 @@ export default class View {
|
|
|
325
352
|
}
|
|
326
353
|
}
|
|
327
354
|
|
|
355
|
+
registerStepSizeInvalidation() {
|
|
356
|
+
this.#registerStepSizeInvalidationFor("width", "x");
|
|
357
|
+
this.#registerStepSizeInvalidationFor("height", "y");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @param {"width" | "height"} dimension
|
|
362
|
+
* @param {import("../spec/channel.js").PrimaryPositionalChannel} channel
|
|
363
|
+
*/
|
|
364
|
+
#registerStepSizeInvalidationFor(dimension, channel) {
|
|
365
|
+
const value = this.spec[dimension];
|
|
366
|
+
if (!isStepSize(value)) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const resolution = this.getScaleResolution(channel);
|
|
371
|
+
if (!resolution) {
|
|
372
|
+
throw new ViewError(
|
|
373
|
+
"Cannot use 'step' size without a scale!",
|
|
374
|
+
this
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const listener = () => this.invalidateSizeCache();
|
|
379
|
+
resolution.addEventListener("domain", listener);
|
|
380
|
+
this.registerDisposer(() =>
|
|
381
|
+
resolution.removeEventListener("domain", listener)
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
|
|
328
385
|
isConfiguredVisible() {
|
|
329
386
|
return this.context.isViewConfiguredVisible(this);
|
|
330
387
|
}
|
|
@@ -348,6 +405,24 @@ export default class View {
|
|
|
348
405
|
);
|
|
349
406
|
}
|
|
350
407
|
|
|
408
|
+
/**
|
|
409
|
+
* Returns true if this view or any ancestor is marked as domain inert.
|
|
410
|
+
*
|
|
411
|
+
* @returns {boolean}
|
|
412
|
+
*/
|
|
413
|
+
isDomainInert() {
|
|
414
|
+
if (this.spec.domainInert) {
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const parent = this.dataParent;
|
|
419
|
+
if (!parent) {
|
|
420
|
+
return false;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
return parent.isDomainInert();
|
|
424
|
+
}
|
|
425
|
+
|
|
351
426
|
/**
|
|
352
427
|
* @returns {"none" | "pending" | "ready"}
|
|
353
428
|
*/
|
|
@@ -436,6 +511,7 @@ export default class View {
|
|
|
436
511
|
*
|
|
437
512
|
* @param {string} type
|
|
438
513
|
* @param {function(BroadcastMessage):void} handler
|
|
514
|
+
* @returns {() => void}
|
|
439
515
|
*/
|
|
440
516
|
_addBroadcastHandler(type, handler) {
|
|
441
517
|
let handlers = this.#broadcastHandlers[type];
|
|
@@ -444,6 +520,18 @@ export default class View {
|
|
|
444
520
|
this.#broadcastHandlers[type] = handlers;
|
|
445
521
|
}
|
|
446
522
|
handlers.push(handler);
|
|
523
|
+
|
|
524
|
+
return () => {
|
|
525
|
+
const currentHandlers = this.#broadcastHandlers[type];
|
|
526
|
+
if (!currentHandlers) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
const index = currentHandlers.indexOf(handler);
|
|
531
|
+
if (index >= 0) {
|
|
532
|
+
currentHandlers.splice(index, 1);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
447
535
|
}
|
|
448
536
|
|
|
449
537
|
/**
|
|
@@ -568,6 +656,10 @@ export default class View {
|
|
|
568
656
|
this.context.dataFlow.removeDataSource(handle.dataSource);
|
|
569
657
|
}
|
|
570
658
|
|
|
659
|
+
this.paramRuntime.dispose();
|
|
660
|
+
|
|
661
|
+
this.context.dataFlow.loadingStatusRegistry.delete(this);
|
|
662
|
+
|
|
571
663
|
this.flowHandle = undefined;
|
|
572
664
|
}
|
|
573
665
|
|
|
@@ -609,7 +701,13 @@ export default class View {
|
|
|
609
701
|
* pass. The order is depth first, pre order.
|
|
610
702
|
*/
|
|
611
703
|
onBeforeRender() {
|
|
612
|
-
|
|
704
|
+
if (!this.#hasRendered) {
|
|
705
|
+
this.#hasRendered = true;
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
hasRendered() {
|
|
710
|
+
return this.#hasRendered;
|
|
613
711
|
}
|
|
614
712
|
|
|
615
713
|
/**
|
|
@@ -793,7 +891,7 @@ export default class View {
|
|
|
793
891
|
return isString(title)
|
|
794
892
|
? title
|
|
795
893
|
: isExprRef(title.text)
|
|
796
|
-
? this.
|
|
894
|
+
? this.paramRuntime.evaluateAndGet(title.text.expr)
|
|
797
895
|
: title.text;
|
|
798
896
|
}
|
|
799
897
|
}
|
|
@@ -832,7 +930,9 @@ export default class View {
|
|
|
832
930
|
}
|
|
833
931
|
|
|
834
932
|
invalidateSizeCache() {
|
|
835
|
-
|
|
933
|
+
// Clear both "size" and "size/*" cache keys.
|
|
934
|
+
invalidatePrefix(this, "size");
|
|
935
|
+
this._invalidateCacheByPrefix("size", "ancestors");
|
|
836
936
|
}
|
|
837
937
|
|
|
838
938
|
/**
|
|
@@ -856,6 +956,16 @@ function isDynamicOpacity(opacity) {
|
|
|
856
956
|
}
|
|
857
957
|
|
|
858
958
|
/**
|
|
959
|
+
* Builds the effective opacity function for a view.
|
|
960
|
+
*
|
|
961
|
+
* The resulting function multiplies parent opacity with one of:
|
|
962
|
+
* 1. constant opacity (`number`)
|
|
963
|
+
* 2. zoom-driven dynamic opacity (`DynamicOpacity`) that maps the current
|
|
964
|
+
* units-per-pixel metric through a log interpolation
|
|
965
|
+
* 3. expression-driven opacity (`ExprRef`) that is evaluated reactively
|
|
966
|
+
*
|
|
967
|
+
* Dynamic opacity supports scale selection via `channel` (`x`, `y`, or
|
|
968
|
+
* `"auto"`), where `"auto"` averages available x/y metrics.
|
|
859
969
|
*
|
|
860
970
|
* @param {View} view
|
|
861
971
|
* @returns {function(number):number}
|
|
@@ -867,46 +977,197 @@ function createViewOpacityFunction(view) {
|
|
|
867
977
|
if (isNumber(opacityDef)) {
|
|
868
978
|
return (parentOpacity) => parentOpacity * opacityDef;
|
|
869
979
|
} else if (isDynamicOpacity(opacityDef)) {
|
|
870
|
-
/**
|
|
871
|
-
|
|
872
|
-
|
|
980
|
+
/**
|
|
981
|
+
* @param {import("../spec/channel.js").PrimaryPositionalChannel} channel
|
|
982
|
+
*/
|
|
983
|
+
const getScaleContext = (channel) => {
|
|
984
|
+
const scaleResolution = view.getScaleResolution(channel);
|
|
985
|
+
const scale = scaleResolution?.getScale();
|
|
873
986
|
// Only works on linear scales
|
|
874
987
|
if (["linear", "index", "locus"].includes(scale?.type)) {
|
|
875
|
-
return scale;
|
|
988
|
+
return { scale, scaleResolution };
|
|
876
989
|
}
|
|
877
990
|
};
|
|
878
991
|
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
992
|
+
const opacityValues = asFiniteNumberArray(
|
|
993
|
+
opacityDef.values,
|
|
994
|
+
"opacity.values",
|
|
995
|
+
view
|
|
996
|
+
);
|
|
882
997
|
|
|
883
|
-
if (!
|
|
998
|
+
if (!isArray(opacityDef.unitsPerPixel)) {
|
|
884
999
|
throw new ViewError(
|
|
885
|
-
"
|
|
1000
|
+
'"opacity.unitsPerPixel" must be an array.',
|
|
886
1001
|
view
|
|
887
1002
|
);
|
|
888
1003
|
}
|
|
889
1004
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
.range(opacityDef.values)
|
|
893
|
-
.clamp(true);
|
|
1005
|
+
/** @type {function(number): number} */
|
|
1006
|
+
let interpolate = () => 1;
|
|
894
1007
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
const unitsPerPixel = span(scale.domain()) / rangeSpan;
|
|
1008
|
+
/** @type {(() => number)[]} */
|
|
1009
|
+
let stopReaders = [];
|
|
898
1010
|
|
|
899
|
-
|
|
1011
|
+
const updateInterpolator = () => {
|
|
1012
|
+
const unitsPerPixel = asFiniteNumberArray(
|
|
1013
|
+
stopReaders.map((readStop) => readStop()),
|
|
1014
|
+
"opacity.unitsPerPixel",
|
|
1015
|
+
view
|
|
1016
|
+
);
|
|
1017
|
+
|
|
1018
|
+
validateDynamicOpacityStops(unitsPerPixel, opacityValues, view);
|
|
1019
|
+
|
|
1020
|
+
const scale = scaleLog()
|
|
1021
|
+
.domain(unitsPerPixel)
|
|
1022
|
+
.range(opacityValues)
|
|
1023
|
+
.clamp(true);
|
|
1024
|
+
|
|
1025
|
+
interpolate = (value) => scale(value);
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
stopReaders = opacityDef.unitsPerPixel.map((stop) => {
|
|
1029
|
+
if (isExprRef(stop)) {
|
|
1030
|
+
const fn = view.paramRuntime.watchExpression(
|
|
1031
|
+
stop.expr,
|
|
1032
|
+
() => {
|
|
1033
|
+
updateInterpolator();
|
|
1034
|
+
view.context.animator.requestRender();
|
|
1035
|
+
}
|
|
1036
|
+
);
|
|
1037
|
+
return () => fn(null);
|
|
1038
|
+
} else {
|
|
1039
|
+
return () => stop;
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
updateInterpolator();
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* @param {{ scale: any, scaleResolution: import("../scales/scaleResolution.js").default }} scaleContext
|
|
1047
|
+
*/
|
|
1048
|
+
const getUnitsPerPixel = (scaleContext) => {
|
|
1049
|
+
const axisLength = scaleContext.scaleResolution.getAxisLength();
|
|
1050
|
+
const rangeSpan = axisLength || 1000;
|
|
1051
|
+
return span(scaleContext.scale.domain()) / rangeSpan;
|
|
1052
|
+
};
|
|
1053
|
+
|
|
1054
|
+
/** @type {() => number} */
|
|
1055
|
+
let getMetric;
|
|
1056
|
+
|
|
1057
|
+
if (opacityDef.channel === "auto") {
|
|
1058
|
+
const xScale = getScaleContext("x");
|
|
1059
|
+
const yScale = getScaleContext("y");
|
|
1060
|
+
|
|
1061
|
+
if (xScale && yScale) {
|
|
1062
|
+
getMetric = () =>
|
|
1063
|
+
(getUnitsPerPixel(xScale) + getUnitsPerPixel(yScale)) /
|
|
1064
|
+
2;
|
|
1065
|
+
} else if (xScale) {
|
|
1066
|
+
getMetric = () => getUnitsPerPixel(xScale);
|
|
1067
|
+
} else if (yScale) {
|
|
1068
|
+
getMetric = () => getUnitsPerPixel(yScale);
|
|
1069
|
+
} else {
|
|
1070
|
+
throw new ViewError(
|
|
1071
|
+
"Cannot find a resolved quantitative x or y scale for dynamic opacity!",
|
|
1072
|
+
view
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
} else {
|
|
1076
|
+
const scaleContext = opacityDef.channel
|
|
1077
|
+
? getScaleContext(opacityDef.channel)
|
|
1078
|
+
: (getScaleContext("x") ?? getScaleContext("y"));
|
|
1079
|
+
|
|
1080
|
+
if (!scaleContext) {
|
|
1081
|
+
throw new ViewError(
|
|
1082
|
+
"Cannot find a resolved quantitative scale for dynamic opacity!",
|
|
1083
|
+
view
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
getMetric = () => getUnitsPerPixel(scaleContext);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
return (parentOpacity) => {
|
|
1091
|
+
return interpolate(getMetric()) * parentOpacity;
|
|
900
1092
|
};
|
|
901
1093
|
} else if (isExprRef(opacityDef)) {
|
|
902
|
-
const fn = view.
|
|
903
|
-
|
|
1094
|
+
const fn = view.paramRuntime.watchExpression(opacityDef.expr, () =>
|
|
1095
|
+
view.context.animator.requestRender()
|
|
1096
|
+
);
|
|
904
1097
|
return (parentOpacity) => fn(null) * parentOpacity;
|
|
905
1098
|
}
|
|
906
1099
|
}
|
|
907
1100
|
return (parentOpacity) => parentOpacity;
|
|
908
1101
|
}
|
|
909
1102
|
|
|
1103
|
+
/**
|
|
1104
|
+
* @param {number[]} unitsPerPixel
|
|
1105
|
+
* @param {number[]} values
|
|
1106
|
+
* @param {View} view
|
|
1107
|
+
*/
|
|
1108
|
+
function validateDynamicOpacityStops(unitsPerPixel, values, view) {
|
|
1109
|
+
if (!unitsPerPixel.length) {
|
|
1110
|
+
throw new ViewError(
|
|
1111
|
+
'"opacity.unitsPerPixel" must contain at least one stop.',
|
|
1112
|
+
view
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
if (unitsPerPixel.length !== values.length) {
|
|
1117
|
+
throw new ViewError(
|
|
1118
|
+
'"opacity.unitsPerPixel" and "opacity.values" must have the same length.',
|
|
1119
|
+
view
|
|
1120
|
+
);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
unitsPerPixel.forEach((value, index) => {
|
|
1124
|
+
if (value <= 0) {
|
|
1125
|
+
throw new ViewError(
|
|
1126
|
+
"Invalid opacity.unitsPerPixel value at index " +
|
|
1127
|
+
index +
|
|
1128
|
+
". Stop values must be positive.",
|
|
1129
|
+
view
|
|
1130
|
+
);
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
for (let i = 1; i < unitsPerPixel.length; i++) {
|
|
1135
|
+
if (unitsPerPixel[i - 1] <= unitsPerPixel[i]) {
|
|
1136
|
+
throw new ViewError(
|
|
1137
|
+
'"opacity.unitsPerPixel" must be strictly decreasing.',
|
|
1138
|
+
view
|
|
1139
|
+
);
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* @param {unknown} value
|
|
1146
|
+
* @param {string} label
|
|
1147
|
+
* @param {View} view
|
|
1148
|
+
* @returns {number[]}
|
|
1149
|
+
*/
|
|
1150
|
+
function asFiniteNumberArray(value, label, view) {
|
|
1151
|
+
if (!isArray(value)) {
|
|
1152
|
+
throw new ViewError('"' + label + '" must evaluate to an array.', view);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
return value.map((item, index) => {
|
|
1156
|
+
if (!isNumber(item) || !Number.isFinite(item)) {
|
|
1157
|
+
throw new ViewError(
|
|
1158
|
+
"Invalid " +
|
|
1159
|
+
label +
|
|
1160
|
+
" value at index " +
|
|
1161
|
+
index +
|
|
1162
|
+
". Expected a finite number.",
|
|
1163
|
+
view
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
return item;
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
|
|
910
1171
|
/**
|
|
911
1172
|
*
|
|
912
1173
|
* @param {any} size
|
|
@@ -16,12 +16,6 @@ export function isLayerSpec(spec: import("../spec/view.js").ViewSpec): spec is i
|
|
|
16
16
|
* @returns {spec is LayerSpec}
|
|
17
17
|
*/
|
|
18
18
|
export function isFacetSpec(spec: import("../spec/view.js").ViewSpec): spec is import("../spec/view.js").LayerSpec;
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {ViewSpec} spec
|
|
22
|
-
* @returns {spec is import("../spec/view.js").AggregateSamplesSpec}
|
|
23
|
-
*/
|
|
24
|
-
export function isAggregateSamplesSpec(spec: import("../spec/view.js").ViewSpec): spec is import("../spec/view.js").AggregateSamplesSpec;
|
|
25
19
|
/**
|
|
26
20
|
*
|
|
27
21
|
* @param {object} spec
|
|
@@ -46,12 +40,6 @@ export function isHConcatSpec(spec: import("../spec/view.js").ViewSpec): spec is
|
|
|
46
40
|
* @returns {spec is ConcatSpec}
|
|
47
41
|
*/
|
|
48
42
|
export function isConcatSpec(spec: import("../spec/view.js").ViewSpec): spec is import("../spec/view.js").ConcatSpec;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
* @param {ViewSpec} spec
|
|
52
|
-
* @returns {spec is SampleSpec}
|
|
53
|
-
*/
|
|
54
|
-
export function isSampleSpec(spec: import("../spec/view.js").ViewSpec): spec is import("../spec/sampleView.js").SampleSpec;
|
|
55
43
|
export const VIEW_ROOT_NAME: "viewRoot";
|
|
56
44
|
/**
|
|
57
45
|
* @typedef {object} ViewFactoryOptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewFactory.d.ts","sourceRoot":"","sources":["../../../src/view/viewFactory.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viewFactory.d.ts","sourceRoot":"","sources":["../../../src/view/viewFactory.js"],"names":[],"mappings":"AAwUA;;;;GAIG;AACH,sEAFa,IAAI,sCAAY,CAI5B;AAED;;;;GAIG;AACH,uEAFa,IAAI,uCAAa,CAI7B;AAED;;;;GAIG;AACH,uEAFa,IAAI,uCAAa,CAS7B;AAED;;;;GAIG;AACH,mCAHW,MAAM,GACJ,IAAI,IAAI,OAAO,iBAAiB,EAAE,UAAU,CAIxD;AAED;;;;GAIG;AACH,yEAFa,IAAI,yCAAe,CAI/B;AAED;;;;GAIG;AACH,yEAFa,IAAI,IAAI,WAAW,CAI/B;AAED;;;;GAIG;AACH,wEAFa,IAAI,wCAAc,CAI9B;AAxXD,6BAA8B,UAAU,CAAC;AAEzC;;;;GAIG;AAEH;;GAEG;AACH;IAiBI;;OAEG;IACH,sBAFW,kBAAkB,EAiD5B;IA9CG,2CAA2C;IAC3C,SADW,QAAQ,CAAC,kBAAkB,CAAC,CAKtC;IA2CL;;;OAGG;IACH,qEA/DiC,OAAO,yHAC2B,OAAO,oBAAoB,EAAE,OAAO,eAAe,OAAO,WAAW,EAAE,OAAO,gBAAgB,MAAM,KAAK,IAAI,QAgE/K;IAED;;;;;;OAMG;IACH,wHAJW,OAAO,oBAAoB,EAAE,OAAO,eACpC,OAAO,WAAW,EAAE,OAAO,gBAC3B,MAAM,QAyBhB;IAED;;;;OAIG;IACH,sDAFa,IAAI,sCAAY,CAU5B;IAED;;;;;;;;;;OAUG;IACH,yBAPW,qCAAW,OAAO,iBAAiB,EAAE,UAAU,qEAE/C,OAAO,oBAAoB,EAAE,OAAO,eACpC,OAAO,WAAW,EAAE,OAAO,gBAC3B,MAAM,cACN,CAAC,IAAI,oCAAU,KAAK,IAAI,iBAiGlC;;CACJ;;;;;kBA9Oa,OAAO;eACP,OAAO;;iBAtBJ,WAAW"}
|