@mapvx/web-js 4.0.3-dev.1 → 4.0.3-dev.2
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/cjs/index.js +4 -2
- package/dist/es/assets/icons.d.ts +0 -1
- package/dist/es/assets/icons.js +0 -50
- package/dist/es/config/draco.d.ts +0 -1
- package/dist/es/config/draco.js +0 -10
- package/dist/es/config/sdkConfig.d.ts +0 -1
- package/dist/es/config/sdkConfig.js +0 -1
- package/dist/es/controllers/markerLayoutController.d.ts +0 -1
- package/dist/es/controllers/markerLayoutController.js +0 -103
- package/dist/es/controllers/routeController.d.ts +0 -1
- package/dist/es/controllers/routeController.js +1 -473
- package/dist/es/domain/models/_internal.d.ts +0 -1
- package/dist/es/domain/models/_internal.js +0 -8
- package/dist/es/domain/models/animation.d.ts +0 -1
- package/dist/es/domain/models/animation.js +0 -6
- package/dist/es/domain/models/banner.d.ts +0 -1
- package/dist/es/domain/models/banner.js +0 -10
- package/dist/es/domain/models/campaign.d.ts +0 -1
- package/dist/es/domain/models/campaign.js +0 -29
- package/dist/es/domain/models/categories.d.ts +0 -1
- package/dist/es/domain/models/categories.js +0 -20
- package/dist/es/domain/models/circle.d.ts +0 -1
- package/dist/es/domain/models/circle.js +0 -118
- package/dist/es/domain/models/cityFilterOption.d.ts +0 -1
- package/dist/es/domain/models/cityFilterOption.js +0 -1
- package/dist/es/domain/models/configuration.d.ts +0 -1
- package/dist/es/domain/models/configuration.js +0 -1
- package/dist/es/domain/models/cssCustomization.d.ts +0 -1
- package/dist/es/domain/models/cssCustomization.js +0 -1
- package/dist/es/domain/models/fitOptions.d.ts +0 -1
- package/dist/es/domain/models/fitOptions.js +0 -1
- package/dist/es/domain/models/innerFloors.d.ts +0 -1
- package/dist/es/domain/models/innerFloors.js +0 -1
- package/dist/es/domain/models/institution.d.ts +0 -1
- package/dist/es/domain/models/institution.js +0 -26
- package/dist/es/domain/models/latLng.d.ts +0 -1
- package/dist/es/domain/models/latLng.js +0 -1
- package/dist/es/domain/models/location.d.ts +0 -1
- package/dist/es/domain/models/location.js +0 -1
- package/dist/es/domain/models/loggeable.d.ts +0 -1
- package/dist/es/domain/models/loggeable.js +0 -24
- package/dist/es/domain/models/mapCamera.d.ts +0 -1
- package/dist/es/domain/models/mapCamera.js +0 -1
- package/dist/es/domain/models/mapConfig.d.ts +0 -1
- package/dist/es/domain/models/mapConfig.js +1 -17
- package/dist/es/domain/models/marker.d.ts +0 -1
- package/dist/es/domain/models/marker.js +0 -292
- package/dist/es/domain/models/multilanguage.d.ts +0 -1
- package/dist/es/domain/models/multilanguage.js +0 -10
- package/dist/es/domain/models/openingHours.d.ts +0 -1
- package/dist/es/domain/models/openingHours.js +0 -1
- package/dist/es/domain/models/place.d.ts +0 -1
- package/dist/es/domain/models/place.js +0 -68
- package/dist/es/domain/models/platform.d.ts +0 -1
- package/dist/es/domain/models/platform.js +0 -1
- package/dist/es/domain/models/popover.d.ts +0 -1
- package/dist/es/domain/models/popover.js +0 -1
- package/dist/es/domain/models/product.d.ts +0 -1
- package/dist/es/domain/models/product.js +0 -1
- package/dist/es/domain/models/property.d.ts +0 -1
- package/dist/es/domain/models/property.js +0 -16
- package/dist/es/domain/models/route.d.ts +0 -1
- package/dist/es/domain/models/route.js +0 -71
- package/dist/es/domain/models/routeConfiguration.d.ts +0 -1
- package/dist/es/domain/models/routeConfiguration.js +0 -36
- package/dist/es/domain/models/routeInstance.d.ts +0 -1
- package/dist/es/domain/models/routeInstance.js +0 -8
- package/dist/es/domain/models/routeStyle.d.ts +0 -1
- package/dist/es/domain/models/routeStyle.js +0 -1
- package/dist/es/domain/models/scene3D.d.ts +0 -1
- package/dist/es/domain/models/scene3D.js +0 -1
- package/dist/es/domain/models/transport.d.ts +0 -1
- package/dist/es/domain/models/transport.js +0 -12
- package/dist/es/domain/ports/ICache.d.ts +0 -1
- package/dist/es/domain/ports/ICache.js +0 -1
- package/dist/es/domain/ports/IHttpClient.d.ts +0 -1
- package/dist/es/domain/ports/IHttpClient.js +0 -1
- package/dist/es/domain/ports/ILogger.d.ts +0 -1
- package/dist/es/domain/ports/ILogger.js +0 -9
- package/dist/es/domain/ports/index.d.ts +0 -1
- package/dist/es/domain/ports/index.js +0 -5
- package/dist/es/index.d.ts +0 -1
- package/dist/es/index.js +1 -28
- package/dist/es/infrastructure/cache/CacheManager.d.ts +0 -1
- package/dist/es/infrastructure/cache/CacheManager.js +0 -94
- package/dist/es/infrastructure/cache/LRUCache.d.ts +0 -1
- package/dist/es/infrastructure/cache/LRUCache.js +0 -57
- package/dist/es/infrastructure/cache/PersistentCache.d.ts +0 -1
- package/dist/es/infrastructure/cache/PersistentCache.js +0 -51
- package/dist/es/infrastructure/cache/cacheConfig.d.ts +0 -1
- package/dist/es/infrastructure/cache/cacheConfig.js +8 -27
- package/dist/es/infrastructure/http/FetchHttpClient.d.ts +0 -1
- package/dist/es/infrastructure/http/FetchHttpClient.js +0 -36
- package/dist/es/infrastructure/logging/MVXLogger.d.ts +0 -1
- package/dist/es/infrastructure/logging/MVXLogger.js +0 -37
- package/dist/es/interfaces/cache.d.ts +0 -1
- package/dist/es/interfaces/cache.js +0 -1
- package/dist/es/interfaces/healthResponse.d.ts +0 -1
- package/dist/es/interfaces/healthResponse.js +0 -1
- package/dist/es/interfaces/institutionResponse.d.ts +0 -1
- package/dist/es/interfaces/institutionResponse.js +0 -1
- package/dist/es/interfaces/metadata.d.ts +0 -1
- package/dist/es/interfaces/metadata.js +0 -1
- package/dist/es/interfaces/placeResponse.d.ts +0 -1
- package/dist/es/interfaces/placeResponse.js +0 -1
- package/dist/es/interfaces/routeCacheResponse.d.ts +0 -1
- package/dist/es/interfaces/routeCacheResponse.js +0 -1
- package/dist/es/interfaces/routeResponse.d.ts +0 -1
- package/dist/es/interfaces/routeResponse.js +0 -1
- package/dist/es/interfaces/styleResponse.d.ts +0 -1
- package/dist/es/interfaces/styleResponse.js +0 -1
- package/dist/es/logger/logger.d.ts +0 -1
- package/dist/es/logger/logger.js +0 -10
- package/dist/es/logger/sentry.d.ts +0 -1
- package/dist/es/logger/sentry.js +1 -39
- package/dist/es/map/fitCamera.d.ts +0 -1
- package/dist/es/map/fitCamera.js +0 -44
- package/dist/es/map/generated/maplibreWorkerSource.d.ts +0 -1
- package/dist/es/map/generated/maplibreWorkerSource.js +0 -12
- package/dist/es/map/installMapLibreWorker.d.ts +0 -1
- package/dist/es/map/installMapLibreWorker.js +0 -100
- package/dist/es/map/liveMapFitTransform.d.ts +0 -1
- package/dist/es/map/liveMapFitTransform.js +0 -82
- package/dist/es/map/map.d.ts +0 -1
- package/dist/es/map/map.js +4 -681
- package/dist/es/map/mapInteractionOptions.d.ts +0 -1
- package/dist/es/map/mapInteractionOptions.js +0 -35
- package/dist/es/map/scene3DController.d.ts +0 -1
- package/dist/es/map/scene3DController.js +0 -221
- package/dist/es/repository/repository.d.ts +0 -1
- package/dist/es/repository/repository.js +0 -56
- package/dist/es/repository/requester.d.ts +0 -1
- package/dist/es/repository/requester.js +0 -233
- package/dist/es/sdk.d.ts +0 -1
- package/dist/es/sdk.js +0 -35
- package/dist/es/utils/3d.d.ts +0 -1
- package/dist/es/utils/3d.js +0 -79
- package/dist/es/utils/deckLayers.d.ts +0 -1
- package/dist/es/utils/deckLayers.js +1 -27
- package/dist/es/utils/error.d.ts +0 -1
- package/dist/es/utils/error.js +0 -7
- package/dist/es/utils/images.d.ts +0 -1
- package/dist/es/utils/images.js +0 -7
- package/dist/es/utils/loadGlb.d.ts +0 -1
- package/dist/es/utils/loadGlb.js +2 -96
- package/dist/es/utils/mapvxHostname.d.ts +0 -1
- package/dist/es/utils/mapvxHostname.js +0 -11
- package/dist/es/utils/nav-functions.d.ts +0 -1
- package/dist/es/utils/nav-functions.js +0 -82
- package/dist/es/utils/opening-hours-helper.d.ts +0 -1
- package/dist/es/utils/opening-hours-helper.js +6 -382
- package/dist/es/utils/preconnect.d.ts +0 -1
- package/dist/es/utils/preconnect.js +0 -61
- package/dist/es/utils/route-utils.d.ts +0 -1
- package/dist/es/utils/route-utils.js +0 -25
- package/dist/es/utils/semaphore.d.ts +0 -1
- package/dist/es/utils/semaphore.js +0 -78
- package/dist/es/utils/three.d.ts +0 -1
- package/dist/es/utils/three.js +0 -43
- package/dist/es/utils/threeScene.d.ts +0 -1
- package/dist/es/utils/threeScene.js +0 -38
- package/dist/es/utils/update-css.d.ts +0 -1
- package/dist/es/utils/update-css.js +0 -26
- package/dist/es/utils/utils.d.ts +0 -1
- package/dist/es/utils/utils.js +0 -53
- package/dist/umd/index.js +4 -29240
- package/dist/umd/index.js.LICENSE.txt +1 -0
- package/dist/umd/styles.css +0 -1
- package/dist/umd/styles.js +3 -32
- package/package.json +11 -5
- package/dist/cjs/index.js.map +0 -1
- package/dist/es/assets/icons.d.ts.map +0 -1
- package/dist/es/assets/icons.js.map +0 -1
- package/dist/es/config/draco.d.ts.map +0 -1
- package/dist/es/config/draco.js.map +0 -1
- package/dist/es/config/sdkConfig.d.ts.map +0 -1
- package/dist/es/config/sdkConfig.js.map +0 -1
- package/dist/es/controllers/markerLayoutController.d.ts.map +0 -1
- package/dist/es/controllers/markerLayoutController.js.map +0 -1
- package/dist/es/controllers/routeController.d.ts.map +0 -1
- package/dist/es/controllers/routeController.js.map +0 -1
- package/dist/es/domain/models/_internal.d.ts.map +0 -1
- package/dist/es/domain/models/_internal.js.map +0 -1
- package/dist/es/domain/models/animation.d.ts.map +0 -1
- package/dist/es/domain/models/animation.js.map +0 -1
- package/dist/es/domain/models/banner.d.ts.map +0 -1
- package/dist/es/domain/models/banner.js.map +0 -1
- package/dist/es/domain/models/campaign.d.ts.map +0 -1
- package/dist/es/domain/models/campaign.js.map +0 -1
- package/dist/es/domain/models/categories.d.ts.map +0 -1
- package/dist/es/domain/models/categories.js.map +0 -1
- package/dist/es/domain/models/circle.d.ts.map +0 -1
- package/dist/es/domain/models/circle.js.map +0 -1
- package/dist/es/domain/models/cityFilterOption.d.ts.map +0 -1
- package/dist/es/domain/models/cityFilterOption.js.map +0 -1
- package/dist/es/domain/models/configuration.d.ts.map +0 -1
- package/dist/es/domain/models/configuration.js.map +0 -1
- package/dist/es/domain/models/cssCustomization.d.ts.map +0 -1
- package/dist/es/domain/models/cssCustomization.js.map +0 -1
- package/dist/es/domain/models/fitOptions.d.ts.map +0 -1
- package/dist/es/domain/models/fitOptions.js.map +0 -1
- package/dist/es/domain/models/innerFloors.d.ts.map +0 -1
- package/dist/es/domain/models/innerFloors.js.map +0 -1
- package/dist/es/domain/models/institution.d.ts.map +0 -1
- package/dist/es/domain/models/institution.js.map +0 -1
- package/dist/es/domain/models/latLng.d.ts.map +0 -1
- package/dist/es/domain/models/latLng.js.map +0 -1
- package/dist/es/domain/models/location.d.ts.map +0 -1
- package/dist/es/domain/models/location.js.map +0 -1
- package/dist/es/domain/models/loggeable.d.ts.map +0 -1
- package/dist/es/domain/models/loggeable.js.map +0 -1
- package/dist/es/domain/models/mapCamera.d.ts.map +0 -1
- package/dist/es/domain/models/mapCamera.js.map +0 -1
- package/dist/es/domain/models/mapConfig.d.ts.map +0 -1
- package/dist/es/domain/models/mapConfig.js.map +0 -1
- package/dist/es/domain/models/marker.d.ts.map +0 -1
- package/dist/es/domain/models/marker.js.map +0 -1
- package/dist/es/domain/models/multilanguage.d.ts.map +0 -1
- package/dist/es/domain/models/multilanguage.js.map +0 -1
- package/dist/es/domain/models/openingHours.d.ts.map +0 -1
- package/dist/es/domain/models/openingHours.js.map +0 -1
- package/dist/es/domain/models/place.d.ts.map +0 -1
- package/dist/es/domain/models/place.js.map +0 -1
- package/dist/es/domain/models/platform.d.ts.map +0 -1
- package/dist/es/domain/models/platform.js.map +0 -1
- package/dist/es/domain/models/popover.d.ts.map +0 -1
- package/dist/es/domain/models/popover.js.map +0 -1
- package/dist/es/domain/models/product.d.ts.map +0 -1
- package/dist/es/domain/models/product.js.map +0 -1
- package/dist/es/domain/models/property.d.ts.map +0 -1
- package/dist/es/domain/models/property.js.map +0 -1
- package/dist/es/domain/models/route.d.ts.map +0 -1
- package/dist/es/domain/models/route.js.map +0 -1
- package/dist/es/domain/models/routeConfiguration.d.ts.map +0 -1
- package/dist/es/domain/models/routeConfiguration.js.map +0 -1
- package/dist/es/domain/models/routeInstance.d.ts.map +0 -1
- package/dist/es/domain/models/routeInstance.js.map +0 -1
- package/dist/es/domain/models/routeStyle.d.ts.map +0 -1
- package/dist/es/domain/models/routeStyle.js.map +0 -1
- package/dist/es/domain/models/scene3D.d.ts.map +0 -1
- package/dist/es/domain/models/scene3D.js.map +0 -1
- package/dist/es/domain/models/transport.d.ts.map +0 -1
- package/dist/es/domain/models/transport.js.map +0 -1
- package/dist/es/domain/ports/ICache.d.ts.map +0 -1
- package/dist/es/domain/ports/ICache.js.map +0 -1
- package/dist/es/domain/ports/IHttpClient.d.ts.map +0 -1
- package/dist/es/domain/ports/IHttpClient.js.map +0 -1
- package/dist/es/domain/ports/ILogger.d.ts.map +0 -1
- package/dist/es/domain/ports/ILogger.js.map +0 -1
- package/dist/es/domain/ports/index.d.ts.map +0 -1
- package/dist/es/domain/ports/index.js.map +0 -1
- package/dist/es/index.d.ts.map +0 -1
- package/dist/es/index.js.map +0 -1
- package/dist/es/infrastructure/cache/CacheManager.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/CacheManager.js.map +0 -1
- package/dist/es/infrastructure/cache/LRUCache.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/LRUCache.js.map +0 -1
- package/dist/es/infrastructure/cache/PersistentCache.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/PersistentCache.js.map +0 -1
- package/dist/es/infrastructure/cache/cacheConfig.d.ts.map +0 -1
- package/dist/es/infrastructure/cache/cacheConfig.js.map +0 -1
- package/dist/es/infrastructure/http/FetchHttpClient.d.ts.map +0 -1
- package/dist/es/infrastructure/http/FetchHttpClient.js.map +0 -1
- package/dist/es/infrastructure/logging/MVXLogger.d.ts.map +0 -1
- package/dist/es/infrastructure/logging/MVXLogger.js.map +0 -1
- package/dist/es/interfaces/cache.d.ts.map +0 -1
- package/dist/es/interfaces/cache.js.map +0 -1
- package/dist/es/interfaces/healthResponse.d.ts.map +0 -1
- package/dist/es/interfaces/healthResponse.js.map +0 -1
- package/dist/es/interfaces/institutionResponse.d.ts.map +0 -1
- package/dist/es/interfaces/institutionResponse.js.map +0 -1
- package/dist/es/interfaces/metadata.d.ts.map +0 -1
- package/dist/es/interfaces/metadata.js.map +0 -1
- package/dist/es/interfaces/placeResponse.d.ts.map +0 -1
- package/dist/es/interfaces/placeResponse.js.map +0 -1
- package/dist/es/interfaces/routeCacheResponse.d.ts.map +0 -1
- package/dist/es/interfaces/routeCacheResponse.js.map +0 -1
- package/dist/es/interfaces/routeResponse.d.ts.map +0 -1
- package/dist/es/interfaces/routeResponse.js.map +0 -1
- package/dist/es/interfaces/styleResponse.d.ts.map +0 -1
- package/dist/es/interfaces/styleResponse.js.map +0 -1
- package/dist/es/logger/logger.d.ts.map +0 -1
- package/dist/es/logger/logger.js.map +0 -1
- package/dist/es/logger/sentry.d.ts.map +0 -1
- package/dist/es/logger/sentry.js.map +0 -1
- package/dist/es/map/fitCamera.d.ts.map +0 -1
- package/dist/es/map/fitCamera.js.map +0 -1
- package/dist/es/map/generated/maplibreWorkerSource.d.ts.map +0 -1
- package/dist/es/map/generated/maplibreWorkerSource.js.map +0 -1
- package/dist/es/map/installMapLibreWorker.d.ts.map +0 -1
- package/dist/es/map/installMapLibreWorker.js.map +0 -1
- package/dist/es/map/liveMapFitTransform.d.ts.map +0 -1
- package/dist/es/map/liveMapFitTransform.js.map +0 -1
- package/dist/es/map/map.d.ts.map +0 -1
- package/dist/es/map/map.js.map +0 -1
- package/dist/es/map/mapInteractionOptions.d.ts.map +0 -1
- package/dist/es/map/mapInteractionOptions.js.map +0 -1
- package/dist/es/map/scene3DController.d.ts.map +0 -1
- package/dist/es/map/scene3DController.js.map +0 -1
- package/dist/es/repository/repository.d.ts.map +0 -1
- package/dist/es/repository/repository.js.map +0 -1
- package/dist/es/repository/requester.d.ts.map +0 -1
- package/dist/es/repository/requester.js.map +0 -1
- package/dist/es/sdk.d.ts.map +0 -1
- package/dist/es/sdk.js.map +0 -1
- package/dist/es/utils/3d.d.ts.map +0 -1
- package/dist/es/utils/3d.js.map +0 -1
- package/dist/es/utils/deckLayers.d.ts.map +0 -1
- package/dist/es/utils/deckLayers.js.map +0 -1
- package/dist/es/utils/error.d.ts.map +0 -1
- package/dist/es/utils/error.js.map +0 -1
- package/dist/es/utils/images.d.ts.map +0 -1
- package/dist/es/utils/images.js.map +0 -1
- package/dist/es/utils/loadGlb.d.ts.map +0 -1
- package/dist/es/utils/loadGlb.js.map +0 -1
- package/dist/es/utils/mapvxHostname.d.ts.map +0 -1
- package/dist/es/utils/mapvxHostname.js.map +0 -1
- package/dist/es/utils/nav-functions.d.ts.map +0 -1
- package/dist/es/utils/nav-functions.js.map +0 -1
- package/dist/es/utils/opening-hours-helper.d.ts.map +0 -1
- package/dist/es/utils/opening-hours-helper.js.map +0 -1
- package/dist/es/utils/preconnect.d.ts.map +0 -1
- package/dist/es/utils/preconnect.js.map +0 -1
- package/dist/es/utils/route-utils.d.ts.map +0 -1
- package/dist/es/utils/route-utils.js.map +0 -1
- package/dist/es/utils/semaphore.d.ts.map +0 -1
- package/dist/es/utils/semaphore.js.map +0 -1
- package/dist/es/utils/three.d.ts.map +0 -1
- package/dist/es/utils/three.js.map +0 -1
- package/dist/es/utils/threeScene.d.ts.map +0 -1
- package/dist/es/utils/threeScene.js.map +0 -1
- package/dist/es/utils/update-css.d.ts.map +0 -1
- package/dist/es/utils/update-css.js.map +0 -1
- package/dist/es/utils/utils.d.ts.map +0 -1
- package/dist/es/utils/utils.js.map +0 -1
- package/dist/umd/index.js.map +0 -1
- package/dist/umd/styles.css.map +0 -1
- package/dist/umd/styles.js.map +0 -1
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hostnames that MapVX maps typically need to talk to during the first
|
|
3
|
-
* paint: vector tiles, sprite, glyphs and indoor tile sources. Exposed so
|
|
4
|
-
* that consumer apps can call `injectPreconnects(MAPVX_DEFAULT_PRECONNECT_HOSTS)`
|
|
5
|
-
* without having to maintain the list themselves.
|
|
6
|
-
*
|
|
7
|
-
* @group Utils
|
|
8
|
-
*/
|
|
9
1
|
export const MAPVX_DEFAULT_PRECONNECT_HOSTS = [
|
|
10
2
|
"https://tiles.mapvx.com",
|
|
11
3
|
"https://api.maptiler.com",
|
|
12
4
|
"https://indoorequals.mapvx.com",
|
|
13
5
|
];
|
|
14
|
-
/**
|
|
15
|
-
* Injects `<link rel="preconnect">` (and a `<link rel="dns-prefetch">` fallback)
|
|
16
|
-
* tags into `document.head` for the given origins, so the browser starts the
|
|
17
|
-
* DNS + TLS handshake before MapLibre actually requests sprite/glyph/tile
|
|
18
|
-
* resources.
|
|
19
|
-
*
|
|
20
|
-
* Call this as early as possible — ideally before {@link initializeSDK} — to
|
|
21
|
-
* maximize the savings. In real captures this shaves ~150-300 ms off the
|
|
22
|
-
* first-paint cascade.
|
|
23
|
-
*
|
|
24
|
-
* Idempotent: hosts that already have a `<link rel="preconnect" crossorigin>`
|
|
25
|
-
* are skipped. If an existing `preconnect` link is missing `crossorigin`, it
|
|
26
|
-
* is upgraded in place (added `crossorigin="anonymous"`) — without that
|
|
27
|
-
* attribute the warmed socket can't be reused for the CORS tile/font/sprite
|
|
28
|
-
* fetches MapLibre performs, so leaving the existing link untouched would
|
|
29
|
-
* silently defeat the optimization. Existing `crossorigin="use-credentials"`
|
|
30
|
-
* is respected and never overwritten.
|
|
31
|
-
*
|
|
32
|
-
* @param hosts - Origin URLs (`"https://tiles.mapvx.com"`) or bare hostnames
|
|
33
|
-
* (`"tiles.mapvx.com"`, normalized to `https://`). Invalid entries are
|
|
34
|
-
* silently ignored.
|
|
35
|
-
* @returns The origins where the helper made a change — either a new link was
|
|
36
|
-
* appended, or an existing one was upgraded with `crossorigin="anonymous"`.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* import { initializeSDK, injectPreconnects, MAPVX_DEFAULT_PRECONNECT_HOSTS } from "@mapvx/web-js"
|
|
41
|
-
*
|
|
42
|
-
* injectPreconnects(MAPVX_DEFAULT_PRECONNECT_HOSTS)
|
|
43
|
-
* const sdk = initializeSDK(apiKey)
|
|
44
|
-
* ```
|
|
45
|
-
*
|
|
46
|
-
* @group Utils
|
|
47
|
-
*/
|
|
48
6
|
export function injectPreconnects(hosts) {
|
|
49
7
|
if (typeof document === "undefined" || !document.head)
|
|
50
8
|
return [];
|
|
@@ -57,12 +15,6 @@ export function injectPreconnects(hosts) {
|
|
|
57
15
|
const origin = normalizeOrigin(raw);
|
|
58
16
|
if (origin === null)
|
|
59
17
|
continue;
|
|
60
|
-
// Check what's already in <head>. We may need to UPGRADE an existing
|
|
61
|
-
// preconnect — server-rendered or hand-authored hints frequently omit
|
|
62
|
-
// `crossorigin`, and a warmed socket without it cannot be reused for
|
|
63
|
-
// the CORS tile/font/sprite fetches that MapLibre performs. Without
|
|
64
|
-
// this branch the optimization would silently no-op when the page
|
|
65
|
-
// already had a partial hint.
|
|
66
18
|
const existingPreconnect = findLinkForOrigin("preconnect", origin);
|
|
67
19
|
let preconnectChanged = false;
|
|
68
20
|
if (existingPreconnect) {
|
|
@@ -70,9 +22,6 @@ export function injectPreconnects(hosts) {
|
|
|
70
22
|
existingPreconnect.crossOrigin = "anonymous";
|
|
71
23
|
preconnectChanged = true;
|
|
72
24
|
}
|
|
73
|
-
// If the existing link already has any `crossorigin` value
|
|
74
|
-
// (including `use-credentials`), respect the author's intent and
|
|
75
|
-
// leave it alone.
|
|
76
25
|
}
|
|
77
26
|
else {
|
|
78
27
|
const preconnect = document.createElement("link");
|
|
@@ -82,7 +31,6 @@ export function injectPreconnects(hosts) {
|
|
|
82
31
|
document.head.appendChild(preconnect);
|
|
83
32
|
preconnectChanged = true;
|
|
84
33
|
}
|
|
85
|
-
// dns-prefetch is a fallback for older browsers that ignore preconnect.
|
|
86
34
|
if (!findLinkForOrigin("dns-prefetch", origin)) {
|
|
87
35
|
const dnsPrefetch = document.createElement("link");
|
|
88
36
|
dnsPrefetch.rel = "dns-prefetch";
|
|
@@ -94,13 +42,6 @@ export function injectPreconnects(hosts) {
|
|
|
94
42
|
}
|
|
95
43
|
return injected;
|
|
96
44
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Returns the first `<link rel="${rel}">` in `<head>` whose resolved origin
|
|
99
|
-
* matches `origin`, or null. We compare canonical URL origins instead of
|
|
100
|
-
* the raw `href` attribute text — the same origin can be written as
|
|
101
|
-
* `https://tiles.mapvx.com` or `https://tiles.mapvx.com/`, and a strict
|
|
102
|
-
* attribute selector would miss the second form and inject a duplicate.
|
|
103
|
-
*/
|
|
104
45
|
function findLinkForOrigin(rel, origin) {
|
|
105
46
|
const links = document.head.querySelectorAll(`link[rel="${rel}"]`);
|
|
106
47
|
for (let i = 0; i < links.length; i++) {
|
|
@@ -110,7 +51,6 @@ function findLinkForOrigin(rel, origin) {
|
|
|
110
51
|
return link;
|
|
111
52
|
}
|
|
112
53
|
catch (_a) {
|
|
113
|
-
// Malformed href — skip and keep scanning.
|
|
114
54
|
}
|
|
115
55
|
}
|
|
116
56
|
return null;
|
|
@@ -124,4 +64,3 @@ function normalizeOrigin(raw) {
|
|
|
124
64
|
return null;
|
|
125
65
|
}
|
|
126
66
|
}
|
|
127
|
-
//# sourceMappingURL=preconnect.js.map
|
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts coordinate points from a route step, attempting multiple data sources
|
|
3
|
-
* in order of preference to ensure the most complete coordinate set is returned.
|
|
4
|
-
*
|
|
5
|
-
* This function implements a fallback strategy to extract coordinates from different
|
|
6
|
-
* properties of the route step. It first tries to use the start and end locations,
|
|
7
|
-
* then attempts to use polyline overview points or detailed points, and finally falls
|
|
8
|
-
* back to the step's direct coordinates property if no other data is available.
|
|
9
|
-
* This approach ensures compatibility with different API response formats and data
|
|
10
|
-
* availability scenarios.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const step = new MVXRouteStep(stepData);
|
|
15
|
-
* const coordinates = extractStepCoordinates(step);
|
|
16
|
-
* // Returns: [{ lat: 40.7128, lng: -74.0060 }, { lat: 40.7580, lng: -74.0431 }, ...]
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @param {MVXRouteStep} step - The route step from which to extract coordinates
|
|
20
|
-
* @returns {LatLng[]} Array of coordinate points. Returns step.coordinates if no other
|
|
21
|
-
* coordinate data is found in the step's properties
|
|
22
|
-
*
|
|
23
|
-
* @group Utils
|
|
24
|
-
*/
|
|
25
1
|
export function extractStepCoordinates(step) {
|
|
26
2
|
var _a, _b, _c, _d, _e, _f;
|
|
27
3
|
const coords = [];
|
|
@@ -51,4 +27,3 @@ export function extractStepCoordinates(step) {
|
|
|
51
27
|
}
|
|
52
28
|
return coords;
|
|
53
29
|
}
|
|
54
|
-
//# sourceMappingURL=route-utils.js.map
|
|
@@ -1,24 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lower bound (inclusive) for the semaphore concurrency limit.
|
|
3
|
-
*
|
|
4
|
-
* A value of 1 means at least one operation can run at a time, which keeps the
|
|
5
|
-
* semaphore meaningful: zero or negative limits would deadlock every caller.
|
|
6
|
-
*/
|
|
7
1
|
const MIN_LIMIT = 1;
|
|
8
|
-
/**
|
|
9
|
-
* Upper bound (inclusive) for the semaphore concurrency limit.
|
|
10
|
-
*
|
|
11
|
-
* 64 is high enough for any practical browser-side fan-out (network requests,
|
|
12
|
-
* tile fetches, etc.) while still protecting downstream services from being
|
|
13
|
-
* overwhelmed by misconfigured callers.
|
|
14
|
-
*/
|
|
15
2
|
const MAX_LIMIT = 64;
|
|
16
|
-
/**
|
|
17
|
-
* Validate and normalize a candidate concurrency limit.
|
|
18
|
-
*
|
|
19
|
-
* @param limit - Candidate value to validate.
|
|
20
|
-
* @returns The validated integer limit, or `null` if the value is invalid.
|
|
21
|
-
*/
|
|
22
3
|
function normalizeLimit(limit) {
|
|
23
4
|
if (!Number.isFinite(limit))
|
|
24
5
|
return null;
|
|
@@ -27,72 +8,22 @@ function normalizeLimit(limit) {
|
|
|
27
8
|
return null;
|
|
28
9
|
return floored;
|
|
29
10
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Counting semaphore that caps the number of concurrent operations.
|
|
32
|
-
*
|
|
33
|
-
* Useful when calling APIs, CDNs, or other shared resources where unbounded
|
|
34
|
-
* parallelism can trigger rate limiting, WAF blocks, or excessive memory use.
|
|
35
|
-
* Waiters are released in FIFO order as slots become free.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* const sem = new Semaphore(4);
|
|
40
|
-
*
|
|
41
|
-
* async function fetchTile(url: string) {
|
|
42
|
-
* await sem.acquire();
|
|
43
|
-
* try {
|
|
44
|
-
* return await fetch(url);
|
|
45
|
-
* } finally {
|
|
46
|
-
* sem.release();
|
|
47
|
-
* }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @group Utils
|
|
52
|
-
*/
|
|
53
11
|
export class Semaphore {
|
|
54
|
-
/**
|
|
55
|
-
* @param limit - Maximum number of concurrent slots. Must be a finite
|
|
56
|
-
* integer in `[1, 64]`; invalid values fall back to `1`.
|
|
57
|
-
*/
|
|
58
12
|
constructor(limit = MIN_LIMIT) {
|
|
59
13
|
var _a;
|
|
60
14
|
this.waiters = [];
|
|
61
15
|
this.slotsInUse = 0;
|
|
62
16
|
this.slotLimit = (_a = normalizeLimit(limit)) !== null && _a !== void 0 ? _a : MIN_LIMIT;
|
|
63
17
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Maximum number of slots that can be acquired concurrently.
|
|
66
|
-
*/
|
|
67
18
|
get limit() {
|
|
68
19
|
return this.slotLimit;
|
|
69
20
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Number of slots currently held by callers (acquired but not released).
|
|
72
|
-
*/
|
|
73
21
|
get inUse() {
|
|
74
22
|
return this.slotsInUse;
|
|
75
23
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Number of callers currently waiting for a slot.
|
|
78
|
-
*/
|
|
79
24
|
get waiting() {
|
|
80
25
|
return this.waiters.length;
|
|
81
26
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Acquire one slot. Resolves immediately if a slot is free; otherwise waits
|
|
84
|
-
* in FIFO order until `release()` is called.
|
|
85
|
-
*
|
|
86
|
-
* Every successful `acquire()` must be paired with exactly one `release()`,
|
|
87
|
-
* typically from a `finally` block. If the promise rejects (e.g. the optional
|
|
88
|
-
* `signal` aborts while queued) no slot was granted, so `release()` must NOT
|
|
89
|
-
* be called.
|
|
90
|
-
*
|
|
91
|
-
* @param signal - Optional `AbortSignal`. If it aborts while the caller is
|
|
92
|
-
* still queued, the waiter is removed from the queue and the promise rejects
|
|
93
|
-
* with an `AbortError`, so cancelled work never occupies a slot.
|
|
94
|
-
* @returns A promise that resolves once a slot has been granted.
|
|
95
|
-
*/
|
|
96
27
|
acquire(signal) {
|
|
97
28
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
98
29
|
return Promise.reject(new DOMException("Aborted", "AbortError"));
|
|
@@ -118,14 +49,6 @@ export class Semaphore {
|
|
|
118
49
|
}
|
|
119
50
|
});
|
|
120
51
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Release one slot, waking the next FIFO waiter only when a slot was actually
|
|
123
|
-
* freed.
|
|
124
|
-
*
|
|
125
|
-
* Safe to call even when no slots are in use: it is a true no-op in that case,
|
|
126
|
-
* so cleanup code in `finally` blocks is defensive against double-releases and
|
|
127
|
-
* a stray release can never admit a waiter beyond {@link limit}.
|
|
128
|
-
*/
|
|
129
52
|
release() {
|
|
130
53
|
if (this.slotsInUse > 0) {
|
|
131
54
|
this.slotsInUse--;
|
|
@@ -136,4 +59,3 @@ export class Semaphore {
|
|
|
136
59
|
}
|
|
137
60
|
}
|
|
138
61
|
}
|
|
139
|
-
//# sourceMappingURL=semaphore.js.map
|
package/dist/es/utils/three.d.ts
CHANGED
package/dist/es/utils/three.js
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memoizes a dynamic-import chain, caching only a FULFILLED result.
|
|
3
|
-
*
|
|
4
|
-
* A plain `cached ??= import(...)` also memoizes a *rejection*, so one transient chunk-fetch
|
|
5
|
-
* failure (a dropped connection, a cache-busted deploy mid-session) permanently disables the
|
|
6
|
-
* feature for the rest of the page's life: every retry receives the same rejected promise and
|
|
7
|
-
* fails identically. The 3D scene retries on its own — `reloadScene3DModelsForLod` reloads GLB
|
|
8
|
-
* templates on every zoom-in past the LOD threshold — so a sticky rejection turns a blip into
|
|
9
|
-
* models that never come back until the user reloads.
|
|
10
|
-
*
|
|
11
|
-
* Concurrent callers still share one in-flight import (that is the point of the cache); only the
|
|
12
|
-
* rejected promise is evicted, and the error is re-thrown so every current caller still sees it.
|
|
13
|
-
*
|
|
14
|
-
* Exported only so the eviction behaviour can be tested directly — the loaders below wrap real
|
|
15
|
-
* dynamic `import()` calls, which a unit test cannot fail on demand.
|
|
16
|
-
*
|
|
17
|
-
* @param load Builds the import promise. Called again on the first retry after a failure.
|
|
18
|
-
* @returns An accessor that imports at most once per successful load.
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
1
|
export function memoizeImport(load) {
|
|
22
2
|
let cached;
|
|
23
3
|
return () => {
|
|
24
4
|
cached !== null && cached !== void 0 ? cached : (cached = load().catch((error) => {
|
|
25
|
-
// Evict BEFORE re-throwing so the next call starts a fresh import. Safe to assign here:
|
|
26
|
-
// a promise never settles synchronously, so `cached` is already assigned by now.
|
|
27
5
|
cached = undefined;
|
|
28
6
|
throw error;
|
|
29
7
|
}));
|
|
30
8
|
return cached;
|
|
31
9
|
};
|
|
32
10
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Dynamically imports Three.js and the GLTF/DRACO/KTX2 loaders once and caches the result.
|
|
35
|
-
* Subsequent calls return the same promise, so a single Three.js instance is shared.
|
|
36
|
-
* A failed import is not cached — see {@link memoizeImport}.
|
|
37
|
-
*/
|
|
38
11
|
export const loadThree = memoizeImport(() => Promise.all([
|
|
39
12
|
import("three"),
|
|
40
13
|
import("three/addons/loaders/GLTFLoader.js"),
|
|
@@ -46,22 +19,7 @@ export const loadThree = memoizeImport(() => Promise.all([
|
|
|
46
19
|
DRACOLoader: draco.DRACOLoader,
|
|
47
20
|
KTX2Loader: ktx2.KTX2Loader,
|
|
48
21
|
})));
|
|
49
|
-
/**
|
|
50
|
-
* Dynamically imports the singleton meshopt decoder once and caches the result.
|
|
51
|
-
*
|
|
52
|
-
* Deliberately NOT part of {@link loadThree}'s import chain: only GLBs compressed with
|
|
53
|
-
* `EXT_meshopt_compression` need it, so keeping it out of the eager `Promise.all` keeps the
|
|
54
|
-
* decoder module (and its WASM instantiation) off the critical path of the first 3D frame.
|
|
55
|
-
* It is fetched on the first meshopt buffer decode instead — see the lazy wrapper in
|
|
56
|
-
* `loadGlb.ts`. That moves the fetch inside `parse()`, competing with hundreds of MB of GLB
|
|
57
|
-
* downloads, so not caching a failed import (see {@link memoizeImport}) matters more here than
|
|
58
|
-
* for the eager loaders.
|
|
59
|
-
*/
|
|
60
22
|
export const loadMeshoptDecoder = memoizeImport(() => import("three/addons/libs/meshopt_decoder.module.js").then((meshopt) => meshopt.MeshoptDecoder));
|
|
61
|
-
/**
|
|
62
|
-
* Dynamically imports the deck.gl overlay and layer classes once and caches the result.
|
|
63
|
-
* A failed import is not cached — see {@link memoizeImport}.
|
|
64
|
-
*/
|
|
65
23
|
export const loadDeck = memoizeImport(() => Promise.all([
|
|
66
24
|
import("@deck.gl/mapbox"),
|
|
67
25
|
import("@deck.gl/geo-layers"),
|
|
@@ -73,4 +31,3 @@ export const loadDeck = memoizeImport(() => Promise.all([
|
|
|
73
31
|
PathLayer: layers.PathLayer,
|
|
74
32
|
TextLayer: layers.TextLayer,
|
|
75
33
|
})));
|
|
76
|
-
//# sourceMappingURL=three.js.map
|
|
@@ -40,4 +40,3 @@ export declare function disposeMaterialsOnly(three: typeof import("three"), root
|
|
|
40
40
|
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
41
41
|
*/
|
|
42
42
|
export declare function disposeObject3D(three: typeof import("three"), root: THREE.Object3D): void;
|
|
43
|
-
//# sourceMappingURL=threeScene.d.ts.map
|
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pure Three.js scene helpers. They receive the resolved Three.js module (from {@link loadThree})
|
|
3
|
-
* as their first argument instead of importing it, so they add nothing to the base bundle and can be
|
|
4
|
-
* unit-tested by passing a real Three.js instance (Three.js core math/scene classes need no WebGL).
|
|
5
|
-
*
|
|
6
|
-
* @group Utils
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Computes the anchor point used for bottom-aligned GLB placement: XZ from the bounding-box center,
|
|
10
|
-
* Y from the bounding-box minimum.
|
|
11
|
-
*
|
|
12
|
-
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
13
|
-
*/
|
|
14
1
|
export function computeGlbBottomAnchor(three, root) {
|
|
15
2
|
const box = new three.Box3().setFromObject(root);
|
|
16
3
|
const center = box.getCenter(new three.Vector3());
|
|
17
4
|
center.y = box.min.y;
|
|
18
5
|
return center;
|
|
19
6
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Instantiates Three.js lights from declarative config and adds them to the scene.
|
|
22
|
-
*
|
|
23
|
-
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
24
|
-
* @returns Number of light objects added (used to keep lights when clearing meshes).
|
|
25
|
-
*/
|
|
26
7
|
export function addScene3DLights(three, scene, lights) {
|
|
27
8
|
let count = 0;
|
|
28
9
|
for (const light of lights) {
|
|
@@ -38,7 +19,6 @@ export function addScene3DLights(three, scene, lights) {
|
|
|
38
19
|
}
|
|
39
20
|
return count;
|
|
40
21
|
}
|
|
41
|
-
/** Every material texture-slot property name across three.js's built-in material types. */
|
|
42
22
|
const MATERIAL_TEXTURE_KEYS = [
|
|
43
23
|
"map",
|
|
44
24
|
"alphaMap",
|
|
@@ -76,15 +56,6 @@ function disposeMaterial(three, material, disposeTextures) {
|
|
|
76
56
|
}
|
|
77
57
|
material.dispose();
|
|
78
58
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Disposes every mesh's material(s) under `root`, releasing each one's GPU-side program reference,
|
|
81
|
-
* without touching geometries or textures. Use this for a group whose geometries/textures are
|
|
82
|
-
* shared with a still-live cache (e.g. a GLB template reused by future placements via `.clone(true)`)
|
|
83
|
-
* and only its per-placement material clones (made so each placement's opacity is independent) are
|
|
84
|
-
* exclusively owned by the group.
|
|
85
|
-
*
|
|
86
|
-
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
87
|
-
*/
|
|
88
59
|
export function disposeMaterialsOnly(three, root) {
|
|
89
60
|
root.traverse((obj) => {
|
|
90
61
|
const mesh = obj;
|
|
@@ -96,14 +67,6 @@ export function disposeMaterialsOnly(three, root) {
|
|
|
96
67
|
}
|
|
97
68
|
});
|
|
98
69
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Fully disposes every mesh's geometry, material(s), and textures under `root`. Use this only for
|
|
101
|
-
* an object that exclusively owns its GPU resources — e.g. a loaded GLB template root being evicted
|
|
102
|
-
* from cache — never for a placement group whose geometries/textures came from a shared template
|
|
103
|
-
* (use {@link disposeMaterialsOnly} for that instead).
|
|
104
|
-
*
|
|
105
|
-
* @param three - The resolved Three.js module (from `loadThree()`).
|
|
106
|
-
*/
|
|
107
70
|
export function disposeObject3D(three, root) {
|
|
108
71
|
root.traverse((obj) => {
|
|
109
72
|
var _a;
|
|
@@ -117,4 +80,3 @@ export function disposeObject3D(three, root) {
|
|
|
117
80
|
}
|
|
118
81
|
});
|
|
119
82
|
}
|
|
120
|
-
//# sourceMappingURL=threeScene.js.map
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Load a CSS customization of a project.
|
|
3
|
-
*
|
|
4
|
-
* This function create a new HTML Style Element and add it to the current document.
|
|
5
|
-
* Also activate the customization adding the first theme name to the body of the document.
|
|
6
|
-
*
|
|
7
|
-
* @group Utils
|
|
8
|
-
* @param data The CSS customization data.
|
|
9
|
-
*/
|
|
10
1
|
export function loadCustomization(data) {
|
|
11
2
|
const style = document.createElement("style");
|
|
12
3
|
style.textContent = "";
|
|
@@ -20,14 +11,6 @@ export function loadCustomization(data) {
|
|
|
20
11
|
document.body.classList.add(firstThemeName);
|
|
21
12
|
}
|
|
22
13
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Process a theme.
|
|
25
|
-
*
|
|
26
|
-
* @group Utils
|
|
27
|
-
* @param themeName The name of the Theme.
|
|
28
|
-
* @param themeData The data of the Theme.
|
|
29
|
-
* @returns A string with the processed theme to use on a CSS file.
|
|
30
|
-
*/
|
|
31
14
|
function loadTheme(themeName, themeData) {
|
|
32
15
|
var _a;
|
|
33
16
|
let cssClass = `.${themeName} {\n`;
|
|
@@ -47,14 +30,6 @@ function loadTheme(themeName, themeData) {
|
|
|
47
30
|
cssClass += "}\n";
|
|
48
31
|
return cssClass;
|
|
49
32
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Process the definitions of a theme.
|
|
52
|
-
*
|
|
53
|
-
* @group Utils
|
|
54
|
-
* @param definitions The definitions of the theme.
|
|
55
|
-
* @param cssClass The string object that will contain the processed theme
|
|
56
|
-
* @returns The cssClass string mutated with the processed definitions.
|
|
57
|
-
*/
|
|
58
33
|
function loadDefinitions(definitions, cssClass) {
|
|
59
34
|
var _a, _b, _c;
|
|
60
35
|
for (const [colorName, colorData] of Object.entries((_a = definitions.colors) !== null && _a !== void 0 ? _a : {})) {
|
|
@@ -70,4 +45,3 @@ function loadDefinitions(definitions, cssClass) {
|
|
|
70
45
|
}
|
|
71
46
|
return cssClass;
|
|
72
47
|
}
|
|
73
|
-
//# sourceMappingURL=update-css.js.map
|
package/dist/es/utils/utils.d.ts
CHANGED
|
@@ -36,4 +36,3 @@ export declare function createPositionsForStops(totalStops: number): number[];
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function createStops(a: number[], b: string[]): Array<number | string>;
|
|
38
38
|
export declare function getBoundingBox(points: LatLng[]): [LatLng, LatLng];
|
|
39
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/es/utils/utils.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { MVXPlace } from "../domain/models/place";
|
|
2
|
-
/**
|
|
3
|
-
* this function generates a hexadecimal identifier
|
|
4
|
-
* @group Utils
|
|
5
|
-
* @returns {string} returns a hexadecimal identifier
|
|
6
|
-
*/
|
|
7
2
|
export function generateHexadecimalKey() {
|
|
8
3
|
let result = "";
|
|
9
4
|
const chars = "0123456789ABCDEF";
|
|
@@ -12,12 +7,6 @@ export function generateHexadecimalKey() {
|
|
|
12
7
|
}
|
|
13
8
|
return result;
|
|
14
9
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Format data into a usable type inside sdk
|
|
17
|
-
* @group Utils
|
|
18
|
-
* @param places array of raw MapVX places data
|
|
19
|
-
* @returns formatted data
|
|
20
|
-
*/
|
|
21
10
|
export function formatArrayPlaceData(places) {
|
|
22
11
|
const formattedData = [];
|
|
23
12
|
places.forEach((place) => {
|
|
@@ -25,20 +14,7 @@ export function formatArrayPlaceData(places) {
|
|
|
25
14
|
});
|
|
26
15
|
return formattedData;
|
|
27
16
|
}
|
|
28
|
-
/**
|
|
29
|
-
* Create positions for stops
|
|
30
|
-
* For example, if you have 3 stops, the positions will be [0, 0.5, 1]
|
|
31
|
-
* If you have 4 stops, the positions will be [0, 1/3, 2/3, 1]
|
|
32
|
-
* If you have 5 stops, the positions will be [0, 0.25, 0.5, 0.75, 1]
|
|
33
|
-
* If you have 1 stop, the positions will be [0]
|
|
34
|
-
* If you have 0 stops, the positions will be []
|
|
35
|
-
*
|
|
36
|
-
* @group Utils
|
|
37
|
-
* @param totalStops - The total number of stops
|
|
38
|
-
* @returns An array of numbers representing the positions for the stops
|
|
39
|
-
*/
|
|
40
17
|
export function createPositionsForStops(totalStops) {
|
|
41
|
-
// Handle edge cases
|
|
42
18
|
if (totalStops === 0) {
|
|
43
19
|
return [];
|
|
44
20
|
}
|
|
@@ -48,37 +24,9 @@ export function createPositionsForStops(totalStops) {
|
|
|
48
24
|
const step = 1 / (totalStops - 1);
|
|
49
25
|
return Array.from({ length: totalStops }, (_, i) => i * step);
|
|
50
26
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Create stops
|
|
53
|
-
* @group Utils
|
|
54
|
-
* @param a - The first array
|
|
55
|
-
* @param b - The second array
|
|
56
|
-
* @returns An array of numbers and strings
|
|
57
|
-
*/
|
|
58
27
|
export function createStops(a, b) {
|
|
59
28
|
return a.flatMap((item, index) => [item, b[index]]);
|
|
60
29
|
}
|
|
61
|
-
/* Calculates the bounding box for a set of points.
|
|
62
|
-
*
|
|
63
|
-
* This function takes an array of points represented as `LatLng` objects, each having `lat` and `lng` properties for
|
|
64
|
-
* latitude and longitude coordinates, respectively. It returns the bounding box that encompasses all the points in the array,
|
|
65
|
-
* extending one kilometer southwest and northeast to add a small margin around the area covered by the points.
|
|
66
|
-
*
|
|
67
|
-
* @group Utils
|
|
68
|
-
* @param points - An array of `LatLng` objects, each representing a geographic coordinate with latitude and longitude values.
|
|
69
|
-
* @returns An array of two elements containing the southwest and northeast coordinates, in that order, that defines the resulting bounding box.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```typescript
|
|
73
|
-
* const points: LatLng[] = [
|
|
74
|
-
* { lat: 10, lng: 20 },
|
|
75
|
-
* { lat: 15, lng: 25 },
|
|
76
|
-
* { lat: 12, lng: 22 },
|
|
77
|
-
* ];
|
|
78
|
-
* const boundingBox = getBoundingBox(points);
|
|
79
|
-
* // boundingBox is now [{ lat: 9.991, lng: 19.991 }, { lat: 15.009, lng: 25.009 }]
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
30
|
export function getBoundingBox(points) {
|
|
83
31
|
const northeast = { lat: -Infinity, lng: -Infinity };
|
|
84
32
|
const southwest = { lat: Infinity, lng: Infinity };
|
|
@@ -94,4 +42,3 @@ export function getBoundingBox(points) {
|
|
|
94
42
|
});
|
|
95
43
|
return [southwest, northeast];
|
|
96
44
|
}
|
|
97
|
-
//# sourceMappingURL=utils.js.map
|