@modelnex/sdk 0.5.50 → 0.5.51
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/dist/index.js +11 -7
- package/dist/index.mjs +11 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3881,16 +3881,17 @@ function compactTourForTransport(tour) {
|
|
|
3881
3881
|
|
|
3882
3882
|
// src/utils/tourSessionPersistence.ts
|
|
3883
3883
|
var ACTIVE_TOUR_SESSION_STORAGE_KEY = "modelnex-active-tour-session";
|
|
3884
|
-
var ACTIVE_TOUR_SESSION_VERSION =
|
|
3884
|
+
var ACTIVE_TOUR_SESSION_VERSION = 2;
|
|
3885
3885
|
var ACTIVE_TOUR_SESSION_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
3886
3886
|
function canUseSessionStorage2() {
|
|
3887
3887
|
return typeof window !== "undefined" && typeof window.sessionStorage !== "undefined";
|
|
3888
3888
|
}
|
|
3889
|
-
function persistActiveTourSession(runId) {
|
|
3889
|
+
function persistActiveTourSession(runId, experienceType) {
|
|
3890
3890
|
if (!canUseSessionStorage2() || !Number.isFinite(runId)) return;
|
|
3891
3891
|
const session = {
|
|
3892
3892
|
version: ACTIVE_TOUR_SESSION_VERSION,
|
|
3893
3893
|
runId,
|
|
3894
|
+
experienceType,
|
|
3894
3895
|
savedAt: Date.now()
|
|
3895
3896
|
};
|
|
3896
3897
|
try {
|
|
@@ -3911,7 +3912,7 @@ function readPersistedActiveTourSession() {
|
|
|
3911
3912
|
const raw = window.sessionStorage.getItem(ACTIVE_TOUR_SESSION_STORAGE_KEY);
|
|
3912
3913
|
if (!raw) return null;
|
|
3913
3914
|
const parsed = JSON.parse(raw);
|
|
3914
|
-
const isValid = parsed && parsed.version === ACTIVE_TOUR_SESSION_VERSION && typeof parsed.runId === "number" && Number.isFinite(parsed.runId) && typeof parsed.savedAt === "number" && Number.isFinite(parsed.savedAt);
|
|
3915
|
+
const isValid = parsed && parsed.version === ACTIVE_TOUR_SESSION_VERSION && typeof parsed.runId === "number" && Number.isFinite(parsed.runId) && typeof parsed.experienceType === "string" && typeof parsed.savedAt === "number" && Number.isFinite(parsed.savedAt);
|
|
3915
3916
|
if (!isValid) {
|
|
3916
3917
|
clearPersistedActiveTourSession();
|
|
3917
3918
|
return null;
|
|
@@ -4543,7 +4544,9 @@ function useTourPlayback({
|
|
|
4543
4544
|
const pendingTourOptionsRef = (0, import_react12.useRef)(null);
|
|
4544
4545
|
const showCaptionsRef = (0, import_react12.useRef)(showCaptions);
|
|
4545
4546
|
const initialPersistedTourSessionRef = (0, import_react12.useRef)(readPersistedActiveTourSession());
|
|
4546
|
-
const runIdRef = (0, import_react12.useRef)(
|
|
4547
|
+
const runIdRef = (0, import_react12.useRef)(
|
|
4548
|
+
initialPersistedTourSessionRef.current?.experienceType === experienceType ? initialPersistedTourSessionRef.current.runId : null
|
|
4549
|
+
);
|
|
4547
4550
|
const turnIdRef = (0, import_react12.useRef)(null);
|
|
4548
4551
|
const startRequestedRef = (0, import_react12.useRef)(false);
|
|
4549
4552
|
const serverStateRef = (0, import_react12.useRef)(null);
|
|
@@ -4574,7 +4577,8 @@ function useTourPlayback({
|
|
|
4574
4577
|
claimedPlaybackOwnerKeyRef.current = null;
|
|
4575
4578
|
}, []);
|
|
4576
4579
|
const emitTourInit = (0, import_react12.useCallback)((socket, currentWebsiteId, profile) => {
|
|
4577
|
-
const
|
|
4580
|
+
const persistedSession = readPersistedActiveTourSession();
|
|
4581
|
+
const persistedRunId = runIdRef.current ?? (persistedSession?.experienceType === experienceTypeRef.current ? persistedSession.runId : null);
|
|
4578
4582
|
const payload = {};
|
|
4579
4583
|
if (currentWebsiteId) {
|
|
4580
4584
|
payload.websiteId = currentWebsiteId;
|
|
@@ -4615,7 +4619,7 @@ function useTourPlayback({
|
|
|
4615
4619
|
turnIdRef.current = payload.turnId ?? null;
|
|
4616
4620
|
}
|
|
4617
4621
|
if (payload?.isActive && typeof payload?.runId === "number") {
|
|
4618
|
-
persistActiveTourSession(payload.runId);
|
|
4622
|
+
persistActiveTourSession(payload.runId, experienceTypeRef.current);
|
|
4619
4623
|
} else if (payload?.isActive === false) {
|
|
4620
4624
|
clearPersistedActiveTourSession();
|
|
4621
4625
|
}
|
|
@@ -5250,7 +5254,7 @@ function useTourPlayback({
|
|
|
5250
5254
|
if (isActiveRef.current) return;
|
|
5251
5255
|
runIdRef.current = typeof tourData.runId === "number" ? tourData.runId : runIdRef.current;
|
|
5252
5256
|
if (typeof runIdRef.current === "number") {
|
|
5253
|
-
persistActiveTourSession(runIdRef.current);
|
|
5257
|
+
persistActiveTourSession(runIdRef.current, experienceTypeRef.current);
|
|
5254
5258
|
}
|
|
5255
5259
|
const tour = tourData.tourContext ?? tourRef.current;
|
|
5256
5260
|
const expType = experienceTypeRef.current;
|
package/dist/index.mjs
CHANGED
|
@@ -3056,16 +3056,17 @@ function compactTourForTransport(tour) {
|
|
|
3056
3056
|
|
|
3057
3057
|
// src/utils/tourSessionPersistence.ts
|
|
3058
3058
|
var ACTIVE_TOUR_SESSION_STORAGE_KEY = "modelnex-active-tour-session";
|
|
3059
|
-
var ACTIVE_TOUR_SESSION_VERSION =
|
|
3059
|
+
var ACTIVE_TOUR_SESSION_VERSION = 2;
|
|
3060
3060
|
var ACTIVE_TOUR_SESSION_MAX_AGE_MS = 10 * 60 * 1e3;
|
|
3061
3061
|
function canUseSessionStorage2() {
|
|
3062
3062
|
return typeof window !== "undefined" && typeof window.sessionStorage !== "undefined";
|
|
3063
3063
|
}
|
|
3064
|
-
function persistActiveTourSession(runId) {
|
|
3064
|
+
function persistActiveTourSession(runId, experienceType) {
|
|
3065
3065
|
if (!canUseSessionStorage2() || !Number.isFinite(runId)) return;
|
|
3066
3066
|
const session = {
|
|
3067
3067
|
version: ACTIVE_TOUR_SESSION_VERSION,
|
|
3068
3068
|
runId,
|
|
3069
|
+
experienceType,
|
|
3069
3070
|
savedAt: Date.now()
|
|
3070
3071
|
};
|
|
3071
3072
|
try {
|
|
@@ -3086,7 +3087,7 @@ function readPersistedActiveTourSession() {
|
|
|
3086
3087
|
const raw = window.sessionStorage.getItem(ACTIVE_TOUR_SESSION_STORAGE_KEY);
|
|
3087
3088
|
if (!raw) return null;
|
|
3088
3089
|
const parsed = JSON.parse(raw);
|
|
3089
|
-
const isValid = parsed && parsed.version === ACTIVE_TOUR_SESSION_VERSION && typeof parsed.runId === "number" && Number.isFinite(parsed.runId) && typeof parsed.savedAt === "number" && Number.isFinite(parsed.savedAt);
|
|
3090
|
+
const isValid = parsed && parsed.version === ACTIVE_TOUR_SESSION_VERSION && typeof parsed.runId === "number" && Number.isFinite(parsed.runId) && typeof parsed.experienceType === "string" && typeof parsed.savedAt === "number" && Number.isFinite(parsed.savedAt);
|
|
3090
3091
|
if (!isValid) {
|
|
3091
3092
|
clearPersistedActiveTourSession();
|
|
3092
3093
|
return null;
|
|
@@ -3714,7 +3715,9 @@ function useTourPlayback({
|
|
|
3714
3715
|
const pendingTourOptionsRef = useRef7(null);
|
|
3715
3716
|
const showCaptionsRef = useRef7(showCaptions);
|
|
3716
3717
|
const initialPersistedTourSessionRef = useRef7(readPersistedActiveTourSession());
|
|
3717
|
-
const runIdRef = useRef7(
|
|
3718
|
+
const runIdRef = useRef7(
|
|
3719
|
+
initialPersistedTourSessionRef.current?.experienceType === experienceType ? initialPersistedTourSessionRef.current.runId : null
|
|
3720
|
+
);
|
|
3718
3721
|
const turnIdRef = useRef7(null);
|
|
3719
3722
|
const startRequestedRef = useRef7(false);
|
|
3720
3723
|
const serverStateRef = useRef7(null);
|
|
@@ -3745,7 +3748,8 @@ function useTourPlayback({
|
|
|
3745
3748
|
claimedPlaybackOwnerKeyRef.current = null;
|
|
3746
3749
|
}, []);
|
|
3747
3750
|
const emitTourInit = useCallback6((socket, currentWebsiteId, profile) => {
|
|
3748
|
-
const
|
|
3751
|
+
const persistedSession = readPersistedActiveTourSession();
|
|
3752
|
+
const persistedRunId = runIdRef.current ?? (persistedSession?.experienceType === experienceTypeRef.current ? persistedSession.runId : null);
|
|
3749
3753
|
const payload = {};
|
|
3750
3754
|
if (currentWebsiteId) {
|
|
3751
3755
|
payload.websiteId = currentWebsiteId;
|
|
@@ -3786,7 +3790,7 @@ function useTourPlayback({
|
|
|
3786
3790
|
turnIdRef.current = payload.turnId ?? null;
|
|
3787
3791
|
}
|
|
3788
3792
|
if (payload?.isActive && typeof payload?.runId === "number") {
|
|
3789
|
-
persistActiveTourSession(payload.runId);
|
|
3793
|
+
persistActiveTourSession(payload.runId, experienceTypeRef.current);
|
|
3790
3794
|
} else if (payload?.isActive === false) {
|
|
3791
3795
|
clearPersistedActiveTourSession();
|
|
3792
3796
|
}
|
|
@@ -4421,7 +4425,7 @@ function useTourPlayback({
|
|
|
4421
4425
|
if (isActiveRef.current) return;
|
|
4422
4426
|
runIdRef.current = typeof tourData.runId === "number" ? tourData.runId : runIdRef.current;
|
|
4423
4427
|
if (typeof runIdRef.current === "number") {
|
|
4424
|
-
persistActiveTourSession(runIdRef.current);
|
|
4428
|
+
persistActiveTourSession(runIdRef.current, experienceTypeRef.current);
|
|
4425
4429
|
}
|
|
4426
4430
|
const tour = tourData.tourContext ?? tourRef.current;
|
|
4427
4431
|
const expType = experienceTypeRef.current;
|