@snap/camera-kit 0.15.1 → 0.17.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 (418) hide show
  1. package/LICENSE.md +139 -3873
  2. package/README.md +3 -3
  3. package/docs/html/assets/main.js +4 -3
  4. package/docs/html/assets/navigation.js +1 -0
  5. package/docs/html/assets/search.js +1 -1
  6. package/docs/html/assets/style.css +72 -25
  7. package/docs/html/classes/CameraKit.html +11 -196
  8. package/docs/html/classes/CameraKitSession.html +43 -366
  9. package/docs/html/classes/CameraKitSource.html +14 -223
  10. package/docs/html/classes/LensPerformanceMeasurement.html +9 -184
  11. package/docs/html/classes/LensPerformanceMetrics.html +7 -148
  12. package/docs/html/classes/LensRepository.html +17 -234
  13. package/docs/html/classes/Transform2D.html +7 -176
  14. package/docs/html/classes/TypedCustomEvent.html +4 -178
  15. package/docs/html/classes/TypedEventTarget.html +4 -209
  16. package/docs/html/enums/Lens_CameraFacing.html +5 -0
  17. package/docs/html/enums/UserData_Zodiac.html +15 -0
  18. package/docs/html/functions/ConcatInjectable.html +10 -193
  19. package/docs/html/functions/Injectable.html +9 -192
  20. package/docs/html/functions/bootstrapCameraKit.html +6 -147
  21. package/docs/html/functions/createExtension.html +6 -123
  22. package/docs/html/functions/createImageSource.html +4 -130
  23. package/docs/html/functions/createMediaStreamSource.html +4 -130
  24. package/docs/html/functions/createVideoSource.html +4 -130
  25. package/docs/html/functions/estimateLensPerformance.html +3 -120
  26. package/docs/html/functions/lensSourcesFactory.html +6 -127
  27. package/docs/html/functions/remoteApiServicesFactory.html +3 -121
  28. package/docs/html/hierarchy.html +1 -0
  29. package/docs/html/index.html +8 -165
  30. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +11 -192
  31. package/docs/html/interfaces/CameraKitDeviceOptions.html +11 -0
  32. package/docs/html/interfaces/CameraKitSourceInfo.html +9 -0
  33. package/docs/html/interfaces/CameraKitSourceSubscriber.html +3 -194
  34. package/docs/html/interfaces/ComputedFrameMetrics.html +2 -150
  35. package/docs/html/interfaces/CreateSessionOptions.html +5 -148
  36. package/docs/html/interfaces/EstimatedLensPerformance.html +3 -146
  37. package/docs/html/interfaces/FunctionSourceOptions.html +7 -0
  38. package/docs/html/interfaces/Lens.html +12 -205
  39. package/docs/html/interfaces/LensCreator.html +3 -0
  40. package/docs/html/interfaces/LensLaunchData.html +3 -179
  41. package/docs/html/interfaces/LensSource.html +3 -172
  42. package/docs/html/interfaces/LoadAssetRequest.html +13 -0
  43. package/docs/html/interfaces/MediaStreamSourceOptions.html +16 -138
  44. package/docs/html/interfaces/Preview.html +4 -141
  45. package/docs/html/interfaces/RemoteApiRequest.html +7 -162
  46. package/docs/html/interfaces/RemoteApiResponse.html +6 -155
  47. package/docs/html/interfaces/RemoteApiService.html +9 -171
  48. package/docs/html/interfaces/Snapcode.html +5 -148
  49. package/docs/html/interfaces/UriCancelRequest.html +2 -138
  50. package/docs/html/interfaces/UriRequest.html +2 -154
  51. package/docs/html/interfaces/UriResponse.html +2 -150
  52. package/docs/html/interfaces/VideoSourceOptions.html +15 -134
  53. package/docs/html/modules.html +57 -175
  54. package/docs/html/types/AssetLoader.html +5 -132
  55. package/docs/html/types/AssetResponse.html +1 -0
  56. package/docs/html/types/AssetTiming.html +2 -115
  57. package/docs/html/types/BenchmarkError.html +1 -112
  58. package/docs/html/types/BootstrapError.html +2 -115
  59. package/docs/html/types/CacheKeyNotFoundError.html +1 -112
  60. package/docs/html/types/CameraKitSessionEventListener.html +2 -115
  61. package/docs/html/types/CameraKitSessionEvents.html +2 -122
  62. package/docs/html/types/CameraKitSourceError.html +1 -112
  63. package/docs/html/types/ConfigurationError.html +2 -115
  64. package/docs/html/types/FetchHandler.html +1 -0
  65. package/docs/html/types/Keyboard.html +14 -194
  66. package/docs/html/types/KeyboardEvents.html +2 -124
  67. package/docs/html/types/LegalError.html +1 -112
  68. package/docs/html/types/LensAbortError.html +2 -115
  69. package/docs/html/types/LensAssetError.html +2 -115
  70. package/docs/html/types/LensContentValidationError.html +1 -112
  71. package/docs/html/types/LensError.html +1 -112
  72. package/docs/html/types/LensExecutionError.html +2 -115
  73. package/docs/html/types/LensImagePickerError.html +2 -115
  74. package/docs/html/types/LensLaunchParams.html +2 -0
  75. package/docs/html/types/LensMetricsEvents.html +2 -115
  76. package/docs/html/types/LensPerformanceCluster.html +1 -113
  77. package/docs/html/types/LensView.html +2 -115
  78. package/docs/html/types/LensWait.html +2 -115
  79. package/docs/html/types/Matrix.html +3 -0
  80. package/docs/html/types/PersistentStoreError.html +2 -115
  81. package/docs/html/types/PlatformNotSupportedError.html +2 -115
  82. package/docs/html/types/PublicContainer.html +2 -115
  83. package/docs/html/types/PublicServices.html +2 -0
  84. package/docs/html/types/RemoteApiCancelRequestHandler.html +2 -0
  85. package/docs/html/types/RemoteApiRequestHandler.html +2 -139
  86. package/docs/html/types/RemoteApiServices.html +1 -112
  87. package/docs/html/types/RemoteApiStatus.html +2 -115
  88. package/docs/html/types/RenderTarget.html +2 -115
  89. package/docs/html/types/Uri.html +1 -112
  90. package/docs/html/types/WebGLError.html +1 -112
  91. package/docs/html/variables/extensionRequestContext.html +2 -115
  92. package/docs/md/README.md +3 -3
  93. package/docs/md/classes/CameraKit.md +15 -15
  94. package/docs/md/classes/CameraKitSession.md +38 -38
  95. package/docs/md/classes/CameraKitSource.md +22 -30
  96. package/docs/md/classes/LensPerformanceMeasurement.md +10 -6
  97. package/docs/md/classes/LensPerformanceMetrics.md +2 -2
  98. package/docs/md/classes/LensRepository.md +18 -18
  99. package/docs/md/classes/Transform2D.md +7 -3
  100. package/docs/md/classes/TypedCustomEvent.md +10 -6
  101. package/docs/md/classes/TypedEventTarget.md +12 -8
  102. package/docs/md/enums/Lens_CameraFacing.md +36 -0
  103. package/docs/md/enums/UserData_Zodiac.md +106 -0
  104. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +2 -2
  105. package/docs/md/interfaces/CameraKitDeviceOptions.md +41 -0
  106. package/docs/md/interfaces/CameraKitSourceInfo.md +43 -0
  107. package/docs/md/interfaces/CameraKitSourceSubscriber.md +7 -7
  108. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  109. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  110. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  111. package/docs/md/interfaces/FunctionSourceOptions.md +22 -0
  112. package/docs/md/interfaces/Lens.md +4 -4
  113. package/docs/md/interfaces/LensCreator.md +17 -0
  114. package/docs/md/interfaces/LensLaunchData.md +6 -6
  115. package/docs/md/interfaces/LensSource.md +5 -5
  116. package/docs/md/interfaces/LoadAssetRequest.md +49 -0
  117. package/docs/md/interfaces/MediaStreamSourceOptions.md +46 -1
  118. package/docs/md/interfaces/Preview.md +1 -1
  119. package/docs/md/interfaces/RemoteApiRequest.md +2 -2
  120. package/docs/md/interfaces/RemoteApiResponse.md +2 -2
  121. package/docs/md/interfaces/RemoteApiService.md +1 -1
  122. package/docs/md/interfaces/Snapcode.md +1 -1
  123. package/docs/md/interfaces/UriCancelRequest.md +2 -2
  124. package/docs/md/interfaces/UriRequest.md +3 -3
  125. package/docs/md/interfaces/UriResponse.md +2 -2
  126. package/docs/md/interfaces/VideoSourceOptions.md +44 -1
  127. package/docs/md/modules.md +183 -201
  128. package/lib/CameraKit.d.ts +108 -108
  129. package/lib/CameraKit.js +1 -1
  130. package/lib/CameraKit.js.map +1 -1
  131. package/lib/bootstrapCameraKit.d.ts +4 -4
  132. package/lib/bootstrapCameraKit.js +21 -20
  133. package/lib/bootstrapCameraKit.js.map +1 -1
  134. package/lib/clients/createTsProtoClient.d.ts +5 -12
  135. package/lib/clients/createTsProtoClient.js +1 -2
  136. package/lib/clients/createTsProtoClient.js.map +1 -1
  137. package/lib/clients/grpcHandler.d.ts +7 -4
  138. package/lib/clients/grpcHandler.js +8 -5
  139. package/lib/clients/grpcHandler.js.map +1 -1
  140. package/lib/clients/lensesClient.d.ts +3 -3
  141. package/lib/clients/lensesClient.js +2 -2
  142. package/lib/clients/lensesClient.js.map +1 -1
  143. package/lib/clients/metricsClient.d.ts +26 -0
  144. package/lib/clients/metricsClient.js +120 -0
  145. package/lib/clients/metricsClient.js.map +1 -0
  146. package/lib/configuration.js +1 -1
  147. package/lib/configuration.js.map +1 -1
  148. package/lib/dependency-injection/Container.d.ts +1 -1
  149. package/lib/dependency-injection/Container.js +1 -1
  150. package/lib/dependency-injection/Container.js.map +1 -1
  151. package/lib/dependency-injection/Injectable.d.ts +6 -6
  152. package/lib/dependency-injection/Injectable.js.map +1 -1
  153. package/lib/dependency-injection/RootServices.d.ts +7 -8
  154. package/lib/dependency-injection/RootServices.js.map +1 -1
  155. package/lib/environment.d.ts +4 -0
  156. package/lib/environment.js +2 -0
  157. package/lib/environment.js.map +1 -0
  158. package/lib/extensions/RemoteApiServices.d.ts +2 -2
  159. package/lib/extensions/RemoteApiServices.js +11 -6
  160. package/lib/extensions/RemoteApiServices.js.map +1 -1
  161. package/lib/extensions/uriHandlersRegister.d.ts +4 -4
  162. package/lib/extensions/uriHandlersRegister.js +6 -6
  163. package/lib/extensions/uriHandlersRegister.js.map +1 -1
  164. package/lib/generated-proto/blizzard/cameraKitEvents.d.ts +4330 -678
  165. package/lib/generated-proto/blizzard/cameraKitEvents.js +515 -72
  166. package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
  167. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +3 -11
  168. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +6 -156
  169. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
  170. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +19 -19
  171. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +13 -27
  172. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
  173. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +0 -6
  174. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +2 -83
  175. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  176. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +0 -22
  177. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +0 -263
  178. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
  179. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +30 -34
  180. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +7 -73
  181. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
  182. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +0 -6
  183. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +0 -110
  184. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
  185. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +48 -114
  186. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +0 -225
  187. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  188. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +6 -6
  189. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +5 -19
  190. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
  191. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +1422 -1422
  192. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +12 -12
  193. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +10 -24
  194. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
  195. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +207 -207
  196. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +530 -530
  197. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +10 -24
  198. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
  199. package/lib/generated-proto/pb_schema/common/value.d.ts +6 -6
  200. package/lib/generated-proto/pb_schema/common/value.js +4 -18
  201. package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
  202. package/lib/generated-proto/pb_schema/google/api/http.d.ts +0 -6
  203. package/lib/generated-proto/pb_schema/google/api/http.js +0 -77
  204. package/lib/generated-proto/pb_schema/google/api/http.js.map +1 -1
  205. package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +0 -2
  206. package/lib/generated-proto/pb_schema/google/protobuf/any.js +0 -44
  207. package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
  208. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.d.ts +4830 -4896
  209. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js +10 -997
  210. package/lib/generated-proto/pb_schema/google/protobuf/descriptor.js.map +1 -1
  211. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +3 -5
  212. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +6 -35
  213. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
  214. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +6 -6
  215. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +10 -24
  216. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
  217. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +9 -9
  218. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +11 -11
  219. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +6 -20
  220. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -1
  221. package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +42 -42
  222. package/lib/generated-proto/pb_schema/lenses/snappable.js +14 -28
  223. package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
  224. package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +8 -8
  225. package/lib/generated-proto/pb_schema/lenses/user_data.js +8 -22
  226. package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
  227. package/lib/handlers/defaultFetchHandler.d.ts +1 -1
  228. package/lib/handlers/defaultFetchHandler.js.map +1 -1
  229. package/lib/handlers/requestStateEmittingHandler.d.ts +5 -6
  230. package/lib/handlers/requestStateEmittingHandler.js +6 -8
  231. package/lib/handlers/requestStateEmittingHandler.js.map +1 -1
  232. package/lib/handlers/responseCachingHandler.d.ts +9 -10
  233. package/lib/handlers/responseCachingHandler.js +9 -3
  234. package/lib/handlers/responseCachingHandler.js.map +1 -1
  235. package/lib/handlers/utils.d.ts +12 -0
  236. package/lib/handlers/utils.js +19 -0
  237. package/lib/handlers/utils.js.map +1 -0
  238. package/lib/index.d.ts +21 -15
  239. package/lib/index.js +17 -12
  240. package/lib/index.js.map +1 -1
  241. package/lib/lens/Lens.d.ts +12 -2
  242. package/lib/lens/Lens.js +5 -0
  243. package/lib/lens/Lens.js.map +1 -1
  244. package/lib/lens/LensLaunchData.d.ts +6 -3
  245. package/lib/lens/LensLaunchData.js +2 -0
  246. package/lib/lens/LensLaunchData.js.map +1 -1
  247. package/lib/lens/LensPersistenceStore.d.ts +1 -1
  248. package/lib/lens/LensPersistenceStore.js +1 -1
  249. package/lib/lens/LensPersistenceStore.js.map +1 -1
  250. package/lib/lens/LensRepository.d.ts +5 -1
  251. package/lib/lens/LensRepository.js +9 -5
  252. package/lib/lens/LensRepository.js.map +1 -1
  253. package/lib/lens/LensSource.d.ts +2 -2
  254. package/lib/lens/LensSource.js +4 -4
  255. package/lib/lens/LensSource.js.map +1 -1
  256. package/lib/lens/assets/LensAssetRepository.d.ts +35 -4
  257. package/lib/lens/assets/LensAssetRepository.js +9 -9
  258. package/lib/lens/assets/LensAssetRepository.js.map +1 -1
  259. package/lib/lens/assets/LensAssetsProvider.d.ts +1 -1
  260. package/lib/lens/assets/LensAssetsProvider.js +9 -4
  261. package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
  262. package/lib/lens/assets/deviceDependentAssetLoader.js +3 -2
  263. package/lib/lens/assets/deviceDependentAssetLoader.js.map +1 -1
  264. package/lib/lens/assets/remoteMediaAssetLoaderFactory.js +4 -3
  265. package/lib/lens/assets/remoteMediaAssetLoaderFactory.js.map +1 -1
  266. package/lib/lens/assets/staticAssetLoader.js +5 -4
  267. package/lib/lens/assets/staticAssetLoader.js.map +1 -1
  268. package/lib/lens/cameraKitLensSource.d.ts +3 -2
  269. package/lib/lens/cameraKitLensSource.js +87 -42
  270. package/lib/lens/cameraKitLensSource.js.map +1 -1
  271. package/lib/lens/fetchWatermarkLens.d.ts +11 -0
  272. package/lib/lens/fetchWatermarkLens.js +27 -0
  273. package/lib/lens/fetchWatermarkLens.js.map +1 -0
  274. package/lib/lens-client-interface/imagePicker.d.ts +2 -1
  275. package/lib/lens-client-interface/imagePicker.js.map +1 -1
  276. package/lib/lens-client-interface/lensClientInterface.d.ts +1 -1
  277. package/lib/lens-client-interface/lensClientInterface.js +1 -1
  278. package/lib/lens-client-interface/lensClientInterface.js.map +1 -1
  279. package/lib/lens-core-module/lensCore.d.ts +2 -1
  280. package/lib/lens-core-module/lensCore.js.map +1 -1
  281. package/lib/lens-core-module/loader/bootstrapURLs.d.ts +12 -0
  282. package/lib/lens-core-module/loader/bootstrapURLs.js +48 -0
  283. package/lib/lens-core-module/loader/bootstrapURLs.js.map +1 -0
  284. package/lib/lens-core-module/loader/lensCoreFactory.d.ts +0 -12
  285. package/lib/lens-core-module/loader/lensCoreFactory.js +4 -49
  286. package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  287. package/lib/lensCoreWasmVersions.d.ts +6 -0
  288. package/lib/lensCoreWasmVersions.js +6 -0
  289. package/lib/lensCoreWasmVersions.js.map +1 -0
  290. package/lib/media-sources/CameraKitSource.d.ts +39 -17
  291. package/lib/media-sources/CameraKitSource.js +8 -2
  292. package/lib/media-sources/CameraKitSource.js.map +1 -1
  293. package/lib/media-sources/FunctionSource.d.ts +15 -4
  294. package/lib/media-sources/FunctionSource.js +1 -2
  295. package/lib/media-sources/FunctionSource.js.map +1 -1
  296. package/lib/media-sources/ImageSource.d.ts +3 -5
  297. package/lib/media-sources/ImageSource.js +1 -3
  298. package/lib/media-sources/ImageSource.js.map +1 -1
  299. package/lib/media-sources/MediaStreamSource.d.ts +17 -33
  300. package/lib/media-sources/MediaStreamSource.js +6 -41
  301. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  302. package/lib/media-sources/VideoSource.d.ts +14 -10
  303. package/lib/media-sources/VideoSource.js +5 -11
  304. package/lib/media-sources/VideoSource.js.map +1 -1
  305. package/lib/metrics/businessEventsReporter.d.ts +3 -4
  306. package/lib/metrics/businessEventsReporter.js +11 -55
  307. package/lib/metrics/businessEventsReporter.js.map +1 -1
  308. package/lib/metrics/operational/Count.d.ts +2 -0
  309. package/lib/metrics/operational/Count.js +6 -1
  310. package/lib/metrics/operational/Count.js.map +1 -1
  311. package/lib/metrics/operational/Histogram.d.ts +1 -1
  312. package/lib/metrics/operational/Histogram.js +7 -3
  313. package/lib/metrics/operational/Histogram.js.map +1 -1
  314. package/lib/metrics/operational/Metric.js +2 -0
  315. package/lib/metrics/operational/Metric.js.map +1 -1
  316. package/lib/metrics/operational/Timer.d.ts +9 -6
  317. package/lib/metrics/operational/Timer.js +12 -26
  318. package/lib/metrics/operational/Timer.js.map +1 -1
  319. package/lib/metrics/reporters/reportBenchmarks.d.ts +3 -3
  320. package/lib/metrics/reporters/reportBenchmarks.js +6 -5
  321. package/lib/metrics/reporters/reportBenchmarks.js.map +1 -1
  322. package/lib/metrics/reporters/reportGlobalException.d.ts +4 -4
  323. package/lib/metrics/reporters/reportGlobalException.js +13 -11
  324. package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
  325. package/lib/metrics/reporters/reportHttpMetrics.d.ts +3 -3
  326. package/lib/metrics/reporters/reportHttpMetrics.js +19 -16
  327. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  328. package/lib/metrics/reporters/reportLegalState.d.ts +3 -3
  329. package/lib/metrics/reporters/reportLegalState.js +7 -9
  330. package/lib/metrics/reporters/reportLegalState.js.map +1 -1
  331. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +3 -3
  332. package/lib/metrics/reporters/reportLensAndAssetDownload.js +12 -12
  333. package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
  334. package/lib/metrics/reporters/reportLensView.d.ts +3 -3
  335. package/lib/metrics/reporters/reportLensView.js +6 -6
  336. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  337. package/lib/metrics/reporters/reportLensWait.d.ts +2 -3
  338. package/lib/metrics/reporters/reportLensWait.js +1 -3
  339. package/lib/metrics/reporters/reportLensWait.js.map +1 -1
  340. package/lib/metrics/reporters/reportPlatformCapabilities.d.ts +3 -3
  341. package/lib/metrics/reporters/reportPlatformCapabilities.js +6 -5
  342. package/lib/metrics/reporters/reportPlatformCapabilities.js.map +1 -1
  343. package/lib/metrics/reporters/reportUserSession.js +3 -3
  344. package/lib/metrics/reporters/reportUserSession.js.map +1 -1
  345. package/lib/metrics/reporters/reporters.d.ts +2 -2
  346. package/lib/namedErrors.d.ts +1 -1
  347. package/lib/namedErrors.js +1 -1
  348. package/lib/namedErrors.js.map +1 -1
  349. package/lib/observable-operators/unsubscribed.d.ts +1 -1
  350. package/lib/observable-operators/unsubscribed.js +1 -1
  351. package/lib/observable-operators/unsubscribed.js.map +1 -1
  352. package/lib/platform/platformCapabilities.d.ts +1 -1
  353. package/lib/platform/platformCapabilities.js +9 -3
  354. package/lib/platform/platformCapabilities.js.map +1 -1
  355. package/lib/platform/platformInfo.d.ts +1 -0
  356. package/lib/platform/platformInfo.js +3 -3
  357. package/lib/platform/platformInfo.js.map +1 -1
  358. package/lib/remote-configuration/cofHandler.d.ts +3 -3
  359. package/lib/remote-configuration/cofHandler.js +6 -4
  360. package/lib/remote-configuration/cofHandler.js.map +1 -1
  361. package/lib/remote-configuration/preloadConfiguration.d.ts +1 -1
  362. package/lib/remote-configuration/preloadConfiguration.js +9 -4
  363. package/lib/remote-configuration/preloadConfiguration.js.map +1 -1
  364. package/lib/remote-configuration/remoteConfiguration.d.ts +7 -6
  365. package/lib/remote-configuration/remoteConfiguration.js +18 -15
  366. package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
  367. package/lib/session/CameraKitSession.d.ts +8 -8
  368. package/lib/session/CameraKitSession.js +11 -9
  369. package/lib/session/CameraKitSession.js.map +1 -1
  370. package/lib/session/LensKeyboard.d.ts +1 -7
  371. package/lib/session/LensKeyboard.js.map +1 -1
  372. package/lib/session/LensPerformanceMeasurement.d.ts +1 -1
  373. package/lib/session/LensPerformanceMeasurement.js +3 -3
  374. package/lib/session/LensPerformanceMeasurement.js.map +1 -1
  375. package/lib/session/LensPerformanceMetrics.d.ts +1 -1
  376. package/lib/session/LensPerformanceMetrics.js.map +1 -1
  377. package/lib/session/lensState.d.ts +5 -4
  378. package/lib/session/lensState.js +80 -57
  379. package/lib/session/lensState.js.map +1 -1
  380. package/lib/transforms/Transform2D.d.ts +8 -3
  381. package/lib/transforms/Transform2D.js +1 -1
  382. package/lib/transforms/Transform2D.js.map +1 -1
  383. package/lib/utils.d.ts +3 -0
  384. package/lib/utils.js +4 -0
  385. package/lib/utils.js.map +1 -0
  386. package/package.json +27 -6
  387. package/docs/html/functions/createUserMediaSource.html +0 -138
  388. package/docs/html/functions/getRequiredBootstrapURLs.html +0 -130
  389. package/docs/html/types/CameraKitDeviceInfo.html +0 -125
  390. package/docs/html/types/CameraKitDeviceOptions.html +0 -120
  391. package/docs/html/types/CameraKitSourceInfo.html +0 -112
  392. package/docs/html/types/CameraKitSourceOptions.html +0 -118
  393. package/lib/common/index.d.ts +0 -2
  394. package/lib/common/index.js +0 -3
  395. package/lib/common/index.js.map +0 -1
  396. package/lib/environment.json +0 -1
  397. package/lib/handlers/index.d.ts +0 -2
  398. package/lib/handlers/index.js +0 -3
  399. package/lib/handlers/index.js.map +0 -1
  400. package/lib/lens-core-module/index.d.ts +0 -3
  401. package/lib/lens-core-module/index.js +0 -4
  402. package/lib/lens-core-module/index.js.map +0 -1
  403. package/lib/lens-core-module/loader/index.d.ts +0 -1
  404. package/lib/lens-core-module/loader/index.js +0 -2
  405. package/lib/lens-core-module/loader/index.js.map +0 -1
  406. package/lib/lensCoreWasmVersions.json +0 -5
  407. package/lib/metrics/metricsHandler.d.ts +0 -10
  408. package/lib/metrics/metricsHandler.js +0 -13
  409. package/lib/metrics/metricsHandler.js.map +0 -1
  410. package/lib/metrics/operational/operationalMetricsReporter.d.ts +0 -64
  411. package/lib/metrics/operational/operationalMetricsReporter.js +0 -144
  412. package/lib/metrics/operational/operationalMetricsReporter.js.map +0 -1
  413. package/lib/session/index.d.ts +0 -1
  414. package/lib/session/index.js +0 -2
  415. package/lib/session/index.js.map +0 -1
  416. package/lib/transforms/index.d.ts +0 -1
  417. package/lib/transforms/index.js +0 -2
  418. package/lib/transforms/index.js.map +0 -1
@@ -1,8 +1,7 @@
1
1
  import { defineAction, defineActions, defineState, defineStates, dispatch, forActions, inStates, StateMachine, } from "@snap/state-management";
2
- import { catchError, exhaustMap, from, map, merge, mergeMap, Observable, of, switchMap, take, takeUntil, tap, } from "rxjs";
2
+ import { catchError, exhaustMap, forkJoin, from, map, merge, mergeMap, Observable, of, switchMap, take, takeUntil, tap, } from "rxjs";
3
3
  import { Injectable } from "../dependency-injection/Injectable";
4
4
  import { lensRepositoryFactory } from "../lens/LensRepository";
5
- import { lensCoreFactory } from "../lens-core-module";
6
5
  import { lensPersistenceStoreFactory } from "../lens/LensPersistenceStore";
7
6
  import { encodeLensLaunchData } from "../lens/LensLaunchData";
8
7
  import { legalStateFactory } from "../legal/legalState";
@@ -10,9 +9,12 @@ import { lensAssetRepositoryFactory } from "../lens/assets/LensAssetRepository";
10
9
  import { legalError, lensContentValidationError, lensError, } from "../namedErrors";
11
10
  import { getLogger } from "../logger/logger";
12
11
  import { Timer } from "../metrics/operational/Timer";
13
- import { operationalMetricReporterFactory, } from "../metrics/operational/operationalMetricsReporter";
14
12
  import { unsubscribed } from "../observable-operators/unsubscribed";
15
13
  import { assertUnreachable } from "../common/assertions";
14
+ import { metricsClientFactory } from "../clients/metricsClient";
15
+ import { lensCoreFactory } from "../lens-core-module/loader/lensCoreFactory";
16
+ import { remoteConfigurationFactory } from "../remote-configuration/remoteConfiguration";
17
+ import { watermarksLensGroup } from "../lens/fetchWatermarkLens";
16
18
  const logger = getLogger("LensState");
17
19
  const createLensState = () => {
18
20
  const actions = defineActions(defineAction("applyLens")(), defineAction("downloadComplete")(), defineAction("turnedOn")(), defineAction("resourcesLoaded")(), defineAction("firstFrameProcessed")(), defineAction("applyLensComplete")(), defineAction("applyLensFailed")(), defineAction("applyLensAborted")(), defineAction("removeLens")(), defineAction("turnedOff")(), defineAction("removeLensComplete")(), defineAction("removeLensFailed")());
@@ -27,8 +29,9 @@ export const lensStateFactory = Injectable("lensState", [
27
29
  lensAssetRepositoryFactory.token,
28
30
  lensPersistenceStoreFactory.token,
29
31
  legalStateFactory.token,
30
- operationalMetricReporterFactory.token,
31
- ], (lensCore, lensRepository, lensAssetRepository, lensPersistence, legalState, operationalMetricsReporter) => {
32
+ metricsClientFactory.token,
33
+ remoteConfigurationFactory.token,
34
+ ], (lensCore, lensRepository, lensAssetRepository, lensPersistence, legalState, metrics, remoteConfig) => {
32
35
  const lensState = createLensState();
33
36
  let firstLensApply = true;
34
37
  /**
@@ -63,58 +66,76 @@ export const lensStateFactory = Injectable("lensState", [
63
66
  // are not present for subsequent applies.
64
67
  const applyTimer = new Timer("lens").mark("apply", { first: `${firstLensApply}` });
65
68
  firstLensApply = false;
66
- return of(a.data).pipe(mergeMap(({ lens, launchData }) => {
67
- // If retrieval throws an error, we still want to proceed with the lens
68
- // because persisted data is not a necessity.
69
- return from(lensPersistence.retrieve(lens.id).catch(() => undefined)).pipe(map((persistentStore) => ({ lens, launchData, persistentStore })));
70
- }), map(({ lens, launchData, persistentStore }) => {
71
- const lensDetails = lensRepository.getLensMetadata(lens.id);
72
- if (!lensDetails) {
73
- throw new Error(`Cannot apply lens ${lens.id}. It has not been loaded by the Lens ` +
74
- `repository. Use CameraKit.lensRepository.loadLens (or loadLensGroups) ` +
75
- `to load lens metadata before calling CameraKitSession.applyLens.`);
76
- }
77
- const { content } = lensDetails;
78
- if (!content) {
79
- throw new Error(`Cannot apply lens ${lens.id}. Metadata retrieved for this lens does not ` +
80
- `include the lens content URL.`);
81
- }
82
- return {
83
- lens,
84
- launchData: encodeLensLaunchData(launchData !== null && launchData !== void 0 ? launchData : {}, persistentStore !== null && persistentStore !== void 0 ? persistentStore : new ArrayBuffer(0)),
85
- content,
86
- };
87
- }),
88
- // Load lens assets and the lens itself in parallel. Both count toward lens download time.
89
- // TODO: use RxJS fetch utilities so that these requests can be cancelled on unsubscribe.
90
- mergeMap(({ lens, launchData, content }) => {
91
- const networkTimer = applyTimer.mark("network");
92
- return from(Promise.all([
93
- lensRepository.getLensContent(lens).finally(() => networkTimer.measure("lens")),
94
- content.assetManifest.length > 0
95
- ? lensAssetRepository
96
- .cacheAssets(content.assetManifest, lens)
97
- .finally(() => networkTimer.measure("assets"))
98
- : Promise.resolve(),
99
- ])).pipe(tap(() => {
100
- networkTimer.measure();
101
- lensState.dispatch("downloadComplete", lens);
102
- }), map(([{ lensBuffer, lensChecksum }]) => {
103
- // NOTE: cached array buffer has to be copied each time in order to be reused,
104
- // otherwise the original cached copy would be detached by LensCore
105
- // One optimization can be done here: do not copy the array if getLensContent()
106
- // returned uncached buffer
107
- const lensDataBuffer = lensBuffer.slice(0);
108
- return { lensId: lens.id, lensDataBuffer, lensChecksum, launchData };
109
- }));
110
- }),
69
+ return forkJoin({
70
+ watermarkInput: remoteConfig.getInitializationConfig().pipe(mergeMap((config) => {
71
+ if (!config.watermarkEnabled)
72
+ return of(undefined);
73
+ return from(lensRepository.loadLens("", watermarksLensGroup)).pipe(mergeMap((watermark) =>
74
+ // NOTE: we expect that watermark lens is preloaded,
75
+ // to not affect loading time of the actual lens
76
+ from(lensRepository.getLensContent(watermark)).pipe(map(({ lensBuffer, lensChecksum }) => {
77
+ return {
78
+ lensId: watermark.id,
79
+ // Copy buffer, so LC can own the copy
80
+ lensDataBuffer: lensBuffer.slice(0),
81
+ lensChecksum,
82
+ launchData: new ArrayBuffer(0),
83
+ };
84
+ }))));
85
+ })),
86
+ lensInput: of(a.data).pipe(mergeMap(({ lens, launchData }) => {
87
+ // If retrieval throws an error, we still want to proceed with the lens
88
+ // because persisted data is not a necessity.
89
+ return from(lensPersistence.retrieve(lens.id).catch(() => undefined)).pipe(map((persistentStore) => ({ lens, launchData, persistentStore })));
90
+ }), map(({ lens, launchData, persistentStore }) => {
91
+ const lensDetails = lensRepository.getLensMetadata(lens.id);
92
+ if (!lensDetails) {
93
+ throw new Error(`Cannot apply lens ${lens.id}. It has not been loaded by the Lens ` +
94
+ `repository. Use CameraKit.lensRepository.loadLens (or loadLensGroups) ` +
95
+ `to load lens metadata before calling CameraKitSession.applyLens.`);
96
+ }
97
+ const { content } = lensDetails;
98
+ if (!content) {
99
+ throw new Error(`Cannot apply lens ${lens.id}. Metadata retrieved for this lens does not ` +
100
+ `include the lens content URL.`);
101
+ }
102
+ return {
103
+ lens,
104
+ launchData: encodeLensLaunchData(launchData !== null && launchData !== void 0 ? launchData : {}, persistentStore !== null && persistentStore !== void 0 ? persistentStore : new ArrayBuffer(0)),
105
+ content,
106
+ };
107
+ }),
108
+ // Load lens assets and the lens itself in parallel. Both count toward lens download time.
109
+ // TODO: use RxJS fetch utilities so that these requests can be cancelled on unsubscribe.
110
+ mergeMap(({ lens, launchData, content }) => {
111
+ const networkTimer = applyTimer.mark("network");
112
+ return from(Promise.all([
113
+ lensRepository.getLensContent(lens).finally(() => networkTimer.measure("lens")),
114
+ content.assetManifest.length > 0
115
+ ? lensAssetRepository
116
+ .cacheAssets(content.assetManifest, lens)
117
+ .finally(() => networkTimer.measure("assets"))
118
+ : Promise.resolve(),
119
+ ])).pipe(tap(() => {
120
+ networkTimer.measure();
121
+ lensState.dispatch("downloadComplete", lens);
122
+ }), map(([{ lensBuffer, lensChecksum }]) => {
123
+ // NOTE: cached array buffer has to be copied each time in order to be reused,
124
+ // otherwise the original cached copy would be detached by LensCore
125
+ // One optimization can be done here: do not copy the array if getLensContent()
126
+ // returned uncached buffer
127
+ const lensDataBuffer = lensBuffer.slice(0);
128
+ return { lensId: lens.id, lensDataBuffer, lensChecksum, launchData };
129
+ }));
130
+ })),
131
+ }).pipe(
111
132
  // If removeLens is dispatched while downloading, cancel download, don't apply the lens.
112
133
  takeUntil(lensState.events.pipe(forActions("removeLens"))),
113
134
  // Once the lens has downloaded, we can call replaceLenses. We're not concerned about
114
135
  // waiting for prior in-progress calls to replaceLenses to complete, because LensCore
115
136
  // guarantees that calls to replaceLenses will always be processed sequentially in the order
116
137
  // they are received.
117
- mergeMap((lensInput) => new Observable((subscriber) => {
138
+ mergeMap(({ lensInput, watermarkInput }) => new Observable((subscriber) => {
118
139
  const coreTimer = applyTimer.mark("core");
119
140
  // replaceLenses has the property that if it fails, LensCore guarantees that no
120
141
  // lenses are active – so we can safely dispatch applyLensFailed and transition
@@ -130,9 +151,11 @@ export const lensStateFactory = Injectable("lensState", [
130
151
  onFirstFrameProcessed: () => {
131
152
  coreTimer.measure("first-frame");
132
153
  applyTimer.measure("success");
133
- applyTimer.stopAndReport(operationalMetricsReporter);
154
+ applyTimer.stopAndReport(metrics);
134
155
  dispatch("firstFrameProcessed");
135
156
  }, onTurnOff: () => dispatch("turnedOff") }),
157
+ // Watermark is always applied last
158
+ ...(watermarkInput ? [watermarkInput] : []),
136
159
  ],
137
160
  })
138
161
  .then(() => {
@@ -151,7 +174,7 @@ export const lensStateFactory = Injectable("lensState", [
151
174
  .catch((lensCoreError) => {
152
175
  coreTimer.measure("failure");
153
176
  applyTimer.measure("failure");
154
- applyTimer.stopAndReport(operationalMetricsReporter);
177
+ applyTimer.stopAndReport(metrics);
155
178
  const message = `Failed to apply lens ${lensInput.lensId}.`;
156
179
  const error = /validation failed/.test(lensCoreError.message)
157
180
  ? lensContentValidationError(message, lensCoreError)
@@ -161,7 +184,7 @@ export const lensStateFactory = Injectable("lensState", [
161
184
  });
162
185
  })), catchError((error) => {
163
186
  applyTimer.measure("failure");
164
- applyTimer.stopAndReport(operationalMetricsReporter);
187
+ applyTimer.stopAndReport(metrics);
165
188
  return of(lensState.actions.applyLensFailed({ error, lens }));
166
189
  }),
167
190
  // If a new applyLens is received, `switchMap` will unsubscribe from this inner observable,
@@ -169,7 +192,7 @@ export const lensStateFactory = Injectable("lensState", [
169
192
  // to measure aborted lens applications.
170
193
  unsubscribed(() => {
171
194
  applyTimer.measure("abort");
172
- applyTimer.stopAndReport(operationalMetricsReporter);
195
+ applyTimer.stopAndReport(metrics);
173
196
  }));
174
197
  }), dispatch(lensState))
175
198
  .subscribe({
@@ -199,8 +222,8 @@ export const lensStateFactory = Injectable("lensState", [
199
222
  .pipe(inStates("applyingLens"), forActions("removeLens"), switchMap(([a]) => lensState.events.pipe(
200
223
  // Wait to remove the lens until it has been applied.
201
224
  inStates("lensApplied"),
202
- // But cancel the removal if a new applyLens supercedes the current lens. The goal here is to
203
- // make sure the latest apply/remove pre-empts any previous request to apply/remove.
225
+ // But cancel the removal if a new applyLens supersedes the current lens. The goal here is to
226
+ // make sure the latest apply/remove preempts any previous request to apply/remove.
204
227
  takeUntil(lensState.events.pipe(forActions("applyLens"))), map(() => a))), dispatch(lensState))
205
228
  .subscribe({
206
229
  error: logger.error,
@@ -1 +1 @@
1
- {"version":3,"file":"lensState.js","sourceRoot":"","sources":["../../src/session/lensState.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,YAAY,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,UAAU,EACV,UAAU,EACV,IAAI,EACJ,GAAG,EACH,KAAK,EACL,QAAQ,EACR,UAAU,EACV,EAAE,EACF,SAAS,EACT,IAAI,E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QAC7E,KAAK,kBAAkB,CAAC;QACxB,KAAK,UAAU,CAAC;QAChB,KAAK,iBAAiB,CAAC;QACvB,KAAK,qBAAqB,CAAC;QAC3B,KAAK,mBAAmB,CAAC;QACzB,KAAK,kBAAkB,CAAC;QACxB,KAAK,WAAW;YACZ,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,YAAY,CAAC;QAClB,KAAK,oBAAoB;YACrB,OAAO,SAAS,CAAC;QACrB,KAAK,kBAAkB;YACnB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1C;YACI,iBAAiB,CAAC,MAAM,CAAC,CAAC;KACjC;AACL,CAAC","sourcesContent":["import {\n Actions,\n defineAction,\n defineActions,\n defineState,\n defineStates,\n dispatch,\n forActions,\n inStates,\n StateMachine,\n} from \"@snap/state-management\";\nimport {\n catchError,\n exhaustMap,\n from,\n map,\n merge,\n mergeMap,\n Observable,\n of,\n switchMap,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { Lens } from \"../lens/Lens\";\nimport { LensRepository, lensRepositoryFactory } from \"../lens/LensRepository\";\nimport { lensCoreFactory, LensCore } from \"../lens-core-module\";\nimport { AddLensInput } from \"../lens-core-module/generated-types\";\nimport { IndexedDBPersistence } from \"../persistence/IndexedDBPersistence\";\nimport { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport { encodeLensLaunchData, LensLaunchData } from \"../lens/LensLaunchData\";\nimport { LegalState, legalStateFactory } from \"../legal/legalState\";\nimport { LensAssetRepository, lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport {\n legalError,\n LegalError,\n lensContentValidationError,\n LensContentValidationError,\n lensError,\n LensError,\n} from \"../namedErrors\";\nimport { getLogger } from \"../logger/logger\";\nimport { Timer } from \"../metrics/operational/Timer\";\nimport {\n operationalMetricReporterFactory,\n OperationalMetricsReporter,\n} from \"../metrics/operational/operationalMetricsReporter\";\nimport { unsubscribed } from \"../observable-operators/unsubscribed\";\nimport { assertUnreachable } from \"../common/assertions\";\n\nconst logger = getLogger(\"LensState\");\n\nconst createLensState = () => {\n const actions = defineActions(\n defineAction(\"applyLens\")<{ lens: Lens; launchData?: LensLaunchData }>(),\n defineAction(\"downloadComplete\")<Lens>(),\n defineAction(\"turnedOn\")<Lens>(),\n defineAction(\"resourcesLoaded\")<Lens>(),\n defineAction(\"firstFrameProcessed\")<Lens>(),\n defineAction(\"applyLensComplete\")<Lens>(),\n defineAction(\"applyLensFailed\")<{ error: LensErrors; lens: Lens }>(),\n defineAction(\"applyLensAborted\")<Lens>(),\n\n defineAction(\"removeLens\")(),\n defineAction(\"turnedOff\")<Lens>(),\n defineAction(\"removeLensComplete\")(),\n defineAction(\"removeLensFailed\")<Error>()\n );\n\n const states = defineStates(\n defineState(\"noLensApplied\")(),\n defineState(\"applyingLens\")<Lens>(),\n defineState(\"lensApplied\")<Lens>()\n );\n\n return new StateMachine(actions, states, states.noLensApplied(), (events) =>\n merge(\n events.pipe(\n // We allow a new lens to be applied at any time, no matter the state.\n inStates(\"noLensApplied\", \"applyingLens\", \"lensApplied\"),\n forActions(\"applyLens\"),\n map(([a]) => states.applyingLens(a.data.lens))\n ),\n events.pipe(\n inStates(\"applyingLens\"),\n forActions(\"applyLensComplete\"),\n map(([a]) => states.lensApplied(a.data))\n ),\n events.pipe(\n inStates(\"applyingLens\"),\n forActions(\"applyLensFailed\"),\n map(() => states.noLensApplied())\n ),\n events.pipe(\n inStates(\"lensApplied\"),\n forActions(\"removeLensComplete\"),\n map(() => states.noLensApplied())\n )\n )\n );\n};\n\nexport type LensErrors = LegalError | LensContentValidationError | LensError;\n\nexport type LensState = ReturnType<typeof createLensState>;\n\nexport const lensStateFactory = Injectable(\n \"lensState\",\n [\n lensCoreFactory.token,\n lensRepositoryFactory.token,\n lensAssetRepositoryFactory.token,\n lensPersistenceStoreFactory.token,\n legalStateFactory.token,\n operationalMetricReporterFactory.token,\n ] as const,\n (\n lensCore: LensCore,\n lensRepository: LensRepository,\n lensAssetRepository: LensAssetRepository,\n lensPersistence: IndexedDBPersistence<ArrayBuffer>,\n legalState: LegalState,\n operationalMetricsReporter: OperationalMetricsReporter\n ): LensState => {\n const lensState = createLensState();\n let firstLensApply = true;\n\n /**\n * Apply lens\n */\n lensState.events\n .pipe(\n forActions(\"applyLens\"),\n\n // Determine the legal state (e.g. terms have been accepted). Using exhaustMap means while we are\n // ascertaining legal status (which may include prompting the end user to accept terms), we will ignore\n // any new applyLens actions.\n exhaustMap(([a]) =>\n of(legalState.actions.requestLegalPrompt()).pipe(\n dispatch(legalState),\n inStates(\"accepted\", \"rejected\"),\n take(1),\n map(([, { name }]) => {\n if (name === \"accepted\") return a;\n return lensState.actions.applyLensFailed({\n error: legalError(\n `Failed to apply lens ${a.data.lens.id}. Required legal terms were not accepted.`\n ),\n lens: a.data.lens,\n });\n })\n )\n ),\n\n // The use of switchMap is important so that if we get a new applyLens action while we're still\n // downloading lens content for a previously-requested lens, we can cancel those requests and ensure\n // that lenses are applied in the order they're requested.\n switchMap((a) => {\n if (a.name === \"applyLensFailed\") return of(a);\n\n const { lens } = a.data;\n // Convenience method making dispatching an action with Lens data less verbose.\n const dispatch = (action: Extract<Actions<LensState>, { data: Lens }>[\"name\"]) => {\n lensState.dispatch(action, lens);\n };\n\n // We record if this was the first lens apply for this page load, since there may be additional\n // sources of latency (e.g. remote configuration that needs to be loaded) on the first apply that\n // are not present for subsequent applies.\n const applyTimer = new Timer(\"lens\").mark(\"apply\", { first: `${firstLensApply}` });\n firstLensApply = false;\n\n return of(a.data).pipe(\n mergeMap(({ lens, launchData }) => {\n // If retrieval throws an error, we still want to proceed with the lens\n // because persisted data is not a necessity.\n return from(lensPersistence.retrieve(lens.id).catch(() => undefined)).pipe(\n map((persistentStore) => ({ lens, launchData, persistentStore }))\n );\n }),\n\n map(({ lens, launchData, persistentStore }) => {\n const lensDetails = lensRepository.getLensMetadata(lens.id);\n if (!lensDetails) {\n throw new Error(\n `Cannot apply lens ${lens.id}. It has not been loaded by the Lens ` +\n `repository. Use CameraKit.lensRepository.loadLens (or loadLensGroups) ` +\n `to load lens metadata before calling CameraKitSession.applyLens.`\n );\n }\n\n const { content } = lensDetails;\n if (!content) {\n throw new Error(\n `Cannot apply lens ${lens.id}. Metadata retrieved for this lens does not ` +\n `include the lens content URL.`\n );\n }\n\n return {\n lens,\n launchData: encodeLensLaunchData(\n launchData ?? {},\n persistentStore ?? new ArrayBuffer(0)\n ),\n content,\n };\n }),\n\n // Load lens assets and the lens itself in parallel. Both count toward lens download time.\n // TODO: use RxJS fetch utilities so that these requests can be cancelled on unsubscribe.\n mergeMap(({ lens, launchData, content }) => {\n const networkTimer = applyTimer.mark(\"network\");\n\n return from(\n Promise.all([\n lensRepository.getLensContent(lens).finally(() => networkTimer.measure(\"lens\")),\n content.assetManifest.length > 0\n ? lensAssetRepository\n .cacheAssets(content.assetManifest, lens)\n .finally(() => networkTimer.measure(\"assets\"))\n : Promise.resolve(),\n ])\n ).pipe(\n tap(() => {\n networkTimer.measure();\n lensState.dispatch(\"downloadComplete\", lens);\n }),\n map(([{ lensBuffer, lensChecksum }]): AddLensInput => {\n // NOTE: cached array buffer has to be copied each time in order to be reused,\n // otherwise the original cached copy would be detached by LensCore\n // One optimization can be done here: do not copy the array if getLensContent()\n // returned uncached buffer\n const lensDataBuffer = lensBuffer.slice(0);\n return { lensId: lens.id, lensDataBuffer, lensChecksum, launchData };\n })\n );\n }),\n\n // If removeLens is dispatched while downloading, cancel download, don't apply the lens.\n takeUntil(lensState.events.pipe(forActions(\"removeLens\"))),\n\n // Once the lens has downloaded, we can call replaceLenses. We're not concerned about\n // waiting for prior in-progress calls to replaceLenses to complete, because LensCore\n // guarantees that calls to replaceLenses will always be processed sequentially in the order\n // they are received.\n mergeMap(\n (lensInput) =>\n new Observable<Actions<LensState>>((subscriber) => {\n const coreTimer = applyTimer.mark(\"core\");\n\n // replaceLenses has the property that if it fails, LensCore guarantees that no\n // lenses are active – so we can safely dispatch applyLensFailed and transition\n // to noLensApplied state.\n lensCore\n .replaceLenses({\n lenses: [\n {\n ...lensInput,\n onTurnOn: () => dispatch(\"turnedOn\"),\n onResourcesLoaded: () => dispatch(\"resourcesLoaded\"),\n\n // onFirstFrameProcessed marks the end of the lens application for\n // the end-user -- this is when they see the newly applied lens\n // begin to render. As such, this is where we stop our overall\n // latency measurement and report latency metrics.\n onFirstFrameProcessed: () => {\n coreTimer.measure(\"first-frame\");\n applyTimer.measure(\"success\");\n applyTimer.stopAndReport(operationalMetricsReporter);\n dispatch(\"firstFrameProcessed\");\n },\n onTurnOff: () => dispatch(\"turnedOff\"),\n },\n ],\n })\n .then(() => {\n coreTimer.measure(\"success\");\n\n // We emit applyLensComplete (and applyLensFailed, below) on an\n // Observable, which is piped to `dispatch` – this allows `switchMap` to\n // properly cancel the dispatch of these actions if a new applyLens\n // arrives while we're waiting for onSuccess/onFailure.\n //\n // That's desirable behavior, because we don't want the applyingLens\n // state due to a *subsequent applyLens action* to be transitioned to\n // lensApplied by this action.\n subscriber.next(lensState.actions.applyLensComplete(lens));\n subscriber.complete();\n })\n .catch((lensCoreError) => {\n coreTimer.measure(\"failure\");\n applyTimer.measure(\"failure\");\n applyTimer.stopAndReport(operationalMetricsReporter);\n\n const message = `Failed to apply lens ${lensInput.lensId}.`;\n const error = /validation failed/.test(lensCoreError.message)\n ? lensContentValidationError(message, lensCoreError)\n : lensError(message, lensCoreError);\n\n subscriber.next(lensState.actions.applyLensFailed({ error, lens }));\n subscriber.complete();\n });\n })\n ),\n catchError((error: LensErrors) => {\n applyTimer.measure(\"failure\");\n applyTimer.stopAndReport(operationalMetricsReporter);\n return of(lensState.actions.applyLensFailed({ error, lens }));\n }),\n\n // If a new applyLens is received, `switchMap` will unsubscribe from this inner observable,\n // which stops the current lens application. When this happens we can record a separate metric\n // to measure aborted lens applications.\n unsubscribed(() => {\n applyTimer.measure(\"abort\");\n applyTimer.stopAndReport(operationalMetricsReporter);\n })\n );\n }),\n dispatch(lensState)\n )\n .subscribe({\n error: logger.error,\n });\n\n /**\n * Remove lens\n */\n lensState.events\n .pipe(\n inStates(\"lensApplied\", \"noLensApplied\"),\n forActions(\"removeLens\"),\n mergeMap(\n () =>\n new Observable<Actions<LensState>>((subscriber) => {\n lensCore\n .clearAllLenses()\n .then(() => {\n subscriber.next(lensState.actions.removeLensComplete());\n subscriber.complete();\n })\n .catch((lensCoreError) => {\n const error = new Error(\"Failed to remove lenses.\", { cause: lensCoreError });\n subscriber.next(lensState.actions.removeLensFailed(error));\n subscriber.complete();\n });\n })\n ),\n dispatch(lensState)\n )\n .subscribe({\n error: logger.error,\n });\n\n lensState.events\n .pipe(\n inStates(\"applyingLens\"),\n forActions(\"removeLens\"),\n switchMap(([a]) =>\n lensState.events.pipe(\n // Wait to remove the lens until it has been applied.\n inStates(\"lensApplied\"),\n // But cancel the removal if a new applyLens supercedes the current lens. The goal here is to\n // make sure the latest apply/remove pre-empts any previous request to apply/remove.\n takeUntil(lensState.events.pipe(forActions(\"applyLens\"))),\n map(() => a)\n )\n ),\n dispatch(lensState)\n )\n .subscribe({\n error: logger.error,\n });\n\n // Log transitions\n lensState.events.subscribe(([a, s]) => {\n const data = extractLoggableData(a);\n logger.debug(`Action: \"${a.name}\", state: \"${s.name}\"${data ? \", data: \" + JSON.stringify(data) : \"\"}`);\n });\n\n return lensState;\n }\n);\n\nfunction extractLoggableData(action: Actions<LensState>): Record<string, string> | undefined {\n switch (action.name) {\n case \"applyLens\":\n return { lensId: action.data.lens.id };\n case \"applyLensFailed\":\n return { lensId: action.data.lens.id, error: action.data.error.message };\n case \"downloadComplete\":\n case \"turnedOn\":\n case \"resourcesLoaded\":\n case \"firstFrameProcessed\":\n case \"applyLensComplete\":\n case \"applyLensAborted\":\n case \"turnedOff\":\n return { lensId: action.data.id };\n case \"removeLens\":\n case \"removeLensComplete\":\n return undefined;\n case \"removeLensFailed\":\n return { error: action.data.message };\n default:\n assertUnreachable(action);\n }\n}\n"]}
1
+ {"version":3,"file":"lensState.js","sourceRoot":"","sources":["../../src/session/lensState.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,YAAY,GACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,UAAU,EACV,UAAU,EACV,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,KAAK,EACL,QAAQ,EACR,UAAU,EACV,EAAE,EACF,SAAS,EACT,IAAI,EACJ,SAAS,EACT,GAAG,GACN,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAAkB,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAG/E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAkB,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAuB,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AACrG,OAAO,EACH,UAAU,EAEV,0BAA0B,EAE1B,SAAS,GAEZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAiB,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAuB,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAC9G,OAAO,E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,IAAI,EAAE;QACjB,KAAK,WAAW;YACZ,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QAC3C,KAAK,iBAAiB;YAClB,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QAC7E,KAAK,kBAAkB,CAAC;QACxB,KAAK,UAAU,CAAC;QAChB,KAAK,iBAAiB,CAAC;QACvB,KAAK,qBAAqB,CAAC;QAC3B,KAAK,mBAAmB,CAAC;QACzB,KAAK,kBAAkB,CAAC;QACxB,KAAK,WAAW;YACZ,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,YAAY,CAAC;QAClB,KAAK,oBAAoB;YACrB,OAAO,SAAS,CAAC;QACrB,KAAK,kBAAkB;YACnB,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1C;YACI,iBAAiB,CAAC,MAAM,CAAC,CAAC;KACjC;AACL,CAAC","sourcesContent":["import {\n Actions,\n defineAction,\n defineActions,\n defineState,\n defineStates,\n dispatch,\n forActions,\n inStates,\n StateMachine,\n} from \"@snap/state-management\";\nimport {\n catchError,\n exhaustMap,\n forkJoin,\n from,\n map,\n merge,\n mergeMap,\n Observable,\n of,\n switchMap,\n take,\n takeUntil,\n tap,\n} from \"rxjs\";\nimport { Injectable } from \"../dependency-injection/Injectable\";\nimport { Lens } from \"../lens/Lens\";\nimport { LensRepository, lensRepositoryFactory } from \"../lens/LensRepository\";\nimport { AddLensInput } from \"../lens-core-module/generated-types\";\nimport { IndexedDBPersistence } from \"../persistence/IndexedDBPersistence\";\nimport { lensPersistenceStoreFactory } from \"../lens/LensPersistenceStore\";\nimport { encodeLensLaunchData, LensLaunchData } from \"../lens/LensLaunchData\";\nimport { LegalState, legalStateFactory } from \"../legal/legalState\";\nimport { LensAssetRepository, lensAssetRepositoryFactory } from \"../lens/assets/LensAssetRepository\";\nimport {\n legalError,\n LegalError,\n lensContentValidationError,\n LensContentValidationError,\n lensError,\n LensError,\n} from \"../namedErrors\";\nimport { getLogger } from \"../logger/logger\";\nimport { Timer } from \"../metrics/operational/Timer\";\nimport { unsubscribed } from \"../observable-operators/unsubscribed\";\nimport { assertUnreachable } from \"../common/assertions\";\nimport { MetricsClient, metricsClientFactory } from \"../clients/metricsClient\";\nimport { LensCore } from \"../lens-core-module/lensCore\";\nimport { lensCoreFactory } from \"../lens-core-module/loader/lensCoreFactory\";\nimport { RemoteConfiguration, remoteConfigurationFactory } from \"../remote-configuration/remoteConfiguration\";\nimport { watermarksLensGroup } from \"../lens/fetchWatermarkLens\";\n\nconst logger = getLogger(\"LensState\");\n\nconst createLensState = () => {\n const actions = defineActions(\n defineAction(\"applyLens\")<{ lens: Lens; launchData?: LensLaunchData }>(),\n defineAction(\"downloadComplete\")<Lens>(),\n defineAction(\"turnedOn\")<Lens>(),\n defineAction(\"resourcesLoaded\")<Lens>(),\n defineAction(\"firstFrameProcessed\")<Lens>(),\n defineAction(\"applyLensComplete\")<Lens>(),\n defineAction(\"applyLensFailed\")<{ error: LensErrors; lens: Lens }>(),\n defineAction(\"applyLensAborted\")<Lens>(),\n\n defineAction(\"removeLens\")(),\n defineAction(\"turnedOff\")<Lens>(),\n defineAction(\"removeLensComplete\")(),\n defineAction(\"removeLensFailed\")<Error>()\n );\n\n const states = defineStates(\n defineState(\"noLensApplied\")(),\n defineState(\"applyingLens\")<Lens>(),\n defineState(\"lensApplied\")<Lens>()\n );\n\n return new StateMachine(actions, states, states.noLensApplied(), (events) =>\n merge(\n events.pipe(\n // We allow a new lens to be applied at any time, no matter the state.\n inStates(\"noLensApplied\", \"applyingLens\", \"lensApplied\"),\n forActions(\"applyLens\"),\n map(([a]) => states.applyingLens(a.data.lens))\n ),\n events.pipe(\n inStates(\"applyingLens\"),\n forActions(\"applyLensComplete\"),\n map(([a]) => states.lensApplied(a.data))\n ),\n events.pipe(\n inStates(\"applyingLens\"),\n forActions(\"applyLensFailed\"),\n map(() => states.noLensApplied())\n ),\n events.pipe(\n inStates(\"lensApplied\"),\n forActions(\"removeLensComplete\"),\n map(() => states.noLensApplied())\n )\n )\n );\n};\n\nexport type LensErrors = LegalError | LensContentValidationError | LensError;\n\nexport type LensState = ReturnType<typeof createLensState>;\n\nexport const lensStateFactory = Injectable(\n \"lensState\",\n [\n lensCoreFactory.token,\n lensRepositoryFactory.token,\n lensAssetRepositoryFactory.token,\n lensPersistenceStoreFactory.token,\n legalStateFactory.token,\n metricsClientFactory.token,\n remoteConfigurationFactory.token,\n ] as const,\n (\n lensCore: LensCore,\n lensRepository: LensRepository,\n lensAssetRepository: LensAssetRepository,\n lensPersistence: IndexedDBPersistence<ArrayBuffer>,\n legalState: LegalState,\n metrics: MetricsClient,\n remoteConfig: RemoteConfiguration\n ): LensState => {\n const lensState = createLensState();\n let firstLensApply = true;\n\n /**\n * Apply lens\n */\n lensState.events\n .pipe(\n forActions(\"applyLens\"),\n\n // Determine the legal state (e.g. terms have been accepted). Using exhaustMap means while we are\n // ascertaining legal status (which may include prompting the end user to accept terms), we will ignore\n // any new applyLens actions.\n exhaustMap(([a]) =>\n of(legalState.actions.requestLegalPrompt()).pipe(\n dispatch(legalState),\n inStates(\"accepted\", \"rejected\"),\n take(1),\n map(([, { name }]) => {\n if (name === \"accepted\") return a;\n return lensState.actions.applyLensFailed({\n error: legalError(\n `Failed to apply lens ${a.data.lens.id}. Required legal terms were not accepted.`\n ),\n lens: a.data.lens,\n });\n })\n )\n ),\n\n // The use of switchMap is important so that if we get a new applyLens action while we're still\n // downloading lens content for a previously-requested lens, we can cancel those requests and ensure\n // that lenses are applied in the order they're requested.\n switchMap((a) => {\n if (a.name === \"applyLensFailed\") return of(a);\n\n const { lens } = a.data;\n // Convenience method making dispatching an action with Lens data less verbose.\n const dispatch = (action: Extract<Actions<LensState>, { data: Lens }>[\"name\"]) => {\n lensState.dispatch(action, lens);\n };\n\n // We record if this was the first lens apply for this page load, since there may be additional\n // sources of latency (e.g. remote configuration that needs to be loaded) on the first apply that\n // are not present for subsequent applies.\n const applyTimer = new Timer(\"lens\").mark(\"apply\", { first: `${firstLensApply}` });\n firstLensApply = false;\n\n return forkJoin({\n watermarkInput: remoteConfig.getInitializationConfig().pipe(\n mergeMap((config) => {\n if (!config.watermarkEnabled) return of(undefined);\n\n return from(lensRepository.loadLens(\"\", watermarksLensGroup)).pipe(\n mergeMap((watermark) =>\n // NOTE: we expect that watermark lens is preloaded,\n // to not affect loading time of the actual lens\n from(lensRepository.getLensContent(watermark)).pipe(\n map(({ lensBuffer, lensChecksum }): AddLensInput => {\n return {\n lensId: watermark.id,\n // Copy buffer, so LC can own the copy\n lensDataBuffer: lensBuffer.slice(0),\n lensChecksum,\n launchData: new ArrayBuffer(0),\n };\n })\n )\n )\n );\n })\n ),\n\n lensInput: of(a.data).pipe(\n mergeMap(({ lens, launchData }) => {\n // If retrieval throws an error, we still want to proceed with the lens\n // because persisted data is not a necessity.\n return from(lensPersistence.retrieve(lens.id).catch(() => undefined)).pipe(\n map((persistentStore) => ({ lens, launchData, persistentStore }))\n );\n }),\n\n map(({ lens, launchData, persistentStore }) => {\n const lensDetails = lensRepository.getLensMetadata(lens.id);\n if (!lensDetails) {\n throw new Error(\n `Cannot apply lens ${lens.id}. It has not been loaded by the Lens ` +\n `repository. Use CameraKit.lensRepository.loadLens (or loadLensGroups) ` +\n `to load lens metadata before calling CameraKitSession.applyLens.`\n );\n }\n\n const { content } = lensDetails;\n if (!content) {\n throw new Error(\n `Cannot apply lens ${lens.id}. Metadata retrieved for this lens does not ` +\n `include the lens content URL.`\n );\n }\n\n return {\n lens,\n launchData: encodeLensLaunchData(\n launchData ?? {},\n persistentStore ?? new ArrayBuffer(0)\n ),\n content,\n };\n }),\n\n // Load lens assets and the lens itself in parallel. Both count toward lens download time.\n // TODO: use RxJS fetch utilities so that these requests can be cancelled on unsubscribe.\n mergeMap(({ lens, launchData, content }) => {\n const networkTimer = applyTimer.mark(\"network\");\n\n return from(\n Promise.all([\n lensRepository.getLensContent(lens).finally(() => networkTimer.measure(\"lens\")),\n content.assetManifest.length > 0\n ? lensAssetRepository\n .cacheAssets(content.assetManifest, lens)\n .finally(() => networkTimer.measure(\"assets\"))\n : Promise.resolve(),\n ])\n ).pipe(\n tap(() => {\n networkTimer.measure();\n lensState.dispatch(\"downloadComplete\", lens);\n }),\n map(([{ lensBuffer, lensChecksum }]): AddLensInput => {\n // NOTE: cached array buffer has to be copied each time in order to be reused,\n // otherwise the original cached copy would be detached by LensCore\n // One optimization can be done here: do not copy the array if getLensContent()\n // returned uncached buffer\n const lensDataBuffer = lensBuffer.slice(0);\n return { lensId: lens.id, lensDataBuffer, lensChecksum, launchData };\n })\n );\n })\n ),\n }).pipe(\n // If removeLens is dispatched while downloading, cancel download, don't apply the lens.\n takeUntil(lensState.events.pipe(forActions(\"removeLens\"))),\n\n // Once the lens has downloaded, we can call replaceLenses. We're not concerned about\n // waiting for prior in-progress calls to replaceLenses to complete, because LensCore\n // guarantees that calls to replaceLenses will always be processed sequentially in the order\n // they are received.\n mergeMap(\n ({ lensInput, watermarkInput }) =>\n new Observable<Actions<LensState>>((subscriber) => {\n const coreTimer = applyTimer.mark(\"core\");\n\n // replaceLenses has the property that if it fails, LensCore guarantees that no\n // lenses are active – so we can safely dispatch applyLensFailed and transition\n // to noLensApplied state.\n lensCore\n .replaceLenses({\n lenses: [\n {\n ...lensInput,\n onTurnOn: () => dispatch(\"turnedOn\"),\n onResourcesLoaded: () => dispatch(\"resourcesLoaded\"),\n\n // onFirstFrameProcessed marks the end of the lens application for\n // the end-user -- this is when they see the newly applied lens\n // begin to render. As such, this is where we stop our overall\n // latency measurement and report latency metrics.\n onFirstFrameProcessed: () => {\n coreTimer.measure(\"first-frame\");\n applyTimer.measure(\"success\");\n applyTimer.stopAndReport(metrics);\n dispatch(\"firstFrameProcessed\");\n },\n onTurnOff: () => dispatch(\"turnedOff\"),\n },\n // Watermark is always applied last\n ...(watermarkInput ? [watermarkInput] : []),\n ],\n })\n .then(() => {\n coreTimer.measure(\"success\");\n\n // We emit applyLensComplete (and applyLensFailed, below) on an\n // Observable, which is piped to `dispatch` – this allows `switchMap` to\n // properly cancel the dispatch of these actions if a new applyLens\n // arrives while we're waiting for onSuccess/onFailure.\n //\n // That's desirable behavior, because we don't want the applyingLens\n // state due to a *subsequent applyLens action* to be transitioned to\n // lensApplied by this action.\n subscriber.next(lensState.actions.applyLensComplete(lens));\n subscriber.complete();\n })\n .catch((lensCoreError) => {\n coreTimer.measure(\"failure\");\n applyTimer.measure(\"failure\");\n applyTimer.stopAndReport(metrics);\n\n const message = `Failed to apply lens ${lensInput.lensId}.`;\n const error = /validation failed/.test(lensCoreError.message)\n ? lensContentValidationError(message, lensCoreError)\n : lensError(message, lensCoreError);\n\n subscriber.next(lensState.actions.applyLensFailed({ error, lens }));\n subscriber.complete();\n });\n })\n ),\n catchError((error: LensErrors) => {\n applyTimer.measure(\"failure\");\n applyTimer.stopAndReport(metrics);\n return of(lensState.actions.applyLensFailed({ error, lens }));\n }),\n\n // If a new applyLens is received, `switchMap` will unsubscribe from this inner observable,\n // which stops the current lens application. When this happens we can record a separate metric\n // to measure aborted lens applications.\n unsubscribed(() => {\n applyTimer.measure(\"abort\");\n applyTimer.stopAndReport(metrics);\n })\n );\n }),\n dispatch(lensState)\n )\n .subscribe({\n error: logger.error,\n });\n\n /**\n * Remove lens\n */\n lensState.events\n .pipe(\n inStates(\"lensApplied\", \"noLensApplied\"),\n forActions(\"removeLens\"),\n mergeMap(\n () =>\n new Observable<Actions<LensState>>((subscriber) => {\n lensCore\n .clearAllLenses()\n .then(() => {\n subscriber.next(lensState.actions.removeLensComplete());\n subscriber.complete();\n })\n .catch((lensCoreError) => {\n const error = new Error(\"Failed to remove lenses.\", { cause: lensCoreError });\n subscriber.next(lensState.actions.removeLensFailed(error));\n subscriber.complete();\n });\n })\n ),\n dispatch(lensState)\n )\n .subscribe({\n error: logger.error,\n });\n\n lensState.events\n .pipe(\n inStates(\"applyingLens\"),\n forActions(\"removeLens\"),\n switchMap(([a]) =>\n lensState.events.pipe(\n // Wait to remove the lens until it has been applied.\n inStates(\"lensApplied\"),\n // But cancel the removal if a new applyLens supersedes the current lens. The goal here is to\n // make sure the latest apply/remove preempts any previous request to apply/remove.\n takeUntil(lensState.events.pipe(forActions(\"applyLens\"))),\n map(() => a)\n )\n ),\n dispatch(lensState)\n )\n .subscribe({\n error: logger.error,\n });\n\n // Log transitions\n lensState.events.subscribe(([a, s]) => {\n const data = extractLoggableData(a);\n logger.debug(`Action: \"${a.name}\", state: \"${s.name}\"${data ? \", data: \" + JSON.stringify(data) : \"\"}`);\n });\n\n return lensState;\n }\n);\n\nfunction extractLoggableData(action: Actions<LensState>): Record<string, string> | undefined {\n switch (action.name) {\n case \"applyLens\":\n return { lensId: action.data.lens.id };\n case \"applyLensFailed\":\n return { lensId: action.data.lens.id, error: action.data.error.message };\n case \"downloadComplete\":\n case \"turnedOn\":\n case \"resourcesLoaded\":\n case \"firstFrameProcessed\":\n case \"applyLensComplete\":\n case \"applyLensAborted\":\n case \"turnedOff\":\n return { lensId: action.data.id };\n case \"removeLens\":\n case \"removeLensComplete\":\n return undefined;\n case \"removeLensFailed\":\n return { error: action.data.message };\n default:\n assertUnreachable(action);\n }\n}\n"]}
@@ -1,17 +1,22 @@
1
1
  import { TupleOf } from "../common/types";
2
+ /**
3
+ * Matrix as a 9-value array in column-major order,
4
+ * where elements are stored sequentially by columns.
5
+ */
6
+ export type Matrix = TupleOf<number, 9>;
2
7
  /**
3
8
  * Use this class to supply the CameraKitSession::setSourceTransform with the proper data
4
- * needed to apply transformations
9
+ * needed to apply transformations.
5
10
  *
6
11
  * @category Rendering
7
12
  */
8
13
  export declare class Transform2D {
9
- readonly matrix: TupleOf<number, 9>;
14
+ readonly matrix: Matrix;
10
15
  static readonly MirrorX: Transform2D;
11
16
  static readonly MirrorY: Transform2D;
12
17
  static readonly Identity: Transform2D;
13
18
  /**
14
19
  * @param matrix A 3x3 matrix in column-major order, representing a 2D transform to be applied to the source media
15
20
  */
16
- constructor(matrix: TupleOf<number, 9>);
21
+ constructor(matrix: Matrix);
17
22
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Use this class to supply the CameraKitSession::setSourceTransform with the proper data
3
- * needed to apply transformations
3
+ * needed to apply transformations.
4
4
  *
5
5
  * @category Rendering
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Transform2D.js","sourceRoot":"","sources":["../../src/transforms/Transform2D.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAa,WAAW;IAKpB;;OAEG;IACH,YAAqB,MAA0B;QAA1B,WAAM,GAAN,MAAM,CAAoB;IAAG,CAAC;;AAPnC,mBAAO,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1E,mBAAO,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1E,oBAAQ,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;SAHjF,WAAW","sourcesContent":["import { TupleOf } from \"../common/types\";\n\n/**\n * Use this class to supply the CameraKitSession::setSourceTransform with the proper data\n * needed to apply transformations\n *\n * @category Rendering\n */\nexport class Transform2D {\n static readonly MirrorX = new Transform2D([-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);\n static readonly MirrorY = new Transform2D([1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0]);\n static readonly Identity = new Transform2D([1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]);\n\n /**\n * @param matrix A 3x3 matrix in column-major order, representing a 2D transform to be applied to the source media\n */\n constructor(readonly matrix: TupleOf<number, 9>) {}\n}\n"]}
1
+ {"version":3,"file":"Transform2D.js","sourceRoot":"","sources":["../../src/transforms/Transform2D.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,MAAa,WAAW;IAKpB;;OAEG;IACH,YAAqB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;;AAPvB,mBAAO,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1E,mBAAO,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAC1E,oBAAQ,GAAG,IAAI,WAAW,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;SAHjF,WAAW","sourcesContent":["import { TupleOf } from \"../common/types\";\n\n/**\n * Matrix as a 9-value array in column-major order,\n * where elements are stored sequentially by columns.\n */\nexport type Matrix = TupleOf<number, 9>;\n\n/**\n * Use this class to supply the CameraKitSession::setSourceTransform with the proper data\n * needed to apply transformations.\n *\n * @category Rendering\n */\nexport class Transform2D {\n static readonly MirrorX = new Transform2D([-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);\n static readonly MirrorY = new Transform2D([1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 1.0, 1.0]);\n static readonly Identity = new Transform2D([1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]);\n\n /**\n * @param matrix A 3x3 matrix in column-major order, representing a 2D transform to be applied to the source media\n */\n constructor(readonly matrix: Matrix) {}\n}\n"]}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { getRequiredBootstrapURLs } from "./lens-core-module/loader/bootstrapURLs";
2
+ export { getPlatformInfo, PlatformInfo, ConnectionType } from "./platform/platformInfo";
3
+ export { getCameraKitUserAgent } from "./platform/cameraKitUserAgent";
package/lib/utils.js ADDED
@@ -0,0 +1,4 @@
1
+ export { getRequiredBootstrapURLs } from "./lens-core-module/loader/bootstrapURLs";
2
+ export { getPlatformInfo } from "./platform/platformInfo";
3
+ export { getCameraKitUserAgent } from "./platform/cameraKitUserAgent";
4
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,eAAe,EAAgC,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["export { getRequiredBootstrapURLs } from \"./lens-core-module/loader/bootstrapURLs\";\nexport { getPlatformInfo, PlatformInfo, ConnectionType } from \"./platform/platformInfo\";\nexport { getCameraKitUserAgent } from \"./platform/cameraKitUserAgent\";\n"]}
package/package.json CHANGED
@@ -1,12 +1,32 @@
1
1
  {
2
2
  "name": "@snap/camera-kit",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "description": "Camera Kit Web",
6
6
  "homepage": "https://ar.snap.com/camera-kit",
7
7
  "author": "Snap Inc.",
8
- "main": "lib/index.js",
9
- "types": "lib/index.d.ts",
8
+ "main": "./lib/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ },
14
+ "./utils": {
15
+ "types": "./lib/utils.d.ts",
16
+ "default": "./lib/utils.js"
17
+ }
18
+ },
19
+ "types": "./lib/index.d.ts",
20
+ "typesVersions": {
21
+ "*": {
22
+ ".": [
23
+ "lib/index.d.ts"
24
+ ],
25
+ "utils": [
26
+ "lib/utils.d.ts"
27
+ ]
28
+ }
29
+ },
10
30
  "files": [
11
31
  "docs",
12
32
  "lib"
@@ -39,8 +59,9 @@
39
59
  "ts-jest": "29.1.0",
40
60
  "ts-node": "10.9.1",
41
61
  "ts-proto": "1.110.0",
42
- "typedoc": "0.24.8",
43
- "typedoc-plugin-markdown": "3.15.3",
62
+ "typedoc": "0.25.7",
63
+ "typedoc-plugin-markdown": "3.17.1",
64
+ "typedoc-plugin-mdn-links": "3.1.14",
44
65
  "typescript": "5.0.4",
45
66
  "webpack": "5.72.0",
46
67
  "webpack-bundle-analyzer": "4.5.0",
@@ -49,7 +70,7 @@
49
70
  },
50
71
  "dependencies": {
51
72
  "@improbable-eng/grpc-web": "^0.15.0",
52
- "@snap/state-management": "^0.15.1",
73
+ "@snap/state-management": "^0.17.0",
53
74
  "browser-fs-access": "^0.31.1",
54
75
  "browser-headers": "^0.4.1",
55
76
  "long": "^4.0.0",