@snap/camera-kit 0.7.0

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 (554) hide show
  1. package/LICENSE.md +6247 -0
  2. package/README.md +166 -0
  3. package/docs/html/.nojekyll +1 -0
  4. package/docs/html/assets/highlight.css +106 -0
  5. package/docs/html/assets/main.js +54 -0
  6. package/docs/html/assets/search.js +1 -0
  7. package/docs/html/assets/style.css +1225 -0
  8. package/docs/html/assets/widgets.png +0 -0
  9. package/docs/html/assets/widgets@2x.png +0 -0
  10. package/docs/html/classes/CameraKit.html +121 -0
  11. package/docs/html/classes/CameraKitSession.html +347 -0
  12. package/docs/html/classes/CameraKitSource.html +152 -0
  13. package/docs/html/classes/LensPerformanceMeasurement.html +115 -0
  14. package/docs/html/classes/LensPerformanceMetrics.html +76 -0
  15. package/docs/html/classes/LensRepository.html +171 -0
  16. package/docs/html/classes/LensSources.html +82 -0
  17. package/docs/html/classes/Transform2D.html +99 -0
  18. package/docs/html/classes/TypedCustomEvent.html +109 -0
  19. package/docs/html/classes/TypedEventTarget.html +146 -0
  20. package/docs/html/functions/Injectable.html +193 -0
  21. package/docs/html/functions/bootstrapCameraKit.html +158 -0
  22. package/docs/html/functions/createExtension.html +127 -0
  23. package/docs/html/functions/createImageSource.html +123 -0
  24. package/docs/html/functions/createMediaStreamSource.html +123 -0
  25. package/docs/html/functions/createUserMediaSource.html +127 -0
  26. package/docs/html/functions/createVideoSource.html +124 -0
  27. package/docs/html/functions/estimateLensPerformance.html +116 -0
  28. package/docs/html/functions/getRequiredBootstrapURLs.html +124 -0
  29. package/docs/html/functions/lensSourcesFactory.html +116 -0
  30. package/docs/html/functions/uriHandlersFactory.html +118 -0
  31. package/docs/html/index.html +208 -0
  32. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +132 -0
  33. package/docs/html/interfaces/CameraKitSourceSubscriber.html +121 -0
  34. package/docs/html/interfaces/ComputedFrameMetrics.html +70 -0
  35. package/docs/html/interfaces/CreateSessionOptions.html +77 -0
  36. package/docs/html/interfaces/EstimatedLensPerformance.html +78 -0
  37. package/docs/html/interfaces/Lens.html +115 -0
  38. package/docs/html/interfaces/LensSource.html +113 -0
  39. package/docs/html/interfaces/MediaStreamSourceOptions.html +65 -0
  40. package/docs/html/interfaces/UriCancelRequest.html +65 -0
  41. package/docs/html/interfaces/UriHandler.html +128 -0
  42. package/docs/html/interfaces/UriRequest.html +80 -0
  43. package/docs/html/interfaces/UriResponse.html +80 -0
  44. package/docs/html/interfaces/VideoSourceOptions.html +60 -0
  45. package/docs/html/modules.html +198 -0
  46. package/docs/html/types/AssetLoader.html +126 -0
  47. package/docs/html/types/AssetTiming.html +116 -0
  48. package/docs/html/types/BenchmarkError.html +107 -0
  49. package/docs/html/types/BootstrapError.html +110 -0
  50. package/docs/html/types/CacheKeyNotFoundError.html +107 -0
  51. package/docs/html/types/CameraKitDeviceInfo.html +114 -0
  52. package/docs/html/types/CameraKitSessionEventListener.html +109 -0
  53. package/docs/html/types/CameraKitSessionEvents.html +118 -0
  54. package/docs/html/types/CameraKitSourceError.html +107 -0
  55. package/docs/html/types/CameraKitSourceInfo.html +107 -0
  56. package/docs/html/types/CameraKitSourceOptions.html +113 -0
  57. package/docs/html/types/ConfigurationError.html +109 -0
  58. package/docs/html/types/Keyboard.html +196 -0
  59. package/docs/html/types/KeyboardEvents.html +109 -0
  60. package/docs/html/types/LegalError.html +107 -0
  61. package/docs/html/types/LensAssetError.html +109 -0
  62. package/docs/html/types/LensContentValidationError.html +107 -0
  63. package/docs/html/types/LensError.html +107 -0
  64. package/docs/html/types/LensExecutionError.html +114 -0
  65. package/docs/html/types/LensImagePickerError.html +110 -0
  66. package/docs/html/types/LensLaunchParams.html +109 -0
  67. package/docs/html/types/LensMetricsEvents.html +110 -0
  68. package/docs/html/types/LensPerformanceCluster.html +107 -0
  69. package/docs/html/types/LensView.html +119 -0
  70. package/docs/html/types/LensWait.html +111 -0
  71. package/docs/html/types/PersistentStoreError.html +109 -0
  72. package/docs/html/types/PlatformNotSupportedError.html +110 -0
  73. package/docs/html/types/PublicContainer.html +110 -0
  74. package/docs/html/types/RenderTarget.html +111 -0
  75. package/docs/html/types/Uri.html +107 -0
  76. package/docs/html/types/UriHandlers.html +109 -0
  77. package/docs/html/types/WebGLError.html +107 -0
  78. package/docs/html/variables/extensionRequestContext.html +109 -0
  79. package/docs/md/.nojekyll +1 -0
  80. package/docs/md/README.md +168 -0
  81. package/docs/md/classes/CameraKit.md +94 -0
  82. package/docs/md/classes/CameraKitSession.md +359 -0
  83. package/docs/md/classes/CameraKitSource.md +110 -0
  84. package/docs/md/classes/LensPerformanceMeasurement.md +77 -0
  85. package/docs/md/classes/LensPerformanceMetrics.md +37 -0
  86. package/docs/md/classes/LensRepository.md +145 -0
  87. package/docs/md/classes/LensSources.md +29 -0
  88. package/docs/md/classes/Transform2D.md +55 -0
  89. package/docs/md/classes/TypedCustomEvent.md +65 -0
  90. package/docs/md/classes/TypedEventTarget.md +103 -0
  91. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +106 -0
  92. package/docs/md/interfaces/CameraKitSourceSubscriber.md +55 -0
  93. package/docs/md/interfaces/ComputedFrameMetrics.md +29 -0
  94. package/docs/md/interfaces/CreateSessionOptions.md +35 -0
  95. package/docs/md/interfaces/EstimatedLensPerformance.md +38 -0
  96. package/docs/md/interfaces/Lens.md +84 -0
  97. package/docs/md/interfaces/LensSource.md +68 -0
  98. package/docs/md/interfaces/MediaStreamSourceOptions.md +22 -0
  99. package/docs/md/interfaces/UriCancelRequest.md +22 -0
  100. package/docs/md/interfaces/UriHandler.md +63 -0
  101. package/docs/md/interfaces/UriRequest.md +43 -0
  102. package/docs/md/interfaces/UriResponse.md +43 -0
  103. package/docs/md/interfaces/VideoSourceOptions.md +15 -0
  104. package/docs/md/modules.md +827 -0
  105. package/lib/CameraKit.d.ts +170 -0
  106. package/lib/CameraKit.js +145 -0
  107. package/lib/CameraKit.js.map +1 -0
  108. package/lib/__tests__/data.d.ts +9 -0
  109. package/lib/__tests__/data.js +50 -0
  110. package/lib/__tests__/data.js.map +1 -0
  111. package/lib/__tests__/deferred.d.ts +16 -0
  112. package/lib/__tests__/deferred.js +29 -0
  113. package/lib/__tests__/deferred.js.map +1 -0
  114. package/lib/__tests__/jest.matchers.d.ts +17 -0
  115. package/lib/__tests__/jest.matchers.js +67 -0
  116. package/lib/__tests__/jest.matchers.js.map +1 -0
  117. package/lib/assertPlatformSupported.d.ts +4 -0
  118. package/lib/assertPlatformSupported.js +10 -0
  119. package/lib/assertPlatformSupported.js.map +1 -0
  120. package/lib/benchmark/benchmarkGflops.d.ts +16 -0
  121. package/lib/benchmark/benchmarkGflops.js +129 -0
  122. package/lib/benchmark/benchmarkGflops.js.map +1 -0
  123. package/lib/benchmark/estimateLensPerformanceCluster.d.ts +33 -0
  124. package/lib/benchmark/estimateLensPerformanceCluster.js +48 -0
  125. package/lib/benchmark/estimateLensPerformanceCluster.js.map +1 -0
  126. package/lib/benchmark/webglUtils.d.ts +7 -0
  127. package/lib/benchmark/webglUtils.js +87 -0
  128. package/lib/benchmark/webglUtils.js.map +1 -0
  129. package/lib/bootstrapCameraKit.d.ts +96 -0
  130. package/lib/bootstrapCameraKit.js +204 -0
  131. package/lib/bootstrapCameraKit.js.map +1 -0
  132. package/lib/common/__mocks__/loadScript.d.ts +1 -0
  133. package/lib/common/__mocks__/loadScript.js +10 -0
  134. package/lib/common/__mocks__/loadScript.js.map +1 -0
  135. package/lib/common/assertions.d.ts +27 -0
  136. package/lib/common/assertions.js +39 -0
  137. package/lib/common/assertions.js.map +1 -0
  138. package/lib/common/cameraKitUserAgent.d.ts +34 -0
  139. package/lib/common/cameraKitUserAgent.js +216 -0
  140. package/lib/common/cameraKitUserAgent.js.map +1 -0
  141. package/lib/common/copyDefinedProperties.d.ts +13 -0
  142. package/lib/common/copyDefinedProperties.js +16 -0
  143. package/lib/common/copyDefinedProperties.js.map +1 -0
  144. package/lib/common/entries.d.ts +3 -0
  145. package/lib/common/entries.js +3 -0
  146. package/lib/common/entries.js.map +1 -0
  147. package/lib/common/errorHelpers.d.ts +10 -0
  148. package/lib/common/errorHelpers.js +24 -0
  149. package/lib/common/errorHelpers.js.map +1 -0
  150. package/lib/common/getFilename.d.ts +1 -0
  151. package/lib/common/getFilename.js +4 -0
  152. package/lib/common/getFilename.js.map +1 -0
  153. package/lib/common/index.d.ts +2 -0
  154. package/lib/common/index.js +3 -0
  155. package/lib/common/index.js.map +1 -0
  156. package/lib/common/loadScript.d.ts +1 -0
  157. package/lib/common/loadScript.js +11 -0
  158. package/lib/common/loadScript.js.map +1 -0
  159. package/lib/common/locale.d.ts +2 -0
  160. package/lib/common/locale.js +11 -0
  161. package/lib/common/locale.js.map +1 -0
  162. package/lib/common/localization.d.ts +43 -0
  163. package/lib/common/localization.js +43 -0
  164. package/lib/common/localization.js.map +1 -0
  165. package/lib/common/memoize.d.ts +8 -0
  166. package/lib/common/memoize.js +15 -0
  167. package/lib/common/memoize.js.map +1 -0
  168. package/lib/common/pageVisibility.d.ts +20 -0
  169. package/lib/common/pageVisibility.js +62 -0
  170. package/lib/common/pageVisibility.js.map +1 -0
  171. package/lib/common/time.d.ts +1 -0
  172. package/lib/common/time.js +2 -0
  173. package/lib/common/time.js.map +1 -0
  174. package/lib/common/typeguards.d.ts +53 -0
  175. package/lib/common/typeguards.js +92 -0
  176. package/lib/common/typeguards.js.map +1 -0
  177. package/lib/common/types.d.ts +10 -0
  178. package/lib/common/types.js +2 -0
  179. package/lib/common/types.js.map +1 -0
  180. package/lib/common/validate.d.ts +14 -0
  181. package/lib/common/validate.js +104 -0
  182. package/lib/common/validate.js.map +1 -0
  183. package/lib/configuration.d.ts +92 -0
  184. package/lib/configuration.js +36 -0
  185. package/lib/configuration.js.map +1 -0
  186. package/lib/configurationOverrides.d.ts +12 -0
  187. package/lib/configurationOverrides.js +41 -0
  188. package/lib/configurationOverrides.js.map +1 -0
  189. package/lib/dependency-injection/Container.d.ts +177 -0
  190. package/lib/dependency-injection/Container.js +160 -0
  191. package/lib/dependency-injection/Container.js.map +1 -0
  192. package/lib/dependency-injection/Injectable.d.ts +39 -0
  193. package/lib/dependency-injection/Injectable.js +18 -0
  194. package/lib/dependency-injection/Injectable.js.map +1 -0
  195. package/lib/dependency-injection/PartialContainer.d.ts +81 -0
  196. package/lib/dependency-injection/PartialContainer.js +85 -0
  197. package/lib/dependency-injection/PartialContainer.js.map +1 -0
  198. package/lib/dependency-injection/RootServices.d.ts +62 -0
  199. package/lib/dependency-injection/RootServices.js +2 -0
  200. package/lib/dependency-injection/RootServices.js.map +1 -0
  201. package/lib/dependency-injection/types.d.ts +56 -0
  202. package/lib/dependency-injection/types.js +2 -0
  203. package/lib/dependency-injection/types.js.map +1 -0
  204. package/lib/environment.json +1 -0
  205. package/lib/events/TypedCustomEvent.d.ts +10 -0
  206. package/lib/events/TypedCustomEvent.js +11 -0
  207. package/lib/events/TypedCustomEvent.js.map +1 -0
  208. package/lib/events/TypedEventTarget.d.ts +25 -0
  209. package/lib/events/TypedEventTarget.js +57 -0
  210. package/lib/events/TypedEventTarget.js.map +1 -0
  211. package/lib/events/scan.d.ts +15 -0
  212. package/lib/events/scan.js +46 -0
  213. package/lib/events/scan.js.map +1 -0
  214. package/lib/extensions/LensSources.d.ts +58 -0
  215. package/lib/extensions/LensSources.js +50 -0
  216. package/lib/extensions/LensSources.js.map +1 -0
  217. package/lib/extensions/UriHandlers.d.ts +54 -0
  218. package/lib/extensions/UriHandlers.js +93 -0
  219. package/lib/extensions/UriHandlers.js.map +1 -0
  220. package/lib/extensions/extensionRequestContext.d.ts +4 -0
  221. package/lib/extensions/extensionRequestContext.js +14 -0
  222. package/lib/extensions/extensionRequestContext.js.map +1 -0
  223. package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +5603 -0
  224. package/lib/generated-proto/blizzard/cameraKitEvents.js +522 -0
  225. package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -0
  226. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +98 -0
  227. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +260 -0
  228. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -0
  229. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +543 -0
  230. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +429 -0
  231. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -0
  232. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +100 -0
  233. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +164 -0
  234. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -0
  235. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +395 -0
  236. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +644 -0
  237. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -0
  238. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +185 -0
  239. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +172 -0
  240. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -0
  241. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +86 -0
  242. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +234 -0
  243. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -0
  244. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +854 -0
  245. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +629 -0
  246. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -0
  247. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +86 -0
  248. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +185 -0
  249. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -0
  250. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +95 -0
  251. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js +104 -0
  252. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -0
  253. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +10212 -0
  254. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +1300 -0
  255. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -0
  256. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +401 -0
  257. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +525 -0
  258. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -0
  259. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +1287 -0
  260. package/lib/generated-proto/pb_schema/cdp/cof/config_response.js +135 -0
  261. package/lib/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -0
  262. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +4208 -0
  263. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +1053 -0
  264. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -0
  265. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +102 -0
  266. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js +165 -0
  267. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -0
  268. package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +8 -0
  269. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +17 -0
  270. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -0
  271. package/lib/generated-proto/pb_schema/common/ruid.d.ts +75 -0
  272. package/lib/generated-proto/pb_schema/common/ruid.js +96 -0
  273. package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -0
  274. package/lib/generated-proto/pb_schema/common/value.d.ts +131 -0
  275. package/lib/generated-proto/pb_schema/common/value.js +204 -0
  276. package/lib/generated-proto/pb_schema/common/value.js.map +1 -0
  277. package/lib/generated-proto/pb_schema/google/api/annotations.d.ts +1 -0
  278. package/lib/generated-proto/pb_schema/google/api/annotations.js +9 -0
  279. package/lib/generated-proto/pb_schema/google/api/annotations.js.map +1 -0
  280. package/lib/generated-proto/pb_schema/google/api/http.d.ts +3636 -0
  281. package/lib/generated-proto/pb_schema/google/api/http.js +271 -0
  282. package/lib/generated-proto/pb_schema/google/api/http.js.map +1 -0
  283. package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +139 -0
  284. package/lib/generated-proto/pb_schema/google/protobuf/any.js +94 -0
  285. package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -0
  286. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +50968 -0
  287. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js +2962 -0
  288. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -0
  289. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +98 -0
  290. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +82 -0
  291. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -0
  292. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +173 -0
  293. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +332 -0
  294. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -0
  295. package/lib/generated-proto/pb_schema/lenses/geocircle.d.ts +42 -0
  296. package/lib/generated-proto/pb_schema/lenses/geocircle.js +52 -0
  297. package/lib/generated-proto/pb_schema/lenses/geocircle.js.map +1 -0
  298. package/lib/generated-proto/pb_schema/lenses/geopoint.d.ts +32 -0
  299. package/lib/generated-proto/pb_schema/lenses/geopoint.js +50 -0
  300. package/lib/generated-proto/pb_schema/lenses/geopoint.js.map +1 -0
  301. package/lib/generated-proto/pb_schema/lenses/launch_params.d.ts +29 -0
  302. package/lib/generated-proto/pb_schema/lenses/launch_params.js +43 -0
  303. package/lib/generated-proto/pb_schema/lenses/launch_params.js.map +1 -0
  304. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +365 -0
  305. package/lib/generated-proto/pb_schema/lenses/launchdata.js +216 -0
  306. package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -0
  307. package/lib/generated-proto/pb_schema/lenses/lures.d.ts +113 -0
  308. package/lib/generated-proto/pb_schema/lenses/lures.js +64 -0
  309. package/lib/generated-proto/pb_schema/lenses/lures.js.map +1 -0
  310. package/lib/generated-proto/pb_schema/lenses/persistent_store.d.ts +29 -0
  311. package/lib/generated-proto/pb_schema/lenses/persistent_store.js +43 -0
  312. package/lib/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -0
  313. package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +921 -0
  314. package/lib/generated-proto/pb_schema/lenses/snappable.js +954 -0
  315. package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -0
  316. package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +247 -0
  317. package/lib/generated-proto/pb_schema/lenses/user_data.js +362 -0
  318. package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -0
  319. package/lib/handlers/HandlerChainBuilder.d.ts +95 -0
  320. package/lib/handlers/HandlerChainBuilder.js +187 -0
  321. package/lib/handlers/HandlerChainBuilder.js.map +1 -0
  322. package/lib/handlers/arrayBufferParsingHandler.d.ts +10 -0
  323. package/lib/handlers/arrayBufferParsingHandler.js +18 -0
  324. package/lib/handlers/arrayBufferParsingHandler.js.map +1 -0
  325. package/lib/handlers/batchingHandler.d.ts +25 -0
  326. package/lib/handlers/batchingHandler.js +79 -0
  327. package/lib/handlers/batchingHandler.js.map +1 -0
  328. package/lib/handlers/cameraKitServiceFetchHandlerFactory.d.ts +12 -0
  329. package/lib/handlers/cameraKitServiceFetchHandlerFactory.js +19 -0
  330. package/lib/handlers/cameraKitServiceFetchHandlerFactory.js.map +1 -0
  331. package/lib/handlers/debugHandler.d.ts +8 -0
  332. package/lib/handlers/debugHandler.js +27 -0
  333. package/lib/handlers/debugHandler.js.map +1 -0
  334. package/lib/handlers/defaultFetchHandler.d.ts +15 -0
  335. package/lib/handlers/defaultFetchHandler.js +29 -0
  336. package/lib/handlers/defaultFetchHandler.js.map +1 -0
  337. package/lib/handlers/headersModifyingFetchHandler.d.ts +8 -0
  338. package/lib/handlers/headersModifyingFetchHandler.js +13 -0
  339. package/lib/handlers/headersModifyingFetchHandler.js.map +1 -0
  340. package/lib/handlers/index.d.ts +2 -0
  341. package/lib/handlers/index.js +3 -0
  342. package/lib/handlers/index.js.map +1 -0
  343. package/lib/handlers/mappingHandler.d.ts +15 -0
  344. package/lib/handlers/mappingHandler.js +65 -0
  345. package/lib/handlers/mappingHandler.js.map +1 -0
  346. package/lib/handlers/noCorsRetryingFetchHandler.d.ts +48 -0
  347. package/lib/handlers/noCorsRetryingFetchHandler.js +94 -0
  348. package/lib/handlers/noCorsRetryingFetchHandler.js.map +1 -0
  349. package/lib/handlers/persistingHandler.d.ts +14 -0
  350. package/lib/handlers/persistingHandler.js +71 -0
  351. package/lib/handlers/persistingHandler.js.map +1 -0
  352. package/lib/handlers/rateLimitingHandler.d.ts +20 -0
  353. package/lib/handlers/rateLimitingHandler.js +43 -0
  354. package/lib/handlers/rateLimitingHandler.js.map +1 -0
  355. package/lib/handlers/requestStateEmittingHandler.d.ts +29 -0
  356. package/lib/handlers/requestStateEmittingHandler.js +43 -0
  357. package/lib/handlers/requestStateEmittingHandler.js.map +1 -0
  358. package/lib/handlers/responseCachingHandler.d.ts +27 -0
  359. package/lib/handlers/responseCachingHandler.js +94 -0
  360. package/lib/handlers/responseCachingHandler.js.map +1 -0
  361. package/lib/handlers/retryingHandler.d.ts +37 -0
  362. package/lib/handlers/retryingHandler.js +73 -0
  363. package/lib/handlers/retryingHandler.js.map +1 -0
  364. package/lib/handlers/timeoutHandler.d.ts +18 -0
  365. package/lib/handlers/timeoutHandler.js +30 -0
  366. package/lib/handlers/timeoutHandler.js.map +1 -0
  367. package/lib/index.d.ts +33 -0
  368. package/lib/index.js +32 -0
  369. package/lib/index.js.map +1 -0
  370. package/lib/legal/legalPrompt.d.ts +17 -0
  371. package/lib/legal/legalPrompt.js +144 -0
  372. package/lib/legal/legalPrompt.js.map +1 -0
  373. package/lib/legal/legalState.d.ts +50 -0
  374. package/lib/legal/legalState.js +149 -0
  375. package/lib/legal/legalState.js.map +1 -0
  376. package/lib/lens/Lens.d.ts +71 -0
  377. package/lib/lens/Lens.js +63 -0
  378. package/lib/lens/Lens.js.map +1 -0
  379. package/lib/lens/LensLaunchParams.d.ts +19 -0
  380. package/lib/lens/LensLaunchParams.js +38 -0
  381. package/lib/lens/LensLaunchParams.js.map +1 -0
  382. package/lib/lens/LensPersistenceStore.d.ts +7 -0
  383. package/lib/lens/LensPersistenceStore.js +20 -0
  384. package/lib/lens/LensPersistenceStore.js.map +1 -0
  385. package/lib/lens/LensRepository.d.ts +134 -0
  386. package/lib/lens/LensRepository.js +239 -0
  387. package/lib/lens/LensRepository.js.map +1 -0
  388. package/lib/lens/assets/LensAssetRepository.d.ts +66 -0
  389. package/lib/lens/assets/LensAssetRepository.js +179 -0
  390. package/lib/lens/assets/LensAssetRepository.js.map +1 -0
  391. package/lib/lens/assets/LensAssetsProvider.d.ts +21 -0
  392. package/lib/lens/assets/LensAssetsProvider.js +41 -0
  393. package/lib/lens/assets/LensAssetsProvider.js.map +1 -0
  394. package/lib/lens/assets/deviceDependentAssetLoader.d.ts +11 -0
  395. package/lib/lens/assets/deviceDependentAssetLoader.js +58 -0
  396. package/lib/lens/assets/deviceDependentAssetLoader.js.map +1 -0
  397. package/lib/lens/assets/remoteMediaAssetLoaderFactory.d.ts +10 -0
  398. package/lib/lens/assets/remoteMediaAssetLoaderFactory.js +26 -0
  399. package/lib/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -0
  400. package/lib/lens/assets/staticAssetLoader.d.ts +10 -0
  401. package/lib/lens/assets/staticAssetLoader.js +24 -0
  402. package/lib/lens/assets/staticAssetLoader.js.map +1 -0
  403. package/lib/lens/index.d.ts +7 -0
  404. package/lib/lens/index.js +7 -0
  405. package/lib/lens/index.js.map +1 -0
  406. package/lib/lens/lensEnvelopeUtil.d.ts +5 -0
  407. package/lib/lens/lensEnvelopeUtil.js +19 -0
  408. package/lib/lens/lensEnvelopeUtil.js.map +1 -0
  409. package/lib/lens/lensHttpUtil.d.ts +4 -0
  410. package/lib/lens/lensHttpUtil.js +30 -0
  411. package/lib/lens/lensHttpUtil.js.map +1 -0
  412. package/lib/lens-client-interface/exif.d.ts +20 -0
  413. package/lib/lens-client-interface/exif.js +61 -0
  414. package/lib/lens-client-interface/exif.js.map +1 -0
  415. package/lib/lens-client-interface/imagePicker.d.ts +7 -0
  416. package/lib/lens-client-interface/imagePicker.js +128 -0
  417. package/lib/lens-client-interface/imagePicker.js.map +1 -0
  418. package/lib/lens-client-interface/lensClientInterface.d.ts +13 -0
  419. package/lib/lens-client-interface/lensClientInterface.js +30 -0
  420. package/lib/lens-client-interface/lensClientInterface.js.map +1 -0
  421. package/lib/lens-core-module/generated-types.d.ts +426 -0
  422. package/lib/lens-core-module/generated-types.js +2 -0
  423. package/lib/lens-core-module/generated-types.js.map +1 -0
  424. package/lib/lens-core-module/index.d.ts +2 -0
  425. package/lib/lens-core-module/index.js +3 -0
  426. package/lib/lens-core-module/index.js.map +1 -0
  427. package/lib/lens-core-module/loader/index.d.ts +1 -0
  428. package/lib/lens-core-module/loader/index.js +2 -0
  429. package/lib/lens-core-module/loader/index.js.map +1 -0
  430. package/lib/lens-core-module/loader/lensCoreFactory.d.ts +30 -0
  431. package/lib/lens-core-module/loader/lensCoreFactory.js +121 -0
  432. package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -0
  433. package/lib/lensCoreWasmVersions.json +5 -0
  434. package/lib/logger/errorLoggingDecorator.d.ts +9 -0
  435. package/lib/logger/errorLoggingDecorator.js +32 -0
  436. package/lib/logger/errorLoggingDecorator.js.map +1 -0
  437. package/lib/logger/logEntries.d.ts +15 -0
  438. package/lib/logger/logEntries.js +14 -0
  439. package/lib/logger/logEntries.js.map +1 -0
  440. package/lib/logger/logger.d.ts +35 -0
  441. package/lib/logger/logger.js +48 -0
  442. package/lib/logger/logger.js.map +1 -0
  443. package/lib/logger/registerLogEntriesSubscriber.d.ts +14 -0
  444. package/lib/logger/registerLogEntriesSubscriber.js +23 -0
  445. package/lib/logger/registerLogEntriesSubscriber.js.map +1 -0
  446. package/lib/media-sources/CameraKitSource.d.ts +88 -0
  447. package/lib/media-sources/CameraKitSource.js +140 -0
  448. package/lib/media-sources/CameraKitSource.js.map +1 -0
  449. package/lib/media-sources/FunctionSource.d.ts +30 -0
  450. package/lib/media-sources/FunctionSource.js +132 -0
  451. package/lib/media-sources/FunctionSource.js.map +1 -0
  452. package/lib/media-sources/ImageSource.d.ts +13 -0
  453. package/lib/media-sources/ImageSource.js +28 -0
  454. package/lib/media-sources/ImageSource.js.map +1 -0
  455. package/lib/media-sources/MediaStreamSource.d.ts +41 -0
  456. package/lib/media-sources/MediaStreamSource.js +146 -0
  457. package/lib/media-sources/MediaStreamSource.js.map +1 -0
  458. package/lib/media-sources/VideoSource.d.ts +21 -0
  459. package/lib/media-sources/VideoSource.js +38 -0
  460. package/lib/media-sources/VideoSource.js.map +1 -0
  461. package/lib/metrics/businessEventsReporter.d.ts +37 -0
  462. package/lib/metrics/businessEventsReporter.js +160 -0
  463. package/lib/metrics/businessEventsReporter.js.map +1 -0
  464. package/lib/metrics/metricsEventTarget.d.ts +41 -0
  465. package/lib/metrics/metricsEventTarget.js +11 -0
  466. package/lib/metrics/metricsEventTarget.js.map +1 -0
  467. package/lib/metrics/metricsHandler.d.ts +9 -0
  468. package/lib/metrics/metricsHandler.js +13 -0
  469. package/lib/metrics/metricsHandler.js.map +1 -0
  470. package/lib/metrics/operationalMetricsReporter.d.ts +52 -0
  471. package/lib/metrics/operationalMetricsReporter.js +108 -0
  472. package/lib/metrics/operationalMetricsReporter.js.map +1 -0
  473. package/lib/metrics/reporters/reportBenchmarks.d.ts +10 -0
  474. package/lib/metrics/reporters/reportBenchmarks.js +29 -0
  475. package/lib/metrics/reporters/reportBenchmarks.js.map +1 -0
  476. package/lib/metrics/reporters/reportGlobalException.d.ts +19 -0
  477. package/lib/metrics/reporters/reportGlobalException.js +68 -0
  478. package/lib/metrics/reporters/reportGlobalException.js.map +1 -0
  479. package/lib/metrics/reporters/reportHttpMetrics.d.ts +17 -0
  480. package/lib/metrics/reporters/reportHttpMetrics.js +92 -0
  481. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -0
  482. package/lib/metrics/reporters/reportLegalState.d.ts +15 -0
  483. package/lib/metrics/reporters/reportLegalState.js +34 -0
  484. package/lib/metrics/reporters/reportLegalState.js.map +1 -0
  485. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +38 -0
  486. package/lib/metrics/reporters/reportLensAndAssetDownload.js +88 -0
  487. package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -0
  488. package/lib/metrics/reporters/reportLensValidationFailed.d.ts +20 -0
  489. package/lib/metrics/reporters/reportLensValidationFailed.js +24 -0
  490. package/lib/metrics/reporters/reportLensValidationFailed.js.map +1 -0
  491. package/lib/metrics/reporters/reportLensView.d.ts +36 -0
  492. package/lib/metrics/reporters/reportLensView.js +101 -0
  493. package/lib/metrics/reporters/reportLensView.js.map +1 -0
  494. package/lib/metrics/reporters/reportLensWait.d.ts +33 -0
  495. package/lib/metrics/reporters/reportLensWait.js +56 -0
  496. package/lib/metrics/reporters/reportLensWait.js.map +1 -0
  497. package/lib/metrics/reporters/reportSessionException.d.ts +17 -0
  498. package/lib/metrics/reporters/reportSessionException.js +12 -0
  499. package/lib/metrics/reporters/reportSessionException.js.map +1 -0
  500. package/lib/metrics/reporters/reportUserSession.d.ts +14 -0
  501. package/lib/metrics/reporters/reportUserSession.js +67 -0
  502. package/lib/metrics/reporters/reportUserSession.js.map +1 -0
  503. package/lib/metrics/reporters/reporters.d.ts +44 -0
  504. package/lib/metrics/reporters/reporters.js +33 -0
  505. package/lib/metrics/reporters/reporters.js.map +1 -0
  506. package/lib/namedErrors.d.ts +107 -0
  507. package/lib/namedErrors.js +56 -0
  508. package/lib/namedErrors.js.map +1 -0
  509. package/lib/persistence/ExpiringPersistence.d.ts +20 -0
  510. package/lib/persistence/ExpiringPersistence.js +58 -0
  511. package/lib/persistence/ExpiringPersistence.js.map +1 -0
  512. package/lib/persistence/IndexedDBPersistence.d.ts +47 -0
  513. package/lib/persistence/IndexedDBPersistence.js +180 -0
  514. package/lib/persistence/IndexedDBPersistence.js.map +1 -0
  515. package/lib/persistence/Persistence.d.ts +25 -0
  516. package/lib/persistence/Persistence.js +10 -0
  517. package/lib/persistence/Persistence.js.map +1 -0
  518. package/lib/remote-configuration/cofHandler.d.ts +21 -0
  519. package/lib/remote-configuration/cofHandler.js +75 -0
  520. package/lib/remote-configuration/cofHandler.js.map +1 -0
  521. package/lib/remote-configuration/remoteConfiguration.d.ts +13 -0
  522. package/lib/remote-configuration/remoteConfiguration.js +43 -0
  523. package/lib/remote-configuration/remoteConfiguration.js.map +1 -0
  524. package/lib/session/CameraKitSession.d.ts +252 -0
  525. package/lib/session/CameraKitSession.js +439 -0
  526. package/lib/session/CameraKitSession.js.map +1 -0
  527. package/lib/session/CameraKitSessionEvents.d.ts +33 -0
  528. package/lib/session/CameraKitSessionEvents.js +21 -0
  529. package/lib/session/CameraKitSessionEvents.js.map +1 -0
  530. package/lib/session/LensKeyboard.d.ts +89 -0
  531. package/lib/session/LensKeyboard.js +95 -0
  532. package/lib/session/LensKeyboard.js.map +1 -0
  533. package/lib/session/LensPerformanceMeasurement.d.ts +55 -0
  534. package/lib/session/LensPerformanceMeasurement.js +91 -0
  535. package/lib/session/LensPerformanceMeasurement.js.map +1 -0
  536. package/lib/session/LensPerformanceMetrics.d.ts +31 -0
  537. package/lib/session/LensPerformanceMetrics.js +58 -0
  538. package/lib/session/LensPerformanceMetrics.js.map +1 -0
  539. package/lib/session/index.d.ts +1 -0
  540. package/lib/session/index.js +2 -0
  541. package/lib/session/index.js.map +1 -0
  542. package/lib/session/lensState.d.ts +29 -0
  543. package/lib/session/lensState.js +160 -0
  544. package/lib/session/lensState.js.map +1 -0
  545. package/lib/session/sessionState.d.ts +10 -0
  546. package/lib/session/sessionState.js +12 -0
  547. package/lib/session/sessionState.js.map +1 -0
  548. package/lib/transforms/Transform2D.d.ts +17 -0
  549. package/lib/transforms/Transform2D.js +18 -0
  550. package/lib/transforms/Transform2D.js.map +1 -0
  551. package/lib/transforms/index.d.ts +1 -0
  552. package/lib/transforms/index.js +2 -0
  553. package/lib/transforms/index.js.map +1 -0
  554. package/package.json +62 -0
@@ -0,0 +1,67 @@
1
+ import { __awaiter } from "tslib";
2
+ import { Injectable } from "../../dependency-injection/Injectable";
3
+ import { TypedCustomEvent } from "../../events/TypedCustomEvent";
4
+ import { DailySessionBucket } from "../../generated-proto/blizzard/cameraKitEvents";
5
+ import { IndexedDBPersistence } from "../../persistence/IndexedDBPersistence";
6
+ import { metricsEventTargetFactory } from "../metricsEventTarget";
7
+ /**
8
+ * @internal
9
+ */
10
+ export const reportUserSession = Injectable("reportUserSession", [metricsEventTargetFactory.token], (metricsEventTarget) => __awaiter(void 0, void 0, void 0, function* () {
11
+ var _a, _b;
12
+ const userSessionKey = "userSessionInfo";
13
+ const db = new IndexedDBPersistence({ databaseName: "SessionHistory" });
14
+ // We standardize all user dates to PST as per our documentation:
15
+ // https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/
16
+ const date = new Date(new Date().toLocaleDateString("en-US", {
17
+ timeZone: "America/Los_Angeles",
18
+ }));
19
+ const currentMonth = date.getMonth();
20
+ const currentDay = date.getDate();
21
+ const currentYear = date.getFullYear();
22
+ const userSessionInfo = yield db.retrieve(userSessionKey);
23
+ const mostRecentSessionStartDate = userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.mostRecentSessionStartDate;
24
+ const dailySessionBucketMap = new Map([
25
+ [1, DailySessionBucket.ONE_SESSION],
26
+ [2, DailySessionBucket.TWO_SESSION],
27
+ [3, DailySessionBucket.THREE_SESSION],
28
+ [4, DailySessionBucket.FOUR_SESSION],
29
+ [5, DailySessionBucket.FIVE_SESSION],
30
+ [6, DailySessionBucket.SIX_SESSION],
31
+ [7, DailySessionBucket.SEVEN_SESSION],
32
+ [8, DailySessionBucket.EIGHT_SESSION],
33
+ [9, DailySessionBucket.NINE_SESSION],
34
+ ]);
35
+ let dailySessionBucket = (_a = userSessionInfo === null || userSessionInfo === void 0 ? void 0 : userSessionInfo.dailySessionBucket) !== null && _a !== void 0 ? _a : DailySessionBucket.NO_SESSION_BUCKET;
36
+ let isFirstWithinMonth = false;
37
+ if (mostRecentSessionStartDate &&
38
+ mostRecentSessionStartDate.getMonth() === currentMonth &&
39
+ mostRecentSessionStartDate.getDate() === currentDay &&
40
+ mostRecentSessionStartDate.getFullYear() === currentYear) {
41
+ dailySessionBucket =
42
+ (_b = dailySessionBucketMap.get(dailySessionBucket + 1)) !== null && _b !== void 0 ? _b : DailySessionBucket.TEN_OR_MORE_SESSION;
43
+ yield db.remove(userSessionKey);
44
+ yield db.store(userSessionKey, {
45
+ mostRecentSessionStartDate: date,
46
+ dailySessionBucket,
47
+ });
48
+ }
49
+ else {
50
+ isFirstWithinMonth = !mostRecentSessionStartDate || mostRecentSessionStartDate.getMonth() !== currentMonth;
51
+ yield db.remove(userSessionKey);
52
+ yield db.store(userSessionKey, {
53
+ mostRecentSessionStartDate: date,
54
+ dailySessionBucket: (dailySessionBucket = DailySessionBucket.ONE_SESSION),
55
+ });
56
+ }
57
+ const session = {
58
+ name: "session",
59
+ dailySessionBucket,
60
+ isFirstWithinMonth,
61
+ month: currentMonth + 1,
62
+ day: currentDay,
63
+ year: currentYear,
64
+ };
65
+ metricsEventTarget.dispatchEvent(new TypedCustomEvent("session", session));
66
+ }));
67
+ //# sourceMappingURL=reportUserSession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reportUserSession.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reportUserSession.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E,OAAO,EAAsB,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAYtF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CACvC,mBAAmB,EACnB,CAAC,yBAAyB,CAAC,KAAK,CAAU,EAC1C,CAAO,kBAAsC,EAAiB,EAAE;;IAC5D,MAAM,cAAc,GAAG,iBAAiB,CAAC;IACzC,MAAM,EAAE,GAAG,IAAI,oBAAoB,CAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACzF,iEAAiE;IACjE,mFAAmF;IACnF,MAAM,IAAI,GAAG,IAAI,IAAI,CACjB,IAAI,IAAI,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE;QACnC,QAAQ,EAAE,qBAAqB;KAClC,CAAC,CACL,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;IACrC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAClC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAEvC,MAAM,eAAe,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC1D,MAAM,0BAA0B,GAAG,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,0BAA0B,CAAC;IAC/E,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAA6B;QAC9D,CAAC,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;QACnC,CAAC,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;QACnC,CAAC,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC;QACrC,CAAC,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC;QACpC,CAAC,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC;QACpC,CAAC,CAAC,EAAE,kBAAkB,CAAC,WAAW,CAAC;QACnC,CAAC,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC;QACrC,CAAC,CAAC,EAAE,kBAAkB,CAAC,aAAa,CAAC;QACrC,CAAC,CAAC,EAAE,kBAAkB,CAAC,YAAY,CAAC;KACvC,CAAC,CAAC;IACH,IAAI,kBAAkB,GAAG,MAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,kBAAkB,mCAAI,kBAAkB,CAAC,iBAAiB,CAAC;IACrG,IAAI,kBAAkB,GAAG,KAAK,CAAC;IAC/B,IACI,0BAA0B;QAC1B,0BAA0B,CAAC,QAAQ,EAAE,KAAK,YAAY;QACtD,0BAA0B,CAAC,OAAO,EAAE,KAAK,UAAU;QACnD,0BAA0B,CAAC,WAAW,EAAE,KAAK,WAAW,EAC1D;QACE,kBAAkB;YACd,MAAA,qBAAqB,CAAC,GAAG,CAAC,kBAAkB,GAAG,CAAC,CAAC,mCAAI,kBAAkB,CAAC,mBAAmB,CAAC;QAChG,MAAM,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAChC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,0BAA0B,EAAE,IAAI;YAChC,kBAAkB;SACrB,CAAC,CAAC;KACN;SAAM;QACH,kBAAkB,GAAG,CAAC,0BAA0B,IAAI,0BAA0B,CAAC,QAAQ,EAAE,KAAK,YAAY,CAAC;QAC3G,MAAM,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAChC,MAAM,EAAE,CAAC,KAAK,CAAC,cAAc,EAAE;YAC3B,0BAA0B,EAAE,IAAI;YAChC,kBAAkB,EAAE,CAAC,kBAAkB,GAAG,kBAAkB,CAAC,WAAW,CAAC;SAC5E,CAAC,CAAC;KACN;IACD,MAAM,OAAO,GAAY;QACrB,IAAI,EAAE,SAAS;QACf,kBAAkB;QAClB,kBAAkB;QAClB,KAAK,EAAE,YAAY,GAAG,CAAC;QACvB,GAAG,EAAE,UAAU;QACf,IAAI,EAAE,WAAW;KACpB,CAAC;IACF,kBAAkB,CAAC,aAAa,CAAC,IAAI,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAA,CACJ,CAAC","sourcesContent":["import { Injectable } from \"../../dependency-injection/Injectable\";\nimport { TypedCustomEvent } from \"../../events/TypedCustomEvent\";\nimport { DailySessionBucket } from \"../../generated-proto/blizzard/cameraKitEvents\";\nimport { IndexedDBPersistence } from \"../../persistence/IndexedDBPersistence\";\nimport { MakeTaggedBusinessEvent } from \"../businessEventsReporter\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"../metricsEventTarget\";\n\ninterface UserSessionInfo {\n mostRecentSessionStartDate: Date;\n dailySessionBucket: DailySessionBucket;\n}\n\n/**\n * The Session metric reports each user session.\n */\nexport type Session = MakeTaggedBusinessEvent<\"session\">;\n\n/**\n * @internal\n */\nexport const reportUserSession = Injectable(\n \"reportUserSession\",\n [metricsEventTargetFactory.token] as const,\n async (metricsEventTarget: MetricsEventTarget): Promise<void> => {\n const userSessionKey = \"userSessionInfo\";\n const db = new IndexedDBPersistence<UserSessionInfo>({ databaseName: \"SessionHistory\" });\n // We standardize all user dates to PST as per our documentation:\n // https://docs.google.com/document/d/1-kSzFWCWw9Qo3D08FR1_cqeHTsUtk9p3p3uOptzWDTY/\n const date = new Date(\n new Date().toLocaleDateString(\"en-US\", {\n timeZone: \"America/Los_Angeles\",\n })\n );\n const currentMonth = date.getMonth();\n const currentDay = date.getDate();\n const currentYear = date.getFullYear();\n\n const userSessionInfo = await db.retrieve(userSessionKey);\n const mostRecentSessionStartDate = userSessionInfo?.mostRecentSessionStartDate;\n const dailySessionBucketMap = new Map<number, DailySessionBucket>([\n [1, DailySessionBucket.ONE_SESSION],\n [2, DailySessionBucket.TWO_SESSION],\n [3, DailySessionBucket.THREE_SESSION],\n [4, DailySessionBucket.FOUR_SESSION],\n [5, DailySessionBucket.FIVE_SESSION],\n [6, DailySessionBucket.SIX_SESSION],\n [7, DailySessionBucket.SEVEN_SESSION],\n [8, DailySessionBucket.EIGHT_SESSION],\n [9, DailySessionBucket.NINE_SESSION],\n ]);\n let dailySessionBucket = userSessionInfo?.dailySessionBucket ?? DailySessionBucket.NO_SESSION_BUCKET;\n let isFirstWithinMonth = false;\n if (\n mostRecentSessionStartDate &&\n mostRecentSessionStartDate.getMonth() === currentMonth &&\n mostRecentSessionStartDate.getDate() === currentDay &&\n mostRecentSessionStartDate.getFullYear() === currentYear\n ) {\n dailySessionBucket =\n dailySessionBucketMap.get(dailySessionBucket + 1) ?? DailySessionBucket.TEN_OR_MORE_SESSION;\n await db.remove(userSessionKey);\n await db.store(userSessionKey, {\n mostRecentSessionStartDate: date,\n dailySessionBucket,\n });\n } else {\n isFirstWithinMonth = !mostRecentSessionStartDate || mostRecentSessionStartDate.getMonth() !== currentMonth;\n await db.remove(userSessionKey);\n await db.store(userSessionKey, {\n mostRecentSessionStartDate: date,\n dailySessionBucket: (dailySessionBucket = DailySessionBucket.ONE_SESSION),\n });\n }\n const session: Session = {\n name: \"session\",\n dailySessionBucket,\n isFirstWithinMonth,\n month: currentMonth + 1, // Date.getMonth() is zero-based so we need to add 1\n day: currentDay,\n year: currentYear,\n };\n metricsEventTarget.dispatchEvent(new TypedCustomEvent(\"session\", session));\n }\n);\n"]}
@@ -0,0 +1,44 @@
1
+ import { PartialContainer } from "../../dependency-injection/PartialContainer";
2
+ /**
3
+ * These metrics reporters must be run once in the top-level DI container. They only depend on globally-available
4
+ * services.
5
+ *
6
+ * The businessEventsReporter is special, it doesn't create any of its own metrics, it simply listens to the global
7
+ * metricsEventTarget and reports metrics emitted there to our backend.
8
+ */
9
+ export declare const reportGloballyScopedMetrics: PartialContainer<{
10
+ reportBenchmarks: Promise<void>;
11
+ reportLensAndAssetDownload: void;
12
+ reportHttpMetrics: void;
13
+ }, {
14
+ configuration: import("../..").CameraKitConfiguration;
15
+ metricsEventTarget: import("../metricsEventTarget").MetricsEventTarget;
16
+ operationalMetricsReporter: import("../operationalMetricsReporter").OperationalMetricsReporter;
17
+ }>;
18
+ /**
19
+ * These metrics reporters must be run once for each CameraKitSession DI container created. They may depend on services
20
+ * which are only available at the session scope (e.g. the CameraKitSession itself).
21
+ */
22
+ export declare const reportSessionScopedMetrics: PartialContainer<{
23
+ reportLensValidationFailed: void;
24
+ reportLensView: void;
25
+ reportLensWait: void;
26
+ reportUserSession: Promise<void>;
27
+ reportLegalState: void;
28
+ reportSessionException: void;
29
+ }, {
30
+ configuration: import("../..").CameraKitConfiguration;
31
+ metricsEventTarget: import("../metricsEventTarget").MetricsEventTarget;
32
+ legalState: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"requestLegalPrompt", undefined> | import("@snap/state-management").Action<"accept", string> | import("@snap/state-management").Action<"reject", string>, import("@snap/state-management").State<"unknown", undefined> | import("@snap/state-management").State<"accepted", undefined> | import("@snap/state-management").State<"rejected", undefined>>;
33
+ lensState: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"applyLens", {
34
+ lens: import("../..").Lens;
35
+ launchParams?: import("../..").LensLaunchParams | undefined;
36
+ }> | import("@snap/state-management").Action<"downloadComplete", import("../..").Lens> | import("@snap/state-management").Action<"turnedOn", import("../..").Lens> | import("@snap/state-management").Action<"resourcesLoaded", import("../..").Lens> | import("@snap/state-management").Action<"firstFrameProcessed", import("../..").Lens> | import("@snap/state-management").Action<"applyLensComplete", import("../..").Lens> | import("@snap/state-management").Action<"applyLensFailed", {
37
+ error: import("../../session/lensState").LensErrors;
38
+ lens: import("../..").Lens;
39
+ }> | import("@snap/state-management").Action<"removeLens", undefined> | import("@snap/state-management").Action<"turnedOff", import("../..").Lens> | import("@snap/state-management").Action<"removeLensComplete", undefined> | import("@snap/state-management").Action<"removeLensFailed", Error>, import("@snap/state-management").State<"noLensApplied", undefined> | import("@snap/state-management").State<"applyingLens", import("../..").Lens> | import("@snap/state-management").State<"lensApplied", import("../..").Lens>>;
40
+ sessionState: import("@snap/state-management").StateMachine<import("@snap/state-management").Action<"suspend", import("../..").CameraKitSession> | import("@snap/state-management").Action<"resume", import("../..").CameraKitSession>, import("@snap/state-management").State<"inactive", undefined> | import("@snap/state-management").State<"active", import("../..").CameraKitSession>>;
41
+ CameraKitSession: import("../..").CameraKitSession;
42
+ operationalMetricsReporter: import("../operationalMetricsReporter").OperationalMetricsReporter;
43
+ reportGlobalException: import("./reportGlobalException").GlobalExceptionReporter;
44
+ }>;
@@ -0,0 +1,33 @@
1
+ import { PartialContainer } from "../../dependency-injection/PartialContainer";
2
+ import { reportSessionException } from "./reportSessionException";
3
+ import { reportBenchmarks } from "./reportBenchmarks";
4
+ import { reportHttpMetrics } from "./reportHttpMetrics";
5
+ import { reportLegalState } from "./reportLegalState";
6
+ import { reportLensAndAssetDownload } from "./reportLensAndAssetDownload";
7
+ import { reportLensValidationFailed } from "./reportLensValidationFailed";
8
+ import { reportLensView } from "./reportLensView";
9
+ import { reportLensWait } from "./reportLensWait";
10
+ import { reportUserSession } from "./reportUserSession";
11
+ /**
12
+ * These metrics reporters must be run once in the top-level DI container. They only depend on globally-available
13
+ * services.
14
+ *
15
+ * The businessEventsReporter is special, it doesn't create any of its own metrics, it simply listens to the global
16
+ * metricsEventTarget and reports metrics emitted there to our backend.
17
+ */
18
+ export const reportGloballyScopedMetrics = new PartialContainer({})
19
+ .provides(reportHttpMetrics)
20
+ .provides(reportBenchmarks)
21
+ .provides(reportLensAndAssetDownload);
22
+ /**
23
+ * These metrics reporters must be run once for each CameraKitSession DI container created. They may depend on services
24
+ * which are only available at the session scope (e.g. the CameraKitSession itself).
25
+ */
26
+ export const reportSessionScopedMetrics = new PartialContainer({})
27
+ .provides(reportUserSession)
28
+ .provides(reportLensView)
29
+ .provides(reportLensWait)
30
+ .provides(reportSessionException)
31
+ .provides(reportLensValidationFailed)
32
+ .provides(reportLegalState);
33
+ //# sourceMappingURL=reporters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reporters.js","sourceRoot":"","sources":["../../../src/metrics/reporters/reporters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC;KAC9D,QAAQ,CAAC,iBAAiB,CAAC;KAC3B,QAAQ,CAAC,gBAAgB,CAAC;KAC1B,QAAQ,CAAC,0BAA0B,CAAC,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,gBAAgB,CAAC,EAAE,CAAC;KAC7D,QAAQ,CAAC,iBAAiB,CAAC;KAC3B,QAAQ,CAAC,cAAc,CAAC;KACxB,QAAQ,CAAC,cAAc,CAAC;KACxB,QAAQ,CAAC,sBAAsB,CAAC;KAChC,QAAQ,CAAC,0BAA0B,CAAC;KACpC,QAAQ,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import { PartialContainer } from \"../../dependency-injection/PartialContainer\";\nimport { reportSessionException } from \"./reportSessionException\";\nimport { reportBenchmarks } from \"./reportBenchmarks\";\nimport { reportHttpMetrics } from \"./reportHttpMetrics\";\nimport { reportLegalState } from \"./reportLegalState\";\nimport { reportLensAndAssetDownload } from \"./reportLensAndAssetDownload\";\nimport { reportLensValidationFailed } from \"./reportLensValidationFailed\";\nimport { reportLensView } from \"./reportLensView\";\nimport { reportLensWait } from \"./reportLensWait\";\nimport { reportUserSession } from \"./reportUserSession\";\n\n/**\n * These metrics reporters must be run once in the top-level DI container. They only depend on globally-available\n * services.\n *\n * The businessEventsReporter is special, it doesn't create any of its own metrics, it simply listens to the global\n * metricsEventTarget and reports metrics emitted there to our backend.\n */\nexport const reportGloballyScopedMetrics = new PartialContainer({})\n .provides(reportHttpMetrics)\n .provides(reportBenchmarks)\n .provides(reportLensAndAssetDownload);\n\n/**\n * These metrics reporters must be run once for each CameraKitSession DI container created. They may depend on services\n * which are only available at the session scope (e.g. the CameraKitSession itself).\n */\nexport const reportSessionScopedMetrics = new PartialContainer({})\n .provides(reportUserSession)\n .provides(reportLensView)\n .provides(reportLensWait)\n .provides(reportSessionException)\n .provides(reportLensValidationFailed)\n .provides(reportLegalState);\n"]}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Helper type to extract type generic parameter.
3
+ */
4
+ declare type ExtractName<P> = P extends NamedError<infer T> ? T : never;
5
+ /**
6
+ * All errors are expected to have "Error" suffix.
7
+ */
8
+ declare type ErrorName = `${string}Error`;
9
+ declare type NamedError<Name extends ErrorName> = Error & {
10
+ name: Name;
11
+ };
12
+ /**
13
+ * Creates error factory that ensures Error.prototype.name field value.
14
+ *
15
+ * NOTE: exported only for unit tests.
16
+ *
17
+ * @param name Error name.
18
+ * @returns Error factory function.
19
+ * @internal
20
+ */
21
+ export declare function namedError<TError extends NamedError<TName> = never, TName extends ErrorName = ExtractName<TError>>(name: TName): (message: string, cause?: unknown) => TError;
22
+ export declare type LegalError = NamedError<"LegalError">;
23
+ /** @internal */
24
+ export declare const legalError: (message: string, cause?: unknown) => LegalError;
25
+ export declare type LensContentValidationError = NamedError<"LensContentValidationError">;
26
+ /** @internal */
27
+ export declare const lensContentValidationError: (message: string, cause?: unknown) => LensContentValidationError;
28
+ export declare type LensError = NamedError<"LensError">;
29
+ /** @internal */
30
+ export declare const lensError: (message: string, cause?: unknown) => LensError;
31
+ export declare type CameraKitSourceError = NamedError<"CameraKitSourceError">;
32
+ /** @internal */
33
+ export declare const cameraKitSourceError: (message: string, cause?: unknown) => CameraKitSourceError;
34
+ /**
35
+ * The error triggered when a lens prompts the user to select an image, but the image fails to be successfully delivered
36
+ * to the lens.
37
+ */
38
+ export declare type LensImagePickerError = NamedError<"LensImagePickerError">;
39
+ /** @internal */
40
+ export declare const lensImagePickerError: (message: string, cause?: unknown) => LensImagePickerError;
41
+ export declare type CacheKeyNotFoundError = NamedError<"CacheKeyNotFoundError">;
42
+ /** @internal */
43
+ export declare const cacheKeyNotFoundError: (message: string, cause?: unknown) => CacheKeyNotFoundError;
44
+ /**
45
+ * Thrown by {@link bootstrapCameraKit} if provided configuration is invalid.
46
+ *
47
+ * @category Bootstrapping and Configuration
48
+ */
49
+ export declare type ConfigurationError = NamedError<"ConfigurationError">;
50
+ /** @internal */
51
+ export declare const configurationError: (message: string, cause?: unknown) => ConfigurationError;
52
+ export declare type WebGLError = NamedError<"WebGLError">;
53
+ /** @internal */
54
+ export declare const webGLError: (message: string, cause?: unknown) => WebGLError;
55
+ export declare type BenchmarkError = NamedError<"BenchmarkError">;
56
+ /** @internal */
57
+ export declare const benchmarkError: (message: string, cause?: unknown) => BenchmarkError;
58
+ /**
59
+ * Thrown by {@link bootstrapCameraKit} when the current platform is not supported by CameraKit.
60
+ *
61
+ * This can happen if the browser doesn't support a required feature (e.g. WebGL).
62
+ *
63
+ * @category Bootstrapping and Configuration
64
+ */
65
+ export declare type PlatformNotSupportedError = NamedError<"PlatformNotSupportedError">;
66
+ /** @internal */
67
+ export declare const platformNotSupportedError: (message: string, cause?: unknown) => PlatformNotSupportedError;
68
+ /**
69
+ * This error occurs if a Lens is unable to continue rendering.
70
+ *
71
+ * If this error occurs, Camera Kit automatically removes the Lens from the session.
72
+ * It's always a good idea to handle this error and update the user experience accordingly.
73
+ * For example, you could remove the faulty Lens from your Lens selection UI.
74
+ *
75
+ * ```ts
76
+ * cameraKitSession.events.addEventListener('error', ({ detail }) => {
77
+ * if (detail.error.name === 'LensExecutionError') {
78
+ * console.log(`Lens ${detail.lens.name} encountered an error and was removed. Please pick a different lens.`)
79
+ * }
80
+ * })
81
+ * ```
82
+ */
83
+ export declare type LensExecutionError = NamedError<"LensExecutionError">;
84
+ /** @internal */
85
+ export declare const lensExecutionError: (message: string, cause?: unknown) => LensExecutionError;
86
+ /**
87
+ * Error thrown when LensCore asked to store lens data, but CameraKit failed storing that.
88
+ */
89
+ export declare type PersistentStoreError = NamedError<"PersistentStoreError">;
90
+ /** @internal */
91
+ export declare const persistentStoreError: (message: string, cause?: unknown) => PersistentStoreError;
92
+ /**
93
+ * Error thrown when LensCore asked to provide an asset, but CameraKit failed providing that.
94
+ */
95
+ export declare type LensAssetError = NamedError<"LensAssetError">;
96
+ /** @internal */
97
+ export declare const lensAssetError: (message: string, cause?: unknown) => LensAssetError;
98
+ /**
99
+ * Thrown by {@link bootstrapCameraKit} if an error occurs during SDK initializion or while downloading the render
100
+ * engine WebAssembly.
101
+ *
102
+ * @category Bootstrapping and Configuration
103
+ */
104
+ export declare type BootstrapError = NamedError<"BootstrapError">;
105
+ /** @internal */
106
+ export declare const bootstrapError: (message: string, cause?: unknown) => BootstrapError;
107
+ export {};
@@ -0,0 +1,56 @@
1
+ // NOTE: All errors thrown in the CameraKit package have to be defined here.
2
+ // Error types are not infered from error factories for API doc purposes and consistency.
3
+ /**
4
+ * Removes the top trace line from the stack.
5
+ */
6
+ function cleanErrorStack(stack) {
7
+ const [first, _, ...rest] = stack.split("\n");
8
+ return [first, ...rest].join("\n");
9
+ }
10
+ /**
11
+ * Creates error factory that ensures Error.prototype.name field value.
12
+ *
13
+ * NOTE: exported only for unit tests.
14
+ *
15
+ * @param name Error name.
16
+ * @returns Error factory function.
17
+ * @internal
18
+ */
19
+ export function namedError(name) {
20
+ return (message, cause) => {
21
+ const error = new Error(message, { cause });
22
+ error.name = name;
23
+ error.stack = error.stack && cleanErrorStack(error.stack);
24
+ // Safety: we set name above and therefore sure the type of error is correct
25
+ return error;
26
+ };
27
+ }
28
+ /** @internal */
29
+ export const legalError = namedError("LegalError");
30
+ /** @internal */
31
+ export const lensContentValidationError = namedError("LensContentValidationError");
32
+ /** @internal */
33
+ export const lensError = namedError("LensError");
34
+ /** @internal */
35
+ export const cameraKitSourceError = namedError("CameraKitSourceError");
36
+ /** @internal */
37
+ export const lensImagePickerError = namedError("LensImagePickerError");
38
+ /** @internal */
39
+ export const cacheKeyNotFoundError = namedError("CacheKeyNotFoundError");
40
+ /** @internal */
41
+ export const configurationError = namedError("ConfigurationError");
42
+ /** @internal */
43
+ export const webGLError = namedError("WebGLError");
44
+ /** @internal */
45
+ export const benchmarkError = namedError("BenchmarkError");
46
+ /** @internal */
47
+ export const platformNotSupportedError = namedError("PlatformNotSupportedError");
48
+ /** @internal */
49
+ export const lensExecutionError = namedError("LensExecutionError");
50
+ /** @internal */
51
+ export const persistentStoreError = namedError("PersistentStoreError");
52
+ /** @internal */
53
+ export const lensAssetError = namedError("LensAssetError");
54
+ /** @internal */
55
+ export const bootstrapError = namedError("BootstrapError");
56
+ //# sourceMappingURL=namedErrors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namedErrors.js","sourceRoot":"","sources":["../src/namedErrors.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,yFAAyF;AAczF;;GAEG;AACH,SAAS,eAAe,CAAC,KAAa;IAClC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAKxB,IAAW;IACT,OAAO,CAAC,OAAe,EAAE,KAAe,EAAU,EAAE;QAChD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5C,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1D,4EAA4E;QAC5E,OAAO,KAAe,CAAC;IAC3B,CAAC,CAAC;AACN,CAAC;AAGD,gBAAgB;AAChB,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAa,YAAY,CAAC,CAAC;AAG/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,0BAA0B,GAAG,UAAU,CAA6B,4BAA4B,CAAC,CAAC;AAG/G,gBAAgB;AAChB,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAY,WAAW,CAAC,CAAC;AAG5D,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAuB,sBAAsB,CAAC,CAAC;AAO7F,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAuB,sBAAsB,CAAC,CAAC;AAG7F,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,UAAU,CAAwB,uBAAuB,CAAC,CAAC;AAQhG,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAqB,oBAAoB,CAAC,CAAC;AAGvF,gBAAgB;AAChB,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAa,YAAY,CAAC,CAAC;AAG/D,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAiB,gBAAgB,CAAC,CAAC;AAU3E,gBAAgB;AAChB,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAA4B,2BAA2B,CAAC,CAAC;AAkB5G,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAqB,oBAAoB,CAAC,CAAC;AAMvF,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAuB,sBAAsB,CAAC,CAAC;AAM7F,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAiB,gBAAgB,CAAC,CAAC;AAS3E,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAiB,gBAAgB,CAAC,CAAC","sourcesContent":["// NOTE: All errors thrown in the CameraKit package have to be defined here.\n// Error types are not infered from error factories for API doc purposes and consistency.\n\n/**\n * Helper type to extract type generic parameter.\n */\ntype ExtractName<P> = P extends NamedError<infer T> ? T : never;\n\n/**\n * All errors are expected to have \"Error\" suffix.\n */\ntype ErrorName = `${string}Error`;\n\ntype NamedError<Name extends ErrorName> = Error & { name: Name };\n\n/**\n * Removes the top trace line from the stack.\n */\nfunction cleanErrorStack(stack: string): string {\n const [first, _, ...rest] = stack.split(\"\\n\");\n return [first, ...rest].join(\"\\n\");\n}\n\n/**\n * Creates error factory that ensures Error.prototype.name field value.\n *\n * NOTE: exported only for unit tests.\n *\n * @param name Error name.\n * @returns Error factory function.\n * @internal\n */\nexport function namedError<\n // default to never to ensure the type argument is specified\n TError extends NamedError<TName> = never,\n // default to provided error name to make this type argument optional to reduce boilerplate\n TName extends ErrorName = ExtractName<TError>\n>(name: TName) {\n return (message: string, cause?: unknown): TError => {\n const error = new Error(message, { cause });\n error.name = name;\n error.stack = error.stack && cleanErrorStack(error.stack);\n // Safety: we set name above and therefore sure the type of error is correct\n return error as TError;\n };\n}\n\nexport type LegalError = NamedError<\"LegalError\">;\n/** @internal */\nexport const legalError = namedError<LegalError>(\"LegalError\");\n\nexport type LensContentValidationError = NamedError<\"LensContentValidationError\">;\n/** @internal */\nexport const lensContentValidationError = namedError<LensContentValidationError>(\"LensContentValidationError\");\n\nexport type LensError = NamedError<\"LensError\">;\n/** @internal */\nexport const lensError = namedError<LensError>(\"LensError\");\n\nexport type CameraKitSourceError = NamedError<\"CameraKitSourceError\">;\n/** @internal */\nexport const cameraKitSourceError = namedError<CameraKitSourceError>(\"CameraKitSourceError\");\n\n/**\n * The error triggered when a lens prompts the user to select an image, but the image fails to be successfully delivered\n * to the lens.\n */\nexport type LensImagePickerError = NamedError<\"LensImagePickerError\">;\n/** @internal */\nexport const lensImagePickerError = namedError<LensImagePickerError>(\"LensImagePickerError\");\n\nexport type CacheKeyNotFoundError = NamedError<\"CacheKeyNotFoundError\">;\n/** @internal */\nexport const cacheKeyNotFoundError = namedError<CacheKeyNotFoundError>(\"CacheKeyNotFoundError\");\n\n/**\n * Thrown by {@link bootstrapCameraKit} if provided configuration is invalid.\n *\n * @category Bootstrapping and Configuration\n */\nexport type ConfigurationError = NamedError<\"ConfigurationError\">;\n/** @internal */\nexport const configurationError = namedError<ConfigurationError>(\"ConfigurationError\");\n\nexport type WebGLError = NamedError<\"WebGLError\">;\n/** @internal */\nexport const webGLError = namedError<WebGLError>(\"WebGLError\");\n\nexport type BenchmarkError = NamedError<\"BenchmarkError\">;\n/** @internal */\nexport const benchmarkError = namedError<BenchmarkError>(\"BenchmarkError\");\n\n/**\n * Thrown by {@link bootstrapCameraKit} when the current platform is not supported by CameraKit.\n *\n * This can happen if the browser doesn't support a required feature (e.g. WebGL).\n *\n * @category Bootstrapping and Configuration\n */\nexport type PlatformNotSupportedError = NamedError<\"PlatformNotSupportedError\">;\n/** @internal */\nexport const platformNotSupportedError = namedError<PlatformNotSupportedError>(\"PlatformNotSupportedError\");\n\n/**\n * This error occurs if a Lens is unable to continue rendering.\n *\n * If this error occurs, Camera Kit automatically removes the Lens from the session.\n * It's always a good idea to handle this error and update the user experience accordingly.\n * For example, you could remove the faulty Lens from your Lens selection UI.\n *\n * ```ts\n * cameraKitSession.events.addEventListener('error', ({ detail }) => {\n * if (detail.error.name === 'LensExecutionError') {\n * console.log(`Lens ${detail.lens.name} encountered an error and was removed. Please pick a different lens.`)\n * }\n * })\n * ```\n */\nexport type LensExecutionError = NamedError<\"LensExecutionError\">;\n/** @internal */\nexport const lensExecutionError = namedError<LensExecutionError>(\"LensExecutionError\");\n\n/**\n * Error thrown when LensCore asked to store lens data, but CameraKit failed storing that.\n */\nexport type PersistentStoreError = NamedError<\"PersistentStoreError\">;\n/** @internal */\nexport const persistentStoreError = namedError<PersistentStoreError>(\"PersistentStoreError\");\n\n/**\n * Error thrown when LensCore asked to provide an asset, but CameraKit failed providing that.\n */\nexport type LensAssetError = NamedError<\"LensAssetError\">;\n/** @internal */\nexport const lensAssetError = namedError<LensAssetError>(\"LensAssetError\");\n\n/**\n * Thrown by {@link bootstrapCameraKit} if an error occurs during SDK initializion or while downloading the render\n * engine WebAssembly.\n *\n * @category Bootstrapping and Configuration\n */\nexport type BootstrapError = NamedError<\"BootstrapError\">;\n/** @internal */\nexport const bootstrapError = namedError<BootstrapError>(\"BootstrapError\");\n"]}
@@ -0,0 +1,20 @@
1
+ import { Persistence, ValidKey } from "./Persistence";
2
+ /**
3
+ * Create a Persistence that will remove entries after they expire.
4
+ *
5
+ * An expiration function must be provided, which is called each time a value is stored. It must return the expiration
6
+ * time for that value, given in seconds from now. For example, to expire a value 24 hours after it is stored, the
7
+ * expiration function should return 86400 (the number of seconds in 24 hours).
8
+ */
9
+ export declare class ExpiringPersistence<T> implements Persistence<T> {
10
+ private readonly expiration;
11
+ private readonly persistence;
12
+ constructor(expiration: (value: T) => number, persistence: Persistence<[number, T]>);
13
+ get size(): number;
14
+ retrieve(key: ValidKey): Promise<T | undefined>;
15
+ retrieveAll(): Promise<T[]>;
16
+ remove(key: ValidKey): Promise<void>;
17
+ removeAll(): Promise<T[]>;
18
+ store(value: T): Promise<ValidKey>;
19
+ store(key: ValidKey, value: T): Promise<ValidKey>;
20
+ }
@@ -0,0 +1,58 @@
1
+ import { __awaiter } from "tslib";
2
+ import { ensureError } from "../common/errorHelpers";
3
+ import { getLogger } from "../logger/logger";
4
+ const logger = getLogger("ExpiringPersistence");
5
+ /**
6
+ * Create a Persistence that will remove entries after they expire.
7
+ *
8
+ * An expiration function must be provided, which is called each time a value is stored. It must return the expiration
9
+ * time for that value, given in seconds from now. For example, to expire a value 24 hours after it is stored, the
10
+ * expiration function should return 86400 (the number of seconds in 24 hours).
11
+ */
12
+ export class ExpiringPersistence {
13
+ constructor(expiration, persistence) {
14
+ this.expiration = expiration;
15
+ this.persistence = persistence;
16
+ }
17
+ get size() {
18
+ return this.persistence.size;
19
+ }
20
+ retrieve(key) {
21
+ var _a;
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const [expiry, value] = (_a = (yield this.persistence.retrieve(key))) !== null && _a !== void 0 ? _a : [];
24
+ if (value === undefined || expiry === undefined)
25
+ return undefined;
26
+ if (Date.now() > expiry) {
27
+ yield this.persistence.remove(key).catch((error) => {
28
+ logger.warn(`Key ${key} is expired, but removing it from persistence failed.`, ensureError(error));
29
+ });
30
+ return undefined;
31
+ }
32
+ return value;
33
+ });
34
+ }
35
+ retrieveAll() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const now = Date.now();
38
+ return (yield this.persistence.retrieveAll()).filter(([expiry]) => expiry >= now).map(([, v]) => v);
39
+ });
40
+ }
41
+ remove(key) {
42
+ return this.persistence.remove(key);
43
+ }
44
+ removeAll() {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const results = yield this.persistence.removeAll();
47
+ return results.map(([, v]) => v);
48
+ });
49
+ }
50
+ store(keyOrValue, maybeValue) {
51
+ const [key, value] = maybeValue === undefined ? [undefined, keyOrValue] : [keyOrValue, maybeValue];
52
+ const expiry = Date.now() + this.expiration(value) * 1000;
53
+ return key === undefined
54
+ ? this.persistence.store([expiry, value])
55
+ : this.persistence.store(key, [expiry, value]);
56
+ }
57
+ }
58
+ //# sourceMappingURL=ExpiringPersistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpiringPersistence.js","sourceRoot":"","sources":["../../src/persistence/ExpiringPersistence.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,MAAM,MAAM,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAC5B,YACqB,UAAgC,EAChC,WAAqC;QADrC,eAAU,GAAV,UAAU,CAAsB;QAChC,gBAAW,GAAX,WAAW,CAA0B;IACvD,CAAC;IAEJ,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACjC,CAAC;IAEK,QAAQ,CAAC,GAAa;;;YACxB,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,MAAA,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;YACrE,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS;gBAAE,OAAO,SAAS,CAAC;YAElE,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,EAAE;gBACrB,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;oBAC/C,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,uDAAuD,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvG,CAAC,CAAC,CAAC;gBACH,OAAO,SAAS,CAAC;aACpB;YACD,OAAO,KAAK,CAAC;;KAChB;IAEK,WAAW;;YACb,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,OAAO,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACxG,CAAC;KAAA;IAED,MAAM,CAAC,GAAa;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;IAEK,SAAS;;YACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;YACnD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;KAAA;IAID,KAAK,CAAC,UAAwB,EAAE,UAAc;QAC1C,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GACd,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,UAAe,CAAC,CAAC,CAAC,CAAC,CAAC,UAAsB,EAAE,UAAU,CAAC,CAAC;QACnG,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1D,OAAO,GAAG,KAAK,SAAS;YACpB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC;CACJ","sourcesContent":["import { ensureError } from \"../common/errorHelpers\";\nimport { getLogger } from \"../logger/logger\";\nimport { Persistence, ValidKey } from \"./Persistence\";\n\nconst logger = getLogger(\"ExpiringPersistence\");\n\n/**\n * Create a Persistence that will remove entries after they expire.\n *\n * An expiration function must be provided, which is called each time a value is stored. It must return the expiration\n * time for that value, given in seconds from now. For example, to expire a value 24 hours after it is stored, the\n * expiration function should return 86400 (the number of seconds in 24 hours).\n */\nexport class ExpiringPersistence<T> implements Persistence<T> {\n constructor(\n private readonly expiration: (value: T) => number,\n private readonly persistence: Persistence<[number, T]>\n ) {}\n\n get size(): number {\n return this.persistence.size;\n }\n\n async retrieve(key: ValidKey): Promise<T | undefined> {\n const [expiry, value] = (await this.persistence.retrieve(key)) ?? [];\n if (value === undefined || expiry === undefined) return undefined;\n\n if (Date.now() > expiry) {\n await this.persistence.remove(key).catch((error) => {\n logger.warn(`Key ${key} is expired, but removing it from persistence failed.`, ensureError(error));\n });\n return undefined;\n }\n return value;\n }\n\n async retrieveAll(): Promise<T[]> {\n const now = Date.now();\n return (await this.persistence.retrieveAll()).filter(([expiry]) => expiry >= now).map(([, v]) => v);\n }\n\n remove(key: ValidKey): Promise<void> {\n return this.persistence.remove(key);\n }\n\n async removeAll(): Promise<T[]> {\n const results = await this.persistence.removeAll();\n return results.map(([, v]) => v);\n }\n\n store(value: T): Promise<ValidKey>;\n store(key: ValidKey, value: T): Promise<ValidKey>;\n store(keyOrValue: T | ValidKey, maybeValue?: T): Promise<ValidKey> {\n const [key, value] =\n maybeValue === undefined ? [undefined, keyOrValue as T] : [keyOrValue as ValidKey, maybeValue];\n const expiry = Date.now() + this.expiration(value) * 1000;\n return key === undefined\n ? this.persistence.store([expiry, value])\n : this.persistence.store(key, [expiry, value]);\n }\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import { Persistence, ValidKey } from "./Persistence";
2
+ /**
3
+ * Specify a database name for this {@link IndexedDBPersistence} instance to use.
4
+ * This will be prefixed by `Snap.CameraKit`.
5
+ *
6
+ * A databaseVersion and objectStore may also be specified. Keep in mind the following limitations:
7
+ * - IndexedDBPersistence currently does nothing to migrate data between versions.
8
+ * - If two different IndexedDBPersistence instances use the same databaseName, they must also use the same objectStore.
9
+ * Otherwise a race condition will occur which prevents the creation of all but one objectStore per database.
10
+ */
11
+ export interface IndexedDBPersistenceOptions {
12
+ databaseName: string;
13
+ databaseVersion?: number;
14
+ objectStore?: string;
15
+ }
16
+ /**
17
+ * A simple key/value persistence using an IndexedDB storage backend.
18
+ *
19
+ * See [Using IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB) for an
20
+ * introduction to how IndexedDB works, its APIs, and how to use it.
21
+ *
22
+ * Note: Currently there is no support for database upgrades. Each instance of this class uses a single IDBObjectStore
23
+ * object set at instantiation time, and there are no hooks for performing migrations between versions. This may be
24
+ * added in the future if such functionality is needed.
25
+ */
26
+ export declare class IndexedDBPersistence<T> implements Persistence<T> {
27
+ size: number;
28
+ private db;
29
+ private readonly databaseName;
30
+ private readonly databaseVersion?;
31
+ private readonly objectStore;
32
+ /**
33
+ * Construct an {@link IndexedDBPersistence} instance corresponding to a given IndexedDB database version.
34
+ *
35
+ * Throws `ConstraintError` if the version number is invalid (e.g. NaN, or less than 1).
36
+ */
37
+ constructor(options: IndexedDBPersistenceOptions);
38
+ retrieve(key: ValidKey): Promise<T | undefined>;
39
+ retrieveAll(): Promise<T[]>;
40
+ remove(key: ValidKey): Promise<void>;
41
+ removeAll(): Promise<T[]>;
42
+ store(value: T): Promise<ValidKey>;
43
+ store(key: ValidKey, value: T): Promise<ValidKey>;
44
+ private openDatabase;
45
+ private simpleTransaction;
46
+ private transaction;
47
+ }