@mapvx/web-js 4.0.2 → 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/README.md +7 -7
- 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 +12 -6
- 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,134 +1,34 @@
|
|
|
1
1
|
import { getVersion, getWorkerUrl, setWorkerUrl } from "maplibre-gl";
|
|
2
2
|
import { MAPLIBRE_WORKER_SOURCE, MAPLIBRE_WORKER_VERSION } from "./generated/maplibreWorkerSource";
|
|
3
|
-
/**
|
|
4
|
-
* The blob URL this SDK created, or `null` while nothing has been installed yet. Kept so the
|
|
5
|
-
* install is idempotent and so we can tell our own URL from one a consumer supplied.
|
|
6
|
-
*/
|
|
7
3
|
let installedWorkerUrl = null;
|
|
8
|
-
/**
|
|
9
|
-
* Registers a self-contained MapLibre worker carried inside this bundle.
|
|
10
|
-
*
|
|
11
|
-
* MapLibre 6 no longer inlines its worker. It resolves it at runtime with
|
|
12
|
-
* `new URL('./maplibre-gl-worker.mjs', import.meta.url)`, building the filename by concatenation
|
|
13
|
-
* so no bundler can see it statically and none emit the file. Once a consumer bundles this SDK,
|
|
14
|
-
* `import.meta.url` is the consumer's own chunk, the worker is requested from a path where nothing
|
|
15
|
-
* exists — in a single-page app the request falls through to the app shell and the worker dies on
|
|
16
|
-
* a `text/html` MIME error — and the map renders nothing at all. Handing MapLibre a `blob:` URL
|
|
17
|
-
* removes that resolution from the picture entirely, so this holds regardless of the consumer's
|
|
18
|
-
* bundler, base href, or whether the app is served from a subpath.
|
|
19
|
-
*
|
|
20
|
-
* Must run before anything touches MapLibre's global worker pool, which is earlier than it looks.
|
|
21
|
-
* The pool is created by the first `Dispatcher` and the URL is read then, once, and not again
|
|
22
|
-
* while a map is alive — so any MapLibre call that builds a Dispatcher ahead of this one wins
|
|
23
|
-
* permanently. `new Map(...)` is the obvious one, but `prewarm()`, `importScriptInWorkers()` and
|
|
24
|
-
* the now-removed `setRTLTextPlugin()` all do it too. Hence the very top of the map constructor,
|
|
25
|
-
* rather than next to the map.
|
|
26
|
-
*
|
|
27
|
-
* Never called at module load: that would run `new Blob` and `URL.createObjectURL` during import,
|
|
28
|
-
* which fails under SSR and in jsdom, and would hand MapLibre a worker URL for applications that
|
|
29
|
-
* import this package without ever creating a map. It does not save memory — the worker string is
|
|
30
|
-
* resident from the moment this module is imported either way.
|
|
31
|
-
*
|
|
32
|
-
* A consumer that installed its own worker URL is self-hosting on purpose — a strict
|
|
33
|
-
* Content-Security-Policy without `worker-src blob:`, typically — and is left alone.
|
|
34
|
-
*
|
|
35
|
-
* Under such a policy with no URL set, the failure is silent from the application's side, and
|
|
36
|
-
* measured rather than assumed: `createObjectURL` does not throw, `new Worker` does not throw
|
|
37
|
-
* synchronously, and MapLibre fires no `error` event. The only signal is the browser's own
|
|
38
|
-
* console message, *"Creating a worker from 'blob:…' violates the following Content Security
|
|
39
|
-
* Policy directive"*, next to a map that never loads. That string is repeated here so searching
|
|
40
|
-
* for it lands on this explanation and on `setMapLibreWorkerUrl`.
|
|
41
|
-
*
|
|
42
|
-
* @see setMapLibreWorkerUrl for the supported way to opt out.
|
|
43
|
-
* @group Configuration
|
|
44
|
-
*/
|
|
45
4
|
export function installMapLibreWorker() {
|
|
46
5
|
if (installedWorkerUrl !== null)
|
|
47
6
|
return;
|
|
48
|
-
// `WORKER_URL` defaults to "", so a truthy value can only mean a consumer set one.
|
|
49
7
|
if (getWorkerUrl())
|
|
50
8
|
return;
|
|
51
9
|
const runtimeVersion = getVersion();
|
|
52
10
|
if (runtimeVersion !== MAPLIBRE_WORKER_VERSION) {
|
|
53
|
-
// The bundled worker and the running MapLibre talk an internal, unversioned protocol. A skew
|
|
54
|
-
// is only possible if the consumer forced a different maplibre-gl than this SDK pinned; it is
|
|
55
|
-
// still better to install a slightly mismatched worker than to leave the map with none, so
|
|
56
|
-
// this warns rather than bails.
|
|
57
11
|
console.warn(`[MapVX] MapLibre version mismatch: the bundled worker is ${MAPLIBRE_WORKER_VERSION} but ` +
|
|
58
12
|
`maplibre-gl ${runtimeVersion} is running. Install maplibre-gl@${MAPLIBRE_WORKER_VERSION} ` +
|
|
59
13
|
`or call setMapLibreWorkerUrl() with a self-hosted worker of the matching version.`);
|
|
60
14
|
}
|
|
61
15
|
try {
|
|
62
16
|
const blob = new Blob([MAPLIBRE_WORKER_SOURCE], { type: "text/javascript" });
|
|
63
|
-
// Deliberately never revoked. MapLibre terminates its worker pool when the last map is
|
|
64
|
-
// removed and reads this URL again when the next map is created, so revoking would break
|
|
65
|
-
// every map after the first.
|
|
66
17
|
installedWorkerUrl = URL.createObjectURL(blob);
|
|
67
18
|
setWorkerUrl(installedWorkerUrl);
|
|
68
19
|
}
|
|
69
20
|
catch (error) {
|
|
70
|
-
// Blob/createObjectURL are absent under SSR and in some test environments. Leaving MapLibre's
|
|
71
|
-
// own resolution in place is the best remaining option: it works when the SDK is served
|
|
72
|
-
// unbundled, which is exactly the situation where this path is reachable.
|
|
73
21
|
installedWorkerUrl = null;
|
|
74
22
|
console.warn("[MapVX] Could not install the bundled MapLibre worker:", error);
|
|
75
23
|
}
|
|
76
24
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Points MapLibre at a worker script you host yourself, instead of the one bundled into this SDK.
|
|
79
|
-
*
|
|
80
|
-
* The bundled worker is delivered as a `blob:` URL, which a Content-Security-Policy without
|
|
81
|
-
* `worker-src blob:` (or `child-src blob:`) will block. Self-hosting is the way out: copy
|
|
82
|
-
* `maplibre-gl-worker.mjs` **and** `maplibre-gl-shared.mjs` from `maplibre-gl/dist` — the worker
|
|
83
|
-
* imports the shared file at runtime, so both must be served from the same directory — and point
|
|
84
|
-
* this at the first one. Use `npm ls maplibre-gl` to see which version this SDK resolved; the
|
|
85
|
-
* files must come from that one.
|
|
86
|
-
*
|
|
87
|
-
* **The URL has to be same-origin.** A cross-origin one does not escape `blob:`: MapLibre wraps
|
|
88
|
-
* any worker URL it considers cross-origin in a generated `blob:` worker that imports it, so a
|
|
89
|
-
* CDN-hosted worker hits exactly the same Content-Security-Policy wall as the bundled one.
|
|
90
|
-
*
|
|
91
|
-
* Call it before creating any map. Once MapLibre's worker pool has spun up it does not re-read the
|
|
92
|
-
* URL until every map has been removed.
|
|
93
|
-
*
|
|
94
|
-
* Exists so opting out does not force a direct `maplibre-gl` dependency on consumers that only
|
|
95
|
-
* use this SDK.
|
|
96
|
-
*
|
|
97
|
-
* @param url - URL of the MapLibre worker script to load.
|
|
98
|
-
* @example
|
|
99
|
-
* ```ts
|
|
100
|
-
* import { setMapLibreWorkerUrl, initializeSDK } from "@mapvx/web-js"
|
|
101
|
-
*
|
|
102
|
-
* setMapLibreWorkerUrl("/assets/maplibre-gl-worker.mjs")
|
|
103
|
-
* const sdk = initializeSDK(token)
|
|
104
|
-
* ```
|
|
105
|
-
* @group Configuration
|
|
106
|
-
*/
|
|
107
25
|
export function setMapLibreWorkerUrl(url) {
|
|
108
26
|
setWorkerUrl(url);
|
|
109
|
-
// Stop claiming ownership: the URL in play is now the consumer's, and ours (if any) must not be
|
|
110
|
-
// revoked while a worker pool may still be using it.
|
|
111
27
|
installedWorkerUrl = null;
|
|
112
28
|
}
|
|
113
|
-
/**
|
|
114
|
-
* The worker URL MapLibre will use, or `""` when none has been set yet.
|
|
115
|
-
*
|
|
116
|
-
* Returns a `blob:` URL once the bundled worker has been installed, which happens when the first
|
|
117
|
-
* map is created. Useful to assert in tests that the bundled worker is in play.
|
|
118
|
-
*
|
|
119
|
-
* @returns The current MapLibre worker URL.
|
|
120
|
-
* @group Configuration
|
|
121
|
-
*/
|
|
122
29
|
export function getMapLibreWorkerUrl() {
|
|
123
30
|
return getWorkerUrl();
|
|
124
31
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Resets the module-level install state. Test seam only — the blob URL is intentionally never
|
|
127
|
-
* revoked in production, so there is nothing to clean up outside tests.
|
|
128
|
-
*
|
|
129
|
-
* @internal
|
|
130
|
-
*/
|
|
131
32
|
export function resetMapLibreWorkerInstallForTests() {
|
|
132
33
|
installedWorkerUrl = null;
|
|
133
34
|
}
|
|
134
|
-
//# sourceMappingURL=installMapLibreWorker.js.map
|
|
@@ -1,63 +1,8 @@
|
|
|
1
1
|
const DEG_TO_RAD = Math.PI / 180;
|
|
2
|
-
/**
|
|
3
|
-
* A {@link FitTransform} backed by a live MapLibre map and its public API.
|
|
4
|
-
*
|
|
5
|
-
* ## Why this exists
|
|
6
|
-
*
|
|
7
|
-
* {@link refineCameraForPitch} needs to project points through MapLibre's real perspective
|
|
8
|
-
* projection for camera states the map is not actually in — it tries a candidate camera, measures
|
|
9
|
-
* where the geometry lands, adjusts, and repeats. Until MapLibre v6 that was done on
|
|
10
|
-
* `map.transform.clone()`, a detached copy of the internal transform.
|
|
11
|
-
*
|
|
12
|
-
* v6 removed `map.transform` and exposes no replacement: there is no exported `Camera`,
|
|
13
|
-
* `Transform` or `MercatorTransform`, and the migration guide says only "use `Map`'s public API
|
|
14
|
-
* instead". So the simulation moves onto the map itself.
|
|
15
|
-
*
|
|
16
|
-
* ## How it stays invisible
|
|
17
|
-
*
|
|
18
|
-
* The map is genuinely moved, but never painted mid-simulation: MapLibre renders on
|
|
19
|
-
* `requestAnimationFrame`, and every mutation here happens inside one synchronous block that ends
|
|
20
|
-
* with {@link restore}. No intermediate frame exists to be seen.
|
|
21
|
-
*
|
|
22
|
-
* Camera writes are also batched. Setters only record intent; the map is moved at most once per
|
|
23
|
-
* refinement iteration, lazily, the first time a projection actually needs the new camera.
|
|
24
|
-
*
|
|
25
|
-
* ## What it costs
|
|
26
|
-
*
|
|
27
|
-
* `jumpTo` fires camera events, so listeners observe movement that no user caused. At the only
|
|
28
|
-
* call site this is bounded — the refinement is immediately followed by a real `easeTo`, so the
|
|
29
|
-
* map was going to move regardless, and the `moveend` handler that reports completion is attached
|
|
30
|
-
* *after* refinement and so cannot see the simulation's events.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* const transform = new LiveMapFitTransform(map)
|
|
35
|
-
* try {
|
|
36
|
-
* camera = refineCameraForPitch(transform, coordinates, camera, params)
|
|
37
|
-
* } finally {
|
|
38
|
-
* transform.restore()
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @group Map
|
|
43
|
-
*/
|
|
44
2
|
export class LiveMapFitTransform {
|
|
45
|
-
/**
|
|
46
|
-
* Capture the map's current camera so it can be restored, and seed the simulation with it.
|
|
47
|
-
*
|
|
48
|
-
* @param map The live map to simulate on.
|
|
49
|
-
*/
|
|
50
3
|
constructor(map) {
|
|
51
4
|
var _a, _b, _c, _d;
|
|
52
|
-
/** Whether {@link pending} has diverged from what the map is currently showing. */
|
|
53
5
|
this.dirty = false;
|
|
54
|
-
/**
|
|
55
|
-
* Whether the map was ever actually moved.
|
|
56
|
-
*
|
|
57
|
-
* Tracked separately from {@link dirty}, which {@link sync} clears the moment it flushes: keying
|
|
58
|
-
* {@link restore} off `dirty` alone would make it a no-op right after a flush and strand the map
|
|
59
|
-
* on a candidate camera.
|
|
60
|
-
*/
|
|
61
6
|
this.moved = false;
|
|
62
7
|
this.setCenter = (center) => {
|
|
63
8
|
this.pending.center = center;
|
|
@@ -87,27 +32,9 @@ export class LiveMapFitTransform {
|
|
|
87
32
|
this.sync();
|
|
88
33
|
return this.map.unproject(p);
|
|
89
34
|
};
|
|
90
|
-
/**
|
|
91
|
-
* Whether a screen point lies on the visible map surface rather than beyond the horizon.
|
|
92
|
-
*
|
|
93
|
-
* MapLibre exposes no public horizon test, so this derives the horizon line from the camera.
|
|
94
|
-
* With `d` the camera-to-centre distance, the ground plane's vanishing line sits
|
|
95
|
-
* `d / tan(pitch)` pixels above the centre of the viewport, and `d` itself follows from the
|
|
96
|
-
* vertical field of view: `d = (height / 2) / tan(fov / 2)`.
|
|
97
|
-
*
|
|
98
|
-
* A round-trip through `unproject`/`project` looks like the obvious test and does not work: the
|
|
99
|
-
* projection matrix is self-consistent on both sides of the horizon, so a sky point round-trips
|
|
100
|
-
* to within 1e-8 px just as a ground point does. Measured in
|
|
101
|
-
* `example/build-test/test-v6-render.html`, which also confirms this formula brackets the
|
|
102
|
-
* horizon where `unproject` actually flips to the far side of the camera.
|
|
103
|
-
*
|
|
104
|
-
* @param p Screen point, as returned by {@link locationToScreenPoint}.
|
|
105
|
-
* @returns `true` when the point is on the map surface.
|
|
106
|
-
*/
|
|
107
35
|
this.isPointOnMapSurface = (p) => {
|
|
108
36
|
this.sync();
|
|
109
37
|
const pitchRad = this.map.getPitch() * DEG_TO_RAD;
|
|
110
|
-
// Looking straight down there is no horizon: the whole viewport is ground.
|
|
111
38
|
if (pitchRad <= 0) {
|
|
112
39
|
return true;
|
|
113
40
|
}
|
|
@@ -117,18 +44,11 @@ export class LiveMapFitTransform {
|
|
|
117
44
|
}
|
|
118
45
|
const fovRad = this.map.getVerticalFieldOfView() * DEG_TO_RAD;
|
|
119
46
|
const cameraToCentreDistance = height / 2 / Math.tan(fovRad / 2);
|
|
120
|
-
// Padding moves the projection centre, and with it the horizon.
|
|
121
47
|
const { top, bottom } = this.pending.padding;
|
|
122
48
|
const centreY = height / 2 + (top - bottom) / 2;
|
|
123
49
|
const horizonY = centreY - cameraToCentreDistance / Math.tan(pitchRad);
|
|
124
50
|
return p.y > horizonY;
|
|
125
51
|
};
|
|
126
|
-
/**
|
|
127
|
-
* Put the camera back exactly as it was when this instance was constructed.
|
|
128
|
-
*
|
|
129
|
-
* Safe to call more than once, and safe to call when nothing was ever changed. Always call it
|
|
130
|
-
* from a `finally` block so a throw mid-refinement cannot strand the map on a candidate camera.
|
|
131
|
-
*/
|
|
132
52
|
this.restore = () => {
|
|
133
53
|
if (!this.moved) {
|
|
134
54
|
return;
|
|
@@ -166,7 +86,6 @@ export class LiveMapFitTransform {
|
|
|
166
86
|
get zoom() {
|
|
167
87
|
return this.pending.zoom;
|
|
168
88
|
}
|
|
169
|
-
/** Flush {@link pending} onto the map, but only when a projection actually needs it. */
|
|
170
89
|
sync() {
|
|
171
90
|
if (!this.dirty) {
|
|
172
91
|
return;
|
|
@@ -182,4 +101,3 @@ export class LiveMapFitTransform {
|
|
|
182
101
|
this.moved = true;
|
|
183
102
|
}
|
|
184
103
|
}
|
|
185
|
-
//# sourceMappingURL=liveMapFitTransform.js.map
|
package/dist/es/map/map.d.ts
CHANGED