@mapvx/web-components 0.0.25 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +16 -3
  2. package/dist/cjs/{base-floor-selector-C1G5K9Er.cjs → base-floor-selector-CLFTtgbp.cjs} +2 -2
  3. package/dist/cjs/{class-map-BQQ7MXll.cjs → class-map-BTH_74Qs.cjs} +2 -2
  4. package/dist/cjs/{compact-floor-selector-DsMWGOFg.cjs → compact-floor-selector-CUgAJzTC.cjs} +2 -2
  5. package/dist/cjs/{consume-DRj4CYCX.cjs → consume-DvEpk7ME.cjs} +2 -2
  6. package/dist/cjs/custom-map-BT2xrMK_.cjs +97 -0
  7. package/dist/cjs/{floor-selector-CDmDuSiD.cjs → floor-selector-_ZGeTisd.cjs} +2 -2
  8. package/dist/cjs/{lazy-load-Dn0YjnPb.cjs → lazy-load-C0UlvHkw.cjs} +2 -2
  9. package/dist/cjs/map-view-with-modal.cjs +6 -6
  10. package/dist/cjs/{qr-modal-DViSVtZI.cjs → qr-modal-dwEr6sDk.cjs} +2 -2
  11. package/dist/cjs/{route-options-CyEO6vv_.cjs → route-options-5hZvnUEf.cjs} +2 -2
  12. package/dist/cjs/route-view-totems.cjs +3 -3
  13. package/dist/es/assets/{compact-floor-selector-CoQYAD6z.js → compact-floor-selector-oq3Ovsm1.js} +3 -3
  14. package/dist/es/assets/{components-BQGHQSdV.js → components-BT9NDTry.js} +53 -14
  15. package/dist/es/assets/{map-view-with-modal-SkmapEWH.js → map-view-with-modal-DiR8q30Q.js} +46 -4
  16. package/dist/es/assets/{route-view-totems-eQTxU-id.js → route-view-totems-CdM6PRGO.js} +57 -9
  17. package/dist/es/assets/{utils-CWtvoL4a.js → utils-DM-AJZn2.js} +136 -28
  18. package/dist/es/index.js +2 -2
  19. package/dist/es/route-view-totems.js +2 -2
  20. package/dist/iife/map-view-with-modal.js +2 -2
  21. package/dist/iife/route-view-totems.js +4 -4
  22. package/dist/sw/mvx-tiles-sw.js +63 -0
  23. package/package.json +3 -2
  24. package/dist/cjs/custom-map-DDdkf9Am.cjs +0 -97
  25. package/dist/components/custom-map.d.ts +0 -13
  26. package/dist/components/custom-map.js +0 -64
  27. package/dist/components/floor-selector.d.ts +0 -6
  28. package/dist/components/floor-selector.js +0 -40
  29. package/dist/components/qr-modal.d.ts +0 -7
  30. package/dist/components/qr-modal.js +0 -69
  31. package/dist/components/route-options.d.ts +0 -6
  32. package/dist/components/route-options.js +0 -51
  33. package/dist/components/zoom-controls.d.ts +0 -6
  34. package/dist/components/zoom-controls.js +0 -40
  35. package/dist/route-view-totems.d.ts +0 -16
  36. package/dist/route-view-totems.js +0 -58
  37. package/dist/utils/styles.d.ts +0 -2
  38. package/dist/utils/styles.js +0 -5
@@ -1,5 +1,5 @@
1
- import { i, s as sdkContext } from './components-BQGHQSdV.js';
2
- import { R as RollbarController } from './route-view-totems-eQTxU-id.js';
1
+ import { i, s as sdkContext } from './components-BT9NDTry.js';
2
+ import { R as RollbarController } from './route-view-totems-CdM6PRGO.js';
3
3
 
4
4
  var dist = {exports: {}};
5
5
 
@@ -12356,8 +12356,75 @@ class SDKController {
12356
12356
  initialValue: { enabledFloors: [], markers: [], cameraInitialized: false }
12357
12357
  });
12358
12358
  }
12359
+ /**
12360
+ * Prewarm SDK and fetch critical data in parallel to reduce first render time.
12361
+ * If origin/destination are provided, their details will also be prefetched and markers/floor set accordingly.
12362
+ */
12363
+ async prewarm(apiKey, locale, parentPlaceId, options) {
12364
+ if (!this.connected) return;
12365
+ const sdk = distExports.initializeSDK(apiKey, { lang: locale });
12366
+ this.contextProvider.setValue({
12367
+ ...this.contextProvider.value,
12368
+ sdk,
12369
+ locale,
12370
+ parentPlaceId,
12371
+ originId: options?.originId ?? this.contextProvider.value.originId,
12372
+ destinationId: options?.destinationId ?? this.contextProvider.value.destinationId
12373
+ });
12374
+ try {
12375
+ const [config, parentPlace, origin, destination] = await Promise.all([
12376
+ sdk.getConfiguration(parentPlaceId).catch(() => void 0),
12377
+ sdk.getPlaceDetail(parentPlaceId).catch(() => void 0),
12378
+ options?.originId ? sdk.getPlaceDetail(options.originId).catch(() => void 0) : Promise.resolve(void 0),
12379
+ options?.destinationId ? sdk.getPlaceDetail(options.destinationId).catch(() => void 0) : Promise.resolve(void 0)
12380
+ ]);
12381
+ const parentFloors = parentPlace?.innerFloors || [];
12382
+ let enabledFloors = parentFloors;
12383
+ let currentFloor = void 0;
12384
+ if (origin || destination) {
12385
+ const floors = [origin, destination].map((place) => place?.inFloor(parentFloors)).filter((floor) => floor !== void 0);
12386
+ if (floors.length > 0) {
12387
+ enabledFloors = floors;
12388
+ }
12389
+ currentFloor = destination?.inFloors?.[0] ? parentFloors.find((f) => f.key === destination.inFloors[0]) : origin?.inFloors?.[0] ? parentFloors.find((f) => f.key === origin.inFloors[0]) : void 0;
12390
+ }
12391
+ this.enabledFloors = enabledFloors;
12392
+ this.contextProvider.setValue({
12393
+ ...this.contextProvider.value,
12394
+ generalConfig: config ?? this.contextProvider.value.generalConfig,
12395
+ parentPlace: parentPlace ?? this.contextProvider.value.parentPlace,
12396
+ origin: origin ?? this.contextProvider.value.origin,
12397
+ destination: destination ?? this.contextProvider.value.destination,
12398
+ enabledFloors,
12399
+ currentFloor: currentFloor ?? this.contextProvider.value.currentFloor,
12400
+ // Pre-create markers if we have origin/destination
12401
+ markers: [
12402
+ ...origin ? [
12403
+ {
12404
+ id: origin.lazarilloId,
12405
+ data: origin,
12406
+ style: MarkerStyle.youAreHere
12407
+ }
12408
+ ] : [],
12409
+ ...destination ? [
12410
+ {
12411
+ id: destination.lazarilloId,
12412
+ data: destination,
12413
+ style: MarkerStyle.placePopup
12414
+ }
12415
+ ] : []
12416
+ ]
12417
+ });
12418
+ } catch (error) {
12419
+ RollbarController.getInstance().warning("Error prewarming SDK", { error, parentPlaceId });
12420
+ }
12421
+ }
12359
12422
  initialize(apiKey, locale, parentPlaceId) {
12360
12423
  if (!this.connected) return;
12424
+ const current = this.contextProvider.value;
12425
+ if (current.sdk && current.locale === locale && current.parentPlaceId === parentPlaceId) {
12426
+ return;
12427
+ }
12361
12428
  this.initializeSDK(apiKey, locale, parentPlaceId);
12362
12429
  const { originId, destinationId } = this.contextProvider.value;
12363
12430
  if (originId && destinationId) {
@@ -12390,9 +12457,9 @@ class SDKController {
12390
12457
  destination
12391
12458
  });
12392
12459
  this.createOriginDestinationMarkers(origin, destination);
12393
- const currentFloor = destination ? destination.inFloors?.[0] : origin ? origin.inFloors?.[0] : void 0;
12394
- if (currentFloor) {
12395
- this.setFloor(currentFloor);
12460
+ const currentFloorId = destination?.inFloors?.[0] || origin?.inFloors?.[0];
12461
+ if (currentFloorId) {
12462
+ this.setFloor(currentFloorId);
12396
12463
  }
12397
12464
  const parentFloors = this.contextProvider.value.parentPlace?.innerFloors || [];
12398
12465
  const enabledFloors = [origin, destination].filter((p) => !!p).map((place) => place.inFloor(parentFloors)).filter((floor) => floor !== void 0);
@@ -12463,14 +12530,12 @@ class SDKController {
12463
12530
  parentPlaceId
12464
12531
  });
12465
12532
  try {
12466
- await this.loadConfig(parentPlaceId);
12467
- } catch (error) {
12468
- RollbarController.getInstance().warning("Error loading config", { error, parentPlaceId });
12469
- }
12470
- try {
12471
- const parentPlace = await sdk.getPlaceDetail(parentPlaceId);
12533
+ const [config, parentPlace] = await Promise.all([
12534
+ sdk.getConfiguration(parentPlaceId).catch(() => void 0),
12535
+ sdk.getPlaceDetail(parentPlaceId).catch(() => void 0)
12536
+ ]);
12472
12537
  const { origin, destination } = this.contextProvider.value;
12473
- let enabledFloors = parentPlace.innerFloors || [];
12538
+ let enabledFloors = parentPlace?.innerFloors || [];
12474
12539
  const currentFloor = origin?.inFloor(enabledFloors) || destination?.inFloor(enabledFloors);
12475
12540
  if (origin || destination) {
12476
12541
  enabledFloors = [origin, destination].map((place) => place?.inFloor(enabledFloors)).filter((floor) => floor !== void 0);
@@ -12478,7 +12543,8 @@ class SDKController {
12478
12543
  }
12479
12544
  this.contextProvider.setValue({
12480
12545
  ...this.contextProvider.value,
12481
- parentPlace,
12546
+ generalConfig: config ?? this.contextProvider.value.generalConfig,
12547
+ parentPlace: parentPlace ?? this.contextProvider.value.parentPlace,
12482
12548
  enabledFloors,
12483
12549
  currentFloor
12484
12550
  });
@@ -12648,9 +12714,11 @@ class MarkerController {
12648
12714
  setParentPlace(place) {
12649
12715
  this.parentPlace = place;
12650
12716
  }
12717
+ setConfig(config) {
12718
+ this.config = config;
12719
+ }
12651
12720
  updateMarkers(markers) {
12652
12721
  if (!this.connected || !this.map || !this.mapReady || !this.parentPlace) return;
12653
- const floors = this.parentPlace.innerFloors ?? [];
12654
12722
  this.markersIds.forEach((m) => {
12655
12723
  try {
12656
12724
  this.map?.removeMarker(m.id);
@@ -12667,7 +12735,7 @@ class MarkerController {
12667
12735
  case MarkerStyle.youAreHere: {
12668
12736
  const markerIcon = document.createElement("img");
12669
12737
  const place = data;
12670
- floorId = place.inFloor(floors)?.key;
12738
+ floorId = place.inFloors?.[0];
12671
12739
  markerIcon.src = this.accessibleRoute ? accessibleMarker : walkingMarker;
12672
12740
  markerElement = markerIcon;
12673
12741
  coordinate = place.position;
@@ -12721,8 +12789,9 @@ class MarkerController {
12721
12789
  content.category = "";
12722
12790
  }
12723
12791
  content.position = data.position;
12724
- floorId = data.inFloor(floors)?.key;
12792
+ content.floorId = data.inFloors?.[0];
12725
12793
  }
12794
+ floorId = content.floorId;
12726
12795
  markerElement = PopupFactory.create({
12727
12796
  name: content.name,
12728
12797
  category: content.category,
@@ -12754,16 +12823,33 @@ class MarkerController {
12754
12823
  );
12755
12824
  const currentFloor = this.map?.getCurrentFloor();
12756
12825
  const coordinates = this.markersIds.filter((m) => m.floorId === currentFloor).map((m) => m.coordinate);
12757
- if (coordinates.length > 0) {
12826
+ if (coordinates.length === 1) {
12827
+ setTimeout(() => {
12828
+ this.map?.updateCamera({
12829
+ center: coordinates[0],
12830
+ bearing: this.config?.mapRotations?.[this.parentPlace?.lazarilloId ?? ""]?.angle ?? 0,
12831
+ pitch: this.config?.pitch ?? 0,
12832
+ zoom: this.config?.initialZoom ?? 18,
12833
+ animate: true
12834
+ });
12835
+ }, 200);
12836
+ } else if (coordinates.length > 0) {
12758
12837
  setTimeout(() => {
12759
12838
  this.map?.fitCoordinates(coordinates, {
12760
12839
  padding: {
12761
- top: 350,
12762
- bottom: 50,
12763
- left: 50,
12764
- right: 100
12840
+ top: 200,
12841
+ bottom: 200,
12842
+ left: 200,
12843
+ right: 200
12765
12844
  }
12766
12845
  });
12846
+ this.map?.updateCamera({
12847
+ bearing: this.config?.mapRotations?.[this.parentPlace?.lazarilloId ?? ""]?.angle ?? 0,
12848
+ pitch: this.config?.pitch ?? 0,
12849
+ // @ts-expect-error TODO: need sdk to get zoom
12850
+ zoom: Math.min(this.config?.initialZoom ?? 18, this.map?.map.getZoom() ?? 18),
12851
+ animate: true
12852
+ });
12767
12853
  }, 200);
12768
12854
  }
12769
12855
  }
@@ -12808,10 +12894,30 @@ class RouteAnimationController {
12808
12894
  if (coordinates.length > 0) {
12809
12895
  this.lzMap?.fitCoordinates(coordinates, {
12810
12896
  padding: {
12811
- bottom: 150,
12812
- left: 150,
12813
- right: 150,
12814
- top: 150
12897
+ bottom: 250,
12898
+ left: 250,
12899
+ right: 250,
12900
+ top: 250
12901
+ }
12902
+ });
12903
+ const routeSteps = [
12904
+ {
12905
+ floorId: this.route?.legs?.at(0)?.steps?.at(0)?.startInsideFloor,
12906
+ coordinates: this.route?.legs?.at(0)?.steps?.at(0)?.startLocation
12907
+ },
12908
+ {
12909
+ floorId: this.route?.legs?.at(-1)?.steps?.at(-1)?.endInsideFloor,
12910
+ coordinates: this.route?.legs?.at(-1)?.steps?.at(-1)?.endLocation
12911
+ }
12912
+ ];
12913
+ routeSteps.forEach((step) => {
12914
+ if (floorId === step.floorId && step.coordinates) {
12915
+ this.lzMap?.updateCamera({
12916
+ animate: false,
12917
+ center: step.coordinates,
12918
+ // @ts-expect-error TODO: need sdk to get zoom
12919
+ zoom: Math.min(this.lzMap?.map.getZoom() ?? 18, this.config?.initialZoom ?? 18)
12920
+ });
12815
12921
  }
12816
12922
  });
12817
12923
  }
@@ -12823,14 +12929,17 @@ class RouteAnimationController {
12823
12929
  setLocale(locale) {
12824
12930
  this.locale = locale;
12825
12931
  }
12932
+ setConfig(config) {
12933
+ this.config = config;
12934
+ }
12826
12935
  startRouteAnimation(route) {
12827
12936
  if (!this.connected || !this.lzMap || this.isAnimatingRoute) return;
12828
12937
  this.isAnimatingRoute = true;
12829
12938
  this.stepAnimationDate = /* @__PURE__ */ new Date();
12939
+ this.route = route;
12830
12940
  const animationConfig = {
12831
12941
  minimumSpeed: 20,
12832
12942
  callBack: (status) => {
12833
- this.stepAnimationDate = /* @__PURE__ */ new Date();
12834
12943
  if (status.isFinished) {
12835
12944
  this.stopAnimatedRoute();
12836
12945
  this.handlers.onRouteAnimationFinished();
@@ -12886,7 +12995,6 @@ class RouteAnimationController {
12886
12995
  this.setCurrentFloor(firstFloor);
12887
12996
  }
12888
12997
  this.lzMap.startAnimateRouteV2(route, drawingConfig, animationConfig);
12889
- this.route = route;
12890
12998
  this.handlers.onStartRouteAnimation();
12891
12999
  }
12892
13000
  removeRoute() {
@@ -12950,4 +13058,4 @@ class RouteAnimationController {
12950
13058
  }
12951
13059
 
12952
13060
  export { MarkerController as M, RouteAnimationController as R, SDKController as S };
12953
- //# sourceMappingURL=utils-CWtvoL4a.js.map
13061
+ //# sourceMappingURL=utils-DM-AJZn2.js.map
package/dist/es/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { c as RouteViewTotems } from './assets/route-view-totems-eQTxU-id.js';
2
- export { M as MapViewWithModal } from './assets/map-view-with-modal-SkmapEWH.js';
1
+ export { c as RouteViewTotems } from './assets/route-view-totems-CdM6PRGO.js';
2
+ export { M as MapViewWithModal } from './assets/map-view-with-modal-DiR8q30Q.js';
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- export { c as RouteViewTotems } from './assets/route-view-totems-eQTxU-id.js';
2
- import './assets/utils-CWtvoL4a.js';
1
+ export { c as RouteViewTotems } from './assets/route-view-totems-CdM6PRGO.js';
2
+ import './assets/utils-DM-AJZn2.js';
3
3
  //# sourceMappingURL=route-view-totems.js.map