@flowmap.gl/data 8.0.0-alpha.4 → 8.0.0-alpha.5

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.
Files changed (35) hide show
  1. package/dist/{FlowMapAggregateAccessors.d.ts → FlowmapAggregateAccessors.d.ts} +6 -6
  2. package/dist/{FlowMapAggregateAccessors.d.ts.map → FlowmapAggregateAccessors.d.ts.map} +1 -1
  3. package/dist/{FlowMapAggregateAccessors.js → FlowmapAggregateAccessors.js} +3 -3
  4. package/dist/{FlowMapSelectors.d.ts → FlowmapSelectors.d.ts} +45 -44
  5. package/dist/FlowmapSelectors.d.ts.map +1 -0
  6. package/dist/FlowmapSelectors.js +869 -0
  7. package/dist/{FlowMapState.d.ts → FlowmapState.d.ts} +4 -2
  8. package/dist/{FlowMapState.d.ts.map → FlowmapState.d.ts.map} +1 -1
  9. package/dist/{FlowMapState.js → FlowmapState.js} +1 -1
  10. package/dist/colors.d.ts +2 -2
  11. package/dist/colors.js +2 -2
  12. package/dist/index.d.ts +6 -6
  13. package/dist/index.js +6 -6
  14. package/dist/provider/FlowmapDataProvider.d.ts +16 -0
  15. package/dist/provider/{FlowMapDataProvider.d.ts.map → FlowmapDataProvider.d.ts.map} +1 -1
  16. package/dist/provider/{FlowMapDataProvider.js → FlowmapDataProvider.js} +4 -4
  17. package/dist/provider/LocalFlowmapDataProvider.d.ts +20 -0
  18. package/dist/provider/{LocalFlowMapDataProvider.d.ts.map → LocalFlowmapDataProvider.d.ts.map} +1 -1
  19. package/dist/provider/{LocalFlowMapDataProvider.js → LocalFlowmapDataProvider.js} +22 -22
  20. package/dist/types.d.ts +2 -2
  21. package/dist/types.js +1 -1
  22. package/package.json +2 -2
  23. package/src/{FlowMapAggregateAccessors.ts → FlowmapAggregateAccessors.ts} +6 -6
  24. package/src/{FlowMapSelectors.ts → FlowmapSelectors.ts} +80 -77
  25. package/src/{FlowMapState.ts → FlowmapState.ts} +3 -1
  26. package/src/colors.ts +2 -2
  27. package/src/index.ts +6 -6
  28. package/src/provider/{FlowMapDataProvider.ts → FlowmapDataProvider.ts} +11 -11
  29. package/src/provider/LocalFlowmapDataProvider.ts +105 -0
  30. package/src/types.ts +2 -2
  31. package/dist/FlowMapSelectors.d.ts.map +0 -1
  32. package/dist/FlowMapSelectors.js +0 -869
  33. package/dist/provider/FlowMapDataProvider.d.ts +0 -16
  34. package/dist/provider/LocalFlowMapDataProvider.d.ts +0 -20
  35. package/src/provider/LocalFlowMapDataProvider.ts +0 -105
@@ -1,16 +0,0 @@
1
- import { AggregateFlow, Cluster, LocationTotals } from '..';
2
- import { FlowMapState } from '../FlowMapState';
3
- import { ClusterNode, FlowMapData, FlowMapDataAccessors, LayersData, ViewportProps } from '../types';
4
- export default interface FlowMapDataProvider<L, F> {
5
- setAccessors(accessors: FlowMapDataAccessors<L, F>): void;
6
- setFlowMapState(flowMapState: FlowMapState): Promise<void>;
7
- getViewportForLocations(dims: [number, number]): Promise<ViewportProps>;
8
- getFlowByIndex(index: number): Promise<F | AggregateFlow | undefined>;
9
- getLocationById(id: string): Promise<L | Cluster | undefined>;
10
- getLocationByIndex(idx: number): Promise<L | ClusterNode | undefined>;
11
- getTotalsForLocation(id: string): Promise<LocationTotals | undefined>;
12
- getLayersData(): Promise<LayersData | undefined>;
13
- }
14
- export declare function isFlowMapData<L, F>(data: Record<string, any>): data is FlowMapData<L, F>;
15
- export declare function isFlowMapDataProvider<L, F>(dataProvider: Record<string, any>): dataProvider is FlowMapDataProvider<L, F>;
16
- //# sourceMappingURL=FlowMapDataProvider.d.ts.map
@@ -1,20 +0,0 @@
1
- import FlowMapDataProvider from './FlowMapDataProvider';
2
- import { Cluster, ClusterNode, FlowMapData, FlowMapDataAccessors, LayersData, LocationTotals, ViewportProps } from '../types';
3
- import { FlowMapState } from '../FlowMapState';
4
- import { AggregateFlow } from '..';
5
- export default class LocalFlowMapDataProvider<L, F> implements FlowMapDataProvider<L, F> {
6
- private selectors;
7
- private flowMapData;
8
- private flowMapState;
9
- constructor(accessors: FlowMapDataAccessors<L, F>);
10
- setAccessors(accessors: FlowMapDataAccessors<L, F>): void;
11
- setFlowMapData(flowMapData: FlowMapData<L, F>): Promise<void>;
12
- setFlowMapState(flowMapState: FlowMapState): Promise<void>;
13
- getFlowByIndex(idx: number): Promise<F | AggregateFlow | undefined>;
14
- getLocationByIndex(idx: number): Promise<L | ClusterNode | undefined>;
15
- getLayersData(): Promise<LayersData | undefined>;
16
- getLocationById(id: string): Promise<L | Cluster | undefined>;
17
- getTotalsForLocation(id: string): Promise<LocationTotals | undefined>;
18
- getViewportForLocations(dims: [number, number]): Promise<ViewportProps>;
19
- }
20
- //# sourceMappingURL=LocalFlowMapDataProvider.d.ts.map
@@ -1,105 +0,0 @@
1
- import FlowMapDataProvider from './FlowMapDataProvider';
2
- import {
3
- Cluster,
4
- ClusterNode,
5
- FlowAccessors,
6
- FlowMapData,
7
- FlowMapDataAccessors,
8
- LayersData,
9
- LocationAccessors,
10
- LocationTotals,
11
- ViewportProps,
12
- } from '../types';
13
- import {FlowMapState} from '../FlowMapState';
14
- import FlowMapSelectors from '../FlowMapSelectors';
15
- import {AggregateFlow} from '..';
16
-
17
- export default class LocalFlowMapDataProvider<L, F>
18
- implements FlowMapDataProvider<L, F>
19
- {
20
- private selectors: FlowMapSelectors<L, F>;
21
- private flowMapData: FlowMapData<L, F> | undefined;
22
- private flowMapState: FlowMapState | undefined;
23
-
24
- constructor(accessors: FlowMapDataAccessors<L, F>) {
25
- // scope selectors to the concrete instance of FlowMapDataProvider
26
- this.selectors = new FlowMapSelectors<L, F>(accessors);
27
- this.flowMapData = undefined;
28
- this.flowMapState = undefined;
29
- }
30
-
31
- setAccessors(accessors: FlowMapDataAccessors<L, F>) {
32
- this.selectors.setAccessors(accessors);
33
- }
34
-
35
- async setFlowMapData(flowMapData: FlowMapData<L, F>): Promise<void> {
36
- this.flowMapData = flowMapData;
37
- }
38
-
39
- async setFlowMapState(flowMapState: FlowMapState): Promise<void> {
40
- this.flowMapState = flowMapState;
41
- }
42
-
43
- async getFlowByIndex(idx: number): Promise<F | AggregateFlow | undefined> {
44
- if (!this.flowMapState || !this.flowMapData) {
45
- return undefined;
46
- }
47
- const flows = this.selectors.getFlowsForFlowMapLayer(
48
- this.flowMapState,
49
- this.flowMapData,
50
- );
51
- return flows?.[idx];
52
- }
53
-
54
- async getLocationByIndex(idx: number): Promise<L | ClusterNode | undefined> {
55
- if (!this.flowMapState || !this.flowMapData) {
56
- return undefined;
57
- }
58
- const locations = this.selectors.getLocationsForFlowMapLayer(
59
- this.flowMapState,
60
- this.flowMapData,
61
- );
62
- return locations?.[idx];
63
- }
64
-
65
- async getLayersData(): Promise<LayersData | undefined> {
66
- if (!this.flowMapState || !this.flowMapData) {
67
- return undefined;
68
- }
69
- return this.selectors.getLayersData(this.flowMapState, this.flowMapData);
70
- }
71
-
72
- async getLocationById(id: string): Promise<L | Cluster | undefined> {
73
- if (!this.flowMapState || !this.flowMapData) {
74
- return undefined;
75
- }
76
- const clusterIndex = this.selectors.getClusterIndex(
77
- this.flowMapState,
78
- this.flowMapData,
79
- );
80
- if (clusterIndex) {
81
- const cluster = clusterIndex.getClusterById(id);
82
- if (cluster) {
83
- return cluster;
84
- }
85
- }
86
- const locationsById = this.selectors.getLocationsById(
87
- this.flowMapState,
88
- this.flowMapData,
89
- );
90
- return locationsById?.get(id);
91
- }
92
-
93
- async getTotalsForLocation(id: string): Promise<LocationTotals | undefined> {
94
- if (!this.flowMapState || !this.flowMapData) {
95
- return undefined;
96
- }
97
- return this.selectors
98
- .getLocationTotals(this.flowMapState, this.flowMapData)
99
- ?.get(id);
100
- }
101
-
102
- getViewportForLocations(dims: [number, number]): Promise<ViewportProps> {
103
- return Promise.resolve({} as ViewportProps);
104
- }
105
- }