@snap/camera-kit 0.12.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 (219) hide show
  1. package/README.md +25 -3
  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 +40 -12
  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 +13 -8
  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 +25 -3
  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 +2 -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.js +3 -1
  109. package/lib/CameraKit.js.map +1 -1
  110. package/lib/__tests__/data.d.ts +1 -1
  111. package/lib/__tests__/data.js +1 -0
  112. package/lib/__tests__/data.js.map +1 -1
  113. package/lib/bootstrapCameraKit.js +12 -10
  114. package/lib/bootstrapCameraKit.js.map +1 -1
  115. package/lib/common/any.d.ts +17 -0
  116. package/lib/common/any.js +36 -0
  117. package/lib/common/any.js.map +1 -0
  118. package/lib/common/cameraKitUserAgent.d.ts +5 -0
  119. package/lib/common/cameraKitUserAgent.js +2 -1
  120. package/lib/common/cameraKitUserAgent.js.map +1 -1
  121. package/lib/common/date.d.ts +3 -0
  122. package/lib/common/date.js +13 -0
  123. package/lib/common/date.js.map +1 -0
  124. package/lib/common/errorHelpers.js +1 -1
  125. package/lib/common/errorHelpers.js.map +1 -1
  126. package/lib/common/time.d.ts +1 -0
  127. package/lib/common/time.js +1 -0
  128. package/lib/common/time.js.map +1 -1
  129. package/lib/common/types.d.ts +8 -0
  130. package/lib/common/types.js.map +1 -1
  131. package/lib/dependency-injection/RootServices.d.ts +2 -0
  132. package/lib/dependency-injection/RootServices.js.map +1 -1
  133. package/lib/environment.json +1 -1
  134. package/lib/extensions/LensSources.d.ts +2 -2
  135. package/lib/extensions/LensSources.js +7 -3
  136. package/lib/extensions/LensSources.js.map +1 -1
  137. package/lib/extensions/RemoteApiServices.d.ts +101 -0
  138. package/lib/extensions/RemoteApiServices.js +198 -0
  139. package/lib/extensions/RemoteApiServices.js.map +1 -0
  140. package/lib/extensions/UriHandlers.d.ts +10 -17
  141. package/lib/extensions/UriHandlers.js +5 -60
  142. package/lib/extensions/UriHandlers.js.map +1 -1
  143. package/lib/extensions/uriHandlersRegister.d.ts +21 -0
  144. package/lib/extensions/uriHandlersRegister.js +72 -0
  145. package/lib/extensions/uriHandlersRegister.js.map +1 -0
  146. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.d.ts +31 -0
  147. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js +43 -0
  148. package/lib/generated-proto/pb_schema/camera_kit/v3/features/remote_api_info.js.map +1 -0
  149. package/lib/generated-proto/pb_schema/cdp/cof/namespace.d.ts +1 -0
  150. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js +1 -0
  151. package/lib/generated-proto/pb_schema/cdp/cof/namespace.js.map +1 -1
  152. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.d.ts +569 -0
  153. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js +1175 -0
  154. package/lib/generated-proto/pb_schema/lenses/remote_api/remote_api_service.js.map +1 -0
  155. package/lib/handlers/defaultFetchHandler.js +17 -4
  156. package/lib/handlers/defaultFetchHandler.js.map +1 -1
  157. package/lib/index.d.ts +1 -0
  158. package/lib/index.js +1 -0
  159. package/lib/index.js.map +1 -1
  160. package/lib/legal/legalState.js +1 -1
  161. package/lib/legal/legalState.js.map +1 -1
  162. package/lib/lens/lensHttpUtil.js +26 -4
  163. package/lib/lens/lensHttpUtil.js.map +1 -1
  164. package/lib/lens-core-module/generated-types.d.ts +24 -4
  165. package/lib/lens-core-module/generated-types.js.map +1 -1
  166. package/lib/lensCoreWasmVersions.json +3 -3
  167. package/lib/logger/registerLogEntriesSubscriber.js +13 -1
  168. package/lib/logger/registerLogEntriesSubscriber.js.map +1 -1
  169. package/lib/media-sources/CameraKitSource.d.ts +13 -3
  170. package/lib/media-sources/CameraKitSource.js +2 -8
  171. package/lib/media-sources/CameraKitSource.js.map +1 -1
  172. package/lib/media-sources/FunctionSource.d.ts +1 -1
  173. package/lib/media-sources/FunctionSource.js +1 -1
  174. package/lib/media-sources/FunctionSource.js.map +1 -1
  175. package/lib/media-sources/ImageSource.d.ts +1 -1
  176. package/lib/media-sources/ImageSource.js +1 -1
  177. package/lib/media-sources/ImageSource.js.map +1 -1
  178. package/lib/media-sources/MediaStreamSource.d.ts +1 -1
  179. package/lib/media-sources/MediaStreamSource.js +2 -1
  180. package/lib/media-sources/MediaStreamSource.js.map +1 -1
  181. package/lib/media-sources/VideoSource.d.ts +1 -1
  182. package/lib/media-sources/VideoSource.js +1 -1
  183. package/lib/media-sources/VideoSource.js.map +1 -1
  184. package/lib/metrics/businessEventsReporter.d.ts +3 -2
  185. package/lib/metrics/businessEventsReporter.js +125 -65
  186. package/lib/metrics/businessEventsReporter.js.map +1 -1
  187. package/lib/metrics/operational/operationalMetricsReporter.js +23 -5
  188. package/lib/metrics/operational/operationalMetricsReporter.js.map +1 -1
  189. package/lib/metrics/reporters/reportHttpMetrics.d.ts +0 -7
  190. package/lib/metrics/reporters/reportHttpMetrics.js +3 -2
  191. package/lib/metrics/reporters/reportHttpMetrics.js.map +1 -1
  192. package/lib/metrics/reporters/reportLensView.d.ts +1 -1
  193. package/lib/metrics/reporters/reportLensView.js +41 -13
  194. package/lib/metrics/reporters/reportLensView.js.map +1 -1
  195. package/lib/metrics/reporters/reportUserSession.js +15 -16
  196. package/lib/metrics/reporters/reportUserSession.js.map +1 -1
  197. package/lib/metrics/reporters/reporters.d.ts +1 -1
  198. package/lib/persistence/ExpiringPersistence.d.ts +2 -1
  199. package/lib/persistence/ExpiringPersistence.js +15 -1
  200. package/lib/persistence/ExpiringPersistence.js.map +1 -1
  201. package/lib/persistence/IndexedDBPersistence.d.ts +1 -1
  202. package/lib/persistence/IndexedDBPersistence.js +11 -1
  203. package/lib/persistence/IndexedDBPersistence.js.map +1 -1
  204. package/lib/persistence/Persistence.d.ts +1 -1
  205. package/lib/persistence/Persistence.js.map +1 -1
  206. package/lib/remote-configuration/preloadConfiguration.d.ts +7 -0
  207. package/lib/remote-configuration/preloadConfiguration.js +15 -0
  208. package/lib/remote-configuration/preloadConfiguration.js.map +1 -0
  209. package/lib/remote-configuration/remoteConfiguration.d.ts +5 -1
  210. package/lib/remote-configuration/remoteConfiguration.js +10 -2
  211. package/lib/remote-configuration/remoteConfiguration.js.map +1 -1
  212. package/lib/session/CameraKitSession.d.ts +7 -2
  213. package/lib/session/CameraKitSession.js +1 -0
  214. package/lib/session/CameraKitSession.js.map +1 -1
  215. package/lib/session/sessionState.d.ts +2 -2
  216. package/lib/session/sessionState.js +3 -3
  217. package/lib/session/sessionState.js.map +1 -1
  218. package/package.json +2 -1
  219. package/docs/md/interfaces/UriHandler.md +0 -63
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / CreateSessionOptions
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / CreateSessionOptions
2
2
 
3
3
  # Interface: CreateSessionOptions
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / EstimatedLensPerformance
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / EstimatedLensPerformance
2
2
 
3
3
  # Interface: EstimatedLensPerformance
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Lens
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / Lens
2
2
 
3
3
  # Interface: Lens
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSource
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / LensSource
2
2
 
3
3
  # Interface: LensSource
4
4
 
@@ -34,7 +34,7 @@ ___
34
34
 
35
35
  ### getLens
36
36
 
37
- ▸ **getLens**(`lensId`, `groupId`): `Promise`<`ArrayBuffer`\>
37
+ `Optional` **getLens**(`lensId`, `groupId`): `Promise`<`ArrayBuffer`\>
38
38
 
39
39
  Returns an encoded lens object.
40
40
 
@@ -53,7 +53,7 @@ ___
53
53
 
54
54
  ### getLensGroup
55
55
 
56
- ▸ **getLensGroup**(`groupId`): `Promise`<`ArrayBuffer`[]\>
56
+ `Optional` **getLensGroup**(`groupId`): `Promise`<`ArrayBuffer`[]\>
57
57
 
58
58
  Returns encoded lens objects.
59
59
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / MediaStreamSourceOptions
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / MediaStreamSourceOptions
2
2
 
3
3
  # Interface: MediaStreamSourceOptions
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Preview
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / Preview
2
2
 
3
3
  # Interface: Preview
4
4
 
@@ -0,0 +1,46 @@
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / RemoteApiRequest
2
+
3
+ # Interface: RemoteApiRequest
4
+
5
+ Remote API request sent by a lens.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [apiSpecId](RemoteApiRequest.md#apispecid)
12
+ - [endpointId](RemoteApiRequest.md#endpointid)
13
+ - [parameters](RemoteApiRequest.md#parameters)
14
+ - [body](RemoteApiRequest.md#body)
15
+
16
+ ## Properties
17
+
18
+ ### apiSpecId
19
+
20
+ • **apiSpecId**: `string`
21
+
22
+ Unique id of the remote API service specification.
23
+
24
+ ___
25
+
26
+ ### endpointId
27
+
28
+ • **endpointId**: `string`
29
+
30
+ Unique id of the remote API service endpoint requested by this request.
31
+
32
+ ___
33
+
34
+ ### parameters
35
+
36
+ • **parameters**: `Record`<`string`, `string`\>
37
+
38
+ A map of named parameters associated with the request.
39
+
40
+ ___
41
+
42
+ ### body
43
+
44
+ • **body**: `ArrayBuffer`
45
+
46
+ Additional binary request payload.
@@ -0,0 +1,37 @@
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / RemoteApiResponse
2
+
3
+ # Interface: RemoteApiResponse
4
+
5
+ Remote API response to a request sent by a lens.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [status](RemoteApiResponse.md#status)
12
+ - [metadata](RemoteApiResponse.md#metadata)
13
+ - [body](RemoteApiResponse.md#body)
14
+
15
+ ## Properties
16
+
17
+ ### status
18
+
19
+ • **status**: ``"timeout"`` \| ``"success"`` \| ``"redirected"`` \| ``"cancelled"`` \| ``"notFound"`` \| ``"badRequest"`` \| ``"accessDenied"`` \| ``"requestTooLarge"`` \| ``"serverError"`` \| ``"proxyError"``
20
+
21
+ Status of the response
22
+
23
+ ___
24
+
25
+ ### metadata
26
+
27
+ • **metadata**: `Record`<`string`, `string`\>
28
+
29
+ A map of named metadata associated with the response.
30
+
31
+ ___
32
+
33
+ ### body
34
+
35
+ • **body**: `ArrayBuffer`
36
+
37
+ Additional binary request payload.
@@ -0,0 +1,45 @@
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / RemoteApiService
2
+
3
+ # Interface: RemoteApiService
4
+
5
+ Service to handle a lens Remote API request.
6
+
7
+ ## Table of contents
8
+
9
+ ### Properties
10
+
11
+ - [apiSpecId](RemoteApiService.md#apispecid)
12
+
13
+ ### Methods
14
+
15
+ - [getRequestHandler](RemoteApiService.md#getrequesthandler)
16
+
17
+ ## Properties
18
+
19
+ ### apiSpecId
20
+
21
+ • **apiSpecId**: `string`
22
+
23
+ Remote API spec ID(s).
24
+
25
+ ## Methods
26
+
27
+ ### getRequestHandler
28
+
29
+ ▸ **getRequestHandler**(`request`, `lens`): `undefined` \| [`RemoteApiRequestHandler`](../modules.md#remoteapirequesthandler)
30
+
31
+ This method is called by Camera Kit when a lens triggers a Remote API request with a corresponding spec ID.
32
+ If the service can handle the request, the method returns a request handler; otherwise, it returns nothing.
33
+
34
+ #### Parameters
35
+
36
+ | Name | Type | Description |
37
+ | :------ | :------ | :------ |
38
+ | `request` | [`RemoteApiRequest`](RemoteApiRequest.md) | Remote API request object. |
39
+ | `lens` | [`Lens`](Lens.md) | Lens that trigges the request. |
40
+
41
+ #### Returns
42
+
43
+ `undefined` \| [`RemoteApiRequestHandler`](../modules.md#remoteapirequesthandler)
44
+
45
+ A request handler if applicable.
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / Snapcode
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / Snapcode
2
2
 
3
3
  # Interface: Snapcode
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / UriCancelRequest
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / UriCancelRequest
2
2
 
3
3
  # Interface: UriCancelRequest
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / UriRequest
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / UriRequest
2
2
 
3
3
  # Interface: UriRequest
4
4
 
@@ -29,7 +29,7 @@ ___
29
29
 
30
30
  ### method
31
31
 
32
- • **method**: ``"GET"`` \| ``"POST"``
32
+ • **method**: ``"POST"`` \| ``"GET"``
33
33
 
34
34
  ___
35
35
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / UriResponse
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / UriResponse
2
2
 
3
3
  # Interface: UriResponse
4
4
 
@@ -1,4 +1,4 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](../README.md) / [Exports](../modules.md) / VideoSourceOptions
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](../README.md) / [Exports](../modules.md) / VideoSourceOptions
2
2
 
3
3
  # Interface: VideoSourceOptions
4
4
 
@@ -1,6 +1,6 @@
1
- [CameraKit Web SDK - v0.12.0-alpha.1](README.md) / Exports
1
+ [CameraKit Web SDK - v0.13.0-alpha.1](README.md) / Exports
2
2
 
3
- # CameraKit Web SDK - v0.12.0-alpha.1
3
+ # CameraKit Web SDK - v0.13.0-alpha.1
4
4
 
5
5
  ## Table of contents
6
6
 
@@ -23,7 +23,9 @@
23
23
  - [EstimatedLensPerformance](interfaces/EstimatedLensPerformance.md)
24
24
  - [CameraKitBootstrapConfiguration](interfaces/CameraKitBootstrapConfiguration.md)
25
25
  - [LensSource](interfaces/LensSource.md)
26
- - [UriHandler](interfaces/UriHandler.md)
26
+ - [RemoteApiRequest](interfaces/RemoteApiRequest.md)
27
+ - [RemoteApiResponse](interfaces/RemoteApiResponse.md)
28
+ - [RemoteApiService](interfaces/RemoteApiService.md)
27
29
  - [UriRequest](interfaces/UriRequest.md)
28
30
  - [UriResponse](interfaces/UriResponse.md)
29
31
  - [UriCancelRequest](interfaces/UriCancelRequest.md)
@@ -40,12 +42,15 @@
40
42
  - [LensMetricsEvents](modules.md#lensmetricsevents)
41
43
  - [LensPerformanceCluster](modules.md#lensperformancecluster)
42
44
  - [PublicContainer](modules.md#publiccontainer)
43
- - [UriHandlers](modules.md#urihandlers)
45
+ - [RemoteApiStatus](modules.md#remoteapistatus)
46
+ - [RemoteApiRequestHandler](modules.md#remoteapirequesthandler)
47
+ - [RemoteApiServices](modules.md#remoteapiservices)
44
48
  - [Uri](modules.md#uri)
45
49
  - [LensLaunchParams](modules.md#lenslaunchparams)
46
50
  - [AssetTiming](modules.md#assettiming)
47
51
  - [AssetLoader](modules.md#assetloader)
48
52
  - [CameraKitDeviceInfo](modules.md#camerakitdeviceinfo)
53
+ - [CameraKitDeviceOptions](modules.md#camerakitdeviceoptions)
49
54
  - [CameraKitSourceInfo](modules.md#camerakitsourceinfo)
50
55
  - [CameraKitSourceOptions](modules.md#camerakitsourceoptions)
51
56
  - [LensView](modules.md#lensview)
@@ -81,7 +86,7 @@
81
86
  - [createExtension](modules.md#createextension)
82
87
  - [Injectable](modules.md#injectable)
83
88
  - [lensSourcesFactory](modules.md#lenssourcesfactory)
84
- - [uriHandlersFactory](modules.md#urihandlersfactory)
89
+ - [remoteApiServicesFactory](modules.md#remoteapiservicesfactory)
85
90
  - [getRequiredBootstrapURLs](modules.md#getrequiredbootstrapurls)
86
91
  - [createImageSource](modules.md#createimagesource)
87
92
  - [createUserMediaSource](modules.md#createusermediasource)
@@ -460,11 +465,42 @@ should decrease – we measure between the request to apply a lens and when the
460
465
 
461
466
  ## Other
462
467
 
463
- ### UriHandlers
468
+ ### RemoteApiStatus
464
469
 
465
- Ƭ **UriHandlers**: [`UriHandler`](interfaces/UriHandler.md)[]
470
+ Ƭ **RemoteApiStatus**: keyof typeof `statusToResponseCodeMap`
466
471
 
467
- Array of [UriHandler](interfaces/UriHandler.md) objects.
472
+ Status of a Remote API response.
473
+
474
+ ___
475
+
476
+ ### RemoteApiRequestHandler
477
+
478
+ Ƭ **RemoteApiRequestHandler**: (`reply`: (`response`: [`RemoteApiResponse`](interfaces/RemoteApiResponse.md)) => `void`) => `RemoteApiCancelRequestHandler` \| `void`
479
+
480
+ #### Type declaration
481
+
482
+ ▸ (`reply`): `RemoteApiCancelRequestHandler` \| `void`
483
+
484
+ Represents a Remote API request handler function.
485
+ It is provided with a reply callback that must be invoked to send a response back to the lens.
486
+ The reply callback can be invoked multiple times if needed.
487
+ Additionally, the handler can return a cancellation callback, which is triggered when the lens cancels the request.
488
+
489
+ ##### Parameters
490
+
491
+ | Name | Type |
492
+ | :------ | :------ |
493
+ | `reply` | (`response`: [`RemoteApiResponse`](interfaces/RemoteApiResponse.md)) => `void` |
494
+
495
+ ##### Returns
496
+
497
+ `RemoteApiCancelRequestHandler` \| `void`
498
+
499
+ ___
500
+
501
+ ### RemoteApiServices
502
+
503
+ Ƭ **RemoteApiServices**: [`RemoteApiService`](interfaces/RemoteApiService.md)[]
468
504
 
469
505
  ___
470
506
 
@@ -679,11 +715,9 @@ ___
679
715
 
680
716
  ___
681
717
 
682
- ### uriHandlersFactory
683
-
684
- ▸ **uriHandlersFactory**(`...args`): [`UriHandlers`](modules.md#urihandlers)
718
+ ### remoteApiServicesFactory
685
719
 
686
- An extension point for client URI handlers.
720
+ **remoteApiServicesFactory**(`...args`): [`RemoteApiServices`](modules.md#remoteapiservices)
687
721
 
688
722
  #### Parameters
689
723
 
@@ -693,7 +727,7 @@ An extension point for client URI handlers.
693
727
 
694
728
  #### Returns
695
729
 
696
- [`UriHandlers`](modules.md#urihandlers)
730
+ [`RemoteApiServices`](modules.md#remoteapiservices)
697
731
 
698
732
  ## Rendering
699
733
 
@@ -701,18 +735,35 @@ An extension point for client URI handlers.
701
735
 
702
736
  Ƭ **CameraKitDeviceInfo**: `Object`
703
737
 
738
+ **`Deprecated`**
739
+
740
+ use [CameraKitDeviceOptions](modules.md#camerakitdeviceoptions)
741
+
742
+ #### Type declaration
743
+
744
+ | Name | Type | Description |
745
+ | :------ | :------ | :------ |
746
+ | `cameraType` | ``"front"`` \| ``"back"`` | **`Deprecated`** "front" and "back" are deprecated please use "user" or "enviroment" for cameraType instead |
747
+ | `fpsLimit` | `number` | - |
748
+
749
+ ___
750
+
751
+ ### CameraKitDeviceOptions
752
+
753
+ Ƭ **CameraKitDeviceOptions**: `Object`
754
+
704
755
  #### Type declaration
705
756
 
706
757
  | Name | Type |
707
758
  | :------ | :------ |
708
- | `cameraType` | ``"front"`` \| ``"back"`` |
759
+ | `cameraType` | ``"user"`` \| ``"environment"`` |
709
760
  | `fpsLimit` | `number` |
710
761
 
711
762
  ___
712
763
 
713
764
  ### CameraKitSourceOptions
714
765
 
715
- Ƭ **CameraKitSourceOptions**<`T`\>: `Partial`<`T`\> & `Partial`<[`CameraKitDeviceInfo`](modules.md#camerakitdeviceinfo)\>
766
+ Ƭ **CameraKitSourceOptions**<`T`\>: `Partial`<`T`\> & `Partial`<[`CameraKitDeviceInfo`](modules.md#camerakitdeviceinfo) \| [`CameraKitDeviceOptions`](modules.md#camerakitdeviceoptions)\>
716
767
 
717
768
  #### Type parameters
718
769
 
package/lib/CameraKit.js CHANGED
@@ -6,7 +6,7 @@ import { cameraKitSessionFactory } from "./session/CameraKitSession";
6
6
  import { registerLensAssetsProvider } from "./lens/assets/LensAssetsProvider";
7
7
  import { lensCoreFactory } from "./lens-core-module/loader/lensCoreFactory";
8
8
  import { configurationToken } from "./configuration";
9
- import { registerUriHandlers } from "./extensions/UriHandlers";
9
+ import { registerUriHandlers } from "./extensions/uriHandlersRegister";
10
10
  import { metricsEventTargetFactory } from "./metrics/metricsEventTarget";
11
11
  import { reportSessionScopedMetrics } from "./metrics/reporters/reporters";
12
12
  import { lensStateFactory } from "./session/lensState";
@@ -18,6 +18,7 @@ import { getLogger, resetLogger } from "./logger/logger";
18
18
  import { errorLoggingDecorator } from "./logger/errorLoggingDecorator";
19
19
  import { TypedEventTarget } from "./events/TypedEventTarget";
20
20
  import { pageVisibilityFactory } from "./common/pageVisibility";
21
+ import { setPreloadedConfiguration } from "./remote-configuration/preloadConfiguration";
21
22
  const logger = getLogger("CameraKit");
22
23
  const log = errorLoggingDecorator(logger);
23
24
  /**
@@ -127,6 +128,7 @@ export class CameraKit {
127
128
  .provides(cameraKitSessionFactory)
128
129
  .run(registerLensAssetsProvider)
129
130
  .run(registerLensClientInterfaceHandler)
131
+ .run(setPreloadedConfiguration)
130
132
  // We'll run a PartialContainer containing reporters for session-scoped metrics. Running this container
131
133
  // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain
132
134
  // actions occur).
@@ -1 +1 @@
1
- {"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,uBAAuB,CAAC;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AAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACvB,CAAC;KAAA;CACJ;AAlFS;IADL,GAAG;;;;8CAuEH;AAMK;IADL,GAAG;;;;wCAMH;AAGL,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,WAAW,EACX;IACI,qBAAqB,CAAC,KAAK;IAC3B,yBAAyB,CAAC,KAAK;IAC/B,eAAe,CAAC,KAAK;IACrB,qBAAqB,CAAC,KAAK;IAC3B,SAAS;CACH,EACV,CACI,cAA8B,EAC9B,OAA2B,EAC3B,QAAwB,EACxB,cAA8B,EAC9B,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,CACnF,CAAC","sourcesContent":["import { lensRepositoryFactory, LensRepository } from \"./lens/LensRepository\";\nimport { CONTAINER, Container } from \"./dependency-injection/Container\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LensCoreError, LensCoreModule } from \"./lens-core-module/generated-types\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport { RootServices } from \"./dependency-injection/RootServices\";\nimport { registerUriHandlers } from \"./extensions/UriHandlers\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportSessionScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { lensStateFactory } from \"./session/lensState\";\nimport { lensKeyboardFactory } from \"./session/LensKeyboard\";\nimport { registerLensClientInterfaceHandler } from \"./lens-client-interface/lensClientInterface\";\nimport { sessionStateFactory } from \"./session/sessionState\";\nimport { lensExecutionError } from \"./namedErrors\";\nimport { getLogger, resetLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport { LensView } from \"./metrics/reporters/reportLensView\";\nimport { LensWait } from \"./metrics/reporters/reportLensWait\";\nimport { PageVisibility, pageVisibilityFactory } from \"./common/pageVisibility\";\n\nconst logger = getLogger(\"CameraKit\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Metrics event names that are exposed to apps.\n */\nconst publicMetricsEventNames: Array<LensMetricsEvents[\"detail\"][\"name\"]> = [\"lensView\", \"lensWait\"];\n\n/**\n * Lens metrics events.\n *\n * These events are emitted by {@link CameraKit} to report lens usage, performance, apply latency, etc.\n *\n * @category Lenses\n * @category Metrics\n */\nexport type LensMetricsEvents =\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>;\n\n/**\n * Options available when creating a {@link CameraKitSession}.\n *\n * @category Rendering\n */\nexport interface CreateSessionOptions {\n /**\n * Optionally provide an existing canvas element, on which the Live RenderTarget will be rendered.\n *\n * If this is not provided, CameraKit will create a new canvas element which can be added to the DOM.\n */\n liveRenderTarget?: HTMLCanvasElement;\n\n /**\n * Browsers optimize tabs when they are hidden - for example, by pausing the execution of requestAnimationFrame\n * callbacks.\n *\n * If you need the CameraKitSession to continue rendering even when the tab is in the background, set this to true.\n * There is a small performance penalty, and it's a good practice to only render in the background if absolutely\n * necessary.\n */\n renderWhileTabHidden?: boolean;\n}\n\n/**\n * The entry point to the CameraKit SDK's API. Most of CameraKit's features are accessed via this class.\n *\n * Applications obtain an instance of CameraKit by calling {@link bootstrapCameraKit}.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * ```\n *\n * Then this class can be used to:\n * - Create a {@link CameraKitSession} instance, which provides the API for setting up media inputs, applying Lenses,\n * and obtaining rendered `<canvas>` outputs.\n * - Query for lenses using {@link LensRepository}.\n * - Listen for lens usage metrics events using {@link MetricsEventTarget}.\n *\n * @category Rendering\n * @category Lenses\n */\nexport class CameraKit {\n /** @deprecated Use {@link lensRepository} */\n readonly lenses: { repository: LensRepository };\n\n /**\n * Business metrics (e.g. each time a lens is viewed) are emitted here.\n */\n readonly metrics: TypedEventTarget<LensMetricsEvents> = new TypedEventTarget();\n\n private sessions: CameraKitSession[] = [];\n\n /** @internal */\n constructor(\n /**\n * Used to query for lenses and lens groups.\n */\n readonly lensRepository: LensRepository,\n\n private readonly lensCore: LensCoreModule,\n private readonly pageVisibility: PageVisibility,\n private readonly container: Container<RootServices>,\n allMetrics: MetricsEventTarget\n ) {\n this.lenses = { repository: this.lensRepository };\n // Proxy only a subset of all metrics events to the public-facing emitter -- applications don't need to\n // know about most events.\n publicMetricsEventNames.forEach((eventName) => {\n allMetrics.addEventListener(eventName, (e) => this.metrics.dispatchEvent(e));\n });\n }\n\n /**\n * Create a CameraKitSession.\n *\n * This initializes the rendering engine and returns a {@link CameraKitSession} instance, which provides access\n * to Lens rendering.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * const session = await cameraKit.createSession()\n *\n * const lens = await cameraKit.lensRepository.loadLens(lensId, groupId)\n * session.applyLens(lens)\n * ```\n *\n * @param options\n */\n @log\n async createSession({\n liveRenderTarget,\n renderWhileTabHidden,\n }: CreateSessionOptions = {}): Promise<CameraKitSession> {\n // Any error happened during lens rendering can be processed by subscribing to sessionErrors\n const exceptionHandler = (error: LensCoreError) =>\n logger.error(\n lensExecutionError(\n \"Error occurred during lens execution. \" +\n \"The lens cannot be rendered and will be removed from the CameraKitSession.\",\n error\n )\n );\n\n /**\n * If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM\n * module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore\n * probably becomes a lot more straightforward.\n *\n * Currently chromium has a bug preventing rendering while tab is hidden when LensCore is in worker mode.\n * In order to process tab while it is hidden, the current stopgap is to pass in renderWhileTabHidden as true,\n * which will initiate session in non worker mode, and set the RenderLoopMode to `SetTimeout`.\n */\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\n onSuccess,\n onFailure,\n });\n });\n\n // Each session gets its own DI Container – some Services provided by this Container may be shared with the\n // root CameraKit Container, but others may be scoped to the session by passing their token to `copy()`.\n const sessionContainer = this.container\n // Right now this is a no-op. If/when we add support for multiple concurrent sessions, we may end up\n // scoping LensCore to the session.\n .copy()\n\n .provides(sessionStateFactory)\n .provides(lensStateFactory)\n .provides(lensKeyboardFactory)\n .provides(cameraKitSessionFactory)\n\n .run(registerLensAssetsProvider)\n .run(registerLensClientInterfaceHandler)\n\n // We'll run a PartialContainer containing reporters for session-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur).\n .run(reportSessionScopedMetrics)\n\n // UriHandlers may have dependencies on session-scoped services (e.g. LensState, LensKeyboard), so they'll\n // be registered with LensCore here.\n .run(registerUriHandlers);\n\n const session = sessionContainer.get(cameraKitSessionFactory.token);\n this.sessions.push(session);\n return session;\n }\n\n /**\n * Destroys all sessions and frees all resources.\n */\n @log\n async destroy() {\n resetLogger();\n this.pageVisibility.destroy();\n await Promise.all(this.sessions.map((session) => session.destroy()));\n this.sessions = [];\n }\n}\n\n/** @internal */\nexport const cameraKitFactory = Injectable(\n \"CameraKit\",\n [\n lensRepositoryFactory.token,\n metricsEventTargetFactory.token,\n lensCoreFactory.token,\n pageVisibilityFactory.token,\n CONTAINER,\n ] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCoreModule,\n pageVisibility: PageVisibility,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, pageVisibility, container, metrics)\n);\n"]}
1
+ {"version":3,"file":"CameraKit.js","sourceRoot":"","sources":["../src/CameraKit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAE/D,OAAO,EAAoB,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AACvF,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAsB,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC7F,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kCAAkC,EAAE,MAAM,6CAA6C,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D,OAAO,EAAkB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,yBAAyB,E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AAK,CAAC,CAAC;YACpE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC5B,OAAO,OAAO,CAAC;QACnB,CAAC;KAAA;IAED;;OAEG;IAEG,OAAO;;YACT,WAAW,EAAE,CAAC;YACd,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;YAC9B,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACvB,CAAC;KAAA;CACJ;AAnFS;IADL,GAAG;;;;8CAwEH;AAMK;IADL,GAAG;;;;wCAMH;AAGL,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CACtC,WAAW,EACX;IACI,qBAAqB,CAAC,KAAK;IAC3B,yBAAyB,CAAC,KAAK;IAC/B,eAAe,CAAC,KAAK;IACrB,qBAAqB,CAAC,KAAK;IAC3B,SAAS;CACH,EACV,CACI,cAA8B,EAC9B,OAA2B,EAC3B,QAAwB,EACxB,cAA8B,EAC9B,SAAkC,EACpC,EAAE,CAAC,IAAI,SAAS,CAAC,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,CACnF,CAAC","sourcesContent":["import { lensRepositoryFactory, LensRepository } from \"./lens/LensRepository\";\nimport { CONTAINER, Container } from \"./dependency-injection/Container\";\nimport { Injectable } from \"./dependency-injection/Injectable\";\nimport { LensCoreError, LensCoreModule } from \"./lens-core-module/generated-types\";\nimport { CameraKitSession, cameraKitSessionFactory } from \"./session/CameraKitSession\";\nimport { registerLensAssetsProvider } from \"./lens/assets/LensAssetsProvider\";\nimport { lensCoreFactory } from \"./lens-core-module/loader/lensCoreFactory\";\nimport { configurationToken } from \"./configuration\";\nimport { RootServices } from \"./dependency-injection/RootServices\";\nimport { registerUriHandlers } from \"./extensions/uriHandlersRegister\";\nimport { MetricsEventTarget, metricsEventTargetFactory } from \"./metrics/metricsEventTarget\";\nimport { reportSessionScopedMetrics } from \"./metrics/reporters/reporters\";\nimport { lensStateFactory } from \"./session/lensState\";\nimport { lensKeyboardFactory } from \"./session/LensKeyboard\";\nimport { registerLensClientInterfaceHandler } from \"./lens-client-interface/lensClientInterface\";\nimport { sessionStateFactory } from \"./session/sessionState\";\nimport { lensExecutionError } from \"./namedErrors\";\nimport { getLogger, resetLogger } from \"./logger/logger\";\nimport { errorLoggingDecorator } from \"./logger/errorLoggingDecorator\";\nimport { TypedEventTarget } from \"./events/TypedEventTarget\";\nimport { TypedCustomEvent } from \"./events/TypedCustomEvent\";\nimport { LensView } from \"./metrics/reporters/reportLensView\";\nimport { LensWait } from \"./metrics/reporters/reportLensWait\";\nimport { PageVisibility, pageVisibilityFactory } from \"./common/pageVisibility\";\nimport { setPreloadedConfiguration } from \"./remote-configuration/preloadConfiguration\";\n\nconst logger = getLogger(\"CameraKit\");\nconst log = errorLoggingDecorator(logger);\n\n/**\n * Metrics event names that are exposed to apps.\n */\nconst publicMetricsEventNames: Array<LensMetricsEvents[\"detail\"][\"name\"]> = [\"lensView\", \"lensWait\"];\n\n/**\n * Lens metrics events.\n *\n * These events are emitted by {@link CameraKit} to report lens usage, performance, apply latency, etc.\n *\n * @category Lenses\n * @category Metrics\n */\nexport type LensMetricsEvents =\n | TypedCustomEvent<LensView[\"name\"], LensView>\n | TypedCustomEvent<LensWait[\"name\"], LensWait>;\n\n/**\n * Options available when creating a {@link CameraKitSession}.\n *\n * @category Rendering\n */\nexport interface CreateSessionOptions {\n /**\n * Optionally provide an existing canvas element, on which the Live RenderTarget will be rendered.\n *\n * If this is not provided, CameraKit will create a new canvas element which can be added to the DOM.\n */\n liveRenderTarget?: HTMLCanvasElement;\n\n /**\n * Browsers optimize tabs when they are hidden - for example, by pausing the execution of requestAnimationFrame\n * callbacks.\n *\n * If you need the CameraKitSession to continue rendering even when the tab is in the background, set this to true.\n * There is a small performance penalty, and it's a good practice to only render in the background if absolutely\n * necessary.\n */\n renderWhileTabHidden?: boolean;\n}\n\n/**\n * The entry point to the CameraKit SDK's API. Most of CameraKit's features are accessed via this class.\n *\n * Applications obtain an instance of CameraKit by calling {@link bootstrapCameraKit}.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * ```\n *\n * Then this class can be used to:\n * - Create a {@link CameraKitSession} instance, which provides the API for setting up media inputs, applying Lenses,\n * and obtaining rendered `<canvas>` outputs.\n * - Query for lenses using {@link LensRepository}.\n * - Listen for lens usage metrics events using {@link MetricsEventTarget}.\n *\n * @category Rendering\n * @category Lenses\n */\nexport class CameraKit {\n /** @deprecated Use {@link lensRepository} */\n readonly lenses: { repository: LensRepository };\n\n /**\n * Business metrics (e.g. each time a lens is viewed) are emitted here.\n */\n readonly metrics: TypedEventTarget<LensMetricsEvents> = new TypedEventTarget();\n\n private sessions: CameraKitSession[] = [];\n\n /** @internal */\n constructor(\n /**\n * Used to query for lenses and lens groups.\n */\n readonly lensRepository: LensRepository,\n\n private readonly lensCore: LensCoreModule,\n private readonly pageVisibility: PageVisibility,\n private readonly container: Container<RootServices>,\n allMetrics: MetricsEventTarget\n ) {\n this.lenses = { repository: this.lensRepository };\n // Proxy only a subset of all metrics events to the public-facing emitter -- applications don't need to\n // know about most events.\n publicMetricsEventNames.forEach((eventName) => {\n allMetrics.addEventListener(eventName, (e) => this.metrics.dispatchEvent(e));\n });\n }\n\n /**\n * Create a CameraKitSession.\n *\n * This initializes the rendering engine and returns a {@link CameraKitSession} instance, which provides access\n * to Lens rendering.\n *\n * @example\n * ```ts\n * const cameraKit = await bootstrapCameraKit(config)\n * const session = await cameraKit.createSession()\n *\n * const lens = await cameraKit.lensRepository.loadLens(lensId, groupId)\n * session.applyLens(lens)\n * ```\n *\n * @param options\n */\n @log\n async createSession({\n liveRenderTarget,\n renderWhileTabHidden,\n }: CreateSessionOptions = {}): Promise<CameraKitSession> {\n // Any error happened during lens rendering can be processed by subscribing to sessionErrors\n const exceptionHandler = (error: LensCoreError) =>\n logger.error(\n lensExecutionError(\n \"Error occurred during lens execution. \" +\n \"The lens cannot be rendered and will be removed from the CameraKitSession.\",\n error\n )\n );\n\n /**\n * If/when we add support for multiple concurrent sessions, we'll need to create a copy of the LensCore WASM\n * module. If we move managing web workers into JS, spawing a new worker thread with its own copy of LensCore\n * probably becomes a lot more straightforward.\n *\n * Currently chromium has a bug preventing rendering while tab is hidden when LensCore is in worker mode.\n * In order to process tab while it is hidden, the current stopgap is to pass in renderWhileTabHidden as true,\n * which will initiate session in non worker mode, and set the RenderLoopMode to `SetTimeout`.\n */\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.initialize({\n canvas: liveRenderTarget,\n shouldUseWorker: !renderWhileTabHidden && this.container.get(configurationToken).shouldUseWorker,\n exceptionHandler,\n onSuccess,\n onFailure,\n });\n });\n\n await new Promise<void>((onSuccess, onFailure) => {\n this.lensCore.setRenderLoopMode({\n mode: renderWhileTabHidden\n ? this.lensCore.RenderLoopMode.SetTimeout\n : this.lensCore.RenderLoopMode.RequestAnimationFrame,\n onSuccess,\n onFailure,\n });\n });\n\n // Each session gets its own DI Container – some Services provided by this Container may be shared with the\n // root CameraKit Container, but others may be scoped to the session by passing their token to `copy()`.\n const sessionContainer = this.container\n // Right now this is a no-op. If/when we add support for multiple concurrent sessions, we may end up\n // scoping LensCore to the session.\n .copy()\n\n .provides(sessionStateFactory)\n .provides(lensStateFactory)\n .provides(lensKeyboardFactory)\n .provides(cameraKitSessionFactory)\n\n .run(registerLensAssetsProvider)\n .run(registerLensClientInterfaceHandler)\n .run(setPreloadedConfiguration)\n\n // We'll run a PartialContainer containing reporters for session-scoped metrics. Running this container\n // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain\n // actions occur).\n .run(reportSessionScopedMetrics)\n\n // UriHandlers may have dependencies on session-scoped services (e.g. LensState, LensKeyboard), so they'll\n // be registered with LensCore here.\n .run(registerUriHandlers);\n\n const session = sessionContainer.get(cameraKitSessionFactory.token);\n this.sessions.push(session);\n return session;\n }\n\n /**\n * Destroys all sessions and frees all resources.\n */\n @log\n async destroy() {\n resetLogger();\n this.pageVisibility.destroy();\n await Promise.all(this.sessions.map((session) => session.destroy()));\n this.sessions = [];\n }\n}\n\n/** @internal */\nexport const cameraKitFactory = Injectable(\n \"CameraKit\",\n [\n lensRepositoryFactory.token,\n metricsEventTargetFactory.token,\n lensCoreFactory.token,\n pageVisibilityFactory.token,\n CONTAINER,\n ] as const,\n (\n lensRepository: LensRepository,\n metrics: MetricsEventTarget,\n lensCore: LensCoreModule,\n pageVisibility: PageVisibility,\n container: Container<RootServices>\n ) => new CameraKit(lensRepository, lensCore, pageVisibility, container, metrics)\n);\n"]}
@@ -4,6 +4,6 @@ import { LensCoreModule, AssetType as LensCoreAssetType } from "../lens-core-mod
4
4
  export declare const falsyValues: readonly [false, null, undefined, 0, ""];
5
5
  export declare const truthyValues: readonly [true, 1, {}, Date, readonly []];
6
6
  export declare function createLensFixture(name: string, content?: Partial<ContentProto>): LensProto;
7
- export type LensCoreMock = Pick<jest.Mocked<LensCoreModule>, "AssetType" | "CanvasType" | "InterfaceAction" | "InterfaceControl" | "ExternalMediaOrientation" | "initialize" | "setRemoteAssetsProvider" | "provideRemoteAssetsResponse" | "getOutputCanvases" | "setRenderLoopMode" | "RenderLoopMode" | "setOnFrameProcessedCallback" | "setClientInterfaceRequestHandler" | "provideExternalImage" | "provideExternalVideo" | "registerSavePersistentStoreCallback">;
7
+ export type LensCoreMock = Pick<jest.Mocked<LensCoreModule>, "AssetType" | "CanvasType" | "InterfaceAction" | "InterfaceControl" | "ExternalMediaOrientation" | "initialize" | "setRemoteAssetsProvider" | "provideRemoteAssetsResponse" | "getOutputCanvases" | "setRenderLoopMode" | "RenderLoopMode" | "setPreloadedConfiguration" | "setOnFrameProcessedCallback" | "setClientInterfaceRequestHandler" | "provideExternalImage" | "provideExternalVideo" | "registerSavePersistentStoreCallback">;
8
8
  export declare const AssetType: Record<keyof LensCoreModule["AssetType"], LensCoreAssetType>;
9
9
  export declare function createLensCore(): LensCoreMock;
@@ -47,6 +47,7 @@ export function createLensCore() {
47
47
  setRemoteAssetsProvider: jest.fn(),
48
48
  provideRemoteAssetsResponse: jest.fn(),
49
49
  getOutputCanvases: jest.fn(),
50
+ setPreloadedConfiguration: jest.fn(),
50
51
  setRenderLoopMode: jest.fn(),
51
52
  setOnFrameProcessedCallback: jest.fn(),
52
53
  setClientInterfaceRequestHandler: jest.fn(),
@@ -1 +1 @@
1
- {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/__tests__/data.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAA2B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAU,CAAC;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAU,CAAC;AAEnE,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAA+B;IAC3E,OAAO;QACH,EAAE,EAAE,IAAI;QACR,IAAI;QACJ,UAAU,EAAE,EAAE;QACd,OAAO,kBACH,WAAW,EAAE,2BAA2B,EACxC,SAAS,EAAE,EAAE,EACb,UAAU,EAAE,EAAE,EACd,OAAO,EAAE;gBACL,QAAQ,EAAE,8BAA8B;gBACxC,iBAAiB,EAAE,GAAG;gBACtB,2BAA2B,EAAE,+BAA+B;aAC/D,EACD,aAAa,EAAE,EAAE,EACjB,aAAa,EAAE,EAAE,EACjB,gBAAgB,EAAE,EAAE,IACjB,OAAO,CACb;QACD,SAAS,EAAE;YACP,gBAAgB,EAAE,8BAA8B;YAChD,gBAAgB,EAAE,8BAA8B;SACnD;QACD,YA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E,KAAK,EAAE,CAAC,EAAE,EAAE;QAC7G,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE;QACrB,uBAAuB,EAAE,IAAI,CAAC,EAAE,EAAE;QAClC,2BAA2B,EAAE,IAAI,CAAC,EAAE,EAAE;QACtC,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,2BAA2B,EAAE,IAAI,CAAC,EAAE,EAAE;QACtC,gCAAgC,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3C,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/B,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/B,mCAAmC,EAAE,IAAI,CAAC,EAAE,EAAE;KACjD,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable max-len */\nimport { ContentProto, LensProto, Lens_CameraFacing } from \"../lens\";\nimport { LensCoreModule, AssetType as LensCoreAssetType } from \"../lens-core-module/generated-types\";\n\nexport const falsyValues = [false, null, undefined, 0, \"\"] as const;\nexport const truthyValues = [true, 1, {}, new Date(), []] as const;\n\nexport function createLensFixture(name: string, content?: Partial<ContentProto>): LensProto {\n return {\n id: name,\n name,\n vendorData: {},\n content: {\n iconUrlBolt: \"https://bolt.com/iconUrl1\",\n lnsSha256: \"\",\n lnsUrlBolt: \"\",\n preview: {\n imageUrl: \"https://bolt.com/previewUrl1\",\n imageSequenceSize: 100,\n imageSequenceWebpUrlPattern: \"http://images.com/face-%d.com\",\n },\n assetManifest: [],\n defaultHintId: \"\",\n hintTranslations: {},\n ...content,\n },\n scannable: {\n snapcodeImageUrl: \"https://snapcodeImageUrl.com\",\n snapcodeDeeplink: \"https://snapcodeDeeplink.com\",\n },\n isThirdParty: false,\n cameraFacingPreference: Lens_CameraFacing.UNRECOGNIZED,\n featureMetadata: [],\n lensCreator: {\n displayName: \"\",\n },\n };\n}\n\nexport type LensCoreMock = Pick<\n jest.Mocked<LensCoreModule>,\n | \"AssetType\"\n | \"CanvasType\"\n | \"InterfaceAction\"\n | \"InterfaceControl\"\n | \"ExternalMediaOrientation\"\n | \"initialize\"\n | \"setRemoteAssetsProvider\"\n | \"provideRemoteAssetsResponse\"\n | \"getOutputCanvases\"\n | \"setRenderLoopMode\"\n | \"RenderLoopMode\"\n | \"setOnFrameProcessedCallback\"\n | \"setClientInterfaceRequestHandler\"\n | \"provideExternalImage\"\n | \"provideExternalVideo\"\n | \"registerSavePersistentStoreCallback\"\n>;\n\n// NOTE: type of the record ensures newly added asset types break compilation\nexport const AssetType: Record<keyof LensCoreModule[\"AssetType\"], LensCoreAssetType> = {\n DeviceDependent: { value: 3 },\n RemoteMediaByUrl: { value: 6 },\n Static: { value: 1 },\n URL: { value: 2 },\n BitmojiDynamicAsset: { value: 4 },\n};\n\nexport function createLensCore(): LensCoreMock {\n return {\n AssetType,\n CanvasType: { Preview: { value: 1 }, Capture: { value: 2 }, None: { value: 0 }, All: { value: 3 } },\n RenderLoopMode: { SetTimeout: { value: 1 }, RequestAnimationFrame: { value: 0 } },\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L39\n InterfaceAction: { Show: { value: 3 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L21\n InterfaceControl: { ImagePicker: { value: 1 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/2d538ecc41f67dd2c199e0ff0eefd96aac6f22dc/Src/Common/IExternalMediaFilePickedObserver.h#L21\n ExternalMediaOrientation: { CW0: { value: 0 }, CW90: { value: 1 }, CW180: { value: 2 }, CW270: { value: 3 } },\n initialize: jest.fn(),\n setRemoteAssetsProvider: jest.fn(),\n provideRemoteAssetsResponse: jest.fn(),\n getOutputCanvases: jest.fn(),\n setRenderLoopMode: jest.fn(),\n setOnFrameProcessedCallback: jest.fn(),\n setClientInterfaceRequestHandler: jest.fn(),\n provideExternalImage: jest.fn(),\n provideExternalVideo: jest.fn(),\n registerSavePersistentStoreCallback: jest.fn(),\n };\n}\n"]}
1
+ {"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/__tests__/data.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,OAAO,EAA2B,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGrE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,CAAU,CAAC;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CAAU,CAAC;AAEnE,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAA+B;IAC3E,OAAO;QACH,EAAE,EAAE,IAAI;QACR,IAAI;QACJ,UAAU,EAAE,EAAE;QACd,OAAO,kBACH,WAAW,EAAE,2BAA2B,EACxC,SAAS,EAAE,EAAE,EACb,UAAU,EAAE,EAAE,EACd,OAAO,EAAE;gBACL,QAAQ,EAAE,8BAA8B;gBACxC,iBAAiB,EAAE,GAAG;gBACtB,2BAA2B,EAAE,+BAA+B;aAC/D,EACD,aAAa,EAAE,EAAE,EACjB,aAAa,EAAE,EAAE,EACjB,gBAAgB,EAAE,EAAE,IACjB,OAAO,CACb;QACD,SAAS,EAAE;YACP,gBAAgB,EAAE,8BAA8B;YAChD,gBAAgB,EAAE,8BAA8B;SACnD;QACD,YAAY,EAAE,KAAK;QACnB,sBAAsB,EAAE,iBAAiB,CAAC,YAAY;QACtD,eAAe,EAAE,EAAE;QACnB,WAAW,EAAE;YACT,WAAW,EAAE,EAAE;SAClB;KACJ,CAAC;AACN,CAAC;AAuBD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,SAAS,GAAiE;IACnF,eAAe,EAAE,EAAE,KAAK,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I,CAAC,EAAE,EAAE;QACpC,iBAAiB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC5B,2BAA2B,EAAE,IAAI,CAAC,EAAE,EAAE;QACtC,gCAAgC,EAAE,IAAI,CAAC,EAAE,EAAE;QAC3C,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/B,oBAAoB,EAAE,IAAI,CAAC,EAAE,EAAE;QAC/B,mCAAmC,EAAE,IAAI,CAAC,EAAE,EAAE;KACjD,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable max-len */\nimport { ContentProto, LensProto, Lens_CameraFacing } from \"../lens\";\nimport { LensCoreModule, AssetType as LensCoreAssetType } from \"../lens-core-module/generated-types\";\n\nexport const falsyValues = [false, null, undefined, 0, \"\"] as const;\nexport const truthyValues = [true, 1, {}, new Date(), []] as const;\n\nexport function createLensFixture(name: string, content?: Partial<ContentProto>): LensProto {\n return {\n id: name,\n name,\n vendorData: {},\n content: {\n iconUrlBolt: \"https://bolt.com/iconUrl1\",\n lnsSha256: \"\",\n lnsUrlBolt: \"\",\n preview: {\n imageUrl: \"https://bolt.com/previewUrl1\",\n imageSequenceSize: 100,\n imageSequenceWebpUrlPattern: \"http://images.com/face-%d.com\",\n },\n assetManifest: [],\n defaultHintId: \"\",\n hintTranslations: {},\n ...content,\n },\n scannable: {\n snapcodeImageUrl: \"https://snapcodeImageUrl.com\",\n snapcodeDeeplink: \"https://snapcodeDeeplink.com\",\n },\n isThirdParty: false,\n cameraFacingPreference: Lens_CameraFacing.UNRECOGNIZED,\n featureMetadata: [],\n lensCreator: {\n displayName: \"\",\n },\n };\n}\n\nexport type LensCoreMock = Pick<\n jest.Mocked<LensCoreModule>,\n | \"AssetType\"\n | \"CanvasType\"\n | \"InterfaceAction\"\n | \"InterfaceControl\"\n | \"ExternalMediaOrientation\"\n | \"initialize\"\n | \"setRemoteAssetsProvider\"\n | \"provideRemoteAssetsResponse\"\n | \"getOutputCanvases\"\n | \"setRenderLoopMode\"\n | \"RenderLoopMode\"\n | \"setPreloadedConfiguration\"\n | \"setOnFrameProcessedCallback\"\n | \"setClientInterfaceRequestHandler\"\n | \"provideExternalImage\"\n | \"provideExternalVideo\"\n | \"registerSavePersistentStoreCallback\"\n>;\n\n// NOTE: type of the record ensures newly added asset types break compilation\nexport const AssetType: Record<keyof LensCoreModule[\"AssetType\"], LensCoreAssetType> = {\n DeviceDependent: { value: 3 },\n RemoteMediaByUrl: { value: 6 },\n Static: { value: 1 },\n URL: { value: 2 },\n BitmojiDynamicAsset: { value: 4 },\n};\n\nexport function createLensCore(): LensCoreMock {\n return {\n AssetType,\n CanvasType: { Preview: { value: 1 }, Capture: { value: 2 }, None: { value: 0 }, All: { value: 3 } },\n RenderLoopMode: { SetTimeout: { value: 1 }, RequestAnimationFrame: { value: 0 } },\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L39\n InterfaceAction: { Show: { value: 3 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/502b54b9a663203bcdf3b90c63214cdf8cc1e713/Src/CoreManager/ClientInterfaceDelegate.hpp#L21\n InterfaceControl: { ImagePicker: { value: 1 } } as any,\n // https://github.sc-corp.net/Snapchat/LensCore/blob/2d538ecc41f67dd2c199e0ff0eefd96aac6f22dc/Src/Common/IExternalMediaFilePickedObserver.h#L21\n ExternalMediaOrientation: { CW0: { value: 0 }, CW90: { value: 1 }, CW180: { value: 2 }, CW270: { value: 3 } },\n initialize: jest.fn(),\n setRemoteAssetsProvider: jest.fn(),\n provideRemoteAssetsResponse: jest.fn(),\n getOutputCanvases: jest.fn(),\n setPreloadedConfiguration: jest.fn(),\n setRenderLoopMode: jest.fn(),\n setOnFrameProcessedCallback: jest.fn(),\n setClientInterfaceRequestHandler: jest.fn(),\n provideExternalImage: jest.fn(),\n provideExternalVideo: jest.fn(),\n registerSavePersistentStoreCallback: jest.fn(),\n };\n}\n"]}
@@ -34,6 +34,7 @@ import { registerLogEntriesSubscriber } from "./logger/registerLogEntriesSubscri
34
34
  import { requestStateEventTargetFactory } from "./handlers/requestStateEmittingHandler";
35
35
  import { pageVisibilityFactory } from "./common/pageVisibility";
36
36
  import { cofHandlerFactory } from "./remote-configuration/cofHandler";
37
+ import { remoteApiServicesFactory } from "./extensions/RemoteApiServices";
37
38
  const logger = getLogger("bootstrapCameraKit");
38
39
  // The following errors are not wrapped with BootstrapError and bubble up as is.
39
40
  const nonWrappableErrors = [
@@ -103,6 +104,7 @@ export function bootstrapCameraKit(configuration, provide) {
103
104
  .provides(defaultFetchHandlerFactory)
104
105
  .provides(remoteMediaAssetLoaderFactory)
105
106
  .provides(lensSourcesFactory)
107
+ .provides(remoteApiServicesFactory)
106
108
  .provides(uriHandlersFactory);
107
109
  const publicContainer = provide ? provide(defaultPublicContainer) : defaultPublicContainer;
108
110
  // Now that the client's provide() function has completed and the configuration override is ready,
@@ -120,6 +122,15 @@ export function bootstrapCameraKit(configuration, provide) {
120
122
  .provides(metricsHandlerFactory)
121
123
  .provides(operationalMetricReporterFactory)
122
124
  .provides(reportGlobalException)
125
+ .provides(cofHandlerFactory)
126
+ .provides(remoteConfigurationFactory)
127
+ .provides(legalPromptFactory)
128
+ .provides(legalStateFactory)
129
+ // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container
130
+ // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain
131
+ // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics
132
+ // and sends them to our backend.
133
+ .run(reportGloballyScopedMetrics)
123
134
  .run(businessEventsReporterFactory);
124
135
  // Run the exception logger so that it can subscribe to log events -- we can't use `Container.run()` because
125
136
  // reportGlobalException is also used as a dependency by other Services (and run does not provide Services,
@@ -134,21 +145,12 @@ export function bootstrapCameraKit(configuration, provide) {
134
145
  const lensCore = yield telemetryContainer.provides(lensCoreFactory).get(lensCoreFactory.token);
135
146
  const container = telemetryContainer
136
147
  .provides(Injectable(lensCoreFactory.token, () => lensCore))
137
- .provides(cofHandlerFactory)
138
- .provides(remoteConfigurationFactory)
139
148
  .provides(lensPersistenceStoreFactory)
140
149
  .provides(deviceDependentAssetLoaderFactory)
141
150
  .provides(staticAssetLoaderFactory)
142
151
  .provides(lensAssetRepositoryFactory)
143
152
  .provides(lensRepositoryFactory)
144
- .provides(legalPromptFactory)
145
- .provides(legalStateFactory)
146
- .provides(cameraKitFactory)
147
- // We'll run a PartialContainer containing reporters for globally-scoped metrics. Running this container
148
- // allows each metric reporter to initialize itself (e.g. by adding event listeners to detect when certain
149
- // actions occur). This PartialContainer also includes the service which listens to locally-reported metrics
150
- // and sends them to our backend.
151
- .run(reportGloballyScopedMetrics);
153
+ .provides(cameraKitFactory);
152
154
  const cameraKit = container.get(cameraKitFactory.token);
153
155
  const bootstrapTimeMs = performance.now() - startTimeMs;
154
156
  const reporter = container.get(operationalMetricReporterFactory.token);