@tomtom-org/maps-sdk-plugin-viewport-places 0.4.0 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -35,10 +35,11 @@ export type ViewportPlacesAddOptions = ViewportPlacesAddCommonOptions & {
35
35
  * The search parameters to query places for this place module.
36
36
  *
37
37
  * @remarks
38
- * `geoBias` and `signal` are not accepted here: each module always searches the current
39
- * viewport and owns an `AbortSignal` so that a new search cancels the one it supersedes.
38
+ * `geoBias`, `cursor` and `signal` are not accepted here: each module always searches the first
39
+ * page of the current viewport and owns an `AbortSignal` so that a new search cancels the one it
40
+ * supersedes.
40
41
  */
41
- searchOptions: Omit<FuzzySearchParams, 'geoBias' | 'signal'>;
42
+ searchOptions: Omit<FuzzySearchParams, 'geoBias' | 'cursor' | 'signal'>;
42
43
  /**
43
44
  * Optional configuration for the places module, such as styling.
44
45
  */
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import{generateId as e}from"@tomtom-org/maps-sdk/core";import{PlacesModule as o}from"@tomtom-org/maps-sdk/map";import{SDKAbortError as s,discoverPlaces as t}from"@tomtom-org/maps-sdk/services";var i=class{map;registeredModules={};mapLibreMap;constructor(e){this.map=e,this.mapLibreMap=e.mapLibreMap}getRegisteredModule(e){const o=this.registeredModules[e];if(!o)throw new Error(`Place module with id ${e} not found`);return o}async searchAndDisplay(e){const o=this.registeredModules[e];if(!o)return;const{placesModule:i,options:r}=o;o.controller?.abort();const a=this.mapLibreMap.getZoom();if(r.minZoom&&a<r.minZoom||r.maxZoom&&a>r.maxZoom)return void(await i.clear());const n=new AbortController;o.controller=n;try{const e=await t({geoBias:{boundingBox:this.map.getBBox()},limit:100,...r.searchOptions,signal:n.signal});if(n.signal.aborted)return;await i.show(e)}catch(l){if(l instanceof s)return;throw l}}async add(s){const t=s.id??e(),i={...s,placesModuleConfig:{theme:"base-map",...s.placesModuleConfig}},r=await o.create(this.map,i.placesModuleConfig),a=()=>this.searchAndDisplay(t),n=this.mapLibreMap.on("moveend",a);return this.registeredModules[t]={placesModule:r,subscription:n,options:i},await a(),r}async addPOICategories(e){return this.add({...e,searchOptions:{poiCategories:e.categories}})}remove(e){const o=this.getRegisteredModule(e);o.controller?.abort(),o.placesModule.clear(),o.subscription.unsubscribe(),delete this.registeredModules[e]}removeAll(){Object.keys(this.registeredModules).forEach(e=>this.remove(e))}async update(e){const o=this.getRegisteredModule(e.id),s=o.options;o.options={...s,...e,searchOptions:{...s.searchOptions,...e.searchOptions},placesModuleConfig:{...s.placesModuleConfig,...e.placesModuleConfig}},o.placesModule.applyConfig(o.options.placesModuleConfig),await this.searchAndDisplay(e.id)}};export{i as ViewportPlaces};
1
+ import{generateId as e}from"@tomtom-org/maps-sdk/core";import{PlacesModule as s}from"@tomtom-org/maps-sdk/map";import{createLatestRequest as o,discoverPlaces as t}from"@tomtom-org/maps-sdk/services";var i=class{map;registeredModules={};mapLibreMap;constructor(e){this.map=e,this.mapLibreMap=e.mapLibreMap}getRegisteredModule(e){const s=this.registeredModules[e];if(!s)throw new Error(`Place module with id ${e} not found`);return s}async searchAndDisplay(e){const s=this.registeredModules[e];if(!s)return;const{placesModule:o,options:i,latestSearch:a}=s,r=this.mapLibreMap.getZoom();if(i.minZoom&&r<i.minZoom||i.maxZoom&&r>i.maxZoom)return a.cancel(),void(await o.clear());const n=await a.run(e=>t({geoBias:{boundingBox:this.map.getBBox()},limit:100,...i.searchOptions,signal:e}));n.current&&await o.show(n.value)}async add(t){const i=t.id??e(),a={...t,placesModuleConfig:{theme:"base-map",...t.placesModuleConfig}},r=await s.create(this.map,a.placesModuleConfig),n=()=>this.searchAndDisplay(i),c=this.mapLibreMap.on("moveend",n);return this.registeredModules[i]={placesModule:r,subscription:c,options:a,latestSearch:o()},await n(),r}async addPOICategories(e){return this.add({...e,searchOptions:{filters:{poiCategories:e.categories}}})}remove(e){const s=this.getRegisteredModule(e);s.latestSearch.cancel(),s.placesModule.clear(),s.subscription.unsubscribe(),delete this.registeredModules[e]}removeAll(){Object.keys(this.registeredModules).forEach(e=>this.remove(e))}async update(e){const s=this.getRegisteredModule(e.id),o=s.options;s.options={...o,...e,searchOptions:{...o.searchOptions,...e.searchOptions,filters:{...o.searchOptions.filters,...e.searchOptions.filters}},placesModuleConfig:{...o.placesModuleConfig,...e.placesModuleConfig}},s.placesModule.applyConfig(s.options.placesModuleConfig),await this.searchAndDisplay(e.id)}};export{i as ViewportPlaces};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","names":["generateId","PlacesModule","SDKAbortError","discoverPlaces","ViewportPlaces","map","registeredModules","mapLibreMap","constructor","this","getRegisteredModule","id","entry","Error","searchAndDisplay","placesModule","options","controller","abort","zoom","getZoom","minZoom","maxZoom","clear","AbortController","places","geoBias","boundingBox","getBBox","limit","searchOptions","signal","aborted","show","error","add","effectiveOptions","placesModuleConfig","theme","create","subscription","on","addPOICategories","poiCategories","categories","remove","unsubscribe","removeAll","Object","keys","forEach","key","update","newOptions","currentOptions","applyConfig"],"sources":["../src/viewportPlaces.ts"],"sourcesContent":["import { generateId, POICategory } from '@tomtom-org/maps-sdk/core';\nimport { PlacesModule, type PlacesModuleConfig, TomTomMap } from '@tomtom-org/maps-sdk/map';\nimport { discoverPlaces, type FuzzySearchParams, SDKAbortError } from '@tomtom-org/maps-sdk/services';\nimport type { Subscription } from 'maplibre-gl';\n\n/**\n * Common Options when adding a viewport places module.\n *\n * @group Viewport Places\n */\nexport type ViewportPlacesAddCommonOptions = {\n /**\n * Optional unique identifier for the viewport places module.\n *\n * @remarks\n * * If not provided, a random ID will be generated.\n * * If you need to keep updating or removing this place module later, provide a fixed ID.\n */\n id?: string;\n /**\n * Minimum zoom level at which the place module is visible.\n */\n minZoom?: number;\n /**\n * Maximum zoom level at which the place module is visible.\n */\n maxZoom?: number;\n};\n\n/**\n * Full Options when adding a viewport places module.\n *\n * @group Viewport Places\n */\nexport type ViewportPlacesAddOptions = ViewportPlacesAddCommonOptions & {\n /**\n * The search parameters to query places for this place module.\n *\n * @remarks\n * `geoBias` and `signal` are not accepted here: each module always searches the current\n * viewport and owns an `AbortSignal` so that a new search cancels the one it supersedes.\n */\n searchOptions: Omit<FuzzySearchParams, 'geoBias' | 'signal'>;\n /**\n * Optional configuration for the places module, such as styling.\n */\n placesModuleConfig?: PlacesModuleConfig;\n};\n\n/**\n * Options when updating a viewport places module.\n *\n * @group Viewport Places\n */\nexport type ViewportPlacesOptions = Omit<ViewportPlacesAddOptions, 'id'> & {\n /**\n * The unique identifier of the place module to update.\n * @remarks\n * * This ID must correspond to an existing place module added via an \"add\" method.\n */\n id: string;\n};\n\n/**\n * A class for managing dynamic searched place modules on a TomTom map.\n *\n * It leverages the SDK search service to maintain place modules that automatically\n * update and stay current as the map viewport changes.\n *\n * @group Viewport Places\n */\nexport class ViewportPlaces {\n /**\n * Internal map of registered place modules, keyed by their `id`.\n * @private\n */\n private registeredModules: Record<\n string,\n {\n options: ViewportPlacesAddOptions;\n placesModule: PlacesModule;\n subscription: Subscription;\n /** Cancels this module's in-flight search when a newer viewport supersedes it. */\n controller?: AbortController;\n }\n > = {};\n private readonly mapLibreMap;\n\n /**\n * Creates an instance of ViewportPlaces bound to a TomTom map.\n * @param map - The TomTom map instance to attach place modules to.\n */\n constructor(private readonly map: TomTomMap) {\n this.mapLibreMap = map.mapLibreMap;\n }\n\n private getRegisteredModule(id: string) {\n const entry = this.registeredModules[id];\n if (!entry) {\n throw new Error(`Place module with id ${id} not found`);\n }\n\n return entry;\n }\n\n /**\n * Performs the update logic for a registered PlacesModule, cancelling whatever search that\n * module still has in flight.\n * @param id - The unique identifier of the registered place module to refresh.\n */\n private async searchAndDisplay(id: string): Promise<void> {\n const entry = this.registeredModules[id];\n if (!entry) return;\n\n const { placesModule, options } = entry;\n\n // The previous viewport's search is stale. Must precede the zoom guard below: that path\n // clears and returns early, and a search left running would repopulate what it cleared.\n entry.controller?.abort();\n\n const zoom = this.mapLibreMap.getZoom();\n if ((options.minZoom && zoom < options.minZoom) || (options.maxZoom && zoom > options.maxZoom)) {\n await placesModule.clear();\n return;\n }\n\n const controller = new AbortController();\n entry.controller = controller;\n\n try {\n const places = await discoverPlaces({\n geoBias: { boundingBox: this.map.getBBox() },\n limit: 100,\n ...options.searchOptions,\n signal: controller.signal,\n });\n // Superseded between the response arriving and rendering it\n if (controller.signal.aborted) return;\n\n await placesModule.show(places);\n } catch (error) {\n if (error instanceof SDKAbortError) return;\n\n throw error;\n }\n }\n\n /**\n * Adds a PlacesModule that displays places based on fuzzy search parameters and automatically updates as the map moves.\n *\n * @remarks\n * * Each call to \"add\" creates a new place module and places it above previously added modules.\n * * Place modules are rendered bottom-up in the order they are added: the first added module is displayed at the bottom, and later modules are stacked on top of earlier ones.\n * * The default places module theme is 'base-map' unless overridden in the options.\n *\n * @param options - The options for the place module.\n * @returns A promise that resolves to the PlacesModule instance managing the module.\n */\n async add(options: ViewportPlacesAddOptions): Promise<PlacesModule> {\n const id = options.id ?? generateId();\n const effectiveOptions = {\n ...options,\n placesModuleConfig: { theme: 'base-map', ...options.placesModuleConfig } as PlacesModuleConfig,\n };\n\n const placesModule = await PlacesModule.create(this.map, effectiveOptions.placesModuleConfig);\n const searchAndDisplay = () => this.searchAndDisplay(id);\n\n const subscription = this.mapLibreMap.on('moveend', searchAndDisplay);\n this.registeredModules[id] = { placesModule, subscription, options: effectiveOptions };\n await searchAndDisplay();\n return placesModule;\n }\n\n /**\n * Adds a PlacesModule for specific POI categories that updates automatically as the map moves.\n * The POIs are shown in the same style as the base map.\n *\n * @remarks\n * * This is a convenience wrapper over `add` that configures a category-based search for a PlacesModule.\n * * Each call creates a new place module that will be stacked on top of previously added modules.\n *\n * @param options - The options for the category-based place module.\n * @returns A promise that resolves to the PlacesModule instance managing the module.\n */\n async addPOICategories(\n options: ViewportPlacesAddCommonOptions & { categories: POICategory[] },\n ): Promise<PlacesModule> {\n return this.add({\n ...options,\n searchOptions: { poiCategories: options.categories },\n });\n }\n\n /**\n * Removes a specific place module by its ID, stopping its updates and clearing the displayed places.\n *\n * @param id - The unique identifier of the PlacesModule to remove.\n * @throws Error if the place module with the given ID does not exist.\n */\n remove(id: string): void {\n const entry = this.getRegisteredModule(id);\n entry.controller?.abort();\n entry.placesModule.clear();\n entry.subscription.unsubscribe();\n delete this.registeredModules[id];\n }\n\n /**\n * Removes all registered place modules, stopping their updates and clearing all displayed places.\n */\n removeAll(): void {\n Object.keys(this.registeredModules).forEach((key) => this.remove(key));\n }\n\n /**\n * Updates the search and display options for an existing place module identified by its ID.\n * This will immediately apply the new options and refresh the place module accordingly.\n * @param newOptions - The new options to apply.\n * @throws Error if the place module with the given ID does not exist.\n */\n async update(newOptions: ViewportPlacesOptions): Promise<void> {\n const entry = this.getRegisteredModule(newOptions.id);\n const currentOptions = entry.options;\n\n // Update the options by merging current and new options:\n entry.options = {\n ...currentOptions,\n ...newOptions,\n // search and places display options are merged incrementally:\n searchOptions: { ...currentOptions.searchOptions, ...newOptions.searchOptions },\n placesModuleConfig: { ...currentOptions.placesModuleConfig, ...newOptions.placesModuleConfig },\n };\n // Update the places module configuration and refresh the display:\n entry.placesModule.applyConfig(entry.options.placesModuleConfig);\n await this.searchAndDisplay(newOptions.id);\n }\n}\n"],"mappings":"iMAuEA,IAAaI,EAAb,MAqBiCC,IAhB7BC,kBASI,CAAC,EACLC,YAMA,WAAAC,CAAYH,GAAiBI,KAAAJ,IAAAA,EACzBI,KAAKF,YAAcF,EAAIE,WAC3B,CAEA,mBAAAG,CAA4BC,GACxB,MAAMC,EAAQH,KAAKH,kBAAkBK,GACrC,IAAKC,EACD,MAAM,IAAIC,MAAM,wBAAwBF,eAG5C,OAAOC,CACX,CAOA,sBAAcE,CAAiBH,GAC3B,MAAMC,EAAQH,KAAKH,kBAAkBK,GACrC,IAAKC,EAAO,OAEZ,MAAMG,aAAEA,EAAAC,QAAcA,GAAYJ,EAIlCA,EAAMK,YAAY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2C,EAAiB1C,EAAMI,QAG7BJ,EAAMI,QAAU,IACTsC,KACAD,EAEHvB,cAAe,IAAKwB,EAAexB,iBAAkBuB,EAAWvB,eAChEO,mBAAoB,IAAKiB,EAAejB,sBAAuBgB,EAAWhB,qBAG9EzB,EAAMG,aAAawC,YAAY3C,EAAMI,QAAQqB,0BACvC5B,KAAKK,iBAAiBuC,EAAW1C,GAC3C"}
1
+ {"version":3,"file":"index.es.js","names":["generateId","PlacesModule","createLatestRequest","discoverPlaces","ViewportPlaces","map","registeredModules","mapLibreMap","constructor","this","getRegisteredModule","id","entry","Error","searchAndDisplay","placesModule","options","latestSearch","zoom","getZoom","minZoom","maxZoom","cancel","clear","search","run","signal","geoBias","boundingBox","getBBox","limit","searchOptions","current","show","value","add","effectiveOptions","placesModuleConfig","theme","create","subscription","on","addPOICategories","filters","poiCategories","categories","remove","unsubscribe","removeAll","Object","keys","forEach","key","update","newOptions","currentOptions","applyConfig"],"sources":["../src/viewportPlaces.ts"],"sourcesContent":["import { generateId, POICategory } from '@tomtom-org/maps-sdk/core';\nimport { PlacesModule, type PlacesModuleConfig, TomTomMap } from '@tomtom-org/maps-sdk/map';\nimport {\n createLatestRequest,\n discoverPlaces,\n type FuzzySearchParams,\n type LatestRequest,\n} from '@tomtom-org/maps-sdk/services';\nimport type { Subscription } from 'maplibre-gl';\n\n/**\n * Common Options when adding a viewport places module.\n *\n * @group Viewport Places\n */\nexport type ViewportPlacesAddCommonOptions = {\n /**\n * Optional unique identifier for the viewport places module.\n *\n * @remarks\n * * If not provided, a random ID will be generated.\n * * If you need to keep updating or removing this place module later, provide a fixed ID.\n */\n id?: string;\n /**\n * Minimum zoom level at which the place module is visible.\n */\n minZoom?: number;\n /**\n * Maximum zoom level at which the place module is visible.\n */\n maxZoom?: number;\n};\n\n/**\n * Full Options when adding a viewport places module.\n *\n * @group Viewport Places\n */\nexport type ViewportPlacesAddOptions = ViewportPlacesAddCommonOptions & {\n /**\n * The search parameters to query places for this place module.\n *\n * @remarks\n * `geoBias`, `cursor` and `signal` are not accepted here: each module always searches the first\n * page of the current viewport and owns an `AbortSignal` so that a new search cancels the one it\n * supersedes.\n */\n searchOptions: Omit<FuzzySearchParams, 'geoBias' | 'cursor' | 'signal'>;\n /**\n * Optional configuration for the places module, such as styling.\n */\n placesModuleConfig?: PlacesModuleConfig;\n};\n\n/**\n * Options when updating a viewport places module.\n *\n * @group Viewport Places\n */\nexport type ViewportPlacesOptions = Omit<ViewportPlacesAddOptions, 'id'> & {\n /**\n * The unique identifier of the place module to update.\n * @remarks\n * * This ID must correspond to an existing place module added via an \"add\" method.\n */\n id: string;\n};\n\n/**\n * A class for managing dynamic searched place modules on a TomTom map.\n *\n * It leverages the SDK search service to maintain place modules that automatically\n * update and stay current as the map viewport changes.\n *\n * @group Viewport Places\n */\nexport class ViewportPlaces {\n /**\n * Internal map of registered place modules, keyed by their `id`.\n * @private\n */\n private registeredModules: Record<\n string,\n {\n options: ViewportPlacesAddOptions;\n placesModule: PlacesModule;\n subscription: Subscription;\n /** Retires this module's in-flight search when a newer viewport supersedes it. */\n latestSearch: LatestRequest;\n }\n > = {};\n private readonly mapLibreMap;\n\n /**\n * Creates an instance of ViewportPlaces bound to a TomTom map.\n * @param map - The TomTom map instance to attach place modules to.\n */\n constructor(private readonly map: TomTomMap) {\n this.mapLibreMap = map.mapLibreMap;\n }\n\n private getRegisteredModule(id: string) {\n const entry = this.registeredModules[id];\n if (!entry) {\n throw new Error(`Place module with id ${id} not found`);\n }\n\n return entry;\n }\n\n /**\n * Performs the update logic for a registered PlacesModule, cancelling whatever search that\n * module still has in flight.\n * @param id - The unique identifier of the registered place module to refresh.\n */\n private async searchAndDisplay(id: string): Promise<void> {\n const entry = this.registeredModules[id];\n if (!entry) return;\n\n const { placesModule, options, latestSearch } = entry;\n\n const zoom = this.mapLibreMap.getZoom();\n if ((options.minZoom && zoom < options.minZoom) || (options.maxZoom && zoom > options.maxZoom)) {\n // A search left running would repopulate what this clears\n latestSearch.cancel();\n await placesModule.clear();\n return;\n }\n\n const search = await latestSearch.run((signal) =>\n discoverPlaces({\n geoBias: { boundingBox: this.map.getBBox() },\n limit: 100,\n ...options.searchOptions,\n signal,\n }),\n );\n if (search.current) await placesModule.show(search.value);\n }\n\n /**\n * Adds a PlacesModule that displays places based on fuzzy search parameters and automatically updates as the map moves.\n *\n * @remarks\n * * Each call to \"add\" creates a new place module and places it above previously added modules.\n * * Place modules are rendered bottom-up in the order they are added: the first added module is displayed at the bottom, and later modules are stacked on top of earlier ones.\n * * The default places module theme is 'base-map' unless overridden in the options.\n *\n * @param options - The options for the place module.\n * @returns A promise that resolves to the PlacesModule instance managing the module.\n */\n async add(options: ViewportPlacesAddOptions): Promise<PlacesModule> {\n const id = options.id ?? generateId();\n const effectiveOptions = {\n ...options,\n placesModuleConfig: { theme: 'base-map', ...options.placesModuleConfig } as PlacesModuleConfig,\n };\n\n const placesModule = await PlacesModule.create(this.map, effectiveOptions.placesModuleConfig);\n const searchAndDisplay = () => this.searchAndDisplay(id);\n\n const subscription = this.mapLibreMap.on('moveend', searchAndDisplay);\n this.registeredModules[id] = {\n placesModule,\n subscription,\n options: effectiveOptions,\n latestSearch: createLatestRequest(),\n };\n await searchAndDisplay();\n return placesModule;\n }\n\n /**\n * Adds a PlacesModule for specific POI categories that updates automatically as the map moves.\n * The POIs are shown in the same style as the base map.\n *\n * @remarks\n * * This is a convenience wrapper over `add` that configures a category-based search for a PlacesModule.\n * * Each call creates a new place module that will be stacked on top of previously added modules.\n *\n * @param options - The options for the category-based place module.\n * @returns A promise that resolves to the PlacesModule instance managing the module.\n */\n async addPOICategories(\n options: ViewportPlacesAddCommonOptions & { categories: POICategory[] },\n ): Promise<PlacesModule> {\n return this.add({\n ...options,\n searchOptions: { filters: { poiCategories: options.categories } },\n });\n }\n\n /**\n * Removes a specific place module by its ID, stopping its updates and clearing the displayed places.\n *\n * @param id - The unique identifier of the PlacesModule to remove.\n * @throws Error if the place module with the given ID does not exist.\n */\n remove(id: string): void {\n const entry = this.getRegisteredModule(id);\n entry.latestSearch.cancel();\n entry.placesModule.clear();\n entry.subscription.unsubscribe();\n delete this.registeredModules[id];\n }\n\n /**\n * Removes all registered place modules, stopping their updates and clearing all displayed places.\n */\n removeAll(): void {\n Object.keys(this.registeredModules).forEach((key) => this.remove(key));\n }\n\n /**\n * Updates the search and display options for an existing place module identified by its ID.\n * This will immediately apply the new options and refresh the place module accordingly.\n * @param newOptions - The new options to apply.\n * @throws Error if the place module with the given ID does not exist.\n */\n async update(newOptions: ViewportPlacesOptions): Promise<void> {\n const entry = this.getRegisteredModule(newOptions.id);\n const currentOptions = entry.options;\n\n // Update the options by merging current and new options:\n entry.options = {\n ...currentOptions,\n ...newOptions,\n // search and places display options are merged incrementally, search filters included:\n searchOptions: {\n ...currentOptions.searchOptions,\n ...newOptions.searchOptions,\n filters: { ...currentOptions.searchOptions.filters, ...newOptions.searchOptions.filters },\n },\n placesModuleConfig: { ...currentOptions.placesModuleConfig, ...newOptions.placesModuleConfig },\n };\n // Update the places module configuration and refresh the display:\n entry.placesModule.applyConfig(entry.options.placesModuleConfig);\n await this.searchAndDisplay(newOptions.id);\n }\n}\n"],"mappings":"uMA6EA,IAAaI,EAAb,MAqBiCC,IAhB7BC,kBASI,CAAC,EACLC,YAMA,WAAAC,CAAYH,GAAiBI,KAAAJ,IAAAA,EACzBI,KAAKF,YAAcF,EAAIE,WAC3B,CAEA,mBAAAG,CAA4BC,GACxB,MAAMC,EAAQH,KAAKH,kBAAkBK,GACrC,IAAKC,EACD,MAAM,IAAIC,MAAM,wBAAwBF,eAG5C,OAAOC,CACX,CAOA,sBAAcE,CAAiBH,GAC3B,MAAMC,EAAQH,KAAKH,kBAAkBK,GACrC,IAAKC,EAAO,OAEZ,MAAMG,aAAEA,EAAAC,QAAcA,EAAAC,aAASA,GAAiBL,EAE1CM,EAAOT,KAAKF,YAAYY,UAC9B,GAAKH,EAAQI,SAAWF,EAAOF,EAAQI,SAAaJ,EAAQK,SAAWH,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AAuBiB,EAAWjB,qBAG9EzB,EAAMG,aAAayC,YAAY5C,EAAMI,QAAQqB,0BACvC5B,KAAKK,iBAAiBwC,EAAW3C,GAC3C"}
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@tomtom-org/maps-sdk-plugin-viewport-places",
3
3
  "author": "TomTom International B.V.",
4
4
  "license": "See in LICENSE.txt",
5
- "version": "0.4.0",
5
+ "version": "0.5.0",
6
6
  "type": "module",
7
7
  "description": "Plugin to leverage search to show places on the current viewport that refresh as the map moves",
8
8
  "types": "dist/index.d.ts",
9
9
  "peerDependencies": {
10
- "@tomtom-org/maps-sdk": ">=0.58.0 <1.0.0"
10
+ "@tomtom-org/maps-sdk": ">=0.59.0 <1.0.0"
11
11
  },
12
12
  "devDependencies": {
13
13
  "@tsconfig/recommended": "^1.0.13",
@@ -18,7 +18,7 @@
18
18
  "typescript": "^6.0.3",
19
19
  "vite": "^8.3.1",
20
20
  "vitest": "^4.1.11",
21
- "@tomtom-org/maps-sdk": "0.58.0"
21
+ "@tomtom-org/maps-sdk": "0.59.0"
22
22
  },
23
23
  "files": [
24
24
  "dist",