@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.js
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
+
// ../seatmap-types/dist/index.js
|
|
2
|
+
var SECTION_CONTENTS_MODES = [
|
|
3
|
+
"always",
|
|
4
|
+
"seatsOnly",
|
|
5
|
+
"afterZoom"
|
|
6
|
+
];
|
|
7
|
+
function isSectionContentsMode(value) {
|
|
8
|
+
return SECTION_CONTENTS_MODES.some((mode) => mode === value);
|
|
9
|
+
}
|
|
10
|
+
var LEGEND_CONTENT_MODES = ["nameAndPrice", "name", "price"];
|
|
11
|
+
function isLegendContentMode(value) {
|
|
12
|
+
return LEGEND_CONTENT_MODES.some((mode) => mode === value);
|
|
13
|
+
}
|
|
14
|
+
function isSeatmapLegendConfig(value) {
|
|
15
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return Object.entries(value).every(([key, entry]) => {
|
|
19
|
+
switch (key) {
|
|
20
|
+
case "show":
|
|
21
|
+
case "initiallyCollapsed":
|
|
22
|
+
case "hideAccessibleSeatsFilter":
|
|
23
|
+
case "hideUnavailableItem":
|
|
24
|
+
case "hideNonSelectableCategories":
|
|
25
|
+
return entry === void 0 || typeof entry === "boolean";
|
|
26
|
+
case "content":
|
|
27
|
+
return entry === void 0 || isLegendContentMode(entry);
|
|
28
|
+
default:
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
var EVENT_DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2}(?:\.\d+)?))?(?:Z|[+-](\d{2}):(\d{2}))$/;
|
|
34
|
+
function eventLocalMinutes(value) {
|
|
35
|
+
if (typeof value !== "string")
|
|
36
|
+
return void 0;
|
|
37
|
+
const match = EVENT_DATE_TIME.exec(value);
|
|
38
|
+
if (!match)
|
|
39
|
+
return void 0;
|
|
40
|
+
const [year, month, day, hours, minutes] = match.slice(1, 6).map(Number);
|
|
41
|
+
const seconds = Number(match[6] ?? 0);
|
|
42
|
+
const offsetHours = Number(match[7] ?? 0);
|
|
43
|
+
const offsetMinutes = Number(match[8] ?? 0);
|
|
44
|
+
const leap = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
|
|
45
|
+
const daysInMonth = month === 2 ? leap ? 29 : 28 : [4, 6, 9, 11].includes(month) ? 30 : 31;
|
|
46
|
+
if (month < 1 || month > 12 || day < 1 || day > daysInMonth || hours > 23 || minutes > 59 || seconds >= 60 || offsetHours > 23 || offsetMinutes > 59)
|
|
47
|
+
return void 0;
|
|
48
|
+
return hours * 60 + minutes + seconds / 60;
|
|
49
|
+
}
|
|
50
|
+
function lightingConfigError(options) {
|
|
51
|
+
if ((options.lighting === "dynamic" || options.eventDateTime !== void 0) && eventLocalMinutes(options.eventDateTime) === void 0)
|
|
52
|
+
return options.eventDateTime === void 0 ? "lighting 'dynamic' requires eventDateTime" : "eventDateTime must be an ISO 8601 date-time with an offset (Z or \xB1hh:mm)";
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
function isVenueDisplayOptions(value) {
|
|
56
|
+
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
57
|
+
return false;
|
|
58
|
+
const options = value;
|
|
59
|
+
if (options.displayMode !== void 0 || options.showDisplayModePicker !== void 0)
|
|
60
|
+
return false;
|
|
61
|
+
if (options.views !== void 0 && options.views !== "2d" && options.views !== "3d" && options.views !== "both")
|
|
62
|
+
return false;
|
|
63
|
+
if (options.lighting !== void 0 && options.lighting !== "designer" && options.lighting !== "dynamic" && options.lighting !== "day" && options.lighting !== "sunset" && options.lighting !== "night")
|
|
64
|
+
return false;
|
|
65
|
+
if (options.eventDateTime !== void 0 && typeof options.eventDateTime !== "string")
|
|
66
|
+
return false;
|
|
67
|
+
if (options.accessibilityControls !== void 0 && typeof options.accessibilityControls !== "boolean")
|
|
68
|
+
return false;
|
|
69
|
+
if (options.seatComparison !== void 0 && typeof options.seatComparison !== "boolean")
|
|
70
|
+
return false;
|
|
71
|
+
if (options.view3d !== void 0) {
|
|
72
|
+
if (typeof options.view3d !== "object" || options.view3d === null || Array.isArray(options.view3d))
|
|
73
|
+
return false;
|
|
74
|
+
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")))
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
function isSeatmapColorScheme(value) {
|
|
80
|
+
return value === "light" || value === "dark";
|
|
81
|
+
}
|
|
82
|
+
|
|
1
83
|
// ../seatmap-rpc/dist/envelope.js
|
|
2
84
|
var PROTOCOL_VERSION = 1;
|
|
3
85
|
var ENVELOPE_TYPES = [
|
|
@@ -209,41 +291,6 @@ function createWindowTransport({ target, targetOrigin, channelId }) {
|
|
|
209
291
|
};
|
|
210
292
|
}
|
|
211
293
|
|
|
212
|
-
// ../seatmap-types/dist/index.js
|
|
213
|
-
var SECTION_CONTENTS_MODES = [
|
|
214
|
-
"always",
|
|
215
|
-
"seatsOnly",
|
|
216
|
-
"afterZoom"
|
|
217
|
-
];
|
|
218
|
-
function isSectionContentsMode(value) {
|
|
219
|
-
return SECTION_CONTENTS_MODES.some((mode) => mode === value);
|
|
220
|
-
}
|
|
221
|
-
var LEGEND_CONTENT_MODES = ["nameAndPrice", "name", "price"];
|
|
222
|
-
function isLegendContentMode(value) {
|
|
223
|
-
return LEGEND_CONTENT_MODES.some((mode) => mode === value);
|
|
224
|
-
}
|
|
225
|
-
function isSeatmapLegendConfig(value) {
|
|
226
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
return Object.entries(value).every(([key, entry]) => {
|
|
230
|
-
switch (key) {
|
|
231
|
-
case "show":
|
|
232
|
-
case "hideAccessibleSeatsFilter":
|
|
233
|
-
case "hideUnavailableItem":
|
|
234
|
-
case "hideNonSelectableCategories":
|
|
235
|
-
return entry === void 0 || typeof entry === "boolean";
|
|
236
|
-
case "content":
|
|
237
|
-
return entry === void 0 || isLegendContentMode(entry);
|
|
238
|
-
default:
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
function isSeatmapColorScheme(value) {
|
|
244
|
-
return value === "light" || value === "dark";
|
|
245
|
-
}
|
|
246
|
-
|
|
247
294
|
// src/chartHandle.ts
|
|
248
295
|
function isRecord(value) {
|
|
249
296
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -513,10 +560,27 @@ function isEventPayload(event, payload) {
|
|
|
513
560
|
case "sectionFocused":
|
|
514
561
|
case "sectionUnfocused":
|
|
515
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
|
+
);
|
|
516
567
|
case "floorChanged":
|
|
517
568
|
return isRecord(payload) && (payload.floor === null || isRecord(payload.floor) && isFloor(payload.floor));
|
|
518
569
|
case "seasonHoldChanged":
|
|
519
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));
|
|
520
584
|
}
|
|
521
585
|
}
|
|
522
586
|
function copyFloorChanged(payload) {
|
|
@@ -542,6 +606,19 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
542
606
|
let destroyed = false;
|
|
543
607
|
let chartRenderedIdentity;
|
|
544
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
|
+
});
|
|
545
622
|
let currentFloor;
|
|
546
623
|
const unsubscribeFloorChanged = endpoint.on("floorChanged", (payload) => {
|
|
547
624
|
if (isEventPayload("floorChanged", payload))
|
|
@@ -780,6 +857,10 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
780
857
|
assertActive("resetView");
|
|
781
858
|
await requestVoid(endpoint, "resetView", {});
|
|
782
859
|
},
|
|
860
|
+
async setDisplayMode(mode) {
|
|
861
|
+
assertActive("setDisplayMode");
|
|
862
|
+
await requestVoid(endpoint, "setDisplayMode", { mode });
|
|
863
|
+
},
|
|
783
864
|
async changeConfig(config) {
|
|
784
865
|
assertActive("changeConfig");
|
|
785
866
|
await requestVoid(endpoint, "changeConfig", config);
|
|
@@ -790,6 +871,8 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
790
871
|
subscriptions.splice(0).forEach((subscription) => subscription.unsubscribe());
|
|
791
872
|
unsubscribeChartRendered();
|
|
792
873
|
unsubscribeFloorChanged();
|
|
874
|
+
unsubscribeDisplayModeChanged();
|
|
875
|
+
unsubscribeFallback();
|
|
793
876
|
unsubscribeSeasonHoldChanged();
|
|
794
877
|
endpoint.close();
|
|
795
878
|
removeIframe();
|
|
@@ -827,6 +910,20 @@ function createChartHandle(endpoint, removeIframe, options) {
|
|
|
827
910
|
unsubscribe();
|
|
828
911
|
}
|
|
829
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
|
+
}
|
|
830
927
|
if (event === "floorChanged" && currentFloor !== void 0) {
|
|
831
928
|
const initialFloor = copyFloorChanged(currentFloor);
|
|
832
929
|
queueMicrotask(() => {
|
|
@@ -876,7 +973,7 @@ function isCategoryFilter(value) {
|
|
|
876
973
|
return value.nonMatchingObjects === "hidden" || value.nonMatchingObjects === "disabled";
|
|
877
974
|
}
|
|
878
975
|
function hasValidOptions(config) {
|
|
879
|
-
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));
|
|
880
977
|
}
|
|
881
978
|
function copyCategoryFilter(filter) {
|
|
882
979
|
return {
|
|
@@ -918,6 +1015,15 @@ function classicHelloParams(config) {
|
|
|
918
1015
|
if (config.legend !== void 0) params.legend = { ...config.legend };
|
|
919
1016
|
if (config.showActiveBlockOnMobile !== void 0)
|
|
920
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;
|
|
921
1027
|
return {
|
|
922
1028
|
...params,
|
|
923
1029
|
...config.onSeatSelectionChange ? { confirmSeatSelection: true } : {}
|
|
@@ -948,6 +1054,15 @@ function seasonHelloParams(config) {
|
|
|
948
1054
|
if (config.legend !== void 0) params.legend = { ...config.legend };
|
|
949
1055
|
if (config.showActiveBlockOnMobile !== void 0)
|
|
950
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;
|
|
951
1066
|
return params;
|
|
952
1067
|
}
|
|
953
1068
|
function startSeatmapSession({
|
|
@@ -955,9 +1070,11 @@ function startSeatmapSession({
|
|
|
955
1070
|
channelId,
|
|
956
1071
|
config,
|
|
957
1072
|
onHandshake,
|
|
1073
|
+
onEngineStarted,
|
|
958
1074
|
onTerminate
|
|
959
1075
|
}) {
|
|
960
1076
|
const endpoint = createEndpoint({ transport, channelId });
|
|
1077
|
+
endpoint.on("engineStarted", onEngineStarted);
|
|
961
1078
|
const isSeasonMount = config.season !== void 0;
|
|
962
1079
|
if ("onSeatSelectionChange" in config && config.onSeatSelectionChange) {
|
|
963
1080
|
const confirm = config.onSeatSelectionChange;
|
|
@@ -1049,7 +1166,7 @@ function startSeatmapSession({
|
|
|
1049
1166
|
}
|
|
1050
1167
|
|
|
1051
1168
|
// src/engineUrl.ts
|
|
1052
|
-
var ENGINE_ARTIFACT = "
|
|
1169
|
+
var ENGINE_ARTIFACT = "e64ac40b6f53d76b";
|
|
1053
1170
|
var CDN_BASE = "https://dev-seatmap.knottech.ai";
|
|
1054
1171
|
function resolveEngineUrl({
|
|
1055
1172
|
artifact,
|
|
@@ -1095,6 +1212,9 @@ function mountSeatmap(container, config, signal) {
|
|
|
1095
1212
|
if (configError) {
|
|
1096
1213
|
return Promise.reject(configError);
|
|
1097
1214
|
}
|
|
1215
|
+
const lightingError = lightingConfigError(config);
|
|
1216
|
+
if (lightingError)
|
|
1217
|
+
return Promise.reject(new RpcError("INVALID_CONFIG", lightingError));
|
|
1098
1218
|
return new Promise((resolve, reject) => {
|
|
1099
1219
|
const artifact = ENGINE_ARTIFACT;
|
|
1100
1220
|
const engineUrl = resolveEngineUrl({ artifact, cdnBase: CDN_BASE });
|
|
@@ -1110,7 +1230,7 @@ function mountSeatmap(container, config, signal) {
|
|
|
1110
1230
|
fail(
|
|
1111
1231
|
new RpcError(
|
|
1112
1232
|
"HANDSHAKE_TIMEOUT",
|
|
1113
|
-
`Engine artifact ${artifact} did not
|
|
1233
|
+
`Engine artifact ${artifact} did not start`
|
|
1114
1234
|
)
|
|
1115
1235
|
);
|
|
1116
1236
|
}, HANDSHAKE_TIMEOUT_MS);
|
|
@@ -1172,6 +1292,9 @@ function mountSeatmap(container, config, signal) {
|
|
|
1172
1292
|
window.removeEventListener("message", receive);
|
|
1173
1293
|
};
|
|
1174
1294
|
},
|
|
1295
|
+
onEngineStarted: () => {
|
|
1296
|
+
window.clearTimeout(timer);
|
|
1297
|
+
},
|
|
1175
1298
|
onTerminate: () => {
|
|
1176
1299
|
iframe.remove();
|
|
1177
1300
|
}
|