mahal_map 1.0.3 → 1.0.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 (86) hide show
  1. package/README.md +2 -0
  2. package/dist/index.d.mts +101 -0
  3. package/dist/index.d.ts +100 -13
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.mjs +2 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/mahal_map.sdk.js +1 -0
  9. package/package.json +20 -10
  10. package/.vscode/settings.json +0 -3
  11. package/dist/app/config/constants.d.ts +0 -9
  12. package/dist/app/config/constants.d.ts.map +0 -1
  13. package/dist/app/config/geojson-polyline.d.ts +0 -3
  14. package/dist/app/config/geojson-polyline.d.ts.map +0 -1
  15. package/dist/app/config/geometry-polyline.d.ts +0 -3
  16. package/dist/app/config/geometry-polyline.d.ts.map +0 -1
  17. package/dist/app/config/index.d.ts +0 -4
  18. package/dist/app/config/index.d.ts.map +0 -1
  19. package/dist/app/lib/axios/api/axios.d.ts +0 -2
  20. package/dist/app/lib/axios/api/axios.d.ts.map +0 -1
  21. package/dist/app/lib/axios/api/index.d.ts +0 -2
  22. package/dist/app/lib/axios/api/index.d.ts.map +0 -1
  23. package/dist/app/lib/axios/index.d.ts +0 -2
  24. package/dist/app/lib/axios/index.d.ts.map +0 -1
  25. package/dist/app/lib/checking-coordinates/index.d.ts +0 -2
  26. package/dist/app/lib/checking-coordinates/index.d.ts.map +0 -1
  27. package/dist/app/lib/checking-coordinates/utils.d.ts +0 -5
  28. package/dist/app/lib/checking-coordinates/utils.d.ts.map +0 -1
  29. package/dist/app/lib/index.d.ts +0 -4
  30. package/dist/app/lib/index.d.ts.map +0 -1
  31. package/dist/app/lib/saveKey/index.d.ts +0 -2
  32. package/dist/app/lib/saveKey/index.d.ts.map +0 -1
  33. package/dist/app/lib/saveKey/utils.d.ts +0 -5
  34. package/dist/app/lib/saveKey/utils.d.ts.map +0 -1
  35. package/dist/app/types/additional-param/index.d.ts +0 -6
  36. package/dist/app/types/additional-param/index.d.ts.map +0 -1
  37. package/dist/app/types/index.d.ts +0 -5
  38. package/dist/app/types/index.d.ts.map +0 -1
  39. package/dist/app/types/map/index.d.ts +0 -10
  40. package/dist/app/types/map/index.d.ts.map +0 -1
  41. package/dist/app/types/router-param/index.d.ts +0 -33
  42. package/dist/app/types/router-param/index.d.ts.map +0 -1
  43. package/dist/app/types/search-param/index.d.ts +0 -13
  44. package/dist/app/types/search-param/index.d.ts.map +0 -1
  45. package/dist/index.d.ts.map +0 -1
  46. package/dist/lib/map/utils.d.ts +0 -5
  47. package/dist/lib/map/utils.d.ts.map +0 -1
  48. package/dist/lib/routing/api.d.ts +0 -3
  49. package/dist/lib/routing/api.d.ts.map +0 -1
  50. package/dist/lib/routing/utils.d.ts +0 -4
  51. package/dist/lib/routing/utils.d.ts.map +0 -1
  52. package/dist/lib/search/api.d.ts +0 -3
  53. package/dist/lib/search/api.d.ts.map +0 -1
  54. package/dist/lib/search/utils.d.ts +0 -4
  55. package/dist/lib/search/utils.d.ts.map +0 -1
  56. package/dist/mahal_map.esm.js +0 -2
  57. package/dist/mahal_map.esm.js.map +0 -1
  58. package/dist/mahal_map.umd.js +0 -2
  59. package/dist/mahal_map.umd.js.map +0 -1
  60. package/index.html +0 -465
  61. package/rollup.config.js +0 -38
  62. package/src/app/config/constants.ts +0 -15
  63. package/src/app/config/geojson-polyline.ts +0 -47
  64. package/src/app/config/geometry-polyline.ts +0 -58
  65. package/src/app/config/index.ts +0 -3
  66. package/src/app/lib/axios/api/axios.ts +0 -17
  67. package/src/app/lib/axios/api/index.ts +0 -1
  68. package/src/app/lib/axios/index.ts +0 -1
  69. package/src/app/lib/checking-coordinates/index.ts +0 -1
  70. package/src/app/lib/checking-coordinates/utils.ts +0 -20
  71. package/src/app/lib/index.ts +0 -3
  72. package/src/app/lib/saveKey/index.ts +0 -1
  73. package/src/app/lib/saveKey/utils.ts +0 -18
  74. package/src/app/types/additional-param/index.ts +0 -6
  75. package/src/app/types/index.ts +0 -4
  76. package/src/app/types/map/index.ts +0 -10
  77. package/src/app/types/router-param/index.ts +0 -33
  78. package/src/app/types/search-param/index.ts +0 -13
  79. package/src/index.d.ts +0 -21
  80. package/src/index.ts +0 -26
  81. package/src/lib/map/utils.ts +0 -35
  82. package/src/lib/routing/api.ts +0 -17
  83. package/src/lib/routing/utils.ts +0 -37
  84. package/src/lib/search/api.ts +0 -13
  85. package/src/lib/search/utils.ts +0 -40
  86. package/tsconfig.json +0 -23
@@ -1,18 +0,0 @@
1
- import { api } from "@app/lib";
2
-
3
- let apiKey: string = "";
4
-
5
- function saveKey(param: string) {
6
- if (param === "") return;
7
- apiKey = param;
8
- api.defaults.headers.common["Authorization"] = `Bearer ${param}`;
9
- }
10
-
11
- function clearKey() {
12
- apiKey = "";
13
- api.defaults.headers.common["Authorization"] = "";
14
- }
15
-
16
- const getApiKey = () => apiKey;
17
-
18
- export { saveKey, clearKey, getApiKey };
@@ -1,6 +0,0 @@
1
- interface IAdditionalParamType {
2
- lat: string;
3
- lng: string;
4
- }
5
-
6
- export type { IAdditionalParamType };
@@ -1,4 +0,0 @@
1
- export * from "./search-param";
2
- export * from "./additional-param";
3
- export * from "./router-param";
4
- export * from "./map";
@@ -1,10 +0,0 @@
1
- interface IMahalMapOptions {
2
- container?: string;
3
- style?: string;
4
- theme?: "dark" | "light";
5
- center?: [number, number];
6
- zoom?: number;
7
- autoAddVectorSource?: boolean;
8
- }
9
-
10
- export type { IMahalMapOptions };
@@ -1,33 +0,0 @@
1
- interface IRoute {
2
- id: number;
3
- type: string;
4
- name: string;
5
- icon: string;
6
- success: boolean;
7
- coords: string;
8
- route?: {
9
- code: string;
10
- routes: {
11
- geometry: string | number[][];
12
- legs: {
13
- steps: [];
14
- summary: string;
15
- weight: number;
16
- duration: number;
17
- distance: number;
18
- }[];
19
- weight_name: string;
20
- distance: number;
21
- duration: number;
22
- weight: number;
23
- }[];
24
- waypoints: {
25
- hint: string;
26
- distance: any;
27
- name: string;
28
- location: number[];
29
- }[];
30
- };
31
- }
32
-
33
- export type { IRoute };
@@ -1,13 +0,0 @@
1
- interface ISearchParam {
2
- id?: string;
3
- text?: string;
4
- lat?: string;
5
- lng?: string;
6
- radius?: string;
7
- user_lat?: string;
8
- user_lng?: string;
9
- limit?: string;
10
- page?: string;
11
- }
12
-
13
- export type { ISearchParam };
package/src/index.d.ts DELETED
@@ -1,21 +0,0 @@
1
- export * from "./app/types/map";
2
- export * from "./app/types/search-param";
3
- export * from "./app/types/additional-param";
4
- export * from "./app/types/router-param";
5
-
6
- import * as Map from "../src/lib/map/utils";
7
- import * as keyUtils from "./app/lib/saveKey";
8
- import * as searchUtils from "./lib/search/utils";
9
- import * as routerUtils from "./lib/routing/utils";
10
-
11
- export { Map, keyUtils, searchUtils, routerUtils };
12
-
13
- declare const MahalMap: {
14
- Map: typeof Map;
15
- keyUtils: typeof keyUtils;
16
- searchUtils: typeof searchUtils;
17
- routerUtils: typeof routerUtils;
18
- loadKeyFromScriptUrl: () => string;
19
- };
20
-
21
- export default MahalMap;
package/src/index.ts DELETED
@@ -1,26 +0,0 @@
1
- import * as Map from "@lib/map/utils";
2
- import * as keyUtils from "@app/lib/saveKey";
3
- import * as searchUtils from "@lib/search/utils";
4
- import * as routerUtils from "@lib/routing/utils";
5
-
6
- export { Map, keyUtils, searchUtils, routerUtils };
7
-
8
- const MahalMap = {
9
- Map,
10
- keyUtils,
11
- searchUtils,
12
- routerUtils,
13
- loadKeyFromScriptUrl: () => {
14
- const scripts = document.getElementsByTagName("script");
15
- for (const script of scripts) {
16
- if (script.src.includes("mahal_map.umd.js")) {
17
- const url = new URL(script.src);
18
- const apikey = url.searchParams.get("apikey");
19
- if (apikey) return apikey;
20
- }
21
- }
22
- return "";
23
- },
24
- };
25
-
26
- export default MahalMap;
@@ -1,35 +0,0 @@
1
- import type { Map as MapType } from "maplibre-gl";
2
- import type { IMahalMapOptions } from "@app/types";
3
- import { DARK, LIGHT, VECTOR } from "@app/config";
4
- import maplibregl from "maplibre-gl";
5
-
6
- const defaultStyles = { dark: DARK, light: LIGHT };
7
-
8
- function createMap(options: IMahalMapOptions): MapType {
9
- let finalStyle;
10
-
11
- if (options.autoAddVectorSource) {
12
- finalStyle = VECTOR;
13
- } else {
14
- finalStyle = options.style
15
- ? options.style
16
- : options.theme === "dark"
17
- ? defaultStyles.dark
18
- : defaultStyles.light;
19
- }
20
-
21
- const map: MapType = new maplibregl.Map({
22
- container: options.container || "map",
23
- style: finalStyle as string,
24
- center: options.center || [69.624024, 40.279687],
25
- zoom: options.zoom || 5,
26
- });
27
- const compactEl = document.getElementsByClassName(
28
- "maplibregl-compact-show"
29
- )[0] as HTMLElement;
30
- if (compactEl) compactEl.style.display = "none";
31
-
32
- return map;
33
- }
34
-
35
- export { createMap };
@@ -1,17 +0,0 @@
1
- import { api } from "@app/lib";
2
-
3
- const routingApi = async (param: number[][]) => {
4
- try {
5
- const points: { lng: number; lat: number }[] = [];
6
- param.forEach((e) => {
7
- points.push({ lng: e[0], lat: e[1] });
8
- });
9
- const response = await api.post("services/getRoutes", { points });
10
- return response.data;
11
- } catch (err) {
12
- console.error(err);
13
- throw err;
14
- }
15
- };
16
-
17
- export { routingApi };
@@ -1,37 +0,0 @@
1
- import { routingApi } from "@lib/routing/api";
2
- import { geojsonPolyline } from "@app/config/index";
3
- import type { IRoute } from "@app/types/index";
4
-
5
- async function getrouter(
6
- param: number[][],
7
- typeData: string
8
- ): Promise<IRoute[]> {
9
- try {
10
- const res = await routingApi(param);
11
-
12
- if (!res?.data) return res;
13
-
14
- const data: IRoute[] = res.data;
15
-
16
- return data.map((route) => {
17
- const updated = { ...route };
18
-
19
- if (updated.route?.routes?.length) {
20
- updated.route.routes = updated.route.routes.map((r) => ({
21
- ...r,
22
- geometry:
23
- typeData === "geojson" && typeof r.geometry === "string"
24
- ? geojsonPolyline(r.geometry)
25
- : r.geometry,
26
- }));
27
- }
28
-
29
- return updated as IRoute;
30
- });
31
- } catch (error) {
32
- console.error(error);
33
- throw error;
34
- }
35
- }
36
-
37
- export { getrouter };
@@ -1,13 +0,0 @@
1
- import { api } from "@app/lib";
2
- import type { ISearchParam } from "@app/types";
3
-
4
- export const searchPost = async (param: ISearchParam) => {
5
- try {
6
- const params = { params: param };
7
- const response = await api.get("elastic/search", params);
8
- return response.data;
9
- } catch (error) {
10
- console.error("Ошибка при поиске адреса:", error);
11
- throw error;
12
- }
13
- };
@@ -1,40 +0,0 @@
1
- import { searchPost } from "./api";
2
- import { IAdditionalParamType } from "@app/types/index";
3
- import { checkCoordinates } from "@app/lib/index";
4
- import { REGEX } from "@app/config";
5
-
6
- async function search(
7
- param: string,
8
- additionalParam?: IAdditionalParamType
9
- ): Promise<any> {
10
- let searchData: any = {
11
- text: "",
12
- ...additionalParam,
13
- };
14
-
15
- if (param !== "") {
16
- if (REGEX.test(param)) {
17
- let coordinates = await checkCoordinates(param);
18
- if (coordinates) {
19
- searchData = {
20
- lat: coordinates.lat ?? "",
21
- lng: coordinates.lng ?? "",
22
- };
23
- }
24
- } else {
25
- searchData.text = param;
26
- }
27
- } else {
28
- searchData.text = "";
29
- }
30
-
31
- try {
32
- const res = await searchPost(searchData);
33
- return res;
34
- } catch (error) {
35
- console.error("Ошибка при выполнении поиска:", error);
36
- throw error;
37
- }
38
- }
39
-
40
- export { search };
package/tsconfig.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "outDir": "dist",
4
- "rootDir": "src",
5
- "module": "ESNext",
6
- "target": "ES2020",
7
- "moduleResolution": "bundler",
8
- "esModuleInterop": true,
9
- "declaration": true,
10
- "declarationMap": true,
11
- "strict": true,
12
- "sourceMap": true,
13
- "skipLibCheck": true,
14
- "emitDeclarationOnly": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "allowSyntheticDefaultImports": true,
17
- "paths": {
18
- "@app/*": ["./src/app/*"],
19
- "@lib/*": ["./src/lib/*"]
20
- }
21
- },
22
- "include": ["src/**/*.ts"]
23
- }