@maplibre/maplibre-react-native 10.0.0-beta.3 → 10.0.0-beta.7
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/android/build.gradle +98 -51
- package/android/gradle.properties +7 -0
- package/android/src/main/AndroidManifest.xml +4 -2
- package/android/src/main/AndroidManifestNew.xml +5 -0
- package/android/src/main/java/org/maplibre/reactnative/MLRNPackage.java +0 -5
- package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSource.java +0 -66
- package/android/src/main/java/org/maplibre/reactnative/components/styles/sources/MLRNShapeSourceManager.java +0 -28
- package/ios/MLRN/MLRNBackgroundLayer.h +0 -1
- package/ios/MLRN/MLRNFillExtrusionLayer.h +0 -1
- package/ios/MLRN/MLRNFillLayer.h +0 -1
- package/ios/MLRN/MLRNFillLayer.m +1 -0
- package/ios/MLRN/MLRNLineLayer.h +0 -1
- package/ios/MLRN/MLRNRasterLayer.h +0 -1
- package/ios/MLRN/MLRNShapeSource.h +0 -11
- package/ios/MLRN/MLRNShapeSource.m +0 -38
- package/ios/MLRN/MLRNShapeSourceManager.m +0 -68
- package/ios/MLRN/MLRNSymbolLayer.h +1 -7
- package/ios/MLRN/MLRNSymbolLayer.m +1 -89
- package/ios/MLRN/MLRNSymbolLayerManager.m +0 -1
- package/lib/commonjs/MapLibreRN.js +1 -13
- package/lib/commonjs/MapLibreRN.js.map +1 -1
- package/lib/commonjs/components/Images.js +1 -5
- package/lib/commonjs/components/Images.js.map +1 -1
- package/lib/commonjs/components/MapView.js +0 -7
- package/lib/commonjs/components/MapView.js.map +1 -1
- package/lib/commonjs/components/ShapeSource.js +6 -38
- package/lib/commonjs/components/ShapeSource.js.map +1 -1
- package/lib/commonjs/components/SymbolLayer.js +2 -17
- package/lib/commonjs/components/SymbolLayer.js.map +1 -1
- package/lib/commonjs/components/VectorSource.js +1 -11
- package/lib/commonjs/components/VectorSource.js.map +1 -1
- package/lib/module/MapLibreRN.js +0 -4
- package/lib/module/MapLibreRN.js.map +1 -1
- package/lib/module/components/Images.js +1 -5
- package/lib/module/components/Images.js.map +1 -1
- package/lib/module/components/MapView.js +0 -7
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/ShapeSource.js +5 -37
- package/lib/module/components/ShapeSource.js.map +1 -1
- package/lib/module/components/SymbolLayer.js +3 -18
- package/lib/module/components/SymbolLayer.js.map +1 -1
- package/lib/module/components/VectorSource.js +1 -11
- package/lib/module/components/VectorSource.js.map +1 -1
- package/lib/typescript/commonjs/src/MapLibreRN.d.ts +0 -4
- package/lib/typescript/commonjs/src/MapLibreRN.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Camera.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/Images.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/MapView.d.ts +0 -1
- package/lib/typescript/commonjs/src/components/MapView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +0 -1
- package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts +0 -6
- package/lib/typescript/commonjs/src/components/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/VectorSource.d.ts.map +1 -1
- package/lib/typescript/module/src/MapLibreRN.d.ts +0 -4
- package/lib/typescript/module/src/MapLibreRN.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Camera.d.ts +1 -1
- package/lib/typescript/module/src/components/Images.d.ts.map +1 -1
- package/lib/typescript/module/src/components/MapView.d.ts +0 -1
- package/lib/typescript/module/src/components/MapView.d.ts.map +1 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts +0 -1
- package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
- package/lib/typescript/module/src/components/SymbolLayer.d.ts +0 -6
- package/lib/typescript/module/src/components/SymbolLayer.d.ts.map +1 -1
- package/lib/typescript/module/src/components/VectorSource.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/MapLibreRN.ts +0 -6
- package/src/components/Camera.tsx +1 -1
- package/src/components/Images.tsx +1 -10
- package/src/components/MapView.tsx +0 -11
- package/src/components/ShapeSource.tsx +5 -73
- package/src/components/SymbolLayer.tsx +5 -33
- package/src/components/VectorSource.tsx +4 -20
- package/android/src/main/res/values/strings.xml +0 -3
- package/lib/commonjs/components/Style.js +0 -266
- package/lib/commonjs/components/Style.js.map +0 -1
- package/lib/commonjs/utils/deprecation.js +0 -31
- package/lib/commonjs/utils/deprecation.js.map +0 -1
- package/lib/module/components/Style.js +0 -261
- package/lib/module/components/Style.js.map +0 -1
- package/lib/module/utils/deprecation.js +0 -27
- package/lib/module/utils/deprecation.js.map +0 -1
- package/lib/typescript/commonjs/src/components/Style.d.ts +0 -81
- package/lib/typescript/commonjs/src/components/Style.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/utils/deprecation.d.ts +0 -6
- package/lib/typescript/commonjs/src/utils/deprecation.d.ts.map +0 -1
- package/lib/typescript/module/src/components/Style.d.ts +0 -81
- package/lib/typescript/module/src/components/Style.d.ts.map +0 -1
- package/lib/typescript/module/src/utils/deprecation.d.ts +0 -6
- package/lib/typescript/module/src/utils/deprecation.d.ts.map +0 -1
- package/src/components/Style.tsx +0 -371
- package/src/utils/deprecation.ts +0 -31
package/src/components/Style.tsx
DELETED
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useMemo,
|
|
3
|
-
useState,
|
|
4
|
-
useEffect,
|
|
5
|
-
type ReactElement,
|
|
6
|
-
type ComponentType,
|
|
7
|
-
} from "react";
|
|
8
|
-
|
|
9
|
-
import BackgroundLayer, { type BackgroundLayerProps } from "./BackgroundLayer";
|
|
10
|
-
import CircleLayer, { type CircleLayerProps } from "./CircleLayer";
|
|
11
|
-
import FillExtrusionLayer, {
|
|
12
|
-
type FillExtrusionLayerProps,
|
|
13
|
-
} from "./FillExtrusionLayer";
|
|
14
|
-
import FillLayer, { type FillLayerProps } from "./FillLayer";
|
|
15
|
-
import HeatmapLayer, { type HeatmapLayerProps } from "./HeatmapLayer";
|
|
16
|
-
import ImageSource from "./ImageSource";
|
|
17
|
-
import LineLayer, { type LineLayerProps } from "./LineLayer";
|
|
18
|
-
import RasterLayer, { type RasterLayerProps } from "./RasterLayer";
|
|
19
|
-
import RasterSource from "./RasterSource";
|
|
20
|
-
import ShapeSource from "./ShapeSource";
|
|
21
|
-
import SymbolLayer, { type SymbolLayerProps } from "./SymbolLayer";
|
|
22
|
-
import VectorSource from "./VectorSource";
|
|
23
|
-
import {
|
|
24
|
-
type ExpressionField,
|
|
25
|
-
type FilterExpression,
|
|
26
|
-
} from "../utils/MapLibreRNStyles";
|
|
27
|
-
|
|
28
|
-
function toCamelCase(s: string): string {
|
|
29
|
-
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
30
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Patches the Mapbox Style Specification keys into the style props attributes:
|
|
35
|
-
// icon-allow-overlap -> iconAllowOverlap
|
|
36
|
-
function toCamelCaseKeys(
|
|
37
|
-
oldObj: Record<string, unknown>,
|
|
38
|
-
): Record<string, unknown> {
|
|
39
|
-
if (!oldObj) {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
const newObj: Record<string, unknown> = {};
|
|
43
|
-
Object.keys(oldObj).forEach((key) => {
|
|
44
|
-
const value = oldObj[key];
|
|
45
|
-
if (key.includes("-")) {
|
|
46
|
-
newObj[toCamelCase(key)] = value;
|
|
47
|
-
} else {
|
|
48
|
-
newObj[key] = value;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
return newObj;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type LayerProps =
|
|
55
|
-
| CircleLayerProps
|
|
56
|
-
| SymbolLayerProps
|
|
57
|
-
| RasterLayerProps
|
|
58
|
-
| LineLayerProps
|
|
59
|
-
| FillLayerProps
|
|
60
|
-
| FillExtrusionLayerProps
|
|
61
|
-
| BackgroundLayerProps
|
|
62
|
-
| HeatmapLayerProps;
|
|
63
|
-
|
|
64
|
-
function getLayerComponentType(
|
|
65
|
-
layer: MapLibreJSONLayer,
|
|
66
|
-
): ComponentType<LayerProps> | null {
|
|
67
|
-
const { type } = layer;
|
|
68
|
-
|
|
69
|
-
switch (type) {
|
|
70
|
-
case "circle":
|
|
71
|
-
return CircleLayer;
|
|
72
|
-
case "symbol":
|
|
73
|
-
return SymbolLayer;
|
|
74
|
-
case "raster":
|
|
75
|
-
return RasterLayer;
|
|
76
|
-
case "line":
|
|
77
|
-
return LineLayer;
|
|
78
|
-
case "fill":
|
|
79
|
-
return FillLayer;
|
|
80
|
-
case "fill-extrusion":
|
|
81
|
-
return FillExtrusionLayer;
|
|
82
|
-
case "background":
|
|
83
|
-
return BackgroundLayer;
|
|
84
|
-
case "heatmap":
|
|
85
|
-
return HeatmapLayer;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
console.warn(`Mapbox layer type '${type}' is not supported/`);
|
|
89
|
-
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface MapLibreJSONLayer {
|
|
94
|
-
type: string;
|
|
95
|
-
paint: { [k: string]: unknown };
|
|
96
|
-
layout: { [k: string]: unknown };
|
|
97
|
-
source?: string;
|
|
98
|
-
"source-layer"?: string;
|
|
99
|
-
minzoom?: number;
|
|
100
|
-
maxzoom?: number;
|
|
101
|
-
filter?: FilterExpression;
|
|
102
|
-
id: string;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function asLayerComponent(
|
|
106
|
-
layer: MapLibreJSONLayer,
|
|
107
|
-
): ReactElement<LayerProps> | null {
|
|
108
|
-
const LayerComponent = getLayerComponentType(layer);
|
|
109
|
-
|
|
110
|
-
if (!LayerComponent) {
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const style = {
|
|
115
|
-
...toCamelCaseKeys(layer.paint),
|
|
116
|
-
...toCamelCaseKeys(layer.layout),
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const layerProps: Partial<LayerProps> = {};
|
|
120
|
-
|
|
121
|
-
if (layer.source) {
|
|
122
|
-
layerProps.sourceID = layer.source;
|
|
123
|
-
}
|
|
124
|
-
if (layer["source-layer"]) {
|
|
125
|
-
layerProps.sourceLayerID = layer["source-layer"];
|
|
126
|
-
}
|
|
127
|
-
if (layer.minzoom) {
|
|
128
|
-
layerProps.minZoomLevel = layer.minzoom;
|
|
129
|
-
}
|
|
130
|
-
if (layer.maxzoom) {
|
|
131
|
-
layerProps.maxZoomLevel = layer.maxzoom;
|
|
132
|
-
}
|
|
133
|
-
if (layer.filter) {
|
|
134
|
-
layerProps.filter = layer.filter;
|
|
135
|
-
}
|
|
136
|
-
if (Object.keys(style).length) {
|
|
137
|
-
layerProps.style = style;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return <LayerComponent key={layer.id} id={layer.id} {...layerProps} />;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
interface MapLibreJSONSource {
|
|
144
|
-
type: string;
|
|
145
|
-
url?: string;
|
|
146
|
-
tiles?: string[];
|
|
147
|
-
minzoom?: number;
|
|
148
|
-
maxzoom?: number;
|
|
149
|
-
attribution?: string;
|
|
150
|
-
scheme?: "xyz" | "tms";
|
|
151
|
-
bounds?: number[];
|
|
152
|
-
buffer?: number;
|
|
153
|
-
tileSize?: number;
|
|
154
|
-
coordinates?: [
|
|
155
|
-
[number, number],
|
|
156
|
-
[number, number],
|
|
157
|
-
[number, number],
|
|
158
|
-
[number, number],
|
|
159
|
-
];
|
|
160
|
-
cluster?: boolean;
|
|
161
|
-
clusterMaxZoom?: number;
|
|
162
|
-
clusterMinPoints?: number;
|
|
163
|
-
clusterRadius?: number;
|
|
164
|
-
clusterProperties?: { [propertyName: string]: ExpressionField };
|
|
165
|
-
data?: string | object;
|
|
166
|
-
filter?: FilterExpression;
|
|
167
|
-
generateId?: boolean;
|
|
168
|
-
lineMetrics?: boolean;
|
|
169
|
-
tolerance?: number;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
type SourceProps = {
|
|
173
|
-
url?: string;
|
|
174
|
-
tileUrlTemplates?: string[];
|
|
175
|
-
minZoomLevel?: number;
|
|
176
|
-
maxZoomLevel?: number;
|
|
177
|
-
attribution?: string;
|
|
178
|
-
tms?: boolean;
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
function getTileSourceProps(source: MapLibreJSONSource): SourceProps {
|
|
182
|
-
const sourceProps: Partial<SourceProps> = {};
|
|
183
|
-
if (source.url) {
|
|
184
|
-
sourceProps.url = source.url;
|
|
185
|
-
}
|
|
186
|
-
if (source.tiles) {
|
|
187
|
-
sourceProps.tileUrlTemplates = source.tiles;
|
|
188
|
-
}
|
|
189
|
-
if (source.minzoom !== undefined) {
|
|
190
|
-
sourceProps.minZoomLevel = source.minzoom;
|
|
191
|
-
}
|
|
192
|
-
if (source.maxzoom !== undefined) {
|
|
193
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
194
|
-
}
|
|
195
|
-
if (source.attribution) {
|
|
196
|
-
sourceProps.attribution = source.attribution;
|
|
197
|
-
}
|
|
198
|
-
if (source.scheme && source.scheme === "tms") {
|
|
199
|
-
sourceProps.tms = true;
|
|
200
|
-
}
|
|
201
|
-
return sourceProps;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function getVectorSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
205
|
-
const sourceProps = { ...getTileSourceProps(source) };
|
|
206
|
-
return <VectorSource key={id} id={id} {...sourceProps} />;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function getRasterSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
210
|
-
const sourceProps: SourceProps & { tileSize?: number } = {
|
|
211
|
-
...getTileSourceProps(source),
|
|
212
|
-
};
|
|
213
|
-
if (source.tileSize) {
|
|
214
|
-
sourceProps.tileSize = source.tileSize;
|
|
215
|
-
}
|
|
216
|
-
return <RasterSource key={id} id={id} {...sourceProps} />;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function getImageSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
220
|
-
const sourceProps = {
|
|
221
|
-
url: source.url,
|
|
222
|
-
coordinates: source.coordinates,
|
|
223
|
-
};
|
|
224
|
-
return <ImageSource key={id} id={id} {...sourceProps} />;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
type ShapeSourceShape = (typeof ShapeSource.prototype.props)["shape"];
|
|
228
|
-
|
|
229
|
-
function getShapeSource(id: string, source: MapLibreJSONSource): ReactElement {
|
|
230
|
-
const sourceProps: SourceProps & {
|
|
231
|
-
shape?: ShapeSourceShape;
|
|
232
|
-
cluster?: boolean;
|
|
233
|
-
clusterRadius?: number;
|
|
234
|
-
clusterMaxZoomLevel?: number;
|
|
235
|
-
clusterProperties?: { [propertyName: string]: ExpressionField };
|
|
236
|
-
buffer?: number;
|
|
237
|
-
tolerance?: number;
|
|
238
|
-
lineMetrics?: boolean;
|
|
239
|
-
} = {};
|
|
240
|
-
if (source.data && typeof source.data === "string") {
|
|
241
|
-
sourceProps.url = source.data;
|
|
242
|
-
} else if (source.data && typeof source.data === "object") {
|
|
243
|
-
sourceProps.shape = source.data as ShapeSourceShape;
|
|
244
|
-
}
|
|
245
|
-
if (source.cluster !== undefined) {
|
|
246
|
-
sourceProps.cluster = source.cluster;
|
|
247
|
-
}
|
|
248
|
-
if (source.clusterRadius !== undefined) {
|
|
249
|
-
sourceProps.clusterRadius = source.clusterRadius;
|
|
250
|
-
}
|
|
251
|
-
if (source.maxzoom !== undefined) {
|
|
252
|
-
sourceProps.maxZoomLevel = source.maxzoom;
|
|
253
|
-
}
|
|
254
|
-
if (source.clusterMaxZoom !== undefined) {
|
|
255
|
-
sourceProps.clusterMaxZoomLevel = source.clusterMaxZoom;
|
|
256
|
-
}
|
|
257
|
-
if (source.clusterProperties !== undefined) {
|
|
258
|
-
sourceProps.clusterProperties = source.clusterProperties;
|
|
259
|
-
}
|
|
260
|
-
if (source.buffer !== undefined) {
|
|
261
|
-
sourceProps.buffer = source.buffer;
|
|
262
|
-
}
|
|
263
|
-
if (source.tolerance !== undefined) {
|
|
264
|
-
sourceProps.tolerance = source.tolerance;
|
|
265
|
-
}
|
|
266
|
-
if (source.lineMetrics !== undefined) {
|
|
267
|
-
sourceProps.lineMetrics = source.lineMetrics;
|
|
268
|
-
}
|
|
269
|
-
return <ShapeSource key={id} id={id} {...sourceProps} />;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function asSourceComponent(
|
|
273
|
-
id: string,
|
|
274
|
-
source: MapLibreJSONSource,
|
|
275
|
-
): ReactElement | null {
|
|
276
|
-
switch (source.type) {
|
|
277
|
-
case "vector":
|
|
278
|
-
return getVectorSource(id, source);
|
|
279
|
-
case "raster":
|
|
280
|
-
return getRasterSource(id, source);
|
|
281
|
-
case "image":
|
|
282
|
-
return getImageSource(id, source);
|
|
283
|
-
case "geojson":
|
|
284
|
-
return getShapeSource(id, source);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
console.warn(`MapLibre source type '${source.type}' is not supported`);
|
|
288
|
-
|
|
289
|
-
return null;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
interface MapLibreJSON {
|
|
293
|
-
layers?: MapLibreJSONLayer[];
|
|
294
|
-
sources?: { [key: string]: MapLibreJSONSource };
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
interface StyleProps {
|
|
298
|
-
/**
|
|
299
|
-
* A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON.
|
|
300
|
-
*/
|
|
301
|
-
json?: MapLibreJSON | URL;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
|
|
306
|
-
* Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
|
|
307
|
-
* Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.
|
|
308
|
-
*
|
|
309
|
-
* TODO: Maintainer forking this project does not understand the above comment regarding what is supported.
|
|
310
|
-
*/
|
|
311
|
-
const Style = (props: StyleProps): ReactElement => {
|
|
312
|
-
const [fetchedJson, setFetchedJson] = useState({});
|
|
313
|
-
const json: MapLibreJSON =
|
|
314
|
-
typeof props.json === "object" ? props.json : fetchedJson;
|
|
315
|
-
|
|
316
|
-
// Fetch style when props.json is a URL
|
|
317
|
-
useEffect(() => {
|
|
318
|
-
const abortController = new AbortController();
|
|
319
|
-
const fetchStyleJson = async (url: string): Promise<void> => {
|
|
320
|
-
try {
|
|
321
|
-
const response = await fetch(url, {
|
|
322
|
-
signal: abortController.signal,
|
|
323
|
-
});
|
|
324
|
-
const responseJson = await response.json();
|
|
325
|
-
setFetchedJson(responseJson);
|
|
326
|
-
} catch (error: unknown) {
|
|
327
|
-
const e = error as { name?: string };
|
|
328
|
-
if (e.name === "AbortError") {
|
|
329
|
-
return;
|
|
330
|
-
}
|
|
331
|
-
throw e;
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
if (typeof props.json === "string") {
|
|
335
|
-
fetchStyleJson(props.json);
|
|
336
|
-
}
|
|
337
|
-
return function cleanup(): void {
|
|
338
|
-
abortController.abort();
|
|
339
|
-
};
|
|
340
|
-
}, [props.json]);
|
|
341
|
-
|
|
342
|
-
// Extract layer components from json
|
|
343
|
-
const layerComponents = useMemo(() => {
|
|
344
|
-
if (!json.layers) {
|
|
345
|
-
return [];
|
|
346
|
-
}
|
|
347
|
-
return json.layers
|
|
348
|
-
.map(asLayerComponent)
|
|
349
|
-
.filter((x: ReactElement | null) => !!x);
|
|
350
|
-
}, [json.layers]);
|
|
351
|
-
|
|
352
|
-
// Extract source components from json
|
|
353
|
-
const sourceComponents = useMemo(() => {
|
|
354
|
-
const { sources } = json;
|
|
355
|
-
if (!sources || !Object.keys(sources)) {
|
|
356
|
-
return [];
|
|
357
|
-
}
|
|
358
|
-
return Object.entries(sources)
|
|
359
|
-
.map(([id, source]) => asSourceComponent(id, source))
|
|
360
|
-
.filter((x) => !!x);
|
|
361
|
-
}, [json]);
|
|
362
|
-
|
|
363
|
-
return (
|
|
364
|
-
<>
|
|
365
|
-
{sourceComponents}
|
|
366
|
-
{layerComponents}
|
|
367
|
-
</>
|
|
368
|
-
);
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
export default Style;
|
package/src/utils/deprecation.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copy properties from origObject to newObject, which not exists in newObject,
|
|
3
|
-
* calls onDeprecatedCalled callback in case a copied property is invoked.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export function copyPropertiesAsDeprecated<
|
|
7
|
-
DeprecatedType extends object,
|
|
8
|
-
WithDeprecatedType extends Record<string, unknown>,
|
|
9
|
-
>(
|
|
10
|
-
origObject: DeprecatedType,
|
|
11
|
-
newObject: WithDeprecatedType,
|
|
12
|
-
onDeprecatedCalled: (key: string) => void,
|
|
13
|
-
accessors: Record<string, (value: any) => unknown> = {},
|
|
14
|
-
): WithDeprecatedType {
|
|
15
|
-
const result = { ...newObject };
|
|
16
|
-
|
|
17
|
-
for (const [key, value] of Object.entries(origObject)) {
|
|
18
|
-
if (!(key in newObject)) {
|
|
19
|
-
Object.defineProperty(result, key, {
|
|
20
|
-
get() {
|
|
21
|
-
onDeprecatedCalled(key);
|
|
22
|
-
return accessors[key] ? accessors[key](value) : value;
|
|
23
|
-
},
|
|
24
|
-
enumerable: true, // Ensure the property is enumerable
|
|
25
|
-
configurable: true, // Ensure the property can be reconfigured
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return result;
|
|
31
|
-
}
|