datakeen-session-react 1.1.202-dev.16 → 1.1.202-dev.18

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.
Files changed (108) hide show
  1. package/dist/cjs/components/DatakeenSession.js +17 -16
  2. package/dist/cjs/components/card-capture-guide/CardCaptureGuide.js +139 -0
  3. package/dist/cjs/components/card-capture-guide/captureTelemetry.js +81 -0
  4. package/dist/cjs/components/card-capture-guide/guidance.js +48 -0
  5. package/dist/cjs/components/card-capture-guide/guideCore.js +389 -0
  6. package/dist/cjs/components/card-capture-guide/guideRuntime.js +118 -0
  7. package/dist/cjs/components/card-capture-guide/modelLoader.js +46 -0
  8. package/dist/cjs/components/card-capture-guide/useCaptureGuideThresholds.js +33 -0
  9. package/dist/cjs/components/card-capture-guide/useCardCaptureGuide.js +117 -0
  10. package/dist/cjs/components/card-capture-guide/useMinDisplay.js +30 -0
  11. package/dist/cjs/components/document-collection/DocumentCollection.js +9 -0
  12. package/dist/cjs/components/id-check/Photo.js +230 -122
  13. package/dist/cjs/components/id-check/card-capture/CardCapture.js +270 -0
  14. package/dist/cjs/components/id-check/card-capture/DynamicCardMask.js +85 -0
  15. package/dist/cjs/components/id-check/card-capture/geometry.js +119 -0
  16. package/dist/cjs/components/id-check/card-capture/guideTone.js +15 -0
  17. package/dist/cjs/components/jdi/JDIDocumentSelection.js +9 -0
  18. package/dist/cjs/components/selfie/Video.js +2 -2
  19. package/dist/cjs/components/selfie/selfie-flow/SelfieFlow.js +4 -2
  20. package/dist/cjs/components/session/DocumentCheck.js +37 -2
  21. package/dist/cjs/components/session/EndFlow.js +4 -0
  22. package/dist/cjs/components/session/Selfie.js +1 -1
  23. package/dist/cjs/components/signature-electronic/SignatureElectronic.js +9 -2
  24. package/dist/cjs/components/start-flow/Start.js +4 -0
  25. package/dist/cjs/components/template/TemplateNodeRenderer.js +3 -1
  26. package/dist/cjs/components/ui/Button.js +3 -3
  27. package/dist/cjs/context/CardCaptureGuideContext.js +16 -0
  28. package/dist/cjs/hooks/useClientInfo.js +7 -0
  29. package/dist/cjs/hooks/useUserInputForm.js +3 -1
  30. package/dist/cjs/i18n/en.json.js +57 -1
  31. package/dist/cjs/i18n/es.json.js +57 -1
  32. package/dist/cjs/i18n/fr.json.js +57 -1
  33. package/dist/cjs/index.css.js +1 -1
  34. package/dist/cjs/index.js +15 -0
  35. package/dist/cjs/preview/DatakeenJourneyPreview.js +257 -0
  36. package/dist/cjs/preview/PreviewAutomaticStep.js +23 -0
  37. package/dist/cjs/preview/PreviewBranchPicker.js +54 -0
  38. package/dist/cjs/preview/PreviewCaptureDisabled.js +19 -0
  39. package/dist/cjs/preview/previewAdapter.js +27 -0
  40. package/dist/cjs/preview/previewMode.js +21 -0
  41. package/dist/cjs/preview/previewNavigation.js +105 -0
  42. package/dist/cjs/services/api.js +5 -0
  43. package/dist/cjs/services/cameraService.js +6 -0
  44. package/dist/cjs/services/realtime/sseClient.js +4 -0
  45. package/dist/cjs/services/sessionService.js +50 -0
  46. package/dist/cjs/utils/cssLoader.js +6 -4
  47. package/dist/cjs/utils/isMobileDevice.js +8 -0
  48. package/dist/esm/components/DatakeenSession.js +17 -16
  49. package/dist/esm/components/card-capture-guide/CardCaptureGuide.js +135 -0
  50. package/dist/esm/components/card-capture-guide/captureTelemetry.js +78 -0
  51. package/dist/esm/components/card-capture-guide/guidance.js +44 -0
  52. package/dist/esm/components/card-capture-guide/guideCore.js +372 -0
  53. package/dist/esm/components/card-capture-guide/guideRuntime.js +115 -0
  54. package/dist/esm/components/card-capture-guide/modelLoader.js +42 -0
  55. package/dist/esm/components/card-capture-guide/useCaptureGuideThresholds.js +31 -0
  56. package/dist/esm/components/card-capture-guide/useCardCaptureGuide.js +115 -0
  57. package/dist/esm/components/card-capture-guide/useMinDisplay.js +28 -0
  58. package/dist/esm/components/document-collection/DocumentCollection.js +10 -1
  59. package/dist/esm/components/id-check/Photo.js +232 -124
  60. package/dist/esm/components/id-check/card-capture/CardCapture.js +266 -0
  61. package/dist/esm/components/id-check/card-capture/DynamicCardMask.js +81 -0
  62. package/dist/esm/components/id-check/card-capture/geometry.js +110 -0
  63. package/dist/esm/components/id-check/card-capture/guideTone.js +13 -0
  64. package/dist/esm/components/jdi/JDIDocumentSelection.js +9 -0
  65. package/dist/esm/components/selfie/Video.js +2 -2
  66. package/dist/esm/components/selfie/selfie-flow/SelfieFlow.js +4 -2
  67. package/dist/esm/components/session/DocumentCheck.js +37 -2
  68. package/dist/esm/components/session/EndFlow.js +4 -0
  69. package/dist/esm/components/session/Selfie.js +1 -1
  70. package/dist/esm/components/signature-electronic/SignatureElectronic.js +9 -2
  71. package/dist/esm/components/start-flow/Start.js +4 -0
  72. package/dist/esm/components/template/TemplateNodeRenderer.js +3 -1
  73. package/dist/esm/components/ui/Button.js +3 -3
  74. package/dist/esm/context/CardCaptureGuideContext.js +13 -0
  75. package/dist/esm/hooks/useClientInfo.js +7 -0
  76. package/dist/esm/hooks/useUserInputForm.js +3 -1
  77. package/dist/esm/i18n/en.json.js +55 -2
  78. package/dist/esm/i18n/es.json.js +55 -2
  79. package/dist/esm/i18n/fr.json.js +55 -2
  80. package/dist/esm/index.css.js +1 -1
  81. package/dist/esm/index.js +6 -0
  82. package/dist/esm/preview/DatakeenJourneyPreview.js +253 -0
  83. package/dist/esm/preview/PreviewAutomaticStep.js +19 -0
  84. package/dist/esm/preview/PreviewBranchPicker.js +48 -0
  85. package/dist/esm/preview/PreviewCaptureDisabled.js +15 -0
  86. package/dist/esm/preview/previewAdapter.js +25 -0
  87. package/dist/esm/preview/previewMode.js +15 -0
  88. package/dist/esm/preview/previewNavigation.js +98 -0
  89. package/dist/esm/services/api.js +5 -0
  90. package/dist/esm/services/cameraService.js +6 -0
  91. package/dist/esm/services/realtime/sseClient.js +4 -0
  92. package/dist/esm/services/sessionService.js +49 -1
  93. package/dist/esm/utils/cssLoader.js +6 -4
  94. package/dist/esm/utils/isMobileDevice.js +8 -0
  95. package/dist/types/components/card-capture-guide/CardCaptureGuide.d.ts +46 -0
  96. package/dist/types/components/card-capture-guide/guidance.d.ts +45 -0
  97. package/dist/types/components/card-capture-guide/guideCore.d.ts +96 -0
  98. package/dist/types/components/card-capture-guide/guideRuntime.d.ts +13 -0
  99. package/dist/types/components/card-capture-guide/modelLoader.d.ts +13 -0
  100. package/dist/types/components/card-capture-guide/useCardCaptureGuide.d.ts +38 -0
  101. package/dist/types/index.d.ts +8 -0
  102. package/dist/types/preview/DatakeenJourneyPreview.d.ts +6 -0
  103. package/dist/types/preview/types.d.ts +77 -0
  104. package/dist/types/services/documentTemplate.d.ts +13 -0
  105. package/dist/types/types/camera.d.ts +3 -0
  106. package/dist/types/types/session.d.ts +268 -1
  107. package/dist/types/utils/cssLoader.d.ts +0 -4
  108. package/package.json +2 -1
@@ -0,0 +1,25 @@
1
+ import { __awaiter, __generator } from '../node_modules/tslib/tslib.es6.js';
2
+ import { getPreviewDocumentTemplates } from './previewMode.js';
3
+
4
+ var DOCUMENT_TEMPLATES_PATH = "document/get-all-document-templates";
5
+ var previewAdapter = function (config) { return __awaiter(void 0, void 0, void 0, function () {
6
+ var url, data, response;
7
+ var _a;
8
+ return __generator(this, function (_b) {
9
+ url = (_a = config.url) !== null && _a !== void 0 ? _a : "";
10
+ data = url.includes(DOCUMENT_TEMPLATES_PATH)
11
+ ? { status: 200, message: "preview", data: getPreviewDocumentTemplates() }
12
+ : {};
13
+ response = {
14
+ data: data,
15
+ status: 200,
16
+ statusText: "OK",
17
+ headers: {},
18
+ config: config,
19
+ request: {},
20
+ };
21
+ return [2 /*return*/, response];
22
+ });
23
+ }); };
24
+
25
+ export { previewAdapter };
@@ -0,0 +1,15 @@
1
+ var previewState = null;
2
+ var enablePreviewMode = function (_a) {
3
+ var device = _a.device, documentTemplates = _a.documentTemplates;
4
+ previewState = { device: device, documentTemplates: documentTemplates !== null && documentTemplates !== void 0 ? documentTemplates : [] };
5
+ };
6
+ var disablePreviewMode = function () {
7
+ previewState = null;
8
+ };
9
+ var isPreviewMode = function () { return previewState !== null; };
10
+ /** Appareil simulé, null hors aperçu. */
11
+ var getPreviewDevice = function () { var _a; return (_a = previewState === null || previewState === void 0 ? void 0 : previewState.device) !== null && _a !== void 0 ? _a : null; };
12
+ /** Modèles de documents fournis par le builder (liste vide hors aperçu ou si non fournis). */
13
+ var getPreviewDocumentTemplates = function () { var _a; return (_a = previewState === null || previewState === void 0 ? void 0 : previewState.documentTemplates) !== null && _a !== void 0 ? _a : []; };
14
+
15
+ export { disablePreviewMode, enablePreviewMode, getPreviewDevice, getPreviewDocumentTemplates, isPreviewMode };
@@ -0,0 +1,98 @@
1
+ import { __assign, __spreadArray } from '../node_modules/tslib/tslib.es6.js';
2
+ import { findOutgoingEdge } from '../services/sessionService.js';
3
+
4
+ /** Nœuds exécutés sans écran pour l'utilisateur final : l'aperçu affiche un écran neutre. */
5
+ var AUTOMATIC_NODE_TYPES = new Set([
6
+ "condition",
7
+ "external-verification",
8
+ "complementary-mandate",
9
+ "pdf-generation",
10
+ "hybrid-verification",
11
+ "task-assignment",
12
+ // Après la fin, sans écran pour l'utilisateur : export et notification de fin de session (APP3-2033).
13
+ "storage-export",
14
+ "session-end-email",
15
+ ]);
16
+ var isAutomaticNodeType = function (type) {
17
+ return AUTOMATIC_NODE_TYPES.has(type);
18
+ };
19
+ /** Vue « template » minimale pour les helpers du sessionService (lecture seule). */
20
+ var asTemplate = function (journey) {
21
+ return ({ nodes: journey.nodes, edges: journey.edges });
22
+ };
23
+ var findNode = function (journey, nodeId) {
24
+ return journey.nodes.find(function (n) { return n.id === nodeId; });
25
+ };
26
+ /** Cible du lien sortant du nœud START (null si absent ou non relié). */
27
+ var getFirstScreenNodeId = function (journey) {
28
+ var start = journey.nodes.find(function (n) { return n.type === "start"; });
29
+ if (!start)
30
+ return null;
31
+ var edge = findOutgoingEdge(start.id, asTemplate(journey));
32
+ if (!edge || !findNode(journey, edge.target))
33
+ return null;
34
+ return edge.target;
35
+ };
36
+ /** Liens sortants vers un nœud existant, dans l'ordre des edges. */
37
+ var getOutgoingBranches = function (journey, nodeId) {
38
+ return (journey.edges || [])
39
+ .filter(function (edge) { return edge.source === nodeId && !!findNode(journey, edge.target); })
40
+ .map(function (edge) { return ({
41
+ edgeId: edge.id,
42
+ targetId: edge.target,
43
+ handle: edge.sourceHandle || edge.conditionValue || null,
44
+ }); });
45
+ };
46
+ /** Écran à afficher pour un nœud (null, START ou id inconnu → accueil). */
47
+ var resolvePreviewScreen = function (journey, nodeId) {
48
+ if (!nodeId)
49
+ return { kind: "start" };
50
+ var node = findNode(journey, nodeId);
51
+ if (!node || node.type === "start")
52
+ return { kind: "start" };
53
+ if (isAutomaticNodeType(node.type))
54
+ return { kind: "automatic", node: node };
55
+ return { kind: "node", node: node };
56
+ };
57
+ /** Session fictive (jamais terminée, sans données) construite depuis le parcours du builder. */
58
+ var buildPreviewSession = function (journey, device) {
59
+ var _a;
60
+ var template = __assign({ id: "preview", name: (_a = journey.name) !== null && _a !== void 0 ? _a : "", description: "", version: "", languages: journey.languages ? __spreadArray([], journey.languages, true) : [], nodes: __spreadArray([], journey.nodes, true), edges: __spreadArray([], journey.edges, true), groupId: "", userId: null, created_at: "", updated_at: "", platforms: journey.platforms, logo: journey.logo, showQRCode: journey.showQRCode, buttonBgColor: journey.buttonBgColor, buttonTextColor: journey.buttonTextColor,
61
+ // Textes en cours d'édition : EndFlow ignore un cas sans item (repli sur l'écran standard).
62
+ endScreenConfig: journey.endScreenConfig }, (journey.actionPhrase !== undefined ? { actionPhrase: journey.actionPhrase } : {}));
63
+ return {
64
+ id: "preview",
65
+ userId: null,
66
+ token: "",
67
+ templateId: "preview",
68
+ templateKey: "preview",
69
+ expireTime: 0,
70
+ status: "in-progress",
71
+ result: {},
72
+ landingPage: null,
73
+ withSelfie: null,
74
+ groupId: null,
75
+ userInput: {},
76
+ callbackURL: null,
77
+ webhookURL: "",
78
+ analysisTemplateId: null,
79
+ userAgent: [],
80
+ mobile: device === "mobile",
81
+ analysisId: null,
82
+ currentStep: 0,
83
+ createdAt: "",
84
+ updatedAt: "",
85
+ auditTrail: [],
86
+ user: null,
87
+ analysis: [],
88
+ documents: [],
89
+ template: template,
90
+ retryCounts: {},
91
+ };
92
+ };
93
+ /** Statut passé à EndFlow pour afficher l'écran conforme / non conforme. */
94
+ var previewEndStatus = function (result) {
95
+ return result === "non_compliant" ? "ai_rejected" : "ai_approved";
96
+ };
97
+
98
+ export { buildPreviewSession, getFirstScreenNodeId, getOutgoingBranches, isAutomaticNodeType, previewEndStatus, resolvePreviewScreen };
@@ -2,6 +2,8 @@ import { __assign, __awaiter, __generator } from '../node_modules/tslib/tslib.es
2
2
  import { credentialForRequest, deviceIdForRequest } from './sessionCredentials.js';
3
3
  import axios from 'axios';
4
4
  import { API_BASE_URL } from '../config/env.js';
5
+ import { isPreviewMode } from '../preview/previewMode.js';
6
+ import { previewAdapter } from '../preview/previewAdapter.js';
5
7
 
6
8
  // Helpers
7
9
  var normalizeBaseURL = function (url) {
@@ -77,6 +79,9 @@ var ApiService = /** @class */ (function () {
77
79
  // Intercepteur de requête
78
80
  this.client.interceptors.request.use(function (config) {
79
81
  var _a, _b;
82
+ // APP3-2057 — aperçu du builder : aucune requête ne part sur le réseau.
83
+ if (isPreviewMode())
84
+ config.adapter = previewAdapter;
80
85
  var token = credentialForRequest((_a = config.url) !== null && _a !== void 0 ? _a : "");
81
86
  if (token)
82
87
  config.headers.set("X-Session-Token", token);
@@ -1,6 +1,8 @@
1
1
  import { __awaiter, __generator, __assign } from '../node_modules/tslib/tslib.es6.js';
2
2
  import { isBelowHd } from '../utils/cameraResolution.js';
3
3
  import { professionalImageQuality } from './professionalImageQuality.js';
4
+ import { isPreviewMode } from '../preview/previewMode.js';
5
+ import sdkI18n from '../i18n/index.js';
4
6
 
5
7
  // Permit to enable development mode to test without a camera
6
8
  var DEV_MODE = false; // import.meta.env.DEV;
@@ -90,6 +92,10 @@ var CameraService = /** @class */ (function () {
90
92
  return __generator(this, function (_b) {
91
93
  switch (_b.label) {
92
94
  case 0:
95
+ // APP3-2057 — aperçu du builder : la caméra n'est jamais ouverte.
96
+ if (isPreviewMode()) {
97
+ return [2 /*return*/, { success: false, error: sdkI18n.t("preview.capture_disabled.title") }];
98
+ }
93
99
  if (this.devMode) {
94
100
  return [2 /*return*/, this.startMockCamera(videoElement)];
95
101
  }
@@ -1,5 +1,6 @@
1
1
  import { __awaiter, __generator, __assign } from '../../node_modules/tslib/tslib.es6.js';
2
2
  import { createSseParser } from './sseParser.js';
3
+ import { isPreviewMode } from '../../preview/previewMode.js';
3
4
 
4
5
  var FATAL_STATUSES = new Set([401, 403, 404]);
5
6
  /**
@@ -15,6 +16,9 @@ function openSseStream(_a) {
15
16
  }
16
17
  return fetch.apply(void 0, args);
17
18
  } : _b, _c = _a.initialRetryMs, initialRetryMs = _c === void 0 ? 1000 : _c, _d = _a.maxRetryMs, maxRetryMs = _d === void 0 ? 30000 : _d, _e = _a.idleTimeoutMs, idleTimeoutMs = _e === void 0 ? 60000 : _e, _f = _a.random, random = _f === void 0 ? Math.random : _f;
19
+ // APP3-2057 — aperçu du builder : aucun flux temps réel n'est ouvert.
20
+ if (isPreviewMode())
21
+ return { close: function () { }, reconnect: function () { } };
18
22
  var closed = false;
19
23
  var controller = null;
20
24
  var timer;
@@ -2,7 +2,49 @@ import { __awaiter, __generator, __assign, __spreadArray } from '../node_modules
2
2
  import { apiService } from './api.js';
3
3
  import { logStatusModified } from './auditTrailService.js';
4
4
  import { clearSessionMemory } from './sessionMemoryStore.js';
5
+ import { isPreviewMode } from '../preview/previewMode.js';
5
6
 
7
+ var THRESHOLD_KEYS = [
8
+ "holdMs", "minBlur", "maxGlareBlob", "minNativeLong", "minCardBrightness", "minFrameBrightness",
9
+ ];
10
+ /** Sends the capture guide aggregates of one capture (APP3-2119). Callers fire and forget. */
11
+ function reportCaptureTelemetry(sessionId, payload) {
12
+ return __awaiter(this, void 0, void 0, function () {
13
+ return __generator(this, function (_a) {
14
+ switch (_a.label) {
15
+ case 0: return [4 /*yield*/, apiService.post("/session/sdk/".concat(sessionId, "/capture-guide/telemetry"), payload)];
16
+ case 1:
17
+ _a.sent();
18
+ return [2 /*return*/];
19
+ }
20
+ });
21
+ });
22
+ }
23
+ /** Server thresholds for the capture guide; unexpected values are dropped (the SDK defaults apply). */
24
+ function getCaptureGuideConfig(sessionId) {
25
+ return __awaiter(this, void 0, void 0, function () {
26
+ var response, raw, thresholds, _i, THRESHOLD_KEYS_1, key, value;
27
+ var _a;
28
+ return __generator(this, function (_b) {
29
+ switch (_b.label) {
30
+ case 0: return [4 /*yield*/, apiService.get("/session/sdk/".concat(sessionId, "/capture-guide"))];
31
+ case 1:
32
+ response = _b.sent();
33
+ raw = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.thresholds;
34
+ thresholds = {};
35
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) {
36
+ for (_i = 0, THRESHOLD_KEYS_1 = THRESHOLD_KEYS; _i < THRESHOLD_KEYS_1.length; _i++) {
37
+ key = THRESHOLD_KEYS_1[_i];
38
+ value = raw[key];
39
+ if (typeof value === "number" && Number.isFinite(value))
40
+ thresholds[key] = value;
41
+ }
42
+ }
43
+ return [2 /*return*/, { thresholds: thresholds }];
44
+ }
45
+ });
46
+ });
47
+ }
6
48
  /** Reports camera diagnostics without updating local session state. */
7
49
  function reportCaptureDiagnostics(sessionId, nodeId, diag) {
8
50
  return __awaiter(this, void 0, void 0, function () {
@@ -399,6 +441,9 @@ var isSessionExpired = function (session) {
399
441
  * @param options - The options to store
400
442
  */
401
443
  var storeDocumentOptions = function (sessionId, documentTypeId, options) {
444
+ // APP3-2057 — aperçu du builder : rien n'est écrit dans le stockage du navigateur.
445
+ if (isPreviewMode())
446
+ return;
402
447
  if (!sessionId || !documentTypeId || !options || options.length === 0) {
403
448
  console.warn("Missing data for storeDocumentOptions:", {
404
449
  sessionId: sessionId,
@@ -467,6 +512,9 @@ var clearStorageBySessionId = function (sessionId) {
467
512
  * for a given session. This is intentionally aggressive for security.
468
513
  */
469
514
  var clearSessionSensitiveData = function (sessionId) {
515
+ // APP3-2057 — aperçu du builder : aucune donnée de session réelle à nettoyer.
516
+ if (isPreviewMode())
517
+ return;
470
518
  clearSessionMemory(sessionId);
471
519
  if (sessionId) {
472
520
  clearStorageBySessionId(sessionId);
@@ -549,4 +597,4 @@ function checkComplementaryMandate(sessionId, nodeId) {
549
597
  return request;
550
598
  }
551
599
 
552
- export { checkComplementaryMandate, claimActiveDevice, clearSessionSensitiveData, fetchSessionById, findOutgoingEdge, getNextStepIndex, getOrderedJourneySteps, getRunPrefillData, hasOutgoingEdgeForHandle, isSessionExpired, reconstructHistoryToStep, reportCaptureDiagnostics, reportSelfieFailure, resetNfcScan, sendClientInfo, skipNfcWithReason, storeDocumentOptions, updateSessionContactInfo, updateSessionCurrentStep, updateSessionStatus, updateSessionUserInput };
600
+ export { checkComplementaryMandate, claimActiveDevice, clearSessionSensitiveData, fetchSessionById, findOutgoingEdge, getCaptureGuideConfig, getNextStepIndex, getOrderedJourneySteps, getRunPrefillData, hasOutgoingEdgeForHandle, isSessionExpired, reconstructHistoryToStep, reportCaptureDiagnostics, reportCaptureTelemetry, reportSelfieFailure, resetNfcScan, sendClientInfo, skipNfcWithReason, storeDocumentOptions, updateSessionContactInfo, updateSessionCurrentStep, updateSessionStatus, updateSessionUserInput };
@@ -1,9 +1,6 @@
1
1
  import { __awaiter, __generator } from '../node_modules/tslib/tslib.es6.js';
2
+ import { isPreviewMode } from '../preview/previewMode.js';
2
3
 
3
- /**
4
- * CSS Route Loading Utility
5
- * Dynamically loads and manages CSS files based on routes/components
6
- */
7
4
  var CSSLoader = /** @class */ (function () {
8
5
  function CSSLoader(baseUrl) {
9
6
  if (baseUrl === void 0) { baseUrl = ''; }
@@ -20,6 +17,9 @@ var CSSLoader = /** @class */ (function () {
20
17
  var fullPath, existing;
21
18
  var _this = this;
22
19
  return __generator(this, function (_a) {
20
+ // APP3-2057 — aperçu du builder : aucune balise <link> (pas de GET vers l'hôte).
21
+ if (isPreviewMode())
22
+ return [2 /*return*/];
23
23
  fullPath = "".concat(this.baseUrl).concat(cssPath);
24
24
  existing = this.loadedCSS.get(routeName);
25
25
  if (existing) {
@@ -64,6 +64,8 @@ var CSSLoader = /** @class */ (function () {
64
64
  * @param cssContent - CSS content as string
65
65
  */
66
66
  CSSLoader.prototype.loadInlineCSS = function (routeName, cssContent) {
67
+ if (isPreviewMode())
68
+ return;
67
69
  // Check if already loaded
68
70
  if (this.loadedCSS.has(routeName)) {
69
71
  var existing = this.loadedCSS.get(routeName);
@@ -1,3 +1,5 @@
1
+ import { getPreviewDevice } from '../preview/previewMode.js';
2
+
1
3
  /**
2
4
  * Détection du type d'appareil par userAgent (plus fiable que la largeur d'écran : un poste de
3
5
  * bureau dans une fenêtre étroite ne doit pas être traité comme un mobile).
@@ -6,6 +8,10 @@
6
8
  * ouvre directement l'application `/scan/:sessionId` plutôt que d'afficher un QR code.
7
9
  */
8
10
  var isMobileDevice = function () {
11
+ // APP3-2057 — aperçu du builder : l'appareil choisi prime sur le user-agent du poste.
12
+ var previewDevice = getPreviewDevice();
13
+ if (previewDevice)
14
+ return previewDevice === "mobile";
9
15
  if (typeof navigator === "undefined")
10
16
  return false;
11
17
  return /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(navigator.userAgent);
@@ -16,6 +22,8 @@ var isMobileDevice = function () {
16
22
  * utilisateur) vers le schéma custom de l'app.
17
23
  */
18
24
  var isIOSDevice = function () {
25
+ if (getPreviewDevice())
26
+ return false;
19
27
  if (typeof navigator === "undefined")
20
28
  return false;
21
29
  return /iPhone|iPad|iPod/i.test(navigator.userAgent);
@@ -0,0 +1,46 @@
1
+ import { CameraFacingMode } from '../../types/camera.js';
2
+ import { Corners, Quality, GuideOptions } from './guideCore.js';
3
+ import { GuidanceEvent, GuidanceMessages } from './guidance.js';
4
+
5
+ interface CardCaptureMeta {
6
+ /** card corners (TL, TR, BR, BL) normalised to the video frame, as last tracked */
7
+ corners: Corners | null;
8
+ quality: Quality | null;
9
+ /** true when the capture was triggered by the guide, false for the manual button */
10
+ automatic: boolean;
11
+ }
12
+ interface CardCaptureGuideProps {
13
+ /** Receives the captured photo (JPEG data URL, full camera resolution) once the card is steady, sharp and glare-free. */
14
+ onCapture: (image: string, meta: CardCaptureMeta) => void;
15
+ /** Capture automatically when the guide says "ready" (default true). A manual button is always available. */
16
+ autoCapture?: boolean;
17
+ facingMode?: CameraFacingMode;
18
+ /** URL of card_guide_v2.onnx (default "/card_guide_v2.onnx"). */
19
+ modelUrl?: string;
20
+ /** Base URL for the onnxruntime-web .wasm files (default: jsDelivr CDN). */
21
+ wasmPaths?: string;
22
+ /** Tune thresholds, e.g. { minBlur: 600, maxGlareBlob: 0.008, holdMs: 800 }. */
23
+ tracker?: GuideOptions;
24
+ /**
25
+ * Real-time guidance channel. Called each time the guidance CODE changes with
26
+ * { code: 'too_blurry' | 'too_dark' | 'bright_spot' | 'too_far' | 'no_card' | 'card_detected' | 'hold_still' | 'ready', message, severity, metrics, ... }.
27
+ * Show your own UI from it (e.g. too_blurry -> "Ajuster la focalisation", too_dark -> "Augmenter la luminosité", bright_spot -> "Éviter les reflets").
28
+ */
29
+ onGuidance?: (event: GuidanceEvent) => void;
30
+ /** Called after every inference (~8/s) with the live metrics (blur, brightness, glare, card size). */
31
+ onFrame?: (event: GuidanceEvent) => void;
32
+ /** Override the text of any code; unspecified codes use the SDK i18n (FR/EN). */
33
+ messages?: GuidanceMessages;
34
+ /** Render the built-in message line (default true). Set false to build your own UI from onGuidance/onFrame. */
35
+ showMessage?: boolean;
36
+ onError?: (message: string) => void;
37
+ className?: string;
38
+ }
39
+ /**
40
+ * Live ID-card capture guide: camera preview + tracked card outline + guidance messages (move closer, hold still, blurry,
41
+ * reflection) and automatic capture once the card is steady, sharp and free of bright spots. Runs fully client-side.
42
+ */
43
+ declare const CardCaptureGuide: React.FC<CardCaptureGuideProps>;
44
+
45
+ export { CardCaptureGuide as default };
46
+ export type { CardCaptureGuideProps, CardCaptureMeta };
@@ -0,0 +1,45 @@
1
+ import { Corners } from './guideCore.js';
2
+
3
+ /**
4
+ * The guidance channel of CardCaptureGuide: one machine-readable CODE per situation, pushed in real time through
5
+ * `onGuidance` (on every change) and `onFrame` (every inference, ~8/s). Map the codes to your own UI/copy:
6
+ *
7
+ * too_blurry -> "Ajuster la focalisation" too_dark -> "Augmenter la luminosité" bright_spot -> "Éviter les reflets"
8
+ */
9
+ declare const GUIDANCE_CODES: readonly ["no_card", "too_far", "too_dark", "card_detected", "hold_still", "too_blurry", "bright_spot", "ready"];
10
+ type GuidanceCode = (typeof GUIDANCE_CODES)[number];
11
+ type GuidanceSeverity = "info" | "warning" | "success";
12
+ /** "warning" = the user must change something; "info" = progress; "success" = capture. */
13
+ declare const GUIDANCE_SEVERITY: Record<GuidanceCode, GuidanceSeverity>;
14
+ type GuidanceMessages = Partial<Record<GuidanceCode, string>>;
15
+ interface GuidanceMetrics {
16
+ /** sharpness (variance of the Laplacian on the card): < 450 is blurry */
17
+ blur: number;
18
+ /** mean gray 0-255 of the card: < 55 is too dark */
19
+ brightness: number;
20
+ /** share (0-1) of the card covered by saturated-white blobs: >= 0.012 is a reflection */
21
+ glare: number;
22
+ /** long side of the card in camera pixels */
23
+ cardSizePx: number;
24
+ }
25
+ interface GuidanceEvent {
26
+ code: GuidanceCode;
27
+ /** previous code, null for the first event */
28
+ previousCode: GuidanceCode | null;
29
+ severity: GuidanceSeverity;
30
+ /** user-facing text for `code` (i18n, or your `messages` override) */
31
+ message: string;
32
+ /** card-detection confidence 0-1 */
33
+ presence: number;
34
+ /** card corners TL,TR,BR,BL, normalised to the video frame (null when no card is tracked) */
35
+ corners: Corners | null;
36
+ /** card metrics, null when no card is measurable */
37
+ metrics: GuidanceMetrics | null;
38
+ /** mean gray 0-255 of the whole camera frame (available even without a card) */
39
+ frameBrightness: number | null;
40
+ /** performance.now() */
41
+ timestamp: number;
42
+ }
43
+
44
+ export { GUIDANCE_CODES, GUIDANCE_SEVERITY };
45
+ export type { GuidanceCode, GuidanceEvent, GuidanceMessages, GuidanceMetrics, GuidanceSeverity };
@@ -0,0 +1,96 @@
1
+ /**
2
+ * MIRRORED from model-id-capture-guidance/web/src/guide-core.mjs (parity-tested there against the Python reference).
3
+ * Keep both in sync. Pure (DOM-free) logic for the browser card-guide v2: letterbox mapping, output decoding,
4
+ * the geometric quad gate, and the temporal tracker that turns noisy per-frame predictions
5
+ * into stable guidance states. Shared by the React component, the plain-JS demo and the Node
6
+ * unit tests. Keep numerically identical to training_v2/model.py::decode and
7
+ * eval/quad_validation.py (parity is checked in tests/run_core_test.js).
8
+ *
9
+ * Model I/O (card_guide_v2.onnx): input (1,3,256,256) letterboxed + ImageNet-normalised;
10
+ * outputs cls(1,3 softmax: none,id_document,other_card) heat(1,4,64,64) off(1,8,64,64) vis(1,4) glob(1,4,2).
11
+ */
12
+ type Point = [number, number];
13
+ type Corners = Point[];
14
+ interface Decoded {
15
+ presence: number;
16
+ idProb: number;
17
+ otherProb: number;
18
+ corners: Corners;
19
+ }
20
+ interface Quality {
21
+ blur: number;
22
+ sat: number;
23
+ blob: number;
24
+ nativeLong: number;
25
+ brightness: number;
26
+ }
27
+ interface GuideOptions {
28
+ enterThr?: number;
29
+ exitThr?: number;
30
+ enterFrames?: number;
31
+ exitFrames?: number;
32
+ ema?: number;
33
+ stillMotion?: number;
34
+ stillExitMotion?: number;
35
+ stillGraceFrames?: number;
36
+ stillFrames?: number;
37
+ holdMs?: number;
38
+ minAreaFrac?: number;
39
+ minBlur?: number;
40
+ maxGlareBlob?: number;
41
+ minNativeLong?: number;
42
+ minCardBrightness?: number;
43
+ minFrameBrightness?: number;
44
+ qualityWindow?: number;
45
+ }
46
+ interface GuideUpdate {
47
+ state: string;
48
+ message: string;
49
+ corners: Corners | null;
50
+ presence: number;
51
+ readyNow: boolean;
52
+ quality: Quality | null;
53
+ frameBrightness: number | null;
54
+ }
55
+ declare const State: Readonly<{
56
+ NO_CARD: "no_card";
57
+ TOO_FAR: "too_far";
58
+ TOO_DARK: "too_dark";
59
+ CARD_DETECTED: "card_detected";
60
+ HOLD_STILL: "hold_still";
61
+ TOO_BLURRY: "too_blurry";
62
+ BRIGHT_SPOT: "bright_spot";
63
+ READY: "ready";
64
+ }>;
65
+ /**
66
+ * Temporal tracker. Feed it one decode() result per inference; it returns a stable guidance state.
67
+ * - hysteresis: card must score >= enterThr on `enterFrames` consecutive frames to appear, and is only
68
+ * dropped after `exitFrames` consecutive frames below exitThr (isolated bad frames do not flicker);
69
+ * - corners are EMA-smoothed; a rejected quad keeps the last good one during the grace period;
70
+ * - optional quality (blur/glare from measureQuality) is median-filtered over `qualityWindow` inferences: GLARE when a bright
71
+ * highlight covers the card, BLURRY when the card is still but soft, TOO_FAR when it is under `minNativeLong` camera pixels;
72
+ * READY additionally requires sharp + no glare, so the auto-capture never fires on a blurry or reflective frame;
73
+ * - HOLD_STILL when mean corner motion < stillMotion (fraction of card diagonal) for `stillFrames`;
74
+ * READY once it has been still for `holdMs` -- `onReady` fires once per card presence.
75
+ */
76
+ declare class GuideTracker {
77
+ o: Required<GuideOptions>;
78
+ fb: number[];
79
+ present: boolean;
80
+ hi: number;
81
+ lo: number;
82
+ corners: Corners | null;
83
+ stillCount: number;
84
+ bad: number;
85
+ stillSince: number | null;
86
+ fired: boolean;
87
+ qual: Quality[];
88
+ state: string;
89
+ constructor(opts?: GuideOptions);
90
+ reset(): void;
91
+ update(dec: Decoded, srcW: number, srcH: number, tMs: number, quality?: Quality | null, frameBrightness?: number | null): GuideUpdate;
92
+ _out(dec: Decoded, srcW: number, srcH: number, tMs?: number): GuideUpdate;
93
+ }
94
+
95
+ export { GuideTracker, State };
96
+ export type { Corners, Decoded, GuideOptions, GuideUpdate, Point, Quality };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Runtime glue for the card guide: onnxruntime-web session, video preprocessing (letterbox 256) and the
3
+ * full-resolution card sampling used by the blur/glare metrics. All pure decisions live in guideCore.ts.
4
+ */
5
+
6
+ interface GuideRuntimeOptions {
7
+ /** URL of the card guide .onnx weights. Default: DEFAULT_MODEL_URL (see modelLoader.ts). */
8
+ modelUrl?: string;
9
+ /** Base URL of the onnxruntime-web .wasm files. Default: jsDelivr CDN pinned to the installed version. */
10
+ wasmPaths?: string;
11
+ }
12
+
13
+ export type { GuideRuntimeOptions };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Model download for the card guide, kept apart from the ONNX runtime so a screen can preload the weights
3
+ * (13.5 MB, the main wait on mobile) without pulling onnxruntime-web or the guide logic.
4
+ */
5
+ /**
6
+ * card-guide-v2b-20261006-weights.onnx (SHA-256 5eae0785…f48b), public Datakeen bucket, CORS `*`.
7
+ * Temporary location for testing: APP3-2118 moves it to the Datakeen CDN with a versioned name and a long cache.
8
+ */
9
+ declare const DEFAULT_MODEL_URL = "https://datakeen-public.s3.eu-west-3.amazonaws.com/FmyFye6vkg8rrzrtQkW3QADx6eyner1q2WAEVUSB/xyG08fbEmVzYFwezy8zzJvHRbfgWpA8spA0TNeJQ.onnx";
10
+ /** Starts the download ahead of the capture screen. Never throws: the capture screen retries or falls back. */
11
+ declare function preloadCardGuideModel(url?: string): void;
12
+
13
+ export { DEFAULT_MODEL_URL, preloadCardGuideModel };
@@ -0,0 +1,38 @@
1
+ import { RefObject } from 'react';
2
+ import { GuideOptions, GuideUpdate } from './guideCore.js';
3
+ import { GuidanceCode, GuidanceEvent } from './guidance.js';
4
+ import { GuideRuntimeOptions } from './guideRuntime.js';
5
+
6
+ interface UseCardCaptureGuideOptions extends GuideRuntimeOptions {
7
+ /** Load the model at all. False = the hook stays idle (no download, no loop). Default: true. */
8
+ active?: boolean;
9
+ /** Run the loop only when true (e.g. once the camera is started and no capture is in progress). */
10
+ enabled?: boolean;
11
+ /** Override tracker thresholds (minBlur, minCardBrightness, maxGlareBlob, holdMs, ...). */
12
+ tracker?: GuideOptions;
13
+ /** Text for a code (i18n or your own copy). Default: the built-in English message. */
14
+ resolveMessage?: (code: GuidanceCode) => string;
15
+ /** Pushed each time the guidance CODE changes (too_blurry, too_dark, bright_spot, ready, ...). */
16
+ onGuidance?: (event: GuidanceEvent) => void;
17
+ /** Pushed after every inference (~8/s) with the live metrics - for meters, debug overlays, analytics. */
18
+ onFrame?: (event: GuidanceEvent) => void;
19
+ /** Model load time, then each inference time (ms) - for telemetry. */
20
+ onTiming?: (timing: {
21
+ kind: "load" | "inference";
22
+ ms: number;
23
+ }) => void;
24
+ /** Fires ONCE per card presence when the card has been steady, sharp, lit and glare-free long enough. */
25
+ onReady?: (guide: GuideUpdate) => void;
26
+ }
27
+ interface CardCaptureGuideState {
28
+ modelReady: boolean;
29
+ guide: GuideUpdate | null;
30
+ /** latest guidance event (same object pushed to onFrame) */
31
+ event: GuidanceEvent | null;
32
+ error: string | null;
33
+ }
34
+ /** Drives the card guide on a <video>: model load, throttled inference loop, temporal tracking, guidance events. */
35
+ declare function useCardCaptureGuide(videoRef: RefObject<HTMLVideoElement>, { modelUrl, wasmPaths, active, enabled, tracker, resolveMessage, onGuidance, onFrame, onReady, onTiming }?: UseCardCaptureGuideOptions): CardCaptureGuideState;
36
+
37
+ export { useCardCaptureGuide };
38
+ export type { CardCaptureGuideState, UseCardCaptureGuideOptions };
@@ -8,6 +8,14 @@ export { I18nProvider, useI18nContext } from './providers/I18nProvider.js';
8
8
  export { AnalysisResult, Prediction, extractRootCauses, getPrimaryRootCause, hasAnalysisFailed } from './utils/apiAnalysis.js';
9
9
  export { default as DatakeenSession } from './components/DatakeenSession.js';
10
10
  export { ConfigProvider } from './context/ConfigContext.js';
11
+ export { CardCaptureGuideConfig, SessionConfig } from './types/session.js';
12
+ export { default as CardCaptureGuide, CardCaptureGuideProps, CardCaptureMeta } from './components/card-capture-guide/CardCaptureGuide.js';
13
+ export { UseCardCaptureGuideOptions, useCardCaptureGuide } from './components/card-capture-guide/useCardCaptureGuide.js';
14
+ export { GuideOptions as CardGuideOptions, Quality as CardGuideQuality, State as CardGuideState, GuideUpdate as CardGuideUpdate, GuideTracker } from './components/card-capture-guide/guideCore.js';
15
+ export { GUIDANCE_CODES, GUIDANCE_SEVERITY, GuidanceCode, GuidanceEvent, GuidanceMessages, GuidanceMetrics, GuidanceSeverity } from './components/card-capture-guide/guidance.js';
16
+ export { DEFAULT_MODEL_URL as CARD_GUIDE_DEFAULT_MODEL_URL, preloadCardGuideModel } from './components/card-capture-guide/modelLoader.js';
17
+ export { default as DatakeenJourneyPreview } from './preview/DatakeenJourneyPreview.js';
18
+ export { DatakeenJourneyPreviewProps, PreviewBranch, PreviewDevice, PreviewEndResult, PreviewEndScreenConfig, PreviewJourney, PreviewJourneyNode, PreviewScreen } from './preview/types.js';
11
19
 
12
20
 
13
21
 
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ import { DatakeenJourneyPreviewProps } from './types.js';
3
+
4
+ declare const DatakeenJourneyPreview: ({ journey, nodeId, language, device, endResult, documentTemplates, onNodeChange, }: DatakeenJourneyPreviewProps) => React.JSX.Element;
5
+
6
+ export { DatakeenJourneyPreview as default };