@knot-technologies/seatmap 0.4.0-dev.11 → 0.4.0-dev.13

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.
@@ -10,12 +10,17 @@ interface SeatmapSessionOptions {
10
10
  config: SeatmapMountConfig;
11
11
  /** Raw handshake data from the engine, already filtered to its exact origin. */
12
12
  onHandshake(listener: (data: unknown) => void): () => void;
13
+ /**
14
+ * The engine accepted the hello and mounted its widget. `ready` settles
15
+ * later, once the map has loaded.
16
+ */
17
+ onEngineStarted(): void;
13
18
  onTerminate(): void;
14
19
  }
15
20
  interface SeatmapSession {
16
21
  ready: Promise<SeatmapChart>;
17
22
  close(): void;
18
23
  }
19
- declare function startSeatmapSession({ transport, channelId, config, onHandshake, onTerminate, }: SeatmapSessionOptions): SeatmapSession;
24
+ declare function startSeatmapSession({ transport, channelId, config, onHandshake, onEngineStarted, onTerminate, }: SeatmapSessionOptions): SeatmapSession;
20
25
 
21
26
  export { type SeatmapSession, type SeatmapSessionOptions, startSeatmapSession, validateMountConfig };
@@ -10,12 +10,17 @@ interface SeatmapSessionOptions {
10
10
  config: SeatmapMountConfig;
11
11
  /** Raw handshake data from the engine, already filtered to its exact origin. */
12
12
  onHandshake(listener: (data: unknown) => void): () => void;
13
+ /**
14
+ * The engine accepted the hello and mounted its widget. `ready` settles
15
+ * later, once the map has loaded.
16
+ */
17
+ onEngineStarted(): void;
13
18
  onTerminate(): void;
14
19
  }
15
20
  interface SeatmapSession {
16
21
  ready: Promise<SeatmapChart>;
17
22
  close(): void;
18
23
  }
19
- declare function startSeatmapSession({ transport, channelId, config, onHandshake, onTerminate, }: SeatmapSessionOptions): SeatmapSession;
24
+ declare function startSeatmapSession({ transport, channelId, config, onHandshake, onEngineStarted, onTerminate, }: SeatmapSessionOptions): SeatmapSession;
20
25
 
21
26
  export { type SeatmapSession, type SeatmapSessionOptions, startSeatmapSession, validateMountConfig };
@@ -18,6 +18,7 @@ function isSeatmapLegendConfig(value) {
18
18
  return Object.entries(value).every(([key, entry]) => {
19
19
  switch (key) {
20
20
  case "show":
21
+ case "initiallyCollapsed":
21
22
  case "hideAccessibleSeatsFilter":
22
23
  case "hideUnavailableItem":
23
24
  case "hideNonSelectableCategories":
@@ -29,6 +30,30 @@ function isSeatmapLegendConfig(value) {
29
30
  }
30
31
  });
31
32
  }
33
+ function isVenueDisplayOptions(value) {
34
+ if (typeof value !== "object" || value === null || Array.isArray(value))
35
+ return false;
36
+ const options = value;
37
+ if (options.displayMode !== void 0 || options.showDisplayModePicker !== void 0)
38
+ return false;
39
+ if (options.views !== void 0 && options.views !== "2d" && options.views !== "3d" && options.views !== "both")
40
+ return false;
41
+ if (options.lighting !== void 0 && options.lighting !== "designer" && options.lighting !== "dynamic" && options.lighting !== "day" && options.lighting !== "sunset" && options.lighting !== "night")
42
+ return false;
43
+ if (options.eventDateTime !== void 0 && typeof options.eventDateTime !== "string")
44
+ return false;
45
+ if (options.accessibilityControls !== void 0 && typeof options.accessibilityControls !== "boolean")
46
+ return false;
47
+ if (options.seatComparison !== void 0 && typeof options.seatComparison !== "boolean")
48
+ return false;
49
+ if (options.view3d !== void 0) {
50
+ if (typeof options.view3d !== "object" || options.view3d === null || Array.isArray(options.view3d))
51
+ return false;
52
+ if (!Object.entries(options.view3d).every(([key, entry]) => key === "quality" ? entry === void 0 || entry === "auto" || entry === "reduced" : (key === "seatView" || key === "confirmSelection") && (entry === void 0 || typeof entry === "boolean")))
53
+ return false;
54
+ }
55
+ return true;
56
+ }
32
57
  function isSeatmapColorScheme(value) {
33
58
  return value === "light" || value === "dark";
34
59
  }
@@ -535,10 +560,27 @@ function isEventPayload(event, payload) {
535
560
  case "sectionFocused":
536
561
  case "sectionUnfocused":
537
562
  return isSectionFocusEventPayload(payload);
563
+ case "displayModeChanged":
564
+ return isRecord(payload) && (payload.mode === "2d" || payload.mode === "overview" || payload.mode === "3d") && (payload.requestedMode === "auto" || payload.requestedMode === "2d" || payload.requestedMode === "overview" || payload.requestedMode === "3d") && ["user", "config", "sdk", "unavailable", "renderer-failure"].includes(
565
+ String(payload.reason)
566
+ );
538
567
  case "floorChanged":
539
568
  return isRecord(payload) && (payload.floor === null || isRecord(payload.floor) && isFloor(payload.floor));
540
569
  case "seasonHoldChanged":
541
570
  return isRecord(payload) && isSeasonHoldState(payload);
571
+ case "venue3dFallback":
572
+ return isRecord(payload) && [
573
+ "not-offered",
574
+ "webgl-unavailable",
575
+ "context-lost",
576
+ "renderer-failed",
577
+ "weak-device",
578
+ "previous-crash"
579
+ ].includes(String(payload.reason)) && ["mobile", "tablet", "desktop", "unknown"].includes(
580
+ String(payload.deviceClass)
581
+ );
582
+ case "seatViewChanged":
583
+ return isRecord(payload) && (payload.object === null || isObjectRef(payload.object));
542
584
  }
543
585
  }
544
586
  function copyFloorChanged(payload) {
@@ -564,6 +606,19 @@ function createChartHandle(endpoint, removeIframe, options) {
564
606
  let destroyed = false;
565
607
  let chartRenderedIdentity;
566
608
  let currentSeasonHold = options?.initialSeasonHold;
609
+ let currentDisplayMode;
610
+ const unsubscribeDisplayModeChanged = endpoint.on(
611
+ "displayModeChanged",
612
+ (payload) => {
613
+ if (isEventPayload("displayModeChanged", payload))
614
+ currentDisplayMode = { ...payload };
615
+ }
616
+ );
617
+ let currentFallback;
618
+ const unsubscribeFallback = endpoint.on("venue3dFallback", (payload) => {
619
+ if (isEventPayload("venue3dFallback", payload))
620
+ currentFallback = { ...payload };
621
+ });
567
622
  let currentFloor;
568
623
  const unsubscribeFloorChanged = endpoint.on("floorChanged", (payload) => {
569
624
  if (isEventPayload("floorChanged", payload))
@@ -802,6 +857,10 @@ function createChartHandle(endpoint, removeIframe, options) {
802
857
  assertActive("resetView");
803
858
  await requestVoid(endpoint, "resetView", {});
804
859
  },
860
+ async setDisplayMode(mode) {
861
+ assertActive("setDisplayMode");
862
+ await requestVoid(endpoint, "setDisplayMode", { mode });
863
+ },
805
864
  async changeConfig(config) {
806
865
  assertActive("changeConfig");
807
866
  await requestVoid(endpoint, "changeConfig", config);
@@ -812,6 +871,8 @@ function createChartHandle(endpoint, removeIframe, options) {
812
871
  subscriptions.splice(0).forEach((subscription) => subscription.unsubscribe());
813
872
  unsubscribeChartRendered();
814
873
  unsubscribeFloorChanged();
874
+ unsubscribeDisplayModeChanged();
875
+ unsubscribeFallback();
815
876
  unsubscribeSeasonHoldChanged();
816
877
  endpoint.close();
817
878
  removeIframe();
@@ -849,6 +910,20 @@ function createChartHandle(endpoint, removeIframe, options) {
849
910
  unsubscribe();
850
911
  }
851
912
  });
913
+ if (event === "displayModeChanged" && currentDisplayMode !== void 0) {
914
+ const initialMode = { ...currentDisplayMode };
915
+ queueMicrotask(() => {
916
+ if (active && !liveEventSeen && isEventPayload(event, initialMode))
917
+ handler(initialMode);
918
+ });
919
+ }
920
+ if (event === "venue3dFallback" && currentFallback !== void 0) {
921
+ const initialFallback = { ...currentFallback };
922
+ queueMicrotask(() => {
923
+ if (active && !liveEventSeen && isEventPayload(event, initialFallback))
924
+ handler(initialFallback);
925
+ });
926
+ }
852
927
  if (event === "floorChanged" && currentFloor !== void 0) {
853
928
  const initialFloor = copyFloorChanged(currentFloor);
854
929
  queueMicrotask(() => {
@@ -898,7 +973,7 @@ function isCategoryFilter(value) {
898
973
  return value.nonMatchingObjects === "hidden" || value.nonMatchingObjects === "disabled";
899
974
  }
900
975
  function hasValidOptions(config) {
901
- return (config.colorScheme === void 0 || isSeatmapColorScheme(config.colorScheme)) && (config.sectionContents === void 0 || isSectionContentsMode(config.sectionContents)) && (config.categoryFilter === void 0 || isCategoryFilter(config.categoryFilter)) && (config.startFloor === void 0 || typeof config.startFloor === "string") && (config.lockedFloor === void 0 || typeof config.lockedFloor === "string") && (config.scrollZoom === void 0 || typeof config.scrollZoom === "boolean") && (config.showFloorPicker === void 0 || typeof config.showFloorPicker === "boolean") && (config.showActiveBlockOnMobile === void 0 || typeof config.showActiveBlockOnMobile === "boolean") && (config.legend === void 0 || isSeatmapLegendConfig(config.legend));
976
+ return isVenueDisplayOptions(config) && (config.colorScheme === void 0 || isSeatmapColorScheme(config.colorScheme)) && (config.sectionContents === void 0 || isSectionContentsMode(config.sectionContents)) && (config.categoryFilter === void 0 || isCategoryFilter(config.categoryFilter)) && (config.startFloor === void 0 || typeof config.startFloor === "string") && (config.lockedFloor === void 0 || typeof config.lockedFloor === "string") && (config.scrollZoom === void 0 || typeof config.scrollZoom === "boolean") && (config.showFloorPicker === void 0 || typeof config.showFloorPicker === "boolean") && (config.showActiveBlockOnMobile === void 0 || typeof config.showActiveBlockOnMobile === "boolean") && (config.legend === void 0 || isSeatmapLegendConfig(config.legend));
902
977
  }
903
978
  function copyCategoryFilter(filter) {
904
979
  return {
@@ -940,6 +1015,15 @@ function classicHelloParams(config) {
940
1015
  if (config.legend !== void 0) params.legend = { ...config.legend };
941
1016
  if (config.showActiveBlockOnMobile !== void 0)
942
1017
  params.showActiveBlockOnMobile = config.showActiveBlockOnMobile;
1018
+ if (config.views !== void 0) params.views = config.views;
1019
+ if (config.view3d !== void 0) params.view3d = { ...config.view3d };
1020
+ if (config.lighting !== void 0) params.lighting = config.lighting;
1021
+ if (config.eventDateTime !== void 0)
1022
+ params.eventDateTime = config.eventDateTime;
1023
+ if (config.accessibilityControls !== void 0)
1024
+ params.accessibilityControls = config.accessibilityControls;
1025
+ if (config.seatComparison !== void 0)
1026
+ params.seatComparison = config.seatComparison;
943
1027
  return {
944
1028
  ...params,
945
1029
  ...config.onSeatSelectionChange ? { confirmSeatSelection: true } : {}
@@ -970,6 +1054,15 @@ function seasonHelloParams(config) {
970
1054
  if (config.legend !== void 0) params.legend = { ...config.legend };
971
1055
  if (config.showActiveBlockOnMobile !== void 0)
972
1056
  params.showActiveBlockOnMobile = config.showActiveBlockOnMobile;
1057
+ if (config.views !== void 0) params.views = config.views;
1058
+ if (config.view3d !== void 0) params.view3d = { ...config.view3d };
1059
+ if (config.lighting !== void 0) params.lighting = config.lighting;
1060
+ if (config.eventDateTime !== void 0)
1061
+ params.eventDateTime = config.eventDateTime;
1062
+ if (config.accessibilityControls !== void 0)
1063
+ params.accessibilityControls = config.accessibilityControls;
1064
+ if (config.seatComparison !== void 0)
1065
+ params.seatComparison = config.seatComparison;
973
1066
  return params;
974
1067
  }
975
1068
  function startSeatmapSession({
@@ -977,9 +1070,11 @@ function startSeatmapSession({
977
1070
  channelId,
978
1071
  config,
979
1072
  onHandshake,
1073
+ onEngineStarted,
980
1074
  onTerminate
981
1075
  }) {
982
1076
  const endpoint = createEndpoint({ transport, channelId });
1077
+ endpoint.on("engineStarted", onEngineStarted);
983
1078
  const isSeasonMount = config.season !== void 0;
984
1079
  if ("onSeatSelectionChange" in config && config.onSeatSelectionChange) {
985
1080
  const confirm = config.onSeatSelectionChange;
@@ -1071,7 +1166,7 @@ function startSeatmapSession({
1071
1166
  }
1072
1167
 
1073
1168
  // src/engineUrl.ts
1074
- var ENGINE_ARTIFACT = "3055fcaa6d7f2600";
1169
+ var ENGINE_ARTIFACT = "e64ac40b6f53d76b";
1075
1170
  var CDN_BASE = "https://dev-seatmap.knottech.ai";
1076
1171
  function resolveEngineUrl({
1077
1172
  artifact,