@snap/camera-kit 0.11.0 → 0.13.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 (319) hide show
  1. package/README.md +264 -67
  2. package/docs/html/assets/search.js +1 -1
  3. package/docs/html/classes/CameraKit.html +12 -7
  4. package/docs/html/classes/CameraKitSession.html +27 -7
  5. package/docs/html/classes/CameraKitSource.html +26 -17
  6. package/docs/html/classes/LensPerformanceMeasurement.html +12 -7
  7. package/docs/html/classes/LensPerformanceMetrics.html +12 -7
  8. package/docs/html/classes/LensRepository.html +12 -7
  9. package/docs/html/classes/LensSources.html +12 -7
  10. package/docs/html/classes/Transform2D.html +12 -7
  11. package/docs/html/classes/TypedCustomEvent.html +12 -7
  12. package/docs/html/classes/TypedEventTarget.html +12 -7
  13. package/docs/html/functions/Injectable.html +12 -7
  14. package/docs/html/functions/bootstrapCameraKit.html +12 -7
  15. package/docs/html/functions/createExtension.html +12 -7
  16. package/docs/html/functions/createImageSource.html +12 -7
  17. package/docs/html/functions/createMediaStreamSource.html +12 -7
  18. package/docs/html/functions/createUserMediaSource.html +12 -7
  19. package/docs/html/functions/createVideoSource.html +12 -7
  20. package/docs/html/functions/estimateLensPerformance.html +12 -7
  21. package/docs/html/functions/getRequiredBootstrapURLs.html +12 -7
  22. package/docs/html/functions/lensSourcesFactory.html +12 -7
  23. package/docs/html/functions/{uriHandlersFactory.html → remoteApiServicesFactory.html} +16 -14
  24. package/docs/html/index.html +194 -50
  25. package/docs/html/interfaces/CameraKitBootstrapConfiguration.html +12 -7
  26. package/docs/html/interfaces/CameraKitSourceSubscriber.html +12 -7
  27. package/docs/html/interfaces/ComputedFrameMetrics.html +12 -7
  28. package/docs/html/interfaces/CreateSessionOptions.html +12 -7
  29. package/docs/html/interfaces/EstimatedLensPerformance.html +12 -7
  30. package/docs/html/interfaces/Lens.html +12 -7
  31. package/docs/html/interfaces/LensSource.html +16 -11
  32. package/docs/html/interfaces/MediaStreamSourceOptions.html +12 -7
  33. package/docs/html/interfaces/Preview.html +12 -7
  34. package/docs/html/interfaces/RemoteApiRequest.html +164 -0
  35. package/docs/html/interfaces/RemoteApiResponse.html +156 -0
  36. package/docs/html/interfaces/{UriHandler.html → RemoteApiService.html} +34 -68
  37. package/docs/html/interfaces/Snapcode.html +12 -7
  38. package/docs/html/interfaces/UriCancelRequest.html +12 -7
  39. package/docs/html/interfaces/UriRequest.html +20 -10
  40. package/docs/html/interfaces/UriResponse.html +12 -7
  41. package/docs/html/interfaces/VideoSourceOptions.html +12 -7
  42. package/docs/html/modules.html +22 -12
  43. package/docs/html/types/AssetLoader.html +12 -7
  44. package/docs/html/types/AssetTiming.html +12 -7
  45. package/docs/html/types/BenchmarkError.html +12 -7
  46. package/docs/html/types/BootstrapError.html +12 -7
  47. package/docs/html/types/CacheKeyNotFoundError.html +12 -7
  48. package/docs/html/types/CameraKitDeviceInfo.html +19 -9
  49. package/docs/html/types/CameraKitDeviceOptions.html +119 -0
  50. package/docs/html/types/CameraKitSessionEventListener.html +12 -7
  51. package/docs/html/types/CameraKitSessionEvents.html +12 -7
  52. package/docs/html/types/CameraKitSourceError.html +12 -7
  53. package/docs/html/types/CameraKitSourceInfo.html +12 -7
  54. package/docs/html/types/CameraKitSourceOptions.html +13 -8
  55. package/docs/html/types/ConfigurationError.html +12 -7
  56. package/docs/html/types/Keyboard.html +12 -7
  57. package/docs/html/types/KeyboardEvents.html +12 -7
  58. package/docs/html/types/LegalError.html +12 -7
  59. package/docs/html/types/LensAssetError.html +12 -7
  60. package/docs/html/types/LensContentValidationError.html +12 -7
  61. package/docs/html/types/LensError.html +12 -7
  62. package/docs/html/types/LensExecutionError.html +12 -7
  63. package/docs/html/types/LensImagePickerError.html +12 -7
  64. package/docs/html/types/LensLaunchParams.html +12 -7
  65. package/docs/html/types/LensMetricsEvents.html +12 -7
  66. package/docs/html/types/LensPerformanceCluster.html +12 -7
  67. package/docs/html/types/LensView.html +12 -7
  68. package/docs/html/types/LensWait.html +12 -7
  69. package/docs/html/types/PersistentStoreError.html +12 -7
  70. package/docs/html/types/PlatformNotSupportedError.html +12 -7
  71. package/docs/html/types/PublicContainer.html +12 -7
  72. package/docs/html/types/RemoteApiRequestHandler.html +141 -0
  73. package/docs/html/types/{UriHandlers.html → RemoteApiServices.html} +15 -13
  74. package/docs/html/types/RemoteApiStatus.html +114 -0
  75. package/docs/html/types/RenderTarget.html +12 -7
  76. package/docs/html/types/Uri.html +12 -7
  77. package/docs/html/types/WebGLError.html +12 -7
  78. package/docs/html/variables/extensionRequestContext.html +12 -7
  79. package/docs/md/README.md +264 -67
  80. package/docs/md/classes/CameraKit.md +1 -1
  81. package/docs/md/classes/CameraKitSession.md +19 -1
  82. package/docs/md/classes/CameraKitSource.md +19 -7
  83. package/docs/md/classes/LensPerformanceMeasurement.md +1 -1
  84. package/docs/md/classes/LensPerformanceMetrics.md +1 -1
  85. package/docs/md/classes/LensRepository.md +1 -1
  86. package/docs/md/classes/LensSources.md +1 -1
  87. package/docs/md/classes/Transform2D.md +1 -1
  88. package/docs/md/classes/TypedCustomEvent.md +1 -1
  89. package/docs/md/classes/TypedEventTarget.md +1 -1
  90. package/docs/md/interfaces/CameraKitBootstrapConfiguration.md +1 -1
  91. package/docs/md/interfaces/CameraKitSourceSubscriber.md +1 -1
  92. package/docs/md/interfaces/ComputedFrameMetrics.md +1 -1
  93. package/docs/md/interfaces/CreateSessionOptions.md +1 -1
  94. package/docs/md/interfaces/EstimatedLensPerformance.md +1 -1
  95. package/docs/md/interfaces/Lens.md +1 -1
  96. package/docs/md/interfaces/LensSource.md +3 -3
  97. package/docs/md/interfaces/MediaStreamSourceOptions.md +1 -1
  98. package/docs/md/interfaces/Preview.md +1 -1
  99. package/docs/md/interfaces/RemoteApiRequest.md +46 -0
  100. package/docs/md/interfaces/RemoteApiResponse.md +37 -0
  101. package/docs/md/interfaces/RemoteApiService.md +45 -0
  102. package/docs/md/interfaces/Snapcode.md +1 -1
  103. package/docs/md/interfaces/UriCancelRequest.md +1 -1
  104. package/docs/md/interfaces/UriRequest.md +9 -2
  105. package/docs/md/interfaces/UriResponse.md +1 -1
  106. package/docs/md/interfaces/VideoSourceOptions.md +1 -1
  107. package/docs/md/modules.md +66 -15
  108. package/lib/CameraKit.d.ts +16 -6
  109. package/lib/CameraKit.js +3 -1
  110. package/lib/CameraKit.js.map +1 -1
  111. package/lib/__tests__/data.d.ts +1 -1
  112. package/lib/__tests__/data.js +1 -0
  113. package/lib/__tests__/data.js.map +1 -1
  114. package/lib/assertPlatformSupported.d.ts +3 -1
  115. package/lib/assertPlatformSupported.js +13 -2
  116. package/lib/assertPlatformSupported.js.map +1 -1
  117. package/lib/bootstrapCameraKit.js +13 -9
  118. package/lib/bootstrapCameraKit.js.map +1 -1
  119. package/lib/common/any.d.ts +17 -0
  120. package/lib/common/any.js +36 -0
  121. package/lib/common/any.js.map +1 -0
  122. package/lib/common/cameraKitUserAgent.d.ts +5 -0
  123. package/lib/common/cameraKitUserAgent.js +18 -2
  124. package/lib/common/cameraKitUserAgent.js.map +1 -1
  125. package/lib/common/date.d.ts +3 -0
  126. package/lib/common/date.js +13 -0
  127. package/lib/common/date.js.map +1 -0
  128. package/lib/common/dialog.d.ts +43 -0
  129. package/lib/common/dialog.js +26 -12
  130. package/lib/common/dialog.js.map +1 -1
  131. package/lib/common/errorHelpers.js +1 -1
  132. package/lib/common/errorHelpers.js.map +1 -1
  133. package/lib/common/time.d.ts +1 -0
  134. package/lib/common/time.js +1 -0
  135. package/lib/common/time.js.map +1 -1
  136. package/lib/common/types.d.ts +8 -0
  137. package/lib/common/types.js.map +1 -1
  138. package/lib/configuration.d.ts +2 -0
  139. package/lib/configuration.js +1 -0
  140. package/lib/configuration.js.map +1 -1
  141. package/lib/dependency-injection/RootServices.d.ts +4 -0
  142. package/lib/dependency-injection/RootServices.js.map +1 -1
  143. package/lib/environment.json +1 -1
  144. package/lib/extensions/LensSources.d.ts +2 -2
  145. package/lib/extensions/LensSources.js +7 -3
  146. package/lib/extensions/LensSources.js.map +1 -1
  147. package/lib/extensions/RemoteApiServices.d.ts +101 -0
  148. package/lib/extensions/RemoteApiServices.js +198 -0
  149. package/lib/extensions/RemoteApiServices.js.map +1 -0
  150. package/lib/extensions/UriHandlers.d.ts +10 -17
  151. package/lib/extensions/UriHandlers.js +5 -60
  152. package/lib/extensions/UriHandlers.js.map +1 -1
  153. package/lib/extensions/uriHandlersRegister.d.ts +21 -0
  154. package/lib/extensions/uriHandlersRegister.js +72 -0
  155. package/lib/extensions/uriHandlersRegister.js.map +1 -0
  156. package/lib/generated-proto/blizzard/cameraKitEvents.js.map +1 -1
  157. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.d.ts +0 -26
  158. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js +0 -15
  159. package/lib/generated-proto/pb_schema/camera_kit/v3/business_events.js.map +1 -1
  160. package/lib/generated-proto/pb_schema/camera_kit/v3/export.d.ts +0 -59
  161. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js +0 -10
  162. package/lib/generated-proto/pb_schema/camera_kit/v3/export.js.map +1 -1
  163. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +31 -0
  164. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +43 -0
  165. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +1 -0
  166. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.d.ts +0 -13
  167. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js +0 -7
  168. package/lib/generated-proto/pb_schema/camera_kit/v3/legal_prompt.js.map +1 -1
  169. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.d.ts +0 -55
  170. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js +0 -12
  171. package/lib/generated-proto/pb_schema/camera_kit/v3/lens.js.map +1 -1
  172. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.d.ts +0 -5
  173. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js +0 -7
  174. package/lib/generated-proto/pb_schema/camera_kit/v3/operational_metrics.js.map +1 -1
  175. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.d.ts +0 -23
  176. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js +0 -15
  177. package/lib/generated-proto/pb_schema/camera_kit/v3/ranking.js.map +1 -1
  178. package/lib/generated-proto/pb_schema/camera_kit/v3/service.d.ts +0 -62
  179. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js +0 -1
  180. package/lib/generated-proto/pb_schema/camera_kit/v3/service.js.map +1 -1
  181. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.d.ts +0 -8
  182. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js +0 -1
  183. package/lib/generated-proto/pb_schema/cdp/cof/benchmark.js.map +1 -1
  184. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.d.ts +0 -45
  185. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js +0 -46
  186. package/lib/generated-proto/pb_schema/cdp/cof/benchmark_name.js.map +1 -1
  187. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.d.ts +0 -104
  188. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js +0 -1
  189. package/lib/generated-proto/pb_schema/cdp/cof/circumstance_service.js.map +1 -1
  190. package/lib/generated-proto/pb_schema/cdp/cof/config_request.d.ts +0 -129
  191. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js +0 -24
  192. package/lib/generated-proto/pb_schema/cdp/cof/config_request.js.map +1 -1
  193. package/lib/generated-proto/pb_schema/cdp/cof/config_response.d.ts +0 -22
  194. package/lib/generated-proto/pb_schema/cdp/cof/config_response.js +0 -1
  195. package/lib/generated-proto/pb_schema/cdp/cof/config_response.js.map +1 -1
  196. package/lib/generated-proto/pb_schema/cdp/cof/config_result.d.ts +0 -510
  197. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js +0 -415
  198. package/lib/generated-proto/pb_schema/cdp/cof/config_result.js.map +1 -1
  199. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.d.ts +0 -9
  200. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js +0 -3
  201. package/lib/generated-proto/pb_schema/cdp/cof/debug_info.js.map +1 -1
  202. package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +1 -1
  203. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +1 -2
  204. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
  205. package/lib/generated-proto/pb_schema/common/ruid.d.ts +0 -27
  206. package/lib/generated-proto/pb_schema/common/ruid.js +0 -20
  207. package/lib/generated-proto/pb_schema/common/ruid.js.map +1 -1
  208. package/lib/generated-proto/pb_schema/common/value.d.ts +0 -9
  209. package/lib/generated-proto/pb_schema/common/value.js +0 -1
  210. package/lib/generated-proto/pb_schema/common/value.js.map +1 -1
  211. package/lib/generated-proto/pb_schema/google/protobuf/any.d.ts +0 -105
  212. package/lib/generated-proto/pb_schema/google/protobuf/any.js +0 -1
  213. package/lib/generated-proto/pb_schema/google/protobuf/any.js.map +1 -1
  214. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.d.ts +0 -64
  215. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js +0 -1
  216. package/lib/generated-proto/pb_schema/google/protobuf/timestamp.js.map +1 -1
  217. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.d.ts +0 -54
  218. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js +0 -1
  219. package/lib/generated-proto/pb_schema/google/protobuf/wrappers.js.map +1 -1
  220. package/lib/generated-proto/pb_schema/lenses/geocircle.js +0 -1
  221. package/lib/generated-proto/pb_schema/lenses/geocircle.js.map +1 -1
  222. package/lib/generated-proto/pb_schema/lenses/geopoint.js +0 -1
  223. package/lib/generated-proto/pb_schema/lenses/geopoint.js.map +1 -1
  224. package/lib/generated-proto/pb_schema/lenses/launch_params.js +0 -1
  225. package/lib/generated-proto/pb_schema/lenses/launch_params.js.map +1 -1
  226. package/lib/generated-proto/pb_schema/lenses/launchdata.d.ts +0 -2
  227. package/lib/generated-proto/pb_schema/lenses/launchdata.js +0 -3
  228. package/lib/generated-proto/pb_schema/lenses/launchdata.js.map +1 -1
  229. package/lib/generated-proto/pb_schema/lenses/lures.d.ts +0 -2
  230. package/lib/generated-proto/pb_schema/lenses/lures.js +0 -1
  231. package/lib/generated-proto/pb_schema/lenses/lures.js.map +1 -1
  232. package/lib/generated-proto/pb_schema/lenses/persistent_store.js +0 -1
  233. package/lib/generated-proto/pb_schema/lenses/persistent_store.js.map +1 -1
  234. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +569 -0
  235. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +1175 -0
  236. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -0
  237. package/lib/generated-proto/pb_schema/lenses/snappable.d.ts +0 -19
  238. package/lib/generated-proto/pb_schema/lenses/snappable.js +0 -2
  239. package/lib/generated-proto/pb_schema/lenses/snappable.js.map +1 -1
  240. package/lib/generated-proto/pb_schema/lenses/user_data.d.ts +0 -18
  241. package/lib/generated-proto/pb_schema/lenses/user_data.js +0 -1
  242. package/lib/generated-proto/pb_schema/lenses/user_data.js.map +1 -1
  243. package/lib/handlers/defaultFetchHandler.js +17 -4
  244. package/lib/handlers/defaultFetchHandler.js.map +1 -1
  245. package/lib/index.d.ts +1 -0
  246. package/lib/index.js +1 -0
  247. package/lib/index.js.map +1 -1
  248. package/lib/legal/legalPrompt.js +29 -27
  249. package/lib/legal/legalPrompt.js.map +1 -1
  250. package/lib/legal/legalState.js +1 -1
  251. package/lib/legal/legalState.js.map +1 -1
  252. package/lib/lens/LensRepository.d.ts +5 -3
  253. package/lib/lens/LensRepository.js +8 -5
  254. package/lib/lens/LensRepository.js.map +1 -1
  255. package/lib/lens/assets/LensAssetsProvider.js +18 -3
  256. package/lib/lens/assets/LensAssetsProvider.js.map +1 -1
  257. package/lib/lens/lensHttpUtil.d.ts +3 -2
  258. package/lib/lens/lensHttpUtil.js +31 -9
  259. package/lib/lens/lensHttpUtil.js.map +1 -1
  260. package/lib/lens-core-module/generated-types.d.ts +42 -1
  261. package/lib/lens-core-module/generated-types.js.map +1 -1
  262. package/lib/lensCoreWasmVersions.json +3 -3
  263. package/lib/logger/registerLogEntriesSubscriber.js +13 -1
  264. package/lib/logger/registerLogEntriesSubscriber.js.map +1 -1
  265. package/lib/media-sources/CameraKitSource.d.ts +13 -3
  266. package/lib/media-sources/CameraKitSource.js +2 -8
  267. package/lib/media-sources/CameraKitSource.js.map +1 -1
  268. package/lib/media-sources/FunctionSource.d.ts +1 -1
  269. package/lib/media-sources/FunctionSource.js +1 -1
  270. package/lib/media-sources/FunctionSource.js.map +1 -1
  271. package/lib/media-sources/ImageSource.d.ts +1 -1
  272. package/lib/media-sources/ImageSource.js +1 -1
  273. package/lib/media-sources/ImageSource.js.map +1 -1
  274. package/lib/media-sources/MediaStreamSource.d.ts +1 -1
  275. package/lib/media-sources/MediaStreamSource.js +6 -1
  276. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  277. package/lib/media-sources/VideoSource.d.ts +1 -1
  278. package/lib/media-sources/VideoSource.js +1 -1
  279. package/lib/media-sources/VideoSource.js.map +1 -1
  280. package/lib/metrics/businessEventsReporter.d.ts +4 -2
  281. package/lib/metrics/businessEventsReporter.js +134 -68
  282. package/lib/metrics/businessEventsReporter.js.map +1 -1
  283. package/lib/metrics/operational/operationalMetricsReporter.d.ts +3 -2
  284. package/lib/metrics/operational/operationalMetricsReporter.js +31 -11
  285. package/lib/metrics/operational/operationalMetricsReporter.js.map +1 -1
  286. package/lib/metrics/reporters/reportHttpMetrics.d.ts +0 -7
  287. package/lib/metrics/reporters/reportHttpMetrics.js +3 -2
  288. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  289. package/lib/metrics/reporters/reportLensView.d.ts +1 -1
  290. package/lib/metrics/reporters/reportLensView.js +41 -13
  291. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  292. package/lib/metrics/reporters/reportUserSession.js +15 -16
  293. package/lib/metrics/reporters/reportUserSession.js.map +1 -1
  294. package/lib/metrics/reporters/reporters.d.ts +1 -1
  295. package/lib/persistence/ExpiringPersistence.d.ts +2 -1
  296. package/lib/persistence/ExpiringPersistence.js +15 -1
  297. package/lib/persistence/ExpiringPersistence.js.map +1 -1
  298. package/lib/persistence/IndexedDBPersistence.d.ts +1 -1
  299. package/lib/persistence/IndexedDBPersistence.js +11 -1
  300. package/lib/persistence/IndexedDBPersistence.js.map +1 -1
  301. package/lib/persistence/Persistence.d.ts +1 -1
  302. package/lib/persistence/Persistence.js.map +1 -1
  303. package/lib/remote-configuration/cofHandler.d.ts +10 -6
  304. package/lib/remote-configuration/cofHandler.js +77 -67
  305. package/lib/remote-configuration/cofHandler.js.map +1 -1
  306. package/lib/remote-configuration/preloadConfiguration.d.ts +7 -0
  307. package/lib/remote-configuration/preloadConfiguration.js +15 -0
  308. package/lib/remote-configuration/preloadConfiguration.js.map +1 -0
  309. package/lib/remote-configuration/remoteConfiguration.d.ts +14 -7
  310. package/lib/remote-configuration/remoteConfiguration.js +15 -15
  311. package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
  312. package/lib/session/CameraKitSession.d.ts +7 -2
  313. package/lib/session/CameraKitSession.js +1 -0
  314. package/lib/session/CameraKitSession.js.map +1 -1
  315. package/lib/session/sessionState.d.ts +2 -2
  316. package/lib/session/sessionState.js +3 -3
  317. package/lib/session/sessionState.js.map +1 -1
  318. package/package.json +2 -1
  319. package/docs/md/interfaces/UriHandler.md +0 -63
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CameraKit Web SDK - v0.11.0-alpha.1</title><meta name="description" content="Documentation for CameraKit Web SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/search.js" id="tsd-search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
1
+ <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>CameraKit Web SDK - v0.13.0-alpha.1</title><meta name="description" content="Documentation for CameraKit Web SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/search.js" id="tsd-search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
2
2
  <div class="tsd-toolbar-contents container">
3
3
  <div class="table-cell" id="tsd-search" data-base=".">
4
4
  <div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
@@ -6,56 +6,172 @@
6
6
  <div id="tsd-toolbar-links"></div></div>
7
7
  <ul class="results">
8
8
  <li class="state loading">Preparing search index...</li>
9
- <li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">CameraKit Web SDK - v0.11.0-alpha.1</a></div>
9
+ <li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">CameraKit Web SDK - v0.13.0-alpha.1</a></div>
10
10
  <div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
11
11
  <div class="container container-main">
12
12
  <div class="col-content">
13
13
  <div class="tsd-page-title">
14
- <h2>CameraKit Web SDK - v0.11.0-alpha.1</h2></div>
14
+ <h2>CameraKit Web SDK - v0.13.0-alpha.1</h2></div>
15
15
  <div class="tsd-panel tsd-typography"><a id="md:snap-camera-kit-web-sdk" class="tsd-anchor"></a><h1><a href="#md:snap-camera-kit-web-sdk">Snap Camera Kit Web SDK</a></h1><p>The Camera Kit Web SDK allows web developers to build Snap&#39;s core AR Lens technology into their applications.</p>
16
- <a id="md:getting-started" class="tsd-anchor"></a><h2><a href="#md:getting-started">Getting started</a></h2><p>First, familiarize yourself with the <a href="https://docs.snap.com/camera-kit/home">Camera Kit docs</a>. This covers access to the Camera Kit Portal, where to find your API Token, how to manage lenses and lens groups, etc.</p>
17
- <p>Most of the content found here can also be found on the <a href="https://docs.snap.com/camera-kit/quick-start/integrate-sdk/integrate-sdk-web/web-configuration">Camera Kit docs</a> site.</p>
18
- <a id="md:installing-the-sdk" class="tsd-anchor"></a><h3><a href="#md:installing-the-sdk">Installing the SDK</a></h3><pre><code><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-0">install</span><span class="hl-1"> @</span><span class="hl-0">snap</span><span class="hl-1">/</span><span class="hl-0">camera</span><span class="hl-1">-</span><span class="hl-0">kit</span>
19
- </code><button>Copy</button></pre>
20
- <a id="md:using-the-sdk-in-a-javascript-project" class="tsd-anchor"></a><h3><a href="#md:using-the-sdk-in-a-javascript-project">Using the SDK in a Javascript project</a></h3><p>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&#39;s also fully compatible with Javascript projects as well.</p>
21
- <a id="md:importing-the-sdk" class="tsd-anchor"></a><h3><a href="#md:importing-the-sdk">Importing the SDK</a></h3><p>Currently, the SDK distributes <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">Javascript modules</a>. We may support other module formats in the future (e.g. CommonJS), but for now you&#39;ll need to use <code>import</code> syntax to use the Camera Kit Web SDK.</p>
22
- <p>If you&#39;re working in a project that uses a bundler (e.g. Webpack or Rollup), or builds using the TypeScript compiler, this shouldn&#39;t be an issue. If you&#39;re not using a bundler, many browsers now support <code>import</code> syntax natively – if you don&#39;t need support for older browsers (or IE), no bundler is necessary.</p>
23
- <a id="md:bootstrapping-the-sdk" class="tsd-anchor"></a><h3><a href="#md:bootstrapping-the-sdk">Bootstrapping the SDK</a></h3><p>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.</p>
16
+ <a id="md:minimum-browser-requirements" class="tsd-anchor"></a><h2><a href="#md:minimum-browser-requirements">Minimum browser requirements</a></h2><ul>
17
+ <li><strong>Chrome 73+</strong></li>
18
+ <li><strong>Safari 15+</strong><ul>
19
+ <li>MacOS 12+, iOS 15+, iPadOS 15+</li>
20
+ <li>SIMD: Unsupported</li>
21
+ <li>Web Worker Mode*: Unsupported</li>
22
+ </ul>
23
+ </li>
24
+ <li><strong>Edge 79+</strong><ul>
25
+ <li>Edge is still currently under evaluation. However, since New Edge is Chromium based, the expectations are similar to that of Chrome.</li>
26
+ </ul>
27
+ </li>
28
+ <li><strong>Firefox</strong> - Under Evaluation<ul>
29
+ <li>Web Worker Mode*: Firefox 105+</li>
30
+ </ul>
31
+ </li>
32
+ </ul>
33
+ <p>*Web Worker Mode requires <code>OffscreenCanvas</code> support.</p>
34
+ <a id="md:prerequisites" class="tsd-anchor"></a><h2><a href="#md:prerequisites">Prerequisites</a></h2><a id="md:snap-developer-set-up" class="tsd-anchor"></a><h3><a href="#md:snap-developer-set-up">Snap Developer set up</a></h3><p>You&#39;ll need a Snap Developer account, and you&#39;ll need to apply for access to Camera Kit Web SDK. You can find more info on that <a href="camera-kit/quick-start/setting-up-accounts">here</a>.</p>
35
+ <p>You may also want to familiarize yourself with how to access and manage AR content (i.e. Lenses). You read about that <a href="/camera-kit/quick-start/build-manage-ar-content/camera-kit-portal">here</a>.</p>
36
+ <a id="md:development-environment" class="tsd-anchor"></a><h3><a href="#md:development-environment">Development environment</a></h3><p>This guide assumes you&#39;ve already set up an <a href="https://www.npmjs.com/">NPM</a> package, you&#39;re using <a href="https://www.typescriptlang.org/">TypeScript</a>, and have some way to build and host your project during development (e.g. using <a href="https://webpack.js.org/">Webpack</a>).</p>
37
+ <a id="md:using-the-sdk-in-a-javascript-project" class="tsd-anchor"></a><h4><a href="#md:using-the-sdk-in-a-javascript-project">Using the SDK in a JavaScript project</a></h4><p>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&#39;s also fully compatible with JavaScript projects as well.</p>
38
+ <a id="md:content-security-policy" class="tsd-anchor"></a><h3><a href="#md:content-security-policy">Content Security Policy</a></h3><p>If your project already has a <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy">Content Security Policy</a> in place, you&#39;ll likely need to make some changes in order for Camera Kit Web SDK to work.</p>
39
+ <p>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&#39;ll need to make sure your Content Security Policy allows this file to be executed.</p>
40
+ <ul>
41
+ <li><code>connect-src</code> must include <code>https://*.snapar.com</code>, otherwise Camera Kit Web will fail to initialize.</li>
42
+ <li><code>script-src</code> must include <code>https://cf-st.sc-cdn.net/ blob: &#39;wasm-unsafe-eval&#39;</code>.</li>
43
+ </ul>
44
+ <p><em>Note: Some older browser versions may not support the <code>&#39;wasm-unsafe-eval&#39;</code> source value, and it may be necessary to use <code>&#39;unsafe-eval&#39;</code> to allow Camera Kit&#39;s downloaded WebAssembly to run.</em></p>
45
+ <a id="md:installing-the-sdk" class="tsd-anchor"></a><h2><a href="#md:installing-the-sdk">Installing the SDK</a></h2><pre><code><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-0">install</span><span class="hl-1"> @</span><span class="hl-0">snap</span><span class="hl-1">/</span><span class="hl-0">camera</span><span class="hl-1">-</span><span class="hl-0">kit</span>
46
+ </code><button>Copy</button></pre>
47
+ <p>You can find the Camera Kit Web SDK package on npmjs.com <a href="https://www.npmjs.com/package/@snap/camera-kit">here</a>.</p>
48
+ <a id="md:importing-camera-kit" class="tsd-anchor"></a><h3><a href="#md:importing-camera-kit">Importing Camera Kit</a></h3><p>Currently, the SDK distributes <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">JavaScript modules</a>. We may support other module formats in the future (e.g. CommonJS), but for now you&#39;ll need to use <code>import</code> syntax to use the Camera Kit Web SDK.</p>
49
+ <a id="md:bootstrapping-the-sdk" class="tsd-anchor"></a><h2><a href="#md:bootstrapping-the-sdk">Bootstrapping the SDK</a></h2><p>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&#39;ll configure the SDK according to your needs.</p>
24
50
  <p>To call <a href="functions/bootstrapCameraKit.html" class="tsd-kind-function">bootstrapCameraKit</a>, you&#39;ll need to provide a <code>apiToken</code>. Once you&#39;ve completed the <a href="https://docs.snap.com/camera-kit/guides/quick-start/integrate-sdk/setting-up-accounts">Getting set up in our portals</a> section of the Getting Started guide, you&#39;ll be able to find this in the <a href="https://devportal.snap.com/manage">Snap Kit Portal</a>.</p>
25
- <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">boostrapCameraKit</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-4">async</span><span class="hl-1"> </span><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">apiToken</span><span class="hl-1"> = </span><span class="hl-3">&quot;API Token value copied from the Camera Kit Portal&quot;</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({ </span><span class="hl-0">apiToken</span><span class="hl-1"> });</span><br/><span class="hl-1">})();</span>
51
+ <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">boostrapCameraKit</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-4">async</span><span class="hl-1"> </span><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">apiToken</span><span class="hl-1"> = </span><span class="hl-3">&quot;Your API Token value copied from the Camera Kit Portal&quot;</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({ </span><span class="hl-0">apiToken</span><span class="hl-1"> });</span><br/><span class="hl-1">})();</span>
26
52
  </code><button>Copy</button></pre>
27
- <a id="md:creating-a-camerakitsession" class="tsd-anchor"></a><h3><a href="#md:creating-a-camerakitsession">Creating a CameraKitSession</a></h3><p>In order to render Lenses, you must first create a <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a>. 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 <code>&lt;canvas&gt;</code> element.</p>
53
+ <a id="md:creating-a-camerakitsession" class="tsd-anchor"></a><h2><a href="#md:creating-a-camerakitsession">Creating a <code>CameraKitSession</code></a></h2><p>In order to render Lenses, you must first create a <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a>. Each session represents a rendering pipeline - it connects an input media source (e.g. a webcam) to Camera Kit&#39;s AR engine, applies a Lens, and renders the output to a <code>&lt;canvas&gt;</code> element.</p>
28
54
  <p>There are two ways to create a session. If you already have a <code>&lt;canvas&gt;</code> element on your page that you&#39;d like for the <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a> to render into, you can pass it to Camera Kit when creating the session. Otherwise, the session will create a new <code>&lt;canvas&gt;</code> element which you can add to the DOM.</p>
29
55
  <pre><code class="language-ts"><span class="hl-7">// Using an existing canvas</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvas</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">&quot;my-canvas&quot;</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">(</span><span class="hl-0">canvas</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// Let Camera Kit create a new canvas, then append it to the DOM</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvasContainer</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">&quot;canvas-container&quot;</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">();</span><br/><span class="hl-0">canvasContainer</span><span class="hl-1">.</span><span class="hl-5">appendChild</span><span class="hl-1">(</span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">output</span><span class="hl-1">.</span><span class="hl-0">live</span><span class="hl-1">);</span>
30
56
  </code><button>Copy</button></pre>
31
- <p><em>There are actually two different output canvases: <code>live</code> and <code>capture</code>. These correspond to the two different RenderTargets to which a Lens may render. The <code>live</code> output renders a view suitable for presentation to the current user. Some Lenses may also render to the <code>capture</code> output, which renders content suitable for viewing by other users.</em></p>
32
- <a id="md:obtaining-a-media-source" class="tsd-anchor"></a><h3><a href="#md:obtaining-a-media-source">Obtaining a media source</a></h3><p>The most common source will be the user&#39;s webcam. Camera Kit Web SDK provides helper methods to create a <a href="classes/CameraKitSource.html" class="tsd-kind-class">CameraKitSource</a> object from
33
- a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStream"><code>MediaStream</code></a>, or directly from a user&#39;s webcam via <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia"><code>getUserMedia</code></a>.</p>
34
- <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">createMediaStreamSource</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-7">// ...</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">({ </span><span class="hl-0">video:</span><span class="hl-1"> </span><span class="hl-4">true</span><span class="hl-1"> });</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, {</span><br/><span class="hl-1"> </span><span class="hl-0">transform:</span><span class="hl-1"> </span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">&quot;front&quot;</span><span class="hl-1">,</span><br/><span class="hl-1">});</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span>
57
+ <p>There are actually two different output canvases:</p>
58
+ <ul>
59
+ <li><code>live</code>: 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.</li>
60
+ <li><code>capture</code>: This canvas renders content intended for presenting to other users.</li>
61
+ </ul>
62
+ <p>These two output canvases correspond to the two different <a href="https://docs.snap.com/lens-studio/references/guides/lens-features/scene-set-up/camera#render-target">RenderTargets</a> a Lens may use to render its content. Not all Lenses will render different content to <code>live</code> vs. <code>capture</code>, so it&#39;s important to understand how the Lenses you&#39;ll be using use these two different outputs.</p>
63
+ <blockquote>
64
+ <p>No rendering will happen yet, and the output canvas associated with this new <code>CameraKitSession</code> will be blank. Frames are not processed until you start <a href="#playback">playback</a> by calling the <code>CameraKitSession</code>&#39;s <code>play()</code> method. This will be discussed below.</p>
65
+ </blockquote>
66
+ <a id="md:creating-a-camerakitsource" class="tsd-anchor"></a><h2><a href="#md:creating-a-camerakitsource">Creating a <code>CameraKitSource</code></a></h2><p>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.</p>
67
+ <p>The most common source of input media is the user&#39;s webcam. Camera Kit Web SDK provides a helper method to create a <code>CameraKitSource</code> object from a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream"><code>MediaStream</code></a>. You can use <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia"><code>getUserMedia</code></a> to obtain a <code>MediaStream</code> with video from the user&#39;s webcam.</p>
68
+ <blockquote>
69
+ <p>Note that calling <code>getUserMedia</code> will prompt the user to grant the webpage access to their camera.</p>
70
+ </blockquote>
71
+ <p>Once we have a <code>CameraKitSource</code>, we can tell the <code>CameraKitSession</code> to use this source for rendering.</p>
72
+ <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">createMediaStreamSource</span><span class="hl-1">, </span><span class="hl-0">Transform2D</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><br/><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">({ </span><span class="hl-0">video:</span><span class="hl-1"> </span><span class="hl-4">true</span><span class="hl-1"> });</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">transform:</span><span class="hl-1"> </span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">, </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">&#39;user&#39;</span><span class="hl-1"> });</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span>
35
73
  </code><button>Copy</button></pre>
36
- <p><em>Note that calling <code>getUserMedia</code> will prompt the user to grant the webpage access to the webcam.</em></p>
37
- <a id="md:applying-a-lens" class="tsd-anchor"></a><h3><a href="#md:applying-a-lens">Applying a Lens</a></h3><p>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.</p>
38
- <p>In the <a href="https://camera-kit.snapchat.com/">Camera Kit Portal</a>, you can find available lenses and add them to lens groups. Once you&#39;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.</p>
39
- <p><em>The <a href="https://docs.snap.com/camera-kit/guides/quick-start/build-manage-ar-content/camera-kit-portal">Camera Kit docs</a> include info on how to set up Lenses and Lens Groups.</em></p>
40
- <pre><code class="language-ts"><span class="hl-7">// A single lens</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">lens</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLens</span><span class="hl-1">(</span><span class="hl-3">&quot;A lens ID found in the Camera Kit Portal&quot;</span><span class="hl-1">, </span><span class="hl-3">&quot;A lens group ID&quot;</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lens</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// One or more lens groups – lenses from all groups are returned as a single array of lenses.</span><br/><span class="hl-4">const</span><span class="hl-1"> { </span><span class="hl-6">lenses</span><span class="hl-1"> } = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLensGroups</span><span class="hl-1">([</span><br/><span class="hl-1"> </span><span class="hl-3">&quot;A lens group ID&quot;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">&quot;These can be found in the Camera Kit Portal&quot;</span><span class="hl-1">,</span><br/><span class="hl-1">]);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lenses</span><span class="hl-1">[</span><span class="hl-8">0</span><span class="hl-1">]);</span>
74
+ <p>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 <a href="#customizing-camerakitsource">below</a>.</p>
75
+ <p>Camera Kit Web SDK has helper methods to create a <code>CameraKitSource</code> from:</p>
76
+ <ul>
77
+ <li>A <code>MediaStream</code> object, which could come from the user&#39;s camera, a WebRTC connection, a <code>&lt;canvas&gt;</code> via the <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream"><code>captureStream()</code> method</a>, or elsewhere.</li>
78
+ <li>A <code>&lt;video&gt;</code> element (i.e. <code>HTMLVideoElement</code>)</li>
79
+ <li>An <code>&lt;img&gt;</code>element (i.e. <code>HTMLImageElement</code>)</li>
80
+ </ul>
81
+ <a id="md:loading-applying-and-removing-lenses" class="tsd-anchor"></a><h2><a href="#md:loading-applying-and-removing-lenses">Loading, applying, and removing Lenses</a></h2><p>In Camera Kit Web SDK -- just like in the Snapchat app itself -- each individual AR experience is called a Lens. Lenses are created using <a href="https://ar.snap.com/en-US/lens-studio">Lens Studio</a>. You can find more information about acquiring Lenses <a href="https://docs.snap.com/camera-kit/quick-start/build-manage-ar-content/ar-overview">here</a>.</p>
82
+ <p>You can find Lens and Lens Groups in the <a href="https://camera-kit.snapchat.com/">Camera Kit Portal</a>. 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 <a href="https://docs.snap.com/camera-kit/quick-start/build-manage-ar-content/camera-kit-portal">here</a>.</p>
83
+ <p>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&#39;ll need a Lens ID and its Lens Group ID to complete this step.</p>
84
+ <pre><code class="language-ts"><span class="hl-7">// Loading a single lens</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">lens</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLens</span><span class="hl-1">(</span><span class="hl-3">&quot;&lt;Lens ID&gt;&quot;</span><span class="hl-1">, </span><span class="hl-3">&quot;&lt;Lens Group ID&gt;&quot;</span><span class="hl-1">);</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lens</span><span class="hl-1">);</span><br/><br/><span class="hl-7">// Loading one or more Lens Groups – Lenses from all groups are returned as a single array of lenses.</span><br/><span class="hl-4">const</span><span class="hl-1"> { </span><span class="hl-6">lenses</span><span class="hl-1"> } = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLensGroups</span><span class="hl-1">([</span><br/><span class="hl-1"> </span><span class="hl-3">&quot;&lt;Lens Group ID 1&gt;&quot;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-3">&quot;&lt;Lens Group ID 2&gt;&quot;</span><span class="hl-1">,</span><br/><span class="hl-1">]);</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lenses</span><span class="hl-1">[</span><span class="hl-8">0</span><span class="hl-1">]);</span>
41
85
  </code><button>Copy</button></pre>
42
- <a id="md:setting-the-render-size" class="tsd-anchor"></a><h3><a href="#md:setting-the-render-size">Setting the render size</a></h3><p>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.</p>
43
- <p>Keep in mind that this controls LensCore&#39;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.</p>
44
- <p>Most of the time you&#39;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.</p>
45
- <pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setRenderSize</span><span class="hl-1">(</span><span class="hl-0">width</span><span class="hl-1">, </span><span class="hl-0">height</span><span class="hl-1">);</span>
86
+ <a id="md:removing-the-lens" class="tsd-anchor"></a><h3><a href="#md:removing-the-lens">Removing the Lens</a></h3><p>You can also remove the currently-applied Lens:</p>
87
+ <pre><code class="language-ts"><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">removeLens</span><span class="hl-1">();</span>
46
88
  </code><button>Copy</button></pre>
47
- <p><em>Note that when calling <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia"><code>getUserMedia</code></a>, best performance can be achieved by requesting the resolution you want to display. This can be done using <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters">constraints</a></em></p>
48
- <a id="md:session-playback" class="tsd-anchor"></a><h3><a href="#md:session-playback">Session playback</a></h3><p>The <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a> 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&#39;s resources (e.g. CPU and GPU compute cycles). You can tell the session to <code>play</code> or <code>pause</code>.</p>
89
+ <p>After removing the Lens, when the session renders it will simply render the input media directly to the output canvas.</p>
90
+ <a id="md:playback" class="tsd-anchor"></a><h2><a href="#md:playback">Playback</a></h2><p>The <a href="classes/CameraKitSession.html" class="tsd-kind-class">CameraKitSession</a> 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&#39;s resources (e.g. CPU and GPU compute cycles). You can tell the session to <code>play</code> or <code>pause</code>.</p>
49
91
  <pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">();</span><br/><br/><span class="hl-7">// ...sometime later</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">pause</span><span class="hl-1">();</span>
50
92
  </code><button>Copy</button></pre>
51
- <p><em>You can also tell the session which output <code>live</code> or <code>capture</code> - to play / pause. By default, <code>play</code> will start rendering the <code>live</code> output and <code>pause</code> will pause rendering all outputs.</em></p>
52
- <a id="md:putting-it-all-together" class="tsd-anchor"></a><h3><a href="#md:putting-it-all-together">Putting it all together</a></h3><p>Using the examples above, here&#39;s a complete example of the minimal Camera Kit Web SDK integration:</p>
53
- <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">boostrapCameraKit</span><span class="hl-1">, </span><span class="hl-0">createMediaStreamSource</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-4">async</span><span class="hl-1"> </span><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">apiToken</span><span class="hl-1"> = </span><span class="hl-3">&quot;API Token value copied from the SnapKit developer portal&quot;</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({ </span><span class="hl-0">apiToken</span><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvas</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">&quot;my-canvas&quot;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">(</span><span class="hl-0">canvas</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">({ </span><span class="hl-0">video:</span><span class="hl-1"> </span><span class="hl-4">true</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, {</span><br/><span class="hl-1"> </span><span class="hl-0">transform:</span><span class="hl-1"> </span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">&quot;front&quot;</span><span class="hl-1">,</span><br/><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">lens</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLens</span><span class="hl-1">(</span><span class="hl-3">&quot;A lens ID found in the Camera Kit Portal&quot;</span><span class="hl-1">, </span><span class="hl-3">&quot;A lens group ID&quot;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lens</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-3">&quot;Lens rendering has started!&quot;</span><span class="hl-1">);</span><br/><span class="hl-1">})();</span>
93
+ <a id="md:playing-and-pausing-the-different-rendertargets" class="tsd-anchor"></a><h3><a href="#md:playing-and-pausing-the-different-rendertargets">Playing and pausing the different RenderTargets</a></h3><p>By default, <code>play()</code> will only begin rendering the <code>live</code> output canvas. You can specify which canvas to render by passing an argument:</p>
94
+ <pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">(</span><span class="hl-3">&#39;live&#39;</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">(</span><span class="hl-3">&#39;capture&#39;</span><span class="hl-1">);</span>
54
95
  </code><button>Copy</button></pre>
55
- <a id="md:content-security-policy" class="tsd-anchor"></a><h3><a href="#md:content-security-policy">Content Security Policy</a></h3><p>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 <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy">Content Security Policy</a> in place on your page, you&#39;ll likely need to make some changes in order for Camera Kit to work.</p>
56
- <a id="md:connect-src" class="tsd-anchor"></a><h4><a href="#md:connect-src"><code>connect-src</code></a></h4><p>Must include <code>https://*.snapchat.com</code>, otherwise Camera Kit Web will fail to initialize.</p>
57
- <a id="md:script-src" class="tsd-anchor"></a><h4><a href="#md:script-src"><code>script-src</code></a></h4><p>Must include <code>https://cf-st.sc-cdn.net/ blob: &#39;wasm-unsafe-eval&#39;</code>.</p>
58
- <p><em>Note: Some older browser versions may not support the <code>&#39;wasm-unsafe-eval&#39;</code> source value, and it may be necessary to use <code>&#39;unsafe-eval&#39;</code> to allow Camera Kit&#39;s downloaded WebAssembly to run.</em></p>
96
+ <p>Calling <code>pause()</code> with no arguments will pause both outputs. But just like with <code>play()</code>, you can pass an argument to select which canvas to pause.</p>
97
+ <pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">pause</span><span class="hl-1">(</span><span class="hl-3">&#39;live&#39;</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">pause</span><span class="hl-1">(</span><span class="hl-3">&#39;capture&#39;</span><span class="hl-1">);</span>
98
+ </code><button>Copy</button></pre>
99
+ <blockquote>
100
+ <ul>
101
+ <li><em><code>live</code>: 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.</em></li>
102
+ <li><em><code>capture</code>: This canvas renders content intended for presenting to other users.</em></li>
103
+ </ul>
104
+ </blockquote>
105
+ <a id="md:error-handling" class="tsd-anchor"></a><h2><a href="#md:error-handling">Error Handling</a></h2><p>Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the <a href="https://kit.snapchat.com/reference/CameraKit/web/0.12.0/index.html">API docs</a>. It is good practice to handle such cases, to provide a good experience to your users.</p>
106
+ <p>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.</p>
107
+ <p>When a <code>LensExecutionError</code> such as these occurs, the Lens is <strong>automatically removed</strong> from the <code>CameraKitSession</code>. An error event is emitted so that your application can respond appropriately. You can listen to these error events like so:</p>
108
+ <pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">events</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">&#39;error&#39;</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">error</span><span class="hl-1">(</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-2">if</span><span class="hl-1"> (</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">.</span><span class="hl-0">name</span><span class="hl-1"> === </span><span class="hl-3">&#39;LensExecutionError&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-7">// The currently-applied Lens encountered a problem that is most likely unrecoverable and the Lens has been removed.</span><br/><span class="hl-1"> </span><span class="hl-7">// Your application may want to prevent this Lens from being applied again.</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span>
109
+ </code><button>Copy</button></pre>
110
+ <a id="md:putting-it-all-together" class="tsd-anchor"></a><h2><a href="#md:putting-it-all-together">Putting it all together</a></h2><p>Using the examples above, here&#39;s a complete example of the minimal Camera Kit Web SDK integration:</p>
111
+ <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">boostrapCameraKit</span><span class="hl-1">, </span><span class="hl-0">createMediaStreamSource</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-4">async</span><span class="hl-1"> </span><span class="hl-4">function</span><span class="hl-1"> </span><span class="hl-5">main</span><span class="hl-1">() {</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">apiToken</span><span class="hl-1"> = </span><span class="hl-3">&quot;Your API Token value copied from the SnapKit developer portal&quot;</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({ </span><span class="hl-0">apiToken</span><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">canvas</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">&quot;my-canvas&quot;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">session</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-5">createSession</span><span class="hl-1">({ </span><span class="hl-0">liveRenderTarget:</span><span class="hl-1"> </span><span class="hl-0">canvas</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">events</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">&#39;error&#39;</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-2">if</span><span class="hl-1"> (</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">.</span><span class="hl-0">name</span><span class="hl-1"> === </span><span class="hl-3">&#39;LensExecutionError&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-3">&#39;The current Lens encountered an error and was removed.&#39;</span><span class="hl-1">, </span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">);</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> });</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">({ </span><span class="hl-0">video:</span><span class="hl-1"> </span><span class="hl-4">true</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">transform:</span><span class="hl-1"> </span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">, </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">&#39;user&#39;</span><span class="hl-1"> });</span><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">lens</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">lensRepository</span><span class="hl-1">.</span><span class="hl-5">loadLens</span><span class="hl-1">(</span><span class="hl-3">&quot;&lt;Lens ID&gt;&quot;</span><span class="hl-1">, </span><span class="hl-3">&quot;&lt;Lens Group ID&gt;&quot;</span><span class="hl-1">);</span><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">applyLens</span><span class="hl-1">(</span><span class="hl-0">lens</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">play</span><span class="hl-1">();</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-3">&quot;Lens rendering has started!&quot;</span><span class="hl-1">);</span><br/><span class="hl-1">})();</span><br/><br/><span class="hl-5">main</span><span class="hl-1">();</span>
112
+ </code><button>Copy</button></pre>
113
+ <a id="md:advanced-use-cases" class="tsd-anchor"></a><h2><a href="#md:advanced-use-cases">Advanced use cases</a></h2><a id="md:logging" class="tsd-anchor"></a><h3><a href="#md:logging">Logging</a></h3><p>By default, Camera Kit Web SDK does very minimal logging. Specifying <code>&#39;console&#39;</code> as logger will cause more log statements to be printed to the browser&#39;s console, which may be useful during development.</p>
114
+ <pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">cameraKit</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-5">bootstrapCameraKit</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-0">apiToken:</span><span class="hl-1"> </span><span class="hl-3">&#39;&lt;apiToken&gt;&#39;</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-0">logger:</span><span class="hl-1"> </span><span class="hl-3">&#39;console&#39;</span><span class="hl-1">,</span><br/><span class="hl-1">});</span>
115
+ </code><button>Copy</button></pre>
116
+ <a id="md:keyboard-support-for-lenses" class="tsd-anchor"></a><h3><a href="#md:keyboard-support-for-lenses">Keyboard support for Lenses</a></h3><p>Some Lenses allow for keyboard input. The SDK provides a <code>&lt;textarea&gt;</code> (<code>HTMLTextAreaElement</code>) element that can be added to your page, and will send its text to the active Lens whenever the user presses the <code>Enter</code> key.</p>
117
+ <pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">textAreaContainer</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">&#39;text-area-container&#39;</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">textArea</span><span class="hl-1"> = </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">keyboard</span><span class="hl-1">.</span><span class="hl-5">getElement</span><span class="hl-1">();</span><br/><span class="hl-0">textAreaContainer</span><span class="hl-1">.</span><span class="hl-5">appendChild</span><span class="hl-1">(</span><span class="hl-0">textArea</span><span class="hl-1">);</span>
118
+ </code><button>Copy</button></pre>
119
+ <p>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:</p>
120
+ <pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">input</span><span class="hl-1"> = </span><span class="hl-0">document</span><span class="hl-1">.</span><span class="hl-5">getElementById</span><span class="hl-1">(</span><span class="hl-3">&#39;my-text-area&#39;</span><span class="hl-1">);</span><br/><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">keyboard</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">&#39;active&#39;</span><span class="hl-1">, () </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">input</span><span class="hl-1">.</span><span class="hl-0">classList</span><span class="hl-1">.</span><span class="hl-5">remove</span><span class="hl-1">(</span><span class="hl-3">&#39;hidden&#39;</span><span class="hl-1">);</span><br/><span class="hl-1">});</span><br/><br/><span class="hl-0">input</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">&#39;keyup&#39;</span><span class="hl-1">, () </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">keyboard</span><span class="hl-1">.</span><span class="hl-5">sendInputToLens</span><span class="hl-1">(</span><span class="hl-0">input</span><span class="hl-1">.</span><span class="hl-0">value</span><span class="hl-1">);</span><br/><span class="hl-1">})</span>
121
+ </code><button>Copy</button></pre>
122
+ <p>See an example of this <a href="https://camera-kit.snapchat.com/websdk/sample/keyboard">here</a>.</p>
123
+ <a id="md:customizing-camerakitsource" class="tsd-anchor"></a><h3><a href="#md:customizing-camerakitsource">Customizing <code>CameraKitSource</code></a></h3><a id="md:setting-the-render-size" class="tsd-anchor"></a><h4><a href="#md:setting-the-render-size">Setting the render size</a></h4><p>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.</p>
124
+ <p>Keep in mind that this controls Camera Kit&#39;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.</p>
125
+ <p>Most of the time you&#39;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.</p>
126
+ <pre><code class="language-ts"><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">)</span><br/><span class="hl-7">// This must be done *after* calling `setSource()`</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">source</span><span class="hl-1">.</span><span class="hl-5">setRenderSize</span><span class="hl-1">(</span><span class="hl-0">width</span><span class="hl-1">, </span><span class="hl-0">height</span><span class="hl-1">);</span>
127
+ </code><button>Copy</button></pre>
128
+ <blockquote>
129
+ <p>When calling <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia"><code>getUserMedia</code></a>, best performance can be achieved by requesting the resolution at which you want to render. This can be done using <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters">constraints</a>. Then you won&#39;t have to use <code>setRenderSize</code> at all.</p>
130
+ </blockquote>
131
+ <a id="md:camera-type" class="tsd-anchor"></a><h4><a href="#md:camera-type">Camera type</a></h4><p>When setting up a <code>CameraKitSource</code>, 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&#39;s (e.g. World AR) render properly.</p>
132
+ <pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">(</span><span class="hl-0">constraints</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">cameraType:</span><span class="hl-1"> </span><span class="hl-3">&#39;environment&#39;</span><span class="hl-1"> });</span><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">);</span>
133
+ </code><button>Copy</button></pre>
134
+ <a id="md:fps-limit" class="tsd-anchor"></a><h4><a href="#md:fps-limit">FPS limit</a></h4><p>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&#39;s rendering framerate to achieve better performance.</p>
135
+ <p>This can be done at the <code>CameraKitSession</code> level:</p>
136
+ <pre><code class="language-ts"><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setFPSLimit</span><span class="hl-1">(</span><span class="hl-8">60</span><span class="hl-1">);</span>
137
+ </code><button>Copy</button></pre>
138
+ <p>Or at the <code>CameraKitSource</code> level:</p>
139
+ <pre><code class="language-ts"><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">stream</span><span class="hl-1"> = </span><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">navigator</span><span class="hl-1">.</span><span class="hl-0">mediaDevices</span><span class="hl-1">.</span><span class="hl-5">getUserMedia</span><span class="hl-1">(</span><span class="hl-0">constraints</span><span class="hl-1">);</span><br/><span class="hl-4">const</span><span class="hl-1"> </span><span class="hl-6">source</span><span class="hl-1"> = </span><span class="hl-5">createMediaStreamSource</span><span class="hl-1">(</span><span class="hl-0">stream</span><span class="hl-1">, { </span><span class="hl-0">fpsLimit:</span><span class="hl-1"> </span><span class="hl-8">60</span><span class="hl-1"> });</span>
140
+ </code><button>Copy</button></pre>
141
+ <p>These options can also be used with any of the <a href="#creating-a-camerakitsource">create source helpers</a>.</p>
142
+ <a id="md:2d-transforms" class="tsd-anchor"></a><h4><a href="#md:2d-transforms">2D transforms</a></h4><p>Any <code>CameraKitSource</code> 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.</p>
143
+ <pre><code class="language-ts"><span class="hl-2">import</span><span class="hl-1"> { </span><span class="hl-0">Transform2D</span><span class="hl-1"> } </span><span class="hl-2">from</span><span class="hl-1"> </span><span class="hl-3">&quot;@snap/camera-kit&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-2">await</span><span class="hl-1"> </span><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-5">setSource</span><span class="hl-1">(</span><span class="hl-0">source</span><span class="hl-1">)</span><br/><span class="hl-7">// This must be done *after* calling `setSource()`</span><br/><span class="hl-0">source</span><span class="hl-1">.</span><span class="hl-5">setTransform</span><span class="hl-1">(</span><span class="hl-0">Transform2D</span><span class="hl-1">.</span><span class="hl-0">MirrorX</span><span class="hl-1">);</span>
144
+ </code><button>Copy</button></pre>
145
+ <a id="md:metrics-reporting" class="tsd-anchor"></a><h3><a href="#md:metrics-reporting">Metrics reporting</a></h3><p>Camera Kit Web SDK reports certain important events which may be of interest to the application.</p>
146
+ <blockquote>
147
+ <p>This is an unstable portion of the Camera Kit Web SDK&#39;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.</p>
148
+ </blockquote>
149
+ <p>Currently, the only event that may be of interest is the <code>lensView</code> event. It is emitted whenever a lens is <em>removed</em> from the <code>CameraKitSession</code>, indicating a complete lens view. It contains information about the lens&#39; performance (e.g. fps, frame processing times, etc.) and how long the lens was applied.</p>
150
+ <p>You may listen to these events like so:</p>
151
+ <pre><code class="language-ts"><span class="hl-0">cameraKit</span><span class="hl-1">.</span><span class="hl-0">metrics</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">&#39;lensView&#39;</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">debug</span><span class="hl-1">(</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">);</span><br/><span class="hl-1">});</span>
152
+ </code><button>Copy</button></pre>
153
+ <p>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD</p>
154
+ <a id="md:error-handling-1" class="tsd-anchor"></a><h3><a href="#md:error-handling-1">Error Handling</a></h3><p>Camera Kit Web SDK methods may throw errors, or return rejected Promises -- these are documented in the <a href="https://kit.snapchat.com/reference/CameraKit/web/0.11.0/index.html">API docs</a>. It is good practice to handle such cases, to provide a good experience to your users.</p>
155
+ <p>Errors may also occur during Lens rendering. For example, if the Lens that has been applied contains a bug -- Lenses have their own internal scripts, which can fail. A rendering error could also occur if a Lens depends on a feature that is not supported by Camera Kit Web SDK.</p>
156
+ <p>When a <code>LensExecutionError</code> such as these occurs, the Lens is <strong>automatically removed</strong> from the <code>CameraKitSession</code>. An error event is emitted so that your application can respond appropriately. You can listen to these error events like so:</p>
157
+ <pre><code class="language-ts"><span class="hl-0">session</span><span class="hl-1">.</span><span class="hl-0">events</span><span class="hl-1">.</span><span class="hl-5">addEventListener</span><span class="hl-1">(</span><span class="hl-3">&#39;error&#39;</span><span class="hl-1">, (</span><span class="hl-0">event</span><span class="hl-1">) </span><span class="hl-4">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">console</span><span class="hl-1">.</span><span class="hl-5">error</span><span class="hl-1">(</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">);</span><br/><br/><span class="hl-1"> </span><span class="hl-2">if</span><span class="hl-1"> (</span><span class="hl-0">event</span><span class="hl-1">.</span><span class="hl-0">detail</span><span class="hl-1">.</span><span class="hl-0">error</span><span class="hl-1">.</span><span class="hl-0">name</span><span class="hl-1"> === </span><span class="hl-3">&#39;LensExecutionError&#39;</span><span class="hl-1">) {</span><br/><span class="hl-1"> </span><span class="hl-7">// The currently-applied Lens encountered a problem that is most likely unrecoverable and the Lens has been removed.</span><br/><span class="hl-1"> </span><span class="hl-7">// Your application may want to do something to prevent this Lens from being applied again.</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">});</span>
158
+ </code><button>Copy</button></pre>
159
+ <p>=======</p>
160
+ <blockquote>
161
+ <blockquote>
162
+ <blockquote>
163
+ <blockquote>
164
+ <blockquote>
165
+ <blockquote>
166
+ <blockquote>
167
+ <p>76e624ce ([CAMKIT-4384] README: error handling gets greater emphasis)</p>
168
+ </blockquote>
169
+ </blockquote>
170
+ </blockquote>
171
+ </blockquote>
172
+ </blockquote>
173
+ </blockquote>
174
+ </blockquote>
59
175
  </div></div>
60
176
  <div class="col-sidebar">
61
177
  <div class="page-menu">
@@ -79,26 +195,49 @@ a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStr
79
195
  <li><a href="#md:snap-camera-kit-web-sdk"><span>Snap <wbr/>Camera <wbr/>Kit <wbr/>Web SDK</span></a></li>
80
196
  <li>
81
197
  <ul>
82
- <li><a href="#md:getting-started"><span>Getting started</span></a></li>
198
+ <li><a href="#md:minimum-browser-requirements"><span>Minimum browser requirements</span></a></li>
199
+ <li><a href="#md:prerequisites"><span>Prerequisites</span></a></li>
83
200
  <li>
84
201
  <ul>
202
+ <li><a href="#md:snap-developer-set-up"><span>Snap <wbr/>Developer set up</span></a></li>
203
+ <li><a href="#md:development-environment"><span>Development environment</span></a></li>
204
+ <li>
205
+ <ul>
206
+ <li><a href="#md:using-the-sdk-in-a-javascript-project"><span>Using the SDK in a <wbr/>Java<wbr/>Script project</span></a></li></ul></li>
207
+ <li><a href="#md:content-security-policy"><span>Content <wbr/>Security <wbr/>Policy</span></a></li></ul></li>
85
208
  <li><a href="#md:installing-the-sdk"><span>Installing the SDK</span></a></li>
86
- <li><a href="#md:using-the-sdk-in-a-javascript-project"><span>Using the SDK in a <wbr/>Javascript project</span></a></li>
87
- <li><a href="#md:importing-the-sdk"><span>Importing the SDK</span></a></li>
209
+ <li>
210
+ <ul>
211
+ <li><a href="#md:importing-camera-kit"><span>Importing <wbr/>Camera <wbr/>Kit</span></a></li></ul></li>
88
212
  <li><a href="#md:bootstrapping-the-sdk"><span>Bootstrapping the SDK</span></a></li>
89
213
  <li><a href="#md:creating-a-camerakitsession"><span>Creating a <wbr/>Camera<wbr/>Kit<wbr/>Session</span></a></li>
90
- <li><a href="#md:obtaining-a-media-source"><span>Obtaining a media source</span></a></li>
91
- <li><a href="#md:applying-a-lens"><span>Applying a <wbr/>Lens</span></a></li>
92
- <li><a href="#md:setting-the-render-size"><span>Setting the render size</span></a></li>
93
- <li><a href="#md:session-playback"><span>Session playback</span></a></li>
214
+ <li><a href="#md:creating-a-camerakitsource"><span>Creating a <wbr/>Camera<wbr/>Kit<wbr/>Source</span></a></li>
215
+ <li><a href="#md:loading-applying-and-removing-lenses"><span>Loading, applying, and removing <wbr/>Lenses</span></a></li>
216
+ <li>
217
+ <ul>
218
+ <li><a href="#md:removing-the-lens"><span>Removing the <wbr/>Lens</span></a></li></ul></li>
219
+ <li><a href="#md:playback"><span>Playback</span></a></li>
220
+ <li>
221
+ <ul>
222
+ <li><a href="#md:playing-and-pausing-the-different-rendertargets"><span>Playing and pausing the different <wbr/>Render<wbr/>Targets</span></a></li></ul></li>
223
+ <li><a href="#md:error-handling"><span>Error <wbr/>Handling</span></a></li>
94
224
  <li><a href="#md:putting-it-all-together"><span>Putting it all together</span></a></li>
95
- <li><a href="#md:content-security-policy"><span>Content <wbr/>Security <wbr/>Policy</span></a></li>
225
+ <li><a href="#md:advanced-use-cases"><span>Advanced use cases</span></a></li>
226
+ <li>
227
+ <ul>
228
+ <li><a href="#md:logging"><span>Logging</span></a></li>
229
+ <li><a href="#md:keyboard-support-for-lenses"><span>Keyboard support for <wbr/>Lenses</span></a></li>
230
+ <li><a href="#md:customizing-camerakitsource"><span>Customizing <wbr/>Camera<wbr/>Kit<wbr/>Source</span></a></li>
96
231
  <li>
97
232
  <ul>
98
- <li><a href="#md:connect-src"><span>connect-<wbr/>src</span></a></li>
99
- <li><a href="#md:script-src"><span>script-<wbr/>src</span></a></li></ul></li></ul></li></ul></li></ul></li></ul></div></details></div>
233
+ <li><a href="#md:setting-the-render-size"><span>Setting the render size</span></a></li>
234
+ <li><a href="#md:camera-type"><span>Camera type</span></a></li>
235
+ <li><a href="#md:fps-limit"><span>FPS limit</span></a></li>
236
+ <li><a href="#md:2d-transforms"><span>2<wbr/>D transforms</span></a></li></ul></li>
237
+ <li><a href="#md:metrics-reporting"><span>Metrics reporting</span></a></li>
238
+ <li><a href="#md:error-handling-1"><span>Error <wbr/>Handling</span></a></li></ul></li></ul></li></ul></li></ul></div></details></div>
100
239
  <div class="site-menu">
101
- <nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>Camera<wbr/>Kit <wbr/>Web SDK -<wbr/> v0.11.0-<wbr/>alpha.1</span></a>
240
+ <nav class="tsd-navigation"><a href="modules.html" class="current"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-namespace)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M9.33 16V7.24H10.77L13.446 14.74C13.43 14.54 13.41 14.296 13.386 14.008C13.37 13.712 13.354 13.404 13.338 13.084C13.33 12.756 13.326 12.448 13.326 12.16V7.24H14.37V16H12.93L10.266 8.5C10.282 8.692 10.298 8.936 10.314 9.232C10.33 9.52 10.342 9.828 10.35 10.156C10.366 10.476 10.374 10.784 10.374 11.08V16H9.33Z" fill="var(--color-text)"></path></g></svg><span>Camera<wbr/>Kit <wbr/>Web SDK -<wbr/> v0.13.0-<wbr/>alpha.1</span></a>
102
241
  <ul class="tsd-small-nested-navigation">
103
242
  <li><a href="classes/CameraKit.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-128"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-class)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.898 16.1201C11.098 16.1201 10.466 15.8961 10.002 15.4481C9.53803 15.0001 9.30603 14.3841 9.30603 13.6001V9.64012C9.30603 8.85612 9.53803 8.24012 10.002 7.79212C10.466 7.34412 11.098 7.12012 11.898 7.12012C12.682 7.12012 13.306 7.34812 13.77 7.80412C14.234 8.25212 14.466 8.86412 14.466 9.64012H13.386C13.386 9.14412 13.254 8.76412 12.99 8.50012C12.734 8.22812 12.37 8.09212 11.898 8.09212C11.426 8.09212 11.054 8.22412 10.782 8.48812C10.518 8.75212 10.386 9.13212 10.386 9.62812V13.6001C10.386 14.0961 10.518 14.4801 10.782 14.7521C11.054 15.0161 11.426 15.1481 11.898 15.1481C12.37 15.1481 12.734 15.0161 12.99 14.7521C13.254 14.4801 13.386 14.0961 13.386 13.6001H14.466C14.466 14.3761 14.234 14.9921 13.77 15.4481C13.306 15.8961 12.682 16.1201 11.898 16.1201Z" fill="var(--color-text)"></path></g></svg><span>Camera<wbr/>Kit</span></a></li>
104
243
  <li><a href="classes/TypedCustomEvent.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-128"></use></svg><span>Typed<wbr/>Custom<wbr/>Event</span></a></li>
@@ -114,7 +253,9 @@ a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStr
114
253
  <li><a href="interfaces/EstimatedLensPerformance.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Estimated<wbr/>Lens<wbr/>Performance</span></a></li>
115
254
  <li><a href="interfaces/CameraKitBootstrapConfiguration.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Camera<wbr/>Kit<wbr/>Bootstrap<wbr/>Configuration</span></a></li>
116
255
  <li><a href="interfaces/LensSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Lens<wbr/>Source</span></a></li>
117
- <li><a href="interfaces/UriHandler.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Uri<wbr/>Handler</span></a></li>
256
+ <li><a href="interfaces/RemoteApiRequest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Remote<wbr/>Api<wbr/>Request</span></a></li>
257
+ <li><a href="interfaces/RemoteApiResponse.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Remote<wbr/>Api<wbr/>Response</span></a></li>
258
+ <li><a href="interfaces/RemoteApiService.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Remote<wbr/>Api<wbr/>Service</span></a></li>
118
259
  <li><a href="interfaces/UriRequest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Uri<wbr/>Request</span></a></li>
119
260
  <li><a href="interfaces/UriResponse.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Uri<wbr/>Response</span></a></li>
120
261
  <li><a href="interfaces/UriCancelRequest.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Uri<wbr/>Cancel<wbr/>Request</span></a></li>
@@ -128,12 +269,15 @@ a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStr
128
269
  <li><a href="types/LensMetricsEvents.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><g id="icon-4194304"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-type-alias)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)"></path></g></svg><span>Lens<wbr/>Metrics<wbr/>Events</span></a></li>
129
270
  <li><a href="types/LensPerformanceCluster.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Lens<wbr/>Performance<wbr/>Cluster</span></a></li>
130
271
  <li><a href="types/PublicContainer.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Public<wbr/>Container</span></a></li>
131
- <li><a href="types/UriHandlers.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Uri<wbr/>Handlers</span></a></li>
272
+ <li><a href="types/RemoteApiStatus.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Remote<wbr/>Api<wbr/>Status</span></a></li>
273
+ <li><a href="types/RemoteApiRequestHandler.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Remote<wbr/>Api<wbr/>Request<wbr/>Handler</span></a></li>
274
+ <li><a href="types/RemoteApiServices.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Remote<wbr/>Api<wbr/>Services</span></a></li>
132
275
  <li><a href="types/Uri.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Uri</span></a></li>
133
276
  <li><a href="types/LensLaunchParams.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Lens<wbr/>Launch<wbr/>Params</span></a></li>
134
277
  <li><a href="types/AssetTiming.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Asset<wbr/>Timing</span></a></li>
135
278
  <li><a href="types/AssetLoader.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Asset<wbr/>Loader</span></a></li>
136
- <li><a href="types/CameraKitDeviceInfo.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Camera<wbr/>Kit<wbr/>Device<wbr/>Info</span></a></li>
279
+ <li><a href="types/CameraKitDeviceInfo.html" class="deprecated"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Camera<wbr/>Kit<wbr/>Device<wbr/>Info</span></a></li>
280
+ <li><a href="types/CameraKitDeviceOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Camera<wbr/>Kit<wbr/>Device<wbr/>Options</span></a></li>
137
281
  <li><a href="types/CameraKitSourceInfo.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Camera<wbr/>Kit<wbr/>Source<wbr/>Info</span></a></li>
138
282
  <li><a href="types/CameraKitSourceOptions.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Camera<wbr/>Kit<wbr/>Source<wbr/>Options</span></a></li>
139
283
  <li><a href="types/LensView.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-4194304"></use></svg><span>Lens<wbr/>View</span></a></li>
@@ -163,7 +307,7 @@ a <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream/MediaStr
163
307
  <li><a href="functions/createExtension.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>Extension</span></a></li>
164
308
  <li><a href="functions/Injectable.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>Injectable</span></a></li>
165
309
  <li><a href="functions/lensSourcesFactory.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>lens<wbr/>Sources<wbr/>Factory</span></a></li>
166
- <li><a href="functions/uriHandlersFactory.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>uri<wbr/>Handlers<wbr/>Factory</span></a></li>
310
+ <li><a href="functions/remoteApiServicesFactory.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>remote<wbr/>Api<wbr/>Services<wbr/>Factory</span></a></li>
167
311
  <li><a href="functions/getRequiredBootstrapURLs.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>get<wbr/>Required<wbr/>BootstrapURLs</span></a></li>
168
312
  <li><a href="functions/createImageSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>Image<wbr/>Source</span></a></li>
169
313
  <li><a href="functions/createUserMediaSource.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-64"></use></svg><span>create<wbr/>User<wbr/>Media<wbr/>Source</span></a></li>