@orioro/react-maplibre-util 0.5.0 → 0.5.1
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/CHANGELOG.md +6 -0
- package/dist/DynamicImages/svgImages/index.d.ts +13 -5
- package/dist/index.mjs +19 -6
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
@@ -24,9 +24,17 @@ export declare function svgToMaplibreImage(svgString: string, pixelRatio?: numbe
|
|
24
24
|
Partial<StyleImageMetadata>
|
25
25
|
]>;
|
26
26
|
export declare function svgIconId(iconId: string, options?: IconPathToSvgOptions): string;
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
type SvgIconGeneratorReturn<T extends Record<string, string>> = {
|
28
|
+
(imageId: string): Promise<[
|
29
|
+
{
|
30
|
+
width: number;
|
31
|
+
height: number;
|
32
|
+
data: Uint8ClampedArray;
|
33
|
+
},
|
34
|
+
Partial<StyleImageMetadata>
|
35
|
+
] | null>;
|
36
|
+
} & {
|
37
|
+
[K in keyof T]: (options?: IconPathToSvgOptions) => string;
|
38
|
+
};
|
39
|
+
export declare function svgIconGenerator<T extends Record<string, string>>(iconPathsById: T): SvgIconGeneratorReturn<T>;
|
32
40
|
export {};
|
package/dist/index.mjs
CHANGED
@@ -920,7 +920,7 @@ function DynamicImages(_a) {
|
|
920
920
|
if (!map.hasImage(imageId)) {
|
921
921
|
if (Array.isArray(result)) {
|
922
922
|
map.addImage(imageId, result[0], result[1]);
|
923
|
-
} else {
|
923
|
+
} else if (result) {
|
924
924
|
map.addImage(imageId, result);
|
925
925
|
}
|
926
926
|
}
|
@@ -1027,15 +1027,28 @@ function svgIconGenerator(iconPathsById) {
|
|
1027
1027
|
var expr = strExpr({
|
1028
1028
|
expressions: fns
|
1029
1029
|
});
|
1030
|
-
|
1030
|
+
function onGenerateSvgImage(imageId) {
|
1031
1031
|
return __awaiter(this, void 0, void 0, function () {
|
1032
|
-
var svg;
|
1032
|
+
var imageExpr, svg;
|
1033
1033
|
return __generator(this, function (_a) {
|
1034
|
-
|
1035
|
-
|
1034
|
+
try {
|
1035
|
+
imageExpr = expr.parse(imageId);
|
1036
|
+
svg = expr.apply(imageExpr, undefined);
|
1037
|
+
return [2 /*return*/, svgToMaplibreImage(svg)];
|
1038
|
+
} catch (err) {
|
1039
|
+
// console.log(`will skip: ${imageId}`)
|
1040
|
+
return [2 /*return*/, null];
|
1041
|
+
}
|
1042
|
+
return [2 /*return*/];
|
1036
1043
|
});
|
1037
1044
|
});
|
1038
|
-
}
|
1045
|
+
}
|
1046
|
+
Object.assign(onGenerateSvgImage, Object.fromEntries(Object.keys(iconPathsById).map(function (iconId) {
|
1047
|
+
return [iconId, function (options) {
|
1048
|
+
return svgIconId(iconId, options);
|
1049
|
+
}];
|
1050
|
+
})));
|
1051
|
+
return onGenerateSvgImage;
|
1039
1052
|
}
|
1040
1053
|
|
1041
1054
|
var DEFAULT_MIN_K = 3;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orioro/react-maplibre-util",
|
3
|
-
"version": "0.5.
|
3
|
+
"version": "0.5.1",
|
4
4
|
"packageManager": "yarn@4.0.2",
|
5
5
|
"type": "module",
|
6
6
|
"main": "dist/index.mjs",
|
@@ -17,6 +17,7 @@
|
|
17
17
|
},
|
18
18
|
"license": "ISC",
|
19
19
|
"scripts": {
|
20
|
+
"prepublish": "yarn build",
|
20
21
|
"build": "rm -rf dist && rollup --config ./rollup.config.mjs",
|
21
22
|
"dev": "storybook dev -p 6006",
|
22
23
|
"build-storybook": "storybook build"
|