@xyo-network/react-map-model 4.2.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.
Files changed (70) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +13 -0
  3. package/dist/browser/AnimatedHeatMapSettings.d.ts +2 -0
  4. package/dist/browser/AnimatedHeatMapSettings.d.ts.map +1 -0
  5. package/dist/browser/colors/MapColorProps.d.ts +17 -0
  6. package/dist/browser/colors/MapColorProps.d.ts.map +1 -0
  7. package/dist/browser/colors/index.d.ts +2 -0
  8. package/dist/browser/colors/index.d.ts.map +1 -0
  9. package/dist/browser/contexts/MapboxAccessToken/Context.d.ts +3 -0
  10. package/dist/browser/contexts/MapboxAccessToken/Context.d.ts.map +1 -0
  11. package/dist/browser/contexts/MapboxAccessToken/Provider.d.ts +7 -0
  12. package/dist/browser/contexts/MapboxAccessToken/Provider.d.ts.map +1 -0
  13. package/dist/browser/contexts/MapboxAccessToken/State.d.ts +7 -0
  14. package/dist/browser/contexts/MapboxAccessToken/State.d.ts.map +1 -0
  15. package/dist/browser/contexts/MapboxAccessToken/index.d.ts +5 -0
  16. package/dist/browser/contexts/MapboxAccessToken/index.d.ts.map +1 -0
  17. package/dist/browser/contexts/MapboxAccessToken/use.d.ts +2 -0
  18. package/dist/browser/contexts/MapboxAccessToken/use.d.ts.map +1 -0
  19. package/dist/browser/contexts/index.d.ts +2 -0
  20. package/dist/browser/contexts/index.d.ts.map +1 -0
  21. package/dist/browser/hooks/index.d.ts +4 -0
  22. package/dist/browser/hooks/index.d.ts.map +1 -0
  23. package/dist/browser/hooks/useFindHashes.d.ts +2 -0
  24. package/dist/browser/hooks/useFindHashes.d.ts.map +1 -0
  25. package/dist/browser/hooks/useHeatMapColors.d.ts +7 -0
  26. package/dist/browser/hooks/useHeatMapColors.d.ts.map +1 -0
  27. package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.d.ts +9 -0
  28. package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.d.ts.map +1 -0
  29. package/dist/browser/index.d.ts +8 -0
  30. package/dist/browser/index.d.ts.map +1 -0
  31. package/dist/browser/index.mjs +235 -0
  32. package/dist/browser/index.mjs.map +1 -0
  33. package/dist/browser/lib/MapStyle.d.ts +9 -0
  34. package/dist/browser/lib/MapStyle.d.ts.map +1 -0
  35. package/dist/browser/lib/index.d.ts +2 -0
  36. package/dist/browser/lib/index.d.ts.map +1 -0
  37. package/dist/browser/settings/DefaultMapSettings.d.ts +3 -0
  38. package/dist/browser/settings/DefaultMapSettings.d.ts.map +1 -0
  39. package/dist/browser/settings/MapSetting.d.ts +16 -0
  40. package/dist/browser/settings/MapSetting.d.ts.map +1 -0
  41. package/dist/browser/settings/index.d.ts +3 -0
  42. package/dist/browser/settings/index.d.ts.map +1 -0
  43. package/dist/browser/types/NetworkLocationAnswerBase.d.ts +37 -0
  44. package/dist/browser/types/NetworkLocationAnswerBase.d.ts.map +1 -0
  45. package/dist/browser/types/index.d.ts +2 -0
  46. package/dist/browser/types/index.d.ts.map +1 -0
  47. package/package.json +75 -0
  48. package/src/AnimatedHeatMapSettings.ts +10 -0
  49. package/src/colors/MapColorProps.ts +19 -0
  50. package/src/colors/index.ts +1 -0
  51. package/src/contexts/MapboxAccessToken/Context.ts +5 -0
  52. package/src/contexts/MapboxAccessToken/Provider.tsx +23 -0
  53. package/src/contexts/MapboxAccessToken/State.ts +7 -0
  54. package/src/contexts/MapboxAccessToken/index.ts +4 -0
  55. package/src/contexts/MapboxAccessToken/use.ts +7 -0
  56. package/src/contexts/index.ts +1 -0
  57. package/src/hooks/index.ts +3 -0
  58. package/src/hooks/useFindHashes.tsx +29 -0
  59. package/src/hooks/useHeatMapColors.tsx +28 -0
  60. package/src/hooks/useQuadKeyPayloadsToFeatures.tsx +55 -0
  61. package/src/index.ts +7 -0
  62. package/src/lib/MapStyle.ts +8 -0
  63. package/src/lib/index.ts +1 -0
  64. package/src/settings/DefaultMapSettings.ts +53 -0
  65. package/src/settings/MapSetting.ts +16 -0
  66. package/src/settings/index.ts +2 -0
  67. package/src/types/NetworkLocationAnswerBase.ts +32 -0
  68. package/src/types/index.ts +1 -0
  69. package/typedoc.json +5 -0
  70. package/xy.config.ts +10 -0
package/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ [![logo][]](https://xyo.network)
2
+
3
+ Part of [@xyo-network/sdk-xyo-react](https://www.npmjs.com/package/@xyo-network/sdk-xyo-react)
4
+
5
+ ## License
6
+
7
+ > See the [LICENSE](LICENSE) file for license details
8
+
9
+ ## Credits
10
+
11
+ [Made with 🔥 and ❄️ by XYO](https://xyo.network)
12
+
13
+ [logo]: https://cdn.xy.company/img/brand/XYO_full_colored.png
@@ -0,0 +1,2 @@
1
+ export declare const AnimatedHeatMapSettings: import("./settings/MapSetting.ts").MapSetting;
2
+ //# sourceMappingURL=AnimatedHeatMapSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AnimatedHeatMapSettings.d.ts","sourceRoot":"","sources":["../../src/AnimatedHeatMapSettings.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,+CAAuB,CAAA"}
@@ -0,0 +1,17 @@
1
+ export interface HeatMapColorProps {
2
+ staticMapColor: string;
3
+ }
4
+ export interface AnimatedHeatMapColorProps extends HeatMapColorProps {
5
+ highUsageColor: string;
6
+ lowUsageColor: string;
7
+ }
8
+ export interface ColorGradientLegendProps {
9
+ endColor: string;
10
+ endLabel: string;
11
+ heading: string;
12
+ startColor: string;
13
+ startLabel: string;
14
+ textColor: string;
15
+ }
16
+ export type LegendProps = ColorGradientLegendProps;
17
+ //# sourceMappingURL=MapColorProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapColorProps.d.ts","sourceRoot":"","sources":["../../../src/colors/MapColorProps.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,cAAc,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,WAAW,GAAG,wBAAwB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './MapColorProps.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/colors/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { MapboxAccessTokenContextState } from './State.ts';
2
+ export declare const MapboxAccessTokenContext: import("react").Context<MapboxAccessTokenContextState & import("@xyo-network/react-shared").ContextExState>;
3
+ //# sourceMappingURL=Context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../../src/contexts/MapboxAccessToken/Context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAA;AAE/D,eAAO,MAAM,wBAAwB,6GAAmD,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import React from 'react';
3
+ export interface MapboxAccessTokenProviderProps {
4
+ defaultAccessToken?: string;
5
+ }
6
+ export declare const MapboxAccessTokenProvider: React.FC<PropsWithChildren<MapboxAccessTokenProviderProps>>;
7
+ //# sourceMappingURL=Provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../../src/contexts/MapboxAccessToken/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAA4B,MAAM,OAAO,CAAA;AAIhD,MAAM,WAAW,8BAA8B;IAC7C,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,8BAA8B,CAAC,CAajG,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { ContextExState } from '@xyo-network/react-shared';
2
+ import type { Dispatch } from 'react';
3
+ export interface MapboxAccessTokenContextState extends ContextExState {
4
+ accessToken?: string;
5
+ setAccessToken?: Dispatch<string>;
6
+ }
7
+ //# sourceMappingURL=State.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../../src/contexts/MapboxAccessToken/State.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAErC,MAAM,WAAW,6BAA8B,SAAQ,cAAc;IACnE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;CAClC"}
@@ -0,0 +1,5 @@
1
+ export * from './Context.ts';
2
+ export * from './Provider.tsx';
3
+ export * from './State.ts';
4
+ export * from './use.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/MapboxAccessToken/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const useMapboxAccessToken: (required?: boolean) => Omit<import("./State.ts").MapboxAccessTokenContextState & import("@xyo-network/react-shared").ContextExState, "provided">;
2
+ //# sourceMappingURL=use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../../src/contexts/MapboxAccessToken/use.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB,mJAEhC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './MapboxAccessToken/index.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA"}
@@ -0,0 +1,4 @@
1
+ export * from './useFindHashes.tsx';
2
+ export * from './useHeatMapColors.tsx';
3
+ export * from './useQuadKeyPayloadsToFeatures.tsx';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oCAAoC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const useFindHashes: () => Lowercase<string>[];
2
+ //# sourceMappingURL=useFindHashes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFindHashes.d.ts","sourceRoot":"","sources":["../../../src/hooks/useFindHashes.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,aAAa,2BAOzB,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { AnimatedHeatMapColorProps, ColorGradientLegendProps } from '../colors/index.ts';
2
+ declare const useHeatMapColors: () => {
3
+ heatMapColorProps: AnimatedHeatMapColorProps;
4
+ legendProps: ColorGradientLegendProps;
5
+ };
6
+ export { useHeatMapColors };
7
+ //# sourceMappingURL=useHeatMapColors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeatMapColors.d.ts","sourceRoot":"","sources":["../../../src/hooks/useHeatMapColors.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAE7F,QAAA,MAAM,gBAAgB;;;CAqBrB,CAAA;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { Feature, Geometry } from 'geojson';
2
+ import type { NetworkLocationHeatmapQuadkeyAnswerPayload } from '../types/index.ts';
3
+ declare const useQuadKeyPayloadsToFeatures: (payloads?: NetworkLocationHeatmapQuadkeyAnswerPayload[] | NetworkLocationHeatmapQuadkeyAnswerPayload) => {
4
+ error: Error | undefined;
5
+ features: Feature<Geometry, import("geojson").GeoJsonProperties>[];
6
+ multipleFeatureSets: Feature<Geometry, import("geojson").GeoJsonProperties>[][];
7
+ };
8
+ export { useQuadKeyPayloadsToFeatures };
9
+ //# sourceMappingURL=useQuadKeyPayloadsToFeatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQuadKeyPayloadsToFeatures.d.ts","sourceRoot":"","sources":["../../../src/hooks/useQuadKeyPayloadsToFeatures.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGhD,OAAO,KAAK,EAAE,0CAA0C,EAAE,MAAM,mBAAmB,CAAA;AAkBnF,QAAA,MAAM,4BAA4B,cAAe,0CAA0C,EAAE,GAAG,0CAA0C;;;;CA6BzI,CAAA;AAED,OAAO,EAAE,4BAA4B,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ export * from './AnimatedHeatMapSettings.ts';
2
+ export * from './colors/index.ts';
3
+ export * from './contexts/index.ts';
4
+ export * from './hooks/index.ts';
5
+ export * from './lib/index.ts';
6
+ export * from './settings/index.ts';
7
+ export * from './types/index.ts';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,mBAAmB,CAAA;AACjC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,235 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/settings/DefaultMapSettings.ts
5
+ var DefaultMapSettings = /* @__PURE__ */ __name(() => ({
6
+ debugLayer: {
7
+ devMode: true,
8
+ field: "debugLayer",
9
+ hidden: true,
10
+ label: "Debug Layer",
11
+ value: false
12
+ },
13
+ debugLogging: {
14
+ devMode: true,
15
+ field: "debugLogging",
16
+ hidden: true,
17
+ label: "Debug Logging",
18
+ value: false
19
+ },
20
+ dynamicMapResize: {
21
+ devMode: true,
22
+ field: "dynamicMapResize",
23
+ hidden: true,
24
+ label: "Auto Map Resize",
25
+ value: true
26
+ },
27
+ enableControls: {
28
+ devMode: true,
29
+ field: "enableControls",
30
+ hidden: true,
31
+ label: "Map Controls",
32
+ value: false
33
+ },
34
+ fitToPoints: {
35
+ devMode: true,
36
+ field: "fitToPoints",
37
+ hidden: true,
38
+ label: "Fit To Points",
39
+ value: false
40
+ },
41
+ preferDark: {
42
+ devMode: false,
43
+ field: "preferDark",
44
+ hidden: true,
45
+ label: "Prefer dark",
46
+ value: false
47
+ },
48
+ scrollToZoom: {
49
+ devMode: true,
50
+ field: "scrollToZoom",
51
+ hidden: true,
52
+ label: "Scroll To Zoom",
53
+ value: false
54
+ }
55
+ }), "DefaultMapSettings");
56
+
57
+ // src/AnimatedHeatMapSettings.ts
58
+ var AnimatedHeatMapSettings = DefaultMapSettings();
59
+ var { debugLayer, scrollToZoom, fitToPoints, preferDark } = AnimatedHeatMapSettings;
60
+ debugLayer.hidden = false;
61
+ scrollToZoom.value = true;
62
+ fitToPoints.value = false;
63
+ preferDark.value = true;
64
+
65
+ // src/contexts/MapboxAccessToken/Context.ts
66
+ import { createContextEx } from "@xyo-network/react-shared";
67
+ var MapboxAccessTokenContext = createContextEx();
68
+
69
+ // src/contexts/MapboxAccessToken/Provider.tsx
70
+ import React, { useMemo, useState } from "react";
71
+ var MapboxAccessTokenProvider = /* @__PURE__ */ __name(({ defaultAccessToken, ...props }) => {
72
+ const [accessToken, setAccessToken] = useState();
73
+ const value = useMemo(() => ({
74
+ accessToken: accessToken ?? defaultAccessToken,
75
+ provided: true,
76
+ setAccessToken
77
+ }), [
78
+ accessToken,
79
+ defaultAccessToken,
80
+ setAccessToken
81
+ ]);
82
+ return /* @__PURE__ */ React.createElement(MapboxAccessTokenContext.Provider, {
83
+ value,
84
+ ...props
85
+ });
86
+ }, "MapboxAccessTokenProvider");
87
+
88
+ // src/contexts/MapboxAccessToken/use.ts
89
+ import { useContextEx } from "@xyo-network/react-shared";
90
+ var useMapboxAccessToken = /* @__PURE__ */ __name((required = false) => {
91
+ return useContextEx(MapboxAccessTokenContext, "MapboxAccessToken", required);
92
+ }, "useMapboxAccessToken");
93
+
94
+ // src/hooks/useFindHashes.tsx
95
+ import { useNetwork } from "@xyo-network/react-network";
96
+ import { useMemo as useMemo2 } from "react";
97
+ var animatedAnswerHashesConst = [
98
+ "79af071f451fc7af10d009dc63236ef9a9b211732c1ee0c06f028fcecf2336c5",
99
+ "531bfba6d8dfefd3bcc888aca54cdbbd4574ed2b3ec551b230845a1f9a608898",
100
+ "c874412b4faa4947de81372fd1ba12fdd6f43f5e408622b7f357cb2bcb3f17cb",
101
+ "29d3f8b882c61a82a1a1675782a27e797ea7196f45a23b4409680ab8b8d5f14e",
102
+ "cfd20f80ac073fd9518f4ef3f43d2a1f5e4e56e40c2677f38d6f6fecd05df60c",
103
+ "1354fa73497519a39aed19fc99bdbae78a880a1eafb2f7898d607e07db36528d",
104
+ "1043b0d25eacfc5013ae9dba780305a6fbf01a43543bd871d7c00537fca142a9",
105
+ "973dfc5df142851ced258d52d0ac2784e814000ac22e35776f772256b0d4dde9",
106
+ "463808eb74d3d87e6563970e0301a493577f8cd1b501e6e0ffa5e027ad2cea95",
107
+ "15b21acea2e3fd9d1ace3768a72636ee7bdf67a6f8e0807bfa2273dea2207555",
108
+ "32d377bfe7ebe382598c54dd13f8af7510e0a1e2fd2e913311fdd58e517e5e2e,"
109
+ ];
110
+ var staticAnswerHashConst = "c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b227a2c6e558d9d3a5";
111
+ var useFindHashes = /* @__PURE__ */ __name(() => {
112
+ const { network } = useNetwork();
113
+ const exploreMapHashes = network?.nodes?.find((node) => node.type === "archivist")?.explorerMapHashes;
114
+ const animatedAnswerHashes = exploreMapHashes?.animatedAnswerHashes || animatedAnswerHashesConst;
115
+ const staticAnswerHash = exploreMapHashes?.staticAnswerHash || staticAnswerHashConst;
116
+ const foundHashes = useMemo2(() => [
117
+ staticAnswerHash,
118
+ ...animatedAnswerHashes
119
+ ], [
120
+ animatedAnswerHashes,
121
+ staticAnswerHash
122
+ ]);
123
+ return foundHashes;
124
+ }, "useFindHashes");
125
+
126
+ // src/hooks/useHeatMapColors.tsx
127
+ import { useTheme } from "@mui/material";
128
+ var useHeatMapColors = /* @__PURE__ */ __name(() => {
129
+ const theme = useTheme();
130
+ const staticMapColor = "#FFFF75";
131
+ const highUsageColor = "#FF0000";
132
+ const heatMapColorProps = {
133
+ highUsageColor,
134
+ lowUsageColor: "#FFB3B3",
135
+ staticMapColor
136
+ };
137
+ const legendProps = {
138
+ endColor: highUsageColor,
139
+ endLabel: "High",
140
+ heading: "Network Usage",
141
+ startColor: staticMapColor,
142
+ startLabel: "Low",
143
+ textColor: theme.palette.common.white
144
+ };
145
+ return {
146
+ heatMapColorProps,
147
+ legendProps
148
+ };
149
+ }, "useHeatMapColors");
150
+
151
+ // src/hooks/useQuadKeyPayloadsToFeatures.tsx
152
+ import { exists } from "@xylabs/exists";
153
+ import { GeoJson } from "@xyo-network/sdk-geo";
154
+ import { useMemo as useMemo3, useState as useState2 } from "react";
155
+ var quadKeyToFeature = /* @__PURE__ */ __name(({ density, quadkey }) => {
156
+ const polygonFeature = new GeoJson(quadkey).polygonFeature();
157
+ polygonFeature.properties = {
158
+ count: density,
159
+ density
160
+ };
161
+ return polygonFeature;
162
+ }, "quadKeyToFeature");
163
+ var setDensity = /* @__PURE__ */ __name((feature) => {
164
+ if (feature.properties) {
165
+ feature.properties.value = feature.properties.density / 5;
166
+ }
167
+ return feature;
168
+ }, "setDensity");
169
+ var useQuadKeyPayloadsToFeatures = /* @__PURE__ */ __name((payloads) => {
170
+ const [multipleFeatureSets, setMultipleFeatureSets] = useState2([
171
+ []
172
+ ]);
173
+ const [features, setFeatures] = useState2([]);
174
+ const [error, setError] = useState2();
175
+ useMemo3(() => {
176
+ if (Array.isArray(payloads)) {
177
+ if (payloads?.filter(exists).length > 0) {
178
+ const mappedFeatures = payloads?.map((payload) => payload?.result.map(quadKeyToFeature));
179
+ setMultipleFeatureSets(mappedFeatures.map((features2) => features2?.map(setDensity) ?? []));
180
+ } else {
181
+ setError(new Error("Cannot find payloads for provided hashes"));
182
+ }
183
+ }
184
+ if (payloads && payloads.result) {
185
+ const singlePayload = payloads;
186
+ const mappedFeatures = singlePayload.result.map(quadKeyToFeature);
187
+ setFeatures(mappedFeatures.map(setDensity));
188
+ }
189
+ }, [
190
+ payloads
191
+ ]);
192
+ return {
193
+ error,
194
+ features,
195
+ multipleFeatureSets
196
+ };
197
+ }, "useQuadKeyPayloadsToFeatures");
198
+
199
+ // src/lib/MapStyle.ts
200
+ var MapStyle = /* @__PURE__ */ function(MapStyle2) {
201
+ MapStyle2["Dark"] = "mapbox/dark-v10";
202
+ MapStyle2["Light"] = "mapbox/light-v10";
203
+ MapStyle2["Outdoors"] = "mapbox/outdoors-v11";
204
+ MapStyle2["Satellite"] = "mapbox/satellite-v9";
205
+ MapStyle2["SatelliteStreets"] = "mapbox/satellite-streets-v11";
206
+ MapStyle2["Streets"] = "mapbox/streets-v11";
207
+ return MapStyle2;
208
+ }({});
209
+
210
+ // src/types/NetworkLocationAnswerBase.ts
211
+ import { isPayloadOfSchemaType } from "@xyo-network/payload-model";
212
+ var NetworkLocationAnswerSchema = "network.xyo.location.range.answer";
213
+ var isNetworkLocationAnswer = isPayloadOfSchemaType(NetworkLocationAnswerSchema);
214
+ var NetworkLocationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
215
+ var isNetworkLocationHeatmapAnswer = isPayloadOfSchemaType(NetworkLocationHeatmapAnswerSchema);
216
+ var NetworkLocationHeatmapQuadkeyAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
217
+ var isNetworkLocationHeatmapQuadkeyAnswer = isPayloadOfSchemaType(NetworkLocationHeatmapQuadkeyAnswerSchema);
218
+ export {
219
+ AnimatedHeatMapSettings,
220
+ DefaultMapSettings,
221
+ MapStyle,
222
+ MapboxAccessTokenContext,
223
+ MapboxAccessTokenProvider,
224
+ NetworkLocationAnswerSchema,
225
+ NetworkLocationHeatmapAnswerSchema,
226
+ NetworkLocationHeatmapQuadkeyAnswerSchema,
227
+ isNetworkLocationAnswer,
228
+ isNetworkLocationHeatmapAnswer,
229
+ isNetworkLocationHeatmapQuadkeyAnswer,
230
+ useFindHashes,
231
+ useHeatMapColors,
232
+ useMapboxAccessToken,
233
+ useQuadKeyPayloadsToFeatures
234
+ };
235
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/settings/DefaultMapSettings.ts","../../src/AnimatedHeatMapSettings.ts","../../src/contexts/MapboxAccessToken/Context.ts","../../src/contexts/MapboxAccessToken/Provider.tsx","../../src/contexts/MapboxAccessToken/use.ts","../../src/hooks/useFindHashes.tsx","../../src/hooks/useHeatMapColors.tsx","../../src/hooks/useQuadKeyPayloadsToFeatures.tsx","../../src/lib/MapStyle.ts","../../src/types/NetworkLocationAnswerBase.ts"],"sourcesContent":["import type { MapSetting } from './MapSetting.ts'\n\nexport const DefaultMapSettings: () => MapSetting = () => ({\n debugLayer: {\n devMode: true,\n field: 'debugLayer',\n hidden: true,\n label: 'Debug Layer',\n value: false,\n },\n debugLogging: {\n devMode: true,\n field: 'debugLogging',\n hidden: true,\n label: 'Debug Logging',\n value: false,\n },\n dynamicMapResize: {\n devMode: true,\n field: 'dynamicMapResize',\n hidden: true,\n label: 'Auto Map Resize',\n value: true,\n },\n enableControls: {\n devMode: true,\n field: 'enableControls',\n hidden: true,\n label: 'Map Controls',\n value: false,\n },\n fitToPoints: {\n devMode: true,\n field: 'fitToPoints',\n hidden: true,\n label: 'Fit To Points',\n value: false,\n },\n preferDark: {\n devMode: false,\n field: 'preferDark',\n hidden: true,\n label: 'Prefer dark',\n value: false,\n },\n scrollToZoom: {\n devMode: true,\n field: 'scrollToZoom',\n hidden: true,\n label: 'Scroll To Zoom',\n value: false,\n },\n})\n","import { DefaultMapSettings } from './settings/index.ts'\n\nexport const AnimatedHeatMapSettings = DefaultMapSettings()\nconst {\n debugLayer, scrollToZoom, fitToPoints, preferDark,\n} = AnimatedHeatMapSettings\ndebugLayer.hidden = false\nscrollToZoom.value = true\nfitToPoints.value = false\npreferDark.value = true\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport type { MapboxAccessTokenContextState } from './State.ts'\n\nexport const MapboxAccessTokenContext = createContextEx<MapboxAccessTokenContextState>()\n","import type { PropsWithChildren } from 'react'\nimport React, { useMemo, useState } from 'react'\n\nimport { MapboxAccessTokenContext } from './Context.ts'\n\nexport interface MapboxAccessTokenProviderProps {\n defaultAccessToken?: string\n}\n\nexport const MapboxAccessTokenProvider: React.FC<PropsWithChildren<MapboxAccessTokenProviderProps>> = ({ defaultAccessToken, ...props }) => {\n const [accessToken, setAccessToken] = useState<string>()\n\n const value = useMemo(() => ({\n accessToken: accessToken ?? defaultAccessToken, provided: true, setAccessToken,\n }), [accessToken, defaultAccessToken, setAccessToken])\n\n return (\n <MapboxAccessTokenContext.Provider\n value={value}\n {...props}\n />\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { MapboxAccessTokenContext } from './Context.ts'\n\nexport const useMapboxAccessToken = (required = false) => {\n return useContextEx(MapboxAccessTokenContext, 'MapboxAccessToken', required)\n}\n","import type { Hash } from '@xylabs/hex'\nimport type { ArchivistPreset } from '@xyo-network/react-network'\nimport { useNetwork } from '@xyo-network/react-network'\nimport { useMemo } from 'react'\n\nconst animatedAnswerHashesConst: Hash[] = [\n '79af071f451fc7af10d009dc63236ef9a9b211732c1ee0c06f028fcecf2336c5',\n '531bfba6d8dfefd3bcc888aca54cdbbd4574ed2b3ec551b230845a1f9a608898',\n 'c874412b4faa4947de81372fd1ba12fdd6f43f5e408622b7f357cb2bcb3f17cb',\n '29d3f8b882c61a82a1a1675782a27e797ea7196f45a23b4409680ab8b8d5f14e',\n 'cfd20f80ac073fd9518f4ef3f43d2a1f5e4e56e40c2677f38d6f6fecd05df60c',\n '1354fa73497519a39aed19fc99bdbae78a880a1eafb2f7898d607e07db36528d',\n '1043b0d25eacfc5013ae9dba780305a6fbf01a43543bd871d7c00537fca142a9',\n '973dfc5df142851ced258d52d0ac2784e814000ac22e35776f772256b0d4dde9',\n '463808eb74d3d87e6563970e0301a493577f8cd1b501e6e0ffa5e027ad2cea95',\n '15b21acea2e3fd9d1ace3768a72636ee7bdf67a6f8e0807bfa2273dea2207555',\n '32d377bfe7ebe382598c54dd13f8af7510e0a1e2fd2e913311fdd58e517e5e2e,',\n]\n\nconst staticAnswerHashConst: Hash = 'c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b227a2c6e558d9d3a5'\n\nexport const useFindHashes = () => {\n const { network } = useNetwork()\n const exploreMapHashes = (network?.nodes?.find(node => node.type === 'archivist') as ArchivistPreset)?.explorerMapHashes\n const animatedAnswerHashes = exploreMapHashes?.animatedAnswerHashes || animatedAnswerHashesConst\n const staticAnswerHash = exploreMapHashes?.staticAnswerHash || staticAnswerHashConst\n const foundHashes = useMemo(() => [staticAnswerHash, ...animatedAnswerHashes], [animatedAnswerHashes, staticAnswerHash])\n return foundHashes\n}\n","import { useTheme } from '@mui/material'\n\nimport type { AnimatedHeatMapColorProps, ColorGradientLegendProps } from '../colors/index.ts'\n\nconst useHeatMapColors = () => {\n const theme = useTheme()\n const staticMapColor = '#FFFF75'\n const highUsageColor = '#FF0000'\n\n const heatMapColorProps: AnimatedHeatMapColorProps = {\n highUsageColor,\n lowUsageColor: '#FFB3B3',\n staticMapColor,\n }\n\n const legendProps: ColorGradientLegendProps = {\n endColor: highUsageColor,\n endLabel: 'High',\n heading: 'Network Usage',\n startColor: staticMapColor,\n startLabel: 'Low',\n textColor: theme.palette.common.white,\n }\n\n return { heatMapColorProps, legendProps }\n}\n\nexport { useHeatMapColors }\n","import { exists } from '@xylabs/exists'\nimport { GeoJson } from '@xyo-network/sdk-geo'\nimport type { Feature, Geometry } from 'geojson'\nimport { useMemo, useState } from 'react'\n\nimport type { NetworkLocationHeatmapQuadkeyAnswerPayload } from '../types/index.ts'\n\nconst quadKeyToFeature = ({ density, quadkey }: { density: number; quadkey: string }) => {\n const polygonFeature = new GeoJson(quadkey).polygonFeature()\n polygonFeature.properties = {\n count: density,\n density,\n }\n return polygonFeature\n}\n\nconst setDensity = (feature: Feature) => {\n if (feature.properties) {\n feature.properties.value = feature.properties.density / 5\n }\n return feature\n}\n\nconst useQuadKeyPayloadsToFeatures = (payloads?: NetworkLocationHeatmapQuadkeyAnswerPayload[] | NetworkLocationHeatmapQuadkeyAnswerPayload) => {\n const [multipleFeatureSets, setMultipleFeatureSets] = useState<Feature<Geometry>[][]>([[]])\n const [features, setFeatures] = useState<Feature<Geometry>[]>([])\n const [error, setError] = useState<Error>()\n\n useMemo(() => {\n // Convert Multiple Payloads from Quadkey to GeoJson\n if (Array.isArray(payloads)) {\n if ((payloads)?.filter(exists).length > 0) {\n const mappedFeatures = payloads?.map(payload => payload?.result.map(quadKeyToFeature))\n\n setMultipleFeatureSets(mappedFeatures.map(features => features?.map(setDensity) ?? []))\n } else {\n setError(new Error('Cannot find payloads for provided hashes'))\n }\n }\n\n // Convert Single Payload from Quadkey to GeoJson\n if (payloads && (payloads as NetworkLocationHeatmapQuadkeyAnswerPayload).result) {\n const singlePayload = payloads as NetworkLocationHeatmapQuadkeyAnswerPayload\n const mappedFeatures = singlePayload.result.map(quadKeyToFeature)\n\n setFeatures(mappedFeatures.map(setDensity))\n }\n }, [payloads])\n\n return {\n error, features, multipleFeatureSets,\n }\n}\n\nexport { useQuadKeyPayloadsToFeatures }\n","export enum MapStyle {\n Dark = 'mapbox/dark-v10',\n Light = 'mapbox/light-v10',\n Outdoors = 'mapbox/outdoors-v11',\n Satellite = 'mapbox/satellite-v9',\n SatelliteStreets = 'mapbox/satellite-streets-v11',\n Streets = 'mapbox/streets-v11',\n}\n","import type { Payload } from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType } from '@xyo-network/payload-model'\nimport type {\n Feature, Point, Polygon,\n} from 'geojson'\n\nexport interface NetworkLocationAnswerBase<T> {\n result: T\n}\n\nexport const NetworkLocationAnswerSchema = 'network.xyo.location.range.answer'\nexport type NetworkLocationAnswerSchema = 'network.xyo.location.range.answer'\nexport type NetworkLocationAnswerPayload = Payload<NetworkLocationAnswerBase<{ features: Feature<Point>[] }>, NetworkLocationAnswerSchema>\nexport const isNetworkLocationAnswer = isPayloadOfSchemaType<NetworkLocationAnswerPayload>(NetworkLocationAnswerSchema)\n\nexport const NetworkLocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\nexport type NetworkLocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'\nexport type NetworkLocationHeatmapAnswerPayload = Payload<\n NetworkLocationAnswerBase<{ features: Feature<Polygon>[] }>,\n NetworkLocationHeatmapAnswerSchema\n>\nexport const isNetworkLocationHeatmapAnswer = isPayloadOfSchemaType<NetworkLocationHeatmapAnswerPayload>(NetworkLocationHeatmapAnswerSchema)\n\nexport const NetworkLocationHeatmapQuadkeyAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport type NetworkLocationHeatmapQuadkeyAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'\nexport type NetworkLocationHeatmapQuadkeyAnswerPayload = Payload<\n NetworkLocationAnswerBase<{ density: number; quadkey: string }[]>,\n NetworkLocationHeatmapQuadkeyAnswerSchema\n>\nexport const isNetworkLocationHeatmapQuadkeyAnswer = isPayloadOfSchemaType<NetworkLocationHeatmapAnswerPayload>(\n NetworkLocationHeatmapQuadkeyAnswerSchema,\n)\n"],"mappings":"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","names":["DefaultMapSettings","debugLayer","devMode","field","hidden","label","value","debugLogging","dynamicMapResize","enableControls","fitToPoints","preferDark","scrollToZoom","AnimatedHeatMapSettings","DefaultMapSettings","debugLayer","scrollToZoom","fitToPoints","preferDark","hidden","value","createContextEx","MapboxAccessTokenContext","React","useMemo","useState","MapboxAccessTokenProvider","defaultAccessToken","props","accessToken","setAccessToken","useState","value","useMemo","provided","MapboxAccessTokenContext","Provider","useContextEx","useMapboxAccessToken","required","useContextEx","MapboxAccessTokenContext","useNetwork","useMemo","animatedAnswerHashesConst","staticAnswerHashConst","useFindHashes","network","useNetwork","exploreMapHashes","nodes","find","node","type","explorerMapHashes","animatedAnswerHashes","staticAnswerHash","foundHashes","useMemo","useTheme","useHeatMapColors","theme","useTheme","staticMapColor","highUsageColor","heatMapColorProps","lowUsageColor","legendProps","endColor","endLabel","heading","startColor","startLabel","textColor","palette","common","white","exists","GeoJson","useMemo","useState","quadKeyToFeature","density","quadkey","polygonFeature","GeoJson","properties","count","setDensity","feature","value","useQuadKeyPayloadsToFeatures","payloads","multipleFeatureSets","setMultipleFeatureSets","useState","features","setFeatures","error","setError","useMemo","Array","isArray","filter","exists","length","mappedFeatures","map","payload","result","Error","singlePayload","MapStyle","isPayloadOfSchemaType","NetworkLocationAnswerSchema","isNetworkLocationAnswer","NetworkLocationHeatmapAnswerSchema","isNetworkLocationHeatmapAnswer","NetworkLocationHeatmapQuadkeyAnswerSchema","isNetworkLocationHeatmapQuadkeyAnswer"]}
@@ -0,0 +1,9 @@
1
+ export declare enum MapStyle {
2
+ Dark = "mapbox/dark-v10",
3
+ Light = "mapbox/light-v10",
4
+ Outdoors = "mapbox/outdoors-v11",
5
+ Satellite = "mapbox/satellite-v9",
6
+ SatelliteStreets = "mapbox/satellite-streets-v11",
7
+ Streets = "mapbox/streets-v11"
8
+ }
9
+ //# sourceMappingURL=MapStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapStyle.d.ts","sourceRoot":"","sources":["../../../src/lib/MapStyle.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,IAAI,oBAAoB;IACxB,KAAK,qBAAqB;IAC1B,QAAQ,wBAAwB;IAChC,SAAS,wBAAwB;IACjC,gBAAgB,iCAAiC;IACjD,OAAO,uBAAuB;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export * from './MapStyle.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { MapSetting } from './MapSetting.ts';
2
+ export declare const DefaultMapSettings: () => MapSetting;
3
+ //# sourceMappingURL=DefaultMapSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DefaultMapSettings.d.ts","sourceRoot":"","sources":["../../../src/settings/DefaultMapSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,eAAO,MAAM,kBAAkB,EAAE,MAAM,UAkDrC,CAAA"}
@@ -0,0 +1,16 @@
1
+ export type MapSettingFields = 'debugLayer' | 'fitToPoints' | 'scrollToZoom' | 'enableControls' | 'debugLogging' | 'preferDark' | 'dynamicMapResize';
2
+ export type MapSetting = {
3
+ [field in MapSettingFields | string]: {
4
+ /** Setting only available when application is in developerMode */
5
+ devMode?: boolean;
6
+ /** Machine-readable string to reference setting */
7
+ field: string;
8
+ /** Hide the setting from the UI */
9
+ hidden?: boolean;
10
+ /** Label in the UI */
11
+ label: string;
12
+ /** Initial toggle value for a setting */
13
+ value: boolean;
14
+ };
15
+ };
16
+ //# sourceMappingURL=MapSetting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapSetting.d.ts","sourceRoot":"","sources":["../../../src/settings/MapSetting.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,aAAa,GAAG,cAAc,GAAG,gBAAgB,GAAG,cAAc,GAAG,YAAY,GAAG,kBAAkB,CAAA;AAEpJ,MAAM,MAAM,UAAU,GAAG;KACtB,KAAK,IAAI,gBAAgB,GAAG,MAAM,GAAG;QACpC,kEAAkE;QAClE,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,mDAAmD;QACnD,KAAK,EAAE,MAAM,CAAA;QACb,mCAAmC;QACnC,MAAM,CAAC,EAAE,OAAO,CAAA;QAChB,sBAAsB;QACtB,KAAK,EAAE,MAAM,CAAA;QACb,yCAAyC;QACzC,KAAK,EAAE,OAAO,CAAA;KACf;CACF,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './DefaultMapSettings.ts';
2
+ export * from './MapSetting.ts';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/settings/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,37 @@
1
+ import type { Payload } from '@xyo-network/payload-model';
2
+ import type { Feature, Point, Polygon } from 'geojson';
3
+ export interface NetworkLocationAnswerBase<T> {
4
+ result: T;
5
+ }
6
+ export declare const NetworkLocationAnswerSchema = "network.xyo.location.range.answer";
7
+ export type NetworkLocationAnswerSchema = 'network.xyo.location.range.answer';
8
+ export type NetworkLocationAnswerPayload = Payload<NetworkLocationAnswerBase<{
9
+ features: Feature<Point>[];
10
+ }>, NetworkLocationAnswerSchema>;
11
+ export declare const isNetworkLocationAnswer: (x?: unknown | null) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & NetworkLocationAnswerBase<{
12
+ features: Feature<Point>[];
13
+ }> & {
14
+ schema: "network.xyo.location.range.answer";
15
+ };
16
+ export declare const NetworkLocationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
17
+ export type NetworkLocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer';
18
+ export type NetworkLocationHeatmapAnswerPayload = Payload<NetworkLocationAnswerBase<{
19
+ features: Feature<Polygon>[];
20
+ }>, NetworkLocationHeatmapAnswerSchema>;
21
+ export declare const isNetworkLocationHeatmapAnswer: (x?: unknown | null) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & NetworkLocationAnswerBase<{
22
+ features: Feature<Polygon>[];
23
+ }> & {
24
+ schema: "network.xyo.location.heatmap.answer";
25
+ };
26
+ export declare const NetworkLocationHeatmapQuadkeyAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
27
+ export type NetworkLocationHeatmapQuadkeyAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer';
28
+ export type NetworkLocationHeatmapQuadkeyAnswerPayload = Payload<NetworkLocationAnswerBase<{
29
+ density: number;
30
+ quadkey: string;
31
+ }[]>, NetworkLocationHeatmapQuadkeyAnswerSchema>;
32
+ export declare const isNetworkLocationHeatmapQuadkeyAnswer: (x?: unknown | null) => x is import("@xyo-network/payload-model").SchemaFields & import("@xyo-network/payload-model").PayloadFields & NetworkLocationAnswerBase<{
33
+ features: Feature<Polygon>[];
34
+ }> & {
35
+ schema: "network.xyo.location.heatmap.answer";
36
+ };
37
+ //# sourceMappingURL=NetworkLocationAnswerBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NetworkLocationAnswerBase.d.ts","sourceRoot":"","sources":["../../../src/types/NetworkLocationAnswerBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEzD,OAAO,KAAK,EACV,OAAO,EAAE,KAAK,EAAE,OAAO,EACxB,MAAM,SAAS,CAAA;AAEhB,MAAM,WAAW,yBAAyB,CAAC,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAA;CACV;AAED,eAAO,MAAM,2BAA2B,sCAAsC,CAAA;AAC9E,MAAM,MAAM,2BAA2B,GAAG,mCAAmC,CAAA;AAC7E,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAA;CAAE,CAAC,EAAE,2BAA2B,CAAC,CAAA;AAC1I,eAAO,MAAM,uBAAuB;cADqD,OAAO,CAAC,KAAK,CAAC,EAAE;;;CACc,CAAA;AAEvH,eAAO,MAAM,kCAAkC,wCAAwC,CAAA;AACvF,MAAM,MAAM,kCAAkC,GAAG,qCAAqC,CAAA;AACtF,MAAM,MAAM,mCAAmC,GAAG,OAAO,CACvD,yBAAyB,CAAC;IAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,CAAA;CAAE,CAAC,EAC3D,kCAAkC,CACnC,CAAA;AACD,eAAO,MAAM,8BAA8B;cAHH,OAAO,CAAC,OAAO,CAAC,EAAE;;;CAGkF,CAAA;AAE5I,eAAO,MAAM,yCAAyC,gDAAgD,CAAA;AACtG,MAAM,MAAM,yCAAyC,GAAG,6CAA6C,CAAA;AACrG,MAAM,MAAM,0CAA0C,GAAG,OAAO,CAC9D,yBAAyB,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,EACjE,yCAAyC,CAC1C,CAAA;AACD,eAAO,MAAM,qCAAqC;cAXV,OAAO,CAAC,OAAO,CAAC,EAAE;;;CAazD,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './NetworkLocationAnswerBase.ts';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@xyo-network/react-map-model",
3
+ "version": "4.2.0",
4
+ "description": "Common React library for all XYO projects that use React",
5
+ "keywords": [
6
+ "xyo",
7
+ "utility",
8
+ "typescript",
9
+ "react"
10
+ ],
11
+ "homepage": "https://xyo.network",
12
+ "bugs": {
13
+ "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js/issues",
14
+ "email": "support@xyo.network"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/XYOracleNetwork/sdk-xyo-react-js.git"
19
+ },
20
+ "license": "LGPL-3.0-only",
21
+ "author": {
22
+ "name": "XYO Development Team",
23
+ "email": "support@xyo.network",
24
+ "url": "https://xyo.network"
25
+ },
26
+ "sideEffects": false,
27
+ "type": "module",
28
+ "exports": {
29
+ ".": {
30
+ "browser": {
31
+ "types": "./dist/browser/index.d.ts",
32
+ "default": "./dist/browser/index.mjs"
33
+ },
34
+ "types": "./dist/browser/index.d.ts",
35
+ "default": "./dist/browser/index.mjs"
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "module": "dist/browser/index.mjs",
40
+ "types": "dist/browser/index.d.ts",
41
+ "scripts": {
42
+ "license": "yarn license-checker --exclude \"MIT, ISC, Apache-2.0, BSD, BSD-2-Clause, CC-BY-4.0, Unlicense, CC-BY-3.0, CC0-1.0\"",
43
+ "lint-pkg": "npmPkgJsonLint ."
44
+ },
45
+ "dependencies": {
46
+ "@xylabs/exists": "^4.3.3",
47
+ "@xylabs/hex": "^4.3.3",
48
+ "@xyo-network/payload-model": "^3.3.2",
49
+ "@xyo-network/react-network": "^4.2.0",
50
+ "@xyo-network/react-shared": "^4.2.0",
51
+ "@xyo-network/sdk-geo": "^3.0.2"
52
+ },
53
+ "devDependencies": {
54
+ "@mui/icons-material": "^6.1.6",
55
+ "@mui/material": "^6.1.6",
56
+ "@mui/styles": "^6.1.6",
57
+ "@types/geojson": "7946.0.14",
58
+ "@xylabs/ts-scripts-yarn3": "^4.2.3",
59
+ "@xylabs/tsconfig-react": "^4.2.3",
60
+ "react": "^18.3.1",
61
+ "react-dom": "^18.3.1",
62
+ "typescript": "^5.6.3"
63
+ },
64
+ "peerDependencies": {
65
+ "@mui/icons-material": "^6",
66
+ "@mui/material": "^6",
67
+ "@mui/styles": "^6",
68
+ "react": "^18",
69
+ "react-dom": "^18"
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "docs": "dist/docs.json"
75
+ }
@@ -0,0 +1,10 @@
1
+ import { DefaultMapSettings } from './settings/index.ts'
2
+
3
+ export const AnimatedHeatMapSettings = DefaultMapSettings()
4
+ const {
5
+ debugLayer, scrollToZoom, fitToPoints, preferDark,
6
+ } = AnimatedHeatMapSettings
7
+ debugLayer.hidden = false
8
+ scrollToZoom.value = true
9
+ fitToPoints.value = false
10
+ preferDark.value = true
@@ -0,0 +1,19 @@
1
+ export interface HeatMapColorProps {
2
+ staticMapColor: string
3
+ }
4
+
5
+ export interface AnimatedHeatMapColorProps extends HeatMapColorProps {
6
+ highUsageColor: string
7
+ lowUsageColor: string
8
+ }
9
+
10
+ export interface ColorGradientLegendProps {
11
+ endColor: string
12
+ endLabel: string
13
+ heading: string
14
+ startColor: string
15
+ startLabel: string
16
+ textColor: string
17
+ }
18
+
19
+ export type LegendProps = ColorGradientLegendProps
@@ -0,0 +1 @@
1
+ export * from './MapColorProps.ts'
@@ -0,0 +1,5 @@
1
+ import { createContextEx } from '@xyo-network/react-shared'
2
+
3
+ import type { MapboxAccessTokenContextState } from './State.ts'
4
+
5
+ export const MapboxAccessTokenContext = createContextEx<MapboxAccessTokenContextState>()
@@ -0,0 +1,23 @@
1
+ import type { PropsWithChildren } from 'react'
2
+ import React, { useMemo, useState } from 'react'
3
+
4
+ import { MapboxAccessTokenContext } from './Context.ts'
5
+
6
+ export interface MapboxAccessTokenProviderProps {
7
+ defaultAccessToken?: string
8
+ }
9
+
10
+ export const MapboxAccessTokenProvider: React.FC<PropsWithChildren<MapboxAccessTokenProviderProps>> = ({ defaultAccessToken, ...props }) => {
11
+ const [accessToken, setAccessToken] = useState<string>()
12
+
13
+ const value = useMemo(() => ({
14
+ accessToken: accessToken ?? defaultAccessToken, provided: true, setAccessToken,
15
+ }), [accessToken, defaultAccessToken, setAccessToken])
16
+
17
+ return (
18
+ <MapboxAccessTokenContext.Provider
19
+ value={value}
20
+ {...props}
21
+ />
22
+ )
23
+ }
@@ -0,0 +1,7 @@
1
+ import type { ContextExState } from '@xyo-network/react-shared'
2
+ import type { Dispatch } from 'react'
3
+
4
+ export interface MapboxAccessTokenContextState extends ContextExState {
5
+ accessToken?: string
6
+ setAccessToken?: Dispatch<string>
7
+ }
@@ -0,0 +1,4 @@
1
+ export * from './Context.ts'
2
+ export * from './Provider.tsx'
3
+ export * from './State.ts'
4
+ export * from './use.ts'
@@ -0,0 +1,7 @@
1
+ import { useContextEx } from '@xyo-network/react-shared'
2
+
3
+ import { MapboxAccessTokenContext } from './Context.ts'
4
+
5
+ export const useMapboxAccessToken = (required = false) => {
6
+ return useContextEx(MapboxAccessTokenContext, 'MapboxAccessToken', required)
7
+ }
@@ -0,0 +1 @@
1
+ export * from './MapboxAccessToken/index.ts'
@@ -0,0 +1,3 @@
1
+ export * from './useFindHashes.tsx'
2
+ export * from './useHeatMapColors.tsx'
3
+ export * from './useQuadKeyPayloadsToFeatures.tsx'
@@ -0,0 +1,29 @@
1
+ import type { Hash } from '@xylabs/hex'
2
+ import type { ArchivistPreset } from '@xyo-network/react-network'
3
+ import { useNetwork } from '@xyo-network/react-network'
4
+ import { useMemo } from 'react'
5
+
6
+ const animatedAnswerHashesConst: Hash[] = [
7
+ '79af071f451fc7af10d009dc63236ef9a9b211732c1ee0c06f028fcecf2336c5',
8
+ '531bfba6d8dfefd3bcc888aca54cdbbd4574ed2b3ec551b230845a1f9a608898',
9
+ 'c874412b4faa4947de81372fd1ba12fdd6f43f5e408622b7f357cb2bcb3f17cb',
10
+ '29d3f8b882c61a82a1a1675782a27e797ea7196f45a23b4409680ab8b8d5f14e',
11
+ 'cfd20f80ac073fd9518f4ef3f43d2a1f5e4e56e40c2677f38d6f6fecd05df60c',
12
+ '1354fa73497519a39aed19fc99bdbae78a880a1eafb2f7898d607e07db36528d',
13
+ '1043b0d25eacfc5013ae9dba780305a6fbf01a43543bd871d7c00537fca142a9',
14
+ '973dfc5df142851ced258d52d0ac2784e814000ac22e35776f772256b0d4dde9',
15
+ '463808eb74d3d87e6563970e0301a493577f8cd1b501e6e0ffa5e027ad2cea95',
16
+ '15b21acea2e3fd9d1ace3768a72636ee7bdf67a6f8e0807bfa2273dea2207555',
17
+ '32d377bfe7ebe382598c54dd13f8af7510e0a1e2fd2e913311fdd58e517e5e2e,',
18
+ ]
19
+
20
+ const staticAnswerHashConst: Hash = 'c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b227a2c6e558d9d3a5'
21
+
22
+ export const useFindHashes = () => {
23
+ const { network } = useNetwork()
24
+ const exploreMapHashes = (network?.nodes?.find(node => node.type === 'archivist') as ArchivistPreset)?.explorerMapHashes
25
+ const animatedAnswerHashes = exploreMapHashes?.animatedAnswerHashes || animatedAnswerHashesConst
26
+ const staticAnswerHash = exploreMapHashes?.staticAnswerHash || staticAnswerHashConst
27
+ const foundHashes = useMemo(() => [staticAnswerHash, ...animatedAnswerHashes], [animatedAnswerHashes, staticAnswerHash])
28
+ return foundHashes
29
+ }
@@ -0,0 +1,28 @@
1
+ import { useTheme } from '@mui/material'
2
+
3
+ import type { AnimatedHeatMapColorProps, ColorGradientLegendProps } from '../colors/index.ts'
4
+
5
+ const useHeatMapColors = () => {
6
+ const theme = useTheme()
7
+ const staticMapColor = '#FFFF75'
8
+ const highUsageColor = '#FF0000'
9
+
10
+ const heatMapColorProps: AnimatedHeatMapColorProps = {
11
+ highUsageColor,
12
+ lowUsageColor: '#FFB3B3',
13
+ staticMapColor,
14
+ }
15
+
16
+ const legendProps: ColorGradientLegendProps = {
17
+ endColor: highUsageColor,
18
+ endLabel: 'High',
19
+ heading: 'Network Usage',
20
+ startColor: staticMapColor,
21
+ startLabel: 'Low',
22
+ textColor: theme.palette.common.white,
23
+ }
24
+
25
+ return { heatMapColorProps, legendProps }
26
+ }
27
+
28
+ export { useHeatMapColors }
@@ -0,0 +1,55 @@
1
+ import { exists } from '@xylabs/exists'
2
+ import { GeoJson } from '@xyo-network/sdk-geo'
3
+ import type { Feature, Geometry } from 'geojson'
4
+ import { useMemo, useState } from 'react'
5
+
6
+ import type { NetworkLocationHeatmapQuadkeyAnswerPayload } from '../types/index.ts'
7
+
8
+ const quadKeyToFeature = ({ density, quadkey }: { density: number; quadkey: string }) => {
9
+ const polygonFeature = new GeoJson(quadkey).polygonFeature()
10
+ polygonFeature.properties = {
11
+ count: density,
12
+ density,
13
+ }
14
+ return polygonFeature
15
+ }
16
+
17
+ const setDensity = (feature: Feature) => {
18
+ if (feature.properties) {
19
+ feature.properties.value = feature.properties.density / 5
20
+ }
21
+ return feature
22
+ }
23
+
24
+ const useQuadKeyPayloadsToFeatures = (payloads?: NetworkLocationHeatmapQuadkeyAnswerPayload[] | NetworkLocationHeatmapQuadkeyAnswerPayload) => {
25
+ const [multipleFeatureSets, setMultipleFeatureSets] = useState<Feature<Geometry>[][]>([[]])
26
+ const [features, setFeatures] = useState<Feature<Geometry>[]>([])
27
+ const [error, setError] = useState<Error>()
28
+
29
+ useMemo(() => {
30
+ // Convert Multiple Payloads from Quadkey to GeoJson
31
+ if (Array.isArray(payloads)) {
32
+ if ((payloads)?.filter(exists).length > 0) {
33
+ const mappedFeatures = payloads?.map(payload => payload?.result.map(quadKeyToFeature))
34
+
35
+ setMultipleFeatureSets(mappedFeatures.map(features => features?.map(setDensity) ?? []))
36
+ } else {
37
+ setError(new Error('Cannot find payloads for provided hashes'))
38
+ }
39
+ }
40
+
41
+ // Convert Single Payload from Quadkey to GeoJson
42
+ if (payloads && (payloads as NetworkLocationHeatmapQuadkeyAnswerPayload).result) {
43
+ const singlePayload = payloads as NetworkLocationHeatmapQuadkeyAnswerPayload
44
+ const mappedFeatures = singlePayload.result.map(quadKeyToFeature)
45
+
46
+ setFeatures(mappedFeatures.map(setDensity))
47
+ }
48
+ }, [payloads])
49
+
50
+ return {
51
+ error, features, multipleFeatureSets,
52
+ }
53
+ }
54
+
55
+ export { useQuadKeyPayloadsToFeatures }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ export * from './AnimatedHeatMapSettings.ts'
2
+ export * from './colors/index.ts'
3
+ export * from './contexts/index.ts'
4
+ export * from './hooks/index.ts'
5
+ export * from './lib/index.ts'
6
+ export * from './settings/index.ts'
7
+ export * from './types/index.ts'
@@ -0,0 +1,8 @@
1
+ export enum MapStyle {
2
+ Dark = 'mapbox/dark-v10',
3
+ Light = 'mapbox/light-v10',
4
+ Outdoors = 'mapbox/outdoors-v11',
5
+ Satellite = 'mapbox/satellite-v9',
6
+ SatelliteStreets = 'mapbox/satellite-streets-v11',
7
+ Streets = 'mapbox/streets-v11',
8
+ }
@@ -0,0 +1 @@
1
+ export * from './MapStyle.ts'
@@ -0,0 +1,53 @@
1
+ import type { MapSetting } from './MapSetting.ts'
2
+
3
+ export const DefaultMapSettings: () => MapSetting = () => ({
4
+ debugLayer: {
5
+ devMode: true,
6
+ field: 'debugLayer',
7
+ hidden: true,
8
+ label: 'Debug Layer',
9
+ value: false,
10
+ },
11
+ debugLogging: {
12
+ devMode: true,
13
+ field: 'debugLogging',
14
+ hidden: true,
15
+ label: 'Debug Logging',
16
+ value: false,
17
+ },
18
+ dynamicMapResize: {
19
+ devMode: true,
20
+ field: 'dynamicMapResize',
21
+ hidden: true,
22
+ label: 'Auto Map Resize',
23
+ value: true,
24
+ },
25
+ enableControls: {
26
+ devMode: true,
27
+ field: 'enableControls',
28
+ hidden: true,
29
+ label: 'Map Controls',
30
+ value: false,
31
+ },
32
+ fitToPoints: {
33
+ devMode: true,
34
+ field: 'fitToPoints',
35
+ hidden: true,
36
+ label: 'Fit To Points',
37
+ value: false,
38
+ },
39
+ preferDark: {
40
+ devMode: false,
41
+ field: 'preferDark',
42
+ hidden: true,
43
+ label: 'Prefer dark',
44
+ value: false,
45
+ },
46
+ scrollToZoom: {
47
+ devMode: true,
48
+ field: 'scrollToZoom',
49
+ hidden: true,
50
+ label: 'Scroll To Zoom',
51
+ value: false,
52
+ },
53
+ })
@@ -0,0 +1,16 @@
1
+ export type MapSettingFields = 'debugLayer' | 'fitToPoints' | 'scrollToZoom' | 'enableControls' | 'debugLogging' | 'preferDark' | 'dynamicMapResize'
2
+
3
+ export type MapSetting = {
4
+ [field in MapSettingFields | string]: {
5
+ /** Setting only available when application is in developerMode */
6
+ devMode?: boolean
7
+ /** Machine-readable string to reference setting */
8
+ field: string
9
+ /** Hide the setting from the UI */
10
+ hidden?: boolean
11
+ /** Label in the UI */
12
+ label: string
13
+ /** Initial toggle value for a setting */
14
+ value: boolean
15
+ }
16
+ }
@@ -0,0 +1,2 @@
1
+ export * from './DefaultMapSettings.ts'
2
+ export * from './MapSetting.ts'
@@ -0,0 +1,32 @@
1
+ import type { Payload } from '@xyo-network/payload-model'
2
+ import { isPayloadOfSchemaType } from '@xyo-network/payload-model'
3
+ import type {
4
+ Feature, Point, Polygon,
5
+ } from 'geojson'
6
+
7
+ export interface NetworkLocationAnswerBase<T> {
8
+ result: T
9
+ }
10
+
11
+ export const NetworkLocationAnswerSchema = 'network.xyo.location.range.answer'
12
+ export type NetworkLocationAnswerSchema = 'network.xyo.location.range.answer'
13
+ export type NetworkLocationAnswerPayload = Payload<NetworkLocationAnswerBase<{ features: Feature<Point>[] }>, NetworkLocationAnswerSchema>
14
+ export const isNetworkLocationAnswer = isPayloadOfSchemaType<NetworkLocationAnswerPayload>(NetworkLocationAnswerSchema)
15
+
16
+ export const NetworkLocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'
17
+ export type NetworkLocationHeatmapAnswerSchema = 'network.xyo.location.heatmap.answer'
18
+ export type NetworkLocationHeatmapAnswerPayload = Payload<
19
+ NetworkLocationAnswerBase<{ features: Feature<Polygon>[] }>,
20
+ NetworkLocationHeatmapAnswerSchema
21
+ >
22
+ export const isNetworkLocationHeatmapAnswer = isPayloadOfSchemaType<NetworkLocationHeatmapAnswerPayload>(NetworkLocationHeatmapAnswerSchema)
23
+
24
+ export const NetworkLocationHeatmapQuadkeyAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'
25
+ export type NetworkLocationHeatmapQuadkeyAnswerSchema = 'network.xyo.location.heatmap.quadkey.answer'
26
+ export type NetworkLocationHeatmapQuadkeyAnswerPayload = Payload<
27
+ NetworkLocationAnswerBase<{ density: number; quadkey: string }[]>,
28
+ NetworkLocationHeatmapQuadkeyAnswerSchema
29
+ >
30
+ export const isNetworkLocationHeatmapQuadkeyAnswer = isPayloadOfSchemaType<NetworkLocationHeatmapAnswerPayload>(
31
+ NetworkLocationHeatmapQuadkeyAnswerSchema,
32
+ )
@@ -0,0 +1 @@
1
+ export * from './NetworkLocationAnswerBase.ts'
package/typedoc.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://typedoc.org/schema.json",
3
+ "entryPoints": ["src/index.ts"],
4
+ "tsconfig": "./tsconfig.typedoc.json"
5
+ }
package/xy.config.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { XyTsupConfig } from '@xylabs/ts-scripts-yarn3'
2
+ const config: XyTsupConfig = {
3
+ compile: {
4
+ browser: { src: true },
5
+ node: {},
6
+ neutral: {},
7
+ },
8
+ }
9
+
10
+ export default config