@incodetech/core 2.0.1 → 2.1.0-rc.1

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 (218) hide show
  1. package/dist/{BrowserStorageProvider-CuOW1Er2.esm.js → BrowserStorageProvider-BpJM-gIl.esm.js} +8 -1
  2. package/dist/{IpifyProvider-D7jx52AL.esm.js → IpifyProvider-D4LWD15E.esm.js} +28 -0
  3. package/dist/{MotionSensorProvider-4v7xkqAp.esm.js → MotionSensorProvider-Bx7Mpzt0.esm.js} +63 -13
  4. package/dist/{OpenViduRecordingProvider-CMu6XVdc.esm.js → OpenViduRecordingProvider-O4GjBseO.esm.js} +1 -1
  5. package/dist/StateMachine-BC_nGvrc.d.ts +2 -0
  6. package/dist/StreamCanvasCapture-ImiDQdVA.esm.js +118 -0
  7. package/dist/StreamCanvasCapture-yyl20qd9.d.ts +152 -0
  8. package/dist/{BaseWasmProvider-C_DLEI40.esm.js → WasmUtilProvider-BKWm8rSA.esm.js} +202 -11
  9. package/dist/{addressSearch-BpTbTWCa.esm.js → addressSearch-DvmWXKZg.esm.js} +63 -57
  10. package/dist/{ae-signature-DDDZmWXj.esm.js → ae-signature-BFZta3TZ.esm.js} +1 -1
  11. package/dist/ae-signature.d.ts +3 -3
  12. package/dist/ae-signature.esm.js +6 -5
  13. package/dist/antifraud.d.ts +5 -46
  14. package/dist/antifraud.esm.js +6 -43
  15. package/dist/antifraudManager-CkV4u-LE.esm.js +55 -0
  16. package/dist/antifraudManager-CznnhyvD.d.ts +63 -0
  17. package/dist/{antifraudStateMachine-O0TMf6yc.esm.js → antifraudStateMachine-Ccrb-Jxc.esm.js} +2 -2
  18. package/dist/apiError-B-j-gyDx.esm.js +51 -0
  19. package/dist/authentication.d.ts +13 -11
  20. package/dist/authentication.esm.js +26 -22
  21. package/dist/{authenticationManager-5M-fKzXx.esm.js → authenticationManager-BlR6mSaG.esm.js} +6 -6
  22. package/dist/{authenticationManager-C83GNIhl.d.ts → authenticationManager-CaiQbp-q.d.ts} +4 -4
  23. package/dist/{authenticationStateMachine-BMZqatiF.esm.js → authenticationStateMachine-DkcGUMw5.esm.js} +21 -9
  24. package/dist/{backCameraStream-DMdMeGk2.esm.js → backCameraStream-D7Wo4Nbx.esm.js} +95 -7
  25. package/dist/{session-CrkWAs-q.esm.js → browserSimulation-B1dWiXp7.esm.js} +61 -476
  26. package/dist/camera.d.ts +4 -3
  27. package/dist/camera.esm.js +4 -3
  28. package/dist/canvas-SKcRBxsk.esm.js +230 -0
  29. package/dist/consent.d.ts +4 -398
  30. package/dist/consent.esm.js +6 -77
  31. package/dist/consentManager-BYo9Nu1r.esm.js +90 -0
  32. package/dist/consentManager-Cg5Sk2tv.d.ts +419 -0
  33. package/dist/{consentStateMachine-CCT-B60O.esm.js → consentStateMachine-BG3yL8aC.esm.js} +9 -6
  34. package/dist/cpf-ocr.d.ts +4 -199
  35. package/dist/cpf-ocr.esm.js +8 -177
  36. package/dist/cpfOcrManager-Dg1s_TY5.d.ts +216 -0
  37. package/dist/cpfOcrManager-sSKegxox.esm.js +190 -0
  38. package/dist/cross-document-data-match.d.ts +1 -1
  39. package/dist/cross-document-data-match.esm.js +4 -4
  40. package/dist/curp-validation.d.ts +8 -158
  41. package/dist/curp-validation.esm.js +6 -108
  42. package/dist/curpValidationManager-CFem6zP9.esm.js +122 -0
  43. package/dist/curpValidationManager-RttixpIc.d.ts +184 -0
  44. package/dist/{curpValidationStateMachine-CitWLr2c.esm.js → curpValidationStateMachine-B7V_qp66.esm.js} +20 -13
  45. package/dist/custom-fields.d.ts +2 -2
  46. package/dist/custom-fields.esm.js +4 -4
  47. package/dist/custom-watchlist.d.ts +1 -1
  48. package/dist/custom-watchlist.esm.js +4 -41
  49. package/dist/customWatchlistStateMachine-HmFybXLX.esm.js +50 -0
  50. package/dist/{deepsightLoader-Cm4JIT_z.esm.js → deepsightLoader-8tnddNx-.esm.js} +19 -10
  51. package/dist/deepsightService-CrHmvx8X.esm.js +276 -0
  52. package/dist/{deepsightService-CEVxzehb.d.ts → deepsightService-Dh5P-hLf.d.ts} +13 -160
  53. package/dist/device.esm.js +4 -3
  54. package/dist/document-capture.d.ts +989 -80
  55. package/dist/document-capture.esm.js +34 -8
  56. package/dist/document-upload.d.ts +44 -44
  57. package/dist/document-upload.esm.js +7 -7
  58. package/dist/{documentCaptureStateMachine-BqzTDy9k.esm.js → documentCaptureStateMachine-CUTUzUw_.esm.js} +90 -6
  59. package/dist/dynamic-forms.d.ts +20 -5
  60. package/dist/dynamic-forms.esm.js +150 -61
  61. package/dist/ekyb.d.ts +32 -13
  62. package/dist/ekyb.esm.js +25 -15
  63. package/dist/{ekybStateMachine-CyMx_kg-.esm.js → ekybStateMachine-klc-AImJ.esm.js} +319 -207
  64. package/dist/ekyc.d.ts +10 -78
  65. package/dist/ekyc.esm.js +17 -12
  66. package/dist/{ekycStateMachine-oeO0Iekd.esm.js → ekycStateMachine-CXbpaJJn.esm.js} +201 -113
  67. package/dist/electronic-signature.d.ts +3 -3
  68. package/dist/electronic-signature.esm.js +5 -4
  69. package/dist/{electronicSignatureManager-D9OHzTpG.esm.js → electronicSignatureManager-BaECdJ1u.esm.js} +91 -23
  70. package/dist/email.d.ts +4 -3
  71. package/dist/email.esm.js +6 -5
  72. package/dist/{emailManager-wAV0LE-H.esm.js → emailManager--D5G3ChB.esm.js} +30 -7
  73. package/dist/{emailManager-DIfnS5g1.d.ts → emailManager-lAzDoQOs.d.ts} +66 -8
  74. package/dist/{emailStateMachine-DOf4j58N.esm.js → emailStateMachine-CxTOMAjC.esm.js} +46 -11
  75. package/dist/{endpoints-CnN3SyDa.esm.js → endpoints-BeTK0Mlt.esm.js} +6 -3
  76. package/dist/{events-D6-e4vok.esm.js → events-Dvvriq9l.esm.js} +3 -1
  77. package/dist/events.d.ts +2 -0
  78. package/dist/events.esm.js +1 -1
  79. package/dist/extensibility.d.ts +41 -16
  80. package/dist/extensibility.esm.js +55 -33
  81. package/dist/face-match.d.ts +21 -2
  82. package/dist/face-match.esm.js +5 -5
  83. package/dist/{faceCaptureManagerFactory-yqtpxjnN.d.ts → faceCaptureManagerFactory-CjdBUS6s.d.ts} +48 -17
  84. package/dist/{faceCaptureManagerFactory-Dh2PdGlF.esm.js → faceCaptureManagerFactory-ej2j1LMr.esm.js} +21 -5
  85. package/dist/{faceCaptureSetup-B3faSpYA.esm.js → faceCaptureSetup-B9t6bYze.esm.js} +68 -183
  86. package/dist/{faceMatchStateMachine-DNFrxTFS.esm.js → faceMatchStateMachine-DeXXzSuz.esm.js} +62 -6
  87. package/dist/field-comparison.d.ts +4 -0
  88. package/dist/field-comparison.esm.js +7 -0
  89. package/dist/fieldComparisonManager-Bu5TaSr3.d.ts +76 -0
  90. package/dist/fieldComparisonManager-COGI2ARD.esm.js +162 -0
  91. package/dist/fiscal-qr.d.ts +59 -0
  92. package/dist/fiscal-qr.esm.js +323 -0
  93. package/dist/flow-events.d.ts +6 -5
  94. package/dist/flow.d.ts +23 -15
  95. package/dist/flow.esm.js +56 -17
  96. package/dist/flowCompletionService-BdR2cGgB.d.ts +19 -0
  97. package/dist/flowCompletionService-DdGojV9K.esm.js +20 -0
  98. package/dist/{flowServices-PiNsxLfK.esm.js → flowServices-ChgTNggJ.esm.js} +10 -5
  99. package/dist/geolocation.d.ts +4 -4
  100. package/dist/geolocation.esm.js +6 -6
  101. package/dist/{geolocationStateMachine-asasuHY2.esm.js → geolocationStateMachine-Dvh7X0wF.esm.js} +5 -5
  102. package/dist/getBrowser-C8DP7oTB.esm.js +8 -0
  103. package/dist/{getBrowser-BSXUTWXw.esm.js → getDeviceClass-C0olyNFS.esm.js} +1 -8
  104. package/dist/{getDeviceClass-BSntT9_j.esm.js → getDeviceClass-C8Do2qYu.esm.js} +1 -1
  105. package/dist/government-validation.d.ts +28 -8
  106. package/dist/government-validation.esm.js +19 -8
  107. package/dist/{governmentValidationStateMachine-BDDYrJTo.esm.js → governmentValidationStateMachine-DcJ-BfsC.esm.js} +35 -77
  108. package/dist/home.d.ts +15 -14
  109. package/dist/home.esm.js +2 -2
  110. package/dist/http-Cai3IoLS.esm.js +0 -0
  111. package/dist/http.esm.js +1 -0
  112. package/dist/id-ocr.d.ts +54 -54
  113. package/dist/id-ocr.esm.js +5 -5
  114. package/dist/id-verification.d.ts +27 -27
  115. package/dist/id-verification.esm.js +4 -4
  116. package/dist/id.d.ts +12 -10
  117. package/dist/id.esm.js +70 -27
  118. package/dist/{idCaptureManager-Fyd0eam-.d.ts → idCaptureManager-ChCNmgBj.d.ts} +40 -20
  119. package/dist/{idCaptureManager-D0ktk7Hh.esm.js → idCaptureManager-D3pwWutw.esm.js} +22 -7
  120. package/dist/{idCaptureStateMachine-dwlBUjbC.esm.js → idCaptureStateMachine-B3AiDIsT.esm.js} +172 -123
  121. package/dist/{idOcrStateMachine-YbjjC_Gg.esm.js → idOcrStateMachine-CDQ5d_VM.esm.js} +4 -4
  122. package/dist/{idVerificationStateMachine-xbw9HP1Z.esm.js → idVerificationStateMachine-kRxwImzO.esm.js} +2 -2
  123. package/dist/identity-reuse.d.ts +4 -530
  124. package/dist/identity-reuse.esm.js +8 -274
  125. package/dist/identityReuseManager-C6n_97dw.esm.js +95 -0
  126. package/dist/identityReuseManager-Cww-NDtd.d.ts +428 -0
  127. package/dist/identityReuseStateMachine-BfE5YiEr.esm.js +148 -0
  128. package/dist/{index-BcRG8rtJ.d.ts → index-B5hPA0Bg.d.ts} +2 -2
  129. package/dist/{index-ChHWNH48.d.ts → index-B9NysVDB.d.ts} +469 -195
  130. package/dist/index.d.ts +2 -2
  131. package/dist/index.esm.js +10 -8
  132. package/dist/{invokeOnCaptureCallback-rc6kBHo5.esm.js → invokeOnCaptureCallback-ygByVdnn.esm.js} +1 -1
  133. package/dist/{lib-BB0B_qQX.esm.js → lib-BY67lgbq.esm.js} +1 -1
  134. package/dist/mandatory-consent.d.ts +8 -412
  135. package/dist/mandatory-consent.esm.js +6 -76
  136. package/dist/mandatoryConsentManager-Dq6WiOZh.d.ts +429 -0
  137. package/dist/mandatoryConsentManager-H6D18cZB.esm.js +89 -0
  138. package/dist/{mandatoryConsentStateMachine-Cnco1jvn.esm.js → mandatoryConsentStateMachine-DtQNW1ji.esm.js} +6 -6
  139. package/dist/openviduLazy-B8L--0oe.esm.js +3 -0
  140. package/dist/{openviduLazy-Cok70ZSg.esm.js → openviduLazy-Dh14JNJc.esm.js} +2 -2
  141. package/dist/otp-CGMdUzBC.esm.js +33 -0
  142. package/dist/otp-DF5A0sFx.d.ts +8 -0
  143. package/dist/permissionGuards-D0wGddy7.esm.js +23 -0
  144. package/dist/permissionServices-Doec4X5L.esm.js +130 -0
  145. package/dist/phone.d.ts +4 -3
  146. package/dist/phone.esm.js +6 -5
  147. package/dist/{phoneManager-DAJbGhlY.esm.js → phoneManager-BmF-0Ez4.esm.js} +30 -7
  148. package/dist/{phoneManager-B6M30hKE.d.ts → phoneManager-fPmIBYQK.d.ts} +65 -7
  149. package/dist/{phoneStateMachine-CuPARRaT.esm.js → phoneStateMachine-BiV0yoEx.esm.js} +46 -11
  150. package/dist/{qe-signature-DFo_Cc-I.esm.js → qe-signature-CUYPcHVo.esm.js} +1 -1
  151. package/dist/qe-signature.d.ts +3 -3
  152. package/dist/qe-signature.esm.js +6 -5
  153. package/dist/{recordingService-Ig2UgbLv.esm.js → recordingService-yRw7hfzU.esm.js} +197 -179
  154. package/dist/redirect-to-mobile.d.ts +6 -104
  155. package/dist/redirect-to-mobile.esm.js +6 -99
  156. package/dist/redirectToMobileManager-BNe3IzC_.d.ts +178 -0
  157. package/dist/redirectToMobileManager-Dy3t7o0C.esm.js +159 -0
  158. package/dist/{redirectToMobileStateMachine-BOEqe46A.esm.js → redirectToMobileStateMachine-DyAdRxfP.esm.js} +28 -19
  159. package/dist/{runChildModule-CqqwqAkW.esm.js → runChildModule-CuoHZ1cx.esm.js} +35 -3
  160. package/dist/selfie.d.ts +13 -11
  161. package/dist/selfie.esm.js +53 -24
  162. package/dist/{selfieManager-Duisl7qN.esm.js → selfieManager-BNuTIGAz.esm.js} +6 -6
  163. package/dist/{selfieManager-D0lSgd-J.d.ts → selfieManager-C2y_t6DG.d.ts} +4 -4
  164. package/dist/{selfieStateMachine-D76whWEf.esm.js → selfieStateMachine-Bv99bZJE.esm.js} +5 -3
  165. package/dist/session-DoVb-OcB.esm.js +152 -0
  166. package/dist/session.d.ts +37 -5
  167. package/dist/session.esm.js +12 -7
  168. package/dist/sessionInitializer-DRB-hgbV.esm.js +366 -0
  169. package/dist/{setup-C5AITV8m.d.ts → setup-BwCluiw3.d.ts} +86 -6
  170. package/dist/{setup-DPPAxmXf.esm.js → setup-CUO4mErT.esm.js} +175 -25
  171. package/dist/signature.d.ts +2 -2
  172. package/dist/signature.esm.js +4 -4
  173. package/dist/{signatureStateMachine-B5-QVUve.esm.js → signatureStateMachine-C5qqYLRz.esm.js} +3 -3
  174. package/dist/stats-BMNUG1AU.esm.js +41 -0
  175. package/dist/stats.d.ts +13 -2
  176. package/dist/stats.esm.js +3 -2
  177. package/dist/trust-graph.d.ts +33 -4
  178. package/dist/trust-graph.esm.js +21 -15
  179. package/dist/{types-CFV9G_7j.d.ts → types-Bj9hdFjU.d.ts} +1 -1
  180. package/dist/{types-BP1m8VRw.d.ts → types-DOUhndhT.d.ts} +14 -2
  181. package/dist/types-DsnEVMhr.esm.js +34 -0
  182. package/dist/types-DvGZI7BF.d.ts +131 -0
  183. package/dist/{types-B06Ypu2F.d.ts → types-NuT8ftBV.d.ts} +1 -1
  184. package/dist/types-ya0LN_MX.d.ts +5 -0
  185. package/dist/{warmup-CEcppFiS.d.ts → warmup-Dg8Lh-50.d.ts} +8 -0
  186. package/dist/wasm.d.ts +6 -4
  187. package/dist/wasm.esm.js +11 -9
  188. package/dist/watchlist-for-business.d.ts +1 -1
  189. package/dist/watchlist-for-business.esm.js +5 -73
  190. package/dist/watchlist.d.ts +1 -1
  191. package/dist/watchlist.esm.js +4 -41
  192. package/dist/watchlistForBusinessStateMachine-DMl8j2Ov.esm.js +74 -0
  193. package/dist/watchlistStateMachine-DmQlqI6L.esm.js +50 -0
  194. package/dist/workflow.d.ts +146 -100
  195. package/dist/workflow.esm.js +116 -66
  196. package/package.json +19 -1
  197. package/dist/StateMachine-BCQrZJhf.d.ts +0 -2
  198. package/dist/WasmUtilProvider-j98OJf-S.esm.js +0 -114
  199. package/dist/browserSimulation-gxD8cSpM.esm.js +0 -20
  200. package/dist/deepsightService-O74l4Y__.esm.js +0 -489
  201. package/dist/displayErrors-DqJ_IbsG.d.ts +0 -39
  202. package/dist/flowCompletionService-DhkT4SRY.d.ts +0 -10
  203. package/dist/flowCompletionService-P54yzGvA.esm.js +0 -13
  204. package/dist/openviduLazy-Cm0XFh_v.esm.js +0 -3
  205. package/dist/permissionServices-D_i6nzEw.esm.js +0 -50
  206. package/dist/stats-CIfiPzb1.esm.js +0 -16
  207. package/dist/types-CAD4va6a.d.ts +0 -5
  208. package/dist/watchlistServices-DMbUhkBX.esm.js +0 -12
  209. /package/dist/{Actor-CI32dTbG.d.ts → Actor-Y0_Fj-KL.d.ts} +0 -0
  210. /package/dist/{ITimerCapability-C67ZRskg.esm.js → ITimerCapability-CB0I1Uf2.esm.js} +0 -0
  211. /package/dist/{Manager-C8PrhBOx.d.ts → Manager-BHn8wH8K.d.ts} +0 -0
  212. /package/dist/{camera-PA2Ljri3.esm.js → camera-DJWm3V4g.esm.js} +0 -0
  213. /package/dist/{camera-DBSxa6ML.d.ts → camera-SRBpPq2X.d.ts} +0 -0
  214. /package/dist/{chunk-CRF6K_H_.esm.js → chunk-CMUKZ2uL.esm.js} +0 -0
  215. /package/dist/{cpf-PPz2Njto.esm.js → cpf-BRzggV8G.esm.js} +0 -0
  216. /package/dist/{dateUtils-UoN5xswP.esm.js → dateUtils-AksLQmgV.esm.js} +0 -0
  217. /package/dist/{platform-CfrjKhmi.esm.js → platform-SKvEfCBh.esm.js} +0 -0
  218. /package/dist/{xstate.esm-B70JrNqo.esm.js → xstate.esm-C9wncMQa.esm.js} +0 -0
@@ -0,0 +1,230 @@
1
+ //#region ../infra/src/media/canvas.ts
2
+ /**
3
+ * Class representing a canvas element for image capture and manipulation.
4
+ */
5
+ var IncodeCanvas = class IncodeCanvas {
6
+ /**
7
+ * Creates an {@link IncodeCanvas} from a raw {@link ImageData} frame.
8
+ * @param imageData - Frame pixels in RGBA format
9
+ * @returns An {@link IncodeCanvas} containing the provided pixels
10
+ */
11
+ static fromImageData(imageData) {
12
+ const canvas = document.createElement("canvas");
13
+ canvas.width = imageData.width;
14
+ canvas.height = imageData.height;
15
+ const context = canvas.getContext("2d", { willReadFrequently: true });
16
+ if (!context) return new IncodeCanvas(canvas);
17
+ if ("putImageData" in context) context.putImageData(imageData, 0, 0);
18
+ return new IncodeCanvas(canvas);
19
+ }
20
+ /**
21
+ * Create a new canvas element.
22
+ * @param canvas_ - The canvas element to clone.
23
+ */
24
+ constructor(canvas_) {
25
+ this.base64Image = null;
26
+ this.blobData = null;
27
+ this.canvas = document.createElement("canvas");
28
+ this.canvas.width = canvas_.width;
29
+ this.canvas.height = canvas_.height;
30
+ const context = this.canvas.getContext("2d");
31
+ if (context) context.drawImage(canvas_, 0, 0);
32
+ }
33
+ /**
34
+ * Check if the current canvas is valid.
35
+ */
36
+ checkCanvas() {
37
+ return this.canvas && this.canvas.width > 1 && this.canvas.height > 1;
38
+ }
39
+ /**
40
+ * Disposes of resources, including revoking object URLs to prevent memory leaks.
41
+ */
42
+ dispose() {
43
+ if (this.blobData?.url) {
44
+ URL.revokeObjectURL(this.blobData.url);
45
+ this.blobData = null;
46
+ }
47
+ this.base64Image = null;
48
+ }
49
+ /**
50
+ * Release the data stored by IncodeCanvas.
51
+ */
52
+ release() {
53
+ if (!this.checkCanvas()) return;
54
+ this.canvas.width = 1;
55
+ this.canvas.height = 1;
56
+ this.canvas.getContext("2d")?.clearRect(0, 0, 1, 1);
57
+ this.base64Image = null;
58
+ if (this.blobData?.url) URL.revokeObjectURL(this.blobData.url);
59
+ this.blobData = null;
60
+ }
61
+ /**
62
+ * Revokes the object URL if one exists, preventing memory leaks.
63
+ * Use this when you no longer need the preview image URL.
64
+ */
65
+ revokeObjectURL() {
66
+ if (this.blobData?.url) {
67
+ URL.revokeObjectURL(this.blobData.url);
68
+ this.blobData = {
69
+ ...this.blobData,
70
+ url: ""
71
+ };
72
+ }
73
+ }
74
+ /**
75
+ * Get the width of the canvas.
76
+ */
77
+ width() {
78
+ if (!this.checkCanvas()) return null;
79
+ return this.canvas.width;
80
+ }
81
+ /**
82
+ * Get the height of the canvas.
83
+ */
84
+ height() {
85
+ if (!this.checkCanvas()) return null;
86
+ return this.canvas.height;
87
+ }
88
+ /**
89
+ * Set the width of the canvas.
90
+ */
91
+ setWidth(width) {
92
+ if (!this.checkCanvas()) return;
93
+ this.canvas.width = width;
94
+ }
95
+ /**
96
+ * Set the height of the canvas.
97
+ */
98
+ setHeight(height) {
99
+ if (!this.checkCanvas()) return;
100
+ this.canvas.height = height;
101
+ }
102
+ /**
103
+ * Clone the current canvas.
104
+ */
105
+ clone() {
106
+ if (!this.checkCanvas()) return null;
107
+ const cloned = new IncodeCanvas(this.canvas);
108
+ cloned.setBase64Image(this.base64Image);
109
+ return cloned;
110
+ }
111
+ /**
112
+ * Deep clone the current IncodeCanvas including blob data.
113
+ */
114
+ async deepClone() {
115
+ const cloned = this.clone();
116
+ if (!cloned) return null;
117
+ if (this.blobData) await cloned.setBlobData(this.blobData);
118
+ return cloned;
119
+ }
120
+ /**
121
+ * Returns the drawing context on the canvas.
122
+ */
123
+ getContext(contextId, contextAttributes) {
124
+ if (!this.checkCanvas()) return null;
125
+ const context = this.canvas.getContext(contextId, contextAttributes);
126
+ return context instanceof CanvasRenderingContext2D ? context : null;
127
+ }
128
+ /**
129
+ * Retrieves the image data from the canvas.
130
+ */
131
+ getImageData() {
132
+ if (!this.checkCanvas()) return null;
133
+ const context = this.canvas.getContext("2d", { willReadFrequently: true });
134
+ if (!context) return null;
135
+ return context.getImageData(0, 0, this.canvas.width, this.canvas.height);
136
+ }
137
+ /**
138
+ * Updates the base64 representation of the current canvas image.
139
+ */
140
+ updateBase64Image(jpegQuality = 1) {
141
+ if (!this.checkCanvas()) return;
142
+ this.base64Image = this.canvas.toDataURL("image/jpeg", jpegQuality);
143
+ }
144
+ /**
145
+ * Converts the current canvas element to a base64 string.
146
+ */
147
+ getBase64Image(jpegQuality = 1, includeDataURLPrefix = false) {
148
+ if (!this.checkCanvas()) return null;
149
+ if (this.base64Image === null) this.updateBase64Image(jpegQuality);
150
+ const base64Image = this.base64Image;
151
+ if (base64Image === null) return null;
152
+ if (includeDataURLPrefix) return base64Image;
153
+ const commaIndex = base64Image.indexOf(",");
154
+ if (commaIndex === -1) return base64Image;
155
+ return base64Image.slice(commaIndex + 1);
156
+ }
157
+ /**
158
+ * Sets the base64 representation of the current canvas image.
159
+ */
160
+ setBase64Image(base64Image) {
161
+ this.base64Image = base64Image;
162
+ }
163
+ /**
164
+ * Updates the Blob representation of the current canvas image.
165
+ */
166
+ updateBlob(jpegQuality = 1, includeDataURLPrefix = false) {
167
+ if (!this.checkCanvas()) return;
168
+ if (this.base64Image === null) this.updateBase64Image(jpegQuality);
169
+ const base64 = this.getBase64Image(jpegQuality, includeDataURLPrefix);
170
+ if (base64) this.blobData = IncodeCanvas.base64ToBlob(base64);
171
+ }
172
+ /**
173
+ * Converts a base64 string to a Blob and creates a URL for it.
174
+ */
175
+ static base64ToBlob(base64) {
176
+ try {
177
+ const binary = atob(base64);
178
+ const array = [];
179
+ for (let i = 0; i < binary.length; i++) array.push(binary.charCodeAt(i));
180
+ const blob = new Blob([new Uint8Array(array)]);
181
+ return {
182
+ blob,
183
+ url: URL.createObjectURL(blob)
184
+ };
185
+ } catch (error) {
186
+ console.error("Failed to convert base64 string to Blob:", error);
187
+ }
188
+ return null;
189
+ }
190
+ /**
191
+ * Retrieves the Blob data and its URL from the current canvas.
192
+ */
193
+ getBlobData(jpegQuality = 1, includeDataURLPrefix = false) {
194
+ if (!this.checkCanvas()) return null;
195
+ if (this.blobData === null) this.updateBlob(jpegQuality, includeDataURLPrefix);
196
+ return this.blobData;
197
+ }
198
+ /**
199
+ * Sets the Blob data of the current canvas image.
200
+ */
201
+ async setBlobData(blobData) {
202
+ const blobDataArrayBuffer = await blobData.blob.arrayBuffer();
203
+ this.blobData = {
204
+ blob: new Blob([blobDataArrayBuffer], { type: blobData.blob.type }),
205
+ url: blobData.url
206
+ };
207
+ }
208
+ /**
209
+ * Returns a resized canvas according to video element size.
210
+ */
211
+ getResizedCanvas(videoElementWidth, videoElementHeight) {
212
+ if (!this.checkCanvas()) return null;
213
+ const cameraOffsetX = Math.abs(videoElementWidth - window.innerWidth);
214
+ const resized = new IncodeCanvas(document.createElement("canvas"));
215
+ const canvasHeight = this.height();
216
+ if (!canvasHeight) return null;
217
+ const ratio = canvasHeight / videoElementHeight;
218
+ const newWidth = window.innerWidth;
219
+ const newHeight = window.innerHeight;
220
+ resized.setWidth(newWidth);
221
+ resized.setHeight(newHeight);
222
+ const context = resized.getContext("2d");
223
+ if (!context) return null;
224
+ context.drawImage(this.canvas, ratio * cameraOffsetX / 2, 0, ratio * newWidth, ratio * newHeight, 0, 0, newWidth, newHeight);
225
+ return resized;
226
+ }
227
+ };
228
+
229
+ //#endregion
230
+ export { IncodeCanvas as t };
package/dist/consent.d.ts CHANGED
@@ -1,398 +1,4 @@
1
- import { t as Manager } from "./Manager-C8PrhBOx.js";
2
- import "./Actor-CI32dTbG.js";
3
- import * as xstate0 from "xstate";
4
-
5
- //#region src/modules/consent/types.d.ts
6
- type ConsentConfig = {
7
- combinedConsents?: string;
8
- consentId?: string;
9
- };
10
- type ConsentCheckbox = {
11
- id: string;
12
- label: string;
13
- required: boolean;
14
- checked: boolean;
15
- };
16
- type FetchCombinedConsentResponse = {
17
- languageConsentId: string;
18
- terms: string;
19
- title: string;
20
- consents: Array<{
21
- checkboxId: string;
22
- consentText: string;
23
- optional: boolean;
24
- }>;
25
- };
26
- //#endregion
27
- //#region src/modules/consent/consentStateMachine.d.ts
28
- type ConsentContext = {
29
- config: ConsentConfig;
30
- title: string;
31
- richText: string;
32
- languageConsentId: string;
33
- checkboxes: ConsentCheckbox[];
34
- error: string | undefined;
35
- };
36
- type ConsentInput = {
37
- config: ConsentConfig;
38
- };
39
- declare const consentMachine: xstate0.StateMachine<ConsentContext, {
40
- type: "LOAD";
41
- } | {
42
- type: "TOGGLE_CHECKBOX";
43
- checkboxId: string;
44
- } | {
45
- type: "SUBMIT";
46
- } | {
47
- type: "RETRY";
48
- } | {
49
- type: "RESET";
50
- }, {
51
- [x: string]: xstate0.ActorRefFromLogic<xstate0.PromiseActorLogic<FetchCombinedConsentResponse, {
52
- consentId: string;
53
- }, xstate0.EventObject>> | xstate0.ActorRefFromLogic<xstate0.PromiseActorLogic<void, {
54
- languageConsentId: string;
55
- checkboxes: ConsentCheckbox[];
56
- }, xstate0.EventObject>> | undefined;
57
- }, xstate0.Values<{
58
- fetchConsent: {
59
- src: "fetchConsent";
60
- logic: xstate0.PromiseActorLogic<FetchCombinedConsentResponse, {
61
- consentId: string;
62
- }, xstate0.EventObject>;
63
- id: string | undefined;
64
- };
65
- submitConsent: {
66
- src: "submitConsent";
67
- logic: xstate0.PromiseActorLogic<void, {
68
- languageConsentId: string;
69
- checkboxes: ConsentCheckbox[];
70
- }, xstate0.EventObject>;
71
- id: string | undefined;
72
- };
73
- }>, xstate0.Values<{
74
- setConsentData: {
75
- type: "setConsentData";
76
- params: xstate0.NonReducibleUnknown;
77
- };
78
- toggleCheckbox: {
79
- type: "toggleCheckbox";
80
- params: xstate0.NonReducibleUnknown;
81
- };
82
- setError: {
83
- type: "setError";
84
- params: xstate0.NonReducibleUnknown;
85
- };
86
- clearError: {
87
- type: "clearError";
88
- params: xstate0.NonReducibleUnknown;
89
- };
90
- resetContext: {
91
- type: "resetContext";
92
- params: xstate0.NonReducibleUnknown;
93
- };
94
- }>, {
95
- type: "canSubmit";
96
- params: unknown;
97
- }, never, "error" | "idle" | "finished" | "loading" | "display" | "submitting", string, ConsentInput, xstate0.NonReducibleUnknown, xstate0.EventObject, xstate0.MetaObject, {
98
- readonly id: "consent";
99
- readonly initial: "idle";
100
- readonly context: ({
101
- input
102
- }: {
103
- spawn: {
104
- <TSrc extends "fetchConsent" | "submitConsent">(logic: TSrc, ...[options]: ({
105
- src: "fetchConsent";
106
- logic: xstate0.PromiseActorLogic<FetchCombinedConsentResponse, {
107
- consentId: string;
108
- }, xstate0.EventObject>;
109
- id: string | undefined;
110
- } extends infer T ? T extends {
111
- src: "fetchConsent";
112
- logic: xstate0.PromiseActorLogic<FetchCombinedConsentResponse, {
113
- consentId: string;
114
- }, xstate0.EventObject>;
115
- id: string | undefined;
116
- } ? T extends {
117
- src: TSrc;
118
- } ? xstate0.ConditionalRequired<[options?: ({
119
- id?: T["id"] | undefined;
120
- systemId?: string;
121
- input?: xstate0.InputFrom<T["logic"]> | undefined;
122
- syncSnapshot?: boolean;
123
- } & { [K in xstate0.RequiredActorOptions<T>]: unknown }) | undefined], xstate0.IsNotNever<xstate0.RequiredActorOptions<T>>> : never : never : never) | ({
124
- src: "submitConsent";
125
- logic: xstate0.PromiseActorLogic<void, {
126
- languageConsentId: string;
127
- checkboxes: ConsentCheckbox[];
128
- }, xstate0.EventObject>;
129
- id: string | undefined;
130
- } extends infer T_1 ? T_1 extends {
131
- src: "submitConsent";
132
- logic: xstate0.PromiseActorLogic<void, {
133
- languageConsentId: string;
134
- checkboxes: ConsentCheckbox[];
135
- }, xstate0.EventObject>;
136
- id: string | undefined;
137
- } ? T_1 extends {
138
- src: TSrc;
139
- } ? xstate0.ConditionalRequired<[options?: ({
140
- id?: T_1["id"] | undefined;
141
- systemId?: string;
142
- input?: xstate0.InputFrom<T_1["logic"]> | undefined;
143
- syncSnapshot?: boolean;
144
- } & { [K_1 in xstate0.RequiredActorOptions<T_1>]: unknown }) | undefined], xstate0.IsNotNever<xstate0.RequiredActorOptions<T_1>>> : never : never : never)): xstate0.ActorRefFromLogic<xstate0.GetConcreteByKey<xstate0.Values<{
145
- fetchConsent: {
146
- src: "fetchConsent";
147
- logic: xstate0.PromiseActorLogic<FetchCombinedConsentResponse, {
148
- consentId: string;
149
- }, xstate0.EventObject>;
150
- id: string | undefined;
151
- };
152
- submitConsent: {
153
- src: "submitConsent";
154
- logic: xstate0.PromiseActorLogic<void, {
155
- languageConsentId: string;
156
- checkboxes: ConsentCheckbox[];
157
- }, xstate0.EventObject>;
158
- id: string | undefined;
159
- };
160
- }>, "src", TSrc>["logic"]>;
161
- <TLogic extends xstate0.AnyActorLogic>(src: TLogic, ...[options]: xstate0.ConditionalRequired<[options?: ({
162
- id?: never;
163
- systemId?: string;
164
- input?: xstate0.InputFrom<TLogic> | undefined;
165
- syncSnapshot?: boolean;
166
- } & { [K in xstate0.RequiredLogicInput<TLogic>]: unknown }) | undefined], xstate0.IsNotNever<xstate0.RequiredLogicInput<TLogic>>>): xstate0.ActorRefFromLogic<TLogic>;
167
- };
168
- input: ConsentInput;
169
- self: xstate0.ActorRef<xstate0.MachineSnapshot<ConsentContext, {
170
- type: "LOAD";
171
- } | {
172
- type: "TOGGLE_CHECKBOX";
173
- checkboxId: string;
174
- } | {
175
- type: "SUBMIT";
176
- } | {
177
- type: "RETRY";
178
- } | {
179
- type: "RESET";
180
- }, Record<string, xstate0.AnyActorRef | undefined>, xstate0.StateValue, string, unknown, any, any>, {
181
- type: "LOAD";
182
- } | {
183
- type: "TOGGLE_CHECKBOX";
184
- checkboxId: string;
185
- } | {
186
- type: "SUBMIT";
187
- } | {
188
- type: "RETRY";
189
- } | {
190
- type: "RESET";
191
- }, xstate0.AnyEventObject>;
192
- }) => {
193
- config: ConsentConfig;
194
- title: string;
195
- richText: string;
196
- languageConsentId: string;
197
- checkboxes: never[];
198
- error: undefined;
199
- };
200
- readonly states: {
201
- readonly idle: {
202
- readonly on: {
203
- readonly LOAD: {
204
- readonly target: "loading";
205
- readonly actions: "clearError";
206
- };
207
- };
208
- };
209
- readonly loading: {
210
- readonly invoke: {
211
- readonly id: "fetchConsent";
212
- readonly src: "fetchConsent";
213
- readonly input: ({
214
- context
215
- }: {
216
- context: ConsentContext;
217
- event: {
218
- type: "LOAD";
219
- } | {
220
- type: "TOGGLE_CHECKBOX";
221
- checkboxId: string;
222
- } | {
223
- type: "SUBMIT";
224
- } | {
225
- type: "RETRY";
226
- } | {
227
- type: "RESET";
228
- };
229
- self: xstate0.ActorRef<xstate0.MachineSnapshot<ConsentContext, {
230
- type: "LOAD";
231
- } | {
232
- type: "TOGGLE_CHECKBOX";
233
- checkboxId: string;
234
- } | {
235
- type: "SUBMIT";
236
- } | {
237
- type: "RETRY";
238
- } | {
239
- type: "RESET";
240
- }, Record<string, xstate0.AnyActorRef>, xstate0.StateValue, string, unknown, any, any>, {
241
- type: "LOAD";
242
- } | {
243
- type: "TOGGLE_CHECKBOX";
244
- checkboxId: string;
245
- } | {
246
- type: "SUBMIT";
247
- } | {
248
- type: "RETRY";
249
- } | {
250
- type: "RESET";
251
- }, xstate0.AnyEventObject>;
252
- }) => {
253
- consentId: string;
254
- };
255
- readonly onDone: {
256
- readonly target: "display";
257
- readonly actions: "setConsentData";
258
- };
259
- readonly onError: {
260
- readonly target: "error";
261
- readonly actions: "setError";
262
- };
263
- };
264
- };
265
- readonly display: {
266
- readonly on: {
267
- readonly TOGGLE_CHECKBOX: {
268
- readonly actions: "toggleCheckbox";
269
- };
270
- readonly SUBMIT: {
271
- readonly target: "submitting";
272
- readonly guard: "canSubmit";
273
- };
274
- readonly RETRY: {
275
- readonly target: "loading";
276
- readonly actions: "clearError";
277
- };
278
- };
279
- };
280
- readonly submitting: {
281
- readonly invoke: {
282
- readonly id: "submitConsent";
283
- readonly src: "submitConsent";
284
- readonly input: ({
285
- context
286
- }: {
287
- context: ConsentContext;
288
- event: {
289
- type: "LOAD";
290
- } | {
291
- type: "TOGGLE_CHECKBOX";
292
- checkboxId: string;
293
- } | {
294
- type: "SUBMIT";
295
- } | {
296
- type: "RETRY";
297
- } | {
298
- type: "RESET";
299
- };
300
- self: xstate0.ActorRef<xstate0.MachineSnapshot<ConsentContext, {
301
- type: "LOAD";
302
- } | {
303
- type: "TOGGLE_CHECKBOX";
304
- checkboxId: string;
305
- } | {
306
- type: "SUBMIT";
307
- } | {
308
- type: "RETRY";
309
- } | {
310
- type: "RESET";
311
- }, Record<string, xstate0.AnyActorRef>, xstate0.StateValue, string, unknown, any, any>, {
312
- type: "LOAD";
313
- } | {
314
- type: "TOGGLE_CHECKBOX";
315
- checkboxId: string;
316
- } | {
317
- type: "SUBMIT";
318
- } | {
319
- type: "RETRY";
320
- } | {
321
- type: "RESET";
322
- }, xstate0.AnyEventObject>;
323
- }) => {
324
- languageConsentId: string;
325
- checkboxes: ConsentCheckbox[];
326
- };
327
- readonly onDone: {
328
- readonly target: "finished";
329
- };
330
- readonly onError: {
331
- readonly target: "display";
332
- readonly actions: "setError";
333
- };
334
- };
335
- };
336
- readonly error: {
337
- readonly on: {
338
- readonly RETRY: {
339
- readonly target: "loading";
340
- readonly actions: "clearError";
341
- };
342
- readonly RESET: {
343
- readonly target: "idle";
344
- readonly actions: "resetContext";
345
- };
346
- };
347
- };
348
- readonly finished: {
349
- readonly type: "final";
350
- };
351
- };
352
- }>;
353
- //#endregion
354
- //#region src/modules/consent/consentActor.d.ts
355
- type CreateConsentActorOptions = {
356
- config: ConsentConfig;
357
- };
358
- //#endregion
359
- //#region src/modules/consent/consentManager.d.ts
360
- type ConsentIdleState = {
361
- status: 'idle';
362
- };
363
- type ConsentLoadingState = {
364
- status: 'loading';
365
- };
366
- type ConsentDisplayState = {
367
- status: 'display';
368
- title: string;
369
- richText: string;
370
- checkboxes: ConsentCheckbox[];
371
- canSubmit: boolean;
372
- error?: string;
373
- };
374
- type ConsentSubmittingState = {
375
- status: 'submitting';
376
- title: string;
377
- richText: string;
378
- checkboxes: ConsentCheckbox[];
379
- canSubmit: false;
380
- };
381
- type ConsentFinishedState = {
382
- status: 'finished';
383
- };
384
- type ConsentErrorState = {
385
- status: 'error';
386
- error: string;
387
- };
388
- type ConsentState = ConsentIdleState | ConsentLoadingState | ConsentDisplayState | ConsentSubmittingState | ConsentFinishedState | ConsentErrorState;
389
- declare function createConsentManager(options: CreateConsentActorOptions): Manager<ConsentState> & {
390
- load(): void;
391
- toggleCheckbox(checkboxId: string): void;
392
- submit(): void;
393
- retry(): void;
394
- reset(): void;
395
- };
396
- type ConsentManager = ReturnType<typeof createConsentManager>;
397
- //#endregion
398
- export { type ConsentCheckbox, type ConsentConfig, type ConsentManager, type ConsentState, consentMachine, createConsentManager };
1
+ import "./Manager-BHn8wH8K.js";
2
+ import "./Actor-Y0_Fj-KL.js";
3
+ import { a as ConsentActor, c as ConsentConfig, i as createConsentManagerFromActor, n as ConsentState, o as consentMachine, r as createConsentManager, s as ConsentCheckbox, t as ConsentManager } from "./consentManager-Cg5Sk2tv.js";
4
+ export { type ConsentActor, type ConsentCheckbox, type ConsentConfig, type ConsentManager, type ConsentState, consentMachine, createConsentManager, createConsentManagerFromActor };