@artstesh/maps 11.0.0 → 11.0.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/dist/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "maps-components",
3
- "version": "0.0.2",
3
+ "version": "11.0.1",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.0.0",
6
6
  "@angular/core": "^20.0.0",
7
7
  "ol-geocoder": "^4.0.0",
8
8
  "ol": "^10.0.0",
9
- "@artstesh/postboy": "^3.3.0",
9
+ "@artstesh/postboy": "^3.4.0",
10
10
  "@artstesh/collections": "^1.0.0"
11
11
  },
12
12
  "dependencies": {
@@ -12,7 +12,6 @@ import { Subscription } from 'rxjs';
12
12
  import { PostboyService, IPostboyDependingService, PostboyGenericMessage, PostboyAbstractRegistrator, PostboyCallbackMessage, PostboyExecutor } from '@artstesh/postboy';
13
13
  import Style, { StyleFunction, StyleLike } from 'ol/style/Style';
14
14
  export { StyleLike } from 'ol/style/Style';
15
- import { Dictionary } from '@artstesh/collections';
16
15
  import { XYZ, Raster } from 'ol/source';
17
16
  import TileLayer from 'ol/layer/Tile';
18
17
  import TileSource from 'ol/source/Tile';
@@ -228,6 +227,114 @@ interface MapPosition {
228
227
  extent: number[];
229
228
  }
230
229
 
230
+ /**
231
+ * A generic class representing a dictionary structure with key-value pairs.
232
+ * Provides utilities for adding, updating, removing, and iterating over elements.
233
+ *
234
+ * @template T The type of values in the dictionary.
235
+ */
236
+ declare class Dictionary<T> {
237
+ readonly collection: Record<string, T>;
238
+ private readonly _keys;
239
+ /**
240
+ * Creates a shallow copy of the given dictionary, optionally applying
241
+ * a transformation function to each element during the cloning process.
242
+ *
243
+ * @param {Dictionary<T>} dic - The dictionary to be cloned.
244
+ * @param {(e: T, k: string) => T} [action] - An optional transformation function
245
+ * that is called for each element. The function takes the element value and
246
+ * its key as arguments and returns the modified value.
247
+ * @return {Dictionary<T>} A new dictionary that is a clone of the input dictionary
248
+ * with transformations applied if the action function is provided.
249
+ */
250
+ static clone<T>(dic: Dictionary<T>, action?: (e: T, k: string) => T): Dictionary<T>;
251
+ /**
252
+ * Creates a Dictionary instance from the given array of elements.
253
+ *
254
+ * @param {T[]} list - An array of elements to be converted into a Dictionary.
255
+ * @param {(e: T) => string} id - A function that produces a unique identifier for each element in the array.
256
+ * @return {Dictionary<T>} A Dictionary where the keys are unique identifiers derived from the elements of the array, and the values are the corresponding elements.
257
+ */
258
+ static fromList<T>(list: T[], id: (e: T) => string): Dictionary<T>;
259
+ /**
260
+ * Creates a new Dictionary instance from a given Record, optionally applying an action to each element.
261
+ *
262
+ * @param {Record<string, T>} dic The input dictionary object.
263
+ * @param {(e: T, k: string) => T} [action] An optional callback function to transform each element.
264
+ * The function receives the value and key of each element.
265
+ * @return {Dictionary<T>} A new Dictionary instance populated with the elements from the input dictionary,
266
+ * potentially transformed by the action callback if provided.
267
+ */
268
+ static create<T>(dic: Record<string, T>, action?: (e: T, k: string) => T): Dictionary<T>;
269
+ /**
270
+ * Retrieves all the keys as an array of strings from the internal data structure.
271
+ *
272
+ * @return {string[]} An array containing the keys.
273
+ */
274
+ get keys(): string[];
275
+ /**
276
+ * Retrieves the number of key-value pairs currently stored.
277
+ *
278
+ * @return {number} The current size of the collection.
279
+ */
280
+ get size(): number;
281
+ /**
282
+ * Finds and returns the first element in the collection that satisfies the provided predicate function.
283
+ *
284
+ * @param {function(T): boolean} predicate - A function used to test each element of the collection. Returns `true` to select the element, `false` otherwise.
285
+ * @return {T | null} The first element in the collection that satisfies the predicate, or `null` if no such element is found.
286
+ */
287
+ find(predicate: (value: T) => boolean): T | null;
288
+ /**
289
+ * Checks if a given key exists within the dictionary.
290
+ *
291
+ * @param {string} key - The key to check for existence in the collection.
292
+ * @returns {boolean} True if the key exists, false otherwise.
293
+ */
294
+ has: (key: string) => boolean;
295
+ /**
296
+ * Retrieves the value associated with the specified key from the collection if it exists.
297
+ *
298
+ * @param {string} key - The key whose associated value is to be retrieved.
299
+ * @return {T | null} The value associated with the specified key, or null if the key does not exist.
300
+ */
301
+ take(key: string): T | null;
302
+ /**
303
+ * Adds or updates a value associated with the specified key in the collection.
304
+ * If the value is null or undefined, removes the key from the collection.
305
+ *
306
+ * @param {string} key - The key to associate with the value in the collection.
307
+ * @param {T | null} [value] - The value to store in the collection. If null or undefined, the key will be removed.
308
+ * @return {void} Does not return a value.
309
+ */
310
+ put(key: string, value?: T | null): void;
311
+ /**
312
+ * Removes a specified key and its associated value from the collection.
313
+ *
314
+ * @param {string} key - The key to be removed from the collection.
315
+ * @return {void} Does not return a value.
316
+ */
317
+ rmv(key: string): void;
318
+ /**
319
+ * Adds a new entry or updates an existing entry in the collection based on the provided key.
320
+ * If the key already exists, it fetches the current value, applies the action, and replaces the value.
321
+ * If the key does not exist, it uses the action to create a new value and adds it.
322
+ *
323
+ * @param {string} key - The key associated with the value to add or update.
324
+ * @param {(current: T | null) => T} action - A function that takes the current value (if any) and returns the new value to be stored.
325
+ * @return {void} - Does not return a value.
326
+ */
327
+ addOrUpdate(key: string, action: (current: T | null) => T): void;
328
+ /**
329
+ * Iterates over each element in the collection and executes the provided callback function.
330
+ *
331
+ * @param {function(T, number): void} callback - A function that is called for each element of the collection.
332
+ * It takes two arguments: the current element's value and the index.
333
+ * @return {void} This method does not return a value.
334
+ */
335
+ forEach(callback: (value: T, index: number) => void): void;
336
+ }
337
+
231
338
  declare class DestructibleComponent implements OnDestroy {
232
339
  protected subs: Subscription[];
233
340
  protected onDestroy?: () => void;
@@ -1870,5 +1977,5 @@ declare class TooltipComponent extends DestructibleComponent implements OnInit {
1870
1977
  static ɵcmp: i0.ɵɵComponentDeclaration<TooltipComponent, "art-tooltip", never, { "contentRef": { "alias": "contentRef"; "required": true; "isSignal": true; }; "settings": { "alias": "settings"; "required": false; }; }, {}, never, never, true, never>;
1871
1978
  }
1872
1979
 
1873
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
1980
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
1874
1981
  export type { MapPosition };
@@ -12,7 +12,6 @@ import { Subscription } from 'rxjs';
12
12
  import { PostboyService, IPostboyDependingService, PostboyGenericMessage, PostboyAbstractRegistrator, PostboyCallbackMessage, PostboyExecutor } from '@artstesh/postboy';
13
13
  import Style, { StyleFunction, StyleLike } from 'ol/style/Style';
14
14
  export { StyleLike } from 'ol/style/Style';
15
- import { Dictionary } from '@artstesh/collections';
16
15
  import { XYZ, Raster } from 'ol/source';
17
16
  import TileLayer from 'ol/layer/Tile';
18
17
  import TileSource from 'ol/source/Tile';
@@ -228,6 +227,114 @@ interface MapPosition {
228
227
  extent: number[];
229
228
  }
230
229
 
230
+ /**
231
+ * A generic class representing a dictionary structure with key-value pairs.
232
+ * Provides utilities for adding, updating, removing, and iterating over elements.
233
+ *
234
+ * @template T The type of values in the dictionary.
235
+ */
236
+ declare class Dictionary<T> {
237
+ readonly collection: Record<string, T>;
238
+ private readonly _keys;
239
+ /**
240
+ * Creates a shallow copy of the given dictionary, optionally applying
241
+ * a transformation function to each element during the cloning process.
242
+ *
243
+ * @param {Dictionary<T>} dic - The dictionary to be cloned.
244
+ * @param {(e: T, k: string) => T} [action] - An optional transformation function
245
+ * that is called for each element. The function takes the element value and
246
+ * its key as arguments and returns the modified value.
247
+ * @return {Dictionary<T>} A new dictionary that is a clone of the input dictionary
248
+ * with transformations applied if the action function is provided.
249
+ */
250
+ static clone<T>(dic: Dictionary<T>, action?: (e: T, k: string) => T): Dictionary<T>;
251
+ /**
252
+ * Creates a Dictionary instance from the given array of elements.
253
+ *
254
+ * @param {T[]} list - An array of elements to be converted into a Dictionary.
255
+ * @param {(e: T) => string} id - A function that produces a unique identifier for each element in the array.
256
+ * @return {Dictionary<T>} A Dictionary where the keys are unique identifiers derived from the elements of the array, and the values are the corresponding elements.
257
+ */
258
+ static fromList<T>(list: T[], id: (e: T) => string): Dictionary<T>;
259
+ /**
260
+ * Creates a new Dictionary instance from a given Record, optionally applying an action to each element.
261
+ *
262
+ * @param {Record<string, T>} dic The input dictionary object.
263
+ * @param {(e: T, k: string) => T} [action] An optional callback function to transform each element.
264
+ * The function receives the value and key of each element.
265
+ * @return {Dictionary<T>} A new Dictionary instance populated with the elements from the input dictionary,
266
+ * potentially transformed by the action callback if provided.
267
+ */
268
+ static create<T>(dic: Record<string, T>, action?: (e: T, k: string) => T): Dictionary<T>;
269
+ /**
270
+ * Retrieves all the keys as an array of strings from the internal data structure.
271
+ *
272
+ * @return {string[]} An array containing the keys.
273
+ */
274
+ get keys(): string[];
275
+ /**
276
+ * Retrieves the number of key-value pairs currently stored.
277
+ *
278
+ * @return {number} The current size of the collection.
279
+ */
280
+ get size(): number;
281
+ /**
282
+ * Finds and returns the first element in the collection that satisfies the provided predicate function.
283
+ *
284
+ * @param {function(T): boolean} predicate - A function used to test each element of the collection. Returns `true` to select the element, `false` otherwise.
285
+ * @return {T | null} The first element in the collection that satisfies the predicate, or `null` if no such element is found.
286
+ */
287
+ find(predicate: (value: T) => boolean): T | null;
288
+ /**
289
+ * Checks if a given key exists within the dictionary.
290
+ *
291
+ * @param {string} key - The key to check for existence in the collection.
292
+ * @returns {boolean} True if the key exists, false otherwise.
293
+ */
294
+ has: (key: string) => boolean;
295
+ /**
296
+ * Retrieves the value associated with the specified key from the collection if it exists.
297
+ *
298
+ * @param {string} key - The key whose associated value is to be retrieved.
299
+ * @return {T | null} The value associated with the specified key, or null if the key does not exist.
300
+ */
301
+ take(key: string): T | null;
302
+ /**
303
+ * Adds or updates a value associated with the specified key in the collection.
304
+ * If the value is null or undefined, removes the key from the collection.
305
+ *
306
+ * @param {string} key - The key to associate with the value in the collection.
307
+ * @param {T | null} [value] - The value to store in the collection. If null or undefined, the key will be removed.
308
+ * @return {void} Does not return a value.
309
+ */
310
+ put(key: string, value?: T | null): void;
311
+ /**
312
+ * Removes a specified key and its associated value from the collection.
313
+ *
314
+ * @param {string} key - The key to be removed from the collection.
315
+ * @return {void} Does not return a value.
316
+ */
317
+ rmv(key: string): void;
318
+ /**
319
+ * Adds a new entry or updates an existing entry in the collection based on the provided key.
320
+ * If the key already exists, it fetches the current value, applies the action, and replaces the value.
321
+ * If the key does not exist, it uses the action to create a new value and adds it.
322
+ *
323
+ * @param {string} key - The key associated with the value to add or update.
324
+ * @param {(current: T | null) => T} action - A function that takes the current value (if any) and returns the new value to be stored.
325
+ * @return {void} - Does not return a value.
326
+ */
327
+ addOrUpdate(key: string, action: (current: T | null) => T): void;
328
+ /**
329
+ * Iterates over each element in the collection and executes the provided callback function.
330
+ *
331
+ * @param {function(T, number): void} callback - A function that is called for each element of the collection.
332
+ * It takes two arguments: the current element's value and the index.
333
+ * @return {void} This method does not return a value.
334
+ */
335
+ forEach(callback: (value: T, index: number) => void): void;
336
+ }
337
+
231
338
  declare class DestructibleComponent implements OnDestroy {
232
339
  protected subs: Subscription[];
233
340
  protected onDestroy?: () => void;
@@ -1870,5 +1977,5 @@ declare class TooltipComponent extends DestructibleComponent implements OnInit {
1870
1977
  static ɵcmp: i0.ɵɵComponentDeclaration<TooltipComponent, "art-tooltip", never, { "contentRef": { "alias": "contentRef"; "required": true; "isSignal": true; }; "settings": { "alias": "settings"; "required": false; }; }, {}, never, never, true, never>;
1871
1978
  }
1872
1979
 
1873
- export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
1980
+ export { AddControlCommand, CalculateAreaExecutor, CancelDrawingCommand, CancelFeatureModificationCommand, CloseTooltipCommand, ClusterLayerComponent, ClusterLayerSettings, Dictionary, DrawSelectionAreaCommand, DrawingType, FeatureLayerComponent, FeatureLayerSettings, FeatureOutputFormat, FilterFeaturesInAreaExecutor, FilterFeaturesInPointExecutor, FitToFeaturesCommand, FitToPolygonsCommand, GeotiffTileLayerComponent, GeotiffTileLayerSettings, GetFeaturesInAreaQuery, GetFeaturesInPointQuery, GetGeometryLengthExecutor, GetMapPositionExecutor, ImageLayerComponent, ImageLayerSettings, MapClickEvent, MapConstants, MapControl, MapControlZoomComponent, MapFeatureHoveredEvent, MapLyrs, MapLyrsLabel, MapMoveEndEvent, MapPlateComponent, MapPointerMoveEvent, MapPostboyService, MapRenderedEvent, MapSettings, MarkerModel, MarkerStyleHelper, MarkersComponent, MessageRegistratorService, ModifyFeatureCommand, OsmTileLayerComponent, PolygonModel, PolygonSelfIntersectionExecutor, PolygonStyleHelper, PolygonsComponent, RasterTileLayerComponent, RasterTileLayerSettings, RemoveControlCommand, SetMapCenterCommand, StartDrawingCommand, StringifyFeatureHelper, TextStyleHelper, TileLayerComponent, TileLayerSettings, TooltipComponent, TooltipSettings, ZoomControlSettings };
1874
1981
  export type { MapPosition };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artstesh/maps",
3
- "version": "11.0.0",
3
+ "version": "11.0.1",
4
4
  "author": "artstesh",
5
5
  "license": "MIT",
6
6
  "description": "Let's draw a map ;)",
@@ -11,7 +11,7 @@
11
11
  "build": "ng build",
12
12
  "prepare": "npm run build",
13
13
  "preversion": "npm test",
14
- "version": "npm run format && git add -A projects",
14
+ "version": "npm run format && node scripts/sync-version.js && git add -A projects",
15
15
  "format": "prettier --write \"projects/**/*.ts\"",
16
16
  "postversion": "git push && git push --tags",
17
17
  "watch": "ng build --watch --configuration development",
@@ -30,9 +30,8 @@
30
30
  "markers"
31
31
  ],
32
32
  "module": "dist/fesm2022/maps-components.mjs",
33
- "main": "dist/esm2022/public-api.mjs",
34
- "types": "dist/public-api.d.ts",
35
- "typings": "dist/index.d.ts",
33
+ "types": "dist/types/maps-components.d.ts",
34
+ "typings": "dist/types/maps-components.d.ts",
36
35
  "repository": {
37
36
  "type": "git",
38
37
  "url": "git+https://github.com/artstesh/maps.git"
@@ -42,14 +41,12 @@
42
41
  "@angular/core": "^22.0.0",
43
42
  "ol-geocoder": "^4.0.0",
44
43
  "ol": "^10.0.0",
45
- "@artstesh/postboy": "^3.4.0",
46
- "@artstesh/collections": "^1.0.0"
44
+ "@artstesh/postboy": "^3.4.0"
47
45
  },
48
46
  "devDependencies": {
49
47
  "@angular/common": "22.1.6",
50
48
  "@angular/compiler": "22.1.6",
51
49
  "@angular/core": "22.1.6",
52
- "@artstesh/collections": "1.0.4",
53
50
  "@artstesh/postboy": "3.4.2",
54
51
  "ol": "10.7.2",
55
52
  "ol-geocoder": "4.3.3",
@@ -108,5 +105,18 @@
108
105
  "extends": [
109
106
  "plugin:storybook/recommended"
110
107
  ]
108
+ },
109
+ "exports": {
110
+ "./package.json": {
111
+ "default": "./package.json"
112
+ },
113
+ ".": {
114
+ "types": "./dist/types/maps-components.d.ts",
115
+ "default": "./dist/fesm2022/maps-components.mjs"
116
+ },
117
+ "./src/map": {
118
+ "types": "./dist/types/maps-components-src-map.d.ts",
119
+ "default": "./dist/fesm2022/maps-components-src-map.mjs"
120
+ }
111
121
  }
112
122
  }