@snap/camera-kit 0.10.0 → 0.12.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 (333) hide show
  1. package/README.md +242 -67
  2. package/docs/html/assets/search.js +1 -1
  3. package/docs/html/classes/CameraKit.html +116 -100
  4. package/docs/html/classes/CameraKitSession.html +175 -153
  5. package/docs/html/classes/CameraKitSource.html +109 -101
  6. package/docs/html/classes/LensPerformanceMeasurement.html +98 -94
  7. package/docs/html/classes/LensPerformanceMetrics.html +83 -81
  8. package/docs/html/classes/LensRepository.html +120 -109
  9. package/docs/html/classes/LensSources.html +86 -82
  10. package/docs/html/classes/Transform2D.html +98 -94
  11. package/docs/html/classes/TypedCustomEvent.html +83 -82
  12. package/docs/html/classes/TypedEventTarget.html +92 -91
  13. package/docs/html/functions/Injectable.html +87 -80
  14. package/docs/html/functions/bootstrapCameraKit.html +89 -86
  15. package/docs/html/functions/createExtension.html +76 -75
  16. package/docs/html/functions/createImageSource.html +80 -77
  17. package/docs/html/functions/createMediaStreamSource.html +80 -77
  18. package/docs/html/functions/createUserMediaSource.html +84 -81
  19. package/docs/html/functions/createVideoSource.html +80 -77
  20. package/docs/html/functions/estimateLensPerformance.html +76 -75
  21. package/docs/html/functions/getRequiredBootstrapURLs.html +78 -76
  22. package/docs/html/functions/lensSourcesFactory.html +74 -74
  23. package/docs/html/functions/uriHandlersFactory.html +76 -75
  24. package/docs/html/index.html +233 -117
  25. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +107 -100
  26. package/docs/html/interfaces/CameraKitSourceSubscriber.html +82 -81
  27. package/docs/html/interfaces/ComputedFrameMetrics.html +94 -84
  28. package/docs/html/interfaces/CreateSessionOptions.html +86 -83
  29. package/docs/html/interfaces/EstimatedLensPerformance.html +85 -84
  30. package/docs/html/interfaces/Lens.html +114 -106
  31. package/docs/html/interfaces/LensSource.html +102 -94
  32. package/docs/html/interfaces/MediaStreamSourceOptions.html +80 -80
  33. package/docs/html/interfaces/Preview.html +81 -79
  34. package/docs/html/interfaces/Snapcode.html +86 -83
  35. package/docs/html/interfaces/UriCancelRequest.html +80 -80
  36. package/docs/html/interfaces/UriHandler.html +102 -93
  37. package/docs/html/interfaces/UriRequest.html +95 -90
  38. package/docs/html/interfaces/UriResponse.html +89 -89
  39. package/docs/html/interfaces/VideoSourceOptions.html +77 -77
  40. package/docs/html/modules.html +153 -153
  41. package/docs/html/types/AssetLoader.html +75 -74
  42. package/docs/html/types/AssetTiming.html +75 -74
  43. package/docs/html/types/BenchmarkError.html +73 -73
  44. package/docs/html/types/BootstrapError.html +75 -74
  45. package/docs/html/types/CacheKeyNotFoundError.html +73 -73
  46. package/docs/html/types/CameraKitDeviceInfo.html +75 -74
  47. package/docs/html/types/CameraKitSessionEventListener.html +75 -74
  48. package/docs/html/types/CameraKitSessionEvents.html +82 -74
  49. package/docs/html/types/CameraKitSourceError.html +73 -73
  50. package/docs/html/types/CameraKitSourceInfo.html +73 -73
  51. package/docs/html/types/CameraKitSourceOptions.html +75 -74
  52. package/docs/html/types/ConfigurationError.html +75 -74
  53. package/docs/html/types/Keyboard.html +85 -80
  54. package/docs/html/types/KeyboardEvents.html +84 -74
  55. package/docs/html/types/LegalError.html +73 -73
  56. package/docs/html/types/LensAssetError.html +75 -74
  57. package/docs/html/types/LensContentValidationError.html +73 -73
  58. package/docs/html/types/LensError.html +73 -73
  59. package/docs/html/types/LensExecutionError.html +75 -74
  60. package/docs/html/types/LensImagePickerError.html +75 -74
  61. package/docs/html/types/LensLaunchParams.html +75 -74
  62. package/docs/html/types/LensMetricsEvents.html +75 -74
  63. package/docs/html/types/LensPerformanceCluster.html +75 -74
  64. package/docs/html/types/LensView.html +75 -74
  65. package/docs/html/types/LensWait.html +75 -74
  66. package/docs/html/types/PersistentStoreError.html +75 -74
  67. package/docs/html/types/PlatformNotSupportedError.html +75 -74
  68. package/docs/html/types/PublicContainer.html +75 -74
  69. package/docs/html/types/RenderTarget.html +75 -74
  70. package/docs/html/types/Uri.html +73 -73
  71. package/docs/html/types/UriHandlers.html +75 -74
  72. package/docs/html/types/WebGLError.html +73 -73
  73. package/docs/html/variables/extensionRequestContext.html +75 -74
  74. package/docs/md/README.md +242 -67
  75. package/docs/md/classes/CameraKit.md +14 -1
  76. package/docs/md/classes/CameraKitSession.md +1 -1
  77. package/docs/md/classes/CameraKitSource.md +1 -1
  78. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  79. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  80. package/docs/md/classes/LensRepository.md +1 -1
  81. package/docs/md/classes/LensSources.md +1 -1
  82. package/docs/md/classes/Transform2D.md +1 -1
  83. package/docs/md/classes/TypedCustomEvent.md +1 -1
  84. package/docs/md/classes/TypedEventTarget.md +1 -1
  85. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  86. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  87. package/docs/md/interfaces/ComputedFrameMetrics.md +15 -1
  88. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  89. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  90. package/docs/md/interfaces/Lens.md +1 -1
  91. package/docs/md/interfaces/LensSource.md +1 -1
  92. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  93. package/docs/md/interfaces/Preview.md +1 -1
  94. package/docs/md/interfaces/Snapcode.md +1 -1
  95. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  96. package/docs/md/interfaces/UriHandler.md +1 -1
  97. package/docs/md/interfaces/UriRequest.md +8 -1
  98. package/docs/md/interfaces/UriResponse.md +1 -1
  99. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  100. package/docs/md/modules.md +2 -2
  101. package/lib/CameraKit.d.ts +33 -14
  102. package/lib/CameraKit.js +32 -4
  103. package/lib/CameraKit.js.map +1 -1
  104. package/lib/assertPlatformSupported.d.ts +3 -1
  105. package/lib/assertPlatformSupported.js +13 -2
  106. package/lib/assertPlatformSupported.js.map +1 -1
  107. package/lib/bootstrapCameraKit.js +7 -3
  108. package/lib/bootstrapCameraKit.js.map +1 -1
  109. package/lib/common/__mocks__/loadScript.d.ts +1 -1
  110. package/lib/common/__mocks__/loadScript.js +1 -1
  111. package/lib/common/__mocks__/loadScript.js.map +1 -1
  112. package/lib/common/cameraKitUserAgent.js +17 -2
  113. package/lib/common/cameraKitUserAgent.js.map +1 -1
  114. package/lib/common/dialog.d.ts +59 -0
  115. package/lib/common/dialog.js +160 -0
  116. package/lib/common/dialog.js.map +1 -0
  117. package/lib/common/hash.d.ts +5 -0
  118. package/lib/common/hash.js +17 -0
  119. package/lib/common/hash.js.map +1 -0
  120. package/lib/common/loadScript.d.ts +6 -1
  121. package/lib/common/loadScript.js +9 -2
  122. package/lib/common/loadScript.js.map +1 -1
  123. package/lib/common/localization.d.ts +17 -10
  124. package/lib/common/localization.js +653 -18
  125. package/lib/common/localization.js.map +1 -1
  126. package/lib/common/pageVisibility.d.ts +34 -20
  127. package/lib/common/pageVisibility.js +57 -48
  128. package/lib/common/pageVisibility.js.map +1 -1
  129. package/lib/configuration.d.ts +2 -0
  130. package/lib/configuration.js +1 -0
  131. package/lib/configuration.js.map +1 -1
  132. package/lib/dependency-injection/Container.d.ts +2 -2
  133. package/lib/dependency-injection/Container.js +10 -10
  134. package/lib/dependency-injection/Container.js.map +1 -1
  135. package/lib/dependency-injection/RootServices.d.ts +5 -1
  136. package/lib/dependency-injection/RootServices.js.map +1 -1
  137. package/lib/environment.json +1 -1
  138. package/lib/extensions/LensSources.d.ts +5 -5
  139. package/lib/extensions/LensSources.js +9 -9
  140. package/lib/extensions/LensSources.js.map +1 -1
  141. package/lib/extensions/UriHandlers.d.ts +1 -1
  142. package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
  143. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +0 -26
  144. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +0 -15
  145. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
  146. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +0 -59
  147. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +0 -10
  148. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
  149. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +5 -13
  150. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +61 -7
  151. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  152. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +0 -55
  153. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +0 -12
  154. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
  155. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +0 -5
  156. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +0 -7
  157. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
  158. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +0 -23
  159. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +0 -15
  160. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
  161. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +43 -56
  162. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +17 -2
  163. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  164. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +0 -8
  165. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +0 -1
  166. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
  167. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +0 -45
  168. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -46
  169. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -1
  170. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +578 -104
  171. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +0 -1
  172. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
  173. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +0 -129
  174. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +0 -24
  175. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
  176. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +84 -22
  177. package/lib/generated-proto/pb_schema/cdp/cof/config_response.js +0 -1
  178. package/lib/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -1
  179. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +177 -466
  180. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +80 -399
  181. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
  182. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +0 -9
  183. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js +0 -3
  184. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -1
  185. package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +0 -1
  186. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +0 -2
  187. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
  188. package/lib/generated-proto/pb_schema/common/ruid.d.ts +0 -27
  189. package/lib/generated-proto/pb_schema/common/ruid.js +0 -20
  190. package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -1
  191. package/lib/generated-proto/pb_schema/common/value.d.ts +0 -9
  192. package/lib/generated-proto/pb_schema/common/value.js +0 -1
  193. package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
  194. package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +0 -105
  195. package/lib/generated-proto/pb_schema/google/protobuf/any.js +0 -1
  196. package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
  197. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +0 -64
  198. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +0 -1
  199. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
  200. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +0 -54
  201. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +0 -1
  202. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
  203. package/lib/generated-proto/pb_schema/lenses/geocircle.js +0 -1
  204. package/lib/generated-proto/pb_schema/lenses/geocircle.js.map +1 -1
  205. package/lib/generated-proto/pb_schema/lenses/geopoint.js +0 -1
  206. package/lib/generated-proto/pb_schema/lenses/geopoint.js.map +1 -1
  207. package/lib/generated-proto/pb_schema/lenses/launch_params.js +0 -1
  208. package/lib/generated-proto/pb_schema/lenses/launch_params.js.map +1 -1
  209. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +0 -2
  210. package/lib/generated-proto/pb_schema/lenses/launchdata.js +0 -3
  211. package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
  212. package/lib/generated-proto/pb_schema/lenses/lures.d.ts +0 -2
  213. package/lib/generated-proto/pb_schema/lenses/lures.js +0 -1
  214. package/lib/generated-proto/pb_schema/lenses/lures.js.map +1 -1
  215. package/lib/generated-proto/pb_schema/lenses/persistent_store.js +0 -1
  216. package/lib/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -1
  217. package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +0 -19
  218. package/lib/generated-proto/pb_schema/lenses/snappable.js +0 -2
  219. package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
  220. package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +0 -18
  221. package/lib/generated-proto/pb_schema/lenses/user_data.js +0 -1
  222. package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
  223. package/lib/handlers/HandlerChainBuilder.js +7 -2
  224. package/lib/handlers/HandlerChainBuilder.js.map +1 -1
  225. package/lib/handlers/batchingHandler.d.ts +8 -2
  226. package/lib/handlers/batchingHandler.js +5 -8
  227. package/lib/handlers/batchingHandler.js.map +1 -1
  228. package/lib/handlers/mappingHandler.d.ts +5 -1
  229. package/lib/handlers/mappingHandler.js +6 -4
  230. package/lib/handlers/mappingHandler.js.map +1 -1
  231. package/lib/handlers/rateLimitingHandler.d.ts +5 -1
  232. package/lib/handlers/rateLimitingHandler.js +6 -4
  233. package/lib/handlers/rateLimitingHandler.js.map +1 -1
  234. package/lib/handlers/responseCachingHandler.d.ts +1 -1
  235. package/lib/handlers/responseCachingHandler.js.map +1 -1
  236. package/lib/handlers/retryingHandler.d.ts +5 -1
  237. package/lib/handlers/retryingHandler.js +13 -9
  238. package/lib/handlers/retryingHandler.js.map +1 -1
  239. package/lib/legal/legalPrompt.d.ts +7 -4
  240. package/lib/legal/legalPrompt.js +126 -135
  241. package/lib/legal/legalPrompt.js.map +1 -1
  242. package/lib/legal/legalState.d.ts +2 -2
  243. package/lib/legal/legalState.js +52 -38
  244. package/lib/legal/legalState.js.map +1 -1
  245. package/lib/lens/LensRepository.d.ts +5 -3
  246. package/lib/lens/LensRepository.js +8 -5
  247. package/lib/lens/LensRepository.js.map +1 -1
  248. package/lib/lens/assets/LensAssetsProvider.js +18 -3
  249. package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
  250. package/lib/lens/lensHttpUtil.d.ts +3 -2
  251. package/lib/lens/lensHttpUtil.js +5 -5
  252. package/lib/lens/lensHttpUtil.js.map +1 -1
  253. package/lib/lens-core-module/generated-types.d.ts +21 -0
  254. package/lib/lens-core-module/generated-types.js.map +1 -1
  255. package/lib/lens-core-module/loader/lensCoreFactory.js +3 -1
  256. package/lib/lens-core-module/loader/lensCoreFactory.js.map +1 -1
  257. package/lib/lensCoreWasmVersions.json +3 -3
  258. package/lib/logger/logEntries.d.ts +1 -1
  259. package/lib/logger/logEntries.js +3 -3
  260. package/lib/logger/logEntries.js.map +1 -1
  261. package/lib/logger/logger.d.ts +7 -2
  262. package/lib/logger/logger.js +9 -4
  263. package/lib/logger/logger.js.map +1 -1
  264. package/lib/media-sources/MediaStreamSource.js +13 -4
  265. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  266. package/lib/metrics/businessEventsReporter.d.ts +4 -2
  267. package/lib/metrics/businessEventsReporter.js +27 -14
  268. package/lib/metrics/businessEventsReporter.js.map +1 -1
  269. package/lib/metrics/metricsHandler.d.ts +3 -2
  270. package/lib/metrics/metricsHandler.js +3 -3
  271. package/lib/metrics/metricsHandler.js.map +1 -1
  272. package/lib/metrics/operational/Count.d.ts +17 -0
  273. package/lib/metrics/operational/Count.js +28 -0
  274. package/lib/metrics/operational/Count.js.map +1 -0
  275. package/lib/metrics/operational/Histogram.d.ts +17 -0
  276. package/lib/metrics/operational/Histogram.js +23 -0
  277. package/lib/metrics/operational/Histogram.js.map +1 -0
  278. package/lib/metrics/operational/Metric.d.ts +20 -0
  279. package/lib/metrics/operational/Metric.js +26 -0
  280. package/lib/metrics/operational/Metric.js.map +1 -0
  281. package/lib/metrics/operational/Timer.d.ts +91 -0
  282. package/lib/metrics/operational/Timer.js +122 -0
  283. package/lib/metrics/operational/Timer.js.map +1 -0
  284. package/lib/metrics/{operationalMetricsReporter.d.ts → operational/operationalMetricsReporter.d.ts} +16 -4
  285. package/lib/metrics/{operationalMetricsReporter.js → operational/operationalMetricsReporter.js} +31 -13
  286. package/lib/metrics/operational/operationalMetricsReporter.js.map +1 -0
  287. package/lib/metrics/reporters/reportBenchmarks.d.ts +1 -1
  288. package/lib/metrics/reporters/reportBenchmarks.js +1 -1
  289. package/lib/metrics/reporters/reportBenchmarks.js.map +1 -1
  290. package/lib/metrics/reporters/reportGlobalException.d.ts +1 -1
  291. package/lib/metrics/reporters/reportGlobalException.js +1 -1
  292. package/lib/metrics/reporters/reportGlobalException.js.map +1 -1
  293. package/lib/metrics/reporters/reportHttpMetrics.d.ts +1 -1
  294. package/lib/metrics/reporters/reportHttpMetrics.js +1 -1
  295. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  296. package/lib/metrics/reporters/reportLegalState.d.ts +1 -1
  297. package/lib/metrics/reporters/reportLegalState.js +1 -1
  298. package/lib/metrics/reporters/reportLegalState.js.map +1 -1
  299. package/lib/metrics/reporters/reportLensAndAssetDownload.d.ts +1 -1
  300. package/lib/metrics/reporters/reportLensAndAssetDownload.js +1 -1
  301. package/lib/metrics/reporters/reportLensAndAssetDownload.js.map +1 -1
  302. package/lib/metrics/reporters/reportLensValidationFailed.d.ts +1 -1
  303. package/lib/metrics/reporters/reportLensView.d.ts +2 -2
  304. package/lib/metrics/reporters/reportLensView.js +23 -17
  305. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  306. package/lib/metrics/reporters/reportLensWait.d.ts +2 -2
  307. package/lib/metrics/reporters/reportLensWait.js +1 -1
  308. package/lib/metrics/reporters/reportLensWait.js.map +1 -1
  309. package/lib/metrics/reporters/reportSessionException.d.ts +1 -1
  310. package/lib/metrics/reporters/reporters.d.ts +6 -6
  311. package/lib/metrics/reporters/reporters.js +3 -3
  312. package/lib/metrics/reporters/reporters.js.map +1 -1
  313. package/lib/observable-operators/unsubscribed.d.ts +12 -0
  314. package/lib/observable-operators/unsubscribed.js +27 -0
  315. package/lib/observable-operators/unsubscribed.js.map +1 -0
  316. package/lib/remote-configuration/cofHandler.d.ts +11 -7
  317. package/lib/remote-configuration/cofHandler.js +77 -67
  318. package/lib/remote-configuration/cofHandler.js.map +1 -1
  319. package/lib/remote-configuration/remoteConfiguration.d.ts +20 -6
  320. package/lib/remote-configuration/remoteConfiguration.js +24 -7
  321. package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
  322. package/lib/session/CameraKitSession.d.ts +4 -3
  323. package/lib/session/CameraKitSession.js +6 -5
  324. package/lib/session/CameraKitSession.js.map +1 -1
  325. package/lib/session/LensKeyboard.d.ts +1 -1
  326. package/lib/session/LensPerformanceMeasurement.d.ts +2 -0
  327. package/lib/session/LensPerformanceMeasurement.js +27 -4
  328. package/lib/session/LensPerformanceMeasurement.js.map +1 -1
  329. package/lib/session/lensState.d.ts +5 -4
  330. package/lib/session/lensState.js +94 -39
  331. package/lib/session/lensState.js.map +1 -1
  332. package/package.json +12 -12
  333. package/lib/metrics/operationalMetricsReporter.js.map +0 -1
package/docs/md/README.md CHANGED
@@ -4,31 +4,60 @@ CameraKit Web SDK / [Exports](modules.md)
4
4
 
5
5
  The Camera Kit Web SDK allows web developers to build Snap's core AR Lens technology into their applications.
6
6
 
7
- ## Getting started
7
+ ## Minimum browser requirements
8
8
 
9
- First, familiarize yourself with the [Camera Kit docs](https://docs.snap.com/camera-kit/home). This covers access to the Camera Kit Portal, where to find your API Token, how to manage lenses and lens groups, etc.
9
+ - **Chrome 73+**
10
+ - **Safari 15+**
11
+ - MacOS 12+, iOS 15+, iPadOS 15+
12
+ - SIMD: Unsupported
13
+ - Web Worker Mode\*: Unsupported
14
+ - **Edge 79+**
15
+ - Edge is still currently under evaluation. However, since New Edge is Chromium based, the expectations are similar to that of Chrome.
16
+ - **Firefox** - Under Evaluation
17
+ - Web Worker Mode\*: Firefox 105+
10
18
 
11
- Most of the content found here can also be found on the [Camera Kit docs](https://docs.snap.com/camera-kit/quick-start/integrate-sdk/integrate-sdk-web/web-configuration) site.
19
+ \*Web Worker Mode requires `OffscreenCanvas` support.
12
20
 
13
- ### Installing the SDK
21
+ ## Prerequisites
22
+
23
+ ### Snap Developer set up
24
+ You'll need a Snap Developer account, and you'll need to apply for access to Camera Kit Web SDK. You can find more info on that [here](camera-kit/quick-start/setting-up-accounts).
25
+
26
+ You may also want to familiarize yourself with how to access and manage AR content (i.e. Lenses). You read about that [here](/camera-kit/quick-start/build-manage-ar-content/camera-kit-portal).
27
+
28
+ ### Development environment
29
+ This guide assumes you've already set up an [NPM](https://www.npmjs.com/) package, you're using [TypeScript](https://www.typescriptlang.org/), and have some way to build and host your project during development (e.g. using [Webpack](https://webpack.js.org/)).
30
+
31
+ #### Using the SDK in a JavaScript project
32
+
33
+ The SDK is authored in TypeScript, and distributes type definitions. All the examples here are presented in TypeScript. We encourage the use of TypeScript in projects that consume the SDK – but it's also fully compatible with JavaScript projects as well.
34
+
35
+ ### Content Security Policy
36
+
37
+ If your project already has a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) in place, you'll likely need to make some changes in order for Camera Kit Web SDK to work.
38
+
39
+ When it bootstraps, Camera Kit Web SDK downloads an executable WebAssembly file containing the Lens rendering engine. This file is served from an optimized CDN managed by Snap. You'll need to make sure your Content Security Policy allows this file to be executed.
40
+
41
+ - `connect-src` must include `https://*.snapar.com`, otherwise Camera Kit Web will fail to initialize.
42
+ - `script-src` must include `https://cf-st.sc-cdn.net/ blob: 'wasm-unsafe-eval'`.
43
+
44
+ _Note: Some older browser versions may not support the `'wasm-unsafe-eval'` source value, and it may be necessary to use `'unsafe-eval'` to allow Camera Kit's downloaded WebAssembly to run._
45
+
46
+ ## Installing the SDK
14
47
 
15
48
  ```
16
49
  npm install @snap/camera-kit
17
50
  ```
18
51
 
19
- ### Using the SDK in a Javascript project
20
-
21
- The SDK is authored in TypeScript, and distributes type definitions. All the examples here are presented in TypeScript. We encourage the use of TypeScript in projects that consume the SDK – but it's also fully compatible with Javascript projects as well.
52
+ You can find the Camera Kit Web SDK package on npmjs.com [here](https://www.npmjs.com/package/@snap/camera-kit).
22
53
 
23
- ### Importing the SDK
54
+ ### Importing Camera Kit
24
55
 
25
- Currently, the SDK distributes [Javascript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). We may support other module formats in the future (e.g. CommonJS), but for now you'll need to use `import` syntax to use the Camera Kit Web SDK.
56
+ Currently, the SDK distributes [JavaScript modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). We may support other module formats in the future (e.g. CommonJS), but for now you'll need to use `import` syntax to use the Camera Kit Web SDK.
26
57
 
27
- If you're working in a project that uses a bundler (e.g. Webpack or Rollup), or builds using the TypeScript compiler, this shouldn't be an issue. If you're not using a bundler, many browsers now support `import` syntax natively – if you don't need support for older browsers (or IE), no bundler is necessary.
58
+ ## Bootstrapping the SDK
28
59
 
29
- ### Bootstrapping the SDK
30
-
31
- With the SDK installed and capable of being imported, the first thing to do is bootstrap the SDK. This tells the SDK to download the LensCore WebAssembly runtime, which will be used to render Lenses. It also allows you to configure the SDK according to your needs.
60
+ With the SDK installed and imported, the first thing to do is bootstrap the SDK. When bootstrapping, the SDK will download the WebAssembly runtime which is used to render Lenses. This is also where you'll configure the SDK according to your needs.
32
61
 
33
62
  To call [bootstrapCameraKit](modules.md#bootstrapcamerakit), you'll need to provide a `apiToken`. Once you've completed the [Getting set up in our portals](https://docs.snap.com/camera-kit/guides/quick-start/integrate-sdk/setting-up-accounts) section of the Getting Started guide, you'll be able to find this in the [Snap Kit Portal](https://devportal.snap.com/manage).
34
63
 
@@ -36,14 +65,14 @@ To call [bootstrapCameraKit](modules.md#bootstrapcamerakit), you'll need to prov
36
65
  import { boostrapCameraKit } from "@snap/camera-kit";
37
66
 
38
67
  (async function main() {
39
- const apiToken = "API Token value copied from the Camera Kit Portal";
68
+ const apiToken = "Your API Token value copied from the Camera Kit Portal";
40
69
  const cameraKit = await bootstrapCameraKit({ apiToken });
41
70
  })();
42
71
  ```
43
72
 
44
- ### Creating a CameraKitSession
73
+ ## Creating a `CameraKitSession`
45
74
 
46
- In order to render Lenses, you must first create a [CameraKitSession](classes/CameraKitSession.md). Each session represents a rendering pipeline - it connects an input media source (e.g. a webcam) to the LensCore AR engine, applies a Lens, and renders the output to a `<canvas>` element.
75
+ In order to render Lenses, you must first create a [CameraKitSession](classes/CameraKitSession.md). Each session represents a rendering pipeline - it connects an input media source (e.g. a webcam) to Camera Kit's AR engine, applies a Lens, and renders the output to a `<canvas>` element.
47
76
 
48
77
  There are two ways to create a session. If you already have a `<canvas>` element on your page that you'd like for the [CameraKitSession](classes/CameraKitSession.md) to render into, you can pass it to Camera Kit when creating the session. Otherwise, the session will create a new `<canvas>` element which you can add to the DOM.
49
78
 
@@ -58,63 +87,71 @@ const session = await cameraKit.createSession();
58
87
  canvasContainer.appendChild(session.output.live);
59
88
  ```
60
89
 
61
- _There are actually two different output canvases: `live` and `capture`. These correspond to the two different RenderTargets to which a Lens may render. The `live` output renders a view suitable for presentation to the current user. Some Lenses may also render to the `capture` output, which renders content suitable for viewing by other users._
90
+ There are actually two different output canvases:
91
+
92
+ - `live`: This canvas renders content intended for the Lens user. Depending on the Lens being used, this canvas may include UI elements, prompts, or other content that is only meant to be seen by the user of the Lens.
93
+ - `capture`: This canvas renders content intended for presenting to other users.
94
+
95
+ These two output canvases correspond to the two different [RenderTargets](https://docs.snap.com/lens-studio/references/guides/lens-features/scene-set-up/camera#render-target) a Lens may use to render its content. Not all Lenses will render different content to `live` vs. `capture`, so it's important to understand how the Lenses you'll be using use these two different outputs.
96
+
97
+ > No rendering will happen yet, and the output canvas associated with this new `CameraKitSession` will be blank. Frames are not processed until you start [playback](#playback) by calling the `CameraKitSession`'s `play()` method. This will be discussed below.
98
+
99
+ ## Creating a `CameraKitSource`
100
+
101
+ In order for Camera Kit Web SDK to render anything, it must have a source of imagery to be processed by the AR engine. The Lens content will be rendered on top of this source media.
102
+
103
+ The most common source of input media is the user's webcam. Camera Kit Web SDK provides a helper method to create a `CameraKitSource` object from a [`MediaStream`](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream). You can use [`getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia) to obtain a `MediaStream` with video from the user's webcam.
62
104
 
63
- ### Obtaining a media source
105
+ > Note that calling `getUserMedia` will prompt the user to grant the webpage access to their camera.
64
106
 
65
- The most common source will be the user's webcam. Camera Kit Web SDK provides helper methods to create a [CameraKitSource](classes/CameraKitSource.md) object from
66
- a [`MediaStream`](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStream), or directly from a user's webcam via [`getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia).
107
+ Once we have a `CameraKitSource`, we can tell the `CameraKitSession` to use this source for rendering.
67
108
 
68
109
  ```ts
69
- import { createMediaStreamSource } from "@snap/camera-kit";
110
+ import { createMediaStreamSource, Transform2D } from "@snap/camera-kit"
70
111
 
71
- // ...
72
112
  const stream = await navigator.mediaDevices.getUserMedia({ video: true });
73
- const source = createMediaStreamSource(stream, {
74
- transform: Transform2D.MirrorX,
75
- cameraType: "front",
76
- });
77
- session.setSource(source);
113
+ const source = createMediaStreamSource(stream, { transform: Transform2D.MirrorX, cameraType: 'front' });
114
+ await session.setSource(source);
78
115
  ```
79
116
 
80
- _Note that calling `getUserMedia` will prompt the user to grant the webpage access to the webcam._
117
+ In this example, we also mirror the source stream (which feels more natural in most cases), and we indicate this source comes from a front-facing camera. To read more about these options, see [below](#customizing-camerakitsource).
118
+
119
+ Camera Kit Web SDK has helper methods to create a `CameraKitSource` from:
120
+
121
+ - A `MediaStream` object, which could come from the user's camera, a WebRTC connection, a `<canvas>` via the [`captureStream()` method](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream), or elsewhere.
122
+ - A `<video>` element (i.e. `HTMLVideoElement`)
123
+ - An `<img>`element (i.e. `HTMLImageElement`)
81
124
 
82
- ### Applying a Lens
125
+ ## Loading, applying, and removing Lenses
83
126
 
84
- In order to apply a lens to our session, we first have to fetch metadata for the lens we wish to apply. We can configure a group of lenses and get all the lenses in that group – this could be useful if we want to allow the user to select a lens from the group. Or if we know the specific lens we want to apply, we can provide its unique ID (along with the ID of a group that contains that lens) and get back just the single lens.
127
+ In Camera Kit Web SDK -- just like in the Snapchat app itself -- each individual AR experience is called a Lens. Lenses are created using [Lens Studio](https://ar.snap.com/en-US/lens-studio). You can find more information about acquiring Lenses [here](https://docs.snap.com/camera-kit/quick-start/build-manage-ar-content/ar-overview).
85
128
 
86
- In the [Camera Kit Portal](https://camera-kit.snapchat.com/), you can find available lenses and add them to lens groups. Once you've chosen a lens or lens group to load, you can use the Lens repository to fetch the lens metadata. Then you can apply the lens to the session.
129
+ You can find Lens and Lens Groups in the [Camera Kit Portal](https://camera-kit.snapchat.com/). This is where you can manage your Lenses and Lens Groups and where you can find Lens IDs and Lens Group IDs. You can read more about managing Lenses in the Camera Kit Portal [here](https://docs.snap.com/camera-kit/quick-start/build-manage-ar-content/camera-kit-portal).
87
130
 
88
- _The [Camera Kit docs](https://docs.snap.com/camera-kit/guides/quick-start/build-manage-ar-content/camera-kit-portal) include info on how to set up Lenses and Lens Groups._
131
+ Before applying a Lens to our session, we have to load metadata about that Lens. Lenses can be loaded either one at a time, or entire Lens Groups can be loaded at once. You'll need a Lens ID and its Lens Group ID to complete this step.
89
132
 
90
133
  ```ts
91
- // A single lens
92
- const lens = await cameraKit.lensRepository.loadLens("A lens ID found in the Camera Kit Portal", "A lens group ID");
93
- session.applyLens(lens);
134
+ // Loading a single lens
135
+ const lens = await cameraKit.lensRepository.loadLens("<Lens ID>", "<Lens Group ID>");
136
+ await session.applyLens(lens);
94
137
 
95
- // One or more lens groupslenses from all groups are returned as a single array of lenses.
138
+ // Loading one or more Lens GroupsLenses from all groups are returned as a single array of lenses.
96
139
  const { lenses } = await cameraKit.lensRepository.loadLensGroups([
97
- "A lens group ID",
98
- "These can be found in the Camera Kit Portal",
140
+ "<Lens Group ID 1>",
141
+ "<Lens Group ID 2>",
99
142
  ]);
100
- session.applyLens(lenses[0]);
143
+ await session.applyLens(lenses[0]);
101
144
  ```
102
145
 
103
- ### Setting the render size
104
-
105
- By default, Camera Kit will render its output at the same resolution as the video input you provided. But you can also tell Camera Kit to render at a different resolution.
106
-
107
- Keep in mind that this controls LensCore's render resolution, and not (necessarily) the size at which the output canvas is displayed to the user. The output canvas may be sized using HTML and CSS, and may apply its own scaling to the rendered output.
108
-
109
- Most of the time you'll not need to set the render size – but it could be useful if your video source is, say, very high resolution. In that case, you may observe better performance by telling Camera Kit to render at a lower resolution.
146
+ ### Removing the Lens
110
147
 
148
+ You can also remove the currently-applied Lens:
111
149
  ```ts
112
- session.setRenderSize(width, height);
150
+ await session.removeLens();
113
151
  ```
152
+ After removing the Lens, when the session renders it will simply render the input media directly to the output canvas.
114
153
 
115
- _Note that when calling [`getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia), best performance can be achieved by requesting the resolution you want to display. This can be done using [constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters)_
116
-
117
- ### Session playback
154
+ ## Playback
118
155
 
119
156
  The [CameraKitSession](classes/CameraKitSession.md) will only process input video frames and render them to the output when you tell it to do so – this way, you can control when Camera Kit is using a client's resources (e.g. CPU and GPU compute cycles). You can tell the session to `play` or `pause`.
120
157
 
@@ -125,9 +162,45 @@ session.play();
125
162
  session.pause();
126
163
  ```
127
164
 
128
- _You can also tell the session which output – `live` or `capture` - to play / pause. By default, `play` will start rendering the `live` output and `pause` will pause rendering all outputs._
165
+ ### Playing and pausing the different RenderTargets
166
+
167
+ By default, `play()` will only begin rendering the `live` output canvas. You can specify which canvas to render by passing an argument:
168
+
169
+ ```ts
170
+ session.play('live');
171
+ session.play('capture');
172
+ ```
173
+
174
+ Calling `pause()` with no arguments will pause both outputs. But just like with `play()`, you can pass an argument to select which canvas to pause.
175
+
176
+ ```ts
177
+ session.pause('live');
178
+ session.pause('capture');
179
+ ```
180
+
181
+ > - _`live`: This canvas renders content intended for the Lens user. Depending on the Lens being used, this canvas may include UI elements, prompts, or other content that is only meant to be seen by the user of the Lens._
182
+ > - _`capture`: This canvas renders content intended for presenting to other users._
183
+
184
+ ## Error Handling
129
185
 
130
- ### Putting it all together
186
+ Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the [API docs](https://kit.snapchat.com/reference/CameraKit/web/0.12.0/index.html). It is good practice to handle such cases, to provide a good experience to your users.
187
+
188
+ Errors may also occur during Lens rendering. For example, Lenses contain their own scripting, which could throw an error. A rendering error could also occur if a Lens attempts to use a feature that is not supported by Camera Kit Web SDK.
189
+
190
+ When a `LensExecutionError` such as these occurs, the Lens is **automatically removed** from the `CameraKitSession`. An error event is emitted so that your application can respond appropriately. You can listen to these error events like so:
191
+
192
+ ```ts
193
+ session.events.addEventListener('error', (event) => {
194
+ console.error(event.detail.error);
195
+
196
+ if (event.detail.error.name === 'LensExecutionError') {
197
+ // The currently-applied Lens encountered a problem that is most likely unrecoverable and the Lens has been removed.
198
+ // Your application may want to prevent this Lens from being applied again.
199
+ }
200
+ });
201
+ ```
202
+
203
+ ## Putting it all together
131
204
 
132
205
  Using the examples above, here's a complete example of the minimal Camera Kit Web SDK integration:
133
206
 
@@ -135,37 +208,139 @@ Using the examples above, here's a complete example of the minimal Camera Kit We
135
208
  import { boostrapCameraKit, createMediaStreamSource } from "@snap/camera-kit";
136
209
 
137
210
  (async function main() {
138
- const apiToken = "API Token value copied from the SnapKit developer portal";
211
+ const apiToken = "Your API Token value copied from the SnapKit developer portal";
139
212
  const cameraKit = await bootstrapCameraKit({ apiToken });
140
213
 
141
214
  const canvas = document.getElementById("my-canvas");
142
- const session = await cameraKit.createSession(canvas);
215
+ const session = await cameraKit.createSession({ liveRenderTarget: canvas });
216
+ session.events.addEventListener('error', (event) => {
217
+ if (event.detail.error.name === 'LensExecutionError') {
218
+ console.log('The current Lens encountered an error and was removed.', event.detail.error);
219
+ }
220
+ });
143
221
 
144
222
  const stream = await navigator.mediaDevices.getUserMedia({ video: true });
145
- const source = createMediaStreamSource(stream, {
146
- transform: Transform2D.MirrorX,
147
- cameraType: "front",
148
- });
149
- session.setSource(source);
223
+ const source = createMediaStreamSource(stream, { transform: Transform2D.MirrorX, cameraType: 'front' });
224
+ await session.setSource(source);
150
225
 
151
- const lens = await cameraKit.lensRepository.loadLens("A lens ID found in the Camera Kit Portal", "A lens group ID");
226
+ const lens = await cameraKit.lensRepository.loadLens("<Lens ID>", "<Lens Group ID>");
152
227
  await session.applyLens(lens);
153
228
 
154
229
  await session.play();
155
230
  console.log("Lens rendering has started!");
156
231
  })();
232
+
233
+ main();
157
234
  ```
158
235
 
159
- ### Content Security Policy
236
+ ## Advanced use cases
237
+
238
+ ### Logging
160
239
 
161
- Camera Kit Web SDK downloads an executable WebAssembly file containing the Lens rendering engine. This file is served from an optimized CDN. If you have a [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy) in place on your page, you'll likely need to make some changes in order for Camera Kit to work.
240
+ By default, Camera Kit Web SDK does very minimal logging. Specifying `'console'` as logger will cause more log statements to be printed to the browser's console, which may be useful during development.
162
241
 
163
- #### `connect-src`
242
+ ```ts
243
+ const cameraKit = await bootstrapCameraKit({
244
+ apiToken: '<apiToken>',
245
+ logger: 'console',
246
+ });
247
+ ```
164
248
 
165
- Must include `https://*.snapchat.com`, otherwise Camera Kit Web will fail to initialize.
249
+ ### Keyboard support for Lenses
166
250
 
167
- #### `script-src`
251
+ Some Lenses allow for keyboard input. The SDK provides a `<textarea>` (`HTMLTextAreaElement`) element that can be added to your page, and will send its text to the active Lens whenever the user presses the `Enter` key.
168
252
 
169
- Must include `https://cf-st.sc-cdn.net/ blob: 'wasm-unsafe-eval'`.
253
+ ```ts
254
+ const textAreaContainer = document.getElementById('text-area-container');
255
+ const textArea = session.keyboard.getElement();
256
+ textAreaContainer.appendChild(textArea);
257
+ ```
170
258
 
171
- _Note: Some older browser versions may not support the `'wasm-unsafe-eval'` source value, and it may be necessary to use `'unsafe-eval'` to allow Camera Kit's downloaded WebAssembly to run._
259
+ Alternatively, an event is emitted when a Lens is expecting text input. You can then implement your own UI and logic for obtaining text input from your users, and then send it back to the Lens. For example, something like:
260
+
261
+ ```ts
262
+ const input = document.getElementById('my-text-area');
263
+ session.keyboard.addEventListener('active', () => {
264
+ input.classList.remove('hidden');
265
+ });
266
+
267
+ input.addEventListener('keyup', () => {
268
+ session.keyboard.sendInputToLens(input.value);
269
+ })
270
+ ```
271
+
272
+ See an example of this [here](https://camera-kit.snapchat.com/websdk/sample/keyboard).
273
+
274
+ ### Customizing `CameraKitSource`
275
+
276
+ #### Setting the render size
277
+
278
+ By default, Camera Kit will render its output at the same resolution as the video input you provided. But you can also tell Camera Kit to render at a different resolution.
279
+
280
+ Keep in mind that this controls Camera Kit's render resolution, and not (necessarily) the size at which the output canvas is displayed to the user. The output canvas may be sized using HTML and CSS, and may apply its own scaling to the rendered output.
281
+
282
+ Most of the time you'll not need to set the render size – but it could be useful if your video source is, say, very high resolution. In that case, you may observe better performance by telling Camera Kit to render at a lower resolution.
283
+
284
+ ```ts
285
+ await session.setSource(source)
286
+ // This must be done *after* calling `setSource()`
287
+ await source.setRenderSize(width, height);
288
+ ```
289
+
290
+ > When calling [`getUserMedia`](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia), best performance can be achieved by requesting the resolution at which you want to render. This can be done using [constraints](https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters). Then you won't have to use `setRenderSize` at all.
291
+
292
+ #### Camera type
293
+
294
+ When setting up a `CameraKitSource`, you can specify whether or not it is a front facing camera or a back facing camera. By default, the media source will be treated as a front facing camera. If it is a back facing camera be sure to specify it as such when you create your source; this ensures that Lenses created for back facing camera's (e.g. World AR) render properly.
295
+
296
+ ```ts
297
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
298
+ const source = createMediaStreamSource(stream, { cameraType: 'back' });
299
+ await session.setSource(source);
300
+ ```
301
+
302
+ #### FPS limit
303
+
304
+ In some cases, it may be desirable to set a limit on the FPS at which Camera Kit renders. By default, Camera Kit will attempt to render frames at the same rate as the source media. But, for example, if your input media source has a very high framerate you may want to limit Camera Kit's rendering framerate to achieve better performance.
305
+
306
+ This can be done at the `CameraKitSession` level:
307
+
308
+ ```ts
309
+ await session.setFPSLimit(60);
310
+ ```
311
+
312
+ Or at the `CameraKitSource` level:
313
+
314
+ ```ts
315
+ const stream = await navigator.mediaDevices.getUserMedia(constraints);
316
+ const source = createMediaStreamSource(stream, { fpsLimit: 60 });
317
+ ```
318
+
319
+ These options can also be used with any of the [create source helpers](#creating-a-camerakitsource).
320
+
321
+ #### 2D transforms
322
+
323
+ Any `CameraKitSource` can be transformed using a matrix, to rotate, scale, or mirror the source media. This is most often used to mirror a front-facing camera stream so that it appears more natural to the user.
324
+
325
+ ```ts
326
+ import { Transform2D } from "@snap/camera-kit";
327
+
328
+ await session.setSource(source)
329
+ // This must be done *after* calling `setSource()`
330
+ source.setTransform(Transform2D.MirrorX);
331
+ ```
332
+
333
+ ### Metrics reporting
334
+
335
+ Camera Kit Web SDK reports certain important events which may be of interest to the application.
336
+
337
+ > This is an unstable portion of the Camera Kit Web SDK's public API -- the specific events and their properties may change between versions of the SDK, without warning. We currently offer these events as a convenient way to gather more information from the SDK, but if you need to report accurate metrics (e.g. number of lens views), that is currently something you will have to implement in your application.
338
+
339
+ Currently, the only event that may be of interest is the `lensView` event. It is emitted whenever a lens is _removed_ from the `CameraKitSession`, indicating a complete lens view. It contains information about the lens' performance (e.g. fps, frame processing times, etc.) and how long the lens was applied.
340
+
341
+ You may listen to these events like so:
342
+ ```ts
343
+ cameraKit.metrics.addEventListener('lensView', (event) => {
344
+ console.debug(event.detail);
345
+ });
346
+ ```
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKit
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKit
2
2
 
3
3
  # Class: CameraKit
4
4
 
@@ -29,6 +29,7 @@ and obtaining rendered `<canvas>` outputs.
29
29
  ### Methods
30
30
 
31
31
  - [createSession](CameraKit.md#createsession)
32
+ - [destroy](CameraKit.md#destroy)
32
33
 
33
34
  ## Properties
34
35
 
@@ -92,3 +93,15 @@ session.applyLens(lens)
92
93
  #### Returns
93
94
 
94
95
  `Promise`<[`CameraKitSession`](CameraKitSession.md)\>
96
+
97
+ ___
98
+
99
+ ### destroy
100
+
101
+ ▸ **destroy**(): `Promise`<`void`\>
102
+
103
+ Destroys all sessions and frees all resources.
104
+
105
+ #### Returns
106
+
107
+ `Promise`<`void`\>
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitSession
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitSession
2
2
 
3
3
  # Class: CameraKitSession
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitSource
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitSource
2
2
 
3
3
  # Class: CameraKitSource
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / LensPerformanceMeasurement
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / LensPerformanceMeasurement
2
2
 
3
3
  # Class: LensPerformanceMeasurement
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / LensPerformanceMetrics
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / LensPerformanceMetrics
2
2
 
3
3
  # Class: LensPerformanceMetrics
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / LensRepository
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / LensRepository
2
2
 
3
3
  # Class: LensRepository
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSources
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSources
2
2
 
3
3
  # Class: LensSources
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Transform2D
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Transform2D
2
2
 
3
3
  # Class: Transform2D
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / TypedCustomEvent
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / TypedCustomEvent
2
2
 
3
3
  # Class: TypedCustomEvent<N, T\>
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / TypedEventTarget
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / TypedEventTarget
2
2
 
3
3
  # Class: TypedEventTarget<Events\>
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitBootstrapConfiguration
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitBootstrapConfiguration
2
2
 
3
3
  # Interface: CameraKitBootstrapConfiguration
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitSourceSubscriber
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CameraKitSourceSubscriber
2
2
 
3
3
  # Interface: CameraKitSourceSubscriber
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / ComputedFrameMetrics
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / ComputedFrameMetrics
2
2
 
3
3
  # Interface: ComputedFrameMetrics
4
4
 
@@ -9,6 +9,8 @@
9
9
  - [avgFps](ComputedFrameMetrics.md#avgfps)
10
10
  - [lensFrameProcessingTimeMsAvg](ComputedFrameMetrics.md#lensframeprocessingtimemsavg)
11
11
  - [lensFrameProcessingTimeMsStd](ComputedFrameMetrics.md#lensframeprocessingtimemsstd)
12
+ - [lensFrameProcessingTimeMsMedian](ComputedFrameMetrics.md#lensframeprocessingtimemsmedian)
13
+ - [lensFrameProcessingN](ComputedFrameMetrics.md#lensframeprocessingn)
12
14
 
13
15
  ## Properties
14
16
 
@@ -27,3 +29,15 @@ ___
27
29
  ### lensFrameProcessingTimeMsStd
28
30
 
29
31
  • **lensFrameProcessingTimeMsStd**: `number`
32
+
33
+ ___
34
+
35
+ ### lensFrameProcessingTimeMsMedian
36
+
37
+ • **lensFrameProcessingTimeMsMedian**: `number`
38
+
39
+ ___
40
+
41
+ ### lensFrameProcessingN
42
+
43
+ • **lensFrameProcessingN**: `number`
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / CreateSessionOptions
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CreateSessionOptions
2
2
 
3
3
  # Interface: CreateSessionOptions
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / EstimatedLensPerformance
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / EstimatedLensPerformance
2
2
 
3
3
  # Interface: EstimatedLensPerformance
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Lens
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Lens
2
2
 
3
3
  # Interface: Lens
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSource
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSource
2
2
 
3
3
  # Interface: LensSource
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / MediaStreamSourceOptions
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / MediaStreamSourceOptions
2
2
 
3
3
  # Interface: MediaStreamSourceOptions
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Preview
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Preview
2
2
 
3
3
  # Interface: Preview
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / Snapcode
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Snapcode
2
2
 
3
3
  # Interface: Snapcode
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / UriCancelRequest
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / UriCancelRequest
2
2
 
3
3
  # Interface: UriCancelRequest
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.10.0-alpha.1](../README.md) / [Exports](../modules.md) / UriHandler
1
+ [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / UriHandler
2
2
 
3
3
  # Interface: UriHandler
4
4