datakeen-session-react 1.1.202-dev.10 → 1.1.202-dev.12
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/cjs/components/DatakeenSession.js +50 -14
- package/dist/cjs/components/session/ContinuedElsewhere.js +20 -0
- package/dist/cjs/components/session/SessionAbandoned.js +18 -0
- package/dist/cjs/components/session/SessionContent.js +7 -3
- package/dist/cjs/hooks/useNfcSseStatus.js +31 -77
- package/dist/cjs/hooks/useRemoteSessionSync.js +135 -0
- package/dist/cjs/hooks/useSessionData.js +28 -2
- package/dist/cjs/hooks/useSessionEventStream.js +88 -0
- package/dist/cjs/hooks/useStepNavigation.js +57 -1
- package/dist/cjs/hooks/useUserInputForm.js +42 -0
- package/dist/cjs/i18n/en.json.js +9 -0
- package/dist/cjs/i18n/es.json.js +9 -0
- package/dist/cjs/i18n/fr.json.js +9 -0
- package/dist/cjs/services/realtime/sessionSyncReducer.js +106 -0
- package/dist/cjs/services/realtime/sseClient.js +127 -0
- package/dist/cjs/services/realtime/sseParser.js +58 -0
- package/dist/esm/components/DatakeenSession.js +51 -15
- package/dist/esm/components/session/ContinuedElsewhere.js +16 -0
- package/dist/esm/components/session/SessionAbandoned.js +14 -0
- package/dist/esm/components/session/SessionContent.js +7 -3
- package/dist/esm/hooks/useNfcSseStatus.js +31 -77
- package/dist/esm/hooks/useRemoteSessionSync.js +133 -0
- package/dist/esm/hooks/useSessionData.js +28 -2
- package/dist/esm/hooks/useSessionEventStream.js +86 -0
- package/dist/esm/hooks/useStepNavigation.js +57 -1
- package/dist/esm/hooks/useUserInputForm.js +42 -0
- package/dist/esm/i18n/en.json.js +9 -0
- package/dist/esm/i18n/es.json.js +9 -0
- package/dist/esm/i18n/fr.json.js +9 -0
- package/dist/esm/services/realtime/sessionSyncReducer.js +103 -0
- package/dist/esm/services/realtime/sseClient.js +125 -0
- package/dist/esm/services/realtime/sseParser.js +56 -0
- package/dist/types/types/session.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { __assign } from '../node_modules/tslib/tslib.es6.js';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { setSessionCredential } from '../services/sessionCredentials.js';
|
|
4
|
-
import { useLayoutEffect, useEffect, useRef,
|
|
4
|
+
import { useLayoutEffect, useState, useEffect, useRef, useMemo } from 'react';
|
|
5
5
|
import Paper from './ui/Paper.js';
|
|
6
6
|
import useIsMobile from '../hooks/useIsMobile.js';
|
|
7
7
|
import PoweredBy from './ui/PoweredBy.js';
|
|
8
8
|
import SessionExpired from './session/SessionExpired.js';
|
|
9
|
+
import SessionAbandoned from './session/SessionAbandoned.js';
|
|
9
10
|
import { useRouteCSS } from '../hooks/useRouteCSS.js';
|
|
10
11
|
import { DocumentProvider } from '../context/DocumentContext.js';
|
|
11
12
|
import { ConfigProvider } from '../context/ConfigContext.js';
|
|
12
13
|
import { setSessionStore } from '../context/SessionContext.js';
|
|
13
14
|
import { useSessionData } from '../hooks/useSessionData.js';
|
|
14
15
|
import { useStepNavigation } from '../hooks/useStepNavigation.js';
|
|
16
|
+
import { useRemoteSessionSync } from '../hooks/useRemoteSessionSync.js';
|
|
15
17
|
import { useStepCSS } from '../hooks/useStepCSS.js';
|
|
16
18
|
import { useTemplateLoader } from '../hooks/useTemplateLoader.js';
|
|
17
19
|
import { useClientInfo } from '../hooks/useClientInfo.js';
|
|
@@ -43,7 +45,7 @@ import SessionContent from './session/SessionContent.js';
|
|
|
43
45
|
*/
|
|
44
46
|
var DatakeenSession = function (_a) {
|
|
45
47
|
var _b, _c, _d;
|
|
46
|
-
var _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
48
|
+
var _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
47
49
|
var sessionId = _a.sessionId, sessionToken = _a.sessionToken, sessionConfig = _a.sessionConfig, apiBaseUrl = _a.apiBaseUrl;
|
|
48
50
|
useLayoutEffect(function () {
|
|
49
51
|
var fragmentToken = typeof window !== 'undefined' ? new URLSearchParams(window.location.hash.slice(1)).get('sessionToken') : null;
|
|
@@ -51,14 +53,44 @@ var DatakeenSession = function (_a) {
|
|
|
51
53
|
return function () { return setSessionCredential(sessionId); };
|
|
52
54
|
}, [sessionId, sessionToken, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.sessionToken]);
|
|
53
55
|
var isMobile = useIsMobile();
|
|
54
|
-
var
|
|
56
|
+
var _q = useClientInfo(), clientInfo = _q.info, clientInfoLoaded = _q.isLoaded;
|
|
55
57
|
var currentLanguage = useI18n().currentLanguage;
|
|
56
58
|
// Load base CSS and UI components CSS that are always needed
|
|
57
59
|
useRouteCSS("ui-components");
|
|
58
60
|
// Session data management
|
|
59
|
-
var
|
|
61
|
+
var _r = useSessionData(sessionId, clientInfo, clientInfoLoaded), session = _r.session, setSession = _r.setSession, loading = _r.loading, setLoading = _r.setLoading, error = _r.error, isExpired = _r.isExpired, userInput = _r.userInput, setUserInput = _r.setUserInput, contactInfo = _r.contactInfo, setContactInfo = _r.setContactInfo, loadSession = _r.loadSession, handleRetrySession = _r.handleRetrySession, applyRemoteSession = _r.applyRemoteSession;
|
|
60
62
|
// Step navigation management
|
|
61
|
-
var
|
|
63
|
+
var _s = useStepNavigation(sessionId, session === null || session === void 0 ? void 0 : session.status, session === null || session === void 0 ? void 0 : session.currentStep, session === null || session === void 0 ? void 0 : session.template), step = _s.step, stepObject = _s.stepObject, history = _s.history, applyRemoteStep = _s.applyRemoteStep, applyRemoteFinish = _s.applyRemoteFinish, isPersistingStep = _s.isPersistingStep, getRecentLocalSteps = _s.getRecentLocalSteps;
|
|
64
|
+
// APP3-2030 — suit la progression faite sur un autre appareil ou onglet.
|
|
65
|
+
var _t = useState(false), remotelyFinished = _t[0], setRemotelyFinished = _t[1];
|
|
66
|
+
var _u = useState(null), remoteClosure = _u[0], setRemoteClosure = _u[1];
|
|
67
|
+
var _v = useState(null), standbyStep = _v[0], setStandbyStep = _v[1];
|
|
68
|
+
useEffect(function () {
|
|
69
|
+
if (standbyStep !== null && step !== standbyStep)
|
|
70
|
+
setStandbyStep(null);
|
|
71
|
+
}, [step, standbyStep]);
|
|
72
|
+
var platforms = (_e = session === null || session === void 0 ? void 0 : session.template) === null || _e === void 0 ? void 0 : _e.platforms;
|
|
73
|
+
var handoffLocked = !isMobile && ((sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.requireMobile) === true || ((platforms === null || platforms === void 0 ? void 0 : platforms.mobile) === true && (platforms === null || platforms === void 0 ? void 0 : platforms.desktop) !== true));
|
|
74
|
+
useRemoteSessionSync({
|
|
75
|
+
sessionId: sessionId,
|
|
76
|
+
enabled: Boolean(session) && !loading && !error && (sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.realtimeSync) !== false,
|
|
77
|
+
template: session === null || session === void 0 ? void 0 : session.template,
|
|
78
|
+
step: step,
|
|
79
|
+
handoffLocked: handoffLocked,
|
|
80
|
+
isPersistingStep: isPersistingStep,
|
|
81
|
+
getRecentLocalSteps: getRecentLocalSteps,
|
|
82
|
+
applyRemoteStep: applyRemoteStep,
|
|
83
|
+
applyRemoteFinish: applyRemoteFinish,
|
|
84
|
+
onSessionRefreshed: applyRemoteSession,
|
|
85
|
+
onStandby: setStandbyStep,
|
|
86
|
+
onFinished: function (finishedSession) {
|
|
87
|
+
setRemotelyFinished(true);
|
|
88
|
+
setSession(finishedSession);
|
|
89
|
+
},
|
|
90
|
+
onExpired: function () { return setRemoteClosure("expired"); },
|
|
91
|
+
onAbandoned: function () { return setRemoteClosure("abandoned"); },
|
|
92
|
+
apiBaseUrl: apiBaseUrl,
|
|
93
|
+
});
|
|
62
94
|
// Load route-specific CSS based on current step
|
|
63
95
|
useStepCSS(step, session);
|
|
64
96
|
// Template loading logic
|
|
@@ -90,7 +122,8 @@ var DatakeenSession = function (_a) {
|
|
|
90
122
|
// resserre les dépendances pour ne pas se re-déclencher à chaque mutation de session
|
|
91
123
|
// (userInput, retryCounts, polling…) — ce qui relançait la boucle.
|
|
92
124
|
useEffect(function () {
|
|
93
|
-
|
|
125
|
+
// Fin venue d'un autre appareil : l'écran de fin s'affiche sans repositionner (ni PATCH).
|
|
126
|
+
if ((session === null || session === void 0 ? void 0 : session.status) !== "ended" || !session.template || remotelyFinished) {
|
|
94
127
|
return;
|
|
95
128
|
}
|
|
96
129
|
var orderedSteps = getOrderedJourneySteps(session.template);
|
|
@@ -103,7 +136,7 @@ var DatakeenSession = function (_a) {
|
|
|
103
136
|
}
|
|
104
137
|
// Dépendances volontairement resserrées à status + template.id (cf. commentaire
|
|
105
138
|
// ci-dessus) : ne pas inclure `session`/`stepObject` qui relanceraient la boucle.
|
|
106
|
-
}, [session === null || session === void 0 ? void 0 : session.status, (
|
|
139
|
+
}, [session === null || session === void 0 ? void 0 : session.status, (_f = session === null || session === void 0 ? void 0 : session.template) === null || _f === void 0 ? void 0 : _f.id]);
|
|
107
140
|
if (!sessionId) {
|
|
108
141
|
return jsx(NoSessionIdState, {});
|
|
109
142
|
}
|
|
@@ -112,7 +145,7 @@ var DatakeenSession = function (_a) {
|
|
|
112
145
|
var showMobilePoweredBy = isMobile && (loading || !!error || isExpired);
|
|
113
146
|
var showDesktopPoweredBy = !isMobile && !loading && !error && !isExpired;
|
|
114
147
|
var poweredByRef = useRef(null);
|
|
115
|
-
var
|
|
148
|
+
var _w = useState(0), poweredByHeight = _w[0], setPoweredByHeight = _w[1];
|
|
116
149
|
useLayoutEffect(function () {
|
|
117
150
|
if (typeof window === "undefined" || !showMobilePoweredBy) {
|
|
118
151
|
setPoweredByHeight(0);
|
|
@@ -139,10 +172,13 @@ var DatakeenSession = function (_a) {
|
|
|
139
172
|
if (error) {
|
|
140
173
|
return jsx(ErrorState, { error: error });
|
|
141
174
|
}
|
|
142
|
-
if (isExpired) {
|
|
175
|
+
if (isExpired || remoteClosure === "expired") {
|
|
143
176
|
return jsx(SessionExpired, { onRetry: handleRetrySession });
|
|
144
177
|
}
|
|
145
|
-
|
|
178
|
+
if (remoteClosure === "abandoned") {
|
|
179
|
+
return jsx(SessionAbandoned, {});
|
|
180
|
+
}
|
|
181
|
+
return (jsx(SessionContent, { step: step, loading: loading, session: session, sessionId: sessionId, stepObject: stepObject, stepHistory: history, userInput: userInput, setUserInput: setUserInput, contactInfo: contactInfo, setContactInfo: setContactInfo, remotelyFinished: remotelyFinished, standbyStep: standbyStep, onResumeHere: function () { return setStandbyStep(null); } }));
|
|
146
182
|
};
|
|
147
183
|
var mobileScrollPadding = showMobilePoweredBy
|
|
148
184
|
? "calc(".concat(poweredByHeight, "px + env(safe-area-inset-bottom, 0px))")
|
|
@@ -158,7 +194,7 @@ var DatakeenSession = function (_a) {
|
|
|
158
194
|
var shouldUseWideDesktopLayout = (currentTemplateNode === null || currentTemplateNode === void 0 ? void 0 : currentTemplateNode.type) === "information-input" &&
|
|
159
195
|
currentTemplateNode.informationType === "custom" &&
|
|
160
196
|
(currentTemplateNode.customFields || []).some(function (field) { return field.valueType === "list"; });
|
|
161
|
-
var
|
|
197
|
+
var _x = useState(false), isRecordingSelfie = _x[0], setIsRecordingSelfie = _x[1];
|
|
162
198
|
useEffect(function () {
|
|
163
199
|
if (typeof document === "undefined")
|
|
164
200
|
return;
|
|
@@ -177,8 +213,8 @@ var DatakeenSession = function (_a) {
|
|
|
177
213
|
(currentTemplateNode === null || currentTemplateNode === void 0 ? void 0 : currentTemplateNode.type) === "selfie-capture" ||
|
|
178
214
|
(currentTemplateNode === null || currentTemplateNode === void 0 ? void 0 : currentTemplateNode.type) === "document-collection" || // Could be upload, but safer to allow full height
|
|
179
215
|
(currentTemplateNode === null || currentTemplateNode === void 0 ? void 0 : currentTemplateNode.type) === "controle-jdi";
|
|
180
|
-
var btnBg = (
|
|
181
|
-
var btnText = (
|
|
216
|
+
var btnBg = (_h = (_g = session === null || session === void 0 ? void 0 : session.template) === null || _g === void 0 ? void 0 : _g.buttonBgColor) !== null && _h !== void 0 ? _h : "#11E5C5";
|
|
217
|
+
var btnText = (_k = (_j = session === null || session === void 0 ? void 0 : session.template) === null || _j === void 0 ? void 0 : _j.buttonTextColor) !== null && _k !== void 0 ? _k : "#3C3C40";
|
|
182
218
|
return (jsx(ConfigProvider, { apiBaseUrl: apiBaseUrl, children: jsx(DocumentProvider, { children: jsx("div", { className: "sdk-session notranslate flex-1 flex flex-col", lang: currentLanguage, translate: "no", style: __assign((_c = {}, _c["--dk-btn-bg"] = btnBg, _c["--dk-btn-text"] = btnText, _c), (isMobile
|
|
183
219
|
? (_d = {},
|
|
184
220
|
_d["--dk-mobile-scroll-padding"] = mobileScrollPadding,
|
|
@@ -188,13 +224,13 @@ var DatakeenSession = function (_a) {
|
|
|
188
224
|
: "var(--dk-mobile-scroll-padding, env(safe-area-inset-bottom, 0px))",
|
|
189
225
|
}, children: jsx("div", { className: "flex flex-1 flex-col min-h-0", children: renderSessionContent() }) }), showMobilePoweredBy && (jsx("div", { className: "bg-white px-4 pt-3 pb-4 sm:px-6 sm:pt-6 sm:pb-6", style: {
|
|
190
226
|
paddingBottom: "calc(env(safe-area-inset-bottom, 0px) + 0.5rem)",
|
|
191
|
-
}, ref: poweredByRef, children: jsx(PoweredBy, { logo: (
|
|
227
|
+
}, ref: poweredByRef, children: jsx(PoweredBy, { logo: (_l = session === null || session === void 0 ? void 0 : session.template) === null || _l === void 0 ? void 0 : _l.logo, text: ((_m = session === null || session === void 0 ? void 0 : session.template) === null || _m === void 0 ? void 0 : _m.logo) ? "par" : undefined }) }))] })) : (jsx("div", { className: "flex items-center justify-center w-full min-h-screen bg-gray-100 py-12", children: jsxs("div", { className: "flex flex-col items-center justify-center", children: [jsx(Paper, { className: "dk-session-paper flex flex-col h-[800px] px-8 py-10 bg-white rounded-2xl shadow-xl z-10 ".concat(isRecordingSelfie
|
|
192
228
|
? ""
|
|
193
229
|
: shouldUseWideDesktopLayout
|
|
194
230
|
? "w-[98vw] max-w-[1500px]"
|
|
195
231
|
: "w-[600px]"), style: isRecordingSelfie
|
|
196
232
|
? { width: "min(66vw, 942px)" }
|
|
197
|
-
: undefined, children: jsx("div", { className: "flex-1 w-full h-full overflow-y-auto", children: renderSessionContent() }) }), showDesktopPoweredBy && (jsx("div", { className: "pt-6 text-center", children: jsx(PoweredBy, { logo: (
|
|
233
|
+
: undefined, children: jsx("div", { className: "flex-1 w-full h-full overflow-y-auto", children: renderSessionContent() }) }), showDesktopPoweredBy && (jsx("div", { className: "pt-6 text-center", children: jsx(PoweredBy, { logo: (_o = session === null || session === void 0 ? void 0 : session.template) === null || _o === void 0 ? void 0 : _o.logo, text: ((_p = session === null || session === void 0 ? void 0 : session.template) === null || _p === void 0 ? void 0 : _p.logo) ? "par" : undefined }) }))] }) })) }) }) }));
|
|
198
234
|
};
|
|
199
235
|
|
|
200
236
|
export { DatakeenSession as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import Button from '../ui/Button.js';
|
|
3
|
+
import { useI18n } from '../../hooks/useI18n.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* APP3-2030 — une étape de capture ou de signature a été atteinte sur un autre appareil.
|
|
7
|
+
* Elle n'est montée ici (caméra, appel de vivacité, ouverture du document) que si
|
|
8
|
+
* l'usager choisit de poursuivre sur cet appareil.
|
|
9
|
+
*/
|
|
10
|
+
var ContinuedElsewhere = function (_a) {
|
|
11
|
+
var onResume = _a.onResume;
|
|
12
|
+
var t = useI18n().t;
|
|
13
|
+
return (jsxs("div", { className: "flex flex-col items-center justify-center h-full text-center p-6", role: "status", children: [jsx("h2", { className: "text-2xl font-bold mb-4", children: t("session.continued_elsewhere.title") }), jsx("p", { className: "text-gray-600 mb-6", children: t("session.continued_elsewhere.description") }), jsx(Button, { onClick: onResume, className: "w-full", children: t("session.continued_elsewhere.resume") })] }));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { ContinuedElsewhere as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import shieldIcon from '../../assets/icons/shield_magic_link.svg.js';
|
|
3
|
+
import { useI18n } from '../../hooks/useI18n.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Session clôturée côté serveur pour abandon (APP3-2030 : annoncé en direct aux appareils
|
|
7
|
+
* encore ouverts). Contrairement à l'expiration, rien à réessayer : la session est terminée.
|
|
8
|
+
*/
|
|
9
|
+
var SessionAbandoned = function () {
|
|
10
|
+
var t = useI18n().t;
|
|
11
|
+
return (jsxs("div", { className: "flex flex-col items-center justify-center h-full text-center p-6", role: "status", children: [jsx("div", { className: "mb-6", children: jsx("img", { src: shieldIcon, alt: "", "aria-hidden": "true" }) }), jsx("h2", { className: "text-2xl font-bold text-red-600 mb-4", children: t("session.abandoned.title") }), jsx("p", { className: "text-gray-600 mb-6", children: t("session.abandoned.description") })] }));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { SessionAbandoned as default };
|
|
@@ -3,6 +3,7 @@ import { useEffect } from 'react';
|
|
|
3
3
|
import StartSession from './StartSession.js';
|
|
4
4
|
import MobileRedirect from './MobileRedirect.js';
|
|
5
5
|
import EndFlow from './EndFlow.js';
|
|
6
|
+
import ContinuedElsewhere from './ContinuedElsewhere.js';
|
|
6
7
|
import LoadingState from '../states/LoadingState.js';
|
|
7
8
|
import TemplateNodeRenderer from '../template/TemplateNodeRenderer.js';
|
|
8
9
|
import { getOrderedJourneySteps } from '../../services/sessionService.js';
|
|
@@ -11,8 +12,8 @@ import { useI18n } from '../../hooks/useI18n.js';
|
|
|
11
12
|
|
|
12
13
|
var SessionContent = function (_a) {
|
|
13
14
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
14
|
-
var step = _a.step, loading = _a.loading, session = _a.session, sessionId = _a.sessionId, stepObject = _a.stepObject, stepHistory = _a.stepHistory, userInput = _a.userInput, setUserInput = _a.setUserInput, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo;
|
|
15
|
-
var
|
|
15
|
+
var step = _a.step, loading = _a.loading, session = _a.session, sessionId = _a.sessionId, stepObject = _a.stepObject, stepHistory = _a.stepHistory, userInput = _a.userInput, setUserInput = _a.setUserInput, contactInfo = _a.contactInfo, setContactInfo = _a.setContactInfo, _o = _a.remotelyFinished, remotelyFinished = _o === void 0 ? false : _o, _p = _a.standbyStep, standbyStep = _p === void 0 ? null : _p, onResumeHere = _a.onResumeHere;
|
|
16
|
+
var _q = useI18n(), setLanguage = _q.setLanguage, currentLanguage = _q.currentLanguage, t = _q.t;
|
|
16
17
|
// If is mobile template, isMobileCapture should be true for document-selection nodes
|
|
17
18
|
var isMobileTemplate = ((_c = (_b = session === null || session === void 0 ? void 0 : session.template) === null || _b === void 0 ? void 0 : _b.platforms) === null || _c === void 0 ? void 0 : _c.mobile) === true;
|
|
18
19
|
var showQRCodeInstructions = isMobileTemplate && ((_d = session === null || session === void 0 ? void 0 : session.template) === null || _d === void 0 ? void 0 : _d.showQRCode) === true;
|
|
@@ -67,7 +68,7 @@ var SessionContent = function (_a) {
|
|
|
67
68
|
// Special check: if the session is already finished, display EndFlow
|
|
68
69
|
// directly (raw "ended" or a consolidated result status).
|
|
69
70
|
if (isSessionFinished(session === null || session === void 0 ? void 0 : session.status)) {
|
|
70
|
-
return (jsx(EndFlow, { sessionId: sessionId, sessionStatus: session === null || session === void 0 ? void 0 : session.status, callbackURL: session === null || session === void 0 ? void 0 : session.callbackURL, compliantCase: (_k = (_j = session === null || session === void 0 ? void 0 : session.template) === null || _j === void 0 ? void 0 : _j.endScreenConfig) === null || _k === void 0 ? void 0 : _k.compliant, nonCompliantCase: (_m = (_l = session === null || session === void 0 ? void 0 : session.template) === null || _l === void 0 ? void 0 : _l.endScreenConfig) === null || _m === void 0 ? void 0 : _m.nonCompliant, alreadyFinished: (session === null || session === void 0 ? void 0 : session.status) !== "ended" }));
|
|
71
|
+
return (jsx(EndFlow, { sessionId: sessionId, sessionStatus: session === null || session === void 0 ? void 0 : session.status, callbackURL: session === null || session === void 0 ? void 0 : session.callbackURL, compliantCase: (_k = (_j = session === null || session === void 0 ? void 0 : session.template) === null || _j === void 0 ? void 0 : _j.endScreenConfig) === null || _k === void 0 ? void 0 : _k.compliant, nonCompliantCase: (_m = (_l = session === null || session === void 0 ? void 0 : session.template) === null || _l === void 0 ? void 0 : _l.endScreenConfig) === null || _m === void 0 ? void 0 : _m.nonCompliant, alreadyFinished: remotelyFinished || (session === null || session === void 0 ? void 0 : session.status) !== "ended" }));
|
|
71
72
|
}
|
|
72
73
|
// Render step content
|
|
73
74
|
switch (step) {
|
|
@@ -77,6 +78,9 @@ var SessionContent = function (_a) {
|
|
|
77
78
|
// MobileRedirect step - only shown if showQRCodeInstructions is true
|
|
78
79
|
return (jsx(MobileRedirect, { sessionId: sessionId, onBack: function () { return stepObject.setStep(0); }, onContinueOnPC: handleContinueOnPC, isDesktopAllowed: isDesktopAllowed, title: qrCodeTitle, subtitle: qrCodeDescription }));
|
|
79
80
|
default:
|
|
81
|
+
if (standbyStep !== null && step === standbyStep && onResumeHere) {
|
|
82
|
+
return jsx(ContinuedElsewhere, { onResume: onResumeHere });
|
|
83
|
+
}
|
|
80
84
|
// From step 1 onwards, use dynamic logic based on template
|
|
81
85
|
if (step >= 1) {
|
|
82
86
|
if (loading) {
|
|
@@ -1,88 +1,42 @@
|
|
|
1
1
|
import { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { useSessionEventStream } from './useSessionEventStream.js';
|
|
2
3
|
|
|
3
4
|
var SUCCESS_DISPLAY_DURATION_MS = 2500;
|
|
4
|
-
var
|
|
5
|
+
var isTerminal = function (data) { return (data === null || data === void 0 ? void 0 : data.status) === "completed" || (data === null || data === void 0 ? void 0 : data.status) === "failed"; };
|
|
6
|
+
/**
|
|
7
|
+
* Suit le scan NFC fait dans l'app native via `GET /session/sdk/:id/nfc-status`.
|
|
8
|
+
*
|
|
9
|
+
* APP3-2030 : passe par le client SSE commun (fetch + `X-Session-Token`) au lieu
|
|
10
|
+
* d'EventSource, qui ne pouvait pas envoyer le credential. Le cycle de vie mobile
|
|
11
|
+
* (arrière-plan pendant le scan, retour, bfcache) est géré par `useSessionEventStream`.
|
|
12
|
+
*/
|
|
5
13
|
function useNfcSseStatus(_a) {
|
|
6
14
|
var sessionId = _a.sessionId, apiBaseUrl = _a.apiBaseUrl, onCompleted = _a.onCompleted;
|
|
7
15
|
var _b = useState("pending"), status = _b[0], setStatus = _b[1];
|
|
8
16
|
var onCompletedRef = useRef(onCompleted);
|
|
9
17
|
onCompletedRef.current = onCompleted;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
setTimeout(function () {
|
|
33
|
-
setStatus("completed");
|
|
34
|
-
onCompletedRef.current();
|
|
35
|
-
}, SUCCESS_DISPLAY_DURATION_MS);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
// `failed` est terminal : le serveur ferme le flux, inutile de le rouvrir en boucle.
|
|
39
|
-
if (data.status === "failed")
|
|
40
|
-
finished = true;
|
|
41
|
-
setStatus(data.status);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (_a) {
|
|
45
|
-
// message malformé, on ignore
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
// EventSource se reconnecte seul tant qu'il est CONNECTING. Mais iOS coupe le flux quand
|
|
49
|
-
// Safari passe en arrière-plan pendant le scan dans l'app, et une réponse non-200 à la
|
|
50
|
-
// reconnexion le ferme définitivement (CLOSED) : on le rouvre alors nous-mêmes.
|
|
51
|
-
current.onerror = function () {
|
|
52
|
-
if (!finished && current.readyState === EventSource.CLOSED) {
|
|
53
|
-
reconnectTimer = setTimeout(open, RECONNECT_DELAY_MS);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
// Retour sur la page (depuis l'app de scan, ou restauration bfcache) : le flux a pu mourir
|
|
58
|
-
// pendant la suspension et l'event `completed` être perdu. On rouvre : le serveur renvoie le
|
|
59
|
-
// statut courant dès la connexion, donc le parcours avance sans recharger la page.
|
|
60
|
-
var reopenIfVisible = function () {
|
|
61
|
-
if (!finished && document.visibilityState === "visible")
|
|
62
|
-
open();
|
|
63
|
-
};
|
|
64
|
-
// Fermer le flux uniquement quand la page se ferme réellement, sinon le SSE reste ouvert côté
|
|
65
|
-
// serveur (heartbeat + listener qui fuient). `pagehide` couvre la fermeture d'onglet/navigation
|
|
66
|
-
// (plus fiable que `beforeunload` sur mobile).
|
|
67
|
-
//
|
|
68
|
-
// NE PAS fermer sur `visibilitychange`/`hidden` : le passage en arrière-plan est le geste
|
|
69
|
-
// NORMAL de l'utilisateur qui bascule vers son téléphone pour scanner le QR. On se contente de
|
|
70
|
-
// ROUVRIR au retour (`visible`), ce qui ne coupe jamais un flux encore utile.
|
|
71
|
-
var closeSource = function () {
|
|
72
|
-
clearTimeout(reconnectTimer);
|
|
73
|
-
source === null || source === void 0 ? void 0 : source.close();
|
|
74
|
-
};
|
|
75
|
-
open();
|
|
76
|
-
window.addEventListener("pagehide", closeSource);
|
|
77
|
-
window.addEventListener("pageshow", reopenIfVisible);
|
|
78
|
-
document.addEventListener("visibilitychange", reopenIfVisible);
|
|
79
|
-
return function () {
|
|
80
|
-
window.removeEventListener("pagehide", closeSource);
|
|
81
|
-
window.removeEventListener("pageshow", reopenIfVisible);
|
|
82
|
-
document.removeEventListener("visibilitychange", reopenIfVisible);
|
|
83
|
-
closeSource();
|
|
84
|
-
};
|
|
85
|
-
}, [sessionId, apiBaseUrl]);
|
|
18
|
+
var successTimer = useRef();
|
|
19
|
+
useEffect(function () { return function () { return clearTimeout(successTimer.current); }; }, []);
|
|
20
|
+
useSessionEventStream({
|
|
21
|
+
sessionId: sessionId,
|
|
22
|
+
path: "nfc-status",
|
|
23
|
+
apiBaseUrl: apiBaseUrl,
|
|
24
|
+
enabled: Boolean(sessionId && apiBaseUrl),
|
|
25
|
+
isTerminal: isTerminal,
|
|
26
|
+
onEvent: function (data) {
|
|
27
|
+
if (!(data === null || data === void 0 ? void 0 : data.status))
|
|
28
|
+
return;
|
|
29
|
+
if (data.status === "completed") {
|
|
30
|
+
setStatus("success");
|
|
31
|
+
successTimer.current = setTimeout(function () {
|
|
32
|
+
setStatus("completed");
|
|
33
|
+
onCompletedRef.current();
|
|
34
|
+
}, SUCCESS_DISPLAY_DURATION_MS);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
setStatus(data.status);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
86
40
|
return { status: status };
|
|
87
41
|
}
|
|
88
42
|
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { __awaiter, __generator } from '../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { useRef, useCallback, useEffect } from 'react';
|
|
3
|
+
import { useSessionEventStream } from './useSessionEventStream.js';
|
|
4
|
+
import { fetchSessionById } from '../services/sessionService.js';
|
|
5
|
+
import { decideRemoteSync, isTerminalSessionEvent } from '../services/realtime/sessionSyncReducer.js';
|
|
6
|
+
|
|
7
|
+
/** Délai avant de réessayer un événement reçu pendant une navigation locale non confirmée. */
|
|
8
|
+
var DEFER_RETRY_MS = 250;
|
|
9
|
+
/**
|
|
10
|
+
* APP3-2030 — suit la progression de la session faite sur d'autres appareils/onglets.
|
|
11
|
+
* N'envoie jamais rien au serveur : `decideRemoteSync` décide, puis des primitives de
|
|
12
|
+
* navigation sans PATCH appliquent. Les événements sont traités un par un, dans l'ordre.
|
|
13
|
+
*/
|
|
14
|
+
function useRemoteSessionSync(options) {
|
|
15
|
+
var _this = this;
|
|
16
|
+
var optionsRef = useRef(options);
|
|
17
|
+
optionsRef.current = options;
|
|
18
|
+
var lastRevision = useRef(null);
|
|
19
|
+
var deferred = useRef(null);
|
|
20
|
+
var retryTimer = useRef();
|
|
21
|
+
var queue = useRef(Promise.resolve());
|
|
22
|
+
var disposed = useRef(false);
|
|
23
|
+
var process = useCallback(function (event) { return __awaiter(_this, void 0, void 0, function () {
|
|
24
|
+
var current, decision, _a, fresh, error_1, session, error_2;
|
|
25
|
+
return __generator(this, function (_b) {
|
|
26
|
+
switch (_b.label) {
|
|
27
|
+
case 0:
|
|
28
|
+
current = optionsRef.current;
|
|
29
|
+
if (disposed.current || !current.template)
|
|
30
|
+
return [2 /*return*/];
|
|
31
|
+
decision = decideRemoteSync({
|
|
32
|
+
lastRevision: lastRevision.current,
|
|
33
|
+
step: current.step,
|
|
34
|
+
localNavigationInFlight: current.isPersistingStep(),
|
|
35
|
+
handoffLocked: current.handoffLocked,
|
|
36
|
+
recentLocalSteps: current.getRecentLocalSteps(),
|
|
37
|
+
}, event, current.template);
|
|
38
|
+
if (decision.action === "defer") {
|
|
39
|
+
if (!deferred.current || event.revision > deferred.current.revision)
|
|
40
|
+
deferred.current = event;
|
|
41
|
+
clearTimeout(retryTimer.current);
|
|
42
|
+
retryTimer.current = setTimeout(function () {
|
|
43
|
+
var pending = deferred.current;
|
|
44
|
+
deferred.current = null;
|
|
45
|
+
if (pending)
|
|
46
|
+
enqueue(pending);
|
|
47
|
+
}, DEFER_RETRY_MS);
|
|
48
|
+
return [2 /*return*/];
|
|
49
|
+
}
|
|
50
|
+
if (decision.action === "ignore" && decision.reason === "stale")
|
|
51
|
+
return [2 /*return*/];
|
|
52
|
+
lastRevision.current = event.revision;
|
|
53
|
+
if (deferred.current && deferred.current.revision <= event.revision)
|
|
54
|
+
deferred.current = null;
|
|
55
|
+
_a = decision.action;
|
|
56
|
+
switch (_a) {
|
|
57
|
+
case "navigate": return [3 /*break*/, 1];
|
|
58
|
+
case "finish": return [3 /*break*/, 5];
|
|
59
|
+
case "expire": return [3 /*break*/, 10];
|
|
60
|
+
case "close": return [3 /*break*/, 10];
|
|
61
|
+
case "abandon": return [3 /*break*/, 11];
|
|
62
|
+
}
|
|
63
|
+
return [3 /*break*/, 12];
|
|
64
|
+
case 1:
|
|
65
|
+
_b.trys.push([1, 3, , 4]);
|
|
66
|
+
return [4 /*yield*/, fetchSessionById(current.sessionId)];
|
|
67
|
+
case 2:
|
|
68
|
+
fresh = _b.sent();
|
|
69
|
+
if (disposed.current)
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
if (fresh)
|
|
72
|
+
optionsRef.current.onSessionRefreshed(fresh);
|
|
73
|
+
return [3 /*break*/, 4];
|
|
74
|
+
case 3:
|
|
75
|
+
error_1 = _b.sent();
|
|
76
|
+
console.error("Failed to reload the session before a remote navigation:", error_1);
|
|
77
|
+
return [3 /*break*/, 4];
|
|
78
|
+
case 4:
|
|
79
|
+
if (decision.standby)
|
|
80
|
+
optionsRef.current.onStandby(decision.step);
|
|
81
|
+
optionsRef.current.applyRemoteStep(decision.step);
|
|
82
|
+
return [3 /*break*/, 13];
|
|
83
|
+
case 5:
|
|
84
|
+
current.applyRemoteFinish();
|
|
85
|
+
_b.label = 6;
|
|
86
|
+
case 6:
|
|
87
|
+
_b.trys.push([6, 8, , 9]);
|
|
88
|
+
return [4 /*yield*/, fetchSessionById(current.sessionId)];
|
|
89
|
+
case 7:
|
|
90
|
+
session = _b.sent();
|
|
91
|
+
if (session && !disposed.current)
|
|
92
|
+
optionsRef.current.onFinished(session);
|
|
93
|
+
return [3 /*break*/, 9];
|
|
94
|
+
case 8:
|
|
95
|
+
error_2 = _b.sent();
|
|
96
|
+
console.error("Failed to reload the finished session:", error_2);
|
|
97
|
+
return [3 /*break*/, 9];
|
|
98
|
+
case 9: return [3 /*break*/, 13];
|
|
99
|
+
case 10:
|
|
100
|
+
// Session supprimée : plus rien à poursuivre, même écran qu'une expiration.
|
|
101
|
+
current.onExpired();
|
|
102
|
+
return [3 /*break*/, 13];
|
|
103
|
+
case 11:
|
|
104
|
+
current.onAbandoned();
|
|
105
|
+
return [3 /*break*/, 13];
|
|
106
|
+
case 12: return [3 /*break*/, 13];
|
|
107
|
+
case 13: return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); }, []);
|
|
111
|
+
var enqueue = useCallback(function (event) {
|
|
112
|
+
queue.current = queue.current.then(function () { return process(event); }).catch(function (error) {
|
|
113
|
+
console.error("Remote session sync failed:", error);
|
|
114
|
+
});
|
|
115
|
+
}, [process]);
|
|
116
|
+
useEffect(function () {
|
|
117
|
+
disposed.current = false;
|
|
118
|
+
return function () {
|
|
119
|
+
disposed.current = true;
|
|
120
|
+
clearTimeout(retryTimer.current);
|
|
121
|
+
};
|
|
122
|
+
}, []);
|
|
123
|
+
useSessionEventStream({
|
|
124
|
+
sessionId: options.sessionId,
|
|
125
|
+
path: "events",
|
|
126
|
+
enabled: options.enabled && Boolean(options.template),
|
|
127
|
+
apiBaseUrl: options.apiBaseUrl,
|
|
128
|
+
onEvent: enqueue,
|
|
129
|
+
isTerminal: isTerminalSessionEvent,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export { useRemoteSessionSync };
|
|
@@ -170,6 +170,24 @@ var useSessionData = function (sessionId, clientInfo, clientInfoLoaded) {
|
|
|
170
170
|
});
|
|
171
171
|
}); };
|
|
172
172
|
var userInputSyncInitialized = useRef(false);
|
|
173
|
+
// Saisies venues du serveur (synchro multi-appareils) : à appliquer localement sans les renvoyer.
|
|
174
|
+
var skipNextUserInputSync = useRef(false);
|
|
175
|
+
/**
|
|
176
|
+
* APP3-2030 — remplace la session par celle relue au serveur après un changement fait sur un
|
|
177
|
+
* autre appareil. Les saisies serveur priment sur les saisies locales : sans cela, le prochain
|
|
178
|
+
* envoi de `userInput` (fusion au premier niveau côté serveur) écraserait celles de l'autre appareil.
|
|
179
|
+
*/
|
|
180
|
+
var applyRemoteSession = function (freshSession) {
|
|
181
|
+
setSession(freshSession);
|
|
182
|
+
var serverInput = freshSession.userInput && typeof freshSession.userInput === "object" && !Array.isArray(freshSession.userInput)
|
|
183
|
+
? freshSession.userInput
|
|
184
|
+
: {};
|
|
185
|
+
if (Object.keys(serverInput).length === 0)
|
|
186
|
+
return;
|
|
187
|
+
skipNextUserInputSync.current = true;
|
|
188
|
+
setUserInput(function (prev) { return (__assign(__assign({}, prev), serverInput)); });
|
|
189
|
+
setSessionMemoryUserInput(sessionId, __assign(__assign({}, getSessionMemoryUserInput(sessionId)), serverInput));
|
|
190
|
+
};
|
|
173
191
|
// Update user input in backend and in-memory store
|
|
174
192
|
useEffect(function () {
|
|
175
193
|
if (!sessionId) {
|
|
@@ -189,6 +207,10 @@ var useSessionData = function (sessionId, clientInfo, clientInfoLoaded) {
|
|
|
189
207
|
userInputSyncInitialized.current = true;
|
|
190
208
|
return;
|
|
191
209
|
}
|
|
210
|
+
if (skipNextUserInputSync.current) {
|
|
211
|
+
skipNextUserInputSync.current = false;
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
192
214
|
if (entries.length === 0) {
|
|
193
215
|
return;
|
|
194
216
|
}
|
|
@@ -261,9 +283,12 @@ var useSessionData = function (sessionId, clientInfo, clientInfoLoaded) {
|
|
|
261
283
|
updateContactData();
|
|
262
284
|
}
|
|
263
285
|
}, [contactInfo, sessionId]);
|
|
264
|
-
// Send client info when it becomes available
|
|
286
|
+
// Send client info when it becomes available — once per session id: the session object
|
|
287
|
+
// is replaced on every remote refresh (APP3-2030) and must not re-log "session started".
|
|
288
|
+
var startEffectsSentFor = useRef(null);
|
|
265
289
|
useEffect(function () {
|
|
266
|
-
if (clientInfoLoaded && clientInfo && session) {
|
|
290
|
+
if (clientInfoLoaded && clientInfo && session && startEffectsSentFor.current !== sessionId) {
|
|
291
|
+
startEffectsSentFor.current = sessionId;
|
|
267
292
|
console.log("Sending client info to backend:", maskClientInfoForLog(clientInfo));
|
|
268
293
|
var sendClientInfoAsync = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
269
294
|
var e_1;
|
|
@@ -365,6 +390,7 @@ var useSessionData = function (sessionId, clientInfo, clientInfoLoaded) {
|
|
|
365
390
|
setContactInfo: setContactInfo,
|
|
366
391
|
loadSession: loadSession,
|
|
367
392
|
handleRetrySession: handleRetrySession,
|
|
393
|
+
applyRemoteSession: applyRemoteSession,
|
|
368
394
|
};
|
|
369
395
|
};
|
|
370
396
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
import { getBaseURL } from '../services/api.js';
|
|
3
|
+
import { getSessionCredential } from '../services/sessionCredentials.js';
|
|
4
|
+
import { openSseStream } from '../services/realtime/sseClient.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Flux SSE d'une session, authentifié par le header `X-Session-Token` (jamais d'URL).
|
|
8
|
+
*
|
|
9
|
+
* Cycle de vie mobile : le flux reste ouvert quand la page passe en arrière-plan (geste
|
|
10
|
+
* normal pour scanner un QR avec le téléphone), se reconnecte au retour au premier plan
|
|
11
|
+
* ou à la restauration bfcache (le serveur renvoie alors l'état courant), et se ferme
|
|
12
|
+
* quand la page est réellement quittée (`pagehide`).
|
|
13
|
+
*/
|
|
14
|
+
function useSessionEventStream(_a) {
|
|
15
|
+
var sessionId = _a.sessionId, path = _a.path, onEvent = _a.onEvent, isTerminal = _a.isTerminal, _b = _a.enabled, enabled = _b === void 0 ? true : _b, apiBaseUrl = _a.apiBaseUrl;
|
|
16
|
+
var onEventRef = useRef(onEvent);
|
|
17
|
+
onEventRef.current = onEvent;
|
|
18
|
+
var isTerminalRef = useRef(isTerminal);
|
|
19
|
+
isTerminalRef.current = isTerminal;
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
if (!enabled || !sessionId)
|
|
22
|
+
return;
|
|
23
|
+
var baseUrl = apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : getBaseURL();
|
|
24
|
+
if (!baseUrl)
|
|
25
|
+
return;
|
|
26
|
+
var finished = false;
|
|
27
|
+
var leftPage = false;
|
|
28
|
+
var stream;
|
|
29
|
+
var open = function () {
|
|
30
|
+
return openSseStream({
|
|
31
|
+
url: "".concat(baseUrl, "/session/sdk/").concat(encodeURIComponent(sessionId), "/").concat(path),
|
|
32
|
+
headers: function () {
|
|
33
|
+
var token = getSessionCredential(sessionId);
|
|
34
|
+
return token ? { "X-Session-Token": token } : {};
|
|
35
|
+
},
|
|
36
|
+
onMessage: function (message) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (finished || message.event === "heartbeat")
|
|
39
|
+
return;
|
|
40
|
+
var data;
|
|
41
|
+
try {
|
|
42
|
+
data = JSON.parse(message.data);
|
|
43
|
+
}
|
|
44
|
+
catch (_b) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
onEventRef.current(data);
|
|
48
|
+
if ((_a = isTerminalRef.current) === null || _a === void 0 ? void 0 : _a.call(isTerminalRef, data)) {
|
|
49
|
+
finished = true;
|
|
50
|
+
stream.close();
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
onFatal: function () {
|
|
54
|
+
finished = true;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var resume = function () {
|
|
59
|
+
if (finished || document.visibilityState !== "visible")
|
|
60
|
+
return;
|
|
61
|
+
if (leftPage) {
|
|
62
|
+
leftPage = false;
|
|
63
|
+
stream = open();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
stream.reconnect();
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var leave = function () {
|
|
70
|
+
leftPage = true;
|
|
71
|
+
stream.close();
|
|
72
|
+
};
|
|
73
|
+
stream = open();
|
|
74
|
+
window.addEventListener("pagehide", leave);
|
|
75
|
+
window.addEventListener("pageshow", resume);
|
|
76
|
+
document.addEventListener("visibilitychange", resume);
|
|
77
|
+
return function () {
|
|
78
|
+
window.removeEventListener("pagehide", leave);
|
|
79
|
+
window.removeEventListener("pageshow", resume);
|
|
80
|
+
document.removeEventListener("visibilitychange", resume);
|
|
81
|
+
stream.close();
|
|
82
|
+
};
|
|
83
|
+
}, [sessionId, path, enabled, apiBaseUrl]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { useSessionEventStream };
|