@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.
- package/README.md +1 -0
- package/dist/core/index.cjs +97 -2
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +6 -1
- package/dist/core/index.d.ts +6 -1
- package/dist/core/index.js +97 -2
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +161 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +161 -38
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -25,6 +25,88 @@ __export(src_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(src_exports);
|
|
27
27
|
|
|
28
|
+
// ../seatmap-types/dist/index.js
|
|
29
|
+
var SECTION_CONTENTS_MODES = [
|
|
30
|
+
"always",
|
|
31
|
+
"seatsOnly",
|
|
32
|
+
"afterZoom"
|
|
33
|
+
];
|
|
34
|
+
function isSectionContentsMode(value) {
|
|
35
|
+
return SECTION_CONTENTS_MODES.some((mode) => mode === value);
|
|
36
|
+
}
|
|
37
|
+
var LEGEND_CONTENT_MODES = ["nameAndPrice", "name", "price"];
|
|
38
|
+
function isLegendContentMode(value) {
|
|
39
|
+
return LEGEND_CONTENT_MODES.some((mode) => mode === value);
|
|
40
|
+
}
|
|
41
|
+
function isSeatmapLegendConfig(value) {
|
|
42
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return Object.entries(value).every(([key, entry]) => {
|
|
46
|
+
switch (key) {
|
|
47
|
+
case "show":
|
|
48
|
+
case "initiallyCollapsed":
|
|
49
|
+
case "hideAccessibleSeatsFilter":
|
|
50
|
+
case "hideUnavailableItem":
|
|
51
|
+
case "hideNonSelectableCategories":
|
|
52
|
+
return entry === void 0 || typeof entry === "boolean";
|
|
53
|
+
case "content":
|
|
54
|
+
return entry === void 0 || isLegendContentMode(entry);
|
|
55
|
+
default:
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
var EVENT_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}(?:\.\d+)?))?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
61
|
+
function eventLocalMinutes(value) {
|
|
62
|
+
if (typeof value !== "string")
|
|
63
|
+
return void 0;
|
|
64
|
+
const match = EVENT_DATE_TIME.exec(value);
|
|
65
|
+
if (!match)
|
|
66
|
+
return void 0;
|
|
67
|
+
const [year, month, day, hours, minutes] = match.slice(1, 6).map(Number);
|
|
68
|
+
const seconds = Number(match[6] ?? 0);
|
|
69
|
+
const offsetHours = Number(match[7] ?? 0);
|
|
70
|
+
const offsetMinutes = Number(match[8] ?? 0);
|
|
71
|
+
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
72
|
+
const daysInMonth = month === 2 ? leap ? 29 : 28 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
73
|
+
if (month < 1 || month > 12 || day < 1 || day > daysInMonth || hours > 23 || minutes > 59 || seconds >= 60 || offsetHours > 23 || offsetMinutes > 59)
|
|
74
|
+
return void 0;
|
|
75
|
+
return hours * 60 + minutes + seconds / 60;
|
|
76
|
+
}
|
|
77
|
+
function lightingConfigError(options) {
|
|
78
|
+
if ((options.lighting === "dynamic" || options.eventDateTime !== void 0) && eventLocalMinutes(options.eventDateTime) === void 0)
|
|
79
|
+
return options.eventDateTime === void 0 ? "lighting 'dynamic' requires eventDateTime" : "eventDateTime must be an ISO 8601 date-time with an offset (Z or \xB1hh:mm)";
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
function isVenueDisplayOptions(value) {
|
|
83
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
84
|
+
return false;
|
|
85
|
+
const options = value;
|
|
86
|
+
if (options.displayMode !== void 0 || options.showDisplayModePicker !== void 0)
|
|
87
|
+
return false;
|
|
88
|
+
if (options.views !== void 0 && options.views !== "2d" && options.views !== "3d" && options.views !== "both")
|
|
89
|
+
return false;
|
|
90
|
+
if (options.lighting !== void 0 && options.lighting !== "designer" && options.lighting !== "dynamic" && options.lighting !== "day" && options.lighting !== "sunset" && options.lighting !== "night")
|
|
91
|
+
return false;
|
|
92
|
+
if (options.eventDateTime !== void 0 && typeof options.eventDateTime !== "string")
|
|
93
|
+
return false;
|
|
94
|
+
if (options.accessibilityControls !== void 0 && typeof options.accessibilityControls !== "boolean")
|
|
95
|
+
return false;
|
|
96
|
+
if (options.seatComparison !== void 0 && typeof options.seatComparison !== "boolean")
|
|
97
|
+
return false;
|
|
98
|
+
if (options.view3d !== void 0) {
|
|
99
|
+
if (typeof options.view3d !== "object" || options.view3d === null || Array.isArray(options.view3d))
|
|
100
|
+
return false;
|
|
101
|
+
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")))
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
function isSeatmapColorScheme(value) {
|
|
107
|
+
return value === "light" || value === "dark";
|
|
108
|
+
}
|
|
109
|
+
|
|
28
110
|
// ../seatmap-rpc/dist/envelope.js
|
|
29
111
|
var PROTOCOL_VERSION = 1;
|
|
30
112
|
var ENVELOPE_TYPES = [
|
|
@@ -236,41 +318,6 @@ function createWindowTransport({ target, targetOrigin, channelId }) {
|
|
|
236
318
|
};
|
|
237
319
|
}
|
|
238
320
|
|
|
239
|
-
// ../seatmap-types/dist/index.js
|
|
240
|
-
var SECTION_CONTENTS_MODES = [
|
|
241
|
-
"always",
|
|
242
|
-
"seatsOnly",
|
|
243
|
-
"afterZoom"
|
|
244
|
-
];
|
|
245
|
-
function isSectionContentsMode(value) {
|
|
246
|
-
return SECTION_CONTENTS_MODES.some((mode) => mode === value);
|
|
247
|
-
}
|
|
248
|
-
var LEGEND_CONTENT_MODES = ["nameAndPrice", "name", "price"];
|
|
249
|
-
function isLegendContentMode(value) {
|
|
250
|
-
return LEGEND_CONTENT_MODES.some((mode) => mode === value);
|
|
251
|
-
}
|
|
252
|
-
function isSeatmapLegendConfig(value) {
|
|
253
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
return Object.entries(value).every(([key, entry]) => {
|
|
257
|
-
switch (key) {
|
|
258
|
-
case "show":
|
|
259
|
-
case "hideAccessibleSeatsFilter":
|
|
260
|
-
case "hideUnavailableItem":
|
|
261
|
-
case "hideNonSelectableCategories":
|
|
262
|
-
return entry === void 0 || typeof entry === "boolean";
|
|
263
|
-
case "content":
|
|
264
|
-
return entry === void 0 || isLegendContentMode(entry);
|
|
265
|
-
default:
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
function isSeatmapColorScheme(value) {
|
|
271
|
-
return value === "light" || value === "dark";
|
|
272
|
-
}
|
|
273
|
-
|
|
274
321
|
// src/chartHandle.ts
|
|
275
322
|
function isRecord(value) {
|
|
276
323
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -540,10 +587,27 @@ function isEventPayload(event, payload) {
|
|
|
540
587
|
case "sectionFocused":
|
|
541
588
|
case "sectionUnfocused":
|
|
542
589
|
return isSectionFocusEventPayload(payload);
|
|
590
|
+
case "displayModeChanged":
|
|
591
|
+
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(
|
|
592
|
+
String(payload.reason)
|
|
593
|
+
);
|
|
543
594
|
case "floorChanged":
|
|
544
595
|
return isRecord(payload) && (payload.floor === null || isRecord(payload.floor) && isFloor(payload.floor));
|
|
545
596
|
case "seasonHoldChanged":
|
|
546
597
|
return isRecord(payload) && isSeasonHoldState(payload);
|
|
598
|
+
case "venue3dFallback":
|
|
599
|
+
return isRecord(payload) && [
|
|
600
|
+
"not-offered",
|
|
601
|
+
"webgl-unavailable",
|
|
602
|
+
"context-lost",
|
|
603
|
+
"renderer-failed",
|
|
604
|
+
"weak-device",
|
|
605
|
+
"previous-crash"
|
|
606
|
+
].includes(String(payload.reason)) && ["mobile", "tablet", "desktop", "unknown"].includes(
|
|
607
|
+
String(payload.deviceClass)
|
|
608
|
+
);
|
|
609
|
+
case "seatViewChanged":
|
|
610
|
+
return isRecord(payload) && (payload.object === null || isObjectRef(payload.object));
|
|
547
611
|
}
|
|
548
612
|
}
|
|
549
613
|
function copyFloorChanged(payload) {
|
|
@@ -569,6 +633,19 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
569
633
|
let destroyed = false;
|
|
570
634
|
let chartRenderedIdentity;
|
|
571
635
|
let currentSeasonHold = options?.initialSeasonHold;
|
|
636
|
+
let currentDisplayMode;
|
|
637
|
+
const unsubscribeDisplayModeChanged = endpoint.on(
|
|
638
|
+
"displayModeChanged",
|
|
639
|
+
(payload) => {
|
|
640
|
+
if (isEventPayload("displayModeChanged", payload))
|
|
641
|
+
currentDisplayMode = { ...payload };
|
|
642
|
+
}
|
|
643
|
+
);
|
|
644
|
+
let currentFallback;
|
|
645
|
+
const unsubscribeFallback = endpoint.on("venue3dFallback", (payload) => {
|
|
646
|
+
if (isEventPayload("venue3dFallback", payload))
|
|
647
|
+
currentFallback = { ...payload };
|
|
648
|
+
});
|
|
572
649
|
let currentFloor;
|
|
573
650
|
const unsubscribeFloorChanged = endpoint.on("floorChanged", (payload) => {
|
|
574
651
|
if (isEventPayload("floorChanged", payload))
|
|
@@ -807,6 +884,10 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
807
884
|
assertActive("resetView");
|
|
808
885
|
await requestVoid(endpoint, "resetView", {});
|
|
809
886
|
},
|
|
887
|
+
async setDisplayMode(mode) {
|
|
888
|
+
assertActive("setDisplayMode");
|
|
889
|
+
await requestVoid(endpoint, "setDisplayMode", { mode });
|
|
890
|
+
},
|
|
810
891
|
async changeConfig(config) {
|
|
811
892
|
assertActive("changeConfig");
|
|
812
893
|
await requestVoid(endpoint, "changeConfig", config);
|
|
@@ -817,6 +898,8 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
817
898
|
subscriptions.splice(0).forEach((subscription) => subscription.unsubscribe());
|
|
818
899
|
unsubscribeChartRendered();
|
|
819
900
|
unsubscribeFloorChanged();
|
|
901
|
+
unsubscribeDisplayModeChanged();
|
|
902
|
+
unsubscribeFallback();
|
|
820
903
|
unsubscribeSeasonHoldChanged();
|
|
821
904
|
endpoint.close();
|
|
822
905
|
removeIframe();
|
|
@@ -854,6 +937,20 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
854
937
|
unsubscribe();
|
|
855
938
|
}
|
|
856
939
|
});
|
|
940
|
+
if (event === "displayModeChanged" && currentDisplayMode !== void 0) {
|
|
941
|
+
const initialMode = { ...currentDisplayMode };
|
|
942
|
+
queueMicrotask(() => {
|
|
943
|
+
if (active && !liveEventSeen && isEventPayload(event, initialMode))
|
|
944
|
+
handler(initialMode);
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
if (event === "venue3dFallback" && currentFallback !== void 0) {
|
|
948
|
+
const initialFallback = { ...currentFallback };
|
|
949
|
+
queueMicrotask(() => {
|
|
950
|
+
if (active && !liveEventSeen && isEventPayload(event, initialFallback))
|
|
951
|
+
handler(initialFallback);
|
|
952
|
+
});
|
|
953
|
+
}
|
|
857
954
|
if (event === "floorChanged" && currentFloor !== void 0) {
|
|
858
955
|
const initialFloor = copyFloorChanged(currentFloor);
|
|
859
956
|
queueMicrotask(() => {
|
|
@@ -903,7 +1000,7 @@ function isCategoryFilter(value) {
|
|
|
903
1000
|
return value.nonMatchingObjects === "hidden" || value.nonMatchingObjects === "disabled";
|
|
904
1001
|
}
|
|
905
1002
|
function hasValidOptions(config) {
|
|
906
|
-
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));
|
|
1003
|
+
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));
|
|
907
1004
|
}
|
|
908
1005
|
function copyCategoryFilter(filter) {
|
|
909
1006
|
return {
|
|
@@ -945,6 +1042,15 @@ function classicHelloParams(config) {
|
|
|
945
1042
|
if (config.legend !== void 0) params.legend = { ...config.legend };
|
|
946
1043
|
if (config.showActiveBlockOnMobile !== void 0)
|
|
947
1044
|
params.showActiveBlockOnMobile = config.showActiveBlockOnMobile;
|
|
1045
|
+
if (config.views !== void 0) params.views = config.views;
|
|
1046
|
+
if (config.view3d !== void 0) params.view3d = { ...config.view3d };
|
|
1047
|
+
if (config.lighting !== void 0) params.lighting = config.lighting;
|
|
1048
|
+
if (config.eventDateTime !== void 0)
|
|
1049
|
+
params.eventDateTime = config.eventDateTime;
|
|
1050
|
+
if (config.accessibilityControls !== void 0)
|
|
1051
|
+
params.accessibilityControls = config.accessibilityControls;
|
|
1052
|
+
if (config.seatComparison !== void 0)
|
|
1053
|
+
params.seatComparison = config.seatComparison;
|
|
948
1054
|
return {
|
|
949
1055
|
...params,
|
|
950
1056
|
...config.onSeatSelectionChange ? { confirmSeatSelection: true } : {}
|
|
@@ -975,6 +1081,15 @@ function seasonHelloParams(config) {
|
|
|
975
1081
|
if (config.legend !== void 0) params.legend = { ...config.legend };
|
|
976
1082
|
if (config.showActiveBlockOnMobile !== void 0)
|
|
977
1083
|
params.showActiveBlockOnMobile = config.showActiveBlockOnMobile;
|
|
1084
|
+
if (config.views !== void 0) params.views = config.views;
|
|
1085
|
+
if (config.view3d !== void 0) params.view3d = { ...config.view3d };
|
|
1086
|
+
if (config.lighting !== void 0) params.lighting = config.lighting;
|
|
1087
|
+
if (config.eventDateTime !== void 0)
|
|
1088
|
+
params.eventDateTime = config.eventDateTime;
|
|
1089
|
+
if (config.accessibilityControls !== void 0)
|
|
1090
|
+
params.accessibilityControls = config.accessibilityControls;
|
|
1091
|
+
if (config.seatComparison !== void 0)
|
|
1092
|
+
params.seatComparison = config.seatComparison;
|
|
978
1093
|
return params;
|
|
979
1094
|
}
|
|
980
1095
|
function startSeatmapSession({
|
|
@@ -982,9 +1097,11 @@ function startSeatmapSession({
|
|
|
982
1097
|
channelId,
|
|
983
1098
|
config,
|
|
984
1099
|
onHandshake,
|
|
1100
|
+
onEngineStarted,
|
|
985
1101
|
onTerminate
|
|
986
1102
|
}) {
|
|
987
1103
|
const endpoint = createEndpoint({ transport, channelId });
|
|
1104
|
+
endpoint.on("engineStarted", onEngineStarted);
|
|
988
1105
|
const isSeasonMount = config.season !== void 0;
|
|
989
1106
|
if ("onSeatSelectionChange" in config && config.onSeatSelectionChange) {
|
|
990
1107
|
const confirm = config.onSeatSelectionChange;
|
|
@@ -1076,7 +1193,7 @@ function startSeatmapSession({
|
|
|
1076
1193
|
}
|
|
1077
1194
|
|
|
1078
1195
|
// src/engineUrl.ts
|
|
1079
|
-
var ENGINE_ARTIFACT = "
|
|
1196
|
+
var ENGINE_ARTIFACT = "e64ac40b6f53d76b";
|
|
1080
1197
|
var CDN_BASE = "https://dev-seatmap.knottech.ai";
|
|
1081
1198
|
function resolveEngineUrl({
|
|
1082
1199
|
artifact,
|
|
@@ -1122,6 +1239,9 @@ function mountSeatmap(container, config, signal) {
|
|
|
1122
1239
|
if (configError) {
|
|
1123
1240
|
return Promise.reject(configError);
|
|
1124
1241
|
}
|
|
1242
|
+
const lightingError = lightingConfigError(config);
|
|
1243
|
+
if (lightingError)
|
|
1244
|
+
return Promise.reject(new RpcError("INVALID_CONFIG", lightingError));
|
|
1125
1245
|
return new Promise((resolve, reject) => {
|
|
1126
1246
|
const artifact = ENGINE_ARTIFACT;
|
|
1127
1247
|
const engineUrl = resolveEngineUrl({ artifact, cdnBase: CDN_BASE });
|
|
@@ -1137,7 +1257,7 @@ function mountSeatmap(container, config, signal) {
|
|
|
1137
1257
|
fail(
|
|
1138
1258
|
new RpcError(
|
|
1139
1259
|
"HANDSHAKE_TIMEOUT",
|
|
1140
|
-
`Engine artifact ${artifact} did not
|
|
1260
|
+
`Engine artifact ${artifact} did not start`
|
|
1141
1261
|
)
|
|
1142
1262
|
);
|
|
1143
1263
|
}, HANDSHAKE_TIMEOUT_MS);
|
|
@@ -1199,6 +1319,9 @@ function mountSeatmap(container, config, signal) {
|
|
|
1199
1319
|
window.removeEventListener("message", receive);
|
|
1200
1320
|
};
|
|
1201
1321
|
},
|
|
1322
|
+
onEngineStarted: () => {
|
|
1323
|
+
window.clearTimeout(timer);
|
|
1324
|
+
},
|
|
1202
1325
|
onTerminate: () => {
|
|
1203
1326
|
iframe.remove();
|
|
1204
1327
|
}
|